Index: /branches/DEV_r1837_MLF/AGRIF/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AA_make	(revision 1844)
@@ -0,0 +1,133 @@
+#- $Id$
+
+TMP=../../../tmp
+
+SRM=/bin/rm -f
+
+#-Q- sx8mercure C_L	= $(FC_L) 
+#-Q- sx8mercure C_O	= $(FC_O) 
+#-Q- sx9mercure C_L	= $(FC_L) 
+#-Q- sx9mercure C_O	= $(FC_O) 
+#-Q- sx8brodie C_L= $(FC_L) 
+#-Q- sx8brodie C_O= $(FC_O) 
+#-Q- sxdkrz C_L	= $(FC_L) 
+#-Q- sxdkrz C_O	= $(FC_O) 
+#-Q- es2 C_L	= $(FC_L) 
+#-Q- es2 C_O	= $(FC_O) 
+#-Q- sx8mercure F_O +=  -Wf"-init heap=zero"
+#-Q- sx9mercure F_O +=  -Wf"-init heap=zero" 
+#-Q- sx8brodie F_O +=   -Wf"-init heap=zero" 
+#-Q- sxdkrz F_O +=  -Wf"-init heap=zero" 
+#-Q- es2 F_O +=  -Wf"-init heap=zero" 
+#-Q- aix F_O = $(w_w) -I$(MODDIR) -qmoddir=$(MODDIR) -qextname
+#-Q- aix6 F_O = $(w_w) -I$(MODDIR) -qmoddir=$(MODDIR) -qextname
+#-Q- osxxlf F_O = $(w_w) -I$(MODDIR) -qmoddir=$(MODDIR) -qextname
+#-Q- linux F_O = $(F_D) $(F_P) -Mfixed -module $(MODDIR)
+
+AGRIFOBJS=AGRIF_OBJS
+AGRIFFILES=AGRIF_FILES
+AGRIFYOURFILES=AGRIF_YOURFILES
+
+FILENAMES= modbc modmpp modcluster modinit modinitvars modinterp  \
+	   modtypes modbcfunction modutil modcurgridfunctions \
+	   modmask modsauv modupdate modinterpbasic\
+	   modupdatebasic modlinktomodel modarrays modflux
+	   
+OBJS1=$(addprefix $(AGRIFOBJS)/,$(FILENAMES))
+OBJS=$(addsuffix .o,$(OBJS1))
+
+
+AGRIF_FILES1=$(addprefix $(AGRIFFILES)/,$(FILENAMES))
+AGRIF_FILES=$(addsuffix .F,$(AGRIF_FILES1))
+
+all :   conv_exe key $(MODDIR)/libagrif.a $(SXMODEL_LIB)
+	@echo AGRIF is OK
+
+conv_exe : 
+	@( cd LIB ; $(M_K) -f Makefile C_L="$(C_L)" C_O="$(C_O)" )
+
+key : 
+	-@if [ "`cat KEY_CPP`" != "$(P_P)" ] ; then \
+	echo "$(P_P)" > KEY_CPP ; fi
+
+$(MODDIR)/libagrif.a : $(OBJS)
+	@$(A_C) $@ $(OBJS)
+
+$(SXMODEL_LIB) : $(OBJS)
+#-Q- sxdkrz     @$(A_X) $@ $(OBJS)
+#-Q- es2     @$(A_X) $@ $(OBJS)
+
+$(AGRIFOBJS)/%.o : $(AGRIFFILES)/%.F KEY_CPP
+	@$(SRM) $(AGRIFYOURFILES)/$(*F).f
+	@$(P_C) $(P_O) $(AGRIFFILES)/$(*F).F > $(AGRIFYOURFILES)/$(*F).f
+	@$(F_C) $(F_O) $(FFLAGS_EXTEND) $(AGRIF_OPTS) -c $(AGRIFYOURFILES)/$(*F).f -o $(AGRIFOBJS)/$(*F).o
+#-Q- linux	@$(SRM) $*.lst
+#-Q- ibm	@$(SRM) $*.lst
+#-Q- aix	@$(SRM) $*.lst
+#-Q- aix6	@$(SRM) $*.lst
+#-Q- sx8mercure	mv *.mod $(MODDIR)
+#-Q- sx9mercure	mv *.mod $(MODDIR)
+#-Q- sx8brodie	mv *.mod $(MODDIR)
+#-Q- sxdkrz	mv *.mod $(MODDIR)
+#-Q- es2	mv *.mod $(MODDIR)
+#-Q- solaris	mv *.mod $(MODDIR)
+
+
+$(AGRIFOBJS)/modarrays.o: $(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modbc.o: $(AGRIFOBJS)/modinterp.o
+
+$(AGRIFOBJS)/modbcfunction.o: $(AGRIFOBJS)/modupdate.o \
+			 $(AGRIFOBJS)/modflux.o  \
+			 $(AGRIFOBJS)/modbc.o 
+
+$(AGRIFOBJS)/modcluster.o: $(AGRIFOBJS)/modsauv.o \
+			$(AGRIFOBJS)/modinitvars.o \
+			$(AGRIFOBJS)/modcurgridfunctions.o
+
+$(AGRIFOBJS)/modcurgridfunctions.o: $(AGRIFOBJS)/modinit.o
+
+$(AGRIFOBJS)/modinit.o: $(AGRIFOBJS)/modlinktomodel.o \
+			$(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modinitvars.o: $(AGRIFOBJS)/modlinktomodel.o \
+			$(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modinterpbasic.o: $(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modinterp.o: $(AGRIFOBJS)/modcurgridfunctions.o \
+			$(AGRIFOBJS)/modmask.o \
+			$(AGRIFOBJS)/modarrays.o \
+			$(AGRIFOBJS)/modmpp.o \
+			$(AGRIFOBJS)/modinterpbasic.o
+
+$(AGRIFOBJS)/modlinktomodel.o: $(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modmask.o: $(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modsauv.o: $(AGRIFOBJS)/modarrays.o \
+			$(AGRIFOBJS)/modlinktomodel.o \
+			$(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modupdatebasic.o: $(AGRIFOBJS)/modtypes.o
+
+$(AGRIFOBJS)/modupdate.o: $(AGRIFOBJS)/modmask.o \
+			$(AGRIFOBJS)/modcurgridfunctions.o \
+			$(AGRIFOBJS)/modarrays.o \
+			$(AGRIFOBJS)/modmpp.o \
+			$(AGRIFOBJS)/modupdatebasic.o
+
+$(AGRIFOBJS)/modutil.o: $(AGRIFOBJS)/modcurgridfunctions.o \
+			$(AGRIFOBJS)/modcluster.o
+
+$(AGRIFOBJS)/modmpp.o: $(AGRIFOBJS)/modtypes.o \
+			$(AGRIFOBJS)/modarrays.o
+
+clean : FORCE
+	$(SRM) $(OBJS) $(MODOBJS)$(LIBDIR)/libagrif.a 
+	
+cleanall : FORCE
+	$(SRM) $(OBJS) $(MODOBJS)$(LIBDIR)/libagrif.a 
+	@(cd LIB ; $(M_K) -f Makefile clean )
+
+FORCE :
Index: /branches/DEV_r1837_MLF/AGRIF/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AA_make.ldef	(revision 1844)
@@ -0,0 +1,29 @@
+#- $Id$
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a AGRIF (lib, config)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../lib
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#--- -DNC_REAL option is needed if compiled in simple precision
+#--- In case you switch to double precision use -DNC_DOUBLE
+#-
+# Compilation:
+#-Q- lxiv7 FFLAGS_EXTEND=  -I..
+#-Q- lxiv8 FFLAGS_EXTEND=  -I..
+#-Q- sun   FFLAGS_EXTEND= -I..
+#-Q- aix   FFLAGS_EXTEND = -I.. -I$(HOME)/include/ -qsuffix=f=f
+#-Q- aix   AGRIF_OPTS = -qfixed -qrecur
+#-Q- aix6  FFLAGS_EXTEND = -I.. -I$(HOME)/include/ -qsuffix=f=f
+#-Q- aix6  AGRIF_OPTS = -qfixed -qrecur
+#-Q- ibm   FFLAGS_EXTEND = -I.. -I$(HOME)/include/ -qsuffix=f=f
+#-Q- ibm   AGRIF_OPTS = -qfixed -qrecur
+#-
+MODEL_LIB = $(LIBDIR)/libagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/libsxagrif.a
+#-
+P_P=$(AGRIF_MPI)
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modarrays.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modarrays.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modarrays.F	(revision 1844)
@@ -0,0 +1,1193 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Arrays
+C      
+      Module Agrif_Arrays
+      Use Agrif_Types
+C
+      implicit none
+C      
+      Contains
+C     **************************************************************************
+CCC   Subroutine Agrif_Childbounds
+C     **************************************************************************
+C
+      Subroutine Agrif_Childbounds(nbdim,lboundloc,uboundloc,
+     &                 pttab,petab,pttruetab,cetruetab,memberin)
+C
+CCC   Description:
+CCC   Subroutine calculating the global indices of the child grid
+C
+C
+C     Declarations:
+C
+
+C
+C     Arguments
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim) :: lboundloc,uboundloc
+      INTEGER,DIMENSION(nbdim) :: pttab,petab,pttruetab,cetruetab
+      LOGICAL :: memberin
+C
+C     Local variables
+      INTEGER :: i,lbglob,ubglob
+C
+#ifdef AGRIF_MPI
+      INTEGER :: indglob1,indglob2
+#endif
+C
+C
+      do i = 1,nbdim
+C
+        lbglob = lboundloc(i)
+        ubglob = uboundloc(i)
+C
+#ifdef AGRIF_MPI
+C
+        Call AGRIF_InvLoc(lbglob,Agrif_ProcRank,i,indglob1)
+C
+        Call AGRIF_InvLoc(ubglob,Agrif_ProcRank,i,indglob2)
+C
+        pttruetab(i) = max(pttab(i),indglob1)        
+C
+        cetruetab(i) = min(petab(i),indglob2)                 
+C
+#else
+C
+        pttruetab(i) = max(pttab(i),lbglob)        
+C
+        cetruetab(i) = min(petab(i),ubglob)
+C
+#endif
+C
+      enddo
+
+      memberin = .TRUE.
+
+      do i=1,nbdim
+        IF (cetruetab(i) < pttruetab(i)) THEN
+          memberin = .FALSE.
+          EXIT
+        ENDIF
+      enddo
+C
+      Return
+C
+C
+      End Subroutine Agrif_Childbounds
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_Get_bound
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_Get_bound(Variable,
+     &                           lower,upper,indice,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to get the lower and the upper boundaries of a
+C     table. Output datas are scalar.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      ! we want extract boundaries of this table
+      TYPE(AGRIF_Variable), Pointer :: Variable    
+      INTEGER              :: lower,upper ! output data
+      ! direction in wich we want to know the dimension
+      INTEGER              :: indice      
+      INTEGER              :: nbdim       ! dimension of the table
+C
+C     Local variables
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+           lower = lbound(Variable % array1,indice)
+           upper = ubound(Variable % array1,indice)
+      CASE (2)
+           lower = lbound(Variable % array2,indice)
+           upper = ubound(Variable % array2,indice)
+      CASE (3)
+           lower = lbound(Variable % array3,indice)
+           upper = ubound(Variable % array3,indice)
+      CASE (4)
+           lower = lbound(Variable % array4,indice)
+           upper = ubound(Variable % array4,indice)
+      CASE (5)
+           lower = lbound(Variable % array5,indice)
+           upper = ubound(Variable % array5,indice)
+      CASE (6)
+           lower = lbound(Variable % array6,indice)
+           upper = ubound(Variable % array6,indice)
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_Get_bound       
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Get_bound_dimension
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_Get_bound_dimension(Variable,
+     &                              lower,upper,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to get the lower and the upper boundaries of a
+C        table. Output datas are scalar.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      ! we want extract boundaries of this table
+      TYPE(AGRIF_Variable), Pointer     :: Variable    
+      INTEGER                  :: nbdim       ! dimension of the table
+      INTEGER,DIMENSION(nbdim) :: lower,upper ! output data
+C
+C     Local variables       
+C
+      lower = Variable % lb(1:nbdim)
+      upper = Variable % ub(1:nbdim)
+      return
+C
+      End Subroutine Agrif_nbdim_Get_bound_dimension     
+      
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_allocation
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_allocation(Variable,inf,sup,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to Allocate the table Variable
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer     :: Variable    
+      INTEGER                  :: nbdim       ! dimension of the table
+      INTEGER,DIMENSION(nbdim) :: inf,sup
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+         allocate(Variable%array1(
+     &            inf(1):sup(1)))
+      CASE (2)
+          allocate(Variable%array2(
+     &            inf(1):sup(1),
+     &            inf(2):sup(2)))
+      CASE (3)
+         allocate(Variable%array3(
+     &            inf(1):sup(1),
+     &            inf(2):sup(2),
+     &            inf(3):sup(3)))
+      CASE (4)
+         allocate(Variable%array4(
+     &            inf(1):sup(1),
+     &            inf(2):sup(2),
+     &            inf(3):sup(3),
+     &            inf(4):sup(4)))
+      CASE (5)
+         allocate(Variable%array5(
+     &            inf(1):sup(1),
+     &            inf(2):sup(2),
+     &            inf(3):sup(3),
+     &            inf(4):sup(4),
+     &            inf(5):sup(5)))
+      CASE (6)
+         allocate(Variable%array6(
+     &            inf(1):sup(1),
+     &            inf(2):sup(2),
+     &            inf(3):sup(3),
+     &            inf(4):sup(4),
+     &            inf(5):sup(5),
+     &            inf(6):sup(6)))
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_allocation
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_deallocation
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_deallocation(Variable,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to give the same value to the table Variable
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer     :: Variable    
+      INTEGER                  :: nbdim       ! dimension of the table
+C
+C     Local variables       
+C
+
+      SELECT CASE (nbdim)
+      CASE (1)
+         Deallocate(Variable%array1)
+      CASE (2)
+         Deallocate(Variable%array2)
+      CASE (3)
+         Deallocate(Variable%array3)
+      CASE (4)
+         Deallocate(Variable%array4)
+      CASE (5)
+         Deallocate(Variable%array5)
+      CASE (6)
+         Deallocate(Variable%array6)
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_deallocation
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_Full_VarEQreal
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_Full_VarEQreal(Variable,Value,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to get the lower and the upper boundaries of a
+C        table. Output datas are scalar.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer :: Variable    
+      REAL                 :: Value       
+      INTEGER              :: nbdim       ! dimension of the table
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+        Variable%array1 = Value      
+      CASE (2)
+        Variable%array2 = Value
+      CASE (3)
+        Call Agrif_set_tozero3D(Variable%array3)
+!        Variable%array3 = Value
+      CASE (4)
+        Variable%array4 = Value
+      CASE (5)
+        Variable%array5 = Value
+      CASE (6)
+        Variable%array6 = Value
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_Full_VarEQreal   
+      
+      Subroutine Agrif_set_tozero3D(tab3D)
+      real,dimension(:,:,:),target :: tab3D
+      
+      tab3D = 0.
+      
+      end subroutine agrif_set_tozero3D    
+C
+C
+#if !defined AGRIF_MPI
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_VarEQreal
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_VarEQreal(Variable,inf,sup,Value,nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to give the same value to a part of 
+C        the table Variable
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer :: Variable    
+      REAL                 :: Value       
+      INTEGER              :: nbdim       ! dimension of the table
+      INTEGER,DIMENSION(nbdim) :: inf,sup
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+         Variable%array1(
+     &             inf(1):sup(1)
+     &             )  = Value
+      CASE (2)
+         Variable%array2(
+     &             inf(1):sup(1),
+     &             inf(2):sup(2)
+     &             )  = Value
+      CASE (3)
+         Variable%array3(
+     &             inf(1):sup(1),
+     &             inf(2):sup(2),
+     &             inf(3):sup(3)
+     &             )  = Value
+      CASE (4)
+         Variable%array4(
+     &             inf(1):sup(1),
+     &             inf(2):sup(2),
+     &             inf(3):sup(3),
+     &             inf(4):sup(4)
+     &             )  = Value
+      CASE (5)
+         Variable%array5(
+     &             inf(1):sup(1),
+     &             inf(2):sup(2),
+     &             inf(3):sup(3),
+     &             inf(4):sup(4),
+     &             inf(5):sup(5)
+     &             )  = Value
+      CASE (6)
+         Variable%array6(
+     &             inf(1):sup(1),
+     &             inf(2):sup(2),
+     &             inf(3):sup(3),
+     &             inf(4):sup(4),
+     &             inf(5):sup(5),
+     &             inf(6):sup(6)
+     &             )  = Value
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_VarEQreal       
+#endif
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_VarEQvar
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_VarEQvar(Variable,inf,sup,
+     &                                Variable2,inf2,sup2,
+     &                                nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to give the value of a part of the table 
+C        Variable2 to the table Variable
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer     :: Variable
+      TYPE(AGRIF_Variable), Pointer     :: Variable2
+      INTEGER                  :: nbdim       ! dimension of the table
+      INTEGER,DIMENSION(nbdim) :: inf,sup
+      INTEGER,DIMENSION(nbdim) :: inf2,sup2
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+         Variable%array1(inf(1):sup(1)) = 
+     &         Variable2%array1(inf2(1):sup2(1))
+      CASE (2)
+     
+      Call Agrif_Copy_2d(Variable%array2,Variable2%array2,
+     &  lbound(Variable%array2),
+     &  lbound(Variable2%array2),
+     &  inf,sup,inf2,sup2)
+          
+      CASE (3)
+
+      Call Agrif_Copy_3d(Variable%array3,Variable2%array3,
+     &  lbound(Variable%array3),
+     &  lbound(Variable2%array3),
+     &  inf,sup,inf2,sup2)
+
+      CASE (4)
+      
+      Call Agrif_Copy_4d(Variable%array4,Variable2%array4,
+     &  lbound(Variable%array4),
+     &  lbound(Variable2%array4),
+     &  inf,sup,inf2,sup2)
+     
+      CASE (5)
+        Variable%array5(inf(1):sup(1),
+     &                         inf(2):sup(2), 
+     &                         inf(3):sup(3),
+     &                         inf(4):sup(4), 
+     &                         inf(5):sup(5)) = 
+     &         Variable2%array5(inf2(1):sup2(1),
+     &                          inf2(2):sup2(2),
+     &                          inf2(3):sup2(3),
+     &                          inf2(4):sup2(4),
+     &                          inf2(5):sup2(5))
+      CASE (6)
+        Variable%array6(inf(1):sup(1),
+     &                         inf(2):sup(2),
+     &                         inf(3):sup(3),
+     &                         inf(4):sup(4),
+     &                         inf(5):sup(5),
+     &                         inf(6):sup(6)) = 
+     &         Variable2%array6(inf2(1):sup2(1),
+     &                          inf2(2):sup2(2),
+     &                          inf2(3):sup2(3),
+     &                          inf2(4):sup2(4),
+     &                          inf2(5):sup2(5),
+     &                          inf2(6):sup2(6))
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_VarEQvar
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_nbdim_Full_VarEQvar
+C     **************************************************************************
+C
+      Subroutine Agrif_nbdim_Full_VarEQvar(Variable,Variable2,
+     &                                nbdim)
+C
+CCC   Description:
+CCC   This subroutine is used to give the value of the table Variable2 
+C        to the table Variable
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_Variable), Pointer     :: Variable
+      TYPE(AGRIF_Variable), Pointer     :: Variable2
+      INTEGER                  :: nbdim       ! dimension of the table
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+          Variable%array1 = Variable2%array1
+      CASE (2)
+          Variable%array2 = Variable2%array2
+      CASE (3)
+          Variable%array3 = Variable2%array3
+      CASE (4)
+          Variable%array4 = Variable2%array4
+      CASE (5)
+          Variable%array5 = Variable2%array5
+      CASE (6)
+          Variable%array6 = Variable2%array6
+      END SELECT
+C
+      return
+C
+      End Subroutine Agrif_nbdim_Full_VarEQvar
+C
+C
+
+C     **************************************************************************
+CCC   Subroutine GiveAgrif_SpecialValueToTab_mpi
+C     **************************************************************************
+C
+      Subroutine GiveAgrif_SpecialValueToTab_mpi(Variable1,Variable2,
+     &                  bound1,lower,upper,Value,nbdim)
+C
+CCC   Description:
+CCC   
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_VARIABLE), Pointer    :: Variable1
+      TYPE(AGRIF_VARIABLE), Pointer    :: Variable2
+      INTEGER                  :: nbdim
+      INTEGER,DIMENSION(:,:,:) :: bound1
+      INTEGER,DIMENSION(nbdim) :: lower,upper
+      REAL                     :: Value
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+             Where (Variable1 % array1(
+     &           bound1(1,1,2):bound1(1,2,2)) 
+     &            == Value)
+             Variable2 % array1(bound1(1,1,1):bound1(1,2,1))
+     &                        = Value
+C      
+              End Where
+      CASE (2)
+             Where (Variable1 % array2(
+     &           bound1(1,1,2):bound1(1,2,2),
+     &           bound1(2,1,2):bound1(2,2,2)) 
+     &            == Value)
+             Variable2 % array2(bound1(1,1,1):bound1(1,2,1),
+     &                       bound1(2,1,1):bound1(2,2,1))
+     &                        = Value
+C      
+              End Where
+      CASE (3)
+             Where (Variable1 % array3(
+     &           bound1(1,1,2):bound1(1,2,2),
+     &                       bound1(2,1,2):bound1(2,2,2),
+     &                       bound1(3,1,2):bound1(3,2,2)) 
+     &            == Value)
+             Variable2 % array3(bound1(1,1,1):bound1(1,2,1),
+     &                       bound1(2,1,1):bound1(2,2,1),
+     &                       bound1(3,1,1):bound1(3,2,1))
+     &                         = Value
+C      
+              End Where
+      CASE (4)
+             Where (Variable1 % array4(
+     &           bound1(1,1,2):bound1(1,2,2),
+     &                       bound1(2,1,2):bound1(2,2,2),
+     &                       bound1(3,1,2):bound1(3,2,2),
+     &                       bound1(4,1,2):bound1(4,2,2)) 
+     &            == Value)
+             Variable2 % array4(bound1(1,1,1):bound1(1,2,1),
+     &                       bound1(2,1,1):bound1(2,2,1),
+     &                       bound1(3,1,1):bound1(3,2,1),
+     &                       bound1(4,1,1):bound1(4,2,1))
+     &                        = Value
+C      
+              End Where
+      CASE (5)
+             Where (Variable1 % array5(
+     &           bound1(1,1,2):bound1(1,2,2),
+     &                       bound1(2,1,2):bound1(2,2,2),
+     &                       bound1(3,1,2):bound1(3,2,2),
+     &                       bound1(4,1,2):bound1(4,2,2),
+     &                       bound1(5,1,2):bound1(5,2,2)) 
+     &            == Value)
+             Variable2 % array5(bound1(1,1,1):bound1(1,2,1),
+     &                       bound1(2,1,1):bound1(2,2,1),
+     &                       bound1(3,1,1):bound1(3,2,1),
+     &                       bound1(4,1,1):bound1(4,2,1),
+     &                       bound1(5,1,1):bound1(5,2,1))
+     &                        = Value
+C      
+              End Where
+      CASE (6)
+             Where (Variable1 % array6(
+     &           bound1(1,1,2):bound1(1,2,2),
+     &                       bound1(2,1,2):bound1(2,2,2),
+     &                       bound1(3,1,2):bound1(3,2,2),
+     &                       bound1(4,1,2):bound1(4,2,2),
+     &                       bound1(5,1,2):bound1(5,2,2),
+     &                       bound1(6,1,2):bound1(6,2,2)) 
+     &            == Value)
+             Variable2 % array6(bound1(1,1,1):bound1(1,2,1),
+     &                       bound1(2,1,1):bound1(2,2,1),
+     &                       bound1(3,1,1):bound1(3,2,1),
+     &                       bound1(4,1,1):bound1(4,2,1),
+     &                       bound1(5,1,1):bound1(5,2,1),
+     &                       bound1(6,1,1):bound1(6,2,1))
+     &                        = Value
+C      
+              End Where
+      END SELECT
+C
+      return
+C
+      End Subroutine GiveAgrif_SpecialValueToTab_mpi    
+
+C     **************************************************************************
+CCC   Subroutine GiveAgrif_SpecialValueToTab
+C     **************************************************************************
+C
+      Subroutine GiveAgrif_SpecialValueToTab(Variable1,Variable2,
+     &                  lower,upper,Value,nbdim)
+C
+CCC   Description:
+CCC   
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_VARIABLE), Pointer    :: Variable1
+      TYPE(AGRIF_VARIABLE), Pointer    :: Variable2
+      INTEGER                  :: nbdim
+      INTEGER,DIMENSION(nbdim) :: lower,upper
+      REAL                     :: Value
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+             Where (Variable1 % array1(
+     &           lower(1):upper(1))
+     &            == Value)
+             Variable2 % array1(lower(1):upper(1))
+     &                        = Value
+C      
+              End Where
+      CASE (2)
+             Where (Variable1 % array2(
+     &           lower(1):upper(1),
+     &           lower(2):upper(2)) 
+     &            == Value)
+             Variable2 % array2(lower(1):upper(1),
+     &                          lower(2):upper(2))
+     &                        = Value
+C      
+              End Where
+      CASE (3)
+             Where (Variable1 % array3(
+     &           lower(1):upper(1),
+     &           lower(2):upper(2), 
+     &           lower(3):upper(3)) 
+     &            == Value)
+             Variable2 % array3(lower(1):upper(1),
+     &                          lower(2):upper(2),
+     &                          lower(3):upper(3))
+     &                         = Value
+C      
+              End Where
+      CASE (4)
+             Where (Variable1 % array4(
+     &           lower(1):upper(1),
+     &           lower(2):upper(2), 
+     &           lower(3):upper(3),
+     &           lower(4):upper(4)) 
+     &            == Value)
+             Variable2 % array4(lower(1):upper(1),
+     &                          lower(2):upper(2),
+     &                          lower(3):upper(3),
+     &                          lower(4):upper(4))
+     &                        = Value
+C      
+              End Where
+      CASE (5)
+             Where (Variable1 % array5(
+     &           lower(1):upper(1),
+     &           lower(2):upper(2),
+     &           lower(3):upper(3),
+     &           lower(4):upper(4),
+     &           lower(5):upper(5)) 
+     &            == Value)
+             Variable2 % array5(lower(1):upper(1),
+     &                          lower(2):upper(2),
+     &                          lower(3):upper(3),
+     &                          lower(4):upper(4),
+     &                          lower(5):upper(5))
+     &                        = Value
+C      
+              End Where
+      CASE (6)
+             Where (Variable1 % array6(
+     &           lower(1):upper(1),
+     &           lower(2):upper(2),
+     &           lower(2):upper(3),
+     &           lower(4):upper(4),
+     &           lower(5):upper(5),
+     &           lower(6):upper(6)) 
+     &            == Value)
+             Variable2 % array6(lower(1):upper(1),
+     &                          lower(2):upper(2),
+     &                          lower(3):upper(3),
+     &                          lower(4):upper(4),
+     &                          lower(5):upper(5),
+     &                          lower(6):upper(6))
+     &                        = Value
+C      
+              End Where
+      END SELECT
+C
+      return
+C
+      End Subroutine GiveAgrif_SpecialValueToTab   
+
+C
+C
+#ifdef AGRIF_MPI
+C     **************************************************************************
+CCC   Subroutine Where_ValTabToTab_mpi
+C     **************************************************************************
+C
+      Subroutine Where_ValTabToTab_mpi(
+     &                  Variable1,Variable2,
+     &                  lower,upper,Value,nbdim)
+C
+CCC   Description:
+CCC   
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+C
+      TYPE(AGRIF_VARIABLE), Pointer     :: Variable1
+      TYPE(AGRIF_VARIABLE), Pointer     :: Variable2
+      INTEGER                  :: nbdim
+      INTEGER,DIMENSION(nbdim) :: lower,upper
+      REAL                     :: Value
+      INTEGER :: i,j,k,l,m,n
+C
+C     Local variables       
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+            DO i = lower(1),upper(1)
+              IF (variable1%array1(i) == Value) then
+                variable1%array1(i)=Variable2%array1(i)
+              ENDIF
+            ENDDO
+      CASE (2)
+            DO j = lower(2),upper(2)
+            DO i = lower(1),upper(1)
+              IF (variable1%array2(i,j) == Value) then
+                variable1%array2(i,j)=Variable2%array2(i,j)
+              ENDIF
+            ENDDO
+            ENDDO
+      CASE (3)
+            DO k = lower(3),upper(3)
+            DO j = lower(2),upper(2)
+            DO i = lower(1),upper(1)
+              IF (variable1%array3(i,j,k) == Value) then
+                variable1%array3(i,j,k)=Variable2%array3(i,j,k)
+              ENDIF
+            ENDDO
+            ENDDO
+            ENDDO
+      CASE (4)
+            DO l = lower(4),upper(4)
+            DO k = lower(3),upper(3)
+            DO j = lower(2),upper(2)
+            DO i = lower(1),upper(1)
+              IF (variable1%array4(i,j,k,l) == Value) then
+                variable1%array4(i,j,k,l)=Variable2%array4(i,j,k,l)
+              ENDIF
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+      CASE (5)
+            DO m = lower(5),upper(5)
+            DO l = lower(4),upper(4)
+            DO k = lower(3),upper(3)
+            DO j = lower(2),upper(2)
+            DO i = lower(1),upper(1)
+              IF (variable1%array5(i,j,k,l,m) == Value) then
+              variable1%array5(i,j,k,l,m)=Variable2%array5(i,j,k,l,m)
+              ENDIF
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+      CASE (6)
+            DO n = lower(6),upper(6)
+            DO m = lower(5),upper(5)
+            DO l = lower(4),upper(4)
+            DO k = lower(3),upper(3)
+            DO j = lower(2),upper(2)
+            DO i = lower(1),upper(1)
+              IF (variable1%array6(i,j,k,l,m,n) == Value) then
+            variable1%array6(i,j,k,l,m,n)=Variable2%array6(i,j,k,l,m,n)
+              ENDIF
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+            ENDDO
+      END SELECT
+C
+      return
+C
+      End Subroutine Where_ValTabToTab_mpi    
+#endif
+
+C     **************************************************************************
+CCC   Subroutine PreProcessToInterpOrUpdate
+C     **************************************************************************
+C
+      Subroutine PreProcessToInterpOrUpdate(parent,child,
+     &             petab_Child,
+     &             pttab_Child,pttab_Parent,
+     &             s_Child,s_Parent,
+     &             ds_Child,ds_Parent,
+     &             nbdim)
+C
+CCC   Description:
+CCC   
+C
+C     Declarations:
+C      
+C     arguments                                   
+      TYPE(AGRIF_PVariable) :: parent   ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child    ! Variable on the child grid
+      INTEGER :: nbdim                  
+      INTEGER,DIMENSION(6) :: pttab_child  
+      INTEGER,DIMENSION(6) :: petab_child      
+      INTEGER,DIMENSION(6) :: pttab_parent  
+      TYPE(AGRIF_Variable), Pointer :: root ! Pointer on the variable of the 
+                                            ! root grid
+      TYPE(Agrif_Grid), Pointer :: Agrif_Child_Gr,Agrif_Parent_Gr
+      REAL, DIMENSION(6) :: s_child,s_parent
+      REAL, DIMENSION(6) :: ds_child,ds_parent
+C     locals variables
+      INTEGER :: n
+      
+C
+C     Arguments      
+C
+
+C
+C     Local variables       
+C
+      Agrif_Child_Gr => Agrif_Curgrid
+      Agrif_Parent_Gr => Agrif_Curgrid % parent
+C
+      root => child % var % root_var 
+C
+C     Number of dimensions of the current grid
+      nbdim = root % nbdim
+C      
+      do n=1,nbdim
+C            
+        Select case(root % interptab(n))
+C
+C       Value of interptab(n) can be either x,y,z or N for a no space 
+C       DIMENSION            
+C
+C         The DIMENSION is 'x'
+          case('x')
+C
+            pttab_Child(n) = root % point(1)
+C            
+            pttab_Parent(n) = root % point(1)
+C        
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(1)
+C
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(1)
+C        
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(1)
+C
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(1)
+C                      
+            if (root % posvar(n).EQ.1) then
+C          
+              petab_Child(n) = pttab_Child(n) + Agrif_Child_Gr%nb(1)
+C        
+              else
+C          
+                petab_Child(n) = pttab_Child(n) + 
+     &                              Agrif_Child_Gr%nb(1) - 1
+C          
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+C
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+C        
+            endif                  
+C
+C         The DIMENSION is 'y'
+          case('y')
+C
+            pttab_Child(n) = root % point(2)
+C            
+            pttab_Parent(n) = root % point(2)
+C        
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(2)
+C
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(2) 
+C        
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(2)
+C
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(2)
+C                      
+            if (root % posvar(n).EQ.1) then
+C          
+             petab_Child(n) = pttab_Child(n) + Agrif_Child_Gr%nb(2)
+C          
+              else
+C          
+                petab_Child(n) = pttab_Child(n) + 
+     &                       Agrif_Child_Gr%nb(2) - 1
+C          
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+C
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+C        
+            endif
+            
+C
+C         The DIMENSION is 'z'                            
+          case('z')
+C
+            pttab_Child(n) = root % point(3)
+C            
+            pttab_Parent(n) = root % point(3)
+C        
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(3)
+C
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(3)
+C        
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(3)
+C
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(3)
+C                      
+            if (root % posvar(n).EQ.1) then
+C          
+             petab_Child(n) = pttab_Child(n) + Agrif_Child_Gr%nb(3)
+C          
+              else
+C          
+                petab_Child(n) = pttab_Child(n) + 
+     &                      Agrif_Child_Gr%nb(3) - 1
+C
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+C
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+C        
+            endif       
+C 
+C         The DIMENSION is not space                            
+          case('N')
+C
+C         The next coefficients are calculated in order to do a simple copy of 
+C         values of the grid variable when the procedure of interpolation is 
+C         called for this DIMENSION 
+C      
+            Call Agrif_nbdim_Get_bound(child % var,
+     &                           pttab_Child(n),petab_Child(n),n,nbdim)
+C
+C           No interpolation but only a copy of the values of the grid variable
+C
+            pttab_Parent(n) = pttab_Child(n)
+C              
+            s_Child(n)=0.
+C      
+            s_Parent(n)=0. 
+C      
+            ds_Child(n)=1.
+C      
+            ds_Parent(n)=1.
+C
+        End select
+C            
+      enddo     
+C
+      return
+C
+      End Subroutine PreProcessToInterpOrUpdate     
+
+#ifdef AGRIF_MPI
+C
+C     **************************************************************************
+CCC   Subroutine GetLocalBoundaries
+C     **************************************************************************
+C
+      Subroutine GetLocalBoundaries(tab1,tab2,i,lb,ub,deb,fin)
+C
+CCC   Descritpion:
+C 
+C
+C     Declarations:
+C
+
+C
+C
+C     Scalar arguments
+      INTEGER  ::  tab1,tab2
+      INTEGER  ::  i
+      INTEGER  ::  lb,ub
+      INTEGER  ::  deb,fin
+C
+C     Local scalars
+      INTEGER  ::  imin,imax
+      INTEGER  ::  i1,i2
+C
+C
+      Call AGRIF_InvLoc(lb,AGRIF_ProcRank,i,imin)
+C
+      Call AGRIF_InvLoc(ub,AGRIF_ProcRank,i,imax)
+C
+C
+      if (imin > tab2) then
+C
+          i1 = imax - imin
+C
+        else
+C
+          i1 = max(tab1 - imin,0)
+C
+      endif
+C
+      if (imax < tab1) then
+C
+          i2 = -(imax - imin)
+C
+        else
+C
+          i2 = min(tab2 - imax,0)
+C
+      endif
+C
+      deb = lb + i1
+C
+      fin = ub + i2
+C
+C
+      End Subroutine GetLocalBoundaries
+C
+#endif
+C
+C
+#ifdef AGRIF_MPI
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_GlobtoLocInd2
+C     **************************************************************************
+C
+      Subroutine Agrif_GlobtoLocInd2(tabarray,lboundl,uboundl,tab1,tab2,
+     &                              nbdim,rank,member)
+C
+CCC   Description:
+CCC   For a global index located on the current processor, tabarray gives the 
+CCC   corresponding local index   
+C
+C
+C     Declarations:
+C
+
+C
+C     Arguments
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim) :: tab1,tab2
+      INTEGER,DIMENSION(nbdim,2,2 ) :: tabarray
+      INTEGER,DIMENSION(nbdim) :: lboundl,uboundl
+      INTEGER :: rank
+      LOGICAL :: member
+C    
+C     Local variables
+      INTEGER :: i,i1,k
+      INTEGER :: nbloc(nbdim)
+C
+C
+      tabarray(:,1,:) =  HUGE(1)
+      tabarray(:,2,:) =  -HUGE(1)
+
+      nbloc = 0
+C        
+      do i = 1,nbdim
+C       
+        Call Agrif_Invloc(lboundl(i),rank,i,i1)
+        
+        do k=tab1(i)+lboundl(i)-i1,tab2(i)+lboundl(i)-i1
+          IF ((k .GE. lboundl(i)) .AND. (k.LE.uboundl(i))) THEN
+            nbloc(i) = 1
+            tabarray(i,1,1) = min(tabarray(i,1,1),k-lboundl(i)+i1)
+            tabarray(i,2,1) = max(tabarray(i,2,1),k-lboundl(i)+i1)
+        
+            tabarray(i,1,2) = min(tabarray(i,1,2),k)
+            tabarray(i,2,2) = max(tabarray(i,2,2),k)
+          ENDIF
+        enddo
+C
+      enddo
+
+      member = .FALSE.
+      IF (sum(nbloc) == nbdim) member = .TRUE.
+C
+      Return
+C
+C
+      End Subroutine Agrif_GlobtoLocInd2
+C
+#endif      
+
+      Subroutine Agrif_Copy_2d(tabout,tabin,l,m,inf,sup,inf2,sup2)
+      integer,dimension(2) :: l,m,inf,sup,inf2,sup2
+      real,target,dimension(l(1):,l(2):) :: tabout
+      real,target,dimension(m(1):,m(2):) :: tabin
+          tabout(inf(1):sup(1),
+     &                         inf(2):sup(2)) = 
+     &         tabin(inf2(1):sup2(1),
+     &                          inf2(2):sup2(2))
+      End Subroutine Agrif_Copy_2d
+      
+      Subroutine Agrif_Copy_3d(tabout,tabin,l,m,inf,sup,inf2,sup2)
+      integer,dimension(3) :: l,m,inf,sup,inf2,sup2
+      real,target,dimension(l(1):,l(2):,l(3):) :: tabout
+      real,target,dimension(m(1):,m(2):,m(3):) :: tabin
+          tabout(inf(1):sup(1),
+     &                         inf(2):sup(2), 
+     &                         inf(3):sup(3)) = 
+     &         tabin(inf2(1):sup2(1),
+     &                          inf2(2):sup2(2),
+     &                          inf2(3):sup2(3))
+      End Subroutine Agrif_Copy_3d
+      
+      Subroutine Agrif_Copy_4d(tabout,tabin,l,m,inf,sup,inf2,sup2)
+      integer,dimension(4) :: l,m,inf,sup,inf2,sup2
+      real,target,dimension(l(1):,l(2):,l(3):,l(4):) :: tabout
+      real,target,dimension(m(1):,m(2):,m(3):,m(4):) :: tabin
+          tabout(inf(1):sup(1),
+     &                         inf(2):sup(2), 
+     &                         inf(3):sup(3), 
+     &                         inf(4):sup(4)) = 
+     &         tabin(inf2(1):sup2(1),
+     &                          inf2(2):sup2(2),
+     &                          inf2(3):sup2(3),
+     &                          inf2(4):sup2(4))
+      End Subroutine Agrif_Copy_4d      
+
+      End Module Agrif_Arrays
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbc.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbc.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbc.F	(revision 1844)
@@ -0,0 +1,1337 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Boundary 
+C 
+      Module Agrif_Boundary  
+C
+CCC   Description:
+CCC   Module to calculate the boundary conditions on the child grids from their
+CCC   parent grids.
+C
+C     Modules used:  
+C   
+      Use Agrif_Interpolation        
+C
+      IMPLICIT NONE
+C        
+      CONTAINS   
+C     Define procedures contained in this module
+C
+C
+      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_1d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_1d(TypeInterp,parent,child,tab,deb,fin,
+     &                              weight,pweight,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 1D 
+CCC   grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      External :: procname
+      Optional :: procname
+      INTEGER,DIMENSION(6,6) :: TypeInterp    ! TYPE of interpolation (linear, 
+                                            ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent       ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child        ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp    ! Temporary variable on the child 
+                                            ! grid
+      INTEGER :: deb,fin                    ! Positions where interpolations are
+                                            ! done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1) 
+     &    ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                    ! Indicates if weight is used for  
+                                            ! the temporal interpolation 
+      REAL :: weight                        ! Coefficient for the time 
+                                            ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid
+C     variable.   
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var
+C      
+C     Values of the grid variable
+      childtemp % var % array1 => tab  
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation 
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade   
+      childtemp % var % list_interp => child % var% list_interp 
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub         
+C
+C     Call to the procedure for the calculations of the boundary conditions
+      IF (present(procname)) THEN
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname)
+      ELSE
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+      ENDIF
+
+C   
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp
+C         
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_1D
+C
+      
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_2d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_2d(TypeInterp,parent,child,tab,deb,fin,
+     &                              weight,pweight,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 2D 
+CCC   grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      External :: procname
+      Optional :: procname
+      INTEGER,DIMENSION(6,6) :: TypeInterp    ! TYPE of interpolation (linear, 
+                                            ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent       ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child        ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp    ! Temporary variable on the child 
+                                            ! grid
+      INTEGER :: deb,fin                    ! Positions where interpolations are
+                                            ! done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2) 
+     &    ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                    ! Indicates if weight is used for  
+                                            ! the temporal interpolation 
+      REAL :: weight                        ! Coefficient for the time 
+                                            ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid
+C     variable.   
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var
+C      
+C     Values of the grid variable
+      childtemp % var % array2 => tab  
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation 
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade   
+      childtemp % var % list_interp => child % var% list_interp 
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub         
+C
+C     Call to the procedure for the calculations of the boundary conditions
+      IF (present(procname)) THEN
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname)
+      ELSE
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+      ENDIF
+
+C   
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp
+C         
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_2D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_3d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_3d(TypeInterp,parent,child,tab,deb,fin,
+     &                              weight,pweight,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 3D 
+CCC   variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments 
+      External :: procname
+      Optional :: procname     
+      INTEGER,DIMENSION(6,6) :: TypeInterp    ! TYPE of interpolation (linear, 
+                                            ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent       ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child        ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp    ! Temporary variable on the child
+                                            ! grid
+      INTEGER :: deb,fin                    ! Positions where interpolations 
+                                            ! are done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3)
+     &         ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                    ! Indicates if weight is used for 
+                                            ! the temporal interpolation 
+      REAL :: weight                        ! Coefficient for the time 
+                                            ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid 
+C     variable.  
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var       
+C      
+C     Values of the grid variable
+      childtemp % var % array3 => tab
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation  
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade 
+      childtemp % var % list_interp => child % var% list_interp 
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub
+C
+C     Call to the procedure for the calculations of the boundary conditions     
+      IF (present(procname)) THEN
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname)
+      ELSE
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+      ENDIF
+C
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp      
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_3D               
+C
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_4d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_4d(TypeInterp,parent,child,tab,deb,fin,
+     &                             weight,pweight,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 4D 
+CCC   grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      External :: procname
+      Optional :: procname     
+      INTEGER,DIMENSION(6,6) :: TypeInterp      ! TYPE of interpolation (linear, 
+                                              ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent         ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child          ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp      ! Temporary varaiable on the child
+                                              ! grid
+      INTEGER :: deb,fin                      ! Positions where interpolations 
+                                              ! are done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4)
+     &        ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                      ! Indicates if weight is used for 
+                                              ! the temporal interpolation 
+      REAL :: weight                          ! Coefficient for the time 
+                                              ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid 
+C     variable.  
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var 
+C      
+C     Values of the grid variable
+      childtemp % var % array4 => tab  
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation       
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade  
+      childtemp % var % list_interp => child % var% list_interp 
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub               
+C
+C     Call to the procedure for the calculations of the boundary conditions
+      IF (present(procname)) THEN
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname)
+      ELSE
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+      ENDIF
+C
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp      
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_4D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_5d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_5d(TypeInterp,parent,child,tab,deb,fin,
+     &                             weight,pweight,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 5D 
+CCC   grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      External :: procname
+      Optional :: procname     
+      INTEGER,DIMENSION(6,6) :: TypeInterp      ! TYPE of interpolation (linear, 
+                                              ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent         ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child          ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp      ! Temporary varaiable on the child
+                                              ! grid
+      INTEGER :: deb,fin                      ! Positions where interpolations 
+                                              ! are done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4),
+     &         child%var%lb(5):child%var%ub(5)
+     &         ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                      ! Indicates if weight is used for 
+                                              ! the temporal interpolation 
+      REAL :: weight                          ! Coefficient for the time 
+                                              ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid 
+C     variable.  
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var 
+C      
+C     Values of the grid variable
+      childtemp % var % array5 => tab  
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation       
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade 
+      childtemp % var % list_interp => child % var% list_interp  
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub
+                     
+C
+C     Call to the procedure for the calculations of the boundary conditions  
+      IF (present(procname)) THEN
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight,procname)
+      ELSE
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+      ENDIF
+C
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp      
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_5D
+C
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_bc_6d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_bc_6d(TypeInterp,parent,child,tab,deb,fin,
+     &                             weight,pweight)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid for a 6D 
+CCC   grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER,DIMENSION(6,6) :: TypeInterp      ! TYPE of interpolation (linear, 
+                                              ! lagrange, spline, ... )
+      TYPE(AGRIF_PVariable) :: parent         ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child          ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp      ! Temporary varaiable on the child
+                                              ! grid
+      INTEGER :: deb,fin                      ! Positions where interpolations 
+                                              ! are done on the fine grid 
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4),
+     &         child%var%lb(5):child%var%ub(5),
+     &         child%var%lb(6):child%var%ub(6)
+     &         ), Target :: tab ! Values of the grid variable
+      LOGICAL :: pweight                      ! Indicates if weight is used for 
+                                              ! the temporal interpolation 
+      REAL :: weight                          ! Coefficient for the time 
+                                              ! interpolation
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE representing the grid 
+C     variable.  
+C
+      allocate(childtemp % var)  
+C
+      childtemp % var % root_var => child % var % root_var 
+C      
+C     Values of the grid variable
+      childtemp % var % array6 => tab  
+C
+C     Temporary results for the time interpolation before and after the space 
+C     interpolation       
+      childtemp % var % oldvalues2D => child % var % oldvalues2D
+C 
+C     Index indicating if a space interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &                 child % var % Interpolationshouldbemade 
+      childtemp % var % list_interp => child % var% list_interp  
+      
+      childtemp % var% lb = child % var % lb
+      childtemp % var% ub = child % var % ub               
+C
+C     Call to the procedure for the calculations of the boundary conditions
+      Call Agrif_CorrectVariable
+     &     (TypeInterp,parent,childtemp,deb,fin,pweight,weight)
+C
+      child % var % oldvalues2D => childtemp % var % oldvalues2D
+      child % var % list_interp => childtemp % var %list_interp      
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_bc_6D
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_CorrectVariable
+C     **************************************************************************
+C
+      Subroutine AGRIF_CorrectVariable(TypeInterp,parent,child,deb,fin,
+     &                                 pweight,weight,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions on a fine grid.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments
+      External :: procname
+      Optional :: procname
+      TYPE(AGRIF_PVariable) :: parent         ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child          ! Variable on the child grid
+      INTEGER,DIMENSION(6,6)  :: TypeInterp     ! TYPE of interpolation
+                                              !    (linear,lagrange,...)
+      INTEGER               :: deb,fin        ! Positions where boundary
+                                              !    conditions are calculated
+      LOGICAL               :: pweight        ! Indicates if weight is used 
+                                              !    for the time interpolation 
+      REAL                  :: weight         ! Coefficient for the time
+                                              !    interpolation
+C
+C     Local scalars
+      TYPE(Agrif_Grid)    , Pointer :: Agrif_Child_Gr,Agrif_Parent_Gr
+      TYPE(AGRIF_Variable), Pointer :: root   ! Variable on the root grid
+      INTEGER                       :: nbdim  ! Number of dimensions of 
+                                              !    the grid variable 
+      INTEGER                       :: n
+      INTEGER,DIMENSION(6)          :: pttab_child  ! Index of the first point
+                                                    !    inside the domain for
+                                                    !    the child grid variable
+      INTEGER,DIMENSION(6)          :: pttab_parent ! Index of the first point
+                                                    !    inside the domain for
+                                                    !    the parent grid
+                                                    !    variable
+      INTEGER,DIMENSION(6)          :: nbtab_Child  ! Number of the cells
+      INTEGER,DIMENSION(6)          :: posvartab_Child    ! Position of the
+                                                    !    variable on the cell 
+      INTEGER,DIMENSION(6)          :: loctab_Child ! Indicates if the child
+                                                    !    grid has a common
+                                                    !    border with the root
+                                                    !    grid      
+      REAL, DIMENSION(6)            :: s_child,s_parent   ! Positions of the
+                                                    !    parent and child grids
+      REAL, DIMENSION(6)            :: ds_child,ds_parent ! Space steps of the
+                                                    !    parent and child grids 
+C
+C
+      loctab_child(:) = 0
+C
+      Agrif_Child_Gr => Agrif_Curgrid
+      Agrif_Parent_Gr => Agrif_Curgrid % parent
+      root => child % var % root_var 
+      nbdim = root % nbdim
+C
+      do n = 1,nbdim
+        posvartab_child(n) = root % posvar(n)      
+      enddo
+C
+C
+      do n = 1,nbdim
+C
+        Select case(root % interptab(n))
+C
+          case('x') ! x DIMENSION
+C
+            nbtab_Child(n) = Agrif_Child_Gr % nb(1)
+            pttab_Child(n) = root % point(1)
+            pttab_Parent(n) = root % point(1)
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(1)
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(1)
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(1)
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(1)
+            if (root % posvar(n) == 2) then
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+            endif
+C
+            if (Agrif_CURGRID % NearRootBorder(1)) 
+     &         loctab_child(n) = -1
+            if (Agrif_CURGRID % DistantRootBorder(1))
+     &         loctab_child(n) = -2
+            if ((Agrif_CURGRID % NearRootBorder(1)) .AND. 
+     &          (Agrif_CURGRID % DistantRootBorder(1))) 
+     &         loctab_child(n) = -3
+C
+          case('y') ! y DIMENSION      
+C
+            nbtab_Child(n) = Agrif_Child_Gr % nb(2)
+            pttab_Child(n) = root % point(2)
+            pttab_Parent(n) = root % point(2)
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(2)
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(2) 
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(2)
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(2)
+            if (root % posvar(n) == 2) then        
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+            endif        
+C
+            if (Agrif_CURGRID % NearRootBorder(2)) 
+     &         loctab_child(n) = -1
+            if (Agrif_CURGRID % DistantRootBorder(2)) 
+     &         loctab_child(n) = -2
+            if ((Agrif_CURGRID % NearRootBorder(2)) .AND. 
+     &          (Agrif_CURGRID % DistantRootBorder(2))) 
+     &         loctab_child(n) = -3
+C
+          case('z') ! z DIMENSION
+C
+            nbtab_Child(n) = Agrif_Child_Gr % nb(3)
+            pttab_Child(n) = root % point(3)
+            pttab_Parent(n) = root % point(3)
+            s_Child(n) = Agrif_Child_Gr % Agrif_x(3)
+            s_Parent(n) = Agrif_Parent_Gr % Agrif_x(3)
+            ds_Child(n) = Agrif_Child_Gr % Agrif_d(3)
+            ds_Parent(n) = Agrif_Parent_Gr % Agrif_d(3)
+            if (root % posvar(n) == 2) then        
+                s_Child(n) = s_Child(n) + ds_Child(n)/2.
+                s_Parent(n) = s_Parent(n) + ds_Parent(n)/2.
+            endif        
+C
+            if (Agrif_CURGRID % NearRootBorder(3)) 
+     &         loctab_child(n) = -1
+            if (Agrif_CURGRID % DistantRootBorder(3)) 
+     &         loctab_child(n) = -2
+            if ((Agrif_CURGRID % NearRootBorder(3)) .AND. 
+     &          (Agrif_CURGRID % DistantRootBorder(3))) 
+     &         loctab_child(n) = -3
+C
+          case('N') ! No space DIMENSION      
+C
+            nbtab_Child(n) = child % var % ub(n) - child % var % lb(n)
+            pttab_Child(n) = child % var % lb(n)
+C
+C           No interpolation but only a copy of the values of the grid variable
+C      
+            posvartab_child(n) = 1
+            pttab_Parent(n)= pttab_Child(n)
+            s_Child(n)=0.
+            s_Parent(n)=0. 
+            ds_Child(n)=1.
+            ds_Parent(n)=1.
+            loctab_child(n) = -3
+C
+        End select
+C
+      enddo
+C
+         IF (present(procname)) THEN
+          Call AGRIF_CorrectnD
+     &         (TypeInterp,parent,child,deb,fin,pweight,weight,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim,procname)
+        ELSE
+          Call AGRIF_CorrectnD
+     &         (TypeInterp,parent,child,deb,fin,pweight,weight,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim)
+         ENDIF
+C
+C
+      End subroutine AGRIF_CorrectVariable
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Correctnd
+C     **************************************************************************
+C
+      Subroutine AGRIF_Correctnd(TypeInterp,parent,child,deb,fin,
+     &                           pweight,weight,
+     &                           pttab_child,pttab_Parent,
+     &                           nbtab_Child,posvartab_Child,
+     &                           loctab_Child,
+     &                           s_Child,s_Parent,
+     &                           ds_Child,ds_Parent,nbdim,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions for a nD grid variable on 
+CCC   a fine grid by using a space and time interpolations; it is called by the 
+CCC   Agrif_CorrectVariable procedure.
+C
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+C
+#include "mpif.h"
+C
+#endif
+C
+C     Arguments
+      External :: procname
+      Optional :: procname
+      INTEGER,DIMENSION(6,6) :: TypeInterp ! TYPE of interpolation (linear, 
+                                         !   spline,...)  
+      TYPE(AGRIF_PVariable)    :: parent ! Variable on the parent grid
+      TYPE(AGRIF_PVariable)    :: child  ! Variable on the child grid 
+      INTEGER                  :: deb,fin ! Positions where interpolations 
+                                         !    are done
+      LOGICAL                  :: pweight ! Indicates if weight is used for 
+                                         !    the temporal interpolation
+      REAL                     :: weight ! Coefficient for the temporal
+                                         !    interpolation
+      INTEGER                  :: nbdim  ! Number of dimensions of the grid
+                                         !    variable
+      INTEGER,DIMENSION(nbdim) :: pttab_child ! Index of the first point inside
+                                         !    the domain for the parent 
+                                         !    grid variable
+      INTEGER,DIMENSION(nbdim) :: pttab_Parent ! Index of the first point 
+                                         !   inside the domain for the 
+                                         !   child grid variable
+      INTEGER,DIMENSION(nbdim) :: nbtab_Child ! Number of cells of the child
+                                         !    grid
+      INTEGER,DIMENSION(nbdim) :: posvartab_Child ! Position of the grid
+                                         !    variable (1 or 2)
+      INTEGER,DIMENSION(nbdim) :: loctab_Child ! Indicates if the child 
+                                        !    grid has a common border with 
+                                        !    the root grid
+      REAL   ,DIMENSION(nbdim) :: s_Child,s_Parent ! Positions of the parent 
+                                        !   and child grids 
+      REAL   ,DIMENSION(nbdim) :: ds_Child,ds_Parent ! Space steps of the 
+                                        !    parent and child grids
+C
+C     Local variables
+      TYPE(AGRIF_PVariable)        :: restore ! Variable on the parent     
+      INTEGER,DIMENSION(nbdim,2)   :: lubglob
+      INTEGER                      :: i          
+      INTEGER                      :: kindex  ! Index used for safeguard 
+                                       !    and time interpolation
+      INTEGER,DIMENSION(nbdim,2,2) :: indtab ! Arrays indicating the limits 
+                                       !    of the child     
+      INTEGER,DIMENSION(nbdim,2,2) :: indtruetab ! grid variable where 
+                                       !   boundary conditions are 
+      INTEGER,DIMENSION(nbdim,2,2,nbdim)   :: ptres,ptres2 ! calculated
+      INTEGER                      :: nb,ndir,n,sizetab(1)
+      REAL, DIMENSION(:), Allocatable :: tab ! Array used for the interpolation
+      REAL    :: c1t,c2t               ! Coefficients for the time interpolation
+                                       !    (c2t=1-c1t) 
+C
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim)   :: lower,upper
+      INTEGER,DIMENSION(nbdim)   :: ltab,utab
+      INTEGER,DIMENSION(nbdim)   :: lb,ub
+      INTEGER,DIMENSION(nbdim,2) :: iminmaxg
+      INTEGER                    :: code
+C
+#endif            
+C      
+C
+      indtab(1:nbdim,2,1) = pttab_child(1:nbdim) + nbtab_child(1:nbdim)
+     &          + deb
+      indtab(1:nbdim,2,2) = indtab(1:nbdim,2,1) + ( fin - deb )
+       
+      indtab(1:nbdim,1,1) = pttab_child(1:nbdim) - fin
+      indtab(1:nbdim,1,2) = pttab_child(1:nbdim) - deb
+                  
+      WHERE (posvartab_child(1:nbdim) == 2)
+        indtab(1:nbdim,1,1) = indtab(1:nbdim,1,1) - 1
+        indtab(1:nbdim,1,2) = indtab(1:nbdim,1,2) - 1
+      END WHERE
+      
+
+#if !defined AGRIF_MPI
+      Call Agrif_nbdim_Get_bound_dimension(child%var,lubglob(:,1),
+     &              lubglob(:,2),nbdim)
+C
+#else
+C     
+      Call Agrif_nbdim_Get_bound_dimension(child%var,lb,ub,nbdim)
+      
+      DO i = 1,nbdim
+C
+        Call Agrif_Invloc(lb(i),Agrif_Procrank,i,iminmaxg(i,1))
+        Call Agrif_Invloc(ub(i),Agrif_Procrank,i,iminmaxg(i,2))
+C
+      ENDDO
+C
+      iminmaxg(1:nbdim,2) = - iminmaxg(1:nbdim,2)
+      
+      CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
+     &                     MPI_COMM_AGRIF,code)  
+     
+      lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
+C
+#endif 
+C     
+      indtruetab(1:nbdim,1,1) = max(indtab(1:nbdim,1,1),
+     &     lubglob(1:nbdim,1))
+      indtruetab(1:nbdim,1,2) = max(indtab(1:nbdim,1,2),
+     &     lubglob(1:nbdim,1))
+      indtruetab(1:nbdim,2,1) = min(indtab(1:nbdim,2,1),
+     &     lubglob(1:nbdim,2))
+      indtruetab(1:nbdim,2,2) = min(indtab(1:nbdim,2,2),
+     &     lubglob(1:nbdim,2))
+
+                              
+C 
+C
+      do nb = 1,nbdim
+C
+        do ndir = 1,2      
+C
+          if (loctab_child(nb) /= (-ndir) 
+     &        .AND. loctab_child(nb) /= -3) then
+C           
+              do n = 1,2
+C
+                ptres(nb,n,ndir,nb) = indtruetab(nb,ndir,n)  
+C
+              enddo              
+C
+              do i = 1,nbdim
+C     
+                if (i .NE. nb) then      
+C
+                    if (loctab_child(i) == -1 
+     &                                 .OR. loctab_child(i) == -3) then
+C
+                        ptres(i,1,ndir,nb) = pttab_child(i)
+C
+                      else
+C
+                        ptres(i,1,ndir,nb) = indtruetab(i,1,1)
+C
+                    endif
+C
+                    if (loctab_child(i) == -2 
+     &                                 .OR. loctab_child(i) == -3) then
+C
+                        if (posvartab_child(i) == 1) then
+C
+                            ptres(i,2,ndir,nb) = pttab_child(i)
+     &                                                 + nbtab_child(i)
+C
+                          else
+C
+                            ptres(i,2,ndir,nb) = pttab_child(i)
+     &                                             + nbtab_child(i) - 1
+C
+                        endif                             
+C
+                      else
+C
+                        ptres(i,2,ndir,nb) = indtruetab(i,2,2)
+C
+                    endif                        
+C      
+                endif
+C      
+              enddo
+      
+C
+#if defined AGRIF_MPI
+                 Call Agrif_nbdim_Get_bound_dimension
+     &                    (child%var,lower,upper,nbdim)
+
+              do i = 1,nbdim
+C
+                 Call GetLocalBoundaries(ptres(i,1,ndir,nb),
+     &                                  ptres(i,2,ndir,nb),i,
+     &                                  lower(i),upper(i),
+     &                                  ltab(i),utab(i))
+                 ptres2(i,1,ndir,nb) = max(ltab(i),lower(i)) 
+                 ptres2(i,2,ndir,nb) = min(utab(i),upper(i))
+                 if ((i == nb) .AND. (ndir == 1)) then 
+                     ptres2(i,2,ndir,nb) = max(utab(i),lower(i))
+                 elseif ((i == nb) .AND. (ndir == 2)) then
+                     ptres2(i,1,ndir,nb) = min(ltab(i),upper(i)) 
+                 endif
+C
+              enddo
+#else
+              ptres2(:,:,ndir,nb) = ptres(:,:,ndir,nb)
+#endif      
+            
+        endif
+      
+        enddo
+       enddo
+C
+      if (child % var % interpIndex 
+     &        /= Agrif_Curgrid % parent % ngridstep .OR.
+     &    child%var%Interpolationshouldbemade ) then
+C
+C     Space interpolation 
+C      
+      kindex = 1    
+      
+
+C
+      do nb = 1,nbdim
+C
+        do ndir = 1,2
+C
+          if (loctab_child(nb) /= (-ndir) 
+     &        .AND. loctab_child(nb) /= -3) then  
+C
+              IF (present(procname)) THEN
+              Call Agrif_InterpnD
+     &             (TYPEInterp(nb,:),parent,child,
+     &              ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              restore,.FALSE.,nbdim,procname)
+              ELSE
+              Call Agrif_InterpnD              
+     &             (TYPEInterp(nb,:),parent,child,
+     &              ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              restore,.FALSE.,nbdim)
+              ENDIF
+     
+              IF (.NOT. child%var%interpolationshouldbemade) THEN
+C     
+C             Safeguard of the values of the grid variable (at times n and n+1
+C                on the parent grid)
+C      
+              sizetab(1) = 1
+C
+              do i = 1,nbdim
+C          
+                sizetab(1) = sizetab(1)
+     &              * (ptres2(i,2,ndir,nb)-ptres2(i,1,ndir,nb)+1)
+C      
+              enddo
+
+              Call saveAfterInterp(child,
+     &           ptres2(:,:,ndir,nb),kindex,sizetab(1),nbdim)
+C
+           ENDIF
+C
+          endif
+C
+        enddo       
+C
+      enddo     
+C
+C
+      child % var % interpIndex = Agrif_Curgrid % parent % ngridstep
+C
+C
+      endif  
+      
+              IF (.NOT. child%var%interpolationshouldbemade) THEN
+C
+C
+C     Calculation of the coefficients c1t and c2t for the temporary
+C        interpolation
+      if (pweight) then
+C
+          c1t = weight
+C
+        else
+C
+          c1t = (REAL(AGRIF_Nbstepint()) + 1.) / Agrif_Rhot()
+C
+      endif
+C                                  
+      c2t = 1. - c1t
+C           
+C     Time interpolation
+C
+      kindex = 1
+C
+      do nb = 1,nbdim
+C
+        do ndir = 1,2      
+C
+          if (loctab_child(nb) /= (-ndir) 
+     &        .AND. loctab_child(nb) /= -3) then
+
+              Call timeInterpolation
+     &             (child,ptres2(:,:,ndir,nb),kindex,c1t,c2t,nbdim)
+          endif
+C
+        enddo
+C      
+      enddo
+C      
+
+       ENDIF
+C  
+      End Subroutine Agrif_Correctnd
+C
+C
+C     **************************************************************************
+CCC   Subroutine saveAfterInterp
+C     **************************************************************************
+C
+      Subroutine saveAfterInterp(child,bounds,kindex,newsize,nbdim)
+C
+CCC   Descritpion:
+CCC   Subroutine used to save the values of the grid variable on the fine grid 
+CCC   after the space interpolation. 
+C
+C     Declarations:
+C
+      
+C
+C     argument
+      TYPE (AGRIF_PVariable) :: child   ! The fine grid variable
+      INTEGER                :: kindex  ! Index indicating where this safeguard 
+                                        ! is done on the fine grid
+      INTEGER :: nbdim, newsize
+      INTEGER,DIMENSION(nbdim,2) :: bounds
+C
+C     Local scalars
+      INTEGER                      :: ir,jr,kr,lr,mr,nr
+C
+C
+C     Allocation of the array oldvalues2d
+
+C
+      if (newsize .LE. 0) return
+C
+      Call Agrif_Checksize
+     &     (child,kindex+newsize)  
+
+      if (child % var % interpIndex 
+     &        /= Agrif_Curgrid % parent % ngridstep ) then
+       child%var%oldvalues2d(1,kindex:kindex+newsize-1)=
+     &        child%var%oldvalues2d(2,kindex:kindex+newsize-1)
+      endif
+
+      SELECT CASE (nbdim)
+      CASE (1)
+
+!CDIR ALTCODE
+         do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array1(ir)
+            kindex = kindex + 1
+         enddo       
+C
+      CASE (2)
+
+        do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+           do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array2(ir,jr)
+            kindex = kindex + 1
+           enddo
+         enddo      
+C
+      CASE (3)
+        do kr=bounds(3,1),bounds(3,2)
+          do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+             do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array3(ir,jr,kr)
+            kindex = kindex + 1
+             enddo
+           enddo
+         enddo       
+C
+      CASE (4)
+          do lr=bounds(4,1),bounds(4,2)
+           do kr=bounds(3,1),bounds(3,2)
+             do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+               do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array4(ir,jr,kr,lr)
+            kindex = kindex + 1
+               enddo
+             enddo
+           enddo
+         enddo         
+C
+      CASE (5)
+         do mr=bounds(5,1),bounds(5,2)
+           do lr=bounds(4,1),bounds(4,2)
+            do kr=bounds(3,1),bounds(3,2) 
+              do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+                 do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array5(ir,jr,kr,lr,mr)
+            kindex = kindex + 1
+                 enddo
+               enddo
+             enddo
+           enddo
+         enddo   
+C
+      CASE (6)
+        do nr=bounds(6,1),bounds(6,2)
+           do mr=bounds(5,1),bounds(5,2)
+             do lr=bounds(4,1),bounds(4,2)
+               do kr=bounds(3,1),bounds(3,2)
+                do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+                   do ir=bounds(1,1),bounds(1,2)
+            child%var%oldvalues2d(2,kindex) =
+     &           child%var%array6(ir,jr,kr,lr,mr,nr)
+            kindex = kindex + 1
+                   enddo
+                 enddo
+               enddo
+             enddo
+           enddo
+         enddo       
+      END SELECT
+C
+C                                                  
+      End subroutine saveAfterInterp
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine timeInterpolation
+C     **************************************************************************
+C
+      Subroutine timeInterpolation(child,bounds,kindex,c1t,c2t,nbdim) 
+C
+CCC   Descritpion:
+CCC   Subroutine for a linear time interpolation on the child grid. 
+C
+C     Declarations:
+C
+      
+C
+C     argument
+      TYPE (AGRIF_PVariable) :: child  ! The fine grid variable
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim,2) :: bounds
+      INTEGER                :: kindex ! Index indicating the values of the fine
+                                       ! grid got before and after the space 
+                                       ! interpolation and used for the time 
+                                       ! interpolation
+      REAL                   :: c1t,c2t! coefficients for the time interpolation
+                                       ! (c2t=1-c1t)  
+C
+C     Local aruments      
+      INTEGER :: i
+C     Local scalars
+      INTEGER                      :: ir,jr,kr,lr,mr,nr      
+C
+C
+      
+      SELECT CASE (nbdim)
+      CASE (1)
+
+!CDIR ALTCODE
+         do ir=bounds(1,1),bounds(1,2)
+                child%var%array1(ir) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex)    
+            kindex = kindex + 1
+         enddo       
+C
+      CASE (2)
+
+        do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+           do ir=bounds(1,1),bounds(1,2)
+                child%var%array2(ir,jr) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex) 
+            kindex = kindex + 1
+           enddo
+         enddo      
+C
+      CASE (3)
+        do kr=bounds(3,1),bounds(3,2)
+          do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+             do ir=bounds(1,1),bounds(1,2)
+                child%var%array3(ir,jr,kr) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex) 
+            kindex = kindex + 1
+             enddo
+           enddo
+         enddo       
+C
+      CASE (4)
+          do lr=bounds(4,1),bounds(4,2)
+           do kr=bounds(3,1),bounds(3,2)
+             do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+               do ir=bounds(1,1),bounds(1,2)
+                child%var%array4(ir,jr,kr,lr) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex) 
+            kindex = kindex + 1
+               enddo
+             enddo
+           enddo
+         enddo         
+C
+      CASE (5)
+         do mr=bounds(5,1),bounds(5,2)
+           do lr=bounds(4,1),bounds(4,2)
+            do kr=bounds(3,1),bounds(3,2) 
+              do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+                 do ir=bounds(1,1),bounds(1,2)
+                child%var%array5(ir,jr,kr,lr,mr) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex) 
+            kindex = kindex + 1
+                 enddo
+               enddo
+             enddo
+           enddo
+         enddo   
+C
+      CASE (6)
+        do nr=bounds(6,1),bounds(6,2)
+           do mr=bounds(5,1),bounds(5,2)
+             do lr=bounds(4,1),bounds(4,2)
+               do kr=bounds(3,1),bounds(3,2)
+                do jr=bounds(2,1),bounds(2,2)
+!CDIR ALTCODE
+                   do ir=bounds(1,1),bounds(1,2)
+                child%var%array6(ir,jr,kr,lr,mr,nr) =
+     &           c2t*child % var % oldvalues2d(1,kindex)   
+     &         + c1t*child % var % oldvalues2d(2,kindex) 
+            kindex = kindex + 1
+                   enddo
+                 enddo
+               enddo
+             enddo
+           enddo
+         enddo       
+      END SELECT
+                                                   
+C
+C
+      End subroutine timeInterpolation      
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Checksize
+C     **************************************************************************
+C
+      Subroutine Agrif_Checksize(child,newsize)
+C
+CCC   Descritpion:
+CCC   Subroutine used in the saveAfterInterp procedure to allocate the 
+CCC   oldvalues2d array. 
+C
+C     Declarations:
+C
+      
+C      
+C     TYPE argument
+      TYPE (AGRIF_PVariable) :: child  ! The fine grid variable
+C 
+C     Scalar arguments
+      INTEGER :: newsize               ! Size of the domains where the boundary 
+                                       ! conditions are calculated  
+C
+C     Local arrays
+      REAL, DIMENSION(:,:), Allocatable :: tempoldvalues ! Temporary array
+C                
+C
+      if (.NOT. associated(child % var % oldvalues2d)) then
+C
+          allocate(child % var % oldvalues2d(2,newsize))
+C  
+          child % var % oldvalues2d=0.
+C
+        else
+C
+          if (SIZE(child % var % oldvalues2d,2) < newsize) then   
+C
+              allocate(tempoldvalues(2,SIZE(child % var %
+     &                                    oldvalues2d,2)))
+C
+              tempoldvalues = child % var % oldvalues2d
+C
+              deallocate(child % var % oldvalues2d)
+C
+              allocate(child % var % oldvalues2d(2,newsize))
+C            
+              child%var%oldvalues2d=0.
+C
+              child % var % oldvalues2d(:,1:SIZE(tempoldvalues,2)) = 
+     &        tempoldvalues(:,:)
+C
+              deallocate(tempoldvalues)
+C
+          endif 
+C
+      endif                                                    
+C
+C
+      End  Subroutine Agrif_Checksize
+C
+C
+C
+C      
+      End Module AGRIF_boundary
+
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbcfunction.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbcfunction.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modbcfunction.F	(revision 1844)
@@ -0,0 +1,2075 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module AGRIF_bcfunction
+C
+C 
+      Module  Agrif_bcfunction
+CCC   Description:
+CCC   
+C
+C     Modules used:
+C  
+      Use Agrif_Boundary
+      Use Agrif_Update
+      Use Agrif_fluxmod
+C             
+      IMPLICIT NONE
+C
+      interface Agrif_Bc_variable
+          module procedure Agrif_Bc_variable0d,
+     &                     Agrif_Bc_variable1d,
+     &                     Agrif_Bc_variable2d,
+     &                     Agrif_Bc_variable3d,
+     &                     Agrif_Bc_variable4d,
+     &                     Agrif_Bc_variable5d
+      end interface       
+C
+      interface Agrif_Set_Parent
+          module procedure Agrif_Set_Parent_int,
+     &                     Agrif_Set_Parent_real
+      end interface       
+C
+      interface Agrif_Interp_variable
+          module procedure Agrif_Interp_var0d,
+     &                     Agrif_Interp_var1d,
+     &                     Agrif_Interp_var2d,
+     &                     Agrif_Interp_var3d,
+     &                     Agrif_Interp_var4d,
+     &                     Agrif_Interp_var5d
+      end interface       
+C
+      interface Agrif_Init_variable
+          module procedure Agrif_Init_variable0d,
+     &                     Agrif_Init_variable1d,
+     &                     Agrif_Init_variable2d,
+     &                     Agrif_Init_variable3d
+      end interface       
+C
+      interface Agrif_update_variable
+          module procedure Agrif_update_var0d,
+     &                     Agrif_update_var1d,
+     &                     Agrif_update_var2d,
+     &                     Agrif_update_var3d,
+     &                     Agrif_update_var4d,
+     &                     Agrif_update_var5d
+      end interface       
+C
+      Contains 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_type
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_type(tabvarsindic,posvar,point)
+C
+CCC   Description:
+CCC   To set the TYPE of the variable.
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C
+C
+C     Arguments      
+C
+      INTEGER, DIMENSION(:) :: posvar
+      INTEGER, DIMENSION(:) :: point
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      INTEGER :: dimensio ! DIMENSION of the variable
+      INTEGER :: i
+C
+C
+C     Begin 
+C
+      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim
+C
+      if (.not.associated(Agrif_Mygrid % tabvars(tabvarsindic)
+     &                                 %var % posvar)) then
+      Allocate( 
+     & Agrif_Mygrid % tabvars(tabvarsindic)%var % posvar(dimensio))
+      endif 
+            
+      do i = 1 , dimensio
+         Agrif_Mygrid % tabvars(tabvarsindic) %var % posvar(i)
+     &                       = posvar(i)
+         Agrif_Mygrid % tabvars(tabvarsindic) %var % point(i) 
+     &                       = point(i)
+      enddo
+C
+C
+      End Subroutine Agrif_Set_type
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_parent_int
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_parent_int(tabvarsindic,value)
+C
+CCC   Description:
+CCC   To set the TYPE of the variable.
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C
+C
+C     Arguments      
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      INTEGER :: Value
+C
+C     Begin 
+C
+      Agrif_Curgrid % parent % tabvars(tabvarsindic) % 
+     &         var % iarray0 = value
+C
+C
+      End Subroutine Agrif_Set_parent_int
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_parent_real
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_parent_real(tabvarsindic,value)
+C
+CCC   Description:
+CCC   To set the TYPE of the variable.
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C
+C
+C     Arguments      
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      REAL :: Value
+C
+C     Begin 
+C
+      Agrif_Curgrid % parent % tabvars(tabvarsindic) % 
+     &          var % array0 = value
+C
+C
+      End Subroutine Agrif_Set_parent_real
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_raf
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_raf(tabvarsindic,tabraf)
+C
+CCC   Description:
+CCC   Attention tabraf est de taille trois si on ne raffine pas suivant z la
+CCC             troisieme entree du tableau tabraf est 'N'
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      CHARACTER(*) ,DIMENSION(:) :: tabraf
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      INTEGER :: dimensio ! DIMENSION of the variable
+      INTEGER :: i
+C
+C
+C     Begin 
+C
+      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim
+C        
+      if (.not.associated(Agrif_Mygrid % tabvars(tabvarsindic)
+     &                                 %var % interptab)) then 
+      Allocate(
+     & Agrif_Mygrid % tabvars(tabvarsindic)%var% interptab(dimensio))
+      endif
+
+      do i = 1 , dimensio
+         Agrif_Mygrid % tabvars(tabvarsindic) %var % interptab(i) 
+     &                 = TRIM(tabraf(i))
+      enddo
+C
+      End Subroutine Agrif_Set_raf
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_bc
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_bc(tabvarsindic,point,
+     &          Interpolationshouldbemade)
+C
+CCC   Description:
+CCC
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER, DIMENSION(2) :: point
+      LOGICAL, OPTIONAL :: Interpolationshouldbemade
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      TYPE(Agrif_PVariable),Pointer ::tabvars
+      
+    
+C
+C
+C     Begin 
+C
+C     
+
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      endif  
+      
+      if (Agrif_Curgrid % fixedrank .NE. 0) then  
+       IF (.Not.Associated(tabvars%var% interpIndex)) THEN
+        Allocate(tabvars%var % interpIndex)
+          tabvars%var % interpIndex = -1
+
+        Allocate(tabvars%var % oldvalues2D(2,1))
+          tabvars%var % oldvalues2D = 0. 
+       ENDIF      
+       if ( PRESENT(Interpolationshouldbemade) ) then
+         tabvars%var %
+     &     Interpolationshouldbemade = Interpolationshouldbemade
+       endif
+
+      endif
+C
+      tabvars%var % bcinf = point(1)
+      tabvars%var % bcsup = point(2)
+C
+      End Subroutine Agrif_Set_bc
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_interp
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_interp(tabvarsindic,interp,interp1,interp2,
+     &                interp3)
+C
+CCC   Description:
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER, OPTIONAL      :: interp,interp1,interp2,interp3
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C
+C     Begin 
+C
+      Agrif_Mygrid % tabvars(tabvarsindic)% var % Typeinterp = 
+     &    Agrif_Constant
+      IF (present(interp)) THEN
+      Agrif_Mygrid % tabvars(tabvarsindic)% var % Typeinterp = 
+     &           interp
+      ENDIF
+      IF (present(interp1)) THEN
+      Agrif_Mygrid % tabvars(tabvarsindic)% var % Typeinterp(1) = 
+     &           interp1
+      ENDIF
+      IF (present(interp2)) THEN
+      Agrif_Mygrid % tabvars(tabvarsindic)% var % Typeinterp(2) = 
+     &           interp2
+      ENDIF
+      IF (present(interp3)) THEN
+      Agrif_Mygrid % tabvars(tabvarsindic)% var % Typeinterp(3) = 
+     &           interp3
+      ENDIF
+C
+      End Subroutine Agrif_Set_interp
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_bcinterp
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_bcinterp(tabvarsindic,interp,interp1,
+     &      interp2,interp3,interp11,interp12,interp21,interp22)
+C
+CCC   Description:
+
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER, OPTIONAL      :: interp,interp1,interp2,interp3
+      INTEGER, OPTIONAL      :: interp11,interp12,interp21,interp22
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      TYPE(Agrif_PVariable),Pointer ::tabvars
+      
+    
+C
+C
+C     Begin 
+C
+C     
+
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Mygrid % tabvars(tabvarsindic)
+      endif 
+C
+      tabvars% var % bctypeinterp = 
+     &           Agrif_Constant   
+      IF (present(interp)) THEN
+      tabvars% var % bctypeinterp = 
+     &           interp
+      ENDIF       
+      IF (present(interp1)) THEN
+      tabvars% var % bctypeinterp(1:2,1) = 
+     &           interp1
+      ENDIF       
+      IF (present(interp11)) THEN
+      tabvars% var % bctypeinterp(1,1) = 
+     &           interp11
+      ENDIF
+      IF (present(interp12)) THEN
+      tabvars% var % bctypeinterp(1,2) = 
+     &           interp12
+      ENDIF          
+      IF (present(interp2)) THEN
+      tabvars% var % bctypeinterp(1:2,2) = 
+     &           interp2
+      ENDIF
+      IF (present(interp21)) THEN
+      tabvars% var % bctypeinterp(2,1) = 
+     &           interp21
+      ENDIF      
+      IF (present(interp22)) THEN
+      tabvars% var % bctypeinterp(2,2) = 
+     &           interp22
+      ENDIF            
+      IF (present(interp3)) THEN
+      tabvars% var % bctypeinterp(1:2,3) =
+     &           interp3
+      ENDIF
+C
+      End Subroutine Agrif_Set_bcinterp
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_Update
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_Update(tabvarsindic,point)
+C
+CCC   Description:
+CCC
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER, DIMENSION(2) :: point
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C
+C
+C     Begin 
+C
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf = point(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup = point(2)
+C
+      End Subroutine Agrif_Set_Update
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_UpdateType
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_UpdateType(tabvarsindic,
+     &                                  update,update1,update2,
+     &                                  update3,update4,update5)
+C
+CCC   Description:
+
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER, OPTIONAL           :: update, update1,
+     &       update2, update3,update4,update5
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C
+C
+C     Begin 
+C
+      Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate = 
+     &                   Agrif_Update_Copy
+      
+      IF (present(update)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate = 
+     &           update
+      ENDIF
+      IF (present(update1)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate(1) = 
+     &           update1
+      ENDIF  
+      IF (present(update2)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate(2) = 
+     &           update2
+      ENDIF  
+      IF (present(update3)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate(3) = 
+     &           update3
+      ENDIF 
+      IF (present(update4)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate(4) = 
+     &           update4
+      ENDIF       
+      IF (present(update5)) THEN
+        Agrif_Mygrid % tabvars(tabvarsindic)% var % typeupdate(5) = 
+     &           update5
+      ENDIF                  
+C
+      End Subroutine Agrif_Set_UpdateType           
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Set_restore
+C     **************************************************************************
+C 
+      Subroutine Agrif_Set_restore(tabvarsindic)
+C
+CCC   Description:
+CCC   
+C
+C     Modules used:
+C      
+
+C
+C     Declarations:
+C      
+C     Arguments      
+C
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C
+C     Begin 
+C
+C
+      Agrif_Mygrid%tabvars(tabvarsindic)%var % restaure = .TRUE.
+C
+      End Subroutine Agrif_Set_restore
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_variable0d
+C     **************************************************************************
+      Subroutine Agrif_Init_variable0d(tabvarsindic0,tabvarsindic,
+     &        procname)
+
+      INTEGER :: tabvarsindic0 ! indice of the variable in tabvars
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+C
+      if (Agrif_Root()) Return
+C      
+      if (present(procname)) then
+      CALL Agrif_Interp_variable(tabvarsindic0,tabvarsindic,procname)
+      CALL Agrif_Bc_variable(tabvarsindic0,tabvarsindic,1.,procname)
+      else
+      CALL Agrif_Interp_variable(tabvarsindic0,tabvarsindic)
+      CALL Agrif_Bc_variable(tabvarsindic0,tabvarsindic,1.)
+      endif
+
+      End Subroutine Agrif_Init_variable0d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_variable1d
+C     **************************************************************************
+      Subroutine Agrif_Init_variable1d(q,tabvarsindic,procname)
+
+      REAL, DIMENSION(:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      CALL Agrif_Interp_variable(q,tabvarsindic,procname)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.,procname)
+      else
+      CALL Agrif_Interp_variable(q,tabvarsindic)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.)
+      endif
+
+      End Subroutine Agrif_Init_variable1d
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_variable2d
+C     **************************************************************************
+      Subroutine Agrif_Init_variable2d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      CALL Agrif_Interp_variable(q,tabvarsindic,procname)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.,procname)
+      else
+      CALL Agrif_Interp_variable(q,tabvarsindic)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.)
+      endif
+
+
+      End Subroutine Agrif_Init_variable2d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_variable3d
+C     **************************************************************************
+      Subroutine Agrif_Init_variable3d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      CALL Agrif_Interp_variable(q,tabvarsindic,procname)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.,procname)
+      else
+      CALL Agrif_Interp_variable(q,tabvarsindic)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.)
+      endif
+
+C
+      End Subroutine Agrif_Init_variable3d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_variable4d
+C     **************************************************************************
+      Subroutine Agrif_Init_variable4d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:,:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      CALL Agrif_Interp_variable(q,tabvarsindic,procname)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.,procname)
+      else
+      CALL Agrif_Interp_variable(q,tabvarsindic)
+      CALL Agrif_Bc_variable(q,tabvarsindic,1.)
+      endif
+
+C
+      End Subroutine Agrif_Init_variable4d      
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable0d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable0d(tabvarsindic0,tabvarsindic,
+     &                               calledweight,procname)
+
+      INTEGER :: tabvarsindic0 ! indice of the variable in tabvars
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      External :: procname
+      Optional ::  procname
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+C
+      INTEGER :: dimensio      
+
+      if (Agrif_Root()) Return
+C
+      dimensio =  Agrif_Mygrid % tabvars(tabvarsindic) % var % nbdim    
+C
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+C      
+C
+
+      
+      if ( dimensio .EQ. 1 ) Call Agrif_Interp_Bc_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array1,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,
+     & pweight)
+C
+      if ( dimensio .EQ. 2 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array2,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight,procname)
+      ELSE
+          
+      Call Agrif_Interp_Bc_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array2,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      endif
+C
+      if ( dimensio .EQ. 3 ) then
+      IF (present(procname)) THEN
+
+      Call Agrif_Interp_Bc_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array3,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array3,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      endif
+C
+      if ( dimensio .EQ. 4 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array4,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array4,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      endif
+C
+      if ( dimensio .EQ. 5 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array5,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array5,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      endif
+C
+      if ( dimensio .EQ. 6 ) Call Agrif_Interp_Bc_6D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) %var % array6,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % bcsup,
+     & weight,
+     & pweight)
+C
+C
+      End Subroutine Agrif_Bc_variable0d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable1d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable1d(q,tabvarsindic,calledweight,
+     &                               procname)
+
+      REAL   , Dimension(:)          :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+      TYPE(Agrif_PVariable),Pointer ::tabvars,parenttabvars,roottabvars
+C
+C      
+C      
+      If (Agrif_Root()) Return
+      
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+      
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      parenttabvars => tabvars%parent_var
+      roottabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      parenttabvars => Agrif_Curgrid % parent % tabvars(tabvarsindic)
+      roottabvars => Agrif_Mygrid % tabvars(tabvarsindic)
+      endif
+            
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_1D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_1D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      End Subroutine Agrif_Bc_variable1d 
+      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable2d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable2d(q,tabvarsindic,calledweight,
+     &                               procname)
+
+      REAL   , Dimension(:,:)          :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+      TYPE(Agrif_PVariable),Pointer ::tabvars,parenttabvars,roottabvars
+C
+C      
+C      
+      If (Agrif_Root()) Return
+      
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+      
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      parenttabvars => tabvars%parent_var
+      roottabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      parenttabvars => Agrif_Curgrid % parent % tabvars(tabvarsindic)
+      roottabvars => Agrif_Mygrid % tabvars(tabvarsindic)
+      endif
+            
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_2D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_2D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      End Subroutine Agrif_Bc_variable2d
+            
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable3d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable3d(q,tabvarsindic,calledweight,
+     &                               procname)
+
+      REAL   , Dimension(:,:,:)          :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+      TYPE(Agrif_PVariable),Pointer ::tabvars,parenttabvars,roottabvars
+C
+C      
+C      
+      If (Agrif_Root()) Return
+      
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+      
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      parenttabvars => tabvars%parent_var
+      roottabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      parenttabvars => Agrif_Curgrid % parent % tabvars(tabvarsindic)
+      roottabvars => Agrif_Mygrid % tabvars(tabvarsindic)
+      endif
+            
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_3D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_3D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      End Subroutine Agrif_Bc_variable3d
+      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable4d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable4d(q,tabvarsindic,calledweight,
+     &                               procname)
+
+      REAL   , Dimension(:,:,:,:)          :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+      TYPE(Agrif_PVariable),Pointer ::tabvars,parenttabvars,roottabvars
+C
+C      
+C      
+      If (Agrif_Root()) Return
+      
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+      
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      parenttabvars => tabvars%parent_var
+      roottabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      parenttabvars => Agrif_Curgrid % parent % tabvars(tabvarsindic)
+      roottabvars => Agrif_Mygrid % tabvars(tabvarsindic)
+      endif
+            
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_4D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_4D(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      End Subroutine Agrif_Bc_variable4d
+            
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Bc_variable5d
+C     **************************************************************************
+      Subroutine Agrif_Bc_variable5d(q,tabvarsindic,calledweight,
+     &                               procname)
+
+      REAL   , Dimension(:,:,:,:,:)          :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C        
+      REAL, OPTIONAL :: calledweight
+      REAL    :: weight
+      LOGICAL :: pweight
+      TYPE(Agrif_PVariable),Pointer ::tabvars,parenttabvars,roottabvars
+C
+C      
+C      
+      If (Agrif_Root()) Return
+      
+      if ( PRESENT(calledweight) ) then
+        weight=calledweight      
+        pweight = .TRUE.
+      else
+        weight = 0.
+        pweight = .FALSE.
+      endif
+      
+      if (tabvarsindic <=0) then
+      tabvars => Agrif_Search_Variable(Agrif_Curgrid,-tabvarsindic)
+      parenttabvars => tabvars%parent_var
+      roottabvars => Agrif_Search_Variable(Agrif_Mygrid,-tabvarsindic)
+      else
+      tabvars=>Agrif_Curgrid % tabvars(tabvarsindic)
+      parenttabvars => Agrif_Curgrid % parent % tabvars(tabvarsindic)
+      roottabvars => Agrif_Mygrid % tabvars(tabvarsindic)
+      endif
+            
+      IF (present(procname)) THEN
+      Call Agrif_Interp_Bc_5d(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight,procname)      
+      ELSE
+      Call Agrif_Interp_Bc_5d(
+     & roottabvars % var % bctypeinterp,
+     & parenttabvars,
+     & tabvars,q,
+     & tabvars % var % bcinf,
+     & tabvars % var % bcsup,
+     & weight,pweight)
+      ENDIF
+      End Subroutine Agrif_Bc_variable5d
+      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var0D
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var0d(tabvarsindic0,tabvarsindic,procname)
+
+      INTEGER :: tabvarsindic0 ! indice of the variable in tabvars
+      INTEGER :: tabvarsindic  ! indice of the variable in tabvars
+      INTEGER :: dimensio  ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+C      
+      if (Agrif_Root()) Return
+C     
+      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) % var % nbdim 
+C
+      if ( dimensio .EQ. 1 ) then
+       if (present(procname)) then
+       Call Agrif_Interp_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array1 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+       else
+       Call Agrif_Interp_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array1 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+       endif
+       endif
+C
+      if ( dimensio .EQ. 2 ) then
+      if (present(procname)) then
+       Call Agrif_Interp_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array2 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+       Call Agrif_Interp_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array2 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      endif
+C
+      if ( dimensio .EQ. 3 ) then
+      if (present(procname)) then
+       Call Agrif_Interp_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array3 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+       Call Agrif_Interp_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array3 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      endif
+C
+      if ( dimensio .EQ. 4 ) then
+      if (present(procname)) then
+       Call Agrif_Interp_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array4 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+       Call Agrif_Interp_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array4 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      endif
+C
+      if ( dimensio .EQ. 5 ) then
+      if (present(procname)) then
+       Call Agrif_Interp_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array5 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+       Call Agrif_Interp_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array5 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+       endif
+       endif
+C
+      if ( dimensio .EQ. 6 ) then
+      if (present(procname)) then
+       Call Agrif_Interp_6D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array6 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+       Call Agrif_Interp_6D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array6 ,     
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      endif
+C
+      Return
+      End Subroutine Agrif_Interp_var0d
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var1d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var1d(q,tabvarsindic,procname)
+
+      REAL, DIMENSION(:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+C
+      if (Agrif_Root()) Return
+C      
+      if (present(procname)) then
+      Call Agrif_Interp_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+      Call Agrif_Interp_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      Return
+      End Subroutine Agrif_Interp_var1d
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var2d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var2d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+       if (Agrif_Root()) Return
+C
+       if (present(procname)) then
+       Call Agrif_Interp_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+       else
+       Call Agrif_Interp_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+       endif
+      Return
+      End Subroutine Agrif_Interp_var2d
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var3d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var3d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      Call Agrif_Interp_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+      Call Agrif_Interp_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      Return
+      End Subroutine Agrif_Interp_var3d
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var4d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var4d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:,:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      Call Agrif_Interp_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+      Call Agrif_Interp_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      Return
+      End Subroutine Agrif_Interp_var4d     
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_var5d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_var5d(q,tabvarsindic,procname)
+
+      REAL,  DIMENSION(:,:,:,:,:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname
+
+C
+      if (Agrif_Root()) Return
+C
+      if (present(procname)) then
+      Call Agrif_Interp_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim,procname)
+      else
+      Call Agrif_Interp_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var %  TypeInterp,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % restaure,
+     & Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim)
+      endif
+      Return
+      End Subroutine Agrif_Interp_var5d       
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var0d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var0d(tabvarsindic0,tabvarsindic,
+     &                              locupdate,locupdate1,
+     &                  locupdate2,procname)
+
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      INTEGER :: tabvarsindic0 ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname      
+      INTEGER :: dimensio
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2            
+C
+      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) % var % nbdim 
+C      
+      if (Agrif_Root()) Return
+      
+C     
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:dimensio)
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:dimensio) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:dimensio) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:dimensio) 
+     &      = -99
+      ENDIF
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF             
+ 
+      if ( dimensio .EQ. 1 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Update_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array1 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array1 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+      endif
+      if ( dimensio .EQ. 2 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Update_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array2 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array2 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+      endif
+      if ( dimensio .EQ. 3 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Update_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array3 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array3 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+      endif
+      if ( dimensio .EQ. 4 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Update_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array4 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array4 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+      endif
+      if ( dimensio .EQ. 5 ) then
+      IF (present(procname)) THEN
+      Call Agrif_Update_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array5 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic0) % var % array5 ,     
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+      endif
+
+      Return
+      End Subroutine Agrif_update_var0d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var1d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var1d(q,tabvarsindic,locupdate,
+     &  locupdate1,locupdate2,procname)
+
+      REAL,  DIMENSION(:) :: q
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+      External :: procname
+      Optional ::  procname      
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2        
+C      
+      if (Agrif_Root()) Return
+C     
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:1) 
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:1) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:1) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:1) 
+     &      = -99
+      ENDIF
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF       
+ 
+      IF (present(procname)) THEN
+      Call Agrif_Update_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_1D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+
+      Return
+      End Subroutine Agrif_update_var1d
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var2d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var2d(q,tabvarsindic,locupdate,
+     &  locupdate1,locupdate2,procname)
+
+      REAL,  DIMENSION(:,:) :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate 
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2        
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C      
+      IF (Agrif_Root()) RETURN
+      
+C 
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:2) 
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:2) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:2) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:2) 
+     &      = -99
+      ENDIF
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF
+ 
+      IF (present(procname)) THEN
+      Call Agrif_Update_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_2D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+
+      Return
+      End Subroutine Agrif_update_var2d
+C 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var3d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var3d(q,tabvarsindic,locupdate,
+     &  locupdate1,locupdate2,procname)
+
+      REAL,  DIMENSION(:,:,:) :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2        
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C      
+      IF (Agrif_Root()) RETURN 
+C      
+
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:3) 
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:3) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:3) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:3) 
+     &      = -99
+      ENDIF      
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF
+
+      IF (present(procname)) THEN
+      Call Agrif_Update_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_3D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+
+      Return
+      End Subroutine Agrif_update_var3d
+C 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var4d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var4d(q,tabvarsindic,locupdate,
+     &  locupdate1,locupdate2,procname)
+
+      REAL,  DIMENSION(:,:,:,:) :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2        
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C      
+      IF (Agrif_Root()) RETURN
+C      
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:4) 
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:4) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:4) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:4) 
+     &      = -99
+      ENDIF
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF
+
+      IF (present(procname)) THEN
+      Call Agrif_Update_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_4D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+
+      Return
+      End Subroutine Agrif_update_var4d  
+C 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_update_var5d
+C     **************************************************************************
+C 
+      Subroutine Agrif_update_var5d(q,tabvarsindic,locupdate,
+     &  locupdate1,locupdate2,procname)
+
+      REAL,  DIMENSION(:,:,:,:,:) :: q
+      External :: procname
+      Optional ::  procname
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate1
+      INTEGER, DIMENSION(2), OPTIONAL :: locupdate2        
+      INTEGER :: tabvarsindic ! indice of the variable in tabvars
+C
+      IF (Agrif_Root()) RETURN
+C      
+      IF (present(locupdate)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:5) 
+     &      = locupdate(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:5) 
+     &      = locupdate(2)
+      ELSE
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1:5) 
+     &      = -99
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1:5) 
+     &      = -99
+      ENDIF
+      
+      IF (present(locupdate1)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(1) 
+     &      = locupdate1(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(1) 
+     &      = locupdate1(2)
+      ENDIF  
+      
+      IF (present(locupdate2)) THEN
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updateinf(2) 
+     &      = locupdate2(1)
+      Agrif_Curgrid%tabvars(tabvarsindic)%var % updatesup(2) 
+     &      = locupdate2(2)
+      ENDIF
+
+      IF (present(procname)) THEN
+      Call Agrif_Update_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup,
+     & procname)
+      ELSE
+      Call Agrif_Update_5D(
+     & Agrif_Mygrid % tabvars(tabvarsindic) % var % typeupdate,
+     & Agrif_Curgrid % parent % tabvars(tabvarsindic),
+     & Agrif_Curgrid % tabvars(tabvarsindic),q,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updateinf,
+     & Agrif_Curgrid % tabvars(tabvarsindic) % var % updatesup)      
+      ENDIF
+
+      Return
+      End Subroutine Agrif_update_var5d  
+          
+      Subroutine Agrif_Declare_Flux(fluxname,profilename) 
+      character*(*) :: fluxname, profilename
+      Type(Agrif_Flux), pointer :: newflux
+      Type(Agrif_Profile), pointer  :: parcours
+      logical :: foundprofile
+      integer :: i,j,n
+            
+      foundprofile = .FALSE.
+      parcours => Agrif_Myprofiles
+      
+      Do While (Associated(parcours))
+         IF (parcours % profilename == profilename) THEN
+           foundprofile = .TRUE.
+           EXIT
+         ENDIF
+         parcours => parcours%nextprofile
+      End Do      
+      
+      IF (.NOT.foundprofile) THEN
+      write(*,*) 'The profile '''
+     &           //TRIM(profilename)//''' has not been declared'  
+      stop    
+      ENDIF
+      
+      Allocate(Newflux)
+      
+      Newflux % fluxname = fluxname
+      
+      Newflux % profile => parcours
+      
+      Newflux % nextflux => Agrif_Curgrid % fluxes
+      
+      Agrif_Curgrid % fluxes => Newflux
+      
+      End Subroutine Agrif_Declare_Flux  
+       
+      Subroutine Agrif_Save_Flux(fluxname, fluxtab)
+      character*(*) :: fluxname
+      REAL, DIMENSION(:,:) :: fluxtab
+      
+      
+      Type(Agrif_Flux), pointer :: Flux
+      
+      Type(Agrif_pgrid), pointer :: parcours_child
+      
+      Type(Agrif_grid), Pointer :: currentgrid,oldcurgrid
+      
+      IF (.Not.Agrif_Root()) THEN
+      Flux => Agrif_Search_Flux(fluxname)
+
+      IF (.NOT.Flux%fluxallocated) THEN
+        CALL Agrif_AllocateFlux(Flux,fluxtab)
+      ENDIF
+      
+      Call Agrif_Save_Fluxtab(Flux,fluxtab)
+      
+      ENDIF
+      
+      oldcurgrid=> Agrif_Curgrid
+      
+      parcours_child => Agrif_Curgrid%child_grids
+      
+      Do While (Associated(parcours_child))
+        currentgrid => parcours_child%gr
+        Agrif_Curgrid => parcours_child%gr
+        Flux => Agrif_Search_Flux(fluxname)
+        IF (.NOT.Flux%fluxallocated) THEN
+          CALL Agrif_AllocateFlux(Flux,fluxtab)
+        ENDIF        
+        Call Agrif_Save_Fluxtab_child(Flux,fluxtab)
+        parcours_child=> parcours_child%next
+      End Do
+      
+      Agrif_Curgrid=>oldcurgrid
+      
+      End Subroutine Agrif_Save_Flux
+
+      Subroutine Agrif_Cancel_Flux(fluxname)
+      character*(*) :: fluxname
+      
+      Type(Agrif_Flux), pointer :: Flux
+      
+      Flux => Agrif_Search_Flux(fluxname)
+
+      IF (Flux%FluxAllocated) Call Agrif_Cancel_Fluxarray(Flux)
+      
+      End Subroutine Agrif_Cancel_Flux
+ 
+      Subroutine Agrif_Flux_Correction(fluxname, procname)
+      character*(*) :: fluxname
+      external :: procname
+      
+      Type(Agrif_Flux), pointer :: Flux
+      
+      Flux => Agrif_Search_Flux(fluxname)
+      
+      Call Agrif_FluxCorrect(Flux, procname)
+
+      
+      End Subroutine Agrif_Flux_Correction
+
+      Subroutine Agrif_Declare_Variable(posvar,firstpoint,
+     &    raf,lb,ub,varid)
+      character*(80) :: variablename
+      Type(Agrif_List_Variables), Pointer :: newvariable,newvariablep
+      INTEGER, DIMENSION(:) :: posvar
+      INTEGER, DIMENSION(:) :: lb,ub
+      INTEGER, DIMENSION(:) :: firstpoint
+      CHARACTER(*) ,DIMENSION(:) :: raf        
+      TYPE(Agrif_Pvariable), Pointer :: parent_var,root_var
+      INTEGER :: dimensio
+      INTEGER :: varid
+            
+      if (agrif_root()) return
+
+      dimensio = SIZE(posvar)
+C
+C    
+      Allocate(newvariable)
+      Allocate(newvariable%pvar)
+      Allocate(newvariable%pvar%var)
+      Allocate(newvariable%pvar%var%posvar(dimensio))
+      Allocate(newvariable%pvar%var%interptab(dimensio))
+      newvariable%pvar%var%variablename = variablename
+      newvariable%pvar%var%interptab = raf
+      newvariable%pvar%var%nbdim = dimensio
+      newvariable%pvar%var%posvar = posvar
+      newvariable%pvar%var%point(1:dimensio) = firstpoint
+      newvariable%pvar%var%lb(1:dimensio) = lb(1:dimensio)
+      newvariable%pvar%var%ub(1:dimensio) = ub(1:dimensio)
+      
+      newvariable % nextvariable => Agrif_Curgrid%variables
+      
+      Agrif_Curgrid%variables => newvariable
+      Agrif_Curgrid%Nbvariables = Agrif_Curgrid%Nbvariables + 1
+      
+      varid = -Agrif_Curgrid%Nbvariables
+      
+       if (agrif_curgrid%parent%nbvariables < agrif_curgrid%nbvariables)
+     &       then
+      Allocate(newvariablep)
+      Allocate(newvariablep%pvar)
+      Allocate(newvariablep%pvar%var)      
+      Allocate(newvariablep%pvar%var%posvar(dimensio))
+      Allocate(newvariablep%pvar%var%interptab(dimensio))
+      newvariablep%pvar%var%variablename = variablename
+      newvariablep%pvar%var%interptab = raf
+      newvariablep%pvar%var%nbdim = dimensio
+      newvariablep%pvar%var%posvar = posvar
+      newvariablep%pvar%var%point(1:dimensio) = firstpoint
+      
+      newvariablep % nextvariable => Agrif_Curgrid%parent%variables
+      
+      Agrif_Curgrid%parent%variables => newvariablep       
+      
+      Agrif_Curgrid%parent%Nbvariables = 
+     &    Agrif_Curgrid%parent%Nbvariables + 1
+      parent_var=>newvariablep%pvar
+      else
+      parent_var=>Agrif_Search_Variable
+     &              (Agrif_Curgrid%parent,Agrif_Curgrid%nbvariables)
+       endif
+       
+       newvariable%pvar%parent_var=>parent_var
+      
+      root_var=>Agrif_Search_Variable
+     &              (Agrif_Mygrid,Agrif_Curgrid%nbvariables)
+     
+      newvariable%pvar%var%root_var=>root_var%var
+      
+           
+      End Subroutine Agrif_Declare_Variable
+
+      FUNCTION Agrif_Search_Variable(grid,varid)
+      integer :: varid
+      Type(Agrif_Pvariable), Pointer :: Agrif_Search_variable
+      Type(Agrif_grid), Pointer :: grid
+      
+      Type(Agrif_List_Variables), pointer :: parcours
+      Logical :: foundvariable
+      integer nb
+      
+      foundvariable = .FALSE.
+      parcours => grid%variables
+      
+      do nb=1,varid-1
+         parcours => parcours%nextvariable
+      End Do
+      
+      Agrif_Search_variable => parcours%pvar
+      
+      
+      End Function Agrif_Search_variable
+                              
+      Subroutine Agrif_Declare_Profile_flux(profilename,posvar,
+     &    firstpoint,raf)
+      character*(*) :: profilename
+      Type(Agrif_Profile), Pointer :: newprofile
+      INTEGER, DIMENSION(:) :: posvar
+      INTEGER, DIMENSION(:) :: firstpoint
+      CHARACTER(*) ,DIMENSION(:) :: raf      
+      INTEGER :: dimensio
+            
+      dimensio = SIZE(posvar)
+C
+C    
+      Allocate(newprofile)
+      Allocate(newprofile%posvar(dimensio))
+      Allocate(newprofile%interptab(dimensio))
+      newprofile%profilename = profilename
+      newprofile%interptab = raf
+      newprofile%nbdim = dimensio
+      newprofile%posvar = posvar
+      newprofile%point(1:dimensio) = firstpoint
+      
+      newprofile % nextprofile => Agrif_myprofiles
+      
+      Agrif_myprofiles => newprofile
+      
+      End Subroutine Agrif_Declare_Profile_flux
+              
+C
+      End module Agrif_bcfunction
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcluster.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcluster.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcluster.F	(revision 1844)
@@ -0,0 +1,1445 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module AGRIF_Clustering  
+C
+C
+      Module Agrif_Clustering 
+C
+CCC   Description:
+CCC   Module to create and initialize the grid hierarchy from the 
+CCC   AGRIF_FixedGrids.in file.
+C
+C     Modules used:
+C  
+      Use Agrif_Curgridfunctions 
+      Use Agrif_Init_Vars
+      Use Agrif_Save
+C             
+      IMPLICIT NONE
+C        
+      Contains 
+C     Define procedures contained in this module
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Cluster_All  
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Cluster_All(g,coarsegrid)
+C
+CCC   Description:
+CCC   Subroutine for the clustering. A temporary grid hierarchy, pointed by 
+CCC   coarsegrid, is created.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Pointer arguments    
+      TYPE(AGRIF_grid)     ,pointer   :: g        ! Pointer on the current grid
+      TYPE(AGRIF_rectangle),pointer   :: coarsegrid
+C      
+C     Local pointer         
+      TYPE(AGRIF_lrectangle),pointer  :: parcours 
+      TYPE(AGRIF_grid)      ,pointer  :: newgrid 
+      REAL                            :: g_eps
+      INTEGER                         :: iii
+C      
+      g_eps = huge(1.)
+      do iii = 1 , Agrif_Probdim
+         g_eps = min(g_eps,g%Agrif_d(iii))
+      enddo
+C
+      g_eps = g_eps/100.                  
+C
+C     Necessary condition for clustering 
+      do iii = 1 , Agrif_Probdim
+         if (g%Agrif_d(iii)/Agrif_coeffref(iii).LT.
+     &                   (Agrif_mind(iii)-g_eps)) Return
+      enddo
+C
+      Nullify(coarsegrid%childgrids)
+C
+      Call Agrif_ClusterGridnD(g,coarsegrid) 
+C
+      parcours => coarsegrid % childgrids                   
+C      
+      do while (associated(parcours))
+C      
+C       Newgrid is created. It is a copy of a fine grid created previously by
+C          clustering.      
+        Allocate(newgrid)
+C      
+        Nullify(newgrid%child_grids)
+C
+        do iii = 1 , Agrif_Probdim
+           newgrid % nb(iii) = (parcours % r % imax(iii) - 
+     &                          parcours % r % imin(iii)) *
+     &                          Agrif_Coeffref(iii)
+C        
+           newgrid % Agrif_x(iii) = g%Agrif_x(iii) + 
+     &                         (parcours %r % imin(iii) -1) 
+     &                         *g%Agrif_d(iii)
+C 
+           newgrid % Agrif_d(iii) = g%Agrif_d(iii) / Agrif_Coeffref(iii)
+C
+        enddo
+C
+        if ( Agrif_Probdim .EQ. 1 ) then
+           allocate(newgrid%tabpoint1D(newgrid%nb(1)+1))
+           newgrid%tabpoint1D = 0
+        endif
+C
+        if ( Agrif_Probdim .EQ. 2 ) then
+           allocate(newgrid%tabpoint2D(newgrid%nb(1)+1,
+     &                                 newgrid%nb(2)+1))
+           newgrid%tabpoint2D = 0      
+        endif
+C
+        if ( Agrif_Probdim .EQ. 3 ) then
+           allocate(newgrid%tabpoint3D(newgrid%nb(1)+1,
+     &                                 newgrid%nb(2)+1,
+     &                                 newgrid%nb(3)+1))
+           newgrid%tabpoint3D = 0
+        endif
+C       Points detection on newgrid
+        Call Agrif_TabpointsnD(Agrif_mygrid,newgrid) 
+C
+C       Recursive call to Agrif_Cluster_All            
+        Call Agrif_Cluster_All (newgrid, parcours % r)     
+C
+        parcours => parcours % next 
+C      
+        if ( Agrif_Probdim .EQ. 1 ) Deallocate(newgrid%tabpoint1D)
+        if ( Agrif_Probdim .EQ. 2 ) Deallocate(newgrid%tabpoint2D)
+        if ( Agrif_Probdim .EQ. 3 ) Deallocate(newgrid%tabpoint3D)
+C
+        Deallocate(newgrid)   
+C
+      enddo
+C
+C      
+      End Subroutine Agrif_Cluster_All
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_TabpointsnD
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_TabpointsnD(g,newgrid)
+C
+CCC   Description:
+CCC   Copy on newgrid of points detected on the grid hierarchy pointed by g.   
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Arguments
+      TYPE(Agrif_Grid),pointer   :: g,newgrid
+C
+C     Local variables      
+      TYPE(Agrif_Pgrid),pointer  :: parcours
+C
+      REAL                  :: g_eps,newgrid_eps,eps
+      REAL   , DIMENSION(3) :: newmin,newmax
+      REAL   , DIMENSION(3) :: gmin,gmax
+      REAL   , DIMENSION(3) :: xmin
+      INTEGER, DIMENSION(3) :: igmin,inewmin
+      INTEGER, DIMENSION(3) :: inewmax
+      INTEGER               :: iii
+      INTEGER               :: i,j,k
+      INTEGER               :: i0,j0,k0
+C
+C     
+      parcours => g % child_grids
+C
+      do While(associated(parcours))
+        Call Agrif_TabpointsnD(parcours%gr,newgrid)
+        parcours => parcours % next
+      enddo      
+C
+      g_eps = 10.
+      newgrid_eps = 10.
+C      
+      do iii = 1 , Agrif_probdim
+         g_eps = min( g_eps , g % Agrif_d(iii) )
+         newgrid_eps = min(newgrid_eps,newgrid%Agrif_d(iii))
+      enddo
+C
+      eps = min(g_eps,newgrid_eps)/100.                  
+C                   
+      do iii = 1 , Agrif_probdim
+         if (newgrid%Agrif_d(iii) .LT. (g%Agrif_d(iii)-eps)) Return
+C                   
+         gmin(iii) = g%Agrif_x(iii)
+         gmax(iii) = g%Agrif_x(iii) + g%nb(iii) * g%Agrif_d(iii)
+C 
+         newmin(iii) = newgrid%Agrif_x(iii)
+         newmax(iii) = newgrid%Agrif_x(iii) + newgrid%nb(iii) *
+     &                 newgrid%Agrif_d(iii)
+C      
+         if (gmax(iii) .LT. newmin(iii)) Return
+C
+         if (gmin(iii) .GT. newmax(iii)) Return
+C           
+         inewmin(iii) = 1 - floor(-(max(gmin(iii),newmin(iii))-
+     &                    newmin(iii))
+     &                   /newgrid%Agrif_d(iii)) 
+C          
+         xmin(iii) = newgrid%Agrif_x(iii) + (inewmin(iii)-1)*
+     &              newgrid%Agrif_d(iii)          
+C        
+         igmin(iii) = 1 + nint((xmin(iii)-gmin(iii))/g%Agrif_d(iii))
+C
+         inewmax(iii) = 1 + int((min(gmax(iii),newmax(iii))-
+     &                  newmin(iii))/newgrid%Agrif_d(iii))
+      enddo
+C                
+      if ( Agrif_probdim .EQ. 1 ) then
+         i0 = igmin(1)
+         do i = inewmin(1),inewmax(1)
+            newgrid%tabpoint1D(i) = max(
+     &                           newgrid%tabpoint1D(i),
+     &                           g%tabpoint1D(i0))
+         enddo
+         i0 = i0 + int(newgrid%Agrif_d(1)/g%Agrif_d(1))
+      endif
+C
+      if ( Agrif_probdim .EQ. 2 ) then
+         i0 = igmin(1)
+         do i = inewmin(1),inewmax(1)
+            j0 = igmin(2)
+            do j = inewmin(2),inewmax(2)
+               newgrid%tabpoint2D(i,j) = max(
+     &                           newgrid%tabpoint2D(i,j),
+     &                           g%tabpoint2D(i0,j0))
+               j0 = j0 + int(newgrid%Agrif_d(2)/g%Agrif_d(2))
+            enddo
+            i0 = i0 + int(newgrid%Agrif_d(1)/g%Agrif_d(1))
+         enddo
+      endif
+C
+      if ( Agrif_probdim .EQ. 3 ) then
+         i0 = igmin(1)
+         do i = inewmin(1),inewmax(1)
+            j0 = igmin(2)
+            do j = inewmin(2),inewmax(2)
+               k0 = igmin(3)
+               do k = inewmin(3),inewmax(3)
+                  newgrid%tabpoint3D(i,j,k) = max(
+     &                           newgrid%tabpoint3D(i,j,k),
+     &                           g%tabpoint3D(i0,j0,k0))
+                  k0 = k0 + int(newgrid%Agrif_d(3)/g%Agrif_d(3))
+               enddo                                        
+               j0 = j0 + int(newgrid%Agrif_d(2)/g%Agrif_d(2))
+            enddo
+            i0 = i0 + int(newgrid%Agrif_d(1)/g%Agrif_d(1))
+         enddo
+      endif
+C
+      Return
+C
+C
+      End Subroutine Agrif_TabpointsnD
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_ClusterGridnD
+C     **************************************************************************
+C      
+      Subroutine Agrif_ClusterGridnD(g,coarsegrid)
+C
+CCC   Description:
+CCC   Clustering on the grid pointed by g.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Pointer arguments
+      TYPE(AGRIF_grid)     ,pointer  :: g          ! Pointer on the current grid
+      TYPE(AGRIF_rectangle),pointer  :: coarsegrid
+C
+C     Local variables      
+      TYPE(Agrif_rectangle) :: newrect
+      TYPE(Agrif_Variable)  :: newflag
+C
+      INTEGER               :: i,j,k
+      INTEGER ,DIMENSION(3) :: sx
+      INTEGER               :: bufferwidth,flagpoints
+      INTEGER               :: n1,n2,m1,m2,o1,o2
+      INTEGER               :: iii
+C
+C      
+      bufferwidth = int(Agrif_Minwidth/5.)
+C      
+      do iii = 1 , Agrif_probdim
+         sx(iii) = g % nb(iii) + 1
+      enddo
+C                  
+      if ( Agrif_probdim .EQ. 1 ) then
+         allocate(newflag%iarray1(sx(1)))
+         newflag%iarray1 = 0      
+      endif
+      if ( Agrif_probdim .EQ. 2 ) then
+         allocate(newflag%iarray2(sx(1),sx(2)))
+         newflag%iarray2 = 0      
+      endif
+      if ( Agrif_probdim .EQ. 3 ) then
+         allocate(newflag%iarray3(sx(1),sx(2),sx(3)))
+         newflag%iarray3 = 0      
+      endif
+C
+      flagpoints = 0 
+C      
+      if (bufferwidth>0) then 
+C      
+         if ( Agrif_probdim .EQ. 1 ) then
+            do i = bufferwidth,sx(1)-bufferwidth+1      
+               if (g % tabpoint1D(i) .EQ. 1) then
+                  m1 = i - bufferwidth + 1
+                  m2 = i + bufferwidth - 1                  
+                  flagpoints = flagpoints + 1
+                  newflag%iarray1(m1:m2)=1 
+               endif 
+            enddo    
+         endif
+C
+        if ( Agrif_probdim .EQ. 2 ) then
+           do i = bufferwidth,sx(1)-bufferwidth+1      
+               do j = bufferwidth,sx(2)-bufferwidth+1
+                  if (g % tabpoint2D(i,j) .EQ. 1) then
+                     n1 = j - bufferwidth + 1
+                     n2 = j + bufferwidth - 1
+                     m1 = i - bufferwidth + 1
+                     m2 = i + bufferwidth - 1                  
+                     flagpoints = flagpoints + 1
+                     newflag%iarray2(m1:m2,n1:n2)=1 
+                  endif  
+               enddo    
+            enddo
+         endif
+C
+        if ( Agrif_probdim .EQ. 3 ) then
+            do i = bufferwidth,sx(1)-bufferwidth+1      
+               do j = bufferwidth,sx(2)-bufferwidth+1
+                  do k = bufferwidth,sx(3)-bufferwidth+1
+                     if (g % tabpoint3D(i,j,k) .EQ. 1) then
+                        o1 = k - bufferwidth + 1
+                        o2 = k + bufferwidth - 1
+                        n1 = j - bufferwidth + 1
+                        n2 = j + bufferwidth - 1
+                        m1 = i - bufferwidth + 1
+                        m2 = i + bufferwidth - 1                  
+                        flagpoints = flagpoints + 1
+                        newflag%iarray3(m1:m2,n1:n2,o1:o2)=1 
+                     endif 
+                  enddo  
+               enddo    
+            enddo
+        endif
+      else
+          flagpoints = 1       
+C
+          if ( Agrif_probdim .EQ. 1 ) then
+          newflag%iarray1 = g % tabpoint1D
+          endif
+          if ( Agrif_probdim .EQ. 2 ) then
+          newflag%iarray2 = g % tabpoint2D
+          endif
+          if ( Agrif_probdim .EQ. 3 ) then
+          newflag%iarray3 = g % tabpoint3D
+          endif
+      endif
+C       
+      if (flagpoints .EQ. 0) then       
+          if ( Agrif_probdim .EQ. 1 ) deallocate(newflag%iarray1) 
+          if ( Agrif_probdim .EQ. 2 ) deallocate(newflag%iarray2) 
+          if ( Agrif_probdim .EQ. 3 ) deallocate(newflag%iarray3) 
+          Return 
+      endif       
+C      
+      do iii = 1 , Agrif_probdim
+         newrect % imin(iii) = 1
+         newrect % imax(iii) = sx(iii)
+      enddo
+C      
+      Call Agrif_Clusternd(newflag,
+     &                     coarsegrid%childgrids,newrect) 
+C      
+      if ( Agrif_probdim .EQ. 1 ) deallocate(newflag%iarray1)
+      if ( Agrif_probdim .EQ. 2 ) deallocate(newflag%iarray2)
+      if ( Agrif_probdim .EQ. 3 ) deallocate(newflag%iarray3)
+C  
+C    
+      End Subroutine Agrif_ClusterGridnD
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_ClusternD
+C     **************************************************************************
+C
+      Recursive subroutine Agrif_Clusternd(flag,boxlib,oldB) 
+C
+CCC   Description:
+CCC   Clustering on the grid pointed by oldB.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Arguments  
+      TYPE(Agrif_rectangle) ::  oldB    
+      TYPE(Agrif_Variable)  :: flag
+c      INTEGER,DIMENSION(oldB%imin(1):oldB%imax(1),
+c     &                  oldB%imin(2):oldB%imax(2)) :: flag
+      TYPE(Agrif_lrectangle),pointer :: boxlib      
+C
+C     Local variables      
+      TYPE(Agrif_lrectangle),pointer :: tempbox,parcbox,parcbox2       
+      TYPE(Agrif_rectangle) :: newB,newB2
+      INTEGER :: i,j,k,iii
+      INTEGER,DIMENSION(:),allocatable :: i_sig 
+      INTEGER,DIMENSION(:),allocatable :: j_sig       
+      INTEGER,DIMENSION(:),allocatable :: k_sig       
+      INTEGER,DIMENSION(3) :: ipu,ipl
+      INTEGER,DIMENSION(3) :: istr,islice
+      REAL :: cureff
+      REAL :: neweff
+      INTEGER :: ValMax,ValSum,TailleTab
+      INTEGER :: nbpoints,nbpointsflag  
+      LOGICAL :: test
+C          
+      allocate(i_sig(oldB%imin(1):oldB%imax(1)))
+      if ( Agrif_probdim .GE. 2 ) 
+     & allocate(j_sig(oldB%imin(2):oldB%imax(2)))
+      if ( Agrif_probdim .EQ. 3 ) 
+     & allocate(k_sig(oldB%imin(3):oldB%imax(3)))
+C
+      test = .FALSE.
+      do iii = 1 , Agrif_probdim
+         test = test .OR. ( (oldB%imax(iii)-oldB%imin(iii)+1) 
+     &                    .LT. Agrif_Minwidth)
+      enddo
+      if ( test ) Return
+C     
+      if ( Agrif_probdim .EQ. 1 ) i_sig = flag%iarray1
+      if ( Agrif_probdim .EQ. 2 ) then
+         do i = oldB%imin(1),oldB%imax(1)
+           i_sig(i) = SUM(flag%iarray2(i,
+     &                            oldB%imin(2):oldB%imax(2)))
+         enddo
+         do j = oldB%imin(2),oldB%imax(2)
+           j_sig(j) = SUM(flag%iarray2(
+     &                            oldB%imin(1):oldB%imax(1),j))
+         enddo      
+      endif
+      if ( Agrif_probdim .EQ. 3 ) then
+         do i = oldB%imin(1),oldB%imax(1)
+            i_sig(i) = SUM(flag%iarray3(i,
+     &                            oldB%imin(2):oldB%imax(2),
+     &                            oldB%imin(3):oldB%imax(3)))
+         enddo
+         do j = oldB%imin(2),oldB%imax(2)
+            j_sig(j) = SUM(flag%iarray3(
+     &                          oldB%imin(1):oldB%imax(1),j,
+     &                          oldB%imin(3):oldB%imax(3)))
+         enddo
+         do k = oldB%imin(3),oldB%imax(3)
+            k_sig(k) = SUM(flag%iarray3(
+     &                          oldB%imin(1):oldB%imax(1),
+     &                          oldB%imin(2):oldB%imax(2),k))
+         enddo      
+      endif
+C                    
+      do iii = 1 , Agrif_probdim
+         ipl(iii) = oldB%imin(iii)
+         ipu(iii) = oldB%imax(iii)
+      enddo
+C           
+      Call Agrif_Clusterprune(i_sig,ipl(1),ipu(1)) 
+      if ( Agrif_probdim .GE. 2 ) 
+     &   Call Agrif_Clusterprune(j_sig,ipl(2),ipu(2))      
+      if ( Agrif_probdim .EQ. 3 ) 
+     &   Call Agrif_Clusterprune(k_sig,ipl(3),ipu(3))      
+C     
+      test = .TRUE.
+      do iii = 1 , Agrif_probdim
+         test = test .AND. (ipl(iii).EQ.oldB%imin(iii))
+         test = test .AND. (ipu(iii).EQ.oldB%imax(iii))
+      enddo
+      
+      if (.NOT. test) then 
+          do iii = 1 , Agrif_probdim
+             newB%imin(iii) = ipl(iii)
+             newB%imax(iii) = ipu(iii)
+          enddo
+C        
+          if ( Agrif_probdim .EQ. 1 ) 
+     &       nbpoints = SUM(flag%iarray1(newB%imin(1):newB%imax(1)))   
+          if ( Agrif_probdim .EQ. 2 ) 
+     &       nbpoints = SUM(flag%iarray2(newB%imin(1):newB%imax(1),
+     &                           newB%imin(2):newB%imax(2)))   
+          if ( Agrif_probdim .EQ. 3 ) 
+     &       nbpoints = SUM(flag%iarray3(newB%imin(1):newB%imax(1),
+     &                           newB%imin(2):newB%imax(2),   
+     &                           newB%imin(3):newB%imax(3)))
+C   
+          if ( Agrif_probdim .EQ. 1 ) 
+     &       TailleTab = newB%imax(1)-newB%imin(1)+1
+          if ( Agrif_probdim .EQ. 2 ) 
+     &       TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                   (newB%imax(2)-newB%imin(2)+1)
+          if ( Agrif_probdim .EQ. 3 ) 
+     &       TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                   (newB%imax(2)-newB%imin(2)+1)*
+     &                   (newB%imax(3)-newB%imin(3)+1)
+C
+          neweff = REAL(nbpoints)/TailleTab
+C     
+          if (nbpoints.GT.0) then
+C        
+              if ((neweff .GT .Agrif_efficiency)) then
+                  Call Agrif_Add_Rectangle(newB,boxlib)
+                  Return
+              else
+C            
+                  tempbox => boxlib
+                  newB2 = newB
+                  Call Agrif_Clusternd(flag,
+     &                      boxlib,newB)
+C     
+C                 Compute new efficiency
+C
+                  cureff = neweff
+                  parcbox2 => boxlib
+                  nbpoints = 0
+                  nbpointsflag = 0
+C
+                  do While (associated(parcbox2))
+                    if (associated(parcbox2,tempbox)) Exit
+                    newB = parcbox2%r
+C
+                    if ( Agrif_probdim .EQ. 1 ) Valsum = 
+     &                                 SUM(flag%iarray1(
+     &                                 newB%imin(1):newB%imax(1)))
+                    if ( Agrif_probdim .EQ. 2 ) Valsum = 
+     &                                 SUM(flag%iarray2(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2)))
+                    if ( Agrif_probdim .EQ. 3 ) Valsum = 
+     &                                 SUM(flag%iarray3(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2),
+     &                                 newB%imin(3):newB%imax(3)))
+C
+                    nbpointsflag = nbpointsflag + ValSum
+                    if ( Agrif_probdim .EQ. 1 ) 
+     &                 TailleTab = newB%imax(1)-newB%imin(1)+1
+                    if ( Agrif_probdim .EQ. 2 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)
+                    if ( Agrif_probdim .EQ. 3 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)*
+     &                             (newB%imax(3)-newB%imin(3)+1)
+                    nbpoints = nbpoints + TailleTab
+                    parcbox2 => parcbox2%next  
+                  enddo  
+C coefficient 1.05 avant 1.15 possibilité de laisser choix à l utilisateur
+                  if  (REAL(nbpointsflag)/REAL(nbpoints)
+     &                 .LT.(1.0001*cureff)) then
+                      parcbox2 => boxlib            
+                      do While (associated(parcbox2))
+                        if (associated(parcbox2,tempbox)) Exit
+                        deallocate(parcbox2%r)
+                        parcbox2 => parcbox2%next             
+                      enddo      
+                      boxlib => tempbox
+                      Call Agrif_Add_Rectangle(newB2,boxlib)
+                      Return
+                  endif
+              endif         
+          endif
+          Return
+      endif 
+C       
+      do iii = 1 , Agrif_Probdim
+         istr(iii) = oldB%imax(iii)
+         islice(iii) = oldB%imin(iii)
+      enddo     
+C      
+      Call Agrif_Clusterslice(i_sig,islice(1),istr(1)) 
+      if ( Agrif_probdim .GE. 2 ) 
+     & Call Agrif_Clusterslice(j_sig,islice(2),istr(2)) 
+      if ( Agrif_probdim .EQ. 3 ) 
+     & Call Agrif_Clusterslice(k_sig,islice(3),istr(3)) 
+C      
+      ValSum = 0
+      do iii = 1 , Agrif_Probdim
+         Valsum = valSum + islice(iii)
+      enddo
+C      
+      if ( Valsum .EQ. -Agrif_Probdim ) then 
+          Call Agrif_Add_Rectangle(oldB,boxlib) 
+          Return 
+      endif 
+C       
+      nullify(tempbox)
+      tempbox => boxlib
+      if ( Agrif_probdim .EQ. 1 ) 
+     &      cureff  = oldB%imax(1)-oldB%imin(1)+1
+      if ( Agrif_probdim .EQ. 2 ) 
+     &      cureff  = (oldB%imax(1)-oldB%imin(1)+1)*
+     &                (oldB%imax(2)-oldB%imin(2)+1)
+      if ( Agrif_probdim .EQ. 3 ) 
+     &       cureff = (oldB%imax(1)-oldB%imin(1)+1)*
+     &                (oldB%imax(2)-oldB%imin(2)+1)*
+     &                (oldB%imax(3)-oldB%imin(3)+1)
+      Nullify(parcbox)
+C 
+      do iii = 1 , Agrif_Probdim
+          newB%imax(iii) = oldB%imax(iii)            
+          newB%imin(iii) = oldB%imin(iii)
+      enddo     
+C
+      ValMax = 0
+      do iii = 1 , Agrif_Probdim
+         ValMax = Max(ValMax,istr(iii))
+      enddo
+C
+      if (istr(1) .EQ. ValMax ) then
+          newB%imax(1) = islice(1)
+          Call Agrif_Add_Rectangle(newB,parcbox)                   
+          newB%imin(1) = islice(1)+1
+          newB%imax(1) = oldB%imax(1)
+          Call Agrif_Add_Rectangle(newB,parcbox)
+      elseif ( Agrif_probdim .GE. 2 ) then
+         if (istr(2) .EQ. ValMax ) then
+            newB%imax(2) = islice(2)
+            Call Agrif_Add_Rectangle(newB,parcbox)
+            newB%imin(2) = islice(2)+1
+            newB%imax(2) = oldB%imax(2)
+            Call Agrif_Add_Rectangle(newB,parcbox)
+         elseif ( Agrif_probdim .EQ. 3 ) then
+            newB%imax(3) = islice(3)
+            Call Agrif_Add_Rectangle(newB,parcbox)
+            newB%imin(3) = islice(3)+1
+            newB%imax(3) = oldB%imax(3)
+            Call Agrif_Add_Rectangle(newB,parcbox)
+         endif
+      endif
+C      
+      do While (associated(parcbox))
+        newB = parcbox%r            
+C
+        if ( Agrif_probdim .EQ. 1 ) nbpoints = 
+     &                                 SUM(flag%iarray1(
+     &                                 newB%imin(1):newB%imax(1)))
+        if ( Agrif_probdim .EQ. 2 ) nbpoints = 
+     &                                 SUM(flag%iarray2(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2)))
+        if ( Agrif_probdim .EQ. 3 ) nbpoints = 
+     &                                 SUM(flag%iarray3(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2),
+     &                                 newB%imin(3):newB%imax(3)))
+C      
+       if ( Agrif_probdim .EQ. 1 ) 
+     &                 TailleTab = newB%imax(1)-newB%imin(1)+1
+       if ( Agrif_probdim .EQ. 2 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)
+       if ( Agrif_probdim .EQ. 3 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)*
+     &                             (newB%imax(3)-newB%imin(3)+1)
+
+        neweff = REAL(nbpoints) / TailleTab
+C     
+        if (nbpoints .GT. 0) then
+C      
+            if ((neweff .GT .Agrif_efficiency)) then
+                Call Agrif_Add_Rectangle(newB,boxlib)
+            else
+                tempbox => boxlib
+                newB2 = newB
+                Call Agrif_Clusternd(flag,
+     &                      boxlib,newB)
+C
+C               Compute new efficiency
+C
+                cureff = neweff
+                parcbox2 => boxlib
+                nbpoints = 0
+                nbpointsflag = 0
+C
+                do While (associated(parcbox2))
+                  if (associated(parcbox2,tempbox)) Exit
+                  newB = parcbox2%r
+C
+                  if ( Agrif_probdim .EQ. 1 ) ValSum = 
+     &                                 SUM(flag%iarray1(
+     &                                 newB%imin(1):newB%imax(1)))
+                  if ( Agrif_probdim .EQ. 2 ) ValSum = 
+     &                                 SUM(flag%iarray2(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2)))
+                  if ( Agrif_probdim .EQ. 3 ) ValSum = 
+     &                                 SUM(flag%iarray3(
+     &                                 newB%imin(1):newB%imax(1),
+     &                                 newB%imin(2):newB%imax(2),
+     &                                 newB%imin(3):newB%imax(3)))
+C
+                  nbpointsflag = nbpointsflag + ValSum
+C
+                    if ( Agrif_probdim .EQ. 1 ) 
+     &                 TailleTab = newB%imax(1)-newB%imin(1)+1
+                    if ( Agrif_probdim .EQ. 2 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)
+                    if ( Agrif_probdim .EQ. 3 ) 
+     &                 TailleTab = (newB%imax(1)-newB%imin(1)+1)*
+     &                             (newB%imax(2)-newB%imin(2)+1)*
+     &                             (newB%imax(3)-newB%imin(3)+1)
+
+                  nbpoints = nbpoints + TailleTab
+C              
+                  parcbox2 => parcbox2%next  
+                enddo   
+C            
+                if  (REAL(nbpointsflag)/REAL(nbpoints)
+     &               .LT.(1.15*cureff)) then
+                    parcbox2 => boxlib            
+                    do While (associated(parcbox2))
+                      if (associated(parcbox2,tempbox)) Exit
+                      deallocate(parcbox2%r)
+                      parcbox2 => parcbox2%next             
+                    enddo
+                    boxlib => tempbox
+                    Call Agrif_Add_Rectangle(newB2,boxlib)
+                endif
+            endif
+        endif
+        parcbox => parcbox%next
+      enddo
+C      
+C      
+      Return
+C      
+      End Subroutine Agrif_Clusternd 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Clusterslice
+C     **************************************************************************
+C                           
+      Subroutine Agrif_Clusterslice(sig,slice,str) 
+C
+C
+CCC   Description:
+CCC   
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Arguments 
+      INTEGER                      :: slice,str
+      INTEGER,DIMENSION(slice:str) :: sig 
+C
+C     Local variables      
+      INTEGER                      :: ideb,ifin
+      INTEGER                      :: i,t,a,di,ts 
+      INTEGER,DIMENSION(slice:str) :: lap 
+C
+C    
+      ideb = slice
+      ifin = str
+C    
+      if (SIZE(sig) <= 2*Agrif_Minwidth) then
+          str = -1 
+          slice = -1 
+          Return
+      endif
+C      
+      t = -1 
+      a = -1 
+C
+      do i = ideb+Agrif_Minwidth-1,ifin-Agrif_Minwidth
+          if (sig(i) .EQ. 0) then
+              if ((i-ideb) < (ifin-i)) then
+                  di = i - ideb
+                else 
+                  di = ifin - i 
+              endif
+C
+              if (di > t) then
+                a = i 
+                t = di 
+              endif
+         endif
+      enddo
+C      
+      if (a .NE. (-1)) then
+          slice = a 
+          str = t 
+          Return
+      endif
+C      
+      t = -1 
+      a = -1 
+C      
+      do i = ideb+1,ifin-1 
+        lap(i) = sig(i+1) + sig(i-1) - 2*sig(i) 
+      enddo
+C      
+      do i = ideb + Agrif_Minwidth-1,ifin-Agrif_Minwidth
+        if ((lap(i+1)*lap(i)) .LE. 0) then
+            ts = ABS(lap(i+1) - lap(i)) 
+            if (ts > t) then
+                t = ts 
+                a = i
+            endif
+       endif
+      enddo
+C      
+      if (a .EQ. (ideb + Agrif_Minwidth - 1)) then
+          a = -1
+          t = -1
+      endif
+C      
+      slice = a 
+      str = t 
+C
+C      
+      End Subroutine Agrif_Clusterslice       
+C
+C
+C    
+C     **************************************************************************
+CCC   Subroutine Agrif_Clusterprune
+C     **************************************************************************
+C      
+      Subroutine Agrif_Clusterprune(sig,pl,pu) 
+C
+C
+CCC   Description:
+CCC   
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C     Arguments
+      INTEGER                  :: pl,pu 
+      INTEGER,DIMENSION(pl:pu) :: sig
+C
+C     Local variables      
+      INTEGER :: ideb,ifin       
+      INTEGER :: diff,addl,addu,udist,ldist  
+C
+C      
+      ideb = pl
+      ifin = pu
+C      
+      if (SIZE(sig) <= Agrif_Minwidth) then
+          return 
+      endif 
+C       
+      do While ((sig(pl) .EQ. 0) .AND. (pl < ifin)) 
+        pl = pl + 1 
+      enddo 
+C       
+      do While ((sig(pu) .EQ. 0) .AND. (pu > ideb)) 
+        pu = pu - 1 
+      enddo 
+C       
+      if ((pu-pl) < Agrif_Minwidth) then
+          diff = Agrif_Minwidth - (pu - pl + 1) 
+          udist = ifin - pu 
+          ldist = pl - ideb
+          addl = diff / 2 
+          addu = diff - addl 
+          if (addu > udist) then
+              addu = udist 
+              addl = diff - addu 
+          endif
+C         
+          if (addl > ldist) then
+              addl = ldist 
+              addu = diff - addl
+          endif
+C         
+          pu = pu + addu 
+          pl = pl - addl         
+C      
+      endif 
+C       
+C
+      End Subroutine Agrif_Clusterprune
+C
+C
+C              
+C     **************************************************************************
+CCC   Subroutine Agrif_Add_Rectangle 
+C     **************************************************************************
+C        
+      Subroutine Agrif_Add_Rectangle(R,LR)
+C
+CCC   Description:
+CCC   Subroutine to add the Agrif_Rectangle R in a list managed by LR.
+C
+C     Declarations:
+C
+C     Arguments               
+      TYPE(AGRIF_rectangle)           :: R  
+      TYPE(AGRIF_lrectangle), Pointer :: LR
+C
+C     Local variable        
+      TYPE(AGRIF_lrectangle), Pointer :: newrect  
+C
+      INTEGER                         :: iii 
+C
+C        
+      allocate(newrect)
+      allocate(newrect % r)
+C
+      newrect % r = R
+C      
+      do iii = 1 , Agrif_Probdim
+         newrect % r % spaceref(iii) = Agrif_Coeffref(iii)
+         newrect % r % timeref(iii) = Agrif_Coeffreft(iii)
+      enddo
+C              
+      newrect % r % number = -1            
+      Nullify(newrect % r % childgrids)
+      newrect % next => LR  
+      LR => newrect  
+C
+C      
+      End Subroutine Agrif_Add_Rectangle   
+C  
+C
+C  
+C     **************************************************************************
+CCC   Subroutine Agrif_Read_Fix_Grd  
+C     **************************************************************************
+C      
+      Recursive Subroutine Agrif_Read_Fix_Grd(coarsegrid,j,nunit)
+C
+CCC   Description:
+CCC   Subroutine to create the grid hierarchy from the reading of the 
+CCC   AGRIF_FixedGrids.in file.
+C
+CC    Method:
+CC    Recursive subroutine and creation of a first grid hierarchy from the
+CC    reading of the AGRIF_FixedGrids.in file.        
+C
+C     Declarations:
+C
+C     Pointer argument      
+      TYPE(AGRIF_rectangle), Pointer   :: coarsegrid ! Pointer on the first grid
+                                                     ! of the grid hierarchy
+C                                    
+C     Scalar arguments                                    
+      INTEGER                          :: j          ! Number of the new grid
+      INTEGER                          :: nunit      ! unit associated with file
+C      
+C     Local variables      
+      TYPE(AGRIF_rectangle)            :: newrect    ! Pointer on a new grid   
+      TYPE(AGRIF_lrectangle), Pointer  :: parcours   ! Pointer for the recursive
+                                                     !    procedure
+      TYPE(AGRIF_lrectangle), Pointer  :: newlrect
+      TYPE(AGRIF_lrectangle), Pointer  :: end_list       
+      INTEGER                          :: i          ! for each child grid
+      INTEGER                          :: nb_grids   ! Number of child grids
+      INTEGER                          :: iii
+C          
+C
+      Nullify(newrect%childgrids)
+C      
+C     Reading of the number of child grids        
+      read(nunit,*) nb_grids
+C      
+C     coarsegrid%nbgridchild = nb_grids
+C      
+      allocate(end_list)
+C
+      nullify(end_list % r)
+      nullify(end_list % next)
+C      
+      coarsegrid % childgrids => end_list
+C
+C     Reading of imin(1),imax(1),imin(2),imax(2),imin(3),imax(3), and space and
+C        time refinement factors for each child grid.
+C     Creation and addition of the new grid to the grid hierarchy. 
+C
+      do i = 1,nb_grids
+        allocate(newlrect)      
+        newrect % number = j   ! Number of the grid
+C
+        if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+           if (Agrif_Probdim == 3) then  
+            read(nunit,*) newrect % imin(1), newrect % imax(1),
+     &                    newrect % imin(2), newrect % imax(2),
+     &                    newrect % imin(3), newrect % imax(3),
+     &                    newrect % spaceref(1),newrect % spaceref(2),
+     &                    newrect % spaceref(3),
+     &                    newrect % timeref(1),newrect % timeref(2),
+     &                    newrect % timeref(3)
+           elseif (Agrif_Probdim == 2) then            
+            read(nunit,*) newrect % imin(1),newrect % imax(1),
+     &                  newrect % imin(2),newrect % imax(2),
+     &                    newrect % spaceref(1),newrect % spaceref(2),
+     &                    newrect % timeref(1),newrect % timeref(2)
+           elseif (Agrif_Probdim == 1) then
+            read(nunit,*) newrect % imin(1), newrect % imax(1),
+     &                    newrect % spaceref(1),
+     &                    newrect % timeref(1)
+           endif
+        else
+           if (Agrif_Probdim == 3) then  
+            read(nunit,*) newrect % imin(1), newrect % imax(1),
+     &                    newrect % imin(2), newrect % imax(2),
+     &                    newrect % imin(3), newrect % imax(3),
+     &                    newrect % spaceref(1),newrect % spaceref(2),
+     &                    newrect % spaceref(3),
+     &                    newrect % timeref(1)
+           elseif (Agrif_Probdim == 2) then            
+            read(nunit,*) newrect % imin(1),newrect % imax(1),
+     &                  newrect % imin(2),newrect % imax(2),
+     &                    newrect % spaceref(1),newrect % spaceref(2),
+     &                    newrect % timeref(1)
+           elseif (Agrif_Probdim == 1) then
+            read(nunit,*) newrect % imin(1), newrect % imax(1),
+     &                    newrect % spaceref(1),
+     &                    newrect % timeref(1)
+           endif
+C
+           if ( Agrif_probdim .GE. 2 ) then
+              do iii = 2 , Agrif_probdim
+                 newrect % timeref(iii) = newrect % timeref(1) 
+              enddo
+           endif
+C
+        endif
+C
+C       Addition to the grid hierarchy
+C
+        nullify(newrect % childgrids)
+        j = j + 1
+        Allocate(newlrect%r)
+        newlrect % r = newrect 
+        nullify(newlrect % next)
+        end_list % next => newlrect
+        end_list => end_list % next
+      enddo
+C      
+      coarsegrid % childgrids => coarsegrid % childgrids % next
+      parcours => coarsegrid % childgrids
+C
+C     Recursive operation to create the grid hierarchy branch by branch
+C
+      do while (associated(parcours))
+        call Agrif_Read_Fix_Grd (parcours % r,j,nunit)
+        parcours => parcours % next
+      enddo
+C      
+C
+      End Subroutine Agrif_Read_Fix_Grd        
+C        
+C 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Create_Grids  
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Create_Grids(g,coarsegrid)
+C
+CCC   Description:
+CCC   Subroutine to create the grid hierarchy (g) from the one created with the
+CCC   Agrif_Read_Fix_Grd or Agrif_Cluster_All procedures (coarsegrid).
+C
+CC    Method:
+CC    Recursive subroutine.        
+C
+C     Declarations:
+C
+C     Pointer arguments        
+      TYPE(AGRIF_grid)     , Pointer  :: g          ! Pointer on the root coarse
+                                                    ! grid
+      TYPE(AGRIF_rectangle), Pointer  :: coarsegrid ! Pointer on the root coarse
+                                                    ! grid of the grid hierarchy
+                                                    ! created with the
+                                                    ! Agrif_Read_Fix_Grd
+                                                    ! subroutine
+C
+C     Local pointers
+      TYPE(Agrif_grid)      , Pointer :: newgrid    ! New grid
+      TYPE(Agrif_pgrid)     , Pointer :: newpgrid
+      TYPE(Agrif_pgrid)     , Pointer :: parcours2
+      TYPE(Agrif_lrectangle), Pointer :: parcours
+      TYPE(Agrif_pgrid)     , Pointer :: end_list
+      TYPE(Agrif_pgrid)     , Pointer :: parcours3
+C
+C     Local scalars      
+      LOGICAL                         :: nullliste
+      INTEGER                         :: iii
+      INTEGER                         :: moving_grid_id = 0      
+
+C
+      parcours3 => g % child_grids
+C     
+      if (associated(parcours3)) then
+          do While (associated(parcours3 % next))
+            parcours3 => parcours3 % next
+          enddo
+          end_list => parcours3
+          nullliste=.FALSE.
+        else
+          allocate(end_list)
+          nullify(end_list % gr)
+          nullify(end_list % next)      
+          g % child_grids => end_list 
+          parcours3 => end_list      
+          nullliste=.TRUE.
+      endif
+C      
+      parcours => coarsegrid % childgrids
+C      
+C     Creation of the grid hierarchy from the one created by using the 
+C     Agrif_Read_Fix_Grd subroutine 
+C
+      do while (associated(parcours))
+        allocate(newgrid)        
+        moving_grid_id=moving_grid_id+1
+        newgrid % grid_id = moving_grid_id
+        do iii = 1 , Agrif_Probdim
+           newgrid % spaceref(iii) = parcours % r % spaceref(iii)
+           newgrid % timeref(iii) = parcours % r % timeref(iii)
+        enddo
+C
+        do iii = 1 , Agrif_Probdim
+          newgrid % nb(iii) = (parcours % r % imax(iii) 
+     &                       - parcours % r % imin(iii)) 
+     &                       * parcours % r % spaceref(iii)
+C     
+          newgrid % ix(iii) =  parcours % r % imin(iii)
+C
+          newgrid % Agrif_d(iii) = g % Agrif_d(iii) 
+     &                  / REAL(newgrid % spaceref(iii))
+C
+          newgrid % Agrif_x(iii) = g % Agrif_x(iii) +
+     &      (parcours % r % imin(iii) - 1)* g % Agrif_d(iii)
+C      
+        enddo
+C
+C       Pointer on the parent grid                        
+C
+        newgrid % parent => g      
+C      
+C       Grid pointed by newgrid is a fixed grid      
+C
+        if (parcours % r % number .GT. 0) then      
+            newgrid % fixed = .true.  
+          else
+            newgrid % fixed = .false.
+        endif
+C
+C       Number of the grid pointed by newgrid
+        newgrid % fixedrank = parcours % r % number
+C           
+C       No time calculation on this grid         
+        newgrid % ngridstep = 0      
+C
+C       Test indicating if the current grid has a common border with the root 
+C       coarse grid in the x direction
+        do iii = 1 , Agrif_Probdim
+           newgrid % NearRootBorder(iii) = .FALSE.
+C        
+           if ((newgrid % parent % NearRootBorder(iii)) .AND. 
+     &         (newgrid % ix(iii) == 1)) then
+               newgrid % NearRootBorder(iii) = .TRUE.
+           endif
+C
+           newgrid % DistantRootBorder(iii) = .FALSE.
+C 
+           if ((newgrid % parent % DistantRootBorder(iii)) .AND. 
+     &         (newgrid % ix(iii) + 
+     &         (newgrid % nb(iii)/newgrid % spaceref(iii))  
+     &          - 1  == newgrid % parent % nb(iii))) then
+               newgrid % DistantRootBorder(iii) = .TRUE.
+           endif
+        enddo
+C
+C       Writing in output files
+C
+        newgrid % oldgrid = .FALSE.      
+C
+C     
+C       Definition of the CHARACTERistics of the variable of the grid pointed by
+C       newgrid 
+        Call Agrif_Create_Var (newgrid)
+C      
+C       Instanciation of the grid pointed by newgrid and its variables
+        Call Agrif_Instance (newgrid)
+C       
+C       Nullify the variable of the grid pointed by newgrid
+C
+C
+C       Addition of this grid to the grid hierarchy 
+C      
+        nullify(newgrid % child_grids)
+        allocate(newpgrid)  
+        newpgrid % gr => newgrid
+        nullify(newpgrid % next)
+        end_list % next => newpgrid
+        end_list => end_list % next               
+        parcours => parcours % next
+C
+C       Updating the total number of fixed grids
+        if (newgrid % fixed) then
+            AGRIF_nbfixedgrids = AGRIF_nbfixedgrids + 1
+        endif
+C                  
+      enddo
+C
+C
+      if (nullliste) then
+          g % child_grids => g % child_grids % next
+          parcours2 => g % child_grids
+          deallocate(parcours3)
+        else
+          parcours2 => parcours3 % next
+      endif
+C      
+      parcours => coarsegrid % childgrids
+C
+C     Recursive call to the subroutine Agrif_Create_Fixed_Grids to create the
+C     grid hierarchy
+C      
+      do while (associated(parcours))
+        Call Agrif_Create_Grids (parcours2 % gr,parcours % r)
+        parcours => parcours % next
+        parcours2 => parcours2 % next
+      enddo 
+C      
+      Return      
+C                  
+      End Subroutine Agrif_Create_Grids
+C
+C      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_Hierarchy  
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Init_Hierarchy(g) 
+C
+CCC   Description:
+CCC   Subroutine to initialize all the grids except the root coarse grid (this 
+CCC   one, pointed by AGRIF_mygrid, is initialized by the subroutine 
+CCC   Agrif_Init_Grids defi ned in the module Agrif_Util and called in the main 
+CCC   program ). 
+C
+CC    Method:
+CC    Recursive subroutine.        
+C
+C     Declarations:
+C
+C     Pointer argument      
+      TYPE(AGRIF_grid), Pointer  :: g         ! Pointer on the root coarse grid 
+C      
+C     Local variables      
+      TYPE(AGRIF_pgrid), Pointer :: parcours  ! Pointer for the recursive call
+      LOGICAL                    :: Init_Hierarchy
+C      
+C
+      parcours=>g%child_grids
+C      
+      do while (associated(parcours))
+        Init_Hierarchy = .false.
+        if ( AGRIF_USE_FIXED_GRIDS .EQ. 1 .OR. 
+     &       AGRIF_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then
+           if ((parcours%gr%fixed) 
+     &         .AND. (Agrif_mygrid%ngridstep == 0)) then
+              Init_Hierarchy = .true.
+           endif      
+       endif
+C
+       if (.NOT. parcours%gr%fixed) Init_Hierarchy = .true.
+       if (parcours % gr % oldgrid) Init_Hierarchy = .false.
+C
+       if (Init_Hierarchy) then 
+C
+C           Instanciation of the grid pointed by parcours%gr and its variables 
+            Call Agrif_Instance (parcours % gr)
+C    
+C           Allocation of the arrays containing values of the variables of the
+C           grid pointed by parcours%gr      
+C      
+            Call Agrif_Allocation (parcours % gr)   
+C            
+            Call Agrif_initialisations(parcours % gr)              
+C       
+            Call Agrif_Instance(parcours % gr)
+C
+            if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+              Call Agrif_Allocate_Restore (parcours % gr)
+            endif
+C
+            if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+C              Initialization by copy of the grids created by clustering 
+               Call AGRIF_CopyFromold_All (parcours%gr,
+     &                                     Agrif_oldmygrid)
+            endif
+C
+C           Initialization by interpolation 
+C           (this routine is written by the user) 
+            Call Agrif_InitValues()
+C
+            if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+               Call Agrif_Free_Restore (parcours % gr)
+            endif
+C
+       endif                                  
+       parcours => parcours % next 
+C         
+      enddo
+C
+      parcours => g % child_grids
+C      
+C     Recursive operation to initialize all the grids
+      do while (associated(parcours))
+        Call Agrif_Init_Hierarchy (parcours%gr)
+        parcours => parcours%next
+      enddo
+C      
+      End Subroutine Agrif_Init_Hierarchy 
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Allocate_Restore  
+C     **************************************************************************
+C
+      Subroutine Agrif_Allocate_Restore(Agrif_Gr)
+C      
+C      
+C     Modules used:
+C
+      TYPE(AGRIF_grid), Pointer  :: Agrif_Gr   ! Pointer on the root coarse grid
+C     
+      INTEGER                    :: i
+C
+        do i = 1 , Agrif_NbVariables
+            if ( Agrif_Mygrid%tabvars(i)%var % restaure ) then
+            if ( Agrif_Gr%tabvars(i)%var % nbdim .EQ. 1 ) then    
+            Allocate( Agrif_Gr%tabvars(i)%var%  
+     &    Restore1D(lbound(Agrif_Gr%tabvars(i)%var%array1,1) 
+     &    :ubound(Agrif_Gr%tabvars(i)%var%array1,1))) 
+            Agrif_Gr%tabvars(i)%var%Restore1D = 0
+C
+            endif
+            if ( Agrif_Gr%tabvars(i)%var % nbdim .EQ. 2 ) then
+            Allocate( Agrif_Gr%tabvars(i)%var%Restore2D(  
+     &      lbound(Agrif_Gr%tabvars(i)%var%array2,1):         
+     &      ubound(Agrif_Gr%tabvars(i)%var%array2,1),         
+     &      lbound(Agrif_Gr%tabvars(i)%var%array2,2)          
+     &      :ubound(Agrif_Gr%tabvars(i)%var%array2,2)))         
+            Agrif_Gr%tabvars(i)%var%Restore2D = 0
+C
+            endif
+            if ( Agrif_Mygrid%tabvars(i)%var % nbdim .EQ. 3 ) then
+C     
+            Allocate( Agrif_Gr%tabvars(i)%var%Restore3D( 
+     &      lbound(Agrif_Gr%tabvars(i)%var%array3,1):        
+     &      ubound(Agrif_Gr%tabvars(i)%var%array3,1),        
+     &      lbound(Agrif_Gr%tabvars(i)%var%array3,2):        
+     &      ubound(Agrif_Gr%tabvars(i)%var%array3,2),        
+     &      lbound(Agrif_Gr%tabvars(i)%var%array3,3):        
+     &      ubound(Agrif_Gr%tabvars(i)%var%array3,3)))  
+            Agrif_Gr%tabvars(i)%var%Restore3D = 0
+            endif
+C 
+            endif
+          enddo
+C
+      Return
+C
+C      
+      End Subroutine Agrif_Allocate_Restore      
+C
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Free_Restore  
+C     **************************************************************************
+C
+      Subroutine Agrif_Free_Restore(Agrif_Gr)
+C
+C      
+C     Pointer argument      
+      TYPE(AGRIF_grid), Pointer  :: Agrif_Gr   ! Pointer on the root coarse grid
+      INTEGER :: i     
+C
+      do i = 1 , Agrif_NbVariables
+         if ( Agrif_Mygrid % tabvars(i) % var % restaure) then
+C  
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore1D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore1D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore2D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore2D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore3D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore3D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore4D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore4D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore5D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore5D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%Restore6D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%Restore6D)
+            endif
+C 
+        endif
+      enddo
+C 
+      Return
+C
+C      
+      End Subroutine Agrif_Free_Restore
+C
+C
+C
+      End Module Agrif_Clustering
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcurgridfunctions.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcurgridfunctions.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modcurgridfunctions.F	(revision 1844)
@@ -0,0 +1,970 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place-  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_CurgridFunctions      
+C      
+      Module Agrif_CurgridFunctions    
+C  
+CCC   Description:
+CCC   Module to define some procedures concerning the current grid
+C
+C     Modules used: 
+C
+      Use Agrif_Init
+C
+      IMPLICIT NONE
+C
+C
+      Contains
+C     Define procedures contained in this module
+C
+C     **************************************************************************
+CCC   Function Agrif_Rhot
+C     **************************************************************************
+C
+      Function Agrif_Rhot()
+C  
+CCC   Description:
+CCC   Function returning the time refinement factor of the current grid.
+C
+C     Declarations:
+C  
+      
+C
+      REAL :: Agrif_Rhot  ! Result
+C
+C     Local scalar      
+      INTEGER :: res         ! Intermediate result
+      INTEGER :: iii
+C
+C
+      res=1
+C
+      do iii = 1 , Agrif_Probdim
+         res = max(res, AGRIF_Curgrid % timeref(iii))
+      enddo
+C
+      Agrif_Rhot = float(res)
+C
+C
+      End function Agrif_rhot
+C
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_IRhot
+C     **************************************************************************
+C
+      Function Agrif_IRhot()
+C  
+CCC   Description:
+CCC   Function returning the time refinement factor of the current grid.
+C
+C     Declarations:
+C  
+      
+C
+      INTEGER :: Agrif_IRhot  ! Result
+C
+C     Local scalar      
+      INTEGER :: res         ! Intermediate result
+      INTEGER :: iii
+C
+C
+      res=1
+C
+      do iii = 1 , Agrif_Probdim
+         res = max(res, AGRIF_Curgrid % timeref(iii))
+      enddo
+C
+      Agrif_IRhot = res
+C
+C
+      End function Agrif_IRhot
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Parent_Rhot
+C     **************************************************************************
+C
+      Function Agrif_Parent_Rhot()
+C  
+CCC   Description:
+CCC   Function returning the time refinement factor of the parent grid of the 
+CCC   current grid.
+C
+C     Declarations:
+C  
+      
+C
+      REAL :: Agrif_Parent_Rhot  ! Result
+C
+C     Local scalar      
+      INTEGER :: res         ! Intermediate result
+      INTEGER :: iii
+C
+C
+      res=1
+C
+      do iii = 1 , Agrif_Probdim
+         res = max(res, AGRIF_Curgrid % parent % timeref(iii))
+      enddo
+C
+      Agrif_Parent_Rhot = float(res)
+C
+C
+      End function Agrif_Parent_Rhot      
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Parent_IRhot
+C     **************************************************************************
+C
+      Function Agrif_Parent_IRhot()
+C  
+CCC   Description:
+CCC   Function returning the time refinement factor of the parent grid of the 
+CCC   current grid.
+C
+C     Declarations:
+C  
+      
+C
+      INTEGER :: Agrif_Parent_IRhot  ! Result
+C
+C     Local scalar      
+      INTEGER :: res         ! Intermediate result
+      INTEGER :: iii
+C
+C
+      res=1
+C
+      do iii = 1 , Agrif_Probdim
+         res = max(res, AGRIF_Curgrid % parent % timeref(iii))
+      enddo
+C
+      Agrif_Parent_IRhot = res
+C
+C
+      End function Agrif_Parent_IRhot      
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Nbstepint
+C     **************************************************************************
+C
+      Function Agrif_Nbstepint()
+C  
+CCC   Description:
+CCC   Function for the calculation of the coefficients used for the time 
+CCC   interpolation (module Agrif_Boundary).
+C
+C     Declarations:
+C  
+      
+C            
+      INTEGER :: Agrif_nbstepint  ! result
+C
+C
+      Agrif_nbstepint = mod(AGRIF_CURGRID % ngridstep,
+     &                      int(AGRIF_rhot()))
+C
+C
+      End function Agrif_Nbstepint
+C
+C
+C
+CC    **************************************************************************
+CCC   Function Agrif_Parent_Nbstepint
+C     **************************************************************************
+C
+      Function Agrif_Parent_Nbstepint()
+C  
+CCC   Description:
+CCC   Function for the calculation of the coefficients used for the time 
+CCC   interpolation (module Agrif_Boundary).
+C
+C     Declarations:
+C  
+      
+C            
+      INTEGER :: Agrif_Parent_Nbstepint  ! result
+C
+C
+      Agrif_Parent_Nbstepint = mod(AGRIF_CURGRID % parent % ngridstep, 
+     &                             int(AGRIF_Parent_Rhot()))
+C
+C
+      End function Agrif_Parent_Nbstepint
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpNearBorderX
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpNearBorderX()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the x direction) on a near border of 
+CCC   the current grid if this one has a common border with the root coarse 
+CCC   grid.   
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_CURGRID % NearRootBorder(1) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpNearBorderX 
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpDistantBorderX
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpDistantBorderX()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the x direction) on a distant border 
+CCC   of the current grid if this one has a common border with the root coarse  
+CCC   grid.
+C
+C     Declarations:
+C  
+
+C
+C
+      AGRIF_CURGRID % DistantRootBorder(1) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpDistantBorderX                 
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpNearBorderY
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpNearBorderY()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the y direction) on a near border of 
+CCC   the current grid if this one has a common border with the root coarse 
+CCC   grid.
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_CURGRID % NearRootBorder(2) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpNearBorderY
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpDistantBorderY
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpDistantBorderY()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the y direction) on a distant border 
+CCC   of the current grid if this one has a common border with the root coarse  
+CCC   grid.
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_CURGRID % DistantRootBorder(2) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpDistantBorderY      
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpNearBorderZ
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpNearBorderZ()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the z direction) on a near border of 
+CCC   the current grid if this one has a common border with the root coarse 
+CCC   grid.
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_CURGRID % NearRootBorder(3) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpNearBorderZ
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpDistantBorderZ
+C     **************************************************************************
+C
+      Subroutine Agrif_InterpDistantBorderZ()
+C  
+CCC   Description:
+CCC   Subroutine allowing to interpole (in the z direction) on a distant border 
+CCC   of the current grid if this one has a common border with the root coarse  
+CCC   grid.
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_CURGRID % DistantRootBorder(3) = .FALSE.             
+C
+C
+      End Subroutine Agrif_InterpDistantBorderZ
+C 
+C     **************************************************************************
+CCC   Function Agrif_Parent_Nb_Step
+C     ************************************************************************** 
+C 
+      Function AGRIF_Parent_Nb_Step() 
+C  
+CCC   Description:
+CCC   Function returning the number of time steps of the parent grid of the
+CCC   current grid.
+C
+C     Declarations:
+C    
+      
+C
+      INTEGER :: AGRIF_Parent_Nb_Step ! Result 
+C
+C
+      if (Agrif_Root()) then  
+C     
+          Agrif_Parent_Nb_Step = -1 
+C       
+        else
+C       
+          Agrif_Parent_Nb_Step = Agrif_Curgrid % parent % ngridstep
+C     
+      endif
+C
+C     
+      End function Agrif_Parent_Nb_Step    
+C 
+C
+C 
+C     **************************************************************************
+CCC   Function Agrif_Root
+C     **************************************************************************
+C
+      Function Agrif_Root()
+C     
+CCC   Description:
+CCC   Function indicating if the current grid is or not the root grid.
+C
+C     Declarations:
+C
+      
+C
+      LOGICAL :: Agrif_Root   ! Result
+C    
+C
+      if (AGRIF_CURGRID % fixedrank .EQ. 0) then
+C          
+          Agrif_Root = .TRUE.
+C    
+        else
+C    
+          Agrif_Root = .FALSE.
+C     
+      endif
+C
+C    
+      End function Agrif_Root
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Parent_Root
+C     **************************************************************************
+C
+      Function Agrif_Parent_Root()
+C     
+CCC   Description:
+CCC   Function indicating if the parent grid of the current grid is or not the 
+CCC   root grid.
+C
+C     Declarations:
+C
+      
+C
+      LOGICAL :: Agrif_Parent_Root   ! Result
+C    
+C
+      if (AGRIF_CURGRID % parent % fixedrank .EQ. 0) then
+C          
+          Agrif_Parent_Root = .TRUE.
+C    
+        else
+C    
+          Agrif_Parent_Root = .FALSE.
+C     
+      endif
+C
+C    
+      End function Agrif_Parent_Root     
+C 
+C
+C 
+C     **************************************************************************
+CCC   Function Agrif_Fixed
+C     **************************************************************************
+C 
+      Function Agrif_Fixed()
+C  
+CCC   Description:
+CCC   Function returning the number of the current grid.
+C
+C     Declarations:
+C   
+      
+C
+      INTEGER Agrif_Fixed   ! Result 
+C 
+C
+      if (Agrif_Curgrid % fixed) then
+C     
+          Agrif_Fixed = Agrif_Curgrid % fixedrank 
+C
+        else
+C     
+         Agrif_Fixed = -1
+C        
+      endif
+C
+C     
+      End function Agrif_Fixed 
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Parent_Fixed
+C     **************************************************************************
+ 
+      Function Agrif_Parent_Fixed()
+C  
+CCC   Description:
+CCC   Function returning the number of the parent grid of the current grid.
+C
+C     Declarations:
+C   
+      
+C
+      INTEGER Agrif_Parent_Fixed   ! Result 
+C 
+C
+      if (Agrif_Curgrid % parent % fixed) then
+C     
+          Agrif_Parent_Fixed = AGRIF_CURGRID % parent % fixedrank 
+C
+        else
+C     
+         Agrif_Parent_Fixed = 0
+C        
+      endif
+C
+C     
+      End function Agrif_Parent_Fixed
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Is_Fixed
+C     **************************************************************************
+ 
+      Function Agrif_Is_Fixed()
+C  
+CCC   Description:
+CCC   Function returning true if the current grid is fixed.
+C
+C     Declarations:
+C   
+      
+C
+      LOGICAL Agrif_Is_Fixed   ! Result 
+C 
+C
+      if (Agrif_Curgrid % fixed) then
+C     
+          Agrif_Is_Fixed = .true.
+C
+        else
+C     
+          Agrif_Is_Fixed = .false.
+C        
+      endif
+C
+C     
+      End function Agrif_Is_Fixed
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Parent_Is_Fixed
+C     **************************************************************************
+ 
+      Function Agrif_Parent_Is_Fixed()
+C  
+CCC   Description:
+CCC   Function returning true if the parent grid of the current grid is fixed.
+C
+C     Declarations:
+C   
+      
+C
+      LOGICAL Agrif_Parent_Is_Fixed   ! Result 
+C 
+C
+      if (Agrif_Curgrid % parent % fixed) then
+C     
+          Agrif_Parent_Is_Fixed = .true.
+C
+        else
+C     
+          Agrif_Parent_Is_Fixed = .false.
+C        
+      endif
+C
+C     
+      End function Agrif_Parent_Is_Fixed            
+C
+C 
+C
+C     **************************************************************************
+CCC   Function AGRIF_CFixed
+C     **************************************************************************
+ 
+            Function AGRIF_CFixed()
+C  
+CCC   Description:
+CCC   Function returning the number of the current grid.
+C
+C     Declarations:
+C   
+      
+C
+      CHARACTER(3) AGRIF_CFixed   ! Result 
+C
+C     Local variables      
+      CHARACTER(3) cfixed
+      INTEGER fixed
+C 
+C
+      fixed = Agrif_Fixed()
+C      
+      if(fixed.NE.-1) then
+C
+           if (fixed .LE. 9) then
+C
+               write(cfixed,'(i1)')fixed
+C 
+           else
+C   
+               write(cfixed,'(i2)')fixed
+C      
+           endif
+C
+           AGrif_Cfixed=cfixed
+C      
+      else
+C
+      print*,'Call to AGRIF_CFixed() on a moving grid'
+      stop
+C
+      endif     
+
+      End function AGRIF_CFixed
+C
+C
+C
+C     **************************************************************************
+CCC   Function AGRIF_Parent_CFixed
+C     **************************************************************************
+ 
+      Function AGRIF_Parent_CFixed()
+C  
+CCC   Description:
+CCC   Function returning the number of the parent grid of the current grid.
+C
+C     Declarations:
+C   
+      
+C
+      CHARACTER(3) AGRIF_Parent_CFixed   ! Result 
+C
+C     Local variables      
+      CHARACTER(3) cfixed
+      INTEGER fixed
+C 
+C
+      fixed = Agrif_Parent_Fixed()
+C      
+      if(fixed.NE.-1) then
+C
+          if (fixed .LE. 9) then
+C
+              write(cfixed,'(i1)')fixed
+C      
+          else
+C        
+              write(cfixed,'(i2)')fixed
+C      
+          endif
+C
+          AGrif_Parent_Cfixed=cfixed
+C
+      else
+C
+      print*,'Illegal call to AGRIF_Parent_CFixed()'
+      stop     
+C
+      endif
+
+      End function AGRIF_Parent_CFixed      
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_ChildGrid_to_ParentGrid
+C     **************************************************************************
+C
+      Subroutine Agrif_ChildGrid_to_ParentGrid()
+C  
+CCC   Description:
+CCC   Subroutine allowing to make the pointer AGRIF_CURGRID point on the parent
+CCC   grid of the current grid.
+C
+C     Declarations:
+C  
+      
+C
+C
+      AGRIF_saveCURGRID => AGRIF_CURGRID
+C
+      Call AGRIF_INSTANCE(AGRIF_CURGRID%parent)            
+C
+C
+      End Subroutine Agrif_ChildGrid_to_ParentGrid
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_ParentGrid_to_ChildGrid
+C     **************************************************************************
+C
+      Subroutine Agrif_ParentGrid_to_ChildGrid()
+C  
+CCC   Description:
+CCC   Subroutine allowing to make the pointer AGRIF_CURGRID point on the child 
+CCC   grid after having called the Agrif_ChildGrid_to_ParentGrid subroutine.
+C
+C     Declarations:
+C  
+      
+C
+C
+      Call AGRIF_INSTANCE(AGRIF_saveCURGRID)            
+C
+C
+      End Subroutine Agrif_ParentGrid_to_ChildGrid
+C
+C
+C
+C     **************************************************************************
+CCC   Function Agrif_Get_Unit
+C     **************************************************************************
+C
+      Function Agrif_Get_Unit()
+
+CCC   Description : return a unit not connected to any file
+C
+C     Declarations
+C
+      
+C
+      INTEGER Agrif_Get_Unit
+C
+C     Local scalars
+      INTEGER n
+      LOGICAL op
+C
+      INTEGER :: nunit
+      INTEGER :: iii,out,iiimax
+      Logical :: BEXIST
+      INTEGER,DIMENSION(1:10) :: ForbiddenUnit
+C
+C
+C     Load forbidden Unit if the file Agrif_forbidenUnit exist
+C      
+
+      INQUIRE(FILE='Agrif_forbiddenUnit.txt',EXIST=BEXIST)
+      If (.not. BEXIST) Then
+c          File Agrif_forbiddenUnit.txt not found
+      Else
+           nunit = 777
+           open(nunit,file='Agrif_forbiddenUnit.txt',form='formatted',
+     &          status="old")
+              iii = 1
+              do while ( .TRUE. )
+                 read(nunit,*,END = 99) ForbiddenUnit(iii)
+                 iii = iii + 1
+              enddo
+   99         CONTINUE
+              iiimax = iii
+           close(nunit)
+      endif     
+C 
+      do n = 7,1000
+C 
+        Inquire(Unit=n,Opened=op)
+C
+        out = 0
+        if ( BEXIST .AND. .NOT.op) then
+           do iii = 1 , iiimax
+              if ( n .EQ. ForbiddenUnit(iii) ) out = 1
+           enddo
+        endif
+C
+        if (.NOT.op .AND. out .EQ. 0) exit
+C      
+      enddo
+C
+      Agrif_Get_Unit=n
+C
+C
+      End Function Agrif_Get_Unit
+      
+      Subroutine Agrif_Set_Efficiency(eff)
+      REAL :: eff
+      
+      IF ((eff.LT.0.).OR.(eff.GT.1)) THEN
+      write(*,*)'Error Efficiency should be between 0 and 1'
+      stop
+      ELSE
+      Agrif_efficiency = eff
+      ENDIF
+      End Subroutine Agrif_Set_Efficiency
+      
+      Subroutine Agrif_Set_Regridding(regfreq)
+      INTEGER :: regfreq
+      
+      IF (regfreq.LT.0) THEN
+      write(*,*)'Regridding frequency should be positive'
+      stop
+      ELSE
+      Agrif_regridding = regfreq
+      ENDIF
+      End Subroutine Agrif_Set_Regridding
+C
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffref_x
+C     **************************************************************************
+      subroutine Agrif_Set_coeffref_x(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffref(1) = coefref
+      endif
+      end subroutine Agrif_Set_coeffref_x
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffref_y
+C     **************************************************************************
+      subroutine Agrif_Set_coeffref_y(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffref(2) = coefref
+      endif
+      end subroutine Agrif_Set_coeffref_y
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffref_z
+C     **************************************************************************
+      subroutine Agrif_Set_coeffref_z(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffref(3) = coefref
+      endif
+      end subroutine Agrif_Set_coeffref_z
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffreft_x
+C     **************************************************************************
+      subroutine Agrif_Set_coeffreft_x(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of time raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffreft(1) = coefref
+      endif
+      end subroutine Agrif_Set_coeffreft_x
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffreft_y
+C     **************************************************************************
+      subroutine Agrif_Set_coeffreft_y(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of time raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffreft(2) = coefref
+      endif
+      end subroutine Agrif_Set_coeffreft_y
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_coeffreft_z
+C     **************************************************************************
+      subroutine Agrif_Set_coeffreft_z(coefref)
+
+      integer :: coefref
+
+      if (coefref.LT.0) then
+         write(*,*)'Coefficient of time raffinement should be positive'
+         stop
+      else
+         AGRIF_coeffreft(3) = coefref
+      endif
+      end subroutine Agrif_Set_coeffreft_z
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_Minwidth
+C     **************************************************************************
+      subroutine Agrif_Set_Minwidth(coefminwidth)
+
+      integer :: coefminwidth
+
+      if (coefminwidth.LT.0) then
+         write(*,*)'Coefficient of Minwidth should be positive'
+         stop
+      else
+         Agrif_Minwidth = coefminwidth
+      endif
+      end subroutine Agrif_Set_Minwidth
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Set_Rafmax
+C     **************************************************************************
+      subroutine Agrif_Set_Rafmax(coefrafmax)
+
+      integer :: coefrafmax
+      integer :: i
+      real :: res
+
+      if (coefrafmax.LT.0) then
+         write(*,*)'Coefficient of  should be positive'
+         stop
+      else
+         res = 1.
+         do i = 1 , coefrafmax - 1
+            res = res * FLOAT(AGRIF_coeffref(1))
+         enddo
+         if ( res .EQ. 0 ) res = 1
+         Agrif_Mind(1) = 1. / res
+C
+         res = 1.
+         do i = 1 , coefrafmax - 1
+            res = res * FLOAT(AGRIF_coeffref(2))
+         enddo
+         if ( res .EQ. 0 ) res = 1
+         Agrif_Mind(2) = 1. / res
+C
+         res = 1.
+         do i = 1 , coefrafmax - 1
+            res = res * FLOAT(AGRIF_coeffref(3))
+         enddo
+         if ( res .EQ. 0 ) res = 1
+         Agrif_Mind(3) = 1. / res
+C
+      endif
+      end subroutine Agrif_Set_Rafmax
+C
+C     **************************************************************************
+CCC   subroutine Agrif_Open_File
+C     **************************************************************************
+      subroutine Agrif_Open_File(num_id,name_file)
+
+      integer :: num_id
+      character(*) :: name_file
+
+      num_id = Agrif_Get_Unit()
+      if ( .NOT. Agrif_Root() ) then
+         name_file = TRIM(Agrif_CFixed())//'_'//TRIM(name_file)
+      endif
+
+      end subroutine Agrif_Open_File
+
+C     **************************************************************************
+CCC    subroutine Agrif_Set_MaskMaxSearch
+C     **************************************************************************
+      subroutine Agrif_Set_MaskMaxSearch(mymaxsearch)
+      integer mymaxsearch
+      MaxSearch = mymaxsearch
+      end subroutine Agrif_Set_MaskMaxSearch
+
+      End Module Agrif_CurgridFunctions 
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modflux.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modflux.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modflux.F	(revision 1844)
@@ -0,0 +1,339 @@
+C     Agrif (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place-Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_fluxmod
+C
+      Module Agrif_fluxmod
+      Use Agrif_types
+      Use Agrif_Arrays
+      Use Agrif_Curgridfunctions
+      
+      CONTAINS  
+      
+      
+      Subroutine Agrif_AllocateFlux(Flux,fluxtab)
+      Type(Agrif_Flux), Pointer :: Flux
+      Real, Dimension(:,:) :: fluxtab
+      Type(Agrif_Profile), Pointer :: Profile
+      Integer :: dimensio,n,n2
+      INTEGER, DIMENSION(:,:), Pointer :: normalsizes
+      INTEGER, DIMENSION(6) :: unitarray
+      Type(Agrif_Variable), Pointer :: fluxtabvar
+      Integer :: nbout
+      
+      Profile => Flux%profile
+      dimensio = Profile%nbdim
+      
+      unitarray = 1
+      
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            Allocate(Flux%fluxtabx)
+            fluxtabvar => Flux%fluxtabx
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            Allocate(Flux%fluxtaby)
+            fluxtabvar => Flux%fluxtaby
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            Allocate(Flux%fluxtabz)
+            fluxtabvar => Flux%fluxtabz
+          ENDIF
+          ALLOCATE(fluxtabvar%iarray2(2,6))
+          normalsizes=>fluxtabvar%iarray2
+          normalsizes(1,1) = 2
+          nbout = 1
+          DO n2 = 1,dimensio
+            IF (n2 .NE. n) THEN
+              nbout = nbout + 1
+              If ((Profile%posvar(n2) == 1)
+     &            .OR.(Profile%posvar(n2) == 2)) THEN
+                IF (Profile%interptab(n2) == 'x') THEN
+                  normalsizes(2,n2) = 
+     &                Agrif_Curgrid%nb(1)/agrif_Curgrid%spaceref(1)
+                  normalsizes(1,nbout) = 
+     &                Agrif_Curgrid%nb(1)/agrif_Curgrid%spaceref(1)
+                ELSE IF (Profile%interptab(n2) == 'y') THEN
+                  normalsizes(2,n2) = 
+     &                Agrif_Curgrid%nb(2)/agrif_Curgrid%spaceref(2)
+                  normalsizes(1,nbout) = 
+     &                Agrif_Curgrid%nb(2)/agrif_Curgrid%spaceref(2)
+                ELSE IF (Profile%interptab(n2) == 'z') THEN
+                  normalsizes(2,n2) = 
+     &                Agrif_Curgrid%nb(3)/agrif_Curgrid%spaceref(3)
+                  normalsizes(1,nbout) = 
+     &                Agrif_Curgrid%nb(3)/agrif_Curgrid%spaceref(3)
+                ENDIF
+              ELSE
+                normalsizes(2,n2) = SIZE(fluxtab,n2)
+                normalsizes(1,nbout) = SIZE(fluxtab,n2)
+              ENDIF
+            ENDIF
+          ENDDO          
+        ENDIF
+      enddo
+      
+      
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            fluxtabvar => Flux%fluxtabx
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            fluxtabvar => Flux%fluxtaby
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            fluxtabvar => Flux%fluxtabz
+          ENDIF
+          Call Agrif_nbdim_allocation(fluxtabvar,unitarray(1:dimensio),
+     &          fluxtabvar%iarray2(1,1:dimensio),dimensio)
+        ENDIF
+      enddo
+      
+      Flux%fluxallocated = .TRUE.
+      
+      End Subroutine Agrif_AllocateFlux
+      
+      FUNCTION Agrif_Search_Flux(fluxname)
+      character*(*) fluxname
+      Type(Agrif_Flux), Pointer :: Agrif_Search_Flux
+      
+      Type(Agrif_Flux), pointer :: parcours
+      Logical :: foundflux
+      
+      foundflux = .FALSE.
+      parcours => Agrif_Curgrid%fluxes
+      
+      Do While (Associated(parcours))
+         IF (parcours % fluxname == fluxname) THEN
+           foundflux = .TRUE.
+           EXIT
+         ENDIF
+         parcours => parcours%nextflux
+      End Do
+      
+      IF (.NOT.foundflux) THEN
+      write(*,*) 'The array flux '''
+     &           //TRIM(fluxname)//''' has not been declared'
+      stop
+      ENDIF      
+      
+      Agrif_Search_Flux => parcours
+      
+      End Function Agrif_Search_Flux
+      
+      Subroutine Agrif_Save_Fluxtab(Flux,Fluxtab)
+      Type(Agrif_Flux), Pointer :: Flux
+      Real, Dimension(:,:) :: Fluxtab
+      INTEGER, DIMENSION(:,:), Pointer :: normalsizes
+      INTEGER, DIMENSION(6) :: normalsizes2, normalsizes3
+      INTEGER, DIMENSION(6) :: unitarray2, unitarray3
+      Type(Agrif_Variable), Pointer :: fluxtabvar
+      Type(Agrif_Profile), Pointer :: Profile
+      Integer :: dimensio,n,n2,j,j1,j2
+      
+      Profile => Flux%profile
+      dimensio = Profile%nbdim
+            
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            fluxtabvar => Flux%fluxtabx
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            fluxtabvar => Flux%fluxtaby
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            fluxtabvar => Flux%fluxtabz
+          ENDIF 
+          normalsizes => fluxtabvar%iarray2
+          unitarray2 = 1
+          unitarray3 = 1
+          normalsizes2 = normalsizes(1,:)
+          normalsizes3 = normalsizes(2,:)
+          
+          unitarray3(n) = Profile%point(n)
+          normalsizes3(n) = Profile%point(n) 
+                              
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+            j1 = unitarray3(2)
+            Do j=unitarray3(2),normalsizes3(2)
+            do j2 = j1,j1+Agrif_curgrid%spaceref(2)
+!            print *,'flux stocke fiun = ',j2,fluxtab(unitarray3(1),j2)
+            enddo
+            fluxtabvar%array2(1:1,j) = 
+     &      fluxtabvar%array2(1:1,j) +
+     &             SUM(fluxtab(unitarray3(1):normalsizes3(1),
+     &                        j1:j1+Agrif_Curgrid%spaceref(2)))
+             j1 = j1+Agrif_Curgrid%spaceref(2)
+            EndDo
+          END SELECT
+          
+          unitarray3(n) = Profile%point(n)+Agrif_Curgrid%nb(n)
+          normalsizes3(n) = Profile%point(n)+Agrif_Curgrid%nb(n) 
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+            j1 = unitarray3(2)
+            Do j=unitarray3(2),normalsizes3(2)
+            fluxtabvar%array2(2:2,j) = 
+     &      fluxtabvar%array2(2:2,j) +
+     &             SUM(fluxtab(unitarray3(1):normalsizes3(1),
+     &                        j1:j1+Agrif_Curgrid%spaceref(2)))
+             j1 = j1+Agrif_Curgrid%spaceref(2)
+            EndDo
+         END SELECT
+        ENDIF
+      enddo
+                  
+      End Subroutine Agrif_Save_Fluxtab
+
+      Subroutine Agrif_Save_Fluxtab_child(Flux,Fluxtab)
+      Type(Agrif_Flux), Pointer :: Flux
+      Real, Dimension(:,:) :: Fluxtab
+      INTEGER, DIMENSION(:,:), Pointer :: normalsizes
+      INTEGER, DIMENSION(6) :: normalsizes2, normalsizes3
+      INTEGER, DIMENSION(6) :: unitarray2, unitarray3
+      Type(Agrif_Variable), Pointer :: fluxtabvar
+      Type(Agrif_Profile), Pointer :: Profile
+      Integer :: dimensio,n,n2
+      
+      Profile => Flux%profile
+      dimensio = Profile%nbdim
+            
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            fluxtabvar => Flux%fluxtabx
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            fluxtabvar => Flux%fluxtaby
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            fluxtabvar => Flux%fluxtabz
+          ENDIF 
+          normalsizes => fluxtabvar%iarray2
+          unitarray2 = 1
+          unitarray3 = 1
+          normalsizes2 = normalsizes(1,:)
+          normalsizes3 = normalsizes(2,:)
+          
+          unitarray3(n) = Profile%point(n)+Agrif_Curgrid%ix(n)
+          normalsizes3(n) = unitarray3(n)
+                              
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+            fluxtabvar%array2(1:1,
+     &                        unitarray2(2):normalsizes2(2)) = 
+     &      - fluxtab(unitarray3(1):normalsizes3(1),
+     &                        unitarray3(2):normalsizes3(2))
+!        print *,'flux stocke = ',fluxtab(unitarray3(1):normalsizes3(1),
+!     &                        unitarray3(2):normalsizes3(2))
+          END SELECT
+          
+          unitarray3(n) = unitarray3(n)+
+     &         Agrif_Curgrid%nb(n)/Agrif_Curgrid%spaceref(n)
+          normalsizes3(n) = unitarray3(n)
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+            fluxtabvar%array2(2:2,
+     &                        unitarray2(2):normalsizes2(2)) = 
+     &      - fluxtab(unitarray3(1):normalsizes3(1),
+     &                        unitarray3(2):normalsizes3(2))    
+         END SELECT
+        ENDIF
+      enddo
+                  
+      End Subroutine Agrif_Save_Fluxtab_child
+      
+      Subroutine Agrif_Cancel_Fluxarray(Flux)
+      Type(Agrif_Flux), Pointer :: Flux
+      Type(Agrif_Variable), Pointer :: fluxtabvar
+      Type(Agrif_Profile), Pointer :: Profile
+      Integer :: dimensio,n,n2
+      
+      Profile => Flux%profile
+      dimensio = Profile%nbdim
+            
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            fluxtabvar => Flux%fluxtabx
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            fluxtabvar => Flux%fluxtaby
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            fluxtabvar => Flux%fluxtabz
+          ENDIF 
+                              
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+            fluxtabvar%array2 = 0.
+          END SELECT
+        ENDIF
+      enddo
+                  
+      End Subroutine Agrif_Cancel_Fluxarray  
+      
+      Subroutine Agrif_FluxCorrect(Flux, procname)
+      Type(Agrif_Flux), Pointer :: Flux
+      External :: procname
+      Type(Agrif_Variable), Pointer :: fluxtabvar
+      Type(Agrif_Profile), Pointer :: Profile
+      Integer :: dimensio,n,n2,j1,j2
+      Integer, Dimension(:), Allocatable :: Loctab
+      Integer :: locind
+      
+      Profile => Flux%profile
+      dimensio = Profile%nbdim
+
+      do n=1,dimensio
+        IF (Profile%posvar(n) == 1) THEN
+          IF (Profile%interptab(n) == 'x') THEN
+            fluxtabvar => Flux%fluxtabx
+            locind = 1
+          ELSE IF (Profile%interptab(n) == 'y') THEN
+            fluxtabvar => Flux%fluxtaby
+            locind = 2
+          ELSE IF (Profile%interptab(n) == 'z') THEN
+            fluxtabvar => Flux%fluxtabz
+            locind = 3
+          ENDIF 
+                              
+          SELECT CASE(dimensio)
+          CASE(1)
+          CASE(2)
+           Allocate(Loctab(2))
+           Loctab(1) = Agrif_Curgrid%ix(locind)
+           Loctab(2) = Agrif_Curgrid%ix(locind)+
+     &         Agrif_Curgrid%nb(locind)/Agrif_Curgrid%spaceref(locind)
+           j1 = agrif_curgrid%ix(2)
+           j2 = agrif_curgrid%ix(2)+
+     &        agrif_curgrid%nb(2)/Agrif_curgrid%spaceref(2)
+           Call Agrif_ChildGrid_to_ParentGrid()
+            Call procname(fluxtabvar%array2,Loctab(1),Loctab(2),j1,j2)
+           Call Agrif_ParentGrid_to_ChildGrid()
+          END SELECT
+        ENDIF
+      enddo
+      
+      If (Allocated(Loctab)) Deallocate(Loctab)
+                  
+      End Subroutine Agrif_FluxCorrect 
+          
+      End Module Agrif_fluxmod
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinit.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinit.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinit.F	(revision 1844)
@@ -0,0 +1,252 @@
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place-  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Init
+C
+      Module Agrif_Init 
+C
+CCC   Description:
+CCC   Several operations on the variables of the current grid (creation,
+CCC   instanciation, ...) used during the creation of the grid hierarchy and
+CCC   during the time integration.
+C
+C     Modules used: 
+C
+      Use Agrif_Types 
+      Use Agrif_link
+C   
+      IMPLICIT NONE
+C
+      Contains
+C     Defininition of the procedures contained in this module
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Allocation  
+C     **************************************************************************
+C  
+      Subroutine Agrif_Allocation(Agrif_Gr)
+C
+CCC   Description:
+CCC   Subroutine to allocate the arrays containing the values of the variables 
+CCC   of the current grd.
+C
+CC    Method:
+CC    Use of the allocate function.  
+C
+C     Declarations:
+C      
+C     Pointer argument:
+      TYPE(AGRIF_grid), Pointer :: Agrif_Gr  ! Pointer on the current grid
+C 
+C     Allocation of the arrays of the variables  
+C     We cut this in several files to avoid long compilation timings
+C
+      Call Agrif_Allocationcalls(Agrif_Gr)
+C
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+C
+         if ( Agrif_Probdim .EQ. 1 ) 
+     &      Allocate(Agrif_Gr%tabpoint1D(Agrif_Gr%nb(1)+1))
+         if ( Agrif_Probdim .EQ. 2 ) 
+     &      Allocate(Agrif_Gr%tabpoint2D(Agrif_Gr%nb(1)+1,
+     &       Agrif_Gr%nb(2)+1))      
+         if ( Agrif_Probdim .EQ. 3 ) 
+     &      Allocate(Agrif_Gr%tabpoint3D(Agrif_Gr%nb(1)+1,
+     &       Agrif_Gr%nb(2)+1,Agrif_Gr%nb(3)+1))      
+C
+      endif
+C 
+      End Subroutine Agrif_Allocation
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Instance 
+C     **************************************************************************
+C 
+      Subroutine Agrif_Instance(Agrif_Gr)
+C
+CCC   Description:
+CCC   Subroutine to do an instance of the common variables to the variables of  
+CCC   the current grid.
+C
+CC    Method:
+CC    Pointing the common variables on these of the current grid.  
+C
+C     Declarations:
+C        
+
+C
+C
+
+C
+C     Pointer argument: 
+      Type(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid  
+C 
+C
+      Agrif_Curgrid => Agrif_Gr
+      Agrif_tabvars => Agrif_Curgrid % tabvars
+C
+      Call Agrif_Get_numberofcells(Agrif_Gr)
+C
+C
+C     Calculation of isf,jsf,nzsf and of the index of the output file 
+      Call Agrif_InitWorkSpace() 
+C
+C 
+      End Subroutine Agrif_Instance
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_initialisations  
+C     **************************************************************************
+      Subroutine Agrif_initialisations(Agrif_Gr)
+C
+CCC   Description:
+C
+CC    Method:
+C
+C     Declarations:
+C        
+      INTEGER :: i
+C
+C     Pointer argument: 
+      Type(Agrif_Grid), Pointer  :: Agrif_Gr
+      
+C
+      do i = 1 , Agrif_NbVariables
+C 
+         Agrif_Gr % tabvars(i) % var % nbdim = 0
+C
+         if (associated(Agrif_Gr%tabvars(i)%var%array1)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 1
+             Agrif_Gr % tabvars(i) % var % lb(1:1) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array1)
+             Agrif_Gr % tabvars(i) % var % ub(1:1) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array1)     
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%array2)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 2
+             Agrif_Gr % tabvars(i) % var % lb(1:2) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array2)
+             Agrif_Gr % tabvars(i) % var % ub(1:2) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array2)
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%array3)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 3
+             Agrif_Gr % tabvars(i) % var % lb(1:3) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array3)
+             Agrif_Gr % tabvars(i) % var % ub(1:3) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array3)
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%array4)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 4
+             Agrif_Gr % tabvars(i) % var % lb(1:4) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array4)
+             Agrif_Gr % tabvars(i) % var % ub(1:4) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array4)
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%array5)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 5
+             Agrif_Gr % tabvars(i) % var % lb(1:5) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array5)
+             Agrif_Gr % tabvars(i) % var % ub(1:5) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array5)
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%array6)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 6
+             Agrif_Gr % tabvars(i) % var % lb(1:6) = 
+     &         lbound(Agrif_Gr%tabvars(i)%var%array6)
+             Agrif_Gr % tabvars(i) % var % ub(1:6) = 
+     &         ubound(Agrif_Gr%tabvars(i)%var%array6)
+         endif
+C
+         if (associated(Agrif_Gr%tabvars(i)%var%darray1)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 1
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%darray2)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 2
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%darray3)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 3
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%darray4)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 4
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%darray5)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 5
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%darray6)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 6
+         endif
+C
+         if (associated(Agrif_Gr%tabvars(i)%var%larray1)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 1
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%larray2)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 2
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%larray3)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 3
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%larray4)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 4
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%larray5)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 5
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%larray6)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 6
+         endif
+C
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray1)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 1
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray2)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 2
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray3)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 3
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray4)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 4
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray5)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 5
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%iarray6)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 6
+         endif
+C
+         if (associated(Agrif_Gr%tabvars(i)%var%carray1)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 1
+         endif
+         if (associated(Agrif_Gr%tabvars(i)%var%carray2)) then
+             Agrif_Gr % tabvars(i) % var % nbdim = 2
+         endif
+C 
+      enddo
+C
+      Return
+C 
+C
+      End Subroutine Agrif_initialisations
+C 
+C
+      End Module AGRIF_Init 
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinitvars.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinitvars.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinitvars.F	(revision 1844)
@@ -0,0 +1,125 @@
+!
+! $Id$
+!
+C     Agrif (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Init_Vars
+C
+      Module Agrif_Init_Vars
+C
+CCC   Description:
+CCC   Initialization of the variables of the current grid.
+C
+C     Modules used: 
+C      
+      Use Agrif_Types
+      Use Agrif_link
+C   
+      IMPLICIT NONE
+C
+      Contains
+C     Defininition of the procedures contained in this module 
+C  
+C 
+C     **************************************************************************
+CCC   Subroutine Agrif_Create_var 
+C     **************************************************************************
+C  
+      Subroutine Agrif_Create_Var(Agrif_Gr)
+C
+CCC   Description:
+CCC   Allocation of the field "var" of the grid variables.
+CCC   Fields "root_var", "nbdim" and "parent_var" of the grid variables.
+CCC   Array "tabvars" of the current grid. 
+C
+CC    Method:                  
+C 
+C     Declarations:
+C
+      
+C
+C     Pointer argument:
+      TYPE(Agrif_Grid),pointer   :: Agrif_Gr  ! Pointer on the current grid
+      INTEGER :: nb
+C
+C     Array "tabvars" of the current grid. 
+C
+      Allocate(Agrif_Gr % tabvars(Agrif_NbVariables))
+C      
+      do nb = 1, Agrif_NbVariables
+        Allocate(Agrif_Gr % tabvars(nb) % var)
+      enddo
+
+C     Fields "root_var", "nbdim" and "parent_var" of the grid variables.     
+      if (Agrif_Gr % fixedrank .NE.0) then
+         do nb = 1, Agrif_NbVariables     
+            Agrif_Gr % tabvars(nb) % parent_var => 
+     &      Agrif_Gr % parent %tabvars(nb)
+            Agrif_Gr % tabvars(nb) % var % nbdim =
+     &      Agrif_Mygrid % tabvars(nb) % var % nbdim
+            Agrif_Gr % tabvars(nb) % var % root_var =>
+     &      Agrif_Mygrid % tabvars(nb) % var          
+         enddo
+      endif
+C           
+      End Subroutine Agrif_Create_Var
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_CreateVar
+C     **************************************************************************
+C 
+      Subroutine Agrif_CreateVar(Agrif_Gr)            
+C
+CCC   Description:
+CCC   This subroutine allows to make a link between Mygrid and the current grid 
+C
+C     Modules used:
+C      
+C
+C     Declarations:
+C      
+C
+C
+C     Arguments      
+C
+      TYPE(Agrif_Grid),pointer   :: Agrif_Gr    ! Pointer on the current grid
+      INTEGER                    :: i           ! Loop
+C
+      if (Agrif_Gr % fixedrank .NE. 0) then
+C  
+         do i = 1 , Agrif_NbVariables 
+            Agrif_Gr % tabvars(i) % parent_var => 
+     &      Agrif_Gr % parent % tabvars(i) 
+            Agrif_Gr % tabvars(i) % var % root_var => 
+     &      Agrif_Mygrid % tabvars(i) % var
+            Agrif_Gr % tabvars(i) % var % nbdim  = 
+     &      Agrif_Gr % parent % tabvars(i) % var % nbdim
+         enddo 
+C	 
+      endif 
+C       
+      End Subroutine Agrif_CreateVar
+C
+C
+C
+      End Module Agrif_Init_Vars
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterp.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterp.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterp.F	(revision 1844)
@@ -0,0 +1,2272 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Interpolation
+C
+      Module Agrif_Interpolation
+C
+CCC   Description:
+CCC   Module to initialize a fine grid from its parent grid, by using a space 
+CCC   interpolation
+C
+C     Modules used:
+C  
+      Use Agrif_Interpbasic
+      Use Agrif_Arrays
+      Use Agrif_Mask 
+      Use Agrif_CurgridFunctions
+#if defined AGRIF_MPI
+      Use Agrif_mpp
+#endif
+C      
+      IMPLICIT NONE
+      logical,  private:: precomputedone(7) = .FALSE.
+C
+      CONTAINS
+C     Define procedures contained in this module        
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_1d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_1d(TypeInterp,parent,child,tab,
+     &    torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 1D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1)
+     &         ), Target :: tab    ! Result
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C      
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim
+C
+C     Tab is the result of the interpolation
+      childtemp % var % array1 => tab 
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+C      
+      if (torestore) then
+C 
+          childtemp % var % array1 = child % var % array1
+C          
+          childtemp % var % restore1D => child % var % restore1D
+C      
+        else
+C        
+          Nullify(childtemp % var % restore1D)
+C      
+      endif     
+C 
+C     Index indicating (in the Agrif_Interp1D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade 
+      childtemp % var % list_interp => child % var% list_interp            
+C      
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+      child % var % list_interp => childtemp % var %list_interp     
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_1D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_2d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_2d(TypeInterp,parent,child,tab,
+     &                           torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 2D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2)
+     &    ), Target :: tab    ! Result
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C      
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim
+C
+C     Tab is the result of the interpolation
+      childtemp % var % array2 => tab  
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub
+      
+C
+      if (torestore) then      
+C 
+          childtemp % var % array2 = child % var % array2          
+C 
+          childtemp % var % restore2D => child % var % restore2D        
+C      
+        else
+C        
+          Nullify(childtemp % var % restore2D)
+C      
+      endif       
+C 
+C     Index indicating (in the Agrif_Interp2D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex       
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade   
+      childtemp % var % list_interp => child % var% list_interp          
+C     
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+
+      child % var % list_interp => childtemp % var %list_interp     
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_2D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_3d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_3d(TypeInterp,parent,child,tab,
+     &   torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 3D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3)
+     &      ), Target :: tab  ! Results
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim  
+C     
+C     Tab is the result of the interpolation 
+      childtemp % var % array3 => tab 
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub        
+C      
+      if (torestore) then
+C     
+          childtemp % var % array3 = child % var % array3
+C
+          childtemp % var % restore3D => child % var % restore3D
+C      
+        else
+C        
+          Nullify(childtemp % var % restore3D)
+C      
+      endif
+C 
+C     Index indicating (in the Agrif_Interp3D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex    
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade   
+      childtemp % var % list_interp => child % var% list_interp          
+C     
+
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+
+
+      child % var % list_interp => childtemp % var %list_interp     
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_3D               
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_4d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_4d(TypeInterp,parent,child,tab,
+     &   torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 4D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4)
+     &      ), Target :: tab  ! Results
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim  
+C      
+C     Tab is the result of the interpolation
+      childtemp % var % array4 => tab 
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+C 
+      if (torestore) then
+C 
+          childtemp % var % array4 = child % var % array4
+C
+          childtemp % var % restore4D => child % var % restore4D
+C      
+        else
+C        
+          Nullify(childtemp % var % restore4D)
+C      
+      endif        
+C 
+C     Index indicating (in the Agrif_Interp4D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex    
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade  
+      childtemp % var % list_interp => child % var% list_interp           
+C     
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+
+
+      child % var % list_interp => childtemp % var %list_interp
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_4D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_5d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_5d(TypeInterp,parent,child,tab,
+     &   torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 5D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4),
+     &         child%var%lb(5):child%var%ub(5)
+     &      ),  Target :: tab  ! Results
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim  
+C      
+C     Tab is the result of the interpolation
+      childtemp % var % array5 => tab  
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+C      
+      if (torestore) then
+C 
+          childtemp % var % array5 = child % var % array5
+C
+          childtemp % var % restore5D => child % var % restore5D
+C      
+        else
+C        
+          Nullify(childtemp % var % restore5D)
+C      
+      endif       
+C 
+C     Index indicating (in the Agrif_Interp5D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex    
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade   
+      childtemp % var % list_interp => child % var% list_interp          
+C      
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+
+     
+      child % var % list_interp => childtemp % var %list_interp
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_5D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_6d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Interp_6d(TypeInterp,parent,child,tab,
+     &  torestore,nbdim,procname)            
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions of a fine grid for a 6D
+C        grid variable.
+C
+C     Declarations:
+C      
+      
+C
+C     Arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp     ! Kind of interpolation
+                                             !    (linear,lagrange,spline)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+                                             !    grid
+      LOGICAL :: torestore
+      REAL, DIMENSION(
+     &         child%var%lb(1):child%var%ub(1),
+     &         child%var%lb(2):child%var%ub(2),
+     &         child%var%lb(3):child%var%ub(3),
+     &         child%var%lb(4):child%var%ub(4),
+     &         child%var%lb(5):child%var%ub(5),
+     &         child%var%lb(6):child%var%ub(6)
+     &      ),  Target :: tab  ! Results
+      External :: procname
+      Optional ::  procname
+C
+C
+      allocate(childtemp % var)  
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = nbdim  
+C      
+C     Tab is the result of the interpolation
+      childtemp % var % array6 => tab  
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+C      
+      if (torestore) then
+C 
+          childtemp % var % array6 = child % var % array6
+C
+          childtemp % var % restore6D => child % var % restore6D
+C      
+        else
+C        
+          Nullify(childtemp % var % restore6D)
+C      
+      endif       
+C 
+C     Index indicating (in the Agrif_Interp6D procedure) if a space
+C        interpolation is necessary
+      childtemp % var % interpIndex => child % var % interpIndex    
+      childtemp % var % Interpolationshouldbemade = 
+     &    child % var % Interpolationshouldbemade  
+     
+      childtemp % var % list_interp => child % var% list_interp           
+C      
+
+      if (present(procname)) then
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore,procname)
+      else
+      Call Agrif_InterpVariable
+     &     (TypeInterp,parent,childtemp,torestore)
+      endif
+
+
+C      
+      child % var % list_interp => childtemp % var %list_interp
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Interp_6D
+C
+C
+C
+C     **************************************************************************
+C     Subroutine Agrif_InterpVariable    
+C     **************************************************************************
+C   
+      Subroutine Agrif_InterpVariable(TYPEinterp,parent,child,torestore,
+     &            procname)
+C
+CCC   Description:
+CCC   Subroutine to set some arguments of subroutine Agrif_InterpnD, n being the
+CCC   DIMENSION of the grid variable.
+C
+CC    Declarations:
+C      
+c      
+C      
+C
+C     Scalar argument
+      INTEGER,DIMENSION(6) :: TYPEinterp! TYPE of interpolation
+                                        !    (linear,spline,...)
+C     Data TYPE arguments                                   
+      TYPE(AGRIF_PVariable) :: parent   ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child    ! Variable on the child grid
+C
+C     LOGICAL argument      
+      LOGICAL:: torestore               ! Its value is .false., it indicates the
+                                        ! results of the interpolation are    
+                                        ! applied on the whole current grid   
+C
+C     Local scalars      
+      INTEGER               :: nbdim          ! Number of dimensions of the
+                                              !    current grid
+      INTEGER ,DIMENSION(6) :: pttab_child  
+      INTEGER ,DIMENSION(6) :: petab_child      
+      INTEGER ,DIMENSION(6) :: pttab_parent  
+      REAL    ,DIMENSION(6) :: s_child,s_parent
+      REAL    ,DIMENSION(6) :: ds_child,ds_parent
+      External :: procname
+      Optional ::  procname
+
+C
+      Call PreProcessToInterpOrUpdate(parent,child,
+     &             petab_Child(1:nbdim),
+     &             pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &             s_Child(1:nbdim),s_Parent(1:nbdim),
+     &             ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &             nbdim)
+C
+C
+C     Call to a procedure of interpolation against the number of dimensions of 
+C     the grid variable
+C
+
+      if (present(procname)) then
+      call Agrif_InterpnD
+     &            (TYPEinterp,parent,child,
+     &             pttab_Child(1:nbdim),petab_Child(1:nbdim),
+     &             pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &             s_Child(1:nbdim),s_Parent(1:nbdim),
+     &             ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &             child,torestore,nbdim,procname)
+      else
+      call Agrif_InterpnD
+     &            (TYPEinterp,parent,child,
+     &             pttab_Child(1:nbdim),petab_Child(1:nbdim),
+     &             pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &             s_Child(1:nbdim),s_Parent(1:nbdim),
+     &             ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &             child,torestore,nbdim)
+
+      endif
+C
+      Return
+C
+C
+      End subroutine Agrif_InterpVariable       
+C
+C
+C     **************************************************************************
+C     Subroutine Agrif_InterpnD  
+C     **************************************************************************
+C  
+      Subroutine Agrif_InterpnD(TYPEinterp,parent,child,
+     &                          pttab,petab,
+     &                          pttab_Child,pttab_Parent,
+     &                          s_Child,s_Parent,ds_Child,ds_Parent,
+     &                          restore,torestore,nbdim,procname)
+C
+C     Description:
+C     Subroutine to interpolate a nD grid variable from its parent grid,
+C     by using a space interpolation. 
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+C
+#include "mpif.h"
+C
+#endif
+C
+C     Arguments
+      External :: procname
+      Optional :: procname
+      INTEGER                    :: nbdim
+      INTEGER,DIMENSION(6)       :: TYPEinterp         ! TYPE of interpolation
+                                                       !    (linear,...)
+      TYPE(AGRIF_PVARIABLE)      :: parent             ! Variable of the parent
+                                                       !    grid
+      TYPE(AGRIF_PVARIABLE)      :: child              ! Variable of the child
+                                                       !    grid
+      INTEGER,DIMENSION(nbdim)   :: pttab              ! Index of the first
+                                                       !    point inside the
+                                                       !    domain
+      INTEGER,DIMENSION(nbdim)   :: petab              ! Index of the first
+                                                       !    point inside the
+                                                       !    domain
+      INTEGER,DIMENSION(nbdim)   :: pttab_Child        ! Index of the first
+                                                       !    point inside the
+                                                       !    domain for the child
+                                                       !    grid variable
+      INTEGER,DIMENSION(nbdim)   :: pttab_Parent       ! Index of the first
+                                                       !    point inside the
+                                                       !    domain for the
+                                                       !    parent grid variable
+      TYPE(AGRIF_PVARIABLE)      :: restore            ! Indicates points where
+                                                       !    interpolation
+      REAL,DIMENSION(nbdim)      :: s_Child,s_Parent   ! Positions of the parent
+                                                       !    and child grids
+      REAL,DIMENSION(nbdim)      :: ds_Child,ds_Parent ! Space steps of the
+                                                       !    parent and child
+                                                       !    grids
+      LOGICAL                        :: torestore      ! Indicates if the array
+                                                       !    restore is used
+C
+C     Local pointers
+      TYPE(AGRIF_PVARIABLE),SAVE      :: tempP,tempPextend  ! Temporary parent grid variable
+      TYPE(AGRIF_PVARIABLE),SAVE      :: tempC      ! Temporary child grid variable
+C
+C     Local scalars        
+      INTEGER                     :: i,j,k,l,m,n
+      INTEGER,DIMENSION(nbdim)    :: pttruetab,cetruetab
+      INTEGER,DIMENSION(nbdim)    :: indmin,indmax
+      LOGICAL,DIMENSION(nbdim)    :: noraftab
+      REAL   ,DIMENSION(nbdim)    :: s_Child_temp,s_Parent_temp
+      INTEGER,DIMENSION(nbdim)    :: lowerbound,upperbound
+      INTEGER,DIMENSION(nbdim)    :: indminglob,indmaxglob
+      INTEGER,DIMENSION(nbdim,2,2) :: childarray
+      INTEGER,DIMENSION(nbdim,2,2) :: parentarray
+      LOGICAL :: memberin,member
+      TYPE(AGRIF_PVARIABLE),SAVE                      ::  parentvalues
+      LOGICAL :: find_list_interp
+      INTEGER,DIMENSION(nbdim)    :: indminglob2,indmaxglob2      
+C
+#ifdef AGRIF_MPI
+C
+      LOGICAL :: memberout
+      INTEGER,PARAMETER                          :: etiquette = 100
+      INTEGER                                    :: code
+      INTEGER,DIMENSION(nbdim,4)           :: tab3
+      INTEGER,DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1,recvfromproc1
+      LOGICAL, DIMENSION(1) :: memberin1
+C
+#endif      
+C     
+
+C   
+C     Boundaries of the current grid where interpolation is done
+
+      IF (Associated(child%var%list_interp)) THEN
+      Call Agrif_Find_list_interp(child%var%list_interp,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim,
+     &                          indmin,indmax,indminglob,
+     &       indmaxglob,indminglob2,indmaxglob2,parentarray,
+     &       pttruetab,cetruetab,member,memberin,find_list_interp
+#if defined AGRIF_MPI
+     &       ,tab4t,memberinall,sendtoproc1,recvfromproc1
+#endif
+     &    )
+      ELSE
+      find_list_interp = .FALSE.
+      ENDIF
+      
+      IF (.not.find_list_interp) THEN
+
+      Call Agrif_nbdim_Get_bound_dimension(child % var,
+     &                               lowerbound,upperbound,nbdim)
+      
+      Call Agrif_Childbounds(nbdim,lowerbound,upperbound,
+     &                                   pttab,petab,
+     &                                   pttruetab,cetruetab,memberin)
+     
+C
+      Call Agrif_Parentbounds(TYPEinterp,nbdim,indminglob,indmaxglob,
+     &                        s_Parent_temp,s_Child_temp,
+     &                        s_Child,ds_Child,
+     &                        s_Parent,ds_Parent,
+     &                        pttab,petab,
+     &                        pttab_Child,pttab_Parent,
+     &                        child%var%root_var%posvar,
+     &                        child % var % root_var % interptab)
+       
+#ifdef AGRIF_MPI
+       IF (memberin) THEN
+        Call Agrif_Parentbounds(TYPEinterp,nbdim,indmin,indmax,
+     &                        s_Parent_temp,s_Child_temp,
+     &                        s_Child,ds_Child,
+     &                        s_Parent,ds_Parent,
+     &                        pttruetab,cetruetab,
+     &                        pttab_Child,pttab_Parent,
+     &                        child%var%root_var%posvar,
+     &                        child % var % root_var % interptab)
+      ENDIF
+       
+      Call Agrif_nbdim_Get_bound_dimension(parent%var,
+     &                              lowerbound,upperbound,nbdim)
+       
+      Call Agrif_ChildGrid_to_ParentGrid()
+C
+      Call Agrif_Childbounds(nbdim,
+     &                       lowerbound,upperbound,
+     &                       indminglob,indmaxglob,
+     &                       indminglob2,indmaxglob2,member)
+
+C
+      IF (member) THEN
+      Call Agrif_GlobtoLocInd2(parentarray,
+     &                     lowerbound,upperbound,
+     &                     indminglob2,indmaxglob2,
+     &                     nbdim,Agrif_Procrank,
+     &                     member)
+       endif
+       
+      Call Agrif_ParentGrid_to_ChildGrid()
+#else
+      parentarray(:,1,1) = indminglob
+      parentarray(:,2,1) = indmaxglob
+      parentarray(:,1,2) = indminglob
+      parentarray(:,2,2) = indmaxglob
+      indmin = indminglob
+      indmax = indmaxglob
+      member = .TRUE.
+#endif
+
+      ELSE
+      
+#if !defined AGRIF_MPI
+      parentarray(:,1,1) = indminglob
+      parentarray(:,2,1) = indmaxglob
+      parentarray(:,1,2) = indminglob
+      parentarray(:,2,2) = indmaxglob
+      indmin = indminglob
+      indmax = indmaxglob
+      member = .TRUE.
+      s_Parent_temp = s_Parent + (indminglob - pttab_Parent)*ds_Parent
+      s_Child_temp = s_Child + (pttab - pttab_Child) * ds_Child
+#else      
+      s_Parent_temp = s_Parent + (indmin - pttab_Parent)*ds_Parent
+      s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child
+#endif      
+           
+      ENDIF
+
+      IF (member) THEN
+      IF (.not.associated(tempP%var)) allocate(tempP%var)
+
+C
+      Call Agrif_nbdim_allocation(tempP%var,
+     &     parentarray(:,1,1),parentarray(:,2,1),nbdim)
+
+      Call Agrif_nbdim_Full_VarEQreal(tempP%var,0.,nbdim)
+
+
+
+      IF (present(procname)) THEN
+      Call Agrif_ChildGrid_to_ParentGrid()
+            SELECT CASE (nbdim)
+        CASE(1)
+          CALL procname(tempP%var%array1,
+     &                          parentarray(1,1,2),parentarray(1,2,2))
+        CASE(2)
+          CALL procname(tempP%var%array2,
+     &                          parentarray(1,1,2),parentarray(1,2,2),
+     &                          parentarray(2,1,2),parentarray(2,2,2))
+        CASE(3)
+          CALL procname(tempP%var%array3,
+     &                          parentarray(1,1,2),parentarray(1,2,2),
+     &                          parentarray(2,1,2),parentarray(2,2,2),
+     &                          parentarray(3,1,2),parentarray(3,2,2))
+        CASE(4)
+          CALL procname(tempP%var%array4,
+     &                          parentarray(1,1,2),parentarray(1,2,2),
+     &                          parentarray(2,1,2),parentarray(2,2,2),
+     &                          parentarray(3,1,2),parentarray(3,2,2),
+     &                          parentarray(4,1,2),parentarray(4,2,2))
+        CASE(5)
+          CALL procname(tempP%var%array5,
+     &                          parentarray(1,1,2),parentarray(1,2,2),
+     &                          parentarray(2,1,2),parentarray(2,2,2),
+     &                          parentarray(3,1,2),parentarray(3,2,2),
+     &                          parentarray(4,1,2),parentarray(4,2,2),
+     &                          parentarray(5,1,2),parentarray(5,2,2))
+        CASE(6)
+          CALL procname(tempP%var%array6,
+     &                          parentarray(1,1,2),parentarray(1,2,2),
+     &                          parentarray(2,1,2),parentarray(2,2,2),
+     &                          parentarray(3,1,2),parentarray(3,2,2),
+     &                          parentarray(4,1,2),parentarray(4,2,2),
+     &                          parentarray(5,1,2),parentarray(5,2,2),
+     &                          parentarray(6,1,2),parentarray(6,2,2))
+            END SELECT
+      Call Agrif_ParentGrid_to_ChildGrid()
+      ELSE
+
+      Call Agrif_nbdim_VarEQvar(tempP%var,
+     &        parentarray(:,1,1),parentarray(:,2,1),
+     &        parent%var,parentarray(:,1,2),parentarray(:,2,2),
+     &        nbdim)
+      ENDIF
+            endif
+
+#ifdef AGRIF_MPI
+      if (.not.find_list_interp) then
+      tab3(:,1) = indminglob2(:)
+      tab3(:,2) = indmaxglob2(:)
+      tab3(:,3) = indmin(:)
+      tab3(:,4) = indmax(:)
+C
+C
+      Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
+
+      IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var)
+
+      DO k=0,Agrif_Nbprocs-1
+       do j=1,4
+         do i=1,nbdim
+         tab4t(i,k,j) = tab4(i,j,k)
+                enddo
+      enddo
+      enddo
+      
+      memberin1(1) = memberin
+      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
+
+       Call Get_External_Data_first(tab4t(:,:,1),
+     &            tab4t(:,:,2),
+     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,member,memberin,
+     &            memberinall,sendtoproc1,recvfromproc1,tab4t(:,:,5),
+     & tab4t(:,:,6),tab4t(:,:,7),tab4t(:,:,8))
+          
+      endif     
+           
+!      Call Get_External_Data(tempP,tempPextend,tab4t(:,:,1),
+!     &            tab4t(:,:,2),
+!     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,member,memberin,
+!     &            memberinall)
+     
+      Call ExchangeSameLevel2(sendtoproc1,recvfromproc1,nbdim,
+     &            tab4t(:,:,3),tab4t(:,:,4),tab4t(:,:,5),tab4t(:,:,6),
+     &            tab4t(:,:,7),tab4t(:,:,8),memberin,tempP,
+     &            tempPextend)
+#else
+      tempPextend%var => tempP%var
+#endif
+
+      if (.not.find_list_interp) then
+      Call Agrif_Addto_list_interp(child%var%list_interp,pttab,petab,
+     &                          pttab_Child,pttab_Parent,indmin,indmax,
+     &   indminglob,indmaxglob,indminglob2,indmaxglob2,parentarray,
+     &   pttruetab,cetruetab,member,memberin,nbdim
+#if defined AGRIF_MPI
+     &   ,tab4t,memberinall,sendtoproc1,recvfromproc1
+#endif
+     &    )
+      endif   
+C
+C
+      IF (memberin) THEN
+      IF (.not.associated(tempC%var)) allocate(tempC%var)
+C
+
+      Call Agrif_nbdim_allocation(tempC%var,pttruetab,cetruetab,nbdim)
+
+C
+C
+C     Special values on the parent grid
+      if (Agrif_UseSpecialValue) then
+C
+          noraftab(1:nbdim) =
+     &         child % var % root_var % interptab(1:nbdim) .EQ. 'N'
+C
+          IF (.not.associated(parentvalues%var))
+     &            Allocate(parentvalues%var)
+C
+          Call Agrif_nbdim_allocation
+     &               (parentvalues%var,indmin,indmax,nbdim)
+          Call Agrif_nbdim_Full_VarEQvar
+     &               (parentvalues%var,tempPextend%var,nbdim)
+C
+          Call Agrif_CheckMasknD(tempPextend,
+     &                           parentvalues,
+     &                           indmin(1:nbdim),indmax(1:nbdim),
+     &                           indmin(1:nbdim),indmax(1:nbdim),
+     &                           noraftab(1:nbdim),nbdim)
+C
+          Call Agrif_nbdim_deallocation(parentvalues%var,nbdim)
+C          Deallocate(parentvalues%var)
+C
+C
+      endif      
+
+C
+C
+C     Interpolation of the current grid
+
+      IF (memberin) THEN
+      if ( nbdim .EQ. 1 ) then
+         Call Agrif_Interp_1D_recursive(TypeInterp,
+     &           tempPextend%var%array1,tempC%var%array1,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      elseif ( nbdim .EQ. 2 ) then
+
+         Call Agrif_Interp_2D_recursive(TypeInterp,
+     &           tempPextend%var%array2,tempC%var%array2,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      elseif ( nbdim .EQ. 3 ) then
+
+         Call Agrif_Interp_3D_recursive(TypeInterp,
+     &           tempPextend%var%array3,tempC%var%array3,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      elseif ( nbdim .EQ. 4 ) then
+         Call Agrif_Interp_4D_recursive(TypeInterp,
+     &           tempPextend%var%array4,tempC%var%array4,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      elseif ( nbdim .EQ. 5 ) then
+         Call Agrif_Interp_5D_recursive(TypeInterp,
+     &           tempPextend%var%array5,tempC%var%array5,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      elseif ( nbdim .EQ. 6 ) then
+         Call Agrif_Interp_6D_recursive(TypeInterp,
+     &           tempPextend%var%array6,tempC%var%array6,
+     &           indmin,indmax,
+     &           pttruetab,cetruetab,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+       endif
+
+
+C  
+
+      Call Agrif_nbdim_Get_bound_dimension(child % var,
+     &                               lowerbound,upperbound,nbdim)
+
+#ifdef AGRIF_MPI
+      Call Agrif_GlobtoLocInd2(childarray,
+     &                     lowerbound,upperbound,
+     &                     pttruetab,cetruetab,
+     &                     nbdim,Agrif_Procrank,
+     &                     memberout)
+
+#else
+       childarray(:,1,1) = pttruetab
+       childarray(:,2,1) = cetruetab
+       childarray(:,1,2) = pttruetab
+       childarray(:,2,2) = cetruetab
+ccccccccccccccc       memberout = .TRUE.
+#endif
+
+
+C
+C
+C     Special values on the child grid  
+      if (Agrif_UseSpecialValueFineGrid) then
+C
+
+          Call GiveAgrif_SpecialValueToTab_mpi(child%var,tempC%var,
+     &                 childarray,
+     &                 pttruetab,cetruetab,
+     &                 Agrif_SpecialValueFineGrid,nbdim)
+
+C        
+      endif
+      
+      endif
+
+C
+      if (torestore) then
+C
+#ifdef AGRIF_MPI
+C
+        SELECT CASE (nbdim)
+        CASE (1)
+             do i = pttruetab(1),cetruetab(1)         
+ChildarrayAModifier                if (restore%var%restore1D(i) == 0) 
+ChildarrayAModifier     &                child%var%array1(childarray(i,1,2)
+ChildarrayAModifier     &                                 ) = 
+ChildarrayAModifier     &                tempC%var%array1(i)
+             enddo
+        CASE (2)
+             do i = pttruetab(1),cetruetab(1)
+             do j = pttruetab(2),cetruetab(2)
+ChildarrayAModifier                   if (restore%var%restore2D(i,j) == 0) 
+ChildarrayAModifier     &                child%var%array2(childarray(i,1,2),
+ChildarrayAModifier     &                                 childarray(j,2,2)) = 
+ChildarrayAModifier     &                tempC%var%array2(i,j)
+             enddo
+             enddo
+        CASE (3)
+             do i = pttruetab(1),cetruetab(1)
+             do j = pttruetab(2),cetruetab(2)  
+             do k = pttruetab(3),cetruetab(3)
+ChildarrayAModifier                      if (restore%var%restore3D(i,j,k) == 0) 
+ChildarrayAModifier     &                child%var%array3(childarray(i,1,2),
+ChildarrayAModifier     &                                 childarray(j,2,2),
+ChildarrayAModifier     &                                 childarray(k,3,2)) = 
+ChildarrayAModifier     &                tempC%var%array3(i,j,k)
+             enddo
+             enddo
+             enddo
+        CASE (4)
+             do i = pttruetab(1),cetruetab(1)
+             do j = pttruetab(2),cetruetab(2)
+             do k = pttruetab(3),cetruetab(3)
+             do l = pttruetab(4),cetruetab(4)
+ChildarrayAModifier                         if (restore%var%restore4D(i,j,k,l) == 0) 
+ChildarrayAModifier     &                      child%var%array4(childarray(i,1,2),
+ChildarrayAModifier     &                                       childarray(j,2,2),
+ChildarrayAModifier     &                                       childarray(k,3,2),
+ChildarrayAModifier     &                                       childarray(l,4,2)) = 
+ChildarrayAModifier     &                      tempC%var%array4(i,j,k,l)
+             enddo
+             enddo
+             enddo
+             enddo
+        CASE (5)
+             do i = pttruetab(1),cetruetab(1)
+             do j = pttruetab(2),cetruetab(2)
+             do k = pttruetab(3),cetruetab(3)
+             do l = pttruetab(4),cetruetab(4)
+             do m = pttruetab(5),cetruetab(5)
+ChildarrayAModifier              if (restore%var%restore5D(i,j,k,l,m) == 0) 
+ChildarrayAModifier     &                child%var%array5(childarray(i,1,2),
+ChildarrayAModifier     &                                 childarray(j,2,2),
+ChildarrayAModifier     &                                 childarray(k,3,2),
+ChildarrayAModifier     &                                 childarray(l,4,2),
+ChildarrayAModifier     &                                 childarray(m,5,2)) = 
+ChildarrayAModifier     &                tempC%var%array5(i,j,k,l,m)
+             enddo
+             enddo
+             enddo
+             enddo
+             enddo
+        CASE (6)
+             do i = pttruetab(1),cetruetab(1)
+             do j = pttruetab(2),cetruetab(2)
+             do k = pttruetab(3),cetruetab(3)
+             do l = pttruetab(4),cetruetab(4)
+             do m = pttruetab(5),cetruetab(5)
+             do n = pttruetab(6),cetruetab(6)
+ChildarrayAModifier              if (restore%var%restore6D(i,j,k,l,m,n) == 0) 
+ChildarrayAModifier     &                child%var%array6(childarray(i,1,2),
+ChildarrayAModifier     &                                 childarray(j,2,2),
+ChildarrayAModifier     &                                 childarray(k,3,2),
+ChildarrayAModifier     &                                 childarray(l,4,2),
+ChildarrayAModifier     &                                 childarray(m,5,2),
+ChildarrayAModifier     &                                 childarray(n,6,2)) = 
+ChildarrayAModifier     &                tempC%var%array6(i,j,k,l,m,n)
+             enddo
+             enddo
+             enddo
+             enddo
+             enddo
+             enddo
+        END SELECT
+C
+#else
+        SELECT CASE (nbdim)
+        CASE (1)
+           do i = pttruetab(1),cetruetab(1)         
+            if (restore%var%restore1D(i) == 0)
+     &            child % var % array1(i) = 
+     &            tempC % var % array1(i)    
+          enddo
+        CASE (2)
+           do j = pttruetab(2),cetruetab(2)
+             do i = pttruetab(1),cetruetab(1) 
+              if (restore%var%restore2D(i,j) == 0)     
+     &              child % var % array2(i,j) = 
+     &              tempC % var % array2(i,j)    
+              enddo
+             enddo
+        CASE (3)
+           do k = pttruetab(3),cetruetab(3)
+           do j = pttruetab(2),cetruetab(2)
+             do i = pttruetab(1),cetruetab(1) 
+              if (restore%var%restore3D(i,j,k) == 0)
+     &                  child % var % array3(i,j,k) =
+     &                  tempC % var % array3(i,j,k)    
+                  enddo
+              enddo
+             enddo
+        CASE (4)
+           do l = pttruetab(4),cetruetab(4)
+           do k = pttruetab(3),cetruetab(3)
+          do j = pttruetab(2),cetruetab(2)
+             do i = pttruetab(1),cetruetab(1)
+                if (restore%var%restore4D(i,j,k,l) == 0)
+     &                 child % var % array4(i,j,k,l) = 
+     &                 tempC % var % array4(i,j,k,l)    
+             enddo
+             enddo
+              enddo
+             enddo
+        CASE (5)
+           do m = pttruetab(5),cetruetab(5)
+          do l = pttruetab(4),cetruetab(4)
+         do k = pttruetab(3),cetruetab(3)
+           do j = pttruetab(2),cetruetab(2)
+             do i = pttruetab(1),cetruetab(1)
+                if (restore%var%restore5D(i,j,k,l,m) == 0)
+     &                  child % var % array5(i,j,k,l,m) = 
+     &                  tempC % var % array5(i,j,k,l,m)    
+             enddo
+             enddo
+                  enddo
+              enddo
+             enddo
+        CASE (6)
+           do n = pttruetab(6),cetruetab(6)
+          do m = pttruetab(5),cetruetab(5)
+          do l = pttruetab(4),cetruetab(4)
+         do k = pttruetab(3),cetruetab(3)
+          do j = pttruetab(2),cetruetab(2)
+             do i = pttruetab(1),cetruetab(1)
+                if (restore%var%restore6D(i,j,k,l,m,n) == 0)
+     &                      child % var % array6(i,j,k,l,m,n) = 
+     &                      tempC % var % array6(i,j,k,l,m,n)    
+             enddo
+            enddo
+                      enddo
+                  enddo
+              enddo
+             enddo
+        END SELECT
+C
+#endif
+C        
+        else
+C
+C
+          IF (memberin) THEN
+          SELECT CASE (nbdim)
+          CASE (1)
+            child%var%array1(childarray(1,1,2):childarray(1,2,2)) =
+     &       tempC%var%array1(childarray(1,1,1):childarray(1,2,1))
+          CASE (2)
+            child%var%array2(childarray(1,1,2):childarray(1,2,2),
+     &                       childarray(2,1,2):childarray(2,2,2)) =
+     &      tempC%var%array2(childarray(1,1,1):childarray(1,2,1),
+     &                       childarray(2,1,1):childarray(2,2,1))
+          CASE (3)
+            child%var%array3(childarray(1,1,2):childarray(1,2,2),
+     &                       childarray(2,1,2):childarray(2,2,2),
+     &                       childarray(3,1,2):childarray(3,2,2)) =
+     &      tempC%var%array3(childarray(1,1,1):childarray(1,2,1),
+     &                       childarray(2,1,1):childarray(2,2,1),
+     &                       childarray(3,1,1):childarray(3,2,1))
+          CASE (4)
+            child%var%array4(childarray(1,1,2):childarray(1,2,2),
+     &                       childarray(2,1,2):childarray(2,2,2),
+     &                       childarray(3,1,2):childarray(3,2,2),
+     &                       childarray(4,1,2):childarray(4,2,2)) =
+     &      tempC%var%array4(childarray(1,1,1):childarray(1,2,1),
+     &                       childarray(2,1,1):childarray(2,2,1),
+     &                       childarray(3,1,1):childarray(3,2,1),
+     &                       childarray(4,1,1):childarray(4,2,1))
+          CASE (5)
+            child%var%array5(childarray(1,1,2):childarray(1,2,2),
+     &                       childarray(2,1,2):childarray(2,2,2),
+     &                       childarray(3,1,2):childarray(3,2,2),
+     &                       childarray(4,1,2):childarray(4,2,2),
+     &                       childarray(5,1,2):childarray(5,2,2)) =
+     &      tempC%var%array5(childarray(1,1,1):childarray(1,2,1),
+     &                       childarray(2,1,1):childarray(2,2,1),
+     &                       childarray(3,1,1):childarray(3,2,1),
+     &                       childarray(4,1,1):childarray(4,2,1),
+     &                       childarray(5,1,1):childarray(5,2,1))
+          CASE (6)
+            child%var%array6(childarray(1,1,2):childarray(1,2,2),
+     &                       childarray(2,1,2):childarray(2,2,2),
+     &                       childarray(3,1,2):childarray(3,2,2),
+     &                       childarray(4,1,2):childarray(4,2,2),
+     &                       childarray(5,1,2):childarray(5,2,2),
+     &                       childarray(6,1,2):childarray(6,2,2)) =
+     &      tempC%var%array6(childarray(1,1,1):childarray(1,2,1),
+     &                       childarray(2,1,1):childarray(2,2,1),
+     &                       childarray(3,1,1):childarray(3,2,1),
+     &                       childarray(4,1,1):childarray(4,2,1),
+     &                       childarray(5,1,1):childarray(5,2,1),
+     &                       childarray(6,1,1):childarray(6,2,1))
+          END SELECT
+          ENDIF
+C
+C       
+      endif
+
+        Call Agrif_nbdim_deallocation(tempPextend%var,nbdim)
+C        deallocate(tempPextend%var)
+
+      Call Agrif_nbdim_deallocation(tempC%var,nbdim)
+      
+C      Deallocate(tempC % var)
+      ELSE
+      
+C      deallocate(tempPextend%var)
+
+      ENDIF
+C
+C             
+C     Deallocations
+#ifdef AGRIF_MPI        
+      IF (member) THEN
+      Call Agrif_nbdim_deallocation(tempP%var,nbdim)
+C      Deallocate(tempP % var)
+      endif
+#endif
+C
+C
+      
+C
+C
+      End Subroutine Agrif_InterpnD 
+C
+C
+C
+C                  
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Parentbounds
+C     **************************************************************************
+C
+      Subroutine Agrif_Parentbounds(TYPEinterp,nbdim,indmin,indmax,
+     &                              s_Parent_temp,
+     &                              s_Child_temp,s_Child,ds_Child,
+     &                              s_Parent,ds_Parent,
+     &                              pttruetab,cetruetab,pttab_Child,
+     &                              pttab_Parent,posvar,interptab)
+C
+CCC   Description:
+CCC   Subroutine calculating the bounds of the parent grid for the interpolation
+CCC   of the child grid     
+C
+C
+C     Declarations:
+C
+C
+C     Arguments
+      INTEGER :: nbdim
+      INTEGER, DIMENSION(6) :: TypeInterp
+      INTEGER,DIMENSION(nbdim) :: indmin,indmax
+      REAL,DIMENSION(nbdim) :: s_Parent_temp,s_child_temp
+      REAL,DIMENSION(nbdim) :: s_Child,ds_child
+      REAL,DIMENSION(nbdim) :: s_Parent,ds_Parent
+      INTEGER,DIMENSION(nbdim) :: pttruetab,cetruetab
+      INTEGER,DIMENSION(nbdim) :: pttab_Child,pttab_Parent
+      INTEGER,DIMENSION(nbdim) :: posvar
+      CHARACTER(6), DIMENSION(nbdim) :: interptab
+C
+C     Local variables
+      INTEGER :: i
+      REAL,DIMENSION(nbdim) :: dim_newmin,dim_newmax      
+C
+      dim_newmin = s_Child + (pttruetab - pttab_Child) * ds_Child
+      dim_newmax = s_Child + (cetruetab - pttab_Child) * ds_Child
+      
+      DO i = 1,nbdim         
+C     
+        indmin(i) = pttab_Parent(i) + 
+     &         agrif_int((dim_newmin(i)-s_Parent(i))/ds_Parent(i))
+C
+        indmax(i) = pttab_Parent(i) + 
+     &                agrif_ceiling((dim_newmax(i)-
+     &                s_Parent(i))/ds_Parent(i))
+     
+C
+C
+C       Necessary for the Quadratic interpolation
+C  
+
+        IF ((pttruetab(i) == cetruetab(i)) .AND. 
+     &                           (posvar(i) == 1)) THEN
+        ELSEIF (interptab(i) .EQ. 'N') THEN
+        ELSEIF ( TYPEinterp(i) .eq. Agrif_ppm .or.
+     &      TYPEinterp(i) .eq. Agrif_eno  .or.
+     &      TYPEinterp(i) .eq. Agrif_weno) THEN            
+           indmin(i) = indmin(i) - 2  
+           indmax(i) = indmax(i) + 2                  
+        ELSE IF (( TYPEinterp(i) .ne. Agrif_constant )
+     &        .AND.( TYPEinterp(i) .ne. Agrif_linear )) THEN
+           indmin(i) = indmin(i) - 1  
+           indmax(i) = indmax(i) + 1
+        ENDIF
+        
+
+C        
+       ENDDO 
+C
+        s_Parent_temp = s_Parent + (indmin - pttab_Parent) * ds_Parent
+C     
+        s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child
+C
+C
+      Return
+C
+C
+      End Subroutine Agrif_Parentbounds
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_1D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_1D_recursive(TypeInterp,tabin,tabout,
+     &           indmin,indmax, 
+     &           pttab_child,petab_child,
+     &           s_child,s_parent,ds_child,ds_parent,nbdim)     
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 1D grid variable. 
+CCC   It calls Agrif_InterpBase. 
+C
+C     Declarations:
+C
+      
+C
+C     Arguments
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(1) :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim) :: s_child,s_parent
+      REAL, DIMENSION(nbdim) :: ds_child,ds_parent
+      REAL, INTENT(IN),DIMENSION(indmin(nbdim):indmax(nbdim)) :: tabin        
+      REAL, INTENT(OUT),
+     &      DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tabout
+      INTEGER :: coeffraf
+C
+C
+C     Commentaire perso : nbdim vaut toujours 1 ici. 
+C
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+      
+      Call Agrif_InterpBase(TypeInterp(1),
+     &                  tabin(indmin(nbdim):indmax(nbdim)),
+     &                  tabout(pttab_child(nbdim):petab_child(nbdim)),
+     &                  indmin(nbdim),indmax(nbdim),            
+     &                  pttab_child(nbdim),petab_child(nbdim),
+     &                  s_parent(nbdim),s_child(nbdim),
+     &                  ds_parent(nbdim),ds_child(nbdim),coeffraf)
+                
+C                
+      Return
+C
+C
+      End Subroutine Agrif_Interp_1D_recursive
+C
+C
+C      
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_2D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_2D_recursive(TypeInterp,
+     &           tabin,tabout,
+     &           indmin,indmax,   
+     &           pttab_child,petab_child,
+     &            s_child, s_parent,
+     &           ds_child,ds_parent,
+     &           nbdim)
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 2D grid variable. 
+CCC   It calls Agrif_Interp_1D_recursive and Agrif_InterpBase.    
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER,DIMENSION(2)      :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL   , DIMENSION(nbdim) ::  s_child, s_parent
+      REAL   , DIMENSION(nbdim) :: ds_child,ds_parent
+      REAL   ,INTENT(IN), DIMENSION(
+     &                indmin(nbdim-1):indmax(nbdim-1),
+     &                indmin(nbdim):indmax(nbdim)
+     &                ) :: tabin        
+      REAL   ,INTENT(OUT), DIMENSION(
+     &                pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                pttab_child(nbdim):petab_child(nbdim)
+     &                ) :: tabout
+C
+C     Local variables      
+      REAL, DIMENSION(pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp
+      INTEGER i,j
+      INTEGER :: coeffraf
+      REAL   , DIMENSION(
+     &                pttab_child(nbdim):petab_child(nbdim),
+     &                pttab_child(nbdim-1):petab_child(nbdim-1)
+     &                ) :: tabout_trsp
+      REAL, DIMENSION(indmin(nbdim):indmax(nbdim),
+     &        pttab_child(nbdim-1):petab_child(nbdim-1)) :: tabtemp_trsp
+
+C
+C
+C
+C
+C     Commentaire perso : nbdim vaut toujours 2 ici.
+C
+      coeffraf = nint ( ds_parent(1) / ds_child(1) )
+      IF((TypeInterp(1) == Agrif_Linear) .AND. (coeffraf /= 1 ) )THEN
+
+!---CDIR NEXPAND
+          IF(.NOT. precomputedone(1) ) call linear1Dprecompute2D(
+     &          indmax(2)-indmin(2)+1,   
+     &          indmax(1)-indmin(1)+1,   
+     &          petab_child(1)-pttab_child(1)+1,
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+!---CDIR NEXPAND
+           call linear1daftercompute(tabin,tabtemp,
+     &          size(tabin), size(tabtemp),  
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+ 
+      ELSEIF((TypeInterp(1) == Agrif_PPM) .AND. (coeffraf /= 1 ) )THEN
+!---CDIR NEXPAND
+          IF(.NOT. precomputedone(1) ) call ppm1Dprecompute2D(
+     &          indmax(2)-indmin(2)+1,   
+     &          indmax(1)-indmin(1)+1,   
+     &          petab_child(1)-pttab_child(1)+1,
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+!---CDIR NEXPAND
+           call ppm1daftercompute(tabin,tabtemp,
+     &          size(tabin), size(tabtemp),  
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+
+      ELSE
+
+      do j = indmin(nbdim),indmax(nbdim)
+C        
+!---CDIR NEXPAND
+        Call Agrif_Interp_1D_recursive(TypeInterp(1),
+     &         tabin(indmin(nbdim-1):indmax(nbdim-1),j),
+     &         tabtemp(pttab_child(nbdim-1):petab_child(nbdim-1),j),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C        
+      enddo
+      ENDIF   
+
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+      
+      tabtemp_trsp = TRANSPOSE(tabtemp)
+
+      IF((TypeInterp(2) == Agrif_Linear) .AND. (coeffraf /= 1 ) )THEN
+
+!---CDIR NEXPAND
+          IF(.NOT. precomputedone(2) ) call linear1Dprecompute2D(
+     &          petab_child(1)-pttab_child(1)+1,
+     &          indmax(2)-indmin(2)+1,
+     &          petab_child(2)-pttab_child(2)+1,
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+!---CDIR NEXPAND
+           call linear1daftercompute(tabtemp_trsp,tabout_trsp,
+     &          size(tabtemp_trsp), size(tabout_trsp),
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+
+      ELSEIF((TypeInterp(2) == Agrif_PPM) .AND. (coeffraf /= 1 ) )THEN
+
+!---CDIR NEXPAND
+           IF(.NOT. precomputedone(1) )call ppm1Dprecompute2D(
+     &          petab_child(1)-pttab_child(1)+1,
+     &          indmax(2)-indmin(2)+1,
+     &          petab_child(2)-pttab_child(2)+1,
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+!---CDIR NEXPAND
+           call ppm1daftercompute(tabtemp_trsp,tabout_trsp,
+     &          size(tabtemp_trsp), size(tabout_trsp),
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+
+      ELSE
+      do i=pttab_child(nbdim-1),petab_child(nbdim-1)
+C
+!---CDIR NEXPAND
+        Call Agrif_InterpBase(TypeInterp(2),
+     &           tabtemp_trsp(indmin(nbdim):indmax(nbdim),i),
+     &           tabout_trsp(pttab_child(nbdim):petab_child(nbdim),i),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),coeffraf)
+
+C        
+      enddo
+      ENDIF
+      
+      tabout = TRANSPOSE(tabout_trsp)
+C
+      Return
+C
+C
+      End Subroutine Agrif_Interp_2D_recursive
+C
+C
+C      
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_3D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_3D_recursive(TypeInterp,tabin,tabout,
+     &           indmin,indmax,   
+     &           pttab_child,petab_child,
+     &           s_child,s_parent,ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 3D grid variable. 
+CCC   It calls Agrif_Interp_2D_recursive and Agrif_InterpBase.    
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(3) :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent
+      REAL,INTENT(IN), DIMENSION(indmin(nbdim-2):indmax(nbdim-2),
+     &                indmin(nbdim-1):indmax(nbdim-1),
+     &                indmin(nbdim)  :indmax(nbdim)) :: tabin        
+      REAL,INTENT(OUT),
+     &        DIMENSION(pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                pttab_child(nbdim):petab_child(nbdim)) :: tabout
+C
+C     Local variables      
+      REAL, DIMENSION(pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp
+      INTEGER i,j,k
+      INTEGER :: coeffraf, locind_child_left, kdeb
+C
+C
+      coeffraf = nint ( ds_parent(1) / ds_child(1) )
+      IF((TypeInterp(1) == Agrif_Linear) .AND. (coeffraf/=1))THEN 
+        Call linear1Dprecompute2D(
+     &          indmax(2)-indmin(2)+1,
+     &          indmax(1)-indmin(1)+1,
+     &          petab_child(1)-pttab_child(1)+1,
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+      precomputedone(1) = .TRUE. 
+      ELSEIF((TypeInterp(1) == Agrif_PPM) .AND. (coeffraf/=1))THEN
+        Call ppm1Dprecompute2D(
+     &          indmax(2)-indmin(2)+1,
+     &          indmax(1)-indmin(1)+1,
+     &          petab_child(1)-pttab_child(1)+1,
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+      precomputedone(1) = .TRUE.
+      ENDIF
+
+      coeffraf = nint ( ds_parent(2) / ds_child(2) )
+      IF((TypeInterp(2) == Agrif_Linear) .AND. (coeffraf/=1)) THEN
+         Call linear1Dprecompute2D(
+     &          petab_child(1)-pttab_child(1)+1,
+     &          indmax(2)-indmin(2)+1,
+     &          petab_child(2)-pttab_child(2)+1,
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+      precomputedone(2) = .TRUE. 
+      ELSEIF((TypeInterp(2) == Agrif_PPM) .AND. (coeffraf/=1)) THEN
+         Call ppm1Dprecompute2D(
+     &          petab_child(1)-pttab_child(1)+1,
+     &          indmax(2)-indmin(2)+1,
+     &          petab_child(2)-pttab_child(2)+1,
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+      precomputedone(2) = .TRUE.
+      ENDIF
+
+      do k = indmin(nbdim),indmax(nbdim)
+C        
+        Call Agrif_Interp_2D_recursive(TypeInterp(1:2),
+     &         tabin(indmin(nbdim-2):indmax(nbdim-2),
+     &         indmin(nbdim-1):indmax(nbdim-1),k),
+     &         tabtemp(pttab_child(nbdim-2):petab_child(nbdim-2),
+     &         pttab_child(nbdim-1):petab_child(nbdim-1),k),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C        
+      enddo
+      
+      precomputedone(1) = .FALSE.
+      precomputedone(2) = .FALSE.
+      coeffraf = nint ( ds_parent(3) / ds_child(3) )
+
+      Call Agrif_Compute_nbdim_interp(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+           
+      IF (coeffraf == 1) THEN
+      
+      kdeb = indmin(3)+locind_child_left-2
+      do k=pttab_child(3),petab_child(3)
+      kdeb = kdeb + 1
+      do j = pttab_child(2),petab_child(2)
+        do i = pttab_child(1),petab_child(1)
+        tabout(i,j,k) = tabtemp(i,j,kdeb)
+      enddo
+      enddo
+      enddo
+              
+      ELSE      
+C
+      do j=pttab_child(nbdim-1),petab_child(nbdim-1) 
+C        
+        do i=pttab_child(nbdim-2),petab_child(nbdim-2)
+C
+          Call Agrif_InterpBase(TypeInterp(3),
+     &           tabtemp(i,j,indmin(nbdim):indmax(nbdim)),
+     &           tabout(i,j,pttab_child(nbdim):petab_child(nbdim)),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),coeffraf)
+C
+        enddo 
+C       
+      enddo
+      ENDIF
+C
+      Return
+C        
+C
+      End Subroutine Agrif_Interp_3D_recursive
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_4D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_4D_recursive(TypeInterp,tabin,tabout,
+     &           indmin,indmax,   
+     &           pttab_child,petab_child,
+     &           s_child,s_parent,ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 4D grid variable. 
+CCC   It calls Agrif_Interp_3D_recursive and Agrif_InterpBase.    
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(4) :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent
+      REAL,INTENT(IN), DIMENSION(indmin(nbdim-3):indmax(nbdim-3),
+     &                indmin(nbdim-2):indmax(nbdim-2),
+     &                indmin(nbdim-1):indmax(nbdim-1),
+     &                indmin(nbdim):indmax(nbdim)) :: tabin        
+      REAL,INTENT(OUT),
+     &       DIMENSION(pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                pttab_child(nbdim):petab_child(nbdim)) :: tabout
+C
+C     Local variables      
+      REAL, DIMENSION(pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                 pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),  
+     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp
+      INTEGER i,j,k,l
+      INTEGER :: coeffraf
+C
+C
+      do l = indmin(nbdim),indmax(nbdim)
+C        
+        Call Agrif_Interp_3D_recursive(TypeInterp(1:3),
+     &         tabin(indmin(nbdim-3):indmax(nbdim-3),
+     &               indmin(nbdim-2):indmax(nbdim-2),
+     &               indmin(nbdim-1):indmax(nbdim-1),l),
+     &         tabtemp(pttab_child(nbdim-3):petab_child(nbdim-3),
+     &         pttab_child(nbdim-2):petab_child(nbdim-2),
+     &         pttab_child(nbdim-1):petab_child(nbdim-1),l),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C        
+      enddo
+C
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+      
+      do k = pttab_child(nbdim-1),petab_child(nbdim-1)
+C
+        do j = pttab_child(nbdim-2),petab_child(nbdim-2) 
+C        
+          do i = pttab_child(nbdim-3),petab_child(nbdim-3)
+C
+            Call Agrif_InterpBase(TypeInterp(4),
+     &           tabtemp(i,j,k,indmin(nbdim):indmax(nbdim)),
+     &           tabout(i,j,k,pttab_child(nbdim):petab_child(nbdim)),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),coeffraf)
+C
+          enddo
+C
+        enddo 
+C       
+      enddo
+C
+      Return
+C
+C        
+      End Subroutine Agrif_Interp_4D_recursive
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_5D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_5D_recursive(TypeInterp,tabin,tabout,
+     &           indmin,indmax,   
+     &           pttab_child,petab_child,
+     &           s_child,s_parent,ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 5D grid variable. 
+CCC   It calls Agrif_Interp_4D_recursive and Agrif_InterpBase.    
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(5) :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent
+      REAL,INTENT(IN), DIMENSION(indmin(nbdim-4):indmax(nbdim-4),
+     &                indmin(nbdim-3):indmax(nbdim-3),
+     &                indmin(nbdim-2):indmax(nbdim-2),
+     &                indmin(nbdim-1):indmax(nbdim-1),
+     &                indmin(nbdim):indmax(nbdim)) :: tabin  
+      REAL,INTENT(OUT),
+     &    DIMENSION(pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                pttab_child(nbdim):petab_child(nbdim)) :: tabout
+C
+C     Local variables      
+      REAL, DIMENSION(pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                 pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                 pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),    
+     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp
+      INTEGER i,j,k,l,m
+      INTEGER :: coeffraf
+C
+C
+      do m = indmin(nbdim),indmax(nbdim)
+C        
+        Call Agrif_Interp_4D_recursive(TypeInterp(1:4),
+     &         tabin(indmin(nbdim-4):indmax(nbdim-4),
+     &               indmin(nbdim-3):indmax(nbdim-3),
+     &               indmin(nbdim-2):indmax(nbdim-2),
+     &               indmin(nbdim-1):indmax(nbdim-1),m),
+     &         tabtemp(pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                 pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                 pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),m),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C        
+      enddo
+      
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+C
+      do l = pttab_child(nbdim-1),petab_child(nbdim-1) 
+C
+        do k = pttab_child(nbdim-2),petab_child(nbdim-2)
+C
+          do j = pttab_child(nbdim-3),petab_child(nbdim-3) 
+C        
+            do i = pttab_child(nbdim-4),petab_child(nbdim-4)
+C
+              Call Agrif_InterpBase(TypeInterp(5),
+     &             tabtemp(i,j,k,l,indmin(nbdim):indmax(nbdim)),
+     &                    tabout(i,j,k,l,
+     &             pttab_child(nbdim):petab_child(nbdim)),
+     &             indmin(nbdim),indmax(nbdim),
+     &             pttab_child(nbdim),petab_child(nbdim),
+     &             s_parent(nbdim),s_child(nbdim),
+     &             ds_parent(nbdim),ds_child(nbdim),coeffraf)
+C
+            enddo
+C
+          enddo
+C
+        enddo 
+C       
+      enddo
+C
+C
+      Return
+C
+C        
+      End Subroutine Agrif_Interp_5D_recursive
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Interp_6D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Interp_6D_recursive(TypeInterp,tabin,tabout,
+     &           indmin,indmax,   
+     &           pttab_child,petab_child,
+     &           s_child,s_parent,ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine for the interpolation of a 6D grid variable. 
+CCC   It calls Agrif_Interp_4D_recursive and Agrif_InterpBase.    
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(6) :: TypeInterp
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent
+      REAL,INTENT(IN), DIMENSION(indmin(nbdim-5):indmax(nbdim-5),
+     &                indmin(nbdim-4):indmax(nbdim-4),
+     &                indmin(nbdim-3):indmax(nbdim-3), 
+     &                indmin(nbdim-2):indmax(nbdim-2),
+     &                indmin(nbdim-1):indmax(nbdim-1),
+     &                indmin(nbdim):indmax(nbdim)) :: tabin        
+      REAL,INTENT(OUT),
+     &    DIMENSION(pttab_child(nbdim-5):petab_child(nbdim-5),
+     &                pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                pttab_child(nbdim-1):petab_child(nbdim-1),
+     &                pttab_child(nbdim):petab_child(nbdim)) :: tabout
+C
+C     Local variables      
+      REAL, DIMENSION(pttab_child(nbdim-5):petab_child(nbdim-5),
+     &                 pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                 pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                 pttab_child(nbdim-2):petab_child(nbdim-2),    
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),    
+     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp
+      INTEGER i,j,k,l,m,n
+      INTEGER :: coeffraf
+C
+C        
+C
+      do n = indmin(nbdim),indmax(nbdim)
+C        
+        Call Agrif_Interp_5D_recursive(TypeInterp(1:5),
+     &         tabin(indmin(nbdim-5):indmax(nbdim-5),
+     &               indmin(nbdim-4):indmax(nbdim-4),
+     &               indmin(nbdim-3):indmax(nbdim-3),
+     &               indmin(nbdim-2):indmax(nbdim-2),
+     &               indmin(nbdim-1):indmax(nbdim-1),n),
+     &         tabtemp(pttab_child(nbdim-5):petab_child(nbdim-5),
+     &                 pttab_child(nbdim-4):petab_child(nbdim-4),
+     &                 pttab_child(nbdim-3):petab_child(nbdim-3),
+     &                 pttab_child(nbdim-2):petab_child(nbdim-2),
+     &                 pttab_child(nbdim-1):petab_child(nbdim-1),n),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C        
+      enddo
+      
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+C
+      do m = pttab_child(nbdim-1),petab_child(nbdim-1) 
+      do l = pttab_child(nbdim-2),petab_child(nbdim-2) 
+C
+        do k = pttab_child(nbdim-3),petab_child(nbdim-3)
+C
+          do j = pttab_child(nbdim-4),petab_child(nbdim-4) 
+C        
+            do i = pttab_child(nbdim-5),petab_child(nbdim-5)
+C
+              Call Agrif_InterpBase(TypeInterp(6),
+     &             tabtemp(i,j,k,l,m,indmin(nbdim):indmax(nbdim)),
+     &                    tabout(i,j,k,l,m,
+     &                    pttab_child(nbdim):petab_child(nbdim)),
+     &             indmin(nbdim),indmax(nbdim),
+     &             pttab_child(nbdim),petab_child(nbdim),
+     &             s_parent(nbdim),s_child(nbdim),
+     &             ds_parent(nbdim),ds_child(nbdim),coeffraf)
+C
+            enddo
+C
+          enddo
+C
+        enddo 
+C       
+      enddo
+      enddo
+C                
+C
+      Return
+C
+C        
+      End Subroutine Agrif_Interp_6D_recursive
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_InterpBase  
+C     **************************************************************************
+C  
+      Subroutine Agrif_InterpBase(TypeInterp,
+     &                           parenttab,childtab,
+     &                           indmin,indmax,pttab_child,petab_child,
+     &                           s_parent,s_child,ds_parent,ds_child,
+     &                           coeffraf)   
+C
+CCC   Description:
+CCC   Subroutine calling the interpolation method chosen by the user (linear, 
+CCC   lagrange or spline). 
+C
+C     Declarations:
+C
+      
+C
+      INTEGER                :: TypeInterp
+      INTEGER :: indmin,indmax
+      INTEGER :: pttab_child,petab_child
+      REAL,INTENT(IN),DIMENSION(indmin:indmax)           :: parenttab       
+      REAL,INTENT(OUT),DIMENSION(pttab_child:petab_child) :: childtab        
+      REAL    :: s_parent,s_child,ds_parent,ds_child 
+      INTEGER :: coeffraf
+C 
+C
+       IF ((indmin == indmax).AND.(pttab_child == petab_child)) THEN
+         childtab(pttab_child) = parenttab(indmin)
+       ELSEIF (TYPEinterp .EQ. AGRIF_LINEAR) then    
+C
+C         Linear interpolation 
+  
+          Call linear1D
+     &         (parenttab,childtab,
+     &          indmax-indmin+1,petab_child-pttab_child+1,
+     &          s_parent,s_child,ds_parent,ds_child)
+C          
+      elseif ( TYPEinterp .EQ. AGRIF_PPM ) then
+
+          Call ppm1D
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)
+C
+
+        elseif (TYPEinterp .EQ. AGRIF_LAGRANGE) then
+C          
+C         Lagrange interpolation    
+          Call lagrange1D
+     &        (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)
+C            
+        elseif (TYPEinterp .EQ. AGRIF_ENO) then
+C          
+C         Eno interpolation
+          Call eno1D
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)
+C        
+        elseif (TYPEinterp .EQ. AGRIF_WENO) then
+C          
+C         Eno interpolation
+          Call weno1D
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)
+C            
+        Else if (TYPEinterp .EQ. AGRIF_LINEARCONSERV) then
+C          
+C         Linear conservative interpolation
+          
+          Call linear1Dconserv
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)   
+C              
+        Else if (TYPEinterp .EQ. AGRIF_LINEARCONSERVLIM) then
+C          
+C         Linear conservative interpolation
+          
+          Call linear1Dconservlim
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)         
+C              
+        elseif (TYPEinterp .EQ. AGRIF_CONSTANT) then
+C          
+          Call constant1D
+     &         (parenttab,childtab,
+     &         indmax-indmin+1,petab_child-pttab_child+1,
+     &         s_parent,s_child,ds_parent,ds_child)
+C              
+      endif 
+C
+C      
+      End Subroutine Agrif_InterpBase 
+C
+
+      Subroutine Agrif_Compute_nbdim_interp(s_parent,s_child,
+     &  ds_parent,ds_child,coeffraf,locind_child_left)
+      real :: s_parent,s_child,ds_parent,ds_child
+      integer :: coeffraf,locind_child_left
+     
+      coeffraf = nint(ds_parent/ds_child)
+      locind_child_left = 1 + agrif_int((s_child-s_parent)/ds_parent)
+      End Subroutine Agrif_Compute_nbdim_interp
+C          
+
+      Subroutine Agrif_Find_list_interp(list_interp,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim,
+     &                          indmin,indmax,indminglob,
+     &      indmaxglob,indminglob2,indmaxglob2,parentarray,
+     &       pttruetab,cetruetab,member,memberin,
+     &      find_list_interp
+#if defined AGRIF_MPI
+     &     ,tab4t,memberinall,sendtoproc1,recvfromproc1
+#endif
+     &    )     
+      TYPE(Agrif_List_Interp_Loc), Pointer :: list_interp
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent
+      LOGICAL :: find_list_interp
+      Type(Agrif_List_Interp_loc), Pointer :: parcours
+      INTEGER,DIMENSION(nbdim)   :: indmin,indmax  
+      INTEGER,DIMENSION(nbdim)   :: indminglob,indmaxglob
+      INTEGER,DIMENSION(nbdim)   :: pttruetab,cetruetab      
+      INTEGER,DIMENSION(nbdim)   :: indminglob2,indmaxglob2  
+      INTEGER,DIMENSION(nbdim,2,2) :: parentarray
+      LOGICAL :: member, memberin
+      INTEGER :: i
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1,recvfromproc1
+#endif 
+                    
+      find_list_interp = .FALSE.
+      
+      parcours => list_interp
+      Find_loop :   Do While (associated(parcours))
+        Do i=1,nbdim
+          IF ((pttab(i) /= parcours%interp_loc%pttab(i)).OR.
+     &        (petab(i) /= parcours%interp_loc%petab(i)).OR.
+     &        (pttab_child(i) /= parcours%interp_loc%pttab_child(i)).OR.
+     &        (pttab_parent(i) /= parcours%interp_loc%pttab_parent(i)))
+     &               THEN
+            parcours=>parcours%suiv
+            Cycle Find_loop
+          ENDIF
+        EndDo
+
+        indmin = parcours%interp_loc%indmin(1:nbdim)
+        indmax = parcours%interp_loc%indmax(1:nbdim)
+        
+        pttruetab = parcours%interp_loc%pttruetab(1:nbdim)
+        cetruetab = parcours%interp_loc%cetruetab(1:nbdim)
+                
+#if !defined AGRIF_MPI
+        indminglob = parcours%interp_loc%indminglob(1:nbdim)
+        indmaxglob = parcours%interp_loc%indmaxglob(1:nbdim)
+#else
+        indminglob2 = parcours%interp_loc%indminglob2(1:nbdim)
+        indmaxglob2 = parcours%interp_loc%indmaxglob2(1:nbdim)
+        parentarray = parcours%interp_loc%parentarray(1:nbdim,:,:)
+        member = parcours%interp_loc%member
+        tab4t = parcours%interp_loc%tab4t(1:nbdim,0:Agrif_Nbprocs-1,1:8)
+        memberinall = parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1)
+        sendtoproc1 = parcours%interp_loc%sendtoproc1(0:Agrif_Nbprocs-1)
+        recvfromproc1 = 
+     &    parcours%interp_loc%recvfromproc1(0:Agrif_Nbprocs-1)
+#endif        
+        memberin = parcours%interp_loc%memberin
+        find_list_interp = .TRUE.   
+        Exit Find_loop
+      End Do Find_loop  
+                              
+      End Subroutine Agrif_Find_list_interp   
+      
+      Subroutine Agrif_AddTo_list_interp(list_interp,pttab,petab,
+     &                          pttab_Child,pttab_Parent,indmin,indmax,
+     &                          indminglob,indmaxglob,
+     &                          indminglob2,indmaxglob2,
+     &                          parentarray,pttruetab,cetruetab,
+     &                          member,memberin,nbdim
+#if defined AGRIF_MPI
+     &      ,tab4t,memberinall,sendtoproc1,recvfromproc1
+#endif
+     &    )
+          
+      TYPE(Agrif_List_Interp_Loc), Pointer :: list_interp
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent
+      INTEGER,DIMENSION(nbdim)   :: indmin,indmax
+      INTEGER,DIMENSION(nbdim)   :: indminglob,indmaxglob
+      INTEGER,DIMENSION(nbdim)   :: indminglob2,indmaxglob2
+      INTEGER,DIMENSION(nbdim)   :: pttruetab,cetruetab
+      INTEGER,DIMENSION(nbdim,2,2) :: parentarray
+      LOGICAL :: member, memberin
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: memberinall
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: recvfromproc1
+#endif                   
+      Type(Agrif_List_Interp_loc), Pointer :: parcours
+            
+       Allocate(parcours)
+      Allocate(parcours%interp_loc)
+      
+      parcours%interp_loc%pttab(1:nbdim) = pttab(1:nbdim)
+      parcours%interp_loc%petab(1:nbdim) = petab(1:nbdim)
+      parcours%interp_loc%pttab_child(1:nbdim) = pttab_child(1:nbdim)
+      parcours%interp_loc%pttab_parent(1:nbdim) = pttab_parent(1:nbdim)
+  
+  
+      parcours%interp_loc%indmin(1:nbdim) = indmin(1:nbdim)
+      parcours%interp_loc%indmax(1:nbdim) = indmax(1:nbdim)
+
+      parcours%interp_loc%memberin = memberin
+#if !defined AGRIF_MPI
+      parcours%interp_loc%indminglob(1:nbdim) = indminglob(1:nbdim)
+      parcours%interp_loc%indmaxglob(1:nbdim) = indmaxglob(1:nbdim)
+#else
+      parcours%interp_loc%indminglob2(1:nbdim) = indminglob2(1:nbdim)
+      parcours%interp_loc%indmaxglob2(1:nbdim) = indmaxglob2(1:nbdim)
+      parcours%interp_loc%parentarray(1:nbdim,:,:) 
+     &       = parentarray(1:nbdim,:,:)
+      parcours%interp_loc%member = member
+      Allocate(parcours%interp_loc%tab4t(nbdim,0:Agrif_Nbprocs-1,8))
+      Allocate(parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1))
+      Allocate(parcours%interp_loc%sendtoproc1(0:Agrif_Nbprocs-1))
+      Allocate(parcours%interp_loc%recvfromproc1(0:Agrif_Nbprocs-1))                  
+      parcours%interp_loc%tab4t=tab4t   
+      parcours%interp_loc%memberinall=memberinall   
+      parcours%interp_loc%sendtoproc1=sendtoproc1
+      parcours%interp_loc%recvfromproc1=recvfromproc1            
+#endif      
+
+      parcours%interp_loc%pttruetab(1:nbdim) = pttruetab(1:nbdim)
+      parcours%interp_loc%cetruetab(1:nbdim) = cetruetab(1:nbdim)
+      
+      parcours%suiv => list_interp
+      
+      list_interp => parcours
+      End Subroutine Agrif_Addto_list_interp 
+                
+      End Module Agrif_Interpolation
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterpbasic.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterpbasic.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modinterpbasic.F	(revision 1844)
@@ -0,0 +1,1691 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Interpbasic
+C
+      Module Agrif_Interpbasic
+C
+CCC   Description:
+CCC   Module containing different procedures of interpolation (linear,lagrange,
+CCC   spline,...) used in the Agrif_Interpolation module.
+C
+C     Modules used:
+      USE Agrif_types
+C
+      IMPLICIT NONE
+C             
+      Real,Dimension(Agrif_MaxRaff) :: tabdiff2, tabdiff3
+      Real,Dimension(5,Agrif_MaxRaff,3) :: tabppm
+      Real,Dimension(:),Allocatable::tabtest4   
+      Integer, Dimension(:,:), Allocatable :: indparent
+      Integer, Dimension(:,:), Allocatable :: 
+     &           indparentppm,indchildppm
+      Integer, Dimension(:), Allocatable :: 
+     &           indparentppm_1d,indchildppm_1d
+      Real, Dimension(:,:),Allocatable :: coeffparent   
+       
+      CONTAINS
+C     Define procedures contained in this module
+C  
+C     **************************************************************************  
+CCC   Subroutine Linear1d  
+C     ************************************************************************** 
+C 
+      Subroutine Linear1d(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a linear 1D interpolation on a child grid (vector y) from
+CCC   its parent grid (vector x).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C        
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL,INTENT(IN), DIMENSION(np) :: x      
+      REAL,INTENT(OUT), DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      INTEGER :: i,coeffraf,locind_parent_left
+      REAL    :: ypos,globind_parent_left,globind_parent_right
+      REAL    :: invds, invds2
+      REAL :: ypos2,diff
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      if (coeffraf == 1) then
+C
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+C        
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+C
+          return
+C
+      endif                          
+C
+      ypos = s_child 
+
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+
+        globind_parent_left = s_parent 
+     &                        + (locind_parent_left - 1)*ds_parent
+
+        globind_parent_right = globind_parent_left + ds_parent
+
+C
+      invds = 1./ds_parent
+      invds2 = ds_child/ds_parent
+      
+      ypos2 = ypos*invds
+      globind_parent_right=globind_parent_right*invds
+      
+      do i = 1,nc-1
+C
+        if (ypos2 > globind_parent_right) then
+           locind_parent_left = locind_parent_left + 1.
+           globind_parent_right = globind_parent_right + 1.
+        endif
+        
+        diff=(globind_parent_right - ypos2)
+        
+        y(i) = (diff*x(locind_parent_left)
+     &        + (1.-diff)*x(locind_parent_left+1))
+C
+        ypos2 = ypos2 + invds2
+C
+      enddo
+C
+      ypos = s_child + (nc-1)*ds_child
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+C
+      if (locind_parent_left == np) then
+C
+          y(nc) = x(np)
+C
+        else
+C
+          globind_parent_left = s_parent 
+     &                        + (locind_parent_left - 1)*ds_parent  
+C      
+          y(nc) = ((globind_parent_left + ds_parent - ypos)
+     &            *x(locind_parent_left)
+     &          + (ypos - globind_parent_left)
+     &            *x(locind_parent_left+1))*invds
+C
+      endif                                          
+C           
+      Return
+C
+C       
+      End Subroutine Linear1d   
+      
+      Subroutine Linear1dprecompute2d(np2, np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to compute 2D coefficient and index for a linear 1D interpolation
+CCC   on a child grid (vector y) from its parent grid (vector x).
+C
+CC    Method:
+C
+C     Declarations:
+C
+
+C        
+C     Arguments
+      INTEGER             :: np,nc,np2,dir
+      REAL                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      INTEGER :: i,j,coeffraf,locind_parent_left,inc,inc1,inc2,toto 
+      Integer, Dimension(:,:), Allocatable :: indparent_tmp
+      Real, Dimension(:,:), Allocatable :: coeffparent_tmp
+      REAL    :: ypos,globind_parent_left,globind_parent_right
+      REAL    :: invds, invds2
+      REAL :: ypos2,diff
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      ypos = s_child
+
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+
+        globind_parent_left = s_parent
+     &                        + (locind_parent_left - 1)*ds_parent
+
+        globind_parent_right = globind_parent_left + ds_parent
+
+C
+      invds = 1./ds_parent
+      invds2 = ds_child/ds_parent
+
+      ypos2 = ypos*invds
+      globind_parent_right=globind_parent_right*invds
+
+      if (.not.allocated(indparent)) then
+      allocate(indparent(nc*np2,3),coeffparent(nc*np2,3))
+      else
+      if (size(indparent,1)<nc*np2) then
+      allocate(coeffparent_tmp(size(indparent,1),size(indparent,2)))
+      allocate(indparent_tmp(size(indparent,1),size(indparent,2)))
+      coeffparent_tmp=coeffparent 
+      indparent_tmp=indparent 
+      deallocate(indparent,coeffparent)
+      allocate(indparent(nc*np2,3),coeffparent(nc*np2,3))
+      coeffparent(1:size(coeffparent_tmp,1),1:size(coeffparent_tmp,2))
+     &  = coeffparent_tmp 
+      indparent(1:size(indparent_tmp,1),1:size(indparent_tmp,2))
+     & = indparent_tmp
+      deallocate(indparent_tmp,coeffparent_tmp)
+      endif
+      endif
+
+      do i = 1,nc-1
+C
+        if (ypos2 > globind_parent_right) then
+           locind_parent_left = locind_parent_left + 1
+           globind_parent_right = globind_parent_right + 1.
+        endif
+        
+        diff=(globind_parent_right - ypos2)
+        indparent(i,dir) = locind_parent_left
+        coeffparent(i,dir) = diff
+        
+        ypos2 = ypos2 + invds2
+C
+      enddo
+C
+      ypos = s_child + (nc-1)*ds_child
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+
+      if (locind_parent_left == np) then
+      indparent(nc,dir) = locind_parent_left-1
+      coeffparent(nc,dir) = 0.
+        else
+C
+          globind_parent_left = s_parent
+     &                        + (locind_parent_left - 1)*ds_parent
+C      
+       indparent(nc,dir) = locind_parent_left
+       
+         coeffparent(nc,dir) = (globind_parent_left + ds_parent - ypos)
+     &       * invds
+      endif                                           
+
+      do i=2, np2
+      inc  =  i*nc
+      inc1 = (i-1)*nc
+      inc2 = (i-2)*nc 
+!CDIR ALTCODE
+      indparent(1+inc1:inc,dir) = indparent(1+inc2:inc1,dir)+np
+!CDIR ALTCODE
+      coeffparent(1+inc1:inc,dir) =coeffparent(1:nc,dir)
+      enddo      
+
+      Return
+C
+C       
+      End Subroutine Linear1dprecompute2d
+
+
+
+      Subroutine Linear1dprecompute(np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to compute 1D coefficient and index for a linear 1D interpolation
+CCC   on a child grid (vector y) from its parent grid (vector x).
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C        
+C     Arguments
+      INTEGER             :: np,nc 
+      REAL                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      INTEGER :: i,coeffraf,locind_parent_left
+      REAL    :: ypos,globind_parent_left,globind_parent_right
+      REAL    :: invds, invds2
+      REAL :: ypos2,diff
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      if (coeffraf == 1) then
+C
+          return
+C
+      endif                          
+C
+      ypos = s_child 
+
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+
+        globind_parent_left = s_parent 
+     &                        + (locind_parent_left - 1)*ds_parent
+
+        globind_parent_right = globind_parent_left + ds_parent
+
+C
+      invds = 1./ds_parent
+      invds2 = ds_child/ds_parent
+      
+      ypos2 = ypos*invds
+      globind_parent_right=globind_parent_right*invds
+      
+      if (.not.allocated(indparent)) then
+      allocate(indparent(nc,1),coeffparent(nc,1))
+      else
+      if (size(indparent)<nc) then
+      deallocate(indparent,coeffparent)
+      allocate(indparent(nc,1),coeffparent(nc,1))
+      endif
+      endif
+      
+      do i = 1,nc-1
+C
+        if (ypos2 > globind_parent_right) then
+           locind_parent_left = locind_parent_left + 1
+           globind_parent_right = globind_parent_right + 1.
+        endif
+        
+        diff=(globind_parent_right - ypos2)
+        indparent(i,1) = locind_parent_left
+        coeffparent(i,1) = diff
+        ypos2 = ypos2 + invds2
+C
+      enddo
+C
+      ypos = s_child + (nc-1)*ds_child
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+      
+      if (locind_parent_left == np) then
+      indparent(nc,1) = locind_parent_left-1
+      coeffparent(nc,1) = 0.
+        else
+C
+          globind_parent_left = s_parent 
+     &                        + (locind_parent_left - 1)*ds_parent  
+C      
+       indparent(nc,1) = locind_parent_left
+       
+         coeffparent(nc,1) = (globind_parent_left + ds_parent - ypos)
+     &       * invds
+      endif                                          
+C           
+      Return
+C
+C       
+      End Subroutine Linear1dprecompute 
+      
+      Subroutine Linear1daftercompute(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child,dir) 
+C
+CCC   Description:
+CCC   Subroutine to do a linear 1D interpolation on a child grid (vector y) from
+CCC   its parent grid (vector x) using precomputed coefficient and index.  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C        
+C     Arguments
+      INTEGER             :: np,nc,dir      
+      REAL,INTENT(IN), DIMENSION(np) :: x      
+      REAL,INTENT(OUT), DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      INTEGER :: i,coeffraf,locind_parent_left
+      REAL    :: ypos,globind_parent_left,globind_parent_right
+      REAL    :: invds, invds2
+      REAL :: ypos2,diff
+C
+C
+
+!CDIR ALTCODE
+!CDIR NODEP
+      do i = 1,nc
+C
+       y(i)=coeffparent(i,dir)*x(MAX(indparent(i,dir),1))+
+     &      (1.-coeffparent(i,dir))*x(indparent(i,dir)+1)
+C
+      enddo                                     
+C           
+      Return
+C
+C       
+      End Subroutine Linear1daftercompute            
+       
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Lagrange1d  
+C     **************************************************************************
+C
+      Subroutine Lagrange1d(x,y,np,nc,
+     &                      s_parent,s_child,ds_parent,ds_child)
+C
+CCC   Description:
+CCC   Subroutine to do a lagrange 1D interpolation on a child grid (vector y) 
+CCC   from its parent grid (vector x).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C             
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL,INTENT(IN), DIMENSION(np) :: x      
+      REAL,INTENT(OUT), DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child,ds_parent,ds_child 
+C
+C     Local scalars
+      INTEGER :: i,coeffraf,locind_parent_left
+      REAL    :: ypos,globind_parent_left
+      REAL    :: X1,X2,X3 
+      real :: deltax,invdsparent
+      real t1,t2,t3,t4,t5,t6,t7,t8
+C
+C 
+      if (np <= 2) then
+C      
+          Call Linear1D(x,y,np,nc,
+     &                  s_parent,s_child,ds_parent,ds_child)
+C         
+         Return
+C 
+      endif
+C
+      coeffraf = nint(ds_parent/ds_child)
+C
+      if (coeffraf == 1) then
+C
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+C        
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+C
+          return
+C
+      endif
+      
+      invdsparent=1./ds_parent
+C
+      ypos = s_child      
+C
+      do i = 1,nc
+C
+        locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+C
+
+        globind_parent_left = s_parent 
+     &                        + (locind_parent_left - 1)*ds_parent 
+     
+        deltax = invdsparent*(ypos-globind_parent_left)
+        ypos = ypos + ds_child
+         if (abs(deltax).LE.0.0001) then
+           y(i)=x(locind_parent_left)
+           
+           cycle
+         endif
+C           
+C
+        t2 = deltax - 2.
+        t3 = deltax - 1.
+        t4 = deltax + 1.
+        
+        t5 = -(1./6.)*deltax*t2*t3
+        t6 = 0.5*t2*t3*t4
+        t7 = -0.5*deltax*t2*t4
+        t8 = (1./6.)*deltax*t3*t4
+        
+        y(i)=t5*x(locind_parent_left-1)+t6*x(locind_parent_left)
+     &  +t7*x(locind_parent_left+1)+t8*x(locind_parent_left+2)
+C
+C
+      enddo
+C
+      return
+C
+C       
+      End Subroutine Lagrange1d 
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Constant1d  
+C     ************************************************************************** 
+C 
+      Subroutine constant1d(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a linear 1D interpolation on a child grid (vector y) from
+CCC   its parent grid (vector x).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C        
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL,INTENT(IN), DIMENSION(np) :: x      
+      REAL,INTENT(OUT), DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      INTEGER :: i,coeffraf,locind_parent
+      REAL    :: ypos
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      if (coeffraf == 1) then
+C
+          locind_parent = 1 + nint((s_child - s_parent)/ds_parent)
+C        
+          y(1:nc) = x(locind_parent:locind_parent+nc-1)
+C
+          return
+C
+      endif                          
+C
+      ypos = s_child      
+C
+      do i = 1,nc
+C
+        locind_parent = 1 + nint((ypos - s_parent)/ds_parent)
+C
+        y(i) = x(locind_parent)
+C
+        ypos = ypos + ds_child
+C
+      enddo
+C           
+      Return
+C
+C       
+      End Subroutine constant1d   
+C
+C     **************************************************************************  
+CCC   Subroutine Linear1dconserv
+C     ************************************************************************** 
+C 
+      Subroutine Linear1dconserv(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a linear 1D interpolation on a child grid (vector y) from
+CCC   its parent grid (vector x).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc      
+      Real, Dimension(np) :: x      
+      Real, Dimension(nc) :: y
+      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Real    :: ypos
+      integer :: i1,i2,ii
+      real :: xpmin,xpmax,slope
+      INTEGER :: diffmod
+      REAL :: xdiffmod
+
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+C
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+C        
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+C
+          return
+C
+      End If
+C              
+      diffmod = 0
+      IF (mod(coeffraf,2) == 0) diffmod = 1  
+
+      xdiffmod = real(diffmod)/2.
+                         
+      allocate(ytemp(-2*coeffraf:nc+2*coeffraf))
+C
+      ypos = s_child  
+C      
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
+
+      locind_parent_last = 1 +
+     &  agrif_ceiling((ypos +(nc - 1) *ds_child - s_parent)/ds_parent)
+     
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent 
+      xpmax = s_parent + (locind_parent_last-1)*ds_parent          
+      
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)
+      i2 = 1+agrif_int((xpmax-s_child)/ds_child)
+
+      i = i1
+      
+      if (locind_parent_left == 1) then
+        slope=
+     &   (x(locind_parent_left+1)-x(locind_parent_left))/(coeffraf)
+      else
+         slope=
+     &   (x(locind_parent_left+1)-x(locind_parent_left-1))/(2.*coeffraf)
+      endif
+      
+        do ii=i-coeffraf/2+diffmod,i+coeffraf/2
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo 
+
+        locind_parent_left = locind_parent_left + 1
+                      
+      do i=i1 +  coeffraf, i2 - coeffraf,coeffraf
+        slope=
+     &   (x(locind_parent_left+1)-x(locind_parent_left-1))/(2.*coeffraf)
+        do ii=i-coeffraf/2+diffmod,i+coeffraf/2
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo
+        locind_parent_left = locind_parent_left + 1
+      enddo
+      
+      i = i2
+      
+      if (locind_parent_left == np) then
+        slope=
+     &   (x(locind_parent_left)-x(locind_parent_left-1))/(coeffraf)
+      else
+         slope=
+     &   (x(locind_parent_left+1)-x(locind_parent_left-1))/(2.*coeffraf)
+      endif
+      
+        do ii=i-coeffraf/2+diffmod,nc
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo      
+C
+      y(1:nc)=ytemp(1:nc)                                   
+C           
+      deallocate(ytemp)
+      Return
+C       
+      End Subroutine Linear1dconserv
+      
+C
+C     **************************************************************************  
+CCC   Subroutine Linear1dconservlim
+C     ************************************************************************** 
+C 
+      Subroutine Linear1dconservlim(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a linear 1D interpolation on a child grid (vector y) from
+CCC   its parent grid (vector x).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc      
+      Real, Dimension(np) :: x      
+      Real, Dimension(nc) :: y
+      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Real    :: ypos
+      integer :: i1,i2,ii
+      real :: xpmin,xpmax,slope
+      INTEGER :: diffmod
+      real :: xdiffmod
+C
+C
+
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+C
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+C        
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+C
+          return
+C
+      End If
+C
+      IF (coeffraf .NE.3) THEN
+      print *,'LINEARCONSERVLIM not ready for refinement ratio = ',
+     &   coeffraf
+      stop
+      ENDIF   
+      
+      diffmod = 0
+      IF (mod(coeffraf,2) == 0) diffmod = 1        
+
+      xdiffmod = real(diffmod)/2.
+                         
+      allocate(ytemp(-2*coeffraf:nc+2*coeffraf))
+C
+      ypos = s_child  
+C      
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
+
+      locind_parent_last = 1 +
+     &  agrif_ceiling((ypos +(nc - 1) *ds_child - s_parent)/ds_parent)
+     
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent 
+      xpmax = s_parent + (locind_parent_last-1)*ds_parent          
+      
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)
+      i2 = 1+agrif_int((xpmax-s_child)/ds_child)
+
+      i = i1
+      
+      if (locind_parent_left == 1) then
+        slope=0.       
+      else
+        slope = vanleer(x(locind_parent_left-1:locind_parent_left+1))
+        slope = slope / coeffraf    
+      endif
+      
+        do ii=i-coeffraf/2+diffmod,i+coeffraf/2
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo 
+
+        locind_parent_left = locind_parent_left + 1
+                      
+      do i=i1 +  coeffraf, i2 - coeffraf,coeffraf     
+        slope = vanleer(x(locind_parent_left-1:locind_parent_left+1))
+        slope = slope / coeffraf
+
+        do ii=i-coeffraf/2+diffmod,i+coeffraf/2
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo
+        locind_parent_left = locind_parent_left + 1
+      enddo
+      
+      i = i2
+      
+      if (locind_parent_left == np) then
+        slope=0.     
+      else
+        slope = vanleer(x(locind_parent_left-1:locind_parent_left+1))
+        slope = slope / coeffraf      
+      endif
+      
+        do ii=i-coeffraf/2+diffmod,nc
+          ytemp(ii) = x(locind_parent_left)+(ii-i-xdiffmod/2.)*slope
+        enddo      
+C
+      y(1:nc)=ytemp(1:nc)                                   
+C           
+      deallocate(ytemp)
+      Return
+C       
+      End Subroutine Linear1dconservlim      
+C         
+
+C     **************************************************************************  
+CCC   Subroutine ppm1d
+C     ************************************************************************** 
+C 
+      Subroutine ppm1d(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints
+CCC   using piecewise parabolic method  
+CCC   on a child grid (vector y) from its parent grid (vector x).
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc      
+      Real, INTENT(IN),Dimension(np) :: x      
+      Real, INTENT(OUT),Dimension(nc) :: y
+C      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,a
+C      
+      Real :: xrmin,xrmax,am3,s2,s1  
+      Real, Dimension(np) :: xl,delta,a6,slope
+C      Real, Dimension(:),Allocatable  :: diff,diff2,diff3    
+      INTEGER :: diffmod
+      REAL :: invcoeffraf
+C      
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+          return
+      End If
+      invcoeffraf = ds_child/ds_parent
+C      
+
+      IF( .NOT. allocated(tabtest4) ) THEN    
+      Allocate(tabtest4(-2*coeffraf:nc+2*coeffraf))
+      ELSE
+         IF (size(tabtest4) .LT. nc+4*coeffraf+1)THEN
+         deallocate( tabtest4 )
+         Allocate(tabtest4(-2*coeffraf:nc+2*coeffraf))
+         ENDIF
+      ENDIF
+            
+      ypos = s_child  
+C
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1) 
+     &      *ds_child - s_parent)/ds_parent)  
+C
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent       
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)        
+C     
+C
+      
+!CDIR NOVECTOR
+      Do i=1,coeffraf
+        tabdiff2(i)=(real(i)-0.5)*invcoeffraf
+      EndDo
+
+      a = invcoeffraf**2 
+      tabdiff3(1) = (1./3.)*a
+      a=2.*a
+!CDIR NOVECTOR
+      Do i=2,coeffraf
+        tabdiff3(i) = tabdiff3(i-1)+(real(i)-1)*a
+      EndDo
+C
+      if( locind_parent_last+2 <= np ) then
+           nmax = locind_parent_last+2    
+      else if( locind_parent_last+1 <= np ) then
+           nmax = locind_parent_last+1
+      else
+           nmax = locind_parent_last 
+      endif     
+C      
+      if(locind_parent_left-1 >= 1) then
+          nmin = locind_parent_left-1
+      else 
+          nmin = locind_parent_left
+      endif    
+C 
+C
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+      Do i = nmin,nmax
+         slope(i) = x(i) - x(i-1)
+      Enddo
+
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+      Do i = nmin+1,nmax-1
+         xl(i)= 0.5*(x(i-1)+x(i))
+     &      -0.08333333333333*(slope(i+1)-slope(i-1)) 
+      Enddo
+C
+C apply parabolic monotonicity
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+       Do i = locind_parent_left,locind_parent_last
+          delta(i) = xl(i+1) - xl(i)
+          a6(i) = 6.*x(i)-3.*(xl(i) +xl(i+1))
+C
+       End do   
+C
+        diffmod = 0
+       IF (mod(coeffraf,2) == 0) diffmod = 1
+C
+        ipos = i1
+C               
+        Do iparent = locind_parent_left,locind_parent_last       
+             pos=1
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+C
+               tabtest4(jj) = xl(iparent)   
+     &             + tabdiff2(pos) *  (delta(iparent)+a6(iparent))
+     &             - tabdiff3(pos) *  a6(iparent)
+               pos = pos+1 
+             End do 
+             ipos = ipos + coeffraf
+C
+        End do
+C
+C
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+        y(1:nc)=tabtest4(1:nc)
+        
+      Return
+      End Subroutine ppm1d
+      
+
+      Subroutine ppm1dprecompute2d(np2,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to compute 2D coefficients and index for a 1D interpolation
+CCC   using piecewise parabolic method  
+CC    Method: 
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np2,np,nc,dir
+C      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer, Dimension(:,:), Allocatable :: indparent_tmp
+      Integer, Dimension(:,:), Allocatable :: indchild_tmp
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,a
+C      
+      Real :: xrmin,xrmax,am3,s2,s1
+      Real, Dimension(np) :: xl,delta,a6,slope
+      INTEGER :: diffmod
+      REAL :: invcoeffraf
+C      
+      coeffraf = nint(ds_parent/ds_child)
+C
+      invcoeffraf = ds_child/ds_parent
+C 
+
+      if (.not.allocated(indparentppm)) then
+      allocate(
+     & indparentppm(np2*nc,3),
+     & indchildppm(np2*nc,3)
+     &        )
+      else
+      if (size(indparentppm,1)<np2*nc) then
+      allocate(
+     &  indparent_tmp(size(indparentppm,1),size(indparentppm,2)),
+     &  indchild_tmp(size(indparentppm,1),size(indparentppm,2)))
+      indparent_tmp = indparentppm 
+      indchild_tmp  = indchildppm 
+      deallocate(indparentppm,indchildppm)
+      allocate(
+     &indparentppm(np2*nc,3),
+     &indchildppm(np2*nc,3)
+     &        )
+      indparentppm(1:size(indparent_tmp,1),1:size(indparent_tmp,2))
+     & = indparent_tmp
+      indchildppm(1:size(indparent_tmp,1),1:size(indparent_tmp,2))
+     & = indchild_tmp
+      deallocate(indparent_tmp,indchild_tmp)
+      endif
+      endif
+
+      if (.not.allocated(indparentppm_1d)) then
+      allocate(indparentppm_1d(-2*coeffraf:nc+2*coeffraf),
+     &         indchildppm_1d(-2*coeffraf:nc+2*coeffraf))
+      else
+      if (size(indparentppm_1d)<nc+4*coeffraf+1) then
+      deallocate(indparentppm_1d,indchildppm_1d)
+      allocate(indparentppm_1d(-2*coeffraf:nc+2*coeffraf),
+     &         indchildppm_1d(-2*coeffraf:nc+2*coeffraf))
+      endif
+      endif
+
+
+      ypos = s_child
+C
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1)
+     &      *ds_child - s_parent)/ds_parent)
+C
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)
+C     
+C
+
+      Do i=1,coeffraf
+        tabdiff2(i)=(real(i)-0.5)*invcoeffraf
+      EndDo
+
+      a = invcoeffraf**2
+      tabdiff3(1) = (1./3.)*a
+      a=2.*a
+!CDIR ALTCODE
+      Do i=2,coeffraf
+        tabdiff3(i) = tabdiff3(i-1)+(real(i)-1)*a
+      EndDo
+
+!CDIR ALTCODE
+      Do i=1,coeffraf
+      tabppm(1,i,dir) = 0.08333333333333*
+     &              (-1.+4*tabdiff2(i)-3*tabdiff3(i))
+      tabppm(2,i,dir) = 0.08333333333333*
+     &              (7.-26.*tabdiff2(i)+18.*tabdiff3(i))
+      tabppm(3,i,dir) = 0.08333333333333*
+     &              (7.+30*tabdiff2(i)-30*tabdiff3(i))
+      tabppm(4,i,dir) = 0.08333333333333*
+     &              (-1.-10.*tabdiff2(i)+18.*tabdiff3(i))
+      tabppm(5,i,dir) = 0.08333333333333*
+     &              (2*tabdiff2(i)-3*tabdiff3(i))                   
+      End Do
+C 
+C
+        diffmod = 0
+       IF (mod(coeffraf,2) == 0) diffmod = 1
+C
+        ipos = i1
+C               
+        Do iparent = locind_parent_left,locind_parent_last
+             pos=1
+!CDIR ALTCODE
+             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+         indparentppm_1d(jj) = iparent-2
+         indchildppm_1d(jj) = pos
+               pos = pos+1
+             End do
+             ipos = ipos + coeffraf
+C
+        End do
+     
+       Do i=1,np2
+
+       indparentppm(1+(i-1)*nc:i*nc,dir) = 
+     &             indparentppm_1d(1:nc) + (i-1)*np
+       indchildppm (1+(i-1)*nc:i*nc,dir) = 
+     &             indchildppm_1d (1:nc) 
+
+       End do
+
+      Return
+      End Subroutine ppm1dprecompute2d
+
+
+      Subroutine ppm1dprecompute(np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to compute coefficient and index for  a 1D interpolation 
+CCC   using piecewise parabolic method  
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc
+C      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,a
+C      
+      Real :: xrmin,xrmax,am3,s2,s1  
+      Real, Dimension(np) :: xl,delta,a6,slope
+C      Real, Dimension(:),Allocatable  :: diff,diff2,diff3    
+      INTEGER :: diffmod
+      REAL :: invcoeffraf
+C      
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+          return
+      End If
+      invcoeffraf = ds_child/ds_parent
+C 
+      
+      if (.not.allocated(indparentppm)) then
+      allocate(indparentppm(-2*coeffraf:nc+2*coeffraf,1),
+     &         indchildppm(-2*coeffraf:nc+2*coeffraf,1))
+      else
+      if (size(indparentppm,1)<nc+4*coeffraf+1) then
+      deallocate(indparentppm,indchildppm)
+      allocate(indparentppm(-2*coeffraf:nc+2*coeffraf,1),
+     &         indchildppm(-2*coeffraf:nc+2*coeffraf,1))
+      endif
+      endif
+            
+      ypos = s_child  
+C
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1) 
+     &      *ds_child - s_parent)/ds_parent)  
+C
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent       
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)        
+C     
+C
+      
+      Do i=1,coeffraf
+        tabdiff2(i)=(real(i)-0.5)*invcoeffraf
+      EndDo
+
+      a = invcoeffraf**2 
+      tabdiff3(1) = (1./3.)*a
+      a=2.*a
+!CDIR ALTCODE
+!!!CDIR SHORTLOOP
+      Do i=2,coeffraf
+        tabdiff3(i) = tabdiff3(i-1)+(real(i)-1)*a
+      EndDo
+      
+!CDIR ALTCODE
+!!!CDIR SHORTLOOP
+      Do i=1,coeffraf
+      tabppm(1,i,1) = 0.08333333333333*(-1.+4*tabdiff2(i)-3*tabdiff3(i))
+      tabppm(2,i,1) = 0.08333333333333*
+     &              (7.-26.*tabdiff2(i)+18.*tabdiff3(i))
+      tabppm(3,i,1) =0.08333333333333*(7.+30*tabdiff2(i)-30*tabdiff3(i))
+      tabppm(4,i,1) = 0.08333333333333*
+     &              (-1.-10.*tabdiff2(i)+18.*tabdiff3(i))     
+      tabppm(5,i,1) = 0.08333333333333*(2*tabdiff2(i)-3*tabdiff3(i)) 
+      End Do   
+C 
+C
+        diffmod = 0
+       IF (mod(coeffraf,2) == 0) diffmod = 1
+C
+        ipos = i1
+C               
+        Do iparent = locind_parent_left,locind_parent_last       
+             pos=1
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+         indparentppm(jj,1) = iparent-2
+         indchildppm(jj,1) = pos
+               pos = pos+1 
+             End do 
+             ipos = ipos + coeffraf
+C
+        End do
+        
+      Return
+      End Subroutine ppm1dprecompute
+      
+      Subroutine ppm1daftercompute(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child,dir) 
+C
+CCC   Description:
+CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints
+CCC   using piecewise parabolic method  
+CCC   on a child grid (vector y) from its parent grid (vector x).
+CC    Method: Use precomputed coefficient and index
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc,dir
+      Real, INTENT(IN),Dimension(np) :: x      
+      Real, INTENT(OUT),Dimension(nc) :: y
+C      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,a
+C      
+      Real :: xrmin,xrmax,am3,s2,s1  
+      Real, Dimension(np) :: xl,delta,a6,slope
+      INTEGER :: diffmod
+C      
+C
+      do i=1,nc
+      y(i)=tabppm(1,indchildppm(i,dir),dir)*x(indparentppm(i,dir))+
+     &        tabppm(2,indchildppm(i,dir),dir)*x(indparentppm(i,dir)+1)+
+     &        tabppm(3,indchildppm(i,dir),dir)*x(indparentppm(i,dir)+2)+
+     &        tabppm(4,indchildppm(i,dir),dir)*x(indparentppm(i,dir)+3)+
+     &        tabppm(5,indchildppm(i,dir),dir)*x(indparentppm(i,dir)+4)
+      enddo
+        
+      Return
+      End Subroutine ppm1daftercompute            
+      
+C     **************************************************************************  
+CCC   Subroutine weno1d
+C     ************************************************************************** 
+C 
+      Subroutine weno1dnew(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints
+CCC   using piecewise parabolic method  
+CCC   on a child grid (vector y) from its parent grid (vector x).
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc
+      Real, Dimension(np) :: x
+      Real, Dimension(nc) :: y
+      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,cavg,a,b
+C      
+      Real :: xrmin,xrmax,am3,s2,s1
+      Real, Dimension(np) :: xr,xl,delta,a6,slope,slope2,smooth
+      Real, Dimension(:),Allocatable  :: diff,diff2,diff3
+      INTEGER :: diffmod
+      REAL :: invcoeffraf
+      integer :: s,l,k
+      integer :: etan, etap
+      real :: delta0, delta1, delta2
+      real :: epsilon
+      parameter (epsilon = 1.D-8)
+      real, dimension(:,:), allocatable :: ak, ck
+C      
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+          return
+      End If
+      invcoeffraf = ds_child/ds_parent
+      Allocate(ak(0:1,coeffraf))
+      Allocate(ck(0:1,coeffraf))
+            
+C      
+      Allocate(ytemp(-2*coeffraf:nc+2*coeffraf))
+      ypos = s_child
+C
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1)
+     &      *ds_child - s_parent)/ds_parent)
+C
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)
+C     
+      Allocate( diff(coeffraf),diff2(coeffraf),diff3(coeffraf) )
+C      
+      diff(1)=0.5*invcoeffraf
+      do i=2,coeffraf
+         diff(i) = diff(i-1)+invcoeffraf
+      enddo
+      
+      ak = 0.
+      ck = 0.
+      
+      do i=1,coeffraf
+         do k=0,1
+         do s=0,2
+         do l=0,2
+           if (l /= s) then
+            ak(k,i) = ak(k,i)+(diff(i)-(k-l+1.))
+           endif
+         enddo
+         enddo
+         enddo
+               
+         etap = 0
+         etan = 0
+         do k=0,1
+          if (ak(k,i) > 0) then
+            etap = etap+1
+          else if (ak(k,i) < 0) then
+            etan = etan + 1
+          endif
+         enddo
+               
+         do k=0,1
+           if (ak(k,i) == 0) then
+            Ck(k,i) = 1.
+           else if (ak(k,i) > 0) then
+            Ck(k,i) = 1./(etap * ak(k,i))
+           else
+            Ck(k,i) = -1./(etan * ak(k,i))
+           endif
+         enddo
+      enddo
+                     
+C      
+      a = 0.
+      b = invcoeffraf
+      Do i=1,coeffraf
+         diff2(i) = 0.5*(b*b - a*a)  
+         diff3(i) = (1./3.)*(b*b*b - a*a*a)
+         a = a + invcoeffraf
+         b = b + invcoeffraf
+      End do
+C
+      if( locind_parent_last+2 <= np ) then
+           nmax = locind_parent_last+2    
+      elseif( locind_parent_last+1 <= np ) then
+           nmax = locind_parent_last+1
+      else
+           nmax = locind_parent_last 
+      endif     
+C      
+      if(locind_parent_left-2 >= 1) then
+          nmin = locind_parent_left-2
+      elseif(locind_parent_left-1 >= 1) then
+          nmin = locind_parent_left-1
+      else 
+          nmin = locind_parent_left
+      endif    
+C 
+      Do i = nmin+1,nmax
+         slope(i) = (x(i) - x(i-1))
+      Enddo 
+      DO i=nmin+2,nmax
+        smooth(i) = 0.5*(slope(i)**2+slope(i-1)**2)
+     &       +(slope(i)-slope(i-1))**2
+      enddo
+C
+        diffmod = 0
+        IF (mod(coeffraf,2) == 0) diffmod = 1           
+C
+        ipos = i1
+C               
+        Do iparent = locind_parent_left,locind_parent_last       
+             pos=1
+             
+            delta0=1./(epsilon+smooth(iparent  ))**3
+            delta1=1./(epsilon+smooth(iparent+1))**3
+            delta2=1./(epsilon+smooth(iparent+2))**3   
+                      
+             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+C
+               pos = pos+1 
+             End do 
+             ipos = ipos + coeffraf
+C
+        End do     
+C
+C
+        y(1:nc)=ytemp(1:nc)                                 
+        deallocate(ytemp)                
+        deallocate(diff, diff2, diff3)
+        
+        deallocate(ak,ck)
+        
+      Return
+      End Subroutine weno1dnew
+      
+C     **************************************************************************  
+CCC   Subroutine weno1d
+C     ************************************************************************** 
+C 
+      Subroutine weno1d(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints
+CCC   using piecewise parabolic method  
+CCC   on a child grid (vector y) from its parent grid (vector x).
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc
+      Real, Dimension(np) :: x
+      Real, Dimension(nc) :: y
+      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: iparent,ipos,pos,nmin,nmax
+      Real    :: ypos
+      integer :: i1,jj
+      Real :: xpmin,cavg,a,b
+C      
+      Real :: xrmin,xrmax,am3,s2,s1
+      Real, Dimension(np) :: xr,xl,delta,a6,slope,slope2
+      Real, Dimension(:),Allocatable  :: diff,diff2,diff3
+      INTEGER :: diffmod
+      REAL :: invcoeffraf
+      integer :: s,l,k
+      integer :: etan, etap
+      real :: delta0, delta1,sumdelta
+      real :: epsilon
+      parameter (epsilon = 1.D-8)
+C      
+      coeffraf = nint(ds_parent/ds_child)
+C
+      If (coeffraf == 1) Then
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+          return
+      End If
+      invcoeffraf = ds_child/ds_parent
+            
+C      
+      Allocate(ytemp(-2*coeffraf:nc+2*coeffraf))
+      ypos = s_child
+C
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent)
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1)
+     &      *ds_child - s_parent)/ds_parent)
+C
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)
+C     
+      Allocate( diff(coeffraf))
+C      
+      diff(1)=0.5*invcoeffraf
+      do i=2,coeffraf
+         diff(i) = diff(i-1)+invcoeffraf
+      enddo
+C
+      if( locind_parent_last+2 <= np ) then
+           nmax = locind_parent_last+2   
+      else if( locind_parent_last+1 <= np ) then
+           nmax = locind_parent_last+1
+      else
+           nmax = locind_parent_last 
+      endif     
+C      
+      if(locind_parent_left-1 >= 1) then
+          nmin = locind_parent_left-1
+      else 
+          nmin = locind_parent_left
+      endif    
+C 
+      Do i = nmin+1,nmax
+         slope(i) = (x(i) - x(i-1))
+      Enddo 
+C
+        diffmod = 0
+        IF (mod(coeffraf,2) == 0) diffmod = 1           
+C
+        ipos = i1
+C               
+        Do iparent = locind_parent_left,locind_parent_last       
+             pos=1
+            delta0=1./(epsilon+slope(iparent  )**2)**2
+            delta1=1./(epsilon+slope(iparent+1)**2)**2
+            sumdelta = 1./(delta0+delta1)             
+             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+C                              
+          ytemp(jj) = x(iparent)+(diff(pos)-0.5)*(
+     &                delta0*slope(iparent)+
+     &                delta1*slope(iparent+1))*sumdelta
+               pos = pos+1 
+             End do 
+             ipos = ipos + coeffraf
+C
+        End do     
+C
+C
+        y(1:nc)=ytemp(1:nc)                                 
+        deallocate(ytemp)                
+        deallocate(diff)
+        
+      Return
+      End Subroutine weno1d
+                 
+C                              
+C     **************************************************************************  
+CCC   Subroutine eno1d
+C     ************************************************************************** 
+C 
+      Subroutine eno1d(x,y,np,nc,
+     &                    s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   ---- p 163-164 Computational gasdynamics ----
+CCC   Subroutine to do a 1D interpolation 
+CCC   using piecewise polynomial ENO reconstruction technique  
+CCC   on a child grid (vector y) from its parent grid (vector x).
+CC    Method:
+C
+C     Declarations:
+C
+      Implicit none
+C        
+C     Arguments
+      Integer             :: np,nc      
+      Real, Dimension(np) :: x      
+      Real, Dimension(nc) :: y
+      Real, Dimension(:),Allocatable :: ytemp
+      Real                :: s_parent,s_child,ds_parent,ds_child
+C
+C     Local scalars
+      Integer :: i,coeffraf,locind_parent_left,locind_parent_last
+      Integer :: ipos,pos
+      Real    :: ypos,xi
+      integer :: i1,jj
+      Real :: xpmin,cavg
+C 
+      Real, Dimension(3,np) :: dd,c
+      Integer :: left
+C           
+      Real, DImension(1:np+1) :: xhalf
+      Real, Dimension(:,:),Allocatable  :: Xbar 
+      INTEGER :: diffmod     
+C
+      coeffraf = nint(ds_parent/ds_child)
+C      
+      If (coeffraf == 1) Then
+          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent)
+          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1)
+          return
+      End If     
+      
+      diffmod = 0
+      IF (mod(coeffraf,2) == 0) diffmod = 1  
+C      
+      Allocate(ytemp(-2*coeffraf:nc+2*coeffraf))
+      ypos = s_child  
+      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
+      locind_parent_last = 1 +
+     &      agrif_ceiling((ypos +(nc - 1) *ds_child - 
+     &      s_parent)/ds_parent)       
+      xpmin = s_parent + (locind_parent_left-1)*ds_parent      
+      i1 = 1+agrif_int((xpmin-s_child)/ds_child)           
+C      
+      xhalf(np+1) = np + 0.5
+      Do i = 1,np
+          xhalf(i) = i - 0.5
+      Enddo
+C
+C compute divided differences
+C
+      dd(1,1:np) = x(1:np)
+      dd(2,1:np-1) = 0.5*( dd(1,2:np) - dd(1,1:np-1) )
+      dd(3,1:np-2) = (1./3.)*( dd(2,2:np-1) - dd(2,1:np-2) )
+C
+      Allocate( Xbar( coeffraf,2 ) )
+      xi = 0.5
+      Do i = 1,coeffraf
+        Xbar(i,1) = (i-1)*ds_child/ds_parent - xi
+        Xbar(i,2) = i*ds_child/ds_parent - xi
+      Enddo
+C
+      ipos = i1
+C           
+      DO i = locind_parent_left,locind_parent_last           
+         left = i           
+         do jj = 2,3
+             If(abs(dd(jj,left)) .gt. abs(dd(jj,left-1)))
+     &               left = left-1            
+         enddo
+C           
+C  convert to Taylor series form
+C
+         Call Taylor(i,xhalf(left:left+2),dd(1:3,left),c(1:3,i))
+      ENDDO     
+C
+C evaluate the reconstruction on each cell
+C
+       DO i = locind_parent_left,locind_parent_last  
+C
+         cavg = 0.
+         pos = 1.            
+C         
+         Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2
+           ytemp(jj) =(c(1,i)*(Xbar(pos,2)-Xbar(pos,1))
+     &                +c(2,i)*(Xbar(pos,2)*Xbar(pos,2)-
+     &                         Xbar(pos,1)*Xbar(pos,1))
+     &                +c(3,i)*(Xbar(pos,2)*Xbar(pos,2)*Xbar(pos,2)-
+     &                         Xbar(pos,1)*Xbar(pos,1)*Xbar(pos,1)))
+     &                         *coeffraf
+           cavg = cavg + ytemp(jj)
+           pos = pos+1
+         Enddo                
+         ipos = ipos + coeffraf                 
+      ENDDO
+C
+      y(1:nc)=ytemp(1:nc)                                            
+      deallocate(ytemp,Xbar)                 
+C      
+      Return       
+      End Subroutine eno1d
+C 
+C      
+C     **************************************************************************  
+CCC   Subroutine taylor
+C     ************************************************************************** 
+C       
+      subroutine taylor(ind,xhalf,dd,c)      
+C      
+      Integer :: ind
+      real,dimension(3) :: dd,c     
+      real,dimension(0:3,0:3) :: d 
+      real,dimension(3) :: xhalf    
+      integer ::i,j
+C      
+C
+      d(0,0:3)=1.
+      do i = 1,3
+         d(i,0)=(ind-xhalf(i))*d(i-1,0)
+      enddo  
+C      
+      do i = 1,3
+         do j = 1,3-i
+           d(i,j) = d(i,j-1) + (ind-xhalf(i+j))*d(i-1,j)
+         enddo
+      enddo
+C         
+      do j = 1,3        
+         c(j) = 0.
+         do i=0,3-j
+            c(j) = c(j) + d(i,j)*dd(i+j)         
+         enddo
+      enddo
+C      
+      end subroutine taylor    
+      
+      
+      REAL FUNCTION vanleer(tab)
+      REAL, DIMENSION(3) :: tab
+       real res1
+       real p1,p2,p3
+       
+       p1=(tab(3)-tab(1))/2.
+       p2=2.*(tab(2)-tab(1))
+       p3=2.*(tab(3)-tab(2))
+       
+       if ((p1>0.).AND.(p2>0.).AND.(p3>0)) then
+          res1=minval((/p1,p2,p3/))
+       elseif ((p1<0.).AND.(p2<0.).AND.(p3<0)) then
+          res1=maxval((/p1,p2,p3/))
+       else
+          res1=0.
+       endif
+          
+          vanleer = res1   
+      
+      
+      END FUNCTION vanleer 
+
+C      
+      End Module Agrif_Interpbasic
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modlinktomodel.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modlinktomodel.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modlinktomodel.F	(revision 1844)
@@ -0,0 +1,174 @@
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place -  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+      Module Agrif_link
+C
+CCC   Description:
+CCC   This module is used to link AGRIF files to the model
+C
+C     Modules used: 
+C
+c        external Agrif_InitValues
+c        external Agrif_InitWorkspace
+c        external Agrif_detect
+C
+        external Agrif_probdim_modtype_def
+        external Agrif_clustering_def
+        external Agrif_comm_def
+C     Interface                       
+      Interface
+         Subroutine Agrif_Set_numberofcells(Agrif_Gr)
+         Use Agrif_Types, Only : Agrif_grid
+         TYPE(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid  
+         End Subroutine Agrif_Set_numberofcells
+      End interface
+      Interface
+         Subroutine Agrif_Get_numberofcells(Agrif_Gr)
+         Use Agrif_Types, Only : Agrif_grid
+         TYPE(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid  
+         End Subroutine Agrif_Get_numberofcells
+      End interface
+      Interface
+         Subroutine Agrif_Allocationcalls(Agrif_Gr)
+         Use Agrif_Types, Only : Agrif_grid
+         TYPE(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid  
+         End Subroutine Agrif_Allocationcalls
+      End interface
+C   
+      End Module Agrif_link
+C     **************************************************************************
+CCC   Function Agrif_parent
+C        modify by conv. To use : un_parent = Agrif_Parent(un)
+C     **************************************************************************
+CCC   Function Agrif_Get_Coarse_Grid
+C        modify by conv. To use : un_Mygrid = Agrif_Get_Coarse_grid(un)
+C     **************************************************************************
+CCC   Function Agrif_Rhox
+C        modify by conv. To use : var = Agrif_Rhox()
+C                    REAL(Agrif_Curgrid % spaceref(1))
+C     **************************************************************************
+CCC   Function Agrif_Parent_Rhox
+C        modify by conv. To use : var = Agrif_Parent_Rhox()
+C                    REAL(Agrif_Curgrid % parent % spaceref(1))
+C     **************************************************************************
+CCC   Function Agrif_Irhox
+C        modify by conv. To use : var = Agrif_Parent_IRhox()
+C                    Agrif_Curgrid % spaceref(1)
+C     **************************************************************************
+CCC   Function Agrif_Parent_Irhox
+C        modify by conv. To use : var = Agrif_Parent_IRhox()
+C                    Agrif_Curgrid % parent % spaceref(1)
+C     **************************************************************************
+CCC   Function Agrif_Rhoy
+C        modify by conv. To use : var = Agrif_Rhoy()
+C                    REAL(Agrif_Curgrid % spaceref(2))
+C     **************************************************************************
+CCC   Function Agrif_Parent_Rhoy
+C        modify by conv. To use : var = Agrif_Parent_Rhoy()
+C                    REAL(Agrif_Curgrid % parent % spaceref(2))
+C     **************************************************************************
+CCC   Function Agrif_Irhoy
+C        modify by conv. To use : var = Agrif_Parent_IRhoy()
+C                    Agrif_Curgrid % spaceref(2)
+C     **************************************************************************
+CCC   Function Agrif_Parent_Irhoy
+C        modify by conv. To use : var = Agrif_Parent_IRhoy()
+C                    Agrif_Curgrid % parent % spaceref(2)
+C     **************************************************************************
+CCC   Function Agrif_Rhoz
+C        modify by conv. To use : var = Agrif_Rhoz()
+C                    REAL(Agrif_Curgrid % spaceref(3))
+C     **************************************************************************
+CCC   Function Agrif_Parent_Rhoz
+C        modify by conv. To use : var = Agrif_Parent_Rhoz()
+C                    REAL(Agrif_Curgrid % parent % spaceref(3))
+C     **************************************************************************
+CCC   Function Agrif_Irhoz
+C        modify by conv. To use : var = Agrif_Parent_IRhoz()
+C                    Agrif_Curgrid % spaceref(3)
+C     **************************************************************************
+CCC   Function Agrif_Parent_Irhoz
+C        modify by conv. To use : var = Agrif_Parent_IRhoz()
+C                    Agrif_Curgrid % parent % spaceref(3)
+C     **************************************************************************
+CCC   Function Agrif_NearCommonBorderX
+C        modify by conv. To use : var = Agrif_NearCommonBorderX()
+C                       AGRIF_CURGRID % NearRootBorder(1)
+C     **************************************************************************
+CCC   Function Agrif_NearCommonBorderY
+C        modify by conv. To use : var = Agrif_NearCommonBorderY()
+C                       AGRIF_CURGRID % NearRootBorder(2)
+C     **************************************************************************
+CCC   Function Agrif_NearCommonBorderZ
+C        modify by conv. To use : var = Agrif_NearCommonBorderZ()
+C                       AGRIF_CURGRID % NearRootBorder(3)
+C     **************************************************************************
+CCC   Function Agrif_DistantCommonBorderX
+C        modify by conv. To use : var = Agrif_DistantCommonBorderX()
+C                       AGRIF_CURGRID % DistantRootBorder(1)
+C     **************************************************************************
+CCC   Function Agrif_DistantCommonBorderY
+C        modify by conv. To use : var = Agrif_DistantCommonBorderY()
+C                       AGRIF_CURGRID % DistantRootBorder(2)
+C     **************************************************************************
+CCC   Function Agrif_DistantCommonBorderZ
+C        modify by conv. To use : var = Agrif_DistantCommonBorderZ()
+C                       AGRIF_CURGRID % DistantRootBorder(3)
+C     **************************************************************************
+CCC   Function Agrif_Nb_Step
+C        modify by conv. To use : var = Agrif_Nb_Step()
+C                          AGRIF_CURGRID % ngridstep
+C     **************************************************************************
+CCC   Function Agrif_Nb_Fine_Grids
+C        modify by conv. To use : var = Agrif_Nb_Fine_Grids()
+C                         Agrif_nbfixedgrids 
+C     **************************************************************************
+CCC   Function Agrif_Ix
+C        modify by conv. To use : var = Agrif_Ix()
+C                         Agrif_CURGRID % ix(1) 
+C     **************************************************************************
+CCC   Function Agrif_Parent_Ix
+C        modify by conv. To use : var = Agrif_Parent_Ix()
+C                        Agrif_CURGRID % parent % ix(1) 
+C     **************************************************************************
+CCC   Function Agrif_Iy
+C        modify by conv. To use : var = Agrif_Iy()
+C                        AGRIF_CURGRID % ix(2) 
+C     **************************************************************************
+CCC   Function Agrif_Parent_Iy
+C        modify by conv. To use : var = Agrif_Parent_Iy()
+C                       Agrif_CURGRID % parent % ix(2) 
+C     **************************************************************************
+CCC   Function Agrif_Iz
+C        modify by conv. To use : var = Agrif_Iz()
+C                      AGRIF_CURGRID % ix(3) 
+C     **************************************************************************
+CCC   Function Agrif_Parent_Iz
+C        modify by conv. To use : var = Agrif_Parent_Iz()
+C                     Agrif_CURGRID % parent % ix(3) 
+C     **************************************************************************
+CCC   Function Agrif_Get_grid_id
+C        modify by conv. To use : var = Agrif_Get_grid_id()
+C                    Agrif_CURGRID % grid_id
+C     **************************************************************************
+CCC   Function Agrif_Get_parent_id
+C        modify by conv. To use : var = Agrif_Get_parent_id()
+C                    Agrif_CURGRID % parent % grid_id
+C     **************************************************************************
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmask.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmask.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmask.F	(revision 1844)
@@ -0,0 +1,688 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place -  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Mask
+C
+      Module Agrif_Mask
+C
+CCC   Description:
+CCC   Module for masks
+C
+C     Modules used: 
+C
+      Use Agrif_Types       
+C
+      IMPLICIT NONE
+C
+      CONTAINS
+C     Define procedures contained in this module
+C
+C     **************************************************************************
+C     Subroutine Agrif_CheckMasknD
+C     **************************************************************************
+C       
+      Subroutine Agrif_CheckMasknD(tempP,parent,pbtab,petab,ppbtab,
+     &               ppetab,noraftab,nbdim)
+C
+CCC   Description:
+CCC   Subroutine called in the procedure Agrif_InterpnD to recalculate the value 
+CCC   of the parent grid variable when this one is equal to Agrif_SpecialValue. 
+C
+C     Declarations:
+C
+       
+C
+C     Arrays arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim) :: pbtab  ! Limits of the parent grid used  
+      INTEGER,DIMENSION(nbdim) :: petab  ! interpolation of the child grid
+      LOGICAL,DIMENSION(nbdim) :: noraftab
+      INTEGER,DIMENSION(nbdim) :: ppbtab,ppetab
+C
+C     Pointer argument
+      TYPE(AGRIF_PVARIABLE) :: tempP  ! Part of the parent grid used for 
+                                      ! the interpolation of the child grid                     
+C     Data TYPE argument                                   
+      TYPE(AGRIF_PVARIABLE) :: parent      ! The parent grid
+C
+C     Local scalar
+      INTEGER                   :: i0,j0,k0,l0,m0,n0
+C      
+C     Local arrays
+C
+C      
+      SELECT CASE (nbdim)
+      CASE (1)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array1(i0)
+     &                        == Agrif_SpecialValue) Then
+            Call CalculNewValTempP((/i0/),
+     &                             tempP,parent,
+     &                             ppbtab,ppetab,
+     &                             noraftab,nbdim)
+         ENDIF
+         enddo
+      CASE (2)
+         do j0 = pbtab(2),petab(2)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array2(i0,j0)
+     &                        == Agrif_SpecialValue) Then
+            Call CalculNewValTempP((/i0,j0/),
+     &                             tempP,parent,
+     &                             ppbtab,ppetab,
+     &                             noraftab,nbdim)
+         ENDIF
+         enddo  
+         enddo
+      CASE (3)
+         do k0 = pbtab(3),petab(3)
+         do j0 = pbtab(2),petab(2)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array3(i0,j0,k0)
+     &                        == Agrif_SpecialValue) Then
+!------CDIR NEXPAND
+            Call CalculNewValTempP3D((/i0,j0,k0/),
+     &      tempP%var%array3(ppbtab(1),ppbtab(2),ppbtab(3)),
+     &      parent%var%array3(ppbtab(1),ppbtab(2),ppbtab(3)),
+     &                           ppbtab,ppetab,
+     &                           noraftab,MaxSearch,Agrif_SpecialValue)
+     
+c            Call CalculNewValTempP((/i0,j0,k0/),
+c     &                             tempP,parent,
+c     &                             ppbtab,ppetab,
+c     &                             noraftab,nbdim)
+          
+         ENDIF
+         enddo
+         enddo  
+         enddo
+      CASE (4)
+         do l0 = pbtab(4),petab(4)
+         do k0 = pbtab(3),petab(3)
+         do j0 = pbtab(2),petab(2)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array4(i0,j0,k0,l0) 
+     &                        == Agrif_SpecialValue) Then
+            Call CalculNewValTempP4D((/i0,j0,k0,l0/),
+     &      tempP%var%array4(ppbtab(1),ppbtab(2),ppbtab(3),ppbtab(4)),
+     &      parent%var%array4(ppbtab(1),ppbtab(2),ppbtab(3),ppbtab(4)),
+     &                           ppbtab,ppetab,
+     &                           noraftab,MaxSearch,Agrif_SpecialValue)
+         ENDIF
+         enddo
+         enddo
+         enddo  
+         enddo
+      CASE (5)
+         do m0 = pbtab(5),petab(5)
+         do l0 = pbtab(4),petab(4)
+         do k0 = pbtab(3),petab(3)
+         do j0 = pbtab(2),petab(2)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array5(i0,j0,k0,l0,m0) 
+     &                       == Agrif_SpecialValue) Then
+            Call CalculNewValTempP((/i0,j0,k0,l0,m0/),
+     &                             tempP,parent,
+     &                             ppbtab,ppetab,
+     &                             noraftab,nbdim)
+         ENDIF
+         enddo
+         enddo
+         enddo  
+         enddo
+         enddo
+      CASE (6)
+         do n0 = pbtab(6),petab(6)
+         do m0 = pbtab(5),petab(5)
+         do l0 = pbtab(4),petab(4)
+         do k0 = pbtab(3),petab(3)
+         do j0 = pbtab(2),petab(2)
+         do i0 = pbtab(1),petab(1)
+         IF (tempP%var%array6(i0,j0,k0,l0,m0,n0) 
+     &                       == Agrif_SpecialValue) Then
+            Call CalculNewValTempP((/i0,j0,k0,l0,m0,n0/),
+     &                             tempP,parent,
+     &                             ppbtab,ppetab,
+     &                             noraftab,nbdim)
+         ENDIF
+         enddo
+         enddo
+         enddo
+         enddo  
+         enddo
+         enddo
+      END SELECT
+C
+C      
+C     
+      End Subroutine Agrif_CheckMasknD
+C
+C
+C     **************************************************************************
+C     Subroutine CalculNewValTempP
+C     **************************************************************************
+C       
+      Subroutine CalculNewValTempP(indic,
+     &               tempP,parent,ppbtab,
+     &               ppetab,noraftab,nbdim)
+C
+CCC   Description:
+CCC   Subroutine called in the procedure Agrif_InterpnD to recalculate the value 
+CCC   of the parent grid variable when this one is equal to Agrif_SpecialValue. 
+C
+C     Declarations:
+C
+       
+C
+C     Arrays arguments      
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim) :: indic
+      LOGICAL,DIMENSION(nbdim) :: noraftab
+      INTEGER,DIMENSION(nbdim) :: ppbtab,ppetab
+C
+C     Pointer argument
+      TYPE(AGRIF_PVARIABLE) :: tempP  ! Part of the parent grid used for 
+                                      ! the interpolation of the child grid                     
+C     Data TYPE argument                                   
+      TYPE(AGRIF_PVARIABLE) :: parent      ! The parent grid
+C
+C     Local scalar
+      INTEGER                  :: i,ii,iii,jj,kk,ll,mm,nn 
+      INTEGER,DIMENSION(nbdim) :: imin,imax,idecal
+      INTEGER                  :: Nbvals
+      REAL                     :: Res
+      REAL                     :: ValParent
+      INTEGER                  :: ValMax
+      LOGICAL                  :: firsttest
+C      
+C     Local arrays      
+C
+      ValMax = 1
+      do iii = 1 , nbdim
+         IF (.NOT.noraftab(iii)) THEN
+         ValMax = max(ValMax,ppetab(iii)-indic(iii))
+         ValMax = max(ValMax,indic(iii)-ppbtab(iii))
+         ENDIF
+      enddo
+C
+      Valmax = min(Valmax,MaxSearch)
+C
+!CDIR NOVECTOR
+      imin = indic
+!CDIR NOVECTOR
+      imax = indic
+C
+         i = 1
+         firsttest = .TRUE.
+C
+         do While(i <= ValMax)
+C
+         IF ((i == 1).AND.(firsttest)) i = Valmax
+
+            do iii = 1 , nbdim
+               if (.NOT.noraftab(iii)) then
+                  imin(iii) = max(indic(iii) - i,ppbtab(iii))
+                  imax(iii) = min(indic(iii) + i,ppetab(iii))
+                  if (firsttest) then               
+                  if (indic(iii).GT.ppbtab(iii)) then
+
+!CDIR NOVECTOR
+                     idecal = indic
+                     idecal(iii) = idecal(iii)-1
+                     SELECT CASE(nbdim)
+                     CASE (1)
+                        if (tempP%var%array1(idecal(1)
+     &                            ) == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif                     
+                     CASE (2)
+                        if (tempP%var%array2(idecal(1),
+     &            idecal(2)) == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif
+                     CASE (3)
+                        if (tempP%var%array3(idecal(1),
+     &            idecal(2),idecal(3)) 
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif  
+                     CASE (4)
+                        if (tempP%var%array4(idecal(1),
+     &            idecal(2),idecal(3),idecal(4)) 
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif     
+                     CASE (5)
+                        if (tempP%var%array5(idecal(1),
+     &            idecal(2),idecal(3),idecal(4),idecal(5)) 
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif  
+                     CASE (6)
+                        if (tempP%var%array6(idecal(1),
+     &            idecal(2),idecal(3),idecal(4),idecal(5),idecal(6)) 
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif                                                                                           
+                     END SELECT
+                  endif
+                  endif
+               endif            
+            enddo
+C
+            Res = 0.
+            Nbvals = 0
+C
+            SELECT CASE(nbdim)
+            CASE (1)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array1(ii)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+               enddo
+C
+            CASE (2)
+               do jj = imin(2),imax(2)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array2(ii,jj)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+               enddo  
+               enddo
+               
+            CASE (3)
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array3(ii,jj,kk)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                        enddo
+                  enddo  
+               enddo
+
+            CASE (4)
+               do ll = imin(4),imax(4)
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array4(ii,jj,kk,ll)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                              enddo
+                        enddo
+                  enddo  
+               enddo
+
+            CASE (5)
+               do mm = imin(5),imax(5)
+               do ll = imin(4),imax(4)
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array5(ii,jj,kk,ll,mm)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                                    enddo
+                              enddo
+                        enddo
+                  enddo  
+               enddo
+
+            CASE (6)
+               do nn = imin(6),imax(6)
+               do mm = imin(5),imax(5)
+               do ll = imin(4),imax(4)
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR ALTCODE
+!CDIR SHORTLOOP
+               do ii = imin(1),imax(1)
+                    ValParent = parent%var%array6(ii,jj,kk,ll,mm,nn)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                                          enddo
+                                    enddo
+                              enddo
+                        enddo
+                  enddo  
+               enddo
+
+            END SELECT
+C
+C
+            
+            if (Nbvals.GT.0) then
+              if (firsttest) then
+                   firsttest = .FALSE.
+                   i=1
+                   cycle
+              endif
+            SELECT CASE(nbdim)
+            CASE (1)              
+              tempP%var%array1(indic(1)) 
+     &           = Res/Nbvals
+            CASE (2)
+              tempP%var%array2(indic(1),
+     &                            indic(2)) = Res/Nbvals
+            CASE (3)
+              tempP%var%array3(indic(1),
+     &                            indic(2),indic(3)) = Res/Nbvals
+            CASE (4)
+              tempP%var%array4(indic(1),
+     &                            indic(2),indic(3),indic(4))
+     &                = Res/Nbvals
+            CASE (5)
+              tempP%var%array5(indic(1),
+     &                            indic(2),indic(3),indic(4),
+     &                   indic(5)) = Res/Nbvals
+            CASE (6)
+              tempP%var%array6(indic(1),
+     &                            indic(2),indic(3),indic(4),
+     &                           indic(5),indic(6)) = Res/Nbvals
+            END SELECT
+              exit
+            else
+               if (firsttest) exit
+               i = i + 1                      
+            endif
+          enddo            
+C     
+      End Subroutine CalculNewValTempP
+C
+C
+      End Module Agrif_Mask     
+      
+      Subroutine CalculNewValTempP3D(indic,
+     &               tempP,parent,ppbtab,
+     &               ppetab,noraftab,MaxSearch,Agrif_SpecialValue)
+C
+CCC   Description:
+CCC   Subroutine called in the procedure Agrif_InterpnD to recalculate the value 
+CCC   of the parent grid variable when this one is equal to Agrif_SpecialValue. 
+C
+C     Declarations:
+C
+       
+C
+C     Arrays arguments      
+      INTEGER, PARAMETER :: nbdim = 3
+      INTEGER,DIMENSION(nbdim) :: indic
+      LOGICAL,DIMENSION(nbdim) :: noraftab
+      INTEGER,DIMENSION(nbdim) :: ppbtab,ppetab
+      REAL :: Agrif_SpecialValue
+C
+C     Pointer argument
+      REAL,DIMENSION(ppbtab(1):ppetab(1),ppbtab(2):ppetab(2),
+     &    ppbtab(3):ppetab(3)) :: tempP, parent  ! Part of the parent grid used for 
+                                      ! the interpolation of the child grid                     
+C
+C     Local scalar
+      INTEGER                  :: i,ii,iii,jj,kk,ll,mm,nn 
+      INTEGER,DIMENSION(nbdim) :: imin,imax,idecal
+      INTEGER                  :: Nbvals
+      REAL                     :: Res
+      REAL                     :: ValParent
+      INTEGER                  :: ValMax
+      INTEGER :: MaxSearch
+      LOGICAL :: Existunmasked
+C      
+C     Local arrays      
+C
+      ValMax = 1
+!CDIR NOVECTOR
+      do iii = 1 , nbdim
+         IF (.NOT.noraftab(iii)) THEN
+         ValMax = max(ValMax,ppetab(iii)-indic(iii))
+         ValMax = max(ValMax,indic(iii)-ppbtab(iii))
+         ENDIF
+      enddo
+C
+      Valmax = min(Valmax,MaxSearch)
+C
+!CDIR NOVECTOR
+      imin = indic
+!CDIR NOVECTOR
+      imax = indic
+      
+!CDIR NOVECTOR
+         idecal = indic	 
+C
+         i = Valmax
+
+            do iii = 1 , nbdim
+               if (.NOT.noraftab(iii)) then
+                  imin(iii) = max(indic(iii) - i,ppbtab(iii))
+                  imax(iii) = min(indic(iii) + i,ppetab(iii))
+         
+                  if (indic(iii).GT.ppbtab(iii)) then
+
+                     idecal(iii) = idecal(iii)-1
+
+                        if (tempP(idecal(1),idecal(2),idecal(3)) 
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                        endif
+
+                     idecal(iii) = idecal(iii)+1
+                  endif
+
+               endif            
+            enddo
+C
+            Existunmasked = .FALSE.
+C
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR NOVECTOR
+               do ii = imin(1),imax(1)
+                    if ( parent(ii,jj,kk) .NE. Agrif_SpecialValue) then
+                        Existunmasked = .TRUE.
+                       exit
+                    endif 
+                        enddo
+                  enddo  
+               enddo
+C
+C
+          if (.Not.Existunmasked) return
+C
+         i = 1
+C
+         do While(i <= ValMax)
+C
+
+            do iii = 1 , nbdim
+               if (.NOT.noraftab(iii)) then
+                  imin(iii) = max(indic(iii) - i,ppbtab(iii))
+                  imax(iii) = min(indic(iii) + i,ppetab(iii))
+               endif            
+            enddo
+C
+            Res = 0.
+            Nbvals = 0
+C
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+!CDIR NOVECTOR
+               do ii = imin(1),imax(1)
+                    ValParent = parent(ii,jj,kk)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                        enddo
+                  enddo  
+               enddo
+C
+C
+            
+            if (Nbvals.GT.0) then
+              tempP(indic(1),indic(2),indic(3)) = Res/Nbvals
+              exit
+            else
+               i = i + 1                      
+            endif
+          enddo            
+C     
+      End Subroutine CalculNewValTempP3D        
+
+      Subroutine CalculNewValTempP4D(indic,
+     &               tempP,parent,ppbtab,
+     &               ppetab,noraftab,MaxSearch,Agrif_SpecialValue)
+C
+CCC   Description:
+CCC   Subroutine called in the procedure Agrif_InterpnD to recalculate the value 
+CCC   of the parent grid variable when this one is equal to Agrif_SpecialValue. 
+C
+C     Declarations:
+C
+       
+C
+C     Arrays arguments      
+      INTEGER, PARAMETER :: nbdim = 4
+      INTEGER,DIMENSION(nbdim) :: indic
+      LOGICAL,DIMENSION(nbdim) :: noraftab
+      INTEGER,DIMENSION(nbdim) :: ppbtab,ppetab
+      INTEGER :: MaxSearch      
+      REAL :: Agrif_SpecialValue      
+C
+C     Pointer argument
+      REAL,DIMENSION(ppbtab(1):ppetab(1),ppbtab(2):ppetab(2),
+     &    ppbtab(3):ppetab(3),
+     &    ppbtab(4):ppetab(4)) :: tempP, parent  ! Part of the parent grid used for 
+                                      ! the interpolation of the child grid                     
+C
+C     Local scalar
+      INTEGER                  :: i,ii,iii,jj,kk,ll,mm,nn 
+      INTEGER,DIMENSION(nbdim) :: imin,imax,idecal
+      INTEGER                  :: Nbvals
+      REAL                     :: Res
+      REAL                     :: ValParent
+      INTEGER                  :: ValMax
+      LOGICAL                  :: firsttest
+C      
+C     Local arrays      
+C
+      ValMax = 1
+      do iii = 1 , nbdim
+         IF (.NOT.noraftab(iii)) THEN
+         ValMax = max(ValMax,ppetab(iii)-indic(iii))
+         ValMax = max(ValMax,indic(iii)-ppbtab(iii))
+         ENDIF
+      enddo
+C
+      Valmax = min(Valmax,MaxSearch)
+C
+      imin = indic
+      imax = indic
+C
+         i = 1
+         firsttest = .TRUE.
+         idecal = indic	 
+	 
+C
+         do While(i <= ValMax)
+C
+         IF ((i == 1).AND.(firsttest)) i = Valmax
+
+            do iii = 1 , nbdim
+               if (.NOT.noraftab(iii)) then
+                  imin(iii) = max(indic(iii) - i,ppbtab(iii))
+                  imax(iii) = min(indic(iii) + i,ppetab(iii))
+                  if (firsttest) then               
+                  if (indic(iii).GT.ppbtab(iii)) then
+
+
+                     idecal(iii) = idecal(iii)-1
+		     
+                     if (tempP(idecal(1),idecal(2),idecal(3),idecal(4))
+     &                               == Agrif_SpecialValue) then
+                           imin(iii) = imax(iii)
+                     endif
+		     
+		     idecal(iii) = idecal(iii)+1
+                  endif
+                  endif
+               endif            
+            enddo
+C
+            Res = 0.
+            Nbvals = 0
+C
+               do ll = imin(4),imax(4)
+               do kk = imin(3),imax(3)
+               do jj = imin(2),imax(2)
+               do ii = imin(1),imax(1)
+                    ValParent = parent(ii,jj,kk,ll)
+                    if ( ValParent .NE. Agrif_SpecialValue) then
+                        Res = Res + ValParent
+                        Nbvals = Nbvals + 1
+                    endif 
+                              enddo
+                        enddo
+                  enddo  
+               enddo
+C
+C
+            
+            if (Nbvals.GT.0) then
+              if (firsttest) then
+                   firsttest = .FALSE.
+                   i=1
+                   cycle
+              endif
+	      
+              tempP(indic(1),indic(2),indic(3),indic(4)) = Res/Nbvals
+	    
+              exit
+            else
+               if (firsttest) exit
+               i = i + 1                      
+            endif
+          enddo            
+C     
+      End Subroutine CalculNewValTempP4D        
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmpp.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmpp.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modmpp.F	(revision 1844)
@@ -0,0 +1,1119 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_mpp
+C
+      Module Agrif_mpp
+      Use Agrif_Types
+      Use Agrif_Arrays
+
+      Contains
+#ifdef AGRIF_MPI
+      Subroutine Get_External_Data_first(pttruetab,
+     &   cetruetab,pttruetabwhole,cetruetabwhole,nbdim,memberin,
+     &   memberout,memberoutall1,sendtoproc,recvfromproc,imin,imax,
+     &   imin_recv,imax_recv)
+
+      IMPLICIT NONE
+#include "mpif.h"
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetab,
+     &                                                 cetruetab
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetabwhole,
+     &                                                 cetruetabwhole
+      INTEGER :: k,i,k2
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc, recvfromproc
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1):: imin,imax,
+     &   imin_recv,imax_recv
+      LOGICAL :: memberin, memberout
+      INTEGER :: imintmp, imaxtmp,j,i1
+      INTEGER :: imin1,imax1
+      LOGICAL :: tochange,tochangebis
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetab2,
+     &                                                 cetruetab2
+      LOGICAL :: memberout1(1),memberoutall(0:Agrif_Nbprocs-1)
+      LOGICAL, OPTIONAL :: memberoutall1(0:Agrif_Nbprocs-1)
+      INTEGER :: code
+      
+C pttruetab2 and cetruetab2 are modified arraysin order to always
+C send the most inner points
+
+        
+        IF (present(memberoutall1)) THEN
+        memberoutall = memberoutall1
+        ELSE
+         memberout1(1) = memberout
+
+         CALL MPI_ALLGATHER(memberout1,1,MPI_LOGICAL,memberoutall,
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
+        ENDIF
+         pttruetab2(:,Agrif_Procrank) = pttruetab(:,Agrif_Procrank)
+         cetruetab2(:,Agrif_Procrank) = cetruetab(:,Agrif_Procrank)
+         do k2=0,Agrif_Nbprocs-1
+            do i=1,nbdim
+
+           tochangebis=.TRUE.
+           DO i1=1,nbdim
+            IF (i .NE. i1) THEN
+              IF ((pttruetab(i1,Agrif_Procrank).NE.pttruetab(i1,k2)).OR.
+     &          (cetruetab(i1,Agrif_Procrank).NE.cetruetab(i1,k2))) THEN
+                   tochangebis = .FALSE.
+               EXIT
+              ENDIF
+             ENDIF
+           ENDDO
+
+           IF (tochangebis) THEN
+
+
+          imin1 = max(pttruetab(i,Agrif_Procrank),
+     &                    pttruetab(i,k2))
+          imax1 = min(cetruetab(i,Agrif_Procrank),
+     &                    cetruetab(i,k2))
+
+C Always send the most interior points
+
+           tochange = .false.
+           IF (cetruetab(i,Agrif_Procrank)> cetruetab(i,k2)) THEN
+
+           DO j=imin1,imax1
+             IF ((cetruetab(i,k2)-j) >
+     &             (j-pttruetab(i,Agrif_Procrank))) THEN
+             imintmp = j+1
+             tochange = .TRUE.
+             ELSE
+              EXIT
+             ENDIF
+          ENDDO
+          ENDIF
+
+           if (tochange) then
+C
+              pttruetab2(i,Agrif_Procrank) = imintmp
+C
+          endif
+
+           tochange = .FALSE.
+           imaxtmp=0
+           IF (pttruetab(i,Agrif_Procrank) < pttruetab(i,k2)) THEN
+          DO j=imax1,imin1,-1
+            IF ((j-pttruetab(i,k2)) >
+     &             (cetruetab(i,Agrif_Procrank)-j)) THEN
+             imaxtmp = j-1
+             tochange = .TRUE.
+            ELSE
+             EXIT
+            ENDIF
+          ENDDO
+
+          ENDIF
+
+                    if (tochange) then
+C
+              cetruetab2(i,Agrif_Procrank) = imaxtmp
+C
+          endif
+C
+
+          ENDIF
+           enddo
+         enddo
+
+
+       do k = 0,Agrif_NbProcs-1
+C
+        sendtoproc(k) = .true.
+C
+!CDIR SHORTLOOP
+        do i = 1,nbdim
+C
+          imin(i,k) = max(pttruetab2(i,Agrif_Procrank),
+     &                    pttruetabwhole(i,k))
+          imax(i,k) = min(cetruetab2(i,Agrif_Procrank),
+     &                    cetruetabwhole(i,k))
+C
+          if (imin(i,k) > imax(i,k)) then
+C
+              sendtoproc(k) = .false.
+C
+          endif
+C
+        enddo
+        IF (.NOT.memberoutall(k)) THEN
+           sendtoproc(k) = .FALSE.
+        ENDIF
+C
+      enddo
+      
+      Call Exchangesamelevel_first(sendtoproc,nbdim,imin,imax,
+     &     recvfromproc,imin_recv,imax_recv)
+      
+      End Subroutine Get_External_Data_first
+C
+      Subroutine Get_External_Data(tempC,tempCextend,pttruetab,
+     &   cetruetab,pttruetabwhole,cetruetabwhole,nbdim,memberin,
+     &   memberout,memberoutall1)
+
+      IMPLICIT NONE
+#include "mpif.h"
+      INTEGER :: nbdim
+      TYPE(Agrif_PVariable) :: tempC, tempCextend
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetab,
+     &                                                 cetruetab
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetabwhole,
+     &                                                 cetruetabwhole
+      INTEGER :: k,i,k2
+      LOGICAL :: sendtoproc(0:Agrif_Nbprocs-1)
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: imin,imax
+      LOGICAL :: memberin, memberout
+      INTEGER :: imintmp, imaxtmp,j,i1
+      INTEGER :: imin1,imax1
+      LOGICAL :: tochange,tochangebis
+      INTEGER,DIMENSION(nbdim,0:Agrif_NbProcs-1)    :: pttruetab2,
+     &                                                 cetruetab2
+      LOGICAL :: memberout1(1),memberoutall(0:Agrif_Nbprocs-1)
+      LOGICAL, OPTIONAL :: memberoutall1(0:Agrif_Nbprocs-1)
+      INTEGER :: code
+
+C pttruetab2 and cetruetab2 are modified arraysin order to always
+C send the most inner points
+
+        
+        IF (present(memberoutall1)) THEN
+        memberoutall = memberoutall1
+        ELSE
+         memberout1(1) = memberout
+
+         CALL MPI_ALLGATHER(memberout1,1,MPI_LOGICAL,memberoutall,
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
+        ENDIF
+         pttruetab2(:,Agrif_Procrank) = pttruetab(:,Agrif_Procrank)
+         cetruetab2(:,Agrif_Procrank) = cetruetab(:,Agrif_Procrank)
+         do k2=0,Agrif_Nbprocs-1
+            do i=1,nbdim
+
+           tochangebis=.TRUE.
+           DO i1=1,nbdim
+            IF (i .NE. i1) THEN
+              IF ((pttruetab(i1,Agrif_Procrank).NE.pttruetab(i1,k2)).OR.
+     &          (cetruetab(i1,Agrif_Procrank).NE.cetruetab(i1,k2))) THEN
+                   tochangebis = .FALSE.
+               EXIT
+              ENDIF
+             ENDIF
+           ENDDO
+
+           IF (tochangebis) THEN
+
+
+          imin1 = max(pttruetab(i,Agrif_Procrank),
+     &                    pttruetab(i,k2))
+          imax1 = min(cetruetab(i,Agrif_Procrank),
+     &                    cetruetab(i,k2))
+
+C Always send the most interior points
+
+           tochange = .false.
+           IF (cetruetab(i,Agrif_Procrank)> cetruetab(i,k2)) THEN
+
+           DO j=imin1,imax1
+             IF ((cetruetab(i,k2)-j) >
+     &             (j-pttruetab(i,Agrif_Procrank))) THEN
+             imintmp = j+1
+             tochange = .TRUE.
+             ELSE
+              EXIT
+             ENDIF
+          ENDDO
+          ENDIF
+
+           if (tochange) then
+C
+              pttruetab2(i,Agrif_Procrank) = imintmp
+C
+          endif
+
+           tochange = .FALSE.
+           imaxtmp=0
+           IF (pttruetab(i,Agrif_Procrank) < pttruetab(i,k2)) THEN
+          DO j=imax1,imin1,-1
+            IF ((j-pttruetab(i,k2)) >
+     &             (cetruetab(i,Agrif_Procrank)-j)) THEN
+             imaxtmp = j-1
+             tochange = .TRUE.
+            ELSE
+             EXIT
+            ENDIF
+          ENDDO
+
+          ENDIF
+
+                    if (tochange) then
+C
+              cetruetab2(i,Agrif_Procrank) = imaxtmp
+C
+          endif
+C
+
+          ENDIF
+           enddo
+         enddo
+
+
+       do k = 0,Agrif_NbProcs-1
+C
+        sendtoproc(k) = .true.
+C
+!CDIR SHORTLOOP
+        do i = 1,nbdim
+C
+          imin(i,k) = max(pttruetab2(i,Agrif_Procrank),
+     &                    pttruetabwhole(i,k))
+          imax(i,k) = min(cetruetab2(i,Agrif_Procrank),
+     &                    cetruetabwhole(i,k))
+C
+          if (imin(i,k) > imax(i,k)) then
+C
+              sendtoproc(k) = .false.
+C
+          endif
+C
+        enddo
+        IF (.NOT.memberoutall(k)) THEN
+           sendtoproc(k) = .FALSE.
+        ENDIF
+C
+      enddo
+
+
+c       IF (.NOT.memberin) sendtoproc = .FALSE.
+
+      IF (memberout) THEN
+      Call Agrif_nbdim_allocation(tempCextend%var,
+     &                 pttruetabwhole(:,Agrif_ProcRank),
+     &                 cetruetabwhole(:,Agrif_ProcRank),nbdim)
+      call Agrif_nbdim_Full_VarEQreal(tempCextend%var,0.,nbdim)
+      ENDIF
+
+      IF (sendtoproc(Agrif_ProcRank)) THEN
+           Call Agrif_nbdim_VarEQvar(tempCextend%var,
+     &                               imin(:,Agrif_Procrank),
+     &                               imax(:,Agrif_Procrank),
+     &                               tempC%var,
+     &                               imin(:,Agrif_Procrank),
+     &                               imax(:,Agrif_Procrank),
+     &                               nbdim)
+      ENDIF
+
+      Call Exchangesamelevel(sendtoproc,nbdim,imin,imax,tempC,
+     &     tempCextend)
+
+      End Subroutine Get_External_Data
+
+       Subroutine ExchangeSameLevel(sendtoproc,nbdim,imin,imax,
+     &          tempC,tempCextend)
+      Implicit None
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin,imax
+      INTEGER,DIMENSION(nbdim,2,0:Agrif_Nbprocs-1) :: iminmax_temp
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin_recv,imax_recv
+      TYPE(Agrif_PVARIABLE) :: tempC,tempCextend
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: sendtoproc
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: recvfromproc
+      LOGICAL                                    :: res
+      TYPE(AGRIF_PVARIABLE), SAVE                      :: temprecv
+
+#include "mpif.h"
+          INTEGER :: i,k
+          INTEGER :: etiquette = 100
+          INTEGER :: code, datasize
+          INTEGER,DIMENSION(MPI_STATUS_SIZE)   :: statut
+
+
+      do k = 0,Agrif_ProcRank-1
+C
+C
+            Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,code)
+C
+            if (sendtoproc(k)) then
+C
+                iminmax_temp(:,1,k) = imin(:,k)
+                iminmax_temp(:,2,k) = imax(:,k)
+
+                Call MPI_SEND(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+C
+                datasize = 1
+C
+!CDIR SHORTLOOP
+                do i = 1,nbdim
+C
+                  datasize = datasize * (imax(i,k)-imin(i,k)+1)
+C
+                enddo
+C
+                SELECT CASE(nbdim)
+                CASE(1)
+                   Call MPI_SEND(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(2)
+                   Call MPI_SEND(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(3)
+                
+                  Call Agrif_Send_3Darray(tempC%var%array3,
+     &             lbound(tempC%var%array3),imin(:,k),imax(:,k),k)
+                CASE(4)
+                   Call MPI_SEND(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(5)
+                   Call MPI_SEND(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(6)
+                   Call MPI_SEND(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                END SELECT
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+C
+C
+            Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,statut,code)
+C
+            recvfromproc(k) = res
+
+C
+            if (recvfromproc(k)) then
+C
+                Call MPI_RECV(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,statut,code)
+
+                imin_recv(:,k) = iminmax_temp(:,1,k)
+                imax_recv(:,k) = iminmax_temp(:,2,k)
+
+                datasize = 1
+C
+!CDIR SHORTLOOP
+                do i = 1,nbdim
+C
+                datasize = datasize * (imax_recv(i,k)-imin_recv(i,k)+1)
+C
+                enddo
+
+             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var)
+             call Agrif_nbdim_allocation(temprecv%var,imin_recv(:,k),
+     &   imax_recv(:,k),nbdim)
+            SELECT CASE(nbdim)
+            CASE(1)
+              Call MPI_RECV(temprecv%var%array1,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(2)
+              Call MPI_RECV(temprecv%var%array2,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(3)
+              Call MPI_RECV(temprecv%var%array3,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+
+            CASE(4)
+              Call MPI_RECV(temprecv%var%array4,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(5)
+              Call MPI_RECV(temprecv%var%array5,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(6)
+              Call MPI_RECV(temprecv%var%array6,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+       END SELECT
+                        
+            Call where_valtabtotab_mpi(tempCextend%var,
+     &             temprecv%var,imin_recv(:,k),imax_recv(:,k),0.,nbdim)
+     
+                Call Agrif_nbdim_deallocation(temprecv%var,nbdim)
+C                deallocate(temprecv%var)
+
+            endif
+
+C
+      enddo
+
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+C
+C
+            
+            Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,code)
+C
+            if (sendtoproc(k)) then
+C
+                iminmax_temp(:,1,k) = imin(:,k)
+                iminmax_temp(:,2,k) = imax(:,k)
+
+                Call MPI_SEND(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+C
+                SELECT CASE(nbdim)
+                CASE(1)
+                datasize=SIZE(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)))
+                   Call MPI_SEND(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(2)
+                datasize=SIZE(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)))
+                   Call MPI_SEND(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(3)
+                datasize=SIZE(tempC%var%array3(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k)))
+                   Call MPI_SEND(tempC%var%array3(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(4)
+                datasize=SIZE(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)))
+                   Call MPI_SEND(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(5)
+                datasize=SIZE(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)))
+                   Call MPI_SEND(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(6)
+                datasize=SIZE(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)))
+                   Call MPI_SEND(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                END SELECT
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank-1,0,-1
+C
+C
+            Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,statut,code)
+C
+            recvfromproc(k) = res
+
+C
+            if (recvfromproc(k)) then
+C
+                Call MPI_RECV(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,statut,code)
+
+C                imin_recv(:,k) = iminmax_temp(:,1,k)
+C                imax_recv(:,k) = iminmax_temp(:,2,k)
+
+C                datasize = 1
+C
+C                do i = 1,nbdim
+C
+C                datasize = datasize * (imax_recv(i,k)-imin_recv(i,k)+1)
+C
+C                enddo
+             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var)
+             call Agrif_nbdim_allocation(temprecv%var,
+     &   iminmax_temp(:,1,k),iminmax_temp(:,2,k),nbdim)
+            SELECT CASE(nbdim)
+            CASE(1)
+              datasize=SIZE(temprecv%var%array1)
+              Call MPI_RECV(temprecv%var%array1,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(2)
+              datasize=SIZE(temprecv%var%array2)
+              Call MPI_RECV(temprecv%var%array2,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(3)
+              datasize=SIZE(temprecv%var%array3)
+              Call MPI_RECV(temprecv%var%array3,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+
+            CASE(4)
+              datasize=SIZE(temprecv%var%array4)
+              Call MPI_RECV(temprecv%var%array4,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(5)
+              datasize=SIZE(temprecv%var%array5)
+              Call MPI_RECV(temprecv%var%array5,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(6)
+              datasize=SIZE(temprecv%var%array6)
+              Call MPI_RECV(temprecv%var%array6,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+          END SELECT
+            
+            Call where_valtabtotab_mpi(tempCextend%var,
+     &             temprecv%var,iminmax_temp(:,1,k),iminmax_temp(:,2,k)
+     &            ,0.,nbdim)
+     
+                Call Agrif_nbdim_deallocation(temprecv%var,nbdim)
+C                deallocate(temprecv%var)
+            endif
+
+C
+      enddo
+
+          End Subroutine ExchangeSamelevel
+          
+       Subroutine ExchangeSameLevel_first(sendtoproc,nbdim,imin,imax,
+     &          recvfromproc,imin_recv,imax_recv)
+      Implicit None
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin,imax
+      INTEGER,DIMENSION(nbdim,2,0:Agrif_Nbprocs-1) :: iminmax_temp
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin_recv,imax_recv
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: sendtoproc
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: recvfromproc
+      LOGICAL                                    :: res
+
+#include "mpif.h"
+          INTEGER :: i,k
+          INTEGER :: etiquette = 100
+          INTEGER :: code, datasize
+          INTEGER,DIMENSION(MPI_STATUS_SIZE)   :: statut
+
+     
+      do k = 0,Agrif_ProcRank-1
+C
+C
+            Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,code)
+C
+            if (sendtoproc(k)) then
+C
+                iminmax_temp(:,1,k) = imin(:,k)
+                iminmax_temp(:,2,k) = imax(:,k)
+
+                Call MPI_SEND(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+C
+C
+            Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,statut,code)
+C
+            recvfromproc(k) = res
+
+C
+            if (recvfromproc(k)) then
+C
+                Call MPI_RECV(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,statut,code)
+
+                imin_recv(:,k) = iminmax_temp(:,1,k)
+                imax_recv(:,k) = iminmax_temp(:,2,k)
+            endif
+
+C
+      enddo
+
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+C
+C
+            
+            Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,code)
+C
+            if (sendtoproc(k)) then
+C
+                iminmax_temp(:,1,k) = imin(:,k)
+                iminmax_temp(:,2,k) = imax(:,k)
+
+                Call MPI_SEND(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank-1,0,-1
+C
+C
+            Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
+     &                    MPI_COMM_AGRIF,statut,code)
+C
+            recvfromproc(k) = res
+
+C
+            if (recvfromproc(k)) then
+C
+                Call MPI_RECV(iminmax_temp(:,:,k),
+     &                        2*nbdim,MPI_INTEGER,k,etiquette,
+     &                        MPI_COMM_AGRIF,statut,code)
+
+                imin_recv(:,k) = iminmax_temp(:,1,k)
+                imax_recv(:,k) = iminmax_temp(:,2,k)
+            endif
+
+C
+      enddo
+
+          End Subroutine ExchangeSamelevel_first          
+
+       Subroutine ExchangeSameLevel2(sendtoproc,recvfromproc,
+     &   nbdim,
+     &          pttruetabwhole,cetruetabwhole,imin,imax,
+     &          imin_recv,imax_recv,memberout,tempC,tempCextend)
+      Implicit None
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin,imax
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: pttruetabwhole,
+     &     cetruetabwhole
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1) :: imin_recv,imax_recv
+      TYPE(Agrif_PVARIABLE) :: tempC,tempCextend
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: sendtoproc
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: recvfromproc
+      LOGICAL                                    :: res
+      LOGICAL :: memberout
+      TYPE(AGRIF_PVARIABLE), SAVE                      :: temprecv
+
+#include "mpif.h"
+          INTEGER :: i,k
+          INTEGER :: etiquette = 100
+          INTEGER :: code, datasize
+          INTEGER,DIMENSION(MPI_STATUS_SIZE)   :: statut
+
+      IF (memberout) THEN
+      Call Agrif_nbdim_allocation(tempCextend%var,
+     &                 pttruetabwhole(:,Agrif_ProcRank),
+     &                 cetruetabwhole(:,Agrif_ProcRank),nbdim)
+      call Agrif_nbdim_Full_VarEQreal(tempCextend%var,0.,nbdim)
+      ENDIF
+
+      IF (sendtoproc(Agrif_ProcRank)) THEN
+           Call Agrif_nbdim_VarEQvar(tempCextend%var,
+     &                               imin(:,Agrif_Procrank),
+     &                               imax(:,Agrif_Procrank),
+     &                               tempC%var,
+     &                               imin(:,Agrif_Procrank),
+     &                               imax(:,Agrif_Procrank),
+     &                               nbdim)
+      ENDIF
+
+      do k = 0,Agrif_ProcRank-1
+C
+C
+C
+            if (sendtoproc(k)) then
+C
+                datasize = 1
+C
+!CDIR SHORTLOOP
+                do i = 1,nbdim
+C
+                  datasize = datasize * (imax(i,k)-imin(i,k)+1)
+C
+                enddo
+C
+
+                SELECT CASE(nbdim)
+                CASE(1)
+                   Call MPI_SEND(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(2)               
+                   Call MPI_SEND(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(3)
+     
+                  Call Agrif_Send_3Darray(tempC%var%array3,
+     &             lbound(tempC%var%array3),imin(:,k),imax(:,k),k)
+                CASE(4)
+                   Call MPI_SEND(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(5)
+                   Call MPI_SEND(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(6)
+                   Call MPI_SEND(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                END SELECT
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+
+C
+            if (recvfromproc(k)) then
+
+                datasize = 1
+C
+!CDIR SHORTLOOP
+                do i = 1,nbdim
+C
+                datasize = datasize * (imax_recv(i,k)-imin_recv(i,k)+1)
+C
+                enddo
+
+             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var)
+             call Agrif_nbdim_allocation(temprecv%var,imin_recv(:,k),
+     &   imax_recv(:,k),nbdim)
+            SELECT CASE(nbdim)
+            CASE(1)
+              Call MPI_RECV(temprecv%var%array1,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(2)           
+              Call MPI_RECV(temprecv%var%array2,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(3)       
+              Call MPI_RECV(temprecv%var%array3,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+
+            CASE(4)
+              Call MPI_RECV(temprecv%var%array4,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(5)
+              Call MPI_RECV(temprecv%var%array5,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(6)
+              Call MPI_RECV(temprecv%var%array6,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+       END SELECT
+                        
+            Call where_valtabtotab_mpi(tempCextend%var,
+     &             temprecv%var,imin_recv(:,k),imax_recv(:,k),0.,nbdim)
+     
+                Call Agrif_nbdim_deallocation(temprecv%var,nbdim)
+C                deallocate(temprecv%var)
+
+            endif
+
+C
+      enddo
+
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank+1,Agrif_Nbprocs-1
+C
+C
+            if (sendtoproc(k)) then
+C
+                SELECT CASE(nbdim)
+                CASE(1)
+                datasize=SIZE(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)))
+                   Call MPI_SEND(tempC%var%array1(
+     &                        imin(1,k):imax(1,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(2)                
+                datasize=SIZE(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)))
+                   Call MPI_SEND(tempC%var%array2(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(3)
+                datasize=SIZE(tempC%var%array3(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k)))
+                   Call MPI_SEND(tempC%var%array3(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(4)
+                datasize=SIZE(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)))
+                   Call MPI_SEND(tempC%var%array4(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(5)
+                datasize=SIZE(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)))
+                   Call MPI_SEND(tempC%var%array5(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                CASE(6)
+                datasize=SIZE(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)))
+                   Call MPI_SEND(tempC%var%array6(
+     &                        imin(1,k):imax(1,k),
+     &                        imin(2,k):imax(2,k),
+     &                        imin(3,k):imax(3,k),
+     &                        imin(4,k):imax(4,k),
+     &                        imin(5,k):imax(5,k),
+     &                        imin(6,k):imax(6,k)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+                END SELECT
+C
+            endif
+
+C
+      enddo
+C
+C
+C     Reception from others processors of the necessary part of the parent grid
+      do k = Agrif_ProcRank-1,0,-1
+C
+
+C
+            if (recvfromproc(k)) then
+C
+             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var)
+             call Agrif_nbdim_allocation(temprecv%var,
+     &   imin_recv(:,k),imax_recv(:,k),nbdim)
+            SELECT CASE(nbdim)
+            CASE(1)
+              datasize=SIZE(temprecv%var%array1)
+              Call MPI_RECV(temprecv%var%array1,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(2)           
+              datasize=SIZE(temprecv%var%array2)
+              Call MPI_RECV(temprecv%var%array2,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(3)           
+              datasize=SIZE(temprecv%var%array3)
+              Call MPI_RECV(temprecv%var%array3,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+
+            CASE(4)
+              datasize=SIZE(temprecv%var%array4)
+              Call MPI_RECV(temprecv%var%array4,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(5)
+              datasize=SIZE(temprecv%var%array5)
+              Call MPI_RECV(temprecv%var%array5,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+            CASE(6)
+              datasize=SIZE(temprecv%var%array6)
+              Call MPI_RECV(temprecv%var%array6,
+     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &               MPI_COMM_AGRIF,statut,code)
+          END SELECT
+            
+            Call where_valtabtotab_mpi(tempCextend%var,
+     &             temprecv%var,imin_recv(:,k),imax_recv(:,k)
+     &            ,0.,nbdim)
+     
+                Call Agrif_nbdim_deallocation(temprecv%var,nbdim)
+C                deallocate(temprecv%var)
+            endif
+
+C
+      enddo
+                  
+          End Subroutine ExchangeSamelevel2
+          
+          Subroutine Agrif_Send_3Darray(tab3D,bounds,imin,imax,k)
+          integer, dimension(3) :: bounds, imin, imax
+          real,dimension(bounds(1):,bounds(2):,bounds(3):),target
+     &                             :: tab3D
+          integer :: k
+          integer :: etiquette = 100
+          integer :: datasize, code
+#include "mpif.h"   
+
+          datasize = SIZE(tab3D(
+     &                       imin(1):imax(1),
+     &                        imin(2):imax(2),
+     &                        imin(3):imax(3)))
+       
+                   Call MPI_SEND(tab3D(
+     &                        imin(1):imax(1),
+     &                        imin(2):imax(2),
+     &                        imin(3):imax(3)),
+     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
+     &                        MPI_COMM_AGRIF,code)
+     
+         End Subroutine Agrif_Send_3Darray
+
+#else
+      Subroutine Agrif_mpp_empty()
+      End Subroutine Agrif_mpp_empty
+#endif
+
+      End Module Agrif_mpp
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modsauv.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modsauv.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modsauv.F	(revision 1844)
@@ -0,0 +1,863 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Save  
+C
+      Module Agrif_Save 
+C
+CCC   Description:   
+CCC   Module for the initialization by copy of the grids created by clustering.
+C
+C     Modules used:
+C      
+      Use Agrif_Types
+      Use Agrif_Link
+      Use Agrif_Arrays
+C
+      IMPLICIT NONE
+C
+      Contains
+C     Definition of procedures contained in this module.
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Free_data_before
+C     **************************************************************************
+C
+      Subroutine Agrif_Free_data_before(Agrif_Gr)
+C
+CCC   Description:
+CCC   
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      TYPE(Agrif_Grid),pointer   :: Agrif_Gr ! Pointer on the current grid
+      INTEGER i 
+C
+C   
+      do i = 1 , AGRIF_NbVariables
+         if ( .NOT. Agrif_Mygrid % tabvars(i) % var % restaure) then
+C 
+            if (associated(Agrif_Gr%tabvars(i)%var%array1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array6)
+            endif
+C
+            if (associated(Agrif_Gr%tabvars(i)%var%darray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray6)
+            endif
+C
+            if (associated(Agrif_Gr%tabvars(i)%var%larray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray6)
+            endif
+C
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray6)
+            endif
+C
+            if (associated(Agrif_Gr%tabvars(i)%var%carray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%carray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%carray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%carray2)
+            endif
+C
+            if (associated(Agrif_Gr%tabvars(i)%var%oldvalues2D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%oldvalues2D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%interpIndex)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%interpIndex)
+            endif
+            
+            if (associated(Agrif_Gr%tabvars(i)%var%posvar)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%posvar)
+            endif     
+            
+            if (associated(Agrif_Gr%tabvars(i)%var%interptab)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%interptab)
+            endif  
+            
+       endif
+           
+C
+       if (associated(Agrif_Gr%tabvars(i)%var%list_interp)) then
+         Call Agrif_Free_list_interp
+     &                          (Agrif_Gr%tabvars(i)%var%list_interp)
+       endif                             
+C
+       if ( .NOT. Agrif_Mygrid % tabvars(i) % var % restaure) then
+            Deallocate(Agrif_Gr%tabvars(i)%var)
+C 
+        endif
+      enddo
+C
+C 
+C
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+         if ( Agrif_Probdim .EQ. 1 ) Deallocate(Agrif_Gr%tabpoint1D)
+         if ( Agrif_Probdim .EQ. 2 ) Deallocate(Agrif_Gr%tabpoint2D)
+         if ( Agrif_Probdim .EQ. 3 ) Deallocate(Agrif_Gr%tabpoint3D)
+      endif
+C          
+      Return
+C
+C
+      End Subroutine Agrif_Free_data_before
+C
+C
+      Recursive Subroutine Agrif_Free_list_interp(list_interp)
+      TYPE(Agrif_List_Interp_Loc), Pointer :: list_interp
+      
+      if (associated(list_interp%suiv))
+     &      Call Agrif_Free_list_interp(list_interp%suiv)
+     
+#ifdef AGRIF_MPI
+       Deallocate(list_interp%interp_loc%tab4t)
+       Deallocate(list_interp%interp_loc%memberinall)
+       Deallocate(list_interp%interp_loc%sendtoproc1)
+       Deallocate(list_interp%interp_loc%recvfromproc1)
+#endif
+       Deallocate(list_interp%interp_loc)
+       Deallocate(list_interp)
+       Nullify(list_interp)
+
+      End Subroutine Agrif_Free_list_interp      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Free_data_after
+C     **************************************************************************
+C      
+      Subroutine Agrif_Free_data_after(Agrif_Gr)
+C
+CCC   Description:
+CCC   
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+C
+      
+C
+C     Pointer argument    
+      TYPE(Agrif_Grid),pointer   :: Agrif_Gr  ! Pointer on the current grid
+      INTEGER i
+C
+C      
+      do i = 1 , AGRIF_NbVariables
+         if ( Agrif_Mygrid % tabvars(i) % var % restaure) then
+C 
+            if (associated(Agrif_Gr%tabvars(i)%var%array1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%array6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%array6)
+            endif
+!
+            if (associated(Agrif_Gr%tabvars(i)%var%darray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%darray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%darray6)
+            endif
+!
+            if (associated(Agrif_Gr%tabvars(i)%var%larray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%larray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%larray6)
+            endif
+!
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray2)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray3)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray3)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray4)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray4)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray5)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray5)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%iarray6)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%iarray6)
+            endif
+!
+            if (associated(Agrif_Gr%tabvars(i)%var%carray1)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%carray1)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%carray2)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%carray2)
+            endif
+!
+            if (associated(Agrif_Gr%tabvars(i)%var%oldvalues2D)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%oldvalues2D)
+            endif
+            if (associated(Agrif_Gr%tabvars(i)%var%interpIndex)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%interpIndex)
+            endif
+            
+            if (associated(Agrif_Gr%tabvars(i)%var%posvar)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%posvar)
+            endif     
+            
+            if (associated(Agrif_Gr%tabvars(i)%var%interptab)) then
+               Deallocate(Agrif_Gr%tabvars(i)%var%interptab)
+            endif                  
+!
+            Deallocate(Agrif_Gr%tabvars(i)%var)
+! 
+         endif
+      enddo
+C
+C      
+      Return
+C
+C
+      End Subroutine Agrif_Free_data_after      
+C
+C
+CC    **************************************************************************
+CCC   Subroutine AGRIF_CopyFromold_All
+C     **************************************************************************
+C
+      Recursive Subroutine AGRIF_CopyFromold_All(g,oldchildgrids)
+C
+CCC   Description:
+CCC   Routine called in the Agrif_Init_Hierarchy procedure 
+C       (Agrif_Clustering module). 
+C
+CC    Method:        
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      TYPE(AGRIF_grid),pointer   :: g ! Pointer on the current grid
+      TYPE(AGRIF_pgrid),pointer   :: oldchildgrids
+C
+C     Local pointer
+      TYPE(AGRIF_pgrid),pointer  :: parcours ! Pointer for the recursive 
+                                             ! procedure 
+      REAL g_eps,eps,oldgrid_eps
+      INTEGER :: out
+      INTEGER :: iii
+C
+      out = 0
+C                                                                           
+      parcours => oldchildgrids  
+C
+      do while (associated(parcours))
+C 
+        if ((.NOT. g % fixed) .AND. (parcours % gr %oldgrid)) then
+C        
+            g_eps = huge(1.)
+            oldgrid_eps = huge(1.)
+            do iii = 1 , Agrif_Probdim
+               g_eps = min(g_eps,g % Agrif_d(iii))
+               oldgrid_eps = min(oldgrid_eps,
+     &                       parcours % gr % Agrif_d(iii))
+            enddo
+C
+            eps = min(g_eps,oldgrid_eps)/100.                  
+C
+            do iii = 1 , Agrif_Probdim
+
+               if (g % Agrif_d(iii) .LT. 
+     &             (parcours % gr % Agrif_d(iii) - eps)) then
+C            
+                   parcours => parcours % next
+C            
+                   out = 1
+C   
+                   Exit
+C             
+               endif
+C      
+            enddo
+        if ( out .EQ. 1 ) Cycle
+C
+            Call AGRIF_CopyFromOld(g,parcours%gr)
+C
+        endif
+C                     
+        Call Agrif_CopyFromold_All
+     &             (g, parcours % gr % child_grids)
+C        
+        parcours => parcours % next
+C        
+      enddo
+C
+C     
+      Return      
+C
+C
+      End Subroutine AGRIF_CopyFromold_All
+C
+C
+C      
+C     **************************************************************************
+CCC   Subroutine Agrif_CopyFromold
+C     **************************************************************************
+C      
+      Subroutine Agrif_CopyFromold(Agrif_New_Gr,Agrif_Old_Gr)
+C
+CCC   Description:
+CCC   Call to the Agrif_Copy procedure.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      TYPE(Agrif_Grid),Pointer   :: Agrif_New_Gr  ! Pointer on the current grid
+      TYPE(Agrif_Grid),Pointer :: Agrif_Old_Gr    ! Pointer on an old grid
+      INTEGER :: i
+C
+C      
+      do i = 1 , AGRIF_NbVariables
+         if ( Agrif_Mygrid % tabvars(i) % var % restaure ) then
+C
+            Call Agrif_Copy(Agrif_New_Gr,Agrif_Old_Gr,
+     &           Agrif_New_Gr % tabvars(i),
+     &           Agrif_Old_Gr % tabvars(i))
+C
+        endif
+      enddo
+
+C      
+C            
+      Return
+C
+C      
+      End Subroutine Agrif_CopyFromold
+C
+C
+CC
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Copy
+C     **************************************************************************
+C      
+      Subroutine Agrif_Copy(Agrif_New_Gr,Agrif_Old_Gr,New_Var,Old_Var)
+C     
+CCC   Description:
+CCC   Sets arguments of the Agrif_UpdatenD procedures, n being the number of 
+CCC   DIMENSION of the grid variable.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+      
+C
+C     Pointer argument    
+      TYPE(Agrif_Grid),Pointer   :: Agrif_New_Gr   ! Pointer on the current grid
+      TYPE(Agrif_Grid), Pointer :: Agrif_Old_Gr    ! Pointer on an old grid
+      TYPE(Agrif_Pvariable) :: New_Var, Old_Var
+      INTEGER :: nbdim                  ! Number of dimensions of the current 
+                                        ! grid      
+      INTEGER,DIMENSION(6) :: pttabnew  ! Indexes of the first point in the 
+                                        ! domain
+      INTEGER,DIMENSION(6) :: petabnew  ! Indexes of the first point in the 
+                                        ! domain
+      INTEGER,DIMENSION(6) :: pttabold  ! Indexes of the first point in the 
+                                        ! domain
+      INTEGER,DIMENSION(6) :: petabold  ! Indexes of the first point in the 
+                                        ! domain
+      INTEGER,DIMENSION(6) :: nbtabold  ! Number of cells in each direction
+      
+      INTEGER,DIMENSION(6) :: nbtabnew  ! Number of cells in each direction   
+      TYPE(AGRIF_Variable), Pointer :: root ! Pointer on the variable of the 
+                                            ! root grid
+      REAL, DIMENSION(6) :: snew,sold
+      REAL, DIMENSION(6) :: dsnew,dsold                              
+      REAL :: eps
+      INTEGER :: n
+C
+C  
+      root => New_Var % var % root_var 
+C      
+      nbdim = root % nbdim
+C         
+      do n=1,nbdim
+C  
+        select case(root % interptab(n))
+C        
+        case('x')                
+C
+          pttabnew(n) = root % point(1)
+C        
+          pttabold(n) = root % point(1)
+C        
+          snew(n) = Agrif_New_Gr % Agrif_x(1)
+C
+          sold(n) = Agrif_Old_Gr % Agrif_x(1) 
+C        
+          dsnew(n) = Agrif_New_Gr % Agrif_d(1)
+C
+          dsold(n) = Agrif_Old_Gr % Agrif_d(1)
+C                      
+          if (root % posvar(n) .EQ. 1) then
+C          
+              petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(1)
+C          
+              petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(1)         
+C        
+            else
+C          
+              petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(1) - 1
+C          
+              petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(1) - 1
+C
+              snew(n) = snew(n) + dsnew(n)/2.
+C
+              sold(n) = sold(n) + dsold(n)/2.
+C        
+          endif           
+C        
+        case('y')
+C        
+          pttabnew(n) = root % point(2)
+C        
+          pttabold(n) = root % point(2)
+C        
+          snew(n) = Agrif_New_Gr % Agrif_x(2)
+C        
+          sold(n) = Agrif_Old_Gr % Agrif_x(2)
+C        
+          dsnew(n) = Agrif_New_Gr % Agrif_d(2)
+C        
+          dsold(n) = Agrif_Old_Gr % Agrif_d(2)
+C                
+          if (root % posvar(n) .EQ. 1) then
+C        
+              petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(2)
+C          
+              petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(2)         
+C        
+            else
+C          
+              petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(2) - 1
+C          
+              petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(2) - 1
+C
+              snew(n) = snew(n) + dsnew(n)/2.
+C
+              sold(n) = sold(n) + dsold(n)/2.                    
+C        
+          endif 
+C        
+        case('z')
+C        
+          pttabnew(n) = root % point(3)
+C        
+          pttabold(n) = root % point(3)
+C        
+          snew(n) = Agrif_New_Gr % Agrif_x(3)
+C        
+          sold(n) = Agrif_Old_Gr % Agrif_x(3)
+C        
+          dsnew(n) = Agrif_New_Gr % Agrif_d(3)
+C        
+          dsold(n) = Agrif_Old_Gr % Agrif_d(3)
+C                
+          if (root % posvar(n) .EQ. 1) then
+C        
+              petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(3)
+C          
+              petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(3)         
+C        
+            else
+C          
+             petabnew(n) = pttabnew(n) + Agrif_New_Gr % nb(3) - 1
+C          
+             petabold(n) = pttabold(n) + Agrif_Old_Gr % nb(3) - 1
+C
+             snew(n) = snew(n) + dsnew(n)/2.
+C
+             sold(n) = sold(n) + dsold(n)/2.                   
+C        
+          endif
+C          
+        case('N')
+C        
+          Call Agrif_nbdim_Get_bound(New_Var%var,
+     &                           pttabnew(n),petabnew(n),
+     &                           n,nbdim)
+C        
+          pttabold(n) = pttabnew(n)
+C      
+          petabold(n) = petabnew(n)
+C              
+          snew(n) = 0.
+C      
+          sold(n) = 0. 
+C      
+          dsnew(n) = 1.
+C      
+          dsold(n) = 1.
+C        
+        end select
+C      
+      enddo
+C      
+      do n = 1,nbdim
+C      
+        nbtabnew(n) = petabnew(n) - pttabnew(n)
+C      
+        nbtabold(n) = petabold(n) - pttabold(n)      
+C 
+      enddo      
+C
+      eps = min(minval(dsnew(1:nbdim)),minval(dsold(1:nbdim)))
+C     
+      eps = eps/100.      
+C      
+      do n = 1,nbdim
+C      
+        if (snew(n) .GT. (sold(n)+dsold(n)*nbtabold(n)+eps)) Return
+C      
+        if ((snew(n)+dsnew(n)*nbtabnew(n)-eps) .LT. sold(n)) Return
+C      
+      enddo
+C            
+C
+      Call AGRIF_CopynD
+     &        (New_Var,Old_Var,pttabold,petabold,pttabnew,petabnew,
+     &         sold,snew,dsold,dsnew,nbdim) 
+C      
+C 
+      Return
+C      
+C
+      End Subroutine Agrif_Copy
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_CopynD
+C     **************************************************************************
+C      
+      Subroutine Agrif_CopynD(New_Var,Old_Var,pttabold,petabold,
+     &                        pttabnew,petabnew,sold,snew,dsold,
+     &                        dsnew,nbdim)
+C     
+CCC   Description:
+CCC   Copy of the nD New_Var variable from the nD Old_Var variable.
+C
+CC    Method:
+CC            
+C
+C     Declarations:
+C
+      
+C
+      INTEGER :: nbdim
+      TYPE(Agrif_Pvariable) :: New_Var, Old_Var     
+      INTEGER,DIMENSION(nbdim) :: pttabnew 
+      INTEGER,DIMENSION(nbdim) :: petabnew
+      INTEGER,DIMENSION(nbdim) :: pttabold
+      INTEGER,DIMENSION(nbdim) :: petabold      
+      REAL, DIMENSION(nbdim) :: snew,sold
+      REAL, DIMENSION(nbdim) :: dsnew,dsold 
+C
+      INTEGER :: i,j,k,l,m,n,i0,j0,k0,l0,m0,n0
+C
+      REAL, DIMENSION(nbdim) :: dim_gmin,dim_gmax
+      REAL, DIMENSION(nbdim) :: dim_newmin,dim_newmax
+      REAL, DIMENSION(nbdim) :: dim_min
+      INTEGER, DIMENSION(nbdim) :: ind_gmin,ind_newmin
+      INTEGER, DIMENSION(nbdim) ::  ind_newmax
+C               
+C
+      do i = 1,nbdim
+C      
+        dim_gmin(i) = sold(i)
+        dim_gmax(i) = sold(i) + (petabold(i)-pttabold(i)) * dsold(i)
+C 
+        dim_newmin(i) = snew(i)
+        dim_newmax(i) = snew(i) + (petabnew(i)-pttabnew(i)) * dsnew(i)
+C
+      enddo         
+C
+      do i = 1,nbdim
+C  
+        if (dim_gmax(i) .LT. dim_newmin(i)) Return
+C      
+        if (dim_gmin(i) .GT. dim_newmax(i)) Return
+C
+      enddo
+C
+C
+      do i = 1,nbdim
+C 
+        ind_newmin(i) = pttabnew(i) - floor(-(max(dim_gmin(i),
+     &                      dim_newmin(i))-dim_newmin(i))/dsnew(i)) 
+C      
+        dim_min(i) = snew(i) + (ind_newmin(i)-pttabnew(i))*dsnew(i)
+C      
+        ind_gmin(i) = pttabold(i) + nint((dim_min(i)-
+     &                dim_gmin(i))/dsold(i))      
+C
+        ind_newmax(i) = pttabnew(i) 
+     &                  + int((min(dim_gmax(i),dim_newmax(i))
+     &                         -dim_newmin(i))/dsnew(i))
+C
+      enddo 
+C
+C
+C
+      SELECT CASE (nbdim)
+      CASE (1)
+         i0 = ind_gmin(1)
+         do i = ind_newmin(1),ind_newmax(1)
+            New_Var % var % array1(i) =
+     &      Old_Var % var % array1(i0)
+            New_Var % var % restore1D(i) = 1   
+         i0 = i0 + int(dsnew(1)/dsold(1))
+         enddo
+      CASE (2)
+        i0 = ind_gmin(1)
+        do i = ind_newmin(1),ind_newmax(1)
+        j0 = ind_gmin(2)
+        do j = ind_newmin(2),ind_newmax(2)
+           New_Var % var % array2(i,j) =
+     &            Old_Var % var % array2(i0,j0)
+           New_Var % var % restore2D(i,j) = 1
+               j0 = j0 + int(dsnew(2)/dsold(2))
+        enddo
+        i0 = i0 + int(dsnew(1)/dsold(1))
+        enddo
+      CASE (3)
+        i0 = ind_gmin(1)
+        do i = ind_newmin(1),ind_newmax(1)
+        j0 = ind_gmin(2)
+        do j = ind_newmin(2),ind_newmax(2)
+        k0 = ind_gmin(3)
+        do k = ind_newmin(3),ind_newmax(3)
+           New_Var % var % array3(i,j,k) =
+     &                  Old_Var % var % array3(i0,j0,k0)
+           New_Var % var % restore3D(i,j,k) = 1   
+                     k0 = k0 + int(dsnew(3)/dsold(3))
+        enddo
+        j0 = j0 + int(dsnew(2)/dsold(2))
+        enddo
+        i0 = i0 + int(dsnew(1)/dsold(1))
+        enddo
+      CASE (4)
+        i0 = ind_gmin(1)
+        do i = ind_newmin(1),ind_newmax(1)
+        j0 = ind_gmin(2)
+        do j = ind_newmin(2),ind_newmax(2)
+        k0 = ind_gmin(3)
+        do k = ind_newmin(3),ind_newmax(3)
+        l0 = ind_gmin(4)
+        do l = ind_newmin(4),ind_newmax(4) 
+           New_Var % var % array4(i,j,k,l) =
+     &                        Old_Var % var % array4(i0,j0,k0,l0)
+           New_Var % var % restore4D(i,j,k,l) = 1   
+        l0 = l0 + int(dsnew(4)/dsold(4))
+        enddo
+        k0 = k0 + int(dsnew(3)/dsold(3))
+        enddo
+        j0 = j0 + int(dsnew(2)/dsold(2))
+        enddo
+        i0 = i0 + int(dsnew(1)/dsold(1))
+        enddo
+      CASE (5)
+        i0 = ind_gmin(1)
+        do i = ind_newmin(1),ind_newmax(1)
+        j0 = ind_gmin(2)
+        do j = ind_newmin(2),ind_newmax(2)
+        k0 = ind_gmin(3)
+        do k = ind_newmin(3),ind_newmax(3)
+        l0 = ind_gmin(4)
+        do l = ind_newmin(4),ind_newmax(4) 
+        m0 = ind_gmin(5)
+        do m = ind_newmin(5),ind_newmax(5)
+           New_Var % var % array5(i,j,k,l,m) =
+     &                        Old_Var % var % array5(i0,j0,k0,l0,m0)
+           New_Var % var % restore5D(i,j,k,l,m) = 1
+        m0 = m0 + int(dsnew(5)/dsold(5)) 
+        enddo
+        l0 = l0 + int(dsnew(4)/dsold(4))
+        enddo
+        k0 = k0 + int(dsnew(3)/dsold(3))
+        enddo
+        j0 = j0 + int(dsnew(2)/dsold(2))
+        enddo
+        i0 = i0 + int(dsnew(1)/dsold(1))
+        enddo
+      CASE (6)
+        i0 = ind_gmin(1)
+        do i = ind_newmin(1),ind_newmax(1)
+        j0 = ind_gmin(2)
+        do j = ind_newmin(2),ind_newmax(2)
+        k0 = ind_gmin(3)
+        do k = ind_newmin(3),ind_newmax(3)
+        l0 = ind_gmin(4)
+        do l = ind_newmin(4),ind_newmax(4) 
+        m0 = ind_gmin(5)
+        do m = ind_newmin(5),ind_newmax(5)
+        n0 = ind_gmin(6)
+        do n = ind_newmin(6),ind_newmax(6)
+           New_Var % var % array6(i,j,k,l,m,n) =
+     &                        Old_Var % var % array6(i0,j0,k0,l0,m0,n0)
+           New_Var % var % restore6D(i,j,k,l,m,n) = 1
+        n0 = n0 + int(dsnew(6)/dsold(6)) 
+        enddo
+        m0 = m0 + int(dsnew(5)/dsold(5)) 
+        enddo
+        l0 = l0 + int(dsnew(4)/dsold(4))
+        enddo
+        k0 = k0 + int(dsnew(3)/dsold(3))
+        enddo
+        j0 = j0 + int(dsnew(2)/dsold(2))
+        enddo
+        i0 = i0 + int(dsnew(1)/dsold(1))
+        enddo
+      END SELECT
+C           
+      Return
+C
+C
+      End Subroutine Agrif_CopynD                    
+C
+C
+C
+      End module Agrif_Save
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modtypes.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modtypes.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modtypes.F	(revision 1844)
@@ -0,0 +1,448 @@
+C     Agrif (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place-Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_types  
+C
+      Module Agrif_types 
+C
+CCC   Description:
+CCC   Definition of data types used in Agrif, of several variables and
+C        PARAMETERs.     
+C
+      IMPLICIT NONE
+      
+C     Maximum refinement ratio
+
+      INTEGER, PARAMETER :: Agrif_MaxRaff = 7
+      
+C     Maximum number of grids of the hierarchy
+      INTEGER, PARAMETER :: Agrif_NbMaxGrids = 10
+                  
+C     MPI Communicator
+      INTEGER :: mpi_comm_agrif
+C
+C     **************************************************************************
+CCC   TYPE Agrif_LRECTANGLE
+C     **************************************************************************
+C
+CCC   Description:
+CCC   Data TYPE allowing a grid to reach a grid on the same level or its child
+CCC   grids.
+C
+      TYPE Agrif_lrectangle  
+           TYPE(Agrif_rectangle) , Pointer :: r    ! to reach a child grid
+           TYPE(Agrif_lrectangle), Pointer :: next ! to reach a grid on the 
+                                                   !    same level
+      End TYPE Agrif_lrectangle  
+C
+C     **************************************************************************
+CCC   TYPE Agrif_RECTANGLE: 
+C     **************************************************************************
+C
+CCC   Description:
+CCC   Data TYPE to define several CHARACTERistics of a grid (number,position,
+CCC   time and space refinement factors,...). 
+C
+      TYPE Agrif_rectangle
+           INTEGER                         :: number      ! Number of the grid
+           ! Number of child grids 
+           INTEGER                         :: nbgridchild 
+           ! Minimal position in the x,y and z direction
+           INTEGER, DIMENSION(3)           :: imin        
+           ! Maximal position in the x,y and z direction 
+           INTEGER, DIMENSION(3)           :: imax 
+           ! Space refinement factor in the x,y and z direction  
+           INTEGER, DIMENSION(3)           :: spaceref    
+           ! Time refinement factor in the x,y and z direction
+           INTEGER, DIMENSION(3)           :: timeref     
+           ! Pointer to reach a grid on  the same level or a child grid
+           TYPE(Agrif_lrectangle), Pointer :: childgrids  
+      End TYPE Agrif_rectangle  
+C
+C
+C
+C     **************************************************************************
+CCC   TYPE Agrif_PGrid
+C     **************************************************************************
+C
+CCC   Description:
+CCC   Data TYPE to go over the grid hierarchy (used for the creation of this 
+CCC   grid hierarchy and during the time integration).
+C 
+      TYPE Agrif_pgrid  
+           ! allows to reach a child grid  
+           TYPE(Agrif_grid) , Pointer :: gr
+           ! allows to reach the grids of the same level 
+           TYPE(Agrif_pgrid), Pointer :: next 
+      End TYPE Agrif_pgrid 
+C
+C
+C
+C     **************************************************************************
+CCC   TYPE Agrif_PVariable
+C     **************************************************************************
+C
+CCC   Description:
+CCC   Data TYPE to define a grid variable.
+C
+      TYPE Agrif_PVariable 
+           ! This field allows to get the various CHARACTERistics 
+           !   of the variable (defined by the Agrif_Variable data TYPE)
+           TYPE(Agrif_Variable) , Pointer :: var  
+           ! Pointer on the parent grid
+           TYPE(Agrif_PVariable), Pointer :: parent_var 
+      End TYPE Agrif_PVariable 
+C
+C     **************************************************************************
+CCC   TYPE Agrif_Grid
+C     **************************************************************************
+C
+CCC   Description:
+CCC   Data TYPE to define a grid (position, space and time refinement factors).
+C
+      TYPE Agrif_grid  
+           ! pointer on the parent grid 
+           TYPE(Agrif_grid)                    ,Pointer :: parent      
+           ! pointer on the child grids 
+           TYPE(Agrif_pgrid)                   ,Pointer :: child_grids 
+           ! List of the grid variables   
+           TYPE(Agrif_PVariable), DIMENSION(:) ,Pointer :: tabvars     
+C
+           ! Global x,y and z position
+           REAL    ,DIMENSION(3)                   :: Agrif_x   
+           ! Global space step in the x,y and z direction
+           REAL    ,DIMENSION(3)                   :: Agrif_d
+           ! number of cells in the x,y and z direction
+           INTEGER ,DIMENSION(3)                   :: nb        
+           ! minimal position in the x,y and z direction
+           INTEGER ,DIMENSION(3)                   :: ix        
+           ! Space refinement factor in the x,y and z direction
+           INTEGER ,DIMENSION(3)                   :: spaceref  
+           ! Time refinement factor in the x,y and z direction 
+           INTEGER ,DIMENSION(3)                   :: timeref   
+           INTEGER ,DIMENSION(:)          ,Pointer :: restore1D   
+           INTEGER ,DIMENSION(:,:)        ,Pointer :: restore2D   
+           INTEGER ,DIMENSION(:,:,:)      ,Pointer :: restore3D 
+           INTEGER ,DIMENSION(:,:,:,:)    ,Pointer :: restore4D
+           INTEGER ,DIMENSION(:,:,:,:,:)  ,Pointer :: restore5D
+           INTEGER ,DIMENSION(:,:,:,:,:,:),Pointer :: restore6D
+           ! number of time step  
+           INTEGER                                 :: ngridstep 
+           INTEGER                                 :: rank  
+           !moving grid id
+           INTEGER                                 :: grid_id
+           ! number of the grid 
+           INTEGER                                 :: fixedrank 
+           ! fixed or moving grid ?  
+           LOGICAL                                 :: fixed     
+           LOGICAL                                 :: oldgrid   
+C          LOGICALs indicating if the current grid has a common border 
+C             with the root coarse grid
+           LOGICAL ,DIMENSION(3)                   :: NearRootBorder
+           LOGICAL ,DIMENSION(3)                   :: DistantRootBorder
+C          Arrays for adaptive grid refinement
+           REAL    ,DIMENSION(:)          ,Pointer :: valtabpoint1D
+           REAL    ,DIMENSION(:,:)        ,Pointer :: valtabpoint2D
+           REAL    ,DIMENSION(:,:,:)      ,Pointer :: valtabpoint3D
+           INTEGER ,DIMENSION(:)          ,Pointer :: tabpoint1D
+           INTEGER ,DIMENSION(:,:)        ,Pointer :: tabpoint2D
+           INTEGER ,DIMENSION(:,:,:)      ,Pointer :: tabpoint3D
+           Type(Agrif_List_Variables), Pointer     :: variables=>NULL()
+           INTEGER                                 :: NbVariables = 0
+           Type(Agrif_Flux), Pointer               :: fluxes => NULL()
+      End TYPE Agrif_grid
+C
+C     **************************************************************************
+CCC   TYPE Agrif_VARIABLE
+C     **************************************************************************
+C     
+CCC   Description:
+CCC   Data TYPE to CHARACTERize a grid variable.   
+C
+      TYPE Agrif_Variable 
+         CHARACTER*80 :: variablename
+C       
+         ! Pointer on the variable of the root grid 
+         TYPE(Agrif_Variable), Pointer :: root_var 
+C
+         ! index of the first point in the REAL domain (x,y and z direction)
+         INTEGER     ,DIMENSION(6)          :: point
+         ! position of the variable on the cell (1 for the boarder of 
+         !    the edge, 2 for the center)
+         INTEGER     ,DIMENSION(:) ,Pointer :: posvar      => NULL() 
+         ! Indication for the space interpolation (module Agrif_Boundary)
+         INTEGER                   ,Pointer :: interpIndex => NULL() 
+         ! number of DIMENSIONs of the grid variable
+         INTEGER                            :: nbdim = 0             
+         ! Array indicating the TYPE of DIMENSION (space or not) for 
+         !    each of them 
+         CHARACTER(6),DIMENSION(:) ,Pointer :: interptab   => NULL() 
+C        Arrays containing the values of the grid variables (REAL)
+         REAL                                    :: array0 
+         REAL   , DIMENSION(:)          ,Pointer :: array1    => NULL()
+         REAL   , DIMENSION(:,:)        ,Pointer :: array2    => NULL()
+         REAL   , DIMENSION(:,:,:)      ,Pointer :: array3    => NULL()
+         REAL   , DIMENSION(:,:,:,:)    ,Pointer :: array4    => NULL()
+         REAL   , DIMENSION(:,:,:,:,:)  ,Pointer :: array5    => NULL()
+         REAL   , DIMENSION(:,:,:,:,:,:),Pointer :: array6    => NULL()
+C        Arrays containing the values of the grid variables (REAL*8)
+         REAL*8                                 :: darray0
+         REAL*8, DIMENSION(:)          ,Pointer :: darray1   => NULL()
+         REAL*8, DIMENSION(:,:)        ,Pointer :: darray2   => NULL()
+         REAL*8, DIMENSION(:,:,:)      ,Pointer :: darray3   => NULL()
+         REAL*8, DIMENSION(:,:,:,:)    ,Pointer :: darray4   => NULL()
+         REAL*8, DIMENSION(:,:,:,:,:)  ,Pointer :: darray5   => NULL()
+         REAL*8, DIMENSION(:,:,:,:,:,:),Pointer :: darray6   => NULL()
+C        Arrays containing the values of the grid variables (REAL*4)
+         REAL*4                                 :: sarray0
+         REAL*4, DIMENSION(:)          ,Pointer :: sarray1   => NULL()
+         REAL*4, DIMENSION(:,:)        ,Pointer :: sarray2   => NULL()
+         REAL*4, DIMENSION(:,:,:)      ,Pointer :: sarray3   => NULL()
+         REAL*4, DIMENSION(:,:,:,:)    ,Pointer :: sarray4   => NULL()
+         REAL*4, DIMENSION(:,:,:,:,:)  ,Pointer :: sarray5   => NULL()
+         REAL*4, DIMENSION(:,:,:,:,:,:),Pointer :: sarray6   => NULL()
+C        Arrays containing the values of the grid variables (LOGICAL)
+         LOGICAL                                 :: larray0
+         LOGICAL, DIMENSION(:)          ,Pointer :: larray1   => NULL()
+         LOGICAL, DIMENSION(:,:)        ,Pointer :: larray2   => NULL()
+         LOGICAL, DIMENSION(:,:,:)      ,Pointer :: larray3   => NULL()
+         LOGICAL, DIMENSION(:,:,:,:)    ,Pointer :: larray4   => NULL()
+         LOGICAL, DIMENSION(:,:,:,:,:)  ,Pointer :: larray5   => NULL()
+         LOGICAL, DIMENSION(:,:,:,:,:,:),Pointer :: larray6   => NULL()
+C         Arrays containing the values of the grid variables (INTEGER)   
+         INTEGER                                 :: iarray0
+         INTEGER, DIMENSION(:)          ,Pointer :: iarray1   => NULL()
+         INTEGER, DIMENSION(:,:)        ,Pointer :: iarray2   => NULL()
+         INTEGER, DIMENSION(:,:,:)      ,Pointer :: iarray3   => NULL()
+         INTEGER, DIMENSION(:,:,:,:)    ,Pointer :: iarray4   => NULL()
+         INTEGER, DIMENSION(:,:,:,:,:)  ,Pointer :: iarray5   => NULL()
+         INTEGER, DIMENSION(:,:,:,:,:,:),Pointer :: iarray6   => NULL()
+C
+         INTEGER, DIMENSION(:)          ,Pointer :: restore1D => NULL()
+         INTEGER, DIMENSION(:,:)        ,Pointer :: restore2D => NULL()
+         INTEGER, DIMENSION(:,:,:)      ,Pointer :: restore3D => NULL()
+         INTEGER, DIMENSION(:,:,:,:)    ,Pointer :: restore4D => NULL()
+         INTEGER, DIMENSION(:,:,:,:,:)  ,Pointer :: restore5D => NULL()
+         INTEGER, DIMENSION(:,:,:,:,:,:),Pointer :: restore6D => NULL()
+C   
+         CHARACTER(2050)                          :: carray0
+         CHARACTER(200), DIMENSION(:)    ,Pointer :: carray1   => NULL()
+         CHARACTER(200), DIMENSION(:,:)  ,Pointer :: carray2   => NULL()
+C
+         ! Array used for the time interpolation
+         REAL   , DIMENSION(:,:)      ,Pointer :: oldvalues2D => NULL()
+
+         ! if the variable should be restore -> =1
+         LOGICAL :: restaure = .FALSE.
+         ! the interpolation should be made in any case
+         LOGICAL :: Interpolationshouldbemade = .FALSE. 
+         INTEGER :: bcinf ! option bc
+         INTEGER :: bcsup ! option bc
+         INTEGER, DIMENSION(6) :: updateinf ! option update
+         INTEGER, DIMENSION(6) :: updatesup ! option update         
+         INTEGER, DIMENSION(6,6) :: bcTYPEinterp ! option bcinterp
+         INTEGER, DIMENSION(6) :: TYPEinterp ! option interp
+         INTEGER, DIMENSION(6) :: TYPEupdate ! option update
+         
+         INTEGER, DIMENSION(6) :: lb, ub
+         
+         Type(Agrif_List_Interp_Loc), Pointer :: list_interp => NULL()
+         Type(Agrif_List_Interp_Loc), Pointer :: list_update => NULL()
+C
+      End TYPE Agrif_Variable 
+      
+      Type Agrif_Interp_Loc
+      integer,dimension(6) :: pttab,petab,
+     &                          pttab_Child,pttab_Parent = -99
+      integer,dimension(6) :: indmin, indmax
+      INTEGER,DIMENSION(6)    :: pttruetab,cetruetab
+      logical :: member, memberin      
+#if !defined AGRIF_MPI      
+      integer,dimension(6) :: indminglob,indmaxglob
+#else
+      integer,dimension(6) :: indminglob2,indmaxglob2
+      INTEGER,DIMENSION(6,2,2) :: parentarray
+      INTEGER,DIMENSION(:,:,:), POINTER :: tab4t
+      LOGICAL, DIMENSION(:), POINTER :: memberinall
+      INTEGER,DIMENSION(:,:,:), POINTER :: tab5t
+      LOGICAL, DIMENSION(:), POINTER :: memberinall2
+      LOGICAL, DIMENSION(:), POINTER :: sendtoproc1    
+      LOGICAL, DIMENSION(:), POINTER :: recvfromproc1      
+      LOGICAL, DIMENSION(:), POINTER :: sendtoproc2      
+      LOGICAL, DIMENSION(:), POINTER :: recvfromproc2      
+#endif      
+      End Type Agrif_Interp_Loc
+      
+      Type Agrif_List_Interp_Loc
+      Type(Agrif_Interp_Loc), Pointer :: interp_loc
+      Type(Agrif_List_Interp_Loc), Pointer :: suiv
+      End Type Agrif_List_Interp_Loc
+
+       TYPE Agrif_List_Variables
+         Type(Agrif_PVariable), Pointer :: pvar
+         Type(Agrif_List_Variables), Pointer :: nextvariable  => NULL()
+       END TYPE Agrif_List_Variables
+               
+       TYPE Agrif_Profile
+          character*80 :: profilename
+C
+         ! index of the first point in the REAL domain (x,y and z direction)
+         INTEGER     ,DIMENSION(6)          :: point
+         ! position of the variable on the cell (1 for the boarder of 
+         !    the edge, 2 for the center)
+         INTEGER     ,DIMENSION(:) ,Pointer :: posvar      => NULL() 
+         ! Indication for the space interpolation (module Agrif_Boundary)
+         INTEGER                   ,Pointer :: interpIndex => NULL() 
+         ! number of DIMENSIONs of the grid variable
+         INTEGER                            :: nbdim = 0             
+         ! Array indicating the TYPE of DIMENSION (space or not) for 
+         !    each of them 
+         CHARACTER(6),DIMENSION(:) ,Pointer :: interptab   => NULL() 
+         Type(Agrif_Variable), Pointer :: var
+         Type(Agrif_Profile), Pointer :: nextprofile  => NULL()
+       END TYPE Agrif_Profile
+       
+       Type(Agrif_Profile), Pointer :: Agrif_MyProfiles => NULL()
+           
+C  Boundaries Fluxes
+
+      Type Agrif_Flux
+        Character*80 fluxname
+        Type(Agrif_Variable), Pointer :: fluxtabx
+        Type(Agrif_Variable), Pointer :: fluxtaby
+        Type(Agrif_Variable), Pointer :: fluxtabz        
+        Type(Agrif_Profile), Pointer  :: profile
+        Logical :: Fluxallocated = .FALSE.
+        Type(Agrif_Flux), Pointer     :: nextflux => NULL()
+      End Type Agrif_Flux      
+C
+C     **************************************************************************
+CCC   Different PARAMETERs
+C     **************************************************************************
+      TYPE(Agrif_PVariable), DIMENSION(:) ,Pointer :: Agrif_tabvars
+C
+      ! this pointer always points on the root grid of the grid hierarchy
+      TYPE(Agrif_grid)  ,Pointer :: Agrif_Mygrid      
+      ! Pointer used in the Agrif_regrid subroutine (Agrif_Util module). 
+      !    It contains  the safeguard of the grid hierarchy.
+      TYPE(Agrif_pgrid) ,Pointer :: Agrif_oldmygrid   
+      ! pointer to the current grid (the link is done by using the
+      !    Agrif_Instance   procedure (module Agrif_Init)) 
+      TYPE(Agrif_grid)  ,Pointer :: Agrif_Curgrid
+      ! Pointer used in the Agrif_ChildGrid_to_ParentGrid and 
+      !    Agrif_ParentGrid_to_ChildGrid subroutines 
+      !    (Agrif_CurgridFunctions module). It contains the 
+      !    safeguard of the current grid hierarchy.
+      TYPE(Agrif_grid)  ,Pointer :: Agrif_saveCURGRID
+C
+      ! Problem DIMENSION
+      INTEGER               :: Agrif_Probdim
+      ! number of variables
+      INTEGER               :: Agrif_NbVariables
+      ! number of fixed grids in the grid hierarchy
+      INTEGER               :: Agrif_nbfixedgrids            
+      ! space refinement factor
+      INTEGER ,DIMENSION(3) :: Agrif_coeffref
+      ! time refinement factor
+      INTEGER ,DIMENSION(3) :: Agrif_coeffreft
+      ! LOGICAL to use special values on the parent grid
+      LOGICAL               :: Agrif_UseSpecialValue
+      ! LOGICAL to use special values on the parent grid
+      LOGICAL               :: Agrif_UseSpecialValueInUpdate
+      ! LOGICAL to use special values on the current grid
+      LOGICAL               :: Agrif_UseSpecialValueFineGrid
+      ! Special values on the parent grid
+      REAL                  :: Agrif_SpecialValue
+      ! Special values on the current grid
+      REAL                  :: Agrif_SpecialValueFineGrid
+C   clustering PARAMETERs
+      INTEGER               :: Agrif_Regridding
+      INTEGER               :: Agrif_Minwidth
+      REAL                  :: Agrif_Efficiency = 0.7
+      INTEGER               :: MaxSearch = 5
+      REAL    ,DIMENSION(3) :: Agrif_mind
+C     PARAMETERs for the interpolation of the child grids
+      ! linear interpolation
+      INTEGER ,PARAMETER    :: Agrif_linear=1
+      ! lagrange interpolation
+      INTEGER ,PARAMETER    :: Agrif_lagrange=2
+      ! spline interpolation
+      INTEGER ,PARAMETER    :: Agrif_eno=3
+      ! user s interpolation
+      INTEGER ,PARAMETER    :: Agrif_user_interp=4
+      ! constant interpolation
+      INTEGER ,PARAMETER    :: Agrif_constant=5
+      ! linear conservative interpolation 
+      INTEGER ,PARAMETER    :: Agrif_linearconserv=6
+      ! linear conservative interpolation       
+      INTEGER ,PARAMETER    :: Agrif_linearconservlim=7
+      INTEGER ,PARAMETER    :: Agrif_ppm=8 
+      INTEGER ,PARAMETER    :: Agrif_weno=9         
+C     PARAMETERs for the update of the parent grids      
+      INTEGER ,PARAMETER    :: Agrif_Update_Copy=1           ! copy
+      INTEGER ,PARAMETER    :: Agrif_Update_Average=2        ! average
+      INTEGER ,PARAMETER    :: Agrif_Update_Full_Weighting=3 ! full-weighting 
+C     Raffinement grid switch definition
+      ! Agrif_USE_ONLY_FIXED_GRIDS =1 if fixed grid mode
+      INTEGER               :: Agrif_USE_ONLY_FIXED_GRIDS    
+      ! Agrif_USE_FIXED_GRIDS = 1 if AMR mode + fixed grid 
+      !    else only AMR mode
+      INTEGER               :: Agrif_USE_FIXED_GRIDS         
+C
+#ifdef AGRIF_MPI
+      INTEGER :: Agrif_Nbprocs  ! Number of processors
+      INTEGER :: Agrif_ProcRank ! Rank of the current processor 
+      INTEGER :: Agrif_Group    ! Group associated to MPI_COMM_AGRIF
+      INTEGER :: Agrif_MPIPREC
+#endif
+C
+      contains
+C   
+      Integer Function agrif_ceiling(x)
+C             
+          Real :: x
+          Integer ::i 
+C
+          i = floor(x)
+C      
+          if( abs(x - i).le.0.0001 )then
+             agrif_ceiling = i
+          else
+             agrif_ceiling = i+1
+          endif      
+C
+      End Function
+C
+      Integer Function agrif_int(x)
+C             
+          Real :: x
+          Integer ::i 
+C
+          i = floor(x) + 1
+C      
+          if( abs(x - i).le.0.0001 )then
+             agrif_int = i
+          else
+             agrif_int = i-1
+          endif      
+C
+      End Function
+      End Module Agrif_TYPEs  
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdate.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdate.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdate.F	(revision 1844)
@@ -0,0 +1,2678 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Update
+C
+      Module Agrif_Update
+C
+CCC   Description:
+CCC   Module to update a parent grid from its child grids
+C
+C     Modules used:
+C   
+      Use Agrif_Updatebasic
+c      Use Agrif_Boundary
+      Use Agrif_Arrays
+      Use Agrif_CurgridFunctions
+      Use Agrif_Mask
+#ifdef AGRIF_MPI
+      Use Agrif_mpp
+#endif
+C
+      IMPLICIT NONE
+      logical, private :: precomputedone(7) = .FALSE.      
+C      
+      CONTAINS
+C     Define procedures contained in this module
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_1d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Update_1d(TypeUpdate,parent,child,tab,deb,fin,
+     &                           procname)
+C
+CCC   Description:
+CCC   Subroutine to update a 1D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                              ! are done on the fine grid       
+      External :: procname
+      Optional ::  procname      
+      REAL, DIMENSION(lbound(child%var%array1,1):
+     &                ubound(child%var%array1,1)), Target :: tab  ! Results
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE  
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 1  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array1 => tab
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub             
+      
+C      childtemp % var % list_update => child%var%list_update
+             
+C
+     
+      IF (present(procname)) THEN
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin,procname)
+      ELSE
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+      ENDIF     
+C      
+C      child % var % list_update => childtemp%var%list_update
+      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_1D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_2d
+C     **************************************************************************
+C 
+
+      Subroutine Agrif_Update_2d(TypeUpdate,parent,child,tab,deb,fin,
+     &                           procname)
+C
+CCC   Description:
+CCC   Subroutine to update a 2D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations  
+                                              ! are done on the fine grid 
+                                              
+      External :: procname
+      Optional ::  procname
+                                                          
+      REAL, DIMENSION(
+     &      lbound(child%var%array2,1):ubound(child%var%array2,1),
+     &      lbound(child%var%array2,2):ubound(child%var%array2,2)),
+     &      Target :: tab  ! Results
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 2  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array2 => tab 
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub             
+      
+C      childtemp % var % list_update => child%var%list_update      
+C
+      IF (present(procname)) THEN
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin,procname)
+      ELSE
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+      ENDIF
+C      
+C      child % var % list_update => childtemp%var%list_update
+      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_2D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_3d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Update_3d(TypeUpdate,parent,child,tab,deb,fin,
+     &                           procname)
+C
+CCC   Description:
+CCC   Subroutine to update a 3D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                              ! are done on the fine grid    
+      External :: procname
+      Optional ::  procname
+                                                       
+      REAL, DIMENSION(
+     &      lbound(child%var%array3,1):ubound(child%var%array3,1),
+     &      lbound(child%var%array3,2):ubound(child%var%array3,2),
+     &      lbound(child%var%array3,3):ubound(child%var%array3,3)),
+     &      Target :: tab  ! Results    
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE  
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 3  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array3 => tab     
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+      
+C      childtemp % var % list_update => child%var%list_update      
+C
+      IF (present(procname)) THEN
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin,procname)
+      ELSE
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+      ENDIF
+C      
+C      child % var % list_update => childtemp%var%list_update
+      
+      DEALLOCATE(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_3D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_4d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Update_4d(TypeUpdate,parent,child,tab,deb,fin,
+     &                           procname)
+C
+CCC   Description:
+CCC   Subroutine to update a 4D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                              ! are done on the fine grid     
+      External :: procname
+      Optional ::  procname        
+      REAL, DIMENSION(
+     &      lbound(child%var%array4,1):ubound(child%var%array4,1),
+     &      lbound(child%var%array4,2):ubound(child%var%array4,2),
+     &      lbound(child%var%array4,3):ubound(child%var%array4,3),
+     &      lbound(child%var%array4,4):ubound(child%var%array4,4)),
+     &      Target :: tab  ! Results
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE  
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 4  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array4 => tab     
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+      
+C      childtemp % var % list_update => child%var%list_update
+            
+C
+      IF (present(procname)) THEN
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin,procname)
+      ELSE
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+      ENDIF
+
+C      child % var % list_update => childtemp%var%list_update      
+C
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_4D
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_5d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Update_5d(TypeUpdate,parent,child,tab,deb,fin,
+     &                           procname)
+C
+CCC   Description:
+CCC   Subroutine to update a 5D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                              ! are done on the fine grid     
+      External :: procname
+      Optional ::  procname
+              
+      REAL, DIMENSION(
+     &      lbound(child%var%array5,1):ubound(child%var%array5,1),
+     &      lbound(child%var%array5,2):ubound(child%var%array5,2),
+     &      lbound(child%var%array5,3):ubound(child%var%array5,3),
+     &      lbound(child%var%array5,4):ubound(child%var%array5,4),
+     &      lbound(child%var%array5,5):ubound(child%var%array5,5)),
+     &      Target :: tab  ! Results
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE  
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 5  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array5 => tab      
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub        
+      
+C      childtemp % var % list_update => child%var%list_update      
+C
+      IF (present(procname)) THEN
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin,procname)
+      ELSE
+      CALL Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+      ENDIF
+      
+C      child % var % list_update => childtemp%var%list_update
+            
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_5D
+C
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_6d
+C     **************************************************************************
+C 
+      Subroutine Agrif_Update_6d(TypeUpdate,parent,child,tab,deb,fin)
+C
+CCC   Description:
+CCC   Subroutine to update a 6D grid variable on the parent grid.
+C
+C     Declarations:
+C
+      
+C
+C     Arguments      
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+      TYPE(AGRIF_PVariable) :: parent        ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child         ! Variable on the child grid
+      TYPE(AGRIF_PVariable) :: childtemp     ! Temporary variable on the child
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                              ! are done on the fine grid       
+      REAL, DIMENSION(
+     &      lbound(child%var%array6,1):ubound(child%var%array6,1),
+     &      lbound(child%var%array6,2):ubound(child%var%array6,2),
+     &      lbound(child%var%array6,3):ubound(child%var%array6,3),
+     &      lbound(child%var%array6,4):ubound(child%var%array6,4),
+     &      lbound(child%var%array6,5):ubound(child%var%array6,5),
+     &      lbound(child%var%array6,6):ubound(child%var%array6,6)),
+     &      Target :: tab  ! Results
+C
+C
+C     Definition of a temporary AGRIF_PVariable data TYPE  
+      allocate(childtemp % var)
+C
+C     Pointer on the root variable
+      childtemp % var % root_var => child % var %root_var
+C      
+C     Number of dimensions of the grid variable
+      childtemp % var % nbdim = 6  
+C      
+C     Values on the current grid used for the update
+      childtemp % var % array6 => tab      
+      
+      childtemp % var % lb = child % var % lb
+      childtemp % var % ub = child % var % ub  
+            
+C      childtemp % var % list_update => child%var%list_update
+C
+      Call Agrif_UpdateVariable
+     &     (TypeUpdate,parent,child,deb,fin)
+     
+C      child % var % list_update => childtemp%var%list_update
+           
+C      
+      deallocate(childtemp % var)
+C
+C       
+      End Subroutine Agrif_Update_6D
+C
+C
+C
+C     **************************************************************************  
+C     Subroutine Agrif_UpdateVariable    
+C     **************************************************************************  
+C   
+      Subroutine Agrif_UpdateVariable(TypeUpdate,parent,child,deb,fin,
+     &                   procname)   
+C
+CCC   Description:
+CCC   Subroutine to set arguments of Agrif_UpdatenD, n being the number of
+C         dimensions of the grid variable.
+C
+CC    Declarations:
+C      
+c      
+C      
+C     Scalar argument
+      INTEGER, DIMENSION(6) :: TypeUpdate                  ! TYPE of update (copy or average)
+C     Data TYPE arguments
+      TYPE(AGRIF_PVariable) :: parent   ! Variable on the parent grid
+      TYPE(AGRIF_PVariable) :: child    ! Variable on the child grid 
+      INTEGER, DIMENSION(6) :: deb,fin       ! Positions where interpolations 
+                                        !    are calculated     
+      External :: procname
+      Optional ::  procname
+      
+C
+C     Local scalars      
+      INTEGER :: nbdim                  ! Number of dimensions of the current
+                                        !    grid
+      INTEGER ,DIMENSION(6) :: pttab_child  
+      INTEGER ,DIMENSION(6) :: petab_child      
+      INTEGER ,DIMENSION(6) :: pttab_parent  
+      REAL    ,DIMENSION(6) :: s_child,s_parent
+      REAL    ,DIMENSION(6) :: ds_child,ds_parent
+      INTEGER,DIMENSION(6)          :: loctab_Child ! Indicates if the child
+                                        !    grid has a common border with 
+                                        !    the root grid            
+      TYPE(AGRIF_Variable), Pointer :: root               ! Variable on the root grid
+      INTEGER,DIMENSION(6)          :: posvartab_Child    ! Position of the
+                                        !    variable on the cell
+      INTEGER,DIMENSION(6)          :: nbtab_Child        ! Number of the cells    
+      INTEGER :: n              
+      LOGICAL :: wholeupdate
+C
+C 
+
+      loctab_child(:) = 0
+C
+      root => child % var % root_var 
+      nbdim = root % nbdim
+C
+      do n = 1,nbdim
+        posvartab_child(n) = root % posvar(n)
+      enddo
+C      
+      
+      Call PreProcessToInterpOrUpdate(parent,child,
+     &             petab_Child(1:nbdim),
+     &             pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &             s_Child(1:nbdim),s_Parent(1:nbdim),
+     &             ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &             nbdim)
+C
+C
+      do n = 1,nbdim
+C
+        Select case(root % interptab(n))
+C
+          case('x') ! x DIMENSION
+C
+            nbtab_Child(n) = Agrif_Curgrid % nb(1)
+C
+          case('y') ! y DIMENSION      
+C
+            nbtab_Child(n) = Agrif_Curgrid % nb(2)
+C
+          case('z') ! z DIMENSION
+C
+            nbtab_Child(n) = Agrif_Curgrid % nb(3)
+C
+          case('N') ! No space DIMENSION      
+C
+            select case (nbdim) 
+C      
+              case(1)
+                nbtab_Child(n) = SIZE(child % var % array1,n) - 1
+              case(2)
+                nbtab_Child(n) = SIZE(child % var % array2,n) - 1
+              case(3)
+                nbtab_Child(n) = SIZE(child % var % array3,n) - 1
+              case(4)
+                nbtab_Child(n) = SIZE(child % var % array4,n) - 1
+              case(5)
+                nbtab_Child(n) = SIZE(child % var % array5,n) - 1  
+              case(6)
+                nbtab_Child(n) = SIZE(child % var % array6,n) - 1 
+C
+            end select
+C
+C           No interpolation but only a copy of the values of the grid variable      
+C      
+            posvartab_child(n) = 1
+            
+            loctab_child(n) = -3
+C
+        End select
+C
+      enddo
+      
+C     Call to a procedure of update according to the number of dimensions of
+C     the grid variable
+
+      wholeupdate = .FALSE.
+      
+      do n=1,nbdim
+      if (loctab_child(n) /= -3) then
+        if (deb(n)>fin(n)) wholeupdate = .TRUE.
+        if ((deb(n) == -99).AND.(deb(n)==fin(n))) wholeupdate=.TRUE.
+      endif
+      enddo
+     
+       IF (present(procname)) THEN
+
+          IF (wholeupdate) THEN
+
+          Call AGRIF_UpdateWhole
+     &         (TypeUpdate,parent,child,deb,fin,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim,procname)  
+         ELSE
+          Call AGRIF_UpdateBcnD
+     &         (TypeUpdate,parent,child,deb,fin,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim,procname)  
+         ENDIF
+       ELSE
+         IF (wholeupdate) THEN
+          Call AGRIF_UpdateWhole
+     &         (TypeUpdate,parent,child,deb,fin,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim)
+         ELSE
+          Call AGRIF_UpdateBcnD
+     &         (TypeUpdate,parent,child,deb,fin,
+     &          pttab_Child(1:nbdim),pttab_Parent(1:nbdim),
+     &          nbtab_Child(1:nbdim),posvartab_Child(1:nbdim),
+     &          loctab_Child(1:nbdim),
+     &          s_Child(1:nbdim),s_Parent(1:nbdim),
+     &          ds_Child(1:nbdim),ds_Parent(1:nbdim),nbdim)
+         ENDIF
+       ENDIF
+C
+      Return
+C
+C
+      End subroutine Agrif_UpdateVariable
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_UpdateWhole
+C     **************************************************************************               
+C
+      Subroutine AGRIF_UpdateWhole(TypeUpdate,parent,child,deb,fin,
+     &                           pttab_child,pttab_Parent,
+     &                           nbtab_Child,posvartab_Child,
+     &                           loctab_Child,
+     &                           s_Child,s_Parent,
+     &                           ds_Child,ds_Parent,nbdim,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions for a nD grid variable on 
+CCC   a fine grid by using a space and time interpolations; it is called by the 
+CCC   Agrif_CorrectVariable procedure.
+C
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+C
+#include "mpif.h"
+C
+#endif
+C
+C     Arguments
+      INTEGER, DIMENSION(6) :: TypeUpdate            ! TYPE of update (copy or
+                                                     !    average) 
+      TYPE(AGRIF_PVariable)    :: parent             ! Variable on the parent
+                                                     !    grid
+      TYPE(AGRIF_PVariable)    :: child              ! Variable on the child
+                                                     !    grid 
+      INTEGER, DIMENSION(6) :: deb, fin
+      INTEGER                  :: nbdim              ! Number of dimensions of
+                                                     !    the grid variable
+      INTEGER,DIMENSION(nbdim) :: pttab_child        ! Index of the first point
+                                                     !    inside the domain for
+                                                     !    the parent grid
+                                                     !    variable
+      INTEGER,DIMENSION(nbdim) :: pttab_Parent       ! Index of the first point
+                                                     !    inside the domain for
+                                                     !    the child grid
+                                                     !    variable
+      INTEGER,DIMENSION(nbdim) :: nbtab_Child        ! Number of cells of the
+                                                     !    child grid
+      INTEGER,DIMENSION(nbdim) :: posvartab_Child    ! Position of the grid
+                                                     !    variable (1 or 2)
+      INTEGER,DIMENSION(nbdim) :: loctab_Child       ! Indicates if the child
+                                                     !    grid has a common
+                                                     !    border with the root
+                                                     !    grid
+      REAL   ,DIMENSION(nbdim) :: s_Child,s_Parent   ! Positions of the parent
+                                                     !    and child grids 
+      REAL   ,DIMENSION(nbdim) :: ds_Child,ds_Parent ! Space steps of the parent
+                                                     !    and child grids
+      External :: procname
+      Optional ::  procname      
+C
+C     Local variables     
+      INTEGER,DIMENSION(nbdim,2)   :: lubglob
+      INTEGER                      :: i                 
+      INTEGER,DIMENSION(nbdim,2,2) :: indtab         ! Arrays indicating the
+                                                     !    limits of the child
+      INTEGER,DIMENSION(nbdim,2,2) :: indtruetab     ! grid variable where
+                                                     !   boundary conditions are
+      integer :: coeffraf
+      INTEGER :: debloc, finloc
+C
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim)   :: lb,ub
+      INTEGER,DIMENSION(nbdim,2) :: iminmaxg
+      INTEGER                    :: code
+C
+#endif
+C      
+C
+C indtab contains the limits for the fine grid points that will be used
+C in the update scheme
+
+      DO i = 1, nbdim
+        coeffraf = nint(ds_Parent(i)/ds_Child(i))
+        debloc = 0
+        finloc = nbtab_Child(i)/coeffraf - 1
+
+        IF (posvartab_child(i) == 1) THEN
+           finloc = finloc - 1
+        ENDIF
+
+        IF (deb(i) > fin(i)) THEN
+          debloc = deb(i)
+          finloc = finloc - deb(i)
+        ENDIF
+
+        indtab(i,1,1) = pttab_child(i) + (debloc + 1) * coeffraf
+        indtab(i,1,2) = pttab_child(i) + (finloc + 1) * coeffraf
+
+        IF (posvartab_child(i) == 1) THEN
+          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+            indtab(i,1,1) = indtab(i,1,1) - (coeffraf - 1)
+            indtab(i,1,2) = indtab(i,1,2) + (coeffraf - 1)        
+          ELSE IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN
+            indtab(i,1,1) = indtab(i,1,1) - coeffraf / 2
+            indtab(i,1,2) = indtab(i,1,2) + coeffraf / 2
+          ENDIF
+        ELSE
+          indtab(i,1,1) = indtab(i,1,1) - coeffraf
+          indtab(i,1,2) = indtab(i,1,2) - 1
+          IF ((TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting)
+     &                            .AND.(mod(coeffraf,2) == 1)) THEN
+            indtab(i,1,1) = indtab(i,1,1) - 1
+            indtab(i,1,2) = indtab(i,1,2) + 1
+          ENDIF
+        ENDIF
+        IF (loctab_child(i) == -3) THEN
+           indtab(i,1,1) = pttab_child(i)
+C
+               if (posvartab_child(i) == 1) then
+C
+               indtab(i,1,2) = pttab_child(i) + nbtab_child(i) 
+C
+               else
+C
+               indtab(i,1,2) = pttab_child(i) + nbtab_child(i) - 1
+               ENDIF
+        ENDIF
+      ENDDO
+
+C lubglob contains the global lbound and ubound of the child array
+C lubglob(:,1) : global lbound for each dimension
+C lubglob(:,2) : global lbound for each dimension
+
+#if !defined AGRIF_MPI
+        Call Agrif_nbdim_Get_bound_dimension(child % var,lubglob(:,1),
+     &               lubglob(:,2),nbdim)
+C
+#else
+C     
+        Call Agrif_nbdim_Get_bound_dimension(child % var,lb,ub,nbdim)
+      DO i = 1,nbdim
+C
+        Call Agrif_Invloc(lb(i),Agrif_Procrank,i,iminmaxg(i,1))
+        Call Agrif_Invloc(ub(i),Agrif_Procrank,i,iminmaxg(i,2))
+C
+      ENDDO
+C
+      iminmaxg(1:nbdim,2) = - iminmaxg(1:nbdim,2)
+      
+      CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
+     &                     MPI_COMM_AGRIF,code)
+
+      lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
+C
+#endif 
+C
+
+      indtruetab(1:nbdim,1,1) = max(indtab(1:nbdim,1,1),
+     &     lubglob(1:nbdim,1))
+      indtruetab(1:nbdim,1,2) = min(indtab(1:nbdim,1,2),
+     &     lubglob(1:nbdim,2))
+
+C
+C
+
+           IF (present(procname)) THEN
+              Call Agrif_UpdatenD              
+     &             (TypeUpdate,parent,child,
+     &              indtruetab(1:nbdim,1,1),indtruetab(1:nbdim,1,2),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              posvartab_child,loctab_Child,
+     &              nbdim,procname)
+           ELSE
+              Call Agrif_UpdatenD              
+     &             (TypeUpdate,parent,child,
+     &              indtruetab(1:nbdim,1,1),indtruetab(1:nbdim,1,2),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              posvartab_child,loctab_Child,
+     &              nbdim)           
+           ENDIF
+C
+C      
+C  
+      End Subroutine Agrif_UpdateWhole
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_UpdateBcnd
+C     **************************************************************************               
+C
+      Subroutine AGRIF_UpdateBcnd(TypeUpdate,parent,child,deb,fin,
+     &                           pttab_child,pttab_Parent,
+     &                           nbtab_Child,posvartab_Child,
+     &                           loctab_Child,
+     &                           s_Child,s_Parent,
+     &                           ds_Child,ds_Parent,nbdim,procname)
+C
+CCC   Description:
+CCC   Subroutine to calculate the boundary conditions for a nD grid variable on
+CCC   a fine grid by using a space and time interpolations; it is called by the 
+CCC   Agrif_CorrectVariable procedure.
+C
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+C
+#include "mpif.h"
+C
+#endif
+C
+C     Arguments
+      INTEGER, DIMENSION(6) :: TypeUpdate            ! TYPE of update 
+                                                     !   (copy or average) 
+      TYPE(AGRIF_PVariable)    :: parent             ! Variable on the parent
+                                                     !   grid
+      TYPE(AGRIF_PVariable)    :: child              ! Variable on the child
+                                                     !   grid 
+      INTEGER, DIMENSION(6) :: deb, fin
+      INTEGER                  :: nbdim              ! Number of dimensions of
+                                                     !   the grid variable
+      INTEGER,DIMENSION(nbdim) :: pttab_child        ! Index of the first point
+                                                     !   inside the domain for
+                                                     !   the parent grid
+                                                     !   variable
+      INTEGER,DIMENSION(nbdim) :: pttab_Parent       ! Index of the first point
+                                                     !   inside the domain for
+                                                     !   the child grid variable
+      INTEGER,DIMENSION(nbdim) :: nbtab_Child        ! Number of cells of the
+                                                     !   child grid
+      INTEGER,DIMENSION(nbdim) :: posvartab_Child    ! Position of the grid
+                                                     !   variable (1 or 2)
+      INTEGER,DIMENSION(nbdim) :: loctab_Child       ! Indicates if the child
+                                                     !   grid has a common
+                                                     !   border with the root
+                                                     !   grid
+      REAL   ,DIMENSION(nbdim) :: s_Child,s_Parent   ! Positions of the parent
+                                                     !   and child grids 
+      REAL   ,DIMENSION(nbdim) :: ds_Child,ds_Parent ! Space steps of the parent
+                                                     !   and child grids
+      External :: procname
+      Optional ::  procname      
+C
+C     Local variables
+      INTEGER,DIMENSION(nbdim,2)   :: lubglob
+      INTEGER                      :: i                 
+      INTEGER,DIMENSION(nbdim,2,2) :: indtab         ! Arrays indicating the
+                                                     !   limits of the child
+      INTEGER,DIMENSION(nbdim,2,2) :: indtruetab     ! grid variable where
+                                                     !  boundary conditions are 
+      INTEGER,DIMENSION(nbdim,2,2,nbdim)   :: ptres      ! calculated
+      INTEGER                      :: nb,ndir,n
+      integer :: coeffraf
+C
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim)   :: lb,ub
+      INTEGER,DIMENSION(nbdim,2) :: iminmaxg
+      INTEGER                    :: code
+C
+#endif
+C      
+C
+
+      DO i = 1, nbdim
+        coeffraf = nint(ds_Parent(i)/ds_Child(i))
+        indtab(i,1,1) = pttab_child(i) + (deb(i) + 1) * coeffraf
+        indtab(i,1,2) = pttab_child(i) + (fin(i) + 1) * coeffraf
+
+        indtab(i,2,1) = pttab_child(i) + nbtab_child(i)
+     &    - (fin(i) + 1) *  coeffraf
+        indtab(i,2,2) = pttab_child(i) + nbtab_child(i)
+     &    - (deb(i) + 1) *  coeffraf
+
+        IF (posvartab_child(i) == 1) THEN
+          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+            indtab(i,:,1) = indtab(i,:,1) - (coeffraf - 1)
+            indtab(i,:,2) = indtab(i,:,2) + (coeffraf - 1)        
+          ELSE IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN
+            indtab(i,:,1) = indtab(i,:,1) - coeffraf / 2
+            indtab(i,:,2) = indtab(i,:,2) + coeffraf / 2
+          ENDIF
+        ELSE
+          indtab(i,1,1) = indtab(i,1,1) - coeffraf
+          indtab(i,1,2) = indtab(i,1,2) - 1
+          indtab(i,2,2) = indtab(i,2,2) + coeffraf - 1
+          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+            indtab(i,1,1) = indtab(i,1,1) - 1
+            indtab(i,1,2) = indtab(i,1,2) + 1
+            indtab(i,2,1) = indtab(i,2,1) - 1
+            indtab(i,2,2) = indtab(i,2,2) + 1
+          ENDIF          
+        ENDIF
+      ENDDO
+
+#if !defined AGRIF_MPI      
+        Call Agrif_nbdim_Get_bound_dimension(child % var,lubglob(:,1),
+     &               lubglob(:,2),nbdim)
+
+C
+#else
+C     
+        Call Agrif_nbdim_Get_bound_dimension(child % var,lb,ub,nbdim)
+      DO i = 1,nbdim
+C
+        Call Agrif_Invloc(lb(i),Agrif_Procrank,i,iminmaxg(i,1))
+        Call Agrif_Invloc(ub(i),Agrif_Procrank,i,iminmaxg(i,2))
+C
+      ENDDO
+C
+      iminmaxg(1:nbdim,2) = - iminmaxg(1:nbdim,2)
+      
+      CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
+     &                     MPI_COMM_AGRIF,code)  
+     
+      lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
+C
+#endif 
+C     
+      indtruetab(1:nbdim,1,1) = max(indtab(1:nbdim,1,1),
+     &     lubglob(1:nbdim,1))
+      indtruetab(1:nbdim,1,2) = max(indtab(1:nbdim,1,2),
+     &     lubglob(1:nbdim,1))
+      indtruetab(1:nbdim,2,1) = min(indtab(1:nbdim,2,1),
+     &     lubglob(1:nbdim,2))
+      indtruetab(1:nbdim,2,2) = min(indtab(1:nbdim,2,2),
+     &     lubglob(1:nbdim,2))
+                        
+C 
+C
+      do nb = 1,nbdim
+C
+        do ndir = 1,2
+C
+          if (loctab_child(nb) /= -3) then
+C           
+              do n = 1,2
+C
+                ptres(nb,n,ndir,nb) = indtruetab(nb,ndir,n)
+C
+              enddo              
+C
+              do i = 1,nbdim
+C     
+                if (i .NE. nb) then      
+C
+                    if (loctab_child(i) == -3) then
+C
+                        ptres(i,1,ndir,nb) = pttab_child(i)
+C
+                      else
+C
+                        ptres(i,1,ndir,nb) = indtruetab(i,1,1)
+C
+                    endif
+C
+                    if (loctab_child(i) == -3) then
+C
+                        if (posvartab_child(i) == 1) then
+C
+                            ptres(i,2,ndir,nb) = pttab_child(i) 
+     &                                + nbtab_child(i)
+C
+                          else
+C
+                            ptres(i,2,ndir,nb) = pttab_child(i) 
+     &                             + nbtab_child(i) - 1
+C
+                        endif                             
+C
+                      else
+C
+                        ptres(i,2,ndir,nb) = indtruetab(i,2,2)
+C
+                    endif                        
+C      
+                endif
+C      
+              enddo
+      
+C
+            
+        endif
+      
+        enddo
+       enddo
+C
+
+C
+
+      do nb = 1,nbdim
+C
+        do ndir = 1,2                
+C
+          if (loctab_child(nb) /= -3) then
+C
+           IF (present(procname)) THEN
+              Call Agrif_UpdatenD              
+     &             (TypeUpdate,parent,child,
+     &              ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              posvartab_Child,loctab_Child,
+     &              nbdim,procname,nb,ndir)
+           ELSE
+              Call Agrif_UpdatenD              
+     &             (TypeUpdate,parent,child,
+     &              ptres(1:nbdim,1,ndir,nb),ptres(1:nbdim,2,ndir,nb),
+     &              pttab_child(1:nbdim),pttab_Parent(1:nbdim),
+     &              s_Child(1:nbdim),s_Parent(1:nbdim),
+     &              ds_Child(1:nbdim),ds_Parent(1:nbdim),
+     &              posvartab_Child,loctab_Child,
+     &              nbdim)           
+           ENDIF
+C
+          endif
+          
+C
+        enddo       
+C
+      enddo
+C
+C      
+C  
+      End Subroutine Agrif_UpdateBcnd
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_UpdatenD  
+C     **************************************************************************  
+C  
+      Subroutine Agrif_UpdatenD(TypeUpdate,parent,child,
+     &                          pttab,petab,
+     &                          pttab_Child,pttab_Parent,
+     &                          s_Child,s_Parent,
+     &                          ds_Child,ds_Parent,
+     &                          posvartab_Child,loctab_Child,
+     &                          nbdim,procname,nb,ndir)  
+C
+C     Description:
+C     Subroutine to update a 2D grid variable on the parent grid of 
+C        the current grid. 
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+C
+#include "mpif.h"
+C
+#endif
+C
+C     Arguments
+      INTEGER                    :: nbdim
+      INTEGER, DIMENSION(6) :: TypeUpdate              ! TYPE of update 
+                                                       !  (copy or average)
+      TYPE(AGRIF_PVARIABLE)      :: parent             ! Variable of the parent
+                                                       !   grid   
+      TYPE(AGRIF_PVARIABLE)      :: child              ! Variable of the child
+                                                       !   grid
+      INTEGER,DIMENSION(nbdim)   :: pttab              ! Index of the first
+                                                       !   point inside the
+                                                       !   domain
+      INTEGER,DIMENSION(nbdim)   :: petab              ! Index of the first
+                                                       !   point inside the
+                                                       !   domain
+      INTEGER,DIMENSION(nbdim)   :: pttab_Child        ! Index of the first
+                                                       !   point inside the
+                                                       !   domain for the child
+                                                       !   grid variable
+      INTEGER,DIMENSION(nbdim)   :: pttab_Parent       ! Index of the first
+                                                       !   point inside the
+                                                       !   domain for the parent
+                                                       !   grid variable
+      REAL,DIMENSION(nbdim)      :: s_Child,s_Parent   ! Positions of the parent
+                                                       !   and child grids
+      REAL,DIMENSION(nbdim)      :: ds_Child,ds_Parent ! Space steps of the
+                                                       !   parent and child
+                                                       !   grids 
+      External :: procname
+      Optional ::  procname
+      Integer :: nb,ndir
+      Optional :: nb,ndir
+      
+C
+C     Local pointers
+      TYPE(AGRIF_PVARIABLE), SAVE      :: tempP      ! Temporary parent grid variable
+      TYPE(AGRIF_PVARIABLE), SAVE      :: tempC      ! Temporary child grid variable
+C
+C     Local scalars
+      INTEGER,DIMENSION(nbdim)    :: pttruetab,cetruetab
+      INTEGER,DIMENSION(nbdim)    :: posvartab_Child,loctab_Child
+      INTEGER,DIMENSION(nbdim)    :: indmin,indmax
+      INTEGER,DIMENSION(nbdim)    :: indminglob,indmaxglob
+      REAL   ,DIMENSION(nbdim)    :: s_Child_temp,s_Parent_temp
+cccccccc      LOGICAL,DIMENSION(nbdim)    :: noraftab
+      INTEGER,DIMENSION(nbdim)    :: lowerbound,upperbound
+      LOGICAL :: memberin, member
+      INTEGER,DIMENSION(nbdim)    :: pttruetabwhole,cetruetabwhole
+      INTEGER,DIMENSION(nbdim,2,2) :: childarray
+      INTEGER,DIMENSION(nbdim,2,2) :: parentarray
+      TYPE(AGRIF_PVARIABLE), SAVE      :: tempCextend,tempPextend ! Temporary child
+      INTEGER :: nbin, ndirin
+C
+#ifdef AGRIF_MPI
+C
+      INTEGER,DIMENSION(nbdim)    :: indminglob2,indmaxglob2
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1,recvfromproc1
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc2,recvfromproc2      
+      INTEGER                              :: code
+      INTEGER                              :: i,j,k
+      INTEGER,DIMENSION(nbdim,4)           :: tab3
+      INTEGER,DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab5t      
+      LOGICAL :: find_list_update
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall, memberinall2
+      LOGICAL, DIMENSION(1) :: memberin1      
+C
+#endif
+C
+  
+C
+C     local lbound and ubound of the child array
+
+      Call Agrif_nbdim_Get_bound_dimension(child%var,
+     &                              lowerbound,upperbound,nbdim)
+
+C here pttab and petab corresponds to the (global) indices of the points needed
+C in the update
+C pttruetab and cetruetab contains only indices that are present
+C on the local processor
+
+      Call Agrif_Childbounds(nbdim,
+     &                       lowerbound,upperbound,
+     &                       pttab,petab,
+     &                       pttruetab,cetruetab,memberin)
+
+       Call Agrif_Prtbounds(nbdim,indminglob,indmaxglob,s_Parent_temp,
+     &                     s_Child_temp,s_Child,ds_Child,
+     &                     s_Parent,ds_Parent,
+     &                     pttab,petab,pttab_Child,
+     &                     pttab_Parent,
+     &                     posvartab_Child,TypeUpdate,loctab_Child
+#ifdef AGRIF_MPI
+     &                 ,pttruetabwhole,cetruetabwhole
+#endif
+     &     )
+
+#ifdef AGRIF_MPI
+      IF (memberin) THEN
+       Call Agrif_GlobtoLocInd2(childarray,
+     &                     lowerbound,upperbound,
+     &                     pttruetab,cetruetab,
+     &                     nbdim,Agrif_Procrank,
+     &                     member)
+
+      ENDIF
+
+
+         Call Agrif_Prtbounds(nbdim,indmin,indmax,s_Parent_temp,
+     &                     s_Child_temp,s_Child,ds_Child,
+     &                     s_Parent,ds_Parent,
+     &                     pttruetab,cetruetab,pttab_Child,
+     &                     pttab_Parent,
+     &                     posvartab_Child,TypeUpdate,loctab_Child
+     &                 ,pttruetabwhole,cetruetabwhole
+     &     )
+
+#else
+       indmin = indminglob
+       indmax = indmaxglob
+       pttruetabwhole = pttruetab
+       cetruetabwhole = cetruetab
+       childarray(:,1,2) = pttruetab
+       childarray(:,2,2) = cetruetab
+#endif
+
+       IF (present(procname)) THEN
+       IF (.Not.present(nb)) THEN
+       nbin=0
+       ndirin=0
+       ELSE
+       nbin = nb
+       ndirin = ndir
+       ENDIF
+       ENDIF
+       
+      IF (memberin) THEN
+      IF (.not.associated(tempC%var)) allocate(tempC%var)
+
+C
+      Call Agrif_nbdim_allocation(tempC%var,
+     &                 pttruetab,cetruetab,nbdim)
+
+      Call Agrif_nbdim_Full_VarEQreal(tempC%var,0.,nbdim)
+
+
+
+      IF (present(procname)) THEN
+        SELECT CASE (nbdim)
+        CASE(1)
+          CALL procname(tempC%var%array1,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        CASE(2)
+          CALL procname(tempC%var%array2,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                          childarray(2,1,2),childarray(2,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        CASE(3)
+          CALL procname(tempC%var%array3,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                          childarray(2,1,2),childarray(2,2,2),
+     &                          childarray(3,1,2),childarray(3,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        CASE(4)
+          CALL procname(tempC%var%array4,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                          childarray(2,1,2),childarray(2,2,2),
+     &                          childarray(3,1,2),childarray(3,2,2),
+     &                          childarray(4,1,2),childarray(4,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        CASE(5)
+          CALL procname(tempC%var%array5,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                          childarray(2,1,2),childarray(2,2,2),
+     &                          childarray(3,1,2),childarray(3,2,2),
+     &                          childarray(4,1,2),childarray(4,2,2),
+     &                          childarray(5,1,2),childarray(5,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        CASE(6)
+          CALL procname(tempC%var%array6,
+     &                          childarray(1,1,2),childarray(1,2,2),
+     &                          childarray(2,1,2),childarray(2,2,2),
+     &                          childarray(3,1,2),childarray(3,2,2),
+     &                          childarray(4,1,2),childarray(4,2,2),
+     &                          childarray(5,1,2),childarray(5,2,2),
+     &                          childarray(6,1,2),childarray(6,2,2),
+     &                                   .TRUE.,nbin,ndirin)
+        END SELECT
+      ELSE
+      Call Agrif_nbdim_VarEQvar(tempC%var,pttruetab,cetruetab,
+     &          child%var,childarray(:,1,2),childarray(:,2,2),
+     &                          nbdim)
+      ENDIF
+
+      ENDIF
+
+
+
+C
+C
+#ifdef AGRIF_MPI
+C
+C     tab2 contains the necessary limits of the parent grid for each processor
+
+      IF (Associated(child%var%list_update)) THEN
+      Call Agrif_Find_list_update(child%var%list_update,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim,
+     &       find_list_update,tab4t,tab5t,memberinall,memberinall2,
+     &     sendtoproc1,recvfromproc1,sendtoproc2,recvfromproc2)
+      ELSE
+      find_list_update = .FALSE.
+      ENDIF
+      
+      if (.not.find_list_update) then      
+      tab3(:,1) = pttruetab(:)
+      tab3(:,2) = cetruetab(:)
+      tab3(:,3) = pttruetabwhole(:)
+      tab3(:,4) = cetruetabwhole(:)
+C
+C
+      Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
+
+      IF (.not.associated(tempCextend%var)) Allocate(tempCextend%var)
+      DO k=0,Agrif_Nbprocs-1
+       do j=1,4
+         do i=1,nbdim
+         tab4t(i,k,j) = tab4(i,j,k)
+         enddo
+       enddo
+      enddo
+      
+      memberin1(1) = memberin
+      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
+ 
+       Call Get_External_Data_first(tab4t(:,:,1),
+     &            tab4t(:,:,2),
+     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,memberin,memberin,
+     &            memberinall,sendtoproc1,recvfromproc1,tab4t(:,:,5),
+     & tab4t(:,:,6),tab4t(:,:,7),tab4t(:,:,8))
+               
+      endif
+
+      Call ExchangeSameLevel2(sendtoproc1,recvfromproc1,nbdim,
+     &            tab4t(:,:,3),tab4t(:,:,4),tab4t(:,:,5),tab4t(:,:,6),
+     &            tab4t(:,:,7),tab4t(:,:,8),memberin,tempC,
+     &            tempCextend) 
+           
+!      Call Get_External_Data(tempC,tempCextend,tab4t(:,:,1),
+!     &            tab4t(:,:,2),
+!     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,memberin,memberin,
+!     &            memberinall)
+
+#else
+      tempCextend%var => tempC%var
+#endif
+
+C
+C
+C     Update of the parent grid (tempP) from the child grid (tempC)
+
+
+      IF (memberin) THEN
+
+      IF (.not.associated(tempP%var)) allocate(tempP%var)
+      Call Agrif_nbdim_allocation(tempP%var,
+     &                 indmin,indmax,nbdim)
+
+      if ( nbdim .EQ. 1 ) then
+         tempP%var%array1 = 0.
+         Call Agrif_Update_1D_recursive(TypeUpdate,
+     &           tempP%var%array1,tempCextend%var%array1,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+      if ( nbdim .EQ. 2 ) then
+         Call Agrif_Update_2D_recursive(TypeUpdate,
+     &           tempP%var%array2,tempCextend%var%array2,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+
+      if ( nbdim .EQ. 3 ) then
+         Call Agrif_Update_3D_recursive(TypeUpdate,
+     &           tempP%var%array3,tempCextend%var%array3,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+      if ( nbdim .EQ. 4 ) then
+         Call Agrif_Update_4D_recursive(TypeUpdate,
+     &           tempP%var%array4,tempCextend%var%array4,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+      if ( nbdim .EQ. 5 ) then
+         Call Agrif_Update_5D_recursive(TypeUpdate,
+     &           tempP%var%array5,tempCextend%var%array5,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+      if ( nbdim .EQ. 6 ) then
+         Call Agrif_Update_6D_recursive(TypeUpdate,
+     &           tempP%var%array6,tempCextend%var%array6,
+     &           indmin,indmax,
+     &           pttruetabwhole,cetruetabwhole,
+     &           s_Child_temp,s_Parent_temp,
+     &           ds_Child,ds_Parent,nbdim)
+      endif
+
+      Call Agrif_nbdim_deallocation(tempCextend%var,nbdim)
+C      Deallocate(tempCextend%var)
+
+      ENDIF
+
+#ifdef AGRIF_MPI
+      Call Agrif_nbdim_Get_bound_dimension(parent%var,
+     &                              lowerbound,upperbound,nbdim)
+
+      Call Agrif_ChildGrid_to_ParentGrid()
+C
+      Call Agrif_Childbounds(nbdim,
+     &                       lowerbound,upperbound,
+     &                       indminglob,indmaxglob,
+     &                       indminglob2,indmaxglob2,member)
+C
+      IF (member) THEN
+      Call Agrif_GlobtoLocInd2(parentarray,
+     &                     lowerbound,upperbound,
+     &                     indminglob2,indmaxglob2,
+     &                     nbdim,Agrif_Procrank,
+     &                     member)
+      ENDIF
+
+      Call Agrif_ParentGrid_to_ChildGrid()
+
+      if (.not.find_list_update) then
+      tab3(:,1) = indmin(:)
+      tab3(:,2) = indmax(:)
+      tab3(:,3) = indminglob2(:)
+      tab3(:,4) = indmaxglob2(:)
+C
+      Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
+
+      IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var)
+      DO k=0,Agrif_Nbprocs-1
+       do j=1,4
+         do i=1,nbdim
+         tab5t(i,k,j) = tab4(i,j,k)
+         enddo
+       enddo
+      enddo
+ 
+      memberin1(1) = member
+      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall2,
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
+ 
+      Call Get_External_Data_first(tab5t(:,:,1),
+     &            tab5t(:,:,2),
+     &            tab5t(:,:,3),tab5t(:,:,4),nbdim,memberin,member,
+     &            memberinall2,sendtoproc2,recvfromproc2,tab5t(:,:,5),
+     & tab5t(:,:,6),tab5t(:,:,7),tab5t(:,:,8))
+          
+      Call Agrif_Addto_list_update(child%var%list_update,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim
+     &   ,tab4t,tab5t,memberinall,memberinall2,
+     &   sendtoproc1,recvfromproc1,sendtoproc2,recvfromproc2) 
+          
+      endif
+      
+c      Call Get_External_Data(tempP,tempPextend,tab5t(:,:,1),
+c     &            tab5t(:,:,2),
+c     &            tab5t(:,:,3),tab5t(:,:,4),nbdim,memberin,member,
+c     &            memberinall2)
+     
+      Call ExchangeSameLevel2(sendtoproc2,recvfromproc2,nbdim,
+     &            tab5t(:,:,3),tab5t(:,:,4),tab5t(:,:,5),tab5t(:,:,6),
+     &            tab5t(:,:,7),tab5t(:,:,8),member,tempP,
+     &            tempPextend)     
+
+#else
+      tempPextend%var => tempP%var
+      parentarray(:,1,1) = indmin
+      parentarray(:,2,1) = indmax
+      parentarray(:,1,2) = indmin
+      parentarray(:,2,2) = indmax
+      member = .TRUE.
+#endif
+
+C
+C
+C
+C     Special values on the child grid
+      if (Agrif_UseSpecialValueFineGrid) then
+C
+ccc         noraftab(1:nbdim) =
+ccc     &    child % var % root_var % interptab(1:nbdim) .EQ. 'N'
+C
+#ifdef AGRIF_MPI
+C
+c          Allocate(childvalues% var)
+C
+c          Call Agrif_nbdim_allocation(childvalues%var,
+c     &                      pttruetab,cetruetab,nbdim)
+c          Call Agrif_nbdim_Full_VarEQvar(childvalues% var,
+c     &                                tempC% var,
+c     &                                nbdim)
+c          Call Agrif_CheckMasknD(tempC,childvalues,
+c     &                           pttruetab(1:nbdim),cetruetab(1:nbdim),
+c     &                           pttruetab(1:nbdim),cetruetab(1:nbdim),
+c     &                           noraftab(1:nbdim),nbdim)
+c          Call Agrif_nbdim_deallocation(childvalues% var,nbdim)
+c         Deallocate(childvalues % var)
+C
+#else
+C
+c          Call Agrif_nbdim_Get_bound_dimension(child%var,
+c     &                              lowerbound,upperbound,nbdim)
+c          Call Agrif_CheckMasknD(tempC,child,
+c     &                           pttruetab(1:nbdim),cetruetab(1:nbdim),
+c     &                           lowerbound,
+c     &                           upperbound,
+c     &                           noraftab(1:nbdim),nbdim)
+C
+#endif
+C
+      endif
+
+
+C
+C
+C
+C
+C     Special values on the parent grid
+      if (Agrif_UseSpecialValue) then
+C
+#ifdef AGRIF_MPI
+C
+c          Call GiveAgrif_SpecialValueToTab_mpi(parent%var,tempP%var,
+c     &                 parentarray,
+c     &                 indmin,indmax,
+c     &                 Agrif_SpecialValue,nbdim)
+C
+C
+#else
+C
+c          Call GiveAgrif_SpecialValueToTab(parent%var,tempP%var,
+c     &                  indmin,indmax,
+c     &                  Agrif_SpecialValue,nbdim)
+C
+#endif
+C
+C
+      endif   
+C
+C
+        IF (member) THEN
+
+          IF (present(procname)) THEN
+            CALL Agrif_ChildGrid_to_ParentGrid()
+            SELECT CASE(nbdim)
+            CASE(1)
+            CALL procname(
+     &      tempPextend%var%array1(
+     &                      parentarray(1,1,1):parentarray(1,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            CASE(2)
+            CALL procname(
+     &      tempPextend%var%array2(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                      parentarray(2,1,2),parentarray(2,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            CASE(3)
+            CALL procname(
+     &      tempPextend%var%array3(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                      parentarray(2,1,2),parentarray(2,2,2),
+     &                      parentarray(3,1,2),parentarray(3,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            CASE(4)
+            CALL procname(
+     &      tempPextend%var%array4(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                      parentarray(2,1,2),parentarray(2,2,2),
+     &                      parentarray(3,1,2),parentarray(3,2,2),
+     &                      parentarray(4,1,2),parentarray(4,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            CASE(5)
+            CALL procname(
+     &      tempPextend%var%array5(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1),
+     &                      parentarray(5,1,1):parentarray(5,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                      parentarray(2,1,2),parentarray(2,2,2),
+     &                      parentarray(3,1,2),parentarray(3,2,2),
+     &                      parentarray(4,1,2),parentarray(4,2,2),
+     &                      parentarray(5,1,2),parentarray(5,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            CASE(6)
+            CALL procname(
+     &      tempPextend%var%array6(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1),
+     &                      parentarray(5,1,1):parentarray(5,2,1),
+     &                      parentarray(6,1,1):parentarray(6,2,1)),
+     &                      parentarray(1,1,2),parentarray(1,2,2),
+     &                      parentarray(2,1,2),parentarray(2,2,2),
+     &                      parentarray(3,1,2),parentarray(3,2,2),
+     &                      parentarray(4,1,2),parentarray(4,2,2),
+     &                      parentarray(5,1,2),parentarray(5,2,2),
+     &                      parentarray(6,1,2),parentarray(6,2,2),
+     &                                   .FALSE.,nbin,ndirin
+     &                      )
+            END SELECT
+            CALL Agrif_ParentGrid_to_ChildGrid()
+          ELSE
+            SELECT CASE(nbdim)
+            CASE(1)
+            parent%var%array1(parentarray(1,1,2):parentarray(1,2,2)) =
+     &      tempPextend%var%array1(
+     &                      parentarray(1,1,1):parentarray(1,2,1))
+            CASE(2)
+            parent%var%array2(parentarray(1,1,2):parentarray(1,2,2),
+     &                      parentarray(2,1,2):parentarray(2,2,2)) =
+     &      tempPextend%var%array2(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1))
+            CASE(3)
+            parent%var%array3(parentarray(1,1,2):parentarray(1,2,2),
+     &                      parentarray(2,1,2):parentarray(2,2,2),
+     &                      parentarray(3,1,2):parentarray(3,2,2)) =
+     &      tempPextend%var%array3(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1))
+            CASE(4)
+            parent%var%array4(parentarray(1,1,2):parentarray(1,2,2),
+     &                      parentarray(2,1,2):parentarray(2,2,2),
+     &                      parentarray(3,1,2):parentarray(3,2,2),
+     &                      parentarray(4,1,2):parentarray(4,2,2)) =
+     &      tempPextend%var%array4(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1))
+            CASE(5)
+            parent%var%array5(parentarray(1,1,2):parentarray(1,2,2),
+     &                      parentarray(2,1,2):parentarray(2,2,2),
+     &                      parentarray(3,1,2):parentarray(3,2,2),
+     &                      parentarray(4,1,2):parentarray(4,2,2),
+     &                      parentarray(5,1,2):parentarray(5,2,2)) =
+     &      tempPextend%var%array5(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1),
+     &                      parentarray(5,1,1):parentarray(5,2,1))
+            CASE(6)
+            parent%var%array6(parentarray(1,1,2):parentarray(1,2,2),
+     &                      parentarray(2,1,2):parentarray(2,2,2),
+     &                      parentarray(3,1,2):parentarray(3,2,2),
+     &                      parentarray(4,1,2):parentarray(4,2,2),
+     &                      parentarray(5,1,2):parentarray(5,2,2),
+     &                      parentarray(6,1,2):parentarray(6,2,2)) =
+     &      tempPextend%var%array6(
+     &                      parentarray(1,1,1):parentarray(1,2,1),
+     &                      parentarray(2,1,1):parentarray(2,2,1),
+     &                      parentarray(3,1,1):parentarray(3,2,1),
+     &                      parentarray(4,1,1):parentarray(4,2,1),
+     &                      parentarray(5,1,1):parentarray(5,2,1),
+     &                      parentarray(6,1,1):parentarray(6,2,1))
+            END SELECT
+          ENDIF
+
+        Call Agrif_nbdim_deallocation(tempPextend%var,nbdim)
+       ENDIF
+C
+C
+C     Deallocations
+
+      IF (memberin) THEN
+#ifdef AGRIF_MPI
+      Call Agrif_nbdim_deallocation(tempP%var,nbdim)
+      Call Agrif_nbdim_deallocation(tempC%var,nbdim)
+!      Deallocate(tempC % var)
+#endif
+!      Deallocate(tempP % var)
+      ENDIF
+#ifdef AGRIF_MPI
+!      Deallocate(tempPextend%var)
+!      IF (.Not.memberin) Deallocate(tempCextend%var)
+#endif
+
+C
+C
+      End Subroutine Agrif_UpdatenD
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Prtbounds
+C     **************************************************************************
+C
+      Subroutine Agrif_Prtbounds(nbdim,indmin,indmax,s_Parent_temp,
+     &                              s_Child_temp,s_Child,ds_Child,
+     &                              s_Parent,ds_Parent,
+     &                              pttruetab,cetruetab,pttab_Child,
+     &                              pttab_Parent,
+     &                              posvartab_child,TypeUpdate,
+     &                              loctab_Child
+#ifdef AGRIF_MPI
+     &                 ,pttruetabwhole,cetruetabwhole
+#endif
+     &                 )
+C
+CCC   Description:
+CCC   Subroutine calculating the bounds of the parent grid to be updated
+CCC   by the child grid     
+C
+C
+C     Declarations:
+C
+      
+C
+#ifdef AGRIF_MPI
+cccccccccccccccccccccccccc#include "mpif.h"
+#endif
+C
+C     Arguments
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim) :: indmin,indmax
+      REAL,DIMENSION(nbdim) :: s_Parent_temp,s_child_temp
+      REAL,DIMENSION(nbdim) :: s_Child,ds_child
+      REAL,DIMENSION(nbdim) :: s_Parent,ds_Parent
+      INTEGER,DIMENSION(nbdim) :: pttruetab,cetruetab
+      INTEGER,DIMENSION(nbdim) :: posvartab_child,TypeUpdate
+      INTEGER,DIMENSION(nbdim) :: loctab_Child
+      INTEGER,DIMENSION(nbdim) :: pttab_Child,pttab_Parent
+C
+C     Local variables
+      INTEGER :: i
+      REAL,DIMENSION(nbdim) :: dim_newmin,dim_newmax      
+#ifdef AGRIF_MPI
+      INTEGER,DIMENSION(nbdim)    :: pttruetabwhole,cetruetabwhole
+      REAL :: positionmin,positionmax
+      INTEGER :: imin,imax
+#endif
+C
+C
+      do i = 1,nbdim
+C
+        dim_newmin(i) = s_Child(i) + (pttruetab(i) -
+     &                                pttab_Child(i)) * ds_Child(i)
+C
+        dim_newmax(i) = s_Child(i) + (cetruetab(i) - 
+     &                                pttab_Child(i)) * ds_Child(i)
+C     
+        indmin(i) = pttab_Parent(i) +
+     &        agrif_ceiling((dim_newmin(i)-s_Parent(i))/ds_Parent(i))
+C
+        indmax(i) = pttab_Parent(i) +
+     &        agrif_int((dim_newmax(i)-s_Parent(i))/ds_Parent(i))
+C
+#ifdef AGRIF_MPI
+        positionmin = s_Parent(i) + (indmin(i)-
+     &                          pttab_Parent(i))*ds_Parent(i)
+        IF (loctab_Child(i) .NE. -3) THEN
+        IF (posvartab_child(i) == 1) THEN
+          IF (TypeUpdate(i) .EQ. Agrif_Update_Average) THEN
+          positionmin = positionmin - ds_Parent(i)/2.
+          ELSE IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+          positionmin = positionmin - (ds_Parent(i)-ds_Child(i))
+          ENDIF
+        ELSE
+        positionmin = positionmin - ds_Parent(i)/2.
+        IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+          positionmin = positionmin - ds_Child(i)
+        ENDIF
+        ENDIF
+        ENDIF
+        imin = pttab_Child(i) +
+     &        agrif_ceiling((positionmin-s_Child(i))/ds_Child(i))
+
+       positionmin = s_Child(i) + (imin -
+     &                                pttab_Child(i)) * ds_Child(i)
+
+        pttruetabwhole(i) = imin
+
+        positionmax = s_Parent(i) + (indmax(i)-
+     &                          pttab_Parent(i))*ds_Parent(i)
+        IF (loctab_Child(i) .NE. -3) THEN
+        IF (posvartab_child(i) == 1) THEN
+          IF (TypeUpdate(i) .EQ. Agrif_Update_Average) THEN
+        positionmax = positionmax  + ds_Parent(i)/2.
+          ELSE IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+          positionmax = positionmax  + (ds_Parent(i)-ds_Child(i))
+          ENDIF
+        ELSE
+        positionmax = positionmax  + ds_Parent(i)/2.
+        IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN
+          positionmax = positionmax + ds_Child(i)
+        ENDIF        
+        ENDIF
+        ENDIF
+        imax = pttab_Child(i) +
+     &        agrif_int((positionmax-s_Child(i))/ds_Child(i))
+
+        positionmax = s_Child(i) + (imax -
+     &                                pttab_Child(i)) * ds_Child(i)
+
+        cetruetabwhole(i) = imax
+
+#endif
+C
+        s_Parent_temp(i) = s_Parent(i) + 
+     &                     (indmin(i) - pttab_Parent(i)) * 
+     &                      ds_Parent(i) 
+C     
+        s_Child_temp(i) = dim_newmin(i)
+
+#ifdef AGRIF_MPI
+        s_Child_temp(i) = positionmin
+#endif
+C
+      enddo
+C
+      Return
+C
+C
+      End Subroutine Agrif_Prtbounds
+C
+C
+C
+C
+
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_Update_2D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_2D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 2D grid variable on the parent grid. 
+CCC   It calls Agrif_Update_1D_Recursive and Agrif_UpdateBase.   
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                indmin(2):indmax(2))           :: tempP
+C      REAL, DIMENSION(pttab_child(1):petab_child(1),
+C     &                pttab_child(2):petab_child(2)) :: tempC
+     
+      REAL, DIMENSION(:,:) :: tempC     
+C
+C     Local variables      
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                 pttab_child(2):petab_child(2)) :: tabtemp
+      REAL, DIMENSION(indmin(2):indmax(2),
+     &                indmin(1):indmax(1))           :: tempP_trsp
+      REAL, DIMENSION(pttab_child(2):petab_child(2),
+     &                 indmin(1):indmax(1)) :: tabtemp_trsp
+      INTEGER :: i,j
+      INTEGER :: coeffraf,locind_child_left
+C
+      tabtemp = 0.
+
+
+      coeffraf = nint ( ds_parent(1) / ds_child(1) ) 
+      IF((TypeUpdate(1) == AGRIF_Update_average) 
+     &                 .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         IF(.NOT. precomputedone(1) ) Call average1Dprecompute2D
+     &       (petab_child(2)-pttab_child(2)+1,
+     &        indmax(1)-indmin(1)+1,
+     &        petab_child(1)-pttab_child(1)+1,
+     &        s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+!---CDIR NEXPAND
+          Call average1Daftercompute
+     &       (  tabtemp, tempC,
+     &          size(tabtemp), size(tempC),
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+ 
+      ELSEIF((TypeUpdate(1) == AGRIF_Update_copy)
+     &                 .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         IF(.NOT. precomputedone(1) ) Call copy1Dprecompute2D
+     &       (petab_child(2)-pttab_child(2)+1,
+     &        indmax(1)-indmin(1)+1,
+     &        petab_child(1)-pttab_child(1)+1,
+     &        s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+!---CDIR NEXPAND
+          Call copy1Daftercompute
+     &       (  tabtemp, tempC,
+     &          size(tabtemp), size(tempC),
+     &          s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+
+      ELSE
+      do j = pttab_child(nbdim),petab_child(nbdim)
+C
+!---CDIR NEXPAND
+        Call Agrif_Update_1D_recursive(TypeUpdate(1:nbdim-1),    
+     &         tabtemp(:,j),
+     &         tempC(:,j-pttab_child(nbdim)+1),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C
+      enddo
+      ENDIF
+      tabtemp_trsp = TRANSPOSE(tabtemp) 
+      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim))
+    
+!---CDIR NEXPAND
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+C
+      
+      tempP_trsp = 0. 
+
+      IF((TypeUpdate(2) == AGRIF_Update_average)
+     &                .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         IF(.NOT. precomputedone(2) ) Call average1Dprecompute2D
+     &      ( indmax(1)-indmin(1)+1,
+     &        indmax(2)-indmin(2)+1,
+     &        petab_child(2)-pttab_child(2)+1,
+     &        s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+!---CDIR NEXPAND
+          Call average1Daftercompute
+     &       (  tempP_trsp, tabtemp_trsp,
+     &          size(tempP_trsp), size(tabtemp_trsp),
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+
+      ELSEIF((TypeUpdate(2) == AGRIF_Update_copy)
+     &                .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         IF(.NOT. precomputedone(2) ) Call copy1Dprecompute2D
+     &      ( indmax(1)-indmin(1)+1,
+     &        indmax(2)-indmin(2)+1,
+     &        petab_child(2)-pttab_child(2)+1,
+     &        s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+!---CDIR NEXPAND
+          Call copy1Daftercompute
+     &       (  tempP_trsp, tabtemp_trsp,
+     &          size(tempP_trsp), size(tabtemp_trsp),
+     &          s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+
+      ELSE
+
+      do i = indmin(1),indmax(1)
+C
+!---CDIR NEXPAND
+        Call Agrif_UpdateBase(TypeUpdate(2),
+     &           tempP_trsp(indmin(nbdim):indmax(nbdim),i),
+     &          tabtemp_trsp(pttab_child(nbdim):petab_child(nbdim),i),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+C        
+      enddo
+      
+      ENDIF
+
+      tempP = TRANSPOSE(tempP_trsp)
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_2D_recursive
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_Update_3D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_3D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,   
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 3D grid variable on the parent grid. 
+CCC   It calls Agrif_Update_2D_Recursive and Agrif_UpdateBase.   
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                indmin(2):indmax(2),
+     &                indmin(3):indmax(3))           :: tempP
+      REAL, DIMENSION(pttab_child(1):petab_child(1),
+     &                pttab_child(2):petab_child(2),
+     &                pttab_child(3):petab_child(3)) :: tempC
+C
+C     Local variables      
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                 indmin(2):indmax(2), 
+     &                 pttab_child(3):petab_child(3)) :: tabtemp
+      INTEGER :: i,j,k
+      INTEGER :: coeffraf,locind_child_left
+      INTEGER :: kdeb
+C
+C
+      coeffraf = nint ( ds_parent(1) / ds_child(1) )
+      IF((TypeUpdate(1) == AGRIF_Update_average)
+     &                 .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         Call average1Dprecompute2D
+     &       (petab_child(2)-pttab_child(2)+1,
+     &        indmax(1)-indmin(1)+1,
+     &        petab_child(1)-pttab_child(1)+1,
+     &        s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+      precomputedone(1) = .TRUE.
+      ELSEIF((TypeUpdate(1) == AGRIF_Update_copy)
+     &                 .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         Call copy1Dprecompute2D
+     &       (petab_child(2)-pttab_child(2)+1,
+     &        indmax(1)-indmin(1)+1,
+     &        petab_child(1)-pttab_child(1)+1,
+     &        s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
+      precomputedone(1) = .TRUE.
+      ENDIF
+
+      coeffraf = nint ( ds_parent(2) / ds_child(2) )
+      IF((TypeUpdate(2) == AGRIF_Update_average)
+     &                .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         Call average1Dprecompute2D
+     &      ( indmax(1)-indmin(1)+1,
+     &        indmax(2)-indmin(2)+1,
+     &        petab_child(2)-pttab_child(2)+1,
+     &        s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+      precomputedone(2) = .TRUE.
+      ELSEIF((TypeUpdate(2) == AGRIF_Update_copy)
+     &                .AND. (coeffraf /= 1 ))THEN
+!---CDIR NEXPAND
+         Call copy1Dprecompute2D
+     &      ( indmax(1)-indmin(1)+1,
+     &        indmax(2)-indmin(2)+1,
+     &        petab_child(2)-pttab_child(2)+1,
+     &        s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
+      precomputedone(2) = .TRUE.
+      ENDIF
+
+
+      do k = pttab_child(nbdim),petab_child(nbdim)
+C
+        Call Agrif_Update_2D_recursive(TypeUpdate(1:nbdim-1),    
+     &         tabtemp(:,:,k),
+     &         tempC(:,:,k),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C
+      enddo
+C
+      precomputedone(1) = .FALSE.
+      precomputedone(2) = .FALSE.
+      coeffraf = nint ( ds_parent(3) / ds_child(3) )
+
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+      
+      IF (coeffraf == 1) THEN
+      
+      kdeb = pttab_child(3)+locind_child_left-2
+      do k=indmin(3),indmax(3)
+      kdeb = kdeb + 1
+      do j = indmin(2),indmax(2)
+        do i = indmin(1),indmax(1)
+        tempP(i,j,k) = tabtemp(i,j,kdeb)
+      enddo
+      enddo
+      enddo
+              
+      ELSE
+      tempP = 0.
+C
+      do j = indmin(2),indmax(2)
+C
+        do i = indmin(1),indmax(1)
+C
+          Call Agrif_UpdateBase(TypeUpdate(3),
+     &           tempP(i,j,:),
+     &          tabtemp(i,j,:),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+C
+        enddo 
+C        
+      enddo
+      ENDIF
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_3D_recursive
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_Update_4D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_4D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,   
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 4D grid variable on the parent grid. 
+CCC   It calls Agrif_Update_3D_Recursive and Agrif_UpdateBase.    
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                indmin(2):indmax(2),
+     &                indmin(3):indmax(3),
+     &                indmin(4):indmax(4))           :: tempP
+      REAL, DIMENSION(pttab_child(1):petab_child(1),
+     &                pttab_child(2):petab_child(2),
+     &                pttab_child(3):petab_child(3),
+     &                pttab_child(4):petab_child(4)) :: tempC
+C
+C     Local variables      
+      REAL, DIMENSION(:,:,:,:), Allocatable :: tabtemp
+      INTEGER :: i,j,k,l
+      INTEGER :: coeffraf,locind_child_left
+C
+C
+      Allocate(tabtemp(indmin(1):indmax(1),
+     &                 indmin(2):indmax(2),
+     &                 indmin(3):indmax(3), 
+     &                 pttab_child(4):petab_child(4)))
+C
+      do l = pttab_child(nbdim),petab_child(nbdim)
+C
+        Call Agrif_Update_3D_recursive(TypeUpdate(1:nbdim-1),    
+     &         tabtemp(indmin(nbdim-3):indmax(nbdim-3),
+     &                 indmin(nbdim-2):indmax(nbdim-2),
+     &                 indmin(nbdim-1):indmax(nbdim-1),l),
+     &         tempC(pttab_child(nbdim-3):petab_child(nbdim-3),
+     &               pttab_child(nbdim-2):petab_child(nbdim-2),
+     &               pttab_child(nbdim-1):petab_child(nbdim-1),l),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C
+      enddo
+      
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+C
+      tempP = 0.
+
+      do k = indmin(3),indmax(3)
+C
+        do j = indmin(2),indmax(2)
+C
+          do i = indmin(1),indmax(1)
+C
+            Call Agrif_UpdateBase(TypeUpdate(4),
+     &           tempP(i,j,k,indmin(nbdim):indmax(nbdim)),
+     &          tabtemp(i,j,k,pttab_child(nbdim):petab_child(nbdim)),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+C
+          enddo 
+C
+        enddo 
+C        
+      enddo
+C
+      Deallocate(tabtemp)
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_4D_recursive
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_Update_5D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_5D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,   
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 5D grid variable on the parent grid. 
+CCC   It calls Agrif_Update_4D_Recursive and Agrif_UpdateBase.    
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                indmin(2):indmax(2),
+     &                indmin(3):indmax(3),
+     &                indmin(4):indmax(4),
+     &                indmin(5):indmax(5))           :: tempP
+      REAL, DIMENSION(pttab_child(1):petab_child(1),
+     &                pttab_child(2):petab_child(2),
+     &                pttab_child(3):petab_child(3),
+     &                pttab_child(4):petab_child(4),
+     &                pttab_child(5):petab_child(5)) :: tempC
+C
+C     Local variables      
+      REAL, DIMENSION(:,:,:,:,:), Allocatable :: tabtemp
+      INTEGER :: i,j,k,l,m
+      INTEGER :: coeffraf,locind_child_left
+C
+C
+      Allocate(tabtemp(indmin(1):indmax(1),
+     &                 indmin(2):indmax(2),
+     &                 indmin(3):indmax(3),
+     &                 indmin(4):indmax(4),   
+     &                 pttab_child(5):petab_child(5)))
+C
+      do m = pttab_child(nbdim),petab_child(nbdim)
+C
+        Call Agrif_Update_4D_recursive(TypeUpdate(1:nbdim-1),    
+     &         tabtemp(indmin(nbdim-4):indmax(nbdim-4),
+     &                 indmin(nbdim-3):indmax(nbdim-3),
+     &                 indmin(nbdim-2):indmax(nbdim-2),
+     &                 indmin(nbdim-1):indmax(nbdim-1),m),
+     &         tempC(pttab_child(nbdim-4):petab_child(nbdim-4),
+     &               pttab_child(nbdim-3):petab_child(nbdim-3),
+     &               pttab_child(nbdim-2):petab_child(nbdim-2),
+     &               pttab_child(nbdim-1):petab_child(nbdim-1),m),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C
+      enddo
+      
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+      tempP = 0.
+C
+      do l = indmin(4),indmax(4)
+C
+        do k = indmin(3),indmax(3)
+C
+          do j = indmin(2),indmax(2)
+C
+            do i = indmin(1),indmax(1)
+C
+              Call Agrif_UpdateBase(TypeUpdate(5),
+     &           tempP(i,j,k,l,indmin(nbdim):indmax(nbdim)),
+     &          tabtemp(i,j,k,l,
+     &                   pttab_child(nbdim):petab_child(nbdim)),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+C
+            enddo
+C
+          enddo 
+C
+        enddo 
+C        
+      enddo
+C
+      Deallocate(tabtemp)
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_5D_recursive
+C
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_Update_6D_Recursive 
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_6D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,   
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 6D grid variable on the parent grid. 
+CCC   It calls Agrif_Update_5D_Recursive and Agrif_UpdateBase.    
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C     
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(1):indmax(1),
+     &                indmin(2):indmax(2),
+     &                indmin(3):indmax(3),
+     &                indmin(4):indmax(4),
+     &                indmin(5):indmax(5),
+     &                indmin(6):indmax(6))           :: tempP
+      REAL, DIMENSION(pttab_child(1):petab_child(1),
+     &                pttab_child(2):petab_child(2),
+     &                pttab_child(3):petab_child(3),
+     &                pttab_child(4):petab_child(4),
+     &                pttab_child(5):petab_child(5),
+     &                pttab_child(6):petab_child(6)) :: tempC
+C
+C     Local variables      
+      REAL, DIMENSION(:,:,:,:,:,:), Allocatable :: tabtemp
+      INTEGER :: i,j,k,l,m,n
+      INTEGER :: coeffraf,locind_child_left
+C
+C
+      Allocate(tabtemp(indmin(1):indmax(1),
+     &                 indmin(2):indmax(2),
+     &                 indmin(3):indmax(3),
+     &                 indmin(4):indmax(4),   
+     &                 indmin(5):indmax(5),   
+     &                 pttab_child(6):petab_child(6)))
+C
+      do n = pttab_child(nbdim),petab_child(nbdim)
+C
+        Call Agrif_Update_5D_recursive(TypeUpdate(1:nbdim-1),    
+     &         tabtemp(indmin(nbdim-5):indmax(nbdim-5),
+     &                 indmin(nbdim-4):indmax(nbdim-4),
+     &                 indmin(nbdim-3):indmax(nbdim-3),
+     &                 indmin(nbdim-2):indmax(nbdim-2),
+     &                 indmin(nbdim-1):indmax(nbdim-1),n),
+     &         tempC(pttab_child(nbdim-5):petab_child(nbdim-5),
+     &               pttab_child(nbdim-4):petab_child(nbdim-4),
+     &               pttab_child(nbdim-3):petab_child(nbdim-3),
+     &               pttab_child(nbdim-2):petab_child(nbdim-2),
+     &               pttab_child(nbdim-1):petab_child(nbdim-1),n),
+     &         indmin(1:nbdim-1),indmax(1:nbdim-1),
+     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1),
+     &         s_child(1:nbdim-1),s_parent(1:nbdim-1),
+     &         ds_child(1:nbdim-1),ds_parent(1:nbdim-1),nbdim-1)
+C
+      enddo
+      
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+C
+      tempP = 0.
+
+      do m = indmin(5),indmax(5)
+      do l = indmin(4),indmax(4)
+C
+        do k = indmin(3),indmax(3)
+C
+          do j = indmin(2),indmax(2)
+C
+            do i = indmin(1),indmax(1)
+C
+              Call Agrif_UpdateBase(TypeUpdate(6),
+     &           tempP(i,j,k,l,m,indmin(nbdim):indmax(nbdim)),
+     &          tabtemp(i,j,k,l,m,
+     &                   pttab_child(nbdim):petab_child(nbdim)),
+     &           indmin(nbdim),indmax(nbdim),
+     &           pttab_child(nbdim),petab_child(nbdim),
+     &           s_parent(nbdim),s_child(nbdim),
+     &           ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+C
+            enddo
+C
+          enddo 
+C
+        enddo 
+C        
+      enddo
+      enddo
+C
+      Deallocate(tabtemp)
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_6D_recursive
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Agrif_UpdateBase  
+C     **************************************************************************  
+C  
+      Subroutine Agrif_UpdateBase(TypeUpdate,
+     &                            parenttab,childtab,
+     &                            indmin,indmax,pttab_child,petab_child,
+     &                            s_parent,s_child,ds_parent,ds_child,
+     &                            coeffraf,locind_child_left)
+C
+CCC   Description:
+CCC   Subroutine calling the updating method chosen by the user (copy, average
+CCC   or full-weighting).    
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C
+      INTEGER :: TypeUpdate
+      INTEGER :: indmin,indmax
+      INTEGER :: pttab_child,petab_child
+      REAL,DIMENSION(indmin:indmax)           :: parenttab       
+      REAL,DIMENSION(pttab_child:petab_child) :: childtab      
+      REAL    :: s_parent,s_child
+      REAL    :: ds_parent,ds_child      
+      INTEGER :: coeffraf,locind_child_left
+C
+C
+      if (TypeUpdate == AGRIF_Update_copy) then
+C             
+          Call agrif_copy1D
+     &       (parenttab,childtab,
+     &          indmax-indmin+1,petab_child-pttab_child+1,
+     &          s_parent,s_child,ds_parent,ds_child)     
+C
+        elseif (TypeUpdate == AGRIF_Update_average) then
+C           
+          Call average1D
+     &       (parenttab,childtab,
+     &          indmax-indmin+1,petab_child-pttab_child+1,
+     &          s_parent,s_child,ds_parent,ds_child) 
+C
+        elseif (TypeUpdate == AGRIF_Update_full_weighting) then
+C             
+          Call full_weighting1D
+     &       (parenttab,childtab,
+     &          indmax-indmin+1,petab_child-pttab_child+1,
+     &          s_parent,s_child,ds_parent,ds_child,
+     &          coeffraf,locind_child_left)
+C
+      endif 
+C
+      Return                
+C
+C      
+      End Subroutine Agrif_UpdateBase
+C
+C
+
+      Subroutine Agrif_Compute_nbdim_update(s_parent,s_child,
+     &  ds_parent,ds_child,coeffraf,locind_child_left)
+      real :: s_parent,s_child,ds_parent,ds_child
+      integer :: coeffraf,locind_child_left
+     
+      coeffraf = nint(ds_parent/ds_child)
+      locind_child_left = 1 + agrif_int((s_parent-s_child)/ds_child)
+      
+      End Subroutine Agrif_Compute_nbdim_update
+ 
+#if defined AGRIF_MPI      
+      Subroutine Agrif_Find_list_update(list_update,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim,
+     &     find_list_update,tab4t,tab5t,memberinall,memberinall2,
+     &     sendtoproc1,recvfromproc1,sendtoproc2,recvfromproc2)     
+      TYPE(Agrif_List_Interp_Loc), Pointer :: list_update
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent
+      LOGICAL :: find_list_update
+      Type(Agrif_List_Interp_loc), Pointer :: parcours
+      INTEGER :: i
+C
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab5t      
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall,memberinall2
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1,recvfromproc1      
+      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc2,recvfromproc2      
+                    
+      find_list_update = .FALSE.
+      
+      parcours => list_update
+      
+      Find_loop :   Do While (associated(parcours))
+        Do i=1,nbdim
+          IF ((pttab(i) /= parcours%interp_loc%pttab(i)).OR.
+     &        (petab(i) /= parcours%interp_loc%petab(i)).OR.
+     &        (pttab_child(i) /= parcours%interp_loc%pttab_child(i)).OR.
+     &        (pttab_parent(i) /= parcours%interp_loc%pttab_parent(i)))
+     &               THEN
+            parcours=>parcours%suiv
+            Cycle Find_loop
+          ENDIF
+        EndDo
+        
+        tab4t = parcours%interp_loc%tab4t(1:nbdim,0:Agrif_Nbprocs-1,1:8)
+        memberinall = parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1)
+        
+        tab5t = parcours%interp_loc%tab5t(1:nbdim,0:Agrif_Nbprocs-1,1:8)
+        memberinall2 = 
+     &       parcours%interp_loc%memberinall2(0:Agrif_Nbprocs-1)
+        sendtoproc1 = 
+     &       parcours%interp_loc%sendtoproc1(0:Agrif_Nbprocs-1)   
+        recvfromproc1 = 
+     &       parcours%interp_loc%recvfromproc1(0:Agrif_Nbprocs-1)     
+        sendtoproc2 = 
+     &       parcours%interp_loc%sendtoproc2(0:Agrif_Nbprocs-1)   
+        recvfromproc2 = 
+     &       parcours%interp_loc%recvfromproc2(0:Agrif_Nbprocs-1)          
+        
+        find_list_update = .TRUE.   
+        Exit Find_loop
+      End Do Find_loop  
+                              
+      End Subroutine Agrif_Find_list_update  
+      
+      Subroutine Agrif_AddTo_list_update(list_update,pttab,petab,
+     &                          pttab_Child,pttab_Parent,nbdim
+     &      ,tab4t,tab5t,memberinall,memberinall2,
+     &      sendtoproc1,recvfromproc1,sendtoproc2,recvfromproc2)
+          
+      TYPE(Agrif_List_Interp_Loc), Pointer :: list_update
+      INTEGER :: nbdim
+      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
+      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab5t      
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: memberinall, memberinall2
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1, recvfromproc1      
+      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc2, recvfromproc2
+
+      Type(Agrif_List_Interp_loc), Pointer :: parcours
+            
+       Allocate(parcours)
+      Allocate(parcours%interp_loc)
+      
+      parcours%interp_loc%pttab(1:nbdim) = pttab(1:nbdim)
+      parcours%interp_loc%petab(1:nbdim) = petab(1:nbdim)
+      parcours%interp_loc%pttab_child(1:nbdim) = pttab_child(1:nbdim)
+      parcours%interp_loc%pttab_parent(1:nbdim) = pttab_parent(1:nbdim)
+      Allocate(parcours%interp_loc%tab4t(nbdim,0:Agrif_Nbprocs-1,8))
+      Allocate(parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1))
+      
+      Allocate(parcours%interp_loc%tab5t(nbdim,0:Agrif_Nbprocs-1,8))
+      Allocate(parcours%interp_loc%memberinall2(0:Agrif_Nbprocs-1))
+      Allocate(parcours%interp_loc%sendtoproc1(0:Agrif_Nbprocs-1))
+      Allocate(parcours%interp_loc%recvfromproc1(0:Agrif_Nbprocs-1))      
+      Allocate(parcours%interp_loc%sendtoproc2(0:Agrif_Nbprocs-1))
+      Allocate(parcours%interp_loc%recvfromproc2(0:Agrif_Nbprocs-1))            
+            
+      parcours%interp_loc%tab4t=tab4t   
+      parcours%interp_loc%memberinall=memberinall
+ 
+      parcours%interp_loc%tab5t=tab5t   
+      parcours%interp_loc%memberinall2=memberinall2
+      parcours%interp_loc%sendtoproc1=sendtoproc1   
+      parcours%interp_loc%recvfromproc1=recvfromproc1      
+      parcours%interp_loc%sendtoproc2=sendtoproc2       
+      parcours%interp_loc%recvfromproc2=recvfromproc2      
+            
+      parcours%suiv => list_update
+      
+      list_update => parcours
+      
+      End Subroutine Agrif_Addto_list_update
+#endif
+           
+
+C     **************************************************************************
+CCC   Subroutine Agrif_Update_1D_Recursive
+C     **************************************************************************
+C
+      Subroutine Agrif_Update_1D_recursive(TypeUpdate,tempP,tempC,
+     &                                     indmin,indmax,
+     &                                     pttab_child,petab_child,
+     &                                     s_child,s_parent,
+     &                                     ds_child,ds_parent,nbdim)
+C
+CCC   Description:
+CCC   Subroutine to update a 1D grid variable on the parent grid.
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C
+C     Arguments
+      INTEGER                   :: nbdim
+      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average)
+      INTEGER, DIMENSION(nbdim) :: indmin,indmax
+      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child
+      REAL, DIMENSION(nbdim)    :: s_child,s_parent
+      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent
+      REAL, DIMENSION(indmin(nbdim):indmax(nbdim))           :: tempP
+      REAL, DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tempC
+      INTEGER :: coeffraf,locind_child_left
+C
+C
+      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim),
+     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left)
+      
+      Call Agrif_UpdateBase(TypeUpdate(1),
+     &                  tempP(indmin(nbdim):indmax(nbdim)),
+     &                  tempC(pttab_child(nbdim):petab_child(nbdim)),
+     &                  indmin(nbdim),indmax(nbdim),           
+     &                  pttab_child(nbdim),petab_child(nbdim),
+     &                  s_parent(nbdim),s_child(nbdim),
+     &                  ds_parent(nbdim),ds_child(nbdim),
+     &                  coeffraf,locind_child_left)
+
+C
+      Return
+C
+C
+      End Subroutine Agrif_Update_1D_recursive      
+
+      End Module Agrif_Update
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdatebasic.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdatebasic.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modupdatebasic.F	(revision 1844)
@@ -0,0 +1,646 @@
+!
+! $Id$
+!
+C     AGRIF (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place -  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Updatebasic
+C      
+C
+      Module Agrif_Updatebasic
+C
+CCC   Description:
+CCC   Module containing different procedures of update (copy,average,
+CCC   full_weighting) used in the Agrif_Update module.
+C
+C     Modules used:
+C
+      USE Agrif_types
+      
+      IMPLICIT NONE
+      
+      integer,dimension(:,:),allocatable :: indchildcopy
+      integer,dimension(:,:),allocatable :: indchildaverage
+C             
+
+      CONTAINS
+C     Define procedures contained in this module
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Copy1d  
+C     ************************************************************************** 
+C
+      Subroutine agrif_copy1d(x,y,np,nc,
+     &                  s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do a copy on a parent grid (vector x) from its child grid 
+CCC   (vector y).  
+C
+CC    Method:
+C
+C     Declarations:
+C
+      
+C        
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL, DIMENSION(np) :: x      
+      REAL, DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+C
+      if (coeffraf == 1) then
+C
+          locind_child_left = 1 + nint((s_parent - s_child)/ds_child)
+C        
+!CDIR ALTCODE
+          x(1:np) = y(locind_child_left:locind_child_left+np-1)
+C
+          return
+C
+      endif
+C
+      
+      locind_child_left = 1 + nint((s_parent - s_child)/ds_child)
+      
+!CDIR ALTCODE
+      do i = 1,np
+C      
+         x(i) = y(locind_child_left)
+C
+         locind_child_left = locind_child_left + coeffraf
+C         
+      enddo    
+       
+C
+      Return 
+C
+C
+      End Subroutine agrif_copy1d
+
+C     **************************************************************************  
+CCC   Subroutine Copy1dprecompute  
+C     ************************************************************************** 
+C
+      Subroutine copy1dprecompute2d(nc2,np,nc,
+     &                  s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to precompute index for a copy on a parent grid (vector x) from
+CCC   its child grid (vector y).
+C
+CC    Method:
+C
+C     Declarations:
+C
+
+C        
+C     Arguments
+      INTEGER             :: nc2,np,nc
+      INTEGER             :: dir   
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER,DIMENSION(:,:),ALLOCATABLE :: indchildcopy_tmp
+      INTEGER :: i,locind_child_left,coeffraf
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+C
+      locind_child_left = 1 + nint((s_parent - s_child)/ds_child)
+
+      if (.not.allocated(indchildcopy)) then
+      allocate(indchildcopy(np*nc2,3))
+      else
+      if (size(indchildcopy,1)<np*nc2) then
+      allocate( indchildcopy_tmp(
+     &         size(indchildcopy,1),size(indchildcopy,2)))
+      indchildcopy_tmp = indchildcopy
+      deallocate(indchildcopy)
+      allocate(indchildcopy(np*nc2,3))
+      indchildcopy(1:size(indchildcopy_tmp,1),
+     &              1:size(indchildcopy_tmp,2)) = indchildcopy_tmp
+      deallocate(indchildcopy_tmp)
+      endif
+      endif
+
+
+      do i = 1,np
+C      
+         indchildcopy(i,dir) = locind_child_left
+         locind_child_left = locind_child_left + coeffraf
+C         
+      enddo
+
+      do i =2, nc2
+        indchildcopy(1+(i-1)*np:i*np,dir)=
+     &       indchildcopy(1+(i-2)*np:(i-1)*np,dir) + nc 
+      enddo
+
+C
+      Return
+C
+C
+      End Subroutine copy1dprecompute2d
+
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Copy1dprecompute  
+C     ************************************************************************** 
+C
+      Subroutine copy1dprecompute(np,nc,
+     &                  s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to precompute index for a copy on a parent grid (vector x) from
+CCC   its child grid (vector y).
+C
+CC    Method:
+C
+C     Declarations:
+C
+
+C        
+C     Arguments
+      INTEGER             :: np,nc
+      INTEGER             :: dir
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+C
+      locind_child_left = 1 + nint((s_parent - s_child)/ds_child)
+
+      if (.not.allocated(indchildcopy)) then
+      allocate(indchildcopy(np,1))
+      else
+      if (size(indchildcopy)<np) then
+      deallocate(indchildcopy)
+      allocate(indchildcopy(np,1))
+      endif
+      endif
+
+!CDIR ALTCODE
+      do i = 1,np
+C      
+         indchildcopy(i,1) = locind_child_left
+         locind_child_left = locind_child_left + coeffraf
+C         
+      enddo
+
+C
+      Return
+C
+C
+      End Subroutine copy1dprecompute
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Copy1daftercompute  
+C     ************************************************************************** 
+C
+      Subroutine copy1daftercompute(x,y,np,nc,
+     &                  s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to do a copy on a parent grid (vector x) from its child grid 
+CCC   (vector y) using precomputed index.  
+C
+CC    Method:
+C
+C     Declarations:
+C
+  
+C        
+C     Arguments
+      INTEGER             :: np,nc
+      INTEGER             :: dir
+      REAL, DIMENSION(np) :: x
+      REAL, DIMENSION(nc) :: y
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i
+C 
+C
+      
+!CDIR ALTCODE
+      do i = 1,np
+C      
+         x(i) = y(indchildcopy(i,dir))
+C
+      enddo
+  
+C
+      Return
+C
+C
+      End Subroutine copy1daftercompute
+
+
+C
+C     **************************************************************************  
+CCC   Subroutine Average1d  
+C     ************************************************************************** 
+C   
+      Subroutine average1d(x,y,np,nc,
+     &                     s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do an update by average on a parent grid (vector x)from its 
+CCC   child grid (vector y).
+C
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL, DIMENSION(np) :: x      
+      REAL, DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf,ii
+      REAL    :: xpos, invcoeffraf 
+      INTEGER :: nbnonnuls
+      INTEGER :: diffmod
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+      invcoeffraf = 1./coeffraf
+C
+      if (coeffraf == 1) then
+C
+          locind_child_left = 1 + nint((s_parent - s_child)/ds_child)
+C        
+          x(1:np) = y(locind_child_left:locind_child_left+np-1)
+C
+          return
+C
+      endif
+C
+      xpos = s_parent      
+      
+      x = 0.
+C
+      diffmod = 0
+      
+      IF ( mod(coeffraf,2) == 0 ) diffmod = 1
+
+        locind_child_left = 1 + agrif_int((xpos - s_child)/ds_child)
+C
+      IF (Agrif_UseSpecialValueInUpdate) THEN
+
+      do i = 1,np
+          nbnonnuls = 0
+!CDIR NOVECTOR
+          Do ii = -coeffraf/2+locind_child_left+diffmod,
+     &                coeffraf/2+locind_child_left
+C 
+               IF (y(ii) .NE. Agrif_SpecialValueFineGrid) THEN
+               nbnonnuls = nbnonnuls + 1
+               x(i) = x(i) + y(ii)
+               ENDIF
+          End Do
+               IF (nbnonnuls .NE. 0) THEN
+                  x(i) = x(i)/nbnonnuls
+               ELSE
+                  x(i) = Agrif_SpecialValueFineGrid
+               ENDIF
+        locind_child_left = locind_child_left + coeffraf
+      enddo
+
+      ELSE 
+
+!CDIR ALTCODE
+      do i = 1,np
+!CDIR NOVECTOR
+          Do ii = -coeffraf/2+locind_child_left+diffmod,
+     &                coeffraf/2+locind_child_left
+C 
+               x(i) = x(i) + y(ii)
+          End Do
+                 x(i) = x(i)*invcoeffraf
+        locind_child_left = locind_child_left + coeffraf
+      enddo
+
+      ENDIF
+
+      Return 
+C            
+C     
+      End Subroutine average1d
+      
+      Subroutine average1dprecompute2d(nc2,np,nc,
+     &                     s_parent,s_child,ds_parent,ds_child,dir)
+C
+CCC   Description:
+CCC   Subroutine to do an update by average on a parent grid (vector x)from its 
+CCC   child grid (vector y).
+C
+C     Arguments
+      INTEGER             :: nc2,np,nc,dir
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf,ii
+      INTEGER,DIMENSION(:,:),ALLOCATABLE :: indchildaverage_tmp
+      REAL    :: xpos, invcoeffraf
+      INTEGER :: nbnonnuls
+      INTEGER :: diffmod
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+C
+      xpos = s_parent
+C
+      diffmod = 0
+
+      IF ( mod(coeffraf,2) == 0 ) diffmod = 1
+
+      locind_child_left = 1 + agrif_int((xpos - s_child)/ds_child)
+
+      if (.not.allocated(indchildaverage)) then
+      allocate(indchildaverage(np*nc2,3))
+      else
+      if (size(indchildaverage,1)<np*nc2) then
+      allocate( indchildaverage_tmp(
+     &         size(indchildaverage,1),size(indchildaverage,2)))
+      indchildaverage_tmp = indchildaverage
+      deallocate(indchildaverage)
+      allocate(indchildaverage(np*nc2,3))
+      indchildaverage(1:size(indchildaverage_tmp,1),
+     &              1:size(indchildaverage_tmp,2)) = indchildaverage_tmp
+      deallocate(indchildaverage_tmp)
+      endif
+      endif
+
+      do i = 1,np
+        indchildaverage(i,dir)= -coeffraf/2+locind_child_left
+     &                                    +diffmod
+        locind_child_left = locind_child_left + coeffraf
+      enddo
+      do i = 2,nc2
+        indchildaverage(1+(i-1)*np:i*np,dir)= 
+     &                 indchildaverage(1+(i-2)*np:(i-1)*np,dir) + nc 
+      enddo
+
+      Return 
+C            
+C     
+      End Subroutine average1dprecompute2d
+      
+
+      Subroutine average1dprecompute(np,nc,
+     &                     s_parent,s_child,ds_parent,ds_child) 
+C
+CCC   Description:
+CCC   Subroutine to do an update by average on a parent grid (vector x)from its 
+CCC   child grid (vector y).
+C
+C     Arguments
+      INTEGER             :: np,nc 
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf,ii
+      REAL    :: xpos, invcoeffraf 
+      INTEGER :: nbnonnuls
+      INTEGER :: diffmod
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+
+C
+      if (coeffraf == 1) then
+C
+          return
+C
+      endif
+            
+C
+      xpos = s_parent
+C
+      diffmod = 0
+      
+      IF ( mod(coeffraf,2) == 0 ) diffmod = 1
+
+        locind_child_left = 1 + agrif_int((xpos - s_child)/ds_child)
+
+      if (.not.allocated(indchildaverage)) then
+      allocate(indchildaverage(np,1))
+      else
+      if (size(indchildaverage,1)<np) then
+      deallocate(indchildaverage)
+      allocate(indchildaverage(np,1))
+      endif
+      endif
+      
+!CDIR ALTCODE
+      do i = 1,np
+C 
+        indchildaverage(i,1)=-coeffraf/2+locind_child_left+diffmod
+        locind_child_left = locind_child_left + coeffraf
+      enddo
+
+      Return 
+C            
+C     
+      End Subroutine average1dprecompute
+      
+      Subroutine average1daftercompute(x,y,np,nc,
+     &                     s_parent,s_child,ds_parent,ds_child,dir) 
+C
+CCC   Description:
+CCC   Subroutine to do an update by average on a parent grid (vector x)from its 
+CCC   child grid (vector y).
+C
+C     Arguments
+      INTEGER             :: np,nc,dir      
+      REAL, DIMENSION(np) :: x      
+      REAL, DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf,ii,j
+      REAL    :: xpos, invcoeffraf 
+      REAL, PARAMETER :: one_third=1./3.
+      INTEGER, DIMENSION(np) :: nbnonnuls
+      INTEGER :: diffmod
+      REAL, DIMENSION(0:5) :: invcoeff=(/1.,1.,0.5,one_third,0.25,0.2/)
+C 
+C
+      coeffraf = nint(ds_parent/ds_child)
+      invcoeffraf = 1./coeffraf      
+C      
+C
+      IF (Agrif_UseSpecialValueInUpdate) THEN
+
+      nbnonnuls = 0
+      do  j =1, coeffraf
+          do i=1, np
+               IF (y(indchildaverage(i,dir) + j -1) .NE. 
+     &               Agrif_SpecialValueFineGrid) THEN
+               nbnonnuls(i) = nbnonnuls(i) + 1
+               x(i) = x(i) +  y(indchildaverage(i,dir) + j -1 )
+               ENDIF
+          End Do
+      enddo
+      do i=1,np
+      x(i)= x(i)*invcoeff(nbnonnuls(i)) 
+      enddo
+
+      ELSE
+!CDIR NOLOOPCHG
+      do  j =1, coeffraf
+!CDIR VECTOR
+          do i=1, np
+             x(i) = x(i) + y(indchildaverage(i,dir) + j -1 )
+          enddo
+      enddo
+       x = x * invcoeffraf
+      ENDIF
+
+      Return 
+C            
+C     
+      End Subroutine average1daftercompute            
+C
+C
+C
+C     **************************************************************************  
+CCC   Subroutine Full_weighting1d  
+C     **************************************************************************  
+C
+      Subroutine full_weighting1D(x,y,np,nc,
+     &                            s_parent,s_child,ds_parent,ds_child,
+     &                            coeffraf,locind_child_left) 
+C
+CCC   Description:
+CCC   Subroutine to do an update by full_weighting on a parent grid (vector x) 
+CCC   from its child grid (vector y).
+C 
+C     Arguments
+      INTEGER             :: np,nc      
+      REAL, DIMENSION(np) :: x      
+      REAL, DIMENSION(nc) :: y  
+      REAL                :: s_parent,s_child
+      REAL                :: ds_parent,ds_child
+C
+C     Local variables
+      INTEGER :: i,locind_child_left,coeffraf
+      REAL    :: xpos,sumweight,weight
+      INTEGER :: ii,diffmod
+      REAL :: xposfin
+      INTEGER :: it1,it2
+      INTEGER :: i1,i2
+      REAL :: invsumweight
+      REAL :: weights(-(coeffraf-1):coeffraf-1)
+      
+C
+C
+      if (coeffraf == 1) then
+C        
+          x(1:np) = y(locind_child_left:locind_child_left+np-1)
+C
+          return
+C
+      endif
+C
+      xpos = s_parent      
+      
+       x = 0.
+
+       xposfin = s_child + ds_child * (locind_child_left - 1)
+       IF (abs(xposfin - xpos).LT.0.001) THEN
+          diffmod = 0
+       ELSE
+          diffmod = 1
+       ENDIF
+C
+             
+       it1 = -(coeffraf-1)
+       i1 = -(coeffraf-1)+locind_child_left+diffmod
+       i2 = 2*coeffraf - 2
+       
+      invsumweight=1./coeffraf**2
+      do i=-(coeffraf-1),0
+        weights(i) = invsumweight*(coeffraf + i)
+      enddo
+      do i=1,coeffraf-1
+        weights(i) = invsumweight*(coeffraf - i)
+      enddo
+
+      sumweight = 0                    
+      do i = 1,np
+C
+          it2 = it1
+          Do ii = i1,i1+i2
+C
+           IF (Agrif_UseSpecialValueInUpdate) THEN
+            IF (y(ii) .NE. Agrif_SpecialValueFineGrid) THEN
+               x(i) = x(i) + weights(it2)*y(ii)
+               sumweight = sumweight+weights(it2)
+            ENDIF
+           ELSE           
+               x(i) = x(i) + weights(it2)*y(ii)
+           ENDIF           
+           
+          it2 = it2+1
+          End Do
+
+           IF (Agrif_UseSpecialValueInUpdate) THEN          
+                 IF (sumweight .NE. 0.) THEN
+                    x(i) = x(i)/sumweight
+                    sumweight = 0
+                 ELSE
+                    x(i) = Agrif_SpecialValueFineGrid
+                 ENDIF
+           ENDIF
+        
+        i1 = i1 + coeffraf
+C
+      enddo    
+C
+      Return 
+C            
+C
+      End Subroutine full_weighting1D 
+
+C
+      End module AGRIF_updatebasic
Index: /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modutil.F
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modutil.F	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/AGRIF_FILES/modutil.F	(revision 1844)
@@ -0,0 +1,816 @@
+!
+! $Id$
+!
+C     Agrif (Adaptive Grid Refinement In Fortran)
+C
+C     Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr)
+C                        Christophe Vouland (Christophe.Vouland@imag.fr)    
+C
+C     This program is free software; you can redistribute it and/or modify
+C     it under the terms of the GNU General Public License as published by
+C     the Free Software Foundation; either version 2 of the License, or
+C     (at your option) any later version.
+C
+C     This program is distributed in the hope that it will be useful,
+C     but WITHOUT ANY WARRANTY; without even the implied warranty of
+C     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+C     GNU General Public License for more details.
+C
+C     You should have received a copy of the GNU General Public License
+C     along with this program; if not, write to the Free Software
+C     Foundation, Inc., 59 Temple Place-  Suite 330, Boston, MA 02111-1307, USA.
+C
+C
+C
+CCC   Module Agrif_Util 
+C 
+      Module Agrif_Util 
+C
+C
+CCC   Description:   
+CCC   This module contains the two procedures called in the main program : 
+CCC   Agrif_Init_Grids allowing the initialization of the root coarse grid, and
+CCC   Agrif_Step allowing the creation of the grid hierarchy and the management
+CCC   of the time integration. 
+C
+C     Modules used:
+C
+      Use Agrif_Clustering    
+      Use Agrif_bcfunction
+C      
+      IMPLICIT NONE
+C
+      Contains
+C     Definition of procedures contained in this module.
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Step
+C     **************************************************************************
+C 
+      Subroutine Agrif_Step(procname) 
+C
+CCC   Description:
+CCC   Subroutine to create the grid hierarchy and to manage the time integration 
+CCC   procedure. It is called in the main program.
+C
+CC    Method:
+CC    Call on subroutines Agrif_Regrid and Agrif_Integrate.
+C
+C     Declarations:
+C
+      Optional :: procname
+      External :: procname
+C
+#ifdef AGRIF_MPI
+      Logical      :: mpi_was_called
+      Integer      :: code, ierr
+#include "mpif.h"
+C
+C
+      Call Agrif_comm_def(mpi_comm_agrif)
+
+      CALL mpi_initialized ( mpi_was_called, code )
+      IF( code /= MPI_SUCCESS ) THEN
+         WRITE(*, *) ': Error in routine mpi_initialized'
+         CALL mpi_abort( mpi_comm_world, code, ierr )
+      ENDIF
+
+      IF( .NOT. mpi_was_called ) THEN 
+         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_agrif, code)
+         IF( code /= MPI_SUCCESS ) THEN
+            WRITE(*, *) ' Agrif_Step: Error in routine mpi_comm_dup'
+            CALL mpi_abort( mpi_comm_world, code, ierr )
+         ENDIF
+      ENDIF
+
+      If (Agrif_Mygrid % ngridstep == 0) Then
+          Call MPI_COMM_SIZE(MPI_COMM_AGRIF,Agrif_Nbprocs,code)
+          Call MPI_COMM_RANK(MPI_COMM_AGRIF,Agrif_ProcRank,code)
+          Call MPI_COMM_GROUP(MPI_COMM_AGRIF,Agrif_Group,code)
+      endif
+#endif
+C
+C     Creation and initialization of the grid hierarchy 
+C
+C  
+C    Set the clustering variables
+C
+      Call Agrif_clustering_def()
+C      
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then
+C     
+         If (Agrif_Mygrid % ngridstep == 0) then
+C
+            Call Agrif_Regrid
+C 
+            Call Agrif_Instance           
+     &          (Agrif_Mygrid)           
+         endif
+C
+      else
+C    
+         If (mod(Agrif_Mygrid % ngridstep, Agrif_Regridding) == 0) then
+C
+            Call Agrif_Regrid
+C  
+            Call Agrif_Instance           
+     &          (Agrif_Mygrid)  
+C            
+         endif
+C
+      endif
+C
+C     Time integration of the grid hierarchy
+C
+      If (present(procname)) Then
+         Call Agrif_Integrate (Agrif_Mygrid,procname)
+      Else
+         Call Agrif_Integrate (Agrif_Mygrid)      
+      endif
+C    
+      If (associated(Agrif_Mygrid%child_grids)) 
+     &   Call Agrif_Instance (Agrif_Mygrid)
+C
+      Return
+C             
+      End Subroutine Agrif_Step      
+
+C     **************************************************************************
+CCC   Subroutine Agrif_Step_Child
+C     **************************************************************************
+C
+      Subroutine Agrif_Step_Child(procname)
+C
+CCC   Description:
+CCC   Subroutine to create the grid hierarchy and to manage the time integration
+CCC   procedure. It is called in the main program.
+C
+CC    Method:
+CC    Call on subroutines Agrif_Regrid and Agrif_Integrate.
+C
+C     Declarations:
+C
+      Optional :: procname
+      External :: procname
+C
+C     Time integration of the grid hierarchy
+C
+      If (present(procname)) Then
+         Call Agrif_Integrate_Child (Agrif_Mygrid,procname)
+      Else
+         Call Agrif_Integrate_Child (Agrif_Mygrid)
+      endif
+C    
+      If (associated(Agrif_Mygrid%child_grids))
+     &   Call Agrif_Instance (Agrif_Mygrid)
+C
+      Return
+C
+      End Subroutine Agrif_Step_Child
+
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Regrid
+C     **************************************************************************
+C
+      Subroutine Agrif_Regrid
+C
+CCC   Description:
+CCC   Subroutine to create the grid hierarchy from fixed grids and 
+CC       adaptive mesh refinement.
+C
+CC    Method:        
+C
+C     Declarations:
+C
+C     Local variables      
+      Type(Agrif_Rectangle), Pointer     :: coarsegrid_fixed
+      Type(Agrif_Rectangle), Pointer     :: coarsegrid_moving  
+      INTEGER                            :: j
+      INTEGER :: nunit
+      INTEGER                            :: iii
+      Logical :: BEXIST
+C 
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 )
+     &   Call Agrif_detect_all(Agrif_Mygrid) ! Detection of areas to be refined
+C
+      Allocate(coarsegrid_fixed)
+      Allocate(coarsegrid_moving)
+C
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) 
+     &    Call Agrif_Cluster_All(Agrif_Mygrid,coarsegrid_moving) ! Clustering
+C
+      if ( Agrif_USE_FIXED_GRIDS .EQ. 1 .OR. 
+     &     Agrif_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then
+C
+      If (Agrif_Mygrid % ngridstep == 0) Then
+          nunit = Agrif_Get_Unit()
+          open(nunit,file='AGRIF_FixedGrids.in',form='formatted',
+     &           status="old",ERR=99) ! Opening of the Agrif_FixedGrids.in file
+          j = 1
+C         Creation of the grid hierarchy from the Agrif_FixedGrids.in file 
+            do iii = 1 , Agrif_Probdim
+               coarsegrid_fixed % imin(iii) = 1
+               coarsegrid_fixed % imax(iii) = Agrif_Mygrid % nb(iii) + 1
+            enddo
+C      
+            Call Agrif_Read_Fix_Grd (coarsegrid_fixed,j,nunit)     
+            close(nunit) ! Closing of the Agrif_FixedGrids.in file 
+C
+          Nullify(Agrif_oldmygrid)
+          Nullify(Agrif_Mygrid  % child_grids)
+C        
+C         Creation of the grid hierarchy from coarsegrid_fixed
+            Call Agrif_Create_Grids (Agrif_Mygrid,coarsegrid_fixed)
+        Else        
+          Agrif_oldmygrid => Agrif_Mygrid % child_grids
+         endif
+      else
+      Agrif_oldmygrid => Agrif_Mygrid % child_grids
+      Nullify(Agrif_Mygrid  % child_grids)
+      endif
+C
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then
+C      
+      Call Agrif_Free_before_All(Agrif_oldmygrid)
+C 
+C     Creation of the grid hierarchy from coarsegrid_moving    
+      Call Agrif_Create_Grids
+     &     (Agrif_Mygrid,coarsegrid_moving)
+C
+      endif
+C
+C     Initialization of the grid hierarchy by copy or interpolation
+C
+      Call Agrif_Init_Hierarchy(Agrif_Mygrid)
+C
+      if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) 
+     &        Call Agrif_Free_after_All(Agrif_oldmygrid)
+C
+      Deallocate(coarsegrid_fixed)
+      Deallocate(coarsegrid_moving)
+C      
+      Return
+C
+C     Opening error
+C
+   99 INQUIRE(FILE='AGRIF_FixedGrids.in',EXIST=BEXIST)
+      If (.not. BEXIST) Then
+          print*,'ERROR : File AGRIF_FixedGrids.in not found.'
+          STOP 
+        Else
+          print*,'Error opening file AGRIF_FixedGrids.in'
+          STOP         
+      endif     
+C      
+      End Subroutine Agrif_Regrid
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_detect_All
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_detect_all(g)
+C
+CCC   Description:
+CCC   Subroutine to detect areas to be refined.
+C
+CC    Method:        
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      TYPE(Agrif_Grid) ,pointer  :: g        ! Pointer on the current grid
+C      
+C     Local variables
+      Type(Agrif_pgrid),pointer  :: parcours ! Pointer for the recursive 
+                                             ! procedure      
+      INTEGER, DIMENSION(3)      :: size
+      INTEGER                    :: iii
+      Real :: g_eps     
+C
+      parcours => g % child_grids
+C  
+C     To be positioned on the finer grids of the grid hierarchy          
+C  
+      do while (associated(parcours))       
+         Call Agrif_detect_all (parcours % gr)  
+        parcours => parcours % next             
+      enddo
+C
+      g_eps = huge(1.)
+      do iii = 1 , Agrif_Probdim
+         g_eps=min(g_eps,g%Agrif_d(iii))
+      enddo
+C
+      g_eps = g_eps/100.
+C          
+      if ( Agrif_Probdim .EQ. 1 ) g%tabpoint1D=0
+      if ( Agrif_Probdim .EQ. 2 ) g%tabpoint2D=0
+      if ( Agrif_Probdim .EQ. 3 ) g%tabpoint3D=0
+C      
+      do iii = 1 , Agrif_Probdim
+         if (g%Agrif_d(iii)/Agrif_coeffref(iii).LT.
+     &                     (Agrif_mind(iii)-g_eps)) Return
+      enddo
+C                                       
+      Call Agrif_instance(g)
+C  
+C     Detection (Agrif_detect is a user s routine)
+C      
+      do iii = 1 , Agrif_Probdim
+         size(iii) = g%nb(iii) + 1
+      enddo
+C
+      SELECT CASE (Agrif_Probdim)
+      CASE (1) 
+         Call Agrif_detect(g%tabpoint1D,size)
+      CASE (2) 
+         Call Agrif_detect(g%tabpoint2D,size)
+      CASE (3) 
+         Call Agrif_detect(g%tabpoint3D,size)
+      END SELECT
+C
+C     Addition of the areas detected on the child grids
+C      
+      parcours => g % child_grids 
+C           
+      Do while (associated(parcours))
+        Call Agrif_Add_detected_areas (g,parcours % gr)
+        parcours => parcours % next 
+      enddo
+C     
+      Return      
+C
+      End Subroutine Agrif_detect_all
+C      
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Add_detected_areas
+C     **************************************************************************
+C      
+      Subroutine Agrif_Add_detected_areas(parentgrid,childgrid)
+C
+CCC   Description:
+CCC   Subroutine to add on the parent grid the areas detected 
+CC       on its child grids.
+C
+CC    Method:        
+C
+C     Declarations:
+C
+      
+C 
+      Type(Agrif_Grid),pointer   :: parentgrid,childgrid
+C      
+      Integer :: i,j,k
+C
+      do i = 1,childgrid%nb(1)+1
+         if ( Agrif_Probdim .EQ. 1 ) then
+            If (childgrid%tabpoint1D(i).EQ.1) Then
+                parentgrid%tabpoint1D(childgrid%ix(1)+
+     &                 (i-1)/Agrif_Coeffref(1)) = 1
+            endif
+         else
+            do j=1,childgrid%nb(2)+1
+               if (Agrif_Probdim.EQ.2) then
+              If (childgrid%tabpoint2D(i,j).EQ.1) Then
+                  parentgrid%tabpoint2D(
+     &                  childgrid%ix(1)+(i-1)/Agrif_Coeffref(1),
+     &                  childgrid%ix(2)+(j-1)/Agrif_Coeffref(2)) = 1
+                  endif
+               else
+                  do k=1,childgrid%nb(3)+1
+                If (childgrid%tabpoint3D(i,j,k).EQ.1) Then
+                    parentgrid%tabpoint3D(
+     &                     childgrid%ix(1)+(i-1)/Agrif_Coeffref(1),
+     &                     childgrid%ix(2)+(j-1)/Agrif_Coeffref(2),
+     &                     childgrid%ix(3)+(k-1)/Agrif_Coeffref(3)) = 1
+                     endif
+                  enddo
+               endif
+            enddo
+         endif
+      enddo
+C      
+      Return
+C
+      End Subroutine Agrif_Add_detected_areas   
+C      
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Free_before_All
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Free_before_All(g)
+C
+CCC   Description:
+C
+CC    Method:        
+C
+C     Declarations:
+C
+C     Pointer argument    
+      Type(Agrif_pgrid),pointer   :: g        ! Pointer on the current grid
+C
+C     Local pointer
+      Type(Agrif_pgrid),pointer  :: parcours ! Pointer for the recursive 
+                                             ! procedure      
+C
+C
+      parcours => g        
+C      
+      Do while (associated(parcours))     
+        If (.not. parcours%gr%fixed) Then
+            Call Agrif_Free_data_before(parcours%gr)
+            parcours % gr % oldgrid = .TRUE.        
+        endif
+C
+        Call Agrif_Free_before_all (parcours % gr % child_grids)
+C  
+        parcours => parcours % next             
+      enddo
+C     
+      Return      
+C
+C
+      End Subroutine Agrif_Free_before_All
+C
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Free_after_All
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Free_after_All(g)
+C
+CCC   Description:
+C
+CC    Method:        
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      Type(Agrif_pgrid),pointer   :: g       ! Pointer on the current grid
+C
+C     Local pointers
+      TYPE(Agrif_pgrid),pointer  :: parcours ! Pointer for the recursive proced
+      Type(Agrif_pgrid),pointer  :: preparcours   
+      Type(Agrif_pgrid),pointer  :: preparcoursini 
+C
+C
+      Allocate(preparcours)
+C 
+      preparcoursini => preparcours
+C 
+      Nullify(preparcours % gr)
+C 
+      preparcours % next => g
+C
+      parcours => g
+C      
+      Do while (associated(parcours))
+C
+         if ( (.NOT. parcours% gr% fixed) .AND.
+     &        (parcours% gr% oldgrid    ) ) then
+          Call Agrif_Free_data_after(parcours%gr)
+         endif
+C
+         Call Agrif_Free_after_all (parcours % gr % child_grids)
+C
+      If (parcours % gr % oldgrid) Then
+          Deallocate(parcours % gr)
+          preparcours % next => parcours % next
+          Deallocate(parcours)
+          parcours => preparcours % next
+        Else
+          preparcours => preparcours % next
+          parcours => parcours % next 
+         endif       
+      enddo
+C
+      Deallocate(preparcoursini)
+C     
+      Return      
+C
+      End Subroutine Agrif_Free_after_All
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Integrate
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Integrate(g, procname)         
+C
+CCC   Description:
+CCC   Subroutine to manage the time integration of the grid hierarchy.
+C
+CC    Method:
+CC    Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step
+C
+C     Declarations:
+C
+      
+C      
+C     Pointer argument    
+      Type(Agrif_Grid),pointer   :: g        ! Pointer on the current grid
+C
+C     main procedure name
+      Optional :: procname
+      External :: procname      
+C      
+C     Local pointer
+      Type(Agrif_pgrid),pointer  :: parcours ! Pointer for the recursive 
+                                             ! procedure
+C
+C     Local scalars
+      INTEGER                    :: nbt      ! Number of time steps 
+                                             ! of the current grid
+      INTEGER                    :: k        
+      INTEGER                    :: iii
+C  
+C     Instanciation of the variables of the current grid
+      If (g%fixedrank .NE.0) Then      
+      Call Agrif_Instance
+     &     (g)
+      End If
+C       
+C     One step on the current grid      
+C
+      If (present(procname)) Then
+         Call procname ()      
+      Else
+        write(*,*) 'The name of the step subroutine has not '
+        write(*,*) 'been given in the subroutine Agrif_Integrate'
+        stop
+      endif
+C
+C     Number of time steps on the current grid      
+C
+      g%ngridstep = g % ngridstep + 1
+C      
+      parcours => g % child_grids
+C    
+C     Recursive procedure for the time integration of the grid hierarchy      
+      Do while (associated(parcours))
+C
+C       Instanciation of the variables of the current grid            
+        Call Agrif_Instance
+     &           (parcours % gr)
+C       
+C       Number of time steps
+        nbt = 1
+        do iii = 1 , Agrif_Probdim
+           nbt = max(nbt, parcours % gr % timeref(iii))
+        enddo
+C       
+        Do k = 1,nbt
+C       
+           If (present(procname)) Then
+                 Call Agrif_Integrate (parcours % gr, procname)
+           Else
+                 Call Agrif_Integrate (parcours % gr)      
+           endif
+C       
+        enddo     
+C  
+        parcours => parcours % next
+C     
+      enddo
+C
+C      
+      End Subroutine Agrif_Integrate 
+
+C     **************************************************************************
+CCC   Subroutine Agrif_Integrate_Child
+C     **************************************************************************
+C
+      Recursive Subroutine Agrif_Integrate_Child(g,procname)
+C
+CCC   Description:
+CCC   Subroutine to manage the time integration of the grid hierarchy.
+C
+CC    Method:
+CC    Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step.
+C
+C     Declarations:
+C
+
+C
+C     Pointer argument
+      Type(Agrif_Grid),pointer   :: g        ! Pointer on the current grid
+C
+C     main procedure name
+      Optional :: procname
+      External :: procname
+C
+C     Local pointer
+      Type(Agrif_pgrid),pointer  :: parcours ! Pointer for the recursive
+                                             ! procedure
+C
+C     One step on the current grid
+C
+      If (present(procname)) Then
+         Call procname ()      
+      Else
+        write(*,*) 'The name of the step subroutine has not '
+        write(*,*) 'been given in the subroutine Agrif_Integrate'
+        stop
+      endif
+C
+C     Number of time steps on the current grid
+C
+C
+      parcours => g % child_grids
+C
+C     Recursive procedure for the time integration of the grid hierarchy      
+      Do while (associated(parcours))
+C
+C       Instanciation of the variables of the current grid
+        Call Agrif_Instance
+     &           (parcours % gr)
+
+C       
+           If (present(procname)) Then
+                 Call Agrif_Integrate_Child (parcours % gr, procname)
+           Else
+                 Call Agrif_Integrate_Child (parcours % gr)
+           endif
+C  
+        parcours => parcours % next
+C     
+      enddo
+C
+C
+      End Subroutine Agrif_Integrate_Child
+
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Init_Grids
+C     **************************************************************************
+C      
+      Subroutine Agrif_Init_Grids
+C
+CCC   Description:
+CCC   Subroutine to initialize the root coarse grid pointed by Agrif_Mygrid. 
+CCC   It is called in the main program.
+C
+C     Declarations:
+C
+C
+      INTEGER :: iii
+C
+C             definition of the probdim and modtypes variables
+C
+#ifdef AGRIF_MPI
+#include "mpif.h"
+      Agrif_MPIPREC = MPI_DOUBLE_PRECISION
+#endif
+      Call Agrif_probdim_modtype_def()
+C      
+      Agrif_UseSpecialValue = .FALSE.
+      Agrif_UseSpecialValueFineGrid = .FALSE.
+      Agrif_SpecialValue = 0.
+      Agrif_SpecialValueFineGrid = 0.
+C      
+C     Allocation of Agrif_Mygrid
+      allocate(Agrif_Mygrid)
+C      
+C     Space and time refinement factors are set to 1 on the root grid
+C
+      do iii = 1 , Agrif_Probdim
+         Agrif_Mygrid % spaceref(iii) = 1
+         Agrif_Mygrid % timeref(iii) = 1
+      enddo
+C      
+C     Initialization of the number of time steps    
+      Agrif_Mygrid % ngridstep = 0
+      Agrif_Mygrid % grid_id = 0
+C
+C     No parent grid for the root coarse grid
+      Nullify(Agrif_Mygrid % parent)
+C      
+C     Initialization of the minimum positions, global abscissa and space steps  
+      do iii= 1 ,  Agrif_Probdim
+         Agrif_Mygrid % ix(iii) = 1            
+         Agrif_Mygrid % Agrif_x(iii) = 0.
+         Agrif_Mygrid % Agrif_d(iii) = 1. 
+C     Borders of the root coarse grid 
+         Agrif_Mygrid % NearRootBorder(iii) = .true.  
+         Agrif_Mygrid % DistantRootBorder(iii) = .true.      
+      enddo
+C  
+C     The root coarse grid is a fixed grid
+      Agrif_Mygrid % fixed = .TRUE.
+C      
+C     Number of the grid pointed by Agrif_Mygrid (root coarse grid)
+      Agrif_Mygrid % rank = 1      
+C 
+C     Number of the root grid as a fixed grid   
+      Agrif_Mygrid % fixedrank = 0  
+C 
+C     Initialization of some fields of the root grid variables     
+      Call Agrif_Create_Var (Agrif_Mygrid)
+C      
+C     Initialization of the other fields of the root grid variables (number of 
+C     cells, positions, number and type of its dimensions, ...)  
+      Call Agrif_Set_numberofcells(Agrif_Mygrid)
+C      
+      Call Agrif_Instance (Agrif_Mygrid)        
+C             
+C     Allocation of the array containing the values of the grid variables
+      Call Agrif_Allocation (Agrif_Mygrid)
+C        
+      Call Agrif_initialisations(Agrif_Mygrid)
+C      
+      nullify(Agrif_Mygrid % child_grids)
+C 
+C     Total number of fixed grids   
+      Agrif_nbfixedgrids = 0         
+C      
+      Call Agrif_Instance (Agrif_Mygrid)
+C        
+      End Subroutine Agrif_Init_Grids  
+C
+C
+C     **************************************************************************
+CCC   Subroutine Agrif_Deallocation
+C     **************************************************************************
+C      
+      Subroutine Agrif_Deallocation
+C
+CCC   Description:
+CCC   Subroutine to initialize the root coarse grid pointed by Agrif_Mygrid. 
+CCC   It is called in the main program.
+C
+C     Declarations:
+C
+C
+      INTEGER :: nb
+C
+C             definition of the probdim and modtypes variables
+C
+      do nb = 1, Agrif_NbVariables
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array1) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array1)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array2) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array2)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array3) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array3)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array4) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array4)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array5) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array5)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % array6) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % array6)
+C
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray1) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray1)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray2) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray2)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray3) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray3)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray4) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray4)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray5) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray5)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray6) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray6)
+C
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray1) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray1)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray2) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray2)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray3) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray3)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray4) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray4)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray5) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray5)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray6) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray6)
+C
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % carray1) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % carray1)
+          if ( associated(Agrif_Mygrid % tabvars(nb) % var % carray2) ) 
+     &       Deallocate(Agrif_Mygrid % tabvars(nb) % var % carray2)
+      enddo
+C
+      do nb = 1, Agrif_NbVariables
+        Deallocate(Agrif_Mygrid % tabvars(nb) % var)
+      enddo
+C
+      Deallocate(Agrif_Mygrid % tabvars)
+C
+      Deallocate(Agrif_Mygrid)
+C
+      End Subroutine  Agrif_Deallocation 
+C
+      End module Agrif_Util 
Index: /branches/DEV_r1837_MLF/AGRIF/KEY_CPP
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/KEY_CPP	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/KEY_CPP	(revision 1844)
@@ -0,0 +1,1 @@
+
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/DiversListe.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/DiversListe.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/DiversListe.c	(revision 1844)
@@ -0,0 +1,603 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                           Add_Common_var_1                                 */
+/******************************************************************************/
+/*  This subroutines is used to add the variable defined in common in the     */
+/*     List_Common_Var                                                        */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Common_var_1()
+{
+   listvar *newvar;
+   listvar *newvar2;
+   variable *newvariable;
+   listdim *dims;
+   char listdimension[LONG_C];
+   char ligne[LONG_C];
+   int out;
+
+   if ( firstpass == 1 )
+   {
+
+   newvar = (listvar *)malloc(sizeof(listvar));
+   newvariable = (variable *)malloc(sizeof(variable));
+   /*                                                                         */
+   Init_Variable(newvariable);
+   /*                                                                         */
+   strcpy(newvariable->v_nomvar,commonvar);
+   Save_Length(commonvar,4);
+   strcpy(newvariable->v_commonname,commonblockname);
+   Save_Length(commonblockname,7);
+   strcpy(newvariable->v_modulename,curmodulename);
+   Save_Length(curmodulename,6);
+   strcpy(newvariable->v_subroutinename,subroutinename);
+   Save_Length(subroutinename,11);
+   newvariable->v_positioninblock= positioninblock;
+   newvariable->v_common=1;
+   strcpy(newvariable->v_commoninfile,mainfile);
+   Save_Length(mainfile,10);
+
+   newvar->var = newvariable;
+
+   if ( commondim )
+   {
+      newvariable->v_dimension=commondim;
+      newvariable->v_dimensiongiven=1;
+      newvariable->v_nbdim=num_dims(commondim);
+      /* Creation of the string for the dimension of this variable            */
+      dimsempty = 1;
+      strcpy(listdimension,"");
+
+      if ( commondim )
+      {
+         dims = commondim;
+         while (dims)
+         {
+            if ( strcasecmp(dims->dim.first,"") ||
+                 strcasecmp(dims->dim.last,""))  dimsempty = 0;
+            sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
+            strcat(listdimension,ligne);
+            if ( dims->suiv ) strcat(listdimension,",");
+            dims = dims->suiv;
+         }
+         if ( dimsempty == 1 ) newvariable->v_dimsempty=1;
+      }
+      strcpy(newvariable->v_readedlistdimension,listdimension);
+      Save_Length(listdimension,15);
+   }
+
+
+   newvar->suiv = NULL;
+
+   if ( !List_Common_Var )
+   {
+      List_Common_Var = newvar;
+   }
+   else
+   {
+      newvar2 = List_Common_Var;
+      out = 0 ;
+      while ( newvar2 && out == 0 )
+      {
+         if ( !strcasecmp(newvar2->var->v_nomvar,commonvar) &&
+              !strcasecmp(newvar2->var->v_commonname,commonblockname) &&
+              !strcasecmp(newvar2->var->v_subroutinename,subroutinename)
+                          ) out = 1 ;
+         else newvar2 = newvar2->suiv;
+      }
+      if ( out == 0 )
+      {
+         newvar->suiv = List_Common_Var;
+         List_Common_Var = newvar;
+      }
+      else
+      {
+         free(newvar);
+      }
+   }
+   }
+}
+
+/******************************************************************************/
+/*                           Addtolistnom                                     */
+/******************************************************************************/
+/* This subroutine is used to add a variable to the list                      */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+listnom *Addtolistnom(char *nom, listnom *listin,int value)
+{
+   listnom *newnom;
+   listnom *parcours;
+   int out;
+
+   newnom=(listnom *) malloc (sizeof (listnom));
+   strcpy(newnom->o_nom,nom);
+   Save_Length(nom,23);
+   newnom->o_val = value;
+   newnom->suiv = NULL;
+
+   if ( !listin ) listin = newnom;
+   else
+   {
+      parcours = listin;
+      out = 0 ;
+      while ( parcours && out == 0 )
+      {
+         if ( !strcasecmp(parcours->o_nom,nom) ) out = 1 ;
+         else parcours=parcours->suiv;
+      }
+      if ( out == 0 )
+      {
+          newnom->suiv = listin;
+          listin = newnom;
+      }
+      else
+      {
+         free(newnom);
+      }
+   }
+   return listin;
+}
+
+/******************************************************************************/
+/*                           Addtolistname                                    */
+/******************************************************************************/
+/* This subroutine is used to add a        variable to the list               */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+listname *Addtolistname(char *nom,listname *input)
+{
+   listname *newnom;
+   listname *parcours;
+   int out;
+
+   if ( !input )
+   {
+      newnom=(listname *) malloc (sizeof (listname));
+      strcpy(newnom->n_name,nom);
+      Save_Length(nom,20);
+      newnom->suiv = NULL;
+      input = newnom;
+   }
+   else
+   {
+      parcours = input;
+      out = 0 ;
+      while ( parcours && out == 0 )
+      {
+         if ( !strcasecmp(parcours->n_name,nom) ) out = 1;
+         else parcours=parcours->suiv;
+      }
+      if ( out == 0 )
+      {
+         newnom=(listname *) malloc (sizeof (listname));
+         strcpy(newnom->n_name,nom);
+         Save_Length(nom,20);
+         newnom->suiv = input;
+         input = newnom;
+      }
+   }
+   return input;
+}
+
+/******************************************************************************/
+/*                    ModuleIsDefineInInputFile                               */
+/******************************************************************************/
+/* This subroutine is used to know if the module is defined in the input file */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+int ModuleIsDefineInInputFile(char *name)
+{
+   listnom *newnom;
+   int out;
+
+   out = 0;
+   if ( listofmodules )
+   {
+      newnom = listofmodules;
+      while( newnom && out == 0 )
+      {
+         if ( !strcasecmp(newnom->o_nom,name) ) out = 1 ;
+         else newnom=newnom->suiv;
+      }
+   }
+   return out;
+}
+
+/******************************************************************************/
+/*                      Addmoduletothelisttmp                                 */
+/******************************************************************************/
+/* This subroutine is used to add a record to a list of struct                */
+/* listusemodule                                                              */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub ... USE mod1 ===> insert in list                      */
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*       list =  listofmoduletmp                                              */
+/*                                                                            */
+/******************************************************************************/
+void Addmoduletothelisttmp(char *name)
+{
+  listusemodule *newmodule;
+  listusemodule *parcours;
+  int out;
+
+  if ( !listofmoduletmp)
+  {
+    newmodule =(listusemodule *)malloc(sizeof(listusemodule));
+    strcpy(newmodule->u_usemodule,name);
+    Save_Length(name,16);
+    strcpy(newmodule->u_cursubroutine,subroutinename);
+    Save_Length(subroutinename,18);
+    newmodule->suiv = NULL;
+    listofmoduletmp = newmodule ;
+  }
+  else
+  {
+    parcours = listofmoduletmp;
+    out = 0;
+    while( parcours && out == 0 )
+    {
+       if ( !strcasecmp(parcours->u_usemodule,name) ) out = 1;
+       else parcours = parcours->suiv;
+    }
+    if ( out == 0 )
+    {
+       newmodule =(listusemodule *)malloc(sizeof(listusemodule));
+       strcpy(newmodule->u_usemodule,name);
+       Save_Length(name,16);
+       strcpy(newmodule->u_cursubroutine,subroutinename);
+       Save_Length(subroutinename,18);
+       newmodule->suiv = listofmoduletmp;
+       listofmoduletmp = newmodule;
+    }
+  }
+}
+
+/******************************************************************************/
+/*                          Add_NameOfModule_1                                */
+/******************************************************************************/
+/* This subroutine is used to add a        variable to the list               */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_NameOfModule_1(char *nom)
+{
+   listnom *newnom;
+
+   if ( firstpass == 1 )
+   {
+      newnom=(listnom *) malloc (sizeof (listnom));
+      strcpy(newnom->o_nom,nom);
+      Save_Length(nom,23);
+      newnom->suiv = List_NameOfModule;
+      List_NameOfModule = newnom;
+   }
+}
+
+/******************************************************************************/
+/*                          Add_NameOfCommon_1                                */
+/******************************************************************************/
+/* This subroutine is used to add a        variable to the list               */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_NameOfCommon_1(char *nom)
+{
+   listnom *newnom;
+   listnom *parcours;
+
+   if ( firstpass == 1 )
+   {
+      parcours = List_NameOfCommon;
+      while ( parcours && strcasecmp(parcours->o_nom,nom) )
+                                                      parcours = parcours->suiv;
+      if ( !parcours )
+      {
+         newnom=(listnom *) malloc (sizeof (listnom));
+         strcpy(newnom->o_nom,nom);
+         Save_Length(nom,23);
+         newnom->suiv = List_NameOfCommon;
+         List_NameOfCommon = newnom;
+      }
+   }
+}
+
+/******************************************************************************/
+/*                     Add_CouplePointed_Var_1                                */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should complete the listvarpointtovar                                   */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_CouplePointed_Var_1(char *namemodule,listcouple *couple)
+{
+   listvarpointtovar *pointtmp;
+
+   if ( firstpass == 1 )
+   {
+      /* we should complete the List_CouplePointed_Var                        */
+      pointtmp=(listvarpointtovar *)malloc(sizeof(listvarpointtovar));
+      strcpy(pointtmp->t_usemodule,namemodule);
+      Save_Length(namemodule,28);
+      strcpy(pointtmp->t_cursubroutine,subroutinename);
+      Save_Length(subroutinename,29);
+      pointtmp->t_couple = couple;
+      if ( List_CouplePointed_Var )
+      {
+         pointtmp->suiv = List_CouplePointed_Var;
+         List_CouplePointed_Var = pointtmp;
+      }
+      else
+      {
+         pointtmp->suiv = NULL;
+         List_CouplePointed_Var = pointtmp;
+      }
+   }
+}
+
+/******************************************************************************/
+/*                           Add_Include_1                                    */
+/******************************************************************************/
+/* This subroutine is used to add a record to a list of struct                */
+/*  List_Include                                                              */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub ... include mod1 ===> insert in list                  */
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*       list =  List_Include                                                 */
+/*                                                                            */
+/******************************************************************************/
+void Add_Include_1(char *name)
+{
+  listusemodule *newinclude;
+
+  if ( firstpass == 1 )
+  {
+  newinclude =(listusemodule *)malloc(sizeof(listusemodule));
+  strcpy(newinclude->u_usemodule,name);
+  Save_Length(name,16);
+  strcpy(newinclude->u_cursubroutine,subroutinename);
+  Save_Length(subroutinename,18);
+  newinclude->suiv = NULL;
+
+  if ( !List_Include)
+  {
+     List_Include  = newinclude ;
+  }
+  else
+  {
+    newinclude->suiv = List_Include;
+    List_Include = newinclude;
+  }
+  }
+}
+
+/******************************************************************************/
+/*                     Add_ImplicitNoneSubroutine_1                           */
+/******************************************************************************/
+/* This subroutine is used to add a record to a list of struct                */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_ImplicitNoneSubroutine_1()
+{
+
+  if ( firstpass == 1 )
+  {
+     List_ImplicitNoneSubroutine = Addtolistname(subroutinename,
+                                                   List_ImplicitNoneSubroutine);
+  }
+}
+
+
+/******************************************************************************/
+/*                        WriteIncludeDeclaration                             */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void WriteIncludeDeclaration()
+{
+  listusemodule *newinclude;
+
+  newinclude = List_Include;
+  fprintf(fortranout,"\n");
+  while ( newinclude )
+  {
+     if ( !strcasecmp(newinclude->u_cursubroutine,subroutinename) )
+     {
+        fprintf(fortranout,"      INCLUDE %s \n",newinclude->u_usemodule);
+     }
+     newinclude = newinclude ->suiv;
+  }
+}
+
+/******************************************************************************/
+/*                          Add_Save_Var_1                                    */
+/******************************************************************************/
+/* This subroutine is used to add a record to List_Save_Var                   */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ Save +--->+ Save +--->+ Save +--->+  Save+             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+void Add_Save_Var_1 (char *name,listdim *d)
+{
+  listvar *newvar;
+  listdim *dims;
+  char ligne[LONG_C];
+  char listdimension[LONG_C];
+
+  if ( firstpass == 1 )
+  {
+     newvar=(listvar *)malloc(sizeof(listvar));
+     newvar->var=(variable *)malloc(sizeof(variable));
+     /*                                                                       */
+     Init_Variable(newvar->var);
+     /*                                                                       */
+     newvar->var->v_save=1;
+     strcpy(newvar->var->v_nomvar,name);
+     Save_Length(name,4);
+     strcpy(newvar->var->v_modulename,curmodulename);
+     Save_Length(curmodulename,6);
+     strcpy(newvar->var->v_subroutinename,subroutinename);
+     Save_Length(subroutinename,11);
+     strcpy(newvar->var->v_commoninfile,mainfile);
+     Save_Length(mainfile,10);
+
+     newvar->var->v_dimension=d;
+     /* Creation of the string for the dimension of this variable             */
+     dimsempty = 1;
+     if ( d )
+     {
+        newvar->var->v_dimensiongiven=1;
+        dims = d;
+        while (dims)
+        {
+           if ( strcasecmp(dims->dim.first,"") || strcasecmp(dims->dim.last,""))
+                                                                  dimsempty = 0;
+           sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
+           strcat(listdimension,ligne);
+           if ( dims->suiv )
+           {
+              strcat(listdimension,",");
+           }
+           dims = dims->suiv;
+        }
+        if ( dimsempty == 1 ) newvar->var->v_dimsempty=1;
+     }
+     strcpy(newvar->var->v_readedlistdimension,listdimension);
+     Save_Length(listdimension,15);
+     /*                                                                       */
+     newvar->suiv = NULL;
+
+     if ( !List_Save_Var )
+     {
+        List_Save_Var  = newvar ;
+     }
+     else
+     {
+        newvar->suiv = List_Save_Var;
+        List_Save_Var = newvar;
+     }
+  }
+}
+
+void Add_Save_Var_dcl_1 (listvar *var)
+{
+  listvar *newvar;
+  listvar *parcours;
+
+  if ( firstpass == 1 )
+  {
+     parcours = var;
+     while ( parcours )
+     {
+        newvar=(listvar *)malloc(sizeof(listvar));
+        newvar->var=(variable *)malloc(sizeof(variable));
+        /*                                                                    */
+        Init_Variable(newvar->var);
+        /*                                                                    */
+        newvar->var->v_save=1;
+        strcpy(newvar->var->v_nomvar,parcours->var->v_nomvar);
+        strcpy(newvar->var->v_modulename,curmodulename);
+        Save_Length(curmodulename,6);
+        strcpy(newvar->var->v_subroutinename,subroutinename);
+        Save_Length(subroutinename,11);
+        strcpy(newvar->var->v_commoninfile,mainfile);
+        Save_Length(mainfile,10);
+        /*                                                                    */
+        strcpy(newvar->var->v_readedlistdimension,
+             parcours->var->v_readedlistdimension);
+        newvar->var->v_nbdim = parcours->var->v_nbdim;
+        newvar->var->v_dimension = parcours->var->v_dimension;
+        /*                                                                    */
+        newvar->var->v_dimensiongiven=parcours->var->v_dimensiongiven;
+        /*                                                                    */
+        newvar->suiv = NULL;
+
+        if ( !List_Save_Var ) List_Save_Var  = newvar ;
+        else
+        {
+           newvar->suiv = List_Save_Var;
+           List_Save_Var = newvar;
+        }
+        parcours = parcours->suiv;
+     }
+  }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile	(revision 1844)
@@ -0,0 +1,50 @@
+#- option to debug
+C_D = -g # -g -Wall
+# Compilation:
+CC		= cc -O
+#-
+OBJS = main.o WriteInFile.o toamr.o fortran.o  \
+       dependfile.o SubLoopCreation.o WorkWithlistvarindoloop.o \
+       WorkWithvarofsubroutineliste.o WorkWithParameterlist.o \
+       Writedeclarations.o WorkWithglobliste.o UtilFortran.o \
+       UtilNotGridDep.o WorkWithlistdatavariable.o \
+       DiversListe.o UtilAgrif.o WorkWithAllocatelist.o \
+       UtilCharacter.o UtilListe.o UtilFile.o \
+       WorkWithlistofmodulebysubroutine.o WorkWithlistmoduleinfile.o \
+       WorkWithlistofcoupled.o
+
+
+.SUFFIXES:
+.SUFFIXES: .c .o
+
+all : conv
+	@echo CONV is ok
+
+conv :  $(OBJS)
+	@$(CC) $(OBJS) -o ../$@
+
+main.o : main.c
+fortran.o : fortran.c	
+toamr.o : toamr.c decl.h
+WriteInFile.o : WriteInFile.c decl.h
+dependfile.o : dependfile.c decl.h	
+SubLoopCreation.o : SubLoopCreation.c decl.h	
+WorkWithglobliste.o : WorkWithglobliste.c decl.h	
+WorkWithlistvarindoloop.o : WorkWithlistvarindoloop.c decl.h	
+WorkWithvarofsubroutineliste.o : WorkWithvarofsubroutineliste.c decl.h	
+Writedeclarations.o : Writedeclarations.c decl.h	
+UtilFortran.o : UtilFortran.c decl.h	
+WorkWithParameterlist.o : WorkWithParameterlist.c decl.h	
+UtilNotGridDep.o : UtilNotGridDep.c decl.h	
+WorkWithlistdatavariable.o : WorkWithlistdatavariable.c decl.h	
+DiversListe.o : DiversListe.c decl.h	
+UtilAgrif.o : UtilAgrif.c decl.h	
+WorkWithAllocatelist.o : WorkWithAllocatelist.c decl.h
+UtilCharacter.o : UtilCharacter.c decl.h
+UtilListe.o : UtilListe.c decl.h
+UtilFile.o : UtilFile.c decl.h
+WorkWithlistofmodulebysubroutine.o : WorkWithlistofmodulebysubroutine.c decl.h
+WorkWithlistmoduleinfile.o : WorkWithlistmoduleinfile.c decl.h
+WorkWithlistofcoupled.o : WorkWithlistofcoupled.c decl.h
+clean : 
+	/bin/rm -f *.o y.output
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile.lex
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile.lex	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/Makefile.lex	(revision 1844)
@@ -0,0 +1,73 @@
+# Compilation:
+CC		= cc -O -g
+LEX		= flex
+
+# option de flex et pas de lex
+LEXFLAGS=-i
+YACC = byacc -t -v
+
+
+OBJS = main.o WriteInFile.o toamr.o fortran.o  \
+       dependfile.o SubLoopCreation.o WorkWithlistvarindoloop.o \
+       WorkWithvarofsubroutineliste.o WorkWithParameterlist.o \
+       Writedeclarations.o WorkWithglobliste.o UtilFortran.o \
+       UtilNotGridDep.o WorkWithlistdatavariable.o \
+       DiversListe.o UtilAgrif.o WorkWithAllocatelist.o \
+       UtilCharacter.o UtilListe.o UtilFile.o \
+       WorkWithlistofmodulebysubroutine.o WorkWithlistmoduleinfile.o \
+       WorkWithlistofcoupled.o
+
+.SUFFIXES:
+.SUFFIXES: .c .o
+
+all : conv
+
+conv :  $(OBJS)
+	$(CC) $(OBJS)  $(LEXLIB) -o ../$@
+
+main.o : main.c
+main.c : convert.tab.c  convert.yy.c
+	rm -f main.c
+	cat convert.tab.c  convert.yy.c > main.c
+	rm -f convert.yy.c convert.tab.c
+fortran.o : fortran.c
+fortran.c : fortran.tab.c fortran.yy.c
+	rm -f fortran.c
+	cat fortran.tab.c  fortran.yy.c > fortran.c
+#rm -f fortran.yy.c fortran.tab.c
+convert.tab.c : convert.y decl.h
+	$(YACC) convert.y
+	mv -f y.tab.c convert.tab.c
+fortran.tab.c : fortran.y decl.h
+	$(YACC) -p fortran fortran.y
+	mv -f y.tab.c fortran.tab.c
+convert.yy.c : convert.lex
+	$(LEX) $(LEXFLAGS) -oconvert.yy.c convert.lex
+fortran.yy.c : fortran.lex
+	$(LEX) $(LEXFLAGS) -Pfortran -ofortran.yy.c fortran.lex
+	
+toamr.o : toamr.c decl.h
+WriteInFile.o : WriteInFile.c decl.h
+dependfile.o : dependfile.c decl.h
+SubLoopCreation.o : SubLoopCreation.c decl.h
+WorkWithglobliste.o : WorkWithglobliste.c decl.h
+WorkWithlistvarindoloop.o : WorkWithlistvarindoloop.c decl.h
+WorkWithvarofsubroutineliste.o : WorkWithvarofsubroutineliste.c decl.h
+Writedeclarations.o : Writedeclarations.c decl.h
+UtilFortran.o : UtilFortran.c decl.h
+WorkWithParameterlist.o : WorkWithParameterlist.c decl.h
+UtilNotGridDep.o : UtilNotGridDep.c decl.h
+WorkWithlistdatavariable.o : WorkWithlistdatavariable.c decl.h
+DiversListe.o : DiversListe.c decl.h
+UtilAgrif.o : UtilAgrif.c decl.h
+WorkWithAllocatelist.o : WorkWithAllocatelist.c decl.h
+UtilCharacter.o : UtilCharacter.c decl.h
+UtilListe.o : UtilListe.c decl.h
+UtilFile.o : UtilFile.c decl.h
+WorkWithlistofmodulebysubroutine.o : WorkWithlistofmodulebysubroutine.c decl.h
+WorkWithlistmoduleinfile.o : WorkWithlistmoduleinfile.c decl.h
+WorkWithlistofcoupled.o : WorkWithlistofcoupled.c decl.h
+clean : 
+	/bin/rm -f *.o y.tab.c main.c lex.yy.c fortran.c \
+	fortran.tab.c fortran.yy.c convert.tab.c convert.yy.c \
+	y.output
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/SubLoopCreation.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/SubLoopCreation.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/SubLoopCreation.c	(revision 1844)
@@ -0,0 +1,567 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+
+/******************************************************************************/
+/*     preparation and write of the argument list of a subroutine             */
+/******************************************************************************/
+
+
+/******************************************************************************/
+/*                             writeheadnewsub_0                              */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/* We should write the head of the subroutine sub_loop_<subroutinename>       */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void writeheadnewsub_0()
+{
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 && IsTabvarsUseInArgument_0() == 1 )
+   {
+      if ( todebug == 1 ) printf("Enter in writeheadnewsub_0\n");
+      /* we should add the use agrif_uti l if it is necessary                 */
+      WriteHeadofSubroutineLoop();
+      WriteUsemoduleDeclaration();
+      if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout,
+                                                       "      IMPLICIT NONE\n");
+      WriteIncludeDeclaration();
+      /*                                                                      */
+      /* We should write once the declaration of tables (extract              */
+      /*    from pointer) in the new subroutine                               */
+      if ( mark == 1 ) fprintf(fortranout,"!!! 000000000000000 \n");
+      if ( SubInList_ContainsSubroutine() == 0 ) WriteLocalParamDeclaration();
+      if ( mark == 1 ) fprintf(fortranout,"!!! 111111111111111 \n");
+
+      sprintf(ligne,"\n#include \"ParamFile%s.h\" \n",subroutinename);
+      tofich(fortranout,ligne,1);
+
+      WriteArgumentDeclaration_Sort();
+
+      if ( mark == 1 ) fprintf(fortranout,"!!! 222222222222222 \n");
+      writesub_loopdeclaration_tab(List_UsedInSubroutine_Var,fortranout);
+      if ( mark == 1 ) fprintf(fortranout,"!!! 333333333333333 \n");
+      writesub_loopdeclaration_scalar(List_UsedInSubroutine_Var,paramout);
+      if ( mark == 1 ) fprintf(fortranout,"!!! 444444444444444 \n");
+      /* now we should write the function declaration                         */
+      /*    case if it is the                                                 */
+      WriteFunctionDeclaration(1);
+      if ( mark == 1 ) fprintf(fortranout,"!!! 555555555555555 \n");
+
+//      if ( SubInList_ContainsSubroutine() == 0 ) WriteSubroutineDeclaration(1);
+  
+      if ( mark == 1 ) fprintf(fortranout,"!!! 666666666666666 \n");
+      if ( todebug == 1 ) printf("Out of writeheadnewsub_0\n");
+   }
+   else if ( firstpass == 0 )
+   {
+      AddUseAgrifUtil_0(fortranout);
+      WriteUsemoduleDeclaration();
+      WriteIncludeDeclaration();
+      if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout,
+                                                       "      IMPLICIT NONE\n");
+      if ( mark == 1 ) fprintf(fortranout,"!!! aaaaaaaaaaaaaaa \n");
+      WriteLocalParamDeclaration();
+      if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbbbbbbbbbb \n");
+      if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(1);
+      WriteArgumentDeclaration_beforecall();
+/*      writesub_loopdeclaration_scalar(List_SubroutineArgument_Var,fortranout);
+      writesub_loopdeclaration_tab(List_SubroutineArgument_Var,fortranout);*/
+      if ( mark == 1 ) fprintf(fortranout,"!!! ccccccccccccccc \n");
+      if ( mark == 1 ) fprintf(fortranout,"!!! ddddddddddddddd \n");
+//      WriteSubroutineDeclaration(1);
+      if ( mark == 1 ) fprintf(fortranout,"!!! eeeeeeeeeeeeeee \n");
+   }
+}
+
+
+/******************************************************************************/
+/*                    WriteVariablelist_subloop                               */
+/******************************************************************************/
+/* This subroutine is used to write the list of the variable which            */
+/* should be called by the sub_loop_<name> subroutine                         */
+/* The first part is composed by the list of the local variables              */
+/******************************************************************************/
+/*                                                                            */
+/*    List_SubroutineDeclaration_Var    a,b,c,  &                             */
+/*                                      d,e,f,  &                             */
+/*     a,b,c,d,e,f,g,h     ========>    g,h                                   */
+/*                                                                            */
+/******************************************************************************/
+void WriteVariablelist_subloop(FILE *outputfile)
+{
+   listvar *parcours;
+   char ligne[LONG_C];
+   int compteur;
+
+   if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop\n");
+   parcours = List_SubroutineArgument_Var;
+   didvariableadded = 0;
+   compteur = 0 ;
+
+   while ( parcours )
+   {
+
+      /* if the readed variable is a variable of the subroutine               */
+      /*    subroutinename we should write the name of this variable          */
+      /*    in the output file                                                */
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) )
+      {
+         if ( didvariableadded == 0 )
+         {
+            strcpy(ligne,"");
+         }
+         else
+         {
+            if ( compteur == 0 ) strcpy(ligne,"");
+            strcat(ligne,",");
+         }
+         strcat(ligne,parcours->var->v_nomvar);
+         didvariableadded = 1;
+         compteur = compteur + 1;
+         if ( compteur == 3 )
+         {
+            if ( retour77 == 0 )
+            {
+               strcat(ligne," &");
+               fprintf(outputfile,"\n      %s",ligne);
+            }
+            else fprintf(outputfile,"\n     & %s",ligne);
+            compteur = 0;
+         }
+      }
+      parcours = parcours -> suiv;
+   }
+   parcours = List_FunctionType_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) )
+      {
+         if ( didvariableadded == 0 )
+         {
+            strcpy(ligne,"");
+         }
+         else
+         {
+            if ( compteur == 0 ) strcpy(ligne,"");
+            strcat(ligne,",");
+         }
+         strcat(ligne,parcours->var->v_nomvar);
+         didvariableadded = 1;
+         compteur = compteur + 1;
+         if ( compteur == 3 )
+         {
+            if ( retour77 == 0 )
+            {
+               strcat(ligne," &");
+               fprintf(outputfile,"\n      %s",ligne);
+            }
+            else fprintf(outputfile,"\n     & %s",ligne);
+            compteur = 0;
+         }
+      }
+      parcours = parcours -> suiv;
+   }
+   if ( compteur != 3 && compteur != 0 )
+   {
+      if ( retour77 == 0 ) fprintf(outputfile,"\n      %s &",ligne);
+      else fprintf(outputfile,"\n     & %s ",ligne);
+   }
+   if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop\n");
+}
+
+
+/******************************************************************************/
+/*                     WriteVariablelist_subloop_Call                         */
+/******************************************************************************/
+/* This subroutine is used to write the list of the variable which            */
+/* should be called by the sub_loop_<name> subroutine into the called         */
+/* The second part is composed by the list of the global table                */
+/******************************************************************************/
+/*                                                                            */
+/*   List_UsedInSubroutine_Var SubloopScalar = 0 | SubloopScalar = 1          */
+/*                                a,b,c,  &      |  a,b(1,1),c,      &        */
+/*     a,b,c,d,e,f,g,h  =====>    d,e,f,  &      |  d(1),e(1,1,1),f, &        */
+/*                                g,h            |  g,h(1,1)                  */
+/*                                                                            */
+/******************************************************************************/
+void WriteVariablelist_subloop_Call(FILE *outputfile)
+{
+   listvar *parcours;
+   char ligne[LONG_40M];
+   char ligne2[10];
+   int i;
+   int compteur ;
+
+   strcpy(ligne,"");
+   
+   if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Call\n");
+   parcours = List_UsedInSubroutine_Var;
+   compteur = 0 ;
+   while ( parcours )
+   {
+      /* if the readed variable is a variable of the subroutine               */
+      /*    subroutinename we should write the name of this variable          */
+      /*    in the output file                                                */
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename)  &&
+          (parcours->var->v_allocatable == 0  || !strcasecmp(parcours->var->v_typevar,"type"))      &&
+           parcours->var->v_pointerdeclare == 0
+         )
+      {
+         if ( didvariableadded == 0 )
+         {
+            if ( retour77 == 1 ) strcpy(ligne,"\n     & ");
+            else strcpy(ligne,"\n      ");
+         }
+         else
+         {
+            if ( compteur == 0 )
+            {
+               if ( retour77 == 1 ) strcpy(ligne,"\n     & ");
+               else strcpy(ligne,"\n      ");
+            }
+            strcat(ligne," , ");
+         }
+         strcat(ligne,vargridcurgridtabvars(parcours->var,0));
+         /* if it is asked in the call of the conv we should give             */
+         /* scalar in argument, so we should put (1,1,1) after the            */
+         /* the name of the variable                                          */
+         if (  SubloopScalar != 0 &&
+               (IsVarAllocatable_0(parcours->var->v_nomvar) == 0 &&
+               parcours->var->v_pointerdeclare == 0 ) &&
+               parcours->var->v_nbdim != 0 )
+         {
+             i = 1;
+             while ( i <=  parcours->var->v_nbdim )
+             {
+                if ( i == 1 ) strcat(ligne,"( ");
+                if ( SubloopScalar == 2 )
+                {
+                   strcat(ligne,":");
+                   if ( i != parcours->var->v_nbdim ) strcat(ligne,",");
+                }
+                else
+                {
+                   strcat(ligne," lbound( ");
+                   strcat(ligne,vargridcurgridtabvars(parcours->var,0));
+                   strcat(ligne,",");
+                   strcpy(ligne2,"");
+                   sprintf(ligne2,"%d",i);
+                   strcat(ligne,ligne2);
+                   if ( i != parcours->var->v_nbdim ) strcat(ligne,"),");
+                }
+                if ( i == parcours->var->v_nbdim ) strcat(ligne,"))");
+                i++;
+             }
+         }
+         didvariableadded = 1;
+         compteur = compteur +1 ;
+         /*if ( retour77 == 0 )
+         {
+            strcat(ligne," &");
+            fprintf(outputfile,"\n");
+         }
+         else fprintf(outputfile,"\n     & ");*/
+         /*tofich(outputfile,ligne,0);*/
+      }
+      parcours = parcours -> suiv;
+   }
+   
+   Save_Length(ligne,41);
+   tofich(outputfile,ligne,0);
+   /* Now we should replace the last ", &" by " &"                            */
+/*   if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR);
+   if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/
+   if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Call\n");
+}
+
+
+/******************************************************************************/
+/*                       WriteVariablelist_subloop_Def                        */
+/******************************************************************************/
+/* This subroutine is used to write the list of the variable which            */
+/* should be called by the sub_loop_<name> subroutine into the def            */
+/* The second part is composed by the list of the global table                */
+/* <name>_tmp                                                                 */
+/******************************************************************************/
+/*                                                                            */
+/*       List_UsedInSubroutine_Var                                            */
+/*                                a-tmp,b-tmp,c_tmp, &                        */
+/*     a,b,c,d,e,f,g,h  =====>    d_tmp,e_tmp,f_tmp, &                        */
+/*                                g_tmp,h_tmp                                 */
+/*                                                                            */
+/******************************************************************************/
+void WriteVariablelist_subloop_Def(FILE *outputfile)
+{
+   listvar *parcours;
+/*   char ligne[LONG_40M];*/
+   char *ligne;
+   int compteur;
+
+/*   strcpy(ligne," ");*/
+
+   ligne=(char *)malloc(LONG_40M*sizeof(char));
+   
+   if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Def\n");
+   parcours = List_UsedInSubroutine_Var;
+   compteur = 0 ;
+   while ( parcours )
+   {
+      /* if the readed variable is a variable of the subroutine               */
+      /*    subrotinename we should write the name of this variable           */
+      /*    in the output file                                                */
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename)  &&
+          (parcours->var->v_allocatable == 0  || !strcasecmp(parcours->var->v_typevar,"type"))      &&
+           parcours->var->v_pointerdeclare == 0
+         )
+      {
+         if ( didvariableadded == 0 )
+         {
+            if ( retour77 == 1 ) strcpy(ligne,"\n     &");
+            else strcpy(ligne,"\n      ");
+         }
+         else
+         {
+            if ( compteur == 0 )
+            {
+               if ( retour77 == 1 ) strcpy(ligne,"\n     & ");
+               else strcpy(ligne,"\n      ");
+            }
+            strcat(ligne,",");
+         }
+         strcat(ligne,parcours->var->v_nomvar);
+         compteur = compteur + 1;
+         didvariableadded = 1;
+/*         if ( compteur == 3 )
+         {
+            if ( retour77 == 0 )
+            {
+               strcat(ligne," &");
+               fprintf(outputfile,"\n      %s",ligne);
+            }
+            else fprintf(outputfile,"\n     & %s",ligne);
+            compteur = 0;
+         }*/
+      }
+      parcours = parcours -> suiv;
+   }
+ /*  if ( compteur != 3 && compteur != 0 )
+   {
+      if ( retour77 == 0 ) fprintf(outputfile,"\n      %s &",ligne);
+      else fprintf(outputfile,"\n     & %s",ligne);
+   }*/
+   Save_Length(ligne,41);
+   tofich(outputfile,ligne,0);
+
+   /* Now we should replace the last ", &" by " &"                            */
+  /* if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR);
+   if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/
+   if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Def\n");
+   strcpy(ligne,"");
+   
+   free(ligne);
+}
+
+
+
+/******************************************************************************/
+/*                      WriteHeadofSubroutineLoop                             */
+/******************************************************************************/
+/* This subroutine is used to write the head of the subroutine                */
+/* Sub_Loop_<name>                                                            */
+/******************************************************************************/
+/*                 Sub_loop_subroutine.h                                      */
+/*                                                                            */
+/*                 subroutine Sub_Loop_subroutine ( &                         */
+/*                 a,b,c, &                                                   */
+/* SubLoopScalar   d,e(1,1),f(1,1,1), &                                       */
+/*                 g,h  &                                                     */
+/*                 )                                                          */
+/******************************************************************************/
+void WriteHeadofSubroutineLoop()
+{
+   char ligne[LONG_C];
+   FILE * subloop;
+
+   if ( todebug == 1 ) printf("Enter in WriteHeadofSubroutineLoop\n");
+   tofich(fortranout,"\n",1);
+   /* Open this newfile                                                       */
+   sprintf(ligne,"Sub_Loop_%s.h",subroutinename);
+   subloop = associate(ligne);
+   /*                                                                         */
+   if ( retour77 == 0 ) sprintf(ligne,"      subroutine Sub_Loop_%s( &"
+                                                               ,subroutinename);
+   else sprintf(ligne,"      subroutine Sub_Loop_%s( ",subroutinename);
+   fprintf(subloop,ligne);
+   /*                                                                         */
+   WriteVariablelist_subloop(subloop);
+   WriteVariablelist_subloop_Def(subloop);
+   /*                                                                         */
+   sprintf(ligne,")");
+   fprintf(subloop,ligne);
+   /* if USE agrif_Uti l should be add                                        */
+   AddUseAgrifUtil_0(subloop);
+   /*                                                                         */
+   oldfortranout = fortranout;
+   fortranout = subloop;
+   if ( todebug == 1 ) printf("Out of WriteHeadofSubroutineLoop\n");
+}
+
+/******************************************************************************/
+/*                closeandcallsubloopandincludeit_0                           */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/* We should close the sub_loop subroutine, call it and close the             */
+/* function (suborfun = 0)                                                    */
+/* subroutine (suborfun = 1)                                                  */
+/* end (suborfun = 2)                                                         */
+/* end program (suborfun = 3)                                                 */
+/* and include the sub_loop subroutine after                                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void closeandcallsubloopandincludeit_0(int suborfun)
+{
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 )
+   {
+   if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n");
+   if ( IsTabvarsUseInArgument_0() == 1 )
+   {
+      /* We should remove the key word end subroutine                         */
+      RemoveWordCUR_0(fortranout,(long)(-(pos_cur-pos_endsubroutine)),
+                                          pos_cur-pos_endsubroutine);
+      /* We should close the loop subroutine                                  */
+      sprintf(ligne,"\n      end subroutine Sub_Loop_%s",subroutinename);
+      tofich(fortranout,ligne,1);
+      fclose(fortranout);
+      fortranout = oldfortranout;
+
+
+      AddUseAgrifUtilBeforeCall_0(fortranout);
+      if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(0);
+      WriteArgumentDeclaration_beforecall();
+      if ( !strcasecmp(subofagrifinitgrids,subroutinename) )
+                     fprintf(oldfortranout,"      Call Agrif_Init_Grids () \n");
+      /* Now we add the call af the new subroutine                            */
+      if ( retour77 == 0 ) sprintf(ligne,"\n      Call Sub_Loop_%s( &"
+                                                               ,subroutinename);
+      else sprintf(ligne,"\n      Call Sub_Loop_%s( ",subroutinename);
+      fprintf(fortranout,ligne);
+      /* Write the list of the local variables used in this new subroutine    */
+      WriteVariablelist_subloop(fortranout);
+      /* Write the list of the global tables used in this new subroutine      */
+      /*    in doloop                                                         */
+      WriteVariablelist_subloop_Call(fortranout);
+      /* Close the parenthesis of the new subroutine called                   */
+      sprintf(ligne,")");
+      fprintf(fortranout,ligne);
+      /* We should close the original subroutine                              */
+      if ( suborfun == 3 ) sprintf(ligne,"\n      end program %s"
+                                                               ,subroutinename);
+      if ( suborfun == 2 ) sprintf(ligne,"\n      end");
+      if ( suborfun == 1 ) sprintf(ligne,"\n      end subroutine %s"
+                                                               ,subroutinename);
+      if ( suborfun == 0 ) sprintf(ligne,"\n      end function %s"
+                                                               ,subroutinename);
+      tofich(fortranout,ligne,1);
+      /* we should include the above file in the original code                */
+      sprintf(ligne,"\n#include \"Sub_Loop_%s.h\" \n",subroutinename);
+      tofich(fortranout,ligne,1);
+      }
+    oldfortranout = (FILE *)NULL;      
+   if ( todebug == 1 ) printf("Out of closeandcallsubloopandincludeit_0\n");
+   }
+   
+}
+
+
+
+
+void closeandcallsubloop_contains_0()
+{
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 )
+   {
+   if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n");
+   if ( IsTabvarsUseInArgument_0() == 1 )
+   {
+      Remove_Word_Contains_0();
+      sprintf(ligne,"\n      end subroutine Sub_Loop_%s",subroutinename);
+      tofich(fortranout,ligne,1);
+      fclose(fortranout);
+      fortranout = oldfortranout;
+
+      AddUseAgrifUtilBeforeCall_0(fortranout);
+      if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout,
+                                                       "      IMPLICIT NONE\n");
+      WriteLocalParamDeclaration();
+      if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(0);
+      WriteArgumentDeclaration_beforecall();
+      WriteSubroutineDeclaration(0);
+      if ( !strcasecmp(subofagrifinitgrids,subroutinename) )
+                     fprintf(oldfortranout,"      Call Agrif_Init_Grids () \n");
+      /* Now we add the call af the new subroutine                            */
+      if ( retour77 == 0 ) sprintf(ligne,"\n      Call Sub_Loop_%s( &"
+                                                               ,subroutinename);
+      else sprintf(ligne,"\n      Call Sub_Loop_%s( ",subroutinename);
+      fprintf(fortranout,ligne);
+      /* Write the list of the local variables used in this new subroutine    */
+      WriteVariablelist_subloop(fortranout);
+      /* Write the list of the global tables used in this new subroutine      */
+      /*    in doloop                                                         */
+      WriteVariablelist_subloop_Call(fortranout);
+      /* Close the parenthesis of the new subroutine called                   */
+      sprintf(ligne,")");
+      tofich(fortranout,ligne,1);
+      /* We should close the original subroutine                              */
+      sprintf(ligne,"\n      contains");
+      tofich(fortranout,ligne,1);
+      /* we should include the above file in the original code                */
+      sprintf(ligne,"\n#include \"Sub_Loop_%s.h\" \n",subroutinename);
+      tofich(fortranout,ligne,1);
+      }
+   oldfortranout = (FILE *)NULL;
+   if ( todebug == 1 ) printf("Out of closeandcallsubloopandincludeit_0\n");
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilAgrif.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilAgrif.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilAgrif.c	(revision 1844)
@@ -0,0 +1,989 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+/******************************************************************************/
+/*                      Vartonumber                                           */
+/******************************************************************************/
+/* This subroutine is used to know if Agrif_ is locate in the char            */
+/* tokname                                                                    */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int Vartonumber(char *tokname)
+{
+   int agrifintheword;
+
+   agrifintheword = 0;
+        if ( !strcasecmp(tokname,"Agrif_parent")         ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_set_type")       ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_set_raf")        ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_set_bc")         ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_set_bcinterp")   ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Root")           ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_CFixed")         ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Fixed")          ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_bc_variable")    ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_set_parent")     ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_interp_variable")) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_init_variable")  ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_update_variable")) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Set_interp")     ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Set_Update")     ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Set_UpdateType") ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"Agrif_Set_restore")    ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"agrif_init_grids")     ) agrifintheword = 1;
+   else if ( !strcasecmp(tokname,"agrif_step")           ) agrifintheword = 1;
+
+   return agrifintheword;
+}
+
+/******************************************************************************/
+/*                              Agrif_in_Tok_NAME                             */
+/******************************************************************************/
+/* This subroutine is used to know if Agrif_ is locate in the char            */
+/* tokname                                                                    */
+/******************************************************************************/
+/*                                                                            */
+/*                 Agrif_name --------------> Agrif_in_Tok_NAME = 1           */
+/*                       name --------------> Agrif_in_Tok_NAME = 0           */
+/*                                                                            */
+/******************************************************************************/
+int Agrif_in_Tok_NAME(char *tokname)
+{
+   int agrifintheword;
+
+   if ( strncasecmp(tokname,"Agrif_",6) == 0 )  agrifintheword = 1;
+   else agrifintheword = 0;
+
+   return agrifintheword;
+}
+
+/******************************************************************************/
+/*                     ModifyTheVariableName_0                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void ModifyTheVariableName_0(char *ident, int lengthname)
+{
+   listvar *newvar;
+   int out;
+   
+   if ( firstpass == 0 )
+   {
+      newvar = List_Global_Var;
+      out=0;
+      while ( newvar && out == 0 )
+      {
+         if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+         else newvar=newvar->suiv;
+      }
+
+      if ( out == 0 )
+      {
+         newvar = List_ModuleUsed_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+      if ( out == 0 )
+      {
+         newvar = List_Common_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+
+      if ( out == 0 )
+      {
+         newvar = List_ModuleUsedInModuleUsed_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+
+      if ( out == 1 )
+      {
+         /* remove the variable                                               */
+         RemoveWordCUR_0(fortranout,(long)(-lengthname),
+                               lengthname);
+         fseek(fortranout,(long)(-lengthname),SEEK_CUR);
+         /* then write the new name                                           */
+         if ( inagrifcallargument == 1 && agrif_parentcall == 0 )
+            fprintf(fortranout,"%d",newvar->var->v_indicetabvars);
+         else
+         {
+            if ( retour77 == 0 )
+            {
+               fprintf(fortranout," Agrif_tabvars & \n      ");
+            }
+            else
+            {
+               fprintf(fortranout,"Agrif_tabvars");
+               fprintf(fortranout," \n     & ");
+            }
+            fprintf(fortranout,"%s",
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+            colnum = strlen(vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+         }
+      }
+      else
+      {
+         /* we should look in the List_ModuleUsed_Var                         */
+         if ( inagrifcallargument != 1 )
+         {
+            newvar = List_ModuleUsed_Var;
+            while ( newvar && out == 0 )
+            {
+               if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+               else newvar=newvar->suiv;
+            }
+            if ( out == 1 )
+            {
+               /* remove the variable                                         */
+               RemoveWordCUR_0(fortranout,(long)(-lengthname),
+                                     lengthname);
+               fseek(fortranout,(long)(-lengthname),SEEK_CUR);
+               /* then write the new name                                     */
+               if ( retour77 == 0 )
+               {
+                  fprintf(fortranout," Agrif_tabvars & \n      ");
+               }
+               else
+               {
+                  fprintf(fortranout," \n     & Agrif_tabvars");
+               }
+               fprintf(fortranout,"%s",
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+               colnum = strlen(
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+            }
+         }
+      }
+   }
+}
+
+/******************************************************************************/
+/*                     ModifyTheVariableName_0                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void ModifyTheVariableNamecoupled_0(char *ident, char* coupledident)
+{
+   listvar *newvar;
+   int out;
+   
+   if ( firstpass == 0 )
+   {
+      newvar = List_Global_Var;
+      out=0;
+      while ( newvar && out == 0 )
+      {
+         if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1;
+         else newvar=newvar->suiv;
+      }
+
+      if ( out == 0 )
+      {
+         newvar = List_ModuleUsed_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+      if ( out == 0 )
+      {
+         newvar = List_Common_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+
+      if ( out == 0 )
+      {
+         newvar = List_ModuleUsedInModuleUsed_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+
+      if ( out == 1 )
+      {
+         /* remove the variable                                               */
+         RemoveWordCUR_0(fortranout,(long)(-strlen(ident)),
+                               strlen(ident));
+         fseek(fortranout,(long)(-strlen(ident)),SEEK_CUR);
+         /* then write the new name                                           */
+         if ( inagrifcallargument == 1 && agrif_parentcall == 0 )
+            fprintf(fortranout,"%d",newvar->var->v_indicetabvars);
+         else
+         {
+            if ( retour77 == 0 )
+            {
+               fprintf(fortranout," Agrif_tabvars & \n      ");
+            }
+            else
+            {
+               fprintf(fortranout,"Agrif_tabvars");
+               fprintf(fortranout," \n     & ");
+            }
+            fprintf(fortranout,"%s",
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+            colnum = strlen(vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+         }
+      }
+      else
+      {
+         /* we should look in the List_ModuleUsed_Var                         */
+         if ( inagrifcallargument != 1 )
+         {
+            newvar = List_ModuleUsed_Var;
+            while ( newvar && out == 0 )
+            {
+               if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1;
+               else newvar=newvar->suiv;
+            }
+            if ( out == 1 )
+            {
+               /* remove the variable                                         */
+               RemoveWordCUR_0(fortranout,(long)(-strlen(ident)),
+                                     strlen(ident));
+               fseek(fortranout,(long)(-strlen(ident)),SEEK_CUR);
+               /* then write the new name                                     */
+               if ( retour77 == 0 )
+               {
+                  fprintf(fortranout," Agrif_tabvars & \n      ");
+               }
+               else
+               {
+                  fprintf(fortranout," \n     & Agrif_tabvars");
+               }
+               fprintf(fortranout,"%s",
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+               colnum = strlen(
+                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
+            }
+         }
+      }
+   }
+}
+
+
+
+/******************************************************************************/
+/*                         Add_SubroutineWhereAgrifUsed_1                     */
+/******************************************************************************/
+/* This subroutine is used to add a record to                                 */
+/* List_SubroutineWhereAgrifUsed                                              */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub ... Agrif_<something>                                 */
+/*                                                                            */
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + list +--->+ list +--->+ list +--->+ list +--->+ sub  +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*       list = List_SubroutineWhereAgrifUsed                                 */
+/*                                                                            */
+/******************************************************************************/
+void Add_SubroutineWhereAgrifUsed_1(char *sub,char *mod)
+{
+  listnom *listnomtmp;
+  listnom *parcours;
+
+  if ( firstpass == 1 )
+  {
+  if ( !List_SubroutineWhereAgrifUsed )
+  {
+     listnomtmp=(listnom *)malloc(sizeof(listnom));
+     strcpy(listnomtmp->o_nom,sub);
+     Save_Length(sub,23);
+     strcpy(listnomtmp->o_module,mod);
+     Save_Length(mod,24);
+     listnomtmp->suiv = NULL;
+     List_SubroutineWhereAgrifUsed  =  listnomtmp;
+  }
+  else
+  {
+    parcours = List_SubroutineWhereAgrifUsed;
+    while ( parcours && strcasecmp(parcours->o_nom,sub) )
+    {
+       parcours = parcours->suiv;
+    }
+    if ( !parcours )
+    {
+       listnomtmp=(listnom *)malloc(sizeof(listnom));
+       strcpy(listnomtmp->o_nom,sub);
+       Save_Length(sub,23);
+       strcpy(listnomtmp->o_module,mod);
+       Save_Length(mod,24);
+       listnomtmp->suiv = List_SubroutineWhereAgrifUsed;
+       List_SubroutineWhereAgrifUsed  =  listnomtmp;
+    }
+  }
+  }
+}
+
+/******************************************************************************/
+/*                                AddUseAgrifUtil_0                           */
+/******************************************************************************/
+/* Add use Agrif_Util at the beginning of the subroutine definition           */
+/* if it is necessary                                                         */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub            |  subroutine sub                          */
+/*                                 |  USE Agrif_Util                          */
+/*       implicit none             |  implicit none                           */
+/*       ...                       |  ...                                     */
+/*       ... Agrif_<something>     |  ... Agrif_<something>                   */
+/*       ...                       |  ...                                     */
+/*       end                       |  end                                     */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void  AddUseAgrifUtil_0(FILE *fileout)
+{
+  listnom *parcours;
+
+  if ( firstpass == 0 )
+  {
+     parcours = List_SubroutineWhereAgrifUsed;
+     while ( parcours && strcasecmp(parcours->o_nom,subroutinename) )
+                                                    parcours = parcours -> suiv;
+     if ( parcours && parcours->o_val != 0 )
+                                   fprintf(fileout,"\n      USE Agrif_Util \n");
+  }
+}
+
+void  AddUseAgrifUtilBeforeCall_0(FILE *fileout)
+{
+  listusemodule *parcours;
+
+  int out;
+
+  if ( firstpass == 0 )
+  {
+     parcours = List_NameOfModuleUsed;
+     out = 0 ;
+     while ( parcours && out == 0 )
+     {
+        if ( !strcasecmp(parcours->u_usemodule,"Agrif_Util")     &&
+             !strcasecmp(parcours->u_modulename,curmodulename)   &&
+             !strcasecmp(parcours->u_cursubroutine,subroutinename)
+            ) out = 1;
+        else parcours = parcours->suiv;
+     }
+     if ( out == 0 )
+     {
+        fprintf(fileout,"\n      USE Agrif_Util \n");
+     }
+  }
+}
+
+/******************************************************************************/
+/*                         NotifyAgrifFunction_0                              */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void NotifyAgrifFunction_0(char *ident)
+{
+   if ( firstpass == 0 )
+   {
+      if ( !strcasecmp(ident,"Agrif_parent") )
+      {
+         InAgrifParentDef = 1;
+         pos_curagrifparent = setposcur()-12;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Get_Coarse_grid") )
+      {
+         InAgrifParentDef = 2;
+         pos_curagrifparent = setposcur()-21;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Rhox") )
+      {
+         InAgrifParentDef = 3;
+         pos_curagrifparent = setposcur()-10;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Rhox") )
+      {
+         InAgrifParentDef = 4;
+         pos_curagrifparent = setposcur()-17;
+      }
+      else if ( !strcasecmp(ident,"Agrif_IRhox") )
+      {
+         InAgrifParentDef = 5;
+         pos_curagrifparent = setposcur()-11;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_IRhox") )
+      {
+         InAgrifParentDef = 6;
+         pos_curagrifparent = setposcur()-18;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Rhoy") )
+      {
+         InAgrifParentDef = 7;
+         pos_curagrifparent = setposcur()-10;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Rhoy") )
+      {
+         InAgrifParentDef = 8;
+         pos_curagrifparent = setposcur()-17;
+      }
+      else if ( !strcasecmp(ident,"Agrif_IRhoy") )
+      {
+         InAgrifParentDef = 9;
+         pos_curagrifparent = setposcur()-11;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_IRhoy") )
+      {
+         InAgrifParentDef = 10;
+         pos_curagrifparent = setposcur()-18;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Rhoz") )
+      {
+         InAgrifParentDef = 11;
+         pos_curagrifparent = setposcur()-10;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Rhoz") )
+      {
+         InAgrifParentDef = 12;
+         pos_curagrifparent = setposcur()-17;
+      }
+      else if ( !strcasecmp(ident,"Agrif_IRhoz") )
+      {
+         InAgrifParentDef = 13;
+         pos_curagrifparent = setposcur()-11;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_IRhoz") )
+      {
+         InAgrifParentDef = 14;
+         pos_curagrifparent = setposcur()-18;
+      }
+      else if ( !strcasecmp(ident,"Agrif_NearCommonBorderX") )
+      {
+         InAgrifParentDef = 15;
+         pos_curagrifparent = setposcur()-23;
+      }
+      else if ( !strcasecmp(ident,"Agrif_NearCommonBorderY") )
+      {
+         InAgrifParentDef = 16;
+         pos_curagrifparent = setposcur()-23;
+      }
+      else if ( !strcasecmp(ident,"Agrif_NearCommonBorderZ") )
+      {
+         InAgrifParentDef = 17;
+         pos_curagrifparent = setposcur()-23;
+      }
+      else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderX") )
+      {
+         InAgrifParentDef = 18;
+         pos_curagrifparent = setposcur()-26;
+      }
+      else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderY") )
+      {
+         InAgrifParentDef = 19;
+         pos_curagrifparent = setposcur()-26;
+      }
+      else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderZ") )
+      {
+         InAgrifParentDef = 20;
+         pos_curagrifparent = setposcur()-26;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Get_parent_id") )
+      {
+         InAgrifParentDef = 21;
+         pos_curagrifparent = setposcur()-19;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Get_grid_id") )
+      {
+         InAgrifParentDef = 22;
+         pos_curagrifparent = setposcur()-17;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Iz") )
+      {
+         InAgrifParentDef = 23;
+         pos_curagrifparent = setposcur()-15;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Iy") )
+      {
+         InAgrifParentDef = 24;
+         pos_curagrifparent = setposcur()-15;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Parent_Ix") )
+      {
+         InAgrifParentDef = 25;
+         pos_curagrifparent = setposcur()-15;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Iz") )
+      {
+         InAgrifParentDef = 26;
+         pos_curagrifparent = setposcur()-8;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Iy") )
+      {
+         InAgrifParentDef = 27;
+         pos_curagrifparent = setposcur()-8;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Ix") )
+      {
+         InAgrifParentDef = 28;
+         pos_curagrifparent = setposcur()-8;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Nb_Fixed_Grids") )
+      {
+         InAgrifParentDef = 29;
+         pos_curagrifparent = setposcur()-20;
+      }
+      else if ( !strcasecmp(ident,"Agrif_Nb_Fine_Grids") )
+      {
+         InAgrifParentDef = 29;
+         pos_curagrifparent = setposcur()-19;
+      }
+      else if ( !strcasecmp(ident,"AGRIF_Nb_Step") )
+      {
+         InAgrifParentDef = 30;
+         pos_curagrifparent = setposcur()-13;
+      }
+   }
+}
+
+/******************************************************************************/
+/*                       ModifyTheAgrifFunction_0                             */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void ModifyTheAgrifFunction_0(char *ident)
+{
+   if ( InAgrifParentDef != 0 )
+          AgriffunctionModify_0(ident,InAgrifParentDef);
+   /*                                                                         */
+   InAgrifParentDef = 0;
+}
+
+
+/******************************************************************************/
+/*                         AgriffunctionModify_0                              */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/* if whichone = 1 Agrif_parent ===>                                          */
+/*                                                                            */
+/* if whichone = 2 Agrif_Get_coarse_grid ===>                                 */
+/*                                                                            */
+/* if whichone = 3 Agrif_Rhox ===>                                            */
+/*                                                                            */
+/* if whichone = 4 Agrif_Parent_Rhox ===>                                     */
+/*                                                                            */
+/* if whichone = 5 Agrif_IRhox ===>                                           */
+/*                                                                            */
+/* if whichone = 6 Agrif_Parent_IRhox ===>                                    */
+/*                                                                            */
+/* if whichone = 7 Agrif_Rhoy ===>                                            */
+/*                                                                            */
+/* if whichone = 8 Agrif_Parent_Rhoy ===>                                     */
+/*                                                                            */
+/* if whichone = 9 Agrif_IRhoy ===>                                           */
+/*                                                                            */
+/* if whichone = 10 Agrif_Parent_IRhoy ===>                                   */
+/*                                                                            */
+/* if whichone = 11 Agrif_Rhoz ===>                                           */
+/*                                                                            */
+/* if whichone = 12 Agrif_Parent_Rhoz ===>                                    */
+/*                                                                            */
+/* if whichone = 13 Agrif_IRhoz ===>                                          */
+/*                                                                            */
+/* if whichone = 14 Agrif_Parent_IRhoz ===>                                   */
+/*                                                                            */
+/* if whichone = 15 Agrif_NearCommonBorderX ===>                              */
+/*                                                                            */
+/* if whichone = 16 Agrif_NearCommonBorderX ===>                              */
+/*                                                                            */
+/* if whichone = 17 Agrif_NearCommonBorderX ===>                              */
+/*                                                                            */
+/* if whichone = 18 Agrif_DistantCommonBorderX ===>                           */
+/*                                                                            */
+/* if whichone = 19 Agrif_DistantCommonBorderY ===>                           */
+/*                                                                            */
+/* if whichone = 20 Agrif_DistantCommonBorderZ ===>                           */
+/*                                                                            */
+/* if whichone = 21 Agrif_Get_parent_id ===>                                  */
+/*                                                                            */
+/* if whichone = 22 Agrif_Get_grid_id ===>                                    */
+/*                                                                            */
+/* if whichone = 23 Agrif_Parent_Iz ===>                                      */
+/*                                                                            */
+/* if whichone = 24 Agrif_Parent_Iy ===>                                      */
+/*                                                                            */
+/* if whichone = 25 Agrif_Parent_Ix ===>                                      */
+/*                                                                            */
+/* if whichone = 26 Agrif_Iz ===>                                             */
+/*                                                                            */
+/* if whichone = 27 Agrif_Iy ===>                                             */
+/*                                                                            */
+/* if whichone = 28 Agrif_Ix ===>                                             */
+/*                                                                            */
+/* if whichone = 29 Agrif_Nb_Fixed_Grids ===>                                 */
+/*                                                                            */
+/* if whichone = 29 Agrif_Nb_Fine_Grids ===>                                  */
+/*                                                                            */
+/* if whichone = 30 AGRIF_Nb_Step ===>                                        */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void AgriffunctionModify_0(char *ident,int whichone)
+{
+   char toprint[LONG_C];
+   if ( firstpass == 0 )
+   {
+      strcpy(toprint,"");
+      pos_end = setposcur();
+      fseek(fortranout,pos_curagrifparent,SEEK_SET);
+      if ( whichone == 1 || whichone == 2 )
+      {
+         /*                                                                   */
+         FindAndChangeNameToTabvars(ident,toprint,List_Global_Var,1);
+         if ( !strcasecmp(ident,toprint) )
+         {
+            /* la liste des use de cette subroutine                           */
+            strcpy(toprint,"");
+            FindAndChangeNameToTabvars(ident,
+                                          toprint,List_Common_Var,whichone);
+         }
+         if ( !strcasecmp(ident,toprint) )
+         {
+            /* la liste des use de cette subroutine                           */
+            strcpy(toprint,"");
+            FindAndChangeNameToTabvars(ident,
+                                          toprint,List_ModuleUsed_Var,whichone);
+         }
+      }
+      else if ( whichone == 3 ) /* Agrif_Rhox                                 */
+      {
+         sprintf(toprint,"REAL(");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"Agrif_Curgrid % spaceref(1))");
+      }
+      else if ( whichone == 4 ) /* Agrif_Parent_Rhox                          */
+      {
+         sprintf(toprint,"REAL(");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"Agrif_Curgrid % parent % spaceref(1))");
+      }
+      else if ( whichone == 5 ) /* Agrif_Rhox                                 */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% spaceref(1)");
+      }
+      else if ( whichone == 6 ) /* Agrif_Parent_Rhox                          */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % spaceref(1)");
+      }
+      else if ( whichone == 7 ) /* Agrif_Rhoy                                 */
+      {
+         sprintf(toprint,"REAL(Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% spaceref(2))");
+      }
+      else if ( whichone == 8 ) /* Agrif_Parent_Rhoy                          */
+      {
+         sprintf(toprint,"REAL(Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % spaceref(2))");
+      }
+      else if ( whichone == 9 ) /* Agrif_Rhoy                                 */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% spaceref(2)");
+      }
+      else if ( whichone == 10 ) /* Agrif_Parent_Rhoy                         */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % spaceref(2)");
+      }
+      else if ( whichone == 11 ) /* Agrif_Rhoz                                */
+      {
+         sprintf(toprint,"REAL(Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% spaceref(3))");
+      }
+      else if ( whichone == 12 ) /* Agrif_Parent_Rhoz                         */
+      {
+         sprintf(toprint,"REAL(Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % spaceref(3))");
+      }
+      else if ( whichone == 13 ) /* Agrif_Rhoz                                */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% spaceref(3)");
+      }
+      else if ( whichone == 14 ) /* Agrif_Parent_Rhoz                         */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % spaceref(3)");
+      }
+      else if ( whichone == 15 ) /* Agrif_NearCommonBorderX                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% NearRootBorder(1)");
+      }
+      else if ( whichone == 16 ) /* Agrif_NearCommonBorderY                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% NearRootBorder(2)");
+      }
+      else if ( whichone == 17 ) /* Agrif_NearCommonBorderZ                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% NearRootBorder(3)");
+      }
+      else if ( whichone == 18 ) /* Agrif_NearCommonBorderX                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% DistantRootBorder(1)");
+      }
+      else if ( whichone == 19 ) /* Agrif_NearCommonBorderY                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% DistantRootBorder(2)");
+      }
+      else if ( whichone == 20 ) /* Agrif_NearCommonBorderZ                   */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% DistantRootBorder(3)");
+      }
+      else if ( whichone == 21 ) /* Agrif_Get_parent_id                       */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % grid_id");
+      }
+      else if ( whichone == 22 ) /*  Agrif_Get_grid_id                        */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% grid_id");
+      }
+      else if ( whichone == 23 ) /*  Agrif_Parent_Iz                          */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % ix(3)");
+      }
+      else if ( whichone == 24 ) /*  Agrif_Parent_Iy                          */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % ix(2)");
+      }
+      else if ( whichone == 25 ) /*  Agrif_Parent_Ix                          */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% parent % ix(1)");
+      }
+      else if ( whichone == 26 ) /* Agrif_Iz                                  */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint," % ix(3)");
+      }
+      else if ( whichone == 27 ) /* Agrif_Iy                                  */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% ix(2)");
+      }
+      else if ( whichone == 28 ) /* Agrif_Ix                                  */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% ix(1)");
+      }
+      else if ( whichone == 29 ) /* Agrif_Nb_Fixed_Grids                      */
+      {
+         sprintf(toprint,"Agrif_nbfixedgrids");
+      }
+      else if ( whichone == 30 ) /* AGRIF_Nb_Step                             */
+      {
+         sprintf(toprint,"Agrif_Curgrid");
+         if( retour77 == 0 ) strcat(toprint," & \n");
+         else strcat(toprint,"\n     & ");
+         strcat(toprint,"% ngridstep");
+      }
+      /*                                                                      */
+      if ( whichone == 1 || whichone == 2 )
+      {
+         Save_Length(toprint,43);
+         tofich(fortranout,toprint,2);
+      }
+      else
+      {
+/*         if( retour77 == 0 ) fprintf(fortranout," & \n");
+         else fprintf(fortranout,"\n     & ");*/
+         Save_Length(toprint,43);
+         fprintf(fortranout,"%s",toprint);
+      }
+   }
+}
+
+
+/******************************************************************************/
+/*                             Instanciation_0                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void Instanciation_0(char *ident)
+{
+   listvar *newvar;
+   int out;
+
+   if ( firstpass == 0 && sameagrifargument == 1 )
+   {
+      newvar = List_Global_Var;
+
+      out=0;
+      while ( newvar && out == 0 )
+      {
+         if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+         else newvar=newvar->suiv;
+      }
+
+      if ( out == 0 )
+      {
+         newvar = List_Common_Var;
+
+         out=0;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+      if ( out == 0 )
+      {
+         newvar = List_ModuleUsed_Var;
+
+         out=0;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
+            else newvar=newvar->suiv;
+         }
+      }
+
+      if ( out == 1 )
+      {
+         /* then write the instanciation                                      */
+         fprintf(fortranout,"\n      %s = %s",ident,
+                                          vargridcurgridtabvars(newvar->var,3));
+         colnum = 0;
+      }
+   }
+   sameagrifargument = 0;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilCharacter.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilCharacter.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilCharacter.c	(revision 1844)
@@ -0,0 +1,445 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+
+
+
+/******************************************************************************/
+/*                         FindAndChangeNameToTabvars                         */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+/* if  whichone = 0 ----> Agrif_tabvars(i) % var % array2                     */
+/*                                                                            */
+/* if  whichone = 1 ----> Agrif_tabvars(i) % parentvar % var % array2         */
+/*                                                                            */
+/******************************************************************************/
+void FindAndChangeNameToTabvars(char name[LONG_C],char toprint[LONG_4C],
+                                              listvar * listtosee, int whichone)
+{
+   listvar *newvar;
+   int out;
+   
+
+   if ( strcasecmp(name,"") )
+   {
+      newvar=listtosee;
+      out=0;
+      while( newvar && out == 0 )
+      {
+         if ( !strcasecmp(newvar->var->v_nomvar,name) )
+         {
+
+            if ( LookingForVariableInListName(
+                             List_SubroutineArgument_Var,name) == 0 )
+            {
+               out = 1;
+               strcat(toprint,vargridcurgridtabvars(newvar->var,whichone));
+            }
+            else newvar=newvar->suiv;
+         }
+         else newvar=newvar->suiv;
+      }
+      if ( out == 0 ) strcat(toprint,name);
+   }
+   Save_Length(toprint,44);
+}
+
+
+/******************************************************************************/
+/*                     ChangeTheInitalvaluebyTabvarsName                      */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+char *ChangeTheInitalvaluebyTabvarsName(char *nom,listvar *listtoread,
+                                                                   int whichone)
+{
+   char toprinttmp[LONG_4C];
+   int i;
+   char chartmp[2];
+
+   i=0;
+   strcpy(toprintglob,"");
+   strcpy(toprinttmp,"");
+
+   /*                                                                         */
+   while ( i < strlen(nom) )
+   {
+      if ( nom[i] == '+' )
+      {
+        FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,"+");
+      }
+      else if ( nom[i] == '-' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,"-");
+      }
+      else if ( nom[i] == '*' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,"*");
+      }
+      else if ( nom[i] == '/' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,"/");
+      }
+      else if ( nom[i] == '(' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,"(");
+      }
+      else if ( nom[i] == ')' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,")");
+      }
+      else if ( nom[i] == ':' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,":");
+      }
+      else if ( nom[i] == ',' )
+      {
+         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+         strcpy(toprinttmp,"");
+         strcat(toprintglob,",");
+      }
+      else
+      {
+         sprintf(chartmp,"%c",nom[i]);
+         strcat(toprinttmp,chartmp);
+      }
+      /*                                                                      */
+      i=i+1;
+   }
+   FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone);
+   strcpy(toprinttmp,"");
+
+   Save_Length(toprinttmp,44);
+   Save_Length(toprintglob,39);
+
+   /*                                                                         */
+   return toprintglob;
+}
+
+/******************************************************************************/
+/*                            IsVariableReal                                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+int IsVariableReal(char *nom)
+{
+   int Real;
+
+   Real = 0;
+   if ( ( nom[0] >= 'a' && nom[0] <= 'h' ) ||
+        ( nom[0] >= 'A' && nom[0] <= 'H' ) ||
+        ( nom[0] >= 'o' && nom[0] <= 'z' ) ||
+        ( nom[0] >= 'O' && nom[0] <= 'Z' )
+       )
+       {
+          Real = 1;
+       }
+   /*                                                                         */
+   return Real;
+}
+/******************************************************************************/
+/*                         IsVarInUseFile                                     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void IsVarInUseFile(char *nom)
+{
+   listvar *parcours;
+   listparameter *parcoursparam;
+   int out;
+
+   out = 0;
+
+   parcours = List_Global_Var;
+   while( parcours && out == 0 )
+   {
+      if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ;
+     else parcours=parcours->suiv;
+   }
+   if ( out == 0 )
+   {
+      parcours = List_Common_Var;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ;
+        else parcours=parcours->suiv;
+      }
+   }
+   if ( out == 0 )
+   {
+      parcours = List_GlobalParameter_Var;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ;
+        else parcours=parcours->suiv;
+      }
+   }
+   if ( out == 0 )
+   {
+      parcours = List_Parameter_Var;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ;
+        else parcours=parcours->suiv;
+      }
+   }
+   if ( out == 0 )
+   {
+      parcoursparam = List_GlobParamModuleUsed_Var;
+      while( parcoursparam && out == 0 )
+      {
+         if ( !strcasecmp(nom,parcoursparam->p_name) ) out =2 ;
+         else parcoursparam=parcoursparam->suiv;
+      }
+   }
+   if ( out == 0 )
+   {
+      parcours = List_ModuleUsed_Var;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =2 ;
+        else parcours=parcours->suiv;
+      }
+   }
+   if ( out == 0 || out == 2 )
+   {
+      parcoursparam = List_GlobParamModuleUsedInModuleUsed_Var;
+      while( parcoursparam && out != 1 )
+      {
+         if ( !strcasecmp(nom,parcoursparam->p_name) ) out =1 ;
+         else parcoursparam=parcoursparam->suiv;
+      }
+      if ( out == 1 )
+      {
+         strcpy(charusemodule,parcoursparam->p_modulename);
+         Addmoduletothelist(parcoursparam->p_modulename);
+      }
+   }
+   if ( out == 0 &&
+        strcasecmp(nom,"MAX")             &&
+        strcasecmp(nom,"mpi_status_size")
+      )
+   {
+      printf("--- in UtilCharacter we do not found the \n");
+      printf("---  variable %s, the module where this \n",nom);
+      printf("---  variable has been defined has not been\n");
+      printf("---  found.\n");
+   }
+}
+
+/******************************************************************************/
+/*                      DecomposeTheNameinlistnom                             */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout)
+{
+   char toprinttmp[LONG_4C];
+   int i;
+   char chartmp[2];
+
+   i=0;
+   strcpy(toprinttmp,"");
+   /*                                                                         */
+   while ( i < strlen(nom) )
+   {
+      if ( nom[i] == '+' ||
+           nom[i] == '-' ||
+           nom[i] == '*' ||
+           nom[i] == '/' ||
+           nom[i] == ')' ||
+           nom[i] == '(' ||
+           nom[i] == ',' ||
+           nom[i] == ':'
+         )
+      {
+         if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) )
+         {
+             listout = Addtolistnom(toprinttmp,listout,0);
+         }
+         strcpy(toprinttmp,"");
+      }
+      else
+      {
+         sprintf(chartmp,"%c",nom[i]);
+         strcat(toprinttmp,chartmp);
+      }
+      /*                                                                      */
+      i=i+1;
+   }
+   if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) )
+   {
+      listout = Addtolistnom(toprinttmp,listout,0);
+   }
+   strcpy(toprinttmp,"");
+   Save_Length(toprinttmp,44);
+
+   return listout;
+}
+
+
+/******************************************************************************/
+/*                      DecomposeTheName                                      */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+void DecomposeTheName(char *nom)
+{
+   char toprinttmp[LONG_4C];
+   int i;
+   char chartmp[2];
+
+   i=0;
+   strcpy(toprinttmp,"");
+   /*                                                                         */
+   while ( i < strlen(nom) )
+   {
+      if ( nom[i] == '+' ||
+           nom[i] == '-' ||
+           nom[i] == '*' ||
+           nom[i] == '/' ||
+           nom[i] == ')' ||
+           nom[i] == '(' ||
+           nom[i] == ',' ||
+           nom[i] == ':'
+         )
+      {
+         if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) )
+         {
+            ajoutevarindoloop_definedimension (toprinttmp);
+            /* Is this variable present in globvarofusefile                   */
+            IsVarInUseFile(toprinttmp);
+         }
+         strcpy(toprinttmp,"");
+      }
+      else
+      {
+         sprintf(chartmp,"%c",nom[i]);
+         strcat(toprinttmp,chartmp);
+      }
+      /*                                                                      */
+      i=i+1;
+   }
+   Save_Length(toprinttmp,44);
+   if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) )
+   {
+      ajoutevarindoloop_definedimension (toprinttmp);
+      /* Is this variable present in globvarofusefile                         */
+      IsVarInUseFile(toprinttmp);
+   }
+   strcpy(toprinttmp,"");
+
+}
+
+void convert2lower(char *name)
+{
+   int l;
+   int i;
+   int caractere;
+
+   l=strlen(name)-1;
+   for (i=0;i<=l;i++)
+   {
+      caractere=name[i];
+      if ((caractere>=65 && caractere<=90)||(caractere>=192 && caractere<=221))
+      {
+         name[i]+=32;
+      }
+   }
+}
+
+int convert2int(char *name)
+{
+   int i;
+   int caractere;
+   int value;
+   int value_tmp;
+   int longueur;
+
+   value = 0;
+
+   longueur = strlen(name) - 1;
+   for (i=0;i<=longueur;i++)
+   {
+      caractere=name[i];
+      value_tmp = caractere -'0';
+      if ( value_tmp > 9 ) return 0;
+           if ( longueur+1-i == 6 ) value = value + value_tmp *100000;
+      else if ( longueur+1-i == 5 ) value = value + value_tmp *10000;
+      else if ( longueur+1-i == 4 ) value = value + value_tmp *1000;
+      else if ( longueur+1-i == 3 ) value = value + value_tmp *100;
+      else if ( longueur+1-i == 2 ) value = value + value_tmp *10;
+      else if ( longueur+1-i == 1 ) value = value + value_tmp *1;
+   }
+   return value;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFile.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFile.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFile.c	(revision 1844)
@@ -0,0 +1,146 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+
+/******************************************************************************/
+/*                            associate                                       */
+/******************************************************************************/
+/* This subroutine is used to open a file                                     */
+/******************************************************************************/
+FILE * associate (char *filename)
+{
+  char filefich[LONG_C];
+  sprintf(filefich,"%s/%s",nomdir,filename);
+  return fopen (filefich, "w");
+}
+
+
+/******************************************************************************/
+/*                          associateaplus                                    */
+/******************************************************************************/
+/* This subroutine is used to open a file with option a+                      */
+/******************************************************************************/
+FILE * associateaplus (char *filename)
+{
+  char filefich[LONG_C];
+  sprintf(filefich,"%s/%s",nomdir,filename);
+  return fopen (filefich, "a+");
+}
+
+
+/******************************************************************************/
+/*                           setposcurname                                       */
+/******************************************************************************/
+/* This subroutine is used to know the current position in the file in argument    */
+/******************************************************************************/
+/*                                                                            */
+/*                      setposcur ---------> position in file                 */
+/*                                                                            */
+/******************************************************************************/
+long int setposcurname(FILE *fileout)
+{
+   fflush(fileout);
+   return ftell(fileout);
+}
+
+/******************************************************************************/
+/*                           setposcur                                        */
+/******************************************************************************/
+/* This subroutine is used to know the current position in the file           */
+/******************************************************************************/
+/*                                                                            */
+/*                      setposcur ---------> position in file                 */
+/*                                                                            */
+/******************************************************************************/
+long int setposcur()
+{
+   fflush(fortranout);
+   return ftell(fortranout);
+}
+
+/******************************************************************************/
+/*                      setposcurinoldfortranout                              */
+/******************************************************************************/
+/* This subroutine is used to know the position in the oldfortranout         */
+/******************************************************************************/
+/*                                                                            */
+/*             setposcurinoldfortranout ---------> position in file           */
+/*                                                                            */
+/******************************************************************************/
+long int setposcurinoldfortranout()
+{
+   fflush(oldfortranout);
+   return ftell(oldfortranout);
+}
+
+/******************************************************************************/
+/*                         copyuse_0                                          */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/* We should write in the fortranout the USE tok_name                         */
+/* read in the original file                                                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void copyuse_0(char *namemodule)
+{
+   if (firstpass == 0 && IsTabvarsUseInArgument_0() == 1 )
+   {
+      /* We should write this declaration into the original subroutine too    */
+      fprintf(oldfortranout,"      USE %s \n",namemodule);
+   }
+}
+
+/******************************************************************************/
+/*                         copyuseonly_0                                      */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/* We should write in the fortranout the USE tok_name, only                   */
+/* read in the original file                                                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void copyuseonly_0(char *namemodule)
+{
+   if (firstpass == 0 && IsTabvarsUseInArgument_0() == 1 )
+   {
+      /* We should write this declaration into the original subroutine too    */
+      fprintf(oldfortranout,"      USE %s , ONLY : \n",namemodule);
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFortran.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFortran.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilFortran.c	(revision 1844)
@@ -0,0 +1,784 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                            initdimprob                                     */
+/******************************************************************************/
+/* This subroutine is used to initialized grid dimension variable             */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void initdimprob(int dimprobmod, char * nx, char * ny,char* nz)
+{
+  dimprob = dimprobmod;
+
+  strcpy(nbmaillesX,nx);
+  strcpy(nbmaillesY,ny);
+  strcpy(nbmaillesZ,nz);
+}
+
+/******************************************************************************/
+/*                      Variableshouldberemove                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */
+/*                                                                            */
+/******************************************************************************/
+int Variableshouldberemove(char *nom)
+{
+
+   int remove;
+
+   remove = 0 ;
+
+   if ( remove == 0 && Agrif_in_Tok_NAME(nom) == 1 ) remove = 1 ;
+
+   return remove;
+}
+
+/******************************************************************************/
+/*                          variableisglobal                                  */
+/******************************************************************************/
+/* This subroutine is to know if a variable is global                         */
+/******************************************************************************/
+int variableisglobal(listvar *curvar, listvar *listin)
+{
+  int Globalite;
+  listvar *newvar;
+
+
+  Globalite = 0;
+  newvar = listin;
+  while ( newvar && Globalite == 0 )
+  {
+     if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) )
+     {
+        Globalite = 1;
+        /* Now we should give the definition of the variable in the           */
+        /* table List_UsedInSubroutine_Var                                    */
+        strcpy(curvar->var->v_typevar,newvar->var->v_typevar);
+        strcpy(curvar->var->v_dimchar,newvar->var->v_dimchar);
+        curvar->var->v_nbdim = newvar->var->v_nbdim;
+        curvar->var->v_dimensiongiven = newvar->var->v_dimensiongiven;
+        curvar->var->v_allocatable = newvar->var->v_allocatable;
+        curvar->var->v_pointerdeclare = newvar->var->v_pointerdeclare;
+        curvar->var->v_indicetabvars = newvar->var->v_indicetabvars;
+        strcpy(curvar->var->v_nameinttypename,newvar->var->v_nameinttypename);
+        strcpy(curvar->var->v_precision,newvar->var->v_precision);
+        strcpy(curvar->var->v_readedlistdimension,
+                                            newvar->var->v_readedlistdimension);
+        strcpy(curvar->var->v_commoninfile,newvar->var->v_commoninfile);
+     }
+     else
+     {
+         newvar = newvar->suiv;
+     }
+  }
+
+  return Globalite ;
+}
+
+int VariableIsInListCommon(listvar *curvar,listvar *listin)
+{
+  int present;
+  listvar *newvar;
+
+  present = 0;
+  newvar = listin;
+  while ( newvar && present == 0 )
+  {
+     if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) &&
+          !strcasecmp(newvar->var->v_subroutinename,
+                                    curvar->var->v_subroutinename)
+        )
+     {
+        CopyRecord(curvar->var,newvar->var);
+        present = 1;
+     }
+     else newvar = newvar->suiv;
+  }
+
+  return present;
+}
+
+int VariableIsInList(listvar *curvar,listvar *listin)
+{
+  int present;
+  listvar *newvar;
+
+  present = 0;
+  newvar = listin;
+  while ( newvar && present == 0 )
+  {
+     if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) )
+     {
+        CopyRecord(curvar->var,newvar->var);
+        present = 1;
+     }
+     else newvar = newvar->suiv;
+  }
+
+  return present;
+}
+
+/******************************************************************************/
+/*                      variableisglobalinmodule                              */
+/******************************************************************************/
+/* This subroutine is to know if a variable is global                         */
+/******************************************************************************/
+void variableisglobalinmodule(listcouple *listin, char *module, FILE *fileout, long int oldposcuruse)
+{
+  int Globalite;
+  listcouple *newvar;
+  listcouple *newvarprec;
+  listvar *tempo;
+  listvar *newvar2;
+  int out;
+  char truename[LONG_C];  
+
+  Globalite = 1;
+  newvarprec = (listcouple *)NULL;
+  tempo = (listvar *)NULL;
+  tempo = Readthedependfile(module,tempo);
+  newvar = listin;
+
+  while ( newvar )
+  {
+     if (!strcmp(newvar->c_namepointedvar,"")) {
+       strcpy(truename,newvar->c_namevar);
+     }
+     else
+     {
+       strcpy(truename,newvar->c_namepointedvar);
+     }
+     
+     out = 0;
+     newvar2 = tempo;
+     while ( newvar2 && out == 0 )
+     {
+        if ( !strcasecmp(newvar2->var->v_nomvar,truename) ) out = 1;
+        else newvar2 = newvar2 ->suiv;
+     }
+     if ( out == 1 )
+     {
+        /* remove from the listin                                             */
+        if ( newvar == listin )
+        {
+           listin = listin->suiv;
+           newvar = listin;
+        }
+        else
+        {
+           newvarprec->suiv = newvar->suiv;
+           newvar = newvar->suiv;
+        }
+     }
+     else
+     {
+         newvarprec = newvar;
+         newvar = newvar->suiv;
+         Globalite = 0;
+     }
+  }
+  if ( Globalite == 0 || !newvar)
+  {
+     pos_end = setposcurname(fileout);
+     RemoveWordSET_0(fileout,oldposcuruse,
+                                pos_end-oldposcuruse);
+                                  
+     newvar = listin;
+     while ( newvar )
+     {
+        fprintf(fileout,"      USE %s, ONLY : %s \n",module,newvar->c_namevar);
+        newvar = newvar->suiv;
+     }
+  }
+}
+
+
+void Remove_Word_Contains_0()
+{
+   if ( firstpass == 0 )
+   {
+      RemoveWordCUR_0(fortranout,(long)(-9),9);
+   }
+}
+
+void Remove_Word_end_module_0(int modulenamelength)
+{
+   if ( firstpass == 0 )
+   {
+      RemoveWordCUR_0(fortranout,(long)(-modulenamelength-12),
+                                         modulenamelength+11);
+   }
+}
+
+void Write_Word_Contains_0()
+{
+   if ( firstpass == 0 )
+   {
+      fprintf(fortranout,"\n      contains\n");
+   }
+}
+
+
+void Write_Word_end_module_0()
+{
+   if ( firstpass == 0 )
+   {
+      fprintf(fortranout,"\n      end module %s",curmodulename);
+   }
+}
+
+void Add_Subroutine_For_Alloc(char *nom)
+{
+   listnom *parcours;
+   listnom *newvar;
+   int out;
+
+   newvar = (listnom *)malloc(sizeof(listnom));
+   strcpy(newvar->o_nom,nom);
+   Save_Length(nom,23);
+   newvar->suiv = NULL;
+
+   if ( !List_Subroutine_For_Alloc )
+   {
+      List_Subroutine_For_Alloc = newvar;
+   }
+   else
+   {
+      parcours = List_Subroutine_For_Alloc;
+      out = 0 ;
+      while ( parcours->suiv && out == 0 )
+      {
+         if ( !strcasecmp(parcours->o_nom,nom) ) out = 1 ;
+         else parcours = parcours ->suiv;
+      }
+      /*                                                                      */
+      if ( out == 0 )
+      {
+         if ( strcasecmp(parcours->o_nom,nom) ) parcours->suiv = newvar;
+      }
+   }
+}
+
+
+void Write_Alloc_Subroutine_0()
+{
+   listnom *parcours_nom;
+   listnom *parcours_nomprec;
+   int out;
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 )
+   {
+      parcours_nomprec = (listnom *)NULL;
+      parcours_nom = List_NameOfModule;
+      out = 0 ;
+      while ( parcours_nom && out == 0 )
+      {
+         /*                                                                   */
+         if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1;
+         else parcours_nom = parcours_nom -> suiv;
+      }
+      if ( out == 1 )
+      {
+         if ( parcours_nom->o_val == 1 )
+         {
+            strcpy (ligne, "\n      PUBLIC Alloc_agrif_");
+            strcat (ligne, curmodulename);
+            strcat (ligne, "\n");
+            convert2lower(ligne);
+            fprintf(fortranout,ligne);
+         }
+      }
+      Write_Word_Contains_0();
+      if ( out == 1 )
+      {
+         if ( parcours_nom->o_val == 1 )
+         {
+            sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)",
+                                                                 curmodulename);
+            tofich(fortranout,ligne,1);
+            strcpy(ligne,"Use Agrif_Util");
+            tofich(fortranout,ligne,1);
+            strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr");
+            tofich(fortranout,ligne,1);
+            strcpy(ligne, "INTEGER :: i");
+            tofich (fortranout, ligne,1);
+            strcpy (ligne, "\n#include \"alloc_agrif_");
+            strcat (ligne, curmodulename);
+            strcat (ligne, ".h\"\n");
+            convert2lower(ligne);
+            fprintf(fortranout,ligne);
+            strcpy (ligne, "Return");
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename);
+            tofich(fortranout,ligne,1);
+            /* List all Call Alloc_agrif_                                     */
+            Add_Subroutine_For_Alloc(curmodulename);
+         }
+         else
+         {
+            parcours_nom = List_Subroutine_For_Alloc;
+            out = 0;
+            while ( parcours_nom && out == 0 )
+            {
+               if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1;
+               else
+               {
+                  parcours_nomprec = parcours_nom;
+                  parcours_nom = parcours_nom->suiv;
+               }
+            }
+            if ( out == 1 )
+            {
+               if ( parcours_nom == List_Subroutine_For_Alloc)
+               {
+                  List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv;
+               }
+               else
+               {
+                  parcours_nomprec->suiv = parcours_nom->suiv;
+                  parcours_nom = parcours_nomprec->suiv ;
+               }
+            }
+         }
+      }
+   }
+}
+
+
+void Write_Alloc_Subroutine_For_End_0()
+{
+   listnom *parcours_nom;
+   listnom *parcours_nomprec;
+   int out;
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 )
+   {
+      parcours_nomprec = (listnom *)NULL;
+      parcours_nom = List_NameOfModule;
+      out = 0 ;
+      while ( parcours_nom && out == 0 )
+      {
+         /*                                                                   */
+         if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1;
+         else parcours_nom = parcours_nom -> suiv;
+      }
+      if ( out == 1 )
+      {
+         if ( parcours_nom->o_val == 1 )
+         {
+            strcpy (ligne, "\n      PUBLIC Alloc_agrif_");
+            strcat (ligne, curmodulename);
+            strcat (ligne, "\n");
+            convert2lower(ligne);
+            fprintf(fortranout,ligne);
+            strcpy (ligne, "\n      contains\n");
+            fprintf(fortranout,ligne);
+            sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)",
+                                                                 curmodulename);
+            tofich(fortranout,ligne,1);
+            strcpy(ligne,"Use Agrif_Util");
+            tofich(fortranout,ligne,1);
+            strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr");
+            tofich(fortranout,ligne,1);
+            strcpy(ligne, "INTEGER :: i");
+            tofich (fortranout, ligne,1);
+            strcpy (ligne, "\n#include \"alloc_agrif_");
+            strcat (ligne, curmodulename);
+            strcat (ligne, ".h\"\n");
+            convert2lower(ligne);
+            fprintf(fortranout,ligne);
+            strcpy (ligne, "Return");
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename);
+            tofich(fortranout,ligne,1);
+            /* List all Call Alloc_agrif                                      */
+            Add_Subroutine_For_Alloc(parcours_nom->o_nom);
+         }
+         else
+         {
+            parcours_nom = List_Subroutine_For_Alloc;
+            out = 0;
+            while ( parcours_nom && out == 0 )
+            {
+               if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1;
+               else
+               {
+                  parcours_nomprec = parcours_nom;
+                  parcours_nom = parcours_nom->suiv;
+               }
+            }
+            if ( out == 1 )
+            {
+               if ( parcours_nom == List_Subroutine_For_Alloc)
+               {
+                  List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv;
+               }
+               else
+               {
+                  parcours_nomprec->suiv = parcours_nom->suiv;
+                  parcours_nom = parcours_nomprec->suiv ;
+               }
+            }
+         }
+      }
+   }
+}
+
+void Write_GlobalParameter_Declaration_0()
+{
+   listvar *parcours;
+
+   if ( firstpass == 0 )
+   {
+      parcours = List_GlobalParameter_Var;
+      while( parcours )
+      {
+         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) )
+         {
+            writevardeclaration(parcours,module_declar,0,1);
+         }
+         parcours = parcours -> suiv;
+      }
+   }
+}
+
+void Write_GlobalType_Declaration_0()
+{
+   listvar *parcours;
+   int out = 0;
+   int headtypewritten = 0;
+   char ligne[LONGNOM];
+   int changeval;
+
+   if ( firstpass == 0 )
+   {
+      parcours = List_Global_Var;
+      while( parcours )
+      {
+         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) )
+         {
+           if (!strcasecmp(parcours->var->v_typevar,"type"))
+           {
+            out = 1;
+            if (headtypewritten == 0)
+              {
+                sprintf(ligne,"TYPE :: Agrif_%s",curmodulename);
+                tofich(module_declar,ligne,1);
+                headtypewritten = 1;
+              }
+            changeval = 0;
+            if (parcours->var->v_allocatable == 1)
+             {
+               changeval = 1;
+               parcours->var->v_allocatable = 0;
+               parcours->var->v_pointerdeclare = 1;
+             }
+            writevardeclaration(parcours,module_declar,0,0);
+            if (changeval == 1)
+              {
+               parcours->var->v_allocatable = 1;
+               parcours->var->v_pointerdeclare = 0;
+              }
+            }
+         }
+         parcours = parcours -> suiv;
+      }
+      if (out == 1)
+        {
+                sprintf(ligne,"END TYPE Agrif_%s",curmodulename);
+                tofich(module_declar,ligne,1);
+                sprintf(ligne,"TYPE(Agrif_%s), DIMENSION(:), ALLOCATABLE :: Agrif_%s_var",curmodulename,curmodulename); 
+                tofich(module_declar,ligne,1);
+        }
+   }
+}
+
+void Write_NotGridDepend_Declaration_0()
+{
+   listvar *parcours;
+
+   if ( firstpass == 0 )
+   {
+      parcours = List_NotGridDepend_Var;
+      while( parcours )
+      {
+         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) )
+         {
+            writevardeclaration(parcours,fortranout,0,1);
+         }
+         parcours = parcours -> suiv;
+      }
+   }
+}
+
+/******************************************************************************/
+/*                          IsTabvarsUseInArgument_0                          */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int IsTabvarsUseInArgument_0()
+{
+   int out;
+   int doloopout;
+   listvar *parcours;
+
+   out=1;
+
+   if ( List_UsedInSubroutine_Var )
+   {
+      doloopout = 0;
+      parcours = List_UsedInSubroutine_Var;
+      while ( parcours && doloopout == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) )
+                                                                  doloopout = 1;
+         else parcours = parcours->suiv;
+      }
+      if (  doloopout == 0 ) out = 0;
+      else out = 1 ;
+   }
+   else out = 0;
+
+   return out;
+}
+
+
+/******************************************************************************/
+/*                        ImplicitNoneInSubroutine                            */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int ImplicitNoneInSubroutine()
+{
+  listname *parcours;
+  int out;
+
+  parcours= List_ImplicitNoneSubroutine;
+  out = 0 ;
+  while ( parcours && out == 0 )
+  {
+     if ( !strcasecmp(parcours->n_name,subroutinename) ) out = 1;
+     else parcours = parcours->suiv;
+  }
+  return out;
+}
+
+/******************************************************************************/
+/*                            Add_Pointer_Var_From_List_1                     */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Pointer_Var_From_List_1(listvar *listin)
+{
+   listvar *parcours;
+
+   if ( firstpass == 1 )
+   {
+       parcours = listin;
+       while ( parcours )
+       {
+          Add_Pointer_Var_1(parcours->var->v_nomvar);
+          parcours = parcours -> suiv ;
+       }
+   }
+}
+
+/******************************************************************************/
+/*                            Add_Pointer_Var_1                               */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Pointer_Var_1(char *nom)
+{
+   listname *newvar;
+   listname *parcours;
+   int out;
+
+   if ( firstpass == 1 )
+   {
+      if ( !List_Pointer_Var )
+      {
+         newvar = (listname *)malloc(sizeof(listname));
+         strcpy(newvar->n_name,nom);
+         Save_Length(nom,20);
+         newvar->suiv = NULL;
+         List_Pointer_Var = newvar;
+      }
+      else
+      {
+         parcours = List_Pointer_Var;
+         out = 0 ;
+         while ( parcours->suiv && out == 0 )
+         {
+            if (  !strcasecmp(parcours->n_name,nom) ) out = 1;
+            else
+               parcours=parcours->suiv;
+         }
+         if ( out == 0 )
+         {
+            if (  !strcasecmp(parcours->n_name,nom) ) out = 1;
+            else
+            {
+               /* add the record                                              */
+              newvar = (listname *)malloc(sizeof(listname));
+              strcpy(newvar->n_name,nom);
+              Save_Length(nom,20);
+              newvar->suiv = NULL;
+              parcours->suiv = newvar;
+            }
+         }
+      }
+   }
+}
+
+/******************************************************************************/
+/*                          varispointer_0                                    */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int varispointer_0(char *ident)
+{
+   listname *newname;
+   int out;
+
+   out =0;
+   if ( firstpass == 0 )
+   {
+      newname = List_Pointer_Var;
+      while( newname && out == 0 )
+      {
+         if ( !strcasecmp(ident,newname->n_name) ) out = 1 ;
+         else newname = newname->suiv;
+      }
+   }
+   return out;
+}
+
+/******************************************************************************/
+/*                          varistyped_0                                    */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int varistyped_0(char *ident)
+{
+   listvar *parcours;
+   int out;
+
+   out =0;
+   if ( firstpass == 0 )
+   {
+      parcours = List_Global_Var;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(ident,parcours->var->v_nomvar) ) 
+             {
+             if (!strcasecmp(parcours->var->v_typevar,"type")) out = 1;
+             }
+         parcours = parcours->suiv;
+      }
+   }
+   return out;
+}
+
+
+/******************************************************************************/
+/*                          VariableIsNotFunction                             */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int VariableIsNotFunction(char *ident)
+{
+   int out;
+   listvar *newvar;
+
+   out =0;
+
+   if ( !strcasecmp(ident,"size") ||
+        !strcasecmp(ident,"if")   ||
+        !strcasecmp(ident,"max")  ||
+        !strcasecmp(ident,"min")
+      )
+   {
+      newvar = List_SubroutineDeclaration_Var;
+      while ( newvar && out == 0 )
+      {
+         if ( !strcasecmp(subroutinename, newvar->var->v_subroutinename) &&
+              !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1;
+         newvar = newvar -> suiv ;
+      }
+      if ( out == 1 ) out = 0;
+      else out = 1;
+      /* if it has not been found                                             */
+      if ( out == 1 )
+      {
+         out = 0;
+         newvar = List_Global_Var;
+         while ( newvar && out == 0 )
+         {
+            if ( !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1;
+            newvar = newvar -> suiv ;
+         }
+         if ( out == 1 ) out = 0;
+         else out = 1;
+      }
+   }
+   /*                                                                         */
+   return out;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilListe.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilListe.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilListe.c	(revision 1844)
@@ -0,0 +1,619 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+
+void Init_Variable(variable *var)
+{
+   strcpy(var->v_typevar            ,"");
+   strcpy(var->v_nomvar             ,"");
+   strcpy(var->v_oldname            ,"");
+   strcpy(var->v_dimchar            ,"");
+   strcpy(var->v_modulename         ,"");
+   strcpy(var->v_commonname         ,"");
+   strcpy(var->v_vallengspec        ,"");
+   strcpy(var->v_nameinttypename    ,"");
+   strcpy(var->v_commoninfile       ,"");
+   strcpy(var->v_subroutinename     ,"");
+   strcpy(var->v_precision          ,"");
+   strcpy(var->v_initialvalue       ,"");
+   strcpy(var->v_IntentSpec         ,"");
+   strcpy(var->v_readedlistdimension,"");
+   var->v_nbdim               = 0 ;
+   var->v_common              = 0 ;
+   var->v_positioninblock     = 0 ;
+   var->v_module              = 0 ;
+   var->v_save                = 0 ;
+   var->v_VariableIsParameter = 0 ;
+   var->v_PublicDeclare       = 0 ;
+   var->v_PrivateDeclare      = 0 ;
+   var->v_ExternalDeclare     = 0 ;
+   var->v_pointedvar          = 0 ;
+   var->v_notgrid             = 0 ;
+   var->v_dimensiongiven      = 0 ;
+   var->v_c_star              = 0 ;
+   var->v_indicetabvars       = 0 ;
+   var->v_pointerdeclare      = 0 ;
+   var->v_optionaldeclare     = 0 ;
+   var->v_allocatable         = 0 ;
+   var->v_dimsempty           = 0 ;
+   var->v_dimension = (listdim *)NULL;
+}
+/******************************************************************************/
+/*                            AddListvartolistvar                             */
+/******************************************************************************/
+/* This subroutine is used to add a listvar l at the end of a listvar         */
+/* glob.                                                                      */
+/*                                                                            */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + glob +--->+ glob +--->+ glob +--->+ glob +--->+  l   +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+listvar * AddListvarToListvar(listvar *l,listvar *glob,int ValueFirstpass)
+{
+   listvar *newvar;
+   if ( firstpass == ValueFirstpass )
+   {
+      if ( !glob) glob = l ;
+      else
+      {
+         newvar=glob;
+         while (newvar->suiv) newvar = newvar->suiv;
+         newvar->suiv = l;
+      }
+   }
+   return glob;
+}
+
+/******************************************************************************/
+/*                       CreateAndFillin_Curvar                               */
+/******************************************************************************/
+/* This subroutine is used to create the record corresponding to the          */
+/* list of declaration                                                        */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void CreateAndFillin_Curvar(char *type,variable *curvar)
+{
+   if (!strcasecmp(type,"character") && strcasecmp(CharacterSize,"") )
+   {
+      strcpy(curvar->v_dimchar,CharacterSize);
+      Save_Length(CharacterSize,5);
+   }
+
+  /* On donne la precision de la variable si elle a ete donnee                */
+  curvar->v_c_star = 0;
+  if ( c_star == 1 ) curvar->v_c_star = 1;
+  /*                                                                          */
+  strcpy(curvar->v_vallengspec,"");
+  if ( strcasecmp(vallengspec,"") )
+  {
+     strcpy(curvar->v_vallengspec,vallengspec);
+     Save_Length(vallengspec,8);
+  }
+
+  strcpy(curvar->v_precision,"");
+  if ( strcasecmp(NamePrecision,"") )
+  {
+     strcpy(curvar->v_precision,NamePrecision);
+     Save_Length(NamePrecision,12);
+  }
+  /* Si cette variable a ete declaree dans un module on met curvar->module=1  */
+  if ( inmoduledeclare == 1 || SaveDeclare == 1)
+  {
+      curvar->v_module = 1;
+   }
+   /* Puis on donne le nom du module dans curvar->v_modulename                */
+   strcpy(curvar->v_modulename,curmodulename);
+   Save_Length(curmodulename,6);
+   /* Si cette variable a ete initialisee                                     */
+   if (InitialValueGiven == 1 )
+   {
+      strcpy(curvar->v_initialvalue,InitValue);
+      Save_Length(InitValue,14);
+   }
+   /* Si cette variable est declaree en save                                  */
+   if (SaveDeclare == 1 ) curvar->v_save = 1;
+   /* Si cette variable est v_allocatable                                     */
+   if (Allocatabledeclare == 1 ) curvar->v_allocatable=1;
+   /* if INTENT spec has been given                                           */
+   if ( strcasecmp(IntentSpec,"") )
+   {
+      strcpy(curvar->v_IntentSpec,IntentSpec);
+      Save_Length(IntentSpec,13);
+   }
+}
+
+
+/******************************************************************************/
+/*                        duplicatelistvar                                    */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void duplicatelistvar(listvar *orig)
+{
+   listvar *parcours;
+   listvar *tmplistvar;
+   listvar *tmplistvarprec;
+   listdim *tmplistdim;
+   variable *tmpvar;
+
+   tmplistvarprec = (listvar *)NULL;
+   parcours = orig;
+   while ( parcours )
+   {
+      tmplistvar = (listvar *)malloc(sizeof(listvar));
+      tmpvar = (variable *)malloc(sizeof(variable));
+      /*                                                                      */
+      Init_Variable(tmpvar);
+      /*                                                                      */
+      strcpy(tmpvar->v_typevar,parcours->var->v_typevar);
+      strcpy(tmpvar->v_nomvar,parcours->var->v_nomvar);
+      strcpy(tmpvar->v_oldname,parcours->var->v_oldname);
+      strcpy(tmpvar->v_dimchar,parcours->var->v_dimchar);
+      if ( parcours->var->v_dimension )
+      {
+         tmplistdim = (listdim *)malloc(sizeof(listdim));
+         tmplistdim = parcours->var->v_dimension;
+         tmpvar->v_dimension = tmplistdim;
+      }
+      tmpvar->v_nbdim=parcours->var->v_nbdim;
+      tmpvar->v_common=parcours->var->v_common;
+      tmpvar->v_positioninblock=parcours->var->v_positioninblock;
+      tmpvar->v_module=parcours->var->v_module;
+      tmpvar->v_save=parcours->var->v_save;
+      tmpvar->v_VariableIsParameter=parcours->var->v_VariableIsParameter;
+      tmpvar->v_indicetabvars=parcours->var->v_indicetabvars;
+      strcpy(tmpvar->v_modulename,parcours->var->v_modulename);
+      strcpy(tmpvar->v_commonname,parcours->var->v_commonname);
+      strcpy(tmpvar->v_vallengspec,parcours->var->v_vallengspec);
+
+      strcpy(tmpvar->v_nameinttypename,parcours->var->v_nameinttypename);
+            
+      tmpvar->v_pointedvar=parcours->var->v_pointedvar;
+      strcpy(tmpvar->v_commoninfile,mainfile);
+      Save_Length(mainfile,10);
+      strcpy(tmpvar->v_subroutinename,parcours->var->v_subroutinename);
+      tmpvar->v_dimensiongiven=parcours->var->v_dimensiongiven;
+      tmpvar->v_c_star=parcours->var->v_c_star;
+      strcpy(tmpvar->v_precision,parcours->var->v_precision);
+      strcpy(tmpvar->v_initialvalue,parcours->var->v_initialvalue);
+      tmpvar->v_pointerdeclare=parcours->var->v_pointerdeclare;
+      tmpvar->v_optionaldeclare=parcours->var->v_optionaldeclare;
+      tmpvar->v_allocatable=parcours->var->v_allocatable;
+      strcpy(tmpvar->v_IntentSpec,parcours->var->v_IntentSpec);
+      tmpvar->v_dimsempty=parcours->var->v_dimsempty;
+      strcpy(tmpvar->v_readedlistdimension,
+                                          parcours->var->v_readedlistdimension);
+      /*                                                                      */
+      tmplistvar->var = tmpvar;
+      tmplistvar->suiv = NULL;
+      /*                                                                      */
+      if ( !listduplicated )
+      {
+         listduplicated = tmplistvar;
+         tmplistvarprec = listduplicated;
+      }
+      else
+      {
+         tmplistvarprec->suiv = tmplistvar;
+         tmplistvarprec = tmplistvar;
+      }
+      /*                                                                      */
+      parcours = parcours->suiv;
+   }
+}
+
+/******************************************************************************/
+/*                           insertdim                                        */
+/******************************************************************************/
+/* This subroutine is used to insert a record in a list of                    */
+/* struct : listdim                                                           */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ lin  +--->+ lin  +--->+ lin  +--->+  lin +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+listdim * insertdim(listdim *lin,typedim nom)
+{
+   listdim *newdim ;
+   listdim *parcours ;
+
+   newdim=(listdim *) malloc (sizeof (listdim));
+   newdim->dim=nom;
+   newdim->suiv=NULL;
+
+   if ( ! lin )
+   {
+      lin = newdim;
+   }
+   else
+   {
+      parcours = lin;
+      while ( parcours->suiv ) parcours=parcours->suiv;
+      parcours->suiv = newdim;
+   }
+
+   return lin;
+}
+
+/******************************************************************************/
+/*                            change_dim_char                                 */
+/******************************************************************************/
+/* This subroutine is used to change the dimension in the list lin            */
+/******************************************************************************/
+/*        _______     _______                 _______     _______             */
+/*       +  l   +    +  l   +                +  l   +    +   l  +             */
+/*       + old  +--->+ old  +--------------->+ lin  +--->+  lin +             */
+/*       +______+    +______+                +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+void change_dim_char(listdim *lin,listvar * l)
+{
+   listvar *parcours_var;
+   variable *v;
+
+   parcours_var=l;
+   while(parcours_var)
+   {
+      v=parcours_var->var;
+      strcpy(v->v_dimchar,(lin->dim).last);
+      Save_Length((lin->dim).last,5);
+      parcours_var=parcours_var->suiv;
+   }
+}
+
+
+/******************************************************************************/
+/*                                num_dims                                    */
+/******************************************************************************/
+/* This subroutine is used to know the dimension of a table                   */
+/******************************************************************************/
+/*                                                                            */
+/*             Dimension(jpi,jpj,jpk) ----------> num_dims = 3                */
+/*                                                                            */
+/******************************************************************************/
+int num_dims(listdim *d)
+{
+   listdim *parcours;
+   int compteur = 0;
+
+   parcours = d;
+   while(parcours)
+   {
+     compteur++;
+     parcours=parcours->suiv;
+   }
+   return compteur;
+}
+
+
+/******************************************************************************/
+/*                          CREATEVAR                                         */
+/******************************************************************************/
+/* This subroutine is used to create and initialized a record of the          */
+/*      struct : variable                                                     */
+/******************************************************************************/
+variable * createvar(char *nom,listdim *d)
+{
+  variable *var;
+  listdim *dims;
+  char ligne[LONG_C];
+  char listdimension[LONG_C];
+
+   var=(variable *) malloc(sizeof(variable));
+   /*                                                                         */
+   Init_Variable(var);
+   /*                                                                         */
+   strcpy(var->v_nomvar,nom);
+   Save_Length(nom,4);
+   /*                                                                         */
+   strcpy(listdimension,"");
+   strcpy(var->v_modulename,curmodulename);
+   Save_Length(curmodulename,6);
+   strcpy(var->v_commoninfile,mainfile);
+   Save_Length(mainfile,10);
+   strcpy(var->v_subroutinename,subroutinename);
+   Save_Length(subroutinename,11);
+   /*                                                                         */
+   if ( strcasecmp(nameinttypename,"") )
+   {
+      strcpy(var->v_nameinttypename,nameinttypename);
+      Save_Length(nameinttypename,9);
+   }
+         
+   if ( optionaldeclare     == 1 ) var->v_optionaldeclare = 1;
+   if ( pointerdeclare      == 1 ) var->v_pointerdeclare = 1;
+   if ( VariableIsParameter == 1 ) var->v_VariableIsParameter = 1 ;
+   if ( PublicDeclare       == 1 ) var->v_PublicDeclare = 1 ;
+   if ( PrivateDeclare      == 1 ) var->v_PrivateDeclare = 1;
+   if ( ExternalDeclare     == 1 ) var->v_ExternalDeclare = 1;
+   /*                                                                         */
+   var->v_dimension=d;
+
+   /* Creation of the string for the dimension of this variable               */
+   dimsempty = 1;
+   if ( d )
+   {
+      var->v_dimensiongiven=1;
+      dims = d;
+      while (dims)
+      {
+         if ( strcasecmp(dims->dim.first,"") || strcasecmp(dims->dim.last,""))
+                                                                  dimsempty = 0;
+         sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
+         strcat(listdimension,ligne);
+         if ( dims->suiv )
+         {
+            strcat(listdimension,",");
+         }
+         dims = dims->suiv;
+      }
+      if ( dimsempty == 1 ) var->v_dimsempty=1;
+   }
+   strcpy(var->v_readedlistdimension,listdimension);
+   Save_Length(listdimension,15);
+   /*                                                                         */
+   var->v_nbdim=num_dims(d);
+   /*                                                                         */
+   return var;
+}
+
+/******************************************************************************/
+/*                            INSERTVAR                                       */
+/******************************************************************************/
+/* This subroutine is used to insert a record in a list of the                */
+/*      struct : listvar                                                      */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       +  lin +--->+  lin +--->+ lin  +--->+ lin  +--->+ NEW  +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+listvar * insertvar(listvar *lin,variable *v)
+{
+   listvar *newvar ;
+   listvar *tmpvar ;
+
+   newvar=(listvar *) malloc (sizeof (listvar));
+   newvar->var=v;
+   newvar->suiv = NULL;
+   if (!lin)
+   {
+      newvar->suiv=NULL;
+      lin = newvar;
+   }
+   else
+   {
+      tmpvar = lin ;
+      while (tmpvar->suiv)
+      {
+         tmpvar = tmpvar ->suiv ;
+      }
+      tmpvar -> suiv = newvar;
+   }
+   return lin;
+}
+
+/******************************************************************************/
+/*                             SETTYPE                                        */
+/******************************************************************************/
+/* This subroutine is used to give the same variable type at each             */
+/*      record of the list of the struct : listvar                            */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       + REAL +    + REAL +    + REAL +    + REAL +    + REAL +             */
+/*       +  lin +--->+  lin +--->+ lin  +--->+ lin  +--->+ lin  +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+listvar *settype(char *nom,listvar *lin)
+{
+   listvar *newvar;
+   variable *v;
+
+   newvar=lin;
+   while (newvar)
+   {
+      v=newvar->var;
+      strcpy(v->v_typevar,nom);
+      Save_Length(nom,3);
+      newvar=newvar->suiv;
+   }
+   newvar=lin;
+   return newvar ;
+}
+
+/******************************************************************/
+/* printliste  */
+/* print the list given in argulent */
+/******************************************************************/
+
+void printliste(listvar * lin)
+{
+   listvar *newvar;
+   variable *v;
+
+   newvar=lin;
+   while (newvar)
+   {
+      v=newvar->var;
+      printf("nom = %s, allocatable = %d dim = %s\n",v->v_nomvar,v->v_allocatable,(v->v_dimension)->dim.last);
+      newvar=newvar->suiv;
+   }
+}
+
+/******************************************************************************/
+/*   IsinListe : return 1 if name nom is in list lin                          */
+/*                                                                            */
+/******************************************************************************/
+ int IsinListe(listvar *lin,char *nom)
+{
+   listvar *newvar;
+   variable *v;
+   int out ;
+   
+   newvar=lin;
+   out = 0;
+   while (newvar && (out == 0))
+   {
+      v=newvar->var;
+      if (!strcasecmp(v->v_nomvar,nom) && !strcasecmp(v->v_subroutinename,subroutinename)) {
+      out = 1;
+      }
+      newvar=newvar->suiv;
+   }
+
+   return out ;
+}
+
+listname *Insertname(listname *lin,char *nom)
+{
+   listname *newvar ;
+   listname *tmpvar;
+
+   newvar=(listname *) malloc (sizeof (listname));
+   strcpy(newvar->n_name,nom);
+   newvar->suiv = NULL;
+   if (!lin)
+   {
+      newvar->suiv=NULL;
+      lin = newvar;
+   }
+   else
+   {
+      tmpvar = lin ;
+      while (tmpvar->suiv)
+      {
+         tmpvar = tmpvar ->suiv ;
+      }
+      tmpvar -> suiv = newvar;
+   }
+   return lin;
+}
+
+/******************************************************************/
+/* printname  */
+/* print the list given in argulent */
+/******************************************************************/
+
+void printname(listname * lin)
+{
+   listname *newvar;
+
+   newvar=lin;
+   while (newvar)
+   {
+      printf("nom = %s \n",newvar->n_name);
+      newvar=newvar->suiv;
+   }
+}
+
+void removeglobfromlist(listname **lin)
+{
+  listname *listemp;
+  listname *parcours1;
+  listvar *parcours2;
+  listname * parcourspres;
+  int out;
+  
+  parcours1 = *lin;
+  parcourspres = (listname *)NULL;
+  
+  while (parcours1)
+  {
+  parcours2 = List_Global_Var;
+  out = 0;
+  while (parcours2 && out == 0)
+  {
+    if (!strcasecmp(parcours2->var->v_nomvar,parcours1->n_name))
+    {
+    out = 1;
+    }
+    parcours2 = parcours2->suiv;
+  }
+  if (out == 1)
+  {
+  if (parcours1 == *lin)
+   {
+   *lin = (*lin)->suiv;
+   parcours1 = *lin;
+   }
+   else
+   {
+   parcourspres->suiv = parcours1->suiv;
+   parcours1 = parcourspres->suiv;
+   }
+   }
+   else
+   {
+   parcourspres = parcours1;
+    parcours1 = parcours1->suiv;  
+    }
+  }
+}
+
+void writelistpublic(listname *lin)
+{
+  listname *parcours1;
+  char ligne[LONG_40M];
+  char tempname[LONG_4M];
+  
+  if (lin)
+  {
+  sprintf(ligne,"public :: ");
+  parcours1 = lin;
+  
+  while (parcours1)
+  {
+    strcat(ligne,parcours1->n_name);
+    if (parcours1->suiv) strcat(ligne,", ");
+    parcours1 = parcours1->suiv;  
+  }
+  tofich(fortranout,ligne,1);
+  }
+
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/UtilNotGridDep.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/UtilNotGridDep.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/UtilNotGridDep.c	(revision 1844)
@@ -0,0 +1,110 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                     Add_NotGridDepend_Var_1                                */
+/******************************************************************************/
+/* This subroutine is used to add a record into List_NotGridDepend_Var        */
+/*    This variable is add only if it is not present in the list              */
+/*    This variable is add at the end of the list                             */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       + not  +    + not  +    +  not +    +  not +    +      +             */
+/*       + grid +--->+ grid +--->+ grid +--->+ grid +--->+ NEW  +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+void Add_NotGridDepend_Var_1 (char *name)
+{
+   listvar *parcours;
+   listvar *newvar;
+   /*                                                                         */
+   /* look in the List_NotGridDepend_Var if this variable exist               */
+   parcours = List_NotGridDepend_Var;
+   while (parcours)
+   {
+     if (!strcasecmp(parcours->var->v_nomvar,name))
+     {
+        /* if this variable exist -> exit of the program                      */
+        printf(" The variable %s\n",name);
+        printf(" has been declared twice \n");
+        printf(" as a non grid dependent variable \n");
+        exit(1);
+     }
+     parcours= parcours->suiv;
+   }
+   /* if variable does not exist, we add it                                   */
+   newvar=(listvar *)malloc(sizeof(listvar));
+   newvar->var=(variable *)malloc(sizeof(variable));
+   strcpy(newvar->var->v_nomvar,name);
+   Save_Length(name,4);
+   strcpy(newvar->var->v_commoninfile,mainfile);
+   Save_Length(mainfile,10);
+   strcpy(newvar->var->v_subroutinename,subroutinename);
+   Save_Length(subroutinename,11);
+   newvar->var->v_notgrid = 1 ;
+   newvar->suiv = List_NotGridDepend_Var;
+   List_NotGridDepend_Var = newvar;
+}
+
+/******************************************************************************/
+/*                      VarIsNonGridDepend                                    */
+/******************************************************************************/
+/* This subroutine is used to know if a variable has been declared as non     */
+/* grid dependent                                                             */
+/******************************************************************************/
+/*                                                                            */
+/*  notgriddepend variable;    ----------->  VarIsNonGridDepend = 1           */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+int VarIsNonGridDepend(char *name)
+{
+   listvar *newvar;
+   int out;
+
+   newvar = List_NotGridDepend_Var;
+   out=0;
+   while (newvar && out == 0 )
+   {
+      if ( !strcasecmp(newvar->var->v_nomvar,name) ) out = 1;
+      else newvar = newvar->suiv;
+   }
+   return out;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithAllocatelist.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithAllocatelist.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithAllocatelist.c	(revision 1844)
@@ -0,0 +1,152 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                               Add_Allocate_Var_1                           */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Allocate_Var_1(char *nom,char *nommodule)
+{
+   listallocate *newvar;
+   listallocate *parcours;
+   int out;
+
+   if ( firstpass == 1 )
+   {
+      if ( !List_Allocate_Var )
+      {
+         newvar = (listallocate *)malloc(sizeof(listallocate));
+         strcpy(newvar->a_nomvar,nom);
+         Save_Length(nom,25);
+         strcpy(newvar->a_subroutine,subroutinename);
+         Save_Length(subroutinename,26);
+         strcpy(newvar->a_module,nommodule);
+         Save_Length(nommodule,27);
+         newvar->suiv = NULL;
+         List_Allocate_Var = newvar;
+      }
+      else
+      {
+         parcours = List_Allocate_Var;
+         out = 0 ;
+         while ( parcours->suiv && out == 0 )
+         {
+            if (  !strcasecmp(parcours->a_nomvar,nom) &&
+                  !strcasecmp(parcours->a_subroutine,subroutinename) &&
+                  !strcasecmp(parcours->a_module,nommodule) ) out = 1;
+            else
+               parcours=parcours->suiv;
+         }
+         if ( out == 0 )
+         {
+            if (  !strcasecmp(parcours->a_nomvar,nom) &&
+                  !strcasecmp(parcours->a_subroutine,subroutinename) &&
+                  !strcasecmp(parcours->a_module,nommodule) ) out = 1;
+            else
+            {
+               /* add the record                                              */
+              newvar = (listallocate *)malloc(sizeof(listallocate));
+              strcpy(newvar->a_nomvar,nom);
+              Save_Length(nom,25);
+              strcpy(newvar->a_subroutine,subroutinename);
+              Save_Length(subroutinename,26);
+              strcpy(newvar->a_module,nommodule);
+              Save_Length(nommodule,27);
+              newvar->suiv = NULL;
+              parcours->suiv = newvar;
+            }
+         }
+      }
+   }
+}
+
+
+/******************************************************************************/
+/*                            IsVarAllocatable_0                              */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int IsVarAllocatable_0(char *ident)
+{
+   listallocate *parcours;
+   int out;
+
+   out = 0 ;
+   if ( firstpass == 0 )
+   {
+      parcours = List_Allocate_Var;
+      while ( parcours && out == 0 )
+      {
+         if ( !strcasecmp(parcours->a_nomvar,ident)  ) out = 1 ;
+         else parcours=parcours->suiv;
+      }
+   }
+   return out;
+}
+
+
+/******************************************************************************/
+/*                          varisallocatable_0                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int varisallocatable_0(char *ident)
+{
+   listallocate *newvaralloc;
+   int out;
+
+   out =0;
+   if (firstpass == 0 )
+   {
+         newvaralloc = List_Allocate_Var;
+         while ( newvaralloc && out == 0 )
+         {
+            if ( !strcasecmp(ident,newvaralloc->a_nomvar) )  out = 1;
+            else newvaralloc = newvaralloc->suiv;
+         }
+   }
+   return out;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithParameterlist.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithParameterlist.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithParameterlist.c	(revision 1844)
@@ -0,0 +1,106 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                       Add_GlobalParameter_Var_1                            */
+/******************************************************************************/
+/*  This subroutines is used to add the variable defined in common in the     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_GlobalParameter_Var_1(listvar *listin)
+{
+   if ( firstpass == 1 )
+   {
+      if ( VariableIsParameter == 1 ) List_GlobalParameter_Var =
+                         AddListvarToListvar(listin,List_GlobalParameter_Var,1);
+   }
+}
+
+/******************************************************************************/
+/*                       Add_Parameter_Var_1                                  */
+/******************************************************************************/
+/*  This subroutines is used to add the variable defined in common in the     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Parameter_Var_1(listvar *listin)
+{
+   listvar *parcours;
+
+   if ( firstpass == 1 && VariableIsParameter == 1 )
+   {
+      if ( !List_Parameter_Var )
+      {
+         List_Parameter_Var = listin;
+      }
+      else
+      {
+         parcours = List_Parameter_Var;
+         while (parcours->suiv) parcours=parcours->suiv;
+         parcours->suiv = listin;
+      }
+   }
+}
+
+/******************************************************************************/
+/*                       Add_Dimension_Var_1                                  */
+/******************************************************************************/
+/*  This subroutines is used to add the variable defined in common in the     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_Dimension_Var_1(listvar *listin)
+{
+   listvar *parcours;
+
+   if ( firstpass == 1 )
+   {
+      if ( !List_Dimension_Var )
+      {
+         List_Dimension_Var = listin;
+      }
+      else
+      {
+         parcours = List_Dimension_Var;
+         while (parcours->suiv) parcours=parcours->suiv;
+         parcours->suiv = listin;
+      }
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithglobliste.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithglobliste.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithglobliste.c	(revision 1844)
@@ -0,0 +1,111 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                          Add_Globliste_1                                   */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should add this declaration to the List_Global_Var                      */
+/******************************************************************************/
+void Add_Globliste_1(listvar *listtoadd)
+{
+   if ( firstpass == 1 )
+   {
+      if ( aftercontainsdeclare == 0 &&
+           VariableIsParameter  == 0 )
+      {
+         List_Global_Var = AddListvarToListvar(listtoadd,List_Global_Var,1);
+      }
+   }
+}
+
+/******************************************************************************/
+/*                  Add_SubroutineDeclarationSave_Var_1                       */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should add this declaration to the List_Global_Var. case SAVE           */
+/******************************************************************************/
+void Add_SubroutineDeclarationSave_Var_1(listvar *listtoadd)
+{
+   if ( firstpass == 1 )
+   {
+      if ( VariableIsParameter == 0 &&
+           SaveDeclare         == 1 )
+      {
+         List_Global_Var = AddListvarToListvar(listtoadd,List_Global_Var,1);
+      }
+   }
+}
+
+void checkandchangedims(listvar *listsecondpass)
+{
+listvar *parcours;
+listvar *parcours1;
+variable * newvar;
+variable * oldvar;
+
+int out ;
+
+printliste(List_Global_Var);
+printliste(List_SubroutineDeclaration_Var);
+
+parcours = listsecondpass;
+while (parcours)
+{
+newvar = parcours->var;
+parcours1 = List_SubroutineDeclaration_Var;
+out = 0;
+while (parcours1 && out == 0)
+{
+  oldvar = parcours1->var;
+  if (!strcasecmp(newvar->v_nomvar,oldvar->v_nomvar) && !strcasecmp(newvar->v_subroutinename,subroutinename))
+   {
+   if (newvar->v_dimensiongiven == 1)
+   {
+    strcpy(oldvar->v_dimension->dim.last,newvar->v_dimension->dim.last);
+    strcpy(oldvar->v_dimension->dim.first,newvar->v_dimension->dim.first);    
+   }
+   out = 1;
+   }
+  parcours1 = parcours1->suiv;
+}
+parcours = parcours->suiv;
+}
+printliste(List_SubroutineDeclaration_Var);
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistdatavariable.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistdatavariable.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistdatavariable.c	(revision 1844)
@@ -0,0 +1,84 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+/******************************************************************************/
+/*                          Add_Data_Var_1                                    */
+/******************************************************************************/
+/* This subroutine is used to add a record to List_Data_Var                   */
+/******************************************************************************/
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ data +--->+ data +--->+ data +--->+  data+             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/******************************************************************************/
+void Add_Data_Var_1 (char *name,char *values)
+{
+  listvar *newvar;
+
+  if ( firstpass == 1 )
+  {
+     newvar=(listvar *)malloc(sizeof(listvar));
+     newvar->var=(variable *)malloc(sizeof(variable));
+     /*                                                                       */
+     Init_Variable(newvar->var);
+     /*                                                                       */
+     if ( inmoduledeclare == 1 ) newvar->var->v_module=1;
+     strcpy(newvar->var->v_nomvar,name);
+     Save_Length(name,4);
+     strcpy(newvar->var->v_subroutinename,subroutinename);
+     Save_Length(subroutinename,11);
+     strcpy(newvar->var->v_modulename,curmodulename);
+     Save_Length(curmodulename,6);
+     strcpy(newvar->var->v_commoninfile,mainfile);
+     Save_Length(mainfile,10);
+     strcpy(newvar->var->v_initialvalue,values);
+     Save_Length(values,14);
+     newvar->suiv = NULL;
+
+     if ( !List_Data_Var )
+     {
+        List_Data_Var  = newvar ;
+     }
+     else
+     {
+        newvar->suiv = List_Data_Var;
+        List_Data_Var = newvar;
+     }
+  }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistmoduleinfile.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistmoduleinfile.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistmoduleinfile.c	(revision 1844)
@@ -0,0 +1,530 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+void Save_Length(char *nom, int whichone)
+{
+   if ( whichone == 1  && strlen(nom) > length_last )
+   {
+      length_last               = strlen(nom);
+      if ( length_last > LONG_C )
+      {
+         printf("WARNING 1 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_last+100);
+      }
+   }
+   if ( whichone == 2  && strlen(nom) > length_first )
+   {
+      length_first              = strlen(nom);
+      if ( length_first > LONG_C )
+      {
+         printf("WARNING 2 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_first+100);
+      }
+   }
+   if ( whichone == 3  && strlen(nom) > length_v_typevar )
+   {
+      length_v_typevar          = strlen(nom);
+      if ( length_v_typevar > LONG_C )
+      {
+         printf("WARNING 3 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_v_typevar+100);
+      }
+   }
+   if ( whichone == 4  && strlen(nom) > length_v_nomvar )
+   {
+      length_v_nomvar           = strlen(nom);
+      if ( length_v_nomvar > LONG_C )
+      {
+         printf("WARNING 4 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_v_nomvar+100);
+      }
+   }
+   if ( whichone == 5  && strlen(nom) > length_v_dimchar )
+   {
+      length_v_dimchar          = strlen(nom);
+      if ( length_v_dimchar > LONG_C )
+      {
+         printf("WARNING 5 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                          length_v_dimchar+100);
+      }
+   }
+   if ( whichone == 6  && strlen(nom) > length_v_modulename )
+   {
+      length_v_modulename       = strlen(nom);
+      if ( length_v_modulename > LONG_C )
+      {
+         printf("WARNING 6 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_v_modulename+100);
+      }
+   }
+   if ( whichone == 7  && strlen(nom) > length_v_commonname )
+   {
+      length_v_commonname       = strlen(nom);
+      if ( length_v_commonname > LONG_C )
+      {
+         printf("WARNING 7 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_v_commonname+100);
+      }
+   }
+   if ( whichone == 8  && strlen(nom) > length_v_vallengspec )
+   {
+      length_v_vallengspec      = strlen(nom);
+      if ( length_v_vallengspec > LONG_C )
+      {
+         printf("WARNING 8 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                      length_v_vallengspec+100);
+      }
+   }
+   if ( whichone == 9  && strlen(nom) > length_v_nameinttypename )
+   {
+      length_v_nameinttypename  = strlen(nom);
+      if ( length_v_nameinttypename > LONG_C )
+      {
+         printf("WARNING 9 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                  length_v_nameinttypename+100);
+      }
+   }
+   if ( whichone == 10 && strlen(nom) > length_v_commoninfile )
+   {
+      length_v_commoninfile     = strlen(nom);
+      if ( length_v_commoninfile > LONG_C )
+      {
+         printf("WARNING 10 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                     length_v_commoninfile+100);
+      }
+   }
+   if ( whichone == 11 && strlen(nom) > length_v_subroutinename )
+   {
+      length_v_subroutinename   = strlen(nom);
+      if ( length_v_subroutinename > LONG_C )
+      {
+         printf("WARNING 11 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                   length_v_subroutinename+100);
+      }
+   }
+   if ( whichone == 12 && strlen(nom) > length_v_precision )
+   {
+      length_v_precision        = strlen(nom);
+      if ( length_v_precision > LONG_C )
+      {
+         printf("WARNING 12 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_v_precision+100);
+      }
+   }
+   if ( whichone == 13 && strlen(nom) > length_v_IntentSpec )
+   {
+      length_v_IntentSpec       = strlen(nom);
+      if ( length_v_IntentSpec > LONG_C )
+      {
+         printf("WARNING 13 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_v_IntentSpec+100);
+      }
+   }
+   if ( whichone == 14 && strlen(nom) > length_v_initialvalue )
+   {
+      length_v_initialvalue     = strlen(nom);
+      if ( length_v_initialvalue > LONG_4C )
+      {
+         printf("WARNING 14 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                     length_v_initialvalue+100);
+      }
+   }
+   if ( whichone == 15 && strlen(nom) > length_v_readedlistdimension )
+   {
+      length_v_readedlistdimension = strlen(nom);
+      if ( length_v_readedlistdimension > LONG_C )
+      {
+         printf("WARNING 15 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                              length_v_readedlistdimension+100);
+      }
+   }
+   if ( whichone == 16 && strlen(nom) > length_u_usemodule )
+   {
+      length_u_usemodule        = strlen(nom);
+      if ( length_u_usemodule > LONG_C )
+      {
+         printf("WARNING 16 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_u_usemodule+100);
+      }
+   }
+   if ( whichone == 17 && strlen(nom) > length_u_charusemodule )
+   {
+      length_u_charusemodule    = strlen(nom);
+      if ( length_u_charusemodule > LONG_C )
+      {
+         printf("WARNING 17 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                    length_u_charusemodule+100);
+      }
+   }
+   if ( whichone == 18 && strlen(nom) > length_u_cursubroutine )
+   {
+      length_u_cursubroutine    = strlen(nom);
+      if ( length_u_cursubroutine > LONG_C )
+      {
+         printf("WARNING 18 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                    length_u_cursubroutine+100);
+      }
+   }
+   if ( whichone == 19 && strlen(nom) > length_u_modulename )
+   {
+      length_u_modulename       = strlen(nom);
+      if ( length_u_modulename > LONG_C )
+      {
+         printf("WARNING 19 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_u_modulename+100);
+      }
+   }
+   if ( whichone == 20 && strlen(nom) > length_n_name )
+   {
+      length_n_name             = strlen(nom);
+      if ( length_n_name > LONG_C )
+      {
+         printf("WARNING 20 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_n_name+100);
+      }
+   }
+   if ( whichone == 21 && strlen(nom) > length_c_namevar )
+   {
+      length_c_namevar          = strlen(nom);
+      if ( length_c_namevar > LONG_C )
+      {
+         printf("WARNING 21 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_c_namevar+100);
+      }
+   }
+   if ( whichone == 22 && strlen(nom) > length_c_namepointedvar )
+   {
+      length_c_namepointedvar   = strlen(nom);
+      if ( length_c_namepointedvar > LONG_C )
+      {
+         printf("WARNING 22 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                   length_c_namepointedvar+100);
+      }
+   }
+   if ( whichone == 23 && strlen(nom) > length_o_nom )
+   {
+      length_o_nom              = strlen(nom);
+      if ( length_o_nom > LONG_C )
+      {
+         printf("WARNING 23 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_o_nom+100);
+      }
+   }
+   if ( whichone == 24 && strlen(nom) > length_o_module )
+   {
+      length_o_module           = strlen(nom);
+      if ( length_o_module > LONG_C )
+      {
+         printf("WARNING 24 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_o_module+100);
+      }
+   }
+   if ( whichone == 25 && strlen(nom) > length_a_nomvar )
+   {
+      length_a_nomvar           = strlen(nom);
+      if ( length_a_nomvar > LONG_C )
+      {
+         printf("WARNING 25 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_a_nomvar+100);
+      }
+   }
+   if ( whichone == 26 && strlen(nom) > length_a_subroutine )
+   {
+      length_a_subroutine       = strlen(nom);
+      if ( length_a_subroutine > LONG_C )
+      {
+         printf("WARNING 26 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_a_subroutine+100);
+      }
+   }
+   if ( whichone == 27 && strlen(nom) > length_a_module )
+   {
+      length_a_module           = strlen(nom);
+      if ( length_a_module > LONG_C )
+      {
+         printf("WARNING 27 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_a_module+100);
+      }
+   }
+   if ( whichone == 28 && strlen(nom) > length_t_usemodule )
+   {
+      length_t_usemodule        = strlen(nom);
+      if ( length_t_usemodule > LONG_C )
+      {
+         printf("WARNING 28 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_t_usemodule+100);
+      }
+   }
+   if ( whichone == 29 && strlen(nom) > length_t_cursubroutine )
+   {
+      length_t_cursubroutine    = strlen(nom);
+      if ( length_t_cursubroutine > LONG_C )
+      {
+         printf("WARNING 29 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                    length_t_cursubroutine+100);
+      }
+   }
+   if ( whichone == 30 && strlen(nom) > length_curfilename )
+   {
+      length_curfilename        = strlen(nom);
+      if (length_curfilename  > LONG_C )
+      {
+         printf("WARNING 30 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_curfilename+100);
+      }
+   }
+   if ( whichone == 31 && strlen(nom) > length_nomfileoutput )
+   {
+      length_nomfileoutput      = strlen(nom);
+      if ( length_nomfileoutput > LONG_C )
+      {
+         printf("WARNING 31 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                      length_nomfileoutput+100);
+      }
+   }
+   if ( whichone == 32 && strlen(nom) > length_motparse )
+   {
+      length_motparse           = strlen(nom);
+      if ( length_motparse > LONG_4C )
+      {
+         printf("WARNING 32 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_motparse+100);
+      }
+   }
+   if ( whichone == 33 && strlen(nom) > length_mainfile )
+   {
+      length_mainfile           = strlen(nom);
+      if ( length_mainfile > LONG_C )
+      {
+         printf("WARNING 33 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_mainfile+100);
+      }
+   }
+   if ( whichone == 34 && strlen(nom) > length_nomdir )
+   {
+      length_nomdir             = strlen(nom);
+      if ( length_nomdir > LONG_C )
+      {
+         printf("WARNING 34 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_nomdir+100);
+      }
+   }
+   if ( whichone == 35 && strlen(nom) > length_commondirout )
+   {
+      length_commondirout       = strlen(nom);
+      if ( length_commondirout > LONG_C )
+      {
+         printf("WARNING 35 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_commondirout+100);
+      }
+   }
+   if ( whichone == 36 && strlen(nom) > length_commondirin )
+   {
+      length_commondirin        = strlen(nom);
+      if ( length_commondirin > LONG_C )
+      {
+         printf("WARNING 36 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_commondirin+100);
+      }
+   }
+   if ( whichone == 37 && strlen(nom) > length_filetoparse )
+   {
+      length_filetoparse        = strlen(nom);
+      if ( length_filetoparse > LONG_C )
+      {
+         printf("WARNING 37 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_filetoparse+100);
+      }
+   }
+   if ( whichone == 38 && strlen(nom) > length_curbuf )
+   {
+      length_curbuf             = strlen(nom);
+      if ( length_curbuf > LONG_40M )
+      {
+         printf("WARNING 38 : The value of LONG_40M - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",length_curbuf+100);
+      }
+   }
+   if ( whichone == 39 && strlen(nom) > length_toprintglob )
+   {
+      length_toprintglob        = strlen(nom);
+      if ( length_toprintglob > LONG_4C )
+      {
+         printf("WARNING 39 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                        length_toprintglob+100);
+      }
+   }
+   if ( whichone == 40 && strlen(nom) > length_tmpvargridname )
+   {
+      length_tmpvargridname     = strlen(nom);
+      if ( length_tmpvargridname > LONG_4C )
+      {
+         printf("WARNING 40 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                     length_tmpvargridname+100);
+      }
+   }
+   if ( whichone == 41 && strlen(nom) > length_ligne_Subloop )
+   {
+       length_ligne_Subloop    = strlen(nom);
+      if ( length_ligne_Subloop > LONG_40M )
+      {
+         printf("WARNING 41 : The value of LONG_40M - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                      length_ligne_Subloop+100);
+      }
+   }
+   if ( whichone == 42 && strlen(nom) > length_lvargridname_toamr )
+   {
+      length_lvargridname_toamr     = strlen(nom);
+      if ( length_lvargridname_toamr > LONG_4C )
+      {
+         printf("WARNING 42 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                 length_lvargridname_toamr+100);
+      }
+   }
+   if ( whichone == 43 && strlen(nom) > length_toprint_utilagrif )
+   {
+      length_toprint_utilagrif     = strlen(nom);
+      if ( length_toprint_utilagrif > LONG_C )
+      {
+         printf("WARNING 43 : The value of LONG_C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                  length_toprint_utilagrif+100);
+      }
+   }
+   if ( whichone == 44 && strlen(nom) > length_toprinttmp_utilchar )
+   {
+      length_toprinttmp_utilchar     = strlen(nom);
+      if ( length_toprinttmp_utilchar > LONG_4C)
+      {
+         printf("WARNING 44 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                length_toprinttmp_utilchar+100);
+      }
+   }
+   if ( whichone == 45 && strlen(nom) > length_ligne_writedecl )
+   {
+      length_ligne_writedecl     = strlen(nom);
+      if ( length_ligne_writedecl > LONG_4C )
+      {
+         printf("WARNING 45 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                    length_ligne_writedecl+100);
+      }
+   }
+   if ( whichone == 46 && strlen(nom) > length_newname_toamr )
+   {
+      length_newname_toamr    = strlen(nom);
+      if ( length_newname_toamr > LONG_4C )
+      {
+         printf("WARNING 46 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                      length_newname_toamr+100);
+      }
+   }
+   if ( whichone == 47 && strlen(nom) > length_newname_writedecl )
+   {
+      length_newname_writedecl    = strlen(nom);
+      if ( length_newname_writedecl > LONG_4C )
+      {
+         printf("WARNING 47 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                 length_newname_writedecl +100);
+      }
+   }
+   if ( whichone == 48 && strlen(nom) > length_ligne_toamr )
+   {
+      length_ligne_toamr    = strlen(nom);
+      if ( length_ligne_toamr > LONGNOM )
+      {
+         printf("WARNING 48 : The value of LONGNOM - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                       length_ligne_toamr +100);
+      }
+   }
+   if ( whichone == 49 && strlen(nom) > length_tmpligne_writedecl )
+   {
+      length_tmpligne_writedecl     = strlen(nom);
+      if ( length_tmpligne_writedecl > LONG_4C )
+      {
+         printf("WARNING 49 : The value of LONG_4C - define in decl.h -\n");
+         printf("             should be upgrated to %d\n",
+                                                 length_tmpligne_writedecl+100);
+      }
+   }
+}
+
+void Save_Length_int(int val, int whichone)
+{
+   if ( whichone == 1 && val > value_char_size )
+                               value_char_size                            = val;
+   if ( whichone == 2 && val > value_char_size1 )
+                               value_char_size1                           = val;
+   if ( whichone == 3 && val > value_char_size2 )
+                               value_char_size2                           = val;
+   if ( whichone == 4 && val > value_char_size3 )
+                               value_char_size3                           = val;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofcoupled.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofcoupled.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofcoupled.c	(revision 1844)
@@ -0,0 +1,111 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or    or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)           */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "decl.h"
+
+/******************************************************************************/
+/*                          varisallocatable_0                                */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int variscoupled_0(char *ident)
+{
+   listallocate *newvaralloc;
+  listvarpointtovar *pointtmplist; 
+  listcouple *coupletmp;   
+  int out;
+
+   out =0;
+   if (firstpass == 0 )
+   {
+  pointtmplist = List_CouplePointed_Var;
+  while ( pointtmplist && out == 0)
+  {
+      coupletmp = pointtmplist->t_couple;
+      while ( coupletmp && out == 0)
+      {
+           /* we should find the same variable name in the same subroutine    */
+           if ( !strcasecmp(ident,coupletmp->c_namevar) &&
+                !strcasecmp(subroutinename,
+                                       pointtmplist->t_cursubroutine) &&
+                 strcasecmp(coupletmp->c_namepointedvar,"")
+              )
+           {
+              out = 1;
+           }
+         coupletmp = coupletmp->suiv;
+     }
+     pointtmplist = pointtmplist->suiv;
+   }
+   }
+   return out;
+}
+
+char * getcoupledname_0(char *ident)
+{
+   listallocate *newvaralloc;
+  listvarpointtovar *pointtmplist; 
+  listcouple *coupletmp;   
+  int out;
+
+   out =0;
+   if (firstpass == 0 )
+   {
+  pointtmplist = List_CouplePointed_Var;
+  while ( pointtmplist && out == 0)
+  {
+      coupletmp = pointtmplist->t_couple;
+      while ( coupletmp && out == 0)
+      {
+           /* we should find the same variable name in the same subroutine    */
+           if ( !strcasecmp(ident,coupletmp->c_namevar) &&
+                !strcasecmp(subroutinename,
+                                       pointtmplist->t_cursubroutine) &&
+                 strcasecmp(coupletmp->c_namepointedvar,"")
+              )
+           {
+              return(coupletmp->c_namepointedvar);
+           }
+         coupletmp = coupletmp->suiv;
+     }
+     pointtmplist = pointtmplist->suiv;
+   }
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofmodulebysubroutine.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofmodulebysubroutine.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistofmodulebysubroutine.c	(revision 1844)
@@ -0,0 +1,299 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "decl.h"
+
+
+
+/******************************************************************************/
+/*                    RecordUseModulesVariables                               */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void RecordUseModulesVariables()
+{
+  listusemodule *tmplistmodule;
+
+  /* we should record all variables defined in modules used in this file      */
+  if ( List_NameOfModuleUsed )
+  {
+     tmplistmodule = List_NameOfModuleUsed;
+     while ( tmplistmodule )
+     {
+        if ( tmplistmodule->u_firstuse == 1 )
+        {
+           /* check if the file .depend<u_usemodule> exist                    */
+           List_ModuleUsed_Var = Readthedependfile
+                               (tmplistmodule->u_usemodule,List_ModuleUsed_Var);
+
+           List_GlobParamModuleUsed_Var = ReaddependParameterList
+                      (tmplistmodule->u_usemodule,List_GlobParamModuleUsed_Var);
+
+        }
+
+        tmplistmodule = tmplistmodule->suiv;
+     }
+  }
+}
+
+/******************************************************************************/
+/*                RecordUseModulesUseModulesVariables                         */
+/******************************************************************************/
+/******************************************************************************/
+void  RecordUseModulesUseModulesVariables()
+{
+  listusemodule *tmplistmodule;
+  listusemodule *tmplistmodule1;
+
+  /* we should record all variables defined in modules used in this file      */
+  if ( List_NameOfModuleUsed )
+  {
+     /* and we should read the .depend of the module used by the module used  */
+     tmplistmodule = List_NameOfModuleUsed;
+     while ( tmplistmodule )
+     {
+        Readthedependlistofmoduleused(tmplistmodule->u_usemodule);
+        while( tmpuselocallist )
+        {
+           Addmoduletothelisttmp(tmpuselocallist->u_usemodule);
+           tmplistmodule1 = tmpuselocallist->suiv;
+           free(tmpuselocallist);
+           tmpuselocallist = tmplistmodule1;
+        }
+        tmplistmodule = tmplistmodule->suiv;
+     }
+
+     tmplistmodule = listofmoduletmp;
+     while ( tmplistmodule )
+     {
+        Readthedependlistofmoduleused(tmplistmodule->u_usemodule);
+        while( tmpuselocallist )
+        {
+           Addmoduletothelisttmp(tmpuselocallist->u_usemodule);
+           tmplistmodule1 = tmpuselocallist->suiv;
+           free(tmpuselocallist);
+           tmpuselocallist = tmplistmodule1;
+        }
+        tmplistmodule = tmplistmodule->suiv;
+     }
+
+
+
+     tmplistmodule = listofmoduletmp;
+     while ( tmplistmodule )
+     {
+        /* check if the file .depend<u_usemodule> exist                       */
+        List_ModuleUsedInModuleUsed_Var = Readthedependfile
+                   (tmplistmodule->u_usemodule,List_ModuleUsedInModuleUsed_Var);
+
+        List_GlobParamModuleUsedInModuleUsed_Var = ReaddependParameterList
+          (tmplistmodule->u_usemodule,List_GlobParamModuleUsedInModuleUsed_Var);
+        tmplistmodule = tmplistmodule->suiv;
+     }
+  }
+}
+
+/******************************************************************************/
+/*                      Add_NameOfModuleUsed_1                                */
+/******************************************************************************/
+/* This subroutine is used to add a record to a list of struct                */
+/* listusemodule                                                              */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub ... USE mod1 ===> insert in list                      */
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*       list =  List_NameOfModuleUsed                                        */
+/*                                                                            */
+/******************************************************************************/
+void Add_NameOfModuleUsed_1(char *name)
+{
+  listusemodule *newmodule;
+  listusemodule *parcours;
+  int out;
+
+  if ( firstpass == 1 )
+  {
+     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
+     strcpy(newmodule->u_usemodule,name);
+     Save_Length(name,16);
+     strcpy(newmodule->u_charusemodule,charusemodule);
+     Save_Length(charusemodule,17);
+     strcpy(newmodule->u_modulename,curmodulename);
+     Save_Length(curmodulename,19);
+     strcpy(newmodule->u_cursubroutine,subroutinename);
+     Save_Length(subroutinename,18);
+     newmodule->u_firstuse = 1 ;
+     newmodule->suiv = NULL;
+
+     if ( !List_NameOfModuleUsed)
+     {
+         List_NameOfModuleUsed = newmodule ;
+     }
+     else
+     {
+    parcours = List_NameOfModuleUsed;
+    while ( parcours && newmodule->u_firstuse == 1 )
+    {
+       if ( !strcasecmp(name,parcours->u_usemodule) )
+       {
+          newmodule->u_firstuse = 0 ;
+       }
+       parcours=parcours->suiv;
+    }
+    /* we can not add the same module twice for the same subroutine           */
+    parcours = List_NameOfModuleUsed;
+    out = 0 ;
+    while ( parcours && out == 0 )
+    {
+       if ( !strcasecmp(name,parcours->u_usemodule) &&
+            !strcasecmp(subroutinename,parcours->u_cursubroutine)
+           )
+       {
+          out = 1 ;
+          free(newmodule);
+       }
+       else parcours=parcours->suiv;
+    }
+    if ( out == 0 )
+    {
+       newmodule->suiv = List_NameOfModuleUsed;
+       List_NameOfModuleUsed = newmodule;
+    }
+  }
+  }
+}
+
+
+/******************************************************************************/
+/*                        Addmoduletothelist                                  */
+/******************************************************************************/
+/* This subroutine is used to add a record to a list of struct                */
+/* listusemodule                                                              */
+/******************************************************************************/
+/*                                                                            */
+/*       subroutine sub ... USE mod1 ===> insert in list                      */
+/*        _______     _______     _______     _______     _______             */
+/*       +      +    +      +    +      +    +      +    +      +             */
+/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
+/*       +______+    +______+    +______+    +______+    +______+             */
+/*                                                                            */
+/*       list =  List_NameOfModuleUsed                                     */
+/*                                                                            */
+/******************************************************************************/
+void Addmoduletothelist(char *name)
+{
+  listusemodule *newmodule;
+  listusemodule *parcours;
+  int out;
+
+     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
+     strcpy(newmodule->u_usemodule,name);
+     Save_Length(name,16);
+     strcpy(newmodule->u_charusemodule,charusemodule);
+     Save_Length(charusemodule,17);
+     strcpy(newmodule->u_cursubroutine,subroutinename);
+     Save_Length(subroutinename,18);
+     newmodule->u_firstuse = 1 ;
+     newmodule->suiv = NULL;
+
+     if ( !List_NameOfModuleUsed)
+     {
+         List_NameOfModuleUsed = newmodule ;
+     }
+     else
+     {
+    parcours = List_NameOfModuleUsed;
+    while ( parcours && newmodule->u_firstuse == 1 )
+    {
+       if ( !strcasecmp(name,parcours->u_usemodule) )
+       {
+          newmodule->u_firstuse = 0 ;
+       }
+       parcours=parcours->suiv;
+    }
+    /* we can not add the same module twice for the same subroutine           */
+    parcours = List_NameOfModuleUsed;
+    out = 0 ;
+    while ( parcours && out == 0 )
+    {
+       if ( !strcasecmp(name,parcours->u_usemodule) &&
+            !strcasecmp(subroutinename,parcours->u_cursubroutine)
+           )
+       {
+          out = 1 ;
+          free(newmodule);
+       }
+       else parcours=parcours->suiv;
+    }
+    if ( out == 0 )
+    {
+       newmodule->suiv = List_NameOfModuleUsed;
+       List_NameOfModuleUsed = newmodule;
+    }
+  }
+}
+
+
+/******************************************************************************/
+/*                        WriteUsemoduleDeclaration                           */
+/******************************************************************************/
+/* Firstpass 0                                                                */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void WriteUsemoduleDeclaration()
+{
+  listusemodule *newmodule;
+
+  newmodule = List_NameOfModuleUsed;
+  fprintf(fortranout,"\n");
+
+  while ( newmodule )
+  {
+     if ( !strcasecmp(newmodule->u_cursubroutine,subroutinename) )
+     {
+             fprintf(fortranout,"      USE %s \n"
+                                                   ,newmodule->u_charusemodule);
+     }
+        newmodule = newmodule ->suiv;
+  }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistvarindoloop.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistvarindoloop.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithlistvarindoloop.c	(revision 1844)
@@ -0,0 +1,1865 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or    or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)           */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "decl.h"
+
+/******************************************************************************/
+/*                         Add_UsedInSubroutine_Var_1                         */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should complete the List_UsedInSubroutine_Var                           */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Add_UsedInSubroutine_Var_1 (char *ident)
+{
+  listvar *newvar;
+  listvar *tmpvar;
+  int out;
+
+   /* In the first pass we record all variables presents in the do loop       */
+   if (firstpass == 1 && insubroutinedeclare == 1 )
+   {
+
+  if ( !List_UsedInSubroutine_Var )
+  {
+      newvar=(listvar *)malloc(sizeof(listvar));
+      newvar->var=(variable *)malloc(sizeof(variable));
+      /*                                                                      */
+      Init_Variable(newvar->var);
+      /*                                                                      */
+      newvar->suiv = NULL;
+      strcpy(newvar->var->v_nomvar,ident);
+      Save_Length(ident,4);
+      strcpy(newvar->var->v_modulename,curmodulename);
+      Save_Length(curmodulename,6);
+      strcpy(newvar->var->v_commoninfile,mainfile);
+      Save_Length(mainfile,10);
+      strcpy(newvar->var->v_subroutinename,subroutinename);
+      Save_Length(subroutinename,11);
+      newvar->var->v_pointedvar=pointedvar;
+      List_UsedInSubroutine_Var = newvar ;
+  }
+  else
+  {
+      /* We should verify that this variable did not added                    */
+      tmpvar = List_UsedInSubroutine_Var;
+      out = 0 ;
+      while (tmpvar && out == 0 )
+      {
+         if ( !strcasecmp(tmpvar->var->v_nomvar,ident) &&
+              !strcasecmp(tmpvar->var->v_subroutinename,subroutinename))
+                                                                      out  = 1 ;
+         else tmpvar = tmpvar->suiv;
+      }
+      if ( out == 0 )
+      {
+         newvar=(listvar *)malloc(sizeof(listvar));
+         newvar->var=(variable *)malloc(sizeof(variable));
+         /*                                                                   */
+         Init_Variable(newvar->var);
+         /*                                                                   */
+         strcpy(newvar->var->v_nomvar,ident);
+         Save_Length(ident,4);
+         strcpy(newvar->var->v_commoninfile,mainfile);
+         Save_Length(mainfile,10);
+         strcpy(newvar->var->v_modulename,curmodulename);
+         Save_Length(curmodulename,6);
+         strcpy(newvar->var->v_subroutinename,subroutinename);
+         Save_Length(subroutinename,11);
+         newvar->var->v_pointedvar=pointedvar;
+         newvar->suiv = List_UsedInSubroutine_Var;
+         List_UsedInSubroutine_Var = newvar;
+      }
+  }
+
+   }
+}
+
+/******************************************************************************/
+/*                        AJOUTEVARINDOLOOP_DEFINEDIMENSION                   */
+/******************************************************************************/
+/* This subroutine is used to add a listvar to  List_UsedInSubroutine_Var     */
+/******************************************************************************/
+void ajoutevarindoloop_definedimension (char *name)
+{
+  listvar *newvar;
+  listvar *tmpvar;
+  listvar *tmpvarprec;
+  int out;
+  int tablemeet;
+
+  if ( !List_UsedInSubroutine_Var )
+  {
+      newvar=(listvar *)malloc(sizeof(listvar));
+      newvar->var=(variable *)malloc(sizeof(variable));
+      /*                                                                      */
+      Init_Variable(newvar->var);
+      /*                                                                      */
+      newvar->suiv = NULL;
+      strcpy(newvar->var->v_nomvar,name);
+      Save_Length(name,4);
+      strcpy(newvar->var->v_modulename,curmodulename);
+      Save_Length(curmodulename,6);
+      strcpy(newvar->var->v_commoninfile,mainfile);
+      Save_Length(mainfile,10);
+      strcpy(newvar->var->v_subroutinename,subroutinename);
+      Save_Length(subroutinename,11);
+      newvar->var->v_pointedvar=pointedvar;
+      List_UsedInSubroutine_Var = newvar ;
+  }
+  else
+  {
+      /* We should verify that this variable did not added                    */
+      tmpvarprec = (listvar *)NULL;
+      tmpvar = List_UsedInSubroutine_Var;
+      out = 0 ;
+      tablemeet = 0 ;
+      while (tmpvar && out == 0 )
+      {
+         if ( tablemeet == 0 && tmpvar->var->v_nbdim != 0 ) tablemeet = 1 ;
+         /*                                                                   */
+         if ( !strcasecmp(tmpvar->var->v_nomvar,name) &&
+              !strcasecmp(tmpvar->var->v_subroutinename,subroutinename))
+         {
+            out  = 1 ;
+            /* if this variable has been define before a table we do nothing  */
+            /*    else we should remove it                                    */
+            if ( tablemeet == 1 )
+            {
+               tmpvarprec->suiv = tmpvar -> suiv;
+               out = 2;
+            }
+         }
+         else
+         {
+            tmpvarprec = tmpvar;
+            tmpvar = tmpvar->suiv;
+         }
+      }
+      if ( out == 2 || out == 0 )
+      {
+         newvar=(listvar *)malloc(sizeof(listvar));
+         newvar->var=(variable *)malloc(sizeof(variable));
+         /*                                                                   */
+         Init_Variable(newvar->var);
+         /*                                                                   */
+         strcpy(newvar->var->v_nomvar,name);
+         Save_Length(name,4);
+         strcpy(newvar->var->v_modulename,curmodulename);
+         Save_Length(curmodulename,6);
+         strcpy(newvar->var->v_commoninfile,mainfile);
+         Save_Length(mainfile,10);
+         strcpy(newvar->var->v_subroutinename,subroutinename);
+         Save_Length(subroutinename,11);
+         newvar->var->v_pointedvar=pointedvar;
+         /* we should find this new variable to know the tabvars indice       */
+         if ( variableisglobal(newvar, List_Global_Var) == 1 )
+         {
+            newvar->suiv = List_UsedInSubroutine_Var;
+            List_UsedInSubroutine_Var = newvar;
+         }
+         else if ( variableisglobal(newvar, List_ModuleUsed_Var) == 1 )
+         {
+            newvar->suiv = List_UsedInSubroutine_Var;
+            List_UsedInSubroutine_Var = newvar;
+         }
+         else if ( variableisglobal(newvar, List_Common_Var) == 1 )
+         {
+            newvar->suiv = List_UsedInSubroutine_Var;
+            List_UsedInSubroutine_Var = newvar;
+         }
+         else
+         {
+            free(newvar);
+         }
+     }
+  }
+}
+
+/******************************************************************************/
+/*                        ModifyThelistvarindoloop                            */
+/******************************************************************************/
+/* This subroutine is to give the old name to the which has been              */
+/* declared as USE MOD, U => V in this case we should replace in the          */
+/* name V by the old name U in the List_UsedInSubroutine_Var                  */
+/******************************************************************************/
+void  ModifyThelistvarindoloop()
+{
+  listvar *newvar;
+
+  newvar = List_UsedInSubroutine_Var;
+  while ( newvar )
+  {
+     if ( strcasecmp(newvar->var->v_oldname,"") )
+     {
+        strcpy(newvar->var->v_nomvar,newvar->var->v_oldname);
+     }
+     newvar = newvar->suiv;
+  }
+}
+
+/******************************************************************************/
+/*                          CompleteThelistvarindoloop                        */
+/******************************************************************************/
+/* This subroutine is to add to the List_UsedInSubroutine_Var all variables   */
+/* which has been declared as USE MOD, U => V in this case we should replace  */
+/* in the List_UsedInSubroutine_Var the word U by the word V                  */
+/******************************************************************************/
+void  CompleteThelistvarindoloop()
+{
+  listvar *newvar;
+  listvarpointtovar *pointtmplist;
+  listcouple *coupletmp;
+  int outvar;
+
+  pointtmplist = List_CouplePointed_Var;
+  while ( pointtmplist )
+  {
+      coupletmp = pointtmplist->t_couple;
+      while ( coupletmp )
+      {
+         newvar = List_UsedInSubroutine_Var;
+         outvar = 0 ;
+         while ( newvar && outvar == 0)
+         {
+           /* we should find the same variable name in the same subroutine    */
+           if ( !strcasecmp(newvar->var->v_nomvar,coupletmp->c_namevar) &&
+                !strcasecmp(newvar->var->v_subroutinename,
+                                       pointtmplist->t_cursubroutine) &&
+                 strcasecmp(coupletmp->c_namepointedvar,"")
+              )
+           {
+              outvar = 1;
+              strcpy(newvar->var->v_oldname,newvar->var->v_nomvar);
+              strcpy(newvar->var->v_nomvar,coupletmp->c_namepointedvar);
+           }
+           else
+           {
+              newvar = newvar->suiv;
+           }
+         }
+         coupletmp = coupletmp->suiv;
+     }
+     pointtmplist = pointtmplist->suiv;
+  }
+}
+
+/******************************************************************************/
+/*                             CopyRecord                                     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void CopyRecord(variable *var1,variable *var2)
+{
+   if ( !strcasecmp(var1->v_typevar,"") )
+                                        strcpy(var1->v_typevar,var2->v_typevar);
+   else strcpy(var2->v_typevar,var1->v_typevar);
+
+   if ( !strcasecmp(var1->v_oldname,"") )
+                                        strcpy(var1->v_oldname,var2->v_oldname);
+   else strcpy(var2->v_oldname,var1->v_oldname);
+
+   if ( !strcasecmp(var1->v_dimchar,"") )
+                                        strcpy(var1->v_dimchar,var2->v_dimchar);
+   else strcpy(var2->v_dimchar,var1->v_dimchar);
+
+   if ( !strcasecmp(var1->v_commonname,"") )
+                                  strcpy(var1->v_commonname,var2->v_commonname);
+   else strcpy(var2->v_commonname,var1->v_commonname);
+
+   if ( !strcasecmp(var1->v_vallengspec,"") )
+                                strcpy(var1->v_vallengspec,var2->v_vallengspec);
+   else strcpy(var2->v_vallengspec,var1->v_vallengspec);
+
+   if ( !strcasecmp(var1->v_nameinttypename,"") )
+                        strcpy(var1->v_nameinttypename,var2->v_nameinttypename);
+   else strcpy(var2->v_nameinttypename,var1->v_nameinttypename);
+          
+   if ( !strcasecmp(var1->v_commoninfile,"") )
+                              strcpy(var1->v_commoninfile,var2->v_commoninfile);
+   else strcpy(var2->v_commoninfile,var1->v_commoninfile);
+
+   if ( !strcasecmp(var1->v_precision,"") )
+                                    strcpy(var1->v_precision,var2->v_precision);
+   else strcpy(var2->v_precision,var1->v_precision);
+
+   if ( !strcasecmp(var1->v_initialvalue,"") )
+                              strcpy(var1->v_initialvalue,var2->v_initialvalue);
+   else strcpy(var2->v_initialvalue,var1->v_initialvalue);
+
+   if ( !strcasecmp(var1->v_IntentSpec,"") )
+                                  strcpy(var1->v_IntentSpec,var2->v_IntentSpec);
+   else strcpy(var2->v_IntentSpec,var1->v_IntentSpec);
+
+   if ( !strcasecmp(var1->v_readedlistdimension,"") )
+                strcpy(var1->v_readedlistdimension,var2->v_readedlistdimension);
+   else strcpy(var2->v_readedlistdimension,var1->v_readedlistdimension);
+
+   if ( var1->v_dimension ) var2->v_dimension = var1->v_dimension ;
+   else var1->v_dimension = var2->v_dimension ;
+
+   if ( var1->v_nbdim == 0 ) var1->v_nbdim = var2->v_nbdim ;
+   else var2->v_nbdim = var1->v_nbdim ;
+
+   if ( var1->v_common == 0 ) var1->v_common = var2->v_common ;
+   else var2->v_common = var1->v_common ;
+
+   if ( var1->v_positioninblock == 0 ) var1->v_positioninblock =
+                                                       var2->v_positioninblock ;
+   else var2->v_positioninblock = var1->v_positioninblock ;
+
+   if ( var1->v_module == 0 ) var1->v_module = var2->v_module ;
+   else var2->v_module = var1->v_module ;
+
+   if ( var1->v_save == 0 ) var1->v_save = var2->v_save ;
+   else var2->v_save = var1->v_save ;
+
+   if ( var1->v_VariableIsParameter == 0 )
+                     var1->v_VariableIsParameter = var2->v_VariableIsParameter ;
+   else var2->v_VariableIsParameter = var1->v_VariableIsParameter ;
+
+   if ( var1->v_indicetabvars == 0 )
+                                 var1->v_indicetabvars = var2->v_indicetabvars ;
+   else var2->v_indicetabvars = var1->v_indicetabvars ;
+
+   if ( var1->v_ExternalDeclare == 0 )
+                             var1->v_ExternalDeclare = var2->v_ExternalDeclare ;
+   else var2->v_ExternalDeclare = var1->v_ExternalDeclare ;
+
+   if ( var1->v_pointedvar == 0 ) var1->v_pointedvar = var2->v_pointedvar ;
+   else var2->v_pointedvar = var1->v_pointedvar ;
+
+   if ( var1->v_dimensiongiven == 0 )
+                                var1->v_dimensiongiven = var2->v_dimensiongiven;
+   else var2->v_dimensiongiven = var1->v_dimensiongiven ;
+
+   if ( var1->v_c_star == 0 ) var1->v_c_star = var2->v_c_star;
+   else var2->v_c_star = var1->v_c_star ;
+
+   if ( var1->v_pointerdeclare == 0 )
+                               var1->v_pointerdeclare = var2->v_pointerdeclare ;
+   else var2->v_pointerdeclare = var1->v_pointerdeclare ;
+
+
+   if ( var1->v_notgrid == 0 ) var1->v_notgrid = var2->v_notgrid ;
+   else var2->v_notgrid = var1->v_notgrid;
+
+   if ( var1->v_optionaldeclare == 0 )
+                              var1->v_optionaldeclare = var2->v_optionaldeclare;
+   else var2->v_optionaldeclare = var1->v_optionaldeclare ;
+
+   if ( var1->v_allocatable == 0 ) var1->v_allocatable = var2->v_allocatable ;
+   else var2->v_allocatable = var1->v_allocatable ;
+
+   if ( var1->v_dimsempty == 0 ) var1->v_dimsempty = var2->v_dimsempty ;
+   else var2->v_dimsempty = var1->v_dimsempty ;
+}
+
+
+/******************************************************************************/
+/*                      Update_List_Subroutine_Var                            */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Update_List_Subroutine_Var(listvar *list_to_modify)
+{
+   listvar *parcours;
+   listvar *parcoursprec;
+   listvar *parcours1;
+   int out;
+
+   parcoursprec = (listvar *)NULL;
+   parcours = list_to_modify;
+   while( parcours )
+   {
+      /* looking in List_SubroutineDeclaration_Var                            */
+      parcours1 = List_SubroutineDeclaration_Var;
+      out = 0;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                          parcours1->var->v_nomvar)         &&
+              !strcasecmp(parcours->var->v_subroutinename,
+                          parcours1->var->v_subroutinename) &&
+              !strcasecmp(parcours->var->v_modulename,
+                          parcours1->var->v_modulename)
+            ) out = 1;
+         else parcours1 = parcours1->suiv;
+      }
+      /* if variable has been found                                           */
+      
+      if ( out == 1 ) CopyRecord(parcours->var,parcours1->var);
+      
+      /* looking in List_Dimension_Var                                        */
+      if (out == 0 )
+      {
+        parcours1 = List_Dimension_Var;
+        out = 0;
+        while ( parcours1 && out == 0 )
+        {
+           if ( !strcasecmp(parcours->var->v_nomvar,
+                            parcours1->var->v_nomvar)         &&
+                !strcasecmp(parcours->var->v_subroutinename,
+                            parcours1->var->v_subroutinename) &&
+                !strcasecmp(parcours->var->v_modulename,
+                            parcours1->var->v_modulename)
+              ) out = 1;
+           else
+           {
+              parcoursprec = parcours1;
+              parcours1 = parcours1->suiv;
+           }
+        }
+        /* if variable has been found                                         */
+        
+        if ( out == 1 )
+        {
+           CopyRecord(parcours->var,parcours1->var);
+           /* we should remove this record from the List_Dimension_Var        */
+           if ( parcours1 == List_Dimension_Var )
+           {
+              List_Dimension_Var = List_Dimension_Var -> suiv;
+           }
+           else
+           {
+              parcoursprec->suiv = parcours1 -> suiv;
+           }
+        }
+      }
+      /*                                                                      */
+      parcours = parcours->suiv;
+   }
+}
+
+void Update_List_Global_Var_From_List_Save_Var()
+{
+   listvar *parcours;
+   listvar *newvar;
+   char ligne[LONG_C];
+
+   parcours = List_Save_Var;
+   while( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_modulename,"") )
+      /* Save in subroutine which is not defined in a module                  */
+      {
+         newvar = (listvar *)malloc(sizeof(listvar));
+         newvar->var = (variable *)malloc(sizeof(variable));
+         /*                                                                   */
+         Init_Variable(newvar->var);
+         /*                                                                   */
+         newvar->suiv = NULL;
+         CopyRecord(parcours->var,newvar->var);
+         strcpy(newvar->var->v_subroutinename,parcours->var->v_subroutinename);
+         strcpy(newvar->var->v_nomvar,parcours->var->v_nomvar);
+         sprintf(ligne,"save_%s",parcours->var->v_subroutinename);
+         Add_NameOfCommon_1(ligne);
+         strcpy(newvar->var->v_commonname,ligne);
+         Save_Length(ligne,7);
+         List_Common_Var = AddListvarToListvar(newvar,List_Common_Var,1);
+      }
+      else
+      /* Save in subroutine which is defined in a module                      */
+      {
+         newvar = (listvar *)malloc(sizeof(listvar));
+         newvar->var = (variable *)malloc(sizeof(variable));
+         /*                                                                   */
+         Init_Variable(newvar->var);
+         /*                                                                   */
+         newvar->suiv = NULL;
+         CopyRecord(parcours->var,newvar->var);
+         strcpy(newvar->var->v_subroutinename,"");
+         strcpy(newvar->var->v_nomvar,parcours->var->v_nomvar);
+         strcpy(newvar->var->v_modulename,parcours->var->v_modulename);
+         List_Global_Var = AddListvarToListvar(newvar,List_Global_Var,1);
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+/******************************************************************************/
+/*                      Update_List_From_Common_Var                           */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Update_List_From_Common_Var(listvar *list_to_modify)
+{
+   listvar *parcours;
+   listvar *parcours1;
+   int out;
+   parcours = list_to_modify;
+   while( parcours )
+   {
+      /* looking in List_Global_Var                                           */
+      parcours1 = List_Common_Var;
+      out = 0;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                          parcours1->var->v_nomvar)         &&
+              !strcasecmp(parcours->var->v_subroutinename,
+                          parcours1->var->v_subroutinename)
+            ) out = 1;
+         else parcours1 = parcours1->suiv;
+      }
+      /* if variable has been found                                           */
+      if ( out == 1 )
+      {
+         strcpy(parcours->var->v_commoninfile,parcours1->var->v_commoninfile);
+         CopyRecord(parcours->var,parcours1->var);
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+/******************************************************************************/
+/*                          Update_List_Var                                   */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Update_List_Var(listvar *list_to_modify)
+{
+   listvar *parcours;
+   listvar *parcours1;
+   int out;
+   
+   parcours = list_to_modify;
+   while( parcours )
+   {
+      /* looking in List_Global_Var                                           */
+      
+      out = 0;
+      if (list_to_modify != List_SubroutineDeclaration_Var) {
+      parcours1 = List_Global_Var;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                          parcours1->var->v_nomvar)         &&
+              !strcasecmp(parcours->var->v_modulename,
+                          parcours1->var->v_modulename)
+            ) out = 1;
+         else parcours1 = parcours1->suiv;
+      }
+      }
+          
+      /* if variable has been found                                           */
+      if ( out == 1 ) {
+      CopyRecord(parcours->var,parcours1->var);
+      }
+      /* looking in List_SubroutineDeclaration_Var                            */
+      else
+      {
+         parcours1 = List_SubroutineDeclaration_Var ;
+         out = 0;
+         while ( parcours1 && out == 0 )
+         {
+            if ( !strcasecmp(parcours->var->v_nomvar,
+                             parcours1->var->v_nomvar)         &&
+                 !strcasecmp(parcours->var->v_subroutinename,
+                             parcours1->var->v_subroutinename) &&
+                 !strcasecmp(parcours->var->v_modulename,
+                             parcours1->var->v_modulename)
+               ) out = 1;
+            else parcours1 = parcours1->suiv;
+         }
+             
+         /* if variable has been found                                        */
+         if ( out == 1 ) {
+         CopyRecord(parcours->var,parcours1->var);
+         }
+         else
+         {
+            parcours1 = List_Common_Var ;
+            out = 0;
+            while ( parcours1 && out == 0 )
+            {
+               if ( !strcasecmp(parcours->var->v_nomvar,
+                                parcours1->var->v_nomvar)         &&
+                    !strcasecmp(parcours->var->v_subroutinename,
+                                parcours1->var->v_subroutinename) &&
+                    !strcasecmp(parcours->var->v_modulename,
+                                parcours1->var->v_modulename)
+                  ) out = 1;
+               else parcours1 = parcours1->suiv;
+            }
+            /* if variable has been found                                     */
+            if ( out == 1 ) CopyRecord(parcours->var,parcours1->var);       
+         }
+      }
+      parcours = parcours->suiv;
+   }
+   
+}
+
+
+void List_UsedInSubroutine_Var_Update_From_Module_Used()
+{
+   listvar *parcours;
+   listvar *parcours3;
+   listusemodule *parcours2;
+   int out;
+
+   parcours = List_UsedInSubroutine_Var;
+   while( parcours )
+   {
+      out = 0 ;
+      if ( parcours->var->v_indicetabvars == 0 )
+      {
+         parcours2 = List_NameOfModuleUsed;
+         while( parcours2 )
+         {
+            if ( !strcasecmp(parcours2->u_cursubroutine,"") &&
+                 !strcasecmp(parcours2->u_modulename,
+                             parcours->var->v_modulename)
+               )
+            {
+               parcours3 = List_Global_Var;
+               out = 0 ;
+               while ( parcours3 && out == 0 )
+               {
+                  if ( !strcasecmp(parcours->var->v_nomvar,
+                                   parcours3->var->v_nomvar)
+                     ) out = 1 ;
+                  else parcours3 = parcours3->suiv;
+               }
+               if ( out == 1 ) CopyRecord(parcours->var,parcours3->var);
+            }
+            else if ( !strcasecmp(parcours2->u_cursubroutine,
+                             parcours->var->v_subroutinename) &&
+                 !strcasecmp(parcours2->u_modulename,
+                             parcours->var->v_modulename)
+               )
+            {
+               parcours3 = List_Global_Var;
+               out = 0 ;
+               while ( parcours3 && out == 0 )
+               {
+                  if ( !strcasecmp(parcours->var->v_nomvar,
+                                   parcours3->var->v_nomvar)
+                     ) out = 1 ;
+                  else parcours3 = parcours3->suiv;
+               }
+               if ( out == 1 ) CopyRecord(parcours->var,parcours3->var);
+            }
+            parcours2 = parcours2->suiv;
+         }
+         /*                                                                   */
+         if ( out == 0 )
+         {
+            parcours3 = List_ModuleUsed_Var;
+            out = 0 ;
+            while ( parcours3 && out == 0 )
+            {
+               if ( !strcasecmp(parcours->var->v_nomvar,
+                                parcours3->var->v_nomvar)
+                  ) out = 1 ;
+               else parcours3 = parcours3->suiv;
+            }
+            if ( out == 1 ) CopyRecord(parcours->var,parcours3->var);
+         }
+         /*                                                                   */
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+
+
+/******************************************************************************/
+/*                       Update_NotGridDepend_Var                             */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void Update_NotGridDepend_Var(listvar *list_to_modify)
+{
+   listvar *parcours;
+   listvar *parcours1;
+   int out;
+
+   parcours = list_to_modify;
+   while( parcours )
+   {
+      /* looking in List_Global_Var                                           */
+      parcours1 = List_Global_Var;
+      out = 0;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                          parcours1->var->v_nomvar)
+            ) out = 1;
+         else parcours1 = parcours1->suiv;
+      }
+      /* if variable has been found                                           */
+      if ( out == 1 )
+      {
+         CopyRecord(parcours->var,parcours1->var);
+         strcpy(parcours->var->v_subroutinename,
+                parcours1->var->v_subroutinename);
+         strcpy(parcours->var->v_modulename,parcours1->var->v_modulename);
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+int LookingForVariableInList(listvar *listin,variable *var)
+{
+   listvar *parcours1;
+   int out;
+
+   parcours1 = listin;
+   out = 0 ;
+   while ( parcours1 && out == 0 )
+   {
+      if ( !strcasecmp(var->v_nomvar,parcours1->var->v_nomvar)                &&
+           !strcasecmp(var->v_subroutinename,parcours1->var->v_subroutinename)&&
+           !strcasecmp(var->v_modulename,parcours1->var->v_modulename)        &&
+                       var->v_save == 0                                       &&
+                       var->v_common == 0
+         ) out = 1 ;
+      else parcours1 = parcours1 -> suiv;
+   }
+
+   return out;
+}
+
+int LookingForVariableInListGlobal(listvar *listin,variable *var)
+{
+   listvar *parcours1;
+   int out;
+
+   parcours1 = listin;
+   out = 0 ;
+   while ( parcours1 && out == 0 )
+   {
+      if ( !strcasecmp(var->v_nomvar,parcours1->var->v_nomvar)                &&
+           !strcasecmp(var->v_subroutinename,parcours1->var->v_subroutinename)&&
+           !strcasecmp(var->v_modulename,parcours1->var->v_modulename)
+         ) out = 1 ;
+      else parcours1 = parcours1 -> suiv;
+   }
+
+   return out;
+}
+
+int LookingForVariableInListName(listvar *listin,char *name)
+{
+   listvar *parcours1;
+   int out;
+
+   parcours1 = listin;
+   out = 0 ;
+   while ( parcours1 && out == 0 )
+   {
+      if ( !strcasecmp(name,parcours1->var->v_nomvar) &&
+           ( !strcasecmp(subroutinename,parcours1->var->v_subroutinename) ||
+             !strcasecmp(subroutinename,"") )
+         ) out = 1 ;
+      else parcours1 = parcours1 -> suiv;
+   }
+
+   return out;
+}
+
+int LookingForVariableInListGlob(listvar *listin,variable *var)
+{
+   listvar *parcours1;
+   int out;
+
+   parcours1 = listin;
+   out = 0 ;
+   while ( parcours1 && out == 0 )
+   {
+      if ( !strcasecmp(var->v_nomvar,parcours1->var->v_nomvar)                &&
+           !strcasecmp(var->v_modulename,parcours1->var->v_modulename)
+         ) out = 1 ;
+      else parcours1 = parcours1 -> suiv;
+   }
+
+   return out;
+}
+
+int LookingForVariableInListParamGlob(listparameter *listin,variable *var)
+{
+   listparameter *parcours1;
+   int out;
+
+   parcours1 = listin;
+   out = 0 ;
+   while ( parcours1 && out == 0 )
+   {
+      if ( !strcasecmp(var->v_nomvar,parcours1->p_name)
+         ) out = 1 ;
+      else parcours1 = parcours1 -> suiv;
+   }
+
+   return out;
+}
+
+void UpdateListDeclarationWithDimensionList()
+{
+   List_SubroutineDeclaration_Var = AddListvarToListvar(List_Dimension_Var,
+                                              List_SubroutineDeclaration_Var,1);
+}
+
+
+/* Remove from List_UsedInSubroutine_Var all variables comming from :         */
+/*       - List_SubroutineArgument_Var                                        */
+/*       - List_SubroutineDeclaration_Var                                     */
+/*       - List_Parameter_Var                                                 */
+/*       - List_FunctionType_Var                                              */
+/*       - List_GlobalParameter_Var                                           */
+/*       -                                                                    */
+/*       -                                                                    */
+void Clean_List_UsedInSubroutine_Var()
+{
+   listvar *parcours;
+   listvar *parcoursprec;
+   int remove;
+    
+        
+   parcoursprec = (listvar *)NULL;
+   parcours = List_UsedInSubroutine_Var;
+   while ( parcours )
+   {
+      /*                                                                      */
+      remove = LookingForVariableInListGlobal(List_SubroutineArgument_Var,
+                                                                 parcours->var);
+      if ( remove == 0 )
+           remove = LookingForVariableInList(List_SubroutineDeclaration_Var,
+                                                                 parcours->var);
+      if ( remove == 0 )
+           remove = LookingForVariableInList(List_Parameter_Var,
+                                                                 parcours->var);
+      if ( remove == 0 )
+           remove = LookingForVariableInList(List_FunctionType_Var,
+                                                                 parcours->var);
+      if ( remove == 0 )
+           remove = LookingForVariableInListGlob(List_GlobalParameter_Var,
+                                                                 parcours->var);
+      if ( remove == 0 )
+           remove = LookingForVariableInListParamGlob(
+                                    List_GlobParamModuleUsed_Var,parcours->var);
+      if ( remove == 0 )
+      {
+         if ( VariableIsInList(parcours,List_Global_Var)                 == 1 ||
+              VariableIsInListCommon(parcours,List_Common_Var)           == 1 ||
+              VariableIsInList(parcours,List_ModuleUsed_Var)             == 1 ||
+              VariableIsInList(parcours,List_ModuleUsedInModuleUsed_Var) == 1
+            ) remove = 0;
+         else remove = 1;
+      }
+      /************************************************************************/
+      /*                         Remove                                       */
+      /************************************************************************/
+      if ( remove == 1 )
+      {
+         if ( parcours == List_UsedInSubroutine_Var )
+         {
+           List_UsedInSubroutine_Var = List_UsedInSubroutine_Var -> suiv;
+           parcours = List_UsedInSubroutine_Var;
+         }
+         else
+         {
+            parcoursprec->suiv = parcours->suiv;
+            parcours = parcoursprec -> suiv ;
+         }
+      }
+      else
+      {
+         parcoursprec = parcours;
+         parcours = parcours -> suiv ;
+      }
+   }
+
+}
+
+
+void Clean_List_ModuleUsed_Var()
+{
+   listvar *parcours;
+   listvar *parcours1;
+   listvar *parcoursprec;
+   int remove;
+
+   parcoursprec = (listvar *)NULL;
+   parcours = List_ModuleUsed_Var;
+   while ( parcours )
+   {
+      /*                                                                      */
+      parcours1 = List_GlobalParameter_Var;
+      remove = 0 ;
+      while ( parcours1 && remove == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,parcours1->var->v_nomvar)
+            ) remove = 1 ;
+         else parcours1 = parcours1 -> suiv;
+      }
+      /************************************************************************/
+      /*                         Remove                                       */
+      /************************************************************************/
+      if ( remove == 1 )
+      {
+         if ( parcours == List_ModuleUsed_Var )
+         {
+           List_ModuleUsed_Var = List_ModuleUsed_Var -> suiv;
+           parcours = List_ModuleUsed_Var;
+         }
+         else
+         {
+            parcoursprec->suiv = parcours->suiv;
+            parcours = parcoursprec -> suiv ;
+         }
+      }
+      else
+      {
+         parcoursprec = parcours;
+         parcours = parcours -> suiv ;
+      }
+   }
+
+}
+
+void Clean_List_SubroutineDeclaration_Var()
+{
+   listvar *parcours;
+   listvar *parcours1;
+   listvar *parcoursprec;
+   int out ;
+           
+   parcoursprec = (listvar *)NULL;
+   parcours = List_SubroutineDeclaration_Var;
+   while ( parcours )
+   {
+      parcours1 = List_FunctionType_Var;
+      out = 0 ;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_subroutinename,
+                          parcours1->var->v_subroutinename) &&
+              !strcasecmp(parcours->var->v_nomvar,
+                          parcours1->var->v_nomvar)
+            ) out = 1;
+         else parcours1 = parcours1->suiv;
+      }
+      if ( out == 0 )
+      {
+         parcours1 = List_SubroutineArgument_Var;
+         out = 0 ;
+         while ( parcours1 && out == 0 )
+         {
+            if ( !strcasecmp(parcours->var->v_subroutinename,
+                             parcours1->var->v_subroutinename) &&
+                 !strcasecmp(parcours->var->v_nomvar,
+                             parcours1->var->v_nomvar)
+               ) out = 1;
+            else parcours1 = parcours1->suiv;
+         }
+      }
+
+      if ( out == 1 )
+      {
+          if ( parcours == List_SubroutineDeclaration_Var )
+          {
+             List_SubroutineDeclaration_Var =
+                                         List_SubroutineDeclaration_Var -> suiv;
+             parcours = List_SubroutineDeclaration_Var;
+          }
+          else
+          {
+             parcoursprec->suiv = parcours->suiv;
+             parcours = parcoursprec->suiv;
+          }
+      }
+      else
+      {
+         parcoursprec = parcours;
+         parcours = parcours -> suiv;
+      }
+   }
+       
+}
+
+void Clean_List_Global_Var()
+{
+   listvar *parcours;
+   listvar *parcours2;
+   listvar *parcoursprec;
+   listvar *parcours2prec;
+
+   parcoursprec = (listvar *)NULL;
+   parcours2prec = (listvar *)NULL;
+   parcours = List_Global_Var;
+   while ( parcours )
+   {
+      if ( parcours->var->v_VariableIsParameter == 1 )
+      {
+         /* remove                                                            */
+         if ( parcours == List_Global_Var )
+         {
+            List_Global_Var = List_Global_Var->suiv;
+            free(parcours);
+            parcours = List_Global_Var;
+         }
+         else
+         {
+            parcoursprec->suiv = parcours->suiv;
+            free(parcours);
+            parcours = parcoursprec->suiv;
+         }
+      }
+      else
+      {
+         parcoursprec = parcours;
+         parcours = parcours->suiv;
+      }
+   }
+   /* looking for sevral declaration of the same variable                     */
+   parcours = List_Global_Var;
+   while ( parcours )
+   {
+      parcours2prec = parcours;
+      parcours2 = parcours->suiv;
+      while ( parcours2 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                         parcours2->var->v_nomvar)     &&
+              !strcasecmp(parcours->var->v_modulename,
+                         parcours2->var->v_modulename) )
+         {
+            CopyRecord(parcours->var,parcours2->var);
+            /* remove var from the parcours2                                  */
+            parcours2prec ->suiv = parcours2->suiv;
+            free(parcours2);
+            parcours2 = parcours2prec ->suiv;
+         }
+         else
+         {
+            parcours2prec = parcours2;
+            parcours2 = parcours2->suiv;
+         }
+      }
+      parcours = parcours->suiv;
+   }
+}
+/******************************************************************************/
+/*                             ListClean                                      */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void ListClean()
+{
+   listvar *newvar;
+
+   Clean_List_ModuleUsed_Var();
+   Clean_List_UsedInSubroutine_Var();
+   Clean_List_SubroutineDeclaration_Var();
+   
+   newvar = (listvar *)NULL;
+/*   newvar = List_Common_Var;*/
+   while(newvar)
+   {
+      printf("----- %s --- %s ---%s---%s---\n",newvar->var->v_nomvar,
+         newvar->var->v_commonname,
+         newvar->var->v_readedlistdimension,
+         newvar->var->v_subroutinename
+      );
+      newvar = newvar -> suiv;
+      printf("+++++++++++++++++++++++++\n");
+   }
+
+}
+
+
+/******************************************************************************/
+/*                             ListUpdate                                     */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void ListUpdate()
+{
+   listvar *newvar;
+        
+   Update_List_Subroutine_Var(List_SubroutineArgument_Var);
+
+
+       
+   Update_List_Subroutine_Var(List_FunctionType_Var);
+   Update_List_Var(List_Parameter_Var);
+   Update_List_Var(List_Dimension_Var);
+   Update_List_Var(List_Data_Var);
+   Update_List_Var(List_Save_Var);
+   Update_List_Var(List_GlobalParameter_Var);
+   Update_List_Var(List_Common_Var);
+   Update_List_Var(List_SubroutineDeclaration_Var);
+   Update_List_Var(List_UsedInSubroutine_Var);
+   Update_List_From_Common_Var(List_UsedInSubroutine_Var);
+   Update_List_From_Common_Var(List_SubroutineDeclaration_Var);
+   Update_NotGridDepend_Var(List_NotGridDepend_Var);
+    
+   newvar =(listvar * )NULL;
+/*   newvar = List_Common_Var;*/
+/*   newvar = List_UsedInSubroutine_Var;*/
+   while ( newvar )
+   {
+      printf("++++ %s %d %s %s %s\n",
+      newvar->var->v_nomvar,
+      newvar->var->v_VariableIsParameter,
+      newvar->var->v_subroutinename,
+      newvar->var->v_modulename,
+      newvar->var->v_typevar
+            );
+      newvar = newvar->suiv;
+   }
+}
+
+void GiveTypeOfVariables()
+{
+   listvar *parcours;
+
+   /*                                                                         */
+   parcours = List_Common_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_typevar,"") )
+      {
+         if ( IsVariableReal(parcours->var->v_nomvar) == 1 )
+                                        strcpy(parcours->var->v_typevar,"REAL");
+         else strcpy(parcours->var->v_typevar,"INTEGER");
+      }
+      parcours = parcours -> suiv ;
+   }
+   /*                                                                         */
+   parcours = List_UsedInSubroutine_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_typevar,"") )
+      {
+         if ( IsVariableReal(parcours->var->v_nomvar) == 1 )
+                                        strcpy(parcours->var->v_typevar,"REAL");
+         else strcpy(parcours->var->v_typevar,"INTEGER");
+      }
+      parcours = parcours -> suiv ;
+   }
+   /*                                                                         */
+   parcours = List_SubroutineArgument_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_typevar,"") )
+      {
+         if ( IsVariableReal(parcours->var->v_nomvar) == 1 )
+                                        strcpy(parcours->var->v_typevar,"REAL");
+         else strcpy(parcours->var->v_typevar,"INTEGER");
+      }
+      parcours = parcours -> suiv ;
+   }
+   /*                                                                         */
+   parcours = List_SubroutineDeclaration_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_typevar,"") )
+      {
+         if ( IsVariableReal(parcours->var->v_nomvar) == 1 )
+                                        strcpy(parcours->var->v_typevar,"REAL");
+         else strcpy(parcours->var->v_typevar,"INTEGER");
+      }
+      parcours = parcours -> suiv ;
+   }
+       
+}
+
+
+
+void Sort_List_SubroutineArgument_Var()
+{
+   listvar *parcours;
+   listvar *parcours1;
+   int position;
+   int out;
+   char name_sub[LONG_C];
+
+   parcours = List_SubroutineArgument_Var;
+   position = 1;
+   while ( parcours )
+   {
+      parcours1 = List_SubroutineDeclaration_Var;
+      out = 0;
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_nomvar,
+                         parcours1->var->v_nomvar)  &&
+              !strcasecmp(parcours->var->v_subroutinename,
+                         parcours1->var->v_subroutinename)
+             )
+         {
+            parcours1->var->v_positioninblock = position;
+            position = position +1 ;
+            out = 1;
+         }
+         else parcours1 = parcours1->suiv;
+      }
+      parcours = parcours->suiv;
+   }
+   /*                                                                         */
+   parcours = List_SubroutineDeclaration_Var;
+   strcpy(name_sub,"");
+   while ( parcours )
+   {
+      if ( !strcasecmp(name_sub,"") )
+      {
+         strcpy(name_sub,parcours->var->v_subroutinename);
+         position = 1;
+      }
+
+      if ( parcours->var->v_positioninblock != 0 )
+      {
+         parcours1 = List_SubroutineArgument_Var;
+         out = 0;
+         while ( parcours1 && out == 0 )
+         {
+            if ( !strcasecmp(parcours->var->v_nomvar,
+                            parcours1->var->v_nomvar)  &&
+                 !strcasecmp(parcours->var->v_subroutinename,
+                            parcours1->var->v_subroutinename)
+                )
+            {
+               parcours1->var->v_positioninblock = position;
+               position = position +1 ;
+               out = 1;
+            }
+            else parcours1 = parcours1->suiv;
+         }
+      }
+      if ( parcours->suiv )
+         if ( strcasecmp(name_sub,parcours->suiv->var->v_subroutinename) )
+            strcpy(name_sub,"");
+      parcours = parcours->suiv;
+   }
+       
+}
+
+
+
+/******************************************************************************/
+/*                      IndiceTabvars_Global_Var_Treated                      */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void IndiceTabvars_Global_Var_Treated(char *nom)
+{
+   listvar *parcours;
+   listvar *parcoursprec;
+   listvar *parcours1;
+   listvar *List_ModuleUsed_Var;
+   listindice *newindice;
+   int out;
+
+   parcoursprec = (listvar *)NULL;
+
+   if ( mark == 1 ) printf("MODULE Treated %s \n",nom);
+
+   List_ModuleUsed_Var = (listvar *)NULL;
+   List_ModuleUsed_Var = Readthedependfile(nom,List_ModuleUsed_Var);
+
+   parcours = List_Global_Var;
+   while( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_modulename,nom) )
+      {
+         parcours1 = List_ModuleUsed_Var;
+         out = 0 ;
+         while ( parcours1 && out == 0 )
+         {
+            if ( !strcasecmp(parcours->var->v_nomvar,parcours1->var->v_nomvar)
+               ) out = 1;
+            else
+            {
+               parcoursprec = parcours1 ;
+               parcours1 = parcours1->suiv;
+            }
+         }
+         /* if we found the var Module name in the old list                   */
+         if ( out == 1 )
+         {
+            CopyRecord(parcours->var,parcours1->var);
+            /* Remove this variable from the List_ModuleUsed_Var              */
+            if ( parcours1 == List_ModuleUsed_Var )
+            {
+               List_ModuleUsed_Var = List_ModuleUsed_Var->suiv ;
+            }
+            else
+            {
+               parcoursprec->suiv = parcours1->suiv;
+               free(parcours1);
+               parcours1 = parcoursprec->suiv;
+            }
+         }
+         else
+         /* if we do not found the var Module name in the old list            */
+         {
+            if ( Listofavailableindices )
+            {
+               parcours->var->v_indicetabvars = Listofavailableindices ->
+                                                                       i_indice;
+               if ( Listofavailableindices->suiv )
+                          Listofavailableindices = Listofavailableindices->suiv;
+               else
+                          Listofavailableindices = (listindice *)NULL;
+            }
+            else
+            {
+               indicemaxtabvars = indicemaxtabvars + 1 ;
+               parcours->var->v_indicetabvars = indicemaxtabvars;
+            }
+         }
+      }
+      parcours = parcours->suiv;
+   }
+   /* if List_ModuleUsed_Var is not empty, some var have been removed from    */
+   /*    the last treatement                                                  */
+  parcours1 = List_ModuleUsed_Var;
+  while ( parcours1 )
+  {
+     newindice=(listindice *) malloc (sizeof (listindice));
+     newindice -> i_indice = parcours1 -> var -> v_indicetabvars;
+     newindice -> suiv = Listofavailableindices;
+     Listofavailableindices = newindice;
+     parcours1 = parcours1->suiv;
+  }
+}
+/******************************************************************************/
+/*                       IndiceTabvars_Global_Var_No_Treated                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void IndiceTabvars_Global_Var_No_Treated(char *nom)
+{
+   listvar *parcours;
+
+   if ( mark == 1 ) printf("MODULE No Treated %s \n",nom);
+
+   parcours = List_Global_Var;
+   while( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_modulename,nom) &&
+           parcours->var->v_VariableIsParameter == 0    &&
+           parcours->var->v_notgrid == 0
+          )
+      {
+         indicemaxtabvars = indicemaxtabvars + 1 ;
+         parcours->var->v_indicetabvars = indicemaxtabvars;
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+
+void UpdateTheRemainingList(listvar *record)
+{
+   listvar *parcours;
+
+   parcours = record;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_nomvar,record->var->v_nomvar) &&
+           !strcasecmp(parcours->var->v_commonname,record->var->v_commonname)
+         )
+      {
+         strcpy(parcours->var->v_commoninfile,record->var->v_commoninfile);
+         CopyRecord(parcours->var,record->var);
+      }
+      parcours = parcours -> suiv;
+   }
+}
+
+
+
+/******************************************************************************/
+/*                      IndiceTabvars_Common_Var_Treated                      */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void IndiceTabvars_Common_Var_Treated(char *nom)
+{
+   listvar *parcours;
+   listvar *parcoursprec;
+   listvar *parcours1;
+   listvar *List_CommonUsed_Var;
+   listindice *newindice;
+   int out;
+
+   parcoursprec = (listvar *)NULL;
+
+   if ( mark == 1 ) printf("COMMON Treated %s \n",nom);
+
+   List_CommonUsed_Var = (listvar *)NULL;
+   List_CommonUsed_Var = Readthedependfile(nom,List_CommonUsed_Var);
+
+   parcours = List_Common_Var;
+   while( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_commonname,nom) )
+      {
+         parcours1 = List_CommonUsed_Var;
+         out = 0 ;
+         while ( parcours1 && out == 0 )
+         {
+
+            if ( !strcasecmp(parcours1->var->v_commonname,nom) &&
+                 !strcasecmp(parcours->var->v_nomvar,parcours1->var->v_nomvar)
+               ) out = 1;
+            else
+            {
+               parcoursprec = parcours1 ;
+               parcours1 = parcours1->suiv;
+            }
+         }
+         /* if we found the var common name in the old list                   */
+         if ( out == 1 )
+         {
+            strcpy(parcours->var->v_commoninfile,
+                   parcours1->var->v_commoninfile);
+            CopyRecord(parcours->var,parcours1->var);
+         }
+         else
+         /* if we do not found the var common name in the old list            */
+         {
+            if ( Listofavailableindices )
+            {
+               parcours->var->v_indicetabvars = Listofavailableindices ->
+                                                                       i_indice;
+               if ( Listofavailableindices->suiv )
+                          Listofavailableindices = Listofavailableindices->suiv;
+               else
+                          Listofavailableindices = (listindice *)NULL;
+            }
+            else
+            {
+               indicemaxtabvars = indicemaxtabvars + 1 ;
+               parcours->var->v_indicetabvars = indicemaxtabvars;
+            }
+         }
+         /* Look in the remaining list in the variable is define              */
+         UpdateTheRemainingList(parcours);
+      }
+      parcours = parcours->suiv;
+   }
+   /* if List_CommonUsed_Var is not empty, some var have been removed from    */
+   /*    the last treatement                                                  */
+  parcours1 = List_CommonUsed_Var;
+  while ( parcours1 )
+  {
+     if ( parcours1 -> var -> v_indicetabvars == 0 )
+     {
+        newindice=(listindice *) malloc (sizeof (listindice));
+        newindice -> i_indice = parcours1 -> var -> v_indicetabvars;
+        newindice -> suiv = Listofavailableindices;
+        Listofavailableindices = newindice;
+     }
+     parcours1 = parcours1->suiv;
+  }
+}
+/******************************************************************************/
+/*                     IndiceTabvars_Common_Var_No_Treated                    */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void IndiceTabvars_Common_Var_No_Treated(char *nom)
+{
+   listvar *parcours;
+   listvar *parcours2;
+
+   if ( mark == 1 ) printf("COMMON No Treated %s \n",nom);
+
+   parcours = List_Common_Var;
+   while( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_commonname,nom) &&
+           strcasecmp(parcours->var->v_subroutinename,"") &&
+           parcours->var->v_indicetabvars == 0
+          )
+      {
+         indicemaxtabvars = indicemaxtabvars + 1 ;
+         parcours->var->v_indicetabvars = indicemaxtabvars;
+         parcours2 = parcours;
+         while ( parcours2 )
+         {
+            if ( !strcasecmp(parcours->var->v_nomvar,
+                             parcours2->var->v_nomvar) &&
+                 !strcasecmp(parcours->var->v_commonname,
+                             parcours2->var->v_commonname)
+               )
+               parcours2->var->v_indicetabvars = parcours->var->v_indicetabvars;
+            parcours2 = parcours2->suiv;
+         }
+      }
+      parcours = parcours->suiv;
+   }
+}
+
+
+/******************************************************************************/
+/*                       IndiceTabvarsIdentification                          */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void IndiceTabvarsIdentification()
+{
+   listnom *parcours_nom;
+
+   /* Identification of tabvars indices in List_Global_Var                    */
+   parcours_nom = List_NameOfModule;
+   while ( parcours_nom )
+   {
+      if ( Did_module_common_treaded(parcours_nom->o_nom) == 1 )
+      {
+         IndiceTabvars_Global_Var_Treated(parcours_nom->o_nom);
+      }
+      else
+      {
+         IndiceTabvars_Global_Var_No_Treated(parcours_nom->o_nom);
+      }
+      parcours_nom = parcours_nom -> suiv;
+   }
+   /* Identification of tabvars indices in List_Common_Var                    */
+   parcours_nom = List_NameOfCommon;
+   while ( parcours_nom )
+   {
+      if ( Did_module_common_treaded(parcours_nom->o_nom) == 1 )
+      {
+         IndiceTabvars_Common_Var_Treated(parcours_nom->o_nom);
+      }
+      else
+      {
+         IndiceTabvars_Common_Var_No_Treated(parcours_nom->o_nom);
+      }
+      parcours_nom = parcours_nom -> suiv;
+   }
+
+}
+
+void New_Allocate_Subroutine_Is_Necessary()
+{
+   listnom *parcours_nom;
+   listvar *parcours;
+   int out;
+
+   parcours_nom = List_NameOfModule;
+   while ( parcours_nom )
+   {
+      /*                                                                      */
+      parcours = List_Global_Var;
+      out = 0 ;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_modulename,parcours_nom->o_nom) &&
+              !strcasecmp(parcours->var->v_subroutinename,"")            &&
+              parcours->var->v_VariableIsParameter == 0                  &&
+              (parcours->var->v_allocatable == 0  || !strcasecmp(parcours->var->v_typevar,"type"))      &&
+              parcours->var->v_notgrid == 0                              &&
+              ( parcours->var->v_nbdim != 0 ||
+                strcasecmp(parcours->var->v_initialvalue,"")
+              ) ) out = 1;
+         else parcours = parcours -> suiv;
+      }
+      if ( out == 1 )
+      {
+         parcours_nom->o_val = 1 ;
+      }
+      /*                                                                      */
+      parcours_nom = parcours_nom -> suiv;
+   }
+}
+
+void New_Allocate_Subroutine_For_Common_Is_Necessary()
+{
+   listnom *parcours_nom;
+   listvar *parcours;
+   int out;
+
+   parcours_nom = List_NameOfCommon;
+   while ( parcours_nom )
+   {
+      /*                                                                      */
+      parcours = List_Common_Var;
+      out = 0 ;
+      while( parcours && out == 0 )
+      {
+         if ( !strcasecmp(parcours->var->v_commonname,parcours_nom->o_nom)  &&
+              strcasecmp(parcours->var->v_subroutinename,"")                &&
+              !strcasecmp(parcours->var->v_commoninfile,mainfile)           &&
+              ( parcours->var->v_nbdim != 0 ||
+                strcasecmp(parcours->var->v_initialvalue,"")
+              ) ) out = 1;
+         else parcours = parcours -> suiv;
+      }
+      if ( out == 1 )
+      {
+         parcours_nom->o_val = 1 ;
+      }
+      /*                                                                      */
+      parcours_nom = parcours_nom -> suiv;
+   }
+}
+
+void NewModule_Creation_0()
+{
+   listnom *parcours_nom;
+   char ligne[LONG_C];
+
+   if ( firstpass == 0 )
+   {
+      parcours_nom = List_NameOfCommon;
+      while ( parcours_nom )
+      {
+         if ( parcours_nom->o_val == 1 )
+         {
+            sprintf (ligne, "module %s",parcours_nom->o_nom);
+            tofich(fortranout,ligne,1);
+            strcpy(ligne,"implicit none");
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "public Alloc_agrif_%s",parcours_nom->o_nom);
+            tofich(fortranout,ligne,1);
+            strcpy (ligne, "contains");
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "subroutine Alloc_agrif_%s(Agrif_Gr)",
+                                                           parcours_nom->o_nom);
+            tofich(fortranout,ligne,1);
+            strcpy(ligne,"Use Agrif_Util");
+            tofich(fortranout,ligne,1);
+            strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr");
+            tofich(fortranout,ligne,1);
+            strcpy(ligne, "INTEGER :: i");
+            tofich (fortranout, ligne,1);
+            strcpy (ligne, "\n#include \"alloc_agrif_");
+            strcat (ligne, parcours_nom->o_nom);
+            strcat (ligne, ".h\"\n");
+            fprintf(fortranout,ligne);
+            strcpy (ligne, "Return");
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "end subroutine Alloc_agrif_%s",
+                                                           parcours_nom->o_nom);
+            tofich(fortranout,ligne,1);
+            sprintf (ligne, "end module %s",parcours_nom->o_nom);
+            tofich(fortranout,ligne,1);
+            /* List all Call Alloc_agrif                                      */
+            Add_Subroutine_For_Alloc(parcours_nom->o_nom);
+         }
+         parcours_nom = parcours_nom->suiv;
+      }
+   }
+}
+
+void UpdateList_SubroutineWhereAgrifUsed()
+{
+   listnom *parcours;
+   listusemodule *parcours1;
+   listallocate *parcours2;
+   listname *parcours3;
+   listvar *parcours4;
+   int out;
+   char name_module[LONG_C];
+
+   /* We should integrate allocate and pointer variables                      */
+   parcours2 = List_Allocate_Var;
+   while ( parcours2 )
+   {
+      parcours4 = List_UsedInSubroutine_Var;
+      out = 0 ;
+      while ( parcours4 && out == 0 )
+      {
+         if ( !strcasecmp(parcours2->a_nomvar,parcours4->var->v_nomvar) )
+         {
+            Add_SubroutineWhereAgrifUsed_1(parcours4->var->v_subroutinename,
+                                           parcours4->var->v_modulename);
+            out = 1;
+         }
+         else parcours4 = parcours4 -> suiv ;
+      }
+      parcours2 = parcours2->suiv;
+   }
+   /*                                                                         */
+   parcours3 = List_Pointer_Var;
+   while ( parcours3 )
+   {
+      parcours4 = List_UsedInSubroutine_Var;
+      out = 0 ;
+      while ( parcours4 && out == 0 )
+      {
+         if ( !strcasecmp(parcours3->n_name,parcours4->var->v_nomvar) )
+         {
+            Add_SubroutineWhereAgrifUsed_1(parcours4->var->v_subroutinename,
+                                           parcours4->var->v_modulename);
+            out = 1;
+         }
+         else parcours4 = parcours4 -> suiv ;
+      }
+      parcours3 = parcours3 -> suiv;
+   }
+   /*                                                                         */
+   parcours4 = List_UsedInSubroutine_Var;
+   while ( parcours4 )
+   {
+      if ( parcours4->var->v_allocatable == 1 && strcasecmp(parcours4->var->v_typevar,"type"))
+      {
+         Add_SubroutineWhereAgrifUsed_1(parcours4->var->v_subroutinename,
+                                        parcours4->var->v_modulename);
+      }
+      parcours4 = parcours4 -> suiv ;
+   }
+   /*                                                                         */
+   parcours = List_SubroutineWhereAgrifUsed;
+   while ( parcours )
+   {
+      parcours1 = List_NameOfModuleUsed;
+      out = 0 ;
+      strcpy(name_module,"");
+      while ( parcours1 && out == 0 )
+      {
+         if ( !strcasecmp(parcours->o_nom,parcours1->u_cursubroutine) &&
+              !strcasecmp(parcours1->u_usemodule,"Agrif_Util")
+            ) out = 1;
+         else
+         {
+            if ( !strcasecmp(parcours->o_nom,parcours1->u_cursubroutine) )
+            {
+               strcpy(name_module,parcours->o_module);
+            }
+            parcours1 = parcours1->suiv;
+         }
+      }
+      /* if out == 0 we should look in the module declaration                 */
+      if ( out == 0 )
+      {
+         parcours1 = List_NameOfModuleUsed;
+         out = 0 ;
+         while ( parcours1 && out == 0 )
+         {
+            if ( !strcasecmp(name_module,parcours1->u_modulename) &&
+                 !strcasecmp(parcours1->u_cursubroutine,"")&&
+                 !strcasecmp(parcours1->u_usemodule,"Agrif_Util")
+               ) out = 1;
+            else parcours1 = parcours1->suiv;
+         }
+      }
+      if ( out == 0 ) parcours->o_val = 1;
+      /*                                                                      */
+      parcours = parcours->suiv;
+   }
+}
+
+
+void UpdateList_UsedInSubroutine_With_dimension()
+{
+   listvar *parcours;
+
+   parcours = List_UsedInSubroutine_Var;
+   while ( parcours )
+   {
+      if ( parcours->var->v_nbdim != 0 )
+      {
+         strcpy(subroutinename,parcours->var->v_subroutinename);
+         DecomposeTheName(parcours->var->v_readedlistdimension);
+         strcpy(subroutinename,"");
+      }
+      parcours = parcours -> suiv;
+   }
+}
+
+void Affiche()
+{
+   listvar *parcours;
+
+   parcours = (listvar *)NULL;
+/*   parcours = List_Global_Var;                  */
+/*   parcours = List_SubroutineDeclaration_Var;   */
+
+/*   parcours = List_SubroutineArgument_Var;      */
+/*   parcours = List_FunctionType_Var;            */
+
+/*   parcours = List_Data_Var;                    */
+/*   parcours = List_Save_Var;                    */
+/*   parcours = List_UsedInSubroutine_Var;        */
+/*   parcours = List_Parameter_Var;               */
+/*   parcours = List_GlobalParameter_Var;         */
+/*   parcours = List_NotGridDepend_Var;           */
+
+/*   parcours = List_Common_Var;                  */
+
+   while( parcours )
+   {
+      printf("module- %s \n",parcours->var->v_modulename);
+      printf("subroutine- %s  \n",parcours->var->v_subroutinename);
+      printf("nom- %s  \n",parcours->var->v_nomvar);
+      printf("common- %s  \n",parcours->var->v_commonname);
+      printf("type- %s  \n",parcours->var->v_typevar);
+      printf("indice- %d  \n",parcours->var->v_indicetabvars);
+      printf("variableisparameter- %d \n",parcours->var->v_VariableIsParameter);
+      printf("module1- %d  \n",parcours->var->v_module);
+      printf("save- %d  \n",parcours->var->v_save);
+      printf("notgrid- %d  \n",parcours->var->v_notgrid);
+      printf("nbdim- %d  \n",parcours->var->v_nbdim);
+      printf("common1- %d  \n",parcours->var->v_common);
+      printf("v_dimensiongiven- %d  \n",parcours->var->v_dimensiongiven);
+      printf("v_dimsempty- %d  \n",parcours->var->v_dimsempty);
+      printf("initialvalue- %s\n \n",parcours->var->v_initialvalue);
+      printf("dim- %s\n \n",parcours->var->v_readedlistdimension);
+
+      parcours = parcours -> suiv ;
+   }
+   if ( mark == 1 ) printf("Indicemaxtabvars = %d \n",indicemaxtabvars);
+}
+
+
+
+
+int SubInList_ContainsSubroutine()
+{
+   int out;
+   listnom *parcours;
+
+   out = 0 ;
+   parcours = List_ContainsSubroutine;
+   while ( parcours && out == 0 )
+   {
+      if ( !strcasecmp(parcours->o_nom,subroutinename) ) out = 1 ;
+      else parcours = parcours -> suiv;
+   }
+
+   return out;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithvarofsubroutineliste.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithvarofsubroutineliste.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WorkWithvarofsubroutineliste.c	(revision 1844)
@@ -0,0 +1,105 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                      Add_SubroutineArgument_Var_1                          */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should complete the                                                     */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_SubroutineArgument_Var_1(listvar *listtoadd)
+{
+
+   if ( firstpass == 1 )
+   {
+       List_SubroutineArgument_Var = AddListvarToListvar
+                              (listtoadd,List_SubroutineArgument_Var,1);
+   }
+}
+
+/******************************************************************************/
+/*                             Add_FunctionType_Var_1                         */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should complete the                                                     */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_FunctionType_Var_1(char *nom)
+{
+   listvar *newvar;
+
+   if ( firstpass == 1 )
+   {
+      curvar=createvar(nom,NULL);
+      strcpy(curvar->v_typevar,DeclType);
+      newvar = insertvar(NULL,curvar);
+      List_FunctionType_Var = AddListvarToListvar
+                              (newvar,List_FunctionType_Var,1);
+   }
+}
+
+
+/******************************************************************************/
+/*                      Add_SubroutineDeclaration_Var_1                       */
+/******************************************************************************/
+/* Firstpass 1                                                                */
+/* We should complete the listvarofsubroutine                                 */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Add_SubroutineDeclaration_Var_1 (listvar *listtoadd)
+{
+   if ( firstpass == 1 )
+   {
+      if ( VariableIsParameter == 0 &&
+           SaveDeclare         == 0 )
+      {
+         listduplicated = (listvar *)NULL;
+         duplicatelistvar(listtoadd);
+         List_SubroutineDeclaration_Var = AddListvarToListvar
+                              (listduplicated,List_SubroutineDeclaration_Var,1);
+      }
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/WriteInFile.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/WriteInFile.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/WriteInFile.c	(revision 1844)
@@ -0,0 +1,248 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+/******************************************************************************/
+/*                            tofich_reste                                    */
+/******************************************************************************/
+/* This subroutine is used to write the string s into the fileout             */
+/******************************************************************************/
+void tofich_reste (FILE * filout, char *s,int returnlineornot)
+{
+  char temp[61];
+  char *tmp;
+  int size;
+  int val_min;
+
+  if (strlen (s) <= 60)
+    {
+      if ( returnlineornot == 0 ) fprintf (filout, "     &%s", s);
+      else if ( returnlineornot == 2 ) fprintf (filout, "&%s", s);
+      else if ( returnlineornot == 3 ) fprintf (filout, "&%s\n", s);
+      else                             fprintf (filout, "     &%s\n", s);
+      if ( returnlineornot == 0 ||
+           returnlineornot == 2 ) colnum=colnum+strlen(s)+6;
+      else colnum=0;
+    }
+  else
+    {
+      val_min = 60;
+      strncpy (temp, s, 60);
+      strcpy (&temp[60], "\0");
+
+      tmp = strrchr(temp, '+');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '-');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '/');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '*');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '%');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, ',');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, ')');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '(');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+
+      size = val_min;
+
+      strcpy (&temp[60-size], "\0");
+
+      if ( retour77 == 0 ) fprintf (filout, "     &%s&\n", temp);
+      else fprintf (filout, "     &%s\n", temp);
+      colnum=0;
+      tofich_reste (filout, (char *) &s[60-size],returnlineornot);
+    }
+}
+
+/******************************************************************************/
+/*                            tofich                                          */
+/******************************************************************************/
+/* This subroutine is used to write the string s into the fileout             */
+/******************************************************************************/
+void tofich (FILE * filout, char *s, int returnlineornot)
+{
+  char temp[61];
+  char *tmp;
+  int size;
+  int val_min;
+
+  if (strlen (s) <= 60)
+    {
+      if ( returnlineornot == 0 ) fprintf (filout, "      %s", s);
+      else if ( returnlineornot == 2 ) fprintf (filout, "%s", s);
+      else if ( returnlineornot == 3 ) fprintf (filout, "%s\n", s);
+      else                             fprintf (filout, "      %s\n", s);
+      if ( returnlineornot == 0 || returnlineornot == 2 )
+                                                      colnum=colnum+strlen(s)+6;
+      else colnum=0;
+    }
+  else
+    {
+      val_min = 60;
+      strncpy (temp, s, 60);
+      strcpy (&temp[60], "\0");
+
+      tmp = strrchr(temp, '+');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '-');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '/');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '*');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '%');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, ',');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, ')');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+      tmp = strrchr(temp, '(');
+      if ( tmp )
+      if ( strlen(tmp) < val_min ) val_min = strlen(tmp);
+
+      size = val_min;
+
+      strcpy (&temp[60-size], "\0");
+
+      if ( retour77 == 0 ) fprintf (filout, "      %s&\n", temp);
+      else fprintf (filout, "      %s\n", temp);
+      colnum=0;
+      tofich_reste (filout, (char *) &s[60-size], returnlineornot);
+    }
+}
+
+/******************************************************************************/
+/*                       tofich_blanc                                         */
+/******************************************************************************/
+/* This subroutine is used to write size blank into the fileout               */
+/******************************************************************************/
+void tofich_blanc (FILE * filout, int size)
+{
+  int i;
+
+  if (size <= 65) fprintf (filout, "%*s\n",size,EmptyChar);
+  else
+  {
+      i=0;
+      do
+      {
+         fprintf (filout, "%*s\n",65,EmptyChar);
+         i = i+1;
+      } while ( i <= size / 65 );
+         fprintf (filout, "%*s\n",size%65,EmptyChar);
+  }
+
+}
+/******************************************************************************/
+/*                       tofich_line                                          */
+/******************************************************************************/
+/* This subroutine is used to write size blank into the fileout               */
+/******************************************************************************/
+void tofich_line (FILE * filout, int size, int long position)
+{
+  int i;
+  int retour;
+
+  if (size <= 65) fprintf (filout, "%*s",size,EmptyChar);
+  else
+  {
+      i=0;
+      do
+      {
+         fprintf (filout, "%*s",65,EmptyChar);
+         i = i+1;
+      } while ( i <= size / 65 );
+         fprintf (filout, "%*s",size%65,EmptyChar);
+  }
+
+   if ( !strstr(motparse1,"\n") ) retour=0;
+   else retour=1;
+
+   fseek(filout,position,SEEK_SET);
+   if (retour == 1 ) fprintf (filout, "\n");
+
+}
+
+
+/******************************************************************************/
+/*                           RemoveWordSET_0                                  */
+/******************************************************************************/
+/* This subroutine is used to remove a sentence in the file filout            */
+/******************************************************************************/
+void RemoveWordSET_0(FILE * filout, long int position, long int sizetoremove)
+{
+   if ( firstpass == 0 && couldaddvariable == 1 )
+   {
+      fseek(filout,position,SEEK_SET);
+      tofich_line(filout,sizetoremove,position);
+   }
+}
+
+
+/******************************************************************************/
+/*                         RemoveWordCUR_0                                    */
+/******************************************************************************/
+/* This subroutine is used to remove a sentence in the file filout            */
+/******************************************************************************/
+void RemoveWordCUR_0(FILE * filout, long int position, long int sizetoremove)
+{
+   if ( firstpass == 0  && couldaddvariable == 1 )
+   {
+      fseek(filout,position,SEEK_CUR);
+      tofich_blanc(filout,sizetoremove);
+   }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/Writedeclarations.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/Writedeclarations.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/Writedeclarations.c	(revision 1844)
@@ -0,0 +1,659 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "decl.h"
+
+/******************************************************************************/
+/*                         WriteBeginDeclaration                              */
+/******************************************************************************/
+/* This subroutine is used to write the begin of a declaration                */
+/* taken in a variable record                                                 */
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*       integer variable ----------->   INTEGER                              */
+/*                                                                            */
+/******************************************************************************/
+void WriteBeginDeclaration(variable *v,char ligne[LONG_4C], int visibility)
+{
+  char tmpligne[LONG_4C];
+
+  if ( !strcasecmp(v->v_typevar,"") )
+  {
+     printf("WARNING : The type of the variable %s \n",v->v_nomvar);
+     printf("          is unknown. CONV should define a type\n");
+  }
+  
+  sprintf (ligne, "%s", v->v_typevar);
+  if ( v->v_c_star == 1 ) strcat(ligne,"*");
+  
+  /* We should give the precision of the variable if it has been given        */
+  if ( strcasecmp(v->v_precision,"") )
+  {
+     sprintf(tmpligne,"(%s)",v->v_precision);
+     Save_Length(tmpligne,49);
+     strcat(ligne,tmpligne);
+  }
+  
+  if (strcasecmp(v->v_dimchar,""))
+  {
+     sprintf(tmpligne,"(%s)",v->v_dimchar);
+     Save_Length(tmpligne,49);
+     strcat(ligne,tmpligne);
+  }
+  
+  if ( strcasecmp(v->v_nameinttypename,"") )
+  {
+     sprintf(tmpligne,"*%s",v->v_nameinttypename);
+     Save_Length(tmpligne,49);
+     strcat(ligne,tmpligne);
+  }
+  if (strcasecmp (v->v_IntentSpec, ""))
+  {
+     sprintf(tmpligne,",INTENT(%s) ",v->v_IntentSpec);
+     Save_Length(tmpligne,49);
+     strcat(ligne,tmpligne);
+  }
+  if ( v->v_VariableIsParameter == 1 ) strcat(ligne, ", PARAMETER");
+  if (visibility == 1)
+  {
+  if ( v->v_PublicDeclare       == 1 ) strcat(ligne, ", PUBLIC");
+  if ( v->v_PrivateDeclare      == 1 ) strcat(ligne, ", PRIVATE");
+  }
+  if ( v->v_ExternalDeclare     == 1 ) strcat(ligne, ", EXTERNAL");
+  if ( v->v_allocatable         == 1 &&
+       v->v_save                == 0 )
+       {strcat(ligne,", ALLOCATABLE");
+       }
+  if ( v->v_optionaldeclare     == 1 ) strcat(ligne,", OPTIONAL");
+  if ( v->v_pointerdeclare      == 1 ) strcat(ligne,", POINTER");
+  Save_Length(ligne,45);
+}
+
+
+/******************************************************************************/
+/*                         WriteScalarDeclaration                             */
+/******************************************************************************/
+/* This subroutine is used to write a scalar declaration                      */
+/* taken in a variable record                                                 */
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*       integer variable ----------->   INTEGER :: VARIABLE                  */
+/*                                                                            */
+/******************************************************************************/
+void WriteScalarDeclaration(variable *v,char ligne[LONG_4C])
+{
+
+  strcat (ligne, " :: ");
+  strcat (ligne, v->v_nomvar);
+  if ( strcasecmp(v->v_vallengspec,"") ) strcat(ligne,v->v_vallengspec);
+  if ( v->v_VariableIsParameter == 1 )
+  {
+     strcat(ligne," = ");
+     strcat(ligne,v->v_initialvalue);
+  }
+  Save_Length(ligne,45);
+}
+
+
+/******************************************************************************/
+/*                         WriteTableDeclaration                              */
+/******************************************************************************/
+/* This subroutine is used to write a Table declaration                       */
+/* taken in a variable record                                                 */
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*  integer variable(nb) ----------->                                         */
+/*                      INTEGER, DIMENSION(1:nb) :: variable                  */
+/*                                                                            */
+/******************************************************************************/
+void WriteTableDeclaration(variable * v,char ligne[LONG_4C],int tmpok)
+{
+  char newname[LONG_4C];
+
+  strcat (ligne, ", Dimension(");
+
+  if ( v->v_dimensiongiven == 1 && tmpok == 1 )
+  {
+                                         strcat(ligne,v->v_readedlistdimension);
+                                         }
+  if ( v->v_dimensiongiven == 1 && tmpok == 0 )
+  {
+     strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                                  (v->v_readedlistdimension,List_Global_Var,0));
+
+     if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension);
+
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                                 (newname,List_Common_Var,0));
+
+     if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); 
+     
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                              (newname,List_ModuleUsed_Var,0));
+        if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension);
+
+     Save_Length(newname,47);
+     strcat(ligne,newname);
+  }
+  strcat (ligne, ")");
+  strcat (ligne, " :: ");
+  strcat (ligne, v->v_nomvar);
+  if ( strcasecmp(vallengspec,"") ) strcat(ligne,v->v_vallengspec);
+
+  if ( v->v_VariableIsParameter == 1 )
+  {
+     strcat(ligne," = ");
+     strcat(ligne,v->v_initialvalue);
+  }
+  Save_Length(ligne,45);
+}
+
+/******************************************************************************/
+/*                        writevardeclaration                                 */
+/******************************************************************************/
+/* This subroutine is used to write the initial declaration in the file       */
+/* fileout of a variable                                                      */
+/*                                                                            */
+/******************************************************************************/
+/*                                                                            */
+/*  integer variable(nb) ----------->                                         */
+/*                      INTEGER, DIMENSION(1:nb),Pointer :: variable          */
+/*                                                                            */
+/******************************************************************************/
+void writevardeclaration (listvar * var_record, FILE *fileout, int value, int visibility)
+{
+  FILE *filecommon;
+  listvar *newvar;
+  variable *v;
+  char ligne[LONG_4C];
+
+  filecommon=fileout;
+  newvar = var_record;
+  
+  if ( newvar->var->v_save == 0 || inmodulemeet == 0 )
+  {
+     v = newvar->var;
+     
+     WriteBeginDeclaration(v,ligne,visibility);
+
+     if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne);
+     else WriteTableDeclaration(v,ligne,value);
+
+     if ( v->v_VariableIsParameter != 1 && strcasecmp(v->v_initialvalue,"") )
+     {
+        strcat(ligne," = ");
+        strcat(ligne,v->v_initialvalue);
+     }
+     
+     tofich (filecommon, ligne,1);
+  }
+  Save_Length(ligne,45);
+  
+}
+
+
+void WriteLocalParamDeclaration()
+{
+   listvar *parcours;
+
+   parcours = List_Parameter_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) )
+      {
+         writevardeclaration(parcours,fortranout,0,1);
+      }
+      parcours = parcours -> suiv;
+   }
+}
+
+void WriteFunctionDeclaration(int value)
+{
+   listvar *parcours;
+
+   parcours = List_FunctionType_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) &&
+            strcasecmp(parcours->var->v_typevar,"")
+         )
+      {
+         writevardeclaration(parcours,fortranout,value,1);
+      }
+      parcours = parcours -> suiv;
+   }
+}
+
+void WriteSubroutineDeclaration(int value)
+{
+   listvar *parcours;
+
+   parcours = List_SubroutineDeclaration_Var;
+   while ( parcours )
+   {
+      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) &&
+           parcours->var->v_save == 0                                  &&
+          (parcours->var->v_allocatable == 0  || !strcasecmp(parcours->var->v_typevar,"type"))      &&
+           parcours->var->v_pointerdeclare == 0                        &&
+           parcours->var->v_VariableIsParameter == 0                   &&
+           parcours->var->v_common == 0
+         )
+      {
+         writevardeclaration(parcours,fortranout,value,1);
+
+      }
+      else if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) &&
+           parcours->var->v_save == 0                                  &&
+           parcours->var->v_VariableIsParameter == 0                   &&
+           parcours->var->v_common == 0
+              )
+      {
+         writevardeclaration(parcours,fortranout,value,1);
+
+      }
+      parcours = parcours -> suiv;
+   }
+}
+
+void WriteArgumentDeclaration_beforecall()
+{
+   int position;
+   listnom *neededparameter;
+   FILE *paramtoamr;
+   listvar *newvar;
+   char ligne[LONG_4C];
+
+   fprintf(fortranout,"#include \"Param_BeforeCall_%s.h\" \n",subroutinename);
+   /*                                                                         */
+   sprintf(ligne,"Param_BeforeCall_%s.h",subroutinename);
+   paramtoamr = associate (ligne);
+   /*                                                                         */
+   neededparameter = (listnom * )NULL;
+   /*                                                                         */
+   position = 1;
+   newvar = List_SubroutineArgument_Var;
+   while ( newvar )
+   {
+      if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
+                       newvar->var->v_positioninblock == position
+         )
+      {
+         position = position + 1;
+
+         writevardeclaration(newvar,fortranout,0,1);
+         neededparameter = writedeclarationintoamr(List_Parameter_Var,
+                   paramtoamr,newvar->var,newvar->var->v_subroutinename,
+                   neededparameter,subroutinename);
+
+         newvar = List_SubroutineArgument_Var;
+      }
+      else newvar = newvar -> suiv;
+   }
+   Save_Length(ligne,45);
+   fclose(paramtoamr);
+}
+
+void WriteArgumentDeclaration_Sort()
+{
+   int position;
+   listvar *newvar;
+
+   /*                                                                         */
+   position = 1;
+   newvar = List_SubroutineArgument_Var;
+   while ( newvar )
+   {
+      if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
+                       newvar->var->v_positioninblock == position
+         )
+      {
+         position = position + 1;
+
+         writevardeclaration(newvar,fortranout,1,1);
+         /*                                                                   */
+         newvar = List_SubroutineArgument_Var;
+      }
+      else newvar = newvar -> suiv;
+   }
+   /*                                                                         */
+   newvar = List_SubroutineArgument_Var;
+   while ( newvar )
+   {
+      if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
+                       newvar->var->v_positioninblock == 0           &&
+                       newvar->var->v_nbdim == 0
+         )
+      {
+
+         writevardeclaration(newvar,fortranout,1,1);
+      }
+      newvar = newvar -> suiv;
+   }
+   /*                                                                         */
+   newvar = List_SubroutineArgument_Var;
+   while ( newvar )
+   {
+      if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
+                       newvar->var->v_positioninblock == 0           &&
+                       newvar->var->v_nbdim != 0
+         )
+      {
+         writevardeclaration(newvar,fortranout,1,1);
+      }
+      newvar = newvar -> suiv;
+   }
+}
+
+/******************************************************************************/
+/*                      writedeclarationintoamr                               */
+/******************************************************************************/
+/* This subroutine is used to write the declaration of parameters needed in   */
+/*    allocation subroutines creates in toamr.c                               */
+/******************************************************************************/
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+listnom *writedeclarationintoamr (listvar * deb_common, FILE *fileout,
+                              variable *var , char commonname[LONG_C],
+                           listnom *neededparameter, char name_common[LONG_C])
+{
+  listvar *newvar;
+  variable *v;
+  char ligne[LONG_4C];
+  int changeval;
+  int out;
+  int writeit;
+  listnom *parcours;
+  listnom *parcoursprec;
+
+  parcoursprec = (listnom * )NULL;
+  /* we should list the needed parameter                                      */
+  if ( !strcasecmp(name_common,commonname) )
+     neededparameter = DecomposeTheNameinlistnom(var->v_readedlistdimension,
+                                                               neededparameter);
+  /*                                                                          */
+  parcours = neededparameter;
+  while (parcours)
+  {
+     newvar = deb_common;
+     out = 0 ;
+     while ( newvar && out == 0 )
+     {
+        if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) )
+        {
+           out=1;
+        /* add the name to the list of needed parameter                       */
+           neededparameter = DecomposeTheNameinlistnom(
+                 newvar->var->v_initialvalue,
+                 neededparameter );
+        }
+        else newvar=newvar->suiv;
+     }
+     parcours=parcours->suiv;
+   }
+  /*                                                                          */
+  parcours = neededparameter;
+  while (parcours)
+  {
+     newvar = deb_common;
+     out = 0 ;
+     while ( newvar && out == 0 )
+     {
+        if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) )
+        {
+           out=1;
+        /* add the name to the list of needed parameter                       */
+           neededparameter = DecomposeTheNameinlistnom(
+                 newvar->var->v_initialvalue,
+                 neededparameter );
+        }
+        else newvar=newvar->suiv;
+     }
+     parcours=parcours->suiv;
+   }
+  /*                                                                          */
+  tofich (fileout, "",1);
+  parcours = neededparameter;
+  while (parcours)
+  {
+     writeit = 0;
+     newvar = deb_common;
+     while ( newvar && writeit == 0 )
+     {
+        if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) &&
+             parcours->o_val == 0 )
+        {
+           writeit=1;
+           parcours->o_val = 1;
+        }
+        else newvar = newvar->suiv;
+     }
+
+     if ( writeit == 1  )
+     {
+        changeval = 0;
+        v = newvar->var;
+        if ( v->v_allocatable == 1 && strcasecmp(v->v_typevar,"type") )
+        {
+           changeval = 1;
+           v->v_allocatable = 0;
+        }
+        WriteBeginDeclaration(v,ligne,1);
+        if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne);
+        else WriteTableDeclaration(v,ligne,1);
+
+        tofich (fileout, ligne,1);
+        if ( changeval == 1 )
+        {
+           v->v_allocatable = 1;
+        }
+     }
+     else
+     {
+        if (  strncasecmp(parcours->o_nom,"mpi_",4) == 0 &&
+              shouldincludempif                     == 1 )
+        {
+           shouldincludempif = 0;
+           fprintf(fileout,"      include \'mpif.h\' \n");
+        }
+     }
+     parcours=parcours->suiv;
+  }
+  Save_Length(ligne,45);
+  return neededparameter;
+}
+
+
+/******************************************************************************/
+/*                       writesub_loopdeclaration_scalar                      */
+/******************************************************************************/
+/* This subroutine is used to write the declaration part of subloop           */
+/*    subroutines                                                             */
+/******************************************************************************/
+/*                                                                            */
+/*  integer variable(nb) ----------->                                         */
+/*                                                                            */
+/*          INTEGER, DIMENSION(1:nb)         :: variable                      */
+/*                                                                            */
+/******************************************************************************/
+void writesub_loopdeclaration_scalar (listvar * deb_common, FILE *fileout)
+{
+  listvar *newvar;
+  variable *v;
+  char ligne[LONG_4C];
+
+  tofich (fileout, "",1);
+  newvar = deb_common;
+  while (newvar)
+  {
+     if ( newvar->var->v_nbdim == 0 &&
+          !strcasecmp(newvar->var->v_subroutinename,subroutinename)  &&
+          (newvar->var->v_allocatable == 0  || !strcasecmp(newvar->var->v_typevar,"type"))      &&
+           newvar->var->v_pointerdeclare == 0
+         )
+     {
+        v = newvar->var;
+
+        WriteBeginDeclaration(v,ligne,1);
+        WriteScalarDeclaration(v,ligne);
+        tofich (fileout, ligne,1);
+     }
+     newvar = newvar->suiv;
+  }
+  Save_Length(ligne,45);
+}
+
+/******************************************************************************/
+/*                       writesub_loopdeclaration_tab                         */
+/******************************************************************************/
+/* This subroutine is used to write the declaration part of subloop           */
+/*    subroutines                                                             */
+/******************************************************************************/
+/*                                                                            */
+/*  integer variable(nb) ----------->                                         */
+/*                                                                            */
+/*          INTEGER, DIMENSION(1:nb)         :: variable                      */
+/*                                                                            */
+/******************************************************************************/
+void writesub_loopdeclaration_tab (listvar * deb_common, FILE *fileout)
+{
+  listvar *newvar;
+  variable *v;
+  char ligne[LONG_4C];
+  int changeval;
+
+  tofich (fileout, "",1);
+  newvar = deb_common;
+  while (newvar)
+  {
+     if ( newvar->var->v_nbdim != 0                                 &&
+          !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
+          (newvar->var->v_allocatable == 0  || !strcasecmp(newvar->var->v_typevar,"type"))      &&
+          newvar->var->v_pointerdeclare == 0
+        )
+     {
+        changeval = 0;
+        v = newvar->var;
+        if ( v->v_allocatable == 1)
+        {
+          if (strcasecmp(v->v_typevar,"type"))
+           {
+           changeval = 1;
+           v->v_allocatable = 0;
+           }
+          else
+           {
+           changeval = 2;
+           v->v_allocatable = 0;
+           v->v_pointerdeclare = 1;
+           }
+        }
+
+        WriteBeginDeclaration(v,ligne,1);
+        WriteTableDeclaration(v,ligne,1);
+        tofich (fileout, ligne,1);
+        if ( changeval >= 1 ) v->v_allocatable = 1;
+        if ( changeval == 2 ) v->v_pointerdeclare = 0;
+     }
+     newvar = newvar->suiv;
+  }
+  Save_Length(ligne,45);
+}
+
+
+void ReWriteDeclarationAndAddTosubroutine_01(listvar *listdecl)
+{
+listvar *parcours;
+listvar *parcours2;
+listvar *parcours3;
+int out;
+
+if (insubroutinedeclare == 1)
+{
+parcours = listdecl;
+while (parcours)
+{
+/*
+parcours2 = List_SubroutineArgument_Var;
+out = 0;
+while (parcours2 && out == 0)
+{
+if (!strcasecmp(parcours2->var->v_subroutinename,subroutinename) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar))
+ {
+ out = 1;
+ }
+parcours2 = parcours2->suiv;
+}
+*/
+out = LookingForVariableInList(List_SubroutineArgument_Var,parcours->var);
+if (out == 0) out = VariableIsInListCommon(parcours,List_Common_Var);
+if (out == 0) out = LookingForVariableInList(List_Parameter_Var,parcours->var);
+if (out == 0) out = LookingForVariableInList(List_FunctionType_Var,parcours->var);
+
+/*
+parcours2 = List_Common_Var;
+while (parcours2 && out == 0)
+{
+if (!strcasecmp(parcours2->var->v_commoninfile,mainfile) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar))
+ {
+ out = 1;
+ }
+parcours2 = parcours2->suiv;
+}
+*/
+//printf("nom = %s %d %d %d\n",parcours->var->v_nomvar,out,VariableIsParameter,SaveDeclare);
+if (firstpass == 0 && out == 0 && VariableIsParameter == 0 && SaveDeclare == 0) 
+
+{
+writevardeclaration(parcours,fortranout,1,1);
+}
+//if (firstpass == 1 && out == 1)
+if (firstpass == 1)
+  {
+  if (VariableIsParameter == 0 && SaveDeclare == 0)
+    {
+    List_SubroutineDeclaration_Var = insertvar(List_SubroutineDeclaration_Var,parcours->var);
+    }
+  }
+parcours = parcours->suiv;
+}
+}
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/convert.lex
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/convert.lex	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/convert.lex	(revision 1844)
@@ -0,0 +1,87 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+%s character
+%{
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+int line_num=1;
+extern FILE * yyin;
+#define MAX_INCLUDE_DEPTH 30
+YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+%}
+
+COMMENT "%"
+SEPARATEUR "::"
+NIMPORTEQUOI .
+COMMENTAIRES1 {COMMENT}{NIMPORTEQUOI}*{COMMENT}
+PROBTYPE "1D"|"2D"|"3D"
+USEITEM "FIXED_GRIDS"|"ONLY_FIXED_GRIDS"|"F77"
+NAME [a-zA-Z\_][a-zA-Z0-9\_]*
+DIGIT [0-9]+
+NEXTLINE \n+[ \t]+"$"|\n+[ \t]+"&"
+%%
+parammodule return TOK_MODULEMAIN; /* name of the module                      */
+notgriddep  return TOK_NOTGRIDDEP; /* variable which are not grid dependent   */
+use         return TOK_USE;
+{COMMENTAIRES1}    {}
+{SEPARATEUR}        return TOK_SEP;
+{USEITEM}          {strcpy(yylval.na,yytext); return TOK_USEITEM;}
+{PROBTYPE}         {strcpy(yylval.na,yytext); return TOK_PROBTYPE;}
+                                   /* dimension of the problem                */
+{NAME}             {strcpy(yylval.na,yytext); return TOK_NAME;}
+;|\,|\(|\)|:|\[|\] {return (int) *yytext;}
+\n                 {line_num++;return (int) *yytext;}
+[ \t]+ ;
+%%
+
+
+int yywrap()
+{
+}
+
+
+yyerror(char *s)
+{
+if (!strcasecmp(curfile,mainfile))
+{
+   printf("Dans convert %s line %d, fichier %s\n",s,line_num,curfile);
+}
+else
+{
+   printf("Dans convert %s line %d, fichier %s\n",s,line_num,curfile);
+}
+exit(0);
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/convert.y
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/convert.y	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/convert.y	(revision 1844)
@@ -0,0 +1,450 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+%{
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+%}
+
+%union {
+       int ival;
+       char na[LONG_C];
+       listnom * ln;
+       }
+
+%token TOK_SEP
+%token TOK_USE
+%token TOK_MODULEMAIN      /* name of the module                              */
+%token TOK_NOTGRIDDEP      /* Variable which are not grid dependent           */
+%token <na> TOK_USEITEM
+%token <na> TOK_NAME
+%token <na> TOK_PROBTYPE   /* dimension of the problem                        */
+%token ','
+%token ';'
+%token ':'
+%token '('
+%token ')'
+%token '['
+%token ']'
+%%
+input :
+      | input line
+;
+line :'\n'
+      | TOK_PROBTYPE TOK_NAME ';'                   {initdimprob(1,$2,"0","0");}
+      | TOK_PROBTYPE TOK_NAME ',' TOK_NAME ';'      {initdimprob(2,$2, $4,"0");}
+      | TOK_PROBTYPE TOK_NAME ',' TOK_NAME ',' TOK_NAME ';'
+                                                    {initdimprob(3,$2, $4, $6);}
+      | TOK_MODULEMAIN TOK_NAME ';'
+                             {listofmodules = Addtolistnom($2,listofmodules,0);
+                                                        Addmoduletothelist($2);}
+      | TOK_NOTGRIDDEP TOK_SEP TOK_NAME ';'       {Add_NotGridDepend_Var_1($3);}
+      | TOK_USE TOK_USEITEM ';'  {
+                                    if (!strcasecmp($2,"FIXED_GRIDS"))
+                                                                 fixedgrids=1;
+                                    if (!strcasecmp($2,"ONLY_FIXED_GRIDS"))
+                                                             onlyfixedgrids=1;
+                                 }
+      ;
+%%
+
+int main(int argc,char *argv[])
+{
+   extern FILE * yyin ;
+   FILE *dependglobaloutput;
+   int i;
+   listnom *parcours;
+   listvar *newvar;
+   int stylegiven = 0;
+   int infreegiven ;
+   int infixedgiven ;
+   int lengthmainfile;
+
+   if (argc < 2)
+   {
+       printf("usage : conv <file> [-rm] [-incdir <directory>] \n");
+       printf(" [-comdirin   <directory>] [-comdirout <directory>]\n");
+       printf(" [-convfile  <FILENAME >] -SubloopScalar -SubloopScalar1 \n");
+       printf(" [-free|-fixed]\n");
+       exit(0);
+   }
+/******************************************************************************/
+/*  1-  Variables initialization                                              */
+/******************************************************************************/
+   List_Global_Var=(listvar *)NULL;
+   List_GlobalParameter_Var=(listvar *)NULL;
+   List_Allocate_Var=(listallocate *)NULL;
+   List_Common_Var=(listvar *)NULL;
+   List_SubroutineWhereAgrifUsed=(listnom *)NULL;
+   List_Subroutine_For_Alloc=(listnom *)NULL;
+   List_Include=(listusemodule *)NULL;
+   List_NameOfModuleUsed=(listusemodule *)NULL;
+   listofmoduletmp=(listusemodule *)NULL;
+   List_SubroutineDeclaration_Var=(listvar *)NULL;
+   List_UsedInSubroutine_Var=(listvar *)NULL;
+   List_NotGridDepend_Var=(listvar *)NULL;
+   Listofavailableindices=(listindice *)NULL;
+   List_CouplePointed_Var=(listvarpointtovar *)NULL;
+   List_ModuleUsed_Var = (listvar *)NULL;
+   List_ModuleUsedInModuleUsed_Var = (listvar *)NULL;
+   List_GlobParamModuleUsed_Var = (listparameter *)NULL;
+   List_GlobParamModuleUsedInModuleUsed_Var = (listparameter *)NULL;
+   List_SubroutineArgument_Var = (listvar *)NULL;
+   List_FunctionType_Var = (listvar *)NULL;
+   tmpuselocallist = (listusemodule *)NULL;
+   List_ContainsSubroutine = (listnom *)NULL;
+   oldfortranout = (FILE *)NULL;
+
+   strcpy(mainfile,argv[1]);
+   strcpy(nomdir,"AGRIF_INC");
+   strcpy(commondirin,".");
+   strcpy(commondirout,".");
+   strcpy(filetoparse," ");
+   strcpy(subofagrifinitgrids,"");
+   strcpy(meetagrifinitgrids,"");
+   strcpy(mpiinitvar,"");
+
+   length_last = 0 ;
+   length_first = 0 ;
+   length_v_typevar = 0 ;
+   length_v_nomvar = 0 ;
+   length_v_dimchar = 0 ;
+   length_v_modulename = 0 ;
+   length_v_commonname = 0 ;
+   length_v_vallengspec = 0 ;
+   length_v_nameinttypename = 0 ;
+   length_v_commoninfile = 0 ;
+   length_v_subroutinename = 0 ;
+   length_v_precision = 0 ;
+   length_v_IntentSpec = 0 ;
+   length_v_initialvalue = 0 ;
+   length_v_readedlistdimension = 0 ;
+   length_u_usemodule = 0 ;
+   length_u_charusemodule = 0 ;
+   length_u_cursubroutine = 0 ;
+   length_u_modulename = 0 ;
+   length_n_name = 0 ;
+   length_c_namevar = 0 ;
+   length_c_namepointedvar = 0 ;
+   length_o_nom = 0 ;
+   length_o_module = 0 ;
+   length_a_nomvar = 0 ;
+   length_a_subroutine = 0 ;
+   length_a_module = 0 ;
+   length_t_usemodule = 0 ;
+   length_t_cursubroutine = 0 ;
+   length_curfilename = 0 ;
+   length_nomfileoutput = 0 ;
+   length_motparse = 0 ;
+   length_mainfile = 0 ;
+   length_nomdir = 0 ;
+   length_commondirout = 0 ;
+   length_commondirin = 0 ;
+   length_filetoparse = 0 ;
+   length_curbuf = 0 ;
+   length_toprintglob = 0 ;
+   length_tmpvargridname = 0 ;
+   length_ligne_Subloop = 0 ;
+   length_lvargridname_toamr = 0 ;
+   length_toprint_utilagrif = 0 ;
+   length_toprinttmp_utilchar = 0 ;
+   length_ligne_writedecl = 0 ;
+   length_newname_toamr = 0 ;
+   length_newname_writedecl = 0 ;
+   length_ligne_toamr = 0 ;
+   length_tmpligne_writedecl = 0 ;
+   value_char_size = 0 ;
+   value_char_size1 = 0 ;
+   value_char_size2 = 0 ;
+   value_char_size3 = 0 ;
+   inallocate = 0;
+   infixed = 1;
+   infree  = 0;
+
+   checkexistcommon=1;
+   todebug=0;
+   onlyfixedgrids=0;
+   fixedgrids=0;
+   InAgrifParentDef = 0;
+   IndicenbmaillesX=0;
+   IndicenbmaillesY=0;
+   IndicenbmaillesZ=0;
+   created_dimensionlist = 1;
+   indicemaxtabvars = 0;   /* current indice in the table tabvars             */
+   SubloopScalar = 0;
+   todebug = 0;
+   todebugfree = 0;
+   retour77 = 1 ;
+   mark = 0 ;
+   shouldincludempif = 0 ;
+   Read_val_max();
+/******************************************************************************/
+/*  2-  Program arguments                                                     */
+/******************************************************************************/
+
+   if ((yyin=fopen(argv[1],"r"))==NULL)
+   {
+      printf("the file %s doesn't exist \n",argv[1]);
+      exit(0);
+   }
+
+   i=2;
+   while (i<argc)
+   {
+      if (!strcasecmp(argv[i],"-incdir"))
+      {
+         strcpy(nomdir,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-comdirin")) /* input directory           */
+      {
+         strcpy(commondirin,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-comdirout")) /* output directory         */
+      {
+         strcpy(commondirout,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-convfile")) /* file to parse             */
+      {
+         strcpy(filetoparse,argv[i+1]);
+         i++;
+         lengthmainfile = strlen(filetoparse);
+         if (!strcasecmp(&filetoparse[lengthmainfile-4],".f90"))
+         {
+         infixed = 0;
+         infree = 1;
+         }
+         else
+         {
+         infixed = 1;
+         infree = 0;
+         }
+      }
+      else if (!strcasecmp(argv[i],"-free")) /* file to parse        */
+      {
+         stylegiven = 1;
+         infreegiven  = 1 ;
+         infixedgiven = 0;
+      }   
+      else if (!strcasecmp(argv[i],"-fixed")) /* file to parse        */
+      {
+         stylegiven = 1;
+         infreegiven  = 0;
+         infixedgiven = 1;
+      }         
+      else if (!strcasecmp(argv[i],"-SubloopScalar")) /* file to parse        */
+      {
+         SubloopScalar = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-SubloopScalar1")) /* file to parse       */
+      {
+         SubloopScalar = 2 ;
+      }
+      else if (!strcasecmp(argv[i],"-todebug")) /* file to parse       */
+      {
+         todebug = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-mark")) /* file to parse       */
+      {
+         mark = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-todebugfree")) /* file to parse       */
+      {
+         todebugfree = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-rm"))
+      {
+         checkexistcommon=0;
+      }
+      else
+      {
+         printf("Unkwon option : %s\n",argv[i]);
+         exit(0);
+      }
+      i++;
+   }
+
+   if (stylegiven == 1) 
+   {
+   infree = infreegiven;
+   infixed = infixedgiven;   
+   }
+   Save_Length(nomdir,34);
+   Save_Length(commondirout,35);
+   Save_Length(commondirin,36);
+   Save_Length(filetoparse,37);
+
+/******************************************************************************/
+/*  3-  Parsing of the  conv file <name>.in                                   */
+/******************************************************************************/
+
+   if ((yyin=fopen(argv[1],"r"))==NULL)
+   {
+       printf("the file %s doesn't exist \n",argv[1]);
+       exit(0);
+   }
+   strcpy(mainfile,argv[1]);
+   Save_Length(mainfile,33);
+
+   if ( strstr(filetoparse,".f90") ||
+        strstr(filetoparse,".F90") ) retour77 = 0;
+
+   yyparse();
+
+/******************************************************************************/
+/*  4-  Preparation of the file parsing                                       */
+/******************************************************************************/
+   if ((yyin=fopen(filetoparse,"r"))==NULL) /* Is the file to parse exist ?   */
+   {
+      printf("the file %s doesn't exist \n",filetoparse);
+      exit(0);
+   }
+   /* mainfile : the name of the file to parse                                */
+   strcpy(mainfile,filetoparse);
+   /*                                                                         */
+   if ((dependglobaloutput=fopen(".dependglobal_agrif","r"))!=NULL)
+   {
+      fscanf(dependglobaloutput,"%d\n",&indicemaxtabvars);
+      fclose(dependglobaloutput);
+   }
+   Readthedependavailablefile();
+   /* Read the .dependnbxnby file which contains indices of nbmaillsX,        */
+   /*    nbmailleY and nbmailleZ                                              */
+   Readthedependnbxnbyfile();
+   Read_Subroutine_For_Alloc();
+/******************************************************************************/
+/*  5-  Parsing of the input file (2 times)                                   */
+/******************************************************************************/
+   /* Record all variable in list                                             */
+   firstpass = 1;
+   processfortran(filetoparse);
+   /*                                                                         */
+   CompleteThelistvarindoloop();
+   /* Read list of module used                                                */
+   RecordUseModulesVariables();
+   /* Read list of module used in module used                                 */
+   RecordUseModulesUseModulesVariables();
+   /* Save variables are considered as globals ones                           */
+   Update_List_Global_Var_From_List_Save_Var();
+   /* Update all lists                                                        */
+   ListUpdate();
+   /*                                                                         */
+   Clean_List_Global_Var();
+   /* Indice tabvars identification                                           */
+   IndiceTabvarsIdentification();
+   /* Update all lists                                                        */
+   ListUpdate();
+   /* The allocation subroutine is necessary ????                             */
+   New_Allocate_Subroutine_Is_Necessary();
+   /* The allocation subroutine is necessary for common list                  */
+   New_Allocate_Subroutine_For_Common_Is_Necessary();
+   /* Sort List_SubroutineArgument_Var                                        */
+   Sort_List_SubroutineArgument_Var();
+   /* Clean all lists                                                         */
+   ListClean();
+   /* Update Indice of List_UsedInSubroutine_Var from module used             */
+   List_UsedInSubroutine_Var_Update_From_Module_Used();
+   /* Update List_SubroutineWhereAgrifUsed                                    */
+   UpdateList_SubroutineWhereAgrifUsed();
+   /* Update List_UsedInSubroutine_Var with v_readedlistdimension             */
+   UpdateList_UsedInSubroutine_With_dimension();;
+   /*                                                                         */
+   ModifyThelistvarindoloop();
+   /*                                                                         */
+   UpdateListDeclarationWithDimensionList();
+   /*                                                                         */
+   GiveTypeOfVariables();
+   Affiche();
+   /* Build new subroutines                                                   */
+   firstpass = 0;
+   processfortran(filetoparse);
+
+   newvar = (listvar *)NULL;
+/*newvar = List_Global_Var; */
+   while ( newvar )
+   {
+      printf("++++ %s %d %s %s %s\n",
+      newvar->var->v_nomvar,
+      newvar->var->v_nbdim,
+      newvar->var->v_subroutinename,
+      newvar->var->v_modulename,
+      newvar->var->v_typevar
+             );
+      newvar = newvar->suiv;
+   }
+/******************************************************************************/
+/*  6-  Write informations in output files                                    */
+/******************************************************************************/
+
+   /* Write the .dependglobal_agrif file which contain the max indice         */
+   /*    of the tabvars table                                                 */
+   dependglobaloutput = fopen(".dependglobal_agrif","w");
+   fprintf(dependglobaloutput,"%d\n",indicemaxtabvars);
+   fclose(dependglobaloutput);
+   /* Write the list of available indice                                      */
+   Writethedependavailablefile();
+   /* Write the .dependnbxnby file which contains indices of nbmaillsX,       */
+   /*    nbmailleY and nbmailleZ                                              */
+   Writethedependnbxnbyfile();
+   /* Write the .depend<namefile> file which contain general informations     */
+   /*    about variable of this file                                          */
+   parcours = List_NameOfModule;
+   while( parcours )
+   {
+      Writethedependlistofmoduleused(parcours->o_nom);
+      WritedependParameterList(parcours->o_nom);
+      Writethedependfile(parcours->o_nom,List_Global_Var);
+      parcours=parcours->suiv;
+   }
+   parcours = List_NameOfCommon;
+   while( parcours )
+   {
+      Writethedependfile(parcours->o_nom,List_Common_Var);
+      parcours=parcours->suiv;
+   }
+   Write_Subroutine_For_Alloc();
+/******************************************************************************/
+/*  7-  Create files in AGRIF_INC directory                                   */
+/******************************************************************************/
+   creefichieramr(NameTamponfile);
+
+   Write_val_max();
+
+   if ( todebug == 1 ) printf("Out of CONV \n");
+   return 0;
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/decl.h
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/decl.h	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/decl.h	(revision 1844)
@@ -0,0 +1,730 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#define LONGNOM 8000
+
+#define LONG_C 3000
+#define LONG_4C 4000
+#define LONG_4M 4000
+#define LONG_40M 40000
+
+/******************************************************************************/
+/*********** Declaration of structures used in conv ***************************/
+/******************************************************************************/
+
+typedef struct
+{
+   char first[LONG_C];
+   char last[LONG_C];
+} typedim ;                /* fortran dimension as 'ndeb:nfin'                */
+
+typedef struct listdim
+{
+   typedim dim;
+   struct listdim *suiv;
+} listdim;                 /* list of the dimensions of a variable            */
+
+typedef struct variable
+{
+   char v_typevar[LONG_C];
+   char v_nomvar[LONG_C] ;
+   char v_oldname[LONG_C] ;
+   char v_dimchar[LONG_C];
+   char v_modulename[LONG_C];
+   char v_commonname[LONG_C];
+   char v_vallengspec[LONG_C];
+   char v_nameinttypename[LONG_C];
+   char v_commoninfile[LONG_C];
+   char v_subroutinename[LONG_C];
+   char v_precision[LONG_C];
+   char v_initialvalue[LONG_4C];
+   char v_IntentSpec[LONG_C];
+   char v_readedlistdimension[LONG_C];
+   int  v_nbdim;
+   int  v_common;
+   int  v_positioninblock;
+   int  v_module;
+   int  v_save;
+   int  v_VariableIsParameter;
+   int  v_PublicDeclare;
+   int  v_PrivateDeclare;
+   int  v_ExternalDeclare;
+   int  v_pointedvar;
+   int  v_notgrid;
+   int  v_dimensiongiven;
+   int  v_c_star;
+   int  v_indicetabvars;
+   int  v_pointerdeclare;
+   int  v_optionaldeclare;
+   int  v_allocatable;
+   int  v_dimsempty;
+   listdim *v_dimension;
+} variable ;               /* type of a variable                              */
+                           /* v_typevar : type (integer, real, ...)           */
+                           /* v_nomvar : name of the variable                 */
+                           /* v_dimension : list of dimensions of the variable*/
+                           /* v_nbdim: 1 if the variable is 1d, etc ...       */
+                           /* precision : Name of the variable which          */
+                           /* determine the precision. example : wp in the    */
+                           /* case where REAL(wp)                             */
+
+typedef struct listvar
+{
+   variable *var ;
+   struct listvar * suiv;
+} listvar ;                /* list of variables                               */
+
+
+typedef struct listusemodule
+{
+   char u_usemodule[LONG_C];
+   char u_charusemodule[LONG_C];
+   char u_cursubroutine[LONG_C];
+   char u_modulename[LONG_C];
+   int  u_firstuse;
+   struct listusemodule * suiv;
+} listusemodule;           /* list of names                                   */
+
+typedef struct listparameter
+{
+   char p_name[LONG_C];
+   char p_modulename[LONG_C];
+   struct listparameter * suiv;
+} listparameter ;           /* list of names                                  */
+
+typedef struct listname
+{
+   char n_name[LONG_C];
+   struct  listname* suiv;
+} listname ;            /* list of names                                  */
+
+typedef struct listcouple
+{
+   char c_namevar[LONG_C];
+   char c_namepointedvar[LONG_C];
+   struct listcouple * suiv;
+} listcouple;              /* list of names                                   */
+
+
+typedef struct listnom
+{
+   char o_nom[LONG_C];
+   char o_module[LONG_C];
+   int  o_val;
+   listcouple *couple;
+   struct listnom * suiv;
+} listnom;                 /* list of names                                   */
+
+
+typedef struct listallocate
+{
+   char a_nomvar[LONG_C];
+   char a_subroutine[LONG_C];
+   char a_module[LONG_C];
+   struct listallocate * suiv;
+} listallocate ;
+
+
+typedef struct listvarpointtovar
+{
+   char t_usemodule[LONG_C];
+   char t_cursubroutine[LONG_C];
+   listcouple *t_couple;
+   struct  listvarpointtovar* suiv;
+}listvarpointtovar ;       /* list of names                                   */
+
+
+typedef struct listindice
+{
+   int i_indice;
+   struct  listindice * suiv;
+} listindice;              /* list of indiced                                 */
+
+ variable *curvar;
+
+ listvar *List_ModuleUsedInModuleUsed_Var;
+ listvar *List_ModuleUsed_Var;
+ listvar *listduplicated;
+
+ listvar *List_GlobalParameter_Var;
+ listvar *List_Global_Var;
+ listvar *List_Data_Var;
+ listvar *List_Save_Var;
+ listvar *List_SubroutineArgument_Var;
+ listvar *List_SubroutineDeclaration_Var;
+ listvar *List_UsedInSubroutine_Var;
+ listvar *List_Parameter_Var;
+ listvar *List_Dimension_Var;
+ listvar *List_FunctionType_Var;
+ listvar *List_NotGridDepend_Var;
+ listvar *List_Common_Var;
+
+
+ listname *List_Pointer_Var;
+ listname *List_ImplicitNoneSubroutine;
+
+ listusemodule *List_NameOfModuleUsed;
+ listusemodule *List_Include;
+ listusemodule *listofmoduletmp;
+ listusemodule *tmpuselocallist;
+
+ listparameter *List_GlobParamModuleUsedInModuleUsed_Var;
+ listparameter *List_GlobParamModuleUsed_Var;
+
+ listnom *List_ContainsSubroutine;
+ listnom *List_Subroutine_For_Alloc;
+ listnom *listofmodules;
+ listnom *List_NameOfModule;
+ listnom *List_NameOfCommon;
+ listnom *List_SubroutineWhereAgrifUsed;
+
+ listallocate *List_Allocate_Var;
+
+ listvarpointtovar *List_CouplePointed_Var;
+                           /*  variables which are pointed to an other one    */
+
+ listindice *Listofavailableindices;
+                           /* List of available indices in the tabvars table  */
+
+ listdim *curdim;
+ listdim *commondim;
+
+/******************************************************************************/
+/****************   *** COMMON Variables ***  *********************************/
+/******************************************************************************/
+
+ int positioninblock;
+ char commonvar[LONG_C];
+ char commonblockname[LONG_C];
+
+/******************************************************************************/
+/****************   *** AGRIF Variables ***   *********************************/
+/******************************************************************************/
+ int inagrifcallargument;
+ int sameagrifargument;
+ int InAgrifParentDef;
+ char sameagrifname[LONG_C];
+/******************************************************************************/
+/****************   *** VAR DEF Variables ***   *******************************/
+/******************************************************************************/
+ int indicemaxtabvars;     /* Number of variables in the model i.e. last      */
+                           /*    indice used in  the tabvars table            */
+ int PublicDeclare;        /* Variable has been declared as PUBLIC */
+ int PrivateDeclare;       /* Variable has been declared as PRIVATE */
+ int ExternalDeclare;      /* Variable has been declared as EXTERNAL */
+ int InitialValueGiven;    /* An initial value has been given */
+ int Allocatabledeclare;
+ int SaveDeclare;
+ int functiondeclarationisdone;
+ int pointerdeclare;
+ int optionaldeclare;
+ int VarType;
+ int VarTypepar;
+ int VariableIsParameter;
+ int dimsgiven;
+ int shouldincludempif;
+ int c_star;
+ char DeclType[LONG_C];
+ char nameinttypename[LONG_C];
+ char nameinttypenameback[LONG_C]; 
+ int GlobalDeclaration;
+ char InitValue[LONG_4C];
+ char IntentSpec[LONG_C];
+ char NamePrecision[LONG_C];
+ char CharacterSize[LONG_C];
+ char curmodulename[LONG_C];
+ char vallengspec[LONG_C];
+ char subroutinename[LONG_C];
+
+/******************************************************************************/
+/****************   *** CONV Variables ***   **********************************/
+/******************************************************************************/
+ int dimprob ;             /* dimension of the problem : 1 for 1D,2 for 2D,   */
+                           /*    3 for 3D                                     */
+ int onlyfixedgrids;       /* = 1 if onlyfixedgrids is true                   */
+ int todebug;
+ int mark;
+ int todebugfree;
+ int fixedgrids;           /* = 1 if fixedgrids is true                       */
+ char nbmaillesX[LONG_C]; /* number of cells in the x direction              */
+ char nbmaillesY[LONG_C]; /* number of cells in the y direction              */
+ char nbmaillesZ[LONG_C]; /* number of cells in the z direction              */
+ int IndicenbmaillesX;
+ int IndicenbmaillesY;
+ int IndicenbmaillesZ;
+
+ int inmodulemeet;
+ int incalldeclare;
+ int aftercontainsdeclare; /* Signale si l'on vient d'un contains ou non */
+ int retour77;
+ int colnum;
+ int callagrifinitgrids;
+ int callmpiinit;
+ int firstpass;
+ int couldaddvariable;
+ int pointedvar;
+ int NbMailleXDefined;
+ int agrif_parentcall;
+ int didvariableadded;
+ int SubloopScalar;        /* = 1 we should put in argument of sub_loop       */
+                           /*    only                                         */
+                           /*    scalar and not table u(1,1,1) in place of u  */
+ int checkexistcommon;
+ int insubroutinedeclare;
+ int inmoduledeclare;
+ int dimsempty;
+ int created_dimensionlist;
+
+ char meetagrifinitgrids[LONG_C];
+ char mpiinitvar[LONG_C];
+ char *NameTamponfile;
+ char toprintglob[LONG_4C];
+ char tmpvargridname[LONG_4C];
+ char EmptyChar[2];        /* An empty char */
+ char curfilename[LONG_C];
+ char nomfileoutput[LONG_C];
+ char curbuf[LONG_40M];
+ char motparse[LONG_4C];
+ char motparse1[LONG_4C];
+ char charusemodule[LONG_C];
+ char subofagrifinitgrids[LONG_C];
+ char curfile[LONG_C];
+ char mainfile[LONG_C];
+ char nomdir[LONG_C];
+ char commondirout[LONG_C];
+ char commondirin[LONG_C];
+ char filetoparse[LONG_C];
+
+ FILE *fortranout;          /* Output File                                    */
+ FILE *fortranin;           /* Input File                                     */
+ FILE *oldfortranout;
+ FILE *subloop;
+ FILE *module_declar;
+ FILE *allocationagrif;
+ FILE *paramout;
+
+ long int pos_cur;         /* current position in the output file             */
+ long int pos_curagrifparent;
+                           /* current position in the output file             */
+ long int pos_curcall;     /* current position in the output file             */
+ long int pos_curuse;      /* current position in the output file             */
+ long int pos_curuseold;   /* current position in the output file             */
+ long int pos_curfunction; /* current position in the output file             */
+ long int pos_cur_decl;    /* current position in the output file             */
+ long int pos_curdata;     /* current position in the output file             */
+ long int pos_curparameter;/* current position in the output file             */
+ long int pos_curcommon;   /* current position in the output file             */
+ long int pos_cursave;     /* current position in the output file             */
+ long int pos_curdimension;/* current position in the output file             */
+ long int pos_curinit;     /* current position in the output file             */
+ long int pos_curinclude;  /* final position of a line in file                */
+ long int pos_end;         /* final position of a line in file                */
+ long int pos_endsubroutine;
+                           /* final position of a line in file                */
+
+/* v_oldname = v_nomvar; */
+/* commonvar = v_nomvar; */
+/* commonblockname = v_commonname;*/
+/* sameagrifname = v_nomvar ; */
+/* DeclType = v_typevar; */
+/* nameinttypename = v_nameinttypename; */
+/* IntentSpec = v_IntentSpec; */
+/* NamePrecision = v_precision; */
+/* CharacterSize = v_dimchar; */
+/* curmodulename = v_modulename; */
+/* vallengspec = v_vallengspec; */
+/* subroutinename = v_subroutinename; */
+/* meetagrifinitgrids = v_subroutinename; */
+/* nbmaillesX = v_nomvar; */
+/* nbmaillesY = v_nomvar; */
+/* nbmaillesZ = v_nomvar; */
+/* mpiinitvar = v_nomvar; */
+/* EmptyChar = 2; */
+/* motparse1 = motparse;*/
+/* charusemodule = p_modulename; */
+/* subofagrifinitgrids = v_subroutinename; */
+/* curfile = mainfile; */
+/* InitValue = v_initialvalue; */
+
+/* p_name;???????? */
+/* p_modulename; ?????????????*/
+
+ int length_last;
+ int length_first;
+ int length_v_typevar;
+ int length_v_nomvar;
+ int length_v_dimchar;
+ int length_v_modulename;
+ int length_v_commonname;
+ int length_v_vallengspec;
+ int length_v_nameinttypename;
+ int length_v_commoninfile;
+ int length_v_subroutinename;
+ int length_v_precision;
+ int length_v_IntentSpec;
+ int length_v_initialvalue;
+ int length_v_readedlistdimension;
+ int length_u_usemodule;
+ int length_u_charusemodule;
+ int length_u_cursubroutine;
+ int length_u_modulename;
+ int length_n_name;
+ int length_c_namevar;
+ int length_c_namepointedvar;
+ int length_o_nom;
+ int length_o_module;
+ int length_a_nomvar;
+ int length_a_subroutine;
+ int length_a_module;
+ int length_t_usemodule;
+ int length_t_cursubroutine;
+ int length_curfilename;
+ int length_nomfileoutput;
+ int length_motparse;
+ int length_mainfile;
+ int length_nomdir;
+ int length_commondirout;
+ int length_commondirin;
+ int length_filetoparse;
+ int length_curbuf;
+ int length_toprintglob;
+ int length_tmpvargridname;
+ int length_ligne_Subloop;
+ int length_lvargridname_toamr;
+ int length_toprint_utilagrif;
+ int length_toprinttmp_utilchar;
+ int length_ligne_writedecl;
+ int length_newname_toamr;
+ int length_newname_writedecl;
+ int length_ligne_toamr;
+ int length_tmpligne_writedecl;
+ int value_char_size;
+ int value_char_size1;
+ int value_char_size2;
+ int value_char_size3;
+
+ 
+ int inallocate;
+ int infixed;
+ int infree;
+/******************************************************************************/
+/*********** Declaration of externals subroutines *****************************/
+/***************************************************** ************************/
+/******************************************************************************/
+/*********** convert.y ********************************************************/
+/******************************************************************************/
+extern int main(int argc,char *argv[]);
+/******************************************************************************/
+/*********** fortran.y ********************************************************/
+/******************************************************************************/
+extern void processfortran(char *fichier_entree);
+/******************************************************************************/
+/*********** dependfile.c *****************************************************/
+/******************************************************************************/
+extern void Writethedependnbxnbyfile();
+extern void Readthedependnbxnbyfile();
+extern void Writethedependlistofmoduleused(char *NameTampon );
+extern void Readthedependlistofmoduleused(char *NameTampon);
+extern void WritedependParameterList(char *NameTampon );
+extern listparameter *ReaddependParameterList(char *NameTampon,
+                                                        listparameter *listout);
+extern void Writethedependfile(char *NameTampon, listvar *input );
+extern listvar *Readthedependfile( char *NameTampon , listvar *listout);
+extern void Write_Subroutine_For_Alloc();
+extern void Read_Subroutine_For_Alloc();
+extern void Writethedependavailablefile();
+extern void Readthedependavailablefile();
+extern int Did_filetoparse_readed(char *NameTampon);
+extern int Did_module_common_treaded(char *NameTampon);
+extern void Write_val_max();
+extern void Read_val_max();
+/******************************************************************************/
+/*********** DiversListe.c ****************************************************/
+/******************************************************************************/
+extern void Add_Common_var_1();
+extern listnom *Addtolistnom(char *nom, listnom *listin,int value);
+extern listname *Addtolistname(char *nom,listname *input);
+extern int ModuleIsDefineInInputFile(char *name);
+extern void Addmoduletothelisttmp(char *name);
+extern void Add_NameOfModule_1(char *nom);
+extern void Add_NameOfCommon_1(char *nom);
+extern void Add_CouplePointed_Var_1(char *namemodule,listcouple *couple);
+extern void Add_Include_1(char *name);
+extern void Add_ImplicitNoneSubroutine_1();
+extern void WriteIncludeDeclaration();
+extern void Add_Save_Var_1 (char *name,listdim *d);
+extern void Add_Save_Var_dcl_1 (listvar *var);
+/******************************************************************************/
+/*********** SubLoopCreation.c ************************************************/
+/******************************************************************************/
+extern void writeheadnewsub_0();
+extern void WriteVariablelist_subloop(FILE *outputfile);
+extern void WriteVariablelist_subloop_Call(FILE *outputfile);
+extern void WriteVariablelist_subloop_Def(FILE *outputfile);
+extern void WriteHeadofSubroutineLoop();
+extern void closeandcallsubloopandincludeit_0(int suborfun);
+extern void closeandcallsubloop_contains_0();
+/******************************************************************************/
+/*********** toamr.c **********************************************************/
+/******************************************************************************/
+extern char *variablenameroottabvars (variable * var);
+extern char *variablenametabvars (variable * var, int iorindice);
+extern char *variablecurgridtabvars (variable * var,int ParentOrCurgrid);
+extern void WARNING_CharSize(variable *var);
+extern char *vargridnametabvars (variable * var,int iorindice);
+extern char *vargridcurgridtabvars (variable * var,int ParentOrCurgrid);
+extern char *vargridcurgridtabvarswithoutAgrif_Gr (variable * var);
+extern char *vargridparam (variable * v, int whichone);
+extern void write_probdimagrif_file();
+extern void write_keysagrif_file();
+extern void write_modtypeagrif_file();
+extern void write_createvarnameagrif_file(variable *v,FILE *createvarname,
+                                                                int *InitEmpty);
+extern void write_Setnumberofcells_file();
+extern void write_Getnumberofcells_file();
+extern void write_initialisationsagrif_file(variable *v,FILE *initproc,
+                                                             int *VarnameEmpty);
+extern void Write_Alloc_Agrif_Files();
+extern int IndiceInlist(int indic, listindice *listin);
+extern void write_allocation_Common_0();
+extern void write_allocation_Global_0();
+extern void creefichieramr (char *NameTampon);
+/******************************************************************************/
+/*********** UtilAgrif.c ******************************************************/
+/******************************************************************************/
+extern int Vartonumber(char *tokname);
+extern int Agrif_in_Tok_NAME(char *tokname);
+extern void ModifyTheVariableName_0(char *ident,int lengthname);
+extern void Add_SubroutineWhereAgrifUsed_1(char *sub,char *mod);
+extern void AddUseAgrifUtil_0(FILE *fileout);
+extern void AddUseAgrifUtilBeforeCall_0(FILE *fileout);
+extern void NotifyAgrifFunction_0(char *ident);
+extern void ModifyTheAgrifFunction_0(char *ident);
+extern void AgriffunctionModify_0(char *ident,int whichone);
+extern void Instanciation_0(char *ident);
+/******************************************************************************/
+/*********** UtilCharacter.c **************************************************/
+/******************************************************************************/
+extern void FindAndChangeNameToTabvars(char name[LONG_C],char toprint[LONG_4C],
+                                             listvar * listtosee, int whichone);
+extern char *ChangeTheInitalvaluebyTabvarsName(char *nom,listvar *listtoread,
+                                                                  int whichone);
+extern int IsVariableReal(char *nom);
+extern void IsVarInUseFile(char *nom);
+extern listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout);
+extern void DecomposeTheName(char *nom);
+extern void convert2lower(char *name);
+extern int convert2int(char *name);
+/******************************************************************************/
+/*********** UtilFile.c *******************************************************/
+/******************************************************************************/
+extern FILE * associate (char *filename);
+extern FILE * associateaplus (char *filename);
+extern long int setposcur();
+extern long int setposcurname(FILE *fileout);
+extern long int setposcurinoldfortranout();
+extern void copyuse_0(char *namemodule);
+extern void copyuseonly_0(char *namemodule);
+/******************************************************************************/
+/*********** UtilFortran.c ****************************************************/
+/******************************************************************************/
+extern void initdimprob(int dimprobmod, char * nx, char * ny,char* nz);
+extern int Variableshouldberemove(char *nom);
+extern int variableisglobal(listvar *curvar, listvar *listin);
+extern int VariableIsInListCommon(listvar *curvar,listvar *listin);
+extern int VariableIsInList(listvar *curvar,listvar *listin);
+extern void variableisglobalinmodule(listcouple *listin, char *module,
+                                                                 FILE *fileout,long int oldposcuruse);
+extern void Remove_Word_Contains_0();
+extern void Remove_Word_end_module_0(int modulenamelength);
+extern void Write_Word_Contains_0();
+extern void Write_Word_end_module_0();
+extern void Add_Subroutine_For_Alloc(char *nom);
+extern void Write_Alloc_Subroutine_0();
+extern void Write_Alloc_Subroutine_For_End_0();
+extern void Write_GlobalParameter_Declaration_0();
+extern void Write_GlobalType_Declaration_0();
+extern void Write_NotGridDepend_Declaration_0();
+extern int IsTabvarsUseInArgument_0();
+extern int ImplicitNoneInSubroutine();
+extern void Add_Pointer_Var_From_List_1(listvar *listin);
+extern void Add_Pointer_Var_1(char *nom);
+extern int varispointer_0(char *ident);
+extern int VariableIsNotFunction(char *ident);
+extern int varistyped_0(char *ident);
+/******************************************************************************/
+/*********** UtilListe.c ******************************************************/
+/******************************************************************************/
+extern void Init_Variable(variable *var);
+extern listvar * AddListvarToListvar(listvar *l,listvar *glob,
+                                                            int ValueFirstpass);
+extern void CreateAndFillin_Curvar(char *type,variable *curvar);
+extern void duplicatelistvar(listvar *orig);
+extern listdim * insertdim(listdim *lin,typedim nom);
+extern void change_dim_char(listdim *lin,listvar * l);
+extern int num_dims(listdim *d);
+extern variable * createvar(char *nom,listdim *d);
+extern listvar * insertvar(listvar *lin,variable *v);
+extern listvar *settype(char *nom,listvar *lin);
+extern void printliste(listvar * lin);
+extern int IsinListe(listvar *lin,char *nom);
+extern listname *Insertname(listname *lin,char *nom);
+extern void printname(listname * lin);
+extern void removeglobfromlist(listname **lin);
+extern void writelistpublic(listname *lin);
+/******************************************************************************/
+/*********** UtilNotGridDep.c *************************************************/
+/******************************************************************************/
+extern void Add_NotGridDepend_Var_1 (char *name);
+extern int VarIsNonGridDepend(char *name);
+/******************************************************************************/
+/*********** WorkWithAllocatelist.c *******************************************/
+/******************************************************************************/
+extern void Add_Allocate_Var_1(char *nom,char *nommodule);
+extern int IsVarAllocatable_0(char *ident);
+extern int varisallocatable_0(char *ident);
+/******************************************************************************/
+/*********** WorkWithglobliste.c **********************************************/
+/******************************************************************************/
+extern void Add_Globliste_1(listvar *listtoadd);
+extern void Add_SubroutineDeclarationSave_Var_1(listvar *listtoadd);
+extern void checkandchangedims(listvar *listsecondpass);
+/******************************************************************************/
+/*********** WorkWithlistdatavariable.c ***************************************/
+/******************************************************************************/
+extern void Add_Data_Var_1 (char *name,char *values);
+/******************************************************************************/
+/*********** WorkWithlistmoduleinfile.c ***************************************/
+/******************************************************************************/
+extern void Save_Length(char *nom, int whichone);
+extern void Save_Length_int(int val, int whichone);
+/******************************************************************************/
+/*********** WorkWithlistofmodulebysubroutine.c *******************************/
+/******************************************************************************/
+extern void RecordUseModulesVariables();
+extern void  RecordUseModulesUseModulesVariables();
+extern void Add_NameOfModuleUsed_1(char *name);
+extern void Addmoduletothelist(char *name);
+extern void WriteUsemoduleDeclaration();
+/******************************************************************************/
+/*********** WorkWithlistvarindoloop.c ****************************************/
+/******************************************************************************/
+extern void Add_UsedInSubroutine_Var_1 (char *ident);
+extern void ajoutevarindoloop_definedimension (char *name);
+extern void  ModifyThelistvarindoloop();
+extern void  CompleteThelistvarindoloop();
+extern void CopyRecord(variable *var1,variable *var2);
+extern void Update_List_Subroutine_Var(listvar *list_to_modify);
+extern void Update_List_Global_Var_From_List_Save_Var();
+extern void Update_List_From_Common_Var(listvar *list_to_modify);
+extern void Update_List_Var(listvar *list_to_modify);
+extern void List_UsedInSubroutine_Var_Update_From_Module_Used();
+extern void Update_NotGridDepend_Var(listvar *list_to_modify);
+extern int LookingForVariableInList(listvar *listin,variable *var);
+extern int LookingForVariableInListGlobal(listvar *listin,variable *var);
+extern int LookingForVariableInListName(listvar *listin,char *var);
+extern int LookingForVariableInListGlob(listvar *listin,variable *var);
+extern int LookingForVariableInListParamGlob(listparameter *listin,
+                                                                 variable *var);
+extern void UpdateListDeclarationWithDimensionList();
+extern void Clean_List_UsedInSubroutine_Var();
+extern void Clean_List_SubroutineDeclaration_Var();
+extern void Clean_List_Global_Var();
+extern void ListClean();
+extern void ListUpdate();
+extern void GiveTypeOfVariables();
+extern void Sort_List_SubroutineArgument_Var();
+extern void IndiceTabvars_Global_Var_Treated(char *nom);
+extern void IndiceTabvars_Global_Var_No_Treated(char *nom);
+extern void UpdateTheRemainingList(listvar *record);
+extern void IndiceTabvars_Common_Var_Treated(char *nom);
+extern void IndiceTabvars_Common_Var_No_Treated(char *nom);
+extern void IndiceTabvarsIdentification();
+extern void New_Allocate_Subroutine_Is_Necessary();
+extern void New_Allocate_Subroutine_For_Common_Is_Necessary();
+extern void NewModule_Creation_0();
+extern void UpdateList_SubroutineWhereAgrifUsed();
+extern void UpdateList_UsedInSubroutine_With_dimension();
+extern void Affiche();
+extern int SubInList_ContainsSubroutine();
+/******************************************************************************/
+/*********** WorkWithParameterlist.c ******************************************/
+/******************************************************************************/
+extern void Add_GlobalParameter_Var_1(listvar *listin);
+extern void Add_Parameter_Var_1(listvar *listin);
+extern void Add_Dimension_Var_1(listvar *listin);
+/******************************************************************************/
+/*********** WorkWithvarofsubroutineliste.c ***********************************/
+/******************************************************************************/
+extern void Add_SubroutineArgument_Var_1(listvar *listtoadd);
+extern void Add_FunctionType_Var_1(char *nom);
+extern void Add_SubroutineDeclaration_Var_1 (listvar *listtoadd);
+/******************************************************************************/
+/*********** Writedeclarations.c **********************************************/
+/******************************************************************************/
+extern void WriteBeginDeclaration(variable *v,char ligne[LONG_4C],int visibility);
+extern void WriteScalarDeclaration(variable *v,char ligne[LONG_4C]);
+extern void WriteTableDeclaration(variable * v,char ligne[LONG_4C],int tmpok);
+extern void writevardeclaration (listvar * var_record, FILE *fileout,
+                                                                     int value,int visibility);
+extern void WriteLocalParamDeclaration();
+extern void WriteFunctionDeclaration(int value);
+extern void WriteSubroutineDeclaration(int value);
+extern void WriteArgumentDeclaration_beforecall();
+extern void WriteArgumentDeclaration_Sort();
+extern listnom *writedeclarationintoamr (listvar * deb_common, FILE *fileout,
+                                       variable *var , char commonname[LONG_C],
+                           listnom *neededparameter, char name_common[LONG_C]);
+extern void writesub_loopdeclaration_scalar (listvar * deb_common,
+                                                                 FILE *fileout);
+extern void writesub_loopdeclaration_tab (listvar * deb_common, FILE *fileout);
+extern void ReWriteDeclarationAndAddTosubroutine_01(listvar *listdecl);
+/******************************************************************************/
+/*********** WriteInFile.c ****************************************************/
+/******************************************************************************/
+extern void tofich_reste (FILE * filout, char *s,int returnlineornot);
+extern void tofich (FILE * filout, char *s, int returnlineornot);
+extern void tofich_blanc (FILE * filout, int size);
+extern void tofich_line (FILE * filout, int size, int long position);
+extern void RemoveWordSET_0(FILE * filout, long int position,
+                                                         long int sizetoremove);
+extern void RemoveWordCUR_0(FILE * filout, long int position,
+                                                         long int sizetoremove);
+
+/******************************************************************************/
+/*********** WorkWithlistofcoupled.c **********************************************/
+/******************************************************************************/                                                        
+extern int variscoupled_0(char *ident) ;
+extern char * getcoupledname_0(char *ident);
+extern void ModifyTheVariableNamecoupled_0(char *ident, char* coupledident);
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/dependfile.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/dependfile.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/dependfile.c	(revision 1844)
@@ -0,0 +1,1116 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "decl.h"
+
+
+/******************************************************************************/
+/*            Creation and modification of .dependfile                        */
+/******************************************************************************/
+/*  .dependnbxnby            : this file contains tabvars indices of variables*/
+/*                                given in agrif.in as number of cells        */
+/*  .dependuse<module>       : this file contains all modules used in the     */
+/*                                current file                                */
+/*  .dependparameter<module> : this file contains all parmeters defined in    */
+/*                                the current file                            */
+/*  .depend<module name>     : this file contains all globals variables       */
+/*                                informations (name, dim, etc ...)           */
+/*  .dependavailable         : this file contains all tabvars indices which   */
+/*                                are not used.                               */
+/******************************************************************************/
+
+
+/******************************************************************************/
+/*                 Writethedependnbxnbyfile                                   */
+/******************************************************************************/
+/* This subroutine is used to create the .dependnbxnby                        */
+/******************************************************************************/
+/*                                                                            */
+/*                     .dependnbxnby                                          */
+/*                                                                            */
+/*                     nbmaillesX                                             */
+/*                     nbmaillesY                                             */
+/*                     nbmaillesZ                                             */
+/*                                                                            */
+/******************************************************************************/
+void Writethedependnbxnbyfile()
+{
+  FILE *dependfileoutput;
+  listvar *parcours;
+  int out;
+
+  /* We are looking for all the variable of the current filetoparse file      */
+  /*    in the List_Global_Var                                                */
+  parcours =List_Global_Var;
+  out = 0;
+  while (parcours && out == 0 )
+  {
+     if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
+     else parcours = parcours->suiv;
+  }
+  if ( out == 0 )
+  {
+     parcours =List_Common_Var;
+     while (parcours && out == 0 )
+     {
+        if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
+        else parcours = parcours->suiv;
+     }
+  }
+  NbMailleXDefined = 0;
+  if ( out == 1 )
+  {
+     NbMailleXDefined = 1;
+     dependfileoutput = fopen(".dependnbxnby","w");
+     fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
+     IndicenbmaillesX = parcours->var->v_indicetabvars;
+
+     if ( dimprob > 1 )
+     {
+        parcours =List_Global_Var;
+        out = 0;
+        while (parcours && out == 0 )
+        {
+           if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
+           else parcours = parcours->suiv;
+        }
+        if ( out == 0 )
+        {
+           parcours =List_Common_Var;
+           while (parcours && out == 0 )
+           {
+              if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
+              else parcours = parcours->suiv;
+           }
+        }
+        if ( out == 1 )
+        {
+           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
+           IndicenbmaillesY = parcours->var->v_indicetabvars;
+        }
+     }
+
+     if ( dimprob > 2 )
+     {
+        parcours =List_Global_Var;
+        out = 0;
+        while (parcours && out == 0 )
+        {
+           if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
+           else parcours = parcours->suiv;
+        }
+        if ( out == 0 )
+        {
+           parcours =List_Common_Var;
+           while (parcours && out == 0 )
+           {
+              if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
+              else parcours = parcours->suiv;
+           }
+        }
+        if ( out == 1 )
+        {
+           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
+           IndicenbmaillesZ = parcours->var->v_indicetabvars;
+        }
+     }
+
+     if ( out == 1 ) fclose(dependfileoutput);
+   }
+}
+
+/******************************************************************************/
+/*                 Readthedependnbxnbyfile                                    */
+/******************************************************************************/
+/* This subroutine is used to create the .dependnbxnby                        */
+/******************************************************************************/
+/*                                                                            */
+/*                     .dependnbxnby                                          */
+/*                                                                            */
+/*                     nbmaillesX                                             */
+/*                     nbmaillesY                                             */
+/*                     nbmaillesZ                                             */
+/*                                                                            */
+/******************************************************************************/
+void Readthedependnbxnbyfile()
+{
+  FILE *dependfileoutput;
+
+  if ((dependfileoutput = fopen(".dependnbxnby","r"))!=NULL)
+  {
+     fscanf(dependfileoutput,"%d\n",&IndicenbmaillesX);
+     if ( dimprob > 1 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesY);
+     if ( dimprob > 2 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesZ);
+     fclose(dependfileoutput);
+  }
+}
+
+/******************************************************************************/
+/*                     Writethedependlistofmoduleused                         */
+/******************************************************************************/
+/* This subroutine is used to create the .dependuse<module>                   */
+/******************************************************************************/
+/*                                                                            */
+/*               .dependuse<name>                                             */
+/*                                                                            */
+/*               mod1                                                         */
+/*               mod2                                                         */
+/*                                                                            */
+/******************************************************************************/
+void Writethedependlistofmoduleused(char *NameTampon )
+{
+  FILE *dependfileoutput;
+  listusemodule *parcours;
+  char ligne[LONG_C];
+
+
+  if ( List_NameOfModuleUsed )
+  {
+     convert2lower(NameTampon);
+     sprintf(ligne,".dependuse%s",NameTampon);
+     dependfileoutput = fopen(ligne,"w");
+     /*                                                                       */
+     parcours = List_NameOfModuleUsed;
+     while (parcours)
+     {
+        if ( !strcasecmp(NameTampon,parcours->u_modulename) &&
+             !strcasecmp(parcours->u_cursubroutine,"")
+           )
+        {
+           /* We are looking for all the variable of the current              */
+           /*    filetoparse file in the List_Global_Var                      */
+           fprintf(dependfileoutput,"%s\n",parcours->u_usemodule);
+        }
+        parcours = parcours->suiv;
+     }
+     fclose(dependfileoutput);
+  }
+}
+
+/******************************************************************************/
+/*                    Readthedependlistofmoduleused                           */
+/******************************************************************************/
+/* This subroutine is used to create the .dependuse<module>                   */
+/******************************************************************************/
+/*                                                                            */
+/*               .dependuse<name>                                             */
+/*                                                                            */
+/*               mod1                                                         */
+/*               mod2                                                         */
+/*                                                                            */
+/******************************************************************************/
+void Readthedependlistofmoduleused(char *NameTampon)
+{
+  FILE *dependfileoutput;
+  listusemodule *parcours;
+  char ligne[LONG_C];
+
+  convert2lower(NameTampon);
+  sprintf(ligne,".dependuse%s",NameTampon);
+
+  tmpuselocallist = (listusemodule *)NULL;
+  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
+  {
+  }
+  else
+  {
+    /* if the file exist we should verify that this file has changed          */
+      while (!feof(dependfileoutput))
+      {
+         parcours=(listusemodule *)malloc(sizeof(listusemodule));
+         fscanf(dependfileoutput,"%s\n",parcours->u_usemodule);
+
+         parcours->suiv = tmpuselocallist;
+         tmpuselocallist = parcours;
+
+         parcours = NULL;
+      }
+      fclose(dependfileoutput);
+  }
+}
+
+
+/******************************************************************************/
+/*                        WritedependParameterList                            */
+/******************************************************************************/
+/* This subroutine is used to create the .dependparameter<name>               */
+/******************************************************************************/
+/*                                                                            */
+/*               .dependparameter<name>                                       */
+/*                                                                            */
+/*               mod1                                                         */
+/*               mod2                                                         */
+/*                                                                            */
+/******************************************************************************/
+void WritedependParameterList(char *NameTampon )
+{
+  FILE *dependfileoutput;
+  listvar *parcours;
+  char ligne[LONG_C];
+
+  if ( List_GlobalParameter_Var )
+  {
+     convert2lower(NameTampon);
+     sprintf(ligne,".dependparameter%s",NameTampon);
+     dependfileoutput = fopen(ligne,"w");
+     /*                                                                       */
+     parcours = List_GlobalParameter_Var;
+     while (parcours)
+     {
+        if ( !strcasecmp(NameTampon,parcours->var->v_modulename) )
+        {
+           fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
+           fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename);
+        }
+        parcours = parcours->suiv;
+     }
+     fclose(dependfileoutput);
+  }
+}
+
+
+/******************************************************************************/
+/*                         ReaddependParameterList                            */
+/******************************************************************************/
+/* This subroutine is used to create the .dependparameter<name>               */
+/******************************************************************************/
+/*                                                                            */
+/*               .dependparameter<name>                                       */
+/*                                                                            */
+/*               mod1                                                         */
+/*               mod2                                                         */
+/*                                                                            */
+/******************************************************************************/
+listparameter *ReaddependParameterList(char *NameTampon,listparameter *listout)
+{
+  FILE *dependfileoutput;
+  listparameter *parcours;
+  char ligne[LONG_C];
+
+  convert2lower(NameTampon);
+  sprintf(ligne,".dependparameter%s",NameTampon);
+
+  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
+  {
+  }
+  else
+  {
+    /* if the file exist we should verify that this file has changed          */
+      while (!feof(dependfileoutput))
+      {
+         parcours=(listparameter *)malloc(sizeof(listparameter));
+         fscanf(dependfileoutput,"%s\n",parcours->p_name);
+         fscanf(dependfileoutput,"%s\n",parcours->p_modulename);
+
+         parcours->suiv = listout;
+         listout = parcours;
+
+         parcours = NULL;
+      }
+      fclose(dependfileoutput);
+  }
+  return listout;
+}
+
+/******************************************************************************/
+/*                   Writethedependfile                                       */
+/******************************************************************************/
+/* This subroutine is used to create the .depend<name>                        */
+/******************************************************************************/
+/*                                                                            */
+/*                     .depend<name>                                          */
+/*                                                                            */
+/*                      REAL                                                  */
+/*                      Variable                                              */
+/*                      char dimension or T                                   */
+/*                      table dimension                                       */
+/*                      is type given                                         */
+/*                      precision or T                                        */
+/*                      initial value or T                                    */
+/*                      indice in the tabvars                                 */
+/*                      listdimension or T                                    */
+/*                      -------------------------                             */
+/*                                                                            */
+/******************************************************************************/
+void Writethedependfile(char *NameTampon, listvar *input )
+{
+  FILE *dependfileoutput;
+  listvar *parcours;
+  listdim *dims;
+  char ligne[LONG_C];
+  char listdimension[LONG_C];
+  char curname[LONG_C];
+  int out;
+
+  if ( input )
+  {
+  convert2lower(NameTampon);
+
+  sprintf(ligne,".depend%s",NameTampon);
+  dependfileoutput = fopen(ligne,"w");
+  /* We are looking for all the variable of the current filetoparse file      */
+  /*    in the input                                                          */
+  parcours =input;
+  out = 0;
+  strcpy(curname,"");
+  while (parcours && out == 0 )
+  {
+     if ( !strcasecmp(parcours->var->v_modulename,NameTampon) ||
+          !strcasecmp(parcours->var->v_commonname,NameTampon) )
+     {
+        /*                                                                    */
+        if (  strcasecmp(curname,"") &&
+             !strcasecmp(curname,parcours->var->v_nomvar) ) out = 1 ;
+        if ( !strcasecmp(curname,"") ) strcpy(curname,parcours->var->v_nomvar);
+        /*                                                                    */
+        if ( out == 0 )
+        {
+           /********** TYPEVAR ************************************************/
+           fprintf(dependfileoutput,"%s\n",parcours->var->v_typevar);
+           /********** NOMVAR *************************************************/
+           fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
+           /********** DIMCHAR ************************************************/
+           if ( strcasecmp(parcours->var->v_dimchar,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /********** COMMONINFILE *******************************************/
+           if ( strcasecmp(parcours->var->v_commoninfile,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /********** COMMONNAME *********************************************/
+           if ( strcasecmp(parcours->var->v_commonname,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_commonname);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /********** NBDIM **************************************************/
+/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_nbdim);*/
+           /********** DIMENSIONGIVEN *****************************************/
+/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_dimensiongiven);*/
+           /********** ALLOCATABLE ********************************************/
+           fprintf(dependfileoutput,"%d\n",parcours->var->v_allocatable);
+           /********** POINTERDECLARE *****************************************/
+           fprintf(dependfileoutput,"%d\n",parcours->var->v_pointerdeclare);
+           /********** PRECISION **********************************************/
+           if ( strcasecmp(parcours->var->v_precision,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_precision);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /********** INITIALVALUE *******************************************/
+/*           if ( strcasecmp(parcours->var->v_initialvalue,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_initialvalue);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }*/
+           /********** NAMEINTYPENAME *****************************************/
+           if ( strcasecmp(parcours->var->v_nameinttypename,"") )
+           {
+              fprintf(dependfileoutput,"%s\n",parcours->var->v_nameinttypename);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /********** INDICETABVARS ******************************************/
+           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
+           /********** READEDLISTDIMENSION ************************************/
+           if ( parcours->var->v_dimensiongiven == 1 )
+           {
+              dims = parcours->var->v_dimension;
+              strcpy(listdimension,"");
+              while (dims)
+              {
+                 sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
+                 strcat(listdimension,ligne);
+                 if ( dims->suiv )
+                 {
+                    strcat(listdimension,",");
+                 }
+                 dims = dims->suiv;
+              }
+              fprintf(dependfileoutput,"%s\n",listdimension);
+           }
+           else
+           {
+              fprintf(dependfileoutput,"T\n");
+           }
+           /*******************************************************************/
+           fprintf(dependfileoutput,"------------------------\n");
+        }
+     }
+     parcours = parcours->suiv;
+  }
+  fclose(dependfileoutput);
+  }
+}
+
+/******************************************************************************/
+/*                         Readthedependfile                                  */
+/******************************************************************************/
+/* This subroutine is used to read the .dependfile<name> and to insert new    */
+/*    information in the listout list.                                        */
+/******************************************************************************/
+/*                                                                            */
+/*           .dependmodule -------->                      = list of var       */
+/*                                                                            */
+/*        not.dependmodule -------->                                          */
+/*                                                                            */
+/******************************************************************************/
+listvar *Readthedependfile( char *NameTampon , listvar *listout)
+{
+  char ligne[LONG_C];
+  FILE *dependfileoutput;
+  listvar *parcours0;
+  listvar *parcours;
+  listvar *parcoursprec;
+  char nothing[LONG_C];
+  int i;
+
+  parcoursprec = (listvar *)NULL;
+
+  convert2lower(NameTampon);
+  sprintf(ligne,".depend%s",NameTampon);
+  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
+  {
+    /* if the file doesn't exist it means that it is the first time           */
+    /*    we tried to parse this file                                         */
+  }
+  else
+  {
+    /* if the file exist we should verify that this file has changed          */
+      while (!feof(dependfileoutput))
+      {
+         parcours=(listvar *)malloc(sizeof(listvar));
+         parcours->var=(variable *)malloc(sizeof(variable));
+         /*                                                                   */
+         Init_Variable(parcours->var);
+         /*                                                                   */
+           /********** TYPEVAR ************************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_typevar);
+           /********** NOMVAR *************************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
+           /********** DIMCHAR ************************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
+         if ( !strcasecmp(parcours->var->v_dimchar,"T") )
+         {
+            strcpy(parcours->var->v_dimchar,"");
+         }
+           /********** COMMONINFILE *******************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
+         if ( !strcasecmp(parcours->var->v_commoninfile,"T") )
+         {
+            strcpy(parcours->var->v_commoninfile,"");
+         }
+           /********** COMMONNAME *********************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_commonname);
+         if ( !strcasecmp(parcours->var->v_commonname,"T") )
+         {
+            strcpy(parcours->var->v_commonname,"");
+         }
+           /********** NBDIM **************************************************/
+/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_nbdim);*/
+           /********** DIMENSIONGIVEN *****************************************/
+/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_dimensiongiven);*/
+           /********** ALLOCATABLE ********************************************/
+         fscanf(dependfileoutput,"%d\n",&parcours->var->v_allocatable);
+         if ( parcours->var->v_allocatable == 1 )
+         {
+            Add_Allocate_Var_1(parcours->var->v_nomvar,
+                               parcours->var->v_commonname);
+         }
+           /********** POINTERDECLARE *****************************************/
+         fscanf(dependfileoutput,"%d\n",&parcours->var->v_pointerdeclare);
+         if ( parcours->var->v_pointerdeclare == 1 )
+         {
+            Add_Pointer_Var_1(parcours->var->v_nomvar);
+         }
+           /********** PRECISION **********************************************/
+         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_precision);
+         if ( !strcasecmp(parcours->var->v_precision,"T") )
+         {
+            strcpy(parcours->var->v_precision,"");
+         }
+           /********** INITIALVALUE *******************************************/
+/*         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_initialvalue);
+         if ( !strcasecmp(parcours->var->v_initialvalue,"T") )
+         {
+            strcpy(parcours->var->v_initialvalue,"");
+         }*/
+           /********** NAMEINTYPENAME *****************************************/
+         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_nameinttypename);
+         if ( !strcasecmp(parcours->var->v_nameinttypename,"T") )
+         {
+            strcpy(parcours->var->v_nameinttypename,"");
+         }
+           /********** INDICETABVARS ******************************************/
+         fscanf(dependfileoutput,"%d\n",&parcours->var->v_indicetabvars);
+           /********** READEDLISTDIMENSION ************************************/
+         fscanf(dependfileoutput,"%s\n",parcours->var->v_readedlistdimension);
+         if ( !strcasecmp(parcours->var->v_readedlistdimension,"T") )
+         {
+            strcpy(parcours->var->v_readedlistdimension,"");
+         }
+         else
+         {
+            parcours->var->v_dimensiongiven = 1;
+            parcours->var->v_nbdim = 1;
+            i = 1;
+            /*                                                                */
+            while ( i < strlen(parcours->var->v_readedlistdimension) )
+            {
+               if ( parcours->var->v_readedlistdimension[i] == ',' )
+               {
+                  parcours->var->v_nbdim = parcours->var->v_nbdim + 1 ;
+               }
+               /*                                                             */
+               i=i+1;
+            }
+         }
+           /*******************************************************************/
+         fscanf(dependfileoutput,"%s\n",nothing);
+         parcours->suiv = NULL;
+         if ( !listout )
+         {
+            listout = parcours;
+            parcoursprec = parcours;
+         }
+         else
+         {
+            if ( parcoursprec )
+            {
+               parcoursprec->suiv = parcours;
+               parcoursprec = parcours;
+            }
+            else
+            {
+               parcours0 = listout;
+               while ( parcours0->suiv ) parcours0=parcours0->suiv;
+               parcours0->suiv = parcours;
+               parcoursprec = parcours0->suiv;
+            }
+         }
+         parcours = NULL;
+      }
+      fclose(dependfileoutput);
+  }
+  return listout;
+}
+
+void Write_Subroutine_For_Alloc()
+{
+   FILE *dependfileoutput;
+   listnom *parcours;
+
+   if ( List_Subroutine_For_Alloc )
+   {
+      if ((dependfileoutput=fopen(".dependAllocAgrif","w"))!=NULL)
+      {
+         parcours = List_Subroutine_For_Alloc;
+         while (parcours)
+         {
+            fprintf(dependfileoutput,"%s\n",parcours->o_nom);
+            parcours = parcours->suiv;
+         }
+         fclose(dependfileoutput);
+      }
+   }
+}
+
+void Read_Subroutine_For_Alloc()
+{
+  FILE *dependfileoutput;
+  listnom *parcours;
+  listnom *ref;
+
+  ref = (listnom *)NULL;
+  if ((dependfileoutput=fopen(".dependAllocAgrif","r"))!=NULL)
+  {
+     List_Subroutine_For_Alloc = (listnom *)NULL;
+     while (!feof(dependfileoutput))
+     {
+        parcours=(listnom *)malloc(sizeof(listnom));
+        strcpy(parcours->o_nom,"");
+
+        fscanf(dependfileoutput,"%s\n",&parcours->o_nom);
+        parcours->suiv = NULL;
+
+        if ( !List_Subroutine_For_Alloc )
+        {
+           List_Subroutine_For_Alloc = parcours;
+           ref = parcours;
+        }
+        else
+        {
+            ref->suiv = parcours;
+            ref = parcours;
+        }
+     }
+     fclose(dependfileoutput);
+  }
+}
+
+/******************************************************************************/
+/*                        Writethedependavailablefile                         */
+/******************************************************************************/
+/* This subroutine is used to write the .dependfileavailable file             */
+/******************************************************************************/
+/*                                                                            */
+/*                                  .dependavailable                          */
+/*     tabvars(1) = var1                                                      */
+/*     tabvars(3) = var1                  2                                   */
+/*     tabvars(4) = var1         =====>   5                                   */
+/*     tabvars(6) = var1                                                      */
+/*     tabvars(7) = var1                                                      */
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Writethedependavailablefile()
+{
+  FILE *dependfileoutput;
+  listindice *parcours;
+
+  if ((dependfileoutput=fopen(".dependavailable","w"))!=NULL)
+  {
+     /* We are looking for all the indices of the Listofavailableindices      */
+     parcours = Listofavailableindices;
+     while (parcours)
+     {
+        if ( parcours->i_indice != 0 )
+        {
+           fprintf(dependfileoutput,"%d\n",parcours->i_indice);
+        }
+        parcours = parcours->suiv;
+     }
+     fclose(dependfileoutput);
+  }
+}
+
+/******************************************************************************/
+/*                        Readthedependavailablefile                          */
+/******************************************************************************/
+/* This subroutine is used to read the .dependfileavailable file              */
+/******************************************************************************/
+/*                                                                            */
+/*                                  .dependavailable                          */
+/*     tabvars(1) = var1                                                      */
+/*     tabvars(3) = var1                  2                                   */
+/*     tabvars(4) = var1         =====>   5  ==> Listofavailableindices       */
+/*     tabvars(6) = var1                                                      */
+/*     tabvars(7) = var1                                                      */
+/*                                                                            */
+/*                                                                            */
+/*                                                                            */
+/******************************************************************************/
+void Readthedependavailablefile()
+{
+  FILE *dependfileoutput;
+  listindice *parcours;
+
+  if ((dependfileoutput=fopen(".dependavailable","r"))!=NULL)
+  {
+     /* We are looking for all the indices of the Listofavailableindices      */
+     Listofavailableindices = (listindice *)NULL;
+     while (!feof(dependfileoutput))
+     {
+        parcours=(listindice *)malloc(sizeof(listindice));
+        fscanf(dependfileoutput,"%d\n",&parcours->i_indice);
+        if ( parcours->i_indice != 0 && parcours->i_indice < 10000000 )
+        {
+           parcours -> suiv = Listofavailableindices;
+           Listofavailableindices = parcours;
+        }
+        else
+        {
+           free(parcours);
+        }
+     }
+     fclose(dependfileoutput);
+  }
+}
+
+
+/******************************************************************************/
+/*                      Did_filetoparse_readed                                */
+/******************************************************************************/
+/* This subroutine is used to know if the .depend<NameTampon> exist           */
+/*    it means if the file has been ever parsed                               */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int Did_filetoparse_readed(char *NameTampon)
+{
+  FILE *dependfileoutput;
+  char ligne[LONG_C];
+  int out;
+
+  convert2lower(NameTampon);
+  sprintf(ligne,".depend%s",NameTampon);
+  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
+  {
+      out = 0;
+  }
+  else
+  {
+      out = 1;
+      fclose(dependfileoutput);
+  }
+  return out;
+}
+
+
+/******************************************************************************/
+/*                      Did_module_common_treaded                             */
+/******************************************************************************/
+/* This subroutine is used to know if the .depend<NameTampon> exist           */
+/*    it means if the file has been ever parsed                               */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+int Did_module_common_treaded(char *NameTampon)
+{
+  FILE *dependfileoutput;
+  char ligne[LONG_C];
+  int out;
+
+  convert2lower(NameTampon);
+  sprintf(ligne,".depend%s",NameTampon);
+  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
+  {
+      out = 0;
+  }
+  else
+  {
+      out = 1;
+      fclose(dependfileoutput);
+  }
+  return out;
+}
+
+
+
+void Write_val_max()
+{
+  FILE *dependfileoutput;
+
+  if ((dependfileoutput=fopen(".dependvalmax","w"))!=NULL)
+  {
+     fprintf(dependfileoutput,"length_last\n");
+     fprintf(dependfileoutput,"%d\n",length_last);
+     fprintf(dependfileoutput,"length_first\n");
+     fprintf(dependfileoutput,"%d\n",length_first);
+     fprintf(dependfileoutput,"length_v_typevar\n");
+     fprintf(dependfileoutput,"%d\n",length_v_typevar);
+     fprintf(dependfileoutput,"length_v_nomvar\n");
+     fprintf(dependfileoutput,"%d\n",length_v_nomvar);
+     fprintf(dependfileoutput,"length_v_dimchar\n");
+     fprintf(dependfileoutput,"%d\n",length_v_dimchar);
+     fprintf(dependfileoutput,"length_v_modulename\n");
+     fprintf(dependfileoutput,"%d\n",length_v_modulename);
+     fprintf(dependfileoutput,"length_v_commonname\n");
+     fprintf(dependfileoutput,"%d\n",length_v_commonname);
+     fprintf(dependfileoutput,"length_v_vallengspec\n");
+     fprintf(dependfileoutput,"%d\n",length_v_vallengspec);
+     fprintf(dependfileoutput,"length_v_nameinttypename\n");
+     fprintf(dependfileoutput,"%d\n",length_v_nameinttypename);
+     fprintf(dependfileoutput,"length_v_commoninfile\n");
+     fprintf(dependfileoutput,"%d\n",length_v_commoninfile);
+     fprintf(dependfileoutput,"length_v_subroutinename\n");
+     fprintf(dependfileoutput,"%d\n",length_v_subroutinename);
+     fprintf(dependfileoutput,"length_v_precision\n");
+     fprintf(dependfileoutput,"%d\n",length_v_precision);
+     fprintf(dependfileoutput,"length_v_IntentSpec\n");
+     fprintf(dependfileoutput,"%d\n",length_v_IntentSpec);
+     fprintf(dependfileoutput,"length_v_initialvalue\n");
+     fprintf(dependfileoutput,"%d\n",length_v_initialvalue);
+     fprintf(dependfileoutput,"length_v_readedlistdimension\n");
+     fprintf(dependfileoutput,"%d\n",length_v_readedlistdimension);
+     fprintf(dependfileoutput,"length_u_usemodule\n");
+     fprintf(dependfileoutput,"%d\n",length_u_usemodule);
+     fprintf(dependfileoutput,"length_u_charusemodule\n");
+     fprintf(dependfileoutput,"%d\n",length_u_charusemodule);
+     fprintf(dependfileoutput,"length_u_cursubroutine\n");
+     fprintf(dependfileoutput,"%d\n",length_u_cursubroutine);
+     fprintf(dependfileoutput,"length_u_modulename\n");
+     fprintf(dependfileoutput,"%d\n",length_u_modulename);
+     fprintf(dependfileoutput,"length_n_name\n");
+     fprintf(dependfileoutput,"%d\n",length_n_name);
+     fprintf(dependfileoutput,"length_c_namevar\n");
+     fprintf(dependfileoutput,"%d\n",length_c_namevar);
+     fprintf(dependfileoutput,"length_c_namepointedvar\n");
+     fprintf(dependfileoutput,"%d\n",length_c_namepointedvar);
+     fprintf(dependfileoutput,"length_o_nom\n");
+     fprintf(dependfileoutput,"%d\n",length_o_nom);
+     fprintf(dependfileoutput,"length_o_module\n");
+     fprintf(dependfileoutput,"%d\n",length_o_module);
+     fprintf(dependfileoutput,"length_a_nomvar\n");
+     fprintf(dependfileoutput,"%d\n",length_a_nomvar);
+     fprintf(dependfileoutput,"length_a_subroutine\n");
+     fprintf(dependfileoutput,"%d\n",length_a_subroutine);
+     fprintf(dependfileoutput,"length_a_module\n");
+     fprintf(dependfileoutput,"%d\n",length_a_module);
+     fprintf(dependfileoutput,"length_usemodule\n");
+     fprintf(dependfileoutput,"%d\n",length_t_usemodule);
+     fprintf(dependfileoutput,"length_cursubroutine\n");
+     fprintf(dependfileoutput,"%d\n",length_t_cursubroutine);
+     fprintf(dependfileoutput,"length_curfilename\n");
+     fprintf(dependfileoutput,"%d\n",length_curfilename);
+     fprintf(dependfileoutput,"length_nomfileoutput\n");
+     fprintf(dependfileoutput,"%d\n",length_nomfileoutput);
+     fprintf(dependfileoutput,"length_motparse\n");
+     fprintf(dependfileoutput,"%d\n",length_motparse);
+     fprintf(dependfileoutput,"length_mainfile\n");
+     fprintf(dependfileoutput,"%d\n",length_mainfile);
+     fprintf(dependfileoutput,"length_nomdir\n");
+     fprintf(dependfileoutput,"%d\n",length_nomdir);
+     fprintf(dependfileoutput,"length_commondirout\n");
+     fprintf(dependfileoutput,"%d\n",length_commondirout);
+     fprintf(dependfileoutput,"length_commondirin\n");
+     fprintf(dependfileoutput,"%d\n",length_commondirin);
+     fprintf(dependfileoutput,"length_filetoparse\n");
+     fprintf(dependfileoutput,"%d\n",length_filetoparse);
+     fprintf(dependfileoutput,"length_curbuf\n");
+     fprintf(dependfileoutput,"%d\n",length_curbuf);
+     fprintf(dependfileoutput,"length_toprintglob\n");
+     fprintf(dependfileoutput,"%d\n",length_toprintglob);
+     fprintf(dependfileoutput,"Size_char0d\n");
+     fprintf(dependfileoutput,"%d\n",value_char_size);
+     fprintf(dependfileoutput,"Size_char1d\n");
+     fprintf(dependfileoutput,"%d\n",value_char_size1);
+     fprintf(dependfileoutput,"Size_char2d\n");
+     fprintf(dependfileoutput,"%d\n",value_char_size2);
+     fprintf(dependfileoutput,"Size_char3d\n");
+     fprintf(dependfileoutput,"%d\n",value_char_size3);
+     fprintf(dependfileoutput,"length_tmpvargridname\n");
+     fprintf(dependfileoutput,"%d\n",length_tmpvargridname);
+     fprintf(dependfileoutput,"length_ligne_Subloop\n");
+     fprintf(dependfileoutput,"%d\n",length_ligne_Subloop);
+     fprintf(dependfileoutput,"length_lvargridname_toamr\n");
+     fprintf(dependfileoutput,"%d\n",length_lvargridname_toamr);
+     fprintf(dependfileoutput,"length_toprint_toamr\n");
+     fprintf(dependfileoutput,"%d\n",length_toprint_utilagrif);
+     fprintf(dependfileoutput,"length_toprinttmp_utilchar\n");
+     fprintf(dependfileoutput,"%d\n",length_toprinttmp_utilchar);
+     fprintf(dependfileoutput,"length_ligne_writedecl\n");
+     fprintf(dependfileoutput,"%d\n",length_ligne_writedecl);
+     fprintf(dependfileoutput,"length_newname_toamr\n");
+     fprintf(dependfileoutput,"%d\n",length_newname_toamr);
+     fprintf(dependfileoutput,"length_newname_writedecl\n");
+     fprintf(dependfileoutput,"%d\n",length_newname_writedecl);
+     fprintf(dependfileoutput,"length_ligne_toamr\n");
+     fprintf(dependfileoutput,"%d\n",length_ligne_toamr);
+     fprintf(dependfileoutput,"length_tmpligne_writedecl\n");
+     fprintf(dependfileoutput,"%d\n",length_tmpligne_writedecl);
+/*     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);
+     fprintf(dependfileoutput,"\n");
+     fprintf(dependfileoutput,"%d\n",);*/
+
+     fclose(dependfileoutput);
+  }
+}
+
+
+void Read_val_max()
+{
+  char nothing[LONG_C];
+  FILE *dependfileoutput;
+
+  if ((dependfileoutput=fopen(".dependvalmax","r"))!=NULL)
+  {
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_last);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_first);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_typevar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_nomvar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_dimchar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_modulename);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_commonname);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_vallengspec);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_nameinttypename);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_commoninfile);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_subroutinename);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_precision);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_IntentSpec);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_initialvalue);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_v_readedlistdimension);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_u_usemodule);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_u_charusemodule);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_u_cursubroutine);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_u_modulename);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_n_name);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_c_namevar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_c_namepointedvar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_o_nom);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_o_module);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_a_nomvar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_a_subroutine);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_a_module);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_t_usemodule);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_t_cursubroutine);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_curfilename);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_nomfileoutput);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_motparse);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_mainfile);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_nomdir);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_commondirout);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_commondirin);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_filetoparse);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_curbuf);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_toprintglob);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&value_char_size);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&value_char_size1);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&value_char_size2);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&value_char_size3);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_tmpvargridname);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_ligne_Subloop);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_lvargridname_toamr);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_toprint_utilagrif);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_toprinttmp_utilchar);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_ligne_writedecl);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_newname_toamr);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_newname_writedecl);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_ligne_toamr);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&length_tmpligne_writedecl);
+/*     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);
+     fscanf(dependfileoutput,"%s\n",nothing);
+     fscanf(dependfileoutput,"%d\n",&);*/
+
+     fclose(dependfileoutput);
+  }
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.c	(revision 1844)
@@ -0,0 +1,13456 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
+#endif
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define yyclearin (yychar=(-1))
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING (yyerrflag!=0)
+#define yyparse fortranparse
+#define yylex fortranlex
+#define yyerror fortranerror
+#define yychar fortranchar
+#define yyval fortranval
+#define yylval fortranlval
+#define yydebug fortrandebug
+#define yynerrs fortrannerrs
+#define yyerrflag fortranerrflag
+#define yyss fortranss
+#define yyssp fortranssp
+#define yyvs fortranvs
+#define yyvsp fortranvsp
+#define yylhs fortranlhs
+#define yylen fortranlen
+#define yydefred fortrandefred
+#define yydgoto fortrandgoto
+#define yysindex fortransindex
+#define yyrindex fortranrindex
+#define yygindex fortrangindex
+#define yytable fortrantable
+#define yycheck fortrancheck
+#define yyname fortranname
+#define yyrule fortranrule
+#define YYPREFIX "fortran"
+#line 36 "fortran.y"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+extern int line_num_fortran;
+extern int line_num_fortran_common;
+char *tmp;
+char c_selectorname[LONG_C];
+char ligne[LONG_C];
+char truename[LONGNOM];
+char identcopy[LONG_C];
+int c_selectorgiven=0;
+int incom;
+listvar *curlistvar;
+typedim c_selectordim;
+listcouple *coupletmp;
+listdim *parcoursdim;
+int removeline=0;
+listvar *test;
+#line 57 "fortran.y"
+typedef union {
+       char      nac[LONG_C];
+       char      na[LONGNOM];
+       listdim  *d;
+       listvar  *l;
+       listnom  *ln;
+       listcouple  *lc;
+       listname *lnn;
+       typedim   dim1;
+       variable *v;
+       } YYSTYPE;
+#line 68 "y.tab.c"
+#define TOK_BINARY_OP 257
+#define TOK_EQV 258
+#define TOK_NEQV 259
+#define TOK_OR 260
+#define TOK_XOR 261
+#define TOK_AND 262
+#define TOK_NOT 263
+#define TOK_LT 264
+#define TOK_GT 265
+#define TOK_LE 266
+#define TOK_GE 267
+#define TOK_EQ 268
+#define TOK_NE 269
+#define TOK_UNARY_OP 270
+#define TOK_DSLASH 271
+#define TOK_SLASH 272
+#define TOK_DASTER 273
+#define TOK_SEP 274
+#define TOK_SEMICOLON 275
+#define TOK_NEXTLINE 276
+#define TOK_PARAMETER 277
+#define TOK_RESULT 278
+#define TOK_ONLY 279
+#define TOK_INCLUDE 280
+#define TOK_SUBROUTINE 281
+#define TOK_PROGRAM 282
+#define TOK_FUNCTION 283
+#define TOK_OMP 284
+#define TOK_DOLLAR 285
+#define TOK_FORMAT 286
+#define TOK_MAX 287
+#define TOK_TANH 288
+#define TOK_WHERE 289
+#define TOK_ELSEWHERE 290
+#define TOK_ENDWHERE 291
+#define TOK_MAXVAL 292
+#define TOK_TRIM 293
+#define TOK_SUM 294
+#define TOK_SQRT 295
+#define TOK_CASE 296
+#define TOK_SELECTCASE 297
+#define TOK_FILE 298
+#define TOK_END 299
+#define TOK_ERR 300
+#define TOK_DONOTTREAT 301
+#define TOK_ENDDONOTTREAT 302
+#define TOK_EXIST 303
+#define TOK_MIN 304
+#define TOK_FLOAT 305
+#define TOK_EXP 306
+#define TOK_COS 307
+#define TOK_COSH 308
+#define TOK_ACOS 309
+#define TOK_NINT 310
+#define TOK_CYCLE 311
+#define TOK_SIN 312
+#define TOK_SINH 313
+#define TOK_ASIN 314
+#define TOK_EQUIVALENCE 315
+#define TOK_BACKSPACE 316
+#define TOK_LOG 317
+#define TOK_TAN 318
+#define TOK_ATAN 319
+#define TOK_RECURSIVE 320
+#define TOK_ABS 321
+#define TOK_MOD 322
+#define TOK_SIGN 323
+#define TOK_MINLOC 324
+#define TOK_MAXLOC 325
+#define TOK_EXIT 326
+#define TOK_MINVAL 327
+#define TOK_PUBLIC 328
+#define TOK_PRIVATE 329
+#define TOK_ALLOCATABLE 330
+#define TOK_RETURN 331
+#define TOK_THEN 332
+#define TOK_ELSEIF 333
+#define TOK_ELSE 334
+#define TOK_ENDIF 335
+#define TOK_PRINT 336
+#define TOK_PLAINGOTO 337
+#define TOK_CONSTRUCTID 338
+#define TOK_LOGICALIF 339
+#define TOK_PLAINDO 340
+#define TOK_CONTAINS 341
+#define TOK_ENDDO 342
+#define TOK_MODULE 343
+#define TOK_ENDMODULE 344
+#define TOK_DOWHILE 345
+#define TOK_ALLOCATE 346
+#define TOK_OPEN 347
+#define TOK_CLOSE 348
+#define TOK_INQUIRE 349
+#define TOK_WRITE 350
+#define TOK_READ 351
+#define TOK_REWIND 352
+#define TOK_DEALLOCATE 353
+#define TOK_NULLIFY 354
+#define TOK_FIN 355
+#define TOK_DEBUT 356
+#define TOK_DIMENSION 357
+#define TOK_ENDSELECT 358
+#define TOK_EXTERNAL 359
+#define TOK_INTENT 360
+#define TOK_INTRINSIC 361
+#define TOK_NAMELIST 362
+#define TOK_CASEDEFAULT 363
+#define TOK_OPTIONAL 364
+#define TOK_POINTER 365
+#define TOK_CONTINUE 366
+#define TOK_SAVE 367
+#define TOK_TARGET 368
+#define TOK_QUOTE 369
+#define TOK_IMPLICIT 370
+#define TOK_NONE 371
+#define TOK_CALL 372
+#define TOK_STAT 373
+#define TOK_POINT_TO 374
+#define TOK_COMMON 375
+#define TOK_GLOBAL 376
+#define TOK_INTERFACE 377
+#define TOK_ENDINTERFACE 378
+#define TOK_LEFTAB 379
+#define TOK_RIGHTAB 380
+#define TOK_PAUSE 381
+#define TOK_PROCEDURE 382
+#define TOK_STOP 383
+#define TOK_NAMEEQ 384
+#define TOK_REAL8 385
+#define TOK_OUT 386
+#define TOK_INOUT 387
+#define TOK_IN 388
+#define TOK_USE 389
+#define TOK_TRUE 390
+#define TOK_FALSE 391
+#define TOK_LABEL 392
+#define TOK_TYPE 393
+#define TOK_TYPEPAR 394
+#define TOK_ENDTYPE 395
+#define TOK_REAL 396
+#define TOK_INTEGER 397
+#define TOK_LOGICAL 398
+#define TOK_DOUBLEPRECISION 399
+#define TOK_DOUBLEREAL 400
+#define TOK_ENDSUBROUTINE 401
+#define TOK_ENDFUNCTION 402
+#define TOK_ENDPROGRAM 403
+#define TOK_ENDUNIT 404
+#define TOK_CHARACTER 405
+#define TOK_CHAR_CONSTANT 406
+#define TOK_CHAR_CUT 407
+#define TOK_DATA 408
+#define TOK_CHAR_INT 409
+#define TOK_CHAR_MESSAGE 410
+#define TOK_CSTREAL 411
+#define TOK_CSTREALDP 412
+#define TOK_CSTREALQP 413
+#define TOK_SFREAL 414
+#define TOK_COMPLEX 415
+#define TOK_DOUBLECOMPLEX 416
+#define TOK_NAME 417
+#define TOK_NAME_CHAR 418
+#define TOK_PROBTYPE 419
+#define TOK_INTERPTYPE 420
+#define TOK_VARTYPE 421
+#define TOK_BC 422
+#define TOK_OP 423
+#define TOK_CSTINT 424
+#define TOK_COMMENT 425
+#define TOK_FILENAME 426
+#define YYERRCODE 256
+short fortranlhs[] = {                                        -1,
+    0,    0,   68,   68,   68,   68,   68,   71,   71,   76,
+   76,   76,   76,   76,   82,   78,   72,   72,   72,   72,
+   69,   70,   70,   73,   73,   83,   75,   84,   84,   77,
+   77,   77,   77,   77,   77,   16,   74,   80,   33,    6,
+    6,    6,   85,   85,   85,    5,    5,   38,   38,   79,
+   79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+   79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+   86,   86,  103,  103,  103,  103,  103,  103,  103,  103,
+  103,  103,  103,  103,  103,  103,  103,  103,  103,  103,
+  103,  103,  103,  103,  103,  103,   98,   98,   88,   88,
+   99,   99,  105,  106,  106,  104,  104,   87,   87,    2,
+    2,  108,   89,  100,  101,  101,  101,   58,   58,   91,
+   91,   91,   91,  111,  112,  112,  110,  110,  110,   47,
+   47,   47,   47,   47,   32,   32,   97,  113,  113,  113,
+  113,  114,   96,   96,  115,    3,    3,   93,   93,   67,
+   67,   66,   66,   90,   90,   90,  117,  117,  118,  118,
+  119,   15,   15,  109,  109,    4,    4,   14,   95,  120,
+  120,   92,   92,  121,    1,    1,  107,   19,   19,   19,
+   19,  127,  126,  126,  126,  126,  128,  128,  128,  125,
+   25,   24,   24,   24,   24,   24,   24,  116,  116,   65,
+   65,  124,  124,  124,  130,  130,   34,   34,   34,   34,
+   37,   37,  129,  129,  122,  122,  122,  131,  131,  132,
+  132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
+   30,   30,   30,  102,  102,   11,   11,   12,   12,   13,
+   13,   13,   13,   13,   63,   63,   62,   62,   62,   62,
+   61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
+   61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
+   61,   61,   61,   61,   61,   61,   40,   40,   39,   39,
+   39,   39,   39,   39,   31,   31,   64,   64,   64,   64,
+   64,   64,   64,   64,   64,   64,   64,   64,   64,   64,
+   64,   64,   64,   64,   64,   64,   64,   59,   59,   59,
+   59,   60,   60,   41,   41,   41,  133,   49,   49,   49,
+   49,   36,   48,   42,   50,   50,   52,   52,   51,   51,
+   53,   53,   53,   53,   53,   53,   53,   28,   27,   27,
+   27,   27,   27,   27,   27,   27,   26,   26,   26,   26,
+   55,   55,   54,   57,   57,   56,   56,  123,  123,  134,
+   35,   94,   94,   94,   94,  135,   17,    9,    9,   10,
+    7,    7,    8,    8,   81,   81,   81,   81,   81,   81,
+   81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
+   81,   81,   81,   81,   81,   81,   81,   20,   23,   22,
+   21,  143,  143,  143,  141,  141,  141,  146,  146,  146,
+  145,  145,   18,   18,  148,  148,  144,  147,  149,  149,
+  136,  136,  136,  136,  136,  136,  136,  136,  136,  136,
+  136,  136,  157,  150,  150,  156,  156,  151,  151,  154,
+  159,  159,  160,  160,  158,  162,  161,  161,  163,  163,
+  155,  155,  153,  153,  153,  153,  153,  153,  171,  171,
+  172,  172,  172,  173,  173,  174,  174,  168,  168,  178,
+  178,  177,  177,  166,  166,  170,  170,  170,  170,  170,
+  179,  179,  181,  181,  181,  181,  181,  181,  181,  181,
+  165,  165,  176,  176,  167,  167,  167,  169,  180,  180,
+  182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
+  182,  182,  182,  183,  183,  175,  175,  185,  185,  184,
+  184,  184,  184,  184,  186,  186,  186,   43,   43,   43,
+   44,   44,   44,   44,   44,   44,   44,   44,   45,   45,
+   45,   45,   45,   46,   46,  187,  187,  164,  152,  152,
+  137,  137,  137,  188,  188,  188,  189,  190,  190,  139,
+  139,  138,  138,  140,  140,  191,  191,  192,  192,  142,
+   29,
+};
+short fortranlen[] = {                                         2,
+    0,    2,    2,    2,    1,    3,    3,    1,    3,    2,
+    2,    3,    3,    2,    2,    2,    1,    1,    1,    1,
+    0,    0,    2,    0,    1,    0,    0,    0,    1,    0,
+    4,    2,    5,    3,    2,    1,    0,    1,    1,    0,
+    2,    3,    0,    2,    3,    1,    3,    1,    1,    2,
+    4,    2,    2,    4,    2,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    4,    3,    3,    2,    3,
+    0,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    3,    3,    5,
+    1,    3,    3,    2,    4,    1,    3,    0,    2,    2,
+    3,    1,    1,    1,    4,    6,    4,    1,    3,    2,
+    3,    5,    3,    1,    0,    2,    1,    4,    3,    2,
+    3,    3,    3,    3,    0,    1,    2,    2,    3,    5,
+    3,    0,    2,    2,    1,    5,    5,    2,    3,    2,
+    3,    1,    3,    2,    3,    5,    1,    2,    1,    3,
+    2,    1,    3,    0,    1,    1,    3,    3,    2,    1,
+    3,    2,    2,    0,    6,    7,    0,    2,    2,    3,
+    3,    1,    0,    2,    4,    3,    3,    4,    2,    1,
+    1,    1,    1,    1,    1,    1,    1,    0,    2,    1,
+    3,    0,    2,    3,    1,    3,    2,    3,    1,    1,
+    1,    1,    0,    3,    0,    2,    4,    1,    3,    1,
+    1,    1,    2,    1,    4,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    0,    3,    1,    3,    1,
+    1,    2,    2,    3,    1,    1,    1,    3,    1,    1,
+    3,    3,    4,    4,    3,    4,    4,    3,    4,    4,
+    4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
+    4,    3,    4,    4,    4,    4,    1,    3,    1,    1,
+    1,    2,    2,    2,    1,    1,    2,    2,    2,    2,
+    2,    2,    2,    2,    2,    2,    2,    3,    2,    3,
+    2,    2,    2,    2,    2,    2,    2,    0,    1,    2,
+    2,    2,    1,    1,    1,    1,    0,    1,    2,    4,
+    5,    4,    3,    3,    1,    2,    1,    3,    1,    1,
+    3,    5,    4,    3,    2,    2,    1,    1,    1,    1,
+    1,    1,    1,    1,    2,    2,    1,    2,    1,    1,
+    0,    1,    5,    0,    1,    1,    1,    0,    3,    0,
+    5,    2,    4,    6,    6,    1,    1,    1,    3,    3,
+    1,    3,    3,    1,    1,    5,    5,    4,    1,    2,
+    2,    2,    2,    1,    2,    5,    1,    1,    2,    5,
+    1,    2,    3,    4,    1,    1,    1,    1,    1,    1,
+    1,    1,    3,    3,    3,    2,    2,    0,    5,    7,
+    0,    2,    1,    1,    0,    1,    1,    1,    0,    1,
+    1,    2,    1,    1,    1,    5,    5,    2,    2,    2,
+    2,    1,    0,    4,    6,    1,    3,    2,    2,    2,
+    0,    3,    0,    1,    2,    1,    1,    3,    1,    2,
+    1,    1,    2,    2,    2,    3,    2,    1,    0,    2,
+    1,    1,    1,    0,    2,    0,    1,    2,    2,    0,
+    1,    0,    2,    3,    3,    3,    3,    1,    3,    1,
+    1,    3,    1,    1,    1,    2,    4,    4,    2,    2,
+    1,    1,    1,    1,    1,    1,    1,    1,    1,    3,
+    1,    1,    3,    3,    3,    3,    2,    3,    2,    2,
+    2,    2,    3,    1,    1,    1,    3,    0,    1,    2,
+    4,    2,    2,    5,    0,    1,    2,    1,    1,    1,
+    3,    3,    3,    3,    3,    3,    1,    1,    1,    3,
+    5,    5,    5,    5,    7,    1,    3,    1,    8,    2,
+    1,    1,    3,    1,    1,    1,    4,    1,    3,    1,
+    3,    0,    4,    1,    3,    0,    1,    0,    2,    3,
+    1,
+};
+short fortrandefred[] = {                                      1,
+    0,   37,   19,   20,   17,   18,   27,    5,   21,    2,
+    0,    0,   27,   23,    3,  113,   38,    0,    0,  458,
+    0,  387,  388,    0,    0,    0,    0,    0,   29,    0,
+    0,    0,    0,    0,  391,    0,  497,    0,    0,  417,
+  397,    0,    0,    0,  418,    0,  491,  492,  496,  498,
+  495,    0,    0,    0,  145,  396,    0,    0,    0,  395,
+    0,  421,  124,    0,  446,  157,    0,    0,    0,  451,
+    0,  452,  366,    0,  182,    0,  193,  192,  197,  195,
+  398,  401,  400,  399,  190,  114,  194,  196,  338,  436,
+    0,    0,    0,    0,    0,  379,    0,    0,    0,   60,
+    0,    8,   21,   21,    0,    0,   21,    0,    0,    0,
+    0,   58,   61,   62,   63,   64,   65,    0,    0,    0,
+    0,    0,    0,    0,    0,  375,  384,    0,    0,    0,
+    0,  423,  424,  425,    0,    0,    0,    0,    0,    0,
+    0,   25,   37,    7,   36,   32,    0,    0,    0,  285,
+  286,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  339,  340,    0,
+  347,  350,  349,  342,  343,  344,  341,    0,    0,    0,
+    0,    0,  249,    0,  247,    0,  281,    0,  316,  250,
+    0,    0,    0,  356,  430,    0,    0,    0,  101,    0,
+  428,    0,    0,  150,    0,  148,    0,  429,    0,  414,
+  413,  392,  548,    0,  550,    0,  416,  407,   35,  383,
+    0,  480,  478,    0,  457,    0,    0,    0,    0,  162,
+    0,    0,  138,    0,    0,  172,  173,  158,  143,  144,
+  170,    0,  234,  235,    0,   72,   52,    0,    0,    0,
+  112,    0,   50,    0,  174,  381,  382,  380,    0,    0,
+    0,  178,   15,    0,    0,    0,   10,   11,   39,   21,
+   37,   14,    0,    0,    0,    0,  166,  165,    0,    0,
+    0,    0,    0,    0,    0,    0,  120,    0,    0,  137,
+    0,    0,    0,    0,  159,    0,    0,  179,    0,  210,
+    0,  367,    0,  389,    0,    0,  433,  385,    0,    0,
+    0,    0,    0,    0,  422,  431,    0,    0,  440,  445,
+    0,  453,  514,  515,  494,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  454,    0,    0,    0,    0,    0,
+    6,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  249,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  348,    0,  352,  346,  345,  317,    0,  319,
+    0,  317,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  282,    0,    0,  393,    0,    0,    0,    0,    0,
+  109,  152,    0,    0,    0,    0,  570,    0,    0,    0,
+    0,    0,  551,  556,    0,    0,    0,    0,    0,  560,
+  564,    0,    0,   74,   75,   78,   73,   79,   76,   81,
+   82,   83,   84,   85,   80,   86,   87,   88,   89,   90,
+   91,   92,   93,   94,   95,   77,   96,    0,   97,    0,
+  139,    0,    0,    0,    0,    0,    0,  220,  222,    0,
+  224,    0,  226,  227,  228,  229,  230,  221,    0,  218,
+  216,  174,  110,    0,    0,  180,    0,    0,  203,    0,
+    0,    0,    9,   16,   12,   13,    0,    0,    0,    0,
+    0,  123,    0,    0,    0,   70,    0,    0,    0,  126,
+  121,  141,    0,    0,  161,    0,    0,  184,    0,  212,
+    0,    0,    0,    0,    0,  207,  181,    0,    0,    0,
+  412,  571,    0,  405,    0,    0,  433,  437,    0,    0,
+    0,    0,  447,  484,  485,    0,    0,    0,    0,  481,
+  499,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  468,    0,  516,    0,    0,  469,    0,    0,    0,
+    0,    0,    0,  456,   49,   48,   41,    0,   46,    0,
+    0,    0,  252,    0,    0,    0,  251,  258,  255,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  272,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  324,    0,    0,    0,    0,  248,    0,    0,
+    0,    0,    0,    0,  307,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  306,    0,    0,    0,    0,    0,    0,    0,
+    0,  394,  104,    0,  103,  102,   66,    0,    0,    0,
+    0,    0,    0,  477,  476,  479,    0,    0,    0,  378,
+    0,  163,    0,   99,    0,  171,   51,    0,  223,    0,
+    0,    0,    0,  111,    0,    0,  204,    0,  245,    0,
+  238,    0,  240,  434,   31,    0,   54,  167,    0,    0,
+  136,    0,    0,    0,    0,    0,    0,  129,    0,    0,
+    0,  160,    0,    0,    0,    0,  189,  186,  208,    0,
+    0,    0,  368,    0,    0,    0,    0,  450,  442,    0,
+  489,  490,    0,    0,    0,    0,  474,  475,    0,    0,
+    0,  526,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   42,    0,   33,  386,    0,  253,  254,
+  257,  261,  262,  263,  264,  265,  260,  266,  267,  268,
+  269,  270,  271,  273,  274,  275,  276,  256,    0,    0,
+    0,  248,  532,    0,  536,    0,  534,    0,  259,    0,
+    0,  322,    0,  327,    0,  330,    0,    0,    0,    0,
+    0,    0,    0,    0,  153,  390,    0,    0,    0,  553,
+  376,  561,  377,  565,   98,    0,    0,    0,  147,  232,
+  233,  231,    0,  219,  217,    0,    0,  206,    0,    0,
+  237,    0,    0,  122,    0,    0,    0,    0,    0,    0,
+  115,  128,    0,  117,  140,  146,  185,    0,  187,    0,
+    0,    0,    0,    0,    0,    0,    0,  448,    0,    0,
+    0,  500,    0,  482,    0,    0,  527,  517,   47,   44,
+    0,    0,    0,    0,    0,  361,    0,    0,    0,    0,
+    0,  321,  105,    0,  557,    0,  100,    0,    0,  199,
+  225,    0,    0,  239,    0,  244,  119,    0,    0,    0,
+    0,    0,  188,  214,    0,  364,    0,  371,  370,  369,
+  426,  427,    0,  435,  488,    0,    0,    0,   45,    0,
+  541,  543,  542,  353,    0,    0,  328,    0,    0,  563,
+    0,    0,  175,    0,  116,    0,    0,    0,  524,    0,
+    0,    0,    0,  201,  176,    0,  373,  372,    0,    0,
+    0,    0,    0,    0,    0,    0,
+};
+short fortrandgoto[] = {                                       1,
+  262,  263,   91,  286,  598,  353,  927,  928,  742,  743,
+  512,  710,  711,  287,  242,  146,  313,  222,   92,   93,
+   94,   95,   96,   97,   98,  189,  190,  191,  553,  843,
+  192,  722,  280,  311,  193,  194,  542,  599,  195,  356,
+  196,  197,  385,  386,  387,  893,  723,  198,  199,  640,
+  814,  815,  816,  395,  396,  205,  211,  724,  663,  645,
+  200,  357,  713,  422,  910,  433,  100,   10,  276,   11,
+  101,   12,  143,   13,   14,  102,  103,  277,  104,  105,
+  106,  107,    0,  108,  776,  255,  215,  245,  109,  110,
+  111,  112,  113,  114,  115,  116,  117,  478,  208,  118,
+  293,  498,  479,  483,  209,  428,  503,  264,  289,  294,
+  119,  297,  120,  300,  121,  839,  122,  304,  305,  252,
+  505,  265,  953,  272,  123,  308,  124,  544,  737,  509,
+  499,  500,  641,  954,  125,  126,  441,  683,  449,  452,
+  127,  128,  202,  129,  320,  554,  130,  228,    0,  131,
+  325,  132,  133,  134,  135,  136,  274,  137,  329,  561,
+  562,  138,  563,  225,  139,  332,  140,  345,  141,  235,
+    0,    0,    0,  582,  583,  346,  587,    0,  568,  347,
+  570,  571,  349,  584,  585,  763,    0,  443,  444,    0,
+    0,    0,
+};
+short fortransindex[] = {                                      0,
+  121,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+27287, -307,    0,    0,    0,    0,    0, -289, -289,    0,
+  111,    0,    0,25188,  118, 1476,  147,  153,    0,25188,
+   91,  107, 1476,  163,    0,   27,    0,  -13,25188,    0,
+    0, -250, -178,   27,    0,  208,    0,    0,    0,    0,
+    0,  -14,  215,  229,    0,    0,  201,  201, -151,    0,
+  244,    0,    0, -237,    0,    0,  -89,   27,   27,    0,
+ -100,    0,    0, -101,    0,   27,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  284,   35,   27,   27,   27,    0,  290,  134,  280,    0,
+   79,    0,    0,    0,   -5, -307,    0,  138,   -9,  387,
+  388,    0,    0,    0,    0,    0,    0,   42, -117,  404,
+  387, -110,  225, -312,   43,    0,    0, 3999,   54,25188,
+   41,    0,    0,    0, 1476,  420,  425,   59,  437,25721,
+  437,    0,    0,    0,    0,    0,  444,25188,25188,    0,
+    0,25188,  446,  448,  450,25188,25188,25188,  455,  456,
+  466,  478,  480,  486,  487,  497,  503,  504,  509,  513,
+25188,  515,  524,  528,  532,  533,25241,    0,    0,  539,
+    0,    0,    0,    0,    0,    0,    0,25188,   18,  149,
+  542,25188,    0,  548,    0,  553,    0,  563,    0,    0,
+ 8597,  115,25188,    0,    0, 8597,  190,  570,    0,25188,
+    0, 8597,  558,    0,  222,    0,  222,    0,25188,    0,
+    0,    0,    0,25188,    0,25903,    0,    0,    0,    0,
+  190,    0,    0,25380,    0,  190,  190,  222, 3040,    0,
+  224,  190,    0,25188,  609,    0,    0,    0,    0,    0,
+    0,  610,    0,    0,  201,    0,    0,  255, 1930,  603,
+    0,  651,    0, -289,    0,    0,    0,    0,  283,25428,
+ -312,    0,    0,  665,27287, -307,    0,    0,    0,    0,
+    0,    0, -289,  648,  296,  675,    0,    0,   19,  308,
+   19,  -12,   86,  -11,  665,  308,    0,  190,   19,    0,
+  313,  665,  318,  692,    0,  -10, 3093,    0,24098,    0,
+  703,    0,  711,    0,  717,  732,    0,    0,  387,  190,
+ 8597,25188,25188,  190,    0,    0,  360, 4498,    0,    0,
+25685,    0,    0,    0,    0,25188,25188,25188,25188,  740,
+25685,  149,  553, 1423,    0,  764,  209,    0, 9398,25241,
+    0,    8,  535,25936, 3157,  236, 8597,25188,25188,25188,
+  281,26019,  461,25188,25188,25188,25188,25188,25188,25188,
+25188,25188,25188,25188,25188,26043,25188,25188,25188,25188,
+25188,25241,    0,  781,  451,  786,  789,    0, 8597,25188,
+  790,26094,    0,25188,    0,    0,    0,    0,   48,    0,
+  190,    0,24299,25188,25188,25188,25188,25188,25188,25188,
+25188,25188,25188,25188,25188,25188,25188, 2012,25188,24438,
+24486,    0,25188,25188,    0,26169,  665,  475,  147,26191,
+    0,    0,  791,  791,26213,27040,    0,  796,  553,  563,
+  793,  801,    0,    0,  798,  256,  799,  796,  797,    0,
+    0,  568,  791,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  800,    0,  571,
+    0, 8597,  577,  802,  428,   27,  665,    0,    0,  665,
+    0,  807,    0,    0,    0,    0,    0,    0,  119,    0,
+    0,    0,    0,  444,  436,    0,24627, 8597,    0,  819,
+ 2554,  665,    0,    0,    0,    0,  444,25188,  599,  296,
+  387,    0,  387,  233,25188,    0,  447,  449,  233,    0,
+    0,    0,  387,  665,    0,  692,  318,    0, 3093,    0,
+24251,  817, 8597,  824,24675,    0,    0, -225,  190,  190,
+    0,    0,  806,    0, 8597, 8597,    0,    0,  445, 8597,
+  827,  826,    0,    0,    0, 9456, 9398,  605,  100,    0,
+    0, 8597, 8597, 8597, 8597,25188,  333, 1423,  538,  553,
+ 8597,    0,  828,    0, 8597, 1423,    0, 9398, 9398, 9398,
+ 9398, 9398,  598,    0,    0,    0,    0,  614,    0,  833,
+ 1476,25188,    0,  618,  619,26276,    0,    0,    0,26327,
+26349,26446,26468,26509,26582,26604,26626,26701,26742,26764,
+26859,    0,  626,  634,  636,  638,  642,  831,  834,  835,
+26881,25241,    0,25241,25241,  644,25188,    0,  822,  840,
+24813,  553,  841,25188,    0, 8597, 2081, 2081, 2226, 2226,
+ 3157,   84,   84,   84,   84,   84,   84,   90,   90,   48,
+25188,25188,    0, 8597,   48,25188,   84,25188,   84, 8597,
+ 8597,    0,    0,  190,    0,    0,    0,  468,  551,25188,
+24813, -278,  845,    0,    0,    0, -278,  846,  190,    0,
+ 3040,    0,25188,    0,25188,    0,    0,  852,    0, -170,
+ 1930,  843,  485,    0,  665,  864,    0,25188,    0,  646,
+    0, 6917,    0,    0,    0, 8597,    0,    0,  318,  308,
+    0,  321,  550,  635,26934,  643,  870,    0,  645,  190,
+  852,    0,  878,24675,  817,  506,    0,    0,    0,  862,
+  547,  880,    0,  793,  797,25188,  665,    0,    0, 4498,
+    0,    0,24813,  631,  544,25685,    0,    0, 8597,    0,
+  656,    0, 8597, 8597, 1423, 8597,  828,  250,  598,  598,
+  598,   38,   -1,    0,   10,    0,    0, 8597,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,25563,25563,
+25563,    0,    0, 8597,    0, 8597,    0, 8597,    0,  885,
+25188,    0,24866,    0,  883,    0, 7337,  548,   84,   84,
+   48,   84,   84,  665,    0,    0,26997,  658,  867,    0,
+    0,    0,    0,    0,    0, 8597,  660,25616,    0,    0,
+    0,    0,  891,    0,    0,  665,  852,    0, 8597, 2554,
+    0,25005,  692,    0,  149,  233,  233,  233,  233,  233,
+    0,    0,  233,    0,    0,    0,    0,  817,    0,24675,
+   28,  516,  517,  894,  895,27113,  665,    0,  896,24169,
+  190,    0,  209,    0, 2501, 8597,    0,    0,    0,    0,
+  662,  879,  898,  900,  902,    0,  903,25188, 7757,24813,
+25188,    0,    0,  904,    0,  190,    0,25053, 8597,    0,
+    0,  852,    0,    0, 8597,    0,    0,  184,  184,  906,
+  491,  677,    0,    0,  573,    0,  917,    0,    0,    0,
+    0,    0,25188,    0,    0,  801,  909, 8597,    0,25188,
+    0,    0,    0,    0, 8597,25188,    0, 8177,25188,    0,
+  927,    0,    0,  911,    0,  557,  559,27166,    0,27187,
+ 8597,25188, 8597,    0,    0,25188,    0,    0,25188,25188,
+ 8597, 8597, 8597,27272,25188, 8597,
+};
+short fortranrindex[] = {                                      0,
+ 5433,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  223,23906,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,23602,
+  560,  560,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,22995,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  560, 3577,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   25,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+18370,  579,    0,    0,    0,    0,    4,  -15,   52,    0,
+23145,    0,    0,    0,    0,23906,    0,    0,    0, 5953,
+13515,    0,    0,    0,    0,    0,    0,    0,18586,13666,
+  580,    0,   11,    0,    0,    0,    0,    0,23298,    0,
+    0,    0,    0,    0,    0,18739,18890,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,16959,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0, 1107, 2724,
+ 1277,    0,    0, 1646,    0, 2894,    0, 1816,    0,    0,
+  125,    0,    0,    0,    0,19043,    0,19194,    0,    0,
+    0,13884,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,19347,    0,    0,    0,    0,    0,
+    0,19498,    0,    0,   29,    0,    0,    0,    0,    0,
+    0,19651,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   24,  223,23906,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,19802,    0,    0,    0,14035,
+    0,  954,  580,    0,  908,14035,    0,   30,    0,    0,
+    0,  908,    0,14191,    0,    0,    0,    0,  960,    0,
+    0,    0,19955,    0,    0,    0,    0,    0,20106,23449,
+20259,    0,    0,    0,    0,    0,    0,  987,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0, 9631,
+    0,10472,10208, 5640,    0,20410,    0,10627,    0,23753,
+    0,    0,20563,    0, 6171,    0,  673,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0, 4668,    0,17110,17263, 3263,    0,    0,
+25786,    0,    0,  972,    0,    0,    0,    0, 3433,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0, 5271,    0,    0,
+    0,    0,    0,    0,    0,    0,  674,    0,    0,    0,
+    0,    0,20714,20867,    0,    0,    0,  165,    0,  510,
+  995,  679,    0,    0, 6497,  869, 9017,  526,  995,    0,
+    0,    0,21018,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,21171,    0,    0,
+    0,  680,    0,    0,    0,    0,14404,    0,    0,  127,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,21322,    0,    0,    0,   40,    0,    0,
+    0,   24,    0,    0,    0,    0,21322,    0,    0,    0,
+  580,    0,14555,  356,    0,    0,    0,    0,  356,    0,
+    0,    0,  580,14404,    0,14711,    0,    0,    0,    0,
+ 5618, 1012,  708,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,21475,21626,    0,    0,    0,  709,
+    0, 1013,    0,    0,    0,   63,    0,    0, 1014,    0,
+    0,12251,12465,12620,12834,    0, 1014,25857,17479, 4299,
+14924,    0,21779,    0,14924, 5802,    0,    0,    0,    0,
+    0,    0,10891,    0,    0,    0,    0,    0,    0,21930,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,27019,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+ 1021, 2185,    0,    0,    0,11727, 9782,10051, 9111, 9262,
+ 6322, 6591, 6742, 7011, 7162, 7431, 7582, 4838, 5101, 3696,
+    0,    0,    0,11882, 3866,    0, 7851,    0, 8002,  164,
+  212,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+ 1025,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,17632,    0,    0,
+    0,    0,    0,    0,12989,    0,    0,  710,    0,    0,
+    0,  720,    0,    0,    0,15080,    0,    0,    0,14035,
+    0,    0,  795,    0,    0,    0,   16,    0,    0,    0,
+17632,    0,    0,    0, 1012,    0,    0,    0,    0,    0,
+    0,22083,    0,  995,  995,    0,   24,    0,    0,    0,
+    0,    0,    0,  729,    0,    0,    0,    0,13203,  698,
+    0,    0,15293,15449, 5802,15662,22234,13358,11046,11309,
+11464,12096,    0,    0,    0,    0,    0,  730,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,15818,    0,15974,    0,16130,    0,27293,
+ 1028,    0,  737,    0, 1030,    0,  738, 2355, 8271, 8422,
+ 4129, 8691, 8842,  674,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  742,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,12989,16286,    0,  744,    0,
+    0,  749,16437,    0,  467,  356,  356,  356,  356,  356,
+    0,    0,  356,    0,    0,    0,    0, 1012,    0,    0,
+    0,    0,    0,    0,    0,    0,   24,    0,    0,    0,
+    0,    0,  750,    0,25857,14924,    0,    0,    0,    0,
+    0,  590,    0,    0,    0,    0,    0,    0,  751,    0,
+  768,    0,    0,    0,    0,    0,    0,    0,17848,    0,
+    0,16286,16655,    0,  720,    0,    0,   93,  146,   31,
+   44,    0,    0,    0,18001,    0,22387,    0,    0,    0,
+    0,    0,    0,    0,    0,  777,    0,16806,    0,    0,
+    0,    0,    0,    0,  778,    0,    0,  779,    0,    0,
+    0,16655,    0,    0,    0,    0,    0,22538,    0,    0,
+  783,    0,22691,    0,    0,    0,    0,    0,    0,    0,
+  788,18217,22842, 1031,    0, 1036,
+};
+short fortrangindex[] = {                                      0,
+    0,    0,    0,  813,  303, -401,    0,  126,    0,  211,
+ -255,    0,  232,  565,  285,   -2,    0,  -23,    0,    0,
+    0,    0,    0,    0,    0,    0, -120,    7,    0,    0,
+ -328,    0,    0,  815, -135,    0, -305,  339, -152,  181,
+ -137,    0,  766,  736, -326, -686, -234, -220,    0,  718,
+  221,  438,  371, -189,    0,  -26, -371, -495,    0,    0,
+ -169,  -24,  273, -397,    0,  -98,    0,    0, 1117,    0,
+    0,    0,  -39,  -56, 1119,  865,    0,   53,    0,    0,
+    0,    0,    0,    0,    0,    0,   65,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0, 1065,  452,  458,  716,    0,    0,    0,  -30,  627,
+    0, -277,    0,    0,    0, -667,    0, -281,  620,    0,
+  654,    0,  194,    0,    0,    0,    0,  608, -649,    0,
+    0,  457,    0,    0,    0, 1032,  612, -392,  613,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0, -230,
+    0,    0,    0,    0,    0,    0,  602,    0,    0,    0,
+    0,    0,  412,  607,    0,  219,    0,    0,    0,    0,
+    0,    0,    0,    0, -408,    0,    0,    0,    0, -317,
+  414, 1033, -335, -688,    0, -522,    0, -226,    0,    0,
+    0,    0,
+};
+#define YYTABLESIZE 27711
+short fortrantable[] = {                                     201,
+  442,  206,  343,  546,  400,  212,  218,  388,  206,  450,
+  440,  592,  522,  569,  226,  440,  147,   99,  531,  342,
+  230,  536,  639,  577,  384,  234,  224,  525,  202,  539,
+  285,  593,  528,  729,   71,  391,  221,  926,  108,  530,
+  595,  383,  202,  191,  249,  250,  535,  191,  597,  595,
+  890,  595,  257,  740,  183,  630,  688,  394,  764,  127,
+  236,  191,  766,  866,  236,  243,  281,  236,  183,  266,
+  267,  268,  133,  133,  133,  133,  888,  324,  259,  589,
+  291,  447,   71,  205,  236,  869,  351,  134,  433,  299,
+  301,  433,  260,  439,  829,  526,  217,  205,  439,  338,
+  214,  322,  704,  338,  309,  321,  338,  420,  326,  421,
+  206,  310,  433,  894,  895,  715,  216,  142,  434,  240,
+  241,  238,  239,  354,  355,  417,  415,  145,  416,  288,
+    9,  417,  362,  246,  317,  131,  131,  131,   89,  453,
+  758,  589,  333,  420,  334,  421,  376,  247,  213,  420,
+  148,  421,  389,  240,  241,  425,  278,  203,  423,  282,
+  240,  241,  701,  392,  213,  402,  227,  399,  402,  761,
+  236,  673,  424,  271,  581,  270,  702,  767,  426,  913,
+  388,  762,  402,  762,  236,  430,  207,  762,  132,  132,
+  132,  741,  210,  343,  435,  721,  888,  384,  937,  436,
+  721,  314,  219,  343,  403,  433,  580,  403,  433,  389,
+  342,  343,  388,  427,  383,  840,  841,  842,  923,  482,
+  342,  403,   30,  579,  516,  859,  253,  254,  342,  628,
+  860,  698,   30,  592,  699,  735,  514,  438,  229,  739,
+  446,  592,  448,  451,  952,  508,  383,  231,  481,  755,
+  589,  333,  404,  334,  236,  404,  714,  592,  213,  524,
+  529,  504,  527,  642,  307,   89,  306,  202,  237,  404,
+  768,  769,  770,  771,  772,  150,  603,  151,  731,  602,
+  517,   99,  543,  244,  543,  248,  191,  127,  551,  240,
+  241,  589,  333,  183,  334,  398,  685,  555,  556,  295,
+  165,  165,  133,  560,  532,  803,  302,  805,  807,  590,
+  591,  572,  573,  574,  575,  134,  251,  261,  442,  486,
+  419,  607,  205,  450,  602,  389,  552,  258,  440,  440,
+  557,  269,  515,  338,  338,  606,  361,  273,  363,  610,
+  611,  612,  613,  614,  615,  616,  617,  618,  619,  620,
+  621,  874,  875,  275,  391,  418,  419,  631,  344,  350,
+  917,  418,  419,  938,  131,  887,  887,  922,  887,  212,
+  588,  590,  591,  760,  589,  333,    2,  334,  646,  647,
+  648,  649,  650,  651,  652,  653,  654,  655,  656,  657,
+  658,  659,  660,  664,  665,  667,  669,  236,  670,  671,
+  279,  202,  232,  296,    3,    4,  303,  284,  581,  233,
+  223,  439,  439,  538,  323,  596,  581,  132,  283,  592,
+  191,    5,    6,  393,  596,  433,  596,  183,  868,  343,
+  288,  290,  592,  592,  592,  592,  592,  853,  883,  897,
+  580,   71,  854,  220,  925,  108,  342,  298,  580,  847,
+  343,  343,  343,  343,  343,  830,  205,  579,  292,  312,
+  832,  440,  697,  327,  328,  579,  440,  342,  342,  342,
+  342,  342,  803,  805,  807,  330,  331,  319,   30,  588,
+  590,  591,  392,  352,  810,  358,  712,  359,  762,  360,
+  719,  877,  720,  716,  364,  365,  383,   30,  383,  383,
+  725,  609,  730,   28,  602,  366,   30,   30,  130,  130,
+  130,  130,    7,  130,  543,  675,  543,  367,  674,  368,
+  543,  590,  591,   30,   30,  369,  370,  721,  721,  721,
+  721,  721,  859,  857,  721,  858,  371,  860,  604,  605,
+  887,  754,  372,  373,  439,    8,  315,  592,  374,  439,
+  555,  759,  375,  555,  377,  438,  448,  623,  624,  625,
+  626,  627,  314,  378,  924,  397,  554,  379,  903,  554,
+  636,  380,  381,  521,  777,  523,  206,  778,  390,  417,
+  415,  398,  416,  533,  882,  589,  333,  394,  334,  401,
+  912,  859,  857,  856,  858,  581,  860,  420,  403,  421,
+  391,  855,  402,  588,  590,  591,   89,  804,  690,  806,
+  808,  689,  389,  429,   30,  431,  817,  694,  343,  819,
+  693,  934,  918,  919,  920,  921,  338,  580,  902,  338,
+  338,  338,  338,  338,  338,  342,  820,  821,  432,  717,
+  480,  822,  520,  823,  579,  757,  810,   30,  756,  338,
+  936,  338,  484,  485,  774,  827,  817,  773,  779,  780,
+  501,  602,  602,  383,  383,  383,  794,  881,  836,  602,
+  482,  487,  417,  415,  795,  416,  796,  602,  797,  602,
+  824,  602,  798,  849,  809,  602,  851,  602,  448,  850,
+  420,  403,  421,  448,  502,  834,  886,  475,  905,  885,
+  907,  900,  939,  693,  511,  773,  506,  475,  518,  543,
+  178,  179,  284,  277,  236,  581,  277,  236,  520,  552,
+  106,  876,  552,  106,  295,  560,  181,  182,  880,  534,
+  183,  184,  185,  186,  302,  537,  865,  475,  130,  475,
+  475,  475,  475,  547,  187,  135,  135,  580,  211,  449,
+  241,  211,  449,  241,  548,  391,  549,  475,  475,  475,
+  246,  135,  135,  246,  579,  135,  135,  135,  135,  486,
+  278,  550,  486,  278,  804,  806,  808,  337,  329,  135,
+  337,  329,  107,  558,  243,  107,  212,  243,  899,  242,
+  483,  335,  242,  483,  335,  404,  405,  406,  407,  408,
+  576,  409,  410,  411,  412,  413,  414,  586,  336,  418,
+  419,  336,  600,  909,  588,  590,  591,  487,  334,  331,
+  487,  334,  331,  333,  632,  712,  333,  915,  332,  634,
+  633,  332,  635,  637,  678,  681,  682,  324,  684,  686,
+  687,  695,  692,  691,  696,  543,  700,  338,  338,  338,
+  338,  338,  705,  338,  338,  338,  338,  338,  338,  707,
+  736,  338,  338,  726,  738,  727,  746,  749,  223,  750,
+  591,  765,  775,  945,  799,  817,  948,  800,  801,  811,
+  812,  818,  826,  392,  825,  831,  833,  317,  404,  405,
+  406,  407,  408,  838,  409,  410,  411,  412,  413,  414,
+  845,  846,  418,  419,  848,  314,  861,  236,  958,  525,
+  314,  314,  950,  314,  863,  960,  864,  236,  867,  871,
+  872,  961,  870,  873,  963,  896,  900,  906,  314,  314,
+  314,  911,  929,  741,  931,  932,  935,  971,  941,  940,
+  942,  972,  943,  944,  973,  974,  956,  949,  955,  959,
+  976,  236,  860,  475,  397,  475,  475,  475,  475,  475,
+  957,  475,  475,  475,  475,  475,  475,  964,  500,  475,
+  475,  966,  475,  967,  475,  925,  108,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  215,  164,  127,  475,  475,
+  209,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  443,  475,  354,
+  475,  475,  475,  475,  475,  562,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  213,  444,  475,  475,  475,  483,  475,  475,
+  475,  325,  475,  475,  475,  317,  118,  475,  354,  475,
+  326,  544,  475,  475,  475,  475,  545,  891,  475,  475,
+  475,  914,  968,  930,  718,  510,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  519,  475,  475,
+  475,  475,  475,  475,  475,  475,  351,  475,  475,  475,
+  475,  889,  475,  475,  475,  594,  351,  629,  828,  643,
+  947,  475,  475,  879,  916,   15,  314,  314,  314,  314,
+  314,  144,  314,  314,  314,  314,  314,  314,  256,  513,
+  314,  314,  835,  351,  676,  965,  733,  351,  351,  351,
+  351,  351,  837,  351,  728,  703,  732,  844,  747,  318,
+  744,  878,  745,  236,  351,  748,  351,  351,  351,  884,
+    0,    0,  348,    0,    0,    0,    0,    0,  236,  236,
+    0,    0,  236,    0,  236,    0,    0,  236,  236,  236,
+  236,  236,  236,  236,    0,    0,  236,  236,  236,    0,
+    0,    0,    0,  236,  236,    0,    0,    0,  236,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,  236,    0,
+    0,    0,  236,  236,    0,    0,    0,  236,    0,    0,
+    0,    0,    0,  236,    0,  236,  236,    0,  236,    0,
+  236,  236,  236,  236,  236,    0,  236,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,    0,    0,  236,  236,  236,    0,  236,  236,
+  236,    0,  236,  236,  236,    0,  314,  236,    0,  236,
+    0,    0,  236,  236,  236,  236,  314,    0,  236,  236,
+  236,    0,    0,    0,    0,    0,  236,    0,    0,  236,
+  236,  236,  236,  236,  236,  236,  236,    0,  236,  236,
+  236,  236,  236,  314,    0,  236,    0,  314,  314,  314,
+  314,  314,  236,  236,  236,    0,    0,    0,    0,    0,
+    0,  236,  236,    0,  314,    0,  314,  314,  314,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  351,    0,  351,  351,  351,  351,  351,    0,
+  351,  351,  351,  351,  351,  351,    0,  351,  351,  351,
+    0,  351,    0,  351,    0,    0,  351,  351,  351,  351,
+  351,  351,  351,    0,    0,  351,  351,  351,    0,    0,
+    0,    0,  351,  351,    0,    0,    0,  351,  351,    0,
+    0,    0,    0,    0,    0,    0,    0,  351,    0,    0,
+    0,  351,  351,    0,    0,    0,  351,    0,    0,    0,
+    0,    0,  351,    0,  351,  351,    0,  351,    0,  351,
+  351,  351,  351,  351,    0,  351,  351,  351,  351,  351,
+  351,  351,  351,  351,  351,  351,  351,  351,  351,  351,
+  351,    0,  578,  351,  351,  351,    0,  351,  351,  351,
+    0,  351,  351,  351,    0,    0,  351,    0,  351,    0,
+    0,  351,  351,  351,  351,  204,  351,  351,  351,  351,
+    0,    0,    0,    0,    0,  351,    0,    0,  351,  351,
+  351,  351,  351,  351,  351,  351,    0,  351,  351,  351,
+  351,  351,    0,    0,  351,  188,    0,    0,  150,    0,
+  151,  351,  351,  351,    0,    0,    0,    0,    0,    0,
+  351,  351,  314,    0,  314,  314,  314,  314,  314,    0,
+  314,  314,  314,  314,  314,  314,    0,  314,  314,  314,
+    0,  314,    0,  314,    0,    0,  314,  314,  314,  314,
+  314,  314,  314,    0,    0,  314,  314,  314,    0,    0,
+    0,    0,  314,  314,    0,    0,    0,  314,  314,    0,
+    0,    0,    0,    0,    0,    0,    0,  314,    0,    0,
+    0,  314,  314,    0,    0,    0,  314,    0,    0,    0,
+    0,    0,  314,    0,  314,  314,    0,  314,    0,  314,
+  314,  314,  314,  314,    0,  314,  314,  314,  314,  314,
+  314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
+  314,    0,    0,  314,  314,  314,    0,  314,  314,  314,
+    0,  314,  314,  314,    0,  318,  314,    0,  314,    0,
+    0,  314,  314,  314,  314,  318,  314,  314,  314,  314,
+    0,    0,    0,    0,    0,  314,    0,    0,  314,  314,
+  314,  314,  314,  314,  314,  314,    0,  314,  314,  314,
+  314,  314,  318,    0,  314,    0,  318,  318,  318,  318,
+  318,  314,  314,  314,    0,    0,    0,    0,    0,    0,
+  314,  314,    0,  318,    0,  318,  318,  318,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,    0,  176,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,  315,    0,    0,  180,    0,
+    0,    0,    0,    0,    0,  315,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,    0,    0,   89,
+    0,    0,    0,    0,    0,    0,  187,    0,    0,    0,
+    0,    0,  315,    0,  177,    0,  315,  315,  315,  315,
+  315,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,  315,    0,  315,  315,  315,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,  318,    0,  318,  318,  318,  318,  318,    0,  318,
+  318,  318,  318,  318,  318,    0,  318,  318,  318,    0,
+  318,    0,  318,    0,    0,  318,  318,  318,  318,  318,
+  318,  318,    0,    0,  318,  318,  318,    0,    0,    0,
+    0,  318,  318,    0,    0,    0,  318,  318,    0,    0,
+    0,    0,    0,    0,    0,    0,  318,    0,    0,    0,
+  318,  318,    0,    0,    0,  318,    0,    0,    0,    0,
+    0,  318,    0,  318,  318,    0,  318,    0,  318,  318,
+  318,  318,  318,    0,  318,  318,  318,  318,  318,  318,
+  318,  318,  318,  318,  318,  318,  318,  318,  318,  318,
+    0,    0,  318,  318,  318,    0,  318,  318,  318,    0,
+  318,  318,  318,    0,    0,  318,    0,  318,    0,    0,
+  318,  318,  318,  318,    0,  318,  318,  318,  318,    0,
+    0,    0,    0,    0,  318,    0,    0,  318,  318,  318,
+  318,  318,  318,  318,  318,    0,  318,  318,  318,  318,
+  318,  188,    0,  318,  150,    0,  151,    0,    0,    0,
+  318,  318,  318,    0,    0,    0,    0,    0,    0,  318,
+  318,  315,  661,  315,  315,  315,  315,  315,    0,  315,
+  315,  315,  315,  315,  315,    0,  315,  315,  315,    0,
+  315,    0,  315,    0,    0,  315,  315,  315,  315,  315,
+  315,  315,    0,    0,  315,  315,  315,    0,    0,    0,
+    0,  315,  315,    0,    0,    0,  315,  315,    0,    0,
+    0,    0,  417,  415,    0,  416,  315,    0,    0,    0,
+  315,  315,    0,    0,    0,  315,    0,    0,    0,    0,
+  420,  315,  421,  315,  315,    0,  315,    0,  315,  315,
+  315,  315,  315,    0,  315,  315,  315,  315,  315,  315,
+  315,  315,  315,  315,  315,  315,  315,  315,  315,  315,
+    0,    0,  315,  315,  315,    0,  315,  315,  315,    0,
+  315,  315,  315,    0,  323,  315,    0,  315,    0,    0,
+  315,  315,  315,  315,  323,  315,  315,  315,  315,    0,
+    0,    0,    0,    0,  315,    0,  488,  315,  315,  315,
+  315,  315,  315,  315,  315,    0,  315,  315,  315,  315,
+  315,    0,    0,  315,  323,  323,  323,  323,  323,  323,
+  315,  315,  315,    0,    0,    0,    0,    0,    0,  315,
+  315,    0,  323,    0,  323,  323,  323,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  253,  254,  489,
+    0,    0,    0,    0,    0,    0,    0,  417,  415,    0,
+  416,    0,    0,    0,  149,    0,    0,    0,    0,    0,
+    0,    0,    0,  662,    0,  420,  490,  421,  491,  492,
+  493,    0,    0,  494,  495,    0,  496,  497,  152,  153,
+    0,    0,    0,  154,  155,  156,  157,    0,    0,    0,
+    0,    0,    0,    0,    0,  158,  159,  160,  161,  162,
+  163,  164,    0,  165,  166,  167,    0,    0,  168,  169,
+  170,    0,  171,  172,  173,  174,  175,    0,  176,    0,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  320,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  320,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  177,  320,    0,    0,    0,  320,  320,  320,  320,  320,
+    0,  178,  179,    0,    0,    0,    0,  180,    0,    0,
+    0,    0,  320,    0,  320,  320,  320,  181,  182,    0,
+    0,  183,  184,  185,  186,    0,    0,    0,   89,    0,
+    0,    0,    0,    0,    0,  187,    0,    0,    0,    0,
+  323,    0,  323,  323,  323,  323,  323,    0,  323,  323,
+  323,  323,  323,  323,    0,  323,  323,  323,    0,  323,
+    0,  323,    0,    0,  323,  323,  323,  323,  323,  323,
+  323,    0,    0,  323,  323,  323,    0,    0,    0,    0,
+  323,  323,    0,    0,    0,  323,  323,  408,    0,  409,
+  410,  411,  412,  413,  414,  323,    0,  418,  419,  323,
+  323,    0,    0,    0,  323,    0,    0,    0,    0,    0,
+  323,    0,  323,  323,    0,  323,    0,  323,  323,  323,
+  323,  323,    0,  323,  323,  323,  323,  323,  323,  323,
+  323,  323,  323,  323,  323,  323,  323,  323,  323,    0,
+  578,  323,  323,  323,    0,  323,  323,  323,    0,  323,
+  323,  323,    0,    0,  323,    0,  323,    0,    0,  323,
+  323,  323,  323,    0,  323,  323,  323,  323,    0,    0,
+    0,    0,    0,  323,    0,    0,  323,  323,  323,  323,
+  323,  323,  323,  323,    0,  323,  323,  323,  323,  323,
+    0,    0,  323,  188,    0,  709,  150,    0,  151,  323,
+  323,  323,    0,    0,    0,    0,    0,    0,  323,  323,
+  320,  708,  320,  320,  320,  320,  320,    0,  320,  320,
+  320,  320,  320,  320,    0,  320,  320,  320,    0,  320,
+    0,  320,    0,    0,  320,  320,  320,  320,  320,  320,
+  320,    0,    0,  320,  320,  320,    0,    0,    0,    0,
+  320,  320,    0,    0,    0,  320,  320,    0,    0,    0,
+    0,    0,    0,    0,    0,  320,    0,    0,    0,  320,
+  320,    0,    0,    0,  320,    0,    0,    0,    0,    0,
+  320,    0,  320,  320,    0,  320,    0,  320,  320,  320,
+  320,  320,    0,  320,  320,  320,  320,  320,  320,  320,
+  320,  320,  320,  320,  320,  320,  320,  320,  320,    0,
+    0,  320,  320,  320,    0,  320,  320,  320,    0,  320,
+  320,  320,    0,  280,  320,    0,  320,    0,    0,  320,
+  320,  320,  320,  280,  320,  320,  320,  320,    0,    0,
+    0,    0,    0,  320,    0,    0,  320,  320,  320,  320,
+  320,  320,  320,  320,    0,  320,  320,  320,  320,  320,
+  280,    0,  320,    0,  280,  280,  280,  280,  280,  320,
+  320,  320,    0,    0,    0,    0,    0,    0,  320,  320,
+    0,  280,    0,  280,  280,  280,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,    0,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,    0,  165,  166,  167,    0,  149,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,    0,  176,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  152,  153,    0,    0,    0,  154,  155,  156,  157,    0,
+    0,    0,    0,    0,    0,    0,    0,  158,  159,  160,
+  161,  162,  163,  164,    0,  165,  166,  167,    0,    0,
+  168,  169,  170,    0,  171,  172,  173,  174,  175,    0,
+  176,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,  279,    0,    0,  180,    0,    0,    0,
+    0,    0,    0,  279,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,    0,    0,  892,    0,    0,
+    0,    0,    0,    0,  187,    0,    0,    0,    0,    0,
+    0,    0,  177,    0,  279,  279,  279,  279,  279,    0,
+    0,    0,    0,  178,  179,    0,    0,    0,    0,  180,
+    0,  279,    0,  279,  279,  279,    0,    0,    0,  181,
+  182,    0,    0,  183,  184,  185,  186,    0,    0,    0,
+   89,    0,    0,    0,    0,    0,    0,  187,    0,  280,
+    0,  280,  280,  280,  280,  280,    0,  280,  280,  280,
+  280,  280,  280,    0,  280,  280,  280,    0,  280,    0,
+  280,    0,    0,  280,  280,  280,  280,  280,  280,  280,
+    0,    0,  280,  280,  280,    0,    0,    0,    0,  280,
+  280,    0,    0,    0,  280,  280,    0,    0,    0,    0,
+    0,    0,    0,    0,  280,    0,    0,    0,  280,  280,
+    0,    0,    0,  280,    0,    0,    0,    0,    0,  280,
+    0,  280,  280,    0,  280,    0,  280,  280,  280,  280,
+  280,    0,  280,  280,  280,  280,  280,  280,  280,  280,
+  280,  280,  280,  280,  280,  280,  280,  280,    0,    0,
+  280,  280,  280,    0,  280,  280,  280,    0,  280,  280,
+  280,    0,    0,  280,    0,  280,    0,    0,  280,  280,
+  280,  280,    0,  280,  280,  280,  280,    0,    0,    0,
+    0,    0,  280,    0,    0,  280,  280,  280,  280,  280,
+  280,  280,  280,    0,  280,  280,  280,  280,  280,    0,
+    0,  280,  188,    0,  540,  150,    0,  151,  280,  280,
+    0,    0,    0,    0,    0,    0,    0,  280,  280,  279,
+    0,  279,  279,  279,  279,  279,    0,  279,  279,  279,
+  279,  279,  279,    0,  279,  279,  279,    0,  279,    0,
+  279,    0,    0,  279,  279,  279,  279,  279,  279,  279,
+    0,    0,  279,  279,  279,    0,    0,    0,    0,  279,
+  279,    0,    0,    0,  279,  279,    0,    0,  417,  415,
+    0,  416,    0,    0,  279,    0,    0,    0,  279,  279,
+    0,    0,    0,  279,    0,    0,  420,    0,  421,  279,
+    0,  279,  279,    0,  279,    0,  279,  279,  279,  279,
+  279,    0,  279,  279,  279,  279,  279,  279,  279,  279,
+  279,  279,  279,  279,  279,  279,  279,  279,    0,    0,
+  279,  279,  279,    0,  279,  279,  279,    0,  279,  279,
+  279,    0,  538,  279,    0,  279,    0,    0,  279,  279,
+  279,  279,  538,  279,  279,  279,  279,    0,    0,    0,
+    0,    0,  279,    0,    0,  279,  279,  279,  279,  279,
+  279,  279,  279,    0,  279,  279,  279,  279,  279,    0,
+    0,  279,    0,  250,  250,  250,  538,  250,  279,  279,
+  279,    0,    0,    0,    0,    0,    0,  279,  279,    0,
+    0,    0,  250,  250,  250,    0,    0,  454,    0,    0,
+    0,  455,  456,  457,  458,    0,    0,    0,    0,    0,
+    0,    0,    0,  459,  460,  461,  462,  463,  464,  465,
+    0,  466,  467,  468,    0,  149,  469,  470,  471,    0,
+    0,  472,  473,  474,  475,    0,  476,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,    0,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,  283,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  283,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  477,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  283,
+    0,  177,    0,  283,  283,  283,  283,  283,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+  283,    0,    0,  283,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,    0,    0,  541,
+    0,    0,    0,    0,    0,    0,  187,    0,  538,    0,
+  250,  250,  250,  250,  250,    0,  250,  250,  250,  250,
+  250,  250,    0,    0,  250,  250,    0,  538,    0,  538,
+    0,    0,  538,  538,  538,  538,  538,  538,  538,    0,
+    0,  538,  538,  538,    0,    0,    0,    0,  538,  538,
+    0,    0,    0,  538,  538,    0,    0,    0,    0,    0,
+    0,    0,    0,  538,    0,    0,    0,  538,  538,    0,
+    0,    0,  538,    0,    0,    0,    0,    0,  538,    0,
+  538,  538,    0,  538,    0,  538,  538,  538,  538,  538,
+    0,  538,  538,  538,  538,  538,  538,  538,  538,  538,
+  538,  538,  538,  538,  538,  538,  538,    0,    0,  538,
+  538,  538,    0,  538,  538,  538,    0,  538,  538,  538,
+    0,    0,  538,    0,  538,    0,    0,  538,  538,  538,
+  538,    0,  538,  538,  538,  538,    0,    0,    0,    0,
+    0,  538,    0,    0,  538,  538,  538,  538,  538,  538,
+  538,  538,    0,  538,  538,  538,  538,  538,    0,    0,
+  538,    0,    0,    0,    0,    0,    0,  538,  538,  538,
+    0,    0,    0,    0,    0,    0,  538,  538,  283,    0,
+  283,  283,  283,  283,  283,  289,  283,  283,  283,  283,
+  283,  283,    0,  283,  283,  289,    0,  283,    0,  283,
+    0,    0,  283,  283,  283,  283,  283,  283,  283,    0,
+    0,  283,  283,  283,    0,    0,    0,    0,  283,  283,
+    0,    0,  289,  283,  283,    0,  289,  289,  289,  289,
+  289,    0,    0,  283,    0,    0,    0,  283,  283,    0,
+    0,    0,  283,  289,    0,    0,  289,    0,  283,    0,
+  283,  283,    0,  283,    0,  283,  283,  283,  283,  283,
+    0,  283,  283,  283,  283,  283,  283,  283,  283,  283,
+  283,  283,  283,  283,  283,  283,  283,    0,    0,  283,
+  283,  283,    0,  283,  283,  283,    0,  283,  283,  283,
+    0,    0,  283,    0,  283,    0,    0,  283,  283,  283,
+  283,    0,  283,  283,  283,  283,    0,    0,    0,    0,
+    0,  283,    0,    0,  283,  283,  283,  283,  283,  283,
+  283,  283,    0,  283,  283,  283,  283,  283,    0,    0,
+  283,    0,    0,    0,    0,    0,    0,  283,  283,  283,
+    0,    0,    0,    0,    0,    0,  283,  283,    0,    0,
+    0,    0,    0,    0,  108,  290,    0,    0,  108,  108,
+  108,  108,    0,    0,    0,  290,    0,    0,    0,    0,
+  108,  108,  108,  108,  108,  108,  108,    0,  108,  108,
+  108,    0,    0,  108,  108,  108,    0,    0,  108,  108,
+  108,  108,  290,  108,    0,    0,  290,  290,  290,  290,
+  290,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  290,    0,    0,  290,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  289,    0,  289,  289,  289,  289,  289,    0,  289,
+  289,  289,  289,  289,  289,    0,  289,  289,    0,    0,
+  289,    0,  289,    0,    0,  289,  289,  289,  289,  289,
+  289,  289,    0,    0,  289,  289,  289,    0,    0,    0,
+    0,  289,  289,  108,    0,    0,  289,  289,    0,    0,
+    0,    0,    0,    0,    0,    0,  289,    0,    0,    0,
+  289,  289,    0,    0,    0,  289,    0,    0,    0,    0,
+    0,  289,    0,  289,  289,    0,  289,    0,  289,  289,
+  289,  289,  289,    0,  289,  289,  289,  289,  289,  289,
+  289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
+    0,    0,  289,  289,  289,    0,  289,  289,  289,    0,
+  289,  289,  289,    0,    0,  289,    0,  289,    0,    0,
+  289,  289,  289,  289,    0,  289,  289,  289,  289,    0,
+    0,    0,    0,    0,  289,    0,    0,  289,  289,  289,
+  289,  289,  289,  289,  289,    0,  289,  289,  289,  289,
+  289,    0,    0,  289,    0,    0,    0,    0,    0,    0,
+  289,  289,  289,    0,    0,    0,    0,    0,    0,  289,
+  289,  290,    0,  290,  290,  290,  290,  290,  311,  290,
+  290,  290,  290,  290,  290,    0,  290,  290,  311,    0,
+  290,    0,  290,    0,    0,  290,  290,  290,  290,  290,
+  290,  290,    0,    0,  290,  290,  290,    0,    0,    0,
+    0,  290,  290,    0,    0,  311,  290,  290,    0,  311,
+  311,  311,  311,  311,    0,    0,  290,    0,    0,    0,
+  290,  290,    0,    0,    0,  290,  311,    0,    0,  311,
+    0,  290,    0,  290,  290,    0,  290,    0,  290,  290,
+  290,  290,  290,    0,  290,  290,  290,  290,  290,  290,
+  290,  290,  290,  290,  290,  290,  290,  290,  290,  290,
+    0,    0,  290,  290,  290,    0,  290,  290,  290,    0,
+  290,  290,  290,    0,    0,  290,    0,  290,    0,    0,
+  290,  290,  290,  290,    0,  290,  290,  290,  290,    0,
+    0,    0,    0,    0,  290,    0,    0,  290,  290,  290,
+  290,  290,  290,  290,  290,    0,  290,  290,  290,  290,
+  290,    0,    0,  290,    0,    0,    0,    0,    0,    0,
+  290,  290,  290,    0,   20,    0,    0,    0,    0,  290,
+  290,    0,    0,    0,    0,    0,    0,    0,  519,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  519,   26,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,   30,    0,    0,    0,    0,   33,
+  314,    0,    0,    0,   37,   38,    0,    0,    0,  519,
+  519,  519,  519,  519,  315,   47,   48,   49,   50,   51,
+   52,  316,    0,    0,    0,    0,    0,    0,  519,  519,
+  519,    0,    0,    0,   62,    0,    0,    0,    0,    0,
+   65,    0,    0,    0,    0,    0,    0,    0,    0,   70,
+    0,   72,    0,    0,  311,    0,  311,  311,  311,  311,
+  311,    0,  311,  311,  311,  311,  311,  311,    0,  311,
+  311,    0,    0,  311,    0,  311,    0,    0,  311,  311,
+  311,  311,  311,  311,  311,   89,    0,  311,  311,  311,
+    0,    0,   90,    0,  311,  311,    0,    0,    0,  311,
+  311,    0,    0,    0,    0,    0,    0,    0,    0,  311,
+    0,    0,    0,  311,  311,    0,    0,    0,  311,    0,
+    0,    0,    0,    0,  311,    0,  311,  311,    0,  311,
+    0,  311,  311,  311,  311,  311,    0,  311,  311,  311,
+  311,  311,  311,  311,  311,  311,  311,  311,  311,  311,
+  311,  311,  311,    0,    0,  311,  311,  311,    0,  311,
+  311,  311,    0,  311,  311,  311,    0,    0,  311,    0,
+  311,    0,    0,  311,  311,  311,  311,    0,  311,  311,
+  311,  311,    0,    0,    0,    0,    0,  311,    0,    0,
+  311,  311,  311,  311,  311,  311,  311,  311,    0,  311,
+  311,  311,  311,  311,    0,    0,  311,  188,    0,  559,
+  150,    0,  151,  311,  311,  311,    0,    0,    0,    0,
+    0,    0,  311,  311,  519,    0,  519,  519,  519,  519,
+  519,    0,  519,  519,  519,  519,  519,  519,    0,    0,
+  519,  519,    0,  519,    0,  519,    0,    0,  519,  519,
+  519,  519,  519,  519,  519,    0,    0,  519,  519,  519,
+    0,    0,    0,    0,  519,  519,    0,    0,    0,  519,
+  519,    0,    0,    0,    0,    0,    0,    0,    0,  519,
+    0,    0,    0,  519,  519,    0,    0,    0,  519,    0,
+    0,    0,    0,    0,  519,    0,  519,  519,    0,  519,
+    0,  519,  519,  519,  519,  519,    0,  519,  519,  519,
+  519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
+  519,  519,  519,    0,    0,  519,  519,  519,    0,  519,
+  519,  519,    0,  519,  519,  519,    0,  528,  519,    0,
+  519,    0,    0,  519,  519,  519,  519,  528,    0,  519,
+  519,  519,    0,    0,    0,    0,    0,  519,    0,    0,
+  519,  519,  519,  519,  519,  519,  519,  519,    0,  519,
+  519,  519,  519,  519,    0,    0,  519,    0,    0,  247,
+  247,    0,  247,  519,  519,  519,    0,    0,    0,    0,
+    0,    0,  519,  519,    0,    0,    0,  247,  247,  247,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  149,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  287,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  287,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  287,    0,  177,    0,  287,    0,
+  287,  287,  287,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,  287,    0,    0,  287,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,    0,   89,    0,    0,    0,    0,    0,
+    0,  187,    0,  528,    0,  247,  247,  247,  247,  247,
+    0,  247,  247,  247,  247,  247,  247,    0,    0,  247,
+  247,    0,  528,    0,  528,    0,    0,  528,  528,  528,
+  528,  528,  528,  528,    0,    0,  528,  528,  528,    0,
+    0,    0,    0,  528,  528,    0,    0,    0,  528,  528,
+    0,    0,    0,    0,    0,    0,    0,    0,  528,    0,
+    0,    0,  528,  528,    0,    0,    0,  528,    0,    0,
+    0,    0,    0,  528,    0,  528,  528,    0,  528,    0,
+  528,  528,  528,  528,  528,    0,  528,  528,  528,  528,
+  528,  528,  528,  528,  528,  528,  528,  528,  528,  528,
+  528,  528,    0,    0,  528,  528,  528,    0,  528,  528,
+  528,    0,  528,  528,  528,    0,    0,  528,    0,  528,
+    0,    0,  528,  528,  528,  528,    0,  528,  528,  528,
+  528,    0,    0,    0,    0,    0,  528,    0,    0,  528,
+  528,  528,  528,  528,  528,  528,  528,    0,  528,  528,
+  528,  528,  528,    0,    0,  528,    0,    0,    0,    0,
+    0,    0,  528,  528,  528,    0,    0,    0,    0,    0,
+    0,  528,  528,  287,    0,  287,  287,  287,  287,  287,
+  288,  287,  287,  287,  287,  287,  287,    0,  287,    0,
+  288,    0,  287,    0,  287,    0,    0,  287,  287,  287,
+  287,  287,  287,  287,    0,    0,  287,  287,  287,    0,
+    0,    0,    0,  287,  287,    0,    0,  288,  287,  287,
+    0,  288,    0,  288,  288,  288,    0,    0,  287,    0,
+    0,    0,  287,  287,    0,    0,    0,  287,  288,    0,
+    0,  288,    0,  287,    0,  287,  287,    0,  287,    0,
+  287,  287,  287,  287,  287,    0,  287,  287,  287,  287,
+  287,  287,  287,  287,  287,  287,  287,  287,  287,  287,
+  287,  287,    0,    0,  287,  287,  287,    0,  287,  287,
+  287,    0,  287,  287,  287,    0,    0,  287,    0,  287,
+    0,    0,  287,  287,  287,  287,    0,  287,  287,  287,
+  287,    0,    0,    0,    0,    0,  287,    0,    0,  287,
+  287,  287,  287,  287,  287,  287,  287,    0,  287,  287,
+  287,  287,  287,    0,    0,  287,    0,    0,    0,    0,
+    0,    0,  287,  287,  287,    0,    0,    0,    0,    0,
+    0,  287,  287,    0,    0,    0,    0,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  308,    0,    0,
+    0,  308,  308,    0,  308,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  308,    0,
+  308,    0,  308,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  288,    0,  288,  288,
+  288,  288,  288,    0,  288,  288,  288,  288,  288,  288,
+    0,  288,    0,    0,    0,  288,    0,  288,    0,    0,
+  288,  288,  288,  288,  288,  288,  288,    0,    0,  288,
+  288,  288,    0,    0,    0,    0,  288,  288,    0,    0,
+    0,  288,  288,    0,    0,    0,    0,    0,    0,    0,
+    0,  288,    0,    0,    0,  288,  288,    0,    0,    0,
+  288,    0,    0,    0,    0,    0,  288,    0,  288,  288,
+    0,  288,   22,  288,  288,  288,  288,  288,    0,  288,
+  288,  288,  288,  288,  288,  288,  288,  288,  288,  288,
+  288,  288,  288,  288,  288,    0,    0,  288,  288,  288,
+    0,  288,  288,  288,    0,  288,  288,  288,    0,    0,
+  288,    0,  288,    0,    0,  288,  288,  288,  288,    0,
+  288,  288,  288,  288,    0,    0,    0,    0,    0,  288,
+    0,    0,  288,  288,  288,  288,  288,  288,  288,  288,
+    0,  288,  288,  288,  288,  288,    0,    0,  288,    0,
+    0,    0,    0,    0,    0,  288,  288,  288,    0,    0,
+    0,    0,    0,    0,  288,  288,  308,    0,  308,  308,
+  308,  308,  308,    0,  308,  308,  308,  308,  308,  308,
+    0,  308,    0,  308,    0,  308,    0,  308,    0,    0,
+  308,  308,  308,  308,  308,  308,  308,    0,    0,  308,
+  308,  308,    0,    0,    0,    0,  308,  308,    0,    0,
+    0,  308,  308,    0,    0,    0,    0,    0,    0,    0,
+    0,  308,    0,    0,    0,  308,  308,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,  308,    0,  308,  308,
+    0,  308,    0,  308,  308,  308,  308,  308,    0,  308,
+  308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
+  308,  308,  308,  308,  308,    0,    0,  308,  308,  308,
+    0,  308,  308,  308,    0,  308,  308,  308,    0,  466,
+  308,    0,  308,    0,    0,  308,  308,  308,  308,  466,
+  308,  308,  308,  308,  338,    0,    0,    0,  338,  308,
+    0,  338,  308,  308,  308,  308,    0,  308,  308,  308,
+    0,  308,  308,  308,  308,  308,    0,  338,  308,  338,
+    0,  518,  518,  518,  518,  308,  308,    0,    0,    0,
+    0,    0,    0,    0,    0,  308,    0,    0,    0,  518,
+  518,  518,    0,    0,    0,    0,    0,   22,    0,   22,
+    0,    0,   22,   22,   22,   22,    0,    0,   22,    0,
+    0,   22,   22,   22,    0,    0,    0,    0,   22,   22,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   22,    0,    0,    0,   22,   22,    0,
+    0,    0,   22,    0,    0,    0,    0,    0,   22,    0,
+   22,   22,    0,   22,    0,   22,   22,   22,   22,   22,
+    0,   22,   22,   22,   22,   22,   22,   22,   22,   22,
+   22,   22,   22,   22,   22,   22,   22,    0,    0,   22,
+   22,   22,    0,   22,   22,   22,    0,   22,   22,   22,
+    0,  518,   22,    0,   22,    0,    0,   22,   22,   22,
+   22,  518,    0,   22,   22,   22,    0,    0,    0,    0,
+    0,   22,    0,    0,    0,   22,   22,   22,   22,   22,
+   22,   22,    0,   22,   22,   22,   22,   22,    0,    0,
+   22,    0,    0,  518,  518,  518,  518,   22,   22,   22,
+    0,    0,    0,    0,    0,    0,   22,    0,    0,    0,
+    0,  518,  518,  518,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  338,  338,  338,  338,  338,
+    0,  338,  338,  338,  338,  338,  338,    0,    0,  338,
+  338,    0,    0,    0,    0,  466,    0,  518,  518,  518,
+  518,  518,    0,  518,  518,  518,  518,  518,  518,    0,
+    0,  518,  518,    0,  466,    0,  466,    0,    0,  466,
+  466,  466,  466,  466,  466,  466,    0,    0,  466,  466,
+  466,    0,    0,    0,    0,  466,  466,    0,    0,    0,
+  466,  466,    0,    0,    0,    0,    0,    0,    0,    0,
+  466,    0,   56,    0,  466,  466,    0,    0,    0,  466,
+    0,    0,   56,    0,    0,  466,    0,  466,  466,    0,
+  466,    0,  466,  466,  466,  466,  466,    0,  466,  466,
+  466,  466,  466,  466,  466,  466,  466,  466,  466,  466,
+  466,  466,  466,  466,    0,    0,  466,  466,  466,    0,
+  466,  466,  466,    0,  466,  466,  466,    0,    0,  466,
+    0,  466,    0,    0,  466,  466,  466,  466,    0,    0,
+  466,  466,  466,    0,    0,    0,    0,    0,  466,    0,
+    0,  466,  466,  466,  466,    0,  466,  466,  466,    0,
+  466,  466,  466,  466,  466,    0,    0,  466,    0,    0,
+    0,    0,    0,    0,  466,  466,    0,  518,    0,  518,
+  518,  518,  518,  518,  466,  518,  518,  518,  518,  518,
+  518,    0,    0,  518,  518,    0,  518,    0,  518,    0,
+    0,  518,  518,  518,  518,  518,  518,  518,    0,    0,
+  518,  518,  518,    0,    0,    0,    0,  518,  518,    0,
+    0,    0,  518,  518,    0,    0,    0,    0,    0,    0,
+    0,    0,  518,    0,    0,    0,  518,  518,    0,    0,
+    0,  518,    0,    0,    0,    0,    0,  518,    0,  518,
+  518,    0,  518,    0,  518,  518,  518,  518,  518,    0,
+  518,  518,  518,  518,  518,  518,  518,  518,  518,  518,
+  518,  518,  518,  518,  518,  518,    0,    0,  518,  518,
+  518,    0,  518,  518,  518,    0,  518,  518,  518,    0,
+  284,  518,    0,  518,    0,    0,  518,  518,  518,  518,
+  284,    0,  518,  518,  518,    0,    0,    0,    0,    0,
+  518,    0,    0,  518,  518,  518,  518,    0,  518,  518,
+  518,    0,  518,  518,  518,  518,  518,  284,   56,  518,
+    0,  284,    0,    0,  284,    0,  518,  518,    0,    0,
+    0,    0,    0,  164,  164,    0,  518,   56,  284,   56,
+    0,  284,   56,   56,   56,   56,   56,   56,   56,    0,
+    0,   56,   56,   56,    0,    0,    0,    0,   56,   56,
+    0,    0,    0,   56,   56,    0,    0,    0,    0,    0,
+    0,    0,    0,   56,    0,    0,    0,   56,   56,    0,
+    0,    0,   56,    0,    0,    0,    0,    0,   56,    0,
+   56,   56,    0,   56,    0,   56,   56,   56,   56,   56,
+    0,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+   56,   56,   56,   56,   56,   56,   56,    0,    0,   56,
+   56,   56,    0,   56,   56,   56,    0,   56,   56,   56,
+    0,  305,   56,    0,   56,    0,    0,   56,   56,   56,
+   56,  305,    0,   56,   56,   56,    0,    0,    0,    0,
+    0,   56,    0,    0,   56,   56,   56,   56,   56,   56,
+   56,   56,    0,   56,   56,   56,   56,   56,  305,    0,
+   56,    0,  305,    0,    0,  305,    0,   56,   56,   56,
+    0,    0,    0,    0,    0,    0,   56,   56,    0,  305,
+    0,    0,  305,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  284,    0,  284,  284,
+  284,  284,  284,    0,    0,    0,    0,    0,    0,    0,
+    0,  284,    0,    0,    0,  284,    0,  284,    0,    0,
+  284,  284,  284,  284,  284,  284,  284,    0,    0,  284,
+  284,  284,    0,    0,    0,    0,  284,  284,    0,    0,
+    0,  284,  284,    0,    0,    0,    0,    0,    0,    0,
+    0,  284,    0,    0,    0,  284,  284,    0,    0,    0,
+  284,    0,    0,    0,    0,    0,  284,    0,  284,  284,
+    0,  284,    0,  284,  284,  284,  284,  284,    0,  284,
+  284,  284,  284,  284,  284,  284,  284,  284,  284,  284,
+  284,  284,  284,  284,  284,    0,    0,  284,  284,  284,
+    0,  284,  284,  284,    0,  284,  284,  284,  341,  341,
+  284,  341,  284,    0,    0,  284,  284,  284,  284,    0,
+  284,  284,  284,  284,    0,    0,  341,  341,  341,  284,
+    0,    0,  284,  284,  284,  284,  284,  284,  284,  284,
+    0,  284,  284,  284,  284,  284,    0,  305,  284,  305,
+  305,  305,  305,  305,    0,  284,  284,  284,    0,    0,
+  295,    0,  305,    0,  284,  284,  305,    0,  305,    0,
+  295,  305,  305,  305,  305,  305,  305,  305,    0,    0,
+  305,  305,  305,    0,    0,    0,    0,  305,  305,    0,
+    0,    0,  305,  305,    0,    0,    0,  295,    0,    0,
+    0,  295,  305,    0,  295,    0,  305,  305,    0,    0,
+    0,  305,    0,    0,    0,    0,    0,  305,  295,  305,
+  305,  295,  305,    0,  305,  305,  305,  305,  305,    0,
+  305,  305,  305,  305,  305,  305,  305,  305,  305,  305,
+  305,  305,  305,  305,  305,  305,    0,    0,  305,  305,
+  305,    0,  305,  305,  305,    0,  305,  305,  305,    0,
+    0,  305,    0,  305,    0,    0,  305,  305,  305,  305,
+    0,  305,  305,  305,  305,    0,    0,    0,    0,    0,
+  305,    0,    0,  305,  305,  305,  305,  305,  305,  305,
+  305,    0,  305,  305,  305,  305,  305,    0,    0,  305,
+    0,    0,    0,    0,    0,    0,  305,  305,  305,    0,
+    0,  293,    0,    0,    0,  305,  305,    0,    0,    0,
+    0,  293,    0,    0,  341,  341,  341,  341,  341,    0,
+  341,  341,  341,  341,  341,  341,    0,    0,  341,  341,
+    0,    0,    0,    0,    0,    0,    0,    0,  293,    0,
+    0,    0,  293,    0,    0,  293,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  293,
+    0,    0,  293,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  295,    0,  295,  295,
+  295,  295,  295,    0,    0,    0,    0,    0,    0,    0,
+    0,  295,    0,    0,    0,  295,    0,  295,    0,    0,
+  295,  295,  295,  295,  295,  295,  295,    0,    0,  295,
+  295,  295,    0,    0,    0,    0,  295,  295,    0,    0,
+    0,  295,  295,    0,    0,    0,    0,    0,    0,    0,
+    0,  295,    0,    0,    0,  295,  295,    0,    0,    0,
+  295,    0,    0,  341,    0,    0,  295,    0,  295,  295,
+    0,  295,    0,  295,  295,  295,  295,  295,    0,  295,
+  295,  295,  295,  295,  295,  295,  295,  295,  295,  295,
+  295,  295,  295,  295,  295,    0,    0,  295,  295,  295,
+    0,  295,  295,  295,    0,  295,  295,  295,  417,  415,
+  295,  416,  295,    0,    0,  295,  295,  295,  295,    0,
+  295,  295,  295,  295,  852,    0,  420,  403,  421,  295,
+    0,    0,  295,  295,  295,  295,  295,  295,  295,  295,
+    0,  295,  295,  295,  295,  295,    0,  293,  295,  293,
+  293,  293,  293,  293,    0,  295,  295,  295,    0,    0,
+  299,    0,  293,    0,  295,  295,  293,    0,  293,    0,
+  299,  293,  293,  293,  293,  293,  293,  293,    0,    0,
+  293,  293,  293,    0,    0,    0,    0,  293,  293,    0,
+    0,    0,  293,  293,    0,    0,    0,  299,    0,    0,
+    0,  299,  293,    0,  299,    0,  293,  293,    0,    0,
+    0,  293,    0,    0,    0,    0,    0,  293,  299,  293,
+  293,  299,  293,    0,  293,  293,  293,  293,  293,    0,
+  293,  293,  293,  293,  293,  293,  293,  293,  293,  293,
+  293,  293,  293,  293,  293,  293,    0,    0,  293,  293,
+  293,    0,  293,  293,  293,    0,  293,  293,  293,    0,
+    0,  293,    0,  293,    0,    0,  293,  293,  293,  293,
+    0,  293,  293,  293,  293,    0,    0,    0,    0,    0,
+  293,    0,    0,  293,  293,  293,  293,  293,  293,  293,
+  293,    0,  293,  293,  293,  293,  293,    0,    0,  293,
+    0,    0,    0,    0,    0,    0,  293,  293,  293,    0,
+    0,  297,    0,    0,    0,  293,  293,    0,    0,    0,
+    0,  297,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  297,    0,
+    0,    0,  297,    0,    0,  297,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  297,
+    0,    0,  297,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  299,    0,  299,  299,
+  299,  299,  299,    0,    0,    0,    0,    0,    0,    0,
+    0,  299,    0,    0,    0,  299,    0,  299,    0,    0,
+  299,  299,  299,  299,  299,  299,  299,    0,    0,  299,
+  299,  299,    0,    0,    0,    0,  299,  299,    0,    0,
+    0,  299,  299,    0,    0,    0,    0,    0,    0,    0,
+    0,  299,    0,    0,    0,  299,  299,    0,    0,    0,
+  299,    0,    0,    0,    0,    0,  299,    0,  299,  299,
+    0,  299,    0,  299,  299,  299,  299,  299,    0,  299,
+  299,  299,  299,  299,  299,  299,  299,  299,  299,  299,
+  299,  299,  299,  299,  299,    0,    0,  299,  299,  299,
+    0,  299,  299,  299,    0,  299,  299,  299,  417,  415,
+  299,  416,  299,    0,    0,  299,  299,  299,  299,    0,
+  299,  299,  299,  299,  901,    0,  420,  403,  421,  299,
+    0,    0,  299,  299,  299,  299,  299,  299,  299,  299,
+    0,  299,  299,  299,  299,  299,    0,  297,  299,  297,
+  297,  297,  297,  297,    0,  299,  299,  299,    0,    0,
+  291,    0,  297,    0,  299,  299,  297,    0,  297,    0,
+  291,  297,  297,  297,  297,  297,  297,  297,    0,    0,
+  297,  297,  297,    0,    0,    0,    0,  297,  297,    0,
+    0,    0,  297,  297,    0,    0,    0,  291,    0,    0,
+    0,  291,  297,    0,  291,    0,  297,  297,    0,    0,
+    0,  297,    0,    0,    0,    0,    0,  297,  291,  297,
+  297,  291,  297,    0,  297,  297,  297,  297,  297,    0,
+  297,  297,  297,  297,  297,  297,  297,  297,  297,  297,
+  297,  297,  297,  297,  297,  297,    0,    0,  297,  297,
+  297,    0,  297,  297,  297,    0,  297,  297,  297,    0,
+    0,  297,    0,  297,    0,    0,  297,  297,  297,  297,
+    0,  297,  297,  297,  297,    0,    0,    0,    0,    0,
+  297,    0,    0,  297,  297,  297,  297,  297,  297,  297,
+  297,    0,  297,  297,  297,  297,  297,    0,    0,  297,
+    0,    0,    0,    0,    0,    0,  297,  297,  297,    0,
+    0,  301,    0,    0,    0,  297,  297,    0,    0,    0,
+    0,  301,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  301,    0,
+    0,    0,  301,    0,    0,  301,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  301,
+    0,    0,  301,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  291,    0,  291,  291,
+  291,  291,  291,    0,    0,    0,    0,    0,    0,    0,
+    0,  291,    0,    0,    0,  291,    0,  291,    0,    0,
+  291,  291,  291,  291,  291,  291,  291,    0,    0,  291,
+  291,  291,    0,    0,    0,    0,  291,  291,    0,    0,
+    0,  291,  291,    0,    0,    0,    0,    0,    0,    0,
+    0,  291,    0,    0,    0,  291,  291,    0,    0,    0,
+  291,    0,    0,    0,    0,    0,  291,    0,  291,  291,
+    0,  291,    0,  291,  291,  291,  291,  291,    0,  291,
+  291,  291,  291,  291,  291,  291,  291,  291,  291,  291,
+  291,  291,  291,  291,  291,    0,    0,  291,  291,  291,
+    0,  291,  291,  291,    0,  291,  291,  291,  417,  415,
+  291,  416,  291,    0,    0,  291,  291,  291,  291,    0,
+  291,  291,  291,  291,  946,    0,  420,  403,  421,  291,
+    0,    0,  291,  291,  291,  291,  291,  291,  291,  291,
+    0,  291,  291,  291,  291,  291,    0,  301,  291,  301,
+  301,  301,  301,  301,    0,  291,  291,  291,    0,    0,
+  296,    0,  301,    0,  291,  291,  301,    0,  301,    0,
+  296,  301,  301,  301,  301,  301,  301,  301,    0,    0,
+  301,  301,  301,    0,    0,    0,    0,  301,  301,    0,
+    0,    0,  301,  301,    0,    0,    0,  296,    0,    0,
+    0,  296,  301,    0,  296,    0,  301,  301,    0,    0,
+    0,  301,    0,    0,    0,    0,    0,  301,  296,  301,
+  301,  296,  301,    0,  301,  301,  301,  301,  301,    0,
+  301,  301,  301,  301,  301,  301,  301,  301,  301,  301,
+  301,  301,  301,  301,  301,  301,    0,    0,  301,  301,
+  301,    0,  301,  301,  301,    0,  301,  301,  301,    0,
+    0,  301,    0,  301,    0,    0,  301,  301,  301,  301,
+    0,  301,  301,  301,  301,    0,    0,    0,    0,    0,
+  301,    0,    0,  301,  301,  301,  301,  301,  301,  301,
+  301,    0,  301,  301,  301,  301,  301,    0,    0,  301,
+    0,    0,    0,    0,    0,    0,  301,  301,  301,    0,
+    0,  294,    0,    0,    0,  301,  301,    0,    0,    0,
+    0,  294,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  294,    0,
+    0,    0,  294,    0,    0,  294,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  294,
+    0,    0,  294,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  296,    0,  296,  296,
+  296,  296,  296,    0,    0,    0,    0,    0,    0,    0,
+    0,  296,    0,    0,    0,  296,    0,  296,    0,    0,
+  296,  296,  296,  296,  296,  296,  296,    0,    0,  296,
+  296,  296,    0,    0,    0,    0,  296,  296,    0,    0,
+    0,  296,  296,    0,    0,    0,    0,    0,    0,    0,
+    0,  296,    0,    0,    0,  296,  296,    0,    0,    0,
+  296,    0,    0,    0,    0,    0,  296,    0,  296,  296,
+    0,  296,    0,  296,  296,  296,  296,  296,    0,  296,
+  296,  296,  296,  296,  296,  296,  296,  296,  296,  296,
+  296,  296,  296,  296,  296,    0,    0,  296,  296,  296,
+    0,  296,  296,  296,    0,  296,  296,  296,  417,  415,
+  296,  416,  296,    0,    0,  296,  296,  296,  296,    0,
+  296,  296,  296,  296,  962,    0,  420,  403,  421,  296,
+    0,    0,  296,  296,  296,  296,  296,  296,  296,  296,
+    0,  296,  296,  296,  296,  296,    0,  294,  296,  294,
+  294,  294,  294,  294,    0,  296,  296,  296,    0,    0,
+  312,    0,  294,    0,  296,  296,  294,    0,  294,    0,
+  312,  294,  294,  294,  294,  294,  294,  294,    0,    0,
+  294,  294,  294,    0,    0,    0,    0,  294,  294,    0,
+    0,    0,  294,  294,    0,    0,    0,  312,    0,    0,
+    0,  312,  294,    0,  312,    0,  294,  294,    0,    0,
+    0,  294,    0,    0,    0,    0,    0,  294,  312,  294,
+  294,  312,  294,    0,  294,  294,  294,  294,  294,    0,
+  294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
+  294,  294,  294,  294,  294,  294,    0,    0,  294,  294,
+  294,    0,  294,  294,  294,    0,  294,  294,  294,    0,
+    0,  294,    0,  294,    0,    0,  294,  294,  294,  294,
+    0,  294,  294,  294,  294,    0,    0,    0,    0,    0,
+  294,    0,    0,  294,  294,  294,  294,  294,  294,  294,
+  294,    0,  294,  294,  294,  294,  294,    0,    0,  294,
+    0,    0,    0,    0,    0,    0,  294,  294,  294,    0,
+    0,  310,    0,    0,    0,  294,  294,    0,    0,    0,
+    0,  310,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  310,    0,
+    0,    0,  310,    0,    0,  310,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  310,
+    0,    0,  310,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  312,    0,  312,  312,
+  312,  312,  312,    0,    0,    0,    0,    0,    0,    0,
+    0,  312,    0,    0,    0,  312,    0,  312,    0,    0,
+  312,  312,  312,  312,  312,  312,  312,    0,    0,  312,
+  312,  312,    0,    0,    0,    0,  312,  312,    0,    0,
+    0,  312,  312,    0,    0,    0,    0,    0,    0,    0,
+    0,  312,    0,    0,    0,  312,  312,    0,    0,    0,
+  312,    0,    0,    0,    0,    0,  312,    0,  312,  312,
+    0,  312,    0,  312,  312,  312,  312,  312,    0,  312,
+  312,  312,  312,  312,  312,  312,  312,  312,  312,  312,
+  312,  312,  312,  312,  312,    0,    0,  312,  312,  312,
+    0,  312,  312,  312,    0,  312,  312,  312,  417,  415,
+  312,  416,  312,    0,    0,  312,  312,  312,  312,    0,
+  312,  312,  312,  312,    0,    0,  420,  403,  421,  312,
+    0,    0,  312,  312,  312,  312,  312,  312,  312,  312,
+    0,  312,  312,  312,  312,  312,    0,  310,  312,  310,
+  310,  310,  310,  310,    0,  312,  312,  312,    0,    0,
+  300,    0,  310,    0,  312,  312,  310,    0,  310,    0,
+  300,  310,  310,  310,  310,  310,  310,  310,    0,    0,
+  310,  310,  310,    0,    0,    0,    0,  310,  310,    0,
+    0,    0,  310,  310,    0,    0,    0,  300,    0,    0,
+    0,  300,  310,    0,  300,    0,  310,  310,    0,    0,
+    0,  310,    0,    0,    0,    0,    0,  310,  300,  310,
+  310,  300,  310,    0,  310,  310,  310,  310,  310,    0,
+  310,  310,  310,  310,  310,  310,  310,  310,  310,  310,
+  310,  310,  310,  310,  310,  310,    0,    0,  310,  310,
+  310,    0,  310,  310,  310,    0,  310,  310,  310,    0,
+    0,  310,    0,  310,    0,    0,  310,  310,  310,  310,
+    0,  310,  310,  310,  310,    0,    0,    0,    0,    0,
+  310,    0,    0,  310,  310,  310,  310,  310,  310,  310,
+  310,    0,  310,  310,  310,  310,  310,    0,    0,  310,
+    0,    0,    0,    0,    0,    0,  310,  310,  310,    0,
+    0,  298,    0,    0,    0,  310,  310,    0,    0,    0,
+    0,  298,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  298,    0,
+    0,    0,  298,    0,    0,  298,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  298,
+    0,    0,  298,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  300,    0,  300,  300,
+  300,  300,  300,    0,    0,    0,    0,    0,    0,    0,
+    0,  300,    0,    0,    0,  300,    0,  300,    0,    0,
+  300,  300,  300,  300,  300,  300,  300,    0,    0,  300,
+  300,  300,    0,    0,    0,    0,  300,  300,    0,    0,
+    0,  300,  300,    0,    0,    0,    0,    0,    0,    0,
+    0,  300,    0,    0,    0,  300,  300,    0,    0,    0,
+  300,    0,    0,    0,    0,    0,  300,    0,  300,  300,
+    0,  300,    0,  300,  300,  300,  300,  300,    0,  300,
+  300,  300,  300,  300,  300,  300,  300,  300,  300,  300,
+  300,  300,  300,  300,  300,    0,    0,  300,  300,  300,
+    0,  300,  300,  300,    0,  300,  300,  300,  247,  247,
+  300,  247,  300,    0,    0,  300,  300,  300,  300,    0,
+  300,  300,  300,  300,    0,    0,  247,  247,  247,  300,
+    0,    0,  300,  300,  300,  300,  300,  300,  300,  300,
+    0,  300,  300,  300,  300,  300,    0,  298,  300,  298,
+  298,  298,  298,  298,    0,  300,  300,  300,    0,    0,
+  304,    0,  298,    0,  300,  300,  298,    0,  298,    0,
+  304,  298,  298,  298,  298,  298,  298,  298,    0,    0,
+  298,  298,  298,    0,    0,    0,    0,  298,  298,    0,
+    0,    0,  298,  298,    0,    0,    0,  304,    0,    0,
+    0,  304,  298,    0,  304,    0,  298,  298,    0,    0,
+    0,  298,    0,    0,    0,    0,    0,  298,  304,  298,
+  298,  304,  298,    0,  298,  298,  298,  298,  298,    0,
+  298,  298,  298,  298,  298,  298,  298,  298,  298,  298,
+  298,  298,  298,  298,  298,  298,    0,    0,  298,  298,
+  298,    0,  298,  298,  298,    0,  298,  298,  298,    0,
+    0,  298,    0,  298,    0,    0,  298,  298,  298,  298,
+    0,  298,  298,  298,  298,    0,    0,    0,    0,    0,
+  298,    0,    0,  298,  298,  298,  298,  298,  298,  298,
+  298,    0,  298,  298,  298,  298,  298,    0,    0,  298,
+    0,    0,    0,    0,    0,    0,  298,  298,  298,    0,
+    0,  303,    0,    0,    0,  298,  298,    0,    0,    0,
+    0,  303,    0,    0,  247,  247,  247,  247,  247,    0,
+  247,  247,  247,  247,  247,  247,    0,    0,  247,  247,
+    0,    0,    0,    0,    0,    0,    0,    0,  303,    0,
+    0,    0,  303,    0,    0,  303,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  303,
+    0,    0,  303,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  304,    0,  304,  304,
+  304,  304,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  304,    0,    0,    0,  304,    0,  304,    0,    0,
+  304,  304,  304,  304,  304,  304,  304,    0,    0,  304,
+  304,  304,    0,    0,    0,    0,  304,  304,    0,    0,
+    0,  304,  304,    0,    0,    0,    0,    0,    0,    0,
+    0,  304,    0,    0,    0,  304,  304,    0,    0,    0,
+  304,    0,    0,    0,    0,    0,  304,  567,  304,  304,
+  333,  304,  334,  304,  304,  304,  304,  304,    0,  304,
+  304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
+  304,  304,  304,  304,  304,    0,    0,  304,  304,  304,
+    0,  304,  304,  304,    0,  304,  304,  304,    0,    0,
+  304,    0,  304,    0,    0,  304,  304,  304,  304,    0,
+  304,  304,  304,  304,    0,  753,    0,  751,  150,  304,
+  151,    0,  304,  304,  304,  304,  304,  304,  304,  304,
+    0,  304,  304,  304,  304,  304,  576,  303,  304,  303,
+  303,  303,  303,    0,    0,  304,  304,  304,    0,    0,
+    0,    0,  303,    0,  304,  304,  303,    0,  303,    0,
+    0,  303,  303,  303,  303,  303,  303,  303,    0,    0,
+  303,  303,  303,    0,    0,    0,    0,  303,  303,    0,
+    0,    0,  303,  303,    0,    0,    0,    0,    0,    0,
+    0,    0,  303,    0,    0,    0,  303,  303,    0,    0,
+    0,  303,    0,    0,    0,    0,    0,  303,    0,  303,
+  303,    0,  303,    0,  303,  303,  303,  303,  303,    0,
+  303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+  303,  303,  303,  303,  303,  303,    0,    0,  303,  303,
+  303,    0,  303,  303,  303,    0,  303,  303,  303,    0,
+  338,  303,    0,  303,    0,    0,  303,  303,  303,  303,
+  338,  303,  303,  303,  303,    0,    0,    0,    0,    0,
+  303,    0,    0,  303,  303,  303,  303,  303,  303,  303,
+  303,    0,  303,  303,  303,  303,  303,  338,    0,  303,
+  338,  338,  338,  338,  338,  338,  303,  303,  303,    0,
+    0,    0,    0,    0,    0,  303,  303,    0,    0,    0,
+    0,    0,    0,    0,    0,  336,  337,  338,    0,    0,
+  339,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  149,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  752,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  292,  176,    0,    0,    0,    0,  178,  179,    0,
+    0,  292,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,    0,  340,    0,    0,    0,  292,    0,
+    0,  187,  292,    0,    0,  292,    0,    0,    0,    0,
+    0,    0,    0,    0,  177,    0,    0,    0,    0,  292,
+    0,    0,  292,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,    0,    0,    0,    0,    0,  338,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  338,  338,  338,    0,  338,    0,  338,    0,    0,
+  338,  338,  338,  338,  338,  338,  338,    0,    0,  338,
+  338,  338,    0,    0,    0,    0,  338,  338,    0,    0,
+    0,  338,  338,    0,    0,    0,    0,    0,    0,    0,
+    0,  338,    0,    0,    0,  338,  338,    0,    0,    0,
+  338,    0,    0,    0,    0,    0,  338,    0,  338,  338,
+    0,  338,    0,  338,  338,  338,  338,  338,    0,  338,
+  338,  338,  338,  338,  338,  338,  338,  338,  338,  338,
+  338,  338,  338,  338,  338,    0,    0,  338,  338,  338,
+    0,  338,  338,  338,    0,  338,  338,  338,    0,    0,
+  338,    0,  338,    0,    0,  338,  338,  338,  338,    0,
+    0,  338,  338,  338,    0,    0,    0,    0,    0,  338,
+    0,    0,  338,  338,  338,  338,  338,  338,  338,  338,
+    0,  338,  338,  338,  338,  338,    0,  292,  338,  292,
+  292,    0,    0,    0,    0,  338,  338,  338,    0,    0,
+  302,    0,  292,    0,  338,  338,  292,    0,  292,    0,
+  302,  292,  292,  292,  292,  292,  292,  292,    0,    0,
+  292,  292,  292,    0,    0,    0,    0,  292,  292,    0,
+    0,    0,  292,  292,    0,    0,    0,  302,    0,    0,
+    0,  302,  292,    0,  302,    0,  292,  292,    0,    0,
+    0,  292,    0,    0,    0,    0,    0,  292,  302,  292,
+  292,  302,  292,    0,  292,  292,  292,  292,  292,    0,
+  292,  292,  292,  292,  292,  292,  292,  292,  292,  292,
+  292,  292,  292,  292,  292,  292,    0,    0,  292,  292,
+  292,    0,  292,  292,  292,    0,  292,  292,  292,    0,
+    0,  292,    0,  292,    0,    0,  292,  292,  292,  292,
+    0,  292,  292,  292,  292,    0,    0,    0,    0,    0,
+  292,    0,    0,  292,  292,  292,  292,  292,  292,  292,
+  292,    0,  292,  292,  292,  292,  292,    0,    0,  292,
+    0,    0,    0,    0,    0,    0,  292,  292,  292,    0,
+    0,    0,    0,    0,    0,  292,  292,  501,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  501,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  501,  501,
+  501,  501,  501,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  302,    0,  302,  302,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  302,    0,    0,    0,  302,    0,  302,    0,    0,
+  302,  302,  302,  302,  302,  302,  302,    0,    0,  302,
+  302,  302,    0,    0,    0,    0,  302,  302,    0,    0,
+    0,  302,  302,    0,    0,    0,    0,    0,    0,    0,
+    0,  302,    0,    0,    0,  302,  302,    0,    0,    0,
+  302,    0,    0,    0,    0,    0,  302,    0,  302,  302,
+    0,  302,    0,  302,  302,  302,  302,  302,    0,  302,
+  302,  302,  302,  302,  302,  302,  302,  302,  302,  302,
+  302,  302,  302,  302,  302,    0,    0,  302,  302,  302,
+    0,  302,  302,  302,    0,  302,  302,  302,    0,    0,
+  302,    0,  302,    0,    0,  302,  302,  302,  302,    0,
+  302,  302,  302,  302,    0,    0,    0,    0,    0,  302,
+    0,    0,  302,  302,  302,  302,  302,  302,  302,  302,
+    0,  302,  302,  302,  302,  302,    0,    0,  302,    0,
+    0,    0,    0,  501,    0,  302,  302,  302,    0,    0,
+    0,  502,    0,    0,  302,  302,    0,    0,  501,  501,
+  501,  502,  501,    0,  501,    0,    0,  501,  501,  501,
+  501,  501,  501,  501,    0,    0,  501,  501,  501,    0,
+    0,    0,    0,  501,  501,    0,    0,    0,  501,  501,
+    0,    0,  502,  502,  502,  502,  502,    0,  501,    0,
+    0,    0,  501,  501,    0,    0,    0,  501,    0,    0,
+    0,    0,    0,  501,    0,  501,  501,    0,  501,    0,
+  501,  501,  501,  501,  501,    0,  501,  501,  501,  501,
+  501,  501,  501,  501,  501,  501,  501,  501,  501,  501,
+  501,  501,    0,    0,  501,  501,  501,    0,  501,  501,
+  501,    0,  501,  501,  501,    0,    0,  501,    0,  501,
+    0,    0,  501,  501,  501,  501,    0,    0,  501,  501,
+  501,    0,    0,    0,    0,    0,  501,    0,    0,  501,
+  501,  501,  501,  501,  501,  501,  501,    0,  501,  501,
+  501,  501,  501,    0,    0,  501,    0,    0,    0,    0,
+    0,    0,  501,  501,  501,    0,  493,    0,    0,    0,
+    0,  501,  501,    0,    0,    0,  493,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  499,  499,
+  493,  499,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  502,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  502,  502,  502,    0,  502,    0,  502,    0,
+    0,  502,  502,  502,  502,  502,  502,  502,    0,    0,
+  502,  502,  502,    0,    0,    0,    0,  502,  502,    0,
+    0,    0,  502,  502,    0,    0,    0,    0,    0,    0,
+    0,    0,  502,    0,    0,    0,  502,  502,    0,    0,
+    0,  502,    0,    0,    0,    0,    0,  502,    0,  502,
+  502,    0,  502,    0,  502,  502,  502,  502,  502,    0,
+  502,  502,  502,  502,  502,  502,  502,  502,  502,  502,
+  502,  502,  502,  502,  502,  502,    0,    0,  502,  502,
+  502,    0,  502,  502,  502,    0,  502,  502,  502,    0,
+    0,  502,    0,  502,    0,    0,  502,  502,  502,  502,
+    0,    0,  502,  502,  502,    0,    0,    0,    0,    0,
+  502,    0,    0,  502,  502,  502,  502,  502,  502,  502,
+  502,    0,  502,  502,  502,  502,  502,    0,    0,  502,
+    0,    0,  493,    0,    0,    0,  502,  502,    0,    0,
+  507,    0,    0,    0,    0,  502,  502,  499,  499,  499,
+  507,  493,    0,  493,    0,    0,  493,  493,  493,  493,
+  493,  493,  493,    0,    0,  493,  493,  493,    0,    0,
+    0,    0,  493,  493,    0,    0,    0,  493,  493,    0,
+    0,  507,  507,  507,  507,  507,    0,  493,    0,    0,
+    0,  493,  493,    0,    0,    0,  493,    0,    0,    0,
+    0,    0,  493,    0,  493,  493,    0,  493,    0,  493,
+  493,  493,  493,  493,    0,  493,  493,  493,  493,  493,
+  493,  493,  493,  493,  493,  493,  493,  493,  493,  493,
+  493,    0,    0,  493,  493,  493,    0,  493,  493,  493,
+    0,  493,  493,  493,    0,    0,  493,    0,  493,    0,
+    0,  493,  493,  493,  493,    0,    0,  493,  493,  493,
+    0,    0,    0,    0,    0,  493,    0,    0,  493,  493,
+  493,  493,  493,  493,  493,  493,    0,  493,  493,  493,
+  493,  493,    0,    0,  493,    0,    0,    0,    0,    0,
+    0,  493,  493,  493,    0,  504,    0,    0,    0,    0,
+  493,  493,    0,    0,    0,  504,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  504,  504,  504,  504,
+  504,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  507,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  507,  507,    0,    0,  507,    0,  507,    0,    0,
+  507,  507,  507,  507,  507,  507,  507,    0,    0,  507,
+  507,  507,    0,    0,    0,    0,  507,  507,    0,    0,
+    0,  507,  507,    0,    0,    0,    0,    0,    0,    0,
+    0,  507,    0,    0,    0,  507,  507,    0,    0,    0,
+  507,    0,    0,    0,    0,    0,  507,    0,  507,  507,
+    0,  507,    0,  507,  507,  507,  507,  507,    0,  507,
+  507,  507,  507,  507,  507,  507,  507,  507,  507,  507,
+  507,  507,  507,  507,  507,    0,    0,  507,  507,  507,
+    0,  507,  507,  507,    0,  507,  507,  507,    0,    0,
+  507,    0,  507,    0,    0,  507,  507,  507,  507,    0,
+    0,  507,  507,  507,    0,    0,    0,    0,    0,  507,
+    0,    0,  507,  507,  507,  507,  507,  507,  507,  507,
+    0,  507,  507,  507,  507,  507,    0,    0,  507,    0,
+    0,  504,    0,    0,    0,  507,  507,  507,  505,    0,
+    0,    0,    0,    0,  507,  507,  504,  504,  505,    0,
+  504,    0,  504,    0,    0,  504,  504,  504,  504,  504,
+  504,  504,    0,    0,  504,  504,  504,    0,    0,    0,
+    0,  504,  504,    0,    0,    0,  504,  504,    0,  505,
+  505,  505,  505,  505,    0,    0,  504,    0,    0,    0,
+  504,  504,    0,    0,    0,  504,    0,    0,    0,    0,
+    0,  504,    0,  504,  504,    0,  504,    0,  504,  504,
+  504,  504,  504,    0,  504,  504,  504,  504,  504,  504,
+  504,  504,  504,  504,  504,  504,  504,  504,  504,  504,
+    0,    0,  504,  504,  504,    0,  504,  504,  504,    0,
+  504,  504,  504,    0,    0,  504,    0,  504,    0,    0,
+  504,  504,  504,  504,    0,    0,  504,  504,  504,    0,
+    0,    0,    0,    0,  504,    0,    0,  504,  504,  504,
+  504,  504,  504,  504,  504,    0,  504,  504,  504,  504,
+  504,    0,    0,  504,    0,    0,    0,    0,    0,    0,
+  504,  504,  504,  506,    0,    0,    0,    0,    0,  504,
+  504,    0,    0,  506,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  506,  506,  506,  506,  506,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  505,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  505,
+  505,    0,    0,  505,    0,  505,    0,    0,  505,  505,
+  505,  505,  505,  505,  505,    0,    0,  505,  505,  505,
+    0,    0,    0,    0,  505,  505,    0,    0,    0,  505,
+  505,    0,    0,    0,    0,    0,    0,    0,    0,  505,
+    0,    0,    0,  505,  505,    0,    0,    0,  505,    0,
+    0,    0,    0,    0,  505,    0,  505,  505,    0,  505,
+    0,  505,  505,  505,  505,  505,    0,  505,  505,  505,
+  505,  505,  505,  505,  505,  505,  505,  505,  505,  505,
+  505,  505,  505,    0,    0,  505,  505,  505,    0,  505,
+  505,  505,    0,  505,  505,  505,    0,    0,  505,    0,
+  505,    0,    0,  505,  505,  505,  505,    0,    0,  505,
+  505,  505,    0,    0,    0,    0,    0,  505,    0,    0,
+  505,  505,  505,  505,  505,  505,  505,  505,    0,  505,
+  505,  505,  505,  505,    0,    0,  505,    0,    0,  506,
+    0,    0,    0,  505,  505,  505,  313,    0,    0,    0,
+    0,    0,  505,  505,  506,  506,  313,    0,  506,    0,
+  506,    0,    0,  506,  506,  506,  506,  506,  506,  506,
+    0,    0,  506,  506,  506,    0,    0,    0,    0,  506,
+  506,    0,    0,  313,  506,  506,    0,  313,    0,    0,
+  313,    0,    0,    0,  506,    0,    0,    0,  506,  506,
+    0,    0,    0,  506,  313,    0,    0,    0,    0,  506,
+    0,  506,  506,    0,  506,    0,  506,  506,  506,  506,
+  506,    0,  506,  506,  506,  506,  506,  506,  506,  506,
+  506,  506,  506,  506,  506,  506,  506,  506,    0,    0,
+  506,  506,  506,    0,  506,  506,  506,    0,  506,  506,
+  506,    0,    0,  506,    0,  506,    0,    0,  506,  506,
+  506,  506,    0,    0,  506,  506,  506,    0,    0,    0,
+    0,    0,  506,    0,    0,  506,  506,  506,  506,  506,
+  506,  506,  506,    0,  506,  506,  506,  506,  506,    0,
+    0,  506,    0,    0,    0,    0,    0,    0,  506,  506,
+  506,  309,    0,    0,    0,    0,    0,  506,  506,    0,
+    0,  309,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  309,    0,
+    0,    0,  309,    0,    0,  309,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  309,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  313,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  313,    0,    0,
+    0,  313,    0,  313,    0,    0,  313,  313,  313,  313,
+  313,  313,  313,    0,    0,  313,  313,  313,    0,    0,
+    0,    0,  313,  313,    0,    0,    0,  313,  313,    0,
+    0,    0,    0,    0,    0,    0,    0,  313,    0,    0,
+    0,  313,  313,    0,    0,    0,  313,    0,    0,    0,
+    0,    0,  313,    0,  313,  313,    0,  313,    0,  313,
+  313,  313,  313,  313,    0,  313,  313,  313,  313,  313,
+  313,  313,  313,  313,  313,  313,  313,  313,  313,  313,
+  313,    0,    0,  313,  313,  313,    0,  313,  313,  313,
+    0,  313,  313,  313,    0,  503,  313,    0,  313,    0,
+    0,  313,  313,  313,  313,  503,  313,  313,  313,  313,
+    0,    0,    0,    0,    0,  313,    0,    0,  313,  313,
+  313,  313,  313,  313,  313,  313,    0,  313,  313,  313,
+  313,  313,    0,    0,  313,    0,  503,  309,  503,  503,
+  503,  313,  313,  313,    0,    0,    0,    0,    0,    0,
+  313,  313,  309,    0,    0,    0,  309,    0,  309,    0,
+    0,  309,  309,  309,  309,  309,  309,  309,    0,    0,
+  309,  309,  309,    0,    0,    0,    0,  309,  309,    0,
+    0,    0,  309,  309,    0,    0,    0,    0,    0,    0,
+    0,    0,  309,    0,    0,    0,  309,  309,    0,    0,
+    0,  309,    0,    0,    0,    0,    0,  309,    0,  309,
+  309,    0,  309,    0,  309,  309,  309,  309,  309,    0,
+  309,  309,  309,  309,  309,  309,  309,  309,  309,  309,
+  309,  309,  309,  309,  309,  309,    0,    0,  309,  309,
+  309,    0,  309,  309,  309,    0,  309,  309,  309,    0,
+  509,  309,    0,  309,    0,    0,  309,  309,  309,  309,
+  509,  309,  309,  309,  309,    0,    0,    0,    0,    0,
+  309,    0,    0,  309,  309,  309,  309,  309,  309,  309,
+  309,    0,  309,  309,  309,  309,  309,    0,    0,  309,
+    0,  509,    0,    0,  509,    0,  309,  309,  309,    0,
+    0,    0,    0,    0,    0,  309,  309,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  503,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  503,    0,    0,    0,
+  503,    0,  503,    0,    0,  503,  503,  503,  503,  503,
+  503,  503,    0,    0,  503,  503,  503,    0,    0,    0,
+    0,  503,  503,    0,    0,    0,  503,  503,    0,    0,
+    0,    0,    0,    0,    0,    0,  503,    0,    0,    0,
+  503,  503,    0,    0,    0,  503,    0,    0,    0,    0,
+    0,  503,    0,  503,  503,    0,  503,    0,  503,  503,
+  503,  503,  503,    0,  503,  503,  503,  503,  503,  503,
+  503,  503,  503,  503,  503,  503,  503,  503,  503,  503,
+    0,    0,  503,  503,  503,    0,  503,  503,  503,    0,
+  503,  503,  503,    0,  512,  503,    0,  503,    0,    0,
+  503,  503,  503,  503,  512,    0,  503,  503,  503,    0,
+    0,    0,    0,    0,  503,    0,    0,  503,  503,  503,
+  503,  503,  503,  503,  503,    0,  503,  503,  503,  503,
+  503,    0,    0,  503,    0,  512,  509,    0,  512,    0,
+  503,  503,  503,    0,    0,    0,    0,    0,    0,  503,
+  503,  509,    0,    0,    0,  509,    0,  509,    0,    0,
+  509,  509,  509,  509,  509,  509,  509,    0,    0,  509,
+  509,  509,    0,    0,    0,    0,  509,  509,    0,    0,
+    0,  509,  509,    0,    0,    0,    0,    0,    0,    0,
+    0,  509,    0,    0,    0,  509,  509,    0,    0,    0,
+  509,    0,    0,    0,    0,    0,  509,    0,  509,  509,
+    0,  509,    0,  509,  509,  509,  509,  509,    0,  509,
+  509,  509,  509,  509,  509,  509,  509,  509,  509,  509,
+  509,  509,  509,  509,  509,    0,    0,  509,  509,  509,
+    0,  509,  509,  509,    0,  509,  509,  509,    0,  511,
+  509,    0,  509,    0,    0,  509,  509,  509,  509,  511,
+    0,  509,  509,  509,    0,    0,    0,    0,    0,  509,
+    0,    0,  509,  509,  509,  509,  509,  509,  509,  509,
+    0,  509,  509,  509,  509,  509,    0,    0,  509,    0,
+  511,    0,    0,  511,    0,  509,  509,  509,    0,    0,
+    0,    0,    0,    0,  509,  509,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  512,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  512,    0,    0,    0,  512,
+    0,  512,    0,    0,  512,  512,  512,  512,  512,  512,
+  512,    0,    0,  512,  512,  512,    0,    0,    0,    0,
+  512,  512,    0,    0,    0,  512,  512,    0,    0,    0,
+    0,    0,    0,    0,    0,  512,    0,    0,    0,  512,
+  512,    0,    0,    0,  512,    0,    0,    0,    0,    0,
+  512,    0,  512,  512,    0,  512,    0,  512,  512,  512,
+  512,  512,    0,  512,  512,  512,  512,  512,  512,  512,
+  512,  512,  512,  512,  512,  512,  512,  512,  512,    0,
+    0,  512,  512,  512,    0,  512,  512,  512,    0,  512,
+  512,  512,    0,  510,  512,    0,  512,    0,    0,  512,
+  512,  512,  512,  510,    0,  512,  512,  512,    0,    0,
+    0,    0,    0,  512,    0,    0,  512,  512,  512,  512,
+  512,  512,  512,  512,    0,  512,  512,  512,  512,  512,
+    0,    0,  512,    0,  510,  511,    0,  510,    0,  512,
+  512,  512,    0,    0,    0,    0,    0,    0,  512,  512,
+  511,    0,    0,    0,  511,    0,  511,    0,    0,  511,
+  511,  511,  511,  511,  511,  511,    0,    0,  511,  511,
+  511,    0,    0,    0,    0,  511,  511,    0,    0,    0,
+  511,  511,    0,    0,    0,    0,    0,    0,    0,    0,
+  511,    0,    0,    0,  511,  511,    0,    0,    0,  511,
+    0,    0,    0,    0,    0,  511,    0,  511,  511,    0,
+  511,    0,  511,  511,  511,  511,  511,    0,  511,  511,
+  511,  511,  511,  511,  511,  511,  511,  511,  511,  511,
+  511,  511,  511,  511,    0,    0,  511,  511,  511,    0,
+  511,  511,  511,    0,  511,  511,  511,    0,  236,  511,
+    0,  511,    0,    0,  511,  511,  511,  511,  236,    0,
+  511,  511,  511,    0,    0,    0,    0,    0,  511,    0,
+    0,  511,  511,  511,  511,  511,  511,  511,  511,    0,
+  511,  511,  511,  511,  511,    0,    0,  511,    0,    0,
+  236,    0,  236,    0,  511,  511,  511,    0,    0,    0,
+    0,    0,    0,  511,  511,    0,    0,    0,    0,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  510,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  510,    0,    0,    0,  510,    0,
+  510,    0,    0,  510,  510,  510,  510,  510,  510,  510,
+    0,    0,  510,  510,  510,    0,    0,    0,    0,  510,
+  510,    0,    0,    0,  510,  510,    0,    0,    0,    0,
+    0,    0,    0,    0,  510,    0,    0,    0,  510,  510,
+    0,    0,    0,  510,    0,    0,    0,    0,    0,  510,
+    0,  510,  510,    0,  510,    0,  510,  510,  510,  510,
+  510,    0,  510,  510,  510,  510,  510,  510,  510,  510,
+  510,  510,  510,  510,  510,  510,  510,  510,    0,    0,
+  510,  510,  510,    0,  510,  510,  510,    0,  510,  510,
+  510,    0,  513,  510,    0,  510,    0,    0,  510,  510,
+  510,  510,  513,    0,  510,  510,  510,    0,    0,    0,
+    0,    0,  510,    0,    0,  510,  510,  510,  510,  510,
+  510,  510,  510,    0,  510,  510,  510,  510,  510,    0,
+    0,  510,    0,  513,  236,    0,  513,    0,  510,  510,
+  510,    0,    0,    0,    0,    0,    0,  510,  510,    0,
+    0,    0,    0,  236,    0,  236,    0,    0,  236,  236,
+  236,  236,  236,  236,  236,    0,    0,  236,  236,  236,
+    0,    0,    0,    0,  236,  236,    0,    0,    0,  236,
+  236,    0,    0,    0,    0,    0,    0,    0,    0,  236,
+    0,    0,    0,  236,  236,    0,    0,    0,  236,    0,
+    0,    0,    0,    0,  236,    0,  236,  236,    0,  236,
+    0,  236,  236,  236,  236,  236,    0,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,  236,    0,    0,  236,  236,  236,    0,  236,
+  236,  236,    0,  236,  236,  236,    0,  508,  236,    0,
+  236,    0,    0,  236,  236,  236,  236,  508,    0,  236,
+  236,  236,    0,    0,    0,    0,    0,  236,    0,    0,
+  236,  236,  236,  236,  236,  236,  236,  236,    0,  236,
+  236,  236,  236,  236,    0,    0,  236,    0,  508,    0,
+    0,  508,    0,  236,  236,  236,    0,    0,    0,    0,
+    0,    0,  236,  236,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  513,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  513,    0,    0,    0,  513,    0,  513,
+    0,    0,  513,  513,  513,  513,  513,  513,  513,    0,
+    0,  513,  513,  513,    0,    0,    0,    0,  513,  513,
+    0,    0,    0,  513,  513,    0,    0,    0,    0,    0,
+    0,    0,    0,  513,   57,    0,    0,  513,  513,    0,
+    0,    0,  513,    0,   57,    0,    0,    0,  513,    0,
+  513,  513,    0,  513,    0,  513,  513,  513,  513,  513,
+    0,  513,  513,  513,  513,  513,  513,  513,  513,  513,
+  513,  513,  513,  513,  513,  513,  513,    0,    0,  513,
+  513,  513,    0,  513,  513,  513,    0,  513,  513,  513,
+    0,    0,  513,    0,  513,    0,    0,  513,  513,  513,
+  513,    0,    0,  513,  513,  513,    0,    0,    0,    0,
+    0,  513,    0,    0,  513,  513,  513,  513,  513,  513,
+  513,  513,    0,  513,  513,  513,  513,  513,    0,    0,
+  513,    0,    0,  508,    0,    0,    0,  513,  513,  513,
+    0,    0,    0,    0,    0,    0,  513,  513,  508,    0,
+    0,    0,  508,    0,  508,    0,    0,  508,  508,  508,
+  508,  508,  508,  508,    0,    0,  508,  508,  508,    0,
+    0,    0,    0,  508,  508,    0,    0,    0,  508,  508,
+    0,    0,    0,    0,    0,  142,    0,    0,  508,    0,
+    0,    0,  508,  508,    0,  142,    0,  508,    0,    0,
+    0,    0,    0,  508,    0,  508,  508,    0,  508,    0,
+  508,  508,  508,  508,  508,    0,  508,  508,  508,  508,
+  508,  508,  508,  508,  508,  508,  508,  508,  508,  508,
+  508,  508,    0,    0,  508,  508,  508,    0,  508,  508,
+  508,    0,  508,  508,  508,    0,    0,  508,    0,  508,
+    0,    0,  508,  508,  508,  508,    0,    0,  508,  508,
+  508,    0,    0,    0,    0,    0,  508,    0,    0,  508,
+  508,  508,  508,  508,  508,  508,  508,    0,  508,  508,
+  508,  508,  508,    0,    0,  508,    0,    0,    0,    0,
+   57,    0,  508,  508,  508,    0,    0,    0,    0,    0,
+    0,  508,  508,    0,    0,  164,  164,    0,    0,   57,
+    0,   57,    0,    0,   57,   57,   57,   57,   57,   57,
+   57,    0,    0,   57,   57,   57,    0,    0,    0,    0,
+   57,   57,    0,    0,    0,   57,   57,    0,    0,    0,
+    0,    0,    0,    0,    0,   57,    0,    0,    0,   57,
+   57,    0,    0,    0,   57,    0,    0,    0,    0,    0,
+   57,    0,   57,   57,    0,   57,    0,   57,   57,   57,
+   57,   57,    0,   57,   57,   57,   57,   57,   57,   57,
+   57,   57,   57,   57,   57,   57,   57,   57,   57,    0,
+    0,   57,   57,   57,    0,   57,   57,   57,    0,   57,
+   57,   57,    0,  355,   57,    0,   57,    0,    0,   57,
+   57,   57,   57,  355,    0,   57,   57,   57,    0,    0,
+    0,    0,    0,   57,    0,    0,   57,   57,   57,   57,
+   57,   57,   57,   57,    0,   57,   57,   57,   57,   57,
+    0,  142,   57,    0,  355,    0,    0,    0,    0,   57,
+   57,   57,    0,    0,    0,    0,  164,  164,   57,   57,
+  142,  355,  142,    0,    0,  142,  142,  142,  142,  142,
+  142,  142,    0,    0,  142,  142,  142,    0,    0,    0,
+    0,  142,  142,    0,    0,    0,  142,  142,    0,    0,
+    0,    0,    0,    0,    0,    0,  142,    0,    0,    0,
+  142,  142,    0,    0,    0,  142,    0,    0,    0,    0,
+    0,  142,    0,  142,  142,    0,  142,    0,  142,  142,
+  142,  142,  142,    0,  142,  142,  142,  142,  142,  142,
+  142,  142,  142,  142,  142,  142,  142,  142,  142,  142,
+    0,    0,  142,  142,  142,    0,  142,  142,  142,    0,
+  142,  142,  142,    0,  125,  142,    0,  142,    0,    0,
+  142,  142,  142,  142,  125,    0,  142,  142,  142,    0,
+    0,    0,    0,    0,  142,    0,    0,  142,  142,  142,
+  142,  142,  142,  142,  142,    0,  142,  142,  142,  142,
+  142,    0,    0,  142,    0,    0,    0,    0,  125,    0,
+  142,  142,  142,    0,    0,    0,    0,    0,    0,  142,
+  142,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  355,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  355,    0,
+  355,    0,    0,  355,  355,  355,  355,  355,  355,  355,
+    0,    0,  355,  355,  355,    0,    0,    0,    0,  355,
+  355,    0,    0,    0,  355,  355,    0,    0,    0,    0,
+  154,    0,    0,    0,  355,    0,    0,    0,  355,  355,
+  154,    0,    0,  355,    0,    0,    0,    0,    0,  355,
+    0,  355,  355,    0,  355,    0,  355,  355,  355,  355,
+  355,    0,  355,  355,  355,  355,  355,  355,  355,  355,
+  355,  355,  355,  355,  355,  355,  355,  355,    0,    0,
+  355,  355,  355,    0,  355,  355,  355,    0,  355,  355,
+  355,    0,    0,  355,    0,  355,    0,    0,  355,  355,
+  355,  355,    0,    0,  355,  355,  355,    0,    0,    0,
+    0,    0,  355,    0,    0,  355,  355,  355,  355,  355,
+  355,  355,  355,    0,  355,  355,  355,  355,  355,    0,
+  125,  355,    0,    0,    0,    0,    0,    0,  355,  355,
+  355,    0,    0,    0,    0,  125,  125,  355,  355,  125,
+    0,  125,    0,    0,  125,  125,  125,  125,  125,  125,
+  125,    0,    0,  125,  125,  125,    0,    0,    0,    0,
+  125,  125,    0,    0,    0,  125,  125,    0,    0,    0,
+    0,    0,    0,    0,    0,  125,    0,    0,    0,  125,
+  125,    0,    0,    0,  125,    0,    0,    0,    0,    0,
+  125,    0,  125,  125,    0,  125,    0,  125,  125,  125,
+  125,  125,    0,  125,  125,  125,  125,  125,  125,  125,
+  125,  125,  125,  125,  125,  125,  125,  125,  125,    0,
+    0,  125,  125,  125,    0,  125,  125,  125,    0,  125,
+  125,  125,    0,  236,  125,    0,  125,    0,    0,  125,
+  125,  125,  125,  236,    0,  125,  125,  125,    0,    0,
+    0,    0,    0,  125,    0,    0,  125,  125,  125,  125,
+  125,  125,  125,  125,    0,  125,  125,  125,  125,  125,
+    0,    0,  125,    0,    0,  236,  154,  236,    0,  125,
+  125,    0,    0,    0,    0,    0,    0,    0,  125,  125,
+    0,  154,  154,    0,    0,  154,    0,  154,    0,    0,
+  154,  154,  154,  154,  154,  154,  154,    0,    0,  154,
+  154,  154,    0,    0,    0,    0,  154,  154,    0,    0,
+    0,  154,  154,    0,    0,    0,    0,    0,    0,    0,
+    0,  154,    0,    0,    0,  154,  154,    0,    0,    0,
+  154,    0,    0,    0,    0,    0,  154,    0,  154,  154,
+    0,  154,    0,  154,  154,  154,  154,  154,    0,  154,
+  154,  154,  154,  154,  154,  154,  154,  154,  154,  154,
+  154,  154,  154,  154,  154,    0,    0,  154,  154,  154,
+    0,  154,  154,  154,  164,  154,  154,  154,    0,    0,
+  154,    0,  154,    0,  164,  154,  154,  154,  154,    0,
+    0,  154,  154,  154,    0,    0,    0,    0,    0,  154,
+    0,    0,  154,  154,  154,  154,  154,  154,  154,  154,
+    0,  154,  154,  154,  154,  154,    0,    0,  154,    0,
+    0,    0,    0,    0,    0,  154,  154,  154,    0,    0,
+    0,    0,    0,    0,  154,  154,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  236,    0,
+  236,    0,    0,  236,  236,  236,  236,  236,  236,  236,
+    0,    0,  236,  236,  236,    0,    0,    0,    0,  236,
+  236,    0,    0,    0,  236,  236,    0,    0,    0,    0,
+  155,    0,    0,    0,  236,    0,    0,    0,  236,  236,
+  155,    0,    0,  236,    0,    0,    0,    0,    0,  236,
+    0,  236,  236,    0,  236,    0,  236,  236,  236,  236,
+  236,    0,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,    0,    0,
+  236,  236,  236,    0,  236,  236,  236,    0,  236,  236,
+  236,    0,    0,  236,    0,  236,    0,    0,  236,  236,
+  236,  236,    0,    0,  236,  236,  236,    0,    0,    0,
+    0,    0,  236,    0,    0,  236,  236,  236,  236,  236,
+  236,  236,  236,    0,  236,  236,  236,  236,  236,    0,
+  164,  236,    0,    0,    0,    0,    0,    0,  236,  236,
+  236,    0,    0,    0,    0,  164,  164,  236,  236,  164,
+    0,  164,    0,    0,  164,  164,  164,  164,  164,  164,
+  164,    0,    0,  164,  164,  164,    0,    0,    0,    0,
+  164,  164,    0,    0,    0,  164,  164,    0,    0,    0,
+    0,    0,    0,    0,    0,  164,    0,    0,    0,  164,
+  164,    0,    0,    0,  164,    0,    0,    0,    0,    0,
+  164,    0,  164,  164,    0,  164,    0,  164,  164,  164,
+  164,  164,    0,  164,  164,  164,  164,  164,  164,  164,
+  164,  164,  164,  164,  164,  164,  164,  164,  164,    0,
+    0,  164,  164,  164,    0,  164,  164,  164,    0,  164,
+  164,  164,    0,  525,  164,    0,  164,    0,    0,  164,
+  164,  164,  164,  525,    0,  164,  164,  164,    0,    0,
+    0,    0,    0,  164,    0,    0,  164,  164,  164,  164,
+  164,  164,  164,  164,    0,  164,  164,  164,  164,  164,
+    0,    0,  164,    0,  525,    0,  155,  525,    0,  164,
+  164,  164,    0,    0,    0,    0,    0,    0,  164,  164,
+    0,  155,  155,    0,    0,  155,    0,  155,    0,    0,
+  155,  155,  155,  155,  155,  155,  155,    0,    0,  155,
+  155,  155,    0,    0,    0,    0,  155,  155,    0,    0,
+    0,  155,  155,    0,    0,    0,    0,    0,    0,    0,
+    0,  155,    0,    0,    0,  155,  155,    0,    0,    0,
+  155,    0,    0,    0,    0,    0,  155,    0,  155,  155,
+    0,  155,    0,  155,  155,  155,  155,  155,    0,  155,
+  155,  155,  155,  155,  155,  155,  155,  155,  155,  155,
+  155,  155,  155,  155,  155,    0,    0,  155,  155,  155,
+    0,  155,  155,  155,    0,  155,  155,  155,    0,  168,
+  155,    0,  155,    0,    0,  155,  155,  155,  155,  168,
+    0,  155,  155,  155,    0,    0,    0,    0,    0,  155,
+    0,    0,  155,  155,  155,  155,  155,  155,  155,  155,
+    0,  155,  155,  155,  155,  155,    0,    0,  155,    0,
+  168,    0,    0,  168,    0,  155,  155,  155,    0,    0,
+    0,    0,    0,    0,  155,  155,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  525,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  525,    0,
+  525,    0,    0,  525,  525,  525,  525,  525,  525,  525,
+    0,    0,  525,  525,  525,    0,    0,    0,    0,  525,
+  525,    0,    0,    0,  525,  525,    0,    0,    0,    0,
+    0,    0,    0,    0,  525,    0,    0,    0,  525,  525,
+    0,    0,    0,  525,    0,    0,    0,    0,    0,  525,
+    0,  525,  525,    0,  525,    0,  525,  525,  525,  525,
+  525,    0,  525,  525,  525,  525,  525,  525,  525,  525,
+  525,  525,  525,  525,  525,  525,  525,  525,    0,    0,
+  525,  525,  525,    0,  525,  525,  525,    0,  525,  525,
+  525,    0,  523,  525,    0,  525,    0,    0,  525,  525,
+  525,  525,  523,    0,  525,  525,  525,    0,    0,    0,
+    0,    0,  525,    0,    0,  525,  525,  525,  525,  525,
+  525,  525,  525,    0,  525,  525,  525,  525,  525,    0,
+    0,  525,    0,  523,    0,  168,  523,    0,  525,  525,
+  525,    0,    0,    0,    0,    0,    0,  525,  525,    0,
+    0,    0,    0,    0,  168,    0,  168,    0,    0,  168,
+  168,  168,  168,  168,  168,  168,    0,    0,  168,  168,
+  168,    0,    0,    0,    0,  168,  168,    0,    0,    0,
+  168,  168,    0,    0,    0,    0,    0,    0,    0,    0,
+  168,    0,    0,    0,  168,  168,    0,    0,    0,  168,
+    0,    0,    0,    0,    0,  168,    0,  168,  168,    0,
+  168,    0,  168,  168,  168,  168,  168,    0,  168,  168,
+  168,  168,  168,  168,  168,  168,  168,  168,  168,  168,
+  168,  168,  168,  168,    0,    0,  168,  168,  168,    0,
+  168,  168,  168,    0,  168,  168,  168,    0,  522,  168,
+    0,  168,    0,    0,  168,  168,  168,  168,  522,    0,
+  168,  168,  168,    0,    0,    0,    0,    0,  168,    0,
+    0,  168,  168,  168,  168,  168,  168,  168,  168,    0,
+  168,  168,  168,  168,  168,    0,    0,  168,    0,  522,
+    0,    0,  522,    0,  168,  168,  168,    0,    0,    0,
+    0,    0,    0,  168,  168,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  523,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  523,    0,  523,
+    0,    0,  523,  523,  523,  523,  523,  523,  523,    0,
+    0,  523,  523,  523,    0,    0,    0,    0,  523,  523,
+    0,    0,    0,  523,  523,    0,    0,    0,    0,    0,
+    0,    0,    0,  523,    0,    0,    0,  523,  523,    0,
+    0,    0,  523,    0,    0,    0,    0,    0,  523,    0,
+  523,  523,    0,  523,    0,  523,  523,  523,  523,  523,
+    0,  523,  523,  523,  523,  523,  523,  523,  523,  523,
+  523,  523,  523,  523,  523,  523,  523,    0,    0,  523,
+  523,  523,    0,  523,  523,  523,    0,  523,  523,  523,
+    0,  520,  523,    0,  523,    0,    0,  523,  523,  523,
+  523,  520,    0,  523,  523,  523,    0,    0,    0,    0,
+    0,  523,    0,    0,  523,  523,  523,  523,  523,  523,
+  523,  523,    0,  523,  523,  523,  523,  523,    0,    0,
+  523,    0,  520,    0,  522,  520,    0,  523,  523,  523,
+    0,    0,    0,    0,    0,    0,  523,  523,    0,    0,
+    0,    0,    0,  522,    0,  522,    0,    0,  522,  522,
+  522,  522,  522,  522,  522,    0,    0,  522,  522,  522,
+    0,    0,    0,    0,  522,  522,    0,    0,    0,  522,
+  522,    0,    0,    0,    0,    0,    0,    0,    0,  522,
+    0,    0,    0,  522,  522,    0,    0,    0,  522,    0,
+    0,    0,    0,    0,  522,    0,  522,  522,    0,  522,
+    0,  522,  522,  522,  522,  522,    0,  522,  522,  522,
+  522,  522,  522,  522,  522,  522,  522,  522,  522,  522,
+  522,  522,  522,    0,    0,  522,  522,  522,    0,  522,
+  522,  522,    0,  522,  522,  522,    0,  531,  522,    0,
+  522,    0,    0,  522,  522,  522,  522,  531,    0,  522,
+  522,  522,    0,    0,    0,    0,    0,  522,    0,    0,
+  522,  522,  522,  522,  522,  522,  522,  522,    0,  522,
+  522,  522,  522,  522,    0,    0,  522,    0,    0,    0,
+    0,  531,    0,  522,  522,  522,    0,    0,    0,    0,
+    0,    0,  522,  522,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  520,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  520,    0,  520,    0,
+    0,  520,  520,  520,  520,  520,  520,  520,    0,    0,
+  520,  520,  520,    0,    0,    0,    0,  520,  520,    0,
+    0,    0,  520,  520,    0,    0,    0,    0,    0,    0,
+    0,    0,  520,  535,    0,    0,  520,  520,    0,    0,
+    0,  520,    0,  535,    0,    0,    0,  520,    0,  520,
+  520,    0,  520,    0,  520,  520,  520,  520,  520,    0,
+  520,  520,  520,  520,  520,  520,  520,  520,  520,  520,
+  520,  520,  520,  520,  520,  520,    0,  535,  520,  520,
+  520,    0,  520,  520,  520,    0,  520,  520,  520,    0,
+    0,  520,    0,  520,    0,    0,  520,  520,  520,  520,
+    0,    0,  520,  520,  520,    0,    0,    0,    0,    0,
+  520,    0,    0,  520,  520,  520,  520,  520,  520,  520,
+  520,    0,  520,  520,  520,  520,  520,    0,    0,  520,
+    0,    0,    0,  531,    0,    0,  520,  520,  520,    0,
+    0,    0,    0,    0,    0,  520,  520,    0,    0,    0,
+    0,    0,  531,    0,  531,    0,    0,  531,  531,  531,
+  531,  531,  531,  531,    0,    0,  531,  531,  531,    0,
+    0,    0,    0,  531,  531,    0,    0,    0,  531,  531,
+    0,    0,    0,    0,    0,    0,    0,    0,  531,  533,
+    0,    0,  531,  531,    0,    0,    0,  531,    0,  533,
+    0,    0,    0,  531,    0,  531,  531,    0,  531,    0,
+  531,  531,  531,  531,  531,    0,  531,  531,  531,  531,
+  531,  531,  531,  531,  531,  531,  531,  531,  531,  531,
+  531,  531,    0,  533,  531,  531,  531,    0,  531,  531,
+  531,    0,  531,  531,  531,    0,    0,  531,    0,  531,
+    0,    0,  531,  531,  531,  531,    0,  531,  531,  531,
+  531,    0,    0,    0,    0,    0,  531,    0,    0,  531,
+  531,  531,  531,  531,  531,  531,  531,    0,  531,  531,
+  531,  531,  531,    0,    0,  531,    0,    0,    0,  535,
+    0,    0,  531,  531,  531,    0,    0,    0,    0,    0,
+    0,  531,  531,    0,    0,    0,    0,    0,  535,    0,
+  535,    0,    0,  535,  535,  535,  535,  535,  535,  535,
+    0,    0,  535,  535,  535,    0,    0,    0,    0,  535,
+  535,    0,    0,    0,  535,  535,    0,    0,    0,    0,
+    0,    0,    0,    0,  535,  198,    0,    0,  535,  535,
+    0,    0,    0,  535,    0,  198,    0,    0,    0,  535,
+    0,  535,  535,    0,  535,    0,  535,  535,  535,  535,
+  535,    0,  535,  535,  535,  535,  535,  535,  535,  535,
+  535,  535,  535,  535,  535,  535,  535,  535,    0,  198,
+  535,  535,  535,    0,  535,  535,  535,    0,  535,  535,
+  535,    0,    0,  535,    0,  535,  198,    0,  535,  535,
+  535,  535,    0,  535,  535,  535,  535,    0,    0,    0,
+    0,    0,  535,    0,    0,  535,  535,  535,  535,  535,
+  535,  535,  535,    0,  535,  535,  535,  535,  535,    0,
+    0,  535,    0,    0,    0,  533,    0,    0,  535,  535,
+  535,    0,    0,    0,    0,    0,    0,  535,  535,    0,
+    0,    0,    0,    0,  533,    0,  533,    0,    0,  533,
+  533,  533,  533,  533,  533,  533,    0,    0,  533,  533,
+  533,    0,    0,    0,    0,  533,  533,    0,    0,    0,
+  533,  533,    0,    0,    0,    0,  156,    0,    0,    0,
+  533,    0,    0,    0,  533,  533,  156,    0,    0,  533,
+    0,    0,    0,    0,    0,  533,    0,  533,  533,    0,
+  533,    0,  533,  533,  533,  533,  533,    0,  533,  533,
+  533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+  533,  533,  533,  533,    0,    0,  533,  533,  533,    0,
+  533,  533,  533,    0,  533,  533,  533,    0,    0,  533,
+    0,  533,    0,    0,  533,  533,  533,  533,    0,  533,
+  533,  533,  533,    0,    0,    0,    0,    0,  533,    0,
+    0,  533,  533,  533,  533,  533,  533,  533,  533,    0,
+  533,  533,  533,  533,  533,    0,    0,  533,    0,    0,
+    0,  198,    0,    0,  533,  533,  533,    0,    0,    0,
+    0,    0,    0,  533,  533,    0,    0,    0,    0,    0,
+  198,    0,  198,    0,    0,  198,  198,  198,  198,  198,
+  198,  198,    0,    0,  198,  198,  198,    0,    0,    0,
+    0,  198,  198,    0,    0,    0,  198,  198,    0,    0,
+    0,    0,    0,    0,    0,    0,  198,    0,    0,    0,
+  198,  198,    0,    0,    0,  198,    0,    0,    0,    0,
+    0,  198,    0,  198,  198,    0,  198,    0,  198,  198,
+  198,  198,  198,    0,  198,  198,  198,  198,  198,  198,
+  198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
+    0,    0,  198,  198,  198,    0,  198,  198,  198,    0,
+  198,  198,  198,    0,  358,  198,    0,  198,    0,    0,
+  198,  198,  198,  198,  358,    0,  198,  198,  198,    0,
+    0,    0,    0,    0,  198,    0,    0,  198,  198,  198,
+  198,  198,  198,  198,  198,    0,  198,  198,  198,  198,
+  198,    0,  156,  198,    0,    0,    0,    0,  358,    0,
+  198,  198,  198,    0,    0,    0,    0,  156,  156,  198,
+  198,  156,    0,  156,    0,  360,  156,  156,  156,  156,
+  156,  156,  156,    0,    0,  156,  156,  156,    0,    0,
+    0,    0,  156,  156,    0,    0,    0,  156,  156,    0,
+    0,    0,    0,    0,    0,    0,    0,  156,    0,    0,
+    0,  156,  156,    0,    0,    0,  156,    0,    0,    0,
+    0,    0,  156,    0,  156,  156,    0,  156,    0,  156,
+  156,  156,  156,  156,    0,  156,  156,  156,  156,  156,
+  156,  156,  156,  156,  156,  156,  156,  156,  156,  156,
+  156,    0,    0,  156,  156,  156,    0,  156,  156,  156,
+    0,  156,  156,  156,    0,  521,  156,    0,  156,    0,
+    0,  156,  156,  156,  156,  521,    0,  156,  156,  156,
+    0,    0,    0,    0,    0,  156,    0,    0,  156,  156,
+  156,  156,  156,  156,  156,  156,    0,  156,  156,  156,
+  156,  156,    0,    0,  156,    0,  521,    0,    0,  521,
+    0,  156,  156,  156,    0,    0,    0,    0,    0,    0,
+  156,  156,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  358,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  358,
+    0,  358,    0,    0,  358,  358,  358,  358,  358,  358,
+  358,    0,    0,  358,  358,  358,    0,    0,    0,    0,
+  358,  358,    0,    0,    0,  358,  358,    0,   40,    0,
+    0,    0,    0,    0,    0,  358,    0,    0,   40,  358,
+  358,    0,    0,    0,  358,    0,    0,    0,    0,    0,
+  358,    0,  358,  358,    0,  358,    0,  358,  358,  358,
+  358,  358,    0,  358,  358,  358,  358,  358,  358,  358,
+  358,  358,  358,  358,  358,  358,  358,  358,  358,    0,
+    0,  358,  358,  358,    0,  358,  358,  358,    0,  358,
+  358,  358,    0,    0,  358,    0,  358,    0,    0,  358,
+  358,  358,  358,    0,    0,  358,  358,  358,    0,    0,
+    0,    0,    0,  358,    0,    0,  358,  358,  358,  358,
+  358,  358,  358,  358,    0,  358,  358,  358,  358,  358,
+    0,  521,  358,    0,    0,    0,    0,    0,    0,  358,
+  358,  358,    0,    0,    0,    0,    0,    0,  358,  358,
+  521,    0,  521,    0,    0,  521,  521,  521,  521,  521,
+  521,  521,    0,    0,  521,  521,  521,    0,    0,    0,
+    0,  521,  521,    0,    0,    0,  521,  521,    0,  530,
+    0,    0,    0,    0,    0,    0,  521,    0,    0,  530,
+  521,  521,    0,    0,    0,  521,    0,    0,    0,    0,
+    0,  521,    0,  521,  521,    0,  521,    0,  521,  521,
+  521,  521,  521,    0,  521,  521,  521,  521,  521,  521,
+  521,  521,  521,  521,  521,  521,  521,  521,  521,  521,
+    0,    0,  521,  521,  521,    0,  521,  521,  521,    0,
+  521,  521,  521,    0,    0,  521,    0,  521,    0,    0,
+  521,  521,  521,  521,    0,    0,  521,  521,  521,    0,
+    0,    0,    0,    0,  521,    0,    0,  521,  521,  521,
+  521,  521,  521,  521,  521,    0,  521,  521,  521,  521,
+  521,    0,    0,  521,   40,    0,    0,    0,    0,    0,
+  521,  521,  521,    0,    0,    0,    0,    0,    0,  521,
+  521,    0,    0,   40,    0,   40,   40,    0,   40,   40,
+   40,   40,   40,   40,   40,    0,    0,   40,   40,   40,
+    0,    0,    0,    0,   40,   40,    0,    0,    0,   40,
+   40,    0,  529,    0,    0,    0,    0,    0,    0,   40,
+    0,    0,  529,   40,   40,    0,    0,    0,   40,    0,
+    0,    0,    0,    0,   40,    0,   40,   40,    0,   40,
+    0,   40,   40,   40,   40,   40,    0,   40,   40,   40,
+   40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
+   40,   40,   40,    0,    0,   40,   40,   40,    0,   40,
+   40,   40,    0,   40,   40,   40,    0,    0,   40,    0,
+   40,    0,    0,   40,   40,   40,   40,    0,    0,   40,
+   40,   40,    0,    0,    0,    0,    0,   40,    0,    0,
+   40,   40,   40,   40,   40,   40,   40,   40,    0,   40,
+   40,   40,   40,   40,    0,  530,   40,    0,    0,    0,
+    0,    0,    0,   40,   40,   40,    0,    0,    0,    0,
+    0,    0,   40,   40,  530,    0,  530,    0,    0,  530,
+  530,  530,  530,  530,  530,  530,    0,    0,  530,  530,
+  530,    0,    0,    0,    0,  530,  530,    0,    0,    0,
+  530,  530,    0,    0,    0,    0,    0,    0,    0,    0,
+  530,    0,    0,    0,  530,  530,    0,    0,    0,  530,
+    0,    0,    0,    0,    0,  530,    0,  530,  530,    0,
+  530,    0,  530,  530,  530,  530,  530,    0,  530,  530,
+  530,  530,  530,  530,  530,  530,  530,  530,  530,  530,
+  530,  530,  530,  530,    0,    0,  530,  530,  530,    0,
+  530,  530,  530,    0,  530,  530,  530,    0,  525,  530,
+    0,  530,    0,    0,  530,  530,  530,  530,  525,  530,
+  530,  530,  530,    0,    0,    0,    0,    0,  530,    0,
+    0,  530,  530,  530,  530,  530,  530,  530,  530,    0,
+  530,  530,  530,  530,  530,    0,    0,  530,  529,  525,
+    0,    0,  525,    0,  530,  530,  530,    0,    0,    0,
+    0,    0,    0,  530,  530,    0,    0,  529,    0,  529,
+    0,    0,  529,  529,  529,  529,  529,  529,  529,    0,
+    0,  529,  529,  529,    0,    0,    0,    0,  529,  529,
+    0,    0,    0,  529,  529,    0,    0,    0,    0,    0,
+    0,    0,    0,  529,    0,    0,    0,  529,  529,    0,
+    0,    0,  529,    0,    0,    0,    0,    0,  529,    0,
+  529,  529,    0,  529,    0,  529,  529,  529,  529,  529,
+    0,  529,  529,  529,  529,  529,  529,  529,  529,  529,
+  529,  529,  529,  529,  529,  529,  529,    0,    0,  529,
+  529,  529,    0,  529,  529,  529,    0,  529,  529,  529,
+    0,  198,  529,    0,  529,    0,    0,  529,  529,  529,
+  529,  198,  529,  529,  529,  529,    0,    0,    0,    0,
+    0,  529,    0,    0,  529,  529,  529,  529,  529,  529,
+  529,  529,    0,  529,  529,  529,  529,  529,    0,    0,
+  529,    0,    0,    0,    0,  198,    0,  529,  529,  529,
+    0,    0,    0,    0,    0,    0,  529,  529,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  525,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  525,    0,  525,    0,    0,  525,  525,
+  525,  525,  525,  525,  525,    0,    0,  525,  525,  525,
+    0,    0,    0,    0,  525,  525,    0,    0,    0,  525,
+  525,    0,    0,    0,    0,    0,    0,    0,    0,  525,
+    0,    0,    0,  525,  525,    0,    0,    0,  525,    0,
+    0,    0,    0,    0,  525,    0,  525,  525,    0,  525,
+    0,  525,  525,  525,  525,  525,    0,  525,  525,  525,
+  525,  525,  525,  525,  525,  525,  525,  525,  525,  525,
+  525,  525,  525,    0,    0,  525,  525,  525,    0,  525,
+  525,  525,    0,  525,  525,  525,    0,  200,  525,    0,
+  525,    0,    0,  525,  525,  525,  525,  200,    0,  525,
+  525,  525,    0,    0,    0,    0,    0,  525,    0,    0,
+  525,  525,  525,  525,  525,  525,  525,  525,    0,  525,
+  525,  525,  525,  525,    0,    0,  525,  198,    0,    0,
+    0,  200,    0,  525,  525,    0,    0,    0,    0,    0,
+    0,    0,  525,  525,    0,    0,  198,    0,  198,    0,
+    0,  198,  198,  198,  198,  198,  198,  198,    0,    0,
+  198,  198,  198,    0,    0,    0,    0,  198,  198,    0,
+    0,    0,  198,  198,    0,    0,    0,    0,    0,    0,
+    0,    0,  198,    0,    0,    0,  198,  198,    0,    0,
+    0,  198,    0,    0,    0,    0,    0,  198,    0,  198,
+  198,    0,  198,    0,  198,  198,  198,  198,  198,    0,
+  198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
+  198,  198,  198,  198,  198,  198,    0,    0,  198,  198,
+  198,    0,  198,  198,  198,    0,  198,  198,  198,    0,
+  374,  198,    0,  198,    0,    0,  198,  198,  198,  198,
+  374,    0,  198,  198,  198,    0,    0,    0,    0,    0,
+  198,    0,    0,  198,  198,  198,  198,  198,  198,  198,
+  198,    0,  198,  198,  198,  198,  198,    0,    0,  198,
+    0,    0,    0,    0,  374,    0,  198,  198,  198,    0,
+    0,    0,    0,    0,    0,  198,  198,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  200,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  200,    0,  200,    0,    0,  200,  200,  200,
+  200,  200,  200,  200,    0,    0,  200,  200,  200,    0,
+    0,    0,    0,  200,  200,    0,    0,    0,  200,  200,
+    0,    0,    0,    0,    0,    0,    0,    0,  200,    0,
+    0,    0,  200,  200,    0,    0,    0,  200,    0,    0,
+    0,    0,    0,  200,    0,  200,  200,    0,  200,    0,
+  200,  200,  200,  200,  200,    0,  200,  200,  200,  200,
+  200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
+  200,  200,    0,    0,  200,  200,  200,    0,  200,  200,
+  200,    0,  200,  200,  200,    0,  359,  200,    0,  200,
+    0,    0,  200,  200,  200,  200,  359,    0,  200,  200,
+  200,    0,    0,    0,    0,    0,  200,    0,    0,  200,
+  200,  200,  200,  200,  200,  200,  200,    0,  200,  200,
+  200,  200,  200,    0,    0,  200,  374,    0,    0,    0,
+  359,    0,  200,  200,  200,    0,    0,    0,    0,    0,
+    0,  200,  200,    0,    0,  374,    0,  374,    0,    0,
+  374,  374,  374,  374,  374,  374,  374,    0,    0,  374,
+  374,  374,    0,    0,    0,    0,  374,  374,    0,    0,
+    0,  374,  374,    0,    0,    0,    0,    0,    0,    0,
+    0,  374,    0,    0,    0,  374,  374,    0,    0,    0,
+  374,    0,    0,    0,    0,    0,  374,    0,  374,  374,
+    0,  374,    0,  374,  374,  374,  374,  374,    0,  374,
+  374,  374,  374,  374,  374,  374,  374,  374,  374,  374,
+  374,  374,  374,  374,  374,    0,    0,  374,  374,  374,
+    0,  374,  374,  374,    0,  374,  374,  374,    0,   59,
+  374,    0,  374,    0,    0,  374,  374,  374,  374,   59,
+    0,  374,  374,  374,    0,    0,    0,    0,    0,  374,
+    0,    0,  374,  374,  374,  374,  374,  374,  374,  374,
+    0,  374,  374,  374,  374,  374,    0,    0,  374,    0,
+    0,    0,    0,    0,    0,  374,  374,  374,    0,    0,
+    0,    0,    0,    0,  374,  374,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  359,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  359,    0,  359,    0,    0,  359,  359,  359,  359,
+  359,  359,  359,    0,    0,  359,  359,  359,    0,    0,
+    0,    0,  359,  359,    0,    0,    0,  359,  359,    0,
+    0,    0,    0,    0,    0,    0,    0,  359,    0,    0,
+    0,  359,  359,    0,    0,    0,  359,    0,    0,    0,
+    0,    0,  359,    0,  359,  359,    0,  359,    0,  359,
+  359,  359,  359,  359,    0,  359,  359,  359,  359,  359,
+  359,  359,  359,  359,  359,  359,  359,  359,  359,  359,
+  359,    0,    0,  359,  359,  359,    0,  359,  359,  359,
+    0,  359,  359,  359,    0,  125,  359,    0,  359,    0,
+    0,  359,  359,  359,  359,  125,    0,  359,  359,  359,
+    0,    0,    0,    0,    0,  359,    0,    0,  359,  359,
+  359,  359,  359,  359,  359,  359,    0,  359,  359,  359,
+  359,  359,    0,    0,  359,   59,    0,    0,    0,  125,
+    0,  359,  359,  359,    0,    0,    0,    0,    0,    0,
+  359,  359,    0,    0,   59,    0,   59,    0,    0,   59,
+   59,   59,   59,   59,   59,   59,    0,    0,   59,   59,
+   59,    0,    0,    0,    0,   59,   59,    0,    0,    0,
+   59,   59,    0,    0,    0,    0,    0,    0,    0,    0,
+   59,    0,    0,    0,   59,   59,    0,    0,    0,   59,
+    0,    0,    0,    0,    0,   59,    0,   59,   59,    0,
+   59,    0,   59,   59,   59,   59,   59,    0,   59,   59,
+   59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+   59,   59,   59,   59,    0,    0,   59,   59,   59,    0,
+   59,   59,   59,    0,   59,   59,   59,    0,  432,   59,
+    0,   59,    0,    0,   59,   59,   59,   59,  432,    0,
+   59,   59,   59,    0,    0,    0,    0,    0,   59,    0,
+    0,   59,   59,   59,   59,   59,   59,   59,   59,    0,
+   59,   59,   59,   59,   59,    0,    0,   59,    0,    0,
+    0,    0,    0,    0,   59,   59,   59,    0,    0,    0,
+    0,    0,    0,   59,   59,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  125,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  125,    0,  125,    0,    0,  125,  125,  125,  125,  125,
+  125,  125,    0,    0,  125,  125,  125,    0,    0,    0,
+    0,  125,  125,    0,    0,    0,  125,  125,    0,  441,
+    0,    0,    0,    0,    0,    0,  125,    0,    0,  441,
+  125,  125,    0,    0,    0,  125,    0,    0,    0,    0,
+    0,  125,    0,  125,  125,    0,  125,    0,  125,  125,
+  125,  125,  125,    0,  125,  125,  125,  125,  125,  125,
+  125,  125,  125,  125,  125,  125,  125,  125,  125,  125,
+    0,    0,  125,  125,  125,    0,  125,  125,  125,    0,
+  125,  125,  125,    0,    0,  125,    0,  125,    0,    0,
+  125,  125,  125,  125,    0,    0,  125,  125,  125,    0,
+    0,    0,    0,    0,  125,    0,    0,  125,  125,  125,
+  125,  125,  125,  125,  125,    0,  125,  125,  125,  125,
+  125,    0,    0,  125,  432,    0,    0,    0,    0,    0,
+  125,  125,    0,    0,    0,    0,    0,    0,    0,  125,
+  125,    0,    0,  432,    0,  432,    0,    0,  432,  432,
+  432,  432,  432,  432,  432,    0,    0,  432,  432,  432,
+    0,    0,    0,    0,  432,  432,    0,    0,    0,  432,
+  432,    0,  357,    0,    0,    0,    0,    0,    0,  432,
+    0,    0,  357,  432,  432,    0,    0,    0,  432,    0,
+    0,    0,    0,    0,  432,    0,  432,  432,    0,  432,
+    0,  432,  432,  432,  432,  432,    0,  432,  432,  432,
+  432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
+  432,  432,  432,    0,    0,  432,  432,  432,    0,  432,
+  432,  432,    0,  432,  432,  432,    0,    0,  432,    0,
+  432,    0,    0,  432,  432,  432,  432,    0,    0,  432,
+  432,  432,    0,    0,    0,    0,    0,  432,    0,    0,
+  432,  432,  432,  432,  432,  432,  432,  432,    0,  432,
+  432,  432,  432,  432,    0,  441,  432,    0,    0,    0,
+    0,    0,    0,  432,  432,  432,    0,    0,    0,    0,
+    0,    0,  432,  432,  441,    0,  441,    0,    0,  441,
+  441,  441,  441,  441,  441,  441,    0,    0,  441,  441,
+  441,    0,    0,    0,    0,  441,  441,    0,    0,    0,
+  441,  441,    0,   69,    0,    0,    0,    0,    0,    0,
+  441,    0,    0,   69,  441,  441,    0,    0,    0,  441,
+    0,    0,    0,    0,    0,  441,    0,  441,  441,    0,
+  441,    0,  441,  441,  441,  441,  441,    0,  441,  441,
+  441,  441,  441,  441,  441,  441,  441,  441,  441,  441,
+  441,  441,  441,  441,    0,    0,  441,  441,  441,    0,
+  441,  441,  441,    0,  441,  441,  441,    0,    0,  441,
+    0,  441,    0,    0,  441,  441,  441,  441,    0,    0,
+  441,  441,  441,    0,    0,    0,    0,    0,  441,    0,
+    0,  441,  441,  441,  441,  441,  441,  441,  441,    0,
+  441,  441,  441,  441,  441,    0,    0,  441,  357,    0,
+    0,    0,    0,    0,  441,  441,  441,    0,    0,    0,
+    0,    0,    0,  441,  441,    0,    0,  357,    0,  357,
+    0,    0,  357,  357,  357,  357,  357,  357,  357,    0,
+    0,  357,  357,  357,    0,    0,    0,    0,  357,  357,
+    0,    0,    0,  357,  357,    0,   53,    0,    0,    0,
+    0,    0,    0,  357,    0,    0,   53,  357,  357,    0,
+    0,    0,  357,    0,    0,    0,    0,    0,  357,    0,
+  357,  357,    0,  357,    0,  357,  357,  357,  357,  357,
+    0,  357,  357,  357,  357,  357,  357,  357,  357,  357,
+  357,  357,  357,  357,  357,  357,  357,    0,    0,  357,
+  357,  357,    0,  357,  357,  357,    0,  357,  357,  357,
+    0,    0,  357,    0,  357,    0,    0,  357,  357,  357,
+  357,    0,    0,  357,  357,  357,    0,    0,    0,    0,
+    0,  357,    0,    0,  357,  357,  357,  357,  357,  357,
+  357,  357,    0,  357,  357,  357,  357,  357,    0,   69,
+  357,    0,    0,    0,    0,    0,    0,  357,  357,  357,
+    0,    0,    0,    0,    0,    0,  357,  357,   69,    0,
+   69,    0,    0,   69,   69,   69,   69,   69,   69,   69,
+    0,    0,   69,   69,   69,    0,    0,    0,    0,   69,
+   69,    0,    0,    0,   69,   69,    0,  169,    0,    0,
+    0,    0,    0,    0,   69,    0,    0,  169,   69,   69,
+    0,    0,    0,   69,    0,    0,    0,    0,    0,   69,
+    0,   69,   69,    0,   69,    0,   69,   69,   69,   69,
+   69,    0,   69,   69,   69,   69,   69,   69,   69,   69,
+   69,   69,   69,   69,   69,   69,   69,   69,    0,    0,
+   69,   69,   69,    0,   69,   69,   69,    0,   69,   69,
+   69,    0,    0,   69,    0,   69,    0,    0,   69,   69,
+   69,   69,    0,    0,   69,   69,   69,    0,    0,    0,
+    0,    0,   69,    0,    0,   69,   69,   69,   69,   69,
+   69,   69,   69,    0,   69,   69,   69,   69,   69,    0,
+    0,   69,   53,    0,    0,    0,    0,    0,   69,   69,
+   69,    0,    0,    0,    0,    0,    0,   69,   69,    0,
+    0,   53,    0,   53,    0,    0,   53,   53,   53,   53,
+   53,   53,   53,    0,    0,   53,   53,   53,    0,    0,
+    0,    0,   53,   53,    0,    0,    0,   53,   53,    0,
+  177,    0,    0,    0,    0,    0,    0,   53,    0,    0,
+  177,   53,   53,    0,    0,    0,   53,    0,    0,    0,
+    0,    0,   53,    0,   53,   53,    0,   53,    0,   53,
+   53,   53,   53,   53,    0,   53,   53,   53,   53,   53,
+   53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
+   53,    0,    0,   53,   53,   53,    0,   53,   53,   53,
+    0,   53,   53,   53,    0,    0,   53,    0,   53,    0,
+    0,   53,   53,   53,   53,    0,    0,   53,   53,   53,
+    0,    0,    0,    0,    0,   53,    0,    0,   53,   53,
+   53,   53,   53,   53,   53,   53,    0,   53,   53,   53,
+   53,   53,    0,  169,   53,    0,    0,    0,    0,    0,
+    0,   53,   53,   53,    0,    0,    0,    0,    0,    0,
+   53,   53,  169,    0,  169,    0,    0,  169,  169,  169,
+  169,  169,  169,  169,    0,    0,  169,  169,  169,    0,
+    0,    0,    0,  169,  169,    0,    0,    0,  169,  169,
+    0,   55,    0,    0,    0,    0,    0,    0,  169,    0,
+    0,   55,  169,  169,    0,    0,    0,  169,    0,    0,
+    0,    0,    0,  169,    0,  169,  169,    0,  169,    0,
+  169,  169,  169,  169,  169,    0,  169,  169,  169,  169,
+  169,  169,  169,  169,  169,  169,  169,  169,  169,  169,
+  169,  169,    0,    0,  169,  169,  169,    0,  169,  169,
+  169,    0,  169,  169,  169,    0,    0,  169,    0,  169,
+    0,    0,  169,  169,  169,  169,    0,    0,  169,  169,
+  169,    0,    0,    0,    0,    0,  169,    0,    0,  169,
+  169,  169,  169,  169,  169,  169,  169,    0,  169,  169,
+  169,  169,  169,    0,    0,  169,  177,    0,    0,    0,
+    0,    0,  169,  169,  169,    0,    0,    0,    0,    0,
+    0,  169,  169,    0,    0,  177,    0,  177,    0,    0,
+  177,  177,  177,  177,  177,  177,  177,    0,    0,  177,
+  177,  177,    0,    0,    0,    0,  177,  177,    0,    0,
+    0,  177,  177,    0,  362,    0,    0,    0,    0,    0,
+    0,  177,    0,    0,  362,  177,  177,    0,    0,    0,
+  177,    0,    0,    0,    0,    0,  177,    0,  177,  177,
+    0,  177,    0,  177,  177,  177,  177,  177,    0,  177,
+  177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+  177,  177,  177,  177,  177,    0,    0,  177,  177,  177,
+    0,  177,  177,  177,    0,  177,  177,  177,    0,    0,
+  177,    0,  177,    0,    0,  177,  177,  177,  177,    0,
+    0,  177,  177,  177,    0,    0,    0,    0,    0,  177,
+    0,    0,  177,  177,  177,  177,  177,  177,  177,  177,
+    0,  177,  177,  177,  177,  177,    0,   55,  177,    0,
+    0,    0,    0,    0,    0,  177,  177,  177,    0,    0,
+    0,    0,    0,    0,  177,  177,   55,    0,   55,    0,
+    0,   55,   55,   55,   55,   55,   55,   55,    0,    0,
+   55,   55,   55,    0,    0,    0,    0,   55,   55,    0,
+    0,    0,   55,   55,    0,  164,    0,    0,    0,    0,
+    0,    0,   55,    0,    0,  164,   55,   55,    0,    0,
+    0,   55,    0,    0,    0,    0,    0,   55,    0,   55,
+   55,    0,   55,    0,   55,   55,   55,   55,   55,    0,
+   55,   55,   55,   55,   55,   55,   55,   55,   55,   55,
+   55,   55,   55,   55,   55,   55,    0,    0,   55,   55,
+   55,    0,   55,   55,   55,    0,   55,   55,   55,    0,
+    0,   55,    0,   55,    0,    0,   55,   55,   55,   55,
+    0,    0,   55,   55,   55,    0,    0,    0,    0,    0,
+   55,    0,    0,   55,   55,   55,   55,   55,   55,   55,
+   55,    0,   55,   55,   55,   55,   55,    0,    0,   55,
+  362,    0,    0,    0,    0,    0,   55,   55,   55,    0,
+    0,    0,    0,    0,    0,   55,   55,    0,    0,  362,
+    0,  362,    0,    0,  362,  362,  362,  362,  362,  362,
+  362,    0,    0,  362,  362,  362,    0,    0,    0,    0,
+  362,  362,    0,    0,    0,  362,  362,    0,  406,    0,
+    0,    0,    0,    0,    0,  362,    0,    0,  406,  362,
+  362,    0,    0,    0,  362,    0,    0,    0,    0,    0,
+  362,    0,  362,  362,    0,  362,    0,  362,  362,  362,
+  362,  362,    0,  362,  362,  362,  362,  362,  362,  362,
+  362,  362,  362,  362,  362,  362,  362,  362,  362,    0,
+    0,  362,  362,  362,    0,  362,  362,  362,    0,  362,
+  362,  362,    0,    0,  362,    0,  362,    0,    0,  362,
+  362,  362,  362,    0,    0,  362,  362,  362,    0,    0,
+    0,    0,    0,  362,    0,    0,  362,  362,  362,  362,
+  362,  362,  362,  362,    0,  362,  362,  362,  362,  362,
+    0,  164,  362,    0,    0,    0,    0,    0,    0,  362,
+  362,  362,    0,    0,    0,    0,    0,    0,  362,  362,
+  164,    0,  164,    0,    0,  164,  164,  164,  164,  164,
+  164,  164,    0,    0,  164,  164,  164,    0,    0,    0,
+    0,  164,  164,    0,    0,    0,  164,  164,    0,  472,
+    0,    0,    0,    0,    0,    0,  164,    0,    0,  472,
+  164,  164,    0,    0,    0,  164,    0,    0,    0,    0,
+    0,  164,    0,  164,  164,    0,  164,    0,  164,  164,
+  164,  164,  164,    0,  164,  164,  164,  164,  164,  164,
+  164,  164,  164,  164,  164,  164,  164,  164,  164,  164,
+    0,    0,  164,  164,  164,    0,  164,  164,  164,    0,
+  164,  164,  164,    0,    0,  164,    0,  164,    0,    0,
+  164,  164,  164,  164,    0,    0,  164,  164,  164,    0,
+    0,    0,    0,    0,  164,    0,    0,  164,  164,  164,
+  164,  164,  164,  164,  164,    0,  164,  164,  164,  164,
+  164,    0,    0,  164,  406,    0,    0,    0,    0,    0,
+  164,  164,  164,    0,    0,    0,    0,    0,    0,  164,
+  164,    0,    0,  406,    0,  406,    0,    0,  406,  406,
+  406,  406,  406,  406,  406,    0,    0,  406,  406,  406,
+    0,    0,    0,    0,  406,  406,    0,    0,    0,  406,
+  406,    0,   34,    0,    0,    0,    0,    0,    0,  406,
+    0,    0,   34,  406,  406,    0,    0,    0,  406,    0,
+    0,    0,    0,    0,  406,    0,  406,  406,    0,  406,
+    0,  406,  406,  406,  406,  406,    0,  406,  406,  406,
+  406,  406,  406,  406,  406,  406,  406,  406,  406,  406,
+  406,  406,  406,    0,    0,  406,  406,  406,    0,  406,
+  406,  406,    0,  406,  406,  406,    0,    0,  406,    0,
+  406,    0,    0,  406,  406,  406,  406,    0,    0,  406,
+  406,  406,    0,    0,    0,    0,    0,  406,    0,    0,
+  406,  406,  406,  406,  406,  406,  406,  406,    0,  406,
+  406,  406,  406,  406,    0,  472,  406,    0,    0,    0,
+    0,    0,    0,  406,  406,  406,    0,    0,    0,    0,
+    0,    0,  406,  406,  472,    0,  472,    0,    0,  472,
+  472,  472,  472,  472,  472,  472,    0,    0,  472,  472,
+  472,    0,    0,    0,    0,  472,  472,    0,    0,    0,
+  472,  472,    0,  151,    0,    0,    0,    0,    0,    0,
+  472,    0,    0,  151,  472,  472,    0,    0,    0,  472,
+    0,    0,    0,    0,    0,  472,    0,  472,  472,    0,
+  472,    0,  472,  472,  472,  472,  472,    0,  472,  472,
+  472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
+  472,  472,  472,  472,    0,    0,  472,  472,  472,    0,
+  472,  472,  472,    0,  472,  472,  472,    0,    0,  472,
+    0,  472,    0,    0,  472,  472,  472,  472,    0,    0,
+  472,  472,  472,    0,    0,    0,    0,    0,  472,    0,
+    0,  472,  472,  472,  472,  472,  472,  472,  472,    0,
+  472,  472,  472,  472,  472,    0,    0,  472,   34,    0,
+    0,    0,    0,    0,  472,  472,  472,    0,    0,    0,
+    0,    0,    0,  472,  472,    0,    0,   34,    0,   34,
+    0,    0,   34,   34,   34,   34,   34,   34,   34,    0,
+    0,   34,   34,   34,    0,    0,    0,    0,   34,   34,
+    0,    0,    0,   34,   34,    0,  149,    0,    0,    0,
+    0,    0,    0,   34,    0,    0,  149,   34,   34,    0,
+    0,    0,   34,    0,    0,    0,    0,    0,   34,    0,
+   34,   34,    0,   34,    0,   34,   34,   34,   34,   34,
+    0,   34,   34,   34,   34,   34,   34,   34,   34,   34,
+   34,   34,   34,   34,   34,   34,   34,    0,    0,   34,
+   34,   34,    0,   34,   34,   34,    0,   34,   34,   34,
+    0,    0,   34,    0,   34,    0,    0,   34,   34,   34,
+   34,    0,    0,   34,   34,   34,    0,    0,    0,    0,
+    0,   34,    0,    0,   34,   34,   34,   34,   34,   34,
+   34,   34,    0,   34,   34,   34,   34,   34,    0,  151,
+   34,    0,    0,    0,    0,    0,    0,   34,   34,   34,
+    0,    0,    0,    0,    0,    0,   34,   34,  151,    0,
+  151,    0,    0,  151,  151,  151,  151,  151,  151,  151,
+    0,    0,  151,  151,  151,    0,    0,    0,    0,  151,
+  151,    0,    0,    0,  151,  151,    0,   67,    0,    0,
+    0,    0,    0,    0,  151,    0,    0,   67,  151,  151,
+    0,    0,    0,  151,    0,    0,    0,    0,    0,  151,
+    0,  151,  151,    0,  151,    0,  151,  151,  151,  151,
+  151,    0,  151,  151,  151,  151,  151,  151,  151,  151,
+  151,  151,  151,  151,  151,  151,  151,  151,    0,    0,
+  151,  151,  151,    0,  151,  151,  151,    0,  151,  151,
+  151,    0,    0,  151,    0,  151,    0,    0,  151,  151,
+  151,  151,    0,    0,  151,  151,  151,    0,    0,    0,
+    0,    0,  151,    0,    0,  151,  151,  151,  151,  151,
+  151,  151,  151,    0,  151,  151,  151,  151,  151,    0,
+    0,  151,  149,    0,    0,    0,    0,    0,  151,  151,
+  151,    0,    0,    0,    0,    0,    0,  151,  151,    0,
+    0,  149,    0,  149,    0,    0,  149,  149,  149,  149,
+  149,  149,  149,    0,    0,  149,  149,  149,    0,    0,
+    0,    0,  149,  149,    0,    0,    0,  149,  149,    0,
+   68,    0,    0,    0,    0,    0,    0,  149,    0,    0,
+   68,  149,  149,    0,    0,    0,  149,    0,    0,    0,
+    0,    0,  149,    0,  149,  149,    0,  149,    0,  149,
+  149,  149,  149,  149,    0,  149,  149,  149,  149,  149,
+  149,  149,  149,  149,  149,  149,  149,  149,  149,  149,
+  149,    0,    0,  149,  149,  149,    0,  149,  149,  149,
+    0,  149,  149,  149,    0,    0,  149,    0,  149,    0,
+    0,  149,  149,  149,  149,    0,    0,  149,  149,  149,
+    0,    0,    0,    0,    0,  149,    0,    0,  149,  149,
+  149,  149,  149,  149,  149,  149,    0,  149,  149,  149,
+  149,  149,    0,   67,  149,    0,    0,    0,    0,    0,
+    0,  149,  149,  149,    0,    0,    0,    0,    0,    0,
+  149,  149,   67,    0,   67,    0,    0,   67,   67,   67,
+   67,   67,   67,   67,    0,    0,   67,   67,   67,    0,
+    0,    0,    0,   67,   67,    0,    0,    0,   67,   67,
+    0,   40,    0,    0,    0,    0,    0,    0,   67,    0,
+    0,   40,   67,   67,    0,    0,    0,   67,    0,    0,
+    0,    0,    0,   67,    0,   67,   67,    0,   67,    0,
+   67,   67,   67,   67,   67,    0,   67,   67,   67,   67,
+   67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+   67,   67,    0,    0,   67,   67,   67,    0,   67,   67,
+   67,    0,   67,   67,   67,    0,    0,   67,    0,   67,
+    0,    0,   67,   67,   67,   67,    0,    0,   67,   67,
+   67,    0,    0,    0,    0,    0,   67,    0,    0,   67,
+   67,   67,   67,   67,   67,   67,   67,    0,   67,   67,
+   67,   67,   67,    0,    0,   67,   68,    0,    0,    0,
+    0,    0,   67,   67,   67,    0,    0,    0,    0,    0,
+    0,   67,   67,    0,    0,   68,    0,   68,    0,    0,
+   68,   68,   68,   68,   68,   68,   68,    0,    0,   68,
+   68,   68,    0,    0,    0,    0,   68,   68,    0,    0,
+    0,   68,   68,    0,  438,    0,    0,    0,    0,    0,
+    0,   68,    0,    0,  438,   68,   68,    0,    0,    0,
+   68,    0,    0,    0,    0,    0,   68,    0,   68,   68,
+    0,   68,    0,   68,   68,   68,   68,   68,    0,   68,
+   68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+   68,   68,   68,   68,   68,    0,    0,   68,   68,   68,
+    0,   68,   68,   68,    0,   68,   68,   68,    0,    0,
+   68,    0,   68,    0,    0,   68,   68,   68,   68,    0,
+    0,   68,   68,   68,    0,    0,    0,    0,    0,   68,
+    0,    0,   68,   68,   68,   68,   68,   68,   68,   68,
+    0,   68,   68,   68,   68,   68,    0,   40,   68,    0,
+    0,    0,    0,    0,    0,   68,   68,   68,    0,    0,
+    0,    0,    0,    0,   68,   68,   40,    0,   40,    0,
+    0,   40,   40,   40,   40,   40,   40,   40,    0,    0,
+   40,   40,   40,    0,    0,    0,    0,   40,   40,    0,
+    0,    0,   40,   40,    0,  439,    0,    0,    0,    0,
+    0,    0,   40,    0,    0,  439,   40,   40,    0,    0,
+    0,   40,    0,    0,    0,    0,    0,   40,    0,   40,
+   40,    0,   40,    0,   40,   40,   40,   40,   40,    0,
+   40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
+   40,   40,   40,   40,   40,   40,    0,    0,   40,   40,
+   40,    0,   40,   40,   40,    0,   40,   40,   40,    0,
+    0,   40,    0,   40,    0,    0,   40,   40,   40,   40,
+    0,    0,   40,   40,   40,    0,    0,    0,    0,    0,
+   40,    0,    0,   40,   40,   40,   40,   40,   40,   40,
+   40,    0,   40,   40,   40,   40,   40,    0,    0,   40,
+  438,    0,    0,    0,    0,    0,   40,   40,   40,    0,
+    0,    0,    0,    0,    0,   40,   40,    0,    0,  438,
+    0,  438,    0,    0,  438,  438,  438,  438,  438,  438,
+  438,    0,    0,  438,  438,  438,    0,    0,    0,    0,
+  438,  438,    0,    0,    0,  438,  438,    0,  467,    0,
+    0,    0,    0,    0,    0,  438,    0,    0,  467,  438,
+  438,    0,    0,    0,  438,    0,    0,    0,    0,    0,
+  438,    0,  438,  438,    0,  438,    0,  438,  438,  438,
+  438,  438,    0,  438,  438,  438,  438,  438,  438,  438,
+  438,  438,  438,  438,  438,  438,  438,  438,  438,    0,
+    0,  438,  438,  438,    0,  438,  438,  438,    0,  438,
+  438,  438,    0,    0,  438,    0,  438,    0,    0,  438,
+  438,  438,  438,    0,    0,  438,  438,  438,    0,    0,
+    0,    0,    0,  438,    0,    0,  438,  438,  438,  438,
+  438,  438,  438,  438,    0,  438,  438,  438,  438,  438,
+    0,  439,  438,    0,    0,    0,    0,    0,    0,  438,
+  438,  438,    0,    0,    0,    0,    0,    0,  438,  438,
+  439,    0,  439,    0,    0,  439,  439,  439,  439,  439,
+  439,  439,    0,    0,  439,  439,  439,    0,    0,    0,
+    0,  439,  439,    0,    0,    0,  439,  439,    0,   43,
+    0,    0,    0,    0,    0,    0,  439,    0,    0,   43,
+  439,  439,    0,    0,    0,  439,    0,    0,    0,    0,
+    0,  439,    0,  439,  439,    0,  439,    0,  439,  439,
+  439,  439,  439,    0,  439,  439,  439,  439,  439,  439,
+  439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
+    0,    0,  439,  439,  439,    0,  439,  439,  439,    0,
+  439,  439,  439,    0,    0,  439,    0,  439,    0,    0,
+  439,  439,  439,  439,    0,    0,  439,  439,  439,    0,
+    0,    0,    0,    0,  439,    0,    0,  439,  439,  439,
+  439,  439,  439,  439,  439,    0,  439,  439,  439,  439,
+  439,    0,    0,  439,  467,    0,    0,    0,    0,    0,
+  439,  439,  439,    0,    0,    0,    0,    0,    0,  439,
+  439,    0,    0,  467,    0,  467,    0,    0,  467,  467,
+  467,  467,  467,  467,  467,    0,    0,  467,  467,  467,
+    0,    0,    0,    0,  467,  467,    0,    0,    0,  467,
+  467,    0,  363,    0,    0,    0,    0,    0,    0,  467,
+    0,    0,  363,  467,  467,    0,    0,    0,  467,    0,
+    0,    0,    0,    0,  467,    0,  467,  467,    0,  467,
+    0,  467,  467,  467,  467,  467,    0,  467,  467,  467,
+  467,  467,  467,  467,  467,  467,  467,  467,  467,  467,
+  467,  467,  467,    0,    0,  467,  467,  467,    0,  467,
+  467,  467,    0,  467,  467,  467,    0,    0,  467,    0,
+  467,    0,    0,  467,  467,  467,  467,    0,    0,  467,
+  467,  467,    0,    0,    0,    0,    0,  467,    0,    0,
+  467,  467,  467,  467,  467,  467,  467,  467,    0,  467,
+  467,  467,  467,  467,    0,   43,  467,    0,    0,    0,
+    0,    0,    0,  467,  467,  467,    0,    0,    0,    0,
+    0,    0,  467,  467,   43,    0,   43,    0,    0,   43,
+   43,   43,   43,   43,   43,   43,    0,    0,   43,   43,
+   43,    0,    0,    0,    0,   43,   43,    0,    0,    0,
+   43,   43,    0,  473,    0,    0,    0,    0,    0,    0,
+   43,    0,    0,  473,   43,   43,    0,    0,    0,   43,
+    0,    0,    0,    0,    0,   43,    0,   43,   43,    0,
+   43,    0,   43,   43,   43,   43,   43,    0,   43,   43,
+   43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
+   43,   43,   43,   43,    0,    0,   43,   43,   43,    0,
+   43,   43,   43,    0,   43,   43,   43,    0,    0,   43,
+    0,   43,    0,    0,   43,   43,   43,   43,    0,    0,
+   43,   43,   43,    0,    0,    0,    0,    0,   43,    0,
+    0,   43,   43,   43,   43,   43,   43,   43,   43,    0,
+   43,   43,   43,   43,   43,    0,    0,   43,  363,    0,
+    0,    0,    0,    0,   43,   43,   43,    0,    0,    0,
+    0,    0,    0,   43,   43,    0,    0,  363,    0,  363,
+    0,    0,  363,  363,  363,  363,  363,  363,  363,    0,
+    0,  363,  363,  363,    0,    0,    0,    0,  363,  363,
+    0,    0,    0,  363,  363,    0,  365,    0,    0,    0,
+    0,    0,    0,  363,    0,    0,  365,  363,  363,    0,
+    0,    0,  363,    0,    0,    0,    0,    0,  363,    0,
+  363,  363,    0,  363,    0,  363,  363,  363,  363,  363,
+    0,  363,  363,  363,  363,  363,  363,  363,  363,  363,
+  363,  363,  363,  363,  363,  363,  363,    0,    0,  363,
+  363,  363,    0,  363,  363,  363,    0,  363,  363,  363,
+    0,    0,  363,    0,  363,    0,    0,  363,  363,  363,
+  363,    0,    0,  363,  363,  363,    0,    0,    0,    0,
+    0,  363,    0,    0,  363,  363,  363,  363,  363,  363,
+  363,  363,    0,  363,  363,  363,  363,  363,    0,  473,
+  363,    0,    0,    0,    0,    0,    0,  363,  363,  363,
+    0,    0,    0,    0,    0,    0,  363,  363,  473,    0,
+  473,    0,    0,  473,  473,  473,  473,  473,  473,  473,
+    0,    0,  473,  473,  473,    0,    0,    0,    0,  473,
+  473,    0,    0,    0,  473,  473,    0,  409,    0,    0,
+    0,    0,    0,    0,  473,    0,    0,  409,  473,  473,
+    0,    0,    0,  473,    0,    0,    0,    0,    0,  473,
+    0,  473,  473,    0,  473,    0,  473,  473,  473,  473,
+  473,    0,  473,  473,  473,  473,  473,  473,  473,  473,
+  473,  473,  473,  473,  473,  473,  473,  473,    0,    0,
+  473,  473,  473,    0,  473,  473,  473,    0,  473,  473,
+  473,    0,    0,  473,    0,  473,    0,    0,  473,  473,
+  473,  473,    0,    0,  473,  473,  473,    0,    0,    0,
+    0,    0,  473,    0,    0,  473,  473,  473,  473,  473,
+  473,  473,  473,    0,  473,  473,  473,  473,  473,    0,
+    0,  473,  365,    0,    0,    0,    0,    0,  473,  473,
+  473,    0,    0,    0,    0,    0,    0,  473,  473,    0,
+    0,  365,    0,  365,    0,    0,  365,  365,  365,  365,
+  365,  365,  365,    0,    0,  365,  365,  365,    0,    0,
+    0,    0,  365,  365,    0,    0,    0,  365,  365,    0,
+  549,    0,    0,    0,    0,    0,    0,  365,    0,    0,
+  549,  365,  365,    0,    0,    0,  365,    0,    0,    0,
+    0,    0,  365,    0,  365,  365,    0,  365,    0,  365,
+  365,  365,  365,  365,    0,  365,  365,  365,  365,  365,
+  365,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+  365,    0,    0,  365,  365,  365,    0,  365,  365,  365,
+    0,  365,  365,  365,    0,    0,  365,    0,  365,    0,
+    0,  365,  365,  365,  365,    0,    0,  365,  365,  365,
+    0,    0,    0,    0,    0,  365,    0,    0,  365,  365,
+  365,  365,  365,  365,  365,  365,    0,  365,  365,  365,
+  365,  365,    0,  409,  365,    0,    0,    0,    0,    0,
+    0,  365,  365,  365,    0,    0,    0,    0,    0,    0,
+  365,  365,  409,    0,  409,    0,    0,  409,  409,  409,
+  409,  409,  409,  409,    0,    0,  409,  409,  409,    0,
+    0,    0,    0,  409,  409,    0,    0,    0,  409,  409,
+    0,  410,    0,    0,    0,    0,    0,    0,  409,    0,
+    0,  410,  409,  409,    0,    0,    0,  409,    0,    0,
+    0,    0,    0,  409,    0,  409,  409,    0,  409,    0,
+  409,  409,  409,  409,  409,    0,  409,  409,  409,  409,
+  409,  409,  409,  409,  409,  409,  409,  409,  409,  409,
+  409,  409,    0,    0,  409,  409,  409,    0,  409,  409,
+  409,    0,  409,  409,  409,    0,    0,  409,    0,  409,
+    0,    0,  409,  409,  409,  409,    0,    0,  409,  409,
+  409,    0,    0,    0,    0,    0,  409,    0,    0,  409,
+  409,  409,  409,  409,  409,  409,  409,    0,  409,  409,
+  409,  409,  409,    0,    0,  409,  549,    0,    0,    0,
+    0,    0,  409,  409,  409,    0,    0,    0,    0,    0,
+    0,  409,  409,    0,    0,  549,    0,  549,    0,    0,
+  549,  549,  549,  549,  549,  549,  549,    0,    0,  549,
+  549,  549,    0,    0,    0,    0,  549,  549,    0,    0,
+    0,  549,  549,    0,  415,    0,    0,    0,    0,    0,
+    0,  549,    0,    0,  415,  549,  549,    0,    0,    0,
+  549,    0,    0,    0,    0,    0,  549,    0,  549,  549,
+    0,  549,    0,  549,  549,  549,  549,  549,    0,  549,
+  549,  549,  549,  549,  549,  549,  549,  549,  549,  549,
+  549,  549,  549,  549,  549,    0,    0,  549,  549,  549,
+    0,  549,  549,  549,    0,  549,  549,  549,    0,    0,
+  549,    0,  549,    0,    0,  549,  549,  549,  549,    0,
+    0,  549,  549,  549,    0,    0,    0,    0,    0,  549,
+    0,    0,  549,  549,  549,  549,  549,  549,  549,  549,
+    0,  549,  549,  549,  549,  549,    0,  410,  549,    0,
+    0,    0,    0,    0,    0,  549,  549,  549,    0,    0,
+    0,    0,    0,    0,  549,  549,  410,    0,  410,    0,
+    0,  410,  410,  410,  410,  410,  410,  410,    0,    0,
+  410,  410,  410,    0,    0,    0,    0,  410,  410,    0,
+    0,    0,  410,  410,    4,    0,    0,    0,    0,    0,
+    0,    0,  410,    0,    4,    0,  410,  410,    0,    0,
+    0,  410,    0,    0,    0,    0,    0,  410,    0,  410,
+  410,    0,  410,    0,  410,  410,  410,  410,  410,    0,
+  410,  410,  410,  410,  410,  410,  410,  410,  410,  410,
+  410,  410,  410,  410,  410,  410,    0,    0,  410,  410,
+  410,    0,  410,  410,  410,    0,  410,  410,  410,    0,
+    0,  410,    0,  410,    0,    0,  410,  410,  410,  410,
+    0,    0,  410,  410,  410,    0,    0,    0,    0,    0,
+  410,    0,    0,  410,  410,  410,  410,  410,  410,  410,
+  410,    0,  410,  410,  410,  410,  410,    0,    0,  410,
+  415,    0,    0,    0,    0,    0,  410,  410,  410,    0,
+    0,    0,    0,    0,    0,  410,  410,    0,    0,  415,
+    0,  415,    0,    0,  415,  415,  415,  415,  415,  415,
+  415,    0,    0,  415,  415,  415,    0,    0,    0,    0,
+  415,  415,    0,    0,    0,  415,  415,  411,    0,    0,
+    0,    0,    0,    0,    0,  415,    0,  411,    0,  415,
+  415,    0,    0,    0,  415,    0,    0,    0,    0,    0,
+  415,    0,  415,  415,    0,  415,    0,  415,  415,  415,
+  415,  415,    0,  415,  415,  415,  415,  415,  415,  415,
+  415,  415,  415,  415,  415,  415,  415,  415,  415,    0,
+    0,  415,  415,  415,    0,  415,  415,  415,    0,  415,
+  415,  415,    0,    0,  415,    0,  415,    0,    0,  415,
+  415,  415,  415,    0,    0,  415,  415,  415,    0,    0,
+    0,    0,    0,  415,    0,    0,  415,  415,  415,  415,
+  415,  415,  415,  415,    0,  415,  415,  415,  415,  415,
+    4,    0,  415,    0,    0,    0,    0,    0,    0,  415,
+  415,    0,    0,    0,    0,    0,    0,    0,  415,  415,
+    0,    4,    0,    0,    4,    4,    4,    4,    4,    4,
+    4,    0,    0,    4,    4,    4,    0,    0,    0,    0,
+    4,    4,    0,    0,    0,    4,    4,    0,  408,    0,
+    0,    0,    0,    0,    0,    4,    0,    0,  408,    4,
+    4,    0,    0,    0,    4,    0,    0,    0,    0,    0,
+    4,    0,    4,    4,    0,    4,    0,    4,    4,    4,
+    4,    4,    0,    4,    4,    4,    4,    4,    4,    4,
+    4,    4,    4,    4,    4,    4,    4,    4,    4,    0,
+    0,    4,    4,    4,    0,    4,    4,    4,    0,    4,
+    4,    4,    0,    0,    4,    0,    4,    0,    0,    4,
+    4,    4,    4,    0,    0,    4,    4,    4,    0,    0,
+    0,    0,    0,    4,    0,    0,    4,    4,    4,    4,
+    4,    4,    4,    4,    0,    4,    4,    4,    4,    4,
+    0,    0,    4,  411,    0,    0,    0,    0,    0,    4,
+    4,    4,    0,    0,    0,    0,    0,    0,    4,    4,
+    0,    0,  411,    0,  411,    0,    0,  411,  411,  411,
+  411,  411,  411,  411,    0,    0,  411,  411,  411,    0,
+    0,    0,    0,  411,  411,    0,    0,    0,  411,  411,
+    0,  354,    0,    0,    0,    0,    0,    0,  411,    0,
+    0,  354,  411,  411,    0,    0,    0,  411,    0,    0,
+    0,    0,    0,  411,    0,  411,  411,    0,  411,    0,
+  411,  411,  411,  411,  411,    0,  411,  411,  411,  411,
+  411,  411,  411,  411,  411,  411,  411,  411,  411,  411,
+  411,  411,    0,    0,  411,  411,  411,    0,  411,  411,
+  411,    0,  411,  411,  411,    0,    0,  411,    0,  411,
+    0,    0,  411,  411,  411,  411,    0,    0,  411,  411,
+  411,    0,    0,    0,    0,    0,  411,    0,    0,  411,
+  411,  411,  411,  411,  411,  411,  411,    0,  411,  411,
+  411,  411,  411,    0,  408,  411,    0,    0,    0,    0,
+    0,    0,  411,  411,  411,    0,    0,    0,    0,    0,
+    0,    0,  411,  408,    0,  408,    0,    0,  408,  408,
+  408,  408,  408,  408,  408,    0,    0,  408,  408,  408,
+    0,    0,    0,    0,  408,  408,    0,    0,    0,  408,
+  408,    0,  455,    0,    0,    0,    0,    0,    0,  408,
+    0,    0,  455,  408,  408,    0,    0,    0,  408,    0,
+    0,    0,    0,    0,  408,    0,  408,  408,    0,  408,
+    0,  408,  408,  408,  408,  408,    0,  408,  408,  408,
+  408,  408,  408,  408,  408,  408,  408,  408,  408,  408,
+  408,  408,  408,    0,    0,  408,  408,  408,    0,  408,
+  408,  408,    0,  408,  408,  408,    0,    0,  408,    0,
+  408,    0,    0,  408,  408,  408,  408,    0,    0,  408,
+  408,  408,    0,    0,    0,    0,    0,  408,    0,    0,
+  408,  408,  408,  408,  408,  408,  408,  408,    0,  408,
+  408,  408,  408,  408,    0,    0,  408,  354,    0,    0,
+    0,    0,    0,  408,  408,    0,    0,    0,    0,    0,
+    0,    0,  408,  408,    0,    0,  354,    0,  354,    0,
+    0,  354,  354,  354,  354,  354,  354,  354,    0,    0,
+  354,  354,  354,    0,    0,    0,    0,  354,  354,    0,
+    0,    0,  354,  354,    0,   24,    0,    0,    0,    0,
+    0,    0,  354,    0,    0,   24,  354,  354,    0,    0,
+    0,  354,    0,    0,    0,    0,    0,  354,    0,  354,
+  354,    0,  354,    0,  354,  354,  354,  354,  354,    0,
+  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
+  354,  354,  354,  354,  354,  354,    0,    0,  354,  354,
+  354,    0,  354,  354,  354,    0,  354,  354,  354,    0,
+    0,  354,    0,  354,    0,    0,  354,  354,  354,  354,
+    0,    0,  354,  354,  354,    0,    0,    0,    0,    0,
+  354,    0,    0,  354,  354,  354,  354,    0,  354,  354,
+  354,    0,  354,  354,  354,  354,  354,    0,  455,  354,
+    0,    0,    0,    0,    0,    0,  354,  354,    0,    0,
+    0,    0,    0,    0,    0,    0,  354,  455,    0,  455,
+    0,    0,  455,  455,  455,  455,  455,  455,  455,    0,
+    0,  455,  455,  455,    0,    0,    0,    0,  455,  455,
+    0,    0,    0,  455,  455,    0,    0,    0,    0,    0,
+    0,    0,    0,  455,    0,    0,    0,  455,  455,    0,
+    0,    0,  455,    0,    0,    0,    0,    0,  455,    0,
+  455,  455,    0,  455,    0,  455,  455,  455,  455,  455,
+    0,  455,  455,  455,  455,  455,  455,  455,  455,  455,
+  455,  455,  455,  455,  455,  455,  455,    0,    0,  455,
+  455,  455,    0,  455,  455,  455,    0,  455,  455,  455,
+    0,    0,  455,    0,  455,    0,    0,  455,  455,  455,
+  455,    0,    0,  455,  455,  455,    0,  188,    0,  540,
+  150,  455,  151,    0,  455,  455,  455,  455,    0,  455,
+  455,  455,    0,  455,  455,  455,  455,  455,  545,    0,
+  455,   24,    0,    0,    0,    0,    0,  455,  455,    0,
+    0,    0,    0,    0,    0,    0,    0,  455,    0,    0,
+   24,    0,   24,    0,    0,   24,   24,   24,   24,   24,
+   24,   24,    0,    0,   24,   24,   24,    0,    0,    0,
+    0,   24,   24,    0,    0,    0,   24,   24,    0,  638,
+  417,  415,    0,  416,    0,    0,   24,    0,    0,    0,
+   24,   24,    0,    0,    0,   24,  901,    0,  420,  403,
+  421,   24,    0,   24,   24,    0,   24,    0,   24,   24,
+   24,   24,   24,    0,   24,   24,   24,   24,   24,   24,
+   24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
+    0,    0,   24,   24,   24,    0,   24,   24,   24,    0,
+   24,   24,   24,    0,    0,   24,    0,   24,    0,    0,
+   24,   24,   24,   24,    0,    0,   24,   24,   24,    0,
+  188,    0,  540,  150,   24,  151,    0,   24,   24,   24,
+   24,   24,   24,   24,   24,    0,   24,   24,   24,   24,
+   24,  734,    0,   24,    0,    0,    0,    0,    0,    0,
+   24,   24,   24,    0,    0,    0,    0,    0,    0,   24,
+    0,    0,    0,    0,    0,    0,    0,    0,  188,    0,
+    0,  150,    0,  151,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  644,
+  149,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  177,  188,    0,    0,
+  150,    0,  151,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,  666,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,  149,   89,    0,    0,    0,    0,    0,
+    0,  187,    0,    0,    0,  188,    0,    0,  150,    0,
+  151,    0,    0,    0,    0,    0,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,  668,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,  149,  165,  166,  167,    0,    0,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,    0,  176,    0,    0,
+    0,    0,    0,    0,    0,  152,  153,    0,    0,    0,
+  154,  155,  156,  157,    0,    0,    0,    0,    0,    0,
+    0,    0,  158,  159,  160,  161,  162,  163,  164,    0,
+  165,  166,  167,    0,    0,  168,  169,  170,    0,  171,
+  172,  173,  174,  175,    0,  176,    0,    0,    0,  177,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,    0,    0,    0,  180,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,    0,  188,   89,  706,  150,
+    0,  151,    0,    0,  187,    0,    0,  177,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  178,  179,
+    0,    0,    0,    0,  180,    0,    0,    0,    0,    0,
+  149,    0,    0,    0,  181,  182,    0,    0,  183,  184,
+  185,  186,    0,    0,  188,   89,  540,  150,    0,  151,
+    0,    0,  187,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,  149,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,    0,  176,    0,    0,    0,  177,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,  188,    0,   89,  150,    0,  151,    0,    0,
+    0,  187,    0,    0,  177,    0,    0,    0,    0,    0,
+  813,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,    0,  149,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,  188,    0,    0,  150,  187,
+  151,    0,    0,  152,  153,    0,    0,    0,  154,  155,
+  156,  157,    0,  898,    0,    0,    0,    0,    0,    0,
+  158,  159,  160,  161,  162,  163,  164,  149,  165,  166,
+  167,    0,    0,  168,  169,  170,    0,  171,  172,  173,
+  174,  175,    0,  176,    0,    0,    0,    0,    0,    0,
+    0,  152,  153,    0,    0,    0,  154,  155,  156,  157,
+    0,    0,    0,    0,    0,    0,    0,    0,  158,  159,
+  160,  161,  162,  163,  164,    0,  165,  166,  167,    0,
+    0,  168,  169,  170,    0,  171,  172,  173,  174,  175,
+    0,  176,    0,    0,    0,  177,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  178,  179,    0,    0,
+    0,    0,  180,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  181,  182,    0,    0,  183,  184,  185,  186,
+    0,    0,    0,   89,  188,    0,  709,  150,    0,  151,
+  187,    0,    0,  177,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,    0,    0,
+  180,    0,    0,    0,    0,  149,    0,    0,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,    0,
+    0,   89,  188,    0,  951,  150,    0,  151,  187,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  177,  176,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,  188,    0,   89,
+  150,    0,  151,    0,    0,    0,  187,    0,    0,    0,
+    0,    0,    0,    0,  177,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,  149,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+  382,    0,   89,  150,    0,  151,    0,    0,    0,  187,
+    0,  152,  153,    0,    0,    0,  154,  155,  156,  157,
+    0,    0,    0,    0,    0,    0,    0,    0,  158,  159,
+  160,  161,  162,  163,  164,  149,  165,  166,  167,    0,
+    0,  168,  169,  170,    0,  171,  172,  173,  174,  175,
+    0,  176,    0,    0,    0,    0,    0,    0,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,    0,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,  177,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,    0,    0,
+  180,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,  188,
+    0,   89,  150,    0,  151,    0,    0,    0,  187,    0,
+    0,  177,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+  149,    0,    0,    0,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,  507,    0,   89,
+  150,    0,  151,    0,  152,  153,  187,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,  149,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,    0,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,    0,  165,  166,  167,    0,    0,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,  177,  176,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,  382,    0,   89,  150,    0,  151,    0,    0,
+    0,  187,    0,    0,    0,    0,    0,    0,    0,  177,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,    0,    0,    0,  180,    0,    0,    0,
+    0,    0,  149,    0,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,  908,    0,   89,  150,    0,
+  151,    0,    0,    0,  187,    0,  152,  153,    0,    0,
+    0,  154,  155,  156,  157,    0,    0,    0,    0,    0,
+    0,    0,    0,  158,  159,  160,  161,  162,  163,  164,
+  149,  165,  166,  167,    0,    0,  168,  169,  170,    0,
+  171,  172,  173,  174,  175,    0,  176,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,  567,    0,  564,  333,    0,  334,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,  177,    0,
+  341,    0,  335,  333,    0,  334,    0,    0,    0,  178,
+  179,    0,    0,    0,    0,  180,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  181,  182,    0,    0,  183,
+  184,  185,  186,    0,    0,    0,   89,    0,    0,    0,
+    0,    0,    0,  445,    0,    0,  177,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,  149,  247,  247,  247,    0,
+  247,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,  247,   89,  247,  247,  247,    0,  152,
+  153,  187,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,  518,  518,  518,
+  518,  518,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,  518,  518,  518,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  177,  176,  437,  417,  415,    0,  416,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,  565,  180,    0,
+    0,    0,  420,  403,  421,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,  601,  417,  415,  892,
+  416,    0,  336,  337,  338,    0,  187,  339,    0,    0,
+    0,    0,    0,    0,  177,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,  336,  337,
+  338,  181,  182,  339,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,    0,    0,  247,  247,  247,  247,  247,    0,  247,
+  247,  247,  247,  247,  247,    0,    0,  247,  247,  608,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,  420,  403,
+  421,    0,    0,  622,  417,  415,    0,  416,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,    0,
+    0,  566,  420,  403,  421,    0,    0,    0,  187,    0,
+  178,  179,    0,    0,  518,  518,  518,  518,  518,    0,
+  518,  518,  518,  518,  518,  518,  181,  182,  518,  518,
+  183,  184,  185,  186,  638,  417,  415,  340,  416,    0,
+    0,    0,    0,    0,  187,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  672,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,  677,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,  679,  417,  415,    0,  416,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  420,  403,  421,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,  781,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  782,  417,  415,
+    0,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,  783,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,  784,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,  785,  417,
+  415,    0,  416,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  420,  403,  421,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  786,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,  787,  417,  415,    0,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  788,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,  789,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,    0,
+    0,    0,    0,    0,    0,  404,  405,  406,  407,  408,
+    0,  409,  410,  411,  412,  413,  414,    0,    0,  418,
+  419,  790,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,  791,  417,  415,    0,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  792,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  793,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,  802,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  862,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  904,  417,  415,
+    0,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,  247,
+  247,  247,    0,  247,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  247,  247,
+  247,  417,  415,  680,  416,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  420,
+  403,  421,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  417,  415,  933,  416,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  420,  403,  421,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  417,  415,  969,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,  417,  415,
+  970,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,  247,  247,  247,  247,
+  247,    0,  247,  247,  247,  247,  247,  247,    0,    0,
+  247,  247,    0,    0,    0,    0,    0,  404,  405,  406,
+  407,  408,    0,  409,  410,  411,  412,  413,  414,    0,
+    0,  418,  419,  417,  415,  975,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  247,  247,  247,  247,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  247,  247,  247,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+  247,  247,  247,  247,  247,    0,  247,  247,  247,  247,
+  247,  247,    0,   16,  247,  247,   17,    0,   18,   19,
+    0,    0,   20,    0,    0,   21,   22,   23,    0,    0,
+    0,    0,   24,   25,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,   26,    0,    0,
+    0,   27,   28,    0,    0,    0,   29,    0,    0,    0,
+    0,    0,   30,    0,   31,   32,    0,   33,    0,   34,
+   35,   36,   37,   38,    0,   39,   40,   41,   42,   43,
+   44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
+   54,    0,    0,   55,   56,   57,    0,   58,   59,   60,
+    0,   61,   62,   63,    0,    0,   64,    0,   65,    0,
+    0,   66,   67,   68,   69,    0,    0,   70,   71,   72,
+    0,    0,    0,    0,    0,   73,    0,    0,    0,   74,
+   75,   76,   77,   78,   79,   80,    0,   81,   82,   83,
+   84,   85,    0,    0,   86,    0,    0,    0,    0,    0,
+    0,   87,   88,   89,    0,    0,    0,    0,    0,    0,
+   90,
+};
+short fortrancheck[] = {                                      24,
+  231,   26,  140,  309,  194,   30,   33,  177,   33,  236,
+  231,  347,  290,  331,   39,  236,   19,   11,  296,  140,
+   44,  303,  394,  341,  177,   40,   40,   40,   44,   40,
+   40,  349,   44,  529,   10,  188,   10,   10,   10,  295,
+   42,  177,   58,   40,   68,   69,  302,   44,   41,   42,
+   41,   42,   76,  279,   44,  382,  449,   40,  581,   44,
+   37,   58,  585,  731,   41,   59,  106,   44,   58,   93,
+   94,   95,   42,   43,   44,   45,  765,   37,   44,   42,
+  111,  234,   58,   44,   61,  735,  143,   44,   37,  120,
+  121,   40,   58,  231,  373,   10,   32,   58,  236,   37,
+   10,   61,  504,   41,  417,  130,   44,   60,  135,   62,
+  135,  424,   61,  800,  801,  517,   10,  425,  217,  271,
+  272,   57,   58,  148,  149,   42,   43,  417,   45,   44,
+   10,   42,  157,  371,  128,   43,   44,   45,  417,  238,
+   41,   42,   43,   60,   45,   62,  171,  385,   58,   60,
+   40,   62,  177,  271,  272,   41,  104,   40,   44,  107,
+  271,  272,   44,  188,   58,   41,  417,  192,   44,  578,
+   44,  427,   58,   40,  344,   42,   58,  586,  203,  847,
+  350,  579,   58,  581,   58,  210,   40,  585,   43,   44,
+   45,  417,   40,  331,  219,  524,  885,  350,  885,  224,
+  529,   37,   40,  341,   41,   41,  344,   44,   44,  234,
+  331,  349,  382,  207,  350,  386,  387,  388,  868,  244,
+  341,   58,    0,  344,  281,   42,  328,  329,  349,  382,
+   47,  487,   10,  569,  490,  541,  276,  231,  417,  545,
+  234,  577,  236,  237,  912,  270,  382,   40,  242,  567,
+   42,   43,   41,   45,   40,   44,  512,  593,   58,  272,
+  272,  264,  293,  401,   40,  417,   42,  283,   40,   58,
+  588,  589,  590,  591,  592,   43,   41,   45,  534,   44,
+  283,  275,  307,   40,  309,  375,  283,  272,  319,  271,
+  272,   42,   43,  283,   45,   40,   41,  322,  323,  417,
+  271,  272,  272,  328,  298,  632,  417,  634,  635,  272,
+  273,  336,  337,  338,  339,  272,  417,  283,  549,  255,
+  273,   41,  283,  550,   44,  350,  320,   44,  549,  550,
+  324,   42,  280,  271,  272,  360,  156,   58,  158,  364,
+  365,  366,  367,  368,  369,  370,  371,  372,  373,  374,
+  375,  744,  745,  275,  507,  272,  273,  382,  140,  141,
+  856,  272,  273,  886,  272,  763,  764,  863,  766,  394,
+  271,  272,  273,   41,   42,   43,  256,   45,  403,  404,
+  405,  406,  407,  408,  409,  410,  411,  412,  413,  414,
+  415,  416,  417,  418,  419,  420,  421,  374,  423,  424,
+  406,  417,  417,  119,  284,  285,  122,  417,  578,  424,
+  424,  549,  550,  424,  374,  417,  586,  272,  281,  755,
+  417,  301,  302,  406,  417,  374,  417,  417,  734,  567,
+   44,   44,  768,  769,  770,  771,  772,  719,  756,  811,
+  578,  417,  720,  417,  417,  417,  567,   44,  586,  705,
+  588,  589,  590,  591,  592,  682,  417,  578,  417,  417,
+  687,  682,  486,   44,   40,  586,  687,  588,  589,  590,
+  591,  592,  799,  800,  801,  417,   40,  424,  256,  271,
+  272,  273,  507,   40,  637,   40,  511,   40,  886,   40,
+  521,  747,  523,  518,   40,   40,  632,  275,  634,  635,
+  525,   41,  533,  281,   44,   40,  284,  285,   42,   43,
+   44,   45,  392,   47,  539,   41,  541,   40,   44,   40,
+  545,  272,  273,  301,  302,   40,   40,  856,  857,  858,
+  859,  860,   42,   43,  863,   45,   40,   47,  358,  359,
+  938,  566,   40,   40,  682,  425,   37,  883,   40,  687,
+   41,  576,   40,   44,   40,  549,  550,  377,  378,  379,
+  380,  381,   37,   40,  870,  417,   41,   40,  824,   44,
+  390,   40,   40,  289,  601,  291,  601,  602,   40,   42,
+   43,   40,   45,  299,   41,   42,   43,   40,   45,   37,
+  846,   42,   43,   44,   45,  765,   47,   60,   61,   62,
+  753,  722,   40,  271,  272,  273,  417,  632,   41,  634,
+  635,   44,  637,   44,  392,   58,  641,   41,  756,  644,
+   44,  877,  857,  858,  859,  860,   37,  765,  818,   40,
+   41,   42,   43,   44,   45,  756,  661,  662,  417,   41,
+  417,  666,   44,  668,  765,   41,  799,  425,   44,   60,
+  881,   62,   44,   44,   41,  680,  681,   44,   41,   41,
+   58,   44,   44,  799,  800,  801,   41,   37,  693,   44,
+  695,  417,   42,   43,   41,   45,   41,   44,   41,   44,
+  674,   44,   41,  708,   41,   44,   41,   44,  682,   44,
+   60,   61,   62,  687,   44,  689,   41,    0,   41,   44,
+   41,   44,   41,   44,   40,   44,  424,   10,   61,  734,
+  390,  391,  417,   41,   41,  885,   44,   44,   44,   41,
+   41,  746,   44,   44,  417,  750,  406,  407,  753,  417,
+  410,  411,  412,  413,  417,   44,  730,   40,  272,   42,
+   43,   44,   45,   41,  424,  390,  391,  885,   41,   41,
+   41,   44,   44,   44,   44,  908,   40,   60,   61,   62,
+   41,  406,  407,   44,  885,  410,  411,  412,  413,   41,
+   41,   40,   44,   44,  799,  800,  801,   41,   41,  424,
+   44,   44,   41,  424,   41,   44,  811,   44,  813,   41,
+   41,   41,   44,   44,   44,  258,  259,  260,  261,  262,
+   61,  264,  265,  266,  267,  268,  269,   44,   41,  272,
+  273,   44,  278,  838,  271,  272,  273,   41,   41,   41,
+   44,   44,   44,   41,   44,  850,   44,  852,   41,   44,
+  380,   44,   44,   44,   44,   40,   44,   37,   41,   41,
+   44,   40,  272,   44,  417,  870,   40,  258,  259,  260,
+  261,  262,  417,  264,  265,  266,  267,  268,  269,   41,
+   44,  272,  273,  417,   41,  417,   61,   41,  424,   44,
+  273,   44,   40,  898,   44,  900,  901,   44,   44,   58,
+   41,   41,  332,  908,  417,   41,   41,  881,  258,  259,
+  260,  261,  262,   42,  264,  265,  266,  267,  268,  269,
+   58,  417,  272,  273,   41,   37,  272,    0,  933,   40,
+   42,   43,  906,   45,  272,  940,  272,   10,   41,   58,
+  374,  946,  417,   44,  949,   41,   44,   61,   60,   61,
+   62,   41,  417,  417,   41,   41,   41,  962,   41,   61,
+   41,  966,   41,   41,  969,  970,  374,   44,  272,   41,
+  975,   44,   47,  256,  417,  258,  259,  260,  261,  262,
+   44,  264,  265,  266,  267,  268,  269,   41,  271,  272,
+  273,   61,  275,  417,  277,  417,  417,  280,  281,  282,
+  283,  284,  285,  286,  287,  288,  289,  290,  291,  292,
+  293,  294,  295,  296,  297,  417,  417,   44,  301,  302,
+   41,  304,  305,  306,  307,  308,  309,  310,  311,  312,
+  313,  314,  315,  316,  317,  318,  319,  320,  321,  322,
+  323,  324,  325,  326,  327,  328,  329,   41,  331,   58,
+  333,  334,  335,  336,  337,   41,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   41,   41,  357,  358,  359,   44,  361,  362,
+  363,   41,  365,  366,  367,   41,  272,  370,   41,  372,
+   41,   41,  375,  376,  377,  378,   41,  775,  381,  382,
+  383,  850,  957,  873,  520,  271,  389,  390,  391,  392,
+  393,  394,  395,  396,  397,  398,  399,  285,  401,  402,
+  403,  404,  405,  406,  407,  408,    0,  410,  411,  412,
+  413,  773,  415,  416,  417,  350,   10,  382,  681,  402,
+  900,  424,  425,  753,  852,    9,  258,  259,  260,  261,
+  262,   13,  264,  265,  266,  267,  268,  269,   74,  275,
+  272,  273,  691,   37,  429,  952,  539,   41,   42,   43,
+   44,   45,  695,   47,  528,  502,  537,  701,  557,  128,
+  549,  750,  550,  256,   58,  559,   60,   61,   62,  756,
+   -1,   -1,  140,   -1,   -1,   -1,   -1,   -1,  271,  272,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   37,   -1,  408,   -1,   41,   42,   43,
+   44,   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   58,   -1,   60,   61,   62,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,  271,  272,  273,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   40,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   40,   -1,   -1,   43,   -1,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  256,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,  271,  272,  273,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   37,   -1,  408,   -1,   41,   42,   43,   44,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   58,   -1,   60,   61,   62,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,    0,   -1,   -1,  396,   -1,
+   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   -1,   37,   -1,  379,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   58,   -1,   60,   61,   62,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,  273,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   40,   -1,  408,   43,   -1,   45,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  256,   61,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,  273,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   42,   43,   -1,   45,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   60,  326,   62,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,  277,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   40,   41,   42,   43,   44,   45,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   58,   -1,   60,   61,   62,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  328,  329,  330,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   42,   43,   -1,
+   45,   -1,   -1,   -1,  263,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  272,   -1,   60,  357,   62,  359,  360,
+  361,   -1,   -1,  364,  365,   -1,  367,  368,  287,  288,
+   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,
+  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,  318,
+  319,   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  379,   37,   -1,   -1,   -1,   41,   42,   43,   44,   45,
+   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,
+   -1,   -1,   58,   -1,   60,   61,   62,  406,  407,   -1,
+   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,
+  256,   -1,  258,  259,  260,  261,  262,   -1,  264,  265,
+  266,  267,  268,  269,   -1,  271,  272,  273,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,  262,   -1,  264,
+  265,  266,  267,  268,  269,  311,   -1,  272,  273,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   40,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   40,   -1,   42,   43,   -1,   45,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  256,   58,  258,  259,  260,  261,  262,   -1,  264,  265,
+  266,  267,  268,  269,   -1,  271,  272,  273,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,  380,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   37,   -1,  408,   -1,   41,   42,   43,   44,   45,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,   58,   -1,   60,   61,   62,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,   -1,  312,  313,  314,   -1,  263,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,
+  307,  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,
+  317,  318,  319,   -1,  321,  322,  323,  324,  325,   -1,
+  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,    0,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,   -1,   10,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   -1,   -1,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  379,   -1,   41,   42,   43,   44,   45,   -1,
+   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,
+   -1,   58,   -1,   60,   61,   62,   -1,   -1,   -1,  406,
+  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,  256,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,  271,  272,  273,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   40,   -1,   42,   43,   -1,   45,  415,  416,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  256,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,  271,  272,  273,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   42,   43,
+   -1,   45,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   60,   -1,   62,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,   42,   43,   44,   45,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,  288,   -1,   -1,
+   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,  310,
+   -1,  312,  313,  314,   -1,  263,  317,  318,  319,   -1,
+   -1,  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,
+   -1,  379,   -1,   41,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+   58,   -1,   -1,   61,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,  256,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  256,   -1,
+  258,  259,  260,  261,  262,    0,  264,  265,  266,  267,
+  268,  269,   -1,  271,  272,   10,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   37,  301,  302,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   58,   -1,   -1,   61,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,   -1,  288,    0,   -1,   -1,  292,  293,
+  294,  295,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,
+  304,  305,  306,  307,  308,  309,  310,   -1,  312,  313,
+  314,   -1,   -1,  317,  318,  319,   -1,   -1,  322,  323,
+  324,  325,   37,  327,   -1,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   58,   -1,   -1,   61,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,  417,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  256,   -1,  258,  259,  260,  261,  262,    0,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,   10,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   37,  301,  302,   -1,   41,
+   42,   43,   44,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   58,   -1,   -1,   61,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,  286,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,  311,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,   -1,   -1,   -1,  331,
+  332,   -1,   -1,   -1,  336,  337,   -1,   -1,   -1,   41,
+   42,   43,   44,   45,  346,  347,  348,  349,  350,  351,
+  352,  353,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,  366,   -1,   -1,   -1,   -1,   -1,
+  372,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  381,
+   -1,  383,   -1,   -1,  256,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,  271,
+  272,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,  417,   -1,  289,  290,  291,
+   -1,   -1,  424,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   40,   -1,   42,
+   43,   -1,   45,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  256,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,   42,
+   43,   -1,   45,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   60,   61,   62,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   37,   -1,  379,   -1,   41,   -1,
+   43,   44,   45,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   58,   -1,   -1,   61,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,   -1,  256,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,  256,   -1,  258,  259,  260,  261,  262,
+    0,  264,  265,  266,  267,  268,  269,   -1,  271,   -1,
+   10,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   37,  301,  302,
+   -1,   41,   -1,   43,   44,   45,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   58,   -1,
+   -1,   61,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,   42,   -1,   44,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,   -1,
+   60,   -1,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,    0,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  256,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,  271,   -1,  273,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+  380,  381,  382,  383,   37,   -1,   -1,   -1,   41,  389,
+   -1,   44,  392,  393,  394,  395,   -1,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   60,  408,   62,
+   -1,   42,   43,   44,   45,  415,  416,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  425,   -1,   -1,   -1,   60,
+   61,   62,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,   -1,   -1,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,   -1,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   42,   43,   44,   45,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,  260,
+  261,  262,   -1,  264,  265,  266,  267,  268,  269,   -1,
+   -1,  272,  273,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,    0,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   10,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,   -1,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,   -1,   -1,   -1,  415,  416,   -1,  256,   -1,  258,
+  259,  260,  261,  262,  425,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,   -1,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   37,  256,  408,
+   -1,   41,   -1,   -1,   44,   -1,  415,  416,   -1,   -1,
+   -1,   -1,   -1,  271,  272,   -1,  425,  275,   58,  277,
+   -1,   61,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   37,   -1,
+  408,   -1,   41,   -1,   -1,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,  417,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   40,  328,  329,
+   43,  331,   45,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   40,   -1,   42,   43,  389,
+   45,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   61,  256,  408,  258,
+  259,  260,  261,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   37,   -1,  408,
+   40,   41,   42,   43,   44,   45,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  298,  299,  300,   -1,   -1,
+  303,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  263,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  273,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,    0,  327,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,   37,   -1,
+   -1,  424,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,  272,  273,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,
+   43,   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,  256,   -1,  415,  416,  417,   -1,   -1,
+   -1,    0,   -1,   -1,  424,  425,   -1,   -1,  271,  272,
+  273,   10,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   41,   42,   43,   44,   45,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,    0,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   10,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   42,   43,
+   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  271,  272,  273,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,  256,   -1,   -1,   -1,  415,  416,   -1,   -1,
+    0,   -1,   -1,   -1,   -1,  424,  425,  271,  272,  273,
+   10,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   41,   42,   43,   44,   45,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,    0,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,  256,   -1,   -1,   -1,  415,  416,  417,    0,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  271,  272,   10,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   41,
+   42,   43,   44,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,    0,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   41,   42,   43,   44,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  271,
+  272,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,  256,
+   -1,   -1,   -1,  415,  416,  417,    0,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  271,  272,   10,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   37,  301,  302,   -1,   41,   -1,   -1,
+   44,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   58,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,    0,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   41,  256,   43,   44,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   41,  256,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   41,  256,   -1,   44,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   42,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   61,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,  256,   -1,   44,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   41,   -1,
+   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,    0,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   10,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,  256,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  271,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   10,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+  256,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  271,  272,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   41,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,
+  275,   58,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   10,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   -1,   42,  256,   44,   -1,  415,
+  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,    0,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   10,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   10,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   41,   -1,  256,   44,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,   -1,  256,   44,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   41,
+   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   41,   -1,  256,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,
+   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,    0,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   10,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   44,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,  256,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,    0,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   10,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   44,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,  256,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,    0,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   10,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   44,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   61,   -1,  375,  376,
+  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   -1,   -1,  256,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   10,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,  380,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,  256,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,  271,  272,  424,
+  425,  275,   -1,  277,   -1,   61,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   41,   -1,   -1,   44,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,  278,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,  380,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   41,
+   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,
+   -1,   44,   -1,  415,  416,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   44,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   44,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   10,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   10,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+  256,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  425,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,
+   -1,   -1,   -1,  415,  416,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,   -1,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,  256,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  425,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   40,   -1,   42,
+   43,  389,   45,   -1,  392,  393,  394,  395,   -1,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   61,   -1,
+  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  425,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   41,
+   42,   43,   -1,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   58,   -1,   60,   61,
+   62,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   40,   -1,   42,   43,  389,   45,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   61,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   40,   -1,
+   -1,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   61,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  379,   40,   -1,   -1,
+   43,   -1,   45,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   61,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,  263,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,   -1,   -1,   -1,   40,   -1,   -1,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   61,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,  263,  312,  313,  314,   -1,   -1,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,
+  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  304,  305,  306,  307,  308,  309,  310,   -1,
+  312,  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,
+  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,  379,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   -1,   40,  417,   42,   43,
+   -1,   45,   -1,   -1,  424,   -1,   -1,  379,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,
+   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,
+  263,   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,
+  412,  413,   -1,   -1,   40,  417,   42,   43,   -1,   45,
+   -1,   -1,  424,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,  263,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,   -1,  327,   -1,   -1,   -1,  379,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   40,   -1,  417,   43,   -1,   45,   -1,   -1,
+   -1,  424,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,
+   58,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  263,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   40,   -1,   -1,   43,  424,
+   45,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,
+  294,  295,   -1,   58,   -1,   -1,   -1,   -1,   -1,   -1,
+  304,  305,  306,  307,  308,  309,  310,  263,  312,  313,
+  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,
+  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,
+  306,  307,  308,  309,  310,   -1,  312,  313,  314,   -1,
+   -1,  317,  318,  319,   -1,  321,  322,  323,  324,  325,
+   -1,  327,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,
+   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,
+   -1,   -1,   -1,  417,   40,   -1,   42,   43,   -1,   45,
+  424,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,
+  396,   -1,   -1,   -1,   -1,  263,   -1,   -1,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,
+   -1,  417,   40,   -1,   42,   43,   -1,   45,  424,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,  379,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   40,   -1,  417,
+   43,   -1,   45,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,  263,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   40,   -1,  417,   43,   -1,   45,   -1,   -1,   -1,  424,
+   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,
+  306,  307,  308,  309,  310,  263,  312,  313,  314,   -1,
+   -1,  317,  318,  319,   -1,  321,  322,  323,  324,  325,
+   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,
+  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   40,
+   -1,  417,   43,   -1,   45,   -1,   -1,   -1,  424,   -1,
+   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   40,   -1,  417,
+   43,   -1,   45,   -1,  287,  288,  424,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,  263,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,   -1,  312,  313,  314,   -1,   -1,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,  379,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   40,   -1,  417,   43,   -1,   45,   -1,   -1,
+   -1,  424,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  379,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,  263,   -1,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   40,   -1,  417,   43,   -1,
+   45,   -1,   -1,   -1,  424,   -1,  287,  288,   -1,   -1,
+   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,  310,
+  263,  312,  313,  314,   -1,   -1,  317,  318,  319,   -1,
+  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   40,   -1,   42,   43,   -1,   45,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,  379,   -1,
+   40,   -1,   42,   43,   -1,   45,   -1,   -1,   -1,  390,
+  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  406,  407,   -1,   -1,  410,
+  411,  412,  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,   -1,   -1,  379,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,  263,   41,   42,   43,   -1,
+   45,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   58,  417,   60,   61,   62,   -1,  287,
+  288,  424,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,   43,
+   44,   45,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,  379,  327,   41,   42,   43,   -1,   45,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,  273,  396,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   41,   42,   43,  417,
+   45,   -1,  298,  299,  300,   -1,  424,  303,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,  298,  299,
+  300,  406,  407,  303,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   60,   61,
+   62,   -1,   -1,   41,   42,   43,   -1,   45,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,
+   -1,  417,   60,   61,   62,   -1,   -1,   -1,  424,   -1,
+  390,  391,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,  406,  407,  272,  273,
+  410,  411,  412,  413,   41,   42,   43,  417,   45,   -1,
+   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   41,   42,   43,   -1,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   41,   42,   43,
+   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,   42,
+   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   -1,
+   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   41,   42,   43,
+   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   42,   43,   44,   45,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,
+   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   42,   43,
+   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,
+  261,  262,   -1,  264,  265,  266,  267,  268,  269,   -1,
+   -1,  272,  273,   42,   43,   44,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,  277,  272,  273,  280,   -1,  282,  283,
+   -1,   -1,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,   -1,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 1
+#endif
+#define YYMAXTOKEN 426
+#if YYDEBUG
+char *fortranname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"'!'",0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
+0,0,0,0,0,"':'",0,"'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'['",0,"']'",0,"'_'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"TOK_BINARY_OP","TOK_EQV","TOK_NEQV",
+"TOK_OR","TOK_XOR","TOK_AND","TOK_NOT","TOK_LT","TOK_GT","TOK_LE","TOK_GE",
+"TOK_EQ","TOK_NE","TOK_UNARY_OP","TOK_DSLASH","TOK_SLASH","TOK_DASTER",
+"TOK_SEP","TOK_SEMICOLON","TOK_NEXTLINE","TOK_PARAMETER","TOK_RESULT",
+"TOK_ONLY","TOK_INCLUDE","TOK_SUBROUTINE","TOK_PROGRAM","TOK_FUNCTION",
+"TOK_OMP","TOK_DOLLAR","TOK_FORMAT","TOK_MAX","TOK_TANH","TOK_WHERE",
+"TOK_ELSEWHERE","TOK_ENDWHERE","TOK_MAXVAL","TOK_TRIM","TOK_SUM","TOK_SQRT",
+"TOK_CASE","TOK_SELECTCASE","TOK_FILE","TOK_END","TOK_ERR","TOK_DONOTTREAT",
+"TOK_ENDDONOTTREAT","TOK_EXIST","TOK_MIN","TOK_FLOAT","TOK_EXP","TOK_COS",
+"TOK_COSH","TOK_ACOS","TOK_NINT","TOK_CYCLE","TOK_SIN","TOK_SINH","TOK_ASIN",
+"TOK_EQUIVALENCE","TOK_BACKSPACE","TOK_LOG","TOK_TAN","TOK_ATAN",
+"TOK_RECURSIVE","TOK_ABS","TOK_MOD","TOK_SIGN","TOK_MINLOC","TOK_MAXLOC",
+"TOK_EXIT","TOK_MINVAL","TOK_PUBLIC","TOK_PRIVATE","TOK_ALLOCATABLE",
+"TOK_RETURN","TOK_THEN","TOK_ELSEIF","TOK_ELSE","TOK_ENDIF","TOK_PRINT",
+"TOK_PLAINGOTO","TOK_CONSTRUCTID","TOK_LOGICALIF","TOK_PLAINDO","TOK_CONTAINS",
+"TOK_ENDDO","TOK_MODULE","TOK_ENDMODULE","TOK_DOWHILE","TOK_ALLOCATE",
+"TOK_OPEN","TOK_CLOSE","TOK_INQUIRE","TOK_WRITE","TOK_READ","TOK_REWIND",
+"TOK_DEALLOCATE","TOK_NULLIFY","TOK_FIN","TOK_DEBUT","TOK_DIMENSION",
+"TOK_ENDSELECT","TOK_EXTERNAL","TOK_INTENT","TOK_INTRINSIC","TOK_NAMELIST",
+"TOK_CASEDEFAULT","TOK_OPTIONAL","TOK_POINTER","TOK_CONTINUE","TOK_SAVE",
+"TOK_TARGET","TOK_QUOTE","TOK_IMPLICIT","TOK_NONE","TOK_CALL","TOK_STAT",
+"TOK_POINT_TO","TOK_COMMON","TOK_GLOBAL","TOK_INTERFACE","TOK_ENDINTERFACE",
+"TOK_LEFTAB","TOK_RIGHTAB","TOK_PAUSE","TOK_PROCEDURE","TOK_STOP","TOK_NAMEEQ",
+"TOK_REAL8","TOK_OUT","TOK_INOUT","TOK_IN","TOK_USE","TOK_TRUE","TOK_FALSE",
+"TOK_LABEL","TOK_TYPE","TOK_TYPEPAR","TOK_ENDTYPE","TOK_REAL","TOK_INTEGER",
+"TOK_LOGICAL","TOK_DOUBLEPRECISION","TOK_DOUBLEREAL","TOK_ENDSUBROUTINE",
+"TOK_ENDFUNCTION","TOK_ENDPROGRAM","TOK_ENDUNIT","TOK_CHARACTER",
+"TOK_CHAR_CONSTANT","TOK_CHAR_CUT","TOK_DATA","TOK_CHAR_INT","TOK_CHAR_MESSAGE",
+"TOK_CSTREAL","TOK_CSTREALDP","TOK_CSTREALQP","TOK_SFREAL","TOK_COMPLEX",
+"TOK_DOUBLECOMPLEX","TOK_NAME","TOK_NAME_CHAR","TOK_PROBTYPE","TOK_INTERPTYPE",
+"TOK_VARTYPE","TOK_BC","TOK_OP","TOK_CSTINT","TOK_COMMENT","TOK_FILENAME",
+};
+char *fortranrule[] = {
+"$accept : input",
+"input :",
+"input : input line",
+"line : '\\n' position",
+"line : thislabel suite_line_list",
+"line : TOK_COMMENT",
+"line : keyword cmnt writedeclar",
+"line : error writedeclar nulcurbuf",
+"suite_line_list : suite_line",
+"suite_line_list : suite_line_list TOK_SEMICOLON suite_line",
+"suite_line : entry fin_line",
+"suite_line : spec fin_line",
+"suite_line : before_include filename fin_line",
+"suite_line : exec cmnt writedeclar",
+"suite_line : instr fin_line",
+"instr : ident ':'",
+"fin_line : position cmnt",
+"keyword : TOK_DONOTTREAT",
+"keyword : TOK_ENDDONOTTREAT",
+"keyword : TOK_OMP",
+"keyword : TOK_DOLLAR",
+"position :",
+"thislabel :",
+"thislabel : TOK_LABEL nulcurbuf",
+"cmnt :",
+"cmnt : TOK_COMMENT",
+"incomment :",
+"nulcurbuf :",
+"opt_recursive :",
+"opt_recursive : TOK_RECURSIVE",
+"entry :",
+"entry : opt_recursive TOK_SUBROUTINE name_routine arglist",
+"entry : TOK_PROGRAM name_routine",
+"entry : TOK_FUNCTION name_routine arglist TOK_RESULT arglist1",
+"entry : TOK_FUNCTION name_routine arglist",
+"entry : TOK_MODULE TOK_NAME",
+"name_routine : TOK_NAME",
+"writedeclar :",
+"before_include : TOK_INCLUDE",
+"filename : TOK_CHAR_CONSTANT",
+"arglist :",
+"arglist : '(' ')'",
+"arglist : '(' args ')'",
+"arglist1 :",
+"arglist1 : '(' ')'",
+"arglist1 : '(' args ')'",
+"args : arg",
+"args : args ',' arg",
+"arg : TOK_NAME",
+"arg : '*'",
+"spec : type after_type",
+"spec : TOK_TYPE opt_spec opt_sep opt_name",
+"spec : TOK_ENDTYPE opt_name",
+"spec : TOK_POINTER list_couple",
+"spec : before_parameter '(' paramlist ')'",
+"spec : before_parameter paramlist",
+"spec : common",
+"spec : save",
+"spec : implicit",
+"spec : dimension",
+"spec : public",
+"spec : private",
+"spec : use_stat",
+"spec : module_proc_stmt",
+"spec : interface",
+"spec : namelist",
+"spec : TOK_BACKSPACE '(' expr ')'",
+"spec : TOK_EXTERNAL opt_sep use_name_list",
+"spec : TOK_INTRINSIC opt_sep use_intrinsic_list",
+"spec : TOK_EQUIVALENCE list_expr_equi",
+"spec : before_data data '\\n'",
+"opt_spec :",
+"opt_spec : access_spec",
+"name_intrinsic : TOK_SUM",
+"name_intrinsic : TOK_TANH",
+"name_intrinsic : TOK_MAXVAL",
+"name_intrinsic : TOK_MIN",
+"name_intrinsic : TOK_MINVAL",
+"name_intrinsic : TOK_TRIM",
+"name_intrinsic : TOK_SQRT",
+"name_intrinsic : TOK_NINT",
+"name_intrinsic : TOK_FLOAT",
+"name_intrinsic : TOK_EXP",
+"name_intrinsic : TOK_COS",
+"name_intrinsic : TOK_COSH",
+"name_intrinsic : TOK_ACOS",
+"name_intrinsic : TOK_SIN",
+"name_intrinsic : TOK_SINH",
+"name_intrinsic : TOK_ASIN",
+"name_intrinsic : TOK_LOG",
+"name_intrinsic : TOK_TAN",
+"name_intrinsic : TOK_ATAN",
+"name_intrinsic : TOK_MOD",
+"name_intrinsic : TOK_SIGN",
+"name_intrinsic : TOK_MINLOC",
+"name_intrinsic : TOK_MAXLOC",
+"name_intrinsic : TOK_NAME",
+"use_intrinsic_list : name_intrinsic",
+"use_intrinsic_list : use_intrinsic_list ',' name_intrinsic",
+"list_couple : '(' list_expr ')'",
+"list_couple : list_couple ',' '(' list_expr ')'",
+"list_expr_equi : expr_equi",
+"list_expr_equi : list_expr_equi ',' expr_equi",
+"expr_equi : '(' list_expr_equi1 ')'",
+"list_expr_equi1 : ident dims",
+"list_expr_equi1 : list_expr_equi1 ',' ident dims",
+"list_expr : expr",
+"list_expr : list_expr ',' expr",
+"opt_sep :",
+"opt_sep : ':' ':'",
+"after_type : dcl nodimsgiven",
+"after_type : before_function name_routine arglist",
+"before_function : TOK_FUNCTION",
+"before_parameter : TOK_PARAMETER",
+"before_data : TOK_DATA",
+"data : TOK_NAME TOK_SLASH datavallist TOK_SLASH",
+"data : data opt_comma TOK_NAME TOK_SLASH datavallist TOK_SLASH",
+"data : datanamelist TOK_SLASH datavallist TOK_SLASH",
+"datavallist : expr_data",
+"datavallist : expr_data ',' datavallist",
+"save : before_save varsave",
+"save : before_save comblock varsave",
+"save : save opt_comma comblock opt_comma varsave",
+"save : save ',' varsave",
+"before_save : TOK_SAVE",
+"varsave :",
+"varsave : TOK_NAME dims",
+"datanamelist : TOK_NAME",
+"datanamelist : TOK_NAME '(' expr ')'",
+"datanamelist : datanamelist ',' datanamelist",
+"expr_data : opt_signe simple_const",
+"expr_data : expr_data '+' expr_data",
+"expr_data : expr_data '-' expr_data",
+"expr_data : expr_data '*' expr_data",
+"expr_data : expr_data '/' expr_data",
+"opt_signe :",
+"opt_signe : signe",
+"namelist : namelist_action after_namelist",
+"namelist_action : TOK_NAMELIST ident",
+"namelist_action : TOK_NAMELIST comblock ident",
+"namelist_action : namelist_action opt_comma comblock opt_comma ident",
+"namelist_action : namelist_action ',' ident",
+"after_namelist :",
+"interface : TOK_INTERFACE opt_name",
+"interface : TOK_ENDINTERFACE opt_name",
+"before_dimension : TOK_DIMENSION",
+"dimension : before_dimension opt_comma TOK_NAME dims lengspec",
+"dimension : dimension ',' TOK_NAME dims lengspec",
+"private : TOK_PRIVATE '\\n'",
+"private : TOK_PRIVATE opt_sep use_name_list",
+"public : TOK_PUBLIC '\\n'",
+"public : TOK_PUBLIC opt_sep use_name_list",
+"use_name_list : TOK_NAME",
+"use_name_list : use_name_list ',' TOK_NAME",
+"common : before_common var_common_list",
+"common : before_common comblock var_common_list",
+"common : common opt_comma comblock opt_comma var_common_list",
+"before_common : TOK_COMMON",
+"before_common : TOK_GLOBAL TOK_COMMON",
+"var_common_list : var_common",
+"var_common_list : var_common_list ',' var_common",
+"var_common : TOK_NAME dims",
+"comblock : TOK_DSLASH",
+"comblock : TOK_SLASH TOK_NAME TOK_SLASH",
+"opt_comma :",
+"opt_comma : ','",
+"paramlist : paramitem",
+"paramlist : paramlist ',' paramitem",
+"paramitem : TOK_NAME '=' expr",
+"module_proc_stmt : TOK_PROCEDURE proc_name_list",
+"proc_name_list : TOK_NAME",
+"proc_name_list : proc_name_list ',' TOK_NAME",
+"implicit : TOK_IMPLICIT TOK_NONE",
+"implicit : TOK_IMPLICIT TOK_REAL8",
+"opt_retour :",
+"dcl : options opt_retour TOK_NAME dims lengspec initial_value",
+"dcl : dcl ',' opt_retour TOK_NAME dims lengspec initial_value",
+"nodimsgiven :",
+"type : typespec selector",
+"type : before_character c_selector",
+"type : typename '*' TOK_CSTINT",
+"type : before_typepar attribute ')'",
+"before_typepar : TOK_TYPEPAR",
+"c_selector :",
+"c_selector : '*' TOK_CSTINT",
+"c_selector : '*' '(' c_attribute ')'",
+"c_selector : '(' c_attribute ')'",
+"c_attribute : TOK_NAME clause opt_clause",
+"c_attribute : TOK_NAME '=' clause opt_clause",
+"c_attribute : clause opt_clause",
+"before_character : TOK_CHARACTER",
+"typespec : typename",
+"typename : TOK_INTEGER",
+"typename : TOK_REAL",
+"typename : TOK_COMPLEX",
+"typename : TOK_DOUBLEPRECISION",
+"typename : TOK_DOUBLECOMPLEX",
+"typename : TOK_LOGICAL",
+"lengspec :",
+"lengspec : '*' proper_lengspec",
+"proper_lengspec : expr",
+"proper_lengspec : '(' '*' ')'",
+"selector :",
+"selector : '*' proper_selector",
+"selector : '(' attribute ')'",
+"proper_selector : expr",
+"proper_selector : '(' '*' ')'",
+"attribute : TOK_NAME clause",
+"attribute : TOK_NAME '=' clause",
+"attribute : TOK_NAME",
+"attribute : TOK_CSTINT",
+"clause : expr",
+"clause : '*'",
+"opt_clause :",
+"opt_clause : ',' TOK_NAME clause",
+"options :",
+"options : ':' ':'",
+"options : ',' attr_spec_list ':' ':'",
+"attr_spec_list : attr_spec",
+"attr_spec_list : attr_spec_list ',' attr_spec",
+"attr_spec : TOK_PARAMETER",
+"attr_spec : access_spec",
+"attr_spec : TOK_ALLOCATABLE",
+"attr_spec : TOK_DIMENSION dims",
+"attr_spec : TOK_EXTERNAL",
+"attr_spec : TOK_INTENT '(' intent_spec ')'",
+"attr_spec : TOK_INTRINSIC",
+"attr_spec : TOK_OPTIONAL",
+"attr_spec : TOK_POINTER",
+"attr_spec : TOK_SAVE",
+"attr_spec : TOK_TARGET",
+"intent_spec : TOK_IN",
+"intent_spec : TOK_OUT",
+"intent_spec : TOK_INOUT",
+"access_spec : TOK_PUBLIC",
+"access_spec : TOK_PRIVATE",
+"dims :",
+"dims : '(' dimlist ')'",
+"dimlist : dim",
+"dimlist : dimlist ',' dim",
+"dim : ubound",
+"dim : ':'",
+"dim : expr ':'",
+"dim : ':' expr",
+"dim : expr ':' ubound",
+"ubound : '*'",
+"ubound : expr",
+"expr : uexpr",
+"expr : '(' expr ')'",
+"expr : complex_const",
+"expr : predefinedfunction",
+"predefinedfunction : TOK_SUM minmaxlist ')'",
+"predefinedfunction : TOK_MAX minmaxlist ')'",
+"predefinedfunction : TOK_TANH '(' minmaxlist ')'",
+"predefinedfunction : TOK_MAXVAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_MIN minmaxlist ')'",
+"predefinedfunction : TOK_MINVAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_TRIM '(' expr ')'",
+"predefinedfunction : TOK_SQRT expr ')'",
+"predefinedfunction : TOK_REAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_NINT '(' expr ')'",
+"predefinedfunction : TOK_FLOAT '(' expr ')'",
+"predefinedfunction : TOK_EXP '(' expr ')'",
+"predefinedfunction : TOK_COS '(' expr ')'",
+"predefinedfunction : TOK_COSH '(' expr ')'",
+"predefinedfunction : TOK_ACOS '(' expr ')'",
+"predefinedfunction : TOK_SIN '(' expr ')'",
+"predefinedfunction : TOK_SINH '(' expr ')'",
+"predefinedfunction : TOK_ASIN '(' expr ')'",
+"predefinedfunction : TOK_LOG '(' expr ')'",
+"predefinedfunction : TOK_TAN '(' expr ')'",
+"predefinedfunction : TOK_ATAN '(' expr ')'",
+"predefinedfunction : TOK_ABS expr ')'",
+"predefinedfunction : TOK_MOD '(' minmaxlist ')'",
+"predefinedfunction : TOK_SIGN '(' minmaxlist ')'",
+"predefinedfunction : TOK_MINLOC '(' minmaxlist ')'",
+"predefinedfunction : TOK_MAXLOC '(' minmaxlist ')'",
+"minmaxlist : expr",
+"minmaxlist : minmaxlist ',' expr",
+"uexpr : lhs",
+"uexpr : simple_const",
+"uexpr : vec",
+"uexpr : expr operation",
+"uexpr : signe expr",
+"uexpr : TOK_NOT expr",
+"signe : '+'",
+"signe : '-'",
+"operation : '+' expr",
+"operation : '-' expr",
+"operation : '*' expr",
+"operation : TOK_DASTER expr",
+"operation : TOK_EQ expr",
+"operation : TOK_EQV expr",
+"operation : TOK_GT expr",
+"operation : '>' expr",
+"operation : TOK_LT expr",
+"operation : '<' expr",
+"operation : TOK_GE expr",
+"operation : '>' '=' expr",
+"operation : TOK_LE expr",
+"operation : '<' '=' expr",
+"operation : TOK_NE expr",
+"operation : TOK_NEQV expr",
+"operation : TOK_XOR expr",
+"operation : TOK_OR expr",
+"operation : TOK_AND expr",
+"operation : TOK_SLASH after_slash",
+"operation : '=' after_equal",
+"after_slash :",
+"after_slash : expr",
+"after_slash : '=' expr",
+"after_slash : TOK_SLASH expr",
+"after_equal : '=' expr",
+"after_equal : expr",
+"lhs : ident",
+"lhs : structure_component",
+"lhs : array_ele_substring_func_ref",
+"beforefunctionuse :",
+"array_ele_substring_func_ref : begin_array",
+"array_ele_substring_func_ref : begin_array substring",
+"array_ele_substring_func_ref : structure_component '(' funarglist ')'",
+"array_ele_substring_func_ref : structure_component '(' funarglist ')' substring",
+"begin_array : ident '(' funarglist ')'",
+"structure_component : lhs '%' lhs",
+"vec : TOK_LEFTAB outlist TOK_RIGHTAB",
+"funarglist : beforefunctionuse",
+"funarglist : beforefunctionuse funargs",
+"funargs : funarg",
+"funargs : funargs ',' funarg",
+"funarg : expr",
+"funarg : triplet",
+"triplet : expr ':' expr",
+"triplet : expr ':' expr ':' expr",
+"triplet : ':' expr ':' expr",
+"triplet : ':' ':' expr",
+"triplet : ':' expr",
+"triplet : expr ':'",
+"triplet : ':'",
+"ident : TOK_NAME",
+"simple_const : TOK_TRUE",
+"simple_const : TOK_FALSE",
+"simple_const : TOK_CSTINT",
+"simple_const : TOK_CSTREAL",
+"simple_const : TOK_CSTREALDP",
+"simple_const : TOK_CSTREALQP",
+"simple_const : simple_const TOK_NAME",
+"simple_const : string_constant opt_substring",
+"string_constant : TOK_CHAR_CONSTANT",
+"string_constant : string_constant TOK_CHAR_CONSTANT",
+"string_constant : TOK_CHAR_MESSAGE",
+"string_constant : TOK_CHAR_CUT",
+"opt_substring :",
+"opt_substring : substring",
+"substring : '(' optexpr ':' optexpr ')'",
+"optexpr :",
+"optexpr : expr",
+"opt_expr : '\\n'",
+"opt_expr : expr",
+"initial_value :",
+"initial_value : before_initial '=' expr",
+"before_initial :",
+"complex_const : '(' uexpr ',' uexpr ')'",
+"use_stat : word_use module_name",
+"use_stat : word_use module_name ',' rename_list",
+"use_stat : word_use module_name ',' TOK_ONLY ':' '\\n'",
+"use_stat : word_use module_name ',' TOK_ONLY ':' only_list",
+"word_use : TOK_USE",
+"module_name : TOK_NAME",
+"rename_list : rename_name",
+"rename_list : rename_list ',' rename_name",
+"rename_name : TOK_NAME TOK_POINT_TO TOK_NAME",
+"only_list : only_name",
+"only_list : only_list ',' only_name",
+"only_name : TOK_NAME TOK_POINT_TO TOK_NAME",
+"only_name : TOK_NAME",
+"exec : iffable",
+"exec : TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'",
+"exec : TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'",
+"exec : TOK_NULLIFY '(' pointer_name_list ')'",
+"exec : word_endunit",
+"exec : word_endprogram opt_name",
+"exec : word_endsubroutine opt_name",
+"exec : word_endfunction opt_name",
+"exec : TOK_ENDMODULE opt_name",
+"exec : boucledo",
+"exec : logif iffable",
+"exec : TOK_WHERE '(' expr ')' opt_expr",
+"exec : TOK_ELSEWHERE",
+"exec : TOK_ENDWHERE",
+"exec : logif TOK_THEN",
+"exec : TOK_ELSEIF '(' expr ')' TOK_THEN",
+"exec : TOK_ELSE",
+"exec : TOK_ENDIF opt_name",
+"exec : TOK_CASE caselist ')'",
+"exec : TOK_SELECTCASE '(' expr ')'",
+"exec : TOK_CASEDEFAULT",
+"exec : TOK_ENDSELECT",
+"exec : TOK_CONTAINS",
+"word_endsubroutine : TOK_ENDSUBROUTINE",
+"word_endunit : TOK_ENDUNIT",
+"word_endprogram : TOK_ENDPROGRAM",
+"word_endfunction : TOK_ENDFUNCTION",
+"caselist : expr",
+"caselist : caselist ',' expr",
+"caselist : caselist ':' expr",
+"boucledo : worddo opt_int do_arg",
+"boucledo : wordwhile expr",
+"boucledo : TOK_ENDDO optname",
+"do_arg :",
+"do_arg : do_var '=' expr ',' expr",
+"do_arg : do_var '=' expr ',' expr ',' expr",
+"opt_int :",
+"opt_int : TOK_CSTINT opt_comma",
+"opt_name : '\\n'",
+"opt_name : TOK_NAME",
+"optname :",
+"optname : TOK_NAME",
+"worddo : TOK_PLAINDO",
+"wordwhile : TOK_DOWHILE",
+"dotarget :",
+"dotarget : TOK_CSTINT",
+"iffable : TOK_CONTINUE",
+"iffable : ident_dims after_ident_dims",
+"iffable : goto",
+"iffable : io",
+"iffable : call",
+"iffable : TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'",
+"iffable : TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'",
+"iffable : TOK_EXIT optexpr",
+"iffable : TOK_RETURN opt_expr",
+"iffable : TOK_CYCLE opt_expr",
+"iffable : stop opt_expr",
+"iffable : int_list",
+"before_dims :",
+"ident_dims : ident before_dims dims dims",
+"ident_dims : ident_dims '%' ident before_dims dims dims",
+"int_list : TOK_CSTINT",
+"int_list : int_list ',' TOK_CSTINT",
+"after_ident_dims : '=' expr",
+"after_ident_dims : TOK_POINT_TO expr",
+"call : keywordcall opt_call",
+"opt_call :",
+"opt_call : '(' opt_callarglist ')'",
+"opt_callarglist :",
+"opt_callarglist : callarglist",
+"keywordcall : before_call TOK_NAME",
+"before_call : TOK_CALL",
+"callarglist : callarg",
+"callarglist : callarglist ',' callarg",
+"callarg : expr",
+"callarg : '*' label",
+"stop : TOK_PAUSE",
+"stop : TOK_STOP",
+"io : iofctl ioctl",
+"io : read option_read",
+"io : write ioctl",
+"io : write ioctl outlist",
+"io : TOK_REWIND after_rewind",
+"io : TOK_FORMAT",
+"opt_CHAR_INT :",
+"opt_CHAR_INT : TOK_CSTINT TOK_NAME",
+"idfile : '*'",
+"idfile : TOK_CSTINT",
+"idfile : ident",
+"option_print :",
+"option_print : ',' outlist",
+"option_inlist :",
+"option_inlist : inlist",
+"option_read : ioctl option_inlist",
+"option_read : infmt opt_inlist",
+"opt_outlist :",
+"opt_outlist : outlist",
+"opt_inlist :",
+"opt_inlist : ',' inlist",
+"ioctl : '(' ctllist ')'",
+"ioctl : '(' fexpr ')'",
+"after_rewind : '(' ident ')'",
+"after_rewind : '(' TOK_CSTINT ')'",
+"after_rewind : TOK_CSTINT",
+"after_rewind : '(' uexpr ')'",
+"after_rewind : TOK_NAME",
+"ctllist : ioclause",
+"ctllist : ctllist ',' ioclause",
+"ioclause : fexpr",
+"ioclause : '*'",
+"ioclause : TOK_DASTER",
+"ioclause : TOK_NAME expr",
+"ioclause : TOK_NAME expr '%' ident_dims",
+"ioclause : TOK_NAME '(' triplet ')'",
+"ioclause : TOK_NAME '*'",
+"ioclause : TOK_NAME TOK_DASTER",
+"iofctl : TOK_OPEN",
+"iofctl : TOK_CLOSE",
+"infmt : unpar_fexpr",
+"infmt : '*'",
+"read : TOK_READ",
+"read : TOK_INQUIRE",
+"read : TOK_PRINT",
+"write : TOK_WRITE",
+"fexpr : unpar_fexpr",
+"fexpr : '(' fexpr ')'",
+"unpar_fexpr : lhs",
+"unpar_fexpr : simple_const",
+"unpar_fexpr : fexpr addop fexpr",
+"unpar_fexpr : fexpr '*' fexpr",
+"unpar_fexpr : fexpr TOK_SLASH fexpr",
+"unpar_fexpr : fexpr TOK_DASTER fexpr",
+"unpar_fexpr : addop fexpr",
+"unpar_fexpr : fexpr TOK_DSLASH fexpr",
+"unpar_fexpr : TOK_FILE expr",
+"unpar_fexpr : TOK_EXIST expr",
+"unpar_fexpr : TOK_ERR expr",
+"unpar_fexpr : TOK_END expr",
+"unpar_fexpr : TOK_NAME '=' expr",
+"addop : '+'",
+"addop : '-'",
+"inlist : inelt",
+"inlist : inlist ',' inelt",
+"opt_lhs :",
+"opt_lhs : lhs",
+"inelt : opt_lhs opt_operation",
+"inelt : '(' inlist ')' opt_operation",
+"inelt : predefinedfunction opt_operation",
+"inelt : simple_const opt_operation",
+"inelt : '(' inlist ',' dospec ')'",
+"opt_operation :",
+"opt_operation : operation",
+"opt_operation : opt_operation operation",
+"outlist : uexpr",
+"outlist : other",
+"outlist : out2",
+"out2 : uexpr ',' expr",
+"out2 : uexpr ',' other",
+"out2 : other ',' expr",
+"out2 : other ',' other",
+"out2 : out2 ',' expr",
+"out2 : out2 ',' other",
+"out2 : uexpr",
+"out2 : predefinedfunction",
+"other : complex_const",
+"other : '(' expr ')'",
+"other : '(' uexpr ',' dospec ')'",
+"other : '(' other ',' dospec ')'",
+"other : '(' out2 ',' dospec ')'",
+"dospec : TOK_NAME '=' expr ',' expr",
+"dospec : TOK_NAME '=' expr ',' expr ',' expr",
+"labellist : label",
+"labellist : labellist ',' label",
+"label : TOK_CSTINT",
+"goto : TOK_PLAINGOTO '(' expr ',' expr ')' ',' expr",
+"goto : TOK_PLAINGOTO label",
+"allocation_list : allocate_object",
+"allocation_list : ident_dims",
+"allocation_list : allocation_list ',' allocate_object",
+"allocate_object : ident",
+"allocate_object : structure_component",
+"allocate_object : array_element",
+"array_element : ident '(' funargs ')'",
+"subscript_list : expr",
+"subscript_list : subscript_list ',' expr",
+"allocate_object_list : allocate_object",
+"allocate_object_list : allocate_object_list ',' allocate_object",
+"opt_stat_spec :",
+"opt_stat_spec : ',' TOK_STAT '=' ident",
+"pointer_name_list : ident",
+"pointer_name_list : pointer_name_list ',' ident",
+"opt_construct_name :",
+"opt_construct_name : TOK_NAME",
+"opt_construct_name_colon :",
+"opt_construct_name_colon : TOK_CONSTRUCTID ':'",
+"logif : TOK_LOGICALIF expr ')'",
+"do_var : ident",
+};
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short yyss[YYSTACKSIZE];
+YYSTYPE yyvs[YYSTACKSIZE];
+#define yystacksize YYSTACKSIZE
+#line 2567 "fortran.y"
+
+void processfortran(char *fichier_entree)
+{
+   extern FILE *fortranin;
+   extern FILE *fortranout;
+   char nomfile[LONG_C];
+   int c;
+   int confirmyes;
+
+   /*fortrandebug = 1;*/
+   if ( mark == 1 ) printf("Firstpass == %d \n",firstpass);
+/******************************************************************************/
+/*  1-  Open input and output files                                           */
+/******************************************************************************/
+   strcpy(nomfile,commondirin);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   fortranin=fopen( nomfile,"r");
+   if (! fortranin)
+   {
+      printf("Error : File %s does not exist\n",nomfile);
+      exit(1);
+   }
+
+   strcpy(curfile,nomfile);
+   strcpy(nomfile,commondirout);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   strcpy(nomfileoutput,nomfile);
+   Save_Length(nomfileoutput,31);
+   if (firstpass == 1)
+   {
+      if (checkexistcommon == 1)
+      {
+         if (fopen(nomfile,"r"))
+         {
+            printf("Warning : file %s already exist\n",nomfile);
+            confirmyes = 0;
+            while (confirmyes==0)
+            {
+               printf("Override file %s ? [Y/N]\n",nomfile);
+               c=getchar();
+               getchar();
+               if (c==79 || c==110)
+               {
+                  printf("We stop\n");
+                  exit(1);
+               }
+               if (c==89 || c==121)
+               {
+                  confirmyes=1;
+               }
+            }
+         }
+      }
+   }
+
+/******************************************************************************/
+/*  2-  Variables initialization                                              */
+/******************************************************************************/
+
+   line_num_fortran_common=1;
+   line_num_fortran=1;
+   PublicDeclare = 0;
+   PrivateDeclare = 0;
+   ExternalDeclare = 0;
+   SaveDeclare = 0;
+   pointerdeclare = 0;
+   optionaldeclare = 0;
+   incalldeclare = 0;
+   VarType = 0;
+   VarTypepar = 0;
+   Allocatabledeclare = 0 ;
+   strcpy(NamePrecision," ");
+   VariableIsParameter =  0 ;
+   strcpy(NamePrecision,"");
+   c_star = 0 ;
+   functiondeclarationisdone = 0;
+   insubroutinedeclare = 0 ;
+   strcpy(subroutinename," ");
+   InitialValueGiven = 0 ;
+   strcpy(EmptyChar," ");
+   inmoduledeclare = 0;
+   colnum=0;
+   incom=0;
+   couldaddvariable=1;
+   aftercontainsdeclare = 1;
+   strcpy(nameinttypename,"");
+   /* Name of the file without format                                         */
+   tmp = strchr(fichier_entree, '.');
+   strncpy(curfilename,fichier_entree,strlen(fichier_entree)-strlen(tmp));
+   Save_Length(curfilename,30);
+/******************************************************************************/
+/*  3-  Parsing of the input file (1 time)                                    */
+/******************************************************************************/
+   if (firstpass == 0 )
+   {
+      fortranout=fopen(nomfileoutput,"w");
+
+      NewModule_Creation_0();
+   }
+
+   fortranparse();
+
+   strcpy(curfile,mainfile);
+
+   if (firstpass == 0 ) fclose(fortranout);
+}
+#line 7005 "y.tab.c"
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yyss + yystacksize - 1)
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yyss + yystacksize - 1)
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 7:
+#line 341 "fortran.y"
+{yyerrok;yyclearin;}
+break;
+case 12:
+#line 349 "fortran.y"
+{
+                     if (inmoduledeclare == 0 )
+                     {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curinclude,
+                                              pos_end-pos_curinclude);
+                     }
+                  }
+break;
+case 17:
+#line 365 "fortran.y"
+{
+            /* we should ignore the declaration until the keyword             */
+            /*    TOK_ENDDONOTTREAT                                           */
+            couldaddvariable = 0 ;
+            RemoveWordCUR_0(fortranout,-20,20);
+         }
+break;
+case 18:
+#line 372 "fortran.y"
+{
+             couldaddvariable = 1 ;
+             RemoveWordCUR_0(fortranout,-24,24);
+          }
+break;
+case 21:
+#line 379 "fortran.y"
+{pos_cur = setposcur();}
+break;
+case 26:
+#line 388 "fortran.y"
+{incom = 1;}
+break;
+case 27:
+#line 391 "fortran.y"
+{if (incom !=1) {strcpy(curbuf,"");incom=0;}}
+break;
+case 31:
+#line 398 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(1);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            writeheadnewsub_0(1);
+                      }
+                      }
+                   }
+break;
+case 32:
+#line 426 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[0].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      strcpy(subroutinename,yyvsp[0].nac);
+                      /* Common case                                          */
+                      insubroutinedeclare = 1;
+                      /* in the second step we should write the head of       */
+                      /*    the subroutine sub_loop_<subroutinename>          */
+                      writeheadnewsub_0(1);
+                   }
+break;
+case 33:
+#line 444 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-3].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-3].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[-2].l);
+                         strcpy(DeclType,"");
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1(yyvsp[-2].l);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1(yyvsp[-3].nac);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+break;
+case 34:
+#line 477 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-1].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         strcpy(DeclType,"");
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1(yyvsp[-1].nac);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+break;
+case 35:
+#line 511 "fortran.y"
+{
+                      GlobalDeclaration = 0;
+                      strcpy(curmodulename,yyvsp[0].nac);
+                      strcpy(subroutinename,"");
+                      Add_NameOfModule_1(yyvsp[0].nac);
+                      if ( inmoduledeclare == 0 )
+                      {
+                         /* To know if there are in the module declaration    */
+                         inmoduledeclare = 1;
+                         /* to know if a module has been met                  */
+                         inmodulemeet = 1;
+                         /* to know if we are after the keyword contains      */
+                         aftercontainsdeclare = 0 ;
+                      }
+                   }
+break;
+case 36:
+#line 528 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,yyvsp[0].nac);strcpy(subroutinename,yyvsp[0].nac);
+                      }
+                   }
+break;
+case 38:
+#line 537 "fortran.y"
+{
+                      pos_curinclude = setposcur()-9;
+                   }
+break;
+case 39:
+#line 541 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Include_1(yyvsp[0].nac);
+                   }
+break;
+case 40:
+#line 545 "fortran.y"
+{
+                      if ( firstpass == 1 && couldaddvariable == 1) yyval.l=NULL;
+                   }
+break;
+case 41:
+#line 548 "fortran.y"
+{
+                      if ( firstpass == 1 && couldaddvariable == 1 ) yyval.l=NULL;
+                   }
+break;
+case 42:
+#line 552 "fortran.y"
+{
+                       if ( firstpass == 1 && couldaddvariable == 1 ) yyval.l=yyvsp[-1].l;
+                   }
+break;
+case 45:
+#line 559 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_SubroutineArgument_Var_1(yyvsp[-1].l);
+                      }
+                   }
+break;
+case 46:
+#line 566 "fortran.y"
+{
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");
+                         curvar=createvar(yyvsp[0].na,NULL);
+                        strcpy(nameinttypename,nameinttypenameback);
+                         curlistvar=insertvar(NULL,curvar);
+                         yyval.l=settype("",curlistvar);
+                      }
+                   }
+break;
+case 47:
+#line 578 "fortran.y"
+{
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");                      
+                         curvar=createvar(yyvsp[0].na,NULL);
+                         strcpy(nameinttypename,nameinttypenameback);                         
+                         yyval.l=insertvar(yyvsp[-2].l,curvar);
+                      }
+                   }
+break;
+case 48:
+#line 589 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 49:
+#line 590 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,"*");}
+break;
+case 50:
+#line 593 "fortran.y"
+{
+                      if ( VarTypepar == 1 )
+                      {
+                         couldaddvariable = 1 ;
+                         VarTypepar = 0;
+                      }
+                   }
+break;
+case 51:
+#line 601 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         VarType = 1;
+                         couldaddvariable = 0 ;
+                      }
+                   }
+break;
+case 52:
+#line 609 "fortran.y"
+{
+                      if ( VarType == 1 ) couldaddvariable = 1 ;
+                      VarType = 0;
+                      VarTypepar = 0;
+                   }
+break;
+case 54:
+#line 616 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[-1].l);
+                         else Add_Parameter_Var_1(yyvsp[-1].l);
+                         pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+break;
+case 55:
+#line 629 "fortran.y"
+{
+                     if ( couldaddvariable == 1 )
+                     {
+                        if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[0].l);
+                         else Add_Parameter_Var_1(yyvsp[0].l);
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+break;
+case 57:
+#line 643 "fortran.y"
+{
+                     pos_end = setposcur();
+                     RemoveWordSET_0(fortranout,pos_cursave,
+                                                pos_end-pos_cursave);
+                  }
+break;
+case 59:
+#line 650 "fortran.y"
+{
+                   /* if the variable is a parameter we can suppose that is   */
+                   /*    value is the same on each grid. It is not useless to */
+                   /*    create a copy of it on each grid                     */
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_Globliste_1(yyvsp[0].l);
+                         /* if variableparamlists has been declared in a      */
+                         /*    subroutine                                     */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            Add_Dimension_Var_1(yyvsp[0].l);
+                         }
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curdimension,
+                                                pos_end-pos_curdimension);
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+break;
+case 60:
+#line 686 "fortran.y"
+{
+      if (firstpass == 0)
+      {
+      if (yyvsp[0].lnn)
+      {
+      removeglobfromlist(&(yyvsp[0].lnn));
+      pos_end = setposcur();
+           RemoveWordSET_0(fortranout,pos_cur,pos_end-pos_cur);
+      writelistpublic(yyvsp[0].lnn);
+      }
+      }
+      }
+break;
+case 70:
+#line 708 "fortran.y"
+{
+                      /* we should remove the data declaration                */
+                      if ( couldaddvariable == 1 && aftercontainsdeclare == 0 )
+                      {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curdata,
+                                              pos_end-pos_curdata);
+                      }
+                  }
+break;
+case 72:
+#line 720 "fortran.y"
+{
+         PublicDeclare = 0 ;
+         PrivateDeclare = 0 ;
+      }
+break;
+case 110:
+#line 771 "fortran.y"
+{
+                      /* if the variable is a parameter we can suppose that is*/
+                      /*    value is the same on each grid. It is not useless */
+                      /*    to create a copy of it on each grid               */
+                      if ( couldaddvariable == 1 )
+                      {
+                      pos_end = setposcur();
+                      /*if (insubroutinedeclare == 0)
+                        {   */
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                 pos_end-pos_cur_decl);
+                                         
+                       /* }
+                      else
+                       {*/
+                        ReWriteDeclarationAndAddTosubroutine_01(yyvsp[-1].l);
+                        pos_cur_decl = setposcur();
+                        
+                       /*}*/
+                      if ( firstpass == 0 &&
+                           GlobalDeclaration == 0 &&
+                           insubroutinedeclare == 0 )
+                      {
+                         sprintf(ligne,"\n#include \"Module_Declar_%s.h\"\n"
+                                                                ,curmodulename);
+                         tofich(fortranout,ligne,1);
+                         sprintf (ligne, "Module_Declar_%s.h",curmodulename);
+                         module_declar = associate(ligne);
+                         sprintf (ligne, " ");
+                         tofich (module_declar, ligne,1);
+                         GlobalDeclaration = 1 ;
+                      }
+                         yyval.l = yyvsp[-1].l;
+                         Add_Globliste_1(yyvsp[-1].l);
+                                                  
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[-1].l);
+                         else
+                         {
+                            if ( pointerdeclare == 1 )
+                                                Add_Pointer_Var_From_List_1(yyvsp[-1].l);
+                            Add_Parameter_Var_1(yyvsp[-1].l);
+                         }
+
+                         /* if variables has been declared in a subroutine    */
+                         if ( insubroutinedeclare == 1 )
+                         { 
+                       /*    Add_SubroutineDeclaration_Var_1($1);*/
+                         }
+                         /* If there are a SAVE declarations in module's      */
+                         /*    subroutines we should remove it from the       */
+                         /*    subroutines declaration and add it in the      */
+                         /*    global declarations                            */
+                         if ( aftercontainsdeclare == 1 &&
+                              SaveDeclare == 1 && firstpass == 1 )
+                         {
+                              if ( inmodulemeet == 0 ) Add_Save_Var_dcl_1(yyvsp[-1].l);
+                              else  Add_SubroutineDeclarationSave_Var_1(yyvsp[-1].l);
+                         }
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+break;
+case 111:
+#line 850 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-1].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      strcpy(nameinttypename,"");
+
+                   }
+break;
+case 112:
+#line 887 "fortran.y"
+{
+                       functiondeclarationisdone = 1;
+                   }
+break;
+case 113:
+#line 893 "fortran.y"
+{
+                      VariableIsParameter = 1;
+                      pos_curparameter = setposcur()-9;
+                   }
+break;
+case 114:
+#line 898 "fortran.y"
+{
+                      pos_curdata = setposcur()-strlen(yyvsp[0].nac);
+                   }
+break;
+case 115:
+#line 902 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",yyvsp[-1].na);
+                      Add_Data_Var_1(yyvsp[-3].nac,ligne);
+                      }
+                   }
+break;
+case 116:
+#line 911 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",yyvsp[-1].na);
+                      Add_Data_Var_1(yyvsp[-3].nac,ligne);
+                      }
+                   }
+break;
+case 117:
+#line 920 "fortran.y"
+{
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                   }
+break;
+case 118:
+#line 931 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.na,yyvsp[0].na);
+                      }
+                   }
+break;
+case 119:
+#line 938 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);
+                      }
+                   }
+break;
+case 124:
+#line 952 "fortran.y"
+{
+                     pos_cursave = setposcur()-4;
+                  }
+break;
+case 126:
+#line 958 "fortran.y"
+{
+                     if ( couldaddvariable == 1 ) Add_Save_Var_1(yyvsp[-1].nac,yyvsp[0].d);
+                  }
+break;
+case 130:
+#line 967 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].nac);}
+break;
+case 131:
+#line 969 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s+%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 132:
+#line 971 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s-%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 133:
+#line 973 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s*%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 134:
+#line 975 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s/%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 135:
+#line 978 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"");}
+break;
+case 136:
+#line 980 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 145:
+#line 995 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curdimension = setposcur()-9;
+                   }
+break;
+case 146:
+#line 1001 "fortran.y"
+{
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar(yyvsp[-2].nac,yyvsp[-1].d);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar(NULL,curvar);
+            /*                                                                */
+            yyval.l=settype("",curlistvar);
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+break;
+case 147:
+#line 1017 "fortran.y"
+{
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar(yyvsp[-2].nac,yyvsp[-1].d);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar(yyvsp[-4].l,curvar);
+            /*                                                                */
+            yyval.l=curlistvar;
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+break;
+case 150:
+#line 1037 "fortran.y"
+{
+        yyval.lnn=(listname *)NULL;
+        }
+break;
+case 151:
+#line 1041 "fortran.y"
+{
+          yyval.lnn=yyvsp[0].lnn;
+         }
+break;
+case 152:
+#line 1046 "fortran.y"
+{
+           yyval.lnn = Insertname(NULL,yyvsp[0].nac);
+           }
+break;
+case 153:
+#line 1050 "fortran.y"
+{
+          yyval.lnn = Insertname(yyvsp[-2].lnn,yyvsp[0].nac);
+          }
+break;
+case 154:
+#line 1055 "fortran.y"
+{
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcommon,
+                                                  pos_end-pos_curcommon);
+                   }
+break;
+case 155:
+#line 1061 "fortran.y"
+{
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",yyvsp[-1].nac);
+                            Add_NameOfCommon_1(yyvsp[-1].nac);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+break;
+case 156:
+#line 1072 "fortran.y"
+{
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",yyvsp[-2].nac);
+                            Add_NameOfCommon_1(yyvsp[-2].nac);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+break;
+case 157:
+#line 1084 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6;
+                   }
+break;
+case 158:
+#line 1089 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6-7;
+                   }
+break;
+case 159:
+#line 1095 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+break;
+case 160:
+#line 1100 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+break;
+case 161:
+#line 1104 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         positioninblock = positioninblock + 1 ;
+                         strcpy(commonvar,yyvsp[-1].nac);
+                         commondim = yyvsp[0].d;
+                      }
+                   }
+break;
+case 162:
+#line 1114 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,"");
+                         positioninblock=0;
+                         strcpy(commonblockname,"");
+                      }
+                   }
+break;
+case 163:
+#line 1123 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,yyvsp[-1].nac);
+                         positioninblock=0;
+                         strcpy(commonblockname,yyvsp[-1].nac);
+                      }
+                   }
+break;
+case 166:
+#line 1136 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) yyval.l=insertvar(NULL,yyvsp[0].v);
+                   }
+break;
+case 167:
+#line 1140 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) yyval.l=insertvar(yyvsp[-2].l,yyvsp[0].v);
+                   }
+break;
+case 168:
+#line 1145 "fortran.y"
+{
+                     if ( couldaddvariable == 1 )
+                     {
+                         curvar=(variable *) malloc(sizeof(variable));
+                         /*                                                   */
+                         Init_Variable(curvar);
+                         /*                                                   */
+                         curvar->v_VariableIsParameter=1;
+                         strcpy(curvar->v_nomvar,yyvsp[-2].nac);
+                         Save_Length(yyvsp[-2].nac,4);
+                         strcpy(curvar->v_subroutinename,subroutinename);
+                         Save_Length(subroutinename,11);
+                         strcpy(curvar->v_modulename,curmodulename);
+                         Save_Length(curmodulename,6);
+                         strcpy(curvar->v_initialvalue,yyvsp[0].na);
+                         Save_Length(yyvsp[0].na,14);
+                         strcpy(curvar->v_commoninfile,mainfile);
+                         Save_Length(mainfile,10);
+                         yyval.v=curvar;
+                      }
+                   }
+break;
+case 172:
+#line 1173 "fortran.y"
+{
+                       if ( insubroutinedeclare == 1 )
+                       {
+                          Add_ImplicitNoneSubroutine_1();
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_end-13,
+                                                             13);
+                       }
+                    }
+break;
+case 175:
+#line 1187 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         /*                                                   */
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar(yyvsp[-3].nac,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar(yyvsp[-3].nac,yyvsp[-2].d);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar(DeclType,curvar);
+                         /*                                                   */
+                         curlistvar=insertvar(NULL,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         yyval.l=settype(DeclType,curlistvar);
+                      }
+                      strcpy(vallengspec,"");
+                   }
+break;
+case 176:
+#line 1219 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar(yyvsp[-3].nac,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar(yyvsp[-3].nac,yyvsp[-2].d);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar(yyvsp[-6].l->var->v_typevar,curvar);
+                         /*                                                   */
+                         strcpy(curvar->v_typevar,(yyvsp[-6].l->var->v_typevar));
+                         Save_Length(yyvsp[-6].l->var->v_typevar,3);
+                         /*                                                   */
+                         curlistvar=insertvar(yyvsp[-6].l,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         yyval.l=curlistvar;
+                      }
+                      strcpy(vallengspec,"");
+                   }
+break;
+case 177:
+#line 1253 "fortran.y"
+{dimsgiven=0;}
+break;
+case 178:
+#line 1256 "fortran.y"
+{strcpy(DeclType,yyvsp[-1].nac);}
+break;
+case 179:
+#line 1258 "fortran.y"
+{
+                      strcpy(DeclType,"CHARACTER");
+                   }
+break;
+case 180:
+#line 1262 "fortran.y"
+{
+                      strcpy(DeclType,yyvsp[-2].nac);
+                      strcpy(nameinttypename,yyvsp[0].nac);
+                   }
+break;
+case 181:
+#line 1267 "fortran.y"
+{
+                      strcpy(DeclType,"TYPE");
+                   }
+break;
+case 182:
+#line 1272 "fortran.y"
+{
+                 /*     if ( couldaddvariable == 1 ) VarTypepar = 1 ;
+                      couldaddvariable = 0 ;
+                      pos_cur_decl = setposcur()-5;*/
+                   pos_cur_decl = setposcur()-5;
+                   }
+break;
+case 184:
+#line 1281 "fortran.y"
+{c_selectorgiven=1;strcpy(c_selectorname,yyvsp[0].nac);}
+break;
+case 185:
+#line 1282 "fortran.y"
+{c_star = 1;}
+break;
+case 190:
+#line 1290 "fortran.y"
+{
+                      pos_cur_decl = setposcur()-9;
+                   }
+break;
+case 191:
+#line 1294 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 192:
+#line 1297 "fortran.y"
+{
+                      strcpy(yyval.nac,"INTEGER");
+                      pos_cur_decl = setposcur()-7;
+                   }
+break;
+case 193:
+#line 1301 "fortran.y"
+{
+                      strcpy(yyval.nac,"REAL");
+                      pos_cur_decl = setposcur()-4;
+                   }
+break;
+case 194:
+#line 1306 "fortran.y"
+{strcpy(yyval.nac,"COMPLEX");
+                   pos_cur_decl = setposcur()-7;}
+break;
+case 195:
+#line 1309 "fortran.y"
+{
+                      pos_cur_decl = setposcur()-16;
+                      strcpy(yyval.nac,"REAL");
+                      strcpy(nameinttypename,"8");
+                   }
+break;
+case 196:
+#line 1315 "fortran.y"
+{strcpy(yyval.nac,"DOUBLE COMPLEX");}
+break;
+case 197:
+#line 1317 "fortran.y"
+{
+                      strcpy(yyval.nac,"LOGICAL");
+                      pos_cur_decl = setposcur()-7;
+                   }
+break;
+case 199:
+#line 1323 "fortran.y"
+{strcpy(vallengspec,yyvsp[0].na);}
+break;
+case 200:
+#line 1325 "fortran.y"
+{sprintf(yyval.na,"*%s",yyvsp[0].na);}
+break;
+case 201:
+#line 1326 "fortran.y"
+{strcpy(yyval.na,"*(*)");}
+break;
+case 208:
+#line 1337 "fortran.y"
+{
+                      if ( strstr(yyvsp[0].na,"0.d0") )
+                      {
+                         strcpy(nameinttypename,"8");
+                         sprintf(NamePrecision,"");
+                      }
+                      else sprintf(NamePrecision,"%s = %s",yyvsp[-2].nac,yyvsp[0].na);
+                   }
+break;
+case 209:
+#line 1346 "fortran.y"
+{
+                      strcpy(NamePrecision,yyvsp[0].nac);
+                   }
+break;
+case 210:
+#line 1350 "fortran.y"
+{
+                      strcpy(NamePrecision,yyvsp[0].nac);
+                   }
+break;
+case 211:
+#line 1354 "fortran.y"
+{strcpy(CharacterSize,yyvsp[0].na);
+                    strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 212:
+#line 1356 "fortran.y"
+{strcpy(CharacterSize,"*");
+                    strcpy(yyval.na,"*");}
+break;
+case 220:
+#line 1370 "fortran.y"
+{
+                      VariableIsParameter = 1;
+                   }
+break;
+case 222:
+#line 1375 "fortran.y"
+{Allocatabledeclare = 1;}
+break;
+case 223:
+#line 1377 "fortran.y"
+{
+                      dimsgiven=1;
+                      curdim=yyvsp[0].d;
+                   }
+break;
+case 224:
+#line 1382 "fortran.y"
+{ExternalDeclare = 1;}
+break;
+case 225:
+#line 1384 "fortran.y"
+{strcpy(IntentSpec,yyvsp[-1].nac);}
+break;
+case 227:
+#line 1386 "fortran.y"
+{optionaldeclare = 1 ;}
+break;
+case 228:
+#line 1387 "fortran.y"
+{pointerdeclare = 1 ;}
+break;
+case 229:
+#line 1388 "fortran.y"
+{
+/*                       if ( inmodulemeet == 1 )
+                       {*/
+                          SaveDeclare = 1 ;
+                     /*  }*/
+                    }
+break;
+case 231:
+#line 1396 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 232:
+#line 1397 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 233:
+#line 1398 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac); }
+break;
+case 234:
+#line 1401 "fortran.y"
+{PublicDeclare = 1;}
+break;
+case 235:
+#line 1403 "fortran.y"
+{PrivateDeclare = 1;}
+break;
+case 236:
+#line 1405 "fortran.y"
+{if ( created_dimensionlist == 1 )
+                       {
+                           yyval.d=(listdim *)NULL;
+                       }
+                   }
+break;
+case 237:
+#line 1411 "fortran.y"
+{if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) yyval.d=yyvsp[-1].d;}
+break;
+case 238:
+#line 1414 "fortran.y"
+{if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) yyval.d=insertdim(NULL,yyvsp[0].dim1);}
+break;
+case 239:
+#line 1417 "fortran.y"
+{if ( couldaddvariable == 1 )
+                         if ( created_dimensionlist == 1 ) yyval.d=insertdim(yyvsp[-2].d,yyvsp[0].dim1);}
+break;
+case 240:
+#line 1420 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"1");
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 241:
+#line 1425 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"");
+                      strcpy(yyval.dim1.last,"");
+                   }
+break;
+case 242:
+#line 1429 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,yyvsp[-1].na);
+                      Save_Length(yyvsp[-1].na,2);
+                      strcpy(yyval.dim1.last,"");
+                   }
+break;
+case 243:
+#line 1434 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"");
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 244:
+#line 1440 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,yyvsp[-2].na);
+                      Save_Length(yyvsp[-2].na,2);
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 245:
+#line 1447 "fortran.y"
+{strcpy(yyval.na,"*");}
+break;
+case 246:
+#line 1448 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 247:
+#line 1450 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 248:
+#line 1452 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s)",yyvsp[-1].na);}
+break;
+case 249:
+#line 1454 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 250:
+#line 1456 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 251:
+#line 1460 "fortran.y"
+{sprintf(yyval.na,"SUM(%s)",yyvsp[-1].na);}
+break;
+case 252:
+#line 1462 "fortran.y"
+{sprintf(yyval.na,"MAX(%s)",yyvsp[-1].na);}
+break;
+case 253:
+#line 1464 "fortran.y"
+{sprintf(yyval.na,"TANH(%s)",yyvsp[-1].na);}
+break;
+case 254:
+#line 1466 "fortran.y"
+{sprintf(yyval.na,"MAXVAL(%s)",yyvsp[-1].na);}
+break;
+case 255:
+#line 1468 "fortran.y"
+{sprintf(yyval.na,"MIN(%s)",yyvsp[-1].na);}
+break;
+case 256:
+#line 1470 "fortran.y"
+{sprintf(yyval.na,"MINVAL(%s)",yyvsp[-1].na);}
+break;
+case 257:
+#line 1472 "fortran.y"
+{sprintf(yyval.na,"TRIM(%s)",yyvsp[-1].na);}
+break;
+case 258:
+#line 1474 "fortran.y"
+{sprintf(yyval.na,"SQRT(%s)",yyvsp[-1].na);}
+break;
+case 259:
+#line 1476 "fortran.y"
+{sprintf(yyval.na,"REAL(%s)",yyvsp[-1].na);}
+break;
+case 260:
+#line 1478 "fortran.y"
+{sprintf(yyval.na,"NINT(%s)",yyvsp[-1].na);}
+break;
+case 261:
+#line 1480 "fortran.y"
+{sprintf(yyval.na,"FLOAT(%s)",yyvsp[-1].na);}
+break;
+case 262:
+#line 1482 "fortran.y"
+{sprintf(yyval.na,"EXP(%s)",yyvsp[-1].na);}
+break;
+case 263:
+#line 1484 "fortran.y"
+{sprintf(yyval.na,"COS(%s)",yyvsp[-1].na);}
+break;
+case 264:
+#line 1486 "fortran.y"
+{sprintf(yyval.na,"COSH(%s)",yyvsp[-1].na);}
+break;
+case 265:
+#line 1488 "fortran.y"
+{sprintf(yyval.na,"ACOS(%s)",yyvsp[-1].na);}
+break;
+case 266:
+#line 1490 "fortran.y"
+{sprintf(yyval.na,"SIN(%s)",yyvsp[-1].na);}
+break;
+case 267:
+#line 1492 "fortran.y"
+{sprintf(yyval.na,"SINH(%s)",yyvsp[-1].na);}
+break;
+case 268:
+#line 1494 "fortran.y"
+{sprintf(yyval.na,"ASIN(%s)",yyvsp[-1].na);}
+break;
+case 269:
+#line 1496 "fortran.y"
+{sprintf(yyval.na,"LOG(%s)",yyvsp[-1].na);}
+break;
+case 270:
+#line 1498 "fortran.y"
+{sprintf(yyval.na,"TAN(%s)",yyvsp[-1].na);}
+break;
+case 271:
+#line 1500 "fortran.y"
+{sprintf(yyval.na,"ATAN(%s)",yyvsp[-1].na);}
+break;
+case 272:
+#line 1502 "fortran.y"
+{sprintf(yyval.na,"ABS(%s)",yyvsp[-1].na);}
+break;
+case 273:
+#line 1504 "fortran.y"
+{sprintf(yyval.na,"MOD(%s)",yyvsp[-1].na);}
+break;
+case 274:
+#line 1506 "fortran.y"
+{sprintf(yyval.na,"SIGN(%s)",yyvsp[-1].na);}
+break;
+case 275:
+#line 1508 "fortran.y"
+{sprintf(yyval.na,"MINLOC(%s)",yyvsp[-1].na);}
+break;
+case 276:
+#line 1510 "fortran.y"
+{sprintf(yyval.na,"MAXLOC(%s)",yyvsp[-1].na);}
+break;
+case 277:
+#line 1512 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 278:
+#line 1514 "fortran.y"
+{if ( couldaddvariable == 1 )
+                   { strcpy(yyval.na,yyvsp[-2].na);strcat(yyval.na,",");strcat(yyval.na,yyvsp[0].na);}}
+break;
+case 279:
+#line 1517 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 280:
+#line 1519 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 281:
+#line 1521 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 282:
+#line 1523 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].na,yyvsp[0].na);}
+break;
+case 283:
+#line 1525 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 284:
+#line 1527 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 285:
+#line 1529 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"+");}
+break;
+case 286:
+#line 1530 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"-");}
+break;
+case 287:
+#line 1533 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"+%s",yyvsp[0].na);}
+break;
+case 288:
+#line 1535 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"-%s",yyvsp[0].na);}
+break;
+case 289:
+#line 1537 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"*%s",yyvsp[0].na);}
+break;
+case 290:
+#line 1539 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 291:
+#line 1541 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 292:
+#line 1543 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 293:
+#line 1545 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 294:
+#line 1547 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," > %s",yyvsp[0].na);}
+break;
+case 295:
+#line 1549 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 296:
+#line 1551 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," < %s",yyvsp[0].na);}
+break;
+case 297:
+#line 1553 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 298:
+#line 1555 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," >= %s",yyvsp[0].na);}
+break;
+case 299:
+#line 1557 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 300:
+#line 1559 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," <= %s",yyvsp[0].na);}
+break;
+case 301:
+#line 1561 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 302:
+#line 1563 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 303:
+#line 1565 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 304:
+#line 1567 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 305:
+#line 1569 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 306:
+#line 1571 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s",yyvsp[0].na);}
+break;
+case 307:
+#line 1573 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s",yyvsp[0].na);}
+break;
+case 308:
+#line 1575 "fortran.y"
+{strcpy(yyval.na,"");}
+break;
+case 309:
+#line 1577 "fortran.y"
+{sprintf(yyval.na,"/%s",yyvsp[0].na);}
+break;
+case 310:
+#line 1579 "fortran.y"
+{sprintf(yyval.na,"/= %s",yyvsp[0].na);}
+break;
+case 311:
+#line 1581 "fortran.y"
+{sprintf(yyval.na,"//%s",yyvsp[0].na);}
+break;
+case 312:
+#line 1584 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"==%s",yyvsp[0].na);}
+break;
+case 313:
+#line 1586 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"= %s",yyvsp[0].na);}
+break;
+case 314:
+#line 1589 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 315:
+#line 1591 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 316:
+#line 1593 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 317:
+#line 1595 "fortran.y"
+{
+                      agrif_parentcall =0;
+                      if (!strcasecmp(identcopy,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                      if ( Agrif_in_Tok_NAME(identcopy) == 1 )
+                      {
+                         inagrifcallargument = 1;
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                      }
+                   }
+break;
+case 318:
+#line 1608 "fortran.y"
+{
+                     strcpy(yyval.na,yyvsp[0].na);
+                     if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+break;
+case 319:
+#line 1613 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," %s %s ",yyvsp[-1].na,yyvsp[0].na);}
+break;
+case 320:
+#line 1615 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                                sprintf(yyval.na," %s ( %s )",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 321:
+#line 1618 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                         sprintf(yyval.na," %s ( %s ) %s ",yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 322:
+#line 1622 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf(yyval.na," %s ( %s )",yyvsp[-3].nac,yyvsp[-1].na);
+                         ModifyTheAgrifFunction_0(yyvsp[-1].na);
+                         agrif_parentcall =0;
+                      }
+                   }
+break;
+case 323:
+#line 1632 "fortran.y"
+{
+                      sprintf(yyval.na," %s %% %s ",yyvsp[-2].na,yyvsp[0].na);
+                      if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+break;
+case 324:
+#line 1638 "fortran.y"
+{sprintf(yyval.na,"(/%s/)",yyvsp[-1].na);}
+break;
+case 325:
+#line 1640 "fortran.y"
+{strcpy(yyval.na," ");}
+break;
+case 326:
+#line 1642 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 327:
+#line 1644 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 328:
+#line 1646 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 329:
+#line 1648 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 330:
+#line 1649 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 331:
+#line 1652 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s :%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 332:
+#line 1654 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                               sprintf(yyval.na,"%s :%s :%s",yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 333:
+#line 1657 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":%s :%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 334:
+#line 1658 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,": : %s",yyvsp[0].na);}
+break;
+case 335:
+#line 1659 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":%s",yyvsp[0].na);}
+break;
+case 336:
+#line 1660 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s :",yyvsp[-1].na);}
+break;
+case 337:
+#line 1661 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":");}
+break;
+case 338:
+#line 1663 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       if ( Vartonumber(yyvsp[0].nac) == 1 )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if (!strcasecmp(yyvsp[0].nac,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                       if ( VariableIsNotFunction(yyvsp[0].nac) == 0 )
+                       {
+                          if ( inagrifcallargument == 1 )
+                          {
+                             if ( !strcasecmp(yyvsp[0].nac,identcopy) )
+                             {
+                                strcpy(sameagrifname,identcopy);
+                                sameagrifargument = 1;
+                             }
+                          }
+                          strcpy(identcopy,yyvsp[0].nac);
+                          pointedvar=0;
+                          strcpy(truename,yyvsp[0].nac);
+                          if (variscoupled_0(yyvsp[0].nac)) strcpy(truename,getcoupledname_0(yyvsp[0].nac));
+/*
+                          if ( VarIsNonGridDepend($1) == 0 &&
+                               Variableshouldberemove($1) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0($1) == 1 ||
+                                  varispointer_0($1) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0($1) == 0)
+                                 {
+                                 ModifyTheVariableName_0($1);
+                                 }
+                                 }
+                                 else
+                                 {
+                                 }
+                             }
+                             if (variscoupled_0($1) == 1)
+                             {
+      printf("mla variable %s est couplee %s\n",$1,getcoupledname_0($1));
+                             ModifyTheVariableNamecoupled_0($1,getcoupledname_0($1));
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1($1);
+                          }
+                          NotifyAgrifFunction_0($1);
+*/
+                          if ( VarIsNonGridDepend(truename) == 0 &&
+                               Variableshouldberemove(truename) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0(truename) == 1 ||
+                                  varispointer_0(truename) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,yyvsp[0].nac) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0(truename) == 0)
+                                 {
+                                 ModifyTheVariableName_0(truename,strlen(yyvsp[0].nac));
+                                 }
+                                 }
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1(truename);
+                          }
+                          NotifyAgrifFunction_0(truename);
+                       }
+                       }
+                    }
+break;
+case 339:
+#line 1742 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,".TRUE.");}
+break;
+case 340:
+#line 1743 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,".FALSE.");}
+break;
+case 341:
+#line 1744 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 342:
+#line 1745 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 343:
+#line 1746 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 344:
+#line 1747 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 345:
+#line 1749 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.nac,"%s%s",yyvsp[-1].nac,yyvsp[0].nac);}
+break;
+case 347:
+#line 1753 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 349:
+#line 1756 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 350:
+#line 1758 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 351:
+#line 1760 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 352:
+#line 1761 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 353:
+#line 1764 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s :%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 354:
+#line 1766 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 355:
+#line 1767 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 356:
+#line 1769 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 357:
+#line 1770 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 358:
+#line 1772 "fortran.y"
+{InitialValueGiven = 0;}
+break;
+case 359:
+#line 1774 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                          strcpy(InitValue,yyvsp[0].na);
+                          InitialValueGiven = 1;
+                       }
+                    }
+break;
+case 360:
+#line 1782 "fortran.y"
+{pos_curinit = setposcur();}
+break;
+case 361:
+#line 1785 "fortran.y"
+{sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 362:
+#line 1788 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuse_0(yyvsp[0].nac);
+                      }
+                      sprintf(charusemodule,"%s",yyvsp[0].nac);
+                      Add_NameOfModuleUsed_1(yyvsp[0].nac);
+
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+break;
+case 363:
+#line 1808 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                      if (insubroutinedeclare == 1)
+                      {
+                         Add_CouplePointed_Var_1(yyvsp[-2].nac,yyvsp[0].lc);
+                      }
+                      if ( firstpass == 1 )
+                      {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            coupletmp = yyvsp[0].lc;
+                            strcpy(ligne,"");
+                            while ( coupletmp )
+                            {
+                               strcat(ligne,coupletmp->c_namevar);
+                               strcat(ligne," => ");
+                               strcat(ligne,coupletmp->c_namepointedvar);
+                               coupletmp = coupletmp->suiv;
+                               if ( coupletmp ) strcat(ligne,",");
+                            }
+                            sprintf(charusemodule,"%s",yyvsp[-2].nac);
+                         }
+                         Add_NameOfModuleUsed_1(yyvsp[-2].nac);
+                      }
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+break;
+case 364:
+#line 1842 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuseonly_0(yyvsp[-4].nac);
+                      }
+                      sprintf(charusemodule,"%s",yyvsp[-4].nac);
+                      Add_NameOfModuleUsed_1(yyvsp[-4].nac);
+
+                       if ( inmoduledeclare == 0 )
+                       {
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_curuse,
+                                                pos_end-pos_curuse);
+                       }
+                       }
+                    }
+break;
+case 365:
+#line 1862 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if variables has been declared in a subroutine      */
+                       if (insubroutinedeclare == 1)
+                       {
+                          Add_CouplePointed_Var_1(yyvsp[-4].nac,yyvsp[0].lc);
+                       }
+                       if ( firstpass == 1 )
+                       {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                             coupletmp = yyvsp[0].lc;
+                             strcpy(ligne,"");
+                             while ( coupletmp )
+                             {
+                                strcat(ligne,coupletmp->c_namevar);
+                               if ( strcasecmp(coupletmp->c_namepointedvar,"") )
+                                                           strcat(ligne," => ");
+                                strcat(ligne,coupletmp->c_namepointedvar);
+                                coupletmp = coupletmp->suiv;
+                                if ( coupletmp ) strcat(ligne,",");
+                             }
+                             sprintf(charusemodule,"%s",yyvsp[-4].nac);
+                          }
+                          Add_NameOfModuleUsed_1(yyvsp[-4].nac);
+                       }
+                       if ( firstpass == 0 )
+                       {
+                          if ( inmoduledeclare == 0 )
+                          {
+
+                            pos_end = setposcur();
+                             RemoveWordSET_0(fortranout,pos_curuse,
+                                                   pos_end-pos_curuse);
+                       if (oldfortranout) 
+                         variableisglobalinmodule(yyvsp[0].lc,yyvsp[-4].nac,oldfortranout,pos_curuseold);
+                        
+                          }
+                          else
+                          {
+
+                             /* if we are in the module declare and if the    */
+                             /* onlylist is a list of global variable         */
+                             variableisglobalinmodule(yyvsp[0].lc, yyvsp[-4].nac, fortranout,pos_curuse);
+                          }
+                       }
+                       }
+                    }
+break;
+case 366:
+#line 1913 "fortran.y"
+{
+                      pos_curuse = setposcur()-strlen(yyvsp[0].nac);
+                     if (firstpass == 0 && oldfortranout) {
+                     pos_curuseold = setposcurname(oldfortranout);
+                     }
+                   }
+break;
+case 367:
+#line 1921 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 368:
+#line 1924 "fortran.y"
+{
+                       if ( couldaddvariable == 1 ) yyval.lc = yyvsp[0].lc;
+                    }
+break;
+case 369:
+#line 1928 "fortran.y"
+{
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        yyvsp[0].lc->suiv = yyvsp[-2].lc;
+                        yyval.lc = yyvsp[0].lc;
+                        }
+                    }
+break;
+case 370:
+#line 1938 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[-2].nac);
+                       Save_Length(yyvsp[-2].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,22);
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                     }
+break;
+case 371:
+#line 1949 "fortran.y"
+{
+                       if ( couldaddvariable == 1 ) yyval.lc = yyvsp[0].lc;
+                    }
+break;
+case 372:
+#line 1953 "fortran.y"
+{
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        yyvsp[0].lc->suiv = yyvsp[-2].lc;
+                        yyval.lc = yyvsp[0].lc;
+                        }
+                    }
+break;
+case 373:
+#line 1963 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[-2].nac);
+                       Save_Length(yyvsp[-2].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,22);
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                       pointedvar=1;
+                       Add_UsedInSubroutine_Var_1(yyvsp[-2].nac);
+                    }
+break;
+case 374:
+#line 1974 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,"");
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                     }
+break;
+case 376:
+#line 1985 "fortran.y"
+{
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 377:
+#line 1991 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                         curmodulename);
+                                                         inallocate = 0;
+                     }
+break;
+case 379:
+#line 1998 "fortran.y"
+{
+                       GlobalDeclaration = 0 ;
+                       if ( firstpass == 0 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                          if ( module_declar && insubroutinedeclare == 0 )
+                          {
+                              fclose(module_declar);
+                          }
+                       }
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       if ( inmodulemeet == 1 )
+                       {
+                         /* we are in a module                                */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            /* it is like an end subroutine <name>            */
+                            insubroutinedeclare = 0 ;
+                            /*                                                */
+                            pos_cur = setposcur();
+                            closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                         }
+                         else
+                         {
+                            /* it is like an end module <name>                */
+                            inmoduledeclare = 0 ;
+                            inmodulemeet = 0 ;
+                         }
+                       }
+                       else
+                       {
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+                          pos_cur = setposcur();                        
+                          closeandcallsubloopandincludeit_0(2);
+                            functiondeclarationisdone = 0;
+                          if ( firstpass == 0 )
+                          {
+                             if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                             else fprintf(paramout,"C\n");
+                             fclose(paramout);
+                           }
+                        }
+                      }
+                      strcpy(subroutinename,"");
+                    }
+break;
+case 380:
+#line 2048 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();                      
+                       closeandcallsubloopandincludeit_0(3);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 381:
+#line 2066 "fortran.y"
+{
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+                                             
+                       closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 382:
+#line 2086 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+
+                       closeandcallsubloopandincludeit_0(0);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 383:
+#line 2105 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if we never meet the contains keyword               */
+                      Remove_Word_end_module_0(strlen(yyvsp[0].nac));
+                       if ( inmoduledeclare == 1 )
+                       {
+                          if ( aftercontainsdeclare == 0 )
+                          {
+                             Write_GlobalParameter_Declaration_0();
+                             Write_NotGridDepend_Declaration_0();
+                             Write_GlobalType_Declaration_0();
+                             Write_Alloc_Subroutine_For_End_0();
+                          }
+                       }
+                                           
+                       inmoduledeclare = 0 ;
+                       inmodulemeet = 0 ;
+
+                      Write_Word_end_module_0();
+                      strcpy(curmodulename,"");
+                      aftercontainsdeclare = 1;
+                      if ( firstpass == 0 )
+                      {
+                         if ( module_declar && insubroutinedeclare == 0)
+                         {
+                           fclose(module_declar);
+                         }
+                      }
+                      GlobalDeclaration = 0 ;
+                      }
+                  }
+break;
+case 397:
+#line 2151 "fortran.y"
+{
+                      if (inmoduledeclare == 1 )
+                      {
+                         Remove_Word_Contains_0();
+                         Write_GlobalParameter_Declaration_0();
+                         Write_GlobalType_Declaration_0();
+                         Write_NotGridDepend_Declaration_0();
+                         Write_Alloc_Subroutine_0();
+                         inmoduledeclare = 0 ;
+                         aftercontainsdeclare = 1;
+                      }
+                      else
+                      {
+                       if ( couldaddvariable == 1 )
+                       {
+                          if ( firstpass == 1 ) List_ContainsSubroutine =
+                                                Addtolistnom(subroutinename,
+                                                     List_ContainsSubroutine,0);
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+
+                          closeandcallsubloop_contains_0();
+                            functiondeclarationisdone = 0;
+                         if ( firstpass == 0 )
+                         {
+                            if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                            else fprintf(paramout,"C\n");
+                            fclose(paramout);
+                         }
+                         }
+                         strcpy(subroutinename,"");
+                      }
+                   }
+break;
+case 398:
+#line 2186 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       functiondeclarationisdone = 0;
+                       }
+                    }
+break;
+case 399:
+#line 2196 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 400:
+#line 2205 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 401:
+#line 2214 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 413:
+#line 2236 "fortran.y"
+{strcpy(yyval.nac,"");}
+break;
+case 414:
+#line 2237 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 426:
+#line 2257 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 427:
+#line 2263 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 433:
+#line 2274 "fortran.y"
+{if ( couldaddvariable == 1 ) created_dimensionlist = 0;}
+break;
+case 434:
+#line 2276 "fortran.y"
+{
+                  created_dimensionlist = 1;
+                  if  ( agrif_parentcall == 1 )
+                  {
+                      ModifyTheAgrifFunction_0(yyvsp[-1].d->dim.last);
+                      agrif_parentcall =0;
+                      fprintf(fortranout," = ");
+                  }
+              }
+break;
+case 435:
+#line 2286 "fortran.y"
+{created_dimensionlist = 1;}
+break;
+case 440:
+#line 2294 "fortran.y"
+{
+                      inagrifcallargument = 0 ;
+                      incalldeclare=0;
+                      if ( oldfortranout &&
+                           !strcasecmp(meetagrifinitgrids,subroutinename) &&
+                           firstpass == 0 &&
+                           callmpiinit == 1)
+                      {
+                      /*   pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+                         fprintf(oldfortranout,"      Call MPI_Init (%s) \n"
+                                                                   ,mpiinitvar);*/
+                      }
+                      if ( oldfortranout           &&
+                           callagrifinitgrids == 1 &&
+                           firstpass == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+
+                         strcpy(subofagrifinitgrids,subroutinename);
+                      }
+                      Instanciation_0(sameagrifname);
+                   }
+break;
+case 445:
+#line 2328 "fortran.y"
+{
+                       if (!strcasecmp(yyvsp[0].nac,"MPI_Init") )
+                       {
+                          callmpiinit = 1;
+                       }
+                       else
+                       {
+                          callmpiinit = 0;
+                       }
+                       if (!strcasecmp(yyvsp[0].nac,"Agrif_Init_Grids") )
+                       {
+                          callagrifinitgrids = 1;
+                          strcpy(meetagrifinitgrids,subroutinename);
+                       }
+                       else callagrifinitgrids = 0;
+                       if ( !strcasecmp(yyvsp[0].nac,"Agrif_Open_File") )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if ( Vartonumber(yyvsp[0].nac) == 1 )
+                       {
+                          incalldeclare=1;
+                          inagrifcallargument = 1 ;
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                    }
+break;
+case 446:
+#line 2358 "fortran.y"
+{pos_curcall=setposcur()-4;}
+break;
+case 449:
+#line 2363 "fortran.y"
+{
+                  if ( callmpiinit == 1 )
+                  {
+                     strcpy(mpiinitvar,yyvsp[0].na);
+                     if ( firstpass == 1 )
+                     {
+                        Add_UsedInSubroutine_Var_1 (mpiinitvar);
+/*                        curvar=createvar($1,NULL);
+                        curlistvar=insertvar(NULL,curvar);
+                        List_Subr outineArgument_Var = AddListvarToListvar
+                         (curlistvar,List_SubroutineAr gument_Var,1);*/
+                     }
+                  }
+               }
+break;
+case 528:
+#line 2485 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 529:
+#line 2486 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 530:
+#line 2487 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 531:
+#line 2490 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 532:
+#line 2492 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 533:
+#line 2494 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 534:
+#line 2496 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 535:
+#line 2498 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 536:
+#line 2500 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 537:
+#line 2501 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 538:
+#line 2502 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 539:
+#line 2505 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 540:
+#line 2507 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," (%s)",yyvsp[-1].na);}
+break;
+case 541:
+#line 2509 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 542:
+#line 2511 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 543:
+#line 2513 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 544:
+#line 2517 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                              sprintf(yyval.na,"%s=%s,%s)",yyvsp[-4].nac,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 545:
+#line 2520 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                        sprintf(yyval.na,"%s=%s,%s,%s)",yyvsp[-6].nac,yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 554:
+#line 2536 "fortran.y"
+{Add_Allocate_Var_1(yyvsp[0].nac,curmodulename);}
+break;
+case 557:
+#line 2541 "fortran.y"
+{Add_Allocate_Var_1(yyvsp[-3].nac,curmodulename);}
+break;
+case 571:
+#line 2564 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+#line 9558 "y.tab.c"
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+    if (yyssp >= yyss + yystacksize - 1)
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    return (0);
+}
+#define yy_create_buffer fortran_create_buffer
+#define yy_delete_buffer fortran_delete_buffer
+#define yy_scan_buffer fortran_scan_buffer
+#define yy_scan_string fortran_scan_string
+#define yy_scan_bytes fortran_scan_bytes
+#define yy_flex_debug fortran_flex_debug
+#define yy_init_buffer fortran_init_buffer
+#define yy_flush_buffer fortran_flush_buffer
+#define yy_load_buffer_state fortran_load_buffer_state
+#define yy_switch_to_buffer fortran_switch_to_buffer
+#define yyin fortranin
+#define yyleng fortranleng
+#define yylex fortranlex
+#define yyout fortranout
+#define yyrestart fortranrestart
+#define yytext fortrantext
+#define yywrap fortranwrap
+
+#line 20 "fortran.yy.c"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		yyless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		*yy_cp = yy_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+	{
+	FILE *yy_input_file;
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via yyrestart()), so that the user can continue scanning by
+	 * just pointing yyin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	yytext_ptr = yy_bp; \
+	yyleng = (int) (yy_cp - yy_bp); \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 173
+#define YY_END_OF_BUFFER 174
+static yyconst short int yy_accept[1124] =
+    {   0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,  174,  173,  163,  159,  162,  172,  151,  150,
+      153,  165,  151,  153,  153,  155,  152,  138,  149,  154,
+      157,  156,  158,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  163,  159,  162,  172,  149,  144,  144,  144,  144,
+      144,  173,  173,  170,  173,  153,  144,    0,    0,  163,
+      164,    0,  162,  172,  172,  172,    0,  142,    0,    0,
+      165,  165,  165,  165,    0,    0,    0,  141,    0,    0,
+      133,   25,    0,  145,    0,    0,    0,    0,    0,    0,
+
+        0,  134,    0,  149,   24,    0,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,   42,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,   84,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  163,  161,    0,  161,    0,    0,
+        0,    0,    0,  164,  160,  161,    0,  172,  171,  172,
+      172,  172,  161,  149,    4,  144,  144,  144,  144,  144,
+      144,    0,  170,    0,    0,    0,  167,   25,    0,    0,
+
+        4,    0,  144,  144,  144,  144,  144,  144,    0,    0,
+        0,  172,  172,    0,    0,  165,  165,    0,    0,    0,
+        0,  140,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,  148,  145,    0,
+        0,    0,  143,    0,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  114,  144,  144,
+      144,    0,  144,  144,  144,  144,  144,   15,  144,  144,
+      144,  113,  144,  144,  144,  144,  144,    0,  144,    0,
+       95,  144,  144,  144,  144,  144,  120,  144,  144,  125,
+      144,  144,  144,  144,  144,  144,   88,  144,  144,  144,
+
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  117,  144,  144,  144,  144,  144,  121,  144,  144,
+      144,  144,  144,  163,  161,    0,  164,    0,    0,    0,
+        0,    0,    0,    0,  161,    0,  161,  172,  172,  172,
+      149,    4,    4,    4,    4,  144,  144,  144,  144,  144,
+      144,    0,    0,    0,  167,    0,    0,    4,    4,    4,
+        4,  143,    0,  144,  144,    0,  144,  144,  144,  144,
+        0,    0,    0,  172,  172,    0,    0,  165,  165,    0,
+        0,    0,    0,  146,    0,  145,    0,  147,    0,   27,
+        0,   29,   28,   31,   30,   33,    0,    0,   35,    0,
+
+      145,    0,  146,    0,  145,    0,  147,    0,  143,    0,
+      144,  144,  124,  116,  144,  119,  122,  144,   21,  144,
+      144,  144,  144,  144,  115,  144,  144,  144,    0,  144,
+      144,  144,   93,    0,  107,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,    0,  108,  144,  144,  144,  144,
+      144,  144,  144,    0,   87,  144,  144,  144,  144,  144,
+      144,  144,    0,   97,  144,  144,    0,  110,  144,  144,
+      144,  144,  111,   20,   59,   73,  144,  144,  144,  144,
+      144,  144,  144,  144,   78,   43,  144,  144,  144,  144,
+       68,  144,  126,  118,  144,   71,   53,  144,    0,   96,
+
+       98,  144,   91,  100,  144,  144,  163,  161,  164,    0,
+        0,    0,    0,    0,    0,  161,    0,  161,  172,  172,
+      172,  149,    4,    4,  144,  144,  144,  144,  144,   17,
+        0,    0,    0,    4,    4,    0,  143,    0,  144,  144,
+      144,  144,    0,    0,    0,  172,  172,    0,    0,  165,
+      165,    0,    0,   37,   26,    0,   34,   36,    0,  143,
+        0,  143,  144,  144,  144,  144,  144,   48,  144,  144,
+      144,  123,  144,  144,    0,  144,  144,  144,    0,  144,
+      144,    0,    0,    0,    0,    0,    0,    0,    0,   41,
+      144,   94,  144,  144,  144,  144,  144,  144,  144,  144,
+
+      144,   75,   75,   75,   75,  144,    0,  106,  112,  144,
+      144,   87,  144,  144,   89,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,   51,
+      144,   76,  144,  144,  144,    0,  144,  144,  144,  144,
+      144,  101,  144,  144,   54,   80,  163,  161,  164,    0,
+        0,    0,    0,    0,  161,    0,  161,  172,  172,  172,
+      149,    4,    3,    0,  103,  144,  144,   85,  144,   69,
+       70,   69,    0,    0,    0,    4,    3,    0,  143,    0,
+      143,  144,   48,  144,  123,    0,   22,    0,  172,   22,
+        0,   22,   22,  165,   22,    0,   22,   22,   22,   32,
+
+      144,   22,   22,   22,  144,  144,  144,   62,  144,  144,
+      144,  144,    0,  144,  144,  139,    0,    0,   92,  144,
+       41,    0,   94,    0,    0,    0,    0,    0,    0,    0,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,    0,
+      109,  144,  144,  144,  144,  144,  144,  144,   65,  144,
+      144,  144,  128,   99,  127,  129,   38,  144,  144,  144,
+      144,  144,  144,   82,    0,  144,   10,   74,   18,  144,
+      144,   81,  163,  161,  164,    0,    0,    0,  161,  172,
+      172,   22,    4,    3,    3,  144,  144,  144,    0,    0,
+       22,    4,    3,    3,  144,   22,   22,   22,   23,  166,
+
+       23,   23,   23,   23,   23,   23,   23,   23,   23,   23,
+      144,  144,  144,   57,  144,  144,  144,    0,    0,  144,
+      144,   39,   92,    0,  144,    0,    0,    0,    0,    0,
+        0,    0,    0,  144,  144,  144,  144,  144,  144,   72,
+      144,  144,  144,    0,    0,  144,  144,   16,   49,   44,
+      144,  144,   45,    0,  144,  144,  144,  144,   66,   83,
+        7,    0,    0,  144,    0,  144,  144,    0,    0,    0,
+      172,   23,    4,  144,  144,   63,    0,   23,    4,   23,
+       23,   23,  144,    8,  144,  144,   86,  144,  144,   39,
+        0,    0,  144,  144,    0,  144,    0,    0,    0,    0,
+
+        0,    0,   72,    0,  144,  144,  144,  144,  144,  144,
+       55,  144,   64,    0,    0,    0,  135,   11,   19,  144,
+      144,    0,  144,   79,   67,  144,    0,  144,    0,  144,
+      144,    0,    0,  172,    4,  144,   58,    0,    4,  144,
+      131,   46,  144,   50,    0,    0,  144,  144,    0,   56,
+        0,    0,    0,    0,    0,    0,   55,  144,  144,   40,
+      144,  105,  144,  144,    0,    0,    0,    0,  135,  130,
+       90,    0,  144,   60,    0,   61,    0,  144,  144,    0,
+       58,  172,    4,    4,  144,    0,    4,    4,  144,    9,
+        0,    0,  144,  144,   56,    0,    0,   40,    0,  105,
+
+        0,  144,  144,   13,  144,  144,    0,    0,    0,  144,
+        0,    0,  102,    6,    0,  172,    4,    4,  144,    0,
+        4,    4,   47,    0,    0,  144,  144,    0,    0,   13,
+        0,   14,  144,  144,   52,    0,    0,    0,  144,    0,
+      102,    0,  172,    4,    2,  104,    0,    4,    2,    0,
+        0,  144,  144,   14,    0,    0,  132,  144,    0,    0,
+        0,  144,    0,  104,  172,    4,    0,    4,    0,    0,
+      137,  144,  132,    0,   12,    0,    0,    0,  144,    0,
+      172,    1,    0,    1,  137,    0,  144,   12,    0,    0,
+        0,  144,    0,  172,    0,    0,  136,    0,    0,    0,
+
+       77,    5,  172,    0,  136,   77,  172,    0,  172,    0,
+      172,    0,  172,    0,  172,    0,  168,    0,    0,    0,
+        0,  169,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    4,    5,    6,    7,    8,    9,   10,   11,   12,
+       13,   14,   15,   16,   17,   18,   19,   20,   21,   22,
+       23,   24,   25,   26,   27,   28,   20,   29,   30,   31,
+       32,   33,    1,    1,   37,   38,   39,   40,   41,   42,
+       43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
+       53,   54,   55,   56,   57,   58,   59,   60,   61,   62,
+       34,    1,   35,    1,   36,    1,   37,   38,   39,   40,
+
+       41,   42,   43,   44,   45,   46,   47,   48,   49,   50,
+       51,   52,   53,   54,   55,   56,   57,   58,   59,   60,
+       61,   62,   63,   63,   63,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[64] =
+    {   0,
+        1,    2,    3,    4,    1,    5,    1,    1,    1,    6,
+        1,    1,    1,    1,    7,    1,    7,    8,    1,    9,
+        9,    9,    9,    9,    9,    9,    9,    9,    1,    1,
+        1,    1,    1,    1,    1,   10,   11,   10,   10,   12,
+       13,   14,   15,   16,   10,   10,   10,   15,   15,   15,
+       11,   10,   12,   15,   15,   14,   15,   10,   17,   10,
+       10,   10,    5
+    } ;
+
+static yyconst short int yy_base[1180] =
+    {   0,
+        0,   62,    0,    0,    0,    0, 4185,   65,    0,   55,
+        0,    0, 4187,   35,   69,   70,   74,   37,   75,   50,
+       53,   72,   93,   78,   66,   56,  148,   87,   81,   65,
+       68,   99,   71,  191,  230,  108,  183,  225,  244,  103,
+      137,  152,  185,  250,  265,  262,  281,  220,  286,  296,
+      308,  368,  134,  424,  321,  350,  149, 4149,  310,  337,
+      270, 4189, 4182, 4189,  158,  380,  481, 4147, 4129,  138,
+      163,  175,  179,    0, 4145, 4127, 4174, 4189,  147,  133,
+     4176, 4175,  192,  156,  232,  393,  376, 4189,  402,  406,
+     4189, 4189,  543,  184, 4127, 4123,  204,  218,  226, 4121,
+
+     4123, 4189,  584,  358, 4189,  448,  532,  507,  514,  572,
+      534,  588,  593,  605,  617,  381,  242,  169,  195,  404,
+      384,  312,  517,  672,  524,  378,  403,  544,  365,  630,
+      597,  545,  424,  565,  651,  679,  425,  650,  626,  648,
+      672,  673,  603,  674,  680,  684,  698,  686,  699,  704,
+      706,  584,  707,  710,  711,  730,  683,  297,  732,  735,
+      734,  737,  742,  750,  788,  795, 4170,  389,  316, 4135,
+     4123,   72, 4115,  807, 4189,  863,  427, 4166, 4189,  225,
+      327,  543,  632,  660,  804,  765,  799,  770,  764,  785,
+      788, 4165, 4189,  343, 4164,  774, 4189, 4163,  820,  564,
+
+      856,  918,  946, 4147,  271,  661,  187,  270, 4116, 4106,
+      812, 4114, 4104,  547,  804,  617,  398,  859,  894,  906,
+      868, 4189,  889,  871,  815,  860,  896, 4120,  372, 4141,
+     4140, 4139, 4138,  275, 4099, 4136, 4099, 4189,  874,  907,
+      908,  914, 4111, 4110,  864,  973,  999,  977,  975,  983,
+      984,  981, 1002,  986,  987, 1006, 1007, 1008, 1011, 1020,
+     1010, 4091,  737, 1029, 1032, 1017, 1036, 1089, 1033, 1078,
+     1042, 1035, 1047, 1058, 1038, 1057, 1063, 1101, 1071, 1013,
+     4189, 1070, 1079, 1082, 1083, 1105, 1110, 1148, 1149, 1112,
+     1117, 1119, 1126, 1128, 1133, 1139, 1076, 1125, 1137, 1140,
+
+     1151, 1161, 1162, 1171, 1163, 1175, 1176, 1177, 1186, 1187,
+     1184, 1198, 1189, 1199, 1202, 1141, 1245, 1207, 1221, 1209,
+     1211, 1213, 1225, 1264, 1283, 4088, 1290, 4145, 4092, 4096,
+     4089, 4093, 4091, 4101, 1346,  715,  922,  557, 1120,  837,
+     1266,    0,  931, 4098, 4091, 1236, 1235, 1243, 1264, 1271,
+     1274,  800, 4020, 1311, 4189, 1268,  873, 4003, 1332, 1295,
+     1132, 1401, 1440,    0, 3971, 1479,  697,  659,  815,  998,
+     3883, 3892,  932, 3876, 3823, 1231,  551,  561, 1302, 1321,
+     1342, 1351, 1355, 1385, 1410, 1424, 1449, 1463, 3829, 4189,
+     3812, 4189, 4189, 4189, 4189, 4189, 3767, 3805, 4189, 3802,
+
+     1347, 1488, 1497, 1506, 1515, 1524, 1533, 1302, 3778, 1327,
+     1304, 1525, 4189, 1273, 1362, 1361, 1402, 1403, 1441, 1442,
+     1526, 1443, 1527, 1528, 1531, 1533, 1535, 1534, 3773, 1549,
+     1553, 1539, 1597, 1655, 4189, 1541, 1554, 1563, 1565, 1567,
+     1569, 1575, 1578, 1577, 1361, 4189, 1583, 1714, 1587, 1623,
+     1591, 1596, 1607, 3762, 1611, 1617, 1612, 1616, 1630, 1631,
+     1645, 1639, 1684, 4189, 1652, 1654, 1690, 4189, 1741, 1672,
+     1742, 1743, 1744, 1745, 1746, 1747, 1751, 1757, 1766, 1756,
+     1767, 1771, 1772, 1777, 1776, 1801, 1779, 1780, 1781, 1782,
+     1787, 1790, 1800, 1802, 1828, 1805, 1806, 1810, 1846, 4189,
+
+     1808, 1812, 1809, 1814, 1830, 1832, 1870, 1885, 1892, 3770,
+     3752, 3770, 3767, 3761, 3797, 1948, 1009, 1380, 1303,  663,
+     1414, 1873, 3746, 3747, 1903, 1863, 1902, 1839, 1943, 3794,
+     1306, 1438, 1451, 1849, 1566, 2003, 2029, 2068, 1591,  424,
+     1063, 1373, 3756,    0, 1392, 3755,    0,  815, 3788, 1875,
+     3790, 1919, 1702, 4189, 4189, 3774, 4189, 4189, 1987, 2013,
+     2038, 2052, 1844, 2096, 1864, 1882, 1884, 1883, 1927, 1924,
+     1929, 1909, 1945, 1930, 3746, 1949, 2123, 2124, 2160, 2045,
+     2126, 3738, 3728, 1588, 3733, 3680, 1623, 3668, 3683, 1963,
+     2129, 1965, 2030, 2132, 2130, 2128, 2136, 2148, 2150, 2138,
+
+     2191, 4189, 2186, 2178, 2162, 2180, 1990, 4189, 2164, 2166,
+     2184, 4189, 2187, 2196, 2188, 2190, 2194, 2200, 2209, 2203,
+     2206, 2210, 2218, 2222, 2221, 2230, 2225, 2228, 2236, 2231,
+     2246, 2237, 2243, 2244, 2249, 3696, 2252, 2255, 2258, 2256,
+     2264, 4189, 2265, 2267, 2276, 2277, 2322, 2331, 2341, 2313,
+     3686, 1416, 3684, 2336, 2397, 1449, 1648, 1854, 2040, 3697,
+     2324, 3654, 1783, 2335, 4189, 2313, 2312, 1910, 2335, 2392,
+     4189, 2389, 2194, 2341, 3693, 2249, 2042, 2452, 2478, 2504,
+     2530, 1870, 3675, 2558, 3672,    0, 4189, 2615,    0,    0,
+     3677, 3676, 4189, 3659, 3654, 2353, 2366, 2400, 4189, 4189,
+
+     2643, 2392, 2355, 2331, 2369, 2384, 2385, 2389, 2390, 2391,
+     2392, 2397, 3580, 2431, 2415, 2393, 3585, 3582, 2395, 2430,
+     4189, 3575, 4189, 3566, 3580, 3539, 3541, 3550, 3535, 3495,
+     2454, 2455, 2457, 2480, 2481, 2428, 2670, 2458, 2671, 2455,
+     4189, 2482, 2708, 2672, 2676, 2677, 2692, 2483, 2484, 2678,
+     2680, 2690, 2685, 2699, 2700, 2703, 2739, 2705, 2710, 2711,
+     2712, 2714, 2721, 2715, 2537, 2726, 2719, 2724, 2735, 2775,
+     2744, 2745, 2781, 2792, 2801, 3478, 3436, 3432,    0, 1637,
+     3476, 3475, 3435,    0, 1991, 2750, 2772, 2806, 1959, 3473,
+     3472, 2313, 3471, 2356, 2860, 2921,    0, 3455, 4189, 4189,
+
+        0, 3466, 4189, 3468, 2537, 2621, 4189, 2905, 2793, 2747,
+     2782, 2779, 2805, 2753, 2897, 2780, 2802, 3429, 2458, 2899,
+     2791, 2898, 4189, 3428, 2900, 3429, 3426, 3409, 3422, 3423,
+     3409, 3421, 3407, 2902, 2903, 2918, 2922, 2923, 2924, 2926,
+     2927, 2928, 2936, 2981, 2976, 2937, 2951, 2955, 2957, 2958,
+     2959, 2963, 2960, 2997, 2965, 2966, 2967, 2969, 2979, 2981,
+     2987, 3024, 3423, 2988, 2811, 2990, 2993, 3417, 3407, 2459,
+     2510, 3453, 3419, 2994, 2997, 2462, 3026, 3448, 3029, 3063,
+        0, 3426, 3002, 3000, 3016, 3006, 3013, 3018, 3021, 4189,
+     3389, 3309, 3024, 3022, 3272, 3027, 3215, 3209, 3187, 3150,
+
+     3134, 3029, 4189, 3004, 3055, 3040, 3056, 3042, 3058, 3061,
+     3062, 3067, 3065, 3098, 2484, 3110, 3119, 3070, 3088, 3089,
+     3094, 2917, 3090, 3091, 3097, 3098, 2953, 3099, 2930, 3100,
+     3109, 2818, 2796, 2785, 2502, 3110, 3102, 2383, 3135, 3112,
+     3120, 3124, 3128, 3125, 2746, 2687, 3131, 3133, 2605, 3134,
+     2590, 2592, 2586, 2479, 2459, 2433, 4189, 3139, 3143, 3144,
+     3147, 3149, 3152, 3155, 2541, 3192, 3208, 3204, 3210, 3162,
+     3178, 2438, 3185, 3182, 2414, 3188, 2340, 3189, 3190, 2333,
+     4189, 2018, 2288, 2260, 3192,  112, 3197, 3188, 3200, 3191,
+     2137, 2149, 3210, 3211, 4189, 2017, 2011, 4189, 1998, 4189,
+
+     1986, 3212, 3213, 3197, 3216, 3218, 2624, 3271, 1977, 3239,
+     1982, 1903, 3223, 3231, 1885, 3254, 1854, 1829, 3232, 3066,
+     1951, 1593, 3241, 1822, 1744, 3242, 3245, 1736, 1662, 4189,
+     1653, 3250, 3257, 3252, 3254, 2850, 3310, 1642, 3270, 1622,
+     4189, 1521, 3100, 1441,    0, 3255, 3294, 1280, 1416, 1354,
+     1309, 3268, 3280, 4189, 1314, 1246, 3264, 3278, 3325, 3333,
+     1178, 3284, 1155, 4189, 3300, 1072, 3313, 2771, 1054, 1064,
+     3294, 3296, 4189, 1044, 3302, 3350, 3377,  992, 3305,  960,
+     3102,    0, 3337,  892, 4189,  829, 3312, 4189, 3342, 3388,
+      696, 3345,  555, 3358, 3364,  406, 3367, 3414, 3415,  348,
+
+     3368, 4189, 3341, 3380, 4189, 4189, 3366, 3381, 3351, 3367,
+     2713, 3390, 3382, 3386,  281, 3404, 4189, 3405, 3416, 3426,
+      177, 4189, 4189, 3482, 3499, 3516, 3533, 3550, 3567, 3577,
+     3584, 3601, 3615, 3629, 3646, 3663, 3672, 3685, 3702, 3716,
+     3722, 3731, 3748, 3765, 3424, 3427, 3428, 3774, 3432, 3436,
+     3440,  362, 2185, 3786, 3800, 3806, 3441, 3445, 3812, 3818,
+     3827, 3844, 3861, 3878, 3895, 3912, 3926, 3935, 3952, 3969,
+     3986, 4003, 4020, 4037, 4054, 4071, 4088, 4105, 4122
+    } ;
+
+static yyconst short int yy_def[1180] =
+    {   0,
+     1123,    1, 1124, 1124,    1,    2, 1125, 1125,    1,    2,
+        1,    2, 1123, 1123, 1123, 1123, 1123, 1126, 1127, 1123,
+     1123, 1128, 1129, 1123, 1123, 1123, 1123, 1123, 1130, 1123,
+     1123, 1123, 1123, 1131, 1131,   35,   35,   35,   35,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   37,
+       37, 1123, 1123, 1123, 1132, 1133,   37,   38,   38,   37,
+       38, 1123, 1134, 1123, 1134, 1135, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1126, 1126, 1126, 1127, 1123, 1127, 1127,
+     1128, 1123, 1128, 1128, 1129, 1136, 1129, 1123, 1129, 1129,
+     1123, 1123, 1123, 1137, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1138, 1130, 1123, 1123,   38,   38,   38,   38,
+       38,   38,   35,   38,   38,  115,  115,  115,  115,  115,
+      115,  115,  115, 1131,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1123, 1139, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1140, 1132, 1123, 1132,
+     1132, 1132, 1140, 1141, 1142,  115,  115,  115,  115,  115,
+      115, 1134, 1123, 1134, 1143, 1143, 1123, 1143, 1143, 1143,
+
+     1144, 1143, 1123,  203,  203,  203,  203,  203, 1123, 1123,
+     1123, 1126, 1126, 1127, 1127, 1128, 1128, 1136, 1136, 1136,
+     1136, 1123, 1129, 1129, 1145, 1146, 1147, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1148, 1149,
+     1150, 1151, 1152, 1153,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115, 1154,  124,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115, 1123,  115, 1123,
+     1123,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123, 1123, 1123, 1123, 1139, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1155, 1155, 1132, 1132, 1132,
+     1156, 1142, 1142, 1142, 1142,  115,  115,  115,  115,  115,
+      115, 1134, 1143, 1143, 1123, 1143, 1143, 1144, 1144, 1144,
+     1144, 1143, 1143,  203,  203, 1143,  203,  203,  203,  203,
+     1123, 1123, 1123, 1126, 1126, 1127, 1127, 1128, 1128, 1136,
+     1129, 1129, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1148, 1123, 1123, 1123, 1123, 1123, 1123, 1157, 1153, 1158,
+      115,  115, 1123,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115, 1123,  115,
+      115,  115,  115, 1123, 1123,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1123,  115, 1123,  115,  115,
+      115,  115,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115, 1123, 1123,  115,  115, 1123, 1123,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115, 1123, 1123,
+
+      115,  115,  115,  115,  115,  115, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1159, 1159, 1132, 1132,
+     1132, 1160, 1142, 1142,  115,  115,  115,  115,  115, 1123,
+     1134, 1143, 1143, 1144, 1144, 1143, 1143, 1143,  203,  203,
+      203,  203, 1123, 1161, 1123, 1126, 1162, 1127, 1163, 1128,
+     1164, 1129, 1165, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123,  115,  115,  115, 1123,  115,
+      115, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+
+      115, 1123, 1123,  115,  115,  115, 1123, 1123,  115,  115,
+      115, 1123,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115, 1123,  115,  115,  115,  115,
+      115, 1123,  115,  115,  115,  115, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1132, 1132, 1166,
+     1167, 1142, 1168, 1123, 1123,  115,  115, 1123,  115, 1123,
+     1123, 1123, 1134, 1143, 1169, 1144, 1170, 1143, 1143, 1143,
+     1143,  203,  203, 1123,  203, 1171, 1123, 1123, 1172, 1126,
+     1173, 1127, 1123, 1174, 1128, 1175, 1129, 1129, 1123, 1123,
+
+     1123, 1123,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115, 1123,  115,  115,  115, 1123, 1123,  115,  115,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+      115,  115,  115,  115,  115,  115,  115,  115,  115, 1123,
+     1123,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123,  115,  115,  115,  115,  115,
+      115,  115, 1123, 1123, 1123, 1123, 1123, 1123,  655, 1132,
+     1176, 1132, 1142, 1168, 1168,  115,  115,  115, 1134, 1177,
+     1143, 1144, 1170, 1170, 1123, 1143,  203,  203, 1123, 1123,
+
+     1126, 1127, 1123, 1128, 1129, 1129, 1123, 1123,  115,  115,
+      115,  115,  115,  115,  115,  115,  115, 1123, 1123,  115,
+      115,  115, 1123, 1123,  115, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123, 1178,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115, 1123, 1123,  115, 1123,  115,  115, 1123, 1123, 1123,
+     1132, 1132, 1142,  115,  115, 1123, 1134, 1143, 1144, 1143,
+      203,  203,  115,  115,  115,  115,  115,  115,  115, 1123,
+     1123, 1123,  115,  115, 1123,  115, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1178, 1123, 1179, 1178,  115,  115,  115,
+      115, 1123,  115,  115,  115,  115, 1123,  115, 1123,  115,
+      115, 1123, 1123, 1132, 1142,  115,  115, 1134, 1144,  115,
+      115,  115,  115,  115, 1123, 1123,  115,  115, 1123,  115,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1179, 1178, 1179, 1179,  115,
+      115, 1123,  115,  115, 1123,  115, 1123,  115,  115, 1123,
+     1123, 1132, 1142, 1142,  115, 1134, 1144, 1144,  115,  115,
+     1123, 1123,  115,  115, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123,  115,  115,  115,  115,  115, 1123, 1178, 1123,  115,
+     1123, 1123,  115,  115, 1123, 1132, 1142, 1142,  115, 1134,
+     1144, 1144,  115, 1123, 1123,  115,  115, 1123, 1123, 1123,
+     1123,  115,  115,  115,  115, 1123, 1178, 1123,  115, 1123,
+     1123, 1123, 1132, 1142, 1142,  115, 1134, 1144, 1144, 1123,
+     1123,  115,  115, 1123, 1123, 1123,  115,  115, 1123, 1178,
+     1123,  115, 1123, 1123, 1132, 1142, 1134, 1144, 1123, 1123,
+      115,  115, 1123, 1123,  115, 1123, 1178, 1123,  115, 1123,
+     1132, 1142, 1134, 1144, 1123, 1123,  115, 1123, 1178, 1178,
+     1123,  115, 1123, 1132, 1134, 1123,  115, 1178, 1179, 1123,
+
+      115, 1123, 1132, 1134, 1123, 1123, 1132, 1134, 1132, 1134,
+     1132, 1134, 1132, 1134, 1132, 1134, 1123, 1134, 1134, 1134,
+     1134, 1123,    0, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123
+    } ;
+
+static yyconst short int yy_nxt[4253] =
+    {   0,
+       14,   15,   16,   17,   18,   19,   14,   20,   21,   22,
+       23,   24,   21,   25,   21,   26,   21,   27,   28,   29,
+       29,   29,   29,   29,   29,   29,   29,   29,   21,   30,
+       31,   32,   33,   21,   21,   34,   35,   36,   37,   38,
+       39,   40,   41,   34,   42,   34,   34,   43,   44,   45,
+       46,   47,   34,   48,   49,   50,   34,   34,   51,   34,
+       34,   34,   14,   52,   53,   54,   55,   64,   66,   65,
+       70,   72,   71,   72,   82,   71,   68,   73,   75,   92,
+       78,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       69,   68,   76,   67,   68,   86,   91,   68,  103,  102,
+
+       57,   58,   87,   88,   59,   69,   68,   68,   69,   68,
+       68,   69,   68,   83,  193,   68,   79,   60,   61,   68,
+       69,   69,   68,   69,   69,  210,   69,   84,   68,   69,
+       80,  105,  333,   69,   89,   72,   69,   72,   78,   70,
+       68,   71,   69,  108,  116,  108,  108,  131,   90,   93,
+      132,   93,   78,  133,   69,  108,  185,  108,   82,  134,
+      193, 1020,  108,  110,   71,  194,   71,   94,   94,   94,
+       94,   94,   94,   94,   94,   94,  211,  108,  211, 1122,
+       71,  108,   73,  214,   95,  186,  215,  135,   96,   68,
+       97,  108,  108,  136,   82,   98,  108,   99,  100,  187,
+
+      137,  138,  108,   69,  366,  254,  108,  101,  106,  217,
+      107,  107,  107,  107,  107,  107,  107,  107,  107,  117,
+      108,  108,  108,  225,  226,  108,  118,  179,  216,  108,
+      119,  108,  109,  120,   86,  139,  227,  108,  110,  108,
+      369,   87,   88,  121,  230,  255,  110,  106,  108,  107,
+      107,  107,  107,  107,  107,  107,  107,  107,  232,  231,
+      153,  338,  108,  108,  108,  122,  234,  111,  112,  123,
+      108,  109,  108,  233,  108,  124,  235,  113,  108,  125,
+      110,  108,  108, 1117,  114,  115,  140,  366,  366,  253,
+      108,  126,  396,  127,  141,  108,  128,  129,  108,  110,
+
+      142,  143,  108,  130,  108,  108,  108,  367,  370,  144,
+      108,  146,  108,  147,  108,  145,  108,  149,  148,  108,
+      108,  108,  154,  179,  191,  108,  155,  397,  180,  179,
+      156,  150,  160,  314,  151,  108,  108,  152,  157,  161,
+      108,  158,  159,  108,  108,  193,  108,  315,  260,  162,
+      108,  163,  329,  183,  108,  108,  108,  189,  108,  168,
+      135,  164,  181,  339,  108,  108,  330,  103,  108,  165,
+      243,  166,  167,  160,  243,  103,  182,  168,   86,  352,
+      161,  196,  197,  196,  108,   87,   88,  108, 1106,  390,
+      162,   68,  168,  198,  219,  220,  219,  190,  168, 1123,
+
+       82,  108,  221,  222,   86,   69,  169,  170,   86,   68,
+      171,   87,   88, 1123,  108,   87,   88,  108,  270,  252,
+      108,  199,  259,  172,  173,  174,  175,  176,  167,  391,
+      337,  108,  267,  168,  108,  200,  168,  108,  223,  108,
+      108,  366,  268,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  256,  257,  379, 1105,  108,  108,  258,  224,
+      108,  108,  169,  170,  683,   68,  171,  243,  243,  243,
+      243,  243,  243,  243,  243,  243,  282,  276,  108,  172,
+      173,  195,  196,  197,  196,  195,  195,  195,  201,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  202,  195,
+
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  195,
+      195,  195,  195,  195,  195,  195,  204,  186,  204,  204,
+      204,  204,  205,  204,  118,  204,  204,  204,  206,  204,
+      204,  187,  204,  204,  204,  204,  207,  204,  204,  204,
+      204,  208,  204,  195,   93,  179,   93,  108,  108,  244,
+      245,  108,   78,  108,  108,  108,   78,  108,  108,  179,
+      108,  108,  108,   82,  108,  261,  197, 1102,  108,  108,
+      108,  266,  108,  108,  108,  108,  108,  108,  108,   95,
+      108,  108,  108,   96,  108,   97,  108,  108,  247,  108,
+       98,  549,   99,  100,  376,  275,  340,  108,  108,  519,
+
+      269,  108,  101,  239,  239,  239,  239,  239,  239,  239,
+      239,  239,  108,  108,  277,  550,  108,  357,  108,   82,
+      108,  303,  108,  240,  241,  246,  108,  108,  108,  108,
+      108,  108,  108,  108,  108,  337,  242,  108,  248,  108,
+      249,  168,  108,  108,  274,  108,  108,  108,  108,  250,
+      108,  291,  278,  251,  278,  108,  108,  108,  108,  108,
+      108,  108,  108,  337,  378,  179,  108,  108,  287,  168,
+      246,  108,  108,  262,  271,  262,  366,  103,  366,  108,
+      280,  272,  280,  108,  108,  273,  108,  108,  283,  106,
+      281,  263,  263,  263,  263,  263,  263,  263,  263,  263,
+
+      284,  108,  285,  108,  108,  286,  279,  288,  108,  108,
+      108,  368,  290,  540,  366,  245,  108,  659,  518,  108,
+      108,  289,  108,  292,  168,  108,  108,  108,  264,  293,
+      265,  294,  108,  108,  108,  108,  313,  108,  295,  108,
+      108,  297,  108,  304,  539,  305,  108,  108,  300, 1100,
+      301,  108,  298,  296,  244,  299,  302,  108,  310,  108,
+      108,  306,  307,  108,  108,  308,  108,  309,  108,  316,
+      108,  108,  311,  108,  320,  354,  355,  354,  108,  312,
+      317,  321,  322,  108,  318,  108,  108,  108,  319,  324,
+      108,  325,  167,  108,  323,  108,  327,  168,  325,  167,
+
+      108,  108,  193,  108,  168,  343,  108,  343,  327,   78,
+      325,  167,  253,  373,  349,  373,  168,  108,  108,  346,
+       78,  108,  197,  108,  108,  348,  169,  170,  351,  383,
+      171,  383,  366,  169,  170,  108,  350,  171,  108,  179,
+      344,  108,  531,  326,  173,  169,  170,  256,  347,  171,
+      326,  173,  108,  258,  345,  691,  356,  359,  197,  359,
+      377,  220,  326,  173,  327,  175,  335,  167,  380,  222,
+      220,  541,  168,   86,  385,  197,  385,  380,  222, 1096,
+       87,   88,  336,  336,  336,  336,  336,  336,  336,  336,
+      336,   86,  360,  521,  197,  219,  220,  219,   87,   88,
+
+      108,  169,  170,  221,  222,  171,  361,  219,  220,  219,
+      387,  411,  387,  225,  226,  221,  222,  108,  326,  173,
+      197,  402,  404,  402,  404,  518,  227,  382,  406,  533,
+      406,  168,  343,  545,  343,  545,  381,  362,  362,  362,
+      362,  362,  362,  362,  362,  362,  353,  353,  197,  353,
+      353,  353,  353,  353,  353,  353,  353,  353,  353,  353,
+      353,  353,  353,  363,  353,  364,  364,  364,  364,  364,
+      364,  364,  364,  364,  353,  353,  353,  353,  353,  353,
+      353,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+      365,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+
+      365,  365,  365,  365,  365,  365,  365,  365,  353,  108,
+      413,  108,  657,  108,  280,  366,  280,  108,  168,  108,
+      108, 1093,  108,  108,  281,  415,  108,  418,  108,  412,
+      108,  414,  416,  417,  108,  108,  108,  108,  108,  420,
+      108,  421,  108,  108,  108,  542,  108,  108, 1091,  419,
+      428,  425,  108,  432,  422,  108,  108,  423,  426,  108,
+      108,  108,  424,  108,  108,  108,  430,  427,  108,  108,
+      108,  108,  108,  108,  451,  431,  433,  444,  108,  445,
+      366,  445,  108,  108, 1088,  108,  108,  449,  108,  108,
+      434,  108,  434,  108,  108,  108,  447,  448,  450,  108,
+
+      108,  453,  278,  684,  278,  452,  108,  108, 1086,  446,
+      108,  108,  108, 1085,  108,  108,  108,  456,  108,  108,
+      435,  455,  179,  108,  108,  108,  457, 1082,  436,  108,
+      437,  108,  108,  438,  197,  108,  108,  439,  458,  459,
+      440,  108,  108,  441,  442,  460,  108,  443,  108,  463,
+      467,  463,  467,  108,  462,  108,  454,  472,  461,  464,
+      468,  478,  108,  108,  108,  108,  474,  520,  471,  108,
+      108, 1080,  108,  108,  473,  108,  108,  108,  108,  108,
+      535,  108,  476,  477,  108,  108,  108,  108,  475,  480,
+      108,  479,  108,  108,  498,  465,  469,  108,  108,  108,
+
+      481,  108,  108,  483,  108,  466,  470,  108,  482,  484,
+      485,  108,  108,  108,  108,  108,  108, 1078,  486,  487,
+      108,  490,  108,  108,  108,  108,  491,  492,  108,  108,
+      108,  488,  489,  493,  108,  108,   78,  108,  108,  108,
+      108,  494,  108,  108,  495,  108,  499,  108,  499,  108,
+      501,  108,  108,  497,  496,  108,  500,  108,  503,  504,
+      108,  108,  108,  502,  108,  507,  505,  508,  167,  518,
+      197,  108,  108,  168,  108,  168,  525,  530,  108,  527,
+      506,  108,  197,  103,  509,  548,  508,  167,  108,  108,
+      526,  509,  168,  508,  167, 1074,  108,  197,  108,  168,
+
+      108,  528,  169,  170,   82,  179,  171,  108,  193,  108,
+      108,  529,  354,  355,  354,  532,  559,  108,  559,  326,
+      173,  169,  170,  220,  108,  171,  108,  108,  169,  170,
+      380,  222,  171,  359,  197,  359, 1068,  534,  326,  173,
+      108,  561,  551,  561,   86,  326,  173,  509,  175,  516,
+      167,   87,   88,   86, 1073,  168,  658,  108,  563,  673,
+       87,   88,  445, 1070,  445,  517,  517,  517,  517,  517,
+      517,  517,  517,  517,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  657,  169,  170,  225,  226,  171,  168,
+      366,  553,  446,  688, 1069,  688,  552,  108,  108,  227,
+
+      565,  326,  173,  197,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  685,  108,  108,  179,  668,  197,  668,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  386,
+      386,  386,  386,  386,  386,  386,  386,  386,  108,  108,
+      197,  536,  197,  386,  386,  386,  386,  386,  386,  386,
+      386,  386,  168,  197,  660,  108,  108,  566,  168,  537,
+      537,  537,  537,  537,  537,  537,  537,  537,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  108,  567,  108,
+      538,  197,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  675,  674,  569,  108,  108,  108, 1066,  362,  362,
+
+      362,  362,  362,  362,  362,  362,  362,  403,  403,  403,
+      403,  403,  403,  403,  403,  403,  403,  403,  403,  403,
+      403,  403,  403,  403,  403,  405,  405,  405,  405,  405,
+      405,  405,  405,  405,  405,  405,  405,  405,  405,  405,
+      405,  405,  405,  407,  407,  407,  407,  407,  407,  407,
+      407,  407,  407,  407,  407,  407,  407,  407,  407,  407,
+      407,  108,  108,  108,  108,  564,  568,  108,  197,  108,
+      108,  108,  571,  572,  570,  108, 1064,  108,  108,  108,
+      108,  108,  573,  574,  108,  108,  108,  108,  108,  108,
+      108,  590,  108,  578,  108,  197,  576,  577,  579,  108,
+
+      579,  108,  108,  108,  592,  108,  108,  108,  366,  596,
+      591,  108,  593,  108,  108,  594,  108,  677,  108,  108,
+      595,  599,  108,  108,  607,  597,  607,  108,  108,  723,
+      108,  108,  610,  108,  600,  598,  108,  724,  601,  179,
+      606,  580, 1049,  108,  108,  682,  609,  108,  108,  108,
+      108,  168,  108,  108,  608,  581,  434,  168,  434,  108,
+      108,  613,  611,  727,  108,  108,  108,  108,  614,  108,
+      108,  615, 1063,  617,  616,  108,  108,  621,  871,  728,
+      618,  108, 1061,  108,  619,  463,  435,  463,  108,  620,
+      623,  467,  108,  467,  582,  464,  583, 1056,  108,  584,
+
+     1055,  468,  622,  585,   86,  108,  586,  108,  625,  587,
+      588,  698,  699,  589,  602,  602,  602,  602,  602,  602,
+      602,  602,  602,  602,  602,  108,  602,  602,  602,  602,
+      602,  603,  602,  604,  604,  604,  604,  604,  604,  604,
+      604,  604,  602,  602,  602,  602,  602,  602,  602,  605,
+      605,  605,  605,  605,  605,  605,  605,  605,  605,  605,
+      605,  605,  605,  605,  605,  605,  605,  605,  605,  605,
+      605,  605,  605,  605,  605,  605,  602,  108,  108,  108,
+      108,  108,  108,  108,  785, 1054,  785,  108, 1051,  626,
+      627,  624,  108,  108,  108,  108,  108,  108,  108,  108,
+
+      108,  628,  108,  108,  108,  629,  630,  633,  108,  108,
+      108,  631,  108,  108,  636,  108,  108,  108,  108,  108,
+      108,  635,  632,  108,  108,  634,  108,  638,  641,  108,
+      108,  640,  637,  108,  639,  108,  108,  108,  108,  642,
+      108,  108,  108,  108,  108,  108,  108,  499,  108,  499,
+      108,  197,  644,  108,  108,  108,  179,  500,  108,  108,
+      643,  108,  108,  108,  108,  108,  108,  108,  108, 1050,
+      645,  647,  646,  648,  167,  669,  657,   82, 1045,  168,
+      108,  108,  168,  108,  701,  108,  649,  366,  648,  167,
+      103, 1044,  108,  649,  168,  648,  167,  108,  780,  667,
+
+      705,  168,  676,  668,  664,  668,  664,  571,  169,  170,
+      795,  668,  171,  668,  665,  694,  108,  108,  108,  108,
+      108,   86,  707,  169,  170,  326,  173,  171,   87,   88,
+      169,  170, 1042,  706,  171,  108,  108,  108,  108,  108,
+      326,  173,  666, 1041,  670,  108,  670,  326,  173,  649,
+      175,  655,  167,  197,  671,  108,  108,  168,  672,  696,
+      108,  193,  108,  108,  709,  108,  108,  656,  656,  656,
+      656,  656,  656,  656,  656,  656,  708,  108,  710,  108,
+      108,  108,  108,  108,  712,  108,  169,  170, 1048,  714,
+      171,  607,  785,  607,  785,  711,  108, 1040,  108,  108,
+
+      877,  108,  108,  326,  173,  197,  560,  560,  560,  560,
+      560,  560,  560,  560,  560, 1038,  108,  678,  108,  678,
+      179,  608,  679,  679,  679,  679,  679,  679,  679,  679,
+      679,  197,  560,  560,  560,  560,  560,  560,  560,  560,
+      560, 1031,  179,  794,  197,  794, 1030, 1029,  537,  537,
+      537,  537,  537,  537,  537,  537,  537,  562,  562,  562,
+      562,  562,  562,  562,  562,  562,  108, 1028, 1016,  536,
+      197,  562,  562,  562,  562,  562,  562,  562,  562,  562,
+      781,  108,  680,  108,  680,  732,  719,  681,  681,  681,
+      681,  681,  681,  681,  681,  681,  687,  687,  108,  687,
+
+      687,  687,  687,  687,  687,  687,  687,  687,  687,  687,
+      687,  687,  687,  702,  687,  703,  703,  703,  703,  703,
+      703,  703,  703,  703,  687,  687,  687,  687,  687,  687,
+      687,  704,  704,  704,  704,  704,  704,  704,  704,  704,
+      704,  704,  704,  704,  704,  704,  704,  704,  704,  704,
+      704,  704,  704,  704,  704,  704,  704,  704,  687,  108,
+      108,  579,  108,  579,  108,  108,  108,  716,  108,  720,
+      715,  733,  108,  736,  739,  735,  108,  108,  731,  108,
+      734,  108,  108,  108,  108,  108,  108, 1025, 1024,  108,
+      738,  108,  740,  409,  740,  244,  193,  409,  108,  737,
+
+      108,  108,  108,  108,  717,  243,  243,  243,  243,  243,
+      243,  243,  243,  243,  108,  108,  108,  108,  718,  108,
+      108,  743,  741,  108,  108,  745,  108,  108,  744,  742,
+      108,  108,  108,  108,  748,  746,  108,  108,  789,  108,
+      108,  108,  752,  747,  108,  108,  108,  108,  753,  108,
+      750,  197,  751,  108,  108,  749,  108,  108,  108,  108,
+      755,  108,  108,  108,  108,  754,  108,  108,  756,  758,
+      757,  108,  108,  108,  108,  108,  760,  759,  108,  108,
+      763,  108,  108,  108,  108,  108,  761,  764,  108,  108,
+      108,  108,  108,  792,  108,  769,  108,  108,  762,  108,
+
+      108,  108,  108,  108, 1018,  108,  766,  768,  108,  108,
+      767,  108,  108,  108,  664,  197,  664,  108,  108,  770,
+      108,  771,  772,  773,  665,  774,  167,  168, 1017,  108,
+      108,  168,  775,  168,  774,  167,  664,  670,  664,  670,
+      168,  103,  775,  197,  774,  167,  665,  671,  108,  108,
+      168,  672,  776,  786,  879,   86,  787,  794,  197,  794,
+      169,  170,  806,  807,  171,  108,  108,  108,   86,  169,
+      170,  108,  244,  171,  776,   87,   88,  326,  173,  169,
+      170,  790,  788,  171,  108,  193,  326,  173,  108, 1015,
+      672,  108,  672,  670, 1012,  670,  326,  173,  775,  175,
+
+      779,  167,   86,  671,  672,  108,  168,  672,  108,   87,
+       88,  243,  243,  243,  243,  243,  243,  243,  243,  243,
+      812,  108,  108,  986,  811,  108,  108,  108,  108,  108,
+      816,  108,  819,  108,  819,  169,  170,  108,  108,  171,
+      813,  817,  108,  108,  108,  108,  108,  815,  108,  814,
+      108,  108,  326,  173,  197,  822,  740, 1011,  740,  819,
+      876,  819,  876,  876,  108,  876,  108,  108,  108,  820,
+      825,  679,  679,  679,  679,  679,  679,  679,  679,  679,
+      197,  839,  821,  108,  108,  965,  741,  965, 1009, 1001,
+      108,  108,  834,  108,  108,  835,  891,  679,  679,  679,
+
+      679,  679,  679,  679,  679,  679,  197,  108,  108,  892,
+      108,  841,  179,  836, 1000,  999,  108,  108,  843,  108,
+      108,  838,  837,  681,  681,  681,  681,  681,  681,  681,
+      681,  681,  197,  108,  108,  108,  850,  108,  862,   86,
+      862,  983, 1007,  984, 1007,  934,   87,   88,  863,  681,
+      681,  681,  681,  681,  681,  681,  681,  681,  791,  791,
+      197,  791,  791,  791,  791,  791,  791,  791,  791,  791,
+      791,  791,  791,  791,  791,  796,  791,  797,  797,  797,
+      797,  797,  797,  797,  797,  797,  791,  791,  791,  791,
+      791,  791,  791,  798,  798,  798,  798,  798,  798,  798,
+
+      798,  798,  798,  798,  798,  798,  798,  798,  798,  798,
+      798,  798,  798,  798,  798,  798,  798,  798,  798,  798,
+      791,  800,  800,   86,  800, 1036,  998, 1036,  800,  800,
+       87,   88,  800,  997,  996,  800,  800,  800,  800,  800,
+      800,  800,  800,  799,  799,  995,  799,  799,  799,  799,
+      799,  799,  799,  799,  799,  799,  799,  799,  799,  799,
+      808,  799,  809,  809,  809,  809,  809,  809,  809,  809,
+      809,  799,  799,  799,  799,  799,  799,  799,  810,  810,
+      810,  810,  810,  810,  810,  810,  810,  810,  810,  810,
+      810,  810,  810,  810,  810,  810,  810,  810,  810,  810,
+
+      810,  810,  810,  810,  810,  799,  108,  108,  108,  844,
+      840,  844,  108,  108,  851,  179,  108,  848,  842,  845,
+      847,  108,  846,  108,  108,  108,  108,  992,  108,  108,
+      108,  108,  849,  108,  852,  108,  108,  853,  108,  108,
+      854,  108,  854,  108,  108,  108,  857,  108,  108, 1113,
+      108,  108,  108,  108,  860,  108,  108,  108,  108,  856,
+      108,  108,  108,  108,  108,  859,  858,  108,  108,  861,
+      864,  108,  108,  197,  108,  108,  865,  108,  865,  108,
+      108,  108,  773,  108,  775,  167,  108,  179,  108,  108,
+      855,  874,  108,  775,  991,  774,  167,  108,  108,  867,
+
+      108,  168,  775,  108,  775,  167,  108,  876,  108,  876,
+      244,  108,  865,  866,  865,  108,  888,  885,  883,  169,
+      170,  875,  884,  171,  982,  108, 1084,  108,  108,  108,
+      169,  170,  108,  108,  171,  108,  326,  173,  108,  169,
+      170,  108,  108,  171,  894,  886,  108,  326,  173,  929,
+      981, 1059,  889, 1059,  980,  108,  326,  173,  108,  108,
+      878,  878,  197,  878,  878,  878,  878,  878,  878,  878,
+      878,  878,  878,  878,  878,  878,  878,  880,  878,  881,
+      881,  881,  881,  881,  881,  881,  881,  881,  878,  878,
+      878,  878,  878,  878,  878,  882,  882,  882,  882,  882,
+
+      882,  882,  882,  882,  882,  882,  882,  882,  882,  882,
+      882,  882,  882,  882,  882,  882,  882,  882,  882,  882,
+      882,  882,  878,  197,  243,  243,  243,  243,  243,  243,
+      243,  243,  243,  108,  108,  108,  108,  887,  108,  108,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  893,
+      108,  108,  108,  896,  108,  108,  906,  905,  108,  108,
+      108,  909,  108,  108,  108,  907,  977,  911,  912,  975,
+      972,  108,  108,  108,  910,  908,  108,  108,  915,  108,
+      108,  108,  844,  913,  844,  916,  918,  108,  917,  108,
+      108,  108,  845,  108,  108,  108,  108,  920,  854,  108,
+
+      854,  108,  108,  108,  108,  108,  919,  921,  108,  926,
+      108,  108,  108,  108,  925,  108,  108,  108,  923,  108,
+      108,  924,  108,  108,  108,  862,  930,  862,  193,  108,
+      936,  197,  108,  108,  108,  863,  108,  931,  108,  940,
+      108,  108,  108,  108,  957,  928,  108,  108,  922,  108,
+      108,  937,  108,  108,  108,  108,  941,  108,  108,  942,
+      108,  938,  948,  108,  939,  197,  108,  950,  193,  108,
+      944,  108,  947,  943,  108,  108,  108,  108,  961,  956,
+      108,  959,  362,  362,  362,  362,  362,  362,  362,  362,
+      362,  108,  108,  108,  108,  108,  960,  108,  108,  958,
+
+      915,  108,  179,  108,  179, 1047,  108,  916,  108,  108,
+      917,  108,  967,  962,  108,  108,  964,  963,  108,  968,
+      108,  915,  969,  108,  108,  108,  108,  108,  916,  970,
+      108,  917,  971,  108,  108,  108,  108,  197,  108,  976,
+      973,  108,  108,  108,  108,  108,  108,  108,  108, 1065,
+      108,  974,  108,  108,  978,  108,  108, 1094,  979,  989,
+      108,  108,  108,  108,  108,  108,  985,  108,  990,  108,
+      108,  994,  955,  108,  987,  108,  988,  108,  108, 1003,
+      108,  108,  993,  108,  108,  108,  108,  108,  108, 1002,
+      197,  108,  108, 1006,  967, 1004,  108,  108,  108,  197,
+
+      108,  968,  108,  954,  969,  108,  967, 1005,  108, 1008,
+      967, 1008,  967,  968,  108,  108,  969,  916,  108,  968,
+      917,  108,  969, 1010,  108,  108,  108,  108,  108, 1013,
+     1014,  108, 1022,  108,  953,  108,  108, 1021,  108, 1019,
+     1023,  108,  108,  108,  108,  108,  108,  108,  108,  108,
+      108, 1033,  108,  108,  108, 1027,  179, 1026, 1035,  108,
+     1034, 1032,  952,  108,  108,  108,  108,  108,  108,  108,
+      951,  108, 1037,  915, 1037,  108,  108,  108,  108, 1039,
+      916,  108, 1052,  917,  108,  108,  108, 1046,  108, 1043,
+      108,  108,  108,  108,  108,  108,  193, 1057,  108, 1053,
+
+      108, 1058,  179,  108,  108,  108,  108,  108,  108, 1062,
+      108, 1060,  915, 1060,  108,  193,  108,  108, 1075,  916,
+      108,  108,  917,  108, 1072,  949, 1076, 1071, 1076, 1067,
+      108,  108,  108,  108, 1077,  915, 1077,  108,  108,  193,
+     1079,  108,  916,  179,  915,  917, 1087,  108,  108,  108,
+     1081,  916, 1083,  179,  917,  108, 1089, 1089, 1092, 1089,
+      179, 1097,  946, 1089, 1089,  108,  193, 1089,  179,  193,
+     1089, 1089, 1089, 1089, 1089, 1089, 1089, 1089, 1090,  915,
+     1090,  108,  193,  193,  179, 1101,  916, 1095,  193,  917,
+      915, 1111,  193, 1103, 1098, 1098, 1107, 1099,  108, 1104,
+
+      917, 1098, 1098,  108,  108, 1098,  193,  193, 1098, 1098,
+     1098, 1098, 1098, 1098, 1098, 1098,  915,  967,  193, 1109,
+      108,  108, 1112,  916,  968, 1114,  917,  969,  193, 1108,
+      384, 1110,  384,  386,  388,  386,  388, 1115,  403,  945,
+      403, 1116,  405,  366,  405, 1119,  407,  560,  407,  560,
+      197,  562, 1120,  562,  935,  179,  933, 1118,  932,  927,
+      904,  903,  902,  901,  900,  899,  898,  897,  895,  890,
+       82,   78,  366,  197,  197,  197,  873,  179,  179,  870,
+      869, 1121,   62,   62,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,   62,   62,   62,   62,   62,   63,
+
+       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
+       63,   63,   63,   63,   63,   63,   74,   74,  868,   74,
+       74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
+       74,   74,   74,   77,   77,  833,   77,   77,   77,   77,
+       77,   77,   77,   77,   77,   77,   77,   77,   77,   77,
+       81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
+       81,   81,   81,   81,   81,   81,   81,   85,   85,   85,
+       85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
+       85,   85,   85,   85,  104,  104,  832,  831,  830,  829,
+      104,  108,  108,  108,  108,  108,  108,  108,  108,  108,
+
+      108,  178,  178,  178,  178,  178,  178,  178,  178,  178,
+      178,  178,  178,  178,  178,  178,  178,  178,  184,  828,
+      184,  827,  184,  184,  826,  824,  823,  818,  184,  192,
+      192,  192,  192,  192,  192,  192,  192,  192,  192,  192,
+      192,  192,  192,  192,  192,  192,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,   82,  195,  195,  195,
+      195,   82,  195,  218,  218,  218,  218,  218,  218,  218,
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
+       94,   78,  803,   94,   94,  238,  238,  238,  238,  366,
+      238,  238,  366,  238,  238,  197,  238,  238,  783,  179,
+
+      238,  238,  328,  328,  328,  328,  328,  328,  328,  328,
+      328,  328,  328,  328,  328,  328,  328,  328,  328,  336,
+      778,  336,  777,  765,  336,  341,  730,  341,  729,  341,
+      341,  342,  342,  726,  342,  342,  342,  342,  342,  342,
+      342,  342,  342,  342,  342,  342,  342,  342,  353,  353,
+      353,  353,  353,  353,  353,  353,  353,  353,  353,  353,
+      353,  353,  353,  353,  353,  358,  358,  358,  358,  358,
+      358,  358,  358,  358,  358,  358,  358,  358,  358,  358,
+      358,  358,  401,  725,  722,  401,  401,  262,  721,  262,
+      713,  700,   82,  693,  262,  689,  686,  530,  663,  662,
+
+      530,  654,  262,  517,  653,  517,  652,  651,  517,  522,
+      650,  522,  612,  522,  522,  656,  575,  656,  408,  558,
+      656,  661,  557,  661,  556,  661,  661,  687,  687,  555,
+      687,  687,  687,  687,  687,  687,  687,  687,  687,  687,
+      687,  687,  687,  687,  690,  690,  554,  690,  690,  690,
+      690,  690,  690,  690,  690,  690,  690,  690,  690,  690,
+      690,  692,  692,  547,  692,  692,  692,  692,  692,  692,
+      692,  692,  692,  692,  692,  692,  692,  692,  695,  695,
+      695,  695,  695,  695,  695,  695,  695,  695,  695,  695,
+      695,  695,  695,  695,  695,  697,  697,  697,  697,  697,
+
+      697,  697,  697,  697,  697,  697,  697,  697,  697,  697,
+      697,  697,  782,  782,  782,  782,  782,  782,  782,  782,
+      782,  782,  782,  782,  782,  782,  782,  782,  782,  104,
+      546,  104,  544,  104,  104,  784,  784,  543,  784,  784,
+      784,  784,  784,  784,  784,  784,  784,  784,  784,  784,
+      784,  784,  791,  791,  791,  791,  791,  791,  791,  791,
+      791,  791,  791,  791,  791,  791,  791,  791,  791,  793,
+      793,  793,  793,  793,  793,  793,  793,  793,  793,  793,
+      793,  793,  793,  793,  793,  793,  799,  799,  366,  799,
+      799,  799,  799,  799,  799,  799,  799,  799,  799,  799,
+
+      799,  799,  799,  801,  801,  197,  801,  801,  801,  801,
+      801,  801,  801,  801,  801,  801,  801,  801,  801,  801,
+      802,  802,  197,  802,  802,  802,  802,  802,  802,  802,
+      802,  802,  802,  802,  802,  802,  802,  804,  804,  804,
+      804,  804,  804,  804,  804,  804,  804,  804,  804,  804,
+      804,  804,  804,  804,  805,  805,  805,  805,  805,  805,
+      805,  805,  805,  805,  805,  805,  805,  805,  805,  805,
+      805,  872,  872,  872,  872,  872,  872,  872,  872,  872,
+      872,  872,  872,  872,  872,  872,  872,  872,  878,  878,
+      878,  878,  878,  878,  878,  878,  878,  878,  878,  878,
+
+      878,  878,  878,  878,  878,  914,  914,  914,  914,  914,
+      914,  914,  914,  914,  914,  914,  914,  914,  914,  914,
+      914,  914,  966,  966,  966,  966,  966,  966,  966,  966,
+      966,  966,  966,  966,  966,  966,  966,  966,  966,  524,
+      523,  515,  514,  513,  512,  511,  510,  179,  333,  429,
+      410,  408,  400,  399,  398,  395,  394,  393,  392,  389,
+      375,  374,  372,  371,  366,  197,  197,  193,  179,  334,
+      332,  331,  179,  237,  236,  229,  228,   82,   82,   78,
+      213,  212,  210,  209,  193,  188, 1123,   64,   13, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123
+    } ;
+
+static yyconst short int yy_chk[4253] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    2,    2,    2,    2,    8,   10,    8,
+       15,   16,   15,   16,   22,   17,   14,   17,   18,   25,
+       19,    2,    2,    2,    2,    2,    2,    2,    2,    2,
+       14,   20,   18,   10,   21,   23,   24,   26,   29,   28,
+
+        2,    2,   23,   23,    2,   20,   30,   25,   21,   31,
+       15,   26,   33,   22,  986,   17,   19,    2,    2,   24,
+       30,   25,   29,   31,   15,  172,   33,   22,   28,   17,
+       19,   32,  172,   24,   23,   53,   29,   53,   80,   70,
+       32,   70,   28,   40,   36,   36,   36,   40,   23,   27,
+       40,   27,   79,   40,   32,   36,   57,   40,   84,   40,
+       65,  986,   36,   36,   71,   65,   71,   27,   27,   27,
+       27,   27,   27,   27,   27,   27,   72,   41,   72, 1121,
+       73,   41,   73,   79,   27,   57,   80,   41,   27,   27,
+       27,   41,   42,   42,   83,   27,   42,   27,   27,   57,
+
+       42,   42,   42,   27,  207,  118,   42,   27,   34,   84,
+       34,   34,   34,   34,   34,   34,   34,   34,   34,   37,
+       37,   37,  118,   94,   94,   43,   37,  180,   83,   43,
+       37,  119,   34,   37,   85,   43,   94,   37,   37,   43,
+      207,   85,   85,   37,   97,  119,   34,   35,  119,   35,
+       35,   35,   35,   35,   35,   35,   35,   35,   98,   97,
+       48,  180,   38,   38,   48,   38,   99,   35,   35,   38,
+       48,   35,   38,   98,   48,   38,   99,   35,  117,   38,
+       38,   39,   39, 1115,   35,   35,   44,  208,  205,  117,
+       44,   39,  234,   39,   44,  117,   39,   39,   39,   39,
+
+       44,   45,   46,   39,   44,   45,   46,  205,  208,   45,
+       61,   46,   46,   46,   61,   45,   46,   47,   46,   45,
+       61,   47,   49,   55,   61,   47,   49,  234,   55,  181,
+       49,   47,   50,  158,   47,   47,   49,   47,   49,   50,
+       49,   49,   49,   50,   51,  194,   50,  158,  122,   50,
+       59,   51,  169,   56,   59,   51,   50,   59,   51,   56,
+       59,   51,   55,  181,   59,  122,  169,   56,   51,   52,
+     1152,   52,   52,   60, 1152,  104,   55,   52,   87,  194,
+       60,   66,   66,   66,   60,   87,   87,   60, 1100,  229,
+       60,   56,  168,   66,   86,   86,   86,   60,  168,  104,
+
+      217,  129,   86,   86,   89,   56,   52,   52,   90,   52,
+       52,   89,   89,  104,  126,   90,   90,  116,  129,  116,
+      121,   66,  121,   52,   52,   54,   54,   54,   54,  229,
+      177,  126,  126,   54,  116,   66,  177,  121,   89,  127,
+      120,  540,  127,   54,   54,   54,   54,   54,   54,   54,
+       54,   54,  120,  120,  217, 1096,  127,  120,  120,   90,
+      133,  137,   54,   54,  540,   54,   54,  106,  106,  106,
+      106,  106,  106,  106,  106,  106,  137,  133,  137,   54,
+       54,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   93,  182,   93,  108,  108,  107,
+      109,  108,  214,  123,  109,  109,  377,  108,  109,  338,
+      125,  108,  108,  378,  109,  123,  200, 1093,  109,  109,
+      123,  125,  107,  107,  111,  111,  107,  125,  111,   93,
+      128,  132,  107,   93,  111,   93,  107,  107,  111,  111,
+       93,  377,   93,   93,  214,  132,  182,  128,  132,  338,
+
+      128,  134,   93,  103,  103,  103,  103,  103,  103,  103,
+      103,  103,  110,  110,  134,  378,  110,  200,  134,  216,
+      152,  152,  110,  103,  103,  110,  110,  110,  112,  112,
+      113,  113,  112,  131,  113,  183,  103,  152,  112,  143,
+      113,  183,  112,  112,  131,  114,  114,  113,  113,  114,
+      131,  143,  135,  115,  135,  114,  143,  115,  115,  114,
+      114,  115,  139,  184,  216,  520,  130,  115,  139,  184,
+      115,  115,  115,  124,  130,  124,  368,  184,  206,  139,
+      136,  130,  136,  130,  140,  130,  138,  135,  138,  124,
+      136,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+
+      138,  140,  138,  138,  135,  138,  135,  140,  141,  142,
+      144,  206,  142,  368,  367,  136,  145,  520,  336,  157,
+      146,  141,  148,  144,  336,  141,  142,  144,  124,  145,
+      124,  146,  136,  145,  147,  149,  157,  146,  147,  148,
+      150,  148,  151,  153,  367,  153,  154,  155,  150, 1091,
+      151,  147,  149,  147,  263,  149,  151,  150,  155,  151,
+      153,  153,  153,  154,  155,  153,  156,  154,  159,  159,
+      161,  160,  156,  162,  161,  196,  196,  196,  163,  156,
+      159,  162,  163,  156,  160,  159,  164,  161,  160,  165,
+      162,  165,  165,  263,  164,  163,  166,  165,  166,  166,
+
+      189,  186,  352,  164,  166,  185,  188,  185,  174,  215,
+      174,  174,  186,  211,  189,  211,  174,  189,  186,  186,
+      548,  190,  199,  188,  191,  188,  165,  165,  191,  225,
+      165,  225,  369,  166,  166,  187,  190,  166,  190,  340,
+      185,  191,  352,  165,  165,  174,  174,  187,  187,  174,
+      166,  166,  187,  187,  185,  548,  199,  201,  201,  201,
+      215,  218,  174,  174,  176,  176,  176,  176,  218,  218,
+      221,  369,  176,  224,  226,  357,  226,  221,  221, 1086,
+      224,  224,  176,  176,  176,  176,  176,  176,  176,  176,
+      176,  223,  201,  340, 1084,  219,  219,  219,  223,  223,
+
+      245,  176,  176,  219,  219,  176,  201,  220,  220,  220,
+      227,  245,  227,  239,  239,  220,  220,  245,  176,  176,
+      202,  240,  241,  240,  241,  337,  239,  224,  242,  357,
+      242,  337,  343,  373,  343,  373,  223,  202,  202,  202,
+      202,  202,  202,  202,  202,  202,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  246,
+      247,  249,  517,  248,  280,  370,  280,  252,  517,  250,
+      251, 1080,  254,  255,  280,  249,  246,  252,  249,  246,
+      248,  248,  250,  251,  252,  247,  250,  251,  253,  254,
+      255,  255,  256,  257,  258,  370,  261,  259, 1078,  253,
+      261,  258,  247,  266,  256,  253,  260,  256,  259,  256,
+      257,  258,  257,  261,  259,  264,  264,  260,  265,  269,
+      266,  272,  267,  260,  275,  265,  267,  269,  271,  270,
+      541,  270,  264,  273, 1074,  265,  269,  273,  272,  267,
+      268,  275,  268,  276,  274,  271,  271,  271,  274,  277,
+
+      273,  277,  278,  541,  278,  276,  282,  279, 1070,  270,
+      276,  274,  297, 1069,  270,  283,  277,  282,  284,  285,
+      268,  279,  339,  282,  279,  268,  283, 1066,  268,  297,
+      268,  270,  283,  268,  361,  284,  285,  268,  284,  285,
+      268,  286,  268,  268,  268,  286,  287,  268,  290,  288,
+      289,  288,  289,  291,  287,  292,  278,  291,  286,  288,
+      289,  298,  293,  287,  294,  290,  293,  339,  290,  295,
+      291, 1063,  292,  299,  292,  296,  300,  316,  298,  293,
+      361,  294,  295,  296,  288,  289,  295,  301,  294,  300,
+      299,  299,  296,  300,  316,  288,  289,  302,  303,  305,
+
+      301,  288,  289,  302,  301,  288,  289,  304,  301,  303,
+      304,  306,  307,  308,  302,  303,  305, 1061,  304,  305,
+      311,  308,  309,  310,  304,  313,  309,  310,  306,  307,
+      308,  306,  307,  311,  312,  314,  376,  311,  315,  309,
+      310,  312,  313,  318,  313,  320,  317,  321,  317,  322,
+      318,  312,  314,  315,  314,  315,  317,  319,  320,  321,
+      318,  323,  320,  319,  321,  324,  322,  324,  324,  341,
+      356,  347,  346,  324,  319,  341,  346,  351,  323,  348,
+      323,  317, 1048,  341,  325,  376,  325,  325,  347,  346,
+      347,  327,  325,  327,  327, 1056,  348,  360,  317,  327,
+
+      349,  349,  324,  324,  379,  519,  324,  350,  531,  414,
+      351,  350,  354,  354,  354,  356,  408,  349,  408,  324,
+      324,  325,  325,  380,  350,  325,  414,  351,  327,  327,
+      380,  380,  327,  359,  359,  359, 1048,  360,  325,  325,
+      411,  410,  379,  410,  381,  327,  327,  335,  335,  335,
+      335,  381,  381,  382, 1055,  335,  519,  411,  411,  531,
+      382,  382,  445, 1051,  445,  335,  335,  335,  335,  335,
+      335,  335,  335,  335,  383,  383,  383,  383,  383,  383,
+      383,  383,  383,  518,  335,  335,  401,  401,  335,  518,
+      542,  382,  445,  545, 1050,  545,  381,  416,  415,  401,
+
+      415,  335,  335,  362,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  542,  416,  415,  521,  652, 1049,  652,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  385,
+      385,  385,  385,  385,  385,  385,  385,  385,  417,  418,
+      532,  362,  363,  386,  386,  386,  386,  386,  386,  386,
+      386,  386,  656,  533,  521,  417,  418,  418,  656,  363,
+      363,  363,  363,  363,  363,  363,  363,  363,  387,  387,
+      387,  387,  387,  387,  387,  387,  387,  419,  420,  422,
+      363,  366,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  533,  532,  422,  419,  420,  422, 1044,  366,  366,
+
+      366,  366,  366,  366,  366,  366,  366,  402,  402,  402,
+      402,  402,  402,  402,  402,  402,  403,  403,  403,  403,
+      403,  403,  403,  403,  403,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  405,  405,  405,  405,  405,  405,
+      405,  405,  405,  406,  406,  406,  406,  406,  406,  406,
+      406,  406,  407,  407,  407,  407,  407,  407,  407,  407,
+      407,  412,  421,  423,  424,  412,  421,  425,  535,  426,
+      428,  427,  424,  426,  423,  432, 1042,  436,  412,  421,
+      423,  424,  427,  428,  425,  430,  426,  428,  427,  431,
+      437,  436,  432,  432,  436, 1022,  430,  431,  433,  438,
+
+      433,  439,  430,  440,  438,  441,  431,  437,  539,  441,
+      437,  442,  438,  444,  443,  439,  438,  535,  439,  447,
+      440,  443,  441,  449,  450,  441,  450,  451,  442,  584,
+      444,  443,  452,  433,  444,  442,  447,  584,  447,  780,
+      449,  433, 1022,  453,  451,  539,  451,  455,  457,  452,
+      433,  657,  458,  456,  450,  433,  434,  657,  434,  450,
+      453,  456,  453,  587,  455,  457,  459,  460,  457,  458,
+      456,  458, 1040,  460,  459,  462,  450,  462,  780,  587,
+      460,  461, 1038,  459,  460,  463,  434,  463,  465,  461,
+      466,  467,  462,  467,  434,  463,  434, 1031,  461,  434,
+
+     1029,  467,  465,  434,  553,  465,  434,  466,  470,  434,
+      434,  553,  553,  434,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  470,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  469,  471,  472,
+      473,  474,  475,  476,  663, 1028,  663,  477, 1025,  471,
+      472,  469,  480,  478,  469,  471,  472,  473,  474,  475,
+
+      476,  477,  479,  481,  477,  478,  479,  482,  483,  480,
+      478,  480,  485,  484,  486,  487,  488,  489,  490,  479,
+      481,  484,  481,  491,  482,  483,  492,  488,  492,  485,
+      484,  490,  487,  488,  489,  490,  493,  486,  494,  495,
+      491,  496,  497,  492,  501,  503,  498,  499,  502,  499,
+      504,  534,  502,  493,  486,  494,  658,  499,  496,  497,
+      498,  501,  503,  498,  495,  502,  505,  504,  506, 1024,
+      505,  507,  506,  507,  507,  528,  522,  550, 1018,  507,
+      563,  495,  522,  505,  563,  506,  508,  682,  508,  508,
+      522, 1017,  528,  509,  508,  509,  509,  563,  658,  526,
+
+      565,  509,  534,  527,  525,  527,  525,  526,  507,  507,
+      682,  668,  507,  668,  525,  550,  526,  565,  566,  568,
+      567,  552,  567,  508,  508,  507,  507,  508,  552,  552,
+      509,  509, 1015,  566,  509,  566,  568,  567,  527,  525,
+      508,  508,  525, 1012,  529,  572,  529,  509,  509,  516,
+      516,  516,  516, 1021,  529,  527,  525,  516,  529,  552,
+      570,  789,  572,  569,  570,  571,  574,  516,  516,  516,
+      516,  516,  516,  516,  516,  516,  569,  570,  571,  529,
+      569,  573,  571,  574,  574,  576,  516,  516, 1021,  576,
+      516,  607,  785,  607,  785,  573,  529, 1011,  573,  590,
+
+      789,  592,  576,  516,  516,  536,  559,  559,  559,  559,
+      559,  559,  559,  559,  559, 1009,  590,  536,  592,  536,
+      982,  607,  536,  536,  536,  536,  536,  536,  536,  536,
+      536,  537,  560,  560,  560,  560,  560,  560,  560,  560,
+      560, 1001,  659,  677,  677,  677,  999,  997,  537,  537,
+      537,  537,  537,  537,  537,  537,  537,  561,  561,  561,
+      561,  561,  561,  561,  561,  561,  593,  996,  982,  537,
+      538,  562,  562,  562,  562,  562,  562,  562,  562,  562,
+      659,  580,  538,  593,  538,  593,  580,  538,  538,  538,
+      538,  538,  538,  538,  538,  538,  564,  564,  580,  564,
+
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  577,
+      578,  579,  581,  579,  596,  591,  595,  578,  594,  581,
+      577,  594,  597,  597,  600,  596,  577,  578,  591,  581,
+      595,  596,  591,  595,  598,  594,  599,  992,  991,  597,
+      599,  600,  601, 1153,  601,  604,  673, 1153,  605,  598,
+
+      609,  598,  610,  599,  579,  603,  603,  603,  603,  603,
+      603,  603,  603,  603,  604,  605,  606,  609,  579,  610,
+      611,  610,  601,  613,  615,  613,  616,  601,  611,  606,
+      617,  604,  614,  606,  617,  614,  618,  611,  673,  620,
+      613,  615,  621,  616,  601,  619,  622,  617,  622,  614,
+      619,  676,  620,  618,  623,  618,  620,  625,  624,  621,
+      624,  627,  619,  622,  628,  623,  626,  630,  625,  627,
+      626,  623,  629,  632,  625,  624,  629,  628,  627,  633,
+      634,  628,  631,  626,  630,  635,  631,  635,  637,  629,
+      632,  638,  640,  676,  639,  640,  633,  634,  633,  631,
+
+      641,  643,  635,  644,  984,  637,  637,  639,  638,  640,
+      638,  639,  645,  646,  650,  792,  650,  641,  643,  641,
+      644,  643,  644,  647,  650,  647,  647,  661,  983,  645,
+      646,  647,  648,  661,  648,  648,  664,  654,  664,  654,
+      648,  661,  649,  674,  649,  649,  664,  654,  667,  666,
+      649,  654,  650,  666,  792,  696,  667,  794,  794,  794,
+      647,  647,  696,  696,  647,  667,  666,  704,  697,  648,
+      648,  669,  703,  648,  664,  697,  697,  647,  647,  649,
+      649,  674,  669,  649,  704,  938,  648,  648,  669,  980,
+      672,  703,  672,  670,  977,  670,  649,  649,  655,  655,
+
+      655,  655,  698,  670,  672,  705,  655,  670,  703,  698,
+      698,  702,  702,  702,  702,  702,  702,  702,  702,  702,
+      706,  707,  705,  938,  705,  708,  709,  710,  711,  716,
+      711,  719,  714,  712,  714,  655,  655,  706,  707,  655,
+      707,  712,  708,  709,  710,  711,  716,  710,  719,  709,
+      712,  715,  655,  655,  678,  715,  740,  975,  740,  819,
+      870,  819,  870,  876,  736,  876,  720,  714,  715,  714,
+      720,  678,  678,  678,  678,  678,  678,  678,  678,  678,
+      679,  736,  714,  720,  714,  915,  740,  915,  972,  956,
+      731,  732,  731,  733,  738,  732,  819,  679,  679,  679,
+
+      679,  679,  679,  679,  679,  679,  680,  731,  732,  819,
+      733,  738,  871,  733,  955,  954,  734,  735,  742,  748,
+      749,  735,  734,  680,  680,  680,  680,  680,  680,  680,
+      680,  680,  681,  734,  735,  742,  748,  749,  765,  805,
+      765,  935,  965,  935,  965,  871,  805,  805,  765,  681,
+      681,  681,  681,  681,  681,  681,  681,  681,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  688,  688,  806,  688, 1007,  953, 1007,  688,  688,
+      806,  806,  688,  952,  951,  688,  688,  688,  688,  688,
+      688,  688,  688,  701,  701,  949,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+
+      701,  701,  701,  701,  701,  701,  737,  739,  744,  743,
+      737,  743,  745,  746,  750, 1111,  751,  746,  739,  743,
+      745,  753,  744,  737,  739,  744,  752,  946,  747,  745,
+      746,  750,  747,  751,  751,  754,  755,  752,  753,  756,
+      757,  758,  757,  752,  743,  747,  759,  760,  761, 1111,
+      762,  764,  754,  755,  762,  767,  756,  763,  758,  758,
+      768,  743,  766,  759,  760,  761,  760,  762,  764,  763,
+      766,  769,  767, 1068,  763,  757,  770,  768,  770,  766,
+      771,  772,  773,  810,  773,  773,  786,  934,  769,  814,
+      757,  786,  757,  774,  945,  774,  774,  771,  772,  771,
+
+      810,  774,  775,  786,  775,  775,  814,  788,  787,  788,
+      809,  770,  865,  770,  865,  812,  816,  812,  811,  773,
+      773,  787,  811,  773,  934,  787, 1068,  821,  770,  809,
+      774,  774,  812,  816,  774,  811,  773,  773,  817,  775,
+      775,  813,  788,  775,  821,  813,  809,  774,  774,  865,
+      933, 1036,  817, 1036,  932,  817,  775,  775,  813,  788,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  796,  808,  808,  808,  808,  808,  808,
+      808,  808,  808,  815,  822,  820,  825,  815,  834,  835,
+      796,  796,  796,  796,  796,  796,  796,  796,  796,  820,
+      815,  822,  820,  825,  836,  834,  835,  834,  837,  838,
+      839,  838,  840,  841,  842,  836,  929,  841,  842,  927,
+      922,  836,  843,  846,  839,  837,  838,  839,  845,  840,
+      841,  842,  844,  843,  844,  845,  846,  847,  845,  843,
+      846,  848,  844,  849,  850,  851,  853,  851,  854,  852,
+
+      854,  855,  856,  857,  847,  858,  847,  852,  848,  858,
+      849,  850,  851,  853,  857,  859,  852,  860,  855,  856,
+      857,  856,  858,  861,  864,  862,  866,  862,  877,  867,
+      874,  879,  859,  875,  860,  862,  884,  867,  883,  883,
+      861,  864,  886,  866,  904,  864,  867,  874,  854,  887,
+      875,  875,  885,  884,  888,  883,  885,  889,  894,  886,
+      893,  877,  894,  896,  879,  880,  887,  896, 1020,  885,
+      889,  888,  893,  888,  889,  894,  906,  893,  908,  902,
+      896,  906,  880,  880,  880,  880,  880,  880,  880,  880,
+      880,  905,  907,  906,  909,  908,  907,  910,  911,  905,
+
+      914,  913, 1043,  912, 1081, 1020,  918,  914,  905,  907,
+      914,  909,  916,  909,  910,  911,  912,  910,  913,  916,
+      912,  917,  916,  918,  919,  920,  923,  924,  917,  920,
+      921,  917,  921,  925,  926,  928,  930,  939,  937,  928,
+      923,  919,  920,  923,  924,  931,  936,  921,  940, 1043,
+      925,  926,  928,  930,  930,  937,  941, 1081,  931,  940,
+      942,  944,  931,  936,  943,  940,  936,  947,  943,  948,
+      950,  948,  901,  941,  939,  958,  939,  942,  944,  959,
+      960,  943,  947,  961,  947,  962,  948,  950,  963,  958,
+      988,  964,  958,  964,  966,  961,  959,  960,  970,  987,
+
+      961,  966,  962,  900,  966,  963,  968,  963,  964,  967,
+      967,  967,  969,  968,  971,  970,  968,  967,  974,  969,
+      967,  973,  969,  973,  976,  978,  979,  990,  985,  978,
+      979,  971,  988, 1004,  899,  974,  989,  987,  973,  985,
+      989,  976,  978,  979,  990,  985,  993,  994, 1002, 1003,
+     1004, 1003, 1005,  989, 1006,  994, 1016,  993, 1006, 1013,
+     1005, 1002,  898,  993,  994, 1002, 1003, 1014, 1019, 1005,
+      897, 1006, 1008, 1008, 1008, 1010, 1013, 1023, 1026, 1010,
+     1008, 1027, 1026, 1008, 1014, 1019, 1032, 1019, 1034, 1016,
+     1035, 1046, 1010, 1033, 1023, 1026, 1047, 1033, 1027, 1027,
+
+     1057, 1034, 1065, 1032, 1052, 1034, 1039, 1035, 1046, 1039,
+     1033, 1037, 1037, 1037, 1058, 1067, 1053, 1057, 1058, 1037,
+     1062, 1052, 1037, 1039, 1053,  895, 1059, 1052, 1059, 1047,
+     1071, 1058, 1072, 1053, 1060, 1060, 1060, 1062, 1075, 1083,
+     1062, 1079, 1060, 1103, 1089, 1060, 1072, 1071, 1087, 1072,
+     1065, 1089, 1067, 1109, 1089, 1075, 1076, 1076, 1079, 1076,
+     1094, 1087,  892, 1076, 1076, 1087, 1095, 1076, 1107, 1110,
+     1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1077, 1077,
+     1077, 1092, 1104, 1108, 1113, 1092, 1077, 1083, 1114, 1077,
+     1090, 1109, 1112, 1094, 1090, 1090, 1103, 1090, 1092, 1095,
+
+     1090, 1090, 1090, 1097, 1101, 1090, 1116, 1118, 1090, 1090,
+     1090, 1090, 1090, 1090, 1090, 1090, 1098, 1099, 1119, 1107,
+     1097, 1101, 1110, 1098, 1099, 1112, 1098, 1099, 1120, 1104,
+     1145, 1108, 1145, 1146, 1147, 1146, 1147, 1113, 1149,  891,
+     1149, 1114, 1150,  882, 1150, 1118, 1151, 1157, 1151, 1157,
+      878, 1158, 1119, 1158,  873,  872,  869, 1116,  868,  863,
+      833,  832,  831,  830,  829,  828,  827,  826,  824,  818,
+      804,  802,  798,  793,  791,  790,  783,  782,  781,  778,
+      777, 1120, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124,
+     1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1125,
+
+     1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
+     1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126,  776, 1126,
+     1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126,
+     1126, 1126, 1126, 1127, 1127,  730, 1127, 1127, 1127, 1127,
+     1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
+     1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128,
+     1128, 1128, 1128, 1128, 1128, 1128, 1128, 1129, 1129, 1129,
+     1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
+     1129, 1129, 1129, 1129, 1130, 1130,  729,  728,  727,  726,
+     1130, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
+
+     1131, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132,
+     1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1133,  725,
+     1133,  724, 1133, 1133,  722,  718,  717,  713, 1133, 1134,
+     1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134,
+     1134, 1134, 1134, 1134, 1134, 1134, 1135, 1135, 1135, 1135,
+     1135, 1135, 1135, 1135, 1135, 1135,  695, 1135, 1135, 1135,
+     1135,  694, 1135, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
+     1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
+     1137,  692,  691, 1137, 1137, 1138, 1138, 1138, 1138,  685,
+     1138, 1138,  683, 1138, 1138,  675, 1138, 1138,  662,  660,
+
+     1138, 1138, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139,
+     1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1140,
+      653, 1140,  651,  636, 1140, 1141,  589, 1141,  588, 1141,
+     1141, 1142, 1142,  586, 1142, 1142, 1142, 1142, 1142, 1142,
+     1142, 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1143, 1143,
+     1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143,
+     1143, 1143, 1143, 1143, 1143, 1144, 1144, 1144, 1144, 1144,
+     1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144,
+     1144, 1144, 1148,  585,  583, 1148, 1148, 1154,  582, 1154,
+      575,  556,  551,  549, 1154,  546,  543,  530,  524,  523,
+
+      515,  514, 1154, 1155,  513, 1155,  512,  511, 1155, 1156,
+      510, 1156,  454, 1156, 1156, 1159,  429, 1159,  409,  400,
+     1159, 1160,  398, 1160,  397, 1160, 1160, 1161, 1161,  391,
+     1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
+     1161, 1161, 1161, 1161, 1162, 1162,  389, 1162, 1162, 1162,
+     1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162,
+     1162, 1163, 1163,  375, 1163, 1163, 1163, 1163, 1163, 1163,
+     1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1164, 1164,
+     1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164,
+     1164, 1164, 1164, 1164, 1164, 1165, 1165, 1165, 1165, 1165,
+
+     1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165,
+     1165, 1165, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166,
+     1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1167,
+      374, 1167,  372, 1167, 1167, 1168, 1168,  371, 1168, 1168,
+     1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
+     1168, 1168, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169,
+     1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1170,
+     1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170,
+     1170, 1170, 1170, 1170, 1170, 1170, 1171, 1171,  365, 1171,
+     1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
+
+     1171, 1171, 1171, 1172, 1172,  358, 1172, 1172, 1172, 1172,
+     1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172,
+     1173, 1173,  353, 1173, 1173, 1173, 1173, 1173, 1173, 1173,
+     1173, 1173, 1173, 1173, 1173, 1173, 1173, 1174, 1174, 1174,
+     1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174,
+     1174, 1174, 1174, 1174, 1175, 1175, 1175, 1175, 1175, 1175,
+     1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175,
+     1175, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176,
+     1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1177, 1177,
+     1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
+
+     1177, 1177, 1177, 1177, 1177, 1178, 1178, 1178, 1178, 1178,
+     1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178,
+     1178, 1178, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
+     1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,  345,
+      344,  334,  333,  332,  331,  330,  329,  328,  326,  262,
+      244,  243,  237,  236,  235,  233,  232,  231,  230,  228,
+      213,  212,  210,  209,  204,  198,  195,  192,  178,  173,
+      171,  170,  167,  101,  100,   96,   95,   82,   81,   77,
+       76,   75,   69,   68,   63,   58,   13,    7, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "fortran.lex"
+#define INITIAL 0
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#define parameter 1
+
+#define character 2
+
+#define donottreat 3
+
+#define fortran77style 4
+
+#define fortran90style 5
+
+#line 41 "fortran.lex"
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+extern FILE * yyin;
+#define MAX_INCLUDE_DEPTH 30
+#define tabsize 6
+YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+int line_num_fortran=1;
+int line_num_fortran_common=1;
+int newlinef90 = 0;
+char *tmp;
+char tmpc;
+/******************************************************************************/
+/**************PETITS PB NON PREVUS *******************************************/
+/******************************************************************************/
+/* NEXTLINF77 un ligne fortran 77 peut commencer par -      &a=b or on        */
+/*            a prevu seulement       & a=b avec l'espace entre le symbole    */
+/*            de la 7eme et le debut de la ligne de commande                  */
+/*            le ! est aussi interdit comme symbole de la 7 eme colonne       */
+/*            Normalement NEXTLINEF77 \n+[ ]{5}[^ ]                           */
+/******************************************************************************/
+#define YY_USER_ACTION \
+        {\
+           if (firstpass == 0) \
+           {\
+              strcat(curbuf,yytext); \
+              Save_Length(curbuf,38); \
+              strcpy(motparse,yytext);\
+              Save_Length(motparse,32); \
+              colnum = colnum + strlen(motparse);\
+              ECHO; \
+           }\
+           strcpy(motparse1,yytext);\
+           /*printf("yytext = %s\n",yytext);*/\
+        /*if ( firstpass == 1 ) 
+                      printf("yytext = %s %d\n",yytext,strlen(yytext));*/\
+        }
+#line 1783 "fortran.yy.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( yy_current_buffer->yy_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( yyin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+		  && ferror( yyin ) ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	if ( yyleng > 0 ) \
+		yy_current_buffer->yy_at_bol = \
+				(yytext[yyleng - 1] == '\n'); \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+
+#line 106 "fortran.lex"
+
+  if (infixed) BEGIN(fortran77style) ;
+  if (infree) BEGIN(fortran90style)  ;
+
+#line 1942 "fortran.yy.c"
+
+	if ( yy_init )
+		{
+		yy_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! yy_start )
+			yy_start = 1;	/* first start state */
+
+		if ( ! yyin )
+			yyin = stdin;
+
+		if ( ! yyout )
+			yyout = stdout;
+
+		if ( ! yy_current_buffer )
+			yy_current_buffer =
+				yy_create_buffer( yyin, YY_BUF_SIZE );
+
+		yy_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yy_c_buf_p;
+
+		/* Support of yytext. */
+		*yy_cp = yy_hold_char;
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+		yy_current_state = yy_start;
+		yy_current_state += YY_AT_BOL();
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				yy_last_accepting_state = yy_current_state;
+				yy_last_accepting_cpos = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 1124 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 4189 );
+
+yy_find_action:
+		yy_act = yy_accept[yy_current_state];
+		if ( yy_act == 0 )
+			{ /* have to back up */
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			yy_act = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = yy_hold_char;
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 110 "fortran.lex"
+return TOK_DEBUT;
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 111 "fortran.lex"
+return TOK_FIN;
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 112 "fortran.lex"
+return TOK_OMP;
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 113 "fortran.lex"
+return TOK_DOLLAR;
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 115 "fortran.lex"
+{return TOK_REAL8;}
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 116 "fortran.lex"
+{return TOK_SUBROUTINE;}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 117 "fortran.lex"
+{return TOK_PROGRAM;}
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 118 "fortran.lex"
+{inallocate = 1; return TOK_ALLOCATE;}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 119 "fortran.lex"
+{inallocate = 1; return TOK_DEALLOCATE;}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 120 "fortran.lex"
+{return TOK_RESULT;}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 121 "fortran.lex"
+{return TOK_FUNCTION;}
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 122 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDSUBROUTINE;}
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 123 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDPROGRAM;}
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 124 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDFUNCTION;}
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 125 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDUNIT;}
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 126 "fortran.lex"
+return TOK_INCLUDE;
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 127 "fortran.lex"
+{
+                            strcpy(yylval.na,yytext);
+                            tmpc = input();
+                            unput(tmpc);
+                            if ( (
+                               tmpc >= 'a' && tmpc <= 'z'
+                                  ) || (
+                               tmpc >= 'A' && tmpc <= 'Z'
+                               )  )
+                               {
+                                  return TOK_USE;
+                               }
+                               else
+                               {
+                                  return TOK_NAME;
+                               }
+                         }
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 144 "fortran.lex"
+{return TOK_REWIND;}
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 145 "fortran.lex"
+return TOK_IMPLICIT;
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 146 "fortran.lex"
+return TOK_NONE;
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 147 "fortran.lex"
+return TOK_CALL;
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 148 "fortran.lex"
+return TOK_TRUE;
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 149 "fortran.lex"
+return TOK_FALSE;
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 150 "fortran.lex"
+{return TOK_POINT_TO;}
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 151 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DASTER;}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 152 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_EQV;}
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 153 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_EQ;}
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 154 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_GT;}
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 155 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_GE;}
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 156 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LT;}
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 157 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LE;}
+	YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 158 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NEQV;}
+	YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 159 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NE;}
+	YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 160 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NOT;}
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 161 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_OR;}
+	YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 162 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_XOR;}
+	YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 163 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_AND;}
+	YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 164 "fortran.lex"
+{return TOK_MODULE;}
+	YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 165 "fortran.lex"
+{return TOK_DOWHILE;}
+	YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 166 "fortran.lex"
+return TOK_ENDMODULE;
+	YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 167 "fortran.lex"
+return TOK_ENDDO;
+	YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 168 "fortran.lex"
+{return TOK_PLAINDO;}
+	YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 169 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_REAL;}
+	YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 170 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_INTEGER;}
+	YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 171 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LOGICAL;}
+	YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 172 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHARACTER;}
+	YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 173 "fortran.lex"
+{return TOK_ALLOCATABLE;}
+	YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 174 "fortran.lex"
+return TOK_CLOSE;
+	YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 175 "fortran.lex"
+return TOK_INQUIRE;
+	YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 176 "fortran.lex"
+{return TOK_DIMENSION;}
+	YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 177 "fortran.lex"
+return TOK_PAUSE;
+	YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 178 "fortran.lex"
+return TOK_EQUIVALENCE;
+	YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 179 "fortran.lex"
+return TOK_STOP;
+	YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 180 "fortran.lex"
+return TOK_WHERE;
+	YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 181 "fortran.lex"
+return TOK_ENDWHERE;
+	YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 182 "fortran.lex"
+return TOK_ELSEWHERE;
+	YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 183 "fortran.lex"
+{return TOK_COMPLEX;}
+	YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 184 "fortran.lex"
+{return TOK_CONTAINS;}
+	YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 185 "fortran.lex"
+{return TOK_ONLY;}
+	YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 186 "fortran.lex"
+{return TOK_PARAMETER;}
+	YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 187 "fortran.lex"
+{return TOK_RECURSIVE;}
+	YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 188 "fortran.lex"
+{return TOK_COMMON;}
+	YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 189 "fortran.lex"
+{return TOK_GLOBAL;}
+	YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 190 "fortran.lex"
+{return TOK_EXTERNAL;}
+	YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 191 "fortran.lex"
+{return TOK_INTENT;}
+	YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 192 "fortran.lex"
+{return TOK_POINTER;}
+	YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 193 "fortran.lex"
+{return TOK_OPTIONAL;}
+	YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 194 "fortran.lex"
+{return TOK_SAVE;}
+	YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 195 "fortran.lex"
+{return TOK_TYPE;}
+	YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 196 "fortran.lex"
+{return TOK_TYPEPAR;}
+	YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 197 "fortran.lex"
+{if (inallocate == 1) return TOK_STAT; else {strcpy(yylval.na,yytext);return TOK_NAME;}}
+	YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 198 "fortran.lex"
+{return TOK_ENDTYPE;}
+	YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 199 "fortran.lex"
+return TOK_OPEN;
+	YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 200 "fortran.lex"
+return TOK_RETURN;
+	YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 201 "fortran.lex"
+return TOK_EXIT;
+	YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 202 "fortran.lex"
+return TOK_PRINT;
+	YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 203 "fortran.lex"
+{return TOK_PROCEDURE;}
+	YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 204 "fortran.lex"
+{return TOK_READ;}
+	YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 205 "fortran.lex"
+{return TOK_NAMELIST;}
+	YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 206 "fortran.lex"
+{return TOK_WRITE;}
+	YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 207 "fortran.lex"
+{return TOK_TARGET;}
+	YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 208 "fortran.lex"
+{return TOK_PUBLIC;}
+	YY_BREAK
+case 83:
+YY_RULE_SETUP
+#line 209 "fortran.lex"
+{return TOK_PRIVATE;}
+	YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 210 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_IN;}
+	YY_BREAK
+case 85:
+YY_RULE_SETUP
+#line 211 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DATA;}
+	YY_BREAK
+case 86:
+YY_RULE_SETUP
+#line 212 "fortran.lex"
+return TOK_CONTINUE;
+	YY_BREAK
+case 87:
+YY_RULE_SETUP
+#line 213 "fortran.lex"
+{return TOK_PLAINGOTO;}
+	YY_BREAK
+case 88:
+YY_RULE_SETUP
+#line 214 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_OUT;}
+	YY_BREAK
+case 89:
+YY_RULE_SETUP
+#line 215 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_INOUT;}
+	YY_BREAK
+case 90:
+YY_RULE_SETUP
+#line 216 "fortran.lex"
+{return TOK_INTRINSIC;}
+	YY_BREAK
+case 91:
+YY_RULE_SETUP
+#line 217 "fortran.lex"
+{return TOK_THEN;}
+	YY_BREAK
+case 92:
+YY_RULE_SETUP
+#line 218 "fortran.lex"
+{return TOK_ELSEIF;}
+	YY_BREAK
+case 93:
+YY_RULE_SETUP
+#line 219 "fortran.lex"
+{return TOK_ELSE;}
+	YY_BREAK
+case 94:
+YY_RULE_SETUP
+#line 220 "fortran.lex"
+{return TOK_ENDIF;}
+	YY_BREAK
+case 95:
+YY_RULE_SETUP
+#line 221 "fortran.lex"
+{return TOK_LOGICALIF;}
+	YY_BREAK
+case 96:
+YY_RULE_SETUP
+#line 222 "fortran.lex"
+{return TOK_SUM;}
+	YY_BREAK
+case 97:
+YY_RULE_SETUP
+#line 223 "fortran.lex"
+{return TOK_MAX;}
+	YY_BREAK
+case 98:
+YY_RULE_SETUP
+#line 224 "fortran.lex"
+{return TOK_TANH;}
+	YY_BREAK
+case 99:
+YY_RULE_SETUP
+#line 225 "fortran.lex"
+{return TOK_MAXVAL;}
+	YY_BREAK
+case 100:
+YY_RULE_SETUP
+#line 226 "fortran.lex"
+{return TOK_TRIM;}
+	YY_BREAK
+case 101:
+YY_RULE_SETUP
+#line 227 "fortran.lex"
+{return TOK_SQRT;}
+	YY_BREAK
+case 102:
+YY_RULE_SETUP
+#line 228 "fortran.lex"
+{return TOK_SELECTCASE;}
+	YY_BREAK
+case 103:
+YY_RULE_SETUP
+#line 229 "fortran.lex"
+{return TOK_CASE;}
+	YY_BREAK
+case 104:
+YY_RULE_SETUP
+#line 230 "fortran.lex"
+{return TOK_CASEDEFAULT;}
+	YY_BREAK
+case 105:
+YY_RULE_SETUP
+#line 231 "fortran.lex"
+{return TOK_ENDSELECT;}
+	YY_BREAK
+case 106:
+YY_RULE_SETUP
+#line 232 "fortran.lex"
+{return TOK_FILE;}
+	YY_BREAK
+case 107:
+YY_RULE_SETUP
+#line 233 "fortran.lex"
+{return TOK_END;}
+	YY_BREAK
+case 108:
+YY_RULE_SETUP
+#line 234 "fortran.lex"
+{return TOK_ERR;}
+	YY_BREAK
+case 109:
+YY_RULE_SETUP
+#line 235 "fortran.lex"
+{return TOK_EXIST;}
+	YY_BREAK
+case 110:
+YY_RULE_SETUP
+#line 236 "fortran.lex"
+{return TOK_MIN;}
+	YY_BREAK
+case 111:
+YY_RULE_SETUP
+#line 237 "fortran.lex"
+{return TOK_NINT;}
+	YY_BREAK
+case 112:
+YY_RULE_SETUP
+#line 238 "fortran.lex"
+{return TOK_FLOAT;}
+	YY_BREAK
+case 113:
+YY_RULE_SETUP
+#line 239 "fortran.lex"
+{return TOK_EXP;}
+	YY_BREAK
+case 114:
+YY_RULE_SETUP
+#line 240 "fortran.lex"
+{return TOK_COS;}
+	YY_BREAK
+case 115:
+YY_RULE_SETUP
+#line 241 "fortran.lex"
+{return TOK_COSH;}
+	YY_BREAK
+case 116:
+YY_RULE_SETUP
+#line 242 "fortran.lex"
+{return TOK_ACOS;}
+	YY_BREAK
+case 117:
+YY_RULE_SETUP
+#line 243 "fortran.lex"
+{return TOK_SIN;}
+	YY_BREAK
+case 118:
+YY_RULE_SETUP
+#line 244 "fortran.lex"
+{return TOK_SINH;}
+	YY_BREAK
+case 119:
+YY_RULE_SETUP
+#line 245 "fortran.lex"
+{return TOK_ASIN;}
+	YY_BREAK
+case 120:
+YY_RULE_SETUP
+#line 246 "fortran.lex"
+{return TOK_LOG;}
+	YY_BREAK
+case 121:
+YY_RULE_SETUP
+#line 247 "fortran.lex"
+{return TOK_TAN;}
+	YY_BREAK
+case 122:
+YY_RULE_SETUP
+#line 248 "fortran.lex"
+{return TOK_ATAN;}
+	YY_BREAK
+case 123:
+YY_RULE_SETUP
+#line 249 "fortran.lex"
+{return TOK_CYCLE;}
+	YY_BREAK
+case 124:
+YY_RULE_SETUP
+#line 250 "fortran.lex"
+{return TOK_ABS;}
+	YY_BREAK
+case 125:
+YY_RULE_SETUP
+#line 251 "fortran.lex"
+{return TOK_MOD;}
+	YY_BREAK
+case 126:
+YY_RULE_SETUP
+#line 252 "fortran.lex"
+{return TOK_SIGN;}
+	YY_BREAK
+case 127:
+YY_RULE_SETUP
+#line 253 "fortran.lex"
+{return TOK_MINLOC;}
+	YY_BREAK
+case 128:
+YY_RULE_SETUP
+#line 254 "fortran.lex"
+{return TOK_MAXLOC;}
+	YY_BREAK
+case 129:
+YY_RULE_SETUP
+#line 255 "fortran.lex"
+{return TOK_MINVAL;}
+	YY_BREAK
+case 130:
+YY_RULE_SETUP
+#line 256 "fortran.lex"
+{return TOK_INTERFACE;}
+	YY_BREAK
+case 131:
+YY_RULE_SETUP
+#line 257 "fortran.lex"
+{return TOK_BACKSPACE;}
+	YY_BREAK
+case 132:
+YY_RULE_SETUP
+#line 258 "fortran.lex"
+{return TOK_ENDINTERFACE;}
+	YY_BREAK
+case 133:
+YY_RULE_SETUP
+#line 259 "fortran.lex"
+{return TOK_LEFTAB;}
+	YY_BREAK
+case 134:
+YY_RULE_SETUP
+#line 260 "fortran.lex"
+{return TOK_RIGHTAB;}
+	YY_BREAK
+case 135:
+YY_RULE_SETUP
+#line 261 "fortran.lex"
+{return TOK_FORMAT;}
+	YY_BREAK
+case 136:
+YY_RULE_SETUP
+#line 262 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;}
+	YY_BREAK
+case 137:
+YY_RULE_SETUP
+#line 263 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;}
+	YY_BREAK
+case 138:
+YY_RULE_SETUP
+#line 264 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_SLASH;}
+	YY_BREAK
+case 139:
+YY_RULE_SETUP
+#line 265 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DSLASH;}
+	YY_BREAK
+case 140:
+YY_RULE_SETUP
+#line 266 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_CUT;}
+	YY_BREAK
+case 141:
+YY_RULE_SETUP
+#line 267 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_CONSTANT;}
+	YY_BREAK
+case 142:
+YY_RULE_SETUP
+#line 268 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_MESSAGE;}
+	YY_BREAK
+case 143:
+YY_RULE_SETUP
+#line 269 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_INT;}
+	YY_BREAK
+case 144:
+YY_RULE_SETUP
+#line 270 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NAME;}
+	YY_BREAK
+case 145:
+YY_RULE_SETUP
+#line 271 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+	YY_BREAK
+case 146:
+YY_RULE_SETUP
+#line 272 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREALDP;}
+	YY_BREAK
+case 147:
+YY_RULE_SETUP
+#line 273 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREALQP;}
+	YY_BREAK
+case 148:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 274 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+	YY_BREAK
+case 149:
+YY_RULE_SETUP
+#line 275 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTINT;}
+	YY_BREAK
+case 150:
+YY_RULE_SETUP
+#line 276 "fortran.lex"
+{}
+	YY_BREAK
+case 151:
+YY_RULE_SETUP
+#line 277 "fortran.lex"
+{return TOK_QUOTE;}
+	YY_BREAK
+case 152:
+YY_RULE_SETUP
+#line 278 "fortran.lex"
+{}
+	YY_BREAK
+case 153:
+YY_RULE_SETUP
+#line 279 "fortran.lex"
+{strcpy(yylval.na,yytext);return (int) *yytext;}
+	YY_BREAK
+case 154:
+YY_RULE_SETUP
+#line 280 "fortran.lex"
+{return TOK_SEMICOLON;}
+	YY_BREAK
+case 155:
+YY_RULE_SETUP
+#line 281 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 156:
+YY_RULE_SETUP
+#line 282 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 157:
+YY_RULE_SETUP
+#line 283 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 158:
+YY_RULE_SETUP
+#line 284 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 159:
+YY_RULE_SETUP
+#line 285 "fortran.lex"
+{colnum=0;line_num_fortran++;line_num_fortran_common++; return (int) *yytext;}
+	YY_BREAK
+case 160:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 286 "fortran.lex"
+
+	YY_BREAK
+case 161:
+YY_RULE_SETUP
+#line 287 "fortran.lex"
+{if (newlinef90 == 0) return TOK_LABEL; else newlinef90 = 0;}
+	YY_BREAK
+case 162:
+YY_RULE_SETUP
+#line 288 "fortran.lex"
+
+	YY_BREAK
+case 163:
+YY_RULE_SETUP
+#line 289 "fortran.lex"
+{colnum=colnum-1+tabsize;}
+	YY_BREAK
+case 164:
+YY_RULE_SETUP
+#line 290 "fortran.lex"
+;
+	YY_BREAK
+case 165:
+YY_RULE_SETUP
+#line 291 "fortran.lex"
+{line_num_fortran++;line_num_fortran_common++;newlinef90=1;colnum=0;}
+	YY_BREAK
+case 166:
+YY_RULE_SETUP
+#line 292 "fortran.lex"
+{line_num_fortran++;line_num_fortran_common++;colnum=0;}
+	YY_BREAK
+case 167:
+YY_RULE_SETUP
+#line 293 "fortran.lex"
+{
+                           convert2lower(motparse1);
+                           if ( strncasecmp(motparse1,"contains",8) == 0 )
+                           {
+                              return TOK_CONTAINS;
+                           }
+                           else
+                           {
+                              colnum=0;line_num_fortran++;line_num_fortran_common++;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                           }
+                         }
+	YY_BREAK
+case 168:
+YY_RULE_SETUP
+#line 306 "fortran.lex"
+BEGIN(donottreat);
+	YY_BREAK
+case 169:
+YY_RULE_SETUP
+#line 307 "fortran.lex"
+BEGIN(INITIAL);
+	YY_BREAK
+case 170:
+YY_RULE_SETUP
+#line 308 "fortran.lex"
+
+	YY_BREAK
+case 171:
+YY_RULE_SETUP
+#line 309 "fortran.lex"
+{
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+	YY_BREAK
+case 172:
+YY_RULE_SETUP
+#line 314 "fortran.lex"
+{
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+	YY_BREAK
+case 173:
+YY_RULE_SETUP
+#line 319 "fortran.lex"
+ECHO;
+	YY_BREAK
+#line 2933 "fortran.yy.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(parameter):
+case YY_STATE_EOF(character):
+case YY_STATE_EOF(donottreat):
+case YY_STATE_EOF(fortran77style):
+case YY_STATE_EOF(fortran90style):
+	yyterminate();
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = yy_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed yyin at a new source and called
+			 * yylex().  If so, then we have to assure
+			 * consistency between yy_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			yy_n_chars = yy_current_buffer->yy_n_chars;
+			yy_current_buffer->yy_input_file = yyin;
+			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++yy_c_buf_p;
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+				yy_cp = yy_c_buf_p;
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				yy_did_buffer_switch_on_eof = 0;
+
+				if ( yywrap() )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * yytext, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				yy_c_buf_p =
+					yytext_ptr + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				yy_c_buf_p =
+				&yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+	{
+	register char *dest = yy_current_buffer->yy_ch_buf;
+	register char *source = yytext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( yy_current_buffer->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = yy_current_buffer;
+
+			int yy_c_buf_p_offset =
+				(int) (yy_c_buf_p - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					yy_flex_realloc( (void *) b->yy_ch_buf,
+							 b->yy_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = yy_current_buffer->yy_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+			yy_n_chars, num_to_read );
+
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	if ( yy_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			yyrestart( yyin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			yy_current_buffer->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	yy_n_chars += number_to_move;
+	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+
+	yy_current_state = yy_start;
+	yy_current_state += YY_AT_BOL();
+
+	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+		{
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		if ( yy_accept[yy_current_state] )
+			{
+			yy_last_accepting_state = yy_current_state;
+			yy_last_accepting_cpos = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 1124 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
+
+	return yy_current_state;
+	}
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+	{
+	register int yy_is_jam;
+	register char *yy_cp = yy_c_buf_p;
+
+	register YY_CHAR yy_c = 1;
+	if ( yy_accept[yy_current_state] )
+		{
+		yy_last_accepting_state = yy_current_state;
+		yy_last_accepting_cpos = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 1124 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 1123);
+
+	return yy_is_jam ? 0 : yy_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+	{
+	register char *yy_cp = yy_c_buf_p;
+
+	/* undo effects of setting up yytext */
+	*yy_cp = yy_hold_char;
+
+	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = yy_n_chars + 2;
+		register char *dest = &yy_current_buffer->yy_ch_buf[
+					yy_current_buffer->yy_buf_size + 2];
+		register char *source =
+				&yy_current_buffer->yy_ch_buf[number_to_move];
+
+		while ( source > yy_current_buffer->yy_ch_buf )
+			*--dest = *--source;
+
+		yy_cp += (int) (dest - source);
+		yy_bp += (int) (dest - source);
+		yy_current_buffer->yy_n_chars =
+			yy_n_chars = yy_current_buffer->yy_buf_size;
+
+		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--yy_cp = (char) c;
+
+
+	yytext_ptr = yy_bp;
+	yy_hold_char = *yy_cp;
+	yy_c_buf_p = yy_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*yy_c_buf_p = yy_hold_char;
+
+	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			/* This was really a NUL. */
+			*yy_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = yy_c_buf_p - yytext_ptr;
+			++yy_c_buf_p;
+
+			switch ( yy_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					yyrestart( yyin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( yywrap() )
+						return EOF;
+
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					yy_c_buf_p = yytext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
+	*yy_c_buf_p = '\0';	/* preserve yytext */
+	yy_hold_char = *++yy_c_buf_p;
+
+	yy_current_buffer->yy_at_bol = (c == '\n');
+
+	return c;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! yy_current_buffer )
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+	yy_init_buffer( yy_current_buffer, input_file );
+	yy_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( yy_current_buffer == new_buffer )
+		return;
+
+	if ( yy_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*yy_c_buf_p = yy_hold_char;
+		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	yy_current_buffer = new_buffer;
+	yy_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (yywrap()) processing, but the only time this flag
+	 * is looked at is after yywrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	yy_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+	{
+	yy_n_chars = yy_current_buffer->yy_n_chars;
+	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+	yyin = yy_current_buffer->yy_input_file;
+	yy_hold_char = *yy_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	yy_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == yy_current_buffer )
+		yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		yy_flex_free( (void *) b->yy_ch_buf );
+
+	yy_flex_free( (void *) b );
+	}
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	yy_flush_buffer( b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->yy_is_interactive = 0;
+#else
+	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == yy_current_buffer )
+		yy_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	yy_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+	{
+	int len;
+	for ( len = 0; yy_str[len]; ++len )
+		;
+
+	return yy_scan_bytes( yy_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) yy_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = yy_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( yy_start_stack_ptr >= yy_start_stack_depth )
+		{
+		yy_size_t new_size;
+
+		yy_start_stack_depth += YY_START_STACK_INCR;
+		new_size = yy_start_stack_depth * sizeof( int );
+
+		if ( ! yy_start_stack )
+			yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+		else
+			yy_start_stack = (int *) yy_flex_realloc(
+					(void *) yy_start_stack, new_size );
+
+		if ( ! yy_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+	{
+	if ( --yy_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(yy_start_stack[yy_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+	{
+	return yy_start_stack[yy_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		yytext[yyleng] = yy_hold_char; \
+		yy_c_buf_p = yytext + n; \
+		yy_hold_char = *yy_c_buf_p; \
+		*yy_c_buf_p = '\0'; \
+		yyleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	yylex();
+	return 0;
+	}
+#endif
+#line 319 "fortran.lex"
+
+
+fortranerror(char *s)
+{
+   if (!strcasecmp(curfile,mainfile))
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran,curfile);
+   }
+   else
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran_common,curfile);
+   }
+   /*exit(0);*/
+}
+
+int fortranwrap()
+{
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.lex
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.lex	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.lex	(revision 1844)
@@ -0,0 +1,336 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+%x parameter
+%s character
+%x donottreat
+%s fortran77style
+%s fortran90style
+%{
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+extern FILE * yyin;
+#define MAX_INCLUDE_DEPTH 30
+#define tabsize 6
+YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+int line_num_fortran=1;
+int line_num_fortran_common=1;
+int newlinef90 = 0;
+char *tmp;
+char tmpc;
+/******************************************************************************/
+/**************PETITS PB NON PREVUS *******************************************/
+/******************************************************************************/
+/* NEXTLINF77 un ligne fortran 77 peut commencer par -      &a=b or on        */
+/*            a prevu seulement       & a=b avec l'espace entre le symbole    */
+/*            de la 7eme et le debut de la ligne de commande                  */
+/*            le ! est aussi interdit comme symbole de la 7 eme colonne       */
+/*            Normalement NEXTLINEF77 \n+[ ]{5}[^ ]                           */
+/******************************************************************************/
+#define YY_USER_ACTION \
+        {\
+           if (firstpass == 0) \
+           {\
+              strcat(curbuf,yytext); \
+              Save_Length(curbuf,38); \
+              strcpy(motparse,yytext);\
+              Save_Length(motparse,32); \
+              colnum = colnum + strlen(motparse);\
+              ECHO; \
+           }\
+           strcpy(motparse1,yytext);\
+           /*printf("yytext = %s\n",yytext);*/\
+        /*if ( firstpass == 1 ) 
+                      printf("yytext = %s %d\n",yytext,strlen(yytext));*/\
+        }
+%}
+AGRIFDEB "Agrif_debut"
+AGRIFFIN "Agrif_fin"
+REAL8 "real*8"[ \t]*"(a-h,o-z)"
+NOTTREAT Agrif_do_not_treat
+ENDNOTTREAT Agrif_end_do_not_treat
+
+NIMPORTEQUOI .
+SLASH "/"
+DSLASH "/"[ \t]*"/"
+NAME [a-zA-Z\_][a-zA-Z0-9\_]*
+DIGIT [0-9]+
+INT {DIGIT}
+EXPONENT e[-+]?{DIGIT}
+DEXPONENT d[-+]?{DIGIT}
+QEXPONENT q[-+]?{DIGIT}
+REAL (({DIGIT}\.[0-9]+|[0-9]*\.{DIGIT}){EXPONENT}?)|{DIGIT}\.{EXPONENT}
+REALDP (({DIGIT}\.[0-9]+|[0-9]*\.{DIGIT}){DEXPONENT}?)|{DIGIT}\.{DEXPONENT}
+REALQP (({DIGIT}\.[0-9]+|[0-9]*\.{DIGIT}){QEXPONENT}?)|{DIGIT}\.{QEXPONENT}
+ENDFUNCTION end[ \t]*function
+DOUBLEPRECISION double[ \t]*precision
+DOUBLECOMPLEX double[ \t]*complex
+
+COMMENTAIRESFORTRAN77 ^([Cc*](([ \t]*\n)|([^AaHhOo\n]{NIMPORTEQUOI}*\n)))
+COMMENTAIRESFORTRAN90 ^([ \t]*!{NIMPORTEQUOI}*\n)
+COMMENTAIRESFORTRAN90_2 (!{NIMPORTEQUOI}*)
+NEXTLINEF90 "&"{NIMPORTEQUOI}*[\n]*
+NEXTLINEF77 \n[ \t]{5}("&"|"+"|"$"|"*"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"."|"#")
+%%
+  if (infixed) BEGIN(fortran77style) ;
+  if (infree) BEGIN(fortran90style)  ;
+
+^C${AGRIFDEB}            return TOK_DEBUT;
+^C${AGRIFFIN}            return TOK_FIN;
+^C$OMP[ \t]*{NIMPORTEQUOI}* return TOK_OMP;
+^C$[ \t]*{NIMPORTEQUOI}* return TOK_DOLLAR;
+
+{REAL8}                 {return TOK_REAL8;}
+subroutine              {return TOK_SUBROUTINE;}
+program                 {return TOK_PROGRAM;}
+allocate                {inallocate = 1; return TOK_ALLOCATE;}
+deallocate              {inallocate = 1; return TOK_DEALLOCATE;}
+result                  {return TOK_RESULT;}
+function                {return TOK_FUNCTION;}
+end[ \t]*subroutine     {strcpy(yylval.na,yytext);return TOK_ENDSUBROUTINE;}
+end[ \t]*program        {strcpy(yylval.na,yytext);return TOK_ENDPROGRAM;}
+end[ \t]*function       {strcpy(yylval.na,yytext);return TOK_ENDFUNCTION;}
+end                     {strcpy(yylval.na,yytext);return TOK_ENDUNIT;}
+include                  return TOK_INCLUDE;
+^[ \t]*use[ ]+           {
+                            strcpy(yylval.na,yytext);
+                            tmpc = input();
+                            unput(tmpc);
+                            if ( (
+                               tmpc >= 'a' && tmpc <= 'z'
+                                  ) || (
+                               tmpc >= 'A' && tmpc <= 'Z'
+                               )  )
+                               {
+                                  return TOK_USE;
+                               }
+                               else
+                               {
+                                  return TOK_NAME;
+                               }
+                         }
+rewind                  {return TOK_REWIND;}
+implicit                 return TOK_IMPLICIT;
+none                     return TOK_NONE;
+call                     return TOK_CALL;
+.true.                   return TOK_TRUE;
+.false.                  return TOK_FALSE;
+\=\>                    {return TOK_POINT_TO;}
+\*\*                    {strcpy(yylval.na,yytext);return TOK_DASTER;}
+\.[ \t]*eqv\.            {strcpy(yylval.na,yytext);return TOK_EQV;}
+\.[ \t]*eq\.            {strcpy(yylval.na,yytext);return TOK_EQ;}
+\.[ \t]*gt\.            {strcpy(yylval.na,yytext);return TOK_GT;}
+\.[ \t]*ge\.            {strcpy(yylval.na,yytext);return TOK_GE;}
+\.[ \t]*lt\.            {strcpy(yylval.na,yytext);return TOK_LT;}
+\.[ \t]*le\.            {strcpy(yylval.na,yytext);return TOK_LE;}
+\.[ \t]*neqv\.          {strcpy(yylval.na,yytext);return TOK_NEQV;}
+\.[ \t]*ne\.            {strcpy(yylval.na,yytext);return TOK_NE;}
+\.[ \t]*not\.           {strcpy(yylval.na,yytext);return TOK_NOT;}
+\.[ \t]*or\.            {strcpy(yylval.na,yytext);return TOK_OR;}
+\.[ \t]*xor\.           {strcpy(yylval.na,yytext);return TOK_XOR;}
+\.[ \t]*and\.           {strcpy(yylval.na,yytext);return TOK_AND;}
+module                  {return TOK_MODULE;}
+do[ 0-9\t]*while           {return TOK_DOWHILE;}
+end[ \t]*module          return TOK_ENDMODULE;
+end[ \t]*do              return TOK_ENDDO;
+do                      {return TOK_PLAINDO;}
+real                    {strcpy(yylval.na,yytext);return TOK_REAL;}
+integer                 {strcpy(yylval.na,yytext);return TOK_INTEGER;}
+logical                 {strcpy(yylval.na,yytext);return TOK_LOGICAL;}
+character               {strcpy(yylval.na,yytext);return TOK_CHARACTER;}
+allocatable             {return TOK_ALLOCATABLE;}
+close                    return TOK_CLOSE;
+inquire                  return TOK_INQUIRE;
+dimension               {return TOK_DIMENSION;}
+pause                    return TOK_PAUSE;
+equivalence              return TOK_EQUIVALENCE;
+stop                     return TOK_STOP;
+where                    return TOK_WHERE;
+end[ \t]*where           return TOK_ENDWHERE;
+else[ \t]*where          return TOK_ELSEWHERE;
+complex                 {return TOK_COMPLEX;}
+^[ \t]*contains         {return TOK_CONTAINS;}
+only                    {return TOK_ONLY;}
+parameter               {return TOK_PARAMETER;}
+recursive               {return TOK_RECURSIVE;}
+common                  {return TOK_COMMON;}
+^[ \t]*global[ \t]+     {return TOK_GLOBAL;}
+external                {return TOK_EXTERNAL;}
+intent                  {return TOK_INTENT;}
+pointer                 {return TOK_POINTER;}
+optional                {return TOK_OPTIONAL;}
+save                    {return TOK_SAVE;}
+^[ \t]*type[ \t\,]+       {return TOK_TYPE;}
+^[ \t]*type[ \t]*\(     {return TOK_TYPEPAR;}
+stat                    {if (inallocate == 1) return TOK_STAT; else {strcpy(yylval.na,yytext);return TOK_NAME;}}
+end[ \t]*type           {return TOK_ENDTYPE;}
+open                     return TOK_OPEN;
+return                   return TOK_RETURN;
+exit[^(]                 return TOK_EXIT;
+print                    return TOK_PRINT;
+module[ \t]*procedure   {return TOK_PROCEDURE;}
+read                    {return TOK_READ;}
+namelist                {return TOK_NAMELIST;}
+write                   {return TOK_WRITE;}
+target                  {return TOK_TARGET;}
+public                  {return TOK_PUBLIC;}
+private                 {return TOK_PRIVATE;}
+in                      {strcpy(yylval.nac,yytext);return TOK_IN;}
+^[ \t]*data[ \t]+       {strcpy(yylval.na,yytext);return TOK_DATA;}
+continue                 return TOK_CONTINUE;
+go[ \t]*to              {return TOK_PLAINGOTO;}
+out                     {strcpy(yylval.nac,yytext);return TOK_OUT;}
+inout                   {strcpy(yylval.nac,yytext);return TOK_INOUT;}
+intrinsic               {return TOK_INTRINSIC;}
+then                    {return TOK_THEN;}
+else[ \t]*if            {return TOK_ELSEIF;}
+else                    {return TOK_ELSE;}
+end[ \t]*if             {return TOK_ENDIF;}
+if[ \t]*\(              {return TOK_LOGICALIF;}
+sum[ \t]*\(             {return TOK_SUM;}
+max[ \t]*\(             {return TOK_MAX;}
+tanh                    {return TOK_TANH;}
+maxval                  {return TOK_MAXVAL;}
+trim                    {return TOK_TRIM;}
+sqrt\(                  {return TOK_SQRT;}
+select[ \t]*case        {return TOK_SELECTCASE;}
+^[ \t]*case[ \t]*\(     {return TOK_CASE;}
+^[ \t]*case[ \t]*default       {return TOK_CASEDEFAULT;}
+end[ \t]*select         {return TOK_ENDSELECT;}
+file[ \t]*\=            {return TOK_FILE;}
+end[ \t]*\=             {return TOK_END;}
+err[ \t]*\=             {return TOK_ERR;}
+exist[ \t]*\=           {return TOK_EXIST;}
+min[ \t]*\(             {return TOK_MIN;}
+nint                    {return TOK_NINT;}
+float                   {return TOK_FLOAT;}
+exp                     {return TOK_EXP;}
+cos                     {return TOK_COS;}
+cosh                    {return TOK_COSH;}
+acos                    {return TOK_ACOS;}
+sin                     {return TOK_SIN;}
+sinh                    {return TOK_SINH;}
+asin                    {return TOK_ASIN;}
+log                     {return TOK_LOG;}
+tan                     {return TOK_TAN;}
+atan                    {return TOK_ATAN;}
+cycle                   {return TOK_CYCLE;}
+abs\(                   {return TOK_ABS;}
+mod                     {return TOK_MOD;}
+sign                    {return TOK_SIGN;}
+minloc                  {return TOK_MINLOC;}
+maxloc                  {return TOK_MAXLOC;}
+minval                  {return TOK_MINVAL;}
+interface               {return TOK_INTERFACE;}
+backspace               {return TOK_BACKSPACE;}
+end[ \t]*interface      {return TOK_ENDINTERFACE;}
+\({SLASH}               {return TOK_LEFTAB;}
+{SLASH}\)               {return TOK_RIGHTAB;}
+format[ \t]*\(({NIMPORTEQUOI}|{NEXTLINEF90}|{NEXTLINEF77})*\)  {return TOK_FORMAT;}
+{DOUBLEPRECISION}       {strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;}
+{DOUBLECOMPLEX}         {strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;}
+{SLASH}                 {strcpy(yylval.na,yytext);return TOK_SLASH;}
+DSLASH                  {strcpy(yylval.na,yytext);return TOK_DSLASH;}
+(\')[^']*&{0,1}\n[ \t]*&{0,1}[^']*(\')         {strcpy(yylval.na,yytext);return TOK_CHAR_CUT;}
+(\')[^\n']*(\')         {strcpy(yylval.na,yytext);return TOK_CHAR_CONSTANT;}
+(\")[^\n"]*(\")         {strcpy(yylval.na,yytext);return TOK_CHAR_MESSAGE;}
+({NAME}{REAL})          {strcpy(yylval.na,yytext);return TOK_CHAR_INT;}
+{NAME}                  {strcpy(yylval.na,yytext);return TOK_NAME;}
+{REAL}                  {strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+{REALDP}                {strcpy(yylval.na,yytext);return TOK_CSTREALDP;}
+{REALQP}                {strcpy(yylval.na,yytext);return TOK_CSTREALQP;}
+({DIGIT}\.)/[^{NAME}|"and."|"false."|"true."|"eq."|"or."|"gt."|"ge."|"lt."|"le."|"not."|"ne."] {strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+{INT}                   {strcpy(yylval.na,yytext);return TOK_CSTINT;}
+\$ {}
+\'|\"                   {return TOK_QUOTE;}
+\.                      {}
+\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;}
+\;                      {return TOK_SEMICOLON;}
+\,                      {return (int) *yytext;}
+\=                      {return (int) *yytext;}
+\<                      {return (int) *yytext;}
+\>                      {return (int) *yytext;}
+\n                      {colnum=0;line_num_fortran++;line_num_fortran_common++; return (int) *yytext;}
+^[ ]*$
+^(((" "|[0-9]){1,5})|([ \t]{1,5}))[ &]+ {if (newlinef90 == 0) return TOK_LABEL; else newlinef90 = 0;}
+[ ]+
+[\t]+                   {colnum=colnum-1+tabsize;}
+[ \t]+ ;
+{NEXTLINEF90}           {line_num_fortran++;line_num_fortran_common++;newlinef90=1;colnum=0;}
+{NEXTLINEF77}           {line_num_fortran++;line_num_fortran_common++;colnum=0;}
+<fortran77style>{COMMENTAIRESFORTRAN77} {
+                           convert2lower(motparse1);
+                           if ( strncasecmp(motparse1,"contains",8) == 0 )
+                           {
+                              return TOK_CONTAINS;
+                           }
+                           else
+                           {
+                              colnum=0;line_num_fortran++;line_num_fortran_common++;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                           }
+                         }
+^"!$AGRIF_DO_NOT_TREAT\n" BEGIN(donottreat);
+<donottreat>^"!$AGRIF_END_DO_NOT_TREAT\n" BEGIN(INITIAL);
+<donottreat>.*\n
+{COMMENTAIRESFORTRAN90}   {
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+{COMMENTAIRESFORTRAN90_2} {
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+%%
+
+fortranerror(char *s)
+{
+   if (!strcasecmp(curfile,mainfile))
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran,curfile);
+   }
+   else
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran_common,curfile);
+   }
+   /*exit(0);*/
+}
+
+int fortranwrap()
+{
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.tab.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.tab.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.tab.c	(revision 1844)
@@ -0,0 +1,9613 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
+#endif
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define yyclearin (yychar=(-1))
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING (yyerrflag!=0)
+#define yyparse fortranparse
+#define yylex fortranlex
+#define yyerror fortranerror
+#define yychar fortranchar
+#define yyval fortranval
+#define yylval fortranlval
+#define yydebug fortrandebug
+#define yynerrs fortrannerrs
+#define yyerrflag fortranerrflag
+#define yyss fortranss
+#define yyssp fortranssp
+#define yyvs fortranvs
+#define yyvsp fortranvsp
+#define yylhs fortranlhs
+#define yylen fortranlen
+#define yydefred fortrandefred
+#define yydgoto fortrandgoto
+#define yysindex fortransindex
+#define yyrindex fortranrindex
+#define yygindex fortrangindex
+#define yytable fortrantable
+#define yycheck fortrancheck
+#define yyname fortranname
+#define yyrule fortranrule
+#define YYPREFIX "fortran"
+#line 36 "fortran.y"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+extern int line_num_fortran;
+extern int line_num_fortran_common;
+char *tmp;
+char c_selectorname[LONG_C];
+char ligne[LONG_C];
+char truename[LONGNOM];
+char identcopy[LONG_C];
+int c_selectorgiven=0;
+int incom;
+listvar *curlistvar;
+typedim c_selectordim;
+listcouple *coupletmp;
+listdim *parcoursdim;
+int removeline=0;
+listvar *test;
+#line 57 "fortran.y"
+typedef union {
+       char      nac[LONG_C];
+       char      na[LONGNOM];
+       listdim  *d;
+       listvar  *l;
+       listnom  *ln;
+       listcouple  *lc;
+       listname *lnn;
+       typedim   dim1;
+       variable *v;
+       } YYSTYPE;
+#line 68 "y.tab.c"
+#define TOK_BINARY_OP 257
+#define TOK_EQV 258
+#define TOK_NEQV 259
+#define TOK_OR 260
+#define TOK_XOR 261
+#define TOK_AND 262
+#define TOK_NOT 263
+#define TOK_LT 264
+#define TOK_GT 265
+#define TOK_LE 266
+#define TOK_GE 267
+#define TOK_EQ 268
+#define TOK_NE 269
+#define TOK_UNARY_OP 270
+#define TOK_DSLASH 271
+#define TOK_SLASH 272
+#define TOK_DASTER 273
+#define TOK_SEP 274
+#define TOK_SEMICOLON 275
+#define TOK_NEXTLINE 276
+#define TOK_PARAMETER 277
+#define TOK_RESULT 278
+#define TOK_ONLY 279
+#define TOK_INCLUDE 280
+#define TOK_SUBROUTINE 281
+#define TOK_PROGRAM 282
+#define TOK_FUNCTION 283
+#define TOK_OMP 284
+#define TOK_DOLLAR 285
+#define TOK_FORMAT 286
+#define TOK_MAX 287
+#define TOK_TANH 288
+#define TOK_WHERE 289
+#define TOK_ELSEWHERE 290
+#define TOK_ENDWHERE 291
+#define TOK_MAXVAL 292
+#define TOK_TRIM 293
+#define TOK_SUM 294
+#define TOK_SQRT 295
+#define TOK_CASE 296
+#define TOK_SELECTCASE 297
+#define TOK_FILE 298
+#define TOK_END 299
+#define TOK_ERR 300
+#define TOK_DONOTTREAT 301
+#define TOK_ENDDONOTTREAT 302
+#define TOK_EXIST 303
+#define TOK_MIN 304
+#define TOK_FLOAT 305
+#define TOK_EXP 306
+#define TOK_COS 307
+#define TOK_COSH 308
+#define TOK_ACOS 309
+#define TOK_NINT 310
+#define TOK_CYCLE 311
+#define TOK_SIN 312
+#define TOK_SINH 313
+#define TOK_ASIN 314
+#define TOK_EQUIVALENCE 315
+#define TOK_BACKSPACE 316
+#define TOK_LOG 317
+#define TOK_TAN 318
+#define TOK_ATAN 319
+#define TOK_RECURSIVE 320
+#define TOK_ABS 321
+#define TOK_MOD 322
+#define TOK_SIGN 323
+#define TOK_MINLOC 324
+#define TOK_MAXLOC 325
+#define TOK_EXIT 326
+#define TOK_MINVAL 327
+#define TOK_PUBLIC 328
+#define TOK_PRIVATE 329
+#define TOK_ALLOCATABLE 330
+#define TOK_RETURN 331
+#define TOK_THEN 332
+#define TOK_ELSEIF 333
+#define TOK_ELSE 334
+#define TOK_ENDIF 335
+#define TOK_PRINT 336
+#define TOK_PLAINGOTO 337
+#define TOK_CONSTRUCTID 338
+#define TOK_LOGICALIF 339
+#define TOK_PLAINDO 340
+#define TOK_CONTAINS 341
+#define TOK_ENDDO 342
+#define TOK_MODULE 343
+#define TOK_ENDMODULE 344
+#define TOK_DOWHILE 345
+#define TOK_ALLOCATE 346
+#define TOK_OPEN 347
+#define TOK_CLOSE 348
+#define TOK_INQUIRE 349
+#define TOK_WRITE 350
+#define TOK_READ 351
+#define TOK_REWIND 352
+#define TOK_DEALLOCATE 353
+#define TOK_NULLIFY 354
+#define TOK_FIN 355
+#define TOK_DEBUT 356
+#define TOK_DIMENSION 357
+#define TOK_ENDSELECT 358
+#define TOK_EXTERNAL 359
+#define TOK_INTENT 360
+#define TOK_INTRINSIC 361
+#define TOK_NAMELIST 362
+#define TOK_CASEDEFAULT 363
+#define TOK_OPTIONAL 364
+#define TOK_POINTER 365
+#define TOK_CONTINUE 366
+#define TOK_SAVE 367
+#define TOK_TARGET 368
+#define TOK_QUOTE 369
+#define TOK_IMPLICIT 370
+#define TOK_NONE 371
+#define TOK_CALL 372
+#define TOK_STAT 373
+#define TOK_POINT_TO 374
+#define TOK_COMMON 375
+#define TOK_GLOBAL 376
+#define TOK_INTERFACE 377
+#define TOK_ENDINTERFACE 378
+#define TOK_LEFTAB 379
+#define TOK_RIGHTAB 380
+#define TOK_PAUSE 381
+#define TOK_PROCEDURE 382
+#define TOK_STOP 383
+#define TOK_NAMEEQ 384
+#define TOK_REAL8 385
+#define TOK_OUT 386
+#define TOK_INOUT 387
+#define TOK_IN 388
+#define TOK_USE 389
+#define TOK_TRUE 390
+#define TOK_FALSE 391
+#define TOK_LABEL 392
+#define TOK_TYPE 393
+#define TOK_TYPEPAR 394
+#define TOK_ENDTYPE 395
+#define TOK_REAL 396
+#define TOK_INTEGER 397
+#define TOK_LOGICAL 398
+#define TOK_DOUBLEPRECISION 399
+#define TOK_DOUBLEREAL 400
+#define TOK_ENDSUBROUTINE 401
+#define TOK_ENDFUNCTION 402
+#define TOK_ENDPROGRAM 403
+#define TOK_ENDUNIT 404
+#define TOK_CHARACTER 405
+#define TOK_CHAR_CONSTANT 406
+#define TOK_CHAR_CUT 407
+#define TOK_DATA 408
+#define TOK_CHAR_INT 409
+#define TOK_CHAR_MESSAGE 410
+#define TOK_CSTREAL 411
+#define TOK_CSTREALDP 412
+#define TOK_CSTREALQP 413
+#define TOK_SFREAL 414
+#define TOK_COMPLEX 415
+#define TOK_DOUBLECOMPLEX 416
+#define TOK_NAME 417
+#define TOK_NAME_CHAR 418
+#define TOK_PROBTYPE 419
+#define TOK_INTERPTYPE 420
+#define TOK_VARTYPE 421
+#define TOK_BC 422
+#define TOK_OP 423
+#define TOK_CSTINT 424
+#define TOK_COMMENT 425
+#define TOK_FILENAME 426
+#define YYERRCODE 256
+short fortranlhs[] = {                                        -1,
+    0,    0,   68,   68,   68,   68,   68,   71,   71,   76,
+   76,   76,   76,   76,   82,   78,   72,   72,   72,   72,
+   69,   70,   70,   73,   73,   83,   75,   84,   84,   77,
+   77,   77,   77,   77,   77,   16,   74,   80,   33,    6,
+    6,    6,   85,   85,   85,    5,    5,   38,   38,   79,
+   79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+   79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+   86,   86,  103,  103,  103,  103,  103,  103,  103,  103,
+  103,  103,  103,  103,  103,  103,  103,  103,  103,  103,
+  103,  103,  103,  103,  103,  103,   98,   98,   88,   88,
+   99,   99,  105,  106,  106,  104,  104,   87,   87,    2,
+    2,  108,   89,  100,  101,  101,  101,   58,   58,   91,
+   91,   91,   91,  111,  112,  112,  110,  110,  110,   47,
+   47,   47,   47,   47,   32,   32,   97,  113,  113,  113,
+  113,  114,   96,   96,  115,    3,    3,   93,   93,   67,
+   67,   66,   66,   90,   90,   90,  117,  117,  118,  118,
+  119,   15,   15,  109,  109,    4,    4,   14,   95,  120,
+  120,   92,   92,  121,    1,    1,  107,   19,   19,   19,
+   19,  127,  126,  126,  126,  126,  128,  128,  128,  125,
+   25,   24,   24,   24,   24,   24,   24,  116,  116,   65,
+   65,  124,  124,  124,  130,  130,   34,   34,   34,   34,
+   37,   37,  129,  129,  122,  122,  122,  131,  131,  132,
+  132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
+   30,   30,   30,  102,  102,   11,   11,   12,   12,   13,
+   13,   13,   13,   13,   63,   63,   62,   62,   62,   62,
+   61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
+   61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
+   61,   61,   61,   61,   61,   61,   40,   40,   39,   39,
+   39,   39,   39,   39,   31,   31,   64,   64,   64,   64,
+   64,   64,   64,   64,   64,   64,   64,   64,   64,   64,
+   64,   64,   64,   64,   64,   64,   64,   59,   59,   59,
+   59,   60,   60,   41,   41,   41,  133,   49,   49,   49,
+   49,   36,   48,   42,   50,   50,   52,   52,   51,   51,
+   53,   53,   53,   53,   53,   53,   53,   28,   27,   27,
+   27,   27,   27,   27,   27,   27,   26,   26,   26,   26,
+   55,   55,   54,   57,   57,   56,   56,  123,  123,  134,
+   35,   94,   94,   94,   94,  135,   17,    9,    9,   10,
+    7,    7,    8,    8,   81,   81,   81,   81,   81,   81,
+   81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
+   81,   81,   81,   81,   81,   81,   81,   20,   23,   22,
+   21,  143,  143,  143,  141,  141,  141,  146,  146,  146,
+  145,  145,   18,   18,  148,  148,  144,  147,  149,  149,
+  136,  136,  136,  136,  136,  136,  136,  136,  136,  136,
+  136,  136,  157,  150,  150,  156,  156,  151,  151,  154,
+  159,  159,  160,  160,  158,  162,  161,  161,  163,  163,
+  155,  155,  153,  153,  153,  153,  153,  153,  171,  171,
+  172,  172,  172,  173,  173,  174,  174,  168,  168,  178,
+  178,  177,  177,  166,  166,  170,  170,  170,  170,  170,
+  179,  179,  181,  181,  181,  181,  181,  181,  181,  181,
+  165,  165,  176,  176,  167,  167,  167,  169,  180,  180,
+  182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
+  182,  182,  182,  183,  183,  175,  175,  185,  185,  184,
+  184,  184,  184,  184,  186,  186,  186,   43,   43,   43,
+   44,   44,   44,   44,   44,   44,   44,   44,   45,   45,
+   45,   45,   45,   46,   46,  187,  187,  164,  152,  152,
+  137,  137,  137,  188,  188,  188,  189,  190,  190,  139,
+  139,  138,  138,  140,  140,  191,  191,  192,  192,  142,
+   29,
+};
+short fortranlen[] = {                                         2,
+    0,    2,    2,    2,    1,    3,    3,    1,    3,    2,
+    2,    3,    3,    2,    2,    2,    1,    1,    1,    1,
+    0,    0,    2,    0,    1,    0,    0,    0,    1,    0,
+    4,    2,    5,    3,    2,    1,    0,    1,    1,    0,
+    2,    3,    0,    2,    3,    1,    3,    1,    1,    2,
+    4,    2,    2,    4,    2,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    4,    3,    3,    2,    3,
+    0,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    3,    3,    5,
+    1,    3,    3,    2,    4,    1,    3,    0,    2,    2,
+    3,    1,    1,    1,    4,    6,    4,    1,    3,    2,
+    3,    5,    3,    1,    0,    2,    1,    4,    3,    2,
+    3,    3,    3,    3,    0,    1,    2,    2,    3,    5,
+    3,    0,    2,    2,    1,    5,    5,    2,    3,    2,
+    3,    1,    3,    2,    3,    5,    1,    2,    1,    3,
+    2,    1,    3,    0,    1,    1,    3,    3,    2,    1,
+    3,    2,    2,    0,    6,    7,    0,    2,    2,    3,
+    3,    1,    0,    2,    4,    3,    3,    4,    2,    1,
+    1,    1,    1,    1,    1,    1,    1,    0,    2,    1,
+    3,    0,    2,    3,    1,    3,    2,    3,    1,    1,
+    1,    1,    0,    3,    0,    2,    4,    1,    3,    1,
+    1,    1,    2,    1,    4,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    0,    3,    1,    3,    1,
+    1,    2,    2,    3,    1,    1,    1,    3,    1,    1,
+    3,    3,    4,    4,    3,    4,    4,    3,    4,    4,
+    4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
+    4,    3,    4,    4,    4,    4,    1,    3,    1,    1,
+    1,    2,    2,    2,    1,    1,    2,    2,    2,    2,
+    2,    2,    2,    2,    2,    2,    2,    3,    2,    3,
+    2,    2,    2,    2,    2,    2,    2,    0,    1,    2,
+    2,    2,    1,    1,    1,    1,    0,    1,    2,    4,
+    5,    4,    3,    3,    1,    2,    1,    3,    1,    1,
+    3,    5,    4,    3,    2,    2,    1,    1,    1,    1,
+    1,    1,    1,    1,    2,    2,    1,    2,    1,    1,
+    0,    1,    5,    0,    1,    1,    1,    0,    3,    0,
+    5,    2,    4,    6,    6,    1,    1,    1,    3,    3,
+    1,    3,    3,    1,    1,    5,    5,    4,    1,    2,
+    2,    2,    2,    1,    2,    5,    1,    1,    2,    5,
+    1,    2,    3,    4,    1,    1,    1,    1,    1,    1,
+    1,    1,    3,    3,    3,    2,    2,    0,    5,    7,
+    0,    2,    1,    1,    0,    1,    1,    1,    0,    1,
+    1,    2,    1,    1,    1,    5,    5,    2,    2,    2,
+    2,    1,    0,    4,    6,    1,    3,    2,    2,    2,
+    0,    3,    0,    1,    2,    1,    1,    3,    1,    2,
+    1,    1,    2,    2,    2,    3,    2,    1,    0,    2,
+    1,    1,    1,    0,    2,    0,    1,    2,    2,    0,
+    1,    0,    2,    3,    3,    3,    3,    1,    3,    1,
+    1,    3,    1,    1,    1,    2,    4,    4,    2,    2,
+    1,    1,    1,    1,    1,    1,    1,    1,    1,    3,
+    1,    1,    3,    3,    3,    3,    2,    3,    2,    2,
+    2,    2,    3,    1,    1,    1,    3,    0,    1,    2,
+    4,    2,    2,    5,    0,    1,    2,    1,    1,    1,
+    3,    3,    3,    3,    3,    3,    1,    1,    1,    3,
+    5,    5,    5,    5,    7,    1,    3,    1,    8,    2,
+    1,    1,    3,    1,    1,    1,    4,    1,    3,    1,
+    3,    0,    4,    1,    3,    0,    1,    0,    2,    3,
+    1,
+};
+short fortrandefred[] = {                                      1,
+    0,   37,   19,   20,   17,   18,   27,    5,   21,    2,
+    0,    0,   27,   23,    3,  113,   38,    0,    0,  458,
+    0,  387,  388,    0,    0,    0,    0,    0,   29,    0,
+    0,    0,    0,    0,  391,    0,  497,    0,    0,  417,
+  397,    0,    0,    0,  418,    0,  491,  492,  496,  498,
+  495,    0,    0,    0,  145,  396,    0,    0,    0,  395,
+    0,  421,  124,    0,  446,  157,    0,    0,    0,  451,
+    0,  452,  366,    0,  182,    0,  193,  192,  197,  195,
+  398,  401,  400,  399,  190,  114,  194,  196,  338,  436,
+    0,    0,    0,    0,    0,  379,    0,    0,    0,   60,
+    0,    8,   21,   21,    0,    0,   21,    0,    0,    0,
+    0,   58,   61,   62,   63,   64,   65,    0,    0,    0,
+    0,    0,    0,    0,    0,  375,  384,    0,    0,    0,
+    0,  423,  424,  425,    0,    0,    0,    0,    0,    0,
+    0,   25,   37,    7,   36,   32,    0,    0,    0,  285,
+  286,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  339,  340,    0,
+  347,  350,  349,  342,  343,  344,  341,    0,    0,    0,
+    0,    0,  249,    0,  247,    0,  281,    0,  316,  250,
+    0,    0,    0,  356,  430,    0,    0,    0,  101,    0,
+  428,    0,    0,  150,    0,  148,    0,  429,    0,  414,
+  413,  392,  548,    0,  550,    0,  416,  407,   35,  383,
+    0,  480,  478,    0,  457,    0,    0,    0,    0,  162,
+    0,    0,  138,    0,    0,  172,  173,  158,  143,  144,
+  170,    0,  234,  235,    0,   72,   52,    0,    0,    0,
+  112,    0,   50,    0,  174,  381,  382,  380,    0,    0,
+    0,  178,   15,    0,    0,    0,   10,   11,   39,   21,
+   37,   14,    0,    0,    0,    0,  166,  165,    0,    0,
+    0,    0,    0,    0,    0,    0,  120,    0,    0,  137,
+    0,    0,    0,    0,  159,    0,    0,  179,    0,  210,
+    0,  367,    0,  389,    0,    0,  433,  385,    0,    0,
+    0,    0,    0,    0,  422,  431,    0,    0,  440,  445,
+    0,  453,  514,  515,  494,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  454,    0,    0,    0,    0,    0,
+    6,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  249,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  348,    0,  352,  346,  345,  317,    0,  319,
+    0,  317,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  282,    0,    0,  393,    0,    0,    0,    0,    0,
+  109,  152,    0,    0,    0,    0,  570,    0,    0,    0,
+    0,    0,  551,  556,    0,    0,    0,    0,    0,  560,
+  564,    0,    0,   74,   75,   78,   73,   79,   76,   81,
+   82,   83,   84,   85,   80,   86,   87,   88,   89,   90,
+   91,   92,   93,   94,   95,   77,   96,    0,   97,    0,
+  139,    0,    0,    0,    0,    0,    0,  220,  222,    0,
+  224,    0,  226,  227,  228,  229,  230,  221,    0,  218,
+  216,  174,  110,    0,    0,  180,    0,    0,  203,    0,
+    0,    0,    9,   16,   12,   13,    0,    0,    0,    0,
+    0,  123,    0,    0,    0,   70,    0,    0,    0,  126,
+  121,  141,    0,    0,  161,    0,    0,  184,    0,  212,
+    0,    0,    0,    0,    0,  207,  181,    0,    0,    0,
+  412,  571,    0,  405,    0,    0,  433,  437,    0,    0,
+    0,    0,  447,  484,  485,    0,    0,    0,    0,  481,
+  499,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  468,    0,  516,    0,    0,  469,    0,    0,    0,
+    0,    0,    0,  456,   49,   48,   41,    0,   46,    0,
+    0,    0,  252,    0,    0,    0,  251,  258,  255,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  272,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  324,    0,    0,    0,    0,  248,    0,    0,
+    0,    0,    0,    0,  307,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  306,    0,    0,    0,    0,    0,    0,    0,
+    0,  394,  104,    0,  103,  102,   66,    0,    0,    0,
+    0,    0,    0,  477,  476,  479,    0,    0,    0,  378,
+    0,  163,    0,   99,    0,  171,   51,    0,  223,    0,
+    0,    0,    0,  111,    0,    0,  204,    0,  245,    0,
+  238,    0,  240,  434,   31,    0,   54,  167,    0,    0,
+  136,    0,    0,    0,    0,    0,    0,  129,    0,    0,
+    0,  160,    0,    0,    0,    0,  189,  186,  208,    0,
+    0,    0,  368,    0,    0,    0,    0,  450,  442,    0,
+  489,  490,    0,    0,    0,    0,  474,  475,    0,    0,
+    0,  526,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   42,    0,   33,  386,    0,  253,  254,
+  257,  261,  262,  263,  264,  265,  260,  266,  267,  268,
+  269,  270,  271,  273,  274,  275,  276,  256,    0,    0,
+    0,  248,  532,    0,  536,    0,  534,    0,  259,    0,
+    0,  322,    0,  327,    0,  330,    0,    0,    0,    0,
+    0,    0,    0,    0,  153,  390,    0,    0,    0,  553,
+  376,  561,  377,  565,   98,    0,    0,    0,  147,  232,
+  233,  231,    0,  219,  217,    0,    0,  206,    0,    0,
+  237,    0,    0,  122,    0,    0,    0,    0,    0,    0,
+  115,  128,    0,  117,  140,  146,  185,    0,  187,    0,
+    0,    0,    0,    0,    0,    0,    0,  448,    0,    0,
+    0,  500,    0,  482,    0,    0,  527,  517,   47,   44,
+    0,    0,    0,    0,    0,  361,    0,    0,    0,    0,
+    0,  321,  105,    0,  557,    0,  100,    0,    0,  199,
+  225,    0,    0,  239,    0,  244,  119,    0,    0,    0,
+    0,    0,  188,  214,    0,  364,    0,  371,  370,  369,
+  426,  427,    0,  435,  488,    0,    0,    0,   45,    0,
+  541,  543,  542,  353,    0,    0,  328,    0,    0,  563,
+    0,    0,  175,    0,  116,    0,    0,    0,  524,    0,
+    0,    0,    0,  201,  176,    0,  373,  372,    0,    0,
+    0,    0,    0,    0,    0,    0,
+};
+short fortrandgoto[] = {                                       1,
+  262,  263,   91,  286,  598,  353,  927,  928,  742,  743,
+  512,  710,  711,  287,  242,  146,  313,  222,   92,   93,
+   94,   95,   96,   97,   98,  189,  190,  191,  553,  843,
+  192,  722,  280,  311,  193,  194,  542,  599,  195,  356,
+  196,  197,  385,  386,  387,  893,  723,  198,  199,  640,
+  814,  815,  816,  395,  396,  205,  211,  724,  663,  645,
+  200,  357,  713,  422,  910,  433,  100,   10,  276,   11,
+  101,   12,  143,   13,   14,  102,  103,  277,  104,  105,
+  106,  107,    0,  108,  776,  255,  215,  245,  109,  110,
+  111,  112,  113,  114,  115,  116,  117,  478,  208,  118,
+  293,  498,  479,  483,  209,  428,  503,  264,  289,  294,
+  119,  297,  120,  300,  121,  839,  122,  304,  305,  252,
+  505,  265,  953,  272,  123,  308,  124,  544,  737,  509,
+  499,  500,  641,  954,  125,  126,  441,  683,  449,  452,
+  127,  128,  202,  129,  320,  554,  130,  228,    0,  131,
+  325,  132,  133,  134,  135,  136,  274,  137,  329,  561,
+  562,  138,  563,  225,  139,  332,  140,  345,  141,  235,
+    0,    0,    0,  582,  583,  346,  587,    0,  568,  347,
+  570,  571,  349,  584,  585,  763,    0,  443,  444,    0,
+    0,    0,
+};
+short fortransindex[] = {                                      0,
+  121,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+27287, -307,    0,    0,    0,    0,    0, -289, -289,    0,
+  111,    0,    0,25188,  118, 1476,  147,  153,    0,25188,
+   91,  107, 1476,  163,    0,   27,    0,  -13,25188,    0,
+    0, -250, -178,   27,    0,  208,    0,    0,    0,    0,
+    0,  -14,  215,  229,    0,    0,  201,  201, -151,    0,
+  244,    0,    0, -237,    0,    0,  -89,   27,   27,    0,
+ -100,    0,    0, -101,    0,   27,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  284,   35,   27,   27,   27,    0,  290,  134,  280,    0,
+   79,    0,    0,    0,   -5, -307,    0,  138,   -9,  387,
+  388,    0,    0,    0,    0,    0,    0,   42, -117,  404,
+  387, -110,  225, -312,   43,    0,    0, 3999,   54,25188,
+   41,    0,    0,    0, 1476,  420,  425,   59,  437,25721,
+  437,    0,    0,    0,    0,    0,  444,25188,25188,    0,
+    0,25188,  446,  448,  450,25188,25188,25188,  455,  456,
+  466,  478,  480,  486,  487,  497,  503,  504,  509,  513,
+25188,  515,  524,  528,  532,  533,25241,    0,    0,  539,
+    0,    0,    0,    0,    0,    0,    0,25188,   18,  149,
+  542,25188,    0,  548,    0,  553,    0,  563,    0,    0,
+ 8597,  115,25188,    0,    0, 8597,  190,  570,    0,25188,
+    0, 8597,  558,    0,  222,    0,  222,    0,25188,    0,
+    0,    0,    0,25188,    0,25903,    0,    0,    0,    0,
+  190,    0,    0,25380,    0,  190,  190,  222, 3040,    0,
+  224,  190,    0,25188,  609,    0,    0,    0,    0,    0,
+    0,  610,    0,    0,  201,    0,    0,  255, 1930,  603,
+    0,  651,    0, -289,    0,    0,    0,    0,  283,25428,
+ -312,    0,    0,  665,27287, -307,    0,    0,    0,    0,
+    0,    0, -289,  648,  296,  675,    0,    0,   19,  308,
+   19,  -12,   86,  -11,  665,  308,    0,  190,   19,    0,
+  313,  665,  318,  692,    0,  -10, 3093,    0,24098,    0,
+  703,    0,  711,    0,  717,  732,    0,    0,  387,  190,
+ 8597,25188,25188,  190,    0,    0,  360, 4498,    0,    0,
+25685,    0,    0,    0,    0,25188,25188,25188,25188,  740,
+25685,  149,  553, 1423,    0,  764,  209,    0, 9398,25241,
+    0,    8,  535,25936, 3157,  236, 8597,25188,25188,25188,
+  281,26019,  461,25188,25188,25188,25188,25188,25188,25188,
+25188,25188,25188,25188,25188,26043,25188,25188,25188,25188,
+25188,25241,    0,  781,  451,  786,  789,    0, 8597,25188,
+  790,26094,    0,25188,    0,    0,    0,    0,   48,    0,
+  190,    0,24299,25188,25188,25188,25188,25188,25188,25188,
+25188,25188,25188,25188,25188,25188,25188, 2012,25188,24438,
+24486,    0,25188,25188,    0,26169,  665,  475,  147,26191,
+    0,    0,  791,  791,26213,27040,    0,  796,  553,  563,
+  793,  801,    0,    0,  798,  256,  799,  796,  797,    0,
+    0,  568,  791,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  800,    0,  571,
+    0, 8597,  577,  802,  428,   27,  665,    0,    0,  665,
+    0,  807,    0,    0,    0,    0,    0,    0,  119,    0,
+    0,    0,    0,  444,  436,    0,24627, 8597,    0,  819,
+ 2554,  665,    0,    0,    0,    0,  444,25188,  599,  296,
+  387,    0,  387,  233,25188,    0,  447,  449,  233,    0,
+    0,    0,  387,  665,    0,  692,  318,    0, 3093,    0,
+24251,  817, 8597,  824,24675,    0,    0, -225,  190,  190,
+    0,    0,  806,    0, 8597, 8597,    0,    0,  445, 8597,
+  827,  826,    0,    0,    0, 9456, 9398,  605,  100,    0,
+    0, 8597, 8597, 8597, 8597,25188,  333, 1423,  538,  553,
+ 8597,    0,  828,    0, 8597, 1423,    0, 9398, 9398, 9398,
+ 9398, 9398,  598,    0,    0,    0,    0,  614,    0,  833,
+ 1476,25188,    0,  618,  619,26276,    0,    0,    0,26327,
+26349,26446,26468,26509,26582,26604,26626,26701,26742,26764,
+26859,    0,  626,  634,  636,  638,  642,  831,  834,  835,
+26881,25241,    0,25241,25241,  644,25188,    0,  822,  840,
+24813,  553,  841,25188,    0, 8597, 2081, 2081, 2226, 2226,
+ 3157,   84,   84,   84,   84,   84,   84,   90,   90,   48,
+25188,25188,    0, 8597,   48,25188,   84,25188,   84, 8597,
+ 8597,    0,    0,  190,    0,    0,    0,  468,  551,25188,
+24813, -278,  845,    0,    0,    0, -278,  846,  190,    0,
+ 3040,    0,25188,    0,25188,    0,    0,  852,    0, -170,
+ 1930,  843,  485,    0,  665,  864,    0,25188,    0,  646,
+    0, 6917,    0,    0,    0, 8597,    0,    0,  318,  308,
+    0,  321,  550,  635,26934,  643,  870,    0,  645,  190,
+  852,    0,  878,24675,  817,  506,    0,    0,    0,  862,
+  547,  880,    0,  793,  797,25188,  665,    0,    0, 4498,
+    0,    0,24813,  631,  544,25685,    0,    0, 8597,    0,
+  656,    0, 8597, 8597, 1423, 8597,  828,  250,  598,  598,
+  598,   38,   -1,    0,   10,    0,    0, 8597,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,25563,25563,
+25563,    0,    0, 8597,    0, 8597,    0, 8597,    0,  885,
+25188,    0,24866,    0,  883,    0, 7337,  548,   84,   84,
+   48,   84,   84,  665,    0,    0,26997,  658,  867,    0,
+    0,    0,    0,    0,    0, 8597,  660,25616,    0,    0,
+    0,    0,  891,    0,    0,  665,  852,    0, 8597, 2554,
+    0,25005,  692,    0,  149,  233,  233,  233,  233,  233,
+    0,    0,  233,    0,    0,    0,    0,  817,    0,24675,
+   28,  516,  517,  894,  895,27113,  665,    0,  896,24169,
+  190,    0,  209,    0, 2501, 8597,    0,    0,    0,    0,
+  662,  879,  898,  900,  902,    0,  903,25188, 7757,24813,
+25188,    0,    0,  904,    0,  190,    0,25053, 8597,    0,
+    0,  852,    0,    0, 8597,    0,    0,  184,  184,  906,
+  491,  677,    0,    0,  573,    0,  917,    0,    0,    0,
+    0,    0,25188,    0,    0,  801,  909, 8597,    0,25188,
+    0,    0,    0,    0, 8597,25188,    0, 8177,25188,    0,
+  927,    0,    0,  911,    0,  557,  559,27166,    0,27187,
+ 8597,25188, 8597,    0,    0,25188,    0,    0,25188,25188,
+ 8597, 8597, 8597,27272,25188, 8597,
+};
+short fortranrindex[] = {                                      0,
+ 5433,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  223,23906,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,23602,
+  560,  560,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,22995,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  560, 3577,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   25,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+18370,  579,    0,    0,    0,    0,    4,  -15,   52,    0,
+23145,    0,    0,    0,    0,23906,    0,    0,    0, 5953,
+13515,    0,    0,    0,    0,    0,    0,    0,18586,13666,
+  580,    0,   11,    0,    0,    0,    0,    0,23298,    0,
+    0,    0,    0,    0,    0,18739,18890,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,16959,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0, 1107, 2724,
+ 1277,    0,    0, 1646,    0, 2894,    0, 1816,    0,    0,
+  125,    0,    0,    0,    0,19043,    0,19194,    0,    0,
+    0,13884,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,19347,    0,    0,    0,    0,    0,
+    0,19498,    0,    0,   29,    0,    0,    0,    0,    0,
+    0,19651,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   24,  223,23906,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,19802,    0,    0,    0,14035,
+    0,  954,  580,    0,  908,14035,    0,   30,    0,    0,
+    0,  908,    0,14191,    0,    0,    0,    0,  960,    0,
+    0,    0,19955,    0,    0,    0,    0,    0,20106,23449,
+20259,    0,    0,    0,    0,    0,    0,  987,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0, 9631,
+    0,10472,10208, 5640,    0,20410,    0,10627,    0,23753,
+    0,    0,20563,    0, 6171,    0,  673,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0, 4668,    0,17110,17263, 3263,    0,    0,
+25786,    0,    0,  972,    0,    0,    0,    0, 3433,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0, 5271,    0,    0,
+    0,    0,    0,    0,    0,    0,  674,    0,    0,    0,
+    0,    0,20714,20867,    0,    0,    0,  165,    0,  510,
+  995,  679,    0,    0, 6497,  869, 9017,  526,  995,    0,
+    0,    0,21018,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,21171,    0,    0,
+    0,  680,    0,    0,    0,    0,14404,    0,    0,  127,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,21322,    0,    0,    0,   40,    0,    0,
+    0,   24,    0,    0,    0,    0,21322,    0,    0,    0,
+  580,    0,14555,  356,    0,    0,    0,    0,  356,    0,
+    0,    0,  580,14404,    0,14711,    0,    0,    0,    0,
+ 5618, 1012,  708,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,21475,21626,    0,    0,    0,  709,
+    0, 1013,    0,    0,    0,   63,    0,    0, 1014,    0,
+    0,12251,12465,12620,12834,    0, 1014,25857,17479, 4299,
+14924,    0,21779,    0,14924, 5802,    0,    0,    0,    0,
+    0,    0,10891,    0,    0,    0,    0,    0,    0,21930,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,27019,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+ 1021, 2185,    0,    0,    0,11727, 9782,10051, 9111, 9262,
+ 6322, 6591, 6742, 7011, 7162, 7431, 7582, 4838, 5101, 3696,
+    0,    0,    0,11882, 3866,    0, 7851,    0, 8002,  164,
+  212,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+ 1025,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,17632,    0,    0,
+    0,    0,    0,    0,12989,    0,    0,  710,    0,    0,
+    0,  720,    0,    0,    0,15080,    0,    0,    0,14035,
+    0,    0,  795,    0,    0,    0,   16,    0,    0,    0,
+17632,    0,    0,    0, 1012,    0,    0,    0,    0,    0,
+    0,22083,    0,  995,  995,    0,   24,    0,    0,    0,
+    0,    0,    0,  729,    0,    0,    0,    0,13203,  698,
+    0,    0,15293,15449, 5802,15662,22234,13358,11046,11309,
+11464,12096,    0,    0,    0,    0,    0,  730,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,15818,    0,15974,    0,16130,    0,27293,
+ 1028,    0,  737,    0, 1030,    0,  738, 2355, 8271, 8422,
+ 4129, 8691, 8842,  674,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  742,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,12989,16286,    0,  744,    0,
+    0,  749,16437,    0,  467,  356,  356,  356,  356,  356,
+    0,    0,  356,    0,    0,    0,    0, 1012,    0,    0,
+    0,    0,    0,    0,    0,    0,   24,    0,    0,    0,
+    0,    0,  750,    0,25857,14924,    0,    0,    0,    0,
+    0,  590,    0,    0,    0,    0,    0,    0,  751,    0,
+  768,    0,    0,    0,    0,    0,    0,    0,17848,    0,
+    0,16286,16655,    0,  720,    0,    0,   93,  146,   31,
+   44,    0,    0,    0,18001,    0,22387,    0,    0,    0,
+    0,    0,    0,    0,    0,  777,    0,16806,    0,    0,
+    0,    0,    0,    0,  778,    0,    0,  779,    0,    0,
+    0,16655,    0,    0,    0,    0,    0,22538,    0,    0,
+  783,    0,22691,    0,    0,    0,    0,    0,    0,    0,
+  788,18217,22842, 1031,    0, 1036,
+};
+short fortrangindex[] = {                                      0,
+    0,    0,    0,  813,  303, -401,    0,  126,    0,  211,
+ -255,    0,  232,  565,  285,   -2,    0,  -23,    0,    0,
+    0,    0,    0,    0,    0,    0, -120,    7,    0,    0,
+ -328,    0,    0,  815, -135,    0, -305,  339, -152,  181,
+ -137,    0,  766,  736, -326, -686, -234, -220,    0,  718,
+  221,  438,  371, -189,    0,  -26, -371, -495,    0,    0,
+ -169,  -24,  273, -397,    0,  -98,    0,    0, 1117,    0,
+    0,    0,  -39,  -56, 1119,  865,    0,   53,    0,    0,
+    0,    0,    0,    0,    0,    0,   65,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0, 1065,  452,  458,  716,    0,    0,    0,  -30,  627,
+    0, -277,    0,    0,    0, -667,    0, -281,  620,    0,
+  654,    0,  194,    0,    0,    0,    0,  608, -649,    0,
+    0,  457,    0,    0,    0, 1032,  612, -392,  613,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0, -230,
+    0,    0,    0,    0,    0,    0,  602,    0,    0,    0,
+    0,    0,  412,  607,    0,  219,    0,    0,    0,    0,
+    0,    0,    0,    0, -408,    0,    0,    0,    0, -317,
+  414, 1033, -335, -688,    0, -522,    0, -226,    0,    0,
+    0,    0,
+};
+#define YYTABLESIZE 27711
+short fortrantable[] = {                                     201,
+  442,  206,  343,  546,  400,  212,  218,  388,  206,  450,
+  440,  592,  522,  569,  226,  440,  147,   99,  531,  342,
+  230,  536,  639,  577,  384,  234,  224,  525,  202,  539,
+  285,  593,  528,  729,   71,  391,  221,  926,  108,  530,
+  595,  383,  202,  191,  249,  250,  535,  191,  597,  595,
+  890,  595,  257,  740,  183,  630,  688,  394,  764,  127,
+  236,  191,  766,  866,  236,  243,  281,  236,  183,  266,
+  267,  268,  133,  133,  133,  133,  888,  324,  259,  589,
+  291,  447,   71,  205,  236,  869,  351,  134,  433,  299,
+  301,  433,  260,  439,  829,  526,  217,  205,  439,  338,
+  214,  322,  704,  338,  309,  321,  338,  420,  326,  421,
+  206,  310,  433,  894,  895,  715,  216,  142,  434,  240,
+  241,  238,  239,  354,  355,  417,  415,  145,  416,  288,
+    9,  417,  362,  246,  317,  131,  131,  131,   89,  453,
+  758,  589,  333,  420,  334,  421,  376,  247,  213,  420,
+  148,  421,  389,  240,  241,  425,  278,  203,  423,  282,
+  240,  241,  701,  392,  213,  402,  227,  399,  402,  761,
+  236,  673,  424,  271,  581,  270,  702,  767,  426,  913,
+  388,  762,  402,  762,  236,  430,  207,  762,  132,  132,
+  132,  741,  210,  343,  435,  721,  888,  384,  937,  436,
+  721,  314,  219,  343,  403,  433,  580,  403,  433,  389,
+  342,  343,  388,  427,  383,  840,  841,  842,  923,  482,
+  342,  403,   30,  579,  516,  859,  253,  254,  342,  628,
+  860,  698,   30,  592,  699,  735,  514,  438,  229,  739,
+  446,  592,  448,  451,  952,  508,  383,  231,  481,  755,
+  589,  333,  404,  334,  236,  404,  714,  592,  213,  524,
+  529,  504,  527,  642,  307,   89,  306,  202,  237,  404,
+  768,  769,  770,  771,  772,  150,  603,  151,  731,  602,
+  517,   99,  543,  244,  543,  248,  191,  127,  551,  240,
+  241,  589,  333,  183,  334,  398,  685,  555,  556,  295,
+  165,  165,  133,  560,  532,  803,  302,  805,  807,  590,
+  591,  572,  573,  574,  575,  134,  251,  261,  442,  486,
+  419,  607,  205,  450,  602,  389,  552,  258,  440,  440,
+  557,  269,  515,  338,  338,  606,  361,  273,  363,  610,
+  611,  612,  613,  614,  615,  616,  617,  618,  619,  620,
+  621,  874,  875,  275,  391,  418,  419,  631,  344,  350,
+  917,  418,  419,  938,  131,  887,  887,  922,  887,  212,
+  588,  590,  591,  760,  589,  333,    2,  334,  646,  647,
+  648,  649,  650,  651,  652,  653,  654,  655,  656,  657,
+  658,  659,  660,  664,  665,  667,  669,  236,  670,  671,
+  279,  202,  232,  296,    3,    4,  303,  284,  581,  233,
+  223,  439,  439,  538,  323,  596,  581,  132,  283,  592,
+  191,    5,    6,  393,  596,  433,  596,  183,  868,  343,
+  288,  290,  592,  592,  592,  592,  592,  853,  883,  897,
+  580,   71,  854,  220,  925,  108,  342,  298,  580,  847,
+  343,  343,  343,  343,  343,  830,  205,  579,  292,  312,
+  832,  440,  697,  327,  328,  579,  440,  342,  342,  342,
+  342,  342,  803,  805,  807,  330,  331,  319,   30,  588,
+  590,  591,  392,  352,  810,  358,  712,  359,  762,  360,
+  719,  877,  720,  716,  364,  365,  383,   30,  383,  383,
+  725,  609,  730,   28,  602,  366,   30,   30,  130,  130,
+  130,  130,    7,  130,  543,  675,  543,  367,  674,  368,
+  543,  590,  591,   30,   30,  369,  370,  721,  721,  721,
+  721,  721,  859,  857,  721,  858,  371,  860,  604,  605,
+  887,  754,  372,  373,  439,    8,  315,  592,  374,  439,
+  555,  759,  375,  555,  377,  438,  448,  623,  624,  625,
+  626,  627,  314,  378,  924,  397,  554,  379,  903,  554,
+  636,  380,  381,  521,  777,  523,  206,  778,  390,  417,
+  415,  398,  416,  533,  882,  589,  333,  394,  334,  401,
+  912,  859,  857,  856,  858,  581,  860,  420,  403,  421,
+  391,  855,  402,  588,  590,  591,   89,  804,  690,  806,
+  808,  689,  389,  429,   30,  431,  817,  694,  343,  819,
+  693,  934,  918,  919,  920,  921,  338,  580,  902,  338,
+  338,  338,  338,  338,  338,  342,  820,  821,  432,  717,
+  480,  822,  520,  823,  579,  757,  810,   30,  756,  338,
+  936,  338,  484,  485,  774,  827,  817,  773,  779,  780,
+  501,  602,  602,  383,  383,  383,  794,  881,  836,  602,
+  482,  487,  417,  415,  795,  416,  796,  602,  797,  602,
+  824,  602,  798,  849,  809,  602,  851,  602,  448,  850,
+  420,  403,  421,  448,  502,  834,  886,  475,  905,  885,
+  907,  900,  939,  693,  511,  773,  506,  475,  518,  543,
+  178,  179,  284,  277,  236,  581,  277,  236,  520,  552,
+  106,  876,  552,  106,  295,  560,  181,  182,  880,  534,
+  183,  184,  185,  186,  302,  537,  865,  475,  130,  475,
+  475,  475,  475,  547,  187,  135,  135,  580,  211,  449,
+  241,  211,  449,  241,  548,  391,  549,  475,  475,  475,
+  246,  135,  135,  246,  579,  135,  135,  135,  135,  486,
+  278,  550,  486,  278,  804,  806,  808,  337,  329,  135,
+  337,  329,  107,  558,  243,  107,  212,  243,  899,  242,
+  483,  335,  242,  483,  335,  404,  405,  406,  407,  408,
+  576,  409,  410,  411,  412,  413,  414,  586,  336,  418,
+  419,  336,  600,  909,  588,  590,  591,  487,  334,  331,
+  487,  334,  331,  333,  632,  712,  333,  915,  332,  634,
+  633,  332,  635,  637,  678,  681,  682,  324,  684,  686,
+  687,  695,  692,  691,  696,  543,  700,  338,  338,  338,
+  338,  338,  705,  338,  338,  338,  338,  338,  338,  707,
+  736,  338,  338,  726,  738,  727,  746,  749,  223,  750,
+  591,  765,  775,  945,  799,  817,  948,  800,  801,  811,
+  812,  818,  826,  392,  825,  831,  833,  317,  404,  405,
+  406,  407,  408,  838,  409,  410,  411,  412,  413,  414,
+  845,  846,  418,  419,  848,  314,  861,  236,  958,  525,
+  314,  314,  950,  314,  863,  960,  864,  236,  867,  871,
+  872,  961,  870,  873,  963,  896,  900,  906,  314,  314,
+  314,  911,  929,  741,  931,  932,  935,  971,  941,  940,
+  942,  972,  943,  944,  973,  974,  956,  949,  955,  959,
+  976,  236,  860,  475,  397,  475,  475,  475,  475,  475,
+  957,  475,  475,  475,  475,  475,  475,  964,  500,  475,
+  475,  966,  475,  967,  475,  925,  108,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  215,  164,  127,  475,  475,
+  209,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  443,  475,  354,
+  475,  475,  475,  475,  475,  562,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  475,  475,  475,
+  475,  475,  213,  444,  475,  475,  475,  483,  475,  475,
+  475,  325,  475,  475,  475,  317,  118,  475,  354,  475,
+  326,  544,  475,  475,  475,  475,  545,  891,  475,  475,
+  475,  914,  968,  930,  718,  510,  475,  475,  475,  475,
+  475,  475,  475,  475,  475,  475,  475,  519,  475,  475,
+  475,  475,  475,  475,  475,  475,  351,  475,  475,  475,
+  475,  889,  475,  475,  475,  594,  351,  629,  828,  643,
+  947,  475,  475,  879,  916,   15,  314,  314,  314,  314,
+  314,  144,  314,  314,  314,  314,  314,  314,  256,  513,
+  314,  314,  835,  351,  676,  965,  733,  351,  351,  351,
+  351,  351,  837,  351,  728,  703,  732,  844,  747,  318,
+  744,  878,  745,  236,  351,  748,  351,  351,  351,  884,
+    0,    0,  348,    0,    0,    0,    0,    0,  236,  236,
+    0,    0,  236,    0,  236,    0,    0,  236,  236,  236,
+  236,  236,  236,  236,    0,    0,  236,  236,  236,    0,
+    0,    0,    0,  236,  236,    0,    0,    0,  236,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,  236,    0,
+    0,    0,  236,  236,    0,    0,    0,  236,    0,    0,
+    0,    0,    0,  236,    0,  236,  236,    0,  236,    0,
+  236,  236,  236,  236,  236,    0,  236,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,    0,    0,  236,  236,  236,    0,  236,  236,
+  236,    0,  236,  236,  236,    0,  314,  236,    0,  236,
+    0,    0,  236,  236,  236,  236,  314,    0,  236,  236,
+  236,    0,    0,    0,    0,    0,  236,    0,    0,  236,
+  236,  236,  236,  236,  236,  236,  236,    0,  236,  236,
+  236,  236,  236,  314,    0,  236,    0,  314,  314,  314,
+  314,  314,  236,  236,  236,    0,    0,    0,    0,    0,
+    0,  236,  236,    0,  314,    0,  314,  314,  314,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  351,    0,  351,  351,  351,  351,  351,    0,
+  351,  351,  351,  351,  351,  351,    0,  351,  351,  351,
+    0,  351,    0,  351,    0,    0,  351,  351,  351,  351,
+  351,  351,  351,    0,    0,  351,  351,  351,    0,    0,
+    0,    0,  351,  351,    0,    0,    0,  351,  351,    0,
+    0,    0,    0,    0,    0,    0,    0,  351,    0,    0,
+    0,  351,  351,    0,    0,    0,  351,    0,    0,    0,
+    0,    0,  351,    0,  351,  351,    0,  351,    0,  351,
+  351,  351,  351,  351,    0,  351,  351,  351,  351,  351,
+  351,  351,  351,  351,  351,  351,  351,  351,  351,  351,
+  351,    0,  578,  351,  351,  351,    0,  351,  351,  351,
+    0,  351,  351,  351,    0,    0,  351,    0,  351,    0,
+    0,  351,  351,  351,  351,  204,  351,  351,  351,  351,
+    0,    0,    0,    0,    0,  351,    0,    0,  351,  351,
+  351,  351,  351,  351,  351,  351,    0,  351,  351,  351,
+  351,  351,    0,    0,  351,  188,    0,    0,  150,    0,
+  151,  351,  351,  351,    0,    0,    0,    0,    0,    0,
+  351,  351,  314,    0,  314,  314,  314,  314,  314,    0,
+  314,  314,  314,  314,  314,  314,    0,  314,  314,  314,
+    0,  314,    0,  314,    0,    0,  314,  314,  314,  314,
+  314,  314,  314,    0,    0,  314,  314,  314,    0,    0,
+    0,    0,  314,  314,    0,    0,    0,  314,  314,    0,
+    0,    0,    0,    0,    0,    0,    0,  314,    0,    0,
+    0,  314,  314,    0,    0,    0,  314,    0,    0,    0,
+    0,    0,  314,    0,  314,  314,    0,  314,    0,  314,
+  314,  314,  314,  314,    0,  314,  314,  314,  314,  314,
+  314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
+  314,    0,    0,  314,  314,  314,    0,  314,  314,  314,
+    0,  314,  314,  314,    0,  318,  314,    0,  314,    0,
+    0,  314,  314,  314,  314,  318,  314,  314,  314,  314,
+    0,    0,    0,    0,    0,  314,    0,    0,  314,  314,
+  314,  314,  314,  314,  314,  314,    0,  314,  314,  314,
+  314,  314,  318,    0,  314,    0,  318,  318,  318,  318,
+  318,  314,  314,  314,    0,    0,    0,    0,    0,    0,
+  314,  314,    0,  318,    0,  318,  318,  318,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,    0,  176,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,  315,    0,    0,  180,    0,
+    0,    0,    0,    0,    0,  315,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,    0,    0,   89,
+    0,    0,    0,    0,    0,    0,  187,    0,    0,    0,
+    0,    0,  315,    0,  177,    0,  315,  315,  315,  315,
+  315,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,  315,    0,  315,  315,  315,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,  318,    0,  318,  318,  318,  318,  318,    0,  318,
+  318,  318,  318,  318,  318,    0,  318,  318,  318,    0,
+  318,    0,  318,    0,    0,  318,  318,  318,  318,  318,
+  318,  318,    0,    0,  318,  318,  318,    0,    0,    0,
+    0,  318,  318,    0,    0,    0,  318,  318,    0,    0,
+    0,    0,    0,    0,    0,    0,  318,    0,    0,    0,
+  318,  318,    0,    0,    0,  318,    0,    0,    0,    0,
+    0,  318,    0,  318,  318,    0,  318,    0,  318,  318,
+  318,  318,  318,    0,  318,  318,  318,  318,  318,  318,
+  318,  318,  318,  318,  318,  318,  318,  318,  318,  318,
+    0,    0,  318,  318,  318,    0,  318,  318,  318,    0,
+  318,  318,  318,    0,    0,  318,    0,  318,    0,    0,
+  318,  318,  318,  318,    0,  318,  318,  318,  318,    0,
+    0,    0,    0,    0,  318,    0,    0,  318,  318,  318,
+  318,  318,  318,  318,  318,    0,  318,  318,  318,  318,
+  318,  188,    0,  318,  150,    0,  151,    0,    0,    0,
+  318,  318,  318,    0,    0,    0,    0,    0,    0,  318,
+  318,  315,  661,  315,  315,  315,  315,  315,    0,  315,
+  315,  315,  315,  315,  315,    0,  315,  315,  315,    0,
+  315,    0,  315,    0,    0,  315,  315,  315,  315,  315,
+  315,  315,    0,    0,  315,  315,  315,    0,    0,    0,
+    0,  315,  315,    0,    0,    0,  315,  315,    0,    0,
+    0,    0,  417,  415,    0,  416,  315,    0,    0,    0,
+  315,  315,    0,    0,    0,  315,    0,    0,    0,    0,
+  420,  315,  421,  315,  315,    0,  315,    0,  315,  315,
+  315,  315,  315,    0,  315,  315,  315,  315,  315,  315,
+  315,  315,  315,  315,  315,  315,  315,  315,  315,  315,
+    0,    0,  315,  315,  315,    0,  315,  315,  315,    0,
+  315,  315,  315,    0,  323,  315,    0,  315,    0,    0,
+  315,  315,  315,  315,  323,  315,  315,  315,  315,    0,
+    0,    0,    0,    0,  315,    0,  488,  315,  315,  315,
+  315,  315,  315,  315,  315,    0,  315,  315,  315,  315,
+  315,    0,    0,  315,  323,  323,  323,  323,  323,  323,
+  315,  315,  315,    0,    0,    0,    0,    0,    0,  315,
+  315,    0,  323,    0,  323,  323,  323,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  253,  254,  489,
+    0,    0,    0,    0,    0,    0,    0,  417,  415,    0,
+  416,    0,    0,    0,  149,    0,    0,    0,    0,    0,
+    0,    0,    0,  662,    0,  420,  490,  421,  491,  492,
+  493,    0,    0,  494,  495,    0,  496,  497,  152,  153,
+    0,    0,    0,  154,  155,  156,  157,    0,    0,    0,
+    0,    0,    0,    0,    0,  158,  159,  160,  161,  162,
+  163,  164,    0,  165,  166,  167,    0,    0,  168,  169,
+  170,    0,  171,  172,  173,  174,  175,    0,  176,    0,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  320,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  320,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  177,  320,    0,    0,    0,  320,  320,  320,  320,  320,
+    0,  178,  179,    0,    0,    0,    0,  180,    0,    0,
+    0,    0,  320,    0,  320,  320,  320,  181,  182,    0,
+    0,  183,  184,  185,  186,    0,    0,    0,   89,    0,
+    0,    0,    0,    0,    0,  187,    0,    0,    0,    0,
+  323,    0,  323,  323,  323,  323,  323,    0,  323,  323,
+  323,  323,  323,  323,    0,  323,  323,  323,    0,  323,
+    0,  323,    0,    0,  323,  323,  323,  323,  323,  323,
+  323,    0,    0,  323,  323,  323,    0,    0,    0,    0,
+  323,  323,    0,    0,    0,  323,  323,  408,    0,  409,
+  410,  411,  412,  413,  414,  323,    0,  418,  419,  323,
+  323,    0,    0,    0,  323,    0,    0,    0,    0,    0,
+  323,    0,  323,  323,    0,  323,    0,  323,  323,  323,
+  323,  323,    0,  323,  323,  323,  323,  323,  323,  323,
+  323,  323,  323,  323,  323,  323,  323,  323,  323,    0,
+  578,  323,  323,  323,    0,  323,  323,  323,    0,  323,
+  323,  323,    0,    0,  323,    0,  323,    0,    0,  323,
+  323,  323,  323,    0,  323,  323,  323,  323,    0,    0,
+    0,    0,    0,  323,    0,    0,  323,  323,  323,  323,
+  323,  323,  323,  323,    0,  323,  323,  323,  323,  323,
+    0,    0,  323,  188,    0,  709,  150,    0,  151,  323,
+  323,  323,    0,    0,    0,    0,    0,    0,  323,  323,
+  320,  708,  320,  320,  320,  320,  320,    0,  320,  320,
+  320,  320,  320,  320,    0,  320,  320,  320,    0,  320,
+    0,  320,    0,    0,  320,  320,  320,  320,  320,  320,
+  320,    0,    0,  320,  320,  320,    0,    0,    0,    0,
+  320,  320,    0,    0,    0,  320,  320,    0,    0,    0,
+    0,    0,    0,    0,    0,  320,    0,    0,    0,  320,
+  320,    0,    0,    0,  320,    0,    0,    0,    0,    0,
+  320,    0,  320,  320,    0,  320,    0,  320,  320,  320,
+  320,  320,    0,  320,  320,  320,  320,  320,  320,  320,
+  320,  320,  320,  320,  320,  320,  320,  320,  320,    0,
+    0,  320,  320,  320,    0,  320,  320,  320,    0,  320,
+  320,  320,    0,  280,  320,    0,  320,    0,    0,  320,
+  320,  320,  320,  280,  320,  320,  320,  320,    0,    0,
+    0,    0,    0,  320,    0,    0,  320,  320,  320,  320,
+  320,  320,  320,  320,    0,  320,  320,  320,  320,  320,
+  280,    0,  320,    0,  280,  280,  280,  280,  280,  320,
+  320,  320,    0,    0,    0,    0,    0,    0,  320,  320,
+    0,  280,    0,  280,  280,  280,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,    0,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,    0,  165,  166,  167,    0,  149,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,    0,  176,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  152,  153,    0,    0,    0,  154,  155,  156,  157,    0,
+    0,    0,    0,    0,    0,    0,    0,  158,  159,  160,
+  161,  162,  163,  164,    0,  165,  166,  167,    0,    0,
+  168,  169,  170,    0,  171,  172,  173,  174,  175,    0,
+  176,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,  279,    0,    0,  180,    0,    0,    0,
+    0,    0,    0,  279,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,    0,    0,  892,    0,    0,
+    0,    0,    0,    0,  187,    0,    0,    0,    0,    0,
+    0,    0,  177,    0,  279,  279,  279,  279,  279,    0,
+    0,    0,    0,  178,  179,    0,    0,    0,    0,  180,
+    0,  279,    0,  279,  279,  279,    0,    0,    0,  181,
+  182,    0,    0,  183,  184,  185,  186,    0,    0,    0,
+   89,    0,    0,    0,    0,    0,    0,  187,    0,  280,
+    0,  280,  280,  280,  280,  280,    0,  280,  280,  280,
+  280,  280,  280,    0,  280,  280,  280,    0,  280,    0,
+  280,    0,    0,  280,  280,  280,  280,  280,  280,  280,
+    0,    0,  280,  280,  280,    0,    0,    0,    0,  280,
+  280,    0,    0,    0,  280,  280,    0,    0,    0,    0,
+    0,    0,    0,    0,  280,    0,    0,    0,  280,  280,
+    0,    0,    0,  280,    0,    0,    0,    0,    0,  280,
+    0,  280,  280,    0,  280,    0,  280,  280,  280,  280,
+  280,    0,  280,  280,  280,  280,  280,  280,  280,  280,
+  280,  280,  280,  280,  280,  280,  280,  280,    0,    0,
+  280,  280,  280,    0,  280,  280,  280,    0,  280,  280,
+  280,    0,    0,  280,    0,  280,    0,    0,  280,  280,
+  280,  280,    0,  280,  280,  280,  280,    0,    0,    0,
+    0,    0,  280,    0,    0,  280,  280,  280,  280,  280,
+  280,  280,  280,    0,  280,  280,  280,  280,  280,    0,
+    0,  280,  188,    0,  540,  150,    0,  151,  280,  280,
+    0,    0,    0,    0,    0,    0,    0,  280,  280,  279,
+    0,  279,  279,  279,  279,  279,    0,  279,  279,  279,
+  279,  279,  279,    0,  279,  279,  279,    0,  279,    0,
+  279,    0,    0,  279,  279,  279,  279,  279,  279,  279,
+    0,    0,  279,  279,  279,    0,    0,    0,    0,  279,
+  279,    0,    0,    0,  279,  279,    0,    0,  417,  415,
+    0,  416,    0,    0,  279,    0,    0,    0,  279,  279,
+    0,    0,    0,  279,    0,    0,  420,    0,  421,  279,
+    0,  279,  279,    0,  279,    0,  279,  279,  279,  279,
+  279,    0,  279,  279,  279,  279,  279,  279,  279,  279,
+  279,  279,  279,  279,  279,  279,  279,  279,    0,    0,
+  279,  279,  279,    0,  279,  279,  279,    0,  279,  279,
+  279,    0,  538,  279,    0,  279,    0,    0,  279,  279,
+  279,  279,  538,  279,  279,  279,  279,    0,    0,    0,
+    0,    0,  279,    0,    0,  279,  279,  279,  279,  279,
+  279,  279,  279,    0,  279,  279,  279,  279,  279,    0,
+    0,  279,    0,  250,  250,  250,  538,  250,  279,  279,
+  279,    0,    0,    0,    0,    0,    0,  279,  279,    0,
+    0,    0,  250,  250,  250,    0,    0,  454,    0,    0,
+    0,  455,  456,  457,  458,    0,    0,    0,    0,    0,
+    0,    0,    0,  459,  460,  461,  462,  463,  464,  465,
+    0,  466,  467,  468,    0,  149,  469,  470,  471,    0,
+    0,  472,  473,  474,  475,    0,  476,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,    0,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,  283,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  283,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  477,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  283,
+    0,  177,    0,  283,  283,  283,  283,  283,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+  283,    0,    0,  283,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,    0,    0,  541,
+    0,    0,    0,    0,    0,    0,  187,    0,  538,    0,
+  250,  250,  250,  250,  250,    0,  250,  250,  250,  250,
+  250,  250,    0,    0,  250,  250,    0,  538,    0,  538,
+    0,    0,  538,  538,  538,  538,  538,  538,  538,    0,
+    0,  538,  538,  538,    0,    0,    0,    0,  538,  538,
+    0,    0,    0,  538,  538,    0,    0,    0,    0,    0,
+    0,    0,    0,  538,    0,    0,    0,  538,  538,    0,
+    0,    0,  538,    0,    0,    0,    0,    0,  538,    0,
+  538,  538,    0,  538,    0,  538,  538,  538,  538,  538,
+    0,  538,  538,  538,  538,  538,  538,  538,  538,  538,
+  538,  538,  538,  538,  538,  538,  538,    0,    0,  538,
+  538,  538,    0,  538,  538,  538,    0,  538,  538,  538,
+    0,    0,  538,    0,  538,    0,    0,  538,  538,  538,
+  538,    0,  538,  538,  538,  538,    0,    0,    0,    0,
+    0,  538,    0,    0,  538,  538,  538,  538,  538,  538,
+  538,  538,    0,  538,  538,  538,  538,  538,    0,    0,
+  538,    0,    0,    0,    0,    0,    0,  538,  538,  538,
+    0,    0,    0,    0,    0,    0,  538,  538,  283,    0,
+  283,  283,  283,  283,  283,  289,  283,  283,  283,  283,
+  283,  283,    0,  283,  283,  289,    0,  283,    0,  283,
+    0,    0,  283,  283,  283,  283,  283,  283,  283,    0,
+    0,  283,  283,  283,    0,    0,    0,    0,  283,  283,
+    0,    0,  289,  283,  283,    0,  289,  289,  289,  289,
+  289,    0,    0,  283,    0,    0,    0,  283,  283,    0,
+    0,    0,  283,  289,    0,    0,  289,    0,  283,    0,
+  283,  283,    0,  283,    0,  283,  283,  283,  283,  283,
+    0,  283,  283,  283,  283,  283,  283,  283,  283,  283,
+  283,  283,  283,  283,  283,  283,  283,    0,    0,  283,
+  283,  283,    0,  283,  283,  283,    0,  283,  283,  283,
+    0,    0,  283,    0,  283,    0,    0,  283,  283,  283,
+  283,    0,  283,  283,  283,  283,    0,    0,    0,    0,
+    0,  283,    0,    0,  283,  283,  283,  283,  283,  283,
+  283,  283,    0,  283,  283,  283,  283,  283,    0,    0,
+  283,    0,    0,    0,    0,    0,    0,  283,  283,  283,
+    0,    0,    0,    0,    0,    0,  283,  283,    0,    0,
+    0,    0,    0,    0,  108,  290,    0,    0,  108,  108,
+  108,  108,    0,    0,    0,  290,    0,    0,    0,    0,
+  108,  108,  108,  108,  108,  108,  108,    0,  108,  108,
+  108,    0,    0,  108,  108,  108,    0,    0,  108,  108,
+  108,  108,  290,  108,    0,    0,  290,  290,  290,  290,
+  290,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  290,    0,    0,  290,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  289,    0,  289,  289,  289,  289,  289,    0,  289,
+  289,  289,  289,  289,  289,    0,  289,  289,    0,    0,
+  289,    0,  289,    0,    0,  289,  289,  289,  289,  289,
+  289,  289,    0,    0,  289,  289,  289,    0,    0,    0,
+    0,  289,  289,  108,    0,    0,  289,  289,    0,    0,
+    0,    0,    0,    0,    0,    0,  289,    0,    0,    0,
+  289,  289,    0,    0,    0,  289,    0,    0,    0,    0,
+    0,  289,    0,  289,  289,    0,  289,    0,  289,  289,
+  289,  289,  289,    0,  289,  289,  289,  289,  289,  289,
+  289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
+    0,    0,  289,  289,  289,    0,  289,  289,  289,    0,
+  289,  289,  289,    0,    0,  289,    0,  289,    0,    0,
+  289,  289,  289,  289,    0,  289,  289,  289,  289,    0,
+    0,    0,    0,    0,  289,    0,    0,  289,  289,  289,
+  289,  289,  289,  289,  289,    0,  289,  289,  289,  289,
+  289,    0,    0,  289,    0,    0,    0,    0,    0,    0,
+  289,  289,  289,    0,    0,    0,    0,    0,    0,  289,
+  289,  290,    0,  290,  290,  290,  290,  290,  311,  290,
+  290,  290,  290,  290,  290,    0,  290,  290,  311,    0,
+  290,    0,  290,    0,    0,  290,  290,  290,  290,  290,
+  290,  290,    0,    0,  290,  290,  290,    0,    0,    0,
+    0,  290,  290,    0,    0,  311,  290,  290,    0,  311,
+  311,  311,  311,  311,    0,    0,  290,    0,    0,    0,
+  290,  290,    0,    0,    0,  290,  311,    0,    0,  311,
+    0,  290,    0,  290,  290,    0,  290,    0,  290,  290,
+  290,  290,  290,    0,  290,  290,  290,  290,  290,  290,
+  290,  290,  290,  290,  290,  290,  290,  290,  290,  290,
+    0,    0,  290,  290,  290,    0,  290,  290,  290,    0,
+  290,  290,  290,    0,    0,  290,    0,  290,    0,    0,
+  290,  290,  290,  290,    0,  290,  290,  290,  290,    0,
+    0,    0,    0,    0,  290,    0,    0,  290,  290,  290,
+  290,  290,  290,  290,  290,    0,  290,  290,  290,  290,
+  290,    0,    0,  290,    0,    0,    0,    0,    0,    0,
+  290,  290,  290,    0,   20,    0,    0,    0,    0,  290,
+  290,    0,    0,    0,    0,    0,    0,    0,  519,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  519,   26,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,   30,    0,    0,    0,    0,   33,
+  314,    0,    0,    0,   37,   38,    0,    0,    0,  519,
+  519,  519,  519,  519,  315,   47,   48,   49,   50,   51,
+   52,  316,    0,    0,    0,    0,    0,    0,  519,  519,
+  519,    0,    0,    0,   62,    0,    0,    0,    0,    0,
+   65,    0,    0,    0,    0,    0,    0,    0,    0,   70,
+    0,   72,    0,    0,  311,    0,  311,  311,  311,  311,
+  311,    0,  311,  311,  311,  311,  311,  311,    0,  311,
+  311,    0,    0,  311,    0,  311,    0,    0,  311,  311,
+  311,  311,  311,  311,  311,   89,    0,  311,  311,  311,
+    0,    0,   90,    0,  311,  311,    0,    0,    0,  311,
+  311,    0,    0,    0,    0,    0,    0,    0,    0,  311,
+    0,    0,    0,  311,  311,    0,    0,    0,  311,    0,
+    0,    0,    0,    0,  311,    0,  311,  311,    0,  311,
+    0,  311,  311,  311,  311,  311,    0,  311,  311,  311,
+  311,  311,  311,  311,  311,  311,  311,  311,  311,  311,
+  311,  311,  311,    0,    0,  311,  311,  311,    0,  311,
+  311,  311,    0,  311,  311,  311,    0,    0,  311,    0,
+  311,    0,    0,  311,  311,  311,  311,    0,  311,  311,
+  311,  311,    0,    0,    0,    0,    0,  311,    0,    0,
+  311,  311,  311,  311,  311,  311,  311,  311,    0,  311,
+  311,  311,  311,  311,    0,    0,  311,  188,    0,  559,
+  150,    0,  151,  311,  311,  311,    0,    0,    0,    0,
+    0,    0,  311,  311,  519,    0,  519,  519,  519,  519,
+  519,    0,  519,  519,  519,  519,  519,  519,    0,    0,
+  519,  519,    0,  519,    0,  519,    0,    0,  519,  519,
+  519,  519,  519,  519,  519,    0,    0,  519,  519,  519,
+    0,    0,    0,    0,  519,  519,    0,    0,    0,  519,
+  519,    0,    0,    0,    0,    0,    0,    0,    0,  519,
+    0,    0,    0,  519,  519,    0,    0,    0,  519,    0,
+    0,    0,    0,    0,  519,    0,  519,  519,    0,  519,
+    0,  519,  519,  519,  519,  519,    0,  519,  519,  519,
+  519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
+  519,  519,  519,    0,    0,  519,  519,  519,    0,  519,
+  519,  519,    0,  519,  519,  519,    0,  528,  519,    0,
+  519,    0,    0,  519,  519,  519,  519,  528,    0,  519,
+  519,  519,    0,    0,    0,    0,    0,  519,    0,    0,
+  519,  519,  519,  519,  519,  519,  519,  519,    0,  519,
+  519,  519,  519,  519,    0,    0,  519,    0,    0,  247,
+  247,    0,  247,  519,  519,  519,    0,    0,    0,    0,
+    0,    0,  519,  519,    0,    0,    0,  247,  247,  247,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  149,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  287,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  287,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  287,    0,  177,    0,  287,    0,
+  287,  287,  287,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,  287,    0,    0,  287,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,    0,   89,    0,    0,    0,    0,    0,
+    0,  187,    0,  528,    0,  247,  247,  247,  247,  247,
+    0,  247,  247,  247,  247,  247,  247,    0,    0,  247,
+  247,    0,  528,    0,  528,    0,    0,  528,  528,  528,
+  528,  528,  528,  528,    0,    0,  528,  528,  528,    0,
+    0,    0,    0,  528,  528,    0,    0,    0,  528,  528,
+    0,    0,    0,    0,    0,    0,    0,    0,  528,    0,
+    0,    0,  528,  528,    0,    0,    0,  528,    0,    0,
+    0,    0,    0,  528,    0,  528,  528,    0,  528,    0,
+  528,  528,  528,  528,  528,    0,  528,  528,  528,  528,
+  528,  528,  528,  528,  528,  528,  528,  528,  528,  528,
+  528,  528,    0,    0,  528,  528,  528,    0,  528,  528,
+  528,    0,  528,  528,  528,    0,    0,  528,    0,  528,
+    0,    0,  528,  528,  528,  528,    0,  528,  528,  528,
+  528,    0,    0,    0,    0,    0,  528,    0,    0,  528,
+  528,  528,  528,  528,  528,  528,  528,    0,  528,  528,
+  528,  528,  528,    0,    0,  528,    0,    0,    0,    0,
+    0,    0,  528,  528,  528,    0,    0,    0,    0,    0,
+    0,  528,  528,  287,    0,  287,  287,  287,  287,  287,
+  288,  287,  287,  287,  287,  287,  287,    0,  287,    0,
+  288,    0,  287,    0,  287,    0,    0,  287,  287,  287,
+  287,  287,  287,  287,    0,    0,  287,  287,  287,    0,
+    0,    0,    0,  287,  287,    0,    0,  288,  287,  287,
+    0,  288,    0,  288,  288,  288,    0,    0,  287,    0,
+    0,    0,  287,  287,    0,    0,    0,  287,  288,    0,
+    0,  288,    0,  287,    0,  287,  287,    0,  287,    0,
+  287,  287,  287,  287,  287,    0,  287,  287,  287,  287,
+  287,  287,  287,  287,  287,  287,  287,  287,  287,  287,
+  287,  287,    0,    0,  287,  287,  287,    0,  287,  287,
+  287,    0,  287,  287,  287,    0,    0,  287,    0,  287,
+    0,    0,  287,  287,  287,  287,    0,  287,  287,  287,
+  287,    0,    0,    0,    0,    0,  287,    0,    0,  287,
+  287,  287,  287,  287,  287,  287,  287,    0,  287,  287,
+  287,  287,  287,    0,    0,  287,    0,    0,    0,    0,
+    0,    0,  287,  287,  287,    0,    0,    0,    0,    0,
+    0,  287,  287,    0,    0,    0,    0,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  308,    0,    0,
+    0,  308,  308,    0,  308,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  308,    0,
+  308,    0,  308,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  288,    0,  288,  288,
+  288,  288,  288,    0,  288,  288,  288,  288,  288,  288,
+    0,  288,    0,    0,    0,  288,    0,  288,    0,    0,
+  288,  288,  288,  288,  288,  288,  288,    0,    0,  288,
+  288,  288,    0,    0,    0,    0,  288,  288,    0,    0,
+    0,  288,  288,    0,    0,    0,    0,    0,    0,    0,
+    0,  288,    0,    0,    0,  288,  288,    0,    0,    0,
+  288,    0,    0,    0,    0,    0,  288,    0,  288,  288,
+    0,  288,   22,  288,  288,  288,  288,  288,    0,  288,
+  288,  288,  288,  288,  288,  288,  288,  288,  288,  288,
+  288,  288,  288,  288,  288,    0,    0,  288,  288,  288,
+    0,  288,  288,  288,    0,  288,  288,  288,    0,    0,
+  288,    0,  288,    0,    0,  288,  288,  288,  288,    0,
+  288,  288,  288,  288,    0,    0,    0,    0,    0,  288,
+    0,    0,  288,  288,  288,  288,  288,  288,  288,  288,
+    0,  288,  288,  288,  288,  288,    0,    0,  288,    0,
+    0,    0,    0,    0,    0,  288,  288,  288,    0,    0,
+    0,    0,    0,    0,  288,  288,  308,    0,  308,  308,
+  308,  308,  308,    0,  308,  308,  308,  308,  308,  308,
+    0,  308,    0,  308,    0,  308,    0,  308,    0,    0,
+  308,  308,  308,  308,  308,  308,  308,    0,    0,  308,
+  308,  308,    0,    0,    0,    0,  308,  308,    0,    0,
+    0,  308,  308,    0,    0,    0,    0,    0,    0,    0,
+    0,  308,    0,    0,    0,  308,  308,    0,    0,    0,
+  308,    0,    0,    0,    0,    0,  308,    0,  308,  308,
+    0,  308,    0,  308,  308,  308,  308,  308,    0,  308,
+  308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
+  308,  308,  308,  308,  308,    0,    0,  308,  308,  308,
+    0,  308,  308,  308,    0,  308,  308,  308,    0,  466,
+  308,    0,  308,    0,    0,  308,  308,  308,  308,  466,
+  308,  308,  308,  308,  338,    0,    0,    0,  338,  308,
+    0,  338,  308,  308,  308,  308,    0,  308,  308,  308,
+    0,  308,  308,  308,  308,  308,    0,  338,  308,  338,
+    0,  518,  518,  518,  518,  308,  308,    0,    0,    0,
+    0,    0,    0,    0,    0,  308,    0,    0,    0,  518,
+  518,  518,    0,    0,    0,    0,    0,   22,    0,   22,
+    0,    0,   22,   22,   22,   22,    0,    0,   22,    0,
+    0,   22,   22,   22,    0,    0,    0,    0,   22,   22,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,   22,    0,    0,    0,   22,   22,    0,
+    0,    0,   22,    0,    0,    0,    0,    0,   22,    0,
+   22,   22,    0,   22,    0,   22,   22,   22,   22,   22,
+    0,   22,   22,   22,   22,   22,   22,   22,   22,   22,
+   22,   22,   22,   22,   22,   22,   22,    0,    0,   22,
+   22,   22,    0,   22,   22,   22,    0,   22,   22,   22,
+    0,  518,   22,    0,   22,    0,    0,   22,   22,   22,
+   22,  518,    0,   22,   22,   22,    0,    0,    0,    0,
+    0,   22,    0,    0,    0,   22,   22,   22,   22,   22,
+   22,   22,    0,   22,   22,   22,   22,   22,    0,    0,
+   22,    0,    0,  518,  518,  518,  518,   22,   22,   22,
+    0,    0,    0,    0,    0,    0,   22,    0,    0,    0,
+    0,  518,  518,  518,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  338,  338,  338,  338,  338,
+    0,  338,  338,  338,  338,  338,  338,    0,    0,  338,
+  338,    0,    0,    0,    0,  466,    0,  518,  518,  518,
+  518,  518,    0,  518,  518,  518,  518,  518,  518,    0,
+    0,  518,  518,    0,  466,    0,  466,    0,    0,  466,
+  466,  466,  466,  466,  466,  466,    0,    0,  466,  466,
+  466,    0,    0,    0,    0,  466,  466,    0,    0,    0,
+  466,  466,    0,    0,    0,    0,    0,    0,    0,    0,
+  466,    0,   56,    0,  466,  466,    0,    0,    0,  466,
+    0,    0,   56,    0,    0,  466,    0,  466,  466,    0,
+  466,    0,  466,  466,  466,  466,  466,    0,  466,  466,
+  466,  466,  466,  466,  466,  466,  466,  466,  466,  466,
+  466,  466,  466,  466,    0,    0,  466,  466,  466,    0,
+  466,  466,  466,    0,  466,  466,  466,    0,    0,  466,
+    0,  466,    0,    0,  466,  466,  466,  466,    0,    0,
+  466,  466,  466,    0,    0,    0,    0,    0,  466,    0,
+    0,  466,  466,  466,  466,    0,  466,  466,  466,    0,
+  466,  466,  466,  466,  466,    0,    0,  466,    0,    0,
+    0,    0,    0,    0,  466,  466,    0,  518,    0,  518,
+  518,  518,  518,  518,  466,  518,  518,  518,  518,  518,
+  518,    0,    0,  518,  518,    0,  518,    0,  518,    0,
+    0,  518,  518,  518,  518,  518,  518,  518,    0,    0,
+  518,  518,  518,    0,    0,    0,    0,  518,  518,    0,
+    0,    0,  518,  518,    0,    0,    0,    0,    0,    0,
+    0,    0,  518,    0,    0,    0,  518,  518,    0,    0,
+    0,  518,    0,    0,    0,    0,    0,  518,    0,  518,
+  518,    0,  518,    0,  518,  518,  518,  518,  518,    0,
+  518,  518,  518,  518,  518,  518,  518,  518,  518,  518,
+  518,  518,  518,  518,  518,  518,    0,    0,  518,  518,
+  518,    0,  518,  518,  518,    0,  518,  518,  518,    0,
+  284,  518,    0,  518,    0,    0,  518,  518,  518,  518,
+  284,    0,  518,  518,  518,    0,    0,    0,    0,    0,
+  518,    0,    0,  518,  518,  518,  518,    0,  518,  518,
+  518,    0,  518,  518,  518,  518,  518,  284,   56,  518,
+    0,  284,    0,    0,  284,    0,  518,  518,    0,    0,
+    0,    0,    0,  164,  164,    0,  518,   56,  284,   56,
+    0,  284,   56,   56,   56,   56,   56,   56,   56,    0,
+    0,   56,   56,   56,    0,    0,    0,    0,   56,   56,
+    0,    0,    0,   56,   56,    0,    0,    0,    0,    0,
+    0,    0,    0,   56,    0,    0,    0,   56,   56,    0,
+    0,    0,   56,    0,    0,    0,    0,    0,   56,    0,
+   56,   56,    0,   56,    0,   56,   56,   56,   56,   56,
+    0,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+   56,   56,   56,   56,   56,   56,   56,    0,    0,   56,
+   56,   56,    0,   56,   56,   56,    0,   56,   56,   56,
+    0,  305,   56,    0,   56,    0,    0,   56,   56,   56,
+   56,  305,    0,   56,   56,   56,    0,    0,    0,    0,
+    0,   56,    0,    0,   56,   56,   56,   56,   56,   56,
+   56,   56,    0,   56,   56,   56,   56,   56,  305,    0,
+   56,    0,  305,    0,    0,  305,    0,   56,   56,   56,
+    0,    0,    0,    0,    0,    0,   56,   56,    0,  305,
+    0,    0,  305,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  284,    0,  284,  284,
+  284,  284,  284,    0,    0,    0,    0,    0,    0,    0,
+    0,  284,    0,    0,    0,  284,    0,  284,    0,    0,
+  284,  284,  284,  284,  284,  284,  284,    0,    0,  284,
+  284,  284,    0,    0,    0,    0,  284,  284,    0,    0,
+    0,  284,  284,    0,    0,    0,    0,    0,    0,    0,
+    0,  284,    0,    0,    0,  284,  284,    0,    0,    0,
+  284,    0,    0,    0,    0,    0,  284,    0,  284,  284,
+    0,  284,    0,  284,  284,  284,  284,  284,    0,  284,
+  284,  284,  284,  284,  284,  284,  284,  284,  284,  284,
+  284,  284,  284,  284,  284,    0,    0,  284,  284,  284,
+    0,  284,  284,  284,    0,  284,  284,  284,  341,  341,
+  284,  341,  284,    0,    0,  284,  284,  284,  284,    0,
+  284,  284,  284,  284,    0,    0,  341,  341,  341,  284,
+    0,    0,  284,  284,  284,  284,  284,  284,  284,  284,
+    0,  284,  284,  284,  284,  284,    0,  305,  284,  305,
+  305,  305,  305,  305,    0,  284,  284,  284,    0,    0,
+  295,    0,  305,    0,  284,  284,  305,    0,  305,    0,
+  295,  305,  305,  305,  305,  305,  305,  305,    0,    0,
+  305,  305,  305,    0,    0,    0,    0,  305,  305,    0,
+    0,    0,  305,  305,    0,    0,    0,  295,    0,    0,
+    0,  295,  305,    0,  295,    0,  305,  305,    0,    0,
+    0,  305,    0,    0,    0,    0,    0,  305,  295,  305,
+  305,  295,  305,    0,  305,  305,  305,  305,  305,    0,
+  305,  305,  305,  305,  305,  305,  305,  305,  305,  305,
+  305,  305,  305,  305,  305,  305,    0,    0,  305,  305,
+  305,    0,  305,  305,  305,    0,  305,  305,  305,    0,
+    0,  305,    0,  305,    0,    0,  305,  305,  305,  305,
+    0,  305,  305,  305,  305,    0,    0,    0,    0,    0,
+  305,    0,    0,  305,  305,  305,  305,  305,  305,  305,
+  305,    0,  305,  305,  305,  305,  305,    0,    0,  305,
+    0,    0,    0,    0,    0,    0,  305,  305,  305,    0,
+    0,  293,    0,    0,    0,  305,  305,    0,    0,    0,
+    0,  293,    0,    0,  341,  341,  341,  341,  341,    0,
+  341,  341,  341,  341,  341,  341,    0,    0,  341,  341,
+    0,    0,    0,    0,    0,    0,    0,    0,  293,    0,
+    0,    0,  293,    0,    0,  293,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  293,
+    0,    0,  293,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  295,    0,  295,  295,
+  295,  295,  295,    0,    0,    0,    0,    0,    0,    0,
+    0,  295,    0,    0,    0,  295,    0,  295,    0,    0,
+  295,  295,  295,  295,  295,  295,  295,    0,    0,  295,
+  295,  295,    0,    0,    0,    0,  295,  295,    0,    0,
+    0,  295,  295,    0,    0,    0,    0,    0,    0,    0,
+    0,  295,    0,    0,    0,  295,  295,    0,    0,    0,
+  295,    0,    0,  341,    0,    0,  295,    0,  295,  295,
+    0,  295,    0,  295,  295,  295,  295,  295,    0,  295,
+  295,  295,  295,  295,  295,  295,  295,  295,  295,  295,
+  295,  295,  295,  295,  295,    0,    0,  295,  295,  295,
+    0,  295,  295,  295,    0,  295,  295,  295,  417,  415,
+  295,  416,  295,    0,    0,  295,  295,  295,  295,    0,
+  295,  295,  295,  295,  852,    0,  420,  403,  421,  295,
+    0,    0,  295,  295,  295,  295,  295,  295,  295,  295,
+    0,  295,  295,  295,  295,  295,    0,  293,  295,  293,
+  293,  293,  293,  293,    0,  295,  295,  295,    0,    0,
+  299,    0,  293,    0,  295,  295,  293,    0,  293,    0,
+  299,  293,  293,  293,  293,  293,  293,  293,    0,    0,
+  293,  293,  293,    0,    0,    0,    0,  293,  293,    0,
+    0,    0,  293,  293,    0,    0,    0,  299,    0,    0,
+    0,  299,  293,    0,  299,    0,  293,  293,    0,    0,
+    0,  293,    0,    0,    0,    0,    0,  293,  299,  293,
+  293,  299,  293,    0,  293,  293,  293,  293,  293,    0,
+  293,  293,  293,  293,  293,  293,  293,  293,  293,  293,
+  293,  293,  293,  293,  293,  293,    0,    0,  293,  293,
+  293,    0,  293,  293,  293,    0,  293,  293,  293,    0,
+    0,  293,    0,  293,    0,    0,  293,  293,  293,  293,
+    0,  293,  293,  293,  293,    0,    0,    0,    0,    0,
+  293,    0,    0,  293,  293,  293,  293,  293,  293,  293,
+  293,    0,  293,  293,  293,  293,  293,    0,    0,  293,
+    0,    0,    0,    0,    0,    0,  293,  293,  293,    0,
+    0,  297,    0,    0,    0,  293,  293,    0,    0,    0,
+    0,  297,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  297,    0,
+    0,    0,  297,    0,    0,  297,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  297,
+    0,    0,  297,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  299,    0,  299,  299,
+  299,  299,  299,    0,    0,    0,    0,    0,    0,    0,
+    0,  299,    0,    0,    0,  299,    0,  299,    0,    0,
+  299,  299,  299,  299,  299,  299,  299,    0,    0,  299,
+  299,  299,    0,    0,    0,    0,  299,  299,    0,    0,
+    0,  299,  299,    0,    0,    0,    0,    0,    0,    0,
+    0,  299,    0,    0,    0,  299,  299,    0,    0,    0,
+  299,    0,    0,    0,    0,    0,  299,    0,  299,  299,
+    0,  299,    0,  299,  299,  299,  299,  299,    0,  299,
+  299,  299,  299,  299,  299,  299,  299,  299,  299,  299,
+  299,  299,  299,  299,  299,    0,    0,  299,  299,  299,
+    0,  299,  299,  299,    0,  299,  299,  299,  417,  415,
+  299,  416,  299,    0,    0,  299,  299,  299,  299,    0,
+  299,  299,  299,  299,  901,    0,  420,  403,  421,  299,
+    0,    0,  299,  299,  299,  299,  299,  299,  299,  299,
+    0,  299,  299,  299,  299,  299,    0,  297,  299,  297,
+  297,  297,  297,  297,    0,  299,  299,  299,    0,    0,
+  291,    0,  297,    0,  299,  299,  297,    0,  297,    0,
+  291,  297,  297,  297,  297,  297,  297,  297,    0,    0,
+  297,  297,  297,    0,    0,    0,    0,  297,  297,    0,
+    0,    0,  297,  297,    0,    0,    0,  291,    0,    0,
+    0,  291,  297,    0,  291,    0,  297,  297,    0,    0,
+    0,  297,    0,    0,    0,    0,    0,  297,  291,  297,
+  297,  291,  297,    0,  297,  297,  297,  297,  297,    0,
+  297,  297,  297,  297,  297,  297,  297,  297,  297,  297,
+  297,  297,  297,  297,  297,  297,    0,    0,  297,  297,
+  297,    0,  297,  297,  297,    0,  297,  297,  297,    0,
+    0,  297,    0,  297,    0,    0,  297,  297,  297,  297,
+    0,  297,  297,  297,  297,    0,    0,    0,    0,    0,
+  297,    0,    0,  297,  297,  297,  297,  297,  297,  297,
+  297,    0,  297,  297,  297,  297,  297,    0,    0,  297,
+    0,    0,    0,    0,    0,    0,  297,  297,  297,    0,
+    0,  301,    0,    0,    0,  297,  297,    0,    0,    0,
+    0,  301,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  301,    0,
+    0,    0,  301,    0,    0,  301,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  301,
+    0,    0,  301,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  291,    0,  291,  291,
+  291,  291,  291,    0,    0,    0,    0,    0,    0,    0,
+    0,  291,    0,    0,    0,  291,    0,  291,    0,    0,
+  291,  291,  291,  291,  291,  291,  291,    0,    0,  291,
+  291,  291,    0,    0,    0,    0,  291,  291,    0,    0,
+    0,  291,  291,    0,    0,    0,    0,    0,    0,    0,
+    0,  291,    0,    0,    0,  291,  291,    0,    0,    0,
+  291,    0,    0,    0,    0,    0,  291,    0,  291,  291,
+    0,  291,    0,  291,  291,  291,  291,  291,    0,  291,
+  291,  291,  291,  291,  291,  291,  291,  291,  291,  291,
+  291,  291,  291,  291,  291,    0,    0,  291,  291,  291,
+    0,  291,  291,  291,    0,  291,  291,  291,  417,  415,
+  291,  416,  291,    0,    0,  291,  291,  291,  291,    0,
+  291,  291,  291,  291,  946,    0,  420,  403,  421,  291,
+    0,    0,  291,  291,  291,  291,  291,  291,  291,  291,
+    0,  291,  291,  291,  291,  291,    0,  301,  291,  301,
+  301,  301,  301,  301,    0,  291,  291,  291,    0,    0,
+  296,    0,  301,    0,  291,  291,  301,    0,  301,    0,
+  296,  301,  301,  301,  301,  301,  301,  301,    0,    0,
+  301,  301,  301,    0,    0,    0,    0,  301,  301,    0,
+    0,    0,  301,  301,    0,    0,    0,  296,    0,    0,
+    0,  296,  301,    0,  296,    0,  301,  301,    0,    0,
+    0,  301,    0,    0,    0,    0,    0,  301,  296,  301,
+  301,  296,  301,    0,  301,  301,  301,  301,  301,    0,
+  301,  301,  301,  301,  301,  301,  301,  301,  301,  301,
+  301,  301,  301,  301,  301,  301,    0,    0,  301,  301,
+  301,    0,  301,  301,  301,    0,  301,  301,  301,    0,
+    0,  301,    0,  301,    0,    0,  301,  301,  301,  301,
+    0,  301,  301,  301,  301,    0,    0,    0,    0,    0,
+  301,    0,    0,  301,  301,  301,  301,  301,  301,  301,
+  301,    0,  301,  301,  301,  301,  301,    0,    0,  301,
+    0,    0,    0,    0,    0,    0,  301,  301,  301,    0,
+    0,  294,    0,    0,    0,  301,  301,    0,    0,    0,
+    0,  294,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  294,    0,
+    0,    0,  294,    0,    0,  294,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  294,
+    0,    0,  294,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  296,    0,  296,  296,
+  296,  296,  296,    0,    0,    0,    0,    0,    0,    0,
+    0,  296,    0,    0,    0,  296,    0,  296,    0,    0,
+  296,  296,  296,  296,  296,  296,  296,    0,    0,  296,
+  296,  296,    0,    0,    0,    0,  296,  296,    0,    0,
+    0,  296,  296,    0,    0,    0,    0,    0,    0,    0,
+    0,  296,    0,    0,    0,  296,  296,    0,    0,    0,
+  296,    0,    0,    0,    0,    0,  296,    0,  296,  296,
+    0,  296,    0,  296,  296,  296,  296,  296,    0,  296,
+  296,  296,  296,  296,  296,  296,  296,  296,  296,  296,
+  296,  296,  296,  296,  296,    0,    0,  296,  296,  296,
+    0,  296,  296,  296,    0,  296,  296,  296,  417,  415,
+  296,  416,  296,    0,    0,  296,  296,  296,  296,    0,
+  296,  296,  296,  296,  962,    0,  420,  403,  421,  296,
+    0,    0,  296,  296,  296,  296,  296,  296,  296,  296,
+    0,  296,  296,  296,  296,  296,    0,  294,  296,  294,
+  294,  294,  294,  294,    0,  296,  296,  296,    0,    0,
+  312,    0,  294,    0,  296,  296,  294,    0,  294,    0,
+  312,  294,  294,  294,  294,  294,  294,  294,    0,    0,
+  294,  294,  294,    0,    0,    0,    0,  294,  294,    0,
+    0,    0,  294,  294,    0,    0,    0,  312,    0,    0,
+    0,  312,  294,    0,  312,    0,  294,  294,    0,    0,
+    0,  294,    0,    0,    0,    0,    0,  294,  312,  294,
+  294,  312,  294,    0,  294,  294,  294,  294,  294,    0,
+  294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
+  294,  294,  294,  294,  294,  294,    0,    0,  294,  294,
+  294,    0,  294,  294,  294,    0,  294,  294,  294,    0,
+    0,  294,    0,  294,    0,    0,  294,  294,  294,  294,
+    0,  294,  294,  294,  294,    0,    0,    0,    0,    0,
+  294,    0,    0,  294,  294,  294,  294,  294,  294,  294,
+  294,    0,  294,  294,  294,  294,  294,    0,    0,  294,
+    0,    0,    0,    0,    0,    0,  294,  294,  294,    0,
+    0,  310,    0,    0,    0,  294,  294,    0,    0,    0,
+    0,  310,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  310,    0,
+    0,    0,  310,    0,    0,  310,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  310,
+    0,    0,  310,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  312,    0,  312,  312,
+  312,  312,  312,    0,    0,    0,    0,    0,    0,    0,
+    0,  312,    0,    0,    0,  312,    0,  312,    0,    0,
+  312,  312,  312,  312,  312,  312,  312,    0,    0,  312,
+  312,  312,    0,    0,    0,    0,  312,  312,    0,    0,
+    0,  312,  312,    0,    0,    0,    0,    0,    0,    0,
+    0,  312,    0,    0,    0,  312,  312,    0,    0,    0,
+  312,    0,    0,    0,    0,    0,  312,    0,  312,  312,
+    0,  312,    0,  312,  312,  312,  312,  312,    0,  312,
+  312,  312,  312,  312,  312,  312,  312,  312,  312,  312,
+  312,  312,  312,  312,  312,    0,    0,  312,  312,  312,
+    0,  312,  312,  312,    0,  312,  312,  312,  417,  415,
+  312,  416,  312,    0,    0,  312,  312,  312,  312,    0,
+  312,  312,  312,  312,    0,    0,  420,  403,  421,  312,
+    0,    0,  312,  312,  312,  312,  312,  312,  312,  312,
+    0,  312,  312,  312,  312,  312,    0,  310,  312,  310,
+  310,  310,  310,  310,    0,  312,  312,  312,    0,    0,
+  300,    0,  310,    0,  312,  312,  310,    0,  310,    0,
+  300,  310,  310,  310,  310,  310,  310,  310,    0,    0,
+  310,  310,  310,    0,    0,    0,    0,  310,  310,    0,
+    0,    0,  310,  310,    0,    0,    0,  300,    0,    0,
+    0,  300,  310,    0,  300,    0,  310,  310,    0,    0,
+    0,  310,    0,    0,    0,    0,    0,  310,  300,  310,
+  310,  300,  310,    0,  310,  310,  310,  310,  310,    0,
+  310,  310,  310,  310,  310,  310,  310,  310,  310,  310,
+  310,  310,  310,  310,  310,  310,    0,    0,  310,  310,
+  310,    0,  310,  310,  310,    0,  310,  310,  310,    0,
+    0,  310,    0,  310,    0,    0,  310,  310,  310,  310,
+    0,  310,  310,  310,  310,    0,    0,    0,    0,    0,
+  310,    0,    0,  310,  310,  310,  310,  310,  310,  310,
+  310,    0,  310,  310,  310,  310,  310,    0,    0,  310,
+    0,    0,    0,    0,    0,    0,  310,  310,  310,    0,
+    0,  298,    0,    0,    0,  310,  310,    0,    0,    0,
+    0,  298,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,  298,    0,
+    0,    0,  298,    0,    0,  298,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  298,
+    0,    0,  298,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  300,    0,  300,  300,
+  300,  300,  300,    0,    0,    0,    0,    0,    0,    0,
+    0,  300,    0,    0,    0,  300,    0,  300,    0,    0,
+  300,  300,  300,  300,  300,  300,  300,    0,    0,  300,
+  300,  300,    0,    0,    0,    0,  300,  300,    0,    0,
+    0,  300,  300,    0,    0,    0,    0,    0,    0,    0,
+    0,  300,    0,    0,    0,  300,  300,    0,    0,    0,
+  300,    0,    0,    0,    0,    0,  300,    0,  300,  300,
+    0,  300,    0,  300,  300,  300,  300,  300,    0,  300,
+  300,  300,  300,  300,  300,  300,  300,  300,  300,  300,
+  300,  300,  300,  300,  300,    0,    0,  300,  300,  300,
+    0,  300,  300,  300,    0,  300,  300,  300,  247,  247,
+  300,  247,  300,    0,    0,  300,  300,  300,  300,    0,
+  300,  300,  300,  300,    0,    0,  247,  247,  247,  300,
+    0,    0,  300,  300,  300,  300,  300,  300,  300,  300,
+    0,  300,  300,  300,  300,  300,    0,  298,  300,  298,
+  298,  298,  298,  298,    0,  300,  300,  300,    0,    0,
+  304,    0,  298,    0,  300,  300,  298,    0,  298,    0,
+  304,  298,  298,  298,  298,  298,  298,  298,    0,    0,
+  298,  298,  298,    0,    0,    0,    0,  298,  298,    0,
+    0,    0,  298,  298,    0,    0,    0,  304,    0,    0,
+    0,  304,  298,    0,  304,    0,  298,  298,    0,    0,
+    0,  298,    0,    0,    0,    0,    0,  298,  304,  298,
+  298,  304,  298,    0,  298,  298,  298,  298,  298,    0,
+  298,  298,  298,  298,  298,  298,  298,  298,  298,  298,
+  298,  298,  298,  298,  298,  298,    0,    0,  298,  298,
+  298,    0,  298,  298,  298,    0,  298,  298,  298,    0,
+    0,  298,    0,  298,    0,    0,  298,  298,  298,  298,
+    0,  298,  298,  298,  298,    0,    0,    0,    0,    0,
+  298,    0,    0,  298,  298,  298,  298,  298,  298,  298,
+  298,    0,  298,  298,  298,  298,  298,    0,    0,  298,
+    0,    0,    0,    0,    0,    0,  298,  298,  298,    0,
+    0,  303,    0,    0,    0,  298,  298,    0,    0,    0,
+    0,  303,    0,    0,  247,  247,  247,  247,  247,    0,
+  247,  247,  247,  247,  247,  247,    0,    0,  247,  247,
+    0,    0,    0,    0,    0,    0,    0,    0,  303,    0,
+    0,    0,  303,    0,    0,  303,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  303,
+    0,    0,  303,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  304,    0,  304,  304,
+  304,  304,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  304,    0,    0,    0,  304,    0,  304,    0,    0,
+  304,  304,  304,  304,  304,  304,  304,    0,    0,  304,
+  304,  304,    0,    0,    0,    0,  304,  304,    0,    0,
+    0,  304,  304,    0,    0,    0,    0,    0,    0,    0,
+    0,  304,    0,    0,    0,  304,  304,    0,    0,    0,
+  304,    0,    0,    0,    0,    0,  304,  567,  304,  304,
+  333,  304,  334,  304,  304,  304,  304,  304,    0,  304,
+  304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
+  304,  304,  304,  304,  304,    0,    0,  304,  304,  304,
+    0,  304,  304,  304,    0,  304,  304,  304,    0,    0,
+  304,    0,  304,    0,    0,  304,  304,  304,  304,    0,
+  304,  304,  304,  304,    0,  753,    0,  751,  150,  304,
+  151,    0,  304,  304,  304,  304,  304,  304,  304,  304,
+    0,  304,  304,  304,  304,  304,  576,  303,  304,  303,
+  303,  303,  303,    0,    0,  304,  304,  304,    0,    0,
+    0,    0,  303,    0,  304,  304,  303,    0,  303,    0,
+    0,  303,  303,  303,  303,  303,  303,  303,    0,    0,
+  303,  303,  303,    0,    0,    0,    0,  303,  303,    0,
+    0,    0,  303,  303,    0,    0,    0,    0,    0,    0,
+    0,    0,  303,    0,    0,    0,  303,  303,    0,    0,
+    0,  303,    0,    0,    0,    0,    0,  303,    0,  303,
+  303,    0,  303,    0,  303,  303,  303,  303,  303,    0,
+  303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+  303,  303,  303,  303,  303,  303,    0,    0,  303,  303,
+  303,    0,  303,  303,  303,    0,  303,  303,  303,    0,
+  338,  303,    0,  303,    0,    0,  303,  303,  303,  303,
+  338,  303,  303,  303,  303,    0,    0,    0,    0,    0,
+  303,    0,    0,  303,  303,  303,  303,  303,  303,  303,
+  303,    0,  303,  303,  303,  303,  303,  338,    0,  303,
+  338,  338,  338,  338,  338,  338,  303,  303,  303,    0,
+    0,    0,    0,    0,    0,  303,  303,    0,    0,    0,
+    0,    0,    0,    0,    0,  336,  337,  338,    0,    0,
+  339,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  149,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  752,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  292,  176,    0,    0,    0,    0,  178,  179,    0,
+    0,  292,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,    0,  340,    0,    0,    0,  292,    0,
+    0,  187,  292,    0,    0,  292,    0,    0,    0,    0,
+    0,    0,    0,    0,  177,    0,    0,    0,    0,  292,
+    0,    0,  292,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,    0,    0,    0,    0,    0,  338,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  338,  338,  338,    0,  338,    0,  338,    0,    0,
+  338,  338,  338,  338,  338,  338,  338,    0,    0,  338,
+  338,  338,    0,    0,    0,    0,  338,  338,    0,    0,
+    0,  338,  338,    0,    0,    0,    0,    0,    0,    0,
+    0,  338,    0,    0,    0,  338,  338,    0,    0,    0,
+  338,    0,    0,    0,    0,    0,  338,    0,  338,  338,
+    0,  338,    0,  338,  338,  338,  338,  338,    0,  338,
+  338,  338,  338,  338,  338,  338,  338,  338,  338,  338,
+  338,  338,  338,  338,  338,    0,    0,  338,  338,  338,
+    0,  338,  338,  338,    0,  338,  338,  338,    0,    0,
+  338,    0,  338,    0,    0,  338,  338,  338,  338,    0,
+    0,  338,  338,  338,    0,    0,    0,    0,    0,  338,
+    0,    0,  338,  338,  338,  338,  338,  338,  338,  338,
+    0,  338,  338,  338,  338,  338,    0,  292,  338,  292,
+  292,    0,    0,    0,    0,  338,  338,  338,    0,    0,
+  302,    0,  292,    0,  338,  338,  292,    0,  292,    0,
+  302,  292,  292,  292,  292,  292,  292,  292,    0,    0,
+  292,  292,  292,    0,    0,    0,    0,  292,  292,    0,
+    0,    0,  292,  292,    0,    0,    0,  302,    0,    0,
+    0,  302,  292,    0,  302,    0,  292,  292,    0,    0,
+    0,  292,    0,    0,    0,    0,    0,  292,  302,  292,
+  292,  302,  292,    0,  292,  292,  292,  292,  292,    0,
+  292,  292,  292,  292,  292,  292,  292,  292,  292,  292,
+  292,  292,  292,  292,  292,  292,    0,    0,  292,  292,
+  292,    0,  292,  292,  292,    0,  292,  292,  292,    0,
+    0,  292,    0,  292,    0,    0,  292,  292,  292,  292,
+    0,  292,  292,  292,  292,    0,    0,    0,    0,    0,
+  292,    0,    0,  292,  292,  292,  292,  292,  292,  292,
+  292,    0,  292,  292,  292,  292,  292,    0,    0,  292,
+    0,    0,    0,    0,    0,    0,  292,  292,  292,    0,
+    0,    0,    0,    0,    0,  292,  292,  501,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  501,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  501,  501,
+  501,  501,  501,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  302,    0,  302,  302,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  302,    0,    0,    0,  302,    0,  302,    0,    0,
+  302,  302,  302,  302,  302,  302,  302,    0,    0,  302,
+  302,  302,    0,    0,    0,    0,  302,  302,    0,    0,
+    0,  302,  302,    0,    0,    0,    0,    0,    0,    0,
+    0,  302,    0,    0,    0,  302,  302,    0,    0,    0,
+  302,    0,    0,    0,    0,    0,  302,    0,  302,  302,
+    0,  302,    0,  302,  302,  302,  302,  302,    0,  302,
+  302,  302,  302,  302,  302,  302,  302,  302,  302,  302,
+  302,  302,  302,  302,  302,    0,    0,  302,  302,  302,
+    0,  302,  302,  302,    0,  302,  302,  302,    0,    0,
+  302,    0,  302,    0,    0,  302,  302,  302,  302,    0,
+  302,  302,  302,  302,    0,    0,    0,    0,    0,  302,
+    0,    0,  302,  302,  302,  302,  302,  302,  302,  302,
+    0,  302,  302,  302,  302,  302,    0,    0,  302,    0,
+    0,    0,    0,  501,    0,  302,  302,  302,    0,    0,
+    0,  502,    0,    0,  302,  302,    0,    0,  501,  501,
+  501,  502,  501,    0,  501,    0,    0,  501,  501,  501,
+  501,  501,  501,  501,    0,    0,  501,  501,  501,    0,
+    0,    0,    0,  501,  501,    0,    0,    0,  501,  501,
+    0,    0,  502,  502,  502,  502,  502,    0,  501,    0,
+    0,    0,  501,  501,    0,    0,    0,  501,    0,    0,
+    0,    0,    0,  501,    0,  501,  501,    0,  501,    0,
+  501,  501,  501,  501,  501,    0,  501,  501,  501,  501,
+  501,  501,  501,  501,  501,  501,  501,  501,  501,  501,
+  501,  501,    0,    0,  501,  501,  501,    0,  501,  501,
+  501,    0,  501,  501,  501,    0,    0,  501,    0,  501,
+    0,    0,  501,  501,  501,  501,    0,    0,  501,  501,
+  501,    0,    0,    0,    0,    0,  501,    0,    0,  501,
+  501,  501,  501,  501,  501,  501,  501,    0,  501,  501,
+  501,  501,  501,    0,    0,  501,    0,    0,    0,    0,
+    0,    0,  501,  501,  501,    0,  493,    0,    0,    0,
+    0,  501,  501,    0,    0,    0,  493,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  499,  499,
+  493,  499,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  502,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  502,  502,  502,    0,  502,    0,  502,    0,
+    0,  502,  502,  502,  502,  502,  502,  502,    0,    0,
+  502,  502,  502,    0,    0,    0,    0,  502,  502,    0,
+    0,    0,  502,  502,    0,    0,    0,    0,    0,    0,
+    0,    0,  502,    0,    0,    0,  502,  502,    0,    0,
+    0,  502,    0,    0,    0,    0,    0,  502,    0,  502,
+  502,    0,  502,    0,  502,  502,  502,  502,  502,    0,
+  502,  502,  502,  502,  502,  502,  502,  502,  502,  502,
+  502,  502,  502,  502,  502,  502,    0,    0,  502,  502,
+  502,    0,  502,  502,  502,    0,  502,  502,  502,    0,
+    0,  502,    0,  502,    0,    0,  502,  502,  502,  502,
+    0,    0,  502,  502,  502,    0,    0,    0,    0,    0,
+  502,    0,    0,  502,  502,  502,  502,  502,  502,  502,
+  502,    0,  502,  502,  502,  502,  502,    0,    0,  502,
+    0,    0,  493,    0,    0,    0,  502,  502,    0,    0,
+  507,    0,    0,    0,    0,  502,  502,  499,  499,  499,
+  507,  493,    0,  493,    0,    0,  493,  493,  493,  493,
+  493,  493,  493,    0,    0,  493,  493,  493,    0,    0,
+    0,    0,  493,  493,    0,    0,    0,  493,  493,    0,
+    0,  507,  507,  507,  507,  507,    0,  493,    0,    0,
+    0,  493,  493,    0,    0,    0,  493,    0,    0,    0,
+    0,    0,  493,    0,  493,  493,    0,  493,    0,  493,
+  493,  493,  493,  493,    0,  493,  493,  493,  493,  493,
+  493,  493,  493,  493,  493,  493,  493,  493,  493,  493,
+  493,    0,    0,  493,  493,  493,    0,  493,  493,  493,
+    0,  493,  493,  493,    0,    0,  493,    0,  493,    0,
+    0,  493,  493,  493,  493,    0,    0,  493,  493,  493,
+    0,    0,    0,    0,    0,  493,    0,    0,  493,  493,
+  493,  493,  493,  493,  493,  493,    0,  493,  493,  493,
+  493,  493,    0,    0,  493,    0,    0,    0,    0,    0,
+    0,  493,  493,  493,    0,  504,    0,    0,    0,    0,
+  493,  493,    0,    0,    0,  504,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  504,  504,  504,  504,
+  504,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  507,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  507,  507,    0,    0,  507,    0,  507,    0,    0,
+  507,  507,  507,  507,  507,  507,  507,    0,    0,  507,
+  507,  507,    0,    0,    0,    0,  507,  507,    0,    0,
+    0,  507,  507,    0,    0,    0,    0,    0,    0,    0,
+    0,  507,    0,    0,    0,  507,  507,    0,    0,    0,
+  507,    0,    0,    0,    0,    0,  507,    0,  507,  507,
+    0,  507,    0,  507,  507,  507,  507,  507,    0,  507,
+  507,  507,  507,  507,  507,  507,  507,  507,  507,  507,
+  507,  507,  507,  507,  507,    0,    0,  507,  507,  507,
+    0,  507,  507,  507,    0,  507,  507,  507,    0,    0,
+  507,    0,  507,    0,    0,  507,  507,  507,  507,    0,
+    0,  507,  507,  507,    0,    0,    0,    0,    0,  507,
+    0,    0,  507,  507,  507,  507,  507,  507,  507,  507,
+    0,  507,  507,  507,  507,  507,    0,    0,  507,    0,
+    0,  504,    0,    0,    0,  507,  507,  507,  505,    0,
+    0,    0,    0,    0,  507,  507,  504,  504,  505,    0,
+  504,    0,  504,    0,    0,  504,  504,  504,  504,  504,
+  504,  504,    0,    0,  504,  504,  504,    0,    0,    0,
+    0,  504,  504,    0,    0,    0,  504,  504,    0,  505,
+  505,  505,  505,  505,    0,    0,  504,    0,    0,    0,
+  504,  504,    0,    0,    0,  504,    0,    0,    0,    0,
+    0,  504,    0,  504,  504,    0,  504,    0,  504,  504,
+  504,  504,  504,    0,  504,  504,  504,  504,  504,  504,
+  504,  504,  504,  504,  504,  504,  504,  504,  504,  504,
+    0,    0,  504,  504,  504,    0,  504,  504,  504,    0,
+  504,  504,  504,    0,    0,  504,    0,  504,    0,    0,
+  504,  504,  504,  504,    0,    0,  504,  504,  504,    0,
+    0,    0,    0,    0,  504,    0,    0,  504,  504,  504,
+  504,  504,  504,  504,  504,    0,  504,  504,  504,  504,
+  504,    0,    0,  504,    0,    0,    0,    0,    0,    0,
+  504,  504,  504,  506,    0,    0,    0,    0,    0,  504,
+  504,    0,    0,  506,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  506,  506,  506,  506,  506,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  505,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  505,
+  505,    0,    0,  505,    0,  505,    0,    0,  505,  505,
+  505,  505,  505,  505,  505,    0,    0,  505,  505,  505,
+    0,    0,    0,    0,  505,  505,    0,    0,    0,  505,
+  505,    0,    0,    0,    0,    0,    0,    0,    0,  505,
+    0,    0,    0,  505,  505,    0,    0,    0,  505,    0,
+    0,    0,    0,    0,  505,    0,  505,  505,    0,  505,
+    0,  505,  505,  505,  505,  505,    0,  505,  505,  505,
+  505,  505,  505,  505,  505,  505,  505,  505,  505,  505,
+  505,  505,  505,    0,    0,  505,  505,  505,    0,  505,
+  505,  505,    0,  505,  505,  505,    0,    0,  505,    0,
+  505,    0,    0,  505,  505,  505,  505,    0,    0,  505,
+  505,  505,    0,    0,    0,    0,    0,  505,    0,    0,
+  505,  505,  505,  505,  505,  505,  505,  505,    0,  505,
+  505,  505,  505,  505,    0,    0,  505,    0,    0,  506,
+    0,    0,    0,  505,  505,  505,  313,    0,    0,    0,
+    0,    0,  505,  505,  506,  506,  313,    0,  506,    0,
+  506,    0,    0,  506,  506,  506,  506,  506,  506,  506,
+    0,    0,  506,  506,  506,    0,    0,    0,    0,  506,
+  506,    0,    0,  313,  506,  506,    0,  313,    0,    0,
+  313,    0,    0,    0,  506,    0,    0,    0,  506,  506,
+    0,    0,    0,  506,  313,    0,    0,    0,    0,  506,
+    0,  506,  506,    0,  506,    0,  506,  506,  506,  506,
+  506,    0,  506,  506,  506,  506,  506,  506,  506,  506,
+  506,  506,  506,  506,  506,  506,  506,  506,    0,    0,
+  506,  506,  506,    0,  506,  506,  506,    0,  506,  506,
+  506,    0,    0,  506,    0,  506,    0,    0,  506,  506,
+  506,  506,    0,    0,  506,  506,  506,    0,    0,    0,
+    0,    0,  506,    0,    0,  506,  506,  506,  506,  506,
+  506,  506,  506,    0,  506,  506,  506,  506,  506,    0,
+    0,  506,    0,    0,    0,    0,    0,    0,  506,  506,
+  506,  309,    0,    0,    0,    0,    0,  506,  506,    0,
+    0,  309,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  309,    0,
+    0,    0,  309,    0,    0,  309,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  309,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  313,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  313,    0,    0,
+    0,  313,    0,  313,    0,    0,  313,  313,  313,  313,
+  313,  313,  313,    0,    0,  313,  313,  313,    0,    0,
+    0,    0,  313,  313,    0,    0,    0,  313,  313,    0,
+    0,    0,    0,    0,    0,    0,    0,  313,    0,    0,
+    0,  313,  313,    0,    0,    0,  313,    0,    0,    0,
+    0,    0,  313,    0,  313,  313,    0,  313,    0,  313,
+  313,  313,  313,  313,    0,  313,  313,  313,  313,  313,
+  313,  313,  313,  313,  313,  313,  313,  313,  313,  313,
+  313,    0,    0,  313,  313,  313,    0,  313,  313,  313,
+    0,  313,  313,  313,    0,  503,  313,    0,  313,    0,
+    0,  313,  313,  313,  313,  503,  313,  313,  313,  313,
+    0,    0,    0,    0,    0,  313,    0,    0,  313,  313,
+  313,  313,  313,  313,  313,  313,    0,  313,  313,  313,
+  313,  313,    0,    0,  313,    0,  503,  309,  503,  503,
+  503,  313,  313,  313,    0,    0,    0,    0,    0,    0,
+  313,  313,  309,    0,    0,    0,  309,    0,  309,    0,
+    0,  309,  309,  309,  309,  309,  309,  309,    0,    0,
+  309,  309,  309,    0,    0,    0,    0,  309,  309,    0,
+    0,    0,  309,  309,    0,    0,    0,    0,    0,    0,
+    0,    0,  309,    0,    0,    0,  309,  309,    0,    0,
+    0,  309,    0,    0,    0,    0,    0,  309,    0,  309,
+  309,    0,  309,    0,  309,  309,  309,  309,  309,    0,
+  309,  309,  309,  309,  309,  309,  309,  309,  309,  309,
+  309,  309,  309,  309,  309,  309,    0,    0,  309,  309,
+  309,    0,  309,  309,  309,    0,  309,  309,  309,    0,
+  509,  309,    0,  309,    0,    0,  309,  309,  309,  309,
+  509,  309,  309,  309,  309,    0,    0,    0,    0,    0,
+  309,    0,    0,  309,  309,  309,  309,  309,  309,  309,
+  309,    0,  309,  309,  309,  309,  309,    0,    0,  309,
+    0,  509,    0,    0,  509,    0,  309,  309,  309,    0,
+    0,    0,    0,    0,    0,  309,  309,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  503,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  503,    0,    0,    0,
+  503,    0,  503,    0,    0,  503,  503,  503,  503,  503,
+  503,  503,    0,    0,  503,  503,  503,    0,    0,    0,
+    0,  503,  503,    0,    0,    0,  503,  503,    0,    0,
+    0,    0,    0,    0,    0,    0,  503,    0,    0,    0,
+  503,  503,    0,    0,    0,  503,    0,    0,    0,    0,
+    0,  503,    0,  503,  503,    0,  503,    0,  503,  503,
+  503,  503,  503,    0,  503,  503,  503,  503,  503,  503,
+  503,  503,  503,  503,  503,  503,  503,  503,  503,  503,
+    0,    0,  503,  503,  503,    0,  503,  503,  503,    0,
+  503,  503,  503,    0,  512,  503,    0,  503,    0,    0,
+  503,  503,  503,  503,  512,    0,  503,  503,  503,    0,
+    0,    0,    0,    0,  503,    0,    0,  503,  503,  503,
+  503,  503,  503,  503,  503,    0,  503,  503,  503,  503,
+  503,    0,    0,  503,    0,  512,  509,    0,  512,    0,
+  503,  503,  503,    0,    0,    0,    0,    0,    0,  503,
+  503,  509,    0,    0,    0,  509,    0,  509,    0,    0,
+  509,  509,  509,  509,  509,  509,  509,    0,    0,  509,
+  509,  509,    0,    0,    0,    0,  509,  509,    0,    0,
+    0,  509,  509,    0,    0,    0,    0,    0,    0,    0,
+    0,  509,    0,    0,    0,  509,  509,    0,    0,    0,
+  509,    0,    0,    0,    0,    0,  509,    0,  509,  509,
+    0,  509,    0,  509,  509,  509,  509,  509,    0,  509,
+  509,  509,  509,  509,  509,  509,  509,  509,  509,  509,
+  509,  509,  509,  509,  509,    0,    0,  509,  509,  509,
+    0,  509,  509,  509,    0,  509,  509,  509,    0,  511,
+  509,    0,  509,    0,    0,  509,  509,  509,  509,  511,
+    0,  509,  509,  509,    0,    0,    0,    0,    0,  509,
+    0,    0,  509,  509,  509,  509,  509,  509,  509,  509,
+    0,  509,  509,  509,  509,  509,    0,    0,  509,    0,
+  511,    0,    0,  511,    0,  509,  509,  509,    0,    0,
+    0,    0,    0,    0,  509,  509,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  512,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  512,    0,    0,    0,  512,
+    0,  512,    0,    0,  512,  512,  512,  512,  512,  512,
+  512,    0,    0,  512,  512,  512,    0,    0,    0,    0,
+  512,  512,    0,    0,    0,  512,  512,    0,    0,    0,
+    0,    0,    0,    0,    0,  512,    0,    0,    0,  512,
+  512,    0,    0,    0,  512,    0,    0,    0,    0,    0,
+  512,    0,  512,  512,    0,  512,    0,  512,  512,  512,
+  512,  512,    0,  512,  512,  512,  512,  512,  512,  512,
+  512,  512,  512,  512,  512,  512,  512,  512,  512,    0,
+    0,  512,  512,  512,    0,  512,  512,  512,    0,  512,
+  512,  512,    0,  510,  512,    0,  512,    0,    0,  512,
+  512,  512,  512,  510,    0,  512,  512,  512,    0,    0,
+    0,    0,    0,  512,    0,    0,  512,  512,  512,  512,
+  512,  512,  512,  512,    0,  512,  512,  512,  512,  512,
+    0,    0,  512,    0,  510,  511,    0,  510,    0,  512,
+  512,  512,    0,    0,    0,    0,    0,    0,  512,  512,
+  511,    0,    0,    0,  511,    0,  511,    0,    0,  511,
+  511,  511,  511,  511,  511,  511,    0,    0,  511,  511,
+  511,    0,    0,    0,    0,  511,  511,    0,    0,    0,
+  511,  511,    0,    0,    0,    0,    0,    0,    0,    0,
+  511,    0,    0,    0,  511,  511,    0,    0,    0,  511,
+    0,    0,    0,    0,    0,  511,    0,  511,  511,    0,
+  511,    0,  511,  511,  511,  511,  511,    0,  511,  511,
+  511,  511,  511,  511,  511,  511,  511,  511,  511,  511,
+  511,  511,  511,  511,    0,    0,  511,  511,  511,    0,
+  511,  511,  511,    0,  511,  511,  511,    0,  236,  511,
+    0,  511,    0,    0,  511,  511,  511,  511,  236,    0,
+  511,  511,  511,    0,    0,    0,    0,    0,  511,    0,
+    0,  511,  511,  511,  511,  511,  511,  511,  511,    0,
+  511,  511,  511,  511,  511,    0,    0,  511,    0,    0,
+  236,    0,  236,    0,  511,  511,  511,    0,    0,    0,
+    0,    0,    0,  511,  511,    0,    0,    0,    0,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  510,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  510,    0,    0,    0,  510,    0,
+  510,    0,    0,  510,  510,  510,  510,  510,  510,  510,
+    0,    0,  510,  510,  510,    0,    0,    0,    0,  510,
+  510,    0,    0,    0,  510,  510,    0,    0,    0,    0,
+    0,    0,    0,    0,  510,    0,    0,    0,  510,  510,
+    0,    0,    0,  510,    0,    0,    0,    0,    0,  510,
+    0,  510,  510,    0,  510,    0,  510,  510,  510,  510,
+  510,    0,  510,  510,  510,  510,  510,  510,  510,  510,
+  510,  510,  510,  510,  510,  510,  510,  510,    0,    0,
+  510,  510,  510,    0,  510,  510,  510,    0,  510,  510,
+  510,    0,  513,  510,    0,  510,    0,    0,  510,  510,
+  510,  510,  513,    0,  510,  510,  510,    0,    0,    0,
+    0,    0,  510,    0,    0,  510,  510,  510,  510,  510,
+  510,  510,  510,    0,  510,  510,  510,  510,  510,    0,
+    0,  510,    0,  513,  236,    0,  513,    0,  510,  510,
+  510,    0,    0,    0,    0,    0,    0,  510,  510,    0,
+    0,    0,    0,  236,    0,  236,    0,    0,  236,  236,
+  236,  236,  236,  236,  236,    0,    0,  236,  236,  236,
+    0,    0,    0,    0,  236,  236,    0,    0,    0,  236,
+  236,    0,    0,    0,    0,    0,    0,    0,    0,  236,
+    0,    0,    0,  236,  236,    0,    0,    0,  236,    0,
+    0,    0,    0,    0,  236,    0,  236,  236,    0,  236,
+    0,  236,  236,  236,  236,  236,    0,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,  236,    0,    0,  236,  236,  236,    0,  236,
+  236,  236,    0,  236,  236,  236,    0,  508,  236,    0,
+  236,    0,    0,  236,  236,  236,  236,  508,    0,  236,
+  236,  236,    0,    0,    0,    0,    0,  236,    0,    0,
+  236,  236,  236,  236,  236,  236,  236,  236,    0,  236,
+  236,  236,  236,  236,    0,    0,  236,    0,  508,    0,
+    0,  508,    0,  236,  236,  236,    0,    0,    0,    0,
+    0,    0,  236,  236,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  513,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  513,    0,    0,    0,  513,    0,  513,
+    0,    0,  513,  513,  513,  513,  513,  513,  513,    0,
+    0,  513,  513,  513,    0,    0,    0,    0,  513,  513,
+    0,    0,    0,  513,  513,    0,    0,    0,    0,    0,
+    0,    0,    0,  513,   57,    0,    0,  513,  513,    0,
+    0,    0,  513,    0,   57,    0,    0,    0,  513,    0,
+  513,  513,    0,  513,    0,  513,  513,  513,  513,  513,
+    0,  513,  513,  513,  513,  513,  513,  513,  513,  513,
+  513,  513,  513,  513,  513,  513,  513,    0,    0,  513,
+  513,  513,    0,  513,  513,  513,    0,  513,  513,  513,
+    0,    0,  513,    0,  513,    0,    0,  513,  513,  513,
+  513,    0,    0,  513,  513,  513,    0,    0,    0,    0,
+    0,  513,    0,    0,  513,  513,  513,  513,  513,  513,
+  513,  513,    0,  513,  513,  513,  513,  513,    0,    0,
+  513,    0,    0,  508,    0,    0,    0,  513,  513,  513,
+    0,    0,    0,    0,    0,    0,  513,  513,  508,    0,
+    0,    0,  508,    0,  508,    0,    0,  508,  508,  508,
+  508,  508,  508,  508,    0,    0,  508,  508,  508,    0,
+    0,    0,    0,  508,  508,    0,    0,    0,  508,  508,
+    0,    0,    0,    0,    0,  142,    0,    0,  508,    0,
+    0,    0,  508,  508,    0,  142,    0,  508,    0,    0,
+    0,    0,    0,  508,    0,  508,  508,    0,  508,    0,
+  508,  508,  508,  508,  508,    0,  508,  508,  508,  508,
+  508,  508,  508,  508,  508,  508,  508,  508,  508,  508,
+  508,  508,    0,    0,  508,  508,  508,    0,  508,  508,
+  508,    0,  508,  508,  508,    0,    0,  508,    0,  508,
+    0,    0,  508,  508,  508,  508,    0,    0,  508,  508,
+  508,    0,    0,    0,    0,    0,  508,    0,    0,  508,
+  508,  508,  508,  508,  508,  508,  508,    0,  508,  508,
+  508,  508,  508,    0,    0,  508,    0,    0,    0,    0,
+   57,    0,  508,  508,  508,    0,    0,    0,    0,    0,
+    0,  508,  508,    0,    0,  164,  164,    0,    0,   57,
+    0,   57,    0,    0,   57,   57,   57,   57,   57,   57,
+   57,    0,    0,   57,   57,   57,    0,    0,    0,    0,
+   57,   57,    0,    0,    0,   57,   57,    0,    0,    0,
+    0,    0,    0,    0,    0,   57,    0,    0,    0,   57,
+   57,    0,    0,    0,   57,    0,    0,    0,    0,    0,
+   57,    0,   57,   57,    0,   57,    0,   57,   57,   57,
+   57,   57,    0,   57,   57,   57,   57,   57,   57,   57,
+   57,   57,   57,   57,   57,   57,   57,   57,   57,    0,
+    0,   57,   57,   57,    0,   57,   57,   57,    0,   57,
+   57,   57,    0,  355,   57,    0,   57,    0,    0,   57,
+   57,   57,   57,  355,    0,   57,   57,   57,    0,    0,
+    0,    0,    0,   57,    0,    0,   57,   57,   57,   57,
+   57,   57,   57,   57,    0,   57,   57,   57,   57,   57,
+    0,  142,   57,    0,  355,    0,    0,    0,    0,   57,
+   57,   57,    0,    0,    0,    0,  164,  164,   57,   57,
+  142,  355,  142,    0,    0,  142,  142,  142,  142,  142,
+  142,  142,    0,    0,  142,  142,  142,    0,    0,    0,
+    0,  142,  142,    0,    0,    0,  142,  142,    0,    0,
+    0,    0,    0,    0,    0,    0,  142,    0,    0,    0,
+  142,  142,    0,    0,    0,  142,    0,    0,    0,    0,
+    0,  142,    0,  142,  142,    0,  142,    0,  142,  142,
+  142,  142,  142,    0,  142,  142,  142,  142,  142,  142,
+  142,  142,  142,  142,  142,  142,  142,  142,  142,  142,
+    0,    0,  142,  142,  142,    0,  142,  142,  142,    0,
+  142,  142,  142,    0,  125,  142,    0,  142,    0,    0,
+  142,  142,  142,  142,  125,    0,  142,  142,  142,    0,
+    0,    0,    0,    0,  142,    0,    0,  142,  142,  142,
+  142,  142,  142,  142,  142,    0,  142,  142,  142,  142,
+  142,    0,    0,  142,    0,    0,    0,    0,  125,    0,
+  142,  142,  142,    0,    0,    0,    0,    0,    0,  142,
+  142,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  355,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  355,    0,
+  355,    0,    0,  355,  355,  355,  355,  355,  355,  355,
+    0,    0,  355,  355,  355,    0,    0,    0,    0,  355,
+  355,    0,    0,    0,  355,  355,    0,    0,    0,    0,
+  154,    0,    0,    0,  355,    0,    0,    0,  355,  355,
+  154,    0,    0,  355,    0,    0,    0,    0,    0,  355,
+    0,  355,  355,    0,  355,    0,  355,  355,  355,  355,
+  355,    0,  355,  355,  355,  355,  355,  355,  355,  355,
+  355,  355,  355,  355,  355,  355,  355,  355,    0,    0,
+  355,  355,  355,    0,  355,  355,  355,    0,  355,  355,
+  355,    0,    0,  355,    0,  355,    0,    0,  355,  355,
+  355,  355,    0,    0,  355,  355,  355,    0,    0,    0,
+    0,    0,  355,    0,    0,  355,  355,  355,  355,  355,
+  355,  355,  355,    0,  355,  355,  355,  355,  355,    0,
+  125,  355,    0,    0,    0,    0,    0,    0,  355,  355,
+  355,    0,    0,    0,    0,  125,  125,  355,  355,  125,
+    0,  125,    0,    0,  125,  125,  125,  125,  125,  125,
+  125,    0,    0,  125,  125,  125,    0,    0,    0,    0,
+  125,  125,    0,    0,    0,  125,  125,    0,    0,    0,
+    0,    0,    0,    0,    0,  125,    0,    0,    0,  125,
+  125,    0,    0,    0,  125,    0,    0,    0,    0,    0,
+  125,    0,  125,  125,    0,  125,    0,  125,  125,  125,
+  125,  125,    0,  125,  125,  125,  125,  125,  125,  125,
+  125,  125,  125,  125,  125,  125,  125,  125,  125,    0,
+    0,  125,  125,  125,    0,  125,  125,  125,    0,  125,
+  125,  125,    0,  236,  125,    0,  125,    0,    0,  125,
+  125,  125,  125,  236,    0,  125,  125,  125,    0,    0,
+    0,    0,    0,  125,    0,    0,  125,  125,  125,  125,
+  125,  125,  125,  125,    0,  125,  125,  125,  125,  125,
+    0,    0,  125,    0,    0,  236,  154,  236,    0,  125,
+  125,    0,    0,    0,    0,    0,    0,    0,  125,  125,
+    0,  154,  154,    0,    0,  154,    0,  154,    0,    0,
+  154,  154,  154,  154,  154,  154,  154,    0,    0,  154,
+  154,  154,    0,    0,    0,    0,  154,  154,    0,    0,
+    0,  154,  154,    0,    0,    0,    0,    0,    0,    0,
+    0,  154,    0,    0,    0,  154,  154,    0,    0,    0,
+  154,    0,    0,    0,    0,    0,  154,    0,  154,  154,
+    0,  154,    0,  154,  154,  154,  154,  154,    0,  154,
+  154,  154,  154,  154,  154,  154,  154,  154,  154,  154,
+  154,  154,  154,  154,  154,    0,    0,  154,  154,  154,
+    0,  154,  154,  154,  164,  154,  154,  154,    0,    0,
+  154,    0,  154,    0,  164,  154,  154,  154,  154,    0,
+    0,  154,  154,  154,    0,    0,    0,    0,    0,  154,
+    0,    0,  154,  154,  154,  154,  154,  154,  154,  154,
+    0,  154,  154,  154,  154,  154,    0,    0,  154,    0,
+    0,    0,    0,    0,    0,  154,  154,  154,    0,    0,
+    0,    0,    0,    0,  154,  154,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  236,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  236,    0,
+  236,    0,    0,  236,  236,  236,  236,  236,  236,  236,
+    0,    0,  236,  236,  236,    0,    0,    0,    0,  236,
+  236,    0,    0,    0,  236,  236,    0,    0,    0,    0,
+  155,    0,    0,    0,  236,    0,    0,    0,  236,  236,
+  155,    0,    0,  236,    0,    0,    0,    0,    0,  236,
+    0,  236,  236,    0,  236,    0,  236,  236,  236,  236,
+  236,    0,  236,  236,  236,  236,  236,  236,  236,  236,
+  236,  236,  236,  236,  236,  236,  236,  236,    0,    0,
+  236,  236,  236,    0,  236,  236,  236,    0,  236,  236,
+  236,    0,    0,  236,    0,  236,    0,    0,  236,  236,
+  236,  236,    0,    0,  236,  236,  236,    0,    0,    0,
+    0,    0,  236,    0,    0,  236,  236,  236,  236,  236,
+  236,  236,  236,    0,  236,  236,  236,  236,  236,    0,
+  164,  236,    0,    0,    0,    0,    0,    0,  236,  236,
+  236,    0,    0,    0,    0,  164,  164,  236,  236,  164,
+    0,  164,    0,    0,  164,  164,  164,  164,  164,  164,
+  164,    0,    0,  164,  164,  164,    0,    0,    0,    0,
+  164,  164,    0,    0,    0,  164,  164,    0,    0,    0,
+    0,    0,    0,    0,    0,  164,    0,    0,    0,  164,
+  164,    0,    0,    0,  164,    0,    0,    0,    0,    0,
+  164,    0,  164,  164,    0,  164,    0,  164,  164,  164,
+  164,  164,    0,  164,  164,  164,  164,  164,  164,  164,
+  164,  164,  164,  164,  164,  164,  164,  164,  164,    0,
+    0,  164,  164,  164,    0,  164,  164,  164,    0,  164,
+  164,  164,    0,  525,  164,    0,  164,    0,    0,  164,
+  164,  164,  164,  525,    0,  164,  164,  164,    0,    0,
+    0,    0,    0,  164,    0,    0,  164,  164,  164,  164,
+  164,  164,  164,  164,    0,  164,  164,  164,  164,  164,
+    0,    0,  164,    0,  525,    0,  155,  525,    0,  164,
+  164,  164,    0,    0,    0,    0,    0,    0,  164,  164,
+    0,  155,  155,    0,    0,  155,    0,  155,    0,    0,
+  155,  155,  155,  155,  155,  155,  155,    0,    0,  155,
+  155,  155,    0,    0,    0,    0,  155,  155,    0,    0,
+    0,  155,  155,    0,    0,    0,    0,    0,    0,    0,
+    0,  155,    0,    0,    0,  155,  155,    0,    0,    0,
+  155,    0,    0,    0,    0,    0,  155,    0,  155,  155,
+    0,  155,    0,  155,  155,  155,  155,  155,    0,  155,
+  155,  155,  155,  155,  155,  155,  155,  155,  155,  155,
+  155,  155,  155,  155,  155,    0,    0,  155,  155,  155,
+    0,  155,  155,  155,    0,  155,  155,  155,    0,  168,
+  155,    0,  155,    0,    0,  155,  155,  155,  155,  168,
+    0,  155,  155,  155,    0,    0,    0,    0,    0,  155,
+    0,    0,  155,  155,  155,  155,  155,  155,  155,  155,
+    0,  155,  155,  155,  155,  155,    0,    0,  155,    0,
+  168,    0,    0,  168,    0,  155,  155,  155,    0,    0,
+    0,    0,    0,    0,  155,  155,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  525,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  525,    0,
+  525,    0,    0,  525,  525,  525,  525,  525,  525,  525,
+    0,    0,  525,  525,  525,    0,    0,    0,    0,  525,
+  525,    0,    0,    0,  525,  525,    0,    0,    0,    0,
+    0,    0,    0,    0,  525,    0,    0,    0,  525,  525,
+    0,    0,    0,  525,    0,    0,    0,    0,    0,  525,
+    0,  525,  525,    0,  525,    0,  525,  525,  525,  525,
+  525,    0,  525,  525,  525,  525,  525,  525,  525,  525,
+  525,  525,  525,  525,  525,  525,  525,  525,    0,    0,
+  525,  525,  525,    0,  525,  525,  525,    0,  525,  525,
+  525,    0,  523,  525,    0,  525,    0,    0,  525,  525,
+  525,  525,  523,    0,  525,  525,  525,    0,    0,    0,
+    0,    0,  525,    0,    0,  525,  525,  525,  525,  525,
+  525,  525,  525,    0,  525,  525,  525,  525,  525,    0,
+    0,  525,    0,  523,    0,  168,  523,    0,  525,  525,
+  525,    0,    0,    0,    0,    0,    0,  525,  525,    0,
+    0,    0,    0,    0,  168,    0,  168,    0,    0,  168,
+  168,  168,  168,  168,  168,  168,    0,    0,  168,  168,
+  168,    0,    0,    0,    0,  168,  168,    0,    0,    0,
+  168,  168,    0,    0,    0,    0,    0,    0,    0,    0,
+  168,    0,    0,    0,  168,  168,    0,    0,    0,  168,
+    0,    0,    0,    0,    0,  168,    0,  168,  168,    0,
+  168,    0,  168,  168,  168,  168,  168,    0,  168,  168,
+  168,  168,  168,  168,  168,  168,  168,  168,  168,  168,
+  168,  168,  168,  168,    0,    0,  168,  168,  168,    0,
+  168,  168,  168,    0,  168,  168,  168,    0,  522,  168,
+    0,  168,    0,    0,  168,  168,  168,  168,  522,    0,
+  168,  168,  168,    0,    0,    0,    0,    0,  168,    0,
+    0,  168,  168,  168,  168,  168,  168,  168,  168,    0,
+  168,  168,  168,  168,  168,    0,    0,  168,    0,  522,
+    0,    0,  522,    0,  168,  168,  168,    0,    0,    0,
+    0,    0,    0,  168,  168,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  523,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  523,    0,  523,
+    0,    0,  523,  523,  523,  523,  523,  523,  523,    0,
+    0,  523,  523,  523,    0,    0,    0,    0,  523,  523,
+    0,    0,    0,  523,  523,    0,    0,    0,    0,    0,
+    0,    0,    0,  523,    0,    0,    0,  523,  523,    0,
+    0,    0,  523,    0,    0,    0,    0,    0,  523,    0,
+  523,  523,    0,  523,    0,  523,  523,  523,  523,  523,
+    0,  523,  523,  523,  523,  523,  523,  523,  523,  523,
+  523,  523,  523,  523,  523,  523,  523,    0,    0,  523,
+  523,  523,    0,  523,  523,  523,    0,  523,  523,  523,
+    0,  520,  523,    0,  523,    0,    0,  523,  523,  523,
+  523,  520,    0,  523,  523,  523,    0,    0,    0,    0,
+    0,  523,    0,    0,  523,  523,  523,  523,  523,  523,
+  523,  523,    0,  523,  523,  523,  523,  523,    0,    0,
+  523,    0,  520,    0,  522,  520,    0,  523,  523,  523,
+    0,    0,    0,    0,    0,    0,  523,  523,    0,    0,
+    0,    0,    0,  522,    0,  522,    0,    0,  522,  522,
+  522,  522,  522,  522,  522,    0,    0,  522,  522,  522,
+    0,    0,    0,    0,  522,  522,    0,    0,    0,  522,
+  522,    0,    0,    0,    0,    0,    0,    0,    0,  522,
+    0,    0,    0,  522,  522,    0,    0,    0,  522,    0,
+    0,    0,    0,    0,  522,    0,  522,  522,    0,  522,
+    0,  522,  522,  522,  522,  522,    0,  522,  522,  522,
+  522,  522,  522,  522,  522,  522,  522,  522,  522,  522,
+  522,  522,  522,    0,    0,  522,  522,  522,    0,  522,
+  522,  522,    0,  522,  522,  522,    0,  531,  522,    0,
+  522,    0,    0,  522,  522,  522,  522,  531,    0,  522,
+  522,  522,    0,    0,    0,    0,    0,  522,    0,    0,
+  522,  522,  522,  522,  522,  522,  522,  522,    0,  522,
+  522,  522,  522,  522,    0,    0,  522,    0,    0,    0,
+    0,  531,    0,  522,  522,  522,    0,    0,    0,    0,
+    0,    0,  522,  522,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  520,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  520,    0,  520,    0,
+    0,  520,  520,  520,  520,  520,  520,  520,    0,    0,
+  520,  520,  520,    0,    0,    0,    0,  520,  520,    0,
+    0,    0,  520,  520,    0,    0,    0,    0,    0,    0,
+    0,    0,  520,  535,    0,    0,  520,  520,    0,    0,
+    0,  520,    0,  535,    0,    0,    0,  520,    0,  520,
+  520,    0,  520,    0,  520,  520,  520,  520,  520,    0,
+  520,  520,  520,  520,  520,  520,  520,  520,  520,  520,
+  520,  520,  520,  520,  520,  520,    0,  535,  520,  520,
+  520,    0,  520,  520,  520,    0,  520,  520,  520,    0,
+    0,  520,    0,  520,    0,    0,  520,  520,  520,  520,
+    0,    0,  520,  520,  520,    0,    0,    0,    0,    0,
+  520,    0,    0,  520,  520,  520,  520,  520,  520,  520,
+  520,    0,  520,  520,  520,  520,  520,    0,    0,  520,
+    0,    0,    0,  531,    0,    0,  520,  520,  520,    0,
+    0,    0,    0,    0,    0,  520,  520,    0,    0,    0,
+    0,    0,  531,    0,  531,    0,    0,  531,  531,  531,
+  531,  531,  531,  531,    0,    0,  531,  531,  531,    0,
+    0,    0,    0,  531,  531,    0,    0,    0,  531,  531,
+    0,    0,    0,    0,    0,    0,    0,    0,  531,  533,
+    0,    0,  531,  531,    0,    0,    0,  531,    0,  533,
+    0,    0,    0,  531,    0,  531,  531,    0,  531,    0,
+  531,  531,  531,  531,  531,    0,  531,  531,  531,  531,
+  531,  531,  531,  531,  531,  531,  531,  531,  531,  531,
+  531,  531,    0,  533,  531,  531,  531,    0,  531,  531,
+  531,    0,  531,  531,  531,    0,    0,  531,    0,  531,
+    0,    0,  531,  531,  531,  531,    0,  531,  531,  531,
+  531,    0,    0,    0,    0,    0,  531,    0,    0,  531,
+  531,  531,  531,  531,  531,  531,  531,    0,  531,  531,
+  531,  531,  531,    0,    0,  531,    0,    0,    0,  535,
+    0,    0,  531,  531,  531,    0,    0,    0,    0,    0,
+    0,  531,  531,    0,    0,    0,    0,    0,  535,    0,
+  535,    0,    0,  535,  535,  535,  535,  535,  535,  535,
+    0,    0,  535,  535,  535,    0,    0,    0,    0,  535,
+  535,    0,    0,    0,  535,  535,    0,    0,    0,    0,
+    0,    0,    0,    0,  535,  198,    0,    0,  535,  535,
+    0,    0,    0,  535,    0,  198,    0,    0,    0,  535,
+    0,  535,  535,    0,  535,    0,  535,  535,  535,  535,
+  535,    0,  535,  535,  535,  535,  535,  535,  535,  535,
+  535,  535,  535,  535,  535,  535,  535,  535,    0,  198,
+  535,  535,  535,    0,  535,  535,  535,    0,  535,  535,
+  535,    0,    0,  535,    0,  535,  198,    0,  535,  535,
+  535,  535,    0,  535,  535,  535,  535,    0,    0,    0,
+    0,    0,  535,    0,    0,  535,  535,  535,  535,  535,
+  535,  535,  535,    0,  535,  535,  535,  535,  535,    0,
+    0,  535,    0,    0,    0,  533,    0,    0,  535,  535,
+  535,    0,    0,    0,    0,    0,    0,  535,  535,    0,
+    0,    0,    0,    0,  533,    0,  533,    0,    0,  533,
+  533,  533,  533,  533,  533,  533,    0,    0,  533,  533,
+  533,    0,    0,    0,    0,  533,  533,    0,    0,    0,
+  533,  533,    0,    0,    0,    0,  156,    0,    0,    0,
+  533,    0,    0,    0,  533,  533,  156,    0,    0,  533,
+    0,    0,    0,    0,    0,  533,    0,  533,  533,    0,
+  533,    0,  533,  533,  533,  533,  533,    0,  533,  533,
+  533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+  533,  533,  533,  533,    0,    0,  533,  533,  533,    0,
+  533,  533,  533,    0,  533,  533,  533,    0,    0,  533,
+    0,  533,    0,    0,  533,  533,  533,  533,    0,  533,
+  533,  533,  533,    0,    0,    0,    0,    0,  533,    0,
+    0,  533,  533,  533,  533,  533,  533,  533,  533,    0,
+  533,  533,  533,  533,  533,    0,    0,  533,    0,    0,
+    0,  198,    0,    0,  533,  533,  533,    0,    0,    0,
+    0,    0,    0,  533,  533,    0,    0,    0,    0,    0,
+  198,    0,  198,    0,    0,  198,  198,  198,  198,  198,
+  198,  198,    0,    0,  198,  198,  198,    0,    0,    0,
+    0,  198,  198,    0,    0,    0,  198,  198,    0,    0,
+    0,    0,    0,    0,    0,    0,  198,    0,    0,    0,
+  198,  198,    0,    0,    0,  198,    0,    0,    0,    0,
+    0,  198,    0,  198,  198,    0,  198,    0,  198,  198,
+  198,  198,  198,    0,  198,  198,  198,  198,  198,  198,
+  198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
+    0,    0,  198,  198,  198,    0,  198,  198,  198,    0,
+  198,  198,  198,    0,  358,  198,    0,  198,    0,    0,
+  198,  198,  198,  198,  358,    0,  198,  198,  198,    0,
+    0,    0,    0,    0,  198,    0,    0,  198,  198,  198,
+  198,  198,  198,  198,  198,    0,  198,  198,  198,  198,
+  198,    0,  156,  198,    0,    0,    0,    0,  358,    0,
+  198,  198,  198,    0,    0,    0,    0,  156,  156,  198,
+  198,  156,    0,  156,    0,  360,  156,  156,  156,  156,
+  156,  156,  156,    0,    0,  156,  156,  156,    0,    0,
+    0,    0,  156,  156,    0,    0,    0,  156,  156,    0,
+    0,    0,    0,    0,    0,    0,    0,  156,    0,    0,
+    0,  156,  156,    0,    0,    0,  156,    0,    0,    0,
+    0,    0,  156,    0,  156,  156,    0,  156,    0,  156,
+  156,  156,  156,  156,    0,  156,  156,  156,  156,  156,
+  156,  156,  156,  156,  156,  156,  156,  156,  156,  156,
+  156,    0,    0,  156,  156,  156,    0,  156,  156,  156,
+    0,  156,  156,  156,    0,  521,  156,    0,  156,    0,
+    0,  156,  156,  156,  156,  521,    0,  156,  156,  156,
+    0,    0,    0,    0,    0,  156,    0,    0,  156,  156,
+  156,  156,  156,  156,  156,  156,    0,  156,  156,  156,
+  156,  156,    0,    0,  156,    0,  521,    0,    0,  521,
+    0,  156,  156,  156,    0,    0,    0,    0,    0,    0,
+  156,  156,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  358,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  358,
+    0,  358,    0,    0,  358,  358,  358,  358,  358,  358,
+  358,    0,    0,  358,  358,  358,    0,    0,    0,    0,
+  358,  358,    0,    0,    0,  358,  358,    0,   40,    0,
+    0,    0,    0,    0,    0,  358,    0,    0,   40,  358,
+  358,    0,    0,    0,  358,    0,    0,    0,    0,    0,
+  358,    0,  358,  358,    0,  358,    0,  358,  358,  358,
+  358,  358,    0,  358,  358,  358,  358,  358,  358,  358,
+  358,  358,  358,  358,  358,  358,  358,  358,  358,    0,
+    0,  358,  358,  358,    0,  358,  358,  358,    0,  358,
+  358,  358,    0,    0,  358,    0,  358,    0,    0,  358,
+  358,  358,  358,    0,    0,  358,  358,  358,    0,    0,
+    0,    0,    0,  358,    0,    0,  358,  358,  358,  358,
+  358,  358,  358,  358,    0,  358,  358,  358,  358,  358,
+    0,  521,  358,    0,    0,    0,    0,    0,    0,  358,
+  358,  358,    0,    0,    0,    0,    0,    0,  358,  358,
+  521,    0,  521,    0,    0,  521,  521,  521,  521,  521,
+  521,  521,    0,    0,  521,  521,  521,    0,    0,    0,
+    0,  521,  521,    0,    0,    0,  521,  521,    0,  530,
+    0,    0,    0,    0,    0,    0,  521,    0,    0,  530,
+  521,  521,    0,    0,    0,  521,    0,    0,    0,    0,
+    0,  521,    0,  521,  521,    0,  521,    0,  521,  521,
+  521,  521,  521,    0,  521,  521,  521,  521,  521,  521,
+  521,  521,  521,  521,  521,  521,  521,  521,  521,  521,
+    0,    0,  521,  521,  521,    0,  521,  521,  521,    0,
+  521,  521,  521,    0,    0,  521,    0,  521,    0,    0,
+  521,  521,  521,  521,    0,    0,  521,  521,  521,    0,
+    0,    0,    0,    0,  521,    0,    0,  521,  521,  521,
+  521,  521,  521,  521,  521,    0,  521,  521,  521,  521,
+  521,    0,    0,  521,   40,    0,    0,    0,    0,    0,
+  521,  521,  521,    0,    0,    0,    0,    0,    0,  521,
+  521,    0,    0,   40,    0,   40,   40,    0,   40,   40,
+   40,   40,   40,   40,   40,    0,    0,   40,   40,   40,
+    0,    0,    0,    0,   40,   40,    0,    0,    0,   40,
+   40,    0,  529,    0,    0,    0,    0,    0,    0,   40,
+    0,    0,  529,   40,   40,    0,    0,    0,   40,    0,
+    0,    0,    0,    0,   40,    0,   40,   40,    0,   40,
+    0,   40,   40,   40,   40,   40,    0,   40,   40,   40,
+   40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
+   40,   40,   40,    0,    0,   40,   40,   40,    0,   40,
+   40,   40,    0,   40,   40,   40,    0,    0,   40,    0,
+   40,    0,    0,   40,   40,   40,   40,    0,    0,   40,
+   40,   40,    0,    0,    0,    0,    0,   40,    0,    0,
+   40,   40,   40,   40,   40,   40,   40,   40,    0,   40,
+   40,   40,   40,   40,    0,  530,   40,    0,    0,    0,
+    0,    0,    0,   40,   40,   40,    0,    0,    0,    0,
+    0,    0,   40,   40,  530,    0,  530,    0,    0,  530,
+  530,  530,  530,  530,  530,  530,    0,    0,  530,  530,
+  530,    0,    0,    0,    0,  530,  530,    0,    0,    0,
+  530,  530,    0,    0,    0,    0,    0,    0,    0,    0,
+  530,    0,    0,    0,  530,  530,    0,    0,    0,  530,
+    0,    0,    0,    0,    0,  530,    0,  530,  530,    0,
+  530,    0,  530,  530,  530,  530,  530,    0,  530,  530,
+  530,  530,  530,  530,  530,  530,  530,  530,  530,  530,
+  530,  530,  530,  530,    0,    0,  530,  530,  530,    0,
+  530,  530,  530,    0,  530,  530,  530,    0,  525,  530,
+    0,  530,    0,    0,  530,  530,  530,  530,  525,  530,
+  530,  530,  530,    0,    0,    0,    0,    0,  530,    0,
+    0,  530,  530,  530,  530,  530,  530,  530,  530,    0,
+  530,  530,  530,  530,  530,    0,    0,  530,  529,  525,
+    0,    0,  525,    0,  530,  530,  530,    0,    0,    0,
+    0,    0,    0,  530,  530,    0,    0,  529,    0,  529,
+    0,    0,  529,  529,  529,  529,  529,  529,  529,    0,
+    0,  529,  529,  529,    0,    0,    0,    0,  529,  529,
+    0,    0,    0,  529,  529,    0,    0,    0,    0,    0,
+    0,    0,    0,  529,    0,    0,    0,  529,  529,    0,
+    0,    0,  529,    0,    0,    0,    0,    0,  529,    0,
+  529,  529,    0,  529,    0,  529,  529,  529,  529,  529,
+    0,  529,  529,  529,  529,  529,  529,  529,  529,  529,
+  529,  529,  529,  529,  529,  529,  529,    0,    0,  529,
+  529,  529,    0,  529,  529,  529,    0,  529,  529,  529,
+    0,  198,  529,    0,  529,    0,    0,  529,  529,  529,
+  529,  198,  529,  529,  529,  529,    0,    0,    0,    0,
+    0,  529,    0,    0,  529,  529,  529,  529,  529,  529,
+  529,  529,    0,  529,  529,  529,  529,  529,    0,    0,
+  529,    0,    0,    0,    0,  198,    0,  529,  529,  529,
+    0,    0,    0,    0,    0,    0,  529,  529,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  525,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  525,    0,  525,    0,    0,  525,  525,
+  525,  525,  525,  525,  525,    0,    0,  525,  525,  525,
+    0,    0,    0,    0,  525,  525,    0,    0,    0,  525,
+  525,    0,    0,    0,    0,    0,    0,    0,    0,  525,
+    0,    0,    0,  525,  525,    0,    0,    0,  525,    0,
+    0,    0,    0,    0,  525,    0,  525,  525,    0,  525,
+    0,  525,  525,  525,  525,  525,    0,  525,  525,  525,
+  525,  525,  525,  525,  525,  525,  525,  525,  525,  525,
+  525,  525,  525,    0,    0,  525,  525,  525,    0,  525,
+  525,  525,    0,  525,  525,  525,    0,  200,  525,    0,
+  525,    0,    0,  525,  525,  525,  525,  200,    0,  525,
+  525,  525,    0,    0,    0,    0,    0,  525,    0,    0,
+  525,  525,  525,  525,  525,  525,  525,  525,    0,  525,
+  525,  525,  525,  525,    0,    0,  525,  198,    0,    0,
+    0,  200,    0,  525,  525,    0,    0,    0,    0,    0,
+    0,    0,  525,  525,    0,    0,  198,    0,  198,    0,
+    0,  198,  198,  198,  198,  198,  198,  198,    0,    0,
+  198,  198,  198,    0,    0,    0,    0,  198,  198,    0,
+    0,    0,  198,  198,    0,    0,    0,    0,    0,    0,
+    0,    0,  198,    0,    0,    0,  198,  198,    0,    0,
+    0,  198,    0,    0,    0,    0,    0,  198,    0,  198,
+  198,    0,  198,    0,  198,  198,  198,  198,  198,    0,
+  198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
+  198,  198,  198,  198,  198,  198,    0,    0,  198,  198,
+  198,    0,  198,  198,  198,    0,  198,  198,  198,    0,
+  374,  198,    0,  198,    0,    0,  198,  198,  198,  198,
+  374,    0,  198,  198,  198,    0,    0,    0,    0,    0,
+  198,    0,    0,  198,  198,  198,  198,  198,  198,  198,
+  198,    0,  198,  198,  198,  198,  198,    0,    0,  198,
+    0,    0,    0,    0,  374,    0,  198,  198,  198,    0,
+    0,    0,    0,    0,    0,  198,  198,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  200,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  200,    0,  200,    0,    0,  200,  200,  200,
+  200,  200,  200,  200,    0,    0,  200,  200,  200,    0,
+    0,    0,    0,  200,  200,    0,    0,    0,  200,  200,
+    0,    0,    0,    0,    0,    0,    0,    0,  200,    0,
+    0,    0,  200,  200,    0,    0,    0,  200,    0,    0,
+    0,    0,    0,  200,    0,  200,  200,    0,  200,    0,
+  200,  200,  200,  200,  200,    0,  200,  200,  200,  200,
+  200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
+  200,  200,    0,    0,  200,  200,  200,    0,  200,  200,
+  200,    0,  200,  200,  200,    0,  359,  200,    0,  200,
+    0,    0,  200,  200,  200,  200,  359,    0,  200,  200,
+  200,    0,    0,    0,    0,    0,  200,    0,    0,  200,
+  200,  200,  200,  200,  200,  200,  200,    0,  200,  200,
+  200,  200,  200,    0,    0,  200,  374,    0,    0,    0,
+  359,    0,  200,  200,  200,    0,    0,    0,    0,    0,
+    0,  200,  200,    0,    0,  374,    0,  374,    0,    0,
+  374,  374,  374,  374,  374,  374,  374,    0,    0,  374,
+  374,  374,    0,    0,    0,    0,  374,  374,    0,    0,
+    0,  374,  374,    0,    0,    0,    0,    0,    0,    0,
+    0,  374,    0,    0,    0,  374,  374,    0,    0,    0,
+  374,    0,    0,    0,    0,    0,  374,    0,  374,  374,
+    0,  374,    0,  374,  374,  374,  374,  374,    0,  374,
+  374,  374,  374,  374,  374,  374,  374,  374,  374,  374,
+  374,  374,  374,  374,  374,    0,    0,  374,  374,  374,
+    0,  374,  374,  374,    0,  374,  374,  374,    0,   59,
+  374,    0,  374,    0,    0,  374,  374,  374,  374,   59,
+    0,  374,  374,  374,    0,    0,    0,    0,    0,  374,
+    0,    0,  374,  374,  374,  374,  374,  374,  374,  374,
+    0,  374,  374,  374,  374,  374,    0,    0,  374,    0,
+    0,    0,    0,    0,    0,  374,  374,  374,    0,    0,
+    0,    0,    0,    0,  374,  374,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  359,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  359,    0,  359,    0,    0,  359,  359,  359,  359,
+  359,  359,  359,    0,    0,  359,  359,  359,    0,    0,
+    0,    0,  359,  359,    0,    0,    0,  359,  359,    0,
+    0,    0,    0,    0,    0,    0,    0,  359,    0,    0,
+    0,  359,  359,    0,    0,    0,  359,    0,    0,    0,
+    0,    0,  359,    0,  359,  359,    0,  359,    0,  359,
+  359,  359,  359,  359,    0,  359,  359,  359,  359,  359,
+  359,  359,  359,  359,  359,  359,  359,  359,  359,  359,
+  359,    0,    0,  359,  359,  359,    0,  359,  359,  359,
+    0,  359,  359,  359,    0,  125,  359,    0,  359,    0,
+    0,  359,  359,  359,  359,  125,    0,  359,  359,  359,
+    0,    0,    0,    0,    0,  359,    0,    0,  359,  359,
+  359,  359,  359,  359,  359,  359,    0,  359,  359,  359,
+  359,  359,    0,    0,  359,   59,    0,    0,    0,  125,
+    0,  359,  359,  359,    0,    0,    0,    0,    0,    0,
+  359,  359,    0,    0,   59,    0,   59,    0,    0,   59,
+   59,   59,   59,   59,   59,   59,    0,    0,   59,   59,
+   59,    0,    0,    0,    0,   59,   59,    0,    0,    0,
+   59,   59,    0,    0,    0,    0,    0,    0,    0,    0,
+   59,    0,    0,    0,   59,   59,    0,    0,    0,   59,
+    0,    0,    0,    0,    0,   59,    0,   59,   59,    0,
+   59,    0,   59,   59,   59,   59,   59,    0,   59,   59,
+   59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+   59,   59,   59,   59,    0,    0,   59,   59,   59,    0,
+   59,   59,   59,    0,   59,   59,   59,    0,  432,   59,
+    0,   59,    0,    0,   59,   59,   59,   59,  432,    0,
+   59,   59,   59,    0,    0,    0,    0,    0,   59,    0,
+    0,   59,   59,   59,   59,   59,   59,   59,   59,    0,
+   59,   59,   59,   59,   59,    0,    0,   59,    0,    0,
+    0,    0,    0,    0,   59,   59,   59,    0,    0,    0,
+    0,    0,    0,   59,   59,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  125,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  125,    0,  125,    0,    0,  125,  125,  125,  125,  125,
+  125,  125,    0,    0,  125,  125,  125,    0,    0,    0,
+    0,  125,  125,    0,    0,    0,  125,  125,    0,  441,
+    0,    0,    0,    0,    0,    0,  125,    0,    0,  441,
+  125,  125,    0,    0,    0,  125,    0,    0,    0,    0,
+    0,  125,    0,  125,  125,    0,  125,    0,  125,  125,
+  125,  125,  125,    0,  125,  125,  125,  125,  125,  125,
+  125,  125,  125,  125,  125,  125,  125,  125,  125,  125,
+    0,    0,  125,  125,  125,    0,  125,  125,  125,    0,
+  125,  125,  125,    0,    0,  125,    0,  125,    0,    0,
+  125,  125,  125,  125,    0,    0,  125,  125,  125,    0,
+    0,    0,    0,    0,  125,    0,    0,  125,  125,  125,
+  125,  125,  125,  125,  125,    0,  125,  125,  125,  125,
+  125,    0,    0,  125,  432,    0,    0,    0,    0,    0,
+  125,  125,    0,    0,    0,    0,    0,    0,    0,  125,
+  125,    0,    0,  432,    0,  432,    0,    0,  432,  432,
+  432,  432,  432,  432,  432,    0,    0,  432,  432,  432,
+    0,    0,    0,    0,  432,  432,    0,    0,    0,  432,
+  432,    0,  357,    0,    0,    0,    0,    0,    0,  432,
+    0,    0,  357,  432,  432,    0,    0,    0,  432,    0,
+    0,    0,    0,    0,  432,    0,  432,  432,    0,  432,
+    0,  432,  432,  432,  432,  432,    0,  432,  432,  432,
+  432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
+  432,  432,  432,    0,    0,  432,  432,  432,    0,  432,
+  432,  432,    0,  432,  432,  432,    0,    0,  432,    0,
+  432,    0,    0,  432,  432,  432,  432,    0,    0,  432,
+  432,  432,    0,    0,    0,    0,    0,  432,    0,    0,
+  432,  432,  432,  432,  432,  432,  432,  432,    0,  432,
+  432,  432,  432,  432,    0,  441,  432,    0,    0,    0,
+    0,    0,    0,  432,  432,  432,    0,    0,    0,    0,
+    0,    0,  432,  432,  441,    0,  441,    0,    0,  441,
+  441,  441,  441,  441,  441,  441,    0,    0,  441,  441,
+  441,    0,    0,    0,    0,  441,  441,    0,    0,    0,
+  441,  441,    0,   69,    0,    0,    0,    0,    0,    0,
+  441,    0,    0,   69,  441,  441,    0,    0,    0,  441,
+    0,    0,    0,    0,    0,  441,    0,  441,  441,    0,
+  441,    0,  441,  441,  441,  441,  441,    0,  441,  441,
+  441,  441,  441,  441,  441,  441,  441,  441,  441,  441,
+  441,  441,  441,  441,    0,    0,  441,  441,  441,    0,
+  441,  441,  441,    0,  441,  441,  441,    0,    0,  441,
+    0,  441,    0,    0,  441,  441,  441,  441,    0,    0,
+  441,  441,  441,    0,    0,    0,    0,    0,  441,    0,
+    0,  441,  441,  441,  441,  441,  441,  441,  441,    0,
+  441,  441,  441,  441,  441,    0,    0,  441,  357,    0,
+    0,    0,    0,    0,  441,  441,  441,    0,    0,    0,
+    0,    0,    0,  441,  441,    0,    0,  357,    0,  357,
+    0,    0,  357,  357,  357,  357,  357,  357,  357,    0,
+    0,  357,  357,  357,    0,    0,    0,    0,  357,  357,
+    0,    0,    0,  357,  357,    0,   53,    0,    0,    0,
+    0,    0,    0,  357,    0,    0,   53,  357,  357,    0,
+    0,    0,  357,    0,    0,    0,    0,    0,  357,    0,
+  357,  357,    0,  357,    0,  357,  357,  357,  357,  357,
+    0,  357,  357,  357,  357,  357,  357,  357,  357,  357,
+  357,  357,  357,  357,  357,  357,  357,    0,    0,  357,
+  357,  357,    0,  357,  357,  357,    0,  357,  357,  357,
+    0,    0,  357,    0,  357,    0,    0,  357,  357,  357,
+  357,    0,    0,  357,  357,  357,    0,    0,    0,    0,
+    0,  357,    0,    0,  357,  357,  357,  357,  357,  357,
+  357,  357,    0,  357,  357,  357,  357,  357,    0,   69,
+  357,    0,    0,    0,    0,    0,    0,  357,  357,  357,
+    0,    0,    0,    0,    0,    0,  357,  357,   69,    0,
+   69,    0,    0,   69,   69,   69,   69,   69,   69,   69,
+    0,    0,   69,   69,   69,    0,    0,    0,    0,   69,
+   69,    0,    0,    0,   69,   69,    0,  169,    0,    0,
+    0,    0,    0,    0,   69,    0,    0,  169,   69,   69,
+    0,    0,    0,   69,    0,    0,    0,    0,    0,   69,
+    0,   69,   69,    0,   69,    0,   69,   69,   69,   69,
+   69,    0,   69,   69,   69,   69,   69,   69,   69,   69,
+   69,   69,   69,   69,   69,   69,   69,   69,    0,    0,
+   69,   69,   69,    0,   69,   69,   69,    0,   69,   69,
+   69,    0,    0,   69,    0,   69,    0,    0,   69,   69,
+   69,   69,    0,    0,   69,   69,   69,    0,    0,    0,
+    0,    0,   69,    0,    0,   69,   69,   69,   69,   69,
+   69,   69,   69,    0,   69,   69,   69,   69,   69,    0,
+    0,   69,   53,    0,    0,    0,    0,    0,   69,   69,
+   69,    0,    0,    0,    0,    0,    0,   69,   69,    0,
+    0,   53,    0,   53,    0,    0,   53,   53,   53,   53,
+   53,   53,   53,    0,    0,   53,   53,   53,    0,    0,
+    0,    0,   53,   53,    0,    0,    0,   53,   53,    0,
+  177,    0,    0,    0,    0,    0,    0,   53,    0,    0,
+  177,   53,   53,    0,    0,    0,   53,    0,    0,    0,
+    0,    0,   53,    0,   53,   53,    0,   53,    0,   53,
+   53,   53,   53,   53,    0,   53,   53,   53,   53,   53,
+   53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
+   53,    0,    0,   53,   53,   53,    0,   53,   53,   53,
+    0,   53,   53,   53,    0,    0,   53,    0,   53,    0,
+    0,   53,   53,   53,   53,    0,    0,   53,   53,   53,
+    0,    0,    0,    0,    0,   53,    0,    0,   53,   53,
+   53,   53,   53,   53,   53,   53,    0,   53,   53,   53,
+   53,   53,    0,  169,   53,    0,    0,    0,    0,    0,
+    0,   53,   53,   53,    0,    0,    0,    0,    0,    0,
+   53,   53,  169,    0,  169,    0,    0,  169,  169,  169,
+  169,  169,  169,  169,    0,    0,  169,  169,  169,    0,
+    0,    0,    0,  169,  169,    0,    0,    0,  169,  169,
+    0,   55,    0,    0,    0,    0,    0,    0,  169,    0,
+    0,   55,  169,  169,    0,    0,    0,  169,    0,    0,
+    0,    0,    0,  169,    0,  169,  169,    0,  169,    0,
+  169,  169,  169,  169,  169,    0,  169,  169,  169,  169,
+  169,  169,  169,  169,  169,  169,  169,  169,  169,  169,
+  169,  169,    0,    0,  169,  169,  169,    0,  169,  169,
+  169,    0,  169,  169,  169,    0,    0,  169,    0,  169,
+    0,    0,  169,  169,  169,  169,    0,    0,  169,  169,
+  169,    0,    0,    0,    0,    0,  169,    0,    0,  169,
+  169,  169,  169,  169,  169,  169,  169,    0,  169,  169,
+  169,  169,  169,    0,    0,  169,  177,    0,    0,    0,
+    0,    0,  169,  169,  169,    0,    0,    0,    0,    0,
+    0,  169,  169,    0,    0,  177,    0,  177,    0,    0,
+  177,  177,  177,  177,  177,  177,  177,    0,    0,  177,
+  177,  177,    0,    0,    0,    0,  177,  177,    0,    0,
+    0,  177,  177,    0,  362,    0,    0,    0,    0,    0,
+    0,  177,    0,    0,  362,  177,  177,    0,    0,    0,
+  177,    0,    0,    0,    0,    0,  177,    0,  177,  177,
+    0,  177,    0,  177,  177,  177,  177,  177,    0,  177,
+  177,  177,  177,  177,  177,  177,  177,  177,  177,  177,
+  177,  177,  177,  177,  177,    0,    0,  177,  177,  177,
+    0,  177,  177,  177,    0,  177,  177,  177,    0,    0,
+  177,    0,  177,    0,    0,  177,  177,  177,  177,    0,
+    0,  177,  177,  177,    0,    0,    0,    0,    0,  177,
+    0,    0,  177,  177,  177,  177,  177,  177,  177,  177,
+    0,  177,  177,  177,  177,  177,    0,   55,  177,    0,
+    0,    0,    0,    0,    0,  177,  177,  177,    0,    0,
+    0,    0,    0,    0,  177,  177,   55,    0,   55,    0,
+    0,   55,   55,   55,   55,   55,   55,   55,    0,    0,
+   55,   55,   55,    0,    0,    0,    0,   55,   55,    0,
+    0,    0,   55,   55,    0,  164,    0,    0,    0,    0,
+    0,    0,   55,    0,    0,  164,   55,   55,    0,    0,
+    0,   55,    0,    0,    0,    0,    0,   55,    0,   55,
+   55,    0,   55,    0,   55,   55,   55,   55,   55,    0,
+   55,   55,   55,   55,   55,   55,   55,   55,   55,   55,
+   55,   55,   55,   55,   55,   55,    0,    0,   55,   55,
+   55,    0,   55,   55,   55,    0,   55,   55,   55,    0,
+    0,   55,    0,   55,    0,    0,   55,   55,   55,   55,
+    0,    0,   55,   55,   55,    0,    0,    0,    0,    0,
+   55,    0,    0,   55,   55,   55,   55,   55,   55,   55,
+   55,    0,   55,   55,   55,   55,   55,    0,    0,   55,
+  362,    0,    0,    0,    0,    0,   55,   55,   55,    0,
+    0,    0,    0,    0,    0,   55,   55,    0,    0,  362,
+    0,  362,    0,    0,  362,  362,  362,  362,  362,  362,
+  362,    0,    0,  362,  362,  362,    0,    0,    0,    0,
+  362,  362,    0,    0,    0,  362,  362,    0,  406,    0,
+    0,    0,    0,    0,    0,  362,    0,    0,  406,  362,
+  362,    0,    0,    0,  362,    0,    0,    0,    0,    0,
+  362,    0,  362,  362,    0,  362,    0,  362,  362,  362,
+  362,  362,    0,  362,  362,  362,  362,  362,  362,  362,
+  362,  362,  362,  362,  362,  362,  362,  362,  362,    0,
+    0,  362,  362,  362,    0,  362,  362,  362,    0,  362,
+  362,  362,    0,    0,  362,    0,  362,    0,    0,  362,
+  362,  362,  362,    0,    0,  362,  362,  362,    0,    0,
+    0,    0,    0,  362,    0,    0,  362,  362,  362,  362,
+  362,  362,  362,  362,    0,  362,  362,  362,  362,  362,
+    0,  164,  362,    0,    0,    0,    0,    0,    0,  362,
+  362,  362,    0,    0,    0,    0,    0,    0,  362,  362,
+  164,    0,  164,    0,    0,  164,  164,  164,  164,  164,
+  164,  164,    0,    0,  164,  164,  164,    0,    0,    0,
+    0,  164,  164,    0,    0,    0,  164,  164,    0,  472,
+    0,    0,    0,    0,    0,    0,  164,    0,    0,  472,
+  164,  164,    0,    0,    0,  164,    0,    0,    0,    0,
+    0,  164,    0,  164,  164,    0,  164,    0,  164,  164,
+  164,  164,  164,    0,  164,  164,  164,  164,  164,  164,
+  164,  164,  164,  164,  164,  164,  164,  164,  164,  164,
+    0,    0,  164,  164,  164,    0,  164,  164,  164,    0,
+  164,  164,  164,    0,    0,  164,    0,  164,    0,    0,
+  164,  164,  164,  164,    0,    0,  164,  164,  164,    0,
+    0,    0,    0,    0,  164,    0,    0,  164,  164,  164,
+  164,  164,  164,  164,  164,    0,  164,  164,  164,  164,
+  164,    0,    0,  164,  406,    0,    0,    0,    0,    0,
+  164,  164,  164,    0,    0,    0,    0,    0,    0,  164,
+  164,    0,    0,  406,    0,  406,    0,    0,  406,  406,
+  406,  406,  406,  406,  406,    0,    0,  406,  406,  406,
+    0,    0,    0,    0,  406,  406,    0,    0,    0,  406,
+  406,    0,   34,    0,    0,    0,    0,    0,    0,  406,
+    0,    0,   34,  406,  406,    0,    0,    0,  406,    0,
+    0,    0,    0,    0,  406,    0,  406,  406,    0,  406,
+    0,  406,  406,  406,  406,  406,    0,  406,  406,  406,
+  406,  406,  406,  406,  406,  406,  406,  406,  406,  406,
+  406,  406,  406,    0,    0,  406,  406,  406,    0,  406,
+  406,  406,    0,  406,  406,  406,    0,    0,  406,    0,
+  406,    0,    0,  406,  406,  406,  406,    0,    0,  406,
+  406,  406,    0,    0,    0,    0,    0,  406,    0,    0,
+  406,  406,  406,  406,  406,  406,  406,  406,    0,  406,
+  406,  406,  406,  406,    0,  472,  406,    0,    0,    0,
+    0,    0,    0,  406,  406,  406,    0,    0,    0,    0,
+    0,    0,  406,  406,  472,    0,  472,    0,    0,  472,
+  472,  472,  472,  472,  472,  472,    0,    0,  472,  472,
+  472,    0,    0,    0,    0,  472,  472,    0,    0,    0,
+  472,  472,    0,  151,    0,    0,    0,    0,    0,    0,
+  472,    0,    0,  151,  472,  472,    0,    0,    0,  472,
+    0,    0,    0,    0,    0,  472,    0,  472,  472,    0,
+  472,    0,  472,  472,  472,  472,  472,    0,  472,  472,
+  472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
+  472,  472,  472,  472,    0,    0,  472,  472,  472,    0,
+  472,  472,  472,    0,  472,  472,  472,    0,    0,  472,
+    0,  472,    0,    0,  472,  472,  472,  472,    0,    0,
+  472,  472,  472,    0,    0,    0,    0,    0,  472,    0,
+    0,  472,  472,  472,  472,  472,  472,  472,  472,    0,
+  472,  472,  472,  472,  472,    0,    0,  472,   34,    0,
+    0,    0,    0,    0,  472,  472,  472,    0,    0,    0,
+    0,    0,    0,  472,  472,    0,    0,   34,    0,   34,
+    0,    0,   34,   34,   34,   34,   34,   34,   34,    0,
+    0,   34,   34,   34,    0,    0,    0,    0,   34,   34,
+    0,    0,    0,   34,   34,    0,  149,    0,    0,    0,
+    0,    0,    0,   34,    0,    0,  149,   34,   34,    0,
+    0,    0,   34,    0,    0,    0,    0,    0,   34,    0,
+   34,   34,    0,   34,    0,   34,   34,   34,   34,   34,
+    0,   34,   34,   34,   34,   34,   34,   34,   34,   34,
+   34,   34,   34,   34,   34,   34,   34,    0,    0,   34,
+   34,   34,    0,   34,   34,   34,    0,   34,   34,   34,
+    0,    0,   34,    0,   34,    0,    0,   34,   34,   34,
+   34,    0,    0,   34,   34,   34,    0,    0,    0,    0,
+    0,   34,    0,    0,   34,   34,   34,   34,   34,   34,
+   34,   34,    0,   34,   34,   34,   34,   34,    0,  151,
+   34,    0,    0,    0,    0,    0,    0,   34,   34,   34,
+    0,    0,    0,    0,    0,    0,   34,   34,  151,    0,
+  151,    0,    0,  151,  151,  151,  151,  151,  151,  151,
+    0,    0,  151,  151,  151,    0,    0,    0,    0,  151,
+  151,    0,    0,    0,  151,  151,    0,   67,    0,    0,
+    0,    0,    0,    0,  151,    0,    0,   67,  151,  151,
+    0,    0,    0,  151,    0,    0,    0,    0,    0,  151,
+    0,  151,  151,    0,  151,    0,  151,  151,  151,  151,
+  151,    0,  151,  151,  151,  151,  151,  151,  151,  151,
+  151,  151,  151,  151,  151,  151,  151,  151,    0,    0,
+  151,  151,  151,    0,  151,  151,  151,    0,  151,  151,
+  151,    0,    0,  151,    0,  151,    0,    0,  151,  151,
+  151,  151,    0,    0,  151,  151,  151,    0,    0,    0,
+    0,    0,  151,    0,    0,  151,  151,  151,  151,  151,
+  151,  151,  151,    0,  151,  151,  151,  151,  151,    0,
+    0,  151,  149,    0,    0,    0,    0,    0,  151,  151,
+  151,    0,    0,    0,    0,    0,    0,  151,  151,    0,
+    0,  149,    0,  149,    0,    0,  149,  149,  149,  149,
+  149,  149,  149,    0,    0,  149,  149,  149,    0,    0,
+    0,    0,  149,  149,    0,    0,    0,  149,  149,    0,
+   68,    0,    0,    0,    0,    0,    0,  149,    0,    0,
+   68,  149,  149,    0,    0,    0,  149,    0,    0,    0,
+    0,    0,  149,    0,  149,  149,    0,  149,    0,  149,
+  149,  149,  149,  149,    0,  149,  149,  149,  149,  149,
+  149,  149,  149,  149,  149,  149,  149,  149,  149,  149,
+  149,    0,    0,  149,  149,  149,    0,  149,  149,  149,
+    0,  149,  149,  149,    0,    0,  149,    0,  149,    0,
+    0,  149,  149,  149,  149,    0,    0,  149,  149,  149,
+    0,    0,    0,    0,    0,  149,    0,    0,  149,  149,
+  149,  149,  149,  149,  149,  149,    0,  149,  149,  149,
+  149,  149,    0,   67,  149,    0,    0,    0,    0,    0,
+    0,  149,  149,  149,    0,    0,    0,    0,    0,    0,
+  149,  149,   67,    0,   67,    0,    0,   67,   67,   67,
+   67,   67,   67,   67,    0,    0,   67,   67,   67,    0,
+    0,    0,    0,   67,   67,    0,    0,    0,   67,   67,
+    0,   40,    0,    0,    0,    0,    0,    0,   67,    0,
+    0,   40,   67,   67,    0,    0,    0,   67,    0,    0,
+    0,    0,    0,   67,    0,   67,   67,    0,   67,    0,
+   67,   67,   67,   67,   67,    0,   67,   67,   67,   67,
+   67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+   67,   67,    0,    0,   67,   67,   67,    0,   67,   67,
+   67,    0,   67,   67,   67,    0,    0,   67,    0,   67,
+    0,    0,   67,   67,   67,   67,    0,    0,   67,   67,
+   67,    0,    0,    0,    0,    0,   67,    0,    0,   67,
+   67,   67,   67,   67,   67,   67,   67,    0,   67,   67,
+   67,   67,   67,    0,    0,   67,   68,    0,    0,    0,
+    0,    0,   67,   67,   67,    0,    0,    0,    0,    0,
+    0,   67,   67,    0,    0,   68,    0,   68,    0,    0,
+   68,   68,   68,   68,   68,   68,   68,    0,    0,   68,
+   68,   68,    0,    0,    0,    0,   68,   68,    0,    0,
+    0,   68,   68,    0,  438,    0,    0,    0,    0,    0,
+    0,   68,    0,    0,  438,   68,   68,    0,    0,    0,
+   68,    0,    0,    0,    0,    0,   68,    0,   68,   68,
+    0,   68,    0,   68,   68,   68,   68,   68,    0,   68,
+   68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+   68,   68,   68,   68,   68,    0,    0,   68,   68,   68,
+    0,   68,   68,   68,    0,   68,   68,   68,    0,    0,
+   68,    0,   68,    0,    0,   68,   68,   68,   68,    0,
+    0,   68,   68,   68,    0,    0,    0,    0,    0,   68,
+    0,    0,   68,   68,   68,   68,   68,   68,   68,   68,
+    0,   68,   68,   68,   68,   68,    0,   40,   68,    0,
+    0,    0,    0,    0,    0,   68,   68,   68,    0,    0,
+    0,    0,    0,    0,   68,   68,   40,    0,   40,    0,
+    0,   40,   40,   40,   40,   40,   40,   40,    0,    0,
+   40,   40,   40,    0,    0,    0,    0,   40,   40,    0,
+    0,    0,   40,   40,    0,  439,    0,    0,    0,    0,
+    0,    0,   40,    0,    0,  439,   40,   40,    0,    0,
+    0,   40,    0,    0,    0,    0,    0,   40,    0,   40,
+   40,    0,   40,    0,   40,   40,   40,   40,   40,    0,
+   40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
+   40,   40,   40,   40,   40,   40,    0,    0,   40,   40,
+   40,    0,   40,   40,   40,    0,   40,   40,   40,    0,
+    0,   40,    0,   40,    0,    0,   40,   40,   40,   40,
+    0,    0,   40,   40,   40,    0,    0,    0,    0,    0,
+   40,    0,    0,   40,   40,   40,   40,   40,   40,   40,
+   40,    0,   40,   40,   40,   40,   40,    0,    0,   40,
+  438,    0,    0,    0,    0,    0,   40,   40,   40,    0,
+    0,    0,    0,    0,    0,   40,   40,    0,    0,  438,
+    0,  438,    0,    0,  438,  438,  438,  438,  438,  438,
+  438,    0,    0,  438,  438,  438,    0,    0,    0,    0,
+  438,  438,    0,    0,    0,  438,  438,    0,  467,    0,
+    0,    0,    0,    0,    0,  438,    0,    0,  467,  438,
+  438,    0,    0,    0,  438,    0,    0,    0,    0,    0,
+  438,    0,  438,  438,    0,  438,    0,  438,  438,  438,
+  438,  438,    0,  438,  438,  438,  438,  438,  438,  438,
+  438,  438,  438,  438,  438,  438,  438,  438,  438,    0,
+    0,  438,  438,  438,    0,  438,  438,  438,    0,  438,
+  438,  438,    0,    0,  438,    0,  438,    0,    0,  438,
+  438,  438,  438,    0,    0,  438,  438,  438,    0,    0,
+    0,    0,    0,  438,    0,    0,  438,  438,  438,  438,
+  438,  438,  438,  438,    0,  438,  438,  438,  438,  438,
+    0,  439,  438,    0,    0,    0,    0,    0,    0,  438,
+  438,  438,    0,    0,    0,    0,    0,    0,  438,  438,
+  439,    0,  439,    0,    0,  439,  439,  439,  439,  439,
+  439,  439,    0,    0,  439,  439,  439,    0,    0,    0,
+    0,  439,  439,    0,    0,    0,  439,  439,    0,   43,
+    0,    0,    0,    0,    0,    0,  439,    0,    0,   43,
+  439,  439,    0,    0,    0,  439,    0,    0,    0,    0,
+    0,  439,    0,  439,  439,    0,  439,    0,  439,  439,
+  439,  439,  439,    0,  439,  439,  439,  439,  439,  439,
+  439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
+    0,    0,  439,  439,  439,    0,  439,  439,  439,    0,
+  439,  439,  439,    0,    0,  439,    0,  439,    0,    0,
+  439,  439,  439,  439,    0,    0,  439,  439,  439,    0,
+    0,    0,    0,    0,  439,    0,    0,  439,  439,  439,
+  439,  439,  439,  439,  439,    0,  439,  439,  439,  439,
+  439,    0,    0,  439,  467,    0,    0,    0,    0,    0,
+  439,  439,  439,    0,    0,    0,    0,    0,    0,  439,
+  439,    0,    0,  467,    0,  467,    0,    0,  467,  467,
+  467,  467,  467,  467,  467,    0,    0,  467,  467,  467,
+    0,    0,    0,    0,  467,  467,    0,    0,    0,  467,
+  467,    0,  363,    0,    0,    0,    0,    0,    0,  467,
+    0,    0,  363,  467,  467,    0,    0,    0,  467,    0,
+    0,    0,    0,    0,  467,    0,  467,  467,    0,  467,
+    0,  467,  467,  467,  467,  467,    0,  467,  467,  467,
+  467,  467,  467,  467,  467,  467,  467,  467,  467,  467,
+  467,  467,  467,    0,    0,  467,  467,  467,    0,  467,
+  467,  467,    0,  467,  467,  467,    0,    0,  467,    0,
+  467,    0,    0,  467,  467,  467,  467,    0,    0,  467,
+  467,  467,    0,    0,    0,    0,    0,  467,    0,    0,
+  467,  467,  467,  467,  467,  467,  467,  467,    0,  467,
+  467,  467,  467,  467,    0,   43,  467,    0,    0,    0,
+    0,    0,    0,  467,  467,  467,    0,    0,    0,    0,
+    0,    0,  467,  467,   43,    0,   43,    0,    0,   43,
+   43,   43,   43,   43,   43,   43,    0,    0,   43,   43,
+   43,    0,    0,    0,    0,   43,   43,    0,    0,    0,
+   43,   43,    0,  473,    0,    0,    0,    0,    0,    0,
+   43,    0,    0,  473,   43,   43,    0,    0,    0,   43,
+    0,    0,    0,    0,    0,   43,    0,   43,   43,    0,
+   43,    0,   43,   43,   43,   43,   43,    0,   43,   43,
+   43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
+   43,   43,   43,   43,    0,    0,   43,   43,   43,    0,
+   43,   43,   43,    0,   43,   43,   43,    0,    0,   43,
+    0,   43,    0,    0,   43,   43,   43,   43,    0,    0,
+   43,   43,   43,    0,    0,    0,    0,    0,   43,    0,
+    0,   43,   43,   43,   43,   43,   43,   43,   43,    0,
+   43,   43,   43,   43,   43,    0,    0,   43,  363,    0,
+    0,    0,    0,    0,   43,   43,   43,    0,    0,    0,
+    0,    0,    0,   43,   43,    0,    0,  363,    0,  363,
+    0,    0,  363,  363,  363,  363,  363,  363,  363,    0,
+    0,  363,  363,  363,    0,    0,    0,    0,  363,  363,
+    0,    0,    0,  363,  363,    0,  365,    0,    0,    0,
+    0,    0,    0,  363,    0,    0,  365,  363,  363,    0,
+    0,    0,  363,    0,    0,    0,    0,    0,  363,    0,
+  363,  363,    0,  363,    0,  363,  363,  363,  363,  363,
+    0,  363,  363,  363,  363,  363,  363,  363,  363,  363,
+  363,  363,  363,  363,  363,  363,  363,    0,    0,  363,
+  363,  363,    0,  363,  363,  363,    0,  363,  363,  363,
+    0,    0,  363,    0,  363,    0,    0,  363,  363,  363,
+  363,    0,    0,  363,  363,  363,    0,    0,    0,    0,
+    0,  363,    0,    0,  363,  363,  363,  363,  363,  363,
+  363,  363,    0,  363,  363,  363,  363,  363,    0,  473,
+  363,    0,    0,    0,    0,    0,    0,  363,  363,  363,
+    0,    0,    0,    0,    0,    0,  363,  363,  473,    0,
+  473,    0,    0,  473,  473,  473,  473,  473,  473,  473,
+    0,    0,  473,  473,  473,    0,    0,    0,    0,  473,
+  473,    0,    0,    0,  473,  473,    0,  409,    0,    0,
+    0,    0,    0,    0,  473,    0,    0,  409,  473,  473,
+    0,    0,    0,  473,    0,    0,    0,    0,    0,  473,
+    0,  473,  473,    0,  473,    0,  473,  473,  473,  473,
+  473,    0,  473,  473,  473,  473,  473,  473,  473,  473,
+  473,  473,  473,  473,  473,  473,  473,  473,    0,    0,
+  473,  473,  473,    0,  473,  473,  473,    0,  473,  473,
+  473,    0,    0,  473,    0,  473,    0,    0,  473,  473,
+  473,  473,    0,    0,  473,  473,  473,    0,    0,    0,
+    0,    0,  473,    0,    0,  473,  473,  473,  473,  473,
+  473,  473,  473,    0,  473,  473,  473,  473,  473,    0,
+    0,  473,  365,    0,    0,    0,    0,    0,  473,  473,
+  473,    0,    0,    0,    0,    0,    0,  473,  473,    0,
+    0,  365,    0,  365,    0,    0,  365,  365,  365,  365,
+  365,  365,  365,    0,    0,  365,  365,  365,    0,    0,
+    0,    0,  365,  365,    0,    0,    0,  365,  365,    0,
+  549,    0,    0,    0,    0,    0,    0,  365,    0,    0,
+  549,  365,  365,    0,    0,    0,  365,    0,    0,    0,
+    0,    0,  365,    0,  365,  365,    0,  365,    0,  365,
+  365,  365,  365,  365,    0,  365,  365,  365,  365,  365,
+  365,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+  365,    0,    0,  365,  365,  365,    0,  365,  365,  365,
+    0,  365,  365,  365,    0,    0,  365,    0,  365,    0,
+    0,  365,  365,  365,  365,    0,    0,  365,  365,  365,
+    0,    0,    0,    0,    0,  365,    0,    0,  365,  365,
+  365,  365,  365,  365,  365,  365,    0,  365,  365,  365,
+  365,  365,    0,  409,  365,    0,    0,    0,    0,    0,
+    0,  365,  365,  365,    0,    0,    0,    0,    0,    0,
+  365,  365,  409,    0,  409,    0,    0,  409,  409,  409,
+  409,  409,  409,  409,    0,    0,  409,  409,  409,    0,
+    0,    0,    0,  409,  409,    0,    0,    0,  409,  409,
+    0,  410,    0,    0,    0,    0,    0,    0,  409,    0,
+    0,  410,  409,  409,    0,    0,    0,  409,    0,    0,
+    0,    0,    0,  409,    0,  409,  409,    0,  409,    0,
+  409,  409,  409,  409,  409,    0,  409,  409,  409,  409,
+  409,  409,  409,  409,  409,  409,  409,  409,  409,  409,
+  409,  409,    0,    0,  409,  409,  409,    0,  409,  409,
+  409,    0,  409,  409,  409,    0,    0,  409,    0,  409,
+    0,    0,  409,  409,  409,  409,    0,    0,  409,  409,
+  409,    0,    0,    0,    0,    0,  409,    0,    0,  409,
+  409,  409,  409,  409,  409,  409,  409,    0,  409,  409,
+  409,  409,  409,    0,    0,  409,  549,    0,    0,    0,
+    0,    0,  409,  409,  409,    0,    0,    0,    0,    0,
+    0,  409,  409,    0,    0,  549,    0,  549,    0,    0,
+  549,  549,  549,  549,  549,  549,  549,    0,    0,  549,
+  549,  549,    0,    0,    0,    0,  549,  549,    0,    0,
+    0,  549,  549,    0,  415,    0,    0,    0,    0,    0,
+    0,  549,    0,    0,  415,  549,  549,    0,    0,    0,
+  549,    0,    0,    0,    0,    0,  549,    0,  549,  549,
+    0,  549,    0,  549,  549,  549,  549,  549,    0,  549,
+  549,  549,  549,  549,  549,  549,  549,  549,  549,  549,
+  549,  549,  549,  549,  549,    0,    0,  549,  549,  549,
+    0,  549,  549,  549,    0,  549,  549,  549,    0,    0,
+  549,    0,  549,    0,    0,  549,  549,  549,  549,    0,
+    0,  549,  549,  549,    0,    0,    0,    0,    0,  549,
+    0,    0,  549,  549,  549,  549,  549,  549,  549,  549,
+    0,  549,  549,  549,  549,  549,    0,  410,  549,    0,
+    0,    0,    0,    0,    0,  549,  549,  549,    0,    0,
+    0,    0,    0,    0,  549,  549,  410,    0,  410,    0,
+    0,  410,  410,  410,  410,  410,  410,  410,    0,    0,
+  410,  410,  410,    0,    0,    0,    0,  410,  410,    0,
+    0,    0,  410,  410,    4,    0,    0,    0,    0,    0,
+    0,    0,  410,    0,    4,    0,  410,  410,    0,    0,
+    0,  410,    0,    0,    0,    0,    0,  410,    0,  410,
+  410,    0,  410,    0,  410,  410,  410,  410,  410,    0,
+  410,  410,  410,  410,  410,  410,  410,  410,  410,  410,
+  410,  410,  410,  410,  410,  410,    0,    0,  410,  410,
+  410,    0,  410,  410,  410,    0,  410,  410,  410,    0,
+    0,  410,    0,  410,    0,    0,  410,  410,  410,  410,
+    0,    0,  410,  410,  410,    0,    0,    0,    0,    0,
+  410,    0,    0,  410,  410,  410,  410,  410,  410,  410,
+  410,    0,  410,  410,  410,  410,  410,    0,    0,  410,
+  415,    0,    0,    0,    0,    0,  410,  410,  410,    0,
+    0,    0,    0,    0,    0,  410,  410,    0,    0,  415,
+    0,  415,    0,    0,  415,  415,  415,  415,  415,  415,
+  415,    0,    0,  415,  415,  415,    0,    0,    0,    0,
+  415,  415,    0,    0,    0,  415,  415,  411,    0,    0,
+    0,    0,    0,    0,    0,  415,    0,  411,    0,  415,
+  415,    0,    0,    0,  415,    0,    0,    0,    0,    0,
+  415,    0,  415,  415,    0,  415,    0,  415,  415,  415,
+  415,  415,    0,  415,  415,  415,  415,  415,  415,  415,
+  415,  415,  415,  415,  415,  415,  415,  415,  415,    0,
+    0,  415,  415,  415,    0,  415,  415,  415,    0,  415,
+  415,  415,    0,    0,  415,    0,  415,    0,    0,  415,
+  415,  415,  415,    0,    0,  415,  415,  415,    0,    0,
+    0,    0,    0,  415,    0,    0,  415,  415,  415,  415,
+  415,  415,  415,  415,    0,  415,  415,  415,  415,  415,
+    4,    0,  415,    0,    0,    0,    0,    0,    0,  415,
+  415,    0,    0,    0,    0,    0,    0,    0,  415,  415,
+    0,    4,    0,    0,    4,    4,    4,    4,    4,    4,
+    4,    0,    0,    4,    4,    4,    0,    0,    0,    0,
+    4,    4,    0,    0,    0,    4,    4,    0,  408,    0,
+    0,    0,    0,    0,    0,    4,    0,    0,  408,    4,
+    4,    0,    0,    0,    4,    0,    0,    0,    0,    0,
+    4,    0,    4,    4,    0,    4,    0,    4,    4,    4,
+    4,    4,    0,    4,    4,    4,    4,    4,    4,    4,
+    4,    4,    4,    4,    4,    4,    4,    4,    4,    0,
+    0,    4,    4,    4,    0,    4,    4,    4,    0,    4,
+    4,    4,    0,    0,    4,    0,    4,    0,    0,    4,
+    4,    4,    4,    0,    0,    4,    4,    4,    0,    0,
+    0,    0,    0,    4,    0,    0,    4,    4,    4,    4,
+    4,    4,    4,    4,    0,    4,    4,    4,    4,    4,
+    0,    0,    4,  411,    0,    0,    0,    0,    0,    4,
+    4,    4,    0,    0,    0,    0,    0,    0,    4,    4,
+    0,    0,  411,    0,  411,    0,    0,  411,  411,  411,
+  411,  411,  411,  411,    0,    0,  411,  411,  411,    0,
+    0,    0,    0,  411,  411,    0,    0,    0,  411,  411,
+    0,  354,    0,    0,    0,    0,    0,    0,  411,    0,
+    0,  354,  411,  411,    0,    0,    0,  411,    0,    0,
+    0,    0,    0,  411,    0,  411,  411,    0,  411,    0,
+  411,  411,  411,  411,  411,    0,  411,  411,  411,  411,
+  411,  411,  411,  411,  411,  411,  411,  411,  411,  411,
+  411,  411,    0,    0,  411,  411,  411,    0,  411,  411,
+  411,    0,  411,  411,  411,    0,    0,  411,    0,  411,
+    0,    0,  411,  411,  411,  411,    0,    0,  411,  411,
+  411,    0,    0,    0,    0,    0,  411,    0,    0,  411,
+  411,  411,  411,  411,  411,  411,  411,    0,  411,  411,
+  411,  411,  411,    0,  408,  411,    0,    0,    0,    0,
+    0,    0,  411,  411,  411,    0,    0,    0,    0,    0,
+    0,    0,  411,  408,    0,  408,    0,    0,  408,  408,
+  408,  408,  408,  408,  408,    0,    0,  408,  408,  408,
+    0,    0,    0,    0,  408,  408,    0,    0,    0,  408,
+  408,    0,  455,    0,    0,    0,    0,    0,    0,  408,
+    0,    0,  455,  408,  408,    0,    0,    0,  408,    0,
+    0,    0,    0,    0,  408,    0,  408,  408,    0,  408,
+    0,  408,  408,  408,  408,  408,    0,  408,  408,  408,
+  408,  408,  408,  408,  408,  408,  408,  408,  408,  408,
+  408,  408,  408,    0,    0,  408,  408,  408,    0,  408,
+  408,  408,    0,  408,  408,  408,    0,    0,  408,    0,
+  408,    0,    0,  408,  408,  408,  408,    0,    0,  408,
+  408,  408,    0,    0,    0,    0,    0,  408,    0,    0,
+  408,  408,  408,  408,  408,  408,  408,  408,    0,  408,
+  408,  408,  408,  408,    0,    0,  408,  354,    0,    0,
+    0,    0,    0,  408,  408,    0,    0,    0,    0,    0,
+    0,    0,  408,  408,    0,    0,  354,    0,  354,    0,
+    0,  354,  354,  354,  354,  354,  354,  354,    0,    0,
+  354,  354,  354,    0,    0,    0,    0,  354,  354,    0,
+    0,    0,  354,  354,    0,   24,    0,    0,    0,    0,
+    0,    0,  354,    0,    0,   24,  354,  354,    0,    0,
+    0,  354,    0,    0,    0,    0,    0,  354,    0,  354,
+  354,    0,  354,    0,  354,  354,  354,  354,  354,    0,
+  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
+  354,  354,  354,  354,  354,  354,    0,    0,  354,  354,
+  354,    0,  354,  354,  354,    0,  354,  354,  354,    0,
+    0,  354,    0,  354,    0,    0,  354,  354,  354,  354,
+    0,    0,  354,  354,  354,    0,    0,    0,    0,    0,
+  354,    0,    0,  354,  354,  354,  354,    0,  354,  354,
+  354,    0,  354,  354,  354,  354,  354,    0,  455,  354,
+    0,    0,    0,    0,    0,    0,  354,  354,    0,    0,
+    0,    0,    0,    0,    0,    0,  354,  455,    0,  455,
+    0,    0,  455,  455,  455,  455,  455,  455,  455,    0,
+    0,  455,  455,  455,    0,    0,    0,    0,  455,  455,
+    0,    0,    0,  455,  455,    0,    0,    0,    0,    0,
+    0,    0,    0,  455,    0,    0,    0,  455,  455,    0,
+    0,    0,  455,    0,    0,    0,    0,    0,  455,    0,
+  455,  455,    0,  455,    0,  455,  455,  455,  455,  455,
+    0,  455,  455,  455,  455,  455,  455,  455,  455,  455,
+  455,  455,  455,  455,  455,  455,  455,    0,    0,  455,
+  455,  455,    0,  455,  455,  455,    0,  455,  455,  455,
+    0,    0,  455,    0,  455,    0,    0,  455,  455,  455,
+  455,    0,    0,  455,  455,  455,    0,  188,    0,  540,
+  150,  455,  151,    0,  455,  455,  455,  455,    0,  455,
+  455,  455,    0,  455,  455,  455,  455,  455,  545,    0,
+  455,   24,    0,    0,    0,    0,    0,  455,  455,    0,
+    0,    0,    0,    0,    0,    0,    0,  455,    0,    0,
+   24,    0,   24,    0,    0,   24,   24,   24,   24,   24,
+   24,   24,    0,    0,   24,   24,   24,    0,    0,    0,
+    0,   24,   24,    0,    0,    0,   24,   24,    0,  638,
+  417,  415,    0,  416,    0,    0,   24,    0,    0,    0,
+   24,   24,    0,    0,    0,   24,  901,    0,  420,  403,
+  421,   24,    0,   24,   24,    0,   24,    0,   24,   24,
+   24,   24,   24,    0,   24,   24,   24,   24,   24,   24,
+   24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
+    0,    0,   24,   24,   24,    0,   24,   24,   24,    0,
+   24,   24,   24,    0,    0,   24,    0,   24,    0,    0,
+   24,   24,   24,   24,    0,    0,   24,   24,   24,    0,
+  188,    0,  540,  150,   24,  151,    0,   24,   24,   24,
+   24,   24,   24,   24,   24,    0,   24,   24,   24,   24,
+   24,  734,    0,   24,    0,    0,    0,    0,    0,    0,
+   24,   24,   24,    0,    0,    0,    0,    0,    0,   24,
+    0,    0,    0,    0,    0,    0,    0,    0,  188,    0,
+    0,  150,    0,  151,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  644,
+  149,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  177,  188,    0,    0,
+  150,    0,  151,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,  666,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,  149,   89,    0,    0,    0,    0,    0,
+    0,  187,    0,    0,    0,  188,    0,    0,  150,    0,
+  151,    0,    0,    0,    0,    0,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,  668,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,  149,  165,  166,  167,    0,    0,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,    0,  176,    0,    0,
+    0,    0,    0,    0,    0,  152,  153,    0,    0,    0,
+  154,  155,  156,  157,    0,    0,    0,    0,    0,    0,
+    0,    0,  158,  159,  160,  161,  162,  163,  164,    0,
+  165,  166,  167,    0,    0,  168,  169,  170,    0,  171,
+  172,  173,  174,  175,    0,  176,    0,    0,    0,  177,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,    0,    0,    0,  180,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,    0,  188,   89,  706,  150,
+    0,  151,    0,    0,  187,    0,    0,  177,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  178,  179,
+    0,    0,    0,    0,  180,    0,    0,    0,    0,    0,
+  149,    0,    0,    0,  181,  182,    0,    0,  183,  184,
+  185,  186,    0,    0,  188,   89,  540,  150,    0,  151,
+    0,    0,  187,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,  149,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,    0,  176,    0,    0,    0,  177,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,  188,    0,   89,  150,    0,  151,    0,    0,
+    0,  187,    0,    0,  177,    0,    0,    0,    0,    0,
+  813,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,    0,  149,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,  188,    0,    0,  150,  187,
+  151,    0,    0,  152,  153,    0,    0,    0,  154,  155,
+  156,  157,    0,  898,    0,    0,    0,    0,    0,    0,
+  158,  159,  160,  161,  162,  163,  164,  149,  165,  166,
+  167,    0,    0,  168,  169,  170,    0,  171,  172,  173,
+  174,  175,    0,  176,    0,    0,    0,    0,    0,    0,
+    0,  152,  153,    0,    0,    0,  154,  155,  156,  157,
+    0,    0,    0,    0,    0,    0,    0,    0,  158,  159,
+  160,  161,  162,  163,  164,    0,  165,  166,  167,    0,
+    0,  168,  169,  170,    0,  171,  172,  173,  174,  175,
+    0,  176,    0,    0,    0,  177,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  178,  179,    0,    0,
+    0,    0,  180,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  181,  182,    0,    0,  183,  184,  185,  186,
+    0,    0,    0,   89,  188,    0,  709,  150,    0,  151,
+  187,    0,    0,  177,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,    0,    0,
+  180,    0,    0,    0,    0,  149,    0,    0,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,    0,
+    0,   89,  188,    0,  951,  150,    0,  151,  187,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,    0,    0,    0,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  177,  176,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,  188,    0,   89,
+  150,    0,  151,    0,    0,    0,  187,    0,    0,    0,
+    0,    0,    0,    0,  177,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,  149,    0,    0,
+    0,  181,  182,    0,    0,  183,  184,  185,  186,    0,
+  382,    0,   89,  150,    0,  151,    0,    0,    0,  187,
+    0,  152,  153,    0,    0,    0,  154,  155,  156,  157,
+    0,    0,    0,    0,    0,    0,    0,    0,  158,  159,
+  160,  161,  162,  163,  164,  149,  165,  166,  167,    0,
+    0,  168,  169,  170,    0,  171,  172,  173,  174,  175,
+    0,  176,    0,    0,    0,    0,    0,    0,    0,  152,
+  153,    0,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,    0,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,  177,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,    0,    0,
+  180,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,  188,
+    0,   89,  150,    0,  151,    0,    0,    0,  187,    0,
+    0,  177,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,    0,  180,    0,
+  149,    0,    0,    0,    0,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,    0,  507,    0,   89,
+  150,    0,  151,    0,  152,  153,  187,    0,    0,  154,
+  155,  156,  157,    0,    0,    0,    0,    0,    0,    0,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,  149,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  152,  153,    0,
+    0,    0,  154,  155,  156,  157,    0,    0,    0,    0,
+    0,    0,    0,    0,  158,  159,  160,  161,  162,  163,
+  164,    0,  165,  166,  167,    0,    0,  168,  169,  170,
+    0,  171,  172,  173,  174,  175,  177,  176,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,  382,    0,   89,  150,    0,  151,    0,    0,
+    0,  187,    0,    0,    0,    0,    0,    0,    0,  177,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  178,  179,    0,    0,    0,    0,  180,    0,    0,    0,
+    0,    0,  149,    0,    0,    0,  181,  182,    0,    0,
+  183,  184,  185,  186,    0,  908,    0,   89,  150,    0,
+  151,    0,    0,    0,  187,    0,  152,  153,    0,    0,
+    0,  154,  155,  156,  157,    0,    0,    0,    0,    0,
+    0,    0,    0,  158,  159,  160,  161,  162,  163,  164,
+  149,  165,  166,  167,    0,    0,  168,  169,  170,    0,
+  171,  172,  173,  174,  175,    0,  176,    0,    0,    0,
+    0,    0,    0,    0,  152,  153,    0,    0,    0,  154,
+  155,  156,  157,    0,  567,    0,  564,  333,    0,  334,
+    0,  158,  159,  160,  161,  162,  163,  164,    0,  165,
+  166,  167,    0,    0,  168,  169,  170,    0,  171,  172,
+  173,  174,  175,    0,  176,    0,    0,    0,  177,    0,
+  341,    0,  335,  333,    0,  334,    0,    0,    0,  178,
+  179,    0,    0,    0,    0,  180,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  181,  182,    0,    0,  183,
+  184,  185,  186,    0,    0,    0,   89,    0,    0,    0,
+    0,    0,    0,  445,    0,    0,  177,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  178,  179,    0,
+    0,    0,    0,  180,    0,  149,  247,  247,  247,    0,
+  247,    0,    0,  181,  182,    0,    0,  183,  184,  185,
+  186,    0,    0,  247,   89,  247,  247,  247,    0,  152,
+  153,  187,    0,    0,  154,  155,  156,  157,    0,    0,
+    0,    0,    0,    0,    0,    0,  158,  159,  160,  161,
+  162,  163,  164,    0,  165,  166,  167,    0,  149,  168,
+  169,  170,    0,  171,  172,  173,  174,  175,    0,  176,
+    0,    0,    0,    0,    0,    0,    0,  518,  518,  518,
+  518,  518,  152,  153,    0,    0,    0,  154,  155,  156,
+  157,    0,    0,    0,    0,    0,  518,  518,  518,  158,
+  159,  160,  161,  162,  163,  164,    0,  165,  166,  167,
+    0,    0,  168,  169,  170,    0,  171,  172,  173,  174,
+  175,  177,  176,  437,  417,  415,    0,  416,    0,    0,
+    0,    0,  178,  179,    0,    0,    0,  565,  180,    0,
+    0,    0,  420,  403,  421,    0,    0,    0,  181,  182,
+    0,    0,  183,  184,  185,  186,  601,  417,  415,  892,
+  416,    0,  336,  337,  338,    0,  187,  339,    0,    0,
+    0,    0,    0,    0,  177,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,  178,  179,    0,    0,    0,
+    0,  180,    0,    0,    0,    0,    0,    0,  336,  337,
+  338,  181,  182,  339,    0,  183,  184,  185,  186,    0,
+    0,    0,   89,    0,    0,    0,    0,    0,    0,  187,
+    0,    0,    0,  247,  247,  247,  247,  247,    0,  247,
+  247,  247,  247,  247,  247,    0,    0,  247,  247,  608,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  178,  179,    0,    0,  420,  403,
+  421,    0,    0,  622,  417,  415,    0,  416,    0,    0,
+  181,  182,    0,    0,  183,  184,  185,  186,    0,    0,
+    0,  566,  420,  403,  421,    0,    0,    0,  187,    0,
+  178,  179,    0,    0,  518,  518,  518,  518,  518,    0,
+  518,  518,  518,  518,  518,  518,  181,  182,  518,  518,
+  183,  184,  185,  186,  638,  417,  415,  340,  416,    0,
+    0,    0,    0,    0,  187,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  672,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,  677,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,  679,  417,  415,    0,  416,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  420,  403,  421,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,  781,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  782,  417,  415,
+    0,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,  783,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,  784,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,  785,  417,
+  415,    0,  416,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  420,  403,  421,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  786,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,  787,  417,  415,    0,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  788,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,  789,  417,  415,    0,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,    0,
+    0,    0,    0,    0,    0,  404,  405,  406,  407,  408,
+    0,  409,  410,  411,  412,  413,  414,    0,    0,  418,
+  419,  790,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,  791,  417,  415,    0,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  792,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,  793,
+  417,  415,    0,  416,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  420,  403,
+  421,  802,  417,  415,    0,  416,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  420,  403,  421,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  862,  417,  415,    0,  416,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  420,  403,  421,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  904,  417,  415,
+    0,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,  247,
+  247,  247,    0,  247,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  247,  247,
+  247,  417,  415,  680,  416,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  420,
+  403,  421,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  404,  405,  406,  407,
+  408,    0,  409,  410,  411,  412,  413,  414,    0,    0,
+  418,  419,    0,    0,    0,    0,    0,    0,  404,  405,
+  406,  407,  408,    0,  409,  410,  411,  412,  413,  414,
+    0,    0,  418,  419,  417,  415,  933,  416,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  420,  403,  421,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  404,  405,  406,  407,  408,    0,  409,  410,  411,
+  412,  413,  414,    0,    0,  418,  419,  417,  415,  969,
+  416,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  420,  403,  421,  417,  415,
+  970,  416,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,  420,  403,  421,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,  247,  247,  247,  247,
+  247,    0,  247,  247,  247,  247,  247,  247,    0,    0,
+  247,  247,    0,    0,    0,    0,    0,  404,  405,  406,
+  407,  408,    0,  409,  410,  411,  412,  413,  414,    0,
+    0,  418,  419,  417,  415,  975,  416,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,  420,  403,  421,  247,  247,  247,  247,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  247,  247,  247,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+  404,  405,  406,  407,  408,    0,  409,  410,  411,  412,
+  413,  414,    0,    0,  418,  419,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,  404,  405,  406,  407,  408,    0,  409,
+  410,  411,  412,  413,  414,    0,    0,  418,  419,    0,
+    0,    0,    0,    0,  404,  405,  406,  407,  408,    0,
+  409,  410,  411,  412,  413,  414,    0,    0,  418,  419,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,  404,
+  405,  406,  407,  408,    0,  409,  410,  411,  412,  413,
+  414,    0,    0,  418,  419,    0,    0,    0,    0,    0,
+  247,  247,  247,  247,  247,    0,  247,  247,  247,  247,
+  247,  247,    0,   16,  247,  247,   17,    0,   18,   19,
+    0,    0,   20,    0,    0,   21,   22,   23,    0,    0,
+    0,    0,   24,   25,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,   26,    0,    0,
+    0,   27,   28,    0,    0,    0,   29,    0,    0,    0,
+    0,    0,   30,    0,   31,   32,    0,   33,    0,   34,
+   35,   36,   37,   38,    0,   39,   40,   41,   42,   43,
+   44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
+   54,    0,    0,   55,   56,   57,    0,   58,   59,   60,
+    0,   61,   62,   63,    0,    0,   64,    0,   65,    0,
+    0,   66,   67,   68,   69,    0,    0,   70,   71,   72,
+    0,    0,    0,    0,    0,   73,    0,    0,    0,   74,
+   75,   76,   77,   78,   79,   80,    0,   81,   82,   83,
+   84,   85,    0,    0,   86,    0,    0,    0,    0,    0,
+    0,   87,   88,   89,    0,    0,    0,    0,    0,    0,
+   90,
+};
+short fortrancheck[] = {                                      24,
+  231,   26,  140,  309,  194,   30,   33,  177,   33,  236,
+  231,  347,  290,  331,   39,  236,   19,   11,  296,  140,
+   44,  303,  394,  341,  177,   40,   40,   40,   44,   40,
+   40,  349,   44,  529,   10,  188,   10,   10,   10,  295,
+   42,  177,   58,   40,   68,   69,  302,   44,   41,   42,
+   41,   42,   76,  279,   44,  382,  449,   40,  581,   44,
+   37,   58,  585,  731,   41,   59,  106,   44,   58,   93,
+   94,   95,   42,   43,   44,   45,  765,   37,   44,   42,
+  111,  234,   58,   44,   61,  735,  143,   44,   37,  120,
+  121,   40,   58,  231,  373,   10,   32,   58,  236,   37,
+   10,   61,  504,   41,  417,  130,   44,   60,  135,   62,
+  135,  424,   61,  800,  801,  517,   10,  425,  217,  271,
+  272,   57,   58,  148,  149,   42,   43,  417,   45,   44,
+   10,   42,  157,  371,  128,   43,   44,   45,  417,  238,
+   41,   42,   43,   60,   45,   62,  171,  385,   58,   60,
+   40,   62,  177,  271,  272,   41,  104,   40,   44,  107,
+  271,  272,   44,  188,   58,   41,  417,  192,   44,  578,
+   44,  427,   58,   40,  344,   42,   58,  586,  203,  847,
+  350,  579,   58,  581,   58,  210,   40,  585,   43,   44,
+   45,  417,   40,  331,  219,  524,  885,  350,  885,  224,
+  529,   37,   40,  341,   41,   41,  344,   44,   44,  234,
+  331,  349,  382,  207,  350,  386,  387,  388,  868,  244,
+  341,   58,    0,  344,  281,   42,  328,  329,  349,  382,
+   47,  487,   10,  569,  490,  541,  276,  231,  417,  545,
+  234,  577,  236,  237,  912,  270,  382,   40,  242,  567,
+   42,   43,   41,   45,   40,   44,  512,  593,   58,  272,
+  272,  264,  293,  401,   40,  417,   42,  283,   40,   58,
+  588,  589,  590,  591,  592,   43,   41,   45,  534,   44,
+  283,  275,  307,   40,  309,  375,  283,  272,  319,  271,
+  272,   42,   43,  283,   45,   40,   41,  322,  323,  417,
+  271,  272,  272,  328,  298,  632,  417,  634,  635,  272,
+  273,  336,  337,  338,  339,  272,  417,  283,  549,  255,
+  273,   41,  283,  550,   44,  350,  320,   44,  549,  550,
+  324,   42,  280,  271,  272,  360,  156,   58,  158,  364,
+  365,  366,  367,  368,  369,  370,  371,  372,  373,  374,
+  375,  744,  745,  275,  507,  272,  273,  382,  140,  141,
+  856,  272,  273,  886,  272,  763,  764,  863,  766,  394,
+  271,  272,  273,   41,   42,   43,  256,   45,  403,  404,
+  405,  406,  407,  408,  409,  410,  411,  412,  413,  414,
+  415,  416,  417,  418,  419,  420,  421,  374,  423,  424,
+  406,  417,  417,  119,  284,  285,  122,  417,  578,  424,
+  424,  549,  550,  424,  374,  417,  586,  272,  281,  755,
+  417,  301,  302,  406,  417,  374,  417,  417,  734,  567,
+   44,   44,  768,  769,  770,  771,  772,  719,  756,  811,
+  578,  417,  720,  417,  417,  417,  567,   44,  586,  705,
+  588,  589,  590,  591,  592,  682,  417,  578,  417,  417,
+  687,  682,  486,   44,   40,  586,  687,  588,  589,  590,
+  591,  592,  799,  800,  801,  417,   40,  424,  256,  271,
+  272,  273,  507,   40,  637,   40,  511,   40,  886,   40,
+  521,  747,  523,  518,   40,   40,  632,  275,  634,  635,
+  525,   41,  533,  281,   44,   40,  284,  285,   42,   43,
+   44,   45,  392,   47,  539,   41,  541,   40,   44,   40,
+  545,  272,  273,  301,  302,   40,   40,  856,  857,  858,
+  859,  860,   42,   43,  863,   45,   40,   47,  358,  359,
+  938,  566,   40,   40,  682,  425,   37,  883,   40,  687,
+   41,  576,   40,   44,   40,  549,  550,  377,  378,  379,
+  380,  381,   37,   40,  870,  417,   41,   40,  824,   44,
+  390,   40,   40,  289,  601,  291,  601,  602,   40,   42,
+   43,   40,   45,  299,   41,   42,   43,   40,   45,   37,
+  846,   42,   43,   44,   45,  765,   47,   60,   61,   62,
+  753,  722,   40,  271,  272,  273,  417,  632,   41,  634,
+  635,   44,  637,   44,  392,   58,  641,   41,  756,  644,
+   44,  877,  857,  858,  859,  860,   37,  765,  818,   40,
+   41,   42,   43,   44,   45,  756,  661,  662,  417,   41,
+  417,  666,   44,  668,  765,   41,  799,  425,   44,   60,
+  881,   62,   44,   44,   41,  680,  681,   44,   41,   41,
+   58,   44,   44,  799,  800,  801,   41,   37,  693,   44,
+  695,  417,   42,   43,   41,   45,   41,   44,   41,   44,
+  674,   44,   41,  708,   41,   44,   41,   44,  682,   44,
+   60,   61,   62,  687,   44,  689,   41,    0,   41,   44,
+   41,   44,   41,   44,   40,   44,  424,   10,   61,  734,
+  390,  391,  417,   41,   41,  885,   44,   44,   44,   41,
+   41,  746,   44,   44,  417,  750,  406,  407,  753,  417,
+  410,  411,  412,  413,  417,   44,  730,   40,  272,   42,
+   43,   44,   45,   41,  424,  390,  391,  885,   41,   41,
+   41,   44,   44,   44,   44,  908,   40,   60,   61,   62,
+   41,  406,  407,   44,  885,  410,  411,  412,  413,   41,
+   41,   40,   44,   44,  799,  800,  801,   41,   41,  424,
+   44,   44,   41,  424,   41,   44,  811,   44,  813,   41,
+   41,   41,   44,   44,   44,  258,  259,  260,  261,  262,
+   61,  264,  265,  266,  267,  268,  269,   44,   41,  272,
+  273,   44,  278,  838,  271,  272,  273,   41,   41,   41,
+   44,   44,   44,   41,   44,  850,   44,  852,   41,   44,
+  380,   44,   44,   44,   44,   40,   44,   37,   41,   41,
+   44,   40,  272,   44,  417,  870,   40,  258,  259,  260,
+  261,  262,  417,  264,  265,  266,  267,  268,  269,   41,
+   44,  272,  273,  417,   41,  417,   61,   41,  424,   44,
+  273,   44,   40,  898,   44,  900,  901,   44,   44,   58,
+   41,   41,  332,  908,  417,   41,   41,  881,  258,  259,
+  260,  261,  262,   42,  264,  265,  266,  267,  268,  269,
+   58,  417,  272,  273,   41,   37,  272,    0,  933,   40,
+   42,   43,  906,   45,  272,  940,  272,   10,   41,   58,
+  374,  946,  417,   44,  949,   41,   44,   61,   60,   61,
+   62,   41,  417,  417,   41,   41,   41,  962,   41,   61,
+   41,  966,   41,   41,  969,  970,  374,   44,  272,   41,
+  975,   44,   47,  256,  417,  258,  259,  260,  261,  262,
+   44,  264,  265,  266,  267,  268,  269,   41,  271,  272,
+  273,   61,  275,  417,  277,  417,  417,  280,  281,  282,
+  283,  284,  285,  286,  287,  288,  289,  290,  291,  292,
+  293,  294,  295,  296,  297,  417,  417,   44,  301,  302,
+   41,  304,  305,  306,  307,  308,  309,  310,  311,  312,
+  313,  314,  315,  316,  317,  318,  319,  320,  321,  322,
+  323,  324,  325,  326,  327,  328,  329,   41,  331,   58,
+  333,  334,  335,  336,  337,   41,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   41,   41,  357,  358,  359,   44,  361,  362,
+  363,   41,  365,  366,  367,   41,  272,  370,   41,  372,
+   41,   41,  375,  376,  377,  378,   41,  775,  381,  382,
+  383,  850,  957,  873,  520,  271,  389,  390,  391,  392,
+  393,  394,  395,  396,  397,  398,  399,  285,  401,  402,
+  403,  404,  405,  406,  407,  408,    0,  410,  411,  412,
+  413,  773,  415,  416,  417,  350,   10,  382,  681,  402,
+  900,  424,  425,  753,  852,    9,  258,  259,  260,  261,
+  262,   13,  264,  265,  266,  267,  268,  269,   74,  275,
+  272,  273,  691,   37,  429,  952,  539,   41,   42,   43,
+   44,   45,  695,   47,  528,  502,  537,  701,  557,  128,
+  549,  750,  550,  256,   58,  559,   60,   61,   62,  756,
+   -1,   -1,  140,   -1,   -1,   -1,   -1,   -1,  271,  272,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   37,   -1,  408,   -1,   41,   42,   43,
+   44,   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   58,   -1,   60,   61,   62,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,  271,  272,  273,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   40,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   40,   -1,   -1,   43,   -1,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  256,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,  271,  272,  273,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   37,   -1,  408,   -1,   41,   42,   43,   44,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   58,   -1,   60,   61,   62,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,    0,   -1,   -1,  396,   -1,
+   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   -1,   37,   -1,  379,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   58,   -1,   60,   61,   62,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,  273,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   40,   -1,  408,   43,   -1,   45,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  256,   61,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,  273,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   42,   43,   -1,   45,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   60,  326,   62,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,  277,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   40,   41,   42,   43,   44,   45,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   58,   -1,   60,   61,   62,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  328,  329,  330,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   42,   43,   -1,
+   45,   -1,   -1,   -1,  263,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  272,   -1,   60,  357,   62,  359,  360,
+  361,   -1,   -1,  364,  365,   -1,  367,  368,  287,  288,
+   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,
+  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,  318,
+  319,   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  379,   37,   -1,   -1,   -1,   41,   42,   43,   44,   45,
+   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,
+   -1,   -1,   58,   -1,   60,   61,   62,  406,  407,   -1,
+   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,
+  256,   -1,  258,  259,  260,  261,  262,   -1,  264,  265,
+  266,  267,  268,  269,   -1,  271,  272,  273,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,  262,   -1,  264,
+  265,  266,  267,  268,  269,  311,   -1,  272,  273,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   40,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   40,   -1,   42,   43,   -1,   45,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  256,   58,  258,  259,  260,  261,  262,   -1,  264,  265,
+  266,  267,  268,  269,   -1,  271,  272,  273,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,  380,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   37,   -1,  408,   -1,   41,   42,   43,   44,   45,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,   58,   -1,   60,   61,   62,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,   -1,  312,  313,  314,   -1,  263,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,
+  307,  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,
+  317,  318,  319,   -1,  321,  322,  323,  324,  325,   -1,
+  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,    0,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,   -1,   10,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   -1,   -1,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  379,   -1,   41,   42,   43,   44,   45,   -1,
+   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,
+   -1,   58,   -1,   60,   61,   62,   -1,   -1,   -1,  406,
+  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,  256,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,  271,  272,  273,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   40,   -1,   42,   43,   -1,   45,  415,  416,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  256,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,  271,  272,  273,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   42,   43,
+   -1,   45,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   60,   -1,   62,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,   42,   43,   44,   45,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,  288,   -1,   -1,
+   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,  310,
+   -1,  312,  313,  314,   -1,  263,  317,  318,  319,   -1,
+   -1,  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,
+   -1,  379,   -1,   41,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+   58,   -1,   -1,   61,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   -1,   -1,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,  256,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  256,   -1,
+  258,  259,  260,  261,  262,    0,  264,  265,  266,  267,
+  268,  269,   -1,  271,  272,   10,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   37,  301,  302,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   58,   -1,   -1,   61,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,   -1,  288,    0,   -1,   -1,  292,  293,
+  294,  295,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,
+  304,  305,  306,  307,  308,  309,  310,   -1,  312,  313,
+  314,   -1,   -1,  317,  318,  319,   -1,   -1,  322,  323,
+  324,  325,   37,  327,   -1,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   58,   -1,   -1,   61,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,  417,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  256,   -1,  258,  259,  260,  261,  262,    0,  264,
+  265,  266,  267,  268,  269,   -1,  271,  272,   10,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   37,  301,  302,   -1,   41,
+   42,   43,   44,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   58,   -1,   -1,   61,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,  380,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,  286,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,  311,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,   -1,   -1,   -1,  331,
+  332,   -1,   -1,   -1,  336,  337,   -1,   -1,   -1,   41,
+   42,   43,   44,   45,  346,  347,  348,  349,  350,  351,
+  352,  353,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,  366,   -1,   -1,   -1,   -1,   -1,
+  372,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  381,
+   -1,  383,   -1,   -1,  256,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,  271,
+  272,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,  417,   -1,  289,  290,  291,
+   -1,   -1,  424,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   40,   -1,   42,
+   43,   -1,   45,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  256,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,   42,
+   43,   -1,   45,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   60,   61,   62,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   37,   -1,  379,   -1,   41,   -1,
+   43,   44,   45,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   58,   -1,   -1,   61,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,   -1,  256,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,  256,   -1,  258,  259,  260,  261,  262,
+    0,  264,  265,  266,  267,  268,  269,   -1,  271,   -1,
+   10,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   37,  301,  302,
+   -1,   41,   -1,   43,   44,   45,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   58,   -1,
+   -1,   61,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,   42,   -1,   44,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,   -1,
+   60,   -1,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,    0,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  256,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,  271,   -1,  273,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+  380,  381,  382,  383,   37,   -1,   -1,   -1,   41,  389,
+   -1,   44,  392,  393,  394,  395,   -1,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   60,  408,   62,
+   -1,   42,   43,   44,   45,  415,  416,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  425,   -1,   -1,   -1,   60,
+   61,   62,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,   -1,   -1,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,   -1,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   42,   43,   44,   45,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,  260,
+  261,  262,   -1,  264,  265,  266,  267,  268,  269,   -1,
+   -1,  272,  273,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,    0,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   10,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,   -1,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,   -1,   -1,   -1,  415,  416,   -1,  256,   -1,  258,
+  259,  260,  261,  262,  425,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,   -1,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   37,  256,  408,
+   -1,   41,   -1,   -1,   44,   -1,  415,  416,   -1,   -1,
+   -1,   -1,   -1,  271,  272,   -1,  425,  275,   58,  277,
+   -1,   61,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   37,   -1,
+  408,   -1,   41,   -1,   -1,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,  417,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   58,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,  262,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   42,   43,
+  370,   45,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   60,   61,   62,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,  260,  261,  262,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,    0,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   10,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+  260,  261,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   40,  328,  329,
+   43,  331,   45,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   40,   -1,   42,   43,  389,
+   45,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   61,  256,  408,  258,
+  259,  260,  261,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   37,   -1,  408,
+   40,   41,   42,   43,   44,   45,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  298,  299,  300,   -1,   -1,
+  303,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  263,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  273,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,    0,  327,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,   37,   -1,
+   -1,  424,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   61,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,  272,  273,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,  258,
+  259,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+    0,   -1,  271,   -1,  424,  425,  275,   -1,  277,   -1,
+   10,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   37,   -1,   -1,
+   -1,   41,  311,   -1,   44,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   58,  328,
+  329,   61,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   10,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,
+   43,   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,  258,  259,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,  256,   -1,  415,  416,  417,   -1,   -1,
+   -1,    0,   -1,   -1,  424,  425,   -1,   -1,  271,  272,
+  273,   10,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   41,   42,   43,   44,   45,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,    0,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   10,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   42,   43,
+   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  271,  272,  273,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,  256,   -1,   -1,   -1,  415,  416,   -1,   -1,
+    0,   -1,   -1,   -1,   -1,  424,  425,  271,  272,  273,
+   10,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   41,   42,   43,   44,   45,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,    0,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,   -1,   10,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,  256,   -1,   -1,   -1,  415,  416,  417,    0,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  271,  272,   10,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   41,
+   42,   43,   44,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,    0,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   41,   42,   43,   44,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  271,
+  272,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,  256,
+   -1,   -1,   -1,  415,  416,  417,    0,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  271,  272,   10,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   37,  301,  302,   -1,   41,   -1,   -1,
+   44,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   58,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,    0,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   10,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   37,   -1,
+   -1,   -1,   41,   -1,   -1,   44,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   58,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,  380,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   41,  256,   43,   44,
+   45,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   41,  256,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   41,  256,   -1,   44,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  271,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   42,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   61,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,  256,   -1,   44,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   41,   -1,
+   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  271,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,    0,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   10,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,  256,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  271,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   10,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,
+  256,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  271,  272,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   41,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,
+  275,   58,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   10,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   -1,   42,  256,   44,   -1,  415,
+  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,    0,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   10,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+    0,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   10,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,  271,  272,  424,  425,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,   -1,   41,   -1,  256,   44,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   41,   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   41,   -1,  256,   44,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   41,
+   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   41,   -1,  256,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,
+   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,    0,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   10,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   44,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,  256,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,    0,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   10,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   44,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,  380,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,   -1,   -1,   -1,  256,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,    0,   -1,   -1,  315,  316,
+   -1,   -1,   -1,  320,   -1,   10,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   44,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   61,   -1,  375,  376,
+  377,  378,   -1,  380,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,   -1,   -1,   -1,  256,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   10,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,  380,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,  256,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   10,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   44,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,  271,  272,  424,
+  425,  275,   -1,  277,   -1,   61,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   41,   -1,   -1,   44,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,  278,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,  380,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   41,
+   -1,   -1,   44,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   10,  380,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,
+  408,   -1,   -1,   -1,   -1,   44,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,
+   -1,   44,   -1,  415,  416,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+    0,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   10,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+   -1,   -1,   -1,   -1,   44,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   10,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   44,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,    0,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,    0,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   10,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   44,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   -1,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,    0,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   10,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,   -1,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  256,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,
+   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,
+  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,
+   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+  425,   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,
+   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,  275,   -1,  277,   -1,   -1,  280,
+  281,  282,  283,  284,  285,  286,   -1,   -1,  289,  290,
+  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,
+  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,
+  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,
+   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,
+  331,   -1,  333,  334,  335,  336,  337,   -1,  339,  340,
+  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
+  351,  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,
+  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,
+   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,
+  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,
+   -1,  392,  393,  394,  395,  396,  397,  398,  399,   -1,
+  401,  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,
+   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,
+   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   -1,  256,
+  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,
+   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,  275,   -1,
+  277,   -1,   -1,  280,  281,  282,  283,  284,  285,  286,
+   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,
+  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,  316,
+   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,
+   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,  336,
+  337,   -1,  339,  340,  341,  342,  343,  344,  345,  346,
+  347,  348,  349,  350,  351,  352,  353,  354,   -1,   -1,
+  357,  358,  359,   -1,  361,  362,  363,   -1,  365,  366,
+  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,
+  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,   -1,
+   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,  396,
+  397,  398,  399,   -1,  401,  402,  403,  404,  405,   -1,
+   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,
+  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,
+   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,
+  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,
+    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,  425,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,   -1,
+  280,  281,  282,  283,  284,  285,  286,   -1,   -1,  289,
+  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,
+   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,   -1,
+  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,  329,
+   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,  339,
+  340,  341,  342,  343,  344,  345,  346,  347,  348,  349,
+  350,  351,  352,  353,  354,   -1,   -1,  357,  358,  359,
+   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,   -1,
+  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,   -1,
+   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,  389,
+   -1,   -1,  392,  393,  394,  395,  396,  397,  398,  399,
+   -1,  401,  402,  403,  404,  405,   -1,  256,  408,   -1,
+   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,   -1,
+   -1,   -1,   -1,   -1,  424,  425,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,    0,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   10,   -1,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,  396,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,   -1,  408,
+  256,   -1,   -1,   -1,   -1,   -1,  415,  416,  417,   -1,
+   -1,   -1,   -1,   -1,   -1,  424,  425,   -1,   -1,  275,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,    0,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   10,   -1,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+  256,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,  415,
+  416,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,  285,
+  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,   -1,
+  296,  297,   -1,   -1,   -1,  301,  302,   -1,    0,   -1,
+   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,   10,  315,
+  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,
+  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,  335,
+  336,  337,   -1,  339,  340,  341,  342,  343,  344,  345,
+  346,  347,  348,  349,  350,  351,  352,  353,  354,   -1,
+   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,  365,
+  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,  375,
+  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,   -1,
+   -1,   -1,   -1,  389,   -1,   -1,  392,  393,  394,  395,
+  396,  397,  398,  399,   -1,  401,  402,  403,  404,  405,
+   -1,   -1,  408,  256,   -1,   -1,   -1,   -1,   -1,  415,
+  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,  425,
+   -1,   -1,  275,   -1,  277,   -1,   -1,  280,  281,  282,
+  283,  284,  285,  286,   -1,   -1,  289,  290,  291,   -1,
+   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,  302,
+   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,
+   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,
+   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,
+  333,  334,  335,  336,  337,   -1,  339,  340,  341,  342,
+  343,  344,  345,  346,  347,  348,  349,  350,  351,  352,
+  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,
+  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,
+   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,
+  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,  392,
+  393,  394,  395,  396,  397,  398,  399,   -1,  401,  402,
+  403,  404,  405,   -1,  256,  408,   -1,   -1,   -1,   -1,
+   -1,   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  425,  275,   -1,  277,   -1,   -1,  280,  281,
+  282,  283,  284,  285,  286,   -1,   -1,  289,  290,  291,
+   -1,   -1,   -1,   -1,  296,  297,   -1,   -1,   -1,  301,
+  302,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,  311,
+   -1,   -1,   10,  315,  316,   -1,   -1,   -1,  320,   -1,
+   -1,   -1,   -1,   -1,  326,   -1,  328,  329,   -1,  331,
+   -1,  333,  334,  335,  336,  337,   -1,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,   -1,   -1,  357,  358,  359,   -1,  361,
+  362,  363,   -1,  365,  366,  367,   -1,   -1,  370,   -1,
+  372,   -1,   -1,  375,  376,  377,  378,   -1,   -1,  381,
+  382,  383,   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,
+  392,  393,  394,  395,  396,  397,  398,  399,   -1,  401,
+  402,  403,  404,  405,   -1,   -1,  408,  256,   -1,   -1,
+   -1,   -1,   -1,  415,  416,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  424,  425,   -1,   -1,  275,   -1,  277,   -1,
+   -1,  280,  281,  282,  283,  284,  285,  286,   -1,   -1,
+  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,   -1,
+   -1,   -1,  301,  302,   -1,    0,   -1,   -1,   -1,   -1,
+   -1,   -1,  311,   -1,   -1,   10,  315,  316,   -1,   -1,
+   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,  328,
+  329,   -1,  331,   -1,  333,  334,  335,  336,  337,   -1,
+  339,  340,  341,  342,  343,  344,  345,  346,  347,  348,
+  349,  350,  351,  352,  353,  354,   -1,   -1,  357,  358,
+  359,   -1,  361,  362,  363,   -1,  365,  366,  367,   -1,
+   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,  378,
+   -1,   -1,  381,  382,  383,   -1,   -1,   -1,   -1,   -1,
+  389,   -1,   -1,  392,  393,  394,  395,   -1,  397,  398,
+  399,   -1,  401,  402,  403,  404,  405,   -1,  256,  408,
+   -1,   -1,   -1,   -1,   -1,   -1,  415,  416,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  425,  275,   -1,  277,
+   -1,   -1,  280,  281,  282,  283,  284,  285,  286,   -1,
+   -1,  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,
+   -1,   -1,   -1,  301,  302,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  311,   -1,   -1,   -1,  315,  316,   -1,
+   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,  326,   -1,
+  328,  329,   -1,  331,   -1,  333,  334,  335,  336,  337,
+   -1,  339,  340,  341,  342,  343,  344,  345,  346,  347,
+  348,  349,  350,  351,  352,  353,  354,   -1,   -1,  357,
+  358,  359,   -1,  361,  362,  363,   -1,  365,  366,  367,
+   -1,   -1,  370,   -1,  372,   -1,   -1,  375,  376,  377,
+  378,   -1,   -1,  381,  382,  383,   -1,   40,   -1,   42,
+   43,  389,   45,   -1,  392,  393,  394,  395,   -1,  397,
+  398,  399,   -1,  401,  402,  403,  404,  405,   61,   -1,
+  408,  256,   -1,   -1,   -1,   -1,   -1,  415,  416,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  425,   -1,   -1,
+  275,   -1,  277,   -1,   -1,  280,  281,  282,  283,  284,
+  285,  286,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,
+   -1,  296,  297,   -1,   -1,   -1,  301,  302,   -1,   41,
+   42,   43,   -1,   45,   -1,   -1,  311,   -1,   -1,   -1,
+  315,  316,   -1,   -1,   -1,  320,   58,   -1,   60,   61,
+   62,  326,   -1,  328,  329,   -1,  331,   -1,  333,  334,
+  335,  336,  337,   -1,  339,  340,  341,  342,  343,  344,
+  345,  346,  347,  348,  349,  350,  351,  352,  353,  354,
+   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,   -1,
+  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,   -1,
+  375,  376,  377,  378,   -1,   -1,  381,  382,  383,   -1,
+   40,   -1,   42,   43,  389,   45,   -1,  392,  393,  394,
+  395,  396,  397,  398,  399,   -1,  401,  402,  403,  404,
+  405,   61,   -1,  408,   -1,   -1,   -1,   -1,   -1,   -1,
+  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   40,   -1,
+   -1,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   61,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  379,   40,   -1,   -1,
+   43,   -1,   45,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   61,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,  263,  417,   -1,   -1,   -1,   -1,   -1,
+   -1,  424,   -1,   -1,   -1,   40,   -1,   -1,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   61,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,  263,  312,  313,  314,   -1,   -1,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,
+  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  304,  305,  306,  307,  308,  309,  310,   -1,
+  312,  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,
+  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,  379,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   -1,   40,  417,   42,   43,
+   -1,   45,   -1,   -1,  424,   -1,   -1,  379,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,
+   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,
+  263,   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,
+  412,  413,   -1,   -1,   40,  417,   42,   43,   -1,   45,
+   -1,   -1,  424,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,  263,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,   -1,  327,   -1,   -1,   -1,  379,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   40,   -1,  417,   43,   -1,   45,   -1,   -1,
+   -1,  424,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,
+   58,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  263,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   40,   -1,   -1,   43,  424,
+   45,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,
+  294,  295,   -1,   58,   -1,   -1,   -1,   -1,   -1,   -1,
+  304,  305,  306,  307,  308,  309,  310,  263,  312,  313,
+  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,
+  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,
+  306,  307,  308,  309,  310,   -1,  312,  313,  314,   -1,
+   -1,  317,  318,  319,   -1,  321,  322,  323,  324,  325,
+   -1,  327,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,
+   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,
+   -1,   -1,   -1,  417,   40,   -1,   42,   43,   -1,   45,
+  424,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,
+  396,   -1,   -1,   -1,   -1,  263,   -1,   -1,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,
+   -1,  417,   40,   -1,   42,   43,   -1,   45,  424,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,  379,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   40,   -1,  417,
+   43,   -1,   45,   -1,   -1,   -1,  424,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,  263,   -1,   -1,
+   -1,  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,
+   40,   -1,  417,   43,   -1,   45,   -1,   -1,   -1,  424,
+   -1,  287,  288,   -1,   -1,   -1,  292,  293,  294,  295,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,
+  306,  307,  308,  309,  310,  263,  312,  313,  314,   -1,
+   -1,  317,  318,  319,   -1,  321,  322,  323,  324,  325,
+   -1,  327,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,
+  288,   -1,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,   -1,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,
+  396,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   40,
+   -1,  417,   43,   -1,   45,   -1,   -1,   -1,  424,   -1,
+   -1,  379,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,   -1,  396,   -1,
+  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   -1,   40,   -1,  417,
+   43,   -1,   45,   -1,  287,  288,  424,   -1,   -1,  292,
+  293,  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,  263,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,  288,   -1,
+   -1,   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,
+  310,   -1,  312,  313,  314,   -1,   -1,  317,  318,  319,
+   -1,  321,  322,  323,  324,  325,  379,  327,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   40,   -1,  417,   43,   -1,   45,   -1,   -1,
+   -1,  424,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  379,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  390,  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,
+   -1,   -1,  263,   -1,   -1,   -1,  406,  407,   -1,   -1,
+  410,  411,  412,  413,   -1,   40,   -1,  417,   43,   -1,
+   45,   -1,   -1,   -1,  424,   -1,  287,  288,   -1,   -1,
+   -1,  292,  293,  294,  295,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  304,  305,  306,  307,  308,  309,  310,
+  263,  312,  313,  314,   -1,   -1,  317,  318,  319,   -1,
+  321,  322,  323,  324,  325,   -1,  327,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  287,  288,   -1,   -1,   -1,  292,
+  293,  294,  295,   -1,   40,   -1,   42,   43,   -1,   45,
+   -1,  304,  305,  306,  307,  308,  309,  310,   -1,  312,
+  313,  314,   -1,   -1,  317,  318,  319,   -1,  321,  322,
+  323,  324,  325,   -1,  327,   -1,   -1,   -1,  379,   -1,
+   40,   -1,   42,   43,   -1,   45,   -1,   -1,   -1,  390,
+  391,   -1,   -1,   -1,   -1,  396,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  406,  407,   -1,   -1,  410,
+  411,  412,  413,   -1,   -1,   -1,  417,   -1,   -1,   -1,
+   -1,   -1,   -1,  424,   -1,   -1,  379,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,
+   -1,   -1,   -1,  396,   -1,  263,   41,   42,   43,   -1,
+   45,   -1,   -1,  406,  407,   -1,   -1,  410,  411,  412,
+  413,   -1,   -1,   58,  417,   60,   61,   62,   -1,  287,
+  288,  424,   -1,   -1,  292,  293,  294,  295,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,  307,
+  308,  309,  310,   -1,  312,  313,  314,   -1,  263,  317,
+  318,  319,   -1,  321,  322,  323,  324,  325,   -1,  327,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   41,   42,   43,
+   44,   45,  287,  288,   -1,   -1,   -1,  292,  293,  294,
+  295,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,  304,
+  305,  306,  307,  308,  309,  310,   -1,  312,  313,  314,
+   -1,   -1,  317,  318,  319,   -1,  321,  322,  323,  324,
+  325,  379,  327,   41,   42,   43,   -1,   45,   -1,   -1,
+   -1,   -1,  390,  391,   -1,   -1,   -1,  273,  396,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,  406,  407,
+   -1,   -1,  410,  411,  412,  413,   41,   42,   43,  417,
+   45,   -1,  298,  299,  300,   -1,  424,  303,   -1,   -1,
+   -1,   -1,   -1,   -1,  379,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   -1,
+   -1,  396,   -1,   -1,   -1,   -1,   -1,   -1,  298,  299,
+  300,  406,  407,  303,   -1,  410,  411,  412,  413,   -1,
+   -1,   -1,  417,   -1,   -1,   -1,   -1,   -1,   -1,  424,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  390,  391,   -1,   -1,   60,   61,
+   62,   -1,   -1,   41,   42,   43,   -1,   45,   -1,   -1,
+  406,  407,   -1,   -1,  410,  411,  412,  413,   -1,   -1,
+   -1,  417,   60,   61,   62,   -1,   -1,   -1,  424,   -1,
+  390,  391,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,  406,  407,  272,  273,
+  410,  411,  412,  413,   41,   42,   43,  417,   45,   -1,
+   -1,   -1,   -1,   -1,  424,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   41,   42,   43,   -1,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   41,   42,   43,
+   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,   42,
+   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   41,   42,   43,   -1,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   -1,
+   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,
+   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,  272,
+  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   41,   42,   43,   -1,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   41,   42,   43,   -1,   45,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   60,   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   41,   42,   43,   -1,   45,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   60,   61,   62,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   41,   42,   43,
+   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   41,
+   42,   43,   -1,   45,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,
+   62,   42,   43,   44,   45,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   60,
+   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
+  260,  261,  262,   -1,  264,  265,  266,  267,  268,  269,
+   -1,   -1,  272,  273,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  258,  259,  260,  261,  262,   -1,  264,  265,  266,
+  267,  268,  269,   -1,   -1,  272,  273,   42,   43,   44,
+   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   42,   43,
+   44,   45,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   60,   61,   62,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,
+  262,   -1,  264,  265,  266,  267,  268,  269,   -1,   -1,
+  272,  273,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,
+  261,  262,   -1,  264,  265,  266,  267,  268,  269,   -1,
+   -1,  272,  273,   42,   43,   44,   45,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   60,   61,   62,   42,   43,   44,   45,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   60,   61,   62,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,  264,
+  265,  266,  267,  268,  269,   -1,   -1,  272,  273,   -1,
+   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,   -1,
+  264,  265,  266,  267,  268,  269,   -1,   -1,  272,  273,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,
+  259,  260,  261,  262,   -1,  264,  265,  266,  267,  268,
+  269,   -1,   -1,  272,  273,   -1,   -1,   -1,   -1,   -1,
+  258,  259,  260,  261,  262,   -1,  264,  265,  266,  267,
+  268,  269,   -1,  277,  272,  273,  280,   -1,  282,  283,
+   -1,   -1,  286,   -1,   -1,  289,  290,  291,   -1,   -1,
+   -1,   -1,  296,  297,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  311,   -1,   -1,
+   -1,  315,  316,   -1,   -1,   -1,  320,   -1,   -1,   -1,
+   -1,   -1,  326,   -1,  328,  329,   -1,  331,   -1,  333,
+  334,  335,  336,  337,   -1,  339,  340,  341,  342,  343,
+  344,  345,  346,  347,  348,  349,  350,  351,  352,  353,
+  354,   -1,   -1,  357,  358,  359,   -1,  361,  362,  363,
+   -1,  365,  366,  367,   -1,   -1,  370,   -1,  372,   -1,
+   -1,  375,  376,  377,  378,   -1,   -1,  381,  382,  383,
+   -1,   -1,   -1,   -1,   -1,  389,   -1,   -1,   -1,  393,
+  394,  395,  396,  397,  398,  399,   -1,  401,  402,  403,
+  404,  405,   -1,   -1,  408,   -1,   -1,   -1,   -1,   -1,
+   -1,  415,  416,  417,   -1,   -1,   -1,   -1,   -1,   -1,
+  424,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 1
+#endif
+#define YYMAXTOKEN 426
+#if YYDEBUG
+char *fortranname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"'!'",0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
+0,0,0,0,0,"':'",0,"'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'['",0,"']'",0,"'_'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"TOK_BINARY_OP","TOK_EQV","TOK_NEQV",
+"TOK_OR","TOK_XOR","TOK_AND","TOK_NOT","TOK_LT","TOK_GT","TOK_LE","TOK_GE",
+"TOK_EQ","TOK_NE","TOK_UNARY_OP","TOK_DSLASH","TOK_SLASH","TOK_DASTER",
+"TOK_SEP","TOK_SEMICOLON","TOK_NEXTLINE","TOK_PARAMETER","TOK_RESULT",
+"TOK_ONLY","TOK_INCLUDE","TOK_SUBROUTINE","TOK_PROGRAM","TOK_FUNCTION",
+"TOK_OMP","TOK_DOLLAR","TOK_FORMAT","TOK_MAX","TOK_TANH","TOK_WHERE",
+"TOK_ELSEWHERE","TOK_ENDWHERE","TOK_MAXVAL","TOK_TRIM","TOK_SUM","TOK_SQRT",
+"TOK_CASE","TOK_SELECTCASE","TOK_FILE","TOK_END","TOK_ERR","TOK_DONOTTREAT",
+"TOK_ENDDONOTTREAT","TOK_EXIST","TOK_MIN","TOK_FLOAT","TOK_EXP","TOK_COS",
+"TOK_COSH","TOK_ACOS","TOK_NINT","TOK_CYCLE","TOK_SIN","TOK_SINH","TOK_ASIN",
+"TOK_EQUIVALENCE","TOK_BACKSPACE","TOK_LOG","TOK_TAN","TOK_ATAN",
+"TOK_RECURSIVE","TOK_ABS","TOK_MOD","TOK_SIGN","TOK_MINLOC","TOK_MAXLOC",
+"TOK_EXIT","TOK_MINVAL","TOK_PUBLIC","TOK_PRIVATE","TOK_ALLOCATABLE",
+"TOK_RETURN","TOK_THEN","TOK_ELSEIF","TOK_ELSE","TOK_ENDIF","TOK_PRINT",
+"TOK_PLAINGOTO","TOK_CONSTRUCTID","TOK_LOGICALIF","TOK_PLAINDO","TOK_CONTAINS",
+"TOK_ENDDO","TOK_MODULE","TOK_ENDMODULE","TOK_DOWHILE","TOK_ALLOCATE",
+"TOK_OPEN","TOK_CLOSE","TOK_INQUIRE","TOK_WRITE","TOK_READ","TOK_REWIND",
+"TOK_DEALLOCATE","TOK_NULLIFY","TOK_FIN","TOK_DEBUT","TOK_DIMENSION",
+"TOK_ENDSELECT","TOK_EXTERNAL","TOK_INTENT","TOK_INTRINSIC","TOK_NAMELIST",
+"TOK_CASEDEFAULT","TOK_OPTIONAL","TOK_POINTER","TOK_CONTINUE","TOK_SAVE",
+"TOK_TARGET","TOK_QUOTE","TOK_IMPLICIT","TOK_NONE","TOK_CALL","TOK_STAT",
+"TOK_POINT_TO","TOK_COMMON","TOK_GLOBAL","TOK_INTERFACE","TOK_ENDINTERFACE",
+"TOK_LEFTAB","TOK_RIGHTAB","TOK_PAUSE","TOK_PROCEDURE","TOK_STOP","TOK_NAMEEQ",
+"TOK_REAL8","TOK_OUT","TOK_INOUT","TOK_IN","TOK_USE","TOK_TRUE","TOK_FALSE",
+"TOK_LABEL","TOK_TYPE","TOK_TYPEPAR","TOK_ENDTYPE","TOK_REAL","TOK_INTEGER",
+"TOK_LOGICAL","TOK_DOUBLEPRECISION","TOK_DOUBLEREAL","TOK_ENDSUBROUTINE",
+"TOK_ENDFUNCTION","TOK_ENDPROGRAM","TOK_ENDUNIT","TOK_CHARACTER",
+"TOK_CHAR_CONSTANT","TOK_CHAR_CUT","TOK_DATA","TOK_CHAR_INT","TOK_CHAR_MESSAGE",
+"TOK_CSTREAL","TOK_CSTREALDP","TOK_CSTREALQP","TOK_SFREAL","TOK_COMPLEX",
+"TOK_DOUBLECOMPLEX","TOK_NAME","TOK_NAME_CHAR","TOK_PROBTYPE","TOK_INTERPTYPE",
+"TOK_VARTYPE","TOK_BC","TOK_OP","TOK_CSTINT","TOK_COMMENT","TOK_FILENAME",
+};
+char *fortranrule[] = {
+"$accept : input",
+"input :",
+"input : input line",
+"line : '\\n' position",
+"line : thislabel suite_line_list",
+"line : TOK_COMMENT",
+"line : keyword cmnt writedeclar",
+"line : error writedeclar nulcurbuf",
+"suite_line_list : suite_line",
+"suite_line_list : suite_line_list TOK_SEMICOLON suite_line",
+"suite_line : entry fin_line",
+"suite_line : spec fin_line",
+"suite_line : before_include filename fin_line",
+"suite_line : exec cmnt writedeclar",
+"suite_line : instr fin_line",
+"instr : ident ':'",
+"fin_line : position cmnt",
+"keyword : TOK_DONOTTREAT",
+"keyword : TOK_ENDDONOTTREAT",
+"keyword : TOK_OMP",
+"keyword : TOK_DOLLAR",
+"position :",
+"thislabel :",
+"thislabel : TOK_LABEL nulcurbuf",
+"cmnt :",
+"cmnt : TOK_COMMENT",
+"incomment :",
+"nulcurbuf :",
+"opt_recursive :",
+"opt_recursive : TOK_RECURSIVE",
+"entry :",
+"entry : opt_recursive TOK_SUBROUTINE name_routine arglist",
+"entry : TOK_PROGRAM name_routine",
+"entry : TOK_FUNCTION name_routine arglist TOK_RESULT arglist1",
+"entry : TOK_FUNCTION name_routine arglist",
+"entry : TOK_MODULE TOK_NAME",
+"name_routine : TOK_NAME",
+"writedeclar :",
+"before_include : TOK_INCLUDE",
+"filename : TOK_CHAR_CONSTANT",
+"arglist :",
+"arglist : '(' ')'",
+"arglist : '(' args ')'",
+"arglist1 :",
+"arglist1 : '(' ')'",
+"arglist1 : '(' args ')'",
+"args : arg",
+"args : args ',' arg",
+"arg : TOK_NAME",
+"arg : '*'",
+"spec : type after_type",
+"spec : TOK_TYPE opt_spec opt_sep opt_name",
+"spec : TOK_ENDTYPE opt_name",
+"spec : TOK_POINTER list_couple",
+"spec : before_parameter '(' paramlist ')'",
+"spec : before_parameter paramlist",
+"spec : common",
+"spec : save",
+"spec : implicit",
+"spec : dimension",
+"spec : public",
+"spec : private",
+"spec : use_stat",
+"spec : module_proc_stmt",
+"spec : interface",
+"spec : namelist",
+"spec : TOK_BACKSPACE '(' expr ')'",
+"spec : TOK_EXTERNAL opt_sep use_name_list",
+"spec : TOK_INTRINSIC opt_sep use_intrinsic_list",
+"spec : TOK_EQUIVALENCE list_expr_equi",
+"spec : before_data data '\\n'",
+"opt_spec :",
+"opt_spec : access_spec",
+"name_intrinsic : TOK_SUM",
+"name_intrinsic : TOK_TANH",
+"name_intrinsic : TOK_MAXVAL",
+"name_intrinsic : TOK_MIN",
+"name_intrinsic : TOK_MINVAL",
+"name_intrinsic : TOK_TRIM",
+"name_intrinsic : TOK_SQRT",
+"name_intrinsic : TOK_NINT",
+"name_intrinsic : TOK_FLOAT",
+"name_intrinsic : TOK_EXP",
+"name_intrinsic : TOK_COS",
+"name_intrinsic : TOK_COSH",
+"name_intrinsic : TOK_ACOS",
+"name_intrinsic : TOK_SIN",
+"name_intrinsic : TOK_SINH",
+"name_intrinsic : TOK_ASIN",
+"name_intrinsic : TOK_LOG",
+"name_intrinsic : TOK_TAN",
+"name_intrinsic : TOK_ATAN",
+"name_intrinsic : TOK_MOD",
+"name_intrinsic : TOK_SIGN",
+"name_intrinsic : TOK_MINLOC",
+"name_intrinsic : TOK_MAXLOC",
+"name_intrinsic : TOK_NAME",
+"use_intrinsic_list : name_intrinsic",
+"use_intrinsic_list : use_intrinsic_list ',' name_intrinsic",
+"list_couple : '(' list_expr ')'",
+"list_couple : list_couple ',' '(' list_expr ')'",
+"list_expr_equi : expr_equi",
+"list_expr_equi : list_expr_equi ',' expr_equi",
+"expr_equi : '(' list_expr_equi1 ')'",
+"list_expr_equi1 : ident dims",
+"list_expr_equi1 : list_expr_equi1 ',' ident dims",
+"list_expr : expr",
+"list_expr : list_expr ',' expr",
+"opt_sep :",
+"opt_sep : ':' ':'",
+"after_type : dcl nodimsgiven",
+"after_type : before_function name_routine arglist",
+"before_function : TOK_FUNCTION",
+"before_parameter : TOK_PARAMETER",
+"before_data : TOK_DATA",
+"data : TOK_NAME TOK_SLASH datavallist TOK_SLASH",
+"data : data opt_comma TOK_NAME TOK_SLASH datavallist TOK_SLASH",
+"data : datanamelist TOK_SLASH datavallist TOK_SLASH",
+"datavallist : expr_data",
+"datavallist : expr_data ',' datavallist",
+"save : before_save varsave",
+"save : before_save comblock varsave",
+"save : save opt_comma comblock opt_comma varsave",
+"save : save ',' varsave",
+"before_save : TOK_SAVE",
+"varsave :",
+"varsave : TOK_NAME dims",
+"datanamelist : TOK_NAME",
+"datanamelist : TOK_NAME '(' expr ')'",
+"datanamelist : datanamelist ',' datanamelist",
+"expr_data : opt_signe simple_const",
+"expr_data : expr_data '+' expr_data",
+"expr_data : expr_data '-' expr_data",
+"expr_data : expr_data '*' expr_data",
+"expr_data : expr_data '/' expr_data",
+"opt_signe :",
+"opt_signe : signe",
+"namelist : namelist_action after_namelist",
+"namelist_action : TOK_NAMELIST ident",
+"namelist_action : TOK_NAMELIST comblock ident",
+"namelist_action : namelist_action opt_comma comblock opt_comma ident",
+"namelist_action : namelist_action ',' ident",
+"after_namelist :",
+"interface : TOK_INTERFACE opt_name",
+"interface : TOK_ENDINTERFACE opt_name",
+"before_dimension : TOK_DIMENSION",
+"dimension : before_dimension opt_comma TOK_NAME dims lengspec",
+"dimension : dimension ',' TOK_NAME dims lengspec",
+"private : TOK_PRIVATE '\\n'",
+"private : TOK_PRIVATE opt_sep use_name_list",
+"public : TOK_PUBLIC '\\n'",
+"public : TOK_PUBLIC opt_sep use_name_list",
+"use_name_list : TOK_NAME",
+"use_name_list : use_name_list ',' TOK_NAME",
+"common : before_common var_common_list",
+"common : before_common comblock var_common_list",
+"common : common opt_comma comblock opt_comma var_common_list",
+"before_common : TOK_COMMON",
+"before_common : TOK_GLOBAL TOK_COMMON",
+"var_common_list : var_common",
+"var_common_list : var_common_list ',' var_common",
+"var_common : TOK_NAME dims",
+"comblock : TOK_DSLASH",
+"comblock : TOK_SLASH TOK_NAME TOK_SLASH",
+"opt_comma :",
+"opt_comma : ','",
+"paramlist : paramitem",
+"paramlist : paramlist ',' paramitem",
+"paramitem : TOK_NAME '=' expr",
+"module_proc_stmt : TOK_PROCEDURE proc_name_list",
+"proc_name_list : TOK_NAME",
+"proc_name_list : proc_name_list ',' TOK_NAME",
+"implicit : TOK_IMPLICIT TOK_NONE",
+"implicit : TOK_IMPLICIT TOK_REAL8",
+"opt_retour :",
+"dcl : options opt_retour TOK_NAME dims lengspec initial_value",
+"dcl : dcl ',' opt_retour TOK_NAME dims lengspec initial_value",
+"nodimsgiven :",
+"type : typespec selector",
+"type : before_character c_selector",
+"type : typename '*' TOK_CSTINT",
+"type : before_typepar attribute ')'",
+"before_typepar : TOK_TYPEPAR",
+"c_selector :",
+"c_selector : '*' TOK_CSTINT",
+"c_selector : '*' '(' c_attribute ')'",
+"c_selector : '(' c_attribute ')'",
+"c_attribute : TOK_NAME clause opt_clause",
+"c_attribute : TOK_NAME '=' clause opt_clause",
+"c_attribute : clause opt_clause",
+"before_character : TOK_CHARACTER",
+"typespec : typename",
+"typename : TOK_INTEGER",
+"typename : TOK_REAL",
+"typename : TOK_COMPLEX",
+"typename : TOK_DOUBLEPRECISION",
+"typename : TOK_DOUBLECOMPLEX",
+"typename : TOK_LOGICAL",
+"lengspec :",
+"lengspec : '*' proper_lengspec",
+"proper_lengspec : expr",
+"proper_lengspec : '(' '*' ')'",
+"selector :",
+"selector : '*' proper_selector",
+"selector : '(' attribute ')'",
+"proper_selector : expr",
+"proper_selector : '(' '*' ')'",
+"attribute : TOK_NAME clause",
+"attribute : TOK_NAME '=' clause",
+"attribute : TOK_NAME",
+"attribute : TOK_CSTINT",
+"clause : expr",
+"clause : '*'",
+"opt_clause :",
+"opt_clause : ',' TOK_NAME clause",
+"options :",
+"options : ':' ':'",
+"options : ',' attr_spec_list ':' ':'",
+"attr_spec_list : attr_spec",
+"attr_spec_list : attr_spec_list ',' attr_spec",
+"attr_spec : TOK_PARAMETER",
+"attr_spec : access_spec",
+"attr_spec : TOK_ALLOCATABLE",
+"attr_spec : TOK_DIMENSION dims",
+"attr_spec : TOK_EXTERNAL",
+"attr_spec : TOK_INTENT '(' intent_spec ')'",
+"attr_spec : TOK_INTRINSIC",
+"attr_spec : TOK_OPTIONAL",
+"attr_spec : TOK_POINTER",
+"attr_spec : TOK_SAVE",
+"attr_spec : TOK_TARGET",
+"intent_spec : TOK_IN",
+"intent_spec : TOK_OUT",
+"intent_spec : TOK_INOUT",
+"access_spec : TOK_PUBLIC",
+"access_spec : TOK_PRIVATE",
+"dims :",
+"dims : '(' dimlist ')'",
+"dimlist : dim",
+"dimlist : dimlist ',' dim",
+"dim : ubound",
+"dim : ':'",
+"dim : expr ':'",
+"dim : ':' expr",
+"dim : expr ':' ubound",
+"ubound : '*'",
+"ubound : expr",
+"expr : uexpr",
+"expr : '(' expr ')'",
+"expr : complex_const",
+"expr : predefinedfunction",
+"predefinedfunction : TOK_SUM minmaxlist ')'",
+"predefinedfunction : TOK_MAX minmaxlist ')'",
+"predefinedfunction : TOK_TANH '(' minmaxlist ')'",
+"predefinedfunction : TOK_MAXVAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_MIN minmaxlist ')'",
+"predefinedfunction : TOK_MINVAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_TRIM '(' expr ')'",
+"predefinedfunction : TOK_SQRT expr ')'",
+"predefinedfunction : TOK_REAL '(' minmaxlist ')'",
+"predefinedfunction : TOK_NINT '(' expr ')'",
+"predefinedfunction : TOK_FLOAT '(' expr ')'",
+"predefinedfunction : TOK_EXP '(' expr ')'",
+"predefinedfunction : TOK_COS '(' expr ')'",
+"predefinedfunction : TOK_COSH '(' expr ')'",
+"predefinedfunction : TOK_ACOS '(' expr ')'",
+"predefinedfunction : TOK_SIN '(' expr ')'",
+"predefinedfunction : TOK_SINH '(' expr ')'",
+"predefinedfunction : TOK_ASIN '(' expr ')'",
+"predefinedfunction : TOK_LOG '(' expr ')'",
+"predefinedfunction : TOK_TAN '(' expr ')'",
+"predefinedfunction : TOK_ATAN '(' expr ')'",
+"predefinedfunction : TOK_ABS expr ')'",
+"predefinedfunction : TOK_MOD '(' minmaxlist ')'",
+"predefinedfunction : TOK_SIGN '(' minmaxlist ')'",
+"predefinedfunction : TOK_MINLOC '(' minmaxlist ')'",
+"predefinedfunction : TOK_MAXLOC '(' minmaxlist ')'",
+"minmaxlist : expr",
+"minmaxlist : minmaxlist ',' expr",
+"uexpr : lhs",
+"uexpr : simple_const",
+"uexpr : vec",
+"uexpr : expr operation",
+"uexpr : signe expr",
+"uexpr : TOK_NOT expr",
+"signe : '+'",
+"signe : '-'",
+"operation : '+' expr",
+"operation : '-' expr",
+"operation : '*' expr",
+"operation : TOK_DASTER expr",
+"operation : TOK_EQ expr",
+"operation : TOK_EQV expr",
+"operation : TOK_GT expr",
+"operation : '>' expr",
+"operation : TOK_LT expr",
+"operation : '<' expr",
+"operation : TOK_GE expr",
+"operation : '>' '=' expr",
+"operation : TOK_LE expr",
+"operation : '<' '=' expr",
+"operation : TOK_NE expr",
+"operation : TOK_NEQV expr",
+"operation : TOK_XOR expr",
+"operation : TOK_OR expr",
+"operation : TOK_AND expr",
+"operation : TOK_SLASH after_slash",
+"operation : '=' after_equal",
+"after_slash :",
+"after_slash : expr",
+"after_slash : '=' expr",
+"after_slash : TOK_SLASH expr",
+"after_equal : '=' expr",
+"after_equal : expr",
+"lhs : ident",
+"lhs : structure_component",
+"lhs : array_ele_substring_func_ref",
+"beforefunctionuse :",
+"array_ele_substring_func_ref : begin_array",
+"array_ele_substring_func_ref : begin_array substring",
+"array_ele_substring_func_ref : structure_component '(' funarglist ')'",
+"array_ele_substring_func_ref : structure_component '(' funarglist ')' substring",
+"begin_array : ident '(' funarglist ')'",
+"structure_component : lhs '%' lhs",
+"vec : TOK_LEFTAB outlist TOK_RIGHTAB",
+"funarglist : beforefunctionuse",
+"funarglist : beforefunctionuse funargs",
+"funargs : funarg",
+"funargs : funargs ',' funarg",
+"funarg : expr",
+"funarg : triplet",
+"triplet : expr ':' expr",
+"triplet : expr ':' expr ':' expr",
+"triplet : ':' expr ':' expr",
+"triplet : ':' ':' expr",
+"triplet : ':' expr",
+"triplet : expr ':'",
+"triplet : ':'",
+"ident : TOK_NAME",
+"simple_const : TOK_TRUE",
+"simple_const : TOK_FALSE",
+"simple_const : TOK_CSTINT",
+"simple_const : TOK_CSTREAL",
+"simple_const : TOK_CSTREALDP",
+"simple_const : TOK_CSTREALQP",
+"simple_const : simple_const TOK_NAME",
+"simple_const : string_constant opt_substring",
+"string_constant : TOK_CHAR_CONSTANT",
+"string_constant : string_constant TOK_CHAR_CONSTANT",
+"string_constant : TOK_CHAR_MESSAGE",
+"string_constant : TOK_CHAR_CUT",
+"opt_substring :",
+"opt_substring : substring",
+"substring : '(' optexpr ':' optexpr ')'",
+"optexpr :",
+"optexpr : expr",
+"opt_expr : '\\n'",
+"opt_expr : expr",
+"initial_value :",
+"initial_value : before_initial '=' expr",
+"before_initial :",
+"complex_const : '(' uexpr ',' uexpr ')'",
+"use_stat : word_use module_name",
+"use_stat : word_use module_name ',' rename_list",
+"use_stat : word_use module_name ',' TOK_ONLY ':' '\\n'",
+"use_stat : word_use module_name ',' TOK_ONLY ':' only_list",
+"word_use : TOK_USE",
+"module_name : TOK_NAME",
+"rename_list : rename_name",
+"rename_list : rename_list ',' rename_name",
+"rename_name : TOK_NAME TOK_POINT_TO TOK_NAME",
+"only_list : only_name",
+"only_list : only_list ',' only_name",
+"only_name : TOK_NAME TOK_POINT_TO TOK_NAME",
+"only_name : TOK_NAME",
+"exec : iffable",
+"exec : TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'",
+"exec : TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'",
+"exec : TOK_NULLIFY '(' pointer_name_list ')'",
+"exec : word_endunit",
+"exec : word_endprogram opt_name",
+"exec : word_endsubroutine opt_name",
+"exec : word_endfunction opt_name",
+"exec : TOK_ENDMODULE opt_name",
+"exec : boucledo",
+"exec : logif iffable",
+"exec : TOK_WHERE '(' expr ')' opt_expr",
+"exec : TOK_ELSEWHERE",
+"exec : TOK_ENDWHERE",
+"exec : logif TOK_THEN",
+"exec : TOK_ELSEIF '(' expr ')' TOK_THEN",
+"exec : TOK_ELSE",
+"exec : TOK_ENDIF opt_name",
+"exec : TOK_CASE caselist ')'",
+"exec : TOK_SELECTCASE '(' expr ')'",
+"exec : TOK_CASEDEFAULT",
+"exec : TOK_ENDSELECT",
+"exec : TOK_CONTAINS",
+"word_endsubroutine : TOK_ENDSUBROUTINE",
+"word_endunit : TOK_ENDUNIT",
+"word_endprogram : TOK_ENDPROGRAM",
+"word_endfunction : TOK_ENDFUNCTION",
+"caselist : expr",
+"caselist : caselist ',' expr",
+"caselist : caselist ':' expr",
+"boucledo : worddo opt_int do_arg",
+"boucledo : wordwhile expr",
+"boucledo : TOK_ENDDO optname",
+"do_arg :",
+"do_arg : do_var '=' expr ',' expr",
+"do_arg : do_var '=' expr ',' expr ',' expr",
+"opt_int :",
+"opt_int : TOK_CSTINT opt_comma",
+"opt_name : '\\n'",
+"opt_name : TOK_NAME",
+"optname :",
+"optname : TOK_NAME",
+"worddo : TOK_PLAINDO",
+"wordwhile : TOK_DOWHILE",
+"dotarget :",
+"dotarget : TOK_CSTINT",
+"iffable : TOK_CONTINUE",
+"iffable : ident_dims after_ident_dims",
+"iffable : goto",
+"iffable : io",
+"iffable : call",
+"iffable : TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'",
+"iffable : TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'",
+"iffable : TOK_EXIT optexpr",
+"iffable : TOK_RETURN opt_expr",
+"iffable : TOK_CYCLE opt_expr",
+"iffable : stop opt_expr",
+"iffable : int_list",
+"before_dims :",
+"ident_dims : ident before_dims dims dims",
+"ident_dims : ident_dims '%' ident before_dims dims dims",
+"int_list : TOK_CSTINT",
+"int_list : int_list ',' TOK_CSTINT",
+"after_ident_dims : '=' expr",
+"after_ident_dims : TOK_POINT_TO expr",
+"call : keywordcall opt_call",
+"opt_call :",
+"opt_call : '(' opt_callarglist ')'",
+"opt_callarglist :",
+"opt_callarglist : callarglist",
+"keywordcall : before_call TOK_NAME",
+"before_call : TOK_CALL",
+"callarglist : callarg",
+"callarglist : callarglist ',' callarg",
+"callarg : expr",
+"callarg : '*' label",
+"stop : TOK_PAUSE",
+"stop : TOK_STOP",
+"io : iofctl ioctl",
+"io : read option_read",
+"io : write ioctl",
+"io : write ioctl outlist",
+"io : TOK_REWIND after_rewind",
+"io : TOK_FORMAT",
+"opt_CHAR_INT :",
+"opt_CHAR_INT : TOK_CSTINT TOK_NAME",
+"idfile : '*'",
+"idfile : TOK_CSTINT",
+"idfile : ident",
+"option_print :",
+"option_print : ',' outlist",
+"option_inlist :",
+"option_inlist : inlist",
+"option_read : ioctl option_inlist",
+"option_read : infmt opt_inlist",
+"opt_outlist :",
+"opt_outlist : outlist",
+"opt_inlist :",
+"opt_inlist : ',' inlist",
+"ioctl : '(' ctllist ')'",
+"ioctl : '(' fexpr ')'",
+"after_rewind : '(' ident ')'",
+"after_rewind : '(' TOK_CSTINT ')'",
+"after_rewind : TOK_CSTINT",
+"after_rewind : '(' uexpr ')'",
+"after_rewind : TOK_NAME",
+"ctllist : ioclause",
+"ctllist : ctllist ',' ioclause",
+"ioclause : fexpr",
+"ioclause : '*'",
+"ioclause : TOK_DASTER",
+"ioclause : TOK_NAME expr",
+"ioclause : TOK_NAME expr '%' ident_dims",
+"ioclause : TOK_NAME '(' triplet ')'",
+"ioclause : TOK_NAME '*'",
+"ioclause : TOK_NAME TOK_DASTER",
+"iofctl : TOK_OPEN",
+"iofctl : TOK_CLOSE",
+"infmt : unpar_fexpr",
+"infmt : '*'",
+"read : TOK_READ",
+"read : TOK_INQUIRE",
+"read : TOK_PRINT",
+"write : TOK_WRITE",
+"fexpr : unpar_fexpr",
+"fexpr : '(' fexpr ')'",
+"unpar_fexpr : lhs",
+"unpar_fexpr : simple_const",
+"unpar_fexpr : fexpr addop fexpr",
+"unpar_fexpr : fexpr '*' fexpr",
+"unpar_fexpr : fexpr TOK_SLASH fexpr",
+"unpar_fexpr : fexpr TOK_DASTER fexpr",
+"unpar_fexpr : addop fexpr",
+"unpar_fexpr : fexpr TOK_DSLASH fexpr",
+"unpar_fexpr : TOK_FILE expr",
+"unpar_fexpr : TOK_EXIST expr",
+"unpar_fexpr : TOK_ERR expr",
+"unpar_fexpr : TOK_END expr",
+"unpar_fexpr : TOK_NAME '=' expr",
+"addop : '+'",
+"addop : '-'",
+"inlist : inelt",
+"inlist : inlist ',' inelt",
+"opt_lhs :",
+"opt_lhs : lhs",
+"inelt : opt_lhs opt_operation",
+"inelt : '(' inlist ')' opt_operation",
+"inelt : predefinedfunction opt_operation",
+"inelt : simple_const opt_operation",
+"inelt : '(' inlist ',' dospec ')'",
+"opt_operation :",
+"opt_operation : operation",
+"opt_operation : opt_operation operation",
+"outlist : uexpr",
+"outlist : other",
+"outlist : out2",
+"out2 : uexpr ',' expr",
+"out2 : uexpr ',' other",
+"out2 : other ',' expr",
+"out2 : other ',' other",
+"out2 : out2 ',' expr",
+"out2 : out2 ',' other",
+"out2 : uexpr",
+"out2 : predefinedfunction",
+"other : complex_const",
+"other : '(' expr ')'",
+"other : '(' uexpr ',' dospec ')'",
+"other : '(' other ',' dospec ')'",
+"other : '(' out2 ',' dospec ')'",
+"dospec : TOK_NAME '=' expr ',' expr",
+"dospec : TOK_NAME '=' expr ',' expr ',' expr",
+"labellist : label",
+"labellist : labellist ',' label",
+"label : TOK_CSTINT",
+"goto : TOK_PLAINGOTO '(' expr ',' expr ')' ',' expr",
+"goto : TOK_PLAINGOTO label",
+"allocation_list : allocate_object",
+"allocation_list : ident_dims",
+"allocation_list : allocation_list ',' allocate_object",
+"allocate_object : ident",
+"allocate_object : structure_component",
+"allocate_object : array_element",
+"array_element : ident '(' funargs ')'",
+"subscript_list : expr",
+"subscript_list : subscript_list ',' expr",
+"allocate_object_list : allocate_object",
+"allocate_object_list : allocate_object_list ',' allocate_object",
+"opt_stat_spec :",
+"opt_stat_spec : ',' TOK_STAT '=' ident",
+"pointer_name_list : ident",
+"pointer_name_list : pointer_name_list ',' ident",
+"opt_construct_name :",
+"opt_construct_name : TOK_NAME",
+"opt_construct_name_colon :",
+"opt_construct_name_colon : TOK_CONSTRUCTID ':'",
+"logif : TOK_LOGICALIF expr ')'",
+"do_var : ident",
+};
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short yyss[YYSTACKSIZE];
+YYSTYPE yyvs[YYSTACKSIZE];
+#define yystacksize YYSTACKSIZE
+#line 2567 "fortran.y"
+
+void processfortran(char *fichier_entree)
+{
+   extern FILE *fortranin;
+   extern FILE *fortranout;
+   char nomfile[LONG_C];
+   int c;
+   int confirmyes;
+
+   /*fortrandebug = 1;*/
+   if ( mark == 1 ) printf("Firstpass == %d \n",firstpass);
+/******************************************************************************/
+/*  1-  Open input and output files                                           */
+/******************************************************************************/
+   strcpy(nomfile,commondirin);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   fortranin=fopen( nomfile,"r");
+   if (! fortranin)
+   {
+      printf("Error : File %s does not exist\n",nomfile);
+      exit(1);
+   }
+
+   strcpy(curfile,nomfile);
+   strcpy(nomfile,commondirout);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   strcpy(nomfileoutput,nomfile);
+   Save_Length(nomfileoutput,31);
+   if (firstpass == 1)
+   {
+      if (checkexistcommon == 1)
+      {
+         if (fopen(nomfile,"r"))
+         {
+            printf("Warning : file %s already exist\n",nomfile);
+            confirmyes = 0;
+            while (confirmyes==0)
+            {
+               printf("Override file %s ? [Y/N]\n",nomfile);
+               c=getchar();
+               getchar();
+               if (c==79 || c==110)
+               {
+                  printf("We stop\n");
+                  exit(1);
+               }
+               if (c==89 || c==121)
+               {
+                  confirmyes=1;
+               }
+            }
+         }
+      }
+   }
+
+/******************************************************************************/
+/*  2-  Variables initialization                                              */
+/******************************************************************************/
+
+   line_num_fortran_common=1;
+   line_num_fortran=1;
+   PublicDeclare = 0;
+   PrivateDeclare = 0;
+   ExternalDeclare = 0;
+   SaveDeclare = 0;
+   pointerdeclare = 0;
+   optionaldeclare = 0;
+   incalldeclare = 0;
+   VarType = 0;
+   VarTypepar = 0;
+   Allocatabledeclare = 0 ;
+   strcpy(NamePrecision," ");
+   VariableIsParameter =  0 ;
+   strcpy(NamePrecision,"");
+   c_star = 0 ;
+   functiondeclarationisdone = 0;
+   insubroutinedeclare = 0 ;
+   strcpy(subroutinename," ");
+   InitialValueGiven = 0 ;
+   strcpy(EmptyChar," ");
+   inmoduledeclare = 0;
+   colnum=0;
+   incom=0;
+   couldaddvariable=1;
+   aftercontainsdeclare = 1;
+   strcpy(nameinttypename,"");
+   /* Name of the file without format                                         */
+   tmp = strchr(fichier_entree, '.');
+   strncpy(curfilename,fichier_entree,strlen(fichier_entree)-strlen(tmp));
+   Save_Length(curfilename,30);
+/******************************************************************************/
+/*  3-  Parsing of the input file (1 time)                                    */
+/******************************************************************************/
+   if (firstpass == 0 )
+   {
+      fortranout=fopen(nomfileoutput,"w");
+
+      NewModule_Creation_0();
+   }
+
+   fortranparse();
+
+   strcpy(curfile,mainfile);
+
+   if (firstpass == 0 ) fclose(fortranout);
+}
+#line 7005 "y.tab.c"
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yyss + yystacksize - 1)
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yyss + yystacksize - 1)
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 7:
+#line 341 "fortran.y"
+{yyerrok;yyclearin;}
+break;
+case 12:
+#line 349 "fortran.y"
+{
+                     if (inmoduledeclare == 0 )
+                     {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curinclude,
+                                              pos_end-pos_curinclude);
+                     }
+                  }
+break;
+case 17:
+#line 365 "fortran.y"
+{
+            /* we should ignore the declaration until the keyword             */
+            /*    TOK_ENDDONOTTREAT                                           */
+            couldaddvariable = 0 ;
+            RemoveWordCUR_0(fortranout,-20,20);
+         }
+break;
+case 18:
+#line 372 "fortran.y"
+{
+             couldaddvariable = 1 ;
+             RemoveWordCUR_0(fortranout,-24,24);
+          }
+break;
+case 21:
+#line 379 "fortran.y"
+{pos_cur = setposcur();}
+break;
+case 26:
+#line 388 "fortran.y"
+{incom = 1;}
+break;
+case 27:
+#line 391 "fortran.y"
+{if (incom !=1) {strcpy(curbuf,"");incom=0;}}
+break;
+case 31:
+#line 398 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(1);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            writeheadnewsub_0(1);
+                      }
+                      }
+                   }
+break;
+case 32:
+#line 426 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[0].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      strcpy(subroutinename,yyvsp[0].nac);
+                      /* Common case                                          */
+                      insubroutinedeclare = 1;
+                      /* in the second step we should write the head of       */
+                      /*    the subroutine sub_loop_<subroutinename>          */
+                      writeheadnewsub_0(1);
+                   }
+break;
+case 33:
+#line 444 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-3].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-3].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[-2].l);
+                         strcpy(DeclType,"");
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1(yyvsp[-2].l);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1(yyvsp[-3].nac);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+break;
+case 34:
+#line 477 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-1].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         strcpy(DeclType,"");
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1(yyvsp[-1].nac);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+break;
+case 35:
+#line 511 "fortran.y"
+{
+                      GlobalDeclaration = 0;
+                      strcpy(curmodulename,yyvsp[0].nac);
+                      strcpy(subroutinename,"");
+                      Add_NameOfModule_1(yyvsp[0].nac);
+                      if ( inmoduledeclare == 0 )
+                      {
+                         /* To know if there are in the module declaration    */
+                         inmoduledeclare = 1;
+                         /* to know if a module has been met                  */
+                         inmodulemeet = 1;
+                         /* to know if we are after the keyword contains      */
+                         aftercontainsdeclare = 0 ;
+                      }
+                   }
+break;
+case 36:
+#line 528 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,yyvsp[0].nac);strcpy(subroutinename,yyvsp[0].nac);
+                      }
+                   }
+break;
+case 38:
+#line 537 "fortran.y"
+{
+                      pos_curinclude = setposcur()-9;
+                   }
+break;
+case 39:
+#line 541 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Include_1(yyvsp[0].nac);
+                   }
+break;
+case 40:
+#line 545 "fortran.y"
+{
+                      if ( firstpass == 1 && couldaddvariable == 1) yyval.l=NULL;
+                   }
+break;
+case 41:
+#line 548 "fortran.y"
+{
+                      if ( firstpass == 1 && couldaddvariable == 1 ) yyval.l=NULL;
+                   }
+break;
+case 42:
+#line 552 "fortran.y"
+{
+                       if ( firstpass == 1 && couldaddvariable == 1 ) yyval.l=yyvsp[-1].l;
+                   }
+break;
+case 45:
+#line 559 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_SubroutineArgument_Var_1(yyvsp[-1].l);
+                      }
+                   }
+break;
+case 46:
+#line 566 "fortran.y"
+{
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");
+                         curvar=createvar(yyvsp[0].na,NULL);
+                        strcpy(nameinttypename,nameinttypenameback);
+                         curlistvar=insertvar(NULL,curvar);
+                         yyval.l=settype("",curlistvar);
+                      }
+                   }
+break;
+case 47:
+#line 578 "fortran.y"
+{
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");                      
+                         curvar=createvar(yyvsp[0].na,NULL);
+                         strcpy(nameinttypename,nameinttypenameback);                         
+                         yyval.l=insertvar(yyvsp[-2].l,curvar);
+                      }
+                   }
+break;
+case 48:
+#line 589 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 49:
+#line 590 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,"*");}
+break;
+case 50:
+#line 593 "fortran.y"
+{
+                      if ( VarTypepar == 1 )
+                      {
+                         couldaddvariable = 1 ;
+                         VarTypepar = 0;
+                      }
+                   }
+break;
+case 51:
+#line 601 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         VarType = 1;
+                         couldaddvariable = 0 ;
+                      }
+                   }
+break;
+case 52:
+#line 609 "fortran.y"
+{
+                      if ( VarType == 1 ) couldaddvariable = 1 ;
+                      VarType = 0;
+                      VarTypepar = 0;
+                   }
+break;
+case 54:
+#line 616 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[-1].l);
+                         else Add_Parameter_Var_1(yyvsp[-1].l);
+                         pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+break;
+case 55:
+#line 629 "fortran.y"
+{
+                     if ( couldaddvariable == 1 )
+                     {
+                        if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[0].l);
+                         else Add_Parameter_Var_1(yyvsp[0].l);
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+break;
+case 57:
+#line 643 "fortran.y"
+{
+                     pos_end = setposcur();
+                     RemoveWordSET_0(fortranout,pos_cursave,
+                                                pos_end-pos_cursave);
+                  }
+break;
+case 59:
+#line 650 "fortran.y"
+{
+                   /* if the variable is a parameter we can suppose that is   */
+                   /*    value is the same on each grid. It is not useless to */
+                   /*    create a copy of it on each grid                     */
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_Globliste_1(yyvsp[0].l);
+                         /* if variableparamlists has been declared in a      */
+                         /*    subroutine                                     */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            Add_Dimension_Var_1(yyvsp[0].l);
+                         }
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curdimension,
+                                                pos_end-pos_curdimension);
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+break;
+case 60:
+#line 686 "fortran.y"
+{
+      if (firstpass == 0)
+      {
+      if (yyvsp[0].lnn)
+      {
+      removeglobfromlist(&(yyvsp[0].lnn));
+      pos_end = setposcur();
+           RemoveWordSET_0(fortranout,pos_cur,pos_end-pos_cur);
+      writelistpublic(yyvsp[0].lnn);
+      }
+      }
+      }
+break;
+case 70:
+#line 708 "fortran.y"
+{
+                      /* we should remove the data declaration                */
+                      if ( couldaddvariable == 1 && aftercontainsdeclare == 0 )
+                      {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curdata,
+                                              pos_end-pos_curdata);
+                      }
+                  }
+break;
+case 72:
+#line 720 "fortran.y"
+{
+         PublicDeclare = 0 ;
+         PrivateDeclare = 0 ;
+      }
+break;
+case 110:
+#line 771 "fortran.y"
+{
+                      /* if the variable is a parameter we can suppose that is*/
+                      /*    value is the same on each grid. It is not useless */
+                      /*    to create a copy of it on each grid               */
+                      if ( couldaddvariable == 1 )
+                      {
+                      pos_end = setposcur();
+                      /*if (insubroutinedeclare == 0)
+                        {   */
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                 pos_end-pos_cur_decl);
+                                         
+                       /* }
+                      else
+                       {*/
+                        ReWriteDeclarationAndAddTosubroutine_01(yyvsp[-1].l);
+                        pos_cur_decl = setposcur();
+                        
+                       /*}*/
+                      if ( firstpass == 0 &&
+                           GlobalDeclaration == 0 &&
+                           insubroutinedeclare == 0 )
+                      {
+                         sprintf(ligne,"\n#include \"Module_Declar_%s.h\"\n"
+                                                                ,curmodulename);
+                         tofich(fortranout,ligne,1);
+                         sprintf (ligne, "Module_Declar_%s.h",curmodulename);
+                         module_declar = associate(ligne);
+                         sprintf (ligne, " ");
+                         tofich (module_declar, ligne,1);
+                         GlobalDeclaration = 1 ;
+                      }
+                         yyval.l = yyvsp[-1].l;
+                         Add_Globliste_1(yyvsp[-1].l);
+                                                  
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1(yyvsp[-1].l);
+                         else
+                         {
+                            if ( pointerdeclare == 1 )
+                                                Add_Pointer_Var_From_List_1(yyvsp[-1].l);
+                            Add_Parameter_Var_1(yyvsp[-1].l);
+                         }
+
+                         /* if variables has been declared in a subroutine    */
+                         if ( insubroutinedeclare == 1 )
+                         { 
+                       /*    Add_SubroutineDeclaration_Var_1($1);*/
+                         }
+                         /* If there are a SAVE declarations in module's      */
+                         /*    subroutines we should remove it from the       */
+                         /*    subroutines declaration and add it in the      */
+                         /*    global declarations                            */
+                         if ( aftercontainsdeclare == 1 &&
+                              SaveDeclare == 1 && firstpass == 1 )
+                         {
+                              if ( inmodulemeet == 0 ) Add_Save_Var_dcl_1(yyvsp[-1].l);
+                              else  Add_SubroutineDeclarationSave_Var_1(yyvsp[-1].l);
+                         }
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+break;
+case 111:
+#line 850 "fortran.y"
+{
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,yyvsp[-1].nac);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,yyvsp[-1].nac);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1(yyvsp[0].l);
+                         Add_FunctionType_Var_1(yyvsp[-1].nac);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      strcpy(nameinttypename,"");
+
+                   }
+break;
+case 112:
+#line 887 "fortran.y"
+{
+                       functiondeclarationisdone = 1;
+                   }
+break;
+case 113:
+#line 893 "fortran.y"
+{
+                      VariableIsParameter = 1;
+                      pos_curparameter = setposcur()-9;
+                   }
+break;
+case 114:
+#line 898 "fortran.y"
+{
+                      pos_curdata = setposcur()-strlen(yyvsp[0].nac);
+                   }
+break;
+case 115:
+#line 902 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",yyvsp[-1].na);
+                      Add_Data_Var_1(yyvsp[-3].nac,ligne);
+                      }
+                   }
+break;
+case 116:
+#line 911 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",yyvsp[-1].na);
+                      Add_Data_Var_1(yyvsp[-3].nac,ligne);
+                      }
+                   }
+break;
+case 117:
+#line 920 "fortran.y"
+{
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                   }
+break;
+case 118:
+#line 931 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.na,yyvsp[0].na);
+                      }
+                   }
+break;
+case 119:
+#line 938 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);
+                      }
+                   }
+break;
+case 124:
+#line 952 "fortran.y"
+{
+                     pos_cursave = setposcur()-4;
+                  }
+break;
+case 126:
+#line 958 "fortran.y"
+{
+                     if ( couldaddvariable == 1 ) Add_Save_Var_1(yyvsp[-1].nac,yyvsp[0].d);
+                  }
+break;
+case 130:
+#line 967 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].nac);}
+break;
+case 131:
+#line 969 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s+%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 132:
+#line 971 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s-%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 133:
+#line 973 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s*%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 134:
+#line 975 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s/%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 135:
+#line 978 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"");}
+break;
+case 136:
+#line 980 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 145:
+#line 995 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curdimension = setposcur()-9;
+                   }
+break;
+case 146:
+#line 1001 "fortran.y"
+{
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar(yyvsp[-2].nac,yyvsp[-1].d);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar(NULL,curvar);
+            /*                                                                */
+            yyval.l=settype("",curlistvar);
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+break;
+case 147:
+#line 1017 "fortran.y"
+{
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar(yyvsp[-2].nac,yyvsp[-1].d);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar(yyvsp[-4].l,curvar);
+            /*                                                                */
+            yyval.l=curlistvar;
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+break;
+case 150:
+#line 1037 "fortran.y"
+{
+        yyval.lnn=(listname *)NULL;
+        }
+break;
+case 151:
+#line 1041 "fortran.y"
+{
+          yyval.lnn=yyvsp[0].lnn;
+         }
+break;
+case 152:
+#line 1046 "fortran.y"
+{
+           yyval.lnn = Insertname(NULL,yyvsp[0].nac);
+           }
+break;
+case 153:
+#line 1050 "fortran.y"
+{
+          yyval.lnn = Insertname(yyvsp[-2].lnn,yyvsp[0].nac);
+          }
+break;
+case 154:
+#line 1055 "fortran.y"
+{
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcommon,
+                                                  pos_end-pos_curcommon);
+                   }
+break;
+case 155:
+#line 1061 "fortran.y"
+{
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",yyvsp[-1].nac);
+                            Add_NameOfCommon_1(yyvsp[-1].nac);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+break;
+case 156:
+#line 1072 "fortran.y"
+{
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",yyvsp[-2].nac);
+                            Add_NameOfCommon_1(yyvsp[-2].nac);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+break;
+case 157:
+#line 1084 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6;
+                   }
+break;
+case 158:
+#line 1089 "fortran.y"
+{
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6-7;
+                   }
+break;
+case 159:
+#line 1095 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+break;
+case 160:
+#line 1100 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+break;
+case 161:
+#line 1104 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         positioninblock = positioninblock + 1 ;
+                         strcpy(commonvar,yyvsp[-1].nac);
+                         commondim = yyvsp[0].d;
+                      }
+                   }
+break;
+case 162:
+#line 1114 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,"");
+                         positioninblock=0;
+                         strcpy(commonblockname,"");
+                      }
+                   }
+break;
+case 163:
+#line 1123 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy(yyval.nac,yyvsp[-1].nac);
+                         positioninblock=0;
+                         strcpy(commonblockname,yyvsp[-1].nac);
+                      }
+                   }
+break;
+case 166:
+#line 1136 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) yyval.l=insertvar(NULL,yyvsp[0].v);
+                   }
+break;
+case 167:
+#line 1140 "fortran.y"
+{
+                      if ( couldaddvariable == 1 ) yyval.l=insertvar(yyvsp[-2].l,yyvsp[0].v);
+                   }
+break;
+case 168:
+#line 1145 "fortran.y"
+{
+                     if ( couldaddvariable == 1 )
+                     {
+                         curvar=(variable *) malloc(sizeof(variable));
+                         /*                                                   */
+                         Init_Variable(curvar);
+                         /*                                                   */
+                         curvar->v_VariableIsParameter=1;
+                         strcpy(curvar->v_nomvar,yyvsp[-2].nac);
+                         Save_Length(yyvsp[-2].nac,4);
+                         strcpy(curvar->v_subroutinename,subroutinename);
+                         Save_Length(subroutinename,11);
+                         strcpy(curvar->v_modulename,curmodulename);
+                         Save_Length(curmodulename,6);
+                         strcpy(curvar->v_initialvalue,yyvsp[0].na);
+                         Save_Length(yyvsp[0].na,14);
+                         strcpy(curvar->v_commoninfile,mainfile);
+                         Save_Length(mainfile,10);
+                         yyval.v=curvar;
+                      }
+                   }
+break;
+case 172:
+#line 1173 "fortran.y"
+{
+                       if ( insubroutinedeclare == 1 )
+                       {
+                          Add_ImplicitNoneSubroutine_1();
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_end-13,
+                                                             13);
+                       }
+                    }
+break;
+case 175:
+#line 1187 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         /*                                                   */
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar(yyvsp[-3].nac,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar(yyvsp[-3].nac,yyvsp[-2].d);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar(DeclType,curvar);
+                         /*                                                   */
+                         curlistvar=insertvar(NULL,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         yyval.l=settype(DeclType,curlistvar);
+                      }
+                      strcpy(vallengspec,"");
+                   }
+break;
+case 176:
+#line 1219 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar(yyvsp[-3].nac,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar(yyvsp[-3].nac,yyvsp[-2].d);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar(yyvsp[-6].l->var->v_typevar,curvar);
+                         /*                                                   */
+                         strcpy(curvar->v_typevar,(yyvsp[-6].l->var->v_typevar));
+                         Save_Length(yyvsp[-6].l->var->v_typevar,3);
+                         /*                                                   */
+                         curlistvar=insertvar(yyvsp[-6].l,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         yyval.l=curlistvar;
+                      }
+                      strcpy(vallengspec,"");
+                   }
+break;
+case 177:
+#line 1253 "fortran.y"
+{dimsgiven=0;}
+break;
+case 178:
+#line 1256 "fortran.y"
+{strcpy(DeclType,yyvsp[-1].nac);}
+break;
+case 179:
+#line 1258 "fortran.y"
+{
+                      strcpy(DeclType,"CHARACTER");
+                   }
+break;
+case 180:
+#line 1262 "fortran.y"
+{
+                      strcpy(DeclType,yyvsp[-2].nac);
+                      strcpy(nameinttypename,yyvsp[0].nac);
+                   }
+break;
+case 181:
+#line 1267 "fortran.y"
+{
+                      strcpy(DeclType,"TYPE");
+                   }
+break;
+case 182:
+#line 1272 "fortran.y"
+{
+                 /*     if ( couldaddvariable == 1 ) VarTypepar = 1 ;
+                      couldaddvariable = 0 ;
+                      pos_cur_decl = setposcur()-5;*/
+                   pos_cur_decl = setposcur()-5;
+                   }
+break;
+case 184:
+#line 1281 "fortran.y"
+{c_selectorgiven=1;strcpy(c_selectorname,yyvsp[0].nac);}
+break;
+case 185:
+#line 1282 "fortran.y"
+{c_star = 1;}
+break;
+case 190:
+#line 1290 "fortran.y"
+{
+                      pos_cur_decl = setposcur()-9;
+                   }
+break;
+case 191:
+#line 1294 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 192:
+#line 1297 "fortran.y"
+{
+                      strcpy(yyval.nac,"INTEGER");
+                      pos_cur_decl = setposcur()-7;
+                   }
+break;
+case 193:
+#line 1301 "fortran.y"
+{
+                      strcpy(yyval.nac,"REAL");
+                      pos_cur_decl = setposcur()-4;
+                   }
+break;
+case 194:
+#line 1306 "fortran.y"
+{strcpy(yyval.nac,"COMPLEX");
+                   pos_cur_decl = setposcur()-7;}
+break;
+case 195:
+#line 1309 "fortran.y"
+{
+                      pos_cur_decl = setposcur()-16;
+                      strcpy(yyval.nac,"REAL");
+                      strcpy(nameinttypename,"8");
+                   }
+break;
+case 196:
+#line 1315 "fortran.y"
+{strcpy(yyval.nac,"DOUBLE COMPLEX");}
+break;
+case 197:
+#line 1317 "fortran.y"
+{
+                      strcpy(yyval.nac,"LOGICAL");
+                      pos_cur_decl = setposcur()-7;
+                   }
+break;
+case 199:
+#line 1323 "fortran.y"
+{strcpy(vallengspec,yyvsp[0].na);}
+break;
+case 200:
+#line 1325 "fortran.y"
+{sprintf(yyval.na,"*%s",yyvsp[0].na);}
+break;
+case 201:
+#line 1326 "fortran.y"
+{strcpy(yyval.na,"*(*)");}
+break;
+case 208:
+#line 1337 "fortran.y"
+{
+                      if ( strstr(yyvsp[0].na,"0.d0") )
+                      {
+                         strcpy(nameinttypename,"8");
+                         sprintf(NamePrecision,"");
+                      }
+                      else sprintf(NamePrecision,"%s = %s",yyvsp[-2].nac,yyvsp[0].na);
+                   }
+break;
+case 209:
+#line 1346 "fortran.y"
+{
+                      strcpy(NamePrecision,yyvsp[0].nac);
+                   }
+break;
+case 210:
+#line 1350 "fortran.y"
+{
+                      strcpy(NamePrecision,yyvsp[0].nac);
+                   }
+break;
+case 211:
+#line 1354 "fortran.y"
+{strcpy(CharacterSize,yyvsp[0].na);
+                    strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 212:
+#line 1356 "fortran.y"
+{strcpy(CharacterSize,"*");
+                    strcpy(yyval.na,"*");}
+break;
+case 220:
+#line 1370 "fortran.y"
+{
+                      VariableIsParameter = 1;
+                   }
+break;
+case 222:
+#line 1375 "fortran.y"
+{Allocatabledeclare = 1;}
+break;
+case 223:
+#line 1377 "fortran.y"
+{
+                      dimsgiven=1;
+                      curdim=yyvsp[0].d;
+                   }
+break;
+case 224:
+#line 1382 "fortran.y"
+{ExternalDeclare = 1;}
+break;
+case 225:
+#line 1384 "fortran.y"
+{strcpy(IntentSpec,yyvsp[-1].nac);}
+break;
+case 227:
+#line 1386 "fortran.y"
+{optionaldeclare = 1 ;}
+break;
+case 228:
+#line 1387 "fortran.y"
+{pointerdeclare = 1 ;}
+break;
+case 229:
+#line 1388 "fortran.y"
+{
+/*                       if ( inmodulemeet == 1 )
+                       {*/
+                          SaveDeclare = 1 ;
+                     /*  }*/
+                    }
+break;
+case 231:
+#line 1396 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 232:
+#line 1397 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 233:
+#line 1398 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac); }
+break;
+case 234:
+#line 1401 "fortran.y"
+{PublicDeclare = 1;}
+break;
+case 235:
+#line 1403 "fortran.y"
+{PrivateDeclare = 1;}
+break;
+case 236:
+#line 1405 "fortran.y"
+{if ( created_dimensionlist == 1 )
+                       {
+                           yyval.d=(listdim *)NULL;
+                       }
+                   }
+break;
+case 237:
+#line 1411 "fortran.y"
+{if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) yyval.d=yyvsp[-1].d;}
+break;
+case 238:
+#line 1414 "fortran.y"
+{if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) yyval.d=insertdim(NULL,yyvsp[0].dim1);}
+break;
+case 239:
+#line 1417 "fortran.y"
+{if ( couldaddvariable == 1 )
+                         if ( created_dimensionlist == 1 ) yyval.d=insertdim(yyvsp[-2].d,yyvsp[0].dim1);}
+break;
+case 240:
+#line 1420 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"1");
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 241:
+#line 1425 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"");
+                      strcpy(yyval.dim1.last,"");
+                   }
+break;
+case 242:
+#line 1429 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,yyvsp[-1].na);
+                      Save_Length(yyvsp[-1].na,2);
+                      strcpy(yyval.dim1.last,"");
+                   }
+break;
+case 243:
+#line 1434 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,"");
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 244:
+#line 1440 "fortran.y"
+{
+                      strcpy(yyval.dim1.first,yyvsp[-2].na);
+                      Save_Length(yyvsp[-2].na,2);
+                      strcpy(yyval.dim1.last,yyvsp[0].na);
+                      Save_Length(yyvsp[0].na,1);
+                   }
+break;
+case 245:
+#line 1447 "fortran.y"
+{strcpy(yyval.na,"*");}
+break;
+case 246:
+#line 1448 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 247:
+#line 1450 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 248:
+#line 1452 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s)",yyvsp[-1].na);}
+break;
+case 249:
+#line 1454 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 250:
+#line 1456 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 251:
+#line 1460 "fortran.y"
+{sprintf(yyval.na,"SUM(%s)",yyvsp[-1].na);}
+break;
+case 252:
+#line 1462 "fortran.y"
+{sprintf(yyval.na,"MAX(%s)",yyvsp[-1].na);}
+break;
+case 253:
+#line 1464 "fortran.y"
+{sprintf(yyval.na,"TANH(%s)",yyvsp[-1].na);}
+break;
+case 254:
+#line 1466 "fortran.y"
+{sprintf(yyval.na,"MAXVAL(%s)",yyvsp[-1].na);}
+break;
+case 255:
+#line 1468 "fortran.y"
+{sprintf(yyval.na,"MIN(%s)",yyvsp[-1].na);}
+break;
+case 256:
+#line 1470 "fortran.y"
+{sprintf(yyval.na,"MINVAL(%s)",yyvsp[-1].na);}
+break;
+case 257:
+#line 1472 "fortran.y"
+{sprintf(yyval.na,"TRIM(%s)",yyvsp[-1].na);}
+break;
+case 258:
+#line 1474 "fortran.y"
+{sprintf(yyval.na,"SQRT(%s)",yyvsp[-1].na);}
+break;
+case 259:
+#line 1476 "fortran.y"
+{sprintf(yyval.na,"REAL(%s)",yyvsp[-1].na);}
+break;
+case 260:
+#line 1478 "fortran.y"
+{sprintf(yyval.na,"NINT(%s)",yyvsp[-1].na);}
+break;
+case 261:
+#line 1480 "fortran.y"
+{sprintf(yyval.na,"FLOAT(%s)",yyvsp[-1].na);}
+break;
+case 262:
+#line 1482 "fortran.y"
+{sprintf(yyval.na,"EXP(%s)",yyvsp[-1].na);}
+break;
+case 263:
+#line 1484 "fortran.y"
+{sprintf(yyval.na,"COS(%s)",yyvsp[-1].na);}
+break;
+case 264:
+#line 1486 "fortran.y"
+{sprintf(yyval.na,"COSH(%s)",yyvsp[-1].na);}
+break;
+case 265:
+#line 1488 "fortran.y"
+{sprintf(yyval.na,"ACOS(%s)",yyvsp[-1].na);}
+break;
+case 266:
+#line 1490 "fortran.y"
+{sprintf(yyval.na,"SIN(%s)",yyvsp[-1].na);}
+break;
+case 267:
+#line 1492 "fortran.y"
+{sprintf(yyval.na,"SINH(%s)",yyvsp[-1].na);}
+break;
+case 268:
+#line 1494 "fortran.y"
+{sprintf(yyval.na,"ASIN(%s)",yyvsp[-1].na);}
+break;
+case 269:
+#line 1496 "fortran.y"
+{sprintf(yyval.na,"LOG(%s)",yyvsp[-1].na);}
+break;
+case 270:
+#line 1498 "fortran.y"
+{sprintf(yyval.na,"TAN(%s)",yyvsp[-1].na);}
+break;
+case 271:
+#line 1500 "fortran.y"
+{sprintf(yyval.na,"ATAN(%s)",yyvsp[-1].na);}
+break;
+case 272:
+#line 1502 "fortran.y"
+{sprintf(yyval.na,"ABS(%s)",yyvsp[-1].na);}
+break;
+case 273:
+#line 1504 "fortran.y"
+{sprintf(yyval.na,"MOD(%s)",yyvsp[-1].na);}
+break;
+case 274:
+#line 1506 "fortran.y"
+{sprintf(yyval.na,"SIGN(%s)",yyvsp[-1].na);}
+break;
+case 275:
+#line 1508 "fortran.y"
+{sprintf(yyval.na,"MINLOC(%s)",yyvsp[-1].na);}
+break;
+case 276:
+#line 1510 "fortran.y"
+{sprintf(yyval.na,"MAXLOC(%s)",yyvsp[-1].na);}
+break;
+case 277:
+#line 1512 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 278:
+#line 1514 "fortran.y"
+{if ( couldaddvariable == 1 )
+                   { strcpy(yyval.na,yyvsp[-2].na);strcat(yyval.na,",");strcat(yyval.na,yyvsp[0].na);}}
+break;
+case 279:
+#line 1517 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 280:
+#line 1519 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 281:
+#line 1521 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 282:
+#line 1523 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].na,yyvsp[0].na);}
+break;
+case 283:
+#line 1525 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 284:
+#line 1527 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 285:
+#line 1529 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"+");}
+break;
+case 286:
+#line 1530 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,"-");}
+break;
+case 287:
+#line 1533 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"+%s",yyvsp[0].na);}
+break;
+case 288:
+#line 1535 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"-%s",yyvsp[0].na);}
+break;
+case 289:
+#line 1537 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"*%s",yyvsp[0].na);}
+break;
+case 290:
+#line 1539 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 291:
+#line 1541 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 292:
+#line 1543 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 293:
+#line 1545 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 294:
+#line 1547 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," > %s",yyvsp[0].na);}
+break;
+case 295:
+#line 1549 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 296:
+#line 1551 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," < %s",yyvsp[0].na);}
+break;
+case 297:
+#line 1553 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 298:
+#line 1555 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," >= %s",yyvsp[0].na);}
+break;
+case 299:
+#line 1557 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 300:
+#line 1559 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," <= %s",yyvsp[0].na);}
+break;
+case 301:
+#line 1561 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 302:
+#line 1563 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 303:
+#line 1565 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 304:
+#line 1567 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 305:
+#line 1569 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s%s",yyvsp[-1].nac,yyvsp[0].na);}
+break;
+case 306:
+#line 1571 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s",yyvsp[0].na);}
+break;
+case 307:
+#line 1573 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s",yyvsp[0].na);}
+break;
+case 308:
+#line 1575 "fortran.y"
+{strcpy(yyval.na,"");}
+break;
+case 309:
+#line 1577 "fortran.y"
+{sprintf(yyval.na,"/%s",yyvsp[0].na);}
+break;
+case 310:
+#line 1579 "fortran.y"
+{sprintf(yyval.na,"/= %s",yyvsp[0].na);}
+break;
+case 311:
+#line 1581 "fortran.y"
+{sprintf(yyval.na,"//%s",yyvsp[0].na);}
+break;
+case 312:
+#line 1584 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"==%s",yyvsp[0].na);}
+break;
+case 313:
+#line 1586 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"= %s",yyvsp[0].na);}
+break;
+case 314:
+#line 1589 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].nac);}
+break;
+case 315:
+#line 1591 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 316:
+#line 1593 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 317:
+#line 1595 "fortran.y"
+{
+                      agrif_parentcall =0;
+                      if (!strcasecmp(identcopy,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                      if ( Agrif_in_Tok_NAME(identcopy) == 1 )
+                      {
+                         inagrifcallargument = 1;
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                      }
+                   }
+break;
+case 318:
+#line 1608 "fortran.y"
+{
+                     strcpy(yyval.na,yyvsp[0].na);
+                     if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+break;
+case 319:
+#line 1613 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," %s %s ",yyvsp[-1].na,yyvsp[0].na);}
+break;
+case 320:
+#line 1615 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                                sprintf(yyval.na," %s ( %s )",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 321:
+#line 1618 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                         sprintf(yyval.na," %s ( %s ) %s ",yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 322:
+#line 1622 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf(yyval.na," %s ( %s )",yyvsp[-3].nac,yyvsp[-1].na);
+                         ModifyTheAgrifFunction_0(yyvsp[-1].na);
+                         agrif_parentcall =0;
+                      }
+                   }
+break;
+case 323:
+#line 1632 "fortran.y"
+{
+                      sprintf(yyval.na," %s %% %s ",yyvsp[-2].na,yyvsp[0].na);
+                      if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+break;
+case 324:
+#line 1638 "fortran.y"
+{sprintf(yyval.na,"(/%s/)",yyvsp[-1].na);}
+break;
+case 325:
+#line 1640 "fortran.y"
+{strcpy(yyval.na," ");}
+break;
+case 326:
+#line 1642 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 327:
+#line 1644 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 328:
+#line 1646 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 329:
+#line 1648 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 330:
+#line 1649 "fortran.y"
+{strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 331:
+#line 1652 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s :%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 332:
+#line 1654 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                               sprintf(yyval.na,"%s :%s :%s",yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 333:
+#line 1657 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":%s :%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 334:
+#line 1658 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,": : %s",yyvsp[0].na);}
+break;
+case 335:
+#line 1659 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":%s",yyvsp[0].na);}
+break;
+case 336:
+#line 1660 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s :",yyvsp[-1].na);}
+break;
+case 337:
+#line 1661 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,":");}
+break;
+case 338:
+#line 1663 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       if ( Vartonumber(yyvsp[0].nac) == 1 )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if (!strcasecmp(yyvsp[0].nac,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                       if ( VariableIsNotFunction(yyvsp[0].nac) == 0 )
+                       {
+                          if ( inagrifcallargument == 1 )
+                          {
+                             if ( !strcasecmp(yyvsp[0].nac,identcopy) )
+                             {
+                                strcpy(sameagrifname,identcopy);
+                                sameagrifargument = 1;
+                             }
+                          }
+                          strcpy(identcopy,yyvsp[0].nac);
+                          pointedvar=0;
+                          strcpy(truename,yyvsp[0].nac);
+                          if (variscoupled_0(yyvsp[0].nac)) strcpy(truename,getcoupledname_0(yyvsp[0].nac));
+/*
+                          if ( VarIsNonGridDepend($1) == 0 &&
+                               Variableshouldberemove($1) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0($1) == 1 ||
+                                  varispointer_0($1) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0($1) == 0)
+                                 {
+                                 ModifyTheVariableName_0($1);
+                                 }
+                                 }
+                                 else
+                                 {
+                                 }
+                             }
+                             if (variscoupled_0($1) == 1)
+                             {
+      printf("mla variable %s est couplee %s\n",$1,getcoupledname_0($1));
+                             ModifyTheVariableNamecoupled_0($1,getcoupledname_0($1));
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1($1);
+                          }
+                          NotifyAgrifFunction_0($1);
+*/
+                          if ( VarIsNonGridDepend(truename) == 0 &&
+                               Variableshouldberemove(truename) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0(truename) == 1 ||
+                                  varispointer_0(truename) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,yyvsp[0].nac) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0(truename) == 0)
+                                 {
+                                 ModifyTheVariableName_0(truename,strlen(yyvsp[0].nac));
+                                 }
+                                 }
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1(truename);
+                          }
+                          NotifyAgrifFunction_0(truename);
+                       }
+                       }
+                    }
+break;
+case 339:
+#line 1742 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,".TRUE.");}
+break;
+case 340:
+#line 1743 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,".FALSE.");}
+break;
+case 341:
+#line 1744 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 342:
+#line 1745 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 343:
+#line 1746 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 344:
+#line 1747 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 345:
+#line 1749 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.nac,"%s%s",yyvsp[-1].nac,yyvsp[0].nac);}
+break;
+case 347:
+#line 1753 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 349:
+#line 1756 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 350:
+#line 1758 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 351:
+#line 1760 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 352:
+#line 1761 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 353:
+#line 1764 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s :%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 354:
+#line 1766 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 355:
+#line 1767 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 356:
+#line 1769 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na," ");}
+break;
+case 357:
+#line 1770 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 358:
+#line 1772 "fortran.y"
+{InitialValueGiven = 0;}
+break;
+case 359:
+#line 1774 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                          strcpy(InitValue,yyvsp[0].na);
+                          InitialValueGiven = 1;
+                       }
+                    }
+break;
+case 360:
+#line 1782 "fortran.y"
+{pos_curinit = setposcur();}
+break;
+case 361:
+#line 1785 "fortran.y"
+{sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 362:
+#line 1788 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuse_0(yyvsp[0].nac);
+                      }
+                      sprintf(charusemodule,"%s",yyvsp[0].nac);
+                      Add_NameOfModuleUsed_1(yyvsp[0].nac);
+
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+break;
+case 363:
+#line 1808 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                      if (insubroutinedeclare == 1)
+                      {
+                         Add_CouplePointed_Var_1(yyvsp[-2].nac,yyvsp[0].lc);
+                      }
+                      if ( firstpass == 1 )
+                      {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            coupletmp = yyvsp[0].lc;
+                            strcpy(ligne,"");
+                            while ( coupletmp )
+                            {
+                               strcat(ligne,coupletmp->c_namevar);
+                               strcat(ligne," => ");
+                               strcat(ligne,coupletmp->c_namepointedvar);
+                               coupletmp = coupletmp->suiv;
+                               if ( coupletmp ) strcat(ligne,",");
+                            }
+                            sprintf(charusemodule,"%s",yyvsp[-2].nac);
+                         }
+                         Add_NameOfModuleUsed_1(yyvsp[-2].nac);
+                      }
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+break;
+case 364:
+#line 1842 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuseonly_0(yyvsp[-4].nac);
+                      }
+                      sprintf(charusemodule,"%s",yyvsp[-4].nac);
+                      Add_NameOfModuleUsed_1(yyvsp[-4].nac);
+
+                       if ( inmoduledeclare == 0 )
+                       {
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_curuse,
+                                                pos_end-pos_curuse);
+                       }
+                       }
+                    }
+break;
+case 365:
+#line 1862 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if variables has been declared in a subroutine      */
+                       if (insubroutinedeclare == 1)
+                       {
+                          Add_CouplePointed_Var_1(yyvsp[-4].nac,yyvsp[0].lc);
+                       }
+                       if ( firstpass == 1 )
+                       {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                             coupletmp = yyvsp[0].lc;
+                             strcpy(ligne,"");
+                             while ( coupletmp )
+                             {
+                                strcat(ligne,coupletmp->c_namevar);
+                               if ( strcasecmp(coupletmp->c_namepointedvar,"") )
+                                                           strcat(ligne," => ");
+                                strcat(ligne,coupletmp->c_namepointedvar);
+                                coupletmp = coupletmp->suiv;
+                                if ( coupletmp ) strcat(ligne,",");
+                             }
+                             sprintf(charusemodule,"%s",yyvsp[-4].nac);
+                          }
+                          Add_NameOfModuleUsed_1(yyvsp[-4].nac);
+                       }
+                       if ( firstpass == 0 )
+                       {
+                          if ( inmoduledeclare == 0 )
+                          {
+
+                            pos_end = setposcur();
+                             RemoveWordSET_0(fortranout,pos_curuse,
+                                                   pos_end-pos_curuse);
+                       if (oldfortranout) 
+                         variableisglobalinmodule(yyvsp[0].lc,yyvsp[-4].nac,oldfortranout,pos_curuseold);
+                        
+                          }
+                          else
+                          {
+
+                             /* if we are in the module declare and if the    */
+                             /* onlylist is a list of global variable         */
+                             variableisglobalinmodule(yyvsp[0].lc, yyvsp[-4].nac, fortranout,pos_curuse);
+                          }
+                       }
+                       }
+                    }
+break;
+case 366:
+#line 1913 "fortran.y"
+{
+                      pos_curuse = setposcur()-strlen(yyvsp[0].nac);
+                     if (firstpass == 0 && oldfortranout) {
+                     pos_curuseold = setposcurname(oldfortranout);
+                     }
+                   }
+break;
+case 367:
+#line 1921 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 368:
+#line 1924 "fortran.y"
+{
+                       if ( couldaddvariable == 1 ) yyval.lc = yyvsp[0].lc;
+                    }
+break;
+case 369:
+#line 1928 "fortran.y"
+{
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        yyvsp[0].lc->suiv = yyvsp[-2].lc;
+                        yyval.lc = yyvsp[0].lc;
+                        }
+                    }
+break;
+case 370:
+#line 1938 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[-2].nac);
+                       Save_Length(yyvsp[-2].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,22);
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                     }
+break;
+case 371:
+#line 1949 "fortran.y"
+{
+                       if ( couldaddvariable == 1 ) yyval.lc = yyvsp[0].lc;
+                    }
+break;
+case 372:
+#line 1953 "fortran.y"
+{
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        yyvsp[0].lc->suiv = yyvsp[-2].lc;
+                        yyval.lc = yyvsp[0].lc;
+                        }
+                    }
+break;
+case 373:
+#line 1963 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[-2].nac);
+                       Save_Length(yyvsp[-2].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,22);
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                       pointedvar=1;
+                       Add_UsedInSubroutine_Var_1(yyvsp[-2].nac);
+                    }
+break;
+case 374:
+#line 1974 "fortran.y"
+{
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,yyvsp[0].nac);
+                       Save_Length(yyvsp[0].nac,21);
+                       strcpy(coupletmp->c_namepointedvar,"");
+                       coupletmp->suiv = NULL;
+                       yyval.lc = coupletmp;
+                     }
+break;
+case 376:
+#line 1985 "fortran.y"
+{
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 377:
+#line 1991 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                         curmodulename);
+                                                         inallocate = 0;
+                     }
+break;
+case 379:
+#line 1998 "fortran.y"
+{
+                       GlobalDeclaration = 0 ;
+                       if ( firstpass == 0 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                          if ( module_declar && insubroutinedeclare == 0 )
+                          {
+                              fclose(module_declar);
+                          }
+                       }
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       if ( inmodulemeet == 1 )
+                       {
+                         /* we are in a module                                */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            /* it is like an end subroutine <name>            */
+                            insubroutinedeclare = 0 ;
+                            /*                                                */
+                            pos_cur = setposcur();
+                            closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                         }
+                         else
+                         {
+                            /* it is like an end module <name>                */
+                            inmoduledeclare = 0 ;
+                            inmodulemeet = 0 ;
+                         }
+                       }
+                       else
+                       {
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+                          pos_cur = setposcur();                        
+                          closeandcallsubloopandincludeit_0(2);
+                            functiondeclarationisdone = 0;
+                          if ( firstpass == 0 )
+                          {
+                             if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                             else fprintf(paramout,"C\n");
+                             fclose(paramout);
+                           }
+                        }
+                      }
+                      strcpy(subroutinename,"");
+                    }
+break;
+case 380:
+#line 2048 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();                      
+                       closeandcallsubloopandincludeit_0(3);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 381:
+#line 2066 "fortran.y"
+{
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+                                             
+                       closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 382:
+#line 2086 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+
+                       closeandcallsubloopandincludeit_0(0);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+break;
+case 383:
+#line 2105 "fortran.y"
+{
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if we never meet the contains keyword               */
+                      Remove_Word_end_module_0(strlen(yyvsp[0].nac));
+                       if ( inmoduledeclare == 1 )
+                       {
+                          if ( aftercontainsdeclare == 0 )
+                          {
+                             Write_GlobalParameter_Declaration_0();
+                             Write_NotGridDepend_Declaration_0();
+                             Write_GlobalType_Declaration_0();
+                             Write_Alloc_Subroutine_For_End_0();
+                          }
+                       }
+                                           
+                       inmoduledeclare = 0 ;
+                       inmodulemeet = 0 ;
+
+                      Write_Word_end_module_0();
+                      strcpy(curmodulename,"");
+                      aftercontainsdeclare = 1;
+                      if ( firstpass == 0 )
+                      {
+                         if ( module_declar && insubroutinedeclare == 0)
+                         {
+                           fclose(module_declar);
+                         }
+                      }
+                      GlobalDeclaration = 0 ;
+                      }
+                  }
+break;
+case 397:
+#line 2151 "fortran.y"
+{
+                      if (inmoduledeclare == 1 )
+                      {
+                         Remove_Word_Contains_0();
+                         Write_GlobalParameter_Declaration_0();
+                         Write_GlobalType_Declaration_0();
+                         Write_NotGridDepend_Declaration_0();
+                         Write_Alloc_Subroutine_0();
+                         inmoduledeclare = 0 ;
+                         aftercontainsdeclare = 1;
+                      }
+                      else
+                      {
+                       if ( couldaddvariable == 1 )
+                       {
+                          if ( firstpass == 1 ) List_ContainsSubroutine =
+                                                Addtolistnom(subroutinename,
+                                                     List_ContainsSubroutine,0);
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+
+                          closeandcallsubloop_contains_0();
+                            functiondeclarationisdone = 0;
+                         if ( firstpass == 0 )
+                         {
+                            if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                            else fprintf(paramout,"C\n");
+                            fclose(paramout);
+                         }
+                         }
+                         strcpy(subroutinename,"");
+                      }
+                   }
+break;
+case 398:
+#line 2186 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       functiondeclarationisdone = 0;
+                       }
+                    }
+break;
+case 399:
+#line 2196 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 400:
+#line 2205 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 401:
+#line 2214 "fortran.y"
+{
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy(yyval.nac,yyvsp[0].nac);
+                       pos_endsubroutine = setposcur()-strlen(yyvsp[0].nac);
+                       }
+                    }
+break;
+case 413:
+#line 2236 "fortran.y"
+{strcpy(yyval.nac,"");}
+break;
+case 414:
+#line 2237 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+case 426:
+#line 2257 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 427:
+#line 2263 "fortran.y"
+{
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+break;
+case 433:
+#line 2274 "fortran.y"
+{if ( couldaddvariable == 1 ) created_dimensionlist = 0;}
+break;
+case 434:
+#line 2276 "fortran.y"
+{
+                  created_dimensionlist = 1;
+                  if  ( agrif_parentcall == 1 )
+                  {
+                      ModifyTheAgrifFunction_0(yyvsp[-1].d->dim.last);
+                      agrif_parentcall =0;
+                      fprintf(fortranout," = ");
+                  }
+              }
+break;
+case 435:
+#line 2286 "fortran.y"
+{created_dimensionlist = 1;}
+break;
+case 440:
+#line 2294 "fortran.y"
+{
+                      inagrifcallargument = 0 ;
+                      incalldeclare=0;
+                      if ( oldfortranout &&
+                           !strcasecmp(meetagrifinitgrids,subroutinename) &&
+                           firstpass == 0 &&
+                           callmpiinit == 1)
+                      {
+                      /*   pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+                         fprintf(oldfortranout,"      Call MPI_Init (%s) \n"
+                                                                   ,mpiinitvar);*/
+                      }
+                      if ( oldfortranout           &&
+                           callagrifinitgrids == 1 &&
+                           firstpass == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+
+                         strcpy(subofagrifinitgrids,subroutinename);
+                      }
+                      Instanciation_0(sameagrifname);
+                   }
+break;
+case 445:
+#line 2328 "fortran.y"
+{
+                       if (!strcasecmp(yyvsp[0].nac,"MPI_Init") )
+                       {
+                          callmpiinit = 1;
+                       }
+                       else
+                       {
+                          callmpiinit = 0;
+                       }
+                       if (!strcasecmp(yyvsp[0].nac,"Agrif_Init_Grids") )
+                       {
+                          callagrifinitgrids = 1;
+                          strcpy(meetagrifinitgrids,subroutinename);
+                       }
+                       else callagrifinitgrids = 0;
+                       if ( !strcasecmp(yyvsp[0].nac,"Agrif_Open_File") )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if ( Vartonumber(yyvsp[0].nac) == 1 )
+                       {
+                          incalldeclare=1;
+                          inagrifcallargument = 1 ;
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                    }
+break;
+case 446:
+#line 2358 "fortran.y"
+{pos_curcall=setposcur()-4;}
+break;
+case 449:
+#line 2363 "fortran.y"
+{
+                  if ( callmpiinit == 1 )
+                  {
+                     strcpy(mpiinitvar,yyvsp[0].na);
+                     if ( firstpass == 1 )
+                     {
+                        Add_UsedInSubroutine_Var_1 (mpiinitvar);
+/*                        curvar=createvar($1,NULL);
+                        curlistvar=insertvar(NULL,curvar);
+                        List_Subr outineArgument_Var = AddListvarToListvar
+                         (curlistvar,List_SubroutineAr gument_Var,1);*/
+                     }
+                  }
+               }
+break;
+case 528:
+#line 2485 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 529:
+#line 2486 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 530:
+#line 2487 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 531:
+#line 2490 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 532:
+#line 2492 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 533:
+#line 2494 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 534:
+#line 2496 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 535:
+#line 2498 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 536:
+#line 2500 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"%s,%s",yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 537:
+#line 2501 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 538:
+#line 2502 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 539:
+#line 2505 "fortran.y"
+{if ( couldaddvariable == 1 ) strcpy(yyval.na,yyvsp[0].na);}
+break;
+case 540:
+#line 2507 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na," (%s)",yyvsp[-1].na);}
+break;
+case 541:
+#line 2509 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 542:
+#line 2511 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 543:
+#line 2513 "fortran.y"
+{if ( couldaddvariable == 1 ) sprintf(yyval.na,"(%s,%s)",yyvsp[-3].na,yyvsp[-1].na);}
+break;
+case 544:
+#line 2517 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                              sprintf(yyval.na,"%s=%s,%s)",yyvsp[-4].nac,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 545:
+#line 2520 "fortran.y"
+{if ( couldaddvariable == 1 )
+                                        sprintf(yyval.na,"%s=%s,%s,%s)",yyvsp[-6].nac,yyvsp[-4].na,yyvsp[-2].na,yyvsp[0].na);}
+break;
+case 554:
+#line 2536 "fortran.y"
+{Add_Allocate_Var_1(yyvsp[0].nac,curmodulename);}
+break;
+case 557:
+#line 2541 "fortran.y"
+{Add_Allocate_Var_1(yyvsp[-3].nac,curmodulename);}
+break;
+case 571:
+#line 2564 "fortran.y"
+{strcpy(yyval.nac,yyvsp[0].nac);}
+break;
+#line 9558 "y.tab.c"
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+    if (yyssp >= yyss + yystacksize - 1)
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    return (0);
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.y
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.y	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.y	(revision 1844)
@@ -0,0 +1,2674 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http ://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+%{
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+extern int line_num_fortran;
+extern int line_num_fortran_common;
+char *tmp;
+char c_selectorname[LONG_C];
+char ligne[LONG_C];
+char truename[LONGNOM];
+char identcopy[LONG_C];
+int c_selectorgiven=0;
+int incom;
+listvar *curlistvar;
+typedim c_selectordim;
+listcouple *coupletmp;
+listdim *parcoursdim;
+int removeline=0;
+listvar *test;
+%}
+
+%union {
+       char      nac[LONG_C];
+       char      na[LONGNOM];
+       listdim  *d;
+       listvar  *l;
+       listnom  *ln;
+       listcouple  *lc;
+       listname *lnn;
+       typedim   dim1;
+       variable *v;
+       }
+
+%left ','
+%nonassoc ':'
+%right '='
+%left TOK_BINARY_OP
+%left TOK_EQV TOK_NEQV
+%left TOK_OR TOK_XOR
+%left TOK_AND
+%left TOK_NOT
+%nonassoc TOK_LT TOK_GT TOK_LE TOK_GE TOK_EQ TOK_NE
+%nonassoc TOK_UNARY_OP
+%left TOK_DSLASH
+%left '+' '-'
+%left '*' TOK_SLASH
+%right TOK_DASTER
+
+%token TOK_SEP
+%token TOK_SEMICOLON
+%token TOK_NEXTLINE
+%token TOK_PARAMETER
+%token TOK_RESULT
+%token TOK_ONLY
+%token TOK_INCLUDE
+%token TOK_SUBROUTINE
+%token TOK_PROGRAM
+%token TOK_FUNCTION
+%token TOK_OMP
+%token TOK_DOLLAR
+%token TOK_FORMAT
+%token TOK_MAX
+%token TOK_TANH
+%token TOK_WHERE
+%token TOK_ELSEWHERE
+%token TOK_ENDWHERE
+%token TOK_MAXVAL
+%token TOK_TRIM
+%token TOK_SUM
+%token TOK_SQRT
+%token TOK_CASE
+%token TOK_SELECTCASE
+%token TOK_FILE
+%token TOK_END
+%token TOK_ERR
+%token TOK_DONOTTREAT
+%token TOK_ENDDONOTTREAT
+%token TOK_EXIST
+%token TOK_MIN
+%token TOK_FLOAT
+%token TOK_EXP
+%token TOK_COS
+%token TOK_COSH
+%token TOK_ACOS
+%token TOK_NINT
+%token TOK_CYCLE
+%token TOK_SIN
+%token TOK_SINH
+%token TOK_ASIN
+%token TOK_EQUIVALENCE
+%token TOK_BACKSPACE
+%token TOK_LOG
+%token TOK_TAN
+%token TOK_ATAN
+%token TOK_RECURSIVE
+%token TOK_ABS
+%token TOK_MOD
+%token TOK_SIGN
+%token TOK_MINLOC
+%token TOK_MAXLOC
+%token TOK_EXIT
+%token TOK_MINVAL
+%token TOK_PUBLIC
+%token TOK_PRIVATE
+%token TOK_ALLOCATABLE
+%token TOK_RETURN
+%token TOK_THEN
+%token TOK_ELSEIF
+%token TOK_ELSE
+%token TOK_ENDIF
+%token TOK_PRINT
+%token TOK_PLAINGOTO
+%token TOK_CONSTRUCTID
+%token TOK_LOGICALIF
+%token TOK_PLAINDO
+%token TOK_CONTAINS
+%token TOK_ENDDO
+%token TOK_MODULE
+%token TOK_ENDMODULE
+%token TOK_DOWHILE
+%token TOK_ALLOCATE
+%token TOK_OPEN
+%token TOK_CLOSE
+%token TOK_INQUIRE
+%token TOK_WRITE
+%token TOK_READ
+%token TOK_REWIND
+%token TOK_DEALLOCATE
+%token TOK_NULLIFY
+%token TOK_FIN
+%token TOK_DEBUT
+%token TOK_DIMENSION
+%token TOK_ENDSELECT
+%token TOK_EXTERNAL
+%token TOK_INTENT
+%token TOK_INTRINSIC
+%token TOK_NAMELIST
+%token TOK_CASEDEFAULT
+%token TOK_OPTIONAL
+%token TOK_POINTER
+%token TOK_CONTINUE
+%token TOK_SAVE
+%token TOK_TARGET
+%token TOK_QUOTE
+%token TOK_IMPLICIT
+%token TOK_NONE
+%token TOK_CALL
+%token TOK_STAT
+%token TOK_POINT_TO
+%token TOK_COMMON
+%token TOK_GLOBAL
+%token TOK_INTERFACE
+%token TOK_ENDINTERFACE
+%token TOK_LEFTAB
+%token TOK_RIGHTAB
+%token TOK_PAUSE
+%token TOK_PROCEDURE
+%token TOK_STOP
+%token TOK_NAMEEQ
+%token TOK_REAL8
+%token <nac> TOK_OUT
+%token <nac> TOK_INOUT
+%token <nac> TOK_IN
+%token <nac> TOK_USE
+%token <nac> TOK_DSLASH
+%token <nac> TOK_DASTER
+%token <nac> TOK_EQ
+%token <nac> TOK_EQV
+%token <nac> TOK_GT
+%token <nac> TOK_LT
+%token <nac> TOK_GE
+%token <nac> TOK_NE
+%token <nac> TOK_NEQV
+%token <nac> TOK_LE
+%token <nac> TOK_OR
+%token <nac> TOK_XOR
+%token <nac> TOK_NOT
+%token <nac> TOK_AND
+%token <nac> TOK_TRUE
+%token <nac> TOK_FALSE
+%token <nac> TOK_LABEL
+%token <nac> TOK_TYPE
+%token <nac> TOK_TYPEPAR
+%token <nac> TOK_ENDTYPE
+%token <nac> TOK_REAL
+%token <nac> TOK_INTEGER
+%token <nac> TOK_LOGICAL
+%token <nac> TOK_DOUBLEPRECISION
+%token <nac> TOK_DOUBLEREAL
+%token <nac> TOK_ENDSUBROUTINE
+%token <nac> TOK_ENDFUNCTION
+%token <nac> TOK_ENDPROGRAM
+%token <nac> TOK_ENDUNIT
+%token <nac> TOK_CHARACTER
+%token <nac> TOK_CHAR_CONSTANT
+%token <nac> TOK_CHAR_CUT
+%token <nac> TOK_DATA
+%token <nac> TOK_CHAR_INT
+%token <nac> TOK_CHAR_MESSAGE
+%token <nac> TOK_CSTREAL
+%token <nac> TOK_CSTREALDP
+%token <nac> TOK_CSTREALQP
+%token <nac> TOK_SFREAL
+%token <nac> TOK_COMPLEX
+%token <nac> TOK_DOUBLECOMPLEX
+%token <nac> TOK_NAME
+%token <nac> TOK_NAME_CHAR
+%token <nac> TOK_PROBTYPE  /* dimension of the problem                        */
+%token <nac> TOK_INTERPTYPE/* kind of interpolation                           */
+%token <nac> TOK_VARTYPE   /* posit ion of the grid variable on the cells of  */
+                          /*     the mesh                                     */
+%token <nac> TOK_SLASH
+%token <nac> TOK_BC        /* calculation of the boundary conditions           */
+%token <nac> TOK_OP
+%token <nac> TOK_CSTINT
+%token <nac> TOK_COMMENT
+%token <nac> TOK_FILENAME
+%token ','
+%token ':'
+%token '('
+%token ')'
+%token '['
+%token ']'
+%token '!'
+%token '_'
+%token '<'
+%token '>'
+%type <l> dcl
+%type <l> after_type
+%type <l> dimension
+%type <l> paramlist
+%type <l> args
+%type <l> arglist
+%type <lc> only_list
+%type <lc> only_name
+%type <lc> rename_list
+%type <lc> rename_name
+%type <d> dims
+%type <d> dimlist
+%type <dim1> dim
+%type <v> paramitem
+%type <nac> comblock
+%type <nac> name_routine
+%type <nac> module_name
+%type <nac> opt_name
+%type <nac> type
+%type <nac> word_endsubroutine
+%type <nac> word_endfunction
+%type <nac> word_endprogram
+%type <nac> word_endunit
+%type <nac> typename
+%type <nac> typespec
+%type <nac> string_constant
+%type <nac> simple_const
+%type <nac> ident
+%type <nac> do_var
+%type <nac> intent_spec
+%type <nac> signe
+%type <nac> opt_signe
+%type <nac> filename
+%type <na> attribute
+%type <na> complex_const
+%type <na> begin_array
+%type <na> clause
+%type <na> arg
+%type <na> uexpr
+%type <na> minmaxlist
+%type <na> lhs
+%type <na> vec
+%type <na> outlist
+%type <na> out2
+%type <na> other
+%type <na> dospec
+%type <na> expr_data
+%type <na> structure_component
+%type <na> array_ele_substring_func_ref
+%type <na> funarglist
+%type <na> funarg
+%type <na> funargs
+%type <na> triplet
+%type <na> substring
+%type <na> opt_substring
+%type <na> opt_expr
+%type <na> optexpr
+%type <na> datavallist
+%type <na> after_slash
+%type <na> after_equal
+%type <na> predefinedfunction
+%type <na> expr
+%type <na> ubound
+%type <na> operation
+%type <na> proper_lengspec
+%type <lnn> use_name_list
+%type <lnn> public
+
+%left TOK_OP
+%%
+input :
+      | input line
+      ;
+line :  '\n' position
+      | thislabel suite_line_list
+      | TOK_COMMENT
+      | keyword cmnt writedeclar
+      | error writedeclar nulcurbuf
+                   {yyerrok;yyclearin;}
+      ;
+suite_line_list : suite_line
+      |   suite_line_list TOK_SEMICOLON suite_line
+      ;
+suite_line : entry fin_line  /* subroutine, function, module                    */
+      | spec fin_line      /* declaration                                     */
+      | before_include filename fin_line
+                  {
+                     if (inmoduledeclare == 0 )
+                     {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curinclude,
+                                              pos_end-pos_curinclude);
+                     }
+                  }
+      | exec cmnt writedeclar /* if, do etc ...                               */
+      | instr fin_line    /* instruction ident  : do i = 1 ...                */
+      ;
+instr : ident ':'
+      ;
+fin_line : position cmnt
+      ;
+keyword : TOK_DONOTTREAT
+         {
+            /* we should ignore the declaration until the keyword             */
+            /*    TOK_ENDDONOTTREAT                                           */
+            couldaddvariable = 0 ;
+            RemoveWordCUR_0(fortranout,-20,20);
+         }
+      | TOK_ENDDONOTTREAT
+         {
+             couldaddvariable = 1 ;
+             RemoveWordCUR_0(fortranout,-24,24);
+          }
+      | TOK_OMP
+      | TOK_DOLLAR
+      ;
+position : {pos_cur = setposcur();}
+      ;
+thislabel :
+      | TOK_LABEL nulcurbuf
+      ;
+cmnt :
+      | TOK_COMMENT
+      ;
+incomment :
+                   {incom = 1;}
+      ;
+nulcurbuf :
+                   {if (incom !=1) {strcpy(curbuf,"");incom=0;}}
+      ;
+opt_recursive :
+      | TOK_RECURSIVE
+      ;
+entry :
+      | opt_recursive TOK_SUBROUTINE name_routine arglist
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,$3);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      Add_SubroutineArgument_Var_1($4);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(1);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            writeheadnewsub_0(1);
+                      }
+                      }
+                   }
+      | TOK_PROGRAM name_routine
+                   {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,$2);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+
+                      }
+                      strcpy(subroutinename,$2);
+                      /* Common case                                          */
+                      insubroutinedeclare = 1;
+                      /* in the second step we should write the head of       */
+                      /*    the subroutine sub_loop_<subroutinename>          */
+                      writeheadnewsub_0(1);
+                   }
+      | TOK_FUNCTION name_routine arglist TOK_RESULT arglist1
+                   {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,$2);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,$2);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1($3);
+                         strcpy(DeclType,"");
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1($3);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1($2);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+      | TOK_FUNCTION name_routine arglist
+                   {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,$2);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,$2);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1($3);
+                         strcpy(DeclType,"");
+                         Add_FunctionType_Var_1($2);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                            insubroutinedeclare = 1;
+                            /* we should to list of the subroutine argument   */
+                            /* name of the function which has to be defined   */
+                            Add_SubroutineArgument_Var_1($3);
+                            strcpy(DeclType,"");
+                            Add_FunctionType_Var_1($2);
+                            writeheadnewsub_0(2);
+                      }
+                   }
+      | TOK_MODULE TOK_NAME
+                   {
+                      GlobalDeclaration = 0;
+                      strcpy(curmodulename,$2);
+                      strcpy(subroutinename,"");
+                      Add_NameOfModule_1($2);
+                      if ( inmoduledeclare == 0 )
+                      {
+                         /* To know if there are in the module declaration    */
+                         inmoduledeclare = 1;
+                         /* to know if a module has been met                  */
+                         inmodulemeet = 1;
+                         /* to know if we are after the keyword contains      */
+                         aftercontainsdeclare = 0 ;
+                      }
+                   }
+      ;
+name_routine : TOK_NAME
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy($$,$1);strcpy(subroutinename,$1);
+                      }
+                   }
+writedeclar :
+      ;
+before_include : TOK_INCLUDE
+                   {
+                      pos_curinclude = setposcur()-9;
+                   }
+filename : TOK_CHAR_CONSTANT
+                   {
+                      if ( couldaddvariable == 1 ) Add_Include_1($1);
+                   }
+      ;
+arglist :           {
+                      if ( firstpass == 1 && couldaddvariable == 1) $$=NULL;
+                   }
+      | '(' ')'    {
+                      if ( firstpass == 1 && couldaddvariable == 1 ) $$=NULL;
+                   }
+      | '(' args ')'
+                   {
+                       if ( firstpass == 1 && couldaddvariable == 1 ) $$=$2;
+                   }
+      ;
+arglist1:
+      | '(' ')'
+      | '(' args ')'
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_SubroutineArgument_Var_1($2);
+                      }
+                   }
+      ;
+args :arg           {
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");
+                         curvar=createvar($1,NULL);
+                        strcpy(nameinttypename,nameinttypenameback);
+                         curlistvar=insertvar(NULL,curvar);
+                         $$=settype("",curlistvar);
+                      }
+                   }
+      | args ',' arg
+                   {
+                      if ( firstpass == 1  && couldaddvariable == 1)
+                      {
+                         strcpy(nameinttypenameback,nameinttypename);
+                         strcpy(nameinttypename,"");                      
+                         curvar=createvar($3,NULL);
+                         strcpy(nameinttypename,nameinttypenameback);                         
+                         $$=insertvar($1,curvar);
+                      }
+                   }
+      ;
+arg : TOK_NAME      {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | '*'        {if ( couldaddvariable == 1 ) strcpy($$,"*");}
+      ;
+spec : type after_type
+                   {
+                      if ( VarTypepar == 1 )
+                      {
+                         couldaddvariable = 1 ;
+                         VarTypepar = 0;
+                      }
+                   }
+      | TOK_TYPE opt_spec opt_sep opt_name
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         VarType = 1;
+                         couldaddvariable = 0 ;
+                      }
+                   }
+      | TOK_ENDTYPE opt_name
+                   {
+                      if ( VarType == 1 ) couldaddvariable = 1 ;
+                      VarType = 0;
+                      VarTypepar = 0;
+                   }
+      | TOK_POINTER list_couple
+      | before_parameter  '(' paramlist ')'
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1($3);
+                         else Add_Parameter_Var_1($3);
+                         pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+      | before_parameter  paramlist
+                   {
+                     if ( couldaddvariable == 1 )
+                     {
+                        if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1($2);
+                         else Add_Parameter_Var_1($2);
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                    pos_end-pos_cur_decl);
+                      }
+                      VariableIsParameter =  0 ;
+                   }
+      | common
+      | save
+                  {
+                     pos_end = setposcur();
+                     RemoveWordSET_0(fortranout,pos_cursave,
+                                                pos_end-pos_cursave);
+                  }
+      | implicit
+      | dimension
+                  {
+                   /* if the variable is a parameter we can suppose that is   */
+                   /*    value is the same on each grid. It is not useless to */
+                   /*    create a copy of it on each grid                     */
+                      if ( couldaddvariable == 1 )
+                      {
+                         Add_Globliste_1($1);
+                         /* if variableparamlists has been declared in a      */
+                         /*    subroutine                                     */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            Add_Dimension_Var_1($1);
+                         }
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curdimension,
+                                                pos_end-pos_curdimension);
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+      | public
+      {
+      if (firstpass == 0)
+      {
+      if ($1)
+      {
+      removeglobfromlist(&($1));
+      pos_end = setposcur();
+           RemoveWordSET_0(fortranout,pos_cur,pos_end-pos_cur);
+      writelistpublic($1);
+      }
+      }
+      }
+      | private
+      | use_stat
+      | module_proc_stmt
+      | interface
+      | namelist
+      | TOK_BACKSPACE '(' expr ')'
+      | TOK_EXTERNAL opt_sep use_name_list
+      | TOK_INTRINSIC opt_sep use_intrinsic_list
+      | TOK_EQUIVALENCE list_expr_equi
+      | before_data data '\n'
+                   {
+                      /* we should remove the data declaration                */
+                      if ( couldaddvariable == 1 && aftercontainsdeclare == 0 )
+                      {
+                        pos_end = setposcur();
+                        RemoveWordSET_0(fortranout,pos_curdata,
+                                              pos_end-pos_curdata);
+                      }
+                  }
+      ;
+opt_spec :
+      | access_spec
+      {
+         PublicDeclare = 0 ;
+         PrivateDeclare = 0 ;
+      }
+      ;
+name_intrinsic : TOK_SUM
+      | TOK_TANH
+      | TOK_MAXVAL
+      | TOK_MIN
+      | TOK_MINVAL
+      | TOK_TRIM
+      | TOK_SQRT
+      | TOK_NINT
+      | TOK_FLOAT
+      | TOK_EXP
+      | TOK_COS
+      | TOK_COSH
+      | TOK_ACOS
+      | TOK_SIN
+      | TOK_SINH
+      | TOK_ASIN
+      | TOK_LOG
+      | TOK_TAN
+      | TOK_ATAN
+      | TOK_MOD
+      | TOK_SIGN
+      | TOK_MINLOC
+      | TOK_MAXLOC
+      | TOK_NAME
+      ;
+use_intrinsic_list : name_intrinsic
+      | use_intrinsic_list ',' name_intrinsic
+      ;
+list_couple : '(' list_expr ')'
+      | list_couple ',' '(' list_expr ')'
+      ;
+list_expr_equi : expr_equi
+      | list_expr_equi ',' expr_equi
+      ;
+expr_equi : '(' list_expr_equi1 ')'
+      ;
+list_expr_equi1 : ident dims
+      | list_expr_equi1 ',' ident dims
+      ;
+list_expr : expr
+      | list_expr ',' expr
+      ;
+opt_sep :
+      | ':' ':'
+      ;
+after_type : dcl nodimsgiven
+                   {
+                      /* if the variable is a parameter we can suppose that is*/
+                      /*    value is the same on each grid. It is not useless */
+                      /*    to create a copy of it on each grid               */
+                      if ( couldaddvariable == 1 )
+                      {
+                      pos_end = setposcur();
+                      /*if (insubroutinedeclare == 0)
+                        {   */
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
+                                                 pos_end-pos_cur_decl);
+                                         
+                       /* }
+                      else
+                       {*/
+                        ReWriteDeclarationAndAddTosubroutine_01($1);
+                        pos_cur_decl = setposcur();
+                        
+                       /*}*/
+                      if ( firstpass == 0 &&
+                           GlobalDeclaration == 0 &&
+                           insubroutinedeclare == 0 )
+                      {
+                         sprintf(ligne,"\n#include \"Module_Declar_%s.h\"\n"
+                                                                ,curmodulename);
+                         tofich(fortranout,ligne,1);
+                         sprintf (ligne, "Module_Declar_%s.h",curmodulename);
+                         module_declar = associate(ligne);
+                         sprintf (ligne, " ");
+                         tofich (module_declar, ligne,1);
+                         GlobalDeclaration = 1 ;
+                      }
+                         $$ = $1;
+                         Add_Globliste_1($1);
+                                                  
+                         if ( insubroutinedeclare == 0 )
+                                                  Add_GlobalParameter_Var_1($1);
+                         else
+                         {
+                            if ( pointerdeclare == 1 )
+                                                Add_Pointer_Var_From_List_1($1);
+                            Add_Parameter_Var_1($1);
+                         }
+
+                         /* if variables has been declared in a subroutine    */
+                         if ( insubroutinedeclare == 1 )
+                         { 
+                       /*    Add_SubroutineDeclaration_Var_1($1);*/
+                         }
+                         /* If there are a SAVE declarations in module's      */
+                         /*    subroutines we should remove it from the       */
+                         /*    subroutines declaration and add it in the      */
+                         /*    global declarations                            */
+                         if ( aftercontainsdeclare == 1 &&
+                              SaveDeclare == 1 && firstpass == 1 )
+                         {
+                              if ( inmodulemeet == 0 ) Add_Save_Var_dcl_1($1);
+                              else  Add_SubroutineDeclarationSave_Var_1($1);
+                         }
+                      }
+                      /*                                                      */
+                      PublicDeclare = 0;
+                      PrivateDeclare = 0;
+                      ExternalDeclare = 0;
+                      strcpy(NamePrecision,"");
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ;
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");
+                      strcpy(c_selectorname,"");
+                   }
+      | before_function name_routine arglist
+                   {
+                      /* open param file                                      */
+                      if ( firstpass == 0 )
+                      {
+                         sprintf(ligne,"%s/ParamFile%s.h",nomdir,$2);
+                         paramout=fopen(ligne,"w");
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                      }
+                      strcpy(subroutinename,$2);
+                      if ( inmodulemeet == 1 )
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1($3);
+                         Add_FunctionType_Var_1($2);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      else
+                      {
+                         insubroutinedeclare = 1;
+                         /* we should to list of the subroutine argument the  */
+                         /*    name of the function which has to be defined   */
+                         Add_SubroutineArgument_Var_1($3);
+                         Add_FunctionType_Var_1($2);
+                         /* in the second step we should write the head of    */
+                         /*    the subroutine sub_loop_<subroutinename>       */
+                         writeheadnewsub_0(2);
+                      }
+                      strcpy(nameinttypename,"");
+
+                   }
+      ;
+before_function : TOK_FUNCTION
+                   {
+                       functiondeclarationisdone = 1;
+                   }
+                   ;
+
+before_parameter : TOK_PARAMETER
+                   {
+                      VariableIsParameter = 1;
+                      pos_curparameter = setposcur()-9;
+                   }
+before_data : TOK_DATA
+                   {
+                      pos_curdata = setposcur()-strlen($1);
+                   }
+data : TOK_NAME TOK_SLASH datavallist TOK_SLASH
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",$3);
+                      Add_Data_Var_1($1,ligne);
+                      }
+                   }
+      | data opt_comma TOK_NAME TOK_SLASH datavallist TOK_SLASH
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                      if ( aftercontainsdeclare == 1 ) strcpy(ligne,"");
+                      else sprintf(ligne,"(/ %s /)",$5);
+                      Add_Data_Var_1($3,ligne);
+                      }
+                   }
+      | datanamelist TOK_SLASH datavallist TOK_SLASH
+                   {
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                   }
+      ;
+datavallist : expr_data
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy($$,$1);
+                      }
+                   }
+      | expr_data ',' datavallist
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf($$,"%s,%s",$1,$3);
+                      }
+                   }
+      ;
+
+save :  before_save varsave
+      | before_save  comblock varsave
+      | save opt_comma comblock opt_comma varsave
+      | save ',' varsave
+      ;
+before_save : TOK_SAVE
+                  {
+                     pos_cursave = setposcur()-4;
+                  }
+      ;
+varsave :
+      | TOK_NAME dims
+                  {
+                     if ( couldaddvariable == 1 ) Add_Save_Var_1($1,$2);
+                  }
+      ;
+datanamelist : TOK_NAME
+      | TOK_NAME '(' expr ')'
+      | datanamelist ',' datanamelist
+      ;
+expr_data : opt_signe simple_const
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      | expr_data '+' expr_data
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s+%s",$1,$3);}
+      | expr_data '-' expr_data
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s-%s",$1,$3);}
+      | expr_data '*' expr_data
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s*%s",$1,$3);}
+      | expr_data '/' expr_data
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s/%s",$1,$3);}
+      ;
+opt_signe :
+                   {if ( couldaddvariable == 1 ) strcpy($$,"");}
+      | signe
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+namelist :  namelist_action after_namelist
+      ;
+namelist_action : TOK_NAMELIST  ident
+      | TOK_NAMELIST  comblock ident
+      | namelist_action opt_comma comblock opt_comma ident
+      | namelist_action ',' ident
+      ;
+after_namelist :
+      ;
+interface : TOK_INTERFACE opt_name
+      | TOK_ENDINTERFACE opt_name
+      ;
+before_dimension : TOK_DIMENSION
+                   {
+                      positioninblock=0;
+                      pos_curdimension = setposcur()-9;
+                   }
+
+dimension :  before_dimension opt_comma TOK_NAME dims lengspec
+      {
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar($3,$4);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar(NULL,curvar);
+            /*                                                                */
+            $$=settype("",curlistvar);
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+      | dimension ',' TOK_NAME dims lengspec
+      {
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar($3,$4);
+            /*                                                                */
+            CreateAndFillin_Curvar("",curvar);
+            /*                                                                */
+            curlistvar=insertvar($1,curvar);
+            /*                                                                */
+            $$=curlistvar;
+            /*                                                                */
+            strcpy(vallengspec,"");
+         }
+      }
+      ;
+private : TOK_PRIVATE '\n'
+      | TOK_PRIVATE opt_sep use_name_list
+      ;
+public : TOK_PUBLIC '\n'
+        {
+        $$=(listname *)NULL;
+        }
+      | TOK_PUBLIC opt_sep use_name_list
+         {
+          $$=$3;
+         }
+      ;
+use_name_list : TOK_NAME
+           {
+           $$ = Insertname(NULL,$1);
+           }
+      | use_name_list ',' TOK_NAME
+          {
+          $$ = Insertname($1,$3);
+          }
+      ;
+common : before_common var_common_list
+                   {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcommon,
+                                                  pos_end-pos_curcommon);
+                   }
+      | before_common comblock var_common_list
+                   {
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",$2);
+                            Add_NameOfCommon_1($2);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+      | common opt_comma comblock opt_comma var_common_list
+                   {
+                         if ( couldaddvariable == 1 )
+                         {
+                            sprintf(charusemodule,"%s",$3);
+                            Add_NameOfCommon_1($3);
+                            pos_end = setposcur();
+                            RemoveWordSET_0(fortranout,pos_curcommon,
+                                                       pos_end-pos_curcommon);
+                         }
+                   }
+      ;
+before_common : TOK_COMMON
+                   {
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6;
+                   }
+      | TOK_GLOBAL TOK_COMMON
+                   {
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6-7;
+                   }
+      ;
+var_common_list : var_common
+                   {
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+
+     | var_common_list ',' var_common
+                   {
+                      if ( couldaddvariable == 1 ) Add_Common_var_1();
+                   }
+var_common : TOK_NAME dims
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         positioninblock = positioninblock + 1 ;
+                         strcpy(commonvar,$1);
+                         commondim = $2;
+                      }
+                   }
+      ;
+comblock : TOK_DSLASH
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy($$,"");
+                         positioninblock=0;
+                         strcpy(commonblockname,"");
+                      }
+                   }
+      | TOK_SLASH TOK_NAME TOK_SLASH
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         strcpy($$,$2);
+                         positioninblock=0;
+                         strcpy(commonblockname,$2);
+                      }
+                   }
+      ;
+opt_comma :
+      | ','
+      ;
+paramlist : paramitem
+                   {
+                      if ( couldaddvariable == 1 ) $$=insertvar(NULL,$1);
+                   }
+      | paramlist ',' paramitem
+                   {
+                      if ( couldaddvariable == 1 ) $$=insertvar($1,$3);
+                   }
+      ;
+paramitem : TOK_NAME '=' expr
+                   {
+                     if ( couldaddvariable == 1 )
+                     {
+                         curvar=(variable *) malloc(sizeof(variable));
+                         /*                                                   */
+                         Init_Variable(curvar);
+                         /*                                                   */
+                         curvar->v_VariableIsParameter=1;
+                         strcpy(curvar->v_nomvar,$1);
+                         Save_Length($1,4);
+                         strcpy(curvar->v_subroutinename,subroutinename);
+                         Save_Length(subroutinename,11);
+                         strcpy(curvar->v_modulename,curmodulename);
+                         Save_Length(curmodulename,6);
+                         strcpy(curvar->v_initialvalue,$3);
+                         Save_Length($3,14);
+                         strcpy(curvar->v_commoninfile,mainfile);
+                         Save_Length(mainfile,10);
+                         $$=curvar;
+                      }
+                   }
+      ;
+module_proc_stmt : TOK_PROCEDURE proc_name_list
+      ;
+proc_name_list : TOK_NAME
+      | proc_name_list ',' TOK_NAME
+      ;
+implicit : TOK_IMPLICIT TOK_NONE
+                    {
+                       if ( insubroutinedeclare == 1 )
+                       {
+                          Add_ImplicitNoneSubroutine_1();
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_end-13,
+                                                             13);
+                       }
+                    }
+      | TOK_IMPLICIT TOK_REAL8
+      ;
+opt_retour :
+      ;
+dcl : options opt_retour TOK_NAME dims lengspec initial_value
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         /*                                                   */
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar($3,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar($3,$4);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar(DeclType,curvar);
+                         /*                                                   */
+                         curlistvar=insertvar(NULL,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         $$=settype(DeclType,curlistvar);
+                      }
+                      strcpy(vallengspec,"");
+                   }
+      | dcl ',' opt_retour TOK_NAME dims lengspec initial_value
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         if (dimsgiven == 1)
+                         {
+                            curvar=createvar($4,curdim);
+                         }
+                         else
+                         {
+                            curvar=createvar($4,$5);
+                         }
+                         /*                                                   */
+                         CreateAndFillin_Curvar($1->var->v_typevar,curvar);
+                         /*                                                   */
+                         strcpy(curvar->v_typevar,($1->var->v_typevar));
+                         Save_Length($1->var->v_typevar,3);
+                         /*                                                   */
+                         curlistvar=insertvar($1,curvar);
+                         if (!strcasecmp(DeclType,"character"))
+                         {
+                            if (c_selectorgiven == 1)
+                            {
+                               strcpy(c_selectordim.first,"1");
+                               strcpy(c_selectordim.last,c_selectorname);
+                               Save_Length(c_selectorname,1);
+                               change_dim_char
+                                     (insertdim(NULL,c_selectordim),curlistvar);
+                            }
+                         }
+                         $$=curlistvar;
+                      }
+                      strcpy(vallengspec,"");
+                   }
+      ;
+nodimsgiven :       {dimsgiven=0;}
+      ;
+type : typespec selector
+                   {strcpy(DeclType,$1);}
+      | before_character c_selector
+                   {
+                      strcpy(DeclType,"CHARACTER");
+                   }
+      | typename '*' TOK_CSTINT
+                   {
+                      strcpy(DeclType,$1);
+                      strcpy(nameinttypename,$3);
+                   }
+      | before_typepar attribute ')'
+                   {
+                      strcpy(DeclType,"TYPE");
+                   }
+      ;
+before_typepar : TOK_TYPEPAR
+                   {
+                 /*     if ( couldaddvariable == 1 ) VarTypepar = 1 ;
+                      couldaddvariable = 0 ;
+                      pos_cur_decl = setposcur()-5;*/
+                   pos_cur_decl = setposcur()-5;
+                   }
+      ;
+c_selector :
+      | '*' TOK_CSTINT
+                   {c_selectorgiven=1;strcpy(c_selectorname,$2);}
+      | '*' '(' c_attribute ')' {c_star = 1;}
+      | '(' c_attribute ')'
+      ;
+c_attribute : TOK_NAME clause opt_clause
+      | TOK_NAME '=' clause opt_clause
+      | clause opt_clause
+      ;
+before_character : TOK_CHARACTER
+                   {
+                      pos_cur_decl = setposcur()-9;
+                   }
+      ;
+typespec : typename {strcpy($$,$1);}
+      ;
+typename : TOK_INTEGER
+                   {
+                      strcpy($$,"INTEGER");
+                      pos_cur_decl = setposcur()-7;
+                   }
+      | TOK_REAL   {
+                      strcpy($$,"REAL");
+                      pos_cur_decl = setposcur()-4;
+                   }
+      | TOK_COMPLEX
+                   {strcpy($$,"COMPLEX");
+                   pos_cur_decl = setposcur()-7;}
+      | TOK_DOUBLEPRECISION
+                   {
+                      pos_cur_decl = setposcur()-16;
+                      strcpy($$,"REAL");
+                      strcpy(nameinttypename,"8");
+                   }
+      | TOK_DOUBLECOMPLEX
+                   {strcpy($$,"DOUBLE COMPLEX");}
+      | TOK_LOGICAL
+                   {
+                      strcpy($$,"LOGICAL");
+                      pos_cur_decl = setposcur()-7;
+                   }
+      ;
+lengspec :
+      | '*' proper_lengspec {strcpy(vallengspec,$2);}
+      ;
+proper_lengspec : expr {sprintf($$,"*%s",$1);}
+      | '(' '*' ')'{strcpy($$,"*(*)");}
+      ;
+selector :
+      | '*' proper_selector
+      | '(' attribute ')'
+      ;
+proper_selector : expr
+      | '(' '*' ')'
+      ;
+attribute : TOK_NAME clause
+      | TOK_NAME '=' clause
+                   {
+                      if ( strstr($3,"0.d0") )
+                      {
+                         strcpy(nameinttypename,"8");
+                         sprintf(NamePrecision,"");
+                      }
+                      else sprintf(NamePrecision,"%s = %s",$1,$3);
+                   }
+      | TOK_NAME
+                   {
+                      strcpy(NamePrecision,$1);
+                   }
+      | TOK_CSTINT
+                   {
+                      strcpy(NamePrecision,$1);
+                   }
+      ;
+clause : expr       {strcpy(CharacterSize,$1);
+                    strcpy($$,$1);}
+      | '*'        {strcpy(CharacterSize,"*");
+                    strcpy($$,"*");}
+      ;
+opt_clause :
+      | ',' TOK_NAME clause
+      ;
+options :
+      | ':' ':'
+      | ',' attr_spec_list ':' ':'
+      ;
+attr_spec_list : attr_spec
+      | attr_spec_list ',' attr_spec
+      ;
+attr_spec : TOK_PARAMETER
+                   {
+                      VariableIsParameter = 1;
+                   }
+      | access_spec
+      | TOK_ALLOCATABLE
+                   {Allocatabledeclare = 1;}
+      | TOK_DIMENSION dims
+                   {
+                      dimsgiven=1;
+                      curdim=$2;
+                   }
+      | TOK_EXTERNAL
+                   {ExternalDeclare = 1;}
+      | TOK_INTENT '(' intent_spec ')'
+                   {strcpy(IntentSpec,$3);}
+      | TOK_INTRINSIC
+      | TOK_OPTIONAL{optionaldeclare = 1 ;}
+      | TOK_POINTER {pointerdeclare = 1 ;}
+      | TOK_SAVE    {
+/*                       if ( inmodulemeet == 1 )
+                       {*/
+                          SaveDeclare = 1 ;
+                     /*  }*/
+                    }
+      | TOK_TARGET
+      ;
+intent_spec : TOK_IN {strcpy($$,$1);}
+      | TOK_OUT     {strcpy($$,$1);}
+      | TOK_INOUT   {strcpy($$,$1); }
+      ;
+access_spec : TOK_PUBLIC
+                   {PublicDeclare = 1;}
+      | TOK_PRIVATE
+                   {PrivateDeclare = 1;}
+      ;
+dims :              {if ( created_dimensionlist == 1 )
+                       {
+                           $$=(listdim *)NULL;
+                       }
+                   }
+      | '(' dimlist ')'
+                   {if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) $$=$2;}
+      ;
+dimlist :   dim     {if ( created_dimensionlist == 1 ||
+                         agrif_parentcall      == 1 ) $$=insertdim(NULL,$1);}
+      | dimlist ',' dim
+                   {if ( couldaddvariable == 1 )
+                         if ( created_dimensionlist == 1 ) $$=insertdim($1,$3);}
+      ;
+dim : ubound         {
+                      strcpy($$.first,"1");
+                      strcpy($$.last,$1);
+                      Save_Length($1,1);
+                   }
+      | ':'        {
+                      strcpy($$.first,"");
+                      strcpy($$.last,"");
+                   }
+      | expr ':'   {
+                      strcpy($$.first,$1);
+                      Save_Length($1,2);
+                      strcpy($$.last,"");
+                   }
+      | ':' expr   {
+                      strcpy($$.first,"");
+                      strcpy($$.last,$2);
+                      Save_Length($2,1);
+                   }
+      | expr ':' ubound
+                   {
+                      strcpy($$.first,$1);
+                      Save_Length($1,2);
+                      strcpy($$.last,$3);
+                      Save_Length($3,1);
+                   }
+      ;
+ubound :  '*'       {strcpy($$,"*");}
+      | expr       {strcpy($$,$1);}
+      ;
+expr :  uexpr       {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | '(' expr ')'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"(%s)",$2);}
+      | complex_const
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | predefinedfunction
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+
+predefinedfunction : TOK_SUM minmaxlist ')'
+                   {sprintf($$,"SUM(%s)",$2);}
+      | TOK_MAX minmaxlist ')'
+                   {sprintf($$,"MAX(%s)",$2);}
+      | TOK_TANH '(' minmaxlist ')'
+                   {sprintf($$,"TANH(%s)",$3);}
+      | TOK_MAXVAL '(' minmaxlist ')'
+                   {sprintf($$,"MAXVAL(%s)",$3);}
+      | TOK_MIN minmaxlist ')'
+                   {sprintf($$,"MIN(%s)",$2);}
+      | TOK_MINVAL '(' minmaxlist ')'
+                   {sprintf($$,"MINVAL(%s)",$3);}
+      | TOK_TRIM '(' expr ')'
+                   {sprintf($$,"TRIM(%s)",$3);}
+      | TOK_SQRT expr ')'
+                   {sprintf($$,"SQRT(%s)",$2);}
+      | TOK_REAL '(' minmaxlist ')'
+                   {sprintf($$,"REAL(%s)",$3);}
+      | TOK_NINT '(' expr ')'
+                   {sprintf($$,"NINT(%s)",$3);}
+      | TOK_FLOAT '(' expr ')'
+                   {sprintf($$,"FLOAT(%s)",$3);}
+      | TOK_EXP '(' expr ')'
+                   {sprintf($$,"EXP(%s)",$3);}
+      | TOK_COS '(' expr ')'
+                   {sprintf($$,"COS(%s)",$3);}
+      | TOK_COSH '(' expr ')'
+                   {sprintf($$,"COSH(%s)",$3);}
+      | TOK_ACOS '(' expr ')'
+                   {sprintf($$,"ACOS(%s)",$3);}
+      | TOK_SIN '(' expr ')'
+                   {sprintf($$,"SIN(%s)",$3);}
+      | TOK_SINH '(' expr ')'
+                   {sprintf($$,"SINH(%s)",$3);}
+      | TOK_ASIN '(' expr ')'
+                   {sprintf($$,"ASIN(%s)",$3);}
+      | TOK_LOG '(' expr ')'
+                   {sprintf($$,"LOG(%s)",$3);}
+      | TOK_TAN '(' expr ')'
+                   {sprintf($$,"TAN(%s)",$3);}
+      | TOK_ATAN '(' expr ')'
+                   {sprintf($$,"ATAN(%s)",$3);}
+      | TOK_ABS expr ')'
+                   {sprintf($$,"ABS(%s)",$2);}
+      | TOK_MOD '(' minmaxlist ')'
+                   {sprintf($$,"MOD(%s)",$3);}
+      | TOK_SIGN '(' minmaxlist ')'
+                   {sprintf($$,"SIGN(%s)",$3);}
+      | TOK_MINLOC '(' minmaxlist ')'
+                   {sprintf($$,"MINLOC(%s)",$3);}
+      | TOK_MAXLOC '(' minmaxlist ')'
+                   {sprintf($$,"MAXLOC(%s)",$3);}
+      ;
+minmaxlist : expr {strcpy($$,$1);}
+      | minmaxlist ',' expr
+                   {if ( couldaddvariable == 1 )
+                   { strcpy($$,$1);strcat($$,",");strcat($$,$3);}}
+      ;
+uexpr :  lhs        {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | simple_const
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | vec
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | expr operation
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      | signe expr %prec '*' 
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      | TOK_NOT expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      ;
+signe : '+'        {if ( couldaddvariable == 1 ) strcpy($$,"+");}
+      | '-'        {if ( couldaddvariable == 1 ) strcpy($$,"-");}
+      ;
+operation : '+' expr %prec '+'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"+%s",$2);}
+      |  '-' expr %prec '+'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"-%s",$2);}
+      |  '*' expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"*%s",$2);}
+      |  TOK_DASTER expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_EQ expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_EQV expr %prec TOK_EQV
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}                   
+      |  TOK_GT expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  '>' expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$," > %s",$2);}
+      |  TOK_LT expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  '<' expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$," < %s",$2);}
+      |  TOK_GE expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  '>''=' expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$," >= %s",$3);}
+      |  TOK_LE expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  '<''=' expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$," <= %s",$3);}
+      |  TOK_NE expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_NEQV expr %prec TOK_EQV
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}                   
+      |  TOK_XOR expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_OR expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_AND expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      |  TOK_SLASH after_slash
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s",$2);}
+      |  '=' after_equal
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s",$2);}
+
+after_slash : {strcpy($$,"");}
+      | expr
+                   {sprintf($$,"/%s",$1);}
+      | '=' expr %prec TOK_EQ
+                   {sprintf($$,"/= %s",$2);}
+      | TOK_SLASH expr
+                   {sprintf($$,"//%s",$2);}
+      ;
+after_equal : '=' expr %prec TOK_EQ
+                   {if ( couldaddvariable == 1 ) sprintf($$,"==%s",$2);}
+      | expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"= %s",$1);}
+      ;
+
+lhs : ident         {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | structure_component
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | array_ele_substring_func_ref
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+beforefunctionuse : {
+                      agrif_parentcall =0;
+                      if (!strcasecmp(identcopy,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                      if ( Agrif_in_Tok_NAME(identcopy) == 1 )
+                      {
+                         inagrifcallargument = 1;
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                      }
+                   }
+      ;
+array_ele_substring_func_ref : begin_array
+                   {
+                     strcpy($$,$1);
+                     if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+      | begin_array substring
+                   {if ( couldaddvariable == 1 ) sprintf($$," %s %s ",$1,$2);}
+      | structure_component '(' funarglist ')'
+                   {if ( couldaddvariable == 1 )
+                                                sprintf($$," %s ( %s )",$1,$3);}
+      | structure_component '(' funarglist ')' substring
+                   {if ( couldaddvariable == 1 )
+                                         sprintf($$," %s ( %s ) %s ",$1,$3,$5);}
+      ;
+begin_array : ident '(' funarglist ')'
+                   {
+                      if ( couldaddvariable == 1 )
+                      {
+                         sprintf($$," %s ( %s )",$1,$3);
+                         ModifyTheAgrifFunction_0($3);
+                         agrif_parentcall =0;
+                      }
+                   }
+      ;
+structure_component : lhs '%' lhs
+                   {
+                      sprintf($$," %s %% %s ",$1,$3);
+                      if ( incalldeclare == 0 ) inagrifcallargument = 0;
+                   }
+      ;
+vec :  TOK_LEFTAB outlist TOK_RIGHTAB
+                   {sprintf($$,"(/%s/)",$2);}
+      ;
+funarglist : beforefunctionuse    {strcpy($$," ");}
+      | beforefunctionuse funargs
+                   {strcpy($$,$2);}
+      ;
+funargs : funarg     {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | funargs ',' funarg
+                    {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      ;
+funarg : expr       {strcpy($$,$1);}
+      | triplet    {strcpy($$,$1);}
+      ;
+triplet : expr ':' expr
+                    {if ( couldaddvariable == 1 ) sprintf($$,"%s :%s",$1,$3);}
+      | expr ':' expr ':' expr
+                    {if ( couldaddvariable == 1 )
+                                               sprintf($$,"%s :%s :%s",$1,$3,$5);}
+      | ':' expr ':' expr
+                    {if ( couldaddvariable == 1 ) sprintf($$,":%s :%s",$2,$4);}
+      | ':' ':' expr{if ( couldaddvariable == 1 ) sprintf($$,": : %s",$3);}
+      | ':' expr    {if ( couldaddvariable == 1 ) sprintf($$,":%s",$2);}
+      | expr ':'    {if ( couldaddvariable == 1 ) sprintf($$,"%s :",$1);}
+      | ':'         {if ( couldaddvariable == 1 ) sprintf($$,":");}
+      ;
+ident : TOK_NAME    {
+                       if ( couldaddvariable == 1 )
+                       {
+                       if ( Vartonumber($1) == 1 )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if (!strcasecmp($1,"Agrif_Parent") )
+                                                            agrif_parentcall =1;
+                       if ( VariableIsNotFunction($1) == 0 )
+                       {
+                          if ( inagrifcallargument == 1 )
+                          {
+                             if ( !strcasecmp($1,identcopy) )
+                             {
+                                strcpy(sameagrifname,identcopy);
+                                sameagrifargument = 1;
+                             }
+                          }
+                          strcpy(identcopy,$1);
+                          pointedvar=0;
+                          strcpy(truename,$1);
+                          if (variscoupled_0($1)) strcpy(truename,getcoupledname_0($1));
+/*
+                          if ( VarIsNonGridDepend($1) == 0 &&
+                               Variableshouldberemove($1) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0($1) == 1 ||
+                                  varispointer_0($1) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0($1) == 0)
+                                 {
+                                 ModifyTheVariableName_0($1);
+                                 }
+                                 }
+                                 else
+                                 {
+                                 }
+                             }
+                             if (variscoupled_0($1) == 1)
+                             {
+      printf("mla variable %s est couplee %s\n",$1,getcoupledname_0($1));
+                             ModifyTheVariableNamecoupled_0($1,getcoupledname_0($1));
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1($1);
+                          }
+                          NotifyAgrifFunction_0($1);
+*/
+                          if ( VarIsNonGridDepend(truename) == 0 &&
+                               Variableshouldberemove(truename) == 0 )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0(truename) == 1 ||
+                                  varispointer_0(truename) == 1 )
+                             {
+                            if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1))
+                             {
+                              if (varistyped_0(truename) == 0)
+                                 {
+                                 ModifyTheVariableName_0(truename,strlen($1));
+                                 }
+                                 }
+                             }
+                             if ( inagrifcallargument != 1 ||
+                                  sameagrifargument ==1 )
+                                  Add_UsedInSubroutine_Var_1(truename);
+                          }
+                          NotifyAgrifFunction_0(truename);
+                       }
+                       }
+                    }
+      ;
+simple_const : TOK_TRUE
+                     {if ( couldaddvariable == 1 ) strcpy($$,".TRUE.");}
+      | TOK_FALSE    {if ( couldaddvariable == 1 ) strcpy($$,".FALSE.");}
+      | TOK_CSTINT   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | TOK_CSTREAL  {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | TOK_CSTREALDP{if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | TOK_CSTREALQP{if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | simple_const TOK_NAME
+                     {if ( couldaddvariable == 1 ) sprintf($$,"%s%s",$1,$2);}
+      | string_constant opt_substring
+      ;
+string_constant : TOK_CHAR_CONSTANT
+                     {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | string_constant TOK_CHAR_CONSTANT
+      | TOK_CHAR_MESSAGE
+                     {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | TOK_CHAR_CUT
+                     {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+opt_substring :      {if ( couldaddvariable == 1 ) strcpy($$," ");}
+      | substring   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+substring : '(' optexpr ':' optexpr ')'
+                    {if ( couldaddvariable == 1 ) sprintf($$,"(%s :%s)",$2,$4);}
+      ;
+optexpr :           {if ( couldaddvariable == 1 ) strcpy($$," ");}
+      | expr        {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+opt_expr : '\n'          {if ( couldaddvariable == 1 ) strcpy($$," ");}
+      | expr        {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+initial_value :      {InitialValueGiven = 0;}
+      | before_initial '=' expr
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                          strcpy(InitValue,$3);
+                          InitialValueGiven = 1;
+                       }
+                    }
+      ;
+before_initial : {pos_curinit = setposcur();}
+      ;
+complex_const : '(' uexpr ',' uexpr ')'
+                    {sprintf($$,"(%s,%s)",$2,$4);}
+      ;
+use_stat : word_use  module_name
+                    {
+                      if ( couldaddvariable == 1 )
+                      {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuse_0($2);
+                      }
+                      sprintf(charusemodule,"%s",$2);
+                      Add_NameOfModuleUsed_1($2);
+
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+      | word_use  module_name ',' rename_list
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                      if (insubroutinedeclare == 1)
+                      {
+                         Add_CouplePointed_Var_1($2,$4);
+                      }
+                      if ( firstpass == 1 )
+                      {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            coupletmp = $4;
+                            strcpy(ligne,"");
+                            while ( coupletmp )
+                            {
+                               strcat(ligne,coupletmp->c_namevar);
+                               strcat(ligne," => ");
+                               strcat(ligne,coupletmp->c_namepointedvar);
+                               coupletmp = coupletmp->suiv;
+                               if ( coupletmp ) strcat(ligne,",");
+                            }
+                            sprintf(charusemodule,"%s",$2);
+                         }
+                         Add_NameOfModuleUsed_1($2);
+                      }
+                      if ( inmoduledeclare == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curuse,
+                                               pos_end-pos_curuse);
+                      }
+                      }
+                    }
+      | word_use  module_name ',' TOK_ONLY ':' '\n'
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                      /* if variables has been declared in a subroutine       */
+                      if (insubroutinedeclare == 1)
+                      {
+                         copyuseonly_0($2);
+                      }
+                      sprintf(charusemodule,"%s",$2);
+                      Add_NameOfModuleUsed_1($2);
+
+                       if ( inmoduledeclare == 0 )
+                       {
+                          pos_end = setposcur();
+                          RemoveWordSET_0(fortranout,pos_curuse,
+                                                pos_end-pos_curuse);
+                       }
+                       }
+                    }
+      | word_use  module_name ',' TOK_ONLY ':' only_list
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if variables has been declared in a subroutine      */
+                       if (insubroutinedeclare == 1)
+                       {
+                          Add_CouplePointed_Var_1($2,$6);
+                       }
+                       if ( firstpass == 1 )
+                       {
+                         if ( insubroutinedeclare == 1 )
+                         {
+                             coupletmp = $6;
+                             strcpy(ligne,"");
+                             while ( coupletmp )
+                             {
+                                strcat(ligne,coupletmp->c_namevar);
+                               if ( strcasecmp(coupletmp->c_namepointedvar,"") )
+                                                           strcat(ligne," => ");
+                                strcat(ligne,coupletmp->c_namepointedvar);
+                                coupletmp = coupletmp->suiv;
+                                if ( coupletmp ) strcat(ligne,",");
+                             }
+                             sprintf(charusemodule,"%s",$2);
+                          }
+                          Add_NameOfModuleUsed_1($2);
+                       }
+                       if ( firstpass == 0 )
+                       {
+                          if ( inmoduledeclare == 0 )
+                          {
+
+                            pos_end = setposcur();
+                             RemoveWordSET_0(fortranout,pos_curuse,
+                                                   pos_end-pos_curuse);
+                       if (oldfortranout) 
+                         variableisglobalinmodule($6,$2,oldfortranout,pos_curuseold);
+                        
+                          }
+                          else
+                          {
+
+                             /* if we are in the module declare and if the    */
+                             /* onlylist is a list of global variable         */
+                             variableisglobalinmodule($6, $2, fortranout,pos_curuse);
+                          }
+                       }
+                       }
+                    }
+      ;
+word_use : TOK_USE
+                   {
+                      pos_curuse = setposcur()-strlen($1);
+                     if (firstpass == 0 && oldfortranout) {
+                     pos_curuseold = setposcurname(oldfortranout);
+                     }
+                   }
+      ;
+module_name : TOK_NAME
+                    {strcpy($$,$1);}
+      ;
+rename_list : rename_name
+                    {
+                       if ( couldaddvariable == 1 ) $$ = $1;
+                    }
+      | rename_list ',' rename_name
+                    {
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        $3->suiv = $1;
+                        $$ = $3;
+                        }
+                    }
+      ;
+rename_name : TOK_NAME TOK_POINT_TO TOK_NAME
+                    {
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,$1);
+                       Save_Length($1,21);
+                       strcpy(coupletmp->c_namepointedvar,$3);
+                       Save_Length($3,22);
+                       coupletmp->suiv = NULL;
+                       $$ = coupletmp;
+                     }
+      ;
+only_list : only_name
+                    {
+                       if ( couldaddvariable == 1 ) $$ = $1;
+                    }
+      | only_list ',' only_name
+                    {
+                        if ( couldaddvariable == 1 )
+                        {
+                        /* insert the variable in the list $1                 */
+                        $3->suiv = $1;
+                        $$ = $3;
+                        }
+                    }
+      ;
+only_name : TOK_NAME TOK_POINT_TO TOK_NAME
+                    {
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,$1);
+                       Save_Length($1,21);
+                       strcpy(coupletmp->c_namepointedvar,$3);
+                       Save_Length($3,22);
+                       coupletmp->suiv = NULL;
+                       $$ = coupletmp;
+                       pointedvar=1;
+                       Add_UsedInSubroutine_Var_1($1);
+                    }
+      | TOK_NAME    {
+                       coupletmp =(listcouple *)malloc(sizeof(listcouple));
+                       strcpy(coupletmp->c_namevar,$1);
+                       Save_Length($1,21);
+                       strcpy(coupletmp->c_namepointedvar,"");
+                       coupletmp->suiv = NULL;
+                       $$ = coupletmp;
+                     }
+      ;
+exec : iffable
+      | TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'
+                     {
+                         Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+      | TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'
+                     {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                         curmodulename);
+                                                         inallocate = 0;
+                     }
+      | TOK_NULLIFY '(' pointer_name_list ')'
+      | word_endunit /* end                                                   */
+                    {
+                       GlobalDeclaration = 0 ;
+                       if ( firstpass == 0 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                          if ( module_declar && insubroutinedeclare == 0 )
+                          {
+                              fclose(module_declar);
+                          }
+                       }
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       if ( inmodulemeet == 1 )
+                       {
+                         /* we are in a module                                */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                            /* it is like an end subroutine <name>            */
+                            insubroutinedeclare = 0 ;
+                            /*                                                */
+                            pos_cur = setposcur();
+                            closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                         }
+                         else
+                         {
+                            /* it is like an end module <name>                */
+                            inmoduledeclare = 0 ;
+                            inmodulemeet = 0 ;
+                         }
+                       }
+                       else
+                       {
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+                          pos_cur = setposcur();                        
+                          closeandcallsubloopandincludeit_0(2);
+                            functiondeclarationisdone = 0;
+                          if ( firstpass == 0 )
+                          {
+                             if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                             else fprintf(paramout,"C\n");
+                             fclose(paramout);
+                           }
+                        }
+                      }
+                      strcpy(subroutinename,"");
+                    }
+      | word_endprogram opt_name
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();                      
+                       closeandcallsubloopandincludeit_0(3);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+      | word_endsubroutine opt_name
+                    {
+                       if ( couldaddvariable == 1 &&
+                            strcasecmp(subroutinename,"") )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+                                             
+                       closeandcallsubloopandincludeit_0(1);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+      | word_endfunction opt_name
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                       insubroutinedeclare = 0;
+                       /*                                                     */
+                       pos_cur = setposcur();
+
+                       closeandcallsubloopandincludeit_0(0);
+                            functiondeclarationisdone = 0;
+                      if ( firstpass == 0 )
+                      {
+                         if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                         else fprintf(paramout,"C\n");
+                         fclose(paramout);
+                      }
+                      strcpy(subroutinename,"");
+                      }
+                    }
+      | TOK_ENDMODULE opt_name
+                    {
+                       if ( couldaddvariable == 1 )
+                       {
+                       /* if we never meet the contains keyword               */
+                      Remove_Word_end_module_0(strlen($2));
+                       if ( inmoduledeclare == 1 )
+                       {
+                          if ( aftercontainsdeclare == 0 )
+                          {
+                             Write_GlobalParameter_Declaration_0();
+                             Write_NotGridDepend_Declaration_0();
+                             Write_GlobalType_Declaration_0();
+                             Write_Alloc_Subroutine_For_End_0();
+                          }
+                       }
+                                           
+                       inmoduledeclare = 0 ;
+                       inmodulemeet = 0 ;
+
+                      Write_Word_end_module_0();
+                      strcpy(curmodulename,"");
+                      aftercontainsdeclare = 1;
+                      if ( firstpass == 0 )
+                      {
+                         if ( module_declar && insubroutinedeclare == 0)
+                         {
+                           fclose(module_declar);
+                         }
+                      }
+                      GlobalDeclaration = 0 ;
+                      }
+                  }
+      | boucledo
+      | logif iffable
+      | TOK_WHERE '(' expr ')' opt_expr
+      | TOK_ELSEWHERE
+      | TOK_ENDWHERE
+      | logif TOK_THEN
+      | TOK_ELSEIF  '(' expr ')' TOK_THEN
+      | TOK_ELSE
+      | TOK_ENDIF opt_name
+      | TOK_CASE caselist ')'
+      | TOK_SELECTCASE '(' expr ')'
+      | TOK_CASEDEFAULT
+      | TOK_ENDSELECT
+      | TOK_CONTAINS
+                   {
+                      if (inmoduledeclare == 1 )
+                      {
+                         Remove_Word_Contains_0();
+                         Write_GlobalParameter_Declaration_0();
+                         Write_GlobalType_Declaration_0();
+                         Write_NotGridDepend_Declaration_0();
+                         Write_Alloc_Subroutine_0();
+                         inmoduledeclare = 0 ;
+                         aftercontainsdeclare = 1;
+                      }
+                      else
+                      {
+                       if ( couldaddvariable == 1 )
+                       {
+                          if ( firstpass == 1 ) List_ContainsSubroutine =
+                                                Addtolistnom(subroutinename,
+                                                     List_ContainsSubroutine,0);
+                          insubroutinedeclare = 0;
+                          /*                                                  */
+
+                          closeandcallsubloop_contains_0();
+                            functiondeclarationisdone = 0;
+                         if ( firstpass == 0 )
+                         {
+                            if ( retour77 == 0 ) fprintf(paramout,"!\n");
+                            else fprintf(paramout,"C\n");
+                            fclose(paramout);
+                         }
+                         }
+                         strcpy(subroutinename,"");
+                      }
+                   }
+      ;
+word_endsubroutine : TOK_ENDSUBROUTINE
+                    {
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy($$,$1);
+                       pos_endsubroutine = setposcur()-strlen($1);
+                       functiondeclarationisdone = 0;
+                       }
+                    }
+      ;
+word_endunit : TOK_ENDUNIT
+                    {
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy($$,$1);
+                       pos_endsubroutine = setposcur()-strlen($1);
+                       }
+                    }
+      ;
+word_endprogram :  TOK_ENDPROGRAM
+                    {
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy($$,$1);
+                       pos_endsubroutine = setposcur()-strlen($1);
+                       }
+                    }
+      ;
+word_endfunction : TOK_ENDFUNCTION
+                    {
+                      if ( couldaddvariable == 1 )
+                      {
+                       strcpy($$,$1);
+                       pos_endsubroutine = setposcur()-strlen($1);
+                       }
+                    }
+      ;
+caselist : expr
+      | caselist ',' expr
+      | caselist ':' expr
+      ;
+boucledo : worddo opt_int do_arg
+      | wordwhile expr
+      | TOK_ENDDO optname
+      ;
+do_arg :
+      | do_var '=' expr ',' expr
+      | do_var '=' expr ',' expr ',' expr
+opt_int :
+      | TOK_CSTINT opt_comma
+      ;
+opt_name : '\n'  {strcpy($$,"");}
+      | TOK_NAME {strcpy($$,$1);}
+      ;
+optname :
+      | TOK_NAME
+      ;
+worddo :  TOK_PLAINDO
+      ;
+wordwhile :TOK_DOWHILE
+      ;
+
+dotarget :
+      | TOK_CSTINT
+      ;
+
+iffable : TOK_CONTINUE
+      | ident_dims after_ident_dims
+      | goto
+      | io
+      | call
+      | TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'
+                     {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+      | TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'
+                     {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                                                        inallocate = 0;
+                     }
+      | TOK_EXIT optexpr
+      | TOK_RETURN opt_expr
+      | TOK_CYCLE opt_expr
+      | stop opt_expr
+      | int_list
+      ;
+before_dims : {if ( couldaddvariable == 1 ) created_dimensionlist = 0;}
+ident_dims : ident before_dims dims dims
+              {
+                  created_dimensionlist = 1;
+                  if  ( agrif_parentcall == 1 )
+                  {
+                      ModifyTheAgrifFunction_0($3->dim.last);
+                      agrif_parentcall =0;
+                      fprintf(fortranout," = ");
+                  }
+              }
+      | ident_dims '%' ident before_dims dims dims
+      {created_dimensionlist = 1;}
+int_list : TOK_CSTINT
+      | int_list ',' TOK_CSTINT
+      ;
+after_ident_dims : '=' expr
+      | TOK_POINT_TO expr
+      ;
+call : keywordcall opt_call
+                   {
+                      inagrifcallargument = 0 ;
+                      incalldeclare=0;
+                      if ( oldfortranout &&
+                           !strcasecmp(meetagrifinitgrids,subroutinename) &&
+                           firstpass == 0 &&
+                           callmpiinit == 1)
+                      {
+                      /*   pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+                         fprintf(oldfortranout,"      Call MPI_Init (%s) \n"
+                                                                   ,mpiinitvar);*/
+                      }
+                      if ( oldfortranout           &&
+                           callagrifinitgrids == 1 &&
+                           firstpass == 0 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curcall,
+                                               pos_end-pos_curcall);
+
+                         strcpy(subofagrifinitgrids,subroutinename);
+                      }
+                      Instanciation_0(sameagrifname);
+                   }
+      ;
+opt_call :
+      | '(' opt_callarglist  ')'
+      ;
+opt_callarglist :
+      | callarglist
+      ;
+keywordcall : before_call TOK_NAME
+                    {
+                       if (!strcasecmp($2,"MPI_Init") )
+                       {
+                          callmpiinit = 1;
+                       }
+                       else
+                       {
+                          callmpiinit = 0;
+                       }
+                       if (!strcasecmp($2,"Agrif_Init_Grids") )
+                       {
+                          callagrifinitgrids = 1;
+                          strcpy(meetagrifinitgrids,subroutinename);
+                       }
+                       else callagrifinitgrids = 0;
+                       if ( !strcasecmp($2,"Agrif_Open_File") )
+                       {
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                       if ( Vartonumber($2) == 1 )
+                       {
+                          incalldeclare=1;
+                          inagrifcallargument = 1 ;
+                          Add_SubroutineWhereAgrifUsed_1(subroutinename,
+                                                        curmodulename);
+                       }
+                    }
+      ;
+before_call : TOK_CALL
+                    {pos_curcall=setposcur()-4;}
+callarglist :  callarg
+      | callarglist ',' callarg
+      ;
+
+callarg :  expr {
+                  if ( callmpiinit == 1 )
+                  {
+                     strcpy(mpiinitvar,$1);
+                     if ( firstpass == 1 )
+                     {
+                        Add_UsedInSubroutine_Var_1 (mpiinitvar);
+/*                        curvar=createvar($1,NULL);
+                        curlistvar=insertvar(NULL,curvar);
+                        List_Subr outineArgument_Var = AddListvarToListvar
+                         (curlistvar,List_SubroutineAr gument_Var,1);*/
+                     }
+                  }
+               }
+      | '*' label
+      ;
+
+stop : TOK_PAUSE
+      | TOK_STOP
+      ;
+
+io : iofctl ioctl
+      | read option_read
+      | write ioctl
+      | write ioctl outlist
+      | TOK_REWIND after_rewind
+      | TOK_FORMAT
+      ;
+opt_CHAR_INT :
+      | TOK_CSTINT TOK_NAME
+      ;
+idfile : '*'
+      | TOK_CSTINT
+      | ident
+      ;
+option_print :
+      | ',' outlist
+      ;
+option_inlist :
+      | inlist
+      ;
+option_read : ioctl option_inlist
+      | infmt opt_inlist
+      ;
+opt_outlist :
+      | outlist
+      ;
+opt_inlist :
+      | ',' inlist
+      ;
+ioctl :  '(' ctllist ')'
+      | '(' fexpr ')'
+      ;
+after_rewind :  '(' ident ')'
+      | '(' TOK_CSTINT ')'
+      | TOK_CSTINT
+      | '(' uexpr ')'
+      | TOK_NAME
+      ;
+ctllist : ioclause
+      | ctllist ',' ioclause
+      ;
+ioclause : fexpr
+      | '*'
+      | TOK_DASTER
+      | TOK_NAME expr
+      | TOK_NAME expr '%' ident_dims
+      | TOK_NAME '(' triplet ')'
+      | TOK_NAME '*'
+      | TOK_NAME TOK_DASTER
+      ;
+iofctl : TOK_OPEN
+      | TOK_CLOSE
+      ;
+infmt :  unpar_fexpr
+      | '*'
+      ;
+
+read :TOK_READ
+      | TOK_INQUIRE
+      | TOK_PRINT
+      ;
+
+write : TOK_WRITE
+      ;
+
+fexpr : unpar_fexpr
+      | '(' fexpr ')'
+      ;
+unpar_fexpr : lhs
+      | simple_const
+      | fexpr addop fexpr %prec '+'
+      | fexpr '*' fexpr
+      | fexpr TOK_SLASH fexpr
+      | fexpr TOK_DASTER fexpr
+      | addop fexpr %prec '*'
+      | fexpr TOK_DSLASH fexpr
+      | TOK_FILE expr
+      | TOK_EXIST expr
+      | TOK_ERR expr
+      | TOK_END expr
+      | TOK_NAME '=' expr
+      ;
+addop : '+'
+      | '-'
+      ;
+inlist : inelt
+      | inlist ',' inelt
+      ;
+opt_lhs :
+      | lhs
+      ;
+inelt : opt_lhs opt_operation
+      | '(' inlist ')' opt_operation
+      | predefinedfunction opt_operation
+      | simple_const opt_operation
+      | '(' inlist ',' dospec ')'
+      ;
+opt_operation :
+      | operation
+      | opt_operation operation
+      ;
+outlist : uexpr    {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | other      {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | out2       {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+out2: uexpr ',' expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | uexpr ',' other
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | other ',' expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | other ',' other
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | out2 ',' expr
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | out2 ',' other
+                   {if ( couldaddvariable == 1 ) sprintf($$,"%s,%s",$1,$3);}
+      | uexpr     {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | predefinedfunction {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      ;
+other :  complex_const
+                   {if ( couldaddvariable == 1 ) strcpy($$,$1);}
+      | '(' expr ')'
+                   {if ( couldaddvariable == 1 ) sprintf($$," (%s)",$2);}
+      | '(' uexpr ',' dospec ')'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"(%s,%s)",$2,$4);}
+      | '(' other ',' dospec ')'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"(%s,%s)",$2,$4);}
+      | '(' out2 ',' dospec ')'
+                   {if ( couldaddvariable == 1 ) sprintf($$,"(%s,%s)",$2,$4);}
+      ;
+
+dospec : TOK_NAME '=' expr ',' expr
+                   {if ( couldaddvariable == 1 )
+                                              sprintf($$,"%s=%s,%s)",$1,$3,$5);}
+      | TOK_NAME '=' expr ',' expr ',' expr
+                   {if ( couldaddvariable == 1 )
+                                        sprintf($$,"%s=%s,%s,%s)",$1,$3,$5,$7);}
+      ;
+labellist : label
+      | labellist ',' label
+      ;
+label : TOK_CSTINT
+      ;
+goto : TOK_PLAINGOTO '(' expr ',' expr ')' ',' expr
+      | TOK_PLAINGOTO label
+      ;
+allocation_list : allocate_object
+      | ident_dims
+      | allocation_list ',' allocate_object
+      ;
+allocate_object : ident
+                   {Add_Allocate_Var_1($1,curmodulename);}
+      | structure_component
+      | array_element
+      ;
+array_element : ident '(' funargs ')'
+                   {Add_Allocate_Var_1($1,curmodulename);}
+      ;
+subscript_list : expr
+      | subscript_list ',' expr
+      ;
+
+allocate_object_list :allocate_object
+      | allocate_object_list ',' allocate_object
+      ;
+opt_stat_spec :
+      | ',' TOK_STAT '=' ident
+      ;
+pointer_name_list : ident
+      | pointer_name_list ',' ident
+      ;
+opt_construct_name :
+      | TOK_NAME
+      ;
+opt_construct_name_colon :
+      | TOK_CONSTRUCTID ':'
+      ;
+logif : TOK_LOGICALIF expr ')'
+      ;
+do_var : ident {strcpy($$,$1);}
+      ;
+%%
+
+void processfortran(char *fichier_entree)
+{
+   extern FILE *fortranin;
+   extern FILE *fortranout;
+   char nomfile[LONG_C];
+   int c;
+   int confirmyes;
+
+   /*fortrandebug = 1;*/
+   if ( mark == 1 ) printf("Firstpass == %d \n",firstpass);
+/******************************************************************************/
+/*  1-  Open input and output files                                           */
+/******************************************************************************/
+   strcpy(nomfile,commondirin);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   fortranin=fopen( nomfile,"r");
+   if (! fortranin)
+   {
+      printf("Error : File %s does not exist\n",nomfile);
+      exit(1);
+   }
+
+   strcpy(curfile,nomfile);
+   strcpy(nomfile,commondirout);
+   strcat(nomfile,"/");
+   strcat(nomfile,fichier_entree);
+   strcpy(nomfileoutput,nomfile);
+   Save_Length(nomfileoutput,31);
+   if (firstpass == 1)
+   {
+      if (checkexistcommon == 1)
+      {
+         if (fopen(nomfile,"r"))
+         {
+            printf("Warning : file %s already exist\n",nomfile);
+            confirmyes = 0;
+            while (confirmyes==0)
+            {
+               printf("Override file %s ? [Y/N]\n",nomfile);
+               c=getchar();
+               getchar();
+               if (c==79 || c==110)
+               {
+                  printf("We stop\n");
+                  exit(1);
+               }
+               if (c==89 || c==121)
+               {
+                  confirmyes=1;
+               }
+            }
+         }
+      }
+   }
+
+/******************************************************************************/
+/*  2-  Variables initialization                                              */
+/******************************************************************************/
+
+   line_num_fortran_common=1;
+   line_num_fortran=1;
+   PublicDeclare = 0;
+   PrivateDeclare = 0;
+   ExternalDeclare = 0;
+   SaveDeclare = 0;
+   pointerdeclare = 0;
+   optionaldeclare = 0;
+   incalldeclare = 0;
+   VarType = 0;
+   VarTypepar = 0;
+   Allocatabledeclare = 0 ;
+   strcpy(NamePrecision," ");
+   VariableIsParameter =  0 ;
+   strcpy(NamePrecision,"");
+   c_star = 0 ;
+   functiondeclarationisdone = 0;
+   insubroutinedeclare = 0 ;
+   strcpy(subroutinename," ");
+   InitialValueGiven = 0 ;
+   strcpy(EmptyChar," ");
+   inmoduledeclare = 0;
+   colnum=0;
+   incom=0;
+   couldaddvariable=1;
+   aftercontainsdeclare = 1;
+   strcpy(nameinttypename,"");
+   /* Name of the file without format                                         */
+   tmp = strchr(fichier_entree, '.');
+   strncpy(curfilename,fichier_entree,strlen(fichier_entree)-strlen(tmp));
+   Save_Length(curfilename,30);
+/******************************************************************************/
+/*  3-  Parsing of the input file (1 time)                                    */
+/******************************************************************************/
+   if (firstpass == 0 )
+   {
+      fortranout=fopen(nomfileoutput,"w");
+
+      NewModule_Creation_0();
+   }
+
+   fortranparse();
+
+   strcpy(curfile,mainfile);
+
+   if (firstpass == 0 ) fclose(fortranout);
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.yy.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.yy.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/fortran.yy.c	(revision 1844)
@@ -0,0 +1,3843 @@
+#define yy_create_buffer fortran_create_buffer
+#define yy_delete_buffer fortran_delete_buffer
+#define yy_scan_buffer fortran_scan_buffer
+#define yy_scan_string fortran_scan_string
+#define yy_scan_bytes fortran_scan_bytes
+#define yy_flex_debug fortran_flex_debug
+#define yy_init_buffer fortran_init_buffer
+#define yy_flush_buffer fortran_flush_buffer
+#define yy_load_buffer_state fortran_load_buffer_state
+#define yy_switch_to_buffer fortran_switch_to_buffer
+#define yyin fortranin
+#define yyleng fortranleng
+#define yylex fortranlex
+#define yyout fortranout
+#define yyrestart fortranrestart
+#define yytext fortrantext
+#define yywrap fortranwrap
+
+#line 20 "fortran.yy.c"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		yyless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		*yy_cp = yy_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+	{
+	FILE *yy_input_file;
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via yyrestart()), so that the user can continue scanning by
+	 * just pointing yyin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	yytext_ptr = yy_bp; \
+	yyleng = (int) (yy_cp - yy_bp); \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 173
+#define YY_END_OF_BUFFER 174
+static yyconst short int yy_accept[1124] =
+    {   0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,  174,  173,  163,  159,  162,  172,  151,  150,
+      153,  165,  151,  153,  153,  155,  152,  138,  149,  154,
+      157,  156,  158,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  163,  159,  162,  172,  149,  144,  144,  144,  144,
+      144,  173,  173,  170,  173,  153,  144,    0,    0,  163,
+      164,    0,  162,  172,  172,  172,    0,  142,    0,    0,
+      165,  165,  165,  165,    0,    0,    0,  141,    0,    0,
+      133,   25,    0,  145,    0,    0,    0,    0,    0,    0,
+
+        0,  134,    0,  149,   24,    0,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,   42,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,   84,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  163,  161,    0,  161,    0,    0,
+        0,    0,    0,  164,  160,  161,    0,  172,  171,  172,
+      172,  172,  161,  149,    4,  144,  144,  144,  144,  144,
+      144,    0,  170,    0,    0,    0,  167,   25,    0,    0,
+
+        4,    0,  144,  144,  144,  144,  144,  144,    0,    0,
+        0,  172,  172,    0,    0,  165,  165,    0,    0,    0,
+        0,  140,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,  148,  145,    0,
+        0,    0,  143,    0,  144,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  114,  144,  144,
+      144,    0,  144,  144,  144,  144,  144,   15,  144,  144,
+      144,  113,  144,  144,  144,  144,  144,    0,  144,    0,
+       95,  144,  144,  144,  144,  144,  120,  144,  144,  125,
+      144,  144,  144,  144,  144,  144,   88,  144,  144,  144,
+
+      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
+      144,  117,  144,  144,  144,  144,  144,  121,  144,  144,
+      144,  144,  144,  163,  161,    0,  164,    0,    0,    0,
+        0,    0,    0,    0,  161,    0,  161,  172,  172,  172,
+      149,    4,    4,    4,    4,  144,  144,  144,  144,  144,
+      144,    0,    0,    0,  167,    0,    0,    4,    4,    4,
+        4,  143,    0,  144,  144,    0,  144,  144,  144,  144,
+        0,    0,    0,  172,  172,    0,    0,  165,  165,    0,
+        0,    0,    0,  146,    0,  145,    0,  147,    0,   27,
+        0,   29,   28,   31,   30,   33,    0,    0,   35,    0,
+
+      145,    0,  146,    0,  145,    0,  147,    0,  143,    0,
+      144,  144,  124,  116,  144,  119,  122,  144,   21,  144,
+      144,  144,  144,  144,  115,  144,  144,  144,    0,  144,
+      144,  144,   93,    0,  107,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,    0,  108,  144,  144,  144,  144,
+      144,  144,  144,    0,   87,  144,  144,  144,  144,  144,
+      144,  144,    0,   97,  144,  144,    0,  110,  144,  144,
+      144,  144,  111,   20,   59,   73,  144,  144,  144,  144,
+      144,  144,  144,  144,   78,   43,  144,  144,  144,  144,
+       68,  144,  126,  118,  144,   71,   53,  144,    0,   96,
+
+       98,  144,   91,  100,  144,  144,  163,  161,  164,    0,
+        0,    0,    0,    0,    0,  161,    0,  161,  172,  172,
+      172,  149,    4,    4,  144,  144,  144,  144,  144,   17,
+        0,    0,    0,    4,    4,    0,  143,    0,  144,  144,
+      144,  144,    0,    0,    0,  172,  172,    0,    0,  165,
+      165,    0,    0,   37,   26,    0,   34,   36,    0,  143,
+        0,  143,  144,  144,  144,  144,  144,   48,  144,  144,
+      144,  123,  144,  144,    0,  144,  144,  144,    0,  144,
+      144,    0,    0,    0,    0,    0,    0,    0,    0,   41,
+      144,   94,  144,  144,  144,  144,  144,  144,  144,  144,
+
+      144,   75,   75,   75,   75,  144,    0,  106,  112,  144,
+      144,   87,  144,  144,   89,  144,  144,  144,  144,  144,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,   51,
+      144,   76,  144,  144,  144,    0,  144,  144,  144,  144,
+      144,  101,  144,  144,   54,   80,  163,  161,  164,    0,
+        0,    0,    0,    0,  161,    0,  161,  172,  172,  172,
+      149,    4,    3,    0,  103,  144,  144,   85,  144,   69,
+       70,   69,    0,    0,    0,    4,    3,    0,  143,    0,
+      143,  144,   48,  144,  123,    0,   22,    0,  172,   22,
+        0,   22,   22,  165,   22,    0,   22,   22,   22,   32,
+
+      144,   22,   22,   22,  144,  144,  144,   62,  144,  144,
+      144,  144,    0,  144,  144,  139,    0,    0,   92,  144,
+       41,    0,   94,    0,    0,    0,    0,    0,    0,    0,
+      144,  144,  144,  144,  144,  144,  144,  144,  144,    0,
+      109,  144,  144,  144,  144,  144,  144,  144,   65,  144,
+      144,  144,  128,   99,  127,  129,   38,  144,  144,  144,
+      144,  144,  144,   82,    0,  144,   10,   74,   18,  144,
+      144,   81,  163,  161,  164,    0,    0,    0,  161,  172,
+      172,   22,    4,    3,    3,  144,  144,  144,    0,    0,
+       22,    4,    3,    3,  144,   22,   22,   22,   23,  166,
+
+       23,   23,   23,   23,   23,   23,   23,   23,   23,   23,
+      144,  144,  144,   57,  144,  144,  144,    0,    0,  144,
+      144,   39,   92,    0,  144,    0,    0,    0,    0,    0,
+        0,    0,    0,  144,  144,  144,  144,  144,  144,   72,
+      144,  144,  144,    0,    0,  144,  144,   16,   49,   44,
+      144,  144,   45,    0,  144,  144,  144,  144,   66,   83,
+        7,    0,    0,  144,    0,  144,  144,    0,    0,    0,
+      172,   23,    4,  144,  144,   63,    0,   23,    4,   23,
+       23,   23,  144,    8,  144,  144,   86,  144,  144,   39,
+        0,    0,  144,  144,    0,  144,    0,    0,    0,    0,
+
+        0,    0,   72,    0,  144,  144,  144,  144,  144,  144,
+       55,  144,   64,    0,    0,    0,  135,   11,   19,  144,
+      144,    0,  144,   79,   67,  144,    0,  144,    0,  144,
+      144,    0,    0,  172,    4,  144,   58,    0,    4,  144,
+      131,   46,  144,   50,    0,    0,  144,  144,    0,   56,
+        0,    0,    0,    0,    0,    0,   55,  144,  144,   40,
+      144,  105,  144,  144,    0,    0,    0,    0,  135,  130,
+       90,    0,  144,   60,    0,   61,    0,  144,  144,    0,
+       58,  172,    4,    4,  144,    0,    4,    4,  144,    9,
+        0,    0,  144,  144,   56,    0,    0,   40,    0,  105,
+
+        0,  144,  144,   13,  144,  144,    0,    0,    0,  144,
+        0,    0,  102,    6,    0,  172,    4,    4,  144,    0,
+        4,    4,   47,    0,    0,  144,  144,    0,    0,   13,
+        0,   14,  144,  144,   52,    0,    0,    0,  144,    0,
+      102,    0,  172,    4,    2,  104,    0,    4,    2,    0,
+        0,  144,  144,   14,    0,    0,  132,  144,    0,    0,
+        0,  144,    0,  104,  172,    4,    0,    4,    0,    0,
+      137,  144,  132,    0,   12,    0,    0,    0,  144,    0,
+      172,    1,    0,    1,  137,    0,  144,   12,    0,    0,
+        0,  144,    0,  172,    0,    0,  136,    0,    0,    0,
+
+       77,    5,  172,    0,  136,   77,  172,    0,  172,    0,
+      172,    0,  172,    0,  172,    0,  168,    0,    0,    0,
+        0,  169,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    4,    5,    6,    7,    8,    9,   10,   11,   12,
+       13,   14,   15,   16,   17,   18,   19,   20,   21,   22,
+       23,   24,   25,   26,   27,   28,   20,   29,   30,   31,
+       32,   33,    1,    1,   37,   38,   39,   40,   41,   42,
+       43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
+       53,   54,   55,   56,   57,   58,   59,   60,   61,   62,
+       34,    1,   35,    1,   36,    1,   37,   38,   39,   40,
+
+       41,   42,   43,   44,   45,   46,   47,   48,   49,   50,
+       51,   52,   53,   54,   55,   56,   57,   58,   59,   60,
+       61,   62,   63,   63,   63,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[64] =
+    {   0,
+        1,    2,    3,    4,    1,    5,    1,    1,    1,    6,
+        1,    1,    1,    1,    7,    1,    7,    8,    1,    9,
+        9,    9,    9,    9,    9,    9,    9,    9,    1,    1,
+        1,    1,    1,    1,    1,   10,   11,   10,   10,   12,
+       13,   14,   15,   16,   10,   10,   10,   15,   15,   15,
+       11,   10,   12,   15,   15,   14,   15,   10,   17,   10,
+       10,   10,    5
+    } ;
+
+static yyconst short int yy_base[1180] =
+    {   0,
+        0,   62,    0,    0,    0,    0, 4185,   65,    0,   55,
+        0,    0, 4187,   35,   69,   70,   74,   37,   75,   50,
+       53,   72,   93,   78,   66,   56,  148,   87,   81,   65,
+       68,   99,   71,  191,  230,  108,  183,  225,  244,  103,
+      137,  152,  185,  250,  265,  262,  281,  220,  286,  296,
+      308,  368,  134,  424,  321,  350,  149, 4149,  310,  337,
+      270, 4189, 4182, 4189,  158,  380,  481, 4147, 4129,  138,
+      163,  175,  179,    0, 4145, 4127, 4174, 4189,  147,  133,
+     4176, 4175,  192,  156,  232,  393,  376, 4189,  402,  406,
+     4189, 4189,  543,  184, 4127, 4123,  204,  218,  226, 4121,
+
+     4123, 4189,  584,  358, 4189,  448,  532,  507,  514,  572,
+      534,  588,  593,  605,  617,  381,  242,  169,  195,  404,
+      384,  312,  517,  672,  524,  378,  403,  544,  365,  630,
+      597,  545,  424,  565,  651,  679,  425,  650,  626,  648,
+      672,  673,  603,  674,  680,  684,  698,  686,  699,  704,
+      706,  584,  707,  710,  711,  730,  683,  297,  732,  735,
+      734,  737,  742,  750,  788,  795, 4170,  389,  316, 4135,
+     4123,   72, 4115,  807, 4189,  863,  427, 4166, 4189,  225,
+      327,  543,  632,  660,  804,  765,  799,  770,  764,  785,
+      788, 4165, 4189,  343, 4164,  774, 4189, 4163,  820,  564,
+
+      856,  918,  946, 4147,  271,  661,  187,  270, 4116, 4106,
+      812, 4114, 4104,  547,  804,  617,  398,  859,  894,  906,
+      868, 4189,  889,  871,  815,  860,  896, 4120,  372, 4141,
+     4140, 4139, 4138,  275, 4099, 4136, 4099, 4189,  874,  907,
+      908,  914, 4111, 4110,  864,  973,  999,  977,  975,  983,
+      984,  981, 1002,  986,  987, 1006, 1007, 1008, 1011, 1020,
+     1010, 4091,  737, 1029, 1032, 1017, 1036, 1089, 1033, 1078,
+     1042, 1035, 1047, 1058, 1038, 1057, 1063, 1101, 1071, 1013,
+     4189, 1070, 1079, 1082, 1083, 1105, 1110, 1148, 1149, 1112,
+     1117, 1119, 1126, 1128, 1133, 1139, 1076, 1125, 1137, 1140,
+
+     1151, 1161, 1162, 1171, 1163, 1175, 1176, 1177, 1186, 1187,
+     1184, 1198, 1189, 1199, 1202, 1141, 1245, 1207, 1221, 1209,
+     1211, 1213, 1225, 1264, 1283, 4088, 1290, 4145, 4092, 4096,
+     4089, 4093, 4091, 4101, 1346,  715,  922,  557, 1120,  837,
+     1266,    0,  931, 4098, 4091, 1236, 1235, 1243, 1264, 1271,
+     1274,  800, 4020, 1311, 4189, 1268,  873, 4003, 1332, 1295,
+     1132, 1401, 1440,    0, 3971, 1479,  697,  659,  815,  998,
+     3883, 3892,  932, 3876, 3823, 1231,  551,  561, 1302, 1321,
+     1342, 1351, 1355, 1385, 1410, 1424, 1449, 1463, 3829, 4189,
+     3812, 4189, 4189, 4189, 4189, 4189, 3767, 3805, 4189, 3802,
+
+     1347, 1488, 1497, 1506, 1515, 1524, 1533, 1302, 3778, 1327,
+     1304, 1525, 4189, 1273, 1362, 1361, 1402, 1403, 1441, 1442,
+     1526, 1443, 1527, 1528, 1531, 1533, 1535, 1534, 3773, 1549,
+     1553, 1539, 1597, 1655, 4189, 1541, 1554, 1563, 1565, 1567,
+     1569, 1575, 1578, 1577, 1361, 4189, 1583, 1714, 1587, 1623,
+     1591, 1596, 1607, 3762, 1611, 1617, 1612, 1616, 1630, 1631,
+     1645, 1639, 1684, 4189, 1652, 1654, 1690, 4189, 1741, 1672,
+     1742, 1743, 1744, 1745, 1746, 1747, 1751, 1757, 1766, 1756,
+     1767, 1771, 1772, 1777, 1776, 1801, 1779, 1780, 1781, 1782,
+     1787, 1790, 1800, 1802, 1828, 1805, 1806, 1810, 1846, 4189,
+
+     1808, 1812, 1809, 1814, 1830, 1832, 1870, 1885, 1892, 3770,
+     3752, 3770, 3767, 3761, 3797, 1948, 1009, 1380, 1303,  663,
+     1414, 1873, 3746, 3747, 1903, 1863, 1902, 1839, 1943, 3794,
+     1306, 1438, 1451, 1849, 1566, 2003, 2029, 2068, 1591,  424,
+     1063, 1373, 3756,    0, 1392, 3755,    0,  815, 3788, 1875,
+     3790, 1919, 1702, 4189, 4189, 3774, 4189, 4189, 1987, 2013,
+     2038, 2052, 1844, 2096, 1864, 1882, 1884, 1883, 1927, 1924,
+     1929, 1909, 1945, 1930, 3746, 1949, 2123, 2124, 2160, 2045,
+     2126, 3738, 3728, 1588, 3733, 3680, 1623, 3668, 3683, 1963,
+     2129, 1965, 2030, 2132, 2130, 2128, 2136, 2148, 2150, 2138,
+
+     2191, 4189, 2186, 2178, 2162, 2180, 1990, 4189, 2164, 2166,
+     2184, 4189, 2187, 2196, 2188, 2190, 2194, 2200, 2209, 2203,
+     2206, 2210, 2218, 2222, 2221, 2230, 2225, 2228, 2236, 2231,
+     2246, 2237, 2243, 2244, 2249, 3696, 2252, 2255, 2258, 2256,
+     2264, 4189, 2265, 2267, 2276, 2277, 2322, 2331, 2341, 2313,
+     3686, 1416, 3684, 2336, 2397, 1449, 1648, 1854, 2040, 3697,
+     2324, 3654, 1783, 2335, 4189, 2313, 2312, 1910, 2335, 2392,
+     4189, 2389, 2194, 2341, 3693, 2249, 2042, 2452, 2478, 2504,
+     2530, 1870, 3675, 2558, 3672,    0, 4189, 2615,    0,    0,
+     3677, 3676, 4189, 3659, 3654, 2353, 2366, 2400, 4189, 4189,
+
+     2643, 2392, 2355, 2331, 2369, 2384, 2385, 2389, 2390, 2391,
+     2392, 2397, 3580, 2431, 2415, 2393, 3585, 3582, 2395, 2430,
+     4189, 3575, 4189, 3566, 3580, 3539, 3541, 3550, 3535, 3495,
+     2454, 2455, 2457, 2480, 2481, 2428, 2670, 2458, 2671, 2455,
+     4189, 2482, 2708, 2672, 2676, 2677, 2692, 2483, 2484, 2678,
+     2680, 2690, 2685, 2699, 2700, 2703, 2739, 2705, 2710, 2711,
+     2712, 2714, 2721, 2715, 2537, 2726, 2719, 2724, 2735, 2775,
+     2744, 2745, 2781, 2792, 2801, 3478, 3436, 3432,    0, 1637,
+     3476, 3475, 3435,    0, 1991, 2750, 2772, 2806, 1959, 3473,
+     3472, 2313, 3471, 2356, 2860, 2921,    0, 3455, 4189, 4189,
+
+        0, 3466, 4189, 3468, 2537, 2621, 4189, 2905, 2793, 2747,
+     2782, 2779, 2805, 2753, 2897, 2780, 2802, 3429, 2458, 2899,
+     2791, 2898, 4189, 3428, 2900, 3429, 3426, 3409, 3422, 3423,
+     3409, 3421, 3407, 2902, 2903, 2918, 2922, 2923, 2924, 2926,
+     2927, 2928, 2936, 2981, 2976, 2937, 2951, 2955, 2957, 2958,
+     2959, 2963, 2960, 2997, 2965, 2966, 2967, 2969, 2979, 2981,
+     2987, 3024, 3423, 2988, 2811, 2990, 2993, 3417, 3407, 2459,
+     2510, 3453, 3419, 2994, 2997, 2462, 3026, 3448, 3029, 3063,
+        0, 3426, 3002, 3000, 3016, 3006, 3013, 3018, 3021, 4189,
+     3389, 3309, 3024, 3022, 3272, 3027, 3215, 3209, 3187, 3150,
+
+     3134, 3029, 4189, 3004, 3055, 3040, 3056, 3042, 3058, 3061,
+     3062, 3067, 3065, 3098, 2484, 3110, 3119, 3070, 3088, 3089,
+     3094, 2917, 3090, 3091, 3097, 3098, 2953, 3099, 2930, 3100,
+     3109, 2818, 2796, 2785, 2502, 3110, 3102, 2383, 3135, 3112,
+     3120, 3124, 3128, 3125, 2746, 2687, 3131, 3133, 2605, 3134,
+     2590, 2592, 2586, 2479, 2459, 2433, 4189, 3139, 3143, 3144,
+     3147, 3149, 3152, 3155, 2541, 3192, 3208, 3204, 3210, 3162,
+     3178, 2438, 3185, 3182, 2414, 3188, 2340, 3189, 3190, 2333,
+     4189, 2018, 2288, 2260, 3192,  112, 3197, 3188, 3200, 3191,
+     2137, 2149, 3210, 3211, 4189, 2017, 2011, 4189, 1998, 4189,
+
+     1986, 3212, 3213, 3197, 3216, 3218, 2624, 3271, 1977, 3239,
+     1982, 1903, 3223, 3231, 1885, 3254, 1854, 1829, 3232, 3066,
+     1951, 1593, 3241, 1822, 1744, 3242, 3245, 1736, 1662, 4189,
+     1653, 3250, 3257, 3252, 3254, 2850, 3310, 1642, 3270, 1622,
+     4189, 1521, 3100, 1441,    0, 3255, 3294, 1280, 1416, 1354,
+     1309, 3268, 3280, 4189, 1314, 1246, 3264, 3278, 3325, 3333,
+     1178, 3284, 1155, 4189, 3300, 1072, 3313, 2771, 1054, 1064,
+     3294, 3296, 4189, 1044, 3302, 3350, 3377,  992, 3305,  960,
+     3102,    0, 3337,  892, 4189,  829, 3312, 4189, 3342, 3388,
+      696, 3345,  555, 3358, 3364,  406, 3367, 3414, 3415,  348,
+
+     3368, 4189, 3341, 3380, 4189, 4189, 3366, 3381, 3351, 3367,
+     2713, 3390, 3382, 3386,  281, 3404, 4189, 3405, 3416, 3426,
+      177, 4189, 4189, 3482, 3499, 3516, 3533, 3550, 3567, 3577,
+     3584, 3601, 3615, 3629, 3646, 3663, 3672, 3685, 3702, 3716,
+     3722, 3731, 3748, 3765, 3424, 3427, 3428, 3774, 3432, 3436,
+     3440,  362, 2185, 3786, 3800, 3806, 3441, 3445, 3812, 3818,
+     3827, 3844, 3861, 3878, 3895, 3912, 3926, 3935, 3952, 3969,
+     3986, 4003, 4020, 4037, 4054, 4071, 4088, 4105, 4122
+    } ;
+
+static yyconst short int yy_def[1180] =
+    {   0,
+     1123,    1, 1124, 1124,    1,    2, 1125, 1125,    1,    2,
+        1,    2, 1123, 1123, 1123, 1123, 1123, 1126, 1127, 1123,
+     1123, 1128, 1129, 1123, 1123, 1123, 1123, 1123, 1130, 1123,
+     1123, 1123, 1123, 1131, 1131,   35,   35,   35,   35,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   37,
+       37, 1123, 1123, 1123, 1132, 1133,   37,   38,   38,   37,
+       38, 1123, 1134, 1123, 1134, 1135, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1126, 1126, 1126, 1127, 1123, 1127, 1127,
+     1128, 1123, 1128, 1128, 1129, 1136, 1129, 1123, 1129, 1129,
+     1123, 1123, 1123, 1137, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1138, 1130, 1123, 1123,   38,   38,   38,   38,
+       38,   38,   35,   38,   38,  115,  115,  115,  115,  115,
+      115,  115,  115, 1131,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1123, 1139, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1140, 1132, 1123, 1132,
+     1132, 1132, 1140, 1141, 1142,  115,  115,  115,  115,  115,
+      115, 1134, 1123, 1134, 1143, 1143, 1123, 1143, 1143, 1143,
+
+     1144, 1143, 1123,  203,  203,  203,  203,  203, 1123, 1123,
+     1123, 1126, 1126, 1127, 1127, 1128, 1128, 1136, 1136, 1136,
+     1136, 1123, 1129, 1129, 1145, 1146, 1147, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1148, 1149,
+     1150, 1151, 1152, 1153,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115, 1154,  124,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115, 1123,  115, 1123,
+     1123,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123, 1123, 1123, 1123, 1139, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1155, 1155, 1132, 1132, 1132,
+     1156, 1142, 1142, 1142, 1142,  115,  115,  115,  115,  115,
+      115, 1134, 1143, 1143, 1123, 1143, 1143, 1144, 1144, 1144,
+     1144, 1143, 1143,  203,  203, 1143,  203,  203,  203,  203,
+     1123, 1123, 1123, 1126, 1126, 1127, 1127, 1128, 1128, 1136,
+     1129, 1129, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1148, 1123, 1123, 1123, 1123, 1123, 1123, 1157, 1153, 1158,
+      115,  115, 1123,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115, 1123,  115,
+      115,  115,  115, 1123, 1123,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1123,  115, 1123,  115,  115,
+      115,  115,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115, 1123, 1123,  115,  115, 1123, 1123,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115, 1123, 1123,
+
+      115,  115,  115,  115,  115,  115, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1159, 1159, 1132, 1132,
+     1132, 1160, 1142, 1142,  115,  115,  115,  115,  115, 1123,
+     1134, 1143, 1143, 1144, 1144, 1143, 1143, 1143,  203,  203,
+      203,  203, 1123, 1161, 1123, 1126, 1162, 1127, 1163, 1128,
+     1164, 1129, 1165, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123,  115,  115,  115, 1123,  115,
+      115, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+
+      115, 1123, 1123,  115,  115,  115, 1123, 1123,  115,  115,
+      115, 1123,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115, 1123,  115,  115,  115,  115,
+      115, 1123,  115,  115,  115,  115, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1132, 1132, 1166,
+     1167, 1142, 1168, 1123, 1123,  115,  115, 1123,  115, 1123,
+     1123, 1123, 1134, 1143, 1169, 1144, 1170, 1143, 1143, 1143,
+     1143,  203,  203, 1123,  203, 1171, 1123, 1123, 1172, 1126,
+     1173, 1127, 1123, 1174, 1128, 1175, 1129, 1129, 1123, 1123,
+
+     1123, 1123,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115, 1123,  115,  115,  115, 1123, 1123,  115,  115,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+      115,  115,  115,  115,  115,  115,  115,  115,  115, 1123,
+     1123,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115, 1123,  115,  115,  115,  115,  115,
+      115,  115, 1123, 1123, 1123, 1123, 1123, 1123,  655, 1132,
+     1176, 1132, 1142, 1168, 1168,  115,  115,  115, 1134, 1177,
+     1143, 1144, 1170, 1170, 1123, 1143,  203,  203, 1123, 1123,
+
+     1126, 1127, 1123, 1128, 1129, 1129, 1123, 1123,  115,  115,
+      115,  115,  115,  115,  115,  115,  115, 1123, 1123,  115,
+      115,  115, 1123, 1123,  115, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123, 1178,  115,  115,  115,  115,  115,
+      115,  115,  115, 1123,  115,  115,  115,  115,  115,  115,
+      115, 1123, 1123,  115, 1123,  115,  115, 1123, 1123, 1123,
+     1132, 1132, 1142,  115,  115, 1123, 1134, 1143, 1144, 1143,
+      203,  203,  115,  115,  115,  115,  115,  115,  115, 1123,
+     1123, 1123,  115,  115, 1123,  115, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123,  115,  115,  115,  115,  115,  115,
+      115,  115,  115, 1178, 1123, 1179, 1178,  115,  115,  115,
+      115, 1123,  115,  115,  115,  115, 1123,  115, 1123,  115,
+      115, 1123, 1123, 1132, 1142,  115,  115, 1134, 1144,  115,
+      115,  115,  115,  115, 1123, 1123,  115,  115, 1123,  115,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123,  115,  115,  115,
+      115,  115,  115,  115, 1123, 1179, 1178, 1179, 1179,  115,
+      115, 1123,  115,  115, 1123,  115, 1123,  115,  115, 1123,
+     1123, 1132, 1142, 1142,  115, 1134, 1144, 1144,  115,  115,
+     1123, 1123,  115,  115, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123,  115,  115,  115,  115,  115, 1123, 1178, 1123,  115,
+     1123, 1123,  115,  115, 1123, 1132, 1142, 1142,  115, 1134,
+     1144, 1144,  115, 1123, 1123,  115,  115, 1123, 1123, 1123,
+     1123,  115,  115,  115,  115, 1123, 1178, 1123,  115, 1123,
+     1123, 1123, 1132, 1142, 1142,  115, 1134, 1144, 1144, 1123,
+     1123,  115,  115, 1123, 1123, 1123,  115,  115, 1123, 1178,
+     1123,  115, 1123, 1123, 1132, 1142, 1134, 1144, 1123, 1123,
+      115,  115, 1123, 1123,  115, 1123, 1178, 1123,  115, 1123,
+     1132, 1142, 1134, 1144, 1123, 1123,  115, 1123, 1178, 1178,
+     1123,  115, 1123, 1132, 1134, 1123,  115, 1178, 1179, 1123,
+
+      115, 1123, 1132, 1134, 1123, 1123, 1132, 1134, 1132, 1134,
+     1132, 1134, 1132, 1134, 1132, 1134, 1123, 1134, 1134, 1134,
+     1134, 1123,    0, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123
+    } ;
+
+static yyconst short int yy_nxt[4253] =
+    {   0,
+       14,   15,   16,   17,   18,   19,   14,   20,   21,   22,
+       23,   24,   21,   25,   21,   26,   21,   27,   28,   29,
+       29,   29,   29,   29,   29,   29,   29,   29,   21,   30,
+       31,   32,   33,   21,   21,   34,   35,   36,   37,   38,
+       39,   40,   41,   34,   42,   34,   34,   43,   44,   45,
+       46,   47,   34,   48,   49,   50,   34,   34,   51,   34,
+       34,   34,   14,   52,   53,   54,   55,   64,   66,   65,
+       70,   72,   71,   72,   82,   71,   68,   73,   75,   92,
+       78,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       69,   68,   76,   67,   68,   86,   91,   68,  103,  102,
+
+       57,   58,   87,   88,   59,   69,   68,   68,   69,   68,
+       68,   69,   68,   83,  193,   68,   79,   60,   61,   68,
+       69,   69,   68,   69,   69,  210,   69,   84,   68,   69,
+       80,  105,  333,   69,   89,   72,   69,   72,   78,   70,
+       68,   71,   69,  108,  116,  108,  108,  131,   90,   93,
+      132,   93,   78,  133,   69,  108,  185,  108,   82,  134,
+      193, 1020,  108,  110,   71,  194,   71,   94,   94,   94,
+       94,   94,   94,   94,   94,   94,  211,  108,  211, 1122,
+       71,  108,   73,  214,   95,  186,  215,  135,   96,   68,
+       97,  108,  108,  136,   82,   98,  108,   99,  100,  187,
+
+      137,  138,  108,   69,  366,  254,  108,  101,  106,  217,
+      107,  107,  107,  107,  107,  107,  107,  107,  107,  117,
+      108,  108,  108,  225,  226,  108,  118,  179,  216,  108,
+      119,  108,  109,  120,   86,  139,  227,  108,  110,  108,
+      369,   87,   88,  121,  230,  255,  110,  106,  108,  107,
+      107,  107,  107,  107,  107,  107,  107,  107,  232,  231,
+      153,  338,  108,  108,  108,  122,  234,  111,  112,  123,
+      108,  109,  108,  233,  108,  124,  235,  113,  108,  125,
+      110,  108,  108, 1117,  114,  115,  140,  366,  366,  253,
+      108,  126,  396,  127,  141,  108,  128,  129,  108,  110,
+
+      142,  143,  108,  130,  108,  108,  108,  367,  370,  144,
+      108,  146,  108,  147,  108,  145,  108,  149,  148,  108,
+      108,  108,  154,  179,  191,  108,  155,  397,  180,  179,
+      156,  150,  160,  314,  151,  108,  108,  152,  157,  161,
+      108,  158,  159,  108,  108,  193,  108,  315,  260,  162,
+      108,  163,  329,  183,  108,  108,  108,  189,  108,  168,
+      135,  164,  181,  339,  108,  108,  330,  103,  108,  165,
+      243,  166,  167,  160,  243,  103,  182,  168,   86,  352,
+      161,  196,  197,  196,  108,   87,   88,  108, 1106,  390,
+      162,   68,  168,  198,  219,  220,  219,  190,  168, 1123,
+
+       82,  108,  221,  222,   86,   69,  169,  170,   86,   68,
+      171,   87,   88, 1123,  108,   87,   88,  108,  270,  252,
+      108,  199,  259,  172,  173,  174,  175,  176,  167,  391,
+      337,  108,  267,  168,  108,  200,  168,  108,  223,  108,
+      108,  366,  268,  177,  177,  177,  177,  177,  177,  177,
+      177,  177,  256,  257,  379, 1105,  108,  108,  258,  224,
+      108,  108,  169,  170,  683,   68,  171,  243,  243,  243,
+      243,  243,  243,  243,  243,  243,  282,  276,  108,  172,
+      173,  195,  196,  197,  196,  195,  195,  195,  201,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  202,  195,
+
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  195,
+      195,  195,  195,  195,  195,  195,  204,  186,  204,  204,
+      204,  204,  205,  204,  118,  204,  204,  204,  206,  204,
+      204,  187,  204,  204,  204,  204,  207,  204,  204,  204,
+      204,  208,  204,  195,   93,  179,   93,  108,  108,  244,
+      245,  108,   78,  108,  108,  108,   78,  108,  108,  179,
+      108,  108,  108,   82,  108,  261,  197, 1102,  108,  108,
+      108,  266,  108,  108,  108,  108,  108,  108,  108,   95,
+      108,  108,  108,   96,  108,   97,  108,  108,  247,  108,
+       98,  549,   99,  100,  376,  275,  340,  108,  108,  519,
+
+      269,  108,  101,  239,  239,  239,  239,  239,  239,  239,
+      239,  239,  108,  108,  277,  550,  108,  357,  108,   82,
+      108,  303,  108,  240,  241,  246,  108,  108,  108,  108,
+      108,  108,  108,  108,  108,  337,  242,  108,  248,  108,
+      249,  168,  108,  108,  274,  108,  108,  108,  108,  250,
+      108,  291,  278,  251,  278,  108,  108,  108,  108,  108,
+      108,  108,  108,  337,  378,  179,  108,  108,  287,  168,
+      246,  108,  108,  262,  271,  262,  366,  103,  366,  108,
+      280,  272,  280,  108,  108,  273,  108,  108,  283,  106,
+      281,  263,  263,  263,  263,  263,  263,  263,  263,  263,
+
+      284,  108,  285,  108,  108,  286,  279,  288,  108,  108,
+      108,  368,  290,  540,  366,  245,  108,  659,  518,  108,
+      108,  289,  108,  292,  168,  108,  108,  108,  264,  293,
+      265,  294,  108,  108,  108,  108,  313,  108,  295,  108,
+      108,  297,  108,  304,  539,  305,  108,  108,  300, 1100,
+      301,  108,  298,  296,  244,  299,  302,  108,  310,  108,
+      108,  306,  307,  108,  108,  308,  108,  309,  108,  316,
+      108,  108,  311,  108,  320,  354,  355,  354,  108,  312,
+      317,  321,  322,  108,  318,  108,  108,  108,  319,  324,
+      108,  325,  167,  108,  323,  108,  327,  168,  325,  167,
+
+      108,  108,  193,  108,  168,  343,  108,  343,  327,   78,
+      325,  167,  253,  373,  349,  373,  168,  108,  108,  346,
+       78,  108,  197,  108,  108,  348,  169,  170,  351,  383,
+      171,  383,  366,  169,  170,  108,  350,  171,  108,  179,
+      344,  108,  531,  326,  173,  169,  170,  256,  347,  171,
+      326,  173,  108,  258,  345,  691,  356,  359,  197,  359,
+      377,  220,  326,  173,  327,  175,  335,  167,  380,  222,
+      220,  541,  168,   86,  385,  197,  385,  380,  222, 1096,
+       87,   88,  336,  336,  336,  336,  336,  336,  336,  336,
+      336,   86,  360,  521,  197,  219,  220,  219,   87,   88,
+
+      108,  169,  170,  221,  222,  171,  361,  219,  220,  219,
+      387,  411,  387,  225,  226,  221,  222,  108,  326,  173,
+      197,  402,  404,  402,  404,  518,  227,  382,  406,  533,
+      406,  168,  343,  545,  343,  545,  381,  362,  362,  362,
+      362,  362,  362,  362,  362,  362,  353,  353,  197,  353,
+      353,  353,  353,  353,  353,  353,  353,  353,  353,  353,
+      353,  353,  353,  363,  353,  364,  364,  364,  364,  364,
+      364,  364,  364,  364,  353,  353,  353,  353,  353,  353,
+      353,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+      365,  365,  365,  365,  365,  365,  365,  365,  365,  365,
+
+      365,  365,  365,  365,  365,  365,  365,  365,  353,  108,
+      413,  108,  657,  108,  280,  366,  280,  108,  168,  108,
+      108, 1093,  108,  108,  281,  415,  108,  418,  108,  412,
+      108,  414,  416,  417,  108,  108,  108,  108,  108,  420,
+      108,  421,  108,  108,  108,  542,  108,  108, 1091,  419,
+      428,  425,  108,  432,  422,  108,  108,  423,  426,  108,
+      108,  108,  424,  108,  108,  108,  430,  427,  108,  108,
+      108,  108,  108,  108,  451,  431,  433,  444,  108,  445,
+      366,  445,  108,  108, 1088,  108,  108,  449,  108,  108,
+      434,  108,  434,  108,  108,  108,  447,  448,  450,  108,
+
+      108,  453,  278,  684,  278,  452,  108,  108, 1086,  446,
+      108,  108,  108, 1085,  108,  108,  108,  456,  108,  108,
+      435,  455,  179,  108,  108,  108,  457, 1082,  436,  108,
+      437,  108,  108,  438,  197,  108,  108,  439,  458,  459,
+      440,  108,  108,  441,  442,  460,  108,  443,  108,  463,
+      467,  463,  467,  108,  462,  108,  454,  472,  461,  464,
+      468,  478,  108,  108,  108,  108,  474,  520,  471,  108,
+      108, 1080,  108,  108,  473,  108,  108,  108,  108,  108,
+      535,  108,  476,  477,  108,  108,  108,  108,  475,  480,
+      108,  479,  108,  108,  498,  465,  469,  108,  108,  108,
+
+      481,  108,  108,  483,  108,  466,  470,  108,  482,  484,
+      485,  108,  108,  108,  108,  108,  108, 1078,  486,  487,
+      108,  490,  108,  108,  108,  108,  491,  492,  108,  108,
+      108,  488,  489,  493,  108,  108,   78,  108,  108,  108,
+      108,  494,  108,  108,  495,  108,  499,  108,  499,  108,
+      501,  108,  108,  497,  496,  108,  500,  108,  503,  504,
+      108,  108,  108,  502,  108,  507,  505,  508,  167,  518,
+      197,  108,  108,  168,  108,  168,  525,  530,  108,  527,
+      506,  108,  197,  103,  509,  548,  508,  167,  108,  108,
+      526,  509,  168,  508,  167, 1074,  108,  197,  108,  168,
+
+      108,  528,  169,  170,   82,  179,  171,  108,  193,  108,
+      108,  529,  354,  355,  354,  532,  559,  108,  559,  326,
+      173,  169,  170,  220,  108,  171,  108,  108,  169,  170,
+      380,  222,  171,  359,  197,  359, 1068,  534,  326,  173,
+      108,  561,  551,  561,   86,  326,  173,  509,  175,  516,
+      167,   87,   88,   86, 1073,  168,  658,  108,  563,  673,
+       87,   88,  445, 1070,  445,  517,  517,  517,  517,  517,
+      517,  517,  517,  517,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  657,  169,  170,  225,  226,  171,  168,
+      366,  553,  446,  688, 1069,  688,  552,  108,  108,  227,
+
+      565,  326,  173,  197,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  685,  108,  108,  179,  668,  197,  668,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  386,
+      386,  386,  386,  386,  386,  386,  386,  386,  108,  108,
+      197,  536,  197,  386,  386,  386,  386,  386,  386,  386,
+      386,  386,  168,  197,  660,  108,  108,  566,  168,  537,
+      537,  537,  537,  537,  537,  537,  537,  537,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  108,  567,  108,
+      538,  197,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  675,  674,  569,  108,  108,  108, 1066,  362,  362,
+
+      362,  362,  362,  362,  362,  362,  362,  403,  403,  403,
+      403,  403,  403,  403,  403,  403,  403,  403,  403,  403,
+      403,  403,  403,  403,  403,  405,  405,  405,  405,  405,
+      405,  405,  405,  405,  405,  405,  405,  405,  405,  405,
+      405,  405,  405,  407,  407,  407,  407,  407,  407,  407,
+      407,  407,  407,  407,  407,  407,  407,  407,  407,  407,
+      407,  108,  108,  108,  108,  564,  568,  108,  197,  108,
+      108,  108,  571,  572,  570,  108, 1064,  108,  108,  108,
+      108,  108,  573,  574,  108,  108,  108,  108,  108,  108,
+      108,  590,  108,  578,  108,  197,  576,  577,  579,  108,
+
+      579,  108,  108,  108,  592,  108,  108,  108,  366,  596,
+      591,  108,  593,  108,  108,  594,  108,  677,  108,  108,
+      595,  599,  108,  108,  607,  597,  607,  108,  108,  723,
+      108,  108,  610,  108,  600,  598,  108,  724,  601,  179,
+      606,  580, 1049,  108,  108,  682,  609,  108,  108,  108,
+      108,  168,  108,  108,  608,  581,  434,  168,  434,  108,
+      108,  613,  611,  727,  108,  108,  108,  108,  614,  108,
+      108,  615, 1063,  617,  616,  108,  108,  621,  871,  728,
+      618,  108, 1061,  108,  619,  463,  435,  463,  108,  620,
+      623,  467,  108,  467,  582,  464,  583, 1056,  108,  584,
+
+     1055,  468,  622,  585,   86,  108,  586,  108,  625,  587,
+      588,  698,  699,  589,  602,  602,  602,  602,  602,  602,
+      602,  602,  602,  602,  602,  108,  602,  602,  602,  602,
+      602,  603,  602,  604,  604,  604,  604,  604,  604,  604,
+      604,  604,  602,  602,  602,  602,  602,  602,  602,  605,
+      605,  605,  605,  605,  605,  605,  605,  605,  605,  605,
+      605,  605,  605,  605,  605,  605,  605,  605,  605,  605,
+      605,  605,  605,  605,  605,  605,  602,  108,  108,  108,
+      108,  108,  108,  108,  785, 1054,  785,  108, 1051,  626,
+      627,  624,  108,  108,  108,  108,  108,  108,  108,  108,
+
+      108,  628,  108,  108,  108,  629,  630,  633,  108,  108,
+      108,  631,  108,  108,  636,  108,  108,  108,  108,  108,
+      108,  635,  632,  108,  108,  634,  108,  638,  641,  108,
+      108,  640,  637,  108,  639,  108,  108,  108,  108,  642,
+      108,  108,  108,  108,  108,  108,  108,  499,  108,  499,
+      108,  197,  644,  108,  108,  108,  179,  500,  108,  108,
+      643,  108,  108,  108,  108,  108,  108,  108,  108, 1050,
+      645,  647,  646,  648,  167,  669,  657,   82, 1045,  168,
+      108,  108,  168,  108,  701,  108,  649,  366,  648,  167,
+      103, 1044,  108,  649,  168,  648,  167,  108,  780,  667,
+
+      705,  168,  676,  668,  664,  668,  664,  571,  169,  170,
+      795,  668,  171,  668,  665,  694,  108,  108,  108,  108,
+      108,   86,  707,  169,  170,  326,  173,  171,   87,   88,
+      169,  170, 1042,  706,  171,  108,  108,  108,  108,  108,
+      326,  173,  666, 1041,  670,  108,  670,  326,  173,  649,
+      175,  655,  167,  197,  671,  108,  108,  168,  672,  696,
+      108,  193,  108,  108,  709,  108,  108,  656,  656,  656,
+      656,  656,  656,  656,  656,  656,  708,  108,  710,  108,
+      108,  108,  108,  108,  712,  108,  169,  170, 1048,  714,
+      171,  607,  785,  607,  785,  711,  108, 1040,  108,  108,
+
+      877,  108,  108,  326,  173,  197,  560,  560,  560,  560,
+      560,  560,  560,  560,  560, 1038,  108,  678,  108,  678,
+      179,  608,  679,  679,  679,  679,  679,  679,  679,  679,
+      679,  197,  560,  560,  560,  560,  560,  560,  560,  560,
+      560, 1031,  179,  794,  197,  794, 1030, 1029,  537,  537,
+      537,  537,  537,  537,  537,  537,  537,  562,  562,  562,
+      562,  562,  562,  562,  562,  562,  108, 1028, 1016,  536,
+      197,  562,  562,  562,  562,  562,  562,  562,  562,  562,
+      781,  108,  680,  108,  680,  732,  719,  681,  681,  681,
+      681,  681,  681,  681,  681,  681,  687,  687,  108,  687,
+
+      687,  687,  687,  687,  687,  687,  687,  687,  687,  687,
+      687,  687,  687,  702,  687,  703,  703,  703,  703,  703,
+      703,  703,  703,  703,  687,  687,  687,  687,  687,  687,
+      687,  704,  704,  704,  704,  704,  704,  704,  704,  704,
+      704,  704,  704,  704,  704,  704,  704,  704,  704,  704,
+      704,  704,  704,  704,  704,  704,  704,  704,  687,  108,
+      108,  579,  108,  579,  108,  108,  108,  716,  108,  720,
+      715,  733,  108,  736,  739,  735,  108,  108,  731,  108,
+      734,  108,  108,  108,  108,  108,  108, 1025, 1024,  108,
+      738,  108,  740,  409,  740,  244,  193,  409,  108,  737,
+
+      108,  108,  108,  108,  717,  243,  243,  243,  243,  243,
+      243,  243,  243,  243,  108,  108,  108,  108,  718,  108,
+      108,  743,  741,  108,  108,  745,  108,  108,  744,  742,
+      108,  108,  108,  108,  748,  746,  108,  108,  789,  108,
+      108,  108,  752,  747,  108,  108,  108,  108,  753,  108,
+      750,  197,  751,  108,  108,  749,  108,  108,  108,  108,
+      755,  108,  108,  108,  108,  754,  108,  108,  756,  758,
+      757,  108,  108,  108,  108,  108,  760,  759,  108,  108,
+      763,  108,  108,  108,  108,  108,  761,  764,  108,  108,
+      108,  108,  108,  792,  108,  769,  108,  108,  762,  108,
+
+      108,  108,  108,  108, 1018,  108,  766,  768,  108,  108,
+      767,  108,  108,  108,  664,  197,  664,  108,  108,  770,
+      108,  771,  772,  773,  665,  774,  167,  168, 1017,  108,
+      108,  168,  775,  168,  774,  167,  664,  670,  664,  670,
+      168,  103,  775,  197,  774,  167,  665,  671,  108,  108,
+      168,  672,  776,  786,  879,   86,  787,  794,  197,  794,
+      169,  170,  806,  807,  171,  108,  108,  108,   86,  169,
+      170,  108,  244,  171,  776,   87,   88,  326,  173,  169,
+      170,  790,  788,  171,  108,  193,  326,  173,  108, 1015,
+      672,  108,  672,  670, 1012,  670,  326,  173,  775,  175,
+
+      779,  167,   86,  671,  672,  108,  168,  672,  108,   87,
+       88,  243,  243,  243,  243,  243,  243,  243,  243,  243,
+      812,  108,  108,  986,  811,  108,  108,  108,  108,  108,
+      816,  108,  819,  108,  819,  169,  170,  108,  108,  171,
+      813,  817,  108,  108,  108,  108,  108,  815,  108,  814,
+      108,  108,  326,  173,  197,  822,  740, 1011,  740,  819,
+      876,  819,  876,  876,  108,  876,  108,  108,  108,  820,
+      825,  679,  679,  679,  679,  679,  679,  679,  679,  679,
+      197,  839,  821,  108,  108,  965,  741,  965, 1009, 1001,
+      108,  108,  834,  108,  108,  835,  891,  679,  679,  679,
+
+      679,  679,  679,  679,  679,  679,  197,  108,  108,  892,
+      108,  841,  179,  836, 1000,  999,  108,  108,  843,  108,
+      108,  838,  837,  681,  681,  681,  681,  681,  681,  681,
+      681,  681,  197,  108,  108,  108,  850,  108,  862,   86,
+      862,  983, 1007,  984, 1007,  934,   87,   88,  863,  681,
+      681,  681,  681,  681,  681,  681,  681,  681,  791,  791,
+      197,  791,  791,  791,  791,  791,  791,  791,  791,  791,
+      791,  791,  791,  791,  791,  796,  791,  797,  797,  797,
+      797,  797,  797,  797,  797,  797,  791,  791,  791,  791,
+      791,  791,  791,  798,  798,  798,  798,  798,  798,  798,
+
+      798,  798,  798,  798,  798,  798,  798,  798,  798,  798,
+      798,  798,  798,  798,  798,  798,  798,  798,  798,  798,
+      791,  800,  800,   86,  800, 1036,  998, 1036,  800,  800,
+       87,   88,  800,  997,  996,  800,  800,  800,  800,  800,
+      800,  800,  800,  799,  799,  995,  799,  799,  799,  799,
+      799,  799,  799,  799,  799,  799,  799,  799,  799,  799,
+      808,  799,  809,  809,  809,  809,  809,  809,  809,  809,
+      809,  799,  799,  799,  799,  799,  799,  799,  810,  810,
+      810,  810,  810,  810,  810,  810,  810,  810,  810,  810,
+      810,  810,  810,  810,  810,  810,  810,  810,  810,  810,
+
+      810,  810,  810,  810,  810,  799,  108,  108,  108,  844,
+      840,  844,  108,  108,  851,  179,  108,  848,  842,  845,
+      847,  108,  846,  108,  108,  108,  108,  992,  108,  108,
+      108,  108,  849,  108,  852,  108,  108,  853,  108,  108,
+      854,  108,  854,  108,  108,  108,  857,  108,  108, 1113,
+      108,  108,  108,  108,  860,  108,  108,  108,  108,  856,
+      108,  108,  108,  108,  108,  859,  858,  108,  108,  861,
+      864,  108,  108,  197,  108,  108,  865,  108,  865,  108,
+      108,  108,  773,  108,  775,  167,  108,  179,  108,  108,
+      855,  874,  108,  775,  991,  774,  167,  108,  108,  867,
+
+      108,  168,  775,  108,  775,  167,  108,  876,  108,  876,
+      244,  108,  865,  866,  865,  108,  888,  885,  883,  169,
+      170,  875,  884,  171,  982,  108, 1084,  108,  108,  108,
+      169,  170,  108,  108,  171,  108,  326,  173,  108,  169,
+      170,  108,  108,  171,  894,  886,  108,  326,  173,  929,
+      981, 1059,  889, 1059,  980,  108,  326,  173,  108,  108,
+      878,  878,  197,  878,  878,  878,  878,  878,  878,  878,
+      878,  878,  878,  878,  878,  878,  878,  880,  878,  881,
+      881,  881,  881,  881,  881,  881,  881,  881,  878,  878,
+      878,  878,  878,  878,  878,  882,  882,  882,  882,  882,
+
+      882,  882,  882,  882,  882,  882,  882,  882,  882,  882,
+      882,  882,  882,  882,  882,  882,  882,  882,  882,  882,
+      882,  882,  878,  197,  243,  243,  243,  243,  243,  243,
+      243,  243,  243,  108,  108,  108,  108,  887,  108,  108,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  893,
+      108,  108,  108,  896,  108,  108,  906,  905,  108,  108,
+      108,  909,  108,  108,  108,  907,  977,  911,  912,  975,
+      972,  108,  108,  108,  910,  908,  108,  108,  915,  108,
+      108,  108,  844,  913,  844,  916,  918,  108,  917,  108,
+      108,  108,  845,  108,  108,  108,  108,  920,  854,  108,
+
+      854,  108,  108,  108,  108,  108,  919,  921,  108,  926,
+      108,  108,  108,  108,  925,  108,  108,  108,  923,  108,
+      108,  924,  108,  108,  108,  862,  930,  862,  193,  108,
+      936,  197,  108,  108,  108,  863,  108,  931,  108,  940,
+      108,  108,  108,  108,  957,  928,  108,  108,  922,  108,
+      108,  937,  108,  108,  108,  108,  941,  108,  108,  942,
+      108,  938,  948,  108,  939,  197,  108,  950,  193,  108,
+      944,  108,  947,  943,  108,  108,  108,  108,  961,  956,
+      108,  959,  362,  362,  362,  362,  362,  362,  362,  362,
+      362,  108,  108,  108,  108,  108,  960,  108,  108,  958,
+
+      915,  108,  179,  108,  179, 1047,  108,  916,  108,  108,
+      917,  108,  967,  962,  108,  108,  964,  963,  108,  968,
+      108,  915,  969,  108,  108,  108,  108,  108,  916,  970,
+      108,  917,  971,  108,  108,  108,  108,  197,  108,  976,
+      973,  108,  108,  108,  108,  108,  108,  108,  108, 1065,
+      108,  974,  108,  108,  978,  108,  108, 1094,  979,  989,
+      108,  108,  108,  108,  108,  108,  985,  108,  990,  108,
+      108,  994,  955,  108,  987,  108,  988,  108,  108, 1003,
+      108,  108,  993,  108,  108,  108,  108,  108,  108, 1002,
+      197,  108,  108, 1006,  967, 1004,  108,  108,  108,  197,
+
+      108,  968,  108,  954,  969,  108,  967, 1005,  108, 1008,
+      967, 1008,  967,  968,  108,  108,  969,  916,  108,  968,
+      917,  108,  969, 1010,  108,  108,  108,  108,  108, 1013,
+     1014,  108, 1022,  108,  953,  108,  108, 1021,  108, 1019,
+     1023,  108,  108,  108,  108,  108,  108,  108,  108,  108,
+      108, 1033,  108,  108,  108, 1027,  179, 1026, 1035,  108,
+     1034, 1032,  952,  108,  108,  108,  108,  108,  108,  108,
+      951,  108, 1037,  915, 1037,  108,  108,  108,  108, 1039,
+      916,  108, 1052,  917,  108,  108,  108, 1046,  108, 1043,
+      108,  108,  108,  108,  108,  108,  193, 1057,  108, 1053,
+
+      108, 1058,  179,  108,  108,  108,  108,  108,  108, 1062,
+      108, 1060,  915, 1060,  108,  193,  108,  108, 1075,  916,
+      108,  108,  917,  108, 1072,  949, 1076, 1071, 1076, 1067,
+      108,  108,  108,  108, 1077,  915, 1077,  108,  108,  193,
+     1079,  108,  916,  179,  915,  917, 1087,  108,  108,  108,
+     1081,  916, 1083,  179,  917,  108, 1089, 1089, 1092, 1089,
+      179, 1097,  946, 1089, 1089,  108,  193, 1089,  179,  193,
+     1089, 1089, 1089, 1089, 1089, 1089, 1089, 1089, 1090,  915,
+     1090,  108,  193,  193,  179, 1101,  916, 1095,  193,  917,
+      915, 1111,  193, 1103, 1098, 1098, 1107, 1099,  108, 1104,
+
+      917, 1098, 1098,  108,  108, 1098,  193,  193, 1098, 1098,
+     1098, 1098, 1098, 1098, 1098, 1098,  915,  967,  193, 1109,
+      108,  108, 1112,  916,  968, 1114,  917,  969,  193, 1108,
+      384, 1110,  384,  386,  388,  386,  388, 1115,  403,  945,
+      403, 1116,  405,  366,  405, 1119,  407,  560,  407,  560,
+      197,  562, 1120,  562,  935,  179,  933, 1118,  932,  927,
+      904,  903,  902,  901,  900,  899,  898,  897,  895,  890,
+       82,   78,  366,  197,  197,  197,  873,  179,  179,  870,
+      869, 1121,   62,   62,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,   62,   62,   62,   62,   62,   63,
+
+       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
+       63,   63,   63,   63,   63,   63,   74,   74,  868,   74,
+       74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
+       74,   74,   74,   77,   77,  833,   77,   77,   77,   77,
+       77,   77,   77,   77,   77,   77,   77,   77,   77,   77,
+       81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
+       81,   81,   81,   81,   81,   81,   81,   85,   85,   85,
+       85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
+       85,   85,   85,   85,  104,  104,  832,  831,  830,  829,
+      104,  108,  108,  108,  108,  108,  108,  108,  108,  108,
+
+      108,  178,  178,  178,  178,  178,  178,  178,  178,  178,
+      178,  178,  178,  178,  178,  178,  178,  178,  184,  828,
+      184,  827,  184,  184,  826,  824,  823,  818,  184,  192,
+      192,  192,  192,  192,  192,  192,  192,  192,  192,  192,
+      192,  192,  192,  192,  192,  192,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,   82,  195,  195,  195,
+      195,   82,  195,  218,  218,  218,  218,  218,  218,  218,
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
+       94,   78,  803,   94,   94,  238,  238,  238,  238,  366,
+      238,  238,  366,  238,  238,  197,  238,  238,  783,  179,
+
+      238,  238,  328,  328,  328,  328,  328,  328,  328,  328,
+      328,  328,  328,  328,  328,  328,  328,  328,  328,  336,
+      778,  336,  777,  765,  336,  341,  730,  341,  729,  341,
+      341,  342,  342,  726,  342,  342,  342,  342,  342,  342,
+      342,  342,  342,  342,  342,  342,  342,  342,  353,  353,
+      353,  353,  353,  353,  353,  353,  353,  353,  353,  353,
+      353,  353,  353,  353,  353,  358,  358,  358,  358,  358,
+      358,  358,  358,  358,  358,  358,  358,  358,  358,  358,
+      358,  358,  401,  725,  722,  401,  401,  262,  721,  262,
+      713,  700,   82,  693,  262,  689,  686,  530,  663,  662,
+
+      530,  654,  262,  517,  653,  517,  652,  651,  517,  522,
+      650,  522,  612,  522,  522,  656,  575,  656,  408,  558,
+      656,  661,  557,  661,  556,  661,  661,  687,  687,  555,
+      687,  687,  687,  687,  687,  687,  687,  687,  687,  687,
+      687,  687,  687,  687,  690,  690,  554,  690,  690,  690,
+      690,  690,  690,  690,  690,  690,  690,  690,  690,  690,
+      690,  692,  692,  547,  692,  692,  692,  692,  692,  692,
+      692,  692,  692,  692,  692,  692,  692,  692,  695,  695,
+      695,  695,  695,  695,  695,  695,  695,  695,  695,  695,
+      695,  695,  695,  695,  695,  697,  697,  697,  697,  697,
+
+      697,  697,  697,  697,  697,  697,  697,  697,  697,  697,
+      697,  697,  782,  782,  782,  782,  782,  782,  782,  782,
+      782,  782,  782,  782,  782,  782,  782,  782,  782,  104,
+      546,  104,  544,  104,  104,  784,  784,  543,  784,  784,
+      784,  784,  784,  784,  784,  784,  784,  784,  784,  784,
+      784,  784,  791,  791,  791,  791,  791,  791,  791,  791,
+      791,  791,  791,  791,  791,  791,  791,  791,  791,  793,
+      793,  793,  793,  793,  793,  793,  793,  793,  793,  793,
+      793,  793,  793,  793,  793,  793,  799,  799,  366,  799,
+      799,  799,  799,  799,  799,  799,  799,  799,  799,  799,
+
+      799,  799,  799,  801,  801,  197,  801,  801,  801,  801,
+      801,  801,  801,  801,  801,  801,  801,  801,  801,  801,
+      802,  802,  197,  802,  802,  802,  802,  802,  802,  802,
+      802,  802,  802,  802,  802,  802,  802,  804,  804,  804,
+      804,  804,  804,  804,  804,  804,  804,  804,  804,  804,
+      804,  804,  804,  804,  805,  805,  805,  805,  805,  805,
+      805,  805,  805,  805,  805,  805,  805,  805,  805,  805,
+      805,  872,  872,  872,  872,  872,  872,  872,  872,  872,
+      872,  872,  872,  872,  872,  872,  872,  872,  878,  878,
+      878,  878,  878,  878,  878,  878,  878,  878,  878,  878,
+
+      878,  878,  878,  878,  878,  914,  914,  914,  914,  914,
+      914,  914,  914,  914,  914,  914,  914,  914,  914,  914,
+      914,  914,  966,  966,  966,  966,  966,  966,  966,  966,
+      966,  966,  966,  966,  966,  966,  966,  966,  966,  524,
+      523,  515,  514,  513,  512,  511,  510,  179,  333,  429,
+      410,  408,  400,  399,  398,  395,  394,  393,  392,  389,
+      375,  374,  372,  371,  366,  197,  197,  193,  179,  334,
+      332,  331,  179,  237,  236,  229,  228,   82,   82,   78,
+      213,  212,  210,  209,  193,  188, 1123,   64,   13, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123
+    } ;
+
+static yyconst short int yy_chk[4253] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    2,    2,    2,    2,    8,   10,    8,
+       15,   16,   15,   16,   22,   17,   14,   17,   18,   25,
+       19,    2,    2,    2,    2,    2,    2,    2,    2,    2,
+       14,   20,   18,   10,   21,   23,   24,   26,   29,   28,
+
+        2,    2,   23,   23,    2,   20,   30,   25,   21,   31,
+       15,   26,   33,   22,  986,   17,   19,    2,    2,   24,
+       30,   25,   29,   31,   15,  172,   33,   22,   28,   17,
+       19,   32,  172,   24,   23,   53,   29,   53,   80,   70,
+       32,   70,   28,   40,   36,   36,   36,   40,   23,   27,
+       40,   27,   79,   40,   32,   36,   57,   40,   84,   40,
+       65,  986,   36,   36,   71,   65,   71,   27,   27,   27,
+       27,   27,   27,   27,   27,   27,   72,   41,   72, 1121,
+       73,   41,   73,   79,   27,   57,   80,   41,   27,   27,
+       27,   41,   42,   42,   83,   27,   42,   27,   27,   57,
+
+       42,   42,   42,   27,  207,  118,   42,   27,   34,   84,
+       34,   34,   34,   34,   34,   34,   34,   34,   34,   37,
+       37,   37,  118,   94,   94,   43,   37,  180,   83,   43,
+       37,  119,   34,   37,   85,   43,   94,   37,   37,   43,
+      207,   85,   85,   37,   97,  119,   34,   35,  119,   35,
+       35,   35,   35,   35,   35,   35,   35,   35,   98,   97,
+       48,  180,   38,   38,   48,   38,   99,   35,   35,   38,
+       48,   35,   38,   98,   48,   38,   99,   35,  117,   38,
+       38,   39,   39, 1115,   35,   35,   44,  208,  205,  117,
+       44,   39,  234,   39,   44,  117,   39,   39,   39,   39,
+
+       44,   45,   46,   39,   44,   45,   46,  205,  208,   45,
+       61,   46,   46,   46,   61,   45,   46,   47,   46,   45,
+       61,   47,   49,   55,   61,   47,   49,  234,   55,  181,
+       49,   47,   50,  158,   47,   47,   49,   47,   49,   50,
+       49,   49,   49,   50,   51,  194,   50,  158,  122,   50,
+       59,   51,  169,   56,   59,   51,   50,   59,   51,   56,
+       59,   51,   55,  181,   59,  122,  169,   56,   51,   52,
+     1152,   52,   52,   60, 1152,  104,   55,   52,   87,  194,
+       60,   66,   66,   66,   60,   87,   87,   60, 1100,  229,
+       60,   56,  168,   66,   86,   86,   86,   60,  168,  104,
+
+      217,  129,   86,   86,   89,   56,   52,   52,   90,   52,
+       52,   89,   89,  104,  126,   90,   90,  116,  129,  116,
+      121,   66,  121,   52,   52,   54,   54,   54,   54,  229,
+      177,  126,  126,   54,  116,   66,  177,  121,   89,  127,
+      120,  540,  127,   54,   54,   54,   54,   54,   54,   54,
+       54,   54,  120,  120,  217, 1096,  127,  120,  120,   90,
+      133,  137,   54,   54,  540,   54,   54,  106,  106,  106,
+      106,  106,  106,  106,  106,  106,  137,  133,  137,   54,
+       54,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
+       67,   67,   67,   67,   93,  182,   93,  108,  108,  107,
+      109,  108,  214,  123,  109,  109,  377,  108,  109,  338,
+      125,  108,  108,  378,  109,  123,  200, 1093,  109,  109,
+      123,  125,  107,  107,  111,  111,  107,  125,  111,   93,
+      128,  132,  107,   93,  111,   93,  107,  107,  111,  111,
+       93,  377,   93,   93,  214,  132,  182,  128,  132,  338,
+
+      128,  134,   93,  103,  103,  103,  103,  103,  103,  103,
+      103,  103,  110,  110,  134,  378,  110,  200,  134,  216,
+      152,  152,  110,  103,  103,  110,  110,  110,  112,  112,
+      113,  113,  112,  131,  113,  183,  103,  152,  112,  143,
+      113,  183,  112,  112,  131,  114,  114,  113,  113,  114,
+      131,  143,  135,  115,  135,  114,  143,  115,  115,  114,
+      114,  115,  139,  184,  216,  520,  130,  115,  139,  184,
+      115,  115,  115,  124,  130,  124,  368,  184,  206,  139,
+      136,  130,  136,  130,  140,  130,  138,  135,  138,  124,
+      136,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+
+      138,  140,  138,  138,  135,  138,  135,  140,  141,  142,
+      144,  206,  142,  368,  367,  136,  145,  520,  336,  157,
+      146,  141,  148,  144,  336,  141,  142,  144,  124,  145,
+      124,  146,  136,  145,  147,  149,  157,  146,  147,  148,
+      150,  148,  151,  153,  367,  153,  154,  155,  150, 1091,
+      151,  147,  149,  147,  263,  149,  151,  150,  155,  151,
+      153,  153,  153,  154,  155,  153,  156,  154,  159,  159,
+      161,  160,  156,  162,  161,  196,  196,  196,  163,  156,
+      159,  162,  163,  156,  160,  159,  164,  161,  160,  165,
+      162,  165,  165,  263,  164,  163,  166,  165,  166,  166,
+
+      189,  186,  352,  164,  166,  185,  188,  185,  174,  215,
+      174,  174,  186,  211,  189,  211,  174,  189,  186,  186,
+      548,  190,  199,  188,  191,  188,  165,  165,  191,  225,
+      165,  225,  369,  166,  166,  187,  190,  166,  190,  340,
+      185,  191,  352,  165,  165,  174,  174,  187,  187,  174,
+      166,  166,  187,  187,  185,  548,  199,  201,  201,  201,
+      215,  218,  174,  174,  176,  176,  176,  176,  218,  218,
+      221,  369,  176,  224,  226,  357,  226,  221,  221, 1086,
+      224,  224,  176,  176,  176,  176,  176,  176,  176,  176,
+      176,  223,  201,  340, 1084,  219,  219,  219,  223,  223,
+
+      245,  176,  176,  219,  219,  176,  201,  220,  220,  220,
+      227,  245,  227,  239,  239,  220,  220,  245,  176,  176,
+      202,  240,  241,  240,  241,  337,  239,  224,  242,  357,
+      242,  337,  343,  373,  343,  373,  223,  202,  202,  202,
+      202,  202,  202,  202,  202,  202,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
+
+      203,  203,  203,  203,  203,  203,  203,  203,  203,  246,
+      247,  249,  517,  248,  280,  370,  280,  252,  517,  250,
+      251, 1080,  254,  255,  280,  249,  246,  252,  249,  246,
+      248,  248,  250,  251,  252,  247,  250,  251,  253,  254,
+      255,  255,  256,  257,  258,  370,  261,  259, 1078,  253,
+      261,  258,  247,  266,  256,  253,  260,  256,  259,  256,
+      257,  258,  257,  261,  259,  264,  264,  260,  265,  269,
+      266,  272,  267,  260,  275,  265,  267,  269,  271,  270,
+      541,  270,  264,  273, 1074,  265,  269,  273,  272,  267,
+      268,  275,  268,  276,  274,  271,  271,  271,  274,  277,
+
+      273,  277,  278,  541,  278,  276,  282,  279, 1070,  270,
+      276,  274,  297, 1069,  270,  283,  277,  282,  284,  285,
+      268,  279,  339,  282,  279,  268,  283, 1066,  268,  297,
+      268,  270,  283,  268,  361,  284,  285,  268,  284,  285,
+      268,  286,  268,  268,  268,  286,  287,  268,  290,  288,
+      289,  288,  289,  291,  287,  292,  278,  291,  286,  288,
+      289,  298,  293,  287,  294,  290,  293,  339,  290,  295,
+      291, 1063,  292,  299,  292,  296,  300,  316,  298,  293,
+      361,  294,  295,  296,  288,  289,  295,  301,  294,  300,
+      299,  299,  296,  300,  316,  288,  289,  302,  303,  305,
+
+      301,  288,  289,  302,  301,  288,  289,  304,  301,  303,
+      304,  306,  307,  308,  302,  303,  305, 1061,  304,  305,
+      311,  308,  309,  310,  304,  313,  309,  310,  306,  307,
+      308,  306,  307,  311,  312,  314,  376,  311,  315,  309,
+      310,  312,  313,  318,  313,  320,  317,  321,  317,  322,
+      318,  312,  314,  315,  314,  315,  317,  319,  320,  321,
+      318,  323,  320,  319,  321,  324,  322,  324,  324,  341,
+      356,  347,  346,  324,  319,  341,  346,  351,  323,  348,
+      323,  317, 1048,  341,  325,  376,  325,  325,  347,  346,
+      347,  327,  325,  327,  327, 1056,  348,  360,  317,  327,
+
+      349,  349,  324,  324,  379,  519,  324,  350,  531,  414,
+      351,  350,  354,  354,  354,  356,  408,  349,  408,  324,
+      324,  325,  325,  380,  350,  325,  414,  351,  327,  327,
+      380,  380,  327,  359,  359,  359, 1048,  360,  325,  325,
+      411,  410,  379,  410,  381,  327,  327,  335,  335,  335,
+      335,  381,  381,  382, 1055,  335,  519,  411,  411,  531,
+      382,  382,  445, 1051,  445,  335,  335,  335,  335,  335,
+      335,  335,  335,  335,  383,  383,  383,  383,  383,  383,
+      383,  383,  383,  518,  335,  335,  401,  401,  335,  518,
+      542,  382,  445,  545, 1050,  545,  381,  416,  415,  401,
+
+      415,  335,  335,  362,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  542,  416,  415,  521,  652, 1049,  652,
+      362,  362,  362,  362,  362,  362,  362,  362,  362,  385,
+      385,  385,  385,  385,  385,  385,  385,  385,  417,  418,
+      532,  362,  363,  386,  386,  386,  386,  386,  386,  386,
+      386,  386,  656,  533,  521,  417,  418,  418,  656,  363,
+      363,  363,  363,  363,  363,  363,  363,  363,  387,  387,
+      387,  387,  387,  387,  387,  387,  387,  419,  420,  422,
+      363,  366,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  533,  532,  422,  419,  420,  422, 1044,  366,  366,
+
+      366,  366,  366,  366,  366,  366,  366,  402,  402,  402,
+      402,  402,  402,  402,  402,  402,  403,  403,  403,  403,
+      403,  403,  403,  403,  403,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  405,  405,  405,  405,  405,  405,
+      405,  405,  405,  406,  406,  406,  406,  406,  406,  406,
+      406,  406,  407,  407,  407,  407,  407,  407,  407,  407,
+      407,  412,  421,  423,  424,  412,  421,  425,  535,  426,
+      428,  427,  424,  426,  423,  432, 1042,  436,  412,  421,
+      423,  424,  427,  428,  425,  430,  426,  428,  427,  431,
+      437,  436,  432,  432,  436, 1022,  430,  431,  433,  438,
+
+      433,  439,  430,  440,  438,  441,  431,  437,  539,  441,
+      437,  442,  438,  444,  443,  439,  438,  535,  439,  447,
+      440,  443,  441,  449,  450,  441,  450,  451,  442,  584,
+      444,  443,  452,  433,  444,  442,  447,  584,  447,  780,
+      449,  433, 1022,  453,  451,  539,  451,  455,  457,  452,
+      433,  657,  458,  456,  450,  433,  434,  657,  434,  450,
+      453,  456,  453,  587,  455,  457,  459,  460,  457,  458,
+      456,  458, 1040,  460,  459,  462,  450,  462,  780,  587,
+      460,  461, 1038,  459,  460,  463,  434,  463,  465,  461,
+      466,  467,  462,  467,  434,  463,  434, 1031,  461,  434,
+
+     1029,  467,  465,  434,  553,  465,  434,  466,  470,  434,
+      434,  553,  553,  434,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  470,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  448,  448,  448,
+      448,  448,  448,  448,  448,  448,  448,  469,  471,  472,
+      473,  474,  475,  476,  663, 1028,  663,  477, 1025,  471,
+      472,  469,  480,  478,  469,  471,  472,  473,  474,  475,
+
+      476,  477,  479,  481,  477,  478,  479,  482,  483,  480,
+      478,  480,  485,  484,  486,  487,  488,  489,  490,  479,
+      481,  484,  481,  491,  482,  483,  492,  488,  492,  485,
+      484,  490,  487,  488,  489,  490,  493,  486,  494,  495,
+      491,  496,  497,  492,  501,  503,  498,  499,  502,  499,
+      504,  534,  502,  493,  486,  494,  658,  499,  496,  497,
+      498,  501,  503,  498,  495,  502,  505,  504,  506, 1024,
+      505,  507,  506,  507,  507,  528,  522,  550, 1018,  507,
+      563,  495,  522,  505,  563,  506,  508,  682,  508,  508,
+      522, 1017,  528,  509,  508,  509,  509,  563,  658,  526,
+
+      565,  509,  534,  527,  525,  527,  525,  526,  507,  507,
+      682,  668,  507,  668,  525,  550,  526,  565,  566,  568,
+      567,  552,  567,  508,  508,  507,  507,  508,  552,  552,
+      509,  509, 1015,  566,  509,  566,  568,  567,  527,  525,
+      508,  508,  525, 1012,  529,  572,  529,  509,  509,  516,
+      516,  516,  516, 1021,  529,  527,  525,  516,  529,  552,
+      570,  789,  572,  569,  570,  571,  574,  516,  516,  516,
+      516,  516,  516,  516,  516,  516,  569,  570,  571,  529,
+      569,  573,  571,  574,  574,  576,  516,  516, 1021,  576,
+      516,  607,  785,  607,  785,  573,  529, 1011,  573,  590,
+
+      789,  592,  576,  516,  516,  536,  559,  559,  559,  559,
+      559,  559,  559,  559,  559, 1009,  590,  536,  592,  536,
+      982,  607,  536,  536,  536,  536,  536,  536,  536,  536,
+      536,  537,  560,  560,  560,  560,  560,  560,  560,  560,
+      560, 1001,  659,  677,  677,  677,  999,  997,  537,  537,
+      537,  537,  537,  537,  537,  537,  537,  561,  561,  561,
+      561,  561,  561,  561,  561,  561,  593,  996,  982,  537,
+      538,  562,  562,  562,  562,  562,  562,  562,  562,  562,
+      659,  580,  538,  593,  538,  593,  580,  538,  538,  538,
+      538,  538,  538,  538,  538,  538,  564,  564,  580,  564,
+
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  564,
+      564,  564,  564,  564,  564,  564,  564,  564,  564,  577,
+      578,  579,  581,  579,  596,  591,  595,  578,  594,  581,
+      577,  594,  597,  597,  600,  596,  577,  578,  591,  581,
+      595,  596,  591,  595,  598,  594,  599,  992,  991,  597,
+      599,  600,  601, 1153,  601,  604,  673, 1153,  605,  598,
+
+      609,  598,  610,  599,  579,  603,  603,  603,  603,  603,
+      603,  603,  603,  603,  604,  605,  606,  609,  579,  610,
+      611,  610,  601,  613,  615,  613,  616,  601,  611,  606,
+      617,  604,  614,  606,  617,  614,  618,  611,  673,  620,
+      613,  615,  621,  616,  601,  619,  622,  617,  622,  614,
+      619,  676,  620,  618,  623,  618,  620,  625,  624,  621,
+      624,  627,  619,  622,  628,  623,  626,  630,  625,  627,
+      626,  623,  629,  632,  625,  624,  629,  628,  627,  633,
+      634,  628,  631,  626,  630,  635,  631,  635,  637,  629,
+      632,  638,  640,  676,  639,  640,  633,  634,  633,  631,
+
+      641,  643,  635,  644,  984,  637,  637,  639,  638,  640,
+      638,  639,  645,  646,  650,  792,  650,  641,  643,  641,
+      644,  643,  644,  647,  650,  647,  647,  661,  983,  645,
+      646,  647,  648,  661,  648,  648,  664,  654,  664,  654,
+      648,  661,  649,  674,  649,  649,  664,  654,  667,  666,
+      649,  654,  650,  666,  792,  696,  667,  794,  794,  794,
+      647,  647,  696,  696,  647,  667,  666,  704,  697,  648,
+      648,  669,  703,  648,  664,  697,  697,  647,  647,  649,
+      649,  674,  669,  649,  704,  938,  648,  648,  669,  980,
+      672,  703,  672,  670,  977,  670,  649,  649,  655,  655,
+
+      655,  655,  698,  670,  672,  705,  655,  670,  703,  698,
+      698,  702,  702,  702,  702,  702,  702,  702,  702,  702,
+      706,  707,  705,  938,  705,  708,  709,  710,  711,  716,
+      711,  719,  714,  712,  714,  655,  655,  706,  707,  655,
+      707,  712,  708,  709,  710,  711,  716,  710,  719,  709,
+      712,  715,  655,  655,  678,  715,  740,  975,  740,  819,
+      870,  819,  870,  876,  736,  876,  720,  714,  715,  714,
+      720,  678,  678,  678,  678,  678,  678,  678,  678,  678,
+      679,  736,  714,  720,  714,  915,  740,  915,  972,  956,
+      731,  732,  731,  733,  738,  732,  819,  679,  679,  679,
+
+      679,  679,  679,  679,  679,  679,  680,  731,  732,  819,
+      733,  738,  871,  733,  955,  954,  734,  735,  742,  748,
+      749,  735,  734,  680,  680,  680,  680,  680,  680,  680,
+      680,  680,  681,  734,  735,  742,  748,  749,  765,  805,
+      765,  935,  965,  935,  965,  871,  805,  805,  765,  681,
+      681,  681,  681,  681,  681,  681,  681,  681,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  684,  684,  684,  684,  684,  684,  684,  684,  684,
+      684,  688,  688,  806,  688, 1007,  953, 1007,  688,  688,
+      806,  806,  688,  952,  951,  688,  688,  688,  688,  688,
+      688,  688,  688,  701,  701,  949,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+      701,  701,  701,  701,  701,  701,  701,  701,  701,  701,
+
+      701,  701,  701,  701,  701,  701,  737,  739,  744,  743,
+      737,  743,  745,  746,  750, 1111,  751,  746,  739,  743,
+      745,  753,  744,  737,  739,  744,  752,  946,  747,  745,
+      746,  750,  747,  751,  751,  754,  755,  752,  753,  756,
+      757,  758,  757,  752,  743,  747,  759,  760,  761, 1111,
+      762,  764,  754,  755,  762,  767,  756,  763,  758,  758,
+      768,  743,  766,  759,  760,  761,  760,  762,  764,  763,
+      766,  769,  767, 1068,  763,  757,  770,  768,  770,  766,
+      771,  772,  773,  810,  773,  773,  786,  934,  769,  814,
+      757,  786,  757,  774,  945,  774,  774,  771,  772,  771,
+
+      810,  774,  775,  786,  775,  775,  814,  788,  787,  788,
+      809,  770,  865,  770,  865,  812,  816,  812,  811,  773,
+      773,  787,  811,  773,  934,  787, 1068,  821,  770,  809,
+      774,  774,  812,  816,  774,  811,  773,  773,  817,  775,
+      775,  813,  788,  775,  821,  813,  809,  774,  774,  865,
+      933, 1036,  817, 1036,  932,  817,  775,  775,  813,  788,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
+      795,  795,  795,  796,  808,  808,  808,  808,  808,  808,
+      808,  808,  808,  815,  822,  820,  825,  815,  834,  835,
+      796,  796,  796,  796,  796,  796,  796,  796,  796,  820,
+      815,  822,  820,  825,  836,  834,  835,  834,  837,  838,
+      839,  838,  840,  841,  842,  836,  929,  841,  842,  927,
+      922,  836,  843,  846,  839,  837,  838,  839,  845,  840,
+      841,  842,  844,  843,  844,  845,  846,  847,  845,  843,
+      846,  848,  844,  849,  850,  851,  853,  851,  854,  852,
+
+      854,  855,  856,  857,  847,  858,  847,  852,  848,  858,
+      849,  850,  851,  853,  857,  859,  852,  860,  855,  856,
+      857,  856,  858,  861,  864,  862,  866,  862,  877,  867,
+      874,  879,  859,  875,  860,  862,  884,  867,  883,  883,
+      861,  864,  886,  866,  904,  864,  867,  874,  854,  887,
+      875,  875,  885,  884,  888,  883,  885,  889,  894,  886,
+      893,  877,  894,  896,  879,  880,  887,  896, 1020,  885,
+      889,  888,  893,  888,  889,  894,  906,  893,  908,  902,
+      896,  906,  880,  880,  880,  880,  880,  880,  880,  880,
+      880,  905,  907,  906,  909,  908,  907,  910,  911,  905,
+
+      914,  913, 1043,  912, 1081, 1020,  918,  914,  905,  907,
+      914,  909,  916,  909,  910,  911,  912,  910,  913,  916,
+      912,  917,  916,  918,  919,  920,  923,  924,  917,  920,
+      921,  917,  921,  925,  926,  928,  930,  939,  937,  928,
+      923,  919,  920,  923,  924,  931,  936,  921,  940, 1043,
+      925,  926,  928,  930,  930,  937,  941, 1081,  931,  940,
+      942,  944,  931,  936,  943,  940,  936,  947,  943,  948,
+      950,  948,  901,  941,  939,  958,  939,  942,  944,  959,
+      960,  943,  947,  961,  947,  962,  948,  950,  963,  958,
+      988,  964,  958,  964,  966,  961,  959,  960,  970,  987,
+
+      961,  966,  962,  900,  966,  963,  968,  963,  964,  967,
+      967,  967,  969,  968,  971,  970,  968,  967,  974,  969,
+      967,  973,  969,  973,  976,  978,  979,  990,  985,  978,
+      979,  971,  988, 1004,  899,  974,  989,  987,  973,  985,
+      989,  976,  978,  979,  990,  985,  993,  994, 1002, 1003,
+     1004, 1003, 1005,  989, 1006,  994, 1016,  993, 1006, 1013,
+     1005, 1002,  898,  993,  994, 1002, 1003, 1014, 1019, 1005,
+      897, 1006, 1008, 1008, 1008, 1010, 1013, 1023, 1026, 1010,
+     1008, 1027, 1026, 1008, 1014, 1019, 1032, 1019, 1034, 1016,
+     1035, 1046, 1010, 1033, 1023, 1026, 1047, 1033, 1027, 1027,
+
+     1057, 1034, 1065, 1032, 1052, 1034, 1039, 1035, 1046, 1039,
+     1033, 1037, 1037, 1037, 1058, 1067, 1053, 1057, 1058, 1037,
+     1062, 1052, 1037, 1039, 1053,  895, 1059, 1052, 1059, 1047,
+     1071, 1058, 1072, 1053, 1060, 1060, 1060, 1062, 1075, 1083,
+     1062, 1079, 1060, 1103, 1089, 1060, 1072, 1071, 1087, 1072,
+     1065, 1089, 1067, 1109, 1089, 1075, 1076, 1076, 1079, 1076,
+     1094, 1087,  892, 1076, 1076, 1087, 1095, 1076, 1107, 1110,
+     1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1077, 1077,
+     1077, 1092, 1104, 1108, 1113, 1092, 1077, 1083, 1114, 1077,
+     1090, 1109, 1112, 1094, 1090, 1090, 1103, 1090, 1092, 1095,
+
+     1090, 1090, 1090, 1097, 1101, 1090, 1116, 1118, 1090, 1090,
+     1090, 1090, 1090, 1090, 1090, 1090, 1098, 1099, 1119, 1107,
+     1097, 1101, 1110, 1098, 1099, 1112, 1098, 1099, 1120, 1104,
+     1145, 1108, 1145, 1146, 1147, 1146, 1147, 1113, 1149,  891,
+     1149, 1114, 1150,  882, 1150, 1118, 1151, 1157, 1151, 1157,
+      878, 1158, 1119, 1158,  873,  872,  869, 1116,  868,  863,
+      833,  832,  831,  830,  829,  828,  827,  826,  824,  818,
+      804,  802,  798,  793,  791,  790,  783,  782,  781,  778,
+      777, 1120, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124,
+     1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1125,
+
+     1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
+     1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126,  776, 1126,
+     1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126,
+     1126, 1126, 1126, 1127, 1127,  730, 1127, 1127, 1127, 1127,
+     1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
+     1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128,
+     1128, 1128, 1128, 1128, 1128, 1128, 1128, 1129, 1129, 1129,
+     1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
+     1129, 1129, 1129, 1129, 1130, 1130,  729,  728,  727,  726,
+     1130, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
+
+     1131, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132,
+     1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1133,  725,
+     1133,  724, 1133, 1133,  722,  718,  717,  713, 1133, 1134,
+     1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134, 1134,
+     1134, 1134, 1134, 1134, 1134, 1134, 1135, 1135, 1135, 1135,
+     1135, 1135, 1135, 1135, 1135, 1135,  695, 1135, 1135, 1135,
+     1135,  694, 1135, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
+     1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
+     1137,  692,  691, 1137, 1137, 1138, 1138, 1138, 1138,  685,
+     1138, 1138,  683, 1138, 1138,  675, 1138, 1138,  662,  660,
+
+     1138, 1138, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139,
+     1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1140,
+      653, 1140,  651,  636, 1140, 1141,  589, 1141,  588, 1141,
+     1141, 1142, 1142,  586, 1142, 1142, 1142, 1142, 1142, 1142,
+     1142, 1142, 1142, 1142, 1142, 1142, 1142, 1142, 1143, 1143,
+     1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143, 1143,
+     1143, 1143, 1143, 1143, 1143, 1144, 1144, 1144, 1144, 1144,
+     1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144, 1144,
+     1144, 1144, 1148,  585,  583, 1148, 1148, 1154,  582, 1154,
+      575,  556,  551,  549, 1154,  546,  543,  530,  524,  523,
+
+      515,  514, 1154, 1155,  513, 1155,  512,  511, 1155, 1156,
+      510, 1156,  454, 1156, 1156, 1159,  429, 1159,  409,  400,
+     1159, 1160,  398, 1160,  397, 1160, 1160, 1161, 1161,  391,
+     1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
+     1161, 1161, 1161, 1161, 1162, 1162,  389, 1162, 1162, 1162,
+     1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162,
+     1162, 1163, 1163,  375, 1163, 1163, 1163, 1163, 1163, 1163,
+     1163, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1164, 1164,
+     1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164,
+     1164, 1164, 1164, 1164, 1164, 1165, 1165, 1165, 1165, 1165,
+
+     1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165,
+     1165, 1165, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166,
+     1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1167,
+      374, 1167,  372, 1167, 1167, 1168, 1168,  371, 1168, 1168,
+     1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
+     1168, 1168, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169,
+     1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1170,
+     1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170,
+     1170, 1170, 1170, 1170, 1170, 1170, 1171, 1171,  365, 1171,
+     1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171,
+
+     1171, 1171, 1171, 1172, 1172,  358, 1172, 1172, 1172, 1172,
+     1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172,
+     1173, 1173,  353, 1173, 1173, 1173, 1173, 1173, 1173, 1173,
+     1173, 1173, 1173, 1173, 1173, 1173, 1173, 1174, 1174, 1174,
+     1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174,
+     1174, 1174, 1174, 1174, 1175, 1175, 1175, 1175, 1175, 1175,
+     1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175,
+     1175, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176,
+     1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1177, 1177,
+     1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
+
+     1177, 1177, 1177, 1177, 1177, 1178, 1178, 1178, 1178, 1178,
+     1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178,
+     1178, 1178, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
+     1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,  345,
+      344,  334,  333,  332,  331,  330,  329,  328,  326,  262,
+      244,  243,  237,  236,  235,  233,  232,  231,  230,  228,
+      213,  212,  210,  209,  204,  198,  195,  192,  178,  173,
+      171,  170,  167,  101,  100,   96,   95,   82,   81,   77,
+       76,   75,   69,   68,   63,   58,   13,    7, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
+     1123, 1123
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "fortran.lex"
+#define INITIAL 0
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#define parameter 1
+
+#define character 2
+
+#define donottreat 3
+
+#define fortran77style 4
+
+#define fortran90style 5
+
+#line 41 "fortran.lex"
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+extern FILE * yyin;
+#define MAX_INCLUDE_DEPTH 30
+#define tabsize 6
+YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+int line_num_fortran=1;
+int line_num_fortran_common=1;
+int newlinef90 = 0;
+char *tmp;
+char tmpc;
+/******************************************************************************/
+/**************PETITS PB NON PREVUS *******************************************/
+/******************************************************************************/
+/* NEXTLINF77 un ligne fortran 77 peut commencer par -      &a=b or on        */
+/*            a prevu seulement       & a=b avec l'espace entre le symbole    */
+/*            de la 7eme et le debut de la ligne de commande                  */
+/*            le ! est aussi interdit comme symbole de la 7 eme colonne       */
+/*            Normalement NEXTLINEF77 \n+[ ]{5}[^ ]                           */
+/******************************************************************************/
+#define YY_USER_ACTION \
+        {\
+           if (firstpass == 0) \
+           {\
+              strcat(curbuf,yytext); \
+              Save_Length(curbuf,38); \
+              strcpy(motparse,yytext);\
+              Save_Length(motparse,32); \
+              colnum = colnum + strlen(motparse);\
+              ECHO; \
+           }\
+           strcpy(motparse1,yytext);\
+           /*printf("yytext = %s\n",yytext);*/\
+        /*if ( firstpass == 1 ) 
+                      printf("yytext = %s %d\n",yytext,strlen(yytext));*/\
+        }
+#line 1783 "fortran.yy.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( yy_current_buffer->yy_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( yyin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+		  && ferror( yyin ) ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	if ( yyleng > 0 ) \
+		yy_current_buffer->yy_at_bol = \
+				(yytext[yyleng - 1] == '\n'); \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+
+#line 106 "fortran.lex"
+
+  if (infixed) BEGIN(fortran77style) ;
+  if (infree) BEGIN(fortran90style)  ;
+
+#line 1942 "fortran.yy.c"
+
+	if ( yy_init )
+		{
+		yy_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! yy_start )
+			yy_start = 1;	/* first start state */
+
+		if ( ! yyin )
+			yyin = stdin;
+
+		if ( ! yyout )
+			yyout = stdout;
+
+		if ( ! yy_current_buffer )
+			yy_current_buffer =
+				yy_create_buffer( yyin, YY_BUF_SIZE );
+
+		yy_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yy_c_buf_p;
+
+		/* Support of yytext. */
+		*yy_cp = yy_hold_char;
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+		yy_current_state = yy_start;
+		yy_current_state += YY_AT_BOL();
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				yy_last_accepting_state = yy_current_state;
+				yy_last_accepting_cpos = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 1124 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 4189 );
+
+yy_find_action:
+		yy_act = yy_accept[yy_current_state];
+		if ( yy_act == 0 )
+			{ /* have to back up */
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			yy_act = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = yy_hold_char;
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 110 "fortran.lex"
+return TOK_DEBUT;
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 111 "fortran.lex"
+return TOK_FIN;
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 112 "fortran.lex"
+return TOK_OMP;
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 113 "fortran.lex"
+return TOK_DOLLAR;
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 115 "fortran.lex"
+{return TOK_REAL8;}
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 116 "fortran.lex"
+{return TOK_SUBROUTINE;}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 117 "fortran.lex"
+{return TOK_PROGRAM;}
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 118 "fortran.lex"
+{inallocate = 1; return TOK_ALLOCATE;}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 119 "fortran.lex"
+{inallocate = 1; return TOK_DEALLOCATE;}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 120 "fortran.lex"
+{return TOK_RESULT;}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 121 "fortran.lex"
+{return TOK_FUNCTION;}
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 122 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDSUBROUTINE;}
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 123 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDPROGRAM;}
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 124 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDFUNCTION;}
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 125 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_ENDUNIT;}
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 126 "fortran.lex"
+return TOK_INCLUDE;
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 127 "fortran.lex"
+{
+                            strcpy(yylval.na,yytext);
+                            tmpc = input();
+                            unput(tmpc);
+                            if ( (
+                               tmpc >= 'a' && tmpc <= 'z'
+                                  ) || (
+                               tmpc >= 'A' && tmpc <= 'Z'
+                               )  )
+                               {
+                                  return TOK_USE;
+                               }
+                               else
+                               {
+                                  return TOK_NAME;
+                               }
+                         }
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 144 "fortran.lex"
+{return TOK_REWIND;}
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 145 "fortran.lex"
+return TOK_IMPLICIT;
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 146 "fortran.lex"
+return TOK_NONE;
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 147 "fortran.lex"
+return TOK_CALL;
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 148 "fortran.lex"
+return TOK_TRUE;
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 149 "fortran.lex"
+return TOK_FALSE;
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 150 "fortran.lex"
+{return TOK_POINT_TO;}
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 151 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DASTER;}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 152 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_EQV;}
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 153 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_EQ;}
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 154 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_GT;}
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 155 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_GE;}
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 156 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LT;}
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 157 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LE;}
+	YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 158 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NEQV;}
+	YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 159 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NE;}
+	YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 160 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NOT;}
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 161 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_OR;}
+	YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 162 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_XOR;}
+	YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 163 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_AND;}
+	YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 164 "fortran.lex"
+{return TOK_MODULE;}
+	YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 165 "fortran.lex"
+{return TOK_DOWHILE;}
+	YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 166 "fortran.lex"
+return TOK_ENDMODULE;
+	YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 167 "fortran.lex"
+return TOK_ENDDO;
+	YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 168 "fortran.lex"
+{return TOK_PLAINDO;}
+	YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 169 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_REAL;}
+	YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 170 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_INTEGER;}
+	YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 171 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_LOGICAL;}
+	YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 172 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHARACTER;}
+	YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 173 "fortran.lex"
+{return TOK_ALLOCATABLE;}
+	YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 174 "fortran.lex"
+return TOK_CLOSE;
+	YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 175 "fortran.lex"
+return TOK_INQUIRE;
+	YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 176 "fortran.lex"
+{return TOK_DIMENSION;}
+	YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 177 "fortran.lex"
+return TOK_PAUSE;
+	YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 178 "fortran.lex"
+return TOK_EQUIVALENCE;
+	YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 179 "fortran.lex"
+return TOK_STOP;
+	YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 180 "fortran.lex"
+return TOK_WHERE;
+	YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 181 "fortran.lex"
+return TOK_ENDWHERE;
+	YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 182 "fortran.lex"
+return TOK_ELSEWHERE;
+	YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 183 "fortran.lex"
+{return TOK_COMPLEX;}
+	YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 184 "fortran.lex"
+{return TOK_CONTAINS;}
+	YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 185 "fortran.lex"
+{return TOK_ONLY;}
+	YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 186 "fortran.lex"
+{return TOK_PARAMETER;}
+	YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 187 "fortran.lex"
+{return TOK_RECURSIVE;}
+	YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 188 "fortran.lex"
+{return TOK_COMMON;}
+	YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 189 "fortran.lex"
+{return TOK_GLOBAL;}
+	YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 190 "fortran.lex"
+{return TOK_EXTERNAL;}
+	YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 191 "fortran.lex"
+{return TOK_INTENT;}
+	YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 192 "fortran.lex"
+{return TOK_POINTER;}
+	YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 193 "fortran.lex"
+{return TOK_OPTIONAL;}
+	YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 194 "fortran.lex"
+{return TOK_SAVE;}
+	YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 195 "fortran.lex"
+{return TOK_TYPE;}
+	YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 196 "fortran.lex"
+{return TOK_TYPEPAR;}
+	YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 197 "fortran.lex"
+{if (inallocate == 1) return TOK_STAT; else {strcpy(yylval.na,yytext);return TOK_NAME;}}
+	YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 198 "fortran.lex"
+{return TOK_ENDTYPE;}
+	YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 199 "fortran.lex"
+return TOK_OPEN;
+	YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 200 "fortran.lex"
+return TOK_RETURN;
+	YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 201 "fortran.lex"
+return TOK_EXIT;
+	YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 202 "fortran.lex"
+return TOK_PRINT;
+	YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 203 "fortran.lex"
+{return TOK_PROCEDURE;}
+	YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 204 "fortran.lex"
+{return TOK_READ;}
+	YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 205 "fortran.lex"
+{return TOK_NAMELIST;}
+	YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 206 "fortran.lex"
+{return TOK_WRITE;}
+	YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 207 "fortran.lex"
+{return TOK_TARGET;}
+	YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 208 "fortran.lex"
+{return TOK_PUBLIC;}
+	YY_BREAK
+case 83:
+YY_RULE_SETUP
+#line 209 "fortran.lex"
+{return TOK_PRIVATE;}
+	YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 210 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_IN;}
+	YY_BREAK
+case 85:
+YY_RULE_SETUP
+#line 211 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DATA;}
+	YY_BREAK
+case 86:
+YY_RULE_SETUP
+#line 212 "fortran.lex"
+return TOK_CONTINUE;
+	YY_BREAK
+case 87:
+YY_RULE_SETUP
+#line 213 "fortran.lex"
+{return TOK_PLAINGOTO;}
+	YY_BREAK
+case 88:
+YY_RULE_SETUP
+#line 214 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_OUT;}
+	YY_BREAK
+case 89:
+YY_RULE_SETUP
+#line 215 "fortran.lex"
+{strcpy(yylval.nac,yytext);return TOK_INOUT;}
+	YY_BREAK
+case 90:
+YY_RULE_SETUP
+#line 216 "fortran.lex"
+{return TOK_INTRINSIC;}
+	YY_BREAK
+case 91:
+YY_RULE_SETUP
+#line 217 "fortran.lex"
+{return TOK_THEN;}
+	YY_BREAK
+case 92:
+YY_RULE_SETUP
+#line 218 "fortran.lex"
+{return TOK_ELSEIF;}
+	YY_BREAK
+case 93:
+YY_RULE_SETUP
+#line 219 "fortran.lex"
+{return TOK_ELSE;}
+	YY_BREAK
+case 94:
+YY_RULE_SETUP
+#line 220 "fortran.lex"
+{return TOK_ENDIF;}
+	YY_BREAK
+case 95:
+YY_RULE_SETUP
+#line 221 "fortran.lex"
+{return TOK_LOGICALIF;}
+	YY_BREAK
+case 96:
+YY_RULE_SETUP
+#line 222 "fortran.lex"
+{return TOK_SUM;}
+	YY_BREAK
+case 97:
+YY_RULE_SETUP
+#line 223 "fortran.lex"
+{return TOK_MAX;}
+	YY_BREAK
+case 98:
+YY_RULE_SETUP
+#line 224 "fortran.lex"
+{return TOK_TANH;}
+	YY_BREAK
+case 99:
+YY_RULE_SETUP
+#line 225 "fortran.lex"
+{return TOK_MAXVAL;}
+	YY_BREAK
+case 100:
+YY_RULE_SETUP
+#line 226 "fortran.lex"
+{return TOK_TRIM;}
+	YY_BREAK
+case 101:
+YY_RULE_SETUP
+#line 227 "fortran.lex"
+{return TOK_SQRT;}
+	YY_BREAK
+case 102:
+YY_RULE_SETUP
+#line 228 "fortran.lex"
+{return TOK_SELECTCASE;}
+	YY_BREAK
+case 103:
+YY_RULE_SETUP
+#line 229 "fortran.lex"
+{return TOK_CASE;}
+	YY_BREAK
+case 104:
+YY_RULE_SETUP
+#line 230 "fortran.lex"
+{return TOK_CASEDEFAULT;}
+	YY_BREAK
+case 105:
+YY_RULE_SETUP
+#line 231 "fortran.lex"
+{return TOK_ENDSELECT;}
+	YY_BREAK
+case 106:
+YY_RULE_SETUP
+#line 232 "fortran.lex"
+{return TOK_FILE;}
+	YY_BREAK
+case 107:
+YY_RULE_SETUP
+#line 233 "fortran.lex"
+{return TOK_END;}
+	YY_BREAK
+case 108:
+YY_RULE_SETUP
+#line 234 "fortran.lex"
+{return TOK_ERR;}
+	YY_BREAK
+case 109:
+YY_RULE_SETUP
+#line 235 "fortran.lex"
+{return TOK_EXIST;}
+	YY_BREAK
+case 110:
+YY_RULE_SETUP
+#line 236 "fortran.lex"
+{return TOK_MIN;}
+	YY_BREAK
+case 111:
+YY_RULE_SETUP
+#line 237 "fortran.lex"
+{return TOK_NINT;}
+	YY_BREAK
+case 112:
+YY_RULE_SETUP
+#line 238 "fortran.lex"
+{return TOK_FLOAT;}
+	YY_BREAK
+case 113:
+YY_RULE_SETUP
+#line 239 "fortran.lex"
+{return TOK_EXP;}
+	YY_BREAK
+case 114:
+YY_RULE_SETUP
+#line 240 "fortran.lex"
+{return TOK_COS;}
+	YY_BREAK
+case 115:
+YY_RULE_SETUP
+#line 241 "fortran.lex"
+{return TOK_COSH;}
+	YY_BREAK
+case 116:
+YY_RULE_SETUP
+#line 242 "fortran.lex"
+{return TOK_ACOS;}
+	YY_BREAK
+case 117:
+YY_RULE_SETUP
+#line 243 "fortran.lex"
+{return TOK_SIN;}
+	YY_BREAK
+case 118:
+YY_RULE_SETUP
+#line 244 "fortran.lex"
+{return TOK_SINH;}
+	YY_BREAK
+case 119:
+YY_RULE_SETUP
+#line 245 "fortran.lex"
+{return TOK_ASIN;}
+	YY_BREAK
+case 120:
+YY_RULE_SETUP
+#line 246 "fortran.lex"
+{return TOK_LOG;}
+	YY_BREAK
+case 121:
+YY_RULE_SETUP
+#line 247 "fortran.lex"
+{return TOK_TAN;}
+	YY_BREAK
+case 122:
+YY_RULE_SETUP
+#line 248 "fortran.lex"
+{return TOK_ATAN;}
+	YY_BREAK
+case 123:
+YY_RULE_SETUP
+#line 249 "fortran.lex"
+{return TOK_CYCLE;}
+	YY_BREAK
+case 124:
+YY_RULE_SETUP
+#line 250 "fortran.lex"
+{return TOK_ABS;}
+	YY_BREAK
+case 125:
+YY_RULE_SETUP
+#line 251 "fortran.lex"
+{return TOK_MOD;}
+	YY_BREAK
+case 126:
+YY_RULE_SETUP
+#line 252 "fortran.lex"
+{return TOK_SIGN;}
+	YY_BREAK
+case 127:
+YY_RULE_SETUP
+#line 253 "fortran.lex"
+{return TOK_MINLOC;}
+	YY_BREAK
+case 128:
+YY_RULE_SETUP
+#line 254 "fortran.lex"
+{return TOK_MAXLOC;}
+	YY_BREAK
+case 129:
+YY_RULE_SETUP
+#line 255 "fortran.lex"
+{return TOK_MINVAL;}
+	YY_BREAK
+case 130:
+YY_RULE_SETUP
+#line 256 "fortran.lex"
+{return TOK_INTERFACE;}
+	YY_BREAK
+case 131:
+YY_RULE_SETUP
+#line 257 "fortran.lex"
+{return TOK_BACKSPACE;}
+	YY_BREAK
+case 132:
+YY_RULE_SETUP
+#line 258 "fortran.lex"
+{return TOK_ENDINTERFACE;}
+	YY_BREAK
+case 133:
+YY_RULE_SETUP
+#line 259 "fortran.lex"
+{return TOK_LEFTAB;}
+	YY_BREAK
+case 134:
+YY_RULE_SETUP
+#line 260 "fortran.lex"
+{return TOK_RIGHTAB;}
+	YY_BREAK
+case 135:
+YY_RULE_SETUP
+#line 261 "fortran.lex"
+{return TOK_FORMAT;}
+	YY_BREAK
+case 136:
+YY_RULE_SETUP
+#line 262 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;}
+	YY_BREAK
+case 137:
+YY_RULE_SETUP
+#line 263 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;}
+	YY_BREAK
+case 138:
+YY_RULE_SETUP
+#line 264 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_SLASH;}
+	YY_BREAK
+case 139:
+YY_RULE_SETUP
+#line 265 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_DSLASH;}
+	YY_BREAK
+case 140:
+YY_RULE_SETUP
+#line 266 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_CUT;}
+	YY_BREAK
+case 141:
+YY_RULE_SETUP
+#line 267 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_CONSTANT;}
+	YY_BREAK
+case 142:
+YY_RULE_SETUP
+#line 268 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_MESSAGE;}
+	YY_BREAK
+case 143:
+YY_RULE_SETUP
+#line 269 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CHAR_INT;}
+	YY_BREAK
+case 144:
+YY_RULE_SETUP
+#line 270 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_NAME;}
+	YY_BREAK
+case 145:
+YY_RULE_SETUP
+#line 271 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+	YY_BREAK
+case 146:
+YY_RULE_SETUP
+#line 272 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREALDP;}
+	YY_BREAK
+case 147:
+YY_RULE_SETUP
+#line 273 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREALQP;}
+	YY_BREAK
+case 148:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 274 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTREAL;}
+	YY_BREAK
+case 149:
+YY_RULE_SETUP
+#line 275 "fortran.lex"
+{strcpy(yylval.na,yytext);return TOK_CSTINT;}
+	YY_BREAK
+case 150:
+YY_RULE_SETUP
+#line 276 "fortran.lex"
+{}
+	YY_BREAK
+case 151:
+YY_RULE_SETUP
+#line 277 "fortran.lex"
+{return TOK_QUOTE;}
+	YY_BREAK
+case 152:
+YY_RULE_SETUP
+#line 278 "fortran.lex"
+{}
+	YY_BREAK
+case 153:
+YY_RULE_SETUP
+#line 279 "fortran.lex"
+{strcpy(yylval.na,yytext);return (int) *yytext;}
+	YY_BREAK
+case 154:
+YY_RULE_SETUP
+#line 280 "fortran.lex"
+{return TOK_SEMICOLON;}
+	YY_BREAK
+case 155:
+YY_RULE_SETUP
+#line 281 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 156:
+YY_RULE_SETUP
+#line 282 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 157:
+YY_RULE_SETUP
+#line 283 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 158:
+YY_RULE_SETUP
+#line 284 "fortran.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 159:
+YY_RULE_SETUP
+#line 285 "fortran.lex"
+{colnum=0;line_num_fortran++;line_num_fortran_common++; return (int) *yytext;}
+	YY_BREAK
+case 160:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 286 "fortran.lex"
+
+	YY_BREAK
+case 161:
+YY_RULE_SETUP
+#line 287 "fortran.lex"
+{if (newlinef90 == 0) return TOK_LABEL; else newlinef90 = 0;}
+	YY_BREAK
+case 162:
+YY_RULE_SETUP
+#line 288 "fortran.lex"
+
+	YY_BREAK
+case 163:
+YY_RULE_SETUP
+#line 289 "fortran.lex"
+{colnum=colnum-1+tabsize;}
+	YY_BREAK
+case 164:
+YY_RULE_SETUP
+#line 290 "fortran.lex"
+;
+	YY_BREAK
+case 165:
+YY_RULE_SETUP
+#line 291 "fortran.lex"
+{line_num_fortran++;line_num_fortran_common++;newlinef90=1;colnum=0;}
+	YY_BREAK
+case 166:
+YY_RULE_SETUP
+#line 292 "fortran.lex"
+{line_num_fortran++;line_num_fortran_common++;colnum=0;}
+	YY_BREAK
+case 167:
+YY_RULE_SETUP
+#line 293 "fortran.lex"
+{
+                           convert2lower(motparse1);
+                           if ( strncasecmp(motparse1,"contains",8) == 0 )
+                           {
+                              return TOK_CONTAINS;
+                           }
+                           else
+                           {
+                              colnum=0;line_num_fortran++;line_num_fortran_common++;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                           }
+                         }
+	YY_BREAK
+case 168:
+YY_RULE_SETUP
+#line 306 "fortran.lex"
+BEGIN(donottreat);
+	YY_BREAK
+case 169:
+YY_RULE_SETUP
+#line 307 "fortran.lex"
+BEGIN(INITIAL);
+	YY_BREAK
+case 170:
+YY_RULE_SETUP
+#line 308 "fortran.lex"
+
+	YY_BREAK
+case 171:
+YY_RULE_SETUP
+#line 309 "fortran.lex"
+{
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+	YY_BREAK
+case 172:
+YY_RULE_SETUP
+#line 314 "fortran.lex"
+{
+                             colnum = 0;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
+                          }
+	YY_BREAK
+case 173:
+YY_RULE_SETUP
+#line 319 "fortran.lex"
+ECHO;
+	YY_BREAK
+#line 2933 "fortran.yy.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(parameter):
+case YY_STATE_EOF(character):
+case YY_STATE_EOF(donottreat):
+case YY_STATE_EOF(fortran77style):
+case YY_STATE_EOF(fortran90style):
+	yyterminate();
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = yy_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed yyin at a new source and called
+			 * yylex().  If so, then we have to assure
+			 * consistency between yy_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			yy_n_chars = yy_current_buffer->yy_n_chars;
+			yy_current_buffer->yy_input_file = yyin;
+			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++yy_c_buf_p;
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+				yy_cp = yy_c_buf_p;
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				yy_did_buffer_switch_on_eof = 0;
+
+				if ( yywrap() )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * yytext, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				yy_c_buf_p =
+					yytext_ptr + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				yy_c_buf_p =
+				&yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+	{
+	register char *dest = yy_current_buffer->yy_ch_buf;
+	register char *source = yytext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( yy_current_buffer->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = yy_current_buffer;
+
+			int yy_c_buf_p_offset =
+				(int) (yy_c_buf_p - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					yy_flex_realloc( (void *) b->yy_ch_buf,
+							 b->yy_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = yy_current_buffer->yy_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+			yy_n_chars, num_to_read );
+
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	if ( yy_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			yyrestart( yyin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			yy_current_buffer->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	yy_n_chars += number_to_move;
+	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+
+	yy_current_state = yy_start;
+	yy_current_state += YY_AT_BOL();
+
+	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+		{
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		if ( yy_accept[yy_current_state] )
+			{
+			yy_last_accepting_state = yy_current_state;
+			yy_last_accepting_cpos = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 1124 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
+
+	return yy_current_state;
+	}
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+	{
+	register int yy_is_jam;
+	register char *yy_cp = yy_c_buf_p;
+
+	register YY_CHAR yy_c = 1;
+	if ( yy_accept[yy_current_state] )
+		{
+		yy_last_accepting_state = yy_current_state;
+		yy_last_accepting_cpos = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 1124 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 1123);
+
+	return yy_is_jam ? 0 : yy_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+	{
+	register char *yy_cp = yy_c_buf_p;
+
+	/* undo effects of setting up yytext */
+	*yy_cp = yy_hold_char;
+
+	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = yy_n_chars + 2;
+		register char *dest = &yy_current_buffer->yy_ch_buf[
+					yy_current_buffer->yy_buf_size + 2];
+		register char *source =
+				&yy_current_buffer->yy_ch_buf[number_to_move];
+
+		while ( source > yy_current_buffer->yy_ch_buf )
+			*--dest = *--source;
+
+		yy_cp += (int) (dest - source);
+		yy_bp += (int) (dest - source);
+		yy_current_buffer->yy_n_chars =
+			yy_n_chars = yy_current_buffer->yy_buf_size;
+
+		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--yy_cp = (char) c;
+
+
+	yytext_ptr = yy_bp;
+	yy_hold_char = *yy_cp;
+	yy_c_buf_p = yy_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*yy_c_buf_p = yy_hold_char;
+
+	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			/* This was really a NUL. */
+			*yy_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = yy_c_buf_p - yytext_ptr;
+			++yy_c_buf_p;
+
+			switch ( yy_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					yyrestart( yyin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( yywrap() )
+						return EOF;
+
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					yy_c_buf_p = yytext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
+	*yy_c_buf_p = '\0';	/* preserve yytext */
+	yy_hold_char = *++yy_c_buf_p;
+
+	yy_current_buffer->yy_at_bol = (c == '\n');
+
+	return c;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! yy_current_buffer )
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+	yy_init_buffer( yy_current_buffer, input_file );
+	yy_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( yy_current_buffer == new_buffer )
+		return;
+
+	if ( yy_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*yy_c_buf_p = yy_hold_char;
+		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	yy_current_buffer = new_buffer;
+	yy_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (yywrap()) processing, but the only time this flag
+	 * is looked at is after yywrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	yy_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+	{
+	yy_n_chars = yy_current_buffer->yy_n_chars;
+	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+	yyin = yy_current_buffer->yy_input_file;
+	yy_hold_char = *yy_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	yy_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == yy_current_buffer )
+		yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		yy_flex_free( (void *) b->yy_ch_buf );
+
+	yy_flex_free( (void *) b );
+	}
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	yy_flush_buffer( b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->yy_is_interactive = 0;
+#else
+	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == yy_current_buffer )
+		yy_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	yy_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+	{
+	int len;
+	for ( len = 0; yy_str[len]; ++len )
+		;
+
+	return yy_scan_bytes( yy_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) yy_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = yy_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( yy_start_stack_ptr >= yy_start_stack_depth )
+		{
+		yy_size_t new_size;
+
+		yy_start_stack_depth += YY_START_STACK_INCR;
+		new_size = yy_start_stack_depth * sizeof( int );
+
+		if ( ! yy_start_stack )
+			yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+		else
+			yy_start_stack = (int *) yy_flex_realloc(
+					(void *) yy_start_stack, new_size );
+
+		if ( ! yy_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+	{
+	if ( --yy_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(yy_start_stack[yy_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+	{
+	return yy_start_stack[yy_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		yytext[yyleng] = yy_hold_char; \
+		yy_c_buf_p = yytext + n; \
+		yy_hold_char = *yy_c_buf_p; \
+		*yy_c_buf_p = '\0'; \
+		yyleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	yylex();
+	return 0;
+	}
+#endif
+#line 319 "fortran.lex"
+
+
+fortranerror(char *s)
+{
+   if (!strcasecmp(curfile,mainfile))
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran,curfile);
+   }
+   else
+   {
+      printf("%s line %d, file %s\n",s,line_num_fortran_common,curfile);
+   }
+   /*exit(0);*/
+}
+
+int fortranwrap()
+{
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/main.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/main.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/main.c	(revision 1844)
@@ -0,0 +1,2426 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
+#endif
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define yyclearin (yychar=(-1))
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING (yyerrflag!=0)
+#define YYPREFIX "yy"
+#line 36 "convert.y"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+#line 42 "convert.y"
+typedef union {
+       int ival;
+       char na[LONG_C];
+       listnom * ln;
+       } YYSTYPE;
+#line 23 "y.tab.c"
+#define TOK_SEP 257
+#define TOK_USE 258
+#define TOK_MODULEMAIN 259
+#define TOK_NOTGRIDDEP 260
+#define TOK_USEITEM 261
+#define TOK_NAME 262
+#define TOK_PROBTYPE 263
+#define YYERRCODE 256
+short yylhs[] = {                                        -1,
+    0,    0,    1,    1,    1,    1,    1,    1,    1,
+};
+short yylen[] = {                                         2,
+    0,    2,    1,    3,    5,    7,    3,    4,    3,
+};
+short yydefred[] = {                                      1,
+    0,    0,    0,    0,    0,    3,    2,    0,    0,    0,
+    0,    9,    7,    0,    0,    4,    8,    0,    0,    5,
+    0,    6,
+};
+short yydgoto[] = {                                       1,
+    7,
+};
+short yysindex[] = {                                      0,
+  -10, -258, -257, -253, -256,    0,    0,  -52,  -51, -252,
+  -43,    0,    0,  -50, -251,    0,    0,  -42, -250,    0,
+  -46,    0,
+};
+short yyrindex[] = {                                      0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,
+};
+short yygindex[] = {                                      0,
+    0,
+};
+#define YYTABLESIZE 253
+short yytable[] = {                                       6,
+   15,   19,    8,   10,    9,   11,   12,   13,   17,   14,
+   18,   21,   22,    0,    0,   16,   20,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    2,    3,    4,
+    0,    0,    5,
+};
+short yycheck[] = {                                      10,
+   44,   44,  261,  257,  262,  262,   59,   59,   59,  262,
+  262,  262,   59,   -1,   -1,   59,   59,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,  260,
+   -1,   -1,  263,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 1
+#endif
+#define YYMAXTOKEN 263
+#if YYDEBUG
+char *yyname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'","';'",0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+"TOK_SEP","TOK_USE","TOK_MODULEMAIN","TOK_NOTGRIDDEP","TOK_USEITEM","TOK_NAME",
+"TOK_PROBTYPE",
+};
+char *yyrule[] = {
+"$accept : input",
+"input :",
+"input : input line",
+"line : '\\n'",
+"line : TOK_PROBTYPE TOK_NAME ';'",
+"line : TOK_PROBTYPE TOK_NAME ',' TOK_NAME ';'",
+"line : TOK_PROBTYPE TOK_NAME ',' TOK_NAME ',' TOK_NAME ';'",
+"line : TOK_MODULEMAIN TOK_NAME ';'",
+"line : TOK_NOTGRIDDEP TOK_SEP TOK_NAME ';'",
+"line : TOK_USE TOK_USEITEM ';'",
+};
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short yyss[YYSTACKSIZE];
+YYSTYPE yyvs[YYSTACKSIZE];
+#define yystacksize YYSTACKSIZE
+#line 83 "convert.y"
+
+int main(int argc,char *argv[])
+{
+   extern FILE * yyin ;
+   FILE *dependglobaloutput;
+   int i;
+   listnom *parcours;
+   listvar *newvar;
+   int stylegiven = 0;
+   int infreegiven ;
+   int infixedgiven ;
+   int lengthmainfile;
+
+   if (argc < 2)
+   {
+       printf("usage : conv <file> [-rm] [-incdir <directory>] \n");
+       printf(" [-comdirin   <directory>] [-comdirout <directory>]\n");
+       printf(" [-convfile  <FILENAME >] -SubloopScalar -SubloopScalar1 \n");
+       printf(" [-free|-fixed]\n");
+       exit(0);
+   }
+/******************************************************************************/
+/*  1-  Variables initialization                                              */
+/******************************************************************************/
+   List_Global_Var=(listvar *)NULL;
+   List_GlobalParameter_Var=(listvar *)NULL;
+   List_Allocate_Var=(listallocate *)NULL;
+   List_Common_Var=(listvar *)NULL;
+   List_SubroutineWhereAgrifUsed=(listnom *)NULL;
+   List_Subroutine_For_Alloc=(listnom *)NULL;
+   List_Include=(listusemodule *)NULL;
+   List_NameOfModuleUsed=(listusemodule *)NULL;
+   listofmoduletmp=(listusemodule *)NULL;
+   List_SubroutineDeclaration_Var=(listvar *)NULL;
+   List_UsedInSubroutine_Var=(listvar *)NULL;
+   List_NotGridDepend_Var=(listvar *)NULL;
+   Listofavailableindices=(listindice *)NULL;
+   List_CouplePointed_Var=(listvarpointtovar *)NULL;
+   List_ModuleUsed_Var = (listvar *)NULL;
+   List_ModuleUsedInModuleUsed_Var = (listvar *)NULL;
+   List_GlobParamModuleUsed_Var = (listparameter *)NULL;
+   List_GlobParamModuleUsedInModuleUsed_Var = (listparameter *)NULL;
+   List_SubroutineArgument_Var = (listvar *)NULL;
+   List_FunctionType_Var = (listvar *)NULL;
+   tmpuselocallist = (listusemodule *)NULL;
+   List_ContainsSubroutine = (listnom *)NULL;
+   oldfortranout = (FILE *)NULL;
+
+   strcpy(mainfile,argv[1]);
+   strcpy(nomdir,"AGRIF_INC");
+   strcpy(commondirin,".");
+   strcpy(commondirout,".");
+   strcpy(filetoparse," ");
+   strcpy(subofagrifinitgrids,"");
+   strcpy(meetagrifinitgrids,"");
+   strcpy(mpiinitvar,"");
+
+   length_last = 0 ;
+   length_first = 0 ;
+   length_v_typevar = 0 ;
+   length_v_nomvar = 0 ;
+   length_v_dimchar = 0 ;
+   length_v_modulename = 0 ;
+   length_v_commonname = 0 ;
+   length_v_vallengspec = 0 ;
+   length_v_nameinttypename = 0 ;
+   length_v_commoninfile = 0 ;
+   length_v_subroutinename = 0 ;
+   length_v_precision = 0 ;
+   length_v_IntentSpec = 0 ;
+   length_v_initialvalue = 0 ;
+   length_v_readedlistdimension = 0 ;
+   length_u_usemodule = 0 ;
+   length_u_charusemodule = 0 ;
+   length_u_cursubroutine = 0 ;
+   length_u_modulename = 0 ;
+   length_n_name = 0 ;
+   length_c_namevar = 0 ;
+   length_c_namepointedvar = 0 ;
+   length_o_nom = 0 ;
+   length_o_module = 0 ;
+   length_a_nomvar = 0 ;
+   length_a_subroutine = 0 ;
+   length_a_module = 0 ;
+   length_t_usemodule = 0 ;
+   length_t_cursubroutine = 0 ;
+   length_curfilename = 0 ;
+   length_nomfileoutput = 0 ;
+   length_motparse = 0 ;
+   length_mainfile = 0 ;
+   length_nomdir = 0 ;
+   length_commondirout = 0 ;
+   length_commondirin = 0 ;
+   length_filetoparse = 0 ;
+   length_curbuf = 0 ;
+   length_toprintglob = 0 ;
+   length_tmpvargridname = 0 ;
+   length_ligne_Subloop = 0 ;
+   length_lvargridname_toamr = 0 ;
+   length_toprint_utilagrif = 0 ;
+   length_toprinttmp_utilchar = 0 ;
+   length_ligne_writedecl = 0 ;
+   length_newname_toamr = 0 ;
+   length_newname_writedecl = 0 ;
+   length_ligne_toamr = 0 ;
+   length_tmpligne_writedecl = 0 ;
+   value_char_size = 0 ;
+   value_char_size1 = 0 ;
+   value_char_size2 = 0 ;
+   value_char_size3 = 0 ;
+   inallocate = 0;
+   infixed = 1;
+   infree  = 0;
+
+   checkexistcommon=1;
+   todebug=0;
+   onlyfixedgrids=0;
+   fixedgrids=0;
+   InAgrifParentDef = 0;
+   IndicenbmaillesX=0;
+   IndicenbmaillesY=0;
+   IndicenbmaillesZ=0;
+   created_dimensionlist = 1;
+   indicemaxtabvars = 0;   /* current indice in the table tabvars             */
+   SubloopScalar = 0;
+   todebug = 0;
+   todebugfree = 0;
+   retour77 = 1 ;
+   mark = 0 ;
+   shouldincludempif = 0 ;
+   Read_val_max();
+/******************************************************************************/
+/*  2-  Program arguments                                                     */
+/******************************************************************************/
+
+   if ((yyin=fopen(argv[1],"r"))==NULL)
+   {
+      printf("the file %s doesn't exist \n",argv[1]);
+      exit(0);
+   }
+
+   i=2;
+   while (i<argc)
+   {
+      if (!strcasecmp(argv[i],"-incdir"))
+      {
+         strcpy(nomdir,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-comdirin")) /* input directory           */
+      {
+         strcpy(commondirin,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-comdirout")) /* output directory         */
+      {
+         strcpy(commondirout,argv[i+1]);
+         i++;
+      }
+      else if (!strcasecmp(argv[i],"-convfile")) /* file to parse             */
+      {
+         strcpy(filetoparse,argv[i+1]);
+         i++;
+         lengthmainfile = strlen(filetoparse);
+         if (!strcasecmp(&filetoparse[lengthmainfile-4],".f90"))
+         {
+         infixed = 0;
+         infree = 1;
+         }
+         else
+         {
+         infixed = 1;
+         infree = 0;
+         }
+      }
+      else if (!strcasecmp(argv[i],"-free")) /* file to parse        */
+      {
+         stylegiven = 1;
+         infreegiven  = 1 ;
+         infixedgiven = 0;
+      }   
+      else if (!strcasecmp(argv[i],"-fixed")) /* file to parse        */
+      {
+         stylegiven = 1;
+         infreegiven  = 0;
+         infixedgiven = 1;
+      }         
+      else if (!strcasecmp(argv[i],"-SubloopScalar")) /* file to parse        */
+      {
+         SubloopScalar = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-SubloopScalar1")) /* file to parse       */
+      {
+         SubloopScalar = 2 ;
+      }
+      else if (!strcasecmp(argv[i],"-todebug")) /* file to parse       */
+      {
+         todebug = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-mark")) /* file to parse       */
+      {
+         mark = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-todebugfree")) /* file to parse       */
+      {
+         todebugfree = 1 ;
+      }
+      else if (!strcasecmp(argv[i],"-rm"))
+      {
+         checkexistcommon=0;
+      }
+      else
+      {
+         printf("Unkwon option : %s\n",argv[i]);
+         exit(0);
+      }
+      i++;
+   }
+
+   if (stylegiven == 1) 
+   {
+   infree = infreegiven;
+   infixed = infixedgiven;   
+   }
+   Save_Length(nomdir,34);
+   Save_Length(commondirout,35);
+   Save_Length(commondirin,36);
+   Save_Length(filetoparse,37);
+
+/******************************************************************************/
+/*  3-  Parsing of the  conv file <name>.in                                   */
+/******************************************************************************/
+
+   if ((yyin=fopen(argv[1],"r"))==NULL)
+   {
+       printf("the file %s doesn't exist \n",argv[1]);
+       exit(0);
+   }
+   strcpy(mainfile,argv[1]);
+   Save_Length(mainfile,33);
+
+   if ( strstr(filetoparse,".f90") ||
+        strstr(filetoparse,".F90") ) retour77 = 0;
+
+   yyparse();
+
+/******************************************************************************/
+/*  4-  Preparation of the file parsing                                       */
+/******************************************************************************/
+   if ((yyin=fopen(filetoparse,"r"))==NULL) /* Is the file to parse exist ?   */
+   {
+      printf("the file %s doesn't exist \n",filetoparse);
+      exit(0);
+   }
+   /* mainfile : the name of the file to parse                                */
+   strcpy(mainfile,filetoparse);
+   /*                                                                         */
+   if ((dependglobaloutput=fopen(".dependglobal_agrif","r"))!=NULL)
+   {
+      fscanf(dependglobaloutput,"%d\n",&indicemaxtabvars);
+      fclose(dependglobaloutput);
+   }
+   Readthedependavailablefile();
+   /* Read the .dependnbxnby file which contains indices of nbmaillsX,        */
+   /*    nbmailleY and nbmailleZ                                              */
+   Readthedependnbxnbyfile();
+   Read_Subroutine_For_Alloc();
+/******************************************************************************/
+/*  5-  Parsing of the input file (2 times)                                   */
+/******************************************************************************/
+   /* Record all variable in list                                             */
+   firstpass = 1;
+   processfortran(filetoparse);
+   /*                                                                         */
+   CompleteThelistvarindoloop();
+   /* Read list of module used                                                */
+   RecordUseModulesVariables();
+   /* Read list of module used in module used                                 */
+   RecordUseModulesUseModulesVariables();
+   /* Save variables are considered as globals ones                           */
+   Update_List_Global_Var_From_List_Save_Var();
+   /* Update all lists                                                        */
+   ListUpdate();
+   /*                                                                         */
+   Clean_List_Global_Var();
+   /* Indice tabvars identification                                           */
+   IndiceTabvarsIdentification();
+   /* Update all lists                                                        */
+   ListUpdate();
+   /* The allocation subroutine is necessary ????                             */
+   New_Allocate_Subroutine_Is_Necessary();
+   /* The allocation subroutine is necessary for common list                  */
+   New_Allocate_Subroutine_For_Common_Is_Necessary();
+   /* Sort List_SubroutineArgument_Var                                        */
+   Sort_List_SubroutineArgument_Var();
+   /* Clean all lists                                                         */
+   ListClean();
+   /* Update Indice of List_UsedInSubroutine_Var from module used             */
+   List_UsedInSubroutine_Var_Update_From_Module_Used();
+   /* Update List_SubroutineWhereAgrifUsed                                    */
+   UpdateList_SubroutineWhereAgrifUsed();
+   /* Update List_UsedInSubroutine_Var with v_readedlistdimension             */
+   UpdateList_UsedInSubroutine_With_dimension();;
+   /*                                                                         */
+   ModifyThelistvarindoloop();
+   /*                                                                         */
+   UpdateListDeclarationWithDimensionList();
+   /*                                                                         */
+   GiveTypeOfVariables();
+   Affiche();
+   /* Build new subroutines                                                   */
+   firstpass = 0;
+   processfortran(filetoparse);
+
+   newvar = (listvar *)NULL;
+/*newvar = List_Global_Var; */
+   while ( newvar )
+   {
+      printf("++++ %s %d %s %s %s\n",
+      newvar->var->v_nomvar,
+      newvar->var->v_nbdim,
+      newvar->var->v_subroutinename,
+      newvar->var->v_modulename,
+      newvar->var->v_typevar
+             );
+      newvar = newvar->suiv;
+   }
+/******************************************************************************/
+/*  6-  Write informations in output files                                    */
+/******************************************************************************/
+
+   /* Write the .dependglobal_agrif file which contain the max indice         */
+   /*    of the tabvars table                                                 */
+   dependglobaloutput = fopen(".dependglobal_agrif","w");
+   fprintf(dependglobaloutput,"%d\n",indicemaxtabvars);
+   fclose(dependglobaloutput);
+   /* Write the list of available indice                                      */
+   Writethedependavailablefile();
+   /* Write the .dependnbxnby file which contains indices of nbmaillsX,       */
+   /*    nbmailleY and nbmailleZ                                              */
+   Writethedependnbxnbyfile();
+   /* Write the .depend<namefile> file which contain general informations     */
+   /*    about variable of this file                                          */
+   parcours = List_NameOfModule;
+   while( parcours )
+   {
+      Writethedependlistofmoduleused(parcours->o_nom);
+      WritedependParameterList(parcours->o_nom);
+      Writethedependfile(parcours->o_nom,List_Global_Var);
+      parcours=parcours->suiv;
+   }
+   parcours = List_NameOfCommon;
+   while( parcours )
+   {
+      Writethedependfile(parcours->o_nom,List_Common_Var);
+      parcours=parcours->suiv;
+   }
+   Write_Subroutine_For_Alloc();
+/******************************************************************************/
+/*  7-  Create files in AGRIF_INC directory                                   */
+/******************************************************************************/
+   creefichieramr(NameTamponfile);
+
+   Write_val_max();
+
+   if ( todebug == 1 ) printf("Out of CONV \n");
+   return 0;
+}
+#line 537 "y.tab.c"
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yyss + yystacksize - 1)
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yyss + yystacksize - 1)
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 4:
+#line 67 "convert.y"
+{initdimprob(1,yyvsp[-1].na,"0","0");}
+break;
+case 5:
+#line 68 "convert.y"
+{initdimprob(2,yyvsp[-3].na, yyvsp[-1].na,"0");}
+break;
+case 6:
+#line 70 "convert.y"
+{initdimprob(3,yyvsp[-5].na, yyvsp[-3].na, yyvsp[-1].na);}
+break;
+case 7:
+#line 72 "convert.y"
+{listofmodules = Addtolistnom(yyvsp[-1].na,listofmodules,0);
+                                                        Addmoduletothelist(yyvsp[-1].na);}
+break;
+case 8:
+#line 74 "convert.y"
+{Add_NotGridDepend_Var_1(yyvsp[-1].na);}
+break;
+case 9:
+#line 75 "convert.y"
+{
+                                    if (!strcasecmp(yyvsp[-1].na,"FIXED_GRIDS"))
+                                                                 fixedgrids=1;
+                                    if (!strcasecmp(yyvsp[-1].na,"ONLY_FIXED_GRIDS"))
+                                                             onlyfixedgrids=1;
+                                 }
+break;
+#line 708 "y.tab.c"
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+    if (yyssp >= yyss + yystacksize - 1)
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    return (0);
+}
+#line 2 "convert.yy.c"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		yyless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		*yy_cp = yy_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+	{
+	FILE *yy_input_file;
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via yyrestart()), so that the user can continue scanning by
+	 * just pointing yyin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	yytext_ptr = yy_bp; \
+	yyleng = (int) (yy_cp - yy_bp); \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 12
+#define YY_END_OF_BUFFER 13
+static yyconst short int yy_accept[74] =
+    {   0,
+        0,    0,    0,    0,   13,   12,   11,   10,   12,    9,
+       12,   12,   12,    9,    8,    8,    8,    8,    8,    8,
+       11,    0,    4,    7,    5,    8,    8,    8,    8,    8,
+        8,    8,    6,    8,    8,    8,    8,    3,    8,    8,
+        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
+        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
+        8,    8,    8,    2,    8,    8,    8,    1,    8,    8,
+        8,    8,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    1,    1,    1,    4,    1,    1,    5,
+        6,    1,    1,    7,    1,    1,    1,    8,    9,   10,
+       11,    8,    8,    8,   12,    8,    8,   13,   14,    1,
+        1,    1,    1,    1,   18,   19,   19,   20,   21,   22,
+       23,   19,   24,   19,   19,   25,   26,   27,   28,   29,
+       19,   30,   31,   32,   33,   19,   19,   34,   35,   19,
+       15,    1,   16,    1,   17,    1,   18,   19,   19,   20,
+
+       21,   22,   23,   19,   24,   19,   19,   25,   26,   27,
+       28,   29,   19,   30,   31,   32,   33,   19,   19,   34,
+       35,   19,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[36] =
+    {   0,
+        1,    1,    2,    1,    1,    1,    1,    3,    3,    3,
+        3,    3,    1,    1,    1,    1,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3
+    } ;
+
+static yyconst short int yy_base[76] =
+    {   0,
+        0,    0,    0,    0,   96,   97,   93,   97,   90,   97,
+       73,   72,   71,   77,    0,   24,   61,   61,   69,   55,
+       83,   80,   79,   97,   97,    0,   70,   47,   48,   54,
+       48,   56,    0,   55,   52,   39,   55,    0,   52,   41,
+       53,   43,   51,   43,   44,   39,   41,   43,   38,   33,
+       30,   39,   24,   37,   32,   34,   33,   20,   32,   21,
+       27,   21,   14,    0,   27,   22,   19,    0,   11,   16,
+       19,    7,   97,   48,   34
+    } ;
+
+static yyconst short int yy_def[76] =
+    {   0,
+       73,    1,    1,    1,   73,   73,   73,   73,   74,   73,
+       73,   73,   73,   73,   75,   75,   75,   75,   75,   75,
+       73,   74,   74,   73,   73,   75,   75,   75,   75,   75,
+       75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
+       75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
+       75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
+       75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
+       75,   75,    0,   73,   73
+    } ;
+
+static yyconst short int yy_nxt[133] =
+    {   0,
+        6,    7,    8,    9,   10,   10,   10,    6,   11,   12,
+       13,    6,   14,   10,   10,   10,   15,   15,   15,   15,
+       15,   16,   15,   15,   15,   15,   17,   18,   19,   15,
+       15,   15,   20,   15,   15,   27,   26,   33,   72,   71,
+       70,   69,   68,   67,   33,   66,   65,   28,   22,   64,
+       22,   63,   62,   61,   60,   59,   58,   57,   56,   55,
+       54,   53,   52,   51,   50,   49,   48,   47,   46,   45,
+       44,   43,   42,   41,   40,   39,   38,   37,   36,   35,
+       34,   33,   23,   23,   21,   32,   31,   30,   29,   25,
+       24,   24,   24,   23,   21,   73,    5,   73,   73,   73,
+
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73
+    } ;
+
+static yyconst short int yy_chk[133] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,   16,   75,   72,   71,   70,
+       69,   67,   66,   65,   63,   62,   61,   16,   74,   60,
+       74,   59,   58,   57,   56,   55,   54,   53,   52,   51,
+       50,   49,   48,   47,   46,   45,   44,   43,   42,   41,
+       40,   39,   37,   36,   35,   34,   32,   31,   30,   29,
+       28,   27,   23,   22,   21,   20,   19,   18,   17,   14,
+       13,   12,   11,    9,    7,    5,   73,   73,   73,   73,
+
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
+       73,   73
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "convert.lex"
+#define INITIAL 0
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#define character 1
+
+#line 37 "convert.lex"
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+int line_num=1;
+extern FILE * yyin;
+#define MAX_INCLUDE_DEPTH 30
+YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+#line 460 "convert.yy.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( yy_current_buffer->yy_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( yyin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+		  && ferror( yyin ) ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+
+#line 55 "convert.lex"
+
+#line 613 "convert.yy.c"
+
+	if ( yy_init )
+		{
+		yy_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! yy_start )
+			yy_start = 1;	/* first start state */
+
+		if ( ! yyin )
+			yyin = stdin;
+
+		if ( ! yyout )
+			yyout = stdout;
+
+		if ( ! yy_current_buffer )
+			yy_current_buffer =
+				yy_create_buffer( yyin, YY_BUF_SIZE );
+
+		yy_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yy_c_buf_p;
+
+		/* Support of yytext. */
+		*yy_cp = yy_hold_char;
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+		yy_current_state = yy_start;
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				yy_last_accepting_state = yy_current_state;
+				yy_last_accepting_cpos = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 74 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 97 );
+
+yy_find_action:
+		yy_act = yy_accept[yy_current_state];
+		if ( yy_act == 0 )
+			{ /* have to back up */
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			yy_act = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = yy_hold_char;
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 56 "convert.lex"
+return TOK_MODULEMAIN; /* name of the module                      */
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 57 "convert.lex"
+return TOK_NOTGRIDDEP; /* variable which are not grid dependent   */
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 58 "convert.lex"
+return TOK_USE;
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 59 "convert.lex"
+{}
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 60 "convert.lex"
+return TOK_SEP;
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 61 "convert.lex"
+{strcpy(yylval.na,yytext); return TOK_USEITEM;}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 62 "convert.lex"
+{strcpy(yylval.na,yytext); return TOK_PROBTYPE;}
+	YY_BREAK
+/* dimension of the problem                */
+case 8:
+YY_RULE_SETUP
+#line 64 "convert.lex"
+{strcpy(yylval.na,yytext); return TOK_NAME;}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 65 "convert.lex"
+{return (int) *yytext;}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 66 "convert.lex"
+{line_num++;return (int) *yytext;}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 67 "convert.lex"
+;
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 68 "convert.lex"
+ECHO;
+	YY_BREAK
+#line 757 "convert.yy.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(character):
+	yyterminate();
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = yy_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed yyin at a new source and called
+			 * yylex().  If so, then we have to assure
+			 * consistency between yy_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			yy_n_chars = yy_current_buffer->yy_n_chars;
+			yy_current_buffer->yy_input_file = yyin;
+			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++yy_c_buf_p;
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+				yy_cp = yy_c_buf_p;
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				yy_did_buffer_switch_on_eof = 0;
+
+				if ( yywrap() )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * yytext, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				yy_c_buf_p =
+					yytext_ptr + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				yy_c_buf_p =
+				&yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+	{
+	register char *dest = yy_current_buffer->yy_ch_buf;
+	register char *source = yytext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( yy_current_buffer->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = yy_current_buffer;
+
+			int yy_c_buf_p_offset =
+				(int) (yy_c_buf_p - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					yy_flex_realloc( (void *) b->yy_ch_buf,
+							 b->yy_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = yy_current_buffer->yy_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+			yy_n_chars, num_to_read );
+
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	if ( yy_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			yyrestart( yyin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			yy_current_buffer->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	yy_n_chars += number_to_move;
+	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+
+	yy_current_state = yy_start;
+
+	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+		{
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		if ( yy_accept[yy_current_state] )
+			{
+			yy_last_accepting_state = yy_current_state;
+			yy_last_accepting_cpos = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 74 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
+
+	return yy_current_state;
+	}
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+	{
+	register int yy_is_jam;
+	register char *yy_cp = yy_c_buf_p;
+
+	register YY_CHAR yy_c = 1;
+	if ( yy_accept[yy_current_state] )
+		{
+		yy_last_accepting_state = yy_current_state;
+		yy_last_accepting_cpos = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 74 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 73);
+
+	return yy_is_jam ? 0 : yy_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+	{
+	register char *yy_cp = yy_c_buf_p;
+
+	/* undo effects of setting up yytext */
+	*yy_cp = yy_hold_char;
+
+	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = yy_n_chars + 2;
+		register char *dest = &yy_current_buffer->yy_ch_buf[
+					yy_current_buffer->yy_buf_size + 2];
+		register char *source =
+				&yy_current_buffer->yy_ch_buf[number_to_move];
+
+		while ( source > yy_current_buffer->yy_ch_buf )
+			*--dest = *--source;
+
+		yy_cp += (int) (dest - source);
+		yy_bp += (int) (dest - source);
+		yy_current_buffer->yy_n_chars =
+			yy_n_chars = yy_current_buffer->yy_buf_size;
+
+		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--yy_cp = (char) c;
+
+
+	yytext_ptr = yy_bp;
+	yy_hold_char = *yy_cp;
+	yy_c_buf_p = yy_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*yy_c_buf_p = yy_hold_char;
+
+	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			/* This was really a NUL. */
+			*yy_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = yy_c_buf_p - yytext_ptr;
+			++yy_c_buf_p;
+
+			switch ( yy_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					yyrestart( yyin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( yywrap() )
+						return EOF;
+
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					yy_c_buf_p = yytext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
+	*yy_c_buf_p = '\0';	/* preserve yytext */
+	yy_hold_char = *++yy_c_buf_p;
+
+
+	return c;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! yy_current_buffer )
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+	yy_init_buffer( yy_current_buffer, input_file );
+	yy_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( yy_current_buffer == new_buffer )
+		return;
+
+	if ( yy_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*yy_c_buf_p = yy_hold_char;
+		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	yy_current_buffer = new_buffer;
+	yy_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (yywrap()) processing, but the only time this flag
+	 * is looked at is after yywrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	yy_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+	{
+	yy_n_chars = yy_current_buffer->yy_n_chars;
+	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+	yyin = yy_current_buffer->yy_input_file;
+	yy_hold_char = *yy_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	yy_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == yy_current_buffer )
+		yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		yy_flex_free( (void *) b->yy_ch_buf );
+
+	yy_flex_free( (void *) b );
+	}
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	yy_flush_buffer( b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->yy_is_interactive = 0;
+#else
+	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == yy_current_buffer )
+		yy_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	yy_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+	{
+	int len;
+	for ( len = 0; yy_str[len]; ++len )
+		;
+
+	return yy_scan_bytes( yy_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) yy_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = yy_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( yy_start_stack_ptr >= yy_start_stack_depth )
+		{
+		yy_size_t new_size;
+
+		yy_start_stack_depth += YY_START_STACK_INCR;
+		new_size = yy_start_stack_depth * sizeof( int );
+
+		if ( ! yy_start_stack )
+			yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+		else
+			yy_start_stack = (int *) yy_flex_realloc(
+					(void *) yy_start_stack, new_size );
+
+		if ( ! yy_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+	{
+	if ( --yy_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(yy_start_stack[yy_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+	{
+	return yy_start_stack[yy_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		yytext[yyleng] = yy_hold_char; \
+		yy_c_buf_p = yytext + n; \
+		yy_hold_char = *yy_c_buf_p; \
+		*yy_c_buf_p = '\0'; \
+		yyleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	yylex();
+	return 0;
+	}
+#endif
+#line 68 "convert.lex"
+
+
+
+int yywrap()
+{
+}
+
+
+yyerror(char *s)
+{
+if (!strcasecmp(curfile,mainfile))
+{
+   printf("Dans convert %s line %d, fichier %s\n",s,line_num,curfile);
+}
+else
+{
+   printf("Dans convert %s line %d, fichier %s\n",s,line_num,curfile);
+}
+exit(0);
+}
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/run
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/run	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/run	(revision 1844)
@@ -0,0 +1,2 @@
+gmake -f Makefile.lex clean
+gmake -f Makefile.lex
Index: /branches/DEV_r1837_MLF/AGRIF/LIB/toamr.c
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/LIB/toamr.c	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/LIB/toamr.c	(revision 1844)
@@ -0,0 +1,1193 @@
+/******************************************************************************/
+/*                                                                            */
+/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
+/*                                                                            */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
+/*                                                                            */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
+/*                                                                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
+/*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.7                                                                */
+/******************************************************************************/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "decl.h"
+char lvargridname[LONG_4C];
+char lvargridname2[LONG_4C];
+
+
+/******************************************************************************/
+/*                       variablenameroottabvars                              */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/*  ----------->  Agrif_Mygrid % tabvars (i) % var                            */
+/*                                                                            */
+/******************************************************************************/
+char *variablenameroottabvars (variable * var)
+{
+  char *ligne;
+
+  ligne = (char *) malloc (LONG_C * sizeof (char));
+  sprintf (ligne, "Agrif_Mygrid %% tabvars(%d) %% var ", var->v_indicetabvars);
+  return ligne;
+}
+
+
+/******************************************************************************/
+/*                        variablenametabvars                                 */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/*  if iorindice = 0 ---------->  Agrif_Gr % tabvars (i) % var                */
+/*                                                                            */
+/*  if iorindice = 1 ---------->  Agrif_Gr % tabvars (12) % var               */
+/*                                                                            */
+/******************************************************************************/
+char *variablenametabvars (variable * var, int iorindice)
+{
+  char *ligne;
+
+  ligne = (char *) malloc (LONG_C * sizeof (char));
+  if ( iorindice == 0 ) sprintf (ligne, " Agrif_Gr %% tabvars(%d)%% var",
+                                 var->v_indicetabvars);
+  else sprintf (ligne, " Agrif_Gr %% tabvars(i)%% var");
+  return ligne;
+}
+
+/******************************************************************************/
+/*                        variablecurgridtabvars                              */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/*  ----------->  Agrif_Curgrid % tabvars (i) % var                           */
+/*                                                                            */
+/******************************************************************************/
+char *variablecurgridtabvars (variable * var,int ParentOrCurgrid)
+{
+  char *ligne;
+
+  ligne = (char *) malloc (LONG_C * sizeof (char));
+  if ( ParentOrCurgrid == 0 ) sprintf (ligne, " Agrif_tabvars(%d) %% var",
+                              var->v_indicetabvars);
+  else if ( ParentOrCurgrid == 1 ) sprintf (ligne,
+                              " Agrif_tabvars(%d) %% parent_var %% var",
+                               var->v_indicetabvars);
+  else if ( ParentOrCurgrid == 2 ) sprintf (ligne,
+                              " Agrif_Mygrid %% tabvars(%d) %% var",
+                               var->v_indicetabvars);
+  else if ( ParentOrCurgrid == 3 ) sprintf (ligne,
+                              " Agrif_Curgrid %% tabvars(%d) %% var",
+                               var->v_indicetabvars);
+  else sprintf (ligne, " AGRIF_Mygrid %% tabvars(%d) %% var",
+                               var->v_indicetabvars);
+  return ligne;
+}
+
+void WARNING_CharSize(variable *var)
+{
+   if ( var->v_nbdim == 0 )
+   {
+      if ( convert2int(var->v_dimchar) > 2050 )
+      {
+         printf("WARNING : The dimension of the character  %s   \n",
+                                                              var->v_nomvar);
+         printf("   is upper than 2050. You must change         \n");
+         printf("   the dimension of carray0                    \n");
+         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n");
+         printf("   line 247. Replace 300 with %d.              \n",
+                                            convert2int(var->v_dimchar)+100);
+      }
+      Save_Length_int(convert2int(var->v_dimchar),1);
+   }
+   else if ( var->v_nbdim == 1 )
+   {
+      if ( convert2int(var->v_dimchar) > 300 )
+      {
+         printf("WARNING : The dimension of the character  %s   \n",
+                                                              var->v_nomvar);
+         printf("   is upper than 300. You must change          \n");
+         printf("   the dimension of carray1                    \n");
+         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n");
+         printf("   line 247. Replace 300 with %d.              \n",
+                                            convert2int(var->v_dimchar)+100);
+      }
+      Save_Length_int(convert2int(var->v_dimchar),2);
+   }
+   else if ( var->v_nbdim == 2 )
+   {
+      if ( convert2int(var->v_dimchar) > 300 )
+      {
+         printf("WARNING : The dimension of the character  %s   \n",
+                                                              var->v_nomvar);
+         printf("   is upper than 300. You must change          \n");
+         printf("   the dimension of carray2                    \n");
+         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n");
+         printf("   line 247. Replace 300 with %d.              \n",
+                                            convert2int(var->v_dimchar)+100);
+      }
+      Save_Length_int(convert2int(var->v_dimchar),3);
+   }
+   else if ( var->v_nbdim == 3 )
+   {
+      if ( convert2int(var->v_dimchar) > 300 )
+      {
+         printf("WARNING : The dimension of the character  %s   \n",
+                                                              var->v_nomvar);
+         printf("   is upper than 300. You must change          \n");
+         printf("   the dimension of carray3                    \n");
+         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n");
+         printf("   line 247. Replace 300 with %d.              \n",
+                                            convert2int(var->v_dimchar)+100);
+      }
+      Save_Length_int(convert2int(var->v_dimchar),4);
+   }
+}
+/******************************************************************************/
+/*                           vargridnametabvars                               */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/*  if iorindice == 0 ----------->  Agrif_Gr % tabvars (i) % var % array1     */
+/*                                                                            */
+/*  if iorindice == 1 ----------->  Agrif_Gr % tabvars (12) % var % array1    */
+/*                                                                            */
+/******************************************************************************/
+char *vargridnametabvars (variable * var,int iorindice)
+{
+  char *tmp;
+  char tmp1[LONG_C];
+
+  tmp = variablenametabvars (var,iorindice);
+  strcpy(tmp1,tmp);
+  if ( todebugfree == 1 ) free(tmp);
+
+  sprintf (lvargridname, "%s", tmp1);
+  if (!strcasecmp (var->v_typevar, "REAL"))
+    {
+      if ( !strcasecmp(var->v_nameinttypename,"8") )
+                           sprintf (lvargridname2, "%% darray%d", var->v_nbdim);
+      else if ( !strcasecmp(var->v_nameinttypename,"4") )
+                           sprintf (lvargridname2, "%% sarray%d", var->v_nbdim);
+      else sprintf (lvargridname2, "%% array%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "INTEGER"))
+    {
+      sprintf (lvargridname2, "%% iarray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "LOGICAL"))
+    {
+      sprintf (lvargridname2, "%% larray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "CHARACTER"))
+    {
+      WARNING_CharSize(var);
+      sprintf (lvargridname2, "%% carray%d", var->v_nbdim);
+    }
+
+  strcat (lvargridname, lvargridname2);
+
+  Save_Length(lvargridname,42);
+  Save_Length(lvargridname2,42);
+  return lvargridname;
+}
+
+/******************************************************************************/
+/*                           vargridcurgridtabvars                            */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/* if ParentOrCurgrid == 0 -->  Agrif_Curgrid % tabvars (i) % var % array1    */
+/*                                                                            */
+/* if ParentOrCurgrid == 1 -->  Agrif_tabvars (i) % parent_var %var % array1  */
+/*                                                                            */
+/* if ParentOrCurgrid == 2 -->  Agrif_Gr % tabvars (i) % var % array1         */
+/*                                                                            */
+/******************************************************************************/
+char *vargridcurgridtabvars (variable * var,int ParentOrCurgrid)
+{
+  char *tmp;
+  char tmp1[LONG_C];
+
+ if (!strcasecmp(var->v_typevar,"type"))
+  {
+  strcpy(lvargridname2,"");
+  sprintf(lvargridname,"Agrif_%s_var(Agrif_Curgrid%%fixedrank)%%%s",var->v_modulename,var->v_nomvar);
+  }
+  else
+  {
+  tmp = variablecurgridtabvars (var,ParentOrCurgrid);
+  strcpy(tmp1,tmp);
+  if ( todebugfree == 1 ) free(tmp);
+
+  sprintf (lvargridname, "%s", tmp1);
+  if (!strcasecmp (var->v_typevar, "REAL"))
+    {
+      if ( !strcasecmp(var->v_nameinttypename,"8") )
+                           sprintf (lvargridname2, "%% darray%d", var->v_nbdim);
+      else if ( !strcasecmp(var->v_nameinttypename,"4") )
+                           sprintf (lvargridname2, "%% sarray%d", var->v_nbdim);
+      else sprintf (lvargridname2, "%% array%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "INTEGER"))
+    {
+      sprintf (lvargridname2, "%% iarray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "LOGICAL"))
+    {
+      sprintf (lvargridname2, "%% larray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "CHARACTER"))
+    {
+      WARNING_CharSize(var);
+      sprintf (lvargridname2, "%% carray%d", var->v_nbdim);
+    }
+  }
+
+  strcat (lvargridname, lvargridname2);
+
+  Save_Length(lvargridname,42);
+  Save_Length(lvargridname2,42);
+  return lvargridname;
+}
+
+/******************************************************************************/
+/*                  vargridcurgridtabvarswithoutAgrif_Gr                      */
+/******************************************************************************/
+/* This subroutine is used to create the string                               */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+char *vargridcurgridtabvarswithoutAgrif_Gr (variable * var)
+{
+
+  sprintf (lvargridname, "(%d) %% var", var->v_indicetabvars);
+
+  if (!strcasecmp (var->v_typevar, "REAL"))
+    {
+      if ( !strcasecmp(var->v_nameinttypename,"8") )
+                           sprintf (lvargridname2, "%% darray%d", var->v_nbdim);
+      else if ( !strcasecmp(var->v_nameinttypename,"4") )
+                           sprintf (lvargridname2, "%% sarray%d", var->v_nbdim);
+      else sprintf (lvargridname2, "%% array%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "INTEGER"))
+    {
+      sprintf (lvargridname2, "%% iarray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "LOGICAL"))
+    {
+      sprintf (lvargridname2, "%% larray%d", var->v_nbdim);
+    }
+  else if (!strcasecmp (var->v_typevar, "CHARACTER"))
+    {
+      WARNING_CharSize(var);
+      sprintf (lvargridname2, "%% carray%d", var->v_nbdim);
+    }
+
+  strcat (lvargridname, lvargridname2);
+
+  Save_Length(lvargridname,42);
+  Save_Length(lvargridname2,42);
+  return lvargridname;
+}
+
+/******************************************************************************/
+/*                               vargridparam                                 */
+/******************************************************************************/
+/* This subroutine is used to create the string which contains                */
+/* dimension list                                                             */
+/******************************************************************************/
+/*                                                                            */
+/*  DIMENSION(jpi,0:jpj) ----------->"1:jpi,0:jpj"                            */
+/*                                                                            */
+/******************************************************************************/
+char *vargridparam (variable * v, int whichone)
+{
+  typedim dim;
+  listdim *newdim;
+  char newname[LONG_4C];
+
+  newdim = v->v_dimension;
+  if (!newdim) return "";
+
+  strcpy (tmpvargridname, "(");
+  while (newdim)
+  {
+     dim = newdim->dim;
+
+     strcpy(newname,"");
+     strcpy(newname,
+            ChangeTheInitalvaluebyTabvarsName(dim.first,List_Global_Var,
+                                                                     whichone));
+                                                                     
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName(newname,
+                       List_Common_Var,whichone));
+
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName(newname,
+                       List_ModuleUsed_Var,whichone));
+
+     strcat (tmpvargridname, newname);
+     strcat (tmpvargridname, " : ");
+
+     strcpy(newname,"");
+     strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                        (dim.last,List_Global_Var,whichone));
+                        
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                       (newname, List_Common_Var,whichone));   
+                       
+        strcpy(newname,ChangeTheInitalvaluebyTabvarsName
+                       (newname, List_ModuleUsed_Var,whichone));                                            
+                        
+     Save_Length(tmpvargridname,46);
+     strcat (tmpvargridname, newname);
+     newdim = newdim->suiv;
+     if (newdim) strcat (tmpvargridname, ",");
+  }
+  strcat (tmpvargridname, ")");
+  strcat (tmpvargridname, "\0");
+  Save_Length(tmpvargridname,40);
+  return tmpvargridname;
+}
+
+/******************************************************************************/
+/*                        write_probdimagrif_file                             */
+/******************************************************************************/
+/* This subroutine is used to create the file probdim_agrif.h                 */
+/******************************************************************************/
+/*                                                                            */
+/*               probdim_agrif.h                                              */
+/*                                                                            */
+/*               Agrif_probdim = <number>                                     */
+/*                                                                            */
+/******************************************************************************/
+void write_probdimagrif_file()
+{
+  FILE *probdim;
+  char ligne[LONG_C];
+
+  probdim = associate("probdim_agrif.h");
+  sprintf (ligne, "Agrif_Probdim = %d", dimprob);
+  tofich (probdim, ligne,1);
+  fclose (probdim);
+}
+
+/******************************************************************************/
+/*                             write_keysagrif_file                           */
+/******************************************************************************/
+/* This subroutine is used to create the file keys_agrif.h                    */
+/******************************************************************************/
+/*                                                                            */
+/*               keys_agrif.h                                                 */
+/*                                                                            */
+/*               AGRIF_USE_FIXED_GRIDS = 0                                    */
+/*               AGRIF_USE_ONLY_FIXED_GRIDS = 0                               */
+/*               AGRIF_USE_(ONLY)_FIXED_GRIDS = 1                             */
+/*                                                                            */
+/******************************************************************************/
+void write_keysagrif_file()
+{
+  FILE *keys;
+
+  keys = associate ("keys_agrif.h");
+  fprintf(keys,"      AGRIF_USE_FIXED_GRIDS = 0\n");
+  fprintf(keys,"      AGRIF_USE_ONLY_FIXED_GRIDS = 0\n");
+  if (fixedgrids     == 1) fprintf(keys,"      AGRIF_USE_FIXED_GRIDS = 1\n");
+  if (onlyfixedgrids == 1)
+                         fprintf(keys,"      AGRIF_USE_ONLY_FIXED_GRIDS = 1\n");
+
+  fclose(keys);
+}
+
+/******************************************************************************/
+/*                      write_modtypeagrif_file                               */
+/******************************************************************************/
+/* This subroutine is used to create the file typedata                        */
+/******************************************************************************/
+/*                                                                            */
+/*               modtype_agrif.h                                              */
+/*                                                                            */
+/*               Agrif_NbVariables =                                          */
+/*                                                                            */
+/******************************************************************************/
+void write_modtypeagrif_file()
+{
+  char ligne[LONG_C];
+  FILE *typedata;
+
+  typedata = associate ("modtype_agrif.h");
+  /* AGRIF_NbVariables : number of variables                                  */
+  sprintf (ligne, "AGRIF_NbVariables = %d",indicemaxtabvars);
+  tofich(typedata,ligne,1);
+  fclose (typedata);
+}
+
+/******************************************************************************/
+/*                   write_createvarnameagrif_file                            */
+/******************************************************************************/
+/* This subroutine is used to create the file  createvarname                  */
+/******************************************************************************/
+/*                                                                            */
+/*    Agrif_Gr % tabvars (i) % var % namevar = "variable"                     */
+/*                                                                            */
+/******************************************************************************/
+void write_createvarnameagrif_file(variable *v,FILE *createvarname,
+                                                       int *InitEmpty)
+{
+  char ligne[LONG_C];
+  char *tmp;
+  char temp1[LONG_C];
+
+  tmp =  variablenametabvars(v,0);
+  strcpy (temp1, tmp);
+  if ( todebugfree == 1 ) free(tmp);
+
+  *InitEmpty = 0 ;
+  sprintf(ligne, "%s %% namevar = \"%s\"",temp1,v->v_nomvar);
+  tofich(createvarname,ligne,1);
+}
+
+/******************************************************************************/
+/*                        write_Setnumberofcells_file                         */
+/******************************************************************************/
+/* This subroutine is used to create the file  setnumberofcells               */
+/******************************************************************************/
+/*                                                                            */
+/*              Agrif_Gr % n(i) = nbmailles                                   */
+/*                                                                            */
+/******************************************************************************/
+void write_Setnumberofcells_file(char *name)
+{
+  char ligne[LONG_C];
+  FILE *setnumberofcells;
+
+  if ( IndicenbmaillesX != 0 )
+  {
+  setnumberofcells=associate(name);
+
+  if (onlyfixedgrids != 1 )
+  {
+  sprintf (ligne,
+           "Agrif_Gr %% nb(1) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesX);
+  }
+  else
+  {
+  sprintf (ligne,
+           "Agrif_Gr %% nb(1) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesX);
+  }
+  tofich (setnumberofcells, ligne,1);
+  if (dimprob > 1)
+  {
+     if (onlyfixedgrids != 1 )
+     {
+     sprintf (ligne,
+           "Agrif_Gr %% nb(2) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesY);
+     }
+     else
+     {
+     sprintf (ligne,
+           "Agrif_Gr %% nb(2) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesY);
+     }
+
+     tofich (setnumberofcells, ligne,1);
+  }
+  if (dimprob > 2)
+  {
+     if (onlyfixedgrids != 1 )
+     {
+     sprintf (ligne,
+           "Agrif_Gr %% nb(3) = Agrif_Gr %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesZ);
+     }
+     else
+     {
+     sprintf (ligne,
+           "Agrif_Gr %% nb(3) = Agrif_Curgrid %% tabvars(%d) %% var %% iarray0",
+           IndicenbmaillesZ);
+     }
+     tofich (setnumberofcells, ligne,1);
+  }
+
+  fclose (setnumberofcells);
+  }
+}
+
+/******************************************************************************/
+/*                       write_Getnumberofcells_file                          */
+/******************************************************************************/
+/* This subroutine is used to create the file  getnumberofcells               */
+/******************************************************************************/
+/*                                                                            */
+/*              nbmailles = Agrif_Gr % n(i)                                   */
+/*                                                                            */
+/******************************************************************************/
+void write_Getnumberofcells_file(char *name)
+{
+  char ligne[LONG_C];
+  FILE *getnumberofcells;
+
+  if ( IndicenbmaillesX != 0 )
+  {
+  getnumberofcells=associate(name);
+  sprintf (ligne,
+           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(1)",
+           IndicenbmaillesX);
+  tofich (getnumberofcells, ligne,1);
+  if (dimprob > 1)
+    {
+      sprintf (ligne,
+           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(2)",
+           IndicenbmaillesY);
+      tofich (getnumberofcells, ligne,1);
+    }
+  if (dimprob > 2)
+    {
+      sprintf (ligne,
+           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(3)",
+           IndicenbmaillesZ);
+      tofich (getnumberofcells, ligne,1);
+    }
+  fclose (getnumberofcells);
+  }
+}
+
+
+/******************************************************************************/
+/*                      write_initialisationsagrif_file                       */
+/******************************************************************************/
+/* This subroutine is used to create the file initproc                        */
+/******************************************************************************/
+/*                                                                            */
+/*              ! variable                                                    */
+/*              Agrif_Gr % tabvars(i) % var % nbdim = 1                       */
+/*                                                                            */
+/******************************************************************************/
+void write_initialisationsagrif_file(variable *v,FILE *initproc,
+                                     int *VarnameEmpty)
+{
+  char ligne[LONG_C];
+  char temp1[LONG_C];
+  char *tmp;
+
+  tmp = variablenameroottabvars (v);
+  strcpy (temp1, tmp);
+  if ( todebugfree == 1 ) free(tmp);
+
+  if ( v->v_nbdim != 0 )
+  {
+     *VarnameEmpty = 0 ;
+     sprintf (ligne, "%s %% nbdim = %d", temp1, v->v_nbdim);
+     tofich (initproc, ligne,1);
+  }
+}
+
+
+void Write_Alloc_Agrif_Files()
+{
+   listnom *parcours;
+   FILE *alloccalls;
+   FILE *AllocUSE;
+
+   AllocUSE= associate("include_use_Alloc_agrif.h");
+   alloccalls = associate("allocations_calls_agrif.h");
+
+   parcours = List_Subroutine_For_Alloc;
+   while ( parcours )
+   {
+      fprintf(AllocUSE,"      USE %s\n", parcours -> o_nom );
+      fprintf (alloccalls,"      Call Alloc_agrif_%s(Agrif_Gr)\n",
+                                                            parcours -> o_nom );
+      parcours = parcours -> suiv;
+   }
+
+   fclose (AllocUSE);
+   fclose (alloccalls);
+}
+
+int IndiceInlist(int indic, listindice *listin)
+{
+   listindice *parcoursindic;
+   int out;
+
+   out = 0 ;
+
+   parcoursindic = listin;
+   while ( parcoursindic && out == 0 )
+   {
+      if ( parcoursindic->i_indice == indic ) out = 1;
+      else parcoursindic = parcoursindic -> suiv;
+   }
+
+   return out;
+}
+void write_allocation_Common_0()
+{
+   listnom *parcours_nom;
+   listnom *neededparameter;
+   listvar *parcours;
+   listvar *parcoursprec;
+   listvar *parcours1;
+   FILE *allocationagrif;
+   FILE *paramtoamr;
+   char ligne[LONGNOM];
+   variable *v;
+   int IndiceMax;
+   int IndiceMin;
+   int compteur;
+   int out;
+   int indiceprec;
+   int ValeurMax;
+   char initialvalue[LONG_4C];
+   listindice *list_indic;
+   listindice *parcoursindic;
+   int i;
+
+   parcoursprec = (listvar *)NULL;
+   parcours_nom = List_NameOfCommon;
+   ValeurMax = 2;
+   while ( parcours_nom  )
+   {
+      /*                                                                      */
+      if ( parcours_nom->o_val == 1 )
+      {
+         /* Open the file to create the Alloc_agrif subroutine                */
+         sprintf(ligne,"alloc_agrif_%s.h",parcours_nom->o_nom);
+         allocationagrif = associate (ligne);
+         /*                                                                   */
+         fprintf(allocationagrif,"#include \"Param_toamr_%s.h\" \n",
+                                                           parcours_nom->o_nom);
+         /*                                                                   */
+         sprintf(ligne,"Param_toamr_%s.h",parcours_nom->o_nom);
+         paramtoamr = associate (ligne);
+         neededparameter = (listnom * )NULL;
+         /*                                                                   */
+         list_indic = (listindice *)NULL;
+         /*                                                                   */
+         shouldincludempif = 1 ;
+         parcours = List_Common_Var;
+         while ( parcours )
+         {
+            if ( !strcasecmp(parcours->var->v_commonname,parcours_nom->o_nom) &&
+                  IndiceInlist(parcours->var->v_indicetabvars,list_indic) == 0
+               )
+            {
+               /***************************************************************/
+               /***************************************************************/
+               /***************************************************************/
+               v = parcours->var;
+               IndiceMax = 0;
+               IndiceMin = indicemaxtabvars;
+  /* body of the file                                                         */
+  if ( !strcasecmp(v->v_commoninfile,mainfile) )
+  {
+     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
+     {
+        strcpy (ligne, "If (.not. associated(");
+        strcat (ligne, vargridnametabvars(v,0));
+        strcat (ligne, "))                       then");
+        Save_Length(ligne,48);
+        tofich (allocationagrif, ligne,1);
+     }
+     if ( v->v_allocatable != 1 && ( v->v_dimsempty != 1) )
+     {
+        /*                ALLOCATION                                          */
+        if ( v->v_dimension != 0  )
+        {
+           if ( v->v_indicetabvars < IndiceMin ||
+                v->v_indicetabvars > IndiceMax )
+           {
+              parcours1 = parcours;
+              compteur = -1;
+              out = 0;
+              indiceprec = parcours->var->v_indicetabvars -1 ;
+              while ( parcours1 && out == 0 &&
+                      !strcasecmp(  parcours->var->v_readedlistdimension,
+                                  parcours1->var->v_readedlistdimension) &&
+                      !strcasecmp(  parcours->var->v_typevar,
+                                  parcours1->var->v_typevar) &&
+                            ( parcours1->var->v_indicetabvars == indiceprec+1 )
+                     )
+              {
+
+               if ( !strcasecmp(parcours1->var->v_modulename,
+                                parcours_nom->o_nom) ||
+                    !strcasecmp(parcours1->var->v_commonname,
+                                parcours_nom->o_nom) )
+                 {
+                      compteur = compteur +1 ;
+                      indiceprec = parcours1->var->v_indicetabvars;
+                      parcoursprec = parcours1;
+                      parcours1 = parcours1->suiv;
+                 }
+                 else out = 1;
+              }
+
+              if ( compteur > ValeurMax )
+              {
+                 fprintf(allocationagrif,"      DO i = %d , %d\n",
+                                         parcours->var->v_indicetabvars,
+                                       parcours->var->v_indicetabvars+compteur);
+                 IndiceMin = parcours->var->v_indicetabvars;
+                 IndiceMax = parcours->var->v_indicetabvars+compteur;
+                 strcpy (ligne, "allocate ");
+                 strcat (ligne, "(");
+                 strcat (ligne, vargridnametabvars(v,1));
+                 strcat (ligne, vargridparam(v,0));
+                 strcat (ligne, ")");
+                 Save_Length(ligne,48);
+                 tofich (allocationagrif, ligne,1);
+                 fprintf(allocationagrif,"      end do\n");
+                 i=parcours->var->v_indicetabvars;
+                 do
+                 {
+                    parcoursindic =  (listindice *)malloc(sizeof(listindice));
+                    parcoursindic -> i_indice = i;
+                    parcoursindic -> suiv = list_indic;
+                    list_indic = parcoursindic;
+                    i = i + 1;
+                 } while ( i <= parcours->var->v_indicetabvars+compteur );
+                 parcours = parcoursprec;
+                 /*                                                           */
+              }
+              else
+              {
+                 strcpy (ligne, "allocate ");
+                 strcat (ligne, "(");
+                 strcat (ligne, vargridnametabvars(v,0));
+                 strcat (ligne, vargridparam(v,0));
+                 strcat (ligne, ")");
+                 Save_Length(ligne,48);
+                 tofich (allocationagrif, ligne,1);
+                 /*                                                           */
+                 parcoursindic =  (listindice *)malloc(sizeof(listindice));
+                 parcoursindic -> i_indice = parcours->var->v_indicetabvars;
+                 parcoursindic -> suiv = list_indic;
+                 list_indic = parcoursindic;
+              }
+                neededparameter = writedeclarationintoamr(List_Parameter_Var,
+                              paramtoamr,v,parcours_nom->o_nom,neededparameter,
+                                                               v->v_commonname);
+              /*                                                              */
+           }
+        } /* end of the allocation part                                       */
+        /*                INITIALISATION                                      */
+        if ( strcasecmp(v->v_initialvalue,"") )
+        {
+           strcpy (ligne, "");
+           strcat (ligne, vargridnametabvars(v,0));
+           /* We should modify the initialvalue in the case of variable has   */
+           /*    been defined with others variables                           */
+                      
+           strcpy(initialvalue,
+                  ChangeTheInitalvaluebyTabvarsName
+                                      (v->v_initialvalue,List_Global_Var,0));
+           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
+           {
+              strcpy(initialvalue,"");
+              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
+                                      (v->v_initialvalue,List_Common_Var,0));
+           }
+           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
+           {
+              strcpy(initialvalue,"");
+              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
+                                     (v->v_initialvalue,List_ModuleUsed_Var,0));
+           }
+           strcat (ligne," = ");
+           strcat (ligne,initialvalue);
+           /*                                                                 */
+           Save_Length(ligne,48);
+           tofich (allocationagrif, ligne,1);
+        }
+     }
+     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
+     {
+        strcpy (ligne, "   End if");
+        tofich (allocationagrif, ligne,1);
+     }
+  }
+               /***************************************************************/
+               /***************************************************************/
+               /***************************************************************/
+            }
+            parcours = parcours -> suiv;
+         }
+         /* Close the file Alloc_agrif                                        */
+         fclose(allocationagrif);
+         fclose(paramtoamr);
+      }
+      /*                                                                      */
+      parcours_nom = parcours_nom -> suiv;
+   }
+
+}
+
+
+
+void write_allocation_Global_0()
+{
+   listnom *parcours_nom;
+   listvar *parcours;
+   listvar *parcoursprec;
+   listvar *parcours1;
+   FILE *allocationagrif;
+   char ligne[LONGNOM];
+   variable *v;
+   int IndiceMax;
+   int IndiceMin;
+   int compteur;
+   int out;
+   int indiceprec;
+   int ValeurMax;
+   char initialvalue[LONG_4C];
+   int typeiswritten ;
+
+   parcoursprec = (listvar *)NULL;
+   parcours_nom = List_NameOfModule;
+   ValeurMax = 2;
+   while ( parcours_nom  )
+   {
+      /*                                                                      */
+      if ( parcours_nom->o_val == 1 )
+      {
+         IndiceMax = 0;
+         IndiceMin = indicemaxtabvars;
+         /* Open the file to create the Alloc_agrif subroutine                */
+         sprintf(ligne,"alloc_agrif_%s.h",parcours_nom->o_nom);
+         allocationagrif = associate (ligne);
+         /*                                                                   */
+         if ( ModuleIsDefineInInputFile(parcours_nom->o_nom) == 1 )
+         {
+             /* add the call to initworkspace                                 */
+            tofich(allocationagrif,"if ( .NOT. Agrif_Root() ) then ",1);
+            fprintf(allocationagrif,"#include \"GetNumberofcells.h\" \n");
+            tofich(allocationagrif,"else ",1);
+            fprintf(allocationagrif,"#include \"SetNumberofcells.h\" \n");
+            tofich(allocationagrif,"endif ",1);
+            tofich(allocationagrif,"Call Agrif_InitWorkspace ",1);
+         }
+
+         typeiswritten = 0;
+
+         parcours = List_Global_Var;
+         while ( parcours )
+         {
+            if ( !strcasecmp(parcours->var->v_modulename,parcours_nom->o_nom) &&
+                 parcours->var->v_VariableIsParameter == 0                  &&
+                 parcours->var->v_notgrid == 0                              &&
+                 !strcasecmp(parcours->var->v_modulename,parcours_nom->o_nom)  )
+            {
+               /***************************************************************/
+               /***************************************************************/
+               /***************************************************************/
+               v = parcours->var;
+               IndiceMax = 0;
+               IndiceMin = indicemaxtabvars;
+  /* body of the file                                                         */
+  if ( !strcasecmp(v->v_commoninfile,mainfile) )
+  {
+     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
+     {
+        strcpy (ligne, "If (.not. associated(");
+        strcat (ligne, vargridnametabvars(v,0));
+        strcat (ligne, "))                       then");
+        Save_Length(ligne,48);
+        tofich (allocationagrif, ligne,1);
+     }
+     if ( v->v_allocatable != 1 && ( v->v_dimsempty != 1) )
+     {
+        /*                ALLOCATION                                          */
+        if ( v->v_dimension != 0  )
+        {
+           if ( v->v_indicetabvars < IndiceMin ||
+                v->v_indicetabvars > IndiceMax )
+           {
+              parcours1 = parcours;
+              compteur = -1;
+              out = 0;
+              indiceprec = parcours->var->v_indicetabvars -1 ;
+              while ( parcours1 && out == 0 &&
+                      !strcasecmp(  parcours->var->v_readedlistdimension,
+                                  parcours1->var->v_readedlistdimension) &&
+                      !strcasecmp(  parcours->var->v_typevar,
+                                  parcours1->var->v_typevar) &&
+                             ( parcours1->var->v_indicetabvars == indiceprec+1 )
+                     )
+              {
+
+               if ( !strcasecmp(parcours1->var->v_modulename,
+                                parcours_nom->o_nom) ||
+                    !strcasecmp(parcours1->var->v_commonname,
+                                parcours_nom->o_nom) )
+                 {
+                      compteur = compteur +1 ;
+                      indiceprec = parcours1->var->v_indicetabvars;
+                      parcoursprec = parcours1;
+                      parcours1 = parcours1->suiv;
+                 }
+                 else out = 1;
+              }
+              if ( compteur > ValeurMax )
+              {
+                 fprintf(allocationagrif,"      DO i = %d , %d\n",
+                                          parcours->var->v_indicetabvars,
+                                       parcours->var->v_indicetabvars+compteur);
+                 IndiceMin = parcours->var->v_indicetabvars;
+                 IndiceMax = parcours->var->v_indicetabvars+compteur;
+                 strcpy (ligne, "allocate ");
+                 strcat (ligne, "(");
+                 strcat (ligne, vargridnametabvars(v,1));
+                 strcat (ligne, vargridparam(v,0));
+                 strcat (ligne, ")");
+                 Save_Length(ligne,48);
+                 tofich (allocationagrif, ligne,1);
+                 fprintf(allocationagrif,"      end do\n");
+                 parcours = parcoursprec;
+              }
+              else
+              {
+                 strcpy (ligne, "allocate ");
+                 strcat (ligne, "(");
+                 strcat (ligne, vargridnametabvars(v,0));
+                 strcat (ligne, vargridparam(v,0));
+                 strcat (ligne, ")");
+                 Save_Length(ligne,48);
+                 tofich (allocationagrif, ligne,1);
+              }
+           }
+        } /* end of the allocation part                                       */
+
+        /*                INITIALISATION                                      */
+        if ( strcasecmp(v->v_initialvalue,"") )
+        {
+           strcpy (ligne, "");
+           strcat (ligne, vargridnametabvars(v,0));
+           /* We should modify the initialvalue in the case of variable has   */
+           /*    been defined with others variables                           */
+
+           strcpy(initialvalue,
+                  ChangeTheInitalvaluebyTabvarsName
+                                      (v->v_initialvalue,List_Global_Var,0));
+           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
+           {
+              strcpy(initialvalue,"");
+              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
+                                      (v->v_initialvalue,List_Common_Var,0));
+           }
+           if ( !strcasecmp(initialvalue,v->v_initialvalue) )
+           {
+              strcpy(initialvalue,"");
+              strcpy(initialvalue,ChangeTheInitalvaluebyTabvarsName
+                                     (v->v_initialvalue,List_ModuleUsed_Var,0));
+           }
+           strcat (ligne," = ");
+           strcat (ligne,initialvalue);
+           /*                                                                 */
+           Save_Length(ligne,48);
+           tofich (allocationagrif, ligne,1);
+        }
+     }
+/* Case of structure types */
+        if ((typeiswritten == 0) && !strcasecmp(v->v_typevar,"type"))
+        {
+        sprintf(ligne,"If (.Not.Allocated(Agrif_%s_var)) Then",v->v_modulename);
+        tofich(allocationagrif, ligne, 1);
+        sprintf(ligne,"Allocate(Agrif_%s_var(0:Agrif_NbMaxGrids))",v->v_modulename);
+        tofich(allocationagrif, ligne, 1);
+        strcpy(ligne,"End If");
+        tofich(allocationagrif, ligne, 1);
+        typeiswritten = 1;
+        }
+     if (onlyfixedgrids != 1 && v->v_nbdim!=0)
+     {
+        strcpy (ligne, "   End if");
+        tofich (allocationagrif, ligne,1);
+     }
+  }
+               /***************************************************************/
+               /***************************************************************/
+               /***************************************************************/
+            }
+            parcours = parcours -> suiv;
+         }
+         /*                                                                   */
+         if ( ModuleIsDefineInInputFile(parcours_nom->o_nom) == 1 )
+         {
+            /* add the call to initworkspace                                  */
+            tofich(allocationagrif,"if ( .NOT. Agrif_Root() ) then ",1);
+            fprintf(allocationagrif,"#include \"GetNumberofcells.h\" \n");
+            tofich(allocationagrif,"else ",1);
+            fprintf(allocationagrif,"#include \"SetNumberofcells.h\" \n");
+            tofich(allocationagrif,"endif ",1);
+            tofich(allocationagrif,"Call Agrif_InitWorkspace ",1);
+         }
+         /* Close the file Alloc_agrif                                        */
+         fclose(allocationagrif);
+      } /* end parcours_nom == 1                                              */
+      /*                                                                      */
+      parcours_nom = parcours_nom -> suiv;
+   }
+}
+
+/******************************************************************************/
+/*                           creefichieramr                                   */
+/******************************************************************************/
+/* This subroutine is the main one to create AGRIF_INC files                  */
+/******************************************************************************/
+/*                                                                            */
+/******************************************************************************/
+void creefichieramr (char *NameTampon)
+{
+  listvar *newvar;
+  variable *v;
+  int erreur;
+  char filefich[LONG_C];
+  char ligne[LONG_C];
+  int IndiceMax;
+  int IndiceMin;
+  int InitEmpty;
+  int VarnameEmpty;
+  int donotwrite;
+
+  FILE *initproc;
+  FILE *initglobal;
+  FILE *createvarname;
+  FILE *createvarnameglobal;
+
+  if ( todebug == 1 ) printf("Enter in creefichieramr\n");
+  strcpy (filefich, "cd ");
+  strcat (filefich, nomdir);
+  erreur = system (filefich);
+  if (erreur)
+  {
+     strcpy (filefich, "mkdir ");
+     strcat (filefich, nomdir);
+     system (filefich);
+     printf ("%s: Directory created\n", nomdir);
+  }
+
+/******************************************************************************/
+/******************** Creation of AGRIF_INC files *****************************/
+/******************************************************************************/
+
+/*----------------------------------------------------------------------------*/
+  if ( todebug == 1 )
+  {
+     strcpy(ligne,"initialisations_agrif_");
+     strcat(ligne,NameTampon);
+     strcat(ligne,".h");
+     initproc = associate (ligne);
+/*----------------------------------------------------------------------------*/
+     strcpy(ligne,"createvarname_agrif_");
+     strcat(ligne,NameTampon);
+     strcat(ligne,".h");
+     createvarname = associate (ligne);
+/*----------------------------------------------------------------------------*/
+     InitEmpty = 1 ;
+     VarnameEmpty = 1 ;
+
+     newvar = List_Global_Var;
+     while ( newvar && todebug == 1 )
+     {
+        donotwrite = 0;
+        v = newvar->var;
+
+        if ( ( v->v_common == 1 || v->v_module == 1 ) && donotwrite == 0 )
+        {
+          write_createvarnameagrif_file(v,createvarname,&VarnameEmpty);
+          write_initialisationsagrif_file(v,initproc,&InitEmpty);
+        }
+        newvar = newvar->suiv;
+     }
+  /*                                                                          */
+     fclose (createvarname);
+     fclose (initproc);
+  /*--------------------------------------------------------------------------*/
+     if ( Did_filetoparse_readed(curmodulename) == 0 )
+     {
+        if ( InitEmpty != 1  )
+        {
+           initglobal = associateaplus("initialisations_agrif.h");
+           strcpy(ligne,"#include \"initialisations_agrif_");
+           strcat(ligne,NameTampon);
+           strcat(ligne,".h\"\n");
+           fprintf(initglobal,ligne);
+           fclose(initglobal);
+        }
+  /*--------------------------------------------------------------------------*/
+        if ( VarnameEmpty != 1 )
+        {
+           createvarnameglobal= associateaplus("createvarname_agrif.h");
+           strcpy(ligne,"#include \"createvarname_agrif_");
+           strcat(ligne,NameTampon);
+           strcat(ligne,".h\"\n");
+           fprintf(createvarnameglobal,ligne);
+           fclose(createvarnameglobal);
+        }
+     }
+  }
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+  IndiceMax = 0;
+  IndiceMin = 0;
+
+  write_allocation_Common_0();
+  write_allocation_Global_0();
+
+  Write_Alloc_Agrif_Files();
+  write_probdimagrif_file();
+  write_keysagrif_file();
+  write_modtypeagrif_file();
+  if ( NbMailleXDefined == 1 )
+                             write_Setnumberofcells_file("SetNumberofcells.h");
+  if ( NbMailleXDefined == 1 )
+                             write_Getnumberofcells_file("GetNumberofcells.h");
+  retour77 = 0;
+  if ( NbMailleXDefined == 1 )
+                          write_Setnumberofcells_file("SetNumberofcellsFree.h");
+  if ( NbMailleXDefined == 1 )
+                          write_Getnumberofcells_file("GetNumberofcellsFree.h");
+  retour77 = 1;
+  if ( NbMailleXDefined == 1 )
+                         write_Setnumberofcells_file("SetNumberofcellsFixed.h");
+  if ( NbMailleXDefined == 1 )
+                         write_Getnumberofcells_file("GetNumberofcellsFixed.h");
+  if ( todebug == 1 ) printf("Out of creefichieramr\n");
+}
Index: /branches/DEV_r1837_MLF/AGRIF/agrif_opa.in
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/agrif_opa.in	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/agrif_opa.in	(revision 1844)
@@ -0,0 +1,12 @@
+% Number of cells in each direction %
+ 2D nbcellsx,nbcellsy;
+% Name of the common file : an include file (paramfile) OR a module (parammodule) %  
+ parammodule par_oce ;
+
+USE ONLY_FIXED_GRIDS;
+
+% Variables which are not grid dependent %
+% notgriddep :: name of the variable; %
+notgriddep :: nstop;
+
+%USE DEBUG;%
Index: /branches/DEV_r1837_MLF/AGRIF/efface
===================================================================
--- /branches/DEV_r1837_MLF/AGRIF/efface	(revision 1844)
+++ /branches/DEV_r1837_MLF/AGRIF/efface	(revision 1844)
@@ -0,0 +1,9 @@
+rm -f AGRIF_INC/*
+rm -f AGRIF_MODELFILES/*
+rm -f AGRIF_OBJS/*
+rm -f AGRIF_YOURFILES/*
+rm -f SORTIE/*
+
+rm -f .depend*
+rm -f .agrif*
+rm -f LIB/*.o
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Header$
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,140 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 00:30:00                # Max total CPU time
+#-Q- sxnec #@$-lt 00:30:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 500Mb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 1800
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 1.8Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=1:01:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=1:01:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=500mb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=00:30:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      GYRE configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories:
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/GYRE
+#- execution repository
+R_TMP=$TMPDIR         
+
+#################################
+# End of user modification
+#################################
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+#- Namelist for the configuration 
+cp ${R_EXPER}/namelist namelist
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT ocean.output ${R_SORTIE_OCE}/ocean.output
+$DPUT solver.stat ${R_SORTIE_OCE}/solver.stat
+[ -f mpp.output* ] && $DPUT mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_grid_*.nc
+do
+$DPUT $file_netcdf ${R_SORTIE_OCE}/$file_netcdf
+done
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT $restart ${R_SORTIE_OCE}/$restart 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,350 @@
+<?xml version="1.0"?>
+<simulation>
+  
+  <context id="nemo"> 
+    
+    <!-- $id$ -->
+
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+    </field_definition>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    <file_definition >
+
+      <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
+      </group>
+
+      <group id="2h" output_freq="7200"   output_level="10" enabled=".TRUE.">                      <!-- 2h files -->
+      </group>
+
+      <group id="3h" output_freq="10800"  output_level="10" enabled=".TRUE.">                      <!-- 3h files -->
+      </group>
+
+      <group id="4h" output_freq="14400"  output_level="10" enabled=".TRUE.">                      <!-- 4h files -->
+      </group>
+
+      <group id="6h" output_freq="21600"  output_level="10" enabled=".TRUE.">                      <!-- 6h files -->
+      </group>
+
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+      </group>
+
+      <group id="2d" output_freq="172800" output_level="10" enabled=".TRUE.">                      <!-- 2d files -->
+
+        <file id="2d_grid_T" name="auto" description="ocean T grid variables" >
+          <field ref="sst"          name="sosstsst"  />
+	  <field ref="sss"          name="sosaline"  />
+	  <field ref="ssh"          name="sossheig"  />
+        </file>
+
+      </group>
+
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+     
+        <file id="5d_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="toce"         name="votemper"  />
+	  <field ref="soce"         name="vosaline"  />
+	  <field ref="sst"          name="sosstsst"  />
+	  <field ref="sss"          name="sosaline"  />
+	  <field ref="ssh"          name="sossheig"  />
+	  <field ref="emp"          name="sowaflup"  />
+	  <field ref="qsr"          name="soshfldo"  />
+	  <field ref="emps"         name="sowaflcd"  />
+	  <field ref="qns+qsr"      name="sohefldo"  />
+	  <field ref="mldr10_1"     name="somxl010"  />
+	  <field ref="mldkz5"       name="somixhgt"  />
+	  <field ref="wspd"         name="sowindsp"  />
+	  <field ref="qrp"          name="sohefldp"  />
+	  <field ref="erp"          name="sowafldp"  />
+	  <field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+	  <field ref="mlddzt"       name="sothedep"  />
+	  <field ref="20d"          name="so20chgt"  />
+	  <field ref="28d"          name="so28chgt"  />
+	  <field ref="hc300"        name="sohtc300"  />
+        </file>
+
+        <file id="5d_grid_U" name="auto" description="ocean U grid variables" >
+          <field ref="uoce"         name="vozocrtx"  />
+          <field ref="uoce_eiv"     name="vozoeivu"  />
+          <field ref="utau"         name="sozotaux"  />
+        </file>
+
+        <file id="5d_grid_V" name="auto" description="ocean V grid variables" >
+          <field ref="voce"         name="vomecrty"  /> 
+          <field ref="voce_eiv"     name="vomeeivv"  />
+          <field ref="vtau"         name="sometauy"  /> 
+        </file>
+
+        <file id="5d_grid_W" name="auto" description="ocean W grid variables" >
+          <field ref="woce"         name="vovecrtz" />
+          <field ref="woce_eiv"     name="voveeivw" />
+          <field ref="avt"          name="votkeavt" />
+          <field ref="avt_evd"      name="votkeevd" />
+          <field ref="avm"          name="votkeavm" />
+          <field ref="avm_evd"      name="votkeevm" />
+          <field ref="avs"          name="voddmavs" />
+          <field ref="aht2d"        name="soleahtw" />
+          <field ref="aht2d_eiv"    name="soleaeiw" />
+        </file>
+
+      </group>
+
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+
+
+   </file_definition>
+
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+
+  <axis_definition>  
+     <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+     <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+     <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+     <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+     <axis id="none" description="axe non defini" unit="none" size="1" />
+  </axis_definition> 
+
+  <grid_definition>
+    <grid id="grid_T" description="grid T" />
+    <grid id="grid_U" description="grid U" />
+    <grid id="grid_V" description="grid V" />
+    <grid id="grid_W" description="grid W" />
+    <grid id="scalarpoint" description="scalar" >
+      <zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+    </grid>
+  </grid_definition>    
+
+</context>
+
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/namelist	(revision 1844)
@@ -0,0 +1,679 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      =  "GYRE"   !  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =    4320   !  last  time step (std 5475)
+   nn_date0    =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =      30   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =    4320   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =      60   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .false.   !  clobber (overwrite) an existing file
+   nn_chunksz  = 0         !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .true.    !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    0      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea    =   0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=    5.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 7200.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   60      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 7200.           !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 7200.           !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .true.    !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .false.   !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .false.   !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked                              , 
+                           !                     =1 global mean of e-p-r set to zero at each nn_fsbc time step   ,
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   100     !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.1e0   !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_qns0     =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u10_core'   ,       -1          , 'u10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'U1'
+   sn_wndj     = 'v10_core'   ,       -1          , 'v10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'V1'
+   sn_qsr      = 'qsw_core'   ,       -1          , 'swdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_qlw      = 'qlw_core'   ,       -1          , 'lwdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tair     = 't2_core'    ,       -1          , 't2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_humi     = 'q2_core'    ,       -1          , 'q2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_prec     = 'precip_core',       -1          , 'precip'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_snow     = 'snow_core'  ,       -1          , 'snow'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tdif     = 'taudif_core',       24          , 'taudif'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .true.    !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_data'   ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   0.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =    1.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 3000.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   = 3000.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+   ln_bfr2d    =   .false. !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    2      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    7.7e-4 !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =  1000.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =     0.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   -1      !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .false. !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .true.    !  z-coordinate - full steps                   
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .true.   !  laplacian operator         
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = 100000.        !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =     0.         !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =   3.75    !  coef. of the surface input of tke
+   rn_emin     =   1.e-5   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.4     !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.4     !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    210    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .false.    !  Add zonal means and meridional stream functions
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,20 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
+  
+  
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make	(revision 1844)
@@ -0,0 +1,11250 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_bdy \
+     key_c1d \
+     key_coupled \
+     key_cpl_albedo \
+     key_cpl_carbon_cycle \
+     key_cpl_discharge \
+     key_cpl_ocevel \
+     key_cpl_rootexchg \
+     key_diaar5 \
+     key_diaeiv \
+     key_diagap \
+     key_diahdy \
+     key_diahth \
+     key_diainstant \
+     key_diaspr \
+     key_dimgout \
+     key_dtasal \
+     key_dtatem \
+     key_dynldf_c1d \
+     key_dynldf_c2d \
+     key_dynldf_c3d \
+     key_dynspg_exp \
+     key_dynspg_flt \
+     key_dynspg_ts \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_floats \
+     key_flx_bulk_monthly \
+     key_flx_core \
+     key_flx_forced_daily \
+     key_gyre \
+     key_iomput \
+     key_kppcustom \
+     key_kpplktb \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_mpp_dyndist \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_noslip_accurate \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_orca_lev10 \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_pomme_r025 \
+     key_top \
+     key_trabbc \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_tradmp \
+     key_traldf_ano \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trddyn \
+     key_trdmld \
+     key_trdtra \
+     key_trdvor \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zdfcst \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdfric \
+     key_zdftke \
+     key_zdftke_old \
+     key_zdftmx 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_opa_interp.o)\
+		$(MODEL_LIB)(agrif_opa_sponge.o)\
+		$(MODEL_LIB)(agrif_opa_update.o)\
+		$(MODEL_LIB)(albedo.o)\
+		$(MODEL_LIB)(bdy_oce.o)\
+		$(MODEL_LIB)(bdy_par.o)\
+		$(MODEL_LIB)(bdydta.o)\
+		$(MODEL_LIB)(bdydyn.o)\
+		$(MODEL_LIB)(bdyini.o)\
+		$(MODEL_LIB)(bdytides.o)\
+		$(MODEL_LIB)(bdytra.o)\
+		$(MODEL_LIB)(bdyvol.o)\
+		$(MODEL_LIB)(c1d.o)\
+		$(MODEL_LIB)(cla.o)\
+		$(MODEL_LIB)(cla_div.o)\
+		$(MODEL_LIB)(cla_dynspg.o)\
+		$(MODEL_LIB)(closea.o)\
+		$(MODEL_LIB)(cpl_oasis3.o)\
+		$(MODEL_LIB)(cpl_oasis4.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(diaar5.o)\
+		$(MODEL_LIB)(diadimg.o)\
+		$(MODEL_LIB)(diafwb.o)\
+		$(MODEL_LIB)(diagap.o)\
+		$(MODEL_LIB)(diahdy.o)\
+		$(MODEL_LIB)(diahth.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(diaptr.o)\
+		$(MODEL_LIB)(diawri.o)\
+		$(MODEL_LIB)(diawri_c1d.o)\
+		$(MODEL_LIB)(divcur.o)\
+		$(MODEL_LIB)(dom_ice_2.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(domhgr.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(domvvl.o)\
+		$(MODEL_LIB)(domwri.o)\
+		$(MODEL_LIB)(domzgr.o)\
+		$(MODEL_LIB)(dtasal.o)\
+		$(MODEL_LIB)(dtatem.o)\
+		$(MODEL_LIB)(dynadv.o)\
+		$(MODEL_LIB)(dynadv_cen2.o)\
+		$(MODEL_LIB)(dynadv_ubs.o)\
+		$(MODEL_LIB)(dynbfr.o)\
+		$(MODEL_LIB)(dyncor_c1d.o)\
+		$(MODEL_LIB)(dynhpg.o)\
+		$(MODEL_LIB)(dynkeg.o)\
+		$(MODEL_LIB)(dynldf.o)\
+		$(MODEL_LIB)(dynldf_bilap.o)\
+		$(MODEL_LIB)(dynldf_bilapg.o)\
+		$(MODEL_LIB)(dynldf_iso.o)\
+		$(MODEL_LIB)(dynldf_lap.o)\
+		$(MODEL_LIB)(dynnxt.o)\
+		$(MODEL_LIB)(dynnxt_c1d.o)\
+		$(MODEL_LIB)(dynspg.o)\
+		$(MODEL_LIB)(dynspg_exp.o)\
+		$(MODEL_LIB)(dynspg_flt.o)\
+		$(MODEL_LIB)(dynspg_oce.o)\
+		$(MODEL_LIB)(dynspg_ts.o)\
+		$(MODEL_LIB)(dynvor.o)\
+		$(MODEL_LIB)(dynzad.o)\
+		$(MODEL_LIB)(dynzdf.o)\
+		$(MODEL_LIB)(dynzdf_exp.o)\
+		$(MODEL_LIB)(dynzdf_imp.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(fldread.o)\
+		$(MODEL_LIB)(flo4rk.o)\
+		$(MODEL_LIB)(flo_oce.o)\
+		$(MODEL_LIB)(floats.o)\
+		$(MODEL_LIB)(floblk.o)\
+		$(MODEL_LIB)(flodom.o)\
+		$(MODEL_LIB)(flowri.o)\
+		$(MODEL_LIB)(geo2ocean.o)\
+		$(MODEL_LIB)(ice_2.o)\
+		$(MODEL_LIB)(iceini_2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(lbcnfd.o)\
+		$(MODEL_LIB)(ldfdyn.o)\
+		$(MODEL_LIB)(ldfdyn_oce.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(limadv_2.o)\
+		$(MODEL_LIB)(limdia_2.o)\
+		$(MODEL_LIB)(limdmp_2.o)\
+		$(MODEL_LIB)(limdyn_2.o)\
+		$(MODEL_LIB)(limhdf_2.o)\
+		$(MODEL_LIB)(limistate_2.o)\
+		$(MODEL_LIB)(limmsh_2.o)\
+		$(MODEL_LIB)(limrhg_2.o)\
+		$(MODEL_LIB)(limrst_2.o)\
+		$(MODEL_LIB)(limsbc_2.o)\
+		$(MODEL_LIB)(limtab_2.o)\
+		$(MODEL_LIB)(limthd_2.o)\
+		$(MODEL_LIB)(limthd_lac_2.o)\
+		$(MODEL_LIB)(limthd_zdf_2.o)\
+		$(MODEL_LIB)(limtrp_2.o)\
+		$(MODEL_LIB)(limwri_2.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oasis4_date.o)\
+		$(MODEL_LIB)(obc_oce.o)\
+		$(MODEL_LIB)(obc_par.o)\
+		$(MODEL_LIB)(obcdta.o)\
+		$(MODEL_LIB)(obcdyn.o)\
+		$(MODEL_LIB)(obcdyn_bt.o)\
+		$(MODEL_LIB)(obcfla.o)\
+		$(MODEL_LIB)(obcini.o)\
+		$(MODEL_LIB)(obcrad.o)\
+		$(MODEL_LIB)(obcrst.o)\
+		$(MODEL_LIB)(obctra.o)\
+		$(MODEL_LIB)(obcvol.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(par_ice_2.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(restart.o)\
+		$(MODEL_LIB)(sbc_ice.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcana.o)\
+		$(MODEL_LIB)(sbcblk_clio.o)\
+		$(MODEL_LIB)(sbcblk_core.o)\
+		$(MODEL_LIB)(sbccpl.o)\
+		$(MODEL_LIB)(sbcflx.o)\
+		$(MODEL_LIB)(sbcfwb.o)\
+		$(MODEL_LIB)(sbcice_if.o)\
+		$(MODEL_LIB)(sbcice_lim.o)\
+		$(MODEL_LIB)(sbcice_lim_2.o)\
+		$(MODEL_LIB)(sbcmod.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sbcssm.o)\
+		$(MODEL_LIB)(sbcssr.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(solmat.o)\
+		$(MODEL_LIB)(solpcg.o)\
+		$(MODEL_LIB)(solsor.o)\
+		$(MODEL_LIB)(solver.o)\
+		$(MODEL_LIB)(sshwzv.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(step_c1d.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(thd_ice_2.o)\
+		$(MODEL_LIB)(traadv.o)\
+		$(MODEL_LIB)(traadv_cen2.o)\
+		$(MODEL_LIB)(traadv_eiv.o)\
+		$(MODEL_LIB)(traadv_muscl.o)\
+		$(MODEL_LIB)(traadv_muscl2.o)\
+		$(MODEL_LIB)(traadv_qck.o)\
+		$(MODEL_LIB)(traadv_tvd.o)\
+		$(MODEL_LIB)(traadv_ubs.o)\
+		$(MODEL_LIB)(trabbc.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(tradmp.o)\
+		$(MODEL_LIB)(traldf.o)\
+		$(MODEL_LIB)(traldf_bilap.o)\
+		$(MODEL_LIB)(traldf_bilapg.o)\
+		$(MODEL_LIB)(traldf_iso.o)\
+		$(MODEL_LIB)(traldf_lap.o)\
+		$(MODEL_LIB)(tranpc.o)\
+		$(MODEL_LIB)(tranxt.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trasbc.o)\
+		$(MODEL_LIB)(trazdf.o)\
+		$(MODEL_LIB)(trazdf_exp.o)\
+		$(MODEL_LIB)(trazdf_imp.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trdicp.o)\
+		$(MODEL_LIB)(trdicp_oce.o)\
+		$(MODEL_LIB)(trdmld.o)\
+		$(MODEL_LIB)(trdmld_oce.o)\
+		$(MODEL_LIB)(trdmld_rst.o)\
+		$(MODEL_LIB)(trdmod.o)\
+		$(MODEL_LIB)(trdmod_oce.o)\
+		$(MODEL_LIB)(trdvor.o)\
+		$(MODEL_LIB)(trdvor_oce.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfbfr.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfevd.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfkpp.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zdfric.o)\
+		$(MODEL_LIB)(zdftke.o)\
+		$(MODEL_LIB)(zdftke_old.o)\
+		$(MODEL_LIB)(zdftmx.o)\
+		$(MODEL_LIB)(zpshde.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_opa_interp.o) :	\
+	agrif_opa_interp.F90
+$(MODEL_LIB)(agrif_opa_sponge.o) :	\
+	agrif_opa_sponge.F90
+$(MODEL_LIB)(agrif_opa_update.o) :	\
+	agrif_opa_update.F90
+$(MODEL_LIB)(albedo.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	in_out_manager.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	albedo.F90
+$(MODEL_LIB)(bdy_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	bdy_oce.F90
+$(MODEL_LIB)(bdy_par.o) :	\
+	KEY_CPP \
+	bdy_par.F90
+$(MODEL_LIB)(bdydta.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	bdydta.F90
+$(MODEL_LIB)(bdydyn.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdydyn.F90
+$(MODEL_LIB)(bdyini.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdyini.F90
+$(MODEL_LIB)(bdytides.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdytides.F90
+$(MODEL_LIB)(bdytra.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdytra.F90
+$(MODEL_LIB)(bdyvol.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	bdyvol.F90
+$(MODEL_LIB)(c1d.o) :	\
+	KEY_CPP \
+	c1d.F90
+$(MODEL_LIB)(cla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla.F90
+$(MODEL_LIB)(cla_div.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	cla_div.F90
+$(MODEL_LIB)(cla_dynspg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla_dynspg.F90
+$(MODEL_LIB)(closea.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	closea.F90
+$(MODEL_LIB)(cpl_oasis3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	cpl_oasis3.F90
+$(MODEL_LIB)(cpl_oasis4.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oasis4_date.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	cpl_oasis4.F90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(diaar5.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diaar5.F90
+$(MODEL_LIB)(diadimg.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diadimg.F90
+$(MODEL_LIB)(diafwb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	diafwb.F90
+$(MODEL_LIB)(diagap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diagap.F90
+$(MODEL_LIB)(diahdy.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahdy.F90
+$(MODEL_LIB)(diahth.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahth.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(diaptr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diaptr.F90
+$(MODEL_LIB)(diawri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	lib_mpp.F90 \
+	diawri_dimg.h90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri.F90
+$(MODEL_LIB)(diawri_c1d.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	trazdf_exp.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri_c1d.F90
+$(MODEL_LIB)(divcur.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	divcur.F90
+$(MODEL_LIB)(dom_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	dom_ice_2.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(domhgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	domhgr.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(domvvl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domvvl.F90
+$(MODEL_LIB)(domwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domwri.F90
+$(MODEL_LIB)(domzgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domzgr.F90
+$(MODEL_LIB)(dtasal.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtasal.F90
+$(MODEL_LIB)(dtatem.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtatem.F90
+$(MODEL_LIB)(dynadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv.F90
+$(MODEL_LIB)(dynadv_cen2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_cen2.F90
+$(MODEL_LIB)(dynadv_ubs.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_ubs.F90
+$(MODEL_LIB)(dynbfr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynbfr.F90
+$(MODEL_LIB)(dyncor_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dyncor_c1d.F90
+$(MODEL_LIB)(dynhpg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynhpg.F90
+$(MODEL_LIB)(dynkeg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynkeg.F90
+$(MODEL_LIB)(dynldf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf.F90
+$(MODEL_LIB)(dynldf_bilap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilap.F90
+$(MODEL_LIB)(dynldf_bilapg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilapg.F90
+$(MODEL_LIB)(dynldf_iso.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_iso.F90
+$(MODEL_LIB)(dynldf_lap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_lap.F90
+$(MODEL_LIB)(dynnxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynnxt.F90
+$(MODEL_LIB)(dynnxt_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	KEY_CPP \
+	dynnxt_c1d.F90
+$(MODEL_LIB)(dynspg.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	in_out_manager.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg.F90
+$(MODEL_LIB)(dynspg_exp.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_exp.F90
+$(MODEL_LIB)(dynspg_flt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdydyn.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynspg_flt.F90
+$(MODEL_LIB)(dynspg_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dynspg_oce.F90
+$(MODEL_LIB)(dynspg_ts.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcfla.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_ts.F90
+$(MODEL_LIB)(dynvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynvor.F90
+$(MODEL_LIB)(dynzad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzad.F90
+$(MODEL_LIB)(dynzdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynzdf.F90
+$(MODEL_LIB)(dynzdf_exp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_exp.F90
+$(MODEL_LIB)(dynzdf_imp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_imp.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(fldread.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	fldread.F90
+$(MODEL_LIB)(flo4rk.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	KEY_CPP \
+	flo4rk.F90
+$(MODEL_LIB)(flo_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	flo_oce.F90
+$(MODEL_LIB)(floats.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	lib_mpp.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	floats.F90
+$(MODEL_LIB)(floblk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	floblk.F90
+$(MODEL_LIB)(flodom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flodom.F90
+$(MODEL_LIB)(flowri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flowri.F90
+$(MODEL_LIB)(geo2ocean.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	geo2ocean.F90
+$(MODEL_LIB)(ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	ice_2.F90
+$(MODEL_LIB)(iceini_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrst_2.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iceini_2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	c1d.F90 \
+	cla_dynspg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	daymod.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	restart.F90 \
+	zdf_oce.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(lbcnfd.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	lbcnfd.F90
+$(MODEL_LIB)(ldfdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	ldftra_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_antarctic.h90 \
+	ldfdyn_arctic.h90 \
+	ldfdyn_c1d.h90 \
+	ldfdyn_c2d.h90 \
+	ldfdyn_c3d.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldfdyn.F90
+$(MODEL_LIB)(ldfdyn_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldfdyn_oce.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(limadv_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limadv_2.F90
+$(MODEL_LIB)(limdia_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdia_2.F90
+$(MODEL_LIB)(limdmp_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	tradmp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdmp_2.F90
+$(MODEL_LIB)(limdyn_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limistate_2.F90 \
+	limrhg_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdyn_2.F90
+$(MODEL_LIB)(limhdf_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limhdf_2.F90
+$(MODEL_LIB)(limistate_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limistate_2.F90
+$(MODEL_LIB)(limmsh_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limmsh_2.F90
+$(MODEL_LIB)(limrhg_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limrhg_2.F90
+$(MODEL_LIB)(limrst_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	limrst_2.F90
+$(MODEL_LIB)(limsbc_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limsbc_2.F90
+$(MODEL_LIB)(limtab_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	KEY_CPP \
+	limtab_2.F90
+$(MODEL_LIB)(limthd_2.o) :	\
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limistate_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limthd_2.F90
+$(MODEL_LIB)(limthd_lac_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	ice_2.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_lac_2.F90
+$(MODEL_LIB)(limthd_zdf_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_zdf_2.F90
+$(MODEL_LIB)(limtrp_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limtrp_2.F90
+$(MODEL_LIB)(limwri_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	diadimg.F90 \
+	limwri_dimg_2.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	limwri_2.F90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oasis4_date.o) :	\
+	KEY_CPP \
+	oasis4_date.F90
+$(MODEL_LIB)(obc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	obc_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	obc_oce.F90
+$(MODEL_LIB)(obc_par.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	obc_par_EEL_R5.h90 \
+	obc_par_POMME_R025.h90 \
+	KEY_CPP \
+	obc_par.F90
+$(MODEL_LIB)(obcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	obcdta.F90
+$(MODEL_LIB)(obcdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn.F90
+$(MODEL_LIB)(obcdyn_bt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn_bt.F90
+$(MODEL_LIB)(obcfla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	obc_oce.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcfla.F90
+$(MODEL_LIB)(obcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcini.F90
+$(MODEL_LIB)(obcrad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcrad.F90
+$(MODEL_LIB)(obcrst.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcrst.F90
+$(MODEL_LIB)(obctra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obctra.F90
+$(MODEL_LIB)(obcvol.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcvol.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	cla.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynnxt_c1d.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(par_ice_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	par_ice_2.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	par_POMME_R025.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(restart.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	restart.F90
+$(MODEL_LIB)(sbc_ice.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_ice_2.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_ice.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcana.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcana.F90
+$(MODEL_LIB)(sbcblk_clio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_clio.F90
+$(MODEL_LIB)(sbcblk_core.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_core.F90
+$(MODEL_LIB)(sbccpl.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	phycst.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbccpl.F90
+$(MODEL_LIB)(sbcflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcflx.F90
+$(MODEL_LIB)(sbcfwb.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcfwb.F90
+$(MODEL_LIB)(sbcice_if.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcice_if.F90
+$(MODEL_LIB)(sbcice_lim.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim.F90
+$(MODEL_LIB)(sbcice_lim_2.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrhg_2.F90 \
+	limrst_2.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	tradmp.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim_2.F90
+$(MODEL_LIB)(sbcmod.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	albedo.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcmod.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sbcssm.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssm.F90
+$(MODEL_LIB)(sbcssr.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssr.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sol_oce.F90
+$(MODEL_LIB)(solmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	KEY_CPP \
+	solmat.F90
+$(MODEL_LIB)(solpcg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	solpcg.F90
+$(MODEL_LIB)(solsor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	solsor.F90
+$(MODEL_LIB)(solver.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	zdf_oce.F90 \
+	KEY_CPP \
+	solver.F90
+$(MODEL_LIB)(sshwzv.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sshwzv.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	albedo.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynhpg.F90 \
+	dynkeg.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynzad.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obctra.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	traqsr.F90 \
+	trazdf.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	cla.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynspg.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbccpl.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(step_c1d.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obctra.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traqsr.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	daymod.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynnxt_c1d.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	stpctl.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	step_c1d.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(thd_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	thd_ice_2.F90
+$(MODEL_LIB)(traadv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv.F90
+$(MODEL_LIB)(traadv_cen2.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_cen2.F90
+$(MODEL_LIB)(traadv_eiv.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	diaar5.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_eiv.F90
+$(MODEL_LIB)(traadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl.F90
+$(MODEL_LIB)(traadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl2.F90
+$(MODEL_LIB)(traadv_qck.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_qck.F90
+$(MODEL_LIB)(traadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_tvd.F90
+$(MODEL_LIB)(traadv_ubs.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_ubs.F90
+$(MODEL_LIB)(trabbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trabbc.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	eosbn2.F90 \
+	iom.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	trabbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(tradmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	tradmp.F90
+$(MODEL_LIB)(traldf.o) :	\
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	trazdf.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf.F90
+$(MODEL_LIB)(traldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_bilap.F90
+$(MODEL_LIB)(traldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	KEY_CPP \
+	traldf_bilapg.F90
+$(MODEL_LIB)(traldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_iso.F90
+$(MODEL_LIB)(traldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_lap.F90
+$(MODEL_LIB)(tranpc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	tranpc.F90
+$(MODEL_LIB)(tranxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obctra.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	tranxt.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traqsr.F90
+$(MODEL_LIB)(trasbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	traqsr.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trasbc.F90
+$(MODEL_LIB)(trazdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf.F90
+$(MODEL_LIB)(trazdf_exp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_exp.F90
+$(MODEL_LIB)(trazdf_imp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_imp.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trdicp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdicp.F90
+$(MODEL_LIB)(trdicp_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdicp_oce.F90
+$(MODEL_LIB)(trdmld.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld.F90
+$(MODEL_LIB)(trdmld_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdmld_oce.F90
+$(MODEL_LIB)(trdmld_rst.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	restart.F90 \
+	trdmod_oce.F90 \
+	KEY_CPP \
+	trdmld_rst.F90
+$(MODEL_LIB)(trdmod.o) :	\
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdmod.F90
+$(MODEL_LIB)(trdmod_oce.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	KEY_CPP \
+	trdmod_oce.F90
+$(MODEL_LIB)(trdvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdvor.F90
+$(MODEL_LIB)(trdvor_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdvor_oce.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfbfr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfbfr.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfevd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfevd.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	restart.F90 \
+	tranpc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfkpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	zdfkpp.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zdfric.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfric.F90
+$(MODEL_LIB)(zdftke.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke.F90
+$(MODEL_LIB)(zdftke_old.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke_old.F90
+$(MODEL_LIB)(zdftmx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftmx.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#---------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model (BB_make.ldef in scripts)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrc AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for GYRE ocean configuration: Analytical forcing ---
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_zco key_gyre key_dynspg_flt key_ldfslp key_zdftke key_vectopt_loop key_vectopt_memory key_iomput
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Id: $
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,142 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 00:30:00                # Max total CPU time
+#-Q- sxnec #@$-lt 00:30:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 500Mb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 1800
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 1.8Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=1:01:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=1:01:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=500mb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=00:30:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      GYRE configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories:
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/GYRE_LOBSTER
+#- execution repository
+R_TMP=$TMPDIR         
+
+#################################
+# End of user modification
+#################################
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+#- Namelist for the configuration 
+cp ${R_EXPER}/namelist         namelist
+cp ${R_EXPER}/namelist_top     namelist_top
+cp ${R_EXPER}/namelist_lobster namelist_lobster
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT ocean.output ${R_SORTIE_OCE}/ocean.output
+$DPUT solver.stat ${R_SORTIE_OCE}/solver.stat
+[ -f mpp.output* ] && $DPUT mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_grid_*.nc *_diad_T*.nc *_ptrc_T*.nc
+do
+$DPUT $file_netcdf ${R_SORTIE_OCE}/$file_netcdf
+done
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT $restart ${R_SORTIE_OCE}/$restart 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,431 @@
+<?xml version="1.0"?>
+<simulation>
+  
+  <context id="nemo"> 
+    
+    <!-- $id$ -->
+
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+      <!-- ptrc on T grid -->
+
+     <group id="ptrc_T" axis_ref="deptht" grid_ref="grid_T">
+       <field id="DET"      description="Detritus"                                      unit="mmole-N/m3" />
+       <field id="ZOO"      description="Zooplankton Concentration"                     unit="mmole-N/m3" />
+       <field id="PHY"      description="Phytoplankton Concentration"                   unit="mmole-N/m3" />
+       <field id="NO3"      description="Nitrate Concentration"                         unit="mmole-N/m3" />
+       <field id="NH4"      description="Ammonium Concentration"                        unit="mmole-N/m3" />
+       <field id="DOM"      description="Dissolved Organic Matter"                      unit="mmole-N/m3" />
+     </group>
+
+     <!-- diad on T grid -->
+
+     <group id="diad_T" axis_ref="none" grid_ref="grid_T">  
+       <field id="FNO3PHY"  description="FNO3PHY"                             unit="-"  axis_ref="deptht" /> 
+       <field id="FNH4PHY"  description="FNH4PHY"                             unit="-"  axis_ref="deptht" /> 
+       <field id="FNH4NO3"  description="FNH4NO3"                             unit="-"  axis_ref="deptht" /> 
+       <field id="TNO3PHY"  description="TNO3PHY"                             unit="-"  /> 
+       <field id="TNH4PHY"  description="TNH4PHY"                             unit="-"  /> 
+       <field id="TPHYDOM"  description="TPHYDOM"                             unit="-"  /> 
+       <field id="TPHYNH4"  description="TPHYNH4"                             unit="-"  /> 
+       <field id="TPHYZOO"  description="TPHYZOO"                             unit="-"  /> 
+       <field id="TPHYDET"  description="TPHYDET"                             unit="-"  /> 
+       <field id="TDETZOO"  description="TDETZOO"                             unit="-"  /> 
+       <field id="TDETSED"  description="TDETSED"                             unit="-"  /> 
+       <field id="TZOODET"  description="TZOODET"                             unit="-"  /> 
+       <field id="TZOOBOD"  description="TZOOBOD"                             unit="-"  /> 
+       <field id="TZOONH4"  description="TZOONH4"                             unit="-"  /> 
+       <field id="TZOODOM"  description="TZOODOM"                             unit="-"  /> 
+       <field id="TNH4NO3"  description="TNH4NO3"                             unit="-"  /> 
+       <field id="TDOMNH4"  description="TDOMNH4"                             unit="-"  /> 
+       <field id="TDETNH4"  description="TDETNH4"                             unit="-"  /> 
+       <field id="TPHYTOT"  description="TPHYTOT"                             unit="-"  /> 
+       <field id="TZOOTOT"  description="TZOOTOT"                             unit="-"  /> 
+       <field id="TDETDOM"  description="TDETDOM"                             unit="-"  /> 
+       <field id="SEDPOC"   description="SEDPOC"                              unit="-"  /> 
+     </group>
+
+  </field_definition>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+
+  <file_definition output_level="10" enabled=".TRUE.">
+
+
+      <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
+      </group>
+
+      <group id="2h" output_freq="7200"   output_level="10" enabled=".TRUE.">                      <!-- 2h files -->
+      </group>
+
+      <group id="3h" output_freq="10800"  output_level="10" enabled=".TRUE.">                      <!-- 3h files -->
+      </group>
+
+      <group id="4h" output_freq="14400"  output_level="10" enabled=".TRUE.">                      <!-- 4h files -->
+      </group>
+
+      <group id="6h" output_freq="21600"  output_level="10" enabled=".TRUE.">                      <!-- 6h files -->
+      </group>
+
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+      </group>
+
+      <group id="2d" output_freq="172800" output_level="10" enabled=".TRUE.">                      <!-- 2d files -->
+
+        <file id="2d_grid_T" name="auto" description="ocean T grid variables" >
+          <field ref="sst"          name="sosstsst"  />
+          <field ref="sss"          name="sosaline"  />
+          <field ref="ssh"          name="sossheig"  />
+        </file>
+
+       <file id="2d_ptrc_T" name="auto" description="lobster sms variables" >
+         <field ref="ZOO"      />
+         <field ref="PHY"      />
+         <field ref="NO3"      />
+       </file>
+
+
+      </group>
+
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+
+        <file id="5d_grid_T" name="auto" description="ocean T grid variables" >
+          <field ref="toce"         name="votemper"  />
+          <field ref="soce"         name="vosaline"  />
+          <field ref="sst"          name="sosstsst"  />
+          <field ref="sss"          name="sosaline"  />
+          <field ref="ssh"          name="sossheig"  />
+          <field ref="emp"          name="sowaflup"  />
+          <field ref="qsr"          name="soshfldo"  />
+          <field ref="emps"         name="sowaflcd"  />
+          <field ref="qns+qsr"      name="sohefldo"  />
+          <field ref="mldr10_1"     name="somxl010"  />
+          <field ref="mldkz5"       name="somixhgt"  />
+          <field ref="wspd"         name="sowindsp"  />
+          <field ref="qrp"          name="sohefldp"  />
+          <field ref="erp"          name="sowafldp"  />
+          <field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+          <field ref="mlddzt"       name="sothedep"  />
+          <field ref="20d"          name="so20chgt"  />
+          <field ref="28d"          name="so28chgt"  />
+          <field ref="hc300"        name="sohtc300"  />
+        </file>
+
+        <file id="5d_grid_U" name="auto" description="ocean U grid variables" >
+          <field ref="uoce"         name="vozocrtx"  />
+          <field ref="uoce_eiv"     name="vozoeivu"  />
+          <field ref="utau"         name="sozotaux"  />
+        </file>
+
+        <file id="5d_grid_V" name="auto" description="ocean V grid variables" >
+          <field ref="voce"         name="vomecrty"  />
+          <field ref="voce_eiv"     name="vomeeivv"  />
+          <field ref="vtau"         name="sometauy"  />
+        </file>
+
+        <file id="5d_grid_W" name="auto" description="ocean W grid variables" >
+          <field ref="woce"         name="vovecrtz" />
+          <field ref="woce_eiv"     name="voveeivw" />
+          <field ref="avt"          name="votkeavt" />
+          <field ref="avt_evd"      name="votkeevd" />
+          <field ref="avm"          name="votkeavm" />
+          <field ref="avm_evd"      name="votkeevm" />
+          <field ref="avs"          name="voddmavs" />
+          <field ref="aht2d"        name="soleahtw" />
+          <field ref="aht2d_eiv"    name="soleaeiw" />
+        </file>
+  
+       <file id="5d_ptrc_T" name="auto" description="lobster sms variables" >
+         <field ref="DET"      />
+         <field ref="ZOO"      />
+         <field ref="PHY"      />
+         <field ref="NO3"      />
+         <field ref="NH4"      />
+         <field ref="DOM"      />
+       </file>
+
+       <file id="5d_diad_T" name="auto" description="additional lobster diagnostics" >  
+         <field ref="FNO3PHY"   /> 
+         <field ref="FNH4PHY"   /> 
+         <field ref="FNH4NO3"   /> 
+         <field ref="TNO3PHY"   /> 
+         <field ref="TNH4PHY"   /> 
+         <field ref="TPHYDOM"   /> 
+         <field ref="TPHYNH4"   /> 
+         <field ref="TPHYZOO"   /> 
+         <field ref="TPHYDET"   /> 
+         <field ref="TDETZOO"   /> 
+         <field ref="TDETSED"   /> 
+         <field ref="TZOODET"   /> 
+         <field ref="TZOOBOD"   /> 
+         <field ref="TZOONH4"   /> 
+         <field ref="TZOODOM"   /> 
+         <field ref="TNH4NO3"   /> 
+         <field ref="TDOMNH4"   /> 
+         <field ref="TDETNH4"   /> 
+         <field ref="TPHYTOT"   /> 
+         <field ref="TZOOTOT"   /> 
+         <field ref="TDETDOM"   /> 
+         <field ref="SEDPOC"    /> 
+       </file>
+
+      </group>
+
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+
+ 
+  </file_definition>
+
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+
+  <axis_definition>  
+     <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+     <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+     <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+     <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+     <axis id="none" description="axe non defini" unit="none" size="1" />
+  </axis_definition> 
+
+  <grid_definition>
+    <grid id="grid_T" description="grid T" />
+    <grid id="grid_U" description="grid U" />
+    <grid id="grid_V" description="grid V" />
+    <grid id="grid_W" description="grid W" />
+    <grid id="scalarpoint" description="scalar" >
+      <zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+    </grid>
+  </grid_definition>    
+
+</context>
+
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist	(revision 1844)
@@ -0,0 +1,679 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      =  "GYREL"  !  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =    4320   !  last  time step (std 5475)
+   nn_date0    =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =      30   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =    4320   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =     360   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .false.   !  clobber (overwrite) an existing file
+   nn_chunksz  = 0         !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .true.    !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    0      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea    =   0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=    5.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 7200.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   60      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 7200.           !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 7200.           !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .true.    !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .false.   !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .false.   !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked                              , 
+                           !                     =1 global mean of e-p-r set to zero at each nn_fsbc time step   ,
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   100     !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.1e0   !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_qns0     =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u10_core'   ,       -1          , 'u10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'U1'
+   sn_wndj     = 'v10_core'   ,       -1          , 'v10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'V1'
+   sn_qsr      = 'qsw_core'   ,       -1          , 'swdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_qlw      = 'qlw_core'   ,       -1          , 'lwdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tair     = 't2_core'    ,       -1          , 't2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_humi     = 'q2_core'    ,       -1          , 'q2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_prec     = 'precip_core',       -1          , 'precip'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_snow     = 'snow_core'  ,       -1          , 'snow'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tdif     = 'taudif_core',       24          , 'taudif'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .true.    !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_data'   ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   0.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =    1.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 3000.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   = 3000.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+   ln_bfr2d    =   .false. !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    2      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    7.7e-4 !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =  1000.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =     0.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   -1      !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .false. !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .true.    !  z-coordinate - full steps                   
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .true.   !  laplacian operator         
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = 100000.        !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =     0.         !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =   3.75    !  coef. of the surface input of tke
+   rn_emin     =   1.e-5   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.4     !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.4     !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    100    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .false.    !  Add zonal means and meridional stream functions
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_lobster
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_lobster	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_lobster	(revision 1844)
@@ -0,0 +1,155 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! LOBSTER :    1  - biological parameters for phytoplankton    (namlobphy)
+!! namelists    2  - biological parameters for nutrients        (namlobnut)
+!!              3  - biological parameters for zooplankton      (namlobzoo)    
+!!              4  - biological parameters for detritus         (namlobdet)
+!!              5  - biological parameters for DOM              (namlobdom)
+!!              6  - parameters from aphotic layers to sediment (namlobsed)
+!!              7  - general coefficients                       (namlobrat)
+!!              8  - optical parameters                         (namlobopt)
+!!              9  - additional 2D/3D  diagnostics              (namlobdia)
+!!              10 - biological diagnostics trends              (namlobdbi) 
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobphy     !   biological parameters for phytoplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   apmin   =  0.        ! fixed phytoplancton concentration            [mmol/m3]
+   tmumax  =  1.21e-5   ! maximal phytoplankton growth rate            [s-1] 
+   rgamma  =  0.05      ! phytoplankton exudation fraction             [%]
+   fphylab =  0.75      ! NH4 fraction of phytoplankton exsudation     
+   tmmaxp  =  0.0       ! maximal phytoplancton mortality rate         [s-1] 
+   tmminp  =  5.8e-7    ! minimal phytoplancton mortality rate         [0.05/86400 s-1=20 days] 
+   rcchl   =  60.       ! Carbone/Chlorophyl ratio                     [mgC.mgChla-1]
+   aki     =  33.       ! light photosynthesis half saturation constant[W/m2]
+   toptp   =  0.        ! optimal photosynthesis temperature
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobnut     !   biological parameters for nutrients
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   anmin   =  0.        ! minimum nutrients concentration              [mmol/m3]
+   akno3   =  0.7       ! nitrate limitation half-saturation value     [mmol/m3]
+   aknh4   =  0.001     ! ammonium limitation half-saturation value    [mmol/m3]
+   taunn   =  5.80e-7   ! nitrification rate                           [s-1]  
+   psinut  =  3.        ! inhibition of nitrate uptake by ammonium
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobzoo     !   biological parameters for zooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   azmin   = 0.         ! minimum zooplancton concentration                      [mmol/m3]
+   eggzoo  = 0.0        ! minimum for zooplankton concentration, egg effect      [mmolN.m-3]
+   rgz     = 0.         ! ivlev coeff for zoo mortality
+   rppz    = 0.8        ! zooplankton nominal preference for phytoplancton food  [%]
+   taus    = 9.26E-6    ! specific zooplankton maximal grazing rate              [s-1] 
+!                       ! 0.75/86400 s-1=8.680555E-6    1/86400 = 1.15e-5
+   aks     = 1.         ! half-saturation constant for total zooplankton grazing [mmolN.m-3]
+   rpnaz   = 0.3        ! non-assimilated phytoplankton by zooplancton           [%]
+   rdnaz   = 0.3        ! non-assimilated detritus by zooplankton                [%] 
+   tauzn   = 8.1e-7     ! zooplancton specific excretion rate                    [0.1/86400 s-1=10 days] 
+   fzoolab = 0.5        ! NH4 fraction of zooplankton excretion
+   fdbod   = 0.5        ! zooplankton mortality fraction that goes to detritus
+   tmmaxz  = 0.         ! maximal zooplankton mortality rate
+   tmminz  = 2.31e-6    ! minimal zooplankton mortality rate                     [(mmolN/m3)-1 d-1]
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobdet     !   biological parameters for detritus
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   admin   = 0.         ! minimum detritus concentration                 [mmol/m3]
+   taudn   = 5.80e-7    ! detritus breakdown rate                        [0.1/86400 s-1=10 days]
+   fdetlab = 0.         ! NH4 fraction of detritus dissolution           
+   vsed    = 3.47e-5    ! detritus sedimentation speed                   [m/s]
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobdom     !   biological parameters for DOM
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   taudomn = 6.43e-8    ! DOM breakdown rate                             [s-1] 
+!                       ! slow remineralization rate of semi-labile dom to nh4 (1 month)
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobsed     !   parameters from aphotic layers to sediment
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   sedlam     = 3.86e-7 ! time coefficient of POC remineralization in sediments [s-1]
+   sedlostpoc = 0.      ! mass of POC lost in sediments
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobrat     !   general coefficients
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   redf    = 6.56       ! redfield ratio (C:N) for phyto
+   reddom  = 6.56       ! redfield ratio (C:N) for DOM
+   slopet  = 0.         ! van t Hoff "coefficient"
+   tmaxr   = 0.         ! maximal damping coeff under euphotic layer
+   tminr   = 5.80e-7    ! minimal damping coeff under euphotic layer
+   xhr     = -0.858     ! coeff for martin''s remineralisation profile
+   filmax  = 0.         ! ????
+   toptgz  = 0.         ! ???? 
+   tmaxgz  = 0.         ! ???? 
+   anumin  = 0.         ! ???? 
+   afdmin  = 0.         ! ???? 
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobopt     !   optical parameters
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xkg0   = 0.0232     ! green absorption coefficient of water
+   xkr0   = 0.225      ! red absorption coefficent of water
+   xkgp   = 0.074      ! green absorption coefficient of chl
+   xkrp   = 0.037      ! red absorption coefficient of chl
+   xlg    = 0.674      ! green chl exposant for absorption
+   xlr    = 0.629      ! red chl exposant for absorption
+   rpig   = 0.7        ! chla/chla+pheo ratio
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobdia     !   additional 2D/3D tracers diagnostics ("key_trc_diaadd")
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   nwritedia    =  360    !  time step frequency for tracers diagnostics
+!
+!              !    name   ! title of   ! units !
+!              !           ! the field  !       !  
+   lobdia2d(1)   = 'TNO3PHY' , 'TNO3PHY',  '-'
+   lobdia2d(2)   = 'TNH4PHY' , 'TNH4PHY',  '-'
+   lobdia2d(3)   = 'TPHYDOM' , 'TPHYDOM',  '-'
+   lobdia2d(4)   = 'TPHYNH4' , 'TPHYNH4',  '-'
+   lobdia2d(5)   = 'TPHYZOO' , 'TPHYZOO',  '-'
+   lobdia2d(6)   = 'TPHYDET' , 'TPHYDET',  '-'
+   lobdia2d(7)   = 'TDETZOO' , 'TDETZOO',  '-'
+   lobdia2d(8)   = 'TDETSED' , 'TDETSED',  '-'
+   lobdia2d(9)   = 'TZOODET' , 'TZOODET',  '-'
+   lobdia2d(10)  = 'TZOOBOD' , 'TZOOBOD',  '-'
+   lobdia2d(11)  = 'TZOONH4' , 'TZOONH4',  '-'
+   lobdia2d(12)  = 'TZOODOM' , 'TZOODOM',  '-'
+   lobdia2d(13)  = 'TNH4NO3' , 'TNH4NO3',  '-'
+   lobdia2d(14)  = 'TDOMNH4' , 'TDOMNH4',  '-'
+   lobdia2d(15)  = 'TDETNH4' , 'TDETNH4',  '-'
+   lobdia2d(16)  = 'TPHYTOT' , 'TPHYTOT',  '-'
+   lobdia2d(17)  = 'TZOOTOT' , 'TZOOTOT',  '-'
+   lobdia2d(18)  = 'TDETDOM' , 'TDETDOM',  '-'
+   lobdia2d(19)  = 'SEDPOC ' , 'SEDPOC ',  '-'
+   lobdia3d(1)   = 'FNO3PHY' , 'FNO3PHY',  '-'
+   lobdia3d(2)   = 'FNH4PHY' , 'FNH4PHY',  '-'
+   lobdia3d(3)   = 'FNH4NO3' , 'FNH4NO3',  '-'
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namlobdbi     !   biological diagnostics trends     
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+!                !  3D bio diagnostics   units : mmole/m3/s   ("key_trc_diabio")
+!                !  2D bio diagnostics   units : mmole/m2/s   ("key_trdmld_trc")
+
+   nwritebio    =   4320    !  time step frequency for biological outputs
+!
+!                !  name    !       title of the field      !     units      !
+   lobdiabio(1)  = 'NO3PHY' , 'Flux from NO3 to PHY          ',  'mmole/m3/s'
+   lobdiabio(2)  = 'NH4PHY' , 'Flux from NH4 to PHY          ',  'mmole/m3/s'
+   lobdiabio(3)  = 'PHYNH4' , 'Flux from PHY to NH4          ',  'mmole/m3/s'
+   lobdiabio(4)  = 'PHYDOM' , 'Flux from PHY to DOM          ',  'mmole/m3/s'
+   lobdiabio(5)  = 'PHYZOO' , 'Flux from PHY to ZOO          ',  'mmole/m3/s'
+   lobdiabio(6)  = 'PHYDET' , 'Flux from PHY to DET          ',  'mmole/m3/s'
+   lobdiabio(7)  = 'DETZOO' , 'Flux from DET to ZOO          ',  'mmole/m3/s'
+   lobdiabio(8)  = 'DETSED' , 'Flux from DET to SED          ',  'mmole/m3/s'
+   lobdiabio(9)  = 'ZOODET' , 'Flux from ZOO to DET          ',  'mmole/m3/s'
+   lobdiabio(10)  = 'ZOOBOD' , 'Zooplankton closure          ',  'mmole/m3/s'
+   lobdiabio(11)  = 'ZOONH4' , 'Flux from ZOO to NH4         ',  'mmole/m3/s'
+   lobdiabio(12)  = 'ZOODOM' , 'Flux from ZOO to DOM         ',  'mmole/m3/s'
+   lobdiabio(13)  = 'NH4NO3' , 'Flux from NH4 to NO3         ',  'mmole/m3/s'
+   lobdiabio(14)  = 'DOMNH4' , 'Flux from DOM to NH4         ',  'mmole/m3/s'
+   lobdiabio(15)  = 'DETNH4' , 'Flux from DET to NH4         ',  'mmole/m3/s'
+   lobdiabio(16)  = 'DETDOM' , 'Flux from DET to DOM         ',  'mmole/m3/s'
+   lobdiabio(17)  = 'SEDNO3' , 'NO3 remineralization from SED',  'mmole/m3/s'
+/
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_top
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_top	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/namelist_top	(revision 1844)
@@ -0,0 +1,107 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  1 - tracer definition                     (namtoptrc)
+!! namelists    2 - dynamical tracer trends               (namtoptrd)
+!!              6 - tracer advection                      (namtopadv)
+!!              7 - tracer bottom boundary                (namtopbbl)
+!!              8 - tracer lateral diffusion              (namtopldf)
+!!              3 - tracer vertical physics               (namtopzdf)
+!!              9 - tracer newtonian damping              (namtopdmp)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namtoptrc     !   tracers definition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ndttrc      =  1        !  time step frequency for passive tracers      
+   nwritetrc   = 360       !  time step frequency for tracer outputs
+   ln_rsttr    = .false.   !  start from a restart file (T) or not (F)
+   nrsttr      =   0       !  restart control = 0 initial time step is not compared to the restart file value
+                           !                  = 1 do not use the value in the restart file
+                           !                  = 2 calendar parameters read in the restart file
+   cn_trcrst_in  = "restart_trc"   !  suffix of pass. tracer restart name (input)
+   cn_trcrst_out = "restart_trc"   !  suffix of pass. tracer restart name (output)
+!
+!              ! name  !     title of the field       !   units       ! initial data ! save   !
+!              !       !                              !               ! from file    ! or not ! 
+!              !       !                              !               ! or not       !        !
+   tracer(1)   = 'DET' , 'Detritus                   ',  'mmole-N/m3' ,  .false.     ,  .true.
+   tracer(2)   = 'ZOO' , 'Zooplankton concentration  ',  'mmole-N/m3' ,  .false.     ,  .true.
+   tracer(3)   = 'PHY' , 'Phytoplankton concentration',  'mmole-N/m3' ,  .false.     ,  .true.
+   tracer(4)   = 'NO3' , 'Nitrate concentration      ',  'mmole-N/m3' ,  .false.     ,  .true.
+   tracer(5)   = 'NH4' , 'Ammonium concentration     ',  'mmole-N/m3' ,  .false.     ,  .true.
+   tracer(6)   = 'DOM' , 'Dissolved organic matter   ',  'mmole-N/m3' ,  .false.     ,  .true.
+/
+!-----------------------------------------------------------------------
+&namtopadv    !   advection scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_trcadv_tvd    =  .true.  !  TVD scheme   
+   ln_trcadv_muscl  =  .false.   !  MUSCL scheme
+   ln_trcadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_trcadv_smolar =  .false.  !  SMOLAR scheme
+   rsc              =  1.       !  tuning coefficient for Smolar. scheme 
+   ncortrc          =  1        !  number of corrective phases for Smolar. scheme 
+   crosster         =  .false.  !  computes Smolar crossterms (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopbbl    !   bottom boundary layer scheme for passive tracer 
+!-----------------------------------------------------------------------
+   atrcbbl          = 1000.     !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!-----------------------------------------------------------------------
+&namtopldf    !   lateral diffusion scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcldf_diff   =  .true.   !  performs lateral diffusion (T) or not (F)
+!                               !  Type of the operator : 
+   ln_trcldf_lap    =  .true.   !     laplacian operator       
+   ln_trcldf_bilap  =  .false.  !     bilaplacian operator     
+                                !  Direction of action  :
+   ln_trcldf_level  =  .false.  !     iso-level                
+   ln_trcldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_trcldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+!                               !  Coefficient
+   ahtrc0      =   300.         !     horizontal eddy diffusivity for tracers [m2/s]
+   ahtrb0      =     0.         !     background eddy diffusivity for ldf_iso [m2/s]
+   aeivtr0     =  1000.         !     eddy induced velocity coefficient [m2/s]    (require "key_trcldf_eiv")
+   trcrat      =  1.            !  ratio betweeen passive and active tracer diffusion coeff
+/
+!-----------------------------------------------------------------------
+&namtopzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   ln_trczdf_exp   =  .false.  !  split explicit (T) or implicit (F) time stepping
+   n_trczdf_exp    =   3       !  number of sub-timestep for ln_trczdfexp=T
+/
+!-----------------------------------------------------------------------
+&namtoprad        !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+   ln_trcrad   =  .true.  !  artificially correct negative concentrations (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopdmp        !   passive tracer newtonian damping                 ('key_trcdmp')
+!-----------------------------------------------------------------------
+   ndmptr      =   20      !  type of damping in passive tracers
+                           !     ='latitude', damping poleward of 'ndmp' degrees and function 
+                           !                  of the distance-to-coast. Red and Med Seas as ndmptr=-1
+                           !     =-1 damping only in Med and Red Seas
+   ndmpftr     =    0      !  create a damping.coeff NetCDF file (=1) or not (=0)
+   nmldmptr    =    1      !  type of damping: =0 damping throughout the water column
+                           !                   =1 no damping in the mixed layer defined by avt >5cm2/s )
+                           !                   =2 no damping in the mixed layer defined rho<rho(surf)+.01 )
+   sdmptr      =   50.     !  surface time scale for internal damping (days)
+   bdmptr      =  360.     !  bottom  time scale for internal damping (days)
+   hdmptr      =  800.     !  depth of transition between sdmptr and bdmptr (meters)
+/
+!-----------------------------------------------------------------------
+&namtoptrd       !   diagnostics on tracer trends
+!                          or mixed-layer trends          ('key_trdmld_trc')
+!----------------------------------------------------------------------
+   ntrd_trc   =  360      !  time step frequency and tracers trends
+   nctls_trc  =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   ucf_trc    =  86400    !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   ln_trdmld_trc_restart = .false.  !  restart for ML diagnostics
+   ln_trdmld_trc_instant = .false.  !  flag to diagnose trends of instantantaneous or mean ML T/S
+   luttrd(1)  =   .true.
+   luttrd(2)  =   .true.
+   luttrd(3)  =   .true.
+   luttrd(4)  =   .true.
+   luttrd(5)  =   .true.
+   luttrd(6)  =   .true.
+/
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,20 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
+  
+  
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make	(revision 1844)
@@ -0,0 +1,17673 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_bdy \
+     key_c14b \
+     key_c1d \
+     key_cfc \
+     key_coupled \
+     key_cpl_albedo \
+     key_cpl_carbon_cycle \
+     key_cpl_discharge \
+     key_cpl_ocevel \
+     key_cpl_rootexchg \
+     key_diaadd \
+     key_diaar5 \
+     key_diaeiv \
+     key_diagap \
+     key_diahdy \
+     key_diahth \
+     key_diainstant \
+     key_diaspr \
+     key_dimgout \
+     key_dtasal \
+     key_dtatem \
+     key_dtatrc \
+     key_dynldf_c1d \
+     key_dynldf_c2d \
+     key_dynldf_c3d \
+     key_dynspg_exp \
+     key_dynspg_flt \
+     key_dynspg_ts \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_floats \
+     key_flx_bulk_monthly \
+     key_flx_core \
+     key_flx_forced_daily \
+     key_gyre \
+     key_iomput \
+     key_kppcustom \
+     key_kpplktb \
+     key_kriest \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_lobster \
+     key_mpp_dyndist \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_my_trc \
+     key_noslip_accurate \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_off_degrad \
+     key_off_tra \
+     key_orca_lev10 \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_pomme_r025 \
+     key_sed \
+     key_sed_off \
+     key_top \
+     key_trabbc \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_tradmp \
+     key_traldf_ano \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trc_dia3d \
+     key_trc_diaadd \
+     key_trc_diabio \
+     key_trc_diatrd \
+     key_trc_zdfddm \
+     key_trcbbc \
+     key_trcbbl_adv \
+     key_trcbbl_dif \
+     key_trcdmp \
+     key_trcldf_eiv \
+     key_trcldf_iso \
+     key_trddyn \
+     key_trdmld \
+     key_trdmld_trc \
+     key_trdtra \
+     key_trdvor \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zdfcst \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdfric \
+     key_zdftke \
+     key_zdftke_old \
+     key_zdftmx 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_opa_interp.o)\
+		$(MODEL_LIB)(agrif_opa_sponge.o)\
+		$(MODEL_LIB)(agrif_opa_update.o)\
+		$(MODEL_LIB)(agrif_top_interp.o)\
+		$(MODEL_LIB)(agrif_top_sponge.o)\
+		$(MODEL_LIB)(agrif_top_update.o)\
+		$(MODEL_LIB)(albedo.o)\
+		$(MODEL_LIB)(bdy_oce.o)\
+		$(MODEL_LIB)(bdy_par.o)\
+		$(MODEL_LIB)(bdydta.o)\
+		$(MODEL_LIB)(bdydyn.o)\
+		$(MODEL_LIB)(bdyini.o)\
+		$(MODEL_LIB)(bdytides.o)\
+		$(MODEL_LIB)(bdytra.o)\
+		$(MODEL_LIB)(bdyvol.o)\
+		$(MODEL_LIB)(c1d.o)\
+		$(MODEL_LIB)(cla.o)\
+		$(MODEL_LIB)(cla_div.o)\
+		$(MODEL_LIB)(cla_dynspg.o)\
+		$(MODEL_LIB)(closea.o)\
+		$(MODEL_LIB)(cpl_oasis3.o)\
+		$(MODEL_LIB)(cpl_oasis4.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(diaar5.o)\
+		$(MODEL_LIB)(diadimg.o)\
+		$(MODEL_LIB)(diafwb.o)\
+		$(MODEL_LIB)(diagap.o)\
+		$(MODEL_LIB)(diahdy.o)\
+		$(MODEL_LIB)(diahth.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(diaptr.o)\
+		$(MODEL_LIB)(diawri.o)\
+		$(MODEL_LIB)(diawri_c1d.o)\
+		$(MODEL_LIB)(divcur.o)\
+		$(MODEL_LIB)(dom_ice_2.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(domhgr.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(domvvl.o)\
+		$(MODEL_LIB)(domwri.o)\
+		$(MODEL_LIB)(domzgr.o)\
+		$(MODEL_LIB)(dtasal.o)\
+		$(MODEL_LIB)(dtatem.o)\
+		$(MODEL_LIB)(dynadv.o)\
+		$(MODEL_LIB)(dynadv_cen2.o)\
+		$(MODEL_LIB)(dynadv_ubs.o)\
+		$(MODEL_LIB)(dynbfr.o)\
+		$(MODEL_LIB)(dyncor_c1d.o)\
+		$(MODEL_LIB)(dynhpg.o)\
+		$(MODEL_LIB)(dynkeg.o)\
+		$(MODEL_LIB)(dynldf.o)\
+		$(MODEL_LIB)(dynldf_bilap.o)\
+		$(MODEL_LIB)(dynldf_bilapg.o)\
+		$(MODEL_LIB)(dynldf_iso.o)\
+		$(MODEL_LIB)(dynldf_lap.o)\
+		$(MODEL_LIB)(dynnxt.o)\
+		$(MODEL_LIB)(dynnxt_c1d.o)\
+		$(MODEL_LIB)(dynspg.o)\
+		$(MODEL_LIB)(dynspg_exp.o)\
+		$(MODEL_LIB)(dynspg_flt.o)\
+		$(MODEL_LIB)(dynspg_oce.o)\
+		$(MODEL_LIB)(dynspg_ts.o)\
+		$(MODEL_LIB)(dynvor.o)\
+		$(MODEL_LIB)(dynzad.o)\
+		$(MODEL_LIB)(dynzdf.o)\
+		$(MODEL_LIB)(dynzdf_exp.o)\
+		$(MODEL_LIB)(dynzdf_imp.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(fldread.o)\
+		$(MODEL_LIB)(flo4rk.o)\
+		$(MODEL_LIB)(flo_oce.o)\
+		$(MODEL_LIB)(floats.o)\
+		$(MODEL_LIB)(floblk.o)\
+		$(MODEL_LIB)(flodom.o)\
+		$(MODEL_LIB)(flowri.o)\
+		$(MODEL_LIB)(geo2ocean.o)\
+		$(MODEL_LIB)(ice_2.o)\
+		$(MODEL_LIB)(iceini_2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(lbcnfd.o)\
+		$(MODEL_LIB)(ldfdyn.o)\
+		$(MODEL_LIB)(ldfdyn_oce.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(limadv_2.o)\
+		$(MODEL_LIB)(limdia_2.o)\
+		$(MODEL_LIB)(limdmp_2.o)\
+		$(MODEL_LIB)(limdyn_2.o)\
+		$(MODEL_LIB)(limhdf_2.o)\
+		$(MODEL_LIB)(limistate_2.o)\
+		$(MODEL_LIB)(limmsh_2.o)\
+		$(MODEL_LIB)(limrhg_2.o)\
+		$(MODEL_LIB)(limrst_2.o)\
+		$(MODEL_LIB)(limsbc_2.o)\
+		$(MODEL_LIB)(limtab_2.o)\
+		$(MODEL_LIB)(limthd_2.o)\
+		$(MODEL_LIB)(limthd_lac_2.o)\
+		$(MODEL_LIB)(limthd_zdf_2.o)\
+		$(MODEL_LIB)(limtrp_2.o)\
+		$(MODEL_LIB)(limwri_2.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oasis4_date.o)\
+		$(MODEL_LIB)(obc_oce.o)\
+		$(MODEL_LIB)(obc_par.o)\
+		$(MODEL_LIB)(obcdta.o)\
+		$(MODEL_LIB)(obcdyn.o)\
+		$(MODEL_LIB)(obcdyn_bt.o)\
+		$(MODEL_LIB)(obcfla.o)\
+		$(MODEL_LIB)(obcini.o)\
+		$(MODEL_LIB)(obcrad.o)\
+		$(MODEL_LIB)(obcrst.o)\
+		$(MODEL_LIB)(obctra.o)\
+		$(MODEL_LIB)(obcvol.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(oce_trc.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(p4zbio.o)\
+		$(MODEL_LIB)(p4zche.o)\
+		$(MODEL_LIB)(p4zflx.o)\
+		$(MODEL_LIB)(p4zint.o)\
+		$(MODEL_LIB)(p4zlim.o)\
+		$(MODEL_LIB)(p4zlys.o)\
+		$(MODEL_LIB)(p4zmeso.o)\
+		$(MODEL_LIB)(p4zmicro.o)\
+		$(MODEL_LIB)(p4zmort.o)\
+		$(MODEL_LIB)(p4zopt.o)\
+		$(MODEL_LIB)(p4zprod.o)\
+		$(MODEL_LIB)(p4zrem.o)\
+		$(MODEL_LIB)(p4zsed.o)\
+		$(MODEL_LIB)(p4zsink.o)\
+		$(MODEL_LIB)(par_c14b.o)\
+		$(MODEL_LIB)(par_cfc.o)\
+		$(MODEL_LIB)(par_ice_2.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_lobster.o)\
+		$(MODEL_LIB)(par_my_trc.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(par_pisces.o)\
+		$(MODEL_LIB)(par_sed.o)\
+		$(MODEL_LIB)(par_trc.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(prtctl_trc.o)\
+		$(MODEL_LIB)(restart.o)\
+		$(MODEL_LIB)(sbc_ice.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcana.o)\
+		$(MODEL_LIB)(sbcblk_clio.o)\
+		$(MODEL_LIB)(sbcblk_core.o)\
+		$(MODEL_LIB)(sbccpl.o)\
+		$(MODEL_LIB)(sbcflx.o)\
+		$(MODEL_LIB)(sbcfwb.o)\
+		$(MODEL_LIB)(sbcice_if.o)\
+		$(MODEL_LIB)(sbcice_lim.o)\
+		$(MODEL_LIB)(sbcice_lim_2.o)\
+		$(MODEL_LIB)(sbcmod.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sbcssm.o)\
+		$(MODEL_LIB)(sbcssr.o)\
+		$(MODEL_LIB)(sed.o)\
+		$(MODEL_LIB)(sedadv.o)\
+		$(MODEL_LIB)(sedarr.o)\
+		$(MODEL_LIB)(sedbtb.o)\
+		$(MODEL_LIB)(sedchem.o)\
+		$(MODEL_LIB)(sedco3.o)\
+		$(MODEL_LIB)(seddsr.o)\
+		$(MODEL_LIB)(seddta.o)\
+		$(MODEL_LIB)(sedini.o)\
+		$(MODEL_LIB)(sedmat.o)\
+		$(MODEL_LIB)(sedmbc.o)\
+		$(MODEL_LIB)(sedmodel.o)\
+		$(MODEL_LIB)(sedrst.o)\
+		$(MODEL_LIB)(sedsfc.o)\
+		$(MODEL_LIB)(sedstp.o)\
+		$(MODEL_LIB)(sedwri.o)\
+		$(MODEL_LIB)(sms_lobster.o)\
+		$(MODEL_LIB)(sms_pisces.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(solmat.o)\
+		$(MODEL_LIB)(solpcg.o)\
+		$(MODEL_LIB)(solsor.o)\
+		$(MODEL_LIB)(solver.o)\
+		$(MODEL_LIB)(sshwzv.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(step_c1d.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(thd_ice_2.o)\
+		$(MODEL_LIB)(traadv.o)\
+		$(MODEL_LIB)(traadv_cen2.o)\
+		$(MODEL_LIB)(traadv_eiv.o)\
+		$(MODEL_LIB)(traadv_muscl.o)\
+		$(MODEL_LIB)(traadv_muscl2.o)\
+		$(MODEL_LIB)(traadv_qck.o)\
+		$(MODEL_LIB)(traadv_tvd.o)\
+		$(MODEL_LIB)(traadv_ubs.o)\
+		$(MODEL_LIB)(trabbc.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(tradmp.o)\
+		$(MODEL_LIB)(traldf.o)\
+		$(MODEL_LIB)(traldf_bilap.o)\
+		$(MODEL_LIB)(traldf_bilapg.o)\
+		$(MODEL_LIB)(traldf_iso.o)\
+		$(MODEL_LIB)(traldf_lap.o)\
+		$(MODEL_LIB)(tranpc.o)\
+		$(MODEL_LIB)(tranxt.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trasbc.o)\
+		$(MODEL_LIB)(trazdf.o)\
+		$(MODEL_LIB)(trazdf_exp.o)\
+		$(MODEL_LIB)(trazdf_imp.o)\
+		$(MODEL_LIB)(trc.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trcadv_cen2.o)\
+		$(MODEL_LIB)(trcadv_muscl.o)\
+		$(MODEL_LIB)(trcadv_muscl2.o)\
+		$(MODEL_LIB)(trcadv_smolar.o)\
+		$(MODEL_LIB)(trcadv_tvd.o)\
+		$(MODEL_LIB)(trcbbc.o)\
+		$(MODEL_LIB)(trcbbl.o)\
+		$(MODEL_LIB)(trcbio.o)\
+		$(MODEL_LIB)(trcctl.o)\
+		$(MODEL_LIB)(trcctl_c14b.o)\
+		$(MODEL_LIB)(trcctl_cfc.o)\
+		$(MODEL_LIB)(trcctl_lobster.o)\
+		$(MODEL_LIB)(trcctl_my_trc.o)\
+		$(MODEL_LIB)(trcctl_pisces.o)\
+		$(MODEL_LIB)(trcdia.o)\
+		$(MODEL_LIB)(trcdmp.o)\
+		$(MODEL_LIB)(trcdta.o)\
+		$(MODEL_LIB)(trcexp.o)\
+		$(MODEL_LIB)(trcini.o)\
+		$(MODEL_LIB)(trcini_c14b.o)\
+		$(MODEL_LIB)(trcini_cfc.o)\
+		$(MODEL_LIB)(trcini_lobster.o)\
+		$(MODEL_LIB)(trcini_my_trc.o)\
+		$(MODEL_LIB)(trcini_pisces.o)\
+		$(MODEL_LIB)(trcldf_bilap.o)\
+		$(MODEL_LIB)(trcldf_bilapg.o)\
+		$(MODEL_LIB)(trcldf_iso.o)\
+		$(MODEL_LIB)(trcldf_iso_zps.o)\
+		$(MODEL_LIB)(trcldf_lap.o)\
+		$(MODEL_LIB)(trclec.o)\
+		$(MODEL_LIB)(trclsm_c14b.o)\
+		$(MODEL_LIB)(trclsm_cfc.o)\
+		$(MODEL_LIB)(trclsm_lobster.o)\
+		$(MODEL_LIB)(trclsm_my_trc.o)\
+		$(MODEL_LIB)(trclsm_pisces.o)\
+		$(MODEL_LIB)(trcnxt.o)\
+		$(MODEL_LIB)(trcopt.o)\
+		$(MODEL_LIB)(trcrad.o)\
+		$(MODEL_LIB)(trcrst.o)\
+		$(MODEL_LIB)(trcsbc.o)\
+		$(MODEL_LIB)(trcsed.o)\
+		$(MODEL_LIB)(trcsms.o)\
+		$(MODEL_LIB)(trcsms_c14b.o)\
+		$(MODEL_LIB)(trcsms_cfc.o)\
+		$(MODEL_LIB)(trcsms_lobster.o)\
+		$(MODEL_LIB)(trcsms_my_trc.o)\
+		$(MODEL_LIB)(trcsms_pisces.o)\
+		$(MODEL_LIB)(trcstp.o)\
+		$(MODEL_LIB)(trctrp.o)\
+		$(MODEL_LIB)(trctrp_ctl.o)\
+		$(MODEL_LIB)(trctrp_lec.o)\
+		$(MODEL_LIB)(trcwri.o)\
+		$(MODEL_LIB)(trczdf_exp.o)\
+		$(MODEL_LIB)(trczdf_imp.o)\
+		$(MODEL_LIB)(trczdf_iso.o)\
+		$(MODEL_LIB)(trczdf_iso_vopt.o)\
+		$(MODEL_LIB)(trdicp.o)\
+		$(MODEL_LIB)(trdicp_oce.o)\
+		$(MODEL_LIB)(trdmld.o)\
+		$(MODEL_LIB)(trdmld_oce.o)\
+		$(MODEL_LIB)(trdmld_rst.o)\
+		$(MODEL_LIB)(trdmld_trc.o)\
+		$(MODEL_LIB)(trdmld_trc_oce.o)\
+		$(MODEL_LIB)(trdmld_trc_rst.o)\
+		$(MODEL_LIB)(trdmod.o)\
+		$(MODEL_LIB)(trdmod_oce.o)\
+		$(MODEL_LIB)(trdvor.o)\
+		$(MODEL_LIB)(trdvor_oce.o)\
+		$(MODEL_LIB)(trp_trc.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfbfr.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfevd.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfkpp.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zdfric.o)\
+		$(MODEL_LIB)(zdftke.o)\
+		$(MODEL_LIB)(zdftke_old.o)\
+		$(MODEL_LIB)(zdftmx.o)\
+		$(MODEL_LIB)(zpshde.o)\
+		$(MODEL_LIB)(zpshde_trc.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_opa_interp.o) :	\
+	agrif_opa_interp.F90
+$(MODEL_LIB)(agrif_opa_sponge.o) :	\
+	agrif_opa_sponge.F90
+$(MODEL_LIB)(agrif_opa_update.o) :	\
+	agrif_opa_update.F90
+$(MODEL_LIB)(agrif_top_interp.o) :	\
+	agrif_top_interp.F90
+$(MODEL_LIB)(agrif_top_sponge.o) :	\
+	agrif_top_sponge.F90
+$(MODEL_LIB)(agrif_top_update.o) :	\
+	agrif_top_update.F90
+$(MODEL_LIB)(albedo.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	in_out_manager.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	albedo.F90
+$(MODEL_LIB)(bdy_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	bdy_oce.F90
+$(MODEL_LIB)(bdy_par.o) :	\
+	KEY_CPP \
+	bdy_par.F90
+$(MODEL_LIB)(bdydta.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	bdydta.F90
+$(MODEL_LIB)(bdydyn.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdydyn.F90
+$(MODEL_LIB)(bdyini.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdyini.F90
+$(MODEL_LIB)(bdytides.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdytides.F90
+$(MODEL_LIB)(bdytra.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdytra.F90
+$(MODEL_LIB)(bdyvol.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	bdyvol.F90
+$(MODEL_LIB)(c1d.o) :	\
+	KEY_CPP \
+	c1d.F90
+$(MODEL_LIB)(cla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla.F90
+$(MODEL_LIB)(cla_div.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	cla_div.F90
+$(MODEL_LIB)(cla_dynspg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla_dynspg.F90
+$(MODEL_LIB)(closea.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	closea.F90
+$(MODEL_LIB)(cpl_oasis3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	cpl_oasis3.F90
+$(MODEL_LIB)(cpl_oasis4.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oasis4_date.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	cpl_oasis4.F90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(diaar5.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diaar5.F90
+$(MODEL_LIB)(diadimg.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diadimg.F90
+$(MODEL_LIB)(diafwb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	diafwb.F90
+$(MODEL_LIB)(diagap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diagap.F90
+$(MODEL_LIB)(diahdy.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahdy.F90
+$(MODEL_LIB)(diahth.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahth.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(diaptr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diaptr.F90
+$(MODEL_LIB)(diawri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	lib_mpp.F90 \
+	diawri_dimg.h90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri.F90
+$(MODEL_LIB)(diawri_c1d.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	trazdf_exp.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri_c1d.F90
+$(MODEL_LIB)(divcur.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	divcur.F90
+$(MODEL_LIB)(dom_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	dom_ice_2.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(domhgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	domhgr.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(domvvl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domvvl.F90
+$(MODEL_LIB)(domwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domwri.F90
+$(MODEL_LIB)(domzgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domzgr.F90
+$(MODEL_LIB)(dtasal.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtasal.F90
+$(MODEL_LIB)(dtatem.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtatem.F90
+$(MODEL_LIB)(dynadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv.F90
+$(MODEL_LIB)(dynadv_cen2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_cen2.F90
+$(MODEL_LIB)(dynadv_ubs.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_ubs.F90
+$(MODEL_LIB)(dynbfr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynbfr.F90
+$(MODEL_LIB)(dyncor_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dyncor_c1d.F90
+$(MODEL_LIB)(dynhpg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynhpg.F90
+$(MODEL_LIB)(dynkeg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynkeg.F90
+$(MODEL_LIB)(dynldf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf.F90
+$(MODEL_LIB)(dynldf_bilap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilap.F90
+$(MODEL_LIB)(dynldf_bilapg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilapg.F90
+$(MODEL_LIB)(dynldf_iso.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_iso.F90
+$(MODEL_LIB)(dynldf_lap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_lap.F90
+$(MODEL_LIB)(dynnxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynnxt.F90
+$(MODEL_LIB)(dynnxt_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	KEY_CPP \
+	dynnxt_c1d.F90
+$(MODEL_LIB)(dynspg.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	in_out_manager.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg.F90
+$(MODEL_LIB)(dynspg_exp.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_exp.F90
+$(MODEL_LIB)(dynspg_flt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdydyn.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynspg_flt.F90
+$(MODEL_LIB)(dynspg_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dynspg_oce.F90
+$(MODEL_LIB)(dynspg_ts.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcfla.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_ts.F90
+$(MODEL_LIB)(dynvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynvor.F90
+$(MODEL_LIB)(dynzad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzad.F90
+$(MODEL_LIB)(dynzdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynzdf.F90
+$(MODEL_LIB)(dynzdf_exp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_exp.F90
+$(MODEL_LIB)(dynzdf_imp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_imp.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(fldread.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	fldread.F90
+$(MODEL_LIB)(flo4rk.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	KEY_CPP \
+	flo4rk.F90
+$(MODEL_LIB)(flo_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	flo_oce.F90
+$(MODEL_LIB)(floats.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	lib_mpp.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	floats.F90
+$(MODEL_LIB)(floblk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	floblk.F90
+$(MODEL_LIB)(flodom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flodom.F90
+$(MODEL_LIB)(flowri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flowri.F90
+$(MODEL_LIB)(geo2ocean.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	geo2ocean.F90
+$(MODEL_LIB)(ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	ice_2.F90
+$(MODEL_LIB)(iceini_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrst_2.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iceini_2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	c1d.F90 \
+	cla_dynspg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	daymod.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	restart.F90 \
+	zdf_oce.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(lbcnfd.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	lbcnfd.F90
+$(MODEL_LIB)(ldfdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	ldftra_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_antarctic.h90 \
+	ldfdyn_arctic.h90 \
+	ldfdyn_c1d.h90 \
+	ldfdyn_c2d.h90 \
+	ldfdyn_c3d.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldfdyn.F90
+$(MODEL_LIB)(ldfdyn_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldfdyn_oce.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(limadv_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limadv_2.F90
+$(MODEL_LIB)(limdia_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdia_2.F90
+$(MODEL_LIB)(limdmp_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	tradmp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdmp_2.F90
+$(MODEL_LIB)(limdyn_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limistate_2.F90 \
+	limrhg_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdyn_2.F90
+$(MODEL_LIB)(limhdf_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limhdf_2.F90
+$(MODEL_LIB)(limistate_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limistate_2.F90
+$(MODEL_LIB)(limmsh_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limmsh_2.F90
+$(MODEL_LIB)(limrhg_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limrhg_2.F90
+$(MODEL_LIB)(limrst_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	limrst_2.F90
+$(MODEL_LIB)(limsbc_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limsbc_2.F90
+$(MODEL_LIB)(limtab_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	KEY_CPP \
+	limtab_2.F90
+$(MODEL_LIB)(limthd_2.o) :	\
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limistate_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limthd_2.F90
+$(MODEL_LIB)(limthd_lac_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	ice_2.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_lac_2.F90
+$(MODEL_LIB)(limthd_zdf_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_zdf_2.F90
+$(MODEL_LIB)(limtrp_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limtrp_2.F90
+$(MODEL_LIB)(limwri_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	diadimg.F90 \
+	limwri_dimg_2.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	limwri_2.F90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trcini.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trcini.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oasis4_date.o) :	\
+	KEY_CPP \
+	oasis4_date.F90
+$(MODEL_LIB)(obc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	obc_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	obc_oce.F90
+$(MODEL_LIB)(obc_par.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	obc_par_EEL_R5.h90 \
+	obc_par_POMME_R025.h90 \
+	KEY_CPP \
+	obc_par.F90
+$(MODEL_LIB)(obcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	obcdta.F90
+$(MODEL_LIB)(obcdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn.F90
+$(MODEL_LIB)(obcdyn_bt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn_bt.F90
+$(MODEL_LIB)(obcfla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	obc_oce.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcfla.F90
+$(MODEL_LIB)(obcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcini.F90
+$(MODEL_LIB)(obcrad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcrad.F90
+$(MODEL_LIB)(obcrst.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcrst.F90
+$(MODEL_LIB)(obctra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obctra.F90
+$(MODEL_LIB)(obcvol.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcvol.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(oce_trc.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	KEY_CPP \
+	oce_trc.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_opa_sponge.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	cla.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynnxt_c1d.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trcstp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trcini.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trcini.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(p4zbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zbio.F90
+$(MODEL_LIB)(p4zche.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zche.F90
+$(MODEL_LIB)(p4zflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zflx.F90
+$(MODEL_LIB)(p4zint.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zint.F90
+$(MODEL_LIB)(p4zlim.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zlim.F90
+$(MODEL_LIB)(p4zlys.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zlys.F90
+$(MODEL_LIB)(p4zmeso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmeso.F90
+$(MODEL_LIB)(p4zmicro.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmicro.F90
+$(MODEL_LIB)(p4zmort.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmort.F90
+$(MODEL_LIB)(p4zopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zopt.F90
+$(MODEL_LIB)(p4zprod.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zprod.F90
+$(MODEL_LIB)(p4zrem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zrem.F90
+$(MODEL_LIB)(p4zsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	p4zsed.F90
+$(MODEL_LIB)(p4zsink.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zsink.F90
+$(MODEL_LIB)(par_c14b.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_c14b.F90
+$(MODEL_LIB)(par_cfc.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_cfc.F90
+$(MODEL_LIB)(par_ice_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	par_ice_2.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_lobster.o) :	\
+	KEY_CPP \
+	par_lobster.F90
+$(MODEL_LIB)(par_my_trc.o) :	\
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_my_trc.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	par_POMME_R025.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(par_pisces.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	KEY_CPP \
+	par_pisces.F90
+$(MODEL_LIB)(par_sed.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	par_kind.F90 \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_sed.F90
+$(MODEL_LIB)(par_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_trc.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(prtctl_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	prtctl_trc.F90
+$(MODEL_LIB)(restart.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	restart.F90
+$(MODEL_LIB)(sbc_ice.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_ice_2.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_ice.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcana.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcana.F90
+$(MODEL_LIB)(sbcblk_clio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_clio.F90
+$(MODEL_LIB)(sbcblk_core.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_core.F90
+$(MODEL_LIB)(sbccpl.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	phycst.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbccpl.F90
+$(MODEL_LIB)(sbcflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcflx.F90
+$(MODEL_LIB)(sbcfwb.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcfwb.F90
+$(MODEL_LIB)(sbcice_if.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcice_if.F90
+$(MODEL_LIB)(sbcice_lim.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim.F90
+$(MODEL_LIB)(sbcice_lim_2.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrhg_2.F90 \
+	limrst_2.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	tradmp.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim_2.F90
+$(MODEL_LIB)(sbcmod.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	albedo.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcmod.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sbcssm.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssm.F90
+$(MODEL_LIB)(sbcssr.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssr.F90
+$(MODEL_LIB)(sed.o) :	\
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	sed.F90
+$(MODEL_LIB)(sedadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedadv.F90
+$(MODEL_LIB)(sedarr.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_sed.o) \
+	par_sed.F90 \
+	KEY_CPP \
+	sedarr.F90
+$(MODEL_LIB)(sedbtb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	sedbtb.F90
+$(MODEL_LIB)(sedchem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	sedchem.F90
+$(MODEL_LIB)(sedco3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedco3.F90
+$(MODEL_LIB)(seddsr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	seddsr.F90
+$(MODEL_LIB)(seddta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	seddta.F90
+$(MODEL_LIB)(sedini.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddta.F90 \
+	sedrst.F90 \
+	KEY_CPP \
+	sedini.F90
+$(MODEL_LIB)(sedmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedmat.F90
+$(MODEL_LIB)(sedmbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	sed.F90 \
+	seddsr.F90 \
+	KEY_CPP \
+	sedmbc.F90
+$(MODEL_LIB)(sedmodel.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedadv.F90 \
+	sedarr.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	KEY_CPP \
+	sedmodel.F90
+$(MODEL_LIB)(sedrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedrst.F90
+$(MODEL_LIB)(sedsfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	sed.F90 \
+	sedarr.F90 \
+	seddta.F90 \
+	KEY_CPP \
+	sedsfc.F90
+$(MODEL_LIB)(sedstp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	sed.F90 \
+	sedadv.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	KEY_CPP \
+	sedstp.F90
+$(MODEL_LIB)(sedwri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	dianam.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedwri.F90
+$(MODEL_LIB)(sms_lobster.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_lobster.F90
+$(MODEL_LIB)(sms_pisces.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_pisces.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sol_oce.F90
+$(MODEL_LIB)(solmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	KEY_CPP \
+	solmat.F90
+$(MODEL_LIB)(solpcg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	solpcg.F90
+$(MODEL_LIB)(solsor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	solsor.F90
+$(MODEL_LIB)(solver.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	zdf_oce.F90 \
+	KEY_CPP \
+	solver.F90
+$(MODEL_LIB)(sshwzv.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sshwzv.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	albedo.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynhpg.F90 \
+	dynkeg.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynzad.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obctra.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	traqsr.F90 \
+	trazdf.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	cla.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynspg.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbccpl.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trcstp.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(step_c1d.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obctra.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traqsr.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdmld_oce.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	daymod.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynnxt_c1d.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	stpctl.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trcstp.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	step_c1d.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(thd_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	thd_ice_2.F90
+$(MODEL_LIB)(traadv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv.F90
+$(MODEL_LIB)(traadv_cen2.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_cen2.F90
+$(MODEL_LIB)(traadv_eiv.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	diaar5.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_eiv.F90
+$(MODEL_LIB)(traadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl.F90
+$(MODEL_LIB)(traadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl2.F90
+$(MODEL_LIB)(traadv_qck.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_qck.F90
+$(MODEL_LIB)(traadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_tvd.F90
+$(MODEL_LIB)(traadv_ubs.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_ubs.F90
+$(MODEL_LIB)(trabbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trabbc.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	eosbn2.F90 \
+	iom.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	trabbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(tradmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	tradmp.F90
+$(MODEL_LIB)(traldf.o) :	\
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	trazdf.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf.F90
+$(MODEL_LIB)(traldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_bilap.F90
+$(MODEL_LIB)(traldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	KEY_CPP \
+	traldf_bilapg.F90
+$(MODEL_LIB)(traldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_iso.F90
+$(MODEL_LIB)(traldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_lap.F90
+$(MODEL_LIB)(tranpc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	tranpc.F90
+$(MODEL_LIB)(tranxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obctra.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	tranxt.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traqsr.F90
+$(MODEL_LIB)(trasbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	traqsr.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trasbc.F90
+$(MODEL_LIB)(trazdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf.F90
+$(MODEL_LIB)(trazdf_exp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_exp.F90
+$(MODEL_LIB)(trazdf_imp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_imp.F90
+$(MODEL_LIB)(trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trc.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trcadv_cen2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_cen2.F90
+$(MODEL_LIB)(trcadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl.F90
+$(MODEL_LIB)(trcadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl2.F90
+$(MODEL_LIB)(trcadv_smolar.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_smolar.F90
+$(MODEL_LIB)(trcadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_tvd.F90
+$(MODEL_LIB)(trcbbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbc.F90
+$(MODEL_LIB)(trcbbl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	eosbn2.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	trcbbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbl.F90
+$(MODEL_LIB)(trcbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbio.F90
+$(MODEL_LIB)(trcctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trctrp_ctl.F90 \
+	KEY_CPP \
+	trcctl.F90
+$(MODEL_LIB)(trcctl_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_c14b.F90
+$(MODEL_LIB)(trcctl_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_cfc.F90
+$(MODEL_LIB)(trcctl_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_lobster.F90
+$(MODEL_LIB)(trcctl_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_my_trc.F90
+$(MODEL_LIB)(trcctl_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_pisces.F90
+$(MODEL_LIB)(trcdia.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdia.F90
+$(MODEL_LIB)(trcdmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdmp.F90
+$(MODEL_LIB)(trcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcdta.F90
+$(MODEL_LIB)(trcexp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcexp.F90
+$(MODEL_LIB)(trcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_ctl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	daymod.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcini.F90
+$(MODEL_LIB)(trcini_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trcini_c14b.F90
+$(MODEL_LIB)(trcini_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trcini_cfc.F90
+$(MODEL_LIB)(trcini_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_lobster.F90
+$(MODEL_LIB)(trcini_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcini_my_trc.F90
+$(MODEL_LIB)(trcini_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_pisces.F90
+$(MODEL_LIB)(trcldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilap.F90
+$(MODEL_LIB)(trcldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilapg.F90
+$(MODEL_LIB)(trcldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso.F90
+$(MODEL_LIB)(trcldf_iso_zps.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso_zps.F90
+$(MODEL_LIB)(trcldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_lap.F90
+$(MODEL_LIB)(trclec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trclec.F90
+$(MODEL_LIB)(trclsm_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trclsm_c14b.F90
+$(MODEL_LIB)(trclsm_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trclsm_cfc.F90
+$(MODEL_LIB)(trclsm_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_lobster.F90
+$(MODEL_LIB)(trclsm_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_my_trc.F90
+$(MODEL_LIB)(trclsm_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_pisces.F90
+$(MODEL_LIB)(trcnxt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trcnxt.F90
+$(MODEL_LIB)(trcopt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcopt.F90
+$(MODEL_LIB)(trcrad.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrad.F90
+$(MODEL_LIB)(trcrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_lec.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrst.F90
+$(MODEL_LIB)(trcsbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsbc.F90
+$(MODEL_LIB)(trcsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcsed.F90
+$(MODEL_LIB)(trcsms.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	KEY_CPP \
+	trcsms.F90
+$(MODEL_LIB)(trcsms_c14b.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_c14b.F90
+$(MODEL_LIB)(trcsms_cfc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_cfc.F90
+$(MODEL_LIB)(trcsms_lobster.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_lobster.F90
+$(MODEL_LIB)(trcsms_my_trc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_my_trc.F90
+$(MODEL_LIB)(trcsms_pisces.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_pisces.F90
+$(MODEL_LIB)(trcstp.o) :	\
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trcstp.F90
+$(MODEL_LIB)(trctrp.o) :	\
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trctrp.F90
+$(MODEL_LIB)(trctrp_ctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_ctl.F90
+$(MODEL_LIB)(trctrp_lec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_lec.F90
+$(MODEL_LIB)(trcwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcwri.F90
+$(MODEL_LIB)(trczdf_exp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_exp.F90
+$(MODEL_LIB)(trczdf_imp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_imp.F90
+$(MODEL_LIB)(trczdf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdf.matrixsolver.h90 \
+	KEY_CPP \
+	trczdf_iso.F90
+$(MODEL_LIB)(trczdf_iso_vopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_iso_vopt.F90
+$(MODEL_LIB)(trdicp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdicp.F90
+$(MODEL_LIB)(trdicp_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdicp_oce.F90
+$(MODEL_LIB)(trdmld.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld.F90
+$(MODEL_LIB)(trdmld_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdmld_oce.F90
+$(MODEL_LIB)(trdmld_rst.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	restart.F90 \
+	trdmod_oce.F90 \
+	KEY_CPP \
+	trdmld_rst.F90
+$(MODEL_LIB)(trdmld_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	oce_trc.F90 \
+	prtctl.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld_trc.F90
+$(MODEL_LIB)(trdmld_trc_oce.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trdmld_trc_oce.F90
+$(MODEL_LIB)(trdmld_trc_rst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trdmld_trc_rst.F90
+$(MODEL_LIB)(trdmod.o) :	\
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdmod.F90
+$(MODEL_LIB)(trdmod_oce.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	KEY_CPP \
+	trdmod_oce.F90
+$(MODEL_LIB)(trdvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdvor.F90
+$(MODEL_LIB)(trdvor_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdvor_oce.F90
+$(MODEL_LIB)(trp_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trp_trc.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfbfr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfbfr.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfevd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfevd.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	restart.F90 \
+	tranpc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfkpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	zdfkpp.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zdfric.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfric.F90
+$(MODEL_LIB)(zdftke.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke.F90
+$(MODEL_LIB)(zdftke_old.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke_old.F90
+$(MODEL_LIB)(zdftmx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftmx.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+$(MODEL_LIB)(zpshde_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde_trc.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#---------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model (BB_make.ldef in scripts)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for GYRE ocean configuration: Analytical forcing ---
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_zco key_gyre key_dynspg_flt key_ldfslp key_zdftke key_vectopt_loop key_vectopt_memory key_top key_lobster key_trc_diaadd key_trc_dia3d key_iomput
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Header$
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist	(revision 1844)
@@ -0,0 +1,678 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      =  "Agulhas"!  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =   10950   !  last  time step (std 5475)
+   nn_date0    =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =       0   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =   10950   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =   10950   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .false.   !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea   =    0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=   20.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 2880.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   64      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 14400.          !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 14400.          !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .false.   !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .true.    !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .false.   !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked 
+                           !                     =1 global mean of e-p-r set to zero at each time step 
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   0       !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.5     !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_qns0     =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u10_core'   ,       -1          , 'u10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'U1'
+   sn_wndj     = 'v10_core'   ,       -1          , 'v10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'V1'
+   sn_qsr      = 'qsw_core'   ,       -1          , 'swdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_qlw      = 'qlw_core'   ,       -1          , 'lwdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tair     = 't2_core'    ,       -1          , 't2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_humi     = 'q2_core'    ,       -1          , 'q2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_prec     = 'precip_core',       -1          , 'precip'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_snow     = 'snow_core'  ,       -1          , 'snow'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tdif     = 'taudif_core',       24          , 'taudif'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .true.    !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_data'   ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=1) or not (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   0.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =    1.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 3000.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   = 3000.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    1      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+   ln_bfr2d    =   .false. !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    0.001  !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =  1000.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =     0.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   90      !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .false.  !  laplacian operator         
+   ln_dynldf_bilap  =  .true.   !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = -8.5e+11       !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =     0.         !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    0      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =  60.      !  coef. of the surface input of tke
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.001   !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.01    !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    300    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .false.    !  Add zonal means and meridional stream functions
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist_ice_lim2
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist_ice_lim2	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/1_namelist_ice_lim2	(revision 1844)
@@ -0,0 +1,135 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM2 :  1 - dynamics/advection/thermo          (namicerun)
+!! namelists    2 - ice intialisation                  (namiceini)
+!!              3 - ice dynamic                        (namicedyn)
+!!              5 - ice advection                      (namicetrp)
+!!              6 - thermodynamic                      (namicethd)
+!!              7 - ice salinity                       (namicesal)
+!!              8 - mechanical redistribution of ice   (namiceitdme)
+!!              3 - ice diagnostics                    (namicedia)
+!!              9 - ice outputs                        (namiceout)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   cn_icerst_in  = "restart_ice_in"   !  suffix of ice restart name (input)
+   cn_icerst_out = "restart_ice"      !  suffix of ice restart name (output)
+   ln_limdyn   = .true.    !  ice dynamics (T) or thermodynamics only (F)
+   ln_limdmp   = .false.   !  restoring ice thickness and fraction leads (T) or not (F)
+   acrit       = 1.0e-06   , 1.0e-06   ! minimum fraction for leads in the Northern (Southern) Hemisphere
+   hsndif      =  0.0      !  computation of temperature in snow (=0.0) or not
+   hicdif      =  0.0      !  computation of temperature in ice  (=0.0) or not (=9999.0)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+   ln_limini   = .false.   !  read the ice initial state in the file 'Ice_initialization.nc' (T) or not (F)
+   ttest       =  2.0      !  threshold water temperature for initial sea ice
+   hninn       =  0.5      !  initial snow thickness in the north
+   hginn       =  3.0      !  initial ice  thickness in the north
+   alinn       =  0.05     !  initial leads area     in the north
+   hnins       =  0.1      !  same  three parameter  in the south
+   hgins       =  1.0      !        "                 "     south   
+   alins       =  0.1      !        "                 "     south
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+   epsd        =   1.0e-20 !  tolerance parameter
+   alpha       =   0.5     !  coefficient for semi-implicit coriolis
+   dm          =   0.6e+03 !  diffusion constant for dynamics
+   nbiter      =   1       !  number of sub-time steps for relaxation
+   nbitdr      = 100       !  maximum number of iterations for relaxation
+   om          =   0.5     !  relaxation constant 
+   resl        =   5.0e-05 !  maximum value for the residual of relaxation
+   cw          =   5.0e-03 !  drag coefficient for oceanic stress
+   angvg       =   0.0     !  turning angle for oceanic stress
+   pstar       =   1.0e+04 !  1st bulk-rheology parameter
+   c_rhg       =  20.0     !  2nd bulk-rhelogy parameter
+   etamn       =   0.0e+07 !  minimun value for viscosity
+   creepl      =   2.0e-08 !  creep limit
+   ecc         =   2.0     !  eccentricity of the elliptical yield curve
+   ahi0        = 350.e0    !  horizontal eddy diffusivity coefficient for sea-ice [m2/s]
+/
+!-----------------------------------------------------------------------
+&namicetrp     !   ice transport
+!-----------------------------------------------------------------------
+   bound       =   0.      !  boundary conditions (=0.0 no-slip, =1.0 free-slip)
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+!  hmelt       : maximum melting at the bottom
+!  hiccrit(1/2): ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+!                caution 1.0, 1.0 best value to be used!!! (gilles G.)
+!  hicmin      : ice thickness corr. to max. energy stored in brine pocket
+!  hiclim      : minimum ice thickness
+!  amax        : maximum lead fraction
+!  swiqst      : energy stored in brine pocket (=1) or not (=0)	
+!  sbeta       : numerical caracteritic of the scheme for diffusion in ice
+!               Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+!  parlat      : percentage of energy used for lateral ablation
+!  hakspl      : slope of distr. for Hakkinen-Mellor's lateral melting
+!  hibspl      : slope of distribution for Hibler's lateral melting
+!  exld        : exponent for leads-closure rate
+!  hakdif      : coefficient for diffusions of ice and snow
+!  thth         : threshold thickness for comp. of eq. thermal conductivity
+!  hnzst       : thickness of the surf. layer in temp. computation
+!  parsub      : switch for snow sublimation or not
+!  alphs       : coefficient for snow density when snow ice formation
+! 
+&namicethd
+   hmelt       = -0.15     !  maximum melting at the bottom
+   hiccrit     = 0.3 , 0.3 !  ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+   hicmin      = 0.2       !  ice thickness corr. to max. energy stored in brine pocket
+   hiclim      = 0.05      !  minimum ice thickness
+   amax        = 0.999     !  maximum lead fraction
+   swiqst      = 1.        !  energy stored in brine pocket (=1) or not (=0)	
+   sbeta       = 1.        !  numerical caracteritic of the scheme for diffusion in ice
+                           !        Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+   parlat      = 0.0       !  percentage of energy used for lateral ablation
+   hakspl      = 0.5       !  slope of distr. for Hakkinen-Mellor's lateral melting
+   hibspl      = 0.5       !  slope of distribution for Hibler's lateral melting
+   exld        = 2.0       !  exponent for leads-closure rate
+   hakdif      = 1.0       !  coefficient for diffusions of ice and snow
+   thth        = 0.2       !  threshold thickness for comp. of eq. thermal conductivity
+   hnzst       = 0.1       !  thickness of the surf. layer in temp. computation
+   parsub      = 1.0       !  switch for snow sublimation or not
+   alphs       = 1.0       !  coefficient for snow density when snow ice formation
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+   fmtinf      ='1PE13.5 ' !  format of the output values
+   nfrinf      = 4         !  number of variables written in one line
+   ntmoy       = 1         !  instantaneous values of ice evolution or averaging
+   ninfo       = 1         !  frequency of ouputs on file ice_evolu in case of averaging
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namiceout     !   parameters for outputs
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   noumef      =   19      !  number of fields
+!
+!           !         title of the field           !  name     !   units   !  save  ! multipl. ! additive !
+!           !                                      !           !           ! or not !  factor  !  factor  !
+   field_1  = 'Snow thickness                     ', 'isnowthi', 'm       ',    1   ,  1.0     ,    0.0
+   field_2  = 'Ice thickness                      ', 'iicethic', 'm       ',    1   ,  1.0     ,    0.0
+   field_3  = 'Ice produced                       ', 'iiceprod', 'm/kt    ',    1   ,  1.0     ,    0.0
+   field_4  = 'Ice concentration                  ', 'ileadfra', '%       ',    1   , -1.0     ,    1.0
+   field_5  = 'Ice temperature                    ', 'iicetemp', 'C       ',    1   ,  1.0     , -273.15
+   field_6  = 'Oceanic flux at the ice base       ', 'ioceflxb', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_7  = 'Ice velocity u                     ', 'iicevelu', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_8  = 'Ice velocity v                     ', 'iicevelv', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_9  = 'Sea surface temperature            ', 'isstempe', 'C       ',    1   ,  1.0     , -273.15
+   field_10 = 'Sea surface salinity               ', 'isssalin', 'PSU     ',    1   ,  1.0     ,    0.0
+   field_11 = 'Total flux at ocean surface        ', 'iocetflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_12 = 'Solar flux at ocean surface        ', 'iocesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_13 = 'Non-solar flux at ocean surface    ', 'iocwnsfl', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_14 = 'Salt flux at ocean surface         ', 'iocesafl', 'kg/m2/kt',    1   ,  1.0     ,    0.0
+   field_15 = 'Wind stress u                      ', 'iocestru', 'Pa      ',    1   ,  1.0     ,    0.0
+   field_16 = 'Wind stress v                      ', 'iocestrv', 'Pa      ',    1   ,  1.0     ,    0.0 
+   field_17 = 'Solar flux at ice/ocean surface    ', 'iicesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_18 = 'Non-solar flux at ice/ocean surface', 'iicenflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_19 = 'Snow precipitation                 ', 'isnowpre', 'kg/day  ',    1   ,  1.0     ,    0.0
+/      
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,171 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 1:00:00                # Max total CPU time
+#-Q- sxnec #@$-lt 0:59:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 2Gb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 5000
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 1.8Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=1:01:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=1:01:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=0:40:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      ORCA2_LIM configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories : 
+#- Input file storing 
+#-Q- sxnec R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8brodie R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- aix R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8mercure R_FORCING="/dmnfs10/cont003/p48ethe/FORCINGS/ORCA_R2/NEMO"
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/ORCA2_LIM
+#- execution repository
+R_TMP=$TMPDIR         
+
+##-- define processus number : to change when running in mpp
+NB_PROC=1
+
+#################################
+# End of user modification
+#################################
+
+#--  define a fonction to get the input tarfile
+#-Q- sxnec Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8brodie Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- aix Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8mercure Rapatrie () { [ -f $1/$2 ] || ( cp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+#- Namelist for ocean and ice
+cp ${R_EXPER}/namelist_ice_lim2 namelist_ice 
+cp ${R_EXPER}/namelist namelist
+
+#- Namelist for ocean and ice (agrif fine grid)
+cp ${R_EXPER}/1_namelist_ice_lim2 1_namelist_ice 
+cp ${R_EXPER}/1_namelist 1_namelist
+cp ${R_EXPER}/AGRIF_FixedGrids.in AGRIF_FixedGrids.in
+
+#- Files for the configuration and ocean dynamics
+Rapatrie ${R_TMP} ORCA2_LIM_nemo_v3.2.tar
+
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT *ocean.output ${R_SORTIE_OCE}/.
+$DPUT *solver.stat ${R_SORTIE_OCE}/.
+[ -f *mpp.output* ] && $DPUT *mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_grid_*.nc
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf}
+done
+#
+#- Save ice output files
+for file_netcdf in *icemod*
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf} 
+done
+$DPUT ice.evolu ${R_SORTIE_OCE}/ice.evolu 
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT ${restart} ${R_SORTIE_OCE}/${restart} 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AGRIF_FixedGrids.in
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AGRIF_FixedGrids.in	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/AGRIF_FixedGrids.in	(revision 1844)
@@ -0,0 +1,3 @@
+1
+125 170 36 63 4 4 2
+0
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/EMPave_old.dat
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/EMPave_old.dat	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/EMPave_old.dat	(revision 1844)
@@ -0,0 +1,1 @@
+                               0  0.0000000000000000E+00  0.0000000000000000E+00
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,939 @@
+<?xml version="1.0"?>
+<simulation> 
+  
+  <context id="nemo">
+    
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+    </field_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition >
+
+      <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
+      </group>
+      
+      <group id="2h" output_freq="7200"   output_level="10" enabled=".TRUE.">                      <!-- 2h files -->
+      </group>
+      
+      <group id="3h" output_freq="10800"  output_level="10" enabled=".TRUE.">                      <!-- 3h files -->
+      </group>
+      
+      <group id="4h" output_freq="14400"  output_level="10" enabled=".TRUE.">                      <!-- 4h files -->
+      </group>
+      
+      <group id="6h" output_freq="21600"  output_level="10" enabled=".TRUE.">                      <!-- 6h files -->
+      </group>
+      
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+
+    <!-- 
+............................................................................................................
+           example of 3 types of 1d files
+............................................................................................................
+    -->
+	<!-- automatic definition of the name based on id="1d_grid_T" 
+	     => this name is used as the radical for all file names of this group
+	     => add a suffix to be sure that all files names of this group are different   -->
+	<group id="1d_grid_T" name="auto" description="ocean T grid variables" >
+	  <!-- mooring: automatic definition of the file name suffix based on id="0n180wT"  -->
+	  <file id="0n180wT" name_suffix="auto" >
+	    <group id="0n180wT" zoom_ref="0n180wT" >    <!-- group of variables sharing the same zoom -->
+	      <field ref="toce" name="votemper"  />
+	      <field ref="uoce" name="vozocrtx"  />     <!-- include a U-grid variable in the list => switch to T-grid -->
+	    </group>
+	  </file>
+	  <!-- Equatorial section: automatic definition of the file name suffix based on id="EqT" -->
+	  <file id="EqT" name_suffix="auto" >
+	    <group id="EqT" zoom_ref="EqT" >
+	      <field ref="toce" name="votemper"  />
+	    </group>
+	  </file>
+	  <!-- global file with different operations on data   -->
+	  <file id="global" >
+	    <field ref="sst"    name="sst_1d_ave"                       />     <!-- mean -->
+	    <field ref="sst"    name="sst_1d_max"  operation="t_max(X)" />     <!-- max -->
+	  </file>
+	</group>
+
+      </group>
+      
+      <group id="3d" output_freq="259200" output_level="10" enabled=".TRUE.">                      <!-- 3d files -->
+      </group>
+      
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+
+	<file id="5d_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="toce"         name="votemper"  />
+	  <field ref="soce"         name="vosaline"  />
+	  <field ref="sst"          name="sosstsst"  />
+	  <field ref="sss"          name="sosaline"  />
+	  <field ref="ssh"          name="sossheig"  />
+	  <field ref="emp"          name="sowaflup"  />
+	  <field ref="qsr"          name="soshfldo"  />
+	  <field ref="emps"         name="sowaflcd"  />
+	  <field ref="qns+qsr"      name="sohefldo"  />
+	  <field ref="mldr10_1"     name="somxl010"  />
+	  <field ref="mldkz5"       name="somixhgt"  />
+	  <field ref="ice_cover"    name="soicecov"  />
+	  <field ref="wspd"         name="sowindsp"  />
+	  <field ref="qrp"          name="sohefldp"  />
+	  <field ref="erp"          name="sowafldp"  />
+	  <field ref="mlddzt"       name="sothedep"  />
+	  <field ref="20d"          name="so20chgt"  />
+	  <field ref="28d"          name="so28chgt"  />
+	  <field ref="hc300"        name="sohtc300"  />
+	  <field ref="ist_ipa"      name="soicetem"  />
+	  <field ref="icealb_cea"   name="soicealb"  />   
+	</file>
+	
+	<file id="5d_grid_U" name="auto" description="ocean U grid variables" >
+	  <field ref="uoce"         name="vozocrtx"  />
+	  <field ref="uoce_eiv"     name="vozoeivu"  />
+	  <field ref="utau"         name="sozotaux"  />
+	</file>
+	
+	<file id="5d_grid_V" name="auto" description="ocean V grid variables" >
+	  <field ref="voce"         name="vomecrty"  />
+	  <field ref="voce_eiv"     name="vomeeivv"  />
+	  <field ref="vtau"         name="sometauy"  />
+	</file>
+	
+	<file id="5d_grid_W" name="auto" description="ocean W grid variables" >
+	  <field ref="woce"         name="vovecrtz" />
+	  <field ref="woce_eiv"     name="voveeivw" />
+	  <field ref="avt"          name="votkeavt" />
+	  <field ref="avt_evd"      name="votkeevd" />
+	  <field ref="avm"          name="votkeavm" />
+	  <field ref="avm_evd"      name="votkeevm" />
+	  <field ref="avs"          name="voddmavs" />
+	  <field ref="aht2d"        name="soleahtw" />
+	  <field ref="aht2d_eiv"    name="soleaeiw" />
+	</file>
+	
+	<file id="5d_icemod" name="auto" description="ice variables" >
+	  <field ref="ice_pres"                     />
+	  <field ref="snowthic_cea" name="isnowthi" />
+	  <field ref="icethic_cea"  name="iicethic" />
+	  <field ref="iceprod_cea"  name="iiceprod" />
+	  <field ref="ist_ipa"      name="iicetemp" />
+	  <field ref="ioceflxb"     name="ioceflxb" />
+	  <field ref="uice_ipa"     name="iicevelu" />
+	  <field ref="vice_ipa"     name="iicevelv" />
+	  <field ref="utau_ice"     name="iicestru" />
+	  <field ref="vtau_ice"     name="iicestrv" />
+	  <field ref="qsr_io_cea"   name="iicesflx" />
+	  <field ref="qns_io_cea"   name="iicenflx" />
+	  <field ref="snowpre"      name="isnowpre" />
+	</file>
+	
+      </group>
+      
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+
+	<file id="1m_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="sst"          name="sosstsst"  />
+	</file>   
+
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+
+	<file id="1y_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+	</file>
+
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+
+    </file_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <axis_definition>  
+      <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+      <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+      <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+      <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+      <axis id="none" description="axe non defini" unit="none" size="1" />
+    </axis_definition> 
+    
+    <grid_definition>
+      <grid id="grid_T" description="grid T" >
+    <!--   Eq section   -->
+	<zoom id="EqT" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+    <!--   TAO   -->
+      <!--   137e   -->
+	<zoom id="2n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   147e   -->
+	<zoom id="0n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   156e   -->
+	<zoom id="5s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   165e   -->
+	<zoom id="8s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   180w   -->
+	<zoom id="8s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   170w   -->
+	<zoom id="8s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   155w   -->
+	<zoom id="8s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   140w   -->
+	<zoom id="8s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   125w   -->
+	<zoom id="8s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   110w   -->
+	<zoom id="8s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95w   -->
+	<zoom id="8s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   RAMA   -->
+      <!--   55e   -->
+	<zoom id="16s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+ 	<zoom id="8s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   65e   -->
+	<zoom id="15n65eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   67e   -->
+	<zoom id="16s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   80.5e   -->
+	<zoom id="16s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   90e   -->
+	<zoom id="1.5s90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="15n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95e   -->
+	<zoom id="16s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   PIRATA   -->
+      <!--   38w-30w   -->
+	<zoom id="19s34wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="14s32wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s30wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n35wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="15n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="20n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   23w   -->
+	<zoom id="0n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="21n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   10w   -->
+	<zoom id="10s10wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="6s10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   0e   -->
+	<zoom id="0n0eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      </grid>
+
+      <grid id="grid_U" description="grid U" >
+    <!--   Eq section   -->
+	<zoom id="EqU" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="grid_V" description="grid V" >
+      </grid>
+
+      <grid id="grid_W" description="grid W" >
+    <!--   Eq section   -->
+	<zoom id="EqW" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="scalarpoint" description="scalar" >
+	<zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+      </grid>
+
+    </grid_definition>    
+    
+  </context>
+  
+  <context id="1_nemo">
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+    </field_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition >
+
+      <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
+      </group>
+      
+      <group id="2h" output_freq="7200"   output_level="10" enabled=".TRUE.">                      <!-- 2h files -->
+      </group>
+      
+      <group id="3h" output_freq="10800"  output_level="10" enabled=".TRUE.">                      <!-- 3h files -->
+      </group>
+      
+      <group id="4h" output_freq="14400"  output_level="10" enabled=".TRUE.">                      <!-- 4h files -->
+      </group>
+      
+      <group id="6h" output_freq="21600"  output_level="10" enabled=".TRUE.">                      <!-- 6h files -->
+      </group>
+      
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+	  <!-- global file with different operations on data   -->
+	 <file id="1d_grid_T" name="auto" description="ocean T grid variables" >
+	    <field ref="sst"    name="sst_1d_ave"                       />     <!-- mean -->
+	    <field ref="sst"    name="sst_1d_max"  operation="t_max(X)" />     <!-- max -->
+	  </file>
+      </group>
+      
+      <group id="3d" output_freq="259200" output_level="10" enabled=".TRUE.">                      <!-- 3d files -->
+      </group>
+      
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+
+	<file id="5d_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="toce"         name="votemper"  />
+	  <field ref="soce"         name="vosaline"  />
+	  <field ref="sst"          name="sosstsst"  />
+	  <field ref="sss"          name="sosaline"  />
+	  <field ref="ssh"          name="sossheig"  />
+	  <field ref="emp"          name="sowaflup"  />
+	  <field ref="qsr"          name="soshfldo"  />
+	  <field ref="emps"         name="sowaflcd"  />
+	  <field ref="qns+qsr"      name="sohefldo"  />
+	  <field ref="mldr10_1"     name="somxl010"  />
+	  <field ref="mldkz5"       name="somixhgt"  />
+	  <field ref="ice_cover"    name="soicecov"  />
+	  <field ref="wspd"         name="sowindsp"  />
+	  <field ref="qrp"          name="sohefldp"  />
+	  <field ref="erp"          name="sowafldp"  />
+	  <field ref="mlddzt"       name="sothedep"  />
+	  <field ref="20d"          name="so20chgt"  />
+	  <field ref="28d"          name="so28chgt"  />
+	  <field ref="hc300"        name="sohtc300"  />
+	  <field ref="ist_ipa"      name="soicetem"  />
+	  <field ref="icealb_cea"   name="soicealb"  />   
+	</file>
+	
+	<file id="5d_grid_U" name="auto" description="ocean U grid variables" >
+	  <field ref="uoce"         name="vozocrtx"  />
+	  <field ref="utau"         name="sozotaux"  />
+	</file>
+	
+	<file id="5d_grid_V" name="auto" description="ocean V grid variables" >
+	  <field ref="voce"         name="vomecrty"  />
+	  <field ref="vtau"         name="sometauy"  />
+	</file>
+	
+	<file id="5d_grid_W" name="auto" description="ocean W grid variables" >
+	  <field ref="woce"         name="vovecrtz" />
+	  <field ref="avt"          name="votkeavt" />
+	  <field ref="avt_evd"      name="votkeevd" />
+	  <field ref="avm"          name="votkeavm" />
+	  <field ref="avm_evd"      name="votkeevm" />
+	  <field ref="avs"          name="voddmavs" />
+	  <field ref="aht2d"        name="soleahtw" />
+	</file>
+	
+<!--
+	<file id="5d_icemod" name="auto" description="ice variables" >
+	  <field ref="ice_pres"                     />
+	  <field ref="snowthic_cea" name="isnowthi" />
+	  <field ref="icethic_cea"  name="iicethic" />
+	  <field ref="iceprod_cea"  name="iiceprod" />
+	  <field ref="ist_ipa"      name="iicetemp" />
+	  <field ref="ioceflxb"     name="ioceflxb" />
+	  <field ref="uice_ipa"     name="iicevelu" />
+	  <field ref="vice_ipa"     name="iicevelv" />
+	  <field ref="utau_ice"     name="iicestru" />
+	  <field ref="vtau_ice"     name="iicestrv" />
+	  <field ref="qsr_io_cea"   name="iicesflx" />
+	  <field ref="qns_io_cea"   name="iicenflx" />
+	  <field ref="snowpre"      name="isnowpre" />
+	</file>
+-->
+	
+      </group>
+      
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+
+	<file id="1m_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="sst"          name="sosstsst"  />
+	</file>   
+
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+
+	<file id="1y_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+	</file>
+
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+
+    </file_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <axis_definition>  
+      <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+      <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+      <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+      <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+      <axis id="none" description="axe non defini" unit="none" size="1" />
+    </axis_definition> 
+    
+    <grid_definition>
+      <grid id="grid_T" description="grid T" >
+      </grid>
+
+      <grid id="grid_U" description="grid U" >
+      </grid>
+
+      <grid id="grid_V" description="grid V" >
+      </grid>
+
+      <grid id="grid_W" description="grid W" >
+      </grid>
+
+      <grid id="scalarpoint" description="scalar" >
+	<zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+      </grid>
+
+    </grid_definition>    
+    
+  </context>
+  
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef_ar5.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef_ar5.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/iodef_ar5.xml	(revision 1844)
@@ -0,0 +1,630 @@
+<?xml version="1.0"?>
+<simulation> 
+  
+  <context id="nemo">
+
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="0" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+    </field_definition>
+    
+    <!-- 
+============================================================================================================
+=                                                                                                          =
+=                                           output files definition                                        =
+=                                                                                                          =
+=                  http://www2-pcmdi.llnl.gov/svn/repository/cmor/trunk/Tables/CMIP5_Oclim                 =
+=                  http://www2-pcmdi.llnl.gov/svn/repository/cmor/trunk/Tables/CMIP5_Omon                  =
+=                  http://www2-pcmdi.llnl.gov/svn/repository/cmor/trunk/Tables/CMIP5_Oimon                 =              
+=          http://www.clivar.org/organization/wgomd/references/WGOMD_CMIP5_ocean_fields.June2009.pdf       =
+=                                                                                                          =
+============================================================================================================
+    -->
+    
+    <file_definition output_level="10" >
+      <!--
++++++++++++++++++++++++++++++++++++++++++++++++   daily   ++++++++++++++++++++++++++++++++++++++++++++++++++
+        -->
+      <group id="1d" output_freq="86400"  enabled=".TRUE.">                      <!-- 1d files -->
+	<file id="1d_grid_T" name="auto" name_suffix="_table2.2" description="table 2.2" >         <!-- grid T  -->
+	  <field ref="sst"          name='tos'      description="sea_surface_temperature"                              level="2"                      />
+	  <field ref="sst2"         name='tossq'    description="square_of_sea_surface_temperature"                    level="2"                      />
+	  <field ref="mldkz5"       name='omldamax' description="ocean_mixed_layer_thickness_defined_by_mixing_scheme" level="2" operation="t_max(X)" />
+	</file>   
+      </group>
+	<!--
+++++++++++++++++++++++++++++++++++++++++++++++   monthly   +++++++++++++++++++++++++++++++++++++++++++++++++
+	  -->
+      <group id="1m" output_freq="-1"     enabled=".TRUE.">                      <!-- real monthly files -->
+	<!--
+..............................................    grid T   .................................................
+	  -->
+	<group id="1m_grid_T" name="auto" >                                                        <!-- grid T -->
+	  
+	  <file id="1m grid_T table 2.2" name_suffix="_table2.2" >
+	    <field ref="botpres"      name="pbo"      description="sea_water_pressure_at_sea_floor"                               />
+	    <!-- pso : sea_water_pressure_at_sea_water_surface = 0 -->
+	    <field ref="ssh"          name="zos"      description="sea_surface_height_above_geoid"                                 />
+	    <field ref="ssh2"         name="zossq"    description="square_of_sea_surface_height_above_geoid"             level="2" />
+	    <!-- masscello : sea_water_mass_per_unit_area = cellthc*rau0                                          no time changes -->
+	    <field ref="cellthc"      name="thkcello" description="cell_thickness"                                                 /> <!-- no time changes -->
+	    <field ref="toce"         name="thetao"   description="sea_water_potential_temperature"                                />
+	    <field ref="sst"          name="tos"      description="sea_surface_temperature"                              level="1" />
+	    <field ref="sst2"         name="tossq"    description="square_of_sea_surface_temperature"                    level="2" />
+	    <field ref="soce"         name="so"       description="sea_water_salinity"                                             />
+	    <field ref="sss"          name="sos"      description="sea_surface_salinity"                                 level="1" />
+	    <field ref="rhop"         name="rhopoto"  description="sea_water_potential_density"                          level="2" />
+	    <!-- no agessc : sea_water_age_since_surface_contact -->
+	    <!-- no cfc11  : moles_per_unit_mass_of_cfc11_in_sea_water -->
+	    <!-- msftbarot : ocean_barotropic_mass_streamfunction : offline -->
+	    <!-- mlotst    :           ocean_mixed_layer_thickness_defined_by_sigma_t : must be done offline -->
+	    <!-- mlotstsq  : square_of_ocean_mixed_layer_thickness_defined_by_sigma_t : must be done offline -->
+	    <field ref="mldkz5"       name='omlmax'   description="ocean_mixed_layer_thickness_defined_by_mixing_scheme" level="2" operation="t_max(X)" />
+	  </file>   
+	  
+	  <file id="1m grid_T table 2.5" name_suffix="_table2.5" >
+	    <field ref="rain"         name="pr"       description="rainfall_flux"                                           level="1" />
+	    <field ref="snow_ao_cea"  name="prsn"     description="snowfall_flux"                                           level="1" />
+	    <field ref="evap_ao_cea"  name="evs"      description="water_evaporation_flux"                                  level="1" />
+	    <field ref="runoffs"      name="friver"   description="water_flux_into_sea_water_from_rivers"                   level="1" />
+	    <field ref="calving"      name="ficeberg" description="water_flux_into_sea_water_from_icebergs"                 level="1" />
+	    <field ref="isnwmlt_cea"  name="fsitherm" description="water_flux_into_sea_water_due_to_sea_ice_thermodynamics" level="1" />
+	    <field ref="emp"          name="wfo"      description="water_flux_into_sea_water"                               level="1" />
+	    <!-- wfonocorr : water_flux_into_sea_water_without_flux_correction : emp - erp -->  
+	    <field ref="erp"          name="wfcorr"   description="water_flux_correction"                                   level="1" /> <!-- usually = 0 -->
+	  </file>   
+	  
+	  <file id="1m grid_T table 2.6" name_suffix="_table2.6" >
+	    <!-- vsfpr    : virtual_salt_flux_into_sea_water_due_to_rainfall    = 0 --> 
+	    <!-- vsfevap  : virtual_salt_flux_into_sea_water_due_to_evaporation = 0 --> 
+	    <!-- vsfriver : virtual_salt_flux_into_sea_water_from_rivers        = 0 --> 	  
+	    <field ref="fsal_virt_cea" name="vsfsit" description="virtual_salt_flux_into_sea_water_due_to_sea_ice_thermodynamics" level="1" />
+	    <!-- vsf      : virtual_salt_flux_into_sea_water = fsal_virtual + fsal_real -->
+	    <!-- wfcorr   : virtual_salt_flux_correction                        = 0 --> 
+	    <field ref="fsal_virt_cea" name="sfdsi"  description="downward_sea_ice_basal_salt_flux"                               level="1" />
+	    <!-- sfriver  : salt_flux_into_sea_water_from_rivers                = 0 --> 
+	  </file>   
+	  
+	  <file id="1m grid_T table 2.7" name_suffix="_table2.7" >
+	    <!-- hfgeou : upward_geothermal_heat_flux_at_sea_floor : cte, see nambbc and trabbc.F90 -->
+	    <field ref="hflx_rain_cea" name="hfrainds"    description="temperature_flux_due_to_rainfall_expressed_as_heat_flux_into_sea_water"      level="1" />
+	    <field ref="hflx_evap_cea" name="hfevapds"    description="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water" level="1" />
+	    <field ref="hflx_rnf_cea"  name="hfrunoffds"  description="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water"        level="1" />
+	    <field ref="hflx_snow_cea" name="hfsnthermds" description="heat_flux_into_sea_water_due_to_snow_thermodynamics"                         level="1" />
+	    <field ref="hflx_ice_cea"  name="hfsithermds" description="heat_flux_into_sea_water_due_to_sea_ice_thermodynamics"                      level="1" />
+	    <field ref="hflx_cal_cea"  name="hfibthermds" description="heat_flux_into_sea_water_due_to_iceberg_thermodynamics"                      level="1" />
+	    <!-- rlds   : surface_net_downward_longwave_flux : not available -->
+	    <!-- hfls   : surface_downward_latent_heat_flux  : not available -->
+	    <!-- hfss   : surface_downward_sensible_heat_flux: not available -->
+	    <field ref="qns"           name="nshfls"      description="surface_net_downward_non_solar_flux"                                         level="1" />
+	    <field ref="qsr"           name="rsntds"      description="surface_net_downward_shortwave_flux"                                         level="1" />
+	    <field ref="qsr3d"         name="rsds"        description="downwelling_shortwave_flux_in_sea_water"                                     level="1" />
+	    <field ref="qrp"           name="hfcorr"      description="heat_flux_correction"                                                        level="1" />
+	  </file>   
+	</group>
+	<!--
+..............................................    grid U   .................................................
+	  -->
+	<group id="1m_grid_U" name="auto" >                                                        <!-- grid U -->
+
+	  <file id="1m grid_U table 2.3" name_suffix="_table2.3" >
+	    <field ref="uoce"         name="uo"      description="sea_water_x_velocity"                                       />
+	    <field ref="u_masstr"     name="umo"     description="ocean_mass_x_transport"                           level="1" />
+	    <field ref="u_heattr"     name="hfx"     description="ocean_heat_x_transport"                           level="1" />
+	    <field ref="ueiv_heattr"  name="hfxba"   description="ocean_heat_x_transport_due_to_bolus_advection"    level="2" />
+	    <field ref="udiff_heattr" name="hfxdiff" description="ocean_heat_x_transport_due_to_diffusion"          level="2" />
+	  </file>   
+
+	  <file id="1m grid_U table 2.8" name_suffix="_table2.8" >
+	    <field ref="utau"         name="tauuo" description="surface_downward_x_stress"                          level="1" />
+	    <!-- tauucorr : surface_downward_x_stress_correction = 0 -->
+	  </file>   
+
+	</group>
+	<!--
+..............................................    grid V   .................................................
+	  -->
+	<group id="1m_grid_V" name="auto" >                                                        <!-- grid V -->
+
+	  <file id="1m grid_V table 2.3" name_suffix="_table2.3" >
+	    <field ref="voce"         name="vo"      description="sea_water_y_velocity"                                       />
+	    <field ref="v_masstr"     name="vmo"     description="ocean_mass_y_transport"                           level="1" />
+	    <field ref="v_heattr"     name="hfy"     description="ocean_heat_y_transport"                           level="1" />
+	    <field ref="veiv_heattr"  name="hfyba"   description="ocean_heat_y_transport_due_to_bolus_advection"    level="2" />
+	    <field ref="vdiff_heattr" name="hfydiff" description="ocean_heat_y_transport_due_to_diffusion"          level="2" />
+	  </file>   
+
+	  <file id="1m grid_V table 2.8" name_suffix="_table2.8" >
+	    <field ref="vtau"         name="tauvo" description="surface_downward_y_stress"                          level="1" />
+	    <!-- tauvcorr : surface_downward_y_stress_correction = 0 -->
+	  </file>   
+
+	</group>
+	<!--
+..............................................    grid W   .................................................
+	  -->
+	<group id="1m_grid_W" name="auto" >                                                        <!-- grid W -->
+	  
+	  <file id="1m grid_W table 2.3" name_suffix="_table2.3" >
+	    <field ref="w_masstr"   name="wmo"   description="upward_ocean_mass_transport"                                    />
+	    <field ref="w_masstr2"  name="wmosq" description="square_pf_upward_ocean_mass_transport"                          />
+	  </file>   
+	  
+	  <file id="1m grid_W table 2.9" name_suffix="_table2.9" >
+	    <field ref="avt"     name="difvho"   description="ocean_vertical_heat_diffusivity"                  level="2" />
+	    <field ref="avs"     name="difvso"   description="ocean_vertical_salt_diffusivity"                  level="2" />
+	    <!-- difvtrbo : ocean_vertical_tracer_diffusivity_due_to_background : cte with time, see namelist parameters nn_avb and  nn_havtb -->
+	    <field ref="av_tide" name="difvtrto" description="ocean_vertical_tracer_diffusivity_due_to_tides"   level="2" />
+	    <!-- tnpeo     : tendency_of_ocean_potential_energy_content                   : not available -->
+	    <!-- tnpeot    : tendency_of_ocean_potential_energy_content_due_to_tides      : not available -->
+	    <!-- tnpeotb   : tendency_of_ocean_potential_energy_content_due_to_background : not available -->
+	    <field ref="avm"     name="difvmo"   description="ocean_vertical_momentum_diffusivity"              level="2" />
+	    <!-- difvmbo : ocean_vertical_momentum_diffusivity_due_to_background : cte with time, see namelist parameters nn_avb -->
+	    <field ref="av_tide" name="difvmto"  description="ocean_vertical_momentum_diffusivity_due_to_tides" level="2" /> <!-- same as tracer -->
+	    <!-- difvmfdo : ocean_vertical_momentum_diffusivity_due_to_form_drag : ??? -->
+	    <!-- dispkevfo : ocean_kinetic_energy_dissipation_per_unit_area_due_to_vertical_friction : not available -->
+	  </file>
+
+	  <file id="1m grid_W table 2.10" name_suffix="_table2.10" >
+	    <!-- if ln_traldf_lap    =  .true. -->
+	    <field ref="aht2d_eiv" name="diftrblo" description="ocean_tracer_bolus_laplacian_diffusivity"                     level="2" />
+	    <!-- diftrelo : ocean_tracer_epineutral_laplacian_diffusivity : cte with time, see ln_traldf_iso -->
+	    <!-- diftrxylo : ocean_tracer_xy_laplacian_diffusivity : cte with time -->
+	    <!-- if ln_traldf_bilap  =  .true. -->
+	    <!-- field ref="diftrbbo" name="aht2d_eiv" description="ocean_tracer_bolus_biharmonic_diffusivity"                    level="2" /-->
+	    <!-- diftrebo : ocean_tracer_epineutral_biharmonic_diffusivity : cte with time, see ln_traldf_iso -->
+	    <!-- diftrxybo : ocean_tracer_xy_biharmonic_diffusivity : cte with time -->
+	    <!-- tnkebto : tendency_of_ocean_eddy_kinetic_energy_content_due_to_bolus_transport : not available -->
+	    <!-- difmxylo : ocean_momentum_xy_laplacian_diffusivity : cte with time, see ln_dynldf_lap -->
+	    <!-- difmxybo : ocean_momentum_xy_biharmonic_diffusivity : cte with time, see ln_dynldf_bilap -->
+	    <!-- dispkexyfo : ocean_kinetic_energy_dissipation_per_unit_area_due_to_xy_friction : not available -->
+	  </file>   
+
+	</group>
+	<!--
+..............................................    scalar   .................................................
+	  -->
+	<file id="1m_scalar" name="auto" name_suffix="_table2.2" description="table 2.2" >         <!-- scalar -->
+	  <field ref="masstot"    name="masso"    description="sea_water_mass"                                />
+	  <field ref="voltot"     name="volo"     description="sea_water_volume"                              />
+	  <field ref="sshtot"     name="zosga"    description="global_average_sea_level_change"               />
+	  <field ref="sshsteric"  name="zossga"   description="global_average_steric_sea_level_change"        />
+	  <field ref="sshthster"  name="zostoga"  description="global_average_thermosteric_sea_level_change"  />
+	  <field ref="temptot"    name="thetaoga" description="sea_water_potential_temperature"               />
+	  <field ref="saltot"     name="soga"     description="sea_water_salinity"                            />
+	</file>   
+	<!--
+..............................................    icemod   .................................................
+	  -->
+	<file id="1m_icemod" name="auto" name_suffix="_table2.2" description="table 2.2" >         <!-- scalar -->
+	  <field ref="ice_pres"                     />
+	  <field ref="ice_cover"    name="sic"        description="sea_ice_area_fraction"                            />
+	  <field ref="icethic_cea"  name="sit"        description="sea_ice_thickness"                                />
+	  <field ref="subl_ai_cea"  name="evap"       description="water_evaporation_flux"                           />
+	  <field ref="snowthic_cea" name="snd"        description="surface_snow_thickness"                           />
+	  <!-- snc : surface_snow_area_fraction : same as sic -->
+	  <field ref="icealb_cea"   name="ialb"       description="Bare Sea Ice Albedo"                              />
+	  <!-- ssi : Sea Ice Salinity : cte = sice = 6, expect in baltic sea = 2 -->
+	  <field ref="ist_cea"      name="tsice"      description="Surface Temperature of Sea Ice"                   />
+	  <!-- tsnint : Temperature at Interface Between Sea Ice and Snow : not available -->
+	  <!-- pr : Surface Rainfall Rate into the Sea Ice Portion of the Grid Cell = 0 -->
+	  <field ref="snow_ai_cea"  name="prsn"       description="Surface Snowfall Rate into the Sea Ice Portion of the Grid Cell" />
+	  <!-- ageice   : Age of Sea Ice : not available ??? -->
+	  <!-- grFrazil : Frazil Sea Ice Growth (Leads) Rate ??? -->
+	  <!-- grCongel : Congelation Sea Ice Growth Rate ??? -->
+	  <field ref="licepro_cea"  name="grLateral"  description="Lateral Sea Ice Growth Rate"                      />
+	  <field ref="sntoice_cea"  name="snoToIce"   description="Snow-Ice Formation Rate"                          />
+	  <field ref="snowmel_cea"  name="snomelt"    description="Snow Melt Rate"                                   />
+	  <field ref="ticemel_cea"  name="tmelt"      description="Rate of Melt at Upper Surface of Sea Ice"         />
+	  <field ref="bicemel_cea"  name="bmelt"      description="Rate of Melt at Sea Ice Base"                     />
+	  <!-- hcice  : Sea Ice Total Heat Content ??? -->
+	  <field ref="qsr_ai_cea"   name="rsdssi"     description="surface_downwelling_shortwave_flux_in_air"        />
+	  <!-- rsussi : surface_upwelling_shortwave_flux_in_air ??? -->
+	  <!-- rldssi : surface_downwelling_longwave_flux_in_air ??? -->
+	  <!-- rlussi : surface_upwelling_longwave_flux_in_air ??? -->
+	  <!-- hfssi  : surface_upward_sensible_heat_flux ??? -->
+	  <!-- hflssi : surface_upward_latent_heat_flux ??? -->
+	  <field ref="subl_ai_cea"  name="sblsi"      description="surface_snow_and_ice_sublimation_flux"             />
+	  <field ref="u_imasstr"    name="transix"    description="Eastward Sea Ice Transport"                        />
+	  <field ref="v_imasstr"    name="transiy"    description="Northward Sea Ice Transport"                       />
+	  <field ref="fram_trans"   name="transifs"   description="Sea Ice Mass Transport Through Fram Strait"        />
+	  <field ref="utau_ice"     name="strairx"    description="Eastward Atmospheric Stress On Sea Ice"            />
+	  <field ref="vtau_ice"     name="strairy"    description="Northward Atmospheric Stress On Sea Ice"           />
+	  <!-- strocnx : Eastward Ocean Stress On Sea Ice ??? -->
+	  <!-- strocny : Northward Ocean Stress On Sea Ice ??? -->
+	  <!-- streng  : Compressive Sea Ice Strength ??? -->
+	  <!-- divice  : Strain Rate Divergence of Sea Ice ??? -->
+	  <!-- shrice  : Strain Rate Shear of Sea Ice ??? -->
+	  <!-- ridgice : Sea Ice Ridging Rate ??? -->
+	</file>   
+      </group>
+
+      <!-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+        -->
+    </file_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <axis_definition>  
+      <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+      <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+      <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+      <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+      <axis id="none" description="axe non defini" unit="none" size="1" />
+    </axis_definition> 
+    
+    <grid_definition>
+      <grid id="grid_T" description="grid T" >
+    <!--   Eq section   -->
+	<zoom id="EqT" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+    <!--   TAO   -->
+      <!--   137e   -->
+	<zoom id="2n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   147e   -->
+	<zoom id="0n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   156e   -->
+	<zoom id="5s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   165e   -->
+	<zoom id="8s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   180w   -->
+	<zoom id="8s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   170w   -->
+	<zoom id="8s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   155w   -->
+	<zoom id="8s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   140w   -->
+	<zoom id="8s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   125w   -->
+	<zoom id="8s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   110w   -->
+	<zoom id="8s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95w   -->
+	<zoom id="8s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="2n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   RAMA   -->
+      <!--   55e   -->
+	<zoom id="16s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+ 	<zoom id="8s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   65e   -->
+	<zoom id="15n65eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   67e   -->
+	<zoom id="16s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   80.5e   -->
+	<zoom id="16s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5s80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   90e   -->
+	<zoom id="1.5s90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="1.5n90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="15n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95e   -->
+	<zoom id="16s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="5s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   PIRATA   -->
+      <!--   38w-30w   -->
+	<zoom id="19s34wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="14s32wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8s30wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n35wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="8n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="15n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="20n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   23w   -->
+	<zoom id="0n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="4n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="12n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="21n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   10w   -->
+	<zoom id="10s10wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="6s10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+	<zoom id="0n10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   0e   -->
+	<zoom id="0n0eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      </grid>
+
+      <grid id="grid_U" description="grid U" >
+    <!--   Eq section   -->
+	<zoom id="EqU" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="grid_V" description="grid V" >
+      </grid>
+
+      <grid id="grid_W" description="grid W" >
+    <!--   Eq section   -->
+	<zoom id="EqW" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="scalarpoint" description="scalar" >
+	<zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+      </grid>
+
+    </grid_definition>    
+    
+  </context>
+  
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 1844)
@@ -0,0 +1,707 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      =  "ORCA2"  !  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =    5475   !  last  time step (std 5475)
+   nn_date0    =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =       0   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =    5475   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =    5475   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .false.   !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea   =    0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=   20.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 5760.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   64      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 28800.          !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 28800.          !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .false.   !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .true.    !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 2         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .true.    !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 3         !  FreshWater Budget: =0 unchecked 
+                           !                     =1 global mean of e-p-r set to zero at each time step 
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   0       !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.5     !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_qns0     =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u10_core'   ,       -1          , 'u10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'U1'
+   sn_wndj     = 'v10_core'   ,       -1          , 'v10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'V1'
+   sn_qsr      = 'qsw_core'   ,       -1          , 'swdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_qlw      = 'qlw_core'   ,       -1          , 'lwdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tair     = 't2_core'    ,       -1          , 't2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_humi     = 'q2_core'    ,       -1          , 'q2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_prec     = 'precip_core',       -1          , 'precip'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_snow     = 'snow_core'  ,       -1          , 'snow'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tdif     = 'taudif_core',       24          , 'taudif'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .true.    !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+                                       ! send
+cn_snd_temperature= 'weighted oce and ice'  ! 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_albedo     = 'weighted ice'          ! 'none' 'weighted ice' 'mixed oce-ice'
+cn_snd_thickness  = 'none'                  ! 'none' 'weighted ice and snow'
+cn_snd_crt_nature = 'none'                  ! 'none' 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_crt_refere = 'spherical'             ! 'spherical' 'cartesian'
+cn_snd_crt_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_snd_crt_grid   = 'T'                     ! 'T'
+                                       ! receive
+cn_rcv_w10m       = 'none'                  ! 'none' 'coupled'
+cn_rcv_taumod     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_tau_nature = 'oce only'              ! 'oce only' 'oce and ice' 'mixed oce-ice'
+cn_rcv_tau_refere = 'cartesian'             ! 'spherical' 'cartesian'
+cn_rcv_tau_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_rcv_tau_grid   = 'U,V'                   ! 'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+cn_rcv_dqnsdt     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_qsr        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_qns        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_emp        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_rnf        = 'coupled'               ! 'coupled' 'climato' 'mixed'
+cn_rcv_cal        = 'coupled'               ! 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl_co2   !   coupled ocean/biogeo/atmosphere model            ("key_cpl_carbon_cycle")
+!-----------------------------------------------------------------------
+cn_snd_co2        = 'coupled'         ! send    :  'none' 'coupled'
+cn_rcv_co2        = 'coupled'         ! receive : 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_data'   ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     2     !  add a damping     term in the surface freshwater flux (=2) 
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .true.  !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =    1.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 3000.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   = 3000.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    1      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+   ln_bfr2d    =   .false. !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    0.001  !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =  2000.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =  2000.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   -1      !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .true.   !  laplacian operator         
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = 40000.         !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =     0.         !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    0      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =  60.      !  coef. of the surface input of tke
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.001   !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.01    !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    300    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .true.     !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .true.     !  Add zonal means and meridional stream functions
+   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   ln_ptrcomp = .true.     !  Add decomposition : overturning
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim2
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim2	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim2	(revision 1844)
@@ -0,0 +1,134 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM2 :  1 - dynamics/advection/thermo          (namicerun)
+!! namelists    2 - ice intialisation                  (namiceini)
+!!              3 - ice dynamic                        (namicedyn)
+!!              5 - ice advection                      (namicetrp)
+!!              6 - thermodynamic                      (namicethd)
+!!              7 - ice salinity                       (namicesal)
+!!              8 - mechanical redistribution of ice   (namiceitdme)
+!!              3 - ice diagnostics                    (namicedia)
+!!              9 - ice outputs                        (namiceout)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   cn_icerst_in  = "restart_ice_in"   !  suffix of ice restart name (input)
+   cn_icerst_out = "restart_ice"      !  suffix of ice restart name (output)
+   ln_limdyn   = .true.    !  ice dynamics (T) or thermodynamics only (F)
+   ln_limdmp   = .false.   !  restoring ice thickness and fraction leads (T) or not (F)
+   acrit       = 1.0e-06   , 1.0e-06   ! minimum fraction for leads in the Northern (Southern) Hemisphere
+   hsndif      =  0.0      !  computation of temperature in snow (=0.0) or not
+   hicdif      =  0.0      !  computation of temperature in ice  (=0.0) or not (=9999.0)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+   ln_limini   = .false.   !  read the ice initial state in the file 'Ice_initialization.nc' (T) or not (F)
+   ttest       =  2.0      !  threshold water temperature for initial sea ice
+   hninn       =  0.5      !  initial snow thickness in the north
+   hginn       =  3.0      !  initial ice  thickness in the north
+   alinn       =  0.05     !  initial leads area     in the north
+   hnins       =  0.1      !  same  three parameter  in the south
+   hgins       =  1.0      !        "                 "     south   
+   alins       =  0.1      !        "                 "     south
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+   epsd        =   1.0e-20 !  tolerance parameter
+   alpha       =   0.5     !  coefficient for semi-implicit coriolis
+   dm          =   0.6e+03 !  diffusion constant for dynamics
+   nbiter      =   1       !  number of sub-time steps for relaxation
+   nbitdr      = 100       !  maximum number of iterations for relaxation
+   om          =   0.5     !  relaxation constant 
+   resl        =   5.0e-05 !  maximum value for the residual of relaxation
+   cw          =   5.0e-03 !  drag coefficient for oceanic stress
+   angvg       =   0.0     !  turning angle for oceanic stress
+   pstar       =   1.0e+04 !  1st bulk-rheology parameter
+   c_rhg       =  20.0     !  2nd bulk-rhelogy parameter
+   etamn       =   0.0e+07 !  minimun value for viscosity
+   creepl      =   2.0e-08 !  creep limit
+   ecc         =   2.0     !  eccentricity of the elliptical yield curve
+   ahi0        = 350.e0    !  horizontal eddy diffusivity coefficient for sea-ice [m2/s]
+/
+!-----------------------------------------------------------------------
+&namicetrp     !   ice transport
+!-----------------------------------------------------------------------
+   bound       =   0.      !  boundary conditions (=0.0 no-slip, =1.0 free-slip)
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+!  hmelt       : maximum melting at the bottom
+!  hiccrit(1/2): ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+!                caution 1.0, 1.0 best value to be used!!! (gilles G.)
+!  hicmin      : ice thickness corr. to max. energy stored in brine pocket
+!  hiclim      : minimum ice thickness
+!  amax        : maximum lead fraction
+!  swiqst      : energy stored in brine pocket (=1) or not (=0)	
+!  sbeta       : numerical caracteritic of the scheme for diffusion in ice
+!               Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+!  parlat      : percentage of energy used for lateral ablation
+!  hakspl      : slope of distr. for Hakkinen-Mellor's lateral melting
+!  hibspl      : slope of distribution for Hibler's lateral melting
+!  exld        : exponent for leads-closure rate
+!  hakdif      : coefficient for diffusions of ice and snow
+!  thth         : threshold thickness for comp. of eq. thermal conductivity
+!  hnzst       : thickness of the surf. layer in temp. computation
+!  parsub      : switch for snow sublimation or not
+!  alphs       : coefficient for snow density when snow ice formation
+! 
+   hmelt       = -0.15     !  maximum melting at the bottom
+   hiccrit     = 0.3 , 0.3 !  ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+   hicmin      = 0.2       !  ice thickness corr. to max. energy stored in brine pocket
+   hiclim      = 0.05      !  minimum ice thickness
+   amax        = 0.999     !  maximum lead fraction
+   swiqst      = 1.        !  energy stored in brine pocket (=1) or not (=0)	
+   sbeta       = 1.        !  numerical caracteritic of the scheme for diffusion in ice
+                           !        Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+   parlat      = 0.0       !  percentage of energy used for lateral ablation
+   hakspl      = 0.5       !  slope of distr. for Hakkinen-Mellor's lateral melting
+   hibspl      = 0.5       !  slope of distribution for Hibler's lateral melting
+   exld        = 2.0       !  exponent for leads-closure rate
+   hakdif      = 1.0       !  coefficient for diffusions of ice and snow
+   thth        = 0.2       !  threshold thickness for comp. of eq. thermal conductivity
+   hnzst       = 0.1       !  thickness of the surf. layer in temp. computation
+   parsub      = 1.0       !  switch for snow sublimation or not
+   alphs       = 1.0       !  coefficient for snow density when snow ice formation
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+   fmtinf      ='1PE13.5 ' !  format of the output values
+   nfrinf      = 4         !  number of variables written in one line
+   ntmoy       = 1         !  instantaneous values of ice evolution or averaging
+   ninfo       = 1         !  frequency of ouputs on file ice_evolu in case of averaging
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namiceout     !   parameters for outputs
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   noumef      =   19      !  number of fields
+!
+!           !         title of the field           !  name     !   units   !  save  ! multipl. ! additive !
+!           !                                      !           !           ! or not !  factor  !  factor  !
+   field_1  = 'Snow thickness                     ', 'isnowthi', 'm       ',    1   ,  1.0     ,    0.0
+   field_2  = 'Ice thickness                      ', 'iicethic', 'm       ',    1   ,  1.0     ,    0.0
+   field_3  = 'Ice produced                       ', 'iiceprod', 'm/kt    ',    1   ,  1.0     ,    0.0
+   field_4  = 'Ice concentration                  ', 'ileadfra', '%       ',    1   , -1.0     ,    1.0
+   field_5  = 'Ice temperature                    ', 'iicetemp', 'C       ',    1   ,  1.0     , -273.15
+   field_6  = 'Oceanic flux at the ice base       ', 'ioceflxb', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_7  = 'Ice velocity u                     ', 'iicevelu', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_8  = 'Ice velocity v                     ', 'iicevelv', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_9  = 'Sea surface temperature            ', 'isstempe', 'C       ',    1   ,  1.0     , -273.15
+   field_10 = 'Sea surface salinity               ', 'isssalin', 'PSU     ',    1   ,  1.0     ,    0.0
+   field_11 = 'Total flux at ocean surface        ', 'iocetflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_12 = 'Solar flux at ocean surface        ', 'iocesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_13 = 'Non-solar flux at ocean surface    ', 'iocwnsfl', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_14 = 'Salt flux at ocean surface         ', 'iocesafl', 'kg/m2/kt',    1   ,  1.0     ,    0.0
+   field_15 = 'Wind stress u                      ', 'iocestru', 'Pa      ',    1   ,  1.0     ,    0.0
+   field_16 = 'Wind stress v                      ', 'iocestrv', 'Pa      ',    1   ,  1.0     ,    0.0 
+   field_17 = 'Solar flux at ice/ocean surface    ', 'iicesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_18 = 'Non-solar flux at ice/ocean surface', 'iicenflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_19 = 'Snow precipitation                 ', 'isnowpre', 'kg/day  ',    1   ,  1.0     ,    0.0
+/      
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim3
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim3	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/namelist_ice_lim3	(revision 1844)
@@ -0,0 +1,193 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM3 :  1 - dynamics/advection/thermo          (namicerun)
+!! namelists    2 - ice intialisation                  (namiceini)
+!!              3 - ice dynamic                        (namicedyn)
+!!              4 - ice advection                      (namicetrp)
+!!              5 - thermodynamic                      (namicethd)
+!!              6 - ice salinity                       (namicesal)
+!!              7 - mechanical redistribution of ice   (namiceitdme)
+!!              8 - ice diagnostics                    (namicedia)
+!!              9 - ice outputs                        (namiceout)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   cn_icerst_in  = "restart_ice_in"   !  suffix of ice restart name (input)
+   cn_icerst_out = "restart_ice"      !  suffix of ice restart name (output)
+   ln_limdyn   = .true.    !  ice dynamics (T) or thermodynamics only (F)
+   acrit       =  1.0e-02 , 1.0e-02  !  minimum fraction for leads in the Northern (Southern) Hemisphere
+   hsndif      =  0.0      !  computation of temperature in snow (=0.0) or not
+   hicdif      =  0.0      !  computation of temperature in ice  (=0.0) or not (=9999.0)
+   cai         =  1.40e-3  !  atmospheric drag over sea ice
+   cao         =  1.00e-3  !  atmospheric drag over ocean
+   ln_nicep    = .false.   !  Ice points output for debug (yes or no)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+   ttest       =  2.0      !  threshold water temperature for initial sea ice
+   hninn       =  0.3      !  initial snow thickness in the north
+   hnins       =  0.1      !        "            "          south
+   hginn_u     =  3.50     !  initial undeformed ice thickness in the north
+   hgins_u     =  1.0      !        "            "              "     south
+   aginn_u     =  0.95     !  initial undeformed ice concentration in the north
+   agins_u     =  0.9      !        "            "              "         south
+   hginn_d     =  0.0      !  initial  deformed  ice thickness     in the north
+   hgins_d     =  0.0      !  
+   aginn_d     =  0.00     !  initial  deformed  ice concentration in the north
+   agins_d     =  0.00     !        "            "              "         south
+   sinn        =  6.301    !  initial salinity in the north
+   sins        =  6.301    !        "            "    south
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+   epsd        =   1.0e-20 !  tolerance parameter
+   alpha       =   0.5     !  coefficient for semi-implicit coriolis
+   dm          =   0.6e+03 !  diffusion constant for dynamics
+   nbiter      =   1       !  number of sub-time steps for relaxation
+   nbitdr      = 500       !  maximum number of iterations for relaxation
+   om          =   0.5     !  relaxation constant 
+   resl        =   5.0e-05 !  maximum value for the residual of relaxation
+   cw          =   5.0e-03 !  drag coefficient for oceanic stress
+   angvg       =   0.0     !  turning angle for oceanic stress
+   pstar       =   4.0e+04 !  1st bulk-rheology parameter
+   c_rhg       =  20.0     !  2nd bulk-rhelogy parameter
+   etamn       =   0.0e+07 !  minimun value for viscosity
+   creepl      =   1.0e-12 !  creep limit
+   ecc         =   2.0     !  eccentricity of the elliptical yield curve
+   ahi0        = 350.e0    !  horizontal eddy diffusivity coefficient for sea-ice [m2/s]
+   nevp        = 300       !  number of iterations for subcycling in EVP, SB, 400
+   telast      =9600.0     !  timescale for elastic waves, SB, 720.0
+   alphaevp    =   1.0     !  coefficient for the solution of internal ice stresses
+/
+!-----------------------------------------------------------------------
+&namicetrp     !   ice transport
+!-----------------------------------------------------------------------
+   bound       =   0.      !  boundary conditions (=0.0 no-slip, =1.0 free-slip)
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+   hmelt       = -0.15     !  maximum melting at the bottom
+   hiccrit     = 0.1 , 0.1 !  ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+                           !         caution 1.0, 1.0 best value to be used!!! (gilles G.)  ????
+   fraz_swi    = 0.0       !  use of frazil ice collection thickness in function of wind (1.0) or not (0.0)
+   maxfrazb    = 0.0       !  maximum portion of frazil ice collecting at the ice bottom
+   vfrazb      = 0.4166667 !  thresold drift speed for frazil ice collecting at the ice bottom
+   Cfrazb      = 5.0       !  squeezing coefficient for frazil ice collecting at the ice bottom
+   hicmin      = 0.2       !  ice thickness corr. to max. energy stored in brine pocket
+   hiclim      = 0.10      !  minimum ice thickness
+   amax        = 0.999     !  maximum lead fraction
+   sbeta       = 1.        !  numerical caracteritic of the scheme for diffusion in ice
+                           !        Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+   parlat      = 0.0       !  percentage of energy used for lateral ablation
+   hakspl      = 0.25      !  slope of distr. for Hakkinen-Mellor's lateral melting
+   hibspl      = 0.5       !  slope of distribution for Hibler's lateral melting
+   exld        = 2.0       !  exponent for leads-closure rate
+   hakdif      = 1.0       !  coefficient for diffusions of ice and snow
+   thth        = 0.2       !  threshold thickness for comp. of eq. thermal conductivity
+   hnzst       = 0.1       !  thickness of the surf. layer in temp. computation
+   parsub      = 1.0       !  switch for snow sublimation or not
+   alphs       = 1.0       !  coefficient for snow density when snow ice formation
+   betas       = 0.6       !  exponent in lead-ice fractionation of snow precipitation 0.66
+                           !        betas = 1 -> equipartition, betas < 1 -> more on leads
+   kappa_i     = 1.0       !  extinction radiation parameter in sea ice (1.0)
+   nconv_i_thd = 50        !  maximal number of iterations for heat diffusion computation
+   maxer_i_thd = 0.0001    !  maximal error in temperature for heat diffusion computation
+   thcon_i_swi = 1         !  switch for computation of thermal conductivity in the ice
+                           !        (0) Untersteiner (1964), (1) Pringle et al. (2007)
+/
+!-----------------------------------------------------------------------
+&namicesal     !   ice salinity
+!-----------------------------------------------------------------------
+   num_sal     =  2        !  salinity option: 1 -> S = bulk_sal
+                           !                   2 -> S = S(z,t) with a simple parameterization
+                           !                   3 -> S = S(z) profile of Scwharzacher [1959]
+                           !                   4 -> S = S(h) Cox and Weeks [1974]
+   bulk_sal    =  4.0      !  if 1 is used, it represents the ice salinity
+   sal_G       =  5.00     !  restoring salinity for GD
+   time_G      =  1.728e+6 !  restoring time for GD
+   sal_F       =  2.00     !  restoring salinity for flushing
+   time_F      =  8.640e+5 !  restoring time for flushing
+   s_i_max     = 20.0      !  Maximum salinity 
+   s_i_min     =  0.1      !  Minimum tolerated ice salinity
+   s_i_0       =  3.5      !  1st salinity for salinity profile
+   s_i_1       =  4.5      !  2nd salinity for salinity profile
+/
+!-----------------------------------------------------------------------
+&namiceitdme   !   parameters for mechanical redistribution of ice 
+!-----------------------------------------------------------------------
+   ridge_scheme_swi = 0      !  which ridging scheme using (1=Rothrock,else=Hibler79)
+   Cs               =   0.50 !  shearing energy contribution to ridging
+   Cf               =  17.0  !  ratio of ridging work to PE change in ridging
+   fsnowrdg         =   0.5  !  snow fraction that survives in ridging
+   fsnowrft         =   0.5  !  snow fraction that survives in rafting
+   Gstar            =   0.15 !  fractional area of thin ice being ridged
+   astar            =   0.05 !  equivalent of gstar (0.05 for TH75 and 0.03 for weaker ice)
+   Hstar            = 100.0  !  parameter determining the maximum thickness of ridged ice
+   raftswi          =   1    !  rafting or not
+   hparmeter        =   0.75 !  threshold thickness for rafting or not
+   Craft            =   5.0  !  coefficient used in the rafting function
+   ridge_por        =   0.3  !  initial porosity of the ridged ice (typically 0.30)
+   sal_max_ridge    =  15.0  !  maximum ridged ice salinity
+   partfun_swi      =   1    !  participation function linear, TH75 (0) or exponential Letal07 (1)
+   transfun_swi     =   0    !  transfer function uniform of H80 (0) or exponential Letal07 (1)
+   brinstren_swi    =   0    !  (1) use brine volume to diminish ice strength
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+   fmtinf      ='1PE13.5 ' !  format of the output values
+   nfrinf      = 4         !  number of variables written in one line
+   ntmoy       = 1         !  instantaneous values of ice evolution or averaging
+   ninfo       = 1         !  frequency of ouputs on file ice_evolu in case of averaging
+/
+!-----------------------------------------------------------------------
+&namiceout     !   parameters for outputs
+!-----------------------------------------------------------------------
+   noumef      =   37      !  number of fields
+   add_diag_swi=    1      !  1 -> diagnose distribution in thickness space
+                           !  0 -> only simple diagnostics
+!
+!           !         title of the field           !  name     !   units   !  save  ! multipl. ! additive !
+!           !                                      !           !           ! or not !  factor  !  factor  !
+   field_1  = 'Ice concentration                  ', 'iiceconc', '%       ',    1   ,  1.0     ,    0.0
+   field_2  = 'Ice thickness                      ', 'iicethic', 'm       ',    1   ,  1.0     ,    0.0
+   field_3  = 'Snow thickness                     ', 'isnowthi', 'm       ',    1   ,  1.0     ,    0.0
+   field_4  = 'Daily bottom thermo ice production ', 'iicebopr', 'cm/day  ',    1   , 100.     ,    0.0
+   field_5  = 'Daily dynamic ice production       ', 'iicedypr', 'cm/day  ',    1   , 100.     ,    0.0
+   field_6  = 'Oceanic flux at the ice base       ', 'ioceflxb', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_7  = 'Ice velocity u                     ', 'iicevelu', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_8  = 'Ice velocity v                     ', 'iicevelv', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_9  = 'Sea surface temperature            ', 'isstempe', 'C       ',    1   ,  1.0     , -273.15
+   field_10 = 'Sea surface salinity               ', 'isssalin', 'PSU     ',    1   ,  1.0     ,    0.0
+   field_11 = 'Total flux at ocean surface        ', 'iocetflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_12 = 'Solar flux at ocean surface        ', 'iocesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_13 = 'Non-solar flux at ocean surface    ', 'iocwnsfl', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_14 = 'Heat flux due to brine release     ', 'iocehebr', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_15 = 'Wind stress u                      ', 'iocestru', 'Pa      ',    1   ,  1.0     ,    0.0
+   field_16 = 'Wind stress v                      ', 'iocestrv', 'Pa      ',    1   ,  1.0     ,    0.0 
+   field_17 = 'Solar flux at ice/ocean surface    ', 'iicesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_18 = 'Non-solar flux at ice/ocean surface', 'iicenflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_19 = 'Snow precipitation                 ', 'isnowpre', 'kg/day  ',    1   ,  1.0     ,    0.0
+   field_20 = 'Mean ice salinity                  ', 'iicesali', 'psu     ',    1   ,  1.0     ,    0.0
+   field_21 = 'Mean ice age                       ', 'iiceages', 'years   ',    1   ,  0.002739,    0.0
+   field_22 = 'Daily lateral thermo ice prod.     ', 'iicelapr', 'cm/day  ',    1   ,100.      ,    0.0
+   field_23 = 'Daily snowice ice production       ', 'iicesipr', 'cm/day  ',    1   ,100.      ,    0.0
+   field_24 = 'Mean ice temperature               ', 'iicetemp', 'C       ',    1   ,  1.0     , -273.15
+   field_25 = 'Ice total heat content             ', 'iiceheco', '10^9 J  ',    1   ,  1.0     ,    0.0
+   field_26 = 'Ice surface temperature            ', 'iicesurt', 'C       ',    1   ,  1.0     , -273.15
+   field_27 = 'Snow temperature                   ', 'isnotem2', 'C       ',    1   ,  1.0     , -273.15
+   field_28 = 'Fsbri - brine salt flux            ', 'iicfsbri', 'kg/m2/s ',    1   ,  1.0     ,    0.0
+   field_29 = 'Fseqv - equivalent FW salt flux    ', 'iicfseqv', 'kg/m2/s ',    1   ,  1.0     ,    0.0
+   field_30 = 'Brine volume                       ', 'ibrinvol', '%       ',    1   ,  100.0   ,    0.0
+   field_31 = 'Frazil ice collection thickness    ', 'iicecolf', 'm       ',    1   ,  1.0     ,    0.0
+   field_32 = 'Ice strength                       ', 'iicestre', 'N/m     ',    1   ,  0.001   ,    0.0
+   field_33 = 'Ice velocity                       ', 'iicevelo', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_34 = 'Surface melt                       ', 'iicesume', 'cm/day  ',    1   ,100.      ,    0.0
+   field_35 = 'Bottom melt                        ', 'iicebome', 'cm/day  ',    1   ,100.      ,    0.0
+   field_36 = 'Divergence                         ', 'iicedive', '10-8s-1 ',    1   ,  1.0e8   ,    0.0
+   field_37 = 'Shear                              ', 'iiceshea', '10-8s-1 ',    1   ,  1.0e8   ,    0.0
+/      
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,20 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
+  
+  
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.card	(revision 1844)
@@ -0,0 +1,28 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+
+[InitialStateFiles]
+List=	()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= ()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist_ice_lim2, namelist_ice)
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart_ice.nc, restart_icemod.nc, restart_ice_in.nc)
+
+[OutputText]
+List=   (ice_evolu)
+
+[OutputFiles]
+List=   (${PREFIX_WFI1}_icemod.nc, ${R_OUT_ICE_WFI1}/${PREFIX}_${WFI1}_icemod.nc, Post_5D_icemod)
+
+[Post_1M_icemod]
+Patches = ()
+GatherWithInternal = (nav_lon, nav_lat, time_counter)
+TimeSeriesVars = (iicethic, ileadfra, isnowthi, iicevelu, iicevelv)
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/lim2.driver	(revision 1844)
@@ -0,0 +1,56 @@
+#!/bin/ksh
+
+#-----------------------------------
+function ICE_Initialize
+{ 
+    IGCM_debug_PushStack "ICE_Initialize"
+
+    echo INITIALIZE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Initialize"
+}
+
+#-----------------------------------
+function ICE_Update
+{
+    IGCM_debug_PushStack "ICE_Update"
+
+    NbFreq=$( echo ${config_ICE_WriteFrequency} | wc -w )
+
+    ##--Write Frequency Purpose ....
+    typeset -Z1 i=1
+    while [ $i -le ${NbFreq} ]; do
+        frequency=$( echo ${config_ICE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+        factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
+        case ${frequency} in
+            *Y|*y)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_Y} ;
+                eval WFI${i}=${factor}Y ;;
+            *M|*m)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_M} ;
+                eval WFI${i}=${factor}M ;;
+            *D|*d)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_D} ;
+                eval WFI${i}=${factor}D ;;
+            *)
+        esac
+        let i=$i+1
+
+    done
+    echo UPDATE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Update"
+}
+
+#-----------------------------------
+function ICE_Finalize
+{
+    IGCM_debug_PushStack "ICE_Finalize"
+
+    echo FINALIZE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Finalize"
+}
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.card	(revision 1844)
@@ -0,0 +1,125 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+OPA_NDT_DAY=15
+#==============================================================
+#-- Name of directory for COMMON ACCOUNT at idris or CCRT
+#-- available directories are:  v3, v3_1, v3_2
+#-- related to NEMO_tag_revision (nemo_v3, nemo_v3_1, nemo_v3_2_beta)
+#-- NOTE: if you use your own directory you have to comment it
+OPA_version=v3_2
+#==============================================================
+
+#===================================
+#-- Use (y) or not (n) of io_server
+io_server=n
+#===================================
+
+#-- if you run interannual is "y", if not (=climatology) is "n"
+Interannual_Run=n
+
+[Interannual]
+#==================================================================================================
+#-- Surface Boundary Condition original files name ( get by the job ) same as the ones in namelist
+#==================================================================================================
+#-- NOTE: MANDATORY STRUCTURE OF FILE NAMES GET BY THE JOB : 
+#-- "basename_yyyy.nc"  	( for interannual data )
+#-- "basename.nc"	  	( for climatologycal data )
+#-- MANDATORY: NAMES USED IN List_jobsbc VARIABLE MUST BE ONLY THE BASENAME
+
+# default climatology, bulk_clio: 
+List_jobsbc=(flx, taux_1m, tauy_1m)
+# example for interannual, bulk core, forcing CORE2:
+#List_jobsbc=(u_1O_orca2, v_1O_orca2, ncar_rad_1O_orca2, t_10_orca2, q_10_orca2, ncar_precip_orca2)
+# example for interannual, bulk core, forcing DRAKKAR:
+#List_jobsbc=(radlw_DFS4-ORCA2, radsw_DFS4-ORCA2, q2_DFS4-ORCA2, t2_DFS4-ORCA2, u10_DFS4-ORCA2, v10_DFS4-ORCA2, snow_DFS4-ORCA2, precip_DFS4-ORCA2)
+
+
+[InitialStateFiles]
+List=	()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/ahmcoef, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_level.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_meter.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_updated.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/coordinates.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_potential_temperature_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_salinity_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/geothermal_heating.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/runoff_1m_nomask.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/sss_data.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/sst_data.nc, .),\
+	    (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/subbasins.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/chlaseawifs_c1m-99-05_smooth_ORCA_R2.nc, chlorophyll.nc),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/Tides_K1_drg_ORCA_R2.nc, K1rowdrg.nc),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/Tides_M2_drg_ORCA_R2.nc, M2rowdrg.nc),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/tmaskitf_ORCA2_bis.nc, mask_itf.nc),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/kRGB61.txt, .)
+
+
+
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist,         namelist), \
+	(${SUBMIT_DIR}/PARAM/iodef.xml,        iodef.xml),      \
+        (${SUBMIT_DIR}/PARAM/xmlio_server.def, xmlio_server.def)
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart.nc,  restart.nc, restart.nc)
+
+[OutputText]
+List=   (ocean.output, solver.stat, STRAIT.dat, out_nemo)
+
+[OutputFiles]
+List=   (${PREFIX_WF1}_grid_T.nc,         ${R_OUT_OCE_WF1}/${PREFIX}_${WF1}_grid_T.nc,               Post_1Y_grid_T),\
+        (${PREFIX_WF2}_grid_T.nc,         ${R_OUT_OCE_WF2}/${PREFIX}_${WF2}_grid_T.nc,               Post_1M_grid_T),\
+        (${PREFIX_WF3}_grid_T.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_T.nc,               Post_1M_grid_T),\
+        (${PREFIX_WF3}_grid_U.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_U.nc,               Post_1M_grid_U) ,\
+        (${PREFIX_WF3}_grid_V.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_V.nc,               Post_1M_grid_V),\
+        (${PREFIX_WF3}_grid_W.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_W.nc,               Post_1M_grid_W),\
+        (${PREFIX_WF4}_grid_T_0n180w.nc,  ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_grid_T_0n180w.nc,        NONE ),\
+        (${PREFIX_WF4}_grid_T_Eq.nc,      ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_grid_T_Eq.nc,            NONE ),\
+        (${PREFIX_WF4}_diaptr.nc,         ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_diaptr.nc,               Post_1D_diaptr),\
+        (mesh_mask.nc     ,               ${R_OUT_OCE_O}/${config_UserChoices_JobName}_mesh_mask.nc, NONE),\
+        (output.abort.nc  ,               ${R_OUT_OCE_D}/${PREFIX}_output.abort.nc,                  NONE),\
+        (output.init.nc   ,               ${R_OUT_OCE_O_I}/${config_UserChoices_JobName}_${PeriodDateBegin}_output.init.nc, NONE)
+
+
+[Post_1Y_grid_T]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (sohtc300, sohefldo, soicecov, somxl010, sosaline, sossheig, sosstsst, sowaflcd, sowaflup)
+
+[Post_1M_grid_T]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (sohtc300, sohefldo, soicecov, somxl010, sosaline, sossheig, sosstsst, sowaflcd, sowaflup)
+
+[Post_1M_grid_U]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthu, time_counter)
+TimeSeriesVars = (sozotaux)
+
+[Post_1M_grid_V]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthv, time_counter)
+TimeSeriesVars = (sometauy)
+
+[Post_1M_grid_W]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthw, time_counter)
+TimeSeriesVars =
+
+[Post_1D_diaptr]
+Patches = ()
+GatherWithInternal = (lat, deptht, depthw, time_counter)
+TimeSeriesVars = (zotemglo, zosalglo, zomsfglo, zotematl, zosalatl, zomsfatl, zotempac, zosalpac, zomsfpac, zotemind, zosalind, zomsfind, zotemipc, zosalipc, zomsfipc, sohtatl, sostatl, sohtpac, sostpac, sohtind, sostind, sohtipc, sostipc, sophtadv, sophtove, sophtldf, sopstadv, sopstove, zomsfeiv, sophteiv, sopsteiv)
+
+[Post_time]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal =
+TimeSeriesVars =
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/COMP/opa9.driver	(revision 1844)
@@ -0,0 +1,297 @@
+#!/bin/ksh
+#-----------------------------------------------------------------
+function OCE_Initialize
+{
+    IGCM_debug_PushStack "OCE_Initialize"
+
+    JOB_NAME=${config_UserChoices_JobName}
+
+    OPA_NDT_DAY=${opa_UserChoices_OPA_NDT_DAY:=15}
+
+
+    ##--Variables used by OPA --
+
+    # cn_exp experience name for vairmer format
+    # nn_it000 number of the first time step
+    # nn_itend number of the last time step
+    # nn_leapy leap year calendar (0/1) (30 for 360d)
+    # nn_write frequency of OUTPUT file
+    # ln_rstart boolean term for restart (true or false)
+    # nn_stock frequency of restart file
+    # nn_rstctl control of the time step (0, 1 or 2)
+    # nn_date0 initial calendar date aammjj
+    # nn_msh  =1 create a mesh file (coordinates, scale factors, masks)
+    # rn_rdt time step in seconds (coming from namelist)
+    # nf_ptr_wri frequency of zonal means and transport output
+
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+
+    PAT_CEXPER=$( supergrep cn_exp    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NIT000=$( supergrep nn_it000    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NITEND=$( supergrep nn_itend    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NLEAPY=$( supergrep nn_leapy    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_RESTAR=$( supergrep ln_rstart ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NSTOCK=$( supergrep nn_stock    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NRSTAR=$( supergrep nn_rstctl    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NDATE0=$( supergrep nn_date0    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NMSH=$(   supergrep nn_msh      ${SUBMIT_DIR}/PARAM/namelist ) 
+    
+
+    OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/namelist | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
+
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # /!\ Needed by OPA namelist to compute file names /!\
+    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
+
+    # Definition from opa9.card of List_jobsbc and List_runsbc used to do to interannual and climatological runs 
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/opa9.card Interannual List_jobsbc
+        set -A ListFormulationJobsbc -- \${opa9_Interannual_Listjobsc${opa9_Interannual_List_jobsbc}[*]}
+
+    ##--Variables used for XMLIO_SERVER configuration file
+	    # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+	    PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def )
+	
+    IGCM_debug_PopStack "OCE_Initialize"
+}
+
+#-----------------------------------------------------------------
+function OCE_Update
+{
+    IGCM_debug_PushStack "OCE_Update"
+
+    # Interannual run
+    # In this case job need to calculate previous and following year and give, and if every run needs to add "_y" before every year 
+    if [ X${opa9_UserChoices_Interannual_Run} = Xy ] ; then
+
+	typeset file 
+
+ 	(( PeriodCumulPeriod =  ${CumulPeriod} - 1 )) 
+ 	(( PeriodInitYear =${InitYear} + ${PeriodCumulPeriod} * ${PeriodLengthInYears} ))
+ 	(( PeriodFinalYear =${InitYear} + ${PeriodLengthInYears}*${CumulPeriod} - 1 ))
+
+        NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
+        (( NbFileInter_tot=${#opa9_Interannual_List_jobsbc[*]} * ${PeriodLengthInYears} ))
+	(( i = 0 ))
+
+	while [ ${year} -le ${PeriodFinalYear} ] ; do #copy in ONCE of ALL necessary files for all PeriodLength
+	    
+	    while [ $i -lt ${NbFileInter} ] ; do
+		
+		eval file=${opa9_Interannual_List_jobsbc[$i]}
+		if [ X${year} = X${PeriodInitYear} ] ; then  
+                        	if [ ${month} -eq 01 ] ; then
+		    			# if year-1 does not exist we copy year in (year-1)
+		    			eval jobsbc_file_ym1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year - 1 )).nc
+		    			if  [ ! -f ${jobsbc_file_ym1} ] ; then
+		    				eval jobsbc_file_ym1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_${year}.nc
+		    				eval runsbc_file_ym1=${file}_noy.nc
+		    			else
+		    			    eval jobsbc_file_ym1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year - 1 )).nc
+		    			    eval runsbc_file_ym1=${file}_y$(( year - 1 )).nc
+		    			fi
+
+                            IGCM_sys_Get ${jobsbc_file_ym1} ${runsbc_file_ym1}
+                        	fi
+		fi
+		
+       		# download year 
+		eval jobsbc_file_y=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_${year}.nc
+		eval runsbc_file_y=${file}_y${year}.nc
+		
+		if [ ! -f ${runsbc_file_y} ] ; then
+		    IGCM_sys_Get ${jobsbc_file_y} ${runsbc_file_y}
+		fi
+		
+		# download (year+1) if it is last year of run
+		if [ X${year} = X${PeriodFinalYear} ] ; then 	
+	
+		    eval jobsbc_file_yp1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year + 1 )).nc
+		    eval runsbc_file_yp1=${file}_y$(( year + 1 )).nc
+		    
+		    if  [ ! -f ${runsbc_file_yp1} ] ; then
+			
+		        # if year+1 does not exist we copy year in (year+1)
+			if  [ ! -f ${jobsbc_file_yp1} ] ; then
+			    eval jobsbc_file_yp1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_${year}.nc
+		    	    eval runsbc_file_yp1=${file}_noy.nc
+			else
+			    eval jobsbc_file_yp1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year + 1 )).nc
+			    eval runsbc_file_yp1=${file}_y$(( year + 1 )).nc
+			fi
+			IGCM_sys_Get ${jobsbc_file_yp1} ${runsbc_file_yp1}
+		    fi
+		    
+		fi
+		(( i = i + 1 ))
+	
+	    done
+	
+	    (( year = year + 1 ))
+	 
+	    (( i = 0 ))
+	done
+
+    # End interannual
+    elif [ X${opa9_UserChoices_Interannual_Run} = Xn ] ; then
+    # Climatological run
+       typeset file 
+
+       eval NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
+
+        (( i = 0 ))
+        while [ $i -lt ${NbFileInter} ] ; do
+            eval file=${opa9_Interannual_List_jobsbc[$i]}
+            eval jobsbc_file=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}.nc
+            eval runsbc_file=${file}.nc
+
+            IGCM_sys_Get ${jobsbc_file} ${runsbc_file}
+            (( i = i + 1 ))
+	done
+    fi
+    # End climatological
+
+    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
+
+    ##--Write Frequency Purpose ....
+    typeset -Z1 i=1
+    while [ $i -le ${NbFreq} ]; do
+        frequency=$( echo ${config_OCE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+    	factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
+    	case ${frequency} in
+    	    *Y|*y)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_Y} ;
+    	        eval WF${i}=${factor}Y ;;
+    	    *M|*m)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_M} ;
+    	        eval WF${i}=${factor}M ;;
+    	    *D|*d)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_D} ;
+    	        eval WF${i}=${factor}D ;;
+    	    *)
+    	esac
+        let i=$i+1
+
+    done
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # Needed by OPA namelist to compute correct file names 
+    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
+
+    ## Count of number of time steps from begin of OPA job
+    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NDT_DAY + 1 ))
+    (( OPA_NDT   = PeriodLengthInDays * OPA_NDT_DAY ))
+    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
+
+    ## Forcing to write one restart file at the end of period
+    OPA_NSTOCK="${OPA_NITEND}"
+
+    ## Verification of number of time steps per day
+    (( NB_SEC_DAY_MODEL = OPA_NDT_DAY * OPA_RDT ))
+    (( NB_SEC_DAY = 60 * 60 * 24 ))
+
+    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
+	then
+        echo " VERIFY OPA_NDT_DAY in opa9.card "
+        exit
+    fi
+
+    ##-- Restart configuration
+    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
+
+        #echo "NO OPA RESTART"
+	OPA_LRSTAR=.FALSE.
+	OPA_NRSTDT=0
+        #Put OPA_NMSH=0 when OPA runnig in parallel mode 
+	OPA_NMSH=1
+	( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) && OPA_NMSH=0
+
+    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
+
+        #echo "OPA RESTART"
+	OPA_LRSTAR=.TRUE.
+	OPA_NRSTDT=1
+	OPA_NMSH=0
+
+    else
+
+        #echo "OPA RESTART"
+	OPA_LRSTAR=.TRUE.
+	OPA_NRSTDT=2
+	OPA_NMSH=0
+
+    fi
+   
+     ## nleapy configuration
+	case ${config_UserChoices_CalendarType} in
+        	leap)
+            	OPA_NLEAPY=1;;
+        	noleap)
+            	OPA_NLEAPY=0;;
+        	360d)
+            	OPA_NLEAPY=30;;
+    	esac
+
+
+        typeset -r PRECIS=8
+	NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
+
+    sed -e "s%${PAT_CEXPER}%       cn_exp=\"${config_UserChoices_JobName}\"%"  \
+	-e "s%${PAT_NIT000}%       nn_it000=${OPA_NIT000}%"                    \
+	-e "s%${PAT_NITEND}%       nn_itend=${OPA_NITEND}%"                    \
+	-e "s%${PAT_RESTAR}%       ln_rstart=${OPA_LRSTAR}%"                   \
+	-e "s%${PAT_NSTOCK}%       nn_stock=${OPA_NSTOCK}%"                    \
+	-e "s%${PAT_NRSTAR}%       nn_rstctl=${OPA_NRSTDT}%"                   \
+	-e "s%${PAT_NDATE0}%       nn_date0=${PeriodDateBegin}%"               \
+	-e "s%${PAT_NMSH}%         nn_msh=${OPA_NMSH}%"                        \
+	-e "s%${PAT_NLEAPY}%       nn_leapy=${OPA_NLEAPY}%"	               \
+	namelist > namelist.tmp
+
+    IGCM_sys_Mv namelist.tmp namelist
+
+
+    # update iodef.xml
+	
+  if ( [ "${CumulPeriod}" -eq 1 ] || [ "${CumulPeriod}" -eq 6 ] ) ; then
+
+	sed -e "s/<group\ id=\"1m\"\ output_freq=\"-1\"\ output_level=\"10\"\ enabled=\".FALSE.\">/<group\ id=\"1m\"\ output_freq=\"-1\"\ output_level=\"10\"\ enabled=\".TRUE.\">/" \
+	        iodef.xml > iodef.xml.tmp
+	    IGCM_sys_Mv iodef.xml.tmp iodef.xml
+  fi	
+	
+
+    # update xmlio_server.def
+
+    if [ X${opa9_UserChoices_io_server} = Xy ] ; then
+        sed -e "s/${PAT_SERVER}/  using_server = .TRUE./" \
+        xmlio_server.def > xmlio_server.def.tmp
+        IGCM_sys_Mv xmlio_server.def.tmp xmlio_server.def
+    fi
+	
+    IGCM_debug_PopStack "OCE_Update"
+}
+
+#-----------------------------------
+function OCE_Finalize
+{
+    IGCM_debug_PushStack "OCE_Finalize"
+
+    if [ -f date.file ] ; then
+        # Prefix use in opa.card AND in lim2.card :
+	DATE_OPA=$( cat date.file | \
+	    sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
+        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
+	MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
+	SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
+    fi
+
+    echo FINALIZE OCE !!!
+
+    IGCM_debug_PopStack "OCE_Finalize"
+}
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/config.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/config.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/IGCM00/config.card	(revision 1844)
@@ -0,0 +1,115 @@
+#
+# This is config.card file for NEMO ORCA2_LIM2 configuration
+#
+#========================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=ORCA2
+LongName="SCRIPT_V1"
+TagName=ORCA2_LIM2
+#============================
+#-- leap, noleap, 360d
+CalendarType=noleap
+#-- Begin and end of Job
+#-- "YYYY-MM-DD"
+DateBegin=2001-01-01
+DateEnd=2005-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1Y
+#============================
+#-- PBS Class (required on brodie mono/multi)
+JobClass=mono
+#JobClass=multi
+#============================
+#-- Total Number of Processors
+#JobNumProcTot=4
+JobNumProcTot=1
+#============================
+#-- Run Options : 
+#JobRunOptions='"-np "${BATCH_NUM_PROC_TOT}"'
+JobRunOptions=''
+#============================
+# config.card configuration options :
+#R_INIT=/home/mancip/PROG/IPSL/FORCAGE_OL/INIT
+#R_BC=/u/rech/psl/rpsl035/IGCM/BC 
+#R_BC=/dmnfs/cont003/p86ipsl/IGCM/BC 
+#============================
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+OCE= (opa9, NEMO_v3)
+ICE= (lim2, LIM_2)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=nemo
+#D- For each component, Real name of executable
+OCE= (opa, nemo)
+ICE= ("", "")
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1999-12-30
+#D- Define restart simulation name
+RestartJobName=NL1
+#D- Path Server Group Login
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+#-- 1Y
+RebuildFrequency=NONE
+#D- Do we rebuild parallel output from archive
+RebuildFromArchive=true
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=NONE
+
+#========================================================================
+#D-- OCE -
+[OCE]
+WriteFrequency="1Y 1M 5D 1D"
+#WriteFrequency="5D"
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=1999-12-31
+# Define restart simulation name
+RestartJobName=NL1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- ICE -
+[ICE]
+WriteFrequency="5D"
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=1999-12-31
+# Define restart simulation name
+RestartJobName=NL1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make	(revision 1844)
@@ -0,0 +1,11580 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_bdy \
+     key_c1d \
+     key_coupled \
+     key_cpl_albedo \
+     key_cpl_carbon_cycle \
+     key_cpl_discharge \
+     key_cpl_ocevel \
+     key_cpl_rootexchg \
+     key_diaar5 \
+     key_diaeiv \
+     key_diagap \
+     key_diahdy \
+     key_diahth \
+     key_diainstant \
+     key_diaspr \
+     key_dimgout \
+     key_dtasal \
+     key_dtatem \
+     key_dynldf_c1d \
+     key_dynldf_c2d \
+     key_dynldf_c3d \
+     key_dynspg_exp \
+     key_dynspg_flt \
+     key_dynspg_ts \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_floats \
+     key_flx_bulk_monthly \
+     key_flx_core \
+     key_flx_forced_daily \
+     key_gyre \
+     key_iomput \
+     key_kppcustom \
+     key_kpplktb \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_mpp_dyndist \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_noslip_accurate \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_off_tra \
+     key_orca_lev10 \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_pomme_r025 \
+     key_top \
+     key_trabbc \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_tradmp \
+     key_traldf_ano \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trddyn \
+     key_trdmld \
+     key_trdtra \
+     key_trdvor \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zco \
+     key_zdfcst \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdfric \
+     key_zdftke \
+     key_zdftke_old \
+     key_zdftmx 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_oce.o)\
+		$(MODEL_LIB)(agrif_opa_interp.o)\
+		$(MODEL_LIB)(agrif_opa_sponge.o)\
+		$(MODEL_LIB)(agrif_opa_update.o)\
+		$(MODEL_LIB)(agrif_top_interp.o)\
+		$(MODEL_LIB)(agrif_top_sponge.o)\
+		$(MODEL_LIB)(agrif_top_update.o)\
+		$(MODEL_LIB)(agrif_user.o)\
+		$(MODEL_LIB)(albedo.o)\
+		$(MODEL_LIB)(bdy_oce.o)\
+		$(MODEL_LIB)(bdy_par.o)\
+		$(MODEL_LIB)(bdydta.o)\
+		$(MODEL_LIB)(bdydyn.o)\
+		$(MODEL_LIB)(bdyini.o)\
+		$(MODEL_LIB)(bdytides.o)\
+		$(MODEL_LIB)(bdytra.o)\
+		$(MODEL_LIB)(bdyvol.o)\
+		$(MODEL_LIB)(c1d.o)\
+		$(MODEL_LIB)(cla.o)\
+		$(MODEL_LIB)(cla_div.o)\
+		$(MODEL_LIB)(cla_dynspg.o)\
+		$(MODEL_LIB)(closea.o)\
+		$(MODEL_LIB)(cpl_oasis3.o)\
+		$(MODEL_LIB)(cpl_oasis4.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(diaar5.o)\
+		$(MODEL_LIB)(diadimg.o)\
+		$(MODEL_LIB)(diafwb.o)\
+		$(MODEL_LIB)(diagap.o)\
+		$(MODEL_LIB)(diahdy.o)\
+		$(MODEL_LIB)(diahth.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(diaptr.o)\
+		$(MODEL_LIB)(diawri.o)\
+		$(MODEL_LIB)(diawri_c1d.o)\
+		$(MODEL_LIB)(divcur.o)\
+		$(MODEL_LIB)(dom_ice_2.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(domhgr.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(domvvl.o)\
+		$(MODEL_LIB)(domwri.o)\
+		$(MODEL_LIB)(domzgr.o)\
+		$(MODEL_LIB)(dtasal.o)\
+		$(MODEL_LIB)(dtatem.o)\
+		$(MODEL_LIB)(dynadv.o)\
+		$(MODEL_LIB)(dynadv_cen2.o)\
+		$(MODEL_LIB)(dynadv_ubs.o)\
+		$(MODEL_LIB)(dynbfr.o)\
+		$(MODEL_LIB)(dyncor_c1d.o)\
+		$(MODEL_LIB)(dynhpg.o)\
+		$(MODEL_LIB)(dynkeg.o)\
+		$(MODEL_LIB)(dynldf.o)\
+		$(MODEL_LIB)(dynldf_bilap.o)\
+		$(MODEL_LIB)(dynldf_bilapg.o)\
+		$(MODEL_LIB)(dynldf_iso.o)\
+		$(MODEL_LIB)(dynldf_lap.o)\
+		$(MODEL_LIB)(dynnxt.o)\
+		$(MODEL_LIB)(dynnxt_c1d.o)\
+		$(MODEL_LIB)(dynspg.o)\
+		$(MODEL_LIB)(dynspg_exp.o)\
+		$(MODEL_LIB)(dynspg_flt.o)\
+		$(MODEL_LIB)(dynspg_oce.o)\
+		$(MODEL_LIB)(dynspg_ts.o)\
+		$(MODEL_LIB)(dynvor.o)\
+		$(MODEL_LIB)(dynzad.o)\
+		$(MODEL_LIB)(dynzdf.o)\
+		$(MODEL_LIB)(dynzdf_exp.o)\
+		$(MODEL_LIB)(dynzdf_imp.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(fldread.o)\
+		$(MODEL_LIB)(flo4rk.o)\
+		$(MODEL_LIB)(flo_oce.o)\
+		$(MODEL_LIB)(floats.o)\
+		$(MODEL_LIB)(floblk.o)\
+		$(MODEL_LIB)(flodom.o)\
+		$(MODEL_LIB)(flowri.o)\
+		$(MODEL_LIB)(geo2ocean.o)\
+		$(MODEL_LIB)(ice_2.o)\
+		$(MODEL_LIB)(iceini_2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(lbcnfd.o)\
+		$(MODEL_LIB)(ldfdyn.o)\
+		$(MODEL_LIB)(ldfdyn_oce.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(limadv_2.o)\
+		$(MODEL_LIB)(limdia_2.o)\
+		$(MODEL_LIB)(limdmp_2.o)\
+		$(MODEL_LIB)(limdyn_2.o)\
+		$(MODEL_LIB)(limhdf_2.o)\
+		$(MODEL_LIB)(limistate_2.o)\
+		$(MODEL_LIB)(limmsh_2.o)\
+		$(MODEL_LIB)(limrhg_2.o)\
+		$(MODEL_LIB)(limrst_2.o)\
+		$(MODEL_LIB)(limsbc_2.o)\
+		$(MODEL_LIB)(limtab_2.o)\
+		$(MODEL_LIB)(limthd_2.o)\
+		$(MODEL_LIB)(limthd_lac_2.o)\
+		$(MODEL_LIB)(limthd_zdf_2.o)\
+		$(MODEL_LIB)(limtrp_2.o)\
+		$(MODEL_LIB)(limwri_2.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oasis4_date.o)\
+		$(MODEL_LIB)(obc_oce.o)\
+		$(MODEL_LIB)(obc_par.o)\
+		$(MODEL_LIB)(obcdta.o)\
+		$(MODEL_LIB)(obcdyn.o)\
+		$(MODEL_LIB)(obcdyn_bt.o)\
+		$(MODEL_LIB)(obcfla.o)\
+		$(MODEL_LIB)(obcini.o)\
+		$(MODEL_LIB)(obcrad.o)\
+		$(MODEL_LIB)(obcrst.o)\
+		$(MODEL_LIB)(obctra.o)\
+		$(MODEL_LIB)(obcvol.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(par_ice_2.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(restart.o)\
+		$(MODEL_LIB)(sbc_ice.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcana.o)\
+		$(MODEL_LIB)(sbcblk_clio.o)\
+		$(MODEL_LIB)(sbcblk_core.o)\
+		$(MODEL_LIB)(sbccpl.o)\
+		$(MODEL_LIB)(sbcflx.o)\
+		$(MODEL_LIB)(sbcfwb.o)\
+		$(MODEL_LIB)(sbcice_if.o)\
+		$(MODEL_LIB)(sbcice_lim.o)\
+		$(MODEL_LIB)(sbcice_lim_2.o)\
+		$(MODEL_LIB)(sbcmod.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sbcssm.o)\
+		$(MODEL_LIB)(sbcssr.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(solmat.o)\
+		$(MODEL_LIB)(solpcg.o)\
+		$(MODEL_LIB)(solsor.o)\
+		$(MODEL_LIB)(solver.o)\
+		$(MODEL_LIB)(sshwzv.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(step_c1d.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(thd_ice_2.o)\
+		$(MODEL_LIB)(traadv.o)\
+		$(MODEL_LIB)(traadv_cen2.o)\
+		$(MODEL_LIB)(traadv_eiv.o)\
+		$(MODEL_LIB)(traadv_muscl.o)\
+		$(MODEL_LIB)(traadv_muscl2.o)\
+		$(MODEL_LIB)(traadv_qck.o)\
+		$(MODEL_LIB)(traadv_tvd.o)\
+		$(MODEL_LIB)(traadv_ubs.o)\
+		$(MODEL_LIB)(trabbc.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(tradmp.o)\
+		$(MODEL_LIB)(traldf.o)\
+		$(MODEL_LIB)(traldf_bilap.o)\
+		$(MODEL_LIB)(traldf_bilapg.o)\
+		$(MODEL_LIB)(traldf_iso.o)\
+		$(MODEL_LIB)(traldf_lap.o)\
+		$(MODEL_LIB)(tranpc.o)\
+		$(MODEL_LIB)(tranxt.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trasbc.o)\
+		$(MODEL_LIB)(trazdf.o)\
+		$(MODEL_LIB)(trazdf_exp.o)\
+		$(MODEL_LIB)(trazdf_imp.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trdicp.o)\
+		$(MODEL_LIB)(trdicp_oce.o)\
+		$(MODEL_LIB)(trdmld.o)\
+		$(MODEL_LIB)(trdmld_oce.o)\
+		$(MODEL_LIB)(trdmld_rst.o)\
+		$(MODEL_LIB)(trdmod.o)\
+		$(MODEL_LIB)(trdmod_oce.o)\
+		$(MODEL_LIB)(trdvor.o)\
+		$(MODEL_LIB)(trdvor_oce.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfbfr.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfevd.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfkpp.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zdfric.o)\
+		$(MODEL_LIB)(zdftke.o)\
+		$(MODEL_LIB)(zdftke_old.o)\
+		$(MODEL_LIB)(zdftmx.o)\
+		$(MODEL_LIB)(zpshde.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	agrif_oce.F90
+$(MODEL_LIB)(agrif_opa_interp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_interp.F90
+$(MODEL_LIB)(agrif_opa_sponge.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_sponge.F90
+$(MODEL_LIB)(agrif_opa_update.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	agrif_oce.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	sshwzv.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_update.F90
+$(MODEL_LIB)(agrif_top_interp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	sol_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_interp.F90
+$(MODEL_LIB)(agrif_top_sponge.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_sponge.F90
+$(MODEL_LIB)(agrif_top_update.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_update.F90
+$(MODEL_LIB)(agrif_user.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_oce.F90 \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfini.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(opa.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	agrif_oce.F90 \
+	agrif_opa_interp.F90 \
+	agrif_opa_sponge.F90 \
+	agrif_opa_update.F90 \
+	agrif_top_interp.F90 \
+	agrif_top_sponge.F90 \
+	agrif_top_update.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	opa.F90 \
+	par_oce.F90 \
+	sol_oce.F90 \
+	tradmp.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_user.F90
+$(MODEL_LIB)(albedo.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	in_out_manager.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	albedo.F90
+$(MODEL_LIB)(bdy_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	bdy_oce.F90
+$(MODEL_LIB)(bdy_par.o) :	\
+	KEY_CPP \
+	bdy_par.F90
+$(MODEL_LIB)(bdydta.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	bdydta.F90
+$(MODEL_LIB)(bdydyn.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdydyn.F90
+$(MODEL_LIB)(bdyini.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdyini.F90
+$(MODEL_LIB)(bdytides.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdytides.F90
+$(MODEL_LIB)(bdytra.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdytra.F90
+$(MODEL_LIB)(bdyvol.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	bdyvol.F90
+$(MODEL_LIB)(c1d.o) :	\
+	KEY_CPP \
+	c1d.F90
+$(MODEL_LIB)(cla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla.F90
+$(MODEL_LIB)(cla_div.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	cla_div.F90
+$(MODEL_LIB)(cla_dynspg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla_dynspg.F90
+$(MODEL_LIB)(closea.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	closea.F90
+$(MODEL_LIB)(cpl_oasis3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	cpl_oasis3.F90
+$(MODEL_LIB)(cpl_oasis4.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oasis4_date.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	cpl_oasis4.F90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(diaar5.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diaar5.F90
+$(MODEL_LIB)(diadimg.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diadimg.F90
+$(MODEL_LIB)(diafwb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	diafwb.F90
+$(MODEL_LIB)(diagap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diagap.F90
+$(MODEL_LIB)(diahdy.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahdy.F90
+$(MODEL_LIB)(diahth.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahth.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(diaptr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diaptr.F90
+$(MODEL_LIB)(diawri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	lib_mpp.F90 \
+	diawri_dimg.h90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri.F90
+$(MODEL_LIB)(diawri_c1d.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	trazdf_exp.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri_c1d.F90
+$(MODEL_LIB)(divcur.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	divcur.F90
+$(MODEL_LIB)(dom_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	dom_ice_2.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(domhgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	domhgr.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(domvvl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domvvl.F90
+$(MODEL_LIB)(domwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domwri.F90
+$(MODEL_LIB)(domzgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domzgr.F90
+$(MODEL_LIB)(dtasal.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtasal.F90
+$(MODEL_LIB)(dtatem.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtatem.F90
+$(MODEL_LIB)(dynadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv.F90
+$(MODEL_LIB)(dynadv_cen2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_cen2.F90
+$(MODEL_LIB)(dynadv_ubs.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_ubs.F90
+$(MODEL_LIB)(dynbfr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynbfr.F90
+$(MODEL_LIB)(dyncor_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dyncor_c1d.F90
+$(MODEL_LIB)(dynhpg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynhpg.F90
+$(MODEL_LIB)(dynkeg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynkeg.F90
+$(MODEL_LIB)(dynldf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf.F90
+$(MODEL_LIB)(dynldf_bilap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilap.F90
+$(MODEL_LIB)(dynldf_bilapg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilapg.F90
+$(MODEL_LIB)(dynldf_iso.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_iso.F90
+$(MODEL_LIB)(dynldf_lap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_lap.F90
+$(MODEL_LIB)(dynnxt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynnxt.F90
+$(MODEL_LIB)(dynnxt_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	KEY_CPP \
+	dynnxt_c1d.F90
+$(MODEL_LIB)(dynspg.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	in_out_manager.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg.F90
+$(MODEL_LIB)(dynspg_exp.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_exp.F90
+$(MODEL_LIB)(dynspg_flt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdydyn.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynspg_flt.F90
+$(MODEL_LIB)(dynspg_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dynspg_oce.F90
+$(MODEL_LIB)(dynspg_ts.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcfla.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_ts.F90
+$(MODEL_LIB)(dynvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynvor.F90
+$(MODEL_LIB)(dynzad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzad.F90
+$(MODEL_LIB)(dynzdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynzdf.F90
+$(MODEL_LIB)(dynzdf_exp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_exp.F90
+$(MODEL_LIB)(dynzdf_imp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_imp.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(fldread.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	fldread.F90
+$(MODEL_LIB)(flo4rk.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	KEY_CPP \
+	flo4rk.F90
+$(MODEL_LIB)(flo_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	flo_oce.F90
+$(MODEL_LIB)(floats.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	lib_mpp.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	floats.F90
+$(MODEL_LIB)(floblk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	floblk.F90
+$(MODEL_LIB)(flodom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flodom.F90
+$(MODEL_LIB)(flowri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flowri.F90
+$(MODEL_LIB)(geo2ocean.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	geo2ocean.F90
+$(MODEL_LIB)(ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	ice_2.F90
+$(MODEL_LIB)(iceini_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrst_2.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iceini_2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	c1d.F90 \
+	cla_dynspg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	daymod.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	restart.F90 \
+	zdf_oce.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(lbcnfd.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	lbcnfd.F90
+$(MODEL_LIB)(ldfdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	ldftra_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_antarctic.h90 \
+	ldfdyn_arctic.h90 \
+	ldfdyn_c1d.h90 \
+	ldfdyn_c2d.h90 \
+	ldfdyn_c3d.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldfdyn.F90
+$(MODEL_LIB)(ldfdyn_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldfdyn_oce.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(limadv_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limadv_2.F90
+$(MODEL_LIB)(limdia_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdia_2.F90
+$(MODEL_LIB)(limdmp_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	tradmp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdmp_2.F90
+$(MODEL_LIB)(limdyn_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limistate_2.F90 \
+	limrhg_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdyn_2.F90
+$(MODEL_LIB)(limhdf_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limhdf_2.F90
+$(MODEL_LIB)(limistate_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limistate_2.F90
+$(MODEL_LIB)(limmsh_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limmsh_2.F90
+$(MODEL_LIB)(limrhg_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limrhg_2.F90
+$(MODEL_LIB)(limrst_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	limrst_2.F90
+$(MODEL_LIB)(limsbc_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limsbc_2.F90
+$(MODEL_LIB)(limtab_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	KEY_CPP \
+	limtab_2.F90
+$(MODEL_LIB)(limthd_2.o) :	\
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limistate_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limthd_2.F90
+$(MODEL_LIB)(limthd_lac_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	ice_2.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_lac_2.F90
+$(MODEL_LIB)(limthd_zdf_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_zdf_2.F90
+$(MODEL_LIB)(limtrp_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limtrp_2.F90
+$(MODEL_LIB)(limwri_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	diadimg.F90 \
+	limwri_dimg_2.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	limwri_2.F90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oasis4_date.o) :	\
+	KEY_CPP \
+	oasis4_date.F90
+$(MODEL_LIB)(obc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	obc_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	obc_oce.F90
+$(MODEL_LIB)(obc_par.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	obc_par_EEL_R5.h90 \
+	obc_par_POMME_R025.h90 \
+	KEY_CPP \
+	obc_par.F90
+$(MODEL_LIB)(obcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	obcdta.F90
+$(MODEL_LIB)(obcdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn.F90
+$(MODEL_LIB)(obcdyn_bt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn_bt.F90
+$(MODEL_LIB)(obcfla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	obc_oce.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcfla.F90
+$(MODEL_LIB)(obcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcini.F90
+$(MODEL_LIB)(obcrad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcrad.F90
+$(MODEL_LIB)(obcrst.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcrst.F90
+$(MODEL_LIB)(obctra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obctra.F90
+$(MODEL_LIB)(obcvol.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcvol.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	cla.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynnxt_c1d.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(par_ice_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	par_ice_2.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	par_POMME_R025.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(restart.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	restart.F90
+$(MODEL_LIB)(sbc_ice.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_ice_2.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_ice.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcana.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcana.F90
+$(MODEL_LIB)(sbcblk_clio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_clio.F90
+$(MODEL_LIB)(sbcblk_core.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_core.F90
+$(MODEL_LIB)(sbccpl.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	phycst.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbccpl.F90
+$(MODEL_LIB)(sbcflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcflx.F90
+$(MODEL_LIB)(sbcfwb.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcfwb.F90
+$(MODEL_LIB)(sbcice_if.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcice_if.F90
+$(MODEL_LIB)(sbcice_lim.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim.F90
+$(MODEL_LIB)(sbcice_lim_2.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrhg_2.F90 \
+	limrst_2.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	tradmp.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim_2.F90
+$(MODEL_LIB)(sbcmod.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	albedo.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcmod.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sbcssm.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssm.F90
+$(MODEL_LIB)(sbcssr.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssr.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sol_oce.F90
+$(MODEL_LIB)(solmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	KEY_CPP \
+	solmat.F90
+$(MODEL_LIB)(solpcg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	solpcg.F90
+$(MODEL_LIB)(solsor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	solsor.F90
+$(MODEL_LIB)(solver.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	zdf_oce.F90 \
+	KEY_CPP \
+	solver.F90
+$(MODEL_LIB)(sshwzv.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sshwzv.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_oce.F90 \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	albedo.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynhpg.F90 \
+	dynkeg.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynzad.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obctra.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	traqsr.F90 \
+	trazdf.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	cla.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynspg.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbccpl.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(step_c1d.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obctra.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traqsr.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	daymod.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynnxt_c1d.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	stpctl.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	step_c1d.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(thd_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	thd_ice_2.F90
+$(MODEL_LIB)(traadv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv.F90
+$(MODEL_LIB)(traadv_cen2.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_cen2.F90
+$(MODEL_LIB)(traadv_eiv.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	diaar5.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_eiv.F90
+$(MODEL_LIB)(traadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl.F90
+$(MODEL_LIB)(traadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl2.F90
+$(MODEL_LIB)(traadv_qck.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_qck.F90
+$(MODEL_LIB)(traadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_tvd.F90
+$(MODEL_LIB)(traadv_ubs.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_ubs.F90
+$(MODEL_LIB)(trabbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trabbc.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	eosbn2.F90 \
+	iom.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	trabbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(tradmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	tradmp.F90
+$(MODEL_LIB)(traldf.o) :	\
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	trazdf.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf.F90
+$(MODEL_LIB)(traldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_bilap.F90
+$(MODEL_LIB)(traldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	KEY_CPP \
+	traldf_bilapg.F90
+$(MODEL_LIB)(traldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_iso.F90
+$(MODEL_LIB)(traldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_lap.F90
+$(MODEL_LIB)(tranpc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	tranpc.F90
+$(MODEL_LIB)(tranxt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obctra.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	tranxt.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traqsr.F90
+$(MODEL_LIB)(trasbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	traqsr.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trasbc.F90
+$(MODEL_LIB)(trazdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf.F90
+$(MODEL_LIB)(trazdf_exp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_exp.F90
+$(MODEL_LIB)(trazdf_imp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_imp.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trdicp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdicp.F90
+$(MODEL_LIB)(trdicp_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdicp_oce.F90
+$(MODEL_LIB)(trdmld.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld.F90
+$(MODEL_LIB)(trdmld_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdmld_oce.F90
+$(MODEL_LIB)(trdmld_rst.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	restart.F90 \
+	trdmod_oce.F90 \
+	KEY_CPP \
+	trdmld_rst.F90
+$(MODEL_LIB)(trdmod.o) :	\
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdmod.F90
+$(MODEL_LIB)(trdmod_oce.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	KEY_CPP \
+	trdmod_oce.F90
+$(MODEL_LIB)(trdvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdvor.F90
+$(MODEL_LIB)(trdvor_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdvor_oce.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfbfr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfbfr.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfevd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfevd.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	restart.F90 \
+	tranpc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfkpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	zdfkpp.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zdfric.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfric.F90
+$(MODEL_LIB)(zdftke.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke.F90
+$(MODEL_LIB)(zdftke_old.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke_old.F90
+$(MODEL_LIB)(zdftmx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftmx.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2 IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_tradmp key_trabbc key_zdftke key_zdfddm key_diahth key_iomput
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Header$
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,173 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 3:00:00                # Max total CPU time
+#-Q- sxnec #@$-lt 2:59:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 5Gb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 10800
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 5Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=5gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=3:01:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=3:01:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=7gb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=2:00:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      ORCA2_LIM configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories : 
+#- Input file storing 
+#-Q- sxnec R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8brodie R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- aix R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8mercure R_FORCING="/dmnfs10/cont003/p48ethe/FORCINGS/ORCA_R2/NEMO"
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/ORCA2_LIM_PISCES
+#- execution repository
+R_TMP=$TMPDIR         
+
+##-- define processus number : to change when running in mpp
+NB_PROC=1
+
+#################################
+# End of user modification
+#################################
+
+#--  define a fonction to get the input tarfile
+#-Q- sxnec Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8brodie Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- aix Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8mercure Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+#- Namelist for the configuration
+cp ${R_EXPER}/namelist_ice_lim2   namelist_ice 
+cp ${R_EXPER}/namelist            namelist
+cp ${R_EXPER}/namelist_top        namelist_top
+cp ${R_EXPER}/namelist_pisces     namelist_pisces
+cp ${R_EXPER}/kRGB61.txt          kRGB61.txt
+
+ls -alF
+
+#- Files for the configuration and ocean dynamics
+Rapatrie ${R_TMP} ORCA2_LIM_nemo_v3.2.tar
+Rapatrie ${R_TMP} INPUTS_INIT_v3.tar
+Rapatrie ${R_TMP} INPUTS_PISCES_v3.tar
+
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT *ocean.output ${R_SORTIE_OCE}/.
+$DPUT *solver.stat ${R_SORTIE_OCE}/.
+[ -f *mpp.output* ] && $DPUT *mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_grid_*.nc *_diad_T*.nc *_ptrc_T*.nc
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf}
+done
+#
+#- Save ice output files
+for file_netcdf in *icemod*
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf} 
+done
+$DPUT ice.evolu ${R_SORTIE_OCE}/ice.evolu 
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT ${restart} ${R_SORTIE_OCE}/${restart} 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/EMPave_old.dat
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/EMPave_old.dat	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/EMPave_old.dat	(revision 1844)
@@ -0,0 +1,1 @@
+                               0  0.0000000000000000E+00  0.0000000000000000E+00
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,697 @@
+<?xml version="1.0"?>
+<simulation> 
+  
+  <context id="nemo">
+    
+    <!-- $id$ -->
+
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+         
+      <!-- ptrc on T grid -->
+
+     <group id="ptrc_T" axis_ref="deptht" grid_ref="grid_T">  
+       <field id="DIC"      description="Dissolved inorganic Concentration"        unit="mol-C/L" />
+       <field id="Alkalini" description="Total Alkalinity Concentration"           unit="eq/L"    />
+       <field id="O2"       description="Oxygen Concentration"                     unit="mol-C/L" />
+       <field id="CaCO3"    description="Calcite Concentration"                    unit="mol-C/L" />
+       <field id="PO4"      description="Phosphate Concentration"                  unit="mol-C/L" />
+       <field id="POC"      description="Small organic carbon Concentration"       unit="mol-C/L" />
+       <field id="Si"       description="Silicate Concentration"                   unit="mol-C/L" />
+       <field id="PHY"      description="Nanophytoplankton Concentration"          unit="mol-C/L" />
+       <field id="ZOO"      description="Microzooplankton Concentration"           unit="mol-C/L" />
+       <field id="DOC"      description="Dissolved organic Concentration"          unit="mol-C/L" />
+       <field id="PHY2"     description="Diatoms Concentration"                    unit="mol-C/L" />
+       <field id="ZOO2"     description="Mesozooplankton Concentration"            unit="mol-C/L" />
+       <field id="BSi"      description="Diatoms Silicate Concentration"           unit="mol-C/L" />
+       <field id="Fer"      description="Dissolved Iron Concentration"             unit="mol-C/L" />
+       <field id="BFe"      description="Big iron particles Concentration"         unit="mol-C/L" />
+       <field id="GOC"      description="Big organic carbon Concentration"         unit="mol-C/L" />
+       <field id="SFe"      description="Small iron particles Concentration"       unit="mol-C/L" />
+       <field id="DFe"      description="Diatoms iron  Concentration"              unit="mol-C/L" />
+       <field id="DSi"      description="Sinking biogenic Silicate Concentration"  unit="mol-C/L" />
+       <field id="NFe"      description="Nano iron Concentration"                  unit="mol-C/L" />
+       <field id="NCHL"     description="Nano chlorophyl Concentration"            unit="mol-C/L" />
+       <field id="DCHL"     description="Diatoms chlorophyl Concentration"         unit="mol-C/L" />
+       <field id="NO3"      description="Nitrates Concentration"                   unit="mol-C/L" />
+       <field id="NH4"      description="Ammonium Concentration"                   unit="mol-C/L" />
+     </group>
+
+      <!-- diad on T grid -->
+
+     <group id="diad_T" axis_ref="none" grid_ref="grid_T">
+       <field id="PH"          description="PH"                                       unit="-"            axis_ref="deptht" />
+       <field id="CO3"         description="Bicarbonates"                             unit="mol/L"        axis_ref="deptht" />
+       <field id="CO3sat"      description="CO3 saturation"                           unit="mol/L"        axis_ref="deptht" />
+       <field id="PAR"         description="Photosynthetically Available Radiation"   unit="W/m2"         axis_ref="deptht" />
+       <field id="PPPHY"       description="Primary production of nanophyto"          unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPPHY2"      description="Primary production of diatoms"            unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPNEWN"      description="New Primary production of nanophyto"      unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPNEWD"      description="New Primary production of diatoms"        unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PBSi"        description="Primary production of Si diatoms"         unit="mol-Si/m3/s"  axis_ref="deptht" />
+       <field id="PFeN"        description="Primary production of nano iron"          unit="mol-Fe/m3/s"  axis_ref="deptht" />
+       <field id="PFeD"        description="Primary production of diatoms iron"       unit="mol-Fe/m3/s"  axis_ref="deptht" />
+       <field id="PCAL"        description="Calcite production"                       unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="DCAL"        description="Calcite dissolution"                      unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="GRAZ"        description="Grazing by zooplankton"                   unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="Nfix"        description="Nitrogen fixation at surface"             unit="mol-N/m2/s"      />
+       <field id="EPC100"      description="Export of carbon particles at 100 m"      unit="mol-C/m2/s"      />
+       <field id="EPFE100"     description="Export of biogenic iron at 100 m"         unit="mol-Fe/m2/s"     />
+       <field id="EPSI100"     description="Export of Silicate at 100 m"              unit="mol-Si/m2/s"     />
+       <field id="EPCAL100"    description="Export of Calcite at 100 m"               unit="mol-C/m2/s"      />
+       <field id="Cflx"        description="DIC flux"                                 unit="mol-C/m2/s"      />
+       <field id="Oflx"        description="Oxygen flux"                              unit="mol-C/m2/s" />
+       <field id="Kg"          description="Gas transfer"                             unit="mol-C/m2/s/uatm" />
+       <field id="Dpco2"       description="Delta CO2"                                unit="uatm" />
+       <field id="Dpo2"        description="Delta O2"                                 unit="uatm" />
+       <field id="Heup"        description="Euphotic layer depth"                     unit="m" />
+       <field id="Irondep"     description="Iron deposition"                          unit="mol-Fe/m2/s" />
+     </group>
+       
+    </field_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition >
+
+      <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
+      </group>
+      
+      <group id="2h" output_freq="7200"   output_level="10" enabled=".TRUE.">                      <!-- 2h files -->
+      </group>
+      
+      <group id="3h" output_freq="10800"  output_level="10" enabled=".TRUE.">                      <!-- 3h files -->
+      </group>
+      
+      <group id="4h" output_freq="14400"  output_level="10" enabled=".TRUE.">                      <!-- 4h files -->
+      </group>
+      
+      <group id="6h" output_freq="21600"  output_level="10" enabled=".TRUE.">                      <!-- 6h files -->
+      </group>
+      
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+
+    <!-- 
+............................................................................................................
+           example of 3 types of 1d files
+............................................................................................................
+    -->
+        <!-- automatic definition of the name based on id="1d_grid_T" 
+             => this name is used as the radical for all file names of this group
+             => add a suffix to be sure that all files names of this group are different   -->
+        <group id="1d_grid_T" name="auto" description="ocean T grid variables" >
+          <!-- mooring: automatic definition of the file name suffix based on id="0n180wT"  -->
+          <file id="0n180wT" name_suffix="auto" >
+            <group id="0n180wT" zoom_ref="0n180wT" >    <!-- group of variables sharing the same zoom -->
+              <field ref="toce" name="votemper"  />
+              <field ref="uoce" name="vozocrtx"  />     <!-- include a U-grid variable in the list => switch to T-grid -->
+            </group>
+          </file>
+          <!-- Equatorial section: automatic definition of the file name suffix based on id="EqT" -->
+          <file id="EqT" name_suffix="auto" >
+            <group id="EqT" zoom_ref="EqT" >
+              <field ref="toce" name="votemper"  />
+            </group>
+          </file>
+          <!-- global file with different operations on data   -->
+          <file id="global" >
+            <field ref="sst"    name="sst_1d_ave"                       />     <!-- mean -->
+            <field ref="sst"    name="sst_1d_max"  operation="t_max(X)" />     <!-- max -->
+          </file>
+        </group>
+
+      </group>
+      
+      <group id="3d" output_freq="259200" output_level="10" enabled=".TRUE.">                      <!-- 3d files -->
+      </group>
+      
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+
+	<file id="5d_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="toce"         name="votemper"  />
+	  <field ref="soce"         name="vosaline"  />
+	  <field ref="sst"          name="sosstsst"  />
+	  <field ref="sss"          name="sosaline"  />
+	  <field ref="ssh"          name="sossheig"  />
+	  <field ref="emp"          name="sowaflup"  />
+	  <field ref="qsr"          name="soshfldo"  />
+	  <field ref="emps"         name="sowaflcd"  />
+	  <field ref="qns+qsr"      name="sohefldo"  />
+	  <field ref="mldr10_1"     name="somxl010"  />
+	  <field ref="mldkz5"       name="somixhgt"  />
+	  <field ref="ice_cover"    name="soicecov"  />
+	  <field ref="wspd"         name="sowindsp"  />
+	  <field ref="qrp"          name="sohefldp"  />
+	  <field ref="erp"          name="sowafldp"  />
+	  <field ref="mlddzt"       name="sothedep"  />
+	  <field ref="20d"          name="so20chgt"  />
+	  <field ref="28d"          name="so28chgt"  />
+	  <field ref="hc300"        name="sohtc300"  />
+	  <field ref="ist_ipa"      name="soicetem"  />
+	  <field ref="icealb_cea"   name="soicealb"  />   
+	</file>
+	
+	<file id="5d_grid_U" name="auto" description="ocean U grid variables" >
+	  <field ref="uoce"         name="vozocrtx"  />
+	  <field ref="uoce_eiv"     name="vozoeivu"  />
+	  <field ref="utau"         name="sozotaux"  />
+	</file>
+	
+	<file id="5d_grid_V" name="auto" description="ocean V grid variables" >
+	  <field ref="voce"         name="vomecrty"  />
+	  <field ref="voce_eiv"     name="vomeeivv"  />
+	  <field ref="vtau"         name="sometauy"  />
+	</file>
+	
+	<file id="5d_grid_W" name="auto" description="ocean W grid variables" >
+	  <field ref="woce"         name="vovecrtz" />
+	  <field ref="woce_eiv"     name="voveeivw" />
+	  <field ref="avt"          name="votkeavt" />
+	  <field ref="avt_evd"      name="votkeevd" />
+	  <field ref="avm"          name="votkeavm" />
+	  <field ref="avm_evd"      name="votkeevm" />
+	  <field ref="avs"          name="voddmavs" />
+	  <field ref="aht2d"        name="soleahtw" />
+	  <field ref="aht2d_eiv"    name="soleaeiw" />
+	</file>
+	
+	<file id="5d_icemod" name="auto" description="ice variables" >
+	  <field ref="ice_pres"                     />
+	  <field ref="snowthic_cea" name="isnowthi" />
+	  <field ref="icethic_cea"  name="iicethic" />
+	  <field ref="iceprod_cea"  name="iiceprod" />
+	  <field ref="ist_ipa"      name="iicetemp" />
+	  <field ref="ioceflxb"     name="ioceflxb" />
+	  <field ref="uice_ipa"     name="iicevelu" />
+	  <field ref="vice_ipa"     name="iicevelv" />
+	  <field ref="utau_ice"     name="iicestru" />
+	  <field ref="vtau_ice"     name="iicestrv" />
+	  <field ref="qsr_io_cea"   name="iicesflx" />
+	  <field ref="qns_io_cea"   name="iicenflx" />
+	  <field ref="snowpre"      name="isnowpre" />
+	</file>
+
+       <file id="5d_diad_T" name="auto" description="additional pisces diagnostics" >
+          <field ref="Cflx"     />
+          <field ref="Oflx"     />
+          <field ref="Dpco2"    />
+          <field ref="Dpo2"     />
+          <field ref="Heup"     />
+       </file>
+
+      </group>
+      
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+
+	<file id="1m_grid_T" name="auto" description="ocean T grid variables" >
+	  <field ref="sst"          name="sosstsst"  />
+	</file>   
+
+        <file id="1m_ptrc_T" name="auto" description="pisces sms variables" >
+          <field ref="DIC"      />
+          <field ref="Alkalini" />
+          <field ref="O2"       />
+          <field ref="NCHL"     />
+          <field ref="DCHL"     />
+          <field ref="DOC"      />
+          <field ref="Fer"      />
+          <field ref="NO3"      />
+       </file>
+	
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+
+        <file id="1y_grid_T" name="auto" description="ocean T grid variables" >
+          <field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+        </file>
+
+        <file id="1y_ptrc_T" name="auto" description="pisces sms variables" >
+          <field ref="DIC"      />
+          <field ref="Alkalini" />
+          <field ref="O2"       />
+          <field ref="CaCO3"    />
+          <field ref="PO4"      />
+          <field ref="POC"      />
+          <field ref="Si"       />
+          <field ref="PHY"      />
+          <field ref="ZOO"      />
+          <field ref="DOC"      />
+          <field ref="PHY2"     />
+          <field ref="ZOO2"     />
+          <field ref="BSi"      />
+          <field ref="Fer"      />
+          <field ref="BFe"      />
+          <field ref="GOC"      />
+          <field ref="SFe"      />
+          <field ref="DFe"      />
+          <field ref="DSi"      />
+          <field ref="NFe"      />
+          <field ref="NCHL"     />
+          <field ref="DCHL"     />
+          <field ref="NO3"      />
+          <field ref="NH4"      />
+       </file>
+
+       <file id="1y_diad_T" name="auto" description="additional pisces diagnostics" >
+          <field ref="PH"       />
+          <field ref="CO3"      />
+          <field ref="CO3sat"   />
+          <field ref="PAR"      />
+          <field ref="PPPHY"    />
+          <field ref="PPPHY2"   />
+          <field ref="PPNEWN"   />
+          <field ref="PPNEWD"   />
+          <field ref="PBSi"     />
+          <field ref="PFeN"     />
+          <field ref="PFeD"     />
+          <field ref="PCAL"     />
+          <field ref="DCAL"     />
+          <field ref="GRAZ"     />
+          <field ref="EPC100"   />
+          <field ref="EPFE100"  />
+          <field ref="EPSI100"  />
+          <field ref="EPCAL100" />
+          <field ref="Cflx"     />
+          <field ref="Oflx"     />
+          <field ref="Kg"       />
+          <field ref="Dpco2"    />
+          <field ref="Dpo2"     />
+          <field ref="Heup"     />
+          <field ref="Irondep"  />
+          <field ref="Nfix"     />
+       </file>
+
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+
+    </file_definition>
+    
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <axis_definition>  
+      <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+      <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+      <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+      <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+      <axis id="none" description="axe non defini" unit="none" size="1" />
+    </axis_definition> 
+    
+    <grid_definition>
+    <!--   Eq section   -->
+        <zoom id="EqT" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+    <!--   TAO   -->
+      <!--   137e   -->
+        <zoom id="2n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n137eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   147e   -->
+        <zoom id="0n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n147eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   156e   -->
+        <zoom id="5s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n156eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   165e   -->
+        <zoom id="8s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n165eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   180w   -->
+        <zoom id="8s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n180wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   170w   -->
+        <zoom id="8s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n170wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   155w   -->
+        <zoom id="8s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n155wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   140w   -->
+        <zoom id="8s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n140wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   125w   -->
+        <zoom id="8s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n125wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   110w   -->
+        <zoom id="8s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n110wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95w   -->
+        <zoom id="8s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2s95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="2n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n95wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   RAMA   -->
+      <!--   55e   -->
+        <zoom id="16s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12s55eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4s55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5s55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5n55eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n55eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   65e   -->
+        <zoom id="15n65eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   67e   -->
+        <zoom id="16s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12s67eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4s67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5s67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5n67eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n67eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   80.5e   -->
+        <zoom id="16s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12s80.5eT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4s80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5s80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5n80.5eT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n80.5eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   90e   -->
+        <zoom id="1.5s90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="1.5n90eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n90eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="15n90eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   95e   -->
+        <zoom id="16s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12s95eT"    ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="5s95eT"     ibegin="0000" jbegin="0000" ni="1" nj="1" />
+    <!--   PIRATA   -->
+      <!--   38w-30w   -->
+        <zoom id="19s34wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="14s32wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8s30wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n35wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="8n38wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="15n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="20n38wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   23w   -->
+        <zoom id="0n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="4n23wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="12n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="21n23wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   10w   -->
+        <zoom id="10s10wT" ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="6s10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+        <zoom id="0n10wT"  ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      <!--   0e   -->
+        <zoom id="0n0eT"   ibegin="0000" jbegin="0000" ni="1" nj="1" />
+      </grid>
+
+      <grid id="grid_U" description="grid U" >
+    <!--   Eq section   -->
+        <zoom id="EqU" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="grid_V" description="grid V" >
+      </grid>
+
+      <grid id="grid_W" description="grid W" >
+    <!--   Eq section   -->
+        <zoom id="EqW" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </grid>
+
+      <grid id="scalarpoint" description="scalar" >
+        <zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+      </grid>
+
+
+    </grid_definition>    
+    
+  </context>
+  
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/kRGB61.txt
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/kRGB61.txt	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/kRGB61.txt	(revision 1844)
@@ -0,0 +1,61 @@
+  0.010    0.01618   0.07464   0.37807
+  0.011    0.01654   0.07480   0.37823
+  0.013    0.01693   0.07499   0.37840
+  0.014    0.01736   0.07518   0.37859
+  0.016    0.01782   0.07539   0.37879
+  0.018    0.01831   0.07562   0.37900
+  0.020    0.01885   0.07586   0.37923
+  0.022    0.01943   0.07613   0.37948
+  0.025    0.02005   0.07641   0.37976
+  0.028    0.02073   0.07672   0.38005
+  0.032    0.02146   0.07705   0.38036
+  0.035    0.02224   0.07741   0.38070
+  0.040    0.02310   0.07780   0.38107
+  0.045    0.02402   0.07821   0.38146
+  0.050    0.02501   0.07866   0.38189
+  0.056    0.02608   0.07914   0.38235
+  0.063    0.02724   0.07967   0.38285
+  0.071    0.02849   0.08023   0.38338
+  0.079    0.02984   0.08083   0.38396
+  0.089    0.03131   0.08149   0.38458
+  0.100    0.03288   0.08219   0.38526
+  0.112    0.03459   0.08295   0.38598
+  0.126    0.03643   0.08377   0.38676
+  0.141    0.03842   0.08466   0.38761
+  0.158    0.04057   0.08561   0.38852
+  0.178    0.04289   0.08664   0.38950
+  0.200    0.04540   0.08775   0.39056
+  0.224    0.04811   0.08894   0.39171
+  0.251    0.05103   0.09023   0.39294
+  0.282    0.05420   0.09162   0.39428
+  0.316    0.05761   0.09312   0.39572
+  0.355    0.06130   0.09474   0.39727
+  0.398    0.06529   0.09649   0.39894
+  0.447    0.06959   0.09837   0.40075
+  0.501    0.07424   0.10040   0.40270
+  0.562    0.07927   0.10259   0.40480
+  0.631    0.08470   0.10495   0.40707
+  0.708    0.09056   0.10749   0.40952
+  0.794    0.09690   0.11024   0.41216
+  0.891    0.10374   0.11320   0.41502
+  1.000    0.11114   0.11639   0.41809
+  1.122    0.11912   0.11984   0.42142
+  1.259    0.12775   0.12356   0.42500
+  1.413    0.13707   0.12757   0.42887
+  1.585    0.14715   0.13189   0.43304
+  1.778    0.15803   0.13655   0.43754
+  1.995    0.16978   0.14158   0.44240
+  2.239    0.18248   0.14701   0.44765
+  2.512    0.19620   0.15286   0.45331
+  2.818    0.21102   0.15918   0.45942
+  3.162    0.22703   0.16599   0.46601
+  3.548    0.24433   0.17334   0.47313
+  3.981    0.26301   0.18126   0.48080
+  4.467    0.28320   0.18981   0.48909
+  5.012    0.30502   0.19903   0.49803
+  5.623    0.32858   0.20898   0.50768
+  6.310    0.35404   0.21971   0.51810
+  7.079    0.38154   0.23129   0.52934
+  7.943    0.41125   0.24378   0.54147
+  8.912    0.44336   0.25725   0.55457
+ 10.000    0.47804   0.27178   0.56870
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist	(revision 1844)
@@ -0,0 +1,707 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      =  "ORCA2P" !  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =    5475   !  last  time step (std 5475)
+   nn_date0    =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =       0   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =    5475   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =    5475   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .false.   !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea   =    0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=   20.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 5760.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   64      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 28800.          !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 28800.          !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .false.   !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .true.    !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 2         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .true.    !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 3         !  FreshWater Budget: =0 unchecked 
+                           !                     =1 global mean of e-p-r set to zero at each time step 
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   0       !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.5     !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_qns0     =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u10_core'   ,       -1          , 'u10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'U1'
+   sn_wndj     = 'v10_core'   ,       -1          , 'v10'      ,    .true.      , .true.  , 'yearly'  ,'bicubic_weights_orca2.nc' , 'V1'
+   sn_qsr      = 'qsw_core'   ,       -1          , 'swdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_qlw      = 'qlw_core'   ,       -1          , 'lwdn'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tair     = 't2_core'    ,       -1          , 't2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_humi     = 'q2_core'    ,       -1          , 'q2'       ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_prec     = 'precip_core',       -1          , 'precip'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_snow     = 'snow_core'  ,       -1          , 'snow'     ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+   sn_tdif     = 'taudif_core',       24          , 'taudif'   ,    .true.      , .true.  , 'yearly'  ,'bilinear_weights_orca2.nc', ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .true.    !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+                                       ! send
+cn_snd_temperature= 'weighted oce and ice'  ! 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_albedo     = 'weighted ice'          ! 'none' 'weighted ice' 'mixed oce-ice'
+cn_snd_thickness  = 'none'                  ! 'none' 'weighted ice and snow'
+cn_snd_crt_nature = 'none'                  ! 'none' 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_crt_refere = 'spherical'             ! 'spherical' 'cartesian'
+cn_snd_crt_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_snd_crt_grid   = 'T'                     ! 'T'
+                                       ! receive
+cn_rcv_w10m       = 'coupled'               ! 'none' 'coupled'
+cn_rcv_taumod     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_tau_nature = 'oce only'              ! 'oce only' 'oce and ice' 'mixed oce-ice'
+cn_rcv_tau_refere = 'cartesian'             ! 'spherical' 'cartesian'
+cn_rcv_tau_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_rcv_tau_grid   = 'U,V'                   ! 'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+cn_rcv_dqnsdt     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_qsr        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_qns        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_emp        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_rnf        = 'coupled'               ! 'coupled' 'climato' 'mixed'
+cn_rcv_cal        = 'coupled'               ! 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl_co2   !   coupled ocean/biogeo/atmosphere model            ("key_cpl_carbon_cycle")
+!-----------------------------------------------------------------------
+cn_snd_co2        = 'coupled'         ! send    :  'none' 'coupled'
+cn_rcv_co2        = 'coupled'         ! receive : 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_data'   ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     2     !  add a damping     term in the surface freshwater flux (=2) 
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .true.  !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =    1.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 3000.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   = 3000.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    1      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+   ln_bfr2d    =   .false. !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    0.001  !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =  2000.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =  2000.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   -1      !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .true.   !  laplacian operator         
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = 40000.         !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =     0.         !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    0      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =  60.      !  coef. of the surface input of tke
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.001   !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.01    !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    300    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .true.     !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .true.     !  Add zonal means and meridional stream functions
+   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   ln_ptrcomp = .true.     !  Add decomposition : overturning 
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim2
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim2	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim2	(revision 1844)
@@ -0,0 +1,134 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM2 :  1 - dynamics/advection/thermo          (namicerun)
+!! namelists    2 - ice intialisation                  (namiceini)
+!!              3 - ice dynamic                        (namicedyn)
+!!              5 - ice advection                      (namicetrp)
+!!              6 - thermodynamic                      (namicethd)
+!!              7 - ice salinity                       (namicesal)
+!!              8 - mechanical redistribution of ice   (namiceitdme)
+!!              3 - ice diagnostics                    (namicedia)
+!!              9 - ice outputs                        (namiceout)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   cn_icerst_in  = "restart_ice_in"   !  suffix of ice restart name (input)
+   cn_icerst_out = "restart_ice"      !  suffix of ice restart name (output)
+   ln_limdyn   = .true.    !  ice dynamics (T) or thermodynamics only (F)
+   ln_limdmp   = .false.   !  restoring ice thickness and fraction leads (T) or not (F)
+   acrit       = 1.0e-06   , 1.0e-06   ! minimum fraction for leads in the Northern (Southern) Hemisphere
+   hsndif      =  0.0      !  computation of temperature in snow (=0.0) or not
+   hicdif      =  0.0      !  computation of temperature in ice  (=0.0) or not (=9999.0)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+   ln_limini   = .false.   !  read the ice initial state in the file 'Ice_initialization.nc' (T) or not (F)
+   ttest       =  2.0      !  threshold water temperature for initial sea ice
+   hninn       =  0.5      !  initial snow thickness in the north
+   hginn       =  3.0      !  initial ice  thickness in the north
+   alinn       =  0.05     !  initial leads area     in the north
+   hnins       =  0.1      !  same  three parameter  in the south
+   hgins       =  1.0      !        "                 "     south   
+   alins       =  0.1      !        "                 "     south
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+   epsd        =   1.0e-20 !  tolerance parameter
+   alpha       =   0.5     !  coefficient for semi-implicit coriolis
+   dm          =   0.6e+03 !  diffusion constant for dynamics
+   nbiter      =   1       !  number of sub-time steps for relaxation
+   nbitdr      = 100       !  maximum number of iterations for relaxation
+   om          =   0.5     !  relaxation constant 
+   resl        =   5.0e-05 !  maximum value for the residual of relaxation
+   cw          =   5.0e-03 !  drag coefficient for oceanic stress
+   angvg       =   0.0     !  turning angle for oceanic stress
+   pstar       =   1.0e+04 !  1st bulk-rheology parameter
+   c_rhg       =  20.0     !  2nd bulk-rhelogy parameter
+   etamn       =   0.0e+07 !  minimun value for viscosity
+   creepl      =   2.0e-08 !  creep limit
+   ecc         =   2.0     !  eccentricity of the elliptical yield curve
+   ahi0        = 350.e0    !  horizontal eddy diffusivity coefficient for sea-ice [m2/s]
+/
+!-----------------------------------------------------------------------
+&namicetrp     !   ice transport
+!-----------------------------------------------------------------------
+   bound       =   0.      !  boundary conditions (=0.0 no-slip, =1.0 free-slip)
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+!  hmelt       : maximum melting at the bottom
+!  hiccrit(1/2): ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+!                caution 1.0, 1.0 best value to be used!!! (gilles G.)
+!  hicmin      : ice thickness corr. to max. energy stored in brine pocket
+!  hiclim      : minimum ice thickness
+!  amax        : maximum lead fraction
+!  swiqst      : energy stored in brine pocket (=1) or not (=0)	
+!  sbeta       : numerical caracteritic of the scheme for diffusion in ice
+!               Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+!  parlat      : percentage of energy used for lateral ablation
+!  hakspl      : slope of distr. for Hakkinen-Mellor's lateral melting
+!  hibspl      : slope of distribution for Hibler's lateral melting
+!  exld        : exponent for leads-closure rate
+!  hakdif      : coefficient for diffusions of ice and snow
+!  thth         : threshold thickness for comp. of eq. thermal conductivity
+!  hnzst       : thickness of the surf. layer in temp. computation
+!  parsub      : switch for snow sublimation or not
+!  alphs       : coefficient for snow density when snow ice formation
+! 
+   hmelt       = -0.15     !  maximum melting at the bottom
+   hiccrit     = 0.3 , 0.3 !  ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+   hicmin      = 0.2       !  ice thickness corr. to max. energy stored in brine pocket
+   hiclim      = 0.05      !  minimum ice thickness
+   amax        = 0.999     !  maximum lead fraction
+   swiqst      = 1.        !  energy stored in brine pocket (=1) or not (=0)	
+   sbeta       = 1.        !  numerical caracteritic of the scheme for diffusion in ice
+                           !        Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+   parlat      = 0.0       !  percentage of energy used for lateral ablation
+   hakspl      = 0.5       !  slope of distr. for Hakkinen-Mellor's lateral melting
+   hibspl      = 0.5       !  slope of distribution for Hibler's lateral melting
+   exld        = 2.0       !  exponent for leads-closure rate
+   hakdif      = 1.0       !  coefficient for diffusions of ice and snow
+   thth        = 0.2       !  threshold thickness for comp. of eq. thermal conductivity
+   hnzst       = 0.1       !  thickness of the surf. layer in temp. computation
+   parsub      = 1.0       !  switch for snow sublimation or not
+   alphs       = 1.0       !  coefficient for snow density when snow ice formation
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+   fmtinf      ='1PE13.5 ' !  format of the output values
+   nfrinf      = 4         !  number of variables written in one line
+   ntmoy       = 1         !  instantaneous values of ice evolution or averaging
+   ninfo       = 1         !  frequency of ouputs on file ice_evolu in case of averaging
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namiceout     !   parameters for outputs
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   noumef      =   19      !  number of fields
+!
+!           !         title of the field           !  name     !   units   !  save  ! multipl. ! additive !
+!           !                                      !           !           ! or not !  factor  !  factor  !
+   field_1  = 'Snow thickness                     ', 'isnowthi', 'm       ',    1   ,  1.0     ,    0.0
+   field_2  = 'Ice thickness                      ', 'iicethic', 'm       ',    1   ,  1.0     ,    0.0
+   field_3  = 'Ice produced                       ', 'iiceprod', 'm/kt    ',    1   ,  1.0     ,    0.0
+   field_4  = 'Ice concentration                  ', 'ileadfra', '%       ',    1   , -1.0     ,    1.0
+   field_5  = 'Ice temperature                    ', 'iicetemp', 'C       ',    1   ,  1.0     , -273.15
+   field_6  = 'Oceanic flux at the ice base       ', 'ioceflxb', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_7  = 'Ice velocity u                     ', 'iicevelu', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_8  = 'Ice velocity v                     ', 'iicevelv', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_9  = 'Sea surface temperature            ', 'isstempe', 'C       ',    1   ,  1.0     , -273.15
+   field_10 = 'Sea surface salinity               ', 'isssalin', 'PSU     ',    1   ,  1.0     ,    0.0
+   field_11 = 'Total flux at ocean surface        ', 'iocetflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_12 = 'Solar flux at ocean surface        ', 'iocesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_13 = 'Non-solar flux at ocean surface    ', 'iocwnsfl', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_14 = 'Salt flux at ocean surface         ', 'iocesafl', 'kg/m2/kt',    1   ,  1.0     ,    0.0
+   field_15 = 'Wind stress u                      ', 'iocestru', 'Pa      ',    1   ,  1.0     ,    0.0
+   field_16 = 'Wind stress v                      ', 'iocestrv', 'Pa      ',    1   ,  1.0     ,    0.0 
+   field_17 = 'Solar flux at ice/ocean surface    ', 'iicesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_18 = 'Non-solar flux at ice/ocean surface', 'iicenflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_19 = 'Snow precipitation                 ', 'isnowpre', 'kg/day  ',    1   ,  1.0     ,    0.0
+/      
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim3
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim3	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_ice_lim3	(revision 1844)
@@ -0,0 +1,193 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM3 :  1 - dynamics/advection/thermo          (namicerun)
+!! namelists    2 - ice intialisation                  (namiceini)
+!!              3 - ice dynamic                        (namicedyn)
+!!              4 - ice advection                      (namicetrp)
+!!              5 - thermodynamic                      (namicethd)
+!!              6 - ice salinity                       (namicesal)
+!!              7 - mechanical redistribution of ice   (namiceitdme)
+!!              8 - ice diagnostics                    (namicedia)
+!!              9 - ice outputs                        (namiceout)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   cn_icerst_in  = "restart_ice_in"   !  suffix of ice restart name (input)
+   cn_icerst_out = "restart_ice"      !  suffix of ice restart name (output)
+   ln_limdyn   = .true.    !  ice dynamics (T) or thermodynamics only (F)
+   acrit       =  1.0e-02 , 1.0e-02  !  minimum fraction for leads in the Northern (Southern) Hemisphere
+   hsndif      =  0.0      !  computation of temperature in snow (=0.0) or not
+   hicdif      =  0.0      !  computation of temperature in ice  (=0.0) or not (=9999.0)
+   cai         =  1.40e-3  !  atmospheric drag over sea ice
+   cao         =  1.00e-3  !  atmospheric drag over ocean
+   ln_nicep    = .false.   !  Ice points output for debug (yes or no)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+   ttest       =  2.0      !  threshold water temperature for initial sea ice
+   hninn       =  0.3      !  initial snow thickness in the north
+   hnins       =  0.1      !        "            "          south
+   hginn_u     =  3.50     !  initial undeformed ice thickness in the north
+   hgins_u     =  1.0      !        "            "              "     south
+   aginn_u     =  0.95     !  initial undeformed ice concentration in the north
+   agins_u     =  0.9      !        "            "              "         south
+   hginn_d     =  0.0      !  initial  deformed  ice thickness     in the north
+   hgins_d     =  0.0      !  
+   aginn_d     =  0.00     !  initial  deformed  ice concentration in the north
+   agins_d     =  0.00     !        "            "              "         south
+   sinn        =  6.301    !  initial salinity in the north
+   sins        =  6.301    !        "            "    south
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+   epsd        =   1.0e-20 !  tolerance parameter
+   alpha       =   0.5     !  coefficient for semi-implicit coriolis
+   dm          =   0.6e+03 !  diffusion constant for dynamics
+   nbiter      =   1       !  number of sub-time steps for relaxation
+   nbitdr      = 500       !  maximum number of iterations for relaxation
+   om          =   0.5     !  relaxation constant 
+   resl        =   5.0e-05 !  maximum value for the residual of relaxation
+   cw          =   5.0e-03 !  drag coefficient for oceanic stress
+   angvg       =   0.0     !  turning angle for oceanic stress
+   pstar       =   4.0e+04 !  1st bulk-rheology parameter
+   c_rhg       =  20.0     !  2nd bulk-rhelogy parameter
+   etamn       =   0.0e+07 !  minimun value for viscosity
+   creepl      =   1.0e-12 !  creep limit
+   ecc         =   2.0     !  eccentricity of the elliptical yield curve
+   ahi0        = 350.e0    !  horizontal eddy diffusivity coefficient for sea-ice [m2/s]
+   nevp        = 300       !  number of iterations for subcycling in EVP, SB, 400
+   telast      =9600.0     !  timescale for elastic waves, SB, 720.0
+   alphaevp    =   1.0     !  coefficient for the solution of internal ice stresses
+/
+!-----------------------------------------------------------------------
+&namicetrp     !   ice transport
+!-----------------------------------------------------------------------
+   bound       =   0.      !  boundary conditions (=0.0 no-slip, =1.0 free-slip)
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+   hmelt       = -0.15     !  maximum melting at the bottom
+   hiccrit     = 0.1 , 0.1 !  ice thickness for lateral accretion in the Northern (Southern) Hemisphere
+                           !         caution 1.0, 1.0 best value to be used!!! (gilles G.)  ????
+   fraz_swi    = 0.0       !  use of frazil ice collection thickness in function of wind (1.0) or not (0.0)
+   maxfrazb    = 0.0       !  maximum portion of frazil ice collecting at the ice bottom
+   vfrazb      = 0.4166667 !  thresold drift speed for frazil ice collecting at the ice bottom
+   Cfrazb      = 5.0       !  squeezing coefficient for frazil ice collecting at the ice bottom
+   hicmin      = 0.2       !  ice thickness corr. to max. energy stored in brine pocket
+   hiclim      = 0.10      !  minimum ice thickness
+   amax        = 0.999     !  maximum lead fraction
+   sbeta       = 1.        !  numerical caracteritic of the scheme for diffusion in ice
+                           !        Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)
+   parlat      = 0.0       !  percentage of energy used for lateral ablation
+   hakspl      = 0.25      !  slope of distr. for Hakkinen-Mellor's lateral melting
+   hibspl      = 0.5       !  slope of distribution for Hibler's lateral melting
+   exld        = 2.0       !  exponent for leads-closure rate
+   hakdif      = 1.0       !  coefficient for diffusions of ice and snow
+   thth        = 0.2       !  threshold thickness for comp. of eq. thermal conductivity
+   hnzst       = 0.1       !  thickness of the surf. layer in temp. computation
+   parsub      = 1.0       !  switch for snow sublimation or not
+   alphs       = 1.0       !  coefficient for snow density when snow ice formation
+   betas       = 0.6       !  exponent in lead-ice fractionation of snow precipitation 0.66
+                           !        betas = 1 -> equipartition, betas < 1 -> more on leads
+   kappa_i     = 1.0       !  extinction radiation parameter in sea ice (1.0)
+   nconv_i_thd = 50        !  maximal number of iterations for heat diffusion computation
+   maxer_i_thd = 0.0001    !  maximal error in temperature for heat diffusion computation
+   thcon_i_swi = 1         !  switch for computation of thermal conductivity in the ice
+                           !        (0) Untersteiner (1964), (1) Pringle et al. (2007)
+/
+!-----------------------------------------------------------------------
+&namicesal     !   ice salinity
+!-----------------------------------------------------------------------
+   num_sal     =  2        !  salinity option: 1 -> S = bulk_sal
+                           !                   2 -> S = S(z,t) with a simple parameterization
+                           !                   3 -> S = S(z) profile of Scwharzacher [1959]
+                           !                   4 -> S = S(h) Cox and Weeks [1974]
+   bulk_sal    =  4.0      !  if 1 is used, it represents the ice salinity
+   sal_G       =  5.00     !  restoring salinity for GD
+   time_G      =  1.728e+6 !  restoring time for GD
+   sal_F       =  2.00     !  restoring salinity for flushing
+   time_F      =  8.640e+5 !  restoring time for flushing
+   s_i_max     = 20.0      !  Maximum salinity 
+   s_i_min     =  0.1      !  Minimum tolerated ice salinity
+   s_i_0       =  3.5      !  1st salinity for salinity profile
+   s_i_1       =  4.5      !  2nd salinity for salinity profile
+/
+!-----------------------------------------------------------------------
+&namiceitdme   !   parameters for mechanical redistribution of ice 
+!-----------------------------------------------------------------------
+   ridge_scheme_swi = 0      !  which ridging scheme using (1=Rothrock,else=Hibler79)
+   Cs               =   0.50 !  shearing energy contribution to ridging
+   Cf               =  17.0  !  ratio of ridging work to PE change in ridging
+   fsnowrdg         =   0.5  !  snow fraction that survives in ridging
+   fsnowrft         =   0.5  !  snow fraction that survives in rafting
+   Gstar            =   0.15 !  fractional area of thin ice being ridged
+   astar            =   0.05 !  equivalent of gstar (0.05 for TH75 and 0.03 for weaker ice)
+   Hstar            = 100.0  !  parameter determining the maximum thickness of ridged ice
+   raftswi          =   1    !  rafting or not
+   hparmeter        =   0.75 !  threshold thickness for rafting or not
+   Craft            =   5.0  !  coefficient used in the rafting function
+   ridge_por        =   0.3  !  initial porosity of the ridged ice (typically 0.30)
+   sal_max_ridge    =  15.0  !  maximum ridged ice salinity
+   partfun_swi      =   1    !  participation function linear, TH75 (0) or exponential Letal07 (1)
+   transfun_swi     =   0    !  transfer function uniform of H80 (0) or exponential Letal07 (1)
+   brinstren_swi    =   0    !  (1) use brine volume to diminish ice strength
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+   fmtinf      ='1PE13.5 ' !  format of the output values
+   nfrinf      = 4         !  number of variables written in one line
+   ntmoy       = 1         !  instantaneous values of ice evolution or averaging
+   ninfo       = 1         !  frequency of ouputs on file ice_evolu in case of averaging
+/
+!-----------------------------------------------------------------------
+&namiceout     !   parameters for outputs
+!-----------------------------------------------------------------------
+   noumef      =   37      !  number of fields
+   add_diag_swi=    1      !  1 -> diagnose distribution in thickness space
+                           !  0 -> only simple diagnostics
+!
+!           !         title of the field           !  name     !   units   !  save  ! multipl. ! additive !
+!           !                                      !           !           ! or not !  factor  !  factor  !
+   field_1  = 'Ice concentration                  ', 'iiceconc', '%       ',    1   ,  1.0     ,    0.0
+   field_2  = 'Ice thickness                      ', 'iicethic', 'm       ',    1   ,  1.0     ,    0.0
+   field_3  = 'Snow thickness                     ', 'isnowthi', 'm       ',    1   ,  1.0     ,    0.0
+   field_4  = 'Daily bottom thermo ice production ', 'iicebopr', 'cm/day  ',    1   , 100.     ,    0.0
+   field_5  = 'Daily dynamic ice production       ', 'iicedypr', 'cm/day  ',    1   , 100.     ,    0.0
+   field_6  = 'Oceanic flux at the ice base       ', 'ioceflxb', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_7  = 'Ice velocity u                     ', 'iicevelu', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_8  = 'Ice velocity v                     ', 'iicevelv', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_9  = 'Sea surface temperature            ', 'isstempe', 'C       ',    1   ,  1.0     , -273.15
+   field_10 = 'Sea surface salinity               ', 'isssalin', 'PSU     ',    1   ,  1.0     ,    0.0
+   field_11 = 'Total flux at ocean surface        ', 'iocetflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_12 = 'Solar flux at ocean surface        ', 'iocesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_13 = 'Non-solar flux at ocean surface    ', 'iocwnsfl', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_14 = 'Heat flux due to brine release     ', 'iocehebr', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_15 = 'Wind stress u                      ', 'iocestru', 'Pa      ',    1   ,  1.0     ,    0.0
+   field_16 = 'Wind stress v                      ', 'iocestrv', 'Pa      ',    1   ,  1.0     ,    0.0 
+   field_17 = 'Solar flux at ice/ocean surface    ', 'iicesflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_18 = 'Non-solar flux at ice/ocean surface', 'iicenflx', 'w/m2    ',    1   ,  1.0     ,    0.0
+   field_19 = 'Snow precipitation                 ', 'isnowpre', 'kg/day  ',    1   ,  1.0     ,    0.0
+   field_20 = 'Mean ice salinity                  ', 'iicesali', 'psu     ',    1   ,  1.0     ,    0.0
+   field_21 = 'Mean ice age                       ', 'iiceages', 'years   ',    1   ,  0.002739,    0.0
+   field_22 = 'Daily lateral thermo ice prod.     ', 'iicelapr', 'cm/day  ',    1   ,100.      ,    0.0
+   field_23 = 'Daily snowice ice production       ', 'iicesipr', 'cm/day  ',    1   ,100.      ,    0.0
+   field_24 = 'Mean ice temperature               ', 'iicetemp', 'C       ',    1   ,  1.0     , -273.15
+   field_25 = 'Ice total heat content             ', 'iiceheco', '10^9 J  ',    1   ,  1.0     ,    0.0
+   field_26 = 'Ice surface temperature            ', 'iicesurt', 'C       ',    1   ,  1.0     , -273.15
+   field_27 = 'Snow temperature                   ', 'isnotem2', 'C       ',    1   ,  1.0     , -273.15
+   field_28 = 'Fsbri - brine salt flux            ', 'iicfsbri', 'kg/m2/s ',    1   ,  1.0     ,    0.0
+   field_29 = 'Fseqv - equivalent FW salt flux    ', 'iicfseqv', 'kg/m2/s ',    1   ,  1.0     ,    0.0
+   field_30 = 'Brine volume                       ', 'ibrinvol', '%       ',    1   ,  100.0   ,    0.0
+   field_31 = 'Frazil ice collection thickness    ', 'iicecolf', 'm       ',    1   ,  1.0     ,    0.0
+   field_32 = 'Ice strength                       ', 'iicestre', 'N/m     ',    1   ,  0.001   ,    0.0
+   field_33 = 'Ice velocity                       ', 'iicevelo', 'm/s     ',    1   ,  1.0     ,    0.0
+   field_34 = 'Surface melt                       ', 'iicesume', 'cm/day  ',    1   ,100.      ,    0.0
+   field_35 = 'Bottom melt                        ', 'iicebome', 'cm/day  ',    1   ,100.      ,    0.0
+   field_36 = 'Divergence                         ', 'iicedive', '10-8s-1 ',    1   ,  1.0e8   ,    0.0
+   field_37 = 'Shear                              ', 'iiceshea', '10-8s-1 ',    1   ,  1.0e8   ,    0.0
+/      
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 1844)
@@ -0,0 +1,177 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! PISCES  :    1  - air-sea exchange                         (nampisext)
+!! namelists    2  - biological parameters                    (nampisbio)
+!!              3  - parameters for nutrient limitations      (nampislim)    
+!!              4  - parameters for phytoplankton             (nampisprod,nampismort)
+!!              5  - parameters for zooplankton               (nampismes,nampiszoo)
+!!              6  - parameters for remineralization          (nampisrem)
+!!              7  - parameters for calcite chemistry         (nampiscal)
+!!              8  - parameters for inputs deposition         (nampissed)
+!!              9  - parameters for Kriest parameterization   (nampiskrp, nampiskrs)
+!!              10 - additional 2D/3D  diagnostics            (nampisdia)
+!!              11 - Damping                                  (nampisdmp)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisext     !   air-sea exchange
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   atcco2     = 287.    ! atmospheric pCO2
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisbio     !   biological parameters
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   part       =  0.85    ! part of calcite not dissolved in guts
+   nrdttrc    =  1       ! time step frequency for biology
+   wsbio      =  2.      ! POC sinking speed
+   xkmort     =  1.E-7   ! half saturation constant for mortality
+   ferat3     =  3.E-6   ! Fe/C in zooplankton 
+   wsbio2     =  30.     ! Big particles sinking speed
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampislim     !   parameters for nutrient limitations
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   conc0      =  2.e-6    ! Phosphate half saturation
+   conc1      =  10E-6    ! Phosphate half saturation for diatoms
+   conc2      =  0.01E-9  ! Iron half saturation for phyto
+   conc2m     =  0.08E-9  ! Max iron half saturation for phyto
+   conc3      =  0.1E-9   ! Iron half saturation for diatoms
+   conc3m     =  0.4E-9   ! Maxi iron half saturation for diatoms
+   concnnh4   =  1.E-7    ! NH4 half saturation for phyto
+   concdnh4   =  5.E-7    ! NH4 half saturation for diatoms
+   xksi1      =  2.E-6    ! half saturation constant for Si uptake
+   xksi2      =  3.33E-6  ! half saturation constant for Si/C
+   xkdoc      =  417.E-6  ! half-saturation constant of DOC remineralization
+   caco3r     =  0.3      ! mean rain ratio
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisprod     !   parameters for phytoplankton growth
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   pislope    =  3.       ! P-I slope  
+   pislope2   =  3.       ! P-I slope  for diatoms
+   excret     =  0.05     ! excretion ratio of phytoplankton
+   excret2    =  0.05     ! excretion ratio of diatoms
+   chlcnm     =  0.033    ! Minimum Chl/C in nanophytoplankton
+   chlcdm     =  0.05     ! Minimum Chl/C in diatoms
+   fecnm      =  10E-6    ! Maximum Fe/C in nanophytoplankton
+   fecdm      =  15E-6    ! Minimum Fe/C in diatoms
+   grosip     =  0.151    ! mean Si/C ratio
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismort     !   parameters for phytoplankton sinks
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   wchl       =  0.001    ! quadratic mortality of phytoplankton
+   wchld      =  0.02     ! maximum quadratic mortality of diatoms
+   mprat      =  0.01     ! phytoplankton mortality rate
+   mprat2     =  0.01     ! Diatoms mortality rate
+   mpratm     =  0.01     ! Phytoplankton minimum mortality rate
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismes     !   parameters for mesozooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   grazrat2   =  0.7      ! maximal mesozoo grazing rate
+   resrat2    =  0.005    ! exsudation rate of mesozooplankton
+   mzrat2     =  0.03     ! mesozooplankton mortality rate
+   xprefc     =  1.       ! zoo preference for phyto
+   xprefp     =  0.2      ! zoo preference for POC
+   xprefz     =  1.       ! zoo preference for zoo
+   xprefpoc   =  0.2      ! zoo preference for poc
+   xkgraz2    =  20.E-6   ! half sturation constant for meso grazing
+   epsher2    =  0.33     ! Efficicency of Mesozoo growth 
+   sigma2     =  0.6      ! Fraction of mesozoo excretion as DOM
+   unass2     =  0.3      ! non assimilated fraction of P by mesozoo
+   grazflux   =  5.e3     ! flux-feeding rate
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiszoo     !   parameters for microzooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   grazrat    =  4.0      ! maximal zoo grazing rate   
+   resrat     =  0.03     ! exsudation rate of zooplankton
+   mzrat      =  0.0      ! zooplankton mortality rate
+   xpref2c    =  0.1      ! Microzoo preference for POM 
+   xpref2p    =  0.45     ! Microzoo preference for Nanophyto
+   xpref2d    =  0.45     ! Microzoo preference for Diatoms
+   xkgraz     =  20.E-6   ! half sturation constant for grazing 
+   epsher     =  0.33     ! Efficiency of microzoo growth
+   sigma1     =  0.6      ! Fraction of microzoo excretion as DOM
+   unass      =  0.3      ! non assimilated fraction of phyto by zoo
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisrem     !   parameters for remineralization
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xremik    =  0.3       ! remineralization rate of DOC
+   xremip    =  0.025     ! remineralisation rate of POC
+   nitrif    =  0.05      ! NH4 nitrification rate
+   xsirem    =  0.015     ! remineralization rate of Si
+   xlam1     =  0.005     ! scavenging rate of Iron
+   oxymin    =  1.E-6     ! Half-saturation constant for anoxia 
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiscal     !   parameters for Calcite chemistry
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   kdca       =  0.327e3  ! calcite dissolution rate constant (1/time)
+   nca        =  1.       ! order of dissolution reaction (dimensionless)
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampissed     !   parameters for inputs deposition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_dustfer  =  .true.   ! boolean for dust input from the atmosphere
+   ln_river    =  .false.  ! boolean for river input of nutrients
+   ln_ndepo    =  .true.   ! boolean for atmospheric deposition of N
+   ln_sedinput =  .true.   ! boolean for Fe input from sediments
+   sedfeinput  =  1E-9     ! Coastal release of Iron
+   dustsolub   =  0.014    ! Solubility of the dust
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiskrp     !   Kriest parameterization : parameters     "key_kriest"
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xkr_eta      = 1.17    ! Sinking  exponent
+   xkr_zeta     = 2.28    ! N content exponent
+   xkr_mass_min = 0.0002  ! Minimum mass for Aggregates
+   xkr_mass_max = 1.      ! Maximum mass for Aggregates
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiskrs     !   Kriest parameterization : size classes  "key_kriest"
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xkr_sfact    = 942.    ! Sinking factor
+   xkr_stick    = 0.5     ! Stickiness
+   xkr_nnano    = 2.337   ! Nbr of cell in nano size class
+   xkr_ndiat    = 3.718   ! Nbr of cell in diatoms size class
+   xkr_nmeso    = 7.147   ! Nbr of cell in mesozoo size class
+   xkr_naggr    = 9.877   ! Nbr of cell in aggregates  size class
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisdia     !   additional 2D/3D tracers diagnostics ("key_trc_diaadd")
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   nwritedia   =  5475     !  time step frequency for tracers diagnostics
+!
+!              !    name   !           title of the field          !     units      !
+!              !           !                                       !                !  
+   pisdia2d(1)  = 'Cflx     ' , 'DIC flux                          ',  'molC/m2/s    '
+   pisdia2d(2)  = 'Oflx     ' , 'Oxygen flux                       ',  'molC/m2/s    '
+   pisdia2d(3)  = 'Kg       ' , 'Gas transfer                      ',  'mol/m2/s/uatm'
+   pisdia2d(4)  = 'Delc     ' , 'Delta CO2                         ',  'uatm         '
+   pisdia2d(5)  = 'PMO      ' , 'POC export                        ',  'molC/m2/s    '
+   pisdia2d(6)  = 'PMO2     ' , 'GOC export                        ',  'molC/m2/s    '
+   pisdia2d(7)  = 'ExpFe1   ' , 'Nano iron export                  ',  'molFe/m2/s   '
+   pisdia2d(8)  = 'ExpFe2   ' , 'Diatoms iron export               ',  'molFe/m2/s   '
+   pisdia2d(9)  = 'ExpSi    ' , 'Silicate export                   ',  'molSi/m2/s   '
+   pisdia2d(10) = 'ExpCaCO3 ' , 'Calcite export                    ',  'molC/m2/s    '
+   pisdia2d(11) = 'heup     ' , 'euphotic layer depth              ',  'm            '
+   pisdia2d(12) = 'Fedep    ' , 'Iron dep                          ',  'molFe/m2/s   '
+   pisdia2d(13) = 'Nfix     ' , 'Nitrogen Fixation                 ',  'molN/m2/s    '
+   pisdia3d(1)  = 'PH       ' , 'PH                                ',  '-            '
+   pisdia3d(2)  = 'CO3      ' , 'Bicarbonates                      ',  'mol/l        '
+   pisdia3d(3)  = 'CO3sat   ' , 'CO3 saturation                    ',  'mol/l        '
+   pisdia3d(4)  = 'PAR      ' , 'light penetration                 ',  'W/m2         '
+   pisdia3d(5)  = 'PPPHY    ' , 'Primary production of nanophyto   ',  'molC/m3/s    '
+   pisdia3d(6)  = 'PPPHY2   ' , 'Primary production of diatoms     ',  'molC/m3/s    '
+   pisdia3d(7)  = 'PPNEWN   ' , 'New Primary production of nano    ',  'molC/m3/s    '
+   pisdia3d(8)  = 'PPNEWD   ' , 'New Primary production of diat    ',  'molC/m3/s    '
+   pisdia3d(9)  = 'PBSi     ' , 'Primary production of Si diatoms  ',  'molSi/m3/s   '
+   pisdia3d(10) = 'PFeN     ' , 'Primary production of nano iron   ',  'molFe/m3/s   '
+   pisdia3d(11) = 'PFeD     ' , 'Primary production of diatoms iron',  'molFe/m3/s   '
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisdmp     !  Damping 
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_pisdmp    =  .true.     !  Relaxation fo some tracers to a mean value
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top	(revision 1844)
@@ -0,0 +1,143 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  1 - tracer definition                     (namtoptrc)
+!! namelists    2 - dynamical tracer trends               (namtoptrd)
+!!              6 - tracer advection                      (namtopadv)
+!!              7 - tracer bottom boundary                (namtopbbl)
+!!              8 - tracer lateral diffusion              (namtopldf)
+!!              3 - tracer vertical physics               (namtopzdf)
+!!              9 - tracer newtonian damping              (namtopdmp)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namtoptrc     !   tracers definition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ndttrc      =  1        !  time step frequency for passive tracers      
+   nwritetrc   =  5475     !  time step frequency for tracer outputs
+   ln_rsttr    = .false.   !  start from a restart file (T) or not (F)
+   nrsttr      =   0       !  restart control = 0 initial time step is not compared to the restart file value
+                           !                  = 1 do not use the value in the restart file
+                           !                  = 2 calendar parameters read in the restart file
+   cn_trcrst_in  = "restart_trc"   !  suffix of pass. tracer restart name (input)
+   cn_trcrst_out = "restart_trc"   !  suffix of pass. tracer restart name (output)
+!
+!              !    name   !           title of the field              !   units    ! initial data ! save   !
+!              !           !                                           !            ! from file    ! or not ! 
+!              !           !                                           !            ! or not       !        !
+   tracer(1)   = 'DIC     ' , 'Dissolved inorganic Concentration      ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(2)   = 'Alkalini' , 'Total Alkalinity Concentration         ',  'eq/L '   ,  .true.     ,  .true.
+   tracer(3)   = 'O2      ' , 'Dissolved Oxygen Concentration         ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(4)   = 'CaCO3   ' , 'Calcite Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(5)   = 'PO4     ' , 'Phosphate Concentration                ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(6)   = 'POC     ' , 'Small organic carbon Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(7)   = 'Si      ' , 'Silicate Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(8)   = 'PHY     ' , 'Nanophytoplankton Concentration        ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(9)   = 'ZOO     ' , 'Microzooplankton Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(10)  = 'DOC     ' , 'Dissolved organic Concentration        ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(11)  = 'PHY2    ' , 'Diatoms Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(12)  = 'ZOO2    ' , 'Mesozooplankton Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(13)  = 'BSi     ' , 'Diatoms Silicate Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(14)  = 'Fer     ' , 'Dissolved Iron Concentration           ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(15)  = 'BFe     ' , 'Big iron particles Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(16)  = 'GOC     ' , 'Big organic carbon Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(17)  = 'SFe     ' , 'Small iron particles Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(18)  = 'DFe     ' , 'Diatoms iron  Concentration            ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(19)  = 'DSi     ' , 'Sinking biogenic Silicate Concentration',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(20)  = 'NFe     ' , 'Nano iron Concentration                ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(21)  = 'NCHL    ' , 'Nano chlorophyl Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(22)  = 'DCHL    ' , 'Diatoms chlorophyl Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(23)  = 'NO3     ' , 'Nitrates Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(24)  = 'NH4     ' , 'Ammonium Concentration                 ',  'mol-C/L' ,  .false.    ,  .true.
+/
+!-----------------------------------------------------------------------
+&namtopadv    !   advection scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_trcadv_tvd    =  .false.  !  TVD scheme   
+   ln_trcadv_muscl  =  .true.   !  MUSCL scheme
+   ln_trcadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_trcadv_smolar =  .false.  !  SMOLAR scheme
+   rsc              =  1.       !  tuning coefficient for Smol-Car. scheme 
+   ncortrc          =  1        !  number of corrective phases for Smol-Car. scheme 
+   crosster         =  .false.  !  computes Smol-Car crossterms (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopbbl    !   bottom boundary layer scheme for passive tracer 
+!-----------------------------------------------------------------------
+   atrcbbl          = 1000.     !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!-----------------------------------------------------------------------
+&namtopldf    !   lateral diffusion scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcldf_diff   =  .true.   !  performs lateral diffusion (T) or not (F)
+!                               !  Type of the operator : 
+   ln_trcldf_lap    =  .true.   !     laplacian operator       
+   ln_trcldf_bilap  =  .false.  !     bilaplacian operator     
+                                !  Direction of action  :
+   ln_trcldf_level  =  .false.  !     iso-level                
+   ln_trcldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_trcldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+!                               !  Coefficient
+   ahtrc0      =  2000.         !     horizontal eddy diffusivity for tracers [m2/s]
+   ahtrb0      =     0.         !     background eddy diffusivity for ldf_iso [m2/s]
+   aeivtr0     =  2000.         !     eddy induced velocity coefficient [m2/s]    (require "key_trcldf_eiv")
+   trcrat      =  1.            !  ratio betweeen passive and active tracer diffusion coeff
+/
+!-----------------------------------------------------------------------
+&namtopzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   ln_trczdf_exp   =  .false.  !  split explicit (T) or implicit (F) time stepping
+   n_trczdf_exp    =   3       !  number of sub-timestep for ln_trczdfexp=T
+/
+!-----------------------------------------------------------------------
+&namtoprad        !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+   ln_trcrad   =  .true.  !  artificially correct negative concentrations (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopdmp        !   passive tracer newtonian damping                 ('key_trcdmp')
+!-----------------------------------------------------------------------
+   ndmptr      =   20      !  type of damping in passive tracers
+                           !     ='latitude', damping poleward of 'ndmp' degrees and function 
+                           !                  of the distance-to-coast. Red and Med Seas as ndmptr=-1
+                           !     =-1 damping only in Med and Red Seas
+   ndmpftr     =    0      !  create a damping.coeff NetCDF file (=1) or not (=0)
+   nmldmptr    =    1      !  type of damping: =0 damping throughout the water column
+                           !                   =1 no damping in the mixed layer defined by avt >5cm2/s )
+                           !                   =2 no damping in the mixed layer defined rho<rho(surf)+.01 )
+   sdmptr      =   50.     !  surface time scale for internal damping (days)
+   bdmptr      =  360.     !  bottom  time scale for internal damping (days)
+   hdmptr      =  800.     !  depth of transition between sdmptr and bdmptr (meters)
+/
+!-----------------------------------------------------------------------
+&namtoptrd       !   diagnostics on tracer trends
+!                          or mixed-layer trends          ('key_trdmld_trc')
+!----------------------------------------------------------------------
+   ntrd_trc   =  5475      !  time step frequency and tracers trends
+   nctls_trc  =   0        !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   ucf_trc    =   1        !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   ln_trdmld_trc_restart = .false.  !  restart for ML diagnostics
+   ln_trdmld_trc_instant = .true.  !  flag to diagnose trends of instantantaneous or mean ML T/S
+   luttrd(1)  =   .true.
+   luttrd(2)  =   .true.
+   luttrd(3)  =   .false.
+   luttrd(4)  =   .false.
+   luttrd(5)  =   .false.
+   luttrd(6)  =   .false.
+   luttrd(7)  =   .false.
+   luttrd(8)  =   .false.
+   luttrd(9)  =   .false.
+   luttrd(10) =   .false.
+   luttrd(11) =   .false.
+   luttrd(12) =   .false.
+   luttrd(13) =   .false.
+   luttrd(14) =   .false.
+   luttrd(15) =   .false.
+   luttrd(16) =   .false.
+   luttrd(17) =   .false.
+   luttrd(18) =   .false.
+   luttrd(19) =   .false.
+   luttrd(20) =   .false.
+   luttrd(21) =   .false.
+   luttrd(22) =   .false.
+   luttrd(23) =   .true.
+   luttrd(24) =   .false.
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,20 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
+  
+  
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.card	(revision 1844)
@@ -0,0 +1,28 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+
+[InitialStateFiles]
+List=	()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= ()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist_ice_lim2, namelist_ice)
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart_ice.nc, restart_icemod.nc, restart_ice_in.nc)
+
+[OutputText]
+List=   (ice_evolu)
+
+[OutputFiles]
+List=   (${PREFIX_WFI1}_icemod.nc, ${R_OUT_ICE_WFI1}/${PREFIX}_${WFI1}_icemod.nc, Post_5D_icemod)
+
+[Post_1M_icemod]
+Patches = ()
+GatherWithInternal = (nav_lon, nav_lat, time_counter)
+TimeSeriesVars = (iicethic, ileadfra, isnowthi, iicevelu, iicevelv)
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/lim2.driver	(revision 1844)
@@ -0,0 +1,56 @@
+#!/bin/ksh
+
+#-----------------------------------
+function ICE_Initialize
+{ 
+    IGCM_debug_PushStack "ICE_Initialize"
+
+    echo INITIALIZE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Initialize"
+}
+
+#-----------------------------------
+function ICE_Update
+{
+    IGCM_debug_PushStack "ICE_Update"
+
+    NbFreq=$( echo ${config_ICE_WriteFrequency} | wc -w )
+
+    ##--Write Frequency Purpose ....
+    typeset -Z1 i=1
+    while [ $i -le ${NbFreq} ]; do
+        frequency=$( echo ${config_ICE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+        factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
+        case ${frequency} in
+            *Y|*y)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_Y} ;
+                eval WFI${i}=${factor}Y ;;
+            *M|*m)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_M} ;
+                eval WFI${i}=${factor}M ;;
+            *D|*d)
+                eval PREFIX_WFI${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
+                eval R_OUT_ICE_WFI${i}=${R_OUT_ICE_O_D} ;
+                eval WFI${i}=${factor}D ;;
+            *)
+        esac
+        let i=$i+1
+
+    done
+    echo UPDATE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Update"
+}
+
+#-----------------------------------
+function ICE_Finalize
+{
+    IGCM_debug_PushStack "ICE_Finalize"
+
+    echo FINALIZE ICE !!!
+
+    IGCM_debug_PopStack "ICE_Finalize"
+}
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.card	(revision 1844)
@@ -0,0 +1,132 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+OPA_NDT_DAY=15
+#==============================================================
+#-- Name of directory for COMMON ACCOUNT at idris or CCRT
+#-- available directories are:  v3, v3_1, v3_2
+#-- related to NEMO_tag_revision (nemo_v3, nemo_v3_1, nemo_v3_2_beta)
+#-- NOTE: if you use your own directory you have to comment it
+OPA_version=v3_2
+#==============================================================
+
+#===================================
+#-- Use (y) or not (n) of io_server
+io_server=n
+#===================================
+
+#-- if you run interannual is "y", if not (=climatology) is "n"
+Interannual_Run=n
+
+[Interannual]
+#=====================================================================
+#-- Surface Boundary Condition original files name ( get by the job )
+#=====================================================================
+#-- NOTE: MANDATORY STRUCTURE OF FILE NAMES GET BY THE JOB : 
+#-- "basename_yyyy.nc"  	( for interannual data )
+#-- "basename.nc"	  	( for climatologycal data )
+#-- MANDATORY: NAMES USED IN List_jobsbc VARIABLE MUST BE ONLY THE BASENAME
+
+# default climatology, bulk_clio: 
+List_jobsbc=(flx, taux_1m, tauy_1m)
+# example for interannual, bulk core:
+#List_jobsbc=(radlw_DFS4-ORCA2, radsw_DFS4-ORCA2, q2_DFS4-ORCA2, t2_DFS4-ORCA2, u10_DFS4-ORCA2, v10_DFS4-ORCA2, snow_DFS4-ORCA2, precip_DFS4-ORCA2)
+
+#==========================================================================================
+#-- Surface Boundary Condition files name expected by NEMO ( same as the ones in namelist )
+#==========================================================================================
+#-- NOTE: 2 possible cases :
+#-- 1) put in List_runsbc file names different from List_jobsbc but identical to the ones in namelist
+#-- 2) leave List_runsbc empty so NEMO will read file names specified in List_jobsbc variable above
+
+# default climatology, bulk_clio: 
+List_runsbc=()
+# example for interannual, bulk core:
+#List_runsbc=(qlw_core, qsw_core, q2_core, t2_core, u10_core, v10_core, snow_core, precip_core)
+
+[InitialStateFiles]
+List=	()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/ahmcoef, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_level.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_meter.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy_updated.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/coordinates.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_potential_temperature_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_salinity_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/geothermal_heating.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/runoff_1m_nomask.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/sss_data.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/sst_data.nc, .),\
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/subbasins.nc, .)
+
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist,         namelist), \
+	(${SUBMIT_DIR}/PARAM/iodef.xml,        iodef.xml),      \
+        (${SUBMIT_DIR}/PARAM/xmlio_server.def, xmlio_server.def)
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart.nc,  restart.nc, restart.nc)
+
+[OutputText]
+List=   (ocean.output, solver.stat, STRAIT.dat, out_nemo)
+
+[OutputFiles]
+List=   (${PREFIX_WF1}_grid_T.nc,         ${R_OUT_OCE_WF1}/${PREFIX}_${WF1}_grid_T.nc,               Post_1Y_grid_T),\
+        (${PREFIX_WF2}_grid_T.nc,         ${R_OUT_OCE_WF2}/${PREFIX}_${WF2}_grid_T.nc,               Post_1M_grid_T),\
+        (${PREFIX_WF3}_grid_T.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_T.nc,               Post_5D_grid_T),\
+        (${PREFIX_WF3}_grid_U.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_U.nc,               Post_5D_grid_U) ,\
+        (${PREFIX_WF3}_grid_V.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_V.nc,               Post_5D_grid_V),\
+        (${PREFIX_WF3}_grid_W.nc,         ${R_OUT_OCE_WF3}/${PREFIX}_${WF3}_grid_W.nc,               Post_5D_grid_W),\
+        (${PREFIX_WF4}_grid_T_0n180w.nc,  ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_grid_T_0n180w.nc,        NONE ),\
+        (${PREFIX_WF4}_grid_T_Eq.nc,      ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_grid_T_Eq.nc,            NONE ),\
+        (${PREFIX_WF4}_diaptr.nc,         ${R_OUT_OCE_WF4}/${PREFIX}_${WF4}_diaptr.nc,               Post_1D_diaptr),\
+        (mesh_mask.nc     ,               ${R_OUT_OCE_O}/${config_UserChoices_JobName}_mesh_mask.nc, NONE),\
+        (output.abort.nc  ,               ${R_OUT_OCE_D}/${PREFIX}_output.abort.nc,                  NONE),\
+        (output.init.nc   ,               ${R_OUT_OCE_O_I}/${config_UserChoices_JobName}_${PeriodDateBegin}_output.init.nc, NONE)
+
+
+[Post_1M_grid_T]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (sohtc300, sohefldo, soicecov, somxl010, sosaline, sossheig, sosstsst, sowaflcd, sowaflup)
+
+[Post_1Y_grid_T]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (sohtc300, sohefldo, soicecov, somxl010, sosaline, sossheig, sosstsst, sowaflcd, sowaflup)
+
+[Post_5D_grid_T]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (sohtc300, sohefldo, soicecov, somxl010, sosaline, sossheig, sosstsst, sowaflcd, sowaflup)
+
+[Post_5D_grid_U]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthu, time_counter)
+TimeSeriesVars = (sozotaux)
+
+[Post_5D_grid_V]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthv, time_counter)
+TimeSeriesVars = (sometauy)
+
+[Post_5D_grid_W]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal = (nav_lon, nav_lat, depthw, time_counter)
+TimeSeriesVars =
+
+[Post_1D_diaptr]
+Patches = ()
+GatherWithInternal = (lat, deptht, depthw, time_counter)
+TimeSeriesVars = (zotemglo, zosalglo, zomsfglo, zotematl, zosalatl, zomsfatl, zotempac, zosalpac, zomsfpac, zotemind, zosalind, zomsfind, zotemipc, zosalipc, zomsfipc, sohtatl, sostatl, sohtpac, sostpac, sohtind, sostind, sohtipc, sostipc, sophtadv, sophtove, sophtldf, sopstadv, sopstove, zomsfeiv, sophteiv, sopsteiv)
+
+[Post_time]
+Patches = (Patch_20091030_histcom_time_axis)
+GatherWithInternal =
+TimeSeriesVars =
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.driver	(revision 1844)
@@ -0,0 +1,267 @@
+#!/bin/ksh
+#-----------------------------------------------------------------
+function OCE_Initialize
+{
+    IGCM_debug_PushStack "OCE_Initialize"
+
+    JOB_NAME=${config_UserChoices_JobName}
+
+    OPA_NDT_DAY=${opa_UserChoices_OPA_NDT_DAY:=15}
+
+
+    ##--Variables used by OPA --
+
+    # cn_exp experience name for vairmer format
+    # nn_it000 number of the first time step
+    # nn_itend number of the last time step
+    # nn_leapy leap year calendar (0/1) (30 for 360d)
+    # nn_write frequency of OUTPUT file
+    # ln_rstart boolean term for restart (true or false)
+    # nn_stock frequency of restart file
+    # nn_rstctl control of the time step (0, 1 or 2)
+    # nn_date0 initial calendar date aammjj
+    # nn_msh  =1 create a mesh file (coordinates, scale factors, masks)
+    # rn_rdt time step in seconds (coming from namelist)
+    # nf_ptr_wri frequency of zonal means and transport output
+
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+
+    PAT_CEXPER=$( supergrep cn_exp    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NIT000=$( supergrep nn_it000    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NITEND=$( supergrep nn_itend    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NLEAPY=$( supergrep nn_leapy    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_RESTAR=$( supergrep ln_rstart ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NSTOCK=$( supergrep nn_stock    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NRSTAR=$( supergrep nn_rstctl    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NDATE0=$( supergrep nn_date0    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NMSH=$(   supergrep nn_msh      ${SUBMIT_DIR}/PARAM/namelist ) 
+    
+
+    OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/namelist | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
+
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # /!\ Needed by OPA namelist to compute file names /!\
+    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
+
+    # Definition from opa9.card of List_jobsbc and List_runsbc used to do to interannual and climatological runs 
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/opa9.card Interannual List_jobsbc
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/opa9.card Interannual List_runsbc
+        set -A ListFormulationJobsbc -- \${opa9_Interannual_Listjobsc${opa9_Interannual_List_jobsbc}[*]}
+        set -A ListFormulationRunsbc -- \${opa9_Interannual_Listrunsbc${opa9_Interannual_List_runsbc}[*]}
+
+    ##--Variables used for XMLIO_SERVER configuration file
+	    # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+	    PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def )
+	
+    IGCM_debug_PopStack "OCE_Initialize"
+}
+
+#-----------------------------------------------------------------
+function OCE_Update
+{
+    IGCM_debug_PushStack "OCE_Update"
+
+    # Interannual run
+    # In this case job need to calculate previous and following year and give, and if every run needs to add "_y" before every year 
+    if [ X${opa9_UserChoices_Interannual_Run} = Xy ] ; then
+
+	typeset file fileo
+
+        eval NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
+
+	(( i = 0 ))
+	while [ $i -lt ${NbFileInter} ] ; do
+	    eval file=${opa9_Interannual_List_jobsbc[$i]}
+	    eval jobsbc_file_ym1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year - 1 )).nc
+	    eval jobsbc_file_y=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_${year}.nc
+	    eval jobsbc_file_yp1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year + 1 )).nc
+     # Copy of List_jobsbc in List_runsbc if this last one is empty 
+            if [ X${opa9_Interannual_List_runsbc[0]} = X${NULL_STR} ] ; then
+	    	eval fileo=${opa9_Interannual_List_jobsbc[$i]}
+            	eval runsbc_file_ym1=${file}_y$(( year - 1 )).nc
+            	eval runsbc_file_y=${file}_y${year}.nc
+            	eval runsbc_file_yp1=${file}_y$(( year + 1 )).nc
+	    else
+	    	eval fileo=${opa9_Interannual_List_runsbc[$i]}
+            	eval runsbc_file_ym1=${fileo}_y$(( year - 1 )).nc
+            	eval runsbc_file_y=${fileo}_y${year}.nc
+            	eval runsbc_file_yp1=${fileo}_y$(( year + 1 )).nc
+	   fi
+
+	    if [ X${Period} = X1 ] ; then
+		if [ ${month} -eq 01 ] ; then
+		    IGCM_sys_Get ${jobsbc_file_ym1} ${runsbc_file_ym1}
+		fi
+		if [ ! -f ${runsbc_file_y} ] ; then
+		    IGCM_sys_Get ${jobsbc_file_y} ${runsbc_file_y}
+		fi
+		if [ ! -f ${runsbc_file_yp1} ] ; then
+		    IGCM_sys_Get ${jobsbc_file_yp1} ${runsbc_file_yp1}
+		fi
+	    else 
+		if [ ! -f ${runsbc_file_yp1} ] ; then
+		    IGCM_sys_Get ${jobsbc_file_yp1} ${runsbc_file_yp1}
+		fi
+	    fi 
+
+	    (( i = i + 1 ))
+	done
+    # End interannual
+    elif [ X${opa9_UserChoices_Interannual_Run} = Xn ] ; then
+    # Climatological run
+       typeset file fileo
+
+       eval NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
+
+        (( i = 0 ))
+        while [ $i -lt ${NbFileInter} ] ; do
+            eval file=${opa9_Interannual_List_jobsbc[$i]}
+            eval jobsbc_file=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}.nc
+            if [ X${opa9_Interannual_List_runsbc[0]} = X${NULL_STR} ] ; then
+	    	eval fileo=${opa9_Interannual_List_jobsbc[$i]}
+            	eval runsbc_file=${fileo}.nc
+	    else
+	    	eval fileo=${opa9_Interannual_List_runsbc[$i]}
+            	eval runsbc_file=${fileo}.nc
+	   fi
+
+            IGCM_sys_Get ${jobsbc_file} ${runsbc_file}
+            (( i = i + 1 ))
+	done
+    fi
+    # End climatological
+
+    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
+
+    ##--Write Frequency Purpose ....
+    typeset -Z1 i=1
+    while [ $i -le ${NbFreq} ]; do
+        frequency=$( echo ${config_OCE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+    	factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
+    	case ${frequency} in
+    	    *Y|*y)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_Y} ;
+    	        eval WF${i}=${factor}Y ;;
+    	    *M|*m)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_M} ;
+    	        eval WF${i}=${factor}M ;;
+    	    *D|*d)
+    	        eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
+    	        eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_D} ;
+    	        eval WF${i}=${factor}D ;;
+    	    *)
+    	esac
+        let i=$i+1
+
+    done
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # Needed by OPA namelist to compute correct file names 
+    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
+
+    ## Count of number of time steps from begin of OPA job
+    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NDT_DAY + 1 ))
+    (( OPA_NDT   = PeriodLengthInDays * OPA_NDT_DAY ))
+    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
+
+    ## Forcing to write one restart file at the end of period
+    OPA_NSTOCK="${OPA_NITEND}"
+
+    ## Verification of number of time steps per day
+    (( NB_SEC_DAY_MODEL = OPA_NDT_DAY * OPA_RDT ))
+    (( NB_SEC_DAY = 60 * 60 * 24 ))
+
+    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
+	then
+        echo " VERIFY OPA_NDT_DAY in opa9.card "
+        exit
+    fi
+
+    ##-- Restart configuration
+    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
+
+        #echo "NO OPA RESTART"
+	OPA_LRSTAR=.FALSE.
+	OPA_NRSTDT=0
+        #Put OPA_NMSH=0 when OPA runnig in parallel mode 
+	OPA_NMSH=1
+	( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) && OPA_NMSH=0
+
+    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
+
+        #echo "OPA RESTART"
+	OPA_LRSTAR=.TRUE.
+	OPA_NRSTDT=1
+	OPA_NMSH=0
+
+    else
+
+        #echo "OPA RESTART"
+	OPA_LRSTAR=.TRUE.
+	OPA_NRSTDT=2
+	OPA_NMSH=0
+
+    fi
+   
+     ## nleapy configuration
+	case ${config_UserChoices_CalendarType} in
+        	leap)
+            	OPA_NLEAPY=1;;
+        	noleap)
+            	OPA_NLEAPY=0;;
+        	360d)
+            	OPA_NLEAPY=30;;
+    	esac
+
+
+        typeset -r PRECIS=8
+	NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
+
+    sed -e "s%${PAT_CEXPER}%       cn_exp=\"${config_UserChoices_JobName}\"%" \
+	-e "s%${PAT_NIT000}%       nn_it000=${OPA_NIT000}%"                    \
+	-e "s%${PAT_NITEND}%       nn_itend=${OPA_NITEND}%"                    \
+	-e "s%${PAT_RESTAR}%       ln_rstart=${OPA_LRSTAR}%"                 \
+	-e "s%${PAT_NSTOCK}%       nn_stock=${OPA_NSTOCK}%"                    \
+	-e "s%${PAT_NRSTAR}%       nn_rstctl=${OPA_NRSTDT}%"                    \
+	-e "s%${PAT_NDATE0}%       nn_date0=${PeriodDateBegin}%"                \
+	-e "s%${PAT_NMSH}%         nn_msh=${OPA_NMSH}%"                        \
+	-e "s%${PAT_NLEAPY}%       nn_leapy=${OPA_NLEAPY}%"	              \
+	namelist > namelist.tmp
+
+    IGCM_sys_Mv namelist.tmp namelist
+
+    # update xmlio_server.def
+
+    if [ X${opa9_UserChoices_io_server} = Xy ] ; then
+        sed -e "s/${PAT_SERVER}/  using_server = .TRUE./" \
+        xmlio_server.def > xmlio_server.def.tmp
+        IGCM_sys_Mv xmlio_server.def.tmp xmlio_server.def
+    fi
+	
+    IGCM_debug_PopStack "OCE_Update"
+}
+
+#-----------------------------------
+function OCE_Finalize
+{
+    IGCM_debug_PushStack "OCE_Finalize"
+
+    if [ -f date.file ] ; then
+        # Prefix use in opa.card AND in lim2.card :
+	DATE_OPA=$( cat date.file | \
+	    sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
+        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
+	MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
+	SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
+    fi
+
+    echo FINALIZE OCE !!!
+
+    IGCM_debug_PopStack "OCE_Finalize"
+}
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.card	(revision 1844)
@@ -0,0 +1,40 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+
+[InitialStateFiles]
+List= ()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_DIC_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_Alkalini_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_O2_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_NO3_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_PO4_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_Si_nomask.nc,  .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_DOC_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/data_1m_Fer_nomask.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/kRGB61.txt, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/dust.orca.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/bathy.orca.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/river.orca.nc, .), \
+            (${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/ndeposition.orca.nc, .)
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist_top, .), \
+        (${SUBMIT_DIR}/PARAM/namelist_pisces, .), \
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart_trc.nc,  restart_trc.nc, restart_trc.nc)
+
+[OutputText]
+List=   ()
+
+[OutputFiles]
+List=   (${PREFIX_WFT1}_ptrc_T.nc, ${R_OUT_MBG_WFT1}/${PREFIX}_${WFT1}_ptrc_T.nc, NONE), \
+        (${PREFIX_WFT1}_diad_T.nc, ${R_OUT_MBG_WFT1}/${PREFIX}_${WFT1}_diad_T.nc, NONE), \
+        (${PREFIX_WFT2}_ptrc_T.nc, ${R_OUT_MBG_WFT2}/${PREFIX}_${WFT2}_ptrc_T.nc, Post_1M_ptrc_T), \
+        (${PREFIX_WFT3}_diad_T.nc, ${R_OUT_MBG_WFT3}/${PREFIX}_${WFT3}_diad_T.nc, Post_5D_ptrc_T)
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/pisces.driver	(revision 1844)
@@ -0,0 +1,110 @@
+#!/bin/ksh
+
+#-----------------------------------
+function MBG_Initialize
+{ 
+    IGCM_debug_PushStack "MBG_Initialize"
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+    ##--Variables used by MBG --
+
+    # lrsttr    boolean term for tracer model restart (true or false)
+    # nrsttr    control of the time step (0, 1 or 2)
+    
+    ##--Variables used by PISCES --
+ 
+    PAT_TOP_LRSTTR=$( supergrep ln_rsttr                 ${SUBMIT_DIR}/PARAM/namelist_top )
+    PAT_TOP_NRSTTR=$( supergrep nrsttr                   ${SUBMIT_DIR}/PARAM/namelist_top )
+    PAT_PIS_LRIVER=$( supergrep ln_river                 ${SUBMIT_DIR}/PARAM/namelist_pisces )
+
+    IGCM_debug_PopStack "MBG_Initialize"
+}
+
+#-----------------------------------
+function MBG_Update
+{
+    IGCM_debug_PushStack "MBG_Update"
+
+
+    ##--Write Frequency Purpose
+    Nbfreq=$( echo ${config_MBG_WriteFrequency} | wc -w )
+    typeset -Z1 i=1
+    while [ $i -le ${Nbfreq} ]; do
+       topfrequency=$( echo ${config_MBG_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+       topfactor=$( echo ${topfrequency} | sed -e "s/[yYmMdD]//" )
+       case ${topfrequency} in
+         *Y|*y)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}y_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_Y} ;
+            eval WFT${i}=${topfactor}Y ;;
+         *M|*m)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}m_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_M} ;
+            eval WFT${i}=${topfactor}M ;;
+         *D|*d)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}d_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_D} ;
+            eval WFT${i}=${topfactor}D ;;
+         *)
+      esac
+       let i=$i+1
+    done
+
+    ##-- Restart configuration
+    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
+
+        #echo "NO RESTART FOR TOP"
+        TOP_LRSTTR=.FALSE.
+        TOP_NRSTTR=0
+
+        PISCES_LRIVER=.FALSE.
+
+    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
+
+        #echo "RESTART TOP"
+        TOP_LRSTTR=.TRUE.
+        TOP_NRSTTR=0
+
+        PISCES_LRIVER=.TRUE.
+
+    else
+
+        #echo "RESTART TOP"
+        TOP_LRSTTR=.TRUE.
+        TOP_NRSTTR=2
+
+        PISCES_LRIVER=.TRUE.
+
+    fi
+
+# on force les sorties PISCES comme les sorties OPA
+
+    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
+        -e "s%${PAT_TOP_NRSTTR}%          nrsttr=${TOP_NRSTTR}%"                   \
+        namelist_top > namelist_top.tmp
+
+    IGCM_sys_Mv namelist_top.tmp namelist_top
+
+    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
+        namelist_pisces > namelist_pisces.tmp
+
+    IGCM_sys_Mv namelist_pisces.tmp namelist_pisces
+
+
+    IGCM_debug_PopStack "MBG_Update"
+}
+
+#-----------------------------------
+function MBG_Finalize
+{
+    IGCM_debug_PushStack "MBG_Finalize"
+
+    echo FINALIZE MBG !!!
+
+    IGCM_debug_PopStack "MBG_Finalize"
+}
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/README
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/README	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/README	(revision 1844)
@@ -0,0 +1,9 @@
+config.card
+ORCA2_LIM_PISCES
+1 year
+trunk of 12 months
+
+Wit monitoring, without atlas
+
+Tested on  NEC SX-8R mercure at CCRT.
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/config.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/config.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/IGCM00/config.card	(revision 1844)
@@ -0,0 +1,125 @@
+#
+# This is config.card file for NEMO ORCA2_LIM_PISCES configuration
+#
+#========================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=OR2LP
+LongName="SCRIPT_V1"
+TagName=ORCA2_LIM2_PISCES
+#============================
+#-- leap, noleap, 360d
+CalendarType=noleap
+#-- Begin and end of Job
+#-- "YYYY-MM-DD"
+DateBegin=2001-01-01
+DateEnd=2005-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1Y
+#============================
+#-- PBS Class (required on brodie mono/multi)
+JobClass=mono
+#JobClass=multi
+#============================
+#-- Total Number of Processors
+#JobNumProcTot=4
+JobNumProcTot=1
+#============================
+#-- Run Options : 
+JobRunOptions=''
+#JobRunOptions='"-np "${BATCH_NUM_PROC_TOT}"'
+#============================
+#============================
+# config.card configuration options :
+#R_BC=/u/rech/psl/rpsl035/IGCM/BC
+#R_BC=/dmnfs/cont003/p86ipsl/IGCM/BC
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+OCE= (opa9, NEMO_v3)
+ICE= (lim2, LIM_2)
+MBG= (pisces, PISCES)
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=nemo
+#D- For each component, Real name of executable
+OCE= (opa_pisces_iomput, nemo)
+ICE= ("", "")
+MBG= ("", "")
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=2000-12-31
+#D- Define restart simulation name
+RestartJobName=OR2LP
+#D- Path Server Group Login
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM_PISCES
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+#D- BETA FEATURE
+RebuildFrequency=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+RebuildFromArchive=true
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=NONE
+
+#========================================================================
+#D-- OCE -
+[OCE]
+WriteFrequency="1Y 1M 5D 1D"
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=2000-12-31
+# Define restart simulation name
+RestartJobName=OR2LP1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM_PISCES
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- ICE -
+[ICE]
+WriteFrequency="5D"
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=2000-12-31
+# Define restart simulation name
+RestartJobName=OR2LP1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM_PISCES
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- MBG -
+[MBG]
+WriteFrequency="1Y 1M 5D"
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=2000-12-31
+# Define restart simulation name
+RestartJobName=OR2LP1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_LIM_PISCES
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make	(revision 1844)
@@ -0,0 +1,18019 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_bdy \
+     key_c14b \
+     key_c1d \
+     key_cfc \
+     key_coupled \
+     key_cpl_albedo \
+     key_cpl_carbon_cycle \
+     key_cpl_discharge \
+     key_cpl_ocevel \
+     key_cpl_rootexchg \
+     key_diaadd \
+     key_diaar5 \
+     key_diaeiv \
+     key_diagap \
+     key_diahdy \
+     key_diahth \
+     key_diainstant \
+     key_diaspr \
+     key_dimgout \
+     key_dtasal \
+     key_dtatem \
+     key_dtatrc \
+     key_dynldf_c1d \
+     key_dynldf_c2d \
+     key_dynldf_c3d \
+     key_dynspg_exp \
+     key_dynspg_flt \
+     key_dynspg_ts \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_floats \
+     key_flx_bulk_monthly \
+     key_flx_core \
+     key_flx_forced_daily \
+     key_gyre \
+     key_iomput \
+     key_kppcustom \
+     key_kpplktb \
+     key_kriest \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_lobster \
+     key_mpp_dyndist \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_my_trc \
+     key_noslip_accurate \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_off_degrad \
+     key_off_tra \
+     key_orca_lev10 \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_pomme_r025 \
+     key_sed \
+     key_sed_off \
+     key_top \
+     key_trabbc \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_tradmp \
+     key_traldf_ano \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trc_dia3d \
+     key_trc_diaadd \
+     key_trc_diabio \
+     key_trc_diatrd \
+     key_trc_zdfddm \
+     key_trcbbc \
+     key_trcbbl_adv \
+     key_trcbbl_dif \
+     key_trcdmp \
+     key_trcldf_eiv \
+     key_trcldf_iso \
+     key_trddyn \
+     key_trdmld \
+     key_trdmld_trc \
+     key_trdtra \
+     key_trdvor \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zco \
+     key_zdfcst \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdfric \
+     key_zdftke \
+     key_zdftke_old \
+     key_zdftmx 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_oce.o)\
+		$(MODEL_LIB)(agrif_opa_interp.o)\
+		$(MODEL_LIB)(agrif_opa_sponge.o)\
+		$(MODEL_LIB)(agrif_opa_update.o)\
+		$(MODEL_LIB)(agrif_top_interp.o)\
+		$(MODEL_LIB)(agrif_top_sponge.o)\
+		$(MODEL_LIB)(agrif_top_update.o)\
+		$(MODEL_LIB)(agrif_user.o)\
+		$(MODEL_LIB)(albedo.o)\
+		$(MODEL_LIB)(bdy_oce.o)\
+		$(MODEL_LIB)(bdy_par.o)\
+		$(MODEL_LIB)(bdydta.o)\
+		$(MODEL_LIB)(bdydyn.o)\
+		$(MODEL_LIB)(bdyini.o)\
+		$(MODEL_LIB)(bdytides.o)\
+		$(MODEL_LIB)(bdytra.o)\
+		$(MODEL_LIB)(bdyvol.o)\
+		$(MODEL_LIB)(c1d.o)\
+		$(MODEL_LIB)(cla.o)\
+		$(MODEL_LIB)(cla_div.o)\
+		$(MODEL_LIB)(cla_dynspg.o)\
+		$(MODEL_LIB)(closea.o)\
+		$(MODEL_LIB)(cpl_oasis3.o)\
+		$(MODEL_LIB)(cpl_oasis4.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(diaar5.o)\
+		$(MODEL_LIB)(diadimg.o)\
+		$(MODEL_LIB)(diafwb.o)\
+		$(MODEL_LIB)(diagap.o)\
+		$(MODEL_LIB)(diahdy.o)\
+		$(MODEL_LIB)(diahth.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(diaptr.o)\
+		$(MODEL_LIB)(diawri.o)\
+		$(MODEL_LIB)(diawri_c1d.o)\
+		$(MODEL_LIB)(divcur.o)\
+		$(MODEL_LIB)(dom_ice_2.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(domhgr.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(domvvl.o)\
+		$(MODEL_LIB)(domwri.o)\
+		$(MODEL_LIB)(domzgr.o)\
+		$(MODEL_LIB)(dtasal.o)\
+		$(MODEL_LIB)(dtatem.o)\
+		$(MODEL_LIB)(dynadv.o)\
+		$(MODEL_LIB)(dynadv_cen2.o)\
+		$(MODEL_LIB)(dynadv_ubs.o)\
+		$(MODEL_LIB)(dynbfr.o)\
+		$(MODEL_LIB)(dyncor_c1d.o)\
+		$(MODEL_LIB)(dynhpg.o)\
+		$(MODEL_LIB)(dynkeg.o)\
+		$(MODEL_LIB)(dynldf.o)\
+		$(MODEL_LIB)(dynldf_bilap.o)\
+		$(MODEL_LIB)(dynldf_bilapg.o)\
+		$(MODEL_LIB)(dynldf_iso.o)\
+		$(MODEL_LIB)(dynldf_lap.o)\
+		$(MODEL_LIB)(dynnxt.o)\
+		$(MODEL_LIB)(dynnxt_c1d.o)\
+		$(MODEL_LIB)(dynspg.o)\
+		$(MODEL_LIB)(dynspg_exp.o)\
+		$(MODEL_LIB)(dynspg_flt.o)\
+		$(MODEL_LIB)(dynspg_oce.o)\
+		$(MODEL_LIB)(dynspg_ts.o)\
+		$(MODEL_LIB)(dynvor.o)\
+		$(MODEL_LIB)(dynzad.o)\
+		$(MODEL_LIB)(dynzdf.o)\
+		$(MODEL_LIB)(dynzdf_exp.o)\
+		$(MODEL_LIB)(dynzdf_imp.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(fldread.o)\
+		$(MODEL_LIB)(flo4rk.o)\
+		$(MODEL_LIB)(flo_oce.o)\
+		$(MODEL_LIB)(floats.o)\
+		$(MODEL_LIB)(floblk.o)\
+		$(MODEL_LIB)(flodom.o)\
+		$(MODEL_LIB)(flowri.o)\
+		$(MODEL_LIB)(geo2ocean.o)\
+		$(MODEL_LIB)(ice_2.o)\
+		$(MODEL_LIB)(iceini_2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(lbcnfd.o)\
+		$(MODEL_LIB)(ldfdyn.o)\
+		$(MODEL_LIB)(ldfdyn_oce.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(limadv_2.o)\
+		$(MODEL_LIB)(limdia_2.o)\
+		$(MODEL_LIB)(limdmp_2.o)\
+		$(MODEL_LIB)(limdyn_2.o)\
+		$(MODEL_LIB)(limhdf_2.o)\
+		$(MODEL_LIB)(limistate_2.o)\
+		$(MODEL_LIB)(limmsh_2.o)\
+		$(MODEL_LIB)(limrhg_2.o)\
+		$(MODEL_LIB)(limrst_2.o)\
+		$(MODEL_LIB)(limsbc_2.o)\
+		$(MODEL_LIB)(limtab_2.o)\
+		$(MODEL_LIB)(limthd_2.o)\
+		$(MODEL_LIB)(limthd_lac_2.o)\
+		$(MODEL_LIB)(limthd_zdf_2.o)\
+		$(MODEL_LIB)(limtrp_2.o)\
+		$(MODEL_LIB)(limwri_2.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oasis4_date.o)\
+		$(MODEL_LIB)(obc_oce.o)\
+		$(MODEL_LIB)(obc_par.o)\
+		$(MODEL_LIB)(obcdta.o)\
+		$(MODEL_LIB)(obcdyn.o)\
+		$(MODEL_LIB)(obcdyn_bt.o)\
+		$(MODEL_LIB)(obcfla.o)\
+		$(MODEL_LIB)(obcini.o)\
+		$(MODEL_LIB)(obcrad.o)\
+		$(MODEL_LIB)(obcrst.o)\
+		$(MODEL_LIB)(obctra.o)\
+		$(MODEL_LIB)(obcvol.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(oce_trc.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(p4zbio.o)\
+		$(MODEL_LIB)(p4zche.o)\
+		$(MODEL_LIB)(p4zflx.o)\
+		$(MODEL_LIB)(p4zint.o)\
+		$(MODEL_LIB)(p4zlim.o)\
+		$(MODEL_LIB)(p4zlys.o)\
+		$(MODEL_LIB)(p4zmeso.o)\
+		$(MODEL_LIB)(p4zmicro.o)\
+		$(MODEL_LIB)(p4zmort.o)\
+		$(MODEL_LIB)(p4zopt.o)\
+		$(MODEL_LIB)(p4zprod.o)\
+		$(MODEL_LIB)(p4zrem.o)\
+		$(MODEL_LIB)(p4zsed.o)\
+		$(MODEL_LIB)(p4zsink.o)\
+		$(MODEL_LIB)(par_c14b.o)\
+		$(MODEL_LIB)(par_cfc.o)\
+		$(MODEL_LIB)(par_ice_2.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_lobster.o)\
+		$(MODEL_LIB)(par_my_trc.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(par_pisces.o)\
+		$(MODEL_LIB)(par_sed.o)\
+		$(MODEL_LIB)(par_trc.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(prtctl_trc.o)\
+		$(MODEL_LIB)(restart.o)\
+		$(MODEL_LIB)(sbc_ice.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcana.o)\
+		$(MODEL_LIB)(sbcblk_clio.o)\
+		$(MODEL_LIB)(sbcblk_core.o)\
+		$(MODEL_LIB)(sbccpl.o)\
+		$(MODEL_LIB)(sbcflx.o)\
+		$(MODEL_LIB)(sbcfwb.o)\
+		$(MODEL_LIB)(sbcice_if.o)\
+		$(MODEL_LIB)(sbcice_lim.o)\
+		$(MODEL_LIB)(sbcice_lim_2.o)\
+		$(MODEL_LIB)(sbcmod.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sbcssm.o)\
+		$(MODEL_LIB)(sbcssr.o)\
+		$(MODEL_LIB)(sed.o)\
+		$(MODEL_LIB)(sedadv.o)\
+		$(MODEL_LIB)(sedarr.o)\
+		$(MODEL_LIB)(sedbtb.o)\
+		$(MODEL_LIB)(sedchem.o)\
+		$(MODEL_LIB)(sedco3.o)\
+		$(MODEL_LIB)(seddsr.o)\
+		$(MODEL_LIB)(seddta.o)\
+		$(MODEL_LIB)(sedini.o)\
+		$(MODEL_LIB)(sedmat.o)\
+		$(MODEL_LIB)(sedmbc.o)\
+		$(MODEL_LIB)(sedmodel.o)\
+		$(MODEL_LIB)(sedrst.o)\
+		$(MODEL_LIB)(sedsfc.o)\
+		$(MODEL_LIB)(sedstp.o)\
+		$(MODEL_LIB)(sedwri.o)\
+		$(MODEL_LIB)(sms_lobster.o)\
+		$(MODEL_LIB)(sms_pisces.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(solmat.o)\
+		$(MODEL_LIB)(solpcg.o)\
+		$(MODEL_LIB)(solsor.o)\
+		$(MODEL_LIB)(solver.o)\
+		$(MODEL_LIB)(sshwzv.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(step_c1d.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(thd_ice_2.o)\
+		$(MODEL_LIB)(traadv.o)\
+		$(MODEL_LIB)(traadv_cen2.o)\
+		$(MODEL_LIB)(traadv_eiv.o)\
+		$(MODEL_LIB)(traadv_muscl.o)\
+		$(MODEL_LIB)(traadv_muscl2.o)\
+		$(MODEL_LIB)(traadv_qck.o)\
+		$(MODEL_LIB)(traadv_tvd.o)\
+		$(MODEL_LIB)(traadv_ubs.o)\
+		$(MODEL_LIB)(trabbc.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(tradmp.o)\
+		$(MODEL_LIB)(traldf.o)\
+		$(MODEL_LIB)(traldf_bilap.o)\
+		$(MODEL_LIB)(traldf_bilapg.o)\
+		$(MODEL_LIB)(traldf_iso.o)\
+		$(MODEL_LIB)(traldf_lap.o)\
+		$(MODEL_LIB)(tranpc.o)\
+		$(MODEL_LIB)(tranxt.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trasbc.o)\
+		$(MODEL_LIB)(trazdf.o)\
+		$(MODEL_LIB)(trazdf_exp.o)\
+		$(MODEL_LIB)(trazdf_imp.o)\
+		$(MODEL_LIB)(trc.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trcadv_cen2.o)\
+		$(MODEL_LIB)(trcadv_muscl.o)\
+		$(MODEL_LIB)(trcadv_muscl2.o)\
+		$(MODEL_LIB)(trcadv_smolar.o)\
+		$(MODEL_LIB)(trcadv_tvd.o)\
+		$(MODEL_LIB)(trcbbc.o)\
+		$(MODEL_LIB)(trcbbl.o)\
+		$(MODEL_LIB)(trcbio.o)\
+		$(MODEL_LIB)(trcctl.o)\
+		$(MODEL_LIB)(trcctl_c14b.o)\
+		$(MODEL_LIB)(trcctl_cfc.o)\
+		$(MODEL_LIB)(trcctl_lobster.o)\
+		$(MODEL_LIB)(trcctl_my_trc.o)\
+		$(MODEL_LIB)(trcctl_pisces.o)\
+		$(MODEL_LIB)(trcdia.o)\
+		$(MODEL_LIB)(trcdmp.o)\
+		$(MODEL_LIB)(trcdta.o)\
+		$(MODEL_LIB)(trcexp.o)\
+		$(MODEL_LIB)(trcini.o)\
+		$(MODEL_LIB)(trcini_c14b.o)\
+		$(MODEL_LIB)(trcini_cfc.o)\
+		$(MODEL_LIB)(trcini_lobster.o)\
+		$(MODEL_LIB)(trcini_my_trc.o)\
+		$(MODEL_LIB)(trcini_pisces.o)\
+		$(MODEL_LIB)(trcldf_bilap.o)\
+		$(MODEL_LIB)(trcldf_bilapg.o)\
+		$(MODEL_LIB)(trcldf_iso.o)\
+		$(MODEL_LIB)(trcldf_iso_zps.o)\
+		$(MODEL_LIB)(trcldf_lap.o)\
+		$(MODEL_LIB)(trclec.o)\
+		$(MODEL_LIB)(trclsm_c14b.o)\
+		$(MODEL_LIB)(trclsm_cfc.o)\
+		$(MODEL_LIB)(trclsm_lobster.o)\
+		$(MODEL_LIB)(trclsm_my_trc.o)\
+		$(MODEL_LIB)(trclsm_pisces.o)\
+		$(MODEL_LIB)(trcnxt.o)\
+		$(MODEL_LIB)(trcopt.o)\
+		$(MODEL_LIB)(trcrad.o)\
+		$(MODEL_LIB)(trcrst.o)\
+		$(MODEL_LIB)(trcsbc.o)\
+		$(MODEL_LIB)(trcsed.o)\
+		$(MODEL_LIB)(trcsms.o)\
+		$(MODEL_LIB)(trcsms_c14b.o)\
+		$(MODEL_LIB)(trcsms_cfc.o)\
+		$(MODEL_LIB)(trcsms_lobster.o)\
+		$(MODEL_LIB)(trcsms_my_trc.o)\
+		$(MODEL_LIB)(trcsms_pisces.o)\
+		$(MODEL_LIB)(trcstp.o)\
+		$(MODEL_LIB)(trctrp.o)\
+		$(MODEL_LIB)(trctrp_ctl.o)\
+		$(MODEL_LIB)(trctrp_lec.o)\
+		$(MODEL_LIB)(trcwri.o)\
+		$(MODEL_LIB)(trczdf_exp.o)\
+		$(MODEL_LIB)(trczdf_imp.o)\
+		$(MODEL_LIB)(trczdf_iso.o)\
+		$(MODEL_LIB)(trczdf_iso_vopt.o)\
+		$(MODEL_LIB)(trdicp.o)\
+		$(MODEL_LIB)(trdicp_oce.o)\
+		$(MODEL_LIB)(trdmld.o)\
+		$(MODEL_LIB)(trdmld_oce.o)\
+		$(MODEL_LIB)(trdmld_rst.o)\
+		$(MODEL_LIB)(trdmld_trc.o)\
+		$(MODEL_LIB)(trdmld_trc_oce.o)\
+		$(MODEL_LIB)(trdmld_trc_rst.o)\
+		$(MODEL_LIB)(trdmod.o)\
+		$(MODEL_LIB)(trdmod_oce.o)\
+		$(MODEL_LIB)(trdvor.o)\
+		$(MODEL_LIB)(trdvor_oce.o)\
+		$(MODEL_LIB)(trp_trc.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfbfr.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfevd.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfkpp.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zdfric.o)\
+		$(MODEL_LIB)(zdftke.o)\
+		$(MODEL_LIB)(zdftke_old.o)\
+		$(MODEL_LIB)(zdftmx.o)\
+		$(MODEL_LIB)(zpshde.o)\
+		$(MODEL_LIB)(zpshde_trc.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	agrif_oce.F90
+$(MODEL_LIB)(agrif_opa_interp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_interp.F90
+$(MODEL_LIB)(agrif_opa_sponge.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_sponge.F90
+$(MODEL_LIB)(agrif_opa_update.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	agrif_oce.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	sshwzv.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_opa_update.F90
+$(MODEL_LIB)(agrif_top_interp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	dom_oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trc.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	sol_oce.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_interp.F90
+$(MODEL_LIB)(agrif_top_sponge.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	dom_oce.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(trc.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_sponge.F90
+$(MODEL_LIB)(agrif_top_update.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	dom_oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(trc.o) \
+	agrif_oce.F90 \
+	dom_oce.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_top_update.F90
+$(MODEL_LIB)(agrif_user.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcini.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_oce.F90 \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trc.F90 \
+	trcini.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfini.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(opa.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(trc.o) \
+	agrif_oce.F90 \
+	agrif_opa_interp.F90 \
+	agrif_opa_sponge.F90 \
+	agrif_opa_update.F90 \
+	agrif_top_interp.F90 \
+	agrif_top_sponge.F90 \
+	agrif_top_update.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	opa.F90 \
+	par_oce.F90 \
+	sol_oce.F90 \
+	tradmp.F90 \
+	trc.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	agrif_user.F90
+$(MODEL_LIB)(albedo.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	in_out_manager.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	albedo.F90
+$(MODEL_LIB)(bdy_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	bdy_oce.F90
+$(MODEL_LIB)(bdy_par.o) :	\
+	KEY_CPP \
+	bdy_par.F90
+$(MODEL_LIB)(bdydta.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	bdydta.F90
+$(MODEL_LIB)(bdydyn.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdydyn.F90
+$(MODEL_LIB)(bdyini.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdyini.F90
+$(MODEL_LIB)(bdytides.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdytides.F90
+$(MODEL_LIB)(bdytra.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdytra.F90
+$(MODEL_LIB)(bdyvol.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	bdyvol.F90
+$(MODEL_LIB)(c1d.o) :	\
+	KEY_CPP \
+	c1d.F90
+$(MODEL_LIB)(cla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla.F90
+$(MODEL_LIB)(cla_div.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	cla_div.F90
+$(MODEL_LIB)(cla_dynspg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla_dynspg.F90
+$(MODEL_LIB)(closea.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	closea.F90
+$(MODEL_LIB)(cpl_oasis3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	cpl_oasis3.F90
+$(MODEL_LIB)(cpl_oasis4.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oasis4_date.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	cpl_oasis4.F90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(diaar5.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diaar5.F90
+$(MODEL_LIB)(diadimg.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diadimg.F90
+$(MODEL_LIB)(diafwb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	diafwb.F90
+$(MODEL_LIB)(diagap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diagap.F90
+$(MODEL_LIB)(diahdy.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahdy.F90
+$(MODEL_LIB)(diahth.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahth.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(diaptr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diaptr.F90
+$(MODEL_LIB)(diawri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	lib_mpp.F90 \
+	diawri_dimg.h90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri.F90
+$(MODEL_LIB)(diawri_c1d.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	trazdf_exp.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri_c1d.F90
+$(MODEL_LIB)(divcur.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	divcur.F90
+$(MODEL_LIB)(dom_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	dom_ice_2.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(domhgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	domhgr.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(domvvl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domvvl.F90
+$(MODEL_LIB)(domwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domwri.F90
+$(MODEL_LIB)(domzgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domzgr.F90
+$(MODEL_LIB)(dtasal.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtasal.F90
+$(MODEL_LIB)(dtatem.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtatem.F90
+$(MODEL_LIB)(dynadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv.F90
+$(MODEL_LIB)(dynadv_cen2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_cen2.F90
+$(MODEL_LIB)(dynadv_ubs.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_ubs.F90
+$(MODEL_LIB)(dynbfr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynbfr.F90
+$(MODEL_LIB)(dyncor_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dyncor_c1d.F90
+$(MODEL_LIB)(dynhpg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynhpg.F90
+$(MODEL_LIB)(dynkeg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynkeg.F90
+$(MODEL_LIB)(dynldf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf.F90
+$(MODEL_LIB)(dynldf_bilap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilap.F90
+$(MODEL_LIB)(dynldf_bilapg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilapg.F90
+$(MODEL_LIB)(dynldf_iso.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_iso.F90
+$(MODEL_LIB)(dynldf_lap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_lap.F90
+$(MODEL_LIB)(dynnxt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynnxt.F90
+$(MODEL_LIB)(dynnxt_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	KEY_CPP \
+	dynnxt_c1d.F90
+$(MODEL_LIB)(dynspg.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	in_out_manager.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg.F90
+$(MODEL_LIB)(dynspg_exp.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_exp.F90
+$(MODEL_LIB)(dynspg_flt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdydyn.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynspg_flt.F90
+$(MODEL_LIB)(dynspg_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dynspg_oce.F90
+$(MODEL_LIB)(dynspg_ts.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcfla.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_ts.F90
+$(MODEL_LIB)(dynvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynvor.F90
+$(MODEL_LIB)(dynzad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzad.F90
+$(MODEL_LIB)(dynzdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynzdf.F90
+$(MODEL_LIB)(dynzdf_exp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_exp.F90
+$(MODEL_LIB)(dynzdf_imp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_imp.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(fldread.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	fldread.F90
+$(MODEL_LIB)(flo4rk.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	KEY_CPP \
+	flo4rk.F90
+$(MODEL_LIB)(flo_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	flo_oce.F90
+$(MODEL_LIB)(floats.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	lib_mpp.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	floats.F90
+$(MODEL_LIB)(floblk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	floblk.F90
+$(MODEL_LIB)(flodom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flodom.F90
+$(MODEL_LIB)(flowri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flowri.F90
+$(MODEL_LIB)(geo2ocean.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	geo2ocean.F90
+$(MODEL_LIB)(ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	ice_2.F90
+$(MODEL_LIB)(iceini_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrst_2.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iceini_2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	c1d.F90 \
+	cla_dynspg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	daymod.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	restart.F90 \
+	zdf_oce.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(lbcnfd.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	lbcnfd.F90
+$(MODEL_LIB)(ldfdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	ldftra_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_antarctic.h90 \
+	ldfdyn_arctic.h90 \
+	ldfdyn_c1d.h90 \
+	ldfdyn_c2d.h90 \
+	ldfdyn_c3d.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldfdyn.F90
+$(MODEL_LIB)(ldfdyn_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldfdyn_oce.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(limadv_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limadv_2.F90
+$(MODEL_LIB)(limdia_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdia_2.F90
+$(MODEL_LIB)(limdmp_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	tradmp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdmp_2.F90
+$(MODEL_LIB)(limdyn_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limistate_2.F90 \
+	limrhg_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdyn_2.F90
+$(MODEL_LIB)(limhdf_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limhdf_2.F90
+$(MODEL_LIB)(limistate_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limistate_2.F90
+$(MODEL_LIB)(limmsh_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limmsh_2.F90
+$(MODEL_LIB)(limrhg_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limrhg_2.F90
+$(MODEL_LIB)(limrst_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	limrst_2.F90
+$(MODEL_LIB)(limsbc_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limsbc_2.F90
+$(MODEL_LIB)(limtab_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	KEY_CPP \
+	limtab_2.F90
+$(MODEL_LIB)(limthd_2.o) :	\
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limistate_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limthd_2.F90
+$(MODEL_LIB)(limthd_lac_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	ice_2.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_lac_2.F90
+$(MODEL_LIB)(limthd_zdf_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_zdf_2.F90
+$(MODEL_LIB)(limtrp_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limtrp_2.F90
+$(MODEL_LIB)(limwri_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	diadimg.F90 \
+	limwri_dimg_2.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	limwri_2.F90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trcini.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trcini.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oasis4_date.o) :	\
+	KEY_CPP \
+	oasis4_date.F90
+$(MODEL_LIB)(obc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	obc_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	obc_oce.F90
+$(MODEL_LIB)(obc_par.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	obc_par_EEL_R5.h90 \
+	obc_par_POMME_R025.h90 \
+	KEY_CPP \
+	obc_par.F90
+$(MODEL_LIB)(obcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	obcdta.F90
+$(MODEL_LIB)(obcdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn.F90
+$(MODEL_LIB)(obcdyn_bt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn_bt.F90
+$(MODEL_LIB)(obcfla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	obc_oce.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcfla.F90
+$(MODEL_LIB)(obcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcini.F90
+$(MODEL_LIB)(obcrad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcrad.F90
+$(MODEL_LIB)(obcrst.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcrst.F90
+$(MODEL_LIB)(obctra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obctra.F90
+$(MODEL_LIB)(obcvol.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcvol.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(oce_trc.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	KEY_CPP \
+	oce_trc.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_opa_sponge.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	cla.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynnxt_c1d.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trcstp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trcini.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trcini.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(p4zbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zbio.F90
+$(MODEL_LIB)(p4zche.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zche.F90
+$(MODEL_LIB)(p4zflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zflx.F90
+$(MODEL_LIB)(p4zint.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zint.F90
+$(MODEL_LIB)(p4zlim.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zlim.F90
+$(MODEL_LIB)(p4zlys.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zlys.F90
+$(MODEL_LIB)(p4zmeso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmeso.F90
+$(MODEL_LIB)(p4zmicro.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmicro.F90
+$(MODEL_LIB)(p4zmort.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmort.F90
+$(MODEL_LIB)(p4zopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zopt.F90
+$(MODEL_LIB)(p4zprod.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zprod.F90
+$(MODEL_LIB)(p4zrem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zrem.F90
+$(MODEL_LIB)(p4zsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	p4zsed.F90
+$(MODEL_LIB)(p4zsink.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zsink.F90
+$(MODEL_LIB)(par_c14b.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_c14b.F90
+$(MODEL_LIB)(par_cfc.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_cfc.F90
+$(MODEL_LIB)(par_ice_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	par_ice_2.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_lobster.o) :	\
+	KEY_CPP \
+	par_lobster.F90
+$(MODEL_LIB)(par_my_trc.o) :	\
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_my_trc.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	par_POMME_R025.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(par_pisces.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	KEY_CPP \
+	par_pisces.F90
+$(MODEL_LIB)(par_sed.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	par_kind.F90 \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_sed.F90
+$(MODEL_LIB)(par_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_trc.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(prtctl_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	prtctl_trc.F90
+$(MODEL_LIB)(restart.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	restart.F90
+$(MODEL_LIB)(sbc_ice.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_ice_2.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_ice.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcana.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcana.F90
+$(MODEL_LIB)(sbcblk_clio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_clio.F90
+$(MODEL_LIB)(sbcblk_core.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_core.F90
+$(MODEL_LIB)(sbccpl.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	phycst.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbccpl.F90
+$(MODEL_LIB)(sbcflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcflx.F90
+$(MODEL_LIB)(sbcfwb.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcfwb.F90
+$(MODEL_LIB)(sbcice_if.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcice_if.F90
+$(MODEL_LIB)(sbcice_lim.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim.F90
+$(MODEL_LIB)(sbcice_lim_2.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrhg_2.F90 \
+	limrst_2.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	tradmp.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim_2.F90
+$(MODEL_LIB)(sbcmod.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	albedo.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcmod.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sbcssm.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssm.F90
+$(MODEL_LIB)(sbcssr.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssr.F90
+$(MODEL_LIB)(sed.o) :	\
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	sed.F90
+$(MODEL_LIB)(sedadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedadv.F90
+$(MODEL_LIB)(sedarr.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_sed.o) \
+	par_sed.F90 \
+	KEY_CPP \
+	sedarr.F90
+$(MODEL_LIB)(sedbtb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	sedbtb.F90
+$(MODEL_LIB)(sedchem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	sedchem.F90
+$(MODEL_LIB)(sedco3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedco3.F90
+$(MODEL_LIB)(seddsr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	seddsr.F90
+$(MODEL_LIB)(seddta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	seddta.F90
+$(MODEL_LIB)(sedini.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddta.F90 \
+	sedrst.F90 \
+	KEY_CPP \
+	sedini.F90
+$(MODEL_LIB)(sedmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedmat.F90
+$(MODEL_LIB)(sedmbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	sed.F90 \
+	seddsr.F90 \
+	KEY_CPP \
+	sedmbc.F90
+$(MODEL_LIB)(sedmodel.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedadv.F90 \
+	sedarr.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	KEY_CPP \
+	sedmodel.F90
+$(MODEL_LIB)(sedrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedrst.F90
+$(MODEL_LIB)(sedsfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	sed.F90 \
+	sedarr.F90 \
+	seddta.F90 \
+	KEY_CPP \
+	sedsfc.F90
+$(MODEL_LIB)(sedstp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	sed.F90 \
+	sedadv.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	KEY_CPP \
+	sedstp.F90
+$(MODEL_LIB)(sedwri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	dianam.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedwri.F90
+$(MODEL_LIB)(sms_lobster.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_lobster.F90
+$(MODEL_LIB)(sms_pisces.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_pisces.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sol_oce.F90
+$(MODEL_LIB)(solmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	KEY_CPP \
+	solmat.F90
+$(MODEL_LIB)(solpcg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	solpcg.F90
+$(MODEL_LIB)(solsor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	solsor.F90
+$(MODEL_LIB)(solver.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	zdf_oce.F90 \
+	KEY_CPP \
+	solver.F90
+$(MODEL_LIB)(sshwzv.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sshwzv.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_oce.F90 \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	albedo.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynhpg.F90 \
+	dynkeg.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynzad.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obctra.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zflx.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	traqsr.F90 \
+	trazdf.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	cla.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynspg.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbccpl.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trcstp.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(step_c1d.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obctra.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traqsr.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdmld_oce.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	daymod.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynnxt_c1d.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	stpctl.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trcstp.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	step_c1d.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(thd_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	thd_ice_2.F90
+$(MODEL_LIB)(traadv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv.F90
+$(MODEL_LIB)(traadv_cen2.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_cen2.F90
+$(MODEL_LIB)(traadv_eiv.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	diaar5.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_eiv.F90
+$(MODEL_LIB)(traadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl.F90
+$(MODEL_LIB)(traadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl2.F90
+$(MODEL_LIB)(traadv_qck.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_qck.F90
+$(MODEL_LIB)(traadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_tvd.F90
+$(MODEL_LIB)(traadv_ubs.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_ubs.F90
+$(MODEL_LIB)(trabbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trabbc.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	eosbn2.F90 \
+	iom.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	trabbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(tradmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	tradmp.F90
+$(MODEL_LIB)(traldf.o) :	\
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	trazdf.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf.F90
+$(MODEL_LIB)(traldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_bilap.F90
+$(MODEL_LIB)(traldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	KEY_CPP \
+	traldf_bilapg.F90
+$(MODEL_LIB)(traldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_iso.F90
+$(MODEL_LIB)(traldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_lap.F90
+$(MODEL_LIB)(tranpc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	tranpc.F90
+$(MODEL_LIB)(tranxt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_oce.F90 \
+	bdy_oce.F90 \
+	cla_div.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	sshwzv.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obctra.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	tranxt.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traqsr.F90
+$(MODEL_LIB)(trasbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	traqsr.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trasbc.F90
+$(MODEL_LIB)(trazdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf.F90
+$(MODEL_LIB)(trazdf_exp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_exp.F90
+$(MODEL_LIB)(trazdf_imp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_imp.F90
+$(MODEL_LIB)(trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trc.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trcadv_cen2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_cen2.F90
+$(MODEL_LIB)(trcadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl.F90
+$(MODEL_LIB)(trcadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl2.F90
+$(MODEL_LIB)(trcadv_smolar.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_smolar.F90
+$(MODEL_LIB)(trcadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_tvd.F90
+$(MODEL_LIB)(trcbbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbc.F90
+$(MODEL_LIB)(trcbbl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	eosbn2.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	trcbbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbl.F90
+$(MODEL_LIB)(trcbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbio.F90
+$(MODEL_LIB)(trcctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trctrp_ctl.F90 \
+	KEY_CPP \
+	trcctl.F90
+$(MODEL_LIB)(trcctl_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_c14b.F90
+$(MODEL_LIB)(trcctl_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_cfc.F90
+$(MODEL_LIB)(trcctl_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_lobster.F90
+$(MODEL_LIB)(trcctl_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_my_trc.F90
+$(MODEL_LIB)(trcctl_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_pisces.F90
+$(MODEL_LIB)(trcdia.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdia.F90
+$(MODEL_LIB)(trcdmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdmp.F90
+$(MODEL_LIB)(trcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcdta.F90
+$(MODEL_LIB)(trcexp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcexp.F90
+$(MODEL_LIB)(trcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_ctl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	daymod.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcini.F90
+$(MODEL_LIB)(trcini_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trcini_c14b.F90
+$(MODEL_LIB)(trcini_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trcini_cfc.F90
+$(MODEL_LIB)(trcini_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_lobster.F90
+$(MODEL_LIB)(trcini_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcini_my_trc.F90
+$(MODEL_LIB)(trcini_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_pisces.F90
+$(MODEL_LIB)(trcldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilap.F90
+$(MODEL_LIB)(trcldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilapg.F90
+$(MODEL_LIB)(trcldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso.F90
+$(MODEL_LIB)(trcldf_iso_zps.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso_zps.F90
+$(MODEL_LIB)(trcldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_lap.F90
+$(MODEL_LIB)(trclec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trclec.F90
+$(MODEL_LIB)(trclsm_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trclsm_c14b.F90
+$(MODEL_LIB)(trclsm_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trclsm_cfc.F90
+$(MODEL_LIB)(trclsm_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_lobster.F90
+$(MODEL_LIB)(trclsm_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_my_trc.F90
+$(MODEL_LIB)(trclsm_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_pisces.F90
+$(MODEL_LIB)(trcnxt.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_oce.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	sol_oce.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trcnxt.F90
+$(MODEL_LIB)(trcopt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcopt.F90
+$(MODEL_LIB)(trcrad.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrad.F90
+$(MODEL_LIB)(trcrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_lec.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrst.F90
+$(MODEL_LIB)(trcsbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsbc.F90
+$(MODEL_LIB)(trcsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcsed.F90
+$(MODEL_LIB)(trcsms.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	KEY_CPP \
+	trcsms.F90
+$(MODEL_LIB)(trcsms_c14b.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_c14b.F90
+$(MODEL_LIB)(trcsms_cfc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_cfc.F90
+$(MODEL_LIB)(trcsms_lobster.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_lobster.F90
+$(MODEL_LIB)(trcsms_my_trc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_my_trc.F90
+$(MODEL_LIB)(trcsms_pisces.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_pisces.F90
+$(MODEL_LIB)(trcstp.o) :	\
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trcstp.F90
+$(MODEL_LIB)(trctrp.o) :	\
+	$(MODEL_LIB)(agrif_oce.o) \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_oce.F90 \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trctrp.F90
+$(MODEL_LIB)(trctrp_ctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_ctl.F90
+$(MODEL_LIB)(trctrp_lec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_lec.F90
+$(MODEL_LIB)(trcwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcwri.F90
+$(MODEL_LIB)(trczdf_exp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_exp.F90
+$(MODEL_LIB)(trczdf_imp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_imp.F90
+$(MODEL_LIB)(trczdf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdf.matrixsolver.h90 \
+	KEY_CPP \
+	trczdf_iso.F90
+$(MODEL_LIB)(trczdf_iso_vopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_iso_vopt.F90
+$(MODEL_LIB)(trdicp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdicp.F90
+$(MODEL_LIB)(trdicp_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdicp_oce.F90
+$(MODEL_LIB)(trdmld.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld.F90
+$(MODEL_LIB)(trdmld_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdmld_oce.F90
+$(MODEL_LIB)(trdmld_rst.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	restart.F90 \
+	trdmod_oce.F90 \
+	KEY_CPP \
+	trdmld_rst.F90
+$(MODEL_LIB)(trdmld_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	oce_trc.F90 \
+	prtctl.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld_trc.F90
+$(MODEL_LIB)(trdmld_trc_oce.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trdmld_trc_oce.F90
+$(MODEL_LIB)(trdmld_trc_rst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trdmld_trc_rst.F90
+$(MODEL_LIB)(trdmod.o) :	\
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdmod.F90
+$(MODEL_LIB)(trdmod_oce.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	KEY_CPP \
+	trdmod_oce.F90
+$(MODEL_LIB)(trdvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdvor.F90
+$(MODEL_LIB)(trdvor_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdvor_oce.F90
+$(MODEL_LIB)(trp_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trp_trc.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfbfr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfbfr.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfevd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfevd.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	restart.F90 \
+	tranpc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfkpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	zdfkpp.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zdfric.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfric.F90
+$(MODEL_LIB)(zdftke.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke.F90
+$(MODEL_LIB)(zdftke_old.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke_old.F90
+$(MODEL_LIB)(zdftmx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftmx.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+$(MODEL_LIB)(zpshde_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde_trc.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2 IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_tradmp key_trabbc key_zdftke key_zdfddm key_top key_pisces key_dtatrc key_trcbbl_dif key_trcldf_eiv key_trc_zdfddm key_trc_diaadd key_trc_dia3d key_iomput 
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Header$
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,166 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 3:00:00                # Max total CPU time
+#-Q- sxnec #@$-lt 2:59:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 4Gb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 14200
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 4.8Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=4.6gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=3:30:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=3:30:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=4.6gb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=3:30:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      ORCA2_LIM configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories : 
+#- Input file storing 
+#-Q- sxnec R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8brodie R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- aix R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8mercure R_FORCING="/dmnfs10/cont003/p48ethe/FORCINGS/ORCA_R2/NEMO"
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/ORCA2_OFF_PISCES
+#- execution repository
+R_TMP=$TMPDIR         
+
+##-- define processus number : to change when running in mpp
+NB_PROC=1
+
+#################################
+# End of user modification
+#################################
+
+#--  define a fonction to get the input tarfile
+#-Q- sxnec Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8brodie Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- aix Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8mercure Rapatrie () { [ -f $1/$2 ] || ( cp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+
+#- Namelist for the configuration
+cp ${R_EXPER}/namelist            namelist
+cp ${R_EXPER}/namelist_top        namelist_top
+cp ${R_EXPER}/namelist_pisces     namelist_pisces
+cp ${R_EXPER}/kRGB61.txt          kRGB61.txt
+
+ls -alF
+
+#- Files for the configuration 
+Rapatrie ${R_TMP} INPUTS_INIT_v3.tar
+Rapatrie ${R_TMP} INPUTS_DYNA_v3.tar
+Rapatrie ${R_TMP} INPUTS_PISCES_v3.tar
+
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT *ocean.output ${R_SORTIE_OCE}/.
+$DPUT *solver.stat ${R_SORTIE_OCE}/.
+[ -f *mpp.output* ] && $DPUT *mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_diad_T*.nc *_ptrc_T*.nc
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf}
+done
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT ${restart} ${R_SORTIE_OCE}/${restart} 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,233 @@
+<?xml version="1.0"?>
+<simulation> 
+  
+  <context id="nemo">
+
+    <!-- $id$ -->
+ 
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+
+  <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+ 
+      <!-- ptrc on T grid -->
+          
+     <group id="ptrc_T" axis_ref="deptht" grid_ref="grid_T">  
+       <field id="DIC"      description="Dissolved inorganic Concentration"        unit="mol-C/L" />
+       <field id="Alkalini" description="Total Alkalinity Concentration"           unit="eq/L"    />
+       <field id="O2"       description="Oxygen Concentration"                     unit="mol-C/L" />
+       <field id="CaCO3"    description="Calcite Concentration"                    unit="mol-C/L" />
+       <field id="PO4"      description="Phosphate Concentration"                  unit="mol-C/L" />
+       <field id="POC"      description="Small organic carbon Concentration"       unit="mol-C/L" />
+       <field id="Si"       description="Silicate Concentration"                   unit="mol-C/L" />
+       <field id="PHY"      description="Nanophytoplankton Concentration"          unit="mol-C/L" />
+       <field id="ZOO"      description="Microzooplankton Concentration"           unit="mol-C/L" />
+       <field id="DOC"      description="Dissolved organic Concentration"          unit="mol-C/L" />
+       <field id="PHY2"     description="Diatoms Concentration"                    unit="mol-C/L" />
+       <field id="ZOO2"     description="Mesozooplankton Concentration"            unit="mol-C/L" />
+       <field id="BSi"      description="Diatoms Silicate Concentration"           unit="mol-C/L" />
+       <field id="Fer"      description="Dissolved Iron Concentration"             unit="mol-C/L" />
+       <field id="BFe"      description="Big iron particles Concentration"         unit="mol-C/L" />
+       <field id="GOC"      description="Big organic carbon Concentration"         unit="mol-C/L" />
+       <field id="SFe"      description="Small iron particles Concentration"       unit="mol-C/L" />
+       <field id="DFe"      description="Diatoms iron  Concentration"              unit="mol-C/L" />
+       <field id="DSi"      description="Sinking biogenic Silicate Concentration"  unit="mol-C/L" />
+       <field id="NFe"      description="Nano iron Concentration"                  unit="mol-C/L" />
+       <field id="NCHL"     description="Nano chlorophyl Concentration"            unit="mol-C/L" />
+       <field id="DCHL"     description="Diatoms chlorophyl Concentration"         unit="mol-C/L" />
+       <field id="NO3"      description="Nitrates Concentration"                   unit="mol-C/L" />
+       <field id="NH4"      description="Ammonium Concentration"                   unit="mol-C/L" />
+     </group>
+
+      <!-- diad on T grid -->
+
+     <group id="diad_T" axis_ref="none" grid_ref="grid_T">
+       <field id="PH"          description="PH"                                       unit="-"            axis_ref="deptht" />
+       <field id="CO3"         description="Bicarbonates"                             unit="mol/L"        axis_ref="deptht" />
+       <field id="CO3sat"      description="CO3 saturation"                           unit="mol/L"        axis_ref="deptht" />
+       <field id="PAR"         description="Photosynthetically Available Radiation"   unit="W/m2"         axis_ref="deptht" />
+       <field id="PPPHY"       description="Primary production of nanophyto"          unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPPHY2"      description="Primary production of diatoms"            unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPNEWN"      description="New Primary production of nanophyto"      unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PPNEWD"      description="New Primary production of diatoms"        unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="PBSi"        description="Primary production of Si diatoms"         unit="mol-Si/m3/s"  axis_ref="deptht" />
+       <field id="PFeN"        description="Primary production of nano iron"          unit="mol-Fe/m3/s"  axis_ref="deptht" />
+       <field id="PFeD"        description="Primary production of diatoms iron"       unit="mol-Fe/m3/s"  axis_ref="deptht" />
+       <field id="PCAL"        description="Calcite production"                       unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="DCAL"        description="Calcite dissolution"                      unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="GRAZ"        description="Grazing by zooplankton"                   unit="mol-C/m3/s"   axis_ref="deptht" />
+       <field id="Nfix"        description="Nitrogen fixation at surface"             unit="mol-N/m2/s"      />
+       <field id="EPC100"      description="Export of carbon particles at 100 m"      unit="mol-C/m2/s"      />
+       <field id="EPFE100"     description="Export of biogenic iron at 100 m"         unit="mol-Fe/m2/s"     />
+       <field id="EPSI100"     description="Export of Silicate at 100 m"              unit="mol-Si/m2/s"     />
+       <field id="EPCAL100"    description="Export of Calcite at 100 m"               unit="mol-C/m2/s"      />
+       <field id="Cflx"        description="DIC flux"                                 unit="mol-C/m2/s" />
+       <field id="Oflx"        description="Oxygen flux"                              unit="mol-C/m2/s" />
+       <field id="Kg"          description="Gas transfer"                             unit="mol-C/m2/s/uatm" />
+       <field id="Dpco2"       description="Delta CO2"                                unit="uatm" />
+       <field id="Dpo2"        description="Delta O2"                                 unit="uatm" />
+       <field id="Heup"        description="Euphotic layer depth"                     unit="m" />
+       <field id="Irondep"     description="Iron deposition"                          unit="mol-Fe/m2/s" />
+     </group>
+
+      <!-- scalar -->
+      
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+      </group>
+
+  </field_definition>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+
+  <file_definition output_level="10" enabled=".TRUE.">
+   
+      <group id="1d" output_freq="86400"  output_level="10" enabled=".TRUE.">                      <!-- 1d files -->
+      </group>
+
+      <group id="5d" output_freq="432000" output_level="10" enabled=".TRUE.">                      <!-- 5d files -->
+
+        <file id="5d_diad_T" name="auto" description="additional pisces diagnostics" >
+          <field ref="Cflx"     />
+          <field ref="Oflx"     />
+          <field ref="Dpco2"    />
+          <field ref="Dpo2"     />
+          <field ref="Heup"     />
+        </file>
+      
+      </group>
+ 
+      <group id="1m" output_freq="-1"     output_level="10" enabled=".TRUE.">                      <!-- real monthly files -->
+
+        <file id="1m_ptrc_T" name="auto" description="pisces sms variables" >
+          <field ref="DIC"      />
+          <field ref="Alkalini" />
+          <field ref="O2"       />
+          <field ref="NCHL"     />
+          <field ref="DCHL"     />
+          <field ref="Fer"      />
+          <field ref="NO3"      />
+       </file>
+
+      </group>
+
+      <group id="2m" output_freq="-2"     output_level="10" enabled=".TRUE.">                      <!-- real 2m files -->
+      </group>
+
+      <group id="3m" output_freq="-3"     output_level="10" enabled=".TRUE.">                      <!-- real 3m files -->
+      </group>
+
+      <group id="4m" output_freq="-4"     output_level="10" enabled=".TRUE.">                      <!-- real 4m files -->
+      </group>
+
+      <group id="6m" output_freq="-6"     output_level="10" enabled=".TRUE.">                      <!-- real 6m files -->
+      </group>
+
+      <group id="1y" output_freq="-12"    output_level="10" enabled=".TRUE.">                      <!-- real yearly files -->
+        
+        <file id="1y_ptrc_T" name="auto" description="pisces sms variables" >
+          <field ref="DIC"      />
+          <field ref="Alkalini" />
+          <field ref="O2"       />
+          <field ref="CaCO3"    />
+          <field ref="PO4"      />
+          <field ref="POC"      />
+          <field ref="Si"       />
+          <field ref="PHY"      />
+          <field ref="ZOO"      />
+          <field ref="DOC"      />
+          <field ref="PHY2"     />
+          <field ref="ZOO2"     />
+          <field ref="BSi"      />
+          <field ref="Fer"      />
+          <field ref="BFe"      />
+          <field ref="GOC"      />
+          <field ref="SFe"      />
+          <field ref="DFe"      />
+          <field ref="DSi"      />
+          <field ref="NFe"      />
+          <field ref="NCHL"     />
+          <field ref="DCHL"     />
+          <field ref="NO3"      />
+          <field ref="NH4"      />
+       </file>
+
+       <file id="1y_diad_T" name="auto" description="additional pisces diagnostics" >
+          <field ref="PH"       />
+          <field ref="CO3"      />
+          <field ref="CO3sat"   />
+          <field ref="PAR"      />
+          <field ref="PPPHY"    />
+          <field ref="PPPHY2"   />
+          <field ref="PPNEWN"   />
+          <field ref="PPNEWD"   />
+          <field ref="PBSi"     />
+          <field ref="PFeN"     />
+          <field ref="PFeD"     />
+          <field ref="PCAL"     />
+          <field ref="DCAL"     />
+          <field ref="GRAZ"     />
+          <field ref="EPC100"   />
+          <field ref="EPFE100"  />
+          <field ref="EPSI100"  />
+          <field ref="EPCAL100" />
+          <field ref="Cflx"     />
+          <field ref="Oflx"     />
+          <field ref="Kg"       />
+          <field ref="Dpco2"    />
+          <field ref="Dpo2"     />
+          <field ref="Heup"     />
+          <field ref="Irondep"  />
+          <field ref="Nfix"     />
+       </file>
+
+      </group>
+
+      <group id="2y"  output_freq="-24"   output_level="10" enabled=".TRUE.">                      <!-- real 2y files -->
+      </group>
+
+      <group id="5y"  output_freq="-60"   output_level="10" enabled=".TRUE.">                      <!-- real 5y files -->
+      </group>
+
+      <group id="10y" output_freq="-120"  output_level="10" enabled=".TRUE.">                      <!-- real 10y files -->
+      </group>
+    
+  </file_definition>
+
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+
+  <axis_definition>  
+     <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+     <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+     <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+     <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+     <axis id="none" description="axe non defini" unit="none" size="1" />
+  </axis_definition> 
+
+  <grid_definition>
+    <grid id="grid_T" description="grid T" />
+    <grid id="grid_U" description="grid U" />
+    <grid id="grid_V" description="grid V" />
+    <grid id="grid_W" description="grid W" />
+    <grid id="scalarpoint" description="scalar" >
+      <zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+    </grid>
+  </grid_definition>
+
+</context>
+
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/kRGB61.txt
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/kRGB61.txt	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/kRGB61.txt	(revision 1844)
@@ -0,0 +1,61 @@
+  0.010    0.01618   0.07464   0.37807
+  0.011    0.01654   0.07480   0.37823
+  0.013    0.01693   0.07499   0.37840
+  0.014    0.01736   0.07518   0.37859
+  0.016    0.01782   0.07539   0.37879
+  0.018    0.01831   0.07562   0.37900
+  0.020    0.01885   0.07586   0.37923
+  0.022    0.01943   0.07613   0.37948
+  0.025    0.02005   0.07641   0.37976
+  0.028    0.02073   0.07672   0.38005
+  0.032    0.02146   0.07705   0.38036
+  0.035    0.02224   0.07741   0.38070
+  0.040    0.02310   0.07780   0.38107
+  0.045    0.02402   0.07821   0.38146
+  0.050    0.02501   0.07866   0.38189
+  0.056    0.02608   0.07914   0.38235
+  0.063    0.02724   0.07967   0.38285
+  0.071    0.02849   0.08023   0.38338
+  0.079    0.02984   0.08083   0.38396
+  0.089    0.03131   0.08149   0.38458
+  0.100    0.03288   0.08219   0.38526
+  0.112    0.03459   0.08295   0.38598
+  0.126    0.03643   0.08377   0.38676
+  0.141    0.03842   0.08466   0.38761
+  0.158    0.04057   0.08561   0.38852
+  0.178    0.04289   0.08664   0.38950
+  0.200    0.04540   0.08775   0.39056
+  0.224    0.04811   0.08894   0.39171
+  0.251    0.05103   0.09023   0.39294
+  0.282    0.05420   0.09162   0.39428
+  0.316    0.05761   0.09312   0.39572
+  0.355    0.06130   0.09474   0.39727
+  0.398    0.06529   0.09649   0.39894
+  0.447    0.06959   0.09837   0.40075
+  0.501    0.07424   0.10040   0.40270
+  0.562    0.07927   0.10259   0.40480
+  0.631    0.08470   0.10495   0.40707
+  0.708    0.09056   0.10749   0.40952
+  0.794    0.09690   0.11024   0.41216
+  0.891    0.10374   0.11320   0.41502
+  1.000    0.11114   0.11639   0.41809
+  1.122    0.11912   0.11984   0.42142
+  1.259    0.12775   0.12356   0.42500
+  1.413    0.13707   0.12757   0.42887
+  1.585    0.14715   0.13189   0.43304
+  1.778    0.15803   0.13655   0.43754
+  1.995    0.16978   0.14158   0.44240
+  2.239    0.18248   0.14701   0.44765
+  2.512    0.19620   0.15286   0.45331
+  2.818    0.21102   0.15918   0.45942
+  3.162    0.22703   0.16599   0.46601
+  3.548    0.24433   0.17334   0.47313
+  3.981    0.26301   0.18126   0.48080
+  4.467    0.28320   0.18981   0.48909
+  5.012    0.30502   0.19903   0.49803
+  5.623    0.32858   0.20898   0.50768
+  6.310    0.35404   0.21971   0.51810
+  7.079    0.38154   0.23129   0.52934
+  7.943    0.41125   0.24378   0.54147
+  8.912    0.44336   0.25725   0.55457
+ 10.000    0.47804   0.27178   0.56870
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 1844)
@@ -0,0 +1,135 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - miscellaneous    (namctl,nammpp)
+!!              3 - Domain           (namzgr, namzgr_sco, namdom)
+!!              6 - Tracer           (nameos, namcla, namqsr)
+!!              7 - Inputs dynamics  (namdyna)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   no          =       0   !  job number
+   cexper      =  "PISCES"  !  experience name 
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nrstdt      =       0   !  restart control = 0 nit000 is not compared to the restart file value
+                           !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                           !                  = 2 calendar parameters read in the restart file
+   nit000      =       1   !  first time step
+   nitend      =     1460  !  last  time step
+   ndate0      =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nleapy      =       0   !  Leap year calendar (1) or not (0)
+   ninist      =       0   !  output the initial state (1) or not (0)
+   nstock      =     1460  !  frequency of creation of a restart file (modulo referenced to 1)
+   nwrite      =     1460  !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+/
+!-----------------------------------------------------------------------
+&namctl       !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl     = .false.    !  trends control print (expensive!)
+   nprint     =    0       !  level of print (0 no extra print)
+   nictls     =    1       !  start i indice of control sum (use to compare mono versus
+   nictle     =    182       !  end   i indice of control sum        multi processor runs
+   njctls     =    1       !  start j indice of control               over a subdomain)
+   njctle     =    149       !  end   j indice of control 
+   isplt      =    1       !  number of processors in i-direction
+   jsplt      =    1       !  number of processors in j-direction
+   nbench     =    0       !  Bench mode (1/0): CAUTION use zero except for bench
+/
+!-----------------------------------------------------------------------
+&nammpp      !   Massively Parallel Processing                         ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   c_mpi_send =  'S'       !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+/
+!-----------------------------------------------------------------------
+&namzgr       !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco   !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   sbot_min    =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   sbot_max    = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   theta       =    6.0    !  surface control parameter (0<=theta<=20)
+   thetb       =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   r_max       =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   e3zps_min   =    25.    !  the thickness of the partial step is set larger than the minimum
+   e3zps_rat   =    0.2    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+   nmsh        =    1      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   nacc        =    0      !  =1 acceleration of convergence method used, rdt < rdttra(k)
+                           !  =0, no acceleration, rdt = rdttra
+   atfp        =    0.1    !  asselin time filter parameter
+   rdt         = 21600.    !  time step for the dynamics (and tracer if nacc=0)
+   rdtmin      = 21600.    !  minimum time step on tracers (used if nacc=1)
+   rdtmax      = 21600.    !  maximum time step on tracers (used if nacc=1)
+   rdth        =  800.     !  depth variation of tracer time step  (used if nacc=1)
+/
+!-----------------------------------------------------------------------
+&namtraldf    !   lateral diffusion scheme for tracer
+!-----------------------------------------------------------------------
+!                               !  Type of the operator :
+   ln_traldf_lap    =  .true.   !     laplacian operator
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator
+                                !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+!                               !  Coefficient
+   aht0        =  2000.         !     horizontal eddy diffusivity for tracers [m2/s]
+   ahtb0       =     0.         !     background eddy diffusivity for ldf_iso [m2/s]
+   aeiv0       =  2000.         !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   n_cla       =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namqsr        !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/  
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   neos        =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   ralpha      =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rbeta       =    0.001  !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namdyn        !   offline parameters 
+!-----------------------------------------------------------------------
+    ndtadyn   =  73        ! number of period in the file for one year    
+    ndtatot   =  73        ! total number of period in the file    
+    nsptint   =  1         ! indicator for time interpolation    
+    nficdyn   =  2         ! number of file to read    
+    lperdyn   = .true.     ! periodicity of the unique file (T)
+!                          ! F  (default)   computed with Blanke' scheme 
+    cfile_grid_T = 'NEMOV3_5d_21210101_21211231_grid_T.nc' ! name of grid_T file
+    cfile_grid_U = 'NEMOV3_5d_21210101_21211231_grid_U.nc' ! name of grid_U file
+    cfile_grid_V = 'NEMOV3_5d_21210101_21211231_grid_V.nc' ! name of grid_V file
+    cfile_grid_W = 'NEMOV3_5d_21210101_21211231_grid_W.nc' ! name of grid_W file
+/
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 1844)
@@ -0,0 +1,178 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! PISCES  :    1  - air-sea exchange                         (nampisext)
+!! namelists    2  - biological parameters                    (nampisbio)
+!!              3  - parameters for nutrient limitations      (nampislim)    
+!!              4  - parameters for phytoplankton             (nampisprod,nampismort)
+!!              5  - parameters for zooplankton               (nampismes,nampiszoo)
+!!              6  - parameters for remineralization          (nampisrem)
+!!              7  - parameters for calcite chemistry         (nampiscal)
+!!              8  - parameters for inputs deposition         (nampissed)
+!!              9  - parameters for Kriest parameterization   (nampiskrp, nampiskrs)
+!!              10 - additional 2D/3D  diagnostics            (nampisdia)
+!!              11 - Damping                                  (nampisdmp)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisext     !   air-sea exchange
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   atcco2     = 287.    ! atmospheric pCO2
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisbio     !   biological parameters
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   part       =  0.85    ! part of calcite not dissolved in guts
+   nrdttrc    =  4       ! time step frequency for biology
+   wsbio      =  2.      ! POC sinking speed
+   xkmort     =  1.E-7   ! half saturation constant for mortality
+   ferat3     =  3.E-6   ! Fe/C in zooplankton 
+   wsbio2     =  30.     ! Big particles sinking speed
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampislim     !   parameters for nutrient limitations
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   conc0      =  2.e-6    ! Phosphate half saturation
+   conc1      =  10E-6    ! Phosphate half saturation for diatoms
+   conc2      =  0.01E-9  ! Iron half saturation for phyto
+   conc2m     =  0.08E-9  ! Max iron half saturation for phyto
+   conc3      =  0.1E-9   ! Iron half saturation for diatoms
+   conc3m     =  0.4E-9   ! Maxi iron half saturation for diatoms
+   concnnh4   =  1.E-7    ! NH4 half saturation for phyto
+   concdnh4   =  5.E-7    ! NH4 half saturation for diatoms
+   xksi1      =  2.E-6    ! half saturation constant for Si uptake
+   xksi2      =  3.33E-6  ! half saturation constant for Si/C
+   xkdoc      =  417.E-6  ! half-saturation constant of DOC remineralization
+   caco3r     =  0.3      ! mean rain ratio
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisprod     !   parameters for phytoplankton growth
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   pislope    =  3.       ! P-I slope  
+   pislope2   =  3.       ! P-I slope  for diatoms
+   excret     =  0.05     ! excretion ratio of phytoplankton
+   excret2    =  0.05     ! excretion ratio of diatoms
+   chlcnm     =  0.033    ! Minimum Chl/C in nanophytoplankton
+   chlcdm     =  0.05     ! Minimum Chl/C in diatoms
+   fecnm      =  10E-6    ! Maximum Fe/C in nanophytoplankton
+   fecdm      =  15E-6    ! Minimum Fe/C in diatoms
+   grosip     =  0.151    ! mean Si/C ratio
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismort     !   parameters for phytoplankton sinks
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   wchl       =  0.001    ! quadratic mortality of phytoplankton
+   wchld      =  0.02     ! maximum quadratic mortality of diatoms
+   mprat      =  0.01     ! phytoplankton mortality rate
+   mprat2     =  0.01     ! Diatoms mortality rate
+   mpratm     =  0.01     ! Phytoplankton minimum mortality rate
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismes     !   parameters for mesozooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   grazrat2   =  0.7      ! maximal mesozoo grazing rate
+   resrat2    =  0.005    ! exsudation rate of mesozooplankton
+   mzrat2     =  0.03     ! mesozooplankton mortality rate
+   xprefc     =  1.       ! zoo preference for phyto
+   xprefp     =  0.2      ! zoo preference for POC
+   xprefz     =  1.       ! zoo preference for zoo
+   xprefpoc   =  0.2      ! zoo preference for poc
+   xkgraz2    =  20.E-6   ! half sturation constant for meso grazing
+   epsher2    =  0.33     ! Efficicency of Mesozoo growth 
+   sigma2     =  0.6      ! Fraction of mesozoo excretion as DOM
+   unass2     =  0.3      ! non assimilated fraction of P by mesozoo
+   grazflux   =  5.e3     ! flux-feeding rate
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiszoo     !   parameters for microzooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   grazrat    =  4.0      ! maximal zoo grazing rate   
+   resrat     =  0.03     ! exsudation rate of zooplankton
+   mzrat      =  0.0      ! zooplankton mortality rate
+   xpref2c    =  0.1      ! Microzoo preference for POM 
+   xpref2p    =  0.45     ! Microzoo preference for Nanophyto
+   xpref2d    =  0.45     ! Microzoo preference for Diatoms
+   xkgraz     =  20.E-6   ! half sturation constant for grazing 
+   epsher     =  0.33     ! Efficiency of microzoo growth
+   sigma1     =  0.6      ! Fraction of microzoo excretion as DOM
+   unass      =  0.3      ! non assimilated fraction of phyto by zoo
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisrem     !   parameters for remineralization
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xremik    =  0.3       ! remineralization rate of DOC
+   xremip    =  0.025     ! remineralisation rate of POC
+   nitrif    =  0.05      ! NH4 nitrification rate
+   xsirem    =  0.015     ! remineralization rate of Si
+   xlam1     =  0.005     ! scavenging rate of Iron
+   oxymin    =  1.E-6     ! Half-saturation constant for anoxia 
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiscal     !   parameters for Calcite chemistry
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   kdca       =  0.327e3  ! calcite dissolution rate constant (1/time)
+   nca        =  1.       ! order of dissolution reaction (dimensionless)
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampissed     !   parameters for inputs deposition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_dustfer  =  .true.   ! boolean for dust input from the atmosphere
+   ln_river    =  .false.   ! boolean for river input of nutrients
+   ln_ndepo    =  .true.   ! boolean for atmospheric deposition of N
+   ln_sedinput =  .true.   ! boolean for Fe input from sediments
+   sedfeinput  =  1E-9     ! Coastal release of Iron
+   dustsolub   =  0.014    ! Solubility of the dust
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiskrp     !   Kriest parameterization : parameters     "key_kriest"
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xkr_eta      = 1.17    ! Sinking  exponent
+   xkr_zeta     = 2.28    ! N content exponent
+   xkr_mass_min = 0.0002  ! Minimum mass for Aggregates
+   xkr_mass_max = 1.      ! Maximum mass for Aggregates
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiskrs     !   Kriest parameterization : size classes  "key_kriest"
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   xkr_sfact    = 942.    ! Sinking factor
+   xkr_stick    = 0.5     ! Stickiness
+   xkr_nnano    = 2.337   ! Nbr of cell in nano size class
+   xkr_ndiat    = 3.718   ! Nbr of cell in diatoms size class
+   xkr_nmeso    = 7.147   ! Nbr of cell in mesozoo size class
+   xkr_naggr    = 9.877   ! Nbr of cell in aggregates  size class
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisdia     !   additional 2D/3D tracers diagnostics ("key_trc_diaadd")
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   nwritedia   =  1460     !  time step frequency for tracers diagnostics
+!
+!              !    name   !           title of the field          !     units      !
+!              !           !                                       !                !  
+   pisdia2d(1)  = 'Cflx     ' , 'DIC flux                          ',  'molC/m2/s    '
+   pisdia2d(2)  = 'Oflx     ' , 'Oxygen flux                       ',  'molC/m2/s    '
+   pisdia2d(3)  = 'Kg       ' , 'Gas transfer                      ',  'mol/m2/s/uatm'
+   pisdia2d(4)  = 'Delc     ' , 'Delta CO2                         ',  'uatm         '
+   pisdia2d(5)  = 'PMO      ' , 'POC export                        ',  'molC/m2/s    '
+   pisdia2d(6)  = 'PMO2     ' , 'GOC export                        ',  'molC/m2/s    '
+   pisdia2d(7)  = 'ExpFe1   ' , 'Nano iron export                  ',  'molFe/m2/s   '
+   pisdia2d(8)  = 'ExpFe2   ' , 'Diatoms iron export               ',  'molFe/m2/s   '
+   pisdia2d(9)  = 'ExpSi    ' , 'Silicate export                   ',  'molSi/m2/s   '
+   pisdia2d(10) = 'ExpCaCO3 ' , 'Calcite export                    ',  'molC/m2/s    '
+   pisdia2d(11) = 'heup     ' , 'euphotic layer depth              ',  'm            '
+   pisdia2d(12) = 'Fedep    ' , 'Iron dep                          ',  'molFe/m2/s   '
+   pisdia2d(13) = 'Nfix     ' , 'Nitrogen Fixation                 ',  'molN/m2/s    '
+   pisdia3d(1)  = 'PH       ' , 'PH                                ',  '-            '
+   pisdia3d(2)  = 'CO3      ' , 'Bicarbonates                      ',  'mol/l        '
+   pisdia3d(3)  = 'CO3sat   ' , 'CO3 saturation                    ',  'mol/l        '
+   pisdia3d(4)  = 'PAR      ' , 'light penetration                 ',  'W/m2         '
+   pisdia3d(5)  = 'PPPHY    ' , 'Primary production of nanophyto   ',  'molC/m3/s    '
+   pisdia3d(6)  = 'PPPHY2   ' , 'Primary production of diatoms     ',  'molC/m3/s    '
+   pisdia3d(7)  = 'PPNEWN   ' , 'New Primary production of nano    ',  'molC/m3/s    '
+   pisdia3d(8)  = 'PPNEWD   ' , 'New Primary production of diat    ',  'molC/m3/s    '
+   pisdia3d(9)  = 'PBSi     ' , 'Primary production of Si diatoms  ',  'molSi/m3/s   '
+   pisdia3d(10) = 'PFeN     ' , 'Primary production of nano iron   ',  'molFe/m3/s   '
+   pisdia3d(11) = 'PFeD     ' , 'Primary production of diatoms iron',  'molFe/m3/s   '
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisdmp     !  Damping 
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_pisdmp    =  .true.     !  Relaxation fo some tracers to a mean value
+   ln_pisclo    =  .false.    !  Restoring of tracer to initial value on closed sea ("key_dtatrc")
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top	(revision 1844)
@@ -0,0 +1,143 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  1 - tracer definition                     (namtoptrc)
+!! namelists    2 - dynamical tracer trends               (namtoptrd)
+!!              6 - tracer advection                      (namtopadv)
+!!              7 - tracer bottom boundary                (namtopbbl)
+!!              8 - tracer lateral diffusion              (namtopldf)
+!!              3 - tracer vertical physics               (namtopzdf)
+!!              9 - tracer newtonian damping              (namtopdmp)
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&namtoptrc     !   tracers definition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ndttrc      =  1        !  time step frequency for passive tracers      
+   nwritetrc   =  1460     !  time step frequency for tracer outputs
+   ln_rsttr    = .false.   !  start from a restart file (T) or not (F)
+   nrsttr      =   0       !  restart control = 0 initial time step is not compared to the restart file value
+                           !                  = 1 do not use the value in the restart file
+                           !                  = 2 calendar parameters read in the restart file
+   cn_trcrst_in  = "restart_trc"   !  suffix of pass. tracer restart name (input)
+   cn_trcrst_out = "restart_trc"   !  suffix of pass. tracer restart name (output)
+!
+!              !    name   !           title of the field              !   units    ! initial data ! save   !
+!              !           !                                           !            ! from file    ! or not ! 
+!              !           !                                           !            ! or not       !        !
+   tracer(1)   = 'DIC     ' , 'Dissolved inorganic Concentration      ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(2)   = 'Alkalini' , 'Total Alkalinity Concentration         ',  'eq/L '   ,  .true.     ,  .true.
+   tracer(3)   = 'O2      ' , 'Dissolved Oxygen Concentration         ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(4)   = 'CaCO3   ' , 'Calcite Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(5)   = 'PO4     ' , 'Phosphate Concentration                ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(6)   = 'POC     ' , 'Small organic carbon Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(7)   = 'Si      ' , 'Silicate Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(8)   = 'PHY     ' , 'Nanophytoplankton Concentration        ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(9)   = 'ZOO     ' , 'Microzooplankton Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(10)  = 'DOC     ' , 'Dissolved organic Concentration        ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(11)  = 'PHY2    ' , 'Diatoms Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(12)  = 'ZOO2    ' , 'Mesozooplankton Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(13)  = 'BSi     ' , 'Diatoms Silicate Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(14)  = 'Fer     ' , 'Dissolved Iron Concentration           ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(15)  = 'BFe     ' , 'Big iron particles Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(16)  = 'GOC     ' , 'Big organic carbon Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(17)  = 'SFe     ' , 'Small iron particles Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(18)  = 'DFe     ' , 'Diatoms iron  Concentration            ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(19)  = 'DSi     ' , 'Sinking biogenic Silicate Concentration',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(20)  = 'NFe     ' , 'Nano iron Concentration                ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(21)  = 'NCHL    ' , 'Nano chlorophyl Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(22)  = 'DCHL    ' , 'Diatoms chlorophyl Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   tracer(23)  = 'NO3     ' , 'Nitrates Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   tracer(24)  = 'NH4     ' , 'Ammonium Concentration                 ',  'mol-C/L' ,  .false.    ,  .true.
+/
+!-----------------------------------------------------------------------
+&namtopadv    !   advection scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_trcadv_tvd    =  .false.  !  TVD scheme   
+   ln_trcadv_muscl  =  .true.   !  MUSCL scheme
+   ln_trcadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_trcadv_smolar =  .false.  !  SMOLAR scheme
+   rsc              =  1.       !  tuning coefficient for Smol-Car. scheme 
+   ncortrc          =  1        !  number of corrective phases for Smol-Car. scheme 
+   crosster         =  .false.  !  computes Smol-Car crossterms (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopbbl    !   bottom boundary layer scheme for passive tracer 
+!-----------------------------------------------------------------------
+   atrcbbl          = 1000.     !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!-----------------------------------------------------------------------
+&namtopldf    !   lateral diffusion scheme for passive tracer 
+!-----------------------------------------------------------------------
+   ln_trcldf_diff   =  .true.   !  performs lateral diffusion (T) or not (F)
+!                               !  Type of the operator : 
+   ln_trcldf_lap    =  .true.   !     laplacian operator       
+   ln_trcldf_bilap  =  .false.  !     bilaplacian operator     
+                                !  Direction of action  :
+   ln_trcldf_level  =  .false.  !     iso-level                
+   ln_trcldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_trcldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+!                               !  Coefficient
+   ahtrc0      =  2000.         !     horizontal eddy diffusivity for tracers [m2/s]
+   ahtrb0      =     0.         !     background eddy diffusivity for ldf_iso [m2/s]
+   aeivtr0     =  2000.         !     eddy induced velocity coefficient [m2/s]    (require "key_trcldf_eiv")
+   trcrat      =  1.            !  ratio betweeen passive and active tracer diffusion coeff
+/
+!-----------------------------------------------------------------------
+&namtopzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   ln_trczdf_exp   =  .false.  !  split explicit (T) or implicit (F) time stepping
+   n_trczdf_exp    =   3       !  number of sub-timestep for ln_trczdfexp=T
+/
+!-----------------------------------------------------------------------
+&namtoprad        !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+   ln_trcrad   =  .true.  !  artificially correct negative concentrations (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtopdmp        !   passive tracer newtonian damping                 ('key_trcdmp')
+!-----------------------------------------------------------------------
+   ndmptr      =   20      !  type of damping in passive tracers
+                           !     ='latitude', damping poleward of 'ndmp' degrees and function 
+                           !                  of the distance-to-coast. Red and Med Seas as ndmptr=-1
+                           !     =-1 damping only in Med and Red Seas
+   ndmpftr     =    0      !  create a damping.coeff NetCDF file (=1) or not (=0)
+   nmldmptr    =    1      !  type of damping: =0 damping throughout the water column
+                           !                   =1 no damping in the mixed layer defined by avt >5cm2/s )
+                           !                   =2 no damping in the mixed layer defined rho<rho(surf)+.01 )
+   sdmptr      =   50.     !  surface time scale for internal damping (days)
+   bdmptr      =  360.     !  bottom  time scale for internal damping (days)
+   hdmptr      =  800.     !  depth of transition between sdmptr and bdmptr (meters)
+/
+!-----------------------------------------------------------------------
+&namtoptrd       !   diagnostics on tracer trends
+!                          or mixed-layer trends          ('key_trdmld_trc')
+!----------------------------------------------------------------------
+   ntrd_trc   =  1460      !  time step frequency and tracers trends
+   nctls_trc  =   0        !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   ucf_trc    =   1        !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   ln_trdmld_trc_restart = .false.  !  restart for ML diagnostics
+   ln_trdmld_trc_instant = .true.  !  flag to diagnose trends of instantantaneous or mean ML T/S
+   luttrd(1)  =   .true.
+   luttrd(2)  =   .true.
+   luttrd(3)  =   .false.
+   luttrd(4)  =   .false.
+   luttrd(5)  =   .false.
+   luttrd(6)  =   .false.
+   luttrd(7)  =   .false.
+   luttrd(8)  =   .false.
+   luttrd(9)  =   .false.
+   luttrd(10) =   .false.
+   luttrd(11) =   .false.
+   luttrd(12) =   .false.
+   luttrd(13) =   .false.
+   luttrd(14) =   .false.
+   luttrd(15) =   .false.
+   luttrd(16) =   .false.
+   luttrd(17) =   .false.
+   luttrd(18) =   .false.
+   luttrd(19) =   .false.
+   luttrd(20) =   .false.
+   luttrd(21) =   .false.
+   luttrd(22) =   .false.
+   luttrd(23) =   .true.
+   luttrd(24) =   .false.
+/
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,18 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card	(revision 1844)
@@ -0,0 +1,65 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+OPA_NDT_DAY=4
+#==============================================================
+#-- Name of directory related to dynamical 
+#-- available directories are:  v3, cpl
+#-- NOTE: if you use your own directory you have to comment it
+OPA_dyn=v3
+#==============================================================
+
+[InitialStateFiles]
+List= ()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_mesh_mask.nc, mesh_mask.nc), \
+            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_21210101_21211231_grid_T.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_21210101_21211231_grid_U.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_21210101_21211231_grid_V.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_21210101_21211231_grid_W.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_DIC_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_Alkalini_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_O2_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_NO3_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_PO4_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_Si_nomask.nc,  .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_DOC_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/INI/data_1m_Fer_nomask.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/ANC/kRGB61.txt, .), \
+            (${R_BC}/${config_UserChoices_TagName}/ANC/dust.orca.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/ANC/bathy.orca.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/ANC/river.orca.nc, .), \
+            (${R_BC}/${config_UserChoices_TagName}/ANC/ndeposition.orca.nc, .)
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/namelist, .), \
+        (${SUBMIT_DIR}/PARAM/namelist_top, .), \
+        (${SUBMIT_DIR}/PARAM/namelist_pisces, .), \
+        (${SUBMIT_DIR}/PARAM/iodef.xml, .), \
+        (${SUBMIT_DIR}/PARAM/xmlio_server.def, .)
+
+[RestartFiles]
+List=	(${config_UserChoices_JobName}_${NEMO_END}_restart_trc.nc,  restart_trc.nc, restart_trc.nc)
+
+[OutputText]
+List=   (ocean.output)
+
+[OutputFiles]
+List=   (${PREFIX_WFT1}_ptrc_T.nc, ${R_OUT_MBG_WFT1}/${PREFIX}_${WFT1}_ptrc_T.nc, NONE), \
+        (${PREFIX_WFT1}_diad_T.nc, ${R_OUT_MBG_WFT1}/${PREFIX}_${WFT1}_diad_T.nc, NONE), \
+        (${PREFIX_WFT2}_ptrc_T.nc, ${R_OUT_MBG_WFT2}/${PREFIX}_${WFT2}_ptrc_T.nc, Post_1M_ptrc_T), \
+        (${PREFIX_WFT3}_diad_T.nc, ${R_OUT_MBG_WFT3}/${PREFIX}_${WFT3}_diad_T.nc, Post_5D_diad_T)
+
+[Post_1M_ptrc_T]
+Patches= ()
+GatherWithInternal = (nav_lon, nav_lat, deptht, time_counter)
+TimeSeriesVars = (DCHL, NCHL, NO3)
+
+[Post_5D_diad_T]
+Patches = ()
+GatherWithInternal = (nav_lon, nav_lat, time_counter)
+TimeSeriesVars = (Cflx)
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.driver
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.driver	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.driver	(revision 1844)
@@ -0,0 +1,192 @@
+#!/bin/ksh
+
+#-----------------------------------
+function MBG_Initialize
+{ 
+    IGCM_debug_PushStack "MBG_Initialize"
+
+    JOB_NAME=${config_UserChoices_JobName}
+    OPA_NDT_DAY=${pisces_UserChoices_OPA_NDT_DAY:=4}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+    ##--Variables used by OPA --
+
+    # cexper experience name for vairmer format
+    # nit000 number of the first time step
+    # nitend number of the last time step
+    # nleapy leap year calendar (0/1) (30 for 360d)
+    # nwrite frequency of OUTPUT file
+    # ln_rstart boolean term for restart (true or false)
+    # nstock frequency of restart file
+    # ndate0 initial calendar date aammjj
+    # rdt time step in seconds (coming from namelist)
+
+
+    PAT_CEXPER=$( supergrep cexper    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NIT000=$( supergrep nit000    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NITEND=$( supergrep nitend    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NLEAPY=$( supergrep nleapy    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NSTOCK=$( supergrep nstock    ${SUBMIT_DIR}/PARAM/namelist )
+    PAT_NDATE0=$( supergrep ndate0    ${SUBMIT_DIR}/PARAM/namelist )
+
+
+    OPA_RDT=$( supergrep rdt  ${SUBMIT_DIR}/PARAM/namelist | sed 's/ *rdt *=//' | sed 's/\. *,//' )
+
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # /!\ Needed by OPA namelist to compute file names /!\
+    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
+
+    ##--Variables used by MBG --
+
+    # lrsttr    boolean term for tracer model restart (true or false)
+    # nrsttr    control of the time step (0, 1 or 2)
+    
+    ##--Variables used by PISCES --
+ 
+    PAT_TOP_LRSTTR=$( supergrep ln_rsttr                 ${SUBMIT_DIR}/PARAM/namelist_top )
+    PAT_TOP_NRSTTR=$( supergrep nrsttr                   ${SUBMIT_DIR}/PARAM/namelist_top )
+    PAT_PIS_LRIVER=$( supergrep ln_river                 ${SUBMIT_DIR}/PARAM/namelist_pisces )
+
+    ##--Variables used for XMLIO_SERVER configuration file
+
+    # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+
+    PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def )
+
+
+    IGCM_debug_PopStack "MBG_Initialize"
+}
+
+#-----------------------------------
+function MBG_Update
+{
+    IGCM_debug_PushStack "MBG_Update"
+
+    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
+    # Needed by OPA namelist to compute correct file names 
+    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
+
+    ## Count of number of time steps from begin of OPA job
+    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NDT_DAY + 1 ))
+    (( OPA_NDT   = PeriodLengthInDays * OPA_NDT_DAY ))
+    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
+
+    ## Forcing to write one restart file at the end of period
+    OPA_NSTOCK="${OPA_NITEND}"
+
+    ## Verification of number of time steps per day
+    (( NB_SEC_DAY_MODEL = OPA_NDT_DAY * OPA_RDT ))
+    (( NB_SEC_DAY = 60 * 60 * 24 ))
+
+    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
+        then
+        echo " VERIFY OPA_NDT_DAY in opa9.card "
+        exit
+    fi
+
+     ## nleapy configuration
+        case ${config_UserChoices_CalendarType} in
+                leap)
+                OPA_NLEAPY=1;;
+                noleap)
+                OPA_NLEAPY=0;;
+                360d)
+                OPA_NLEAPY=30;;
+        esac
+
+
+        typeset -r PRECIS=8
+        NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) )
+
+    sed -e "s%${PAT_CEXPER}%       cexper=\"${config_UserChoices_JobName}\"%" \
+        -e "s%${PAT_NIT000}%       nit000=${OPA_NIT000}%"                    \
+        -e "s%${PAT_NITEND}%       nitend=${OPA_NITEND}%"                    \
+        -e "s%${PAT_NSTOCK}%       nstock=${OPA_NSTOCK}%"                    \
+        -e "s%${PAT_NDATE0}%       ndate0=${PeriodDateBegin}%"                \
+        -e "s%${PAT_NLEAPY}%       nleapy=${OPA_NLEAPY}%"                     \
+        namelist > namelist.tmp
+
+    IGCM_sys_Mv namelist.tmp namelist
+
+    ##--Write Frequency Purpose
+    Nbfreq=$( echo ${config_MBG_WriteFrequency} | wc -w )
+    typeset -Z1 i=1
+    while [ $i -le ${Nbfreq} ]; do
+       topfrequency=$( echo ${config_MBG_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
+       topfactor=$( echo ${topfrequency} | sed -e "s/[yYmMdD]//" )
+       case ${topfrequency} in
+         *Y|*y)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}y_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_Y} ;
+            eval WFT${i}=${topfactor}Y ;;
+         *M|*m)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}m_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_M} ;
+            eval WFT${i}=${topfactor}M ;;
+         *D|*d)
+            eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}d_${DatesPeriod} ;
+            eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_D} ;
+            eval WFT${i}=${topfactor}D ;;
+         *)
+      esac
+       let i=$i+1
+    done
+
+    ##-- Restart configuration
+    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
+
+        #echo "NO RESTART FOR TOP"
+        TOP_LRSTTR=.FALSE.
+        TOP_NRSTTR=0
+
+        PISCES_LRIVER=.FALSE.
+
+    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
+
+        #echo "RESTART TOP"
+        TOP_LRSTTR=.TRUE.
+        TOP_NRSTTR=0
+
+        PISCES_LRIVER=.TRUE.
+
+    else
+
+        #echo "RESTART TOP"
+        TOP_LRSTTR=.TRUE.
+        TOP_NRSTTR=2
+
+        PISCES_LRIVER=.TRUE.
+
+    fi
+
+# on force les sorties PISCES comme les sorties OPA
+
+    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
+        -e "s%${PAT_TOP_NRSTTR}%          nrsttr=${TOP_NRSTTR}%"                   \
+        namelist_top > namelist_top.tmp
+
+    IGCM_sys_Mv namelist_top.tmp namelist_top
+
+    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
+        namelist_pisces > namelist_pisces.tmp
+
+    IGCM_sys_Mv namelist_pisces.tmp namelist_pisces
+
+
+    IGCM_debug_PopStack "MBG_Update"
+}
+
+#-----------------------------------
+function MBG_Finalize
+{
+    IGCM_debug_PushStack "MBG_Finalize"
+
+    echo FINALIZE MBG !!!
+
+    IGCM_debug_PopStack "MBG_Finalize"
+}
+
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/README
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/README	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/README	(revision 1844)
@@ -0,0 +1,58 @@
+ config.card
+ ORCA2_OFF_PISCES
+ 5 years run -  trunk of 1 year per job with diagnostics ( key_trc_diaadd & key_trc_dia3d activated )
+
+ - NEMO    trunk revision 1656
+ - mpi on 4 processors ( 1x4 domain decomposition )
+ - libIGCM trunk revision 183
+ - dynamical files from IPSLCM5-VA66 runs from Olivier Marti
+
+without monitoring and atlas
+
+Tested on  NEC SX9 mercure at CCRT.
+
+Ouputs on : /dmnfs10/cont003/p48ethe/IGCM_OUT/ORCA2_OFF_PISCES/VA66P
+
+========================================================================
+run.card
+
+# $Date: $
+# $Name: $
+# $Revision: $
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+
+#========================================================================
+[Configuration]
+#last PREFIX
+OldPrefix= VA66P_20051231
+#Compute date of loop
+PeriodDateBegin= 2006-01-01
+PeriodDateEnd= 2006-12-31
+CumulPeriod= 6
+# State of Job "Start", "Running", "OnQueue", "Completed"
+PeriodState= Completed
+
+#========================================================================
+[PostProcessing]
+
+#RebuildRunning=y/n
+#RebuildToComplete=number of dir to rebuild
+#RebuildDateID=PeriodDateEnd correspondant au dernier flag de RebuildFrequency=true
+
+TimeSeriesRunning=n
+TimeSeriesCompleted=
+
+#========================================================================
+[Log]
+# Executables Size
+LastExeSize= ( 11596207 )
+
+#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+# CumulPeriod | PeriodDateBegin |   PeriodDateEnd |        RunDateBegin |          RunDateEnd |     RealCpuTime |     UserCpuTime |      SysCpuTime | ExeDate
+#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+#           1 |        20010101 |        20011231 | 2009-10-14T15:05:34 | 2009-10-14T15:10:39 |       304.19207 |      1191.95484 |         4.41881 | MBG_Oct_14_15:02
+#           2 |        20020101 |        20021231 | 2009-10-14T15:14:18 | 2009-10-14T15:20:13 |       354.59008 |      1412.65806 |         2.16025 | MBG_Oct_14_15:02
+#           3 |        20030101 |        20031231 | 2009-10-14T15:24:17 | 2009-10-14T15:30:10 |       353.09587 |      1407.03031 |         2.22349 | MBG_Oct_14_15:02
+#           4 |        20040101 |        20041231 | 2009-10-14T15:34:16 | 2009-10-14T15:40:18 |       362.49957 |      1430.77230 |         3.31767 | MBG_Oct_14_15:02
+#           5 |        20050101 |        20051231 | 2009-10-14T15:44:16 | 2009-10-14T15:50:17 |       360.82695 |       717.62953 |         1.79535 | MBG_Oct_14_15:02
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/config.card
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/config.card	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/IGCM00/config.card	(revision 1844)
@@ -0,0 +1,96 @@
+#
+# This is config.card file for NEMO ORCA2_LIM_PISCES configuration
+#
+#========================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=PISCES
+LongName="SCRIPT_V1"
+TagName=ORCA2_OFF_PISCES
+#============================
+#-- leap, noleap, 360d
+CalendarType=noleap
+#-- Begin and end of Job
+#-- "YYYY-MM-DD"
+DateBegin=2001-01-01
+DateEnd=2005-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1Y
+#============================
+#-- PBS Class (required on brodie mono/multi)
+JobClass=mono
+#JobClass=multi
+#============================
+#-- Total Number of Processors
+JobNumProcTot=1
+#JobNumProcTot=8
+#============================
+#-- Run Options : 
+#JobRunOptions=''
+JobRunOptions='"-np "${BATCH_NUM_PROC_TOT}"'
+#============================
+#============================
+# config.card configuration options :
+# config.card configuration options :
+###R_BC=/u/rech/eee/reee451/IGCM/BC
+R_BC=/dmnfs/cont003/p48ethe/IGCM/BC
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+MBG= (pisces, PISCES)
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=nemo
+#D- For each component, Real name of executable
+MBG= (opa, nemo)
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=2000-12-31
+#D- Define restart simulation name
+RestartJobName=OROFP
+#D- Path Server Group Login
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_OFF_PISCES
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+#D- BETA FEATURE
+RebuildFrequency=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+RebuildFromArchive=false
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=NONE
+#========================================================================
+#D-- MBG -
+[MBG]
+##-- frequency 
+WriteFrequency="1Y 1M 5D"
+##--  restart
+Restart= n
+##-- Last day of the experience used as restart
+RestartDate=2000-12-31
+# Define restart simulation name
+RestartJobName=OROFP1
+RestartPath=${ARCHIVE}/IGCM_OUT/ORCA2_OFF_PISCES
+# Old component name for restart (if empty, use new name)
+OldName=
+#========================================================================
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make	(revision 1844)
@@ -0,0 +1,7937 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_c14b \
+     key_c1d \
+     key_cfc \
+     key_cpl_carbon_cycle \
+     key_diaadd \
+     key_diaeiv \
+     key_diainstant \
+     key_dimgout \
+     key_dtatrc \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_fdir \
+     key_gyre \
+     key_iomput \
+     key_kriest \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_lobster \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_my_trc \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_off_degrad \
+     key_off_tra \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_sed \
+     key_sed_off \
+     key_top \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trc_dia3d \
+     key_trc_diaadd \
+     key_trc_diabio \
+     key_trc_diatrd \
+     key_trc_zdfddm \
+     key_trcbbc \
+     key_trcbbl_adv \
+     key_trcbbl_dif \
+     key_trcdmp \
+     key_trcldf_eiv \
+     key_trcldf_iso \
+     key_trdmld_trc \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdftke 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(ctlopn.o)\
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_isml.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_top_interp.o)\
+		$(MODEL_LIB)(agrif_top_sponge.o)\
+		$(MODEL_LIB)(agrif_top_update.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domrea.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(dtadyn.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(oce_trc.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(p4zbio.o)\
+		$(MODEL_LIB)(p4zche.o)\
+		$(MODEL_LIB)(p4zflx.o)\
+		$(MODEL_LIB)(p4zint.o)\
+		$(MODEL_LIB)(p4zlim.o)\
+		$(MODEL_LIB)(p4zlys.o)\
+		$(MODEL_LIB)(p4zmeso.o)\
+		$(MODEL_LIB)(p4zmicro.o)\
+		$(MODEL_LIB)(p4zmort.o)\
+		$(MODEL_LIB)(p4zopt.o)\
+		$(MODEL_LIB)(p4zprod.o)\
+		$(MODEL_LIB)(p4zrem.o)\
+		$(MODEL_LIB)(p4zsed.o)\
+		$(MODEL_LIB)(p4zsink.o)\
+		$(MODEL_LIB)(par_c14b.o)\
+		$(MODEL_LIB)(par_cfc.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_lobster.o)\
+		$(MODEL_LIB)(par_my_trc.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(par_pisces.o)\
+		$(MODEL_LIB)(par_sed.o)\
+		$(MODEL_LIB)(par_trc.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(prtctl_trc.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sed.o)\
+		$(MODEL_LIB)(sedadv.o)\
+		$(MODEL_LIB)(sedarr.o)\
+		$(MODEL_LIB)(sedbtb.o)\
+		$(MODEL_LIB)(sedchem.o)\
+		$(MODEL_LIB)(sedco3.o)\
+		$(MODEL_LIB)(seddsr.o)\
+		$(MODEL_LIB)(seddta.o)\
+		$(MODEL_LIB)(sedini.o)\
+		$(MODEL_LIB)(sedmat.o)\
+		$(MODEL_LIB)(sedmbc.o)\
+		$(MODEL_LIB)(sedmodel.o)\
+		$(MODEL_LIB)(sedrst.o)\
+		$(MODEL_LIB)(sedsfc.o)\
+		$(MODEL_LIB)(sedstp.o)\
+		$(MODEL_LIB)(sedwri.o)\
+		$(MODEL_LIB)(sms_lobster.o)\
+		$(MODEL_LIB)(sms_pisces.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trc.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trcadv_cen2.o)\
+		$(MODEL_LIB)(trcadv_muscl.o)\
+		$(MODEL_LIB)(trcadv_muscl2.o)\
+		$(MODEL_LIB)(trcadv_smolar.o)\
+		$(MODEL_LIB)(trcadv_tvd.o)\
+		$(MODEL_LIB)(trcbbc.o)\
+		$(MODEL_LIB)(trcbbl.o)\
+		$(MODEL_LIB)(trcbio.o)\
+		$(MODEL_LIB)(trcctl.o)\
+		$(MODEL_LIB)(trcctl_c14b.o)\
+		$(MODEL_LIB)(trcctl_cfc.o)\
+		$(MODEL_LIB)(trcctl_lobster.o)\
+		$(MODEL_LIB)(trcctl_my_trc.o)\
+		$(MODEL_LIB)(trcctl_pisces.o)\
+		$(MODEL_LIB)(trcdia.o)\
+		$(MODEL_LIB)(trcdmp.o)\
+		$(MODEL_LIB)(trcdta.o)\
+		$(MODEL_LIB)(trcexp.o)\
+		$(MODEL_LIB)(trcini.o)\
+		$(MODEL_LIB)(trcini_c14b.o)\
+		$(MODEL_LIB)(trcini_cfc.o)\
+		$(MODEL_LIB)(trcini_lobster.o)\
+		$(MODEL_LIB)(trcini_my_trc.o)\
+		$(MODEL_LIB)(trcini_pisces.o)\
+		$(MODEL_LIB)(trcldf_bilap.o)\
+		$(MODEL_LIB)(trcldf_bilapg.o)\
+		$(MODEL_LIB)(trcldf_iso.o)\
+		$(MODEL_LIB)(trcldf_iso_zps.o)\
+		$(MODEL_LIB)(trcldf_lap.o)\
+		$(MODEL_LIB)(trclec.o)\
+		$(MODEL_LIB)(trclsm_c14b.o)\
+		$(MODEL_LIB)(trclsm_cfc.o)\
+		$(MODEL_LIB)(trclsm_lobster.o)\
+		$(MODEL_LIB)(trclsm_my_trc.o)\
+		$(MODEL_LIB)(trclsm_pisces.o)\
+		$(MODEL_LIB)(trcnxt.o)\
+		$(MODEL_LIB)(trcopt.o)\
+		$(MODEL_LIB)(trcrad.o)\
+		$(MODEL_LIB)(trcrst.o)\
+		$(MODEL_LIB)(trcsbc.o)\
+		$(MODEL_LIB)(trcsed.o)\
+		$(MODEL_LIB)(trcsms.o)\
+		$(MODEL_LIB)(trcsms_c14b.o)\
+		$(MODEL_LIB)(trcsms_cfc.o)\
+		$(MODEL_LIB)(trcsms_lobster.o)\
+		$(MODEL_LIB)(trcsms_my_trc.o)\
+		$(MODEL_LIB)(trcsms_pisces.o)\
+		$(MODEL_LIB)(trcstp.o)\
+		$(MODEL_LIB)(trctrp.o)\
+		$(MODEL_LIB)(trctrp_ctl.o)\
+		$(MODEL_LIB)(trctrp_lec.o)\
+		$(MODEL_LIB)(trcwri.o)\
+		$(MODEL_LIB)(trczdf_exp.o)\
+		$(MODEL_LIB)(trczdf_imp.o)\
+		$(MODEL_LIB)(trczdf_iso.o)\
+		$(MODEL_LIB)(trczdf_iso_vopt.o)\
+		$(MODEL_LIB)(trdmld_trc.o)\
+		$(MODEL_LIB)(trdmld_trc_oce.o)\
+		$(MODEL_LIB)(trdmld_trc_rst.o)\
+		$(MODEL_LIB)(trp_trc.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zpshde.o)\
+		$(MODEL_LIB)(zpshde_trc.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_top_interp.o) :	\
+	agrif_top_interp.F90
+$(MODEL_LIB)(agrif_top_sponge.o) :	\
+	agrif_top_sponge.F90
+$(MODEL_LIB)(agrif_top_update.o) :	\
+	agrif_top_update.F90
+$(MODEL_LIB)(ctlopn.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	in_out_manager.F90 \
+	ctlopn.f90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domrea.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dommsk.F90 \
+	domrea.F90 \
+	domstp.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domrea.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domrea_dimg.h90 \
+	domrea_fdir.h90 \
+	KEY_CPP \
+	domrea.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(dtadyn.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trabbl.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dtadyn.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_isml.o) :	\
+	lib_isml.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtadyn.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trcini.o) \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtadyn.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	step.F90 \
+	traqsr.F90 \
+	trcini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(iom.o) \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(oce_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	KEY_CPP \
+	oce_trc.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domrea.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(dtadyn.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	daymod.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domrea.F90 \
+	domstp.F90 \
+	dtadyn.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90 \
+	trabbl.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdia.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trcstp.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtadyn.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trcini.o) \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtadyn.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	step.F90 \
+	traqsr.F90 \
+	trcini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(p4zbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zbio.F90
+$(MODEL_LIB)(p4zche.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zche.F90
+$(MODEL_LIB)(p4zflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zflx.F90
+$(MODEL_LIB)(p4zint.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zint.F90
+$(MODEL_LIB)(p4zlim.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zlim.F90
+$(MODEL_LIB)(p4zlys.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	p4zlys.F90
+$(MODEL_LIB)(p4zmeso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmeso.F90
+$(MODEL_LIB)(p4zmicro.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmicro.F90
+$(MODEL_LIB)(p4zmort.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zmort.F90
+$(MODEL_LIB)(p4zopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zopt.F90
+$(MODEL_LIB)(p4zprod.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zprod.F90
+$(MODEL_LIB)(p4zrem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zmeso.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zrem.F90
+$(MODEL_LIB)(p4zsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zopt.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	p4zsed.F90
+$(MODEL_LIB)(p4zsink.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	p4zsink.F90
+$(MODEL_LIB)(par_c14b.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_c14b.F90
+$(MODEL_LIB)(par_cfc.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_cfc.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_lobster.o) :	\
+	KEY_CPP \
+	par_lobster.F90
+$(MODEL_LIB)(par_my_trc.o) :	\
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_my_trc.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(par_pisces.o) :	\
+	$(MODEL_LIB)(par_lobster.o) \
+	par_lobster.F90 \
+	KEY_CPP \
+	par_pisces.F90
+$(MODEL_LIB)(par_sed.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	par_kind.F90 \
+	par_lobster.F90 \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_sed.F90
+$(MODEL_LIB)(par_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_lobster.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	KEY_CPP \
+	par_trc.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(prtctl_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	prtctl_trc.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sed.o) :	\
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	prtctl_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	sed.F90
+$(MODEL_LIB)(sedadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedadv.F90
+$(MODEL_LIB)(sedarr.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_sed.o) \
+	par_sed.F90 \
+	KEY_CPP \
+	sedarr.F90
+$(MODEL_LIB)(sedbtb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	sedbtb.F90
+$(MODEL_LIB)(sedchem.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	sedchem.F90
+$(MODEL_LIB)(sedco3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedco3.F90
+$(MODEL_LIB)(seddsr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	KEY_CPP \
+	seddsr.F90
+$(MODEL_LIB)(seddta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	KEY_CPP \
+	seddta.F90
+$(MODEL_LIB)(sedini.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddta.F90 \
+	sedrst.F90 \
+	KEY_CPP \
+	sedini.F90
+$(MODEL_LIB)(sedmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	sed.F90 \
+	KEY_CPP \
+	sedmat.F90
+$(MODEL_LIB)(sedmbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedco3.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	sed.F90 \
+	seddsr.F90 \
+	KEY_CPP \
+	sedmbc.F90
+$(MODEL_LIB)(sedmodel.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedadv.F90 \
+	sedarr.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	KEY_CPP \
+	sedmodel.F90
+$(MODEL_LIB)(sedrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	iom.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedrst.F90
+$(MODEL_LIB)(sedsfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	sed.F90 \
+	sedarr.F90 \
+	seddta.F90 \
+	KEY_CPP \
+	sedsfc.F90
+$(MODEL_LIB)(sedstp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmat.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmat.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedadv.o) \
+	$(MODEL_LIB)(sedbtb.o) \
+	$(MODEL_LIB)(sedchem.o) \
+	$(MODEL_LIB)(sedco3.o) \
+	$(MODEL_LIB)(seddsr.o) \
+	$(MODEL_LIB)(seddta.o) \
+	$(MODEL_LIB)(sedmbc.o) \
+	$(MODEL_LIB)(sedrst.o) \
+	$(MODEL_LIB)(sedsfc.o) \
+	$(MODEL_LIB)(sedwri.o) \
+	sed.F90 \
+	sedadv.F90 \
+	sedbtb.F90 \
+	sedchem.F90 \
+	sedco3.F90 \
+	seddsr.F90 \
+	seddta.F90 \
+	sedmbc.F90 \
+	sedrst.F90 \
+	sedsfc.F90 \
+	sedwri.F90 \
+	KEY_CPP \
+	sedstp.F90
+$(MODEL_LIB)(sedwri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_sed.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	p4zsink.F90 \
+	par_sed.F90 \
+	phycst.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedarr.o) \
+	dianam.F90 \
+	sed.F90 \
+	sedarr.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	sedwri.F90
+$(MODEL_LIB)(sms_lobster.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_lobster.F90
+$(MODEL_LIB)(sms_pisces.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	sms_pisces.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	sol_oce.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	trc.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp.F90 \
+	trctrp_lec.F90 \
+	trcwri.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtadyn.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcstp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	daymod.F90 \
+	dom_oce.F90 \
+	dtadyn.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	stpctl.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcstp.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	in_out_manager.F90 \
+	traqsr.F90
+$(MODEL_LIB)(trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trc.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trcadv_cen2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_cen2.F90
+$(MODEL_LIB)(trcadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl.F90
+$(MODEL_LIB)(trcadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_muscl2.F90
+$(MODEL_LIB)(trcadv_smolar.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_smolar.F90
+$(MODEL_LIB)(trcadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcadv_tvd.F90
+$(MODEL_LIB)(trcbbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbc.F90
+$(MODEL_LIB)(trcbbl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	eosbn2.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	trcbbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbbl.F90
+$(MODEL_LIB)(trcbio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcbio.F90
+$(MODEL_LIB)(trcctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trctrp_ctl.F90 \
+	KEY_CPP \
+	trcctl.F90
+$(MODEL_LIB)(trcctl_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_c14b.F90
+$(MODEL_LIB)(trcctl_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_cfc.F90
+$(MODEL_LIB)(trcctl_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_lobster.F90
+$(MODEL_LIB)(trcctl_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_my_trc.F90
+$(MODEL_LIB)(trcctl_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcctl_pisces.F90
+$(MODEL_LIB)(trcdia.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdia.F90
+$(MODEL_LIB)(trcdmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trcdmp.F90
+$(MODEL_LIB)(trcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	iom.F90 \
+	lib_print.f90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcdta.F90
+$(MODEL_LIB)(trcexp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcexp.F90
+$(MODEL_LIB)(trcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl_c14b.o) \
+	$(MODEL_LIB)(trcctl_cfc.o) \
+	$(MODEL_LIB)(trcctl_lobster.o) \
+	$(MODEL_LIB)(trcctl_my_trc.o) \
+	$(MODEL_LIB)(trcctl_pisces.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_ctl.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcctl_c14b.F90 \
+	trcctl_cfc.F90 \
+	trcctl_lobster.F90 \
+	trcctl_my_trc.F90 \
+	trcctl_pisces.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_ctl.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcctl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trcini_c14b.o) \
+	$(MODEL_LIB)(trcini_cfc.o) \
+	$(MODEL_LIB)(trcini_lobster.o) \
+	$(MODEL_LIB)(trcini_my_trc.o) \
+	$(MODEL_LIB)(trcini_pisces.o) \
+	$(MODEL_LIB)(trclec.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	daymod.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcctl.F90 \
+	trcdta.F90 \
+	trcini_c14b.F90 \
+	trcini_cfc.F90 \
+	trcini_lobster.F90 \
+	trcini_my_trc.F90 \
+	trcini_pisces.F90 \
+	trclec.F90 \
+	trcrst.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcini.F90
+$(MODEL_LIB)(trcini_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trcini_c14b.F90
+$(MODEL_LIB)(trcini_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trcini_cfc.F90
+$(MODEL_LIB)(trcini_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_lobster.F90
+$(MODEL_LIB)(trcini_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trcini_my_trc.F90
+$(MODEL_LIB)(trcini_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zche.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcini_pisces.F90
+$(MODEL_LIB)(trcldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilap.F90
+$(MODEL_LIB)(trcldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_bilapg.F90
+$(MODEL_LIB)(trcldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso.F90
+$(MODEL_LIB)(trcldf_iso_zps.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_iso_zps.F90
+$(MODEL_LIB)(trcldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcldf_lap.F90
+$(MODEL_LIB)(trclec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trclsm_c14b.o) \
+	$(MODEL_LIB)(trclsm_cfc.o) \
+	$(MODEL_LIB)(trclsm_lobster.o) \
+	$(MODEL_LIB)(trclsm_my_trc.o) \
+	$(MODEL_LIB)(trclsm_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trclsm_c14b.F90 \
+	trclsm_cfc.F90 \
+	trclsm_lobster.F90 \
+	trclsm_my_trc.F90 \
+	trclsm_pisces.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trclec.F90
+$(MODEL_LIB)(trclsm_c14b.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	KEY_CPP \
+	trclsm_c14b.F90
+$(MODEL_LIB)(trclsm_cfc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trcsms_cfc.F90 \
+	KEY_CPP \
+	trclsm_cfc.F90
+$(MODEL_LIB)(trclsm_lobster.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_lobster.F90
+$(MODEL_LIB)(trclsm_my_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_my_trc.F90
+$(MODEL_LIB)(trclsm_pisces.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	in_out_manager.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trclsm_pisces.F90
+$(MODEL_LIB)(trcnxt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trcnxt.F90
+$(MODEL_LIB)(trcopt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcopt.F90
+$(MODEL_LIB)(trcrad.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrad.F90
+$(MODEL_LIB)(trcrst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_my_trc.F90 \
+	trctrp_lec.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcrst.F90
+$(MODEL_LIB)(trcsbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsbc.F90
+$(MODEL_LIB)(trcsed.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	sms_lobster.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trcsed.F90
+$(MODEL_LIB)(trcsms.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	KEY_CPP \
+	trcsms.F90
+$(MODEL_LIB)(trcsms_c14b.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_c14b.F90
+$(MODEL_LIB)(trcsms_cfc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	iom.F90 \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcsms_cfc.F90
+$(MODEL_LIB)(trcsms_lobster.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbio.o) \
+	$(MODEL_LIB)(trcexp.o) \
+	$(MODEL_LIB)(trcopt.o) \
+	$(MODEL_LIB)(trcsed.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	trc.F90 \
+	trcbio.F90 \
+	trcexp.F90 \
+	trcopt.F90 \
+	trcsed.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_lobster.F90
+$(MODEL_LIB)(trcsms_my_trc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	oce_trc.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_my_trc.F90
+$(MODEL_LIB)(trcsms_pisces.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlim.o) \
+	$(MODEL_LIB)(p4zmeso.o) \
+	$(MODEL_LIB)(p4zmicro.o) \
+	$(MODEL_LIB)(p4zmort.o) \
+	$(MODEL_LIB)(p4zopt.o) \
+	$(MODEL_LIB)(p4zprod.o) \
+	$(MODEL_LIB)(p4zrem.o) \
+	$(MODEL_LIB)(p4zsink.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sed.o) \
+	$(MODEL_LIB)(sedini.o) \
+	$(MODEL_LIB)(sedstp.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zint.F90 \
+	p4zlim.F90 \
+	p4zmeso.F90 \
+	p4zmicro.F90 \
+	p4zmort.F90 \
+	p4zopt.F90 \
+	p4zprod.F90 \
+	p4zrem.F90 \
+	p4zsink.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sed.F90 \
+	sedini.F90 \
+	sedstp.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(p4zbio.o) \
+	$(MODEL_LIB)(p4zche.o) \
+	$(MODEL_LIB)(p4zflx.o) \
+	$(MODEL_LIB)(p4zint.o) \
+	$(MODEL_LIB)(p4zlys.o) \
+	$(MODEL_LIB)(p4zsed.o) \
+	$(MODEL_LIB)(sedmodel.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce_trc.F90 \
+	p4zbio.F90 \
+	p4zche.F90 \
+	p4zflx.F90 \
+	p4zint.F90 \
+	p4zlys.F90 \
+	p4zsed.F90 \
+	sedmodel.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trcsms_pisces.F90
+$(MODEL_LIB)(trcstp.o) :	\
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trcsms_c14b.o) \
+	$(MODEL_LIB)(trcsms_cfc.o) \
+	$(MODEL_LIB)(trcsms_lobster.o) \
+	$(MODEL_LIB)(trcsms_my_trc.o) \
+	$(MODEL_LIB)(trcsms_pisces.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trcsms_c14b.F90 \
+	trcsms_cfc.F90 \
+	trcsms_lobster.F90 \
+	trcsms_my_trc.F90 \
+	trcsms_pisces.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde_trc.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcdia.o) \
+	$(MODEL_LIB)(trcrst.o) \
+	$(MODEL_LIB)(trcsms.o) \
+	$(MODEL_LIB)(trctrp.o) \
+	$(MODEL_LIB)(trcwri.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcdia.F90 \
+	trcrst.F90 \
+	trcsms.F90 \
+	trctrp.F90 \
+	trcwri.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trcstp.F90
+$(MODEL_LIB)(trctrp.o) :	\
+	$(MODEL_LIB)(agrif_top_interp.o) \
+	$(MODEL_LIB)(agrif_top_update.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdta.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	agrif_top_interp.F90 \
+	agrif_top_update.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl_trc.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trcbbl.F90 \
+	trcdta.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(agrif_top_sponge.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trcadv_cen2.o) \
+	$(MODEL_LIB)(trcadv_muscl.o) \
+	$(MODEL_LIB)(trcadv_muscl2.o) \
+	$(MODEL_LIB)(trcadv_smolar.o) \
+	$(MODEL_LIB)(trcadv_tvd.o) \
+	$(MODEL_LIB)(trcbbl.o) \
+	$(MODEL_LIB)(trcdmp.o) \
+	$(MODEL_LIB)(trcldf_bilap.o) \
+	$(MODEL_LIB)(trcldf_bilapg.o) \
+	$(MODEL_LIB)(trcldf_iso.o) \
+	$(MODEL_LIB)(trcldf_iso_zps.o) \
+	$(MODEL_LIB)(trcldf_lap.o) \
+	$(MODEL_LIB)(trcnxt.o) \
+	$(MODEL_LIB)(trcrad.o) \
+	$(MODEL_LIB)(trcsbc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trczdf_exp.o) \
+	$(MODEL_LIB)(trczdf_imp.o) \
+	$(MODEL_LIB)(trczdf_iso.o) \
+	$(MODEL_LIB)(trczdf_iso_vopt.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zpshde_trc.o) \
+	agrif_top_sponge.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trcadv_cen2.F90 \
+	trcadv_muscl.F90 \
+	trcadv_muscl2.F90 \
+	trcadv_smolar.F90 \
+	trcadv_tvd.F90 \
+	trcbbl.F90 \
+	trcdmp.F90 \
+	trcldf_bilap.F90 \
+	trcldf_bilapg.F90 \
+	trcldf_iso.F90 \
+	trcldf_iso_zps.F90 \
+	trcldf_lap.F90 \
+	trcnxt.F90 \
+	trcrad.F90 \
+	trcsbc.F90 \
+	trctrp_lec.F90 \
+	trczdf_exp.F90 \
+	trczdf_imp.F90 \
+	trczdf_iso.F90 \
+	trczdf_iso_vopt.F90 \
+	trp_trc.F90 \
+	zpshde_trc.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	trctrp.F90
+$(MODEL_LIB)(trctrp_ctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trctrp_lec.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_ctl.F90
+$(MODEL_LIB)(trctrp_lec.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce_trc.F90 \
+	trp_trc.F90 \
+	KEY_CPP \
+	trctrp_lec.F90
+$(MODEL_LIB)(trcwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	dianam.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trcwri.F90
+$(MODEL_LIB)(trczdf_exp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_exp.F90
+$(MODEL_LIB)(trczdf_imp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_imp.F90
+$(MODEL_LIB)(trczdf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdf.matrixsolver.h90 \
+	KEY_CPP \
+	trczdf_iso.F90
+$(MODEL_LIB)(trczdf_iso_vopt.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl_trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce.F90 \
+	oce_trc.F90 \
+	prtctl_trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trczdf_iso_vopt.F90
+$(MODEL_LIB)(trdmld_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	trp_trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sms_lobster.o) \
+	$(MODEL_LIB)(sms_pisces.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trctrp_lec.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	$(MODEL_LIB)(trdmld_trc_rst.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	dianam.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	oce_trc.F90 \
+	prtctl.F90 \
+	sms_lobster.F90 \
+	sms_pisces.F90 \
+	trc.F90 \
+	trctrp_lec.F90 \
+	trdmld_trc_oce.F90 \
+	trdmld_trc_rst.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld_trc.F90
+$(MODEL_LIB)(trdmld_trc_oce.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_pisces.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	KEY_CPP \
+	trdmld_trc_oce.F90
+$(MODEL_LIB)(trdmld_trc_rst.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(trdmld_trc_oce.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce_trc.F90 \
+	trc.F90 \
+	trdmld_trc_oce.F90 \
+	KEY_CPP \
+	trdmld_trc_rst.F90
+$(MODEL_LIB)(trp_trc.o) :	\
+	$(MODEL_LIB)(par_c14b.o) \
+	$(MODEL_LIB)(par_cfc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_lobster.o) \
+	$(MODEL_LIB)(par_my_trc.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_pisces.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	par_c14b.F90 \
+	par_cfc.F90 \
+	par_kind.F90 \
+	par_lobster.F90 \
+	par_my_trc.F90 \
+	par_oce.F90 \
+	par_pisces.F90 \
+	par_trc.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(trc.o) \
+	par_oce.F90 \
+	par_trc.F90 \
+	trc.F90 \
+	KEY_CPP \
+	trp_trc.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	par_oce.F90 \
+	zdf_oce.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+$(MODEL_LIB)(zpshde_trc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(par_trc.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	par_trc.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	traqsr.F90 \
+	trc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce_trc.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(trp_trc.o) \
+	lbclnk.F90 \
+	oce_trc.F90 \
+	par_kind.F90 \
+	trp_trc.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	top_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde_trc.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2 IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_ldfslp key_traldf_c2d key_traldf_eiv key_zdftke key_zdfddm key_top key_off_tra key_pisces key_dtatrc key_trcbbl_dif key_trcldf_eiv key_trc_zdfddm key_trc_diaadd key_trc_dia3d key_iomput
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make	(revision 1844)
@@ -0,0 +1,13 @@
+# $Header$
+all: ioipsl opa
+
+ioipsl:
+	(cd ../../modeles/IOIPSL/src; $(M_K) ;)
+
+
+opa:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) ;)
+
+
+clean:
+	(cd ../../modeles/NEMO/WORK;  $(M_K) clean ;)
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/AA_make.ldef	(revision 1844)
@@ -0,0 +1,11 @@
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/AA_job
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/AA_job	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/AA_job	(revision 1844)
@@ -0,0 +1,158 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:           # job name
+#-Q- sxnec #@$-o output_XXXXXXX.1        # outputfile name
+#-Q- sxnec #@$-me                        # sends a mail at the end of execution
+#-Q- sxnec #@$-eo                        # merge standard error and output
+#-Q- sxnec #@$-jo                        # print a short performance analysis
+#-Q- sxnec #@$-lT 1:00:00                # Max total CPU time
+#-Q- sxnec #@$-lt 0:59:00                # Max CPU time per process
+#-Q- sxnec #@$-lM 2Gb                    # Max memory
+#-Q- sxnec ##@$-c 4                     # Max number of simultaneous procs used (here=4)
+#-Q- sxnec ##@$-q multi                 # Use more than 1 proc
+#-Q- aix ##################
+#-Q- aix ## IBM   IDRIS  ##
+#-Q- aix ##################
+#-Q- aix #@job_name= :XXX:XXX:XXX:          
+#-Q- aix #@output= output_XXXXXXX.1          
+#-Q- aix #@error= error_XXXXXXX.1          
+#-Q- aix #@cpu_limit= 5000
+#-Q- aix #@stack_limit= 200Mb        
+#-Q- aix #@data_limit= 1.8Gb         
+#-Q- aix #@notification= complete
+#-Q- aix #@total_tasks= 1 
+#-Q- aix #@job_type= parallel
+#-Q- aix #@queue
+#-Q- sx8brodie ##################
+#-Q- sx8brodie ## SX8NEC IDRIS ##
+#-Q- sx8brodie ##################
+#-Q- sx8brodie #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8brodie #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8brodie #PBS -j o                    # merge standard error and output
+#-Q- sx8brodie #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8brodie #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8brodie #PBS -l cputim_prc=1:01:00   # Max CPU time/prc
+#-Q- sx8brodie #PBS -l cputim_job=1:01:00   # Max CPU time/job
+#-Q- sx8brodie ##PBS -l cpunum_job=4
+#-Q- sx8brodie ##PBS -q multi
+#-Q- sx8mercure ##################
+#-Q- sx8mercure ## SX8NEC   CEA ##
+#-Q- sx8mercure ##################
+#-Q- sx8mercure #PBS -N :XXX:XXX:XXX:        # job name
+#-Q- sx8mercure #PBS -o output_XXXXXXX.1     # outputfile name
+#-Q- sx8mercure #PBS -j o                    # merge standard error and output
+#-Q- sx8mercure #PBS -S /usr/bin/ksh         # user shell
+#-Q- sx8mercure #PBS -l memsz_job=3.6gb      # Max memory
+#-Q- sx8mercure #PBS -l cputim_job=0:40:00   # Max CPU time
+#-Q- sx8mercure ##PBS -l cpunum_job=4
+########################################################################
+##
+##      Script to run a short experiment when installing the
+##      POMME configuration 
+##
+##            Rachid Benshila, OPA System Team
+##
+##
+#########################################################################
+##-- print echo of commands before and after shell interpretation
+date
+set -vx
+
+#################################
+# Beginning of user modification
+#################################
+
+##-- define some directories : 
+#- Input file storing 
+#-Q- sxnec R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8brodie R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- aix R_FORCING="gaya:/u/rech/eee/reee512/NEMO"
+#-Q- sx8mercure R_FORCING="/dmnfs10/cont003/p48ethe/FORCINGS/POMME_R025/NEMO"
+#- Launching run repository
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8brodie R_EXPER=${PBS_O_WORKDIR}
+#-Q- aix R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx8mercure R_EXPER=${PWD}
+#- modipsl repository
+R_EXEDIR=MMMMMMM     
+#- output files storing 
+R_SORTIE_OCE=AAAAAAA/POMME
+#- execution repository
+R_TMP=$TMPDIR         
+
+##-- define processus number : to change when running in mpp
+NB_PROC=1
+
+#################################
+# End of user modification
+#################################
+
+#--  define a fonction to get the input tarfile
+#-Q- sxnec Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8brodie Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- aix Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+#-Q- sx8mercure Rapatrie () { [ -f $1/$2 ] || ( cp ${R_FORCING}/$2 $1 ; cd $1; tar xvf $2 ;) }
+
+[ -d ${R_TMP} ] || mkdir ${R_TMP}
+cd ${R_TMP}
+
+#--  get the executable
+#-Q- sxnec rcp ${LOGNAME}@rhodes:${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8brodie rcp ${LOGNAME}@brodie:${R_EXEDIR}/bin/opa opa.xx
+#-Q- aix cp ${R_EXEDIR}/bin/opa opa.xx
+#-Q- sx8mercure cp ${R_EXEDIR}/bin/opa opa.xx
+chmod 777 opa.xx
+
+## --  Copy ancillary files
+#
+#- Namelist for ocean
+cp ${R_EXPER}/namelist namelist
+
+#- Files for the configuration and ocean dynamics
+Rapatrie ${R_TMP} POMME_nemo_v3_2.tar
+
+ls -alF
+
+#-Q- sxnec export F_PROGINF=yes
+#-Q- sxnec export F_ERRCNT=5
+#-Q- sx8brodie export F_PROGINF=yes
+#-Q- sx8brodie export F_ERRCNT=5
+#-Q- sx8mercure export F_PROGINF=yes
+#-Q- sx8mercure export F_ERRCNT=5
+
+#-Q- sxnec #- To be use for a mpp run
+#-Q- sxnec #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8brodie #- To be use for a mpp run
+#-Q- sx8brodie #mpirun -np ${NB_PROC} ./opa.xx
+#-Q- sx8mercure #- To be use for a mpp run
+#-Q- sx8mercure #mpirun -np ${NB_PROC} ./opa.xx
+
+./opa.xx
+
+## -- Save output files
+ls -alF
+#- to copy on a storage machine
+#-Q- sxnec DPUT=mfput
+#-Q- sx8brodie DPUT=mfput
+#-Q- aix DPUT=mfput
+#-Q- sx8mercure DPUT=cp 
+#-Q- sx8mercure [ -d ${R_SORTIE_OCE} ] || mkdir -p ${R_SORTIE_OCE}
+
+#- Save ocean output files
+$DPUT *ocean.output ${R_SORTIE_OCE}/.
+$DPUT *solver.stat ${R_SORTIE_OCE}/.
+[ -f *mpp.output* ] && $DPUT *mpp.output* ${R_SORTIE_OCE}/.
+for file_netcdf in *_grid_*.nc
+do
+$DPUT ${file_netcdf} ${R_SORTIE_OCE}/${file_netcdf}
+done
+#
+#- Save restart files
+for restart in *restart*
+do
+$DPUT ${restart} ${R_SORTIE_OCE}/${restart} 
+done
+#
+#- Save ftrace file
+[ -f ftrace.out* ] && $DPUT ftrace.out* ${R_SORTIE_OCE}/.
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/iodef.xml
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/iodef.xml	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/iodef.xml	(revision 1844)
@@ -0,0 +1,290 @@
+<?xml version="1.0"?>
+<simulation> 
+  
+  <context id="nemo">
+
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    
+    <field_definition level="1" prec="4" operation="ave(X)" enabled=".TRUE."> <!-- time step automaticaly defined -->
+
+      <!-- T grid -->
+      
+      <group id="grid_T" axis_ref="none" grid_ref="grid_T">
+	<field id="toce"         description="temperature"                               unit="degC" axis_ref="deptht"   />
+       	<field id="soce"         description="salinity"                                  unit="psu"  axis_ref="deptht"   />
+	<field id="sst"          description="sea surface temperature"                   unit="degC"                     />
+	<field id="sst2"         description="square of sea surface temperature"         unit="degC2"                    />
+	<field id="|sstgrad|"    description="module of sst gradient"                    unit="degC/m"                   />
+	<field id="|sstgrad|2"   description="square of module of sst gradient"          unit="degC2/m2"                 />
+	<field id="sss"          description="sea surface salinity"                      unit="psu"                      />
+	<field id="sss2"         description="square of sea surface salinity"            unit="psu2"                     />
+	<field id="ssh"          description="sea surface height"                        unit="m"                        />
+	<field id="ssh2"         description="square of sea surface height"              unit="m2"                       />
+	<field id="mldkz5"       description="mixing layer depth (Turbocline)"           unit="m"                        />
+	<field id="mldr10_1"     description="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
+       	<field id="rhop"         description="potential density (sigma0)"                unit="kg/m3" axis_ref="deptht"  />
+	<!-- next variables available with key_diahth -->
+	<field id="mlddzt"       description="Thermocline Depth (max dT/dz)"             unit="m"                        />
+	<field id="mldr10_3"     description="Mixed Layer Depth dr=0.03 (ref.10m)"       unit="m"                        />
+	<field id="mldr0_1"      description="Mixed Layer Depth dr=0.01 (ref.surf)"      unit="m"                        />
+	<field id="mldr0_3"      description="Mixed Layer Depth dr=0.03 (ref.surf)"      unit="m"                        />
+	<field id="mld|dt|"      description="Mixed Layer Depth |dt|=0.2 (ref.10m)"      unit="m"                        />
+	<field id="topthdep"     description="Top of the thermocline dt=-0.2 (ref.10m)"  unit="m"                        />
+	<field id="pycndep"      description="Pycnocline depth dr~dt=-0.2 (ref.10m)"     unit="m"                        />
+	<field id="BLT"          description="Barrier Layer Thickness"                   unit="m"                        />
+	<field id="tinv"         description="Max of vertical invertion of temperature"  unit="degC"                     />
+	<field id="depti"        description="Depth of max. vert. inv. of temperature"   unit="m"                        />
+        <field id="20d"          description="Depth of 20C isotherm"                     unit="m"                        />
+	<field id="28d"          description="Depth of 28C isotherm"                     unit="m"                        />
+	<field id="hc300"        description="Heat content 300 m"                        unit="W"                        />
+	<!-- variables available with key_diaar5 -->
+	<field id="botpres"      description="Pressure at sea floor"                     unit="dbar"                     />
+	<field id="cellthc"      description="Cell thickness"                            unit="m"     axis_ref="deptht"  />
+     </group>
+
+      <!-- SBC -->
+      
+      <group id="SBC" axis_ref="none" grid_ref="grid_T" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+	<field id="emp"          description="Net Upward Water Flux"                                        unit="kg/m2/s"  />
+	<field id="emps"         description="concentration/dilution water flux"                            unit="kg/m2/s"  />
+	<field id="snowpre"      description="Snow precipitation"                                           unit="kg/m2/s"  />
+	<field id="runoffs"      description="River Runoffs"                                                unit="Kg/m2/s"  />
+
+	<field id="qns+qsr"      description="Net Downward Heat Flux"                                       unit="W/m2"     />
+	<field id="qns"          description="non solar Downward Heat Flux"                                 unit="W/m2"     />
+	<field id="qsr"          description="Shortwave Radiation"                                          unit="W/m2"     />
+	<field id="qsr3d"        description="Shortwave Radiation 3D distribution"        axis_ref="deptht" unit="W/m2"     />
+	<field id="qrp"          description="Surface Heat Flux: Damping"                                   unit="W/m2"     />
+	<field id="erp"          description="Surface Water Flux: Damping"                                  unit="Kg/m2/s"  />
+	<field id="taum"         description="wind stress module"                                           unit="N/m2"     />
+	<field id="wspd"         description="Wind speed module at 10 m"                                    unit="m/s"      />
+	
+	<!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+	<field id="qns_oce"      description="Non solar Downward Heat Flux over open ocean"                 unit="W/m2"     />
+	<field id="qlw_oce"      description="Longwave Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qsb_oce"      description="Sensible Downward Heat Flux over open ocean"                  unit="W/m2"     />
+	<field id="qla_oce"      description="Latent Downward Heat Flux over open ocean"                    unit="W/m2"     />
+	<field id="taum_oce"     description="wind stress module over open ocean"                           unit="N/m2"     />
+
+	<field id="ice_cover"    description="Ice fraction"                                                 unit="1"        />
+
+	<field id="ioceflxb"     description="Oceanic flux at the ice base"                                 unit="W/m2"     />
+	<field id="qsr_ai_cea"   description="Air-Ice downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_ai_cea"   description="Air-Ice downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	<field id="qla_ai_cea"   description="Air-Ice downward Latent heat flux (cell average)"             unit="W/m2"     />
+	
+	<field id="qsr_io_cea"   description="Ice-Oce downward solar heat flux (cell average)"              unit="W/m2"     />
+	<field id="qns_io_cea"   description="Ice-Oce downward non-solar heat flux (cell average)"          unit="W/m2"     />
+	
+	<field id="snowthic_cea" description="Snow thickness (cell average)"                                unit="m"        />
+	<field id="icethic_cea"  description="Ice thickness (cell average)"                                 unit="m"        />
+	<field id="iceprod_cea"  description="Ice production (cell average)"                                unit="m/s"      />
+	
+	<field id="ice_pres"     description="Ice presence"                                                 unit="-"        />
+	<field id="ist_cea"      description="Ice surface temperature (cell average)"                       unit="degC"     />
+	<field id="ist_ipa"      description="Ice surface temperature (ice presence average)"               unit="degC"     />      
+	<field id="uice_ipa"     description="Ice velocity along i-axis at I-point (ice presence average)"  unit="m/s"      />      
+	<field id="vice_ipa"     description="Ice velocity along j-axis at I-point (ice presence average)"  unit="m/s"      />      
+	
+	<field id="utau_ice"     description="Wind stress along i-axis over the ice at i-point"             unit="N/m2"     />
+	<field id="vtau_ice"     description="Wind stress along j-axis over the ice at i-point"             unit="N/m2"     />
+	
+	<field id="u_imasstr"    description="Sea-ice mass transport along i-axis"                          unit="kg/s"     />
+	<field id="v_imasstr"    description="Sea-ice mass transport along j-axis"                          unit="kg/s"     />
+
+	<!-- available key_coupled -->
+	<field id="snow_ao_cea"  description="Snow over ice-free ocean (cell average)"                      unit="kg/m2/s"  />
+	<field id="snow_ai_cea"  description="Snow over sea-ice (cell average)"                             unit="kg/m2/s"  />
+	<field id="subl_ai_cea"  description="Sublimation over sea-ice (cell average)"                      unit="kg/m2/s"  />
+	<field id="icealb_cea"   description="Ice albedo (cell average)"                                    unit="1"        />
+	<field id="calving"      description="Calving"                                                      unit="kg/m2/s"  />
+	<!-- available if key_coupled + conservative method -->
+	<field id="rain"         description="Liquid precipitation"                                         unit="Kg/m2/s"  />
+	<field id="evap_ao_cea"  description="Evaporation over ice-free ocean (cell average)"               unit="kg/m2/s"  />
+	<!-- variables available with key_diaar5 -->
+	<field id="isnwmlt_cea"   description="Snow over Ice melting (cell average)"                        unit="kg/m2/s"  />
+	<field id="fsal_virt_cea" description="Virtual salt flux due to ice formation (cell average)"       unit="kg/m2/s"  />
+	<field id="fsal_real_cea" description="Real salt flux due to ice formation (cell average)"          unit="kg/m2/s"  />
+	<field id="hflx_rain_cea" description="heat flux due to rainfall"                                   unit="W/m2"     />
+	<field id="hflx_evap_cea" description="heat flux due to evaporation"                                unit="W/m2"     />
+	<field id="hflx_snow_cea" description="heat flux due to snow falling over ice-free ocean"           unit="W/m2"     />
+	<field id="hflx_ice_cea"  description="heat flux due to ice thermodynamics"                         unit="W/m2"     />
+	<field id="hflx_rnf_cea"  description="heat flux due to runoffs"                                    unit="W/m2"     />
+	<field id="hflx_cal_cea"  description="heat flux due to calving"                                    unit="W/m2"     />
+	<field id="bicemel_cea"  description="Rate of Melt at Sea Ice Base (cell average)"                  unit="kg/m2/s"  />
+	<field id="licepro_cea"  description="Lateral Sea Ice Growth Rate (cell average)"                   unit="kg/m2/s"  />
+	<field id="snowmel_cea"  description="Snow Melt Rate (cell average)"                                unit="kg/m2/s"  />
+	<field id="sntoice_cea"  description="Snow-Ice Formation Rate (cell average)"                       unit="kg/m2/s"  />
+	<field id="ticemel_cea"  description="Rate of Melt at Upper Surface of Sea Ice (cell average)"      unit="kg/m2/s"  />
+
+      </group>
+
+      <!-- U grid -->
+      
+      <group id="grid_U"  axis_ref="depthu" grid_ref="grid_U">
+	<field id="utau"         description="Wind Stress along i-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="uoce"         description="ocean current along i-axis"                  unit="m/s"                  />
+	<field id="uoce_eff"     description="Effective ocean current along i-axis"        unit="m/s"                  />
+	<!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="uoce_eiv"     description="EIV ocean current along i-axis"              unit="m/s"                  />
+	<!-- uoce_eiv: available with key_trabbl_adv -->
+	<field id="uoce_bbl"     description="BBL ocean current along i-axis"              unit="m/s"                  />
+ 	<!-- variables available with key_diaar5 -->
+	<field id="u_masstr"     description="ocean eulerian mass transport along i-axis"  unit="kg/s"                 />
+	<field id="u_heattr"     description="ocean eulerian heat transport along i-axis"  unit="W"    axis_ref="none" />
+	<field id="ueiv_heattr"  description="ocean bolus heat transport along i-axis"     unit="W"    axis_ref="none" />
+	<field id="udiff_heattr" description="ocean diffusion heat transport along i-axis" unit="W"    axis_ref="none" />
+     </group>
+      
+      <!-- V grid -->
+      
+      <group id="grid_V"  axis_ref="depthv" grid_ref="grid_V">
+	<field id="vtau"         description="Wind Stress along j-axis"                    unit="N/m2" axis_ref="none" />
+	<field id="voce"         description="ocean current along j-axis"                  unit="m/s"                  />
+	<field id="voce_eff"     description="Effective ocean current along j-axis"        unit="m/s"                  />
+	<!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="voce_eiv"     description="EIV ocean current along j-axis"              unit="m/s"                  />
+	<!-- voce_eiv: available with key_trabbl_adv -->
+	<field id="voce_bbl"     description="BBL ocean current along j-axis"              unit="m/s"                  />
+	<!-- variables available with key_diaar5 -->
+	<field id="v_masstr"     description="ocean eulerian mass transport along j-axis"  unit="kg/s"                 />
+	<field id="v_heattr"     description="ocean eulerian heat transport along j-axis"  unit="W"    axis_ref="none" />
+	<field id="veiv_heattr"  description="ocean bolus heat transport along j-axis"     unit="W"    axis_ref="none" />
+	<field id="vdiff_heattr" description="ocean diffusion heat transport along j-axis" unit="W"    axis_ref="none" />
+      </group>
+      
+      <!-- W grid -->
+      
+      <group id="grid_W"  axis_ref="depthw" grid_ref="grid_W">
+	<field id="woce"         description="ocean vertical velocity"                     unit="m/s"                  />
+	<field id="woce_eff"     description="effective ocean vertical velocity"           unit="m/s"                  />
+	<!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+	<field id="woce_eiv"     description="EIV ocean vertical velocity"                 unit="m/s"                  />
+	<!-- woce_eiv: available with key_trabbl_adv -->
+	<field id="woce_bbl"     description="BBL ocean vertical velocity"                 unit="m/s"                  />
+	<field id="avt"          description="vertical eddy diffusivity"                   unit="m2/s"                 />
+	<field id="avm"          description="vertical eddy viscosity"                     unit="m2/s"                 />
+	<!-- avs: available with key_zdfddm -->
+	<field id="avs"          description="salt vertical eddy diffusivity"              unit="m2/s"                 />
+	<!-- avt_evd and avm_evd: available with ln_zdfevd -->
+	<field id="avt_evd"      description="enhanced vertical diffusivity"               unit="m2/s"                 />
+	<field id="avm_evd"      description="enhanced vertical viscosity"                 unit="m2/s"                 />
+	<!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+	<field id="aht2d"        description="lateral eddy diffusivity"                    unit="m2/s" axis_ref="none" />
+	<field id="aht2d_eiv"    description="EIV lateral eddy diffusivity"                unit="m2/s" axis_ref="none" />
+	<!-- avt_tide: available with key_zdftmx -->
+	<field id="av_tide"      description="tidal vertical diffusivity"                  unit="m2/s"                 />
+	<!-- variables available with key_diaar5 -->   
+	<field id="w_masstr"     description="vertical mass trasport"                      unit="kg/s"                 />
+	<field id="w_masstr2"    description="square of vertical mass trasport"            unit="kg2/s2"               />
+      </group>
+          
+      <!-- scalar -->
+      
+      <!-- variables available with key_diaar5 -->
+      <group id="scalar" axis_ref="none" grid_ref="scalarpoint" zoom_ref="1point" >
+	<field id="voltot"     description="global mean volume"                         unit="m3"   />
+	<field id="sshtot"     description="global mean ssh"                            unit="m"    />
+	<field id="sshsteric"  description="global mean ssh steric"                     unit="m"    />
+	<field id="sshthster"  description="global mean ssh thermosteric"               unit="m"    />
+	<field id="masstot"    description="global mean mass"                           unit="kg"   />
+	<field id="temptot"    description="global mean temperature"                    unit="degC" />
+	<field id="saltot"     description="global mean salinity"                       unit="psu"  />
+	<field id="fram_trans" description="Sea Ice Mass Transport Through Fram Strait" unit="kg/s" />
+      </group>
+
+    </field_definition>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+
+  <file_definition output_level="10" enabled=".TRUE.">
+     
+     <file id="POMME025_5d_grid_T" description="ocean T grid variables" output_freq="300" output_level="5" >
+	<field ref="toce"         name="votemper"  />
+	<field ref="soce"         name="vosaline"  />
+	<field ref="sst"          name="sosstsst"  />
+	<field ref="sss"          name="sosaline"  />
+	<field ref="ssh"          name="sossheig"  />
+	<field ref="emp"          name="sowaflup"  />
+	<field ref="qsr"          name="soshfldo"  />
+	<field ref="emps"         name="sowaflcd"  />
+	<field ref="qns+qsr"      name="sohefldo"  />
+	<field ref="mldr10_1"     name="somxl010"  />
+	<field ref="mldkz5"       name="somixhgt"  />
+	<field ref="qrp"          name="sohefldp"  />
+	<field ref="erp"          name="sowafldp"  />
+	<field ref="mldr10_1"     name="sobowlin"  operation="t_max(X)" />
+	<field ref="mlddzt"       name="sothedep"  />
+	<field ref="20d"          name="so20chgt"  />
+	<field ref="28d"          name="so28chgt"  />
+	<field ref="hc300"        name="sohtc300"  />
+    </file>
+   
+    <file id="POMME025_5d_grid_U" description="ocean U grid variables" output_freq="300" output_level="5" >
+	<field ref="uoce"         name="vozocrtx"  />
+	<field ref="uoce_eiv"     name="vozoeivu"  />
+	<field ref="utau"         name="sozotaux"  />
+    </file>
+  
+    <file id="POMME025_5d_grid_V" description="ocean V grid variables" output_freq="300" output_level="5" >
+	<field ref="voce"         name="vomecrty"  />
+	<field ref="voce_eiv"     name="vomeeivv"  />
+	<field ref="vtau"         name="sometauy"  />
+    </file>
+ 
+    <file id="POMME025_5d_grid_W" description="ocean W grid variables" output_freq="300" output_level="5" >
+	<field ref="woce"         name="vovecrtz" />
+	<field ref="woce_eiv"     name="voveeivw" />
+	<field ref="avt"          name="votkeavt" />
+	<field ref="avt_evd"      name="votkeevd" />
+	<field ref="avm"          name="votkeavm" />
+	<field ref="avm_evd"      name="votkeevm" />
+	<field ref="avs"          name="voddmavs" />
+	<field ref="aht2d"        name="soleahtw" />
+	<field ref="aht2d_eiv"    name="soleaeiw" />
+    </file>
+  
+  </file_definition>
+
+    <!-- 
+============================================================================================================
+=                                           grid definition                                                =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+
+  <axis_definition>  
+     <axis id="deptht" description="Vertical T levels" unit="m" positive=".false." />
+     <axis id="depthu" description="Vertical U levels" unit="m" positive=".false." />
+     <axis id="depthv" description="Vertical V levels" unit="m" positive=".false." />
+     <axis id="depthw" description="Vertical W levels" unit="m" positive=".false." />
+     <axis id="none" description="axe non defini" unit="none" size="1" />
+  </axis_definition> 
+
+  <grid_definition>
+    <grid id="grid_T" description="grid T" />
+    <grid id="grid_U" description="grid U" />
+    <grid id="grid_V" description="grid V" />
+    <grid id="grid_W" description="grid W" />
+    <grid id="scalarpoint" description="scalar" >
+      <zoom id="1point" ibegin="1" jbegin="1" ni="1" nj="1" />
+    </grid>
+  </grid_definition>    
+
+</context>
+
+</simulation>
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/namelist
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/namelist	(revision 1844)
@@ -0,0 +1,703 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namzgr, namzgr_sco, namdom)
+!!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
+!!                                    namsbc_cpl, namqsr, namsbc_rnf, namsbc_ssr, namsbc_alb)
+!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              9 - diagnostics      (namtrd, namgap, namspr, namflo, namptr)
+!!              9 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical use .true./.false., not .TRUE./.FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun            parameters of the run
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number
+   cn_exp      = "POMM025" !  experience name 
+   nn_it000    =       1   !  first time step
+   nn_itend    =   21900   !  last  time step (std 5475)
+   nn_date0    =  19880101 !  initial calendar date yymmdd (used if nrstdt=1)
+   nn_leapy    =       0   !  Leap year calendar (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =   21900   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =     300   !  frequency of write in the output file   (modulo referenced to nit000)
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_clobber  = .true.    !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nn_rstctl   =       0       !  restart control = 0 nit000 is not compared to the restart file value
+                               !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                               !                  = 2 calendar parameters read in the restart file
+   cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+/
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namzgr       vertical coordinate
+!!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   rn_sbot_min =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_thetb    =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   rn_rmax     =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+   ln_s_sigma  = .false.   !  hybrid s-sigma coordinates
+   rn_bb       =    0.8    !  stretching with s-sigma
+   rn_hc       =  150.0    !  critical depth with s-sigma 
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute (=0) or read(=1) the bathymetry file
+   nn_closea   =    0      !  closed seas and lakes are removed (=0) or kept (=1) from the ORCA domain
+   nn_msh      =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   rn_e3zps_min=   25.     !  the thickness of the partial step is set larger than the minimum
+   rn_e3zps_rat=    0.2    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+                           !
+   rn_rdt      = 1440.     !  time step for the dynamics (and tracer if nacc=0)   ==> 5760
+   nn_baro     =   64      !  number of barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
+                                 !                          =0, not used, rdt = rdttra
+   rn_rdtmin   = 1440.          !  minimum time step on tracers (used if nacc=1)
+   rn_rdtmax   = 1440.          !  maximum time step on tracers (used if nacc=1)
+   rn_rdth     =  800.           !  depth variation of tracer time step  (used if nacc=1)
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc        surface boundary condition
+!!   namsbc_ana    analytical         formulation
+!!   namsbc_flx    flux               formulation
+!!   namsbc_clio   CLIO bulk formulea formulation
+!!   namsbc_core   CORE bulk formulea formulation
+!!   namsbc_cpl    CouPLed            formulation                       ("key_coupled")
+!!   namtra_qsr    penetrative solar radiation
+!!   namsbc_rnf    river runoffs
+!!   namsbc_ssr    sea surface restoring term (for T and/or S)
+!!   namsbc_alb    albedo parameters
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .false.   !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .false.   !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .true.    !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stresses recomputed each ocean time step ("key_lim3" only)
+                           !                       =2 combination of 0 and 1 cases             ("key_lim3" only)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .true.    !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked 
+                           !                     =1 global mean of e-p-r set to zero at each time step 
+                           !                     =2 annual global mean of e-p-r set to zero
+                           !                     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   0       !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.5     !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_q0       =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'utau'       ,        24         ,    'utau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_vtau     = 'vtau'       ,        24         ,    'vtau'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qtot     = 'qtot'       ,        24         ,    'qtot'  ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_qsr      = 'qsr'        ,        24         ,    'qsr'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_emp      = 'emp'        ,        24         ,    'emp'   ,     .false.    , .false. , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_utau     = 'taux_1m'    ,       -1          , 'sozotaux' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_vtau     = 'tauy_1m'    ,       -1          , 'sometauy' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_wndm     = 'flx'        ,       -1          , 'socliowi' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_tair     = 'flx'        ,       -1          , 'socliot2' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_humi     = 'flx'        ,       -1          , 'socliohu' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_ccov     = 'flx'        ,       -1          , 'socliocl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+   sn_prec     = 'flx'        ,       -1          , 'socliopl' ,    .false.     , .true.  , 'yearly'  , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name      ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !                  !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_wndi     = 'u10_1988'       ,       24          , 'u10'      ,    .true.      , .false. ,   'yearly' , ''
+   sn_wndj     = 'v10_1988'       ,       24          , 'v10'      ,    .true.      , .false. ,   'yearly' , ''
+   sn_qsr      = 'radsw_1988'     ,       24          , 'radsw'    ,    .true.      , .false. ,   'yearly' , ''
+   sn_qlw      = 'radlw_1988'     ,       24          , 'radlw'    ,    .true.      , .false. ,   'yearly' , ''
+   sn_tair     = 't2_1988.nc'     ,       24          , 't2'       ,    .true.      , .false. ,   'yearly' , ''
+   sn_humi     = 'q2_1988'        ,       24          , 'q2'       ,    .true.      , .false. ,   'yearly' , ''
+   sn_prec     = 'precip_1988.nc' ,       -1          , 'precip'   ,    .true.      , .false. ,   'yearly' , ''
+   sn_tdif     = 'taudif_core'    ,       24          , 'taudif'   ,    .true.      , .true.  ,   'yearly'  ,''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .false.   !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data ?
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+                                       ! send
+cn_snd_temperature= 'weighted oce and ice'  ! 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_albedo     = 'weighted ice'          ! 'none' 'weighted ice' 'mixed oce-ice'
+cn_snd_thickness  = 'none'                  ! 'none' 'weighted ice and snow'
+cn_snd_crt_nature = 'none'                  ! 'none' 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_crt_refere = 'spherical'             ! 'spherical' 'cartesian'
+cn_snd_crt_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_snd_crt_grid   = 'T'                     ! 'T'
+                                       ! receive
+cn_rcv_w10m       = 'none'                  ! 'none' 'coupled'
+cn_rcv_taumod     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_tau_nature = 'oce only'              ! 'oce only' 'oce and ice' 'mixed oce-ice'
+cn_rcv_tau_refere = 'cartesian'             ! 'spherical' 'cartesian'
+cn_rcv_tau_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_rcv_tau_grid   = 'U,V'                   ! 'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+cn_rcv_dqnsdt     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_qsr        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_qns        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_emp        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_rnf        = 'coupled'               ! 'coupled' 'climato' 'mixed'
+cn_rcv_cal        = 'coupled'               ! 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl_co2   !   coupled ocean/biogeo/atmosphere model            ("key_cpl_carbon_cycle")
+!-----------------------------------------------------------------------
+cn_snd_co2        = 'coupled'         ! send    :  'none' 'coupled'
+cn_rcv_co2        = 'coupled'         ! receive : 'none' 'coupled'
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_chl      = 'chlorophyll',        -1         , 'CHLA'     ,    .true.      , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_traqsr   = .true.    !  Light penetration (T) or not (F)
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   rn_si2      =   62.0    !  3 bands: longest depth of extinction (for blue waveband & 0.01 mg/m2 Chl)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_rnf      = 'runoff_1m_nomask' ,  -1         , 'sorunoff' ,    .true.      , .true.  , 'yearly'  , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask' ,   0         , 'socoefr'  ,    .false.     , .true.  , 'yearly'  , ''       , ''
+ 
+   cn_dir       = './'      !  root directory for the location of the runoff files
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =  0.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+   rn_rfact     =   1.e0    !  multiplicative factor for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sst      = 'sst_data'   ,        24         ,  'sst'     ,     .false.    , .false. , 'yearly'  , ''       , ''
+   sn_sss      = 'sss_1m'     ,        -1         ,  'vosaline',     .true.     , .true.  , 'yearly'  , ''       , ''
+    
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     1     !  add a damping     term in the surface freshwater flux (=2) 
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day/psu]
+   ln_sssr_bnd =   .true.  !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/      
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
+   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
+   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphdi   =    0.72   !  (Pyane, 1972)
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcla        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   nambdy        Unstructured open boundaries                         ("key_bdy")
+!!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   nn_cla      =    0      !  advection between 2 ocean pts separates by land
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .false.    !  impose the total volume conservation (T) or not (F)
+    ln_obc_fla = .false.   !  Flather open boundary condition 
+    nn_obcdta  =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cn_obcdta  = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rn_dpein   =    1.     !  damping time scale for inflow at east  open boundary
+    rn_dpwin   =    1.     !     -           -         -       west    -      -
+    rn_dpnin   =   30.     !     -           -         -       north   -      -
+    rn_dpsin   =    1.     !     -           -         -       south   -      -
+    rn_dpeob   = 1500.     !  time relaxation (days) for the east  open boundary
+    rn_dpwob   =   15.     !     -           -         -     west    -      -
+    rn_dpnob   =  150.     !     -           -         -     north   -      -
+    rn_dpsob   =   15.     !     -           -         -     south   -      -
+    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R)
+                           !  = 1 the total volume remains constant
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+    nn_cln_update = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    rn_sponge_tra = 2880.  !  coefficient for tracer   sponge layer [s]
+    rn_sponge_dyn = 2880.  !  coefficient for dynamics sponge layer [s]
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    3      !  type of bottom friction :   = 0 : no   slip,  = 2 : nonlinear friction
+                           !                              = 3 : free slip,  = 1 :    linear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux 
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   rn_ahtbbl   =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   namtra_adv    advection scheme
+!!   namtra_ldf    lateral diffusion scheme
+!!   namtra_dmp    T & S newtonian damping                              ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   rn_alpha    =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rn_beta     =    0.001  !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
+   ln_traadv_tvd    =  .true.   !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                           !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+                           !  Coefficient
+   rn_aht_0         =   300.    !     horizontal eddy diffusivity for tracers [m2/s]
+   rn_ahtb_0        =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_aeiv_0        =     0.    !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      ('key_tradmp')
+!-----------------------------------------------------------------------
+   nn_hdmp     =   1       !  horizontal shape =-1, damping in Med and Red Seas only
+                           !                   =XX, damping poleward of XX degrees (XX>0)
+                           !                      + F(distance-to-coast) + Red and Med Seas
+   nn_zdmp     =    1      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   rn_surf     =   50.     !  surface time scale of damping   [days]
+   rn_bot      =  360.     !  bottom  time scale of damping   [days]
+   rn_dep      =  800.     !  depth of transition between rn_surf and rn_bot [meters]
+   nn_file     =    0      !  create a damping.coeff NetCDF file (=1) or not (=0)
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
+   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   rn_gamma    = 0.e0      !  weighting coefficient (wdj scheme)
+   ln_dynhpg_imp = .true.  !  time stepping: semi-implicit time scheme  (T)
+                                 !           centered      time scheme  (F)
+   nn_dynhpg_rst =  0            ! =1 dynhpg restartable restart or not (=0)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                           !  Type of the operator : 
+   ln_dynldf_lap    =  .false.  !  laplacian operator         
+   ln_dynldf_bilap  =  .true.  !  bilaplacian operator    
+                           !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+                           !  Coefficient
+   rn_ahm_0    = -1.5e11        !  horizontal eddy viscosity   [m2/s]
+   rn_ahmb_0   =    500.        !  background eddy viscosity for ldf_iso [m2/s]
+/
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namzdf_ric    richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namzdf_tke    TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namzdf_kpp    KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namzdf_ddm    double diffusive mixing parameterization         ("key_zdfddm"      )
+!!       namzdf_tmx    tidal mixing parameterization                    ("key_zdftmx"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.e-4   !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.e-5   !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    0      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avevd    =  100.     !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative algorithm (T) or not (F)
+   nn_npc      =    1            !  frequency of application of npc
+   nn_npcp     =  365            !  npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+   nn_zdfexp   =    3            !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    = 100.e-4   !  maximum value of the vertical viscosity
+   rn_alp      =   5.      !  coefficient of the parameterization
+   nn_ric      =   2       !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =   3.75    !  coef. of the surface input of tke
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  !  background shear (>0)
+   nn_mxl      =   3       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.4     !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.4     !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source (rn_efr * en)
+                           !        = 2 additional tke source (rn_efr * en) applied only at the base of the mixed layer
+                           !        = 3 additional tke source (HF contribution: mean of stress module - module of mean stress)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m at high latitudes
+                           !        = 2  30 meters constant depth penetration
+                           !  otion used only if nn_etau = 1 or 2: 
+   rn_efr      =   0.05    !     fraction of surface tke value which penetrates inside the ocean
+                           !  otion used only if nn_etau = 3:
+   rn_addhft   =  -1.e-3   !     add offset   applied to the "mean of stress module - module of mean stress" (always kept > 0)
+   rn_sclhft   =   1.      !     scale factor applied to the "mean of stress module - module of mean stress"
+   ln_lc       = .false.   !  Langmuir cell parameterisation
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+   ln_kpprimix = .true.    !  shear instability mixing 
+   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
+   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency 
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
+!!   namctl            Control prints & Benchmark
+!!   namsol            elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
+   rn_eps      =  1.e-6    !  absolute precision of the solver
+   nn_nmin     =    300    !  minimum of iterations for the SOR solver
+   nn_nmax     =    800    !  maximum of iterations for the SOR solver
+   nn_nmod     =     10    !  frequency of test for the SOR solver
+   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
+   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'S'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni        =    1      !  jpni   number of processors following i
+   jpnj        =    1      !  jpnj   number of processors following j
+   jpnij       =    1      !  jpnij  number of local domains
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_bench    =    0      !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nn_bit_cmp  =    0      !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namflo       float parameters                                      ("key_float")
+!!   namptr       Poleward Transport Diagnostics
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ('key_trdmld' or  "key_trdvor")
+!-----------------------------------------------------------------------
+   nn_trd      = 365       !  time step frequency dynamics and tracers trends
+   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   nn_gap     =  15        !  time-step frequency of model-data gap computation
+   nn_prg     =  10        !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nn_writefl=      75    !  frequency of writing in float output file 
+    nn_stockfl=    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
+   ln_diaznl  = .false.    !  Add zonal means and meridional stream functions
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   nf_ptr     =  1         !  Frequency of ptr computation [time step]
+   nf_ptr_wri =  15        !  Frequency of ptr outputs
+/
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/xmlio_server.def
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/xmlio_server.def	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/EXP00/xmlio_server.def	(revision 1844)
@@ -0,0 +1,20 @@
+! xmlio_server namelist
+!
+! using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
+! using_oasis : .TRUE.(.FALSE.) if nemo is coupled through OASIS
+! client_id   : used only for OASIS, NEMO      id in the namecouple 
+! server_id   : used only for OASIS, io_server id in the namecouple
+!
+&coupling_param
+  using_server = .FALSE.
+  using_oasis  = .FALSE.
+  client_id    = 'nemo.x'
+  server_id    = 'ionemo'
+/
+
+! global_mpi_buffer_size: size in Mo of the MPI buffer used by the io_server
+&mpi_param
+  global_mpi_buffer_size = 512
+/  
+  
+  
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make	(revision 1844)
@@ -0,0 +1,11250 @@
+# $Header$
+# some variables
+TMP = ../../../tmp
+
+#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function
+#          This doesnt happen whith Fortran 90 compilers but
+#          Check your compilers option in consequence when using real F95 compilers
+
+#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) 
+#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) 
+#-Q- platine L_X = $(L_O) 
+#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) 
+#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx8mercure  L_X = $(L_O)
+#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) 
+#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) 
+#-Q- sx9mercure  L_X = $(L_O)
+#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) 
+#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sx8brodie  L_X = $(L_O)
+#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) 
+#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- sxdkrz  L_X = $(L_O) -ftrace
+#-Q- es2  # Compiler options for NEMO (Earth Simulator)
+#-Q- es2  # for super perfs!
+#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  # regular options!
+#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- es2  L_X = $(L_O)
+#-Q- linux  # Compiler options for NEMO (pgf version)
+#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- linux  L_X = -r8 -O3
+#-Q- lxiv7  # Compiler options for NEMO (ifc version)
+#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv7  L_X = -r8 -O3
+#-Q- lxiv8  # Compiler options for NEMO (ifort version)
+#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- lxiv8  L_X = -r8 -O3
+#-Q- g95  # Compiler options for NEMO (g95 version)
+#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- g95  L_X = -r8 -O3
+#-Q- gfortran  # Compiler options for NEMO (gfortran version)
+#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- gfortran  L_X = -fdefault-real-8
+#-Q- aix    # Compiler options for NEMO (aix version)
+#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix   L_O = $(F_P) -q64 -O3
+#-Q- aix   L_X = $(L_O)
+#-Q- aix6    # Compiler options for NEMO (aix6 version)
+#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- aix6   L_O = $(F_P) -q64 -O3
+#-Q- aix6   L_X = $(L_O)
+#-Q- babel  # Compiler options for NEMO (blue gene version)
+#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- babel  L_X = $(L_O)
+#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)
+#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)
+#-Q- osxxlf    L_X = -qrealsize=8 -O3
+PREF=
+#-Q- sx8mercure	PREF=i.
+#-Q- sx9mercure	PREF=i.
+#-Q- sx8brodie	PREF=i.
+#-Q- sxdkrz	PREF=i.
+#-Q- es2	PREF=i.
+
+# add suffix to P_P
+override P_P := $(P_P:%=$(prefix)%)
+
+# Some tests to define variables related to Agrif compilation
+# Please do not change 
+ifneq (,$(findstring key_agrif,$(P_P)))
+AGRIF=use
+else
+AGRIF=notuse
+AGRIF_LIB=
+endif
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+AGRIF_MPI=-DAGRIF_MPI
+else
+AGRIF_MPI=
+endif
+
+# Some tests to define variables related to xmlioserver compilation
+# Please do not change 
+ifneq (,$(findstring key_iomput,$(P_P)))
+IOSERVER=use
+override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90
+override USER_INC += -I../../../lib/libxmlio_server
+ifneq (,$(findstring key_mpp_mpi,$(P_P)))
+IOSERVER_MPI=
+else
+IOSERVER_MPI=-DNO_MPI
+endif
+else
+IOSERVER=notuse
+endif
+
+# A variables related to xmlioserver compilationi (fcm or AA_make)
+# Please do not change 
+override FCM ?= notuse
+
+#check key compatibility
+keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))
+
+KEY_LIST = \
+     key_agrif \
+     key_antarctic \
+     key_arctic \
+     key_bdy \
+     key_c1d \
+     key_coupled \
+     key_cpl_albedo \
+     key_cpl_carbon_cycle \
+     key_cpl_discharge \
+     key_cpl_ocevel \
+     key_cpl_rootexchg \
+     key_diaar5 \
+     key_diaeiv \
+     key_diagap \
+     key_diahdy \
+     key_diahth \
+     key_diainstant \
+     key_diaspr \
+     key_dimgout \
+     key_dtasal \
+     key_dtatem \
+     key_dynldf_c1d \
+     key_dynldf_c2d \
+     key_dynldf_c3d \
+     key_dynspg_exp \
+     key_dynspg_flt \
+     key_dynspg_ts \
+     key_eel_r2 \
+     key_eel_r5 \
+     key_eel_r6 \
+     key_esopa \
+     key_floats \
+     key_flx_bulk_monthly \
+     key_flx_core \
+     key_flx_forced_daily \
+     key_gyre \
+     key_iomput \
+     key_kppcustom \
+     key_kpplktb \
+     key_ldfslp \
+     key_lim2 \
+     key_lim3 \
+     key_mpp_dyndist \
+     key_mpp_mpi \
+     key_mpp_shmem \
+     key_noslip_accurate \
+     key_oasis3 \
+     key_oasis4 \
+     key_obc \
+     key_orca_lev10 \
+     key_orca_r025 \
+     key_orca_r05 \
+     key_orca_r2 \
+     key_orca_r4 \
+     key_pisces \
+     key_pomme_r025 \
+     key_top \
+     key_trabbc \
+     key_trabbl_adv \
+     key_trabbl_dif \
+     key_tradmp \
+     key_traldf_ano \
+     key_traldf_c1d \
+     key_traldf_c2d \
+     key_traldf_c3d \
+     key_traldf_eiv \
+     key_trddyn \
+     key_trdmld \
+     key_trdtra \
+     key_trdvor \
+     key_vectopt_loop \
+     key_vectopt_memory \
+     key_vvl \
+     key_zco \
+     key_zdfcst \
+     key_zdfddm \
+     key_zdfkpp \
+     key_zdfric \
+     key_zdftke \
+     key_zdftke_old \
+     key_zdftmx 
+# .o file list in the library
+LIB_OBJ = \
+		$(MODEL_LIB)(lib_cray.o)\
+		$(MODEL_LIB)(lib_print.o)\
+		$(MODEL_LIB)(agrif_opa_interp.o)\
+		$(MODEL_LIB)(agrif_opa_sponge.o)\
+		$(MODEL_LIB)(agrif_opa_update.o)\
+		$(MODEL_LIB)(albedo.o)\
+		$(MODEL_LIB)(bdy_oce.o)\
+		$(MODEL_LIB)(bdy_par.o)\
+		$(MODEL_LIB)(bdydta.o)\
+		$(MODEL_LIB)(bdydyn.o)\
+		$(MODEL_LIB)(bdyini.o)\
+		$(MODEL_LIB)(bdytides.o)\
+		$(MODEL_LIB)(bdytra.o)\
+		$(MODEL_LIB)(bdyvol.o)\
+		$(MODEL_LIB)(c1d.o)\
+		$(MODEL_LIB)(cla.o)\
+		$(MODEL_LIB)(cla_div.o)\
+		$(MODEL_LIB)(cla_dynspg.o)\
+		$(MODEL_LIB)(closea.o)\
+		$(MODEL_LIB)(cpl_oasis3.o)\
+		$(MODEL_LIB)(cpl_oasis4.o)\
+		$(MODEL_LIB)(daymod.o)\
+		$(MODEL_LIB)(diaar5.o)\
+		$(MODEL_LIB)(diadimg.o)\
+		$(MODEL_LIB)(diafwb.o)\
+		$(MODEL_LIB)(diagap.o)\
+		$(MODEL_LIB)(diahdy.o)\
+		$(MODEL_LIB)(diahth.o)\
+		$(MODEL_LIB)(dianam.o)\
+		$(MODEL_LIB)(diaptr.o)\
+		$(MODEL_LIB)(diawri.o)\
+		$(MODEL_LIB)(diawri_c1d.o)\
+		$(MODEL_LIB)(divcur.o)\
+		$(MODEL_LIB)(dom_ice_2.o)\
+		$(MODEL_LIB)(dom_oce.o)\
+		$(MODEL_LIB)(domain.o)\
+		$(MODEL_LIB)(domcfg.o)\
+		$(MODEL_LIB)(domhgr.o)\
+		$(MODEL_LIB)(dommsk.o)\
+		$(MODEL_LIB)(domngb.o)\
+		$(MODEL_LIB)(domstp.o)\
+		$(MODEL_LIB)(domvvl.o)\
+		$(MODEL_LIB)(domwri.o)\
+		$(MODEL_LIB)(domzgr.o)\
+		$(MODEL_LIB)(dtasal.o)\
+		$(MODEL_LIB)(dtatem.o)\
+		$(MODEL_LIB)(dynadv.o)\
+		$(MODEL_LIB)(dynadv_cen2.o)\
+		$(MODEL_LIB)(dynadv_ubs.o)\
+		$(MODEL_LIB)(dynbfr.o)\
+		$(MODEL_LIB)(dyncor_c1d.o)\
+		$(MODEL_LIB)(dynhpg.o)\
+		$(MODEL_LIB)(dynkeg.o)\
+		$(MODEL_LIB)(dynldf.o)\
+		$(MODEL_LIB)(dynldf_bilap.o)\
+		$(MODEL_LIB)(dynldf_bilapg.o)\
+		$(MODEL_LIB)(dynldf_iso.o)\
+		$(MODEL_LIB)(dynldf_lap.o)\
+		$(MODEL_LIB)(dynnxt.o)\
+		$(MODEL_LIB)(dynnxt_c1d.o)\
+		$(MODEL_LIB)(dynspg.o)\
+		$(MODEL_LIB)(dynspg_exp.o)\
+		$(MODEL_LIB)(dynspg_flt.o)\
+		$(MODEL_LIB)(dynspg_oce.o)\
+		$(MODEL_LIB)(dynspg_ts.o)\
+		$(MODEL_LIB)(dynvor.o)\
+		$(MODEL_LIB)(dynzad.o)\
+		$(MODEL_LIB)(dynzdf.o)\
+		$(MODEL_LIB)(dynzdf_exp.o)\
+		$(MODEL_LIB)(dynzdf_imp.o)\
+		$(MODEL_LIB)(eosbn2.o)\
+		$(MODEL_LIB)(fldread.o)\
+		$(MODEL_LIB)(flo4rk.o)\
+		$(MODEL_LIB)(flo_oce.o)\
+		$(MODEL_LIB)(floats.o)\
+		$(MODEL_LIB)(floblk.o)\
+		$(MODEL_LIB)(flodom.o)\
+		$(MODEL_LIB)(flowri.o)\
+		$(MODEL_LIB)(geo2ocean.o)\
+		$(MODEL_LIB)(ice_2.o)\
+		$(MODEL_LIB)(iceini_2.o)\
+		$(MODEL_LIB)(in_out_manager.o)\
+		$(MODEL_LIB)(iom.o)\
+		$(MODEL_LIB)(iom_def.o)\
+		$(MODEL_LIB)(iom_ioipsl.o)\
+		$(MODEL_LIB)(iom_nf90.o)\
+		$(MODEL_LIB)(iom_rstdimg.o)\
+		$(MODEL_LIB)(istate.o)\
+		$(MODEL_LIB)(lbclnk.o)\
+		$(MODEL_LIB)(lbcnfd.o)\
+		$(MODEL_LIB)(ldfdyn.o)\
+		$(MODEL_LIB)(ldfdyn_oce.o)\
+		$(MODEL_LIB)(ldfeiv.o)\
+		$(MODEL_LIB)(ldfslp.o)\
+		$(MODEL_LIB)(ldftra.o)\
+		$(MODEL_LIB)(ldftra_oce.o)\
+		$(MODEL_LIB)(lib_mpp.o)\
+		$(MODEL_LIB)(limadv_2.o)\
+		$(MODEL_LIB)(limdia_2.o)\
+		$(MODEL_LIB)(limdmp_2.o)\
+		$(MODEL_LIB)(limdyn_2.o)\
+		$(MODEL_LIB)(limhdf_2.o)\
+		$(MODEL_LIB)(limistate_2.o)\
+		$(MODEL_LIB)(limmsh_2.o)\
+		$(MODEL_LIB)(limrhg_2.o)\
+		$(MODEL_LIB)(limrst_2.o)\
+		$(MODEL_LIB)(limsbc_2.o)\
+		$(MODEL_LIB)(limtab_2.o)\
+		$(MODEL_LIB)(limthd_2.o)\
+		$(MODEL_LIB)(limthd_lac_2.o)\
+		$(MODEL_LIB)(limthd_zdf_2.o)\
+		$(MODEL_LIB)(limtrp_2.o)\
+		$(MODEL_LIB)(limwri_2.o)\
+		$(MODEL_LIB)(mppini.o)\
+		$(MODEL_LIB)(oasis4_date.o)\
+		$(MODEL_LIB)(obc_oce.o)\
+		$(MODEL_LIB)(obc_par.o)\
+		$(MODEL_LIB)(obcdta.o)\
+		$(MODEL_LIB)(obcdyn.o)\
+		$(MODEL_LIB)(obcdyn_bt.o)\
+		$(MODEL_LIB)(obcfla.o)\
+		$(MODEL_LIB)(obcini.o)\
+		$(MODEL_LIB)(obcrad.o)\
+		$(MODEL_LIB)(obcrst.o)\
+		$(MODEL_LIB)(obctra.o)\
+		$(MODEL_LIB)(obcvol.o)\
+		$(MODEL_LIB)(oce.o)\
+		$(MODEL_LIB)(opa.o)\
+		$(MODEL_LIB)(par_ice_2.o)\
+		$(MODEL_LIB)(par_kind.o)\
+		$(MODEL_LIB)(par_oce.o)\
+		$(MODEL_LIB)(phycst.o)\
+		$(MODEL_LIB)(prtctl.o)\
+		$(MODEL_LIB)(restart.o)\
+		$(MODEL_LIB)(sbc_ice.o)\
+		$(MODEL_LIB)(sbc_oce.o)\
+		$(MODEL_LIB)(sbcana.o)\
+		$(MODEL_LIB)(sbcblk_clio.o)\
+		$(MODEL_LIB)(sbcblk_core.o)\
+		$(MODEL_LIB)(sbccpl.o)\
+		$(MODEL_LIB)(sbcflx.o)\
+		$(MODEL_LIB)(sbcfwb.o)\
+		$(MODEL_LIB)(sbcice_if.o)\
+		$(MODEL_LIB)(sbcice_lim.o)\
+		$(MODEL_LIB)(sbcice_lim_2.o)\
+		$(MODEL_LIB)(sbcmod.o)\
+		$(MODEL_LIB)(sbcrnf.o)\
+		$(MODEL_LIB)(sbcssm.o)\
+		$(MODEL_LIB)(sbcssr.o)\
+		$(MODEL_LIB)(sol_oce.o)\
+		$(MODEL_LIB)(solmat.o)\
+		$(MODEL_LIB)(solpcg.o)\
+		$(MODEL_LIB)(solsor.o)\
+		$(MODEL_LIB)(solver.o)\
+		$(MODEL_LIB)(sshwzv.o)\
+		$(MODEL_LIB)(step.o)\
+		$(MODEL_LIB)(step_c1d.o)\
+		$(MODEL_LIB)(stpctl.o)\
+		$(MODEL_LIB)(thd_ice_2.o)\
+		$(MODEL_LIB)(traadv.o)\
+		$(MODEL_LIB)(traadv_cen2.o)\
+		$(MODEL_LIB)(traadv_eiv.o)\
+		$(MODEL_LIB)(traadv_muscl.o)\
+		$(MODEL_LIB)(traadv_muscl2.o)\
+		$(MODEL_LIB)(traadv_qck.o)\
+		$(MODEL_LIB)(traadv_tvd.o)\
+		$(MODEL_LIB)(traadv_ubs.o)\
+		$(MODEL_LIB)(trabbc.o)\
+		$(MODEL_LIB)(trabbl.o)\
+		$(MODEL_LIB)(tradmp.o)\
+		$(MODEL_LIB)(traldf.o)\
+		$(MODEL_LIB)(traldf_bilap.o)\
+		$(MODEL_LIB)(traldf_bilapg.o)\
+		$(MODEL_LIB)(traldf_iso.o)\
+		$(MODEL_LIB)(traldf_lap.o)\
+		$(MODEL_LIB)(tranpc.o)\
+		$(MODEL_LIB)(tranxt.o)\
+		$(MODEL_LIB)(traqsr.o)\
+		$(MODEL_LIB)(trasbc.o)\
+		$(MODEL_LIB)(trazdf.o)\
+		$(MODEL_LIB)(trazdf_exp.o)\
+		$(MODEL_LIB)(trazdf_imp.o)\
+		$(MODEL_LIB)(trc_oce.o)\
+		$(MODEL_LIB)(trdicp.o)\
+		$(MODEL_LIB)(trdicp_oce.o)\
+		$(MODEL_LIB)(trdmld.o)\
+		$(MODEL_LIB)(trdmld_oce.o)\
+		$(MODEL_LIB)(trdmld_rst.o)\
+		$(MODEL_LIB)(trdmod.o)\
+		$(MODEL_LIB)(trdmod_oce.o)\
+		$(MODEL_LIB)(trdvor.o)\
+		$(MODEL_LIB)(trdvor_oce.o)\
+		$(MODEL_LIB)(zdf_oce.o)\
+		$(MODEL_LIB)(zdfbfr.o)\
+		$(MODEL_LIB)(zdfddm.o)\
+		$(MODEL_LIB)(zdfevd.o)\
+		$(MODEL_LIB)(zdfini.o)\
+		$(MODEL_LIB)(zdfkpp.o)\
+		$(MODEL_LIB)(zdfmxl.o)\
+		$(MODEL_LIB)(zdfric.o)\
+		$(MODEL_LIB)(zdftke.o)\
+		$(MODEL_LIB)(zdftke_old.o)\
+		$(MODEL_LIB)(zdftmx.o)\
+		$(MODEL_LIB)(zpshde.o)
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce $(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq ($(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		$(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB) $(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif $(MODEL_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) agrif2model.o model.o 
+ifeq ($(AGRIF),use)
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o agrif2model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(AGRIF_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+else
+		$(F_L) $(L_X) -o $(EXEC_BIN) model.o $(SXMODEL_LIB) $(USER_LIB) $(IOIPSL_LIB) $(NCDF_LIB) $(LIBMPI) $(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq ($(IOSERVER),use)
+ifeq ($(FCM),use)
+	(cd ../../XMLF90; ./configure -arch $(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch $(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; $(M_K) -f Makefile P_P="$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  $(call keycompat,key_iomput,key_agrif)
+ifeq ($(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; $(M_K) -f Makefile P_P="$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq ($(AGRIF),use)
+	@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+	@$(F_C) \
+#-Q- aix		-qsuffix=f=F90 \
+#-Q- aix6		-qsuffix=f=F90 \
+#-Q- babel		-qsuffix=f=F90 \
+#-Q- osxxlf		-qsuffix=f=F90 \
+	$(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix6		-qsource \
+#-Q- aix		-qsource \
+#-Q- babel		-qsource \
+	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@$(F_C) $(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : $(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
+
+# library dependancies
+$(MODEL_LIB):	$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq ($(AGRIF),use) 
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC $*.F90 > OPAFILES/$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \
+#-Q- linux		-SubloopScalar \
+#-Q- g95			-SubloopScalar \
+#-Q- f95			-SubloopScalar \
+#-Q- osf1			-SubloopScalar \
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(P_C) $(P_O) -IOPAFILES/AGRIF_INC OPAFILES/$*.F90 > OPAFILES/AGRIF_MODELFILES/$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/$*.F90 OPAFILES/$*.F90
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		OPAFILES/$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; } 
+else
+		@$(F_C) $(P_P) $(F_O) \
+#-Q- fjvpp		-Z $*.L \
+#-Q- sx8mercure		-R2 \
+#-Q- sx9mercure		-R2 \
+#-Q- sx8brodie		-R2 \
+#-Q- sxdkrz		-R2 \
+#-Q- es2		-R2 \
+#-Q- aix		-qsource \
+#-Q- aix6		-qsource \
+#-Q- babel		-qsource \
+		$*.F90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+		@$(A_C) $(MODEL_LIB) $*.o  > /dev/null
+		@$(RM) $*.[of]
+		@if [ -f $*.mod ] ; then mv $*.mod $(MODDIR)/oce ; fi
+#-Q- aix		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- aix6		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- babel		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- linux		@mv $(PREF)$*.lst $(PREF)$*.L
+#-Q- osxxlf		@mv $(PREF)$*.lst $(PREF)$*.L
+		@if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi
+
+$(MODEL_LIB)(agrif_opa_interp.o) :	\
+	agrif_opa_interp.F90
+$(MODEL_LIB)(agrif_opa_sponge.o) :	\
+	agrif_opa_sponge.F90
+$(MODEL_LIB)(agrif_opa_update.o) :	\
+	agrif_opa_update.F90
+$(MODEL_LIB)(albedo.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	in_out_manager.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	albedo.F90
+$(MODEL_LIB)(bdy_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	bdy_oce.F90
+$(MODEL_LIB)(bdy_par.o) :	\
+	KEY_CPP \
+	bdy_par.F90
+$(MODEL_LIB)(bdydta.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	bdydta.F90
+$(MODEL_LIB)(bdydyn.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdydyn.F90
+$(MODEL_LIB)(bdyini.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdyini.F90
+$(MODEL_LIB)(bdytides.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_par.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	bdytides.F90
+$(MODEL_LIB)(bdytra.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	KEY_CPP \
+	bdytra.F90
+$(MODEL_LIB)(bdyvol.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	bdyvol.F90
+$(MODEL_LIB)(c1d.o) :	\
+	KEY_CPP \
+	c1d.F90
+$(MODEL_LIB)(cla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla.F90
+$(MODEL_LIB)(cla_div.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	cla_div.F90
+$(MODEL_LIB)(cla_dynspg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	cla_dynspg.F90
+$(MODEL_LIB)(closea.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	closea.F90
+$(MODEL_LIB)(cpl_oasis3.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	cpl_oasis3.F90
+$(MODEL_LIB)(cpl_oasis4.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oasis4_date.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	cpl_oasis4.F90
+$(MODEL_LIB)(daymod.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	$(IOIPSL_LIB) \
+	daymod.F90
+$(MODEL_LIB)(diaar5.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diaar5.F90
+$(MODEL_LIB)(diadimg.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diadimg.F90
+$(MODEL_LIB)(diafwb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	diafwb.F90
+$(MODEL_LIB)(diagap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diagap.F90
+$(MODEL_LIB)(diahdy.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahdy.F90
+$(MODEL_LIB)(diahth.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	diahth.F90
+$(MODEL_LIB)(dianam.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	dianam.F90
+$(MODEL_LIB)(diaptr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diaptr.F90
+$(MODEL_LIB)(diawri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(lib_mpp.o) \
+	lib_mpp.F90 \
+	diawri_dimg.h90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri.F90
+$(MODEL_LIB)(diawri_c1d.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	trazdf_exp.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	diawri_c1d.F90
+$(MODEL_LIB)(divcur.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	bdy_par.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	divcur.F90
+$(MODEL_LIB)(dom_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	dom_ice_2.F90
+$(MODEL_LIB)(dom_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dom_oce.F90
+$(MODEL_LIB)(domain.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	domain.F90
+$(MODEL_LIB)(domcfg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	domcfg.F90
+$(MODEL_LIB)(domhgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	domhgr.F90
+$(MODEL_LIB)(dommsk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dommsk.F90
+$(MODEL_LIB)(domngb.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	lib_mpp.F90 \
+	domngb.F90
+$(MODEL_LIB)(domstp.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	domstp.F90
+$(MODEL_LIB)(domvvl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domvvl.F90
+$(MODEL_LIB)(domwri.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domwri.F90
+$(MODEL_LIB)(domzgr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	c1d.F90 \
+	closea.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	domzgr.F90
+$(MODEL_LIB)(dtasal.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtasal.F90
+$(MODEL_LIB)(dtatem.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	dtatem.F90
+$(MODEL_LIB)(dynadv.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv.F90
+$(MODEL_LIB)(dynadv_cen2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_cen2.F90
+$(MODEL_LIB)(dynadv_ubs.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynadv_ubs.F90
+$(MODEL_LIB)(dynbfr.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynbfr.F90
+$(MODEL_LIB)(dyncor_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dyncor_c1d.F90
+$(MODEL_LIB)(dynhpg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynhpg.F90
+$(MODEL_LIB)(dynkeg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynkeg.F90
+$(MODEL_LIB)(dynldf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf.F90
+$(MODEL_LIB)(dynldf_bilap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilap.F90
+$(MODEL_LIB)(dynldf_bilapg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	KEY_CPP \
+	dynldf_bilapg.F90
+$(MODEL_LIB)(dynldf_iso.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_iso.F90
+$(MODEL_LIB)(dynldf_lap.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynldf_lap.F90
+$(MODEL_LIB)(dynnxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynnxt.F90
+$(MODEL_LIB)(dynnxt_c1d.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	KEY_CPP \
+	dynnxt_c1d.F90
+$(MODEL_LIB)(dynspg.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	in_out_manager.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg.F90
+$(MODEL_LIB)(dynspg_exp.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_exp.F90
+$(MODEL_LIB)(dynspg_flt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynspg_oce.F90 \
+	dynzad.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdydyn.F90 \
+	bdyvol.F90 \
+	cla_dynspg.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcdyn.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	dynspg_flt.F90
+$(MODEL_LIB)(dynspg_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	dynspg_oce.F90
+$(MODEL_LIB)(dynspg_ts.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynadv.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcfla.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdfbfr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynspg_ts.F90
+$(MODEL_LIB)(dynvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynkeg.F90 \
+	dynzad.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	dynadv.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynvor.F90
+$(MODEL_LIB)(dynzad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzad.F90
+$(MODEL_LIB)(dynzdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	dynzdf.F90
+$(MODEL_LIB)(dynzdf_exp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_exp.F90
+$(MODEL_LIB)(dynzdf_imp.o) :	\
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	dynzdf_imp.F90
+$(MODEL_LIB)(eosbn2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	eosbn2.F90
+$(MODEL_LIB)(fldread.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	fldread.F90
+$(MODEL_LIB)(flo4rk.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	KEY_CPP \
+	flo4rk.F90
+$(MODEL_LIB)(flo_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	flo_oce.F90
+$(MODEL_LIB)(floats.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	lib_mpp.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	floats.F90
+$(MODEL_LIB)(floblk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	floblk.F90
+$(MODEL_LIB)(flodom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flodom.F90
+$(MODEL_LIB)(flowri.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	flo_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	flowri.F90
+$(MODEL_LIB)(geo2ocean.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	geo2ocean.F90
+$(MODEL_LIB)(ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	ice_2.F90
+$(MODEL_LIB)(iceini_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrst_2.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iceini_2.F90
+$(MODEL_LIB)(in_out_manager.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	in_out_manager.F90
+$(MODEL_LIB)(iom.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	iom.F90
+$(MODEL_LIB)(iom_def.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	iom_def.F90
+$(MODEL_LIB)(iom_ioipsl.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	$(IOIPSL_LIB) \
+	iom_ioipsl.F90
+$(MODEL_LIB)(iom_nf90.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_nf90.F90
+$(MODEL_LIB)(iom_rstdimg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	lbclnk.F90 \
+	iom_rstdimg.F90
+$(MODEL_LIB)(istate.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdyvol.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_dynspg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcfla.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(solpcg.o) \
+	$(MODEL_LIB)(solsor.o) \
+	$(MODEL_LIB)(solver.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdyvol.F90 \
+	c1d.F90 \
+	cla_dynspg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynadv.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcdyn.F90 \
+	obcfla.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	solpcg.F90 \
+	solsor.F90 \
+	solver.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	daymod.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	restart.F90 \
+	zdf_oce.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	istate.F90
+$(MODEL_LIB)(lbclnk.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	KEY_CPP \
+	lbclnk.F90
+$(MODEL_LIB)(lbcnfd.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	lbcnfd.F90
+$(MODEL_LIB)(ldfdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	ldftra_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_antarctic.h90 \
+	ldfdyn_arctic.h90 \
+	ldfdyn_c1d.h90 \
+	ldfdyn_c2d.h90 \
+	ldfdyn_c3d.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldfdyn.F90
+$(MODEL_LIB)(ldfdyn_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldfdyn_oce.F90
+$(MODEL_LIB)(ldfeiv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfeiv.F90
+$(MODEL_LIB)(ldfslp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	ldfslp.F90
+$(MODEL_LIB)(ldftra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldftra_c1d.h90 \
+	ldftra_c2d.h90 \
+	ldftra_c3d.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	ldftra.F90
+$(MODEL_LIB)(ldftra_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	ldftra_oce.F90
+$(MODEL_LIB)(lib_cray.o) :	\
+	lib_cray.f90
+$(MODEL_LIB)(lib_mpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	lib_mpp.F90
+$(MODEL_LIB)(lib_print.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	lib_print.f90
+$(MODEL_LIB)(limadv_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limadv_2.F90
+$(MODEL_LIB)(limdia_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdia_2.F90
+$(MODEL_LIB)(limdmp_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	tradmp.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdmp_2.F90
+$(MODEL_LIB)(limdyn_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limistate_2.F90 \
+	limrhg_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limdyn_2.F90
+$(MODEL_LIB)(limhdf_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	prtctl.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limhdf_2.F90
+$(MODEL_LIB)(limistate_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limistate_2.F90
+$(MODEL_LIB)(limmsh_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	limmsh_2.F90
+$(MODEL_LIB)(limrhg_2.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limrhg_2.F90
+$(MODEL_LIB)(limrst_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	KEY_CPP \
+	limrst_2.F90
+$(MODEL_LIB)(limsbc_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limsbc_2.F90
+$(MODEL_LIB)(limtab_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	KEY_CPP \
+	limtab_2.F90
+$(MODEL_LIB)(limthd_2.o) :	\
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limistate_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limthd_2.F90
+$(MODEL_LIB)(limthd_lac_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	ice_2.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_lac_2.F90
+$(MODEL_LIB)(limthd_zdf_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	cpl_oasis3.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	limistate_2.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	thd_ice_2.F90 \
+	KEY_CPP \
+	limthd_zdf_2.F90
+$(MODEL_LIB)(limtrp_2.o) :	\
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	phycst.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	limtrp_2.F90
+$(MODEL_LIB)(limwri_2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	phycst.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	diadimg.F90 \
+	limwri_dimg_2.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	limwri_2.F90
+$(MODEL_LIB)(model.o) :	\
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	$(MODEL_LIB)(opa.o) \
+	opa.F90 \
+	model.f90
+$(MODEL_LIB)(mppini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	domzgr_substitute.h90 \
+	mppini_2.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	mppini.F90
+$(MODEL_LIB)(oasis4_date.o) :	\
+	KEY_CPP \
+	oasis4_date.F90
+$(MODEL_LIB)(obc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	obc_par.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	obc_oce.F90
+$(MODEL_LIB)(obc_par.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	obc_par_EEL_R5.h90 \
+	obc_par_POMME_R025.h90 \
+	KEY_CPP \
+	obc_par.F90
+$(MODEL_LIB)(obcdta.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	obcdta.F90
+$(MODEL_LIB)(obcdyn.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn.F90
+$(MODEL_LIB)(obcdyn_bt.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcdyn_bt.F90
+$(MODEL_LIB)(obcfla.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	obc_oce.F90 \
+	obcdta.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcfla.F90
+$(MODEL_LIB)(obcini.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcini.F90
+$(MODEL_LIB)(obcrad.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcrad.F90
+$(MODEL_LIB)(obcrst.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	KEY_CPP \
+	obcrst.F90
+$(MODEL_LIB)(obctra.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obctra.F90
+$(MODEL_LIB)(obcvol.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	obc_vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	obcvol.F90
+$(MODEL_LIB)(oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	oce.F90
+$(MODEL_LIB)(opa.o) :	\
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domhgr.o) \
+	$(MODEL_LIB)(dommsk.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domstp.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(domwri.o) \
+	$(MODEL_LIB)(domzgr.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_oce.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	bdytides.F90 \
+	c1d.F90 \
+	cla.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domhgr.F90 \
+	dommsk.F90 \
+	domngb.F90 \
+	domstp.F90 \
+	domvvl.F90 \
+	domwri.F90 \
+	domzgr.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynnxt_c1d.F90 \
+	dynspg.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdyini.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domain.o) \
+	$(MODEL_LIB)(domcfg.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(istate.o) \
+	$(MODEL_LIB)(ldfdyn.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(mppini.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcini.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(step.o) \
+	$(MODEL_LIB)(step_c1d.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdfini.o) \
+	bdy_par.F90 \
+	bdyini.F90 \
+	c1d.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domain.F90 \
+	domcfg.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	istate.F90 \
+	ldfdyn.F90 \
+	ldftra.F90 \
+	lib_mpp.F90 \
+	mppini.F90 \
+	obc_par.F90 \
+	obcini.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	step.F90 \
+	step_c1d.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdfini.F90 \
+	KEY_CPP \
+	opa.F90
+$(MODEL_LIB)(par_ice_2.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	par_ice_2.F90
+$(MODEL_LIB)(par_kind.o) :	\
+	par_kind.F90
+$(MODEL_LIB)(par_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	par_EEL_R2.h90 \
+	par_EEL_R5.h90 \
+	par_EEL_R6.h90 \
+	par_GYRE.h90 \
+	par_ORCA_R025.h90 \
+	par_ORCA_R05.h90 \
+	par_ORCA_R2.h90 \
+	par_ORCA_R4.h90 \
+	par_POMME_R025.h90 \
+	KEY_CPP \
+	par_oce.F90
+$(MODEL_LIB)(phycst.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	phycst.F90
+$(MODEL_LIB)(prtctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lib_mpp.F90 \
+	prtctl.F90
+$(MODEL_LIB)(restart.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	restart.F90
+$(MODEL_LIB)(sbc_ice.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	par_ice_2.F90 \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_ice.F90
+$(MODEL_LIB)(sbc_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sbc_oce.F90
+$(MODEL_LIB)(sbcana.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcana.F90
+$(MODEL_LIB)(sbcblk_clio.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_clio.F90
+$(MODEL_LIB)(sbcblk_core.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcblk_core.F90
+$(MODEL_LIB)(sbccpl.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oasis4_date.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oasis4_date.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dom_oce.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	phycst.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbccpl.F90
+$(MODEL_LIB)(sbcflx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcflx.F90
+$(MODEL_LIB)(sbcfwb.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcfwb.F90
+$(MODEL_LIB)(sbcice_if.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcice_if.F90
+$(MODEL_LIB)(sbcice_lim.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim.F90
+$(MODEL_LIB)(sbcice_lim_2.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limadv_2.o) \
+	$(MODEL_LIB)(limhdf_2.o) \
+	$(MODEL_LIB)(limistate_2.o) \
+	$(MODEL_LIB)(limmsh_2.o) \
+	$(MODEL_LIB)(limrhg_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limtab_2.o) \
+	$(MODEL_LIB)(limthd_lac_2.o) \
+	$(MODEL_LIB)(limthd_zdf_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(thd_ice_2.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	albedo.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limadv_2.F90 \
+	limhdf_2.F90 \
+	limistate_2.F90 \
+	limmsh_2.F90 \
+	limrhg_2.F90 \
+	limrst_2.F90 \
+	limtab_2.F90 \
+	limthd_lac_2.F90 \
+	limthd_zdf_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	thd_ice_2.F90 \
+	tradmp.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	albedo.F90 \
+	c1d.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sbcice_lim_2.F90
+$(MODEL_LIB)(sbcmod.o) :	\
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_ice_2.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(iceini_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limdia_2.o) \
+	$(MODEL_LIB)(limdmp_2.o) \
+	$(MODEL_LIB)(limdyn_2.o) \
+	$(MODEL_LIB)(limrst_2.o) \
+	$(MODEL_LIB)(limsbc_2.o) \
+	$(MODEL_LIB)(limthd_2.o) \
+	$(MODEL_LIB)(limtrp_2.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	albedo.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	dom_ice_2.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	iceini_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limdia_2.F90 \
+	limdmp_2.F90 \
+	limdyn_2.F90 \
+	limrst_2.F90 \
+	limsbc_2.F90 \
+	limthd_2.F90 \
+	limtrp_2.F90 \
+	limwri_2.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcrnf.F90 \
+	sbcssr.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcmod.F90
+$(MODEL_LIB)(sbcrnf.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90
+$(MODEL_LIB)(sbcssm.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssm.F90
+$(MODEL_LIB)(sbcssr.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	closea.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	fldread.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	sbcrnf.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	sbcssr.F90
+$(MODEL_LIB)(sol_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	sol_oce.F90
+$(MODEL_LIB)(solmat.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	KEY_CPP \
+	solmat.F90
+$(MODEL_LIB)(solpcg.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	solpcg.F90
+$(MODEL_LIB)(solsor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	zdf_oce.F90 \
+	solsor.F90
+$(MODEL_LIB)(solver.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sol_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(solmat.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	obc_oce.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	solmat.F90 \
+	zdf_oce.F90 \
+	KEY_CPP \
+	solver.F90
+$(MODEL_LIB)(sshwzv.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	bdy_oce.F90 \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	cla_div.F90 \
+	diaar5.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	sshwzv.F90
+$(MODEL_LIB)(step.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(albedo.o) \
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(bdydyn.o) \
+	$(MODEL_LIB)(bdytides.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(cla_div.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(cpl_oasis4.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(divcur.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynadv_cen2.o) \
+	$(MODEL_LIB)(dynadv_ubs.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynkeg.o) \
+	$(MODEL_LIB)(dynldf_bilap.o) \
+	$(MODEL_LIB)(dynldf_bilapg.o) \
+	$(MODEL_LIB)(dynldf_iso.o) \
+	$(MODEL_LIB)(dynldf_lap.o) \
+	$(MODEL_LIB)(dynspg_exp.o) \
+	$(MODEL_LIB)(dynspg_flt.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynspg_ts.o) \
+	$(MODEL_LIB)(dynzad.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(flo4rk.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floblk.o) \
+	$(MODEL_LIB)(flodom.o) \
+	$(MODEL_LIB)(flowri.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(ice_2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdyn.o) \
+	$(MODEL_LIB)(obcdyn_bt.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(obcvol.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_ice_2.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	albedo.F90 \
+	bdy_oce.F90 \
+	bdydta.F90 \
+	bdydyn.F90 \
+	bdytides.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	cla_div.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	cpl_oasis4.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	divcur.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynadv_cen2.F90 \
+	dynadv_ubs.F90 \
+	dynhpg.F90 \
+	dynkeg.F90 \
+	dynldf_bilap.F90 \
+	dynldf_bilapg.F90 \
+	dynldf_iso.F90 \
+	dynldf_lap.F90 \
+	dynspg_exp.F90 \
+	dynspg_flt.F90 \
+	dynspg_oce.F90 \
+	dynspg_ts.F90 \
+	dynzad.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	flo4rk.F90 \
+	flo_oce.F90 \
+	floblk.F90 \
+	flodom.F90 \
+	flowri.F90 \
+	geo2ocean.F90 \
+	ice_2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obc_oce.F90 \
+	obc_par.F90 \
+	obcdyn.F90 \
+	obcdyn_bt.F90 \
+	obctra.F90 \
+	obcvol.F90 \
+	oce.F90 \
+	par_ice_2.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	traqsr.F90 \
+	trazdf.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(agrif_opa_sponge.o) \
+	$(MODEL_LIB)(bdy_par.o) \
+	$(MODEL_LIB)(bdydta.o) \
+	$(MODEL_LIB)(cla.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diafwb.o) \
+	$(MODEL_LIB)(diagap.o) \
+	$(MODEL_LIB)(diahdy.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dynadv.o) \
+	$(MODEL_LIB)(dynbfr.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynldf.o) \
+	$(MODEL_LIB)(dynnxt.o) \
+	$(MODEL_LIB)(dynspg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynvor.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(flo_oce.o) \
+	$(MODEL_LIB)(floats.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfeiv.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(obc_par.o) \
+	$(MODEL_LIB)(obcdta.o) \
+	$(MODEL_LIB)(obcrad.o) \
+	$(MODEL_LIB)(obcrst.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sshwzv.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(traadv.o) \
+	$(MODEL_LIB)(trabbc.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(tradmp.o) \
+	$(MODEL_LIB)(traldf.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zdftmx.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_sponge.F90 \
+	bdy_par.F90 \
+	bdydta.F90 \
+	cla.F90 \
+	cpl_oasis3.F90 \
+	daymod.F90 \
+	diaar5.F90 \
+	diafwb.F90 \
+	diagap.F90 \
+	diahdy.F90 \
+	diahth.F90 \
+	diaptr.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dynadv.F90 \
+	dynbfr.F90 \
+	dynhpg.F90 \
+	dynldf.F90 \
+	dynnxt.F90 \
+	dynspg.F90 \
+	dynspg_oce.F90 \
+	dynvor.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	flo_oce.F90 \
+	floats.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfeiv.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	obc_par.F90 \
+	obcdta.F90 \
+	obcrad.F90 \
+	obcrst.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbccpl.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sshwzv.F90 \
+	stpctl.F90 \
+	traadv.F90 \
+	trabbc.F90 \
+	trabbl.F90 \
+	tradmp.F90 \
+	traldf.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdftmx.F90 \
+	zpshde.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	step.F90
+$(MODEL_LIB)(step_c1d.o) :	\
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(diahth.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(dynzdf_imp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(limwri_2.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	diaar5.F90 \
+	diadimg.F90 \
+	diahth.F90 \
+	dianam.F90 \
+	diawri.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	dynzdf_exp.F90 \
+	dynzdf_imp.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	limwri_2.F90 \
+	obctra.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	sol_oce.F90 \
+	traqsr.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(daymod.o) \
+	$(MODEL_LIB)(diawri.o) \
+	$(MODEL_LIB)(diawri_c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(dyncor_c1d.o) \
+	$(MODEL_LIB)(dynnxt_c1d.o) \
+	$(MODEL_LIB)(dynzdf.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(stpctl.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(tranxt.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trasbc.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	daymod.F90 \
+	diawri.F90 \
+	diawri_c1d.F90 \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	dyncor_c1d.F90 \
+	dynnxt_c1d.F90 \
+	dynzdf.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	stpctl.F90 \
+	tranpc.F90 \
+	tranxt.F90 \
+	traqsr.F90 \
+	trasbc.F90 \
+	trazdf.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	domzgr_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	step_c1d.F90
+$(MODEL_LIB)(stpctl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(sol_oce.o) \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	sol_oce.F90 \
+	stpctl.F90
+$(MODEL_LIB)(thd_ice_2.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(par_ice_2.o) \
+	par_ice_2.F90 \
+	KEY_CPP \
+	thd_ice_2.F90
+$(MODEL_LIB)(traadv.o) :	\
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaar5.F90 \
+	dianam.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traadv_cen2.o) \
+	$(MODEL_LIB)(traadv_eiv.o) \
+	$(MODEL_LIB)(traadv_muscl.o) \
+	$(MODEL_LIB)(traadv_muscl2.o) \
+	$(MODEL_LIB)(traadv_qck.o) \
+	$(MODEL_LIB)(traadv_tvd.o) \
+	$(MODEL_LIB)(traadv_ubs.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	traadv_cen2.F90 \
+	traadv_eiv.F90 \
+	traadv_muscl.F90 \
+	traadv_muscl2.F90 \
+	traadv_qck.F90 \
+	traadv_tvd.F90 \
+	traadv_ubs.F90 \
+	trabbl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv.F90
+$(MODEL_LIB)(traadv_cen2.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(cpl_oasis3.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_ice.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcana.o) \
+	$(MODEL_LIB)(sbcblk_clio.o) \
+	$(MODEL_LIB)(sbcblk_core.o) \
+	$(MODEL_LIB)(sbccpl.o) \
+	$(MODEL_LIB)(sbcflx.o) \
+	$(MODEL_LIB)(sbcfwb.o) \
+	$(MODEL_LIB)(sbcice_if.o) \
+	$(MODEL_LIB)(sbcice_lim.o) \
+	$(MODEL_LIB)(sbcice_lim_2.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(sbcssm.o) \
+	$(MODEL_LIB)(sbcssr.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	closea.F90 \
+	cpl_oasis3.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_ice.F90 \
+	sbc_oce.F90 \
+	sbcana.F90 \
+	sbcblk_clio.F90 \
+	sbcblk_core.F90 \
+	sbccpl.F90 \
+	sbcflx.F90 \
+	sbcfwb.F90 \
+	sbcice_if.F90 \
+	sbcice_lim.F90 \
+	sbcice_lim_2.F90 \
+	sbcrnf.F90 \
+	sbcssm.F90 \
+	sbcssr.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(closea.o) \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(sbcmod.o) \
+	$(MODEL_LIB)(sbcrnf.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	closea.F90 \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	sbcmod.F90 \
+	sbcrnf.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_cen2.F90
+$(MODEL_LIB)(traadv_eiv.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaar5.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	diaar5.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_eiv.F90
+$(MODEL_LIB)(traadv_muscl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl.F90
+$(MODEL_LIB)(traadv_muscl2.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_muscl2.F90
+$(MODEL_LIB)(traadv_qck.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_qck.F90
+$(MODEL_LIB)(traadv_tvd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trabbl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trabbl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_tvd.F90
+$(MODEL_LIB)(traadv_ubs.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traadv_ubs.F90
+$(MODEL_LIB)(trabbc.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trabbc.F90
+$(MODEL_LIB)(trabbl.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	eosbn2.F90 \
+	iom.F90 \
+	oce.F90 \
+	domzgr_substitute.h90 \
+	trabbl_adv.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trabbl.F90
+$(MODEL_LIB)(tradmp.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dtasal.o) \
+	$(MODEL_LIB)(dtatem.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dtasal.F90 \
+	dtatem.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	tradmp.F90
+$(MODEL_LIB)(traldf.o) :	\
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(traldf_bilap.o) \
+	$(MODEL_LIB)(traldf_bilapg.o) \
+	$(MODEL_LIB)(traldf_iso.o) \
+	$(MODEL_LIB)(traldf_lap.o) \
+	$(MODEL_LIB)(trazdf.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	traldf_bilap.F90 \
+	traldf_bilapg.F90 \
+	traldf_iso.F90 \
+	traldf_lap.F90 \
+	trazdf.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf.F90
+$(MODEL_LIB)(traldf_bilap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_bilap.F90
+$(MODEL_LIB)(traldf_bilapg.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldfeiv_substitute.h90 \
+	ldftra_substitute.h90 \
+	KEY_CPP \
+	traldf_bilapg.F90
+$(MODEL_LIB)(traldf_iso.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_iso.F90
+$(MODEL_LIB)(traldf_lap.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(diaptr.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	diaptr.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traldf_lap.F90
+$(MODEL_LIB)(tranpc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	tranpc.F90
+$(MODEL_LIB)(tranxt.o) :	\
+	$(MODEL_LIB)(bdy_oce.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(obc_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	bdy_oce.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	obc_oce.F90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(agrif_opa_interp.o) \
+	$(MODEL_LIB)(agrif_opa_update.o) \
+	$(MODEL_LIB)(bdytra.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynhpg.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(obctra.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	agrif_opa_interp.F90 \
+	agrif_opa_update.F90 \
+	bdytra.F90 \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynhpg.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	obctra.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	$(AGRIF_LIB) \
+	KEY_CPP \
+	tranxt.F90
+$(MODEL_LIB)(traqsr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(geo2ocean.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	geo2ocean.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	traqsr.F90
+$(MODEL_LIB)(trasbc.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(fldread.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	fldread.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(traqsr.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	traqsr.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trasbc.F90
+$(MODEL_LIB)(trazdf.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynspg_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trazdf_imp.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	dynspg_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trazdf_imp.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf.F90
+$(MODEL_LIB)(trazdf_exp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_exp.F90
+$(MODEL_LIB)(trazdf_imp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdicp_oce.F90 \
+	trdmld.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	trazdf_imp.F90
+$(MODEL_LIB)(trc_oce.o) :	\
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	par_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	trc_oce.F90
+$(MODEL_LIB)(trdicp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdicp.F90
+$(MODEL_LIB)(trdicp_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdicp_oce.F90
+$(MODEL_LIB)(trdmld.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldftra_substitute.h90 \
+	zdfddm_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdmld.F90
+$(MODEL_LIB)(trdmld_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdmld_oce.F90
+$(MODEL_LIB)(trdmld_rst.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	restart.F90 \
+	trdmod_oce.F90 \
+	KEY_CPP \
+	trdmld_rst.F90
+$(MODEL_LIB)(trdmod.o) :	\
+	$(MODEL_LIB)(diadimg.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmld_rst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	diadimg.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdmld_rst.F90 \
+	trdmod_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	ldftra_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	trdmod.F90
+$(MODEL_LIB)(trdmod_oce.o) :	\
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	KEY_CPP \
+	trdmod_oce.F90
+$(MODEL_LIB)(trdvor.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(trdicp_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdvor_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	trdicp_oce.F90 \
+	trdmld_oce.F90 \
+	trdvor_oce.F90 \
+	zdf_oce.F90 \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	ldfdyn_oce.F90 \
+	oce.F90 \
+	phycst.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	ldfdyn_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	$(IOIPSL_LIB) \
+	KEY_CPP \
+	trdvor.F90
+$(MODEL_LIB)(trdvor_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	trdvor_oce.F90
+$(MODEL_LIB)(zdf_oce.o) :	\
+	$(MODEL_LIB)(par_kind.o) \
+	par_kind.F90 \
+	$(MODEL_LIB)(par_oce.o) \
+	par_oce.F90 \
+	KEY_CPP \
+	zdf_oce.F90
+$(MODEL_LIB)(zdfbfr.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfbfr.F90
+$(MODEL_LIB)(zdfddm.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdfddm.F90
+$(MODEL_LIB)(zdfevd.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	zdfkpp.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfevd.F90
+$(MODEL_LIB)(zdfini.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	dynzdf_exp.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldfdyn_oce.F90 \
+	ldftra_oce.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfddm.F90 \
+	zdfkpp.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(ldfdyn_oce.o) \
+	$(MODEL_LIB)(ldfslp.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(tranpc.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfevd.o) \
+	$(MODEL_LIB)(zdfkpp.o) \
+	$(MODEL_LIB)(zdfric.o) \
+	$(MODEL_LIB)(zdftke.o) \
+	$(MODEL_LIB)(zdftke_old.o) \
+	in_out_manager.F90 \
+	iom.F90 \
+	ldfdyn_oce.F90 \
+	ldfslp.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	par_oce.F90 \
+	restart.F90 \
+	tranpc.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfevd.F90 \
+	zdfkpp.F90 \
+	zdfric.F90 \
+	zdftke.F90 \
+	zdftke_old.F90 \
+	zdfini.F90
+$(MODEL_LIB)(zdfkpp.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(ldftra_oce.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdicp.o) \
+	$(MODEL_LIB)(trdmld.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(trdvor.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	ldftra_oce.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdicp.F90 \
+	trdmld.F90 \
+	trdmod_oce.F90 \
+	trdvor.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmod.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	zdfddm_substitute.h90 \
+	KEY_CPP \
+	zdfkpp.F90
+$(MODEL_LIB)(zdfmxl.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	sbc_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	oce.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfmxl.F90
+$(MODEL_LIB)(zdfric.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	KEY_CPP \
+	zdfric.F90
+$(MODEL_LIB)(zdftke.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfbfr.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	domvvl.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	zdf_oce.F90 \
+	zdfbfr.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke.F90
+$(MODEL_LIB)(zdftke_old.o) :	\
+	$(MODEL_LIB)(c1d.o) \
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(domvvl.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trdmld_oce.o) \
+	$(MODEL_LIB)(trdmod.o) \
+	$(MODEL_LIB)(trdmod_oce.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	$(MODEL_LIB)(zpshde.o) \
+	c1d.F90 \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	domvvl.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	trdmld_oce.F90 \
+	trdmod.F90 \
+	trdmod_oce.F90 \
+	zdf_oce.F90 \
+	zdfddm.F90 \
+	zdfmxl.F90 \
+	zpshde.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(dynzdf_exp.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(restart.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(trazdf_exp.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	$(MODEL_LIB)(zdfmxl.o) \
+	dom_oce.F90 \
+	dynzdf_exp.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	restart.F90 \
+	sbc_oce.F90 \
+	trazdf_exp.F90 \
+	zdf_oce.F90 \
+	zdfmxl.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftke_old.F90
+$(MODEL_LIB)(zdftmx.o) :	\
+	$(MODEL_LIB)(dianam.o) \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(domngb.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom_def.o) \
+	$(MODEL_LIB)(iom_ioipsl.o) \
+	$(MODEL_LIB)(iom_nf90.o) \
+	$(MODEL_LIB)(iom_rstdimg.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(sbc_oce.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dianam.F90 \
+	dom_oce.F90 \
+	domngb.F90 \
+	in_out_manager.F90 \
+	iom_def.F90 \
+	iom_ioipsl.F90 \
+	iom_nf90.F90 \
+	iom_rstdimg.F90 \
+	lbclnk.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	sbc_oce.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(iom.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdf_oce.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	iom.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdf_oce.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zdftmx.F90
+$(MODEL_LIB)(zpshde.o) :	\
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbcnfd.o) \
+	$(MODEL_LIB)(lib_mpp.o) \
+	$(MODEL_LIB)(lib_print.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(par_kind.o) \
+	$(MODEL_LIB)(par_oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	$(MODEL_LIB)(prtctl.o) \
+	$(MODEL_LIB)(zdfddm.o) \
+	dom_oce.F90 \
+	in_out_manager.F90 \
+	lbcnfd.F90 \
+	lib_mpp.F90 \
+	lib_print.f90 \
+	oce.F90 \
+	par_kind.F90 \
+	par_oce.F90 \
+	phycst.F90 \
+	prtctl.F90 \
+	zdfddm.F90 \
+	$(MODEL_LIB)(dom_oce.o) \
+	$(MODEL_LIB)(eosbn2.o) \
+	$(MODEL_LIB)(in_out_manager.o) \
+	$(MODEL_LIB)(lbclnk.o) \
+	$(MODEL_LIB)(oce.o) \
+	$(MODEL_LIB)(phycst.o) \
+	dom_oce.F90 \
+	eosbn2.F90 \
+	in_out_manager.F90 \
+	lbclnk.F90 \
+	oce.F90 \
+	phycst.F90 \
+	domzgr_substitute.h90 \
+	vectopt_loop_substitute.h90 \
+	KEY_CPP \
+	zpshde.F90
+# agrif previous use
+firstagrif:
+ifeq ($(AGRIF),use)
+	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+else
+	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp
+#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC
+# recompile all in this case
+mpiagrif:
+ifeq ($(AGRIF),use)
+ifeq (,$(AGRIF_MPI))
+	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi
+endif
+endif
+# key changing control
+key: 
+	@echo CHANGE of CPP KEYS yes/no ?
+	-@if [ "`cat KEY_CPP`" != "$(P_P:$(prefix)%=%)" ] ; then \
+		echo CPP options changed ; echo "$(P_P:$(prefix)%=%)" > KEY_CPP ; fi 
+# check key values
+keyverif:
+	@echo CHECKING KEY
+	@echo KEY USED : 
+	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \
+	do \
+	echo $$v ;\
+        w=`echo $$v | cut -c1-3` ; \
+        if [ $$w = `echo "key"` ] ; then \
+        r=n ; \
+        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \
+           if [ $$r != "n" ] ; then \
+              echo "UNKNOWN KEY" ;\
+              false ;  \
+              exit ;  \
+           fi \
+        fi \
+	done
+# Checking the number of routines
+src_file_list: 
+	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES 
+	@$(RM) `ls | fgrep -v -f .patron` 
+	@check=`grep OPA_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OPA_SRC files"                ; \
+	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \
+	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep LIM_SRC_3 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_3 files"                ; \
+      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep LIM_SRC_2 .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use LIM_SRC_2 files"                ; \
+      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep C1D_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use C1D_SRC files"                ; \
+      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \
+  fi 
+	@check=`grep TOP_SRC .config`              ; \
+	if [ -n "$$check" ] ; then  \
+	echo "   use TOP_SRC files"                ; \
+      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \
+      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \
+  fi 
+	@check=`grep OFF_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use OFF_SRC files"                ; \
+      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \
+      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \
+  fi 
+	@check=`grep NST_SRC .config`              ; \
+	if [ -n "$$check" ] ; then                   \
+	echo "   use NST_SRC files"                ; \
+      \$(RM) agrif_opa_interp.F90           ; \
+      \$(RM) agrif_opa_sponge.F90           ; \
+      \$(RM) agrif_opa_update.F90           ; \
+      \$(RM) agrif_top_interp.F90           ; \
+      \$(RM) agrif_top_sponge.F90           ; \
+      \$(RM) agrif_top_update.F90           ; \
+      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \
+  fi 
+	@\$(RM) tmplist
+	@ls -1 | fgrep -v -f .patron  >tmplist
+	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \
+	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \
+	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \
+	echo "Rebuilding the AA_make files" ; \
+	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \
+	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \
+	echo "========================================== " ; \
+	../../util/ins_make ; echo " " ;  false ; exit ; }
Index: /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/CONFIG/POMME/scripts/BB_make.ldef	(revision 1844)
@@ -0,0 +1,50 @@
+#---------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model (BB_make.ldef in scripts)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce/libopa.a
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrc AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa
+
+#-
+#- Key options for GYRE ocean configuration: Analytical forcing ---
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_pomme_r025 key_dynspg_flt key_zdftke key_dtatem key_dtasal key_traldf_c2d key_dynldf_c2d key_ldfslp key_obc
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx9mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix    prefix = -WF,-D
+#-Q- aix6   prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+#-Q- platine prefix= -Wp,-D
Index: /branches/DEV_r1837_MLF/CVSROOT/checkoutlist
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/checkoutlist	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/checkoutlist	(revision 1844)
@@ -0,0 +1,13 @@
+# The "checkoutlist" file is used to support additional version controlled
+# administrative files in $CVSROOT/CVSROOT, such as template files.
+#
+# The first entry on a line is a filename which will be checked out from
+# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
+# The remainder of the line is an error message to use if the file cannot
+# be checked out.
+#
+# File format:
+#
+#	[<whitespace>]<filename><whitespace><error message><end-of-line>
+#
+# comment lines begin with '#'
Index: /branches/DEV_r1837_MLF/CVSROOT/commitinfo
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/commitinfo	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/commitinfo	(revision 1844)
@@ -0,0 +1,15 @@
+# The "commitinfo" file is used to control pre-commit checks.
+# The filter on the right is invoked with the repository and a list 
+# of files to check.  A non-zero exit of the filter program will 
+# cause the commit to be aborted.
+#
+# The first entry on a line is a regular expression which is tested
+# against the directory that the change is being committed to, relative
+# to the $CVSROOT.  For the first match that is found, then the remainder
+# of the line is the name of the filter to run.
+#
+# If the repository name does not match any of the regular expressions in this
+# file, the "DEFAULT" line is used, if it is specified.
+#
+# If the name "ALL" appears as a regular expression it is always used
+# in addition to the first matching regex or "DEFAULT".
Index: /branches/DEV_r1837_MLF/CVSROOT/config
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/config	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/config	(revision 1844)
@@ -0,0 +1,21 @@
+# Set this to "no" if pserver shouldn't check system users/passwords
+#SystemAuth=no
+
+# Put CVS lock files in this directory rather than directly in the repository.
+#LockDir=/var/lock/cvs
+
+# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
+# level of the new working directory when using the `cvs checkout'
+# command.
+#TopLevelAdmin=no
+
+# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
+# history file, or a subset as needed (ie `TMAR' logs all write operations)
+#LogHistory=TOFEWGCMAR
+
+# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
+# script to change the log message.  Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra
+# second per directory being committed, so it is not recommended for large
+# repositories.  Set it to `never' (the previous CVS behavior) to prevent
+# verifymsg scripts from changing the log message.
+#RereadLogAfterVerify=always
Index: /branches/DEV_r1837_MLF/CVSROOT/cvswrappers
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/cvswrappers	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/cvswrappers	(revision 1844)
@@ -0,0 +1,19 @@
+# This file affects handling of files based on their names.
+#
+# The -m option specifies whether CVS attempts to merge files.
+#
+# The -k option specifies keyword expansion (e.g. -kb for binary).
+#
+# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
+#
+#  wildcard	[option value][option value]...
+#
+#  where option is one of
+#  -f		from cvs filter		value: path to filter
+#  -t		to cvs filter		value: path to filter
+#  -m		update methodology	value: MERGE or COPY
+#  -k		expansion mode		value: b, o, kkv, &c
+#
+#  and value is a single-quote delimited value.
+# For example:
+#*.gif -k 'b'
Index: /branches/DEV_r1837_MLF/CVSROOT/editinfo
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/editinfo	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/editinfo	(revision 1844)
@@ -0,0 +1,21 @@
+# The "editinfo" file is used to allow verification of logging
+# information.  It works best when a template (as specified in the
+# rcsinfo file) is provided for the logging procedure.  Given a
+# template with locations for, a bug-id number, a list of people who
+# reviewed the code before it can be checked in, and an external
+# process to catalog the differences that were code reviewed, the
+# following test can be applied to the code:
+#
+#   Making sure that the entered bug-id number is correct.
+#   Validating that the code that was reviewed is indeed the code being
+#       checked in (using the bug-id number or a seperate review
+#       number to identify this particular code set.).
+#
+# If any of the above test failed, then the commit would be aborted.
+#
+# Actions such as mailing a copy of the report to each reviewer are
+# better handled by an entry in the loginfo file.
+#
+# One thing that should be noted is the the ALL keyword is not
+# supported.  There can be only one entry that matches a given
+# repository.
Index: /branches/DEV_r1837_MLF/CVSROOT/loginfo
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/loginfo	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/loginfo	(revision 1844)
@@ -0,0 +1,26 @@
+# The "loginfo" file controls where "cvs commit" log information
+# is sent.  The first entry on a line is a regular expression which must match
+# the directory that the change is being made to, relative to the
+# $CVSROOT.  If a match is found, then the remainder of the line is a filter
+# program that should expect log information on its standard input.
+#
+# If the repository name does not match any of the regular expressions in this
+# file, the "DEFAULT" line is used, if it is specified.
+#
+# If the name ALL appears as a regular expression it is always used
+# in addition to the first matching regex or DEFAULT.
+#
+# You may specify a format string as part of the
+# filter.  The string is composed of a `%' followed
+# by a single format character, or followed by a set of format
+# characters surrounded by `{' and `}' as separators.  The format
+# characters are:
+#
+#   s = file name
+#   V = old version number (pre-checkin)
+#   v = new version number (post-checkin)
+#
+# For example:
+#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
+# or
+#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
Index: /branches/DEV_r1837_MLF/CVSROOT/modules
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/modules	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/modules	(revision 1844)
@@ -0,0 +1,26 @@
+# Three different line formats are valid:
+#	key	-a    aliases...
+#	key [options] directory
+#	key [options] directory files...
+#
+# Where "options" are composed of:
+#	-i prog		Run "prog" on "cvs commit" from top-level of module.
+#	-o prog		Run "prog" on "cvs checkout" of module.
+#	-e prog		Run "prog" on "cvs export" of module.
+#	-t prog		Run "prog" on "cvs rtag" of module.
+#	-u prog		Run "prog" on "cvs update" of module.
+#	-d dir		Place module in directory "dir" instead of module name.
+#	-l		Top-level directory only -- do not recurse.
+#
+# NOTE:  If you change any of the "Run" options above, you'll have to
+# release and re-checkout any working directories of these modules.
+#
+# And "directory" is a path to a directory relative to $CVSROOT.
+#
+# The "-a" option specifies an alias.  An alias is interpreted as if
+# everything on the right of the "-a" had been typed on the command line.
+#
+# You can encode a module within a module by using the special '&'
+# character to interpose another module into the current module.  This
+# can be useful for creating a module that consists of many directories
+# spread out over the entire source repository.
Index: /branches/DEV_r1837_MLF/CVSROOT/notify
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/notify	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/notify	(revision 1844)
@@ -0,0 +1,12 @@
+# The "notify" file controls where notifications from watches set by
+# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
+# a regular expression which is tested against the directory that the
+# change is being made to, relative to the $CVSROOT.  If it matches,
+# then the remainder of the line is a filter program that should contain
+# one occurrence of %s for the user to notify, and information on its
+# standard input.
+#
+# "ALL" or "DEFAULT" can be used in place of the regular expression.
+#
+# For example:
+#ALL mail -s "CVS notification" %s
Index: /branches/DEV_r1837_MLF/CVSROOT/rcsinfo
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/rcsinfo	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/rcsinfo	(revision 1844)
@@ -0,0 +1,13 @@
+# The "rcsinfo" file is used to control templates with which the editor
+# is invoked on commit and import.
+#
+# The first entry on a line is a regular expression which is tested
+# against the directory that the change is being made to, relative to the
+# $CVSROOT.  For the first match that is found, then the remainder of the
+# line is the name of the file that contains the template.
+#
+# If the repository name does not match any of the regular expressions in this
+# file, the "DEFAULT" line is used, if it is specified.
+#
+# If the name "ALL" appears as a regular expression it is always used
+# in addition to the first matching regex or "DEFAULT".
Index: /branches/DEV_r1837_MLF/CVSROOT/taginfo
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/taginfo	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/taginfo	(revision 1844)
@@ -0,0 +1,20 @@
+# The "taginfo" file is used to control pre-tag checks.
+# The filter on the right is invoked with the following arguments:
+#
+# $1 -- tagname
+# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
+# $3 -- repository
+# $4->  file revision [file revision ...]
+#
+# A non-zero exit of the filter program will cause the tag to be aborted.
+#
+# The first entry on a line is a regular expression which is tested
+# against the directory that the change is being committed to, relative
+# to the $CVSROOT.  For the first match that is found, then the remainder
+# of the line is the name of the filter to run.
+#
+# If the repository name does not match any of the regular expressions in this
+# file, the "DEFAULT" line is used, if it is specified.
+#
+# If the name "ALL" appears as a regular expression it is always used
+# in addition to the first matching regex or "DEFAULT".
Index: /branches/DEV_r1837_MLF/CVSROOT/verifymsg
===================================================================
--- /branches/DEV_r1837_MLF/CVSROOT/verifymsg	(revision 1844)
+++ /branches/DEV_r1837_MLF/CVSROOT/verifymsg	(revision 1844)
@@ -0,0 +1,21 @@
+# The "verifymsg" file is used to allow verification of logging
+# information.  It works best when a template (as specified in the
+# rcsinfo file) is provided for the logging procedure.  Given a
+# template with locations for, a bug-id number, a list of people who
+# reviewed the code before it can be checked in, and an external
+# process to catalog the differences that were code reviewed, the
+# following test can be applied to the code:
+#
+#   Making sure that the entered bug-id number is correct.
+#   Validating that the code that was reviewed is indeed the code being
+#       checked in (using the bug-id number or a seperate review
+#       number to identify this particular code set.).
+#
+# If any of the above test failed, then the commit would be aborted.
+#
+# Actions such as mailing a copy of the report to each reviewer are
+# better handled by an entry in the loginfo file.
+#
+# One thing that should be noted is the the ALL keyword is not
+# supported.  There can be only one entry that matches a given
+# repository.
Index: /branches/DEV_r1837_MLF/DOC/NEMO_book.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/NEMO_book.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/NEMO_book.tex	(revision 1844)
@@ -0,0 +1,299 @@
+%description: Book template
+
+% template of document for LaTeX
+% (C) Xavier Perseguers 2002 - xavier.perseguers@epfl.ch
+
+\documentclass[a4paper,12pt]{book}
+
+%  makeindex NEMO_book     <== to regenerate the index
+%  bibtex         NEMO_book	<== to generate  the bibliography
+
+% ================================================================
+% HEADERS DEFINITION
+% ================================================================
+
+\usepackage[french]{babel}
+\usepackage{fancyhdr}
+
+\usepackage{alltt}  		%%  alltt for namelist
+\usepackage{verbatim}  	%%  alltt for namelist
+
+%hyperref  ===>>>  don't work.....
+%\usepackage[a4paper=true,ps2pdf=true,pagebackref=true,breaklinks=true]{hyperref}
+
+%\usepackage{amssymb}
+\pagestyle{fancy}
+% with this we ensure that the chapter and section
+% headings are in lowercase.
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
+\fancyhf{}             % delete current setting for header and footer
+\fancyhead[LE,RO]{\bfseries\thepage}
+\fancyhead[LO]{\bfseries\hspace{-0em}\rightmark}
+\fancyhead[RE]{\bfseries\leftmark}
+\renewcommand{\headrulewidth}{0.5pt}
+\renewcommand{\footrulewidth}{0pt}
+\addtolength{\headheight}{2.6pt}   % make space for the rule
+%\addtolength{\headheight}{1.6pt}   % make space for the rule
+\fancypagestyle{plain}{
+  \fancyhead{}         % get rid of headers on plain pages
+  \renewcommand{\headrulewidth}{0pt}  % and the line
+}
+
+% Leave blank pages completely empty, w/o header
+\makeatletter
+\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
+  \hbox{}
+  \vspace*{\fill}
+  \vspace{\fill}
+  \thispagestyle{empty}
+  \newpage
+  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
+\makeatother
+
+\usepackage{makeidx}
+
+\usepackage{minitoc}				%in french : \usepackage[french]{minitoc}
+
+%\usepackage{mtcoff}				% invalidate the use of minitocs
+\usepackage[latin1]{inputenc}
+\usepackage{graphics}				% allows insertion of pictures
+\usepackage{times}					% use vector fonts instead of bitmap
+\usepackage{fancybox}
+\usepackage{color}
+\usepackage{colortbl}
+
+%%%% add by Word2Tex
+%\documentclass{amsart}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{amsmath}
+\usepackage{graphicx}
+%%%%
+
+%%%%
+%\usepackage{mathtime}      % font for illustrator to work (belleek fonts )
+%%%%
+
+%\usepackage{showidx}				% show the index entry
+
+
+
+%%%% define the style of title for chapter  %%%
+\usepackage{pstricks}
+\makeatletter
+\def\LigneVerticale{\vrule height 5cm depth 2cm\hspace{0.1cm}\relax}
+\def\LignesVerticales{%
+  \let\LV\LigneVerticale\LV\LV\LV\LV\LV\LV\LV\LV\LV\LV}
+\def\GrosCarreAvecUnChiffre#1{%
+  \rlap{\vrule height 0.8cm width 1cm depth 0.2cm}%
+  \rlap{\hbox to 1cm{\hss\mbox{\white #1}\hss}}%
+  \vrule height 0pt width 1cm depth 0pt}
+\def\GrosCarreAvecTroisChiffre#1{%
+  \rlap{\vrule height 0.8cm width 1.6cm depth 0.2cm}%
+  \rlap{\hbox to 1.5cm{\hss\mbox{\white #1}\hss}}%
+  \vrule height 0pt width 1cm depth 0pt}
+
+\def\@makechapterhead#1{\hbox{%
+    \huge 
+    \LignesVerticales
+    \hspace{-0.5cm}%
+    \GrosCarreAvecUnChiffre{\thechapter}
+    \hspace{0.2cm}\hbox{#1}%
+%    \GrosCarreAvecTroisChiffre{\thechapter}
+%    \hspace{1cm}\hbox{#1}%
+%}\par\vskip 2cm}
+}\par\vskip 1cm}
+\def\@makeschapterhead#1{\hbox{%
+    \huge 
+    \LignesVerticales
+    %\hspace{0.5cm}%
+    \hbox{#1}%
+}\par\vskip 2cm}
+
+%\def\thechapter{\Roman{chapter}}   	% chapter number to be Roman
+
+%%%% end style chapter %%%
+
+%%% eqution shortcut:
+\newcommand{\vect} [1] { \rm{\textbf{#1}} }    % vector style: non-italic bold
+
+%%% essai commande
+\newcommand{\nl} [1] {\texttt{\small {\textcolor{blue}{#1}} } } 
+
+%essai commande  
+\newcommand{\mdl} [1] {\textit{#1.F90}\index{Modules!#1}}			%module (mdl)
+\newcommand{\rou} [1] {\textit{#1}\index{Routines!#1}}			%module (routine)
+\newcommand{\hf} [1] {\textit{#1.h90}\index{h90 file!#1}}			%module (h90 files)
+\newcommand{\np} [1] {\textit{#1}\index{Namelist parameters!#1}}%namelist parameter (nampar)
+\newcommand{\jp} [1] {\textit{#1}\index{Model parameters!#1}}%model parameter (jp)
+\newcommand{\pp} [1] {\textit{#1}\index{Model parameters!#1}}%namelist parameter (pp)
+\newcommand{\key} [1] {\textbf{key\_#1}\index{CPP keys!key\_#1}}	%key_cpp (key)
+\newcommand{\NEMO} {\textit{NEMO }}						%NEMO (nemo)
+\newcommand{\amtcomment}[1]{#1}   	% command to allow "commented out" portions of 
+\newcommand{\gmcomment}[1]{}   	% command to allow "commented out" portions of 
+%                                    				% text that span line breaks
+
+%--------------------------------------------namlist---------------------------------------------------------
+\newcommand{\namdisplay} [1] { 
+	\begin{alltt}  {{\tiny \verbatiminput{./TexFiles/Namelist/#1}}}  \end{alltt} 
+                               \vspace{-10pt}	}
+%--------------------------------------------------------------------------------------------------------------
+
+%Red (NR) or Yellow(WARN)
+%\newcommand{\NR} {\colorbox{red}{#1}}
+%\newcommand{\WARN} {{ \colorbox{yellow}{#1}} }
+
+%---------------------%%%%%  Section number in Margin  %%%%%-----------------------------
+% typeset the number of each section in the left margin, with the start of each instance of
+% sectional heading text aligned with the left hand edge of  the body text.
+\makeatletter 
+\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname the#1\endcsname\quad}} 
+\makeatother 
+%--------------------------------------------------------------------------------------------------------------
+
+%----------------------------%%%%%   Bilbiography   %%%%%%-------------------------------%
+\usepackage[nottoc, notlof, notlot]{tocbibind}
+\usepackage[square, comma]{natbib}
+\bibpunct{[}{]}{,}{a}{}{;}                           %suppress "," after "et al."
+\providecommand{\bibfont}{\small}
+%--------------------------------------------------------------------------------------------------------------
+
+% ================================================================
+% FRONT PAGE
+% ================================================================
+
+\title{ 
+\includegraphics[width=0.2\textwidth]{./TexFiles/Figures/logo_CNRS.pdf} 
+\quad
+\includegraphics[width=0.2\textwidth]{./TexFiles/Figures/logo_MERCATOR.pdf} 
+\quad
+\includegraphics[width=0.1\textwidth]{./TexFiles/Figures/logo_UKMO.pdf} 
+\quad
+\includegraphics[width=0.2\textwidth]{./TexFiles/Figures/logo_NERC.pdf} \\
+\vspace{3.0cm}
+\includegraphics[width=0.3\textwidth]{./TexFiles/Figures/NEMO_logo_Black.pdf} \\
+\vspace{1.0cm}
+\rule{345pt}{1.5pt} \\
+\vspace{0.45cm}
+ {\Huge NEMO ocean engine} 
+\rule{345pt}{1.5pt} \\ 
+%{\small NEMO v2.3} \\
+{\small  -- version 3.1 --}   }
+%{ -- Draft --}   }
+%\date{\today}
+\date{
+May 2008  \\
+\textit{\small Note du P\^ole de mod\'{e}lisation de l'Institut Pierre-Simon Laplace No 27 }\\
+\vspace{0.45cm}
+{ ISSN No 1288-1619.}
+}
+
+
+%%\includegraphics[width=0.2\textwidth]{./TexFiles/Figures/logo_NERC.pdf} \\
+
+%%    \hbox{\mbox{%
+%%       \hspace{4pt}%
+%%         \fbox{\includegraphics[width=3em]{./TexFiles/Figures/logo_CNRS.pdf}}%
+%%        \hspace{4pt}
+%%        }  }%
+
+\author{ \Large Gurvan Madec \\
+ \texttt{\small gurvan.madec@locean-ipsl.umpc.fr} \\
+{\small Laboratoire d'Oc\'{e}anographie  et du Climat: Exp\'{e}rimentation et Approches Num\'{e}riques}
+}
+
+\dominitoc
+\makeindex  		%type this first :     makeindex -s NEMO.ist NEMO_book.idx
+
+% ================================================================
+% ================================================================
+%      Include ONLY order
+% ================================================================
+
+%\includeonly{./TexFiles/Chapters/Chap_MISC}
+%\includeonly{./TexFiles/Chapters/Annex_E}
+%\includeonly{./TexFiles/Chapters/Chap_LBC,./TexFiles/Chapters/Chap_MISC}
+%\includeonly{./TexFiles/Chapters/Chap_Model_Basics_zstar}
+%\includeonly{./TexFiles/Chapters/Annex_A,./TexFiles/Chapters/Annex_B,./TexFiles/Chapters/Annex_C,./TexFiles/Chapters/Annex_D}
+
+% ================================================================
+% ================================================================
+\begin{document}
+
+\maketitle						% generate the title
+
+\frontmatter
+
+\tableofcontents					% generate a table of content
+%\listoffigures					% generate a table of content
+%\listoftables					% generate a table of content
+
+\mainmatter
+
+% ================================================================
+% Abstract - Foreword
+% ================================================================
+
+\include{./TexFiles/Chapters/Abstracts_Foreword}
+
+% ================================================================
+% INTRODUCTION
+% ================================================================
+
+\include{./TexFiles/Chapters/Introduction}
+
+% ================================================================
+% CHAPTERS
+% ================================================================
+
+\include{./TexFiles/Chapters/Chap_Model_Basics}
+
+%\include{./TexFiles/Chapters/Chap_Model_Basics_zstar}	% attent to describe z*-s*
+
+\include{./TexFiles/Chapters/Chap_DOM}
+
+\include{./TexFiles/Chapters/Chap_TRA}
+
+\include{./TexFiles/Chapters/Chap_DYN}
+
+\include{./TexFiles/Chapters/Chap_SBC}
+
+\include{./TexFiles/Chapters/Chap_LBC}
+
+\include{./TexFiles/Chapters/Chap_LDF}
+
+\include{./TexFiles/Chapters/Chap_ZDF}
+
+\include{./TexFiles/Chapters/Chap_MISC}
+
+% ================================================================
+% APPENDIX
+% ================================================================
+
+\appendix
+
+%\include{./TexFiles/Chapters/Chap_Conservation}
+\include{./TexFiles/Chapters/Annex_A}
+\include{./TexFiles/Chapters/Annex_B}
+\include{./TexFiles/Chapters/Annex_C}
+%\include{./TexFiles/Chapters/Annex_D}
+%\include{./TexFiles/Chapters/Annex_E}
+
+% ================================================================
+% INDEX
+% ================================================================
+
+\addcontentsline{toc}{chapter}{Index}
+\printindex
+
+% ================================================================
+% BIBLIOGRAPHY
+% ================================================================
+
+%%\bibliographystyle{plainat}
+\bibliographystyle{./TexFiles/ametsoc}			% AMS biblio style (JPO)
+\bibliography{./TexFiles/Biblio/Biblio}
+
+% ================================================================
+\end{document}
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Biblio/Biblio.bib
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Biblio/Biblio.bib	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Biblio/Biblio.bib	(revision 1844)
@@ -0,0 +1,2395 @@
+This file was created with JabRef 2.2.
+Encoding: UTF8
+
+@STRING{AP = {Academic Press}}
+
+@STRING{AREPS = {Annual Review of Earth Planetary Science}}
+
+@STRING{ARFM = {Annual Review of Fluid Mechanics}}
+
+@STRING{ASL = {Atmospheric Science Letters}}
+
+@STRING{AW = {Addison-Wesley}}
+
+@STRING{CD = {Clim. Dyn.}}
+
+@STRING{CP = {Clarendon Press}}
+
+@STRING{CUP = {Cambridge University Press}}
+
+@STRING{D = {Dover Publications}}
+
+@STRING{DAO = {Dyn. Atmos. Ocean}}
+
+@STRING{DSR = {Deep-Sea Res.}}
+
+@STRING{E = {Eyrolles}}
+
+@STRING{GRL = {Geophys. Res. Let.}}
+
+@STRING{I = {Interscience}}
+
+@STRING{JAOT = {J. Atmos. Ocean Tech.}}
+
+@STRING{JAS = {J. Atmos. Sc.}}
+
+@STRING{JC = {J. Climate}}
+
+@STRING{JCP = {J. Comput. Phys.}}
+
+@STRING{JGR = {J. Geophys. Res}}
+
+@STRING{JHUP = {The Johns Hopkins University Press}}
+
+@STRING{JMR = {J. Mar. Res.}}
+
+@STRING{JMS = {J. Mar. Sys.}}
+
+@STRING{JMSJ = {J. Met. Soc. Japan}}
+
+@STRING{JPO = {J. Phys. Oceanogr.}}
+
+@STRING{JWS = {John Wiley and Sons}}
+
+@STRING{M = {Macmillan}}
+
+@STRING{MGH = {McGraw-Hill}}
+
+@STRING{MWR = {Mon. Wea. Rev.}}
+
+@STRING{Nature = {Nat.}}
+
+@STRING{NH = {North-Holland}}
+
+@STRING{Ocean = {Oceanology}}
+
+@STRING{OS = {Ocean Science}}
+
+@STRING{OUP = {Oxford University Press}}
+
+@STRING{PH = {Prentice-Hall}}
+
+@STRING{PO = {Prog. Oceangr.}}
+
+@STRING{PP = {Pergamon Press}}
+
+@STRING{PRSL = {Proceedings of the Royal Society of London}}
+
+@STRING{QJRMS = {Quart J Roy Meteor Soc}}
+
+@STRING{Recherche = {La Recherche}}
+
+@STRING{Science = {Science}}
+
+@STRING{SV = {Springer-Verlag}}
+
+@STRING{Tellus = {Tellus}}
+
+@ARTICLE{Adcroft_Campin_OM04,
+  author = {A. Adcroft and J.-M. Campin},
+  title = {Re-scaled height coordinates for accurate representation of free-surface
+	flows in ocean circulation models},
+  journal = {Ocean Modelling},
+  year = {2004},
+  volume = {7},
+  owner = {gm},
+  timestamp = {2008.01.27}
+}
+
+@ARTICLE{Arakawa1966,
+  author = {A. Arakawa},
+  title = {Computational design for long term numerical integration of the equations
+	of fluid motion, two-dimensional incompressible flow, Part. I.},
+  journal = JCP,
+  year = {1966},
+  volume = {I},
+  pages = {119-149},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Arakawa1990,
+  author = {A. Arakawa and Y.-J. G. Hsu},
+  title = {Energy Conserving and Potential-Enstrophy Dissipating Schemes for
+	the Shallow Water Equations},
+  journal = MWR,
+  year = {1990},
+  volume = {118},
+  pages = {1960--1969
+	
+	},
+  number = {10},
+  abstract = {To incorporate potential enstrophy dissipation into discrete shallow
+	water equations with no or arbitrarily small energy dissipation,
+	a family of finite-difference schemes have been derived with which
+	potential enstrophy is guaranteed to decrease while energy is conserved
+	(when the mass flux is nondivergent and time is continuous). Among
+	this family of schemes, there is a member that minimizes the spurious
+	impact of infinite potential vorticities associated with infinitesimal
+	fluid depth. The scheme is, therefore, useful for problems in which
+	the free surface may intersect with the lower boundary.},
+  date = {October 01, 1990},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Arakawa1981,
+  author = {Arakawa, Akio and Lamb, Vivian R.},
+  title = {A Potential Enstrophy and Energy Conserving Scheme for the Shallow
+	Water Equations},
+  journal = MWR,
+  year = {1981},
+  volume = {109},
+  pages = {18--36
+	
+	},
+  number = {1},
+  abstract = {To improve the simulation of nonlinear aspects of the flow over steep
+	topography, a potential enstrophy and energy conserving scheme for
+	the shallow water equations is derived. It is pointed out that a
+	family of schemes can conserve total energy for general flow and
+	potential enstrophy for flow with no mass flux divergence. The newly
+	derived scheme is a unique member of this family, that conserves
+	both potential enstrophy and energy for general flow. Comparison
+	by means of numerical experiment with a scheme that conserves (potential)
+	enstrophy for purely horizontal nondivergent flow demonstrated the
+	considerable superiority of the newly derived potential enstrophy
+	and energy conserving scheme, not only in suppressing a spurious
+	energy cascade but also in determining the overall flow regime. The
+	potential enstrophy and energy conserving scheme for a spherical
+	grid is also presented.},
+  date = {January 01, 1981},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Arhan2006,
+  author = {M. Arhan and A.M. Treguier and B. Bourles and S. Michel},
+  title = {Diagnosing the annual cycle of the Equatorial Undercurrent in the
+	Atlantic Ocean from a general circulation model},
+  journal = JPO,
+  year = {2006},
+  volume = { 36},
+  pages = {1502-1522}
+}
+
+@ARTICLE{ASSELIN1972,
+  author = {R. Asselin},
+  title = {Frequency Filter for Time Integrations},
+  journal = MWR,
+  year = {1972},
+  volume = {100},
+  pages = {487-490},
+  number = {6},
+  abstract = {A simple filter for controlling high-frequency computational and physical
+	modes arising in time integrations is proposed. A linear analysis
+	of the filter with leapfrog, implicit, and semi-implicit, differences
+	is made. The filter very quickly removes the computational mode and
+	is also very useful in damping high-frequency physical waves. The
+	stability of the leapfrog scheme is adversely affected when a large
+	filter parameter is used, but the analysis shows that the use of
+	centered differences with frequency filter is still more advantageous
+	than the use of the Euler-backward method. An example of the use
+	of the filter in an actual forecast with the meteorological equations
+	is shown.},
+  date = {June 01, 1972},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Barnier_al_OD06,
+  author = {B. Barnier and G. Madec and T. Penduff and J.-M. Molines and A.-M.
+	Treguier and J. Le Sommer and A. Beckmann and A. Biastoch and C.
+	Boning and J. Dengg and C. Derval and E. Durand and S. Gulev and
+	E. Remy and C. Talandier and S. Theetten and M. Maltrud and J. McClean
+	and B. De Cuevas},
+  title = {Impact of partial steps and momentum advection schemes in a global
+	ocean circulation model at eddy-permitting resolution.},
+  journal = {Ocean Dyn.},
+  year = {2006},
+  pages = {doi: 10.1007/s10236-006-0082-1.},
+  owner = {gm},
+  timestamp = {2008.01.25}
+}
+
+@INCOLLECTION{Barnier1996,
+  author = {B. Barnier and P. Marchesiello and A.P. de Miranda},
+  title = {Modeling the ocean circulation in the South Atlantic: A strategy
+	for dealing with open boundaries},
+  booktitle = {The South Atlantic: Present and Past Circulation},
+  publisher = {Springer-Verlag, Berlin},
+  year = {1996},
+  editor = {G.Wefer and W.H. Berger and G Siedler and D. Webb},
+  pages = {289-304}
+}
+
+@ARTICLE{Barnier1998,
+  author = {B. Barnier and P. Marchesiello and A. P. de Miranda and J.M. Molines
+	and M. Coulibaly},
+  title = {A sigma-coordinate primitive equation model for studying the circulation
+	in the South Atlantic I, Model configuration with error estimates},
+  journal = {Deep Sea Res.},
+  year = {1998},
+  volume = {45},
+  pages = {543-572}
+}
+
+@ARTICLE{Beckmann1998,
+  author = {A. Beckmann},
+  title = {The representation of bottom boundary layer processes in numerical
+	ocean circulation models.},
+  journal = {Ocean modelling and parameterization, E. P. Chassignet and J. Verron
+	(eds.), NATO Science Series, Kluwer Academic Publishers},
+  year = {1998},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{BeckDos1998,
+  author = {A. Beckmann and R. D\"{o}scher},
+  title = {A method for improved representation of dense water spreading over
+	topography in geopotential-coordinate models},
+  journal = JPO,
+  year = {1998},
+  volume = {27},
+  pages = {581-591},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Beckmann1993,
+  author = {A. Beckmann and D. B. Haidvogel},
+  title = {Numerical Simulation of Flow around a Tall Isolated Seamount. Part
+	I - Problem Formulation and Model Accuracy},
+  journal = {Journal of Physical Oceanography},
+  year = {1993},
+  volume = {23},
+  pages = {1736--1753
+	
+	},
+  number = {8},
+  abstract = {A sigma coordinate ocean circulation model is employed to study flow
+	trapped to a tall seamount in a periodic f-plane channel. In Part
+	I, errors arising from the pressure gradient formulation in the steep
+	topography&#47;strong stratification limit are examined. To illustrate
+	the error properties, a linearized adiabatic version of the model
+	is considered, both with and without forcing, and starting from a
+	resting state with level isopycnals. The systematic discretization
+	errors from the horizontal pressure gradient terms are shown analytically
+	to increase with steeper topography (relative to a fixed horizontal
+	grid) and for stronger stratification (as measured by the Burger
+	number). For an initially quiescent unforced ocean, the pressure
+	gradient errors produce a spurious oscillating current that, at the
+	end of 10 days, is approximately 1 cm s&#8722;1 in amplitude. The
+	period of the spurious oscillation (about 0.5 days) is shown to be
+	a consequence of the particular form of the pressure gradient terms
+	in the sigma coordinate system. With the addition of an alongchannel
+	diurnal forcing, resonantly generated seamount-trapped waves are
+	observed to form. Error levels in these solutions are less than those
+	in the unforced cases; spurious time-mean currents are several orders
+	of magnitude less in amplitude than the resonant propagating waves.
+	However, numerical instability is encountered in a wider range of
+	parameter space. The properties of these resonantly generated waves
+	is explored in detail in Part II of this study. Several new formulations
+	of the pressure gradient terms are tested. Two of the formulations&#8212;constructed
+	to have additional conservation properties relative to the traditional
+	form of the pressure gradient terms (conservation of JEBAR and conservation
+	of energy)&#8212;are found to have error properties generally similar
+	to those of the traditional formulation. A corrected gradient algorithm,
+	based upon vertical interpolation of the pressure field, has a dramatically
+	reduced error level but a much more restrictive range of stable behavior.},
+  date = {August 01, 1993},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Blanke_al_JPO99,
+  author = {B. Blanke and M. Arhan and G. Madec and S. Roche},
+  title = {Warm Water Paths in the Equatorial Atlantic as Diagnosed with a General
+	Circulation Model},
+  journal = JPO,
+  year = {1999},
+  volume = {29, 11},
+  pages = {2753-2768},
+  owner = {gm},
+  timestamp = {2008.05.27}
+}
+
+@ARTICLE{Blanke1993,
+  author = {B. Blanke and P. Delecluse},
+  title = {Low frequency variability of the tropical Atlantic ocean simulated
+	by a general circulation model with mixed layer physics},
+  journal = JPO,
+  year = {1993},
+  volume = {23},
+  pages = {1363-1388}
+}
+
+@ARTICLE{blanketal97,
+  author = {B. Blanke and J. D. Neelin and D. Gutzler},
+  title = {Estimating the effect of stochastic wind forcing on ENSO irregularity},
+  journal = JC,
+  year = {1997},
+  volume = {10},
+  pages = {1473-1486},
+  abstract = {One open question in El NinoSouthern Oscillation (ENSO) simulation
+	and predictability is the role of random
+	
+	forcing by atmospheric variability with short correlation times, on
+	coupled variability with interannual timescales.
+	
+	The discussion of this question requires a quantitative assessment
+	of the stochastic component of the wind stress
+	
+	forcing. Self-consistent estimates of this noise (the stochastic forcing)
+	can be made quite naturally in an empirical
+	
+	atmospheric model that uses a statistical estimate of the relationship
+	between sea surface temperature (SST) and
+	
+	wind stress anomaly patterns as the deterministic feedback between
+	the ocean and the atmosphere. The authors
+	
+	use such an empirical model as the atmospheric component of a hybrid
+	coupled model, coupled to the GFDL
+	
+	ocean general circulation model. The authors define as residual the
+	fraction of the Florida State University wind
+	
+	stress not explained by the empirical atmosphere run from observed
+	SST, and a noise product is constructed by
+	
+	random picks among monthly maps of this residual.
+	
+	The impact of included or excluded noise is assessed with several
+	ensembles of simulations. The model is
+	
+	run in coupled regimes where, in the absence of noise, it is perfectly
+	periodic: in the presence of prescribed
+	
+	seasonal variability, the model is strongly frequency locked on a
+	2-yr period; in annual average conditions it
+	
+	has a somewhat longer inherent ENSO period (30 months). Addition of
+	noise brings an irregular behavior that
+	
+	is considerably richer in spatial patterns as well as in temporal
+	structures. The broadening of the model ENSO
+	
+	spectral peak is roughly comparable to observed. The tendency to frequency
+	lock to subharmonic resonances
+	
+	of the seasonal cycle tends to increase the broadening and to emphasize
+	lower frequencies. An inclination to
+	
+	phase lock to preferred seasons persists even in the presence of noise-induced
+	irregularity. Natural uncoupled
+	
+	atmospheric variability is thus a strong candidate for explaining
+	the observed aperiodicity in ENSO time series.
+	
+	Modelmodel hindcast experiments also suggest the importance of atmospheric
+	noise in setting limits to ENSO
+	
+	predictability.},
+  pdf = {Blanke_etal_JC97.pdf}
+}
+
+@ARTICLE{Blanke_Raynaud_JPO97,
+  author = {B. Blanke and S. Raynaud},
+  title = {Kinematics of the Pacific Equatorial Undercurrent: An Eulerian and
+	Lagrangian Approach from GCM Results},
+  journal = JPO,
+  year = {1997},
+  volume = {27, 6},
+  pages = {1038-1053},
+  owner = {gm},
+  timestamp = {2008.05.27}
+}
+
+@ARTICLE{Blayo2005,
+  author = {E. Blayo and L. Debreu},
+  title = {Revisiting open boundary conditions from the point of view of characteristic
+	variables},
+  journal = {Ocean Modelling},
+  year = {2005},
+  volume = {9},
+  pages = {231-252}
+}
+
+@ARTICLE{Bougeault1989,
+  author = {P. Bougeault and P. Lacarrere},
+  title = {Parameterization of Orography-Induced Turbulence in a Mesobeta--Scale
+	Model},
+  journal = MWR,
+  year = {1989},
+  volume = {117},
+  pages = {1872-1890},
+  number = {8},
+  abstract = {The possibility of extending existing techniques for turbulence parameterization
+	in the planetary boundary layer to attitude, orography-induced turbulence
+	events is examined. Starting from a well-tested scheme, we show that
+	it is possible to generalize the specification method of the length
+	scales, with no deterioration of the scheme performance in the boundary
+	layer. The new scheme is implemented in a two-dimensional version
+	of a limited-area, numerical model used for the simulation of mesobeta-scale
+	atmospheric flows. Three well-known cases of orographically induced
+	turbulence are studied. The comparison with observations and former
+	studies shows a satisfactory behavior of the new scheme.},
+  date = {August 01, 1989},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Brown1978,
+  author = {J. A. Brown and K. A. Campana},
+  title = {An Economical Time-Differencing System for Numerical Weather Prediction},
+  journal = MWR,
+  year = {1978},
+  volume = {106},
+  pages = {1125-1136},
+  number = {8},
+  month = aug,
+  abstract = {A simple method for integrating the primitive equations is presented
+	which allows for a timestep increment up to twice that of the conventional
+	leapfrog scheme. It consists of a time-averaging operator, which
+	incorporates three consecutive time levels, on the pressure gradient
+	terms in the equations of motion. An attractive feature of the method
+	is its case in programming, since the resulting finite-difference
+	equations can he solved explicitly.Presented here are linear analyses
+	of the method applied to the barotropic and two-layer baroclinic
+	gravity waves. Also presented is an analysis of the method with a
+	time-damping device incorporated, which is an alternative in controlling
+	linearly amplifying computational modes.},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Bryan1997,
+  author = {K. Bryan},
+  title = {A Numerical Method for the Study of the Circulation of the World
+	Ocean},
+  journal = JCP,
+  year = {1997},
+  volume = {135, 2},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@ARTICLE{Bryan1984,
+  author = {K. Bryan},
+  title = {Accelerating the convergence to equilibrium of ocean-climate models},
+  journal = JPO,
+  year = {1984},
+  volume = {14},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@ARTICLE{Bryden1973,
+  author = {H. L. Bryden},
+  title = {New polynomials for thermal expansion, adiabatic temperature gradient
+	
+	and potential temperature of sea water},
+  journal = DSR,
+  year = {1973},
+  volume = {20},
+  pages = {401-408},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Campin2004,
+  author = {J.-M. Campin and A. Adcroft and C. Hill and J. Marshall},
+  title = {Conservation of properties in a free-surface model},
+  journal = {Ocean Modelling},
+  year = {2004},
+  volume = {6, 3-4},
+  pages = {221-244},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Campin_Goosse_Tel99,
+  author = {J. M. Campin and H. Goosse},
+  title = {Parameterization of density-driven downsloping flow for a coarse-resolution
+	ocean model in z-coordinate},
+  journal = {Tellus},
+  year = {1999},
+  volume = {51},
+  pages = {412-430},
+  owner = {gm},
+  timestamp = {2008.01.20}
+}
+
+@ARTICLE{Cox1987,
+  author = {M. Cox},
+  title = {Isopycnal diffusion in a z-coordinate ocean model},
+  journal = {Ocean Modelling},
+  year = {1987},
+  volume = {74},
+  pages = {1-9},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Dorscher_Beckmann_JAOT00,
+  author = {R. D\"{o}scher and A. Beckmann},
+  title = {Effects of a Bottom Boundary Layer Parameterization in a Coarse-Resolution
+	Model of the North Atlantic Ocean},
+  journal = JAOT,
+  year = {2000},
+  volume = {17},
+  pages = {698-707},
+  owner = {gm},
+  timestamp = {2008.01.23}
+}
+
+@ARTICLE{Debreu_al_CG2008,
+  author = {L. Debreu and C. Vouland and E. Blayo},
+  title = {AGRIF: Adaptive Grid Refinement In Fortran},
+  journal = {Computers and Geosciences},
+  year = {2008},
+  volume = {34},
+  pages = {8-13},
+  owner = {gm},
+  timestamp = {2008.02.03}
+}
+
+@ARTICLE{Delecluse_Madec_Bk00,
+  author = {P. Delecluse and G. Madec},
+  title = {Ocean modelling and the role of the ocean in the climate system},
+  journal = {In \textit{Modeling the Earth's Climate and its Variability}, Les
+	Houches, Session, LXVII 1997,
+	
+	Eds. W. R. Holland, S. Joussaume and F. David, Elsevier Science,},
+  year = {2000},
+  pages = {237-313},
+  owner = {gm},
+  timestamp = {2008.02.03}
+}
+
+@ARTICLE{Dukowicz1994,
+  author = {J. K. Dukowicz and R. D. Smith},
+  title = {Implicit free-surface method for the Bryan-Cox-Semtner ocean model},
+  journal = JGR,
+  year = {1994},
+  volume = {99},
+  pages = {7991-8014},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@INCOLLECTION{Durran2001,
+  author = {D.R. Durran },
+  title = {Open boundary conditions: fact and fiction},
+  booktitle = {Advances in Mathematical Modelling of Atmosphere and Ocean Dynamics},
+  publisher = {Kluwer Academic Publishers},
+  year = {2001},
+  editor = {P.F. Hodnett}
+}
+
+@ARTICLE{Dutay.J.C2004,
+  author = {J. -C. Dutay and P. J. -Baptiste and J. -M. Campin and A. Ishida
+	and E. M. -Reimer and R. J. Matear and A. Mouchet and I. J. Totterdell
+	and Y. Yamanaka and K. Rodgers and G. Madec and J.C. Orr},
+  title = {Evaluation of OCMIP-2 ocean models deep circulation
+	
+	with mantle helium-3},
+  journal = {Journal of Marine Systems},
+  year = {2004},
+  pages = {1-22},
+  abstract = {We compare simulations of the injection of mantle helium-3 into the
+	deep ocean from six global coarse resolution models which participated
+	in the Ocean Carbon Model Intercomparison Project (OCMIP). We also
+	discuss the results of a study carried out with one of the models,
+	which examines the effect of the subgrid-scale mixing parameterization.
+	These sensitivity tests provide useful information to interpret the
+	differences among the OCMIP models and between model simulations
+	and the data.
+	
+	We find that the OCMIP models, which parameterize subgrid-scale mixing
+	using an eddy-induced velocity, tend to
+	
+	underestimate the ventilation of the deep ocean, based on diagnostics
+	with d3He. In these models, this parameterization is implemented
+	with a constant thickness diffusivity coefficient. In future simulations,
+	we recommend using such a parameterization with spatially and temporally
+	varying coefficients in order to moderate its effect on stratification.
+	
+	The performance of the models with regard to the formation of AABW
+	confirms the conclusion from a previous evaluation with CFC-11. Models
+	coupled with a sea-ice model produce a substantial bottom water formation
+	in the Southern Ocean that tends to overestimate AABW ventilation,
+	while models that are not coupled with a sea-ice model systematically
+	underestimate the formation of AABW.
+	
+	We also analyze specific features of the deep 3He distribution (3He
+	plumes) that are particularly well depicted in the data and which
+	put severe constraints on the deep circulation. We show that all
+	the models fail to reproduce a correct propagation of these plumes
+	in the deep ocean. The resolution of the models may be too coarse
+	to reproduce the strong and narrow currents in the deep ocean, and
+	the models do not incorporate the geothermal heating that may also
+	contribute to the generation of these currents. We also use the context
+	of OCMIP-2 to explore the potential of mantle helium-3 as a tool
+	to compare and evaluate modeled deep-ocean circulations. Although
+	the source function of mantle helium is known with a rather large
+	uncertainty, we find that the parameterization used for the injection
+	of mantle helium-3 is sufficient to generate realistic results, even
+	in the Atlantic Ocean where a previous pioneering study [J. Geophys.
+	Res. 100 (1995) 3829] claimed this parameterization generates
+	
+	inadequate results. These results are supported by a multi-tracer
+	evaluation performed by considering the simulated distributions of
+	both helium-3 and natural 14C, and comparing the simulated tracer
+	fields with available data.},
+  owner = {sandra},
+  pdf = {Dutay_etal_OCMIP_JMS04.pdf},
+  timestamp = {2006.10.17}
+}
+
+@ARTICLE{Eiseman1980,
+  author = {P. R. Eiseman and A. P. Stone},
+  title = {Conservation lows of fluid dynamics -- A survey},
+  journal = {SIAM Review},
+  year = {1980},
+  volume = {22},
+  pages = {12-27},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Emile-Geay_Madec_OSD08,
+  author = {J. Emile-Geay and G. Madec},
+  title = {Geothermal heating, diapycnal mixing and the abyssal circulation},
+  journal = {Ocean Sci. Discuss.},
+  year = {2008},
+  volume = {5},
+  pages = {281-325},
+  owner = {gm},
+  timestamp = {2008.07.16}
+}
+
+@PHDTHESIS{Farge1987,
+  author = {M. Farge},
+  title = {Dynamique non lineaire des ondes et des tourbillons dans les equations
+	de Saint Venant},
+  school = {Doctorat es Mathematiques, Paris VI University, 401 pp.},
+  year = {1987},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Farrow1995,
+  author = {D. E. Farrow and D. P. Stevens},
+  title = {A new tracer advection scheme for Bryan--Cox type ocean general circulation
+	models},
+  journal = JPO,
+  year = {1995},
+  volume = {25},
+  pages = {1731-1741.},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Fujio1991,
+  author = {S. Fujio and N. Imasato},
+  title = {Diagnostic calculation for circulation and water mass movement in
+	the deep Pacific},
+  journal = JGR,
+  year = {1991},
+  volume = {96},
+  pages = {759-774},
+  month = jan,
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Gargett1984,
+  author = {A. E. Gargett},
+  title = {Vertical eddy diffusivity in the ocean interior},
+  journal = JMR,
+  year = {1984},
+  volume = {42},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Gaspar1990,
+  author = {P. Gaspar and Y. Gr{\'e}goris and J.-M. Lefevre},
+  title = {A simple eddy kinetic energy model for simulations of the oceanic
+	vertical mixing\: Tests at Station Papa and long-term upper ocean
+	study site},
+  journal = JGR,
+  year = {1990},
+  volume = {95(C9)},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Gent1990,
+  author = {P. R. Gent and J. C. Mcwilliams},
+  title = {Isopycnal Mixing in Ocean Circulation Models},
+  journal = JPO,
+  year = {1990},
+  volume = {20},
+  pages = {150-155},
+  number = {1},
+  abstract = {A subgrid-scale form for mesoscale eddy mixing on isopycnal surfaces
+	is proposed for use in non-eddy-resolving ocean circulation models.
+	The mixing is applied in isopycnal coordinates to isopycnal layer
+	thickness, or inverse density gradient, as well as to passive scalars,
+	temperature and salinity. The transformation of these mixing forms
+	to physical coordinates is also presented.},
+  date = {January 01, 1990},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Gerdes1993a,
+  author = {R. Gerdes},
+  title = {A primitive equation ocean circulation model using a general vertical
+	coordinate transformation 1. Description and testing of the model},
+  journal = JGR,
+  year = {1993},
+  volume = {98},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Gerdes1993b,
+  author = {R. Gerdes},
+  title = {A primitive equation ocean circulation model using a general vertical
+	coordinate transformation 2. Application to an overflow problem},
+  journal = JGR,
+  year = {1993},
+  volume = {98},
+  pages = {14703-14726},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@TECHREPORT{Gibson_TR86,
+  author = {J. K. Gibson},
+  title = {Standard software development and maintenance},
+  institution = {Operational Dep., ECMWF, Reading, UK.},
+  year = {1986},
+  owner = {gm},
+  timestamp = {2008.02.03}
+}
+
+@BOOK{Gill1982,
+  title = {Atmosphere-Ocean Dynamics},
+  publisher = {International Geophysics Series, Academic Press, New-York},
+  year = {1982},
+  author = {A. E. Gill}
+}
+
+@ARTICLE{Goosse_al_JGR99,
+  author = {H. Goosse and E. Deleersnijder and T. Fichefet and M. England},
+  title = {Sensitivity of a global coupled ocean-sea ice model to the parameterization
+	of vertical mixing},
+  journal = JGR,
+  year = {1999},
+  volume = {104},
+  pages = {13,681-13,695},
+  owner = {gm},
+  timestamp = {2008.05.27}
+}
+
+@ARTICLE{Griffes2005,
+  author = {S. M. Griffes and A. Gnanadesikan and K. W. Dixon and J. P. Dunne
+	and R. Gerdes and M. J. Harrison and A. Rosati and J. L. Russell
+	and B. L. Samuels and M. J. Spelman and M. Winton and R. Zhang},
+  title = {Formulation of an ocean model for global climate simulations},
+  journal = OS,
+  year = {2005},
+  pages = {165246},
+  abstract = {This paper summarizes the formulation of the ocean component to the
+	Geophysical
+	
+	Fluid Dynamics Laboratorys (GFDL) coupled climate model used for
+	the 4th IPCC As- Assessment
+	
+	(AR4) of global climate change. In particular, it reviews elements
+	of ocean
+	
+	sessment climate models and how they are pieced together for use in
+	a state-of-the-art coupled 5
+	
+	model. Novel issues are also highlighted, with particular attention
+	given to sensitivity of
+	
+	the coupled simulation to physical parameterizations and numerical
+	methods. Features
+	
+	of the model described here include the following: (1) tripolar grid
+	to resolve the Arctic
+	
+	Ocean without polar filtering, (2) partial bottom step representation
+	of topography to
+	
+	better represent topographically influenced advective and wave processes,
+	(3) more 10
+	
+	accurate equation of state, (4) three-dimensional flux limited tracer
+	advection to reduce
+	
+	overshoots and undershoots, (5) incorporation of regional climatological
+	variability in
+	
+	shortwave penetration, (6) neutral physics parameterization for representation
+	of the
+	
+	pathways of tracer transport, (7) staggered time stepping for tracer
+	conservation and
+	
+	numerical eciency, (8) anisotropic horizontal viscosities for representation
+	of equato- 15
+	
+	rial currents, (9) parameterization of exchange with marginal seas,
+	(10) incorporation
+	
+	of a free surface that accomodates a dynamic ice model and wave propagation,
+	(11)
+	
+	transport of water across the ocean free surface to eliminate unphysical
+	virtual tracer
+	
+	flux methods, (12) parameterization of tidal mixing on continental
+	shelves.},
+  owner = {sandra},
+  pdf = {Griffies_al_OSD05.pdf},
+  timestamp = {2007.01.25}
+}
+
+@BOOK{Griffies2004,
+  title = {Fundamentals of ocean climate models},
+  publisher = {Princeton University Press, 434pp},
+  year = {2004},
+  author = {S. M. Griffies},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Griffies_JPO98,
+  author = {S. M. Griffies},
+  title = {The Gent-McWilliams skew-ﬂux},
+  journal = JPO,
+  year = {1998},
+  volume = {28},
+  pages = {831–841},
+  owner = {gm},
+  timestamp = {2008.06.28}
+}
+
+@ARTICLE{Griffies1998,
+  author = {S. M. Griffies and A. Gnanadesikan and R. C. Pacanowski and V. D.
+	Larichev and J. K. Dukowicz and R. D. Smith},
+  title = {Isoneutral Diffusion in a z-Coordinate Ocean Model},
+  journal = JPO,
+  year = {1998},
+  volume = {28},
+  pages = {805-830},
+  number = {5},
+  abstract = {This paper considers the requirements that must be satisfied in order
+	to provide a stable and physically based isoneutral tracer diffusion
+	scheme in a z-coordinate ocean model. Two properties are emphasized:
+	1) downgradient orientation of the diffusive fluxes along the neutral
+	directions and 2) zero isoneutral diffusive flux of locally referenced
+	potential density. It is shown that the Cox diffusion scheme does
+	not respect either of these properties, which provides an explanation
+	for the necessity to add a nontrivial background horizontal diffusion
+	to that scheme. A new isoneutral diffusion scheme is proposed that
+	aims to satisfy the stated properties and is found to require no
+	horizontal background diffusion.},
+  date = {May 01, 1998},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Griffies2001,
+  author = {S. M. Griffies and R. C. Pacanowski and M. Schmidt and V. Balaji},
+  title = {Tracer Conservation with an Explicit Free Surface Method for z-Coordinate
+	Ocean Models},
+  journal = MWR,
+  year = {2001},
+  volume = {129},
+  pages = {1081-1098},
+  number = {5},
+  abstract = {This paper details a free surface method using an explicit time stepping
+	scheme for use in z-coordinate ocean models. One key property that
+	makes the method especially suitable for climate simulations is its
+	very stable numerical time stepping scheme, which allows for the
+	use of a long density time step, as commonly employed with coarse-resolution
+	rigid-lid models. Additionally, the effects of the undulating free
+	surface height are directly incorporated into the baroclinic momentum
+	and tracer equations. The novel issues related to local and global
+	tracer conservation when allowing for the top cell to undulate are
+	the focus of this work. The method presented here is quasi-conservative
+	locally and globally of tracer when the baroclinic and tracer time
+	steps are equal. Important issues relevant for using this method
+	in regional as well as large-scale climate models are discussed and
+	illustrated, and examples of scaling achieved on parallel computers
+	provided.},
+  date = {May 01, 2001},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Guily2001,
+  author = {E. Guilyardi and G. Madec and L. Terray},
+  title = {The role of lateral ocean physics in the upper ocean thermal balance
+	of a coupled ocean-atmosphere GCM},
+  journal = CD,
+  year = {2001},
+  volume = {17},
+  pages = {589-599},
+  number = {8},
+  pdf = {/home/ericg/TeX/Papers/Published_pdfs/Guilyardi_al_CD01.pdf}
+}
+
+@ARTICLE{Guyon_al_EP99,
+  author = {M. Guyon and G. Madec and F.-X. Roux and M. Imbard},
+  title = {A Parallel ocean model for high resolution studies},
+  journal = {Lecture Notes in Computer Science},
+  year = {1999},
+  volume = {Euro-Par'99},
+  pages = {603-607},
+  owner = {gm},
+  timestamp = {2008.05.27}
+}
+
+@ARTICLE{Guyon_al_CalPar99,
+  author = {M. Guyon and G. Madec and F.-X. Roux and M. Imbard and C. Herbaut
+	and P. Fronier},
+  title = {Parallelization of the OPA ocean model},
+  journal = {Calculateurs Paralleles},
+  year = {1999},
+  volume = {11, 4},
+  pages = {499-517},
+  owner = {gm},
+  timestamp = {2008.05.27}
+}
+
+@BOOK{Haltiner1980,
+  title = {Numerical prediction and dynamic meteorology},
+  publisher = {John Wiley {\&} Sons Eds., second edition, 477pp},
+  year = {1980},
+  author = {G. J. Haltiner and R. T. Williams},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Haney1991,
+  author = {R. L. Haney},
+  title = {On the Pressure Gradient Force over Steep Topography in Sigma Coordinate
+	Ocean Models},
+  journal = JPO,
+  year = {1991},
+  volume = {21},
+  pages = {610--619
+	
+	},
+  number = {4},
+  abstract = {The error in computing the pressure gradient force near steep topography
+	using terms following (&#963;) coordinates is investigated in an
+	ocean model using the family of vertical differencing schemes proposed
+	by Arakawa and Suarez. The truncation error is estimated by substituting
+	known buoyancy profiles into the finite difference hydrostatic and
+	pressure gradient terms. The error due to &#8220;hydrostatic inconsistency,&#8221;
+	which is not simply a space truncation error, is also documented.
+	The results show that the pressure gradient error is spread throughout
+	the water column, and it is sensitive to the vertical resolution
+	and to the placement of the grid points relative to the vertical
+	structure of the buoyancy field being modeled. Removing a reference
+	state, as suggested for the atmosphere by Gary, reduces the truncation
+	error associated with the two lowest vertical modes by a factor of
+	2 to 3. As an example, the error in computing the pressure gradient
+	using a standard 10-level primitive equation model applied to buoyancy
+	profiles and topographic slopes typical of the California Current
+	region corresponds to a false geostrophic current of the order of
+	10&#8211;12 cm s&#8722;1. The analogous error in a hydrostatically
+	consistent 30-level model with the reference state removed is about
+	an order of magnitude smaller.},
+  date = {April 01, 1991},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Hsu1990,
+  author = {Hsu, Yueh-Jiuan G. and Arakawa, Akio},
+  title = {Numerical Modeling of the Atmosphere with an Isentropic Vertical
+	Coordinate},
+  journal = MWR,
+  year = {1990},
+  volume = {118},
+  pages = {1933--1959
+	
+	},
+  number = {10},
+  abstract = {In constructing a numerical model of the atmosphere, we must choose
+	an appropriate vertical coordinate. Among the various possibilities,
+	isentropic vertical coordinates such as the &#952;-coordinate seem
+	to have the greatest potential, in spite of the technical difficulties
+	in treating the intersections of coordinate surfaces with the lower
+	boundary. The purpose of this paper is to describe the &#952;-coordinate
+	model we have developed and to demonstrate its potential through
+	simulating the nonlinear evolution of a baroclinic wave.In the model
+	we have developed, vertical discretization maintains important integral
+	constraints, such as conservation of the angular momentum and total
+	energy. In treating the intersections of coordinate surfaces with
+	the lower boundary, we have followed the massless-layer approach
+	in which the intersecting coordinate surfaces are extended along
+	the boundary by introducing massless layers. Although this approach
+	formally eliminates the intersection problem, it raises other computational
+	problems. Horizontal discretization of the continuity and momentum
+	equations in the model has been carefully designed to overcome these
+	problems.Selected results from a 10-day integration with the 25-layer,
+	&#946;-plane version of the model are presented. It seems that the
+	model can simulate the nonlinear evolution of a baroclinic wave and
+	associated dynamical processes without major computational difficulties.},
+  date = {October 01, 1990},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{JackMcD1995,
+  author = {D. R. Jackett and T. J. McDougall},
+  title = {Minimal adjustment of hydrographic data to achieve static stability},
+  journal = JAOT,
+  year = {1995},
+  volume = {12},
+  pages = {381-389},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@BOOK{Jerlov1968,
+  title = {Optical Oceanography},
+  publisher = {194pp},
+  year = {1968},
+  author = {N. G. Jerlov},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@BOOK{Jerlov_Bk1968,
+  publisher = {Elsevier},
+  year = {1968},
+  author = {N. G. Jerlov},
+  pages = {194pp},
+  owner = {gm},
+  timestamp = {2008.08.31}
+}
+
+@INPROCEEDINGS{Killworth1989,
+  author = {P. D. Killworth},
+  title = {On the parameterization of deep convection in ocean models},
+  booktitle = {Parameterization of small-scale processes},
+  year = {1989},
+  editor = {Hawaiian winter workshop},
+  month = {January 17-20},
+  organization = {University of Hawaii at Manoa},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Killworth1992,
+  author = {P. D. Killworth},
+  title = {An equivalent-barotropic mode in the fine resolution Antarctic model},
+  journal = JPO,
+  year = {1992},
+  volume = {22},
+  pages = {1379-1387}
+}
+
+@ARTICLE{Killworth1991,
+  author = {Killworth, P. D. and Stainforth, D. and Webb, D. J. and Paterson,
+	S. M.},
+  title = {The Development of a Free-Surface Bryan-Cox-Semtner Ocean Model},
+  journal = JPO,
+  year = {1991},
+  volume = {21},
+  pages = {1333--1348},
+  number = {9},
+  abstract = {A version of the Bryan&#8211;Cox&#8211;Semtner numerical ocean general
+	circulation model, adapted to include a free surface, is described.
+	The model is designed for the following uses&#058; tidal studies
+	(a tidal option is explicitly included); assimilation of altimetric
+	data (since the surface elevation is now a prognostic variable);
+	and in situations where accurate relaxation to obtain the streamfunction
+	in the original model is too time consuming. Comparison is made between
+	a 300-year run of the original model and the free-surface version,
+	using a very coarse North Atlantic calculation as the basis. The
+	results are very similar, differing only in the streamfunction over
+	topography; this is to be expected, since the treatment of topographic
+	torques on the barotropic flow differs because of the nature of the
+	modifications.},
+  date = {September 01, 1991},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Kolmogorov1942,
+  author = {A. N. Kolmogorov},
+  title = {The equation of turbulent motion in an incompressible fluid},
+  journal = {Izv. Akad. Nauk SSSR, Ser. Fiz.},
+  year = {1942},
+  volume = {6},
+  pages = {56-58},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@PHDTHESIS{Levy1996,
+  author = {M. L\'{e}vy},
+  title = {Mod\'{e}lisation des processus biog\'{e}ochimiques en M\'{e}diterran\'{e}e
+	nord-occidentale. Cycle saisonnier et variabilit\'{e} m\'{e}so\'{e}chelle},
+  school = {Universit\'{e} Pierre et Marie Curie, Paris, France, 207pp},
+  year = {1996},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Levy2001,
+  author = {M. L\'{e}vy and A. Estubier and G Madec},
+  title = {Choice of an advection scheme for biogeochemical models},
+  journal = GRL,
+  year = {2001},
+  volume = {28},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Levy1998,
+  author = {M. L\'{e}vy and L. M\'{e}mery and G. Madec},
+  title = {The onset of a bloom after deep winter convection in the Northwestern
+	Mediterranean Sea: mesoscale 
+	
+	process study with a primitive equation model},
+  journal = JMS,
+  year = {1998},
+  volume = {16/1-2},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@BOOK{LargeYeager2004,
+  title = {Diurnal to decadal global forcing for ocean and sea-ice models: the
+	data sets and flux climatologies},
+  publisher = {NCAR Technical Note, NCAR/TN-460+STR, CGD Division of the National
+	Center for Atmospheric Research},
+  year = {2004},
+  author = {W. Large and S. Yeager},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Large_al_RG94,
+  author = {W. G. Large and J. C. McWilliams and S. C. Doney},
+  title = {Oceanic vertical mixing - a review and a model with a nonlocal boundary
+	layer parameterization},
+  journal = {Reviews of Geophysics},
+  year = {1994},
+  volume = {32},
+  pages = {363-404},
+  doi = {10.1029/94RG01872},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@PHDTHESIS{Lazar1997,
+  author = {A. Lazar},
+  title = {La branche froide de la circulation thermohaline - sensibilit\'{e}
+	\`{a} la diffusion turbulente dans un mod\`{e}le de circulation g\'{e}n\'{e}rale
+	id\'{e}alis\'{e}e},
+  school = {Universit\'{e} Pierre et Marie Curie, Paris, France, 200pp},
+  year = {1997},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Lazar1999,
+  author = {A. Lazar and G. Madec and P. Delecluse},
+  title = {The Deep Interior Downwelling, the Veronis Effect, and Mesoscale
+	Tracer Transport Parameterizations in an OGCM},
+  journal = JPO,
+  year = {1999},
+  volume = {29},
+  pages = {2945-2961},
+  number = {11},
+  abstract = {Numerous numerical simulations of basin-scale ocean circulation display
+	a vast interior downwelling and a companion intense western boundary
+	layer upwelling at midlatitude below the thermocline. These features,
+	related to the so-called Veronis effect, are poorly rationalized
+	and depart strongly from the classical vision of the deep circulation
+	where upwelling is considered to occur in the interior. Furthermore,
+	they significantly alter results of ocean general circulation models
+	(OGCMs) using horizontal Laplacian diffusion. Recently, some studies
+	showed that the parameterization for mesoscale eddy effects formulated
+	by Gent and McWilliams allows integral quantities like the streamfunction
+	and meridional heat transport to be free of these undesired effects.
+	In this paper, an idealized OGCM is used to validate an analytical
+	rationalization of the processes at work and help understand the
+	physics. The results show that the features associated with the Veronis
+	effect can be related quantitatively to three different width scales
+	that characterize the baroclinic structure of the deep western boundary
+	current. In addition, since one of these scales may be smaller than
+	the Munk barotropic layer, usually considered to determine the minimum
+	resolution and horizontal viscosity for numerical models, the authors
+	recommend that it be taken into account. Regarding the introduction
+	of the new parameterization, diagnostics in terms of heat balances
+	underline some interesting similarities between local heat fluxes
+	by eddy-induced velocities and horizontal diffusion at low and midlatitudes
+	when a common large diffusivity (here 2000 m2 s&#8722;1) is used.
+	The near-quasigeostrophic character of the flow explains these results.
+	As a consequence, the response of the Eulerian-mean circulation is
+	locally similar for runs using either of the two parameterizations.
+	However, it is shown that the advective nature of the eddy-induced
+	heat fluxes results in a very different effective circulation, which
+	is the one felt by tracers.},
+  date = {November 01, 1999},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Lengaigne_al_JGR03,
+  author = {M. Lengaigne and G. Madec and G. Alory and C. Menkes},
+  title = {Sensitivity of the tropical Pacific Ocean to isopycnal diffusion
+	on tracer and dynamics},
+  journal = JGR,
+  year = {2003},
+  volume = {108 (C11)},
+  pages = {3345, doi:10.1029/2002JC001704},
+  owner = {gm},
+  timestamp = {2008.01.26}
+}
+
+@ARTICLE{Leonard1991,
+  author = {B. P. Leonard},
+  title = {The ULTIMATE conservative difference scheme applied to unsteady one--dimensional
+	advection},
+  journal = {Computer Methods in Applied Mechanics and Engineering},
+  year = {1991},
+  pages = {17-74},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@TECHREPORT{Leonard1988,
+  author = {B. P. Leonard},
+  title = {Universal limiter for transient interpolation modelling of the advective
+	transport equations},
+  institution = {Technical Memorandum TM-100916 ICOMP-88-11, NASA},
+  year = {1988},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Leonard1979,
+  author = {B. P. Leonard},
+  title = {A stable and accurate convective modelling procedure based on quadratic
+	upstream interpolation},
+  journal = {Computer Methods in Applied Mechanics and Engineering},
+  year = {1979},
+  volume = {19},
+  pages = {59-98},
+  month = jun,
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@TECHREPORT{Levier2007,
+  author = {B. Levier and A.-M. Tr\'{e}guier and G. Madec and V. Garnier},
+  title = {Free surface and variable volume in the NEMO code},
+  institution = {MERSEA MERSEA IP report WP09-CNRS-STR-03-1A, 47pp, available on the
+	NEMO web site},
+  year = {2007},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@BOOK{levitus82,
+  title = {Climatological Atlas of the world ocean},
+  publisher = {NOAA professional paper No. 13, 174pp},
+  year = {1982},
+  author = {S Levitus },
+  note = {173 p.}
+}
+
+@TECHREPORT{Lott1989,
+  author = {F. Lott and G. Madec},
+  title = {Implementation of bottom topography in the Ocean General Circulation
+	Model OPA of the LODYC: formalism and experiments.},
+  institution = {LODYC, France, 36pp.},
+  year = {1989},
+  number = {3},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Lott1990,
+  author = {F. Lott and G. Madec and J. Verron},
+  title = {Topographic experiments in an Ocean General Circulation Model},
+  journal = {Ocean Modelling},
+  year = {1990},
+  volume = {88},
+  pages = {1-4},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@BOOK{Madec_Bk08,
+  title = {NEMO ocean engine},
+  publisher = {Note du P\^ole de mod\'{e}lisation, Institut Pierre- 
+	
+	Simon Laplace (IPSL), France, No 27, ISSN No 1288-1619},
+  year = {2008},
+  author = {G. Madec},
+  owner = {gm},
+  timestamp = {2008.07.05}
+}
+
+@PHDTHESIS{Madec1990,
+  author = {G. Madec},
+  title = {La formation d'eau profonde et son impact sur la circulation r\'{e}gionale
+	en M\'{e}diterran\'{e}e Occidentale - une approche num\'{e}rique},
+  school = {Universit\'{e}Pierre et Marie Curie, Paris, France, 194pp.},
+  year = {1990},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@ARTICLE{Madec1991a,
+  author = {G. Madec and M. Chartier and M. Cr\'{e}pon},
+  title = {Effect of thermohaline forcing variability on deep water formation
+	in the Northwestern Mediterranean Sea - a high resulution three-dimensional
+	study},
+  journal = DAO,
+  year = {1991},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Madec1991b,
+  author = {G. Madec and M. Chartier and P. Delecluse and M. Cr\'{e}pon},
+  title = {A three-dimensional numerical study of deep water formation in the
+	
+	
+	Northwestern Mediterranean Sea .},
+  journal = JPO,
+  year = {1991},
+  volume = {21},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@INBOOK{Madec1991c,
+  chapter = {Thermohaline-driven deep water formation in the Northwestern Mediterranean
+	Sea},
+  title = {Deep convection and deep water formation in the oceans},
+  publisher = {Elsevier Oceanographic Series},
+  year = {1991},
+  author = {G. Madec and M. Cr\'{e}pon},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Madec1997,
+  author = {G. Madec and P. Delecluse},
+  title = {The OPA/ARPEGE and OPA/LMD Global Ocean-Atmosphere Coupled Model},
+  journal = {Int. WOCE Newsletter},
+  year = {1997},
+  volume = {26},
+  pages = {12-15},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@TECHREPORT{Madec1998,
+  author = {G. Madec and P. Delecluse and M. Imbard and C. Levy},
+  title = {OPA 8 Ocean General Circulation Model - Reference Manual},
+  institution = {LODYC/IPSL Note 11},
+  year = {1998}
+}
+
+@ARTICLE{MadecImb1996,
+  author = {G Madec and M Imbard},
+  title = {A global ocean mesh to overcome the north pole singularity},
+  journal = CD,
+  year = {1996},
+  volume = {12},
+  pages = {381-388}
+}
+
+@ARTICLE{Madec1996,
+  author = {G. Madec and F. Lott and P. Delecluse and M. Cr\'{e}pon},
+  title = {Large-Scale Preconditioning of Deep-Water Formation in the Northwestern
+	Mediterranean Sea},
+  journal = JPO,
+  year = {1996},
+  volume = {26},
+  pages = {1393-1408},
+  number = {8},
+  month = aug,
+  abstract = {The large-scale processes preconditioning the winter deep-water formation
+	in the northwestern Mediterranean Sea are investigated with a primitive
+	equation numerical model where convection is parameterized by a non-penetrative
+	convective adjustment algorithm. The ocean is forced by momentum
+	and buoyancy fluxes that have the gross features of mean winter forcing
+	found in the MEDOC area. The wind-driven barotropic circulation appears
+	to be a major ingredient of the preconditioning phase of deep-water
+	formation. After three months, the ocean response is dominated by
+	a strong barotropic cyclonic vortex located under the forcing area,
+	which fits the Sverdrup balance away from the northern coast. In
+	the vortex center, the whole water column remains trapped under the
+	forcing area all winter. This trapping enables the thermohaline forcing
+	to drive deep-water formation efficiently. Sensitivity studies show
+	that, &#946; effect and bottom topography play a paramount role and
+	confirm that deep convection occurs only in areas that combine a
+	strong surface thermohaline forcing and a weak barotropic advection
+	so that water masses are submitted to the negative buoyancy fluxes
+	for a much longer time. In particular, the impact of the Rh&#244;ne
+	Deep Sea Fan on the barotropic circulation dominates the &#946; effect:
+	the barotropic flow is constrained to follow the bathymetric contours
+	and the cyclonic vortex is shifted southward so that the fluid above
+	the fan remains quiescent. Hence, buoyancy fluxes trigger deep convection
+	above the fan in agreement with observations. The selection of the
+	area of deep-water formation through the defection of the barotropic
+	circulation by the topography seems a more efficient mechanism than
+	those associated with the wind- driven barotropic vortex. This is
+	due to its permanency, while the latter may be too sensitive to time
+	and space variations of the forcing.},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Madec1988,
+  author = {G. Madec and C. Rahier and M. Chartier},
+  title = {A comparison of two-dimensional elliptic solvers for the barotropic
+	streamfunction in a multilevel OGCM},
+  journal = {Ocean Modelling},
+  year = {1988},
+  volume = {78},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@ARTICLE{Maltrud1998,
+  author = {M. E. Maltrud and R. D. Smith and A. J. Semtner and R. C. Malone},
+  title = {Global eddy-resolving ocean simulations driven by 1985-1995 atmospheric
+	winds},
+  journal = JGR,
+  year = {1998},
+  volume = {103(C13)},
+  pages = {30,825-30,854},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Marchesiello2001,
+  author = { P. Marchesiello and J. Mc Williams and A. Shchepetkin },
+  title = {Open boundary conditions for long-term integrations of Regional Oceanic
+	Models},
+  journal = {Ocean Modelling},
+  year = {2001},
+  volume = {3},
+  pages = {1-20}
+}
+
+@BOOK{MIT-GCM_2004,
+  title = {MIT-gcm User Manual},
+  year = {2004},
+  editor = {MIT Department of EAPS},
+  author = {J. Marshall and A. Adcroft and J.-M. Campin and P. Heimbach and A.
+	Molod and S. Dutkiewicz and H. Hill and M. Losch and B. Fox-Kemper
+	and D. Menemenlis and D. Ferreira and E. Hill and M. Follows and
+	C. Hill and C. Evangelinos and G. Forget},
+  owner = {gm},
+  timestamp = {2008.07.04}
+}
+
+@PHDTHESIS{MartiTh1992,
+  author = {O. Marti},
+  title = {Etude de l'oc\'{e}an mondial : mod\'{e}lisation de la circulation
+	et du transport de traceurs anthropog\'{e}niques},
+  school = {Universit\'{e} Pierre et Marie Curie, Paris, France, 201pp},
+  year = {1992},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Marti1992,
+  author = {O. Marti and G. Madec and P. Delecluse},
+  title = {Comment on "Net diffusivity in ocean general circulation models with
+	nonuniform grids" by F. L. Yin and I. Y. Fung},
+  journal = JGR,
+  year = {1992},
+  volume = {97},
+  pages = {12763-12766},
+  month = aug,
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{McDougall1987,
+  author = {T. J. McDougall},
+  title = {Neutral Surfaces},
+  journal = {Journal of Physical Oceanography},
+  year = {1987},
+  volume = {17},
+  pages = {1950-1964},
+  number = {11},
+  abstract = {Scalar properties in the ocean are stirred (and subsequently mixed)
+	rather efficiently by mesoscale eddies and two-dimensional turbulence
+	along &#8220;neutral surfaces&#8221;, defined such that when water
+	parcels are moved small distances in the neutral surface, they experience
+	no buoyant restoring forces. By contrast, work would have to be done
+	on a moving fluid parcel in order to keep it on a potential density
+	surface. The differences between neutral surfaces and potential density
+	surfaces are due to the variation of &#945;&#47;&#946; with pressure
+	(where &#945; is the thermal expansion coefficient and &#946; is
+	the saline contraction coefficient). By regarding the equation of
+	state of seawater as a function of salinity, potential temperature,
+	and pressure, rather than in terms of salinity, temperature, and
+	pressure, it is possible to quantify the differences between neutral
+	surfaces and potential density surfaces. In particular, the spatial
+	gradients of scalar properties (e.g., S, &#952;, tritium or potential
+	vorticity) on a neutral surface can be quite different to the corresponding
+	gradients in a potential density surface. For example, at a potential
+	temperature of 4&#176;C and a pressure of 1000 db, the lateral gradient
+	of potential temperature in a potential density surface (referenced
+	to sea level) is too large by between 50&#37; and 350&#37; (depending
+	on the stability ratio Rp of the water column) compared with the
+	physically relevant gradient of potential temperature on the neutral
+	surface. Three-examples of neutral surfaces are presented, based
+	on the Levitus atlas of the North Atlantic.},
+  date = {November 01, 1987},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{McDougall_Taylor_JMR84,
+  author = {T. J. McDougall and J. R. Taylor},
+  title = {Flux measurements across a finger interface at low values of the
+	stability ratio},
+  journal = {Journal of Marine Research},
+  year = {1984},
+  volume = {42},
+  pages = {1-14},
+  owner = {gm},
+  timestamp = {2008.05.20}
+}
+
+@ARTICLE{Merryfield1999,
+  author = {W. J. Merryfield and G. Holloway and A. E. Gargett},
+  title = {A Global Ocean Model with Double-Diffusive Mixing},
+  journal = JPO,
+  year = {1999},
+  volume = {29},
+  pages = {1124-1142},
+  number = {6},
+  abstract = {A global ocean model is described in which parameterizations of diapycnal
+	mixing by double-diffusive fingering and layering are added to a
+	stability-dependent background turbulent diffusivity. Model runs
+	with and without double-diffusive mixing are compared for annual-mean
+	and seasonally varying surface forcing. Sensitivity to different
+	double-diffusive mixing parameterizations is considered. In all cases,
+	the locales and extent of salt fingering (as diagnosed from buoyancy
+	ratio R&#961;) are grossly comparable to climatology, although fingering
+	in the models tends to be less intense than observed. Double-diffusive
+	mixing leads to relatively minor changes in circulation but exerts
+	significant regional influences on temperature and salinity.},
+  date = {June 01, 1999},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@BOOK{Mesinger_Arakawa_Bk76,
+  title = {Numerical methods used in Atmospheric models},
+  publisher = {GARP Publication Series No 17},
+  year = {1976},
+  author = {F. Mesinger and A. Arakawa},
+  owner = {gm},
+  timestamp = {2008.02.09}
+}
+
+@ARTICLE{Murray1996,
+  author = {R. J. Murray},
+  title = {Explicit Generation of Orthogonal Grids for Ocean Models},
+  journal = JCP,
+  year = {1996},
+  volume = {126},
+  pages = {251-273},
+  number = {2},
+  month = {July},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@PHDTHESIS{OlivierPh2001,
+  author = {F. Olivier},
+  title = {Etude de l'activit\'{e} biologique et de la circulation oc\'{e}anique
+	dans un jet g\'{e}ostrophique: le front Alm\'{e}ria-Oran},
+  school = {Universit\'{e} Pierre et Marie Curie, Paris, France},
+  year = {2001},
+  owner = {gm},
+  timestamp = {2007.08.14}
+}
+
+@ARTICLE{PacPhil1981,
+  author = {R.C. Pacanowski and S.G.H. Philander},
+  title = {Parameterization of Vertical Mixing in Numerical Models of Tropical
+	Oceans},
+  journal = JPO,
+  year = {1981},
+  volume = {11},
+  pages = {1443-1451},
+  number = {11},
+  abstract = {Measurements indicate that mixing processes are intense in the surface
+	layers of the ocean but weak below the thermocline, except for the
+	region below the core of the Equatorial Undercurrent where vertical
+	temperature gradients are small and the shear is large. Parameterization
+	of these mixing processes by means of coefficients of eddy mixing
+	that are Richardson-number dependent, leads to realistic simulations
+	of the response of the equatorial oceans to different windstress
+	patterns. In the case of eastward winds results agree well with measurements
+	in the Indian Ocean. In the case of westward winds it is of paramount
+	importance that the nonzero heat flux into the ocean be taken into
+	account. This beat flux stabilizes the upper layers and reduces the
+	intensity of the mixing, especially in the cast. With an appropriate
+	surface boundary condition, the results are relatively insensitive
+	to values assigned to constants in the parameterization formula.},
+  date = {November 01, 1981},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Pacanowski_Gnanadesikan_MWR98,
+  author = {R. C. Pacanowski and A. Gnanadesikan},
+  title = {Transient response in a z-level ocean model that resolves topography
+	
+	
+	with partial-cells},
+  journal = MWR,
+  year = {1998},
+  volume = {126},
+  pages = {3248-3270},
+  owner = {gm},
+  timestamp = {2008.01.26}
+}
+
+@ARTICLE{Paulson1977,
+  author = {C. A. Paulson and J. J. Simpson},
+  title = {Irradiance Measurements in the Upper Ocean},
+  journal = JPO,
+  year = {1977},
+  volume = {7},
+  pages = {952-956},
+  number = {6},
+  abstract = {Observations were made of downward solar radiation as a function of
+	depth during an experiment in the North Pacific (35&#176;N, 155&#176;W).
+	The irradiance meter employed was sensitive to solar radiation of
+	wavelength 400&#8211;1000 nm arriving from above at a horizontal
+	surface. Because of selective absorption of the short and long wavelengths,
+	the irradiance decreases much faster than exponential in the upper
+	few meters, falling to one-third of the incident value between 2
+	and 3 m depth. Below 10 m the decrease was exponential at a rate
+	characteristic of moderately clear water of Type IA. Neglecting one
+	case having low sun altitude, the observations are well represented
+	by the expression I&#47;I0&#61;Rez&#47;&#950;1&#43;(1&#8722;R)ez&#950;2,
+	where I is the irradiance at depth &#8722;z, I0 is the irradiance
+	at the surface less reflected solar radiation, R&#61;0.62, &#950;1
+	and &#950;2 are attenuation lengths equal to 1.5 and 20 m, respectively,
+	and z is the vertical space coordinate, positive upward with the
+	origin at mean sea level. The depth at which the irradiance falls
+	to 10&#37; of its surface value is nearly the same as observations
+	of Secchi depth when cases with high wind speed or low solar altitude
+	are neglected. Parameters R, &#950;1, and &#950;2 are computed for
+	the entire range of oceanic water types.},
+  date = {November 01, 1977},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Penduff2000,
+  author = {T. Penduff and B. Barnier and A. Colin de Verdi\`{e}re},
+  title = { Self-adapting open boundaries for a regional model of the eastern
+	North Atlantic},
+  journal = JGR,
+  year = {2000},
+  volume = {105},
+  pages = {11,279-11,297}
+}
+
+@ARTICLE{Penduff2007,
+  author = {T. Penduff and J. Le Sommer and B. Barnier and A.M. Treguier and
+	J. Molines and G. Madec},
+  title = {Influence of numerical schemes on current-topography interactions
+	in 1/4$^{\circ}$ global ocean simulations},
+  journal = {Ocean Science},
+  year = {2007},
+  volume = {?},
+  pages = {in revision}
+}
+
+@ARTICLE{Phillips1959,
+  author = {R. S. Phillips},
+  title = {Dissipative Operators and Hyperbolic Systems of Partial Differential
+	Equations},
+  journal = {Transactions of the American Mathematical Society},
+  year = {1959},
+  volume = {90(2)},
+  pages = {193-254},
+  doi = {doi:10.2307/1993202},
+  owner = {gm},
+  timestamp = {2007.08.10}
+}
+
+@ARTICLE{Redi_JPO82,
+  author = {M. H. Redi},
+  title = {Oceanic isopycnal mixing by coordinate rotation},
+  journal = JPO,
+  year = {1982},
+  volume = {13},
+  pages = {1154-1158},
+  owner = {gm},
+  timestamp = {2008.02.02}
+}
+
+@ARTICLE{Reverdin1991,
+  author = {G. Reverdin and P. Delecluse and C. L\'{e}vy and P. Andrich and A.
+	Morli\`{e}re and J. M. Verstraete},
+  title = {The near surface tropical Atlantic in 1982-1984 : results from a
+	numerical simulation and a data analysis},
+  journal = PO,
+  year = {1991},
+  volume = {27},
+  pages = {273-340},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@BOOK{Richtmyer1967,
+  title = {Difference methods for initial-value problems},
+  publisher = {Interscience Publisher, Second Edition, 405pp},
+  year = {1967},
+  author = {R. D. Richtmyer and K. W. Morton},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Robert1966,
+  author = {A. J. Robert},
+  title = {The integration of a Low order spectral form of the primitive meteorological
+	equations},
+  journal = {J. Meteo. Soc. Japan},
+  year = {1966},
+  volume = {44, 2},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@INCOLLECTION{Roed1986,
+  author = {L.P. Roed and C.K. Cooper},
+  title = {Open boundary conditions in numerical ocean models},
+  booktitle = {Advanced Physical Oceanography Numerical Modelling},
+  publisher = { NATO ASI Series, vol. 186.},
+  year = {1986},
+  editor = {J.J. O'Brien}
+}
+
+@ARTICLE{Roullet2000,
+  author = {G. Roullet and G. Madec},
+  title = {salt conservation, free surface, and varying levels: a new formulation
+	for ocean general circulation models},
+  journal = JGR,
+  year = {2000},
+  volume = {105},
+  pages = {23,927-23,942},
+  owner = {sandra},
+  pdf = {Roullet_Madec_JGR00.pdf},
+  timestamp = {2007.03.22}
+}
+
+@ARTICLE{Sadourny1975,
+  author = {R. Sadourny},
+  title = {The Dynamics of Finite-Difference Models of the Shallow-Water Equations},
+  journal = JAS,
+  year = {1975},
+  volume = {32},
+  pages = {680-689},
+  number = {4},
+  abstract = {Two simple numerical models of the shallow-water equations identical
+	in all respects but for their con-servation properties have been
+	tested regarding their internal mixing processes. The experiments
+	show that violation of enstrophy conservation results in a spurious
+	accumulation of rotational energy in the smaller scales, reflected
+	by an unrealistic increase of enstrophy, which ultimately produces
+	a finite rate of energy dissipation in the zero viscosity limit,
+	thus violating the well-known dynamics of two-dimensional flow. Further,
+	the experiments show a tendency to equipartition of the kinetic energy
+	of the divergent part of the flow in the inviscid limit, suggesting
+	the possibility of a divergent energy cascade in the physical system,
+	as well as a possible influence of the energy mixing on the process
+	of adjustment toward balanced flow.},
+  date = {April 01, 1975},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Sarmiento1982,
+  author = {J. L. Sarmiento and K. Bryan},
+  title = {Ocean transport model for the North Atlantic},
+  journal = JGR,
+  year = {1982},
+  volume = {87},
+  pages = {394-409},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Sacha2005,
+  author = {A. F. Shchepetkin and J. C. McWilliams},
+  title = {The regional oceanic modeling system (ROMS) - a split-explicit, free-surface,
+	topography-following-coordinate oceanic modelr},
+  journal = {Ocean Modelling},
+  year = {2005},
+  volume = {9, 4},
+  pages = {347-404},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Sacha2003,
+  author = {A. F. Shchepetkin and J. C. McWilliams},
+  title = {A method for computing horizontal pressure-gradient force in an oceanic
+	model with a nonaligned 
+	
+	vertical coordinate},
+  journal = JGR,
+  year = {2003},
+  volume = {108(C3)},
+  pages = {3090, doi:10.1029/2001JC001047},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Shchepetkin1996,
+  author = {A. F. Shchepetkin and J. J. O'Brien},
+  title = {A Physically Consistent Formulation of Lateral Friction in Shallow-Water
+	Equation Ocean Models},
+  journal = MWR,
+  year = {1996},
+  volume = {124},
+  pages = {1285-1300},
+  number = {6},
+  abstract = {Dissipation in numerical ocean models has two purposes: to simulate
+	processes in which the friction is physically relevant and to prevent
+	numerical instability by suppressing accumulation of energy in the
+	smallest resolved scales. This study shows that even for the latter
+	case the form of the friction term should be chosen in a physically
+	consistent way. Violation of fundamental physical principles reduces
+	the fidelity of the numerical solution, even if the friction is small.
+	Several forms of the lateral friction, commonly used in numerical
+	ocean models, are discussed in the context of shallow-water equations
+	with nonuniform layer thickness. It is shown that in a numerical
+	model tuned for the minimal dissipation, the improper form of the
+	friction term creates finite artificial vorticity sources that do
+	not vanish with increased resolution, even if the viscous coefficient
+	is reduced consistently with resolution. An alternative numerical
+	implementation of the no-slip boundary conditions for an arbitrary
+	coast line is considered. It was found that the quality of the numerical
+	solution may be considerably improved by discretization of the viscous
+	stress tensor in such a way that the numerical boundary scheme approximates
+	not only the stress tensor to a certain order of accuracy but also
+	simulates the truncation error of the numerical scheme used in the
+	interior of the domain. This ensures error cancellation during subsequent
+	use of the elements of the tensor in the discrete version of the
+	momentum equations, allowing for approximation of them without decrease
+	in the order of accuracy near the boundary.},
+  date = {June 01, 1996},
+  owner = {gm},
+  timestamp = {2007.08.14}
+}
+
+@ARTICLE{Simmons2003,
+  author = {H. L. Simmons and S. R. Jayne and L. C. St. Laurent and A. J. Weaver},
+  title = {Tidally driven mixing in a numerical model of the
+	
+	ocean general circulation},
+  journal = OM,
+  year = {2003},
+  pages = {1-19},
+  abstract = {Astronomical data reveals that approximately 3.5 terawatts (TW) of
+	tidal energy is dissipated in the
+	
+	ocean. Tidal models and satellite altimetry suggest that 1 TW of this
+	energy is converted from the barotropic
+	
+	to internal tides in the deep ocean, predominantly around regions
+	of rough topography such as midocean
+	
+	ridges. Aglobal tidal model is used to compute turbulent energy levels
+	associated with the dissipation
+	
+	of internal tides, and the diapycnal mixing supported by this energy
+	?ux is computed using a simple parameterization.
+	
+	The mixing parameterization has been incorporated into a coarse resolution
+	numerical model of the
+	
+	global ocean. This parameterization o?ers an energetically consistent
+	and practical means of improving the
+	
+	representation of ocean mixing processes in climate models. Novel
+	features of this implementation are that
+	
+	the model explicitly accounts for the tidal energy source for mixing,
+	and that the mixing evolves both
+	
+	spatially and temporally with the model state. At equilibrium, the
+	globally averaged di?usivity pro?le
+	
+	ranges from 0.3 cm2 s1 at thermocline depths to 7.7 cm2 s1 in the
+	abyss with a depth average of 0.9
+	
+	cm2 s1, in close agreement with inferences from global balances.
+	Water properties are strongly in?uenced
+	
+	by the combination of weak mixing in the main thermocline and enhanced
+	mixing in the deep ocean.
+	
+	Climatological comparisons show that the parameterized mixing scheme
+	results in a substantial reduction},
+  owner = {sandra},
+  pdf = {Simmons_mixing_OM2003.pdf},
+  timestamp = {2007.03.22}
+}
+
+@ARTICLE{Song1994,
+  author = {Y. Song and D. Haidvogel},
+  title = {A Semi-implicit Ocean Circulation Model Using a Generalized Topography-Following
+	Coordinate System
+	
+	Authors:},
+  journal = JCP,
+  year = {1994},
+  volume = {115, 1},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Song1998,
+  author = {Y. T. Song},
+  title = {A General Pressure Gradient Formulation for Ocean Models. Part I:
+	Scheme Design and Diagnostic Analysis},
+  journal = MWR,
+  year = {1998},
+  volume = {126},
+  pages = {3213-3230},
+  number = {12},
+  abstract = {A Jacobian formulation of the pressure gradient force for use in models
+	with topography-following coordinates is proposed. It can be used
+	in conjunction with any vertical coordinate system and is easily
+	implemented. Vertical variations in the pressure gradient are expressed
+	in terms of a vertical integral of the Jacobian of density and depth
+	with respect to the vertical computational coordinate. Finite difference
+	approximations are made on the density field, consistent with piecewise
+	linear and continuous fields, and accurate pressure gradients are
+	obtained by vertically integrating the discrete Jacobian from sea
+	surface.Two discrete schemes are derived and examined in detail:
+	the first using standard centered differencing in the generalized
+	vertical coordinate and the second using a vertical weighting such
+	that the finite differences are centered with respect to the Cartesian
+	z coordinate. Both schemes achieve second-order accuracy for any
+	vertical coordinate system and are significantly more accurate than
+	conventional schemes based on estimating the pressure gradients by
+	finite differencing a previously determined pressure field.The standard
+	Jacobian formulation is constructed to give exact pressure gradient
+	results, independent of the bottom topography, if the buoyancy field
+	varies bilinearly with horizontal position, x, and the generalized
+	vertical coordinate, s, over each grid cell. Similarly, the weighted
+	Jacobian scheme is designed to achieve exact results, when the buoyancy
+	field varies linearly with z and arbitrarily with x, that is, b(x,z)
+	&#61; b0(x) &#43; b1(x)z.When horizontal resolution cannot be made
+	fine enough to avoid hydrostatic inconsistency, errors can be substantially
+	reduced by the choice of an appropriate vertical coordinate. Tests
+	with horizontally uniform, vertically varying, and with horizontally
+	and vertically varying buoyancy fields show that the standard Jacobian
+	formulation achieves superior results when the condition for hydrostatic
+	consistency is satisfied, but when coarse horizontal resolution causes
+	this condition to be strongly violated, the weighted Jacobian may
+	give superior results.},
+  date = {December 01, 1998},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{SongWright1998,
+  author = {Y. T. Song and D. G. Wright},
+  title = {A General Pressure Gradient Formulation for Ocean Models. Part II
+	- Energy, Momentum, and Bottom Torque Consistency},
+  journal = MWR,
+  year = {1998},
+  volume = {126},
+  pages = {3231-3247},
+  number = {12},
+  abstract = {A new formulation of the pressure gradient force for use in models
+	with topography-following coordinates is proposed and diagnostically
+	analyzed in Part I. Here, it is shown that important properties of
+	the continuous equations are retained by the resulting numerical
+	schemes, and their performance in prognostic simulations is examined.
+	Numerical consistency is investigated with respect to global energy
+	conservation, depth-integrated momentum changes, and the representation
+	of the bottom pressure torque. The performances of the numerical
+	schemes are tested in prognostic integrations of an ocean model to
+	demonstrate numerical accuracy and long-term integral stability.
+	Two typical geometries, an isolated tall seamount and an unforced
+	basin with sloping boundaries, are considered for the special case
+	of no external forcing and horizontal isopycnals to test numerical
+	accuracy. These test problems confirm that the proposed schemes yield
+	accurate approximations to the pressure gradient force. Integral
+	consistency conditions are verified and the energetics of the &#8220;advective
+	elimination&#8221; of the pressure gradient error (Mellor et al)
+	is considered.A large-scale wind-driven basin with and without topography
+	is used to test the model&#8217;s long-term integral performance
+	and the effects of bottom pressure torque on the transport in western
+	boundary currents. Integrations are carried out for 10 years in each
+	case and results show that the schemes are stable, and the steep
+	topography causes no obvious numerical problems. A realistic meandering
+	western boundary current is well developed with detached cold cyclonic
+	and warm anticyclonic eddies as it extends across the basin. In addition,
+	the results with topography show earlier separation and enhanced
+	transport in the western boundary currents due to the bottom pressure
+	torque.},
+  date = {December 01, 1998},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@PHDTHESIS{Speich1992,
+  author = {S. Speich},
+  title = {Etude du for\c{c}age de la circulation g\'{e}n\'{e}rale oc\'{e}anique
+	par les d\'{e}troits - cas de la mer d'Alboran},
+  school = {Universit\'{e} Pierre et Marie Curie, Paris, France},
+  year = {1992},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Speich1996,
+  author = {S. Speich and G. Madec and M. Cr\'{e}pon},
+  title = {The circulation in the Alboran Sea - a sensitivity study},
+  journal = JPO,
+  year = {1996},
+  volume = {26},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Steele2001,
+  author = {M. Steele and R. Morley and W. Ermold},
+  title = {PHC- A Global Ocean Hydrography with a High-Quality Arctic Ocean},
+  journal = {Journal of Climate},
+  year = {2001},
+  volume = {14},
+  pages = {2079--2087
+	
+	},
+  number = {9},
+  abstract = {A new gridded ocean climatology, the Polar Science Center Hydrographic
+	Climatology (PHC), has been created that merges the 1998 version
+	of the World Ocean Atlas with the new regional Arctic Ocean Atlas.
+	The result is a global climatology for temperature and salinity that
+	contains a good description of the Arctic Ocean and its environs.
+	Monthly, seasonal, and annual average products have been generated.
+	How the original datasets were prepared for merging, how the optimal
+	interpolation procedure was performed, and characteristics of the
+	resulting dataset are discussed, followed by a summary and discussion
+	of future plans.},
+  date = {May 01, 2001},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Stein1992,
+  author = {C. A. Stein and S. Stein},
+  title = {A model for the global variation in oceanic depth and heat flow with
+	lithospheric age},
+  journal = {Nature},
+  year = {1992},
+  volume = {359},
+  pages = {123-129},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Thiem2006,
+  author = {O. Thiem and J. Berntsen},
+  title = {Internal pressure errors in sigma-coordinate ocean models due to
+	anisotropy},
+  journal = {Ocean Modelling},
+  year = {2006},
+  volume = {12, 1-2},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@ARTICLE{Timmermann_al_OM05,
+  author = {R. Timmermann and H. Goosse and G. Madec and T. Fichefet, and C.
+	Ethe and V. Duli\`{e}re},
+  title = {On the representation of high latitude processes in the ORCA-LIM
+	global coupled 
+	
+	sea ice-ocean model.},
+  journal = {Ocean Modelling},
+  year = {2005},
+  volume = {8},
+  pages = {175–201},
+  owner = {gm},
+  timestamp = {2008.07.05}
+}
+
+@ARTICLE{Treguier1992,
+  author = {A.M. Tr\'{e}guier},
+  title = {Kinetic energy analysis of an eddy resolving, primitive equation
+	North Atlantic model},
+  journal = JGR,
+  year = {1992},
+  volume = {97},
+  pages = {687-701}
+}
+
+@ARTICLE{Treguier2001,
+  author = {A.M Tr\'{e}guier and B. Barnier and A.P. de Miranda and J.M. Molines
+	and N. Grima and M. Imbard and G. Madec and C. Messager and T. Reynaud
+	and S. Michel},
+  title = {An Eddy Permitting model of the Atlantic circulation: evaluating
+	open boundary conditions},
+  journal = JGR,
+  year = {2001},
+  volume = {106},
+  pages = {22115-22129}
+}
+
+@ARTICLE{Treguier1996,
+  author = {A.-M. Tr\'{e}guier and J. Dukowicz and K. Bryan},
+  title = {Properties of nonuniform grids used in ocean general circulation
+	models},
+  journal = JGR,
+  year = {1996},
+  volume = {101},
+  pages = {20877-20881},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@ARTICLE{Treguier1997,
+  author = {A. M. Tr\'{e}guier and I. M. Held and V. D. Larichev},
+  title = {Parameterization of Quasigeostrophic Eddies in Primitive Equation
+	Ocean Models},
+  journal = JPO,
+  year = {1997},
+  volume = {27},
+  pages = {567-580},
+  number = {4},
+  abstract = {A parameterization of mesoscale eddy fluxes in the ocean should be
+	consistent with the fact that the ocean interior is nearly adiabatic.
+	Gent and McWilliams have described a framework in which this can
+	be approximated in z-coordinate primitive equation models by incorporating
+	the effects of eddies on the buoyancy field through an eddy-induced
+	velocity. It is also natural to base a parameterization on the simple
+	picture of the mixing of potential vorticity in the interior and
+	the mixing of buoyancy at the surface. The authors discuss the various
+	constraints imposed by these two requirements and attempt to clarify
+	the appropriate boundary conditions on the eddy-induced velocities
+	at the surface. Quasigeostrophic theory is used as a guide to the
+	simplest way of satisfying these constraints.},
+  date = {April 01, 1997},
+  owner = {gm},
+  timestamp = {2007.08.03}
+}
+
+@BOOK{UNESCO1983,
+  title = {Algorithms for computation of fundamental property of sea water},
+  publisher = {Techn. Paper in Mar. Sci, 44, UNESCO},
+  year = {1983},
+  author = {UNESCO},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@TECHREPORT{OASIS2006,
+  author = {S. Valcke},
+  title = {OASIS3 User Guide (prism\_2-5)},
+  institution = {PRISM Support Initiative Report No 3, CERFACS, Toulouse, France,
+	64 pp},
+  year = {2006},
+  owner = {gm},
+  timestamp = {2007.08.05}
+}
+
+@TECHREPORT{valal00,
+  author = {S. Valcke and L. Terray and A. Piacentini },
+  title = {The OASIS Coupled User Guide Version 2.4},
+  institution = {CERFACS},
+  year = {2000},
+  number = {TR/CMGC/00-10}
+}
+
+@ARTICLE{Vancoppenolle_al_OM08,
+  author = {M. Vancoppenolle and T. Fichefet and H. Goosse and S. Bouillon and
+	G. Madec and M. A. Morales Maqueda},
+  title = {Simulating the mass balance and salinity of Arctic and Antarctic
+	sea ice. 1. Model description and validation},
+  journal = {Ocean Modelling},
+  year = {2008},
+  volume = {in press},
+  owner = {gm},
+  timestamp = {2008.07.05}
+}
+
+@ARTICLE{Weatherly1984,
+  author = {G. L. Weatherly},
+  title = {An estimate of bottom frictional dissipation by Gulf Stream fluctuations},
+  journal = JMR,
+  year = {1984},
+  volume = {42, 2},
+  pages = {289-301},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Weaver1997,
+  author = {A. J. Weaver and M. Eby},
+  title = {On the numerical implementation of advection schemes for use in conjuction
+	with various mixing 
+	
+	parameterizations in the GFDL ocean model},
+  journal = JPO,
+  year = {1997},
+  volume = {27},
+  owner = {gm},
+  timestamp = {2007.08.06}
+}
+
+@ARTICLE{Webb1998,
+  author = {D. J. Webb and B. A. de Cuevas and C. S. Richmond},
+  title = {Improved Advection Schemes for Ocean Models},
+  journal = JAOT,
+  year = {1998},
+  volume = {15},
+  pages = {1171-1187},
+  number = {5},
+  abstract = {Leonard&#8217;s widely used QUICK advection scheme is, like the Bryan&#8211;Cox&#8211;Semtner
+	ocean model, based on a control volume form of the advection equation.
+	Unfortunately, in its normal form it cannot be used with the leapfrog&#8211;Euler
+	forward time-stepping schemes used by the ocean model. Farrow and
+	Stevens overcame the problem by implementing a predictor&#8211;corrector
+	time-stepping scheme, but this is computationally expensive to run.
+	The present paper shows that the problem can be overcome by splitting
+	the QUICK operator into an O(&#948;x2) advective term and a velocity
+	dependent biharmonic diffusion term. These can then be time-stepped
+	using the combined leapfrog and Euler forward schemes of the Bryan&#8211;Cox&#8211;Semtner
+	ocean model, leading to a significant increase in model efficiency.
+	A small change in the advection operator coefficients may also be
+	made leading to O(&#948;x4) accuracy. Tests of the improved schemes
+	are carried out making use of a global eddy-permitting ocean model.
+	Results are presented from cases where the schemes were applied to
+	only the tracer fields and also from cases where they were applied
+	to both the tracer and velocity fields. It is found that the new
+	schemes have the most effect in the western boundary current regions,
+	where, for example, the warm core of the Agulhas Current is no longer
+	broken up by numerical noise.},
+  date = {October 01, 1998},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Willebrand2001,
+  author = {J. Willebrand and B. Barnier and C. Boning and C. Dieterich and P.
+	D. Killworth and C. Le Provost and Y. Jia and J.-M. Molines and A.
+	L. New},
+  title = {Circulation characteristics in three eddy-permitting models of the
+	North Atlantic},
+  journal = {Progress in Oceanography},
+  year = {2001},
+  volume = {48, 2},
+  pages = {123-161},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Zalesak1979,
+  author = {S. T. Zalesak},
+  title = {Fully multidimensional flux corrected transport algorithms for fluids},
+  journal = JCP,
+  year = {1979},
+  volume = {31},
+  owner = {gm},
+  timestamp = {2007.08.04}
+}
+
+@ARTICLE{Zhang1992,
+  author = {Zhang, R.-H. and Endoh, M.},
+  title = {A free surface general circulation model for the tropical Pacific
+	Ocean},
+  journal = JGR,
+  year = {1992},
+  volume = {97},
+  pages = {11237-11255},
+  month = jul,
+  owner = {gm}
+}
+
+@comment{jabref-meta: groupsversion:3;}
+
+@comment{jabref-meta: groupstree:
+0 AllEntriesGroup:;
+1 ExplicitGroup:El Nino\;2\;blanketal97\;;
+2 ExplicitGroup:97/98 event\;0\;;
+2 ExplicitGroup:Forecast\;0\;;
+2 ExplicitGroup:GHG change\;0\;;
+2 ExplicitGroup:in GCMs\;0\;;
+2 ExplicitGroup:in MIPs\;0\;;
+2 ExplicitGroup:momentum balance\;0\;;
+2 ExplicitGroup:Obs analysis\;0\;;
+2 ExplicitGroup:Paleo\;0\;;
+2 ExplicitGroup:Previous events\;0\;;
+2 ExplicitGroup:Reviews\;0\;;
+2 ExplicitGroup:Simple models\;0\;Zhang1992\;;
+2 ExplicitGroup:SPL, SC, mean\;0\;;
+2 ExplicitGroup:Teleconnections\;0\;;
+2 ExplicitGroup:Low freq\;0\;;
+2 ExplicitGroup:Theory\;0\;;
+2 ExplicitGroup:Energetics\;0\;;
+1 ExplicitGroup:Diurnal in tropics\;0\;;
+1 ExplicitGroup:Indian\;0\;;
+1 ExplicitGroup:Atlantic\;0\;;
+1 ExplicitGroup:MJO, IO, TIW\;2\;;
+2 ExplicitGroup:Obs\;0\;;
+2 ExplicitGroup:GCM\;0\;;
+2 ExplicitGroup:Mechanims\;0\;;
+2 ExplicitGroup:TIW\;0\;;
+1 ExplicitGroup:Observations\;2\;;
+2 ExplicitGroup:ERBE\;0\;;
+2 ExplicitGroup:Tropical\;0\;;
+2 ExplicitGroup:Global\;0\;;
+2 ExplicitGroup:Clouds\;0\;;
+2 ExplicitGroup:Scale interactions\;0\;;
+1 ExplicitGroup:Mechanisms\;2\;;
+2 ExplicitGroup:CRF\;0\;;
+2 ExplicitGroup:Water vapor\;0\;;
+2 ExplicitGroup:Atmos mechanisms\;0\;;
+1 ExplicitGroup:GCMs\;2\;;
+2 ExplicitGroup:Uncertainty\;0\;;
+2 ExplicitGroup:Momentum balance\;0\;;
+1 ExplicitGroup:Climate change\;0\;;
+2 ExplicitGroup:IPCC AR4\;0\;;
+1 ExplicitGroup:Analysis tools\;0\;;
+1 KeywordGroup:EG publis\;0\;author\;guilyardi\;0\;0\;;
+}
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Abstracts_Foreword.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Abstracts_Foreword.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Abstracts_Foreword.tex	(revision 1844)
@@ -0,0 +1,59 @@
+
+% ================================================================
+% Abstract (English / French)
+% ================================================================
+
+\chapter*{Abstract / R\'{e}sum\'{e}}
+
+\vspace{-40pt}
+
+\small{ 
+The ocean engine of NEMO (Nucleus for European Modelling of the Ocean) is a primitive 
+equation model adapted to regional and global ocean circulation problems. It is intended to 
+be a flexible tool for studying the ocean and its interactions with the others components of 
+the earth climate system (atmosphere, sea-ice, biogeochemical tracers, ...) over a wide range 
+of space and time scales. Prognostic variables are the three-dimensional velocity field, a linear 
+or non-linear sea surface height, the temperature and the salinity. In the horizontal direction, 
+the model uses a curvilinear orthogonal grid and in the vertical direction, a full or partial step 
+$z$-coordinate, or $s$-coordinate, or a mixture of the two. The distribution of variables is a 
+three-dimensional Arakawa C-type grid. Various physical choices are available to describe 
+ocean physics, including TKE and KPP vertical physics. Within NEMO, the ocean is interfaced 
+with a sea-ice model (LIM v2 and v3), passive tracer and biogeochemical models (TOP) 
+and, via the OASIS coupler, with several atmospheric general circulation models. 
+
+% ================================================================
+ \vspace{0.5cm}
+
+Le moteur oc\'{e}anique de NEMO (Nucleus for European Modelling of the Ocean) est un 
+mod\`{e}le aux \'{e}quations primitives de la circulation oc\'{e}anique r\'{e}gionale et globale. 
+Il se veut un outil flexible pour \'{e}tudier sur un vaste spectre spatiotemporel l'oc\'{e}an et ses 
+interactions avec les autres composantes du syst\`{e}me climatique terrestre (atmosph\`{e}re, 
+glace de mer, traceurs biog\'{e}ochimiques...). Les variables pronostiques sont le champ 
+tridimensionnel de vitesse, une hauteur de la mer lin\'{e}aire ou non, la temperature et la salinit\'{e}. 
+La distribution des variables se fait sur une grille C d'Arakawa tridimensionnelle utilisant une 
+coordonn\'{e}e verticale $z$ \`{a} niveaux entiers ou partiels, ou une coordonn\'{e}e s, ou encore 
+une combinaison des deux. Diff\'{e}rents choix sont propos\'{e}s pour d\'{e}crire la physique 
+oc\'{e}anique, incluant notamment des physiques verticales TKE et KPP. A travers l'infrastructure 
+NEMO, l'oc\'{e}an est interfac\'{e} avec un mod\`{e}le de glace de mer, des mod\`{e}les 
+biog\'{e}ochimiques et de traceur passif, et, via le coupleur OASIS, \`{a} plusieurs mod\`{e}les 
+de circulation g\'{e}n\'{e}rale atmosph\'{e}rique. 
+} 
+
+% ================================================================
+% Disclaimer
+% ================================================================
+\chapter*{Disclaimer}
+
+Like all components of NEMO, the ocean component is developed under the CECILL license, which is a French adaptation of the GNU GPL (General Public License). Anyone may use it freely for research purposes, and is encouraged to communicate back to the NEMO team its own developments and improvements. The model and the present document have been made available as a service to the community. We cannot certify that the code and its manual are free of errors. Bugs are inevitable and some have undoubtedly survived the testing phase. Users are encouraged to bring them to our attention. The author assumes no responsibility for problems, errors, or incorrect usage of NEMO.
+
+ \vspace{1cm}
+NEMO reference in papers and other publications is as follows:
+ \vspace{0.5cm}
+
+Madec, G., 2008: NEMO ocean engine. \textit{Note du P\^ole de mod\'{e}lisation}, Institut Pierre-Simon Laplace (IPSL), France, No 27, ISSN No 1288-1619.\\
+
+
+ \vspace{0.5cm}
+Additional information can be found on http://www.nemo-ocean.eu/
+ \vspace{0.5cm}
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_A.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_A.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_A.tex	(revision 1844)
@@ -0,0 +1,288 @@
+
+% ================================================================
+% Chapter Ñ Appendix A : Curvilinear s-Coordinate Equations
+% ================================================================
+\chapter{Curvilinear $s$-Coordinate Equations}
+\label{Apdx_A}
+\minitoc
+
+
+In order to establish the set of Primitive Equation in curvilinear $s$-coordinates 
+($i.e.$ an orthogonal curvilinear coordinate in the horizontal and $s$-coordinate 
+in the vertical), we start from the set of equations established in \S\ref{PE_zco_Eq} 
+for the special case $k = z$ and thus $e_3 = 1$, and we introduce an arbitrary 
+vertical coordinate $s = s(i,j,z,t)$. Let us define a new vertical scale factor by 
+$e_3 = \partial z / \partial s$ (which now depends on $(i,j,z,t)$) and the horizontal 
+slope of $s$-surfaces by :
+\begin{equation} \label{Apdx_A_s_slope}
+\sigma _1 =\frac{1}{e_1 }\;\left. {\frac{\partial z}{\partial i}} \right|_s 
+\quad \text{and} \quad 
+\sigma _2 =\frac{1}{e_2 }\;\left. {\frac{\partial z}{\partial j}} \right|_s 
+\end{equation}
+
+The chain rule to establish the model equations in the curvilinear $s$-coordinate 
+system is:
+\begin{equation} \label{Apdx_A_s_chain_rule}
+\begin{aligned}
+&\left. {\frac{\partial \bullet }{\partial t}} \right|_z  =
+\left. {\frac{\partial \bullet }{\partial t}} \right|_s 
+	 -\frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial t} \\
+&\left. {\frac{\partial \bullet }{\partial i}} \right|_z  =
+  \left. {\frac{\partial \bullet }{\partial i}} \right|_s 
+  	  -\frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial i}=
+	  \left. {\frac{\partial \bullet }{\partial i}} \right|_s 
+	  -\frac{e_1 }{e_3 }\sigma _1 \frac{\partial \bullet }{\partial s} \\
+&\left. {\frac{\partial \bullet }{\partial j}} \right|_z  =
+\left. {\frac{\partial \bullet }{\partial j}} \right|_s 
+	- \frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial j}=
+\left. {\frac{\partial \bullet }{\partial j}} \right|_s 
+	- \frac{e_2 }{e_3 }\sigma _2 \frac{\partial \bullet }{\partial s} \\
+&\;\frac{\partial \bullet }{\partial z}  \;\; = \frac{1}{e_3 }\frac{\partial \bullet }{\partial s} \\
+\end{aligned}
+\end{equation}
+
+In particular applying the time derivative chain rule to $z$ provides the 
+expression for $w_s$,  the vertical velocity of the $s-$surfaces:
+\begin{equation} \label{Apdx_A_w_in_s}
+w_s   =  \left.   \frac{\partial z }{\partial t}   \right|_s 
+				= \frac{\partial z}{\partial s} \; \frac{\partial s}{\partial t} 
+			    = e_3 \, \frac{\partial s}{\partial t} 
+\end{equation}
+
+% ================================================================
+% continuity equation
+% ================================================================
+\section{Continuity Equation}
+\label{Apdx_B_continuity}
+
+Using (\ref{Apdx_A_s_chain_rule}) and the fact that the horizontal scale factors 
+$e_1$ and $e_2$ do not depend on the vertical coordinate, the divergence of 
+the velocity relative to the ($i$,$j$,$z$) coordinate system is transformed as follows:
+
+\begin{align*}
+\nabla \cdot {\rm {\bf U}} 
+&= \frac{1}{e_1 \,e_2 }  \left[ \left. {\frac{\partial (e_2 \,u)}{\partial i}} \right|_z 
+						+\left. {\frac{\partial(e_1 \,v)}{\partial j}} \right|_z  \right]
++ \frac{\partial w}{\partial z} 		\\
+\\
+&     = \frac{1}{e_1 \,e_2 }  \left[ 
+		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s       
+		  - \frac{e_1 }{e_3 } \sigma _1 \frac{\partial (e_2 \,u)}{\partial s}
+		+ \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s       
+		  - \frac{e_2 }{e_3 } \sigma _2 \frac{\partial (e_1 \,v)}{\partial s}	\right]
+	+ \frac{\partial w}{\partial s} \; \frac{\partial s}{\partial z}                        \\
+\\
+&     = \frac{1}{e_1 \,e_2 }   \left[ 
+		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s       
+		+ \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s       	\right]
+	+ \frac{1}{e_3 }\left[        \frac{\partial w}{\partial s}
+						-  \sigma _1 \frac{\partial u}{\partial s}
+						-  \sigma _2 \frac{\partial v}{\partial s}      \right]          \\
+\\
+&     = \frac{1}{e_1 \,e_2 \,e_3 }   \left[ 
+		  \left.   \frac{\partial (e_2 \,e_3 \,u)}{\partial i}    \right|_s  
+		  -\left.    e_2 \,u    \frac{\partial e_3 }{\partial i}     \right|_s      
+		+ \left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j}    \right|_s
+		  - \left.    e_1 v      \frac{\partial e_3 }{\partial j}    \right|_s   \right]          \\
+& \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
+	+ \frac{1}{e_3 } \left[        \frac{\partial w}{\partial s}
+						-  \sigma _1 \frac{\partial u}{\partial s}
+						-  \sigma _2 \frac{\partial v}{\partial s}      \right]      \\
+\\
+\end{align*}
+
+Noting that $\frac{1}{e_1 }\left. {\frac{\partial e_3 }{\partial i}} 
+\right|_s =\frac{1}{e_1 }\left. {\frac{\partial ^2z}{\partial i\,\partial 
+s}} \right|_s =\frac{\partial }{\partial s}\left( {\frac{1}{e_1 }\left. 
+{\frac{\partial z}{\partial i}} \right|_s } \right)=\frac{\partial \sigma _1 
+}{\partial s}$ and $\frac{1}{e_2 }\left. {\frac{\partial e_3 }{\partial j}} 
+\right|_s =\frac{\partial \sigma _2 }{\partial s}$, it becomes:
+
+\begin{align*}
+\nabla \cdot {\rm {\bf U}} 
+& = \frac{1}{e_1 \,e_2 \,e_3 }  \left[   
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]        \\ 
+& \qquad \qquad \qquad \qquad \qquad \quad
+ +\frac{1}{e_3 }\left[ {\frac{\partial w}{\partial s}-u\frac{\partial \sigma _1 }{\partial s}-v\frac{\partial \sigma _2 }{\partial s}-\sigma _1 \frac{\partial u}{\partial s}-\sigma _2 \frac{\partial v}{\partial s}} \right] \\ 
+\\
+& = \frac{1}{e_1 \,e_2 \,e_3 }  \left[   
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]      
+   + \frac{1}{e_3 } \; \frac{\partial}{\partial s}   \left[  w -  u\;\sigma _1  - v\;\sigma _2  \right]
+ \end{align*} 
+ 
+Here, $w$ is the vertical velocity relative to the $z-$coordinate system. 
+Introducing the dia-surface velocity component, $\omega $, defined as 
+the velocity relative to the moving $s$-surfaces and normal to them:
+\begin{equation} \label{Apdx_A_w_s}
+\omega  = w - w_s - \sigma _1 \,u - \sigma _2 \,v    \\
+\end{equation}
+with $w_s$ given by \eqref{Apdx_A_w_in_s}, we obtain the expression for 
+the divergence of the velocity in the curvilinear $s$-coordinate system:
+\begin{align*} \label{Apdx_A_A4}
+\nabla \cdot {\rm {\bf U}} 
+&= \frac{1}{e_1 \,e_2 \,e_3 }    \left[ 
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]      
++ \frac{1}{e_3 } \frac{\partial \omega }{\partial s} 
++ \frac{1}{e_3 } \frac{\partial w_s       }{\partial s}    \\
+\\
+&= \frac{1}{e_1 \,e_2 \,e_3 }    \left[ 
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]      
++ \frac{1}{e_3 } \frac{\partial \omega }{\partial s} 
++ \frac{1}{e_3 } \frac{\partial}{\partial s}  \left(  e_3 \; \frac{\partial s}{\partial t}   \right)   \\
+\\
+&= \frac{1}{e_1 \,e_2 \,e_3 }    \left[ 
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]      
++ \frac{1}{e_3 } \frac{\partial \omega }{\partial s} 
++ \frac{\partial}{\partial s} \frac{\partial s}{\partial t}
++ \frac{1}{e_3 } \frac{\partial s}{\partial t} \frac{\partial e_3}{\partial s}     \\
+\\
+&= \frac{1}{e_1 \,e_2 \,e_3 }    \left[ 
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s 
+		+\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]      
++ \frac{1}{e_3 } \frac{\partial \omega }{\partial s} 
++ \frac{1}{e_3 } \frac{\partial e_3}{\partial t}     \\
+\end{align*}
+
+As a result, the continuity equation \eqref{Eq_PE_continuity} in the 
+$s$-coordinates becomes:
+\begin{equation} \label{Apdx_A_A5}
+\frac{1}{e_3 } \frac{\partial e_3}{\partial t} 
++ \frac{1}{e_1 \,e_2 \,e_3 }\left[ 
+			{\left. {\frac{\partial (e_2 \,e_3 \,u)}{\partial i}} \right|_s 
+		    +  \left. {\frac{\partial (e_1 \,e_3 \,v)}{\partial j}} \right|_s } \right]
+ +\frac{1}{e_3 }\frac{\partial \omega }{\partial s} = 0   
+\end{equation}
+
+% ================================================================
+% momentum equation
+% ================================================================
+\section{Momentum Equation}
+\label{Apdx_B_momentum}
+
+Let us consider \eqref{Eq_PE_dyn_vect}, the first component of the momentum 
+equation in the vector invariant form (similar manipulations can be performed 
+on the second component). Its non-linear term can be transformed as follows:
+
+\begin{align*}
+&+\left. \zeta \right|_z v-\frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_z 
+- w \;\frac{\partial u}{\partial z} \\
+\\
+&\qquad=\frac{1}{e_1 \,e_2 }\left[ {\left. {\frac{\partial (e_2 \,v)}{\partial i}} 
+\right|_z -\left. {\frac{\partial (e_1 \,u)}{\partial j}} \right|_z } 
+\right]\;v-\frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} 
+\right|_z -w\frac{\partial u}{\partial z}      \\
+\\
+&\qquad =\frac{1}{e_1 \,e_2 }\left[ {\left. {\frac{\partial (e_2 \,v)}{\partial i}} 
+\right|_s -\left. {\frac{\partial (e_1 \,u)}{\partial j}} \right|_s }     \right. 
+ \left. {-\frac{e_1 }{e_3 }\sigma _1 \frac{\partial (e_2 \,v)}{\partial s}+\frac{e_2 }{e_3 }\sigma _2 \frac{\partial (e_1 \,u)}{\partial s}} \right]\;v \\ 
+&\qquad \qquad \qquad \qquad \qquad
+{ -\frac{1}{2e_1 }\left( {\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s -\frac{e_1 }{e_3 }\sigma _1 \frac{\partial (u^2+v^2)}{\partial s}} \right)
+-\frac{w}{e_3 }\frac{\partial u}{\partial s} }    \\
+\end{align*}
+\begin{align*}
+\qquad  &= \left. \zeta \right|_s \;v
+	- \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s 
+	- \frac{w}{e_3 }\frac{\partial u}{\partial s}
+	- \left[   {\frac{\sigma _1 }{e_3 }\frac{\partial v}{\partial s}
+	           - \frac{\sigma_2 }{e_3 }\frac{\partial u}{\partial s}}   \right]\;v      \\
+\qquad&\qquad \qquad \qquad \qquad \qquad \qquad
+\qquad  \qquad \qquad \qquad \quad
+	+\frac{\sigma _1 }{2e_3 }\frac{\partial (u^2+v^2)}{\partial s}      \\
+%\\
+\qquad &= \left. \zeta \right|_s \;v
+		- \frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s \\ 
+\qquad&\qquad \qquad \qquad
+ -\frac{1}{e_3} \left[    {w\frac{\partial u}{\partial s}
+	+\sigma _1 v\frac{\partial v}{\partial s} - \sigma _2 v\frac{\partial u}{\partial s}
+	-\sigma _1 u\frac{\partial u}{\partial s} - \sigma _1 v\frac{\partial v}{\partial s}} \right] \\
+\\
+\qquad &= \left. \zeta \right|_s \;v
+		- \frac{1}{2e_1 }\left. \frac{\partial (u^2+v^2)}{\partial i} \right|_s    
+		  - \frac{1}{e_3} \left[  w - \sigma _2 v - \sigma _1 u  \right] 
+		  			 \; \frac{\partial u}{\partial s}   \\
+\\
+\qquad &= \left. \zeta \right|_s \;v
+		- \frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s   
+		  - \frac{1}{e_3 }\omega \frac{\partial u}{\partial s} 
+		  - \frac{\partial s}{\partial t}  \frac{\partial u}{\partial s} 
+\end{align*}
+
+Therefore, the non-linear terms of the momentum equation have the same 
+form in $z-$ and $s-$coordinates but with the addition of the time derivative 
+of the velocity: 
+\begin{multline}  \label{Apdx_A_momentum_NL}
++\left. \zeta \right|_z v-\frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_z 
+- w \;\frac{\partial u}{\partial z}    \\
+= - \frac{\partial u}{\partial t} + \left. \zeta \right|_s \;v
+	- \frac{1}{2e_1 }\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s   
+	- \frac{1}{e_3 }\omega \frac{\partial u}{\partial s} 
+\end{multline}
+
+The pressure gradient term can be transformed as follows:
+\begin{equation} \label{Apdx_A_grad_p}
+\begin{split}
+ -\frac{1}{\rho _o e_1 }\left. {\frac{\partial p}{\partial i}} \right|_z& =-\frac{1}{\rho _o e_1 }\left[ {\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{e_1 }{e_3 }\sigma _1 \frac{\partial p}{\partial s}} \right] \\
+& =-\frac{1}{\rho _o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s +\frac{\sigma _1 }{\rho _o \,e_3 }\left( {-g\;\rho \;e_3 } \right) \\
+&=-\frac{1}{\rho _o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{g\;\rho }{\rho _o }\sigma _1
+\end{split}
+\end{equation}
+
+An additional term appears in (\ref{Apdx_A_grad_p}) which accounts for the 
+tilt of model levels.
+
+Introducing \eqref{Apdx_A_momentum_NL} and \eqref{Apdx_A_grad_p} in \eqref{Eq_PE_dyn_vect} and regrouping the time derivative terms in the left 
+hand side, and performing the same manipulation on the second component, 
+we obtain the vector invariant form of the momentum equations in the 
+$s-$coordinate :
+\begin{subequations} \label{Apdx_A_dyn_vect}
+\begin{multline} \label{Apdx_A_PE_dyn_vect_u}
+ \frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t}=
+	+   \left( {\zeta +f} \right)\,v                                    
+	-   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right) 
+	-   \frac{1}{e_3} \omega \frac{\partial u}{\partial k}       \\
+	-   \frac{1}{e_1} \frac{\partial}{\partial i} \left( \frac{p_s + p_h}{\rho _o}    \right)    
+	+  g\frac{\rho }{\rho _o}\sigma _1 
+	+   D_u^{\vect{U}}  +   F_u^{\vect{U}}
+\end{multline}
+\begin{multline} \label{Apdx_A_dyn_vect_v}
+ \frac{1}{e_3}\frac{\partial \left(  e_3\,v  \right) }{\partial t}=
+	-   \left( {\zeta +f} \right)\,u   
+	-   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)     	
+	-   \frac{1}{e_3 } \omega \frac{\partial v}{\partial k}         \\
+	-   \frac{1}{e_2 }\frac{\partial }{\partial j}\left( \frac{p_s+p_h }{\rho _o}  \right) 
+	 +  g\frac{\rho }{\rho _o }\sigma _2   
+	+  D_v^{\vect{U}}  +   F_v^{\vect{U}}
+\end{multline}
+\end{subequations}
+
+It has the same form as in the $z-$coordinate but for the vertical scale factor 
+that has appeared inside the time derivative. The form of the vertical physics 
+and forcing terms remains unchanged. The form of the lateral physics is 
+discussed in appendix~\ref{Apdx_B}.  
+
+% ================================================================
+% Tracer equation
+% ================================================================
+\section{Tracer Equation}
+\label{Apdx_B_tracer}
+
+The tracer equation is obtained using the same calculation as for the continuity 
+equation and then regrouping the time derivative terms in the left hand side :
+
+\begin{multline} \label{Apdx_A_tracer}
+ \frac{1}{e_3} \frac{\partial \left(  e_3 T  \right)}{\partial t} 
+ 	= -\frac{1}{e_1 \,e_2 \,e_3 } 
+		\left[ {\frac{\partial }{\partial i}} \left( {e_2 \,e_3 \;Tu} \right) \right .
+		    +         \frac{\partial }{\partial j} \left( {e_1 \,e_3 \;Tv} \right)                \\
+		    + \left. \frac{\partial }{\partial j} \left( {e_1 \,e_3 \;Tv} \right) \right] +D^{T} +F^{T} \; \;
+\end{multline}
+
+
+The expression for the advection term is a straight consequence of (A.4), the 
+expression of the 3D divergence in the $s$-coordinates established above. 
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_B.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_B.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_B.tex	(revision 1844)
@@ -0,0 +1,279 @@
+% ================================================================
+% Chapter Ñ Appendix B : Diffusive Operators
+% ================================================================
+\chapter{Appendix B : Diffusive Operators}
+\label{Apdx_B}
+\minitoc
+
+% ================================================================
+% Horizontal/Vertical 2nd Order Tracer Diffusive Operators
+% ================================================================
+\section{Horizontal/Vertical 2nd Order Tracer Diffusive Operators}
+\label{Apdx_B_1}
+
+
+In the $z$-coordinate, the horizontal/vertical second order tracer diffusion operator 
+is given by:
+\begin{multline} \label{Apdx_B1}
+ D^T = \frac{1}{e_1 \, e_2}      \left[ 
+  \left. \frac{\partial}{\partial i} \left( 	\frac{e_2}{e_1}A^{lT} \;\left. \frac{\partial T}{\partial i} \right|_z   \right)   \right|_z      \right.          \\
+						     \left.
++ \left. \frac{\partial}{\partial j} \left(  \frac{e_1}{e_2}A^{lT} \;\left. \frac{\partial T}{\partial j} \right|_z   \right)   \right|_z      \right]         
++ \frac{\partial }{\partial z}\left( {A^{vT} \;\frac{\partial T}{\partial z}} \right)
+\end{multline}
+
+In the $s$-coordinate, we defined the slopes of $s$-surfaces, $\sigma_1$ and 
+$\sigma_2$ by (!!!A.1!!!) and the vertical/horizontal ratio of diffusion coefficient 
+by $\epsilon = A^{vT} / A^{lT}$. The diffusion operator is given by:
+
+\begin{equation} \label{Apdx_B2}
+D^T = \left. \nabla \right|_s \cdot 
+           \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_s T  \right] \\
+\;\;\text{where} \;\Re =\left( {{\begin{array}{*{20}c}
+ 1 \hfill & 0 \hfill & {-\sigma _1 } \hfill \\
+ 0 \hfill & 1 \hfill & {-\sigma _2 } \hfill \\
+ {-\sigma _1 } \hfill & {-\sigma _2 } \hfill & {\varepsilon +\sigma _1 
+^2+\sigma _2 ^2} \hfill \\
+\end{array} }} \right)
+\end{equation}
+or in expanded form:
+\begin{multline} \label{Apdx_B3}
+D^T=\frac{1}{e_1\,e_2\,e_3 }\;\left[ {\quad \; \; e_2\,e_3\,A^{lT} \;\left. 
+{\frac{\partial }{\partial i}\left( {\frac{1}{e_1 }\;\left. {\frac{\partial 
+T}{\partial i}} \right|_s -\frac{\sigma _1 }{e_3 }\;\frac{\partial 
+T}{\partial s}} \right)} \right|_s } \right.  \\
++e_1\,e_3\,A^{lT} \;\left. {\frac{\partial }{\partial j}\left( {\frac{1}{e_2 }\;\left. {\frac{\partial T}{\partial j}} \right|_s -\frac{\sigma _2 }{e_3 }\;\frac{\partial T}{\partial s}} \right)} \right|_s \\
+ \;\;+e_1\,e_2\,A^{lT} \;\frac{\partial }{\partial s}\left( {-\frac{\sigma _1 }{e_1 }\;\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{\sigma _2 }{e_2 }\;\left. {\frac{\partial T}{\partial j}} \right|_s } \right. \; \\
+\shoveright{\;\;\left. {\left. {+\left( {\varepsilon +\sigma _1^2+\sigma _2 ^2} \right)\;\frac{1}{e_3 }\;\frac{\partial T}{\partial s}} \right)\;\;\,} \right]} 
+\end{multline}
+
+Equation \eqref{Apdx_B2} (or equivalently \eqref{Apdx_B3}) is obtained from 
+\eqref{Apdx_B1} without any additional assumption. Indeed, for the special 
+case $k=z$ and thus $e_3 =1$, we introduce an arbitrary vertical coordinate 
+$s = s (i,j,z)$ as in Appendix~\ref{Apdx_A} and use \eqref{Apdx_A_s_slope} 
+and \eqref{Apdx_A_s_chain_rule}. Since no cross horizontal derivative 
+$\partial _i \partial _j $ appears in \eqref{Apdx_B1}, the ($i$,$z$) and ($j$,$z$) 
+planes are independent. The derivation can then be demonstrated for the 
+($i$,$z$)~$\to$~($j$,$s$) transformation without any loss of generality:
+
+\begin{equation*}
+D^T=\frac{1}{e_1\,e_2 }\left. {\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_z } \right)} \right|_z +\frac{\partial }{\partial z}\left( {A^{vT}\;\frac{\partial T}{\partial z}} \right)        \qquad  \qquad  \qquad  \qquad \qquad  \qquad \qquad     \\
+\end{equation*}
+\begin{multline*}
+ =\frac{1}{e_1\,e_2 }\left[ {\left. {\;\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left( {\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{e_1 \,\sigma _1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right)} \right|_s } \right. \\ 
+ \left. { -\frac{e_1 \,\sigma _1 }{e_3 }\frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\left( {\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{e_1 \,\sigma _1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right|_s } \right)\;} \right]   
+\shoveright{ +\frac{1}{e_3 }\frac{\partial }{\partial s}\left[ {\frac{A^{vT}}{e_3 }\;\frac{\partial T}{\partial s}} \right]} \\ 
+\end{multline*}
+\begin{multline*}
+ =\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s -\left. {\frac{e_2 }{e_1 
+}A^{lT}\;\frac{\partial e_3 }{\partial i}} \right|_s \left. {\frac{\partial T}{\partial i}} \right|_s } \right. \\ 
+ \left. {-e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma _1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s -e_1 \,\sigma _1 \frac{\partial }{\partial s}\left( 
+{\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
+ \shoveright{ -e_1 \,\sigma _1 \frac{\partial }{\partial s}\left( {-\frac{e_2 \,\sigma _1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)\;\,\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;} \right] }\\ 
+\end{multline*}
+
+Noting that $\frac{1}{e_1} \left. \frac{\partial e_3 }{\partial i} \right|_s = \frac{\partial \sigma _1 }{\partial s}$, it becomes:
+
+\begin{multline*}
+ =\frac{1}{e_1\,e_2\,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2\,e_3 }{e_1}\,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. 
+-\, {e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma _1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\ 
+\qquad -e_2 A^{lT}\;\frac{\partial \sigma _1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\ 
+\shoveright{ \left. { +e_1 \,\sigma _1 \frac{\partial }{\partial s}\left( {\frac{e_2 \,\sigma _1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial z}} \right)\;\;\;} \right] }\\ 
+\end{multline*}
+\begin{multline*}
+ =\frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. {-\frac{\partial }{\partial 
+i}\left( {e_2 \,\sigma _1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\ 
+ \left. {+\frac{e_2 \,\sigma _1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s} \;\frac{\partial e_3 }{\partial i}}  \right|_s -e_2 A^{lT}\;\frac{\partial \sigma _1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s \\ 
+-e_2 \,\sigma _1 \frac{\partial}{\partial s}\left( {A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma _1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right) \\ 
+\shoveright{ \left. {-\frac{\partial \left( {e_1 \,e_2 \,\sigma _1 } \right)}{\partial s} \left( {\frac{\sigma _1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s}} \right) + \frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right]} \\ 
+\end{multline*}
+using the same remark as just above, it becomes:
+\begin{multline*}
+= \frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma _1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right.\;\;\; \\ 
++\frac{e_1 \,e_2 \,\sigma _1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}\;\frac{\partial \sigma _1 }{\partial s} - \frac {\sigma _1 }{e_3} A^{lT} \;\frac{\partial \left( {e_1 \,e_2 \,\sigma _1 } \right)}{\partial s}\;\frac{\partial T}{\partial s} \\ 
+-e_2 \left( {A^{lT}\;\frac{\partial \sigma _1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s +\frac{\partial }{\partial s}\left( {\sigma _1 A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)-\frac{\partial \sigma _1 }{\partial s}\;A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\ 
+\shoveright{\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma _1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}+\frac{e_1 \,e_2}{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right] }\\ 
+\end{multline*}
+
+Since the horizontal scale factors do not depend on the vertical coordinate, 
+the last term of the first line and the first term of the last line cancel, while 
+the second line reduces to a single vertical derivative, so it becomes:
+
+\begin{multline*}
+ =\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma _1 \,A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\ 
+ \shoveright{ \left. {+\frac{\partial }{\partial s}\left( {-e_2 \,\sigma _1 \,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s +A^{lT}\frac{e_1 \,e_2 }{e_3 }\;\left( {\varepsilon +\sigma _1 ^2} \right)\frac{\partial T}{\partial s}} \right)\;\;\;} \right]} \\ 
+\end{multline*}
+
+in other words, the horizontal Laplacian operator in the ($i$,$s$) plane takes the following form :
+
+\begin{equation*}
+D^T = {\frac{1}{e_1\,e_2\,e_3}}
+\left( {{\begin{array}{*{30}c}
+{\left. {\frac{\partial \left( {e_2 e_3 \bullet } \right)}{\partial i}} \right|_s } \hfill \\
+{\frac{\partial \left( {e_1 e_2 \bullet } \right)}{\partial s}} \hfill \\
+\end{array}}}\right)
+\cdot \left[ {A^{lT}
+\left( {{\begin{array}{*{30}c}
+ {1} \hfill & {-\sigma_1 } \hfill \\
+ {-\sigma_1} \hfill & {\varepsilon_1^2} \hfill \\
+\end{array} }} \right)
+\cdot 
+\left( {{\begin{array}{*{30}c}
+{\frac{1}{e_1 }\;\left. {\frac{\partial \bullet }{\partial i}} \right|_s } \hfill \\
+{\frac{1}{e_3 }\;\frac{\partial \bullet }{\partial s}} \hfill \\
+\end{array}}}
+\right) \left( T \right)} \right]
+\end{equation*}
+ 
+
+% ================================================================
+% Isopycnal/Vertical 2nd Order Tracer Diffusive Operators
+% ================================================================
+\section{Iso/diapycnal 2nd Order Tracer Diffusive Operators}
+\label{Apdx_B_2}
+
+
+The iso/diapycnal diffusive tensor $\textbf {A}_{\textbf I}$ expressed in the ($i$,$j$,$k$) 
+curvilinear coordinate system in which the equations of the ocean circulation model are 
+formulated, takes the following form \citep{Redi_JPO82}:
+
+\begin{equation*}
+\textbf {A}_{\textbf I} = \frac{A^{lT}}{\left( {1+a_1 ^2+a_2 ^2} \right)}
+\left[ {{\begin{array}{*{20}c}
+ {1+a_1 ^2} \hfill & {-a_1 a_2 } \hfill & {-a_1 } \hfill \\
+ {-a_1 a_2 } \hfill & {1+a_2 ^2} \hfill & {-a_2 } \hfill \\
+ {-a_1 } \hfill & {-a_2 } \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
+\end{array} }} \right]
+\end{equation*}
+where ($a_1$, $a_2$) are the isopycnal slopes in ($\textbf{i}$, $\textbf{j}$) directions:
+\begin{equation*}
+a_1 =\frac{e_3 }{e_1 }\left( {\frac{\partial \rho }{\partial i}} \right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
+\qquad , \qquad
+a_2 =\frac{e_3 }{e_2 }\left( {\frac{\partial \rho }{\partial j}} 
+\right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
+\end{equation*}
+
+In practice, the isopycnal slopes are generally less than $10^{-2}$ in the ocean, so 
+$\textbf {A}_{\textbf I}$ can be simplified appreciably \citep{Cox1987}:
+\begin{equation*}
+{\textbf{A}_{\textbf{I}}} \approx A^{lT}
+\left[ {{\begin{array}{*{20}c}
+ 1 \hfill & 0 \hfill & {-a_1 } \hfill \\
+ 0 \hfill & 1 \hfill & {-a_2 } \hfill \\
+ {-a_1 } \hfill & {-a_2 } \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
+\end{array} }} \right]
+\end{equation*}
+
+The resulting isopycnal operator conserves the quantity and dissipates its square. 
+The demonstration of the first property is trivial as \eqref{Apdx_B2} is the divergence 
+of fluxes. Let us demonstrate the second one:
+\begin{equation*}
+\iiint\limits_D T\;\nabla .\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv = -\iiint\limits_D \nabla T\;.\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv
+\end{equation*}
+since
+\begin{align*}
+ \nabla T\;.\left( {{\rm {\bf A}}_{\rm {\bf I}} \nabla T} 
+\right)&=A^{lT}\left[ {\left( {\frac{\partial T}{\partial i}} \right)^2-2a_1 
+\frac{\partial T}{\partial i}\frac{\partial T}{\partial k}+\left( 
+{\frac{\partial T}{\partial j}} \right)^2} \right. \\ 
+&\qquad \qquad \qquad \quad
+{ \left. -\,{2a_2 \frac{\partial T}{\partial j}\frac{\partial T}{\partial 
+k}+\left( {a_1 ^2+a_2 ^2} \right)\left( {\frac{\partial T}{\partial k}} 
+\right)^2} \right]} \\
+&=A_h \left[ {\left( {\frac{\partial T}{\partial i}-a_1 \frac{\partial T}{\partial k}} \right)^2+\left( {\frac{\partial T}{\partial j}-a_2 \frac{\partial T}{\partial k}} \right)^2} \right]\quad \geq 0
+\end{align*}
+the property becomes obvious. 
+
+The resulting diffusion operator in $z$-coordinate has the following form :
+\begin{multline*} \label{Apdx_B_ldfiso}
+ D^T=\frac{1}{e_1 e_2 }\left\{ {\;\frac{\partial }{\partial i}\left[ {A_h \left( {\frac{e_2 }{e_1 }\frac{\partial T}{\partial i}-a_1 \frac{e_2}{e_3}\frac{\partial T}{\partial k}} \right)} \right]\;} \right.\;\; \\ 
+ \;\left. {\;\;\;+\frac{\partial}{\partial j}\left[ {A_h \left( {\frac{e_1 }{e_2 }\frac{\partial T}{\partial j}-a_2 \frac{e_1 }{e_3 }\frac{\partial T}{\partial k}} \right)} \right]\;} \right\} \\
+\shoveright{+\frac{1}{e_3 }\frac{\partial }{\partial k}\left[ {A_h \left( {-\frac{a_1 }{e_1 }\frac{\partial T}{\partial i}-\frac{a_2 }{e_2 }\frac{\partial T}{\partial j}+\frac{\left( {a_1 ^2+a_2 ^2} \right)}{e_3 }\frac{\partial T}{\partial k}} \right)} \right]} \\ 
+\end{multline*}
+
+It has to be emphasised that the simplification introduced, leads to a decoupling 
+between ($i$,$z$) and ($j$,$z$) planes. The operator has therefore the same 
+expression as \eqref{Apdx_B3}, the diffusion operator obtained for geopotential 
+diffusion in the $s$-coordinate. 
+
+% ================================================================
+% Lateral/Vertical Momentum Diffusive Operators
+% ================================================================
+\section{Lateral/Vertical Momentum Diffusive Operators}
+\label{Apdx_B_3}
+
+The second order momentum diffusion operator (Laplacian) in the $z$-coordinate 
+is found by applying \eqref{Eq_PE_lap_vector}, the expression for the Laplacian 
+of a vector,  to the horizontal velocity vector : 
+\begin{align*}
+\Delta {\textbf{U}}_h 
+&=\nabla \left( {\nabla \cdot {\textbf{U}}_h } \right)-
+\nabla \times \left( {\nabla \times {\textbf{U}}_h } \right)    \\
+\\
+&=\left( {{\begin{array}{*{20}c}
+ {\frac{1}{e_1 }\frac{\partial \chi }{\partial i}} \hfill \\
+ {\frac{1}{e_2 }\frac{\partial \chi }{\partial j}} \hfill \\
+ {\frac{1}{e_3 }\frac{\partial \chi }{\partial k}} \hfill \\
+\end{array} }} \right)-\left( {{\begin{array}{*{20}c}
+ {\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}-\frac{1}{e_3 
+}\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial 
+u}{\partial k}} \right)} \hfill \\
+ {\frac{1}{e_3 }\frac{\partial }{\partial k}\left( {-\frac{1}{e_3 
+}\frac{\partial v}{\partial k}} \right)-\frac{1}{e_1 }\frac{\partial \zeta 
+}{\partial i}} \hfill \\
+ {\frac{1}{e_1 e_2 }\left[ {\frac{\partial }{\partial i}\left( {\frac{e_2 
+}{e_3 }\frac{\partial u}{\partial k}} \right)-\frac{\partial }{\partial 
+j}\left( {-\frac{e_1 }{e_3 }\frac{\partial v}{\partial k}} \right)} \right]} 
+\hfill \\
+\end{array} }} \right)
+\\
+\\
+&=\left( {{\begin{array}{*{20}c}
+{\frac{1}{e_1 }\frac{\partial \chi }{\partial i}-\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}} \\
+{\frac{1}{e_2 }\frac{\partial \chi }{\partial j}+\frac{1}{e_1 }\frac{\partial \zeta }{\partial i}} \\
+0 \\
+\end{array} }} \right)
++\frac{1}{e_3 }
+\left( {{\begin{array}{*{20}c}
+{\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial u}{\partial k}} \right)} \\
+{\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial v}{\partial k}} \right)} \\
+{\frac{\partial \chi }{\partial k}-\frac{1}{e_1 e_2 }\left( {\frac{\partial ^2\left( {e_2 \,u} \right)}{\partial i\partial k}+\frac{\partial ^2\left( {e_1 \,v} \right)}{\partial j\partial k}} \right)} \\
+\end{array} }} \right)
+\end{align*}
+Using \eqref{Eq_PE_div}, the definition of the horizontal divergence, the third 
+componant of the second vector is obviously zero and thus :
+\begin{equation*}
+\Delta {\textbf{U}}_h = \nabla _h \left( \chi \right) - \nabla _h \times \left( \zeta \right) + \frac {1}{e_3 } \frac {\partial }{\partial k} \left( {\frac {1}{e_3 } \frac{\partial {\textbf{ U}}_h }{\partial k}} \right)
+\end{equation*}
+
+Note that this operator ensures a full separation between the vorticity and horizontal 
+divergence fields (see Appendix~\ref{Apdx_C}). It is only equal to a Laplacian 
+applied to each component in Cartesian coordinates, not on the sphere.
+
+The horizontal/vertical second order (Laplacian type) operator used to diffuse 
+horizontal momentum in the $z$-coordinate therefore takes the following form :
+\begin{equation} \label{Apdx_B_Lap_U}
+ {\textbf{D}}^{\textbf{U}} = 
+ 	  \nabla _h \left( {A^{lm}\;\chi } \right)
+	- \nabla _h \times \left( {A^{lm}\;\zeta \;{\textbf{k}}} \right)
+	+ \frac{1}{e_3 }\frac{\partial }{\partial k}\left( {\frac{A^{vm}\;}{e_3 }
+				\frac{\partial {\rm {\bf U}}_h }{\partial k}} \right) \\ 
+\end{equation}
+that is, in expanded form:
+\begin{align*}
+D^{\textbf{U}}_u 
+& = \frac{1}{e_1} \frac{\partial \left( {A^{lm}\chi   } \right)}{\partial i}
+     -\frac{1}{e_2} \frac{\partial \left( {A^{lm}\zeta } \right)}{\partial j}
+     +\frac{1}{e_3} \frac{\partial u}{\partial k}      \\
+D^{\textbf{U}}_v   
+& = \frac{1}{e_2 }\frac{\partial \left( {A^{lm}\chi   } \right)}{\partial j}
+     +\frac{1}{e_1 }\frac{\partial \left( {A^{lm}\zeta } \right)}{\partial i}
+     +\frac{1}{e_3} \frac{\partial v}{\partial k}
+\end{align*}
+
+Note Bene: introducing a rotation in \eqref{Apdx_B_Lap_U} does not lead to a 
+useful expression for the iso/diapycnal Laplacian operator in the $z$-coordinate. 
+Similarly, we did not found an expression of practical use for the geopotential 
+horizontal/vertical Laplacian operator in the $s$-coordinate. Generally, 
+\eqref{Apdx_B_Lap_U} is used in both $z$- and $s$-coordinate systems, that is 
+a Laplacian diffusion is applied on momentum along the coordinate directions.
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_C.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_C.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_C.tex	(revision 1844)
@@ -0,0 +1,1387 @@
+% ================================================================
+% Chapter Ñ Appendix C : Discrete Invariants of the Equations
+% ================================================================
+\chapter{Discrete Invariants of the Equations}
+\label{Apdx_C}
+\minitoc
+
+%%%  Appendix put in gmcomment as it has not been updated for z* and s coordinate
+I'm writting this appendix. It will be available in a forthcoming release of the documentation
+
+%\gmcomment{
+
+% ================================================================
+% Conservation Properties on Ocean Dynamics
+% ================================================================
+\section{Conservation Properties on Ocean Dynamics}
+\label{Apdx_C.1}
+
+First, the boundary condition on the vertical velocity (no flux through the surface 
+and the bottom) is established for the discrete set of momentum equations. 
+Then, it is shown that the non-linear terms of the momentum equation are written 
+such that the potential enstrophy of a horizontally non-divergent flow is preserved 
+while all the other non-diffusive terms preserve the kinetic energy; in practice the 
+energy is also preserved. In addition, an option is also offered for the vorticity term 
+discretization which provides a total kinetic energy conserving discretization for 
+that term. 
+
+Nota Bene: these properties are established here in the rigid-lid case and for the 
+2nd order centered scheme. A forthcoming update will be their generalisation to 
+the free surface case and higher order scheme.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Bottom Boundary Condition on Vertical Velocity Field
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Bottom Boundary Condition on Vertical Velocity Field}
+\label{Apdx_C.1.1}
+
+
+The discrete set of momentum equations used in the rigid-lid approximation 
+automatically satisfies the surface and bottom boundary conditions 
+(no flux through the surface and the bottom: $w_{surface} =w_{bottom} =~0$). 
+Indeed, taking the discrete horizontal divergence of the vertical sum of the 
+horizontal momentum equations (!!!Eqs. (II.2.1) and (II.2.2)!!!) weighted by the 
+vertical scale factors, it becomes:
+\begin{flalign*}
+\frac{\partial } {\partial t}  \left( \sum\limits_k    \chi    \right)
+\equiv 
+\frac{\partial } {\partial t}  \left( 	w_{surface} -w_{bottom}     \right)&&&\\
+\end{flalign*}
+\begin{flalign*}
+\equiv \frac{1} {e_{1T}\,e_{2T}\,e_{3T}} 
+	\biggl\{ \quad
+	\delta_i 
+		&\left[ 
+		e_{2u}\,H_u 
+			\left( 
+			M_u - M_u - \frac{1} {H_u\,e_{2u}} \delta_j 
+				\left[ \partial_t\, \psi \right] 
+			\right) 
+		\right] &&
+	\biggr. \\
+	\biggl. 
+	+ \delta_j 
+		&\left[ 
+		e_{1v}\,H_v 
+			\left( M_v - M_v - \frac{1} {H_v\,e_{1v}} \delta_i 
+				\left[ \partial_i\, \psi \right] 
+			\right) 
+		\right] 
+	\biggr\}&& \\
+\end{flalign*}
+\begin{flalign*}
+\equiv \frac{1} {e_{1T} \,e_{2T} \,e_{3T}} \;
+	\biggl\{ 
+	- \delta_i 
+		\Bigl[ 
+		\delta_j 
+			\left[ \partial_t \psi  \right] 
+		\Bigr]
+	+ \delta_j 
+		\Bigl[ 
+		\delta_i 
+			\left[ \partial_t \psi  \right] 
+		\Bigr]\; 
+	\biggr\}\;
+	\equiv 0
+	&&&\\
+\end{flalign*}
+
+
+The surface boundary condition associated with the rigid lid approximation 
+($w_{surface} =0)$ is imposed in the computation of the vertical velocity (!!! II.2.5!!!!). 
+Therefore, it turns out to be:
+\begin{equation*}
+\frac{\partial } {\partial t}w_{bottom} \equiv 0
+\end{equation*}
+As the bottom velocity is initially set to zero, it remains zero all the time. 
+Symmetrically, if $w_{bottom} =0$ is used in the computation of the vertical 
+velocity (upward integral of the horizontal divergence), the same computation 
+leads to $w_{surface} =0$ as soon as the surface vertical velocity is initially 
+set to zero.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Coriolis and advection terms: vector invariant form
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Coriolis and advection terms: vector invariant form}
+\label{Apdx_C_vor_zad}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Vorticity Term
+% -------------------------------------------------------------------------------------------------------------
+\subsubsection{Vorticity Term}
+\label{Apdx_C_vor} 
+
+Potential vorticity is located at $f$-points and defined as: $\zeta / e_{3f}$. 
+The standard discrete formulation of the relative vorticity term obviously 
+conserves potential vorticity (ENS scheme). It also conserves the potential 
+enstrophy for a horizontally non-divergent flow (i.e. $\chi $=0) but not the 
+total kinetic energy. Indeed, using the symmetry or skew symmetry properties 
+of the operators (Eqs \eqref{DOM_mi_adj} and \eqref{DOM_di_adj}), it can 
+be shown that:
+\begin{equation} \label{Apdx_C_1.1}
+\int_D {\zeta / e_3\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {\zeta \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \equiv 0
+\end{equation}
+where $dv=e_1\,e_2\,e_3 \; di\,dj\,dk$ is the volume element. Indeed, using 
+\eqref{Eq_dynvor_ens}, the discrete form of the right hand side of \eqref{Apdx_C_1.1} 
+can be transformed as follow:
+\begin{flalign*} 
+&\int_D \zeta / e_3\,\; \textbf{k} \cdot \frac{1} {e_3 } \nabla \times 
+	\left( 
+	\zeta \; \textbf{k} \times  \textbf{U}_h  
+	\right)\;
+	dv
+	&&& \displaybreak[0] \\
+%
+\equiv& \sum\limits_{i,j,k} 
+\frac{\zeta / e_{3f}} {e_{1f}\,e_{2f}\,e_{3f}} 
+	\biggl\{ \quad
+	\delta_{i+1/2} 
+		\left[ 
+		   - \overline {\left( {\zeta / e_{3f}} \right)}^{\,i}\;
+		      \overline{\overline {\left( e_{2u}\,e_{3u}\,u \right)}}^{\,i,j+1/ 2} 
+		 \right]  
+	&&  \\ & \qquad \qquad \qquad \;\;
+	- \delta_{j+1/2} 
+		\left[	\;\;\;
+		     \overline {\left( \zeta / e_{3f} \right)}^{\,j}\;
+		     \overline{\overline {\left( e_{1v}\,e_{3v}\,v \right)}}^{\,i+1/2,j} 
+		\right] 
+	\;\;\biggr\} \;  e_{1f}\,e_{2f}\,e_{3f}       && \displaybreak[0] \\ 
+%
+\equiv& \sum\limits_{i,j,k} 
+	\biggl\{   \delta_i     \left[   \frac{\zeta} {e_{3f}}   \right] \;
+		     \overline{  \left(   \frac{\zeta} {e_{3f}}   \right)  }^{\,i}\; 
+		     \overline{  \overline{   \left( e_{1u}\,e_{3u}\,u \right)  }  }^{\,i,j+1/2} 
+			+ \delta_j   \left[   \frac{\zeta} {e_{3f}}   \right] \;
+        		\overline{   \left(  \frac{\zeta} {e_{3f}}    \right)  }^{\,j} \; 
+		\overline{\overline {\left( e_{2v}\,e_{3v}\,v \right)}}^{\,i+1/2,j}         \biggr\} 
+		&&&& \displaybreak[0] \\ 
+%
+\equiv& \frac{1} {2} \sum\limits_{i,j,k}  
+	\biggl\{	\delta_i    \Bigl[    \left(  \frac{\zeta} {e_{3f}} \right)^2   \Bigr]\;
+			\overline{\overline {\left( e_{2u}\,e_{3u}\,u \right)}}^{\,i,j+1/2} 
+		      + \delta_j 	\Bigl[    \left( \zeta / e_{3f} \right)^2     \Bigr]\; 
+			\overline{\overline {\left( e_{1v}\,e_{3v}\,v \right)}}^{\,i+1/2,j} 
+	\biggr\} 
+	&& \displaybreak[0] \\ 
+%
+\equiv& - \frac{1} {2} \sum\limits_{i,j,k} 	\left(  \frac{\zeta} {e_{3f}} \right)^2\;
+	\biggl\{    \delta_{i+1/2} 
+	      \left[   \overline{\overline {\left( e_{2u}\,e_{3u}\,u \right)}}^{\,i,j+1/2}    \right]  
+	            + \delta_{j+1/2}
+		\left[   \overline{\overline {\left( e_{1v}\,e_{3v}\,v \right)}}^{\,i+1/2,j}     \right]  
+	\biggr\}    && \\ 
+\end{flalign*}
+Since $\overline {\;\cdot \;} $ and $\delta $ operators commute: $\delta_{i+1/2} 
+\left[ {\overline a^{\,i}} \right] = \overline {\delta_i \left[ a \right]}^{\,i+1/2}$, 
+and introducing the horizontal divergence $\chi $, it becomes:
+\begin{align*}
+\equiv& \sum\limits_{i,j,k} - \frac{1} {2} \left(  \frac{\zeta} {e_{3f}} \right)^2 \; \overline{\overline{ e_{1T}\,e_{2T}\,e_{3T}\, \chi}}^{\,i+1/2,j+1/2} \;\;\equiv 0 
+\qquad \qquad \qquad \qquad \qquad \qquad \qquad &&&&\\
+\end{align*}
+
+Note that the derivation is demonstrated here for the relative potential 
+vorticity but it applies also to the planetary ($f/e_3$) and the total 
+potential vorticity $((\zeta +f) /e_3 )$. Another formulation of the two 
+components of the vorticity term is optionally offered (ENE scheme) :
+\begin{equation*}
+	- \zeta \;{\textbf{k}}\times {\textbf {U}}_h 
+\equiv 
+	\left( {{
+	\begin{array} {*{20}c}
+		+ \frac{1} {e_{1u}} \; 
+		\overline {\left( \zeta / e_{3f} 	  \right)	
+		\overline {\left( e_{1v}\,e_{3v}\,v \right)}^{\,i+1/2}} ^{\,j} 
+		\hfill \\
+		- \frac{1} {e_{2v}} \; 
+		\overline {\left( \zeta / e_{3f}  	  \right)
+		\overline {\left( e_{2u}\,e_{3u}\,u \right)}^{\,j+1/2}} ^{\,i} 
+		\hfill \\
+	\end{array}} } 
+	\right)
+\end{equation*}
+
+This formulation does not conserve the enstrophy but it does conserve the 
+total kinetic energy. It is also possible to mix the two formulations in order 
+to conserve enstrophy on the relative vorticity term and energy on the 
+Coriolis term.
+\begin{flalign*}
+&\int\limits_D - \textbf{U}_h \cdot   \left(  \zeta \;\textbf{k} \times \textbf{U}_h  \right)  \;  dv &&  \\
+\equiv& \sum\limits_{i,j,k} 	\biggl\{ 	
+	   \overline {\left(  \frac{\zeta} {e_{3f}}      \right) 
+	     \overline {\left( e_{1v}e_{3v}v \right)}^{\,i+1/2}} ^{\,j} \, e_{2u}e_{3u}u 
+	- \overline {\left(  \frac{\zeta} {e_{3f}}       \right) 
+	    \overline {\left( e_{2u}e_{3u}u \right)}^{\,j+1/2}} ^{\,i} \, e_{1v}e_{3v}v \;
+	                                \biggr\}     
+\\
+\equiv& \sum\limits_{i,j,k}  \frac{\zeta} {e_{3f}}
+	\biggl\{  \overline {\left( e_{1v}e_{3v} v \right)}^{\,i+1/2}\;
+	    	    \overline {\left( e_{2u}e_{3u} u \right)}^{\,j+1/2}        
+		  - \overline {\left( e_{2u}e_{3u} u \right)}^{\,j+1/2}\;
+	            \overline {\left( e_{1v}e_{3v} v \right)}^{\,i+1/2}
+	\biggr\}
+	\equiv 0
+\end{flalign*}
+
+
+% -------------------------------------------------------------------------------------------------------------
+%       Gradient of Kinetic Energy / Vertical Advection
+% -------------------------------------------------------------------------------------------------------------
+\subsubsection{Gradient of Kinetic Energy / Vertical Advection}
+\label{Apdx_C_zad} 
+
+The change of Kinetic Energy (KE) due to the vertical advection is exactly 
+balanced by the change of KE due to the horizontal gradient of KE~:
+\begin{equation*}
+      \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv
+ = - \int_D \textbf{U}_h \cdot w \frac{\partial \textbf{U}_h} {\partial k}\;dv
+\end{equation*}
+Indeed, using successively \eqref{DOM_di_adj} ($i.e.$ the skew symmetry 
+property of the $\delta$ operator) and the incompressibility, then 
+\eqref{DOM_di_adj} again, then the commutativity of operators 
+$\overline {\,\cdot \,}$ and $\delta$, and finally \eqref{DOM_mi_adj} 
+($i.e.$ the symmetry property of the $\overline {\,\cdot \,}$ operator) 
+applied in the horizontal and vertical directions, it becomes:
+\begin{flalign*}
+&\int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv	&&&\\
+\equiv& \frac{1}{2} \sum\limits_{i,j,k} 
+	\biggl\{	
+	\frac{1} {e_{1u}}  \delta_{i+1/2} 
+	\left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}    \right]  u\,e_{1u}e_{2u}e_{3u}  
+     + \frac{1} {e_{2v}}  \delta_{j+1/2} 
+	\left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  v\,e_{1v}e_{2v}e_{3v} 
+	\biggr\} 
+	&&& \displaybreak[0] \\ 
+%
+\equiv&  \frac{1}{2} \sum\limits_{i,j,k} 
+	\left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)\;
+	\delta_k \left[  e_{1T}\,e_{2T} \,w   \right]
+%
+\;\; \equiv -\frac{1}{2} \sum\limits_{i,j,k}  \delta_{k+1/2} 
+	\left[ 
+	   \overline{ u^2}^{\,i} 
+	+ \overline{ v^2}^{\,j} 
+	\right] \;
+	e_{1v}\,e_{2v}\,w 
+	&&& \displaybreak[0]\\
+%
+\equiv &\frac{1} {2} \sum\limits_{i,j,k} 
+	\left(    \overline {\delta_{k+1/2} \left[ u^2 \right]}^{\,i} 
+		+ \overline {\delta_{k+1/2} \left[ v^2 \right]}^{\,j}    \right) \; e_{1T}\,e_{2T} \,w 
+	&& \displaybreak[0] \\
+%	
+\equiv &\frac{1} {2} \sum\limits_{i,j,k} 
+	\biggl\{  \overline {e_{1T}\,e_{2T} \,w}^{\,i+1/2}\;2 	
+			\overline {u}^{\,k+1/2}\; \delta_{k+1/2}         \left[ u \right]     %&&&  \\
+	 + \overline {e_{1T}\,e_{2T} \,w}^{\,j+1/2}\;2 	\overline {v}^{\,k+1/2}\; \delta_{k+1/2} 	\left[ v \right]  \;
+	\biggr\} 
+	&&\displaybreak[0] \\ 
+%
+\equiv& -\sum\limits_{i,j,k}  
+	\biggl\{
+	\quad \frac{1} {b_u } \;
+	\overline {\Bigl\{ \overline {e_{1T}\,e_{2T} \,w}^{\,i+1/2}\,\delta_{k+1/2}
+		\left[ u \right] 
+		       \Bigr\} }^{\,k} \;u\;e_{1u}\,e_{2u}\,e_{3u}  
+	&& \\
+	&\qquad \quad\; + \frac{1} {b_v } \;
+	\overline {\Bigl\{ \overline {e_{1T}\,e_{2T} \,w}^{\,j+1/2} \delta_{k+1/2}
+		 \left[ v \right] 
+		 	\Bigr\} }^{\,k} \;v\;e_{1v}\,e_{2v}\,e_{3v}  \;
+	\biggr\} 
+	&& \\ 
+\equiv& -\int\limits_D \textbf{U}_h \cdot w \frac{\partial \textbf{U}_h} {\partial k}\;dv	&&&\\
+\end{flalign*}
+
+The main point here is that the satisfaction of this property links the choice of 
+the discrete formulation of the vertical advection and of the horizontal gradient 
+of KE. Choosing one imposes the other. For example KE can also be discretized 
+as $1/2\,({\overline u^{\,i}}^2 + {\overline v^{\,j}}^2)$. This leads to the following 
+expression for the vertical advection:
+\begin{equation*}
+\frac{1} {e_3 }\; w\; \frac{\partial \textbf{U}_h } {\partial k}
+\equiv \left( {{\begin{array} {*{20}c}
+\frac{1} {e_{1u}\,e_{2u}\,e_{3u}} \;
+\overline{\overline {e_{1T}\,e_{2T} \,w\;\delta_{k+1/2} 
+\left[ \overline u^{\,i+1/2} \right]}}^{\,i+1/2,k}  \hfill \\
+\frac{1} {e_{1v}\,e_{2v}\,e_{3v}} \;
+\overline{\overline {e_{1T}\,e_{2T} \,w\;\delta_{k+1/2}
+\left[ \overline v^{\,j+1/2} \right]}}^{\,j+1/2,k} \hfill \\
+\end{array}} } \right)
+\end{equation*}
+a formulation that requires an additional horizontal mean in contrast with 
+the one used in NEMO. Nine velocity points have to be used instead of 3. 
+This is the reason why it has not been chosen.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Coriolis and advection terms: flux form
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Coriolis and advection terms: flux form}
+\label{Apdx_C.1.3}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Coriolis plus ``metric'' Term
+% -------------------------------------------------------------------------------------------------------------
+\subsubsection{Coriolis plus ``metric'' Term}
+\label{Apdx_C.1.3.1} 
+
+In flux from the vorticity term reduces to a Coriolis term in which the Coriolis 
+parameter has been modified to account for the ``metric'' term. This altered 
+Coriolis parameter is discretised at an f-point. It is given by: 
+\begin{equation*}
+f+\frac{1} {e_1 e_2 } 
+\left( v \frac{\partial e_2 } {\partial i} - u \frac{\partial e_1 } {\partial j}\right)\;
+\equiv \;
+f+\frac{1} {e_{1f}\,e_{2f}} 
+\left( \overline v^{\,i+1/2} \delta_{i+1/2} \left[ e_{2u} \right] 
+-\overline u^{\,j+1/2} \delta_{j+1/2} \left[ e_{1u}  \right] \right)
+\end{equation*}
+
+The ENE scheme is then applied to obtain the vorticity term in flux form. 
+It therefore conserves the total KE. The derivation is the same as for the 
+vorticity term in the vector invariant form (\S\ref{Apdx_C_vor}).
+
+% -------------------------------------------------------------------------------------------------------------
+%       Flux form advection
+% -------------------------------------------------------------------------------------------------------------
+\subsubsection{Flux form advection}
+\label{Apdx_C.1.3.2} 
+
+The flux form operator of the momentum advection is evaluated using a 
+centered second order finite difference scheme. Because of the flux form, 
+the discrete operator does not contribute to the global budget of linear 
+momentum. Because of the centered second order scheme, it conserves 
+the horizontal kinetic energy, that is :
+
+\begin{equation} \label{Apdx_C_I.3.10}
+\int_D \textbf{U}_h \cdot 
+\left( {{\begin{array} {*{20}c}
+\nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
+\nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
+\end{array}} } \right)\;dv =\;0
+\end{equation}
+
+Let us demonstrate this property for the first term of the scalar product 
+($i.e.$ considering just the the terms associated with the i-component of 
+the advection):
+\begin{flalign*}
+&\int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv    &&&\\
+%
+\equiv& \sum\limits_{i,j,k} 
+\biggl\{    \frac{1} {e_{1u}\, e_{2u}\,e_{3u}}    \biggl(   
+      \delta_{i+1/2}  \left[   \overline {e_{2u}\,e_{3u}\,u}^{\,i}      \;\overline u^{\,i}          \right]   
+   + \delta_j           \left[   \overline {e_{1u}\,e_{3u}\,v}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right] 
+		&&& \\ & \qquad \qquad \qquad \qquad \qquad \qquad
+   + \delta_k          \left[   \overline {e_{1w}\,e_{2w}\,w}^{\,i+1/2}\;\overline u^{\,k+1/2} \right]
+			\biggr)   \;   \biggr\} \, e_{1u}\,e_{2u}\,e_{3u} \;u 
+		&&& \displaybreak[0] \\ 
+%
+\equiv& \sum\limits_{i,j,k} 
+	\biggl\{ 
+      \delta_{i+1/2} \left[   \overline {e_{2u}\,e_{3u}\,u}^{\,i}\;  \overline u^{\,i}  \right]
+   + \delta_j          \left[   \overline {e_{1u}\,e_{3u}\,v}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
+		&&& \\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
+   + \delta_k         \left[   \overline {e_{1w}\,e_{2w}\,w}^{\,i+12}\;\overline u^{\,k+1/2}  \right]
+   	\; \biggr\} \; u    &&& \displaybreak[0] \\
+%
+\equiv& - \sum\limits_{i,j,k}
+	\biggl\{ 
+	   \overline {e_{2u}\,e_{3u}\,u}^{\,i}\;			\overline u^{\,i} 		\delta_i 
+		\left[ u \right] 
+        + \overline {e_{1u}\,e_{3u}\,v}^{\,i+1/2}\;	\overline u^{\,j+1/2} 	\delta_{j+1/2} 
+		\left[ u \right] 
+		&&& \\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
+       + \overline {e_{1w}\,e_{2w}\,w}^{\,i+1/2}\;	\overline u^{\,k+1/2}	\delta_{k+1/2} 	\left[ u \right]     \biggr\}     && \displaybreak[0] \\
+%
+\equiv& - \sum\limits_{i,j,k}
+	\biggl\{ 
+	     \overline {e_{2u}\,e_{3u}\,u}^{\,i} 			\delta_i 		\left[ u^2 \right] 
+	 + \overline {e_{1u}\,e_{3u}\,v}^{\,i+1/2} 		\delta_{j+/2} 	\left[ u^2 \right]
+	 + \overline {e_{1w}\,e_{2w}\,w}^{\,i+1/2} 	\delta_{k+1/2} 	\left[ u^2 \right] 
+	\biggr\} 
+	&& \displaybreak[0] \\
+%
+\equiv& \sum\limits_{i,j,k}
+	\bigg\{ 
+	   e_{2u}\,e_{3u}\,u\;		\delta_{i+1/2} 	   \left[ \overline {u^2}^{\,i} \right]
+        + e_{1u}\,e_{3u}\,v\;	\delta_{j+1/2} 	\; \left[ \overline {u^2}^{\,i} \right]
+	 + e_{1w}\,e_{2w}\,w\;	\delta_{k+1/2}  	   \left[ \overline {u^2}^{\,i} \right] 
+	\biggr\} 
+	&& \displaybreak[0] \\
+%
+\equiv& \sum\limits_{i,j,k}
+\overline {u^2}^{\,i} 
+	\biggl\{ 
+	   \delta_{i+1/2} 	\left[ e_{2u}\,e_{3u}\,u  \right]
+	+ \delta_{j+1/2} 	\left[ e_{1u}\,e_{3u}\,v  \right]
+	+ \delta_{k+1/2} 	\left[ e_{1w}\,e_{2w}\,w \right] 
+	\biggr\}  \;\;  \equiv 0
+	&&& \\
+\end{flalign*}
+
+When the UBS scheme is used to evaluate the flux form momentum advection, 
+the discrete operator does not contribute to the global budget of linear momentum 
+(flux form). The horizontal kinetic energy is not conserved, but forced to decay 
+($i.e.$ the scheme is diffusive). 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Hydrostatic Pressure Gradient Term
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Hydrostatic Pressure Gradient Term}
+\label{Apdx_C.1.4}
+
+
+A pressure gradient has no contribution to the evolution of the vorticity as the 
+curl of a gradient is zero. In the $z$-coordinate, this property is satisfied locally 
+on a C-grid with 2nd order finite differences (property \eqref{Eq_DOM_curl_grad}). 
+When the equation of state is linear ($i.e.$ when an advection-diffusion equation 
+for density can be derived from those of temperature and salinity) the change of 
+KE due to the work of pressure forces is balanced by the change of potential 
+energy due to buoyancy forces: 
+\begin{equation*}
+\int_D - \frac{1} {\rho_o} \left. \nabla p^h \right|_z \cdot \textbf{U}_h \;dv 
+= \int_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+\end{equation*}
+
+This property can be satisfied in a discrete sense for both $z$- and $s$-coordinates. 
+Indeed, defining the depth of a $T$-point, $z_T$, as the sum of the vertical scale 
+factors at $w$-points starting from the surface, the work of pressure forces can be 
+written as:
+\begin{flalign*}
+&\int_D - \frac{1} {\rho_o} \left. \nabla p^h \right|_z \cdot \textbf{U}_h \;dv   &&& \\
+\equiv& \sum\limits_{i,j,k} \biggl\{ \;  - \frac{1} {\rho_o e_{1u}}   \Bigl( 
+\delta_{i+1/2} \left[ p^h \right] - g\;\overline \rho^{\,i+1/2}\;\delta_{i+1/2} \left[ z_T \right] 
+		  			\Bigr)  \; u\;e_{1u}\,e_{2u}\,e_{3u}  
+	&&  \\ & \qquad \qquad
+						      	      - \frac{1} {\rho_o e_{2v}}    \Bigl( 
+\delta_{j+1/2} \left[ p^h \right] - g\;\overline \rho^{\,j+1/2}\delta_{j+1/2}  \left[ z_T \right] 
+					\Bigr)  \; v\;e_{1v}\,e_{2v}\,e_{3v} \;
+	\biggr\}   && \\ 
+\end{flalign*}
+
+Using  \eqref{DOM_di_adj}, $i.e.$ the skew symmetry property of the $\delta$ 
+operator, \eqref{Eq_wzv}, the continuity equation), and \eqref{Eq_dynhpg_sco}, 
+the hydrostatic equation in the $s$-coordinate, it becomes: 
+\begin{flalign*} 
+\equiv& \frac{1} {\rho_o} \sum\limits_{i,j,k}    \biggl\{ 
+		e_{2u}\,e_{3u} \;u\;g\;	\overline \rho^{\,i+1/2}\;\delta_{i+1/2}[ z_T]    
+	+ 	e_{1v}\,e_{3v} \;v\;g\;	\overline \rho^{\,j+1/2}\;\delta_{j+1/2}[ z_T]     
+&& \\  & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \;\;\,
+	+\Bigl(  \delta_i[ e_{2u}\,e_{3u}\,u] + \delta_j [ e_{1v}\,e_{3v}\,v]  \Bigr)\;p^h \biggr\}  &&\\
+%
+\equiv& \frac{1} {\rho_o } \sum\limits_{i,j,k}
+	\biggl\{ 
+		 e_{2u}\,e_{3u} \;u\;g\;	\overline \rho^{\,i+1/2} \delta_{i+1/2} \left[ z_T \right]
+	+ 	e_{1v}\,e_{3v} \;v\;g\;	\overline \rho^{\,j+1/2} \delta_{j+1/2} \left[ z_T \right] 
+	&&&\\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \;\;\,
+	 - \delta_k \left[ e_{1w} e_{2w}\,w \right]\;p^h   \biggr\}   &&&\\ 
+%
+\equiv& \frac{1} {\rho_o } \sum\limits_{i,j,k}
+	\biggl\{ 
+		e_{2u}\,e_{3u} \;u\;g\;	\overline \rho^{\,i+1/2}\;\delta_{i+1/2} \left[ z_T \right]
+	+ 	e_{1v}\,e_{3v} \;v\;g\;	\overline \rho^{\,j+1/2} \;\delta_{j+1/2} \left[ z_T \right] 
+	&&& \\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \;\;\,
+	+	 e_{1w} e_{2w} \;w\;\delta_{k+1/2} \left[ p_h \right] 
+	\biggr\}  &&&\\ 
+%
+\equiv& \frac{g} {\rho_o}  \sum\limits_{i,j,k}
+	\biggl\{ 
+		e_{2u}\,e_{3u} \;u\;	\overline \rho^{\,i+1/2}\;\delta_{i+1/2} \left[ z_T \right]
+	+	e_{1v}\,e_{3v} \;v\;	\overline \rho^{\,j+1/2}\;\delta_{j+1/2} \left[ z_T \right] 	
+	&&& \\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \;\;\,
+	- 	e_{1w} e_{2w} \;w\;e_{3w} \overline \rho^{\,k+1/2} 
+	\biggr\}   &&&\\ 
+\end{flalign*}
+noting that by definition of $z_T$, $\delta_{k+1/2} \left[ z_T \right] \equiv - e_{3w} $, thus:
+\begin{multline*}
+\equiv \frac{g} {\rho_o}  \sum\limits_{i,j,k}
+	\biggl\{ 
+		e_{2u}\,e_{3u} \;u\;	\overline \rho^{\,i+1/2}\;\delta_{i+1/2} \left[ z_T \right]
+	+ 	e_{1v}\,e_{3v} \;v\;	\overline \rho^{\,j+1/2} \delta_{j+1/2} \left[ z_T \right]
+	\biggr. \\ 
+\shoveright{
+	\biggl. 
+	+ 	e_{1w} e_{2w} \;w\;	\overline \rho^{\,k+1/2}\;\delta_{k+1/2} \left[ z_T \right] 
+	\biggr\} } \\ 
+\end{multline*}
+Using \eqref{DOM_di_adj}, it becomes:
+\begin{flalign*}
+\equiv& - \frac{g} {\rho_o} \sum\limits_{i,j,k} z_T 
+	\biggl\{ 
+		\delta_i 	\left[ e_{2u}\,e_{3u}\,u\;	\overline \rho^{\,i+1/2} 	\right]
+	+ 	\delta_j 	\left[ e_{1v}\,e_{3v}\,v\;	\overline \rho^{\,j+1/2} 	\right]
+	+ 	\delta_k 	\left[ e_{1w} e_{2w}\,w\;	\overline \rho^{\,k+1/2} 	\right] 
+	\biggr\} 
+	&&& \\
+%
+\equiv& -\int_D \nabla \cdot \left( \rho \, \textbf{U} \right)\;g\;z\;\;dv 	&&& \\
+\end{flalign*}
+
+Note that this property strongly constrains the discrete expression of both 
+the depth of $T-$points and of the term added to the pressure gradient in the
+$s$-coordinate. Nevertheless, it is almost never satisfied since a linear equation 
+of state is rarely used.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Surface Pressure Gradient Term
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Surface Pressure Gradient Term}
+\label{Apdx_C.1.5}
+
+
+The surface pressure gradient has no contribution to the evolution of the vorticity. 
+This property is trivially satisfied locally since the equation verified by $\psi$ has 
+been derived from the discrete formulation of the momentum equation and of the curl. 
+But it has to be noted that since the elliptic equation satisfied by $\psi$ is solved 
+numerically by an iterative solver (preconditioned conjugate gradient or successive 
+over relaxation), the property is only satisfied at the precision requested for the 
+solver used.
+
+With the rigid-lid approximation, the change of KE due to the work of surface 
+pressure forces is exactly zero. This is satisfied in discrete form, at the precision 
+requested for the elliptic solver used to solve this equation. This can be 
+demonstrated as follows:
+\begin{flalign*}
+\int\limits_D  - \frac{1} {\rho_o} \nabla_h \left( p_s \right) \cdot \textbf{U}_h \;dv%	&&& \\
+%
+&\equiv \sum\limits_{i,j,k}   \biggl\{ 	\;
+	 \left(  - M_u - \frac{1} {H_u \,e_{2u}}  \delta_j 	\left[ \partial_t \psi  \right]   \right)\;
+	 u\;e_{1u}\,e_{2u}\,e_{3u}  
+&&&\\&  \qquad \;\;\,
+      + \left(  - M_v + \frac{1} {H_v \,e_{1v}}  \delta_i \left[ \partial_t \psi \right]     \right)\;
+	  v\;e_{1v}\,e_{2v}\,e_{3v} 	\; \biggr\}      
+&&&\\
+\\
+%
+&\equiv \sum\limits_{i,j}  \Biggl\{   \;
+	\biggl( - M_u - \frac{1} {H_u \,e_{2u}}  \delta_j \left[ \partial_t \psi  \right]   \biggr)
+	\biggl( \sum\limits_k  u\;e_{3u}   \biggr)\;  e_{1u}\,e_{2u} 
+&&&\\&  \qquad \;\;\,
+	+ \biggl( - M_v + \frac{1} {H_v \,e_{1v}}  \delta_i \left[ \partial_t \psi  \right]   \biggr)
+	   \biggl(   \sum\limits_k   v\;e_{3v}   \biggr)\;   e_{1v}\,e_{2v} \;   \Biggr\} 
+	&& \\ 
+%
+\intertext{using the relation between \textit{$\psi $} and the vertical sum of the velocity, it becomes:}
+%
+&\equiv \sum\limits_{i,j} 
+	\biggl\{  \;	
+		\left( \;\;\,
+		M_u + \frac{1} {H_u \,e_{2u}}  \delta_j \left[ \partial_t \psi \right] 
+		\right)\;
+		e_{1u} \,\delta_j 
+			\left[ \partial_t \psi  \right] 
+	&& \\ &  \qquad \;\;\,
+		+ \left( 
+		- M_v + \frac{1} {H_v \,e_{1v}}  \delta_i \left[ \partial_t \psi \right] 
+		\right)\;
+		e_{2v} \,\delta_i \left[ \partial_t \psi \right] 	\;
+	\biggr\} 
+	&& \\ 
+%
+\intertext{applying the adjoint of the $\delta$ operator, it is now:}
+%
+&\equiv \sum\limits_{i,j}  - \partial_t \psi \;
+	\biggl\{ 	\;
+	  \delta_{j+1/2} \left[ e_{1u} M_u \right] 
+	  - \delta_{i+1/2} \left[ e_{1v} M_v \right] 
+	&& \\ &  \qquad \;\;\,
+	+ \delta_{i+1/2} 
+		\left[ \frac{e_{2v}} {H_v \,e_{2v}}  \delta_i \left[ \partial_t \psi \right] 
+		\right] 
+	+ \delta_{j+1/2} 
+	 	 \left[ \frac{e_{1u}} {H_u \,e_{2u}}  \delta_j \left[ \partial_t \psi \right] 
+		 \right]  
+	\biggr\}   &&&\\
+	&\equiv 0                   && \\ 
+\end{flalign*}
+
+The last equality is obtained using \eqref{Eq_dynspg_rl}, the discrete barotropic 
+streamfunction time evolution equation. By the way, this shows that 
+\eqref{Eq_dynspg_rl} is the only way to compute the streamfunction, 
+otherwise the surface pressure forces will do work. Nevertheless, since 
+the elliptic equation satisfied by $\psi $ is solved numerically by an iterative 
+solver, the property is only satisfied at the precision requested for the solver.
+
+% ================================================================
+% Conservation Properties on Tracers
+% ================================================================
+\section{Conservation Properties on Tracers}
+\label{Apdx_C.2}
+
+
+All the numerical schemes used in NEMO are written such that the tracer content 
+is conserved by the internal dynamics and physics (equations in flux form). 
+For advection, only the CEN2 scheme ($i.e.$ $2^{nd}$ order finite different scheme) 
+conserves the global variance of tracer. Nevertheless the other schemes ensure 
+that the global variance decreases ($i.e.$ they are at least slightly diffusive). 
+For diffusion, all the schemes ensure the decrease of the total tracer variance, 
+except the iso-neutral operator. There is generally no strict conservation of mass, 
+as the equation of state is non linear with respect to $T$ and $S$. In practice, 
+the mass is conserved to a very high accuracy. 
+% -------------------------------------------------------------------------------------------------------------
+%       Advection Term
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Advection Term}
+\label{Apdx_C.2.1}
+
+Whatever the advection scheme considered it conserves of the tracer content as all 
+the scheme are written in flux form. Let $\tau$ be the tracer interpolated at velocity point 
+(whatever the interpolation is). The conservation of the tracer content is obtained as follows: 
+\begin{flalign*}
+&\int_D \nabla \cdot \left( T \textbf{U} \right)\;dv    &&&\\
+&\equiv  \sum\limits_{i,j,k}    \biggl\{
+	 \frac{1} {e_{1T}\,e_{2T}\,e_{3T}} 
+	 \left(  \delta_i    \left[   e_{2u}\,e_{3u}\; u \;\tau_u   \right]
+	        + \delta_j    \left[   e_{1v}\,e_{3v}\; v  \;\tau_v   \right] \right) 
+&&&\\& \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
+	+ \frac{1} {e_{3T}} \delta_k \left[ w\;\tau \right]    \biggl\}  e_{1T}\,e_{2T}\,e_{3T} &&&\\
+%
+&\equiv  \sum\limits_{i,j,k}     \left\{
+	   \delta_i  \left[ e_{2u}\,e_{3u}  \,\overline T^{\,i+1/2}\,u \right]
+       	+ \delta_j  \left[ e_{1v}\,e_{3v}  \,\overline T^{\,j+1/2}\,v \right] 
+ 	+ \delta_k \left[ e_{1T}\,e_{2T} \,\overline T^{\,k+1/2}\,w \right] \right\} 
+ 	 && \\
+&\equiv 0 &&&
+\end{flalign*}
+
+The conservation of the variance of tracer can be achieved only with the CEN2 scheme. 
+It can be demonstarted as follows:
+\begin{flalign*}
+&\int\limits_D T\;\nabla \cdot \left( T\; \textbf{U} \right)\;dv &&&\\
+\equiv& \sum\limits_{i,j,k} T\;
+	\left\{
+	   \delta_i  \left[ e_{2u}\,e_{3u} \overline T^{\,i+1/2}\,u \right]
+	+ \delta_j  \left[ e_{1v}\,e_{3v} \overline T^{\,j+1/2}\,v \right]
+	+ \delta_k \left[ e_{1T}\,e_{2T} \overline T^{\,k+1/2}w \right]
+	\right\} 
+	&& \\
+\equiv& \sum\limits_{i,j,k} 
+	\left\{
+	-           e_{2u}\,e_{3u} \overline T^{\,i+1/2}\,u\,\delta_{i+1/2}  \left[ T \right] \right.
+	-           e_{1v}\,e_{3v}  \overline T^{\,j+1/2}\,v\;\delta_{j+1/2}  \left[ T \right]
+&&&\\& \qquad \qquad \qquad \qquad \qquad \qquad \quad \;
+	- \left. e_{1T}\,e_{2T} \overline T^{\,k+1/2}w\;\delta_{k+1/2} \left[ T \right]
+	\right\} 
+	&&\\
+\equiv&  -\frac{1} {2}  \sum\limits_{i,j,k}
+	\Bigl\{
+	   e_{2u}\,e_{3u} \;  u\;\delta_{i+1/2} \left[ T^2 \right]
+	+ e_{1v}\,e_{3v} \;  v\;\delta_{j+1/2}  \left[ T^2 \right]
+	+ e_{1T}\,e_{2T} \;w\;\delta_{k+1/2} \left[ T^2 \right]
+	\Bigr\} 
+	&& \\ 
+\equiv& \frac{1} {2}  \sum\limits_{i,j,k} T^2
+	\Bigl\{
+	   \delta_i  \left[ e_{2u}\,e_{3u}\,u \right]
+	+ \delta_j  \left[ e_{1v}\,e_{3v}\,v \right]
+	+ \delta_k \left[ e_{1T}\,e_{2T}\,w \right]
+	\Bigr\} 
+\quad \equiv 0 &&&
+\end{flalign*}
+
+
+% ================================================================
+% Conservation Properties on Lateral Momentum Physics
+% ================================================================
+\section{Conservation Properties on Lateral Momentum Physics}
+\label{Apdx_dynldf_properties}
+
+
+The discrete formulation of the horizontal diffusion of momentum ensures the 
+conservation of potential vorticity and the horizontal divergence, and the 
+dissipation of the square of these quantities (i.e. enstrophy and the 
+variance of the horizontal divergence) as well as the dissipation of the 
+horizontal kinetic energy. In particular, when the eddy coefficients are 
+horizontally uniform, it ensures a complete separation of vorticity and 
+horizontal divergence fields, so that diffusion (dissipation) of vorticity 
+(enstrophy) does not generate horizontal divergence (variance of the 
+horizontal divergence) and \textit{vice versa}. 
+
+These properties of the horizontal diffusion operator are a direct consequence 
+of properties \eqref{Eq_DOM_curl_grad} and \eqref{Eq_DOM_div_curl}. 
+When the vertical curl of the horizontal diffusion of momentum (discrete sense) 
+is taken, the term associated with the horizontal gradient of the divergence is 
+locally zero. 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation of Potential Vorticity
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Conservation of Potential Vorticity}
+\label{Apdx_C.3.1}
+
+The lateral momentum diffusion term conserves the potential vorticity :
+\begin{flalign*}
+&\int \limits_D \frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
+	\Bigl[ \nabla_h 
+		\left( A^{\,lm}\;\chi  \right)
+	- \nabla_h \times
+		\left( A^{\,lm}\;\zeta \; \textbf{k} \right)
+	\Bigr]\;dv  = 0
+\end{flalign*}
+%%%%%%%%%%  recheck here....  (gm)
+\begin{flalign*}
+= \int \limits_D  -\frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
+	\Bigl[ \nabla_h \times 
+		\left( A^{\,lm}\;\zeta \; \textbf{k} \right) 
+	\Bigr]\;dv &&& \\ 
+\end{flalign*}
+\begin{flalign*}
+\equiv& \sum\limits_{i,j}
+	\left\{
+	\delta_{i+1/2} 
+	\left[ 
+	\frac {e_{2v}} {e_{1v}\,e_{3v}}  \delta_i
+		\left[ A_f^{\,lm} e_{3f} \zeta  \right]
+	 \right]
+ 	+ \delta_{j+1/2} 
+	\left[ 
+	\frac {e_{1u}} {e_{2u}\,e_{3u}} \delta_j 
+		\left[ A_f^{\,lm} e_{3f} \zeta  \right]
+	\right]
+	\right\} 
+	&& \\ 
+%
+\intertext{Using \eqref{DOM_di_adj}, it follows:}
+%
+\equiv& \sum\limits_{i,j,k} 
+	-\,\left\{
+	   \frac{e_{2v}} {e_{1v}\,e_{3v}}  \delta_i
+		\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_i \left[ 1\right]
+	+ \frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j 
+		\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_j \left[ 1\right]
+	\right\} \quad \equiv 0 
+	&& \\ 
+\end{flalign*}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Dissipation of Horizontal Kinetic Energy
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Dissipation of Horizontal Kinetic Energy}
+\label{Apdx_C.3.2}
+
+
+The lateral momentum diffusion term dissipates the horizontal kinetic energy:
+%\begin{flalign*}
+\begin{equation*}
+\begin{split}
+\int_D \textbf{U}_h \cdot 
+	\left[ \nabla_h 		\right.   &     \left.       \left( A^{\,lm}\;\chi \right)      
+	- \nabla_h \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)     \right] \; dv    \\
+\\  %%%
+\equiv& \sum\limits_{i,j,k} 
+	\left\{
+	  \frac{1} {e_{1u}}               \delta_{i+1/2} \left[  A_T^{\,lm}          \chi     \right]
+	- \frac{1} {e_{2u}\,e_{3u}}  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta   \right]
+	\right\} \; e_{1u}\,e_{2u}\,e_{3u} \;u     \\
+&\;\; + 	\left\{
+	   \frac{1} {e_{2u}}             \delta_{j+1/2}	\left[ A_T^{\,lm}          \chi    \right] 
+	+ \frac{1} {e_{1v}\,e_{3v}} \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right] 
+	\right\} \; e_{1v}\,e_{2u}\,e_{3v} \;v     \qquad \\ 
+\\  %%%
+\equiv& \sum\limits_{i,j,k} 
+ 	\Bigl\{
+	  e_{2u}\,e_{3u} \;u\;  \delta_{i+1/2} \left[ A_T^{\,lm}           \chi    \right]
+	- e_{1u}             \;u\;  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta  \right]
+	 \Bigl\} 
+	 \\ 
+&\;\; + \Bigl\{
+	   e_{1v}\,e_{3v} \;v\;  \delta_{j+1/2}  \left[ A_T^{\,lm}           \chi    \right]
+	+ e_{2v}             \;v\;  \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right]
+	\Bigl\}      \\ 
+\\  %%%
+\equiv& \sum\limits_{i,j,k} 
+	- \Bigl(
+	  \delta_i   \left[  e_{2u}\,e_{3u} \;u  \right]
+	+ \delta_j  \left[  e_{1v}\,e_{3v}  \;v  \right] 
+	     \Bigr) \;  A_T^{\,lm} \chi   \\ 
+&\;\; - \Bigl(
+	  \delta_{i+1/2}  \left[  e_{2v}  \;v  \right]
+	- \delta_{j+1/2}  \left[  e_{1u} \;u  \right] 
+	     \Bigr)\;  A_f^{\,lm} e_{3f} \zeta      \\ 
+\\  %%%
+\equiv& \sum\limits_{i,j,k} 
+	- A_T^{\,lm}  \,\chi^2   \;e_{1T}\,e_{2T}\,e_{3T}
+	- A_f ^{\,lm}  \,\zeta^2 \;e_{1f }\,e_{2f }\,e_{3f}  
+\quad \leq 0       \\
+\end{split}
+\end{equation*}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Dissipation of Enstrophy
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Dissipation of Enstrophy}
+\label{Apdx_C.3.3}
+
+
+The lateral momentum diffusion term dissipates the enstrophy when the eddy 
+coefficients are horizontally uniform:
+\begin{flalign*}
+&\int\limits_D  \zeta \; \textbf{k} \cdot \nabla \times 
+	\left[ 
+	  \nabla_h 
+		\left( A^{\,lm}\;\chi  \right)
+	-\nabla_h \times 
+		\left( A^{\,lm}\;\zeta \; \textbf{k} \right)
+	\right]\;dv &&&\\
+&= A^{\,lm} \int \limits_D \zeta \textbf{k} \cdot \nabla \times 
+ 	\left[ 
+	\nabla_h \times 
+		\left( \zeta \; \textbf{k} \right)
+	\right]\;dv &&&\displaybreak[0]\\
+&\equiv A^{\,lm} \sum\limits_{i,j,k}  \zeta \;e_{3f} 
+	\left\{
+	  \delta_{i+1/2} 
+	\left[ 
+	\frac{e_{2v}} {e_{1v}\,e_{3v}} \delta_i 
+		\left[ e_{3f} \zeta  \right]
+	\right]
+	+ \delta_{j+1/2} 
+	\left[
+	\frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j 
+		\left[ e_{3f} \zeta  \right]
+	\right]
+	\right\} 
+	&&&\\ 
+%
+\intertext{Using \eqref{DOM_di_adj}, it follows:}
+%
+&\equiv  - A^{\,lm} \sum\limits_{i,j,k} 
+	\left\{
+	  \left( 
+	  \frac{1} {e_{1v}\,e_{3v}}  \delta_i 
+		\left[ e_{3f} \zeta  \right] 
+	  \right)^2   e_{1v}\,e_{2v}\,e_{3v}
+	+ \left(
+	  \frac{1} {e_{2u}\,e_{3u}}  \delta_j 
+	  	\left[ e_{3f} \zeta  \right]
+	  \right)^2   e_{1u}\,e_{2u}\,e_{3u}
+	  \right\}      &&&\\
+& \leq \;0       &&&\\ 
+\end{flalign*}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation of Horizontal Divergence
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Conservation of Horizontal Divergence}
+\label{Apdx_C.3.4}
+
+When the horizontal divergence of the horizontal diffusion of momentum 
+(discrete sense) is taken, the term associated with the vertical curl of the 
+vorticity is zero locally, due to (!!! II.1.8  !!!!!). The resulting term conserves the 
+$\chi$ and dissipates $\chi^2$ when the eddy coefficients are 
+horizontally uniform.
+\begin{flalign*}
+& \int\limits_D  \nabla_h \cdot 
+	\Bigl[ 
+	  \nabla_h 
+		\left( A^{\,lm}\;\chi \right)
+	- \nabla_h \times 
+		\left( A^{\,lm}\;\zeta \;\textbf{k} \right)
+	\Bigr]
+	dv
+= \int\limits_D  \nabla_h \cdot \nabla_h 
+	\left( A^{\,lm}\;\chi  \right)
+	dv 
+&&&\\
+&\equiv \sum\limits_{i,j,k} 
+	\left\{ 
+	  \delta_i
+		\left[ 
+		A_u^{\,lm} \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} 
+			\left[ \chi \right] 
+		\right]
+	+ \delta_j 
+		\left[ 
+		A_v^{\,lm} \frac{e_{1v}\,e_{3v}} {e_{2v}}  \delta_{j+1/2} 
+			\left[ \chi \right] 
+		\right] 
+	\right\}
+	&&&\\ 
+%
+\intertext{Using \eqref{DOM_di_adj}, it follows:}
+%
+&\equiv \sum\limits_{i,j,k} 
+	- \left\{
+	\frac{e_{2u}\,e_{3u}} {e_{1u}}  A_u^{\,lm} \delta_{i+1/2} 
+		\left[ \chi \right]
+	\delta_{i+1/2} 
+		\left[ 1 \right] 
+	+ \frac{e_{1v}\,e_{3v}} {e_{2v}}  A_v^{\,lm} \delta_{j+1/2} 
+		\left[ \chi \right]
+	\delta_{j+1/2} 
+		\left[ 1 \right]
+	\right\} \;
+	\equiv 0 
+	&&& \\ 
+\end{flalign*}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Dissipation of Horizontal Divergence Variance
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Dissipation of Horizontal Divergence Variance}
+\label{Apdx_C.3.5}
+
+\begin{flalign*}
+&\int\limits_D \chi \;\nabla_h \cdot 
+	\left[    \nabla_h              \left( A^{\,lm}\;\chi                    \right)
+	        - \nabla_h   \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \right]\;  dv
+ = A^{\,lm}   \int\limits_D \chi \;\nabla_h \cdot \nabla_h \left( \chi \right)\;  dv    &&&\\ 
+%
+&\equiv A^{\,lm}  \sum\limits_{i,j,k}  \frac{1} {e_{1T}\,e_{2T}\,e_{3T}}  \chi 
+	\left\{
+	   \delta_i  \left[   \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]   \right]
+	+ \delta_j  \left[   \frac{e_{1v}\,e_{3v}} {e_{2v}}   \delta_{j+1/2} \left[ \chi \right]   \right]
+	\right\} \;   e_{1T}\,e_{2T}\,e_{3T}    &&&\\ 
+%
+\intertext{Using \eqref{DOM_di_adj}, it turns out to be:}
+%
+&\equiv - A^{\,lm} \sum\limits_{i,j,k}
+	\left\{ 
+   \left(  \frac{1} {e_{1u}}  \delta_{i+1/2}  \left[ \chi \right]  \right)^2  e_{1u}\,e_{2u}\,e_{3u}
++ \left(  \frac{1} {e_{2v}}  \delta_{j+1/2}  \left[ \chi \right]  \right)^2  e_{1v}\,e_{2v}\,e_{3v}
+	\right\} \;    &&&\\
+&\leq 0              &&&\\
+\end{flalign*}
+
+% ================================================================
+% Conservation Properties on Vertical Momentum Physics
+% ================================================================
+\section{Conservation Properties on Vertical Momentum Physics}
+\label{Apdx_C_4}
+
+
+As for the lateral momentum physics, the continuous form of the vertical diffusion 
+of momentum satisfies several integral constraints. The first two are associated 
+with the conservation of momentum and the dissipation of horizontal kinetic energy:
+\begin{align*}
+ \int\limits_D  
+	 \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+ 	\left( 
+	\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}
+	\right)\;
+	dv \qquad \quad &= \vec{\textbf{0}}
+	\\
+%
+\intertext{and}
+%
+\int\limits_D 
+	\textbf{U}_h \cdot 
+	\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+	\left(
+	\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}
+	\right)\;
+	dv \quad &\leq 0
+	\\
+\end{align*}
+The first property is obvious. The second results from:
+
+\begin{flalign*}
+\int\limits_D 
+	\textbf{U}_h \cdot 
+	\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+	\left( 
+	\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+	\right)\;dv
+	&&&\\
+\end{flalign*}
+\begin{flalign*}
+&\equiv \sum\limits_{i,j,k} 
+	\left( 
+	  u\; \delta_k 
+		\left[ 
+		\frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} 
+			\left[ u \right] 
+		\right]\;
+		e_{1u}\,e_{2u} 
+	+ v\;\delta_k 
+		\left[
+		\frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} 
+			\left[ v \right] 
+		\right]\;
+		e_{1v}\,e_{2v} 
+	\right)
+	&&&\\ 
+%
+\intertext{since the horizontal scale factor does not depend on $k$, it follows:}
+%
+&\equiv - \sum\limits_{i,j,k} 
+	\left( 
+	   \frac{A_u^{\,vm}} {e_{3uw}}
+		\left( 
+		\delta_{k+1/2} 
+			\left[ u \right] 
+		\right)^2\;
+		e_{1u}\,e_{2u} 
+	+ \frac{A_v^{\,vm}} {e_{3vw}} 
+		\left( \delta_{k+1/2} 
+			\left[ v \right] 
+		\right)^2\;
+		e_{1v}\,e_{2v}
+	\right)
+	 \quad \leq 0
+	 &&&\\
+\end{flalign*}
+
+The vorticity is also conserved. Indeed:
+\begin{flalign*}
+\int \limits_D 
+	\frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
+		\left( 
+		\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+			\left( 
+			\frac{A^{\,vm}} {e_3}\; \frac{\partial \textbf{U}_h } {\partial k} 
+			\right)
+		\right)\;
+		dv
+		&&&\\ 
+\end{flalign*}
+\begin{flalign*}
+\equiv \sum\limits_{i,j,k}  \frac{1} {e_{3f}}\; \frac{1} {e_{1f}\,e_{2f}}
+	\bigg\{    \biggr.   \quad
+	\delta_{i+1/2} 
+		&\left(
+		\frac{e_{2v}} {e_{3v}} \delta_k 
+			\left[
+			\frac{1} {e_{3vw}} \delta_{k+1/2} 
+				\left[ v \right] 
+			\right]
+		\right)
+	 &&\\
+	\biggl. 
+	- \delta_{j+1/2} 
+		&\left(
+		\frac{e_{1u}} {e_{3u}} \delta_k 
+			\left[
+			\frac{1} {e_{3uw}}\delta_{k+1/2} 
+				\left[ u \right]
+			\right]
+		\right)
+	\biggr\} \;
+	e_{1f}\,e_{2f}\,e_{3f} \; \equiv 0
+	&& \\
+\end{flalign*}
+If the vertical diffusion coefficient is uniform over the whole domain, the 
+enstrophy is dissipated, $i.e.$
+\begin{flalign*}
+\int\limits_D \zeta \, \textbf{k} \cdot \nabla \times 
+	\left( 
+	\frac{1} {e_3}\; \frac{\partial } {\partial k}
+		\left( 
+		\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+		\right) 
+	\right)\;
+	dv = 0
+	&&&\\
+\end{flalign*}
+This property is only satisfied in $z$-coordinates:
+
+\begin{flalign*}
+\int\limits_D \zeta \, \textbf{k} \cdot \nabla \times 
+	\left( 
+	\frac{1} {e_3}\; \frac{\partial } {\partial k}
+		\left( 
+		\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+		\right)
+	\right)\;
+	dv
+	&&& \\ 
+\end{flalign*}
+\begin{flalign*}
+\equiv \sum\limits_{i,j,k} \zeta \;e_{3f} \;
+	\biggl\{ 	\biggr.	\quad
+	\delta_{i+1/2} 
+		&\left( 
+		   \frac{e_{2v}} {e_{3v}} \delta_k 
+			\left[ 
+			\frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} 
+				\left[ v \right] 
+			\right]
+		   \right)
+		   &&\\
+	- \delta_{j+1/2} 
+		&\biggl.
+		\left( 	
+		   \frac{e_{1u}} {e_{3u}} \delta_k 
+			\left[ 
+			\frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} 
+				\left[ u \right]
+			 \right] 
+		   \right) 
+	\biggr\} 
+	&&\\ 
+\end{flalign*}
+\begin{flalign*}
+\equiv \sum\limits_{i,j,k} \zeta \;e_{3f} 
+	\biggl\{		\biggr.	\quad
+	\frac{1} {e_{3v}} \delta_k 
+		&\left[ 
+		\frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} 
+			\left[ \delta_{i+1/2} 
+				\left[ e_{2v}\,v \right]
+			 \right]
+		\right]
+		&&\\ 
+ 	 \biggl. 
+	- \frac{1} {e_{3u}} \delta_k 
+		&\left[ 
+		\frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} 
+			\left[ \delta_{j+1/2} 
+				\left[ e_{1u}\,u \right]
+			 \right]
+		\right]
+	\biggr\} 
+	&&\\ 
+\end{flalign*}
+Using the fact that the vertical diffusion coefficients are uniform, and that in 
+$z$-coordinate, the vertical scale factors do not depend on $i$ and $j$ so 
+that: $e_{3f} =e_{3u} =e_{3v} =e_{3T} $ and $e_{3w} =e_{3uw} =e_{3vw} $, 
+it follows:
+\begin{flalign*}
+\equiv A^{\,vm} \sum\limits_{i,j,k} \zeta \;\delta_k 
+	\left[ 
+	\frac{1} {e_{3w}} \delta_{k+1/2} 
+		\Bigl[ 
+		\delta_{i+1/2} 
+			\left[ e_{2v}\,v \right]
+		- \delta_{j+1/ 2} 
+			\left[ e_{1u}\,u \right]
+		 \Bigr] 
+	\right] 
+	&&&\\
+\end{flalign*}
+\begin{flalign*}
+\equiv - A^{\,vm} \sum\limits_{i,j,k} \frac{1} {e_{3w}}
+	\left( 
+	\delta_{k+1/2} 
+		\left[ \zeta  \right]
+	 \right)^2 \;
+	 e_{1f}\,e_{2f} 
+	 \; \leq 0
+	 &&&\\
+\end{flalign*}
+Similarly, the horizontal divergence is obviously conserved:
+
+\begin{flalign*}
+\int\limits_D \nabla \cdot 
+	\left( 
+	\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+		\left( 
+		\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+		\right) 
+	\right)\;
+	dv = 0
+	&&&\\
+\end{flalign*}
+and the square of the horizontal divergence decreases ($i.e.$ the horizontal 
+divergence is dissipated) if the vertical diffusion coefficient is uniform over the 
+whole domain:
+
+\begin{flalign*}
+\int\limits_D \chi \;\nabla \cdot 
+	\left( 
+	\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+		\left( 
+		\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+		\right) 
+	\right)\;
+	dv = 0
+	&&&\\
+\end{flalign*}
+This property is only satisfied in the $z$-coordinate:
+\begin{flalign*}
+\int\limits_D \chi \;\nabla \cdot 
+	\left( 
+	\frac{1} {e_3 }\; \frac{\partial } {\partial k}
+		\left( 
+		\frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} 
+		\right) 
+	\right)\;
+	dv
+	&&&\\
+\end{flalign*}
+\begin{flalign*}
+\equiv \sum\limits_{i,j,k} \frac{\chi } {e_{1T}\,e_{2T}}
+	\biggl\{ 	\Biggr.	\quad
+	\delta_{i+1/2} 
+		&\left( 
+		   \frac{e_{2u}} {e_{3u}} \delta_k 
+		   	\left[ 
+			\frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} 
+				\left[ u \right] 
+			\right]
+		 \right)
+		 &&\\ 
+ 	\Biggl. 
+	+ \delta_{j+1/2} 
+		&\left( 
+		\frac{e_{1v}} {e_{3v}} \delta_k 
+			\left[ 
+			\frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} 
+				\left[ v \right]
+			 \right]
+		\right)
+	\Biggr\} \;
+	e_{1T}\,e_{2T}\,e_{3T} 
+	&&\\ 
+\end{flalign*}
+
+\begin{flalign*}
+\equiv A^{\,vm} \sum\limits_{i,j,k}  \chi \,
+	\biggl\{	\biggr.	\quad
+	\delta_{i+1/2}
+		&\left( 
+		   \delta_k 
+			\left[ 
+			\frac{1} {e_{3uw}} \delta_{k+1/2} 
+				\left[ e_{2u}\,u \right]
+			 \right]
+		   \right) 
+		   && \\ 
+	\biggl. 
+	+ \delta_{j+1/2} 
+		&\left( 
+		   \delta_k 
+			\left[ 
+			\frac{1} {e_{3vw}} \delta_{k+1/2} 
+				\left[ e_{1v}\,v \right]
+			 \right] 
+		   \right)
+	\biggr\} 
+	&& \\ 
+\end{flalign*}
+
+\begin{flalign*}
+\equiv -A^{\,vm} \sum\limits_{i,j,k} 
+\frac{\delta_{k+1/2} \left[ \chi \right]} {e_{3w}}\;
+	\biggl\{ 
+	\delta_{k+1/2} 
+		\Bigl[
+		   \delta_{i+1/2} 
+			\left[ e_{2u}\,u \right]
+		+ \delta_{j+1/2} 
+			\left[ e_{1v}\,v \right]
+		\Bigr]
+	\biggr\} 
+	&&&\\
+\end{flalign*}
+
+\begin{flalign*}
+\equiv -A^{\,vm} \sum\limits_{i,j,k}
+ \frac{1} {e_{3w}} 
+\delta_{k+1/2} 
+	\left[ \chi \right]\;
+\delta_{k+1/2} 
+	\left[ e_{1T}\,e_{2T} \;\chi \right]
+&&&\\
+\end{flalign*}
+
+\begin{flalign*}
+\equiv -A^{\,vm} \sum\limits_{i,j,k} 
+\frac{e_{1T}\,e_{2T}} {e_{3w}}\;
+	\left( 
+	\delta_{k+1/2} 
+		\left[ \chi \right]
+	\right)^2
+	\quad  \equiv 0
+&&&\\
+\end{flalign*}
+
+% ================================================================
+% Conservation Properties on Tracer Physics
+% ================================================================
+\section{Conservation Properties on Tracer Physics}
+\label{Apdx_C.5}
+
+The numerical schemes used for tracer subgridscale physics are written such 
+that the heat and salt contents are conserved (equations in flux form, second 
+order centered finite differences). Since a flux form is used to compute the 
+temperature and salinity, the quadratic form of these quantities (i.e. their variance) 
+globally tends to diminish. As for the advection term, there is generally no strict 
+conservation of mass, even if in practice the mass is conserved to a very high 
+accuracy. 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation of Tracers
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Conservation of Tracers}
+\label{Apdx_C.5.1}
+
+constraint of conservation of tracers:
+\begin{flalign*}
+&\int\limits_D  \nabla  \cdot \left( A\;\nabla T \right)\;dv  &&&\\ 
+\\
+&\equiv \sum\limits_{i,j,k} 
+	\biggl\{ 	\biggr.
+	\delta_i 
+		\left[ 
+		A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2} 
+			\left[ T \right]
+		\right]
+	+ \delta_j 
+		\left[ 
+		A_v^{\,lT} \frac{e_{1v}\,e_{3v}} {e_{2v}} \delta_{j+1/2} 
+			\left[ T \right] 
+		\right]
+	&&\\  & \qquad \qquad \qquad \qquad \qquad \qquad \quad \;\;\;
+	+ \delta_k 
+		\left[ 
+		A_w^{\,vT} \frac{e_{1T}\,e_{2T}} {e_{3T}} \delta_{k+1/2} 
+			\left[ T \right] 
+		\right]
+	\biggr\}   \quad  \equiv 0
+	&&\\ 
+\end{flalign*}
+
+In fact, this property simply results from the flux form of the operator. 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Dissipation of Tracer Variance
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Dissipation of Tracer Variance}
+\label{Apdx_C.5.2}
+
+constraint on the dissipation of tracer variance:
+\begin{flalign*}
+\int\limits_D T\;\nabla & \cdot \left( A\;\nabla T \right)\;dv	&&&\\ 
+&\equiv   \sum\limits_{i,j,k} \; T
+\biggl\{  \biggr.
+     \delta_i \left[ A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2} \left[T\right] \right]
+& + \delta_j \left[ A_v^{\,lT} \frac{e_{1v} \,e_{3v}} {e_{2v}} \delta_{j+1/2} \left[T\right] \right] 
+		\quad&& \\ 
+ \biggl. 
+&&+ \delta_k \left[A_w^{\,vT}\frac{e_{1T}\,e_{2T}} {e_{3T}}\delta_{k+1/2}\left[T\right]\right]
+\biggr\} && 
+\end{flalign*}
+\begin{flalign*}
+\equiv - \sum\limits_{i,j,k} 
+	\biggl\{ 	\biggr.	\quad
+	& A_u^{\,lT} 
+		\left( 
+		\frac{1} {e_{1u}} \delta_{i+1/2} 
+			\left[ T \right]
+		\right)^2
+		e_{1u}\,e_{2u}\,e_{3u}
+	&& \\
+	& + A_v^{\,lT} 
+		\left( 
+		\frac{1} {e_{2v}} \delta_{j+1/2} 
+			\left[ T \right] 
+		\right)^2
+		e_{1v}\,e_{2v}\,e_{3v}
+	&& \\ 
+ 	\biggl. 
+	& + A_w^{\,vT} 
+		\left( 
+		\frac{1} {e_{3w}} \delta_{k+1/2} 
+			\left[ T \right] 
+		\right)^2
+		e_{1w}\,e_{2w}\,e_{3w} 
+	\biggr\} 
+	\quad \leq 0 
+	&& \\ 
+\end{flalign*}
+
+
+%%%%  end of appendix in gm comment
+%}
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_D.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_D.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_D.tex	(revision 1844)
@@ -0,0 +1,159 @@
+% ================================================================
+% Appendix D Ñ Coding Rules
+% ================================================================
+\chapter{Coding Rules}
+\label{Apdx_D}
+\minitoc
+
+
+A "model life" is more than ten years. Its software, composed of a few 
+hundred modules, is used by many people who are scientists or students 
+and do not necessarily know every aspect of computing very well. 
+Moreover, a well thought-out program is easier to read and understand, 
+less difficult to modify, produces fewer bugs and is easier to maintain. 
+Therefore, it is essential that the model development follows some rules :
+
+- well planned and designed
+
+- well written
+
+- well documented (both on- and off-line)
+
+- maintainable
+
+- easily portable
+
+- flexible.
+
+To satisfy part of these aims, \NEMO is written with a coding standard which 
+is close to the ECMWF rules, named DOCTOR \citep{Gibson_TR86}. 
+These rules present some advantages like :
+
+- to provide a well presented program
+
+- to use rules for variable names which allow recognition of their type 
+(integer, real, parameter, local or shared variables, etc. ) so that debugging is 
+facilitated.
+
+% ================================================================
+% The program structure
+% ================================================================
+\section{The program structure}
+\label{Apdx_D_structure}
+
+Each program begins with a set of headline comments containing :
+
+- the program title
+
+- the purpose of the routine
+
+- the method and algorithms used
+
+- the detail of input and output interfaces
+
+- the external routines and functions used (if they exist)
+
+- references (if they exist)
+
+- the author name(s), the date of creation and any updates.
+
+- Each program is split into several well separated sections and 
+sub-sections with an underlined title and specific labelled statements.
+
+- A program has not more than 200 to 300 lines.
+
+% ================================================================
+% Coding conventions
+% ================================================================
+\section{Coding conventions}
+\label{Apdx_D_coding}
+
+- Use of the universal language \textsc{Fortran} 90, and try to avoid obsolescent
+features like statement functions, do not use GO TO and EQUIVALENCE statements.
+
+- A continuation line begins with the character {\$} indented by three spaces 
+compared to the previous line.
+
+- Always use a three spaces indentation in DO loop, CASE, or IF-ELSEIF-ELSE-ENDIF 
+statements.
+
+- use call to ctl\_stop routine instead of just a STOP.
+
+% ================================================================
+% Naming Conventions
+% ================================================================
+\section{Naming Conventions}
+\label{Apdx_D_naming}
+
+The purpose of the naming conventions is to use prefix letters to classify 
+model variables. These conventions allow the variable type to be easily known
+and rapidly identified:
+
+%--------------------------------------------------TABLE--------------------------------------------------
+\begin{table}[htbp]
+\begin{center}
+\begin{tabular}{|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|}
+\hline  Type \par / Status &   integer&   real&   logical &   character&   double \par precision&   complex \\  
+\hline
+public  \par or  \par module variable& 
+\textbf{m n} \par \textit{but not } \par \textbf{nn\_}& 
+\textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& 
+\textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_}& 
+\textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_}& 
+\textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_}& 
+\textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\
+\hline
+dummy \par argument& 
+\textbf{k} \par \textit{but not} \par \textbf{kf}& 
+\textbf{p} \par \textit{but not}  \par \textbf{pp pf}& 
+\textbf{ld}& 
+\textbf{cd}& 
+\textbf{dd}& 
+\textbf{yd} \\
+\hline
+local \par variable& 
+\textbf{i}& 
+\textbf{z}& 
+\textbf{ll}& 
+\textbf{cl}& 
+\textbf{cd}& 
+\textbf{yl} \\
+\hline
+loop \par control& 
+\textbf{j} \par \textit{but not } \par \textbf{jp}& 
+& 
+& 
+& 
+& 
+ \\
+\hline
+parameter& 
+\textbf{jp}& 
+\textbf{pp}& 
+\textbf{lp}& 
+\textbf{cp}& 
+\textbf{dp}& 
+\textbf{yp} \\
+\hline
+
+namelist&
+\textbf{nn\_}& 
+\textbf{rn\_}& 
+\textbf{ln\_}& 
+\textbf{cn\_}& 
+\textbf{dn\_}& 
+\\
+\hline
+CPP \par macro& 
+\textbf{kf}& 
+\textbf{sf} \par & 
+& 
+& 
+& 
+ \\
+\hline
+\end{tabular}
+\label{tab1}
+\end{center}
+\end{table}
+%--------------------------------------------------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_E.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_E.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Annex_E.tex	(revision 1844)
@@ -0,0 +1,227 @@
+% ================================================================
+% Appendix E : UBS scheme
+% ================================================================
+\chapter{UBS scheme}
+\label{AN_E}
+\minitoc
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        UBS scheme  
+% -------------------------------------------------------------------------------------------------------------
+\section{Upstream Biased Scheme (UBS) (\np{ln\_traadv\_ubs}=T)}
+\label{TRA_adv_ubs}
+
+The UBS advection scheme is an upstream biased third order scheme based on 
+an upstream-biased parabolic interpolation. It is also known as Cell Averaged 
+QUICK scheme (Quadratic Upstream Interpolation for Convective 
+Kinematics). For example, in the $i$-direction :
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\tau _u^{ubs} = \left\{	 \begin{aligned}
+  & \tau _u^{cen4} + \frac{1}{12} \,\tau"_i	   & \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
+  & \tau _u^{cen4} - \frac{1}{12} \,\tau"_{i+1} & \quad \text{if }\ u_{i+1/2}       <       0
+  						 \end{aligned}    \right.
+\end{equation}
+or equivalently, the advective flux is
+\begin{equation} \label{Eq_tra_adv_ubs2}
+U_{i+1/2} \ \tau _u^{ubs} 
+=U_{i+1/2} \ \overline{ T_i - \frac{1}{6}\,\tau"_i }^{\,i+1/2}
+- \frac{1}{2}\, |U|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+\end{equation}
+where $U_{i+1/2} = e_{1u}\,e_{3u}\,u_{i+1/2}$ and 
+$\tau "_i =\delta _i \left[ {\delta _{i+1/2} \left[ \tau \right]} \right]$. 
+By choosing this expression for $\tau "$ we consider a fourth order approximation 
+of $\partial_i^2$ with a constant i-grid spacing ($\Delta i=1$). 
+
+Alternative choice: introduce the scale factors:  
+$\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta _i \left[ \frac{e_{2u} e_{3u} }{e_{1u} }\delta _{i+1/2}[\tau] \right]$.
+
+
+This results in a dissipatively dominant (i.e. hyper-diffusive) truncation 
+error \citep{Sacha2005}. The overall performance of the 
+advection scheme is similar to that reported in \cite{Farrow1995}. 
+It is a relatively good compromise between accuracy and smoothness. It is 
+not a \emph{positive} scheme meaning false extrema are permitted but the 
+amplitude of such are significantly reduced over the centred second order 
+method. Nevertheless it is not recommended to apply it to a passive tracer 
+that requires positivity. 
+
+The intrinsic diffusion of UBS makes its use risky in the vertical direction 
+where the control of artificial diapycnal fluxes is of paramount importance. 
+It has therefore been preferred to evaluate the vertical flux using the TVD 
+scheme when \np{ln\_traadv\_ubs}=T.
+
+For stability reasons, in \eqref{Eq_tra_adv_ubs}, the first term which corresponds 
+to a second order centred scheme is evaluated using the \textit{now} velocity 
+(centred in time) while the second term which is the diffusive part of the scheme, 
+is evaluated using the \textit{before} velocity (forward in time. This is discussed 
+by \citet{Webb1998} in the context of the Quick advection scheme. UBS and QUICK 
+schemes only differ by one coefficient. Substituting 1/6 with 1/8 in 
+(\ref{Eq_tra_adv_ubs}) leads to the QUICK advection scheme \citep{Webb1998}. 
+This option is not available through a namelist parameter, since the 1/6 
+coefficient is hard coded. Nevertheless it is quite easy to make the 
+substitution in \mdl{traadv\_ubs} module and obtain a QUICK scheme
+
+NB 1: When a high vertical resolution $O(1m)$ is used, the model stability can 
+be controlled by vertical advection (not vertical diffusion which is usually 
+solved using an implicit scheme). Computer time can be saved by using a 
+time-splitting technique on vertical advection. This possibility have been 
+implemented and validated in ORCA05-L301. It is not currently offered in the 
+current reference version. 
+
+NB 2 : In a forthcoming release four options will be proposed for the 
+vertical component used in the UBS scheme. $\tau _w^{ubs}$ will be 
+evaluated using either \textit{(a)} a centred $2^{nd}$ order scheme , 
+or  \textit{(b)} a TVD scheme, or  \textit{(c)} an interpolation based on conservative 
+parabolic splines following \citet{Sacha2005} implementation of UBS in ROMS, 
+or  \textit{(d)} an UBS. The $3^{rd}$ case has dispersion properties similar to an 
+eight-order accurate conventional scheme.
+
+NB 3 : It is straight forward to rewrite \eqref{Eq_tra_adv_ubs} as follows:
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\tau _u^{ubs} = \left\{	 \begin{aligned}
+	& \tau _u^{cen4} + \frac{1}{12} \tau"_i		& \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
+	& \tau _u^{cen4} - \frac{1}{12} \tau"_{i+1}	& \quad \text{if }\ u_{i+1/2}       <       0
+  						 \end{aligned}    \right.
+\end{equation}
+or equivalently 
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\begin{split}
+e_{2u} e_{3u}\,u_{i+1/2} \ \tau _u^{ubs} 
+&= e_{2u} e_{3u}\,u_{i+1/2} \ \overline{ T - \frac{1}{6}\,\tau"_i }^{\,i+1/2} \\
+& - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+\end{split}
+\end{equation}
+\eqref{Eq_tra_adv_ubs2} has several advantages. First it clearly evidence that 
+the UBS scheme is based on the fourth order scheme to which is added an 
+upstream biased diffusive term. Second, this emphasises that the $4^{th}$ order 
+part have to be evaluated at \emph{now} time step, not only the $2^{th}$ order 
+part as stated above using \eqref{Eq_tra_adv_ubs}. Third, the diffusive term is 
+in fact a biharmonic operator with a eddy coefficient with is simply proportional 
+to the velocity.
+
+laplacian diffusion:
+\begin{equation} \label{Eq_tra_ldf_lap}
+\begin{split}
+D_T^{lT} =\frac{1}{e_{1T} \; e_{2T}\;  e_{3T} } &\left[ {\quad \delta _i 
+\left[ {A_u^{lT} \frac{e_{2u} e_{3u} }{e_{1u} }\;\delta _{i+1/2} 
+\left[ T \right]} \right]} \right.
+\\
+&\ \left. {+\; \delta _j \left[ 
+{A_v^{lT} \left( {\frac{e_{1v} e_{3v} }{e_{2v} }\;\delta _{j+1/2} \left[ T 
+\right]} \right)} \right]\quad } \right]
+\end{split}
+\end{equation}
+
+bilaplacian:
+\begin{equation} \label{Eq_tra_ldf_lap}
+\begin{split}
+D_T^{lT} =&-\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
+& \delta _i \left[  \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta _{i+1/2} 
+		  \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
+    \delta _i \left[ \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta _{i+1/2} 
+    		  [T] \right] \right] \right]
+\end{split}
+\end{equation}
+with ${A_u^{lT}}^2 = \frac{1}{12} {e_{1u}}^3\ |u|$, 
+$i.e.$ $A_u^{lT} = \frac{1}{\sqrt{12}} \,e_{1u}\ \sqrt{ e_{1u}\,|u|\,}$
+it comes :
+\begin{equation} \label{Eq_tra_ldf_lap}
+\begin{split}
+D_T^{lT} =&-\frac{1}{12}\,\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
+& \delta _i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta _{i+1/2} 
+		 \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}} 
+    \delta _i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta _{i+1/2} 
+    		[T] \right] \right] \right]
+\end{split}
+\end{equation}
+if the velocity is uniform ($i.e.$ $|u|=cst$) then the diffusive flux is
+\begin{equation} \label{Eq_tra_ldf_lap}
+\begin{split}
+F_u^{lT} = - \frac{1}{12}
+ e_{2u}\,e_{3u}\,|u| \;\sqrt{ e_{1u}}\,\delta _{i+1/2} 
+		 \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}} 
+    \delta _i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}}\:\delta _{i+1/2} 
+    		[T] \right] \right]
+\end{split}
+\end{equation}
+beurk....  reverte the logic: starting from the diffusive part of the advective flux it comes:
+
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\begin{split}
+F_u^{lT}
+&= - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+\end{split}
+\end{equation}
+if the velocity is uniform ($i.e.$ $|u|=cst$) and choosing $\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta _i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta _{i+1/2}[\tau] \right]$
+
+sol 1 coefficient at T-point ( add $e_{1u}$ and $e_{1T}$ on both side of first $\delta$):
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\begin{split}
+F_u^{lT}
+&= - \frac{1}{12} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{e_{1T}^3\,|u|}{e_{1T}e_{2T}\,e_{3T}}\,\delta _i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta _{i+1/2}[\tau] \right] \right]
+\end{split}
+\end{equation}
+which leads to ${A_T^{lT}}^2 = \frac{1}{12} {e_{1T}}^3\ \overline{|u|}^{\,i+1/2}$
+
+sol 2 coefficient at u-point: split $|u|$ into $\sqrt{|u|}$ and $e_{1T}$ into $\sqrt{e_{1u}}$
+\begin{equation} \label{Eq_tra_adv_ubs2}
+\begin{split}
+F_u^{lT}
+&= - \frac{1}{12} {e_{1u}}^1 \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{2T}\,e_{3T}}\,\delta _i \left[ \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u} }{e_{1u} } \delta _{i+1/2}[\tau] \right] \right] \\
+&= - \frac{1}{12} e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{1T}\,e_{2T}\,e_{3T}}\,\delta _i \left[ e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u} }{e_{1u}} \delta _{i+1/2}[\tau] \right] \right]
+\end{split}
+\end{equation}
+which leads to ${A_u^{lT}} = \frac{1}{12} {e_{1u}}^3\ |u|$
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        Leap-Frog energetic  
+% -------------------------------------------------------------------------------------------------------------
+\section{Leap-Frog energetic }
+\label{LF}
+
+We adopt the following semi-discrete notation for time derivative. Given the values of a variable $q$ at successive time step, the time derivation and averaging operators at the mid time step are:
+\begin{subequations} \label{dt_mt}
+\begin{align}
+ \delta _{t+\Delta t/2} [q]     &=  \  \ \,   q^{t+\Delta t}  - q^{t}		\\
+ \overline q^{\,t+\Delta t/2} &= \left\{ q^{t+\Delta t} + q^{t} \right\} \; / \; 2
+\end{align}
+\end{subequations}
+As for space operator, the adjoint of the derivation and averaging time operators are 
+$\delta_t^*=\delta_{t+\Delta t/2}$ and $\overline{\cdot}^{\,t\,*}= \overline{\cdot}^{\,t+\Delta/2}$
+, respectively. 
+
+The Leap-frog time stepping given by \eqref{Eq_DOM_nxt} can be defined as:
+\begin{equation} \label{LF}
+   \frac{\partial q}{\partial t} 
+   		\equiv \frac{1}{\Delta t} \overline{ \delta _{t+\Delta t/2}[q]}^{\,t} 
+		=         \frac{q^{t+\Delta t}-q^{t-\Delta t}}{2\Delta t}
+\end{equation} 
+Note that \eqref{LF} shows that the leapfrog time step is $\Delta t$, not $2\Delta t$ 
+as it can be found sometime in literature. 
+The leap-Frog time stepping is a second order centered scheme. As such it respects 
+the quadratic invariant in integral forms, $i.e.$ the following continuous property,
+\begin{equation} \label{Energy}
+\int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt} 
+	=\int_{t_0}^{t_1} {\frac{1}{2}\, \frac{\partial q^2}{\partial t} \;dt} 
+	=  \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right) ,
+\end{equation}
+is satisfied in discrete form. Indeed, 
+\begin{equation} \begin{split}
+\int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt} 
+	&\equiv \sum\limits_{0}^{N} 
+			{\frac{1}{\Delta t} q^t \ \overline{ \delta _{t+\Delta t/2}[q]}^{\,t} \ \Delta t} 
+	   \equiv \sum\limits_{0}^{N}  { q^t \ \overline{ \delta _{t+\Delta t/2}[q]}^{\,t} } \\
+	&\equiv \sum\limits_{0}^{N}  { \overline{q}^{\,t+\Delta/2}{ \delta _{t+\Delta t/2}[q]}}
+	   \equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta _{t+\Delta t/2}[q^2] }\\
+	&\equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta _{t+\Delta t/2}[q^2] }
+	   \equiv \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right)
+\end{split} \end{equation}
+NB here pb of boundary condition when applying the adjoin! In space, setting to 0 
+the quantity in land area is sufficient to get rid of the boundary condition 
+(equivalently of the boundary value of the integration by part). In time this boundary 
+condition is not physical and \textbf{add something here!!!}
+
+
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Conservation.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Conservation.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Conservation.tex	(revision 1844)
@@ -0,0 +1,334 @@
+
+% ================================================================
+% Invariant of the Equations
+% ================================================================
+\chapter{Invariants of the Primitive Equations}
+\label{Invariant}
+\minitoc
+
+The continuous equations of motion have many analytic properties. Many 
+quantities (total mass, energy, enstrophy, etc.) are strictly conserved in 
+the inviscid and unforced limit, while ocean physics conserve the total 
+quantities on which they act (momentum, temperature, salinity) but dissipate 
+their total variance (energy, enstrophy, etc.). Unfortunately, the finite 
+difference form of these equations is not guaranteed to retain all these 
+important properties. In constructing the finite differencing schemes, we 
+wish to ensure that certain integral constraints will be maintained. In 
+particular, it is desirable to construct the finite difference equations so 
+that horizontal kinetic energy and/or potential enstrophy of horizontally 
+non-divergent flow, and variance of temperature and salinity will be 
+conserved in the absence of dissipative effects and forcing. \citet{Arakawa1966} 
+has first pointed out the advantage of this approach. He showed that if 
+integral constraints on energy are maintained, the computation will be free 
+of the troublesome "non linear" instability originally pointed out by 
+\citet{Phillips1959}. A consistent formulation of the energetic properties is 
+also extremely important in carrying out long-term numerical simulations for 
+an oceanographic model. Such a formulation avoids systematic errors that 
+accumulate with time \citep{Bryan1997}.
+
+The general philosophy of OPA which has led to the discrete formulation 
+presented in {\S}II.2 and II.3 is to choose second order non-diffusive 
+scheme for advective terms for both dynamical and tracer equations. At this 
+level of complexity, the resulting schemes are dispersive schemes. 
+Therefore, they require the addition of a diffusive operator to be stable. 
+The alternative is to use diffusive schemes such as upstream or flux 
+corrected schemes. This last option was rejected because we prefer a 
+complete handling of the model diffusion, i.e. of the model physics rather 
+than letting the advective scheme produces its own implicit diffusion 
+without controlling the space and time structure of this implicit diffusion. 
+Note that in some very specific cases as passive tracer studies, the 
+positivity of the advective scheme is required. In that case, and in that 
+case only, the advective scheme used for passive tracer is a flux correction 
+scheme \citep{Marti1992, Levy1996, Levy1998}.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation Properties on Ocean Dynamics
+% -------------------------------------------------------------------------------------------------------------
+\section{Conservation Properties on Ocean Dynamics}
+\label{Invariant_dyn}
+
+The non linear term of the momentum equations has been split into a 
+vorticity term, a gradient of horizontal kinetic energy and a vertical 
+advection term. Three schemes are available for the former (see {\S}~II.2) 
+according to the CPP variable defined (default option\textbf{ 
+}or \textbf{key{\_}vorenergy } or \textbf{key{\_}vorcombined 
+} defined). They differ in their conservative 
+properties (energy or enstrophy conserving scheme). The two latter terms 
+preserve the total kinetic energy: the large scale kinetic energy is also 
+preserved in practice. The remaining non-diffusive terms of the momentum 
+equation (namely the hydrostatic and surface pressure gradient terms) also 
+preserve the total kinetic energy and have no effect on the vorticity of the 
+flow.
+
+\textbf{* relative, planetary and total vorticity term:}
+
+Let us define as either the relative, planetary and total potential 
+vorticity, i.e. , , and , respectively. The continuous formulation of the 
+vorticity term satisfies following integral constraints:
+\begin{equation} \label{Eq_vor_vorticity}
+\int_D {{\textbf {k}}\cdot \frac{1}{e_3 }\nabla \times \left( {\varsigma 
+\;{\rm {\bf k}}\times {\textbf {U}}_h } \right)\;dv} =0
+\end{equation}
+
+\begin{equation} \label{Eq_vor_enstrophy}
+if\quad \chi =0\quad \quad \int\limits_D {\varsigma \;{\textbf{k}}\cdot 
+\frac{1}{e_3 }\nabla \times \left( {\varsigma {\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} =-\int\limits_D {\frac{1}{2}\varsigma ^2\,\chi \;dv} 
+=0
+\end{equation}
+
+\begin{equation} \label{Eq_vor_energy}
+\int_D {{\textbf{U}}_h \times \left( {\varsigma \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} =0
+\end{equation}
+where $dv = e_1\, e_2\, e_3\, di\, dj\, dk$ is the volume element. 
+(II.4.1a) means that $\varsigma $ is conserved. (II.4.1b) is obtained by an 
+integration by part. It means that $\varsigma^2$ is conserved for a horizontally 
+non-divergent flow. 
+(II.4.1c) is even satisfied locally since the vorticity term is orthogonal 
+to the horizontal velocity. It means that the vorticity term has no 
+contribution to the evolution of the total kinetic energy. (II.4.1a) is 
+obviously always satisfied, but (II.4.1b) and (II.4.1c) cannot be satisfied 
+simultaneously with a second order scheme. Using the symmetry or 
+anti-symmetry properties of the operators (Eqs II.1.10 and 11), it can be 
+shown that the scheme (II.2.11) satisfies (II.4.1b) but not (II.4.1c), while 
+scheme (II.2.12) satisfies (II.4.1c) but not (II.4.1b) (see appendix C). 
+Note that the enstrophy conserving scheme on total vorticity has been chosen 
+as the standard discrete form of the vorticity term.
+
+\textbf{* Gradient of kinetic energy / vertical advection}
+
+In continuous formulation, the gradient of horizontal kinetic energy has no 
+contribution to the evolution of the vorticity as the curl of a gradient is 
+zero. This property is satisfied locally with the discrete form of both the 
+gradient and the curl operator we have made (property (II.1.9)~). Another 
+continuous property is that the change of horizontal kinetic energy due to 
+vertical advection is exactly balanced by the change of horizontal kinetic 
+energy due to the horizontal gradient of horizontal kinetic energy:
+
+\begin{equation} \label{Eq_keg_zad}
+\int_D {{\textbf{U}}_h \cdot \nabla _h \left( {1/2\;{\textbf{U}}_h ^2} \right)\;dv} =-\int_D {{\textbf{U}}_h \cdot \frac{w}{e_3 }\;\frac{\partial 
+{\textbf{U}}_h }{\partial k}\;dv}
+\end{equation}
+
+Using the discrete form given in {\S}II.2-a and the symmetry or 
+anti-symmetry properties of the mean and difference operators, \eqref{Eq_keg_zad} is 
+demonstrated in the Appendix C. The main point here is that satisfying 
+\eqref{Eq_keg_zad} links the choice of the discrete forms of the vertical advection 
+and of the horizontal gradient of horizontal kinetic energy. Choosing one 
+imposes the other. The discrete form of the vertical advection given in 
+{\S}II.2-a is a direct consequence of formulating the horizontal kinetic 
+energy as $1/2 \left( \overline{u^2}^i + \overline{v^2}^j \right) $ in the gradient term.
+
+\textbf{* hydrostatic pressure gradient term}
+
+In continuous formulation, a pressure gradient has no contribution to the 
+evolution of the vorticity as the curl of a gradient is zero. This 
+properties is satisfied locally with the choice of discretization we have 
+made (property (II.1.9)~). In addition, when the equation of state is linear 
+(i.e. when an advective-diffusive equation for density can be derived from 
+those of temperature and salinity) the change of horizontal kinetic energy 
+due to the work of pressure forces is balanced by the change of potential 
+energy due to buoyancy forces:
+
+\begin{equation} \label{Eq_hpg_pe}
+\int_D {-\frac{1}{\rho _o }\left. {\nabla p^h} \right|_z \cdot {\textbf {U}}_h \;dv} \;=\;\int_D {\nabla .\left( {\rho \,{\textbf{U}}} \right)\;g\;z\;\;dv}
+\end{equation}
+
+Using the discrete form given in {\S}~II.2-a and the symmetry or 
+anti-symmetry properties of the mean and difference operators, (II.4.3) is 
+demonstrated in the Appendix C. The main point here is that satisfying 
+(II.4.3) strongly constraints the discrete expression of the depth of 
+$T$-points and of the term added to the pressure gradient in $s-$coordinates: the 
+depth of a $T$-point, $z_T$, is defined as the sum the vertical scale 
+factors at $w$-points starting from the surface.
+
+\textbf{* surface pressure gradient term}
+
+In continuous formulation, the surface pressure gradient has no contribution 
+to the evolution of vorticity. This properties is trivially satisfied 
+locally as (II.2.3) (the equation verified by $\psi$ has been 
+derived from the discrete formulation of the momentum equations, vertical 
+sum and curl. Nevertheless, the $\psi$-equation is solved numerically by an 
+iterative solver (see {\S}~III.5), thus the property is only satisfied with 
+the accuracy required on the solver. In addition, with the rigid-lid 
+approximation, the change of horizontal kinetic energy due to the work of 
+surface pressure forces is exactly zero:
+\begin{equation} \label{Eq_spg}
+\int_D {-\frac{1}{\rho _o }\nabla _h } \left( {p_s } \right)\cdot {\textbf{U}}_h \;dv=0
+\end{equation}
+
+(II.4.4) is satisfied in discrete form only if the discrete barotropic 
+streamfunction time evolution equation is given by (II.2.3) (see appendix 
+C). This shows that (II.2.3) is the only way to compute the streamfunction, 
+otherwise there is no guarantee that the surface pressure force work 
+vanishes.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation Properties on Ocean Thermodynamics
+% -------------------------------------------------------------------------------------------------------------
+\section{Conservation Properties on Ocean Thermodynamics}
+\label{Invariant_tra}
+
+In continuous formulation, the advective terms of the tracer equations 
+conserve the tracer content and the quadratic form of the tracer, i.e.
+\begin{equation} \label{Eq_tra_tra2}
+\int_D {\nabla .\left( {T\;{\textbf{U}}} \right)\;dv} =0
+\;\text{and}
+\int_D {T\;\nabla .\left( {T\;{\textbf{U}}} \right)\;dv} =0
+\end{equation}
+
+The numerical scheme used ({\S}II.2-b) (equations in flux form, second order 
+centred finite differences) satisfies (II.4.5) (see appendix C). Note that 
+in both continuous and discrete formulations, there is generally no strict 
+conservation of mass, since the equation of state is non linear with respect 
+to $T$ and $S$. In practice, the mass is conserved with a very good accuracy. 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation Properties on Momentum Physics
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Conservation Properties on Momentum Physics}
+\label{Invariant_dyn_physics}
+
+\textbf{* lateral momentum diffusion term}
+
+The continuous formulation of the horizontal diffusion of momentum satisfies 
+the following integral constraints~:
+\begin{equation} \label{Eq_dynldf_dyn}
+\int\limits_D {\frac{1}{e_3 }{\rm {\bf k}}\cdot \nabla \times \left[ {\nabla 
+_h \left( {A^{lm}\;\chi } \right)-\nabla _h \times \left( {A^{lm}\;\zeta 
+\;{\rm {\bf k}}} \right)} \right]\;dv} =0
+\end{equation}
+
+\begin{equation} \label{Eq_dynldf_div}
+\int\limits_D {\nabla _h \cdot \left[ {\nabla _h \left( {A^{lm}\;\chi } 
+\right)-\nabla _h \times \left( {A^{lm}\;\zeta \;{\rm {\bf k}}} \right)} 
+\right]\;dv} =0
+\end{equation}
+
+\begin{equation} \label{Eq_dynldf_curl}
+\int_D {{\rm {\bf U}}_h \cdot \left[ {\nabla _h \left( {A^{lm}\;\chi } 
+\right)-\nabla _h \times \left( {A^{lm}\;\zeta \;{\rm {\bf k}}} \right)} 
+\right]\;dv} \leqslant 0
+\end{equation}
+
+\begin{equation} \label{Eq_dynldf_curl2}
+\mbox{if}\quad A^{lm}=cste\quad \quad \int_D {\zeta \;{\rm {\bf k}}\cdot 
+\nabla \times \left[ {\nabla _h \left( {A^{lm}\;\chi } \right)-\nabla _h 
+\times \left( {A^{lm}\;\zeta \;{\rm {\bf k}}} \right)} \right]\;dv} 
+\leqslant 0
+\end{equation}
+
+\begin{equation} \label{Eq_dynldf_div2}
+\mbox{if}\quad A^{lm}=cste\quad \quad \int_D {\chi \;\nabla _h \cdot \left[ 
+{\nabla _h \left( {A^{lm}\;\chi } \right)-\nabla _h \times \left( 
+{A^{lm}\;\zeta \;{\rm {\bf k}}} \right)} \right]\;dv} \leqslant 0
+\end{equation}
+
+
+(II.4.6a) and (II.4.6b) means that the horizontal diffusion of momentum 
+conserve both the potential vorticity and the divergence of the flow, while 
+Eqs (II.4.6c) to (II.4.6e) mean that it dissipates the energy, the enstrophy 
+and the square of the divergence. The two latter properties are only 
+satisfied when the eddy coefficients are horizontally uniform.
+
+Using (II.1.8) and (II.1.9), and the symmetry or anti-symmetry properties of 
+the mean and difference operators, it is shown that the discrete form of the 
+lateral momentum diffusion given in {\S}II.2-c satisfies all the integral 
+constraints (II.4.6) (see appendix C). In particular, when the eddy 
+coefficients are horizontally uniform, a complete separation of vorticity 
+and horizontal divergence fields is ensured, so that diffusion (dissipation) 
+of vorticity (enstrophy) does not generate horizontal divergence (variance 
+of the horizontal divergence) and \textit{vice versa}. When the vertical curl of the horizontal 
+diffusion of momentum (discrete sense) is taken, the term associated to the 
+horizontal gradient of the divergence is zero locally. When the horizontal 
+divergence of the horizontal diffusion of momentum (discrete sense) is 
+taken, the term associated to the vertical curl of the vorticity is zero 
+locally. The resulting term conserves $\chi$ and dissipates 
+$\chi^2$ when the 
+eddy coefficient is horizontally uniform.
+
+\textbf{* vertical momentum diffusion term}
+
+As for the lateral momentum physics, the continuous form of the vertical 
+diffusion of momentum satisfies following integral constraints~:
+
+conservation of momentum, dissipation of horizontal kinetic energy
+
+\begin{equation} \label{Eq_dynzdf_dyn}
+\begin{aligned}
+& \int_D {\frac{1}{e_3 }}  \frac{\partial }{\partial k}\left( \frac{A^{vm}}{e_3 }\frac{\partial {\textbf{U}}_h }{\partial k} \right) \;dv = \overrightarrow{\textbf{0}} \\ 
+& \int_D \textbf{U}_h \cdot \frac{1}{e_3} \frac{\partial}{\partial k} \left( {\frac{A^{vm}}{e_3 }}{\frac{\partial \textbf{U}_h }{\partial k}} \right) \;dv \leq 0 \\ 
+ \end{aligned} 
+ \end{equation}
+conservation of vorticity, dissipation of enstrophy
+\begin{equation} \label{Eq_dynzdf_vor}
+\begin{aligned}
+& \int_D {\frac{1}{e_3 }{\rm {\bf k}}\cdot \nabla \times \left( {\frac{1}{e_3 
+}\frac{\partial }{\partial k}\left( {\frac{A^{vm}}{e_3 }\frac{\partial {\rm 
+{\bf U}}_h }{\partial k}} \right)} \right)\;dv} =0 \\ 
+& \int_D {\zeta \,{\rm {\bf k}}\cdot \nabla \times \left( {\frac{1}{e_3 
+}\frac{\partial }{\partial k}\left( {\frac{A^{vm}}{e_3 }\frac{\partial {\rm 
+{\bf U}}_h }{\partial k}} \right)} \right)\;dv} \leq 0 \\ 
+\end{aligned}
+\end{equation}
+conservation of horizontal divergence, dissipation of square of the 
+horizontal divergence
+\begin{equation} \label{Eq_dynzdf_div}
+\begin{aligned}
+ &\int_D {\nabla \cdot \left( {\frac{1}{e_3 }\frac{\partial }{\partial 
+k}\left( {\frac{A^{vm}}{e_3 }\frac{\partial {\rm {\bf U}}_h }{\partial k}} 
+\right)} \right)\;dv} =0 \\ 
+& \int_D {\chi \;\nabla \cdot \left( {\frac{1}{e_3 }\frac{\partial }{\partial 
+k}\left( {\frac{A^{vm}}{e_3 }\frac{\partial {\rm {\bf U}}_h }{\partial k}} 
+\right)} \right)\;dv} \leq 0 \\ 
+\end{aligned}
+\end{equation}
+
+In discrete form, all these properties are satisfied in $z$-coordinate (see 
+Appendix C). In $s$-coordinates, only first order properties can be 
+demonstrated, i.e. the vertical momentum physics conserve momentum, 
+potential vorticity, and horizontal divergence.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Conservation Properties on Tracer Physics
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Conservation Properties on Tracer Physics}
+\label{Invariant_tra_physics}
+
+The numerical schemes used for tracer subgridscale physics are written in 
+such a way that the heat and salt contents are conserved (equations in flux 
+form, second order centred finite differences). As a form flux is used to 
+compute the temperature and salinity, the quadratic form of these quantities 
+(i.e. their variance) globally tends to diminish. As for the advective term, 
+there is generally no strict conservation of mass even if, in practice, the 
+mass is conserved with a very good accuracy. 
+
+\textbf{* lateral physics: }conservation of tracer, dissipation of tracer 
+variance, i.e.
+
+\begin{equation} \label{Eq_traldf_t_t2}
+\begin{aligned}
+&\int_D \nabla\, \cdot\, \left( A^{lT} \,\Re \,\nabla \,T \right)\;dv = 0 \\ 
+&\int_D \,T\, \nabla\, \cdot\, \left( A^{lT} \,\Re \,\nabla \,T \right)\;dv \leq 0 \\ 
+\end{aligned}
+\end{equation}
+
+\textbf{* vertical physics: }conservation of tracer, dissipation of tracer 
+variance, i.e.
+
+\begin{equation} \label{Eq_trazdf_t_t2}
+\begin{aligned}
+& \int_D \frac{1}{e_3 } \frac{\partial }{\partial k}\left( \frac{A^{vT}}{e_3 }  \frac{\partial T}{\partial k}  \right)\;dv = 0 \\ 
+& \int_D \,T \frac{1}{e_3 } \frac{\partial }{\partial k}\left( \frac{A^{vT}}{e_3 }  \frac{\partial T}{\partial k}  \right)\;dv \leq 0 \\ 
+\end{aligned}
+\end{equation}
+
+Using the symmetry or anti-symmetry properties of the mean and difference 
+operators, it is shown that the discrete form of tracer physics given in 
+{\S}~II.2-c satisfies all the integral constraints (II.4.8) and (II.4.9) 
+except the dissipation of the square of the tracer when non-geopotential 
+diffusion is used (see appendix C). A discrete form of the lateral tracer 
+physics can be derived which satisfies these last properties. Nevertheless, 
+it requires a horizontal averaging of the vertical component of the lateral 
+physics that prevents the use of implicit resolution in the vertical. It has 
+not been implemented.
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DOM.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 1844)
@@ -0,0 +1,1110 @@
+
+% ================================================================
+% Chapter 2 Ñ Space and Time Domain (DOM)
+% ================================================================
+\chapter{Space and Time Domain (DOM) }
+\label{DOM}
+\minitoc
+
+% Missing things:
+% 	- istate: description of the initial state   ==> this has to be put elsewhere..
+%                  perhaps in MISC ?  By the way the initialisation of T S and dynamics 
+%                  should be put outside of DOM routine (better with TRC staff and off-line
+%                  tracers)
+%	- daymod: definition of the time domain (nit000, nitend andd the calendar)
+% 	-geo2ocean:  how to switch from geographic to mesh coordinate
+%  - domclo:  closed sea and lakes.... management of closea sea area : specific to global configuration, both forced and coupled
+
+\gmcomment{STEVEN :maybe a picture of the directory structure in the introduction 
+which could be referred to here, would help  ==> to be added}
+%%%%
+
+
+\newpage
+$\ $\newline    % force a new ligne
+
+
+Having defined the continuous equations in Chap.~\ref{PE}, we need to choose a 
+discretization on a grid, and numerical algorithms. In the present chapter, we 
+provide a general description of the staggered grid used in \NEMO, and other 
+information relevant to the main directory routines (time stepping, main program) 
+as well as the DOM (DOMain) directory. 
+
+% ================================================================
+% Fundamentals of the Discretisation
+% ================================================================
+\section{Fundamentals of the Discretisation}
+\label{DOM_basics}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Arrangement of Variables 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Arrangement of Variables}
+\label{DOM_cell}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_cell}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_cell.pdf}
+\caption{Arrangement of variables. $T$ indicates scalar points where temperature, 
+salinity, density, pressure and horizontal divergence are defined. ($u$,$v$,$w$) 
+indicates vector points, and $f$ indicates vorticity points where both relative and 
+planetary vorticities are defined}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The numerical techniques used to solve the Primitive Equations in this model are 
+based on the traditional, centred second-order finite difference approximation. 
+Special attention has been given to the homogeneity of the solution in the three 
+space directions. The arrangement of variables is the same in all directions. 
+It consists of cells centred on scalar points ($T$, $S$, $p$, $\rho$) with vector 
+points $(u, v, w)$ defined in the centre of each face of the cells (Fig. \ref{Fig_cell}). 
+This is the generalisation to three dimensions of the well-known ``C'' grid in 
+Arakawa's classification \citep{Mesinger_Arakawa_Bk76}. The relative and 
+planetary vorticity, $\zeta$ and $f$, are defined in the centre of each vertical edge 
+and the barotropic stream function $\psi$ is defined at horizontal points overlying 
+the $\zeta$ and $f$-points.
+
+The ocean mesh ($i.e.$ the position of all the scalar and vector points) is defined 
+by the transformation that gives ($\lambda$ ,$\varphi$ ,$z$) as a function of $(i,j,k)$. 
+The grid-points are located at integer or integer and a half value of $(i,j,k)$ as 
+indicated on Table \ref{Tab_cell}. In all the following, subscripts $u$, $v$, $w$, 
+$f$, $uw$, $vw$ or $fw$ indicate the position of the grid-point where the scale 
+factors are defined. Each scale factor is defined as the local analytical value 
+provided by \eqref{Eq_scale_factors}. As a result, the mesh on which partial 
+derivatives $\frac{\partial}{\partial \lambda}, \frac{\partial}{\partial \varphi}$, and 
+$\frac{\partial}{\partial z} $ are evaluated is a uniform mesh with a grid size of unity. 
+Discrete partial derivatives are formulated by the traditional, centred second order 
+finite difference approximation while the scale factors are chosen equal to their 
+local analytical value. An important point here is that the partial derivative of the 
+scale factors must be evaluated by centred finite difference approximation, not 
+from their analytical expression. This preserves the symmetry of the discrete set 
+of equations and therefore satisfies many of the continuous properties (see 
+Appendix~\ref{Apdx_C}). A similar, related remark can be made about the domain 
+size: when needed, an area, volume, or the total ocean depth must be evaluated 
+as the sum of the relevant scale factors (see \eqref{DOM_bar}) in the next section). 
+
+\begin{table}[!tb] \label{Tab_cell}
+\begin{center} \begin{tabular}{|p{46pt}|p{56pt}|p{56pt}|p{56pt}|}
+\hline
+T	&$i$ 		& $j$		& $k$		 \\ \hline
+u	& $i+1/2$	& $j$		& $k$	 	\\ \hline
+v	& $i$	 	& $j+1/2$	& $k$	 	\\ \hline
+w	& $i$	 	& $j$		& $k+1/2$ 	\\ \hline
+f	& $i+1/2$ 	& $j+1/2$	& $k$	 	\\ \hline
+uw	& $i+1/2$ 	& $j$		& $k+1/2$ 	\\ \hline
+vw	& $i$	 	& $j+1/2$	& $k+1/2$ 	\\ \hline
+fw	& $i+1/2$ 	& $j+1/2$	& $k+1/2$ 	\\ \hline
+\end{tabular}
+\caption{Location of grid-points as a function of integer or integer and a half value 
+of the column, line or level. This indexing is only used for the writing of the semi-
+discrete equation. In the code, the indexing uses integer values only and has a 
+reverse direction in the vertical (see \S\ref{DOM_Num_Index})}
+\end{center}
+\end{table}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Vector Invariant Formulation 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Discrete Operators}
+\label{DOM_operators}
+
+Given the values of a variable $q$ at adjacent points, the differencing and 
+averaging operators at the midpoint between them are:
+\begin{subequations} \label{Eq_di_mi}
+\begin{align}
+ \delta _i [q]       &=  \  \    q(i+1/2)  - q(i-1/2)		\\
+ \overline q^{\,i} &= \left\{ q(i+1/2) + q(i-1/2) \right\} \; / \; 2
+\end{align}
+\end{subequations}
+
+Similar operators are defined with respect to $i+1/2$, $j$, $j+1/2$, $k$, and 
+$k+1/2$. Following \eqref{Eq_PE_grad} and \eqref{Eq_PE_lap}, the gradient of a 
+variable $q$ defined at a $T$-point has its three components defined at $u$-, $v$- 
+and $w$-points while its Laplacien is defined at $T$-point. These operators have 
+the following discrete forms in the curvilinear $s$-coordinate system:
+\begin{equation} \label{Eq_DOM_grad}
+\nabla q\equiv 	\frac{1}{e_{1u} }\delta _{i+1/2} \left[ q \right]\;\,{\rm {\bf i}}
+			+	\frac{1}{e_{2v} }\delta _{j+1/2} \left[ q \right]\;\,{\rm {\bf j}}
+			+	\frac{1}{e_{3w} }\delta _{k+1/2} \left[ q \right]\;\,{\rm {\bf k}}
+\end{equation}
+\begin{multline} \label{Eq_DOM_lap}
+\Delta q\equiv \frac{1}{e_{1T} {\kern 1pt}e_{2T} {\kern 1pt}e_{3T} }\;\left( 
+{\delta _i \left[ {\frac{e_{2u} e_{3u} }{e_{1u} }\;\delta _{i+1/2} 
+\left[ q \right]} \right]
++\delta _j \left[ {\frac{e_{1v} e_{3v} }{e_{2v} 
+}\;\delta _{j+1/2} \left[ q \right]} \right]\;} \right)		\\
++\frac{1}{e_{3T} }\delta _k \left[ {\frac{1}{e_{3w} }\;\delta _{k+1/2} 
+\left[ q \right]} \right]
+\end{multline}
+
+Following \eqref{Eq_PE_curl} and \eqref{Eq_PE_div}, a vector ${\rm {\bf A}}=\left( a_1,a_2,a_3\right)$ defined at vector points $(u,v,w)$ has its three curl 
+components defined at $vw$-, $uw$, and $f$-points, and its divergence defined 
+at $T$-points:
+\begin{equation} \label{Eq_DOM_curl}
+\begin{split}
+ \nabla \times {\rm {\bf A}}\equiv \frac{1}{e_{2v} {\kern 1pt}e_{3vw} 
+}{\kern 1pt}\,\;\left( {\delta _{j+1/2} \left[ {e_{3w} a_3 } \right]-\delta 
+_{k+1/2} \left[ {e_{2v} a_2 } \right]} \right)	&\;\;{\rm {\bf i}} \\ 
+ +\frac{1}{e_{2u} {\kern 1pt}e_{3uw} }\;\left( {\delta _{k+1/2} \left[ {e_{1u} a_1 } 
+\right]-\delta _{i+1/2} \left[ {e_{3w} a_3 } \right]} \right) 	&\;\;{\rm{\bf j}} \\ 
+ +\frac{e_{3f} }{e_{1f} {\kern 1pt}e_{2f} }\,{\kern 1pt}\;\left( {\delta 
+_{i+1/2} \left[ {e_{2v} a_2 } \right]-\delta _{j+12} \left[ {e_{1u} a_1 } \right]} 
+\right)	&\;\;{\rm {\bf k}}
+ \end{split}
+\end{equation}
+\begin{equation} \label{Eq_DOM_div}
+\nabla \cdot {\rm {\bf A}}=\frac{1}{e_{1T} e_{2T} e_{3T} }\left( {\delta 
+_i \left[ {e_{2u} e_{3u} a_1 } \right]+\delta _j \left[ {e_{1v} e_{3v} a_2 } 
+\right]} \right)+\frac{1}{e_{3T} }\delta _k \left[ {a_3 } \right]
+\end{equation}
+
+In the special case of a pure $z$-coordinate system, \eqref{Eq_DOM_lap} and 
+\eqref{Eq_DOM_div} can be simplified. In this case, the vertical scale factor 
+becomes a function of the single variable $k$ and thus does not depend on the 
+horizontal location of a grid point. For example \eqref{Eq_DOM_div} reduces to: 
+\begin{equation*}
+\nabla \cdot {\rm {\bf A}}=\frac{1}{e_{1T} e_{2T} }\left( {\delta 
+_i \left[ {e_{2u} a_1 } \right]+\delta _j \left[ {e_{1v}  a_2 } 
+\right]} \right)+\frac{1}{e_{3T} }\delta _k \left[ {a_3 } \right]
+\end{equation*}
+
+The vertical average over the whole water column denoted by an overbar becomes 
+for a quantity $q$ which is a masked field (i.e. equal to zero inside solid area):
+\begin{equation} \label{DOM_bar}
+\bar q 	= \frac{1}{H}\int_{k^b}^{k^o} {q\;e_{3q} \,dk} 
+		\equiv \frac{1}{H_q }\sum\limits_k {q\;e_{3q} }
+\end{equation}
+where $H_q$  is the ocean depth, which is the masked sum of the vertical scale 
+factors at $q$ points, $k^b$ and $k^o$ are the bottom and surface $k$-indices, 
+and the symbol $k^o$ refers to a summation over all grid points of the same type 
+in the direction indicated by the subscript (here $k$). 
+
+In continuous form, the following properties are satisfied:
+\begin{equation} \label{Eq_DOM_curl_grad}
+\nabla \times \nabla q ={\rm {\bf {0}}}
+\end{equation}
+\begin{equation} \label{Eq_DOM_div_curl}
+\nabla \cdot \left( {\nabla \times {\rm {\bf A}}} \right)=0
+\end{equation}
+
+It is straightforward to demonstrate that these properties are verified locally in 
+discrete form as soon as the scalar $q$ is taken at $T$-points and the vector 
+\textbf{A} has its components defined at vector points $(u,v,w)$.
+
+Let $a$ and $b$ be two fields defined on the mesh, with value zero inside 
+continental area. Using integration by parts it can be shown that the differencing 
+operators ($\delta_i$, $\delta_j$ and $\delta_k$) are anti-symmetric linear 
+operators, and further that the averaging operators $\overline{\,\cdot\,}^{\,i}$, 
+$\overline{\,\cdot\,}^{\,k}$ and $\overline{\,\cdot\,}^{\,k}$) are symmetric linear 
+operators, $i.e.$
+\begin{align} 
+\label{DOM_di_adj}
+\sum\limits_i { a_i \;\delta _i \left[ b \right]} 
+	&\equiv -\sum\limits_i {\delta _{i+1/2} \left[ a \right]\;b_{i+1/2} }      \\
+\label{DOM_mi_adj}
+\sum\limits_i { a_i \;\overline b^{\,i}} 
+	& \equiv \quad \sum\limits_i {\overline a ^{\,i+1/2}\;b_{i+1/2} } 
+\end{align}
+
+In other words, the adjoint of the differencing and averaging operators are 
+$\delta_i^*=\delta_{i+1/2}$ and 
+${(\overline{\,\cdot \,}^{\,i})}^*= \overline{\,\cdot\,}^{\,i+1/2}$, respectively. 
+These two properties will be used extensively in the Appendix~\ref{Apdx_C} to 
+demonstrate integral conservative properties of the discrete formulation chosen.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Numerical Indexing 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Numerical Indexing}
+\label{DOM_Num_Index}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_index_hor}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_index_hor.pdf}
+\caption{Horizontal integer indexing used in the \textsc{Fortran} code. The dashed 
+area indicates the cell in which variables contained in arrays have the same 
+$i$- and $j$-indices}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The array representation used in the \textsc{Fortran} code requires an integer 
+indexing while the analytical definition of the mesh (see \S\ref{DOM_cell}) is 
+associated with the use of integer values for $T$-points and both integer and 
+integer and a half values for all the other points. Therefore a specific integer 
+indexing must be defined for points other than $T$-points ($i.e.$ velocity and 
+vorticity grid-points). Furthermore, the direction of the vertical indexing has 
+been changed so that the surface level is at $k=1$.
+
+% -----------------------------------
+%        Horizontal Indexing 
+% -----------------------------------
+\subsubsection{Horizontal Indexing}
+\label{DOM_Num_Index_hor}
+
+The indexing in the horizontal plane has been chosen as shown in Fig.\ref{Fig_index_hor}. For an increasing $i$ index ($j$ index), the $T$-point 
+and the eastward $u$-point (northward $v$-point) have the same index 
+(see the dashed area in Fig.\ref{Fig_index_hor}). A $T$-point and its 
+nearest northeast $f$-point have the same $i$-and $j$-indices.
+
+% -----------------------------------
+%        Vertical indexing 
+% -----------------------------------
+\subsubsection{Vertical Indexing}
+\label{DOM_Num_Index_vertical}
+
+In the vertical, the chosen indexing requires special attention since the 
+$k$-axis is re-orientated downward in the \textsc{Fortran} code compared 
+to the indexing used in the semi-discrete equations and given in \S\ref{DOM_cell}. 
+The sea surface corresponds to the $w$-level $k=1$ which is the same index 
+as $T$-level just below (Fig.\ref{Fig_index_vert}). The last $w$-level ($k=jpk$) 
+either corresponds to the ocean floor or is inside the bathymetry while the last 
+$T$-level is always inside the bathymetry (Fig.\ref{Fig_index_vert}). Note that 
+for an increasing $k$ index, a $w$-point and the $T$-point just below have the 
+same $k$ index, in opposition to what is done in the horizontal plane where 
+it is the $T$-point and the nearest velocity points in the direction of the horizontal 
+axis that have the same $i$ or $j$ index (compare the dashed area in 
+Fig.\ref{Fig_index_hor} and \ref{Fig_index_vert}). Since the scale factors are 
+chosen to be strictly positive, a \emph{minus sign} appears in the \textsc{Fortran} 
+code \emph{before all the vertical derivatives} of the discrete equations given in 
+this documentation.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!pt] \label{Fig_index_vert}  \begin{center}
+\includegraphics[width=.90\textwidth]{./TexFiles/Figures/Fig_index_vert.pdf}
+\caption{Vertical integer indexing used in the \textsc{Fortran } code. Note that 
+the $k$-axis is orientated downward. The dashed area indicates the cell in 
+which variables contained in arrays have the same $k$-index.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -----------------------------------
+%        Domain Size
+% -----------------------------------
+\subsubsection{Domain Size}
+\label{DOM_size}
+
+The total size of the computational domain is set by the parameters \jp{jpiglo}, 
+\jp{jpjglo} and \jp{jpk} in the $i$, $j$ and $k$ directions respectively. They are 
+given as parameters in the \mdl{par\_oce} module\footnote{When a specific 
+configuration is used (ORCA2 global ocean, etc...) the parameter are actually 
+defined in additional files introduced by \mdl{par\_oce} module via CPP 
+\textit{include} command. For example, ORCA2 parameters are set in 
+\textit{par\_ORCA\_R2.h90} file}. The use of parameters rather than variables 
+(together with dynamic allocation of arrays) was chosen because it ensured that 
+the compiler would optimize the executable code efficiently, especially on vector 
+machines (optimization may be less efficient when the problem size is unknown 
+at the time of compilation). Nevertheless, it is possible to set up the code with full 
+dynamical allocation by using the AGRIF packaged \citep{Debreu_al_CG2008}. 
+%
+\gmcomment{  add the following ref 
+\colorbox{yellow}{(ref part of the doc)} } 
+%
+Note that are other parameters in \mdl{par\_oce} that refer to the domain size. 
+The two parameters $jpidta$ and $jpjdta$ may be larger than $jpiglo$, $jpjglo$ 
+when the user wants to use only a sub-region of a given configuration. This is 
+the "zoom" capability described in \S\ref{MISC_zoom}. In most applications of 
+the model, $jpidta=jpiglo$, $jpjdta=jpjglo$, and $jpizoom=jpjzoom=1$. Parameters 
+$jpi$ and $jpj$ refer to the size of each processor subdomain when the code is 
+run in parallel using domain decomposition (\key{mpp\_mpi} defined, see 
+\S\ref{LBC_mpp}).
+
+% ================================================================
+% Domain: Horizontal Grid (mesh) 
+% ================================================================
+\section  [Domain: Horizontal Grid (mesh) (\textit{domhgr})]               
+		{Domain: Horizontal Grid (mesh) \small{(\mdl{domhgr} module)} }
+\label{DOM_hgr}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Coordinates and scale factors 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Coordinates and scale factors}
+\label{DOM_hgr_coord_e}
+
+The ocean mesh ($i.e.$ the position of all the scalar and vector points) is defined 
+by the transformation that gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$. 
+The grid-points are located at integer or integer and a half values of as indicated 
+in Table~\ref{Tab_cell}. The associated scale factors are defined using the 
+analytical first derivative of the transformation \eqref{Eq_scale_factors}. These 
+definitions are done in two modules, \mdl{domhgr} and \mdl{domzgr}, which 
+provide the horizontal and vertical meshes, respectively. This section deals with 
+the horizontal mesh parameters.
+
+In a horizontal plane, the location of all the model grid points is defined from the 
+analytical expressions of the longitude $\lambda$ and  latitude $\varphi$ as a 
+function of  $(i,j)$. The horizontal scale factors are calculated using 
+\eqref{Eq_scale_factors}. For example, when the longitude and latitude are 
+function of a single value ($i$ and $j$, respectively) (geographical configuration 
+of the mesh), the horizontal mesh definition reduces to define the wanted 
+$\lambda(i)$, $\varphi(j)$, and their derivatives $\lambda'(i)$ $\varphi'(j)$ in the 
+\mdl{domhgr} module. The model computes the grid-point positions and scale 
+factors in the horizontal plane as follows:
+\begin{flalign*}
+\lambda_T &\equiv \text{glamt}= \lambda(i)	  & \varphi_T &\equiv \text{gphit} = \varphi(j)\\
+\lambda_u &\equiv \text{glamu}= \lambda(i+1/2)& \varphi_u &\equiv \text{gphiu}= \varphi(j)\\
+\lambda_v &\equiv \text{glamv}= \lambda(i)       & \varphi_v &\equiv \text{gphiv} = \varphi(j+1/2)\\
+\lambda_f &\equiv \text{glamf }= \lambda(i+1/2)& \varphi_f &\equiv \text{gphif }= \varphi(j+1/2) 
+\end{flalign*}
+\begin{flalign*}
+e_{1T} &\equiv \text{e1t} = r_a |\lambda'(i)		\; \cos\varphi(j)  |&
+e_{2T} &\equiv \text{e2t} = r_a |\varphi'(j)|  \\
+e_{1u} &\equiv \text{e1t} = r_a |\lambda'(i+1/2)	\; \cos\varphi(j)  |&
+e_{2u} &\equiv \text{e2t} = r_a |\varphi'(j)|\\
+e_{1v} &\equiv \text{e1t} = r_a |\lambda'(i)		\; \cos\varphi(j+1/2)  |&
+e_{2v} &\equiv \text{e2t} = r_a |\varphi'(j+1/2)|\\
+e_{1f} &\equiv \text{e1t} = r_a |\lambda'(i+1/2)\; \cos\varphi(j+1/2)  |&
+e_{2f} &\equiv \text{e2t} = r_a |\varphi'(j+1/2)|
+\end{flalign*}
+where the last letter of each computational name indicates the grid point 
+considered and $r_a$ is the earth radius (defined in \mdl{phycst} along with 
+all universal constants). Note that the horizontal position of and scale factors 
+at $w$-points are exactly equal to those of $T$-points, thus no specific arrays 
+are defined at $w$-points. 
+
+Note that the definition of the scale factors ($i.e.$ as the analytical first derivative 
+of the transformation that gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$) is 
+specific to the \NEMO model \citep{Marti1992}. As an example, $e_{1T}$ is defined 
+locally at a $T$-point, whereas many other models on a C grid choose to define 
+such a scale factor as the distance between the $U$-points on each side of the 
+$T$-point. Relying on an analytical transformation has two advantages: firstly, there 
+is no ambiguity in the scale factors appearing in the discrete equations, since they 
+are first introduced in the continuous equations; secondly, analytical transformations 
+encourage good practice by the definition of smoothly varying grids (rather than 
+allowing the user to set arbitrary jumps in thickness between adjacent layers) 
+\citep{Treguier1996}. An example of the effect of such a choice is shown in 
+Fig.~\ref{Fig_zgr_e3}.
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_zgr_e3}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_zgr_e3.pdf}
+\caption{Comparison of (a) traditional definitions of grid-point position and grid-size 
+in the vertical, and (b) analytically derived grid-point position and scale factors. For 
+both grids here,  the same $w$-point depth has been chosen but in (a) the 
+$T$-points are set half way between $w$-points while in (b) they are defined from 
+an analytical function: $z(k)=5\,(i-1/2)^3 - 45\,(i-1/2)^2 + 140\,(i-1/2) - 150$. 
+Note the resulting difference between the value of the grid-size $\Delta_k$ and 
+those of the scale factor $e_k$. }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -------------------------------------------------------------------------------------------------------------
+%        Choice of horizontal grid
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Choice of horizontal grid}
+\label{DOM_hgr_msh_choice}
+
+The user has three options available in defining a horizontal grid, which involve 
+the parameter $jphgr\_mesh$ of the \mdl{par\_oce} module. 
+\begin{description}
+\item[\jp{jphgr\_mesh}=0]  The most general curvilinear orthogonal grids.
+The coordinates and their first derivatives with respect to $i$ and $j$ are 
+provided in a file, read in \rou{hgr\_read} subroutine of the domhgr module.
+\item[\jp{jphgr\_mesh}=1 to 5] A few simple analytical grids are provided (see below). 
+For other analytical grids, the \mdl{domhgr} module must be modified by the user. 
+\end{description}
+
+There are two simple cases of geographical grids on the sphere. With 
+\jp{jphgr\_mesh}=1, the grid (expressed in degrees) is regular in space, 
+with grid sizes specified by parameters \pp{ppe1\_deg} and \pp{ppe2\_deg}, 
+respectively. Such a geographical grid can be very anisotropic at high latitudes 
+because of the convergence of meridians (the zonal scale factors $e_1$ 
+become much smaller than the meridional scale factors $e_2$). The Mercator 
+grid (\jp{jphgr\_mesh}=4) avoids this anisotropy by refining the meridional scale 
+factors in the same way as the zonal ones. In this case, meridional scale factors 
+and latitudes are calculated analytically using the formulae appropriate for 
+a Mercator projection, based on \pp{ppe1\_deg} which is a reference grid spacing 
+at the equator (this applies even when the geographical equator is situated outside 
+the model domain). 
+%%%
+\gmcomment{ give here the analytical expression of the Mercator mesh}
+%%%
+In these two cases (\jp{jphgr\_mesh}=1 or 4), the grid position is defined by the 
+longitude and latitude of the south-westernmost point (\pp{ppglamt0} 
+and \pp{ppgphi0}). Note that for the Mercator grid the user need only provide 
+an approximate starting latitude: the real latitude will be recalculated analytically, 
+in order to ensure that the equator corresponds to line passing through $T$- 
+and $u$-points.  
+
+Rectangular grids ignoring the spherical geometry are defined with 
+\jp{jphgr\_mesh} = 2, 3, 5. The domain is either an $f$-plane (\jp{jphgr\_mesh} = 2, 
+Coriolis factor is constant) or a beta-plane (\jp{jphgr\_mesh} = 3, the Coriolis factor 
+is linear in the $j$-direction). The grid size is uniform in meter in each direction, 
+and given by the parameters \pp{ppe1\_m} and \pp{ppe2\_m} respectively. 
+The zonal grid coordinate (\textit{glam} arrays) is in kilometers, starting at zero 
+with the first $T$-point. The meridional coordinate (gphi. arrays) is in kilometers, 
+and the second $T$-point corresponds to coordinate $gphit=0$. The input 
+parameter \pp{ppglam0} is ignored. \pp{ppgphi0} is used to set the reference 
+latitude for computation of the Coriolis parameter. In the case of the beta plane, 
+\pp{ppgphi0} corresponds to the center of the domain. Finally, the special case 
+\jp{jphgr\_mesh}=5 corresponds to a beta plane in a rotated domain for the 
+GYRE configuration, representing a classical mid-latitude double gyre system. 
+The rotation allows us to maximize the jet length relative to the gyre areas 
+(and the number of grid points). 
+
+The choice of the grid must be consistent with the boundary conditions specified 
+by the parameter \jp{jperio} (see {\S\ref{LBC}).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Grid files
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Grid files}
+\label{DOM_hgr_files}
+
+All the arrays relating to a particular ocean model configuration (grid-point 
+position, scale factors, masks) can be saved in files if $\np{nmsh} \not= 0$ 
+(namelist parameter). This can be particularly useful for plots and off-line 
+diagnostics. In some cases, the user may choose to make a local modification 
+of a scale factor in the code. This is the case in global configurations when 
+restricting the width of a specific strait (usually a one-grid-point strait that 
+happens to be too wide due to insufficient model resolution). An example 
+is Gibraltar Strait in the ORCA2 configuration. When such modifications are done, 
+the output grid written when $\np{nmsh} \not=0$ is no more equal to the input grid.
+
+% ================================================================
+% Domain: Vertical Grid (domzgr)
+% ================================================================
+\section  [Domain: Vertical Grid (\textit{domzgr})]
+		{Domain: Vertical Grid \small{(\mdl{domzgr} module)} }
+\label{DOM_zgr}
+%-----------------------------------------nam_zgr & namdom-------------------------------------------
+\namdisplay{nam_zgr} 
+\namdisplay{namdom} 
+%-------------------------------------------------------------------------------------------------------------
+
+In the vertical, the model mesh is determined by four things: 
+(1) the bathymetry given in meters ; 
+(2) the number of levels of the model (\jp{jpk}) ; 
+(3) the analytical transformation $z(i,j,k)$ and the vertical scale factors 
+(derivatives of the transformation) ; 
+and (4) the masking system, $i.e.$ the number of wet model levels at each 
+$(i,j)$ column of points.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_z_zps_s_sps}  \begin{center}
+\includegraphics[width=1.0\textwidth]{./TexFiles/Figures/Fig_z_zps_s_sps.pdf}
+\caption{The ocean bottom as seen by the model: 
+(a) $z$-coordinate with full step, 
+(b) $z$-coordinate with partial step, 
+(c) $s$-coordinate: terrain following representation, 
+(d) hybrid $s-z$ coordinate, 
+(e) hybrid $s-z$ coordinate with partial step, and 
+(f) same as (e) but with variable volume associated with the non-linear free surface. 
+Note that the variable volume option (\key{vvl}) can be used with any of the 
+5 coordinates (a) to (e).}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The choice of a vertical coordinate, even if it is made through a namelist parameter, 
+must be done once of all at the beginning of an experiment. It is not intended as an 
+option which can be enabled or disabled in the middle of an experiment. Three main 
+choices are offered (Fig.~\ref{Fig_z_zps_s_sps}a to c): $z$-coordinate with full step 
+bathymetry (\np{ln\_zco}=true), $z$-coordinate with partial step bathymetry 
+(\np{ln\_zps}=true), or generalized, $s$-coordinate (\np{ln\_sco}=true). 
+Hybridation of the three main coordinates are available: $s-z$ or $s-zps$ coordinate 
+(Fig.~\ref{Fig_z_zps_s_sps}d and \ref{Fig_z_zps_s_sps}e). When using the variable 
+volume option \key{vvl}) ($i.e.$ non-linear free surface), the coordinate follow the 
+time-variation of the free surface so that the transformation is time dependent: 
+$z(i,j,k,t)$ (Fig.~\ref{Fig_z_zps_s_sps}f). This option can be used with full step 
+bathymetry or $s$-coordinate (hybride and partial step coordinates have not 
+yet been tested in NEMO v2.3). 
+
+Contrary to the horizontal grid, the vertical grid is computed in the code and no 
+provision is made for reading it from a file. The only input file is the bathymetry 
+(in meters)\footnote{N.B. in full step $z$-coordinate, a \textit{bathy\_level} file can 
+replace the \textit{bathy\_meter} file, so that the computation of the number of 
+wet ocean point in each water column is by-passed}. After reading the bathymetry, 
+the algorithm for vertical grid definition differs between the different options:
+\begin{description}
+\item[\textit{zco}] set a reference coordinate transformation $z_0 (k)$, and set $z(i,j,k,t)=z_0 (k)$.
+\item[\textit{zps}] set a reference coordinate transformation $z_0 (k)$, and 
+calculate the thickness of the deepest level at each $(i,j)$ point using the 
+bathymetry, to obtain the final three-dimensional depth and scale factor arrays.
+\item[\textit{sco}] smooth the bathymetry to fulfil the hydrostatic consistency 
+criteria and set the three-dimensional transformation.
+\item[\textit{s-z} and \textit{s-zps}] smooth the bathymetry to fulfil the hydrostatic 
+consistency criteria and set the three-dimensional transformation $z(i,j,k)$, and 
+possibly introduce masking of extra land points to better fit the original bathymetry file
+\end{description}
+%%%
+\gmcomment{   add the description of the smoothing:  envelop topography...}
+%%%
+
+Generally, the arrays describing the grid point depths and vertical scale factors 
+are three dimensional arrays $(i,j,k)$. In the special case of $z$-coordinates with 
+full step bottom topography, it is possible to define those arrays as one-dimensional, 
+in order to save memory. This is performed by defining the \key{zco} 
+C-Pre-Processor (CPP) key. To improve the code readability while providing this 
+flexibility, the vertical coordinate and scale factors are defined as functions of 
+$(i,j,k)$ with "fs" as prefix (examples: \textit{fsdeptht, fse3t,} etc) that can be either 
+three-dimensional arrays, or a one dimensional array when \key{zco} is defined. 
+These functions are defined in the file \hf{domzgr\_substitute} of the DOM directory. 
+They are used throughout the code, and replaced by the corresponding arrays at 
+the time of pre-processing (CPP capability).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Meter Bathymetry
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Meter Bathymetry}
+\label{DOM_bathy}
+
+Three options are possible for defining the bathymetry, according to the 
+namelist variable \np{ntopo}: 
+\begin{description}
+\item[\np{ntopo} = 0] a flat-bottom domain is defined. The total depth $z_w (jpk)$ 
+is given by the coordinate transformation. The domain can either be a closed 
+basin or a periodic channel depending on the parameter \jp{jperio}. 
+\item[\np{ntopo} = -1] a domain with a bump of topography one third of the 
+domain width at the central latitude. This is meant for the "EEL-R5" configuration, 
+a periodic or open boundary channel with a seamount. 
+\item[\np{ntopo} = 1] read a bathymetry. The bathymetry file (Netcdf format) 
+provides the ocean depth (positive, in meters) at each grid point of the model grid. 
+The bathymetry is usually built by interpolating a standard bathymetry product 
+($e.g.$ ETOPO2) onto the horizontal ocean mesh. Defining the bathymetry also 
+defines the coastline: where the bathymetry is zero, no model levels are defined 
+(all levels are masked).
+\end{description}
+
+When using the rigid lid approximation (\key{dynspg\_rl} is defined) isolated land 
+masses (islands) must be identified by negative integers in the input bathymetry file 
+(see \S\ref{MISC_solisl}).
+
+When a global ocean is coupled to an atmospheric model it is better to represent 
+all large water bodies (e.g, great lakes, Caspian sea...) even if the model 
+resolution does not allow their communication with the rest of the ocean. 
+This is unnecessary when the ocean is forced by fixed atmospheric conditions, 
+so these seas can be removed from the ocean domain. The user has the option 
+to set the bathymetry in closed seas to zero (see \S\ref{MISC_closea}), but the 
+code has to be adapted to the user's configuration. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        z-coordinate  and reference coordinate transformation
+% -------------------------------------------------------------------------------------------------------------
+\subsection[$z$-coordinate (\np{ln\_zco} or \key{zco})]
+	  	  {$z$-coordinate (\np{ln\_zco}=.true. or \key{zco}) and reference coordinate}
+\label{DOM_zco}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_zgr}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_zgr.pdf}
+\caption{Default vertical mesh for ORCA2: 30 ocean levels (L30). Vertical level 
+functions for (a) T-point depth and (b) the associated scale factor as computed 
+from \eqref{DOM_zgr_ana} using \eqref{DOM_zgr_coef} in $z$-coordinate.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The reference coordinate transformation $z_0 (k)$ defines the arrays $gdept_0$ 
+and $gdepw_0$ for $T$- and $w$-points, respectively. As indicated on 
+Fig.\ref{Fig_index_vert} \jp{jpk} is the number of $w$-levels. $gdepw_0(1)$ is the 
+ocean surface. There are at most \jp{jpk}-1 $T$-points inside the ocean, the 
+additional $T$-point at $jk=jpk$ is below the sea floor and is not used. 
+The vertical location of $w$- and $T$-levels is defined from the analytic expression 
+of the depth $z_0(k)$ whose analytical derivative with respect to $k$ provides the 
+vertical scale factors. The user must provide the analytical expression of both 
+$z_0$ and its first derivative with respect to $k$. This is done in routine \mdl{domzgr} 
+through statement functions, using parameters provided in the \textit{par\_oce.h90} file. 
+
+It is possible to define a simple regular vertical grid by giving zero stretching (\pp{ppacr=0}). 
+In that case, the parameters \jp{jpk} (number of $w$-levels) and \pp{pphmax} 
+(total ocean depth in meters) fully define the grid. 
+
+For climate-related studies it is often desirable to concentrate the vertical resolution 
+near the ocean surface. The following function is proposed as a standard for a 
+$z$-coordinate (with either full or partial steps): 
+\begin{equation} \label{DOM_zgr_ana}
+\begin{split}
+ z_0 (k) 	&= h_{sur} -h_0 \;k-\;h_1 \;\log \left[ {\,\cosh \left( {{(k-h_{th} )} / {h_{cr} }} \right)\,} \right] \\ 
+ e_3^0 (k) 	&= \left| -h_0 -h_1 \;\tanh \left( {{(k-h_{th} )} / {h_{cr} }} \right) \right| 
+\end{split}
+\end{equation}
+where $k=1$ to \jp{jpk} for $w$-levels and $k=1$ to $k=1$ for $T-$levels. Such an 
+expression allows us to define a nearly uniform vertical location of levels at the 
+ocean top and bottom with a smooth hyperbolic tangent transition in between 
+(Fig.~\ref{Fig_zgr}).
+
+The most used vertical grid for ORCA2 has $10~m$ ($500~m)$ resolution in the 
+surface (bottom) layers and a depth which varies from 0 at the sea surface to a 
+minimum of $-5000~m$. This leads to the following conditions:
+\begin{equation} \label{DOM_zgr_coef}
+\begin{split}
+ e_3 (1+1/2)		&=10. \\ 
+ e_3 (jpk-1/2)	&=500. \\ 
+ z(1)			&=0. \\ 
+ z(jpk)			&=-5000. \\ 
+\end{split}
+\end{equation}
+
+With the choice of the stretching $h_{cr} =3$ and the number of levels 
+\jp{jpk}=$31$, the four coefficients $h_{sur}$, $h_{0}$, $h_{1}$, and $h_{th}$ in 
+\eqref{DOM_zgr_ana} have been determined such that \eqref{DOM_zgr_coef} is 
+satisfied, through an optimisation procedure using a bisection method. For the first 
+standard ORCA2 vertical grid this led to the following values: $h_{sur} =4762.96$, 
+$h_0 =255.58, h_1 =245.5813$, and $h_{th} =21.43336$. The resulting depths and 
+scale factors as a function of the model levels are shown in Fig.~\ref{Fig_zgr} and 
+given in Table \ref{Tab_orca_zgr}. Those values correspond to the parameters 
+\pp{ppsur}, \pp{ppa0}, \pp{ppa1}, \pp{ppkth} in the parameter file \mdl{par\_oce}. 
+
+Rather than entering parameters $h_{sur}$, $h_{0}$, and $h_{1}$ directly, it is 
+possible to recalculate them. In that case the user sets 
+\pp{ppsur}=\pp{ppa0}=\pp{ppa1}=\pp{pp\_to\_be\_computed}, in \mdl{par\_oce}, 
+and specifies instead the four following parameters:
+\begin{itemize}
+\item 	\pp{ppacr}=$h_{cr} $: stretching factor (nondimensional). The larger 
+\pp{ppacr}, the smaller the stretching. Values from $3$ to $10$ are usual.
+\item 	\pp{ppkth}=$h_{th} $: is approximately the model level at which maximum 
+stretching occurs (nondimensional, usually of order 1/2 or 2/3 of \jp{jpk})
+\item 	\pp{ppdzmin}: minimum thickness for the top layer (in meters)
+\item 	\pp{pphmax}: total depth of the ocean (meters).
+\end{itemize}
+As an example, for the $45$ layers used in the DRAKKAR configuration those 
+parameters are: \jp{jpk}=46, \pp{ppacr}=9, \pp{ppkth}=23.563, \pp{ppdzmin}=6m, 
+\pp{pphmax}=5750m.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{table} \label{Tab_orca_zgr}
+\begin{center} \begin{tabular}{c||r|r|r|r}
+\hline
+\textbf{LEVEL}& \textbf{GDEPT}& \textbf{GDEPW}& \textbf{E3T }& \textbf{E3W  } \\ \hline
+1	&	\textbf{  5.00}	&       0.00 &	\textbf{ 10.00} &	 10.00 \\	\hline
+2	&	\textbf{15.00}	& 	  10.00 &	\textbf{ 10.00} &	 10.00 \\	\hline
+3	&	\textbf{25.00}	&	  20.00 &	\textbf{ 10.00} & 	 10.00 \\	\hline
+4	&	\textbf{35.01}	&	  30.00 & 	\textbf{ 10.01} & 	 10.00 \\	\hline
+5	&	\textbf{45.01}	&	  40.01 &	\textbf{ 10.01} &	 10.01 \\	\hline
+6	&	\textbf{55.03}	&	  50.02 &	\textbf{ 10.02} & 	 10.02 \\	\hline
+7	&	\textbf{65.06}	&	  60.04 &	\textbf{ 10.04} &	 10.03 \\	\hline
+8	&	\textbf{75.13}	&	  70.09 &	\textbf{ 10.09} &	 10.06 \\	\hline
+9	&	\textbf{85.25}	&	  80.18 &	\textbf{ 10.17} &	 10.12 \\	\hline
+10	& 	\textbf{95.49}	& 	  90.35 &	\textbf{ 10.33} &	 10.24 \\	\hline
+11	& 	\textbf{105.97}	& 	 100.69 &	\textbf{ 10.65} &	 10.47 \\	\hline
+12	& 	\textbf{116.90}	& 	 111.36 &	\textbf{ 11.27} &	 10.91 \\	\hline
+13	& 	\textbf{128.70}	& 	 122.65 &	\textbf{ 12.47} &	 11.77 \\	\hline
+14	& 	\textbf{142.20}	& 	 135.16 &	\textbf{ 14.78} &	 13.43 \\	\hline
+15	& 	\textbf{158.96}	& 	 150.03 &	\textbf{ 19.23} &	 16.65 \\	\hline
+16	& 	\textbf{181.96}	& 	 169.42 &	\textbf{ 27.66} &	 22.78 \\	\hline
+17	& 	\textbf{216.65}	& 	 197.37 & 	\textbf{ 43.26} &	 34.30 \\ \hline
+18	& 	\textbf{272.48}	& 	 241.13 & 	\textbf{ 70.88} &	 55.21 \\ \hline
+19	& 	\textbf{364.30}	& 	 312.74 & 	\textbf{116.11} &	 90.99 \\ \hline
+20	& 	\textbf{511.53}	& 	 429.72 & 	\textbf{181.55} & 	146.43 \\ \hline
+21	& 	\textbf{732.20}	& 	 611.89 & 	\textbf{261.03} & 	220.35 \\ \hline
+22	& 	\textbf{1033.22}&	 872.87 & 	\textbf{339.39} & 	301.42 \\ \hline
+23	& 	\textbf{1405.70}&	1211.59 & \textbf{402.26} & 	373.31 \\ \hline
+24	& 	\textbf{1830.89}&	1612.98 & \textbf{444.87} & 	426.00 \\ \hline
+25	& 	\textbf{2289.77}&	2057.13 & \textbf{470.55} & 	459.47 \\ \hline
+26	& 	\textbf{2768.24}&	2527.22 & \textbf{484.95} & 	478.83 \\ \hline
+27	& 	\textbf{3257.48}&	3011.90 & \textbf{492.70} & 	489.44 \\ \hline
+28	& 	\textbf{3752.44}&	3504.46 & \textbf{496.78} & 	495.07 \\ \hline
+29	& 	\textbf{4250.40}&	4001.16 & \textbf{498.90} & 	498.02 \\ \hline
+30	& 	\textbf{4749.91}&	4500.02 & \textbf{500.00} &	499.54 \\ \hline
+31	& 	\textbf{5250.23}&	5000.00 &	\textbf{500.56} &	500.33 \\ \hline
+\end{tabular} \end{center} 
+\caption{Default vertical mesh in $z$-coordinate for 30 layers ORCA2 configuration 
+as computed from \eqref{DOM_zgr_ana} using the coefficients given in 
+\eqref{DOM_zgr_coef}}
+\end{table}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -------------------------------------------------------------------------------------------------------------
+%        z-coordinate with partial step
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [$z$-coordinate with partial step (\np{ln\_zps})]
+			{$z$-coordinate with partial step (\np{ln\_zps}=.true.)}
+\label{DOM_zps}
+%--------------------------------------------namdom-------------------------------------------------------
+\namdisplay{namdom} 
+%--------------------------------------------------------------------------------------------------------------
+
+In $z$-coordinate partial step, the depths of the model levels are defined by the 
+reference analytical function $z_0 (k)$ as described in the previous 
+section, \emph{except} in the bottom layer. The thickness of the bottom layer is 
+allowed to vary as a function of geographical location $(\lambda,\varphi)$ to allow a 
+better representation of the bathymetry, especially in the case of small 
+slopes (where the bathymetry varies by less than one level thickness from 
+one grid point to the next). The reference layer thicknesses $e_{3t}^0$ have been 
+defined in the absence of bathymetry. With partial steps, layers from 1 to 
+\jp{jpk}-2 can have a thickness smaller than $e_{3t}(jk)$. The model deepest layer (\jp{jpk}-1) 
+is allowed to have either a smaller or larger thickness than $e_{3t}(jpk)$: the 
+maximum thickness allowed is $2*e_{3t}(jpk-1)$. This has to be kept in mind when 
+specifying the maximum depth \pp{pphmax} in partial steps: for example, with 
+\pp{pphmax}$=5750~m$ for the DRAKKAR 45 layer grid, the maximum ocean depth 
+allowed is actually $6000~m$ (the default thickness $e_{3t}(jpk-1)$ being $250~m$). 
+Two variables in the namdom namelist are used to define the partial step 
+vertical grid. The mimimum water thickness (in meters) allowed for a cell 
+partially filled with bathymetry at level jk is the minimum of \np{e3zpsmin} 
+(thickness in meters, usually $20~m$) or $e_{3t}(jk)*\np{e3zps\_rat}$ (a fraction, 
+usually 10\%, of the default thickness $e_{3t}(jk)$).
+
+ \colorbox{yellow}{Add a figure here of pstep especially at last ocean level }
+
+% -------------------------------------------------------------------------------------------------------------
+%        s-coordinate
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [$s$-coordinate (\np{ln\_sco})]
+			{$s$-coordinate (\np{ln\_sco}=true)}
+\label{DOM_sco}
+%------------------------------------------nam_zgr_sco---------------------------------------------------
+\namdisplay{nam_zgr_sco} 
+%--------------------------------------------------------------------------------------------------------------
+In $s$-coordinate (\key{sco} is defined), the depth and thickness of the model 
+levels are defined from the product of a depth field and either a stretching 
+function or its derivative, respectively:
+\begin{equation} \label{DOM_sco_ana}
+\begin{split}
+ z(k) 		&= h(i,j) \; z_0(k)	\\
+ e_3(k)	&= h(i,j) \; z_0'(k)
+\end{split}
+\end{equation}
+where $h$ is the depth of the last $w$-level ($z_0(k)$) defined at the $T$-point 
+location in the horizontal and $z_0(k)$ is a function which varies from $0$ at the sea 
+surface to $1$ at the ocean bottom. The depth field $h$ is not necessary the ocean 
+depth, since a mixed step-like and bottom-following representation of the 
+topography can be used (Fig.~\ref{Fig_z_zps_s_sps}d-e). In the example provided 
+(\hf{zgr\_s} file) $h$ is a smooth envelope bathymetry and steps are used to represent 
+sharp bathymetric gradients.
+
+A new flexible stretching function, modified from \citet{Song1994} is provided as an example:
+\begin{equation} \label{DOM_sco_function}
+\begin{split}
+z	&= h_c +( h-h_c)\;c s)	\\
+c(s)	&=  \frac{ \left[	  \tanh{ \left( \theta \, (s+b) \right)} 
+	  	 			- \tanh{ \left(  \theta \, b      \right)}  \right]}
+		      {2\;\sinh \left( \theta \right)}
+\end{split}
+\end{equation}
+where $h_c$ is the thermocline depth and $\theta$ and $b$ are the surface and 
+bottom control parameters such that $0\leqslant \theta \leqslant 20$, and 
+$0\leqslant b\leqslant 1$. $b$ has been designed to allow surface and/or bottom 
+increase of the vertical resolution (Fig.~\ref{Fig_sco_function}).
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_sco_function}  \begin{center}
+\includegraphics[width=1.0\textwidth]{./TexFiles/Figures/Fig_sco_function.pdf}
+\caption{Examples of the stretching function applied to a sea mont; from left to right: 
+surface, surface and bottom, and bottom intensified resolutions}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -------------------------------------------------------------------------------------------------------------
+%        z*- or s*-coordinate
+% -------------------------------------------------------------------------------------------------------------
+\subsection{$z^*$- or $s^*$-coordinate (add \key{vvl}) }
+\label{DOM_zgr_vvl}
+
+This option is described in the Report by Levier \textit{et al.} (2007), available on 
+the \NEMO web site. 
+
+%gm% key advantage: minimise the diffusion/dispertion associated with advection in response to high frequency surface disturbances
+
+% -------------------------------------------------------------------------------------------------------------
+%        level bathymetry and mask 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{level bathymetry and mask}
+\label{DOM_msk}
+
+Whatever the vertical coordinate used, the model offers the possibility of 
+representing the bottom topography with steps that follow the face of the 
+model cells (step like topography) \citep{Madec1996}. The distribution of 
+the steps in the horizontal is defined in a 2D integer array, mbathy, which 
+gives the number of ocean levels ($i.e.$ those that are not masked) at each 
+$T$-point. mbathy is computed from the meter bathymetry using the definiton of 
+gdept as the number of $T$-points which gdept $\leq$ bathy. Note that in version 
+NEMO v2.3, the user still has to provide the "level" bathymetry in a NetCDF
+file when using the full step option (\np{ln\_zco}), rather than the bathymetry 
+in meters: both will be allowed in future versions.
+
+Modifications of the model bathymetry are performed in the \textit{bat\_ctl} 
+routine (see \mdl{domzgr} module) after mbathy is computed. Isolated grid points 
+that do not communicate with another ocean point at the same level are eliminated.
+
+In the case of the rigid-lid approximation when islands occur in the computational 
+domain (\np{ln\_dynspg\_rl}=.true. and \key{island} is defined), the \textit{mbathy} 
+array must be provided and takes values from $-N$ to \jp{jpk}-1. It provides the 
+following information: $mbathy(i,j) = -n, \ n \in \left] 0,N \right]$, $T$-points are 
+land points on the $n^{th}$ island ; $mbathy(i,j) =0$, $T$-points are land points 
+on the main land (continent) ; $mbathy(i,j) =k$, the first $k$ $T$- and $w$-points 
+are ocean points, the others are points below the ocean floor. 
+
+This is used to compute the island barotropic stream function used in the rigid lid 
+computation (see \S\ref{MISC_solisl}).
+
+From the \textit{mbathy} array, the mask fields are defined as follows:
+\begin{align*}
+tmask(i,j,k) &= \begin{cases}   \; 1&   \text{ if $k\leq mbathy(i,j)$  }    \\
+                                                \; 0&   \text{ if $k\leq mbathy(i,j)$  }    \end{cases}     \\
+umask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i+1,j,k)	\\
+vmask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i,j+1,k)	\\
+fmask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i+1,j,k)	\\
+                   & \ \ \, * tmask(i,j,k) \ * \ tmask(i+1,j,k)
+\end{align*}
+
+\gmcomment{ STEVEN: are the dots multiplications?}      
+
+Note that \textit{wmask} is not defined as it is exactly equal to \textit{tmask} with 
+the numerical indexing used (\S~\ref{DOM_Num_Index}). Moreover, the 
+specification of closed lateral boundaries requires that at least the first and last 
+rows and columns of the \textit{mbathy} array are set to zero. In the particular 
+case of an east-west cyclical boundary condition, \textit{mbathy} has its last 
+column equal to the second one and its first column equal to the last but one 
+(and so too the mask arrays) (see \S~\ref{LBC_jperio}).
+
+%%%
+\gmcomment{   \colorbox{yellow}{Add one word on tricky trick !} mbathy in further modified in zdfbfr{\ldots}.  }
+%%%
+
+% ================================================================
+% Time Discretisation
+% ================================================================
+\section{Time Discretisation}
+\label{DOM_nxt}
+
+The time stepping used in \NEMO is a three level scheme that can be 
+represented as follows:
+\begin{equation} \label{Eq_DOM_nxt}
+   x^{t+\Delta t} = x^{t-\Delta t} + 2 \, \Delta t \  \text{RHS}_x^{t-\Delta t,t,t+\Delta t}
+\end{equation} 
+where $x$ stands for $u$, $v$, $T$ or $S$; RHS is the Right-Hand-Side of the 
+corresponding time evolution equation; $\Delta t$ is the time step; and the 
+superscripts indicate the time at which a quantity is evaluated. Each term of the 
+RHS is evaluated at a specific time step(s) depending on the physics with which 
+it is associated. 
+
+The choice of the time step used for this evaluation is discussed below as 
+well as the implications in terms of starting or restarting a model 
+simulation. Note that the time stepping is generally performed in a one step 
+operation. With such a complex and nonlinear system of equations it would be 
+dangerous to let a prognostic variable evolve in time for each term separately.
+
+The three level scheme requires three arrays for each prognostic variables. 
+For each variable $x$ there is $x_b$ (before) and $x_n$ (now). The third array, 
+although referred to as $x_a$ (after) in the code, is usually not the variable at 
+the next time step; but rather it is used to store the time derivative (RHS in 
+\eqref{Eq_DOM_nxt}) prior to time-stepping the equation. Generally, the time 
+stepping is performed once at each time step in \mdl{tranxt} and \mdl{dynnxt} 
+modules, except for implicit vertical diffusion or sea surface height when 
+time-splitting options are used.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Non-Diffusive Part---Leapfrog Scheme
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Non-Diffusive Part --- Leapfrog Scheme}
+\label{DOM_nxt_leap_frog}
+
+The time stepping used for non-diffusive processes is the well-known 
+leapfrog scheme. It is a time centred scheme, i.e. the RHS is evaluated at 
+time step $t$, the now time step. It is only used for non-diffusive terms, 
+that is momentum and tracer advection, pressure gradient, and Coriolis 
+terms. This scheme is widely used for advective processes in low-viscosity 
+fluids. It is an efficient method that achieves second-order accuracy with 
+just one right hand side evaluation per time step. Moreover, it does not 
+artificially damp linear oscillatory motion nor does it produce instability 
+by amplifying the oscillations. These advantages are somewhat diminished by 
+the large phase-speed error of the leapfrog scheme, and the unsuitability of 
+leapfrog differencing for the representation of diffusive and Rayleigh 
+damping processes. However, the most serious problem associated with the 
+leapfrog scheme is a high-frequency computational noise called 
+"time-splitting" \citep{Haltiner1980} that develops when the method 
+is used to model non linear fluid dynamics: the even and odd time steps tend 
+to diverge into a physical and a computational mode. Time splitting can 
+be controlled through the use of an Asselin time filter (first designed by 
+\citep{Robert1966} and more comprehensively studied by \citet{Asselin1972}), 
+or by periodically reinitialising the leapfrog solution through a single 
+integration step with a two-level scheme. In \NEMO we follow the first 
+strategy:
+\begin{equation} \label{Eq_DOM_nxt_asselin}
+x_F^t  = x^t + \gamma \, \left[ x_f^{t-\Delta t} - 2 x^t + x^{t+\Delta t} \right]
+\end{equation} 
+where the subscript $f$ denotes filtered values and $\gamma$ is the Asselin 
+coefficient. $\gamma$ is initialized as \np{atfp} (namelist parameter). 
+Its default value is \np{atfp}=0.1.  This default value causes a significant dissipation 
+of high frequency motions. Recommended values in idealized studies of shallow 
+water turbulence are two orders of magnitude smaller (\citep{Farge1987}). 
+Both strategies do, nevertheless, degrade the accuracy of the calculation from 
+second to first order. The leapfrog scheme combined with a Robert-Asselin 
+time filter has been preferred to other time differencing schemes such as 
+predictor corrector or trapezoidal schemes, because the user has an explicit 
+and simple control of the magnitude of the time diffusion of the scheme. 
+In association with the 2nd order centred space discretisation of the 
+advective terms in the momentum and tracer equations, it avoids implicit 
+numerical diffusion in both the time and space discretisations of the 
+advective term: they are both set explicitly by the user through the Robert-Asselin 
+filter parameter and the viscous and diffusive coefficients.
+
+\gmcomment{
+%gm - reflexion about leapfrog: ongoing work with Matthieu Leclair
+% to be updated latter with addition of new time stepping strategy
+\colorbox{yellow}{Note}: 
+The Robert-Asselin time filter slightly departs from a simple second order time 
+diffusive operator computed with a forward time stepping due to the presence of 
+$x_f^{t-\Delta t}$ in the right hand side of  \ref{Eq_DOM_nxt_asselin}. The original 
+willing of Robert1966 and Asselin1972 was to design a time filter that allow much 
+larger parameter than 0.5.   is due to computer saving consideration. In the original 
+asselin filter, $x^{t-\Delta t}$ is used instead:
+ \begin{equation} \label{Eq_DOM_nxt_asselin_true}
+x_f^t  = x^t + \gamma \, \left[ x^{t-\Delta t} - 2 x^t + x^{t+\Delta t} \right]
+\end{equation} 
+Applying a "true" Asselin time filter is nothing more than adding a harmonic 
+diffusive operator in time. Indeed, equations \ref{Eq_DOM_nxt} and 
+\ref{Eq_DOM_nxt_asselin_true} can be rewritten together as:
+\begin{equation} \label{Eq_DOM_nxt2}
+\begin{split}
+  \frac{ x^{t+\Delta t} - x^{t-\Delta t} } { 2 \,\Delta t } 
+  &=  \text{RHS}_x^{t-\Delta t,t,t+\Delta t} + \frac{ x_f^t  - x^t }{2 \,\Delta t} \\
+  &=  \text{RHS}_x^{t-\Delta t,t,t+\Delta t} 
+    + \gamma\ \frac{  \, \left[ x^{t-\Delta t} - 2 x^t + x^{t+\Delta t} \right] }{2 \,\Delta t}  \\
+  &=  \text{RHS}_x^{t-\Delta t,t,t+\Delta t} 
+  + 2 \Delta t \ \gamma \ \frac{1}{{2 \Delta t}^2}  
+  	\,\delta_{t-1}\,\left[ \delta_{t+1/2}\left[ x^t \right] \right] 
+  \end{split}
+\end{equation} 
+expressing this again in a continuous form, one finds that the Asselin filter leads to :
+\begin{equation} \label{Eq_DOM_nxt3}
+  \frac{ \partial x} { \partial t } =  \text{RHS} + 2 \,\Delta t \ \gamma \ \frac{ {\partial}^2 x}{ \partial t ^2 }
+\end{equation} 
+
+Equations  \ref{Eq_DOM_nxt2} and \ref{Eq_DOM_nxt3} suggest several remarks. 
+First the Asselin filter is definitively a second order time diffusive operator which is 
+evaluated at centered time step. The magnitude of this diffusion is proportional to 
+the time step (with $\gamma$ usually taken between $10^{-1}$ to $10^{-3}$). 
+Second, this term has to be taken into account in all budgets of the equations 
+(mass, heat content, salt content, kinetic energy...). Nevertheless,we stress here 
+that it is small and does not create systematic biases. Indeed let us evaluate how 
+it contributes to the time evolution of $x$ between $t_o$ and $t_1$:
+\begin{equation} \label{Eq_DOM_nxt4}
+\begin{split}
+ t_1-t_o &= \int_{t_o}^{t_1} \frac{ \partial x} { \partial t } dt \\
+ 		&= \int_{t_o}^{t_1} \text{RHS} dt + 2 \,\Delta t \ \gamma \left(
+		  \left. \frac{ \partial x}{ \partial t } \right|_1 
+		- \left. \frac{ \partial x}{ \partial t } \right|_o  \right)
+ \end{split}
+\end{equation} 
+}
+
+Alternative time stepping schemes are currently under investigation.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Diffusive Part---Forward or Backward Scheme
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Diffusive Part --- Forward or Backward Scheme}
+\label{DOM_nxt_forward_imp}
+
+The leapfrog differencing scheme is unsuitable for the representation of 
+diffusive and damping processes. For a tendancy $D_x$, representing a 
+diffusive term or a restoring term to a tracer climatology 
+(when present, see \S~\ref{TRA_dmp}), a forward time differencing scheme
+ is used :
+\begin{equation} \label{Eq_DOM_nxt_euler}
+   x^{t+\Delta t} = x^{t-\Delta t} + 2 \, \Delta t \ {D_x}^{t-\Delta t}
+\end{equation} 
+
+This is diffusive in time and conditionally stable. For example, the 
+conditions for stability of second and fourth order horizontal diffusion schemes are \citep{Griffies2004}:
+\begin{equation} \label{Eq_DOM_nxt_euler_stability}
+A^h < \left\{
+\begin{aligned}
+                    &\frac{e^2}{  8 \; \Delta t } 	&&\quad \text{laplacian diffusion} 	\\
+                    &\frac{e^4}{64 \; \Delta t } 	&&\quad \text{bilaplacian diffusion} 
+            \end{aligned}
+\right.
+\end{equation}
+where $e$ is the smallest grid size in the two horizontal directions and $A^h$ is 
+the mixing coefficient. The linear constraint \eqref{Eq_DOM_nxt_euler_stability} 
+is a necessary condition, but not sufficient. If it is not satisfied, even mildly, 
+then the model soon becomes wildly unstable. The instability can be removed 
+by either reducing the length of the time steps or reducing the mixing coefficient.
+
+For the vertical diffusion terms, a forward time differencing scheme can be 
+used, but usually the numerical stability condition implies a strong 
+constraint on the time step. Two solutions are available in \NEMO to overcome 
+the stability constraint: $(a)$ a forward time differencing scheme using a 
+time splitting technique (\np{ln\_zdfexp}=.true.) or $(b)$ a backward (or implicit) 
+time differencing scheme by \np{ln\_zdfexp}=.false.). In $(a)$, the master 
+time step $\Delta $t is cut into $N$ fractional time steps so that the 
+stability criterion is reduced by a factor of $N$. The computation is done as 
+follows:
+\begin{equation} \label{Eq_DOM_nxt_ts}
+\begin{split}
+& u_\ast ^{t-\Delta t} = u^{t-\Delta t}   \\
+& u_\ast ^{t-\Delta t+L\frac{2\Delta t}{N}}=u_\ast ^{t-\Delta t+\left( {L-1} 
+\right)\frac{2\Delta t}{N}}+\frac{2\Delta t}{N}\;\text{DF}^{t-\Delta t+\left( {L-1} \right)\frac{2\Delta t}{N}}
+        \quad \text{for $L=1$ to $N$}      \\
+& u^{t+\Delta t} = u_\ast^{t+\Delta t}
+\end{split}
+\end{equation}
+with DF a vertical diffusion term. The number of fractional time steps, $N$, is given 
+by setting \np{n\_zdfexp}, (namelist parameter). The scheme $(b)$ is unconditionally 
+stable but diffusive. It can be written as follows:
+\begin{equation} \label{Eq_DOM_nxt_imp}
+   x^{t+\Delta t} = x^{t-\Delta t} + 2 \, \Delta t \  \text{RHS}_x^{t+\Delta t}
+\end{equation} 
+
+This scheme is rather time consuming since it requires a matrix inversion, 
+but it becomes attractive since a splitting factor of 3 or more is needed 
+for the forward time differencing scheme. For example, the finite difference 
+approximation of the temperature equation is:
+\begin{equation} \label{Eq_DOM_nxt_imp_zdf}
+\frac{T(k)^{t+1}-T(k)^{t-1}}{2\;\Delta t}\equiv \text{RHS}+\frac{1}{e_{3T} }\delta 
+_k \left[ {\frac{A_w^{vT} }{e_{3w} }\delta _{k+1/2} \left[ {T^{t+1}} \right]} 
+\right]
+\end{equation}
+where RHS is the right hand side of the equation except for the vertical diffusion term. 
+We rewrite \eqref{Eq_DOM_nxt_imp} as:
+\begin{equation} \label{Eq_DOM_nxt_imp_mat}
+-c(k+1)\;u^{t+1}(k+1)+d(k)\;u^{t+1}(k)-\;c(k)\;u^{t+1}(k-1) \equiv b(k)
+\end{equation}
+where 
+\begin{align*} 
+ c(k) &= A_w^{vm} (k) \, / \, e_{3uw} (k)     \\
+ d(k) &= e_{3u} (k)       \, / \, (2\Delta t) + c_k + c_{k+1}    \\
+ b(k) &= e_{3u} (k) \; \left( u^{t-1}(k) \, / \, (2\Delta t) + \text{RHS} \right)    
+\end{align*}
+
+\eqref{Eq_DOM_nxt_imp_mat} is a linear system of equations which associated 
+matrix is tridiagonal. Moreover, $c(k)$ and $d(k)$ are positive and the diagonal 
+term is greater than the sum of the two extra-diagonal terms, therefore a special 
+adaptation of the Gauss elimination procedure is used to find the solution 
+(see for example \citet{Richtmyer1967}).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Start/Restart strategy
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Start/Restart strategy}
+\label{DOM_nxt_rst}
+%--------------------------------------------namrun-------------------------------------------
+\namdisplay{namrun}         
+%--------------------------------------------------------------------------------------------------------------
+
+The first time step of this three level scheme when starting from initial conditions 
+is a forward step (Euler time integration): 
+\begin{equation} \label{Eq_DOM_euler}
+	x^1 = x^0 + \Delta t \ \text{RHS}^0
+\end{equation}
+
+It is also possible to restart from a previous computation, by using a 
+restart file. The restart strategy is designed to ensure perfect 
+restartability of the code: the user should obtain the same results to 
+machine precision either by running the model for $2N$ time steps in one go, 
+or by performing two consecutive experiments of $N$ steps with a restart. 
+This requires saving two time levels and many auxiliary data in the restart 
+files in machine precision. 
+
+Note that when a semi-implicit scheme is used to evaluate the hydrostatic pressure 
+gradient (see \S\ref{DYN_hpg_imp}), an extra three-dimensional field has to be 
+added in the restart file to ensure an exact restartability. This is done only optionally 
+via the namelist parameter \np{nn\_dynhpg\_rst}, so that a reduction of the size of 
+restart file can be obtained when the restartability is not a key issue (operational 
+oceanography or ensemble simulation for seasonal forcast).
+%%%
+\gmcomment{add here how to force the restart to contain only one time step for operational purposes}
+%%%
+
+\gmcomment{       % add a subsection here  
+
+%-------------------------------------------------------------------------------------------------------------
+%        Time Domain
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Time domain}
+\label{DOM_nxt_time}
+
+ \colorbox{yellow}{add here a few word on nit000 and nitend}
+
+ \colorbox{yellow}{Write documentation on the calendar and the key variable adatrj}
+
+}     	%% end add
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DYN.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 1844)
@@ -0,0 +1,1114 @@
+% ================================================================
+% Chapter Ñ Ocean Dynamics (DYN)
+% ================================================================
+\chapter{Ocean Dynamics (DYN)}
+\label{DYN}
+\minitoc
+
+% add a figure for  dynvor ens, ene latices
+
+%\vspace{2.cm}
+$\ $\newline      %force an empty line
+
+Using the representation described in Chap.\ref{DOM}, several semi-discrete 
+space forms of the dynamical equations are available depending on the vertical 
+coordinate used and on the conservation properties of the vorticity term. In all 
+the equations presented here, the masking has been omitted for simplicity. 
+One must be aware that all the quantities are masked fields and that each time a 
+average or difference operator is used, the resulting field is multiplied by a mask.
+
+The prognostic ocean dynamics equation can be summarized as follows:
+\begin{equation*}
+\text{NXT} = \dbinom	{\text{VOR} + \text{KEG} + \text {ZAD} }
+						{\text{COR} + \text{ADV}                       }
+			+ \text{HPG} + \text{SPG} + \text{LDF} + \text{ZDF}
+\end{equation*}
+
+NXT stands for next, referring to the time-stepping. The first group of terms on 
+the rhs of the momentum equations corresponds to the Coriolis and advection 
+terms that are decomposed into a vorticity part (VOR), a kinetic energy part (KEG) 
+and, a vertical advection part (ZAD) in the vector invariant formulation or a Coriolis 
+and advection part(COR+ADV) in the flux formulation. The terms following these 
+are the pressure gradient contributions (HPG, Hydrostatic Pressure Gradient, 
+and SPG, Surface Pressure Gradient); and contributions from lateral diffusion 
+(LDF) and vertical diffusion (ZDF), which are added to the rhs in the \mdl{dynldf} 
+and \mdl{dynzdf} modules. The vertical diffusion term includes the surface and 
+bottom stresses. The external forcings and parameterisations require complex 
+inputs (surface wind stress calculation using bulk formulae, estimation of mixing 
+coefficients) that are carried out in modules SBC, LDF and ZDF and are described 
+in Chapters \ref{SBC}, \ref{LDF} and \ref{ZDF}, respectively. 
+
+In the present chapter we also describe the diagnostic equations used to compute 
+the horizontal divergence and curl of the velocities (\emph{divcur} module) as well 
+as the vertical velocity (\emph{wzvmod} module).
+
+The different options available to the user are managed by namelist variables. 
+For equation term \textit{ttt}, the logical namelist variables are \textit{ln\_dynttt\_xxx}, 
+where \textit{xxx} is a 3 or 4 letter acronym corresponding to each optional scheme. 
+If a CPP key is used for this term its name is \textbf{key\_ttt}. The corresponding 
+code can be found in the \textit{dynttt\_xxx} module in the DYN directory, and it is 
+usually computed in the \textit{dyn\_ttt\_xxx} subroutine.
+
+The user has the option of extracting each tendency term of both the rhs of the 
+3D momentum equation (\key{trddyn} defined) for output, as described in 
+Chap.\ref{MISC}.  Furthermore, the tendency terms associated to the 2D 
+barotropic vorticity balance (\key{trdvor} defined) can be derived on-line from the 
+3D terms.
+%%%
+\gmcomment{STEVEN: not quite sure I've got the sense of the last sentence. does 
+MISC correspond to "extracting tendency terms" or "vorticity balance"?}
+
+$\ $\newline    % force a new ligne
+% ================================================================
+% Coriolis and Advection terms: vector invariant form
+% ================================================================
+\section{Coriolis and Advection: vector invariant form}
+\label{DYN_adv_cor_vect}
+%-----------------------------------------nam_dynadv----------------------------------------------------
+\namdisplay{nam_dynadv} 
+%-------------------------------------------------------------------------------------------------------------
+
+The vector invariant form of the momentum equations is the one most 
+often used in applications of \NEMO ocean model. The flux form option 
+(see next section) has been introduced since version $2$. 
+Coriolis and momentum advection terms are evaluated using a leapfrog 
+scheme, $i.e.$ the velocity appearing in these expressions is centred in 
+time (\textit{now} velocity). 
+At the lateral boundaries either free slip, no slip or partial slip boundary 
+conditions are applied following Chap.\ref{LBC}.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Vorticity term 
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Vorticity term (\textit{dynvor}) ]
+			{Vorticity term (\mdl{dynvor})}
+\label{DYN_vor}
+%------------------------------------------nam_dynvor----------------------------------------------------
+\namdisplay{nam_dynvor} 
+%-------------------------------------------------------------------------------------------------------------
+
+Different discretisations of the vorticity term (\textit{ln\_dynvor\_xxx}=.true.) are 
+available: conserving potential enstrophy of horizontally non-divergent flow ; 
+conserving horizontal kinetic energy ; or conserving potential enstrophy for the 
+relative vorticity term and horizontal kinetic energy for the planetary vorticity 
+term (see  Appendix~\ref{Apdx_C}). The vorticity terms are given below for the 
+general case, but note that in the full step $z$-coordinate (\key{zco} is defined), 
+$e_{3u} =e_{3v} =e_{3f}$ so that the vertical scale factors disappear. They are 
+all computed in dedicated routines that can be found in the \mdl{dynvor} module.
+
+%-------------------------------------------------------------
+%                 enstrophy conserving scheme
+%-------------------------------------------------------------
+\subsubsection{Enstrophy conserving scheme (\np{ln\_dynvor\_ens}=.true.)}
+\label{DYN_vor_ens}
+
+In the enstrophy conserving case (ENS scheme), the discrete formulation of the 
+vorticity term provides a global conservation of the enstrophy 
+($ [ (\zeta +f ) / e_{3f} ]^2 $ in $s$-coordinates) for a horizontally non-divergent 
+flow ($i.e.$ $\chi=0$), but does not conserve the total kinetic energy. It is given by:
+\begin{equation} \label{Eq_dynvor_ens}
+\left\{ 
+\begin{aligned}
+{+\frac{1}{e_{1u} } } & {\overline {\left( { \frac{\zeta +f}{e_{3f} }} \right)} }^{\,i} 
+                                & {\overline{\overline {\left( {e_{1v} e_{3v} v} \right)}} }^{\,i, j+1/2}    \\
+{- \frac{1}{e_{2v} } } & {\overline {\left( {\frac{\zeta +f}{e_{3f} }} \right)} }^{\,j}  
+                                & {\overline{\overline {\left( {e_{2u} e_{3u} u} \right)}} }^{\,i+1/2, j}  
+\end{aligned} 
+ \right.
+\end{equation} 
+
+%-------------------------------------------------------------
+%                 energy conserving scheme
+%-------------------------------------------------------------
+\subsubsection{Energy conserving scheme (\np{ln\_dynvor\_ene}=.true.)}
+\label{DYN_vor_ene}
+
+The kinetic energy conserving scheme (ENE scheme) conserves the global 
+kinetic energy but not the global enstrophy. It is given by:
+\begin{equation} \label{Eq_dynvor_ene}
+\left\{   \begin{aligned}
+{+\frac{1}{e_{1u}}\; {\overline {\left( {\frac{\zeta +f}{e_{3f} }} \right)
+                            \;  \overline {\left( {e_{1v} e_{3v} v} \right)} ^{\,i+1/2}} }^{\,j} }    \\
+{- \frac{1}{e_{2v}}\; {\overline {\left( {\frac{\zeta +f}{e_{3f} }} \right)
+                            \;  \overline {\left( {e_{2u} e_{3u} u} \right)} ^{\,j+1/2}} }^{\,i} }
+\end{aligned}    \right.
+\end{equation} 
+
+%-------------------------------------------------------------
+%                 mix energy/enstrophy conserving scheme
+%-------------------------------------------------------------
+\subsubsection{Mixed energy/enstrophy conserving scheme (\np{ln\_dynvor\_mix}=.true.) }
+\label{DYN_vor_mix}
+
+The mixed energy/enstrophy conserving scheme (MIX scheme), a mixture of the 
+two previous schemes is used. It consists of the ENS scheme (\ref{Eq_dynvor_ens}) 
+to the relative vorticity term, and of the ENE scheme (\ref{Eq_dynvor_ene}) applied 
+to the planetary vorticity term.
+\begin{equation} \label{Eq_dynvor_mix}
+\left\{ {
+\begin{aligned}
+ {+\frac{1}{e_{1u} }\; {\overline {\left( {\frac{\zeta }{e_{3f} }} \right)} }^{\,i} 
+ \; {\overline{\overline {\left( {e_{1v} \; e_{3v} \ v} \right)}} }^{\,i,j+1/2} -\frac{1}{e_{1u} }
+ \; {\overline {\left( {\frac{f}{e_{3f} }} \right) 
+ \;\overline {\left( {e_{1v} \; e_{3v} \ v} \right)} ^{\,i+1/2}} }^{\,j} } \\
+{-\frac{1}{e_{2v} }\; {\overline {\left( {\frac{\zeta }{e_{3f} }} \right)} }^j
+ \; {\overline{\overline {\left( {e_{2u} \; e_{3u} \ u} \right)}} }^{\,i+1/2,j} +\frac{1}{e_{2v} }
+ \; {\overline {\left( {\frac{f}{e_{3f} }} \right)
+ \;\overline {\left( {e_{2u}\; e_{3u} \ u} \right)} ^{\,j+1/2}} }^{\,i} } \hfill
+\end{aligned} 
+} \right.
+\end{equation} 
+
+%-------------------------------------------------------------
+%                 energy and enstrophy conserving scheme
+%-------------------------------------------------------------
+\subsubsection{Energy and enstrophy conserving scheme (\np{ln\_dynvor\_een}=.true.) }
+\label{DYN_vor_een}
+
+In the energy and enstrophy conserving scheme (EEN scheme), the vorticity term 
+is  evaluated using the vorticity advection scheme of \citet{Arakawa1990}. 
+This scheme conserves both total energy and potential enstrophy in the limit of 
+horizontally nondivergent flow ($i.e. \ \chi=0$). While EEN is more complicated 
+than ENS or ENE and does not conserve potential enstrophy and total energy in 
+general flow, it tolerates arbitrarily thin layers. This feature is essential for 
+$z$-coordinate with partial step. 
+%%%
+\gmcomment{gm :   it actually conserve kinetic energy  !   show that in appendix C }
+%%%
+
+The \citet{Arakawa1990} vorticity advection scheme for a single layer is modified 
+for spherical coordinates as described by \citet{Arakawa1981} to obtain the EEN 
+scheme. The potential vorticity, defined at an $f$-point, is: 
+\begin{equation} \label{Eq_pot_vor}
+q_f  = \frac{\zeta +f} {e_{3f} }
+\end{equation}
+where the relative vorticity is defined by (\ref{Eq_divcur_cur}), the Coriolis parameter 
+is given by $f=2 \,\Omega \;\sin \varphi _f $ and the layer thickness at $f$-points is: 
+\begin{equation} \label{Eq_een_e3f}
+e_{3f} = \overline{\overline {e_{3t} }} ^{\,i+1/2,j+1/2}
+\end{equation}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_DYN_een_triad}
+\begin{center}
+\includegraphics[width=0.70\textwidth]{./TexFiles/Figures/Fig_DYN_een_triad.pdf}
+\caption{Triads used in the energy and enstrophy conserving scheme (een) for 
+$u$-component (upper panel) and $v$-component (lower panel).}
+\end{center}
+\end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+Note that a key point in \eqref{Eq_een_e3f} is that the averaging in \textbf{i}- and 
+\textbf{j}- directions uses the masked vertical scale factor but is always divided by 
+$4$, not by the sum of the mask at $T$-point. This preserves the continuity of 
+$e_{3f}$ when one or more of the neighbouring $e_{3T}$ tends to zero and 
+extends by continuity the value of $e_{3f}$ in the land areas. 
+%%%
+\gmcomment{this has to be further investigate in case of several step topography}
+%%%
+
+The vorticity terms are represented as: 
+\begin{equation} \label{Eq_dynvor_een}
+\left\{ {
+\begin{aligned}
+ +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }  \left[ 
+{{\begin{array}{*{20}c}
+    	{\,\ \ a_{j+1/2}^{i   } \left( {e_{1v} e_{3v} \ v} \right)_{j+1}^{i+1/2} } 
+  	{\,+\,b_{j+1/2}^{i   } \left( {e_{1v} e_{3v} \ v} \right)_{j+1}^{i-1/2}  } \\
+ \\
+     {  +\,c_{j-1/2}^{i   }  \left( {e_{1v} e_{3v} \ v} \right)_{j    }^{i+1/2}         } 
+ 	{\,+\,d_{j+1/2}^{i   } \left( {e_{1v} e_{3v} \ v} \right)_{j+1}^{i+1/2} } \\
+\end{array} }} \right] \\ 
+\\
+-q\,e_3 \,u  		&\equiv -\frac{1}{e_{2v} }  \left[ 
+{{\begin{array}{*{20}c}
+ 	{\,\ \ a_{j-1/2}^{i   }  \left( {e_{2u} e_{3u} \ u} \right)_{j+1}^{i+1/2} } 
+  	{\,+\,b_{j-1/2}^{i+1}  \left( {e_{2u} e_{3u} \ u} \right)_{j+1/2}^{i+1} } \\
+ \\
+     	{  +\,c_{j+1/2}^{i+1} \left( {e_{2u} e_{3u} \ u} \right)_{j+1/2}^{i+1} } 
+  	{\,+\,d_{j+1/2}^{i   }  \left( {e_{2u} e_{3u} \ u} \right)_{j+1/2}^{i   } } \\
+\end{array} }} \right]
+\end{aligned} 
+} \right.
+\end{equation} 
+where $a$, $b$, $c$ and $d$ are the following triad combinations of the 
+neighbouring potential vorticities (Fig.~\ref{Fig_DYN_een_triad}): 
+\begin{equation} \label{Eq_een_triads}
+\left\{ 
+\begin{aligned}
+ a_{\,j+1/2}^i & = \frac{1}  {12} \left( q_{j+1/2}^{i+1} + q_{j+1 /2}^i + q_{j-1/2}^i  \right)    \\ 
+ \\
+ b_{\,j+1/2}^i & = \frac{1}  {12} \left( q_{j+1/2}^{i-1} +q_{j+1/2}^i +q_{j-1/2}^i   \right)     \\ 
+\\
+ c_{\,j+1/2}^i & = \frac{1}  {12} \left( q_{j-1/2}^{i-1} +q_{j+1/2}^i +q_{j-1/2}^i   \right)     \\ 
+\\
+ d_{\,j+1/2}^i & = \frac{1}  {12} \left( q_{j-1/2}^{i+1} +q_{j+1/2}^i +q_{j-1/2}^i  \right)     \\ 
+\end{aligned} 
+\right.
+\end{equation}
+
+%--------------------------------------------------------------------------------------------------------------
+%           Kinetic Energy Gradient term
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Kinetic Energy Gradient term (\textit{dynkeg})]
+			{Kinetic Energy Gradient term (\mdl{dynkeg})}
+\label{DYN_keg}
+
+As demonstarted in Appendix~\ref{Apdx_C}, there is a single discrete formulation 
+of the kinetic energy gradient term that, together with the formulation chosen for 
+the vertical advection (see below), conserves the total kinetic energy:
+\begin{equation} \label{Eq_dynkeg}
+\left\{ \begin{aligned}
+ -\frac{1}{2 \; e_{1u} } 
+ & \ \delta _{i+1/2} \left[ {\overline {u^2}^{\,i} + \overline{v^2}^{\,j}} \right]   \\
+ -\frac{1}{2 \; e_{2v} } 
+ & \ \delta _{j+1/2} \left[ {\overline {u^2}^{\,i} + \overline{v^2}^{\,j}} \right]    
+\end{aligned} \right.
+\end{equation} 
+
+%--------------------------------------------------------------------------------------------------------------
+%           Vertical advection term
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Vertical advection term (\textit{dynzad}) ]
+			{Vertical advection term (\mdl{dynzad}) }
+\label{DYN_zad}
+
+The discrete formulation of the vertical advection, together with the formulation 
+chosen for the gradient of kinetic energy (KE) term, conserves the total kinetic 
+energy. Indeed, the change of KE due to the vertical advection is exactly 
+balanced by the change of KE due to the gradient of KE (see Appendix~\ref{Apdx_C}).
+\begin{equation} \label{Eq_dynzad}
+\left\{ 		\begin{aligned}
+ -\frac{1}  { e_{1u}\,e_{2u}\,e_{3u} }  &  
+  \ {\overline {\overline{ e_{1T}\,e_{2T}\,w } ^{\,i+1/2}  \;\delta _{k+1/2} \left[ u \right]  }^{\,k}   } \\
+ -\frac{1}  { e_{1v}\,e_{2v}\,e_{3v} }  &
+  \ {\overline {\overline{ e_{1T}\,e_{2T}\,w } ^{\,j+1/2}  \;\delta _{k+1/2} \left[ u \right]  }^{\,k}   }
+\end{aligned} \right.
+\end{equation} 
+
+% ================================================================
+% Coriolis and Advection : flux form
+% ================================================================
+\section{Coriolis and Advection: flux form}
+\label{DYN_adv_cor_flux}
+%------------------------------------------nam_dynadv----------------------------------------------------
+\namdisplay{nam_dynadv} 
+%-------------------------------------------------------------------------------------------------------------
+
+In the flux form (as in the vector invariant form), the Coriolis and momentum 
+advection terms are evaluated using a leapfrog scheme, $i.e.$ the velocity 
+appearing in their expressions is centred in time (\textit{now} velocity). At the 
+lateral boundaries either free slip, no slip or partial slip boundary conditions 
+are applied following Chap.\ref{LBC}.
+
+
+%--------------------------------------------------------------------------------------------------------------
+%           Coriolis plus curvature metric terms
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Coriolis plus curvature metric terms (\textit{dynvor}) ]
+			{Coriolis plus curvature metric terms (\mdl{dynvor}) }
+\label{DYN_cor_flux}
+
+In flux form, the vorticity term reduces to a Coriolis term in which the Coriolis 
+parameter has been modified to account for the "metric" term. This altered 
+Coriolis parameter is thus discretised at $f$-points. It is given by: 
+\begin{multline} \label{Eq_dyncor_metric}
+f+\frac{1}{e_1 e_2 }\left( {v\frac{\partial e_2 }{\partial i}  -  u\frac{\partial e_1 }{\partial j}} \right)  \\
+   \equiv   f + \frac{1}{e_{1f} e_{2f} } 
+	\left( { \ \overline v ^{i+1/2}\delta _{i+1/2} \left[ {e_{2u} } \right]  
+	         -  \overline u ^{j+1/2}\delta _{j+1/2} \left[ {e_{1u} } \right]  }  \ \right)
+\end{multline} 
+
+Any of the (\ref{Eq_dynvor_ens}), (\ref{Eq_dynvor_ene}) and (\ref{Eq_dynvor_een}) 
+schemes can be used to compute the product of the Coriolis parameter and the 
+vorticity. However, the energy-conserving scheme  (\ref{Eq_dynvor_een}) has 
+exclusively been used to date. This term is evaluated using a leapfrog scheme, 
+$i.e.$ the velocity is centred in time (\textit{now} velocity).
+
+%--------------------------------------------------------------------------------------------------------------
+%           Flux form Advection term
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Flux form Advection term (\textit{dynadv}) ]
+			{Flux form Advection term (\mdl{dynadv}) }
+\label{DYN_adv_flux}
+
+The discrete expression of the advection term is given by :
+\begin{equation} \label{Eq_dynadv}
+\left\{ 
+\begin{aligned}
+\frac{1}{e_{1u}\,e_{2u}\,e_{3u}} 
+\left(      \delta _{i+1/2} \left[ \overline{e_{2u}\,e_{3u}\ u }^{i       }  \ u_T      \right]    
+          + \delta _{j       } \left[ \overline{e_{1u}\,e_{3u}\ v }^{i+1/2}  \ u_F      \right] \right.  \ \;   \\
+\left.   + \delta _{k      } \left[ \overline{e_{1w}\,e_{2w} w}^{i+1/2}  \ u_{uw} \right] \right)   \\
+\\
+\frac{1}{e_{1v}\,e_{2v}\,e_{3v}} 
+\left( 	\delta _{i      } \left[  \overline{e_{2u}\,e_{3u } \ u }^{j+1/2} \ v_F       \right] 
+         + \delta _{j+1/2} \left[ \overline{e_{1u}\,e_{3u } \ v }^{i       } \ v_T       \right] \right.  \ \, \\
+\left.  + \delta _{k     } \left[  \overline{e_{1w}\,e_{2w} \ w}^{j+1/2} \ v_{vw}  \right] \right) \\
+\end{aligned}
+\right.
+\end{equation}
+
+Two advection schemes are available: a $2^{nd}$ order centered finite 
+difference scheme, CEN2, or a $3^{rd}$ order upstream biased scheme, UBS. 
+The latter is described in \citet{Sacha2005}. The schemes are selected using 
+the namelist logicals \np{ln\_dynadv\_cen2} and \np{ln\_dynadv\_ubs}. In flux 
+form, the schemes differ by the choice of a space and time interpolation to 
+define the value of $u$ and $v$ at the centre of each face of $u$- and $v$-cells, 
+$i.e.$ at the $T$-, $f$-, and $uw$-points for $u$ and at the $f$-, $T$- and 
+$vw$-points for $v$. 
+
+%-------------------------------------------------------------
+%                 2nd order centred scheme
+%-------------------------------------------------------------
+\subsubsection{$2^{nd}$ order centred scheme (cen2) (\np{ln\_dynadv\_cen2}=.true.)}
+\label{DYN_adv_cen2}
+
+In the centered $2^{nd}$ order formulation, the velocity is evaluated as the 
+mean of the two neighbouring points :
+\begin{equation} \label{Eq_dynadv_cen2}
+\left\{ 		\begin{aligned}
+ u_T^{cen2} &=\overline u^{i }		\quad & 	
+  u_F^{cen2} &=\overline u^{j+1/2}		\quad &
+ u_{uw}^{cen2} &=\overline u^{k+1/2}      \\
+ v_F^{cen2} &=\overline v ^{i+1/2}		\quad &
+ v_F^{cen2} &=\overline v^j		\quad &
+ v_{vw}^{cen2} &=\overline v ^{k+1/2}      \\
+\end{aligned} \right.
+\end{equation} 
+
+The scheme is non diffusive (i.e. conserves the kinetic energy) but dispersive 
+($i.e.$ it may create false extrema). It is therefore notoriously noisy and must be 
+used in conjunction with an explicit diffusion operator to produce a sensible solution. 
+The associated time-stepping is performed using a leapfrog scheme in conjunction 
+with an Asselin time-filter, so $u$ and $v$ are the \emph{now} velocities.
+
+%-------------------------------------------------------------
+%                 UBS scheme
+%-------------------------------------------------------------
+\subsubsection{Upstream Biased Scheme (UBS) (\np{ln\_dynadv\_ubs}=.true.)}
+\label{DYN_adv_ubs}
+
+The UBS advection scheme is an upstream biased third order scheme based on 
+an upstream-biased parabolic interpolation. For example, the evaluation of 
+$u_T^{ubs} $ is done as follows:
+\begin{equation} \label{Eq_dynadv_ubs}
+u_T^{ubs} =\overline u ^i-\;\frac{1}{6} 	\begin{cases}
+		u"_{i-1/2}& 	\text{if $\ \overline{e_{2u}\,e_{3u} \ u}^i  \geqslant 0$ } 	\\
+		u"_{i+1/2}& 	\text{if $\ \overline{e_{2u}\,e_{3u} \ u}^i  < 0$ }
+\end{cases}
+\end{equation}
+where $u"_{i+1/2} =\delta _{i+1/2} \left[ {\delta _i \left[ u \right]} \right]$. This results 
+in a dissipatively dominant ($i.e.$ hyper-diffusive) truncation error \citep{Sacha2005}. 
+The overall performance of the advection scheme is similar to that reported in 
+\citet{Farrow1995}. It is a relatively good compromise between accuracy and 
+smoothness. It is not a \emph{positive} scheme, meaning that false extrema are 
+permitted. But the amplitudes of the false extrema are significantly reduced over 
+those in the centred second order method. 
+
+The UBS scheme is not used in all directions. In the vertical, the centred $2^{nd}$ 
+order evaluation of the advection is preferred, $i.e.$ $u_{uw}^{ubs}$ and 
+$u_{vw}^{ubs}$ in \eqref{Eq_dynadv_cen2} are used. UBS is diffusive and is 
+associated with vertical mixing of momentum. \gmcomment{ gm  pursue the 
+sentence:Since vertical mixing of momentum is a source term of the TKE equation...  }
+
+For stability reasons,  the first term in (\ref{Eq_dynadv_ubs}), which corresponds 
+to a second order centred scheme, is evaluated using the \textit{now} velocity 
+(centred in time), while the second term, which is the diffusive part of the scheme, 
+is evaluated using the \textit{before} velocity (forward in time). This is discussed 
+by \citet{Webb1998} in the context of the Quick advection scheme.
+
+Note that the UBS and Quadratic Upstream Interpolation for Convective Kinematics 
+(QUICK) schemes only differ by one coefficient. Substituting $1/6$ with $1/8$ in 
+(\ref{Eq_dynadv_ubs}) leads to the QUICK advection scheme \citep{Webb1998}. 
+This option is not available through a namelist parameter, since the $1/6$ coefficient 
+is hard coded. Nevertheless it is quite easy to make the substitution in 
+\mdl{dynadv\_ubs} module and obtain a QUICK scheme.
+
+Note also that in the current version of \mdl{dynadv\_ubs}, there is also the 
+possibility of using a $4^{th}$ order evaluation of the advective velocity as in 
+ROMS. This is an error and should be suppressed soon.
+%%%
+\gmcomment{action :  this have to be done}
+%%%
+
+% ================================================================
+%           Hydrostatic pressure gradient term
+% ================================================================
+\section  [Hydrostatic pressure gradient (\textit{dynhpg})]
+		{Hydrostatic pressure gradient (\mdl{dynhpg})}
+\label{DYN_hpg}
+%------------------------------------------nam_dynhpg---------------------------------------------------
+\namdisplay{nam_dynhpg} 
+\namdisplay{namflg} 
+%-------------------------------------------------------------------------------------------------------------
+%%%
+\gmcomment{Suppress the namflg namelist and incorporate it in the namhpg namelist}
+%%%
+
+The key distinction between the different algorithms used for the hydrostatic 
+pressure gradient is the vertical coordinate used, since HPG is a \emph{horizontal} 
+pressure gradient, $i.e.$ computed along geopotential surfaces. As a result, any 
+tilt of the surface of the computational levels will require a specific treatment to 
+compute the hydrostatic pressure gradient.
+
+The hydrostatic pressure gradient term is evaluated either using a leapfrog scheme, 
+$i.e.$ the density appearing in its expression is centred in time (\emph{now} rho), or 
+a semi-implcit scheme. At the lateral boundaries either free slip, no slip or partial slip 
+boundary conditions are applied.
+
+%--------------------------------------------------------------------------------------------------------------
+%           z-coordinate with full step
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [$z$-coordinate with full step (\np{ln\_dynhpg\_zco}) ]
+			{$z$-coordinate with full step (\np{ln\_dynhpg\_zco}=.true.)}
+\label{DYN_hpg_zco}
+
+The hydrostatic pressure can be obtained by integrating the hydrostatic equation 
+vertically from the surface. However, the pressure is large at great depth while its 
+horizontal gradient is several orders of magnitude smaller. This may lead to large 
+truncation errors in the pressure gradient terms. Thus, the two horizontal components 
+of the hydrostatic pressure gradient are computed directly as follows:
+
+for $k=km$ (surface layer, $jk=1$ in the code)
+\begin{equation} \label{Eq_dynhpg_zco_surf}
+\left\{ \begin{aligned}
+					\left. \delta _{i+1/2} \left[  p^h 			 \right] \right|_{k=km} 
+&= \frac{1}{2} g \ 	\left. \delta _{i+1/2} \left[  e_{3w} \ \rho \right] \right|_{k=km}   \\
+     					\left. \delta _{j+1/2} \left[  p^h  			 \right] \right|_{k=km} 
+&= \frac{1}{2} g \ 	\left. \delta _{j+1/2} \left[  e_{3w} \ \rho \right] \right|_{k=km}   \\
+\end{aligned} \right.
+\end{equation} 
+
+for $1<k<km$ (interior layer)
+\begin{equation} \label{Eq_dynhpg_zco}
+\left\{ \begin{aligned}
+					\left. \delta _{i+1/2} \left[  p^h 			 \right] \right|_{k} 
+&=					\left. \delta _{i+1/2} \left[  p^h 			 \right] \right|_{k-1} 
++    \frac{1}{2}\;g\;	\left. \delta _{i+1/2} \left[  e_{3w} \ \overline {\rho}^{k+1/2} \right] \right|_{k}   \\
+     					\left. \delta _{j+1/2} \left[  p^h  			 \right] \right|_{k} 
+&=     				\left. \delta _{j+1/2} \left[  p^h  			 \right] \right|_{k-1} 
++    \frac{1}{2}\;g\;	\left. \delta _{j+1/2} \left[  e_{3w} \ \overline {\rho}^{k+1/2} \right] \right|_{k}   \\
+\end{aligned} \right.
+\end{equation} 
+
+Note that the $1/2$ factor in (\ref{Eq_dynhpg_zco_surf}) is adequate because of 
+the definition of $e_{3w}$ as the vertical derivative of the scale factor at the surface 
+level ($z=0)$. 
+
+%--------------------------------------------------------------------------------------------------------------
+%           z-coordinate with partial step
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [$z$-coordinate with partial step (\np{ln\_dynhpg\_zps})]
+			{$z$-coordinate with partial step (\np{ln\_dynhpg\_zps}=.true.)}
+\label{DYN_hpg_zps}
+
+With partial bottom cells, tracers in horizontally adjacent cells generally live at 
+different depths. Before taking horizontal gradients between these tracer points, 
+a linear interpolation is used to approximate the deeper tracer as if it actually lived 
+at the depth of the shallower tracer point. 
+
+Apart from this modification, the horizontal hydrostatic pressure gradient evaluated 
+in the $z$-coordinate with partial step is exactly as in the pure $z$-coordinate case. 
+As explained in detail in section \S\ref{TRA_zpshde}, the nonlinearity of pressure 
+effects in the equation of state is such that it is better to interpolate temperature and 
+salinity vertically before computing the density. Horizontal gradients of temperature 
+and salinity are needed for the TRA modules, which is the reason why the horizontal 
+gradients of density at the deepest model level are computed in module \mdl{zpsdhe} 
+located in the TRA directory and described in \S\ref{TRA_zpshde}.
+
+%--------------------------------------------------------------------------------------------------------------
+%           s- and s-z-coordinates
+%--------------------------------------------------------------------------------------------------------------
+\subsection{$s$- and $z$-$s$-coordinates}
+\label{DYN_hpg_sco}
+
+Pressure gradient formulations in $s$-coordinate have been the subject of a vast 
+literature ($e.g.$, \citet{Song1998, Sacha2003}). A number of different pressure 
+gradient options are coded, but they are not yet fully documented or tested. 
+
+$\bullet$ Traditional coding (see for example \citet{Madec1996}: (\np{ln\_dynhpg\_sco}=.true., 
+\np{ln\_dynhpg\_hel}=.true.)
+\begin{equation} \label{Eq_dynhpg_sco}
+\left\{ \begin{aligned}
+ - \frac{1}    					{\rho_o \, e_{1u}} \;	\delta _{i+1/2} \left[  p^h  \right] 
++ \frac{g\; \overline {\rho}^{i+1/2}}	{\rho_o \, e_{1u}} \;	\delta _{i+1/2} \left[  z_T  \right]    \\
+ - \frac{1}    					{\rho_o \, e_{2v}} \;	\delta _{j+1/2} \left[  p^h  \right]  
++ \frac{g\; \overline {\rho}^{j+1/2}}	{\rho_o \, e_{2v}} \;	\delta _{j+1/2} \left[  z_T  \right]    \\
+\end{aligned} \right.
+\end{equation} 
+
+Where the first term is the pressure gradient along coordinates, computed as in 
+\eqref{Eq_dynhpg_zco_surf} - \eqref{Eq_dynhpg_zco}, and $z_T$ is the depth of 
+the $T$-point evaluated from the sum of the vertical scale factors at the $w$-point 
+($e_{3w}$). The version \np{ln\_dynhpg\_hel}=.true. has been added by Aike 
+Beckmann and involves a redefinition of the relative position of $T$-points relative 
+to $w$-points. 
+
+$\bullet$ Weighted density Jacobian (WDJ) \citep{Song1998} (\np{ln\_dynhpg\_wdj}=.true.)
+
+$\bullet$ Density Jacobian with cubic polynomial scheme (DJC) \citep{Sacha2003} 
+(\np{ln\_dynhpg\_djc}=.true.)
+
+$\bullet$ Rotated axes scheme (rot) \citep{Thiem2006} (\np{ln\_dynhpg\_rot}=.true.)
+
+Note that expression \eqref{Eq_dynhpg_sco} is used when the variable volume 
+formulation is activated (\key{vvl}) because in that case, even with a flat bottom, 
+the coordinate surfaces are not horizontal but follow the free surface 
+\citep{Levier2007}. The other pressure gradient options are not yet available.
+
+%--------------------------------------------------------------------------------------------------------------
+%           Time-scheme
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Time-scheme (\np{ln\_dynhpg\_imp}) ]
+			{Time-scheme (\np{ln\_dynhpg\_imp}=.true./.false.)}
+\label{DYN_hpg_imp}
+
+The default time differencing scheme used for the horizontal pressure gradient is 
+a leapfrog scheme and therefore the density used in all discrete expressions given 
+above is the  \textit{now} density, computed from the \textit{now} temperature and 
+salinity. In some specific cases (usually high resolution simulations over an ocean 
+domain which includes weakly stratified regions) the physical phenomenum that 
+controls the time-step is internal gravity waves (IGWs). A semi-implicit scheme for 
+doubling the stability limit associated with IGWs can be used \citep{Brown1978, 
+Maltrud1998}. It involves the evaluation of the hydrostatic pressure gradient as an 
+average over the three time levels $t-\Delta t$, $t$, and $t+\Delta t$ ($i.e.$  
+\textit{before},  \textit{now} and  \textit{after} time-steps), rather than at central 
+time level $t$ only, as in the standard leapfrog scheme. 
+
+$\bullet$ leapfrog scheme (\np{ln\_dynhpg\_imp}=.true.):
+
+\begin{equation} \label{Eq_dynhpg_lf}
+\frac{u^{t+\Delta t}-u^{t-\Delta t}}{2\Delta t}
+=\;\cdots \;-\frac{1}{\rho _o \,e_{1u} }\delta _{i+1/2} \left[ {p_h^t } \right]
+\end{equation}
+
+$\bullet$ semi-implicit scheme (\np{ln\_dynhpg\_imp}=.true.):
+\begin{equation} \label{Eq_dynhpg_imp}
+\frac{u^{t+\Delta t}-u^{t-\Delta t}}{2\Delta t}
+=\;\cdots \;-\frac{1}{\rho _o \,e_{1u} } \delta _{i+1/2} \left[ \frac{ p_h^{t+\Delta t} +2p_h^t 
++p_h^{t-\Delta t} } { 4 }  \right]
+\end{equation}
+
+The semi-implicit time scheme \eqref{Eq_dynhpg_imp} is made possible without 
+significant additional computation since the density can be updated to time level 
+$t+\Delta t$ before computing the horizontal hydrostatic pressure gradient. It can 
+be easily shown that the stability limit associated with the hydrostatic pressure 
+gradient doubles using \eqref{Eq_dynhpg_imp} compared to that using the 
+standard leapfrog scheme \eqref{Eq_dynhpg_lf}. Note that \eqref{Eq_dynhpg_imp} 
+is equivalent to applying a time filter to the pressure gradient to eliminate high 
+frequency IGWs. Obviously, when using \eqref{Eq_dynhpg_imp}, the doubling of 
+the time-step is achievable only if no other factors control the time-step, such as 
+the stability limits associated with advection or diffusion.
+
+In practice, the semi-implicit scheme is used when \np{ln\_dynhpg\_imp}=.true.. 
+In this case, we choose to apply the time filter to temperature and salinity used in 
+the equation of state, instead of applying it to the hydrostatic pressure or to the 
+density, so that no additional storage array has to be defined. The density used to 
+compute the hydrostatic pressure gradient (whatever the formulation) is evaluated 
+as follows:
+\begin{equation} \label{Eq_rho_flt}
+	\rho^t = \rho( \widetilde{T},\widetilde {S},z_T)
+ \quad	  \text{with}	\quad 
+	\widetilde{\,\cdot\,} = \frac{  \,\cdot\,^{t+\Delta t} +2 \,\,\cdot\,^t + \,\cdot\,^{t-\Delta t}  } {4}
+\end{equation}
+\gmcomment{STEVEN: bullets look odd in this, could use X}
+
+Note that in the semi-implicit case, it is necessary to save the filtered density, an 
+extra three-dimensional field, in the restart file to restart the model with exact 
+reproducibility. This option is controlled by the namelist parameter 
+\np{nn\_dynhpg\_rst}=.true..
+
+% ================================================================
+% Surface Pressure Gradient
+% ================================================================
+\section  [Surface pressure gradient (\textit{dynspg}) ]
+		{Surface pressure gradient (\mdl{dynspg})}
+\label{DYN_hpg_spg}
+%-----------------------------------------nam_dynspg----------------------------------------------------
+\namdisplay{nam_dynspg} 
+%------------------------------------------------------------------------------------------------------------
+
+The form of the surface pressure gradient term is dependent on the representation 
+of the free surface (\S\ref{PE_hor_pg}). The main distinction is between the fixed 
+volume case (linear free surface or rigid lid) and the variable volume case 
+(nonlinear free surface, \key{vvl} is defined). In the linear free surface case 
+(\S\ref{PE_free_surface}) and the rigid lid case (\S\ref{PE_rigid_lid}), the vertical 
+scale factors $e_{3}$ are fixed in time, whilst in the nonlinear case 
+(\S\ref{PE_free_surface}) they are time-dependent. With both linear and nonlinear 
+free surface, external gravity waves are allowed in the equations, which imposes 
+a very small time step when an explicit time stepping is used. Two methods are 
+proposed to allow a longer time step for the three-dimensional equations: the 
+filtered free surface method, which involves a modification of the continuous 
+equations (see \eqref{Eq_PE_flt}), and the split-explicit free surface method 
+described below. The extra term introduced in the filtered method is calculated 
+implicitly, so that the update of the $next$ velocities is done in module 
+\mdl{dynspg\_flt} and not in \mdl{dynnxt}.
+
+%--------------------------------------------------------------------------------------------------------------
+% Linear free surface formulation
+%--------------------------------------------------------------------------------------------------------------
+\subsection{Linear free surface formulation (\key{exp} or \textbf{\_ts} or \textbf{\_flt})}
+\label{DYN_spg_linear}
+
+In the linear free surface formulation, the sea surface height is assumed to be 
+small compared to the thickness of the ocean levels, so that $(a)$ the time 
+evolution of the sea surface height becomes a linear equation, and $(b)$ the 
+thickness of the ocean levels is assumed to be constant with time. 
+As mentioned in (\S\ref{PE_free_surface}) the linearization affects the 
+conservation of tracers. 
+
+%-------------------------------------------------------------
+% Explicit
+%-------------------------------------------------------------
+\subsubsection{Explicit (\key{dynspg\_exp})}
+\label{DYN_spg_exp}
+
+In the explicit free surface formulation, the model time step is chosen to be 
+small enough to describe the external gravity waves (typically a few tens of 
+seconds). The sea surface height is given by :
+\begin{equation} \label{Eq_dynspg_ssh}
+\frac{\partial \eta }{\partial t}\equiv \frac{\text{EMP}}{\rho _w }+\frac{1}{e_{1T} 
+e_{2T} }\sum\limits_k {\left( {\delta _i \left[ {e_{2u} e_{3u} u} 
+\right]+\delta _j \left[ {e_{1v} e_{3v} v} \right]} \right)} 
+\end{equation}
+where EMP is the surface freshwater budget, expressed in Kg/m$^2$/s 
+(which is equal to mm/s), and $\rho _w$=1,000~Kg/m$^3$ is the volumic 
+mass of pure water. If river runoff is expressed as a surface freshwater flux 
+(see \S\ref{SBC}) then EMP can be written as the evaporation minus 
+precipitation, minus the river runoff. The sea-surface height is evaluated 
+using a leapfrog scheme in combination with an Asselin time filter, $i.e.$ 
+the velocity appearing in \eqref{Eq_dynspg_ssh} is centred in time 
+(\textit{now} velocity). 
+
+The surface pressure gradient, also evaluated using a leap-frog scheme, is 
+then simply given by :
+\begin{equation} \label{Eq_dynspg_exp}
+\left\{ \begin{aligned}
+ - \frac{1}{e_{1u}} \;	\delta _{i+1/2} \left[  \,\eta\,  \right] 	\\
+ - \frac{1}{e_{2v}} \;	\delta _{j+1/2} \left[  \,\eta\,  \right]  
+\end{aligned} \right.
+\end{equation} 
+
+Consistent with the linearization, a factor of $\left. \rho \right|_{k=1} / \rho _o$ 
+is omitted in \eqref{Eq_dynspg_exp}. 
+
+%-------------------------------------------------------------
+% Split-explicit time-stepping
+%-------------------------------------------------------------
+\subsubsection{Split-explicit time-stepping (\key{dynspg\_ts})}
+\label{DYN_spg_ts}
+%--------------------------------------------namdom----------------------------------------------------
+\namdisplay{namdom} 
+%--------------------------------------------------------------------------------------------------------------
+
+The split-explicit free surface formulation used in \NEMO follows the one 
+proposed by \citet{Griffies2004}. The general idea is to solve the free surface 
+equation with a small time step \np{rdtbt}, while the three dimensional 
+prognostic variables are solved with a longer time step that is a multiple of 
+\np{rdtbt} (Fig.\ref {Fig_DYN_dynspg_ts}). 
+
+%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+\begin{figure}[!t] \label{Fig_DYN_dynspg_ts}
+\begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_DYN_dynspg_ts.pdf}
+\caption{Schematic of the split-explicit time stepping scheme for the external 
+and internal modes. Time increases to the right. 
+Internal mode time steps (which are also the model time steps) are denoted 
+by $t-\Delta t$, $t, t+\Delta t$, and $t+2\Delta t$. 
+The curved line represents a leap-frog time step, and the smaller time 
+steps $N \Delta t_e=\frac{3}{2}\Delta t$ are denoted by the zig-zag line. 
+The vertically integrated forcing \textbf{M}(t) computed at the model time step $t$ 
+represents the interaction between the external and internal motions. 
+While keeping \textbf{M} and freshwater forcing field fixed, a leap-frog 
+integration carries the external mode variables (surface height and vertically 
+integrated velocity) from $t$ to $t+\frac{3}{2} \Delta t$ using N external time 
+steps of length $\Delta t_e$. Time averaging the external fields over the 
+$\frac{2}{3}N+1$ time steps (endpoints included) centers the vertically integrated 
+velocity and the sea surface height at the model timestep $t+\Delta t$. 
+These averaged values are used to update \textbf{M}(t) with both the surface 
+pressure gradient and the Coriolis force, therefore providing the $t+\Delta t$
+velocity.  The model time stepping scheme can then be achieved by a baroclinic 
+leap-frog time step that carries the surface height from $t-\Delta t$ to $t+\Delta t$.  }
+\end{center}
+\end{figure}
+%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+
+The split-explicit formulation has a damping effect on external gravity waves, 
+which is weaker damping than for the filtered free surface but still significant as 
+shown by \citet{Levier2007} in the case of an analytical barotropic Kelvin wave. 
+
+%-------------------------------------------------------------
+% Filtered formulation 
+%-------------------------------------------------------------
+\subsubsection{Filtered formulation (\key{dynspg\_flt})}
+\label{DYN_spg_flt}
+
+The filtered formulation follows the \citet{Roullet2000} implementation. The extra 
+term introduced in the equations (see {\S}I.2.2) is solved implicitly. The elliptic 
+solvers available in the code are documented in \S\ref{MISC}. The amplitude of 
+the extra term is given by the namelist variable \np{rnu}. The default value is 1, 
+as recommended by \citet{Roullet2000}
+
+\gmcomment{\np{rnu}=1 to be suppressed from namelist !}
+
+%-------------------------------------------------------------
+% Non-linear free surface formulation 
+%-------------------------------------------------------------
+\subsection{Non-linear free surface formulation (\key{vvl})}
+\label{DYN_spg_vvl}
+
+In the non-linear free surface formulation, the variations of volume are fully 
+taken into account. This option is presented in a report \citep{Levier2007} 
+available on the \NEMO web site. The three time-stepping methods (explicit, 
+split-explicit and filtered) are the same as in \S\ref{DYN_spg_linear} except 
+that the ocean depth is now time-dependent. In particular, this means that 
+in the filtered case, the matrix to be inverted has to be recomputed at each 
+time-step.
+
+%--------------------------------------------------------------------------------------------------------------
+%           Rigid-lid formulation
+%--------------------------------------------------------------------------------------------------------------
+\subsection{Rigid-lid formulation (\key{dynspg\_rl})}
+\label{DYN_spg_rl}
+
+With the rigid lid formulation, an elliptic equation has to be solved for 
+the barotropic streamfunction. For consistency this equation is obtained by 
+taking the discrete curl of the discrete vertical sum of the discrete 
+momentum equation: 
+\begin{equation}\label{Eq_dynspg_rl}
+\frac{1}{\rho _o }\nabla _h p_s \equiv \left( {{\begin{array}{*{20}c}
+ {\overline M_u +\frac{1}{H\;e_2 } \delta_ j \left[ \partial_t \psi \right]}		 \\
+ \\
+ {\overline M_v -\frac{1}{H\;e_1 }  \delta_i  \left[ \partial_t \psi \right]} 		 \\
+\end{array} }} \right)
+\end{equation}
+
+Here ${\rm {\bf M}}= \left( M_u,M_v \right)$ represents the collected 
+contributions of nonlinear, viscous and hydrostatic pressure gradient terms in 
+\eqref{Eq_PE_dyn} and the overbar indicates a vertical average over the 
+whole water column (i.e. from $z=-H$, the ocean bottom, to $z=0$, the rigid-lid). 
+The time derivative of $\psi$ is the solution of an elliptic equation:
+\begin{multline} \label{Eq_bsf}
+   \delta_{i+1/2} \left[ \frac{e_{2v}}{H_v\;e_{1v}} \delta_{i} \left[  \partial_t \psi \right] \right]
++ \delta_{j+1/2} \left[ \frac{e_{1u}}{H_u\;e_{2u}} \delta_{j} \left[  \partial_t \psi \right] \right]
+\\ =
+  \delta_{i+1/2} \left[ e_{2v} M_v  \right]
+- \delta_{j+1/2} \left[ e_{1u} M_u  \right]
+\end{multline}
+
+The elliptic solvers available in the code are documented in \S\ref{MISC}). 
+The boundary conditions must be given on all separate landmasses (islands), 
+which is done by integrating the vorticity equation around each island. This 
+requires identifying each island in the bathymetry file, a cumbersome task. 
+This explains why the rigid lid option is not recommended with complex 
+domains such as the global ocean. Parameters jpisl (number of islands) and 
+jpnisl (maximum number of points per island) of the \hf{par\_oce} file are 
+related to this option.
+
+
+% ================================================================
+% Lateral diffusion term
+% ================================================================
+\section  [Lateral diffusion term (\textit{dynldf})]
+		{Lateral diffusion term (\mdl{dynldf})}
+\label{DYN_ldf}
+%------------------------------------------nam_dynldf----------------------------------------------------
+\namdisplay{nam_dynldf} 
+%-------------------------------------------------------------------------------------------------------------
+
+The options available for lateral diffusion are for the choice of  laplacian 
+(rotated or not) or biharmonic operators. The coefficients may be constant 
+or spatially variable; the description of the coefficients is found in the chapter 
+on lateralphysics (Chap.\ref{LDF}). The lateral diffusion of momentum is 
+evaluated using a forward scheme, i.e. the velocity appearing in its expression 
+is the \textit{before} velocity in time, except for the pure vertical component 
+that appears when a tensor of rotation is used. This latter term is solved 
+implicitly together with the vertical diffusion term (see \S\ref{DOM_nxt}) 
+
+At the lateral boundaries either free slip, no slip or partial slip boundary 
+conditions are applied according to the user's choice (see Chap.\ref{LBC}).
+
+% ================================================================
+\subsection   [Iso-level laplacian operator (\np{ln\_dynldf\_lap}) ]
+			{Iso-level laplacian operator (\np{ln\_dynldf\_lap}=.true.)}
+\label{DYN_ldf_lap}
+
+For lateral iso-level diffusion, the discrete operator is: 
+\begin{equation} \label{Eq_dynldf_lap}
+\left\{ \begin{aligned}
+ D_u^{l{\rm {\bf U}}} =\frac{1}{e_{1u} }\delta _{i+1/2} \left[ {A_T^{lm} 
+\;\chi } \right]-\frac{1}{e_{2u} {\kern 1pt}e_{3u} }\delta _j \left[ 
+{A_f^{lm} \;e_{3f} \zeta } \right] \\ 
+\\
+ D_v^{l{\rm {\bf U}}} =\frac{1}{e_{2v} }\delta _{j+1/2} \left[ {A_T^{lm} 
+\;\chi } \right]+\frac{1}{e_{1v} {\kern 1pt}e_{3v} }\delta _i \left[ 
+{A_f^{lm} \;e_{3f} \zeta } \right] \\ 
+\end{aligned} \right.
+\end{equation} 
+
+As explained in \S\ref{PE_ldf}, this formulation (as the gradient of a divergence 
+and curl of the vorticity) preserves symmetry and ensures a complete 
+separation between the vorticity and divergence parts. Note that in the full step 
+$z$-coordinate (\key{zco} is defined), $e_{3u} =e_{3v} =e_{3f}$ so that they 
+cancel in the rotational part of \eqref{Eq_dynldf_lap}.
+
+%--------------------------------------------------------------------------------------------------------------
+%           Rotated laplacian operator
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Rotated laplacian operator (\np{ln\_dynldf\_iso}) ]
+			{Rotated laplacian operator (\np{ln\_dynldf\_iso}=.true.)}
+\label{DYN_ldf_iso}
+
+A rotation of the lateral momentum diffusive operator is needed in several cases: 
+for iso-neutral diffusion in $z$-coordinate (\np{ln\_dynldf\_iso}=.true.) and for 
+either iso-neutral (\np{ln\_dynldf\_iso}=.true.) or geopotential 
+(\np{ln\_dynldf\_hor}=.true.) diffusion in $s$-coordinate. In the partial step 
+case, coordinates are horizontal excepted at the deepest level and no 
+rotation is performed when \np{ln\_dynldf\_hor}=.true.. The diffusive operator 
+is defined simply as the divergence of down gradient momentum fluxes on each 
+momentum component. It must be emphasized that this formulation ignores 
+constraints on the stress tensor such as symmetry. The resulting discrete 
+representation is:
+\begin{equation} \label{Eq_dyn_ldf_iso}
+\begin{split}
+ D_u^{l\textbf{U}} &= \frac{1}{e_{1u} \, e_{2u} \, e_{3u} }	\\
+&  \left\{\quad  {\delta _{i+1/2} \left[ {A_T^{lm}  \left( 
+	 {\frac{e_{2T} \; e_{3T} }{e_{1T} } \,\delta _{i}[u]
+	-e_{2T} \; r_{1T} \,\overline{\overline {\delta _{k+1/2}[u]}}^{\,i,\,k}}
+ \right)} \right]} 	\right.
+\\ 
+& \qquad +\ \delta_j \left[ {A_f^{lm} \left( {\frac{e_{1f}\,e_{3f} }{e_{2f} 
+}\,\delta _{j+1/2} [u] - e_{1f}\, r_{2f} 
+\,\overline{\overline {\delta _{k+1/2} [u]}} ^{\,j+1/2,\,k}} 
+\right)} \right] 
+\\ 
+&\qquad +\ \delta_k \left[ {A_{uw}^{lm} \left( {-e_{2u} \, r_{1uw} \,\overline{\overline 
+{\delta_{i+1/2} [u]}}^{\,i+1/2,\,k+1/2} } 
+\right.} \right. 
+\\ 
+&  \ \qquad \qquad \qquad \quad\ 
+- e_{1u} \, r_{2uw} \,\overline{\overline {\delta_{j+1/2} [u]}} ^{\,j,\,k+1/2}
+\\ 
+& \left. {\left. { \ \qquad \qquad \qquad \ \ \ \left. {\ 
++\frac{e_{1u}\, e_{2u} }{e_{3uw} }\,\left( {r_{1uw}^2+r_{2uw}^2} 
+\right)\,\delta_{k+1/2} [u]} \right)} \right]\;\;\;} \right\} 
+\\
+\\
+ D_v^{l\textbf{V}} &= \frac{1}{e_{1v} \, e_{2v} \, e_{3v} }    \\
+&  \left\{\quad  {\delta _{i+1/2} \left[ {A_f^{lm}  \left( 
+	 {\frac{e_{2f} \; e_{3f} }{e_{1f} } \,\delta _{i+1/2}[v]
+	-e_{2f} \; r_{1f} \,\overline{\overline {\delta _{k+1/2}[v]}}^{\,i+1/2,\,k}}
+ \right)} \right]} 	\right.
+\\ 
+& \qquad +\ \delta_j \left[ {A_T^{lm} \left( {\frac{e_{1T}\,e_{3T} }{e_{2T} 
+}\,\delta _{j} [v] - e_{1T}\, r_{2T} 
+\,\overline{\overline {\delta _{k+1/2} [v]}} ^{\,j,\,k}} 
+\right)} \right] 
+\\ 
+& \qquad +\ \delta_k \left[ {A_{vw}^{lm} \left( {-e_{2v} \, r_{1vw} \,\overline{\overline 
+{\delta_{i+1/2} [v]}}^{\,i+1/2,\,k+1/2} }\right.} \right. 
+\\
+&  \ \qquad \qquad \qquad \quad\ 
+- e_{1v} \, r_{2vw} \,\overline{\overline {\delta_{j+1/2} [v]}} ^{\,j+1/2,\,k+1/2}
+\\ 
+& \left. {\left. { \ \qquad \qquad \qquad \ \ \ \left. {\ 
++\frac{e_{1v}\, e_{2v} }{e_{3vw} }\,\left( {r_{1vw}^2+r_{2vw}^2} 
+\right)\,\delta_{k+1/2} [v]} \right)} \right]\;\;\;} \right\} 
+ \end{split}
+\end{equation}
+where $r_1$ and $r_2$ are the slopes between the surface along which the 
+diffusive operator acts and the surface of computation ($z$- or $s$-surfaces). 
+The way these slopes are evaluated is given in the lateral physics chapter 
+(Chap.\ref{LDF}).
+
+%--------------------------------------------------------------------------------------------------------------
+%           Iso-level bilaplacian operator
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Iso-level bilaplacian operator (\np{ln\_dynldf\_bilap})]
+			{Iso-level bilaplacian operator (\np{ln\_dynldf\_bilap}=.true.)}
+\label{DYN_ldf_bilap}
+
+The lateral fourth order operator formulation on momentum is obtained by 
+applying \eqref{Eq_dynldf_lap} twice. It requires an additional assumption on 
+boundary conditions: the first derivative term normal to the coast depends on 
+the free or no-slip lateral boundary conditions chosen, while the third 
+derivative terms normal to the coast are set to zero (see Chap.\ref{LBC}).
+%%%
+\gmcomment{add a remark on the the change in the position of the coefficient}
+%%%
+
+% ================================================================
+%           Vertical diffusion term
+% ================================================================
+\section  [Vertical diffusion term (\mdl{dynzdf})]
+		{Vertical diffusion term (\mdl{dynzdf})}
+\label{DYN_zdf}
+%----------------------------------------------namzdf------------------------------------------------------
+\namdisplay{namzdf} 
+%-------------------------------------------------------------------------------------------------------------
+
+The large vertical diffusion coefficient found in the surface mixed layer together 
+with high vertical resolution implies that in the case of explicit time stepping there 
+would be too restrictive a constraint on the time step. Two time stepping schemes 
+can be used for the vertical diffusion term : $(a)$ a forward time differencing 
+scheme (\np{ln\_zdfexp}=.true.) using a time splitting technique 
+(\np{n\_zdfexp} $>$ 1) or $(b)$ a backward (or implicit) time differencing scheme 
+(\np{ln\_zdfexp}=.false.) (see \S\ref{DOM_nxt}). Note that namelist variables 
+\np{ln\_zdfexp} and \np{n\_zdfexp} apply to both tracers and dynamics. 
+
+The formulation of the vertical subgrid scale physics is the same whatever 
+the vertical coordinate is. The vertical diffusion operators given by 
+\eqref{Eq_PE_zdf} take the following semi-discrete space form:
+\begin{equation} \label{Eq_dynzdf}
+\left\{   \begin{aligned}
+D_u^{vm} &\equiv \frac{1}{e_{3u}} \ \delta _k \left[ \frac{A_{uw}^{vm} }{e_{3uw} }
+                              \ \delta _{k+1/2} [\,u\,]         \right]     \\
+\\
+D_v^{vm} &\equiv \frac{1}{e_{3v}} \ \delta _k \left[ \frac{A_{vw}^{vm} }{e_{3vw} }
+                              \ \delta _{k+1/2} [\,v\,]         \right]
+\end{aligned}   \right.
+\end{equation} 
+where $A_{uw}^{vm} $ and $A_{vw}^{vm} $ are the vertical eddy viscosity and 
+diffusivity coefficients. The way these coefficients are evaluated 
+depends on the vertical physics used (see \S\ref{ZDF}).
+
+The surface boundary condition on momentum is given by the stress exerted by 
+the wind. At the surface, the momentum fluxes are prescribed as the boundary 
+condition on the vertical turbulent momentum fluxes,
+\begin{equation} \label{Eq_dynzdf_sbc}
+\left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{z=1}
+	 = \frac{1}{\rho _o} \binom{\tau _u}{\tau _v }
+\end{equation}
+where $\left( \tau _u ,\tau _v \right)$ are the two components of the wind stress 
+vector in the (\textbf{i},\textbf{j}) coordinate system. The high mixing coefficients 
+in the surface mixed layer ensure that the surface wind stress is distributed in 
+the vertical over the mixed layer depth. If the vertical mixing coefficient 
+is small (when no mixed layer scheme is used) the surface stress enters only 
+the top model level, as a body force. The surface wind stress is calculated 
+in the surface module routines (SBC, see Chap.\ref{SBC})
+
+The turbulent flux of momentum at the bottom of the ocean is specified through 
+a bottom friction parameterisation (see \S\ref{ZDF_bfr})
+
+% ================================================================
+% External Forcing
+% ================================================================
+\section{External Forcings}
+\label{DYN_forcing}
+
+Besides the surface and bottom stresses (see the above section) which are 
+introduced as boundary conditions on the vertical mixing, two other forcings 
+enter the dynamical equations. 
+
+One is the effect of atmospheric pressure on the ocean dynamics (to be 
+introduced later). 
+
+Another forcing term is the tidal potential, which will be introduced in the 
+reference version soon. 
+
+% ================================================================
+% Time evolution term 
+% ================================================================
+\section  [Time evolution term (\textit{dynnxt})]
+		{Time evolution term (\mdl{dynnxt})}
+\label{DYN_nxt}
+
+%----------------------------------------------namdom----------------------------------------------------
+\namdisplay{namdom} 
+%-------------------------------------------------------------------------------------------------------------
+
+The general framework for dynamics time stepping is a leap-frog scheme, 
+$i.e.$ a three level centred time scheme associated with an Asselin time filter 
+(cf. \S\ref{DOM_nxt})
+\begin{equation} \label{Eq_dynnxt}
+\begin{split}
+&u^{t+\Delta t} = u^{t-\Delta t} + 2 \, \Delta t  \ \text{RHS}_u^t  	\\
+\\
+&u_f^t \;\quad = u^t+\gamma \,\left[ {u_f^{t-\Delta t} -2u^t+u^{t+\Delta t}} \right]
+\end{split}
+\end{equation} 
+where RHS is the right hand side of the momentum equation, the subscript $f$ 
+denotes filtered values and $\gamma$ is the Asselin coefficient. $\gamma$ is 
+initialized as \np{atfp} (namelist parameter). Its default value is \np{atfp} = 0.1.
+
+Note that whith the filtered free surface, the update of the \textit{next} velocities 
+is done in the \mdl{dynsp\_flt} module, and only the swap of arrays 
+and Asselin filtering is done in \mdl{dynnxt.}
+
+% ================================================================
+% Diagnostic variables
+% ================================================================
+\section{Diagnostic variables ($\zeta$, $\chi$, $w$)}
+\label{DYN_divcur_wzv}
+
+%--------------------------------------------------------------------------------------------------------------
+%           Horizontal divergence and relative vorticity
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Horizontal divergence and relative vorticity (\textit{divcur})]
+			{Horizontal divergence and relative vorticity (\mdl{divcur})}
+\label{DYN_divcur}
+
+The vorticity is defined at an $f$-point ($i.e.$ corner point) as follows:
+\begin{equation} \label{Eq_divcur_cur}
+\zeta =\frac{1}{e_{1f}\,e_{2f} }\left( {\;\delta _{i+1/2} \left[ {e_{2v}\;v} \right]
+						        -\delta _{j+1/2} \left[ {e_{1u}\;u} \right]\;} \right)
+\end{equation} 
+
+The horizontal divergence is defined at a $T$-point. It is given by:
+\begin{equation} \label{Eq_divcur_div}
+\chi =\frac{1}{e_{1T}\,e_{2T}\,e_{3T} }
+		\left( {\delta _i \left[ {e_{2u}\,e_{3u}\,u} \right]
+			  +\delta _j \left[ {e_{1v}\,e_{3v}\,v} \right]} \right)
+\end{equation} 
+
+Note that in the $z$-coordinate with full step (\key{zco} is defined), 
+$e_{3u} =e_{3v} =e_{3f}$ so that they cancel in \eqref{Eq_divcur_div}.
+
+Note also that whereas the vorticity have the same discrete expression in $z$- 
+and $s$-coordinate, its physical meaning is not identical. $\zeta$ is a pseudo 
+vorticity along $s$-surfaces (only pseudo because $(u,v)$ are still defined along 
+geopotential surfaces, but are no more necessary defined at the same depth).
+
+The vorticity and divergence at the \textit{before} step are used in the computation 
+of the horizontal diffusion of momentum. Note that because they have been 
+calculated prior to the Asselin filtering of the \textit{before} velocities, the 
+\textit{before} vorticity and divergence arrays must be included in the restart file 
+to ensure perfect restartability. The vorticity and divergence at the \textit{now} 
+time step are used for the computation of the nonlinear advection and of the 
+vertical velocity respectively. 
+
+%--------------------------------------------------------------------------------------------------------------
+%           Vertical Velocity
+%--------------------------------------------------------------------------------------------------------------
+\subsection   [Vertical velocity (\textit{wzvmod})]
+			{Vertical velocity (\mdl{wzvmod})}
+\label{DYN_wzv}
+
+The vertical velocity is computed by an upward integration of the horizontal 
+divergence from the bottom :
+
+\begin{equation} \label{Eq_wzv}
+\left\{   \begin{aligned}
+&\left. w \right|_{3/2} \quad= 0   	\\
+\\
+&\left. w \right|_{k+1/2}     = \left. w \right|_{k+1/2}  + e_{3t}\;  \left. \chi \right|_k  
+\end{aligned}   \right.
+\end{equation} 
+
+With a free surface, the top vertical velocity is non-zero, due to the 
+freshwater forcing and the variations of the free surface elevation. With a 
+linear free surface or with a rigid lid, the upper boundary condition 
+applies at a fixed level $z=0$. Note that in the rigid-lid case (\key{dynspg\_rl} 
+is defined), the surface boundary condition ($\left. w \right|_\text{surface}=0)$ is 
+automatically achieved at least at computer accuracy, due to the the way the 
+surface pressure gradient is expressed in discrete form (Appendix~\ref{Apdx_C}).
+
+Note also that whereas the vertical velocity has the same discrete 
+expression in $z$- and $s$-coordinate, its physical meaning is not the same: 
+in the second case, $w$ is the velocity normal to the $s$-surfaces. 
+
+With the variable volume option, the calculation of the vertical velocity is 
+modified (see \citet{Levier2007}, report available on the \NEMO web site). 
+
+% ================================================================
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LBC.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LBC.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LBC.tex	(revision 1844)
@@ -0,0 +1,744 @@
+% ================================================================
+% Chapter Ñ Lateral Boundary Condition (LBC) 
+% ================================================================
+\chapter{Lateral Boundary Condition (LBC) }
+\label{LBC}
+\minitoc
+
+\newpage
+$\ $\newline    % force a new ligne
+
+
+%gm% add here introduction to this chapter
+
+% ================================================================
+% Boundary Condition at the Coast
+% ================================================================
+\section{Boundary Condition at the Coast (\np{shlat})}
+\label{LBC_coast}
+%--------------------------------------------nam_lbc-------------------------------------------------------
+\namdisplay{nam_lbc} 
+%--------------------------------------------------------------------------------------------------------------
+
+%The lateral ocean boundary conditions contiguous to coastlines are Neumann conditions for heat and salt (no flux across boundaries) and Dirichlet conditions for momentum (ranging from free-slip to "strong" no-slip). They are handled automatically by the mask system (see \S\ref{DOM_msk}). 
+
+%OPA allows land and topography grid points in the computational domain due to the presence of continents or islands, and includes the use of a full or partial step representation of bottom topography. The computation is performed over the whole domain, i.e. we do not try to restrict the computation to ocean-only points. This choice has two motivations. Firstly, working on ocean only grid points overloads the code and harms the code readability. Secondly, and more importantly, it drastically reduces the vector portion of the computation, leading to a dramatic increase of CPU time requirement on vector computers.  The current section describes how the masking affects the computation of the various terms of the equations with respect to the boundary condition at solid walls. The process of defining which areas are to be masked is described in \S\ref{DOM_msk}.
+
+The discrete representation of a domain with complex boundaries (coastlines and 
+bottom topography) leads to arrays that include large portions where a computation 
+is not required as the model variables remain at zero. Nevertheless, vectorial 
+supercomputers are far more efficient when computing over a whole array, and the 
+readability of a code is greatly improved when boundary conditions are applied in 
+an automatic way rather than by a specific computation before or after each 
+computational loop. An efficient way to work over the whole domain while specifying 
+the boundary conditions, is to use multiplication by mask arrays in the computation. 
+A mask array is a matrix whose elements are $1$ in the ocean domain and $0$ 
+elsewhere. A simple multiplication of a variable by its own mask ensures that it will 
+remain zero over land areas. Since most of the boundary conditions consist of a 
+zero flux across the solid boundaries, they can be simply applied by multiplying 
+variables by the correct mask arrays, $i.e.$ the mask array of the grid point where 
+the flux is evaluated. For example, the heat flux in the \textbf{i}-direction is evaluated 
+at $u$-points. Evaluating this quantity as,
+
+\begin{equation} \label{Eq_lbc_aaaa}
+\frac{A^{lT} }{e_1 }\frac{\partial T}{\partial i}\equiv \frac{A_u^{lT} 
+}{e_{1u} } \; \delta _{i+1 / 2} \left[ T \right]\;\;mask_u 
+\end{equation}
+(where mask$_{u}$ is the mask array at a $u$-point) ensures that the heat flux is 
+zero inside land and at the boundaries, since mask$_{u}$ is zero at solid boundaries 
+which in this case are defined at $u$-points (normal velocity $u$ remains zero at 
+the coast) (Fig.~\ref{Fig_LBC_uv}). 
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_LBC_uv}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_LBC_uv.pdf}
+\caption {Lateral boundary (thick line) at T-level. The velocity normal to the 
+		 boundary is set to zero.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+For momentum the situation is a bit more complex as two boundary conditions 
+must be provided along the coast (one each for the normal and tangential velocities). 
+The boundary of the ocean in the C-grid is defined by the velocity-faces. 
+For example, at a given $T$-level, the lateral boundary (a coastline or an intersection 
+with the bottom topography) is made of segments joining $f$-points, and normal 
+velocity points are located between two $f-$points (Fig.~\ref{Fig_LBC_uv}). 
+The boundary condition on the normal velocity (no flux through solid boundaries) 
+can thus be easily implemented using the mask system. The boundary condition 
+on the tangential velocity requires a more specific treatment. This boundary 
+condition influences the relative vorticity and momentum diffusive trends, and is 
+required in order to compute the vorticity at the coast. Four different types of 
+lateral boundary condition are available, controlled by the value of the \np{shlat} 
+namelist parameter. (The value of the mask$_{f}$ array along the coastline is set 
+equal to this parameter.) These are:
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!p] \label{Fig_LBC_shlat}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_LBC_shlat.pdf}
+\caption {lateral boundary condition (a) free-slip ($shlat=0$) ; (b) no-slip ($shlat=2$) 
+; (c) "partial" free-slip ($0<shlat<2$) and (d) "strong" no-slip ($2<shlat$). 
+Implied "ghost" velocity inside land area is display in grey. }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+\begin{description}
+
+\item[free-slip boundary condition (\np{shlat}=0): ]  the tangential velocity at the 
+coastline is equal to the offshore velocity, $i.e.$ the normal derivative of the 
+tangential velocity is zero at the coast, so the vorticity: mask$_{f}$ array is set 
+to zero inside the land and just at the coast (Fig.~\ref{Fig_LBC_shlat}-a).
+
+\item[no-slip boundary condition (\np{shlat}=2): ] the tangential velocity vanishes 
+at the coastline. Assuming that the tangential velocity decreases linearly from 
+the closest ocean velocity grid point to the coastline, the normal derivative is 
+evaluated as if the velocities at the closest land velocity gridpoint and the closest 
+ocean velocity gridpoint were of the same magnitude but in the opposite direction 
+(Fig.~\ref{Fig_LBC_shlat}-b). Therefore, the vorticity along the coastlines is given by: 
+
+\begin{equation*}
+\zeta \equiv 2 \left(\delta_{i+1/2} \left[e_{2v} v \right] - \delta_{j+1/2} \left[e_{1u} u \right] \right) / \left(e_{1f} e_{2f} \right) \ ,
+\end{equation*}
+where $u$ and $v$ are masked fields. Setting the mask$_{f}$ array to $2$ along 
+the coastline provides a vorticity field computed with the no-slip boundary condition, 
+simply by multiplying it by the mask$_{f}$ :
+\begin{equation} \label{Eq_lbc_bbbb}
+\zeta \equiv \frac{1}{e_{1f} {\kern 1pt}e_{2f} }\left( {\delta _{i+1/2} 
+\left[ {e_{2v} \,v} \right]-\delta _{j+1/2} \left[ {e_{1u} \,u} \right]} 
+\right)\;\mbox{mask}_f 
+\end{equation}
+
+\item["partial" free-slip boundary condition (0$<$\np{shlat}$<$2): ] the tangential 
+velocity at the coastline is smaller than the offshore velocity, $i.e.$ there is a lateral 
+friction but not strong enough to make the tangential velocity at the coast vanish 
+(Fig.~\ref{Fig_LBC_shlat}-c). This can be selected by providing a value of mask$_{f}$ 
+strictly inbetween $0$ and $2$.
+
+\item["strong" no-slip boundary condition (2$<$\np{shlat}): ] the viscous boundary 
+layer is assumed to be smaller than half the grid size (Fig.~\ref{Fig_LBC_shlat}-d). 
+The friction is thus larger than in the no-slip case.
+
+\end{description}
+
+Note that when the bottom topography is entirely represented by the $s$-coor-dinates 
+(pure $s$-coordinate), the lateral boundary condition on tangential velocity is of much 
+less importance as it is only applied next to the coast where the minimum water depth 
+can be quite shallow.
+
+The alternative numerical implementation of the no-slip boundary conditions for an 
+arbitrary coast line of \citet{Shchepetkin1996} is also available through the 
+\key{noslip\_accurate} CPP key. It is based on a fourth order evaluation of the shear at the 
+coast which, in turn, allows a true second order scheme in the interior of the domain 
+($i.e.$ the numerical boundary scheme simulates the truncation error of the numerical 
+scheme used in the interior of the domain). \citet{Shchepetkin1996} found that such a 
+technique considerably improves the quality of the numerical solution. In \NEMO, such 
+spectacular improvements have not been found in the half-degree global ocean 
+(ORCA05), but significant reductions of numerically induced coastal upwellings were 
+found in an eddy resolving simulation of the Alboran Sea \citep{OlivierPh2001}. 
+Nevertheless, since a no-slip boundary condition is not recommended in an eddy 
+permitting or resolving simulation \citep{Penduff2007}, the use of this option is also 
+not recommended.
+
+In practice, the no-slip accurate option changes the way the curl is evaluated at the 
+coast (see \mdl{divcur} module), and requires the nature of each coastline grid point 
+(convex or concave corners, straight north-south or east-west coast) to be specified.  
+This is performed in routine \rou{dom\_msk\_nsa} in the \mdl{domask} module.
+
+% ================================================================
+% Boundary Condition around the Model Domain
+% ================================================================
+\section{Model Domain Boundary Condition (\jp{jperio})}
+\label{LBC_jperio}
+
+At the model domain boundaries several choices are offered: closed, cyclic east-west, 
+south symmetric across the equator, a north-fold, and combination closed-north fold 
+or cyclic-north-fold. The north-fold boundary condition is associated with the 3-pole ORCA mesh. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        Closed, cyclic, south symmetric (\jp{jperio} = 0, 1 or 2) 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Closed, cyclic, south symmetric (\jp{jperio} = 0, 1 or 2)}
+\label{LBC_jperio012}
+
+The choice of closed, cyclic or symmetric model domain boundary condition is made 
+by setting \jp{jperio} to 0, 1 or 2 in file \mdl{par\_oce}. Each time such a boundary 
+condition is needed, it is set by a call to routine \mdl{lbclnk}. The computation of 
+momentum and tracer trends proceeds from $i=2$ to $i=jpi-1$ and from $j=2$ to 
+$j=jpj-1$, $i.e.$ in the model interior. To choose a lateral model boundary condition 
+is to specify the first and last rows and columns of the model variables. 
+
+\begin{description}
+
+\item[For closed boundary (\textit{jperio=0})], solid walls are imposed at all model 
+boundaries: first and last rows and columns are set to zero.
+
+\item[For cyclic east-west boundary (\textit{jperio=1})], first and last rows are set 
+to zero (closed) whilst the first column is set to the value of the last-but-one column 
+and the last column to the value of the second one (Fig.~\ref{Fig_LBC_jperio}-a). 
+Whatever flows out of the eastern (western) end of the basin enters the western 
+(eastern) end. Note that there is no option for north-south cyclic or for doubly 
+cyclic cases.
+
+\item[For symmetric boundary condition across the equator (\textit{jperio=2})], 
+last rows, and first and last columns are set to zero (closed). The row of symmetry 
+is chosen to be the $u$- and $T-$points equator line ($j=2$, i.e. at the southern 
+end of the domain). For arrays defined at $u-$ or $T-$points, the first row is set 
+to the value of the third row while for most of $v$- and $f$-point arrays ($v$, $\zeta$, 
+$j\psi$, but \gmcomment{not sure why this is "but"} scalar arrays such as eddy coefficients) 
+the first row is set to minus the value of the second row (Fig.~\ref{Fig_LBC_jperio}-b). 
+Note that this boundary condition is not yet available for the case of a massively 
+parallel computer (\textbf{key{\_}mpp} defined).
+
+\end{description}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_LBC_jperio}  \begin{center}
+\includegraphics[width=1.0\textwidth]{./TexFiles/Figures/Fig_LBC_jperio.pdf}
+\caption {setting of (a) east-west cyclic  (b) symmetric across the equator boundary conditions.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -------------------------------------------------------------------------------------------------------------
+%        North fold (\textit{jperio = 3 }to $6)$ 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{North-fold (\textit{jperio = 3 }to $6)$ }
+\label{LBC_north_fold}
+
+The north fold boundary condition has been introduced in order to handle the north 
+boundary of a three-polar ORCA grid. Such a grid has two poles in the northern hemisphere. 
+\colorbox{yellow}{to be completed...}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_North_Fold_T}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_North_Fold_T.pdf}
+\caption {North fold boundary with a $T$-point pivot and cyclic east-west boundary condition 
+($jperio=4$), as used in ORCA 2, 1/4, and 1/12. Pink shaded area corresponds to the inner 
+domain mask (see text). }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% ====================================================================
+% Exchange with neighbouring processors 
+% ====================================================================
+\section  [Exchange with neighbouring processors (\textit{lbclnk}, \textit{lib\_mpp})]
+		{Exchange with neighbouring processors (\mdl{lbclnk}, \mdl{lib\_mpp})}
+\label{LBC_mpp}
+
+For massively parallel processing (mpp), a domain decomposition method is used. 
+The basic idea of the method is to split the large computation domain of a numerical 
+experiment into several smaller domains and solve the set of equations by addressing 
+independent local problems. Each processor has its own local memory and computes 
+the model equation over a subdomain of the whole model domain. The subdomain 
+boundary conditions are specified through communications between processors 
+which are organized by explicit statements (message passing method). 
+
+A big advantage is that the method does not need many modifications of the initial 
+FORTRAN code. From the modeller's point of view, each sub domain running on 
+a processor is identical to the "mono-domain" code. In addition, the programmer 
+manages the communications between subdomains, and the code is faster when 
+the number of processors is increased. The porting of OPA code on an iPSC860 
+was achieved during Guyon's PhD [Guyon et al. 1994, 1995] in collaboration with 
+CETIIS and ONERA. The implementation in the operational context and the studies 
+of performance on a T3D and T3E Cray computers have been made in collaboration 
+with IDRIS and CNRS. The present implementation is largely inspired by Guyon's 
+work  [Guyon 1995].
+
+The parallelization strategy is defined by the physical characteristics of the 
+ocean model. Second order finite difference schemes lead to local discrete 
+operators that depend at the very most on one neighbouring point. The only 
+non-local computations concern the vertical physics (implicit diffusion, 1.5 
+turbulent closure scheme, ...) (delocalization over the whole water column), 
+and the solving of the elliptic equation associated with the surface pressure 
+gradient computation (delocalization over the whole horizontal domain). 
+Therefore, a pencil strategy is used for the data sub-structuration 
+\gmcomment{no idea what this means!}
+: the 3D initial domain is laid out on local processor 
+memories following a 2D horizontal topological splitting. Each sub-domain 
+computes its own surface and bottom boundary conditions and has a side 
+wall overlapping interface which defines the lateral boundary conditions for 
+computations in the inner sub-domain. The overlapping area consists of the 
+two rows at each edge of the sub-domain. After a computation, a communication 
+phase starts: each processor sends to its neighbouring processors the update 
+values of the points corresponding to the interior overlapping area to its 
+neighbouring sub-domain (i.e. the innermost of the two overlapping rows). 
+The communication is done through message passing. Usually the parallel virtual 
+language, PVM, is used as it is a standard language available on  nearly  all 
+MPP computers. More specific languages (i.e. computer dependant languages) 
+can be easily used to speed up the communication, such as SHEM on a T3E 
+computer. The data exchanges between processors are required at the very 
+place where lateral domain boundary conditions are set in the mono-domain 
+computation (\S III.10-c): the lbc\_lnk routine which manages such conditions 
+is substituted by mpplnk.F or mpplnk2.F routine when running on an MPP 
+computer (\key{mpp\_mpi} defined). It has to be pointed out that when using 
+the MPP version of the model, the east-west cyclic boundary condition is done 
+implicitly, whilst the south-symmetric boundary condition option is not available.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_mpp}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_mpp.pdf}
+\caption {Positioning of a sub-domain when massively parallel processing is used. }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+In the standard version of the OPA model, the splitting is regular and arithmetic.
+ the i-axis is divided by \jp{jpni} and the j-axis by \jp{jpnj} for a number of processors 
+ \jp{jpnij} most often equal to $jpni \times jpnj$ (model parameters set in 
+ \mdl{par\_oce}). Each processor is independent and without message passing 
+ or synchronous process 
+ \gmcomment{how does a synchronous process relate to this?}, 
+ programs run alone and access just its own local memory. For this reason, the 
+ main model dimensions are now the local dimensions of the subdomain (pencil) 
+ that are named \jp{jpi}, \jp{jpj}, \jp{jpk}. These dimensions include the internal 
+ domain and the overlapping rows. The number of rows to exchange (known as 
+ the halo) is usually set to one (\jp{jpreci}=1, in \mdl{par\_oce}). The whole domain 
+ dimensions are named \jp{jpiglo}, \jp{jpjglo} and \jp{jpk}. The relationship between 
+ the whole domain and a sub-domain is:
+\begin{eqnarray} 
+      jpi & = & ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci  \nonumber \\
+      jpj & = & ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj  \label{Eq_lbc_jpi}
+\end{eqnarray}
+where \jp{jpni}, \jp{jpnj} are the number of processors following the i- and j-axis.
+
+\colorbox{yellow}{Figure IV.3: example of a domain splitting with 9 processors and 
+no east-west cyclic boundary conditions.}
+
+One also defines variables nldi and nlei which correspond to the internal 
+domain bounds, and the variables nimpp and njmpp which are the position 
+of the (1,1) grid-point in the global domain. An element of $T_{l}$, a local array 
+(subdomain) corresponds to an element of $T_{g}$, a global array 
+(whole domain) by the relationship: 
+\begin{equation} \label{Eq_lbc_nimpp}
+T_{g} (i+nimpp-1,j+njmpp-1,k) = T_{l} (i,j,k),
+\end{equation}
+with  $1 \leq i \leq jpi$, $1  \leq j \leq jpj $ , and  $1  \leq k \leq jpk$.
+
+Processors are numbered from 0 to $jpnij-1$, the number is saved in the variable 
+nproc. In the standard version, a processor has no more than four neighbouring 
+processors named nono (for north), noea (east), noso (south) and nowe (west) 
+and two variables, nbondi and nbondj, indicate the relative position of the processor 
+\colorbox{yellow}{(see Fig.IV.3)}:
+\begin{itemize}
+\item 		nbondi = -1 	an east neighbour, no west processor,
+\item 		nbondi =  0	an east neighbour, a west neighbour,
+\item 		nbondi =  1 	no east processor, a west neighbour,
+\item 		nbondi =  2 	no splitting following the i-axis.
+\end{itemize}
+During the simulation, processors exchange data with their neighbours. 
+If there is effectively a neighbour, the processor receives variables from this 
+processor on its overlapping row, and sends the data issued from internal 
+domain corresponding to the overlapping row of the other processor.
+		 
+\colorbox{yellow}{Figure IV.4: pencil splitting with the additional outer halos }
+
+
+The \NEMO model computes equation terms with the help of mask arrays (0 on land 
+points and 1 on sea points). It is easily readable and very efficient in the context of 
+a computer with vectorial architecture. However, in the case of a scalar processor, 
+computations over the land regions become more expensive in terms of CPU time. 
+It is worse when we use a complex configuration with a realistic bathymetry like the 
+global ocean where more than 50 \% of points are land points. For this reason, a 
+pre-processing tool can be used to choose the mpp domain decomposition with a 
+maximum number of only land points processors, which can then be eliminated. 
+(For example, the mpp\_optimiz tools, available from the DRAKKAR web site.) 
+This optimisation is dependent on the specific bathymetry employed. The user 
+then chooses optimal parameters \jp{jpni}, \jp{jpnj} and \jp{jpnij} with 
+$jpnij < jpni \times jpnj$, leading to the elimination of $jpni \times jpnj - jpnij$ 
+land processors. When those parameters are specified in module \mdl{par\_oce}, 
+the algorithm in the \rou{inimpp2} routine sets each processor's parameters (nbound, 
+nono, noea,...) so that the land-only processors are not taken into account. 
+
+\colorbox{yellow}{Note that the inimpp2 routine is general so that the original inimpp 
+routine should be suppressed from the code.}
+
+When land processors are eliminated, the value corresponding to these locations in 
+the model output files is zero. Note that this is a problem for a mesh output file written 
+by such a model configuration, because model users often divide by the scale factors 
+($e1t$, $e2t$, etc) and do not expect the grid size to be zero, even on land. It may be 
+best not to eliminate land processors when running the model especially to write the 
+mesh files as outputs (when \np{nmsh} namelist parameter differs from 0).
+\gmcomment{Steven : dont understand this, no land processor means no output file 
+covering this part of globe; its only when files are stitched together into one that you 
+can leave a hole}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_mppini2}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_mppini2.pdf}
+\caption {Example of Atlantic domain defined for the CLIPPER projet. Initial grid is 
+composed of 773 x 1236 horizontal points. (a) the domain is split onto 9 \time 20 
+subdomains (jpni=9, jpnj=20). 52 subdomains are land areas. (b) 52 subdomains 
+are eliminated (white rectangles) and the resulting number of processors really 
+used during the computation is jpnij=128.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+% ================================================================
+% Open Boundary Conditions 
+% ================================================================
+\section{Open Boundary Conditions (\key{obc})}
+\label{LBC_obc}
+%-----------------------------------------nam_obc  -------------------------------------------
+%-    nobc_dta    =    0     !  = 0 the obc data are equal to the initial state
+%-                           !  = 1 the obc data are read in 'obc   .dta' files
+%-    rdpein      =    1.    !  ???
+%-    rdpwin      =    1.    !  ???
+%-    rdpnin      =   30.    !  ???
+%-    rdpsin      =    1.    !  ???
+%-    rdpeob      = 1500.    !  time relaxation (days) for the east  open boundary
+%-    rdpwob      =   15.    !    "        "           for the west  open boundary
+%-    rdpnob      =  150.    !    "        "           for the north open boundary
+%-    rdpsob      =   15.    !    "        "           for the south open boundary
+%-    zbsic1      =  140.e+6 !  barotropic stream function on first  isolated coastline
+%-    zbsic2      =    1.e+6 !    "                   "    on second isolated coastline
+%-    zbsic3      =    0.    !    "                   "    on thrid  isolated coastline
+%-    ln_obc_clim = .true.   !  climatological obc data files (default T)
+%-    ln_vol_cst  = .true.   !  total volume conserved
+\namdisplay{namobc} 
+
+It is often necessary to implement a model configuration limited to an oceanic 
+region or a basin, which communicates with the rest of the global ocean through 
+''open boundaries''. As stated by \citet{Roed1986}, an open boundary is a 
+computational border where the aim of the calculations is to allow the perturbations 
+generated inside the computational domain to leave it without deterioration of the 
+inner model solution. However, an open boundary also has to let information from 
+the outer ocean enter the model and should support inflow and outflow conditions. 
+
+The open boundary package OBC is the first open boundary option developed in 
+NEMO (originally in OPA8.2). It allows the user to 
+\begin{itemize}
+\item tell the model that a boundary is ''open'' and not closed by a wall, for example 
+by modifying the calculation of the divergence of velocity there;
+\item impose values of tracers and velocities at that boundary (values which may 
+be taken from a climatology): this is the``fixed OBC'' option. 
+\item calculate boundary values by a sophisticated algorithm combining radiation 
+and relaxation (``radiative OBC'' option)
+\end{itemize}
+
+The package resides in the OBC directory. It is described here in four parts: the 
+boundary geometry (parameters to be set in \mdl{obc\_par}), the forcing data at 
+the boundaries (module \mdl{obcdta}),  the radiation algorithm involving the 
+namelist and module \mdl{obcrad}, and a brief presentation of boundary update 
+and restart files.
+
+%----------------------------------------------
+\subsection{Boundary geometry}
+\label{OBC_geom}
+%
+First one has to realize that open boundaries may not necessarily be located 
+at the extremities of the computational domain. They may exist in the middle 
+of the domain, for example at Gibraltar Straits if one wants to avoid including 
+the Mediterranean in an Atlantic domain. This flexibility has been found necessary 
+for the CLIPPER project \citep{Treguier2001}. Because of the complexity of the 
+geometry of ocean basins, it may even be necessary to have more than one 
+''west'' open boundary, more than one ''north'', etc. This is not possible with 
+the OBC option: only one open boundary of each kind, west, east, south and 
+north is allowed; these names refer to the grid geometry (not to the direction 
+of the geographical ''west'', ''east'', etc).
+
+The open boundary geometry is set by a series of parameters in the module 
+\mdl{obc\_par}. For an eastern open boundary, parameters are \jp{lp\_obc\_east} 
+(true if an east open boundary exists), \jp{jpieob} the $i$-index along which 
+the eastern open boundary (eob) is located, \jp{jpjed} the $j$-index at which 
+it starts, and \jp{jpjef} the $j$-index where it ends (note $d$ is for ''d\'{e}but'' 
+and $f$ for ''fin'' in French). Similar parameters exist for the west, south and 
+north cases (Table~\ref{Tab_obc_param}).
+
+
+%--------------------------------------------------TABLE--------------------------------------------------
+
+\begin{table}[htbp]  \label{Tab_obc_param}
+\begin{center}
+\begin{tabular}{|l|c|c|c|}
+\hline
+Boundary and  & Constant index  & Starting index (d\'{e}but) & Ending index (fin) \\
+Logical flag  &                 &                            &                     \\
+\hline
+West          & \jp{jpiwob} $>= 2$         &  \jp{jpjwd}$>= 2$          &  \jp{jpjwf}<= \jp{jpjglo}-1 \\
+lp\_obc\_west & $i$-index of a $u$ point   & $j$ of a $T$ point   &$j$ of a $T$ point \\
+\hline
+East            & \jp{jpieob}$<=$\jp{jpiglo}-2&\jp{jpjed} $>= 2$         & \jp{jpjef}$<=$ \jp{jpjglo}-1 \\
+ lp\_obc\_east  & $i$-index of a $u$ point    & $j$ of a $T$ point & $j$ of a $T$ point \\
+\hline
+South           & \jp{jpjsob} $>= 2$         & \jp{jpisd} $>= 2$          & \jp{jpisf}$<=$\jp{jpiglo}-1 \\
+lp\_obc\_south  & $j$-index of a $v$ point   & $i$ of a $T$ point   & $i$ of a $T$ point \\
+\hline
+North           & \jp{jpjnob} $<=$ \jp{jpjglo}-2& \jp{jpind} $>= 2$        & \jp{jpinf}$<=$\jp{jpiglo}-1 \\
+lp\_obc\_north  & $j$-index of a $v$ point      & $i$  of a $T$ point & $i$ of a $T$ point \\
+\hline
+\end{tabular}
+\end{center}
+\caption{Names of different indices relating to the open boundaries. In the case 
+of a completely open ocean domain with four ocean boundaries, the parameters 
+take exactly the values indicated.}
+\end{table}
+
+The open boundaries must be along coordinate lines. On the C-grid, the boundary 
+itself is along a line of normal velocity points: $v$ points for a zonal open boundary 
+(the south or north one), and $u$ points for a meridional open boundary (the west 
+or east one). Another constraint is that there still must be a row of masked points 
+all around the domain, as if the domain were a closed basin (unless periodic conditions 
+are used together with open boundary conditions). Therefore, an open boundary 
+cannot be located at the first/last index, namely, 1, \jp{jpiglo} or \jp{jpjglo}. Also, 
+the open boundary algorithm involves calculating the normal velocity points situated 
+just on the boundary, as well as the tangential velocity and temperature and salinity 
+just outside the boundary. This means that for a west/south boundary, normal 
+velocities and temperature are calculated at the same index \jp{jpiwob} and 
+\jp{jpjsob}, respectively. For an east/north boundary, the normal velocity is 
+calculated at index \jp{jpieob} and \jp{jpjnob}, but the ``outside'' temperature is 
+at index \jp{jpieob}+1 and \jp{jpjnob}+1. This means that \jp{jpieob}, \jp{jpjnob} 
+cannot be bigger than \jp{jpiglo}-2, \jp{jpjglo}-2. 
+
+
+The starting and ending indices are to be thought of as $T$ point indices: in many 
+cases they indicate the first land $T$-point, at the extremity of an open boundary 
+(the coast line follows the $f$ grid points, see Fig.~\ref{Fig_obc_north} for an example 
+of a northern open boundary). All indices are relative to the global domain. In the 
+free surface case it is possible to have ``ocean corners'', that is, an open boundary 
+starting and ending in the ocean.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_obc_north}  \begin{center}
+\includegraphics[width=0.70\textwidth]{./TexFiles/Figures/Fig_obc_north.pdf}
+\caption {Localization of the North open boundary points.}
+\end{center}  
+\end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+Although not compulsory, it is highly recommended that the bathymetry in the 
+vicinity of an open boundary follows the following rule: in the direction perpendicular 
+to the open line, the water depth should be constant for 4 grid points. This is in 
+order to ensure that the radiation condition, which involves model variables next 
+to the boundary, is calculated in a consistent way. On Fig.\ref{Fig_obc_north} we 
+indicate by an $=$ symbol, the points which should have the same depth. It means 
+that at the 4 points near the boundary, the bathymetry is cylindrical \gmcomment{not sure 
+why cylindrical}. The line behind the open $T$-line must be 0 in the bathymetry file 
+(as shown on Fig.\ref{Fig_obc_north} for example).
+
+%----------------------------------------------
+\subsection{Boundary data}
+\label{OBC_data}
+
+It is necessary to provide information at the boundaries. The simplest case is 
+when this information does not change in time and is equal to the initial conditions 
+(namelist variable \np{nobc\_dta}=0). This is the case for the standard configuration 
+EEL5 with open boundaries. When (\np{nobc\_dta}=1), open boundary information 
+is read from netcdf files. For convenience the input files are supposed to be similar 
+to the ''history'' NEMO output files, for dimension names and variable names. 
+Open boundary arrays must be dimensioned according to the parameters of table~
+\ref{Tab_obc_param}: for example, at the western boundary, arrays have a 
+dimension of \jp{jpwf}-\jp{jpwd}+1 in the horizontal and \jp{jpk} in the vertical. 
+
+When ocean observations are used to generate the boundary data (a hydrographic 
+section for example, as in \citet{Treguier2001}) it happens often that only the velocity 
+normal to the boundary is known, which is the reason why the initial OBC code 
+assumes that only $T$, $S$, and the normal velocity ($u$ or $v$) needs to be 
+specified. As more and more global model solutions and ocean analysis products 
+become available, it will be possible to provide information about all the variables 
+(including the tangential velocity) so that the specification of four variables at each 
+boundaries will become standard. For the sea surface height, one must distinguish 
+between the filtered free surface case and the time-splitting or explicit treatment of 
+the free surface.
+ In the first case, it is assumed that the user does not wish to represent high 
+ frequency motions such as tides. The boundary condition is thus one of zero 
+ normal gradient of sea surface height at the open boundaries, following \citet{Marchesiello2001}. 
+No information other than the total velocity needs to be provided at the open 
+boundaries in that case. In the other two cases (time splitting or explicit free surface), 
+the user must provide barotropic information (sea surface height and barotropic 
+velocities) and the use of the Flather algorithm for barotropic variables is 
+recommanded. However, this algorithm has not yet been fully tested and bugs 
+remain in NEMO v2.3. Users should read the code carefully before using it. Finally, 
+in the case of the rigid lid approximation the barotropic streamfunction must be 
+provided, as documented in \citet{Treguier2001}). This option is no longer 
+recommended but remains in NEMO V2.3.
+
+One frequently encountered case is when an open boundary domain is constructed 
+from a global or larger scale NEMO configuration. Assuming the domain corresponds 
+to indices $ib:ie$, $jb:je$ of the global domain, the bathymetry and forcing of the 
+small domain can be created by using the following netcdf utility on the global files: 
+ncks -F $-d\;x,ib,ie$ $-d\;y,jb,je$ (part of the nco series of utilities, see http://nco.sourceforge.net). 
+The open boundary files can be constructed using ncks 
+commands, following table~\ref{Tab_obc_ind}. 
+
+%--------------------------------------------------TABLE--------------------------------------------------
+
+\begin{table}[htbp]  \label{Tab_obc_ind}
+\begin{center}
+\begin{tabular}{|l|c|c|c|c|c|}
+\hline
+OBC  & Variable   & file name      & Index  & Start  & end  \\
+West &  T,S       &   obcwest\_TS.nc &  $ib$+1     &   $jb$+1 &  $je-1$  \\
+     &    U       &   obcwest\_U.nc  &  $ib$+1     &   $jb$+1 &  $je-1$  \\ 
+     &    V       &   obcwest\_V.nc  &  $ib$+1     &   $jb$+1 &  $je-1$  \\       
+\hline
+East &  T,S       &   obceast\_TS.nc &  $ie$-1     &   $jb$+1 &  $je-1$  \\
+     &    U       &   obceast\_U.nc  &  $ie$-2     &   $jb$+1 &  $je-1$  \\ 
+     &    V       &   obceast\_V.nc  &  $ie$-1     &   $jb$+1 &  $je-1$  \\       
+\hline         
+South &  T,S      &   obcsouth\_TS.nc &  $jb$+1     &  $ib$+1 &  $ie-1$  \\
+      &    U      &   obcsouth\_U.nc  &  $jb$+1     &  $ib$+1 &  $ie-1$  \\ 
+      &    V      &   obcsouth\_V.nc  &  $jb$+1     &  $ib$+1 &  $ie-1$  \\    
+\hline
+North &  T,S      &   obcnorth\_TS.nc &  $je$-1     &  $ib$+1 &  $ie-1$  \\
+      &    U      &   obcnorth\_U.nc  &  $je$-1     &  $ib$+1 &  $ie-1$  \\ 
+      &    V      &   obcnorth\_V.nc  &  $je$-2     &  $ib$+1 &  $ie-1$  \\  
+\hline
+\end{tabular}
+\end{center}
+\caption{Requirements for creating open boundary files from a global configuration, 
+appropriate for the subdomain of indices $ib:ie$, $jb:je$. ``Index'' designates the 
+$i$ or $j$ index along which the $u$ of $v$ boundary point is situated in the global 
+configuration, starting and ending with the $j$ or $i$ indices indicated. 
+For example, to generate file obcnorth\_V.nc, use the command ncks 
+$-F$ $-d\;y,je-2$  $-d\;x,ib+1,ie-1$ } 
+\end{table}
+
+It is assumed that the open boundary files contain the variables for the period of 
+the model integration. If the boundary files contain one time frame, the boundary 
+data is held fixed in time. If the files contain 12 values, it is assumed that the input 
+is a climatology for a repeated annual cycle (corresponding to the case \np{ln\_obc\_clim} 
+= .True.). The case of an arbitrary number of time frames is not yet implemented 
+correctly; the user is required to write his own code in the module \mdl{obc\_dta} 
+to deal with this situation. 
+
+\subsection{Radiation algorithm}
+\label{OBC_rad}
+
+The art of open boundary management consists in applying a constraint strong 
+enough that the inner domain "feels" the rest of the ocean, but weak enough
+that perturbations are allowed to leave the domain with minimum false reflections 
+of energy. The constraints are specified separately at each boundary as time 
+scales for ''inflow'' and ''outflow'' as defined below. The time scales are set (in days) 
+by namelist parameters such as \np{rdpein}, \np{rdpeob} for the eastern open 
+boundary for example. When both time scales are zero for a given boundary 
+($e.g.$ for the western boundary, \jp{lp\_obc\_west}=.True., \np{rdpwob}=0 and 
+\np{rdpwin}=0) this means that the boundary in question is a ''fixed '' boundary 
+where the solution is set exactly by the boundary data. This is not recommended, 
+except in combination with increased viscosity in a ''sponge'' layer next to the 
+boundary in order to avoid spurious reflections.  
+
+
+The radiation\/relaxation \gmcomment{the / doesnt seem to appear in the output} 
+algorithm is applied when either relaxation time (for ''inflow'' or ''outflow'') is 
+non-zero. It has been developed and tested in the SPEM model and its 
+successor ROMS \citep{Barnier1996, Marchesiello2001}, which is an 
+$s$-coordinate model on an Arakawa C-grid. Although the algorithm has 
+been numerically successful in the CLIPPER Atlantic models, the physics 
+do not work as expected \citep{Treguier2001}. Users are invited to consider 
+open boundary conditions (OBC hereafter) with some scepticism 
+\citep{Durran2001, Blayo2005}.
+
+The first part of the algorithm calculates a phase velocity to determine 
+whether perturbations tend to propagate toward, or away from, the 
+boundary. Let us consider a model variable $\phi$. 
+The phase velocities ($C_{\phi x}$,$C_{\phi y}$) for the variable $\phi$, 
+in the directions normal and tangential to the boundary are
+\begin{equation} \label{Eq_obc_cphi}
+C_{\phi x} = \frac{ -\phi_{t} }{ ( \phi_{x}^{2} + \phi_{y}^{2}) } \phi_{x} 
+\;\;\;\;\; \;\;\; 
+C_{\phi y} = \frac{ -\phi_{t} }{ ( \phi_{x}^{2} + \phi_{y}^{2}) } \phi_{y}. 
+\end{equation}
+Following \citet{Treguier2001} and \citet{Marchesiello2001} we retain only 
+the normal component of the velocity, $C_{\phi x}$, setting $C_{\phi y} =0$ 
+(but unlike the original Orlanski radiation algorithm we retain $\phi_{y}$ in 
+the expression for $C_{\phi x}$).  
+
+The discrete form of (\ref{Eq_obc_cphi}), described by \citet{Barnier1998},
+takes into account the two rows of grid points situated inside the domain 
+next to the boundary, and the three previous time steps ($n$, $n-1$,
+and $n-2$). The same equation can then be discretized at the boundary at
+time steps $n-1$, $n$ and $n+1$ \gmcomment{since the original was three time-level} 
+in order to extrapolate for the new boundary value $\phi^{n+1}$. 
+
+In the open boundary algorithm as implemented in NEMO v2.3, the new boundary 
+values are updated differently depending on the sign of $C_{\phi x}$. Let us take 
+an eastern boundary as an example. The solution for variable $\phi$ at the 
+boundary is given by a generalized wave equation with phase velocity $C_{\phi}$, 
+with the addition of a relaxation term, as:
+\begin{eqnarray}
+\phi_{t} &  =  & -C_{\phi x} \phi_{x} + \frac{1}{\tau_{o}} (\phi_{c}-\phi) 
+                        \;\;\; \;\;\; \;\;\; (C_{\phi x} > 0), \label{Eq_obc_rado} \\
+\phi_{t} &  =  & \frac{1}{\tau_{i}} (\phi_{c}-\phi) 
+\;\;\; \;\;\; \;\;\;\;\;\; (C_{\phi x} < 0), \label{Eq_obc_radi}
+\end{eqnarray}
+where $\phi_{c}$ is the estimate of $\phi$ at the boundary, provided as boundary 
+data. Note that in (\ref{Eq_obc_rado}), $C_{\phi x}$ is bounded by the ratio 
+$\delta x/\delta t$ for stability reasons. When $C_{\phi x}$ is eastward (outward 
+propagation), the radiation condition (\ref{Eq_obc_rado}) is used. 
+When  $C_{\phi x}$ is westward (inward propagation), (\ref{Eq_obc_radi}) is 
+used with a strong relaxation to climatology (usually $\tau_{i}=\np{rdpein}=$1~day).
+Equation (\ref{Eq_obc_radi}) is solved with a Euler time-stepping scheme. As a 
+consequence, setting $\tau_{i}$ smaller than, or equal to the time step is equivalent 
+to a fixed boundary condition. A time scale of one day is usually a good compromise 
+which guarantees that the inflow conditions remain close to climatology while ensuring 
+numerical stability. 
+
+In  the case of a western boundary located in the Eastern Atlantic, \citet{Penduff2000} 
+have been able to implement the radiation algorithm without any boundary data, 
+using persistence from the previous time step instead. This solution has not worked 
+in other cases \citep{Treguier2001}, so that the use of boundary data is recommended. 
+Even in the outflow condition (\ref{Eq_obc_rado}), we have found it desirable to 
+maintain a weak relaxation to climatology. The time step is usually chosen so as to 
+be larger than typical turbulent scales (of order 1000~days \gmcomment{or maybe seconds?}).
+
+The radiation condition is applied to the model variables: temperature, salinity, 
+tangential and normal velocities. For normal and tangential velocities, $u$ and $v$, 
+radiation is applied with phase velocities calculated from $u$ and $v$ respectively.  
+For the radiation of tracers, we use the phase velocity calculated from the tangential 
+velocity in order to avoid calculating too many independent radiation velocities and 
+because tangential velocities and tracers have the same position along the boundary 
+on a C-grid.  
+
+\subsection{Domain decomposition (\key{mpp\_mpi})}
+\label{OBC_mpp}
+When \key{mpp\_mpi} is active in the code, the computational domain is divided 
+into rectangles that are attributed each to a different processor. The open boundary 
+code is ``mpp-compatible'' up to a certain point. The radiation algorithm will not 
+work if there is an mpp subdomain boundary parallel to the open boundary at the 
+index of the boundary, or the grid point after (outside), or three grid points before 
+(inside). On the other hand, there is no problem if an mpp subdomain boundary 
+cuts the open boundary perpendicularly. These geometrical limitations must be 
+checked for by the user (there is no safeguard in the code).  
+The general principle for the open boundary mpp code is that loops over the open 
+boundaries {not sure what this means} are performed on local indices (nie0, 
+nie1, nje0, nje1 for an eastern boundary for instance) that are initialized in module 
+\mdl{obc\_ini}. Those indices have relevant values on the processors that contain 
+a segment of an open boundary. For processors that do not include an open 
+boundary segment, the indices are such that the calculations within the loops are 
+not performed.
+\gmcomment{I dont understand most of the last few sentences}
+ 
+Arrays of climatological data that are read from files are seen by all processors 
+and have the same dimensions for all (for instance, for the eastern boundary, 
+uedta(jpjglo,jpk,2)). On the other hand, the arrays for the calculation of radiation 
+are local to each processor (uebnd(jpj,jpk,3,3) for instance).  This allowed the 
+CLIPPER model for example, to save on memory where the eastern boundary 
+crossed 8 processors so that \jp{jpj} was much smaller than (\jp{jpjef}-\jp{jpjed}+1). 
+
+\subsection{Volume conservation}
+\label{OBC_vol}
+
+It is necessary to control the volume inside a domain when using open boundaries. 
+With fixed boundaries, it is enough to ensure that the total inflow/outflow has 
+reasonable values (either zero or a value compatible with an observed volume 
+balance). When using radiative boundary conditions it is necessary to have a 
+volume constraint because each open boundary works independently from the 
+others. The methodology used to control this volume is identical to the one 
+coded in the ROMS model \citep{Marchesiello2001}.
+
+
+%---------------------------------------- EXTRAS
+\colorbox{yellow}{Explain obc\_vol{\ldots}}
+
+\colorbox{yellow}{OBC algorithm for update, OBC restart, list of routines where obc key appears{\ldots}}
+
+\colorbox{yellow}{OBC rigid lid? {\ldots}}
+
+
+
+
+% ====================================================================
+% Flow Relaxation Scheme 
+% ====================================================================
+\section{Flow Relaxation Scheme (???)}
+\label{LBC_bdy}
+
+%gm% to be updated by Met Office
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LDF.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LDF.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_LDF.tex	(revision 1844)
@@ -0,0 +1,451 @@
+
+% ================================================================
+% Chapter Ñ Lateral Ocean Physics (LDF)
+% ================================================================
+\chapter{Lateral Ocean Physics (LDF)}
+\label{LDF}
+\minitoc
+
+$\ $\newline    % force a new ligne
+
+The lateral physics terms in the momentum and tracer equations have been 
+described in \S\ref{PE_zdf} and their discrete formulation in \S\ref{TRA_ldf} 
+and \S\ref{DYN_ldf}). In this section we further discuss each lateral physics option. 
+Choosing one lateral physics scheme means for the user defining, (1) the space 
+and time variations of the eddy coefficients ; (2) the direction along which the 
+lateral diffusive fluxes are evaluated (model level, geopotential or isopycnal 
+surfaces); and (3) the type of operator used (harmonic, or biharmonic operators, 
+and for tracers only, eddy induced advection on tracers). These three aspects 
+of the lateral diffusion are set through namelist parameters and CPP keys 
+(see the nam\_traldf and nam\_dynldf below).
+
+%-----------------------------------nam_traldf - nam_dynldf--------------------------------------------
+\namdisplay{nam_traldf} 
+\namdisplay{nam_dynldf} 
+%--------------------------------------------------------------------------------------------------------------
+
+
+% ================================================================
+% Lateral Mixing Coefficients
+% ================================================================
+\section {Lateral Mixing Coefficient (\mdl{ldftra}, \mdl{ldfdyn)} }
+\label{LDF_coef}
+
+
+Introducing a space variation in the lateral eddy mixing coefficients changes 
+the model core memory requirement, adding up to four extra three-dimensional 
+arrays for the geopotential or isopycnal second order operator applied to 
+momentum. Six CPP keys control the space variation of eddy coefficients: 
+three for momentum and three for tracer. The three choices allow: 
+a space variation in the three space directions, in the horizontal plane, 
+or in the vertical only. The default option is a constant value over the whole 
+ocean on both momentum and tracers. 
+
+The number of additional arrays that have to be defined and the gridpoint 
+position at which they are defined depend on both the space variation chosen 
+and the type of operator used. The resulting eddy viscosity and diffusivity 
+coefficients can be a function of more than one variable. Changes in the 
+computer code when switching from one option to another have been 
+minimized by introducing the eddy coefficients as statement functions
+(include file \hf{ldftra\_substitute} and \hf{ldfdyn\_substitute}). The functions 
+are replaced by their actual meaning during the preprocessing step (CPP). 
+The specification of the space variation of the coefficient is made in 
+\mdl{ldftra} and \mdl{ldfdyn}, or more precisely in include files 
+\textit{ldftra\_cNd.h90} and \textit{ldfdyn\_cNd.h90}, with N=1, 2 or 3. 
+The user can modify these include files as he/she wishes. The way the 
+mixing coefficient are set in the reference version can be briefly described 
+as follows:
+
+\subsubsection{Constant Mixing Coefficients (default option)}
+When none of the \textbf{key\_ldfdyn\_...} and \textbf{key\_ldftra\_...} keys are 
+defined, a constant value is used over the whole ocean for momentum and 
+tracers, which is specified through the \np{ahm0} and \np{aht0} namelist 
+parameters.
+
+\subsubsection{Vertically varying Mixing Coefficients (\key{ldftra\_c1d} and \key{ldfdyn\_c1d})} 
+The 1D option is only available when using the $z$-coordinate with full step. 
+Indeed in all the other types of vertical coordinate, the depth is a 3D function 
+of (\textbf{i},\textbf{j},\textbf{k}) and therefore, introducing depth-dependent 
+mixing coefficients will require 3D arrays, $i.e.$ \key{ldftra\_c3d} and \key{ldftra\_c3d}.  
+In the 1D option, a hyperbolic variation of the lateral mixing coefficient is introduced 
+in which the surface value is \np{aht0} (\np{ahm0}), the bottom value is 1/4 of 
+the surface value, and the transition takes place around z=300~m with a width 
+of 300~m ($i.e.$ both the depth and the width of the inflection point are set to 300~m). 
+This profile is hard coded in file \hf{ldftra\_c1d}, but can be easily modified by users.
+
+\subsubsection{Horizontally Varying Mixing Coefficients (\key{ldftra\_c2d} and \key{ldfdyn\_c2d})}
+By default the horizontal variation of the eddy coefficient depends on the local mesh 
+size and the type of operator used:
+\begin{equation} \label{Eq_title}
+  A_l = \left\{     
+   \begin{aligned}
+         & \frac{\max(e_1,e_2)}{e_{max}} A_o^l  			& \text{for laplacian operator } \\
+         & \frac{\max(e_1,e_2)^{3}}{e_{max}^{3}} A_o^l  & \text{for bilaplacian operator } 
+   \end{aligned}    \right.
+\quad \text{comments}
+\end{equation}
+where $e_{max}$ is the maximum of $e_1$ and $e_2$ taken over the whole masked 
+ocean domain, and $A_o^l$ is the \np{ahm0} (momentum) or \np{aht0} (tracer) 
+namelist parameter. This variation is intended to reflect the lesser need for subgrid 
+scale eddy mixing where the grid size is smaller in the domain. It was introduced in 
+the context of the DYNAMO modelling project \citep{Willebrand2001}. 
+%%%
+\gmcomment { not only that! stability reasons: with non uniform grid size, it is common 
+to face a blow up of the model due to to large diffusive coefficient compare to the smallest 
+grid size... this is especially true for bilaplacian (to be added in the text!)  }
+
+Other formulations can be introduced by the user for a given configuration. 
+For example, in the ORCA2 global ocean model (\key{orca\_r2}), the laplacian 
+viscosity operator uses \np{ahm0}~=~$4.10^4 m^2/s$ poleward of 20$^{\circ}$ 
+north and south and decreases linearly to \np{aht0}~=~$2.10^3 m^2/s$ 
+at the equator \citep{Madec1996, Delecluse_Madec_Bk00}. This modification 
+can be found in routine \rou{ldf\_dyn\_c2d\_orca} defined in \mdl{ldfdyn\_c2d}. 
+Similar modified horizontal variations can be found with the Antarctic or Arctic 
+sub-domain options of ORCA2 and ORCA05 (\key{antarctic} or \key{arctic} 
+defined, see \hf{ldfdyn\_antarctic} and \hf{ldfdyn\_arctic}).
+
+\subsubsection{Space Varying Mixing Coefficients (\key{ldftra\_c3d} and \key{ldfdyn\_c3d})}
+
+The 3D space variation of the mixing coefficient is simply the combination of the 
+1D and 2D cases, $i.e.$ a hyperbolic tangent variation with depth associated with 
+a grid size dependence of the magnitude of the coefficient. 
+
+\subsubsection{Space and Time Varying Mixing Coefficients}
+
+There is no default specification of space and time varying mixing coefficient. 
+The only case available is specific to the ORCA2 and ORCA05 global ocean 
+configurations (\key{orca\_r2} or \key{orca\_r05}). It provides only a tracer 
+mixing coefficient for eddy induced velocity (ORCA2) or both iso-neutral and 
+eddy induced velocity (ORCA05) that depends on the local growth rate of 
+baroclinic instability. This specification is actually used when an ORCA key 
+and both \key{traldf\_eiv} and \key{traldf\_c2d} are defined.
+
+A space variation in the eddy coefficient appeals several remarks:
+
+(1) the momentum diffusion operator acting along model level surfaces is 
+written in terms of curl and divergent components of the horizontal current 
+(see \S\ref{PE_ldf}). Although the eddy coefficient can be set to different values 
+in these two terms, this option is not available. 
+
+(2) with an horizontally varying viscosity, the quadratic integral constraints 
+on enstrophy and on the square of the horizontal divergence for operators 
+acting along model-surfaces are no longer satisfied 
+(Appendix~\ref{Apdx_dynldf_properties}).
+
+(3) for isopycnal diffusion on momentum or tracers, an additional purely 
+horizontal background diffusion with uniform coefficient can be added by 
+setting a non zero value of \np{ahmb0} or \np{ahtb0}, a background horizontal 
+eddy viscosity or diffusivity coefficient (namelist parameters whose default 
+values are $0$). However, the technique used to compute the isopycnal 
+slopes is intended to get rid of such a background diffusion, since it introduces 
+spurious diapycnal diffusion (see {\S\ref{LDF_slp}).
+
+(4) when an eddy induced advection term is used (\key{trahdf\_eiv}), $A^{eiv}$, 
+the eddy induced coefficient has to be defined. Its space variations are controlled 
+by the same CPP variable as for the eddy diffusivity coefficient ($i.e.$ 
+\textbf{key\_traldf\_cNd}). 
+
+(5) the eddy coefficient associated with a biharmonic operator must be set to a \emph{negative} value.
+
+
+% ================================================================
+% Direction of lateral Mixing
+% ================================================================
+\section  [Direction of Lateral Mixing (\textit{ldfslp})]
+		{Direction of Lateral Mixing (\mdl{ldfslp})}
+\label{LDF_slp}
+
+%%%
+\gmcomment{  we should emphasize here that the implementation is a rather old one. 
+Better work can be achieved by using \citet{Griffies1998, Griffies2004} iso-neutral scheme. }
+
+A direction for lateral mixing has to be defined when the desired operator does 
+not act along the model levels. This occurs when $(a)$ horizontal mixing is 
+required on tracer or momentum (\np{ln\_traldf\_hor} or \np{ln\_dynldf\_hor}) 
+in $s$- or mixed $s$-$z$- coordinates, and $(b)$ isoneutral mixing is required 
+whatever the vertical coordinate is. This direction of mixing is defined by its 
+slopes in the \textbf{i}- and \textbf{j}-directions at the face of the cell of the 
+quantity to be diffused. For a tracer, this leads to the following four slopes : 
+$r_{1u}$, $r_{1w}$, $r_{2v}$, $r_{2w}$ (see \eqref{Eq_tra_ldf_iso}), while 
+for momentum the slopes are  $r_{1T}$, $r_{1uw}$, $r_{2f}$, $r_{2uw}$ for 
+$u$ and  $r_{1f}$, $r_{1vw}$, $r_{2T}$, $r_{2vw}$ for $v$. 
+
+%gm% add here afigure of the slope in i-direction
+
+\subsection{slopes for tracer geopotential mixing in the $s$-coordinate}
+
+In $s$-coordinates, geopotential mixing ($i.e.$ horizontal mixing) $r_1$ and 
+$r_2$ are the slopes between the geopotential and computational surfaces. 
+Their discrete formulation is found by locally solving \eqref{Eq_tra_ldf_iso} 
+when the diffusive fluxes in the three directions are set to zero and $T$ is 
+assumed to be horizontally uniform, $i.e.$ a linear function of $z_T$, the 
+depth of a $T$-point. 
+%gm { Steven : My version is obviously wrong since I'm left with an arbitrary constant which is the local vertical temperature gradient}
+
+\begin{equation} \label{Eq_ldfslp_geo}
+\begin{aligned}
+ r_{1u} &= \frac{e_{3u}}{ \left( e_{1u}\;\overline{\overline{e_{3w}}}^{\,i+1/2,\,k} \right)}
+ 			  \;\delta_{i+1/2}[z_T] 
+ 		&\approx \frac{1}{e_{1u}}\; \delta_{i+1/2}[z_T] 
+\\
+ r_{2v} &= \frac{e_{3v}}{\left( e_{2v}\;\overline{\overline{e_{3w}}}^{\,j+1/2,\,k} \right)} 
+ 			  \;\delta_{j+1/2} [z_T] 
+		&\approx \frac{1}{e_{2v}}\; \delta_{j+1/2}[z_T] 
+\\
+ r_{1w} &= \frac{1}{e_{1w}}\;\overline{\overline{\delta_{i+1/2}[z_T]}}^{\,i,\,k+1/2}
+ 		&\approx \frac{1}{e_{1w}}\; \delta_{i+1/2}[z_{uw}] 
+ \\
+ r_{2w} &= \frac{1}{e_{2w}}\;\overline{\overline{\delta_{j+1/2}[z_T]}}^{\,j,\,k+1/2}
+		&\approx \frac{1}{e_{2w}}\; \delta_{j+1/2}[z_{vw}] 
+ \\
+\end{aligned}
+\end{equation}
+
+%gm%  caution I'm not sure the simplification was a good idea! 
+
+These slopes are computed once in \rou{ldfslp\_init} when \np{ln\_sco}=True, 
+and either \np{ln\_traldf\_hor}=True or \np{ln\_dynldf\_hor}=True. 
+
+\subsection{slopes for tracer iso-neutral mixing}
+In iso-neutral mixing  $r_1$ and $r_2$ are the slopes between the iso-neutral 
+and computational surfaces. Their formulation does not depend on the vertical 
+coordinate used. Their discrete formulation is found using the fact that the 
+diffusive fluxes of locally referenced potential density ($i.e.$ $in situ$ density) 
+vanish. So, substituting $T$ by $\rho$ in \eqref{Eq_tra_ldf_iso} and setting the 
+diffusive fluxes in the three directions to zero leads to the following definition for 
+the neutral slopes:
+
+\begin{equation} \label{Eq_ldfslp_iso}
+\begin{split}
+ r_{1u} &= \frac{e_{3u}}{e_{1u}}\; \frac{\delta_{i+1/2}[\rho]}
+ 								{\overline{\overline{\delta_{k+1/2}[\rho]}}^{\,i+1/2,\,k}}
+\\
+ r_{2v} &= \frac{e_{3v}}{e_{2v}}\; \frac{\delta_{j+1/2}\left[\rho \right]}
+ 								{\overline{\overline{\delta_{k+1/2}[\rho]}}^{\,j+1/2,\,k}}
+\\
+ r_{1w} &= \frac{e_{3w}}{e_{1w}}\; 
+ 			\frac{\overline{\overline{\delta_{i+1/2}[\rho]}}^{\,i,\,k+1/2}}
+				 {\delta_{k+1/2}[\rho]}
+\\
+ r_{2w} &= \frac{e_{3w}}{e_{2w}}\; 
+ 			\frac{\overline{\overline{\delta_{j+1/2}[\rho]}}^{\,j,\,k+1/2}}
+				 {\delta_{k+1/2}[\rho]}
+\\
+\end{split}
+\end{equation}
+
+%gm% rewrite this as the explanation is not very clear !!!
+%In practice, \eqref{Eq_ldfslp_iso} is of little help in evaluating the neutral surface slopes. Indeed, for an unsimplified equation of state, the density has a strong dependancy on pressure (here approximated as the depth), therefore applying \eqref{Eq_ldfslp_iso} using the $in situ$ density, $\rho$, computed at T-points leads to a flattening of slopes as the depth increases. This is due to the strong increase of the $in situ$ density with depth. 
+
+%By definition, neutral surfaces are tangent to the local $in situ$ density \citep{McDougall1987}, therefore in \eqref{Eq_ldfslp_iso}, all the derivatives have to be evaluated at the same local pressure (which in decibars is approximated by the depth in meters).
+
+%In the $z$-coordinate, the derivative of the  \eqref{Eq_ldfslp_iso} numerator is evaluated at the same depth \nocite{as what?} ($T$-level, which is the same as the $u$- and $v$-levels), so  the $in situ$ density can be used for its evaluation. 
+
+As the mixing is performed along neutral surfaces, the gradient of $\rho$ in 
+\eqref{Eq_ldfslp_iso} has to be evaluated at the same local pressure (which, 
+in decibars, is approximated by the depth in meters in the model). Therefore 
+\eqref{Eq_ldfslp_iso} cannot be used as such, but further transformation is 
+needed depending on the vertical coordinate used:
+
+\begin{description}
+
+\item[$z$-coordinate with full step : ] in \eqref{Eq_ldfslp_iso} the densities 
+appearing in the $i$ and $j$ derivatives  are taken at the same depth, thus 
+the $in situ$ density can be used. This is not the case for the vertical 
+derivatives: $\delta_{k+1/2}[\rho]$ is replaced by $-\rho N^2/g$, where $N^2$ 
+is the local Brunt-Vais\"{a}l\"{a} frequency evaluated following 
+\citet{McDougall1987} (see \S\ref{TRA_bn2}). 
+
+\item[$z$-coordinate with partial step : ] this case is identical to the full step 
+case except that at partial step level, the \emph{horizontal} density gradient 
+is evaluated as described in \S\ref{TRA_zpshde}.
+
+\item[$s$- or hybrid $s$-$z$- coordinate : ] in the current release of \NEMO, 
+there is no specific treatment for iso-neutral mixing in the $s$-coordinate. 
+In other words, iso-neutral mixing will only be accurately represented with a 
+linear equation of state (\np{neos}=1 or 2). In the case of a "true" equation 
+of state, the evaluation of $i$ and $j$ derivatives in \eqref{Eq_ldfslp_iso} 
+will include a pressure dependent part, leading to the wrong evaluation of 
+the neutral slopes.
+
+%gm% 
+Note: The solution for $s$-coordinate passes trough the use of different 
+(and better) expression for the constraint on iso-neutral fluxes. Following 
+\citet{Griffies2004}, instead of specifying directly that there is a zero neutral 
+diffusive flux of locally referenced potential density, we stay in the $T$-$S$ 
+plane and consider the balance between the neutral direction diffusive fluxes 
+of potential temperature and salinity:
+\begin{equation}
+\alpha \ \textbf{F}(T) = \beta \ \textbf{F}(S)
+\end{equation}
+%gm{  where vector F is ....}
+
+This constraint leads to the following definition for the slopes:
+
+\begin{equation} \label{Eq_ldfslp_iso2}
+\begin{split}
+ r_{1u} &= \frac{e_{3u}}{e_{1u}}\; \frac
+ 		{\alpha_u \;\delta_{i+1/2}[T] - \beta_u \;\delta_{i+1/2}[S]}
+		{\alpha_u \;\overline{\overline{\delta_{k+1/2}[T]}}^{\,i+1/2,\,k}
+		 -\beta_u  \;\overline{\overline{\delta_{k+1/2}[S]}}^{\,i+1/2,\,k} }
+\\
+ r_{2v} &= \frac{e_{3v}}{e_{2v}}\; \frac
+ 		{\alpha_v \;\delta_{j+1/2}[T] - \beta_v \;\delta_{j+1/2}[S]}
+		{\alpha_v \;\overline{\overline{\delta_{k+1/2}[T]}}^{\,j+1/2,\,k}
+		 -\beta_v  \;\overline{\overline{\delta_{k+1/2}[S]}}^{\,j+1/2,\,k} }
+\\
+ r_{1w} &= \frac{e_{3w}}{e_{1w}}\; \frac
+		{\alpha_w \;\overline{\overline{\delta_{i+1/2}[T]}}^{\,i,\,k+1/2}
+		 -\beta_w  \;\overline{\overline{\delta_{i+1/2}[S]}}^{\,i,\,k+1/2} }
+ 		{\alpha_w \;\delta_{k+1/2}[T] - \beta_w \;\delta_{k+1/2}[S]}
+\\
+ r_{2w} &= \frac{e_{3w}}{e_{2w}}\; \frac
+		{\alpha_w \;\overline{\overline{\delta_{j+1/2}[T]}}^{\,j,\,k+1/2}
+		 -\beta_w  \;\overline{\overline{\delta_{j+1/2}[S]}}^{\,j,\,k+1/2} }
+ 		{\alpha_w \;\delta_{k+1/2}[T] - \beta_w \;\delta_{k+1/2}[S]}
+\\
+\end{split}
+\end{equation}
+where $\alpha$ and $\beta$, the thermal expansion and saline contraction 
+coefficients introduced in \S\ref{TRA_bn2}, have to be evaluated at the three 
+velocity points. In order to save computation time, they should be approximated 
+by the mean of their values at $T$-points (for example in the case of $\alpha$:  
+$\alpha_u=\overline{\alpha_T}^{i+1/2}$,  $\alpha_v=\overline{\alpha_T}^{j+1/2}$ 
+and $\alpha_w=\overline{\alpha_T}^{k+1/2}$).
+
+Note that such a formulation could be also used in the $z$-coordinate and 
+$z$-coordinate with partial steps cases.
+
+\end{description}
+
+This implementation is a rather old one. It is similar to the one proposed 
+by Cox [1987], except for the background horizontal diffusion. Indeed, 
+the Cox implementation of isopycnal diffusion in GFDL-type models requires 
+a minimum background horizontal diffusion for numerical stability reasons. 
+To overcome this problem, several techniques have been proposed in which 
+the numerical schemes of the ocean model are modified \citep{Weaver1997, 
+Griffies1998}. Here, another strategy has been chosen \citep{Lazar1997}: 
+a local filtering of the iso-neutral slopes (made on 9 grid-points) prevents 
+the development of grid point noise generated by the iso-neutral diffusion 
+operator (Fig.~\ref{Fig_LDF_ZDF1}). This allows an iso-neutral diffusion scheme 
+without additional background horizontal mixing. This technique can be viewed 
+as a diffusion operator that acts along large-scale (2~$\Delta$x) 
+\gmcomment{2deltax doesnt seem very large scale} 
+iso-neutral surfaces. The diapycnal diffusion required for numerical stability is 
+thus minimized and its net effect on the flow is quite small when compared to 
+the effect of an horizontal background mixing. 
+
+Nevertheless, this iso-neutral operator does not ensure that variance cannot increase, 
+contrary to the \citet{Griffies1998} operator which has that property. 
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_LDF_ZDF1}  \begin{center}
+\includegraphics[width=0.70\textwidth]{./TexFiles/Figures/Fig_LDF_ZDF1.pdf}
+\caption {averaging procedure for isopycnal slope computation.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+%There are three additional questions about the slope calculation. 
+%First the expression for the rotation tensor has been obtain assuming the "small slope" approximation, so a bound has to be imposed on slopes. 
+%Second, numerical stability issues also require a bound on slopes. 
+%Third, the question of boundary condition specified on slopes...
+
+%from griffies: chapter 13.1....
+
+
+
+In addition and also for numerical stability reasons \citep{Cox1987, Griffies2004}, 
+the slopes are bounded by $1/100$ everywhere. This limit is decreasing linearly 
+to zero fom $70$ meters depth and the surface (the fact that the eddies "feel" the 
+surface motivates this flattening of isopycnals near the surface).
+
+For numerical stability reasons \citep{Cox1987, Griffies2004}, the slopes must also 
+be bounded by $1/100$ everywhere. This constraint is applied in a piecewise linear 
+fashion, increasing from zero at the surface to $1/100$ at $70$ metres and thereafter 
+decreasing to zero at the bottom of the ocean. (the fact that the eddies "feel" the 
+surface motivates this flattening of isopycnals near the surface).
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_eiv_slp}  \begin{center}
+\includegraphics[width=0.70\textwidth]{./TexFiles/Figures/Fig_eiv_slp.pdf}
+\caption {Vertical profile of the slope used for lateral mixing in the mixed layer : 
+\textit{(a)} in the real ocean the slope is the iso-neutral slope in the ocean interior, 
+which has to be adjusted at the surface boundary (i.e. it must tend to zero at the 
+surface since there is no mixing across the air-sea interface: wall boundary 
+condition). Nevertheless, the profile between the surface zero value and the interior 
+iso-neutral one is unknown, and especially the value at the base of the mixed layer ; 
+\textit{(b)} profile of slope using a linear tapering of the slope near the surface and 
+imposing a maximum slope of 1/100 ; \textit{(c)} profile of slope actually used in 
+\NEMO: a linear decrease of the slope from zero at the surface to its ocean interior 
+value computed just below the mixed layer. Note the huge change in the slope at the 
+base of the mixed layer between  \textit{(b)}  and \textit{(c)}.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+\colorbox{yellow}{add here a discussion about the flattening of the slopes, vs  tapering the coefficient.}
+
+\subsection{slopes for momentum iso-neutral mixing}
+
+The iso-neutral diffusion operator on momentum is the same as the one used on 
+tracers but applied to each component of the velocity separately (see 
+\eqref{Eq_dyn_ldf_iso} in section~\ref{DYN_ldf_iso}). The slopes between the 
+surface along which the diffusion operator acts and the surface of computation 
+($z$- or $s$-surfaces) are defined at $T$-, $f$-, and \textit{uw}- points for the 
+$u$-component, and $T$-, $f$- and \textit{vw}- points for the $v$-component. 
+They are computed from the slopes used for tracer diffusion, $i.e.$ 
+\eqref{Eq_ldfslp_geo} and \eqref{Eq_ldfslp_iso} :
+
+\begin{equation} \label{Eq_ldfslp_dyn}
+\begin{aligned}
+&r_{1T}\ \ = \overline{r_{1u}}^{\,i}       &&&    r_{1f}\ \ &= \overline{r_{1u}}^{\,i+1/2} \\
+&r_{2f} \ \ = \overline{r_{2v}}^{\,j+1/2} &&& 	r_{2T}\ &= \overline{r_{2v}}^{\,j} \\
+&r_{1uw}  = \overline{r_{1w}}^{\,i+1/2} &&\ \ \text{and} \ \ &   r_{1vw}&= \overline{r_{1w}}^{\,j+1/2} \\
+&r_{2uw}= \overline{r_{2w}}^{\,j+1/2} &&&         r_{2vw}&= \overline{r_{2w}}^{\,j+1/2}\\
+\end{aligned}
+\end{equation}
+
+The major issue remaining is in the specification of the boundary conditions. 
+The same boundary conditions are chosen as those used for lateral 
+diffusion along model level surfaces, i.e. using the shear computed along 
+the model levels and with no additional friction at the ocean bottom (see 
+{\S\ref{LBC_coast}).
+
+
+% ================================================================
+% Eddy Induced Mixing
+% ================================================================
+\section  [Eddy Induced Velocity (\textit{traadv\_eiv}, \textit{ldfeiv})]
+		{Eddy Induced Velocity (\mdl{traadv\_eiv}, \mdl{ldfeiv})}
+\label{LDF_eiv}
+
+When Gent and McWilliams [1990] diffusion is used (\key{traldf\_eiv} defined), 
+an eddy induced tracer advection term is added, the formulation of which 
+depends on the slopes of iso-neutral surfaces. Contrary to the case of iso-neutral 
+mixing, the slopes used here are referenced to the geopotential surfaces, $i.e.$ 
+\eqref{Eq_ldfslp_geo} is used in $z$-coordinates, and the sum \eqref{Eq_ldfslp_geo}  
++ \eqref{Eq_ldfslp_iso} in $s$-coordinates. The eddy induced velocity is given by: 
+\begin{equation} \label{Eq_ldfeiv}
+\begin{split}
+ u^* & = \frac{1}{e_{2u}e_{3u}}\; \delta_k \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right]\\
+v^* & = \frac{1}{e_{1u}e_{3v}}\; \delta_k \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right]\\
+w^* & = \frac{1}{e_{1w}e_{2w}}\; \left\{ \delta_i \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right] + \delta_j \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right] \right\} \\
+\end{split}
+\end{equation}
+where $A^{eiv}$ is the eddy induced velocity coefficient whose value is set 
+through \np{aeiv}, a \textit{nam\_traldf} namelist parameter. 
+The three components of the eddy induced velocity are computed and add 
+to the eulerian velocity in \mdl{traadv\_eiv}. This has been preferred to a 
+separate computation of the advective trends associated with the eiv velocity, 
+since it allows us to take advantage of all the advection schemes offered for 
+the tracers (see \S\ref{TRA_adv}) and not just the $2^{nd}$ order advection 
+scheme as in previous releases of OPA \citep{Madec1998}. This is particularly 
+useful for passive tracers where \emph{positivity} of the advection scheme is 
+of paramount importance. 
+
+At the surface, lateral and bottom boundaries, the eddy induced velocity, 
+and thus the advective eddy fluxes of heat and salt, are set to zero. 
+
+
+
+
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_MISC.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_MISC.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_MISC.tex	(revision 1844)
@@ -0,0 +1,671 @@
+% ================================================================
+% Chapter Ñ Miscellaneous Topics
+% ================================================================
+\chapter{Miscellaneous Topics (xxx)}
+\label{MISC}
+\minitoc
+
+% ================================================================
+% Representation of Unresolved Straits
+% ================================================================
+\section{Representation of Unresolved Straits}
+\label{MISC_strait}
+
+% In climate modeling, it is often necessary to allow water masses that are separated by land to exchange properties. This situation arises in models when the grid mesh is too coarse to resolve narrow passageways that in reality provide crucial connections between water masses. For example, coarse grid spacing typically closes off the Mediterranean from the Atlantic at the Straits of Gibraltar. In this case, it is important for climate models to include the effects of salty water entering the Atlantic from the Mediterranean. Likewise, it is important for the Mediterranean to replenish its supply of water from the Atlantic to balance the net evaporation occurring over the Mediterranean region. 
+% Same problem occurs as soon as important straits are not properly resolved by the mesh. For example it arises in ORCA 1/4\r{} in several straits of the Indonesian archipelago (Ombai, Lombok...).
+% We describe here the three methods that can be used in \NEMO to handle such improperly resolved straits. 
+%The problem is resolved here by allowing the mixing of tracers and mass/volume between non-adjacent water columns at nominated regions within the model. Momentum is not mixed. The scheme conserves total tracer content, and total volume (the latter in $z*$- or $s*$-coordinate), and maintains compatibility between the tracer and mass/volume budgets.  
+
+% Note: such changes are so specific to a given configuration that no attempt has been made to set them in a generic way. Nevertheless, an example of how they can be set up is given in the ORCA2 configuration (\key{ORCA_R2}).
+
+% -------------------------------------------------------------------------------------------------------------
+%       Hand made geometry changes
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Hand made geometry changes}
+\label{MISC_strait_hand}
+
+$\bullet$ reduced scale factor, also called partially open face (Hallberg, personnal communication 2006)
+%also called partially open cell  or partial closed cells
+
+$\bullet$ increase of the viscous boundary layer thickness by local increase of the fmask value at the coast
+
+\colorbox{yellow}{Add a short description of scale factor changes staff and fmask increase}
+
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tbp] \label{Fig_MISC_strait_hand}  \begin{center}
+\includegraphics[width=0.80\textwidth]{./TexFiles/Figures/Fig_Gibraltar.pdf}
+\includegraphics[width=0.80\textwidth]{./TexFiles/Figures/Fig_Gibraltar2.pdf}
+\caption {Example of the Gibraltar strait defined in a 1\r{} x 1\r{} mesh. 
+\textit{Top}: using partially open cells. The meridional scale factor at $v$-point 
+is reduced on both sides of the strait to account for the real width of the strait 
+(about 20 km). Note that the scale factors of the strait $T$-point remains unchanged. 
+\textit{Bottom}: using viscous boundary layers. The four fmask parameters 
+along the strait coastlines are set to a value larger than 4, $i.e.$ "strong" no-slip 
+case (see Fig.\ref{Fig_LBC_shlat}) creating a large viscous boundary layer 
+that allows a reduced transport through the strait.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+% -------------------------------------------------------------------------------------------------------------
+% Cross Land Advection 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Cross Land Advection (\textit{tracla} module)}
+\label{MISC_strait_cla}
+
+%--------------------------------------------namcla--------------------------------------------------------
+\namdisplay{namcla} 
+%--------------------------------------------------------------------------------------------------------------
+
+\colorbox{yellow}{Add a short description of CLA staff here or in lateral boundary condition chapter?}
+
+% ================================================================
+% Closed seas
+% ================================================================
+\section{Closed seas}
+\label{MISC_closea}
+
+
+% ================================================================
+% Sub-Domain Functionality (\textit{nizoom, njzoom}, namelist parameters)
+% ================================================================
+\section{Sub-Domain Functionality (\jp{jpizoom}, \jp{jpjzoom})}
+\label{MISC_zoom}
+
+The sub-domain functionality, also improperly called the zoom option 
+(improperly because it is not associated with a change in model resolution) 
+is a quite simple function that allows a simulation over a sub-domain of an 
+already defined configuration ($i.e.$ without defining a new mesh, initial 
+state and forcings). This option can be useful for testing the user settings 
+of surface boundary conditions, or the initial ocean state of a huge ocean 
+model configuration while having a small computer memory requirement. 
+It can also be used to easily test specific physics in a sub-domain (for example, 
+see \citep{Madec1996} for a test of the coupling used in the global ocean 
+version of OPA between sea-ice and ocean model over the Arctic or Antarctic 
+ocean, using a sub-domain). In the standard model, this option does not 
+include any specific treatment for the ocean boundaries of the sub-domain: 
+they are considered as artificial vertical walls. Nevertheless, it is quite easy 
+to add a restoring term toward a climatology in the vicinity of such boundaries 
+(see \S\ref{TRA_dmp}).
+
+In order to easily define a sub-domain over which the computation can be 
+performed, the dimension of all input arrays (ocean mesh, bathymetry, 
+forcing, initial state, ...) are defined as \jp{jpidta}, \jp{jpjdta} and \jp{jpkdta} 
+(\mdl{par\_oce} module), while the computational domain is defined through 
+\jp{jpiglo}, \jp{jpjglo} and \jp{jpk} (\mdl{par\_oce} module). When running the 
+model over the whole domain, the user sets \jp{jpiglo}=\jp{jpidta} \jp{jpjglo}=\jp{jpjdta} 
+and \jp{jpk}=\jp{jpkdta}. When running the model over a sub-domain, the user 
+has to provide the size of the sub-domain, (\jp{jpiglo}, \jp{jpjglo}, \jp{jpkglo}), 
+and the indices of the south western corner as \jp{jpizoom} and \jp{jpjzoom} in 
+the \mdl{par\_oce} module (Fig.~\ref{Fig_LBC_zoom}). 
+
+Note that a third set of dimensions exist, \jp{jpi}, \jp{jpj} and \jp{jpk} which is 
+actually used to perform the computation. It is set by default to \jp{jpi}=\jp{jpjglo} 
+and \jp{jpj}=\jp{jpjglo}, except for massively parallel computing where the 
+computational domain is laid out on local processor memories following a 2D 
+horizontal splitting. % (see {\S}IV.2-c) ref to the section to be updated
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_LBC_zoom}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_LBC_zoom.pdf}
+\caption {Position of a model domain compared to the data input domain when the zoom functionality is used.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+% ================================================================
+% 1D model functionality
+% ================================================================
+\section{Water column model: 1D model (\key{cfg\_1d})}
+\label{MISC_1D}
+
+The 1D model option simulates a stand alone water column within the 3D \NEMO 
+system. It can be applied to the ocean alone or to the ocean-ice system and can 
+include passive tracers or a biogeochemical model. It is set up by defining the 
+\key{cfg\_1d} CPP key. This 1D model is a very useful tool  \textit{(a)} to learn 
+about the physics and numerical treatment of vertical mixing processes ; \textit{(b)} 
+to investigate suitable parameterisations of unresolved turbulence (wind steering, 
+langmuir circulation, skin layers) ; \textit{(c)} to compare the behaviour of different 
+vertical mixing schemes  ; \textit{(d)} to perform sensitivity studies on the vertical 
+diffusion at a particular point of the ocean global domain ; \textit{(d)} to produce 
+extra diagnostics, without the large memory requirement of the full 3D model.
+
+The methodology is based on the use of the zoom functionality (see 
+\S\ref{MISC_zoom}), with some extra routines. There is no need to define a new 
+mesh, bathymetry, initial state or forcing, since the 1D model will use those of the 
+configuration it is a zoom of. 
+
+% ================================================================
+% Accelerating the Convergence 
+% ================================================================
+\section{Accelerating the Convergence (\np{nn\_acc} = 1)}
+\label{MISC_acc}
+%--------------------------------------------namdom-------------------------------------------------------
+\namdisplay{namdom} 
+%--------------------------------------------------------------------------------------------------------------
+
+% Steven update just bellow...   not sure it  is what I vant to say
+%Searching an equilibrium state with an ocean model requires repeated very long time 
+%integrations (each of a few thousand years for a global model). Due to the size of 
+Searching an equilibrium state with an ocean model requires very long time 
+integration (a few thousand years for a global model). Due to the size of 
+the time step required for numerical stability (less than a 
+few hours), this usually requires a large elapsed time. In order to overcome 
+this problem, \citet{Bryan1984} introduces a technique that is intended to accelerate 
+the spin up to equilibrium. It uses a larger time step in 
+the thermodynamic evolution equations than in the dynamic evolution 
+equations. It does not affect the equilibrium solution but modifies the 
+trajectory to reach it.
+
+The acceleration of convergence option is used when \np{nn\_acc}=1. In that case, 
+$\Delta t=rdt$ is the time step of dynamics while $\widetilde{\Delta t}=rdttra$ is the 
+tracer time-step. Their values are set from the \np{rdt} and \np{rdttra}  namelist 
+parameters. The set of prognostic equations to solve becomes:
+\begin{equation} \label{Eq_acc}
+\begin{split}
+\frac{\partial \textbf{U}_h }{\partial t} 
+	&\equiv \frac{\textbf{U}_h ^{t+1}-\textbf{U}_h^{t-1} }{2\Delta t} = \ldots \\ 
+\frac{\partial T}{\partial t} &\equiv \frac{T^{t+1}-T^{t-1}}{2 \widetilde{\Delta t}} = \ldots \\ 
+\frac{\partial S}{\partial t} &\equiv \frac{S^{t+1} -S^{t-1}}{2 \widetilde{\Delta t}} = \ldots \\ 
+\end{split}
+\end{equation}
+
+\citet{Bryan1984} has examined the consequences of this distorted physics. 
+Free waves have a slower phase speed, their meridional structure is slightly 
+modified, and the growth rate of baroclinically unstable waves is reduced 
+but with a wider range of instability. This technique is efficient for 
+searching for an equilibrium state in coarse resolution models. However its 
+application is not suitable for many oceanic problems: it cannot be used for 
+transient or time evolving problems (in particular, it is very questionable 
+to use this technique when there is a seasonal cycle in the forcing fields), 
+and it cannot be used in high-resolution models where baroclinically 
+unstable processes are important. Moreover, the vertical variation of 
+$\widetilde{ \Delta t}$ implies that the heat and salt contents are no longer 
+conserved due to the vertical coupling of the ocean level through both 
+advection and diffusion.
+% first mention of depth varying tilda-delta-t!   and namelist parameter associated to that are to be described
+
+
+% ================================================================
+% Model optimisation, Control Print and Benchmark
+% ================================================================
+\section{Model Optimisation, Control Print and Benchmark}
+\label{MISC_opt}
+%--------------------------------------------namctl-------------------------------------------------------
+\namdisplay{namctl} 
+%--------------------------------------------------------------------------------------------------------------
+
+% \gmcomment{why not make these bullets into subsections?}
+
+Three issues to be described here:
+
+$\bullet$ Vector and memory optimisation:
+
+\key{vectopt\_loop} enables internal loop collapse, a very efficient way to increase 
+the length of vector calculations and thus speed up the model on vector computers.
+ 
+% Add here also one word on NPROMA technique that has been found useless, since compiler have made significant progress during the last decade.
+ 
+% Add also one word on NEC specific optimisation (Novercheck option for example)
+
+\key{vectopt\_memory} has been introduced in order to reduce the memory 
+requirement of the model. This is obviously done at the cost of increasing the 
+CPU time requirement, since it suppress intermediate computations which would 
+have been saved in in-core memory. This feature has not been intensively used. 
+In fact, currently it is only implemented for the TKE physics, in which,  when 
+\key{vectopt\_memory} is defined, the coefficients used for horizontal smoothing 
+of $A_v^T$ and $A_v^m$ are no longer computed once and for all. This reduces 
+the memory requirement by three 2D arrays.
+
+ 
+$\bullet$ Control print %: describe here 4 things:
+
+1- \np{ln\_ctl} : compute and print the trends averaged over the interior domain 
+in all TRA, DYN, LDF and ZDF modules. This option is very helpful when 
+diagnosing the origin of an undesired change in model results. 
+
+2- also \np{ln\_ctl} but using the nictl and njctl namelist parameters to check 
+the source of differences between mono and multi processor runs.
+
+3- \key{esopa} (to be rename key\_nemo) : which is another option for model 
+management. When defined, this key forces the activation of all options and 
+CPP keys. For example, all tracer and momentum advection schemes are called! 
+There is therefore no physical meaning associated with the model results. 
+However, this option forces both the compiler and the model to run through 
+all the \textsc{Fortran} lines of the model. This allows the user to check for obvious 
+compilation or execution errors with all CPP options, and errors in namelist options.
+
+3- \key{esopa} (to be rename key\_nemo) : which is another option for model 
+management. When defined, this key forces the activation of all options and CPP keys. 
+For example, all tracer and momentum advection schemes are called! There is 
+therefore no physical meaning associated with the model results. However, this option 
+forces both the compiler and the model to run through all the Fortran lines of the model. 
+This allows the user to check for obvious compilation or execution errors with all CPP 
+options, and errors in namelist options.
+
+4- last digit comparison (\np{nbit\_cmp}). In an MPP simulation, the computation of 
+a sum over the whole domain is performed as the summation over all processors of 
+each of their sums over their interior domains. This double sum never gives exactly 
+the same result as a single sum over the whole domain, due to truncation differences. 
+The "bit comparison" option has been introduced in order to be able to check that 
+mono-processor and multi-processor runs give exactly the same results. 
+
+$\bullet$  Benchmark (\np{nbench}). This option defines a benchmark run based on 
+a GYRE configuration in which the resolution remains the same whatever the domain 
+size. This allows a very large model domain to be used, just by changing the domain 
+size (\jp{jpiglo}, \jp{jpjglo}) and without adjusting either the time-step or the physical 
+parameterisations. 
+
+
+% ================================================================
+% Elliptic solvers (SOL)
+% ================================================================
+\section{Elliptic solvers (SOL directory)}
+\label{MISC_sol}
+%--------------------------------------------namdom-------------------------------------------------------
+\namdisplay{namsol} 
+%--------------------------------------------------------------------------------------------------------------
+
+The computation of the surface pressure gradient with a rigid lid assumption 
+requires the computation of $\partial_t \psi$, the time evolution of the 
+barotropic streamfunction. $\partial_t \psi$ is the solution of an elliptic 
+equation \eqref{Eq_PE_psi} for which three solvers are available: a 
+Successive-Over-Relaxation scheme (SOR), a preconditioned conjugate gradient 
+scheme(PCG) \citep{Madec1988, Madec1990} and a Finite Elements Tearing and 
+Interconnecting scheme (FETI) \citep{Guyon_al_EP99, Guyon_al_CalPar99}. 
+The PCG is a very efficient method for solving elliptic equations on vector computers. 
+It is a fast and rather easy method to use; which are attractive features for a large 
+number of ocean situations (variable bottom topography, complex coastal geometry, 
+variable grid spacing, islands, open or cyclic boundaries, etc ...). It does not require 
+a search for an optimal parameter as in the SOR method. However, the SOR has 
+been retained because it is a linear solver, which is a very useful property when 
+using the adjoint model of \NEMO. The FETI solver is a very efficient method on 
+massively parallel computers. However, it has never been used since OPA 8.0. 
+The current version in \NEMO should not even successfully go through the 
+compilation phase. 
+
+The surface pressure gradient is computed in \mdl{dynspg}. The solver used 
+(PCG or SOR) depending on the value of \np{nsolv} (namelist parameter). 
+At each time step the time derivative of the barotropic streamfunction is 
+the solution of \eqref{Eq_psi_total}. Introducing the following coefficients:
+
+\begin{equation} 
+\begin{aligned}
+&C_{i,j}^{NS} &&= \frac{e_{2v}(i,j)}{\left( H_v (i,j) e_{1v} (i,j)\right)}\\
+&C_{i,j}^{EW} &&= \frac{e_{1u}(i,j)}{\left( H_u (i,j) e_{2u} (i,j)\right)}\\
+&B_{i,j} &&= \delta_i \left( e_{2v}M_v \right) - \delta_j \left( e_{1u}M_u \right)\\
+\end{aligned}
+\end{equation}
+
+the five-point finite difference equation \eqref{Eq_psi_total} can be rewritten as:
+
+\begin{multline} \label{Eq_solmat}
+C_{i+1,j}^{NS} {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i+1,j} + \;
+C_{i,j+1}^{EW}{   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j+1} + \;
+C_{i,j}    ^{NS} {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i-1,j} + \;
+C_{i,j}    ^{EW}{   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j-1}\\
+-\left(C_{i+1,j}^{NS} + C_{i,j+1}^{EW} + C_{i,j}^{NS} + C_{i,j}^{EW} \right)   {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j}  =  B_{i,j}
+\end{multline}
+\eqref{Eq_solmat} is a linear symmetric system of equations. All the elements of 
+the corresponding matrix \textbf{A} vanish except those of five diagonals. With 
+the natural ordering of the grid points (i.e. from west to east and from 
+south to north), the structure of \textbf{A} is block-tridiagonal with 
+tridiagonal or diagonal blocks. \textbf{A} is a positive-definite symmetric 
+matrix of size $(jpi \cdot jpj)^2$, and \textbf{B}, the right hand side of 
+\eqref{Eq_solmat}, is a vector.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Successive Over Relaxation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Successive Over Relaxation \np{nsolv}=2}
+\label{MISC_solsor}
+
+Let us introduce the four cardinal coefficients: $A_{i,j}^S = C_{i,j}^{NS}/D_{i,j}\,$, 
+$A_{i,j}^W = C_{i,j}^{EW}/D_{i,j}\,$, $A_{i,j}^E = C_{i,j+1}^{EW}/D_{i,j}\,$ and $A_{i,j}^N = C_{i+1,j}^{NS}/D_{i,j}\,$, and define 
+$\tilde B_{i,j} = B_{i,j}/D_{i,j}\,$, where $D_{i,j} = C_{i,j}^{NS}+ C_{i+1,j}^{NS} + C_{i,j}^{EW} + C_{i,j+1}^{EW} $ (i.e. the diagonal of 
+\textbf{A}). (VII.5.1) can be rewritten as:
+
+\begin{multline} \label{Eq_solmat_p}
+    A_{i,j}^{N}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i+1,j   } 
++\,A_{i,j}^{E}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i    ,j+1} 		\\
++\,A_{i,j}^{S}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i-1 ,j    } 
++\,A_{i,j}^{W} {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i    ,j-1} 	
+               -  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j} = \tilde B_{i,j}
+\end{multline}
+
+The SOR method used is an iterative method. Its algorithm can be summarised 
+as follows [see \citet{Haltiner1980} for a further discussion]:
+
+initialisation (evaluate a first guess from previous time step computations)
+\begin{equation}
+\left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^0 = 2{\left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^t} - {\left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^{t-1}}
+\end{equation}
+iteration $n$, from $n=0$ until convergence, do :
+\begin{multline} 
+R_{i,j}^n
+= A_{i,j}^{N}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i+1,j}^n 
++\,A_{i,j}^{E}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j+1} ^n		\\
++\,A_{i,j}^{S}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i-1,j} ^{n+1}
++\,A_{i,j}^{W} {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j-1} ^{n+1}	
+                   -  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j}^n - \tilde B_{i,j}
+\end{multline}
+\begin{equation} 
+     {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j} ^{n+1}
+  = {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j} ^{n}
+  + \omega \;R_{i,j}^n
+\end{equation}
+where \textit{$\omega $ }satisfies $1\leq \omega \leq 2$. An optimal value exists for 
+\textit{$\omega$} which significantly accelerates the convergence, but it has to be 
+adjusted empirically for each model domain (except for a uniform grid where an 
+analytical expression for \textit{$\omega$} can be found \citep{Richtmyer1967}). 
+The value of $\omega$ is set using \textit{sor}, a \textbf{namelist} parameter. 
+The convergence test is of the form:
+\begin{equation}
+\delta = \frac{\sum\limits_{i,j}{R_{i,j}^n}{R_{i,j}^n}}{\sum\limits_{i,j}{ \tilde B_{i,j}^n}{\tilde B_{i,j}^n}} \leq \epsilon
+\end{equation}
+where $\epsilon$ is the absolute precision that is required. It is recommended 
+that a value smaller or equal to $10^{-3}$ is used for $\epsilon$ since larger 
+values may lead to numerically induced basin scale barotropic oscillations. In fact, 
+for an eddy resolving configuration or in a filtered free surface case, a value three 
+orders of magnitude smaller than this should be used. The precision is specified by 
+setting \textit{eps} (\textbf{namelist parameter}). In addition, two other tests are 
+used to halt the iterative algorithm. They involve the number of iterations and the 
+modulus of the right hand side. If the former exceeds a specified value, \textit{nmax} 
+(\textbf{namelist parameter}), or the latter is greater than $10^{15}$, the whole 
+model computation is stopped and the last computed time step fields are saved 
+in the standard output file. In both cases, this usually indicates that there is something 
+wrong in the model configuration (an error in the mesh, the initial state, the input forcing, 
+or the magnitude of the time step or of the mixing coefficients). A typical value of 
+$nmax$ is a few hundred when $\epsilon = 10^{-6}$, increasing to a few 
+thousand when $\epsilon = 10^{-12}$.
+The vectorization of the SOR algorithm is not straightforward. The scheme
+contains two linear recurrences on $i$ and $j$. This inhibits the vectorisation. 
+Therefore it has been rewritten as:
+
+\begin{multline} 
+R_{i,j}^n
+= A_{i,j}^{N}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i+1,j}^n 
++\,A_{i,j}^{E}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j+1} ^n		\\
++\,A_{i,j}^{S}  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i-1,j} ^{n}
++\,A_{i,j}^{W} {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j-1} ^{n}	
+                   -  {   \left(  \frac{\partial \psi}{\partial t } \right)    }_{i,j}^n - \tilde B_{i,j}
+\end{multline}
+
+\begin{equation}
+R_{i,j}^n = R_{i,j}^n - \omega \;A_{i,j}^{S}\; R_{i,j-1}^n
+\end{equation}
+
+\begin{equation}
+R_{i,j}^n = R_{i,j}^n - \omega \;A_{i,j}^{W}\; R_{i-1,j}^n
+\end{equation}
+
+The SOR method is very flexible and can be used under a wide 
+range of conditions, including irregular boundaries, interior boundary 
+points, etc. Proofs of convergence, etc. may be found in the standard 
+numerical methods texts for partial differential equations.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Preconditioned Conjugate Gradient
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Preconditioned Conjugate Gradient}
+\label{MISC_solpcg}
+
+\begin{flushright}
+(\textit{nbsfs=1}, \textbf{namelist parameter})
+\end{flushright}
+
+\textbf{A} is a definite positive symmetric matrix, thus solving the linear 
+system \eqref{Eq_solmat} is equivalent to the minimisation of a quadratic 
+functional:
+\begin{equation*}
+\textbf{Ax} = \textbf{b} \leftrightarrow \textbf{x} =\text{inf}_{y} \,\phi (\textbf{y})
+\quad , \qquad
+\phi (\textbf{y}) = 1/2 \langle \textbf{Ay},\textbf{y}\rangle - \langle \textbf{b},\textbf{y} \rangle 
+\end{equation*}
+where $\langle , \rangle$ is the canonical dot product. The idea of the 
+conjugate gradient method is to search for the solution in the following 
+iterative way: assuming that $\textbf{x}^n$ has been obtained, $\textbf{x}^{n+1}$ 
+is found from $\textbf {x}^{n+1}={\textbf {x}}^n+\alpha^n{\textbf {d}}^n$ which satisfies:
+\begin{equation*}
+{\textbf{ x}}^{n+1}=\text{inf} _{{\textbf{ y}}={\textbf{ x}}^n+\alpha^n \,{\textbf{ d}}^n} \,\phi ({\textbf{ y}})\;\;\Leftrightarrow \;\;\frac{d\phi }{d\alpha}=0
+\end{equation*}
+and expressing $\phi (\textbf{y})$ as a function of \textit{$\alpha $}, we obtain the 
+value that minimises the functional: 
+\begin{equation*}
+\alpha ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle  / \langle {\textbf{ A d}^n, \textbf{d}^n} \rangle
+\end{equation*}
+where $\textbf{r}^n = \textbf{b}-\textbf{A x}^n = \textbf{A} (\textbf{x}-\textbf{x}^n)$ 
+is the error at rank $n$. The descent vector $\textbf{d}^n$ s chosen to be dependent 
+on the error: $\textbf{d}^n = \textbf{r}^n + \beta^n \,\textbf{d}^{n-1}$. $\beta ^n$ 
+is searched such that the descent vectors form an orthogonal basis for the dot 
+product linked to \textbf{A}. Expressing the condition 
+$\langle \textbf{A d}^n, \textbf{d}^{n-1} \rangle = 0$ the value of $\beta ^n$ is found:
+ $\beta ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle  / \langle {\textbf{r}^{n-1}, \textbf{r}^{n-1}} \rangle$. 
+ As a result, the errors $ \textbf{r}^n$ form an orthogonal 
+base for the canonic dot product while the descent vectors $\textbf{d}^n$ form 
+an orthogonal base for the dot product linked to \textbf{A}. The resulting 
+algorithm is thus the following one:
+
+initialisation :
+
+\begin{equation*} 
+\textbf{x}^0 = \left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^0 = 2{\left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^t} - {\left(  \frac{\partial \psi}{\partial t } \right)_{i,j}^{t-1}}
+, \text{the initial guess }
+\end{equation*}
+
+\begin{equation*}
+\textbf{r}^0 = \textbf{d}^0 = \textbf{b} - \textbf{A x}^0
+\end{equation*}
+\begin{equation*}
+\gamma_0 = \langle{ \textbf{r}^0 , \textbf{r}^0} \rangle
+\end{equation*}
+iteration $n,$ from $n=0$ until convergence, do :
+
+\begin{equation} 
+\begin{split}
+\text{z}^n& = \textbf{A d}^n \\
+\alpha_n &= \gamma_n  \langle{ \textbf{z}^n , \textbf{d}^n} \rangle \\
+\textbf{x}^{n+1} &= \textbf{x}^n + \alpha_n \,\textbf{d}^n \\
+\textbf{r}^{n+1} &= \textbf{r}^n - \alpha_n \,\textbf{z}^n \\
+\gamma_{n+1} &= \langle{ \textbf{r}^{n+1} , \textbf{r}^{n+1}} \rangle \\
+\beta_{n+1} &= \gamma_{n+1}/\gamma_{n}  \\
+\textbf{d}^{n+1} &= \textbf{r}^{n+1} + \beta_{n+1}\; \textbf{d}^{n}\\
+\end{split}
+\end{equation}
+
+
+The convergence test is:
+
+\begin{equation}
+\delta = \gamma_{n}\; / \langle{ \textbf{b} , \textbf{b}} \rangle \leq \epsilon
+\end{equation}
+where $\epsilon $ is the absolute precision that is required. As for the SOR algorithm, 
+the whole model computation is stopped when the number of iterations, $nmax$, or 
+the modulus of the right hand side of the convergence equation exceeds a 
+specified value (see \S\ref{MISC_solsor} for a further discussion). The required 
+precision and the maximum number of iterations allowed are specified by setting 
+$eps$ and $nmax$ (\textbf{namelist parameters}).
+
+It can be demonstrated that the above algorithm is optimal, provides the exact 
+solution in a number of iterations equal to the size of the matrix, and that 
+the convergence rate is faster as the matrix is closer to the identity matrix,
+$i.e.$ its eigenvalues are closer to 1. Therefore, it is more efficient to solve a 
+better conditioned system which has the same solution. For that purpose, we 
+introduce a preconditioning matrix \textbf{Q} which is an approximation of 
+\textbf{A} but much easier to invert than \textbf{A}, and solve the system:
+\begin{equation} \label{Eq_pmat}
+\textbf{Q}^{-1} \textbf{A x} = \textbf{Q}^{-1} \textbf{b}
+\end{equation}
+
+The same algorithm can be used to solve \eqref{Eq_pmat} if instead of the 
+canonical dot product the following one is used: 
+${\langle{ \textbf{a} , \textbf{b}} \rangle}_Q = \langle{ \textbf{a} , \textbf{Q b}} \rangle$, and 
+if $\textbf{\~{b}} = \textbf{Q}^{-1}\;\textbf{b}$ and $\textbf{\~{A}} = \textbf{Q}^{-1}\;\textbf{A}$ 
+are substituted to \textbf{b} and \textbf{A} \citep{Madec1988}. 
+In \NEMO, \textbf{Q} is chosen as the diagonal of \textbf{ A}, i.e. the simplest form for 
+\textbf{Q} so that it can be easily inverted. In this case, the discrete formulation of 
+\eqref{Eq_pmat} is in fact given by \eqref{Eq_solmat_p} and thus the matrix and 
+right hand side are computed independently from the solver used.
+
+% -------------------------------------------------------------------------------------------------------------
+%       FETI
+% -------------------------------------------------------------------------------------------------------------
+\subsection{FETI}
+\label{MISC_solfeti}
+
+FETI is a powerful solver that was developed by Marc Guyon  \citep{Guyon_al_EP99, 
+Guyon_al_CalPar99}. It has been converted from Fortan 77 to 90, but never 
+successfully tested after that. 
+
+Its main advantage is to save a lot of CPU time when compared to the SOR or PCG 
+algorithms. However, its main drawback is that the solution is dependent on the 
+domain decomposition chosen. Using a different number of processors, the solution 
+is the same at the precision required, but not the same at the computer precision. 
+This make it hard to debug.  
+
+% -------------------------------------------------------------------------------------------------------------
+%       Boundary Conditions --- Islands
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Boundary Conditions --- Islands (\key{islands})}
+\label{MISC_solisl}
+
+The boundary condition used for both recommended solvers is that the time 
+derivative of the barotropic streamfunction is zero along all the coastlines. 
+When islands are present in the model domain, additional computations must 
+be performed to determine the barotropic streamfunction with the correct boundary 
+conditions. This is detailed below.
+
+The model does not have specialised code for islands. They must instead be 
+identified to the solvers by the user via bathymetry information, i.e. the $mbathy$ 
+array should equal $-1$ over the first island, $-2$ over the second, ... , $-N$ over 
+the $N^{th}$ island. The model determines the position of island grid-points and 
+defines a closed contour around each island which is used to compute the circulation 
+around each one. The closed contour is formed from the ocean grid-points which 
+are the closest to the island.
+
+First, the island barotropic streamfunctions $\psi_n$ are computed using the SOR 
+or PCG scheme (they are solutions of \eqref{Eq_solmat} with the right-hand side 
+equal to zero and with $\psi_n = 1$ along the island $n$ and $\psi_n = 0$ along 
+the other coastlines) (Note that specifying $1$ as boundary condition on an island 
+for $\psi$ is equivalent to defining a specific right hand side for \eqref{Eq_solmat}). 
+The requested precision of this computation can be very high since it is only 
+performed once. The absolute precision, $epsisl$, and the maximum number of 
+iterations allowed, $nmisl$, are the \textbf{namelist parameters} used for this 
+computation. Their typical values are $epsisl = 10^{-10}$ and $nmisl = 4000$. 
+Then the island matrix A is computed from \eqref{Eq_PE_psi_isl_matrix} and 
+inverted. At each time step, $\psi_0$, the solution of \eqref{Eq_solmat} with $\psi = 0$ 
+along all coastlines, is computed using either SOR or PCG. (It should
+be noted that the first guess of this computation remains as usual except that 
+$\partial_t \psi_0$ is used, instead of $\partial_t \psi$. Indeed we are 
+computing $\partial_t \psi_0$ which is usually very different from $\partial_t \psi$.)
+Then, it is easy to find the time evolution of the barotropic streamfunction on each 
+island and to deduce $\partial_t \psi$, and to use it to compute the surface pressure 
+gradient. Note that the value of the barotropic streamfunction itself is also computed 
+as the time integration of $\partial_t \psi$ for further diagnostics.
+
+% ================================================================
+% Diagnostics
+% ================================================================
+\section{Diagnostics }
+\label{MISC_diag}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Standard Model Output 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Standard Model Output (default option or \key{dimg})}
+\label{MISC_iom}
+
+%to be updated with Seb documentation on the IO
+\amtcomment{ 
+The model outputs are of three types: the restart file, the output listing, 
+and the output file(s). The restart file is used internally by the code when 
+the user wants to start the model with initial conditions defined by a 
+previous simulation. It contains all the information that is necessary in 
+order for there to be no changes in the model results (even at the computer 
+precision) between a run performed with several restarts and the same run 
+performed in one step. It should be noted that this requires that the restart file 
+contain two consecutive time steps for all the prognostic variables, and 
+that it is saved in the same binary format as the one used by the computer 
+that is to read it (in particular, 32 bits binary IEEE format must not be used for 
+this file). The output listing and file(s) are predefined but should be checked 
+and eventually adapted to the user's needs. The output listing is stored in 
+the $ocean.output$ file. The information is printed from within the code on the 
+logical unit $numout$. To locate these prints, use the UNIX command 
+"$grep -i numout^*$" in the source code directory.
+
+In the standard configuration, the user will find the model results in two 
+output files containing values for every time-step where output is demanded: 
+a \textbf{VO} file containing all the three dimensional fields in logical unit 
+$numwvo$, and a \textbf{SO} file containing all the two dimensional (horizontal) 
+fields in logical unit $numwso$. These outputs are defined in the $diawri.F$ 
+routine. The default and user-selectable diagnostics are described in {\S}III-12-c.
+
+The default output (for all output files apart from the restart file) is 32 bits binary 
+IEEE format, compatible with the Vairmer software (see the Climate Modelling 
+and global Change team WEB server at CERFACS: http://www.cerfacs.fr). 
+The model's reference directory also contains a visualisation tool based on 
+\textbf{NCAR Graphics} (http://ngwww.ucar.edu). If a user has access to the 
+NCAR software, he or she can copy the \textbf{LODMODEL/UTILS/OPADRA} 
+directory from the reference and, following the \textbf{README}, create 
+graphical outputs from the model's results.
+}
+
+% -------------------------------------------------------------------------------------------------------------
+%       Tracer/Dynamics Trends
+% -------------------------------------------------------------------------------------------------------------
+\subsection[Tracer/Dynamics Trends (\key{trdlmd}, \textbf{key\_diatrd...})]
+                  {Tracer/Dynamics Trends (\key{trdlmd}, \key{diatrdtra}, \key{diatrddyn})}
+\label{MISC_tratrd}
+
+%to be udated this corresponds to OPA8
+When \key{diatrddyn} and/or \key{diatrddyn} cpp variables are defined, each 
+trend of the dynamics and/or temperature and salinity time evolution equations 
+is stored in three-dimensional arrays just after their computation ($i.e.$ at the end 
+of each $dyn\cdots .F90$ and/or $tra\cdots .F90$ routine). These trends are then 
+used in diagnostic routines $diadyn.F90$ and $diatra.F90$ respectively. 
+In the standard model, these routines check the basin averaged properties of 
+the momentum and tracer equations every \textit{ntrd } time-steps (\textbf{namelist 
+parameter}). These routines are supplied as an example; they must be adapted by 
+the user to his/her requirements.
+
+These two options imply the creation of several extra arrays in the in-core 
+memory, increasing quite seriously the code memory requirements.
+
+% -------------------------------------------------------------------------------------------------------------
+%       On-line Floats trajectories
+% -------------------------------------------------------------------------------------------------------------
+\subsection{On-line Floats trajectories}
+\label{FLO}
+%--------------------------------------------namflo-------------------------------------------------------
+\namdisplay{namflo} 
+%--------------------------------------------------------------------------------------------------------------
+
+The on-line computation of floats adevected either by the three dimensional velocity 
+field or constraint to remain at a given depth ($w = 0$ in the computation) have been 
+introduced in the system during the CLIPPER project. The algorithm used is based on 
+the work of \cite{Blanke_Raynaud_JPO97}. (see also the web site describing the off-line 
+use of this marvellous diagnostic tool (http://stockage.univ-brest.fr/~grima/Ariane/).
+
+% -------------------------------------------------------------------------------------------------------------
+%       Other Diagnostics
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Other Diagnostics}
+\label{MISC_diag_others}
+
+%To be updated  this mainly corresponds to OPA 8
+
+Aside from the standard model variables, other diagnostics can be computed 
+on-line or can be added to the model. The available ready-to-add diagnostics 
+routines can be found in directory DIA. Among the available diagnostics are: 
+
+- the mixed layer depth (based on a density criterion) (\mdl{diamxl})
+
+- the turbocline depth (based on a turbulent mixing coefficient criterion) (\mdl{diamxl})
+
+- the depth of the 20\r{}C isotherm (\mdl{diahth})
+
+- the depth of the thermocline (maximum of the vertical temperature gradient) (\mdl{diahth})
+
+- the meridional heat and salt transports and their decomposition (\mdl{diamfl})
+
+- the surface pressure (\mdl{diaspr})
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics.tex	(revision 1844)
@@ -0,0 +1,1304 @@
+% ================================================================
+% Chapter 1 Ñ Model Basics
+% ================================================================
+
+\chapter{Model basics}
+\label{PE}
+\minitoc
+
+
+% ================================================================
+% Primitive Equations
+% ================================================================
+\section{Primitive Equations}
+\label{PE_PE}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Vector Invariant Formulation 
+% -------------------------------------------------------------------------------------------------------------
+
+\subsection{Vector Invariant Formulation}
+\label{PE_Vector}
+
+
+The ocean is a fluid that can be described to a good approximation by the primitive 
+equations, $i.e.$ the Navier-Stokes equations along with a nonlinear equation of 
+state which couples the two active tracers (temperature and salinity) to the fluid 
+velocity, plus the following additional assumptions made from scale considerations:
+
+\textit{(1) spherical earth approximation: }the geopotential surfaces are assumed to 
+be spheres so that gravity (local vertical) is parallel to the earth's radius
+
+\textit{(2) thin-shell approximation: }the ocean depth is neglected compared to the earth's radius
+
+\textit{(3) turbulent closure hypothesis: }the turbulent fluxes (which represent the effect 
+of small scale processes on the large-scale) are expressed in terms of large-scale features
+
+\textit{(4) Boussinesq hypothesis:} density variations are neglected except in their 
+contribution to the buoyancy force
+
+\textit{(5) Hydrostatic hypothesis: }the vertical momentum equation is reduced to a 
+balance between the vertical pressure gradient and the buoyancy force (this removes 
+convective processes from the initial Navier-Stokes equations and so convective processes 
+must be parameterized instead)
+
+\textit{(6) Incompressibility hypothesis: }the three dimensional divergence of the velocity 
+vector is assumed to be zero.
+
+Because the gravitational force is so dominant in the equations of large-scale motions, 
+it is useful to choose an orthogonal set of unit vectors (\textbf{i},\textbf{j},\textbf{k}) linked 
+to the earth such that \textbf{k} is the local upward vector and (\textbf{i},\textbf{j}) are two 
+vectors orthogonal to \textbf{k}, $i.e.$ tangent to the geopotential surfaces. Let us define 
+the following variables: \textbf{U} the vector velocity, $\textbf{U}=\textbf{U}_h + w\, \textbf{k}$ 
+(the subscript $h$ denotes the local horizontal vector, $i.e.$ over the (\textbf{i},\textbf{j}) plane), 
+$T$ the potential temperature, $S$ the salinity, \textit{$\rho $} the \textit{in situ} density. 
+The vector invariant form of the primitive equations in the (\textbf{i},\textbf{j},\textbf{k}) 
+vector system provides the following six equations (namely the momentum balance, the 
+hydrostatic equilibrium, the incompressibility equation, the heat and salt conservation 
+equations and an equation of state):
+\begin{subequations} \label{Eq_PE}
+  \begin{equation}     \label{Eq_PE_dyn}
+\frac{\partial {\rm {\bf U}}_h }{\partial t}=
+-\left[    {\left( {\nabla \times {\rm {\bf U}}} \right)\times {\rm {\bf U}}
+            +\frac{1}{2}\nabla \left( {{\rm {\bf U}}^2} \right)}    \right]_h
+ -f\;{\rm {\bf k}}\times {\rm {\bf U}}_h 
+-\frac{1}{\rho _o }\nabla _h p + {\rm {\bf D}}^{\rm {\bf U}} + {\rm {\bf F}}^{\rm {\bf U}}
+  \end{equation}
+  \begin{equation}     \label{Eq_PE_hydrostatic}
+\frac{\partial p }{\partial z} = - \rho \ g
+  \end{equation}
+  \begin{equation}     \label{Eq_PE_continuity}
+\nabla \cdot {\bf U}=  0
+  \end{equation}
+\begin{equation} \label{Eq_PE_tra_T}
+\frac{\partial T}{\partial t} = - \nabla \cdot  \left( T \ \rm{\bf U} \right) + D^T + F^T
+  \end{equation}
+  \begin{equation}     \label{Eq_PE_tra_S}
+\frac{\partial S}{\partial t} = - \nabla \cdot  \left( S \ \rm{\bf U} \right) + D^S + F^S
+  \end{equation}
+  \begin{equation}     \label{Eq_PE_eos}
+\rho = \rho \left( T,S,p \right)
+  \end{equation}
+\end{subequations}
+where $\nabla$ is the generalised derivative vector operator in $(\bf i,\bf j, \bf k)$ directions, 
+$t$ is the time, $z$ is the vertical coordinate, $\rho $ is the \textit{in situ} density given by 
+the equation of state (\ref{Eq_PE_eos}), $\rho_o$ is a reference density, $p$ the pressure, 
+$f=2 \bf \Omega \cdot \bf k$ is the Coriolis acceleration (where $\bf \Omega$ is the Earth's 
+angular velocity vector), and $g$ is the gravitational acceleration. 
+${\rm {\bf D}}^{\rm {\bf U}}$, $D^T$ and $D^S$ are the parameterisations of small-scale 
+physics for momentum, temperature and salinity, and ${\rm {\bf F}}^{\rm {\bf U}}$, $F^T$ 
+and $F^S$ surface forcing terms. Their nature and formulation are discussed in 
+\S\ref{PE_zdf_ldf} and page \S\ref{PE_boundary_condition}.
+
+.
+
+% -------------------------------------------------------------------------------------------------------------
+% Boundary condition
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Boundary Conditions}
+\label{PE_boundary_condition}
+
+An ocean is bounded by complex coastlines, bottom topography at its base and an air-sea 
+or ice-sea interface at its top. These boundaries can be defined by two surfaces, $z=-H(i,j)$ 
+and $z=\eta(i,j,k,t)$, where $H$ is the depth of the ocean bottom and $\eta$ is the height 
+of the sea surface. Both $H$ and $\eta$ are usually referenced to a given surface, $z=0$, 
+chosen as a mean sea surface (Fig.~\ref{Fig_ocean_bc}). Through these two boundaries, 
+the ocean can exchange fluxes of heat, fresh water, salt, and momentum with the solid earth, 
+the continental margins, the sea ice and the atmosphere. However, some of these fluxes are 
+so weak that even on climatic time scales of thousands of years they can be neglected. 
+In the following, we briefly review the fluxes exchanged at the interfaces between the ocean 
+and the other components of the earth system.
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!ht] \label{Fig_ocean_bc}  \begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_I_ocean_bc.pdf}
+\caption{The ocean is bounded by two surfaces, $z=-H(i,j)$ and $z=\eta(i,j,k,t)$, where $H$ 
+is the depth of the sea floor and $\eta$ the height of the sea surface. Both $H$ and $\eta $ 
+are referenced to $z=0$.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+\begin{description}
+\item[Land - ocean interface:] the major flux between continental margins and the ocean is 
+a mass exchange of fresh water through river runoff. Such an exchange modifies the sea 
+surface salinity especially in the vicinity of major river mouths. It can be neglected for short 
+range integrations but has to be taken into account for long term integrations as it influences 
+the characteristics of water masses formed (especially at high latitudes). It is required in order 
+to close the water cycle of the climate system. It is usually specified as a fresh water flux at 
+the air-sea interface in the vicinity of river mouths.
+\item[Solid earth - ocean interface:] heat and salt fluxes through the sea floor are small, 
+except in special areas of little extent. They are usually neglected in the model 
+\footnote{In fact, it has been shown that the heat flux associated with the solid Earth cooling 
+($i.e.$the geothermal heating) is not negligible for the thermohaline circulation of the world 
+ocean (see \ref{TRA_bbc}).}. 
+The boundary condition is thus set to no flux of heat and salt across solid boundaries. 
+For momentum, the situation is different. There is no flow across solid boundaries, 
+$i.e.$ the velocity normal to the ocean bottom and coastlines is zero (in other words, 
+the bottom velocity is parallel to solid boundaries). This kinematic boundary condition 
+can be expressed as:
+\begin{equation} \label{Eq_PE_w_bbc}
+w = -{\rm {\bf U}}_h \cdot  \nabla _h \left( H \right)
+\end{equation}
+In addition, the ocean exchanges momentum with the earth through frictional processes. 
+Such momentum transfer occurs at small scales in a boundary layer. It must be parameterized 
+in terms of turbulent fluxes using bottom and/or lateral boundary conditions. Its specification 
+depends on the nature of the physical parameterisation used for ${\rm {\bf D}}^{\rm {\bf U}}$ 
+in \eqref{Eq_PE_dyn}. It is discussed in \S\ref{PE_zdf}, page~\pageref{PE_zdf}.% and Chap. III.6 to 9.
+\item[Atmosphere - ocean interface:] the kinematic surface condition plus the mass flux 
+of fresh water PE  (the precipitation minus evaporation budget) leads to: 
+\begin{equation} \label{Eq_PE_w_sbc}
+w = \frac{\partial \eta }{\partial t} 
+    + \left. {{\rm {\bf U}}_h } \right|_{z=\eta } \cdot  \nabla _h \left( \eta \right) 
+    + P-E
+\end{equation}
+The dynamic boundary condition, neglecting the surface tension (which removes capillary 
+waves from the system) leads to the continuity of pressure across the interface $z=\eta$. 
+The atmosphere and ocean also exchange horizontal momentum (wind stress), and heat.
+\item[Sea ice - ocean interface:] the ocean and sea ice exchange heat, salt, fresh water 
+and momentum. The sea surface temperature is constrained to be at the freezing point 
+at the interface. Sea ice salinity is very low ($\sim4-6 \,psu$) compared to those of the 
+ocean ($\sim34 \,psu$). The cycle of freezing/melting is associated with fresh water and 
+salt fluxes that cannot be neglected.
+\end{description}
+
+
+% ================================================================
+% The Horizontal Pressure Gradient
+% ================================================================
+\section{The Horizontal Pressure Gradient }
+\label{PE_hor_pg}
+
+% -------------------------------------------------------------------------------------------------------------
+% Pressure Formulation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Pressure Formulation}
+\label{PE_p_formulation}
+
+The total pressure at a given depth $z$ is composed of a surface pressure $p_s$ at a 
+reference geopotential surface ($z=0$) and a hydrostatic pressure $p_h$ such that: 
+$p(i,j,k,t)=p_s(i,j,t)+p_h(i,j,k,t)$. The latter is computed by integrating (\ref{Eq_PE_hydrostatic}), 
+assuming that pressure in decibars can be approximated by depth in meters in (\ref{Eq_PE_eos}). 
+The hydrostatic pressure is then given by:
+\begin{equation} \label{Eq_PE_pressure}
+p_h \left( {i,j,z,t} \right)
+ = \int_{\varsigma =z}^{\varsigma =0} {g\;\rho \left( {T,S,\varsigma} \right)\;d\varsigma } 
+\end{equation}
+ Two strategies can be considered for the surface pressure term: $(a)$ introduce of a 
+ new variable $\eta$, the free-surface elevation, for which a prognostic equation can be 
+ established and solved; $(b)$ assume that the ocean surface is a rigid lid, on which the 
+ pressure (or its horizontal gradient) can be diagnosed. When the former strategy is used, 
+ one solution of the free-surface elevation consists of the excitation of external gravity waves. 
+ The flow is barotropic and the surface moves up and down with gravity as the restoring force. 
+ The phase speed of such waves is high (some hundreds of metres per second) so that 
+ the time step would have to be very short if they were present in the model. The latter 
+ strategy filters out these waves since the rigid lid approximation implies $\eta=0$, $i.e.$ 
+ the sea surface is the surface $z=0$. This well known approximation increases the surface 
+ wave speed to infinity and modifies certain other longwave dynamics ($e.g.$ barotropic 
+ Rossby or planetary waves). In the present release of \NEMO, both strategies are still available. 
+ They are further described in the next two sub-sections.
+
+% -------------------------------------------------------------------------------------------------------------
+% Free Surface Formulation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Free Surface Formulation}
+\label{PE_free_surface}
+
+In the free surface formulation, a variable $\eta$, the sea-surface height, is introduced 
+which describes the shape of the air-sea interface. This variable is solution of a 
+prognostic equation which is established by forming the vertical average of the kinematic 
+surface condition (\ref{Eq_PE_w_bbc}):
+\begin{equation} \label{Eq_PE_ssh}
+\frac{\partial \eta }{\partial t}=-D+P-E
+ 	\quad \text{where} \ 
+D=\nabla \cdot \left[ {\left( {H+\eta } \right) \; {\rm{\bf \overline{U}}}_h \,} \right]
+\end{equation}
+and using (\ref{Eq_PE_hydrostatic}) the surface pressure is given by: $p_s = \rho \, g \, \eta$.
+
+Allowing the air-sea interface to move introduces the external gravity waves (EGWs) 
+as a class of solution of the primitive equations. These waves are barotropic because 
+of hydrostatic assumption, and their phase speed is quite high. Their time scale is 
+short with respect to the other processes described by the primitive equations.
+
+Three choices can be made regarding the implementation of the free surface in the model, 
+depending on the physical processes of interest. 
+
+$\bullet$ If one is interested in EGWs, in particular the tides and their interaction 
+with the baroclinic structure of the ocean (internal waves) possibly in shallow seas, 
+then a non linear free surface is the most appropriate. This means that no 
+approximation is made in (\ref{Eq_PE_ssh}) and that the variation of the ocean 
+volume is fully taken into account. Note that in order to study the fast time scales 
+associated with EGWs it is necessary to minimize time filtering effects (use an 
+explicit time scheme with very small time step, or a split-explicit scheme with 
+reasonably small time step, see \S\ref{DYN_spg_exp} or \S\ref{DYN_spg_ts}.
+
+$\bullet$ If one is not interested in EGW but rather sees them as high frequency 
+noise, it is possible to apply an explicit filter to slow down the fastest waves while 
+not altering the slow barotropic Rossby waves. If further, an approximative conservation 
+of heat and salt contents is sufficient for the problem solved, then it is 
+sufficient to solve a linearized version of (\ref{Eq_PE_ssh}), which still allows 
+to take into account freshwater fluxes applied at the ocean surface \citep{Roullet2000}.
+
+$\bullet$ For process studies not involving external waves nor surface freshwater 
+fluxes, it is possible to use the rigid lid approximation see (next 
+section). The ocean surface is then considered as a fixed surface, so that all 
+external waves are removed from the system. 
+
+The filtering of EGWs in models with a free surface is usually a matter of discretisation 
+of the temporal derivatives, using the time splitting method \citep{Killworth1991, Zhang1992} 
+or the implicit scheme \citep{Dukowicz1994}. In \NEMO, we use a slightly different approach 
+developed by \citet{Roullet2000}: the damping of EGWs is ensured by introducing an 
+additional force in the momentum equation. \eqref{Eq_PE_dyn} becomes: 
+\begin{equation} \label{Eq_PE_flt}
+\frac{\partial {\rm {\bf U}}_h }{\partial t}= {\rm {\bf M}}
+- g \nabla \left( \tilde{\rho} \ \eta \right) 
+- g \ T_c \nabla \left( \widetilde{\rho} \ \partial_t \eta \right) 
+\end{equation}
+where $T_c$, is a parameter with dimensions of time which characterizes the force, 
+$\widetilde{\rho} = \rho / \rho_o$ is the dimensionless density, and $\rm {\bf M}$ 
+represents the collected contributions of the Coriolis, hydrostatic pressure gradient, 
+non-linear and viscous terms in \eqref{Eq_PE_dyn}.
+
+The new force can be interpreted as a diffusion of vertically integrated volume flux divergence. 
+The time evolution of $D$ is thus governed by a balance of two terms, $-g$ \textbf{A} $\eta$ 
+and $g \, T_c \,$ \textbf{A} $D$, associated with a propagative regime and a diffusive regime 
+in the temporal spectrum, respectively. In the diffusive regime, the EGWs no longer propagate, 
+$i.e.$ they are stationary and damped. The diffusion regime applies to the modes shorter than 
+$T_c$. For longer ones, the diffusion term vanishes. Hence, the temporally unresolved EGWs 
+can be damped by choosing $T_c > \Delta t$. \citet{Roullet2000} demonstrate that 
+(\ref{Eq_PE_flt}) can be integrated with a leap frog scheme except the additional term which 
+has to be computed implicitly. This is not surprising since the use of a large time step has a 
+necessarily numerical cost. Two gains arise in comparison with the previous formulations. 
+Firstly, the damping of EGWs can be quantified through the magnitude of the additional term. 
+Secondly, the numerical scheme does not need any tuning. Numerical stability is ensured as 
+soon as $T_c > \Delta t$.
+
+When the variations of free surface elevation are small compared to the thickness of the first 
+model layer, the free surface equation (\ref{Eq_PE_ssh}) can be linearized. As emphasized 
+by \citet{Roullet2000} the linearization of (\ref{Eq_PE_ssh}) has consequences on the 
+conservation of salt in the model. With the nonlinear free surface equation, the time evolution 
+of the total salt content is 
+\begin{equation} \label{Eq_PE_salt_content}
+    \frac{\partial }{\partial t}\int\limits_{D\eta } {S\;dv} 
+                        =\int\limits_S {S\;(-\frac{\partial \eta }{\partial t}-D+P-E)\;ds}
+\end{equation}
+where $S$ is the salinity, and the total salt is integrated over the whole ocean volume 
+$D_\eta$ bounded by the time-dependent free surface. The right hand side (which is an 
+integral over the free surface) vanishes when the nonlinear equation (\ref{Eq_PE_ssh}) 
+is satisfied, so that the salt is perfectly conserved. When the free surface equation is 
+linearized, \citet{Roullet2000} show that the total salt content integrated in the fixed 
+volume $D$ (bounded by the surface $z=0$) is no longer conserved:
+\begin{equation} \label{Eq_PE_salt_content_linear}
+         \frac{\partial }{\partial t}\int\limits_D {S\;dv} 
+         		= - \int\limits_S {S\;\frac{\partial \eta }{\partial t}ds} 
+\end{equation}
+
+The right hand side of (\ref{Eq_PE_salt_content_linear}) is small in equilibrium solutions 
+\citep{Roullet2000}. It can be significant when the freshwater forcing is not balanced and 
+the globally averaged free surface is drifting. An increase in sea surface height \textit{$\eta $} 
+results in a decrease of the salinity in the fixed volume $D$. Even in that case though, 
+the total salt integrated in the variable volume $D_{\eta}$ varies much less, since 
+(\ref{Eq_PE_salt_content_linear}) can be rewritten as 
+\begin{equation} \label{Eq_PE_salt_content_corrected}
+\frac{\partial }{\partial t}\int\limits_{D\eta } {S\;dv} 
+=\frac{\partial}{\partial t} \left[ \;{\int\limits_D {S\;dv} +\int\limits_S {S\eta \;ds} } \right]
+=\int\limits_S {\eta \;\frac{\partial S}{\partial t}ds}
+\end{equation}
+
+Although the total salt content is not exactly conserved with the linearized free surface, 
+its variations are driven by correlations of the time variation of surface salinity with the 
+sea surface height, which is a negligible term. This situation contrasts with the case of 
+the rigid lid approximation (following section) in which case freshwater forcing is 
+represented by a virtual salt flux, leading to a spurious source of salt at the ocean 
+surface \citep{Roullet2000}.
+
+% -------------------------------------------------------------------------------------------------------------
+% Rigid-Lid Formulation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Rigid-Lid formulation}
+\label{PE_rigid_lid}
+
+With the rigid lid approximation, we assume that the ocean surface ($z=0$) is a rigid lid 
+on which a pressure $p_s$ is exerted. This implies that the vertical velocity at the surface 
+is equal to zero. From the continuity equation \eqref{Eq_PE_continuity} and the kinematic 
+condition at the bottom \eqref{Eq_PE_w_bbc} (no flux across the bottom), it can be shown 
+that the vertically integrated flow $H{\rm {\bf \bar {U}}}_h$ is non-divergent (where the 
+overbar indicates a vertical average over the whole water column, i.e. from $z=-H$, 
+the ocean bottom, to $z=0$ , the rigid-lid). Thus, $\rm {\bf \bar {U}}_h$ can be derived 
+from a volume transport streamfunction $\psi$:
+\begin{equation} \label{Eq_PE_u_psi}
+\overline{\vect{U}}_h =\frac{1}{H}\left(   \vect{k} \times \nabla \psi   \right)
+\end{equation}
+
+As $p_s$ does not depend on depth, its horizontal gradient is obtained by forming the 
+vertical average of \eqref{Eq_PE_dyn} and using \eqref{Eq_PE_u_psi}:
+
+\begin{equation} \label{Eq_PE_u_barotrope}
+\frac{1}{\rho _o }\nabla _h p_s 
+=\overline{\vect{M}} -\frac{\partial \overline{\vect{U}} _h }{\partial t}
+=\overline{\vect{M}} 
+-\frac{1}{H} \left[   \vect{k} \times \nabla \left( \frac{\partial \psi}{\partial t} \right)   \right]
+\end{equation}
+
+Here ${\rm {\bf M}} = \left( M_u,M_v \right)$ represents the collected contributions of the 
+Coriolis, hydrostatic pressure gradient, nonlinear and viscous terms in \eqref{Eq_PE_dyn}. 
+The time derivative of $\psi $ is the solution of an elliptic equation which is obtained from 
+the vertical component of the curl of (\ref{Eq_PE_u_barotrope}):
+\begin{equation} \label{Eq_PE_psi}
+\left[   {\nabla \times \left[ {\frac{1}{H} \vect{\bf k} 
+  \times \nabla \left(   {\frac{\partial \psi }{\partial t}} \right)}   \right]} \; \right]_z 
+=\left[   {\nabla \times \overline{\vect{M}} }   \right]_z 
+\end{equation}
+
+Using the proper boundary conditions, \eqref{Eq_PE_psi} can be solved to find $\partial_t \psi$ 
+and thus using \eqref{Eq_PE_u_barotrope} the horizontal surface pressure gradient. 
+It should be noted that $p_s$ can be computed by taking the divergence of 
+\eqref{Eq_PE_u_barotrope} and solving the resulting elliptic equation. Thus the surface 
+pressure is a diagnostic quantity that can be recovered for analysis purposes.
+
+A difficulty lies in the determination of the boundary condition on $\partial_t \psi$. 
+The boundary condition on velocity is that there is no flow normal to a solid wall, 
+$i.e.$ the coastlines are streamlines. Therefore \eqref{Eq_PE_psi} is solved with 
+the following Dirichlet boundary condition: $\partial_t \psi$ is constant along each 
+coastline of the same continent or of the same island. When all the coastlines are 
+connected (there are no islands), the constant value of $\partial_t \psi$ along the 
+coast can be arbitrarily chosen to be zero. When islands are present in the domain, 
+the value of the barotropic streamfunction will generally be different for each island 
+and for the continent, and will vary with respect to time. So the boundary condition is: 
+$\psi=0$ along the continent and $\psi=\mu_n$ along island $n$ ($1 \leq n \leq Q$), 
+where $Q$ is the number of islands present in the domain and $\mu_n$ is a time 
+dependent variable. A time evolution equation of the unknown $\mu_n$ can be found 
+by evaluating the circulation of the time derivative of the vertical average (barotropic) 
+velocity field along a closed contour around each island. Since the circulation of a 
+gradient field along a closed contour is zero, from \eqref{Eq_PE_u_barotrope} we have:
+\begin{equation} \label{Eq_PE_isl_circulation}
+\oint_n {\frac{1}{H}\left[ {{\rm {\bf k}}\times \nabla \left( 
+{\frac{\partial \psi }{\partial t}} \right)} \right] \cdot {\rm {\bf d}}\ell } 
+= \oint_n {\overline {\rm {\bf M}} \cdot {\rm {\bf d}}\ell } 
+\qquad  1 \leq n \leq Q
+\end{equation}
+
+Since (\ref{Eq_PE_psi}) is linear, its solution \textit{$\psi $} can be decomposed 
+as follows:
+\begin{equation} \label{Eq_PE_psi_isl}
+\psi =\psi _o +\sum\limits_{n=1}^{n=Q} {\mu _n \psi _n } 
+\end{equation}
+where $\psi _o$ is the solution of \eqref{Eq_PE_psi} with $\psi _o=0$ long all 
+the coastlines, and where $\psi _n$ is the solution of \eqref{Eq_PE_psi} with 
+the right-hand side equal to $0$, and with $\psi _n =1$ long the island $n$, 
+$\psi _n =0$ along the other boundaries. The function $\psi _n$ is thus 
+independent of time. Introducing \eqref{Eq_PE_psi_isl} into 
+\eqref{Eq_PE_isl_circulation} yields:
+\begin{multline} \label{Eq_PE_psi_isl_circulation}
+\left[ {\oint_n {\frac{1}{H}  \left[ {{\rm {\bf k}}\times \nabla \psi _m } \right]\cdot {\rm {\bf d}}\ell } } \right]_{1\leq m\leqslant Q \atop 1\leq n\leqslant Q  }
+ \left( {\frac{\partial \mu _n }{\partial t}} 
+\right)_{1\leqslant n\leqslant Q}        \\
+ =\left( {\oint_n {\left[ {\overline {\rm 
+{\bf M}} -\frac{1}{H}\left[ {{\rm {\bf k}}\times \nabla \left( 
+{\frac{\partial \psi _o }{\partial t}} \right)} \right]} \right]\cdot {\rm 
+{\bf d}}\ell } } \right)_{1\leqslant n\leqslant Q} 
+\end{multline}
+which can be rewritten as:
+\begin{equation} \label{Eq_PE_psi_isl_matrix}
+{\rm {\bf A}}\;\left( {\frac{\partial \mu _n }{\partial t}} 
+\right)_{1\leqslant n\leqslant Q} ={\rm {\bf B}}
+\end{equation}
+where \textbf{A} is a $Q  \times Q$ matrix and \textbf{B} is a time dependent vector. 
+As \textbf{A} is independent of time, it can be calculated and inverted once. The time 
+derivative of the streamfunction when islands are present is thus given by:
+\begin{equation} \label{Eq_PE_psi_isl_dt}
+\frac{\partial \psi }{\partial t}=\frac{\partial \psi _o }{\partial 
+t}+\sum\limits_{n=1}^{n=Q} {{\rm {\bf A}}^{-1}{\rm {\bf B}}\;\psi _n } 
+\end{equation}
+
+
+
+% ================================================================
+% Curvilinear z-coordinate System
+% ================================================================
+\section{Curvilinear \textit{z-}coordinate System}
+\label{PE_zco}
+
+
+% -------------------------------------------------------------------------------------------------------------
+% Tensorial Formalism
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Tensorial Formalism}
+\label{PE_tensorial}
+
+In many ocean circulation problems, the flow field has regions of enhanced dynamics 
+($i.e.$ surface layers, western boundary currents, equatorial currents, or ocean fronts). 
+The representation of such dynamical processes can be improved by specifically increasing 
+the model resolution in these regions. As well, it may be convenient to use a lateral 
+boundary-following coordinate system to better represent coastal dynamics. Moreover, 
+the common geographical coordinate system has a singular point at the North Pole that 
+cannot be easily treated in a global model without filtering. A solution consists of introducing 
+an appropriate coordinate transformation that shifts the singular point onto land 
+\citep{MadecImb1996, Murray1996}. As a consequence, it is important to solve the primitive 
+equations in various curvilinear coordinate systems. An efficient way of introducing an 
+appropriate coordinate transform can be found when using a tensorial formalism. 
+This formalism is suited to any multidimensional curvilinear coordinate system. Ocean 
+modellers mainly use three-dimensional orthogonal grids on the sphere (spherical earth 
+approximation), with preservation of the local vertical. Here we give the simplified equations 
+for this particular case. The general case is detailed by \citet{Eiseman1980} in their survey 
+of the conservation laws of fluid dynamics.
+
+Let (\textbf{i},\textbf{j},\textbf{k}) be a set of orthogonal curvilinear coordinates on the sphere 
+associated with the positively oriented orthogonal set of unit vectors (\textbf{i},\textbf{j},\textbf{k}) 
+linked to the earth such that \textbf{k} is the local upward vector and (\textbf{i},\textbf{j}) are 
+two vectors orthogonal to \textbf{k}, $i.e.$ along geopotential surfaces (Fig.\ref{Fig_referential}). 
+Let $(\lambda,\varphi,z)$ be the geographical coordinate system in which a position is defined 
+by the latitude $\varphi(i,j)$, the longitude $\lambda(i,j)$ and the distance from the centre of 
+the earth $a+z(k)$ where $a$ is the earth's radius and $z$ the altitude above a reference sea 
+level (Fig.\ref{Fig_referential}). The local deformation of the curvilinear coordinate system is 
+given by $e_1$, $e_2$ and $e_3$, the three scale factors:
+\begin{equation} \label{Eq_scale_factors}
+\begin{aligned}
+ e_1 &=\left( {a+z} \right)\;\left[ {\left( {\frac{\partial \lambda 
+}{\partial i}\cos \varphi } \right)^2+\left( {\frac{\partial \varphi 
+}{\partial i}} \right)^2} \right]^{1/2} \\ 
+ e_2 &=\left( {a+z} \right)\;\left[ {\left( {\frac{\partial \lambda 
+}{\partial j}\cos \varphi } \right)^2+\left( {\frac{\partial \varphi 
+}{\partial j}} \right)^2} \right]^{1/2} \\ 
+ e_3 &=\left( {\frac{\partial z}{\partial k}} \right) \\ 
+ \end{aligned}
+ \end{equation}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!tb] \label{Fig_referential}  \begin{center}
+\includegraphics[width=0.60\textwidth]{./TexFiles/Figures/Fig_I_earth_referential.pdf}
+\caption{the geographical coordinate system $(\lambda,\varphi,z)$ and the curvilinear 
+coordinate system (\textbf{i},\textbf{j},\textbf{k}). }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+Since the ocean depth is far smaller than the earth's radius, $a+z$, can be replaced by 
+$a$ in (\ref{Eq_scale_factors}) (thin-shell approximation). The resulting horizontal scale 
+factors $e_1$, $e_2$  are independent of $k$ while the vertical scale factor is a single 
+function of $k$ as \textbf{k} is parallel to \textbf{z}. The scalar and vector operators that 
+appear in the primitive equations (Eqs. \eqref{Eq_PE_dyn} to \eqref{Eq_PE_eos}) can 
+be written in the tensorial form, invariant in any orthogonal horizontal curvilinear coordinate 
+system transformation:
+\begin{subequations} \label{Eq_PE_discrete_operators}
+\begin{equation} \label{Eq_PE_grad}
+\nabla q=\frac{1}{e_1 }\frac{\partial q}{\partial i}\;{\rm {\bf 
+i}}+\frac{1}{e_2 }\frac{\partial q}{\partial j}\;{\rm {\bf j}}+\frac{1}{e_3 
+}\frac{\partial q}{\partial k}\;{\rm {\bf k}}    \\
+\end{equation}
+\begin{equation} \label{Eq_PE_div}
+\nabla \cdot {\rm {\bf A}} 
+= \frac{1}{e_1 \; e_2} \left[ 
+  \frac{\partial \left(e_2 \; a_1\right)}{\partial i }
++\frac{\partial \left(e_1 \; a_2\right)}{\partial j }    	\right]
++ \frac{1}{e_3} \left[ \frac{\partial a_3}{\partial k }   \right]
+\end{equation}
+\begin{equation} \label{Eq_PE_curl}
+   \begin{split}
+\nabla \times \vect{A} = 
+    \left[ {\frac{1}{e_2 }\frac{\partial a_3}{\partial j}
+            -\frac{1}{e_3 }\frac{\partial a_2 }{\partial k}} \right] \; \vect{i}
+&+\left[ {\frac{1}{e_3 }\frac{\partial a_1 }{\partial k}
+           -\frac{1}{e_1 }\frac{\partial a_3 }{\partial i}} \right] \; \vect{j} 		\\
+&+\frac{1}{e_1 e_2 } \left[ {\frac{\partial \left( {e_2 a_2 } \right)}{\partial i}
+                                       -\frac{\partial \left( {e_1 a_1 } \right)}{\partial j}} \right] \; \vect{k} 
+   \end{split}
+\end{equation}
+\begin{equation} \label{Eq_PE_lap}
+\Delta q = \nabla \cdot \left(  \nabla q \right)
+\end{equation}
+\begin{equation} \label{Eq_PE_lap_vector}
+\Delta {\rm {\bf A}} =
+  \nabla \left( \nabla \cdot {\rm {\bf A}} \right)
+- \nabla \times \left(  \nabla \times {\rm {\bf A}} \right)
+\end{equation}
+\end{subequations}
+where $q$ is a scalar quantity and ${\rm {\bf A}}=(a_1,a_2,a_3)$ a vector in the $(i,j,k)$ coordinate system.
+
+% -------------------------------------------------------------------------------------------------------------
+% Continuous Model Equations
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Continuous Model Equations}
+\label{PE_zco_Eq}
+
+In order to express the Primitive Equations in tensorial formalism, it is necessary to compute 
+the horizontal component of the non-linear and viscous terms of the equation using 
+\eqref{Eq_PE_grad}) to \eqref{Eq_PE_lap_vector}. 
+Let us set $\vect U=(u,v,w)={\vect{U}}_h +w\;\vect{k}$, the velocity in the $(i,j,k)$ coordinate 
+system and define the relative vorticity $\zeta$ and the divergence of the horizontal velocity 
+field $\chi$, by:
+\begin{equation} \label{Eq_PE_curl_Uh}
+\zeta =\frac{1}{e_1 e_2 }\left[ {\frac{\partial \left( {e_2 \,v} 
+\right)}{\partial i}-\frac{\partial \left( {e_1 \,u} \right)}{\partial j}} 
+\right]
+\end{equation}
+\begin{equation} \label{Eq_PE_div_Uh}
+\chi =\frac{1}{e_1 e_2 }\left[ {\frac{\partial \left( {e_2 \,u} 
+\right)}{\partial i}+\frac{\partial \left( {e_1 \,v} \right)}{\partial j}} 
+\right]
+\end{equation}
+
+Using the fact that the horizontal scale factors $e_1$ and $e_2$ are independent of $k$ 
+and that $e_3$  is a function of the single variable $k$, the nonlinear term of 
+\eqref{Eq_PE_dyn} can be transformed as follows:
+\begin{flalign*}
+&\left[ {\left( {	\nabla \times {\rm {\bf U}}    } \right) \times {\rm {\bf U}}
++\frac{1}{2}	\nabla \left( {{\rm {\bf U}}^2} \right)}	 \right]_h 			&
+\end{flalign*}
+\begin{flalign*}
+&\qquad=\left( {{\begin{array}{*{20}c}
+ {\left[ 	{	 \frac{1}{e_3}	\frac{\partial u	}{\partial k}
+			-\frac{1}{e_1}	\frac{\partial w	}{\partial i} } \right] w - \zeta \; v } 	 	\\
+ 		{\zeta \; u - \left[ {	 \frac{1}{e_2} \frac{\partial w}{\partial j}
+							-\frac{1}{e_3} \frac{\partial v}{\partial k} } \right] \ w}	 \\
+		 \end{array} }} \right)			
++\frac{1}{2}	\left( {{\begin{array}{*{20}c}
+		 {	\frac{1}{e_1}	\frac{\partial \left( u^2+v^2+w^2 \right)}{\partial i}} 	\hfill	 \\
+		 {	\frac{1}{e_2}	\frac{\partial \left( u^2+v^2+w^2 \right)}{\partial j}} 	\hfill	 \\
+		 \end{array} }} \right)			&
+\end{flalign*}
+\begin{flalign*}
+& \qquad =\left( {{	\begin{array}{*{20}c}
+ {-\zeta \; v} \hfill \\
+ { \zeta \; u} \hfill \\
+			\end{array} }} \right)
++\frac{1}{2}\left( {{	\begin{array}{*{20}c}
+ {\frac{1}{e_1 }\frac{\partial \left( {u^2+v^2} \right)}{\partial i}} \hfill 	\\
+ {\frac{1}{e_2 }\frac{\partial \left( {u^2+v^2} \right)}{\partial j}} \hfill 	\\
+						\end{array} }} \right)			
++\frac{1}{e_3 }\left( {{		\begin{array}{*{20}c}
+ { w \; \frac{\partial u}{\partial k}} 	\\
+ { w \; \frac{\partial v}{\partial k}} 	\\
+							\end{array} }} \right)	
+-\left( {{	\begin{array}{*{20}c}
+ {\frac{w}{e_1}\frac{\partial w}{\partial i}
+ -\frac{1}{2e_1}\frac{\partial w^2}{\partial i}} \hfill \\
+ {\frac{w}{e_2}\frac{\partial w}{\partial j}
+  -\frac{1}{2e_2}\frac{\partial w^2}{\partial j}} \hfill \\
+			\end{array} }} \right) 			&
+\end{flalign*}
+
+The last term of the right hand side is obviously zero, and thus the nonlinear term of 
+\eqref{Eq_PE_dyn} is written in the $(i,j,k)$ coordinate system:
+\begin{equation} \label{Eq_PE_vector_form}
+\left[ {\left( {	\nabla \times {\rm {\bf U}}    } \right) \times {\rm {\bf U}}
++\frac{1}{2}	\nabla \left( {{\rm {\bf U}}^2} \right)}	 \right]_h 
+=\zeta 
+\;{\rm {\bf k}}\times {\rm {\bf U}}_h +\frac{1}{2}\nabla _h \left( {{\rm 
+{\bf U}}_h^2 } \right)+\frac{1}{e_3 }w\frac{\partial {\rm {\bf U}}_h 
+}{\partial k}   	
+\end{equation}
+
+This is the so-called \textit{vector invariant form} of the momentum advection term. 
+For some purposes, it can be advantageous to write this term in the so-called flux form, 
+$i.e.$ to write it as the divergence of fluxes. For example, the first component of 
+\eqref{Eq_PE_vector_form} (the $i$-component) is transformed as follows:
+\begin{flalign*}
+&{	\begin{array}{*{20}l}
+\left[ {\left( {\nabla \times \vect{U}} \right)\times \vect{U}
+          +\frac{1}{2}\nabla \left( {\vect{U}}^2 \right)} \right]_i   % \\
+%\\
+     = - \zeta \;v 
+     + \frac{1}{2\;e_1 } \frac{\partial \left( {u^2+v^2} \right)}{\partial i}
+     + \frac{1}{e_3}w \ \frac{\partial u}{\partial k} 			\\
+\\
+\qquad =\frac{1}{e_1 \; e_2} \left( 	-v\frac{\partial \left( {e_2 \,v} \right)}{\partial i}
+							+v\frac{\partial \left( {e_1 \,u} \right)}{\partial j}	 \right)
++\frac{1}{e_1 e_2 }\left( 	+e_2 \; u\frac{\partial u}{\partial i}
+ 							+e_2 \; v\frac{\partial v}{\partial i}	  				 \right) 
++\frac{1}{e_3}       \left( 	w\;\frac{\partial u}{\partial k} 		\right)   \\
+\end{array} } 			&
+\end{flalign*}
+\begin{flalign*}
+&{	\begin{array}{*{20}l}
+\qquad =\frac{1}{e_1 \; e_2} 	\left\{ 
+ -\left(   	    v^2 	\frac{\partial e_2                                }{\partial i} 
+ 		+e_2 \,v		\frac{\partial v                                   }{\partial i}  	\right)
++\left( 				\frac{\partial \left( {e_1 \,u\,v} 	\right)}{\partial j}
+		-e_1 \,u		\frac{\partial v                                   }{\partial j} 	\right) 	\right. 
+\\  \left.	\qquad \qquad \quad
++\left( 				\frac{\partial \left( {e_2 u\,u}     \right)}{\partial i}
+		-u			\frac{\partial \left( {e_2 u}         \right)}{\partial i} 	\right)
++e_2 v		 		\frac{\partial v                                    }{\partial i}
+ 						\right\} 
++\frac{1}{e_3} \left(
+ 					\frac{\partial \left( {w\,u} \right)         }{\partial k}
+		 -u			\frac{\partial w 						   }{\partial k} 	\right) \\
+\end{array} } 		&
+\end{flalign*}
+\begin{flalign*}
+&{	\begin{array}{*{20}l}
+\qquad =\frac{1}{e_1 \; e_2} 	\left( 
+					\frac{\partial \left( {e_2 \,u\,u} \right)}{\partial i}
+		+			\frac{\partial \left( {e_1 \,u\,v} \right)}{\partial j}	\right)
++\frac{1}{e_3 }		\frac{\partial \left( {w\,u		 } \right)}{\partial k}
+\\  \qquad \qquad \quad
++\frac{1}{e_1 e_2 }		\left( 
+ 		-u	\left( 	\frac{\partial \left( {e_1 v	 } \right)}{\partial j}
+	 				-v\,\frac{\partial e_1 }{\partial j}				 \right)
+		-u			\frac{\partial \left( {e_2 u	 } \right)}{\partial i}
+						\right)
+ -\frac{1}{e_3 }	 	\frac{\partial w}{\partial k}	u
+ +\frac{1}{e_1 e_2 }\left( 	-v^2\frac{\partial e_2	 }{\partial i}		 \right)	
+\end{array} } 		&
+\end{flalign*}
+\begin{flalign*}
+&{	\begin{array}{*{20}l}
+\qquad = \nabla \cdot \left( {{\rm {\bf U}}\,u}	\right)
+-   \left( \nabla \cdot {\rm {\bf U}} \right) \ u
++\frac{1}{e_1 e_2 }\left( 
+		-v^2		\frac{\partial e_2 }{\partial i}
+		+uv	\,		\frac{\partial e_1 }{\partial j} 	\right) \\
+\end{array} } 		&
+\end{flalign*}
+as $\nabla \cdot {\rm {\bf U}}\;=0$ (incompressibility) it comes:
+\begin{flalign*}
+&{	\begin{array}{*{20}l}
+\qquad = \nabla \cdot \left( 	{{\rm {\bf U}}\,u}		\right)
++	\frac{1}{e_1 e_2 }   \left( v \; \frac{\partial e_2}{\partial i}
+						       -u \; \frac{\partial e_1}{\partial j} 	\right)  \left( -v \right)	
+\end{array} } 		&
+\end{flalign*}
+
+The flux form of the momentum advection term is therefore given by:
+\begin{multline} \label{Eq_PE_flux_form}
+		\left[ 
+  \left( 	{\nabla \times {\rm {\bf U}}} 	\right) \times {\rm {\bf U}}
++\frac{1}{2}	\nabla \left( 	{{\rm {\bf U}}^2} 	\right)
+		\right]_h 
+\\
+= \nabla \cdot 	\left( {{\begin{array}{*{20}c}	{\rm {\bf U}} \, u 	\hfill \\
+												{\rm {\bf U}} \, v	\hfill \\
+						\end{array} }} 	
+				\right)
++\frac{1}{e_1 e_2 }		\left( 
+		 v\frac{\partial e_2}{\partial i}
+		-u\frac{\partial e_1}{\partial j} 
+						\right) {\rm {\bf k}} \times {\rm {\bf U}}_h
+\end{multline}
+
+The flux form has two terms, the first one is expressed as the divergence of momentum 
+fluxes (hence the flux form name given to this formulation) and the second one is due to 
+the curvilinear nature of the coordinate system used. The latter is called the \emph{metric} 
+term and can be viewed as a modification of the Coriolis parameter: 
+\begin{equation} \label{Eq_PE_cor+metric}
+f \to f + \frac{1}{e_1 \; e_2}	\left( 	 v \frac{\partial e_2}{\partial i}
+										-u \frac{\partial e_1}{\partial j} 	\right)
+\end{equation}
+
+Note that in the case of geographical coordinate, $i.e.$ when $(i,j) \to (\lambda ,\varphi )$ 
+and $(e_1 ,e_2) \to (a \,\cos \varphi ,a)$, we recover the commonly used modification of 
+the Coriolis parameter $f \to f+(u/a) \tan \varphi$.
+
+To sum up, the equations solved by the ocean model can be written in the following tensorial formalism:
+
+\vspace{+10pt}
+$\bullet$ \textit{momentum equations} :
+
+vector invariant form :
+\begin{subequations} \label{Eq_PE_dyn_vect}
+\begin{multline} \label{Eq_PE_dyn_vect_u}
+\frac{\partial u}{\partial t}=
+	+   \left( {\zeta +f} \right)\,v                                    
+	-   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right) 
+	-   \frac{1}{e_3} w \frac{\partial u}{\partial k}       \\
+	-   \frac{1}{e_1} \frac{\partial}{\partial i} \left( \frac{p_s+p_h }{\rho _o}    \right)    
++   D_u^{\vect{U}}  +   F_u^{\vect{U}}
+\end{multline}
+\begin{multline} \label{Eq_PE_dyn_vect_v}
+\frac{\partial v}{\partial t}=
+	-   \left( {\zeta +f} \right)\,u   
+	-   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)     	-   \frac{1}{e_3 }w\frac{\partial v}{\partial k}         \\
+	-   \frac{1}{e_2 }\frac{\partial }{\partial j}\left( \frac{p_s+p_h }{\rho _o}  \right)    
++  D_v^{\vect{U}}  +   F_v^{\vect{U}}
+\end{multline}
+\end{subequations}
+
+flux form:
+\begin{subequations} \label{Eq_PE_dyn_flux}
+\begin{multline} \label{Eq_PE_dyn_flux_u}
+\frac{\partial u}{\partial t}=
++   \left( { f + \frac{1}{e_1 \; e_2}
+					\left( 	 v \frac{\partial e_2}{\partial i}
+						-u \frac{\partial e_1}{\partial j} 	\right)} 	\right) \, v    \\
+- \frac{1}{e_1 \; e_2} 	\left( 
+					\frac{\partial \left( {e_2 \,u\,u} \right)}{\partial i}
+		+			\frac{\partial \left( {e_1 \,v\,u} \right)}{\partial j}	\right)
+                 - \frac{1}{e_3 }\frac{\partial \left( {         w\,u} \right)}{\partial k}    \\
+-   \frac{1}{e_1 }\frac{\partial}{\partial i}\left( \frac{p_s+p_h }{\rho _o}   \right)
++   D_u^{\vect{U}} +   F_u^{\vect{U}}
+\end{multline}
+\begin{multline} \label{Eq_PE_dyn_flux_v}
+\frac{\partial v}{\partial t}=
+-   \left( { f + \frac{1}{e_1 \; e_2}
+					\left( 	 v \frac{\partial e_2}{\partial i}
+						-u \frac{\partial e_1}{\partial j} 	\right)} 	\right) \, u   \\
+ \frac{1}{e_1 \; e_2} 	\left( 
+					\frac{\partial \left( {e_2 \,u\,v} \right)}{\partial i}
+		+			\frac{\partial \left( {e_1 \,v\,v} \right)}{\partial j}	\right)
+                 - \frac{1}{e_3 } \frac{\partial \left( {        w\,v} \right)}{\partial k}    \\
+-   \frac{1}{e_2 }\frac{\partial }{\partial j}\left( \frac{p_s+p_h }{\rho _o}    \right)
++  D_v^{\vect{U}} +  F_v^{\vect{U}} 
+\end{multline}
+\end{subequations}
+where $\zeta$ is given by \eqref{Eq_PE_curl_Uh} and the surface pressure gradient formulation 
+depends on the one of the free surface:
+
+$*$ free surface formulation
+\begin{equation}\label{Eq_PE_dyn_sco}
+\frac{1}{\rho _o }\nabla _h p_s =\left( {{\begin{array}{*{20}c}
+ {\frac{g}{\;e_1 }\frac{\partial \eta }{\partial i}} \hfill \\
+ {\frac{g}{\;e_2 }\frac{\partial \eta }{\partial j}} \hfill \\
+\end{array} }} \right)
+\qquad \text{where $\eta$ is solution of \eqref{Eq_PE_ssh} }
+\end{equation}
+
+$*$ rigid-lid approximation
+\begin{equation}\label{Eq_PE_dyn_zco}
+\frac{1}{\rho _o }\nabla _h p_s =\left( {{\begin{array}{*{20}c}
+ {\overline M _u +\frac{1}{H\;e_2 }\frac{\partial }{\partial j}\left( 
+{\frac{\partial \psi }{\partial t}} \right)}		 \\
+ {\overline M _v -\frac{1}{H\;e_1 }\frac{\partial }{\partial i}\left( 
+{\frac{\partial \psi }{\partial t}} \right)} 		 \\
+\end{array} }} \right)
+\end{equation}
+where ${\vect{M}}= \left( M_u,M_v \right)$ represents the collected contributions of nonlinear, 
+viscosity and hydrostatic pressure gradient terms in \eqref{Eq_PE_dyn_vect} and the overbar 
+indicates a vertical average over the whole water column ($i.e.$ from $z=-H$, the ocean bottom, 
+to $z=0$, the rigid-lid), and where the time derivative of $\psi$ is the solution of an elliptic equation:
+\begin{multline} \label{Eq_psi_total}
+  \frac{\partial }{\partial i}\left[ {\frac{e_2 }{H\,e_1}\frac{\partial}{\partial i}
+								 \left( {\frac{\partial \psi }{\partial t}} \right)}   \right]
++\frac{\partial }{\partial j}\left[ {\frac{e_1 }{H\,e_2}\frac{\partial }{\partial j}
+								 \left( {\frac{\partial \psi }{\partial t}} \right)} \right]
+= \\
+  \frac{\partial }{\partial i}\left( {e_2 \overline M _v } \right)
+- \frac{\partial }{\partial j}\left( {e_1 \overline M _u } \right)
+\end{multline}
+
+The vertical velocity and the hydrostatic pressure are diagnosed from the following equations:
+\begin{equation} \label{Eq_w_diag}
+\frac{\partial w}{\partial k}=-\chi \;e_3 
+\end{equation}
+\begin{equation} \label{Eq_hp_diag}
+\frac{\partial p_h }{\partial k}=-\rho \;g\;e_3 
+\end{equation}
+
+where the divergence of the horizontal velocity, $\chi$ is given by \eqref{Eq_PE_div_Uh}.
+
+\vspace{+10pt}
+$\bullet$ \textit{tracer equations} :
+\begin{equation} \label{Eq_S}
+\frac{\partial T}{\partial t} = 
+-\frac{1}{e_1 e_2 }\left[ {	   \frac{\partial \left( {e_2 T\,u} \right)}{\partial i}
+						+\frac{\partial \left( {e_1 T\,v} \right)}{\partial j}} \right]
+-\frac{1}{e_3 }\frac{\partial \left( {T\,w} \right)}{\partial k} + D^T + F^T
+\end{equation}
+\begin{equation} \label{Eq_T}
+\frac{\partial S}{\partial t} = 
+-\frac{1}{e_1 e_2 }\left[ 	  {\frac{\partial \left( {e_2 S\,u} \right)}{\partial i}
+						+\frac{\partial \left( {e_1 S\,v} \right)}{\partial j}} \right]
+-\frac{1}{e_3 }\frac{\partial \left( {S\,w} \right)}{\partial k} + D^S + F^S
+\end{equation}
+\begin{equation} \label{Eq_rho}
+\rho =\rho \left( {T,S,z(k)} \right)
+\end{equation}
+
+The expression of \textbf{D}$^{U}$, $D^{S}$ and $D^{T}$ depends on the subgrid scale 
+parameterisation used. It will be defined in \S\ref{PE_zdf}. The nature and formulation of 
+${\rm {\bf F}}^{\rm {\bf U}}$, $F^T$ and $F^S$, the surface forcing terms, are discussed 
+in Chapter~\ref{SBC}.
+
+\newpage 
+% ================================================================
+% Curvilinear z*-coordinate System
+% ================================================================
+\section{Curvilinear \textit{z*}-coordinate System}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!b] \label{Fig_z_zstar}  \begin{center}
+\includegraphics[width=1.0\textwidth]{./TexFiles/Figures/Fig_z_zstar.pdf}
+\caption{(a) $z$-coordinate in linear free-surface case ; (b) $z-$coordinate in non-linear 
+free surface case (c) re-scaled height coordinate (become popular as the \textit{z*-}coordinate 
+\citep{Adcroft_Campin_OM04} ).}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+In that case, the free surface equation is nonlinear, and the variations of volume are fully 
+taken into account. These coordinates systems is presented in a report \citep{Levier2007} 
+available on the \NEMO web site. 
+
+\gmcomment{
+The \textit{z*} coordinate approach is an unapproximated, non-linear free surface implementation 
+which allows one to deal with large amplitude free-surface
+variations relative to the vertical resolution \citep{Adcroft_Campin_OM04}. In
+the  \textit{z*} formulation, the variation of the column thickness due to sea-surface
+undulations is not concentrated in the surface level, as in the $z$-coordinate formulation,
+but is equally distributed over the full water column. Thus vertical
+levels naturally follow sea-surface variations, with a linear attenuation with
+depth, as illustrated by figure fig.1c . Note that with a flat bottom, such as in
+fig.1c, the bottom-following  $z$ coordinate and  \textit{z*} are equivalent.
+The definition and modified oceanic equations for the rescaled vertical coordinate
+ \textit{z*}, including the treatment of fresh-water flux at the surface, are
+detailed in Adcroft and Campin (2004). The major points are summarized
+here. The position ( \textit{z*}) and vertical discretization (\textit{z*}) are expressed as:
+
+$H +  \textit{z*} = (H + z) / r$ and  $\delta \textit{z*} = \delta z / r$ with $r = \frac{H+\eta} {H}$
+
+Since the vertical displacement of the free surface is incorporated in the vertical
+coordinate  \textit{z*}, the upper and lower boundaries are at fixed  \textit{z*} position,  
+$\textit{z*} = 0$ and  $\textit{z*} = ?H$ respectively. Also the divergence of the flow field 
+is no longer zero as shown by the continuity equation:
+
+$\frac{\partial r}{\partial t} = \nabla_{\textit{z*}} \cdot \left( r \; \rm{\bf U}_h \right)
+		\left( r \; w\textit{*} \right) = 0 $
+
+}
+
+
+\newpage 
+% ================================================================
+% Curvilinear s-coordinate System
+% ================================================================
+\section{Curvilinear \textit{s}-coordinate System}
+\label{PE_sco}
+
+% -------------------------------------------------------------------------------------------------------------
+% Introduction
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Introduction}
+
+Several important aspects of the ocean circulation are influenced by bottom topography. 
+Of course, the most important is that bottom topography determines deep ocean sub-basins, 
+barriers, sills and channels that strongly constrain the path of water masses, but more subtle 
+effects exist. For example, the topographic $\beta$-effect is usually larger than the planetary 
+one along continental slopes. Topographic Rossby waves can be excited and can interact 
+with the mean current. In the $z-$coordinate system presented in the previous section 
+(\S\ref{PE_zco}), $z-$surfaces are geopotential surfaces. The bottom topography is 
+discretised by steps. This often leads to a misrepresentation of a gradually sloping bottom 
+and to large localized depth gradients associated with large localized vertical velocities. 
+The response to such a velocity field often leads to numerical dispersion effects. 
+One solution to strongly reduce this error is to use a partial step representation of bottom 
+topography instead of a full step one \cite{Pacanowski_Gnanadesikan_MWR98}. 
+Another solution is to introduce a terrain-following coordinate system (hereafter $s-$coordinate) 
+
+The $s$-coordinate avoids the discretisation error in the depth field since the layers of 
+computation are gradually adjusted with depth to the ocean bottom. Relatively small 
+topographic features as well as  gentle, large-scale slopes of the sea floor in the deep 
+ocean, which would be ignored in typical $z$-model applications with the largest grid 
+spacing at greatest depths, can easily be represented (with relatively low vertical resolution). 
+A terrain-following model (hereafter $s-$model) also facilitates the modelling of the 
+boundary layer flows over a large depth range, which in the framework of the $z$-model 
+would require high vertical resolution over the whole depth range. Moreover, with a 
+$s$-coordinate it is possible, at least in principle, to have the bottom and the sea surface 
+as the only boundaries of the domain (nomore lateral boundary condition to specify). 
+Nevertheless, a $s$-coordinate also has its drawbacks. Perfectly adapted to a 
+homogeneous ocean, it has strong limitations as soon as stratification is introduced. 
+The main two problems come from the truncation error in the horizontal pressure 
+gradient and a possibly increased diapycnal diffusion. The horizontal pressure force 
+in $s$-coordinate consists of two terms (see Appendix~\ref{Apdx_A}),
+
+\begin{equation} \label{Eq_PE_p_sco}
+\left. {\nabla p} \right|_z =\left. {\nabla p} \right|_s -\frac{\partial 
+p}{\partial s}\left. {\nabla z} \right|_s 
+\end{equation}
+
+The second term in \eqref{Eq_PE_p_sco} depends on the tilt of the coordinate surface 
+and introduces a truncation error that is not present in a $z$-model. In the special case 
+of a $\sigma-$coordinate (i.e. a depth-normalised coordinate system $\sigma = z/H$), 
+\citet{Haney1991} and \citet{Beckmann1993} have given estimates of the magnitude 
+of this truncation error. It depends on topographic slope, stratification, horizontal and 
+vertical resolution, the equation of state, and the finite difference scheme. This error 
+limits the possible topographic slopes that a model can handle at a given horizontal 
+and vertical resolution. This is a severe restriction for large-scale applications using 
+realistic bottom topography. The large-scale slopes require high horizontal resolution, 
+and the computational cost becomes prohibitive. This problem can be at least partially 
+overcome by mixing $s$-coordinate and step-like representation of bottom topography \citep{Gerdes1993a,Gerdes1993b,Madec1996}. However, the definition of the model 
+domain vertical coordinate becomes then a non-trivial thing for a realistic bottom 
+topography: a envelope topography is defined in $s$-coordinate on which a full or 
+partial step bottom topography is then applied in order to adjust the model depth to 
+the observed one (see \S\ref{DOM_zgr}.
+
+For numerical reasons a minimum of diffusion is required along the coordinate surfaces 
+of any finite difference model. It causes spurious diapycnal mixing when coordinate 
+surfaces do not coincide with isoneutral surfaces. This is the case for a $z$-model as 
+well as for a $s$-model. However, density varies more strongly on $s-$surfaces than 
+on horizontal surfaces in regions of large topographic slopes, implying larger diapycnal 
+diffusion in a $s$-model than in a $z$-model. Whereas such a diapycnal diffusion in a 
+$z$-model tends to weaken horizontal density (pressure) gradients and thus the horizontal 
+circulation, it usually reinforces these gradients in a $s$-model, creating spurious circulation. 
+For example, imagine an isolated bump of topography in an ocean at rest with a horizontally 
+uniform stratification. Spurious diffusion along $s$-surfaces will induce a bump of isoneutral 
+surfaces over the topography, and thus will generate there a baroclinic eddy. In contrast, 
+the ocean will stay at rest in a $z$-model. As for the truncation error, the problem can be reduced by introducing the terrain-following coordinate below the strongly stratified portion of the water column 
+($i.e.$ the main thermocline) \citep{Madec1996}. An alternate solution consists of rotating 
+the lateral diffusive tensor to geopotential or to isoneutral surfaces (see \S\ref{PE_ldf}. 
+Unfortunately, the slope of isoneutral surfaces relative to the $s$-surfaces can very large, 
+strongly exceeding the stability limit of such a operator when it is discretized (see Chapter~\ref{LDF}). 
+
+The $s-$coordinates introduced here \citep{Lott1990,Madec1996} differ mainly in two 
+aspects from similar models:  it allows  a representation of bottom topography with mixed 
+full or partial step-like/terrain following topography ; It also offers a completely general 
+transformation, $s=s(i,j,z)$ for the vertical coordinate.
+
+% -------------------------------------------------------------------------------------------------------------
+% The s-coordinate Formulation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{The \textit{s-}coordinate Formulation}
+
+Starting from the set of equations established in \S\ref{PE_zco} for the special case $k=z$ 
+and thus $e_3=1$, we introduce an arbitrary vertical coordinate $s=s(i,j,k,t)$, which includes 
+$z$-, \textit{z*}- and $\sigma-$coordinates as special cases ($s=z$, $s=\textit{z*}$, and 
+$s=\sigma=z/H$ or $=z/\left(H+\eta \right)$, resp.). A formal derivation of the transformed 
+equations is given in Appendix~\ref{Apdx_A}. Let us define the vertical scale factor by 
+$e_3=\partial_s z$  ($e_3$ is now a function of $(i,j,k,t)$ ), and the slopes in the 
+(\textbf{i},\textbf{j}) directions between $s-$ and $z-$surfaces by :
+\begin{equation} \label{Eq_PE_sco_slope}
+\sigma _1 =\frac{1}{e_1 }\;\left. {\frac{\partial z}{\partial i}} \right|_s 
+\quad \text{, and } \quad 
+\sigma _2 =\frac{1}{e_2 }\;\left. {\frac{\partial z}{\partial j}} \right|_s
+\end{equation}
+We also introduce  $\omega $, a dia-surface velocity component, defined as the velocity 
+relative to the moving $s$-surfaces and normal to them:
+\begin{equation} \label{Eq_PE_sco_w}
+\omega  = w - e_3 \, \frac{\partial s}{\partial t} - \sigma _1 \,u - \sigma _2 \,v    \\
+\end{equation}
+
+The equations solved by the ocean model \eqref{Eq_PE} in $s-$coordinate can be written as follows:
+
+ \vspace{0.5cm}
+* momentum equation:
+\begin{multline} \label{Eq_PE_sco_u}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t}=
+	+   \left( {\zeta +f} \right)\,v                                    
+	-   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right) 
+	-   \frac{1}{e_3} \omega \frac{\partial u}{\partial k}       \\
+	-   \frac{1}{e_1} \frac{\partial}{\partial i} \left( \frac{p_s + p_h}{\rho _o}    \right)    
+	+  g\frac{\rho }{\rho _o}\sigma _1 
+	+   D_u^{\vect{U}}  +   F_u^{\vect{U}} \quad
+\end{multline}
+\begin{multline} \label{Eq_PE_sco_v}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,v  \right) }{\partial t}=
+	-   \left( {\zeta +f} \right)\,u   
+	-   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)     	
+	-   \frac{1}{e_3 } \omega \frac{\partial v}{\partial k}         \\
+	-   \frac{1}{e_2 }\frac{\partial }{\partial j}\left( \frac{p_s+p_h }{\rho _o}  \right) 
+	 +  g\frac{\rho }{\rho _o }\sigma _2   
+	+  D_v^{\vect{U}}  +   F_v^{\vect{U}} \quad
+\end{multline}
+where the relative vorticity, \textit{$\zeta $}, the surface pressure gradient, and the hydrostatic 
+pressure have the same expressions as in $z$-coordinates although they do not represent 
+exactly the same quantities. $\omega$ is provided by the continuity equation 
+(see Appendix~\ref{Apdx_A}):
+
+\begin{equation} \label{Eq_PE_sco_continuity}
+\frac{\partial e_3}{\partial t} + e_3 \; \chi + \frac{\partial \omega }{\partial s} = 0   
+\qquad \text{with }\;\;  
+\chi =\frac{1}{e_1 e_2 e_3 }\left[ {\frac{\partial \left( {e_2 e_3 \,u} 
+\right)}{\partial i}+\frac{\partial \left( {e_1 e_3 \,v} \right)}{\partial 
+j}} \right]
+\end{equation}
+
+ \vspace{0.5cm}
+* tracer equations:
+\begin{multline} \label{Eq_PE_sco_t}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,T  \right) }{\partial t}=
+-\frac{1}{e_1 e_2 e_3 }\left[ {\frac{\partial \left( {e_2 e_3\,u\,T} \right)}{\partial i}
+                                           +\frac{\partial \left( {e_1 e_3\,v\,T} \right)}{\partial j}} \right]   \\
+-\frac{1}{e_3 }\frac{\partial \left( {T\,\omega } \right)}{\partial k}   + D^T + F^S   \qquad
+\end{multline}
+
+\begin{multline} \label{Eq_PE_sco_s}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,S  \right) }{\partial t}=
+-\frac{1}{e_1 e_2 e_3 }\left[ {\frac{\partial \left( {e_2 e_3\,u\,S} \right)}{\partial i}
+                                           +\frac{\partial \left( {e_1 e_3\,v\,S} \right)}{\partial j}} \right]    \\
+-\frac{1}{e_3 }\frac{\partial \left( {S\,\omega } \right)}{\partial k}     + D^S + F^S   \qquad
+\end{multline}
+
+The equation of state has the same expression as in $z$-coordinate, and similar expressions 
+are used for mixing and forcing terms.
+
+\gmcomment{
+\colorbox{yellow}{ to be updated $= = >$}
+Add a few works on z and zps and s and underlies the differences between all of them
+\colorbox{yellow}{ $< = =$ end update}  }
+
+\newpage 
+% ================================================================
+% Subgrid Scale Physics
+% ================================================================
+\section{Subgrid Scale Physics}
+\label{PE_zdf_ldf}
+
+The primitive equations describe the behaviour of a geophysical fluid at 
+space and time scales larger than a few kilometres in the horizontal, a few 
+meters in the vertical and a few minutes. They are usually solved at larger 
+scales: the specified grid spacing and time step of the numerical model. The 
+effects of smaller scale motions (coming from the advective terms in the 
+Navier-Stokes equations) must be represented entirely in terms of 
+large-scale patterns to close the equations. These effects appear in the 
+equations as the divergence of turbulent fluxes ($i.e.$ fluxes associated with 
+the mean correlation of small scale perturbations). Assuming a turbulent 
+closure hypothesis is equivalent to choose a formulation for these fluxes. 
+It is usually called the subgrid scale physics. It must be emphasized that 
+this is the weakest part of the primitive equations, but also one of the 
+most important for long-term simulations as small scale processes \textit{in fine} 
+balance the surface input of kinetic energy and heat.
+
+The control exerted by gravity on the flow induces a strong anisotropy 
+between the lateral and vertical motions. Therefore subgrid-scale physics  
+\textbf{D}$^{\vect{U}}$, $D^{S}$ and $D^{T}$  in \eqref{Eq_PE_dyn}, 
+\eqref{Eq_PE_tra_T} and \eqref{Eq_PE_tra_S} are divided into a lateral part  
+\textbf{D}$^{l \vect{U}}$, $D^{lS}$ and $D^{lT}$ and a vertical part  
+\textbf{D}$^{vU}$, $D^{vS}$ and $D^{vT}$. The formulation of these terms 
+and their underlying physics are briefly discussed in the next two subsections.
+
+% -------------------------------------------------------------------------------------------------------------
+% Vertical Subgrid Scale Physics
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Vertical Subgrid Scale Physics}
+\label{PE_zdf}
+
+The model resolution is always larger than the scale at which the major 
+sources of vertical turbulence occur (shear instability, internal wave 
+breaking...). Turbulent motions are thus never explicitly solved, even 
+partially, but always parameterized. The vertical turbulent fluxes are 
+assumed to depend linearly on the gradients of large-scale quantities (for 
+example, the turbulent heat flux is given by $\overline{T'w'}=-A^{vT} \partial_z \overline T$, 
+where $A^{vT}$ is an eddy coefficient). This formulation is 
+analogous to that of molecular diffusion and dissipation. This is quite 
+clearly a necessary compromise: considering only the molecular viscosity 
+acting on large scale severely underestimates the role of turbulent 
+diffusion and dissipation, while an accurate consideration of the details of 
+turbulent motions is simply impractical. The resulting vertical momentum and 
+tracer diffusive operators are of second order:
+\begin{equation} \label{Eq_PE_zdf}
+   \begin{split}
+{\vect{D}}^{v \vect{U}} &=\frac{\partial }{\partial z}\left( {A^{vm}\frac{\partial {\vect{U}}_h }{\partial z}} \right) \ , \\         
+D^{vT}                         &= \frac{\partial }{\partial z}\left( {A^{vT}\frac{\partial T}{\partial z}} \right) \ ,
+\quad
+D^{vS}=\frac{\partial }{\partial z}\left( {A^{vT}\frac{\partial S}{\partial z}} \right)
+   \end{split}
+\end{equation}
+where $A^{vm}$ and $A^{vT}$ are the vertical eddy viscosity and diffusivity coefficients, 
+respectively. At the sea surface and at the bottom, turbulent fluxes of momentum, heat 
+and salt must be specified (see Chap.~\ref{SBC} and \ref{ZDF} and \S\ref{TRA_bbl}). 
+All the vertical physics is embedded in the specification of the eddy coefficients. 
+They can be assumed to be either constant, or function of the local fluid properties 
+($e.g.$ Richardson number, Brunt-Vais\"{a}l\"{a} frequency...), or computed from a 
+turbulent closure model. The choices available in \NEMO are discussed in \S\ref{ZDF}).
+
+% -------------------------------------------------------------------------------------------------------------
+% Lateral Diffusive and Viscous Operators Formulation
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Lateral Diffusive and Viscous Operators Formulation}
+\label{PE_ldf}
+
+Lateral turbulence can be roughly divided into a mesoscale turbulence 
+associated with eddies (which can be solved explicitly if the resolution is 
+sufficient since their underlying physics are included in the primitive 
+equations), and a sub mesoscale turbulence which is never explicitly solved 
+even partially, but always parameterized. The formulation of lateral eddy 
+fluxes depends on whether the mesoscale is below or above the grid-spacing 
+($i.e.$ the model is eddy-resolving or not).
+
+In non-eddy-resolving configurations, the closure is similar to that used 
+for the vertical physics. The lateral turbulent fluxes are assumed to depend 
+linearly on the lateral gradients of large-scale quantities. The resulting 
+lateral diffusive and dissipative operators are of second order. 
+Observations show that lateral mixing induced by mesoscale turbulence tends 
+to be along isopycnal surfaces (or more precisely neutral surfaces \cite{McDougall1987}) 
+rather than across them. 
+As the slope of neutral surfaces is small in the ocean, a common 
+approximation is to assume that the `lateral' direction is the horizontal, 
+$i.e.$ the lateral mixing is performed along geopotential surfaces. This leads 
+to a geopotential second order operator for lateral subgrid scale physics. 
+This assumption can be relaxed: the eddy-induced turbulent fluxes can be 
+better approached by assuming that they depend linearly on the gradients of 
+large-scale quantities computed along neutral surfaces. In such a case, 
+the diffusive operator is an isoneutral second order operator and it has 
+components in the three space directions. However, both horizontal and 
+isoneutral operators have no effect on mean ($i.e.$ large scale) potential 
+energy whereas potential energy is a main source of turbulence (through 
+baroclinic instabilities). \citet{Gent1990} have proposed a 
+parameterisation of mesoscale eddy-induced turbulence which associates an 
+eddy-induced velocity to the isoneutral diffusion. Its mean effect is to 
+reduce the mean potential energy of the ocean. This leads to a formulation 
+of lateral subgrid-scale physics made up of an isoneutral second order 
+operator and an eddy induced advective part. In all these lateral diffusive 
+formulations, the specification of the lateral eddy coefficients remains the 
+problematic point as there is no really satisfactory formulation of these 
+coefficients as a function of large-scale features.
+
+In eddy-resolving configurations, a second order operator can be used, but 
+usually a more scale selective one (biharmonic operator) is preferred as the 
+grid-spacing is usually not small enough compared to the scale of the 
+eddies. The role devoted to the subgrid-scale physics is to dissipate the 
+energy that cascades toward the grid scale and thus ensures the stability of 
+the model while not interfering with the solved mesoscale activity. Another approach 
+is becoming more and more popular: instead of specifying explicitly a sub-grid scale 
+term in the momentum and tracer time evolution equations, one uses a advective 
+scheme which is diffusive enough to maintain the model stability. It must be emphasised
+that then, all the sub-grid scale physics is in this case include in the formulation of the
+advection scheme. 
+
+All these parameterisations of subgrid scale physics present advantages and 
+drawbacks. There are not all available in \NEMO. In the $z$-coordinate 
+formulation, five options are offered for active tracers (temperature and 
+salinity): second order geopotential operator, second order isoneutral 
+operator, \citet{Gent1990} parameterisation, fourth order 
+geopotential operator, and various slightly diffusive advection schemes. 
+The same options are available for momentum, except 
+\citet{Gent1990} parameterisation which only involves tracers. In the
+$s$-coordinate formulation, additional options are offered for tracers: second 
+order operator acting along $s-$surfaces, and for momentum: fourth order 
+operator acting along $s-$surfaces (see \S\ref{LDF}).
+
+\subsubsection{lateral second order tracer diffusive operator}
+
+The lateral second order tracer diffusive operator is defined by (see Appendix~\ref{Apdx_B}):
+\begin{equation} \label{Eq_PE_iso_tensor}
+D^{lT}=\nabla {\rm {\bf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad 
+\mbox{with}\quad \;\;\Re =\left( {{\begin{array}{*{20}c}
+ 1 \hfill & 0 \hfill & {-r_1 } \hfill \\
+ 0 \hfill & 1 \hfill & {-r_2 } \hfill \\
+ {-r_1 } \hfill & {-r_2 } \hfill & {r_1 ^2+r_2 ^2} \hfill \\
+\end{array} }} \right)
+\end{equation}
+where $r_1 \;\mbox{and}\;r_2 $ are the slopes between the surface along 
+which the diffusive operator acts and the model level ($e. g.$ $z$- or 
+$s$-surfaces). Note that the formulation \eqref{Eq_PE_iso_tensor} is exact for the 
+rotation between geopotential and $s$-surfaces, while it is only an approximation 
+for the rotation between isoneutral and $z$- or $s$-surfaces. Indeed, in the latter 
+case, two assumptions are made to simplify  \eqref{Eq_PE_iso_tensor} \citep{Cox1987}. 
+First, the horizontal contribution of the dianeutral mixing is neglected since the ratio 
+between iso and dia-neutral diffusive coefficients is known to be several orders of 
+magnitude smaller than unity. Second, the two isoneutral directions of diffusion are 
+assumed to be independent since the slopes are generally less than $10^{-2}$ in the 
+ocean (see Appendix~\ref{Apdx_B}).
+
+For \textit{geopotential} diffusion, $r_1$ and $r_2 $ are the slopes between the 
+geopotential and computational surfaces: in $z$-coordinates they are zero 
+($r_1 = r_2 = 0$) while in $s$-coordinate (including $\textit{z*}$ case) they are 
+equal to $\sigma _1$ and $\sigma _2$, respectively (see \eqref{Eq_PE_sco_slope} ).
+
+For \textit{isoneutral} diffusion $r_1$ and $r_2$ are the slopes between the isoneutral 
+and computational surfaces. Therefore, they have a same expression in $z$- and $s$-coordinates:
+\begin{equation} \label{Eq_PE_iso_slopes}
+r_1 =\frac{e_3 }{e_1 }	\left( {\frac{\partial \rho }{\partial i}} \right)
+						\left( {\frac{\partial \rho }{\partial k}} \right)^{-1} \ , \quad
+r_1 =\frac{e_3 }{e_1 }	\left( {\frac{\partial \rho }{\partial i}} \right)
+						\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
+\end{equation}
+
+When the \textit{Eddy Induced Velocity} parametrisation (eiv) \citep{Gent1990} is used, 
+an additional tracer advection is introduced in combination with the isoneutral diffusion of tracers:
+\begin{equation} \label{Eq_PE_iso+eiv}
+D^{lT}=\nabla \cdot \left( {A^{lT}\;\Re \;\nabla T} \right)
+           +\nabla \cdot \left( {{\vect{U}}^\ast \,T} \right)
+\end{equation}
+where ${\vect{U}}^\ast =\left( {u^\ast ,v^\ast ,w^\ast } \right)$ is a non-divergent, 
+eddy-induced transport velocity. This velocity field is defined by:
+\begin{equation} \label{Eq_PE_eiv}
+   \begin{split}
+ u^\ast  &= +\frac{1}{e_3       }\frac{\partial }{\partial k}\left[ {A^{eiv}\;\tilde{r}_1 } \right] \\ 
+ v^\ast  &= +\frac{1}{e_3       }\frac{\partial }{\partial k}\left[ {A^{eiv}\;\tilde{r}_2 } \right] \\ 
+ w^\ast &=  -\frac{1}{e_1 e_2 }\left[ 
+                      \frac{\partial }{\partial i}\left( {A^{eiv}\;e_2\,\tilde{r}_1 } \right)
+                    +\frac{\partial }{\partial j}\left( {A^{eiv}\;e_1\,\tilde{r}_2 } \right)      \right]
+   \end{split}
+\end{equation}
+where $A^{eiv}$ is the eddy induced velocity coefficient (or equivalently the isoneutral 
+thickness diffusivity coefficient), and $\tilde{r}_1$ and $\tilde{r}_2$ are the slopes 
+between isoneutral and \emph{geopotential} surfaces and thus depends on the coordinate 
+considered: 
+\begin{align} \label{Eq_PE_slopes_eiv}
+\tilde{r}_n = \begin{cases}
+   r_n                  &      \text{in $z$-coordinate}    \\
+   r_n + \sigma_n &      \text{in \textit{z*} and $s$-coordinates}  
+                   \end{cases}
+\quad \text{where } n=1,2
+\end{align}
+
+The normal component of the eddy induced velocity is zero at all the boundaries. 
+This can be achieved in a model by tapering either the eddy coefficient or the slopes 
+to zero in the vicinity of the boundaries. The latter strategy is used in \NEMO (cf. Chap.~\ref{LDF}).
+
+\subsubsection{lateral fourth order tracer diffusive operator}
+
+The lateral fourth order tracer diffusive operator is defined by:
+\begin{equation} \label{Eq_PE_bilapT}
+D^{lT}=\Delta \left( {A^{lT}\;\Delta T} \right) 
+\qquad \text{where} \  D^{lT}=\Delta \left( {A^{lT}\;\Delta T} \right)
+ \end{equation}
+
+It is the second order operator given by \eqref{Eq_PE_iso_tensor} applied twice with 
+the eddy diffusion coefficient correctly placed. 
+
+
+\subsubsection{lateral second order momentum diffusive operator}
+
+The second order momentum diffusive operator along $z$- or $s$-surfaces is found by 
+applying \eqref{Eq_PE_lap_vector} to the horizontal velocity vector (see Appendix~\ref{Apdx_B}):
+\begin{equation} \label{Eq_PE_lapU}
+\begin{split}
+{\rm {\bf D}}^{l{\rm {\bf U}}} 
+&= \quad \  \nabla _h \left( {A^{lm}\chi } \right)
+   \ - \ \nabla _h \times \left( {A^{lm}\,\zeta \;{\rm {\bf k}}} \right)     \\
+&=   \left(      \begin{aligned}
+             \frac{1}{e_1      } \frac{\partial \left( A^{lm} \chi          \right)}{\partial i} 
+         &-\frac{1}{e_2 e_3}\frac{\partial \left( {A^{lm} \;e_3 \zeta} \right)}{\partial j}  \\
+             \frac{1}{e_2      }\frac{\partial \left( {A^{lm} \chi         } \right)}{\partial j}   
+         &+\frac{1}{e_1 e_3}\frac{\partial \left( {A^{lm} \;e_3 \zeta} \right)}{\partial i}
+        \end{aligned}    \right)
+\end{split}
+\end{equation}
+
+Such a formulation ensures a complete separation between the vorticity and 
+horizontal divergence fields (see Appendix~\ref{Apdx_C}). Unfortunately, it is not 
+available for geopotential diffusion in $s-$coordinates and for isoneutral 
+diffusion in both $z$- and $s$-coordinates ($i.e.$ when a rotation is required). 
+In these two cases, the $u$ and $v-$fields are considered as independent scalar 
+fields, so that the diffusive operator is given by:
+\begin{equation} \label{Eq_PE_lapU_iso}
+\begin{split}
+ D_u^{l{\rm {\bf U}}} &= \nabla .\left( {\Re \;\nabla u} \right) \\ 
+ D_v^{l{\rm {\bf U}}} &= \nabla .\left( {\Re \;\nabla v} \right)
+ \end{split}
+ \end{equation}
+where $\Re$ is given by  \eqref{Eq_PE_iso_tensor}. It is the same expression as 
+those used for diffusive operator on tracers. It must be emphasised that such a 
+formulation is only exact in a Cartesian coordinate system, $i.e.$ on a $f-$ or 
+$\beta-$plane, not on the sphere. It is also a very good approximation in vicinity 
+of the Equator in a geographical coordinate system \citep{Lengaigne_al_JGR03}.
+
+\subsubsection{lateral fourth order momentum diffusive operator}
+
+As for tracers, the fourth order momentum diffusive operator along $z$ or $s$-surfaces 
+is a re-entering second order operator \eqref{Eq_PE_lapU} or \eqref{Eq_PE_lapU} 
+with the eddy viscosity coefficient correctly placed:
+
+geopotential diffusion in $z$-coordinate:
+\begin{equation} \label{Eq_PE_bilapU}
+\begin{split}
+{\rm {\bf D}}^{l{\rm {\bf U}}} &=\nabla _h \left\{ {\;\nabla _h {\rm {\bf 
+.}}\left[ {A^{lm}\,\nabla _h \left( \chi \right)} \right]\;} 
+\right\}\;   \\
+&+\nabla _h \times \left\{ {\;{\rm {\bf k}}\cdot \nabla \times 
+\left[ {A^{lm}\,\nabla _h \times \left( {\zeta \;{\rm {\bf k}}} \right)} 
+\right]\;} \right\}
+\end{split}
+\end{equation}
+
+\gmcomment{  change the position of the coefficient, both here and in the code}
+
+geopotential diffusion in $s$-coordinate:
+\begin{equation} \label{Eq_bilapU_iso}
+   \left\{   \begin{aligned}
+         D_u^{l{\rm {\bf U}}} =\Delta \left( {A^{lm}\;\Delta u} \right) \\ 
+         D_v^{l{\rm {\bf U}}} =\Delta \left( {A^{lm}\;\Delta v} \right)
+   \end{aligned}    \right.
+   \quad \text{where} \quad 
+   \Delta \left( \bullet \right) = \nabla \cdot \left( \Re \nabla(\bullet) \right) 
+\end{equation}
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex	(revision 1844)
@@ -0,0 +1,243 @@
+% ================================================================
+% Chapter 1 Ñ Model Basics
+% ================================================================
+% ================================================================
+% Curvilinear z*- s*-coordinate System
+% ================================================================
+\chapter{ essai z* s*}
+\section{Curvilinear \textit{z*}- or \textit{s*} coordinate System}
+
+% -------------------------------------------------------------------------------------------------------------
+% ????
+% -------------------------------------------------------------------------------------------------------------
+
+\colorbox{yellow}{ to be updated }
+
+In that case, the free surface equation is nonlinear, and the variations of 
+volume are fully taken into account. These coordinates systems is presented in 
+a report \citep{Levier2007} available on the \NEMO web site. 
+
+\colorbox{yellow}{  end of to be updated}
+\newline
+
+% from MOM4p1 documentation
+
+To overcome problems with vanishing surface and/or bottom cells, we consider the 
+zstar coordinate 
+\begin{equation} \label{PE_}
+	z^\star = H \left( \frac{z-\eta}{H+\eta} \right)
+\end{equation}
+
+This coordinate is closely related to the "eta" coordinate used in many atmospheric 
+models (see Black (1994) for a review of eta coordinate atmospheric models). It 
+was originally used in ocean models by Stacey et al. (1995) for studies of tides 
+next to shelves, and it has been recently promoted by Adcroft and Campin (2004) 
+for global climate modelling.
+
+The surfaces of constant $z^\star$ are quasi-horizontal. Indeed, the $z^\star$ coordinate reduces to $z$ when $\eta$ is zero. In general, when noting the large differences between 
+undulations of the bottom topography versus undulations in the surface height, it 
+is clear that surfaces constant $z^\star$ are very similar to the depth surfaces. These properties greatly reduce difficulties of computing the horizontal pressure gradient relative to terrain following sigma models discussed in \S\ref{PE_sco}. 
+Additionally, since $z^\star$ when $\eta = 0$, no flow is spontaneously generated in an 
+unforced ocean starting from rest, regardless the bottom topography. This behaviour is in contrast to the case with "s"-models, where pressure gradient errors in 
+the presence of nontrivial topographic variations can generate nontrivial spontaneous flow from a resting state, depending on the sophistication of the pressure 
+gradient solver. The quasi-horizontal nature of the coordinate surfaces also facilitates the implementation of neutral physics parameterizations in $z^\star$ models using 
+the same techniques as in $z$-models (see Chapters 13-16 of Griffies (2004) for a 
+discussion of neutral physics in $z$-models, as well as Section \S\ref{LDF_slp} 
+in this document for treatment in \NEMO). 
+
+The range over which $z^\star$ varies is time independent $-H \leq z^\star \leq 0$. Hence, all 
+cells remain nonvanishing, so long as the surface height maintains $\eta > ?H$. This 
+is a minor constraint relative to that encountered on the surface height when using 
+$s = z$ or $s = z - \eta$. 
+
+Because $z^\star$ has a time independent range, all grid cells have static increments 
+ds, and the sum of the ver tical increments yields the time independent ocean 
+depth %·k ds = H. 
+The $z^\star$ coordinate is therefore invisible to undulations of the 
+free surface, since it moves along with the free surface. This proper ty means that 
+no spurious ver tical transpor t is induced across surfaces of constant $z^\star$ by the 
+motion of external gravity waves. Such spurious transpor t can be a problem in 
+z-models, especially those with tidal forcing. Quite generally, the time independent 
+range for the $z^\star$ coordinate is a very convenient proper ty that allows for a nearly 
+arbitrary ver tical resolution even in the presence of large amplitude fluctuations of 
+the surface height, again so long as $\eta > -H$. 
+
+
+
+%%%
+%  essai update time splitting...
+%%%
+
+
+% ================================================================
+% Surface Pressure Gradient and Sea Surface Height
+% ================================================================
+\section{Surface pressure gradient and Sea Surface Heigth (\mdl{dynspg})}
+\label{DYN_hpg_spg}
+%-----------------------------------------nam_dynspg----------------------------------------------------
+\namdisplay{nam_dynspg} 
+%------------------------------------------------------------------------------------------------------------
+The surface pressure gradient term is related to the representation of the free surface (\S\ref{PE_hor_pg}). The main distinction is between the fixed volume case (linear free surface or rigid lid) and the variable volume case (nonlinear free surface, \key{vvl} is active). In the linear free surface case (\S\ref{PE_free_surface}) and rigid lid (\S\ref{PE_rigid_lid}), the vertical scale factors $e_{3}$ are fixed in time, while in the nonlinear case (\S\ref{PE_free_surface}) they are time-dependent. With both linear and nonlinear free surface, external gravity waves are allowed in the equations, which imposes a very small time step when an explicit time stepping is used. Two methods are proposed to allow a longer time step for the three-dimensional equations: the filtered free surface, which is a modification of the continuous equations (see \eqref{Eq_PE_flt}), and the split-explicit free surface described below. The extra term introduced in the filtered method is calculated implicitly, so that the update of the next velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
+
+%-------------------------------------------------------------
+% Explicit
+%-------------------------------------------------------------
+\subsubsection{Explicit (\key{dynspg\_exp})}
+\label{DYN_spg_exp}
+
+In the explicit free surface formulation, the model time step is chosen small enough to describe the external gravity waves (typically a few ten seconds). The sea surface height is given by :
+\begin{equation} \label{Eq_dynspg_ssh}
+\frac{\partial \eta }{\partial t}\equiv \frac{\text{EMP}}{\rho _w }+\frac{1}{e_{1T} 
+e_{2T} }\sum\limits_k {\left( {\delta _i \left[ {e_{2u} e_{3u} u} 
+\right]+\delta _j \left[ {e_{1v} e_{3v} v} \right]} \right)} 
+\end{equation}
+
+where EMP is the surface freshwater budget (evaporation minus precipitation, and minus river runoffs (if the later are introduced as a surface freshwater flux, see \S\ref{SBC}) expressed in $Kg.m^{-2}.s^{-1}$, and $\rho _w =1,000\,Kg.m^{-3}$ is the volumic mass of pure water. The sea-surface height is evaluated using a leapfrog scheme in combination with an Asselin time filter, i.e. the velocity appearing in (\ref{Eq_dynspg_ssh}) is centred in time (\textit{now} velocity). 
+
+The surface pressure gradient, also evaluated using a leap-frog scheme, is then simply given by :
+\begin{equation} \label{Eq_dynspg_exp}
+\left\{ \begin{aligned}
+ - \frac{1}    						{e_{1u}} \;	\delta _{i+1/2} \left[  \,\eta\,  \right] 	\\
+ \\
+ - \frac{1}    						{e_{2v}} \;	\delta _{j+1/2} \left[  \,\eta\,  \right]  
+\end{aligned} \right.
+\end{equation} 
+
+Consistent with the linearization, a $\left. \rho \right|_{k=1} / \rho _o$ factor is omitted in (\ref{Eq_dynspg_exp}). 
+
+%-------------------------------------------------------------
+% Split-explicit time-stepping
+%-------------------------------------------------------------
+\subsubsection{Split-explicit time-stepping (\key{dynspg\_ts})}
+\label{DYN_spg_ts}
+%--------------------------------------------namdom----------------------------------------------------
+\namdisplay{namdom} 
+%--------------------------------------------------------------------------------------------------------------
+The split-explicit free surface formulation used in OPA follows the one proposed by \citet{Griffies2004}. The general idea is to solve the free surface equation with a small time step, while the three dimensional prognostic variables are solved with a longer time step that is a multiple of \np{rdtbt} (Figure III.3). 
+
+%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+\begin{figure}[!t] \label{Fig_DYN_dynspg_ts}
+\begin{center}
+\includegraphics[width=0.90\textwidth]{./Figures/Fig_DYN_dynspg_ts.pdf}
+\caption{Schematic of the split-explicit time stepping scheme for the barotropic and baroclinic modes, after \citet{Griffies2004}. Time increases to the right. Baroclinic time steps are denoted by $t-\Delta t$, $t, t+\Delta t$, and $t+2\Delta t$. The curved line represents a leap-frog time step, and the smaller barotropic time steps $N \Delta t=2\Delta t$ are denoted by the zig-zag line. The vertically integrated forcing \textbf{M}(t) computed at baroclinic time step t represents the interaction between the barotropic and baroclinic motions. While keeping the total depth, tracer, and freshwater forcing fields fixed, a leap-frog integration carries the surface height and vertically integrated velocity from t to $t+2 \Delta t$ using N barotropic time steps of length $\Delta t$. Time averaging the barotropic fields over the N+1 time steps (endpoints included) centers the vertically integrated velocity at the baroclinic timestep $t+\Delta t$. A baroclinic leap-frog time step carries the surface height to $t+\Delta t$ using the convergence of the time averaged vertically integrated velocity taken from baroclinic time step t. }
+\end{center}
+\end{figure}
+%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+
+The split-explicit formulation has a damping effect on external gravity waves, which is weaker than the filtered free surface but still significant as shown by \citet{Levier2007} in the case of an analytical barotropic Kelvin wave. 
+
+%from griffies book: .....   copy past !
+
+\textbf{title: Time stepping the barotropic system }
+
+Assume knowledge of the full velocity and tracer fields at baroclinic time $\tau$. Hence, 
+we can update the surface height and vertically integrated velocity with a leap-frog 
+scheme using the small barotropic time step $\Delta t$. We have 
+
+\begin{equation} \label{DYN_spg_ts_eta}
+\eta^{(b)}(\tau,t_{n+1}) - \eta^{(b)}(\tau,t_{n+1}) (\tau,t_{n-1})
+	= 2 \Delta t \left[-\nabla \cdot \textbf{U}^{(b)}(\tau,t_n) + \text{EMP}_w(\tau) \right] 
+\end{equation}
+\begin{multline} \label{DYN_spg_ts_u}
+\textbf{U}^{(b)}(\tau,t_{n+1}) - \textbf{U}^{(b)}(\tau,t_{n-1})  \\
+	= 2\Delta t \left[ - f \textbf{k} \times \textbf{U}^{(b)}(\tau,t_{n}) 
+	- H(\tau) \nabla p_s^{(b)}(\tau,t_{n}) +\textbf{M}(\tau) \right]
+\end{multline}
+\
+
+In these equations, araised (b) denotes values of surface height and vertically integrated velocity updated with the barotropic time steps. The $\tau$ time label on $\eta^{(b)}$ 
+and $U^{(b)}$ denotes the baroclinic time at which the vertically integrated forcing $\textbf{M}(\tau)$ (note that this forcing includes the surface freshwater forcing), the tracer fields, the freshwater flux $\text{EMP}_w(\tau)$, and total depth of the ocean $H(\tau)$ are held for the duration of the barotropic time stepping over a single cycle. This is also the time 
+that sets the barotropic time steps via 
+\begin{equation} \label{DYN_spg_ts_t}
+t_n=\tau+n\Delta t   
+\end{equation}
+with $n$ an integer. The density scaled surface pressure is evaluated via 
+\begin{equation} \label{DYN_spg_ts_ps}
+p_s^{(b)}(\tau,t_{n}) = \begin{cases}
+	g \;\eta_s^{(b)}(\tau,t_{n}) \;\rho(\tau)_{k=1}) / \rho_o  &      \text{non-linear case} \\
+	g \;\eta_s^{(b)}(\tau,t_{n})  &      \text{linear case} 
+	\end{cases}
+\end{equation}
+To get started, we assume the following initial conditions 
+\begin{equation} \label{DYN_spg_ts_eta}
+\begin{split}
+\eta^{(b)}(\tau,t_{n=0}) &= \overline{\eta^{(b)}(\tau)}
+\\
+\eta^{(b)}(\tau,t_{n=1}) &= \eta^{(b)}(\tau,t_{n=0}) + \Delta t \ \text{RHS}_{n=0} 
+\end{split}
+\end{equation}
+with 
+\begin{equation} \label{DYN_spg_ts_etaF}
+ \overline{\eta^{(b)}(\tau)} = \frac{1}{N+1} \sum\limits_{n=0}^N \eta^{(b)}(\tau-\Delta t,t_{n})
+\end{equation}
+the time averaged surface height taken from the previous barotropic cycle. Likewise, 
+\begin{equation} \label{DYN_spg_ts_u}
+\textbf{U}^{(b)}(\tau,t_{n=0}) = \overline{\textbf{U}^{(b)}(\tau)}	\\
+\\
+\textbf{U}(\tau,t_{n=1}) = \textbf{U}^{(b)}(\tau,t_{n=0}) + \Delta t \ \text{RHS}_{n=0}  	
+\end{equation}
+with 
+\begin{equation} \label{DYN_spg_ts_u}
+ \overline{\textbf{U}^{(b)}(\tau)} 
+ 	= \frac{1}{N+1} \sum\limits_{n=0}^N\textbf{U}^{(b)}(\tau-\Delta t,t_{n})
+\end{equation}
+the time averaged vertically integrated transport. Notably, there is no Robert-Asselin time filter used in the barotropic portion of the integration. 
+
+Upon reaching $t_{n=N} = \tau + 2\Delta \tau$ , the vertically integrated velocity is time averaged to produce the updated vertically integrated velocity at baroclinic time $\tau + \Delta \tau$ 
+\begin{equation} \label{DYN_spg_ts_u}
+\textbf{U}(\tau+\Delta t) = \overline{\textbf{U}^{(b)}(\tau+\Delta t)} 
+ 	= \frac{1}{N+1} \sum\limits_{n=0}^N\textbf{U}^{(b)}(\tau,t_{n})
+\end{equation}
+The surface height on the new baroclinic time step is then determined via a baroclinic leap-frog using the following form 
+
+\begin{equation} \label{DYN_spg_ts_ssh}
+\eta(\tau+\Delta) - \eta^{F}(\tau-\Delta) = 2\Delta t \ \left[ - \nabla \cdot \textbf{U}(\tau) + \text{EMP}_w \right]  
+\end{equation}
+
+ The use of this "big-leap-frog" scheme for the surface height ensures compatibility between the mass/volume budgets and the tracer budgets. More discussion of this point is provided in Chapter 10 (see in particular Section 10.2). 
+ 
+In general, some form of time filter is needed to maintain integrity of the surface 
+height field due to the leap-frog splitting mode in equation \ref{DYN_spg_ts_ssh}. We 
+have tried various forms of such filtering, with the following method discussed in 
+Griffies et al. (2001) chosen due to its stability and reasonably good maintenance of 
+tracer conservation properties (see Section ??) 
+
+\begin{equation} \label{DYN_spg_ts_sshf}
+\eta^{F}(\tau-\Delta) =  \overline{\eta^{(b)}(\tau)} 
+\end{equation}
+Another approach tried was 
+
+\begin{equation} \label{DYN_spg_ts_sshf2}
+\eta^{F}(\tau-\Delta) = \eta(\tau) 
+	+ (\alpha/2) \left[\overline{\eta^{(b)}}(\tau+\Delta t)
+				    + \overline{\eta^{(b)}}(\tau-\Delta t) -2 \;\eta(\tau) \right]
+\end{equation}
+
+which is useful since it isolates all the time filtering aspects into the term multiplied 
+by $\alpha$. This isolation allows for an easy check that tracer conservation is exact when 
+eliminating tracer and surface height time filtering (see Section ?? for more complete discussion). However, in the general case with a non-zero $\alpha$, the filter \ref{DYN_spg_ts_sshf} was found to be more conservative, and so is recommended. 
+
+
+
+
+
+%-------------------------------------------------------------
+% Filtered formulation 
+%-------------------------------------------------------------
+\subsubsection{Filtered formulation (\key{dynspg\_flt})}
+\label{DYN_spg_flt}
+
+The filtered formulation follows the \citet{Roullet2000} implementation. The extra term introduced in the equations (see {\S}I.2.2) is solved implicitly. The elliptic solvers available in the code are 
+documented in \S\ref{MISC}. The amplitude of the extra term is given by the namelist variable \np{rnu}. The default value is 1, as recommended by \citet{Roullet2000}
+
+\colorbox{red}{\np{rnu}=1 to be suppressed from namelist !}
+
+%-------------------------------------------------------------
+% Non-linear free surface formulation 
+%-------------------------------------------------------------
+\subsection{Non-linear free surface formulation (\key{vvl})}
+\label{DYN_spg_vvl}
+
+In the non-linear free surface formulation, the variations of volume are fully taken into account. This option is presented in a report \citep{Levier2007} available on the NEMO web site. The three time-stepping methods (explicit, split-explicit and filtered) are the same as in \S\ref{DYN_spg_linear} except that the ocean depth is now time-dependent. In particular, this means that in filtered case, the matrix to be inverted has to be recomputed at each time-step.
+
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_SBC.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 1844)
@@ -0,0 +1,619 @@
+% ================================================================
+% Chapter Ñ Surface Boundary Condition (SBC) 
+% ================================================================
+\chapter{Surface Boundary Condition (SBC) }
+\label{SBC}
+\minitoc
+
+\newpage
+$\ $\newline    % force a new ligne
+%---------------------------------------namsbc--------------------------------------------------
+\namdisplay{namsbc}
+%--------------------------------------------------------------------------------------------------------------
+$\ $\newline    % force a new ligne
+
+The ocean needs six fields as surface boundary condition:
+\begin{itemize}
+\item the two components of the surface ocean stress $\left( {\tau _u \;,\;\tau _v} \right)$
+\item the incoming solar and non solar heat fluxes $\left( {Q_{ns} \;,\;Q_{sr} } \right)$
+\item the surface freshwater budget $\left( {\text{EMP},\;\text{EMP}_S } \right)$
+\end{itemize}
+
+Four different ways to provide those six fields to the ocean are available which 
+are controlled by namelist variables: an analytical formulation (\np{ln\_ana}=true), 
+a flux formulation (\np{ln\_flx}=true), a bulk formulae formulation (CORE 
+(\np{ln\_core}=true) or CLIO (\np{ln\_clio}=true) bulk formulae) and a coupled 
+formulation (exchanges with a atmospheric model via the OASIS coupler) 
+(\np{ln\_cpl}=true). The frequency at which the six fields have to be updated is
+the  \np{nf\_sbc} namelist parameter. 
+When the fields are supplied from data files (flux and bulk formulations), the input fields 
+need not be supplied on the model grid.  Instead a file of coordinates and weights can be supplied which
+maps the data from the supplied grid to the model points (so called "Interpolation on the Fly").
+In addition, the resulting fields can be further modified using 
+several namelist options. These options control  the rotation of vector components
+supplied relative to an east-north coordinate system onto the local grid directions in the model;
+the addition of a surface restoring 
+term to observed SST and/or SSS (\np{ln\_ssr}=true); the modification of fluxes 
+below ice-covered areas (using observed ice-cover or a sea-ice model) 
+(\np{nn\_ice}=0,1, 2 or 3); the addition of river runoffs as surface freshwater 
+fluxes (\np{ln\_rnf}=true); the addition of a freshwater flux adjustment in 
+order to avoid a mean sea-level drift (\np{nn\_fwb}= 0, 1 or 2); and the 
+transformation of the solar radiation (if provided as daily mean) into a diurnal 
+cycle (\np{ln\_dm2dc}=true).
+
+In this chapter, we first discuss where the surface boundary condition 
+appears in the model equations. Then we present the four ways of providing 
+the surface boundary condition. Next the scheme for interpolation on the fly is described.
+Finally, the different options that further modify
+the fluxes applied to the ocean are discussed.
+
+
+% ================================================================
+% Surface boundary condition for the ocean
+% ================================================================
+\section{Surface boundary condition for the ocean}
+\label{SBC_general}
+
+
+The surface ocean stress is the stress exerted by the wind and the sea-ice 
+on the ocean. The two components of stress are assumed to be interpolated 
+onto the ocean mesh, $i.e.$ resolved onto the model (\textbf{i},\textbf{j}) direction 
+at $u$- and $v$-points They are applied as a surface boundary condition of the 
+computation of the momentum vertical mixing trend (\mdl{dynzdf} module) :
+\begin{equation} \label{Eq_sbc_dynzdf}
+\left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{z=1}
+	 = \frac{1}{\rho _o} \binom{\tau _u}{\tau _v }
+\end{equation}
+where $(\tau _u ,\;\tau _v )=(utau,vtau)$ are the two components of the wind 
+stress vector in the $(\textbf{i},\textbf{j})$ coordinate system.
+
+The surface heat flux is decomposed into two parts, a non solar and a solar heat 
+flux, $Q_{ns}$ and $Q_{sr}$, respectively. The former is the non penetrative part 
+of the heat flux ($i.e.$ the sum of sensible, latent and long wave heat fluxes). 
+It is applied as a surface boundary condition trend of the first level temperature 
+time evolution equation (\mdl{trasbc} module). 
+\begin{equation} \label{Eq_sbc_trasbc_q}
+\frac{\partial T}{\partial t}\equiv \cdots \;+\;\left. {\frac{Q_{ns} }{\rho 
+_o \;C_p \;e_{3T} }} \right|_{k=1} \quad
+\end{equation}
+$Q_{sr}$ is the penetrative part of the heat flux. It is applied as a 3D 
+trends of the temperature equation (\mdl{traqsr} module) when \np{ln\_traqsr}=True.
+
+\begin{equation} \label{Eq_sbc_traqsr}
+\frac{\partial T}{\partial t}\equiv \cdots \;+\frac{Q_{sr} }{\rho _o C_p 
+\,e_{3T} }\delta _k \left[ {I_w } \right]
+\end{equation}
+where $I_w$ is a non-dimensional function that describes the way the light 
+penetrates inside the water column. It is generally a sum of decreasing 
+exponentials (see \S\ref{TRA_qsr}).
+
+The surface freshwater budget is provided by fields: EMP and EMP$_S$ which 
+may or may not be identical. Indeed, a surface freshwater flux has two effects: 
+it changes the volume of the ocean and it changes the surface concentration of 
+salt (and other tracers). Therefore it appears in the sea surface height as a volume 
+flux, EMP (\textit{dynspg\_xxx} modules), and in the salinity time evolution equations 
+as a concentration/dilution effect, 
+EMP$_{S}$ (\mdl{trasbc} module). 
+\begin{equation} \label{Eq_trasbc_emp}
+\begin{aligned}
+&\frac{\partial \eta }{\partial t}\equiv \cdots \;+\;\text{EMP}\quad  \\ 
+\\
+ &\frac{\partial S}{\partial t}\equiv \cdots \;+\left. {\frac{\text{EMP}_S \;S}{e_{3T} }} \right|_{k=1} \\ 
+ \end{aligned}
+\end{equation} 
+
+In the real ocean, EMP$=$EMP$_S$ and the ocean salt content is conserved, 
+but it exist several numerical reasons why this equality should be broken. 
+For example:
+
+When the rigid-lid assumption is made, the ocean volume becomes constant and 
+thus, EMP$=$0, not EMP$_{S }$.
+
+When the ocean is coupled to a sea-ice model, the water exchanged between ice and 
+ocean is slightly salty (mean sea-ice salinity is $\sim $\textit{4 psu}). In this case, 
+EMP$_{S}$ take into account both concentration/dilution effect associated with 
+freezing/melting and the salt flux between ice and ocean, while EMP is 
+only the volume flux. In addition, in the current version of \NEMO, the 
+sea-ice is assumed to be above the ocean. Freezing/melting does not change 
+the ocean volume (no impact on EMP) but it modifies the SSS.
+%gm  \colorbox{yellow}{(see {\S} on LIM sea-ice model)}.
+
+Note that SST can also be modified by a freshwater flux. Precipitation (in 
+particular solid precipitation) may have a temperature significantly different from 
+the SST. Due to the lack of information about the temperature of 
+precipitation, we assume it is equal to the SST. Therefore, no 
+concentration/dilution term appears in the temperature equation. It has to 
+be emphasised that this absence does not mean that there is no heat flux 
+associated with precipitation! Precipitation can change the ocean volume and thus the
+ocean heat content. It is therefore associated with a heat flux (not yet  
+diagnosed in the model) \citep{Roullet2000}).
+
+%\colorbox{yellow}{Miss: }
+%
+%A extensive description of all namsbc namelist (parameter that have to be 
+%created!)
+%
+%Especially the \np{nf\_sbc}, the \mdl{sbc\_oce} module (fluxes + mean sst sss ssu 
+%ssv) i.e. information required by flux computation or sea-ice
+%
+%\mdl{sbc\_oce} containt the definition in memory of the 7 fields (6+runoff), add 
+%a word on runoff: included in surface bc or add as lateral obc{\ldots}.
+%
+%Sbcmod manage the ``providing'' (fourniture) to the ocean the 7 fields
+%
+%Fluxes update only each nf{\_}sbc time step (namsbc) explain relation 
+%between nf{\_}sbc and nf{\_}ice, do we define nf{\_}blk??? ? only one 
+%nf{\_}sbc
+%
+%Explain here all the namlist namsbc variable{\ldots}.
+%
+%\colorbox{yellow}{End Miss }
+
+The ocean model provides the surface currents, temperature and salinity 
+averaged over \np{nf\_sbc} time-step (\ref{Tab_ssm}).The computation of the 
+mean is done in \mdl{sbcmod} module.
+
+%-------------------------------------------------TABLE---------------------------------------------------
+\begin{table}[tb]  \label{Tab_ssm}
+\begin{center}
+\begin{tabular}{|l|l|l|l|}
+\hline
+Variable description					& Model variable	& Units	& point \\	\hline
+i-component of the surface current	& ssu\_m	& $m.s^{-1}$	& U \\	\hline
+j-component of the surface current	& ssv\_m	& $m.s^{-1}$	& V \\	\hline
+Sea surface temperature				& sst\_m	& \r{}$K$		& T \\	\hline
+Sea surface salinty					& sss\_m	& $psu$			& T \\	\hline
+\end{tabular}
+\caption{Ocean variables provided by the ocean to the surface module (SBC). 
+The variable are averaged over nf{\_}sbc time step, $i.e.$ the frequency of 
+computation of surface fluxes.}
+\end{center}
+\end{table}
+%--------------------------------------------------------------------------------------------------------------
+
+
+
+%\colorbox{yellow}{Penser a} mettre dans le restant l'info nf{\_}sbc ET nf{\_}sbc*rdt de sorte de reinitialiser la moyenne si on change la frequence ou le pdt
+
+
+% ================================================================
+% Analytical formulation (sbcana module) 
+% ================================================================
+\section  [Analytical formulation (\textit{sbcana}) ]
+		{Analytical formulation (\mdl{sbcana} module) }
+\label{SBC_ana}
+
+%---------------------------------------namsbc_ana--------------------------------------------------
+\namdisplay{namsbc_ana}
+%--------------------------------------------------------------------------------------------------------------
+
+
+The analytical formulation of the surface boundary condition is the default scheme.
+In this case, all the six fluxes needed by the ocean are assumed to 
+be uniform in space. They take constant values given in the namelist 
+namsbc{\_}ana by the variables \np{rn\_utau0}, \np{rn\_vtau0}, \np{rn\_qns0}, 
+\np{rn\_qsr0}, and \np{rn\_emp0} (EMP$=$EMP$_S$). The runoff is set to zero. 
+In addition, the wind is allowed to reach its nominal value within a given number 
+of time steps (\np{nn\_tau000}).
+
+If a user wants to apply a different analytical forcing, the \mdl{sbcana} 
+module can be modified to use another scheme. As an example, 
+the \mdl{sbc\_ana\_gyre} routine provides the analytical forcing for the 
+GYRE configuration (see GYRE configuration manual, in preparation).
+
+
+% ================================================================
+% Flux formulation 
+% ================================================================
+\section  [Flux formulation (\textit{sbcflx}) ]
+		{Flux formulation (\mdl{sbcflx} module) }
+\label{SBC_flx}
+%------------------------------------------namsbc_flx----------------------------------------------------
+\namdisplay{namsbc_flx} 
+%-------------------------------------------------------------------------------------------------------------
+
+In the flux formulation (\np{ln\_flx}=true), the surface boundary 
+condition fields are directly read from input files. The user has to define 
+in the namelist namsbc{\_}flx the name of the file, the name of the variable 
+read in the file, the time frequency at which it is given (in hours), and a logical 
+setting whether a time interpolation to the model time step is required 
+for this field). (fld\_i namelist structure).
+
+\textbf{Caution}: when the frequency is set to --12, the data are monthly 
+values. These are assumed to be climatological values, so time interpolation 
+between December the 15$^{th}$ and January the 15$^{th}$ is done using 
+records 12 and 1
+
+When higher frequency is set and time interpolation is demanded, the model 
+will try to read the last (first) record of previous (next) year in a file 
+having the same name but a suffix {\_}prev{\_}year ({\_}next{\_}year) being 
+added (e.g. "{\_}1989"). These files must only contain a single record. If they don't exist, 
+the model assumes that the last record of the previous year is equal to the first 
+record of the current year, and similarly, that the first record of the 
+next year is equal to the last record of the current year. This will cause 
+the forcing to remain constant over the first and last half fld\_frequ hours.
+
+Note that in general, a flux formulation is used in associated with a 
+restoring term to observed SST and/or SSS. See \S\ref{SBC_ssr} for its 
+specification.
+
+
+% ================================================================
+% Bulk formulation
+% ================================================================
+\section  [Bulk formulation (\textit{sbcblk\_core} or \textit{sbcblk\_clio}) ]
+		{Bulk formulation \small{(\mdl{sbcblk\_core} or \mdl{sbcblk\_clio} module)} }
+\label{SBC_blk}
+
+In the bulk formulation, the surface boundary condition fields are computed 
+using bulk formulae and atmospheric fields and ocean (and ice) variables. 
+
+The atmospheric fields used depend on the bulk formulae used. Two bulk formulations 
+are available : the CORE and CLIO bulk formulea. The choice is made by setting to true
+one of the following namelist variable : \np{ln\_core} and \np{ln\_clio}.
+
+Note : in forced mode, when a sea-ice model is used, a bulk formulation have to be used. 
+Therefore the two bulk formulea provided include the computation of the fluxes over both 
+an ocean and an ice surface. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        CORE Bulk formulea
+% -------------------------------------------------------------------------------------------------------------
+\subsection    [CORE Bulk formulea (\np{ln\_core}=true)]
+		      {CORE Bulk formulea (\np{ln\_core}=true, \mdl{sbcblk\_core})}
+\label{SBC_blk_core}
+%------------------------------------------namsbc_core----------------------------------------------------
+\namdisplay{namsbc_core} 
+%-------------------------------------------------------------------------------------------------------------
+
+The CORE bulk formulae have been developed by \citet{LargeYeager2004}. 
+They have been designed to handle the CORE forcing, a mixture of NCEP 
+reanalysis and satellite data. They use an inertial dissipative method to compute 
+the turbulent transfer coefficients (momentum, sensible heat and evaporation) 
+from the 10 metre wind speed, air temperature and specific humidity.
+
+Note that substituting ERA40 to NCEP reanalysis fields 
+does not require changes in the bulk formulea themself. 
+
+The required 8 input fields are:
+
+%--------------------------------------------------TABLE--------------------------------------------------
+\begin{table}[htbp]   \label{Tab_CORE}
+\begin{center}
+\begin{tabular}{|l|l|l|l|}
+\hline
+Variable desciption					& Model variable	& Units	 & point \\		\hline
+i-component of the 10m air velocity	& utau		& $m.s^{-1}$			& T  \\ 	\hline
+j-component of the 10m air velocity	& vtau		& $m.s^{-1}$			& T  \\	\hline
+10m air temperature					& tair		& \r{}$K$				& T 	\\	\hline
+Specific humidity					& humi		& \%					& T \\		\hline
+Incoming long wave radiation		& qlw		& $W.m^{-2}$			& T \\		\hline
+Incoming short wave radiation		& qsr		& $W.m^{-2}$			& T \\		\hline
+Total precipitation (liquid + solid)	& precip	& $Kg.m^{-2}.s^{-1}$	& T \\ 	\hline
+Solid precipitation					& snow		& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
+\end{tabular}
+\end{center}
+\end{table}
+%--------------------------------------------------------------------------------------------------------------
+
+Note that the air velocity is provided at a tracer ocean point, not at a velocity ocean point ($u$- and $v$-points). It is simpler and faster (less fields to be read), but it is not the recommended method when the ocean grid
+size is the same or larger than the one of the input atmospheric fields.
+
+% -------------------------------------------------------------------------------------------------------------
+%        CLIO Bulk formulea
+% -------------------------------------------------------------------------------------------------------------
+\subsection    [CLIO Bulk formulea (\np{ln\_clio}=true)]
+		      {CLIO Bulk formulea (\np{ln\_clio}=true, \mdl{sbcblk\_clio})}
+\label{SBC_blk_clio}
+%------------------------------------------namsbc_clio----------------------------------------------------
+\namdisplay{namsbc_clio} 
+%-------------------------------------------------------------------------------------------------------------
+
+The CLIO bulk formulae were developed several years ago for the 
+Louvain-la-neuve coupled ice-ocean model (CLIO, \cite{Goosse_al_JGR99}). 
+They are simpler bulk formulae. They assume the stress to be known and 
+compute the radiative fluxes from a climatological cloud cover. 
+
+The required 7 input fields are:
+
+%--------------------------------------------------TABLE--------------------------------------------------
+\begin{table}[htbp]   \label{Tab_CLIO}
+\begin{center}
+\begin{tabular}{|l|l|l|l|}
+\hline
+Variable desciption				& Model variable	& Units				& point \\	\hline
+i-component of the ocean stress		& utau			& $N.m^{-2}$			& U \\	\hline
+j-component of the ocean stress		& vtau			& $N.m^{-2}$			& V \\	\hline
+Wind speed module					& vatm			& $m.s^{-1}$			& T \\	\hline
+10m air temperature					& tair			& \r{}$K$				& T \\	\hline
+Specific humidity						& humi			& \%					& T \\	\hline
+Cloud cover							& 				& \%					& T \\	\hline
+Total precipitation (liquid + solid)	& precip		& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
+Solid precipitation 					& snow			& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
+\end{tabular}
+\end{center}
+\end{table}
+%--------------------------------------------------------------------------------------------------------------
+
+As for the flux formulation, information about the input data required by the 
+model is provided in the namsbc\_blk\_core or namsbc\_blk\_clio 
+namelist (via the structure fld\_i). The first and last record assumption is also made 
+(see \S\ref{SBC_flx})
+
+% ================================================================
+% Coupled formulation
+% ================================================================
+\section  [Coupled formulation (\textit{sbccpl}) ]
+		{Coupled formulation (\mdl{sbccpl} module)}
+\label{SBC_cpl}
+%------------------------------------------namsbc_cpl----------------------------------------------------
+\namdisplay{namsbc_cpl} 
+%-------------------------------------------------------------------------------------------------------------
+
+In the coupled formulation of the surface boundary condition, the fluxes are 
+provided by the OASIS coupler at each \np{nf\_cpl} time-step, while sea and ice 
+surface temperature, ocean and ice albedo, and ocean currents are sent to 
+the atmospheric component.
+
+The generalised coupled interface is under development. It should be available
+in summer 2008. It will include the ocean interface for most of the European 
+atmospheric GCM (ARPEGE, ECHAM, ECMWF, HadAM, LMDz).
+
+% ================================================================
+% Interpolation on the Fly
+% ================================================================
+
+\section [Interpolation on the Fly] {Interpolation on the Fly}
+\label{SBC_iof}
+
+Interpolation on the Fly allows the user to supply input files required
+for the surface forcing on grids other than the model grid.
+To do this he or she must supply, in addition to the source data file,
+a file of weights to be used to interpolate from the data grid to the model
+grid.
+The original development of this code used the SCRIP package (freely available 
+under a copyright agreement from http://climate.lanl.gov/Software/SCRIP).
+In principle, any package can be used to generate the weights, but the
+variables in the input weights file must have the same names and meanings as
+assumed by the model.
+Two methods are currently available: bilinear and bicubic interpolation.
+
+\subsection{Bilinear Interpolation}
+\label{SBC_iof_bilinear}
+
+The input weights file in this case has two sets of variables: src01, src02,
+src03, src04 and wgt01, wgt02, wgt03, wgt04.
+The "src" variables correspond to the point in the input grid to which the weight
+"wgt" is to be applied. Each src value is an integer corresponding to the index of a 
+point in the input grid when written as a one dimensional array.  For example, for an input grid
+of size 5x10, point (3,2) is referenced as point 8, since (2-1)*5+3=8.
+There are four of each variable because bilinear interpolation uses the four points defining
+the grid box containing the point to be interpolated.
+All of these arrays are on the model grid, so that values src01(i,j) and
+wgt01(i,j) are used to generate a value for point (i,j) in the model.
+
+Symbolically, the algorithm used is:
+
+\begin{equation}
+f_{m}(i,j) = f_{m}(i,j) + \sum_{k=1}^{4} {wgt(k)f(idx(src(k)))}
+\end{equation}
+where function idx() transforms a one dimensional index src(k) into a two dimensional index,
+and wgt(1) corresponds to variable "wgt01" for example.
+
+\subsection{Bicubic Interpolation}
+\label{SBC_iof_bicubic}
+
+Again there are two sets of variables: "src" and "wgt".
+But in this case there are 16 of each.
+The symbolic algorithm used to calculate values on the model grid is now:
+
+\begin{multline*}
+f_{m}(i,j) = f_{m}(i,j) + \sum_{k=1}^{4} {wgt(k)f(idx(src(k)))}
+\\
+                        + \sum_{k=5}^{8} {wgt(k)\left.\frac{\partial f}{\partial i}\right| _{idx(src(k))} }
+\\
+                        + \sum_{k=9}^{12} {wgt(k)\left.\frac{\partial f}{\partial j}\right| _{idx(src(k))} }
+\\
+                        + \sum_{k=13}^{16} {wgt(k)\left.\frac{\partial ^2 f}{\partial i \partial j}\right| _{idx(src(k))} }
+\end{multline*}
+The gradients here are taken with respect to the horizontal indices and not distances since the spatial dependency has been absorbed into the weights.
+
+\subsection{Implementation}
+\label{SBC_iof_imp}
+
+To activate this option, a non-empty string should be supplied in the weights filename column of the relevant namelist;
+if this is left as an empty string no action is taken.
+In the model, weights files are read in and stored in a structured type (WGT) in the fldread module, as and when they are first required.
+This initialisation procedure tries to determine whether the input data grid should be treated as cyclical or not.
+(In fact this only matters when bicubic interpolation is required.)
+To do this the model looks in the input data file (i.e. the data to which the weights are to be applied) for a variable with name "nav\_lon" or "lon".
+If found, it checks the difference between the first and last values of longitude along a single row.
+If the absolute value of this difference is close to 360 degrees or less than twice the maximum spacing from 360 degrees, the grid is assumed to be cyclical, and the difference determines whether the first column is a repeat of the last one or not.
+If neither "nav\_lon" or "lon" can be found, the model resorts to looking at the first and last columns of data.
+If the sum of the absolute values of the differences between the columns is very small, then the grid is assumed to be cyclical with coincident first and last columns.
+If both of these tests fail, the grid is assumed not to be cyclical.
+
+Next the routine reads in the weights.
+Bicubic interpolation is assumed if it finds a variable with name "src05", otherwise bilinear interpolation is used.
+The WGT structure includes dynamic arrays both for the storage of the weights (on the model grid), and when required, for reading in the variable to be interpolated (on the input data grid).
+The size of the input data array is determined by examining the values in the "src" arrays to find the minimum and maximum i and j values required.
+Since bicubic interpolation requires the calculation of gradients at each point on the grid, the corresponding arrays are dimensioned with a halo of width one grid point all the way around.
+When the array of points from the data file is adjacent to an edge of the data grid, the halo is either a copy of the row/column next to it (non-cyclical case), or is a copy of one from the first two rows/columns on the opposite side of the grid (cyclical case with coincident end rows/columns, or cyclical case with non-coincident end rows/columns).
+
+\subsection{Limitations}
+\label{SBC_iof_lim}
+
+\begin{description}
+\item
+Input data grids must be logically rectangular.
+\item
+This code is not guaranteed to produce positive definite answers from positive definite inputs.
+\item
+The cyclic condition is only applied on left and right columns, and not to top and bottom rows.
+\item
+The gradients across the ends of a cyclical grid assume that the grid spacing between the two columns involved are consistent with the weights used.
+\item
+Neither interpolation scheme is conservative.
+(There is a conservative scheme available in SCRIP, but this has not been implemented.)
+\end{description}
+
+\subsection{Utilities}
+\label{SBC_iof_util}
+
+% to be completed
+A set of utilities to create a weights file for a rectilinear input grid is available.
+
+% ================================================================
+% Miscellanea options
+% ================================================================
+\section{Miscellaneous options}
+\label{SBC_misc}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Rotation of vector pairs onto the model grid directions
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Rotation of vector pairs onto the model grid directions}
+\label{SBC_rotation}
+
+When using a flux (\np{ln\_flx}=true) or bulk (\np{ln\_clio}=true or \np{ln\_core}=true) formulation, 
+pairs of vector components can be rotated from east-north directions onto the local grid directions.  
+This is particularly useful when interpolation on the fly is used since here any vectors are likely to be defined 
+relative to a rectilinear grid.
+To activate this option a non-empty string is supplied in the rotation pair column of the relevant namelist.
+The eastward component must start with "U" and the northward component with "V".  
+The remaining characters in the strings are used to identify which pair of components go together.
+So for example, strings "U1" and "V1" next to "utau" and "vtau" would pair the wind stress components together
+and rotate them on to the model grid directions; "U2" and "V2" could be used against a second pair of components, 
+and so on.
+The extra characters used in the strings are arbitrary.
+The rot\_rep routine from the \mdl{geo2ocean} module is used to perform the rotation.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Surface restoring to observed SST and/or SSS
+% -------------------------------------------------------------------------------------------------------------
+\subsection    [Surface restoring to observed SST and/or SSS (\textit{sbcssr})]
+			{Surface restoring to observed SST and/or SSS (\mdl{sbcssr})}
+\label{SBC_ssr}
+%------------------------------------------namsbc_ssr----------------------------------------------------
+\namdisplay{namsbc_ssr} 
+%-------------------------------------------------------------------------------------------------------------
+
+In forced mode using a flux formulation (default option or \key{flx} defined), a 
+feedback term \emph{must} be added to the surface heat flux $Q_{ns}^o$:
+\begin{equation} \label{Eq_sbc_dmp_q}
+Q_{ns} = Q_{ns}^o + \frac{dQ}{dT} \left( \left. T \right|_{k=1} - SST_{Obs} \right)
+\end{equation}
+where SST is a sea surface temperature field (observed or climatological), $T$ is 
+the model surface layer temperature and $\frac{dQ}{dT}$ is a negative feedback 
+coefficient usually taken equal to $-40~W/m^2/K$. For a $50~m$ 
+mixed-layer depth, this value corresponds to a relaxation time scale of two months. 
+This term ensures that if $T$ perfectly matches the supplied SST, then $Q$ is 
+equal to $Q_o$. 
+
+In the fresh water budget, a feedback term can also be added. Converted into an 
+equivalent freshwater flux, it takes the following expression :
+
+\begin{equation} \label{Eq_sbc_dmp_emp}
+EMP = EMP_o + \gamma_s^{-1} e_{3t}  \frac{  \left(\left.S\right|_{k=1}-SSS_{Obs}\right)}
+												         {\left.S\right|_{k=1}}
+\end{equation}
+
+where EMP$_{o }$ is a net surface fresh water flux (observed, climatological or an
+atmospheric model product), \textit{SSS}$_{Obs}$ is a sea surface salinity (usually a time 
+interpolation of the monthly mean Polar Hydrographic Climatology \citep{Steele2001}), 
+$\left.S\right|_{k=1}$ is the model surface layer salinity and $\gamma_s$ is a negative 
+feedback coefficient which is provided as a namelist parameter. Unlike heat flux, there is no 
+physical justification for the feedback term in \ref{Eq_sbc_dmp_emp} as the atmosphere 
+does not care about ocean surface salinity \citep{Madec1997}. The SSS restoring 
+term should be viewed as a flux correction on freshwater fluxes to reduce the 
+uncertainties we have on the observed freshwater budget.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Handling of ice-covered area
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Handling of ice-covered area  (\textit{sbcice\_...})}
+\label{SBC_ice-cover}
+
+The presence at the sea surface of an ice covered area modifies all the fluxes 
+transmitted to the ocean. There are several way to handle sea-ice in the system 
+depending on the value of the \np{nn{\_}ice} namelist parameter.  
+\begin{description}
+\item[nn{\_}ice = 0]  there will never be sea-ice in the computational domain. 
+This is a typical namelist value used for tropical ocean domain. The surface fluxes 
+are simply specified for an ice-free ocean. No specific things is done for sea-ice.
+\item[nn{\_}ice = 1]  sea-ice can exist in the computational domain, but no sea-ice model 
+is used. An observed ice covered area is read in a file. Below this area, the SST is 
+restored to the freezing point and the heat fluxes are set to $-4~W/m^2$ ($-2~W/m^2$) 
+in the northern (southern) hemisphere. The associated modification of the freshwater 
+fluxes are done in such a way that the change in buoyancy fluxes remains zero. 
+This prevents deep convection to occur when trying to reach the freezing point 
+(and so ice covered area condition) while the SSS is too large. This manner of 
+managing sea-ice area, just by using si IF case, is usually referred as the \textit{ice-if} 
+model. It can be found in the \mdl{sbcice{\_}if} module.
+\item[nn{\_}ice = 2 or more]  A full sea ice model is used. This model computes the 
+ice-ocean fluxes, that are combined with the air-sea fluxes using the ice fraction of 
+each model cell to provide the surface ocean fluxes. Note that the activation of a 
+sea-ice model is is done by defining a CPP key (\key{lim2} or \key{lim3}). 
+The activation automatically ovewrite the read value of nn{\_}ice to its appropriate 
+value ($i.e.$ $2$ for LIM-2 and $3$ for LIM-3).
+\end{description}
+
+% {Description of Ice-ocean interface to be added here or in LIM 2 and 3 doc ?}
+
+% -------------------------------------------------------------------------------------------------------------
+%        Addition of river runoffs
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Addition of river runoffs (\textit{sbcrnf})]
+			{Addition of river runoffs (\mdl{sbcrnf})}
+\label{SBC_rnf}
+%------------------------------------------namsbc_rnf----------------------------------------------------
+\namdisplay{namsbc_rnf} 
+%-------------------------------------------------------------------------------------------------------------
+
+The river runoffs 
+
+It is convenient to introduce the river runoff in the model as a surface 
+fresh water flux. 
+
+
+%Griffies:  River runoff generally enters the ocean at a nonzero depth rather than through the surface. Many global models, however, have traditionally inserted river runoff to the top model cell. Such can become problematic numerically and physically when the top grid cells are reÞned to levels common in coastal modelling. Hence, more applications are now considering the input of runoff throughout a nonzero depth. Likewise, sea ice can melt at depth, thus necessitating a mass transport to occur within the ocean between the liquid and solid water masses.
+
+\colorbox{yellow}{Nevertheless, Pb of vertical resolution and increase of Kz in vicinity of }
+
+\colorbox{yellow}{river mouths{\ldots}}
+
+%IF( ln_rnf ) THEN                                     ! increase diffusivity at rivers mouths
+%        DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + rn_avt_rnf * rnfmsk(:,:)   ;   END DO
+%ENDIF
+
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        Freshwater budget control 
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Freshwater budget control (\textit{sbcfwb})]
+			{Freshwater budget control (\mdl{sbcfwb})}
+\label{SBC_fwb}
+
+For global ocean simulation it can be useful to introduce a control of the mean sea 
+level in order to prevent unrealistic drift of the sea surface height due to inaccuracy 
+in the freshwater fluxes. In \NEMO, two way of controlling the the freshwater budget. 
+\begin{description}
+\item[\np{nn\_fwb}=0]  no control at all. The mean sea level is free to drift, and will 
+certainly do so.
+\item[\np{nn\_fwb}=1]  global mean EMP set to zero at each model time step. 
+%Note that with a sea-ice model, this technique only control the mean sea level with linear free surface (\key{vvl} not defined) and no mass flux between ocean and ice (as it is implemented in the current ice-ocean coupling). 
+\item[\np{nn\_fwb}=2]  freshwater budget is adjusted from the previous year annual 
+mean budget which is read in the \textit{EMPave\_old.dat} file. As the model uses the 
+Boussinesq approximation, the annual mean fresh water budget is simply evaluated 
+from the change in the mean sea level at January the first and saved in the 
+\textit{EMPav.dat} file. 
+\end{description}
+
+% Griffies doc:
+% When running ocean-ice simulations, we are not explicitly representing land processes, such as rivers, catchment areas, snow accumulation, etc. However, to reduce model drift, it is important to balance the hydrological cycle in ocean-ice models. We thus need to prescribe some form of global normalization to the precipitation minus evaporation plus river runoff. The result of the normalization should be a global integrated zero net water input to the ocean-ice system over a chosen time scale. 
+%How often the normalization is done is a matter of choice. In mom4p1, we choose to do so at each model time step, so that there is always a zero net input of water to the ocean-ice system. Others choose to normalize over an annual cycle, in which case the net imbalance over an annual cycle is used to alter the subsequent yearÕs water budget in an attempt to damp the annual water imbalance. Note that the annual budget approach may be inappropriate with interannually varying precipitation forcing. 
+%When running ocean-ice coupled models, it is incorrect to include the water transport between the ocean and ice models when aiming to balance the hydrological cycle. The reason is that it is the sum of the water in the ocean plus ice that should be balanced when running ocean-ice models, not the water in any one sub-component. As an extreme example to illustrate the issue, consider an ocean-ice model with zero initial sea ice. As the ocean-ice model spins up, there should be a net accumulation of water in the growing sea ice, and thus a net loss of water from the ocean. The total water contained in the ocean plus ice system is constant, but there is an exchange of water between the subcomponents. This exchange should not be part of the normalization used to balance the hydrological cycle in ocean-ice models. 
+
+
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_TRA.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 1844)
@@ -0,0 +1,1289 @@
+% ================================================================
+% Chapter 1 Ñ Ocean Tracers (TRA)
+% ================================================================
+\chapter{Ocean Tracers (TRA)}
+\label{TRA}
+\minitoc
+
+% missing/update 
+% traqsr: need to coordinate with SBC module
+% trabbl : advective case to be discussed
+%			diffusive case : add : only the bottom ocean cell is concerned
+%			==> addfigure on bbl
+
+%STEVEN :  is the use of the word "positive" to describe a scheme enough, or should it be "positive definite"? I added a comment to this effect on some instances of this below
+
+%\newpage
+\vspace{2.cm}
+%$\ $\newline    % force a new ligne
+
+Using the representation described in Chap.~\ref{DOM}, several semi-discrete 
+space forms of the tracer equations are available depending on the vertical 
+coordinate used and on the physics used. In all the equations presented 
+here, the masking has been omitted for simplicity. One must be aware that 
+all the quantities are masked fields and that each time a mean or difference 
+operator is used, the resulting field is multiplied by a mask.
+
+The two active tracers are potential temperature and salinity. Their prognostic 
+equations can be summarized as follows:
+\begin{equation*}
+\text{NXT} = \text{ADV}+\text{LDF}+\text{ZDF}+\text{SBC}
+                   \ (+\text{QSR})\ (+\text{BBC})\ (+\text{BBL})\ (+\text{DMP})
+\end{equation*}
+
+NXT stands for next, referring to the time-stepping. From left to right, the terms 
+on the rhs of the tracer equations are the advection (ADV), the lateral diffusion 
+(LDF), the vertical diffusion (ZDF), the contributions from the external forcings 
+(SBC: Surface Boundary Condition, QSR: penetrative Solar Radiation, and BBC: 
+Bottom Boundary Condition), the contribution from the bottom boundary Layer 
+(BBL) parametrisation, and an internal damping (DMP) term. The terms QSR, 
+BBC, BBL and DMP are optional. The external forcings and parameterisations 
+require complex inputs and complex calculations (e.g. bulk formulae, estimation 
+of mixing coefficients) that are carried out in the SBC, LDF and ZDF modules and 
+described in chapters \S\ref{SBC}, \S\ref{LDF} and  \S\ref{ZDF}, respectively. 
+Note that \mdl{tranpc}, the non-penetrative convection module,  although 
+(temporarily) located in the NEMO/OPA/TRA directory, is described with the 
+model vertical physics (ZDF).
+%%%
+\gmcomment{change the position of eosbn2 in the reference code}
+%%%
+
+In the present chapter we also describe the diagnostic equations used to compute 
+the sea-water properties (density, Brunt-Vais\"{a}l\"{a} frequency, specific heat and 
+freezing point) although the associated modules ($i.e.$ \mdl{eosbn2}, \mdl{ocfzpt} 
+and \mdl{phycst}) are (temporarily) located in the NEMO/OPA directory.
+
+The different options available to the user are managed by namelist logical or 
+CPP keys. For each equation term \textit{ttt}, the namelist logicals are \textit{ln\_trattt\_xxx}, 
+where \textit{xxx} is a 3 or 4 letter acronym accounting for each optional scheme. 
+The CPP key (when it exists) is \textbf{key\_trattt}. The corresponding code can be 
+found in the \textit{trattt} or \textit{trattt\_xxx} module, in the NEMO/OPA/TRA directory.
+
+The user has the option of extracting each tendency term on the rhs of the tracer 
+equation for output (\key{trdtra} is defined), as described in Chap.~\ref{MISC}.
+
+$\ $\newline    % force a new ligne
+% ================================================================
+% Tracer Advection
+% ================================================================
+\section  [Tracer Advection (\textit{traadv})]
+		{Tracer Advection (\mdl{traadv})}
+\label{TRA_adv}
+%------------------------------------------nam_traadv-----------------------------------------------------
+\namdisplay{nam_traadv}
+%-------------------------------------------------------------------------------------------------------------
+
+The advection tendency of a tracer in flux form is the divergence of the advective 
+fluxes. Its discrete expression is given by :
+\begin{equation} \label{Eq_tra_adv}
+ADV_\tau =-\frac{1}{b_T} \left( 
+\;\delta _i \left[ e_{2u}\,e_{3u} \;  u\; \tau _u  \right]
++\delta _j \left[ e_{1v}\,e_{3v}  \;  v\; \tau _v  \right] \; \right)
+-\frac{1}{e_{3T}} \;\delta _k \left[ w\; \tau _w \right]
+\end{equation}
+where $\tau$ is either T or S, and $b_T= e_{1T}\,e_{2T}\,e_{3T}$ is the volume of $T$-cells. 
+In pure $z$-coordinate (\key{zco} is defined), it reduces to :
+\begin{equation} \label{Eq_tra_adv_zco}
+ADV_\tau =-\frac{1}{e_{1T} {\kern 1pt}e_{2T} {\kern 1pt}}\left( {\;\delta _i 
+\left[ {e_{2u} {\kern 1pt}{\kern 1pt}\;u\;\tau _u } \right]+\delta _j \left[ 
+{e_{1v} {\kern 1pt}v\;\tau _v } \right]\;} \right)-\frac{1}{\mathop 
+e\nolimits_{3T} }\delta _k \left[ {w\;\tau _w } \right]
+\end{equation}
+since the vertical scale factors are functions of $k$ only, and thus 
+$e_{3u} =e_{3v} =e_{3T} $. The flux form in \eqref{Eq_tra_adv} 
+requires implicitly the use of the continuity equation. Indeed, it is obtained
+by using the following equality : $\nabla \cdot \left( \vect{U}\,T \right)=\vect{U} \cdot \nabla T$ 
+which results from the use of the continuity equation, $\nabla \cdot \vect{U}=0$ or 
+$\partial _t e_3 + e_3\;\nabla \cdot \vect{U}=0$ in constant (default option) 
+or variable (\key{vvl} defined) volume case, respectively. 
+Therefore it is of paramount importance to design the discrete analogue of the 
+advection tendency so that it is consistent with the continuity equation in order to 
+enforce the conservation properties of the continuous equations. In other words, 
+by substituting $\tau$ by 1 in (\ref{Eq_tra_adv}) we recover the discrete form of 
+the continuity equation which is used to calculate the vertical velocity.
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_adv_scheme}  \begin{center}
+\includegraphics[width=0.9\textwidth]{./TexFiles/Figures/Fig_adv_scheme.pdf}
+\caption{Schematic representation of some ways used to evaluate the tracer value 
+at $u$-point and the amount of tracer exchanged between two neighbouring grid 
+points. Upsteam biased scheme (ups): the upstream value is used and the black 
+area is exchanged. Piecewise parabolic method (ppm): a parabolic interpolation 
+is used and the black and dark grey areas are exchanged. Monotonic upstream 
+scheme for conservative laws (muscl):  a parabolic interpolation is used and black, 
+dark grey and grey areas are exchanged. Second order scheme (cen2): the mean 
+value is used and black, dark grey, grey and light grey areas are exchanged. Note 
+that this illustration does not include the flux limiter used in ppm and muscl schemes.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The key difference between the advection schemes used in \NEMO is the choice 
+made in space and time interpolation to define the value of the tracer at the 
+velocity points (Fig.~\ref{Fig_adv_scheme}). 
+
+Along solid lateral and bottom boundaries a zero tracer flux is naturally 
+specified, since the normal velocity is zero there. At the sea surface the 
+boundary condition depends on the type of sea surface chosen: 
+\begin{description}
+\item  [rigid-lid formulation:] $w=0$ at the surface, so the advective 
+fluxes through the surface are zero.
+\item [linear free surface:] the first level thickness is constant in time: 
+the vertical boundary condition is applied at the fixed surface $z=0$ 
+rather than on the moving surface $z=\eta$. There is a non-zero advective 
+flux which is set for all advection schemes as the product of surface 
+velocity (at $z=0$) by the first level tracer value: 
+$\left. {\tau _w } \right|_{k=1/2} =T_{k=1} $. 
+\item [non-linear free surface:] (\key{vvl} is defined) 
+convergence/divergence in the first ocean level moves the free surface 
+up/down. There is no tracer advection through it so that the advective 
+fluxes through the surface are also zero 
+\end{description}
+In all cases, this boundary condition retains local conservation of tracer. 
+Global conservation is obtained in both rigid-lid and non-linear free surface 
+cases, but not in the linear free surface case. Nevertheless, in the latter
+case, it is achieved to a good approximation since the non-conservative 
+term is the product of the time derivative of the tracer and the free surface 
+height, two quantities that are not correlated (see \S\ref{PE_free_surface}, 
+and also \citet{Roullet2000,Griffies2001,Campin2004}).
+
+The velocity field that appears in (\ref{Eq_tra_adv}) and (\ref{Eq_tra_adv_zco}) 
+is the centred (\textit{now}) \textit{eulerian} ocean velocity (see Chap.~\ref{DYN}). 
+When advective bottom boundary layer (\textit{bbl}) and/or eddy induced velocity 
+(\textit{eiv}) parameterisations are used it is the \textit{now} \textit{effective} 
+velocity ($i.e.$ the sum of the eulerian, the bbl and/or the eiv velocities) which is used.
+
+The choice of an advection scheme is made in the \np{nam\_traadv} namelist, by 
+setting to \textit{true} one and only one of the logicals \textit{ln\_traadv\_xxx}. The 
+corresponding code can be found in the \textit{traadv\_xxx.F90} module, where 
+\textit{xxx} is a 3 or 4 letter acronym corresponding to each scheme. Details 
+of the advection schemes are given below. The choice of an advection scheme 
+is a complex matter which depends on the model physics, model resolution, 
+type of tracer, as well as the issue of numerical cost. 
+
+Note that 
+(1) cen2, cen4 and TVD schemes require an explicit diffusion 
+operator while the other schemes are diffusive enough so that they do not 
+require additional diffusion ; 
+(2) cen2, cen4, MUSCL2, and UBS are not \textit{positive} schemes
+\footnote{negative values can appear in an initially strictly positive tracer field 
+which is advected}
+, implying that false extrema are permitted. Their use is not recommended on passive tracers ; 
+(3) It is highly recommended that the same advection-diffusion scheme is 
+used on both active and passive tracers. Indeed, if a source or sink of a 
+passive tracer depends on an active one, the difference of treatment of 
+active and passive tracers can create very nice-looking frontal structures 
+that are pure numerical artefacts. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        2nd order centred scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [$2^{nd}$ order centred scheme (cen2) (\np{ln\_traadv\_cen2})]
+			{$2^{nd}$ order centred scheme (cen2) (\np{ln\_traadv\_cen2}=.true.)}
+\label{TRA_adv_cen2}
+
+In the centred second order formulation, the tracer at velocity points is 
+evaluated as the mean of the two neighbouring $T$-point values. 
+For example, in the $i$-direction :
+\begin{equation} \label{Eq_tra_adv_cen2}
+\tau _u^{cen2} =\overline T ^{i+1/2}
+\end{equation}
+
+The scheme is non diffusive ($i.e.$ it conserves the tracer variance, $\tau^2)$ 
+but dispersive ($i.e.$ it may create false extrema). It is therefore notoriously 
+noisy and must be used in conjunction with an explicit diffusion operator to 
+produce a sensible solution. The associated time-stepping is performed using 
+a leapfrog scheme in conjunction with an Asselin time-filter, so $T$ in 
+(\ref{Eq_tra_adv_cen2}) is the \textit{now} tracer value. The centered second 
+order advection is computed in the \mdl{traadv\_cen2} module. In this module,
+it is also proposed to combine the \textit{cen2} scheme with an upstream scheme
+in specific areas which requires a strong diffusion in order to avoid the generation 
+of false extrema. These areas are the vicinity of large river mouths, some straits 
+with coarse resolution, and the vicinity of ice cover area ($i.e.$ when the ocean 
+temperature is close to the freezing point).
+
+Note that using the cen2 scheme, the overall tracer advection is of second 
+order accuracy since both (\ref{Eq_tra_adv}) and (\ref{Eq_tra_adv_cen2}) 
+have this order of accuracy. Note also that 
+
+% -------------------------------------------------------------------------------------------------------------
+%        4nd order centred scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [$4^{nd}$ order centred scheme (cen4) (\np{ln\_traadv\_cen4})]
+		     {$4^{nd}$ order centred scheme (cen4) (\np{ln\_traadv\_cen4}=.true.)}
+\label{TRA_adv_cen4}
+
+In the $4^{th}$ order formulation (to be implemented), tracer values are 
+evaluated at velocity points as a $4^{th}$ order interpolation, and thus uses 
+the four neighbouring $T$-points. For example, in the $i$-direction:
+\begin{equation} \label{Eq_tra_adv_cen4}
+\tau _u^{cen4} 
+=\overline{   T - \frac{1}{6}\,\delta _i \left[ \delta_{i+1/2}[T] \,\right]   }^{\,i+1/2}
+\end{equation}
+
+Strictly speaking, the cen4 scheme is not a $4^{th}$ order advection scheme 
+but a $4^{th}$ order evaluation of advective fluxes, since the divergence of 
+advective fluxes \eqref{Eq_tra_adv} is kept at $2^{nd}$ order. The phrase ``$4^{th}$ 
+order scheme'' used in oceanographic literature is usually associated 
+with the scheme presented here. Introducing a \textit{true} $4^{th}$ order advection 
+scheme is feasible but, for consistency reasons, it requires changes in the 
+discretisation of the tracer advection together with changes in both the 
+continuity equation and the momentum advection terms.  
+
+A direct consequence of the pseudo-fourth order nature of the scheme is that 
+it is not non-diffusive, i.e. the global variance of a tracer is not preserved using 
+\textit{cen4}. Furthermore, it must be used in conjunction with an explicit 
+diffusion operator to produce a sensible solution. The time-stepping is also 
+performed using a leapfrog scheme in conjunction with an Asselin time-filter, 
+so $T$ in (\ref{Eq_tra_adv_cen4}) is the \textit{now} tracer.
+
+At a $T$-grid cell adjacent to a boundary (coastline, bottom and surface), an 
+additional hypothesis must be made to evaluate $\tau _u^{cen4}$. This 
+hypothesis usually reduces the order of the scheme. Here we choose to set 
+the gradient of $T$ across the boundary to zero. Alternative conditions can be 
+specified, such as a reduction to a second order scheme for these near boundary 
+grid points.
+
+% -------------------------------------------------------------------------------------------------------------
+%        TVD scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Total Variance Dissipation scheme (TVD) (\np{ln\_traadv\_tvd})]
+			{Total Variance Dissipation scheme (TVD) (\np{ln\_traadv\_tvd}=.true.)}
+\label{TRA_adv_tvd}
+
+In the Total Variance Dissipation (TVD) formulation, the tracer at velocity 
+points is evaluated using a combination of an upstream and a centred scheme. 
+For example, in the $i$-direction :
+\begin{equation} \label{Eq_tra_adv_tvd}
+\begin{split}
+\tau _u^{ups}&= \begin{cases}
+ 					T_{i+1} 	& \text{if $\ u_{i+1/2} <     0$} \hfill \\
+ 					T_i   		& \text{if $\ u_{i+1/2} \geq 0$} \hfill \\
+				  \end{cases}     \\
+\\
+\tau _u^{tvd}&=\tau _u^{ups} +c_u \;\left( {\tau _u^{cen2} -\tau _u^{ups} } \right)
+\end{split}
+\end{equation}
+where $c_u$ is a flux limiter function taking values between 0 and 1. 
+There exist many ways to define $c_u$, each correcponding to a different 
+total variance decreasing scheme. The one chosen in \NEMO is described in 
+\citet{Zalesak1979}. $c_u$ only departs from $1$ when the advective term 
+produces a local extremum in the tracer field. The resulting scheme is quite 
+expensive but \emph{positive}. It can be used on both active and passive tracers. 
+This scheme is tested and compared with MUSCL and the MPDATA scheme in 
+\citet{Levy2001}; note that in this paper it is referred to as "FCT" (Flux corrected 
+transport) rather than TVD. The TVD scheme is computed in the \mdl{traadv\_tvd} module.
+
+For stability reasons (see \S\ref{DOM_nxt}), in (\ref{Eq_tra_adv_tvd}) 
+$\tau _u^{cen2}$ is evaluated using the \textit{now} tracer while $\tau _u^{ups}$ 
+is evaluated using the \textit{before} tracer. In other words, the advective part of 
+the scheme is time stepped with a leap-frog scheme while a forward scheme is 
+used for the diffusive part. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        MUSCL scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection[MUSCL scheme  (\np{ln\_traadv\_muscl})]
+	{Monotone Upstream Scheme for Conservative Laws (MUSCL) (\np{ln\_traadv\_muscl}=T)}
+\label{TRA_adv_muscl}
+
+The Monotone Upstream Scheme for Conservative Laws (MUSCL) has been 
+implemented by \citet{Levy2001}. In its formulation, the tracer at velocity points 
+is evaluated assuming a linear tracer variation between two $T$-points 
+(Fig.\ref{Fig_adv_scheme}). For example, in the $i$-direction :
+\begin{equation} \label{Eq_tra_adv_muscl}
+   \tau _u^{mus} = \left\{      \begin{aligned}
+         &\tau _i  &+ \frac{1}{2} \;\left( 1-\frac{u_{i+1/2} \;\Delta t}{e_{1u}} \right)
+         &\ \widetilde{\partial _i \tau}  & \quad \text{if }\;u_{i+1/2} \geqslant 0      \\
+         &\tau _{i+1/2} &+\frac{1}{2}\;\left( 1+\frac{u_{i+1/2} \;\Delta t}{e_{1u} } \right)
+         &\ \widetilde{\partial_{i+1/2} \tau } & \text{if }\;u_{i+1/2} <0
+   \end{aligned}    \right.
+\end{equation}
+where $\widetilde{\partial _i \tau}$ is the slope of the tracer on which a limitation 
+is imposed to ensure the \textit{positive} character of the scheme.
+
+The time stepping is performed using a forward scheme, that is the \textit{before} 
+tracer field is used to evaluate $\tau _u^{mus}$.
+
+For an ocean grid point adjacent to land and where the ocean velocity is 
+directed toward land, two choices are available: an upstream flux 
+(\np{ln\_traadv\_muscl}=.true.) or a second order flux 
+(\np{ln\_traadv\_muscl2}=.true.). Note that the latter choice does not ensure 
+the \textit{positive} character of the scheme. Only the former can be used 
+on both active and passive tracers. The two MUSCL schemes are computed 
+in the \mdl{traadv\_tvd} and \mdl{traadv\_tvd2} modules.
+
+% -------------------------------------------------------------------------------------------------------------
+%        UBS scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Upstream-Biased Scheme (UBS) (\np{ln\_traadv\_ubs})]
+			{Upstream-Biased Scheme (UBS) (\np{ln\_traadv\_ubs}=.true.)}
+\label{TRA_adv_ubs}
+
+The UBS advection scheme is an upstream-biased third order scheme based on 
+an upstream-biased parabolic interpolation. It is also known as the Cell 
+Averaged QUICK scheme (Quadratic Upstream Interpolation for Convective 
+Kinematics). For example, in the $i$-direction :
+\begin{equation} \label{Eq_tra_adv_ubs}
+   \tau _u^{ubs} =\overline T ^{i+1/2}-\;\frac{1}{6} \left\{      
+   \begin{aligned}
+         &\tau"_i        	& \quad \text{if }\ u_{i+1/2} \geqslant 0      \\
+         &\tau"_{i+1}	& \quad \text{if }\ u_{i+1/2}       <       0
+   \end{aligned}    \right.
+\end{equation}
+where $\tau "_i =\delta _i \left[ {\delta _{i+1/2} \left[ \tau \right]} \right]$.
+
+This results in a dissipatively dominant (i.e. hyper-diffusive) truncation 
+error \citep{Sacha2005}. The overall performance of the advection 
+scheme is similar to that reported in \cite{Farrow1995}. 
+It is a relatively good compromise between accuracy and smoothness. 
+It is not a \emph{positive} scheme, meaning that false extrema are permitted, 
+but the amplitude of such are significantly reduced over the centred second 
+order method. Nevertheless it is not recommended that it should be applied 
+to a passive tracer that requires positivity. 
+
+The intrinsic diffusion of UBS makes its use risky in the vertical direction 
+where the control of artificial diapycnal fluxes is of paramount importance. 
+Therefore the vertical flux is evaluated using the TVD scheme when 
+\np{ln\_traadv\_ubs}=.true..
+
+For stability reasons  (see \S\ref{DOM_nxt}), in \eqref{Eq_tra_adv_ubs}, 
+the first term (which corresponds to a second order centred scheme) 
+is evaluated using the \textit{now} tracer (centred in time) while the 
+second term (which is the diffusive part of the scheme), is 
+evaluated using the \textit{before} tracer (forward in time). 
+This choice is discussed by \citet{Webb1998} in the context of the 
+QUICK advection scheme. UBS and QUICK schemes only differ 
+by one coefficient. Replacing 1/6 with 1/8 in \eqref{Eq_tra_adv_ubs} 
+leads to the QUICK advection scheme \citep{Webb1998}. 
+This option is not available through a namelist parameter, since the 
+1/6 coefficient is hard coded. Nevertheless it is quite easy to make the 
+substitution in the \mdl{traadv\_ubs} module and obtain a QUICK scheme.
+
+Note that :
+
+(1) When a high vertical resolution $O(1m)$ is used, the model stability can 
+be controlled by vertical advection (not vertical diffusion which is usually 
+solved using an implicit scheme). Computer time can be saved by using a 
+time-splitting technique on vertical advection. Such a technique has been 
+implemented and validated in ORCA05 with 301 levels. It is not available 
+in the current reference version. 
+
+(2) In a forthcoming release four options will be available for the vertical 
+component used in the UBS scheme. $\tau _w^{ubs}$ will be evaluated 
+using either \textit{(a)} a centred $2^{nd}$ order scheme, or  \textit{(b)} 
+a TVD scheme, or  \textit{(c)} an interpolation based on conservative 
+parabolic splines following the \citet{Sacha2005} implementation of UBS 
+in ROMS, or  \textit{(d)} a UBS. The $3^{rd}$ case has dispersion properties 
+similar to an eighth-order accurate conventional scheme.
+
+(3) It is straightforward to rewrite \eqref{Eq_tra_adv_ubs} as follows:
+\begin{equation} \label{Eq_traadv_ubs2}
+\tau _u^{ubs} = \tau _u^{cen4} + \frac{1}{12} \left\{	 
+   \begin{aligned}
+	& + \tau"_i			& \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
+	&  - \tau"_{i+1}		& \quad \text{if }\ u_{i+1/2}       <       0
+   \end{aligned}    \right.
+\end{equation}
+or equivalently 
+\begin{equation} \label{Eq_traadv_ubs2b}
+u_{i+1/2} \ \tau _u^{ubs} 
+=u_{i+1/2} \ \overline{ T - \frac{1}{6}\,\delta _i\left[ \delta_{i+1/2}[T] \,\right] }^{\,i+1/2}
+- \frac{1}{2} |u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+\end{equation}
+
+\eqref{Eq_traadv_ubs2} has several advantages. Firstly, it clearly reveals 
+that the UBS scheme is based on the fourth order scheme to which an 
+upstream-biased diffusion term is added. Secondly, this emphasises that the 
+$4^{th}$ order part (as well as the $2^{nd}$ order part as stated above) has 
+to be evaluated at the \emph{now} time step using \eqref{Eq_tra_adv_ubs}. 
+Thirdly, the diffusion term is in fact a biharmonic operator with an eddy 
+coefficient which is simply proportional to the velocity:
+ $A_u^{lm}= - \frac{1}{12}\,{e_{1u}}^3\,|u|$. Note that NEMO v2.3 still uses 
+ \eqref{Eq_tra_adv_ubs}, not \eqref{Eq_traadv_ubs2}. This should be 
+ changed in forthcoming release.
+ %%%
+ \gmcomment{the change in UBS scheme has to be done}
+ %%%
+
+% -------------------------------------------------------------------------------------------------------------
+%        QCK scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [QUICKEST scheme (QCK) (\np{ln\_traadv\_qck})]
+			{QUICKEST scheme (QCK) (\np{ln\_traadv\_qck}=.true.)}
+\label{TRA_adv_qck}
+
+The Quadratic Upstream Interpolation for Convective Kinematics with 
+Estimated Streaming Terms (QUICKEST) scheme proposed by \citet{Leonard1979} 
+is the third order Godunov scheme. It is associated with the ULTIMATE QUICKEST 
+limiter \citep{Leonard1991}. It has been implemented in NEMO by G. Reffray 
+(MERCATOR-ocean) and can be found in the \mdl{traadv\_qck} module.
+The resulting scheme is quite expensive but \emph{positive}. 
+It can be used on both active and passive tracers. 
+Nevertheless, the intrinsic diffusion of QCK makes its use risky in the vertical 
+direction where the control of artificial diapycnal fluxes is of paramount importance. 
+Therefore the vertical flux is evaluated using the CEN2 scheme. 
+This no more ensure the positivity of the scheme. The use of TVD in the vertical 
+direction as for the UBS case should be implemented to maintain the property.
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        PPM scheme  
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Piecewise Parabolic Method (PPM) (\np{ln\_traadv\_ppm})]
+			{Piecewise Parabolic Method (PPM) (\np{ln\_traadv\_ppm}=.true.)}
+\label{TRA_adv_ppm}
+
+The Piecewise Parabolic Method (PPM) proposed by Colella and Woodward (1984) 
+is based on a quadradic piecewise rebuilding. Like the QCK scheme, it is associated 
+with the ULTIMATE QUICKEST limiter \citep{Leonard1991}. It has been implemented 
+in \NEMO by G. Reffray (MERCATOR-ocean) but is not yet offered in the reference 
+version 3.0.
+
+% ================================================================
+% Tracer Lateral Diffusion
+% ================================================================
+\section  [Tracer Lateral Diffusion (\textit{traldf})]
+		{Tracer Lateral Diffusion (\mdl{traldf})}
+\label{TRA_ldf}
+%-----------------------------------------nam_traldf------------------------------------------------------
+\namdisplay{nam_traldf}
+%-------------------------------------------------------------------------------------------------------------
+ 
+The options available for lateral diffusion are a laplacian (rotated or not) 
+or a biharmonic operator, the latter being more scale-selective (more 
+diffusive at small scales). The specification of eddy diffusivity 
+coefficients (either constant or variable in space and time) as well as the 
+computation of the slope along which the operators act, are performed in the 
+\mdl{ldftra} and \mdl{ldfslp} modules, respectively. This is described in Chap.~\ref{LDF}. 
+The lateral diffusion of tracers is evaluated using a forward scheme, 
+$i.e.$ the tracers appearing in its expression are the \textit{before} tracers in time, 
+except for the pure vertical component that appears when a rotation tensor 
+is used. This latter term is solved implicitly together with the 
+vertical diffusion term (see \S\ref{DOM_nxt}).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Iso-level laplacian operator
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Iso-level laplacian operator (lap) (\np{ln\_traldf\_lap})]
+			{Iso-level laplacian operator (lap) (\np{ln\_traldf\_lap}=.true.) }
+\label{TRA_ldf_lap}
+
+A laplacian diffusion operator ($i.e.$ a harmonic operator) acting along the model 
+surfaces is given by: 
+\begin{equation} \label{Eq_tra_ldf_lap}
+D_T^{lT} =\frac{1}{b_T} \left( \;
+   \delta _{i}\left[ A_u^{lT} \; \frac{e_{2u}\,e_{3u}}{e_{1u}} \;\delta _{i+1/2} [T] \right] 
++ \delta _{j}\left[ A_v^{lT} \;  \frac{e_{1v}\,e_{3v}}{e_{2v}} \;\delta _{j+1/2} [T] \right]  \;\right)
+\end{equation}
+where  $b_T= e_{1T}\,e_{2T}\,e_{3T}$  is the volume of $T$-cells. 
+It can be found in the \mdl{traadv\_lap} module.
+
+This lateral operator is computed in \mdl{traldf\_lap}. It is a \emph{horizontal} 
+operator ($i.e.$ acting along geopotential surfaces) in the $z$-coordinate with 
+or without partial step, but is simply an iso-level operator in the $s$-coordinate. 
+It is thus used when, in addition to \np{ln\_traldf\_lap}=.true., we have 
+\np{ln\_traldf\_level}=.true., or \np{ln\_traldf\_hor}=\np{ln\_zco}=.true.. 
+In both cases, it significantly contributes to diapycnal mixing. 
+It is therefore not recommended.
+
+Note that 
+(a) In pure $z$-coordinate (\key{zco} is defined), $e_{3u}=e_{3v}=e_{3T}$, 
+so that the vertical scale factors disappear from (\ref{Eq_tra_ldf_lap}) ; 
+(b) In partial step $z$-coordinate (\np{ln\_zps}=.true.), tracers in horizontally 
+adjacent cells are located at different depths in the vicinity of the bottom. 
+In this case, horizontal derivatives in (\ref{Eq_tra_ldf_lap}) at the bottom level 
+require a specific treatment. They are calculated in the \mdl{zpshde} module, 
+described in \S\ref{TRA_zpshde}.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Rotated laplacian operator
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Rotated laplacian operator (iso) (\np{ln\_traldf\_lap})]
+			{Rotated laplacian operator (iso) (\np{ln\_traldf\_lap}=.true.)}
+\label{TRA_ldf_iso}
+
+The general form of the second order lateral tracer subgrid scale physics 
+(\ref{Eq_PE_zdf}) takes the following semi-discrete space form in $z$- and 
+$s$-coordinates:
+\begin{equation} \label{Eq_tra_ldf_iso}
+\begin{split}
+ D_T^{lT} = \frac{1}{b_T}   & \left\{   \,\;\delta_i \left[   A_u^{lT}  \left( 
+	  \frac{e_{2u}\;e_{3u}}{e_{1u}} \,\delta_{i+1/2}[T]
+	- e_{2u}\;r_{1u} \,\overline{\overline{ \delta_{k+1/2}[T] }}^{\,i+1/2,k}
+                                                     \right)   \right]   \right.    \\ 
+&             +\delta_j \left[ A_v^{lT} \left( 
+          \frac{e_{1v}\,e_{3v}}{e_{2v}}  \,\delta_{j+1/2} [T] 
+        - e_{1v}\,r_{2v} \,\overline{\overline{ \delta_{k+1/2} [T] }}^{\,j+1/2,k} 
+                                                    \right)   \right]                 \\ 
+& +\delta_k \left[ A_w^{lT} \left( 
+       -\;e_{2w}\,r_{1w} \,\overline{\overline{ \delta_{i+1/2} [T] }}^{\,i,k+1/2}
+                                                    \right.   \right.                 \\ 
+& \qquad \qquad \quad 
+        - e_{1w}\,r_{2w} \,\overline{\overline{ \delta_{j+1/2} [T] }}^{\,j,k+1/2}     \\
+& \left. {\left. {   \qquad \qquad \ \ \ \left. {
+        +\;\frac{e_{1w}\,e_{2w}}{e_{3w}} \,\left( r_{1w}^2 + r_{2w}^2 \right)
+           \,\delta_{k+1/2} [T] } \right) } \right] \quad } \right\} 
+ \end{split}
+ \end{equation}
+where $b_T= e_{1T}\,e_{2T}\,e_{3T}$  is the volume of $T$-cells, 
+$r_1$ and $r_2$ are the slopes between the surface of computation 
+($z$- or $s$-surfaces) and the surface along which the diffusion operator 
+acts ($i.e.$ horizontal or iso-neutral surfaces).  It is thus used when, 
+in addition to \np{ln\_traldf\_lap}= .true., we have \np{ln\_traldf\_iso}=.true., 
+or both \np{ln\_traldf\_hor}=.true. and \np{ln\_zco}=.true.. The way these 
+slopes are evaluated is given in \S\ref{LDF_slp}. At the surface, bottom 
+and lateral boundaries, the turbulent fluxes of heat and salt are set to zero 
+using the mask technique (see \S\ref{LBC_coast}). 
+
+The operator in \eqref{Eq_tra_ldf_iso} involves both lateral and vertical 
+derivatives. For numerical stability, the vertical second derivative must 
+be solved using the same implicit time scheme as that used in the vertical 
+physics (see \S\ref{TRA_zdf}). For computer efficiency reasons, this term 
+is not computed in the \mdl{traldf\_iso} module, but in the \mdl{trazdf} module 
+where, if iso-neutral mixing is used, the vertical mixing coefficient is simply 
+increased by $\frac{e_{1w}\,e_{2w} }{e_{3w} }\ \left( {r_{1w} ^2+r_{2w} ^2} \right)$. 
+
+This formulation conserves the tracer but does not ensure the decrease 
+of the tracer variance. Nevertheless the treatment performed on the slopes 
+(see \S\ref{LDF}) allows the model to run safely without any additional 
+background horizontal diffusion \citep{Guily2001}. An alternative scheme 
+developed by \cite{Griffies1998} which preserves both tracer and its variance 
+is currently been tested in \NEMO. It should be available in a forthcoming
+release.
+
+Note that in the partial step $z$-coordinate (\np{ln\_zps}=.true.), the horizontal 
+derivatives at the bottom level in \eqref{Eq_tra_ldf_iso} require a specific 
+treatment. They are calculated in module zpshde, described in \S\ref{TRA_zpshde}.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Iso-level bilaplacian operator
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Iso-level bilaplacian operator (bilap) (\np{ln\_traldf\_bilap})]
+			{Iso-level bilaplacian operator (bilap) (\np{ln\_traldf\_bilap}=.true.)}
+\label{TRA_ldf_bilap}
+
+The lateral fourth order bilaplacian operator on tracers is obtained by 
+applying (\ref{Eq_tra_ldf_lap}) twice. It requires an additional assumption 
+on boundary conditions: the first and third derivative terms normal to the 
+coast are set to zero. It is used when, in addition to \np{ln\_traldf\_bilap}=.true., 
+we have \np{ln\_traldf\_level}=.true., or both \np{ln\_traldf\_hor}=.true. and 
+\np{ln\_zco}=.false.. In both cases, it can contribute diapycnal mixing, 
+although less than in the laplacian case. It is therefore not recommended.
+
+Note that in the code, the bilaplacian routine does not call the laplacian 
+routine twice but is rather a separate routine that can be found in the
+\mdl{traldf\_bilap} module. This is due to the fact that we introduce the 
+eddy diffusivity coefficient, A, in the operator as: 
+$\nabla \cdot \nabla \left( {A\nabla \cdot \nabla T} \right)$, 
+instead of 
+$-\nabla \cdot a\nabla \left( {\nabla \cdot a\nabla T} \right)$ 
+where $a=\sqrt{|A|}$ and $A<0$. This was a mistake: both formulations 
+ensure the total variance decrease, but the former requires a larger 
+number of code-lines. It will be corrected in a forthcoming release.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Rotated bilaplacian operator
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Rotated bilaplacian operator (bilapg) (\np{ln\_traldf\_bilap})]
+			{Rotated bilaplacian operator (bilapg) (\np{ln\_traldf\_bilap}=.true.)}
+\label{TRA_ldf_bilapg}
+
+The lateral fourth order operator formulation on tracers is obtained by 
+applying (\ref{Eq_tra_ldf_iso}) twice. It requires an additional assumption 
+on boundary conditions: first and third derivative terms normal to the 
+coast, the bottom and the surface are set to zero. It can be found in the
+\mdl{traldf\_bilapg}.
+
+It is used when, in addition to \np{ln\_traldf\_bilap}=.true., we have 
+\np{ln\_traldf\_iso}= .true, or both \np{ln\_traldf\_hor}=.true. and \np{ln\_zco}=.true.. 
+Nevertheless, this rotated bilaplacian operator has never been seriously 
+tested. No warranties that it is neither free of bugs or correctly formulated. 
+Moreover, the stability range of such an operator will be probably quite 
+narrow, requiring a significantly smaller time-step than the one used on 
+unrotated operator.
+
+% ================================================================
+% Tracer Vertical Diffusion
+% ================================================================
+\section  [Tracer Vertical Diffusion (\textit{trazdf})]
+		{Tracer Vertical Diffusion (\mdl{trazdf})}
+\label{TRA_zdf}
+%--------------------------------------------namzdf---------------------------------------------------------
+\namdisplay{namzdf}
+%--------------------------------------------------------------------------------------------------------------
+
+The formulation of the vertical subgrid scale tracer physics is the same 
+for all the vertical coordinates, and is based on a laplacian operator. 
+The vertical diffusion operator given by (\ref{Eq_PE_zdf}) takes the 
+following semi-discrete space form:
+\begin{equation} \label{Eq_tra_zdf}
+\begin{split}
+D^{vT}_T &= \frac{1}{e_{3T}} \; \delta_k \left[ \;\frac{A^{vT}_w}{e_{3w}}  \delta_{k+1/2}[T] \;\right] 
+\\
+D^{vS}_T &= \frac{1}{e_{3T}} \; \delta_k \left[ \;\frac{A^{vS}_w}{e_{3w}}  \delta_{k+1/2}[S] \;\right] 
+\end{split}
+\end{equation}
+where $A_w^{vT}$ and $A_w^{vS}$ are the vertical eddy diffusivity 
+coefficients on temperature and salinity, respectively. Generally, 
+$A_w^{vT}=A_w^{vS}$ except when double diffusive mixing is 
+parameterised ($i.e.$ \key{zdfddm} is defined). The way these coefficients 
+are evaluated is given in \S\ref{ZDF} (ZDF). Furthermore, when 
+iso-neutral mixing is used, both mixing coefficients are increased 
+by $\frac{e_{1w}\,e_{2w} }{e_{3w} }\ \left( {r_{1w} ^2+r_{2w} ^2} \right)$ 
+to account for the vertical second derivative of \eqref{Eq_tra_ldf_iso}. 
+
+At the surface and bottom boundaries, the turbulent fluxes of 
+heat and salt must be specified. At the surface they are prescribed 
+from the surface forcing and added in a dedicated routine (see \S\ref{TRA_sbc}), 
+whilst at the bottom they are set to zero for heat and salt unless 
+a geothermal flux forcing is prescribed as a bottom boundary 
+condition (see \S\ref{TRA_bbc}). 
+
+The large eddy coefficient found in the mixed layer together with high 
+vertical resolution implies that in the case of explicit time stepping 
+(\np{ln\_zdfexp}=.true.) there would be too restrictive a constraint on 
+the time step. Therefore, the default implicit time stepping is preferred 
+for the vertical diffusion since it overcomes the stability constraint. 
+A forward time differencing scheme (\np{ln\_zdfexp}=.true.) using a time 
+splitting technique (\np{n\_zdfexp} $> 1$) is provided as an alternative. 
+Namelist variables \np{ln\_zdfexp} and \np{n\_zdfexp} apply to both 
+tracers and dynamics. 
+
+% ================================================================
+% External Forcing
+% ================================================================
+\section{External Forcing}
+\label{TRA_sbc_qsr_bbc}
+
+% -------------------------------------------------------------------------------------------------------------
+%        surface boundary condition
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Surface boundary condition (\textit{trasbc})]
+			{Surface boundary condition (\mdl{trasbc})}
+\label{TRA_sbc}
+
+The surface boundary condition for tracers is implemented in a separate 
+module (\mdl{trasbc}) instead of entering as a boundary condition on the vertical 
+diffusion operator (as in the case of momentum). This has been found to 
+enhance readability of the code. The two formulations are completely 
+equivalent; the forcing terms in trasbc are the surface fluxes divided by 
+the thickness of the top model layer. Following \citet{Roullet2000} the 
+forcing on an ocean tracer, $c$, can be split into two parts: $F_{ext}$, the 
+flux of tracer crossing the sea surface and not linked with the water 
+exchange with the atmosphere, $F_{wf}^d$, and $F_{wf}^i$ the forcing 
+on the tracer concentration associated with this water exchange. 
+The latter forcing has two components: a direct effect of change 
+in concentration associated with the tracer carried by the water flux, 
+and an indirect concentration/dilution effect :
+\begin{equation*}
+\begin{split}
+ F^C &= F_{ext} + F_{wf}^d                                          +F_{wf}^i  	\\
+        &= F_{ext} - \left( c_E \, E - c_p \,P - c_R \,R \right) +c\left( E-P-R \right)
+\end{split}
+\end{equation*} 
+
+\gmcomment{add here a description of the variable names used in the above equation}
+
+Two cases must be distinguished, the nonlinear free surface case 
+(\key{vvl} is defined) and the linear free surface case. The first case 
+is simpler, because the indirect concentration/dilution effect is naturally 
+taken into account by letting the vertical scale factors vary in time. 
+The salinity of water exchanged at the surface is assumed to be zero, 
+so there is no salt flux at the free surface, except in the presence of sea ice. 
+The heat flux at the free surface is the sum of $F_{ext}$, the direct 
+heating/cooling (by the total non-penetrative heat flux) and $F_{wf}^e$ 
+the heat carried by the water exchanged through the surface (evaporation, 
+precipitation, runoff). The temperature of precipitation is not well known. 
+In the model we assume that this water has the same temperature as 
+the sea surface temperature. The resulting forcing terms for temperature 
+T and salinity S are: 
+\begin{equation} \label{Eq_tra_forcing}
+\begin{aligned}
+ &F^T =\frac{Q_{ns} }{\rho _o \;C_p \,e_{3T} }-\frac{\text{EMP}\;\left. T 
+\right|_{k=1} }{e_{3T} }  & \\ 
+\\
+& F^S =\frac{\text{EMP}_S\;\left. S \right|_{k=1} }{e_{3T} }   &
+ \end{aligned}
+\end{equation} 
+where EMP is the freshwater budget (evaporation minus precipitation 
+minus river runoff) which forces the ocean volume, $Q_{ns}$ is the 
+non-penetrative part of the net surface heat flux (difference between 
+the total surface heat flux and the fraction of the short wave flux that 
+penetrates into the water column), the product EMP$_S\;.\left. S \right|_{k=1}$ 
+is  the ice-ocean salt flux, and $\left. S\right|_{k=1}$ is the sea surface 
+salinity (\textit{SSS}). The total salt content is conserved in this formulation 
+(except for the effect of the Asselin filter).
+
+%AMT note: the ice-ocean flux had been forgotten in the first release of the key_vvl option, has this been corrected in the code?     ===> gm :  NO to be added at NOCS 
+
+In the second case (linear free surface), the vertical scale factors are 
+fixed in time so that the concentration/dilution effect must be added in 
+the \mdl{trasbc} module. Because of the hypothesis made for the 
+temperature of precipitation and runoffs, $F_{wf}^e +F_{wf}^i =0$ 
+for temperature. The resulting forcing term for temperature is: 
+\begin{equation} \label{Eq_tra_forcing_q}
+F^T=\frac{Q_{ns} }{\rho _o \;C_p \,e_{3T} }
+\end{equation} 
+
+The salinity forcing is still given by \eqref{Eq_tra_forcing} but the 
+definition of EMP$_S$ is different: it is the total surface freshwater 
+budget (evaporation minus precipitation minus river runoff plus 
+the rate of change of the sea ice thickness). The total salt content 
+is not exactly conserved (\citet{Roullet2000}. 
+See also \S\ref{PE_free_surface}).
+
+In the case of the rigid lid approximation, the surface salinity forcing $F^s$ 
+is also expressed by \eqref{Eq_tra_forcing}, but now the global integral of 
+the product of EMP and S, is not compensated by the advection of fluid 
+through the top level: this is because in the rigid lid case \textit{w(k=1) = 0} 
+(in contrast to the linear free surface case). As a result, even if the budget 
+of \textit{EMP} is zero on average over the whole ocean domain, the 
+associated salt flux is not, since sea-surface salinity and \textit{EMP} are 
+intrinsically correlated (high \textit{SSS} are found where evaporation is 
+strong whilst low \textit{SSS} is usually associated with high precipitation 
+or river runoff).
+
+The $Q_{ns} $ and \textit{EMP} fields are defined and updated in the 
+\mdl{sbcmod} module (see \S\ref{SBC}).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Solar Radiation Penetration 
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Solar Radiation Penetration (\textit{traqsr})]
+			{Solar Radiation Penetration (\mdl{traqsr})}
+\label{TRA_qsr}
+%--------------------------------------------namqsr--------------------------------------------------------
+\namdisplay{namqsr}
+%--------------------------------------------------------------------------------------------------------------
+
+When the penetrative solar radiation option is used (\np{ln\_flxqsr}=.true.), 
+the solar radiation penetrates the top few meters of the ocean, otherwise 
+all the heat flux is absorbed in the first ocean level (\np{ln\_flxqsr}=.false.). 
+Thus, in the former case a term is added to the time evolution equation of 
+temperature \eqref{Eq_PE_tra_T} whilst the surface boundary condition is 
+modified to take into account only the non-penetrative part of the surface 
+heat flux:
+\begin{equation} \label{Eq_PE_qsr}
+\begin{split}
+\frac{\partial T}{\partial t} &= {\ldots} + \frac{1}{\rho_o\, C_p \,e_3} \; \frac{\partial I}{\partial k}	\\
+Q_{ns} &= Q_\text{Total} - Q_{sr}
+\end{split}
+\end{equation}
+
+where $I$ is the downward irradiance. The additional term in \eqref{Eq_PE_qsr} 
+is discretized as follows:
+\begin{equation} \label{Eq_tra_qsr}
+\frac{1}{\rho_o\, C_p \,e_3} \; \frac{\partial I}{\partial k} \equiv \frac{1}{\rho_o\, C_p\, e_{3T}} \delta_k \left[ I_w \right]
+\end{equation}
+
+A formulation involving two extinction coefficients is assumed for the 
+downward irradiance $I$ \citep{Paulson1977}:
+\begin{equation} \label{Eq_traqsr_iradiance}
+I(z) = Q_{sr} \left[Re^{-z / \xi_1} + \left( 1-R\right) e^{-z / \xi_2} \right]
+\end{equation}
+where $Q_{sr}$ is the penetrative part of the surface heat flux, 
+$\xi_1$ and $\xi_2$ are two extinction length scales and $R$ 
+determines the relative contribution of the two terms. 
+The default values used correspond to a Type I water in Jerlov's [1968] 
+%
+\gmcomment : Jerlov reference to be added
+%
+classification: $\xi_1 = 0.35~m$, $\xi_2 = 23~m$ and $R = 0.58$ 
+(corresponding to \np{xsi1}, \np{xsi2} and \np{rabs} namelist parameters, 
+respectively). $I$ is masked (no flux through the ocean bottom), 
+so all the solar radiation that reaches the last ocean level is absorbed 
+in that level. The trend in \eqref{Eq_tra_qsr} associated with the 
+penetration of the solar radiation is added to the temperature trend, 
+and the surface heat flux is modified in routine \mdl{traqsr}. 
+Note that in the $z$-coordinate, the depth of $T-$levels depends 
+on the single variable $k$. A one dimensional array of the coefficients 
+$gdsr(k) = Re^{-z_w (k)/\xi_1} + (1-R)e^{-z_w (k)/\xi_2}$ can then 
+be computed once and saved in memory. Moreover \textit{nksr}, 
+the level at which $gdrs$ becomes negligible (less than the 
+computer precision) is computed once, and the trend associated 
+with the penetration of the solar radiation is only added until that level. 
+Finally, note that when the ocean is shallow (< 200~m), part of the 
+solar radiation can reach the ocean floor. In this case, we have 
+chosen that all remaining radiation is absorbed in the last ocean 
+level ($i.e.$ $I_w$ is masked). 
+
+When coupling with a biological model (for example PISCES or LOBSTER), 
+it is possible to calculate the light attenuation using information from 
+the biology model. Without biological model, it is still possible to introduce 
+a horizontal variation of the light attenuation by using the observed ocean 
+surface color. At the time of writing, the latter has not been implemented
+ in the reference version.
+%
+\gmcomment{  {yellow}{case 4 bands and bio-coupling to add !!!}  }
+%
+
+% -------------------------------------------------------------------------------------------------------------
+%        Bottom Boundary Condition
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Bottom Boundary Condition (\textit{trabbc} - \key{bbc})]
+			{Bottom Boundary Condition (\mdl{trabbc} - \key{bbc})}
+\label{TRA_bbc}
+%--------------------------------------------nambbc--------------------------------------------------------
+\namdisplay{nambbc}
+%--------------------------------------------------------------------------------------------------------------
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_geothermal}  \begin{center}
+\includegraphics[width=1.0\textwidth]{./TexFiles/Figures/Fig_TRA_geoth.pdf}
+\caption{Geothermal Heat flux (in $mW.m^{-2}$) used by \cite{Emile-Geay_Madec_OSD08}.
+It is inferred from the age of the sea floor and the formulae of \citet{Stein1992}.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+Usually it is assumed that there is no exchange of heat or salt through 
+the ocean bottom, $i.e.$ a no flux boundary condition is applied on active 
+tracers at the bottom. This is the default option in \NEMO, and it is 
+implemented using the masking technique. However, there is a 
+non-zero heat flux across the seafloor that is associated with solid 
+earth cooling. This flux is weak compared to surface fluxes (a mean 
+global value of $\sim0.1\;W/m^2$ \citep{Stein1992}), but it is 
+systematically positive and acts on the densest water masses. 
+Taking this flux into account in a global ocean model increases
+the deepest overturning cell ($i.e.$ the one associated with the Antarctic 
+Bottom Water) by a few Sverdrups  \citep{Emile-Geay_Madec_OSD08}. 
+
+The presence or not of geothermal heating is controlled by the namelist 
+parameter  \np{ngeo\_flux}. If this parameter is set to 1, a constant 
+geothermal heating is introduced whose value is given by the 
+\np{ngeo\_flux\_const}, which is also a namelist parameter. If it is set to 2, 
+a spatially varying geothermal heat flux is introduced which is provided 
+in the geothermal\_heating.nc NetCDF file (Fig.\ref{Fig_geothermal}).
+
+% ================================================================
+% Bottom Boundary Layer
+% ================================================================
+\section  [Bottom Boundary Layer (\textit{trabbl}, \textit{trabbl\_adv} )]
+		{Bottom Boundary Layer (\mdl{trabbl}, \mdl{trabbl\_adv})}
+\label{TRA_bbl}
+%--------------------------------------------nambbl---------------------------------------------------------
+\namdisplay{nambbl}
+%--------------------------------------------------------------------------------------------------------------
+
+In a $z$-coordinate configuration, the bottom topography is represented by a 
+series of discrete steps. This is not adequate to represent gravity driven 
+downslope flows. Such flows arise downstream of sills such as the Strait of 
+Gibraltar, Bab El Mandeb, or Denmark Strait, where dense water formed in 
+marginal seas flows into a basin filled with less dense water. The amount of 
+entrainment that occurs in these gravity plumes is critical in determining the 
+density and volume flux of the densest waters of the ocean, such as 
+Antarctic Bottom Water, or North Atlantic Deep Water. $z$-coordinate 
+models tend to overestimate the entrainment, because the gravity flow is 
+mixed down vertically by convection as it goes ``downstairs'' following the 
+step topography, sometimes over a thickness much larger than the thickness 
+of the observed gravity plume. A similar problem occurs in the $s$-coordinate when 
+the thickness of the bottom level varies in large proportions downstream of 
+a sill \citep{Willebrand2001}, and the thickness of the plume is not resolved. 
+
+The idea of the bottom boundary layer (BBL) parameterisation first introduced by 
+\citet{BeckDos1998} is to allow a direct communication between 
+two adjacent bottom cells at different levels, whenever the densest water is 
+located above the less dense water. The communication can be by a diffusive 
+(diffusive BBL), advective fluxes (advective BBL), or both. In the current 
+implementation of the BBL, only the tracers are modified, not the velocities. 
+Furthermore, it only connects ocean bottom cells, and therefore does not include 
+the improvment proposed by \citet{Campin_Goosse_Tel99}.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Diffusive BBL
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Diffusive Bottom Boundary layer (\key{bbl\_diff})}
+\label{TRA_bbl_diff}
+
+When applying sigma-diffusion (\key{trabbl} is defined), the diffusive flux between 
+two adjacent cells living at the ocean bottom is given by 
+\begin{equation} \label{Eq_tra_bbl_diff}
+{\rm {\bf F}}_\sigma=A_l^\sigma \; \nabla_\sigma T
+\end{equation} 
+with $\nabla_\sigma$ the lateral gradient operator taken between bottom cells, 
+and  $A_l^\sigma $ the lateral diffusivity in the BBL. Following \citet{BeckDos1998}, 
+the latter is prescribed with a spatial dependence, $e.g.$ in the conditional form
+\begin{equation} \label{Eq_tra_bbl_coef}
+A_l^\sigma (i,j,t)=\left\{ {\begin{array}{l}
+ A_{bbl}  \quad \quad   \mbox{if}  \quad   \nabla_\sigma \rho  \cdot  \nabla H<0 \\ 
+ \\
+ 0\quad \quad \;\,\mbox{otherwise} \\ 
+ \end{array}} \right.
+\end{equation} 
+where $A_{bbl}$ is the BBL diffusivity coefficient, given by the namelist 
+parameter \np{atrbbl}. $A_{bbl}$ is usually set to a value much larger 
+than the one used on lateral mixing in open ocean. 
+Note that in practice, \eqref{Eq_tra_bbl_coef} constraint is applied 
+separately in the two horizontal directions, and the density gradient in 
+\eqref{Eq_tra_bbl_coef} is evaluated at $\overline{H}^i$ ($\overline{H}^j$) 
+using the along bottom mean temperature and salinity. 
+
+% -------------------------------------------------------------------------------------------------------------
+%        Advective BBL
+% -------------------------------------------------------------------------------------------------------------
+\subsection   {Advective Bottom Boundary Layer (\key{bbl\_adv})}
+\label{TRA_bbl_adv}
+
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_bbl}  \begin{center}
+\includegraphics[width=0.8\textwidth]{./TexFiles/Figures/Fig_BBL_adv.pdf}
+\caption{Advective Bottom Boundary Layer.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+%%%gmcomment   :  this section has to be really written
+
+The advective BBL is in fact not only an advective one but include a diffusive 
+component as we chose an upstream scheme to perform the advection within 
+the BBL. The associated diffusion only act in the stream direction and is 
+proportional to the velocity.
+
+When applying sigma-advection (\key{trabbl\_adv} defined), the advective 
+flux between two adjacent cells living at the ocean bottom is given by 
+\begin{equation} \label{Eq_tra_bbl_fadv}
+{\rm {\bf F}}_\sigma={\rm {\bf U}}_h^\sigma \; \overline{T}^\sigma
+\end{equation} 
+with $\nabla_\sigma$ the lateral gradient operator taken between bottom cells, 
+and  $A_l^\sigma$ the lateral diffusivity in the BBL. Following \citet{BeckDos1998}, 
+the latter is prescribed with a spatial dependence, $e.g.$ in the conditional form
+\begin{equation} \label{Eq_tra_bbl_Aadv}
+A_l^\sigma (i,j,t)=\left\{ {\begin{array}{l}
+ A_{bbl} \quad \quad \mbox{if}     \quad    \nabla_\sigma \rho \cdot \nabla H<0 
+              \quad \quad \mbox{and} \quad         {\rm {\bf U}}_h  \cdot \nabla H<0 \\ 
+ \\
+ 0\quad \quad \;\,\mbox{otherwise} \\ 
+ \end{array}} \right.
+\end{equation} 
+
+% ================================================================
+% Tracer damping
+% ================================================================
+\section  [Tracer damping (\textit{tradmp})]
+		{Tracer damping (\mdl{tradmp})}
+\label{TRA_dmp}
+%--------------------------------------------namtdp-----------------------------------------------------
+\namdisplay{namtdp}
+%--------------------------------------------------------------------------------------------------------------
+
+In some applications it can be useful to add a Newtonian damping term 
+into the temperature and salinity equations:
+\begin{equation} \label{Eq_tra_dmp}
+\begin{split}
+ \frac{\partial T}{\partial t}=\;\cdots \;-\gamma \,\left( {T-T_o } \right)  \\
+\\ 
+ \frac{\partial S}{\partial t}=\;\cdots \;-\gamma \,\left( {S-S_o } \right) 
+ \end{split}
+ \end{equation} 
+where $\gamma$ is the inverse of a time scale, and $T_o$ and $S_o$ 
+are given temperature and salinity fields (usually a climatology). 
+The restoring term is added when \key{tradmp} is defined. 
+It also requires that both \key{temdta} and \key{saldta} are defined 
+($i.e.$ that $T_o$ and $S_o$ are read). The restoring coefficient 
+$S_o$ is a three-dimensional array initialized by the user in routine 
+\rou{dtacof} also located in module \mdl{tradmp}. 
+
+The two main cases in which \eqref{Eq_tra_dmp} is used are \textit{(a)} 
+the specification of the boundary conditions along artificial walls of a 
+limited domain basin and \textit{(b)} the computation of the velocity 
+field associated with a given $T$-$S$ field (for example to build the 
+initial state of a prognostic simulation, or to use the resulting velocity 
+field for a passive tracer study). The first case applies to regional 
+models that have artificial walls instead of open boundaries. 
+In the vicinity of these walls, $S_o$ takes large values (equivalent to 
+a time scale of a few days) whereas it is zero in the interior of the 
+model domain. The second case corresponds to the use of the robust 
+diagnostic method \citep{Sarmiento1982}. It allows us to find the velocity 
+field consistent with the model dynamics whilst having a $T$-$S$ field 
+close to a given climatological field ($T_o -S_o$). The time scale 
+associated with $S_o$ is generally not a constant but spatially varying 
+in order to respect other properties. For example, it is usually set to zero 
+in the mixed layer (defined either on a density or $S_o$ criterion) 
+\citep{Madec1996} and in the equatorial region 
+\citep{Reverdin1991, Fujio1991, MartiTh1992} since these two regions 
+have a short time scale of adjustment; while smaller $S_o$ are used 
+in the deep ocean where the typical time scale is long \citep{Sarmiento1982}. 
+In addition the time scale is reduced (even to zero) along the western 
+boundary to allow the model to reconstruct its own western boundary 
+structure in equilibrium with its physics. The choice of a 
+Newtonian damping acting in the mixed layer or not is controlled by
+namelist parameter \np{nmldmp}.
+
+The robust diagnostic method is very efficient in preventing temperature 
+drift in intermediate waters but it produces artificial sources of heat and salt 
+within the ocean. It also has undesirable effects on the ocean convection. 
+It tends to prevent deep convection and subsequent deep-water formation, 
+by stabilising the water column too much.
+
+An example of the computation of $S_o$ for robust diagnostic experiments 
+with the ORCA2 model is provided in the \mdl{tradmp} module 
+(subroutines \rou{dtacof} and \rou{cofdis} which compute the coefficient 
+and the distance to the bathymetry, respectively). These routines are 
+provided as examples and can be customised by the user. 
+
+% ================================================================
+% Tracer time evolution
+% ================================================================
+\section  [Tracer time evolution (\textit{tranxt})]
+		{Tracer time evolution (\mdl{tranxt})}
+\label{TRA_nxt}
+%--------------------------------------------namdom-----------------------------------------------------
+\namdisplay{namdom}
+%--------------------------------------------------------------------------------------------------------------
+
+The general framework for tracer time stepping is a leap-frog scheme, 
+$i.e.$ a three level centred time scheme associated with a Asselin time 
+filter (cf. \S\ref{DOM_nxt}):
+\begin{equation} \label{Eq_tra_nxt}
+\begin{split}
+T^{t+\Delta t} &= T^{t-\Delta t} + 2 \, \Delta t  \ \text{RHS}_T^t 	\\
+\\
+T_f^t  \;\ \quad &= T^t \;\quad +\gamma \,\left[ {T_f^{t-\Delta t} -2T^t+T^{t+\Delta t}} \right]
+\end{split}
+\end{equation} 
+where $\text{RHS}_T$ is the right hand side of the temperature equation, 
+the subscript $f$ denotes filtered values and $\gamma$ is the Asselin 
+coefficient. $\gamma$ is initialized as \np{atfp} (\textbf{namelist} parameter). 
+Its default value is \np{atfp=0.1}. 
+
+When the vertical mixing is solved implicitly, the update of the \textit{next} tracer 
+fields is done in module \mdl{trazdf}. In this case only the swapping of arrays 
+and the Asselin filtering is done in the \mdl{tranxt} module.
+
+In order to prepare for the computation of the \textit{next} time step, 
+a swap of tracer arrays is performed: $T^{t-\Delta t} = T^t$ and $T^t = T_f$. 
+
+% ================================================================
+% Equation of State (eosbn2) 
+% ================================================================
+\section  [Equation of State (\textit{eosbn2}) ]
+		{Equation of State (\mdl{eosbn2}) }
+\label{TRA_eosbn2}
+%--------------------------------------------nameos-----------------------------------------------------
+\namdisplay{nameos}
+%--------------------------------------------------------------------------------------------------------------
+
+% -------------------------------------------------------------------------------------------------------------
+%        Equation of State
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Equation of State (\np{neos} = 0, 1 or 2)}
+\label{TRA_eos}
+
+It is necessary to know the equation of state for the ocean very accurately 
+to determine stability properties (especially the Brunt-Vais\"{a}l\"{a} frequency), 
+particularly in the deep ocean. The ocean density is a non linear empirical 
+function of \textit{in situ }temperature, salinity and pressure. The reference 
+equation of state is that defined by the Joint Panel on Oceanographic Tables 
+and Standards \citep{UNESCO1983}. It was the standard equation of state 
+used in early releases of OPA. However, even though this computation is 
+fully vectorised, it is quite time consuming ($15$ to $20${\%} of the total 
+CPU time) since it requires the prior computation of the \textit{in situ} 
+temperature from the model \textit{potential} temperature using the 
+\citep{Bryden1973} polynomial for adiabatic lapse rate and a $4^th$ order 
+Runge-Kutta integration scheme. Since OPA6, we have used the 
+\citet{JackMcD1995} equation of state for seawater instead. It allows the 
+computation of the \textit{in situ} ocean density directly as a function of 
+\textit{potential} temperature relative to the surface (an \NEMO variable), 
+the practical salinity (another \NEMO variable) and the pressure (assuming no 
+pressure variation along geopotential surfaces, i.e. the pressure in decibars is 
+approximated by the depth in meters). Both the \citet{UNESCO1983} and 
+\citet{JackMcD1995} equations of state have exactly the same except that 
+the values of the various coefficients have been adjusted by \citet{JackMcD1995} 
+in order to directly use the \textit{potential} temperature instead of the 
+\textit{in situ} one. This reduces the CPU time of the in situ density computation 
+to about $3${\%} of the total CPU time, while maintaining a quite accurate 
+equation of state.
+
+In the computer code, a \textit{true} density $d$ is computed, $i.e.$ the ratio 
+of seawater volumic mass to $\rho_o$, a reference volumic mass (\textit{rau0} 
+defined in \mdl{phycst}, usually $rau0= 1,020~Kg/m^3$). The default option 
+(namelist prameter \np{neos}=0) is the \citet{JackMcD1995} equation of state. 
+Its use is highly recommended. However, for process studies, it is often 
+convenient to use a linear approximation of the density$^{\ast}$
+\footnote{$^{\ast }$ With the linear equation of state there is no longer 
+a distinction between \textit{in situ} and \textit{potential} density. Cabling 
+and thermobaric effects are also removed.}. 
+Two linear formulations are available: a function of $T$ only (\np{neos}=1) 
+and a function of both $T$ and $S$ (\np{neos}=2):
+\begin{equation} \label{Eq_tra_eos_linear}
+\begin{aligned}
+ d(T)    &= {\rho (T)} / {\rho _0 } &&= 1.028 - \alpha \;T     \\ 
+ d(T,S) &= {\rho (T,S)}                &&= \ \ \ \beta \;S - \alpha \;T 
+\end{aligned}
+\end{equation} 
+where $\alpha$ and $\beta$ are the thermal and haline expansion 
+coefficients, and $\rho_o$, the reference volumic mass, $rau0$. 
+($\alpha$ and $\beta$ can be modified through the \np{ralpha} and 
+\np{rbeta} namelist parameters). Note that when $d$ is a function 
+of $T$ only (\np{neos}=1), the salinity is a passive tracer and can be 
+used as such.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Brunt-Vais\"{a}l\"{a} Frequency
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Brunt-Vais\"{a}l\"{a} Frequency (\np{neos} = 0, 1 or 2)}
+\label{TRA_bn2}
+
+An accurate computation of the ocean stability (i.e. of $N$, the brunt-Vais\"{a}l\"{a}
+ frequency) is of paramount importance as it is used in several ocean 
+ parameterisations (namely TKE, KPP, Richardson number dependent 
+ vertical diffusion, enhanced vertical diffusion, non-penetrative convection, 
+ iso-neutral diffusion). In particular, one must be aware that $N^2$ has to 
+ be computed with an \textit{in situ} reference. The expression for $N^2$ 
+ depends on the type of equation of state used (\np{neos} namelist parameter).
+
+For \np{neos}=0 (\citet{JackMcD1995} equation of state), the \citet{McDougall1987} 
+polynomial expression is used (with the pressure in decibar approximated by 
+the depth in meters): 
+\begin{equation} \label{Eq_tra_bn2}
+N^2 = \frac{g}{e_{3w}} \; \beta   \ 
+	   \left(  \alpha / \beta \ \delta_{k+1/2}[T]     - \delta_{k+1/2}[S]   \right) 
+\end{equation} 
+where $\alpha$ ($\beta$) is the thermal (haline) expansion coefficient. 
+They are a function of  
+$\overline{T}^{\,k+1/2},\widetilde{S}=\overline{S}^{\,k+1/2} - 35.$, 
+and  $z_w$, with $T$ the \textit{potential} temperature and 
+$\widetilde{S}$ a salinity anomaly. 
+Note that both $\alpha$ and $\beta$ depend on \textit{potential} 
+temperature and salinity which are averaged at $w$-points prior 
+to the computation instead of being computed at $T$-points and 
+then averaged to $w$-points.
+
+When a linear equation of state is used (\np{neos}=1 or 2, 
+\eqref{Eq_tra_bn2} reduces to:
+\begin{equation} \label{Eq_tra_bn2_linear}
+N^2 =	\frac{g}{e_{3w}} \left(   \beta \;\delta_{k+1/2}[S] - \alpha \;\delta_{k+1/2}[T]   \right)
+\end{equation} 
+where $\alpha$ and $\beta $ are the constant coefficients used to 
+defined the linear equation of state \eqref{Eq_tra_eos_linear}.
+
+% -------------------------------------------------------------------------------------------------------------
+%        Specific Heat
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Specific Heat (\textit{phycst})]
+			{Specific Heat (\mdl{phycst})}
+\label{TRA_adv_ldf}
+
+The specific heat of sea water, $C_p$, is a function of temperature, salinity 
+and pressure \citep{UNESCO1983}. It is only used in the model to convert 
+surface heat fluxes into surface temperature increase and so the pressure 
+dependence is neglected. The dependence on $T$ and $S$ is weak. 
+For example, with $S=35~psu$, $C_p$ increases from $3989$ to $4002$ 
+when $T$ varies from -2~\degres C to 31~\degres C. Therefore, $C_p$ has 
+been chosen as a constant: $C_p=4.10^3~J\,Kg^{-1}\,\degres K^{-1}$. 
+Its value is set in \mdl{phycst} module. 
+
+%%%
+\gmcomment{ STEVEN:  consistency, no other computer variable names are 
+supplied, so why this one}
+%%%
+
+% -------------------------------------------------------------------------------------------------------------
+%        Freezing Point of Seawater
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Freezing Point of Seawater (\textit{ocfzpt})]
+			{Freezing Point of Seawater (\mdl{ocfzpt})}
+\label{TRA_fzp}
+
+The freezing point of seawater is a function of salinity and pressure \citep{UNESCO1983}:
+\begin{equation} \label{Eq_tra_eos_fzp}
+   \begin{split}
+T_f (S,p) = \left( -0.0575 + 1.710523 \;10^{-3} \, \sqrt{S} 
+						     -  2.154996 \;10^{-4} \,S  \right) \ S    \\
+               - 7.53\,10^{-3} \ \ p 
+   \end{split}
+\end{equation}
+
+\eqref{Eq_tra_eos_fzp} is only used to compute the potential freezing point of 
+sea water ($i.e.$ referenced to the surface $p=0$), thus the pressure dependent 
+terms in \eqref{Eq_tra_eos_fzp} (last term) have been dropped. The \textit{before} 
+and \textit{now} surface freezing point is introduced in the code as $fzptb$ and 
+$fzptn$ 2D arrays together with a  \textit{now} mask (\textit{freezn}) which takes 
+the value 0 or 1 depending on whether the ocean temperature is above or at the 
+freezing point. Caution: do not confuse \textit{freezn} with the fraction of lead 
+(\textit{frld}) defined in LIM.  
+
+%%%
+\gmcomment{STEVEN: consistency, not many computer variable names are supplied, so why these    ===>  gm  I agree   this should evolve both here and in the code itself}
+%%%
+
+% ================================================================
+% Horizontal Derivative in zps-coordinate 
+% ================================================================
+\section  [Horizontal Derivative in \textit{zps}-coordinate (\textit{zpshde})]
+		{Horizontal Derivative in \textit{zps}-coordinate (\mdl{zpshde})}
+\label{TRA_zpshde}
+
+\gmcomment{STEVEN: to be consistent with earlier discussion of differencing and averaging operators, I've changed "derivative" to "difference" and "mean" to "average"}
+
+With partial bottom cells (\np{ln\_zps}=.true.), in general, tracers in horizontally 
+adjacent cells live at different depths. Horizontal gradients of tracers are needed 
+for horizontal diffusion (\mdl{traldf} module) and for the hydrostatic pressure 
+gradient (\mdl{dynhpg} module) to be active. 
+\gmcomment{STEVEN from gm : question: not sure of  what -to be active- means}
+Before taking horizontal gradients between the tracers next to the bottom, a linear 
+interpolation in the vertical is used to approximate the deeper tracer as if it actually 
+lived at the depth of the shallower tracer point (Fig.~\ref{Fig_Partial_step_scheme}). 
+For example, for temperature in the $i$-direction the needed interpolated 
+temperature, $\widetilde{T}$, is:
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!p] \label{Fig_Partial_step_scheme}  \begin{center}
+\includegraphics[width=0.9\textwidth]{./TexFiles/Figures/Partial_step_scheme.pdf}
+\caption{ Discretisation of the horizontal difference and average of tracers in the $z$-partial step coordinate (\np{ln\_zps}=.true.) in the case $( e3w_k^{i+1} - e3w_k^i  )>0$. A linear interpolation is used to estimate $\widetilde{T}_k^{i+1}$, the tracer value at the depth of the shallower tracer point of the two adjacent bottom $T$-points. The horizontal difference is then given by: $\delta _{i+1/2} T_k=  \widetilde{T}_k^{\,i+1} -T_k^{\,i}$ and the average by: $\overline{T}_k^{\,i+1/2}= ( \widetilde{T}_k^{\,i+1/2} - T_k^{\,i} ) / 2$.  }
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{equation*}
+\widetilde{T}= \left\{  \begin{aligned}  
+&T^{\,i+1}      -\frac{ \left( e_{3w}^{i+1} -e_{3w}^i \right)}{ e_{3w}^{i+1} }\;\delta _k T^{i+1}	
+ 								&& \quad\text{if  $\ e_{3w}^{i+1} \geq e_{3w}^i$   } 	\\
+										\\
+&T^{\,i} \ \ \ \,+\frac{ \left( e_{3w}^{i+1} -e_{3w}^i \right) }{e_{3w}^i       }\;\delta _k T^{i+1}
+			 					&& \quad\text{if  $\ e_{3w}^{i+1}    <   e_{3w}^i$   } 
+            \end{aligned}   \right.
+\end{equation*}
+and the resulting forms for the horizontal difference and the horizontal average 
+value of $T$ at a $U$-point are: 
+\begin{equation} \label{Eq_zps_hde}
+\begin{aligned}
+ \delta _{i+1/2} T= 	\begin{cases}
+\ \ \ \widetilde {T}\quad\ -T^i	 	& \ \ \quad\quad\text{if  $\ e_{3w}^{i+1} \geq e_{3w}^i$ } \\
+										\\
+\ \ \ T^{\,i+1}-\widetilde{T}		& \ \ \quad\quad\text{if  $\ e_{3w}^{i+1}    <   e_{3w}^i$   } 
+            		\end{cases}     \\
+\\
+\overline {T}^{\,i+1/2} \ = 	\begin{cases}
+( \widetilde {T}\ \ \;\,-T^{\,i})	 / 2	& \;\ \ \quad\text{if  $\ e_{3w}^{i+1} \geq e_{3w}^i$ } \\
+										\\
+( T^{\,i+1}-\widetilde{T} ) / 2		& \;\ \ \quad\text{if  $\ e_{3w}^{i+1}    <   e_{3w}^i$   } 
+            \end{cases}
+\end{aligned}
+\end{equation}
+
+The computation of horizontal derivative of tracers as well as of density is 
+performed once for all at each time step in \mdl{zpshde} module and stored 
+in shared arrays to be used when needed. It has to be emphasized that the 
+procedure used to compute the interpolated density, $\widetilde{\rho}$, is not 
+the same as that used for $T$ and $S$. Instead of forming a linear approximation 
+of density, we compute $\widetilde{\rho }$ from the interpolated values of $T$ 
+and $S$, and the pressure at a $u$-point (in the equation of state pressure is 
+approximated by depth, see \S\ref{TRA_eos} ) : 
+\begin{equation} \label{Eq_zps_hde_rho}
+\widetilde{\rho } = \rho ( {\widetilde{T},\widetilde {S},z_u }) 
+\quad \text{where }\  z_u = \min \left( {z_T^{i+1} ,z_T^i } \right)
+\end{equation} 
+
+This is a much better approximation as the variation of $\rho$ with depth (and 
+thus pressure) is highly non-linear with a true equation of state and thus is badly 
+approximated with a linear interpolation. This approximation is used to compute 
+both the horizontal pressure gradient (\S\ref{DYN_hpg}) and the slopes of neutral 
+surfaces (\S\ref{LDF_slp})
+
+Note that in almost all the advection schemes presented in this Chapter, both 
+averaging and differencing operators appear. Yet \eqref{Eq_zps_hde} has not 
+been used in these schemes: in contrast to diffusion and pressure gradient 
+computations, no correction for partial steps is applied for advection. The main 
+motivation is to preserve the domain averaged mean variance of the advected 
+field when using the $2^{nd}$ order centred scheme. Sensitivity of the advection 
+schemes to the way horizontal averages are performed in the vicinity of partial 
+cells should be further investigated in the near future.
+%%%
+\gmcomment{gm :   this last remark has to be done}
+%%%
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_ZDF.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 1844)
@@ -0,0 +1,606 @@
+% ================================================================
+% Chapter Ñ Vertical Ocean Physics (ZDF)
+% ================================================================
+\chapter{Vertical Ocean Physics (ZDF)}
+\label{ZDF}
+\minitoc
+
+%gm% Add here a small introduction to ZDF and naming of the different physics (similar to what have been written for TRA and DYN.
+\gmcomment{Steven remark (not taken into account : problem here with turbulent vs turbulence.  I've changed "turbulent closure" to "turbulence closure", "turbulent mixing length" to "turbulence mixing length", but I've left "turbulent kinetic energy" alone - though I think it is an historical abberation!
+Gurvan :  I kept "turbulent closure etc "...}
+
+
+% ================================================================
+% Vertical Mixing
+% ================================================================
+\section{Vertical Mixing}
+\label{ZDF_zdf}
+
+The discrete form of the ocean subgrid scale physics has been presented in 
+\S\ref{TRA_zdf} and \S\ref{DYN_zdf}. At the surface and bottom boundaries, 
+the turbulent fluxes of momentum, heat and salt have to be defined. At the 
+surface they are prescribed from the surface forcing (see Chap.~\ref{SBC}), 
+while at the bottom they are set to zero for heat and salt, unless a geothermal 
+flux forcing is prescribed as a bottom boundary condition ($i.e.$ \key{trabbl} 
+defined, see \S\ref{TRA_bbc}), and specified through a bottom friction 
+parameterisation for momentum (see \S\ref{ZDF_bfr}).
+
+In this section we briefly discuss the various choices offered to compute 
+the vertical eddy viscosity and diffusivity coefficients, $A_u^{vm}$ , 
+$A_v^{vm}$ and $A^{vT}$ ($A^{vS}$), defined at $uw$-, $vw$- and $w$- 
+points, respectively (see \S\ref{TRA_zdf} and \S\ref{DYN_zdf}). These 
+coefficients can be assumed to be either constant, or a function of the local 
+Richardson number, or computed from a turbulent closure model (either 
+TKE or KPP formulation). The computation of these coefficients is initialized 
+in the \mdl{zdfini} module and performed in the \mdl{zdfric}, \mdl{zdftke} or 
+\mdl{zdfkpp} modules. The trends due to the vertical momentum and tracer 
+diffusion, including the surface forcing, are computed and added to the 
+general trend in the \mdl{dynzdf} and \mdl{trazdf} modules, respectively. 
+These trends can be computed using either a forward time stepping scheme 
+(namelist parameter \np{np\_zdfexp}=true) or a backward time stepping 
+scheme (\np{np\_zdfexp}=false) depending on the magnitude of the mixing 
+coefficients, and thus of the formulation used (see \S\ref{DOM_nxt}).
+
+% -------------------------------------------------------------------------------------------------------------
+%        Constant 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Constant (\key{zdfcst})}
+\label{ZDF_cst}
+%--------------------------------------------namzdf---------------------------------------------------------
+\namdisplay{namzdf}
+%--------------------------------------------------------------------------------------------------------------
+
+When \key{zdfcst} is defined, the momentum and tracer vertical eddy coefficients 
+are set to constant values over the whole ocean. This is the crudest way to define 
+the vertical ocean physics. It is recommended that this option is only used in 
+process studies, not in basin scale simulations. Typical values used in this case are:
+\begin{align*} 
+A_u^{vm} = A_v^{vm} &= 1.2\ 10^{-4}~m^2.s^{-1} 	\\
+\\
+A^{vT} = A^{vS} &= 1.2\ 10^{-5}~m^2.s^{-1}
+\end{align*}
+
+These values are set through the \np{avm0} and \np{avt0} namelist parameters. 
+In all cases, do not use values smaller that those associated with the molecular 
+viscosity and diffusivity, that is $\sim10^{-6}~m^2.s^{-1}$ for momentum, 
+$\sim10^{-7}~m^2.s^{-1}$ for temperature and $\sim10^{-9}~m^2.s^{-1}$ for salinity.
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        Richardson Number Dependent
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Richardson Number Dependent (\key{zdfric})}
+\label{ZDF_ric}
+
+%--------------------------------------------namric---------------------------------------------------------
+\namdisplay{namric}
+%--------------------------------------------------------------------------------------------------------------
+
+When \key{zdfric} is defined, a local Richardson number dependent formulation 
+for the vertical momentum and tracer eddy coefficients is set. The vertical mixing 
+coefficients are diagnosed from the large scale variables computed by the model. 
+\textit{In situ} measurements have been used to link vertical turbulent activity to 
+large scale ocean structures. The hypothesis of a mixing mainly maintained by the 
+growth of Kelvin-Helmholtz like instabilities leads to a dependency between the 
+vertical eddy coefficients and the local Richardson number ($i.e.$ the 
+ratio of stratification to vertical shear). Following \citet{PacPhil1981}, the following 
+formulation has been implemented:
+\begin{equation} \label{Eq_zdfric}
+   \left\{      \begin{aligned}
+         A^{vT} &= \frac {A_{ric}^{vT}}{\left( 1+a \; Ri \right)^n} + A_b^{vT}       \\
+         \\
+         A^{vm} &= \frac{A^{vT}        }{\left( 1+ a \;Ri  \right)   } + A_b^{vm}
+   \end{aligned}    \right.
+\end{equation}
+where $Ri = N^2 / \left(\partial_z \textbf{U}_h \right)^2$ is the local Richardson 
+number, $N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \S\ref{TRA_bn2}), 
+$A_b^{vT} $ and $A_b^{vm}$ are the constant background values set as in the 
+constant case (see \S\ref{ZDF_cst}), and $A_{ric}^{vT} = 10^{-4}~m^2.s^{-1}$ 
+is the maximum value that can be reached by the coefficient when $Ri\leq 0$, 
+$a=5$ and $n=2$. The last three values can be modified by setting the 
+\np{avmri}, \np{alp} and \np{nric} namelist parameters, respectively.
+
+% -------------------------------------------------------------------------------------------------------------
+%        TKE Turbulent Closure Scheme 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{TKE Turbulent Closure Scheme (\key{zdftke})}
+\label{ZDF_tke}
+
+%--------------------------------------------namtke---------------------------------------------------------
+\namdisplay{namtke}
+%--------------------------------------------------------------------------------------------------------------
+
+The vertical eddy viscosity and diffusivity coefficients are computed from a TKE 
+turbulent closure model based on a prognostic equation for $\bar {e}$, the turbulent 
+kinetic energy, and a closure assumption for the turbulent length scales. This 
+turbulent closure model has been developed by \citet{Bougeault1989} in the 
+atmospheric case, adapted by \citet{Gaspar1990} for the oceanic case, and 
+embedded in OPA by \citet{Blanke1993} for equatorial Atlantic simulations. Since 
+then, significant modifications have been introduced by \citet{Madec1998} in both 
+the implementation and the formulation of the mixing length scale. The time 
+evolution of $\bar{e}$ is the result of the production of $\bar{e}$ through vertical 
+shear, its destruction through stratification, its vertical diffusion, and its dissipation 
+of \citet{Kolmogorov1942} type:
+\begin{equation} \label{Eq_zdftke_e}
+\frac{\partial \bar{e}}{\partial t} = 
+\frac{A^{vm}}{e_3 }\;\left[ {\left( {\frac{\partial u}{\partial k}} \right)^2
+							+\left( {\frac{\partial v}{\partial k}} \right)^2} \right]
+-A^{vT}\,N^2
++\frac{1}{e_3}	\;\frac{\partial }{\partial k}\left[ {\frac{A^{vm}}{e_3 }
+				\;\frac{\partial \bar{e}}{\partial k}} \right]
+- c_\epsilon \;\frac{\bar {e}^{3/2}}{l_\epsilon }
+\end{equation}
+\begin{equation} \label{Eq_zdftke_kz}
+   \begin{split}
+         A^{vm} &= C_k\  l_k\  \sqrt {\bar{e}}  	\\
+         A^{vT} &= A^{vm} / P_{rt}
+   \end{split}
+\end{equation}
+where $N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \S\ref{TRA_bn2}), 
+$l_{\epsilon }$ and $l_{\kappa }$ are the dissipation and mixing length scales, 
+$P_{rt} $ is the Prandtl number. The constants $C_k = \sqrt {2} /2$ and 
+$C_\epsilon = 0.1$ are designed to deal with vertical mixing at any depth 
+\citep{Gaspar1990}. They are set through namelist parameters \np{ediff} 
+and \np{ediss}. $P_{rt} $ can be set to unity or, following \citet{Blanke1993}, 
+be a function of the local Richardson number, $R_i $:
+\begin{align*} \label{Eq_prt}
+P_{rt} = \begin{cases}
+                    \ \ \ 1 &      \text{if $\ R_i \leq 0.2$} 	\\
+                    5\,R_i &      \text{if $\ 0.2 \leq R_i \leq 2$} 	\\
+                    \ \ 10 &      \text{if $\ 2 \leq R_i$} 
+            \end{cases}
+\end{align*}
+Note that a horizontal Shapiro filter can optionally be applied to $R_i$. 
+However it is an obsolescent option that is not recommended.  
+The choice of $P_{rt} $ is controlled by the \np{npdl} namelist parameter.
+
+For computational efficiency, the original formulation of the turbulent length 
+scales proposed by \citet{Gaspar1990} has been simplified. Four formulations 
+are proposed, the choice of which is controlled by the \np{nmxl} namelist 
+parameter. The first two are based on the following first order approximation 
+\citep{Blanke1993}:
+\begin{equation} \label{Eq_tke_mxl0_1}
+l_k = l_\epsilon = \sqrt {2 \bar e} / N
+\end{equation}
+which is valid in a stable stratified region with constant values of the brunt-
+Vais\"{a}l\"{a} frequency. The resulting length scale is bounded by the distance 
+to the surface or to the bottom (\np{nmxl}=0) or by the local vertical scale factor (\np{nmxl}=1). \citet{Blanke1993} notice that this simplification has two major 
+drawbacks: it makes no sense for locally unstable stratification and the 
+computation no longer uses all the information contained in the vertical density 
+profile. To overcome these drawbacks, \citet{Madec1998} introduces the 
+\np{nmxl}=2 or 3 cases, which add an extra assumption concerning the vertical 
+gradient of the computed length scale. So, the length scales are first evaluated 
+as in \eqref{Eq_tke_mxl0_1} and then bounded such that:
+\begin{equation} \label{Eq_tke_mxl_constraint}
+\frac{1}{e_3 }\left| {\frac{\partial l}{\partial k}} \right| \leq 1
+\qquad \text{with }\  l =  l_k = l_\epsilon
+\end{equation}
+\eqref{Eq_tke_mxl_constraint} means that the vertical variations of the length 
+scale cannot be larger than the variations of depth. It provides a better 
+approximation of the \citet{Gaspar1990} formulation while being much less 
+time consuming. In particular, it allows the length scale to be limited not only 
+by the distance to the surface or to the ocean bottom but also by the distance 
+to a strongly stratified portion of the water column such as the thermocline 
+(Fig.~\ref{Fig_mixing_length}). In order to impose the \eqref{Eq_tke_mxl_constraint} 
+constraint, we introduce two additional length scales: $l_{up}$ and $l_{dwn}$, 
+the upward and downward length scales, and evaluate the dissipation and 
+mixing turbulent length scales as (and note that here we use numerical 
+indexing):
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_mixing_length}  \begin{center}
+\includegraphics[width=1.00\textwidth]{./TexFiles/Figures/Fig_mixing_length.pdf}
+\caption {Illustration of the mixing length computation. }
+\end{center}  
+\end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{equation} \label{Eq_tke_mxl2}
+\begin{aligned}
+ l_{up\ \ }^{(k)} &= \min \left(  l^{(k)} \ , \ l_{up}^{(k+1)} + e_{3T}^{(k)}\ \ \ \;  \right)
+    \quad &\text{ from $k=1$ to $jpk$ }\ \\
+ l_{dwn}^{(k)} &= \min \left(  l^{(k)} \ , \ l_{dwn}^{(k-1)} + e_{3T}^{(k-1)}  \right)   
+    \quad &\text{ from $k=jpk$ to $1$ }\ \\
+\end{aligned}
+\end{equation}
+where $l^{(k)}$ is computed using \eqref{Eq_tke_mxl0_1}, 
+$i.e.$ $l^{(k)} = \sqrt {2 \bar e^{(k)} / N^{(k)} }$.
+
+In the \np{nmxl}=2 case, the dissipation and mixing length scales take the same 
+value: $ l_k=  l_\epsilon = \min \left(\ l_{up} \;,\;  l_{dwn}\ \right)$, while in the 
+\np{nmxl}=2 case, the dissipation and mixing length scales are give 
+as in \citet{Gaspar1990}:
+\begin{equation} \label{Eq_tke_mxl_gaspar}
+\begin{aligned}
+& l_k          = \sqrt{\  l_{up} \ \ l_{dwn}\ }  	\\
+& l_\epsilon = \min \left(\ l_{up} \;,\;  l_{dwn}\ \right) 
+\end{aligned}
+\end{equation}
+
+At the sea surface the value of $\bar{e}$ is prescribed from the wind 
+stress field: $\bar{e}=ebb\;\left| \tau \right|$ ($ebb=60$ by default) 
+with a minimal threshold of $emin0=10^{-4}~m^2.s^{-2}$ (namelist
+parameters). Its value at the bottom of the ocean is assumed to be 
+equal to the value of the level just above. The time integration of the 
+$\bar{e}$ equation may formally lead to negative values because the 
+numerical scheme does not ensure its positivity. To overcome this 
+problem, a cut-off in the minimum value of $\bar{e}$ is used. Following 
+\citet{Gaspar1990}, the cut-off value is set to $\sqrt{2}/2~10^{-6}~m^2.s^{-2}$. 
+This allows the subsequent formulations to match that of\citet{Gargett1984} 
+for the diffusion in the thermocline and deep ocean :  $(A^{vT} = 10^{-3} / N)$. 
+In addition, a cut-off is applied on $A^{vm}$ and $A^{vT}$ to avoid numerical 
+instabilities associated with too weak vertical diffusion. They must be 
+specified at least larger than the molecular values, and are set through 
+\textit{avm0} and \textit{avt0} (\textbf{namelist} parameters).
+
+% -------------------------------------------------------------------------------------------------------------
+%        K Profile Parametrisation (KPP) 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{K Profile Parametrisation (KPP) (\key{zdfkpp}) }
+\label{ZDF_kpp}
+
+%--------------------------------------------namkpp--------------------------------------------------------
+\namdisplay{namkpp}
+%--------------------------------------------------------------------------------------------------------------
+
+The K-Profile Parametrization (KKP) developed by \cite{Large_al_RG94} has been 
+implemented in \NEMO by J. Chanut (PhD reference to be added here!).
+
+\colorbox{yellow}{Add a description of KPP here.}
+
+
+% ================================================================
+% Convection
+% ================================================================
+\section{Convection}
+\label{ZDF_conv}
+
+%--------------------------------------------namzdf--------------------------------------------------------
+\namdisplay{namzdf}
+%--------------------------------------------------------------------------------------------------------------
+
+Static instabilities (i.e. light potential densities under heavy ones) may 
+occur at particular ocean grid points. In nature, convective processes 
+quickly re-establish the static stability of the water column. These 
+processes have been removed from the model via the hydrostatic 
+assumption so they must be parameterized. Three parameterisations 
+are available to deal with convective processes: a non-penetrative 
+convective adjustment or an enhanced vertical diffusion, or/and the 
+use of a turbulent closure scheme.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Non-Penetrative Convective Adjustment 
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Non-Penetrative Convective Adjustment (\np{ln\_tranpc}) ]
+			{Non-Penetrative Convective Adjustment (\np{ln\_tranpc}=.true.) }
+\label{ZDF_npc}
+
+%--------------------------------------------namnpc--------------------------------------------------------
+\namdisplay{namnpc}
+%--------------------------------------------------------------------------------------------------------------
+
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!htb] \label{Fig_npc}  	\begin{center}
+\includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_npc.pdf}
+\caption {Example of an unstable density profile treated by the non penetrative 
+convective adjustment algorithm. $1^{st}$ step: the initial profile is checked from 
+the surface to the bottom. It is found to be unstable between levels 3 and 4. 
+They are mixed. The resulting $\rho$ is still larger than $\rho$(5): levels 3 to 5 
+are mixed. The resulting $\rho$ is still larger than $\rho$(6): levels 3 to 6 are 
+mixed. The $1^{st}$ step ends since the density profile is then stable below 
+the level 3. $2^{nd}$ step: the new $\rho$ profile is checked following the same 
+procedure as in $1^{st}$ step: levels 2 to 5 are mixed. The new density profile 
+is checked. It is found stable: end of algorithm.}
+\end{center}  	\end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The non-penetrative convective adjustment is used when \np{ln\_zdfnpc}=true. 
+It is applied at each \np{nnpc1} time step and mixes downwards instantaneously 
+the statically unstable portion of the water column, but only until the density 
+structure becomes neutrally stable ($i.e.$ until the mixed portion of the water 
+column has \textit{exactly} the density of the water just below) \citep{Madec1991a}. 
+The associated algorithm is an iterative process used in the following way 
+(Fig. \ref{Fig_npc}): starting from the top of the ocean, the first instability is 
+found. Assume in the following that the instability is located between levels 
+$k$ and $k+1$. The potential temperature and salinity in the two levels are 
+vertically mixed, conserving the heat and salt contents of the water column. 
+The new density is then computed by a linear approximation. If the new 
+density profile is still unstable between levels $k+1$ and $k+2$, levels $k$, 
+$k+1$ and $k+2$ are then mixed. This process is repeated until stability is 
+established below the level $k$ (the mixing process can go down to the 
+ocean bottom). The algorithm is repeated to check if the density profile 
+between level $k-1$ and $k$ is unstable and/or if there is no deeper instability.
+
+This algorithm is significantly different from mixing statically unstable levels 
+two by two. The latter procedure cannot converge with a finite number 
+of iterations for some vertical profiles while the algorithm used in \NEMO 
+converges for any profile in a number of iterations which is less than the 
+number of vertical levels. This property is of paramount importance as 
+pointed out by \citet{Killworth1989}: it avoids the existence of permanent 
+and unrealistic static instabilities at the sea surface. This non-penetrative 
+convective algorithm has been proved successful in studies of the deep 
+water formation in the north-western Mediterranean Sea 
+\citep{Madec1991a, Madec1991b, Madec1991c}.
+
+Note that in the current implementation of this algorithm presents several 
+limitations. First, potential density referenced to the sea surface is used to 
+check whether the density profile is stable or not. This is a strong 
+simplification which leads to large errors for realistic ocean simulations. 
+Indeed, many water masses of the world ocean, especially Antarctic Bottom
+Water, are unstable when represented in surface-referenced potential density. 
+The scheme will erroneously mix them up. Second, the mixing of potential 
+density is assumed to be linear. This assures the convergence of the algorithm 
+even when the equation of state is non-linear. Small static instabilities can thus 
+persist due to cabbeling: they will be treated at the next time step. 
+Third, temperature and salinity, and thus density, are mixed, but the 
+corresponding velocity fields remain unchanged. When using a Richardson 
+Number dependent eddy viscosity, the mixing of momentum is done through 
+the vertical diffusion: after a static adjustment, the Richardson Number is zero 
+and thus the eddy viscosity coefficient is at a maximum. When this convective 
+adjustment algorithm is used with constant vertical eddy viscosity, spurious 
+solutions can occur since the vertical momentum diffusion remains small even 
+after a static adjustment. In that case, we recommend the addition of momentum 
+mixing in a manner that mimics the mixing in temperature and salinity 
+\citep{Speich1992, Speich1996}.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Enhanced Vertical Diffusion 
+% -------------------------------------------------------------------------------------------------------------
+\subsection   [Enhanced Vertical Diffusion (\np{ln\_zdfevd})]
+			{Enhanced Vertical Diffusion (\np{ln\_zdfevd}=.true.)}
+\label{ZDF_evd}
+
+%--------------------------------------------namzdf--------------------------------------------------------
+\namdisplay{namzdf}
+%--------------------------------------------------------------------------------------------------------------
+
+The enhanced vertical diffusion parameterisation is used when \np{ln\_zdfevd}=true. 
+In this case, the vertical eddy mixing coefficients are assigned very large values 
+(a typical value is $10\;m^2s^{-1})$ in regions where the stratification is unstable 
+($i.e.$ when the Brunt-Vais\"{a}l\"{a} frequency is negative) \citep{Lazar1997, Lazar1999}. 
+This is done either on tracers only (\np{n\_evdm}=0) or on both momentum and 
+tracers (\np{n\_evdm}=1).
+
+In practice, where $N^2\leq 10^{-12}$, $A_T^{vT}$ and $A_T^{vS}$, and 
+if \np{n\_evdm}=1, the four neighbouring $A_u^{vm} \;\mbox{and}\;A_v^{vm}$ 
+values also, are set equal to the namelist parameter \np{avevd}. A typical value 
+for $avevd$ is between 1 and $100~m^2.s^{-1}$. This parameterisation of 
+convective processes is less time consuming than the convective adjustment 
+algorithm presented above when mixing both tracers and momentum in the 
+case of static instabilities. It requires the use of an implicit time stepping on 
+vertical diffusion terms (i.e. \np{ln\_zdfexp}=false). 
+
+% -------------------------------------------------------------------------------------------------------------
+%       Turbulent Closure Scheme 
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Turbulent Closure Scheme (\key{zdftke})}
+\label{ZDF_tcs}
+
+The TKE turbulent closure scheme presented in \S\ref{ZDF_tke} and used 
+when the \key{zdftke} is defined, in theory solves the problem of statically 
+unstable density profiles. In such a case, the term corresponding to the 
+destruction of turbulent kinetic energy through stratification in \eqref{Eq_zdftke_e} 
+becomes a source term, since $N^2$ is negative. It results in large values of 
+$A_T^{vT}$ and  $A_T^{vT}$, and also the four neighbouring 
+$A_u^{vm} {and}\;A_v^{vm}$ (up to $1\;m^2s^{-1})$. These large values 
+restore the static stability of the water column in a way similar to that of the 
+enhanced vertical diffusion parameterisation (\S\ref{ZDF_evd}). However, 
+in the vicinity of the sea surface (first ocean layer), the eddy coefficients 
+computed by the turbulent closure scheme do not usually exceed $10^{-2}m.s^{-1}$, 
+because the mixing length scale is bounded by the distance to the sea surface 
+(see \S\ref{ZDF_tke}). It can thus be useful to combine the enhanced vertical 
+diffusion with the turbulent closure scheme, $i.e.$ setting the \np{ln\_zdfnpc} 
+namelist parameter to true and defining the \key{zdftke} CPP key all together.
+
+The KPP turbulent closure scheme already includes enhanced vertical diffusion 
+in the case of convection, as governed by the variables $bvsqcon$ and $difcon$ 
+found in \mdl{zdfkpp}, therefore \np{np\_zdfevd} should not be used with the KPP 
+scheme. %gm%  + one word on non local flux with KPP scheme trakpp.F90 module...
+
+% ================================================================
+% Double Diffusion Mixing
+% ================================================================
+\section  [Double Diffusion Mixing (\textit{zdfddm} - \key{zdfddm})]
+		{Double Diffusion Mixing (\mdl{zdfddm} module - \key{zdfddm})}
+\label{ZDF_ddm}
+
+%-------------------------------------------namddm--------------------------------------------------------
+\namdisplay{namddm}
+%--------------------------------------------------------------------------------------------------------------
+
+Double diffusion occurs when relatively warm, salty water overlies cooler, fresher 
+water, or vice versa. The former condition leads to salt fingering and the latter 
+to diffusive convection. Double-diffusive phenomena contribute to diapycnal 
+mixing in extensive regions of the ocean.  \citet{Merryfield1999} include a 
+parameterisation of such phenomena in a global ocean model and show that 
+it leads to relatively minor changes in circulation but exerts significant regional 
+influences on temperature and salinity. 
+
+Diapycnal mixing of S and T are described by diapycnal diffusion coefficients 
+\begin{align*} % \label{Eq_zdfddm_Kz}
+    &A^{vT} = A_o^{vT}+A_f^{vT}+A_d^{vT}	\\
+    &A^{vS} = A_o^{vS}+A_f^{vS}+A_d^{vS}
+\end{align*}
+where subscript $f$ represents mixing by salt fingering, $d$ by diffusive convection, 
+and $o$ by processes other than double diffusion. The rates of double-diffusive mixing 
+depend on the buoyancy ratio $R_\rho = \alpha \partial_z T / \beta \partial_z S$, 
+where $\alpha$ and $\beta$ are coefficients of thermal expansion and saline 
+contraction (see \S\ref{TRA_eos}). To represent mixing of $S$ and $T$ by salt 
+fingering, we adopt the diapycnal diffusivities suggested by Schmitt (1981):
+\begin{align} \label{Eq_zdfddm_f}
+A_f^{vS} &= 	\begin{cases}
+	\frac{A^{\ast v}}{1+(R_\rho / R_c)^n   } &\text{if  $R_\rho > 1$ and $N^2>0$ } \\
+	0 				  					    &\text{otherwise} 
+				\end{cases}   
+\\ 		    \label{Eq_zdfddm_f_T}
+A_f^{vT} &= 0.7 \ A_f^{vS} / R_\rho 
+\end{align}
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!t] \label{Fig_zdfddm}  \begin{center}
+\includegraphics[width=0.99\textwidth]{./TexFiles/Figures/Fig_zdfddm.pdf}
+\caption {From \citet{Merryfield1999} : (a) Diapycnal diffusivities $A_f^{vT}$ 
+and $A_f^{vS}$ for temperature and salt in regions of salt fingering. Heavy 
+curves denote $A^{\ast v} = 10^{-3}~m^2.s^{-1}$ and thin curves 
+$A^{\ast v} = 10^{-4}~m^2.s^{-1}$ ; (b) diapycnal diffusivities $A_d^{vT}$ and 
+$A_d^{vS}$ for temperature and salt in regions of diffusive convection. Heavy 
+curves denote the Federov parameterisation and thin curves the Kelley 
+parameterisation. The latter is not implemented in \NEMO. }
+\end{center}    \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+The factor 0.7 in \eqref{Eq_zdfddm_f_T} reflects the measured ratio 
+$\alpha F_T /\beta F_S \approx  0.7$ of buoyancy flux of heat to buoyancy 
+flux of salt ($e.g.$, \citet{McDougall_Taylor_JMR84}). Following  \citet{Merryfield1999}, 
+we adopt $R_c = 1.6$, $n = 6$, and $A^{\ast v} = 10^{-4}~m^2.s^{-1}$.
+
+To represent mixing of S and T by diffusive layering,  the diapycnal diffusivities suggested 
+by Federov (1988) is used: 
+\begin{align} 	\label{Eq_zdfddm_d}
+A_d^{vT} &= 	\begin{cases}
+	1.3635 \, \exp{\left( 4.6\, \exp{ \left[  -0.54\,( R_{\rho}^{-1} - 1 )  \right] }    \right)}
+									&\text{if  $0<R_\rho < 1$ and $N^2>0$ } \\
+	0 								&\text{otherwise} 
+				\end{cases}   
+\\   			\label{Eq_zdfddm_d_S}
+A_d^{vS} &= 	\begin{cases}
+	A_d^{vT}\ \left( 1.85\,R_{\rho} - 0.85 \right)
+									&\text{if  $0.5 \leq R_\rho<1$ and $N^2>0$ } \\
+	A_d^{vT} \ 0.15 \ R_\rho
+									&\text{if  $\ \ 0 < R_\rho<0.5$ and $N^2>0$ } \\
+	0 								&\text{otherwise} 
+				\end{cases}   
+\end{align}
+
+The dependencies of \eqref{Eq_zdfddm_f} to \eqref{Eq_zdfddm_d_S} on $R_\rho$ 
+are illustrated in Fig.~\ref{Fig_zdfddm}. Implementing this requires computing 
+$R_\rho$ at each grid point on every time step. This is done in \mdl{eosbn2} at the 
+same time as $N^2$ is computed. This avoids duplication in the computation of 
+$\alpha$ and $\beta$ (which is usually quite expensive).
+
+% ================================================================
+% Bottom Friction
+% ================================================================
+\section  [Bottom Friction (\textit{zdfbfr})]
+		{Bottom Friction (\mdl{zdfbfr} module)}
+\label{ZDF_bfr}
+
+%--------------------------------------------nambfr--------------------------------------------------------
+\namdisplay{nambfr}
+%--------------------------------------------------------------------------------------------------------------
+
+Both the surface momentum flux (wind stress) and the bottom momentum 
+flux (bottom friction) enter the equations as a condition on the vertical 
+diffusive flux. For the bottom boundary layer, one has:
+\begin{equation} \label{Eq_zdfbfr_flux}
+A^{vm} \left( \partial \textbf{U}_h / \partial z \right) = \textbf{F}_h
+\end{equation}
+where $\textbf{F}_h$ is supposed to represent the horizontal momentum flux 
+outside the logarithmic turbulent boundary layer (thickness of the order of 
+1~m in the ocean). How $\textbf{F}_h$ influences the interior depends on the 
+vertical resolution of the model near the bottom relative to the Ekman layer 
+depth. For example, in order to obtain an Ekman layer depth 
+$d = \sqrt{2\;A^{vm}} / f = 50$~m, one needs a vertical diffusion coefficient 
+$A^{vm} = 0.125$~m$^2$s$^{-1}$ (for a Coriolis frequency 
+$f = 10^{-4}$~m$^2$s$^{-1}$). With a background diffusion coefficient 
+$A^{vm} = 10^{-4}$~m$^2$s$^{-1}$, the Ekman layer depth is only 1.4~m. 
+When the vertical mixing coefficient is this small, using a flux condition is 
+equivalent to entering the viscous forces (either wind stress or bottom friction) 
+as a body force over the depth of the top or bottom model layer. To illustrate 
+this, consider the equation for $u$ at $k$, the last ocean level:
+\begin{equation} \label{Eq_zdfbfr_flux2}
+\frac{\partial u \; (k)}{\partial t} = \frac{1}{e_{3u}} \left[ A^{vm} \; (k) \frac{U \; (k-1) - U \; (k)}{e_{3uw} \; (k-1)} - F_u \right] \approx - \frac{F_u}{e_{3u}}
+\end{equation}
+For example, if the bottom layer thickness is 200~m, the Ekman transport will 
+be distributed over that depth. On the other hand, if the vertical resolution 
+is high (1~m or less) and a turbulent closure model is used, the turbulent 
+Ekman layer will be represented explicitly by the model. However, the 
+logarithmic layer is never represented in current primitive equation model 
+applications: it is \emph{necessary} to parameterize the flux $\textbf{F}_h $. 
+Two choices are available in \NEMO: a linear and a quadratic bottom friction. 
+Note that in both cases, the rotation between the interior velocity and the 
+bottom friction is neglected in the present release of \NEMO.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Linear Bottom Friction
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Linear Bottom Friction (\np{nbotfr} = 1) }
+\label{ZDF_bfr_linear}
+
+The linear bottom friction parameterisation assumes that the bottom friction 
+is proportional to the interior velocity (i.e. the velocity of the last model level):
+\begin{equation} \label{Eq_zdfbfr_linear}
+\textbf{F}_h = \frac{A^{vm}}{e_3} \; \frac{\partial \textbf{U}_h}{\partial k} = r \; \textbf{U}_h^b
+\end{equation}
+where $\textbf{U}_h^b$ is the horizontal velocity vector of the bottom ocean 
+layer and $r$ is a friction coefficient expressed in m.s$^{-1}$. This coefficient 
+is generally estimated by setting a typical decay time $\tau$ in the deep ocean, 
+and setting $r = H / \tau$, where $H$ is the ocean depth. Commonly accepted 
+values of $\tau$ are of the order of 100 to 200 days \citep{Weatherly1984}. 
+A value $\tau^{-1} = 10^{-7}$~s$^{-1}$ equivalent to 115 days, is usually used 
+in quasi-geostrophic models. One may consider the linear friction as an 
+approximation of quadratic friction, $r \approx 2\;C_D\;U_{av}$ (\citet{Gill1982}, 
+Eq. 9.6.6). For example, with a drag coefficient $C_D = 0.002$, a typical speed 
+of tidal currents of $U_{av} =0.1$~m.s$^{-1}$, and assuming an ocean depth 
+$H = 4000$~m, the resulting friction coefficient is $r = 4\;10^{-4}$~m.s$^{-1}$. 
+This is the default value used in \NEMO. It corresponds to a decay time scale 
+of 115~days. It can be changed by specifying \np{bfric1} (namelist parameter).
+
+In the code, the bottom friction is imposed by updating the value of the 
+vertical eddy coefficient at the bottom level. Indeed, the discrete formulation 
+of (\ref{Eq_zdfbfr_linear}) at the last ocean $T-$level, using the fact that 
+$\textbf {U}_h =0$ below the ocean floor, leads to
+\begin{equation} \label{Eq_zdfbfr_linKz}
+\begin{split}
+A_u^{vm} &= r\;e_{3uw}\\
+A_v^{vm} &= r\;e_{3vw}\\
+\end{split}
+\end{equation}
+
+This update is done in \mdl{zdfbfr} when \np{nbotfr}=1. The value of $r$ 
+used is \np{bfric1}. Setting \np{nbotfr}=3 is equivalent to setting $r=0$ and 
+leads to a free-slip bottom boundary condition. Setting \np{nbotfr}=0 sets 
+$r=2\;A_{vb}^{\rm {\bf U}} $, where $A_{vb}^{\rm {\bf U}} $ is the background 
+vertical eddy coefficient, and a no-slip boundary condition is imposed. 
+Note that this latter choice generally leads to an underestimation of the 
+bottom friction: for example with a deepest level thickness of $200~m$ 
+and $A_{vb}^{\rm {\bf U}} =10^{-4}$m$^2$.s$^{-1}$, the friction coefficient 
+is only $r=10^{-6}$m.s$^{-1}$.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Non-Linear Bottom Friction
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Non-Linear Bottom Friction (\np{nbotfr} = 2)}
+\label{ZDF_bfr_nonlinear}
+
+The non-linear bottom friction parameterisation assumes that the bottom 
+friction is quadratic: 
+\begin{equation} \label{Eq_zdfbfr_nonlinear}
+\textbf {F}_h = \frac{A^{vm}}{e_3 }\frac{\partial \textbf {U}_h 
+}{\partial k}=C_D \;\sqrt {u_b ^2+v_b ^2+e_b } \;\; \textbf {U}_h^b 
+\end{equation}
+
+with $\textbf{U}_h^b = (u_b\;,\;v_b)$ the horizontal interior velocity ($i.e.$ 
+the horizontal velocity of the bottom ocean layer), $C_D$ a drag coefficient, 
+and $e_b $ a bottom turbulent kinetic energy due to tides, internal waves 
+breaking and other short time scale currents. A typical value of the drag 
+coefficient is $C_D = 10^{-3} $. As an example, the CME experiment 
+\citep{Treguier1992} uses $C_D = 10^{-3}$ and $e_b = 2.5\;10^{-3}$m$^2$.s$^{-2}$, 
+while the FRAM experiment \citep{Killworth1992} uses $e_b =0$ 
+and $e_b =2.5\;\;10^{-3}$m$^2$.s$^{-2}$. The FRAM choices have been 
+set as default values (\np{bfric2} and \np{bfeb2} namelist parameters).
+
+As for the linear case, the bottom friction is imposed in the code by 
+updating the value of the vertical eddy coefficient at the bottom level:
+\begin{equation} \label{Eq_zdfbfr_nonlinKz}
+\begin{split}
+A_u^{vm} &=C_D\; e_{3uw} \left[ u^2 + \left(\bar{\bar{v}}^{i+1,j}\right)^2 + e_b \right]^
+{1/2}\\
+A_v^{vm} &=C_D\; e_{3uw} \left[  \left(\bar{\bar{u}}^{i,j+1}\right)^2 + v^2 + e_b \right]^{1/2}\\
+\end{split}
+\end{equation}
+
+This update is done in \mdl{zdfbfr}. The coefficients that control the strength of the 
+non-linear bottom friction are initialized as namelist parameters: $C_D$= \np{bfri2}, 
+and $e_b$ =\np{bfeb2}.
+
+% ================================================================
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Introduction.tex
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Introduction.tex	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Chapters/Introduction.tex	(revision 1844)
@@ -0,0 +1,151 @@
+
+% ================================================================
+% INTRODUCTION
+% ================================================================
+
+\chapter{Introduction}
+
+The Nucleus for European Modelling of the Ocean (\NEMO) is a framework of ocean 
+related engines, namely OPA\footnote{OPA = Oc\'{e}an PArall\'{e}lis\'{e}} for the 
+ocean dynamics and thermodynamics, LIM\footnote{LIM= Louvain)la-neuve Ice 
+Model} for the sea-ice dynamics and thermodynamics, TOP\footnote{TOP = Tracer 
+in the Ocean Paradigm} for the biogeochemistry (both transport (TRP) and sources 
+minus sinks (LOBSTER, PISCES)\footnote{Both LOBSTER and PISCES are not 
+acronyms just name}. It is intended to be a flexible tool for studying the ocean and 
+its interactions with the other components of the earth climate system (atmosphere, 
+sea-ice, biogeochemical tracers, ...) over a wide range of space and time scales. 
+This documentation provides information about the physics represented by the ocean 
+component of \NEMO and the rationale for the choice of numerical schemes and 
+the model design. More specific information about running the model on different 
+computers, or how to set up a configuration, are found on the \NEMO web site 
+(www.locean-ipsl.upmc.fr/NEMO). 
+
+The ocean component of \NEMO has been developed from the OPA model, 
+release 8.2, described in \citet{Madec1998}. This model has been used for a wide 
+range of applications, both regional or global, as a forced ocean model and as a 
+model coupled with the atmosphere. A complete list of references is found on the 
+\NEMO web site. 
+
+This manual is organised in as follows. Chapter~\ref{PE} presents the model basics, 
+$i.e.$ the equations and their assumptions, the vertical coordinates used, and the 
+subgrid scale physics. This part deals with the continuous equations of the model 
+(primitive equations, with potential temperature, salinity and an equation of state). 
+The equations are written in a curvilinear coordinate system, with a choice of vertical 
+coordinates ($z$ or $s$, with the rescaled height coordinate formulation \textit{z*}, or  
+\textit{s*}). Momentum equations are formulated in the vector invariant form or in the 
+flux form. Dimensional units in the meter, kilogram, second (MKS) international system 
+are used throughout.
+
+The following chapters deal with the discrete equations. Chapter~\ref{DOM} presents the 
+space and time domain. The model is discretised on a staggered grid (Arakawa C grid) 
+with masking of land areas and uses a Leap-frog environment for time-stepping. Vertical 
+discretisation used depends on both how the bottom topography is represented and 
+whether the free surface is linear or not. Full step or partial step $z$-coordinate or 
+$s$- (terrain-following) coordinate is used with linear free surface (level position are then 
+fixed in time). In non-linear free surface, the corresponding rescaled height coordinate 
+formulation (\textit{z*} or \textit{s*}) is used (the level position then vary in time as a 
+function of the sea surface heigh). The following two chapters (\ref{TRA} and \ref{DYN}) 
+describe the discretisation of the prognostic equations for the active tracers and the 
+momentum. Explicit, split-explicit and implicit free surface formulations are implemented 
+as well as rigid-lid case. A number of numerical schemes are available for momentum 
+advection, for the computation of the pressure gradients, as well as for the advection of 
+tracers (second or higher order advection schemes, including positive ones).
+
+Surface boundary conditions (chapter~\ref{SBC}) can be implemented as prescribed
+fluxes, or bulk formulations for the surface fluxes (wind stress, heat, freshwater). The 
+model allows penetration of solar radiation  There is an optional geothermal heating at 
+the ocean bottom. Within the \NEMO system the ocean model is interactively coupled 
+with a sea ice model (LIM) and with biogeochemistry models (PISCES, LOBSTER). 
+Interactive coupling to Atmospheric models is possible via the OASIS coupler 
+\citep{OASIS2006}. 
+
+Other model characteristics are the lateral boundary conditions (chapter~\ref{LBC}).  
+Global configurations of the model make use of the ORCA tripolar grid, with special north 
+fold boundary condition. Free-slip or no-slip boundary conditions are allowed at land 
+boundaries. Closed basin geometries as well as periodic domains and open boundary 
+conditions are possible. 
+
+Physical parameterisations are described in chapters~\ref{LDF} and \ref{ZDF}. The 
+model includes an implicit treatment of vertical viscosity and diffusivity. The lateral 
+Laplacian and biharmonic viscosity and diffusion can be rotated following a geopotential 
+or neutral direction. There is an optional eddy induced velocity \citep{Gent1990} with a 
+space and time variable coefficient \citet{Treguier1997}. The model has vertical harmonic 
+viscosity and diffusion with a space and time variable coefficient, with options to compute 
+the coefficients with \citet{Blanke1993}, \citet{Large_al_RG94}, or \citet{PacPhil1981} mixing 
+schemes.
+
+Specific online diagnostics (not documented yet) are available in the model: output of all 
+the tendencies of the momentum and tracers equations, output of tracers tendencies 
+averaged over the time evolving mixed layer.
+
+The model is implemented in \textsc{Fortran 90}, with preprocessing (C-pre-processor). 
+It runs under UNIX. It is optimized for vector computers and parallelised by domain  
+decomposition with MPI. All input and output is done in NetCDF (Network Common Data 
+Format) with a optional direct access format for output. To ensure the clarity and 
+readability of the code it is necessary to follow coding rules. The coding rules for OPA 
+include conventions for naming variables, with different starting letters for different types 
+of variables (real, integer, parameter\ldots). Those rules are presented in a document 
+available on the \NEMO web site.
+
+The model is organized with a high internal modularity based on physics. For example, 
+each trend ($i.e.$, a term in the RHS of the prognostic equation) for momentum and 
+tracers is computed in a dedicated module.  To make it easier for the user to find his way 
+around the code, the module names follow a three-letter rule. For example, \mdl{tradmp} 
+is a module related to the TRAcers equation, computing the DaMPing. The complete list 
+of module names is presented in Appendix~\ref{Apdx_D}. Furthermore, modules are  
+organized in a few directories that correspond to their category, as indicated by the first 
+three letters of their name. 
+
+The manual mirrors the organization of the model. After the presentation of the 
+continuous equations (Chapter \ref{PE}), the following chapters refer to specific terms of 
+the equations each associated with a group of modules .
+
+
+\begin{table}[htbp] \label{tab1}
+%\begin{center} \begin{tabular}{|p{143pt}|l|l|}	\hline
+\begin{center} \begin{tabular}{|l|l|l|}	\hline
+Chapter \ref{DOM}	& DOM		& model DOMain \\		\hline
+Chapter \ref{TRA}	& TRA		& TRAcer equations (potential temperature and salinity) \\   \hline
+Chapter \ref{DYN}	& DYN		& DYNamic equations (momentum) \\		\hline
+Chapter \ref{SBC} 	& SBC		& Surface Boundary Conditions \\			\hline
+Chapter \ref{LBC}	& LBC		& Lateral Boundary Conditions  \\ 		\hline
+Chapter \ref{LDF}	& LDF		& Lateral DiFfusion (parameterisations) \\	\hline
+Chapter \ref{ZDF}	& ZDF		& Vertical DiFfusion  \\		\hline
+Chapter \ref{MISC}	& ...		& Miscellaneous  topics	 \\			\hline
+\end{tabular} 	\end{center}
+\end{table}
+
+In the current release (v3.0), the LBC directory does not yet exist. 
+When created LBC will contain the OBC directory (Open Boundary Condition), 
+and the \mdl{lbclnk}, \mdl{mppini} and \mdl{lib\_mpp} modules. 
+
+ \vspace{1cm}   Nota Bene : \vspace{0.25cm}
+
+OPA, like all research tools, is in perpetual evolution. The present document describes 
+the OPA version include in the release 3.0 of NEMO. This release differs significantly
+from version 8, documented in \citet{Madec1998}. The main modifications are :\\
+(1) transition to full native \textsc{Fortran} 90, deep code restructuring and drastic 
+reduction of CPP keys; \\
+(2) introduction of partial step representation of bottom topography \citep{Barnier_al_OD06}; \\
+(3) partial reactivation of a terrain-following vertical coordinate ($s$- and hybrid $s$-$z$) 
+with the addition of several options for pressure gradient computation \footnote{Partial 
+support of $s$-coordinate: there is presently no support for neutral physics in $s$-
+coordinate and for the new options for horizontal pressure gradient computation with 
+a non-linear equation of state.}; \\ 
+(4) more choices for the treatment of the free surface: full explicit, split-explicit , filtered 
+and rigid-lid; \\
+(5) non linear free surface option (associated with the rescaled height coordinate  
+\textit{z*} or  \textit{s*}); \\
+(6) additional schemes for vector and flux forms of the momentum  advection; \\
+(7) additional advection schemes for tracers; \\
+(8) implementation of the AGRIF package (Adaptative Grid Refinement in \textsc{Fortran}) \citep{Debreu_al_CG2008}; \\
+(9) online diagnostics : tracers trend in the mixed layer and vorticity balance; \\
+(10) rewriting of the I/O management; \\
+(11) OASIS 3 and 4 couplers interfacing with atmospheric global circulation models. \\
+(12) surface module (SBC) that simplify the way the ocean is forced and include two
+bulk formulea (CLIO and CORE)\\
+(13) introduction of LIM 3, the new Louvain-la-Neuve sea-ice model (C-grid rheology and
+new thermodynamics including bulk ice salinity) \citep{Vancoppenolle_al_OM08}
+
+In addition, several minor modifications in the coding have been introduced with the constant concern of improving performance on both scalar and vector computers. 
+
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/NEMO.ist
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/NEMO.ist	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/NEMO.ist	(revision 1844)
@@ -0,0 +1,3 @@
+delim_0 "\\dotfill"
+delim_1 "\\dotfill"
+delim_2 "\\dotfill"
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynadv
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynadv	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynadv	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nam_dynadv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
+/  
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynhpg
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynhpg	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynhpg	(revision 1844)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+&nam_dynhpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel  = .false.   !  s-coordinate (helsinki modification)
+   ln_hpg_wdj  = .false.   !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot  = .false.   !  s-coordinate (ROTated axes scheme)
+   gamm        = 0.e0      !  weighting coefficient (wdj scheme)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynldf
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynldf	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynldf	(revision 1844)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&nam_dynldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+!                               !  Type of the operator : 
+   ln_dynldf_lap    =  .true.   !     laplacian operator         
+   ln_dynldf_bilap  =  .false.  !     bilaplacian operator    
+!                               !  Direction of action  : 
+   ln_dynldf_level  =  .false.  !     iso-level               
+   ln_dynldf_hor    =  .true.   !     horizontal (geopotential)        (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.  !     iso-neutral                      (require "key_ldfslp")
+                                !  Coefficient
+   ahm0    = 40000.             !     horizontal eddy viscosity   [m2/s]
+   ahmb0   =     0.             !     background eddy viscosity for ldf_iso [m2/s]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynspg
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynspg	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynspg	(revision 1844)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+!nam_dynspg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  Non-linear free surface                   ("key_vvl")
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+!                          !  rigid-lid                                 ("key_dynspg_rl")
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynvor
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynvor	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_dynvor	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&nam_dynvor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
+   ln_dynvor_ens = .true.  !  energy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme               
+   ln_dynvor_een = .false. !  energy & enstrophy scheme  
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_lbc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_lbc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_lbc	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   shlat       =    2.     !      shlat = 0 : free slip
+                           !  0 < shlat < 2 : partial slip
+                           !      shlat = 2 : no slip
+                           !  2 < shlat     : strong slip
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nam_mpp      !   Massively Parallel Processing                         ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   c_mpi_send =  'S'       !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer  =   0        !  size in bytes of exported buffer ('B' case), 0 no exportation
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp_dyndist
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp_dyndist	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_mpp_dyndist	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nam_mpp_dyndist !   Massively Parallel Distribution                    ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+   jpni       =    1       !  jpni   number of processors following i
+   jpnj       =    1       !  jpnj   number of processors following j
+   jpnij      =    1       !  jpnij  number of local domains
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traadv
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traadv	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traadv	(revision 1844)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&nam_traadv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .true.   !  2nd order centered scheme   
+   ln_traadv_tvd    =  .false.  !  TVD scheme                
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
+   ln_traadv_ubs    =  .false.  !  UBS scheme                 
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traldf
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traldf	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_traldf	(revision 1844)
@@ -0,0 +1,15 @@
+!-----------------------------------------------------------------------
+&nam_traldf    !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+!                               !  Type of the operator : 
+   ln_traldf_lap    =  .true.   !     laplacian operator       
+   ln_traldf_bilap  =  .false.  !     bilaplacian operator     
+                                !  Direction of action  :
+   ln_traldf_level  =  .false.  !     iso-level                
+   ln_traldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
+!                               !  Coefficient
+   aht0        =  2000.         !     horizontal eddy diffusivity for tracers [m2/s]
+   ahtb0       =     0.         !     background eddy diffusivity for ldf_iso [m2/s]
+   aeiv0       =  2000.         !     eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nam_zgr       !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .true.    !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate    (T/F)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr_sco
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr_sco	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nam_zgr_sco	(revision 1844)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&nam_zgr_sco   !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   sbot_min    =  300.     !  minimum depth of s-bottom surface (>0) (m)
+   sbot_max    = 5250.     !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   theta       =    6.0    !  surface control parameter (0<=theta<=20)
+   thetb       =    0.75   !  bottom control parameter  (0<=thetb<= 1)
+   r_max       =    0.15   !  maximum cut-off r-value allowed (0<r_max<1)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namagrif
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namagrif	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namagrif	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namagrif      !                                                        ("key_agrif")
+!-----------------------------------------------------------------------
+    nbclineupdate = 3      !  baroclinic update frequency
+    ln_spc_dyn    = .true. !  use 0 as special value for dynamics
+    visc_tra      = 2880.  !  viscosity coeeficient for tracers sponge layer
+    visc_dyn      = 2880.  !  viscosity coeeficient for dynamics sponge layer
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbc	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ngeo_flux   =    2      !  geothermal heat flux = 0 no flux considered 
+                           !                       = 1 constant flux
+                           !                       = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+   ngeo_flux_const = 86.4e-3  !  Constant value of geothermal heat flux [W/m2]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbl
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbl	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambbl	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+!                          !  diffusive bbl                             ("key_trabbl")
+!                          !  advective bbl                             ("key_trabbl_adv")
+   atrbbl      =  10000.   !  lateral mixing coefficient in the bbl  [m2/s]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambdy
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambdy	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambdy	(revision 1844)
@@ -0,0 +1,20 @@
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries parameters               ("key_bdy")
+!-----------------------------------------------------------------------
+    filbdy_mask    =  ''                  !  name of mask file (if ln_bdy_mask=.TRUE.)
+    filbdy_data_T  = 'bdydata_grid_T.nc'  !  name of data file (T-points)
+    filbdy_data_U  = 'bdydata_grid_U.nc'  !  name of data file (U-points)
+    filbdy_data_V  = 'bdydata_grid_V.nc'  !  name of data file (V-points)
+    ln_bdy_clim    = .false.              !  contain 1 (T) or 12 (F) time dumps and be cyclic
+    ln_bdy_vol     = .true.               !  total volume correction (see volbdy parameter)
+    ln_bdy_mask    = .false.              !  boundary mask from filbdy_mask (T) or boundaries are on edges of domain (F)
+    ln_bdy_tides   = .true.               !  Apply tidal harmonic forcing with Flather condition
+    ln_bdy_dyn_fla = .true.               !  Apply Flather condition to velocities
+    ln_bdy_tra_frs = .false.              !  Apply FRS condition to temperature and salinity 
+    ln_bdy_dyn_frs = .false.              !  Apply FRS condition to velocities
+    nbdy_dta       =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    nb_rimwidth    = 9                    !  width of the relaxation zone
+    volbdy         = 0                    !  = 0, the total water flux across open boundaries is zero
+                                          !  = 1, the total volume of the system is conserved
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambfr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambfr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nambfr	(revision 1844)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nbotfr      =    1      !  type of bottom friction :   = 0 : no   slip,  = 2 : nonlinear friction
+                           !                              = 3 : free slip,  = 1 :    linear friction
+   bfri1       =    4.e-4  !  bottom drag coefficient (linear case)
+   bfri2       =    1.e-3  !  bottom drag coefficient (non linear case)
+   bfeb2       =    2.5e-3 !  bottom turbulent kinetic energy background  (m^2/s^2)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namcla
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namcla	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namcla	(revision 1844)
@@ -0,0 +1,5 @@
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+   n_cla       =    1      !  advection between 2 ocean pts separates by land
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namctl
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namctl	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namctl	(revision 1844)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+&namctl       !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl     = .false.    !  trends control print (expensive!)
+   nprint     =    0       !  level of print (0 no extra print)
+   nictls     =    0       !  start i indice of control sum (use to compare mono versus
+   nictle     =    0       !  end   i indice of control sum        multi processor runs
+   njctls     =    0       !  start j indice of control               over a subdomain)
+   njctle     =    0       !  end   j indice of control 
+   isplt      =    1       !  number of processors in i-direction
+   jsplt      =    1       !  number of processors in j-direction
+   nbench     =    0       !  Bench mode (1/0): CAUTION use zero except for bench
+                           !     (no physical validity of the results)
+   nbit_cmp   =    0       !  bit comparison mode (1/0): CAUTION use zero except for test
+                           !     of comparison between single and multiple processor runs
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namddm
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namddm	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namddm	(revision 1844)
@@ -0,0 +1,6 @@
+!-----------------------------------------------------------------------
+&namddm        !   double diffusive mixing parameterization                  ("key_zdfddm")
+!-----------------------------------------------------------------------
+      avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+      hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namdom
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namdom	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namdom	(revision 1844)
@@ -0,0 +1,18 @@
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   ntopo       =    1      !  compute (=0) or read(=1) the bathymetry file
+   e3zps_min   =    5.     !  the thickness of the partial step is set larger than the minimum
+   e3zps_rat   =    0.1    !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+   nmsh        =    0      !  create (=1) a mesh file (coordinates, scale factors, masks) or not (=0)
+   nacc        =    0      !  =1 acceleration of convergence method used, rdt < rdttra(k)
+                           !  =0, no acceleration, rdt = rdttra
+   atfp        =    0.1    !  asselin time filter parameter
+   rdt         = 5760.     !  time step for the dynamics (and tracer if nacc=0)
+   rdtmin      = 5760.     !  minimum time step on tracers (used if nacc=1)
+   rdtmax      = 5760.     !  maximum time step on tracers (used if nacc=1)
+   rdth        =  800.     !  depth variation of tracer time step  (used if nacc=1)
+   rdtbt       =   90.     !  barotropic time step (for the split explicit algorithm) ("key_dynspg_ts")
+   nclosea     =    0      !  = 0 no closed sea in the model domain
+                           !  = 1 closed sea (Black Sea, Caspian Sea, Great US Lakes...) 
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nameos
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nameos	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/nameos	(revision 1844)
@@ -0,0 +1,10 @@
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   neos        =    0      !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   ralpha      =    2.e-4  !  thermal expension coefficient (neos= 1 or 2)
+   rbeta       =    0.001  !  saline  expension coefficient (neos= 2)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflg
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflg	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflg	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&namflg        !   algorithm flags (algorithm not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynhpg_imp = .false. !  hydrostatic pressure gradient: semi-implicit time scheme  (T)
+                           !                                 centered      time scheme  (F)
+   nn_dynhpg_rst =  0      !  add dynhpg implicit variables in restart ot not (1/0)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflo
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflo	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namflo	(revision 1844)
@@ -0,0 +1,10 @@
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.    !  float restart (T) or not (F)
+    nwritefl  =      75    !  frequency of writing in float output file 
+    nstockfl  =    5475    !  frequency of creation of the float restart file 
+    ln_argo   = .false.    !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
+                           !  or computed with Blanke' scheme (F)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namgap
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namgap	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namgap	(revision 1844)
@@ -0,0 +1,6 @@
+!-----------------------------------------------------------------------
+&namgap       !   level mean model-data gap                             ('key_diagap')
+!-----------------------------------------------------------------------
+   ngap       =  15        !  time-step frequency of model-data gap computation
+   nprg       =  10        !  time-step frequency of gap print in model output
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namkpp
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namkpp	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namkpp	(revision 1844)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&namkpp        !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionnally:
+!                                                                         "key_kppcustom" or "key_kpplktb")
+!------------------------------------------------------------------------
+   ln_kpprimix = .true.    !  shear instability mixing 
+   difmiw      =  1.0e-04  !  constant internal wave viscosity [m2/s]
+   difsiw      =  0.1e-04  !  constant internal wave diffusivity [m2/s]
+   Riinfty     =  0.8      !  local Richardson Number limit for shear instability
+   difri       =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
+   bvsqcon     = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
+   difcon      =  1.       !  maximum mixing in interior convection [m2/s]
+   navb        =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
+   nave        =  1        !  constant (=0) or profile (=1) background on avt
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namlbc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namlbc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namlbc	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   shlat       =    2.     !      shlat = 0 : free slip
+                           !  0 < shlat < 2 : partial slip
+                           !      shlat = 2 : no slip
+                           !  2 < shlat     : strong slip
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namnpc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namnpc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namnpc	(revision 1844)
@@ -0,0 +1,6 @@
+!-----------------------------------------------------------------------
+&namnpc        !   non penetrative convection
+!-----------------------------------------------------------------------
+   nnpc1       =    1      !  non penetrative convective scheme computation frequency
+   nnpc2       =  365      !  non penetrative convective scheme print frequency
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namobc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namobc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namobc	(revision 1844)
@@ -0,0 +1,21 @@
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+    nobc_dta   =    1      !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc.dta' files
+    cffile     = 'annual'  !  set to annual if obc datafile hold 1 year of data
+                           !  set to monthly if obc datafile hold 1 month of data
+    rdpein     =    1.     !  ???
+    rdpwin     =    1.     !  ???
+    rdpnin     =    1.     !  ???
+    rdpsin     =    1.     !  ???
+    rdpeob     = 3000.     !  time relaxation (days) for the east  open boundary
+    rdpwob     =   15.     !    "        "             "     west         "
+    rdpnob     = 3000.     !    "        "             "     north        "
+    rdpsob     =   15.     !    "        "             "     south        "
+    zbsic1     =  140.e+6  !   barotropic stream function on first  isolated coastline
+    zbsic2     =    1.e+6  !    "                   "        second       "
+    zbsic3     =    0.     !    "                   "        thrid        "
+    ln_obc_clim= .false.   !  climatological obc data files (T) or not (F)
+    ln_vol_cst = .true.    !  impose the total volume conservation (T) or not (F)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namptr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namptr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namptr	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
+   nf_ptr     =  15        !  Frequency of ptr computation [time step]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namqsr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namqsr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namqsr	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namqsr        !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_traqsr   = .true.    !  penetrative solar radiation (T) or not (F)
+   rabs        =   0.58    !  fraction of qsr associated with xsi1
+   xsi1        =   0.35    !  first depth of extinction
+   xsi2        =   23.0    !  second depth of extinction
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namric
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namric	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namric	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&namric        !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   avmri       = 100.e-4   !  maximum value of the vertical viscosity
+   alp         =   5.      !  coefficient of the parameterization
+   nric        =   2       !  coefficient of the parameterization
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namrun
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namrun	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namrun	(revision 1844)
@@ -0,0 +1,18 @@
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   no          =       0   !  job number
+   cexper      =  "ORCA2"  !  experience name 
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   nrstdt      =       0   !  restart control = 0 nit000 is not compared to the restart file value
+                           !                  = 1 use ndate0 in namelist (not the value in the restart file)
+                           !                  = 2 calendar parameters read in the restart file
+   nit000      =       1   !  first time step
+   nitend      =    5475   !  last  time step
+   ndate0      =  010101   !  initial calendar date yymmdd (used if nrstdt=1)
+   nleapy      =       0   !  Leap year calendar (1) or not (0)
+   ninist      =       0   !  output the initial state (1) or not (0)
+   nstock      =    5475   !  frequency of creation of a restart file
+   nwrite      =    5475   !  frequency of write in the output file 
+   ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc	(revision 1844)
@@ -0,0 +1,23 @@
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+                           !               (= the frequency of sea-ice model call)
+   ln_ana      = .false.   !  analytical formulation (T => fill namsbc_ana ) 
+   ln_flx      = .false.   !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_clio = .true.    !  CLIO bulk formulation  (T => fill namsbc_clio) 
+   ln_blk_core = .false.   !  CORE bulk formulation  (T => fill namsbc_core) 
+   ln_cpl      = .false.   !  Coupled formulation    (T => fill namsbc_cpl )
+   nn_ice      = 2         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                             ("key_lim3" or "key_lim2)
+   nn_ico_cpl  = 0         !  ice-ocean coupling : =0 each nn_fsbc 
+                           !                       =1 stress recomputed each ocean time step ("key_lim3")
+                           !                       =2 combination of 0 and 1 cases           ("key_lim3")
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle short wave (qsr)
+   ln_rnf      = .true.    !  runoffs (T => fill namsbc_rnf)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked                              , 
+                           !                     =1 global mean of e-p-r set to zero at each nn_fsbc time step   ,
+                           !                     =2 annual global mean of e-p-r set to zero
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_alb
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_alb	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_alb	(revision 1844)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&namalb        !   albedo parameters
+!-----------------------------------------------------------------------
+   cgren       =    0.06   !  correction of the snow or ice albedo to take into account the
+   albice      =    0.5    !  albedo of melting ice in the arctic and antarctic
+   alphd       =    0.80   !  coefficients for linear interpolation used to
+   alphc       =    0.65   !  compute albedo between two extremes values 
+   alphdi      =    0.72   !  (Pyane, 1972)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ana
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ana	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ana	(revision 1844)
@@ -0,0 +1,10 @@
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   0       !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.5     !  uniform value for the i-stress
+   rn_vtau0    =   0.e0    !  uniform value for the j-stress
+   rn_q0       =   0.e0    !  uniform value for the total heat flux
+   rn_qsr0     =   0.e0    !  uniform value for the solar radiation
+   rn_emp0     =   0.e0    !  uniform value for the freswater budget (E-P)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_clio
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_clio	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_clio	(revision 1844)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+&namsbc_clio              CLIO bulk formulea
+!-----------------------------------------------------------------------
+!              !      file name     ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly' or !
+!              !                    !  (if <0  months)  !    name    !    (logical)   !  (T/F)  !  'monthly'  !
+   sn_utau      =    'taux_1m'       ,      -12.         , 'sozotaux' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_vtau      =    'tauy_1m'       ,      -12.         , 'sometauy' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_wndm      =    'flx'           ,      -12.         , 'socliowi' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_tair      =    'flx'           ,      -12.         , 'socliot1' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_humi      =    'flx'           ,      -12.         , 'socliohu' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_ccov      =    'flx'           ,      -12.         , 'socliocl' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_prec      =    'flx'           ,      -12.         , 'socliopl' ,     .false.        ,    1   ,    0     , ''       , ''
+
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_core
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_core	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_core	(revision 1844)
@@ -0,0 +1,18 @@
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulea
+!-----------------------------------------------------------------------
+!              !   file name        ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly' or !
+!              !                    !  (if <0  months)  !   name     !    (logical)   !  (T/F)  !  'monthly'  !
+   sn_wndi      =    'u10'           ,       24.         , 'U_10_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_wndj      =    'v10'           ,       24.         , 'V_10_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_qsr       =    'rad'           ,       24.         , 'SWDN_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_qlw       =    'rad'           ,       24.         , 'LWDN_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_tair      =    't10'           ,       24.         , 'T_10_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_humi      =    'q10'           ,       24.         , 'Q_10_MOD' ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_prec      =    'precip'        ,      -12.         , 'RAIN'     ,     .false.        ,    1   ,    0     , ''       , ''
+   sn_snow      =    'precip'        ,      -12.         , 'SNOW'     ,     .false.        ,    1   ,    0     , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_2m       = .false.   !  air temperature and humidity referenced at 2m (T) instead 10m (F)
+   alpha_precip= 1.        !  multiplicative factor for precipitation (total & snow)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_cpl
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_cpl	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_cpl	(revision 1844)
@@ -0,0 +1,24 @@
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                        ("key_coupled")
+!-----------------------------------------------------------------------
+! SEND
+cn_snd_temperature= 'weighted oce and ice'  ! 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_albedo     = 'weighted ice'          ! 'none' 'weighted ice' 'mixed oce-ice'
+cn_snd_thickness  = 'none'                  ! 'none' 'weighted ice and snow'
+cn_snd_crt_nature = 'none'                  ! 'none' 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_crt_refere = 'spherical'             ! 'spherical' 'cartesian'
+cn_snd_crt_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_snd_crt_grid   = 'T'                     ! 'T'
+! RECEIVE
+cn_rcv_w10m       = 'coupled'               ! 'none' 'coupled'
+cn_rcv_tau_nature = 'oce only'              ! 'oce only' 'oce and ice' 'mixed oce-ice'
+cn_rcv_tau_refere = 'cartesian'             ! 'spherical' 'cartesian'
+cn_rcv_tau_orient = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_rcv_tau_grid   = 'U,V'                   ! 'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+cn_rcv_dqnsdt     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_qsr        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_qns        = 'oce and ice'           ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_emp        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_rnf        = 'coupled'               ! 'coupled' 'climato' 'mixed'
+cn_rcv_cal        = 'coupled'               ! 'none' 'coupled'
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_flx
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_flx	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_flx	(revision 1844)
@@ -0,0 +1,13 @@
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !      file name     ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly' or !
+!              !                    !  (if <0  months)  !    name    !    (logical)   !  (T/F)  !  'monthly'  !
+   sn_utau      =      'utau.nc'     ,        24.        ,  'utau'  ,      .false.       ,    0   ,     0    , ''       , ''
+   sn_vtau      =      'vtau.nc'     ,        24.        ,  'vtau'  ,      .false.       ,    0   ,     0    , ''       , ''
+   sn_qtot      =      'qtot.nc'     ,        24.        ,  'qtot'  ,      .false.       ,    0   ,     0    , ''       , ''
+   sn_qsr       =      'qsr.nc'      ,        24.        ,  'qsr'   ,      .false.       ,    0   ,     0    , ''       , ''
+   sn_emp       =      'emp.nc'      ,        24.        ,  'emp'   ,      .false.       ,    0   ,     0    , ''       , ''
+!
+   cn_dir      = './'      !  root directory for the location of the flux files
+/      
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_qsr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_qsr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_qsr	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namqsr        !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_traqsr   = .true.    !  penetrative solar radiation (T) or not (F)
+   rabs        =   0.58    !  fraction of qsr associated with xsi1
+   xsi1        =   0.35    !  first depth of extinction
+   xsi2        =   23.0    !  second depth of extinction
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_rnf
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_rnf	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_rnf	(revision 1844)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!               !   file name        ! frequency (hours) ! variable   ! time interpolation !  clim  ! starting !
+!               !                    !   (if <0  months) !   name     !     (logical)      !  (0/1) !  record  !
+   sn_rnf     = 'runoff_1m_nomask.nc' ,      -12.        ,  'sorunoff',      .true.        ,    1   ,    0     , ''       , ''
+   sn_cnf     = 'runoff_1m_nomask.nc' ,        0.        ,  'socoefr' ,      .false.       ,    1   ,    0     , ''       , ''
+!
+   cn_dir       = './'       ! directory in which the model is executed
+   ln_rnf_emp   =   .false. !  runoffs included into precipitation field (T) or into a file (F)
+   ln_rnf_mouth =   .false. !  specific treatment at rivers mouths
+   rn_hrnf      =   0.e0    !  depth over which enhanced vertical mixing is used
+   rn_avt_rnf   =   1.e-3   !  value of the additional vertical mixing coef. [m2/s]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ssr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ssr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsbc_ssr	(revision 1844)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !     file name      ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly' or !
+!              !                    !  (if <0  months)  !   name     !    (logical)   !  (T/F)  !  'monthly'  !
+   sn_sst       =  'sst_data.nc'     ,         24.       ,  'sst'     ,      .false.       ,    0   ,    0
+   sn_sss       =  'sss_data.nc'     ,        -12.       ,  'sss'     ,      .true.        ,    0   ,    0
+!   
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     1     !  add a damping     term in the surface freshwater flux (=1) or not (=0)
+   dqdt        =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   deds        =   -27.7   !  magnitude of the damping on salinity   [mm/day/psu]
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsol
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsol	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namsol	(revision 1844)
@@ -0,0 +1,18 @@
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nsolv       =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+                           !                   =2 successive-over-relaxation (sor)
+                           !                   =3 FETI (fet)                               ("key_feti")
+                           !                   =4 sor with extra outer halo
+   nsol_arp    =      0    !  absolute/relative (0/1) precision convergence test
+   nmin        =    300    !  minimum of iterations for the SOR solver
+   nmax        =    800    !  maximum of iterations for the SOR solver
+   nmod        =     10    !  frequency of test for the SOR solver
+   eps         =  1.e-6    !  absolute precision of the solver
+   resmax      =  1.e-10   !  absolute precision for the SOR solver
+   sor         =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+   epsisl      =  1.e-10   !  absolute precision on stream function solver
+   nmisl       =   4000    !  maximum pcg iterations for island                            ("key_islands")
+   rnu         =      1.   !  strength of the additional force used in filtered free surface
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namspr
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namspr	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namspr	(revision 1844)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&namspr       !   surface pressure diagnostic
+!-----------------------------------------------------------------------
+   nmaxp      =   1000     !  maximum of iterations for the solver
+   epsp       =  1.e-3     !  absolute precision of the solver
+   niterp     =    400     !  number of iteration done by the solver
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtdp
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtdp	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtdp	(revision 1844)
@@ -0,0 +1,15 @@
+!-----------------------------------------------------------------------
+&namtdp        !   tracer newtonian damping                             ('key_tradmp')
+!-----------------------------------------------------------------------
+   ndmp        =   -1      !  type of damping in temperature and salinity 
+                           !     ='latitude', damping poleward of 'ndmp' degrees and function 
+                           !                  of the distance-to-coast. Red and Med Seas as ndmp=-1
+                           !     =-1 damping only in Med and Red Seas
+   ndmpf       =    1      !  create a damping.coeff NetCDF file (=1) or not (=0)
+   nmldmp      =    1      !  type of damping: =0 damping throughout the water column
+                           !                   =1 no damping in the mixed layer defined by avt >5cm2/s )
+                           !                   =2 no damping in the mixed layer defined rho<rho(surf)+.01 )
+   sdmp        =   50.     !  surface time scale for internal damping (days)
+   bdmp        =  360.     !  bottom  time scale for internal damping (days)
+   hdmp        =  800.     !  depth of transition between sdmp and bdmp (meters)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtide
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtide	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtide	(revision 1844)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namtide        ! tidal forcing at unstructured boundaries              
+!-----------------------------------------------------------------------
+    filtide      = 'bdytide_'           !  file name root of tidal forcing files
+    tide_cpt     = 'M2','S1'            !  names of tidal components used
+    tide_speed   = 28.984106, 15.000001 !  phase speeds of tidal components (deg/hour)
+    ln_tide_date = .false.              !  adjust tidal harmonics for start date of run
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtke
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtke	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtke	(revision 1844)
@@ -0,0 +1,34 @@
+!-----------------------------------------------------------------------
+&namtke        !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   ln_rstke    = .false.   !  restart with tke from a run without tke (T) or not (F)
+   nn_itke     =  50       !  number of iterative loops if ln_rstke=T 
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =   3.75    !  coef. of the surface input of tke
+   rn_efave    =   1.      !  boost of the tke diffusion ( avtke=rn_efave*avm )
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 same criteria as case 2 but applied in a different way
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   nn_avb      =   0       !  profile for constant background used on avt & avm (=1) or not (=0)
+   nn_ave      =   1       !  horizontal averaged on avt (=1) or not (=0) 
+   ln_mxl0     = .false.   !  mixing length scale surface value as function of wind stress (T) or not (F)
+   rn_lmin     =   0.4     !  interior buoyancy lenght scale minimum value
+   rn_lmin0    =   0.4     !  surface  buoyancy lenght scale minimum value
+   nn_etau     =   0       !  exponentially deceasing penetration of tke due to internal & intertial waves
+                           !        = 0 no penetration ( O(2 km) resolution)
+                           !        = 1 additional tke source 
+                           !        = 2 additional tke source applied only at the base of the mixed layer
+   nn_htau     =   2       !  type of exponential decrease of tke penetration
+                           !        = 0  constant 10 m length scale
+                           !        = 1  ???
+                           !        = 2  ???
+   rn_efr      =   0.05    !  fraction of surface tke value which penetrates inside the ocean
+   ln_lc       = .false.   !  Langmuir cell effect
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+   nn_havtb    =   0       !  horizontal shape for avtb (=1) or not (=0)
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtrd
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtrd	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namtrd	(revision 1844)
@@ -0,0 +1,11 @@
+!-----------------------------------------------------------------------
+&namtrd       !   diagnostics on dynamics and/or tracer trends             ("key_trddyn" and/or "key_trdtra")
+!                          or mixed-layer trends                        ('key_trdmld')
+!                          or barotropic vorticity                      ("key_trdvor")
+!-----------------------------------------------------------------------
+   ntrd       = 365        !  time step frequency dynamics and tracers trends
+   nctls      =   0        !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   ucf        =   1.       !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+   ln_trdmld_restart = .false.  !  restart for ML diagnostics
+   ln_trdmld_instant = .false.  !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namzdf
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namzdf	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/Namelist/namzdf	(revision 1844)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   avm0        =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   avt0        =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   ln_zdfnpc   = .false.   !  convection: Non-Penetrative algorithm (T) or not (F)
+   ln_zdfevd   = .true.    !  convection: enhanced vertical diffusion (T) or not (F)    
+   avevd       = 100.      !  vertical coefficient for enhanced diffusion scheme [m2/s]
+   n_evdm      =   1       !  enhanced mixing apply on tracer (=0) or on tracer and momentum (=1)
+   ln_zdfexp   =  .false.  !  split explicit (T) or implicit (F) time stepping
+   n_zdfexp    =   3       !  number of sub-timestep for ln_zdfexp=T
+/
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/ametsoc.bst
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/ametsoc.bst	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/ametsoc.bst	(revision 1844)
@@ -0,0 +1,1662 @@
+%%
+%% This is file `ametsoc7.bst',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% merlin.mbs  (with options: `ay,nat,nm-rev1,ed-rev,jnrlst,nmdash,nmd-3,dt-beg,yr-com,yrp-col,thtit-a,vol-2bf,vnum-sp,volp-com,pgsep-s,num-xser,numser,ser-vol,bkpg-x,pg-bk,pre-edn,agu-doi,doi,edparc,bkedcap,edby,edbyy,blk-tit,in-x,pp,ed,abr,ednx,ord,jabr,eprint,url,url-nt,em-it,nfss,')
+%% ----------------------------------------
+%% *** Bibliography style file for ALL AMS Journals...version 1.0  ***
+%% *** Brian Papa - American Meteorological Society ***
+%% 
+%% Copyright 1994-2004 Patrick W Daly
+ % ===============================================================
+ % IMPORTANT NOTICE:
+ % This bibliographic style (bst) file has been generated from one or
+ % more master bibliographic style (mbs) files, listed above.
+ %
+ % This generated file can be redistributed and/or modified under the terms
+ % of the LaTeX Project Public License Distributed from CTAN
+ % archives in directory macros/latex/base/lppl.txt; either
+ % version 1 of the License, or any later version.
+ % ===============================================================
+ % Name and version information of the main mbs file:
+ % \ProvidesFile{merlin.mbs}[2004/02/09 4.13 (PWD, AO, DPC)]
+ %   For use with BibTeX version 0.99a or later
+ %-------------------------------------------------------------------
+ % This bibliography style file is intended for texts in ENGLISH
+ % This is an author-year citation style bibliography. As such, it is
+ % non-standard LaTeX, and requires a special package file to function properly.
+ % Such a package is    natbib.sty   by Patrick W. Daly
+ % The form of the \bibitem entries is
+ %   \bibitem[Jones et al.(1990)]{key}...
+ %   \bibitem[Jones et al.(1990)Jones, Baker, and Smith]{key}...
+ % The essential feature is that the label (the part in brackets) consists
+ % of the author names, as they should appear in the citation, with the year
+ % in parentheses following. There must be no space before the opening
+ % parenthesis!
+ % With natbib v5.3, a full list of authors may also follow the year.
+ % In natbib.sty, it is possible to define the type of enclosures that is
+ % really wanted (brackets or parentheses), but in either case, there must
+ % be parentheses in the label.
+ % The \cite command functions as follows:
+ %   \citet{key} ==>>                Jones et al. (1990)
+ %   \citet*{key} ==>>               Jones, Baker, and Smith (1990)
+ %   \citep{key} ==>>                (Jones et al., 1990)
+ %   \citep*{key} ==>>               (Jones, Baker, and Smith, 1990)
+ %   \citep[chap. 2]{key} ==>>       (Jones et al., 1990, chap. 2)
+ %   \citep[e.g.][]{key} ==>>        (e.g. Jones et al., 1990)
+ %   \citep[e.g.][p. 32]{key} ==>>   (e.g. Jones et al., p. 32)
+ %   \citeauthor{key} ==>>           Jones et al.
+ %   \citeauthor*{key} ==>>          Jones, Baker, and Smith
+ %   \citeyear{key} ==>>             1990
+ %---------------------------------------------------------------------
+
+ENTRY
+  { address
+    archive
+    author
+    booktitle
+    chapter
+    doi
+    edition
+    editor
+    eid
+    eprint
+    howpublished
+    department
+    institution
+    journal
+    key
+    month
+    note
+    number
+    organization
+    pages
+    publisher
+    school
+    series
+    title
+    type
+    url
+    volume
+    year
+  }
+  {}
+  { label extra.label sort.label short.list }
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+  #1 'mid.sentence :=
+  #2 'after.sentence :=
+  #3 'after.block :=
+}
+STRINGS { s t}
+FUNCTION {output.nonnull}
+{ 's :=
+  output.state mid.sentence =
+    { ", " * write$ }
+    { output.state after.block =
+        { add.period$ write$
+          newline$
+          "\newblock " write$
+        }
+        { output.state before.all =
+            'write$
+            { add.period$ " " * write$ }
+          if$
+        }
+      if$
+      mid.sentence 'output.state :=
+    }
+  if$
+  s
+}
+FUNCTION {output}
+{ duplicate$ empty$
+    'pop$
+    'output.nonnull
+  if$
+}
+FUNCTION {output.check}
+{ 't :=
+  duplicate$ empty$
+    { pop$ "empty " t * " in " * cite$ * warning$ }
+    'output.nonnull
+  if$
+}
+FUNCTION {fin.entry}
+{ add.period$
+  write$
+  newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+    'skip$
+    { after.block 'output.state := }
+  if$
+}
+FUNCTION {new.sentence}
+{ output.state after.block =
+    'skip$
+    { output.state before.all =
+        'skip$
+        { after.sentence 'output.state := }
+      if$
+    }
+  if$
+}
+FUNCTION {add.blank}
+{  " " * before.all 'output.state :=
+}
+
+FUNCTION {date.block}
+{
+  ":" *
+  add.blank
+}
+
+FUNCTION {not}
+{   { #0 }
+    { #1 }
+  if$
+}
+FUNCTION {and}
+{   'skip$
+    { pop$ #0 }
+  if$
+}
+FUNCTION {or}
+{   { pop$ #1 }
+    'skip$
+  if$
+}
+FUNCTION {new.block.checkb}
+{ empty$
+  swap$ empty$
+  and
+    'skip$
+    'new.block
+  if$
+}
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+    { pop$ "" }
+    'skip$
+  if$
+}
+FUNCTION {emphasize}
+{ duplicate$ empty$
+    { pop$ "" }
+    { "\textit{" swap$ * "}" * }
+  if$
+}
+FUNCTION {bolden}
+{ duplicate$ empty$
+    { pop$ "" }
+    { "\textbf{" swap$ * "}" * }
+  if$
+}
+FUNCTION {tie.or.space.prefix}
+{ duplicate$ text.length$ #3 <
+    { "~" }
+    { " " }
+  if$
+  swap$
+}
+
+FUNCTION {capitalize}
+{ "u" change.case$ "t" change.case$ }
+
+FUNCTION {space.word}
+{ " " swap$ * " " * }
+ % Here are the language-specific definitions for explicit words.
+ % Each function has a name bbl.xxx where xxx is the English word.
+ % The language selected here is ENGLISH
+FUNCTION {bbl.and}
+{ "and"}
+
+FUNCTION {bbl.etal}
+{ "et~al." }
+
+FUNCTION {bbl.editors}
+{ "Eds." }
+
+FUNCTION {bbl.editor}
+{ "Ed." }
+
+FUNCTION {bbl.edby}
+{ "edited by" }
+
+FUNCTION {bbl.edition}
+{ "ed." }
+
+FUNCTION {bbl.volume}
+{ "Vol." }
+
+FUNCTION {bbl.of}
+{ "of" }
+
+FUNCTION {bbl.number}
+{ "No." }
+
+FUNCTION {bbl.nr}
+{ "No." }
+
+FUNCTION {bbl.in}
+{ "in" }
+
+FUNCTION {bbl.pages}
+{ "pp." }
+
+FUNCTION {bbl.page}
+{ "p." }
+
+FUNCTION {bbl.chapter}
+{ "chap." }
+
+FUNCTION {bbl.techrep}
+{ "Tech. Rep." }
+
+FUNCTION {bbl.mthesis}
+{ "Master's thesis" }
+
+FUNCTION {bbl.phdthesis}
+{ "Ph.D. thesis" }
+
+FUNCTION {bbl.first}
+{ "1st" }
+
+FUNCTION {bbl.second}
+{ "2d" }
+
+FUNCTION {bbl.third}
+{ "3d" }
+
+FUNCTION {bbl.fourth}
+{ "4th" }
+
+FUNCTION {bbl.fifth}
+{ "5th" }
+
+FUNCTION {bbl.st}
+{ "st" }
+
+FUNCTION {bbl.nd}
+{ "d" }
+
+FUNCTION {bbl.rd}
+{ "d" }
+
+FUNCTION {bbl.th}
+{ "th" }
+
+MACRO {jan} {"Jan."}
+
+MACRO {feb} {"Feb."}
+
+MACRO {mar} {"Mar."}
+
+MACRO {apr} {"Apr."}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"Jun."}
+
+MACRO {jul} {"Jul."}
+
+MACRO {aug} {"Aug."}
+
+MACRO {sep} {"Sep."}
+
+MACRO {oct} {"Oct."}
+
+MACRO {nov} {"Nov."}
+
+MACRO {dec} {"Dec."}
+
+FUNCTION {eng.ord}
+{ duplicate$ "1" swap$ *
+  #-2 #1 substring$ "1" =
+     { bbl.th * }
+     { duplicate$ #-1 #1 substring$
+       duplicate$ "1" =
+         { pop$ bbl.st * }
+         { duplicate$ "2" =
+             { pop$ bbl.nd * }
+             { "3" =
+                 { bbl.rd * }
+                 { bbl.th * }
+               if$
+             }
+           if$
+          }
+       if$
+     }
+   if$
+}
+
+MACRO {acmcs} {"ACM Comput. Surv."}
+
+MACRO {acta} {"Acta Inf."}
+
+MACRO {cacm} {"Commun. ACM"}
+
+MACRO {ibmjrd} {"IBM J. Res. Dev."}
+
+MACRO {ibmsj} {"IBM Syst.~J."}
+
+MACRO {ieeese} {"IEEE Trans. Software Eng."}
+
+MACRO {ieeetc} {"IEEE Trans. Comput."}
+
+MACRO {ieeetcad}
+ {"IEEE Trans. Comput. Aid. Des."}
+
+MACRO {ipl} {"Inf. Process. Lett."}
+
+MACRO {jacm} {"J.~ACM"}
+
+MACRO {jcss} {"J.~Comput. Syst. Sci."}
+
+MACRO {scp} {"Sci. Comput. Program."}
+
+MACRO {sicomp} {"SIAM J. Comput."}
+
+MACRO {tocs} {"ACM Trans. Comput. Syst."}
+
+MACRO {tods} {"ACM Trans. Database Syst."}
+
+MACRO {tog} {"ACM Trans. Graphic."}
+
+MACRO {toms} {"ACM Trans. Math. Software"}
+
+MACRO {toois} {"ACM Trans. Office Inf. Syst."}
+
+MACRO {toplas} {"ACM Trans. Progr. Lang. Syst."}
+
+MACRO {tcs} {"Theor. Comput. Sci."}
+
+FUNCTION {bibinfo.check}
+{ swap$
+  duplicate$ missing$
+    {
+      pop$ pop$
+      ""
+    }
+    { duplicate$ empty$
+        {
+          swap$ pop$
+        }
+        { swap$
+          pop$
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {bibinfo.warn}
+{ swap$
+  duplicate$ missing$
+    {
+      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
+      ""
+    }
+    { duplicate$ empty$
+        {
+          swap$ "empty " swap$ * " in " * cite$ * warning$
+        }
+        { swap$
+          pop$
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.eprint}
+{ eprint duplicate$ empty$
+    'skip$
+    { "\eprint"
+      archive empty$
+        'skip$
+        { "[" * archive * "]" * }
+      if$
+      "{" * swap$ * "}" *
+    }
+  if$
+}
+STRINGS  { bibinfo}
+INTEGERS { nameptr namesleft numnames }
+
+FUNCTION {format.names}
+{ 'bibinfo :=
+  duplicate$ empty$ 'skip$ {
+  's :=
+  "" 't :=
+  #1 'nameptr :=
+  s num.names$ 'numnames :=
+  numnames 'namesleft :=
+    { namesleft #0 > }
+    { s nameptr
+      duplicate$ #1 >
+        { "{f.~}{vv~}{ll}{, jj}" }
+        { "{vv~}{ll}{, f.}{, jj}" }
+      if$
+      format.name$
+      bibinfo bibinfo.check
+      't :=
+      nameptr #1 >
+        {
+          namesleft #1 >
+            { ", " * t * }
+            {
+              numnames #2 >
+                { "," * }
+                'skip$
+              if$
+              s nameptr "{ll}" format.name$ duplicate$ "others" =
+                { 't := }
+                { pop$ }
+              if$
+              t "others" =
+                {
+                  " " * bbl.etal *
+                }
+                {
+                  bbl.and
+                  space.word * t *
+                }
+              if$
+            }
+          if$
+        }
+        't
+      if$
+      nameptr #1 + 'nameptr :=
+      namesleft #1 - 'namesleft :=
+    }
+  while$
+  } if$
+}
+FUNCTION {format.names.ed}
+{
+  format.names
+}
+FUNCTION {format.key}
+{ empty$
+    { key field.or.null }
+    { "" }
+  if$
+}
+
+FUNCTION {format.authors}
+{ author "author" format.names
+}
+FUNCTION {get.bbl.editor}
+{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }
+
+FUNCTION {format.editors}
+{ editor "editor" format.names duplicate$ empty$ 'skip$
+    {
+      "," *
+      " " *
+      get.bbl.editor
+      capitalize
+   "(" swap$ * ")" *
+      *
+    }
+  if$
+}
+FUNCTION {format.book.pages}
+{ pages "pages" bibinfo.check
+  duplicate$ empty$ 'skip$
+    { " " * bbl.pages * }
+  if$
+}
+FUNCTION {format.doi}
+{ doi "doi" bibinfo.check
+  duplicate$ empty$ 'skip$
+    {
+      "\doi{" swap$ * "}" *
+    }
+  if$
+}
+FUNCTION {format.note}
+{
+  url empty$
+    'skip$
+    { "\urlprefix\url{" url * "}" * output }
+  if$
+ note empty$
+    { "" }
+    { note #1 #1 substring$
+      duplicate$ "{" =
+        'skip$
+        { output.state mid.sentence =
+          { "l" }
+          { "u" }
+        if$
+        change.case$
+        }
+      if$
+      note #2 global.max$ substring$ * "note" bibinfo.check
+    }
+  if$
+}
+
+FUNCTION {format.title}
+{ title
+  duplicate$ empty$ 'skip$
+    { "t" change.case$ }
+  if$
+  "title" bibinfo.check
+}
+FUNCTION {format.full.names}
+{'s :=
+ "" 't :=
+  #1 'nameptr :=
+  s num.names$ 'numnames :=
+  numnames 'namesleft :=
+    { namesleft #0 > }
+    { s nameptr
+      "{vv~}{ll}" format.name$
+      't :=
+      nameptr #1 >
+        {
+          namesleft #1 >
+            { ", " * t * }
+            {
+              s nameptr "{ll}" format.name$ duplicate$ "others" =
+                { 't := }
+                { pop$ }
+              if$
+              t "others" =
+                {
+                  " " * bbl.etal *
+                }
+                {
+                  numnames #2 >
+                    { "," * }
+                    'skip$
+                  if$
+                  bbl.and
+                  space.word * t *
+                }
+              if$
+            }
+          if$
+        }
+        't
+      if$
+      nameptr #1 + 'nameptr :=
+      namesleft #1 - 'namesleft :=
+    }
+  while$
+}
+
+FUNCTION {author.editor.key.full}
+{ author empty$
+    { editor empty$
+        { key empty$
+            { cite$ #1 #3 substring$ }
+            'key
+          if$
+        }
+        { editor format.full.names }
+      if$
+    }
+    { author format.full.names }
+  if$
+}
+
+FUNCTION {author.key.full}
+{ author empty$
+    { key empty$
+         { cite$ #1 #3 substring$ }
+          'key
+      if$
+    }
+    { author format.full.names }
+  if$
+}
+
+FUNCTION {editor.key.full}
+{ editor empty$
+    { key empty$
+         { cite$ #1 #3 substring$ }
+          'key
+      if$
+    }
+    { editor format.full.names }
+  if$
+}
+
+FUNCTION {make.full.names}
+{ type$ "book" =
+  type$ "inbook" =
+  or
+    'author.editor.key.full
+    { type$ "proceedings" =
+        'editor.key.full
+        'author.key.full
+      if$
+    }
+  if$
+}
+
+FUNCTION {output.bibitem}
+{ newline$
+  "\bibitem[{" write$
+  label write$
+  ")" make.full.names duplicate$ short.list =
+     { pop$ }
+     { * }
+   if$
+  "}]{" * write$
+  cite$ write$
+  "}" write$
+  newline$
+  ""
+  before.all 'output.state :=
+}
+
+FUNCTION {if.digit}
+{ duplicate$ "0" =
+  swap$ duplicate$ "1" =
+  swap$ duplicate$ "2" =
+  swap$ duplicate$ "3" =
+  swap$ duplicate$ "4" =
+  swap$ duplicate$ "5" =
+  swap$ duplicate$ "6" =
+  swap$ duplicate$ "7" =
+  swap$ duplicate$ "8" =
+  swap$ "9" = or or or or or or or or or
+}
+FUNCTION {n.separate}
+{ 't :=
+  ""
+  #0 'numnames :=
+  { t empty$ not }
+  { t #-1 #1 substring$ if.digit
+      { numnames #1 + 'numnames := }
+      { #0 'numnames := }
+    if$
+    t #-1 #1 substring$ swap$ *
+    t #-2 global.max$ substring$ 't :=
+    numnames #5 =
+      { duplicate$ #1 #2 substring$ swap$
+        #3 global.max$ substring$
+        "\," swap$ * *
+      }
+      'skip$
+    if$
+  }
+  while$
+}
+FUNCTION {n.dashify}
+{
+  n.separate
+  't :=
+  ""
+    { t empty$ not }
+    { t #1 #1 substring$ "-" =
+        { t #1 #2 substring$ "--" = not
+            { "--" *
+              t #2 global.max$ substring$ 't :=
+            }
+            {   { t #1 #1 substring$ "-" = }
+                { "-" *
+                  t #2 global.max$ substring$ 't :=
+                }
+              while$
+            }
+          if$
+        }
+        { t #1 #1 substring$ *
+          t #2 global.max$ substring$ 't :=
+        }
+      if$
+    }
+  while$
+}
+
+FUNCTION {word.in}
+{ "" }
+
+FUNCTION {format.date}
+{ year "year" bibinfo.check duplicate$ empty$
+    {
+      "empty year in " cite$ * "; set to ????" * warning$
+       pop$ "????"
+    }
+    'skip$
+  if$
+  extra.label *
+  before.all 'output.state :=
+  ", " swap$ *
+}
+FUNCTION {format.btitle}
+{ title "title" bibinfo.check
+  duplicate$ empty$ 'skip$
+    {
+      emphasize
+    }
+  if$
+}
+FUNCTION {either.or.check}
+{ empty$
+    'pop$
+    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+  if$
+}
+FUNCTION {format.bvolume}
+{ volume empty$
+    { "" }
+    { bbl.volume volume tie.or.space.prefix
+      "volume" bibinfo.check * *
+      series "series" bibinfo.check
+      duplicate$ empty$ 'pop$
+%%% NO ITALIC SERIES        { emphasize ", " * swap$ * }
+      {", " * swap$ * }
+      if$
+      "volume and number" number either.or.check
+    }
+  if$
+}
+FUNCTION {format.number.series}
+{ volume empty$
+    { number empty$
+        { series field.or.null }
+        { series empty$
+            { number "number" bibinfo.check }
+            { output.state mid.sentence =
+                { bbl.number }
+                { bbl.number capitalize }
+              if$
+              number tie.or.space.prefix "number" bibinfo.check * *
+              bbl.in space.word *
+              series "series" bibinfo.check *
+            }
+          if$
+        }
+      if$
+    }
+    { "" }
+  if$
+}
+FUNCTION {is.num}
+{ chr.to.int$
+  duplicate$ "0" chr.to.int$ < not
+  swap$ "9" chr.to.int$ > not and
+}
+
+FUNCTION {extract.num}
+{ duplicate$ 't :=
+  "" 's :=
+  { t empty$ not }
+  { t #1 #1 substring$
+    t #2 global.max$ substring$ 't :=
+    duplicate$ is.num
+      { s swap$ * 's := }
+      { pop$ "" 't := }
+    if$
+  }
+  while$
+  s empty$
+    'skip$
+    { pop$ s }
+  if$
+}
+
+FUNCTION {convert.edition}
+{ extract.num "l" change.case$ 's :=
+  s "first" = s "1" = or
+    { bbl.first 't := }
+    { s "second" = s "2" = or
+        { bbl.second 't := }
+        { s "third" = s "3" = or
+            { bbl.third 't := }
+            { s "fourth" = s "4" = or
+                { bbl.fourth 't := }
+                { s "fifth" = s "5" = or
+                    { bbl.fifth 't := }
+                    { s #1 #1 substring$ is.num
+                        { s eng.ord 't := }
+                        { edition 't := }
+                      if$
+                    }
+                  if$
+                }
+              if$
+            }
+          if$
+        }
+      if$
+    }
+  if$
+  t
+}
+
+FUNCTION {format.edition}
+{ edition duplicate$ empty$ 'skip$
+    {
+      convert.edition
+      output.state mid.sentence =
+        { "l" }
+        { "t" }
+      if$ change.case$
+      "edition" bibinfo.check
+      " " * bbl.edition *
+    }
+  if$
+}
+INTEGERS { multiresult }
+FUNCTION {multi.page.check}
+{ 't :=
+  #0 'multiresult :=
+    { multiresult not
+      t empty$ not
+      and
+    }
+    { t #1 #1 substring$
+      duplicate$ "-" =
+      swap$ duplicate$ "," =
+      swap$ "+" =
+      or or
+        { #1 'multiresult := }
+        { t #2 global.max$ substring$ 't := }
+      if$
+    }
+  while$
+  multiresult
+}
+FUNCTION {format.pages}
+{ pages duplicate$ empty$ 'skip$
+    { duplicate$ multi.page.check
+        {
+          n.dashify
+        }
+        {
+        }
+      if$
+      "pages" bibinfo.check
+    }
+  if$
+}
+FUNCTION {format.journal.pages}
+{ pages duplicate$ empty$ 'pop$
+    { swap$ duplicate$ empty$
+        { pop$ pop$ format.pages }
+        {
+          ", " *
+          swap$
+          n.dashify
+          "pages" bibinfo.check
+          *
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.journal.eid}
+{ eid "eid" bibinfo.check
+  duplicate$ empty$ 'pop$
+    { swap$ duplicate$ empty$ 'skip$
+      {
+          ", " *
+      }
+      if$
+      swap$ *
+    }
+  if$
+}
+FUNCTION {format.vol.num.pages}
+{ volume field.or.null
+  duplicate$ empty$ 'skip$
+    {
+      "volume" bibinfo.check
+    }
+  if$
+  number "number" bibinfo.check duplicate$ empty$ 'skip$
+    {
+      swap$ duplicate$ empty$
+        { "there's a number but no volume in " cite$ * warning$ }
+        'skip$
+      if$
+      swap$
+      "~(" swap$ * ")" *
+    }
+  if$ *
+  bolden
+  eid empty$
+    { format.journal.pages }
+    { format.journal.eid }
+  if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+    'format.pages
+    { type empty$
+        { bbl.chapter }
+        { type "l" change.case$
+          "type" bibinfo.check
+        }
+      if$
+      chapter tie.or.space.prefix
+      "chapter" bibinfo.check
+      * *
+      pages empty$
+        'skip$
+        { ", " * format.pages * }
+      if$
+    }
+  if$
+}
+
+FUNCTION {format.booktitle}
+{
+  booktitle "booktitle" bibinfo.check
+  emphasize
+}
+FUNCTION {format.in.ed.booktitle}
+{ format.booktitle duplicate$ empty$ 'skip$
+    {
+      editor "editor" format.names.ed duplicate$ empty$ 'pop$
+        {
+          get.bbl.editor
+          swap$ "," *
+          " " * swap$ *
+          swap$
+          "," *
+          " " * swap$
+          * }
+      if$
+      word.in swap$ *
+    }
+  if$
+}
+FUNCTION {format.thesis.type}
+{ type duplicate$ empty$
+    'pop$
+    { swap$ pop$
+      "t" change.case$ "type" bibinfo.check
+    }
+  if$
+}
+FUNCTION {format.tr.number}
+{ number "number" bibinfo.check
+  type duplicate$ empty$
+    { pop$ bbl.techrep }
+    'skip$
+  if$
+  "type" bibinfo.check
+  swap$ duplicate$ empty$
+    { pop$ "t" change.case$ }
+    { tie.or.space.prefix * * }
+  if$
+}
+FUNCTION {format.article.crossref}
+{
+  word.in
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.book.crossref}
+{ volume duplicate$ empty$
+    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+      pop$ word.in
+    }
+    { bbl.volume
+      capitalize
+      swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word *
+    }
+  if$
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.incoll.inproc.crossref}
+{
+  word.in
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.org.or.pub}
+{ 't :=
+  ""
+  address empty$ t empty$ and
+    'skip$
+    {
+      t empty$
+        { address "address" bibinfo.check *
+        }
+        { t *
+          address empty$
+            'skip$
+            { ", " * address "address" bibinfo.check * }
+          if$
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.publisher.address}
+{ publisher "publisher" bibinfo.warn format.org.or.pub
+}
+
+FUNCTION {format.organization.address}
+{ organization "organization" bibinfo.check format.org.or.pub
+}
+
+STRINGS {oldname}
+
+FUNCTION {name.or.dash}
+{ 's :=
+   oldname empty$
+     { s 'oldname := s }
+     { s oldname =
+         { "---{}---{}---" }
+         { s 'oldname := s }
+       if$
+     }
+   if$
+}
+
+FUNCTION {article}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title "title" output.check
+  new.sentence
+  crossref missing$
+    {
+      journal
+      "journal" bibinfo.check
+      emphasize
+      "journal" output.check
+      format.vol.num.pages output
+  format.doi output
+    }
+    { format.article.crossref output.nonnull
+      format.pages output
+    }
+  if$
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {book}
+{ output.bibitem
+  author empty$
+    { format.editors "author and editor" output.check
+      editor format.key output
+      add.blank
+      name.or.dash
+    }
+    { format.authors output.nonnull
+      name.or.dash
+      crossref missing$
+        { "author and editor" editor either.or.check }
+        'skip$
+      if$
+    }
+  if$
+  format.date "year" output.check
+  date.block
+  format.btitle "title" output.check
+  crossref missing$
+    { format.bvolume output
+  new.sentence
+      format.edition output
+      format.number.series output
+      format.publisher.address output
+    }
+    {
+  new.sentence
+      format.book.crossref output.nonnull
+    }
+  if$
+  format.book.pages output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {booklet}
+{ output.bibitem
+  format.authors output
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title "title" output.check
+  new.sentence
+  howpublished "howpublished" bibinfo.check output
+  address "address" bibinfo.check output
+  format.book.pages output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+  author empty$
+    { format.editors "author and editor" output.check
+      editor format.key output
+      name.or.dash
+    }
+    { format.authors output.nonnull
+      name.or.dash
+      crossref missing$
+        { "author and editor" editor either.or.check }
+        'skip$
+      if$
+    }
+  if$
+  format.date "year" output.check
+  date.block
+  format.btitle "title" output.check
+  crossref missing$
+    {
+      format.bvolume output
+      format.chapter.pages "chapter and pages" output.check
+  new.sentence
+      format.edition output
+      format.number.series output
+      format.publisher.address output
+    }
+    {
+      format.chapter.pages "chapter and pages" output.check
+  new.sentence
+      format.book.crossref output.nonnull
+    }
+  if$
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title "title" output.check
+  new.sentence
+  crossref missing$
+    { format.in.ed.booktitle "booktitle" output.check
+      format.publisher.address output      
+      format.bvolume output
+      format.number.series output
+      format.edition output
+      format.chapter.pages output
+    }
+    { format.incoll.inproc.crossref output.nonnull
+      format.chapter.pages output
+    }
+  if$
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {inproceedings}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title "title" output.check
+  new.sentence
+  crossref missing$
+    { format.in.ed.booktitle "booktitle" output.check
+      publisher empty$
+        { format.organization.address output }
+        { organization "organization" bibinfo.check output
+          format.publisher.address output
+        }
+      if$
+      format.bvolume output
+      format.pages output
+      format.number.series output
+      howpublished "howpublished" bibinfo.check output
+    }
+    { format.incoll.inproc.crossref output.nonnull
+      format.pages output
+    }
+  if$
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {conference} { inproceedings }
+FUNCTION {manual}
+{ output.bibitem
+  format.authors output
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.btitle "title" output.check
+  new.sentence
+  organization "organization" bibinfo.check output
+  address "address" bibinfo.check output
+  format.edition output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title
+  "title" output.check
+  new.sentence
+  bbl.mthesis format.thesis.type output.nonnull
+  department "department" bibinfo.warn output
+  school "school" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+  format.authors output
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title output
+  new.sentence
+  howpublished "howpublished" bibinfo.check output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {phdthesis}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title
+  "title" output.check
+  new.sentence
+  bbl.phdthesis format.thesis.type output.nonnull
+  school "school" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+  format.editors output
+  editor format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.btitle "title" output.check
+  format.bvolume output
+  format.number.series output
+  publisher empty$
+    { format.organization.address output }
+    { organization "organization" bibinfo.check output
+      format.publisher.address output
+    }
+  if$
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title
+  "title" output.check
+  new.sentence
+  format.tr.number output.nonnull
+  institution "institution" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.doi output
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+  format.authors "author" output.check
+  author format.key output
+  name.or.dash
+  format.date "year" output.check
+  date.block
+  format.title "title" output.check
+  format.doi output
+  format.note "note" output.check
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {default.type} { misc }
+READ
+FUNCTION {sortify}
+{ purify$
+  "l" change.case$
+}
+INTEGERS { len }
+FUNCTION {chop.word}
+{ 's :=
+  'len :=
+  s #1 len substring$ =
+    { s len #1 + global.max$ substring$ }
+    's
+  if$
+}
+FUNCTION {format.lab.names}
+{ 's :=
+  "" 't :=
+  s #1 "{vv~}{ll}" format.name$
+  s num.names$ duplicate$
+  #2 >
+    { pop$
+      " " * bbl.etal *
+    }
+    { #2 <
+        'skip$
+        { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+            {
+              " " * bbl.etal *
+            }
+            { bbl.and space.word * s #2 "{vv~}{ll}" format.name$
+              * }
+          if$
+        }
+      if$
+    }
+  if$
+}
+
+FUNCTION {author.key.label}
+{ author empty$
+    { key empty$
+        { cite$ #1 #3 substring$ }
+        'key
+      if$
+    }
+    { author format.lab.names }
+  if$
+}
+
+FUNCTION {author.editor.key.label}
+{ author empty$
+    { editor empty$
+        { key empty$
+            { cite$ #1 #3 substring$ }
+            'key
+          if$
+        }
+        { editor format.lab.names }
+      if$
+    }
+    { author format.lab.names }
+  if$
+}
+
+FUNCTION {editor.key.label}
+{ editor empty$
+    { key empty$
+        { cite$ #1 #3 substring$ }
+        'key
+      if$
+    }
+    { editor format.lab.names }
+  if$
+}
+
+FUNCTION {calc.short.authors}
+{ type$ "book" =
+  type$ "inbook" =
+  or
+    'author.editor.key.label
+    { type$ "proceedings" =
+        'editor.key.label
+        'author.key.label
+      if$
+    }
+  if$
+  'short.list :=
+}
+
+FUNCTION {calc.label}
+{ calc.short.authors
+  short.list
+  "("
+  *
+  year duplicate$ empty$
+     { pop$ "????" }
+     { purify$ #-1 #4 substring$ }
+  if$
+  *
+  'label :=
+}
+
+FUNCTION {sort.format.names}
+{ 's :=
+  #1 'nameptr :=
+  ""
+  s num.names$ 'numnames :=
+  numnames 'namesleft :=
+    { namesleft #0 > }
+    { s nameptr
+      "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}"
+      format.name$ 't :=
+      nameptr #1 >
+        {
+          "   "  *
+          namesleft #1 = t "others" = and
+            { "zzzzz" * }
+            { t sortify * }
+          if$
+        }
+        { t sortify * }
+      if$
+      nameptr #1 + 'nameptr :=
+      namesleft #1 - 'namesleft :=
+    }
+  while$
+}
+
+FUNCTION {sort.format.title}
+{ 't :=
+  "A " #2
+    "An " #3
+      "The " #4 t chop.word
+    chop.word
+  chop.word
+  sortify
+  #1 global.max$ substring$
+}
+FUNCTION {author.sort}
+{ author empty$
+    { key empty$
+        { "to sort, need author or key in " cite$ * warning$
+          ""
+        }
+        { key sortify }
+      if$
+    }
+    { author sort.format.names }
+  if$
+}
+FUNCTION {author.editor.sort}
+{ author empty$
+    { editor empty$
+        { key empty$
+            { "to sort, need author, editor, or key in " cite$ * warning$
+              ""
+            }
+            { key sortify }
+          if$
+        }
+        { editor sort.format.names }
+      if$
+    }
+    { author sort.format.names }
+  if$
+}
+FUNCTION {editor.sort}
+{ editor empty$
+    { key empty$
+        { "to sort, need editor or key in " cite$ * warning$
+          ""
+        }
+        { key sortify }
+      if$
+    }
+    { editor sort.format.names }
+  if$
+}
+FUNCTION {presort}
+{ calc.label
+  label sortify
+  "    "
+  *
+  type$ "book" =
+  type$ "inbook" =
+  or
+    'author.editor.sort
+    { type$ "proceedings" =
+        'editor.sort
+        'author.sort
+      if$
+    }
+  if$
+  #1 entry.max$ substring$
+  'sort.label :=
+  sort.label
+  *
+  "    "
+  *
+  title field.or.null
+  sort.format.title
+  *
+  #1 entry.max$ substring$
+  'sort.key$ :=
+}
+
+ITERATE {presort}
+SORT
+STRINGS { last.label next.extra }
+INTEGERS { last.extra.num number.label }
+FUNCTION {initialize.extra.label.stuff}
+{ #0 int.to.chr$ 'last.label :=
+  "" 'next.extra :=
+  #0 'last.extra.num :=
+  #0 'number.label :=
+}
+FUNCTION {forward.pass}
+{ last.label label =
+    { last.extra.num #1 + 'last.extra.num :=
+      last.extra.num int.to.chr$ 'extra.label :=
+    }
+    { "a" chr.to.int$ 'last.extra.num :=
+      "" 'extra.label :=
+      label 'last.label :=
+    }
+  if$
+  number.label #1 + 'number.label :=
+}
+FUNCTION {reverse.pass}
+{ next.extra "b" =
+    { "a" 'extra.label := }
+    'skip$
+  if$
+  extra.label 'next.extra :=
+  extra.label
+  duplicate$ empty$
+    'skip$
+    { "{\natexlab{" swap$ * "}}" * }
+  if$
+  'extra.label :=
+  label extra.label * 'label :=
+}
+EXECUTE {initialize.extra.label.stuff}
+ITERATE {forward.pass}
+REVERSE {reverse.pass}
+FUNCTION {bib.sort.order}
+{ sort.label
+  "    "
+  *
+  year field.or.null sortify
+  *
+  "    "
+  *
+  title field.or.null
+  sort.format.title
+  *
+  #1 entry.max$ substring$
+  'sort.key$ :=
+}
+ITERATE {bib.sort.order}
+SORT
+FUNCTION {begin.bib}
+{ preamble$ empty$
+    'skip$
+    { preamble$ write$ newline$ }
+  if$
+  "\begin{thebibliography}{" number.label int.to.str$ * "}" *
+  write$ newline$
+  "\providecommand{\natexlab}[1]{#1}"
+  write$ newline$
+  "\providecommand{\url}[1]{\texttt{#1}}"
+  write$ newline$
+  "\providecommand{\urlprefix}{URL }"
+  write$ newline$
+  "\expandafter\ifx\csname urlstyle\endcsname\relax"
+  write$ newline$
+  "  \providecommand{\doi}[1]{doi:\discretionary{}{}{}#1}\else"
+  write$ newline$
+  "  \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi"
+  write$ newline$
+  "\providecommand{\eprint}[2][]{\url{#2}}"
+  write$ newline$
+}
+EXECUTE {begin.bib}
+EXECUTE {init.state.consts}
+ITERATE {call.type$}
+FUNCTION {end.bib}
+{ newline$
+  "\end{thebibliography}" write$ newline$
+}
+EXECUTE {end.bib}
+%% End of customized bst file
+%%
+%% End of file `ametsoc7.bst'.
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/clean.sh
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/clean.sh	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/clean.sh	(revision 1844)
@@ -0,0 +1,2 @@
+rm -f $( ls -1 NEMO_book.* | egrep -v "(tex|pdf)" ) *mpgraph*
+rm -f Chapters/*.aux Chapters/*.log
Index: /branches/DEV_r1837_MLF/DOC/TexFiles/namlist_opa_New
===================================================================
--- /branches/DEV_r1837_MLF/DOC/TexFiles/namlist_opa_New	(revision 1844)
+++ /branches/DEV_r1837_MLF/DOC/TexFiles/namlist_opa_New	(revision 1844)
@@ -0,0 +1,513 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! OPA namelists :   1 - run manager      (namrun, nam_ctl, nam_mpp)
+!!                   2 - Domain           (nam_zgr, nam_zgr_sco, namdom)
+!!                   3 - Surface boundary (namtau, namflx, namqsr, namfwb, namalb, namcpl)
+!!                   4 - lateral boundary (namlbc, namobc, namcla)
+!!                   5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!                   6 - Tracer           (nam_traadv, nam_traldf, namtdp)
+!!                   7 - dynamics         (nam_dynvor, nam_dynhpg, namcfg, nam_dynldf)
+!!                   8 - Verical physics  (namzdf, namnpc, namgap, namznl, namspr, namflo)
+!!                   9 - diagnostics      (namtrd, namgap, namznl, namptr, namspr, namflo)
+!!                   9 - miscellaneous    (solver)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!  CAUTION: some scripts does not support CAPITALs for logical definition 
+!  *******       use .true. or .false. and NOT .TRUE. or .FALSE.
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun       parameters of the run
+!!   nam_ctl      Control prints & Benchmark
+!!   nam_mpp      Massively Parallel Processing
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namrun   !   parameters of the run
+!-----------------------------------------------------------------------
+   no         =       0    !  job number
+   cexper     =  "ORCA2"   !  experience name for vairmer format
+   ln_rstart  = .false.    !  boolean term for restart (true or false)
+   nrstdt     =       0    !  restart control = 0 restart, do not control nit000 in the restart file.
+                           !                  = 1 restart, control nit000 in the restart file. Do not
+                           !                      use the date in the restart file (use ndate0 in namelist)
+                           !                  = 2 restart, control nit000 in the restart file, use the date
+                           !                      in the restart file. ndate0 in the namelist is ignored.
+   nit000     =       1    !  number of the first time step
+   nitend     =    5475    !  number of the first time step
+   ndate0     =  010101    !  initial calendar date aammjj
+   nleapy     =       0    !  Leap year calendar (0/1)
+   ninist     =       0    !  initial state output flag (0/1)
+   nstock     =    5475    !  number of the first time step
+   nwrite     =    5475    !  frequency of OUTPUT file
+   nrunoff    =       2    !  = 0 no, 1 runoff, 2 runoff+river mouth ups adv
+/
+!-----------------------------------------------------------------------
+&nam_ctl      !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+   ln_ctl =  .false.       !  trends control print (expensive!)
+   nprint =       0        !  level of print (0 no print)
+   nictls =       0        !  start i indice to make the control SUM (very usefull to compare mono-
+   nictle =       0        !  end   i indice to make the control SUM (-versus multi processor runs)
+   njctls =       0        !  start j indice to make the control SUM (very usefull to compare mono-
+   njctle =       0        !  end   j indice to make the control SUM (-versus multi processor runs)
+   isplt  =       1        !  number of processors following i
+   jsplt  =       1        !  number of processors following j
+   nbench =       0        !  Bench parameter (0/1): CAUTION it must be zero except for bench
+                           !     for which we don't care about physical meaning of the results
+   nbit_cmp =     0        !  bit comparison mode parameter (0/1): enables bit comparison between 
+                           !             single and multiple processor runs
+/
+!-----------------------------------------------------------------------
+&nam_mpp      !   Massively Parallel Processing
+!-----------------------------------------------------------------------
+   c_mpi_send =  'S'       !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+/
+
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   nam_zgr       vertical coordinate
+!!   nam_zgr_sco   s-coordinate or hybrid z-s-coordinate
+!!   namdom        space and time domain (bathymetry, mesh, timestep)
+!!======================================================================
+!-----------------------------------------------------------------------
+&nam_zgr       !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco   =  .false.     !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps   =  .true.      !  z-coordinate - partial steps   (T/F)
+   ln_sco   =  .false.     !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&nam_zgr_sco   !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   sbot_min =  300.        !  minimum depth of s-bottom surface (>0) (m)
+   sbot_max = 5250.        !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   theta    =    6.0       !  surface control parameter (0<=theta<=20)
+   thetb    =    0.75      !  bottom control parameter  (0<=thetb<= 1)
+   r_max    =    0.15      !  maximum cut-off r-value allowed (0<r_max<1)
+/
+!-----------------------------------------------------------------------
+&namdom   !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   ntopo     =     1       !  = 0/1 ,compute/read the bathymetry file (mbathy, nb of T-ocean levels)
+   e3zps_min =     5.      !  the thickness of the partial step is set larger than the minimum
+   e3zps_rat =     0.1     !  of e3zps_min and e3zps_rat * e3t   (N.B. 0<e3zps_rat<1)
+   nmsh      =     0       !  =1 create a mesh file (coordinates, scale factors, masks)
+   nacc      =     0       !  the acceleration of convergence method   = 0, no acceleration, rdt = rdttra
+                           !                                           = 1, acceleration used, rdt < rdttra(k)
+   atfp      =     0.1     !  asselin time filter parameter
+   rdt       =  5760.      !  time step for the dynamics (and tracer if nacc=0)
+   rdtmin    =  5760.      !  minimum time step on tracers
+   rdtmax    =  5760.      !  maximum time step on tracers
+   rdth      =   800.      !  depth variation of tracer time step
+   rdtbt     =    90.      !  barotropic time step (for the time splitting algorithm)
+   nfice     =     5       !  frequency of ice model call
+   nfbulk    =     5       !  frequency of bulk formulea call (not used if ice used)
+   nclosea   =     0       !  = 0 no closed sea in the model domain
+                           !  = 1 closed sea (Black Sea, Caspian Sea, Great US Lakes...) 
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namtau      surface wind stress
+!!   namflx      surface fluxes
+!!   namqsr      penetrative solar radiation
+!!   namfwb      freshwater budget correction
+!!   namalb      albedo parameters
+!!   namcpl      coupled ocean/atmosphere model (#ifdef "key_coupled")
+!!======================================================================
+!-----------------------------------------------------------------------
+&namtau   !   surface wind stress
+!-----------------------------------------------------------------------
+   ntau000 =      0        !  gently increase the stress over the first ntau_rst time-steps
+   tau0x   =      0.e0     !  uniform value used as default surface heat flux
+   tau0y   =      0.e0     !  uniform value used as default solar radiation flux
+/
+!-----------------------------------------------------------------------
+&namflx   !   surface fluxes
+!-----------------------------------------------------------------------
+   q0      =      0.e0     !  uniform value used as default surface heat flux
+   qsr0    =      0.e0     !  uniform value used as default solar radiation flux
+   emp0    =      0.e0     !  uniform value used as default surface freswater budget (E-P)
+   dqdt0   =      -40.     !  feedback coefficient for SST damping (W/m2/K)
+   deds0   =        0.     !  feedback coefficient for SSS damping (mm/day)
+/
+!-----------------------------------------------------------------------
+&namqsr   !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_traqsr = .true.      !  penetrative solar radiation (T) or not (F)     (Default=T)
+   rabs     =   0.58       !  fraction of qsr associated with xsi1
+   xsi1     =   0.35       !  first depth of extinction
+   xsi2     =   23.0       !  second depth of extinction
+/
+!-----------------------------------------------------------------------
+&namfwb   !   freshwater budget correction
+!-----------------------------------------------------------------------
+   ln_fwb    = .true.      !  flag for freshwater budget correction (0 annual mean)
+/
+!-----------------------------------------------------------------------
+&namalb   !   albedo parameters
+!-----------------------------------------------------------------------
+   cgren    =      0.06    !  correction of the snow or ice albedo to take into account
+   albice   =      0.5     !  albedo of melting ice in the arctic and antarctic
+   alphd    =      0.80    !  coefficients for linear interpolation used to
+   alphc    =      0.65    !  compute albedo between two extremes values 
+   alphdi   =      0.72    !  (Pyane, 1972)
+/
+!-----------------------------------------------------------------------
+&namcpl   !   coupled ocean/atmosphere model                            ("key_coupled")
+!-----------------------------------------------------------------------
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namcro        cross land advection
+!!   namobc        open boundaries parameters                           ("key_obc")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namlbc   !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   shlat  =      2.        !      shlat = 0 : free slip
+                           !  0 < shlat < 2 : partial slip
+                           !      shlat = 2 : no slip
+                           !  2 < shlat     : strong slip
+/
+!-----------------------------------------------------------------------
+&namcro   !   cross land advection
+!-----------------------------------------------------------------------
+!  n_cla   advection between 2 ocean pts separates by land 
+   n_cla   = 1
+/
+!-----------------------------------------------------------------------
+&namobc   !   open boundaries parameters                            ("key_obc")
+!-----------------------------------------------------------------------
+    nobc_dta    =    0     !  = 0 the obc data are equal to the initial state
+                           !  = 1 the obc data are read in 'obc   .dta' files
+    rdpein      =    1.    !  ???
+    rdpwin      =    1.    !  ???
+    rdpnin      =   30.    !  ???
+    rdpsin      =    1.    !  ???
+    rdpeob      = 1500.    !  time relaxation (days) for the east  open boundary
+    rdpwob      =   15.    !    "        "           for the west  open boundary
+    rdpnob      =  150.    !    "        "           for the north open boundary
+    rdpsob      =   15.    !    "        "           for the south open boundary
+    zbsic1      =  140.e+6 !  barotropic stream function on first  isolated coastline
+    zbsic2      =    1.e+6 !    "                   "    on second isolated coastline
+    zbsic3      =    0.    !    "                   "    on thrid  isolated coastline
+    ln_obc_clim = .true.   !  climatological obc data files (default T)
+    ln_vol_cst  = .true.   !  total volume conserved
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition                ("key_trabbc")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nambfr   !   bottom friction
+!-----------------------------------------------------------------------
+   nbotfr =       1        !  type of bottom friction :   = 0 : no slip        ,  = 2 : nonlinear friction
+                           !                              = 1 : linear friction,  = 3 : free slip
+   bfri1  =   4.e-4        !  bottom drag coefficient (linear case)
+   bfri2  =   1.e-3        !  bottom drag coefficient (non linear case)
+   bfeb2  =  2.5e-3        !  bottom turbulent kinetic energy background  (m^2/s^2)
+/
+!-----------------------------------------------------------------------
+&nambbc   !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ngeo_flux =  2             !  = 0 no geothermal heat flux
+                              !  = 1 constant geothermal heat flux
+                              !  = 2 variable geothermal heat flux (read in geothermal_heating.nc in mW/m2) 
+   ngeo_flux_const = 86.4e-3  !  Constant value of geothermal heat flux (W/m2)
+/
+
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos        equation of state
+!!   nam_traadv    advection scheme
+!!   nam_traldf    lateral diffusion scheme
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl_dif","key_trabbl_adv")
+!!   namdmp        tracer newtonian damping                             ("key_tradmp")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nameos   !   ocean physical parameters
+!-----------------------------------------------------------------------
+   neos   =      0         !  type of equation of state and Brunt-Vaisala frequency
+                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
+                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
+                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
+   ralpha =  2.e-4         !  thermal expension coefficient (neos= 1 or 2)
+   rbeta  =  0.001         !  saline  expension coefficient (neos= 2)
+/
+!-----------------------------------------------------------------------
+&nam_traadv   !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .true.    !  2nd order centered scheme    (default T)
+   ln_traadv_tvd    =  .false.   !  TVD scheme                   (default F)
+   ln_traadv_muscl  =  .false.   !  MUSCL scheme                 (default F)
+   ln_traadv_muscl2 =  .false.   !  MUSCL2 scheme                (default F)
+   ln_traadv_ubs    =  .false.   !  UBS scheme                   (default F)
+/
+!-----------------------------------------------------------------------
+&nam_traldf   !   lateral diffusion scheme for tracer 
+!-----------------------------------------------------------------------
+!                                !  Type of the operator : 
+   ln_traldf_lap    =  .true.    !     laplacian operator          (default T)
+   ln_traldf_bilap  =  .false.   !     bilaplacian operator        (default F)
+                                 !  Direction of action  :
+   ln_traldf_level  =  .false.   !     iso-level                   (default F)
+   ln_traldf_hor    =  .false.   !     horizontal (geopotential)   (default F)   (require "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .true.    !     iso-neutral                 (default T)   (require "key_ldfslp")
+!                                !  Coefficient
+   aht0    =  2000.              !     horizontal eddy diffusivity for tracers (m2/s)
+   ahtb0   =     0.              !     background eddy diffusivity for isopycnal diffusion (m2/s)
+   aeiv0   =  2000.              !     eddy induced velocity coefficient (m2/s)  (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&nam_trabbl   !   bottom boundary layer scheme                          ("key_trabbl_dif","key_trabbl_adv")
+!-----------------------------------------------------------------------
+!  "key_trabbl	                  ! diffusive bbl 
+!  "key_trabbl_adv               ! advective bbl 
+   atrbbl = 10000.               !  lateral tracer coeff. for bottom boundary layer scheme (m2/s)
+/
+!-----------------------------------------------------------------------
+&namdmp   tracer newtonian damping ('key_tradmp')
+!-----------------------------------------------------------------------
+   ndmp   =   -1                 !  type of damping in temperature and salinity 
+                                 !     ='latitude', damping poleward of 'ndmp' degrees and function 
+                                 !                  of the distance-to-coast. Red and Med Seas as ndmp=-1
+                                 !     =-1 damping only in Med and Red Seas
+   ndmpf  =    1                 !  =1 create a damping.coeff NetCDF file (the 3D damping array)
+   nmldmp =    1                 !  type of damping in the mixed layer
+                                 !     =0 damping throughout the water column
+                                 !     =1 no damping in the mixed layer defined by avt >5cm2/s )
+                                 !     =2 no damping in the mixed layer defined rho<rho(surf)+.01 )
+   sdmp   =  50.                 !  surface time scale for internal damping (days)
+   bdmp   = 360.                 !  bottom  time scale for internal damping (days)
+   hdmp   = 800.                 !  depth of transition between sdmp and bdmp (meters)
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   nam_dynvor    advection scheme
+!!   nam_dynhpg    hydrostatic pressure gradient
+!!   namflg        hydrostatic pressure gradient time stepping
+!!   nam_dynldf    lateral diffusion scheme
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&nam_dynvor   !   option of physics/algorithm 
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false.    !  enstrophy conserving scheme (default T)
+   ln_dynvor_ens = .true.     !  energy conserving scheme    (default F)
+   ln_dynvor_mix = .false.    !  mixed scheme                (default F)
+   ln_dynvor_een = .false.    !  energy & enstrophy scheme   (default F)
+/
+!-----------------------------------------------------------------------
+&nam_dynhpg   !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco = .false.       !  z-coordinate - full steps                   
+   ln_hpg_zps = .true.        !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco = .false.       !  s-coordinate (standard jacobian formulation)
+   ln_hpg_hel = .false.       !  s-coordinate (helsinki modification)
+   ln_hpg_wdj = .false.       !  s-coordinate (weighted density jacobian)
+   ln_hpg_djc = .false.       !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_rot = .false.       !  s-coordinate (ROTated axes scheme)
+   gamm       = 0.e0          !  weighting coefficient (wdj scheme)
+/
+!-----------------------------------------------------------------------
+&namflg   !   algorithm flags (algorithm not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynhpg_imp   =  .false. !  hydrostatic pressure gradient: semi-implicit time scheme  (T)
+                              !                                 centered      time scheme  (F)
+   nn_dynhpg_rst   =  0       !  add dynhpg implicit variables in restart ot not (1/0)
+/
+!-----------------------------------------------------------------------
+!nam_dynspg   !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                                !  explicit free surface               ("key_dynspg_exp")
+!                                !  filtered free surface               ("key_dynspg_flt")
+!                                !  split-explicit free surface         ("key_dynspg_ts")
+!                                !  rigid-lid                           ("key_dynspg_rl")
+
+!-----------------------------------------------------------------------
+&nam_dynldf   !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+                                 !  Type of the operator : 
+   ln_dynldf_lap    =  .true.    !     laplacian operator          (default T)
+   ln_dynldf_bilap  =  .false.   !     bilaplacian operator        (default F)
+                                 !  Direction of action  : 
+   ln_dynldf_level  =  .false.   !     iso-level                   (default F)
+   ln_dynldf_hor    =  .true.    !     horizontal (geopotential)   (default F)   (require "key_ldfslp" in s-coord.)
+   ln_dynldf_iso    =  .false.   !     iso-neutral                 (default T)   (require "key_ldfslp")
+                                 !  Coefficient
+   ahm0    = 40000.              !     horizontal eddy viscosity for the dynamics (m2/s)
+   ahmb0   =     0.              !     background eddy viscosity for isopycnal diffusion (m2/s)
+/
+
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!       namzdf        vertical physics
+!!       namnpc        non penetrative convection                       
+!!       nambbl        bottom boundary layer scheme                     ("key_trabbl_dif", "key_trabbl_adv")
+!!       namric        richardson number dependent vertical mixing      ("key_zdfric"      )
+!!       namtke        TKE dependent vertical mixing                    ("key_zdftke"      )
+!!       namkpp        KPP dependent vertical mixing                    ("key_zdfkpp"      )
+!!       namddm        double diffusive mixing parameterization         ("key_zdfddm"      )
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namzdf   !   vertical physics
+!-----------------------------------------------------------------------
+   ln_zdfnpc = .false.        !  Non-Penetrative Convection          (default T)
+   avm0      = 1.2e-4         !  vertical eddy viscosity   for the dynamic (m2/s)   (background Kz if not "key_zdfcst")
+   avt0      = 1.2e-5         !  vertical eddy diffusivity for tracers     (m2/s)   (background Kz if not "key_zdfcst")
+   ln_zdfevd = .true.         !  enhanced vertical diffusion         (default T)
+   avevd     =   100.         !  vertical coefficient for enhanced diffusion scheme (m2/s)
+   n_evdm    =     0          !  enhanced mixing apply on tracer (=0) or on tracer and momentum (=1)
+   ln_zdfexp =  .false.       !  =T/F  split explicit / implicit      (Default=F)
+   n_zdfexp  =     3          !  number of sub-timestep for ln_zdfexp=T
+/
+!-----------------------------------------------------------------------
+&namnpc   !   non penetrative convection
+!-----------------------------------------------------------------------
+   nnpc1  =      1            !  non penetrative convective scheme computation frequency
+   nnpc2  =    365            !  non penetrative convective scheme print frequency
+/
+!-----------------------------------------------------------------------
+&namric   richardson number dependent vertical diffusion                ("key_zdfric" )
+!-----------------------------------------------------------------------
+   avmri = 100.e-4            !  maximum value of the vertical viscosity
+   alp   =      5.            !  coefficient of the parameterization
+   nric  =       2            !  coefficient of the parameterization
+/
+!-----------------------------------------------------------------------
+&namtke   !   turbulent eddy kinetic dependent vertical diffusion       ("key_zdftke" )
+!-----------------------------------------------------------------------
+   ln_rstke = .false.         !  flag to restart with tke from a run without tke (default F)
+   ediff =       0.1          !  coef. to compute vertical eddy coef. (avt=ediff*mxl*sqrt(e) )
+   ediss =       0.7          !  coef. of the Kolmogoroff dissipation
+   ebb   =      3.75          !  coef. of the surface input of tke
+   efave =        1.          !  coef. to applied to the tke diffusion ( avtke=efave*avm )
+   emin  =     1.e-6          !  minimum value of tke (m^2/s^2)
+   emin0 =     1.e-4          !  surface minimum value of tke (m^2/s^2)
+   nitke =        50          !  number of restart iterative loops
+!! ri_c  =         0.22222222 !  critic richardson number (default = 2/9)
+   nmxl  =         2          !  mixing length    = 0 bounded by the distance to surface and bottom
+                              !                   = 1 bounded by the local vertical scale factor
+                              !                   = 2 first vertical derivative of mixing length bounded by 1
+   npdl  =         1          !  prandtl number   = 0 no vertical prandtl number (avt=avm)
+                              !                   = 1 prandtl number function of richarson number (avt=pdl*avm)
+                              !                   = 2 same as = 1 but a shapiro filter is applied on pdl
+   nave  =         1          !  horizontal averaged (=1) or not (=0) on avt and amv   (default =1)
+   navb  =         0          !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namkpp   !   K-Profile Parameterization dependent vertical mixing      ("key_zdfkpp", and optionnally:
+!                                                                        "key_kppcustom" or "key_kpplktb")
+!-----------------------------------------------------------------------
+   ln_kpprimix  = .true.      !  shear instability mixing  (default T)
+   difmiw       =  1.0e-04    !  constant internal wave viscosity (m2/s)
+   difsiw       =  0.1e-04    !  constant internal wave diffusivity (m2/s)
+   Riinfty      =  0.8        !  local Richardson Number limit for shear instability
+   difri        =  0.0050     !  maximum shear mixing at Rig = 0    (m2/s)
+   bvsqcon      = -0.01e-07   !  Brunt-Vaisala squared (1/s**2) for maximum convection
+   difcon       =  1.         !  maximum mixing in interior convection (m2/s)
+   navb         =  0          !  horizontal averaged (=1) or not (=0) on avt and amv   (default =1)
+   nave         =  1          !  constant (=0) or profile (=1) background on avt
+/
+!-----------------------------------------------------------------------
+&namddm   !   double diffusive mixing parameterization                  ("key_zdfddm")
+!-----------------------------------------------------------------------
+      avts  = 1.e-4           !  maximum avs (vertical mixing on salinity)
+      hsbfr = 1.6             !  heat/salt buoyancy flux ratio
+/
+
+!!======================================================================
+!!                  ***  Miscelaneous namelists  ***
+!!======================================================================
+!!   namsol      elliptic solver / island / free surface 
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namsol   !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+   nsolv     =      1         !  type of elliptic solver  =1 preconditioned conjugate gradient (pcg)
+                              !                           =2 successive-over-relaxation (sor)
+                              !                           =3 FETI (fet)                               ("key_feti")
+                              !                           =4 sor with extra outer halo
+   nsol_arp  =      0         !  absolute/relative (0/1) precision convergence test
+   nmin      =    300         !  minimum of iterations for the SOR solver
+   nmax      =    800         !  maximum of iterations for the SOR solver
+   nmod      =     10         !  frequency of test for the SOR solver
+   eps       =  1.E-6         !  absolute precision of the solver
+   resmax    = 1.E-10         !  absolute precision for the SOR solver
+   sor       =   1.92         !  optimal coefficient for SOR solver
+   epsisl    = 1.e-10         !  absolute precision on stream function solver
+   nmisl     =   4000         !  maximum pcg iterations for island                                    ("key_islands")
+   rnu       =     1.         !  strength of the additional force used in filtered free surface
+/
+
+!!======================================================================
+!!                       ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         ("key_trddyn","key_trdtra","key_trdmld")
+!!   namgap       level mean model-data gap                             ("key_diagap")
+!!   namptr       Poleward Transport Diagnostics                        ("key_diaspr")
+!!   namspr       surface pressure diagnosed in rigid-lid               ("key_diaspr")
+!!   namflo       float parameters                                      ("key_float")
+!!======================================================================
+
+!-----------------------------------------------------------------------
+&namtrd    !   diagnostics on dynamics and/or tracer trends             ("key_trddyn" and/or "key_trdtra")
+!                          or mixed-layer trends                        ('key_trdmld')
+!                          or barotropic vorticity                      ("key_trdvor")
+!-----------------------------------------------------------------------
+   ntrd  = 365                   !  time step frequency dynamics and tracers trends
+   nctls =   0                   !  control surface type in mixed-layer trends (0,1 or n<jpk)
+   ln_trdmld_restart = .false.   !  restart for ML diagnostics
+   ucf   =  1.                   !  unit conversion factor (=1 -> /seconds | =86400. -> /day)
+   ln_trdmld_instant = .false.   !  flag to diagnose trends of instantantaneous or mean ML T/S
+/
+!-----------------------------------------------------------------------
+&namgap    !   level mean model-data gap                                ('key_diagap')
+!-----------------------------------------------------------------------
+   ngap =  15                    !  time-step frequency of model-data gap computation
+   nprg =  10                    !  time-step frequency of gap print in model output
+/
+!-----------------------------------------------------------------------
+&namptr   !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+   ln_diaptr = .false.           !  logical flag for Poleward transport computation
+   ln_subbas = .false.           !  logical flag for Atlantic/Pacific/Indian basins computation
+                                 !  need input basins mask file named "subbasins.nc"
+   nf_ptr    =  15               !  Frequency of computation
+/
+!-----------------------------------------------------------------------
+&namspr  !   surface pressure diagnostic
+!-----------------------------------------------------------------------
+   nmaxp   =   1000              !  maximum of iterations for the solver
+   epsp    =  1.e-3              !  absolute precision of the solver
+   niterp  =    400              !  number of iteration done by the solver
+/
+!-----------------------------------------------------------------------
+&namflo    !   float parameters                                         ("key_float")
+!-----------------------------------------------------------------------
+    ln_rstflo = .false.          !  boolean term for float restart (true or false)
+    nwritefl  =      75          !  frequency of float output file 
+    nstockfl  =    5475          !  frequency of float restart file 
+    ln_argo   = .false.          !  Argo type floats (stay at the surface each 10 days)
+    ln_flork4 = .false.          !  = T trajectories computed with a 4th order Runge-Kutta
+                                 !  = F  (default)   computed with Blanke' scheme
+/
Index: /branches/DEV_r1837_MLF/EXTERNAL/MISC/README
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/MISC/README	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/MISC/README	(revision 1844)
@@ -0,0 +1,5 @@
+07/28/2009: rblod
+
+Some perl scripts to create AA_make for XMLF90 and XMLIOSERVER, based on makemake by Michael Wester:
+- makemake_XMLF90.perl
+- makemake_XMLIO.perl
Index: /branches/DEV_r1837_MLF/EXTERNAL/README
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/README	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/README	(revision 1844)
@@ -0,0 +1,4 @@
+07/28/2009: rblod
+
+Directory to store external elements coupled with NEMO under the name of the component_N.
+Directory MISC is a clever name for garbage.
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make	(revision 1844)
@@ -0,0 +1,144 @@
+VPATH=../src/cml:../src/dom:../src/sax:../src/strings:../src/xpath:../src/wxml
+MAKE_NAM = $(MAKE)
+ifneq ($(MAKE_NAM),$(M_K))
+ @$(error You must invoke this Makefile with the $(M_K) command)
+endif
+USER_DIR = $(shell /bin/pwd)
+MAKE_DIR = '??'
+ifneq ($(USER_DIR),$(MAKE_DIR))
+ @$(error You must invoke this Makefile from its directory)
+endif
+#-
+#-Q- sxdkrz F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
+#-Q- es2 F_O = $(F_D) $(F_P) -C vsafe -I $(MODDIR)
+#-Q- sx8brodie F_O = $(F_D) $(F_P) -I $(MODDIR)
+#-Q- sx6nec F_O = $(F_D) $(F_P) -size_t64 -Wf,"-pvctl loopcnt=999999" -I $(MODDIR)
+#-Q- sx8mercure F_O = $(F_D) $(F_P) -size_t64 -Wf,"-pvctl loopcnt=999999" -I $(MODDIR)
+#-Q- sx9mercure F_O = $(F_D) $(F_P) -size_t64 -Wf,"-pvctl loopcnt=999999" -I $(MODDIR)
+#-Q- aix6 F_O = $(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+#-Q- aix F_O = $(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+#-Q- osxxlf = $(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+#---------------------------------------------------------------------
+#- Create libxmlf90
+#---------------------------------------------------------------------
+
+.PRECIOUS : $(MODEL_LIB)
+SXMODEL_LIB = $(MODEL_LIB)
+ifeq ($(L_X),1)
+SXMODEL_LIB = $(LIBDIR)/libsxxmlf90.a
+.PRECIOUS : $(SXMODEL_LIB)
+endif
+
+MODS1 =	../src/cml/flib_cml.f90 ../src/cml/m_cmlw.f90 ../src/cml/m_stmw.f90 \
+	../src/dom/flib_dom.f90 ../src/dom/m_dom_attribute.f90 \
+	../src/dom/m_dom_debug.f90 ../src/dom/m_dom_document.f90 \
+	../src/dom/m_dom_element.f90 ../src/dom/m_dom_error.f90 \
+	../src/dom/m_dom_namednodemap.f90 ../src/dom/m_dom_node.f90 \
+	../src/dom/m_dom_nodelist.f90 ../src/dom/m_dom_parse.f90 \
+	../src/dom/m_dom_types.f90 ../src/dom/m_dom_utils.f90 \
+	../src/sax/flib_sax.f90 ../src/sax/m_buffer.f90 \
+	../src/sax/m_charset.f90 ../src/sax/m_converters.f90 \
+	../src/sax/m_debug.f90 ../src/sax/m_dictionary.f90 \
+	../src/sax/m_elstack.f90 ../src/sax/m_entities.f90 \
+	../src/sax/m_fsm.f90 ../src/sax/m_io.f90 ../src/sax/m_reader.f90 \
+	../src/sax/m_xml_error.f90 ../src/sax/m_xml_parser.f90 \
+	../src/strings/m_strings.f90 ../src/wxml/flib_wxml.f90 \
+	../src/wxml/m_wxml_buffer.f90 ../src/wxml/m_wxml_core.f90 \
+	../src/wxml/m_wxml_dictionary.f90 ../src/wxml/m_wxml_elstack.f90 \
+	../src/wxml/m_wxml_text.f90 ../src/xpath/flib_xpath.f90 \
+	../src/xpath/m_path.f90 ../src/xpath/m_path_orig.f90 \
+	../src/xpath/match_tester.f90
+
+OBJSMODS1 =	flib_cml.o m_cmlw.o m_stmw.o flib_dom.o m_dom_attribute.o \
+	m_dom_debug.o m_dom_document.o m_dom_element.o m_dom_error.o \
+	m_dom_namednodemap.o m_dom_node.o m_dom_nodelist.o m_dom_parse.o \
+	m_dom_types.o m_dom_utils.o flib_sax.o m_buffer.o m_charset.o \
+	m_converters.o m_debug.o m_dictionary.o m_elstack.o m_entities.o \
+	m_fsm.o m_io.o m_reader.o m_xml_error.o m_xml_parser.o m_strings.o \
+	flib_wxml.o m_wxml_buffer.o m_wxml_core.o m_wxml_dictionary.o \
+	m_wxml_elstack.o m_wxml_text.o flib_xpath.o m_path.o m_path_orig.o \
+	match_tester.o
+
+all: dirxml $(MODEL_LIB)($(OBJSMODS1))
+	@echo XMLF90 is OK
+
+#---USE VPATH--- $(MODEL_LIB)(%.o): ../*/*/%.f90
+$(MODEL_LIB)(%.o): %.f90
+	$(F_C) $(F_O) -I$(NCDF_INC) $<
+	$(A_C) $(MODEL_LIB) $*.o
+ifeq ($(L_X),1)
+	$(A_X) $(SXMODEL_LIB) $*.o
+endif
+#-Q- sgi6       mv $(shell echo $* | tr '[:lower:]' '[:upper:]').mod $(MODDIR)
+ifeq ($(M_M),1)
+	@mv -f *.mod $(MODDIR)  2> /dev/null || true
+endif
+	$(RM) $*.o
+
+dirxml: 
+	@if [ ! -d ../../../lib/libxmlio_server ] ; then mkdir ../../../lib/libxmlio_server ; fi
+
+clean:
+	$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L
+	$(RM)  $(MODEL_LIB) 
+
+$(MODEL_LIB)(flib_cml.o): $(MODEL_LIB)(m_cmlw.o) $(MODEL_LIB)(m_stmw.o)
+$(MODEL_LIB)(m_cmlw.o): $(MODEL_LIB)(m_stmw.o) $(MODEL_LIB)(flib_wxml.o)
+$(MODEL_LIB)(m_stmw.o): $(MODEL_LIB)(flib_wxml.o)
+$(MODEL_LIB)(flib_dom.o): $(MODEL_LIB)(m_dom_attribute.o) \
+	$(MODEL_LIB)(m_dom_document.o) $(MODEL_LIB)(m_dom_element.o) \
+	$(MODEL_LIB)(m_dom_namednodemap.o) $(MODEL_LIB)(m_dom_node.o) \
+	$(MODEL_LIB)(m_dom_nodelist.o) $(MODEL_LIB)(m_dom_parse.o) \
+	$(MODEL_LIB)(m_dom_types.o) $(MODEL_LIB)(m_dom_utils.o) \
+	$(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_attribute.o): $(MODEL_LIB)(m_dom_node.o) \
+	$(MODEL_LIB)(m_dom_types.o) $(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_document.o): $(MODEL_LIB)(m_dom_types.o) \
+	$(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_element.o): $(MODEL_LIB)(m_dom_attribute.o) \
+	$(MODEL_LIB)(m_dom_debug.o) $(MODEL_LIB)(m_dom_document.o) \
+	$(MODEL_LIB)(m_dom_namednodemap.o) $(MODEL_LIB)(m_dom_node.o) \
+	$(MODEL_LIB)(m_dom_nodelist.o) $(MODEL_LIB)(m_dom_types.o) \
+	$(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_namednodemap.o): $(MODEL_LIB)(m_dom_types.o) \
+	$(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_node.o): $(MODEL_LIB)(m_dom_debug.o) \
+	$(MODEL_LIB)(m_dom_error.o) $(MODEL_LIB)(m_dom_namednodemap.o) \
+	$(MODEL_LIB)(m_dom_nodelist.o) $(MODEL_LIB)(m_dom_types.o) \
+	$(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_nodelist.o): $(MODEL_LIB)(m_dom_types.o)
+$(MODEL_LIB)(m_dom_parse.o): $(MODEL_LIB)(m_dom_debug.o) \
+	$(MODEL_LIB)(m_dom_document.o) $(MODEL_LIB)(m_dom_element.o) \
+	$(MODEL_LIB)(m_dom_node.o) $(MODEL_LIB)(m_dom_types.o) \
+	$(MODEL_LIB)(flib_sax.o)
+$(MODEL_LIB)(m_dom_types.o): $(MODEL_LIB)(m_strings.o)
+$(MODEL_LIB)(m_dom_utils.o): $(MODEL_LIB)(m_dom_debug.o) \
+	$(MODEL_LIB)(m_dom_document.o) $(MODEL_LIB)(m_dom_element.o) \
+	$(MODEL_LIB)(m_dom_namednodemap.o) $(MODEL_LIB)(m_dom_node.o) \
+	$(MODEL_LIB)(m_dom_types.o) $(MODEL_LIB)(m_strings.o) \
+	$(MODEL_LIB)(flib_wxml.o)
+$(MODEL_LIB)(flib_sax.o): $(MODEL_LIB)(m_converters.o) \
+	$(MODEL_LIB)(m_dictionary.o) $(MODEL_LIB)(m_xml_error.o) \
+	$(MODEL_LIB)(m_xml_parser.o)
+$(MODEL_LIB)(m_converters.o): $(MODEL_LIB)(m_debug.o)
+$(MODEL_LIB)(m_dictionary.o): $(MODEL_LIB)(m_buffer.o)
+$(MODEL_LIB)(m_elstack.o): $(MODEL_LIB)(m_buffer.o)
+$(MODEL_LIB)(m_entities.o): $(MODEL_LIB)(m_buffer.o)
+$(MODEL_LIB)(m_fsm.o): $(MODEL_LIB)(m_buffer.o) $(MODEL_LIB)(m_charset.o) \
+	$(MODEL_LIB)(m_dictionary.o) $(MODEL_LIB)(m_elstack.o) \
+	$(MODEL_LIB)(m_entities.o)
+$(MODEL_LIB)(m_reader.o): $(MODEL_LIB)(m_io.o)
+$(MODEL_LIB)(m_xml_error.o): $(MODEL_LIB)(m_elstack.o)
+$(MODEL_LIB)(m_xml_parser.o): $(MODEL_LIB)(m_buffer.o) \
+	$(MODEL_LIB)(m_debug.o) $(MODEL_LIB)(m_dictionary.o) \
+	$(MODEL_LIB)(m_elstack.o) $(MODEL_LIB)(m_entities.o) \
+	$(MODEL_LIB)(m_fsm.o) $(MODEL_LIB)(m_reader.o) \
+	$(MODEL_LIB)(m_xml_error.o)
+$(MODEL_LIB)(flib_wxml.o): $(MODEL_LIB)(m_wxml_core.o) \
+	$(MODEL_LIB)(m_wxml_text.o)
+$(MODEL_LIB)(m_wxml_core.o): $(MODEL_LIB)(m_wxml_buffer.o) \
+	$(MODEL_LIB)(m_wxml_dictionary.o) $(MODEL_LIB)(m_wxml_elstack.o)
+$(MODEL_LIB)(flib_xpath.o): $(MODEL_LIB)(flib_sax.o) \
+	$(MODEL_LIB)(m_path_orig.o)
+$(MODEL_LIB)(m_path.o): $(MODEL_LIB)(flib_sax.o)
+$(MODEL_LIB)(m_path_orig.o): $(MODEL_LIB)(flib_sax.o)
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/AA_make.ldef	(revision 1844)
@@ -0,0 +1,12 @@
+#-
+#- $Id: $
+#-
+#---------------------------------------------------------------------
+#- Local parameters for "libxml90"
+#---------------------------------------------------------------------
+SHELL = /bin/ksh
+#---------------------------------------------------------------------
+LIBDIR = ../../../lib/libxmlio_server
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+MODEL_LIB = $(LIBDIR)/libxmlf90.a
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/makemake_XMLF90.perl
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/makemake_XMLF90.perl	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLF90/makemake_XMLF90.perl	(revision 1844)
@@ -0,0 +1,286 @@
+#!/usr/bin/perl
+#
+# Usage: makemake {<program name> {<F90 compiler or fc or f77 or cc or c>}}
+#
+# Generate a Makefile from the sources in the current directory.  The source
+# files may be in either C, FORTRAN 77, Fortran 90 or some combination of
+# these languages.  If the F90 compiler specified is cray or parasoft, then
+# the Makefile generated will conform to the conventions of these compilers.
+# To run makemake, it will be necessary to modify the first line of this script
+# to point to the actual location of Perl on your system.
+#
+# Written by Michael Wester <wester@math.unm.edu> February 16, 1995
+# Cotopaxi (Consulting), Albuquerque, New Mexico
+#
+open(MAKEFILE, "> AA_make");
+#
+#print MAKEFILE "PROG =\t$ARGV[0]\n\n";
+#
+# Misc
+
+print MAKEFILE "VPATH=../src/cml:../src/dom:../src/sax:../src/strings:../src/xpath:../src/wxml\n";
+print MAKEFILE "MAKE_NAM = \$(MAKE)\n";
+print MAKEFILE "ifneq (\$(MAKE_NAM),\$(M_K))\n";
+print MAKEFILE " \@\$(error You must invoke this Makefile with the \$(M_K) command)\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "USER_DIR = \$(shell /bin/pwd)\n";
+print MAKEFILE "MAKE_DIR = '??'\n";
+print MAKEFILE "ifneq (\$(USER_DIR),\$(MAKE_DIR))\n";
+print MAKEFILE " \@\$(error You must invoke this Makefile from its directory)\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-\n";
+print MAKEFILE "#-Q- sxdkrz F_O = \$(F_D) \$(F_P) -C vsafe -size_t64 -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- es2 F_O = \$(F_D) \$(F_P) -C vsafe -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- sx8brodie F_O = \$(F_D) \$(F_P) -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- sx6nec F_O = \$(F_D) \$(F_P) -size_t64 -Wf\,\"-pvctl loopcnt=999999\" -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- sx8mercure F_O = \$(F_D) \$(F_P) -size_t64 -Wf\,\"-pvctl loopcnt=999999\" -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- sx9mercure F_O = \$(F_D) \$(F_P) -size_t64 -Wf\,\"-pvctl loopcnt=999999\" -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- aix6 F_O = \$(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- aix F_O = \$(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- osxxlf = \$(F_P) -O3 -qextname -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "#---------------------------------------------------------------------\n";
+print MAKEFILE "#- Create libxmlf90\n";
+print MAKEFILE "#---------------------------------------------------------------------\n\n";
+
+print MAKEFILE ".PRECIOUS : \$(MODEL_LIB)\n";
+print MAKEFILE "SXMODEL_LIB = \$(MODEL_LIB)\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "SXMODEL_LIB = \$(LIBDIR)/libsxxmlf90.a\n";
+print MAKEFILE ".PRECIOUS : \$(SXMODEL_LIB)\n";
+print MAKEFILE "endif\n\n";
+
+# Source listing
+#
+print MAKEFILE "MODS1 =\t";
+@srcs = < ../*/*/*.f90 >;
+&PrintWords(8, 0, @srcs);
+print MAKEFILE "\n\n";
+#
+# Object listing
+#
+print MAKEFILE "OBJSMODS1 =\t";
+@objs =  @srcs;
+foreach (@objs) { s/\.[^.]+$/.o/ };
+         foreach $objs (@objs) {
+         @tab = split('/', $objs);
+         $objs = $tab[$#tab] ;
+         };
+
+&PrintWords(8, 0, @objs);
+print MAKEFILE "\n\n";
+#
+# Define common macros
+#
+#print MAKEFILE "LIBS =\t\n\n";
+#print MAKEFILE "CC = cc\n";
+#print MAKEFILE "CFLAGS = -O\n";
+#print MAKEFILE "FC = f77\n";
+#print MAKEFILE "FFLAGS = -O\n";
+#print MAKEFILE "F90 = f90\n";
+#print MAKEFILE "F90FLAGS = -O\n";
+#print MAKEFILE "LDFLAGS = -s\n\n";
+#
+# make
+#
+print MAKEFILE "all: dirxml \$(MODEL_LIB)(\$(OBJSMODS1))\n";
+print MAKEFILE "\t\@echo XMLF90 is OK\n\n";
+
+# .f90 -> .o
+#
+
+print MAKEFILE "#---USE VPATH--- \$(MODEL_LIB)(%.o): ../*/*/%.f90\n";
+print MAKEFILE "\$(MODEL_LIB)(%.o): %.f90\n";
+print MAKEFILE "\t\$(F_C) \$(F_O) -I\$(NCDF_INC) \$<\n";
+print MAKEFILE "\t\$(A_C) \$(MODEL_LIB) \$*.o\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "\t\$(A_X) \$(SXMODEL_LIB) \$*.o\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-Q- sgi6       mv \$(shell echo \$* | tr '[:lower:]' '[:upper:]').mod \$(MODDIR)\n";
+print MAKEFILE "ifeq (\$(M_M),1)\n";
+print MAKEFILE "\t\@mv -f *.mod \$(MODDIR)  2> /dev/null || true\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "\t\$(RM) \$*.o\n\n";;
+
+
+print MAKEFILE "dirxml: \n";
+print MAKEFILE "\t\@if [ ! -d ../../../lib/libxmlio_server ] ; then mkdir ../../../lib/libxmlio_server ; fi\n\n";
+#
+# make clean
+#
+print MAKEFILE "clean:\n";
+print MAKEFILE "\t\$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L\n";
+print MAKEFILE "\t\$(RM)  \$(MODEL_LIB) \n\n";
+#
+#
+# Dependency listings
+#
+&MakeDependsf90($ARGV[1]);
+&MakeDepends("*.f *.F", '^\s*include\s+["\']([^"\']+)["\']');
+&MakeDepends("*.c",     '^\s*#\s*include\s+["\']([^"\']+)["\']');
+
+#
+# &PrintWords(current output column, extra tab?, word list); --- print words
+#    nicely
+#
+sub PrintWords {
+   local($columns) = 78 - shift(@_);
+   local($extratab) = shift(@_);
+   local($wordlength);
+   #
+   print MAKEFILE @_[0];
+   $columns -= length(shift(@_));
+   foreach $word (@_) {
+      $wordlength = length($word);
+      if ($wordlength + 1 < $columns) {
+         print MAKEFILE " $word";
+         $columns -= $wordlength + 1;
+         }
+      else {
+         #
+         # Continue onto a new line
+         #
+         if ($extratab) {
+            print MAKEFILE " \\\n\t\t$word";
+            $columns = 62 - $wordlength;
+            }
+         else {
+            print MAKEFILE " \\\n\t$word";
+            $columns = 70 - $wordlength;
+            }
+         }
+      }
+   }
+
+#
+# &LanguageCompiler(compiler, sources); --- determine the correct language
+#    compiler
+#
+sub LanguageCompiler {
+   local($compiler) = &toLower(shift(@_));
+   local(@srcs) = @_;
+   #
+   if (length($compiler) > 0) {
+      CASE: {
+         grep(/^$compiler$/, ("fc", "f77")) &&
+            do { $compiler = "FC"; last CASE; };
+         grep(/^$compiler$/, ("cc", "c"))   &&
+            do { $compiler = "CC"; last CASE; };
+         $compiler = "F90";
+         }
+      }
+   else {
+      CASE: {
+         grep(/\.f90$/, @srcs)   && do { $compiler = "F90"; last CASE; };
+         grep(/\.(f|F)$/, @srcs) && do { $compiler = "FC";  last CASE; };
+         grep(/\.c$/, @srcs)     && do { $compiler = "CC";  last CASE; };
+         $compiler = "???";
+         }
+      }
+   $compiler;
+   }
+
+#
+# &toLower(string); --- convert string into lower case
+#
+sub toLower {
+   local($string) = @_[0];
+   $string =~ tr/A-Z/a-z/;
+   $string;
+   }
+
+#
+# &uniq(sorted word list); --- remove adjacent duplicate words
+#
+sub uniq {
+   local(@words);
+   foreach $word (@_) {
+      if ($word ne $words[$#words]) {
+         push(@words, $word);
+         }
+      }
+   @words;
+   }
+
+#
+# &MakeDepends(language pattern, include file sed pattern); --- dependency
+#    maker
+#
+sub MakeDepends {
+   local(@incs);
+   local($lang) = @_[0];
+   local($pattern) = @_[1];
+   #
+   foreach $file (<${lang}>) {
+      open(FILE, $file) || warn "Cannot open $file: $!\n";
+      while (<FILE>) {
+         /$pattern/i && push(@incs, $1);
+         }
+      if (defined @incs) {
+         $file =~ s/\.[^.]+$/.o/;
+         @tab = split('/', $file);
+         $file = '$(MODEL_LIB)(' . $tab[$#tab] . ')' ;
+         print MAKEFILE "$file: ";
+         &PrintWords(length($file) + 2, 0, @incs);
+         print MAKEFILE "\n";
+         undef @incs;
+         }
+      }
+   }
+
+#
+# &MakeDependsf90(f90 compiler); --- FORTRAN 90 dependency maker
+#
+sub MakeDependsf90 {
+   local($compiler) = &toLower(@_[0]);
+   local(@dependencies);
+   local(%filename);
+   local(@incs);
+   local(@modules);
+   local($objfile);
+   #
+   # Associate each module with the name of the file that contains it
+   #
+   foreach $file (<../*/*/*.f90>) {
+      open(FILE, $file) || warn "Cannot open $file: $!\n";
+      while (<FILE>) {
+         /^\s*module\s+([^\s!]+)/i &&
+            ($filename{&toLower($1)} = $file) =~ s/\.f90$/.o/;
+         }
+      }
+   #
+   # Print the dependencies of each file that has one or more include's or
+   # references one or more modules
+   #
+   foreach $file (<../*/*/*.f90>) {
+      open(FILE, $file);
+      while (<FILE>) {
+         /^\s*include\s+["\']([^"\']+)["\']/i && push(@incs, $1);
+         /^\s*use\s+([^\s,!]+)/i && push(@modules, &toLower($1));
+         }
+      if (defined @incs || defined @modules) {
+         ($objfile = $file) =~ s/\.f90$/.o/;
+         @tab = split('/', $objfile);
+         $objfile = '$(MODEL_LIB)(' . $tab[$#tab] . ')' ;
+
+         print MAKEFILE "$objfile: ";
+         undef @dependencies;
+         foreach $module (@modules) {
+            push(@dependencies, $filename{$module});
+            }
+         @dependencies = &uniq(sort(@dependencies));
+
+         foreach $dependencies (@dependencies) {
+         @tab = split('/', $dependencies);
+         $dependencies = '$(MODEL_LIB)(' . $tab[$#tab] . ')';
+         }
+
+         &PrintWords(length($objfile) + 2, 0,
+                     @dependencies, &uniq(sort(@incs)));
+         print MAKEFILE "\n";
+         undef @incs;
+         undef @modules;
+         #
+         #
+         }
+      }
+   }
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make	(revision 1844)
@@ -0,0 +1,332 @@
+VPATH=../src/IOSERVER:../src/XMLIO
+MAKE_NAM = $(MAKE)
+ifneq ($(MAKE_NAM),$(M_K))
+ @$(error You must invoke this Makefile with the $(M_K) command)
+endif
+USER_DIR = $(shell /bin/pwd)
+MAKE_DIR = '??'
+ifneq ($(USER_DIR),$(MAKE_DIR))
+ @$(error You must invoke this Makefile from its directory)
+endif
+#-
+#-Q- sx6nec F_O := $(F_O) -Wf,-ptr byte
+#-Q- sx8brodie F_O := $(F_O) -Wf,-ptr byte
+#-Q- sx8mercure F_O := $(F_O) -Wf,-ptr byte
+#-Q- sx9mercure F_O := $(F_O) -Wf,-ptr byte
+#-Q- sxdkrz F_O := $(F_O) -Wf,-ptr byte
+#-Q- es2 F_O := $(F_O) -Wf,-ptr byte
+#-Q- aix6 F_O = $(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+#-Q- aix F_O = $(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+#-Q- osxxlf F_O = $(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=$(MODDIR) -I $(MODDIR)
+F_O := $(F_O) -I../../../lib
+P_O := $(P_O) -traditional
+#-Q- aix6 L_O = $(F_P) -q64 -O3
+#-Q- aix L_O = $(F_P) -q64 -O3
+prefix=''
+#-Q- aix6 prefix='-WF,'
+#-Q- aix prefix='-WF,'
+override P_P := $(P_P:%=$(prefix)%)
+
+#---------------------------------------------------------------------
+#- Create libioserver and libxmlio
+#---------------------------------------------------------------------
+
+.PRECIOUS : $(MODEL_LIB1) $(MODEL_LIB2)
+SXMODEL_LIB1 = $(MODEL_LIB1)
+SXMODEL_LIB2 = $(MODEL_LIB2)
+ifeq ($(L_X),1)
+SXMODEL_LIB1 = $(LIBDIR)/libsxioserver.a
+SXMODEL_LIB2 = $(LIBDIR)/libsxxmlio.a
+.PRECIOUS : $(SXMODEL_LIB1) $(SXMODEL_LIB2)
+endif
+
+MODS1 =	../src/IOSERVER/mod_ioclient_para.F90 \
+	../src/IOSERVER/mod_ioserver_para.F90 ../src/IOSERVER/mpi_mod.F90 \
+	../src/IOSERVER/mpi_wrapper.F90 ../src/IOSERVER/mpitrace.F90 \
+	../src/IOSERVER/init_vampir.f90 ../src/IOSERVER/main.f90 \
+	../src/IOSERVER/mod_box_grid.f90 ../src/IOSERVER/mod_boxed_domain.f90 \
+	../src/IOSERVER/mod_event_client.f90 \
+	../src/IOSERVER/mod_event_parameters.f90 \
+	../src/IOSERVER/mod_event_server.f90 \
+	../src/IOSERVER/mod_field_bufferize.f90 \
+	../src/IOSERVER/mod_global_memory.f90 \
+	../src/IOSERVER/mod_interface_ioipsl.f90 \
+	../src/IOSERVER/mod_ioclient.f90 ../src/IOSERVER/mod_iomanager.f90 \
+	../src/IOSERVER/mod_ioserver_namelist.f90 \
+	../src/IOSERVER/mod_mpi_buffer_client.f90 \
+	../src/IOSERVER/mod_mpi_buffer_parameters.f90 \
+	../src/IOSERVER/mod_mpi_buffer_server.f90 \
+	../src/IOSERVER/mod_pack.f90 ../src/IOSERVER/mod_prec.f90 \
+	../src/IOSERVER/mod_wait.f90 ../src/IOSERVER/pack_f.f90 \
+	../src/IOSERVER/server.f90
+
+OBJSMODS1 =	mod_ioclient_para.o mod_ioserver_para.o mpi_mod.o mpi_wrapper.o \
+	mpitrace.o init_vampir.o main.o mod_box_grid.o mod_boxed_domain.o \
+	mod_event_client.o mod_event_parameters.o mod_event_server.o \
+	mod_field_bufferize.o mod_global_memory.o mod_interface_ioipsl.o \
+	mod_ioclient.o mod_iomanager.o mod_ioserver_namelist.o \
+	mod_mpi_buffer_client.o mod_mpi_buffer_parameters.o \
+	mod_mpi_buffer_server.o mod_pack.o mod_prec.o mod_wait.o pack_f.o 
+
+MODS2 =	../src/XMLIO/mod_attribut.f90 ../src/XMLIO/mod_attribut_list.f90 \
+	../src/XMLIO/mod_axis.f90 ../src/XMLIO/mod_axis_attribut.f90 \
+	../src/XMLIO/mod_axis_definition.f90 ../src/XMLIO/mod_axis_group.f90 \
+	../src/XMLIO/mod_context.f90 ../src/XMLIO/mod_dependency.f90 \
+	../src/XMLIO/mod_domain.f90 ../src/XMLIO/mod_error_msg.f90 \
+	../src/XMLIO/mod_field.f90 ../src/XMLIO/mod_field_attribute.f90 \
+	../src/XMLIO/mod_field_definition.f90 \
+	../src/XMLIO/mod_field_group.f90 ../src/XMLIO/mod_file.f90 \
+	../src/XMLIO/mod_file_attribut.f90 \
+	../src/XMLIO/mod_file_definition.f90 ../src/XMLIO/mod_file_group.f90 \
+	../src/XMLIO/mod_grid.f90 ../src/XMLIO/mod_grid_attribut.f90 \
+	../src/XMLIO/mod_grid_definition.f90 ../src/XMLIO/mod_grid_group.f90 \
+	../src/XMLIO/mod_object.f90 ../src/XMLIO/mod_parse_xml.f90 \
+	../src/XMLIO/mod_sorted_list.f90 ../src/XMLIO/mod_stdtype.f90 \
+	../src/XMLIO/mod_time_parameters.f90 \
+	../src/XMLIO/mod_xmlio_parameters.f90 ../src/XMLIO/mod_zoom.f90 \
+	../src/XMLIO/mod_zoom_attribut.f90 ../src/XMLIO/string_function.f90 \
+	../src/XMLIO/test_xmlio.f90 ../src/XMLIO/xmlio.f90
+
+OBJSMODS2 =	mod_attribut.o mod_attribut_list.o mod_axis.o mod_axis_attribut.o \
+	mod_axis_definition.o mod_axis_group.o mod_context.o mod_dependency.o \
+	mod_domain.o mod_error_msg.o mod_field.o mod_field_attribute.o \
+	mod_field_definition.o mod_field_group.o mod_file.o \
+	mod_file_attribut.o mod_file_definition.o mod_file_group.o mod_grid.o \
+	mod_grid_attribut.o mod_grid_definition.o mod_grid_group.o \
+	mod_object.o mod_parse_xml.o mod_sorted_list.o mod_stdtype.o \
+	mod_time_parameters.o mod_xmlio_parameters.o mod_zoom.o \
+	mod_zoom_attribut.o string_function.o  xmlio.o
+
+.SUFFIXES: .f90 .F90
+
+all: libioipsl libxmlf90 dirxml $(MODEL_LIB2)($(OBJSMODS2)) key $(MODEL_LIB1)($(OBJSMODS1)) server.o EXEC_BIN
+	@echo IOSERVER is OK
+
+key :
+	-@if [ "`cat KEY_CPP`" != "$(P_P)" ] ; then \
+	echo "$(P_P)" > KEY_CPP ; fi
+
+ifneq  (,$(findstring NO_MPI,$(P_P)))
+EXEC_BIN :
+server.o :
+else
+EXEC_BIN : server.o
+	$(F_L) $(L_O) -o ../../../bin/ioserver server.o $(MODEL_LIB1) $(MODEL_LIB2) ../../../lib/libioipsl.a $(NCDF_LIB) ../../../lib/libxmlio_server/libxmlf90.a
+server.o :       ../src/IOSERVER/server.f90
+	@$(F_C) $(F_O) -c ../src/IOSERVER/server.f90
+endif
+
+#Rules for ioserver
+#---- Using VPATH instead $(MODEL_LIB1)(%.o): ../src/IOSERVER/%.f90
+$(MODEL_LIB1)(%.o): %.f90
+	$(F_C) $(F_O)  -I../src/XMLIO -I../src/IOSERVER -I$(NCDF_INC) $<
+	$(A_C) $(MODEL_LIB1) $*.o
+ifeq ($(L_X),1)
+	$(A_X) $(SXMODEL_LIB1) $*.o
+endif
+#-Q- sgi6       mv $(shell echo $* | tr '[:lower:]' '[:upper:]').mod $(MODDIR)
+ifeq ($(M_M),1)
+	@mv -f *.mod $(MODDIR)  2> /dev/null || true
+endif
+	$(RM) $*.o
+
+#Rules for ioserver
+#---- Using VPATH instead $(MODEL_LIB1)(%.o): ../src/IOSERVER/%.F90
+$(MODEL_LIB1)(%.o): %.F90 KEY_CPP
+	$(F_C) $(F_O) $(P_P) -I$(NCDF_INC) -I../src/XMLIO -I../src/IOSERVER $<
+	$(A_C) $(MODEL_LIB1) $*.o
+ifeq ($(L_X),1)
+	$(A_X) $(SXMODEL_LIB1) $*.o
+endif
+#-Q- sgi6       mv $(shell echo $* | tr '[:lower:]' '[:upper:]').mod $(MODDIR)
+ifeq ($(M_M),1)
+	@mv -f *.mod $(MODDIR)  2> /dev/null || true
+endif
+	$(RM) $*.o
+
+#Rules for xmlio
+#---- Using VPATH instead $(MODEL_LIB1)(%.o): ../src/XMLIO/%.F90
+$(MODEL_LIB2)(%.o): %.f90
+	$(F_C) $(F_O) -I$(NCDF_INC) -I../src/XMLIO $<
+	$(A_C) $(MODEL_LIB2) $*.o
+ifeq ($(L_X),1)
+	$(A_X) $(SXMODEL_LIB2) $*.o
+endif
+#-Q- sgi6       mv $(shell echo $* | tr '[:lower:]' '[:upper:]').mod $(MODDIR)
+ifeq ($(M_M),1)
+	@mv -f *.mod $(MODDIR)  2> /dev/null || true
+endif
+	$(RM) $*.o
+
+dirxml: 
+	@if [ ! -d ../../../lib/libxmlio_server ] ; then mkdir ../../../lib/libxmlio_server ; fi
+
+# IOIPSL library
+libioipsl :
+	(cd ../../IOIPSL/src ; $(M_K) -f Makefile )
+
+# XMLF90 library
+libxmlf90 :
+	(cd ../../XMLF90/external ; $(M_K) -f Makefile )
+
+clean:
+	$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L
+	$(RM) server.o $(MODEL_LIB1) $(MODEL_LIB2)
+
+$(MODEL_LIB1)(init_vampir.o): $(MODEL_LIB1)(mpitrace.o)
+$(MODEL_LIB1)(main.o): $(MODEL_LIB1)(mod_pack.o) $(MODEL_LIB1)(mod_wait.o)
+$(MODEL_LIB1)(mod_event_client.o): $(MODEL_LIB1)(mod_event_parameters.o) \
+	$(MODEL_LIB1)(mod_iomanager.o) $(MODEL_LIB1)(mod_ioserver_namelist.o) \
+	$(MODEL_LIB1)(mod_mpi_buffer_client.o) $(MODEL_LIB1)(mod_pack.o) \
+	$(MODEL_LIB1)(mod_attribut.o)
+$(MODEL_LIB1)(mod_event_server.o): $(MODEL_LIB1)(mod_event_parameters.o) \
+	$(MODEL_LIB1)(mod_iomanager.o) $(MODEL_LIB1)(mod_pack.o) \
+	$(MODEL_LIB1)(mod_attribut.o)
+$(MODEL_LIB1)(mod_global_memory.o): $(MODEL_LIB1)(mpi_mod.o)
+$(MODEL_LIB1)(mod_interface_ioipsl.o): $(MODEL_LIB1)(mod_ioserver_para.o) \
+	$(MODEL_LIB2)
+$(MODEL_LIB1)(mod_ioclient.o): $(MODEL_LIB1)(mod_event_client.o) \
+	$(MODEL_LIB1)(mod_ioclient_para.o) $(MODEL_LIB1)(mod_iomanager.o) \
+	$(MODEL_LIB1)(mod_ioserver_namelist.o) \
+	$(MODEL_LIB1)(mod_mpi_buffer_client.o) $(MODEL_LIB1)(mod_wait.o) \
+	$(MODEL_LIB1)(mpi_mod.o)
+$(MODEL_LIB1)(mod_iomanager.o): $(MODEL_LIB1)(mod_field_bufferize.o) \
+	$(MODEL_LIB1)(mod_interface_ioipsl.o) $(MODEL_LIB1)(mod_attribut.o) \
+	$(MODEL_LIB1)(mod_axis.o) $(MODEL_LIB1)(mod_axis_group.o) \
+	$(MODEL_LIB1)(mod_field.o) $(MODEL_LIB1)(mod_field_group.o) \
+	$(MODEL_LIB1)(mod_file.o) $(MODEL_LIB1)(mod_file_group.o) \
+	$(MODEL_LIB1)(mod_grid.o) $(MODEL_LIB1)(mod_grid_group.o) \
+	$(MODEL_LIB1)(mod_object.o) $(MODEL_LIB1)(mod_zoom.o) $(MODEL_LIB2)
+$(MODEL_LIB1)(mod_mpi_buffer_client.o): $(MODEL_LIB1)(mod_global_memory.o) \
+	$(MODEL_LIB1)(mod_ioclient_para.o) \
+	$(MODEL_LIB1)(mod_mpi_buffer_parameters.o) $(MODEL_LIB1)(mod_pack.o) \
+	$(MODEL_LIB1)(mod_wait.o) $(MODEL_LIB1)(mpi_mod.o) \
+	$(MODEL_LIB1)(mpitrace.o)
+$(MODEL_LIB1)(mod_mpi_buffer_parameters.o): $(MODEL_LIB1)(mod_ioserver_namelist.o)
+$(MODEL_LIB1)(mod_mpi_buffer_server.o): $(MODEL_LIB1)(mod_event_server.o) \
+	$(MODEL_LIB1)(mod_global_memory.o) $(MODEL_LIB1)(mod_ioserver_para.o) \
+	$(MODEL_LIB1)(mod_mpi_buffer_parameters.o) $(MODEL_LIB1)(mod_pack.o) \
+	$(MODEL_LIB1)(mod_wait.o) $(MODEL_LIB1)(mpi_mod.o) \
+	$(MODEL_LIB1)(mpitrace.o)
+$(MODEL_LIB1)(mod_pack.o): $(MODEL_LIB1)(mod_attribut.o) \
+	$(MODEL_LIB1)(mod_stdtype.o)
+$(MODEL_LIB1)(pack_f.o): $(MODEL_LIB1)(mod_prec.o)
+$(MODEL_LIB1)(server.o): $(MODEL_LIB1)(mod_global_memory.o) \
+	$(MODEL_LIB1)(mod_interface_ioipsl.o) $(MODEL_LIB1)(mod_iomanager.o) \
+	$(MODEL_LIB1)(mod_ioserver_namelist.o) \
+	$(MODEL_LIB1)(mod_ioserver_para.o) \
+	$(MODEL_LIB1)(mod_mpi_buffer_server.o) $(MODEL_LIB1)(mod_wait.o)
+$(MODEL_LIB1)(mod_ioclient_para.o): $(MODEL_LIB1)(mod_ioserver_namelist.o) \
+	$(MODEL_LIB1)(mpi_mod.o) $(MODEL_LIB1)(mpitrace.o)
+$(MODEL_LIB1)(mod_ioserver_para.o): $(MODEL_LIB1)(mod_ioserver_namelist.o) \
+	$(MODEL_LIB1)(mpi_mod.o) $(MODEL_LIB1)(mpitrace.o)
+$(MODEL_LIB1)(mpi_mod.o): 
+$(MODEL_LIB1)(mpitrace.o): 
+$(MODEL_LIB2)(mod_attribut.o): $(MODEL_LIB2)(mod_attribut_list.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_object.o) \
+	$(MODEL_LIB2)(mod_stdtype.o) $(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o)
+$(MODEL_LIB2)(mod_attribut_list.o): $(MODEL_LIB2)(mod_axis_attribut.o) \
+	$(MODEL_LIB2)(mod_field_attribute.o) \
+	$(MODEL_LIB2)(mod_file_attribut.o) $(MODEL_LIB2)(mod_grid_attribut.o) \
+	$(MODEL_LIB2)(mod_zoom_attribut.o)
+$(MODEL_LIB2)(mod_axis.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_axis_attribut.o) $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) ../src/XMLIO/vector_axis_def.inc
+$(MODEL_LIB2)(mod_axis_attribut.o): $(MODEL_LIB2)(mod_object.o)
+$(MODEL_LIB2)(mod_axis_definition.o): $(MODEL_LIB2)(mod_axis_group.o)
+$(MODEL_LIB2)(mod_axis_group.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_axis.o) $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_object.o) $(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_axis_group_def.inc
+$(MODEL_LIB2)(mod_context.o): $(MODEL_LIB2)(mod_axis.o) \
+	$(MODEL_LIB2)(mod_axis_definition.o) $(MODEL_LIB2)(mod_axis_group.o) \
+	$(MODEL_LIB2)(mod_dependency.o) $(MODEL_LIB2)(mod_field.o) \
+	$(MODEL_LIB2)(mod_field_definition.o) \
+	$(MODEL_LIB2)(mod_field_group.o) $(MODEL_LIB2)(mod_file.o) \
+	$(MODEL_LIB2)(mod_file_definition.o) $(MODEL_LIB2)(mod_file_group.o) \
+	$(MODEL_LIB2)(mod_grid.o) $(MODEL_LIB2)(mod_grid_definition.o) \
+	$(MODEL_LIB2)(mod_grid_group.o) $(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_time_parameters.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) $(MODEL_LIB2)(mod_zoom.o) \
+	$(MODEL_LIB2)(string_function.o) ../src/XMLIO/vector_context_def.inc
+$(MODEL_LIB2)(mod_dependency.o): $(MODEL_LIB2)(mod_axis.o) \
+	$(MODEL_LIB2)(mod_field.o) $(MODEL_LIB2)(mod_file.o) \
+	$(MODEL_LIB2)(mod_file_definition.o) $(MODEL_LIB2)(mod_file_group.o) \
+	$(MODEL_LIB2)(mod_grid.o) $(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_zoom.o) $(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_field_dep_def.inc
+$(MODEL_LIB2)(mod_domain.o): $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	../src/XMLIO/vector_domain_def.inc
+$(MODEL_LIB2)(mod_error_msg.o): $(MODEL_LIB2)(mod_xmlio_parameters.o)
+$(MODEL_LIB2)(mod_field.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_axis.o) $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_field_attribute.o) $(MODEL_LIB2)(mod_grid.o) \
+	$(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) $(MODEL_LIB2)(mod_zoom.o) \
+	$(MODEL_LIB2)(string_function.o) ../src/XMLIO/vector_field_def.inc
+$(MODEL_LIB2)(mod_field_attribute.o): $(MODEL_LIB2)(mod_object.o)
+$(MODEL_LIB2)(mod_field_definition.o): $(MODEL_LIB2)(mod_field_group.o)
+$(MODEL_LIB2)(mod_field_group.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_field.o) \
+	$(MODEL_LIB2)(mod_object.o) $(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_field_group_def.inc
+$(MODEL_LIB2)(mod_file.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_field_group.o) \
+	$(MODEL_LIB2)(mod_file_attribut.o) $(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) ../src/XMLIO/vector_file_def.inc
+$(MODEL_LIB2)(mod_file_attribut.o): $(MODEL_LIB2)(mod_object.o)
+$(MODEL_LIB2)(mod_file_definition.o): $(MODEL_LIB2)(mod_file_group.o)
+$(MODEL_LIB2)(mod_file_group.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_file.o) \
+	$(MODEL_LIB2)(mod_object.o) $(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_file_group_def.inc
+$(MODEL_LIB2)(mod_grid.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_domain.o) $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_grid_attribut.o) $(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) $(MODEL_LIB2)(mod_zoom.o) \
+	$(MODEL_LIB2)(string_function.o) ../src/XMLIO/vector_grid_def.inc
+$(MODEL_LIB2)(mod_grid_attribut.o): $(MODEL_LIB2)(mod_object.o)
+$(MODEL_LIB2)(mod_grid_definition.o): $(MODEL_LIB2)(mod_grid_group.o)
+$(MODEL_LIB2)(mod_grid_group.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_grid.o) \
+	$(MODEL_LIB2)(mod_object.o) $(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_grid_group_def.inc
+$(MODEL_LIB2)(mod_parse_xml.o): $(MODEL_LIB2)(mod_axis.o) \
+	$(MODEL_LIB2)(mod_axis_definition.o) $(MODEL_LIB2)(mod_axis_group.o) \
+	$(MODEL_LIB2)(mod_context.o) $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_field.o) $(MODEL_LIB2)(mod_field_definition.o) \
+	$(MODEL_LIB2)(mod_field_group.o) $(MODEL_LIB2)(mod_file.o) \
+	$(MODEL_LIB2)(mod_file_definition.o) $(MODEL_LIB2)(mod_file_group.o) \
+	$(MODEL_LIB2)(mod_grid.o) $(MODEL_LIB2)(mod_grid_definition.o) \
+	$(MODEL_LIB2)(mod_grid_group.o) $(MODEL_LIB2)(mod_zoom.o) \
+	$(MODEL_LIB2)(string_function.o)
+$(MODEL_LIB2)(mod_sorted_list.o): ../src/XMLIO/vector_node_def.inc
+$(MODEL_LIB2)(mod_zoom.o): $(MODEL_LIB2)(mod_attribut.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_sorted_list.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o) \
+	$(MODEL_LIB2)(mod_zoom_attribut.o) $(MODEL_LIB2)(string_function.o) \
+	../src/XMLIO/vector_zoom_def.inc
+$(MODEL_LIB2)(mod_zoom_attribut.o): $(MODEL_LIB2)(mod_object.o)
+$(MODEL_LIB2)(string_function.o): $(MODEL_LIB2)(mod_error_msg.o) \
+	$(MODEL_LIB2)(mod_xmlio_parameters.o)
+$(MODEL_LIB2)(test_xmlio.o): $(MODEL_LIB2)(mod_interface_ioipsl.o) \
+	$(MODEL_LIB2)(xmlio.o)
+$(MODEL_LIB2)(xmlio.o): $(MODEL_LIB2)(mod_axis.o) \
+	$(MODEL_LIB2)(mod_axis_definition.o) $(MODEL_LIB2)(mod_axis_group.o) \
+	$(MODEL_LIB2)(mod_context.o) $(MODEL_LIB2)(mod_dependency.o) \
+	$(MODEL_LIB2)(mod_error_msg.o) $(MODEL_LIB2)(mod_field.o) \
+	$(MODEL_LIB2)(mod_field_definition.o) \
+	$(MODEL_LIB2)(mod_field_group.o) $(MODEL_LIB2)(mod_file.o) \
+	$(MODEL_LIB2)(mod_file_definition.o) $(MODEL_LIB2)(mod_file_group.o) \
+	$(MODEL_LIB2)(mod_grid.o) $(MODEL_LIB2)(mod_grid_definition.o) \
+	$(MODEL_LIB2)(mod_grid_group.o) $(MODEL_LIB2)(mod_parse_xml.o) \
+	$(MODEL_LIB2)(mod_time_parameters.o) $(MODEL_LIB2)(string_function.o)
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/AA_make.ldef	(revision 1844)
@@ -0,0 +1,13 @@
+#-
+#- $Id: $
+#-
+#---------------------------------------------------------------------
+#- Local parameters for "libxml90"
+#---------------------------------------------------------------------
+SHELL = /bin/ksh
+#---------------------------------------------------------------------
+LIBDIR = ../../../lib/libxmlio_server
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+MODEL_LIB1 = $(LIBDIR)/libioserver.a
+MODEL_LIB2 = $(LIBDIR)/libxmlio.a
Index: /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl
===================================================================
--- /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl	(revision 1844)
+++ /branches/DEV_r1837_MLF/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl	(revision 1844)
@@ -0,0 +1,403 @@
+#!/usr/bin/perl
+#
+# Usage: makemake {<program name> {<F90 compiler or fc or f77 or cc or c>}}
+#
+# Generate a Makefile from the sources in the current directory.  The source
+# files may be in either C, FORTRAN 77, Fortran 90 or some combination of
+# these languages.  If the F90 compiler specified is cray or parasoft, then
+# the Makefile generated will conform to the conventions of these compilers.
+# To run makemake, it will be necessary to modify the first line of this script
+# to point to the actual location of Perl on your system.
+#
+# Written by Michael Wester <wester@math.unm.edu> February 16, 1995
+# Cotopaxi (Consulting), Albuquerque, New Mexico
+#
+open(MAKEFILE, "> AA_make");
+#
+#print MAKEFILE "PROG =\t$ARGV[0]\n\n";
+#
+# Misc
+
+print MAKEFILE "VPATH=../src/IOSERVER:../src/XMLIO\n";
+print MAKEFILE "MAKE_NAM = \$(MAKE)\n";
+print MAKEFILE "ifneq (\$(MAKE_NAM),\$(M_K))\n";
+print MAKEFILE " \@\$(error You must invoke this Makefile with the \$(M_K) command)\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "USER_DIR = \$(shell /bin/pwd)\n";
+print MAKEFILE "MAKE_DIR = '??'\n";
+print MAKEFILE "ifneq (\$(USER_DIR),\$(MAKE_DIR))\n";
+print MAKEFILE " \@\$(error You must invoke this Makefile from its directory)\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-\n";
+print MAKEFILE "#-Q- sx6nec F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- sx8brodie F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- sx8mercure F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- sx9mercure F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- sxdkrz F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- es2 F_O := \$(F_O) -Wf,-ptr byte\n";
+print MAKEFILE "#-Q- aix6 F_O = \$(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- aix F_O = \$(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "#-Q- osxxlf F_O = \$(F_P) -O3 -qextname -qsuffix=cpp=F90 -qsuffix=f=f90  -qmoddir=\$(MODDIR) -I \$(MODDIR)\n";
+print MAKEFILE "F_O := \$(F_O) -I../../../lib\n";
+print MAKEFILE "P_O := \$(P_O) -traditional\n";
+print MAKEFILE "#-Q- aix6 L_O = \$(F_P) -q64 -O3\n"; 
+print MAKEFILE "#-Q- aix L_O = \$(F_P) -q64 -O3\n"; 
+print MAKEFILE "prefix=''\n";
+print MAKEFILE "#-Q- aix6 prefix='-WF,'\n";
+print MAKEFILE "#-Q- aix prefix='-WF,'\n";
+print MAKEFILE "override P_P := \$(P_P:\%=\$(prefix)\%)\n\n";
+print MAKEFILE "#---------------------------------------------------------------------\n";
+print MAKEFILE "#- Create libioserver and libxmlio\n";
+print MAKEFILE "#---------------------------------------------------------------------\n\n";
+
+print MAKEFILE ".PRECIOUS : \$(MODEL_LIB1) \$(MODEL_LIB2)\n";
+print MAKEFILE "SXMODEL_LIB1 = \$(MODEL_LIB1)\n";
+print MAKEFILE "SXMODEL_LIB2 = \$(MODEL_LIB2)\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "SXMODEL_LIB1 = \$(LIBDIR)/libsxioserver.a\n";
+print MAKEFILE "SXMODEL_LIB2 = \$(LIBDIR)/libsxxmlio.a\n";
+print MAKEFILE ".PRECIOUS : \$(SXMODEL_LIB1) \$(SXMODEL_LIB2)\n";
+print MAKEFILE "endif\n\n";
+
+# Source listing
+#IOSERVER
+print MAKEFILE "MODS1 =\t";
+@srcs = < ../src/IOSERVER/*.F90 ../src/IOSERVER/*.f90>;
+&PrintWords(8, 0, @srcs);
+print MAKEFILE "\n\n";
+#
+# Object listing
+#
+print MAKEFILE "OBJSMODS1 =\t";
+@objs =  @srcs;
+foreach (@objs) { s/\.[^.]+$/.o/ };
+         foreach $objs (@objs) {
+         @tab = split('/', $objs);
+         $objs = $tab[$#tab] ;
+         if( "$objs" eq 'server.o' ){
+         $objs = ''};
+         };
+         
+&PrintWords(8, 0, @objs);
+print MAKEFILE "\n\n";
+
+# Source listing
+#XMLIO
+print MAKEFILE "MODS2 =\t";
+@srcs = < ../src/XMLIO/*.F90 ../src/XMLIO/*.f90>;
+&PrintWords(8, 0, @srcs);
+print MAKEFILE "\n\n";
+#
+# Object listing
+#
+print MAKEFILE "OBJSMODS2 =\t";
+@objs =  @srcs;
+foreach (@objs) { s/\.[^.]+$/.o/ };
+         foreach $objs (@objs) {
+         @tab = split('/', $objs);
+         $objs = $tab[$#tab] ;
+         if( "$objs" eq 'test_xmlio.o' ){
+         $objs = ''};
+         };
+
+&PrintWords(8, 0, @objs);
+print MAKEFILE "\n\n";
+
+#
+# make
+#
+print MAKEFILE ".SUFFIXES: .f90 .F90\n\n";
+
+print MAKEFILE "all: libioipsl libxmlf90 dirxml \$(MODEL_LIB2)(\$(OBJSMODS2)) key \$(MODEL_LIB1)(\$(OBJSMODS1)) server.o EXEC_BIN\n";
+print MAKEFILE "\t\@echo IOSERVER is OK\n\n";
+
+# mpi or not
+print MAKEFILE "key :\n";
+print MAKEFILE "\t\-\@if [ \"`cat KEY_CPP`\" \!= \"\$(P_P)\" ] \; then \\\n";
+print MAKEFILE "\techo \"\$(P_P)\" > KEY_CPP \; fi\n\n";
+
+
+# Main program
+print MAKEFILE "ifneq  (,\$(findstring NO_MPI,\$(P_P)))\n";
+print MAKEFILE "EXEC_BIN :\n";
+print MAKEFILE "server.o :\n";
+print MAKEFILE "else\n";
+print MAKEFILE "EXEC_BIN : server.o\n";
+print MAKEFILE "\t\$(F_L) \$(L_O) -o ../../../bin/ioserver server.o \$(MODEL_LIB1) \$(MODEL_LIB2) ../../../lib/libioipsl.a \$(NCDF_LIB) ../../../lib/libxmlio_server/libxmlf90.a\n";
+print MAKEFILE "server.o :       ../src/IOSERVER/server.f90\n";
+print MAKEFILE "\t\@\$(F_C) \$(F_O) -c ../src/IOSERVER/server.f90\n";
+print MAKEFILE "endif\n\n";
+
+
+# .f90 -> .o
+#
+
+print MAKEFILE "#Rules for ioserver\n";
+print MAKEFILE "#---- Using VPATH instead \$(MODEL_LIB1)(%.o): ../src/IOSERVER/%.f90\n";
+print MAKEFILE "\$(MODEL_LIB1)(%.o): %.f90\n";
+print MAKEFILE "\t\$(F_C) \$(F_O)  -I../src/XMLIO -I../src/IOSERVER -I\$(NCDF_INC) \$<\n";
+print MAKEFILE "\t\$(A_C) \$(MODEL_LIB1) \$*.o\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "\t\$(A_X) \$(SXMODEL_LIB1) \$*.o\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-Q- sgi6       mv \$(shell echo \$* | tr '[:lower:]' '[:upper:]').mod \$(MODDIR)\n";
+print MAKEFILE "ifeq (\$(M_M),1)\n";
+print MAKEFILE "\t\@mv -f *.mod \$(MODDIR)  2> /dev/null || true\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "\t\$(RM) \$*.o\n\n";
+
+print MAKEFILE "#Rules for ioserver\n";
+#print MAKEFILE "\$src/IOSERVER/%.f90: ../src/IOSERVER/%.F90\n";
+#print MAKEFILE "\t@\$(P_C) \$(P_O) \$(P_P) src/IOSERVER/\$(*F).F90 > src/IOSERVER/\$(*F).f90\n\n";
+print MAKEFILE "#---- Using VPATH instead \$(MODEL_LIB1)(%.o): ../src/IOSERVER/%.F90\n";
+print MAKEFILE "\$(MODEL_LIB1)(%.o): %.F90 KEY_CPP\n";
+print MAKEFILE "\t\$(F_C) \$(F_O) \$(P_P) -I\$(NCDF_INC) -I../src/XMLIO -I../src/IOSERVER \$<\n";
+print MAKEFILE "\t\$(A_C) \$(MODEL_LIB1) \$*.o\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "\t\$(A_X) \$(SXMODEL_LIB1) \$*.o\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-Q- sgi6       mv \$(shell echo \$* | tr '[:lower:]' '[:upper:]').mod \$(MODDIR)\n";
+print MAKEFILE "ifeq (\$(M_M),1)\n";
+print MAKEFILE "\t\@mv -f *.mod \$(MODDIR)  2> /dev/null || true\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "\t\$(RM) \$*.o\n\n";
+
+print MAKEFILE "#Rules for xmlio\n";
+print MAKEFILE "#---- Using VPATH instead \$(MODEL_LIB1)(%.o): ../src/XMLIO/%.F90\n";
+print MAKEFILE "\$(MODEL_LIB2)(%.o): %.f90\n";
+print MAKEFILE "\t\$(F_C) \$(F_O) -I\$(NCDF_INC) -I../src/XMLIO \$<\n";
+print MAKEFILE "\t\$(A_C) \$(MODEL_LIB2) \$*.o\n";
+print MAKEFILE "ifeq (\$(L_X),1)\n";
+print MAKEFILE "\t\$(A_X) \$(SXMODEL_LIB2) \$*.o\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "#-Q- sgi6       mv \$(shell echo \$* | tr '[:lower:]' '[:upper:]').mod \$(MODDIR)\n";
+print MAKEFILE "ifeq (\$(M_M),1)\n";
+print MAKEFILE "\t\@mv -f *.mod \$(MODDIR)  2> /dev/null || true\n";
+print MAKEFILE "endif\n";
+print MAKEFILE "\t\$(RM) \$*.o\n\n";
+
+
+
+
+print MAKEFILE "dirxml: \n";
+print MAKEFILE "\t\@if [ ! -d ../../../lib/libxmlio_server ] ; then mkdir ../../../lib/libxmlio_server ; fi\n\n";
+
+print MAKEFILE "# IOIPSL library\n";
+print MAKEFILE "libioipsl :\n";
+print MAKEFILE "\t(cd ../../IOIPSL/src ; \$(M_K) -f Makefile )\n\n";
+
+print MAKEFILE "# XMLF90 library\n";
+print MAKEFILE "libxmlf90 :\n";
+print MAKEFILE "\t(cd ../../XMLF90/external ; \$(M_K) -f Makefile )\n\n";
+
+#
+# make clean
+#
+print MAKEFILE "clean:\n";
+print MAKEFILE "\t\$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L\n";
+print MAKEFILE "\t\$(RM) server.o \$(MODEL_LIB1) \$(MODEL_LIB2)\n\n";
+#
+#
+# Dependency listings
+#
+&MakeDependsf90($ARGV[1],IOSERVER,MODEL_LIB1);
+&MakeDependsf90($ARGV[1],XMLIO,MODEL_LIB2);
+&MakeDepends("*.f *.F", '^\s*include\s+["\']([^"\']+)["\']');
+&MakeDepends("*.c",     '^\s*#\s*include\s+["\']([^"\']+)["\']');
+
+#
+# &PrintWords(current output column, extra tab?, word list); --- print words
+#    nicely
+#
+sub PrintWords {
+   local($columns) = 78 - shift(@_);
+   local($extratab) = shift(@_);
+   local($wordlength);
+   #
+   print MAKEFILE @_[0];
+   $columns -= length(shift(@_));
+   foreach $word (@_) {
+      $wordlength = length($word);
+      if ($wordlength + 1 < $columns) {
+         print MAKEFILE " $word";
+         $columns -= $wordlength + 1;
+         }
+      else {
+         #
+         # Continue onto a new line
+         #
+         if ($extratab) {
+            print MAKEFILE " \\\n\t\t$word";
+            $columns = 62 - $wordlength;
+            }
+         else {
+            print MAKEFILE " \\\n\t$word";
+            $columns = 70 - $wordlength;
+            }
+         }
+      }
+   }
+
+#
+# &LanguageCompiler(compiler, sources); --- determine the correct language
+#    compiler
+#
+sub LanguageCompiler {
+   local($compiler) = &toLower(shift(@_));
+   local(@srcs) = @_;
+   #
+   if (length($compiler) > 0) {
+      CASE: {
+         grep(/^$compiler$/, ("fc", "f77")) &&
+            do { $compiler = "FC"; last CASE; };
+         grep(/^$compiler$/, ("cc", "c"))   &&
+            do { $compiler = "CC"; last CASE; };
+         $compiler = "F90";
+         }
+      }
+   else {
+      CASE: {
+         grep(/\.f90$/, @srcs)   && do { $compiler = "F90"; last CASE; };
+         grep(/\.(f|F)$/, @srcs) && do { $compiler = "FC";  last CASE; };
+         grep(/\.c$/, @srcs)     && do { $compiler = "CC";  last CASE; };
+         $compiler = "???";
+         }
+      }
+   $compiler;
+   }
+
+#
+# &toLower(string); --- convert string into lower case
+#
+sub toLower {
+   local($string) = @_[0];
+   $string =~ tr/A-Z/a-z/;
+   $string;
+   }
+
+#
+# &uniq(sorted word list); --- remove adjacent duplicate words
+#
+sub uniq {
+   local(@words);
+   foreach $word (@_) {
+      if ($word ne $words[$#words]) {
+         push(@words, $word);
+         }
+      }
+   @words;
+   }
+
+#
+# &MakeDepends(language pattern, include file sed pattern); --- dependency
+#    maker
+#
+sub MakeDepends {
+   local(@incs);
+   local($lang) = @_[0];
+   local($pattern) = @_[1];
+   #
+   foreach $file (<${lang}>) {
+      open(FILE, $file) || warn "Cannot open $file: $!\n";
+      while (<FILE>) {
+         /$pattern/i && push(@incs, $1);
+         }
+      if (defined @incs) {
+         $file =~ s/\.[^.]+$/.o/;
+         @tab = split('/', $file);
+         $file = '$(MODEL_LIB)(' . $tab[$#tab] . ')' ;
+         print MAKEFILE "$file: ";
+         &PrintWords(length($file) + 2, 0, @incs);
+         print MAKEFILE "\n";
+         undef @incs;
+         }
+      }
+   }
+
+#
+# &MakeDependsf90(f90 compiler); --- FORTRAN 90 dependency maker
+#
+sub MakeDependsf90 {
+   local($compiler) = &toLower(@_[0]);
+   local(@dependencies);
+   local(%filename);
+   local(@incs);
+   local(@modules);
+   local($objfile);
+   local($DIR) = @_[1];
+   local($MODEL_LIB) = @_[2];
+   #
+   # Associate each module with the name of the file that contains it
+   #
+   foreach $file (<../*/*/*.f90>) {
+      open(FILE, $file) || warn "Cannot open $file: $!\n";
+      while (<FILE>) {
+         /^\s*module\s+([^\s!]+)/i &&
+            ($filename{&toLower($1)} = $file) =~ s/\.f90$/.o/;
+         }
+      }
+   foreach $file (<../*/*/*.F90>) {
+      open(FILE, $file) || warn "Cannot open $file: $!\n";
+      while (<FILE>) {
+         /^\s*module\s+([^\s!]+)/i &&
+            ($filename{&toLower($1)} = $file) =~ s/\.F90$/.o/;
+         }
+      }
+
+   #
+   # Print the dependencies of each file that has one or more include's or
+   # references one or more modules
+   #
+   foreach $file (<../src/$DIR/*.f90 ../src/$DIR/*.F90>) {
+      open(FILE, $file);
+      while (<FILE>) {
+         /^\s*include\s+["\']([^"\']+)["\']/i && push(@incs, $1);
+         /^\s*use\s+([^\s,!]+)/i && push(@modules, &toLower($1));
+         }
+      if (defined @incs || defined @modules) {
+#         ($objfile = $file) =~ s/\.F90$/.o/;
+         ($objfile = $file) =~ s/\.[fF]90$/.o/;
+         @tab = split('/', $objfile);
+         $objfile = '$(' . $MODEL_LIB . ')(' . $tab[$#tab] . ')' ;
+
+         print MAKEFILE "$objfile: ";
+         undef @dependencies;
+         foreach $module (@modules) {
+            push(@dependencies, $filename{$module});
+            }
+         @dependencies = &uniq(sort(@dependencies));
+
+         foreach $dependencies (@dependencies) {
+         	
+         @tab = split('/', $dependencies);
+         $dependencies = '$(' . $MODEL_LIB . ')(' . $tab[$#tab] . ')';
+
+             if( "$DIR" eq 'IOSERVER'  && "$dependencies" eq '$(MODEL_LIB1)(xmlio.o)' ) {
+             	$dependencies = '$(MODEL_LIB2)'
+#                $dependencies = ''
+
+             }          
+         }
+
+         foreach $incs (@incs) {
+         @tab = split('/', $incs);
+         @incs = '../src' . '/' . $DIR. '/' . $tab[$#tab] ;
+         }
+        foreach $incs (@incs) {
+             if( "$incs" eq '../src/IOSERVER/mpif.h' ||  "$incs" eq '../src/IOSERVER/VT.inc' ||  "$incs" eq  '../src/IOSERVER/ios_mpif.h' ) {
+                $incs = '';
+       }
+       }
+
+ 
+
+         &PrintWords(length($objfile) + 2, 0,
+                     @dependencies, &uniq(sort(@incs)));
+         print MAKEFILE "\n";
+         undef @incs;
+         undef @modules;
+         #
+         #
+         }
+      }
+   }
Index: /branches/DEV_r1837_MLF/NEMO/C1D_SRC/c1d.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/C1D_SRC/c1d.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/C1D_SRC/c1d.F90	(revision 1844)
@@ -0,0 +1,24 @@
+MODULE c1d
+   !!======================================================================
+   !!                     ***  MODULE  c1d  ***
+   !! Ocean domain  :  1D configuration
+   !!=====================================================================
+   !! History :   2.0  !  2004-09  (C. Ethe)  Original code
+   !!             3.0  !  2008-04 (G. Madec)  adaptation to SBC
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PRIVATE
+
+#if defined key_c1d
+   LOGICAL, PUBLIC, PARAMETER ::   lk_c1d = .TRUE.    !: 1D config. flag activated
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_c1d = .FALSE.   !: 1D config. flag de-activated
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/C1D 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!=====================================================================
+END MODULE c1d
Index: /branches/DEV_r1837_MLF/NEMO/C1D_SRC/diawri_c1d.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/C1D_SRC/diawri_c1d.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/C1D_SRC/diawri_c1d.F90	(revision 1844)
@@ -0,0 +1,360 @@
+MODULE diawri_c1d
+   !!======================================================================
+   !!                     ***  MODULE  diawri_c1d  ***
+   !! Ocean diagnostics :  write ocean output files
+   !!=====================================================================
+   !! History :   2.0  !  2004-10  (C. Ethe)  1D Configuration
+   !!             3.0  !  2008-04  (G. Madec)  adaptation to SBC
+   !!----------------------------------------------------------------------
+#if defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_c1d'                                          1D Configuration
+   !!----------------------------------------------------------------------  
+   !!   dia_wri_c1d       : create the standart NetCDF output files
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE zdf_oce         ! ocean vertical physics
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE sbc_ice         ! surface boundary condition: ice
+   USE sbcmod          ! surface Boundary Codition
+   USE sbcssr          ! surface boundary condition: restauring to SSS and or SST
+   USE zdftke_old      ! TKE vertical mixing (old scheme)
+   USE zdftke          ! TKE vertical mixing
+   USE zdfkpp          ! KPP vertical mixing
+   USE sol_oce         ! solver variables
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer
+   USE dianam          ! build name of file (routine)
+   USE diawri
+   USE zdfddm          ! vertical  physics: double diffusion
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE ioipsl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dia_wri_c1d                 ! routines called by step.F90
+
+   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT, ndex(1)   ! grid_T file
+   INTEGER, DIMENSION(jpi*jpj)     ::   ndex_hT
+   INTEGER, DIMENSION(jpi*jpj*jpk) ::   ndex_T
+
+   !! * Substitutions
+#  include "zdfddm_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/C1D 3.0 , LOCEAN-IPSL  (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_wri_c1d( kt, kindic )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri_c1d  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), 
+      !!      define all the NETCDF files and fields
+      !!      At each time step call histdef to compute the mean if ncessary
+      !!      Each nwrite time step, output the instantaneous or mean fields
+      !!      IF kindic <0, output of fields before the model interruption.
+      !!      IF kindic =0, time step loop
+      !!      IF kindic >0, output of fields before the time step loop
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      INTEGER, INTENT( in ) ::   kindic  ! 
+      !!
+      LOGICAL ::   ll_print = .FALSE.                ! =T print and flush numout
+      CHARACTER (len=40) ::   clhstnam, clop, clmx   ! temporary names
+      INTEGER ::   inum = 11                         ! temporary logical unit
+      INTEGER ::   ji, jj, ik                        ! dummy loop indices
+      INTEGER ::   iimi, iima, ipk, it, ijmi, ijma   ! temporary integers
+      INTEGER ::   itmod                             ! 
+      REAL(wp) ::   zsto, zout, zmax, zjulian, zdt   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zw2d         ! temporary workspace
+      !!----------------------------------------------------------------------
+      
+      ! 0. Initialisation
+      ! -----------------
+      
+      ! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( nacc == 1 ) zdt = rdtmin
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#if defined key_diainstant
+      zsto = nwrite * zdt
+      clop = "inst("//TRIM(clop)//")"
+#else
+      zsto=zdt
+      clop = "ave("//TRIM(clop)//")"
+#endif
+      zout = nwrite * zdt
+      zmax = ( nitend - nit000 + 1 ) * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt
+      itmod = kt - nit000 + 1
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      IF(ll_print) WRITE(numout,*) 'dia_wri_c1d kt = ', kt, ' kindic ', kindic
+
+      IF( kt == nit000 ) THEN
+
+         ! Define the NETCDF files (one per grid)
+         
+         ! Compute julian date from starting date of the run
+         CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) 'Date 0 used :', nit000, ' YEAR ', nyear,   &
+            &                    ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian
+         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,   &
+                                 ' limit storage in depth = ', ipk
+
+         ! WRITE root name in date.file for use by postpro
+         CALL dia_nam( clhstnam, nwrite,' ' )
+         CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp )
+         WRITE(inum,*) clhstnam
+         CLOSE(inum)
+         
+         ! Define the T grid FILE ( nid_T )
+         
+         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+            &          nit000-1, zjulian, zdt, nh_T, nid_T, domain_id=nidom )
+         CALL histvert( nid_T, "deptht", "Vertical T levels",      &  ! Vertical grid: gdept
+            &           "m", ipk, gdept_0, nz_T, "down" )
+         !                                                            ! Index of ocean points
+         CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_T , ndim_T  )      ! volume
+         CALL wheneq( jpi*jpj    , tmask, 1, 1., ndex_hT, ndim_hT )      ! surface
+
+
+         ! Declare all the output fields as NETCDF variables
+
+         !                                                                                      !!! nid_T : 3D
+         CALL histdef( nid_T, "votemper", "Temperature"                        , "C"      ,   &  ! tn
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vosaline", "Salinity"                           , "PSU"    ,   &  ! sn
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         !                                                                                      !!! nid_T : 2D
+         CALL histdef( nid_T, "sosstsst", "Sea Surface temperature"            , "C"      ,   &  ! sst
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosaline", "Sea Surface Salinity"               , "PSU"    ,   &  ! sss
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowaflup", "Net Upward Water Flux"              , "Kg/m2/s",   &  ! emp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+!!       CALL histdef( nid_T, "sorunoff", "Runoffs"                            , "Kg/m2/s",   &  ! runoffs
+!!          &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowaflcd", "concentration/dilution water flux"  , "kg/m2/s",   &  ! emps
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosalflx", "Surface Salt Flux"                  , "Kg/m2/s",   &  ! emps * sn
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux"             , "W/m2"   ,   &  ! qsr + qns
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "soshfldo", "Shortwave Radiation"                , "W/m2"   ,   &  ! qsr
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "somxl010", "Mixed Layer Depth 0.01"             , "m"      ,   &  ! hmlp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#if defined key_zdfkpp
+         CALL histdef( nid_T, "sokppekd", "Ekman depth                     "   , "m"      ,   &  ! sokppekd
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sokppbld", "Boundary Layer Depth            "   , "m"      ,   &  ! sokppbld
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+         CALL histdef( nid_T, "somxlavt", "AVT : bottom of the mixed layer    ", "m"      ,   &  ! avt_mxl
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "somixhgt", "Turbocline Depth"                   , "m"      ,   &  ! hmld
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "soicecov", "Ice Fraction"                          , "[0,1]"  ,   &  ! fr_i
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         IF( ln_ssr ) THEN
+            CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
+               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+            CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
+               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+            CALL histdef( nid_T, "sosafldp", "Surface salt flux: damping"         , "Kg/m2/s",   &  ! erp * sn
+               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         ENDIF
+         clmx ="l_max(only(x))"    ! max index on a period
+         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
+         !                                                                                      !!! nid_U : 3D
+         CALL histdef( nid_T, "vozocrtx", "Zonal Current"                      , "m/s"    ,   &  ! un
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#if defined key_diaeiv
+         CALL histdef( nid_T, "vozoeivu", "Zonal EIV Current"                  , "m/s"    ,   &  ! u_eiv
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#endif
+         !                                                                                      !!! nid_U : 2D
+         CALL histdef( nid_T, "sozotaux", "Wind Stress along i-axis"           , "N/m2"   ,   &  ! utau
+            &          jpi, jpj, nh_T, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+
+         !                                                                                      !!! nid_V : 3D
+         CALL histdef( nid_T, "vomecrty", "Meridional Current"                 , "m/s"    ,   &  ! vn
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#if defined key_diaeiv
+         CALL histdef( nid_T, "vomeeivv", "Meridional EIV Current"             , "m/s"    ,   &  ! v_eiv
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#endif
+         !                                                                                      !!! nid_V : 2D
+         CALL histdef( nid_T, "sometauy", "Wind Stress along j-axis"           , "N/m2"   ,   &  ! vtau
+            &          jpi, jpj, nh_T, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+#if defined key_zdftke_old
+         CALL histdef( nid_T, "votlsdis", " Dissipation Turbulent Lenght Scale", "m"      ,   &  ! e_dis
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votlsmix", " Mixing Turbulent Lenght Scale"     , "m"      ,   &  ! e_mix
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votlspdl", " Prandl Number",                      "-"       ,   &  ! e_pdl
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votlsric", " Local Richardson Number",            "-"       ,   &  ! e_ric
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votkeend", "TKE: Turbulent kinetic energy"       , "m2/s"   ,   &  ! TKE
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sotkehlc", "TKE: Langmuir Circulation depth"     , "m"      ,   &  ! hlc
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+#if defined key_zdfkpp
+         CALL histdef( nid_T, "vokpprig", " Gradient Richardson Number"        ,  "-"      ,   &  ! rig
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vokpprib", " Bulk Richardson Number    "        ,  "-"      ,   &   ! rib
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vokppbsf", " Buoyancy forcing          "        , "N/m2"    ,   &  ! sokppbsf
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vokppmol", "Moning Obukhov length scale     "   , "m"       ,   &  ! sokppmol
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#endif
+         !
+         CALL histdef( nid_T, "voeosbn2", "Brunt-Vaisala Frequency"             , "m2/s2"  ,   &  ! rn2
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votkeavt", "Vertical Eddy Diffusivity"          , "m2/s"   ,   &  ! avt
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "votkeavm", "Vertical Eddy Viscosity",             "m2/s"   ,   &  ! avmu
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         !
+         IF( lk_zdfddm ) THEN
+            CALL histdef( nid_T,"voddmavs","Salt Vertical Eddy Diffusivity"    , "m2/s"   ,   &  ! avs
+               &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         ENDIF
+
+         CALL histend( nid_T )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization'
+         IF(ll_print) CALL FLUSH(numout )
+
+      ENDIF
+
+      ! 2. Start writing data
+      ! ---------------------
+
+      ! ndex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et ndex la liste des indices a sortir
+
+      IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN 
+         WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      ! Write fields on T grid
+      CALL histwrite( nid_T, "votemper", it, tn            , ndim_T , ndex_T  )   ! temperature
+      CALL histwrite( nid_T, "vosaline", it, sn            , ndim_T , ndex_T  )   ! salinity
+      CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface temperature
+      CALL histwrite( nid_T, "sosaline", it, sn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface salinity
+      CALL histwrite( nid_T, "sowaflup", it, emp           , ndim_hT, ndex_hT )   ! upward water flux
+!!    CALL histwrite( nid_T, "sorunoff", it, runoff        , ndim_hT, ndex_hT )   ! runoff
+      CALL histwrite( nid_T, "sowaflcd", it, emps          , ndim_hT, ndex_hT )   ! c/d water flux
+      zw2d(:,:) = emps(:,:) * sn(:,:,1) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sosalflx", it, zw2d          , ndim_hT, ndex_hT )   ! c/d salt flux
+      CALL histwrite( nid_T, "sohefldo", it, qsr + qns     , ndim_hT, ndex_hT )   ! total heat flux
+      CALL histwrite( nid_T, "soshfldo", it, qsr           , ndim_hT, ndex_hT )   ! solar heat flux
+      CALL histwrite( nid_T, "somxl010", it, hmlp          , ndim_hT, ndex_hT )   ! mixed layer depth
+#if defined key_zdfkpp
+      CALL histwrite( nid_T, "sokppekd", it, ekdp          , ndim_hT, ndex_hT )   ! Ekman depht
+      CALL histwrite( nid_T, "sokppbld", it, hkpp          , ndim_hT, ndex_hT )   ! boundary layer depth 
+#endif  
+      ! store the vertical eddy diffusivity coef. at the bottom of the mixed layer
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = nmln(ji,jj)
+            zw2d(ji,jj) = avt(ji,jj,ik) * tmask(ji,jj,1)
+         END DO
+      END DO
+      CALL histwrite( nid_T, "somxlavt", it, zw2d          , ndim_hT, ndex_hT )   ! Kz at bottom of mixed layer 
+      CALL histwrite( nid_T, "somixhgt", it, hmld          , ndim_hT, ndex_hT )   ! turbocline depth
+      CALL histwrite( nid_T, "soicecov", it, fr_i          , ndim_hT, ndex_hT )   ! ice fraction 
+      IF( ln_ssr ) THEN
+         CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
+         CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
+         zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
+         CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
+      ENDIF
+      zw2d(:,:) = FLOAT( nmln(:,:) ) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sobowlin", it, zw2d          , ndim_hT, ndex_hT )   ! ???
+      CALL histwrite( nid_T, "vozocrtx", it, un            , ndim_T , ndex_T )    ! i-current
+      CALL histwrite( nid_T, "sozotaux", it, utau          , ndim_hT, ndex_hT )   ! i-wind stress
+      CALL histwrite( nid_T, "vomecrty", it, vn            , ndim_T , ndex_T  )   ! j-current
+      CALL histwrite( nid_T, "sometauy", it, vtau          , ndim_hT, ndex_hT )   ! j-wind stress
+#if defined key_zdftke_old
+      CALL histwrite( nid_T, "votlsdis", it, e_dis         , ndim_T , ndex_T )    ! Diss. Turb. lenght scale
+      CALL histwrite( nid_T, "votlsmix", it, e_mix         , ndim_T , ndex_T )    ! Mixing Turb. lenght scale
+      CALL histwrite( nid_T, "votlspdl", it, e_pdl         , ndim_T , ndex_T )    ! Prandl number
+      CALL histwrite( nid_T, "votlsric", it, e_ric         , ndim_T , ndex_T )    ! local Richardson number
+      CALL histwrite( nid_T, "votkeend", it, en            , ndim_T , ndex_T )    ! TKE
+      CALL histwrite( nid_T, "sotkehlc", it, hlc           , ndim_hT, ndex_hT )   ! TKE Langmuir Circulation depth
+#endif
+#if defined key_zdfkpp
+      CALL histwrite( nid_T, "vokpprig", it, rig           , ndim_T , ndex_T )    ! gradient Richardson number
+      CALL histwrite( nid_T, "vokpprib", it, rib           , ndim_T , ndex_T )    ! bulk Richardson number
+      CALL histwrite( nid_T, "vokppbsf", it, buof          , ndim_T , ndex_T )    ! buoyancy forcing
+      CALL histwrite( nid_T, "vokppmol", it, mols          , ndim_T , ndex_T )    ! Moning-Obukov length scale
+#endif
+      CALL histwrite( nid_T, "voeosbn2", it, rn2           , ndim_T , ndex_T )    ! Brunt-Vaisala Frequency
+      CALL histwrite( nid_T, "votkeavt", it, avt           , ndim_T , ndex_T )    ! T vert. eddy diff. coef.
+      CALL histwrite( nid_T, "votkeavm", it, avmu          , ndim_T , ndex_T )    ! T vert. eddy visc. coef.
+      IF( lk_zdfddm ) THEN
+         CALL histwrite( nid_T, "voddmavs", it, fsavs(:,:,:), ndim_T, ndex_T )    ! S vert. eddy diff. coef.
+      ENDIF
+
+      !  Create an output files (output.abort.nc) if S < 0 or u > 20 m/s
+      IF( kindic < 0 )   CALL dia_wri_state( 'output.abort', kt )
+
+      ! 3. Close all files
+      ! ---------------------------------------
+      IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nid_T )
+      !
+   END SUBROUTINE dia_wri_c1d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO 1D Configuration
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dia_wri_c1d ( kt, kindic )      ! dummy routine
+      WRITE(*,*) 'dia_wri_c1d: You should not have seen this print! error?', kt, kindic
+   END SUBROUTINE dia_wri_c1d
+#endif
+
+   !!======================================================================
+END MODULE diawri_c1d
Index: /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dyncor_c1d.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dyncor_c1d.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dyncor_c1d.F90	(revision 1844)
@@ -0,0 +1,131 @@
+MODULE dyncor_c1d
+   !!======================================================================
+   !!                     ***  MODULE  dyncor_c1d  ***
+   !! Ocean Dynamics :   Coriolis term in 1D configuration
+   !!=====================================================================
+   !! History :  2.0  !  2004-09  (C. Ethe)  Original code
+   !!            3.0  !  2008-04  (G. Madec)  style only
+   !!----------------------------------------------------------------------
+#if defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_c1d'                                          1D Configuration
+   !!----------------------------------------------------------------------
+   !!   cor_c1d      : Coriolis factor at T-point (1D configuration)
+   !!   dyn_cor_c1d  : vorticity trend due to Coriolis at T-point
+   !!----------------------------------------------------------------------
+   USE oce               ! ocean dynamics and tracers
+   USE dom_oce           ! ocean space and time domain
+   USE phycst            ! physical constants
+   USE in_out_manager    ! I/O manager
+   USE prtctl            ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   cor_c1d      ! routine called by OPA.F90
+   PUBLIC   dyn_cor_c1d  ! routine called by step1d.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/C1D  3.0 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE cor_c1d
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE cor_c1d  ***
+      !! 
+      !! ** Purpose : Compute the Coriolis factor at T-point
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zphi0, zbeta, zf0         !  temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cor_c1d : Coriolis factor at T-point'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+      SELECT CASE( jphgr_msh )   ! type of horizontal mesh
+      !
+      CASE ( 0, 1, 4 )               ! mesh on the sphere
+         ff(:,:) = 2. * omega * SIN( rad * gphit(:,:) ) 
+         !
+      CASE ( 2 )                     ! f-plane at ppgphi0 
+         ff(:,:) = 2. * omega * SIN( rad * ppgphi0 )
+         IF(lwp) WRITE(numout,*) '          f-plane: Coriolis parameter = constant = ', ff(1,1)
+         !
+      CASE ( 3 )                     ! beta-plane
+         zbeta   = 2. * omega * COS( rad * ppgphi0 ) / ra                     ! beta at latitude ppgphi0
+         zphi0   = ppgphi0 - FLOAT( jpjglo/2) * ppe2_m *1.e-3  / ( ra * rad ) ! latitude of the first row F-points
+         zf0     = 2. * omega * SIN( rad * zphi0 )                            ! compute f0 1st point south
+         ff(:,:) = ( zf0  + zbeta * gphit(:,:) * 1.e+3 )                      ! f = f0 +beta* y ( y=0 at south)
+         IF(lwp) WRITE(numout,*) '          Beta-plane: Beta parameter = constant = ', ff(1,1)
+         IF(lwp) WRITE(numout,*) '                      Coriolis parameter varies from ', ff(1,1),' to ', ff(1,jpj)
+         !
+      CASE ( 5 )                     ! beta-plane and rotated domain
+         zbeta = 2. * omega * COS( rad * ppgphi0 ) / ra                     ! beta at latitude ppgphi0
+         zphi0 = 15.e0                                                      ! latitude of the first row F-points
+         zf0   = 2. * omega * SIN( rad * zphi0 )                            ! compute f0 1st point south
+         ff(:,:) = ( zf0 + zbeta * ABS( gphit(:,:) - zphi0 ) * rad * ra )   ! f = f0 +beta* y ( y=0 at south)
+         IF(lwp) WRITE(numout,*) '          Beta-plane: Beta parameter = constant = ', ff(1,1)
+         IF(lwp) WRITE(numout,*) '                      Coriolis parameter varies from ', ff(1,1),' to ', ff(1,jpj)
+         !
+      END SELECT
+      !
+   END SUBROUTINE cor_c1d
+
+
+   SUBROUTINE dyn_cor_c1d( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dyn_cor_c1d  ***
+      !! 
+      !! ** Purpose :   Compute the now total vorticity trend and add it to 
+      !!               the general trend of the momentum equation
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!   9.0  !  04-09  (C. Ethe) 1D configuration
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk         ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_cor_c1d : total vorticity trend in 1D'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+      ENDIF
+      !
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) + ff(ji,jj) * vn(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) - ff(ji,jj) * un(ji,jj,jk)
+            END DO
+         END DO
+      END DO   
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' cor  - Ua: ', mask1=umask,  &
+         &                       tab3d_2=va, clinfo2=' Va: '       , mask2=vmask )
+      !
+   END SUBROUTINE dyn_cor_c1d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO 1D Configuration
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE cor_c1d              ! Empty routine
+   END SUBROUTINE cor_c1d   
+   SUBROUTINE dyn_cor_c1d ( kt )      ! Empty routine
+      WRITE(*,*) 'dyn_cor_c1d: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_cor_c1d
+#endif
+
+   !!=====================================================================
+END MODULE dyncor_c1d
Index: /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dynnxt_c1d.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dynnxt_c1d.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/C1D_SRC/dynnxt_c1d.F90	(revision 1844)
@@ -0,0 +1,109 @@
+MODULE dynnxt_c1d
+   !!======================================================================
+   !!                       ***  MODULE  dynnxt_c1d  ***
+   !! Ocean dynamics: time stepping in 1D configuration
+   !!======================================================================
+   !! History :  2.0  !  2004-10  (C. Ethe)  Original code from dynnxt.F90
+   !!            3.0  !  2008-04  (G.madec)  Style only
+   !!----------------------------------------------------------------------
+#if defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_c1d'                                          1D Configuration
+   !!----------------------------------------------------------------------  
+   !!----------------------------------------------------------------------
+   !!   dyn_nxt_c1d : update the horizontal velocity from the momentum trend
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! lateral boundary condition (or mpp link)
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dyn_nxt_c1d                ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !! NEMO/C1D  3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_nxt_c1d ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_nxt_c1d  ***
+      !!                   
+      !! ** Purpose :   Compute the after horizontal velocity from the 
+      !!      momentum trend.
+      !!
+      !! ** Method  :   Apply lateral boundary conditions on the trends (ua,va) 
+      !!      through calls to routine lbc_lnk.
+      !!      After velocity is compute using a leap-frog scheme environment:
+      !!         (ua,va) = (ub,vb) + 2 rdt (ua,va)
+      !!      Time filter applied on now horizontal velocity to avoid the
+      !!      divergence of two consecutive time-steps and swap of dynamics
+      !!      arrays to start the next time step:
+      !!         (ub,vb) = (un,vn) + atfp [ (ub,vb) + (ua,va) - 2 (un,vn) ]
+      !!         (un,vn) = (ua,va) 
+      !!
+      !! ** Action : - Update ub,vb arrays, the before horizontal velocity
+      !!             - Update un,vn arrays, the now horizontal velocity
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER  ::   jk           ! dummy loop indices
+      REAL(wp) ::   z2dt         ! temporary scalar
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_nxt_c1d : time stepping on 1D configuation'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Local constant initialization
+      z2dt = 2. * rdt
+      IF( neuler == 0 .AND. kt == nit000 )  z2dt = rdt
+
+      ! Lateral boundary conditions on ( ua, va )
+      CALL lbc_lnk( ua, 'U', -1. )
+      CALL lbc_lnk( va, 'V', -1. )
+
+      DO jk = 1, jpkm1      ! Next Velocity
+         ua(:,:,jk) = ( ub(:,:,jk) + z2dt * ua(:,:,jk) ) * umask(:,:,jk)
+         va(:,:,jk) = ( vb(:,:,jk) + z2dt * va(:,:,jk) ) * vmask(:,:,jk)
+      END DO 
+ 
+      DO jk = 1, jpkm1      ! Time filter and swap of dynamics arrays
+         IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler (forward) time stepping
+             ub(:,:,jk) = un(:,:,jk)
+             vb(:,:,jk) = vn(:,:,jk)
+             un(:,:,jk) = ua(:,:,jk)
+             vn(:,:,jk) = va(:,:,jk)
+         ELSE                                           ! Leap-frog time stepping
+             ub(:,:,jk) = atfp * ( ub(:,:,jk) + ua(:,:,jk) ) + atfp1 * un(:,:,jk)
+             vb(:,:,jk) = atfp * ( vb(:,:,jk) + va(:,:,jk) ) + atfp1 * vn(:,:,jk)
+             un(:,:,jk) = ua(:,:,jk)
+             vn(:,:,jk) = va(:,:,jk)
+         ENDIF
+      END DO
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt_c1d  - Un: ', mask1=umask,   &
+         &                       tab3d_2=vn, clinfo2=' Vn: '           , mask2=vmask )
+      !
+   END SUBROUTINE dyn_nxt_c1d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO 1D Config
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_nxt_c1d ( kt )
+      WRITE(*,*) 'dyn_nxt_c1d: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_nxt_c1d
+#endif
+
+   !!======================================================================
+END MODULE dynnxt_c1d
Index: /branches/DEV_r1837_MLF/NEMO/C1D_SRC/step_c1d.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/C1D_SRC/step_c1d.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/C1D_SRC/step_c1d.F90	(revision 1844)
@@ -0,0 +1,213 @@
+MODULE step_c1d
+   !!======================================================================
+   !!                       ***  MODULE step_c1d  ***
+   !! Time-stepping    : manager of the ocean, tracer and ice time stepping - c1d case
+   !!======================================================================
+   !! History :   2.0  !  2004-04  (C. Ethe)  adapted from step.F90 for C1D
+   !!             3.0  !  2008-04  (G. Madec)  redo the adaptation to include SBC
+   !!----------------------------------------------------------------------
+#if defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_c1d'                                       1D Configuration
+   !!----------------------------------------------------------------------  
+   !!   stp_c1d        : NEMO system time-stepping in c1d case
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE in_out_manager  ! I/O manager
+   USE iom             !
+   USE lbclnk
+
+   USE daymod          ! calendar                         (day     routine)
+
+   USE dtatem          ! ocean temperature data           (dta_tem routine)
+   USE dtasal          ! ocean salinity    data           (dta_sal routine)
+   USE sbcmod          ! surface boundary condition       (sbc     routine)
+   USE sbcrnf          ! surface boundary condition: runoff variables
+
+   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
+
+   USE traqsr          ! solar radiation penetration      (tra_qsr routine)
+   USE trasbc          ! surface boundary condition       (tra_sbc routine)
+   !   zdfkpp          ! KPP non-local tracer fluxes      (tra_kpp routine)
+   USE trazdf          ! vertical mixing                  (tra_zdf routine)
+   USE tranxt          ! time-stepping                    (tra_nxt routine)
+   USE tranpc          ! non-penetrative convection       (tra_npc routine)
+
+   USE eosbn2          ! equation of state                (eos_bn2 routine)
+
+   USE dyncor_c1d      ! Coriolis term (c1d case)         (dyn_cor_1d     )
+   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
+   USE dynnxt_c1d      ! time-stepping                    (dyn_nxt routine)
+   USE diawri_c1d      ! write outputs                (dia_wri_c1d routine)
+
+   USE zdfbfr          ! bottom friction                  (zdf_bfr routine)
+   USE zdftke          ! TKE vertical mixing              (zdf_tke routine)
+   USE zdfkpp          ! KPP vertical mixing              (zdf_kpp routine)
+   USE zdfddm          ! double diffusion mixing          (zdf_ddm routine)
+   USE zdfevd          ! enhanced vertical diffusion      (zdf_evd routine)
+   USE zdfric          ! Richardson vertical mixing       (zdf_ric routine)
+   USE zdfmxl          ! Mixed-layer depth                (zdf_mxl routine)
+
+
+   USE diawri          ! Standard run outputs             (dia_wri routine)
+
+   USE stpctl          ! time stepping control            (stp_ctl routine)
+   USE restart         ! ocean restart                    (rst_wri routine)
+   USE prtctl          ! Print control                    (prt_ctl routine)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC stp_c1d      ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE stp_c1d( kstp )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE stp_c1d  ***
+      !!                      
+      !! ** Purpose :  - Time stepping of SBC including LIM (dynamic and thermodynamic eqs.)
+      !!               - Time stepping of OPA (momentum and active tracer eqs.)
+      !!               - Time stepping of TOP (passive tracer eqs.)
+      !! 
+      !! ** Method  : -1- Update forcings and data  
+      !!              -2- Update vertical ocean physics 
+      !!              -3- Compute the t and s trends 
+      !!              -4- Update t and s 
+      !!              -5- Compute the momentum trends
+      !!              -6- Update the horizontal velocity
+      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
+      !!              -8- Outputs and diagnostics
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
+      INTEGER ::   jk       ! dummy loop indice
+      INTEGER ::   indic    ! error indicator if < 0
+      !! ---------------------------------------------------------------------
+
+      indic = 1                    ! reset to no error condition
+
+      CALL day( kstp )             ! Calendar
+
+      CALL rst_opn( kstp )         ! Open the restart file
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update data, open boundaries, surface boundary condition (including sea-ice)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
+      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
+
+                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
+
+      IF( ninist == 1 ) THEN                          ! Output the initial state and forcings
+                        CALL dia_wri_state( 'output.init', kstp )   ;   ninist = 0
+      ENDIF
+
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Ocean physics update
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !-----------------------------------------------------------------------
+      !  VERTICAL PHYSICS
+      !-----------------------------------------------------------------------
+      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
+      !-----------------------------------------------------------------------
+
+                        CALL bn2( tb, sb, rn2 )             ! before Brunt-Vaisala frequency
+      
+      !                                                     ! Vertical eddy viscosity and diffusivity coefficients
+      IF( lk_zdfric )   CALL zdf_ric( kstp )                     ! Richardson number dependent Kz
+      IF( lk_zdftke )   CALL zdf_tke( kstp )                     ! TKE closure scheme for Kz
+      IF( lk_zdfkpp )   CALL zdf_kpp( kstp )                     ! KPP closure scheme for Kz
+      IF( lk_zdfcst )   THEN                                     ! Constant Kz (reset avt, avm to the background value)
+         avt (:,:,:) = avt0 * tmask(:,:,:)
+         avmu(:,:,:) = avm0 * umask(:,:,:)
+         avmv(:,:,:) = avm0 * vmask(:,:,:)
+      ENDIF
+
+      IF( ln_rnf_mouth ) THEN                                ! increase diffusivity at rivers mouths
+         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:)   ;   END DO
+      ENDIF
+      IF( ln_zdfevd )   CALL zdf_evd( kstp )                 ! enhanced vertical eddy diffusivity
+      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
+         &              CALL zdf_ddm( kstp )                 ! double diffusive mixing
+                        CALL zdf_bfr( kstp )                 ! bottom friction
+                        CALL zdf_mxl( kstp )                 ! mixed layer depth
+
+#if defined key_top
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Passive Tracer Model
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
+      !-----------------------------------------------------------------------
+                             CALL trc_stp( kstp, indic )            ! time-stepping
+#endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Active tracers
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      ! N.B. ua, va arrays are used as workspace in this section
+      !-----------------------------------------------------------------------
+                             ta(:,:,:) = 0.e0                ! set tracer trends to zero
+                             sa(:,:,:) = 0.e0
+
+                             CALL tra_sbc    ( kstp )        ! surface boundary condition
+      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )        ! penetrative solar radiation qsr
+      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )        ! KPP non-local tracer fluxes
+                             CALL tra_zdf    ( kstp )        ! vertical mixing
+                             CALL tra_nxt( kstp )            ! tracer fields at next time step
+      IF( ln_zdfnpc      )   CALL tra_npc( kstp )            ! applied non penetrative convective adjustment on (t,s)
+                             CALL eos( tb, sb, rhd, rhop )   ! now (swap=before) in situ density for dynhpg module
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Dynamics
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      ! N.B. ta, sa arrays are used as workspace in this section 
+      !-----------------------------------------------------------------------
+                               ua(:,:,:) = 0.e0               ! set dynamics trends to zero
+                               va(:,:,:) = 0.e0
+
+                               CALL dyn_cor_c1d( kstp )       ! vorticity term including Coriolis
+                               CALL dyn_zdf    ( kstp )       ! vertical diffusion
+                               CALL dyn_nxt_c1d( kstp )       ! lateral velocity at next time step
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control and restarts
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                                 CALL stp_ctl( kstp, indic )
+      IF( kstp == nit000     )   CALL iom_close( numror )             ! close input  ocean restart file
+      IF( lrst_oce           )   CALL rst_write  ( kstp )             ! write output ocean restart file
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! diagnostics and outputs
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
+      !-----------------------------------------------------------------------
+
+      IF( nstop == 0 )           CALL dia_wri_c1d( kstp, indic )       ! ocean model: outputs
+      !
+   END SUBROUTINE stp_c1d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                            NO 1D Config
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE stp_c1d ( kt )      ! dummy routine
+      WRITE(*,*) 'stp_c1d: You should not have seen this print! error?', kt
+   END SUBROUTINE stp_c1d
+#endif
+
+   !!======================================================================
+END MODULE step_c1d
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/dom_ice_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 1844)
@@ -0,0 +1,34 @@
+MODULE dom_ice_2
+   !!======================================================================
+   !!                   ***  MODULE  dom_ice  ***
+   !! LIM 2.0 Sea Ice :   Domain  variables
+   !!======================================================================
+   !! History :   2.0  !  03-08  (C. Ethe)  Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_ice_2
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC ::   l_jeq     = .TRUE.     !: Equator inside the domain flag
+
+   INTEGER, PUBLIC ::   njeq , njeqm1          !: j-index of the equator if it is inside the domain
+      !                                        !  (otherwise = jpj+10 (SH) or -10 (SH) )
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)         ::   fs2cor , fcor,   &  !: coriolis factor and coeficient
+      &                                              covrai ,         &  !: sine of geographic latitude
+      &                                              area   ,         &  !: surface of grid cell 
+      &                                              tms    , tmu        !: temperature and velocity points masks
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2,2)     ::   wght   ,         &  !: weight of the 4 neighbours to compute averages
+      &                                              akappa , bkappa     !: first and third group of metric coefficients
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2,2,2,2) ::   alambd   !: second group of metric coefficients
+
+   !!======================================================================
+#endif
+END MODULE dom_ice_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/ice_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/ice_2.F90	(revision 1844)
@@ -0,0 +1,105 @@
+MODULE ice_2
+   !!======================================================================
+   !!                        ***  MODULE ice  ***
+   !! Sea Ice physics:  diagnostics variables of ice defined in memory
+   !!=====================================================================
+   !! History :  2.0  !  03-08  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice_2          ! LIM sea-ice parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !!* Share parameters namelist (namicerun read in iceini) *
+   CHARACTER(len=32)     , PUBLIC ::   cn_icerst_in  = "restart_ice_in"   !: suffix of ice restart name (input)
+   CHARACTER(len=32)     , PUBLIC ::   cn_icerst_out = "restart_ice"      !: suffix of ice restart name (output)
+   LOGICAL               , PUBLIC ::   ln_limdyn     = .TRUE.             !: flag for ice dynamics (T) or not (F)
+   LOGICAL               , PUBLIC ::   ln_limdmp     = .FALSE.            !: Ice damping
+   REAL(wp)              , PUBLIC ::   hsndif        = 0.e0               !: computation of temp. in snow (0) or not (9999)
+   REAL(wp)              , PUBLIC ::   hicdif        = 0.e0               !: computation of temp. in ice (0) or not (9999)
+   REAL(wp), DIMENSION(2), PUBLIC ::   acrit = (/ 1.e-06 , 1.e-06 /)      !: minimum fraction for leads in 
+   !                                                                      !: north and south hemisphere
+   !!* ice-dynamic namelist (namicedyn) *
+   INTEGER , PUBLIC ::   nbiter = 1         !: number of sub-time steps for relaxation
+   INTEGER , PUBLIC ::   nbitdr = 250       !: maximum number of iterations for relaxation
+   REAL(wp), PUBLIC ::   rdt_ice            !: ice time step
+   REAL(wp), PUBLIC ::   epsd   = 1.0e-20   !: tolerance parameter for dynamic
+   REAL(wp), PUBLIC ::   alpha  = 0.5       !: coefficient for semi-implicit coriolis
+   REAL(wp), PUBLIC ::   dm     = 0.6e+03   !: diffusion constant for dynamics
+   REAL(wp), PUBLIC ::   om     = 0.5       !: relaxation constant
+   REAL(wp), PUBLIC ::   resl   = 5.0e-05   !: maximum value for the residual of relaxation
+   REAL(wp), PUBLIC ::   cw     = 5.0e-03   !: drag coefficient for oceanic stress
+   REAL(wp), PUBLIC ::   angvg  = 0.e0      !: turning angle for oceanic stress
+   REAL(wp), PUBLIC ::   pstar  = 1.0e+04   !: first bulk-rheology parameter
+   REAL(wp), PUBLIC ::   c_rhg  = 20.e0     !: second bulk-rhelogy parameter
+   REAL(wp), PUBLIC ::   etamn  = 0.e+07    !: minimun value for viscosity
+   REAL(wp), PUBLIC ::   creepl = 2.e-08    !: creep limit
+   REAL(wp), PUBLIC ::   ecc    = 2.e0      !: eccentricity of the elliptical yield curve
+   REAL(wp), PUBLIC ::   ahi0   = 350.e0    !: sea-ice hor. eddy diffusivity coeff. (m2/s)
+
+   REAL(wp), PUBLIC ::   usecc2             !:  = 1.0 / ( ecc * ecc )
+   REAL(wp), PUBLIC ::   rhoco              !: = rau0 * cw
+   REAL(wp), PUBLIC ::   sangvg, cangvg     !: sin and cos of the turning angle for ocean stress
+   REAL(wp), PUBLIC ::   pstarh             !: pstar / 2.0
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ahiu , ahiv   !: hor. diffusivity coeff. at ocean U- and V-points (m2/s)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   pahu , pahv   !: ice hor. eddy diffusivity coef. at ocean U- and V-points
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hsnm , hicm   !: mean snow and ice thicknesses
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ust2s                 !: friction velocity
+
+   !!* diagnostic quantities
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sist          !: Sea-Ice Surface Temperature (Kelvin)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tfu           !: Freezing/Melting point temperature of sea water at SSS
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hicif         !: Ice thickness
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hsnif         !: Snow thickness
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hicifp        !: Ice production/melting
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   frld          !: Leads fraction = 1-a/totalarea
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   phicif        !: ice thickness  at previous time 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   pfrld         !: Leads fraction at previous time  
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qstoif        !: Energy stored in the brine pockets
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fbif          !: Heat flux at the ice base
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rdmsnif       !: Variation of snow mass
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rdmicif       !: Variation of ice mass
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qldif         !: heat balance of the lead (or of the open ocean)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qcmif         !: Energy needed to bring the ocean surface layer until its freezing 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fdtcn         !: net downward heat flux from the ice to the ocean
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qdtcn         !: energy from the ice to the ocean point (at a factor 2)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   thcm          !: part of the solar energy used in the lead heat budget
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fstric        !: Solar flux transmitted trough the ice
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ffltbif       !: Array linked with the max heat contained in brine pockets (?)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fscmbq        !: Linked with the solar flux below the ice (?)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fsbbq         !: Also linked with the solar flux below the ice (?)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qfvbq         !: Array used to store energy in case of toral lateral ablation (?)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   dmgwi         !: Variation of the mass of snow ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   u_ice, v_ice   !: two components of the ice   velocity at I-point (m/s)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   u_oce, v_oce   !: two components of the ocean velocity at I-point (m/s)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jplayersp1) ::   tbif  !: Temperature inside the ice/snow layer
+
+   !!* moment used in the advection scheme
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxice, syice, sxxice, syyice, sxyice   !: for ice  volume
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxsn,  sysn,  sxxsn,  syysn,  sxysn    !: for snow volume
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxa,   sya,   sxxa,   syya,   sxya     !: for ice cover area
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxc0,  syc0,  sxxc0,  syyc0,  sxyc0    !: for heat content of snow
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxc1,  syc1,  sxxc1,  syyc1,  sxyc1    !: for heat content of 1st ice layer
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxc2,  syc2,  sxxc2,  syyc2,  sxyc2    !: for heat content of 2nd ice layer
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sxst,  syst,  sxxst,  syyst,  sxyst    !: for heat content of brine pockets
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty module        NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE ice_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/iceini_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/iceini_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/iceini_2.F90	(revision 1844)
@@ -0,0 +1,110 @@
+MODULE iceini_2
+   !!======================================================================
+   !!                       ***  MODULE iceini   ***
+   !!   Sea-ice model : LIM 2.0 Sea ice model Initialization
+   !!======================================================================
+   !! History :   1.0  !  02-08  (G. Madec)  F90: Free form and modules
+   !!             2.0  !  03-08  (C. Ethe)  add ice_run
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   ice_init_2       : sea-ice model initialization
+   !!   ice_run_2        : Definition some run parameter for ice model
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE dom_ice_2
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE sbc_ice         ! surface boundary condition: ice
+   USE phycst          ! Define parameters for the routines
+   USE ice_2
+   USE limmsh_2
+   USE limistate_2
+   USE limrst_2   
+   USE in_out_manager
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ice_init_2               ! called by sbcice_lim_2.F90
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ice_init_2
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_init_2  ***
+      !!
+      !! ** purpose :   
+      !!----------------------------------------------------------------------
+      !
+      ! Open the namelist file 
+      CALL ctl_opn( numnam_ice, 'namelist_ice', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )      
+      CALL ice_run_2                    !  read in namelist some run parameters
+                 
+      ! Louvain la Neuve Ice model
+      rdt_ice = nn_fsbc * rdttra(1)
+
+      CALL lim_msh_2                  ! ice mesh initialization
+     
+      ! Initial sea-ice state
+      IF( .NOT.ln_rstart ) THEN
+         CALL lim_istate_2            ! start from rest: sea-ice deduced from sst
+      ELSE
+         CALL lim_rst_read_2          ! start from a restart file
+      ENDIF
+      
+      tn_ice(:,:,1) = sist(:,:)         ! initialisation of ice temperature   
+      fr_i  (:,:) = 1.0 - frld(:,:)   ! initialisation of sea-ice fraction    
+      !
+   END SUBROUTINE ice_init_2
+
+
+   SUBROUTINE ice_run_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_run_2 ***
+      !!                 
+      !! ** Purpose :   Definition some run parameter for ice model
+      !!
+      !! ** Method  :   Read the namicerun namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicerun
+      !!-------------------------------------------------------------------
+      NAMELIST/namicerun/ cn_icerst_in, cn_icerst_out, ln_limdyn, ln_limdmp, acrit, hsndif, hicdif
+      !!-------------------------------------------------------------------
+      !                    
+      REWIND ( numnam_ice )                       ! Read Namelist namicerun 
+      READ   ( numnam_ice , namicerun )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'ice_run : ice share parameters for dynamics/advection/thermo of sea-ice'
+         WRITE(numout,*) ' ~~~~~~'
+         WRITE(numout,*) '   switch for ice dynamics (1) or not (0)      ln_limdyn   = ', ln_limdyn
+         WRITE(numout,*) '   Ice damping                                 ln_limdmp   = ', ln_limdmp
+         WRITE(numout,*) '   minimum fraction for leads in the NH (SH)  acrit(1/2)   = ', acrit(:)
+         WRITE(numout,*) '   computation of temp. in snow (=0) or not (=9999) hsndif = ', hsndif
+         WRITE(numout,*) '   computation of temp. in ice  (=0) or not (=9999) hicdif = ', hicdif
+      ENDIF
+      !
+   END SUBROUTINE ice_run_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Empty module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ice_init_2      ! Empty routine
+   END SUBROUTINE ice_init_2
+#endif
+
+   !!======================================================================
+END MODULE iceini_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limadv_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limadv_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limadv_2.F90	(revision 1844)
@@ -0,0 +1,409 @@
+MODULE limadv_2 
+   !!======================================================================
+   !!                       ***  MODULE limadv_2   ***
+   !! LIM 2.0 sea-ice model : sea-ice advection
+   !!======================================================================
+   !! History :  OPA  ! 2000-01 (LIM)  Original code
+   !!                 ! 2001-05 (G. Madec, R. Hordoir) Doctor norm
+   !!   NEMO     1.0  ! 2003-10 (C. Ethe) F90, module
+   !!             -   ! 2003-12 (R. Hordoir, G. Madec) mpp
+   !!            3.2  ! 2009-06 (F. Dupont)  correct a error in the North fold b. c.
+   !!--------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_adv_x_2  : advection of sea ice on x axis
+   !!   lim_adv_y_2  : advection of sea ice on y axis
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE dom_ice_2
+   USE ice_2
+   USE lbclnk
+   USE in_out_manager     ! I/O manager
+   USE prtctl             ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_adv_x_2   ! called by lim_trp
+   PUBLIC   lim_adv_y_2   ! called by lim_trp
+
+   REAL(wp)  ::   epsi20 = 1.e-20   ! constant values
+   REAL(wp)  ::   rzero  = 0.e0     !    -       -
+   REAL(wp)  ::   rone   = 1.e0     !    -       -
+   
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2,  UCL-LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_adv_x_2( pdf, put , pcrh, psm , ps0 ,   &
+      &                    psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_x_2  **
+      !!  
+      !! ** purpose :   Computes and adds the advection trend to sea-ice
+      !!              variable on i-axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects tracers
+      !!              but also theirquadratic forms. The method preserves
+      !!              tracer structures by conserving second order moments.
+      !!
+      !! Reference:  Prather, 1986, JGR, 91, D6. 6671-6681.
+      !!--------------------------------------------------------------------
+      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
+      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   put                ! i-direction ice velocity at U-point [m/s]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      !! 
+      INTEGER  ::   ji, jj                               ! dummy loop indices
+      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp, zin0   ! temporary scalars
+      REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
+      REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zf0, zfx , zfy , zbet   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfm, zfxx, zfyy, zfxy   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.                                           
+
+      zrdt = rdt_ice * pdf      ! If ice drift field is too fast, use an appropriate time step for advection.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zslpmax = MAX( rzero, ps0(ji,jj) )
+            zs1max  = 1.5 * zslpmax
+            zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj) ) )
+            zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
+               &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj) )  )
+            zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+            !
+            ps0 (ji,jj) = zslpmax  
+            psx (ji,jj) = zs1new      * zin0
+            psxx(ji,jj) = zs2new      * zin0
+            psy (ji,jj) = psy (ji,jj) * zin0
+            psyy(ji,jj) = psyy(ji,jj) * zin0
+            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+         END DO
+      END DO
+
+      !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
+      psm (:,:)  = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
+
+      !  Calculate fluxes and moments between boxes i<-->i+1              
+      DO jj = 1, jpj                      !  Flux from i to i+1 WHEN u GT 0 
+         DO ji = 1, jpi
+            zbet(ji,jj)  =  MAX( rzero, SIGN( rone, put(ji,jj) ) )
+            zalf         =  MAX( rzero, put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji,jj)
+            zalfq        =  zalf * zalf
+            zalf1        =  1.0 - zalf
+            zalf1q       =  zalf1 * zalf1
+            !
+            zfm (ji,jj)  =  zalf  * psm(ji,jj)
+            zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psx(ji,jj) + (zalf1 - zalf) * psxx(ji,jj)  ) )
+            zfx (ji,jj)  =  zalfq * ( psx(ji,jj) + 3.0 * zalf1 * psxx(ji,jj) )
+            zfxx(ji,jj)  =  zalf  * zalfq * psxx(ji,jj)
+            zfy (ji,jj)  =  zalf  * ( psy(ji,jj) + zalf1 * psxy(ji,jj) )
+            zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
+            zfyy(ji,jj)  =  zalf  * psyy(ji,jj)
+            !
+            !  Readjust moments remaining in the box.
+            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+            psx (ji,jj)  =  zalf1q * ( psx(ji,jj) - 3.0 * zalf * psxx(ji,jj) )
+            psxx(ji,jj)  =  zalf1  * zalf1q * psxx(ji,jj)
+            psy (ji,jj)  =  psy (ji,jj) - zfy(ji,jj)
+            psyy(ji,jj)  =  psyy(ji,jj) - zfyy(ji,jj)
+            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 1, jpjm1                      !  Flux from i+1 to i when u LT 0.
+         DO ji = 1, fs_jpim1
+            zalf          = MAX( rzero, -put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji+1,jj) 
+            zalg  (ji,jj) = zalf
+            zalfq         = zalf * zalf
+            zalf1         = 1.0 - zalf
+            zalg1 (ji,jj) = zalf1
+            zalf1q        = zalf1 * zalf1
+            zalg1q(ji,jj) = zalf1q
+            zfm   (ji,jj) = zfm (ji,jj) + zalf  * psm(ji+1,jj)
+            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0(ji+1,jj) - zalf1 * ( psx(ji+1,jj) - (zalf1 - zalf ) * psxx(ji+1,jj) ) )
+            zfx   (ji,jj) = zfx (ji,jj) + zalfq * ( psx(ji+1,jj) - 3.0 * zalf1 * psxx(ji+1,jj) )
+            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  * zalfq * psxx(ji+1,jj)
+            zfy   (ji,jj) = zfy (ji,jj) + zalf  * ( psy(ji+1,jj) - zalf1 * psxy(ji+1,jj) )
+            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji+1,jj)
+            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  * psyy(ji+1,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji-1,jj) )
+            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji-1,jj) )
+            psx (ji,jj) = zalg1q(ji-1,jj) * ( psx(ji,jj) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj) )
+            psxx(ji,jj) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj)
+            psy (ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) - zfy (ji-1,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) - zfyy(ji-1,jj) )
+            psxy(ji,jj) = zalg1q(ji-1,jj) * psxy(ji,jj)
+         END DO
+      END DO
+
+      !   Put the temporary moments into appropriate neighboring boxes.    
+      DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj)
+            zalf        = zbt * zfm(ji-1,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji-1,jj)
+            !
+            ps0 (ji,jj) = zbt * (ps0(ji,jj) + zf0(ji-1,jj)) + zbt1 * ps0(ji,jj)
+            psx (ji,jj) = zbt * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp ) + zbt1 * psx(ji,jj)
+            psxx(ji,jj) = zbt * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj)                               &
+               &                + 5.0 * ( zalf * zalf1 * ( psx (ji,jj) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  )   &
+               &        + zbt1 * psxx(ji,jj)
+            psxy(ji,jj) = zbt * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj)             &
+               &                + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj) ) )   &
+               &         + zbt1 * psxy(ji,jj)
+            psy (ji,jj) = zbt * ( psy (ji,jj) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj)
+            psyy(ji,jj) = zbt * ( psyy(ji,jj) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Flux from i+1 to i IF u LT 0.
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji,jj)
+            zbt1 = 1.0 - zbet(ji,jj)
+            psm(ji,jj)  = zbt * psm(ji,jj)  + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
+            !
+            ps0(ji,jj)  = zbt * ps0 (ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
+            psx(ji,jj)  = zbt * psx (ji,jj) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp )
+            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * (  zalf * zalf * zfxx(ji,jj)  + zalf1 * zalf1 * psxx(ji,jj)   &
+               &                                      + 5.0 *( zalf * zalf1 * ( - psx(ji,jj) + zfx(ji,jj) )        &
+               &                                      + ( zalf1 - zalf ) * ztemp )                                 )
+            psxy(ji,jj) = zbt * psxy(ji,jj) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)          &
+               &                                      + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj) )  )
+            psy(ji,jj)  = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) + zfy (ji,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) + zfyy(ji,jj) )
+         END DO
+      END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T',  1. )   ;   CALL lbc_lnk( ps0 , 'T',  1. )
+      CALL lbc_lnk( psx , 'T', -1. )   ;   CALL lbc_lnk( psy , 'T', -1. )      ! caution gradient ==> the sign changes
+      CALL lbc_lnk( psxx, 'T',  1. )   ;   CALL lbc_lnk( psyy, 'T',  1. )
+      CALL lbc_lnk( psxy, 'T',  1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_x: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_x: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_x: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_x: psxy :')
+      ENDIF
+      !
+   END SUBROUTINE lim_adv_x_2
+
+
+   SUBROUTINE lim_adv_y_2( pdf, pvt , pcrh, psm , ps0 ,   &
+      &                    psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_y_2  **
+      !!            
+      !! ** purpose :   Computes and adds the advection trend to sea-ice 
+      !!              variable on j-axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects tracers
+      !!              but also their quadratic forms. The method preserves 
+      !!              tracer structures by conserving second order moments.
+      !!
+      !! Reference:  Prather, 1986, JGR, 91, D6. 6671-6681.
+      !!---------------------------------------------------------------------
+      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
+      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pvt                ! j-direction ice velocity at V-point [m/s]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      !!
+      INTEGER  ::   ji, jj                               ! dummy loop indices
+      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp, zin0   ! temporary scalars
+      REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
+      REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zf0, zfx , zfy , zbet   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfm, zfxx, zfyy, zfxy   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.
+
+      zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zslpmax = MAX( rzero, ps0(ji,jj) )
+            zs1max  = 1.5 * zslpmax
+            zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj) ) )
+            zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
+               &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj) )  )
+            zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+            !
+            ps0 (ji,jj) = zslpmax  
+            psx (ji,jj) = psx (ji,jj) * zin0
+            psxx(ji,jj) = psxx(ji,jj) * zin0
+            psy (ji,jj) = zs1new * zin0
+            psyy(ji,jj) = zs2new * zin0
+            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+         END DO
+      END DO
+
+      !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
+      psm(:,:)  = MAX(  pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20  )
+
+      !  Calculate fluxes and moments between boxes j<-->j+1              
+      DO jj = 1, jpj                     !  Flux from j to j+1 WHEN v GT 0   
+         DO ji = 1, jpi
+            zbet(ji,jj)  =  MAX( rzero, SIGN( rone, pvt(ji,jj) ) )
+            zalf         =  MAX( rzero, pvt(ji,jj) ) * zrdt * e1v(ji,jj) / psm(ji,jj)
+            zalfq        =  zalf * zalf
+            zalf1        =  1.0 - zalf
+            zalf1q       =  zalf1 * zalf1
+            zfm (ji,jj)  =  zalf  * psm(ji,jj)
+            zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psy(ji,jj)  + (zalf1-zalf) * psyy(ji,jj)  ) ) 
+            zfy (ji,jj)  =  zalfq *( psy(ji,jj) + 3.0*zalf1*psyy(ji,jj) )
+            zfyy(ji,jj)  =  zalf  * zalfq * psyy(ji,jj)
+            zfx (ji,jj)  =  zalf  * ( psx(ji,jj) + zalf1 * psxy(ji,jj) )
+            zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
+            zfxx(ji,jj)  =  zalf  * psxx(ji,jj)
+            !
+            !  Readjust moments remaining in the box.
+            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+            psy (ji,jj)  =  zalf1q * ( psy(ji,jj) -3.0 * zalf * psyy(ji,jj) )
+            psyy(ji,jj)  =  zalf1 * zalf1q * psyy(ji,jj)
+            psx (ji,jj)  =  psx (ji,jj) - zfx(ji,jj)
+            psxx(ji,jj)  =  psxx(ji,jj) - zfxx(ji,jj)
+            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+         END DO
+      END DO
+      !
+      DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
+         DO ji = 1, jpi
+            zalf          = ( MAX(rzero, -pvt(ji,jj) ) * zrdt * e1v(ji,jj) ) / psm(ji,jj+1) 
+            zalg  (ji,jj) = zalf
+            zalfq         = zalf * zalf
+            zalf1         = 1.0 - zalf
+            zalg1 (ji,jj) = zalf1
+            zalf1q        = zalf1 * zalf1
+            zalg1q(ji,jj) = zalf1q
+            zfm   (ji,jj) = zfm (ji,jj) + zalf  * psm(ji,jj+1)
+            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0(ji,jj+1) - zalf1 * (psy(ji,jj+1) - (zalf1 - zalf ) * psyy(ji,jj+1) ) )
+            zfy   (ji,jj) = zfy (ji,jj) + zalfq * ( psy(ji,jj+1) - 3.0 * zalf1 * psyy(ji,jj+1) )
+            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  * zalfq * psyy(ji,jj+1)
+            zfx   (ji,jj) = zfx (ji,jj) + zalf  * ( psx(ji,jj+1) - zalf1 * psxy(ji,jj+1) )
+            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji,jj+1)
+            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  * psxx(ji,jj+1)
+         END DO
+      END DO
+ 
+      !  Readjust moments remaining in the box. 
+      DO jj = 2, jpj
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj-1)
+            zbt1 = ( 1.0 - zbet(ji,jj-1) )
+            !
+            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji,jj-1) )
+            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji,jj-1) )
+            psy (ji,jj) = zalg1q(ji,jj-1) * ( psy(ji,jj) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj) )
+            psyy(ji,jj) = zalg1 (ji,jj-1)  * zalg1q(ji,jj-1) * psyy(ji,jj)
+            psx (ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) - zfx (ji,jj-1) )
+            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) - zfxx(ji,jj-1) )
+            psxy(ji,jj) = zalg1q(ji,jj-1) * psxy(ji,jj)
+         END DO
+      END DO
+
+      !   Put the temporary moments into appropriate neighboring boxes.    
+      DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj-1)
+            zbt1 = ( 1.0 - zbet(ji,jj-1) )
+            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj) 
+            zalf        = zbt * zfm(ji,jj-1) / psm(ji,jj) 
+            zalf1       = 1.0 - zalf
+            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji,jj-1)
+            !
+            ps0(ji,jj)  = zbt * (ps0(ji,jj) + zf0(ji,jj-1)) + zbt1 * ps0(ji,jj)
+            psy(ji,jj)  = zbt  * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj) + 3.0 * ztemp )   &
+               &        + zbt1 * psy(ji,jj)  
+            psyy(ji,jj) = zbt  * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj)                             &
+               &                 + 5.0 * ( zalf * zalf1 * ( psy(ji,jj) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) )   & 
+               &        + zbt1 * psyy(ji,jj)
+            psxy(ji,jj) = zbt  * ( zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj)              &
+               &                 + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj) ) )   &
+               &        + zbt1 * psxy(ji,jj)
+            psx (ji,jj) = zbt * ( psx (ji,jj) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj)
+            psxx(ji,jj) = zbt * ( psxx(ji,jj) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj)
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1                   !  Flux from j+1 to j IF v LT 0.
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj)
+            zbt1 = ( 1.0 - zbet(ji,jj) )
+            psm(ji,jj)  = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
+            ps0(ji,jj)  = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
+            psy(ji,jj)  = zbt  * psy(ji,jj)  &
+               &        + zbt1 * ( zalf*zfy(ji,jj) + zalf1 * psy(ji,jj) + 3.0 * ztemp )
+            psyy(ji,jj) = zbt  * psyy(ji,jj)                                                                         &
+               &        + zbt1 * ( zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj)                           &
+               &                 + 5.0 *( zalf *zalf1 *( -psy(ji,jj) + zfy(ji,jj) ) + ( zalf1 - zalf ) * ztemp ) )
+            psxy(ji,jj) = zbt  * psxy(ji,jj)                                  &
+               &        + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)   &
+               &                 + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj) ) )
+            psx(ji,jj)  = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) + zfx (ji,jj) )
+            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) + zfxx(ji,jj) )
+         END DO
+      END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T',  1. )   ;   CALL lbc_lnk( ps0 , 'T',  1. )
+      CALL lbc_lnk( psx , 'T', -1. )   ;   CALL lbc_lnk( psy , 'T', -1. )      ! caution gradient ==> the sign changes
+      CALL lbc_lnk( psxx, 'T',  1. )   ;   CALL lbc_lnk( psyy, 'T',  1. )
+      CALL lbc_lnk( psxy, 'T',  1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_y: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_y: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_y: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_y: psxy :')
+      ENDIF
+      !
+   END SUBROUTINE lim_adv_y_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy module     NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE limadv_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdia_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdia_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdia_2.F90	(revision 1844)
@@ -0,0 +1,282 @@
+MODULE limdia_2
+   !!======================================================================
+   !!                       ***  MODULE limdia_2   ***
+   !!                      diagnostics of ice model 
+   !!======================================================================
+   !! History :   8.0  !  97-06  (Louvain-La-Neuve)  Original code
+   !!             8.5  !  02-09  (C. Ethe , G. Madec )  F90: Free form and module
+   !!             9.0  !  06-08  (S. Masson)  change frequency output control
+   !!-------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_dia_2      : computation of the time evolution of keys var.
+   !!   lim_dia_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! 
+   USE par_ice_2       ! ice parameters
+   USE sbc_oce         ! surface boundary condition variables
+   USE dom_ice_2       !
+   USE ice_2           !
+   USE limistate_2     !
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC               lim_dia_2          ! called by sbc_ice_lim_2
+   INTEGER, PUBLIC ::   ntmoy   = 1 ,   &  !: instantaneous values of ice evolution or averaging ntmoy
+      &                 ninfo   = 1        !: frequency of ouputs on file ice_evolu in case of averaging
+
+   INTEGER, PARAMETER ::   &  ! Parameters for outputs to files "evolu"
+      jpinfmx = 100         ,    &  ! maximum number of key variables
+      jpchinf = 5           ,    &  ! ???
+      jpchsep = jpchinf + 2         ! ???
+
+   INTEGER ::   &
+      nfrinf  = 4 ,     &  ! number of variables written in one line 
+      nferme ,          &  ! last time step at which the var. are written on file
+      nvinfo ,          &  ! number of total variables 
+      nbvt   ,          &  ! number of time variables
+      naveg                ! number of step for accumulation before averaging
+
+   CHARACTER(len= 8) ::   fmtinf  = '1PE13.5 ' ! format of the output values  
+   CHARACTER(len=30) ::   fmtw  ,           &  ! formats
+      &                   fmtr  ,           &  ! ???
+      &                   fmtitr               ! ???
+   CHARACTER(len=jpchsep), DIMENSION(jpinfmx) ::   titvar               ! title of key variables
+ 
+   REAL(wp)                     ::   epsi06 = 1.e-06      ! ???
+   REAL(wp), DIMENSION(jpinfmx) ::   vinfom               ! temporary working space
+   REAL(wp), DIMENSION(jpi,jpj) ::   aire                 ! masked grid cell area
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dia_2( kt )
+      !!--------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dia_2  ***
+      !!   
+      !! ** Purpose : Computation and outputs on file ice.evolu 
+      !!      the temporal evolution of some key variables
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER  ::   jv,ji, jj   ! dummy loop indices
+      INTEGER  ::   nv          ! indice of variable 
+      REAL(wp) ::   zarea    , zldarea  ,    &  ! sea-ice and leads area
+         &          zextent15, zextent85,    &  ! sea-ice extent (15% and 85%)
+         &          zicevol  , zsnwvol  ,    &  ! sea-ice and snow volume volume
+         &          zicespd                     ! sea-ice velocity
+      REAL(wp), DIMENSION(jpinfmx) ::   vinfor  ! temporary working space 
+      !!-------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL lim_dia_init_2  ! initialisation of ice_evolu file      
+
+      ! computation of key variables at each time step   
+
+      nv = 1 
+      vinfor(nv) = REAL( kt + nn_fsbc - 1 )
+      nv = nv + 1
+      vinfor(nv) = nyear
+ 
+      DO jv = nbvt + 1, nvinfo
+         vinfor(jv) = 0.e0
+      END DO
+
+      zextent15 = 0.e0
+      zextent85 = 0.e0
+      ! variables in northern Hemis
+      DO jj = njeq, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               zarea = ( 1.0 - frld(ji,jj) ) * aire(ji,jj)
+               IF (frld(ji,jj) <= 0.15 ) zextent15 = aire(ji,jj)    
+               IF (frld(ji,jj) <= 0.85 ) zextent85 = aire(ji,jj)   
+               zldarea = zarea   / MAX( ( 1 - frld(ji,jj) ) , epsi06 )
+               zicevol = zarea   * hicif(ji,jj)
+               zsnwvol = zarea   * hsnif(ji,jj)
+               zicespd = zicevol * ( u_ice(ji,jj) * u_ice(ji,jj) + v_ice(ji,jj) * v_ice(ji,jj) )
+               vinfor(nv+ 1) = vinfor(nv+ 1) + zarea
+               vinfor(nv+ 3) = vinfor(nv+ 3) + zextent15
+               vinfor(nv+ 5) = vinfor(nv+ 5) + zextent85
+               vinfor(nv+ 7) = vinfor(nv+ 7) + zldarea
+               vinfor(nv+ 9) = vinfor(nv+ 9) + zicevol
+               vinfor(nv+11) = vinfor(nv+11) + zsnwvol
+               vinfor(nv+13) = vinfor(nv+13) + zicespd
+            ENDIF
+         END DO
+      END DO
+      vinfor(nv+13) = SQRT( vinfor(nv+13) / MAX( vinfor(nv+9) , epsi06 ) )
+
+
+      ! variables in southern Hemis
+       nv = nv + 1
+       DO jj = 2, njeqm1
+          DO ji = fs_2, fs_jpim1   ! vector opt.
+             IF( tms(ji,jj) == 1 ) THEN
+                zarea = ( 1.0 - frld(ji,jj) ) * aire(ji,jj)
+                IF (frld(ji,jj) <= 0.15 ) zextent15 = aire(ji,jj)    
+                IF (frld(ji,jj) <= 0.85 ) zextent85 = aire(ji,jj)   
+                zldarea = zarea   / MAX( ( 1 - frld(ji,jj) ) , epsi06 )
+                zicevol = zarea   * hicif(ji,jj)
+                zsnwvol = zarea   * hsnif(ji,jj)
+                zicespd = zicevol * ( u_ice(ji,jj) * u_ice(ji,jj) + v_ice(ji,jj) * v_ice(ji,jj) )
+                vinfor(nv+ 1) = vinfor(nv+ 1) + zarea
+                vinfor(nv+ 3) = vinfor(nv+ 3) + zextent15
+                vinfor(nv+ 5) = vinfor(nv+ 5) + zextent85
+                vinfor(nv+ 7) = vinfor(nv+ 7) + zldarea
+                vinfor(nv+ 9) = vinfor(nv+ 9) + zicevol
+                vinfor(nv+11) = vinfor(nv+11) + zsnwvol
+                vinfor(nv+13) = vinfor(nv+13) + zicespd
+             ENDIF
+          END DO
+       END DO
+       vinfor(nv+13) = SQRT( vinfor(nv+13) / MAX( vinfor(nv+9) , epsi06 ) )    
+
+       !  Accumulation before averaging 
+       DO jv = 1, nvinfo
+          vinfom(jv) = vinfom(jv) + vinfor(jv)
+       END DO
+       naveg = naveg + 1  
+    
+       ! oututs on file ice_evolu    
+       IF( MOD( kt + nn_fsbc - 1, ninfo ) == 0 ) THEN
+          WRITE(numevo_ice,fmtw) ( titvar(jv), vinfom(jv)/naveg, jv = 1, nvinfo )
+          naveg = 0
+          DO jv = 1, nvinfo
+             vinfom(jv) = 0.e0
+          END DO
+       ENDIF
+       !
+    END SUBROUTINE lim_dia_2
+ 
+
+    SUBROUTINE lim_dia_init_2
+       !!-------------------------------------------------------------------
+       !!                  ***  ROUTINE lim_dia_init_2  ***
+       !!             
+       !! ** Purpose : Preparation of the file ice_evolu for the output of
+       !!      the temporal evolution of key variables
+       !!
+       !! ** input   : Namelist namicedia
+       !!-------------------------------------------------------------------
+       CHARACTER(len=jpchinf) ::   titinf
+       INTEGER  ::   jv            ! dummy loop indice
+       INTEGER  ::   ntot , ndeb 
+       INTEGER  ::   nv            ! indice of variable 
+       REAL(wp) ::   zxx0, zxx1    ! temporary scalars
+
+       NAMELIST/namicedia/fmtinf, nfrinf, ninfo, ntmoy
+       !!-------------------------------------------------------------------
+
+       ! Read Namelist namicedia
+       REWIND ( numnam_ice )
+       READ   ( numnam_ice  , namicedia )
+       
+       IF(lwp) THEN
+          WRITE(numout,*)
+          WRITE(numout,*) 'lim_dia_init_2 : ice parameters for ice diagnostics '
+          WRITE(numout,*) '~~~~~~~~~~~~~~'
+          WRITE(numout,*) '   format of the output values                                 fmtinf = ', fmtinf
+          WRITE(numout,*) '   number of variables written in one line                     nfrinf = ', nfrinf 
+          WRITE(numout,*) '   Instantaneous values of ice evolution or averaging          ntmoy  = ', ntmoy
+          WRITE(numout,*) '   frequency of ouputs on file ice_evolu in case of averaging  ninfo  = ', ninfo
+       ENDIF
+
+       ! masked grid cell area
+       aire(:,:) = area(:,:) * tms(:,:)
+
+       ! Titles of ice key variables :
+       nv = 1
+       titvar(nv) = 'NoIt'  ! iteration number
+       nv = nv + 1
+       titvar(nv) = 'T yr'  ! time step in years
+       
+       nbvt = nv - 1
+
+       nv = nv + 1   ;   titvar(nv) = 'AEFN' ! sea ice area in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'AEFS' ! sea ice area in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A15N'  ! sea ice extent (15%) in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A15S'  ! sea ice extent (15%) in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A85N'  ! sea ice extent (85%) in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A85S'  ! sea ice extent (85%) in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'ALEN'  ! leads area in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'ALES'  ! leads area in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'VOLN'  ! sea ice volume in the northern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VOLS'  ! sea ice volume in the southern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VONN'  ! snow volume over sea ice in the northern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VONS'  ! snow volume over sea ice in the southern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'ECGN'  ! mean sea ice velocity in the northern Hemisp.(m/s)
+       nv = nv + 1   ;   titvar(nv) = 'ECGS'  ! mean sea ice velocity in the southern Hemisp.(m/s)
+
+       nvinfo = nv
+
+       ! Definition et Ecriture de l'entete : nombre d'enregistrements 
+       ndeb   = ( nit000 - 1 + nn_fsbc - 1 ) / ninfo
+       IF( nit000 - 1 + nn_fsbc == 1 ) ndeb = -1
+
+       nferme = ( nitend + nn_fsbc - 1 ) / ninfo ! nit000 - 1 + nn_fsbc - 1 + nitend - nit000 + 1
+       ntot   = nferme - ndeb
+       ndeb   = ninfo * ( 1 + ndeb )
+       nferme = ninfo * nferme
+
+       ! definition of formats 
+       WRITE( fmtw  , '(A,I3,A2,I1,A)' )  '(', nfrinf, '(A', jpchsep, ','//fmtinf//'))'
+       WRITE( fmtr  , '(A,I3,A,I1,A)'  )  '(', nfrinf, '(', jpchsep, 'X,'//fmtinf//'))'
+       WRITE( fmtitr, '(A,I3,A,I1,A)'  )  '(', nvinfo, 'A', jpchinf, ')'
+
+       ! opening  "ice_evolu" file
+       CALL ctl_opn( numevo_ice, 'ice_evolu', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+
+       !- ecriture de 2 lignes d''entete :
+       WRITE(numevo_ice,1000) fmtr, fmtw, fmtitr, nvinfo, ntot, 0, nfrinf
+       zxx0 = 0.001 * REAL( ninfo )
+       zxx1 = 0.001 * REAL( ndeb  )
+       WRITE(numevo_ice,1111) REAL(jpchinf), 0., zxx1, zxx0, 0., 0., 0
+
+       !- ecriture de 2 lignes de titre :
+       WRITE(numevo_ice,'(A,I8,A,I8,A,I5)')                 &
+          'Evolution chronologique - Experience '//cexper   &
+          //'   de', ndeb, ' a', nferme, ' pas', ninfo
+       WRITE(numevo_ice,fmtitr) ( titvar(jv), jv = 1, nvinfo )
+
+
+       !--preparation de "titvar" pour l''ecriture parmi les valeurs numeriques :
+       DO  jv = 2 , nvinfo
+          titinf     = titvar(jv)(:jpchinf)
+          titvar(jv) = '  '//titinf
+       END DO
+
+       !--Initialisation of the arrays for the accumulation
+       DO  jv = 1, nvinfo
+          vinfom(jv) = 0.
+       END DO
+       naveg = 0
+
+1000   FORMAT( 3(A20),4(1x,I6) )
+1111   FORMAT( 3(F7.1,1X,F7.3,1X),I3,A )  
+      !
+    END SUBROUTINE lim_dia_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                           NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dia_2         ! Empty routine
+   END SUBROUTINE lim_dia_2
+#endif
+
+   !!======================================================================
+END MODULE limdia_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdmp_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 1844)
@@ -0,0 +1,180 @@
+MODULE limdmp_2
+   !!======================================================================
+   !!                       ***  MODULE limdmp_2   ***
+   !!  Ice model : restoring Ice thickness and Fraction leads
+   !!======================================================================
+   !! History :   2.0  !  04-04 (S. Theetten) Original code
+   !!----------------------------------------------------------------------
+#if defined key_lim2   &&   defined key_tradmp
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  AND                               LIM 2.0 sea-ice model
+   !!   'key_tradmp'                                                Damping
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_dmp_2      : ice model damping
+   !!----------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE ice_2
+   USE tradmp
+   USE dom_oce
+   USE oce
+   USE iom
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_dmp_2     ! called by ice_step_2
+   
+   INTEGER                        ::   nice1, nice2,  &  ! first and second record used
+      &                                inumice_dmp       ! logical unit for ice variables (damping)
+   REAL(wp), DIMENSION(jpi,jpj)   ::   hicif_dta  ,   &  ! ice thickness at a given time
+      &                                frld_dta          ! fraction lead at a given time
+   REAL(wp), DIMENSION(jpi,jpj,2) ::   hicif_data ,   &  ! ice thickness data at two consecutive times
+      &                                frld_data         ! fraction lead data at two consecutive times
+
+   !! * Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0 , UCL-LOCEAN-IPSL  (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dmp_2(kt)
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_dmp_2 ***
+      !!
+      !! ** purpose : ice model damping : restoring ice thickness and 
+      !!              fraction leads
+      !!
+      !! ** method  : the key_tradmp must be used to compute resto(:,:) coef.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !
+      INTEGER             ::   ji, jj         ! dummy loop indices
+      !!---------------------------------------------------------------------
+      !
+      CALL dta_lim_2( kt )
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            hicif(ji,jj) = hicif(ji,jj) - rdt_ice * resto(ji,jj,1) * ( hicif(ji,jj) - hicif_dta(ji,jj) )
+            frld(ji,jj)  = frld (ji,jj) - rdt_ice * resto(ji,jj,1) * ( frld(ji,jj)  - frld_dta (ji,jj) )  
+         END DO
+      END DO
+      !
+   END SUBROUTINE lim_dmp_2
+
+
+   SUBROUTINE dta_lim_2( kt ) 
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dta_lim_2  ***
+      !!
+      !! ** Purpose :   Reads monthly ice thickness and fraction lead  data
+      !!
+      !! ** Method  :   Read on unit numicedt the interpolated ice variable
+      !!      onto the model grid.
+      !!      Data begin at january.
+      !!      The value is centered at the middle of month.
+      !!      In the opa model, kt=1 agree with january 1.
+      !!      At each time step, a linear interpolation is applied between
+      !!      two monthly values.
+      !!      
+      !! ** Action  :   define hicif_dta and frld_dta arrays at time-step kt
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !
+      INTEGER  ::   imois, iman, i15          ! temporary integers
+      REAL(wp) ::   zxy
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization
+      ! -----------------
+      iman  = INT( raamo )
+!!! better but change the results     i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) )
+      i15   = nday / 16
+      imois = nmonth + i15 - 1
+      IF( imois == 0 ) imois = iman
+      
+      ! 1. First call kt=nit000: Initialization and Open
+      ! -----------------------
+      IF( kt == nit000 ) THEN
+         nice1 = 0
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dtalim : Ice thickness and lead fraction  monthly fields'
+         IF(lwp) WRITE(numout,*) '~~~~~~'
+         IF(lwp) WRITE(numout,*) '             NetCDF FORMAT'
+         IF(lwp) WRITE(numout,*)
+         ! open file
+         CALL iom_open( 'ice_damping_ATL4.nc', inumice_dmp )
+      ENDIF
+
+
+      ! 2. Read monthly file
+      ! --------------------
+      IF( ( kt == nit000 ) .OR. imois /= nice1 ) THEN
+         !
+         ! Calendar computation
+         nice1 = imois        ! first file record used 
+         nice2 = nice1 + 1    ! last  file record used
+         nice1 = MOD( nice1, iman )
+         nice2 = MOD( nice2, iman )
+         IF( nice1 == 0 )   nice1 = iman
+         IF( nice2 == 0 )   nice2 = iman
+         IF(lwp) WRITE(numout,*) 'first record file used nice1 ', nice1
+         IF(lwp) WRITE(numout,*) 'last  record file used nice2 ', nice2
+         
+         ! Read monthly ice thickness Levitus 
+         CALL iom_get( inumice_dmp, jpdom_data, 'iicethic', hicif_data(:,:,1), nice1 ) 
+         CALL iom_get( inumice_dmp, jpdom_data, 'iicethic', hicif_data(:,:,2), nice2 ) 
+         
+         ! Read monthly ice thickness Levitus 
+         CALL iom_get( inumice_dmp, jpdom_data, 'ileadfra', frld_data(:,:,1), nice1 ) 
+         CALL iom_get( inumice_dmp, jpdom_data, 'ileadfra', frld_data(:,:,2), nice2 ) 
+         
+         ! The fraction lead read in the file is in fact the 
+         ! ice concentration which is 1 - the fraction lead
+         frld_data = 1 - frld_data          
+         
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' Ice thickness month ', nice1,' and ', nice2
+            WRITE(numout,*)
+            WRITE(numout,*) ' Ice thickness month = ', nice1
+            CALL prihre( hicif_data(1,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+            WRITE(numout,*)
+            WRITE(numout,*) ' Fraction lead months ', nice1,' and ', nice2
+            WRITE(numout,*)
+            WRITE(numout,*) ' Fraction lead month = ', nice1
+            CALL prihre( frld_data(1,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+         ENDIF
+
+         CALL FLUSH(numout)
+
+      ENDIF
+        
+      ! 3. At every time step compute ice thickness and fraction lead data
+      ! ------------------------------------------------------------------
+      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+      hicif_dta(:,:) = (1.-zxy) * hicif_data(:,:,1) + zxy * hicif_data(:,:,2)
+      frld_dta (:,:) = (1.-zxy) * frld_data (:,:,1) + zxy * frld_data (:,:,2)
+
+      IF( kt == nitend )   CALL iom_close( inumice_dmp )
+      !
+   END SUBROUTINE dta_lim_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                  No ice damping
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dmp_2( kt )        ! Dummy routine
+      WRITE(*,*) 'lim_dmp_2: You should not see this print! error? ', kt
+   END SUBROUTINE lim_dmp_2
+#endif
+
+   !!======================================================================
+END MODULE limdmp_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdyn_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 1844)
@@ -0,0 +1,250 @@
+MODULE limdyn_2
+   !!======================================================================
+   !!                     ***  MODULE  limdyn_2  ***
+   !!   Sea-Ice dynamics :  
+   !!======================================================================
+   !! History :   1.0  !  01-04  (LIM)  Original code
+   !!             2.0  !  02-08  (C. Ethe, G. Madec)  F90, mpp
+   !!             2.0  !  03-08  (C. Ethe) add lim_dyn_init
+   !!             2.0  !  06-07  (G. Madec)  Surface module
+   !!---------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!    lim_dyn_2      : computes ice velocities
+   !!    lim_dyn_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_oce        !
+   USE phycst         !
+   USE ice_2          !
+   USE dom_ice_2      !
+   USE limistate_2    !
+   USE limrhg_2       ! ice rheology
+
+   USE lbclnk         !
+   USE lib_mpp        !
+   USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_dyn_2 ! routine called by sbc_ice_lim
+
+   !! * Module variables
+   REAL(wp)  ::  rone    = 1.e0   ! constant value
+
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dyn_2( kt )
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_dyn_2  ***
+      !!               
+      !! ** Purpose :   compute ice velocity and ocean-ice friction velocity
+      !!                
+      !! ** Method  : 
+      !!
+      !! ** Action  : - Initialisation
+      !!              - Call of the dynamic routine for each hemisphere
+      !!              - computation of the friction velocity at the sea-ice base
+      !!              - treatment of the case if no ice dynamic
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER  ::   ji, jj             ! dummy loop indices
+      INTEGER  ::   i_j1, i_jpj        ! Starting/ending j-indices for rheology
+      REAL(wp) ::   zcoef              ! temporary scalar
+      REAL(wp), DIMENSION(jpj)     ::   zind           ! i-averaged indicator of sea-ice
+      REAL(wp), DIMENSION(jpj)     ::   zmsk           ! i-averaged of tmask
+      REAL(wp), DIMENSION(jpi,jpj) ::   zu_io, zv_io   ! ice-ocean velocity
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL lim_dyn_init_2   ! Initialization (first time-step only)
+      
+      IF( ln_limdyn ) THEN
+         !
+         ! Mean ice and snow thicknesses.          
+         hsnm(:,:)  = ( 1.0 - frld(:,:) ) * hsnif(:,:)
+         hicm(:,:)  = ( 1.0 - frld(:,:) ) * hicif(:,:)
+         !
+         !                                     ! Rheology (ice dynamics)
+         !                                     ! ========
+         
+         !  Define the j-limits where ice rheology is computed
+         ! ---------------------------------------------------
+         
+         IF( lk_mpp .OR. nbit_cmp == 1 ) THEN                    ! mpp: compute over the whole domain
+            i_j1 = 1   
+            i_jpj = jpj
+            IF(ln_ctl)   CALL prt_ctl_info( 'lim_dyn  :    i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj )
+            CALL lim_rhg_2( i_j1, i_jpj )
+            !
+         ELSE                                 ! optimization of the computational area
+            !
+            DO jj = 1, jpj
+               zind(jj) = SUM( frld (:,jj  ) )   ! = FLOAT(jpj) if ocean everywhere on a j-line
+               zmsk(jj) = SUM( tmask(:,jj,1) )   ! = 0          if land  everywhere on a j-line
+            END DO
+            !
+            IF( l_jeq ) THEN                     ! local domain include both hemisphere
+               !                                 ! Rheology is computed in each hemisphere
+               !                                 ! only over the ice cover latitude strip
+               ! Northern hemisphere
+               i_j1  = njeq
+               i_jpj = jpj
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-1 )
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : NH i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+               ! 
+               CALL lim_rhg_2( i_j1, i_jpj )
+               ! 
+               ! Southern hemisphere
+               i_j1  =  1 
+               i_jpj = njeq
+               DO WHILE ( i_jpj >= 1 .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+2 )
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : SH i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+               ! 
+               CALL lim_rhg_2( i_j1, i_jpj )
+               ! 
+            ELSE                                 ! local domain extends over one hemisphere only
+               !                                 ! Rheology is computed only over the ice cover
+               !                                 ! latitude strip
+               i_j1  = 1
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-1 )
+    
+               i_jpj  = jpj
+               DO WHILE ( i_jpj >= 1  .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+2)
+    
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : one hemisphere: i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+               ! 
+               CALL lim_rhg_2( i_j1, i_jpj )
+               !
+            ENDIF
+            !
+         ENDIF
+
+         IF(ln_ctl)   CALL prt_ctl(tab2d_1=u_ice , clinfo1=' lim_dyn  : u_ice :', tab2d_2=v_ice , clinfo2=' v_ice :')
+         
+         ! computation of friction velocity
+         ! --------------------------------
+         ! ice-ocean velocity at U & V-points (u_ice v_ice at I-point ; ssu_m, ssv_m at U- & V-points)
+         
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1   ! NO vector opt.
+               zu_io(ji,jj) = 0.5 * ( u_ice(ji+1,jj+1) + u_ice(ji+1,jj  ) ) - ssu_m(ji,jj)
+               zv_io(ji,jj) = 0.5 * ( v_ice(ji+1,jj+1) + v_ice(ji  ,jj+1) ) - ssv_m(ji,jj)
+            END DO
+         END DO
+         ! frictional velocity at T-point
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! NO vector opt. because of zu_io
+               ust2s(ji,jj) = 0.5 * cw                                                          &
+                  &         * (  zu_io(ji,jj) * zu_io(ji,jj) + zu_io(ji-1,jj) * zu_io(ji-1,jj)   &
+                  &            + zv_io(ji,jj) * zv_io(ji,jj) + zv_io(ji,jj-1) * zv_io(ji,jj-1)   ) * tms(ji,jj)
+            END DO
+         END DO
+         !
+      ELSE      ! no ice dynamics : transmit directly the atmospheric stress to the ocean
+         !
+         zcoef = SQRT( 0.5 ) / rau0
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ust2s(ji,jj) = zcoef * tms(ji,jj) * SQRT(  utau(ji,jj) * utau(ji,jj) + utau(ji-1,jj) * utau(ji-1,jj)   &
+                  &                                     + vtau(ji,jj) * vtau(ji,jj) + vtau(ji,jj-1) * vtau(ji,jj-1) )
+            END DO
+         END DO
+         !
+      ENDIF
+      !
+      CALL lbc_lnk( ust2s, 'T',  1. )   ! T-point
+      !
+      IF(ln_ctl)   CALL prt_ctl(tab2d_1=ust2s , clinfo1=' lim_dyn  : ust2s :')
+
+   END SUBROUTINE lim_dyn_2
+
+
+   SUBROUTINE lim_dyn_init_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dyn_init_2  ***
+      !!
+      !! ** Purpose :   Physical constants and parameters linked to the ice
+      !!              dynamics
+      !!
+      !! ** Method  :   Read the namicedyn namelist and check the ice-dynamic
+      !!              parameter values
+      !!
+      !! ** input   :   Namelist namicedyn
+      !!-------------------------------------------------------------------
+      NAMELIST/namicedyn/ epsd, alpha,     &
+         &                dm, nbiter, nbitdr, om, resl, cw, angvg, pstar,   &
+         &                c_rhg, etamn, creepl, ecc, ahi0
+      !!-------------------------------------------------------------------
+
+      REWIND ( numnam_ice )                       ! Read Namelist namicedyn
+      READ   ( numnam_ice  , namicedyn )
+
+      IF(lwp) THEN                                ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_dyn_init_2: ice parameters for ice dynamics '
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '       tolerance parameter                              epsd   = ', epsd
+         WRITE(numout,*) '       coefficient for semi-implicit coriolis           alpha  = ', alpha
+         WRITE(numout,*) '       diffusion constant for dynamics                  dm     = ', dm
+         WRITE(numout,*) '       number of sub-time steps for relaxation          nbiter = ', nbiter
+         WRITE(numout,*) '       maximum number of iterations for relaxation      nbitdr = ', nbitdr
+         WRITE(numout,*) '       relaxation constant                              om     = ', om
+         WRITE(numout,*) '       maximum value for the residual of relaxation     resl   = ', resl
+         WRITE(numout,*) '       drag coefficient for oceanic stress              cw     = ', cw
+         WRITE(numout,*) '       turning angle for oceanic stress                 angvg  = ', angvg, ' degrees'
+         WRITE(numout,*) '       first bulk-rheology parameter                    pstar  = ', pstar
+         WRITE(numout,*) '       second bulk-rhelogy parameter                    c_rhg  = ', c_rhg
+         WRITE(numout,*) '       minimun value for viscosity                      etamn  = ', etamn
+         WRITE(numout,*) '       creep limit                                      creepl = ', creepl
+         WRITE(numout,*) '       eccentricity of the elliptical yield curve       ecc    = ', ecc
+         WRITE(numout,*) '       horizontal diffusivity coeff. for sea-ice        ahi0   = ', ahi0
+      ENDIF
+
+      !  Initialization
+      usecc2 = 1.0 / ( ecc * ecc )
+      rhoco  = rau0 * cw
+      angvg  = angvg * rad      ! convert angvg from degree to radian
+      sangvg = SIN( angvg )
+      cangvg = COS( angvg )
+      pstarh = pstar / 2.0
+      !
+      ahiu(:,:) = ahi0 * umask(:,:,1)            ! Ice eddy Diffusivity coefficients.
+      ahiv(:,:) = ahi0 * vmask(:,:,1)
+      !
+   END SUBROUTINE lim_dyn_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Empty module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dyn_2         ! Empty routine
+   END SUBROUTINE lim_dyn_2
+#endif 
+
+   !!======================================================================
+END MODULE limdyn_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limhdf_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 1844)
@@ -0,0 +1,184 @@
+MODULE limhdf_2
+   !!======================================================================
+   !!                    ***  MODULE limhdf_2   ***
+   !! LIM 2.0 ice model : horizontal diffusion of sea-ice quantities
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_hdf_2  : diffusion trend on sea-ice variable
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce
+   USE in_out_manager
+   USE ice_2
+   USE lbclnk
+   USE lib_mpp
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_hdf_2    ! called by lim_tra_2
+
+   !! * Module variables
+   LOGICAL  ::   linit = .TRUE.              ! ???
+   REAL(wp) ::   epsi04 = 1e-04              ! constant
+   REAL(wp), DIMENSION(jpi,jpj) ::   zfact   ! ???
+
+   !! * Substitution 
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_hdf_2( ptab )
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_hdf_2  ***
+      !!
+      !! ** purpose :   Compute and add the diffusive trend on sea-ice
+      !!      variables
+      !!
+      !! ** method  :   Second order diffusive operator evaluated using a
+      !!      Cranck-Nicholson time Scheme.
+      !!
+      !! ** Action  :    update ptab with the diffusive contribution
+      !!
+      !! History :
+      !!        !  00-01 (LIM) Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!        !  02-08 (C. Ethe)  F90, free form
+      !!-------------------------------------------------------------------
+      ! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         ptab                 ! Field on which the diffusion is applied  
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ptab0                ! ???
+
+      ! * Local variables
+      INTEGER ::  ji, jj      ! dummy loop indices
+      INTEGER ::  &
+         its, iter            ! temporary integers
+      CHARACTER (len=55) :: charout
+      REAL(wp) ::  &
+         zalfa, zrlxint, zconv, zeps   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::  & 
+         zrlx, zflu, zflv, &  ! temporary workspaces
+         zdiv0, zdiv          !    "           "
+      !!-------------------------------------------------------------------
+
+      ! Initialisation
+      ! ---------------   
+      ! Time integration parameters
+      zalfa = 0.5       ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit
+      its   = 100       ! Maximum number of iteration
+      zeps  =  2. * epsi04
+
+      ! Arrays initialization
+      ptab0 (:, : ) = ptab(:,:)
+!bug  zflu (:,jpj) = 0.e0
+!bug  zflv (:,jpj) = 0.e0
+      zdiv0(:, 1 ) = 0.e0
+      zdiv0(:,jpj) = 0.e0
+      IF( .NOT.lk_vopt_loop ) THEN
+         zflu (jpi,:) = 0.e0   
+         zflv (jpi,:) = 0.e0
+         zdiv0(1,  :) = 0.e0
+         zdiv0(jpi,:) = 0.e0
+      ENDIF
+
+      ! Metric coefficient (compute at the first call and saved in
+      IF( linit ) THEN
+         DO jj = 2, jpjm1  
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zfact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj  ) + e1v(ji,jj) + e1v(ji,jj-1) ) &
+                  &          / ( e1t(ji,jj) * e2t(ji,jj) )
+            END DO
+         END DO
+         linit = .FALSE.
+      ENDIF
+
+
+      ! Sub-time step loop
+      zconv = 1.e0
+      iter  = 0
+
+      !                                                   !===================
+      DO WHILE ( ( zconv > zeps ) .AND. (iter <= its) )   ! Sub-time step loop
+         !                                                !===================
+         ! incrementation of the sub-time step number
+         iter = iter + 1
+
+         ! diffusive fluxes in U- and V- direction
+         DO jj = 1, jpjm1
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) / e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) )
+               zflv(ji,jj) = pahv(ji,jj) * e1v(ji,jj) / e2v(ji,jj) * ( ptab(ji,jj+1) - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! diffusive trend : divergence of the fluxes
+         DO jj= 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt. 
+               zdiv (ji,jj) = (  zflu(ji,jj) - zflu(ji-1,jj  )   &
+                  &            + zflv(ji,jj) - zflv(ji  ,jj-1)  ) / ( e1t (ji,jj) * e2t (ji,jj) )
+            END DO
+         END DO
+
+         ! save the first evaluation of the diffusive trend in zdiv0
+         IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)       
+
+         ! XXXX iterative evaluation?????
+         DO jj = 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zrlxint = (   ptab0(ji,jj)    &
+                  &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + zfact(ji,jj) * ptab(ji,jj) )   &
+                  &                      + ( 1.0 - zalfa ) *   zdiv0(ji,jj) )  )                             & 
+                  &    / ( 1.0 + zalfa * rdt_ice * zfact(ji,jj) )
+               zrlx(ji,jj) = ptab(ji,jj) + om * ( zrlxint - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! lateral boundary condition on ptab
+         CALL lbc_lnk( zrlx, 'T', 1. )
+
+         ! convergence test
+         zconv = 0.e0
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zconv = MAX( zconv, ABS( zrlx(ji,jj) - ptab(ji,jj) )  )
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_max( zconv )   ! max over the global domain
+
+         ptab(:,:) = zrlx(:,:)
+
+         !                                         !==========================
+      END DO                                       ! end of sub-time step loop
+      !                                            !==========================
+
+      IF(ln_ctl)   THEN
+         zrlx(:,:) = ptab(:,:) - ptab0(:,:)
+         WRITE(charout,FMT="(' lim_hdf  : zconv =',D23.16, ' iter =',I4,2X)") zconv, iter
+         CALL prt_ctl(tab2d_1=zrlx, clinfo1=charout)
+      ENDIF
+
+   END SUBROUTINE lim_hdf_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_hdf_2       ! Empty routine
+   END SUBROUTINE lim_hdf_2
+#endif
+
+   !!======================================================================
+END MODULE limhdf_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limistate_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limistate_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limistate_2.F90	(revision 1844)
@@ -0,0 +1,216 @@
+MODULE limistate_2
+   !!======================================================================
+   !!                     ***  MODULE  limistate_2  ***
+   !!              Initialisation of diagnostics ice variables
+   !!======================================================================
+   !! History :   1.0  !  01-04  (C. Ethe, G. Madec)  Original code
+   !!             2.0  !  03-08  (G. Madec)  add lim_istate_init
+   !!                  !  04-04  (S. Theetten) initialization from a file
+   !!                  !  06-07  (S. Masson)  IOM to read the restart
+   !!                  !  07-10  (G. Madec)  surface module
+   !!--------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_istate_2      :  Initialisation of diagnostics ice variables
+   !!   lim_istate_init_2 :  initialization of ice state and namelist read
+   !!----------------------------------------------------------------------
+   USE phycst
+   USE par_ice_2       ! ice parameters
+   USE dom_ice_2
+   USE eosbn2          ! equation of state
+   USE lbclnk
+   USE oce
+   USE ice_2
+   USE iom
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC lim_istate_2      ! routine called by lim_init_2.F90
+
+!!! ** init namelist (namiceini) **
+   LOGICAL  ::   ln_limini = .FALSE.  !: Ice initialization state
+   REAL(wp) ::   ttest     = 2.0      ! threshold water temperature for initial sea ice
+   REAL(wp) ::   hninn     = 0.5      ! initial snow thickness in the north
+   REAL(wp) ::   hginn     = 3.0      ! initial ice thickness in the north
+   REAL(wp) ::   alinn     = 0.05     ! initial leads area in the north
+   REAL(wp) ::   hnins     = 0.1      ! initial snow thickness in the south
+   REAL(wp) ::   hgins     = 1.0      ! initial ice thickness in the south
+   REAL(wp) ::   alins     = 0.1      ! initial leads area in the south
+   
+   REAL(wp) ::   zero      = 0.e0     ! constant value = 0
+   REAL(wp) ::   zone      = 1.e0     ! constant value = 1
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_istate_2
+      !!-------------------------------------------------------------------
+      !!                    ***  ROUTINE lim_istate_2  ***
+      !!
+      !! ** Purpose :   defined the sea-ice initial state
+      !!
+      !! ** Method  :   restart from a state defined in a binary file
+      !!                or from arbitrary sea-ice conditions
+      !!--------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zidto                     ! temporary scalar
+      !--------------------------------------------------------------------
+ 
+      CALL lim_istate_init_2     !  reading the initials parameters of the ice
+
+      IF( .NOT. ln_limini ) THEN  
+         
+         tfu(:,:) = tfreez( sn(:,:,1) ) * tmask(:,:,1)       ! freezing/melting point of sea water [Celcius]
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !                     ! ice if sst <= t-freez + ttest
+               IF( tn(ji,jj,1)  - tfu(ji,jj) >= ttest ) THEN   ;   zidto = 0.e0      ! no ice
+               ELSE                                            ;   zidto = 1.e0      !    ice
+               ENDIF
+               !
+               IF( fcor(ji,jj) >= 0.e0 ) THEN     !--  Northern hemisphere.
+                  hicif(ji,jj)   = zidto * hginn
+                  frld(ji,jj)    = zidto * alinn + ( 1.0 - zidto ) * 1.0
+                  hsnif(ji,jj)   = zidto * hninn
+               ELSE                               !---  Southern hemisphere.
+                  hicif(ji,jj)   = zidto * hgins
+                  frld(ji,jj)    = zidto * alins + ( 1.0 - zidto ) * 1.0
+                  hsnif(ji,jj)   = zidto * hnins
+               ENDIF
+            END DO
+         END DO
+
+         tfu(:,:) = tfu(:,:) + rt0       ! ftu converted from Celsius to Kelvin (rt0 over land)
+         
+         sist  (:,:)   = tfu(:,:)
+         tbif  (:,:,1) = tfu(:,:)
+         tbif  (:,:,2) = tfu(:,:)
+         tbif  (:,:,3) = tfu(:,:)
+
+      ENDIF
+     
+      fsbbq (:,:)   = 0.e0
+      qstoif(:,:)   = 0.e0
+      u_ice (:,:)   = 0.e0
+      v_ice (:,:)   = 0.e0
+
+      !---  Moments for advection.             
+
+      sxice (:,:)  = 0.e0   ;   sxsn (:,:)  = 0.e0   ;   sxa  (:,:)  = 0.e0
+      syice (:,:)  = 0.e0   ;   sysn (:,:)  = 0.e0   ;   sya  (:,:)  = 0.e0
+      sxxice(:,:)  = 0.e0   ;   sxxsn(:,:)  = 0.e0   ;   sxxa (:,:)  = 0.e0
+      syyice(:,:)  = 0.e0   ;   syysn(:,:)  = 0.e0   ;   syya (:,:)  = 0.e0
+      sxyice(:,:)  = 0.e0   ;   sxysn(:,:)  = 0.e0   ;   sxya (:,:)  = 0.e0
+
+      sxc0  (:,:)  = 0.e0   ;   sxc1 (:,:)  = 0.e0   ;   sxc2 (:,:)  = 0.e0
+      syc0  (:,:)  = 0.e0   ;   syc1 (:,:)  = 0.e0   ;   syc2 (:,:)  = 0.e0
+      sxxc0 (:,:)  = 0.e0   ;   sxxc1(:,:)  = 0.e0   ;   sxxc2(:,:)  = 0.e0
+      syyc0 (:,:)  = 0.e0   ;   syyc1(:,:)  = 0.e0   ;   syyc2(:,:)  = 0.e0
+      sxyc0 (:,:)  = 0.e0   ;   sxyc1(:,:)  = 0.e0   ;   sxyc2(:,:)  = 0.e0
+
+      sxst  (:,:)  = 0.e0
+      syst  (:,:)  = 0.e0
+      sxxst (:,:)  = 0.e0
+      syyst (:,:)  = 0.e0
+      sxyst (:,:)  = 0.e0
+
+      !-- lateral boundary conditions
+      CALL lbc_lnk( hicif, 'T', 1. )
+      CALL lbc_lnk( frld , 'T', 1. )
+
+      ! C A U T I O N  frld = 1 over land and lbc_lnk put zero along 
+      ! *************  closed boundaries herefore we force to one over land
+      frld(:,:) = tms(:,:) * frld(:,:) + ( 1. - tms(:,:) )   
+
+      CALL lbc_lnk( hsnif, 'T', 1. )
+      CALL lbc_lnk( sist , 'T', 1. , pval = rt0 )      ! set rt0 on closed boundary (required by bulk formulation)
+      DO jk = 1, jplayersp1
+         CALL lbc_lnk(tbif(:,:,jk), 'T', 1. )
+      END DO
+      CALL lbc_lnk( fsbbq  , 'T', 1. )
+      CALL lbc_lnk( qstoif , 'T', 1. )
+
+   END SUBROUTINE lim_istate_2
+
+   
+   SUBROUTINE lim_istate_init_2
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_istate_init_2  ***
+      !!        
+      !! ** Purpose :   Definition of initial state of the ice 
+      !!
+      !! ** Method  :   Read the namiceini namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namiceini
+      !!-------------------------------------------------------------------
+      INTEGER :: inum_ice
+      INTEGER :: ji,jj
+
+      NAMELIST/namiceini/ ln_limini, ttest, hninn, hginn, alinn, &
+         &                hnins, hgins, alins
+      !!-------------------------------------------------------------------
+      !
+      REWIND ( numnam_ice )               ! Read Namelist namiceini 
+      READ   ( numnam_ice , namiceini )
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_istate_init_2 : ice parameters inititialisation '
+         WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '         threshold water temp. for initial sea-ice    ttest      = ', ttest
+         WRITE(numout,*) '         initial snow thickness in the north          hninn      = ', hninn
+         WRITE(numout,*) '         initial ice thickness in the north           hginn      = ', hginn 
+         WRITE(numout,*) '         initial leads area in the north              alinn      = ', alinn            
+         WRITE(numout,*) '         initial snow thickness in the south          hnins      = ', hnins 
+         WRITE(numout,*) '         initial ice thickness in the south           hgins      = ', hgins
+         WRITE(numout,*) '         initial leads area in the south              alins      = ', alins
+         WRITE(numout,*) '         Ice state initialization using input file    ln_limini  = ', ln_limini
+      ENDIF
+
+      IF( ln_limini ) THEN                      ! Ice initialization using input file
+         !
+         CALL iom_open( 'Ice_initialization.nc', inum_ice )
+         !
+         IF( inum_ice > 0 ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '                  ice state initialization with : Ice_initialization.nc'
+            
+            CALL iom_get( inum_ice, jpdom_data, 'hicif', hicif )      
+            CALL iom_get( inum_ice, jpdom_data, 'hsnif', hsnif )      
+            CALL iom_get( inum_ice, jpdom_data, 'frld' , frld  )     
+            CALL iom_get( inum_ice, jpdom_data, 'ts'   , sist  )
+            CALL iom_get( inum_ice, jpdom_unknown, 'tbif', tbif(1:nlci,1:nlcj,:),   &
+                 &        kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,jplayersp1 /) )
+            ! put some values in the extra-halo...
+            DO jj = nlcj+1, jpj   ;   tbif(1:nlci,jj,:) = tbif(1:nlci,nlej,:)   ;   END DO
+            DO ji = nlci+1, jpi   ;   tbif(ji    ,: ,:) = tbif(nlei  ,:   ,:)   ;   END DO
+
+            CALL iom_close( inum_ice)
+            !
+         ENDIF
+      ENDIF
+      !     
+   END SUBROUTINE lim_istate_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_istate_2        ! Empty routine
+   END SUBROUTINE lim_istate_2
+#endif
+
+   !!======================================================================
+END MODULE limistate_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limmsh_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 1844)
@@ -0,0 +1,259 @@
+MODULE limmsh_2
+   !!======================================================================
+   !!                     ***  MODULE  limmsh_2  ***
+   !! LIM 2.0 ice model :   definition of the ice mesh parameters
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                     LIM 2.0sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_msh_2   : definition of the ice mesh
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE dom_oce
+   USE dom_ice_2
+   USE lbclnk
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_msh_2      ! routine called by ice_ini_2.F90
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_msh_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_msh_2  ***
+      !!              
+      !! ** Purpose : Definition of the charact. of the numerical grid
+      !!       
+      !! ** Action  : - Initialisation of some variables
+      !!              - Definition of some constants linked with the grid
+      !!              - Definition of the metric coef. for the sea/ice
+      !!              - Initialization of the ice masks (tmsk, umsk)
+      !! 
+      !! ** Refer.  : Deleersnijder et al. Ocean Modelling 100, 7-10 
+      !!
+      !! ** History :
+      !!         original    : 01-04 (LIM)
+      !!         addition    : 02-08 (C. Ethe, G. Madec)
+      !!--------------------------------------------------------------------- 
+      !! * Local variables
+      INTEGER :: ji, jj      ! dummy loop indices
+
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zd2d1 , zd1d2       ! Derivative of zh2 (resp. zh1) in the x direction
+         !                   ! (resp. y direction) (defined at the center)
+      REAL(wp) ::         &
+         zh1p  , zh2p   , &  ! Idem zh1, zh2 for the bottom left corner of the grid
+         zd2d1p, zd1d2p , &  ! Idem zd2d1, zd1d2 for the bottom left corner of the grid
+         zusden, zusden2     ! temporary scalars
+      !!---------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_msh_2 : LIM 2.0 sea-ice model, mesh initialization'
+         WRITE(numout,*) '~~~~~~~~~'
+      ENDIF
+      
+      !----------------------------------------------------------                          
+      !    Initialization of local and some global (common) variables 
+      !------------------------------------------------------------------ 
+      
+      njeq   = INT( jpj / 2 )   !i bug mpp potentiel
+      njeqm1 = njeq - 1 
+
+      fcor(:,:) = 2. * omega * SIN( gphit(:,:) * rad )   !  coriolis factor
+ 
+!i    DO jj = 1, jpj
+!i       zmsk(jj) = SUM( tmask(:,jj,:) )   ! = 0          if land  everywhere on a j-line
+!!ii     write(numout,*) jj, zind(jj)
+!i    END DO
+
+      IF( fcor(1,1) * fcor(1,nlcj) < 0.e0 ) THEN   ! local domain include both hemisphere
+         l_jeq = .TRUE.
+         njeq  = 1
+         DO WHILE ( njeq <= jpj .AND. fcor(1,njeq) < 0.e0 )
+            njeq = njeq + 1
+         END DO
+         IF(lwp ) WRITE(numout,*) '          the equator is inside the domain at about njeq = ', njeq
+      ELSEIF( fcor(1,1) < 0.e0 ) THEN
+         l_jeq = .FALSE.
+         njeq = jpj
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the southern hemisphere: njeq = ', njeq
+      ELSE
+         l_jeq = .FALSE.
+         njeq = 2
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the northern hemisphere: njeq = ', njeq
+      ENDIF
+
+      njeqm1 = njeq - 1
+
+
+      !   For each grid, definition of geometric tables 
+      !------------------------------------------------------------------
+      
+      !-------------------
+      ! Conventions :    !
+      !-------------------
+      !  indices 1 \ 2 <-> localisation in the 2 direction x \ y
+      !  3rd indice <-> localisation on the mesh :
+      !  0 = Centre ;  1 = corner W x(i-1/2) ; 2 = corner S y(j-1/2) ;
+      !  3 = corner SW x(i-1/2),y(j-1/2)
+      !-------------------
+!!ibug ???
+      akappa(:,:,:,:) = 0.e0
+      wght(:,:,:,:) = 0.e0
+      alambd(:,:,:,:,:,:) = 0.e0
+      tmu(:,:) = 0.e0
+!!i
+      
+      
+      ! metric coefficients for sea ice dynamic
+      !----------------------------------------
+      !                                                       ! akappa
+      DO jj = 2, jpj
+         zd1d2(:,jj) = e1v(:,jj) - e1v(:,jj-1)
+      END DO
+      CALL lbc_lnk( zd1d2, 'T', -1. )
+
+      DO ji = 2, jpi
+         zd2d1(ji,:) = e2u(ji,:) - e2u(ji-1,:)
+      END DO
+      CALL lbc_lnk( zd2d1, 'T', -1. )
+
+      akappa(:,:,1,1) =        1.0 / ( 2.0 * e1t(:,:) )
+      akappa(:,:,1,2) = zd1d2(:,:) / ( 4.0 * e1t(:,:) * e2t(:,:) )
+      akappa(:,:,2,1) = zd2d1(:,:) / ( 4.0 * e1t(:,:) * e2t(:,:) )
+      akappa(:,:,2,2) =        1.0 / ( 2.0 * e2t(:,:) )
+      
+      !                                                      ! weights (wght)
+      DO jj = 2, jpj
+         DO ji = 2, jpi
+            zusden = 1. / (  ( e1t(ji,jj) + e1t(ji-1,jj  ) )   &
+               &           * ( e2t(ji,jj) + e2t(ji  ,jj-1) ) )
+            wght(ji,jj,1,1) = zusden * e1t(ji  ,jj) * e2t(ji,jj  )
+            wght(ji,jj,1,2) = zusden * e1t(ji  ,jj) * e2t(ji,jj-1)
+            wght(ji,jj,2,1) = zusden * e1t(ji-1,jj) * e2t(ji,jj  )
+            wght(ji,jj,2,2) = zusden * e1t(ji-1,jj) * e2t(ji,jj-1)
+         END DO
+      END DO
+      CALL lbc_lnk( wght(:,:,1,1), 'I', 1. )      ! CAUTION: even with the lbc_lnk at ice U-V-point
+      CALL lbc_lnk( wght(:,:,1,2), 'I', 1. )      ! the value of wght at jpj is wrong
+      CALL lbc_lnk( wght(:,:,2,1), 'I', 1. )      ! but it is never used
+      CALL lbc_lnk( wght(:,:,2,2), 'I', 1. )
+    
+      ! Coefficients for divergence of the stress tensor
+      !-------------------------------------------------
+
+      DO jj = 2, jpj
+         DO ji = 2, jpi   ! NO vector opt.
+            zh1p  =  e1t(ji  ,jj  ) * wght(ji,jj,2,2)   &
+               &   + e1t(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &   + e1t(ji  ,jj-1) * wght(ji,jj,2,1)   &
+               &   + e1t(ji-1,jj-1) * wght(ji,jj,1,1)
+
+            zh2p  =  e2t(ji  ,jj  ) * wght(ji,jj,2,2)   &
+               &   + e2t(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &   + e2t(ji  ,jj-1) * wght(ji,jj,2,1)   &
+               &   + e2t(ji-1,jj-1) * wght(ji,jj,1,1)
+
+! better written but change the last digit and thus solver in less than 100 timestep
+!           zh1p  = e1t(ji-1,jj  ) * wght(ji,jj,1,2) + e1t(ji,jj  ) * wght(ji,jj,2,2)   &
+!              &  + e1t(ji-1,jj-1) * wght(ji,jj,1,1) + e1t(ji,jj-1) * wght(ji,jj,2,1) 
+
+!           zh2p  = e2t(ji-1,jj  ) * wght(ji,jj,1,2) + e2t(ji,jj  ) * wght(ji,jj,2,2)   &
+!              &  + e2t(ji-1,jj-1) * wght(ji,jj,1,1) + e2t(ji,jj-1) * wght(ji,jj,2,1)
+
+!!ibug =0   zusden = 1.0 / ( zh1p * zh2p * 4.e0 )
+            zusden = 1.0 / MAX( zh1p * zh2p * 4.e0 , 1.e-20 )
+            zusden2 = zusden * 2.0 
+
+            zd1d2p = zusden * 0.5 * ( -e1t(ji-1,jj-1) + e1t(ji-1,jj  ) - e1t(ji,jj-1) + e1t(ji  ,jj)   )
+            zd2d1p = zusden * 0.5 * (  e2t(ji  ,jj-1) - e2t(ji-1,jj-1) + e2t(ji,jj  ) - e2t(ji-1,jj)   )
+
+            alambd(ji,jj,2,2,2,1) = zusden2 * e2t(ji  ,jj-1)
+            alambd(ji,jj,2,2,2,2) = zusden2 * e2t(ji  ,jj  )
+            alambd(ji,jj,2,2,1,1) = zusden2 * e2t(ji-1,jj-1)
+            alambd(ji,jj,2,2,1,2) = zusden2 * e2t(ji-1,jj  )
+
+            alambd(ji,jj,1,1,2,1) = zusden2 * e1t(ji  ,jj-1)
+            alambd(ji,jj,1,1,2,2) = zusden2 * e1t(ji  ,jj  )
+            alambd(ji,jj,1,1,1,1) = zusden2 * e1t(ji-1,jj-1)
+            alambd(ji,jj,1,1,1,2) = zusden2 * e1t(ji-1,jj  )
+
+            alambd(ji,jj,1,2,2,1) = zd1d2p
+            alambd(ji,jj,1,2,2,2) = zd1d2p
+            alambd(ji,jj,1,2,1,1) = zd1d2p
+            alambd(ji,jj,1,2,1,2) = zd1d2p
+
+            alambd(ji,jj,2,1,2,1) = zd2d1p
+            alambd(ji,jj,2,1,2,2) = zd2d1p
+            alambd(ji,jj,2,1,1,1) = zd2d1p
+            alambd(ji,jj,2,1,1,2) = zd2d1p
+         END DO
+      END DO
+
+      CALL lbc_lnk( alambd(:,:,2,2,2,1), 'I', 1. )      ! CAUTION: even with the lbc_lnk at ice U-V point
+      CALL lbc_lnk( alambd(:,:,2,2,2,2), 'I', 1. )      ! the value of wght at jpj is wrong
+      CALL lbc_lnk( alambd(:,:,2,2,1,1), 'I', 1. )      ! but it is never used
+      CALL lbc_lnk( alambd(:,:,2,2,1,2), 'I', 1. )      ! 
+
+      CALL lbc_lnk( alambd(:,:,1,1,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,1,1,2,2), 'I', 1. )      ! 
+      CALL lbc_lnk( alambd(:,:,1,1,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,1,1,2), 'I', 1. )      !
+
+      CALL lbc_lnk( alambd(:,:,1,2,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,1,2,2,2), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,2,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,2,1,2), 'I', 1. )      !
+
+      CALL lbc_lnk( alambd(:,:,2,1,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,2,1,2,2), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,2,1,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,2,1,1,2), 'I', 1. )      !
+            
+
+      ! Initialization of ice masks
+      !----------------------------
+      
+      tms(:,:) = tmask(:,:,1)      ! ice T-point  : use surface tmask
+
+!i here we can use umask with a i and j shift of -1,-1
+      tmu(:,1) = 0.e0
+      tmu(1,:) = 0.e0
+      DO jj = 2, jpj               ! ice U.V-point: computed from ice T-point mask
+         DO ji = 2, jpim1   ! NO vector opt.
+            tmu(ji,jj) =  tms(ji,jj) * tms(ji-1,jj) * tms(ji,jj-1) * tms(ji-1,jj-1)            
+         END DO
+      END DO
+      
+      !--lateral boundary conditions    
+      CALL lbc_lnk( tmu(:,:), 'I', 1. )
+      
+      ! unmasked and masked area of T-grid cell
+      area(:,:) = e1t(:,:) * e2t(:,:)
+      
+   END SUBROUTINE lim_msh_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy Module         NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_msh_2           ! Dummy routine
+   END SUBROUTINE lim_msh_2
+#endif
+
+   !!======================================================================
+END MODULE limmsh_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrhg_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 1844)
@@ -0,0 +1,591 @@
+MODULE limrhg_2
+   !!======================================================================
+   !!                     ***  MODULE  limrhg_2  ***
+   !!   Ice rheology :  performs sea ice rheology
+   !!======================================================================
+   !! History :  0.0  !  93-12  (M.A. Morales Maqueda.)  Original code
+   !!            1.0  !  94-12  (H. Goosse) 
+   !!            2.0  !  03-12  (C. Ethe, G. Madec)  F90, mpp
+   !!            " "  !  06-08  (G. Madec)  surface module, ice-stress at I-point
+   !!            " "  !  09-09  (G. Madec)  Huge verctor optimisation
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_rhg_2   : computes ice velocities
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean parameter
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_oce        ! surface boundary condition: ocean variables
+   USE sbc_ice        ! surface boundary condition: ice variables
+   USE dom_ice_2      ! domaine: ice variables
+   USE phycst         ! physical constant
+   USE ice_2          ! ice variables
+   USE lbclnk         ! lateral boundary condition
+   USE lib_mpp        ! MPP library
+   USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_rhg_2 ! routine called by lim_dyn
+
+   REAL(wp) ::   rzero   = 0.e0   ! constant value: zero
+   REAL(wp) ::   rone    = 1.e0   !            and  one
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rhg_2( k_j1, k_jpj )
+      !!-------------------------------------------------------------------
+      !!                 ***  SUBROUTINR lim_rhg_2  ***
+      !!
+      !! ** purpose :   determines the velocity field of sea ice by using
+      !!  atmospheric (wind stress) and oceanic (water stress and surface
+      !!  tilt) forcings. Ice-ice interaction is described by a non-linear
+      !!  viscous-plastic law including shear strength and a bulk rheology.
+      !!
+      !! ** Action  : - compute u_ice, v_ice the sea-ice velocity defined
+      !!              at I-point
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   k_j1    ! southern j-index for ice computation
+      INTEGER, INTENT(in) ::   k_jpj   ! northern j-index for ice computation
+      !!
+      INTEGER ::   ji, jj              ! dummy loop indices
+      INTEGER ::   iter, jter          ! temporary integers
+      CHARACTER (len=50) ::   charout
+      REAL(wp) ::   ze11  , ze12  , ze22  , ze21               ! temporary scalars
+      REAL(wp) ::   zt11  , zt12  , zt21  , zt22               !    "         "
+      REAL(wp) ::   zvis11, zvis21, zvis12, zvis22             !    "         "
+      REAL(wp) ::   zgphsx, ztagnx, zgsshx, zunw, zur, zusw    !    "         "
+      REAL(wp) ::   zgphsy, ztagny, zgsshy, zvnw, zvr          !    "         "
+      REAL(wp) ::   zresm,  za, zac, zmod
+      REAL(wp) ::   zmpzas, zstms, zindu, zusdtp, zmassdt, zcorlal
+      REAL(wp) ::   ztrace2, zdeter, zdelta, zmask, zdgp, zdgi, zdiag
+      REAL(wp) ::   za1, zb1, zc1, zd1
+      REAL(wp) ::   za2, zb2, zc2, zd2, zden
+      REAL(wp) ::   zs11_11, zs11_12, zs11_21, zs11_22
+      REAL(wp) ::   zs12_11, zs12_12, zs12_21, zs12_22
+      REAL(wp) ::   zs21_11, zs21_12, zs21_21, zs21_22
+      REAL(wp) ::   zs22_11, zs22_12, zs22_21, zs22_22
+      REAL(wp), DIMENSION(jpi,  jpj  ) ::   zfrld, zmass, zcorl
+      REAL(wp), DIMENSION(jpi,  jpj  ) ::   za1ct, za2ct, zresr
+      REAL(wp), DIMENSION(jpi,  jpj  ) ::   zc1u, zc1v, zc2u, zc2v
+      REAL(wp), DIMENSION(jpi,  jpj  ) ::   zsang
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zu0, zv0
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zu_n, zv_n
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zu_a, zv_a
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zviszeta, zviseta
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zzfrld, zztms
+      REAL(wp), DIMENSION(jpi,0:jpj+1) ::   zi1, zi2, zmasst, zpresh
+
+      !!-------------------------------------------------------------------
+
+!!bug
+!!    u_oce(:,:) = 0.e0
+!!    v_oce(:,:) = 0.e0
+!!    write(*,*) 'rhg min, max u & v', maxval(u_oce), minval(u_oce), maxval(v_oce), minval(v_oce)
+!!bug
+      
+      !  Store initial velocities
+      !  ----------------
+      zztms(:,0    ) = 0.e0       ;    zzfrld(:,0    ) = 0.e0
+      zztms(:,jpj+1) = 0.e0       ;    zzfrld(:,jpj+1) = 0.e0
+      zu0(:,0    ) = 0.e0         ;    zv0(:,0    ) = 0.e0
+      zu0(:,jpj+1) = 0.e0         ;    zv0(:,jpj+1) = 0.e0
+      zztms(:,1:jpj) = tms(:,:)   ;    zzfrld(:,1:jpj) = frld(:,:)
+      zu0(:,1:jpj) = u_ice(:,:)   ;    zv0(:,1:jpj) = v_ice(:,:)
+
+      zu_a(:,:)    = zu0(:,:)     ;   zv_a(:,:) = zv0(:,:)
+      zu_n(:,:)    = zu0(:,:)     ;   zv_n(:,:) = zv0(:,:)
+
+!i
+      zi1   (:,:) = 0.e0
+      zi2   (:,:) = 0.e0
+      zpresh(:,:) = 0.e0
+      zmasst(:,:) = 0.e0
+!i
+!!gm violant
+      zfrld(:,:) =0.e0
+      zcorl(:,:) =0.e0
+      zmass(:,:) =0.e0
+      za1ct(:,:) =0.e0
+      za2ct(:,:) =0.e0
+!!gm end
+
+      zviszeta(:,:) = 0.e0
+      zviseta (:,:) = 0.e0
+
+!i    zviszeta(:,0    ) = 0.e0    ;    zviseta(:,0    ) = 0.e0
+!i    zviszeta(:,jpj  ) = 0.e0    ;    zviseta(:,jpj  ) = 0.e0
+!i    zviszeta(:,jpj+1) = 0.e0    ;    zviseta(:,jpj+1) = 0.e0
+
+
+      ! Ice mass, ice strength, and wind stress at the center            |
+      ! of the grid squares.                                             |
+      !-------------------------------------------------------------------
+
+!CDIR NOVERRCHK
+      DO jj = k_j1 , k_jpj-1
+!CDIR NOVERRCHK
+         DO ji = 1 , jpi
+            ! only the sinus changes its sign with the hemisphere
+            zsang(ji,jj)  = SIGN( 1.e0, fcor(ji,jj) ) * sangvg   ! only the sinus changes its sign with the hemisphere
+            !
+            zmasst(ji,jj) = tms(ji,jj) * ( rhosn * hsnm(ji,jj) + rhoic * hicm(ji,jj) )
+            zpresh(ji,jj) = tms(ji,jj) *  pstarh * hicm(ji,jj) * EXP( -c_rhg * frld(ji,jj) )
+!!gm  :: stress given at I-point (F-point for the ocean) only compute the ponderation with the ice fraction (1-frld)
+            zi1(ji,jj)    = tms(ji,jj) * ( 1.0 - frld(ji,jj) )
+            zi2(ji,jj)    = tms(ji,jj) * ( 1.0 - frld(ji,jj) )
+         END DO
+      END DO
+
+
+      !---------------------------------------------------------------------------
+      !  Wind stress, coriolis and mass terms at the corners of the grid squares |
+      !  Gradient of ice strenght.                                               |
+      !---------------------------------------------------------------------------
+         
+      DO jj = k_j1+1, k_jpj-1
+         DO ji = 2, jpi    ! NO vector opt.
+            zstms = zztms(ji,jj  ) * wght(ji,jj,2,2) + zztms(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &  + zztms(ji,jj-1) * wght(ji,jj,2,1) + zztms(ji-1,jj-1) * wght(ji,jj,1,1)
+            zusw  = 1.0 / MAX( zstms, epsd )
+
+            zt11 = zztms(ji  ,jj  ) * zzfrld(ji  ,jj  ) 
+            zt12 = zztms(ji-1,jj  ) * zzfrld(ji-1,jj  ) 
+            zt21 = zztms(ji  ,jj-1) * zzfrld(ji  ,jj-1) 
+            zt22 = zztms(ji-1,jj-1) * zzfrld(ji-1,jj-1)
+
+            ! Leads area.
+            zfrld(ji,jj) =  (  zt11 * wght(ji,jj,2,2) + zt12 * wght(ji,jj,1,2)   &
+               &             + zt21 * wght(ji,jj,2,1) + zt22 * wght(ji,jj,1,1) ) * zusw
+
+            ! Mass and coriolis coeff. at I-point
+            zmass(ji,jj) = ( zmasst(ji,jj  ) * wght(ji,jj,2,2) + zmasst(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &           + zmasst(ji,jj-1) * wght(ji,jj,2,1) + zmasst(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw
+            zcorl(ji,jj) = zmass(ji,jj) &
+               &           *( fcor(ji,jj  ) * wght(ji,jj,2,2) + fcor(ji-1,jj  )*wght(ji,jj,1,2)   &
+               &            + fcor(ji,jj-1) * wght(ji,jj,2,1) + fcor(ji-1,jj-1)*wght(ji,jj,1,1) ) * zusw
+
+            ! Wind stress.
+            ! always provide stress at I-point
+            ztagnx = ( zi1(ji,jj  ) * wght(ji,jj,2,2) + zi1(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zi1(ji,jj-1) * wght(ji,jj,2,1) + zi1(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw * utau_ice(ji,jj)
+            ztagny = ( zi2(ji,jj  ) * wght(ji,jj,2,2) + zi2(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zi2(ji,jj-1) * wght(ji,jj,2,1) + zi2(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw * vtau_ice(ji,jj)
+
+            ! Gradient of ice strength
+            zgphsx =   ( alambd(ji,jj,2,2,2,1) - alambd(ji,jj,2,1,2,1) ) * zpresh(ji  ,jj-1)   &
+               &     + ( alambd(ji,jj,2,2,2,2) - alambd(ji,jj,2,1,2,2) ) * zpresh(ji  ,jj  )   &
+               &     - ( alambd(ji,jj,2,2,1,1) + alambd(ji,jj,2,1,1,1) ) * zpresh(ji-1,jj-1)   &
+               &     - ( alambd(ji,jj,2,2,1,2) + alambd(ji,jj,2,1,1,2) ) * zpresh(ji-1,jj  )
+
+            zgphsy = - ( alambd(ji,jj,1,1,2,1) + alambd(ji,jj,1,2,2,1) ) * zpresh(ji  ,jj-1)   &
+               &     - ( alambd(ji,jj,1,1,1,1) + alambd(ji,jj,1,2,1,1) ) * zpresh(ji-1,jj-1)   &
+               &     + ( alambd(ji,jj,1,1,2,2) - alambd(ji,jj,1,2,2,2) ) * zpresh(ji  ,jj  )   &
+               &     + ( alambd(ji,jj,1,1,1,2) - alambd(ji,jj,1,2,1,2) ) * zpresh(ji-1,jj  )
+
+            ! Gradient of the sea surface height
+            zgsshx =  (   (ssh_m(ji  ,jj  ) - ssh_m(ji-1,jj  ))/e1u(ji-1,jj  )   &
+               &       +  (ssh_m(ji  ,jj-1) - ssh_m(ji-1,jj-1))/e1u(ji-1,jj-1)   ) * 0.5
+            zgsshy =  (   (ssh_m(ji  ,jj  ) - ssh_m(ji  ,jj-1))/e2v(ji  ,jj-1)   &
+               &       +  (ssh_m(ji-1,jj  ) - ssh_m(ji-1,jj-1))/e2v(ji-1,jj-1)   ) * 0.5
+
+            ! Computation of the velocity field taking into account the ice-ice interaction.                                 
+            ! Terms that are independent of the ice velocity field.
+            za1ct(ji,jj) = ztagnx - zmass(ji,jj) * grav * zgsshx - zgphsx
+            za2ct(ji,jj) = ztagny - zmass(ji,jj) * grav * zgsshy - zgphsy
+         END DO
+      END DO
+
+
+      ! SOLUTION OF THE MOMENTUM EQUATION.
+      !------------------------------------------
+      !                                                   ! ==================== !
+      DO iter = 1 , 2 * nbiter                            !    loop over iter    !
+         !                                                ! ==================== !        
+         zindu = MOD( iter , 2 )
+         zusdtp = ( zindu * 2.0 + ( 1.0 - zindu ) * 1.0 )  * REAL( nbiter ) / rdt_ice
+
+         ! Computation of free drift field for free slip boundary conditions.
+
+!CDIR NOVERRCHK
+         DO jj = k_j1, k_jpj-1
+!CDIR NOVERRCHK
+            DO ji = 1, fs_jpim1
+               !- Rate of strain tensor.
+               zt11 =   akappa(ji,jj,1,1) * ( zu_a(ji+1,jj) + zu_a(ji+1,jj+1) - zu_a(ji,jj  ) - zu_a(ji  ,jj+1) )  &
+                  &   + akappa(ji,jj,1,2) * ( zv_a(ji+1,jj) + zv_a(ji+1,jj+1) + zv_a(ji,jj  ) + zv_a(ji  ,jj+1) )
+               zt12 = - akappa(ji,jj,2,2) * ( zu_a(ji  ,jj) + zu_a(ji+1,jj  ) - zu_a(ji,jj+1) - zu_a(ji+1,jj+1) )  &
+                  &   - akappa(ji,jj,2,1) * ( zv_a(ji  ,jj) + zv_a(ji+1,jj  ) + zv_a(ji,jj+1) + zv_a(ji+1,jj+1) )
+               zt22 = - akappa(ji,jj,2,2) * ( zv_a(ji  ,jj) + zv_a(ji+1,jj  ) - zv_a(ji,jj+1) - zv_a(ji+1,jj+1) )  &
+                  &   + akappa(ji,jj,2,1) * ( zu_a(ji  ,jj) + zu_a(ji+1,jj  ) + zu_a(ji,jj+1) + zu_a(ji+1,jj+1) )
+               zt21 =   akappa(ji,jj,1,1) * ( zv_a(ji+1,jj) + zv_a(ji+1,jj+1) - zv_a(ji,jj  ) - zv_a(ji  ,jj+1) )  &
+                  &   - akappa(ji,jj,1,2) * ( zu_a(ji+1,jj) + zu_a(ji+1,jj+1) + zu_a(ji,jj  ) + zu_a(ji  ,jj+1) )
+
+               !- Rate of strain tensor. 
+               zdgp = zt11 + zt22
+               zdgi = zt12 + zt21
+               ztrace2 = zdgp * zdgp 
+               zdeter  = zt11 * zt22 - 0.25 * zdgi * zdgi
+
+               !  Creep limit depends on the size of the grid.
+               zdelta = MAX( SQRT( ztrace2 + ( ztrace2 - 4.0 * zdeter ) * usecc2 ),  creepl)
+
+               !-  Computation of viscosities.
+               zviszeta(ji,jj) = MAX( zpresh(ji,jj) / zdelta, etamn )
+               zviseta (ji,jj) = zviszeta(ji,jj) * usecc2
+            END DO
+         END DO
+
+         !-  Determination of zc1u, zc2u, zc1v and zc2v.
+         DO jj = k_j1+1, k_jpj-1
+            DO ji = 2, fs_jpim1   ! NO vector opt.
+               !* zc1u , zc2v
+               zvis11 = 2.0 * zviseta (ji-1,jj-1) + dm
+               zvis12 =       zviseta (ji-1,jj-1) + dm
+               zvis21 =       zviseta (ji-1,jj-1)
+               zvis22 =       zviszeta(ji-1,jj-1) - zviseta(ji-1,jj-1)
+               zdiag  = zvis22 * ( akappa(ji-1,jj-1,1,1) + akappa(ji-1,jj-1,2,1) )
+               zs11_11 =  zvis11 * akappa(ji-1,jj-1,1,1) + zdiag
+               zs12_11 =  zvis12 * akappa(ji-1,jj-1,2,2) - zvis21 * akappa(ji-1,jj-1,1,2)
+               zs21_11 = -zvis12 * akappa(ji-1,jj-1,1,2) + zvis21 * akappa(ji-1,jj-1,2,2)
+               zs22_11 =  zvis11 * akappa(ji-1,jj-1,2,1) + zdiag
+
+               zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+               zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+               zvis12 =       zviseta (ji,jj-1) + dm
+               zvis21 =       zviseta (ji,jj-1)
+               zdiag = zvis22 * ( -akappa(ji,jj-1,1,1) + akappa(ji,jj-1,2,1) )
+               zs11_21 = -zvis11 * akappa(ji,jj-1,1,1) + zdiag
+               zs12_21 =  zvis12 * akappa(ji,jj-1,2,2) - zvis21 * akappa(ji,jj-1,1,2)
+               zs22_21 =  zvis11 * akappa(ji,jj-1,2,1) + zdiag
+               zs21_21 = -zvis12 * akappa(ji,jj-1,1,2) + zvis21 * akappa(ji,jj-1,2,2)
+
+               zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+               zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+               zvis12 =       zviseta (ji-1,jj) + dm
+               zvis21 =       zviseta (ji-1,jj)
+               zdiag = zvis22 * ( akappa(ji-1,jj,1,1) + akappa(ji-1,jj,2,1) )
+               zs11_12 =  zvis11 * akappa(ji-1,jj,1,1) + zdiag
+               zs12_12 = -zvis12 * akappa(ji-1,jj,2,2) - zvis21 * akappa(ji-1,jj,1,2)
+               zs22_12 =  zvis11 * akappa(ji-1,jj,2,1) + zdiag
+               zs21_12 = -zvis12 * akappa(ji-1,jj,1,2) - zvis21 * akappa(ji-1,jj,2,2)
+
+               zvis11 = 2.0 * zviseta (ji,jj) + dm
+               zvis22 =       zviszeta(ji,jj) - zviseta(ji,jj)
+               zvis12 =       zviseta (ji,jj) + dm
+               zvis21 =       zviseta (ji,jj)
+               zdiag = zvis22 * ( -akappa(ji,jj,1,1) + akappa(ji,jj,2,1) )
+               zs11_22 = -zvis11 * akappa(ji,jj,1,1) + zdiag
+               zs12_22 = -zvis12 * akappa(ji,jj,2,2) - zvis21 * akappa(ji,jj,1,2)
+               zs22_22 =  zvis11 * akappa(ji,jj,2,1) + zdiag
+               zs21_22 = -zvis12 * akappa(ji,jj,1,2) - zvis21 * akappa(ji,jj,2,2)
+
+               zc1u(ji,jj) = + alambd(ji,jj,2,2,2,1) * zs11_21 + alambd(ji,jj,2,2,2,2) * zs11_22   &
+                  &          - alambd(ji,jj,2,2,1,1) * zs11_11 - alambd(ji,jj,2,2,1,2) * zs11_12   &
+                  &          - alambd(ji,jj,1,1,2,1) * zs12_21 - alambd(ji,jj,1,1,1,1) * zs12_11   &
+                  &          + alambd(ji,jj,1,1,2,2) * zs12_22 + alambd(ji,jj,1,1,1,2) * zs12_12   &
+                  &          + alambd(ji,jj,1,2,1,1) * zs21_11 + alambd(ji,jj,1,2,2,1) * zs21_21   &
+                  &          + alambd(ji,jj,1,2,1,2) * zs21_12 + alambd(ji,jj,1,2,2,2) * zs21_22   &
+                  &          - alambd(ji,jj,2,1,1,1) * zs22_11 - alambd(ji,jj,2,1,2,1) * zs22_21   &
+                  &          - alambd(ji,jj,2,1,1,2) * zs22_12 - alambd(ji,jj,2,1,2,2) * zs22_22
+
+               zc2u(ji,jj) = + alambd(ji,jj,2,2,2,1) * zs21_21 + alambd(ji,jj,2,2,2,2) * zs21_22   &
+                  &          - alambd(ji,jj,2,2,1,1) * zs21_11 - alambd(ji,jj,2,2,1,2) * zs21_12   &
+                  &          - alambd(ji,jj,1,1,2,1) * zs22_21 - alambd(ji,jj,1,1,1,1) * zs22_11   &
+                  &          + alambd(ji,jj,1,1,2,2) * zs22_22 + alambd(ji,jj,1,1,1,2) * zs22_12   &
+                  &          - alambd(ji,jj,1,2,1,1) * zs11_11 - alambd(ji,jj,1,2,2,1) * zs11_21   &
+                  &          - alambd(ji,jj,1,2,1,2) * zs11_12 - alambd(ji,jj,1,2,2,2) * zs11_22   &
+                  &          + alambd(ji,jj,2,1,1,1) * zs12_11 + alambd(ji,jj,2,1,2,1) * zs12_21   &
+                  &          + alambd(ji,jj,2,1,1,2) * zs12_12 + alambd(ji,jj,2,1,2,2) * zs12_22
+
+               !* zc1v , zc2v.
+               zvis11 = 2.0 * zviseta (ji-1,jj-1) + dm
+               zvis22 =       zviszeta(ji-1,jj-1) - zviseta(ji-1,jj-1)
+               zvis12 =       zviseta (ji-1,jj-1) + dm
+               zvis21 =       zviseta (ji-1,jj-1)
+               zdiag = zvis22 * ( akappa(ji-1,jj-1,1,2) + akappa(ji-1,jj-1,2,2) )
+               zs11_11 =  zvis11 * akappa(ji-1,jj-1,1,2) + zdiag
+               zs12_11 = -zvis12 * akappa(ji-1,jj-1,2,1) + zvis21 * akappa(ji-1,jj-1,1,1)
+               zs22_11 =  zvis11 * akappa(ji-1,jj-1,2,2) + zdiag
+               zs21_11 =  zvis12 * akappa(ji-1,jj-1,1,1) - zvis21 * akappa(ji-1,jj-1,2,1)
+ 
+               zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+               zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+               zvis12 =       zviseta (ji,jj-1) + dm
+               zvis21 =       zviseta (ji,jj-1)
+               zdiag = zvis22 * ( akappa(ji,jj-1,1,2) + akappa(ji,jj-1,2,2) )
+               zs11_21 =  zvis11 * akappa(ji,jj-1,1,2) + zdiag
+               zs12_21 = -zvis12 * akappa(ji,jj-1,2,1) - zvis21 * akappa(ji,jj-1,1,1)
+               zs22_21 =  zvis11 * akappa(ji,jj-1,2,2) + zdiag
+               zs21_21 = -zvis12 * akappa(ji,jj-1,1,1) - zvis21 * akappa(ji,jj-1,2,1)
+
+               zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+               zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+               zvis12 =       zviseta (ji-1,jj) + dm
+               zvis21 =       zviseta (ji-1,jj)
+               zdiag = zvis22 * ( akappa(ji-1,jj,1,2) - akappa(ji-1,jj,2,2) )
+               zs11_12 =  zvis11 * akappa(ji-1,jj,1,2) + zdiag
+               zs12_12 = -zvis12 * akappa(ji-1,jj,2,1) + zvis21 * akappa(ji-1,jj,1,1)
+               zs22_12 = -zvis11 * akappa(ji-1,jj,2,2) + zdiag
+               zs21_12 =  zvis12 * akappa(ji-1,jj,1,1) - zvis21 * akappa(ji-1,jj,2,1)
+
+               zvis11 = 2.0 * zviseta (ji,jj) + dm
+               zvis22 =       zviszeta(ji,jj) - zviseta(ji,jj)
+               zvis12 =       zviseta (ji,jj) + dm
+               zvis21 =       zviseta (ji,jj)
+               zdiag = zvis22 * ( akappa(ji,jj,1,2) - akappa(ji,jj,2,2) )
+               zs11_22 =  zvis11 * akappa(ji,jj,1,2) + zdiag
+               zs12_22 = -zvis12 * akappa(ji,jj,2,1) - zvis21 * akappa(ji,jj,1,1)
+               zs22_22 = -zvis11 * akappa(ji,jj,2,2) + zdiag
+               zs21_22 = -zvis12 * akappa(ji,jj,1,1) - zvis21 * akappa(ji,jj,2,1)
+
+               zc1v(ji,jj) = + alambd(ji,jj,2,2,2,1) * zs11_21 + alambd(ji,jj,2,2,2,2) * zs11_22   &
+                  &          - alambd(ji,jj,2,2,1,1) * zs11_11 - alambd(ji,jj,2,2,1,2) * zs11_12   &
+                  &          - alambd(ji,jj,1,1,2,1) * zs12_21 - alambd(ji,jj,1,1,1,1) * zs12_11   &
+                  &          + alambd(ji,jj,1,1,2,2) * zs12_22 + alambd(ji,jj,1,1,1,2) * zs12_12   &
+                  &          + alambd(ji,jj,1,2,1,1) * zs21_11 + alambd(ji,jj,1,2,2,1) * zs21_21   &
+                  &          + alambd(ji,jj,1,2,1,2) * zs21_12 + alambd(ji,jj,1,2,2,2) * zs21_22   &
+                  &          - alambd(ji,jj,2,1,1,1) * zs22_11 - alambd(ji,jj,2,1,2,1) * zs22_21   &
+                  &          - alambd(ji,jj,2,1,1,2) * zs22_12 - alambd(ji,jj,2,1,2,2) * zs22_22
+
+               zc2v(ji,jj) = + alambd(ji,jj,2,2,2,1) * zs21_21 + alambd(ji,jj,2,2,2,2) * zs21_22   &
+                  &          - alambd(ji,jj,2,2,1,1) * zs21_11 - alambd(ji,jj,2,2,1,2) * zs21_12   &
+                  &          - alambd(ji,jj,1,1,2,1) * zs22_21 - alambd(ji,jj,1,1,1,1) * zs22_11   &
+                  &          + alambd(ji,jj,1,1,2,2) * zs22_22 + alambd(ji,jj,1,1,1,2) * zs22_12   &
+                  &          - alambd(ji,jj,1,2,1,1) * zs11_11 - alambd(ji,jj,1,2,2,1) * zs11_21   &
+                  &          - alambd(ji,jj,1,2,1,2) * zs11_12 - alambd(ji,jj,1,2,2,2) * zs11_22   &
+                  &          + alambd(ji,jj,2,1,1,1) * zs12_11 + alambd(ji,jj,2,1,2,1) * zs12_21   &
+                  &          + alambd(ji,jj,2,1,1,2) * zs12_12 + alambd(ji,jj,2,1,2,2) * zs12_22
+            END DO
+         END DO
+
+         ! GAUSS-SEIDEL method
+         !                                                      ! ================ !
+iflag:   DO jter = 1 , nbitdr                                   !    Relaxation    !
+            !                                                   ! ================ !
+!CDIR NOVERRCHK
+            DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+               DO ji = 2, fs_jpim1   ! NO vector opt.
+                  !
+                  ze11 =   akappa(ji,jj-1,1,1) * zu_a(ji+1,jj) + akappa(ji,jj-1,1,2) * zv_a(ji+1,jj)
+                  ze12 = + akappa(ji,jj-1,2,2) * zu_a(ji+1,jj) - akappa(ji,jj-1,2,1) * zv_a(ji+1,jj)
+                  ze22 = + akappa(ji,jj-1,2,2) * zv_a(ji+1,jj) + akappa(ji,jj-1,2,1) * zu_a(ji+1,jj)
+                  ze21 =   akappa(ji,jj-1,1,1) * zv_a(ji+1,jj) - akappa(ji,jj-1,1,2) * zu_a(ji+1,jj)
+                  zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+                  zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+                  zvis12 =       zviseta (ji,jj-1) + dm
+                  zvis21 =       zviseta (ji,jj-1)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_21 =  zvis11 * ze11 + zdiag
+                  zs12_21 =  zvis12 * ze12 + zvis21 * ze21
+                  zs22_21 =  zvis11 * ze22 + zdiag
+                  zs21_21 =  zvis12 * ze21 + zvis21 * ze12
+
+                  ze11 =   akappa(ji-1,jj,1,1) * ( zu_a(ji  ,jj+1) - zu_a(ji-1,jj+1) )   &
+                     &   + akappa(ji-1,jj,1,2) * ( zv_a(ji  ,jj+1) + zv_a(ji-1,jj+1) )
+                  ze12 = + akappa(ji-1,jj,2,2) * ( zu_a(ji-1,jj+1) + zu_a(ji  ,jj+1) )   &
+                     &   - akappa(ji-1,jj,2,1) * ( zv_a(ji-1,jj+1) + zv_a(ji  ,jj+1) )
+                  ze22 = + akappa(ji-1,jj,2,2) * ( zv_a(ji-1,jj+1) + zv_a(ji  ,jj+1) )   &
+                     &   + akappa(ji-1,jj,2,1) * ( zu_a(ji-1,jj+1) + zu_a(ji  ,jj+1) )
+                  ze21 =   akappa(ji-1,jj,1,1) * ( zv_a(ji  ,jj+1) - zv_a(ji-1,jj+1) )   &
+                     &   - akappa(ji-1,jj,1,2) * ( zu_a(ji  ,jj+1) + zu_a(ji-1,jj+1) )
+                  zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+                  zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+                  zvis12 =       zviseta (ji-1,jj) + dm
+                  zvis21 =       zviseta (ji-1,jj)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_12 =  zvis11 * ze11 + zdiag
+                  zs12_12 =  zvis12 * ze12 + zvis21 * ze21
+                  zs22_12 =  zvis11 * ze22 + zdiag
+                  zs21_12 =  zvis12 * ze21 + zvis21 * ze12
+
+                  ze11 =   akappa(ji,jj,1,1) * ( zu_a(ji+1,jj) + zu_a(ji+1,jj+1) - zu_a(ji  ,jj+1) )   &
+                     &   + akappa(ji,jj,1,2) * ( zv_a(ji+1,jj) + zv_a(ji+1,jj+1) + zv_a(ji  ,jj+1) )
+                  ze12 = - akappa(ji,jj,2,2) * ( zu_a(ji+1,jj) - zu_a(ji  ,jj+1) - zu_a(ji+1,jj+1) )   &
+                     &   - akappa(ji,jj,2,1) * ( zv_a(ji+1,jj) + zv_a(ji  ,jj+1) + zv_a(ji+1,jj+1) )
+                  ze22 = - akappa(ji,jj,2,2) * ( zv_a(ji+1,jj) - zv_a(ji  ,jj+1) - zv_a(ji+1,jj+1) )   &
+                     &   + akappa(ji,jj,2,1) * ( zu_a(ji+1,jj) + zu_a(ji  ,jj+1) + zu_a(ji+1,jj+1) )
+                  ze21 =   akappa(ji,jj,1,1) * ( zv_a(ji+1,jj) + zv_a(ji+1,jj+1) - zv_a(ji  ,jj+1) )   &
+                     &   - akappa(ji,jj,1,2) * ( zu_a(ji+1,jj) + zu_a(ji+1,jj+1) + zu_a(ji  ,jj+1) )
+                  zvis11 = 2.0 * zviseta (ji,jj) + dm
+                  zvis22 =       zviszeta(ji,jj) - zviseta(ji,jj)
+                  zvis12 =       zviseta (ji,jj) + dm
+                  zvis21 =       zviseta (ji,jj)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_22 =  zvis11 * ze11 + zdiag
+                  zs12_22 =  zvis12 * ze12 + zvis21 * ze21
+                  zs22_22 =  zvis11 * ze22 + zdiag
+                  zs21_22 =  zvis12 * ze21 + zvis21 * ze12
+
+            ! 2nd part
+                  ze11 =   akappa(ji-1,jj-1,1,1) * ( zu_a(ji  ,jj-1) - zu_a(ji-1,jj-1) - zu_a(ji-1,jj) )   &
+                     &   + akappa(ji-1,jj-1,1,2) * ( zv_a(ji  ,jj-1) + zv_a(ji-1,jj-1) + zv_a(ji-1,jj) )
+                  ze12 = - akappa(ji-1,jj-1,2,2) * ( zu_a(ji-1,jj-1) + zu_a(ji  ,jj-1) - zu_a(ji-1,jj) )   &
+                     &   - akappa(ji-1,jj-1,2,1) * ( zv_a(ji-1,jj-1) + zv_a(ji  ,jj-1) + zv_a(ji-1,jj) )
+                  ze22 = - akappa(ji-1,jj-1,2,2) * ( zv_a(ji-1,jj-1) + zv_a(ji  ,jj-1) - zv_a(ji-1,jj) )   &
+                     &   + akappa(ji-1,jj-1,2,1) * ( zu_a(ji-1,jj-1) + zu_a(ji  ,jj-1) + zu_a(ji-1,jj) )
+                  ze21 =   akappa(ji-1,jj-1,1,1) * ( zv_a(ji  ,jj-1) - zv_a(ji-1,jj-1) - zv_a(ji-1,jj) )   &
+                     &  -  akappa(ji-1,jj-1,1,2) * ( zu_a(ji  ,jj-1) + zu_a(ji-1,jj-1) + zu_a(ji-1,jj) )
+                  zvis11 = 2.0 * zviseta (ji-1,jj-1) + dm
+                  zvis22 =       zviszeta(ji-1,jj-1) - zviseta(ji-1,jj-1)
+                  zvis12 =       zviseta (ji-1,jj-1) + dm
+                  zvis21 =       zviseta (ji-1,jj-1)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_11 =  zvis11 * ze11 + zdiag
+                  zs12_11 =  zvis12 * ze12 + zvis21 * ze21
+                  zs22_11 =  zvis11 * ze22 + zdiag
+                  zs21_11 =  zvis12 * ze21 + zvis21 * ze12
+
+                  ze11 =   akappa(ji,jj-1,1,1) * ( zu_a(ji+1,jj-1) - zu_a(ji  ,jj-1) )   &
+                     &   + akappa(ji,jj-1,1,2) * ( zv_a(ji+1,jj-1) + zv_a(ji  ,jj-1) )
+                  ze12 = - akappa(ji,jj-1,2,2) * ( zu_a(ji  ,jj-1) + zu_a(ji+1,jj-1) )   &
+                     &   - akappa(ji,jj-1,2,1) * ( zv_a(ji  ,jj-1) + zv_a(ji+1,jj-1) )
+                  ze22 = - akappa(ji,jj-1,2,2) * ( zv_a(ji  ,jj-1) + zv_a(ji+1,jj-1) )   &
+                     &   + akappa(ji,jj-1,2,1) * ( zu_a(ji  ,jj-1) + zu_a(ji+1,jj-1) )
+                  ze21 =   akappa(ji,jj-1,1,1) * ( zv_a(ji+1,jj-1) - zv_a(ji  ,jj-1) )   &
+                     &   - akappa(ji,jj-1,1,2) * ( zu_a(ji+1,jj-1) + zu_a(ji  ,jj-1) )
+                  zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+                  zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+                  zvis12 =       zviseta (ji,jj-1) + dm
+                  zvis21 =       zviseta (ji,jj-1)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_21 =  zs11_21 + zvis11 * ze11 + zdiag
+                  zs12_21 =  zs12_21 + zvis12 * ze12 + zvis21 * ze21
+                  zs22_21 =  zs22_21 + zvis11 * ze22 + zdiag
+                  zs21_21 =  zs21_21 + zvis12 * ze21 + zvis21 * ze12
+
+                  ze11 = - akappa(ji-1,jj,1,1) * zu_a(ji-1,jj) + akappa(ji-1,jj,1,2) * zv_a(ji-1,jj)
+                  ze12 = - akappa(ji-1,jj,2,2) * zu_a(ji-1,jj) - akappa(ji-1,jj,2,1) * zv_a(ji-1,jj)
+                  ze22 = - akappa(ji-1,jj,2,2) * zv_a(ji-1,jj) + akappa(ji-1,jj,2,1) * zu_a(ji-1,jj)
+                  ze21 = - akappa(ji-1,jj,1,1) * zv_a(ji-1,jj) - akappa(ji-1,jj,1,2) * zu_a(ji-1,jj)
+                  zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+                  zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+                  zvis12 =       zviseta (ji-1,jj) + dm
+                  zvis21 =       zviseta (ji-1,jj)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11_12 =  zs11_12 + zvis11 * ze11 + zdiag
+                  zs12_12 =  zs12_12 + zvis12 * ze12 + zvis21 * ze21
+                  zs22_12 =  zs22_12 + zvis11 * ze22 + zdiag
+                  zs21_12 =  zs21_12 + zvis12 * ze21 + zvis21 * ze12
+
+                  zd1 = + alambd(ji,jj,2,2,2,1) * zs11_21 + alambd(ji,jj,2,2,2,2) * zs11_22  &
+                     &  - alambd(ji,jj,2,2,1,1) * zs11_11 - alambd(ji,jj,2,2,1,2) * zs11_12  &
+                     &  - alambd(ji,jj,1,1,2,1) * zs12_21 - alambd(ji,jj,1,1,1,1) * zs12_11  &
+                     &  + alambd(ji,jj,1,1,2,2) * zs12_22 + alambd(ji,jj,1,1,1,2) * zs12_12  &
+                     &  + alambd(ji,jj,1,2,1,1) * zs21_11 + alambd(ji,jj,1,2,2,1) * zs21_21  &
+                     &  + alambd(ji,jj,1,2,1,2) * zs21_12 + alambd(ji,jj,1,2,2,2) * zs21_22  &
+                     &  - alambd(ji,jj,2,1,1,1) * zs22_11 - alambd(ji,jj,2,1,2,1) * zs22_21  &
+                     &  - alambd(ji,jj,2,1,1,2) * zs22_12 - alambd(ji,jj,2,1,2,2) * zs22_22
+
+                  zd2 = + alambd(ji,jj,2,2,2,1) * zs21_21 + alambd(ji,jj,2,2,2,2) * zs21_22  &
+                     &  - alambd(ji,jj,2,2,1,1) * zs21_11 - alambd(ji,jj,2,2,1,2) * zs21_12  &
+                     &  - alambd(ji,jj,1,1,2,1) * zs22_21 - alambd(ji,jj,1,1,1,1) * zs22_11  &
+                     &  + alambd(ji,jj,1,1,2,2) * zs22_22 + alambd(ji,jj,1,1,1,2) * zs22_12  &
+                     &  - alambd(ji,jj,1,2,1,1) * zs11_11 - alambd(ji,jj,1,2,2,1) * zs11_21  &
+                     &  - alambd(ji,jj,1,2,1,2) * zs11_12 - alambd(ji,jj,1,2,2,2) * zs11_22  &
+                     &  + alambd(ji,jj,2,1,1,1) * zs12_11 + alambd(ji,jj,2,1,2,1) * zs12_21  &
+                     &  + alambd(ji,jj,2,1,1,2) * zs12_12 + alambd(ji,jj,2,1,2,2) * zs12_22
+
+                  zur     = zu_a(ji,jj) - u_oce(ji,jj)
+                  zvr     = zv_a(ji,jj) - v_oce(ji,jj)
+!!!!
+                  zmod    = SQRT( zur*zur + zvr*zvr ) * ( 1.0 - zfrld(ji,jj) )
+                  za      = rhoco * zmod
+!!!!
+!!gm chg resul    za      = rhoco * SQRT( zur*zur + zvr*zvr ) * ( 1.0 - zfrld(ji,jj) )
+                  zac     = za * cangvg
+                  zmpzas  = alpha * zcorl(ji,jj) + za * zsang(ji,jj)
+                  zmassdt = zusdtp * zmass(ji,jj)
+                  zcorlal = ( 1.0 - alpha ) * zcorl(ji,jj)
+
+                  za1 =  zmassdt * zu0(ji,jj) + zcorlal * zv0(ji,jj) + za1ct(ji,jj)   &
+                     &        + za * ( cangvg * u_oce(ji,jj) - zsang(ji,jj) * v_oce(ji,jj) )
+                  za2 =  zmassdt * zv0(ji,jj) - zcorlal * zu0(ji,jj) + za2ct(ji,jj)   &
+                     &        + za * ( cangvg * v_oce(ji,jj) + zsang(ji,jj) * u_oce(ji,jj) )
+                  zb1    = zmassdt + zac - zc1u(ji,jj)
+                  zb2    = zmpzas        - zc2u(ji,jj)
+                  zc1    = zmpzas        + zc1v(ji,jj)
+                  zc2    = zmassdt + zac - zc2v(ji,jj)
+                  zdeter = zc1 * zb2 + zc2 * zb1
+                  zden   = SIGN( rone, zdeter) / MAX( epsd , ABS( zdeter ) )
+                  zunw   = (  ( za1 + zd1 ) * zc2 + ( za2 + zd2 ) * zc1 ) * zden
+                  zvnw   = (  ( za2 + zd2 ) * zb1 - ( za1 + zd1 ) * zb2 ) * zden
+                  zmask  = ( 1.0 - MAX( rzero, SIGN( rone , 1.0 - zmass(ji,jj) ) ) ) * tmu(ji,jj)
+
+                  zu_n(ji,jj) = ( zu_a(ji,jj) + om * ( zunw - zu_a(ji,jj) ) * tmu(ji,jj) ) * zmask
+                  zv_n(ji,jj) = ( zv_a(ji,jj) + om * ( zvnw - zv_a(ji,jj) ) * tmu(ji,jj) ) * zmask
+               END DO
+            END DO
+
+            CALL lbc_lnk( zu_n(:,1:jpj), 'I', -1. )
+            CALL lbc_lnk( zv_n(:,1:jpj), 'I', -1. )
+
+            ! Test of Convergence
+            DO jj = k_j1+1 , k_jpj-1
+               zresr(:,jj) = MAX( ABS( zu_a(:,jj) - zu_n(:,jj) ) , ABS( zv_a(:,jj) - zv_n(:,jj) ) )
+            END DO
+            zresm = MAXVAL( zresr(1:jpi,k_j1+1:k_jpj-1) )
+!!!! this should be faster on scalar processor
+!           zresm = MAXVAL(  MAX( ABS( zu_a(1:jpi,k_j1+1:k_jpj-1) - zu_n(1:jpi,k_j1+1:k_jpj-1) ),   &
+!              &                  ABS( zv_a(1:jpi,k_j1+1:k_jpj-1) - zv_n(1:jpi,k_j1+1:k_jpj-1) ) )  )
+!!!!
+            IF( lk_mpp )   CALL mpp_max( zresm )   ! max over the global domain
+
+            DO jj = k_j1, k_jpj
+               zu_a(:,jj) = zu_n(:,jj)
+               zv_a(:,jj) = zv_n(:,jj)
+            END DO
+
+            IF( zresm <= resl )   EXIT   iflag
+
+            !                                                   ! ================ !
+         END DO    iflag                                        !  end Relaxation  !
+         !                                                      ! ================ !
+
+         IF( zindu == 0 ) THEN      ! even iteration
+            DO jj = k_j1 , k_jpj-1
+               zu0(:,jj) = zu_a(:,jj)
+               zv0(:,jj) = zv_a(:,jj)
+            END DO
+         ENDIF
+         !                                                ! ==================== !
+      END DO                                              !  end loop over iter  !
+      !                                                   ! ==================== !
+
+      u_ice(:,:) = zu_a(:,1:jpj)
+      v_ice(:,:) = zv_a(:,1:jpj)
+
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('lim_rhg  : res =',D23.16, ' iter =',I4)") zresm, jter
+         CALL prt_ctl_info(charout)
+         CALL prt_ctl(tab2d_1=u_ice, clinfo1=' lim_rhg  : u_ice :', tab2d_2=v_ice, clinfo2=' v_ice :')
+      ENDIF
+
+   END SUBROUTINE lim_rhg_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO 2.0 LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_rhg_2( k1 , k2 )       ! Dummy routine
+      WRITE(*,*) 'lim_rhg_2: You should not have seen this print! error?', k1, k2
+   END SUBROUTINE lim_rhg_2
+#endif
+
+   !!==============================================================================
+END MODULE limrhg_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrst_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrst_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limrst_2.F90	(revision 1844)
@@ -0,0 +1,269 @@
+MODULE limrst_2
+   !!======================================================================
+   !!                     ***  MODULE  limrst_2  ***
+   !! Ice restart :  write the ice restart file
+   !!======================================================================
+   !! History :  2.0  !  01-04  (C. Ethe, G. Madec)  Original code
+   !!                 !  06-07  (S. Masson)  use IOM for restart read/write
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_rst_opn_2   : open ice restart file
+   !!   lim_rst_write_2 : write of the ice restart file 
+   !!   lim_rst_read_2  : read  the ice restart file 
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE ice_2
+   USE sbc_oce
+   USE sbc_ice
+
+   USE in_out_manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_rst_opn_2     ! routine called by sbcice_lim_2.F90
+   PUBLIC   lim_rst_write_2   ! routine called by sbcice_lim_2.F90
+   PUBLIC   lim_rst_read_2    ! routine called by iceini_2.F90
+
+   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write 
+   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rst_opn_2( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_opn_2  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      !
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
+      
+      ! to get better performances with NetCDF format:
+      ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1)
+      ! except if we write ice restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1
+      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+         IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+         ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out)
+         IF(lwp) THEN
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ice restart binary file: '//clname
+            CASE DEFAULT         ;   WRITE(numout,*) '             open ice restart NetCDF file: '//clname
+            END SELECT
+            IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN   
+               WRITE(numout,*)         '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
+            ELSE   ;   WRITE(numout,*) '             kt = '                         , kt,' date= ', ndastp
+            ENDIF
+         ENDIF
+
+         CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib )
+         lrst_ice = .TRUE.
+      ENDIF
+      !
+   END SUBROUTINE lim_rst_opn_2
+
+   SUBROUTINE lim_rst_write_2( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_write_2  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! number of iteration
+      !
+      INTEGER ::   iter   ! kt + nn_fsbc -1
+      !!----------------------------------------------------------------------
+
+      iter = kt + nn_fsbc - 1   ! ice restarts are written at kt == nitrst - nn_fsbc + 1
+
+      IF( iter == nitrst ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_rst_write_2 : write ice restart file  kt =', kt
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
+      ENDIF
+
+      ! Write in numriw (if iter == nitrst)
+      ! ------------------ 
+      !                                                                     ! calendar control
+      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice', REAL( iter, wp) ) 
+      
+      CALL iom_rstput( iter, nitrst, numriw, 'hicif' , hicif (:,:)   )      ! prognostic variables 
+      CALL iom_rstput( iter, nitrst, numriw, 'hsnif' , hsnif (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'frld'  , frld  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sist'  , sist  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif  (:,:,1) )
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif  (:,:,2) )
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif3' , tbif  (:,:,3) )
+      CALL iom_rstput( iter, nitrst, numriw, 'u_ice' , u_ice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ice' , v_ice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'qstoif', qstoif(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq' , fsbbq (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa   (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya   (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc0'  , sxc0  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc0'  , syc0  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc0' , sxxc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc0' , syyc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc0' , sxyc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc1'  , sxc1  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc1'  , syc1  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc1' , sxxc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc1' , syyc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc1' , sxyc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc2'  , sxc2  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc2'  , syc2  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc2' , sxxc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc2' , syyc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc2' , sxyc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxst'  , sxst  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syst'  , syst  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxst' , sxxst (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyst' , syyst (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyst' , sxyst (:,:)   )
+      
+      IF( iter == nitrst ) THEN
+         CALL iom_close( numriw )                         ! close the restart file
+         lrst_ice = .FALSE.
+      ENDIF
+      !
+   END SUBROUTINE lim_rst_write_2
+
+
+   SUBROUTINE lim_rst_read_2
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_read_2  ***
+      !!
+      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   ziter
+      INTEGER  ::   jlibalt = jprstlib
+      LOGICAL  ::   llok
+      INTEGER  ::   itest
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_rst_read_2 : read ice NetCDF restart file'
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+      ENDIF
+
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if {cn_icerst_in}.nc exists, then set jlibalt to jpnf90
+        INQUIRE( FILE = TRIM(cn_icerst_in)//'.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+      ENDIF
+
+      CALL iom_open ( cn_icerst_in, numrir, kiolib = jlibalt )
+
+      CALL iom_get( numrir, 'kt_ice' , ziter )
+      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', INT( ziter )
+      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
+
+      !Control of date
+      
+      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
+         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
+         &                   '   verify the file or rerun with the value 0 for the',        &
+         &                   '   control of time parameter  nrstdt' )
+
+      CALL iom_get( numrir, jpdom_autoglo, 'hicif' , hicif  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'hsnif' , hsnif  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'frld'  , frld   )    
+      CALL iom_get( numrir, jpdom_autoglo, 'sist'  , sist   )    
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) )    
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) )    
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif3' , tbif(:,:,3) )    
+
+      itest = iom_varid( numrir, 'u_ice', ldstop = .FALSE. )   ! test if the variable u_ice is included in the file
+      IF( itest > 0 ) THEN   ! yes -> new restart files (from NEMO 3.2)
+         CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice )  
+         CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice )    
+      ELSE                   ! no  -> old restart file with variable called [uv]i_ice (inroduced in NEMO 3.0)
+         CALL iom_get( numrir, jpdom_autoglo, 'ui_ice', u_ice )  
+         CALL iom_get( numrir, jpdom_autoglo, 'vi_ice', v_ice )    
+      ENDIF
+
+      CALL iom_get( numrir, jpdom_autoglo, 'qstoif', qstoif )    
+      CALL iom_get( numrir, jpdom_autoglo, 'fsbbq' , fsbbq  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'sxice' , sxice  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syice' , syice  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxice', sxxice )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyice', syyice )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyice', sxyice )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxsn'  , sxsn   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sysn'  , sysn   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxsn' , sxxsn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syysn' , syysn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxysn' , sxysn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxa'   , sxa    )
+      CALL iom_get( numrir, jpdom_autoglo, 'sya'   , sya    )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxa'  , sxxa   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syya'  , syya   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxya'  , sxya   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc0'  , sxc0   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc0'  , syc0   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc0' , sxxc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc0' , syyc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc0' , sxyc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc1'  , sxc1   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc1'  , syc1   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc1' , sxxc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc1' , syyc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc1' , sxyc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc2'  , sxc2   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc2'  , syc2   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc2' , sxxc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc2' , syyc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc2' , sxyc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxst'  , sxst   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syst'  , syst   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxst' , sxxst  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyst' , syyst  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyst' , sxyst  )
+      
+      CALL iom_close( numrir )
+      !
+   END SUBROUTINE lim_rst_read_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :       Empty module        NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE limrst_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 1844)
@@ -0,0 +1,333 @@
+MODULE limsbc_2
+   !!======================================================================
+   !!                       ***  MODULE limsbc_2   ***
+   !!           computation of the flux at the sea ice/ocean interface
+   !!======================================================================
+   !! History : 00-01 (H. Goosse) Original code
+   !!           02-07 (C. Ethe, G. Madec) re-writing F90
+   !!           06-07 (G. Madec) surface module
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_sbc_2  : flux at the ice / ocean interface
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+   USE dom_oce          ! ocean domain
+   USE sbc_ice          ! surface boundary condition
+   USE sbc_oce          ! surface boundary condition
+   USE phycst           ! physical constants
+   USE ice_2            ! LIM sea-ice variables
+
+   USE lbclnk           ! ocean lateral boundary condition
+   USE in_out_manager   ! I/O manager
+   USE diaar5, ONLY :   lk_diaar5
+   USE iom              ! 
+   USE albedo           ! albedo parameters
+   USE prtctl           ! Print control
+   USE cpl_oasis3, ONLY : lk_cpl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC lim_sbc_2     ! called by sbc_ice_lim_2
+
+   REAL(wp)  ::   epsi16 = 1.e-16  ! constant values
+   REAL(wp)  ::   rzero  = 0.e0    
+   REAL(wp)  ::   rone   = 1.e0
+   REAL(wp), DIMENSION(jpi,jpj)  ::   soce_r
+   REAL(wp), DIMENSION(jpi,jpj)  ::   sice_r
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_sbc_2( kt )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_sbc_2 ***
+      !!  
+      !! ** Purpose : Update surface ocean boundary condition over areas
+      !!      that are at least partially covered by sea-ice
+      !!         
+      !! ** Action  : - comput. of the momentum, heat and freshwater/salt
+      !!      fluxes at the ice-ocean interface.
+      !!              - Update 
+      !!     
+      !! ** Outputs : - qsr     : sea heat flux:     solar 
+      !!              - qns     : sea heat flux: non solar
+      !!              - emp     : freshwater budget: volume flux 
+      !!              - emps    : freshwater budget: concentration/dillution 
+      !!              - utau    : sea surface i-stress (ocean referential)
+      !!              - vtau    : sea surface j-stress (ocean referential)
+      !!              - fr_i    : ice fraction
+      !!              - tn_ice  : sea-ice surface temperature
+      !!              - alb_ice : sea-ice alberdo (lk_cpl=T)
+      !!
+      !! References : Goosse, H. et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90.
+      !!              Tartinville et al. 2001 Ocean Modelling, 3, 95-108.
+      !!---------------------------------------------------------------------
+      INTEGER ::   kt    ! number of iteration
+      !!
+      INTEGER  ::   ji, jj           ! dummy loop indices
+      INTEGER  ::   ifvt, i1mfr, idfr               ! some switches
+      INTEGER  ::   iflt, ial, iadv, ifral, ifrdv
+      INTEGER  ::   ii0, ii1, ij0, ij1  ! temporary integers
+      REAL(wp) ::   zrdtir           ! 1. / rdt_ice
+      REAL(wp) ::   zqsr  , zqns     ! solar & non solar heat flux
+      REAL(wp) ::   zinda            ! switch for testing the values of ice concentration
+      REAL(wp) ::   zfons            ! salt exchanges at the ice/ocean interface
+      REAL(wp) ::   zemp             ! freshwater exchanges at the ice/ocean interface
+      REAL(wp) ::   zfrldu, zfrldv   ! lead fraction at U- & V-points
+      REAL(wp) ::   zutau , zvtau    ! lead fraction at U- & V-points
+      REAL(wp) ::   zu_io , zv_io    ! 2 components of the ice-ocean velocity
+! interface 2D --> 3D
+      REAL(wp), DIMENSION(jpi,jpj,1) ::   zalb     ! albedo of ice under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj,1) ::   zalbp    ! albedo of ice under clear sky
+      REAL(wp) ::   zsang, zmod, zztmp, zfm
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztio_u, ztio_v   ! component of ocean stress below sea-ice at I-point
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztiomi           ! module    of ocean stress below sea-ice at I-point
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqnsoce          ! save qns before its modification by ice model
+
+      !!---------------------------------------------------------------------
+     
+      zrdtir = 1. / rdt_ice
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_sbc_2 : LIM 2.0 sea-ice - surface boundary condition'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~   '
+
+         soce_r(:,:) = soce
+         sice_r(:,:) = sice
+         !
+         IF( cp_cfg == "orca"  .AND. jp_cfg == 2 ) THEN
+            !                                        ! =======================
+            !                                        !  ORCA_R2 configuration
+            !                                        ! =======================
+            ii0 = 145   ;   ii1 = 180        ! Baltic Sea
+            ij0 = 113   ;   ij1 = 130   ;   soce_r(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0
+                                            sice_r(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 2.e0
+         ENDIF
+         !
+      ENDIF
+
+      !------------------------------------------!
+      !      heat flux at the ocean surface      !
+      !------------------------------------------!
+
+!!gm
+!!gm CAUTION   
+!!gm re-verifies the non solar expression, especially over open ocen
+!!gm
+      zqnsoce(:,:) = qns(:,:)
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zinda   = 1.0   - MAX( rzero , SIGN( rone, - ( 1.0 - pfrld(ji,jj) )   ) )
+            ifvt    = zinda * MAX( rzero , SIGN( rone,  - phicif(ji,jj)           ) )
+            i1mfr   = 1.0   - MAX( rzero , SIGN( rone, - ( 1.0 - frld(ji,jj) )    ) )
+            idfr    = 1.0   - MAX( rzero , SIGN( rone, frld(ji,jj) - pfrld(ji,jj) ) )
+            iflt    = zinda  * (1 - i1mfr) * (1 - ifvt )
+            ial     = ifvt   * i1mfr + ( 1 - ifvt ) * idfr
+            iadv    = ( 1  - i1mfr ) * zinda
+            ifral   = ( 1  - i1mfr * ( 1 - ial ) )   
+            ifrdv   = ( 1  - ifral * ( 1 - ial ) ) * iadv 
+
+!!$            zinda   = 1.0 - AINT( pfrld(ji,jj) )                   !   = 0. if pure ocean else 1. (at previous time)
+!!$
+!!$            i1mfr   = 1.0 - AINT(  frld(ji,jj) )                   !   = 0. if pure ocean else 1. (at current  time)
+!!$
+!!$            IF( phicif(ji,jj) <= 0. ) THEN   ;   ifvt = zinda      !   = 1. if (snow and no ice at previous time) else 0. ???
+!!$            ELSE                             ;   ifvt = 0.
+!!$            ENDIF
+!!$
+!!$            IF( frld(ji,jj) >= pfrld(ji,jj) ) THEN   ;   idfr = 0.  !   = 0. if lead fraction increases from previous to current
+!!$            ELSE                                     ;   idfr = 1.   
+!!$            ENDIF
+!!$
+!!$            iflt    = zinda  * (1 - i1mfr) * (1 - ifvt )    !   = 1. if ice (not only snow) at previous and pure ocean at current
+!!$
+!!$            ial     = ifvt   * i1mfr    +    ( 1 - ifvt ) * idfr
+!!$!                 snow no ice   ice         ice or nothing  lead fraction increases
+!!$!                 at previous   now           at previous
+!!$!                -> ice aera increases  ???         -> ice aera decreases ???
+!!$
+!!$            iadv    = ( 1  - i1mfr ) * zinda  
+!!$!                     pure ocean      ice at
+!!$!                     at current      previous
+!!$!                        -> = 1. if ice disapear between previous and current
+!!$
+!!$            ifral   = ( 1  - i1mfr * ( 1 - ial ) )  
+!!$!                            ice at     ???
+!!$!                            current         
+!!$!                         -> ???
+!!$ 
+!!$            ifrdv   = ( 1  - ifral * ( 1 - ial ) ) * iadv 
+!!$!                                                    ice disapear                           
+!!$
+!!$
+
+            !   computation the solar flux at ocean surface
+#if defined key_coupled 
+            zqsr = qsr_tot(ji,jj) + ( fstric(ji,jj) - qsr_ice(ji,jj,1) ) * ( 1.0 - pfrld(ji,jj) )
+#else
+            zqsr = pfrld(ji,jj) * qsr(ji,jj)  + ( 1.  - pfrld(ji,jj) ) * fstric(ji,jj)
+#endif            
+            !  computation the non solar heat flux at ocean surface
+            zqns    =  - ( 1. - thcm(ji,jj) ) * zqsr   &   ! part of the solar energy used in leads
+               &       + iflt    * ( fscmbq(ji,jj) + ffltbif(ji,jj) )                            &
+               &       + ifral   * ( ial * qcmif(ji,jj) + (1 - ial) * qldif(ji,jj) ) * zrdtir    &
+               &       + ifrdv   * ( qfvbq(ji,jj) + qdtcn(ji,jj) ) * zrdtir
+
+            fsbbq(ji,jj) = ( 1.0 - ( ifvt + iflt ) ) * fscmbq(ji,jj)     ! ???
+            
+            qsr  (ji,jj) = zqsr                                          ! solar heat flux 
+            qns  (ji,jj) = zqns - fdtcn(ji,jj)                           ! non solar heat flux
+         END DO
+      END DO
+
+      CALL iom_put( 'hflx_ice_cea', - fdtcn(:,:) )      
+      CALL iom_put( 'qns_io_cea', qns(:,:) - zqnsoce(:,:) * pfrld(:,:) )      
+      CALL iom_put( 'qsr_io_cea', fstric(:,:) * (1. - pfrld(:,:)) )
+
+      !------------------------------------------!
+      !      mass flux at the ocean surface      !
+      !------------------------------------------!
+
+!!gm
+!!gm CAUTION   
+!!gm re-verifies the emp & emps expression, especially the absence of 1-frld on zfm
+!!gm
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            
+#if defined key_coupled
+          zemp = emp_tot(ji,jj) - emp_ice(ji,jj) * ( 1. - pfrld(ji,jj) )    &   ! 
+             &   + rdmsnif(ji,jj) * zrdtir                                      !  freshwaterflux due to snow melting 
+#else
+!!$            !  computing freshwater exchanges at the ice/ocean interface
+!!$            zpme = - evap(ji,jj)    *   frld(ji,jj)           &   !  evaporation over oceanic fraction
+!!$               &   + tprecip(ji,jj)                           &   !  total precipitation
+!!$               &   - sprecip(ji,jj) * ( 1. - pfrld(ji,jj) )   &   !  remov. snow precip over ice
+!!$               &   - rdmsnif(ji,jj) / rdt_ice                     !  freshwaterflux due to snow melting 
+            !  computing freshwater exchanges at the ice/ocean interface
+            zemp = + emp(ji,jj)     *         frld(ji,jj)      &   !  e-p budget over open ocean fraction 
+               &   - tprecip(ji,jj) * ( 1. -  frld(ji,jj) )    &   !  liquid precipitation reaches directly the ocean
+               &   + sprecip(ji,jj) * ( 1. - pfrld(ji,jj) )    &   !  taking into account change in ice cover within the time step
+               &   + rdmsnif(ji,jj) * zrdtir                       !  freshwaterflux due to snow melting 
+               !                                                   !  ice-covered fraction:
+#endif            
+
+            !  computing salt exchanges at the ice/ocean interface
+            zfons =  ( soce_r(ji,jj) - sice_r(ji,jj) ) * ( rdmicif(ji,jj) * zrdtir ) 
+            
+            !  converting the salt flux from ice to a freshwater flux from ocean
+            zfm  = zfons / ( sss_m(ji,jj) + epsi16 )
+            
+            emps(ji,jj) = zemp + zfm      ! surface ocean concentration/dilution effect (use on SSS evolution)
+            emp (ji,jj) = zemp            ! surface ocean volume flux (use on sea-surface height evolution)
+
+         END DO
+      END DO
+
+      IF( lk_diaar5 ) THEN
+         CALL iom_put( 'isnwmlt_cea'  ,                 rdmsnif(:,:) * zrdtir )
+         CALL iom_put( 'fsal_virt_cea',   soce_r(:,:) * rdmicif(:,:) * zrdtir )
+         CALL iom_put( 'fsal_real_cea', - sice_r(:,:) * rdmicif(:,:) * zrdtir )
+      ENDIF
+
+      !------------------------------------------!
+      !    momentum flux at the ocean surface    !
+      !------------------------------------------!
+
+      IF ( ln_limdyn ) THEN                        ! Update the stress over ice-over area (only in ice-dynamic case)
+         !                                         ! otherwise the atmosphere-ocean stress is used everywhere
+
+         ! ... ice stress over ocean with a ice-ocean rotation angle (at I-point)
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               ! ... change the cosinus angle sign in the south hemisphere
+               zsang  = SIGN(1.e0, gphif(ji,jj) ) * sangvg
+               ! ... ice velocity relative to the ocean at I-point
+               zu_io  = u_ice(ji,jj) - u_oce(ji,jj)
+               zv_io  = v_ice(ji,jj) - v_oce(ji,jj)
+               zmod   = SQRT( zu_io * zu_io + zv_io * zv_io )
+               zztmp  = rhoco * zmod
+               ! ... components of ice stress over ocean with a ice-ocean rotation angle (at I-point)
+               ztio_u(ji,jj) = zztmp * ( cangvg * zu_io - zsang * zv_io )
+               ztio_v(ji,jj) = zztmp * ( cangvg * zv_io + zsang * zu_io )
+               ! ... module of ice stress over ocean (at I-point)
+               ztiomi(ji,jj) = zztmp * zmod
+               ! 
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! NO vector opt.
+               ! ... components of ice-ocean stress at U and V-points  (from I-point values)
+               zutau  = 0.5 * ( ztio_u(ji+1,jj) + ztio_u(ji+1,jj+1) )
+               zvtau  = 0.5 * ( ztio_v(ji,jj+1) + ztio_v(ji+1,jj+1) )
+               ! ... open-ocean (lead) fraction at U- & V-points (from T-point values)
+               zfrldu = 0.5 * ( frld(ji,jj) + frld(ji+1,jj  ) )
+               zfrldv = 0.5 * ( frld(ji,jj) + frld(ji  ,jj+1) )
+               ! ... update components of surface ocean stress (ice-cover wheighted)
+               utau(ji,jj) = zfrldu * utau(ji,jj) + ( 1. - zfrldu ) * zutau
+               vtau(ji,jj) = zfrldv * vtau(ji,jj) + ( 1. - zfrldv ) * zvtau
+               ! ... module of ice-ocean stress at T-points (from I-point values)
+               zztmp = 0.25 * ( ztiomi(ji,jj) + ztiomi(ji+1,jj) + ztiomi(ji,jj+1) + ztiomi(ji+1,jj+1) )
+               ! ... update module of surface ocean stress (ice-cover wheighted)
+               taum(ji,jj) = frld(ji,jj) * taum(ji,jj) + ( 1. - frld(ji,jj) ) * zztmp
+               !
+            END DO
+         END DO
+
+         ! boundary condition on the stress (utau,vtau,taum)
+         CALL lbc_lnk( utau, 'U', -1. )
+         CALL lbc_lnk( vtau, 'V', -1. )
+         CALL lbc_lnk( taum, 'T',  1. )
+
+      ENDIF
+
+      !-----------------------------------------------!
+      !   Coupling variables                          !
+      !-----------------------------------------------!
+
+      IF ( lk_cpl ) THEN           
+         ! Ice surface temperature 
+         tn_ice(:,:,1) = sist(:,:)          ! sea-ice surface temperature       
+         ! Computation of snow/ice and ocean albedo
+         CALL albedo_ice( tn_ice, reshape( hicif, (/jpi,jpj,1/) ), reshape( hsnif, (/jpi,jpj,1/) ), zalbp, zalb )
+         alb_ice(:,:,1) =  0.5 * ( zalbp(:,:,1) + zalb (:,:,1) )   ! Ice albedo (mean clear and overcast skys)
+         CALL iom_put( "icealb_cea", alb_ice(:,:,1) * fr_i(:,:) )  ! ice albedo
+      ENDIF
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=qsr   , clinfo1=' lim_sbc: qsr    : ', tab2d_2=qns   , clinfo2=' qns     : ')
+         CALL prt_ctl(tab2d_1=emp   , clinfo1=' lim_sbc: emp    : ', tab2d_2=emps  , clinfo2=' emps    : ')
+         CALL prt_ctl(tab2d_1=utau  , clinfo1=' lim_sbc: utau   : ', mask1=umask,   &
+            &         tab2d_2=vtau  , clinfo2=' vtau    : '        , mask2=vmask )
+         CALL prt_ctl(tab2d_1=fr_i  , clinfo1=' lim_sbc: fr_i   : ', tab2d_2=tn_ice(:,:,1), clinfo2=' tn_ice  : ')
+      ENDIF 
+   
+    END SUBROUTINE lim_sbc_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_sbc_2         ! Dummy routine
+   END SUBROUTINE lim_sbc_2
+#endif 
+
+   !!======================================================================
+END MODULE limsbc_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtab_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtab_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtab_2.F90	(revision 1844)
@@ -0,0 +1,80 @@
+MODULE limtab_2
+   !!======================================================================
+   !!                       ***  MODULE limtab_2   ***
+   !!              transform 1D (2D) array to a 2D (1D) table
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   tab_2d_1d  : 2-D to 1-D
+   !!   tab_1d_2d  : 1-D to 2-D
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tab_2d_1d_2  ! called by lim_ther
+   PUBLIC tab_1d_2d_2  ! called by lim_ther
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tab_2d_1d_2 ( ndim1d, tab1d, tab2d, ndim2d_x, ndim2d_y, tab_ind )
+
+      INTEGER, INTENT(in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT(in) ::  &
+         tab2d
+
+      INTEGER, DIMENSION ( ndim1d), INTENT ( in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT ( out) ::  & 
+         tab1d
+
+      INTEGER ::  &
+         jn , jid, jjd
+        
+      DO jn = 1, ndim1d
+         jid        = MOD( tab_ind(jn) - 1, ndim2d_x ) + 1
+         jjd        = ( tab_ind(jn) - 1 ) / ndim2d_x + 1
+         tab1d( jn) = tab2d( jid, jjd)
+      END DO 
+
+   END SUBROUTINE tab_2d_1d_2
+
+
+   SUBROUTINE tab_1d_2d_2 ( ndim1d, tab2d, tab_ind, tab1d, ndim2d_x, ndim2d_y )
+
+      INTEGER, INTENT ( in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      INTEGER, DIMENSION (ndim1d) , INTENT (in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT (in) ::  &
+         tab1d  
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT ( out) :: &
+         tab2d
+
+      INTEGER :: &
+         jn, jid, jjd
+
+      DO jn = 1, ndim1d
+         jid             = MOD( tab_ind(jn) - 1, ndim2d_x) + 1
+         jjd             =    ( tab_ind(jn) - 1 ) / ndim2d_x  + 1
+         tab2d(jid, jjd) = tab1d( jn)
+      END DO
+
+   END SUBROUTINE tab_1d_2d_2
+
+#endif
+END MODULE limtab_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_2.F90	(revision 1844)
@@ -0,0 +1,574 @@
+MODULE limthd_2
+   !!======================================================================
+   !!                  ***  MODULE limthd_2   ***
+   !!              LIM thermo ice model : ice thermodynamic
+   !!======================================================================
+   !! History :  1.0  ! 2000-01 (LIM)
+   !!            2.0  ! 2002-07 (C. Ethe, G. Madec) F90
+   !!            2.0  ! 2003-08 (C. Ethe)  add lim_thd_init
+   !!             -   ! 2008-2008  (A. Caubel, G. Madec, E. Maisonnave, S. Masson ) generic coupled interface
+   !!---------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_thd_2      : thermodynamic of sea ice
+   !!   lim_thd_init_2 : initialisation of sea-ice thermodynamic
+   !!----------------------------------------------------------------------
+   USE phycst          ! physical constants
+   USE dom_oce         ! ocean space and time domain variables
+   USE domvvl
+   USE lbclnk
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp
+   USE iom             ! IOM library
+   USE ice_2           ! LIM sea-ice variables
+   USE sbc_oce         ! 
+   USE sbc_ice         ! 
+   USE thd_ice_2       ! LIM thermodynamic sea-ice variables
+   USE dom_ice_2       ! LIM sea-ice domain
+   USE limthd_zdf_2
+   USE limthd_lac_2
+   USE limtab_2
+   USE prtctl          ! Print control
+   USE cpl_oasis3, ONLY : lk_cpl
+   USE diaar5, ONLY :   lk_diaar5
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_thd_2  ! called by lim_step
+
+   REAL(wp) ::   epsi20 = 1.e-20   ! constant values
+   REAL(wp) ::   epsi16 = 1.e-16   !
+   REAL(wp) ::   epsi04 = 1.e-04   !
+   REAL(wp) ::   rzero  = 0.e0     !
+   REAL(wp) ::   rone   = 1.e0     !
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!-------- -------------------------------------------------------------
+   !! NEMO/LIM 3.2,  UCL-LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_2( kt )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_2  ***       
+      !!  
+      !! ** Purpose : This routine manages the ice thermodynamic.
+      !!         
+      !! ** Action : - Initialisation of some variables
+      !!             - Some preliminary computation (oceanic heat flux
+      !!               at the ice base, snow acc.,heat budget of the leads)
+      !!             - selection of the icy points and put them in an array
+      !!             - call lim_vert_ther for vert ice thermodynamic
+      !!             - back to the geographic grid
+      !!             - selection of points for lateral accretion
+      !!             - call lim_lat_acc  for the ice accretion
+      !!             - back to the geographic grid
+      !!
+      !! References :   Goosse et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER  ::   ji, jj               ! dummy loop indices
+      INTEGER  ::   nbpb                 ! nb of icy pts for thermo. cal.
+      INTEGER  ::   nbpac                ! nb of pts for lateral accretion 
+      CHARACTER (len=22) :: charout
+      REAL(wp) ::   zfric_umin = 5e-03   ! lower bound for the friction velocity
+      REAL(wp) ::   zfric_umax = 2e-02   ! upper bound for the friction velocity
+      REAL(wp) ::   zinda                ! switch for test. the val. of concen.
+      REAL(wp) ::   zindb, zindg         ! switches for test. the val of arg
+      REAL(wp) ::   zfricp               ! temporary scalar
+      REAL(wp) ::   za , zh, zthsnice    !
+      REAL(wp) ::   zfric_u              ! friction velocity 
+      REAL(wp) ::   zfnsol               ! total non solar heat
+      REAL(wp) ::   zfontn               ! heat flux from snow thickness
+      REAL(wp) ::   zfntlat, zpareff     ! test. the val. of lead heat budget
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztmp      ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zqlbsbq   ! link with lead energy budget qldif
+      REAL(wp) ::   zuice_m, zvice_m     ! Sea-ice velocities at U & V-points
+      REAL(wp) ::   zhice_u, zhice_v     ! Sea-ice volume at U & V-points
+      REAL(wp) ::   ztr_fram             ! Sea-ice transport through Fram strait
+      REAL(wp) ::   zrhoij, zrhoijm1     ! temporary scalars
+      REAL(wp) ::   zztmp                ! temporary scalars within a loop
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zlicegr   ! link with lateral ice growth 
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmsk      ! 3D workspace
+!!$      REAL(wp), DIMENSION(jpi,jpj) ::   firic         !: IR flux over the ice            (outputs only)
+!!$      REAL(wp), DIMENSION(jpi,jpj) ::   fcsic         !: Sensible heat flux over the ice (outputs only)
+!!$      REAL(wp), DIMENSION(jpi,jpj) ::   fleic         !: Latent heat flux over the ice   (outputs only)
+!!$      REAL(wp), DIMENSION(jpi,jpj) ::   qlatic        !: latent flux                     (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdvosif       !: Variation of volume at surface                (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdvobif       !: Variation of ice volume at the bottom ice     (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdvolif       !: Total variation of ice volume                 (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdvonif       !: Surface accretion Snow to Ice transformation  (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdvomif       !: Bottom variation of ice volume due to melting (outputs only)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zu_imasstr    !: Sea-ice transport along i-axis at U-point     (outputs only) 
+      REAL(wp), DIMENSION(jpi,jpj) ::   zv_imasstr    !: Sea-ice transport along j-axis at V-point     (outputs only) 
+      !!-------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL lim_thd_init_2  ! Initialization (first time-step only)
+   
+      !-------------------------------------------!
+      !   Initilization of diagnostic variables   !
+      !-------------------------------------------!
+      
+!!gm needed?  yes at least for some of these arrays 
+      zdvosif(:,:) = 0.e0   ! variation of ice volume at surface
+      zdvobif(:,:) = 0.e0   ! variation of ice volume at bottom
+      zdvolif(:,:) = 0.e0   ! total variation of ice volume
+      zdvonif(:,:) = 0.e0   ! transformation of snow to sea-ice volume
+!      zdvonif(:,:) = 0.e0   ! lateral variation of ice volume
+      zlicegr(:,:) = 0.e0   ! lateral variation of ice volume
+      zdvomif(:,:) = 0.e0   ! variation of ice volume at bottom due to melting only
+      ztr_fram     = 0.e0   ! sea-ice transport through Fram strait
+      fstric (:,:) = 0.e0   ! part of solar radiation absorbing inside the ice
+      fscmbq (:,:) = 0.e0   ! linked with fstric
+      ffltbif(:,:) = 0.e0   ! linked with fstric
+      qfvbq  (:,:) = 0.e0   ! linked with fstric
+      rdmsnif(:,:) = 0.e0   ! variation of snow mass per unit area
+      rdmicif(:,:) = 0.e0   ! variation of ice mass per unit area
+      zmsk (:,:,:) = 0.e0
+
+      ! set to zero snow thickness smaller than epsi04
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            hsnif(ji,jj)  = hsnif(ji,jj) *  MAX( rzero, SIGN( rone , hsnif(ji,jj) - epsi04 ) )
+         END DO
+      END DO
+!!gm better coded (do not use SIGN...)
+!     WHERE( hsnif(:,:) < epsi04 )   hsnif(:,:) = 0.e0
+!!gm
+
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=hsnif, clinfo1=' lim_thd: hsnif   : ' )
+      
+      !-----------------------------------!
+      !   Treatment of particular cases   !
+      !-----------------------------------!
+      
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !  snow is transformed into ice if the original ice cover disappears.
+            zindg         = tms(ji,jj) *  MAX( rzero , SIGN( rone , -hicif(ji,jj) ) )
+            hicif(ji,jj)  = hicif(ji,jj) + zindg * rhosn * hsnif(ji,jj) / rau0
+            hsnif(ji,jj)  = ( rone - zindg ) * hsnif(ji,jj) + zindg * hicif(ji,jj) * ( rau0 - rhoic ) / rhosn
+            dmgwi(ji,jj)  = zindg * (1.0 - frld(ji,jj)) * rhoic * hicif(ji,jj)   ! snow/ice mass
+            
+            !  the lead fraction, frld, must be little than or equal to amax (ice ridging).
+            zthsnice      = hsnif(ji,jj) + hicif(ji,jj)
+            zindb         = tms(ji,jj) * ( 1.0 - MAX( rzero , SIGN( rone , - zthsnice ) ) ) 
+            za            = zindb * MIN( rone, ( 1.0 - frld(ji,jj) ) * uscomi )
+            hsnif (ji,jj) = hsnif(ji,jj)  * za
+            hicif (ji,jj) = hicif(ji,jj)  * za
+            qstoif(ji,jj) = qstoif(ji,jj) * za
+            frld  (ji,jj) = 1.0 - zindb * ( 1.0 - frld(ji,jj) ) / MAX( za, epsi20 )
+            
+            !  the in situ ice thickness, hicif, must be equal to or greater than hiclim.
+            zh            = MAX( rone , zindb * hiclim  / MAX( hicif(ji,jj), epsi20 ) )
+            hsnif (ji,jj) = hsnif(ji,jj)  * zh
+            hicif (ji,jj) = hicif(ji,jj)  * zh
+            qstoif(ji,jj) = qstoif(ji,jj) * zh
+            frld  (ji,jj) = ( frld(ji,jj) + ( zh - 1.0 ) ) / zh
+         END DO
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl( tab2d_1=hicif , clinfo1=' lim_thd: hicif   : ' )
+         CALL prt_ctl( tab2d_1=hsnif , clinfo1=' lim_thd: hsnif   : ' )
+         CALL prt_ctl( tab2d_1=dmgwi , clinfo1=' lim_thd: dmgwi   : ' )
+         CALL prt_ctl( tab2d_1=qstoif, clinfo1=' lim_thd: qstoif  : ' )
+         CALL prt_ctl( tab2d_1=frld  , clinfo1=' lim_thd: frld    : ' )
+      ENDIF
+
+      
+      !-------------------------------!
+      !   Thermodynamics of sea ice   !
+      !-------------------------------!
+      
+      !      Partial computation of forcing for the thermodynamic sea ice model.
+      !--------------------------------------------------------------------------
+
+      sst_m(:,:) = sst_m(:,:) + rt0
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            zthsnice       = hsnif(ji,jj) + hicif(ji,jj)
+            zindb          = tms(ji,jj) * ( 1.0 - MAX( rzero , SIGN( rone , - zthsnice ) ) ) 
+            pfrld(ji,jj)   = frld(ji,jj)
+            zfricp         = 1.0 - frld(ji,jj)
+            zinda          = 1.0 - MAX( rzero , SIGN( rone , - zfricp ) )
+            
+            !  solar irradiance transmission at the mixed layer bottom and used in the lead heat budget
+            thcm(ji,jj)    = 0.e0 
+            
+            !  net downward heat flux from the ice to the ocean, expressed as a function of ocean 
+            !  temperature and turbulent mixing (McPhee, 1992)
+            zfric_u        = MAX ( MIN( SQRT( ust2s(ji,jj) ) , zfric_umax ) , zfric_umin )  ! friction velocity
+            fdtcn(ji,jj)  = zindb * rau0 * rcp * 0.006  * zfric_u * ( sst_m(ji,jj) - tfu(ji,jj) ) 
+            qdtcn(ji,jj)  = zindb * fdtcn(ji,jj) * frld(ji,jj) * rdt_ice
+                        
+            !  partial computation of the lead energy budget (qldif)
+#if defined key_coupled 
+            qldif(ji,jj)   = tms(ji,jj) * rdt_ice                                             &
+               &    * (   ( qsr_tot(ji,jj) - qsr_ice(ji,jj,1) * zfricp ) * ( 1.0 - thcm(ji,jj) )   &
+               &        + ( qns_tot(ji,jj) - qns_ice(ji,jj,1) * zfricp )                           &
+               &        + frld(ji,jj) * ( fdtcn(ji,jj) + ( 1.0 - zindb ) * fsbbq(ji,jj) )   )
+#else
+            zfontn         = ( sprecip(ji,jj) / rhosn ) * xlsn  !   energy for melting solid precipitation
+            zfnsol         = qns(ji,jj)                         !  total non solar flux over the ocean
+            qldif(ji,jj)   = tms(ji,jj) * ( qsr(ji,jj) * ( 1.0 - thcm(ji,jj) )   &
+               &                               + zfnsol + fdtcn(ji,jj) - zfontn     &
+               &                               + ( 1.0 - zindb ) * fsbbq(ji,jj) )   &
+               &                        * frld(ji,jj) * rdt_ice    
+!!$            qldif(ji,jj)   = tms(ji,jj) * rdt_ice * frld(ji,jj) 
+!!$               &           * ( qsr(ji,jj) * ( 1.0 - thcm(ji,jj) )      &
+!!$               &             + qns(ji,jj)  + fdtcn(ji,jj) - zfontn     &
+!!$               &             + ( 1.0 - zindb ) * fsbbq(ji,jj)      )   &
+#endif
+            !  parlat : percentage of energy used for lateral ablation (0.0) 
+            zfntlat        = 1.0 - MAX( rzero , SIGN( rone ,  - qldif(ji,jj) ) )
+            zpareff        = 1.0 + ( parlat - 1.0 ) * zinda * zfntlat
+            zqlbsbq(ji,jj) = qldif(ji,jj) * ( 1.0 - zpareff ) / MAX( (1.0 - frld(ji,jj)) * rdt_ice , epsi16 )
+            qldif  (ji,jj) = zpareff *  qldif(ji,jj)
+            qdtcn  (ji,jj) = zpareff * qdtcn(ji,jj)
+            
+            !  energy needed to bring ocean surface layer until its freezing
+            qcmif  (ji,jj) =  rau0 * rcp * fse3t_m(ji,jj,1)   &
+                &          * ( tfu(ji,jj) - sst_m(ji,jj) ) * ( 1 - zinda )
+            
+            !  calculate oceanic heat flux.
+            fbif   (ji,jj) = zindb * (  fsbbq(ji,jj) / MAX( (1.0 - frld(ji,jj)) , epsi20 ) + fdtcn(ji,jj) )
+            
+            ! computation of the thermodynamic ice production (only needed for output)
+            hicifp(ji,jj) = hicif(ji,jj) * ( 1.0 - frld(ji,jj) )
+         END DO
+      END DO
+      
+      sst_m(:,:) = sst_m(:,:) - rt0
+               
+      !         Select icy points and fulfill arrays for the vectorial grid.
+      !----------------------------------------------------------------------
+      nbpb = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( frld(ji,jj) < 1.0 ) THEN     
+               nbpb      = nbpb + 1
+               npb(nbpb) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=pfrld, clinfo1=' lim_thd: pfrld   : ', tab2d_2=thcm   , clinfo2='  thcm    : ')
+         CALL prt_ctl(tab2d_1=fdtcn, clinfo1=' lim_thd: fdtcn   : ', tab2d_2=qdtcn  , clinfo2='  qdtcn   : ')
+         CALL prt_ctl(tab2d_1=qldif, clinfo1=' lim_thd: qldif   : ', tab2d_2=zqlbsbq, clinfo2='  zqlbsbq : ')
+         CALL prt_ctl(tab2d_1=qcmif, clinfo1=' lim_thd: qcmif   : ', tab2d_2=fbif   , clinfo2='  fbif    : ')
+         zmsk(:,:,1) = tms(:,:)
+         CALL prt_ctl(tab2d_1=qcmif , clinfo1=' lim_thd: qcmif  : ', mask1=zmsk)
+         CALL prt_ctl(tab2d_1=hicifp, clinfo1=' lim_thd: hicifp : ')
+         WRITE(charout, FMT="('lim_thd: nbpb = ',I4)") nbpb
+         CALL prt_ctl_info(charout)
+      ENDIF
+      
+      
+      ! If there is no ice, do nothing. Otherwise, compute Top and Bottom accretion/ablation 
+      !------------------------------------------------------------------------------------ 
+
+      IF( nbpb > 0 ) THEN
+         !    
+         !  put the variable in a 1-D array for thermodynamics process
+         CALL tab_2d_1d_2( nbpb, frld_1d    (1:nbpb)     , frld           , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, h_ice_1d   (1:nbpb)     , hicif          , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, h_snow_1d  (1:nbpb)     , hsnif          , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, sist_1d    (1:nbpb)     , sist           , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 1 ), tbif(:,:,1)    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 2 ), tbif(:,:,2)    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 3 ), tbif(:,:,3)    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qsr_ice_1d (1:nbpb)     , qsr_ice(:,:,1) , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, fr1_i0_1d  (1:nbpb)     , fr1_i0         , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, fr2_i0_1d  (1:nbpb)     , fr2_i0         , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb,  qns_ice_1d(1:nbpb)     ,  qns_ice(:,:,1), jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, dqns_ice_1d(1:nbpb)     , dqns_ice(:,:,1), jpi, jpj, npb(1:nbpb) )
+         IF( .NOT. lk_cpl ) THEN 
+            CALL tab_2d_1d_2( nbpb, qla_ice_1d (1:nbpb)     ,  qla_ice(:,:,1), jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d_2( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice(:,:,1), jpi, jpj, npb(1:nbpb) )
+         ENDIF
+         CALL tab_2d_1d_2( nbpb, tfu_1d     (1:nbpb)     , tfu        , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, sprecip_1d (1:nbpb)     , sprecip    , jpi, jpj, npb(1:nbpb) ) 
+         CALL tab_2d_1d_2( nbpb, fbif_1d    (1:nbpb)     , fbif       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, thcm_1d    (1:nbpb)     , thcm       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qldif_1d   (1:nbpb)     , qldif      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qstbif_1d  (1:nbpb)     , qstoif     , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, rdmicif_1d (1:nbpb)     , rdmicif    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, dmgwi_1d   (1:nbpb)     , dmgwi      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qlbbq_1d   (1:nbpb)     , zqlbsbq    , jpi, jpj, npb(1:nbpb) )
+         !
+         CALL lim_thd_zdf_2( 1, nbpb )       !  compute ice growth
+         !
+         !  back to the geographic grid.
+         CALL tab_1d_2d_2( nbpb, frld       , npb, frld_1d   (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, hicif      , npb, h_ice_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, hsnif      , npb, h_snow_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, sist       , npb, sist_1d   (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,1), npb, tbif_1d   (1:nbpb , 1 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,2), npb, tbif_1d   (1:nbpb , 2 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,3), npb, tbif_1d   (1:nbpb , 3 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, fscmbq     , npb, fscbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, ffltbif    , npb, fltbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, fstric     , npb, fstbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qldif      , npb, qldif_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qfvbq      , npb, qfvbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qstoif     , npb, qstbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdmicif    , npb, rdmicif_1d(1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, dmgwi      , npb, dmgwi_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdmsnif    , npb, rdmsnif_1d(1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, zdvosif    , npb, dvsbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, zdvobif    , npb, dvbbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, zdvomif    , npb, rdvomif_1d(1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, zdvolif    , npb, dvlbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, zdvonif    , npb, dvnbq_1d  (1:nbpb)     , jpi, jpj ) 
+         CALL tab_1d_2d_2( nbpb, qsr_ice(:,:,1), npb, qsr_ice_1d(1:nbpb)  , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qns_ice(:,:,1), npb, qns_ice_1d(1:nbpb)  , jpi, jpj )
+         IF( .NOT. lk_cpl )   CALL tab_1d_2d_2( nbpb, qla_ice(:,:,1), npb, qla_ice_1d(1:nbpb)  , jpi, jpj )
+         !
+      ENDIF
+
+      ! Up-date sea ice thickness
+      !--------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            phicif(ji,jj) = hicif(ji,jj)  
+            hicif(ji,jj)  = hicif(ji,jj) *  ( rone -  MAX( rzero, SIGN( rone, - ( 1.0 - frld(ji,jj) ) ) ) )
+         END DO
+      END DO
+
+      
+      ! Tricky trick : add 2 to frld in the Southern Hemisphere
+      !--------------------------------------------------------
+      IF( fcor(1,1) < 0.e0 ) THEN
+         DO jj = 1, njeqm1
+            DO ji = 1, jpi
+               frld(ji,jj) = frld(ji,jj) + 2.0
+            END DO
+         END DO
+      ENDIF
+      
+      
+      ! Select points for lateral accretion (this occurs when heat exchange
+      ! between ice and ocean is negative; ocean losing heat) 
+      !-----------------------------------------------------------------
+      nbpac = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+!i yes!     IF ( ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+            IF ( tms(ji,jj) * ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+               nbpac = nbpac + 1
+               npac( nbpac ) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+      
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=phicif, clinfo1=' lim_thd: phicif  : ', tab2d_2=hicif, clinfo2=' hicif : ')
+         WRITE(charout, FMT="('lim_thd: nbpac = ',I4)") nbpac
+         CALL prt_ctl_info(charout)
+      ENDIF
+
+
+      ! If ocean gains heat do nothing ; otherwise, one performs lateral accretion
+      !--------------------------------------------------------------------------------
+      IF( nbpac > 0 ) THEN
+         !
+         zlicegr(:,:) = rdmicif(:,:)		! to output the lateral sea-ice growth 
+         !...Put the variable in a 1-D array for lateral accretion
+         CALL tab_2d_1d_2( nbpac, frld_1d   (1:nbpac)     , frld       , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, h_snow_1d (1:nbpac)     , hsnif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, h_ice_1d  (1:nbpac)     , hicif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 1 ), tbif(:,:,1), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 2 ), tbif(:,:,2), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 3 ), tbif(:,:,3), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, qldif_1d  (1:nbpac)     , qldif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, qcmif_1d  (1:nbpac)     , qcmif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, qstbif_1d (1:nbpac)     , qstoif     , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, rdmicif_1d(1:nbpac)     , rdmicif    , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, dvlbq_1d  (1:nbpac)     , zdvolif    , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, tfu_1d    (1:nbpac)     , tfu        , jpi, jpj, npac(1:nbpac) )
+         !
+         CALL lim_thd_lac_2( 1 , nbpac )         ! lateral accretion routine.
+         !
+         !   back to the geographic grid
+         CALL tab_1d_2d_2( nbpac, frld       , npac(1:nbpac), frld_1d   (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, hsnif      , npac(1:nbpac), h_snow_1d (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, hicif      , npac(1:nbpac), h_ice_1d  (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,1), npac(1:nbpac), tbif_1d   (1:nbpac , 1 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,2), npac(1:nbpac), tbif_1d   (1:nbpac , 2 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,3), npac(1:nbpac), tbif_1d   (1:nbpac , 3 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, qstoif     , npac(1:nbpac), qstbif_1d (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, rdmicif    , npac(1:nbpac), rdmicif_1d(1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, zdvolif    , npac(1:nbpac), dvlbq_1d  (1:nbpac)     , jpi, jpj )
+         !
+      ENDIF
+       
+       
+      ! Recover frld values between 0 and 1 in the Southern Hemisphere (tricky trick)
+      ! Update daily thermodynamic ice production.    
+      !------------------------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            frld  (ji,jj) = MIN( frld(ji,jj), ABS( frld(ji,jj) - 2.0 ) )
+            fr_i  (ji,jj) = 1.0 - frld(ji,jj)  
+            hicifp(ji,jj) = hicif(ji,jj) * fr_i(ji,jj) - hicifp(ji,jj)
+         END DO
+      END DO
+
+      ! Outputs
+      !--------------------------------------------------------------------------------
+      ztmp(:,:) = 1. - pfrld(:,:)                                ! fraction of ice after the dynamic, before the thermodynamic
+      CALL iom_put( 'ioceflxb', fbif )                           ! Oceanic flux at the ice base           [W/m2 ???]
+      CALL iom_put( 'ist_cea', (sist(:,:) - rt0) * ztmp(:,:) )   ! Ice surface temperature                [Celius]
+      CALL iom_put( 'qsr_ai_cea', qsr_ice(:,:,1) * ztmp(:,:) )   ! Solar flux over the ice                [W/m2]
+      CALL iom_put( 'qns_ai_cea', qns_ice(:,:,1) * ztmp(:,:) )   ! Non-solar flux over the ice            [W/m2]
+      IF( .NOT. lk_cpl )   CALL iom_put( 'qla_ai_cea', qla_ice(:,:,1) * ztmp(:,:) )     ! Latent flux over the ice  [W/m2]
+      !
+      CALL iom_put( 'snowthic_cea', hsnif  (:,:) * fr_i(:,:) )   ! Snow thickness             [m]
+      CALL iom_put( 'icethic_cea' , hicif  (:,:) * fr_i(:,:) )   ! Ice thickness              [m]
+      zztmp = 1.0 / rdt_ice
+      CALL iom_put( 'iceprod_cea' , hicifp (:,:) * zztmp     )   ! Ice produced               [m/s]
+      IF( lk_diaar5 ) THEN
+         CALL iom_put( 'snowmel_cea' , rdmsnif(:,:) * zztmp     )   ! Snow melt                  [kg/m2/s]
+         zztmp = rhoic / rdt_ice
+         CALL iom_put( 'sntoice_cea' , zdvonif(:,:) * zztmp     )   ! Snow to Ice transformation [kg/m2/s]
+         CALL iom_put( 'ticemel_cea' , zdvosif(:,:) * zztmp     )   ! Melt at Sea Ice top        [kg/m2/s]
+         CALL iom_put( 'bicemel_cea' , zdvomif(:,:) * zztmp     )   ! Melt at Sea Ice bottom     [kg/m2/s]
+         zlicegr(:,:) = MAX( 0.e0, rdmicif(:,:)-zlicegr(:,:) )
+         CALL iom_put( 'licepro_cea' , zlicegr(:,:) * zztmp     )   ! Latereal sea ice growth    [kg/m2/s]
+      ENDIF
+      !
+      ! Compute the Eastward & Northward sea-ice transport
+      zztmp = 0.25 * rhoic
+      DO jj = 1, jpjm1 
+         DO ji = 1, jpim1   ! NO vector opt.
+            ! Ice velocities, volume & transport at U & V-points
+            zuice_m = u_ice(ji+1,jj+1) + u_ice(ji+1,jj )
+            zvice_m = v_ice(ji+1,jj+1) + v_ice(ji ,jj+1)
+            zhice_u = hicif(ji,jj)*e2t(ji,jj)*fr_i(ji,jj) + hicif(ji+1,jj  )*e2t(ji+1,jj  )*fr_i(ji+1,jj  )
+            zhice_v = hicif(ji,jj)*e1t(ji,jj)*fr_i(ji,jj) + hicif(ji  ,jj+1)*e1t(ji  ,jj+1)*fr_i(ji  ,jj+1)
+            zu_imasstr(ji,jj) = zztmp * zhice_u * zuice_m 
+            zv_imasstr(ji,jj) = zztmp * zhice_v * zvice_m 
+         END DO
+      END DO
+      CALL lbc_lnk( zu_imasstr, 'U', -1. )   ;   CALL lbc_lnk( zv_imasstr, 'V', -1. )
+      CALL iom_put( 'u_imasstr',  zu_imasstr(:,:) )   ! Ice transport along i-axis at U-point [kg/s] 
+      CALL iom_put( 'v_imasstr',  zv_imasstr(:,:) )   ! Ice transport along j-axis at V-point [kg/s] 
+
+      !! Fram Strait sea-ice transport (sea-ice + snow)  (in ORCA2 = 5 points)
+      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
+         DO jj = mj0(137), mj1(137) ! B grid
+            IF( mj0(jj-1) >= nldj ) THEN
+               DO ji = MAX(mi0(134),nldi), MIN(mi1(138),nlei)
+                  zrhoij    = e1t(ji,jj  ) * fr_i(ji,jj  ) * ( rhoic*hicif(ji,jj  ) + rhosn*hsnif(ji,jj  ) ) 
+                  zrhoijm1  = e1t(ji,jj-1) * fr_i(ji,jj-1) * ( rhoic*hicif(ji,jj-1) + rhosn*hsnif(ji,jj-1) ) 
+                  ztr_fram  = ztr_fram - 0.25 * ( v_ice(ji,jj)+ v_ice(ji+1,jj) ) * ( zrhoij + zrhoijm1 )
+               END DO
+            ENDIF
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztr_fram )
+         CALL iom_put( 'fram_trans', ztr_fram )   ! Ice transport through Fram strait     [kg/s] 
+      ENDIF
+
+      ztmp(:,:) = 1. - AINT( frld(:,:), wp )                        ! return 1 as soon as there is ice
+      CALL iom_put( 'ice_pres'  , ztmp                            )   ! Ice presence                          [-]
+      CALL iom_put( 'ist_ipa'   , ( sist(:,:) - rt0 ) * ztmp(:,:) )   ! Ice surface temperature               [Celius]
+      CALL iom_put( 'uice_ipa'  ,  u_ice(:,:)         * ztmp(:,:) )   ! Ice velocity along i-axis at I-point  [m/s] 
+      CALL iom_put( 'vice_ipa'  ,  v_ice(:,:)         * ztmp(:,:) )   ! Ice velocity along j-axis at I-point  [m/s]
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl_info(' lim_thd  end  ')
+         CALL prt_ctl( tab2d_1=hicif      , clinfo1=' lim_thd: hicif   : ', tab2d_2=hsnif , clinfo2=' hsnif  : ' )
+         CALL prt_ctl( tab2d_1=frld       , clinfo1=' lim_thd: frld    : ', tab2d_2=hicifp, clinfo2=' hicifp : ' )
+         CALL prt_ctl( tab2d_1=phicif     , clinfo1=' lim_thd: phicif  : ', tab2d_2=pfrld , clinfo2=' pfrld  : ' )
+         CALL prt_ctl( tab2d_1=sist       , clinfo1=' lim_thd: sist    : ' )
+         CALL prt_ctl( tab2d_1=tbif(:,:,1), clinfo1=' lim_thd: tbif 1  : ' )
+         CALL prt_ctl( tab2d_1=tbif(:,:,2), clinfo1=' lim_thd: tbif 2  : ' )
+         CALL prt_ctl( tab2d_1=tbif(:,:,3), clinfo1=' lim_thd: tbif 3  : ' )
+         CALL prt_ctl( tab2d_1=fdtcn      , clinfo1=' lim_thd: fdtcn   : ', tab2d_2=qdtcn , clinfo2=' qdtcn  : ' )
+         CALL prt_ctl( tab2d_1=qstoif     , clinfo1=' lim_thd: qstoif  : ', tab2d_2=fsbbq , clinfo2=' fsbbq  : ' )
+      ENDIF
+       !
+    END SUBROUTINE lim_thd_2
+
+
+    SUBROUTINE lim_thd_init_2
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_init_2 *** 
+      !!                 
+      !! ** Purpose :   Physical constants and parameters linked to the ice 
+      !!      thermodynamics
+      !!
+      !! ** Method  :   Read the namicethd namelist and check the ice-thermo
+      !!       parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicether
+      !!-------------------------------------------------------------------
+      NAMELIST/namicethd/ hmelt , hiccrit, hicmin, hiclim, amax  ,        &
+         &                swiqst, sbeta  , parlat, hakspl, hibspl, exld,  &
+         &                hakdif, hnzst  , thth  , parsub, alphs
+      !!-------------------------------------------------------------------
+      !
+      REWIND( numnam_ice )                  ! read namelist
+      READ  ( numnam_ice , namicethd )
+      IF( lk_cpl .AND. parsub /= 0.0 )   CALL ctl_stop( 'In coupled mode, use parsub = 0. or send dqla' )
+      !
+      IF(lwp) THEN                          ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)'lim_thd_init_2: ice parameters for ice thermodynamic computation '
+         WRITE(numout,*)'~~~~~~~~~~~~~~'
+         WRITE(numout,*)'       maximum melting at the bottom                           hmelt        = ', hmelt
+         WRITE(numout,*)'       ice thick. for lateral accretion in NH (SH)             hiccrit(1/2) = ', hiccrit
+         WRITE(numout,*)'       ice thick. corr. to max. energy stored in brine pocket  hicmin       = ', hicmin  
+         WRITE(numout,*)'       minimum ice thickness                                   hiclim       = ', hiclim 
+         WRITE(numout,*)'       maximum lead fraction                                   amax         = ', amax 
+         WRITE(numout,*)'       energy stored in brine pocket (=1) or not (=0)          swiqst       = ', swiqst 
+         WRITE(numout,*)'       numerical carac. of the scheme for diffusion in ice '
+         WRITE(numout,*)'       Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)   sbeta        = ', sbeta
+         WRITE(numout,*)'       percentage of energy used for lateral ablation          parlat       = ', parlat
+         WRITE(numout,*)'       slope of distr. for Hakkinen-Mellor lateral melting     hakspl       = ', hakspl  
+         WRITE(numout,*)'       slope of distribution for Hibler lateral melting        hibspl       = ', hibspl
+         WRITE(numout,*)'       exponent for leads-closure rate                         exld         = ', exld
+         WRITE(numout,*)'       coefficient for diffusions of ice and snow              hakdif       = ', hakdif
+         WRITE(numout,*)'       threshold thick. for comp. of eq. thermal conductivity  zhth         = ', thth 
+         WRITE(numout,*)'       thickness of the surf. layer in temp. computation       hnzst        = ', hnzst
+         WRITE(numout,*)'       switch for snow sublimation  (=1) or not (=0)           parsub       = ', parsub  
+         WRITE(numout,*)'       coefficient for snow density when snow ice formation    alphs        = ', alphs
+      ENDIF
+      !          
+      uscomi = 1.0 / ( 1.0 - amax )   ! inverse of minimum lead fraction
+      rcdsn = hakdif * rcdsn 
+      rcdic = hakdif * rcdic
+      !
+      IF( hsndif > 100.e0 .OR. hicdif > 100.e0 ) THEN
+         cnscg = 0.e0
+      ELSE
+         cnscg = rcpsn / rcpic   ! ratio  rcpsn/rcpic
+      ENDIF
+      !
+   END SUBROUTINE lim_thd_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd_2         ! Dummy routine
+   END SUBROUTINE lim_thd_2
+#endif
+
+   !!======================================================================
+END MODULE limthd_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_lac_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 1844)
@@ -0,0 +1,231 @@
+MODULE limthd_lac_2
+#if defined key_lim2
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac_2   ***
+   !!                lateral thermodynamic growth of the ice 
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   lim_lat_acr_2    : lateral accretion of ice
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst
+   USE thd_ice_2
+   USE ice_2
+   USE limistate_2 
+     
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_lac_2   ! called by lim_thd_2
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1.e-20  ,  &
+      epsi13 = 1.e-13  ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+    
+   SUBROUTINE lim_thd_lac_2( kideb, kiut )
+      !!-------------------------------------------------------------------
+      !!               ***   ROUTINE lim_thd_lac_2  ***
+      !!  
+      !! ** Purpose : Computation of the evolution of the ice thickness and 
+      !!      concentration as a function of the heat balance in the leads.
+      !!      It is only used for lateral accretion
+      !!       
+      !! ** Method  : Ice is formed in the open water when ocean lose heat
+      !!      (heat budget of open water Bl is negative) .
+      !!      Computation of the increase of 1-A (ice concentration) fol-
+      !!      lowing the law :
+      !!      (dA/dt)acc = F[ (1-A)/(1-a) ] * [ Bl / (Li*h0) ]
+      !!       where - h0 is the thickness of ice created in the lead
+      !!             - a is a minimum fraction for leads
+      !!             - F is a monotonic non-increasing function defined as:
+      !!                  F(X)=( 1 - X**exld )**(1.0/exld)
+      !!             - exld is the exponent closure rate (=2 default val.)
+      !! 
+      !! ** Action : - Adjustment of snow and ice thicknesses and heat
+      !!                content in brine pockets
+      !!             - Updating ice internal temperature
+      !!             - Computation of variation of ice volume and mass
+      !!             - Computation of frldb after lateral accretion and 
+      !!               update h_snow_1d, h_ice_1d and tbif_1d(:,:)      
+      !! 
+      !! ** References :
+      !!      M. Maqueda, 1995, PhD Thesis, Univesidad Complutense Madrid
+      !!      Fichefet T. and M. Maqueda 1997, J. Geo. Res., 102(C6), 
+      !!                                                12609 -12646   
+      !! History :
+      !!   1.0  !  01-04 (LIM)  original code
+      !!   2.0  !  02-08 (C. Ethe, G. Madec)  F90, mpp
+      !!-------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT(IN)::  &
+         kideb          ,   &  ! start point on which the the computation is applied
+         kiut                  ! end point on which the the computation is applied
+
+      !! * Local variables
+      INTEGER ::            &
+         ji             ,   &  !  dummy loop indices
+         iicefr         ,   &  !  1 = existing ice ; 0 = no ice
+         iiceform       ,   &  !  1 = ice formed   ; 0 = no ice formed
+         ihemis                !  dummy indice
+      REAL(wp), DIMENSION(jpij) :: &
+         zqbgow           ,  &  !  heat budget of the open water (negative)
+         zfrl_old         ,  &  !  previous sea/ice fraction
+         zhice_old        ,  &  !  previous ice thickness
+         zhice0           ,  &  !  thickness of newly formed ice in leads
+         zfrlmin          ,  &  !  minimum fraction for leads
+         zdhicbot               !  part of thickness of newly formed ice in leads which 
+                                !  has been already used in transport for example
+      REAL(wp)  ::  &
+         zhemis           ,  &  !  hemisphere (0 = North, 1 = South)
+         zhicenew         ,  &  !  new ice thickness
+         zholds2          ,  &  !  ratio of previous ice thickness and 2 
+         zhnews2          ,  &  !  ratio of new ice thickness and 2 
+         zfrlnew          ,  &  !  new sea/ice fraction
+         zfrld            ,  &  !  ratio of sea/ice fraction and minimum fraction for leads
+         zfrrate          ,  &  !  leads-closure rate
+         zdfrl                  !  sea-ice fraction increment
+      REAL(wp)  ::  &
+         zdh1 , zdh2 , zdh3 , zdh4, zdh5   , &   ! tempory scalars
+         ztint , zta1 , zta2 , zta3 , zta4 , &
+         zah, zalpha , zbeta
+      !!---------------------------------------------------------------------      
+                   
+      !--------------------------------------------------------------
+      !   Computation of the heat budget of the open water (negative)
+      !--------------------------------------------------------------
+      
+      DO ji = kideb , kiut      
+         zqbgow(ji) = qldif_1d(ji) - qcmif_1d(ji)
+      END DO
+      
+      !-----------------------------------------------------------------
+      !   Taking the appropriate values for the corresponding hemisphere
+      !-----------------------------------------------------------------
+      DO ji = kideb , kiut
+         zhemis       = MAX( zzero , SIGN( zone , frld_1d(ji) - 2.0 ) ) 
+         ihemis       = INT( 1 + zhemis )
+         zhice0  (ji) = hiccrit( ihemis ) 
+         zfrlmin (ji) = acrit  ( ihemis )   
+         frld_1d (ji) = frld_1d(ji) - 2.0 * zhemis
+         zfrl_old(ji) = frld_1d(ji)
+      END DO
+      
+      !-------------------------------------------------------------------
+      !     Lateral Accretion (modification of the fraction of open water)
+      !     The ice formed in the leads has always a thickness zhice0, but
+      !     only a fraction zfrrate of the ice formed contributes to the 
+      !     increase of the ice fraction. The remaining part (1-zfrrate)
+      !     is rather assumed to lead to an increase in the thickness of the
+      !     pre-existing ice (transport for example). 
+      !     Morales Maqueda, 1995 - Fichefet and Morales Maqueda, 1997
+      !---------------------------------------------------------------------
+      
+!CDIR NOVERRCHK
+      DO ji = kideb , kiut
+         iicefr       = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         !---computation of the leads-closure rate
+         zfrld        = MIN( zone , ( 1.0 - frld_1d(ji) ) / ( 1.0 - zfrlmin(ji) ) )
+         zfrrate      = ( 1.0 - zfrld**exld )**( 1.0 / exld )
+         !--computation of the sea-ice fraction increment and the new fraction 
+         zdfrl        = ( zfrrate / zhice0(ji) )  * ( zqbgow(ji) / xlic )
+         zfrlnew      = zfrl_old(ji) + zdfrl
+         !--update the sea-ice fraction 
+         frld_1d   (ji) = MAX( zfrlnew , zfrlmin(ji) )
+         !--computation of the remaining part of ice thickness which has been already used
+         zdhicbot(ji) =  ( frld_1d(ji) - zfrlnew ) * zhice0(ji) / ( 1.0 - zfrlmin(ji) ) & 
+                      -  (  ( 1.0 - zfrrate ) / ( 1.0 - frld_1d(ji) ) )  * ( zqbgow(ji) / xlic ) 
+      END DO
+ 
+      !----------------------------------------------------------------------------------------
+      !      Ajustement of snow and ice thicknesses and updating the total heat stored in brine pockets  
+      !      The thickness of newly formed ice is averaged with that of the pre-existing
+      !         (1-Anew) * hinew = (1-Aold) * hiold + ((1-Anew)-(1-Aold)) * h0
+      !      Snow is distributed over the new ice-covered area 
+      !         (1-Anew) * hsnew = (1-Aold) * hsold            
+      !--------------------------------------------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         iicefr       = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         zhice_old(ji) = h_ice_1d(ji)
+         zhicenew      = iicefr * zhice_old(ji) + ( 1 - iicefr ) * zhice0(ji)
+         zalpha        = ( 1. - zfrl_old(ji) ) / ( 1.- frld_1d(ji) )
+         h_snow_1d(ji) = zalpha * h_snow_1d(ji)
+         h_ice_1d (ji) = zalpha * zhicenew + ( 1.0 - zalpha ) * zhice0(ji)
+         qstbif_1d(ji) = zalpha * qstbif_1d(ji) 
+      END DO
+      
+      !-------------------------------------------------------
+      !   Ajustement of ice internal temperatures
+      !-------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         iicefr      = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         iiceform    = 1 - MAX( 0 ,INT( SIGN( 1.5 * zone , zhice0(ji) - h_ice_1d(ji) ) ) )
+         zholds2     = zhice_old(ji)/ 2.
+         zhnews2     = h_ice_1d(ji) / 2.
+         zdh1        = MAX( zzero ,  zhice_old(ji)   - zhnews2 )
+         zdh2        = MAX( zzero , -zhice_old(ji)   + zhnews2 )
+         zdh3        = MAX( zzero ,  h_ice_1d(ji) - zholds2 )
+         zdh4        = MAX( zzero , -h_ice_1d(ji) + zholds2 )
+         zdh5        = MAX( zzero , zhice0(ji)      - zholds2 )
+         ztint       =       iiceform   * (  ( zholds2 - zdh3 ) * tbif_1d(ji,3) + zdh4 * tbif_1d(ji,2) )      &
+            &                           / MAX( epsi20 , h_ice_1d(ji) - zhice0(ji) )                           &
+            &                 + ( 1 - iiceform ) * tfu_1d(ji)
+         zta1        = iicefr * ( 1.  - zfrl_old(ji) ) * tbif_1d(ji,2) 
+         zta2        = iicefr * ( 1.  - zfrl_old(ji) ) * tbif_1d(ji,3)
+         zta3        = iicefr * ( 1.  - zfrl_old(ji) ) * ztint
+         zta4        = ( zfrl_old(ji) - frld_1d   (ji) ) * tfu_1d(ji)
+         zah         = ( 1. - frld_1d(ji) ) * zhnews2 
+
+         tbif_1d(ji,2) = (  MIN( zhnews2 , zholds2 )                                              * zta1   &
+            &          + ( 1 - iiceform ) * ( zholds2 - zdh1 )                                    * zta2   &
+            &          + ( iiceform * ( zhnews2 - zhice0(ji) + zdh5 ) + ( 1 - iiceform ) * zdh2 ) * zta3   & 
+            &          + MIN ( zhnews2 , zhice0(ji) )                                             * zta4   &
+            &          ) / zah
+         
+         tbif_1d(ji,3) =     (  iiceform * ( zhnews2 - zdh3 )                                          * zta1  &
+            &              + ( iiceform * zdh3 + ( 1 - iiceform ) * zdh1 )                             * zta2  &
+            &              + ( iiceform * ( zhnews2 - zdh5 ) + ( 1 - iiceform ) * ( zhnews2 - zdh1 ) ) * zta3  & 
+            &              + ( iiceform * zdh5 + ( 1 - iiceform ) * zhnews2 )                          * zta4  &
+            &            ) / zah
+         !---removing the remaining part of ice formed which has been already used
+         zbeta         = h_ice_1d(ji) / ( h_ice_1d(ji) + zdhicbot(ji) )
+         h_ice_1d(ji)  = h_ice_1d(ji) + zdhicbot(ji)
+         tbif_1d (ji,2)= zbeta * tbif_1d(ji,2) + ( 1.0 - zbeta ) * tbif_1d(ji,3)
+         tbif_1d (ji,3)= ( 2. * zbeta - 1.0 ) * tbif_1d(ji,3) + ( 2. * zdhicbot(ji) / h_ice_1d(ji) ) * tfu_1d(ji)
+         
+      END DO
+      
+      !-------------------------------------------------------------
+      !    Computation of variation of ice volume and ice mass 
+      !           Vold = (1-Aold) * hiold ; Vnew = (1-Anew) * hinew
+      !           dV = Vnew - Vold
+      !-------------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         dvlbq_1d  (ji) = ( 1. - frld_1d(ji) ) * h_ice_1d(ji) - ( 1. - zfrl_old(ji) ) * zhice_old(ji)
+         rdmicif_1d(ji) = rdmicif_1d(ji) + rhoic * dvlbq_1d(ji)
+      END DO
+      
+   END SUBROUTINE lim_thd_lac_2
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac_2   ***
+   !!                           no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_lac_2           ! Empty routine
+   END SUBROUTINE lim_thd_lac_2
+#endif
+END MODULE limthd_lac_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_zdf_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 1844)
@@ -0,0 +1,776 @@
+MODULE limthd_zdf_2
+   !!======================================================================
+   !!                       ***  MODULE limthd_zdf_2 ***
+   !!                thermodynamic growth and decay of the ice 
+   !!======================================================================
+   !! History :  1.0  !  01-04 (LIM) Original code
+   !!            2.0  !  02-08 (C. Ethe, G. Madec) F90
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_thd_zdf_2 : vertical accr./abl. and lateral ablation of sea ice
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst           ! ???
+   USE thd_ice_2
+   USE ice_2
+   USE limistate_2
+   USE in_out_manager
+   USE cpl_oasis3, ONLY : lk_cpl
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_thd_zdf_2        ! called by lim_thd_2
+
+   REAL(wp) ::   epsi20 = 1.e-20  ,  &  ! constant values
+      &          epsi13 = 1.e-13  ,  &
+      &          zzero  = 0.e0    ,  &
+      &          zone   = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_zdf_2( kideb , kiut )
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_zdf_2  ***
+      !!              
+      !! ** Purpose : This routine determines the time evolution of snow 
+      !!      and sea-ice thicknesses, concentration and heat content 
+      !!      due to the vertical and lateral thermodynamic accretion-
+      !!      ablation processes. One only treats the case of lat. abl.
+      !!      For lateral accretion, see routine lim_lat_accr 
+      !! 
+      !! ** Method  : The representation of vertical growth and decay of 
+      !!      the sea-ice model is based upon the diffusion of heat 
+      !!      through the external and internal boundaries of a 
+      !!      three-layer system (two layers of ice and one layer and 
+      !!      one layer of snow, if present, on top of the ice).
+      !! 
+      !! ** Action  : - Calculation of some intermediates variables
+      !!              - Calculation of surface temperature
+      !!              - Calculation of available heat for surface ablation
+      !!              - Calculation of the changes in internal temperature 
+      !!                of the three-layer system, due to vertical diffusion 
+      !!                processes
+      !!              - Performs surface ablation and bottom accretion-ablation
+      !!              - Performs snow-ice formation
+      !!              - Performs lateral ablation
+      !!
+      !! References : Fichefet T. and M. Maqueda 1997, J. Geophys. Res., 102(C6), 12609-12646   
+      !!              Fichefet T. and M. Maqueda 1999, Clim. Dyn, 15(4), 251-268  
+      !!------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kideb    ! Start point on which the  the computation is applied
+      INTEGER, INTENT(in) ::   kiut     ! End point on which the  the computation is applied
+      !!
+      INTEGER ::   ji       ! dummy loop indices
+      REAL(wp), DIMENSION(jpij,2) ::   zqcmlt        ! energy due to surface( /1 ) and bottom melting( /2 )
+      REAL(wp), DIMENSION(jpij) ::  &
+         ztsmlt      &    ! snow/ice surface melting temperature
+         ,ztbif      &    ! int. temp. at the mid-point of the 1st layer of the snow/ice sys. 
+         ,zksn       &    ! effective conductivity of snow
+         ,zkic       &    ! effective conductivity of ice
+         ,zksndh     &    ! thermal cond. at the mid-point of the 1st layer of the snow/ice sys. 
+         , zfcsu     &    ! conductive heat flux at the surface of the snow/ice system 
+         , zfcsudt   &    ! = zfcsu * dt
+         , zi0       &    ! frac. of the net SW rad. which is not absorbed at the surface
+         , z1mi0     &    ! fraction of the net SW radiation absorbed at the surface
+         , zqmax     &    ! maximum energy stored in brine pockets
+         , zrcpdt    &    ! h_su*rho_su*cp_su/dt(h_su being the thick. of surf. layer)
+         , zts_old   &    ! previous surface temperature
+         , zidsn , z1midsn , zidsnic ! tempory variables
+      REAL(wp), DIMENSION(jpij) ::   &
+          zfnet       &  ! net heat flux at the top surface( incl. conductive heat flux)
+          , zsprecip  &    ! snow accumulation
+          , zhsnw_old &    ! previous snow thickness
+          , zdhictop  &    ! change in ice thickness due to top surf ablation/accretion
+          , zdhicbot  &    ! change in ice thickness due to bottom surf abl/acc
+          , zqsup     &    ! energy transmitted to ocean (coming from top surf abl/acc)
+          , zqocea    &    ! energy transmitted to ocean (coming from bottom sur abl/acc)
+          , zfrl_old  &    ! previous sea/ice fraction
+          , zfrld_1d    &    ! new sea/ice fraction
+          , zep            ! internal temperature of the 2nd layer of the snow/ice system
+       REAL(wp), DIMENSION(3) :: & 
+          zplediag  &    ! principle diagonal, subdiag. and supdiag. of the 
+          , zsubdiag  &    ! tri-diagonal matrix coming from the computation
+          , zsupdiag  &    ! of the temperatures inside the snow-ice system
+          , zsmbr          ! second member
+       REAL(wp) :: & 
+          zhsu     &     ! thickness of surface layer
+          , zhe      &     ! effective thickness for compu. of equ. thermal conductivity
+          , zheshth  &     ! = zhe / thth
+          , zghe     &     ! correction factor of the thermal conductivity
+          , zumsb    &     ! parameter for numerical method to solve heat-diffusion eq.
+          , zkhsn    &     ! conductivity at the snow layer
+          , zkhic    &     ! conductivity at the ice layers
+          , zkint    &     ! equivalent conductivity at the snow-ice interface
+          , zkhsnint &     ! = zkint*dt / (hsn*rhosn*cpsn)  
+          , zkhicint &     ! = 2*zkint*dt / (hic*rhoic*cpic)
+          , zpiv1 , zpiv2  &       ! tempory scalars used to solve the tri-diagonal system
+          , zb2 , zd2 , zb3 , zd3 &
+          , ztint          ! equivalent temperature at the snow-ice interface
+       REAL(wp) :: & 
+          zexp      &     ! exponential function of the ice thickness
+          , zfsab     &     ! part of solar radiation stored in brine pockets
+          , zfts      &     ! value of energy balance function when the temp. equal surf. temp.
+          , zdfts     &     ! value of derivative of ztfs when the temp. equal surf. temp.
+          , zdts      &     ! surface temperature increment
+          , zqsnw_mlt &     ! energy needed to melt snow
+          , zdhsmlt   &     ! change in snow thickness due to melt
+          , zhsn      &     ! snow thickness (previous+accumulation-melt)
+          , zqsn_mlt_rem &  ! remaining heat coming from snow melting
+          , zqice_top_mlt & ! energy used to melt ice at top surface
+          , zdhssub      &  ! change in snow thick. due to sublimation or evaporation
+          , zdhisub      &  ! change in ice thick. due to sublimation or evaporation    
+          , zdhsn        &  ! snow ice thickness increment
+          , zdtsn        &  ! snow internal temp. increment
+          , zdtic        &  ! ice internal temp. increment
+          , zqnes          ! conductive energy due to ice melting in the first ice layer
+       REAL(wp) :: & 
+          ztbot     &      ! temperature at the bottom surface
+          , zfcbot    &      ! conductive heat flux at bottom surface
+          , zqice_bot &      ! energy used for bottom melting/growing
+          , zqice_bot_mlt &  ! energy used for bottom melting
+          , zqstbif_bot  &  ! part of energy stored in brine pockets used for bottom melting
+          , zqstbif_old  &  ! tempory var. for zqstbif_bot
+          , zdhicmlt      &  ! change in ice thickness due to bottom melting
+          , zdhicm        &  ! change in ice thickness var. 
+          , zdhsnm        &  ! change in snow thickness var. 
+          , zhsnfi        &  ! snow thickness var. 
+          , zc1, zpc1, zc2, zpc2, zp1, zp2 & ! tempory variables
+          , ztb2, ztb3
+       REAL(wp) :: & 
+          zdrmh         &   ! change in snow/ice thick. after snow-ice formation
+          , zhicnew       &   ! new ice thickness
+          , zhsnnew       &   ! new snow thickness
+          , zquot , ztneq &   ! tempory temp. variables
+          , zqice, zqicetot & ! total heat inside the snow/ice system
+          , zdfrl         &   ! change in ice concentration
+          , zdvsnvol      &   ! change in snow volume
+          , zdrfrl1, zdrfrl2 &  ! tempory scalars
+          , zihsn, zidhb, zihic, zihe, zihq, ziexp, ziqf, zihnf, zibmlt, ziqr, zihgnew, zind
+       !!----------------------------------------------------------------------
+
+       !-----------------------------------------------------------------------
+       !  1. Boundaries conditions for snow/ice system internal temperature
+       !       - If tbif_1d(ji,1) > rt0_snow, tbif_1d(ji,1) = rt0_snow 
+       !       - If tbif_1d(ji,2/3) > rt0_ice, tbif_1d(ji,2/3) = rt0_ice 
+       !     Computation of energies due to surface and bottom melting 
+       !-----------------------------------------------------------------------
+       
+       DO ji = kideb , kiut
+          zihsn = MAX( zzero , SIGN( zone , hsndif - h_snow_1d(ji) ) )
+          zihic = MAX( zzero , SIGN( zone , hicdif - h_ice_1d(ji) ) )
+          !--computation of energy due to surface melting
+          zqcmlt(ji,1) = ( MAX ( zzero ,  &
+             &                   rcpsn * h_snow_1d(ji) * ( tbif_1d(ji,1) - rt0_snow ) ) ) * ( 1.0 - zihsn )
+          !--computation of energy due to bottom melting
+          zqcmlt(ji,2) = ( MAX( zzero , &
+             &                  rcpic * ( tbif_1d(ji,2) - rt0_ice ) * ( h_ice_1d(ji) / 2. ) ) &
+             &           + MAX( zzero , &
+             &                  rcpic * ( tbif_1d(ji,3) - rt0_ice ) * ( h_ice_1d(ji) / 2. ) ) &
+             &           ) * ( 1.0 - zihic  )
+          !--limitation of  snow/ice system internal temperature
+          tbif_1d(ji,1)   = MIN( rt0_snow, tbif_1d(ji,1) )
+          tbif_1d(ji,2)   = MIN( rt0_ice , tbif_1d(ji,2) )
+          tbif_1d(ji,3)   = MIN( rt0_ice , tbif_1d(ji,3) )
+       END DO
+
+       !-------------------------------------------
+       !  2. Calculate some intermediate variables.  
+       !-------------------------------------------
+       
+       ! initialisation of the thickness of surface layer
+       zhsu = hnzst  
+
+       DO ji = kideb , kiut
+          zind   = MAX( zzero , SIGN( zone , zhsu - h_snow_1d(ji) ) )
+          zihsn  = MAX( zzero , SIGN( zone , hsndif - h_snow_1d(ji) ) )
+          zihsn  = MAX( zihsn , zind )
+          zihic  = MAX( zzero , sign( zone , hicdif - h_ice_1d(ji) ) )
+          !     2.1. Computation of surface melting temperature
+          !----------------------------------------------------
+          zind  = MAX( zzero , SIGN( zone , -h_snow_1d(ji) ) )
+          ztsmlt(ji) = ( 1.0 - zind ) * rt0_snow + zind * rt0_ice
+          !
+          !     2.2. Effective conductivity of snow and ice
+          !-----------------------------------------------
+
+          !---computation of the correction factor on the thermal conductivity
+          !-- (Morales Maqueda, 1995 ; Fichefet and Morales Maqueda, 1997)
+          zhe      =  ( rcdsn / ( rcdsn + rcdic ) ) * h_ice_1d(ji)   &
+             &     + ( rcdic / ( rcdsn + rcdic ) ) * h_snow_1d(ji) 
+          zihe     = MAX( zzero , SIGN( zone , 2.0 * zhe - thth ) )
+          zheshth  = zhe / thth
+          zghe     = ( 1.0 - zihe ) * zheshth * ( 2.0 - zheshth )   &
+             &     +         zihe   * 0.5 * ( 1.5 + LOG( 2.0 * zheshth ) )
+
+          !---effective conductivities 
+          zksn(ji)  = zghe * rcdsn  
+          zkic(ji)  = zghe * rcdic
+
+          !
+          !     2.3. Computation of the conductive heat flux from the snow/ice 
+          !          system interior toward the top surface
+          !------------------------------------------------------------------
+
+          !---Thermal conductivity at the mid-point of the first snow/ice system layer
+          zksndh(ji) =   ( ( 1.0 - zihsn ) * 2.0 * zksn(ji) + zihsn * 4.0 * zkic(ji) )   &
+             &         / ( ( 1.0 - zihsn ) *  h_snow_1d(ji)                              &
+             &           +        zihsn   *  ( ( 1.0 + 3.0 * zihic ) * h_ice_1d(ji)      &
+             &           + 4.0 * zkic(ji)/zksn(ji) * h_snow_1d(ji) ) )
+
+          !---internal temperature at the mid-point of the first snow/ice system layer
+          ztbif(ji)  = ( 1.0 - zihsn ) * tbif_1d(ji,1)                       &
+             &       +         zihsn   * ( ( 1.0 - zihic ) * tbif_1d(ji,2)   &
+             &       +         zihic   * tfu_1d(ji)   )
+          !---conductive heat flux 
+          zfcsu(ji) = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
+
+       END DO
+
+       !--------------------------------------------------------------------
+       !  3. Calculate : 
+       !     - fstbif_1d, part of solar radiation absorbing inside the ice
+       !       assuming an exponential absorption (Grenfell and Maykut, 1977)
+       !     - zqmax,  maximum energy stored in brine pockets
+       !     - qstbif_1d, total energy stored in brine pockets (updating)
+       !-------------------------------------------------------------------
+
+       DO ji = kideb , kiut
+          zihsn  = MAX( zzero , SIGN (zone , -h_snow_1d(ji) ) )
+          zihic  = MAX( zzero , 1.0 - ( h_ice_1d(ji) / zhsu ) )     
+          zind   = MAX( zzero , SIGN (zone , hicdif - h_ice_1d(ji) ) )
+          !--Computation of the fraction of the net shortwave radiation which
+          !--penetrates inside the ice cover ( See Forcat)
+          zi0(ji)  = zihsn * ( fr1_i0_1d(ji) + zihic * fr2_i0_1d(ji) )
+          zexp     = MIN( zone , EXP( -1.5 * ( h_ice_1d(ji) - zhsu ) ) )
+          fstbif_1d(ji) = zi0(ji) * qsr_ice_1d(ji) * zexp
+          !--Computation of maximum energy stored in brine pockets zqmax and update
+          !--the total energy stored in brine pockets, if less than zqmax
+          zqmax(ji) = MAX( zzero , 0.5 * xlic * ( h_ice_1d(ji) - hicmin ) )
+          zfsab   = zi0(ji) * qsr_ice_1d(ji) * ( 1.0 - zexp )
+          zihq    = ( 1.0 - zind ) * MAX(zzero, SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) ) &
+             &    +         zind   * zone
+          qstbif_1d(ji) = ( qstbif_1d(ji) + ( 1.0 - zihq ) * zfsab * rdt_ice ) * swiqst
+          !--fraction of shortwave radiation absorbed at surface
+          ziexp = zihq * zexp + ( 1.0 - zihq ) * ( swiqst + ( 1.0 - swiqst ) * zexp )
+          z1mi0(ji) = 1.0 - zi0(ji) * ziexp
+       END DO
+
+       !--------------------------------------------------------------------------------
+       !  4. Computation of the surface temperature : determined by considering the 
+       !     budget of a thin layer of thick. zhsu at the top surface (H. Grenier, 1995) 
+       !     and based on a surface energy balance : 
+       !     hsu * rcp * dT/dt = Fsr + Fnsr(T) + Fcs(T),
+       !     where - Fsr is the net absorbed solar radiation, 
+       !           - Fnsr is the total non solar radiation (incoming and outgoing long-wave,
+       !             sensible and latent heat fluxes)
+       !           - Fcs the conductive heat flux at the top of surface
+       !------------------------------------------------------------------------------
+
+       !     4.1. Computation of intermediate values
+       !---------------------------------------------
+       DO ji = kideb, kiut
+          zrcpdt(ji) = ( rcpsn * MIN( h_snow_1d(ji) , zhsu )    &
+             &       + rcpic * MAX( zhsu - h_snow_1d(ji) , zzero ) ) / rdt_ice
+          zts_old(ji) =  sist_1d(ji)
+       END DO
+
+       !     4.2. Computation of surface temperature by expanding the eq. of energy balance
+       !          with Ts = Tp + DT. One obtain , F(Tp) + DT * DF(Tp) = 0
+       !          where  - F(Tp) = Fsr + Fnsr(Tp) + Fcs(Tp) 
+       !                 - DF(Tp)= (dFnsr(Tp)/dT) + (dFcs(Tp)/dT) - hsu*rcp/dt
+       !---------------------------------------------------------------------------------
+
+       DO ji = kideb, kiut
+          !---computation of the derivative of energy balance function 
+          zdfts    =  zksndh(ji)   & ! contribution of the conductive heat flux
+             &      + zrcpdt(ji)   & ! contribution of hsu * rcp / dt
+             &      - dqns_ice_1d (ji)     ! contribution of the total non solar radiation 
+          !---computation of the energy balance function 
+          zfts    = - z1mi0 (ji) * qsr_ice_1d(ji)   & ! net absorbed solar radiation
+             &      - qns_ice_1d(ji)                & ! total non solar radiation
+             &      - zfcsu (ji)                      ! conductive heat flux from the surface
+          !---computation of surface temperature increment  
+          zdts    = -zfts / zdfts
+          !---computation of the new surface temperature 
+          sist_1d(ji) = sist_1d(ji) + zdts
+       END DO
+
+       !----------------------------------------------------------------------------
+       !  5. Boundary condition at the top surface
+       !--    IF Tsb < Tmelt, Fnet = Fcs (the net heat flux equal the conductive heat flux)
+       !      Otherwise Tsb = Tmelt and Qnet(Tmelt) > 0 
+       !      Fnet(Tmelt) is therefore the net surface flux needed for melting
+       !----------------------------------------------------------------------------
+       
+       
+       !     5.1.  Limitation of surface temperature and update total non solar fluxes,
+       !          latent heat flux and conductive flux at the top surface 
+       !----------------------------------------------------------------------  
+                     
+       IF ( .NOT. lk_cpl ) THEN   ! duplicate the loop for performances issues
+          DO ji = kideb, kiut
+             sist_1d(ji) = MIN( ztsmlt(ji) , sist_1d(ji) )
+             qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+             qla_ice_1d(ji) = qla_ice_1d(ji) + dqla_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+             zfcsu(ji)  = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
+          END DO
+       ELSE
+          DO ji = kideb, kiut
+             sist_1d(ji) = MIN( ztsmlt(ji) , sist_1d(ji) )
+             zfcsu(ji)  = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
+          END DO
+       ENDIF
+
+       !     5.2. Calculate available heat for surface ablation. 
+       !---------------------------------------------------------------------
+
+       DO ji = kideb, kiut
+          zfnet(ji) = qns_ice_1d(ji) + z1mi0(ji) * qsr_ice_1d(ji) + zfcsu(ji)          
+          zfnet(ji) = MAX( zzero , zfnet(ji) )
+          zfnet(ji) = zfnet(ji) * MAX( zzero , SIGN( zone , sist_1d(ji) - ztsmlt(ji) ) )
+       END DO
+
+       !-------------------------------------------------------------------------
+       !  6. Calculate changes in internal temperature due to vertical diffusion   
+       !     processes. The evolution of this temperature is governed by the one-
+       !     dimensionnal heat-diffusion equation. 
+       !     Given the temperature tbif(1/2/3), at time m we solve a set
+       !     of finite difference equations to obtain new tempe. Each tempe is coupled
+       !     to the temp. immediatly above and below by heat conduction terms. Thus 
+       !     we have a set of equations of the form A * T = B, where A is a tridiagonal
+       !     matrix, T a vector whose components are the unknown new temp.
+       !-------------------------------------------------------------------------
+       
+       !--parameter for the numerical methode use to solve the heat-diffusion equation
+       !- implicit, explicit or Crank-Nicholson
+       zumsb = 1.0 - sbeta  
+       DO ji = kideb, kiut
+          zidsn(ji)   = MAX ( zzero, SIGN( zone, hsndif - h_snow_1d(ji) ) ) 
+          z1midsn(ji) = 1.0 - zidsn(ji)
+          zihic       = MAX ( zzero, SIGN( zone, hicdif - h_ice_1d(ji) ) ) 
+          zidsnic(ji) = zidsn(ji) *  zihic 
+          zfcsudt(ji) = zfcsu(ji) * rdt_ice 
+       END DO 
+   
+       DO ji = kideb, kiut
+
+          !     6.1 Calculate intermediate variables.
+          !----------------------------------------
+
+          !--conductivity at the snow surface
+          zkhsn = 2.0 * zksn(ji) * rdt_ice / rcpsn
+          !--conductivity at the ice surface
+          zkhic = 4.0 * zkic(ji) * rdt_ice / MAX( h_ice_1d(ji) * h_ice_1d(ji) * rcpic , epsi20 )
+          !--conductivity at the snow/ice interface 
+          zkint = 4.0 * zksn(ji) * zkic(ji)  &
+             &        / ( zksn(ji) * h_ice_1d(ji) + 2.0 * zkic(ji) * h_snow_1d(ji) * z1midsn(ji)) 
+          zkhsnint = zkint * rdt_ice / rcpsn
+          zkhicint = zkint * 2.0 * rdt_ice / MAX( h_ice_1d(ji) * rcpic , epsi20 )
+          
+          !     6.2. Fulfill the linear system matrix.
+          !-----------------------------------------
+!$$$          zplediag(1) = 1 + sbeta * z1midsn(ji) * ( zkhsn + zkhsnint )       
+          zplediag(1) =   zidsn(ji) + z1midsn(ji) * h_snow_1d(ji)   &
+             &          + sbeta * z1midsn(ji) * zkhsnint 
+          zplediag(2) = 1 + sbeta * ( z1midsn(ji) * zkhicint + zkhic ) 
+          zplediag(3) = 1 + 3.0 * sbeta * zkhic   
+
+          zsubdiag(1) =  0.e0              
+          zsubdiag(2) = -1.e0 * z1midsn(ji) * sbeta * zkhicint
+          zsubdiag(3) = -1.e0 * sbeta * zkhic 
+
+          zsupdiag(1) = -1.e0 * z1midsn(ji) * sbeta * zkhsnint 
+          zsupdiag(2) = zsubdiag(3)
+          zsupdiag(3) =  0.e0
+          
+          !     6.3. Fulfill the idependent term vector.
+          !-------------------------------------------
+          
+!$$$          zsmbr(1) = zidsn(ji) * sist_1d(ji) + z1midsn(ji) *   &
+!$$$             &         ( tbif_1d(ji,1) + zkhsn * sist_1d(ji)
+!$$$             &         - zumsb * ( zkhsn * tbif_1d(ji,1)
+!$$$             &                   + zkhsnint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) ) )
+          zsmbr(1) = zidsn(ji) * sist_1d(ji) + z1midsn(ji) *    &
+             &       ( h_snow_1d(ji) * tbif_1d(ji,1) - ( zfcsudt(ji) / rcpsn )  &
+             &       - zumsb * zkhsnint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) )
+
+          zsmbr(2) =  tbif_1d(ji,2)  &
+             &      - zidsn(ji) * ( 1.0 - zidsnic(ji) ) &
+             &        * ( zfcsudt(ji) / MAX( h_ice_1d(ji) * rcpic , epsi20 ) ) &
+             &      + zumsb * ( zkhicint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) &
+             &                   - zkhic * ( tbif_1d(ji,2) - tbif_1d(ji,3) )  )
+
+          zsmbr(3) =  tbif_1d(ji,3)  &
+             &      + zkhic * ( 2.0 * tfu_1d(ji) &
+             &                + zumsb * ( tbif_1d(ji,2) - 3.0 * tbif_1d(ji,3) ) )
+          
+          !     6.4. Solve the system (Gauss elimination method).
+          !----------------------------------------------------
+          
+          zpiv1 = zsubdiag(2) / zplediag(1) 
+          zb2   = zplediag(2) - zpiv1 * zsupdiag(1)
+          zd2   = zsmbr(2) - zpiv1 * zsmbr(1)
+
+          zpiv2 = zsubdiag(3) / zb2
+          zb3   = zplediag(3) - zpiv2 * zsupdiag(2)
+          zd3   = zsmbr(3) - zpiv2 * zd2
+
+          tbif_1d(ji,3) = zd3 / zb3
+          tbif_1d(ji,2) = ( zd2 - zsupdiag(2) * tbif_1d(ji,3) ) / zb2
+          tbif_1d(ji,1) = ( zsmbr(1) - zsupdiag(1) * tbif_1d(ji,2) ) / zplediag(1)            
+
+          !--- taking into account the particular case of  zidsnic(ji) = 1
+          ztint =  (  zkic(ji) * h_snow_1d(ji) * tfu_1d (ji)    &
+             &      + zksn(ji) * h_ice_1d(ji) * sist_1d(ji) )   &
+             &   / ( zkic(ji) * h_snow_1d(ji) + zksn(ji) * h_ice_1d(ji) ) 
+
+          tbif_1d(ji,1) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,1)   &
+             &                + zidsnic(ji)   * ( ztint + sist_1d(ji) ) / 2.0
+          tbif_1d(ji,2) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,2)   &
+             &                + zidsnic(ji)   * ( 3.0 * ztint + tfu_1d(ji) ) / 4.0
+          tbif_1d(ji,3) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,3)   &
+             &                + zidsnic(ji)   * ( ztint + 3.0 * tfu_1d(ji) ) / 4.0     
+       END DO
+ 
+       !----------------------------------------------------------------------
+       !  9. Take into account surface ablation and bottom accretion-ablation.|
+       !----------------------------------------------------------------------
+       
+       !---Snow accumulation in one thermodynamic time step
+       zsprecip(kideb:kiut) = sprecip_1d(kideb:kiut) * rdt_ice / rhosn
+
+
+       DO ji = kideb, kiut
+          
+          !      9.1. Surface ablation and update of snow thickness and qstbif_1d
+          !--------------------------------------------------------------------
+          
+          !--------------------------------------------------------------------------
+          !--      Melting snow processes :
+          !--      Melt at the upper surface is computed from the difference between 
+          !--      the net heat flux (including the conductive heat flux) at the upper 
+          !--      surface and the pre-existing energy due to surface melting
+          !------------------------------------------------------------------------------
+          
+          !-- store the snow thickness
+          zhsnw_old(ji) =  h_snow_1d(ji)
+          !--computation of the energy needed to melt snow
+          zqsnw_mlt  = zfnet(ji) * rdt_ice - zqcmlt(ji,1)
+          !--change in snow thickness due to melt
+          zdhsmlt = - zqsnw_mlt / xlsn
+          
+          !-- compute new snow thickness, taking into account the part of snow accumulation
+          !   (as snow precipitation) and the part of snow lost due to melt
+          zhsn =  h_snow_1d(ji) + zsprecip(ji) + zdhsmlt
+          h_snow_1d(ji) = MAX( zzero , zhsn )
+          !-- compute the volume of snow lost after surface melting and the associated mass
+          dvsbq_1d(ji) =  ( 1.0 - frld_1d(ji) ) * ( h_snow_1d(ji) - zhsnw_old(ji) - zsprecip(ji) )
+          dvsbq_1d(ji) =  MIN( zzero , dvsbq_1d(ji) )
+          rdmsnif_1d(ji) =  rhosn * dvsbq_1d(ji)
+          !-- If the snow is completely melted the remaining heat is used to melt ice
+          zqsn_mlt_rem  = MAX( zzero , -zhsn ) * xlsn
+          zqice_top_mlt = zqsn_mlt_rem 
+          zqstbif_old   = qstbif_1d(ji)
+
+          !--------------------------------------------------------------------------
+          !--      Melting ice processes at the top surface :
+          !--      The energy used to melt ice, zqice_top_mlt, is taken from the energy
+          !--      stored in brine pockets qstbif_1d and the remaining energy coming 
+          !--      from the melting snow process zqsn_mlt_rem.
+          !--      If qstbif_1d > zqsn_mlt_rem then, one uses only a zqsn_mlt_rem part
+          !--      of qstbif_1d to melt ice,
+          !--         zqice_top_mlt = zqice_top_mlt + zqsn_mlt_rem
+          !--         qstbif_1d = qstbif_1d - zqsn_mlt_rem
+          !--      Otherwise one uses all qstbif_1d to melt ice
+          !--         zqice_top_mlt = zqice_top_mlt + qstbif_1d
+          !--         qstbif_1d = 0
+          !------------------------------------------------------
+          
+          ziqf =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqsn_mlt_rem  ) )
+          zqice_top_mlt =         ziqf   * ( zqice_top_mlt + zqsn_mlt_rem )   &
+             &          + ( 1.0 - ziqf ) * ( zqice_top_mlt + qstbif_1d(ji)  )
+
+          qstbif_1d(ji) =         ziqf   * ( qstbif_1d(ji) - zqsn_mlt_rem )   &
+             &          + ( 1.0 - ziqf ) * ( qstbif_1d(ji) - qstbif_1d(ji)  )
+
+          !--    The contribution of the energy stored in brine pockets qstbif_1d to melt
+          !--    ice is taking into account only when qstbif_1d is less than zqmax. 
+          !--    Otherwise, only the remaining energy coming from the melting snow 
+          !--    process is used 
+          zihq =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) )
+
+          zqice_top_mlt =         zihq   * zqice_top_mlt   &
+             &          + ( 1.0 - zihq ) * zqsn_mlt_rem
+
+          qstbif_1d(ji) =         zihq   * qstbif_1d(ji)   &
+             &          + ( 1.0 - zihq ) * zqstbif_old
+
+          !--change in ice thickness due to melt at the top surface
+          zdhictop(ji) = -zqice_top_mlt / xlic
+          !--compute the volume formed after surface melting
+          dvsbq_1d(ji) =  zdhictop(ji) * ( 1.0 - frld_1d(ji) )
+
+          !-------------------------------------------------------------------------
+          !--      A small variation at the surface also occurs because of sublimation
+          !--      associated with the latent flux. If qla_ice_1d is negative, snow condensates at 
+          !        the surface. Otherwise, snow evaporates
+          !-----------------------------------------------------------------------
+          !----change in snow and ice thicknesses due to sublimation or evaporation
+          zdhssub  = parsub * ( qla_ice_1d(ji) / ( rhosn * xsn ) ) * rdt_ice 
+          zhsn     = h_snow_1d(ji) - zdhssub
+          zdhisub  = MAX( zzero , -zhsn ) * rhosn/rhoic
+          zdhictop(ji) =  zdhictop(ji) - zdhisub
+          h_snow_1d(ji)  =  MAX( zzero , zhsn )
+          !-------------------------------------------------
+          !--  Update Internal temperature and qstbif_1d.
+          !-------------------------------------------
+          zihsn  =  MAX( zzero , SIGN( zone, -h_snow_1d(ji) ) )
+          tbif_1d(ji,1) = ( 1.0 - zihsn ) * tbif_1d(ji,1) + zihsn   * tfu_1d(ji)
+          !--change in snow internal temperature if snow has increased
+          zihnf = MAX( zzero , SIGN( zone , h_snow_1d(ji) - zhsnw_old(ji) ) )
+          zdhsn = 1.0 - zhsnw_old(ji) / MAX( h_snow_1d(ji) , epsi20 )
+          zdtsn = zdhsn * ( sist_1d(ji) - tbif_1d(ji,1) )
+          tbif_1d(ji,1) = tbif_1d(ji,1) + z1midsn(ji) * zihnf * zdtsn
+          !--energy created due to ice melting in the first ice layer
+          zqnes  = ( rt0_ice - tbif_1d(ji,2) ) * rcpic * ( h_ice_1d(ji) / 2. )
+          !--change in first ice layer internal temperature
+          ziqr  = MAX( zzero , SIGN( zone , qstbif_1d(ji) - zqnes ) )
+          zdtic = qstbif_1d(ji) / ( rcpic * ( h_ice_1d(ji) / 2. ) )
+          tbif_1d(ji,2) =  ziqr * rt0_ice + ( 1 - ziqr ) * ( tbif_1d(ji,2) + zdtic )
+          !--update qstbif_1d
+          qstbif_1d(ji) = ziqr * ( qstbif_1d(ji) - zqnes ) * swiqst
+
+
+          !--      9.2. Calculate bottom accretion-ablation and update qstbif_1d.
+          !             Growth and melting at bottom ice surface are governed by  
+          !                 -xlic * Dh = (Fcb - Fbot ) * Dt 
+          !             where Fbot is the net downward heat flux from ice to the ocean
+          !            and Fcb is the conductive heat flux at the bottom surface
+          !---------------------------------------------------------------------------
+          ztbot = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,3) + zidsnic(ji) * sist_1d(ji)
+          !---computes conductive heat flux at bottom surface 
+          zfcbot =  4.0 * zkic(ji) * ( tfu_1d(ji) - ztbot )   &
+             &   / ( h_ice_1d(ji) + zidsnic(ji) * ( 3. * h_ice_1d(ji) &
+             &   + 4.0 * zkic(ji)/zksn(ji) * h_snow_1d(ji) ) )
+          !---computation of net energy needed for bottom melting/growing
+          zqice_bot = ( zfcbot - ( fbif_1d(ji) + qlbbq_1d(ji) ) ) * rdt_ice
+          zqstbif_bot = qstbif_1d(ji)
+          !---switch to know if bottom surface melts ( = 1 ) or grows ( = 0 )occurs
+          zibmlt = MAX( zzero , SIGN( zone , -zqice_bot ) )
+          !--particular case of melting (in the same way as the top surface)
+          zqice_bot_mlt = zqice_bot 
+          zqstbif_old = zqstbif_bot
+
+          ziqf =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) + zqice_bot_mlt  ) )
+          zqice_bot_mlt =         ziqf   * ( zqice_bot_mlt + zqice_bot_mlt ) &
+             &          + ( 1.0 - ziqf ) * ( zqice_bot_mlt + qstbif_1d(ji)  )          
+          qstbif_1d(ji)   =         ziqf   * ( qstbif_1d(ji) + zqice_bot_mlt ) &
+             &          + ( 1.0 - ziqf ) * ( qstbif_1d(ji) - qstbif_1d(ji)  )
+          !--    The contribution of the energy stored in brine pockets qstbif_1d to melt
+          !--    ice is taking into account only when qstbif_1d is less than zqmax. 
+          zihq =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) )
+          zqice_bot_mlt =         zihq   * zqice_bot_mlt   &
+             &          + ( 1.0 - zihq ) * zqice_bot
+          qstbif_1d(ji)   =         zihq   * qstbif_1d(ji)   &
+             &             + ( 1.0 - zihq ) * zqstbif_old
+
+          !---treatment of the case of melting/growing
+          zqice_bot   =         zibmlt   * ( zqice_bot_mlt - zqcmlt(ji,2) )   &
+             &        + ( 1.0 - zibmlt ) * ( zqice_bot - zqcmlt(ji,2)  )
+          qstbif_1d(ji) =         zibmlt   * qstbif_1d(ji)   &
+             &           + ( 1.0 - zibmlt ) * zqstbif_bot
+
+          !--computes change in ice thickness due to melt or growth
+          zdhicbot(ji) = zqice_bot / xlic
+          !--limitation of bottom melting if so : hmelt maximum melting at bottom
+          zdhicmlt  = MAX( hmelt , zdhicbot(ji) ) 
+          !-- output part due to bottom melting only
+          IF( zdhicmlt < 0.e0 ) rdvomif_1d(ji) = ( 1.0 - frld_1d(ji) ) * zdhicmlt
+          !--energy after bottom melting/growing
+          zqsup(ji) = ( 1.0 - frld_1d(ji) ) * xlic * ( zdhicmlt - zdhicbot(ji) )
+          !-- compute the new thickness and the newly formed volume after bottom melting/growing
+          zdhicbot(ji)  = zdhicmlt
+          dvbbq_1d(ji) = ( 1.0 - frld_1d(ji) ) * zdhicbot(ji)
+
+
+          !        9.3.  Updating ice thickness after top surface ablation 
+          !              and bottom surface accretion/ablation
+          !---------------------------------------------------------------
+          zhicnew  = h_ice_1d(ji) + zdhictop(ji) + zdhicbot(ji)
+
+          !
+          !        9.4. Case of total ablation (ice is gone but snow may be left)
+          !-------------------------------------------------------------------
+          zhsn  = h_snow_1d(ji)
+          zihgnew = 1.0 - MAX( zzero , SIGN( zone , -zhicnew ) )
+          zihsn   = MAX( zzero , SIGN( zone , -zhsn ) )
+          !---convert 
+          zdhicm  = ( 1.0 - zihgnew ) * ( zhicnew - qstbif_1d(ji) / xlic )
+          zdhsnm  = ( 1.0 - zihsn ) * zdhicm * rhoic / rhosn
+          !---updating new ice thickness and computing the newly formed ice mass
+          zhicnew   =  zihgnew * zhicnew
+          rdmicif_1d(ji) =  rdmicif_1d(ji) + ( 1.0 - frld_1d(ji) ) * ( zhicnew - h_ice_1d(ji) ) * rhoic
+          !---updating new snow thickness and computing the newly formed snow mass
+          zhsnfi   = zhsn + zdhsnm
+          h_snow_1d(ji) = MAX( zzero , zhsnfi )
+          rdmsnif_1d(ji) =  rdmsnif_1d(ji) + ( 1.0 - frld_1d(ji) ) * ( h_snow_1d(ji) - zhsn ) * rhosn
+          !--remaining energy in case of total ablation
+          zqocea(ji) = - ( zihsn * xlic * zdhicm + xlsn * ( zhsnfi - h_snow_1d(ji) ) ) * ( 1.0 - frld_1d(ji) )
+          qstbif_1d(ji) = zihgnew * qstbif_1d(ji)
+
+          !
+          !        9.5. Update internal temperature and ice thickness.
+          !-------------------------------------------------------
+          !
+          sist_1d(ji) = zihgnew * sist_1d(ji) + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          zidhb  = MAX( zzero , SIGN( zone , - zdhicbot(ji) ) )
+          zc1    = - zhicnew * 0.5
+          zpc1   = MIN( 0.5 * zone , - h_ice_1d(ji) * 0.5 - zdhictop(ji) )
+          zc2    = - zhicnew
+          zpc2   =  zidhb * zc2 + ( 1.0 - zidhb ) * ( - h_ice_1d(ji) - zdhictop(ji) )
+          zp1    =  MAX( zpc1 , zc1 )
+          zp2    =  MAX( zpc2 , zc1 )
+          zep(ji) =  tbif_1d(ji,2)
+          ztb2  = 2.0 * (         - zp1   * tbif_1d(ji,2)  &
+             &  + ( zp1 - zp2 ) * tbif_1d(ji,3)  &
+             &  + ( zp2 - zc1 ) * tfu_1d(ji) ) / MAX( zhicnew , epsi20 ) 
+          tbif_1d(ji,2) = zihgnew * ztb2 + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          !---
+          zp1  =  MIN( zpc1 , zc1 )
+          zp2  =  MIN( zpc2 , zc1 )
+          zp1  =  MAX( zc2  , zp1 )
+          ztb3 =  2.0 * (   ( 1.0 - zidhb ) * (  ( zc1 - zp2 ) * tbif_1d(ji,3)  &
+             &                                 + ( zp2 - zc2 ) * tfu_1d(ji) )   &
+             &               +      zidhb   * (  ( zc1 - zp1 ) * zep(ji)      &
+             &                                 + ( zp1 - zc2 ) * tbif_1d(ji,3))  ) / MAX( zhicnew , epsi20 )
+          tbif_1d(ji,3) =  zihgnew * ztb3 + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          h_ice_1d(ji)  =  zhicnew
+       END DO
+
+
+       !----------------------------------------------------------------------------
+       !  10. Surface accretion. 
+       !      The change of ice thickness after snow/ice formation is such that
+       !      the interface between snow and ice is located at the same height
+       !      as the ocean surface. It is given by (Fichefet and Morales Maqueda 1999)
+       !          D(h_ice) = (- D(hsn)/alph) =  [rhosn*hsn - (rau0 - rhoic)*hic]
+       !                                     / [alph*rhosn+rau0 - rhoic]
+       !----------------------------------------------------------------------------
+       !
+       DO ji = kideb , kiut
+
+          !--  Computation of the change of ice thickness after snow-ice formation
+          zdrmh =  ( rhosn * h_snow_1d(ji) + ( rhoic - rau0 ) * h_ice_1d(ji) )  &
+             &  / ( alphs * rhosn + rau0 - rhoic )
+          zdrmh = MAX( zzero , zdrmh )
+
+          !--New ice and snow thicknesses Fichefet and Morales Maqueda (1999)
+          zhicnew  = MAX( h_ice_1d(ji) , h_ice_1d(ji) + zdrmh )
+          zhsnnew  = MIN( h_snow_1d(ji) , h_snow_1d(ji) - alphs * zdrmh )
+          !---Compute new ice temperatures. snow temperature remains unchanged
+          !   Lepparanta (1983):
+          zihic = 1.0 - MAX( zzero , SIGN( zone , -zhicnew ) )
+          zquot  = ( 1.0 - zihic ) &
+             &   +         zihic * MIN( zone , h_ice_1d(ji) / MAX( zhicnew , epsi20 ) ) 
+          ztneq  =         alphs * cnscg * tbif_1d(ji,1)    &
+             &   + ( 1.0 - alphs * ( rhosn/rhoic ) ) * tfu_1d(ji)
+          zep(ji) = tbif_1d(ji,2)
+          tbif_1d(ji,2) = ztneq - zquot * zquot * ( ztneq - tbif_1d(ji,2) )
+          tbif_1d(ji,3) = 2.0 * ztneq &
+             &        + zquot * ( tbif_1d(ji,3) + zep(ji) - 2.0 * ztneq ) - tbif_1d(ji,2)
+
+          !---  Lepparanta (1983) (latent heat released during white ice formation
+          !     goes to the ocean -for lateral ablation-)
+          qldif_1d(ji)  = qldif_1d(ji) + zdrmh * ( 1.0 - alphs * ( rhosn/rhoic ) ) * xlic * ( 1.0 - frld_1d(ji) )
+          !--   Changes in ice volume and ice mass Lepparanta (1983):
+          dvnbq_1d(ji) = ( 1.0 - frld_1d(ji) ) * ( zhicnew - h_ice_1d(ji) )
+          dmgwi_1d(ji) = dmgwi_1d(ji) + ( 1.0 -frld_1d(ji) ) * ( h_snow_1d(ji) - zhsnnew ) * rhosn
+          !---  volume change of ice and snow (used for ocean-ice freshwater flux computation)
+          rdmicif_1d(ji) = rdmicif_1d(ji) + ( 1.0 - frld_1d(ji) )   * ( zhicnew - h_ice_1d (ji) ) * rhoic
+          rdmsnif_1d(ji) = rdmsnif_1d(ji) + ( 1.0 - frld_1d(ji) )   * ( zhsnnew - h_snow_1d(ji) ) * rhosn
+
+          !---  Actualize new snow and ice thickness.
+          h_snow_1d(ji)  = zhsnnew
+          h_ice_1d (ji)  = zhicnew
+
+       END DO
+
+       !----------------------------------------------------
+       !  11. Lateral ablation (Changes in sea/ice fraction) 
+       !----------------------------------------------------
+       DO ji = kideb , kiut
+          zfrl_old(ji)  = frld_1d(ji)
+          zihic   = 1.0 - MAX( zzero , SIGN( zone , -h_ice_1d(ji) ) )
+          zihsn   = 1.0 - MAX( zzero , SIGN( zone , -h_snow_1d(ji) ) )
+          !--In the case of total ablation (all the ice ice has melted) frld = 1
+          frld_1d(ji)  = ( 1.0 - zihic ) + zihic * zfrl_old(ji)
+          !--Part of solar radiation absorbing inside the ice and going
+          !--through the ocean
+          fscbq_1d(ji) = ( 1.0 - zfrl_old(ji) ) * ( 1.0 - thcm_1d(ji) ) * fstbif_1d(ji)
+          !--Total remaining energy after bottom melting/growing 
+          qfvbq_1d(ji) = zqsup(ji) + ( 1.0 - zihic ) * zqocea(ji)
+          !--Updating of total heat from the ocean
+          qldif_1d(ji)  = qldif_1d(ji) + qfvbq_1d(ji) + ( 1.0 - zihic ) * fscbq_1d(ji) * rdt_ice
+          !--Computation of total heat inside the snow/ice system
+          zqice  = h_snow_1d(ji) * xlsn + h_ice_1d(ji) * xlic
+          zqicetot  = ( 1.0 - frld_1d(ji) ) * zqice
+          !--The concentration of ice is reduced (frld increases) if the heat 
+          !--exchange between ice and ocean is positive
+          ziqf = MAX( zzero , SIGN( zone ,  zqicetot - qldif_1d(ji) ) )
+          zdfrl = qldif_1d(ji) / MAX( epsi20 , zqice ) 
+          frld_1d(ji)  = ( 1.0 - ziqf )    &
+             &       +         ziqf * ( frld_1d(ji) + MAX( zzero , zdfrl ) ) 
+          fltbif_1d(ji) = ( ( 1.0 - zfrl_old(ji) ) * qstbif_1d(ji) - zqicetot  ) / rdt_ice
+          !--  Opening of leads: Hakkinen & Mellor, 1992.
+          zdfrl = - ( zdhictop(ji) + zdhicbot(ji) ) * hakspl * ( 1.0 - zfrl_old(ji) ) &
+             &  / MAX( epsi13 , h_ice_1d(ji) + h_snow_1d(ji) * rhosn/rhoic ) 
+          zfrld_1d(ji) =  frld_1d(ji) + MAX( zzero , zdfrl )
+          !--Limitation of sea-ice fraction <= 1
+          zfrld_1d(ji) = ziqf * MIN( 0.99 * zone , zfrld_1d(ji) ) + ( 1 - ziqf )
+          !---Update surface and internal temperature and snow/ice thicknesses.
+          sist_1d(ji)   = sist_1d(ji)   + ( 1.0 - ziqf ) * ( tfu_1d(ji) - sist_1d(ji)   )
+          tbif_1d(ji,1) = tbif_1d(ji,1) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,1) )
+          tbif_1d(ji,2) = tbif_1d(ji,2) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,2) )
+          tbif_1d(ji,3) = tbif_1d(ji,3) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,3) )
+          !--variation of ice volume and ice mass 
+          dvlbq_1d(ji)   = zihic * ( zfrl_old(ji) - frld_1d(ji) ) * h_ice_1d(ji)
+          rdmicif_1d(ji) = rdmicif_1d(ji) + dvlbq_1d(ji) * rhoic
+          !--variation of snow volume and snow mass 
+          zdvsnvol    = zihsn * ( zfrl_old(ji) - frld_1d(ji) ) * h_snow_1d(ji)
+          rdmsnif_1d(ji) = rdmsnif_1d(ji) + zdvsnvol * rhosn
+          h_snow_1d(ji)  = ziqf * h_snow_1d(ji)
+
+          zdrfrl1 = ziqf * ( 1.0 -  frld_1d(ji) ) / MAX( epsi20 , 1.0 - zfrld_1d(ji) )
+          zdrfrl2 = ziqf * ( 1.0 - zfrl_old(ji) ) / MAX( epsi20 , 1.0 - zfrld_1d(ji) )
+
+          h_snow_1d (ji) = zdrfrl1 * h_snow_1d(ji)
+          h_ice_1d  (ji) = zdrfrl1 * h_ice_1d(ji)
+          qstbif_1d(ji) = zdrfrl2 * qstbif_1d(ji)
+          frld_1d(ji)    = zfrld_1d(ji)
+          !
+       END DO
+       ! 
+    END SUBROUTINE lim_thd_zdf_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default Option                                     NO sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd_zdf_2          ! Empty routine
+   END SUBROUTINE lim_thd_zdf_2
+#endif
+
+   !!======================================================================
+END MODULE limthd_zdf_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtrp_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 1844)
@@ -0,0 +1,319 @@
+MODULE limtrp_2
+   !!======================================================================
+   !!                       ***  MODULE limtrp_2   ***
+   !! LIM 2.0 transport ice model : sea-ice advection/diffusion
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_trp_2      : advection/diffusion process of sea ice
+   !!   lim_trp_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE dom_oce
+   USE in_out_manager  ! I/O manager
+   USE dom_ice_2
+   USE ice_2
+   USE limistate_2
+   USE limadv_2
+   USE limhdf_2
+   USE lbclnk
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_trp_2     ! called by sbc_ice_lim_2
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC  ::   &  !:
+      bound  = 0.e0          !: boundary condit. (0.0 no-slip, 1.0 free-slip)
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi06 = 1.e-06  ,  &
+      epsi03 = 1.e-03  ,  &
+      epsi16 = 1.e-16  ,  &
+      rzero  = 0.e0    ,  &
+      rone   = 1.e0
+
+   !! * Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_trp_2( kt )
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_trp_2 ***
+      !!                    
+      !! ** purpose : advection/diffusion process of sea ice
+      !!
+      !! ** method  : variables included in the process are scalar,   
+      !!     other values are considered as second order. 
+      !!     For advection, a second order Prather scheme is used.  
+      !!
+      !! ** action :
+      !!
+      !! History :
+      !!   1.0  !  00-01 (LIM)  Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!   2.0  !  04-01 (G. Madec, C. Ethe)  F90, mpp
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      INTEGER  ::   ji, jj, jk,   &  ! dummy loop indices
+         &          initad           ! number of sub-timestep for the advection
+
+      REAL(wp) ::  &                              
+         zindb  ,  &
+         zacrith, &
+         zindsn , &
+         zindic , &
+         zusvosn, &
+         zusvoic, &
+         zignm  , &
+         zindhe , &
+         zvbord , &
+         zcfl   , &
+         zusnit , &
+         zrtt, ztsn, ztic1, ztic2
+
+      REAL(wp), DIMENSION(jpi,jpj)  ::   &  ! temporary workspace
+         zui_u , zvi_v , zsm   ,         &
+         zs0ice, zs0sn , zs0a  ,         &
+         zs0c0 , zs0c1 , zs0c2 ,         &
+         zs0st
+      !---------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL lim_trp_init_2      ! Initialization (first time-step only)
+
+      zsm(:,:) = area(:,:)
+      
+      IF( ln_limdyn ) THEN
+         !-------------------------------------!
+         !   Advection of sea ice properties   !
+         !-------------------------------------!
+
+         ! ice velocities at ocean U- and V-points (zui_u,zvi_v)
+         ! ---------------------------------------
+         ! zvbord factor between 1 and 2 to take into account slip or no-slip boundary conditions.        
+         zvbord = 1.0 + ( 1.0 - bound )
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1   ! NO vector opt.
+               zui_u(ji,jj) = ( u_ice(ji+1,jj  ) + u_ice(ji+1,jj+1) ) / ( MAX( tmu(ji+1,jj  ) + tmu(ji+1,jj+1), zvbord ) )
+               zvi_v(ji,jj) = ( v_ice(ji  ,jj+1) + v_ice(ji+1,jj+1) ) / ( MAX( tmu(ji  ,jj+1) + tmu(ji+1,jj+1), zvbord ) )
+            END DO
+         END DO
+         ! Lateral boundary conditions on zui_u, zvi_v
+         CALL lbc_lnk( zui_u, 'U', -1. )
+         CALL lbc_lnk( zvi_v, 'V', -1. )
+
+         ! CFL test for stability
+         ! ----------------------
+         zcfl  = 0.e0
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zui_u(1:jpim1, :     ) ) * rdt_ice / e1u(1:jpim1, :     ) ) )
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zvi_v( :     ,1:jpjm1) ) * rdt_ice / e2v( :     ,1:jpjm1) ) )
+
+         IF (lk_mpp ) CALL mpp_max(zcfl)
+
+         IF ( zcfl > 0.5 .AND. lwp )   WRITE(numout,*) 'lim_trp_2 : violation of cfl criterion the ',nday,'th day, cfl = ',zcfl
+
+         ! content of properties
+         ! ---------------------
+         zs0sn (:,:) =  hsnm(:,:) * area(:,:)                 ! Snow volume.
+         zs0ice(:,:) =  hicm (:,:) * area(:,:)                ! Ice volume.
+         zs0a  (:,:) =  ( 1.0 - frld(:,:) ) * area(:,:)       ! Surface covered by ice.
+         zs0c0 (:,:) =  tbif(:,:,1) / rt0_snow * zs0sn(:,:)   ! Heat content of the snow layer.
+         zs0c1 (:,:) =  tbif(:,:,2) / rt0_ice  * zs0ice(:,:)  ! Heat content of the first ice layer.
+         zs0c2 (:,:) =  tbif(:,:,3) / rt0_ice  * zs0ice(:,:)  ! Heat content of the second ice layer.
+         zs0st (:,:) =  qstoif(:,:) / xlic     * zs0a(:,:)    ! Heat reservoir for brine pockets.
+         
+ 
+         ! Advection 
+         ! ---------
+         ! If ice drift field is too fast, use an appropriate time step for advection.         
+         initad = 1 + INT( MAX( rzero, SIGN( rone, zcfl-0.5 ) ) )
+         zusnit = 1.0 / REAL( initad ) 
+         
+         IF ( MOD( nday , 2 ) == 0) THEN
+            DO jk = 1,initad
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+            END DO
+         ELSE
+            DO jk = 1, initad
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+            END DO
+         ENDIF
+                        
+         ! recover the properties from their contents
+         ! ------------------------------------------
+         zs0ice(:,:) = zs0ice(:,:) / area(:,:)
+         zs0sn (:,:) = zs0sn (:,:) / area(:,:)
+         zs0a  (:,:) = zs0a  (:,:) / area(:,:)
+         zs0c0 (:,:) = zs0c0 (:,:) / area(:,:)
+         zs0c1 (:,:) = zs0c1 (:,:) / area(:,:)
+         zs0c2 (:,:) = zs0c2 (:,:) / area(:,:)
+         zs0st (:,:) = zs0st (:,:) / area(:,:)
+
+
+         !-------------------------------------!
+         !   Diffusion of sea ice properties   !
+         !-------------------------------------!
+
+         ! Masked eddy diffusivity coefficient at ocean U- and V-points
+         ! ------------------------------------------------------------
+         DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji  ,jj) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji+1,jj) ) ) ) * ahiu(ji,jj)
+               pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji,jj  ) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone,- zs0a(ji,jj+1) ) ) ) * ahiv(ji,jj)
+            END DO
+         END DO
+
+         ! diffusion
+         ! ---------
+         CALL lim_hdf_2( zs0ice )
+         CALL lim_hdf_2( zs0sn  )
+         CALL lim_hdf_2( zs0a   )
+         CALL lim_hdf_2( zs0c0  )
+         CALL lim_hdf_2( zs0c1  )
+         CALL lim_hdf_2( zs0c2  )
+         CALL lim_hdf_2( zs0st  )
+
+         zs0ice(:,:) = MAX( rzero, zs0ice(:,:) * area(:,:) )    !!bug:  est-ce utile
+         zs0sn (:,:) = MAX( rzero, zs0sn (:,:) * area(:,:) )    !!bug:  cf /area  juste apres
+         zs0a  (:,:) = MAX( rzero, zs0a  (:,:) * area(:,:) )    !! suppression des 2 change le resultat...
+         zs0c0 (:,:) = MAX( rzero, zs0c0 (:,:) * area(:,:) )
+         zs0c1 (:,:) = MAX( rzero, zs0c1 (:,:) * area(:,:) )
+         zs0c2 (:,:) = MAX( rzero, zs0c2 (:,:) * area(:,:) )
+         zs0st (:,:) = MAX( rzero, zs0st (:,:) * area(:,:) )
+
+
+         ! -------------------------------------------------------------------!
+         !   Up-dating and limitation of sea ice properties after transport   !
+         ! -------------------------------------------------------------------!
+
+         ! Up-dating and limitation of sea ice properties after transport.
+         DO jj = 1, jpj
+!!!iii      zindhe = REAL( MAX( 0, isign(1, jj - njeq ) ) )              !ibug mpp  !!bugmpp  njeq!
+            zindhe = MAX( 0.e0, SIGN( 1.e0, fcor(1,jj) ) )              ! = 0 for SH, =1 for NH
+            DO ji = 1, jpi
+
+               ! Recover mean values over the grid squares.
+               zs0sn (ji,jj) = MAX( rzero, zs0sn (ji,jj)/area(ji,jj) )
+               zs0ice(ji,jj) = MAX( rzero, zs0ice(ji,jj)/area(ji,jj) )
+               zs0a  (ji,jj) = MAX( rzero, zs0a  (ji,jj)/area(ji,jj) )
+               zs0c0 (ji,jj) = MAX( rzero, zs0c0 (ji,jj)/area(ji,jj) )
+               zs0c1 (ji,jj) = MAX( rzero, zs0c1 (ji,jj)/area(ji,jj) )
+               zs0c2 (ji,jj) = MAX( rzero, zs0c2 (ji,jj)/area(ji,jj) )
+               zs0st (ji,jj) = MAX( rzero, zs0st (ji,jj)/area(ji,jj) )
+
+               ! Recover in situ values.
+               zindb         = MAX( rzero, SIGN( rone, zs0a(ji,jj) - epsi06 ) )
+               zacrith       = 1.0 - ( zindhe * acrit(1) + ( 1.0 - zindhe ) * acrit(2) )
+               zs0a (ji,jj)  = zindb * MIN( zs0a(ji,jj), zacrith )
+               hsnif(ji,jj)  = zindb * ( zs0sn(ji,jj) /MAX( zs0a(ji,jj), epsi16 ) )
+               hicif(ji,jj)  = zindb * ( zs0ice(ji,jj)/MAX( zs0a(ji,jj), epsi16 ) )
+               zindsn        = MAX( rzero, SIGN( rone, hsnif(ji,jj) - epsi06 ) )
+               zindic        = MAX( rzero, SIGN( rone, hicif(ji,jj) - epsi03 ) )
+               zindb         = MAX( zindsn, zindic )
+               zs0a (ji,jj)  = zindb * zs0a(ji,jj)
+               frld (ji,jj)  = 1.0 - zs0a(ji,jj)
+               hsnif(ji,jj)  = zindsn * hsnif(ji,jj)
+               hicif(ji,jj)  = zindic * hicif(ji,jj)
+               zusvosn       = 1.0/MAX( hsnif(ji,jj) * zs0a(ji,jj), epsi16 )
+               zusvoic       = 1.0/MAX( hicif(ji,jj) * zs0a(ji,jj), epsi16 )
+               zignm         = MAX( rzero,  SIGN( rone, hsndif - hsnif(ji,jj) ) )
+               zrtt          = 173.15 * rone 
+               ztsn          =          zignm   * tbif(ji,jj,1)  &
+                              + ( 1.0 - zignm ) * MIN( MAX( zrtt, rt0_snow * zusvosn * zs0c0(ji,jj)) , tfu(ji,jj) ) 
+               ztic1          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c1(ji,jj) ) , tfu(ji,jj) )
+               ztic2          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c2(ji,jj) ) , tfu(ji,jj) )
+ 
+               tbif(ji,jj,1) = zindsn * ztsn  + ( 1.0 - zindsn ) * tfu(ji,jj)               
+               tbif(ji,jj,2) = zindic * ztic1 + ( 1.0 - zindic ) * tfu(ji,jj)
+               tbif(ji,jj,3) = zindic * ztic2 + ( 1.0 - zindic ) * tfu(ji,jj)
+               qstoif(ji,jj) = zindb  * xlic * zs0st(ji,jj) /  MAX( zs0a(ji,jj), epsi16 )
+            END DO
+         END DO
+         
+      ENDIF
+      
+   END SUBROUTINE lim_trp_2
+
+
+   SUBROUTINE lim_trp_init_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_trp_init_2  ***
+      !!
+      !! ** Purpose :   initialization of ice advection parameters
+      !!
+      !! ** Method  : Read the namicetrp namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicetrp
+      !!
+      !! history :
+      !!   2.0  !  03-08 (C. Ethe)  Original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicetrp/ bound
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicetrp
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicetrp )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_trp_init_2 : Ice parameters for advection '
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   boundary conditions (0. no-slip, 1. free-slip) bound  = ', bound
+      ENDIF
+            
+   END SUBROUTINE lim_trp_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                No sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_trp_2        ! Empty routine
+   END SUBROUTINE lim_trp_2
+#endif
+
+   !!======================================================================
+END MODULE limtrp_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_2.F90	(revision 1844)
@@ -0,0 +1,337 @@
+MODULE limwri_2
+   !!======================================================================
+   !!                     ***  MODULE  limwri_2  ***
+   !!         Ice diagnostics :  write ice output files
+   !!======================================================================
+   !! history :  2.0  ! 2003-08  (C. Ethe)      original code
+   !!            2.0  ! 2004-10  (C. Ethe )     1D configuration
+   !!             -   ! 2009-06  (B. Lemaire )  iom_put + lim_wri_state_2
+   !!-------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_wri_2      : write of the diagnostics variables in ouput file 
+   !!   lim_wri_init_2 : initialization and namelist read
+   !!   lim_wri_state_2 : write for initial state or/and abandon:
+   !!                     > output.init.nc (if ninist = 1 in namelist)
+   !!                     > output.abort.nc
+   !!----------------------------------------------------------------------
+   USE phycst
+   USE dom_oce
+   USE sbc_oce
+   USE sbc_ice
+   USE dom_ice_2
+   USE ice_2
+
+   USE lbclnk
+   USE dianam          ! build name of file (routine)
+   USE in_out_manager
+   USE iom
+   USE ioipsl
+
+   IMPLICIT NONE
+   PRIVATE
+
+#if ! defined key_iomput
+   PUBLIC   lim_wri_2         ! called by sbc_ice_lim_2
+#endif
+   PUBLIC   lim_wri_state_2   ! called by dia_wri_state 
+
+   INTEGER, PARAMETER                       ::   jpnoumax = 40   ! maximum number of variable for ice output
+   INTEGER                                  ::   noumef          ! number of fields
+   REAL(wp)           , DIMENSION(jpnoumax) ::   cmulti ,     &  ! multiplicative constant
+      &                                          cadd            ! additive constant
+   CHARACTER(len = 35), DIMENSION(jpnoumax) ::   titn            ! title of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::   nam             ! name of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::   uni             ! unit of the field
+   INTEGER            , DIMENSION(jpnoumax) ::   nc              ! switch for saving field ( = 1 ) or not ( = 0 )
+
+   INTEGER ::   nice, nhorid, ndim, niter, ndepid       ! ????
+   INTEGER , DIMENSION( jpij ) ::   ndex51              ! ????
+
+   REAL(wp)  ::            &  ! constant values
+      epsi16 = 1.e-16   ,  &
+      zzero  = 0.e0     ,  &
+      zone   = 1.e0
+
+   !! * Substitutions
+#   include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if ! defined key_iomput
+# if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   'key_dimgout'                                    Direct Access file
+   !!----------------------------------------------------------------------
+# include "limwri_dimg_2.h90"
+# else
+   SUBROUTINE lim_wri_2( kt )
+      !!-------------------------------------------------------------------
+      !!                    ***   ROUTINE lim_wri_2  ***
+      !!                
+      !! ** Purpose :   write the sea-ice output file in NetCDF
+      !!
+      !! ** Method  :   computes the average of some variables and write
+      !!      it in the NetCDF ouput files
+      !!      CAUTION: the sea-ice time-step must be an integer fraction
+      !!      of a day
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER  ::   ji, jj, jf                      ! dummy loop indices
+      CHARACTER(len = 40)  ::   clhstnam, clop
+      REAL(wp) ::   zsto, zjulian, zout,   &  ! temporary scalars
+         &          zindh, zinda, zindb, ztmu
+      REAL(wp), DIMENSION(1)                ::   zdept
+      REAL(wp), DIMENSION(jpi,jpj)          ::   zfield
+      REAL(wp), DIMENSION(jpi,jpj,jpnoumax) ::   zcmo
+      !!-------------------------------------------------------------------
+                                                 !--------------------!
+      IF( kt == nit000 ) THEN                    !   Initialisation   !
+         !                                       !--------------------!
+         CALL lim_wri_init_2 
+                           
+         zsto     = rdt_ice
+         IF( ln_mskland )   THEN   ;   clop = "ave(only(x))"   ! put 1.e+20 on land (very expensive!!)
+         ELSE                      ;   clop = "ave(x)"         ! no use of the mask value (require less cpu time)
+         ENDIF
+         zout     = nwrite * rdt_ice / nn_fsbc
+         niter    = ( nit000 - 1 ) / nn_fsbc
+         zdept(1) = 0.
+         
+         CALL ymds2ju ( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         CALL dia_nam ( clhstnam, nwrite, 'icemod' )
+         CALL histbeg ( clhstnam, jpi, glamt, jpj, gphit,    &
+            &           1, jpi, 1, jpj, niter, zjulian, rdt_ice, nhorid, nice , domain_id=nidom)
+         CALL histvert( nice, "deptht", "Vertical T levels", "m", 1, zdept, ndepid, "down")
+         CALL wheneq  ( jpij , tmask(:,:,1), 1, 1., ndex51, ndim)
+         
+         DO jf = 1, noumef
+            IF( nc(jf) == 1 )   CALL histdef( nice, nam(jf), titn(jf), uni(jf), jpi, jpj   &
+               &                                  , nhorid, 1, 1, 1, -99, 32, clop, zsto, zout )
+         END DO
+         CALL histend( nice )
+         !
+      ENDIF
+      !                                          !--------------------!
+      !                                          !   Cumulate at kt   !
+      !                                          !--------------------!
+
+      !-- Store instantaneous values in zcmo
+      
+      zcmo(:,:, 1:jpnoumax ) = 0.e0 
+      DO jj = 2 , jpjm1
+         DO ji = 1 , jpim1   ! NO vector opt.
+            zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+            zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+            zindb  = zindh * zinda
+            ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+            zcmo(ji,jj,1)  = hsnif (ji,jj)
+            zcmo(ji,jj,2)  = hicif (ji,jj)
+            zcmo(ji,jj,3)  = hicifp(ji,jj)
+            zcmo(ji,jj,4)  = frld  (ji,jj)
+            zcmo(ji,jj,5)  = sist  (ji,jj)
+            zcmo(ji,jj,6)  = fbif  (ji,jj)
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                                      + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                                  / ztmu 
+
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                                      + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                                  / ztmu
+            zcmo(ji,jj,9)  = sst_m(ji,jj)
+            zcmo(ji,jj,10) = sss_m(ji,jj)
+            zcmo(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+            zcmo(ji,jj,12) = qsr(ji,jj)
+            zcmo(ji,jj,13) = qns(ji,jj)
+            ! See thersf for the coefficient
+            zcmo(ji,jj,14) = - emps(ji,jj) * rday * ( sss_m(ji,jj) + epsi16 ) / soce    !!gm ???
+            zcmo(ji,jj,15) = utau_ice(ji,jj)
+            zcmo(ji,jj,16) = vtau_ice(ji,jj)
+            zcmo(ji,jj,17) = qsr_ice(ji,jj,1)
+            zcmo(ji,jj,18) = qns_ice(ji,jj,1)
+            zcmo(ji,jj,19) = sprecip(ji,jj)
+         END DO
+      END DO
+      !
+      ! Write the netcdf file
+      !
+      niter = niter + 1
+      DO jf = 1 , noumef
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
+               zfield(ji,jj) = zcmo(ji,jj,jf) * cmulti(jf) + cadd(jf)
+            END DO
+         END DO
+         
+         IF( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN
+            CALL lbc_lnk( zfield, 'T', -1. )
+         ELSE 
+            CALL lbc_lnk( zfield, 'T',  1. )
+         ENDIF
+         
+         IF( nc(jf) == 1 )   CALL histwrite( nice, nam(jf), niter, zfield, ndim, ndex51 )
+         
+      END DO
+      
+      IF( ( nn_fsbc * niter ) >= nitend )   CALL histclo( nice ) 
+
+   END SUBROUTINE lim_wri_2
+     
+
+   SUBROUTINE lim_wri_init_2
+      !!-------------------------------------------------------------------
+      !!                    ***   ROUTINE lim_wri_init_2  ***
+      !!                
+      !! ** Purpose :   intialisation of LIM sea-ice output
+      !!
+      !! ** Method  : Read the namicewri namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicewri
+      !!-------------------------------------------------------------------
+      INTEGER ::   nf      ! ???
+      TYPE FIELD 
+         CHARACTER(len = 35) :: ztitle 
+         CHARACTER(len = 8 ) :: zname          
+         CHARACTER(len = 8 ) :: zunit
+         INTEGER             :: znc   
+         REAL                :: zcmulti 
+         REAL                :: zcadd        
+      END TYPE FIELD
+      TYPE(FIELD) ::  &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19
+      TYPE(FIELD) , DIMENSION(jpnoumax) :: zfield
+
+      NAMELIST/namiceout/ noumef, &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19
+      !!-------------------------------------------------------------------
+
+      REWIND ( numnam_ice )                ! Read Namelist namicewri
+      READ   ( numnam_ice  , namiceout )
+      
+      zfield( 1) = field_1
+      zfield( 2) = field_2
+      zfield( 3) = field_3
+      zfield( 4) = field_4
+      zfield( 5) = field_5
+      zfield( 6) = field_6
+      zfield( 7) = field_7
+      zfield( 8) = field_8
+      zfield( 9) = field_9
+      zfield(10) = field_10
+      zfield(11) = field_11
+      zfield(12) = field_12
+      zfield(13) = field_13
+      zfield(14) = field_14
+      zfield(15) = field_15
+      zfield(16) = field_16
+      zfield(17) = field_17
+      zfield(18) = field_18
+      zfield(19) = field_19
+      
+      DO nf = 1, noumef
+         titn  (nf) = zfield(nf)%ztitle
+         nam   (nf) = zfield(nf)%zname
+         uni   (nf) = zfield(nf)%zunit
+         nc    (nf) = zfield(nf)%znc
+         cmulti(nf) = zfield(nf)%zcmulti
+         cadd  (nf) = zfield(nf)%zcadd
+      END DO
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_wri_init_2 : Ice parameters for outputs'
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    number of fields to be stored         noumef = ', noumef
+         WRITE(numout,*) '           title                            name     unit      Saving (1/0) ',   &
+            &            '    multiplicative constant       additive constant '
+         DO nf = 1 , noumef         
+            WRITE(numout,*) '   ', titn(nf), '   ', nam(nf),'      ', uni(nf),'  ', nc(nf),'        ', cmulti(nf),   &
+               &       '        ', cadd(nf)
+         END DO
+      ENDIF
+      !    
+   END SUBROUTINE lim_wri_init_2
+
+# endif
+#endif
+
+   SUBROUTINE lim_wri_state_2( kt, kid, kh_i )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE lim_wri_state_2  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ice state and forcing fields for ice model
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! History :
+      !!   2.0  !  2009-06  (B. Lemaire)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt               ! ocean time-step index)
+      INTEGER, INTENT( in ) ::   kid , kh_i       
+      !!----------------------------------------------------------------------
+
+      CALL histdef( kid, "isnowthi", "Snow thickness"          , "m"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicethic", "Ice thickness"           , "m"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iiceprod", "Ice produced"            , "m/kt"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "ileadfra", "Ice concentration"       , "-"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicetemp", "Ice temperature"         , "K"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "ioceflxb", "flux at ice base"        , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicevelu", "i-Ice speed (I-point)"   , "m/s"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicevelv", "j-Ice speed (I-point)"   , "m/s"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "isstempe", "Sea surface temperature" , "C"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "isssalin", "Sea surface salinity"    , "PSU"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicestru", "i-Wind stress over ice (I-pt)", "Pa", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicestrv", "j-Wind stress over ice (I-pt)", "Pa", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicesflx", "Solar flux over ice"     , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicenflx", "Non-solar flux over ice" , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "isnowpre", "Snow precipitation"      , "kg/m2/s", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+
+      CALL histend( kid )   ! end of the file definition
+
+      CALL histwrite( kid, "isnowthi", kt, hsnif          , jpi*jpj, (/1/) )   
+      CALL histwrite( kid, "iicethic", kt, hicif          , jpi*jpj, (/1/) )    
+      CALL histwrite( kid, "iiceprod", kt, hicifp         , jpi*jpj, (/1/) )   
+      CALL histwrite( kid, "ileadfra", kt, 1. - frld(:,:) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicetemp", kt, sist(:,:) - rt0, jpi*jpj, (/1/) )
+      CALL histwrite( kid, "ioceflxb", kt, fbif           , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicevelu", kt, u_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicevelv", kt, v_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isstempe", kt, sst_m          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isssalin", kt, sss_m          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicestru", kt, utau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicestrv", kt, vtau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicesflx", kt, qsr_ice(:,:,1) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicenflx", kt, qns_ice(:,:,1) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isnowpre", kt, sprecip        , jpi*jpj, (/1/) )
+
+    END SUBROUTINE lim_wri_state_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_wri_2          ! Empty routine
+   END SUBROUTINE lim_wri_2
+#endif
+
+   !!======================================================================
+END MODULE limwri_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_dimg_2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 1844)
@@ -0,0 +1,205 @@
+    SUBROUTINE lim_wri_2(kt)
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+    !!-------------------------------------------------------------------
+    !!  This routine computes the average of some variables and write it
+    !!  on the ouput files.
+    !!  ATTENTION cette routine n'est valable que si le pas de temps est
+    !!  egale a une fraction entiere de 1 jours.
+    !!  Diff 1-D 3-D : suppress common also included in etat
+    !!                 suppress cmoymo 11-18
+    !!  modif : 03/06/98
+    !!-------------------------------------------------------------------
+    USE  diadimg                ! use of dia_wri_dimg
+
+    INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+    REAL(wp),DIMENSION(1) ::   zdept
+
+    REAL(wp) :: &
+         zsto, zsec, zjulian,zout, &
+         zindh,zinda,zindb,  &
+         ztmu
+    REAL(wp), DIMENSION(jpi,jpj,jpnoumax) :: &
+         zcmo
+    REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zfield
+    INTEGER, SAVE :: nmoyice, &  !: counter for averaging
+         &             nwf         !: number of fields to write on disk
+    INTEGER, SAVE,DIMENSION (:), ALLOCATABLE  :: nsubindex   !: subindex to be saved
+    ! according to namelist
+
+    REAL(wp), SAVE, DIMENSION(jpi,jpj,jpnoumax) :: rcmoy
+#if ! defined key_diainstant
+    LOGICAL, PARAMETER :: ll_dia_inst=.false.      ! local logical variable 
+#else
+    LOGICAL, PARAMETER :: ll_dia_inst=.true.
+#endif
+    INTEGER ::  ji, jj, jf, ii   ! dummy loop indices and array index
+    INTEGER :: iyear, iday, imon ! 
+
+    CHARACTER(LEN=80) :: clname, cltext, clmode
+
+
+    INTEGER , SAVE ::      &
+         nice, nhorid, ndim, niter, ndepid
+    INTEGER , DIMENSION( jpij ) , SAVE ::  &
+         ndex51  
+    !!-------------------------------------------------------------------
+    IF ( kt == nit000 ) THEN 
+
+       CALL lim_wri_init_2 
+
+       nwf = 0 
+       ii  = 0
+
+       IF (lwp ) THEN
+          WRITE(numout,*) 'lim_wri_2 : Write ice outputs in dimg'
+          WRITE(numout,*) '~~~~~~~~'
+          WRITE(numout,*) '   According to namelist_ice, following fields saved:'
+          DO jf =1, noumef
+             IF (nc(jf) == 1 ) THEN
+                WRITE(numout,* ) '    -',titn(jf), nam(jf), uni(jf)
+             ENDIF
+          END DO
+       ENDIF
+
+       DO jf = 1, noumef
+          IF (nc(jf) == 1 ) nwf = nwf + 1
+       END DO
+
+       ALLOCATE( nsubindex (nwf) )
+
+       DO jf = 1, noumef
+          IF (nc(jf) == 1 ) THEN 
+             ii = ii +1 
+             nsubindex(ii) = jf
+          END IF
+       END DO
+
+       zsto     = rdt_ice
+       zout     = nwrite * rdt_ice / nn_fsbc
+       zsec     = 0.
+       niter    = 0
+       zdept(1) = 0.
+       nmoyice  = 0
+
+    ENDIF
+
+#if ! defined key_diainstant 
+    !-- calculs des valeurs instantanees
+
+    zcmo(:,:, 1:jpnoumax ) = 0.e0 
+    DO jj = 2 , jpjm1
+       DO ji = 2 , jpim1   ! NO vector opt.
+          zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+          zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+          zindb  = zindh * zinda
+          ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+          zcmo(ji,jj,1)  = hsnif (ji,jj)
+          zcmo(ji,jj,2)  = hicif (ji,jj)
+          zcmo(ji,jj,3)  = hicifp(ji,jj)
+          zcmo(ji,jj,4)  = frld  (ji,jj)
+          zcmo(ji,jj,5)  = sist  (ji,jj)
+          zcmo(ji,jj,6)  = fbif  (ji,jj)
+          zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+             &                      + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+               / ztmu 
+
+          zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+             &                      + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+               / ztmu
+          zcmo(ji,jj,9)  = sst_m(ji,jj)
+          zcmo(ji,jj,10) = sss_m(ji,jj)
+
+          zcmo(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+          zcmo(ji,jj,12) = qsr(ji,jj)
+          zcmo(ji,jj,13) = qns(ji,jj)
+          ! See thersf for the coefficient
+          zcmo(ji,jj,14) = - emps(ji,jj) * rday * ( sss_m(ji,jj) + epsi16 ) / soce
+          zcmo(ji,jj,15) = utau_ice(ji,jj)
+          zcmo(ji,jj,16) = vtau_ice(ji,jj)
+          zcmo(ji,jj,17) = qsr_ice(ji,jj,1)
+          zcmo(ji,jj,18) = qns_ice(ji,jj,1)
+          zcmo(ji,jj,19) = sprecip(ji,jj)
+       END DO
+    END DO
+    ! Cumulates values between outputs           
+    rcmoy(:,:,:)= rcmoy(:,:,:) + zcmo(:,:,:)
+    nmoyice = nmoyice + 1 
+    ! compute mean value if it is time to write on file
+    IF ( MOD(kt+nn_fsbc-1-nit000+1,nwrite) == 0 ) THEN
+       rcmoy(:,:,:) = rcmoy(:,:,:) / FLOAT(nmoyice)
+#else  
+       IF ( MOD(kt-nn_fsbc-1-nit000+1,nwrite) == 0 ) THEN 
+          !  case of instantaneaous output rcmoy(:,:, 1:jpnoumax ) = 0.e0
+          DO jj = 2 , jpjm1
+             DO ji = 2 , jpim1   ! NO vector opt.
+                zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+                zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+                zindb  = zindh * zinda
+                ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) )
+                rcmoy(ji,jj,1)  = hsnif (ji,jj)
+                rcmoy(ji,jj,2)  = hicif (ji,jj)
+                rcmoy(ji,jj,3)  = hicifp(ji,jj)
+                rcmoy(ji,jj,4)  = frld  (ji,jj)
+                rcmoy(ji,jj,5)  = sist  (ji,jj)
+                rcmoy(ji,jj,6)  = fbif  (ji,jj)
+                rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                   &                       + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                     / ztmu
+
+                rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                   &                       + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                     / ztmu
+                rcmoy(ji,jj,9)  = sst_m(ji,jj)
+                rcmoy(ji,jj,10) = sss_m(ji,jj)
+
+                rcmoy(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+                rcmoy(ji,jj,12) = qsr(ji,jj)
+                rcmoy(ji,jj,13) = qns(ji,jj)
+                ! See thersf for the coefficient
+                rcmoy(ji,jj,14) = - emps(ji,jj) * rday * ( sss_m(ji,jj) + epsi16 ) / soce
+                rcmoy(ji,jj,15) = utau_ice(ji,jj)
+                rcmoy(ji,jj,16) = vtau_ice(ji,jj)
+                rcmoy(ji,jj,17) = qsr_ice(ji,jj,1)
+                rcmoy(ji,jj,18) = qns_ice(ji,jj,1)
+                rcmoy(ji,jj,19) = sprecip(ji,jj)
+             END DO
+          END DO
+#endif
+
+          !
+          niter = niter + 1
+          DO jf = 1 , noumef
+             zfield(:,:) = (rcmoy(:,:,jf) * cmulti(jf) + cadd(jf)) * tmask(:,:,1)
+
+             IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+                CALL lbc_lnk( zfield, 'T', -1. )
+             ELSE 
+                CALL lbc_lnk( zfield, 'T',  1. )
+             ENDIF
+             rcmoy(:,:,jf) = zfield(:,:)
+          END DO
+
+          IF (ll_dia_inst) THEN
+           clmode='instantaneous'
+          ELSE
+           WRITE(clmode,'(f5.1,a)' ) nwrite*rdt/86400.,' days average'
+          END IF
+          iyear = ndastp/10000
+          imon = (ndastp-iyear*10000)/100
+          iday = ndastp - imon*100 - iyear*10000
+          WRITE(clname,9000) TRIM(cexper),'ICEMOD',iyear,imon,iday
+          cltext=TRIM(cexper)//' ice modele output'//TRIM(clmode)
+          CALL dia_wri_dimg (clname, cltext, rcmoy, nwf , 'I', nsubindex)
+9000      FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
+
+          rcmoy(:,:,:) = 0.0
+          nmoyice = 0 
+       END IF     !  MOD(kt+nn_fsbc-1-nit000+1, nwrite == 0 ) !
+
+     END SUBROUTINE lim_wri_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/par_ice_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/par_ice_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/par_ice_2.F90	(revision 1844)
@@ -0,0 +1,30 @@
+MODULE par_ice_2
+   !!======================================================================
+   !!                       ***  MODULE par_ice_2   ***
+   !! Sea-Ice model : definition of the parameters
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!  'key_lim2'                                       LIM-2 sea-ice model
+   !!----------------------------------------------------------------------
+   USE par_oce
+
+   IMPLICIT NONE
+   PUBLIC               ! allows par_oce and par_kind to be known in ice modules
+
+   INTEGER, PUBLIC, PARAMETER ::   jpl        = 1              !: number of ice categories (only 1 in LIM-2)
+
+   INTEGER, PUBLIC, PARAMETER ::   jplayers   = 2              !: number of vertical ice layers
+   INTEGER, PUBLIC, PARAMETER ::   jplayersp1 = jplayers + 1   !: ???
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Default option                                No LIM-2 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 2.0, UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE par_ice_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/thd_ice_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 1844)
@@ -0,0 +1,87 @@
+MODULE thd_ice_2
+#if defined key_lim2
+   !!======================================================================
+   !!                       ***  MODULE thd_ice_2  ***
+   !! LIM 2.0 sea-ice :   Ice thermodynamics in 1D
+   !!=====================================================================
+   !! History :
+   !!   2.0  !  02-11  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice_2
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Share Module variables
+   REAL(wp) , PUBLIC ::   & !!! ** ice-thermo namelist (namicethd) **
+      hmelt   = -0.15  ,  &  !: maximum melting at the bottom
+      hicmin  = 0.2    ,  &  !: ice th. corr. to max. ener. in brine pocket
+      hiclim  = 0.05   ,  &  !: minimum ice thickness
+      amax    = 0.999  ,  &  !: maximum lead fraction
+      swiqst  = 1.0    ,  &  !: energy stored in brine pocket (1) or not (0)
+      sbeta   = 1.0    ,  &  !: numerical scheme for diffusion in ice 
+      parlat  = 0.0    ,  &  !: percent. of energy used for lateral ablation
+      hakspl  = 0.5    ,  &  !: slope of distr. for Hakkinen-Mellro's lat. melt
+      hibspl  = 0.5    ,  &  !: slope of distribution for Hibler's lat. melt
+      exld    = 2.0    ,  &  !: exponent for leads-closure rate
+      hakdif  = 1.0    ,  &  !: coefficient for diffusions of ice and snow
+      thth    = 0.2    ,  &  !: thick. for comp. of eq. thermal conduct
+      hnzst   = 0.1    ,  &  !: thick. of the surf. layer in temp. comp.
+      parsub  = 1.0    ,  &  !: switch for snow sublimation or not
+      alphs   = 1.0          !: coef. for snow density when snow-ice formation
+
+   REAL(wp), PUBLIC, DIMENSION(2)  ::  &  !:   
+      hiccrit = (/0.3,0.3/)  !: ice th. for lateral accretion in the NH (SH) (m)
+
+   REAL(wp) , PUBLIC ::   &  !:
+      uscomi,             &  !: inverse of minimum lead fraction
+      cnscg                  !: ratio  rcpsn/rcpic
+
+   INTEGER , PUBLIC, DIMENSION(jpij) ::   &  !:
+      npb     ,   &   !: number of points where computations has to be done
+      npac            !: correspondance between the points
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !: 
+      qldif_1d    ,     &  !: corresponding to the 2D var  qldif
+      qcmif_1d    ,     &  !: corresponding to the 2D var  qcmif
+      thcm_1d     ,     &  !:    "                  "      thcm
+      fstbif_1d   ,     &  !:    "                  "      fstric
+      fltbif_1d   ,     &  !:    "                  "      ffltbif
+      fscbq_1d    ,     &  !:    "                  "      fscmcbq
+      qsr_ice_1d  ,     &  !:    "                  "      qsr_ice
+      fr1_i0_1d   ,     &  !:    "                  "      fr1_i0
+      fr2_i0_1d   ,     &  !:    "                  "      fr2_i0
+      qns_ice_1d  ,     &  !:    "                  "      qns_ice
+      qfvbq_1d    ,     &  !:    "                  "      qfvbq
+      sist_1d     ,     &  !:    "                  "      sist
+      tfu_1d      ,     &  !:    "                  "      tfu
+      sprecip_1d  ,     &  !:    "                  "      sprecip
+      h_snow_1d   ,     &  !:    "                  "      h_snow
+      h_ice_1d    ,     &  !:    "                  "      h_ice
+      frld_1d     ,     &  !:    "                  "      frld
+      qstbif_1d   ,     &  !:    "                  "      qstoif
+      fbif_1d     ,     &  !:    "                  "      fbif
+      rdmicif_1d  ,     &  !:    "                  "      rdmicif
+      rdmsnif_1d  ,     &  !:    "                  "      rdmsnif
+      qlbbq_1d    ,     &  !:    "                  "      qlbsbq
+      dmgwi_1d    ,     &  !:    "                  "      dmgwi
+      dvsbq_1d    ,     &  !:    "                  "      rdvosif
+      rdvomif_1d  ,     &  !:    "                  "      rdvomif
+      dvbbq_1d    ,     &  !:    "                  "      rdvobif
+      dvlbq_1d    ,     &  !:    "                  "      rdvolif
+      dvnbq_1d    ,     &  !:    "                  "      rdvolif
+      dqns_ice_1d ,     &  !:    "                  "      dqns_ice
+      qla_ice_1d  ,     &  !:    "                  "      qla_ice
+      dqla_ice_1d          !:    "                  "      dqla_ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpij,jplayersp1) ::   &  !:
+      tbif_1d              !: corresponding to the 2D var  tbif
+
+   !!======================================================================
+#endif
+END MODULE thd_ice_2
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/dom_ice.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/dom_ice.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/dom_ice.F90	(revision 1844)
@@ -0,0 +1,32 @@
+MODULE dom_ice
+   !!======================================================================
+   !!                   ***  MODULE  dom_ice  ***
+   !! LIM-3 Sea Ice :   Domain  variables
+   !!======================================================================
+   !! History :  3.0  ! 2003-08  (M. Vancoppenolle)  LIM-3
+   !!----------------------------------------------------------------------
+   USE par_ice
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC ::   l_jeq = .TRUE.       !: Equator inside the domain flag
+
+   INTEGER, PUBLIC ::   njeq , njeqm1        !: j-index of the equator if it is inside the domain
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fs2cor     !: coriolis factor
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fcor       !: coriolis coefficient
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   covrai     !: sine of geographic latitude
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   area       !: surface of grid cell 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tms, tmi   !: temperature mask, mask for stress
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tmu, tmv   !: mask at u and v velocity points
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tmf        !: mask at f-point
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2,2) ::   wght     !: weight of the 4 neighbours to compute averages
+
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2, UCL-ASTR-LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE dom_ice
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/ice.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/ice.F90	(revision 1844)
@@ -0,0 +1,509 @@
+MODULE ice
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !! History :
+   !!   2.0  !  03-08  (C. Ethe)  F90: Free form and module
+   !!   3.0  !  08-03  (M. Vancoppenolle) : LIM3 !
+   !!----------------------------------------------------------------------
+   !!  LIM 3.0, UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice          ! LIM sea-ice parameters
+
+   IMPLICIT NONE
+   PRIVATE
+   !!
+   !!======================================================================
+   !!                        ***  MODULE ice  ***
+   !!
+   !!                           **************
+   !!                           * L I M  3.0 *
+   !!                           **************
+   !!
+   !!                         ''in ice we trust''
+   !!
+   !!                   This module contains the sea ice 
+   !!                 diagnostics variables of ice defined 
+   !!                             in memory
+   !!
+   !!======================================================================
+   !!
+   !! LIM3 by the use of sweat, agile fingers and sometimes brain juice, 
+   !!  was developed in Louvain-la-Neuve by : 
+   !!
+   !!    * Martin Vancoppenolle (UCL-ASTR, Belgium)
+   !!    * Sylvain Bouillon (UCL-ASTR, Belgium)
+   !!    * Miguel Angel Morales Maqueda (POL, UK)
+   !! 
+   !! Based on extremely valuable earlier work by
+   !!
+   !!    * Thierry Fichefet
+   !!    * Hugues Goosse
+   !!
+   !! The following persons also contributed to the code in various ways
+   !!
+   !!    * Gurvan Madec, Claude Talandier, Christian Ethe 
+   !!      and Rachid Benshila (LOCEAN-IPSL, France)
+   !!    * Xavier Fettweis (UCL-ASTR), Ralph Timmermann (AWI, Germany)
+   !!    * Bill Lipscomb (LANL), Cecilia Bitz (UWa) 
+   !!      and Elisabeth Hunke (LANL), USA.
+   !! 
+   !! (c) UCL-ASTR, 2005-2008
+   !!
+   !! For more info, the interested user is kindly invited to consult the
+   !! following references
+   !!    For model description and validation :
+   !!    * Vancoppenolle et al., Ocean Modelling, 2008a.
+   !!    * Vancoppenolle et al., Ocean Modelling, 2008b.
+   !!
+   !!    For a specific description of EVP :
+   !!    * Bouillon et al., in prep for 2008.
+   !!
+   !!    Or the reference manual, that should be available by 2009
+   !!
+   !!======================================================================
+   !!                                                                     |
+   !!            *****************************************                |
+   !!            *                                       *                |
+   !! ************ I C E   S T A T E   V A R I A B L E S **************** |
+   !!            *                                       *                |
+   !!            *****************************************                |
+   !!                                                                     |
+   !! Introduction :                                                      |
+   !! --------------                                                      |
+   !!                                                                     |
+   !! Every ice-covered grid cell is characterized by a series of state   |
+   !! variables. To account for unresolved spatial variability in ice     |
+   !! thickness, the ice cover in divided in ice thickness categories.    |
+   !!                                                                     |
+   !! Sea ice state variables depend on the ice thickness category        |
+   !!                                                                     |
+   !! Those variables are divided into two groups                         |
+   !! * Extensive (or global) variables.                                  |
+   !!   These are the variables that are transported by all means         |
+   !! * Intensive (or equivalent) variables.                              |
+   !!   These are the variables that are either physically more           |
+   !!   meaningful and/or used in ice thermodynamics                      |
+   !!                                                                     |
+   !! Routines in limvar.F90 perform conversions                          |
+   !!  - lim_var_glo2eqv  : from global to equivalent variables           |
+   !!  - lim_var_eqv2glo  : from equivalent to global variables           |
+   !!                                                                     |
+   !! For various purposes, the sea ice state variables have sometimes    |
+   !! to be aggregated over all ice thickness categories. This operation  |
+   !! is done in :                                                        |
+   !!  - lim_var_agg                                                      |
+   !!                                                                     |
+   !! in icestp.F90, the routines that compute the changes in the ice     |
+   !! state variables are called                                          |
+   !! - lim_dyn : ice dynamics                                            |
+   !! - lim_trp : ice transport                                           |
+   !! - lim_itd_me : mechanical redistribution (ridging and rafting)      |
+   !! - lim_thd : ice halo-thermodynamics                                 |
+   !! - lim_itd_th : thermodynamic changes in ice thickness distribution  |
+   !!                and creation of new ice                              |
+   !!                                                                     |
+   !! See the associated routines for more information                    |
+   !!                                                                     |
+   !! List of ice state variables :                                       |
+   !! -----------------------------                                       |
+   !!                                                                     |
+   !!-------------|-------------|---------------------------------|-------|
+   !!   name in   |   name in   |              meaning            | units |
+   !! 2D routines | 1D routines |                                 |       |
+   !!-------------|-------------|---------------------------------|-------|
+   !!                                                                     |
+   !! ******************************************************************* |
+   !! ***         Dynamical variables (prognostic)                    *** |
+   !! ******************************************************************* |
+   !!                                                                     |
+   !! u_ice       |      -      |    Comp. U of the ice velocity  | m/s   |
+   !! v_ice       |      -      |    Comp. V of the ice velocity  | m/s   |
+   !!                                                                     |
+   !! ******************************************************************* |
+   !! ***         Category dependent state variables (prognostic)     *** |
+   !! ******************************************************************* |
+   !!                                                                     |
+   !! ** Global variables                                                 |
+   !!                                                                     |
+   !!-------------|-------------|---------------------------------|-------|
+   !! a_i         | a_i_b       |    Ice concentration            |       |
+   !! v_i         |      -      |    Ice volume per unit area     | m     |
+   !! v_s         |      -      |    Snow volume per unit area    | m     |
+   !! smv_i       |      -      |    Sea ice salt content         | ppt.m |
+   !! oa_i        !      -      !    Sea ice areal age content    | day   |
+   !! e_i         !      -      !    Ice enthalpy                 | 10^9 J| 
+   !!      -      ! q_i_b       !    Ice enthalpy per unit vol.   | J/m3  | 
+   !! e_s         !      -      !    Snow enthalpy                | 10^9 J| 
+   !!      -      ! q_s_b       !    Snow enthalpy per unit vol.  | J/m3  | 
+   !!                                                                     |
+   !!-------------|-------------|---------------------------------|-------|
+   !!                                                                     |
+   !! ** Equivalent variables                                             |
+   !!                                                                     |
+   !!-------------|-------------|---------------------------------|-------|
+   !!                                                                     |
+   !! ht_i        | ht_i_b      |    Ice thickness                | m     |
+   !! ht_s        ! ht_s_b      |    Snow depth                   | m     |
+   !! sm_i        ! sm_i_b      |    Sea ice bulk salinity        ! ppt   |
+   !! s_i         ! s_i_b       |    Sea ice salinity profile     ! ppt   |
+   !! o_i         !      -      |    Sea ice Age                  ! days  |
+   !! t_i         ! t_i_b       |    Sea ice temperature          ! K     |
+   !! t_s         ! t_s_b       |    Snow temperature             ! K     |
+   !! t_su        ! t_su_b      |    Sea ice surface temperature  ! K     |
+   !!                                                                     |
+   !! notes: the ice model only sees a bulk (i.e., vertically averaged)   |
+   !!        salinity, except in thermodynamic computations, for which    |
+   !!        the salinity profile is computed as a function of bulk       |
+   !!        salinity                                                     |
+   !!                                                                     |
+   !!        the sea ice surface temperature is not associated to any     |
+   !!        heat content. Therefore, it is not a state variable and      |
+   !!        does not have to be advected. Nevertheless, it has to be     |
+   !!        computed to determine whether the ice is melting or not      |
+   !!                                                                     |
+   !! ******************************************************************* |
+   !! ***         Category-summed state variables (diagnostic)        *** |
+   !! ******************************************************************* |
+   !! at_i        | at_i_b      |    Total ice concentration      |       |
+   !! vt_i        |      -      |    Total ice vol. per unit area | m     |
+   !! vt_s        |      -      |    Total snow vol. per unit ar. | m     |
+   !! smt_i       |      -      |    Mean sea ice salinity        | ppt   |
+   !! tm_i        |      -      |    Mean sea ice temperature     | K     |
+   !! ot_i        !      -      !    Sea ice areal age content    | day   |
+   !! et_i        !      -      !    Total ice enthalpy           | 10^9 J| 
+   !! et_s        !      -      !    Total snow enthalpy          | 10^9 J| 
+   !! bv_i        !      -      !    Mean relative brine volume   | ???   | 
+   !!                                                                     |
+   !!                                                                     |
+   !!=====================================================================
+
+   LOGICAL, PUBLIC ::    &
+      con_i = .false.           ! switch for conservation test
+
+   !!--------------------------------------------------------------------------
+   !! * Share Module variables
+   !!--------------------------------------------------------------------------
+   REAL(wp), PUBLIC ::   rdt_ice      !: ice time step
+
+   INTEGER , PUBLIC ::   &     !!: ** ice-dynamic namelist (namicedyn) **
+      nbiter = 1      ,  &     !: number of sub-time steps for relaxation
+      nbitdr = 250    ,  &     !: maximum number of iterations for relaxation
+      nevp   = 400    ,  &     !: number of iterations for subcycling
+      nlay_i = 5               !: number of layers in the ice
+
+   REAL(wp), PUBLIC ::   &     !!: ** ice-dynamic namelist (namicedyn) **
+      epsd   = 1.0e-20,  &     !: tolerance parameter for dynamic
+      alpha  = 0.5    ,  &     !: coefficient for semi-implicit coriolis
+      dm     = 0.6e+03,  &     !: diffusion constant for dynamics
+      om     = 0.5    ,  &     !: relaxation constant
+      resl   = 5.0e-05,  &     !: maximum value for the residual of relaxation
+      cw     = 5.0e-03,  &     !: drag coefficient for oceanic stress
+      angvg  = 0.0    ,  &     !: turning angle for oceanic stress
+      pstar  = 1.0e+04,  &     !: determines ice strength (N/M), Hibler JPO79
+      c_rhg  = 20.0   ,  &     !: determines changes in ice strength
+      etamn  = 0.0e+07,  &     !: minimun value for viscosity : has to be 0
+      creepl = 2.0e-08,  &     !: creep limit : has to be under 1.0e-9
+      ecc    = 2.0    ,  &  !: eccentricity of the elliptical yield curve
+      ahi0   = 350.e0 ,  &  !: sea-ice hor. eddy diffusivity coeff. (m2/s)
+      telast = 2880.0 ,  &  !: timescale for elastic waves (s) !SB
+      alphaevp = 1.0  ,  &  !: coeficient of the internal stresses !SB
+      unit_fac = 1.0e9      !: conversion factor for ice / snow enthalpy
+
+   REAL(wp), PUBLIC ::   & !!: ** ice-salinity namelist (namicesal) **
+      s_i_max  = 20.0 ,  &  !: maximum ice salinity (ppt)
+      s_i_min  =  0.1 ,  &  !: minimum ice salinity (ppt)
+      s_i_0    =  3.5 ,  &  !: 1st sal. value for the computation of sal .prof.
+                                !: (ppt)
+      s_i_1    =  4.5 ,  &  !: 2nd sal. value for the computation of sal .prof.
+                                !: (ppt)
+      sal_G    = 5.00 ,  &  !: restoring salinity for gravity drainage
+                                !: (ppt)
+      sal_F    = 2.50 ,  &  !: restoring salinity for flushing
+                                !: (ppt)
+      time_G   = 1.728e+06,&!: restoring time constant for gravity drainage
+                                !: (= 20 days, in s)
+      time_F   = 8.640e+05,&!: restoring time constant for gravity drainage 
+                                !: (= 10 days, in s)
+      bulk_sal = 4.0        !: bulk salinity (ppt) in case of constant salinity
+
+   INTEGER , PUBLIC ::   & !!: ** ice-salinity namelist (namicesal) **
+      num_sal  = 1    ,  &  !: salinity configuration used in the model
+                                !: 1 - s constant in space and time
+                                !: 2 - prognostic salinity (s(z,t))
+                                !: 3 - salinity profile, constant in time
+                                !: 4 - salinity variations affect only ice
+                                !      thermodynamics
+      sal_prof = 1    ,  &  !: salinity profile or not 
+      thcon_i_swi = 1       !: thermal conductivity of Untersteiner (1964) (1) or
+   !: Pringle et al (2007) (2)
+
+   REAL(wp), PUBLIC ::   & !!: ** ice-mechanical redistribution namelist (namiceitdme)
+      Cs = 0.25       ,  & !!: fraction of shearing energy contributing to ridging            
+      Cf = 17.0       ,  & !!: ratio of ridging work to PE loss
+      fsnowrdg = 0.5  ,  & !!: fractional snow loss to the ocean during ridging
+      fsnowrft = 0.5  ,  & !!: fractional snow loss to the ocean during ridging
+      Gstar = 0.15    ,  & !!: fractional area of young ice contributing to ridging
+      astar = 0.05    ,  & !!: equivalent of G* for an exponential participation function
+      Hstar = 100.0   ,  & !!: thickness that determines the maximal thickness of ridged
+                                !!: ice
+      hparmeter = 0.75,  & !!: threshold thickness (m) for rafting / ridging 
+      Craft = 5.0     ,  & !!: coefficient for smoothness of the hyperbolic tangent in rafting
+      ridge_por = 0.0 ,  & !!: initial porosity of ridges (0.3 regular value)
+      sal_max_ridge = 15.0, & !!: maximum ridged ice salinity (ppt)
+      betas    = 1.0      , & !:: coef. for partitioning of snowfall between leads and sea ice
+      kappa_i  = 1.0      , & !!: coefficient for the extinction of radiation
+                                !!: Grenfell et al. (2006) (m-1)
+      nconv_i_thd = 50    , & !!: maximal number of iterations for heat diffusion
+      maxer_i_thd = 1.0e-4    !!: maximal tolerated error (C) for heat diffusion
+
+   INTEGER , PUBLIC ::   & !!: ** ice-mechanical redistribution namelist (namiceitdme)
+      ridge_scheme_swi = 0, & !!: scheme used for ice ridging
+      raftswi          = 1, & !!: rafting of ice or not                        
+      partfun_swi      = 1, & !!: participation function Thorndike et al. JGR75 (0) 
+                                !!: or Lipscomb et al. JGR07 (1) 
+      transfun_swi     = 0, & !!: transfer function of Hibler, MWR80 (0) 
+                                !!: or Lipscomb et al., 2007 (1)
+      brinstren_swi    = 0    !!: use brine volume to diminish ice strength
+
+   REAL(wp), PUBLIC ::   &  !:
+      usecc2          ,  &  !:  = 1.0 / ( ecc * ecc )
+      rhoco           ,  &  !: = rau0 * cw
+      sangvg, cangvg  ,  &  !: sin and cos of the turning angle for ocean stress
+      pstarh                !: pstar / 2.0
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &  !:
+      u_oce, v_oce    ,  &  !: surface ocean velocity used in ice dynamics
+      ahiu , ahiv     ,  &  !: hor. diffusivity coeff. at ocean U- and V-points (m2/s)
+      pahu , pahv     ,  &  !: ice hor. eddy diffusivity coef. at ocean U- and V-points
+      ust2s, hicol    ,  &  !: friction velocity, ice collection thickness accreted in leads
+      strength        ,  &  !: ice strength
+      strp1, strp2    ,  &  !: strength at previous time steps
+      stress1_i       ,  &  !: first stress tensor element
+      stress2_i       ,  &  !: second stress tensor element
+      stress12_i      ,  &  !: diagonal stress tensor element
+      delta_i         ,  &  !: Delta factor for the ice rheology (see Flato and Hibler 95) [s-1] -> limrhg.F90
+      divu_i          ,  &  !: Divergence of the velocity field [s-1] -> limrhg.F90
+      shear_i               !: Shear of the velocity field [s-1] -> limrhg.F90
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      firic  ,   &  !: IR flux over the ice (only used for outputs)
+      fcsic  ,   &  !: Sensible heat flux over the ice (only used for outputs)
+      fleic  ,   &  !: Latent heat flux over the ice (only used for outputs)
+      qlatic ,   &  !: latent flux
+      rdvosif,   &  !: Variation of volume at surface (only used for outputs)
+      rdvobif,   &  !: Variation of ice volume at the bottom ice (only used for outputs)
+      fdvolif,   &  !: Total variation of ice volume (only used for outputs)
+      rdvonif,   &  !: Lateral Variation of ice volume (only used for outputs)
+      sist   ,   &  !: Average Sea-Ice Surface Temperature (Kelvin)
+      icethi ,   &  !: total ice thickness (for all categories) (only used for outputs)
+      t_bo   ,   &  !: Sea-Ice bottom temperature (Kelvin)      
+      hicifp ,   &  !: Ice production/melting
+                                !obsolete... can be removed
+      frld   ,   &  !: Leads fraction = 1-a/totalarea REFERS TO LEAD FRACTION everywhere
+                                !: except in the OUTPUTS!!!!
+      pfrld  ,   &  !: Leads fraction at previous time  
+      phicif ,   &  !: Old ice thickness
+      fbif   ,   &  !: Heat flux at the ice base
+      rdmsnif,   &  !: Variation of snow mass
+      rdmicif,   &  !: Variation of ice mass
+      qldif  ,   &  !: heat balance of the lead (or of the open ocean)
+      qcmif  ,   &  !: Energy needed to bring the ocean surface layer until its freezing 
+      fdtcn  ,   &  !: net downward heat flux from the ice to the ocean
+      qdtcn  ,   &  !: energy from the ice to the ocean
+      fstric ,   &  !: transmitted solar radiation under ice
+      fscmbq ,   &  !: associated with lead chipotage with solar flux
+      ffltbif,   &  !: Array linked with the max heat contained in brine pockets (?)
+      fsbbq  ,   &  !: Also linked with the solar flux below the ice (?)
+      qfvbq  ,   &  !: Array used to store energy in case of toral lateral ablation (?)
+      dmgwi  ,   &  !: Variation of the mass of snow ice
+      fsalt_res, &  !: Residual salt flux due to correction of ice thickness
+      fsbri  ,   &  !: Salt flux due to brine rejection
+      fsalt_rpo, &  !: Salt flux associated with porous ridged ice formation
+      fheat_rpo, &  !: Heat flux associated with porous ridged ice formation
+      fhbri  ,   &  !: heat flux due to brine rejection
+      fmmec  ,   &  !: Mass flux due to snow loss during compression
+      fseqv  ,   &  !: Equivalent salt flux due to ice growth/melt
+      fheat_res, &  !: Residual heat flux due to correction of ice thickness
+      fhmec         !: Heat flux due to snow loss during compression
+
+   ! temporary arrays for dummy version of the code
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      dh_i_surf2D, dh_i_bott2D, fstbif, fsup2D, focea2D, q_s
+
+   INTEGER, PUBLIC, DIMENSION(jpi, jpj, jpl) ::          &   !::
+      patho_case ! number of the pathological case (if any, of course)
+
+   !!--------------------------------------------------------------------------
+   !! * Ice global state variables
+   !!--------------------------------------------------------------------------
+   !! Variables defined for each ice category
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl)        ::   &  !:
+      ht_i   ,   &  !: Ice thickness (m)
+      a_i    ,   &  !: Ice fractional areas (concentration)
+      v_i    ,   &  !: Ice volume per unit area (m)
+      v_s    ,   &  !: Snow volume per unit area(m)
+      ht_s   ,   &  !: Snow thickness (m)
+      t_su   ,   &  !: Sea-Ice Surface Temperature (K)
+      sm_i   ,   &  !: Sea-Ice Bulk salinity (ppt)
+      smv_i  ,   &  !: Sea-Ice Bulk salinity times volume per area (ppt.m)
+                                !: this is an extensive variable that has to be transported
+      o_i    ,   &  !: Sea-Ice Age (days)
+      ov_i   ,   &  !: Sea-Ice Age times volume per area (days.m)
+      oa_i          !: Sea-Ice Age times ice area (days)
+
+   !! Variables summed over all categories, or associated to 
+   !! all the ice in a single grid cell
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      u_ice, v_ice,   &  !: two components of the ice velocity (m/s)
+      tio_u, tio_v,   &  !: two components of the ice-ocean stress (N/m2)
+      vt_i        ,   &  !: ice total volume per unit area (m)
+      vt_s        ,   &  !: snow total volume per unit area (m)
+      at_i        ,   &  !: ice total fractional area (ice concentration)
+      ato_i       ,   &  !: total open water fractional area (1-at_i)
+      et_i        ,   &  !: total ice heat content
+      et_s        ,   &  !: total snow heat content
+      ot_i        ,   &  !: mean age over all categories
+      tm_i        ,   &  !: mean ice temperature over all categories
+      bv_i        ,   &  !: brine volume averaged over all categories
+      smt_i              !: mean sea ice salinity averaged over all categories
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpm) ::   &  !:
+      at_i_typ    ,   &  !: total area contained in each ice type
+      vt_i_typ           !: total volume contained in each ice type
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,nlay_s,jpl) :: & !:
+      t_s,            &  !: Snow temperatures (K)
+      e_s
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   &  !: ! go to trash
+      e_i_cat
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jkmax,jpl) :: & !:
+      t_i,            &  !: Ice temperatures     [ Kelvins     ]
+      e_i,            &  !: Ice thermal contents [ Joules*10^9 ]
+      s_i                !: Ice salinities
+
+   !!--------------------------------------------------------------------------
+   !! * Moments for advection
+   !!--------------------------------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   &  !:
+      sxopw, syopw, sxxopw, syyopw, sxyopw          !: open water in sea ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   &  !:
+      sxice, syice, sxxice, syyice, sxyice,      &  !: ice thickness moments for advection
+      sxsn,  sysn,  sxxsn,  syysn,  sxysn,       &  !: snow thickness
+      sxa,   sya,   sxxa,   syya,   sxya,        &  !: lead fraction
+      sxc0,  syc0,  sxxc0,  syyc0,  sxyc0,       &  !: snow thermal content
+      sxsal, sysal, sxxsal, syysal, sxysal,      &  !: ice salinity
+      sxage, syage, sxxage, syyage, sxyage          !: ice age
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jkmax,jpl) ::   &  !:
+      sxe ,  sye ,  sxxe ,  syye ,  sxye            !: ice layers heat content
+
+   !!--------------------------------------------------------------------------
+   !! * Old values of global variables
+   !!--------------------------------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   &  !: 
+      old_v_s, old_v_i,                          &  !: snow and ice volumes
+      old_a_i, old_smv_i, old_oa_i
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,nlay_s,jpl) ::   &  !:
+      old_e_s                                       !: snow heat content
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jkmax,jpl) ::   &  !:
+      old_e_i                          !: ice temperatures
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !: ice velocity (gv6 and gv7)
+      old_u_ice, old_v_ice
+
+   !!--------------------------------------------------------------------------
+   !! * Increment of global variables
+   !!--------------------------------------------------------------------------
+   ! thd refers to changes induced by thermodynamics
+   ! trp   ''         ''     ''       advection (transport of ice)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   &  !: 
+      d_a_i_thd  , d_a_i_trp ,                   &  !: icefractions                  
+      d_v_s_thd  , d_v_s_trp,                    &  !: snow volume
+      d_v_i_thd  , d_v_i_trp,                    &  !: ice  volume
+      d_smv_i_thd, d_smv_i_trp,                  &     
+      d_sm_i_fl  , d_sm_i_gd ,                   &
+      d_sm_i_se  , d_sm_i_si , d_sm_i_la ,       &
+      d_oa_i_thd , d_oa_i_trp, s_i_newice
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,nlay_s,jpl) ::  &  !:
+      d_e_s_thd, d_e_s_trp
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jkmax,jpl) ::   &  !:
+      d_e_i_thd, d_e_i_trp
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::       &  !: ice velocity 
+      d_u_ice_dyn, d_v_ice_dyn
+
+   !!--------------------------------------------------------------------------
+   !! * Ice thickness distribution variables
+   !!--------------------------------------------------------------------------
+   ! REMOVE
+   INTEGER, PUBLIC, DIMENSION(jpl)                ::   &  !:
+      ice_types      !: Vector making the connection between types and categories
+
+   INTEGER, PUBLIC, DIMENSION(jpm,2)              ::   &  !:
+      ice_cat_bounds !: Matrix containing the integer upper and 
+   !: lower boundaries of ice thickness categories
+
+   ! REMOVE
+   INTEGER, PUBLIC, DIMENSION(jpm)                ::   &  !:
+      ice_ncat_types !: Vector containing the number of thickness categories in each ice type
+
+   REAL(wp), PUBLIC, DIMENSION(0:jpl)             ::   &  !:
+      hi_max          !: Boundary of ice thickness categories in thickness space
+
+   REAL(wp), PUBLIC, DIMENSION(jpl)               ::   &  !:
+      hi_mean         !: Mean ice thickness in catgories 
+
+   ! REMOVE
+   REAL(wp), PUBLIC, DIMENSION(0:jpl,jpm)         ::   &  !:
+      hi_max_typ     !: Boundary of ice thickness categories 
+   !:in thickness space (same but specific for each ice type)
+
+   !!--------------------------------------------------------------------------
+   !! * Ice Run
+   !!--------------------------------------------------------------------------
+   !! Namelist namicerun read in iceini
+   CHARACTER(len=32)     , PUBLIC ::   cn_icerst_in  = "restart_ice_in"   !: suffix of ice restart name (input)
+   CHARACTER(len=32)     , PUBLIC ::   cn_icerst_out = "restart_ice"      !: suffix of ice restart name (output)
+   LOGICAL               , PUBLIC ::   ln_limdyn     = .TRUE.             !: flag for ice dynamics (T) or not (F)
+   LOGICAL               , PUBLIC ::   ln_nicep      = .TRUE.             !: flag for sea-ice points output (T) or not (F)
+   REAL(wp)              , PUBLIC ::   hsndif        = 0.e0               !: computation of temp. in snow (0) or not (9999)
+   REAL(wp)              , PUBLIC ::   hicdif        = 0.e0               !: computation of temp. in ice (0) or not (9999)
+   REAL(wp)              , PUBLIC ::   cai           = 1.40e-3            !: atmospheric drag over sea ice
+   REAL(wp)              , PUBLIC ::   cao           = 1.00e-3            !: atmospheric drag over ocean
+   REAL(wp), DIMENSION(2), PUBLIC ::   acrit  = (/ 1.e-06 , 1.e-06 /)     !: minimum fraction for leads in
+   !                                                                      !: north and south hemisphere
+   !!--------------------------------------------------------------------------
+   !! * Ice diagnostics
+   !!--------------------------------------------------------------------------
+   !! Check if everything down here is necessary
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !: volume of ice formed in the leads
+      v_newice
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   &  !: thermodynamic growth rates 
+      dv_dt_thd,  &
+      izero, fstroc, fhbricat
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   & 
+      diag_sni_gr,                           & ! snow ice growth 
+      diag_lat_gr,                           & ! lateral ice growth 
+      diag_bot_gr,                           & ! bottom ice growth 
+      diag_dyn_gr,                           & ! dynamical ice growth 
+      diag_bot_me,                           & ! vertical bottom melt 
+      diag_sur_me                              ! vertical surface melt
+   INTEGER , PUBLIC ::   jiindx, jjindx        !: indexes of the debugging point
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty module            NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE ice
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/iceini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/iceini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/iceini.F90	(revision 1844)
@@ -0,0 +1,276 @@
+MODULE iceini
+   !!======================================================================
+   !!                       ***  MODULE iceini   ***
+   !!   Sea-ice model : LIM Sea ice model Initialization
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM sea-ice model
+   !!----------------------------------------------------------------------
+   !!   ice_init       : sea-ice model initialization
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE in_out_manager
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE phycst          ! Define parameters for the routines
+   USE ice
+   USE limmsh
+   USE limistate
+   USE limrst
+   USE par_ice
+   USE limvar
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC ice_init                 ! called by opa.F90
+   PUBLIC lim_itd_ini
+
+   !! * Share Module variables
+   INTEGER , PUBLIC  ::   &  !:
+      nstart ,            &  !: iteration number of the begining of the run 
+      nlast  ,            &  !: iteration number of the end of the run 
+      nitrun ,            &  !: number of iteration
+      numit                  !: iteration number
+   REAL(wp), PUBLIC  ::   &  !:
+      tpstot                 !: time of the run in seconds
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ice_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_init  ***
+      !!
+      !! ** purpose :   
+      !!
+      !! History :
+      !!   2.0  !  02-08  (G. Madec)  F90: Free form and modules
+      !!   3.0  !  08-03  (M. Vancop) ITD, salinity, EVP-C
+      !!----------------------------------------------------------------------
+
+      ! Open the namelist file 
+      CALL ctl_opn( numnam_ice, 'namelist_ice', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+
+      CALL ice_run                    !  read in namelist some run parameters
+
+      ! Louvain la Neuve Ice model
+      IF( nacc == 1 ) THEN
+         rdt_ice = nn_fsbc * rdtmin
+      ELSE
+         rdt_ice = nn_fsbc * rdt
+      ENDIF
+
+      CALL lim_msh                    ! ice mesh initialization
+
+      CALL lim_itd_ini                ! initialize the ice thickness
+      ! distribution
+      ! Initial sea-ice state
+      IF( .NOT.ln_rstart ) THEN
+         numit = 0
+         numit = nit000 - 1
+         CALL lim_istate              ! start from rest: sea-ice deduced from sst
+         CALL lim_var_agg(1)          ! aggregate category variables in
+         ! bulk variables
+         CALL lim_var_glo2eqv         ! convert global variables in equivalent
+         ! variables
+      ELSE
+         CALL lim_rst_read            ! start from a restart file
+
+         numit = nit000 - 1
+         CALL lim_var_agg(1)          ! aggregate ice variables
+         CALL lim_var_glo2eqv         ! convert global var in equivalent variables
+      ENDIF
+
+      fr_i(:,:) = at_i(:,:)           ! initialisation of sea-ice fraction
+
+      nstart = numit  + nn_fsbc      
+      nitrun = nitend - nit000 + 1 
+      nlast  = numit  + nitrun 
+
+      IF( nstock == 0  )  nstock = nlast + 1
+
+   END SUBROUTINE ice_init
+
+   SUBROUTINE ice_run
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_run ***
+      !!                 
+      !! ** Purpose :   Definition some run parameter for ice model
+      !!
+      !! ** Method  :   Read the namicerun namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicerun
+      !!
+      !! history :
+      !!   2.0  !  03-08 (C. Ethe)  Original code
+      !!   3.0  !  08-03 (M. Vancop) LIM3
+      !!-------------------------------------------------------------------
+      NAMELIST/namicerun/ cn_icerst_in, cn_icerst_out, ln_limdyn, acrit, hsndif, hicdif, cai, cao, ln_nicep
+      !!-------------------------------------------------------------------
+
+      !                                           ! Read Namelist namicerun 
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice , namicerun )
+
+      IF( lk_mpp .AND. ln_nicep ) THEN
+         ln_nicep = .FALSE.
+         CALL ctl_warn( 'ice_run : specific control print for LIM3 desactivated with MPI' )
+      ENDIF       
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'ice_run : ice share parameters for dynamics/advection/thermo of sea-ice'
+         WRITE(numout,*) ' ~~~~~~'
+         WRITE(numout,*) '   switch for ice dynamics (1) or not (0)      ln_limdyn   = ', ln_limdyn
+         WRITE(numout,*) '   minimum fraction for leads in the NH (SH)  acrit(1/2)   = ', acrit(:)
+         WRITE(numout,*) '   computation of temp. in snow (=0) or not (=9999) hsndif = ', hsndif
+         WRITE(numout,*) '   computation of temp. in ice  (=0) or not (=9999) hicdif = ', hicdif
+         WRITE(numout,*) '   atmospheric drag over sea ice                           = ', cai
+         WRITE(numout,*) '   atmospheric drag over ocean                             = ', cao
+         WRITE(numout,*) '   Several ice points in the ice or not in ocean.output = ', ln_nicep
+      ENDIF
+
+   END SUBROUTINE ice_run
+
+   SUBROUTINE lim_itd_ini
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_ini ***
+      !! ** Purpose :
+      !!            Initializes the ice thickness distribution
+      !! ** Method  :
+      !!            Very simple. Currently there are no ice types in the
+      !!            model...
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External :
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (12-2005) Martin Vancoppenolle
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      !! * Local variables
+      INTEGER ::   jl,       &   ! ice category dummy loop index
+         jm            ! ice types    dummy loop index
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10,   & !
+         zc1                 ,   & !
+         zc2                 ,   & !
+         zc3                 ,   & !
+         zx1
+
+      IF(lwp) WRITE(numout,*) 'lim_itd_ini : Initialization of ice thickness distribution '
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+
+      !!-- End of declarations
+      !!------------------------------------------------------------------------------
+
+      !------------------------------------------------------------------------------!
+      ! 1) Ice thickness distribution parameters initialization    
+      !------------------------------------------------------------------------------!
+
+      !- Types boundaries (integer)
+      !----------------------------
+      ice_cat_bounds(1,1) = 1
+      ice_cat_bounds(1,2) = jpl
+
+      !- Number of ice thickness categories in each ice type
+      DO jm = 1, jpm
+         ice_ncat_types(jm) = ice_cat_bounds(jm,2) - ice_cat_bounds(jm,1) + 1 
+      END DO
+
+      !- Make the correspondence between thickness categories and ice types
+      !---------------------------------------------------------------------
+      DO jm = 1, jpm       !over types
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2) !over thickness categories
+            ice_types(jl) = jm
+         END DO
+      END DO
+
+      IF(lwp) THEN  
+         WRITE(numout,*) ' Number of ice types jpm =      ', jpm
+         WRITE(numout,*) ' Number of ice categories jpl = ', jpl
+         DO jm = 1, jpm
+            WRITE(numout,*) ' Ice type ', jm
+            WRITE(numout,*) ' Number of thickness categories ', ice_ncat_types(jm)
+            WRITE(numout,*) ' Thickness category boundaries  ', ice_cat_bounds(jm,1:2)
+         END DO
+         WRITE(numout,*) 'Ice type vector', ice_types(1:jpl)
+         WRITE(numout,*)
+      ENDIF
+
+      !- Thickness categories boundaries 
+      !----------------------------------
+      hi_max(:) = 0.0
+      hi_max_typ(:,:) = 0.0
+
+      !- Type 1 - undeformed ice
+      zc1 = 3./REAL(ice_cat_bounds(1,2)-ice_cat_bounds(1,1)+1)
+      zc2 = 10.0*zc1
+      zc3 = 3.0
+
+      DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2)
+         zx1 = REAL(jl-1) / REAL(ice_cat_bounds(1,2)-ice_cat_bounds(1,1)+1)
+         hi_max(jl) = hi_max(jl-1) + zc1 + zc2 * (1.0 + TANH ( zc3 * (zx1 - 1.0 ) ) )
+      END DO
+
+      !- Fill in the hi_max_typ vector, useful in other circumstances
+      ! Tricky trick
+      ! hi_max_typ is actually not used in the code and will be removed in a
+      ! next flyspray at this time, the tricky trick will also be removed
+      ! Martin, march 08
+      DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2)
+         hi_max_typ(jl,1) = hi_max(jl)
+      END DO
+
+      IF(lwp) WRITE(numout,*) ' Thickness category boundaries independently of ice type '
+      IF(lwp) WRITE(numout,*) ' hi_max ', hi_max(0:jpl)
+
+      IF(lwp) WRITE(numout,*) ' Thickness category boundaries inside ice types '
+      IF(lwp) THEN 
+         DO jm = 1, jpm
+            WRITE(numout,*) ' Type number ', jm
+            WRITE(numout,*) ' hi_max_typ : ', hi_max_typ(0:ice_ncat_types(jm),jm)
+         END DO
+      ENDIF
+
+      DO jl = 1, jpl
+         hi_mean(jl) = ( hi_max(jl) + hi_max(jl-1) ) / 2.0
+      END DO
+
+      tn_ice(:,:,:) = t_su(:,:,:)
+
+   END SUBROUTINE lim_itd_ini
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Empty module           NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ice_init        ! Empty routine
+   END SUBROUTINE ice_init
+
+   SUBROUTINE lim_itd_ini
+   END SUBROUTINE lim_itd_ini
+#endif
+
+   !!======================================================================
+END MODULE iceini
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limadv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limadv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limadv.F90	(revision 1844)
@@ -0,0 +1,409 @@
+MODULE limadv 
+   !!======================================================================
+   !!                       ***  MODULE limadv   ***
+   !! LIM sea-ice model : sea-ice advection
+   !!======================================================================
+   !! History :  LIM  ! 2008-03 (M. Vancoppenolle)  LIM-3 from LIM-2 code
+   !!            3.2  ! 2009-06 (F. Dupont)  correct a error in the North fold b. c.
+   !!--------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                     LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_adv_x  : advection of sea ice on x axis
+   !!   lim_adv_y  : advection of sea ice on y axis
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE dom_ice
+   USE ice
+   USE lbclnk
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_adv_x   ! called by lim_trp
+   PUBLIC   lim_adv_y   ! called by lim_trp
+
+   REAL(wp)  ::   epsi20 = 1.e-20   ! constant values
+   REAL(wp)  ::   rzero  = 0.e0     !    -       -
+   REAL(wp)  ::   rone   = 1.e0     !    -       -
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2,  UCL-LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_adv_x( pdf, put , pcrh, psm , ps0 ,   &
+      &                  psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_x  **
+      !!  
+      !! ** purpose :   Computes and adds the advection trend to sea-ice
+      !!              variable on i-axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects tracers
+      !!              but also theirquadratic forms. The method preserves
+      !!              tracer structures by conserving second order moments.
+      !!
+      !! Reference:  Prather, 1986, JGR, 91, D6. 6671-6681.
+      !!--------------------------------------------------------------------
+      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
+      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   put                ! i-direction ice velocity at U-point [m/s]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      !! 
+      INTEGER  ::   ji, jj                               ! dummy loop indices
+      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp, zin0   ! temporary scalars
+      REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
+      REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zf0, zfx , zfy , zbet   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfm, zfxx, zfyy, zfxy   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.                                           
+
+      zrdt = rdt_ice * pdf      ! If ice drift field is too fast, use an appropriate time step for advection.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zslpmax = MAX( rzero, ps0(ji,jj) )
+            zs1max  = 1.5 * zslpmax
+            zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj) ) )
+            zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
+               &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj) )  )
+            zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+
+            ps0 (ji,jj) = zslpmax  
+            psx (ji,jj) = zs1new      * zin0
+            psxx(ji,jj) = zs2new      * zin0
+            psy (ji,jj) = psy (ji,jj) * zin0
+            psyy(ji,jj) = psyy(ji,jj) * zin0
+            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+         END DO
+      END DO
+
+      !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
+      psm (:,:)  = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
+
+      !  Calculate fluxes and moments between boxes i<-->i+1              
+      DO jj = 1, jpj                      !  Flux from i to i+1 WHEN u GT 0 
+         DO ji = 1, jpi
+            zbet(ji,jj)  =  MAX( rzero, SIGN( rone, put(ji,jj) ) )
+            zalf         =  MAX( rzero, put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji,jj)
+            zalfq        =  zalf * zalf
+            zalf1        =  1.0 - zalf
+            zalf1q       =  zalf1 * zalf1
+            !
+            zfm (ji,jj)  =  zalf  *   psm (ji,jj)
+            zf0 (ji,jj)  =  zalf  * ( ps0 (ji,jj) + zalf1 * ( psx(ji,jj) + (zalf1 - zalf) * psxx(ji,jj) )  )
+            zfx (ji,jj)  =  zalfq * ( psx (ji,jj) + 3.0 * zalf1 * psxx(ji,jj) )
+            zfxx(ji,jj)  =  zalf  *   psxx(ji,jj) * zalfq
+            zfy (ji,jj)  =  zalf  * ( psy (ji,jj) + zalf1 * psxy(ji,jj) )
+            zfxy(ji,jj)  =  zalfq *   psxy(ji,jj)
+            zfyy(ji,jj)  =  zalf  *   psyy(ji,jj)
+
+            !  Readjust moments remaining in the box.
+            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+            psx (ji,jj)  =  zalf1q * ( psx(ji,jj) - 3.0 * zalf * psxx(ji,jj) )
+            psxx(ji,jj)  =  zalf1  * zalf1q * psxx(ji,jj)
+            psy (ji,jj)  =  psy (ji,jj) - zfy(ji,jj)
+            psyy(ji,jj)  =  psyy(ji,jj) - zfyy(ji,jj)
+            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 1, jpjm1                      !  Flux from i+1 to i when u LT 0.
+         DO ji = 1, fs_jpim1
+            zalf          = MAX( rzero, -put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji+1,jj) 
+            zalg  (ji,jj) = zalf
+            zalfq         = zalf * zalf
+            zalf1         = 1.0 - zalf
+            zalg1 (ji,jj) = zalf1
+            zalf1q        = zalf1 * zalf1
+            zalg1q(ji,jj) = zalf1q
+            !
+            zfm   (ji,jj) = zfm (ji,jj) + zalf  *   psm (ji+1,jj)
+            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0 (ji+1,jj) - zalf1 * ( psx(ji+1,jj) - (zalf1 - zalf ) * psxx(ji+1,jj) ) )
+            zfx   (ji,jj) = zfx (ji,jj) + zalfq * ( psx (ji+1,jj) - 3.0 * zalf1 * psxx(ji+1,jj) )
+            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *   psxx(ji+1,jj) * zalfq
+            zfy   (ji,jj) = zfy (ji,jj) + zalf  * ( psy (ji+1,jj) - zalf1 * psxy(ji+1,jj) )
+            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *   psxy(ji+1,jj)
+            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *   psyy(ji+1,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            !
+            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji-1,jj) )
+            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji-1,jj) )
+            psx (ji,jj) = zalg1q(ji-1,jj) * ( psx(ji,jj) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj) )
+            psxx(ji,jj) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj)
+            psy (ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) - zfy (ji-1,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) - zfyy(ji-1,jj) )
+            psxy(ji,jj) = zalg1q(ji-1,jj) * psxy(ji,jj)
+         END DO
+      END DO
+
+      !   Put the temporary moments into appropriate neighboring boxes.    
+      DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj)
+            zalf        = zbt * zfm(ji-1,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji-1,jj)
+            !
+            ps0 (ji,jj) = zbt * ( ps0(ji,jj) + zf0(ji-1,jj) ) + zbt1 * ps0(ji,jj)
+            psx (ji,jj) = zbt * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp ) + zbt1 * psx(ji,jj)
+            psxx(ji,jj) = zbt * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj)                               &
+               &                + 5.0 * ( zalf * zalf1 * ( psx (ji,jj) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  )   &
+               &                                                + zbt1 * psxx(ji,jj)
+            psxy(ji,jj) = zbt * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj)             &
+               &                + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj) ) )   &
+               &                                                + zbt1 * psxy(ji,jj)
+            psy (ji,jj) = zbt * ( psy (ji,jj) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj)
+            psyy(ji,jj) = zbt * ( psyy(ji,jj) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Flux from i+1 to i IF u LT 0.
+         DO ji = fs_2, fs_jpim1
+            zbt  =       zbet(ji,jj)
+            zbt1 = 1.0 - zbet(ji,jj)
+            psm(ji,jj)  = zbt * psm(ji,jj)  + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = - zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
+            !
+            ps0(ji,jj)  = zbt * ps0 (ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
+            psx(ji,jj)  = zbt * psx (ji,jj) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp )
+            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( zalf * zalf * zfxx(ji,jj)  + zalf1 * zalf1 * psxx(ji,jj)  &
+               &                                      + 5.0 *( zalf * zalf1 * ( - psx(ji,jj) + zfx(ji,jj) )      &
+               &                                      + ( zalf1 - zalf ) * ztemp ) )
+            psxy(ji,jj) = zbt * psxy(ji,jj) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)  &
+               &                                      + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj) )  )
+            psy(ji,jj)  = zbt * psy (ji,jj)  + zbt1 * ( psy (ji,jj) + zfy (ji,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj)  + zbt1 * ( psyy(ji,jj) + zfyy(ji,jj) )
+         END DO
+      END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T',  1. )   ;   CALL lbc_lnk( ps0 , 'T',  1. )
+      CALL lbc_lnk( psx , 'T', -1. )   ;   CALL lbc_lnk( psy , 'T', -1. )      ! caution gradient ==> the sign changes
+      CALL lbc_lnk( psxx, 'T',  1. )   ;   CALL lbc_lnk( psyy, 'T',  1. )
+      CALL lbc_lnk( psxy, 'T',  1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_x: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_x: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_x: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_x: psxy :')
+      ENDIF
+      !
+   END SUBROUTINE lim_adv_x
+
+
+   SUBROUTINE lim_adv_y( pdf, pvt , pcrh, psm , ps0 ,   &
+      &                  psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_y  **
+      !!            
+      !! ** purpose :   Computes and adds the advection trend to sea-ice 
+      !!              variable on y axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects tracers
+      !!              but also their quadratic forms. The method preserves 
+      !!              tracer structures by conserving second order moments.
+      !! 
+      !! Reference:  Prather, 1986, JGR, 91, D6. 6671-6681.
+      !!---------------------------------------------------------------------
+      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
+      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call lim_adv_x then lim_adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pvt                ! j-direction ice velocity at V-point [m/s]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      !!
+      INTEGER  ::   ji, jj                               ! dummy loop indices
+      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp, zin0   ! temporary scalars
+      REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
+      REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zf0, zfx , zfy , zbet   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfm, zfxx, zfyy, zfxy   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.
+
+      zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zslpmax = MAX( rzero, ps0(ji,jj) )
+            zs1max  = 1.5 * zslpmax
+            zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj) ) )
+            zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
+               &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj) )  )
+            zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+            !
+            ps0 (ji,jj) = zslpmax  
+            psx (ji,jj) = psx (ji,jj) * zin0
+            psxx(ji,jj) = psxx(ji,jj) * zin0
+            psy (ji,jj) = zs1new * zin0
+            psyy(ji,jj) = zs2new * zin0
+            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+         END DO
+      END DO
+
+      !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
+      psm(:,:)  = MAX(  pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20  )
+
+      !  Calculate fluxes and moments between boxes j<-->j+1              
+      DO jj = 1, jpj                     !  Flux from j to j+1 WHEN v GT 0   
+         DO ji = 1, jpi
+            zbet(ji,jj)  =  MAX( rzero, SIGN( rone, pvt(ji,jj) ) )
+            zalf         =  MAX( rzero, pvt(ji,jj) ) * zrdt * e1v(ji,jj) / psm(ji,jj)
+            zalfq        =  zalf * zalf
+            zalf1        =  1.0 - zalf
+            zalf1q       =  zalf1 * zalf1
+            !
+            zfm (ji,jj)  =  zalf  * psm(ji,jj)
+            zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psy(ji,jj)  + (zalf1-zalf) * psyy(ji,jj)  ) ) 
+            zfy (ji,jj)  =  zalfq *( psy(ji,jj) + 3.0*zalf1*psyy(ji,jj) )
+            zfyy(ji,jj)  =  zalf  * zalfq * psyy(ji,jj)
+            zfx (ji,jj)  =  zalf  * ( psx(ji,jj) + zalf1 * psxy(ji,jj) )
+            zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
+            zfxx(ji,jj)  =  zalf  * psxx(ji,jj)
+            !
+            !  Readjust moments remaining in the box.
+            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+            psy (ji,jj)  =  zalf1q * ( psy(ji,jj) -3.0 * zalf * psyy(ji,jj) )
+            psyy(ji,jj)  =  zalf1 * zalf1q * psyy(ji,jj)
+            psx (ji,jj)  =  psx (ji,jj) - zfx(ji,jj)
+            psxx(ji,jj)  =  psxx(ji,jj) - zfxx(ji,jj)
+            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+         END DO
+      END DO
+      !
+      DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
+         DO ji = 1, jpi
+            zalf          = ( MAX(rzero, -pvt(ji,jj) ) * zrdt * e1v(ji,jj) ) / psm(ji,jj+1) 
+            zalg  (ji,jj) = zalf
+            zalfq         = zalf * zalf
+            zalf1         = 1.0 - zalf
+            zalg1 (ji,jj) = zalf1
+            zalf1q        = zalf1 * zalf1
+            zalg1q(ji,jj) = zalf1q
+            !
+            zfm   (ji,jj) = zfm (ji,jj) + zalf  *   psm (ji,jj+1)
+            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0 (ji,jj+1) - zalf1 * (psy(ji,jj+1) - (zalf1 - zalf ) * psyy(ji,jj+1) ) )
+            zfy   (ji,jj) = zfy (ji,jj) + zalfq * ( psy (ji,jj+1) - 3.0 * zalf1 * psyy(ji,jj+1) )
+            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *   psyy(ji,jj+1) * zalfq
+            zfx   (ji,jj) = zfx (ji,jj) + zalf  * ( psx (ji,jj+1) - zalf1 * psxy(ji,jj+1) )
+            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *   psxy(ji,jj+1)
+            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *   psxx(ji,jj+1)
+         END DO
+      END DO
+
+      !  Readjust moments remaining in the box. 
+      DO jj = 2, jpj
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj-1)
+            zbt1 = ( 1.0 - zbet(ji,jj-1) )
+            !
+            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji,jj-1) )
+            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji,jj-1) )
+            psy (ji,jj) = zalg1q(ji,jj-1) * ( psy(ji,jj) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj) )
+            psyy(ji,jj) = zalg1 (ji,jj-1) * zalg1q(ji,jj-1) * psyy(ji,jj)
+            psx (ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) - zfx (ji,jj-1) )
+            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) - zfxx(ji,jj-1) )
+            psxy(ji,jj) = zalg1q(ji,jj-1) * psxy(ji,jj)
+         END DO
+      END DO
+
+      !   Put the temporary moments into appropriate neighboring boxes.    
+      DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj-1)
+            zbt1 = ( 1.0 - zbet(ji,jj-1) )
+            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj) 
+            zalf        = zbt * zfm(ji,jj-1) / psm(ji,jj) 
+            zalf1       = 1.0 - zalf
+            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji,jj-1)
+            !
+            ps0(ji,jj)  = zbt  * ( ps0(ji,jj) + zf0(ji,jj-1) ) + zbt1 * ps0(ji,jj)
+            psy(ji,jj)  = zbt  * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj) + 3.0 * ztemp )   &
+               &                                               + zbt1 * psy(ji,jj)  
+            psyy(ji,jj) = zbt  * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj)                             &
+               &                 + 5.0 * ( zalf * zalf1 * ( psy(ji,jj) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) )   & 
+               &                                               + zbt1 * psyy(ji,jj)
+            psxy(ji,jj) = zbt  * (  zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj)               &
+               &                  + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj) )  )   &
+               &                                                + zbt1 * psxy(ji,jj)
+            psx (ji,jj) = zbt * ( psx (ji,jj) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj)
+            psxx(ji,jj) = zbt * ( psxx(ji,jj) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                   !  Flux from j+1 to j IF v LT 0.
+         DO ji = 1, jpi
+            zbt  =         zbet(ji,jj)
+            zbt1 = ( 1.0 - zbet(ji,jj) )
+            psm(ji,jj)  = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = - zalf * ps0 (ji,jj) + zalf1 * zf0(ji,jj)
+            ps0 (ji,jj) =   zbt  * ps0 (ji,jj) + zbt1  * ( ps0(ji,jj) + zf0(ji,jj) )
+            psy (ji,jj) =   zbt  * psy (ji,jj) + zbt1  * ( zalf * zfy(ji,jj) + zalf1 * psy(ji,jj) + 3.0 * ztemp )
+            psyy(ji,jj) =   zbt  * psyy(ji,jj) + zbt1 * (  zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj)   &
+               &                                         + 5.0 *( zalf *zalf1 *( -psy(ji,jj) + zfy(ji,jj) )          &
+               &                                         + ( zalf1 - zalf ) * ztemp )                                )
+            psxy(ji,jj) =   zbt  * psxy(ji,jj) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)       &
+               &                                         + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj) )  )
+            psx (ji,jj) =   zbt  * psx (ji,jj) + zbt1 * ( psx (ji,jj) + zfx (ji,jj) )
+            psxx(ji,jj) =   zbt  * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) + zfxx(ji,jj) )
+         END DO
+      END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T',  1. )   ;   CALL lbc_lnk( ps0 , 'T',  1. )
+      CALL lbc_lnk( psx , 'T', -1. )   ;   CALL lbc_lnk( psy , 'T', -1. )      ! caution gradient ==> the sign changes
+      CALL lbc_lnk( psxx, 'T',  1. )   ;   CALL lbc_lnk( psyy, 'T',  1. )
+      CALL lbc_lnk( psxy, 'T',  1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_y: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_y: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_y: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_y: psxy :')
+      ENDIF
+      !
+   END SUBROUTINE lim_adv_y
+
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy module         NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE limadv
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limcons.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limcons.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limcons.F90	(revision 1844)
@@ -0,0 +1,235 @@
+MODULE limcons
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!
+   !!======================================================================
+   !!                     ***  MODULE  limcons  ***
+   !!
+   !! This module checks whether
+   !!   Ice Total Energy
+   !!   Ice Total Mass
+   !!   Salt Mass
+   !! Are conserved !
+   !! 
+   !!======================================================================
+   !!    lim_cons   :   checks whether energy/mass are conserved 
+   !!----------------------------------------------------------------------
+   !!
+   !! * Modules used
+
+   USE par_ice
+   USE dom_oce
+   USE dom_ice
+   USE ice
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_column_sum
+   PUBLIC lim_column_sum_energy
+   PUBLIC lim_cons_check
+
+   !! * Module variables
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !===============================================================================
+
+   SUBROUTINE lim_column_sum(nsum,xin,xout)
+      !     !!-------------------------------------------------------------------
+      !     !!               ***  ROUTINE lim_column_sum ***
+      !     !!
+      !     !! ** Purpose : Compute the sum of xin over nsum categories
+      !     !!
+      !     !! ** Method  : Arithmetics
+      !     !!
+      !     !! ** Action  : Gets xin(ji,jj,jl) and computes xout(ji,jj)
+      !     !!
+      !     !! History :
+      !     !!   author: William H. Lipscomb, LANL
+      !     !!   2.1  !  04-06  (M. Vancoppenolle)   Energy Conservation 
+      !     !!---------------------------------------------------------------------
+      !     !! * Local variables
+      INTEGER, INTENT(in) ::     &
+         nsum                  ! number of categories/layers
+
+      REAL (wp), DIMENSION(jpi, jpj, jpl), INTENT(IN) ::   &
+         xin                   ! input field
+
+      REAL (wp), DIMENSION(jpi, jpj), INTENT(OUT) ::  &
+         xout                  ! output field
+      INTEGER ::                 &
+         ji, jj, jl         ! horizontal indices
+
+      !     !!---------------------------------------------------------------------
+      !     WRITE(numout,*) ' lim_column_sum '
+      !     WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
+
+      xout(:,:) = 0.00
+
+      DO jl = 1, nsum
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               xout(ji,jj) = xout(ji,jj) + xin(ji,jj,jl)
+            END DO ! ji 
+         END DO  ! jj 
+      END DO  ! jl 
+
+   END SUBROUTINE lim_column_sum
+
+   !===============================================================================
+
+   SUBROUTINE lim_column_sum_energy(nsum,nlay,xin,xout)
+
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_column_sum_energy ***
+      !!
+      !! ** Purpose : Compute the sum of xin over nsum categories
+      !!              and nlay layers
+      !!
+      !! ** Method  : Arithmetics
+      !!
+      !! ** Action  : Gets xin(ji,jj,jl) and computes xout(ji,jj)
+      !!
+      !! History :
+      !!   author: William H. Lipscomb, LANL
+      !!   2.1  !  04-06  (M. Vancoppenolle)   Energy Conservation 
+      !!---------------------------------------------------------------------
+      !! * Local variables
+      INTEGER, INTENT(in) ::  &
+         nsum,              &  !: number of categories
+         nlay                  !: number of vertical layers
+
+      REAL (wp), DIMENSION(jpi, jpj, jkmax, jpl), INTENT(IN) :: &
+         xin                   !: input field
+
+      REAL (wp), DIMENSION(jpi, jpj), INTENT(OUT) ::  &
+         xout                  !: output field
+
+      INTEGER ::              &
+         ji, jj,            &  !: horizontal indices
+         jk, jl                !: layer and category  indices
+      !!---------------------------------------------------------------------
+
+      !     WRITE(numout,*) ' lim_column_sum_energy '
+      !     WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~ '
+
+      xout(:,:) = 0.00
+
+      DO jl = 1, nsum
+         DO jk = 1, nlay 
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  xout(ji,jj) = xout(ji,jj) + xin(ji,jj,jk,jl)
+               END DO ! ji 
+            END DO  ! jj 
+         END DO  ! jk
+      END DO ! jl
+
+   END SUBROUTINE lim_column_sum_energy
+
+   !===============================================================================
+
+   SUBROUTINE lim_cons_check(x1, x2, max_err, fieldid)
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_cons_check ***
+      !!
+      !! ** Purpose : Test the conservation of a certain variable
+      !!              For each physical grid cell, check that initial 
+      !!              and final values
+      !!              of a conserved field are equal to within a small value.
+      !!
+      !! ** Method  :
+      !!
+      !! ** Action  : -
+      !! History :
+      !!   author: William H. Lipscomb, LANL
+      !!   2.1  !  04-06  (M. Vancoppenolle)   Energy Conservation 
+      !!---------------------------------------------------------------------
+      !! * Local variables
+
+      REAL (wp), DIMENSION(jpi, jpj), INTENT(IN) ::   &
+         x1 (jpi,jpj) , & !: initial field
+         x2 (jpi,jpj)     !: final field
+
+      REAL (wp) , INTENT ( IN )                  ::   &
+         max_err          !: max allowed error
+
+      REAL (wp)                                  ::   &
+         mean_error       !: mean error on error points
+
+      INTEGER                                    ::   &
+         num_error        !: number of g.c where there is a cons. error
+
+      CHARACTER(len=15) , INTENT(IN)             ::   &
+         fieldid          !: field identifyer
+
+      INTEGER ::              &
+         ji, jj           !: horizontal indices      
+
+      LOGICAL ::              &
+         conserv_err      !: = .true. if conservation check failed
+
+      !!---------------------------------------------------------------------
+      WRITE(numout,*) ' lim_cons_check '
+      WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
+
+      conserv_err = .FALSE.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF (ABS(x2(ji,jj) - x1(ji,jj)) .GT. max_err) THEN
+               conserv_err = .TRUE.
+            ENDIF
+         END DO
+      END DO
+
+      IF ( conserv_err ) THEN
+
+         num_error  = 0
+         mean_error = 0.0
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               IF (ABS(x2(ji,jj) - x1(ji,jj)) .GT. max_err ) THEN
+                  num_error  = num_error + 1
+                  mean_error = mean_error + ABS(x2(ji,jj) - x1(ji,jj))
+
+                  WRITE (numout,*) ' ALERTE 99 '
+                  WRITE (numout,*) ' Conservation error: ', fieldid
+                  WRITE (numout,*) ' Point         : ', ji, jj 
+                  WRITE (numout,*) ' lat, lon      : ', gphit(ji,jj), & 
+                     glamt(ji,jj)
+                  WRITE (numout,*) ' Initial value : ', x1(ji,jj)
+                  WRITE (numout,*) ' Final value   : ', x2(ji,jj)
+                  WRITE (numout,*) ' Difference    : ', x2(ji,jj) - x1(ji,jj)
+
+               ENDIF
+            END DO
+         END DO
+
+         IF ( num_error .GT. 0 ) mean_error = mean_error / num_error
+         WRITE(numout,*) ' Conservation check for : ', fieldid
+         WRITE(numout,*) ' Number of error points : ', num_error
+         WRITE(numout,*) ' Mean error on these pts: ', mean_error
+
+      ENDIF ! conserv_err
+
+   END SUBROUTINE lim_cons_check
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty module            NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+   !!======================================================================
+END MODULE limcons
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdia.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdia.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdia.F90	(revision 1844)
@@ -0,0 +1,617 @@
+MODULE limdia
+   !!======================================================================
+   !!                       ***  MODULE limdia   ***
+   !!                      diagnostics of ice model 
+   !!======================================================================
+   !! To add a new field
+   !! 1) in lim_dia : add its definition for both hemispheres if wished
+   !! 2) add the new titles in lim_dia_init
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_dia      : computation of the time evolution of keys var.
+   !!   lim_dia_init : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE in_out_manager
+   USE par_ice         ! ice parameters
+   USE dom_ice
+   USE ice
+   USE iceini
+   USE limistate
+   USE dom_oce
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_dia       ! called by ice_step
+
+   !! * Shared module variables
+   INTEGER, PUBLIC  ::  &
+      ntmoy   = 1 ,     &  !: instantaneous values of ice evolution or averaging ntmoy
+      ninfo   = 1          !: frequency of ouputs on file ice_evolu in case of averaging
+
+   !! * Module variables
+   INTEGER, PARAMETER ::   &  ! Parameters for outputs to files "evolu"
+      jpinfmx = 100         ,    &  ! maximum number of key variables
+      jpchinf = 5           ,    &  ! ???
+      jpchsep = jpchinf + 2         ! ???
+
+   INTEGER          ::  &
+      nfrinf  = 4    ,  &  ! number of variables written in one line 
+      nferme ,          &  ! last time step at which the var. are written on file
+      nvinfo ,          &  ! number of total variables 
+      nbvt   ,          &  ! number of time variables
+      naveg                ! number of step for accumulation before averaging
+
+   CHARACTER(len=8) ::  &
+      fmtinf  = '1PE13.5 ' ! format of the output values  
+
+   CHARACTER(len=30) :: &
+      fmtw  ,           &  ! formats
+      fmtr  ,           &  ! ???
+      fmtitr               ! ???
+
+   CHARACTER(len=jpchsep), DIMENSION(jpinfmx) ::   &
+      titvar               ! title of key variables
+
+   REAL(wp), DIMENSION(jpinfmx) ::  &
+      vinfom               ! temporary working space
+   REAL(wp) :: &
+      epsi06 = 1.e-06
+   REAL(wp), DIMENSION(jpi,jpj) ::   &
+      aire                 ! masked grid cell area
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dia
+      !!--------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dia  ***
+      !!   
+      !! ** Purpose : Computation and outputs on file ice.evolu 
+      !!      the temporal evolution of some key variables
+      !!
+      !! History :
+      !!   8.0  !  97-06  (Louvain-La-Neuve)  Original code
+      !!   8.5  !  02-09  (C. Ethe , G. Madec )  F90: Free form and module
+      !!   9.0  !  05-06  (M. Vancoppenolle LLN) Rehabilitation and fixing a few bugs
+      !!           01-07  (M. Vancoppenolle LLN) added new fields + fram strait
+      !!                                         export
+      !!-------------------------------------------------------------------
+      !! * Local variables
+      INTEGER  ::   jv,ji,jj,jl ! dummy loop indices
+      REAL(wp), DIMENSION(jpinfmx) ::  & 
+         vinfor           ! temporary working space 
+      REAL(wp) ::    &
+         zshift_date   , & ! date from the minimum ice extent
+         zday, zday_min, & ! current day, day of minimum extent
+         zafy, zamy,     & ! temporary area of fy and my ice
+         zindb
+      !!-------------------------------------------------------------------
+
+      ! 0) date from the minimum of ice extent
+      !---------------------------------------
+      zday_min = 273.0        ! zday_min = date of minimum extent, here September 30th
+      zday = FLOAT(numit-nit000) * rdt_ice / ( 86400.0 * FLOAT(nn_fsbc) )
+      IF (zday.GT.zday_min) THEN 
+         zshift_date  =  zday - zday_min
+      ELSE
+         zshift_date  =  zday - (365.0 - zday_min)
+      ENDIF
+
+      IF( numit == nstart )   CALL lim_dia_init   ! initialisation of ice_evolu file      
+
+      ! temporal diagnostics 
+      vinfor(1) = REAL(numit)
+      vinfor(2) = nyear
+
+      ! put everything to zero
+      DO jv = nbvt + 1, nvinfo
+         vinfor(jv) = 0.0
+      END DO
+
+      !!-------------------------------------------------------------------
+      !! 1) Northern hemisphere
+      !!-------------------------------------------------------------------
+      !! 1.1) Diagnostics independent on age
+      !!------------------------------------
+      DO jj = njeq, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               vinfor(3)  = vinfor(3)  + at_i(ji,jj)*aire(ji,jj) / 1.0e12 !ice area
+               IF (at_i(ji,jj).GT.0.15) vinfor(5) = vinfor(5) + aire(ji,jj) / 1.0e12 !ice extent
+               vinfor(7)  = vinfor(7)  + vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(9)  = vinfor(9)  + vt_s(ji,jj)*aire(ji,jj) / 1.0e12 !snow volume
+               vinfor(15) = vinfor(15) + ot_i(ji,jj) *vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !mean age
+               vinfor(29) = vinfor(29) + smt_i(ji,jj)*vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !mean salinity
+               ! the computation of this diagnostic is not reliable
+               vinfor(31) = vinfor(31) + vt_i(ji,jj)*( u_ice(ji,jj)*u_ice(ji,jj) + & 
+                  v_ice(ji,jj)*v_ice(ji,jj) )*aire(ji,jj)/1.0e12 
+               vinfor(53) = vinfor(53) + emps(ji,jj)*aire(ji,jj) / 1.0e12 !salt flux
+               vinfor(55) = vinfor(55) + fsbri(ji,jj)*aire(ji,jj) / 1.0e12 !brine drainage flux
+               vinfor(57) = vinfor(57) + fseqv(ji,jj)*aire(ji,jj) / 1.0e12 !equivalent salt flux
+               vinfor(59) = vinfor(59) +(sst_m(ji,jj)+rt0)*at_i(ji,jj)*aire(ji,jj) / 1.0e12  !SST
+               vinfor(61) = vinfor(61) + sss_m(ji,jj)*at_i(ji,jj)*aire(ji,jj) / 1.0e12  !SSS
+               vinfor(65) = vinfor(65) + et_s(ji,jj)/1.0e9*aire(ji,jj) / 1.0e12  ! snow temperature
+               vinfor(67) = vinfor(67) + et_i(ji,jj)/1.0e9*aire(ji,jj) / 1.0e12       ! ice heat content
+               vinfor(69) = vinfor(69) + v_i(ji,jj,1)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(71) = vinfor(71) + v_i(ji,jj,2)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(73) = vinfor(73) + v_i(ji,jj,3)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(75) = vinfor(75) + v_i(ji,jj,4)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(77) = vinfor(77) + v_i(ji,jj,5)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(79) = 0.0
+               vinfor(81) = vinfor(81) + emp(ji,jj)*aire(ji,jj) / 1.0e12 ! mass flux
+            ENDIF
+         END DO
+      END DO
+
+      DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2)
+         DO jj = njeq, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tms(ji,jj) == 1 ) THEN
+                  vinfor(11) = vinfor(11) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !undef def ice volume
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      vinfor(13) = 0.0
+
+      vinfor(15) = vinfor(15) / MAX(vinfor(7),epsi06) ! these have to be divided by total ice volume to have the
+      vinfor(29) = vinfor(29) / MAX(vinfor(7),epsi06) ! right value
+      vinfor(31) = SQRT( vinfor(31) / MAX( vinfor(7) , epsi06 ) )
+      vinfor(67) = vinfor(67) / MAX(vinfor(7),epsi06)
+
+      vinfor(53) = vinfor(53) / MAX(vinfor(5),epsi06) ! these have to be divided by total ice extent to have the
+      vinfor(55) = vinfor(55) / MAX(vinfor(5),epsi06) ! right value 
+      vinfor(57) = vinfor(57) / MAX(vinfor(5),epsi06) ! 
+      vinfor(79) = vinfor(79) / MAX(vinfor(5),epsi06) !
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(3))) !
+      vinfor(59) = zindb*vinfor(59) / MAX(vinfor(3),epsi06) ! divide by ice area
+      vinfor(61) = zindb*vinfor(61) / MAX(vinfor(3),epsi06) !
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(9))) !
+      vinfor(65) = zindb*vinfor(65) / MAX(vinfor(9),epsi06) ! divide it by snow volume
+
+
+      DO jl = 1, jpl
+         DO jj = njeq, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tms(ji,jj) == 1 ) THEN
+                  vinfor(33) = vinfor(33) + d_v_i_trp(ji,jj,jl)*aire(ji,jj) / 1.0e12 !ice volume
+                  vinfor(35) = vinfor(35) + d_v_i_thd(ji,jj,jl)*aire(ji,jj) / 1.0e12 !ice volume
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jj = njeq, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               vinfor(37) = vinfor(37) + diag_sni_gr(ji,jj)*aire(ji,jj) / 1.0e12 !th growth rates
+               vinfor(39) = vinfor(39) + diag_lat_gr(ji,jj)*aire(ji,jj) / 1.0e12 
+               vinfor(41) = vinfor(41) + diag_bot_gr(ji,jj)*aire(ji,jj) / 1.0e12
+               vinfor(43) = vinfor(43) + diag_dyn_gr(ji,jj)*aire(ji,jj) / 1.0e12 
+               vinfor(45) = vinfor(45) + dv_dt_thd(ji,jj,5)*aire(ji,jj) / 1.0e12
+               vinfor(47) = vinfor(47) + v_newice(ji,jj) *aire(ji,jj) / 1.0e12 / rdt_ice ! volume acc in OW
+            ENDIF
+         END DO
+      END DO
+
+      DO jl = 1, jpl
+         DO jj = njeq, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tms(ji,jj) == 1 ) THEN
+                  vinfor(63) = vinfor(63) + t_su(ji,jj,jl)*a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12
+               ENDIF
+            END DO
+         END DO
+      END DO
+      vinfor(63) = vinfor(63) / MAX(vinfor(3),epsi06) ! these have to be divided by total ice area
+
+      !! 1.2) Diagnostics dependent on age
+      !!------------------------------------
+      DO jj = njeq, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               zafy = 0.0
+               zamy = 0.0
+               DO jl = 1, jpl
+                  IF ((o_i(ji,jj,jl) - zshift_date).LT.0.0) THEN
+                     vinfor(17) = vinfor(17) + a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 ! FY ice area
+                     vinfor(25) = vinfor(25) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 ! FY ice volume
+                     vinfor(49) = vinfor(49) + sm_i(ji,jj,jl)*v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !FY ice salinity
+                     zafy = zafy + a_i(ji,jj,jl)
+                  ENDIF
+                  IF ((o_i(ji,jj,jl) - zshift_date).GT.0.0) THEN
+                     vinfor(19) = vinfor(19) + a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12    ! MY ice area
+                     vinfor(27) = vinfor(27) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 ! MY ice volume
+                     vinfor(51) = vinfor(51) + sm_i(ji,jj,jl)*v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !MY ice salinity
+                     zamy = zamy + a_i(ji,jj,jl)
+                  ENDIF
+               END DO
+               IF ((at_i(ji,jj).GT.0.15).AND.(zafy.GT.zamy)) THEN
+                  vinfor(21) = vinfor(21) + aire(ji,jj) / 1.0e12 ! Seasonal ice extent
+               ENDIF
+               IF ((at_i(ji,jj).GT.0.15).AND.(zafy.LE.zamy)) THEN
+                  vinfor(23) = vinfor(23) + aire(ji,jj) / 1.0e12 ! Perennial ice extent
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(25))) !=0 if no multiyear ice 1 if yes
+      vinfor(49) = zindb*vinfor(49) / MAX(vinfor(25),epsi06)
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(27))) !=0 if no multiyear ice 1 if yes
+      vinfor(51) = zindb*vinfor(51) / MAX(vinfor(27),epsi06)
+
+      !! Fram Strait Export
+      !! 83 = area export
+      !! 84 = volume export
+      !! Fram strait in ORCA2 = 5 points
+      !! export = -v_ice*e1t*ddtb*at_i or -v_ice*e1t*ddtb*at_i*h_i
+      jj = 136 ! C grid
+      vinfor(83) = 0.0
+      vinfor(84) = 0.0
+      DO ji = 134, 138
+         vinfor(83) = vinfor(83) - v_ice(ji,jj) * & 
+            e1t(ji,jj)*at_i(ji,jj)*rdt_ice / 1.0e12
+         vinfor(84) = vinfor(84) - v_ice(ji,jj) * & 
+            e1t(ji,jj)*vt_i(ji,jj)*rdt_ice / 1.0e12
+      END DO
+
+      !!-------------------------------------------------------------------
+      !! 2) Southern hemisphere
+      !!-------------------------------------------------------------------
+      !! 2.1) Diagnostics independent on age
+      !!------------------------------------
+      DO jj = 2, njeqm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               vinfor(4)  = vinfor(4)  + at_i(ji,jj)*aire(ji,jj) / 1.0e12 !ice area
+               IF (at_i(ji,jj).GT.0.15) vinfor(6) = vinfor(6) + aire(ji,jj) / 1.0e12 !ice extent
+               vinfor(8)  = vinfor(8)  + vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(10) = vinfor(10) + vt_s(ji,jj)*aire(ji,jj) / 1.0e12 !snow volume
+               vinfor(16) = vinfor(16) + ot_i(ji,jj)*vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !mean age
+               vinfor(30) = vinfor(30) + smt_i(ji,jj)*vt_i(ji,jj)*aire(ji,jj) / 1.0e12 !mean salinity
+               ! this diagnostic is not well computed (weighted by vol instead
+               ! of area)
+               vinfor(32) = vinfor(32) + vt_i(ji,jj)*( u_ice(ji,jj)*u_ice(ji,jj) + & 
+                  v_ice(ji,jj)*v_ice(ji,jj) )*aire(ji,jj)/1.0e12 !ice vel
+               vinfor(54) = vinfor(54) + at_i(ji,jj)*emps(ji,jj)*aire(ji,jj) / 1.0e12 ! Total salt flux
+               vinfor(56) = vinfor(56) + at_i(ji,jj)*fsbri(ji,jj)*aire(ji,jj) / 1.0e12 ! Brine drainage salt flux
+               vinfor(58) = vinfor(58) + at_i(ji,jj)*fseqv(ji,jj)*aire(ji,jj) / 1.0e12 ! Equivalent salt flux
+               vinfor(60) = vinfor(60) +(sst_m(ji,jj)+rt0)*at_i(ji,jj)*aire(ji,jj) / 1.0e12  !SST
+               vinfor(62) = vinfor(62) + sss_m(ji,jj)*at_i(ji,jj)*aire(ji,jj) / 1.0e12  !SSS
+               vinfor(66) = vinfor(66) + et_s(ji,jj)/1.0e9*aire(ji,jj) / 1.0e12 ! snow temperature
+               vinfor(68) = vinfor(68) + et_i(ji,jj)/1.0e9*aire(ji,jj) / 1.0e12 ! ice enthalpy
+               vinfor(70) = vinfor(70) + v_i(ji,jj,1)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(72) = vinfor(72) + v_i(ji,jj,2)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(74) = vinfor(74) + v_i(ji,jj,3)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(76) = vinfor(76) + v_i(ji,jj,4)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(78) = vinfor(78) + v_i(ji,jj,5)*aire(ji,jj) / 1.0e12 !ice volume
+               vinfor(80) = 0.0
+               vinfor(82) = vinfor(82) + emp(ji,jj)*aire(ji,jj) / 1.0e12 ! mass flux
+            ENDIF
+         END DO
+      END DO
+
+      DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2)
+         DO jj = 2, njeqm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               vinfor(12) = vinfor(12) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !undef def ice volume
+            END DO
+         END DO
+      END DO
+
+      vinfor(14) = 0.0
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(8))) 
+      vinfor(16) = zindb * vinfor(16) / MAX(vinfor(8),epsi06) ! these have to be divided by ice vol
+      vinfor(30) = zindb * vinfor(30) / MAX(vinfor(8),epsi06) ! 
+      vinfor(32) = zindb * SQRT( vinfor(32) / MAX( vinfor(8) , epsi06 ) )
+      vinfor(68) = zindb * vinfor(68) / MAX(vinfor(8),epsi06) ! 
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(6))) 
+      vinfor(54) = zindb * vinfor(54) / MAX(vinfor(6),epsi06) ! these have to be divided by ice extt
+      vinfor(56) = zindb * vinfor(56) / MAX(vinfor(6),epsi06) ! 
+      vinfor(58) = zindb * vinfor(58) / MAX(vinfor(6),epsi06) ! 
+      vinfor(80) = zindb * vinfor(80) / MAX(vinfor(6),epsi06) !
+      !      vinfor(84) = vinfor(84) / vinfor(6) !
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(4))) !
+      vinfor(60) = zindb*vinfor(60) / ( MAX(vinfor(4), epsi06) ) ! divide by ice area
+      vinfor(62) = zindb*vinfor(62) / ( MAX(vinfor(4), epsi06) ) !
+
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(10))) !
+      vinfor(66) = zindb*vinfor(66) / MAX(vinfor(10),epsi06) ! divide it by snow volume
+
+      DO jl = 1, jpl
+         DO jj = 2, njeqm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tms(ji,jj) == 1 ) THEN
+                  vinfor(34) = vinfor(34) + d_v_i_trp(ji,jj,jl)*aire(ji,jj) / 1.0e12 !ice volume
+                  vinfor(36) = vinfor(36) + d_v_i_thd(ji,jj,jl)*aire(ji,jj) / 1.0e12 !ice volume
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jj = 2, njeqm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               vinfor(38) = vinfor(38) + diag_sni_gr(ji,jj)*aire(ji,jj) / 1.0e12 !th growth rates
+               vinfor(40) = vinfor(40) + diag_lat_gr(ji,jj)*aire(ji,jj) / 1.0e12 
+               vinfor(42) = vinfor(42) + diag_bot_gr(ji,jj)*aire(ji,jj) / 1.0e12
+               vinfor(44) = vinfor(44) + diag_dyn_gr(ji,jj)*aire(ji,jj) / 1.0e12 
+               vinfor(46) = vinfor(46) + dv_dt_thd(ji,jj,5)*aire(ji,jj) / 1.0e12
+               vinfor(48) = vinfor(48) + v_newice(ji,jj) *aire(ji,jj) / 1.0e12 / rdt_ice ! volume acc in OW
+            ENDIF
+         END DO
+      END DO
+
+
+      DO jl = 1, jpl
+         DO jj = 2, njeqm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tms(ji,jj) == 1 ) THEN
+                  vinfor(64) = vinfor(64) + t_su(ji,jj,jl)*a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12
+               ENDIF
+            END DO
+         END DO
+      END DO
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(4))) !
+      vinfor(64) = zindb * vinfor(64) / MAX(vinfor(4),epsi06) ! divide by ice extt
+      !! 2.2) Diagnostics dependent on age
+      !!------------------------------------
+      DO jj = 2, njeqm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               zafy = 0.0
+               zamy = 0.0
+               DO jl = 1, jpl
+                  IF ((o_i(ji,jj,jl) - zshift_date).LT.0.0) THEN
+                     vinfor(18) = vinfor(18) + a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 ! FY ice area
+                     vinfor(26) = vinfor(26) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 ! FY ice volume
+                     zafy = zafy + a_i(ji,jj,jl)
+                     vinfor(50) = vinfor(50) + sm_i(ji,jj,jl)*v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !FY ice salinity
+                  ENDIF
+                  IF ((o_i(ji,jj,jl) - zshift_date).GT.0.0) THEN
+                     vinfor(20) = vinfor(20) + a_i(ji,jj,jl)*aire(ji,jj) / 1.0e12    ! MY ice area
+                     vinfor(28) = vinfor(28) + v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12
+                     vinfor(52) = vinfor(52) + sm_i(ji,jj,jl)*v_i(ji,jj,jl)*aire(ji,jj) / 1.0e12 !FY ice salinity
+                     zamy = zamy + a_i(ji,jj,jl)
+                  ENDIF
+               END DO ! jl
+               IF ((at_i(ji,jj).GT.0.15).AND.(zafy.GT.zamy)) THEN
+                  vinfor(22) = vinfor(22) + aire(ji,jj) / 1.0e12 ! Seasonal ice extent
+               ENDIF
+               IF ((at_i(ji,jj).GT.0.15).AND.(zafy.LE.zamy)) THEN
+                  vinfor(24) = vinfor(24) + aire(ji,jj) / 1.0e12 ! Perennial ice extent
+               ENDIF
+            ENDIF ! tms
+         END DO ! jj
+      END DO ! ji
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(26))) !=0 if no multiyear ice 1 if yes
+      vinfor(50) = zindb*vinfor(50) / MAX(vinfor(26),epsi06)
+      zindb      = 1.0 - MAX(0.0,SIGN(1.0,-vinfor(28))) !=0 if no multiyear ice 1 if yes
+      vinfor(52) = zindb*vinfor(52) / MAX(vinfor(28),epsi06)
+
+      !  Accumulation before averaging 
+      DO jv = 1, nvinfo
+         vinfom(jv) = vinfom(jv) + vinfor(jv)
+      END DO
+      naveg = naveg + 1  
+
+      ! oututs on file ice_evolu    
+      !MV      IF( MOD( numit , ninfo ) == 0 ) THEN
+      WRITE(numevo_ice,fmtw) ( titvar(jv), vinfom(jv)/naveg, jv = 1, nvinfo )
+      naveg = 0
+      DO jv = 1, nvinfo
+         vinfom(jv)=0.0
+      END DO
+      !MV      ENDIF
+
+   END SUBROUTINE lim_dia
+
+   SUBROUTINE lim_dia_init
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dia_init  ***
+      !!             
+      !! ** Purpose : Preparation of the file ice_evolu for the output of
+      !!      the temporal evolution of key variables
+      !!
+      !! ** input   : Namelist namicedia
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!  9.0  ! 08-03 (M. Vancoppenolle) LIM3
+      !!-------------------------------------------------------------------
+      NAMELIST/namicedia/fmtinf, nfrinf, ninfo, ntmoy
+
+      INTEGER  ::   jv   ,     &  ! dummy loop indice
+         &          ntot ,     &
+         &          ndeb
+
+      REAL(wp) ::   zxx0, zxx1    ! temporary scalars
+
+      CHARACTER(len=jpchinf) ::   titinf
+      !!-------------------------------------------------------------------
+
+
+      ! Read Namelist namicedia
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicedia )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_dia_init : ice parameters for ice diagnostics '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   format of the output values                                 fmtinf = ', fmtinf
+         WRITE(numout,*) '   number of variables written in one line                     nfrinf = ', nfrinf 
+         WRITE(numout,*) '   Instantaneous values of ice evolution or averaging          ntmoy  = ', ntmoy
+         WRITE(numout,*) '   frequency of ouputs on file ice_evolu in case of averaging  ninfo  = ', ninfo
+      ENDIF
+
+      ! masked grid cell area
+      aire(:,:) = area(:,:) * tms(:,:)
+
+      ! Titles of ice key variables :
+      titvar(1) = 'NoIt'  ! iteration number
+      titvar(2) = 'T yr'  ! time step in years
+      nbvt = 2            ! number of time variables
+
+      titvar(3) = 'AI_N'  ! sea ice area in the northern Hemisp.(10^12 km2)
+      titvar(4) = 'AI_S'  ! sea ice area in the southern Hemisp.(10^12 km2)
+      titvar(5) = 'EI_N'  ! sea ice extent (15%) in the northern Hemisp.(10^12 km2)
+      titvar(6) = 'EI_S'  ! sea ice extent (15%) in the southern Hemisp.(10^12 km2)
+      titvar(7) = 'VI_N'  ! sea ice volume in the northern Hemisp.(10^3 km3)
+      titvar(8) = 'VI_S'  ! sea ice volume in the southern Hemisp.(10^3 km3)
+      titvar(9) = 'VS_N'  ! snow volume over sea ice in the northern Hemisp.(10^3 km3)
+      titvar(10)= 'VS_S'  ! snow volume over sea ice in the northern Hemisp.(10^3 km3)
+      titvar(11)= 'VuIN'  ! undeformed sea ice volume in the northern Hemisp.(10^3 km3)
+      titvar(12)= 'VuIS'  ! undeformed sea ice volume in the southern Hemisp.(10^3 km3)
+      titvar(13)= 'VdIN'  ! deformed sea ice volume in the northern Hemisp.(10^3 km3)
+      titvar(14)= 'VdIS'  ! deformed sea ice volume in the southern Hemisp.(10^3 km3)
+      titvar(15)= 'OI_N'  ! sea ice mean age in the northern Hemisp.(years)
+      titvar(16)= 'OI_S'  ! sea ice mean age in the southern Hemisp.(years)
+      titvar(17)= 'AFYN'  ! total FY ice area northern Hemisp.(10^12 km2)
+      titvar(18)= 'AFYS'  ! total FY ice area southern Hemisp.(10^12 km2)
+      titvar(19)= 'AMYN'  ! total MY ice area northern Hemisp.(10^12 km2)
+      titvar(20)= 'AMYS'  ! total MY ice area southern Hemisp.(10^12 km2)
+      titvar(21)= 'EFYN'  ! total FY ice extent northern Hemisp.(10^12 km2) (with more 50% FY ice)
+      titvar(22)= 'EFYS'  ! total FY ice extent southern Hemisp.(10^12 km2) (with more 50% FY ice)
+      titvar(23)= 'EMYN'  ! total MY ice extent northern Hemisp.(10^12 km2) (with more 50% MY ice)
+      titvar(24)= 'EMYS'  ! total MY ice extent southern Hemisp.(10^12 km2) (with more 50% MY ice)
+      titvar(25)= 'VFYN'  ! total undeformed FY ice volume northern Hemisp.(10^3 km3) 
+      titvar(26)= 'VFYS'  ! total undeformed FY ice volume southern Hemisp.(10^3 km3)
+      titvar(27)= 'VMYN'  ! total undeformed MY ice volume northern Hemisp.(10^3 km3) 
+      titvar(28)= 'VMYS'  ! total undeformed MY ice volume southern Hemisp.(10^3 km3) 
+      titvar(29)= 'IS_N'  ! sea ice mean salinity in the northern hemisphere (ppt)  
+      titvar(30)= 'IS_S'  ! sea ice mean salinity in the southern hemisphere (ppt)  
+      titvar(31)= 'IVeN'  ! sea ice mean velocity in the northern hemisphere (m/s) 
+      titvar(32)= 'IVeS'  ! sea ice mean velocity in the southern hemisphere (m/s) 
+      titvar(33)= 'DVDN'  ! variation of sea ice volume due to dynamics in the northern hemisphere
+      titvar(34)= 'DVDS'  ! variation of sea ice volume due to dynamics in the southern hemisphere
+      titvar(35)= 'DVTN'  ! variation of sea ice volume due to thermo in the   northern hemisphere
+      titvar(36)= 'DVTS'  ! variation of sea ice volume due to thermo in the   southern hemisphere
+      titvar(37)= 'TG1N'  ! thermodynamic vertical growth rate in the northern hemisphere, cat 1  
+      titvar(38)= 'TG1S'  ! thermodynamic vertical growth rate in the souhtern hemisphere, cat 1  
+      titvar(39)= 'TG2N'  ! thermodynamic vertical growth rate in the northern hemisphere, cat 2  
+      titvar(40)= 'TG2S'  ! thermodynamic vertical growth rate in the souhtern hemisphere, cat 2  
+      titvar(41)= 'TG3N'  ! thermodynamic vertical growth rate in the northern hemisphere, cat 3  
+      titvar(42)= 'TG3S'  ! thermodynamic vertical growth rate in the souhtern hemisphere, cat 3  
+      titvar(43)= 'TG4N'  ! thermodynamic vertical growth rate in the northern hemisphere, cat 4  
+      titvar(44)= 'TG4S'  ! thermodynamic vertical growth rate in the souhtern hemisphere, cat 4  
+      titvar(45)= 'TG5N'  ! thermodynamic vertical growth rate in the northern hemisphere, cat 5  
+      titvar(46)= 'TG5S'  ! thermodynamic vertical growth rate in the souhtern hemisphere, cat 5  
+      titvar(47)= 'LA_N'  ! lateral accretion growth rate, northern hemisphere
+      titvar(48)= 'LA_S'  ! lateral accretion growth rate, southern hemisphere 
+      titvar(49)= 'SF_N'  ! Salinity FY, NH 
+      titvar(50)= 'SF_S'  ! Salinity FY, SH 
+      titvar(51)= 'SF_N'  ! Salinity MY, NH 
+      titvar(52)= 'SF_S'  ! Salinity MY, SH 
+      titvar(53)= 'Fs_N'  ! Total salt flux NH
+      titvar(54)= 'Fs_S'  ! Total salt flux SH
+      titvar(55)= 'FsbN'  ! Salt - brine drainage flux NH
+      titvar(56)= 'FsbS'  ! Salt - brine drainage flux SH
+      titvar(57)= 'FseN'  ! Salt - Equivalent salt flux NH
+      titvar(58)= 'FseS'  ! Salt - Equivalent salt flux SH
+      titvar(59)= 'SSTN'  ! SST, NH
+      titvar(60)= 'SSTS'  ! SST, SH
+      titvar(61)= 'SSSN'  ! SSS, NH
+      titvar(62)= 'SSSS'  ! SSS, SH
+      titvar(63)= 'TsuN'  ! Tsu, NH
+      titvar(64)= 'TsuS'  ! Tsu, SH
+      titvar(65)= 'TsnN'  ! Tsn, NH
+      titvar(66)= 'TsnS'  ! Tsn, SH
+      titvar(67)= 'ei_N'  ! ei, NH
+      titvar(68)= 'ei_S'  ! ei, SH
+      titvar(69)= 'vi1N'  ! vi1, NH
+      titvar(70)= 'vi1S'  ! vi1, SH
+      titvar(71)= 'vi2N'  ! vi2, NH
+      titvar(72)= 'vi2S'  ! vi2, SH
+      titvar(73)= 'vi3N'  ! vi3, NH
+      titvar(74)= 'vi3S'  ! vi3, SH
+      titvar(75)= 'vi4N'  ! vi4, NH
+      titvar(76)= 'vi4S'  ! vi4, SH
+      titvar(77)= 'vi5N'  ! vi5, NH
+      titvar(78)= 'vi5S'  ! vi5, SH
+      titvar(79)= 'vi6N'  ! vi6, NH
+      titvar(80)= 'vi6S'  ! vi6, SH
+      titvar(81)= 'fmaN'  ! mass flux in the ocean, NH
+      titvar(82)= 'fmaS'  ! mass flux in the ocean, SH
+      titvar(83)= 'AFSE'  ! Fram Strait Area export
+      titvar(84)= 'VFSE'  ! Fram Strait Volume export
+      nvinfo = 84
+
+      ! Definition et Ecriture de l'entete : nombre d'enregistrements 
+      ndeb   = ( nstart - 1 ) / ninfo
+      IF( nstart == 1 ) ndeb = -1
+
+      nferme = ( nstart - 1 + nitrun) / ninfo
+      ntot   = nferme - ndeb
+      ndeb   = ninfo * ( 1 + ndeb )
+      nferme = ninfo * nferme
+
+      ! definition of formats 
+      WRITE( fmtw  , '(A,I3,A2,I1,A)' )  '(', nfrinf, '(A', jpchsep, ','//fmtinf//'))'
+      WRITE( fmtr  , '(A,I3,A,I1,A)'  )  '(', nfrinf, '(', jpchsep, 'X,'//fmtinf//'))'
+      WRITE( fmtitr, '(A,I3,A,I1,A)'  )  '(', nvinfo, 'A', jpchinf, ')'
+
+      ! opening  "ice_evolu" file
+      CALL ctl_opn( numevo_ice, 'ice.evolu', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+
+      !- ecriture de 2 lignes d''entete :
+      WRITE(numevo_ice,1000) fmtr, fmtw, fmtitr, nvinfo, ntot, 0, nfrinf
+      zxx0 = 0.001 * REAL(ninfo)
+      zxx1 = 0.001 * REAL(ndeb)
+      WRITE(numevo_ice,1111) REAL(jpchinf), 0., zxx1, zxx0, 0., 0., 0
+
+      !- ecriture de 2 lignes de titre :
+      WRITE(numevo_ice,'(A,I8,A,I8,A,I5)')                                      &
+         'Evolution chronologique - Experience '//cexper   &
+         //'   de', ndeb, ' a', nferme, ' pas', ninfo
+      WRITE(numevo_ice,fmtitr) ( titvar(jv), jv = 1, nvinfo )
+
+
+      !--preparation de "titvar" pour l''ecriture parmi les valeurs numeriques :
+      DO  jv = 2 , nvinfo
+         titinf     = titvar(jv)(:jpchinf)
+         titvar(jv) = '  '//titinf
+      END DO
+
+      !--Initialisation of the arrays for the accumulation
+      DO  jv = 1, nvinfo
+         vinfom(jv) = 0.
+      END DO
+      naveg = 0
+
+1000  FORMAT( 3(A20),4(1x,I6) )
+1111  FORMAT( 3(F7.1,1X,F7.3,1X),I3,A )  
+
+   END SUBROUTINE lim_dia_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                               NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dia         ! Empty routine
+   END SUBROUTINE lim_dia
+#endif
+
+   !!======================================================================
+END MODULE limdia
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdyn.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdyn.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limdyn.F90	(revision 1844)
@@ -0,0 +1,300 @@
+MODULE limdyn
+   !!======================================================================
+   !!                     ***  MODULE  limdyn  ***
+   !!   Sea-Ice dynamics :  
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                 LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!    lim_dyn      : computes ice velocities
+   !!    lim_dyn_init : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE in_out_manager  ! I/O manager
+   USE dom_ice
+   USE dom_oce         ! ocean space and time domain
+   USE ice
+   USE par_ice
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE iceini
+   USE limistate
+   USE limrhg          ! ice rheology
+   USE lbclnk
+   USE lib_mpp
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_dyn  ! routine called by ice_step
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+
+   !! * Module variables
+   REAL(wp)  ::  rone    = 1.e0   ! constant value
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dyn( kt )
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_dyn  ***
+      !!               
+      !! ** Purpose :   compute ice velocity and ocean-ice stress
+      !!                
+      !! ** Method  : 
+      !!
+      !! ** Action  : - Initialisation
+      !!              - Call of the dynamic routine for each hemisphere
+      !!              - computation of the stress at the ocean surface         
+      !!              - treatment of the case if no ice dynamic
+      !! History :
+      !!   1.0  !  01-04   (LIM)  Original code
+      !!   2.0  !  02-08   (C. Ethe, G. Madec)  F90, mpp
+      !!   3.0  !  2007-03 (M.A. Morales Maqueda, S. Bouillon, M. Vancoppenolle) 
+      !!                   LIM3, EVP, C-grid
+      !!------------------------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !! * Local variables
+      INTEGER  ::   ji, jj, jl, ja    ! dummy loop indices
+      INTEGER  ::   i_j1, i_jpj       ! Starting/ending j-indices for rheology
+      REAL(wp) ::   zcoef             ! temporary scalar
+      REAL(wp), DIMENSION(jpj)     ::   zind           ! i-averaged indicator of sea-ice
+      REAL(wp), DIMENSION(jpj)     ::   zmsk           ! i-averaged of tmask
+      REAL(wp), DIMENSION(jpi,jpj) ::   zu_io, zv_io   ! ice-ocean velocity
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*) ' lim_dyn : Ice dynamics '
+         WRITE(numout,*) ' ~~~~~~~ '
+      ENDIF
+
+      IF( numit == nstart  )   CALL lim_dyn_init   ! Initialization (first time-step only)
+
+      IF ( ln_limdyn ) THEN
+
+         old_u_ice(:,:) = u_ice(:,:) * tmu(:,:)
+         old_v_ice(:,:) = v_ice(:,:) * tmv(:,:)
+
+         ! Rheology (ice dynamics)
+         ! ========
+
+         !  Define the j-limits where ice rheology is computed
+         ! ---------------------------------------------------
+
+         IF( lk_mpp .OR. nbit_cmp == 1 ) THEN                    ! mpp: compute over the whole domain
+            i_j1 = 1
+            i_jpj = jpj
+            IF(ln_ctl) CALL prt_ctl_info( 'lim_dyn  :    i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj )
+            CALL lim_rhg( i_j1, i_jpj )
+         ELSE                                 ! optimization of the computational area
+
+            DO jj = 1, jpj
+               zind(jj) = SUM( 1.0 - at_i (:,jj  ) )   ! = FLOAT(jpj) if ocean everywhere on a j-line
+               zmsk(jj) = SUM( tmask(:,jj,1) )   ! = 0          if land  everywhere on a j-line
+            END DO
+
+            IF( l_jeq ) THEN                     ! local domain include both hemisphere
+               !                                 ! Rheology is computed in each hemisphere
+               !                                 ! only over the ice cover latitude strip
+               ! Northern hemisphere
+               i_j1  = njeq
+               i_jpj = jpj
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-2 )
+               IF(ln_ctl) CALL prt_ctl_info( 'lim_dyn  : NH  i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj )
+               CALL lim_rhg( i_j1, i_jpj )
+
+               ! Southern hemisphere
+               i_j1  =  1
+               i_jpj = njeq
+               DO WHILE ( i_jpj >= 1 .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+1 )
+               IF(ln_ctl) CALL prt_ctl_info( 'lim_dyn  : SH  i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj )
+
+       CALL lim_rhg( i_j1, i_jpj )
+
+    ELSE                                 ! local domain extends over one hemisphere only
+       !                                 ! Rheology is computed only over the ice cover
+       !                                 ! latitude strip
+       i_j1  = 1
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-2 )
+
+               i_jpj  = jpj
+               DO WHILE ( i_jpj >= 1  .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+1)
+
+               IF(ln_ctl) CALL prt_ctl_info( 'lim_dyn  : one hemisphere:  i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj )
+
+               CALL lim_rhg( i_j1, i_jpj )
+
+            ENDIF
+
+         ENDIF
+
+         ! computation of friction velocity
+         ! --------------------------------
+         ! ice-ocean velocity at U & V-points (u_ice v_ice at U- & V-points ; ssu_m, ssv_m at U- & V-points)
+         zu_io(:,:) = u_ice(:,:) - ssu_m(:,:)
+         zv_io(:,:) = v_ice(:,:) - ssv_m(:,:)
+         ! frictional velocity at T-point
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ust2s(ji,jj) = 0.5 * cw                                                          &
+                  &         * (  zu_io(ji,jj) * zu_io(ji,jj) + zu_io(ji-1,jj) * zu_io(ji-1,jj)   &
+                  &            + zv_io(ji,jj) * zv_io(ji,jj) + zv_io(ji,jj-1) * zv_io(ji,jj-1)   ) * tms(ji,jj)
+            END DO
+         END DO
+         !
+      ELSE      ! no ice dynamics : transmit directly the atmospheric stress to the ocean
+         !
+         zcoef = SQRT( 0.5 ) / rau0
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ust2s(ji,jj) = zcoef * tms(ji,jj) * SQRT(  utau(ji,jj) * utau(ji,jj) + utau(ji-1,jj) * utau(ji-1,jj)   &
+                  &                                     + vtau(ji,jj) * vtau(ji,jj) + vtau(ji,jj-1) * vtau(ji,jj-1) )
+            END DO
+         END DO
+         !
+      ENDIF
+
+      CALL lbc_lnk( ust2s, 'T',  1. )   ! T-point
+
+      IF(ln_ctl) THEN   ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=ust2s     , clinfo1=' lim_dyn  : ust2s     :')
+         CALL prt_ctl(tab2d_1=divu_i    , clinfo1=' lim_dyn  : divu_i    :')
+         CALL prt_ctl(tab2d_1=delta_i   , clinfo1=' lim_dyn  : delta_i   :')
+         CALL prt_ctl(tab2d_1=strength  , clinfo1=' lim_dyn  : strength  :')
+         CALL prt_ctl(tab2d_1=area      , clinfo1=' lim_dyn  : cell area :')
+         CALL prt_ctl(tab2d_1=at_i      , clinfo1=' lim_dyn  : at_i      :')
+         CALL prt_ctl(tab2d_1=vt_i      , clinfo1=' lim_dyn  : vt_i      :')
+         CALL prt_ctl(tab2d_1=vt_s      , clinfo1=' lim_dyn  : vt_s      :')
+         CALL prt_ctl(tab2d_1=stress1_i , clinfo1=' lim_dyn  : stress1_i :')
+         CALL prt_ctl(tab2d_1=stress2_i , clinfo1=' lim_dyn  : stress2_i :')
+         CALL prt_ctl(tab2d_1=stress12_i, clinfo1=' lim_dyn  : stress12_i:')
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_dyn  : a_i      : ')
+            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_dyn  : ht_i     : ')
+            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_dyn  : ht_s     : ')
+            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_dyn  : v_i      : ')
+            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_dyn  : v_s      : ')
+            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_dyn  : e_s      : ')
+            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_dyn  : t_su     : ')
+            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_dyn  : t_snow   : ')
+            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_dyn  : sm_i     : ')
+            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_dyn  : smv_i    : ')
+            DO ja = 1, nlay_i
+               CALL prt_ctl_info(' ')
+               CALL prt_ctl_info(' - Layer : ', ivar1=ja)
+               CALL prt_ctl_info('   ~~~~~~~')
+               CALL prt_ctl(tab2d_1=t_i(:,:,ja,jl) , clinfo1= ' lim_dyn  : t_i      : ')
+               CALL prt_ctl(tab2d_1=e_i(:,:,ja,jl) , clinfo1= ' lim_dyn  : e_i      : ')
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE lim_dyn
+
+   SUBROUTINE lim_dyn_init
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dyn_init  ***
+      !!
+      !! ** Purpose : Physical constants and parameters linked to the ice
+      !!      dynamics
+      !!
+      !! ** Method  :  Read the namicedyn namelist and check the ice-dynamic
+      !!       parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicedyn
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!  9.0  ! 07-03 (MA Morales Maqueda, S. Bouillon, M. Vancoppenolle)
+      !!               EVP-Cgrid-LIM3
+      !!-------------------------------------------------------------------
+      NAMELIST/namicedyn/ epsd, alpha,     &
+         &                dm, nbiter, nbitdr, om, resl, cw, angvg, pstar,   &
+         &                c_rhg, etamn, creepl, ecc, ahi0, &
+         &                nevp, telast, alphaevp
+      !!-------------------------------------------------------------------
+
+      ! Define the initial parameters
+      ! -------------------------
+
+      ! Read Namelist namicedyn
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicedyn )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_dyn_init : ice parameters for ice dynamics '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   tolerance parameter                              epsd   = ', epsd
+         WRITE(numout,*) '   coefficient for semi-implicit coriolis           alpha  = ', alpha
+         WRITE(numout,*) '   diffusion constant for dynamics                  dm     = ', dm
+         WRITE(numout,*) '   number of sub-time steps for relaxation          nbiter = ', nbiter
+         WRITE(numout,*) '   maximum number of iterations for relaxation      nbitdr = ', nbitdr
+         WRITE(numout,*) '   relaxation constant                              om     = ', om
+         WRITE(numout,*) '   maximum value for the residual of relaxation     resl   = ', resl
+         WRITE(numout,*) '   drag coefficient for oceanic stress              cw     = ', cw
+         WRITE(numout,*) '   turning angle for oceanic stress                 angvg  = ', angvg
+         WRITE(numout,*) '   first bulk-rheology parameter                    pstar  = ', pstar
+         WRITE(numout,*) '   second bulk-rhelogy parameter                    c_rhg  = ', c_rhg
+         WRITE(numout,*) '   minimun value for viscosity                      etamn  = ', etamn
+         WRITE(numout,*) '   creep limit                                      creepl = ', creepl
+         WRITE(numout,*) '   eccentricity of the elliptical yield curve       ecc    = ', ecc
+         WRITE(numout,*) '   horizontal diffusivity coeff. for sea-ice        ahi0   = ', ahi0
+         WRITE(numout,*) '   number of iterations for subcycling              nevp   = ', nevp
+         WRITE(numout,*) '   timescale for elastic waves                      telast = ', telast
+         WRITE(numout,*) '   coefficient for the solution of int. stresses  alphaevp = ', alphaevp
+
+      ENDIF
+
+      usecc2 = 1.0 / ( ecc * ecc )
+      rhoco  = rau0 * cw
+      angvg  = angvg * rad
+      sangvg = SIN( angvg )
+      cangvg = COS( angvg )
+      pstarh = pstar / 2.0
+
+      !  Diffusion coefficients.
+      ahiu(:,:) = ahi0 * umask(:,:,1)
+      ahiv(:,:) = ahi0 * vmask(:,:,1)
+
+   END SUBROUTINE lim_dyn_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Empty module           NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dyn         ! Empty routine
+   END SUBROUTINE lim_dyn
+#endif 
+
+   !!======================================================================
+END MODULE limdyn
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limhdf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limhdf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limhdf.F90	(revision 1844)
@@ -0,0 +1,189 @@
+MODULE limhdf
+   !!======================================================================
+   !!                    ***  MODULE limhdf   ***
+   !! LIM ice model : horizontal diffusion of sea-ice quantities
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_hdf  : diffusion trend on sea-ice variable
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce
+   USE in_out_manager
+   USE ice
+   USE lbclnk
+   USE lib_mpp
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_hdf    ! called by lim_tra
+
+   !! * Module variables
+   LOGICAL  ::   linit = .TRUE.              ! ???
+   REAL(wp) ::   epsi04 = 1e-04              ! constant
+   REAL(wp), DIMENSION(jpi,jpj) ::   zfact   ! ???
+
+   !! * Substitution 
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_hdf( ptab )
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_hdf  ***
+      !!
+      !! ** purpose :   Compute and add the diffusive trend on sea-ice
+      !!      variables
+      !!
+      !! ** method  :   Second order diffusive operator evaluated using a
+      !!      Cranck-Nicholson time Scheme.
+      !!
+      !! ** Action  :    update ptab with the diffusive contribution
+      !!
+      !! History :
+      !!        !  00-01 (LIM) Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!        !  02-08 (C. Ethe)  F90, free form
+      !!-------------------------------------------------------------------
+      ! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         ptab                 ! Field on which the diffusion is applied  
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ptab0                ! ???
+
+      ! * Local variables
+      INTEGER ::  ji, jj      ! dummy loop indices
+      INTEGER ::  &
+         its, iter            ! temporary integers
+      CHARACTER (len=55) :: charout
+      REAL(wp) ::  &
+         zalfa, zrlxint, zconv, zeps   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::  & 
+         zrlx, zflu, zflv, &  ! temporary workspaces
+         zdiv0, zdiv          !    "           "
+      !!-------------------------------------------------------------------
+
+      ! Initialisation
+      ! ---------------   
+      ! Time integration parameters
+      zalfa = 0.5       ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit
+      its   = 100       ! Maximum number of iteration
+      zeps  =  2. * epsi04
+
+      ! Arrays initialization
+      ptab0 (:, : ) = ptab(:,:)
+      !bug  zflu (:,jpj) = 0.e0
+      !bug  zflv (:,jpj) = 0.e0
+      zdiv0(:, 1 ) = 0.e0
+      zdiv0(:,jpj) = 0.e0
+      IF( .NOT.lk_vopt_loop ) THEN
+         zflu (jpi,:) = 0.e0   
+         zflv (jpi,:) = 0.e0
+         zdiv0(1,  :) = 0.e0
+         zdiv0(jpi,:) = 0.e0
+      ENDIF
+
+      ! Metric coefficient (compute at the first call and saved in
+      IF( linit ) THEN
+         DO jj = 2, jpjm1  
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zfact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj  ) + e1v(ji,jj) + e1v(ji,jj-1) ) &
+                  &          / ( e1t(ji,jj) * e2t(ji,jj) )
+            END DO
+         END DO
+         linit = .FALSE.
+      ENDIF
+
+
+      ! Sub-time step loop
+      zconv = 1.e0
+      iter  = 0
+
+      !                                                   !===================
+      DO WHILE ( ( zconv > zeps ) .AND. (iter <= its) )   ! Sub-time step loop
+         !                                                !===================
+         ! incrementation of the sub-time step number
+         iter = iter + 1
+
+         ! diffusive fluxes in U- and V- direction
+         DO jj = 1, jpjm1
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) / e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) )
+               zflv(ji,jj) = pahv(ji,jj) * e1v(ji,jj) / e2v(ji,jj) * ( ptab(ji,jj+1) - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! diffusive trend : divergence of the fluxes
+         DO jj= 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt. 
+               zdiv (ji,jj) = (  zflu(ji,jj) - zflu(ji-1,jj  )   &
+                  &            + zflv(ji,jj) - zflv(ji  ,jj-1)  ) / ( e1t (ji,jj) * e2t (ji,jj) )
+            END DO
+         END DO
+
+         ! save the first evaluation of the diffusive trend in zdiv0
+         IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)       
+
+         ! XXXX iterative evaluation?????
+         DO jj = 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zrlxint = (   ptab0(ji,jj)    &
+                  &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + zfact(ji,jj) * ptab(ji,jj) )   &
+                  &                      + ( 1.0 - zalfa ) *   zdiv0(ji,jj) )  )                             & 
+                  &    / ( 1.0 + zalfa * rdt_ice * zfact(ji,jj) )
+               zrlx(ji,jj) = ptab(ji,jj) + om * ( zrlxint - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! lateral boundary condition on zrlx
+         CALL lbc_lnk( zrlx, 'T', 1. )
+
+         ! convergence test
+         zconv = 0.e0
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zconv = MAX( zconv, ABS( zrlx(ji,jj) - ptab(ji,jj) )  )
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_max( zconv )   ! max over the global domain
+
+         DO jj = 1, jpj
+            DO ji = 1 , jpi
+               ptab(ji,jj) = zrlx(ji,jj)
+            END DO
+         END DO
+
+         !                                         !==========================
+      END DO                                       ! end of sub-time step loop
+      !                                            !==========================
+
+      IF(ln_ctl)   THEN
+         zrlx(:,:) = ptab(:,:) - ptab0(:,:)
+         WRITE(charout,FMT="(' lim_hdf  : zconv =',D23.16, ' iter =',I4,2X)") zconv, iter
+         CALL prt_ctl(tab2d_1=zrlx, clinfo1=charout)
+      ENDIF
+
+
+   END SUBROUTINE lim_hdf
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module           NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_hdf         ! Empty routine
+   END SUBROUTINE lim_hdf
+#endif
+
+   !!======================================================================
+END MODULE limhdf
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limistate.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limistate.F90	(revision 1844)
@@ -0,0 +1,584 @@
+MODULE limistate
+   !!======================================================================
+   !!                     ***  MODULE  limistate  ***
+   !!              Initialisation of diagnostics ice variables
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                    LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_istate      :  Initialisation of diagnostics ice variables
+   !!   lim_istate_init :  initialization of ice state and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE oce             ! dynamics and tracers variables
+   USE dom_oce
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE par_ice         ! ice parameters
+   USE eosbn2          ! equation of state
+   USE in_out_manager
+   USE dom_ice
+   USE ice
+   USE lbclnk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_istate      ! routine called by lim_init.F90
+
+   !! * Module variables
+   REAL(wp) ::             & !!! ** init namelist (namiceini) **
+      ttest    = 2.0  ,    &  ! threshold water temperature for initial sea ice
+      hninn    = 0.5  ,    &  ! initial snow thickness in the north
+      hginn_u  = 2.5  ,    &  ! initial ice thickness in the north
+      aginn_u  = 0.7  ,    &  ! initial leads area in the north
+      hginn_d  = 5.0  ,    &  ! initial ice thickness in the north
+      aginn_d  = 0.25 ,    &  ! initial leads area in the north
+      hnins    = 0.1  ,    &  ! initial snow thickness in the south
+      hgins_u  = 1.0  ,    &  ! initial ice thickness in the south
+      agins_u  = 0.7  ,    &  ! initial leads area in the south
+      hgins_d  = 2.0  ,    &  ! initial ice thickness in the south
+      agins_d  = 0.2  ,    &  ! initial leads area in the south
+      sinn     = 6.301 ,   &  ! initial salinity 
+      sins     = 6.301
+
+   REAL(wp)  ::            &  ! constant values
+      zzero   = 0.0     ,  &
+      zone    = 1.0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_istate
+      !!-------------------------------------------------------------------
+      !!                    ***  ROUTINE lim_istate  ***
+      !!
+      !! ** Purpose :   defined the sea-ice initial state
+      !!
+      !! ** Method  :   restart from a state defined in a binary file
+      !!                or from arbitrary sea-ice conditions
+      !!
+      !! History :
+      !!   2.0  !  01-04  (C. Ethe, G. Madec)  Original code
+      !!--------------------------------------------------------------------
+
+      !! * Local variables
+      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices
+
+      REAL(wp) ::       &  ! temporary scalar
+         zeps6, zeps, ztmelts, &
+         epsi06
+      REAL(wp), DIMENSION(jpm) ::   &
+         zgfactorn, zhin, &
+         zgfactors, zhis
+      REAL(wp) ::  &
+         zvol, zare, zh, zh1, zh2, zh3, zan, zbn, zas, zbs 
+      REAL(wp), DIMENSION(jpi,jpj) ::   zidto    ! ice indicator
+      !--------------------------------------------------------------------
+
+      !--------------------------------------------------------------------
+      ! 1) Preliminary things 
+      !--------------------------------------------------------------------
+      epsi06 = 1.0e-6
+
+      CALL lim_istate_init     !  reading the initials parameters of the ice
+
+!!gm  in lim2  the initialisation if only done if required in the namelist :
+!!gm      IF( .NOT. ln_limini ) THEN
+!!gm  this should be added in lim3 namelist...
+
+      !--------------------------------------------------------------------
+      ! 2) Ice initialization (hi,hs,frld,t_su,sm_i,t_i,t_s)              | 
+      !--------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'lim_istate : Ice initialization '
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
+
+      t_bo(:,:) = tfreez( sn(:,:,1) ) * tmask(:,:,1)       ! freezing/melting point of sea water [Celcius]
+
+      DO jj = 1, jpj                                       ! ice if sst <= t-freez + ttest
+         DO ji = 1, jpi
+            IF( tn(ji,jj,1)  - t_bo(ji,jj) >= ttest ) THEN   ;   zidto(ji,jj) = 0.e0      ! no ice
+            ELSE                                             ;   zidto(ji,jj) = 1.e0      !    ice
+            ENDIF
+         END DO
+      END DO
+
+      t_bo(:,:) = t_bo(:,:) + rt0                          ! t_bo converted from Celsius to Kelvin (rt0 over land)
+
+      ! constants for heat contents
+      zeps   = 1.0d-20
+      zeps6  = 1.0d-06
+
+      ! zgfactor for initial ice distribution
+      zgfactorn(:) = 0.0
+      zgfactors(:) = 0.0
+
+      ! first ice type
+      DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2)
+         zhin (1)     = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+         zgfactorn(1) = zgfactorn(1) + exp(-(zhin(1)-hginn_u)*(zhin(1)-hginn_u)/2.0)
+         zhis (1)     = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+         zgfactors(1) = zgfactors(1) + exp(-(zhis(1)-hgins_u)*(zhis(1)-hgins_u)/2.0)
+      END DO ! jl
+      zgfactorn(1) = aginn_u / zgfactorn(1)
+      zgfactors(1) = agins_u / zgfactors(1)
+
+      ! -------------
+      ! new distribution, polynom of second order, conserving area and volume
+      zh1 = 0.0
+      zh2 = 0.0
+      zh3 = 0.0
+      DO jl = 1, jpl
+         zh = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+         zh1 = zh1 + zh
+         zh2 = zh2 + zh*zh
+         zh3 = zh3 + zh*zh*zh
+      END DO
+      IF(lwp) WRITE(numout,*) ' zh1 : ', zh1
+      IF(lwp) WRITE(numout,*) ' zh2 : ', zh2
+      IF(lwp) WRITE(numout,*) ' zh3 : ', zh3
+
+      zvol = aginn_u*hginn_u
+      zare = aginn_u
+      IF ( jpl .GE. 2 ) THEN
+         zbn = ( zvol*zh2 - zare*zh3 ) / ( zh2*zh2 - zh1*zh3)
+         zan = ( zare - zbn*zh1 ) / zh2
+      ENDIF
+
+      IF(lwp) WRITE(numout,*) ' zvol: ', zvol
+      IF(lwp) WRITE(numout,*) ' zare: ', zare
+      IF(lwp) WRITE(numout,*) ' zbn : ', zbn 
+      IF(lwp) WRITE(numout,*) ' zan : ', zan 
+
+      zvol = agins_u*hgins_u
+      zare = agins_u
+      IF ( jpl .GE. 2 ) THEN
+         zbs = ( zvol*zh2 - zare*zh3 ) / ( zh2*zh2 - zh1*zh3)
+         zas = ( zare - zbs*zh1 ) / zh2
+      ENDIF
+
+      IF(lwp) WRITE(numout,*) ' zvol: ', zvol
+      IF(lwp) WRITE(numout,*) ' zare: ', zare
+      IF(lwp) WRITE(numout,*) ' zbn : ', zbn 
+      IF(lwp) WRITE(numout,*) ' zan : ', zan 
+
+      !end of new lines
+      ! -------------
+!!!
+      ! retour a LIMA_MEC
+      !     ! second ice type
+      !     zdummy  = hi_max(ice_cat_bounds(2,1)-1)
+      !     hi_max(ice_cat_bounds(2,1)-1) = 0.0
+
+      !     ! here to change !!!!
+      !     jm = 2
+      !     DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+      !        zhin (2)     = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+      !        zhin (2)     = ( hi_max_typ(jl-ice_cat_bounds(2,1),jm    ) + &
+      !                         hi_max_typ(jl-ice_cat_bounds(2,1) + 1,jm)   ) / 2.0
+      !        zgfactorn(2) = zgfactorn(2) + exp(-(zhin(2)-hginn_d)*(zhin(2)-hginn_d)/2.0)
+      !        zhis (2)     = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+      !        zhis (2)     = ( hi_max_typ(jl-ice_cat_bounds(2,1),jm    ) + &
+      !                         hi_max_typ(jl-ice_cat_bounds(2,1) + 1,jm)   ) / 2.0
+      !        zgfactors(2) = zgfactors(2) + exp(-(zhis(2)-hgins_d)*(zhis(2)-hgins_d)/2.0)
+      !     END DO ! jl
+      !     zgfactorn(2) = aginn_d / zgfactorn(2)
+      !     zgfactors(2) = agins_d / zgfactors(2)
+      !     hi_max(ice_cat_bounds(2,1)-1) = zdummy
+      ! END retour a LIMA_MEC
+!!!
+
+!!gm  optimisation :  loop over the ice categories inside the ji, jj loop !!!
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            !--- Northern hemisphere
+            !----------------------------------------------------------------
+            IF( fcor(ji,jj) >= 0.e0 ) THEN    
+
+               !-----------------------
+               ! Ice area / thickness
+               !-----------------------
+
+               IF ( jpl .EQ. 1) THEN ! one category
+
+                  DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2) ! loop over ice thickness categories
+                     a_i(ji,jj,jl)    = zidto(ji,jj) * aginn_u
+                     ht_i(ji,jj,jl)   = zidto(ji,jj) * hginn_u
+                     v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+                  END DO
+
+               ELSE ! several categories
+
+                  DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2) ! loop over ice thickness categories
+                     zhin(1)          = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+                     a_i(ji,jj,jl)    = zidto(ji,jj) * MAX( zgfactorn(1) * exp(-(zhin(1)-hginn_u)* & 
+                        (zhin(1)-hginn_u)/2.0) , epsi06)
+                     ! new line
+                     a_i(ji,jj,jl)    = zidto(ji,jj) * ( zan * zhin(1) * zhin(1) + zbn * zhin(1) )
+                     ht_i(ji,jj,jl)   = zidto(ji,jj) * zhin(1) 
+                     v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+                  END DO
+
+               ENDIF
+
+
+!!!
+               ! retour a LIMA_MEC
+               !              !ridged ice
+               !              zdummy  = hi_max(ice_cat_bounds(2,1)-1)
+               !              hi_max(ice_cat_bounds(2,1)-1) = 0.0
+               !              DO jl = ice_cat_bounds(2,1), ice_cat_bounds(2,2) ! loop over ice thickness categories
+               !                 zhin(2)          = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+               !                 a_i(ji,jj,jl)    = zidto(ji,jj) * MAX( zgfactorn(2) * exp(-(zhin(2)-hginn_d)* &
+               !                                    (zhin(2)-hginn_d)/2.0) , epsi06)
+               !                 ht_i(ji,jj,jl)   = zidto(ji,jj) * zhin(2) 
+               !                 v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+               !              END DO
+               !              hi_max(ice_cat_bounds(2,1)-1) = zdummy
+
+               !              !rafted ice
+               !              jl = 6
+               !              a_i(ji,jj,jl)       = 0.0
+               !              ht_i(ji,jj,jl)      = 0.0
+               !              v_i(ji,jj,jl)       = 0.0
+               ! END retour a LIMA_MEC
+!!!
+
+               DO jl = 1, jpl
+
+                  !-------------
+                  ! Snow depth
+                  !-------------
+                  ht_s(ji,jj,jl)   = zidto(ji,jj) * hninn
+                  v_s(ji,jj,jl)    = ht_s(ji,jj,jl)*a_i(ji,jj,jl)
+
+                  !---------------
+                  ! Ice salinity
+                  !---------------
+                  sm_i(ji,jj,jl)   = zidto(ji,jj) * sinn  + ( 1.0 - zidto(ji,jj) ) * 0.1
+                  smv_i(ji,jj,jl)  = MIN( sm_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl)
+
+                  !----------
+                  ! Ice age
+                  !----------
+                  o_i(ji,jj,jl)    = zidto(ji,jj) * 1.0   + ( 1.0 - zidto(ji,jj) )
+                  oa_i(ji,jj,jl)   = o_i(ji,jj,jl) * a_i(ji,jj,jl)
+
+                  !------------------------------
+                  ! Sea ice surface temperature
+                  !------------------------------
+
+                  t_su(ji,jj,jl)   = zidto(ji,jj) * 270.0 + ( 1.0 - zidto(ji,jj) ) * t_bo(ji,jj)
+
+                  !------------------------------------
+                  ! Snow temperature and heat content
+                  !------------------------------------
+
+                  DO jk = 1, nlay_s
+                     t_s(ji,jj,jk,jl) = zidto(ji,jj) * 270.00 + ( 1.0 - zidto(ji,jj) ) * rtt
+                     ! Snow energy of melting
+                     e_s(ji,jj,jk,jl) = zidto(ji,jj) * rhosn * ( cpic * ( rtt - t_s(ji,jj,jk,jl) ) + lfus )
+                     ! Change dimensions
+                     e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) / unit_fac
+                     ! Multiply by volume, so that heat content in 10^9 Joules
+                     e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * area(ji,jj) * &
+                        v_s(ji,jj,jl)  / nlay_s
+                  END DO !jk
+
+                  !-----------------------------------------------
+                  ! Ice salinities, temperature and heat content 
+                  !-----------------------------------------------
+
+                  DO jk = 1, nlay_i
+                     t_i(ji,jj,jk,jl) = zidto(ji,jj)*270.00 + ( 1.0 - zidto(ji,jj) ) * rtt 
+                     s_i(ji,jj,jk,jl) = zidto(ji,jj) * sinn + ( 1.0 - zidto(ji,jj) ) * 0.1
+                     ztmelts          = - tmut * s_i(ji,jj,jk,jl) + rtt !Melting temperature in K
+
+                     ! heat content per unit volume
+                     e_i(ji,jj,jk,jl) = zidto(ji,jj) * rhoic * &
+                        (   cpic    * ( ztmelts - t_i(ji,jj,jk,jl) ) &
+                        +   lfus    * ( 1.0 - (ztmelts-rtt) / MIN((t_i(ji,jj,jk,jl)-rtt),-zeps) ) &
+                        - rcp      * ( ztmelts - rtt ) &
+                        )
+
+                     ! Correct dimensions to avoid big values
+                     e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / unit_fac 
+
+                     ! Mutliply by ice volume, and divide by number of layers to get heat content in 10^9 J
+                     e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * & 
+                        area(ji,jj) * a_i(ji,jj,jl) * ht_i(ji,jj,jl) / &
+                        nlay_i
+                  END DO ! jk
+
+               END DO ! jl 
+
+            ELSE ! on fcor 
+
+               !--- Southern hemisphere
+               !----------------------------------------------------------------
+
+               !-----------------------
+               ! Ice area / thickness
+               !-----------------------
+
+               IF ( jpl .EQ. 1) THEN ! one category
+
+                  DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2) ! loop over ice thickness categories
+                     a_i(ji,jj,jl)    = zidto(ji,jj) * agins_u
+                     ht_i(ji,jj,jl)   = zidto(ji,jj) * hgins_u
+                     v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+                  END DO
+
+               ELSE ! several categories
+
+                  !level ice
+                  DO jl = ice_cat_bounds(1,1), ice_cat_bounds(1,2) !over thickness categories
+
+                     zhis(1)       = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+                     a_i(ji,jj,jl) = zidto(ji,jj) * MAX( zgfactors(1) * exp(-(zhis(1)-hgins_u) * & 
+                        (zhis(1)-hgins_u)/2.0) , epsi06 )
+                     ! new line square distribution volume conserving
+                     a_i(ji,jj,jl)    = zidto(ji,jj) * ( zas * zhis(1) * zhis(1) + zbs * zhis(1) )
+                     ht_i(ji,jj,jl)   = zidto(ji,jj) * zhis(1) 
+                     v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+
+                  END DO ! jl
+
+               ENDIF
+
+!!!
+               ! retour a LIMA_MEC
+               !              !ridged ice
+               !              zdummy  = hi_max(ice_cat_bounds(2,1)-1)
+               !              hi_max(ice_cat_bounds(2,1)-1) = 0.0
+               !              DO jl = ice_cat_bounds(2,1), ice_cat_bounds(2,2) !over thickness categories
+               !                 zhis(2)       = ( hi_max(jl-1) + hi_max(jl) ) / 2.0
+               !                 a_i(ji,jj,jl) = zidto(ji,jj)*MAX( zgfactors(2)   &
+               !                    &          * exp(-(zhis(2)-hgins_d)*(zhis(2)-hgins_d)/2.0), epsi06 )
+               !                 ht_i(ji,jj,jl)   = zidto(ji,jj) * zhis(2) 
+               !                 v_i(ji,jj,jl)    = ht_i(ji,jj,jl)*a_i(ji,jj,jl)
+               !              END DO
+               !              hi_max(ice_cat_bounds(2,1)-1) = zdummy
+
+               !              !rafted ice
+               !              jl = 6
+               !              a_i(ji,jj,jl)       = 0.0
+               !              ht_i(ji,jj,jl)      = 0.0
+               !              v_i(ji,jj,jl)       = 0.0
+               ! END retour a LIMA_MEC
+!!!
+
+               DO jl = 1, jpl !over thickness categories
+
+                  !---------------
+                  ! Snow depth
+                  !---------------
+
+                  ht_s(ji,jj,jl)   = zidto(ji,jj) * hnins
+                  v_s(ji,jj,jl)    = ht_s(ji,jj,jl)*a_i(ji,jj,jl)
+
+                  !---------------
+                  ! Ice salinity
+                  !---------------
+
+                  sm_i(ji,jj,jl)   = zidto(ji,jj) * sins  + ( 1.0 - zidto(ji,jj) ) * 0.1
+                  smv_i(ji,jj,jl)  = MIN( sm_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl)
+
+                  !----------
+                  ! Ice age
+                  !----------
+
+                  o_i(ji,jj,jl)    = zidto(ji,jj) * 1.0   + ( 1.0 - zidto(ji,jj) )
+                  oa_i(ji,jj,jl)   = o_i(ji,jj,jl) * a_i(ji,jj,jl)
+
+                  !------------------------------
+                  ! Sea ice surface temperature
+                  !------------------------------
+
+                  t_su(ji,jj,jl)   = zidto(ji,jj) * 270.0 + ( 1.0 - zidto(ji,jj) ) * t_bo(ji,jj)
+
+                  !----------------------------------
+                  ! Snow temperature / heat content
+                  !----------------------------------
+
+                  DO jk = 1, nlay_s
+                     t_s(ji,jj,jk,jl) = zidto(ji,jj) * 270.00 + ( 1.0 - zidto(ji,jj) ) * rtt
+                     ! Snow energy of melting
+                     e_s(ji,jj,jk,jl) = zidto(ji,jj) * rhosn * ( cpic * ( rtt - t_s(ji,jj,jk,jl) ) + lfus )
+                     ! Change dimensions
+                     e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) / unit_fac
+                     ! Multiply by volume, so that heat content in 10^9 Joules
+                     e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * area(ji,jj) * &
+                        v_s(ji,jj,jl)  / nlay_s
+                  END DO
+
+                  !---------------------------------------------
+                  ! Ice temperature, salinity and heat content
+                  !---------------------------------------------
+
+                  DO jk = 1, nlay_i
+                     t_i(ji,jj,jk,jl) = zidto(ji,jj)*270.00 + ( 1.0 - zidto(ji,jj) ) * rtt 
+                     s_i(ji,jj,jk,jl) = zidto(ji,jj) * sins + ( 1.0 - zidto(ji,jj) ) * 0.1
+                     ztmelts          = - tmut * s_i(ji,jj,jk,jl) + rtt !Melting temperature in K
+
+                     ! heat content per unit volume
+                     e_i(ji,jj,jk,jl) = zidto(ji,jj) * rhoic * &
+                        (   cpic    * ( ztmelts - t_i(ji,jj,jk,jl) ) &
+                        +   lfus  * ( 1.0 - (ztmelts-rtt) / MIN((t_i(ji,jj,jk,jl)-rtt),-zeps) ) &
+                        - rcp      * ( ztmelts - rtt ) &
+                        )
+
+                     ! Correct dimensions to avoid big values
+                     e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / unit_fac 
+
+                     ! Mutliply by ice volume, and divide by number of layers to get heat content in 10^9 J
+                     e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * & 
+                        area(ji,jj) * a_i(ji,jj,jl) * ht_i(ji,jj,jl) / &
+                        nlay_i
+                  END DO !jk
+
+               END DO ! jl 
+
+            ENDIF ! on fcor
+
+         ENDDO
+      ENDDO
+
+      !--------------------------------------------------------------------
+      ! 3) Global ice variables for output diagnostics                    | 
+      !--------------------------------------------------------------------
+
+      fsbbq (:,:)     = 0.e0
+      u_ice (:,:)     = 0.e0
+      v_ice (:,:)     = 0.e0
+      stress1_i(:,:)  = 0.0
+      stress2_i(:,:)  = 0.0
+      stress12_i(:,:) = 0.0
+
+      !--------------------------------------------------------------------
+      ! 4) Moments for advection
+      !--------------------------------------------------------------------
+
+      sxice (:,:,:)  = 0.e0   ;   sxsn (:,:,:)  = 0.e0   ;   sxa  (:,:,:)  = 0.e0
+      syice (:,:,:)  = 0.e0   ;   sysn (:,:,:)  = 0.e0   ;   sya  (:,:,:)  = 0.e0
+      sxxice(:,:,:)  = 0.e0   ;   sxxsn(:,:,:)  = 0.e0   ;   sxxa (:,:,:)  = 0.e0
+      syyice(:,:,:)  = 0.e0   ;   syysn(:,:,:)  = 0.e0   ;   syya (:,:,:)  = 0.e0
+      sxyice(:,:,:)  = 0.e0   ;   sxysn(:,:,:)  = 0.e0   ;   sxya (:,:,:)  = 0.e0
+
+      sxc0  (:,:,:)  = 0.e0   ;   sxe  (:,:,:,:)= 0.e0   
+      syc0  (:,:,:)  = 0.e0   ;   sye  (:,:,:,:)= 0.e0   
+      sxxc0 (:,:,:)  = 0.e0   ;   sxxe (:,:,:,:)= 0.e0   
+      syyc0 (:,:,:)  = 0.e0   ;   syye (:,:,:,:)= 0.e0   
+      sxyc0 (:,:,:)  = 0.e0   ;   sxye (:,:,:,:)= 0.e0   
+
+      sxsal  (:,:,:)  = 0.e0
+      sysal  (:,:,:)  = 0.e0
+      sxxsal (:,:,:)  = 0.e0
+      syysal (:,:,:)  = 0.e0
+      sxysal (:,:,:)  = 0.e0
+
+      !--------------------------------------------------------------------
+      ! 5) Lateral boundary conditions                                    | 
+      !--------------------------------------------------------------------
+
+      DO jl = 1, jpl
+
+         CALL lbc_lnk( a_i(:,:,jl)  , 'T', 1. )
+         CALL lbc_lnk( v_i(:,:,jl)  , 'T', 1. )
+         CALL lbc_lnk( v_s(:,:,jl)  , 'T', 1. )
+         CALL lbc_lnk( smv_i(:,:,jl), 'T', 1. )
+         CALL lbc_lnk( oa_i(:,:,jl) , 'T', 1. )
+
+         CALL lbc_lnk( ht_i(:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( ht_s(:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( sm_i(:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( o_i(:,:,jl)  , 'T', 1. )
+         CALL lbc_lnk( t_su(:,:,jl) , 'T', 1. )
+         DO jk = 1, nlay_s
+            CALL lbc_lnk(t_s(:,:,jk,jl), 'T', 1. )
+            CALL lbc_lnk(e_s(:,:,jk,jl), 'T', 1. )
+         END DO
+         DO jk = 1, nlay_i
+            CALL lbc_lnk(t_i(:,:,jk,jl), 'T', 1. )
+            CALL lbc_lnk(e_i(:,:,jk,jl), 'T', 1. )
+         END DO
+
+         a_i (:,:,jl) = tms(:,:) * a_i(:,:,jl)
+
+      END DO
+
+      CALL lbc_lnk( at_i , 'T', 1. )
+      at_i(:,:) = tms(:,:) * at_i(:,:)                       ! put 0 over land
+
+      CALL lbc_lnk( fsbbq  , 'T', 1. )
+
+   END SUBROUTINE lim_istate
+
+   SUBROUTINE lim_istate_init
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_istate_init  ***
+      !!        
+      !! ** Purpose : Definition of initial state of the ice 
+      !!
+      !! ** Method : Read the namiceini namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input : 
+      !!        Namelist namiceini
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!-----------------------------------------------------------------------------
+      NAMELIST/namiceini/ ttest, hninn, hginn_u, aginn_u, hginn_d, aginn_d, hnins, &
+         hgins_u, agins_u, hgins_d, agins_d, sinn, sins
+      !!-----------------------------------------------------------------------------
+
+      ! Define the initial parameters
+      ! -------------------------
+
+      ! Read Namelist namiceini 
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice , namiceini )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_istate_init : ice parameters inititialisation '
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   threshold water temp. for initial sea-ice    ttest      = ', ttest
+         WRITE(numout,*) '   initial snow thickness in the north          hninn      = ', hninn
+         WRITE(numout,*) '   initial undef ice thickness in the north     hginn_u    = ', hginn_u
+         WRITE(numout,*) '   initial undef ice concentr. in the north     aginn_u    = ', aginn_u          
+         WRITE(numout,*) '   initial  def  ice thickness in the north     hginn_d    = ', hginn_d
+         WRITE(numout,*) '   initial  def  ice concentr. in the north     aginn_d    = ', aginn_d          
+         WRITE(numout,*) '   initial snow thickness in the south          hnins      = ', hnins 
+         WRITE(numout,*) '   initial undef ice thickness in the north     hgins_u    = ', hgins_u
+         WRITE(numout,*) '   initial undef ice concentr. in the north     agins_u    = ', agins_u          
+         WRITE(numout,*) '   initial  def  ice thickness in the north     hgins_d    = ', hgins_d
+         WRITE(numout,*) '   initial  def  ice concentr. in the north     agins_d    = ', agins_d          
+         WRITE(numout,*) '   initial  ice salinity       in the north     sinn       = ', sinn
+         WRITE(numout,*) '   initial  ice salinity       in the south     sins       = ', sins
+      ENDIF
+
+   END SUBROUTINE lim_istate_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module          NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_istate          ! Empty routine
+   END SUBROUTINE lim_istate
+#endif
+
+   !!======================================================================
+END MODULE limistate
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_me.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_me.F90	(revision 1844)
@@ -0,0 +1,1877 @@
+MODULE limitd_me
+   !!======================================================================
+   !!                       ***  MODULE limitd_me ***
+   !!            Mechanical impact on ice thickness distribution
+   !!                     computation of changes in g(h)      
+   !!======================================================================
+   !! History :  LIM  ! 2006-02  (M. Vancoppenolle) Original code 
+   !!            3.2  ! 2009-07  (M. Vancoppenolle, Y. Aksenov, G. Madec) bug correction in smsw & fsalt_rpo
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                    LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   USE dom_ice
+   USE par_oce          ! ocean parameters
+   USE dom_oce
+   USE lbclnk
+   USE phycst           ! physical constants (ocean directory) 
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE thd_ice
+   USE limistate
+   USE in_out_manager
+   USE ice
+   USE par_ice
+   USE limthd_lac
+   USE limvar
+   USE iceini
+   USE limcons
+   USE prtctl           ! Print control
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_itd_me        ! called by ice_stp
+   PUBLIC lim_itd_me_icestrength
+   PUBLIC lim_itd_me_ridgeprep
+   PUBLIC lim_itd_me_ridgeshift
+   PUBLIC lim_itd_me_asumr
+   PUBLIC lim_itd_me_init
+   PUBLIC lim_itd_me_zapsmall
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1e-20   ,  &
+      epsi13 = 1e-13   ,  &
+      epsi11 = 1e-11   ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !-----------------------------------------------------------------------
+   ! Variables shared among ridging subroutines
+   !-----------------------------------------------------------------------
+   REAL(wp), DIMENSION (jpi,jpj) ::    &
+      asum         , & ! sum of total ice and open water area
+      aksum            ! ratio of area removed to area ridged
+
+   REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: &     
+      athorn           ! participation function; fraction of ridging/
+   !  closing associated w/ category n
+
+   REAL(wp), DIMENSION(jpi,jpj,jpl) ::  &
+      hrmin      , &   ! minimum ridge thickness
+      hrmax      , &   ! maximum ridge thickness
+      hraft      , &   ! thickness of rafted ice
+      krdg       , &   ! mean ridge thickness/thickness of ridging ice 
+      aridge     , &   ! participating ice ridging
+      araft            ! participating ice rafting
+
+   REAL(wp), PARAMETER :: &
+      krdgmin = 1.1, &    ! min ridge thickness multiplier
+      kraft   = 2.0       ! rafting multipliyer
+
+   REAL(wp) :: &                               
+      Cp 
+   !
+   !-----------------------------------------------------------------------
+   ! Ridging diagnostic arrays for history files
+   !-----------------------------------------------------------------------
+   !
+   REAL (wp), DIMENSION(jpi,jpj) :: &
+      dardg1dt     , & ! rate of fractional area loss by ridging ice (1/s)
+      dardg2dt     , & ! rate of fractional area gain by new ridges (1/s)
+      dvirdgdt     , & ! rate of ice volume ridged (m/s)
+      opening          ! rate of opening due to divergence/shear (1/s)
+
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+
+CONTAINS
+
+   !!-----------------------------------------------------------------------------!
+   !!-----------------------------------------------------------------------------!
+
+   SUBROUTINE lim_itd_me ! (subroutine 1/6)
+      !!---------------------------------------------------------------------!
+      !!                ***  ROUTINE lim_itd_me ***
+      !! ** Purpose :
+      !!        This routine computes the mechanical redistribution
+      !!                      of ice thickness
+      !!
+      !! ** Method  : a very simple method :-)
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** Steps :
+      !!  1) Thickness categories boundaries, ice / o.w. concentrations
+      !!     Ridge preparation
+      !!  2) Dynamical inputs (closing rate, divu_adv, opning)
+      !!  3) Ridging iteration
+      !!  4) Ridging diagnostics
+      !!  5) Heat, salt and freshwater fluxes
+      !!  6) Compute increments of tate variables and come back to old values
+      !!
+      !! ** References : There are a lot of references and can be difficult / 
+      !!                 boring to read
+      !!
+      !! Flato, G. M., and W. D. Hibler III, 1995: Ridging and strength
+      !!  in modeling the thickness distribution of Arctic sea ice,
+      !!  J. Geophys. Res., 100, 18,611-18,626.
+      !!
+      !! Hibler, W. D. III, 1980: Modeling a variable thickness sea ice
+      !!  cover, Mon. Wea. Rev., 108, 1943-1973, 1980.
+      !!
+      !! Rothrock, D. A., 1975: The energetics of the plastic deformation of
+      !!  pack ice by ridging, J. Geophys. Res., 80, 4514-4519.
+      !!
+      !! Thorndike, A. S., D. A. Rothrock, G. A. Maykut, and R. Colony, 
+      !!  1975: The thickness distribution of sea ice, J. Geophys. Res., 
+      !!  80, 4501-4513. 
+      !!
+      !! Bitz et al., JGR 2001
+      !!
+      !! Amundrud and Melling, JGR 2005
+      !!
+      !! Babko et al., JGR 2002 
+      !!
+      !!     This routine is based on CICE code and authors William H. Lipscomb,
+      !!  and Elizabeth C. Hunke, LANL are gratefully acknowledged
+      !!--------------------------------------------------------------------!
+      !! * Arguments
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial dummy loop index
+         jj,       &   ! spatial dummy loop index
+         jk,       &   ! vertical layering dummy loop index
+         jl,       &   ! ice category dummy loop index
+         niter,    &   ! iteration counter
+         nitermax = 20 ! max number of ridging iterations 
+
+      REAL(wp)  ::             &  ! constant values
+         zeps      =  1.0e-10, &
+         epsi10    =  1.0e-10, &
+         epsi06    =  1.0e-6
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         closing_net,        &  ! net rate at which area is removed    (1/s)
+                                ! (ridging ice area - area of new ridges) / dt
+         divu_adv   ,        &  ! divu as implied by transport scheme  (1/s)
+         opning     ,        &  ! rate of opening due to divergence/shear
+         closing_gross,      &  ! rate at which area removed, not counting
+                                ! area of new ridges
+         msnow_mlt  ,        &  ! mass of snow added to ocean (kg m-2)
+         esnow_mlt              ! energy needed to melt snow in ocean (J m-2)
+
+      REAL(wp) ::            &
+         w1,                 &  ! temporary variable
+         tmpfac,             &  ! factor by which opening/closing rates are cut
+         dti                    ! 1 / dt
+
+      LOGICAL   ::           &
+         asum_error              ! flag for asum .ne. 1
+
+      INTEGER :: iterate_ridging ! if true, repeat the ridging
+
+      REAL(wp) ::  &         
+         big = 1.0e8
+
+      REAL (wp), DIMENSION(jpi,jpj) :: &  ! 
+         vt_i_init, vt_i_final       !  ice volume summed over categories
+
+      CHARACTER (len = 15) :: fieldid
+
+      !!-- End of declarations
+      !-----------------------------------------------------------------------------!
+
+      IF( numit == nstart  ) CALL lim_itd_me_init ! Initialization (first time-step only)
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=ato_i , clinfo1=' lim_itd_me: ato_i  : ', tab2d_2=at_i   , clinfo2=' at_i    : ')
+         CALL prt_ctl(tab2d_1=divu_i, clinfo1=' lim_itd_me: divu_i : ', tab2d_2=delta_i, clinfo2=' delta_i : ')
+      ENDIF
+
+      !-----------------------------------------------------------------------------!
+      ! 1) Thickness categories boundaries, ice / o.w. concentrations, init_ons
+      !-----------------------------------------------------------------------------!
+      ! Set hi_max(ncat) to a big value to ensure that all ridged ice 
+      ! is thinner than hi_max(ncat).
+
+      hi_max(jpl) = 999.99
+
+      Cp = 0.5* grav * (rau0-rhoic)*rhoic/rau0    ! proport const for PE
+      CALL lim_itd_me_ridgeprep ! prepare ridging
+
+      ! conservation check
+      IF ( con_i) CALL lim_column_sum (jpl,   v_i, vt_i_init)
+
+      ! Initialize arrays.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            msnow_mlt(ji,jj) = 0.0
+            esnow_mlt(ji,jj) = 0.0
+            dardg1dt(ji,jj)  = 0.0
+            dardg2dt(ji,jj)  = 0.0
+            dvirdgdt(ji,jj)  = 0.0
+            opening (ji,jj)  = 0.0
+
+            !-----------------------------------------------------------------------------!
+            ! 2) Dynamical inputs (closing rate, divu_adv, opning)
+            !-----------------------------------------------------------------------------!
+            !
+            ! 2.1 closing_net
+            !-----------------
+            ! Compute the net rate of closing due to convergence 
+            ! and shear, based on Flato and Hibler (1995).
+            ! 
+            ! The energy dissipation rate is equal to the net closing rate
+            ! times the ice strength.
+            !
+            ! NOTE: The NET closing rate is equal to the rate that open water 
+            !  area is removed, plus the rate at which ice area is removed by 
+            !  ridging, minus the rate at which area is added in new ridges.
+            !  The GROSS closing rate is equal to the first two terms (open
+            !  water closing and thin ice ridging) without the third term
+            !  (thick, newly ridged ice).
+
+            closing_net(ji,jj) = &
+               Cs*0.5*(Delta_i(ji,jj)-ABS(divu_i(ji,jj))) - MIN(divu_i(ji,jj),0.0)
+
+            ! 2.2 divu_adv
+            !--------------
+            ! Compute divu_adv, the divergence rate given by the transport/
+            ! advection scheme, which may not be equal to divu as computed 
+            ! from the velocity field.
+            !
+            ! If divu_adv < 0, make sure the closing rate is large enough
+            ! to give asum = 1.0 after ridging.
+
+            divu_adv(ji,jj) = (1.0-asum(ji,jj)) / rdt_ice  ! asum found in ridgeprep
+
+            IF (divu_adv(ji,jj) .LT. 0.0) &
+               closing_net(ji,jj) = max(closing_net(ji,jj), -divu_adv(ji,jj))
+
+            ! 2.3 opning
+            !------------
+            ! Compute the (non-negative) opening rate that will give 
+            ! asum = 1.0 after ridging.
+            opning(ji,jj) = closing_net(ji,jj) + divu_adv(ji,jj)
+
+         END DO
+      END DO
+
+      !-----------------------------------------------------------------------------!
+      ! 3) Ridging iteration
+      !-----------------------------------------------------------------------------!
+      niter = 1                 ! iteration counter
+      iterate_ridging = 1
+
+
+      DO WHILE ( iterate_ridging > 0 .AND. niter < nitermax )
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               ! 3.2 closing_gross
+               !-----------------------------------------------------------------------------!
+               ! Based on the ITD of ridging and ridged ice, convert the net
+               !  closing rate to a gross closing rate.  
+               ! NOTE: 0 < aksum <= 1
+               closing_gross(ji,jj) = closing_net(ji,jj) / aksum(ji,jj)
+
+               ! correction to closing rate and opening if closing rate is excessive
+               !---------------------------------------------------------------------
+               ! Reduce the closing rate if more than 100% of the open water 
+               ! would be removed.  Reduce the opening rate proportionately.
+               IF ( ato_i(ji,jj) .GT. epsi11 .AND. athorn(ji,jj,0) .GT. 0.0 ) THEN
+                  w1 = athorn(ji,jj,0) * closing_gross(ji,jj) * rdt_ice
+                  IF ( w1 .GT. ato_i(ji,jj)) THEN
+                     tmpfac = ato_i(ji,jj) / w1
+                     closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac
+                     opning(ji,jj) = opning(ji,jj) * tmpfac
+                  ENDIF !w1
+               ENDIF !at0i and athorn
+
+            END DO ! ji
+         END DO ! jj
+
+         ! correction to closing rate / opening if excessive ice removal
+         !---------------------------------------------------------------
+         ! Reduce the closing rate if more than 100% of any ice category 
+         ! would be removed.  Reduce the opening rate proportionately.
+
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF ( a_i(ji,jj,jl) .GT. epsi11 .AND. athorn(ji,jj,jl) .GT. 0.0 ) THEN
+                     w1 = athorn(ji,jj,jl) * closing_gross(ji,jj) * rdt_ice
+                     IF ( w1 .GT. a_i(ji,jj,jl) ) THEN
+                        tmpfac = a_i(ji,jj,jl) / w1
+                        closing_gross(ji,jj) = closing_gross(ji,jj) * tmpfac
+                        opning(ji,jj) = opning(ji,jj) * tmpfac
+                     ENDIF
+                  ENDIF
+               END DO !ji
+            END DO ! jj
+         END DO !jl
+
+         ! 3.3 Redistribute area, volume, and energy.
+         !-----------------------------------------------------------------------------!
+
+         CALL lim_itd_me_ridgeshift (opning,    closing_gross, &
+            msnow_mlt, esnow_mlt)
+
+         ! 3.4 Compute total area of ice plus open water after ridging.
+         !-----------------------------------------------------------------------------!
+
+         CALL lim_itd_me_asumr
+
+         ! 3.5 Do we keep on iterating ???
+         !-----------------------------------------------------------------------------!
+         ! Check whether asum = 1.  If not (because the closing and opening
+         ! rates were reduced above), ridge again with new rates.
+
+         iterate_ridging = 0
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (ABS(asum(ji,jj) - 1.0) .LT. epsi11) THEN
+                  closing_net(ji,jj) = 0.0 
+                  opning(ji,jj)      = 0.0
+               ELSE
+                  iterate_ridging    = 1
+                  divu_adv(ji,jj)    = (1.0 - asum(ji,jj)) / rdt_ice
+                  closing_net(ji,jj) = MAX(0.0, -divu_adv(ji,jj))
+                  opning(ji,jj)      = MAX(0.0, divu_adv(ji,jj))
+               ENDIF
+            END DO
+         END DO
+
+         IF( lk_mpp ) CALL mpp_max(iterate_ridging)
+
+         ! Repeat if necessary.
+         ! NOTE: If strength smoothing is turned on, the ridging must be
+         ! iterated globally because of the boundary update in the 
+         ! smoothing.
+
+         niter = niter + 1
+
+         IF (iterate_ridging == 1) THEN
+            IF (niter .GT. nitermax) THEN
+               WRITE(numout,*) ' ALERTE : non-converging ridging scheme '
+               WRITE(numout,*) ' niter, iterate_ridging ', niter, iterate_ridging
+            ENDIF
+            CALL lim_itd_me_ridgeprep
+         ENDIF
+
+      END DO !! on the do while over iter
+
+      !-----------------------------------------------------------------------------!
+      ! 4) Ridging diagnostics
+      !-----------------------------------------------------------------------------!
+      ! Convert ridging rate diagnostics to correct units.
+      ! Update fresh water and heat fluxes due to snow melt.
+
+      dti = 1.0/rdt_ice
+
+      asum_error = .false. 
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            IF (ABS(asum(ji,jj) - 1.0) .GT. epsi11) asum_error = .true.
+
+            dardg1dt(ji,jj) = dardg1dt(ji,jj) * dti
+            dardg2dt(ji,jj) = dardg2dt(ji,jj) * dti
+            dvirdgdt(ji,jj) = dvirdgdt(ji,jj) * dti
+            opening (ji,jj) = opening (ji,jj) * dti
+
+            !-----------------------------------------------------------------------------!
+            ! 5) Heat, salt and freshwater fluxes
+            !-----------------------------------------------------------------------------!
+            ! fresh water source for ocean
+            fmmec(ji,jj)      = fmmec(ji,jj)      + msnow_mlt(ji,jj)*dti  
+
+            ! heat sink for ocean
+            fhmec(ji,jj)      = fhmec(ji,jj)      + esnow_mlt(ji,jj)*dti
+
+         END DO
+      END DO
+
+      ! Check if there is a ridging error
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF (ABS(asum(ji,jj) - 1.0) .GT. epsi11) THEN ! there is a bug
+               WRITE(numout,*) ' '
+               WRITE(numout,*) ' ALERTE : Ridging error: total area = ', asum(ji,jj)
+               WRITE(numout,*) ' limitd_me '
+               WRITE(numout,*) ' POINT : ', ji, jj
+               WRITE(numout,*) ' jpl, a_i, athorn '
+               WRITE(numout,*) 0, ato_i(ji,jj), athorn(ji,jj,0)
+               DO jl = 1, jpl
+                  WRITE(numout,*) jl, a_i(ji,jj,jl), athorn(ji,jj,jl)
+               END DO
+            ENDIF  ! asum
+
+         END DO !ji
+      END DO !jj
+
+      ! Conservation check
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vt_i_final)
+         fieldid = ' v_i : limitd_me '
+         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid) 
+      ENDIF
+
+      !-----------------------------------------------------------------------------!
+      ! 6) Updating state variables and trend terms
+      !-----------------------------------------------------------------------------!
+
+      CALL lim_var_glo2eqv
+      CALL lim_itd_me_zapsmall
+
+      !-----------------
+      !  Trend terms
+      !-----------------
+
+      d_u_ice_dyn(:,:) = u_ice(:,:) - old_u_ice(:,:)
+      d_v_ice_dyn(:,:) = v_ice(:,:) - old_v_ice(:,:)
+      d_a_i_trp(:,:,:)    = a_i(:,:,:)   - old_a_i(:,:,:)
+      d_v_s_trp(:,:,:)    = v_s(:,:,:)   - old_v_s(:,:,:)  
+      d_v_i_trp(:,:,:)    = v_i(:,:,:)   - old_v_i(:,:,:)   
+      d_e_s_trp(:,:,:,:)  = e_s(:,:,:,:) - old_e_s(:,:,:,:)  
+      d_e_i_trp(:,:,:,:)  = e_i(:,:,:,:) - old_e_i(:,:,:,:)
+      d_oa_i_trp(:,:,:)   = oa_i(:,:,:)  - old_oa_i(:,:,:)
+      d_smv_i_trp(:,:,:)   = 0.0
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &
+         d_smv_i_trp(:,:,:)  = smv_i(:,:,:) - old_smv_i(:,:,:)
+
+      IF(ln_ctl) THEN     ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=area , clinfo1=' lim_itd_me  : cell area :')
+         CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_itd_me  : at_i      :')
+         CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_itd_me  : vt_i      :')
+         CALL prt_ctl(tab2d_1=vt_s , clinfo1=' lim_itd_me  : vt_s      :')
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_itd_me  : a_i      : ')
+            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_itd_me  : ht_i     : ')
+            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_itd_me  : ht_s     : ')
+            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_itd_me  : v_i      : ')
+            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_itd_me  : v_s      : ')
+            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_itd_me  : e_s      : ')
+            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_itd_me  : t_su     : ')
+            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_itd_me  : t_snow   : ')
+            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_itd_me  : sm_i     : ')
+            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_itd_me  : smv_i    : ')
+            DO jk = 1, nlay_i
+               CALL prt_ctl_info(' ')
+               CALL prt_ctl_info(' - Layer : ', ivar1=jk)
+               CALL prt_ctl_info('   ~~~~~~~')
+               CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' lim_itd_me  : t_i      : ')
+               CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' lim_itd_me  : e_i      : ')
+            END DO
+         END DO
+      ENDIF
+
+      !-------------------------!
+      ! Back to initial values
+      !-------------------------!
+
+      ! update of fields will be made later in lim update
+      u_ice(:,:)    = old_u_ice(:,:)
+      v_ice(:,:)    = old_v_ice(:,:)
+      a_i(:,:,:)    = old_a_i(:,:,:)
+      v_s(:,:,:)    = old_v_s(:,:,:)
+      v_i(:,:,:)    = old_v_i(:,:,:)
+      e_s(:,:,:,:)  = old_e_s(:,:,:,:)
+      e_i(:,:,:,:)  = old_e_i(:,:,:,:)
+      oa_i(:,:,:)   = old_oa_i(:,:,:)
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
+         smv_i(:,:,:)  = old_smv_i(:,:,:)
+
+      !----------------------------------------------------!
+      ! Advection of ice in a free cell, newly ridged ice
+      !----------------------------------------------------!
+
+      ! to allow for thermodynamics to melt new ice
+      ! we immediately advect ice in free cells
+
+      ! heat content has to be corrected before ice volume
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF ( ( old_v_i(ji,jj,jl) .LT. epsi06 ) .AND. &
+                     ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN
+                     old_e_i(ji,jj,jk,jl)   = d_e_i_trp(ji,jj,jk,jl)
+                     d_e_i_trp(ji,jj,jk,jl) = 0.0
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      END DO
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ( old_v_i(ji,jj,jl) .LT. epsi06 ) .AND. &
+                  ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN
+                  old_v_i(ji,jj,jl)     = d_v_i_trp(ji,jj,jl)
+                  d_v_i_trp(ji,jj,jl)   = 0.0
+                  old_a_i(ji,jj,jl)     = d_a_i_trp(ji,jj,jl)
+                  d_a_i_trp(ji,jj,jl)   = 0.0
+                  old_v_s(ji,jj,jl)     = d_v_s_trp(ji,jj,jl)
+                  d_v_s_trp(ji,jj,jl)   = 0.0
+                  old_e_s(ji,jj,1,jl)   = d_e_s_trp(ji,jj,1,jl)
+                  d_e_s_trp(ji,jj,1,jl) = 0.0
+                  old_oa_i(ji,jj,jl)    = d_oa_i_trp(ji,jj,jl)
+                  d_oa_i_trp(ji,jj,jl)  = 0.0
+                  IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
+                     old_smv_i(ji,jj,jl)   = d_smv_i_trp(ji,jj,jl)
+                  d_smv_i_trp(ji,jj,jl) = 0.0
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE lim_itd_me
+
+   !===============================================================================
+
+   SUBROUTINE lim_itd_me_icestrength (kstrngth) ! (subroutine 2/6)
+
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_me_icestrength ***
+      !! ** Purpose :
+      !!        This routine computes ice strength used in dynamics routines
+      !!                      of ice thickness
+      !!
+      !! ** Method  :
+      !!       Compute the strength of the ice pack, defined as the energy (J m-2) 
+      !! dissipated per unit area removed from the ice pack under compression,
+      !! and assumed proportional to the change in potential energy caused
+      !! by ridging. Note that only Hibler's formulation is stable and that
+      !! ice strength has to be smoothed
+      !!
+      !! ** Inputs / Ouputs : kstrngth (what kind of ice strength we are using)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!                
+      !!----------------------------------------------------------------------
+      !! * Arguments
+
+      INTEGER, INTENT(in) :: &
+         kstrngth    ! = 1 for Rothrock formulation, 0 for Hibler (1979)
+
+      INTEGER ::   &
+         ji,jj,    &         !: horizontal indices
+         jl,       &         !: thickness category index
+         ksmooth,  &         !: smoothing the resistance to deformation
+         numts_rm            !: number of time steps for the P smoothing
+
+      REAL(wp) ::  &  
+         hi,       &         !: ice thickness (m)
+         zw1,      &         !: temporary variable
+         zp,       &         !: temporary ice strength 
+         zdummy
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zworka              !: temporary array used here
+
+      !------------------------------------------------------------------------------!
+      ! 1) Initialize
+      !------------------------------------------------------------------------------!
+      strength(:,:) = 0.0
+
+      !------------------------------------------------------------------------------!
+      ! 2) Compute thickness distribution of ridging and ridged ice
+      !------------------------------------------------------------------------------!
+      CALL lim_itd_me_ridgeprep
+
+      !------------------------------------------------------------------------------!
+      ! 3) Rothrock(1975)'s method
+      !------------------------------------------------------------------------------!
+      IF (kstrngth == 1) then
+
+         DO jl = 1, jpl
+            DO jj= 1, jpj
+               DO ji = 1, jpi
+
+                  IF(     ( a_i(ji,jj,jl)    .GT. epsi11 )                     &
+                     .AND. ( athorn(ji,jj,jl) .GT. 0.0    ) ) THEN
+                     hi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+                     !----------------------------
+                     ! PE loss from deforming ice
+                     !----------------------------
+                     strength(ji,jj) = strength(ji,jj) - athorn(ji,jj,jl) *    &
+                        hi * hi
+
+                     !--------------------------
+                     ! PE gain from rafting ice
+                     !--------------------------
+                     strength(ji,jj) = strength(ji,jj) + 2.0 * araft(ji,jj,jl) &
+                        * hi * hi
+
+                     !----------------------------
+                     ! PE gain from ridging ice
+                     !----------------------------
+                     strength(ji,jj) = strength(ji,jj)                         &
+                        + aridge(ji,jj,jl)/krdg(ji,jj,jl)                         &
+                        * 1.0/3.0 * (hrmax(ji,jj,jl)**3 - hrmin(ji,jj,jl)**3)     &
+                        / (hrmax(ji,jj,jl)-hrmin(ji,jj,jl))                      
+                  ENDIF            ! aicen > epsi11
+
+               END DO ! ji
+            END DO !jj
+         END DO !jl
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               strength(ji,jj) = Cf * Cp * strength(ji,jj) / aksum(ji,jj) 
+               ! Cp = (g/2)*(rhow-rhoi)*(rhoi/rhow)
+               ! Cf accounts for frictional dissipation
+
+            END DO              ! j
+         END DO                 ! i
+
+         ksmooth = 1
+
+         !------------------------------------------------------------------------------!
+         ! 4) Hibler (1979)' method
+         !------------------------------------------------------------------------------!
+      ELSE                      ! kstrngth ne 1:  Hibler (1979) form
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               strength(ji,jj) = Pstar*vt_i(ji,jj)*exp(-C_rhg*(1.0-at_i(ji,jj)))
+            END DO              ! j
+         END DO                 ! i
+
+         ksmooth = 1
+
+      ENDIF                     ! kstrngth
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 5) Impact of brine volume
+      !------------------------------------------------------------------------------!
+      ! CAN BE REMOVED
+      !
+      IF ( brinstren_swi .EQ. 1 ) THEN
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( bv_i(ji,jj) .GT. 0.0 ) THEN
+                  zdummy = MIN ( bv_i(ji,jj), 0.10 ) * MIN( bv_i(ji,jj), 0.10 )
+               ELSE
+                  zdummy = 0.0
+               ENDIF
+               strength(ji,jj) = strength(ji,jj) * exp(-5.88*SQRT(MAX(bv_i(ji,jj),0.0)))
+            END DO              ! j
+         END DO                 ! i
+
+      ENDIF
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 6) Smoothing ice strength
+      !------------------------------------------------------------------------------!
+      !
+      !-------------------
+      ! Spatial smoothing
+      !-------------------
+      IF ( ksmooth .EQ. 1 ) THEN
+
+         CALL lbc_lnk( strength, 'T', 1. )
+
+         DO jj = 2, jpj - 1
+            DO ji = 2, jpi - 1
+               IF ( ( asum(ji,jj) - ato_i(ji,jj) ) .GT. epsi11) THEN ! ice is
+                  ! present
+                  zworka(ji,jj) = 4.0 * strength(ji,jj)              &
+                     + strength(ji-1,jj) * tms(ji-1,jj) &  
+                     + strength(ji+1,jj) * tms(ji+1,jj) &  
+                     + strength(ji,jj-1) * tms(ji,jj-1) &  
+                     + strength(ji,jj+1) * tms(ji,jj+1)    
+
+                  zw1 = 4.0 + tms(ji-1,jj) + tms(ji+1,jj)            &
+                     + tms(ji,jj-1) + tms(ji,jj+1)
+                  zworka(ji,jj) = zworka(ji,jj) / zw1
+               ELSE
+                  zworka(ji,jj) = 0.0
+               ENDIF
+            END DO
+         END DO
+
+         DO jj = 2, jpj - 1
+            DO ji = 2, jpi - 1
+               strength(ji,jj) = zworka(ji,jj)
+            END DO
+         END DO
+         CALL lbc_lnk( strength, 'T', 1. )
+
+      ENDIF ! ksmooth
+
+      !--------------------
+      ! Temporal smoothing
+      !--------------------
+      IF ( numit .EQ. nit000 + nn_fsbc - 1 ) THEN
+         strp1(:,:) = 0.0            
+         strp2(:,:) = 0.0            
+      ENDIF
+
+      IF ( ksmooth .EQ. 2 ) THEN
+
+
+         CALL lbc_lnk( strength, 'T', 1. )
+
+         DO jj = 1, jpj - 1
+            DO ji = 1, jpi - 1
+               IF ( ( asum(ji,jj) - ato_i(ji,jj) ) .GT. epsi11) THEN ! ice is
+                  ! present
+                  numts_rm = 1 ! number of time steps for the running mean
+                  IF ( strp1(ji,jj) .GT. 0.0 ) numts_rm = numts_rm + 1
+                  IF ( strp2(ji,jj) .GT. 0.0 ) numts_rm = numts_rm + 1
+                  zp = ( strength(ji,jj) + strp1(ji,jj) + strp2(ji,jj) ) /   &
+                     numts_rm
+                  strp2(ji,jj) = strp1(ji,jj)
+                  strp1(ji,jj) = strength(ji,jj)
+                  strength(ji,jj) = zp
+
+               ENDIF
+            END DO
+         END DO
+
+      ENDIF ! ksmooth
+
+      ! Boundary conditions
+      CALL lbc_lnk( strength, 'T', 1. )
+
+   END SUBROUTINE lim_itd_me_icestrength
+
+   !===============================================================================
+
+   SUBROUTINE lim_itd_me_ridgeprep !(subroutine 3/6)
+
+      !!---------------------------------------------------------------------!
+      !!                ***  ROUTINE lim_itd_me_ridgeprep ***
+      !! ** Purpose :
+      !!         preparation for ridging and strength calculations
+      !!
+      !! ** Method  :
+      !! Compute the thickness distribution of the ice and open water 
+      !! participating in ridging and of the resulting ridges.
+      !!
+      !! ** Arguments :
+      !!
+      !! ** External : 
+      !!
+      !!---------------------------------------------------------------------!
+      !! * Arguments
+
+      INTEGER :: &
+         ji,jj,  &          ! horizontal indices
+         jl,     &          ! thickness category index
+         krdg_index         ! which participation function using
+
+      REAL(wp)            ::     &
+         Gstari, &          !  = 1.0/Gstar    
+         astari             !  = 1.0/astar
+
+      REAL(wp), DIMENSION(jpi,jpj,-1:jpl) ::    &
+         Gsum             ! Gsum(n) = sum of areas in categories 0 to n
+
+      REAL(wp) ::    &
+         hi,         &    ! ice thickness for each cat (m)
+         hrmean           ! mean ridge thickness (m)
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zworka            ! temporary array used here
+
+      REAL(wp)            ::     &
+         zdummy,                 &
+         epsi06 = 1.0e-6
+
+      !------------------------------------------------------------------------------!
+
+      Gstari     = 1.0/Gstar    
+      astari     = 1.0/astar    
+      aksum(:,:)    = 0.0
+      athorn(:,:,:) = 0.0
+      aridge(:,:,:) = 0.0
+      araft (:,:,:) = 0.0
+      hrmin(:,:,:)  = 0.0 
+      hrmax(:,:,:)  = 0.0 
+      hraft(:,:,:)  = 0.0 
+      krdg (:,:,:)  = 1.0
+
+      !     ! Zero out categories with very small areas
+      CALL lim_itd_me_zapsmall
+
+      !------------------------------------------------------------------------------!
+      ! 1) Participation function 
+      !------------------------------------------------------------------------------!
+
+      ! Compute total area of ice plus open water.
+      CALL lim_itd_me_asumr
+      ! This is in general not equal to one 
+      ! because of divergence during transport
+
+      ! Compute cumulative thickness distribution function
+      ! Compute the cumulative thickness distribution function Gsum,
+      ! where Gsum(n) is the fractional area in categories 0 to n.
+      ! initial value (in h = 0) equals open water area
+
+      Gsum(:,:,-1) = 0.0
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF (ato_i(ji,jj) .GT. epsi11) THEN
+               Gsum(ji,jj,0) = ato_i(ji,jj)
+            ELSE
+               Gsum(ji,jj,0) = 0.0
+            ENDIF
+         END DO
+      END DO
+
+      ! for each value of h, you have to add ice concentration then
+      DO jl = 1, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               IF ( a_i(ji,jj,jl) .GT. epsi11 ) THEN
+                  Gsum(ji,jj,jl) = Gsum(ji,jj,jl-1) + a_i(ji,jj,jl)
+               ELSE
+                  Gsum(ji,jj,jl) = Gsum(ji,jj,jl-1)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Normalize the cumulative distribution to 1
+      DO jj = 1, jpj 
+         DO ji = 1, jpi
+            zworka(ji,jj) = 1.0 / Gsum(ji,jj,jpl)
+         END DO
+      END DO
+
+      DO jl = 0, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               Gsum(ji,jj,jl) = Gsum(ji,jj,jl) * zworka(ji,jj)
+            END DO
+         END DO
+      END DO
+
+      ! 1.3 Compute participation function a(h) = b(h).g(h) (athorn)
+      !--------------------------------------------------------------------------------------------------
+      ! Compute the participation function athorn; this is analogous to
+      ! a(h) = b(h)g(h) as defined in Thorndike et al. (1975).
+      ! area lost from category n due to ridging/closing
+      ! athorn(n)   = total area lost due to ridging/closing
+      ! assume b(h) = (2/Gstar) * (1 - G(h)/Gstar). 
+      !
+      ! The expressions for athorn are found by integrating b(h)g(h) between
+      ! the category boundaries.
+      !-----------------------------------------------------------------
+
+      krdg_index = 1
+
+      IF ( krdg_index .EQ. 0 ) THEN
+
+         !--- Linear formulation (Thorndike et al., 1975)
+         DO jl = 0, ice_cat_bounds(1,2) ! only undeformed ice participates
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  IF (Gsum(ji,jj,jl) < Gstar) THEN
+                     athorn(ji,jj,jl) = Gstari * (Gsum(ji,jj,jl)-Gsum(ji,jj,jl-1)) * &
+                        (2.0 - (Gsum(ji,jj,jl-1)+Gsum(ji,jj,jl))*Gstari)
+                  ELSEIF (Gsum(ji,jj,jl-1) < Gstar) THEN
+                     athorn(ji,jj,jl) = Gstari * (Gstar-Gsum(ji,jj,jl-1)) *  &
+                        (2.0 - (Gsum(ji,jj,jl-1)+Gstar)*Gstari)
+                  ELSE
+                     athorn(ji,jj,jl) = 0.0
+                  ENDIF
+               END DO ! ji
+            END DO ! jj
+         END DO ! jl 
+
+      ELSE ! krdg_index = 1
+
+         !--- Exponential, more stable formulation (Lipscomb et al, 2007)
+         ! precompute exponential terms using Gsum as a work array
+         zdummy = 1.0 / (1.0-EXP(-astari))
+
+         DO jl = -1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  Gsum(ji,jj,jl) = EXP(-Gsum(ji,jj,jl)*astari)*zdummy
+               END DO !ji
+            END DO !jj
+         END DO !jl
+
+         ! compute athorn
+         DO jl = 0, ice_cat_bounds(1,2)
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  athorn(ji,jj,jl) = Gsum(ji,jj,jl-1) - Gsum(ji,jj,jl)
+               END DO !ji
+            END DO ! jj
+         END DO !jl
+
+      ENDIF ! krdg_index
+
+      ! Ridging and rafting ice participation functions
+      IF ( raftswi .EQ. 1 ) THEN
+
+         DO jl = 1, jpl
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  IF ( athorn(ji,jj,jl) .GT. 0.0 ) THEN
+                     aridge(ji,jj,jl) = ( TANH ( Craft * ( ht_i(ji,jj,jl) - &
+                        hparmeter ) ) + 1.0 ) / 2.0 * & 
+                        athorn(ji,jj,jl)
+                     araft (ji,jj,jl) = ( TANH ( - Craft * ( ht_i(ji,jj,jl) - &
+                        hparmeter ) ) + 1.0 ) / 2.0 * &
+                        athorn(ji,jj,jl)
+                     IF ( araft(ji,jj,jl) .LT. epsi06 ) araft(ji,jj,jl)  = 0.0
+                     aridge(ji,jj,jl) = MAX( athorn(ji,jj,jl) - araft(ji,jj,jl), 0.0)
+                  ENDIF ! athorn
+               END DO ! ji
+            END DO ! jj
+         END DO ! jl
+
+      ELSE  ! raftswi = 0
+
+         DO jl = 1, jpl
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  aridge(ji,jj,jl) = 1.0*athorn(ji,jj,jl)
+               END DO
+            END DO
+         END DO
+
+      ENDIF
+
+      IF ( raftswi .EQ. 1 ) THEN
+
+         IF( MAXVAL(aridge + araft - athorn(:,:,1:jpl)) .GT. epsi11 ) THEN
+            DO jl = 1, jpl
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) .GT. &
+                        epsi11 ) THEN
+                        WRITE(numout,*) ' ALERTE 96 : wrong participation function ... '
+                        WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl
+                        WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj)
+                        WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl)
+                        WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl)
+                        WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+         ENDIF
+
+      ENDIF
+
+      !-----------------------------------------------------------------
+      ! 2) Transfer function
+      !-----------------------------------------------------------------
+      ! Compute max and min ridged ice thickness for each ridging category.
+      ! Assume ridged ice is uniformly distributed between hrmin and hrmax.
+      ! 
+      ! This parameterization is a modified version of Hibler (1980).
+      ! The mean ridging thickness, hrmean, is proportional to hi^(0.5)
+      !  and for very thick ridging ice must be >= krdgmin*hi
+      !
+      ! The minimum ridging thickness, hrmin, is equal to 2*hi 
+      !  (i.e., rafting) and for very thick ridging ice is
+      !  constrained by hrmin <= (hrmean + hi)/2.
+      ! 
+      ! The maximum ridging thickness, hrmax, is determined by
+      !  hrmean and hrmin.
+      !
+      ! These modifications have the effect of reducing the ice strength
+      ! (relative to the Hibler formulation) when very thick ice is
+      ! ridging.
+      !
+      ! aksum = net area removed/ total area removed
+      ! where total area removed = area of ice that ridges
+      !         net area removed = total area removed - area of new ridges
+      !-----------------------------------------------------------------
+
+      ! Transfer function
+      DO jl = 1, jpl !all categories have a specific transfer function
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               IF (a_i(ji,jj,jl) .GT. epsi11 .AND. athorn(ji,jj,jl) .GT. 0.0 ) THEN
+                  hi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+                  hrmean          = MAX(SQRT(Hstar*hi), hi*krdgmin)
+                  hrmin(ji,jj,jl) = MIN(2.0*hi, 0.5*(hrmean + hi))
+                  hrmax(ji,jj,jl) = 2.0*hrmean - hrmin(ji,jj,jl)
+                  hraft(ji,jj,jl) = kraft*hi
+                  krdg(ji,jj,jl)  = hrmean / hi
+               ELSE
+                  hraft(ji,jj,jl) = 0.0
+                  hrmin(ji,jj,jl) = 0.0 
+                  hrmax(ji,jj,jl) = 0.0 
+                  krdg (ji,jj,jl) = 1.0
+               ENDIF
+
+            END DO ! ji
+         END DO ! jj
+      END DO ! jl
+
+      ! Normalization factor : aksum, ensures mass conservation
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            aksum(ji,jj) = athorn(ji,jj,0)
+         END DO
+      END DO
+
+      DO jl = 1, jpl 
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               aksum(ji,jj)    = aksum(ji,jj)                          &
+                  + aridge(ji,jj,jl) * (1.0 - 1.0/krdg(ji,jj,jl))    &
+                  + araft (ji,jj,jl) * (1.0 - 1.0/kraft)
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE lim_itd_me_ridgeprep
+
+   !===============================================================================
+
+   SUBROUTINE lim_itd_me_ridgeshift(opning,    closing_gross,       &
+      msnow_mlt, esnow_mlt) ! (subroutine 4/6)
+
+      !!-----------------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_me_icestrength ***
+      !! ** Purpose :
+      !!        This routine shift ridging ice among thickness categories
+      !!                      of ice thickness
+      !!
+      !! ** Method  :
+      !! Remove area, volume, and energy from each ridging category
+      !! and add to thicker ice categories.
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : 
+      !!
+      !! ** External : 
+      !!
+
+      REAL (wp), DIMENSION(jpi,jpj), INTENT(IN)   :: &
+         opning,         & ! rate of opening due to divergence/shear
+         closing_gross     ! rate at which area removed, not counting
+      ! area of new ridges
+
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: &
+         msnow_mlt,     & ! mass of snow added to ocean (kg m-2)
+         esnow_mlt        ! energy needed to melt snow in ocean (J m-2)
+
+      INTEGER :: &
+         ji, jj, &         ! horizontal indices
+         jl, jl1, jl2, &   ! thickness category indices
+         jk,           &   ! ice layer index
+         ij,           &   ! horizontal index, combines i and j loops
+         icells            ! number of cells with aicen > puny
+
+      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+         indxi, indxj      ! compressed indices
+
+      REAL(wp), DIMENSION(jpi,jpj) ::          &
+         vice_init, vice_final, &  ! ice volume summed over categories
+         eice_init, eice_final     ! ice energy summed over layers
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::      &
+         aicen_init,            &  ! ice area before ridging
+         vicen_init,            &  ! ice volume before ridging
+         vsnon_init,            &  ! snow volume before ridging
+         esnon_init,            &  ! snow energy before ridging
+         smv_i_init,            &  ! ice salinity before ridging
+         oa_i_init                 ! ice age before ridging
+
+      REAL(wp), DIMENSION(jpi,jpj,jkmax,jpl) :: &
+         eicen_init        ! ice energy before ridging
+
+      REAL(wp), DIMENSION(jpi,jpj) ::           &
+         afrac      , &     ! fraction of category area ridged
+         ardg1      , &     ! area of ice ridged
+         ardg2      , &     ! area of new ridges
+         vsrdg      , &     ! snow volume of ridging ice
+         esrdg      , &     ! snow energy of ridging ice
+         oirdg1     , &     ! areal age content of ridged ice
+         oirdg2     , &     ! areal age content of ridging ice
+         dhr        , &     ! hrmax - hrmin
+         dhr2       , &     ! hrmax^2 - hrmin^2
+         fvol               ! fraction of new ridge volume going to n2
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         vrdg1      , &     ! volume of ice ridged
+         vrdg2      , &     ! volume of new ridges
+         vsw        , &     ! volume of seawater trapped into ridges
+         srdg1      , &     ! sal*volume of ice ridged
+         srdg2      , &     ! sal*volume of new ridges
+         smsw               ! sal*volume of water trapped into ridges
+
+      REAL(wp), DIMENSION(jpi,jpj) ::           &
+         afrft      , &     ! fraction of category area rafted
+         arft1      , &     ! area of ice rafted
+         arft2      , &     ! area of new rafted zone
+         virft      , &     ! ice volume of rafting ice
+         vsrft      , &     ! snow volume of rafting ice
+         esrft      , &     ! snow energy of rafting ice
+         smrft      , &     ! salinity of rafting ice
+         oirft1     , &     ! areal age content of rafted ice
+         oirft2             ! areal age content of rafting ice
+
+      REAL(wp), DIMENSION(jpi,jpj,jkmax) ::    &
+         eirft      , &     ! ice energy of rafting ice
+         erdg1      , &     ! enth*volume of ice ridged
+         erdg2      , &     ! enth*volume of new ridges
+         ersw               ! enth of water trapped into ridges
+
+      REAL(wp) ::     &
+         hL, hR     , &    ! left and right limits of integration
+         farea      , &    ! fraction of new ridge area going to n2
+         zdummy     , &    ! dummy argument
+         zdummy0    , &    ! dummy argument
+         ztmelts           ! ice melting point
+
+      REAL(wp) ::   zsrdg2
+
+      CHARACTER (len=80) :: &
+         fieldid           ! field identifier
+
+      LOGICAL, PARAMETER :: &
+         l_conservation_check = .true.  ! if true, check conservation 
+      ! (useful for debugging)
+      LOGICAL ::         &
+         neg_ato_i     , &  ! flag for ato_i(i,j) < -puny
+         large_afrac   , &  ! flag for afrac > 1
+         large_afrft        ! flag for afrac > 1
+
+      REAL(wp) ::        &
+         zeps          , &
+         epsi10        , &
+         zindb              ! switch for the presence of ridge poros or not
+
+      !----------------------------------------------------------------------------
+
+      ! Conservation check
+      eice_init(:,:) = 0.0 
+
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vice_init )
+         WRITE(numout,*) ' vice_init  : ', vice_init(jiindx,jjindx)
+         CALL lim_column_sum_energy (jpl, nlay_i,  e_i, eice_init )
+         WRITE(numout,*) ' eice_init  : ', eice_init(jiindx,jjindx)
+      ENDIF
+
+      zeps   = 1.0d-20
+      epsi10 = 1.0d-10
+
+      !-------------------------------------------------------------------------------
+      ! 1) Compute change in open water area due to closing and opening.
+      !-------------------------------------------------------------------------------
+
+      neg_ato_i = .false.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ato_i(ji,jj) = ato_i(ji,jj)                                   &
+               - athorn(ji,jj,0)*closing_gross(ji,jj)*rdt_ice        &
+               + opning(ji,jj)*rdt_ice
+            IF (ato_i(ji,jj) .LT. -epsi11) THEN
+               neg_ato_i = .true.
+            ELSEIF (ato_i(ji,jj) .LT. 0.0) THEN    ! roundoff error
+               ato_i(ji,jj) = 0.0
+            ENDIF
+         END DO !jj
+      END DO !ji
+
+      ! if negative open water area alert it
+      IF (neg_ato_i) THEN       ! there is a bug
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               IF (ato_i(ji,jj) .LT. -epsi11) THEN 
+                  WRITE(numout,*) ''  
+                  WRITE(numout,*) 'Ridging error: ato_i < 0'
+                  WRITE(numout,*) 'ato_i : ', ato_i(ji,jj)
+               ENDIF               ! ato_i < -epsi11
+            END DO              ! ji
+         END DO                 ! jj
+      ENDIF                     ! neg_ato_i
+
+      !-----------------------------------------------------------------
+      ! 2) Save initial state variables
+      !-----------------------------------------------------------------
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               aicen_init(ji,jj,jl) = a_i(ji,jj,jl)
+               vicen_init(ji,jj,jl) = v_i(ji,jj,jl)
+               vsnon_init(ji,jj,jl) = v_s(ji,jj,jl)
+
+               smv_i_init(ji,jj,jl) = smv_i(ji,jj,jl)
+               oa_i_init (ji,jj,jl) = oa_i(ji,jj,jl)
+            END DO !ji
+         END DO ! jj
+      END DO !jl
+
+      esnon_init(:,:,:) = e_s(:,:,1,:)
+
+      DO jl = 1, jpl  
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  eicen_init(ji,jj,jk,jl) = e_i(ji,jj,jk,jl)
+               END DO !ji
+            END DO !jj
+         END DO !jk
+      END DO !jl
+
+      !
+      !-----------------------------------------------------------------
+      ! 3) Pump everything from ice which is being ridged / rafted
+      !-----------------------------------------------------------------
+      ! Compute the area, volume, and energy of ice ridging in each
+      ! category, along with the area of the resulting ridge.
+
+      DO jl1 = 1, jpl !jl1 describes the ridging category
+
+         !------------------------------------------------
+         ! 3.1) Identify grid cells with nonzero ridging
+         !------------------------------------------------
+
+         icells = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (aicen_init(ji,jj,jl1) .GT. epsi11 .AND. athorn(ji,jj,jl1) .GT. 0.0       &
+                  .AND. closing_gross(ji,jj) > 0.0) THEN
+                  icells = icells + 1
+                  indxi(icells) = ji
+                  indxj(icells) = jj
+               ENDIF ! test on a_icen_init 
+            END DO ! ji
+         END DO ! jj
+
+         large_afrac = .false.
+         large_afrft = .false.
+
+!CDIR NODEP
+         DO ij = 1, icells
+            ji = indxi(ij)
+            jj = indxj(ij)
+
+            !--------------------------------------------------------------------
+            ! 3.2) Compute area of ridging ice (ardg1) and of new ridge (ardg2)
+            !--------------------------------------------------------------------
+
+            ardg1(ji,jj) = aridge(ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
+            arft1(ji,jj) = araft (ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
+            ardg2(ji,jj) = ardg1(ji,jj) / krdg(ji,jj,jl1)
+            arft2(ji,jj) = arft1(ji,jj) / kraft
+
+            oirdg1(ji,jj)= aridge(ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
+            oirft1(ji,jj)= araft (ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
+            oirdg2(ji,jj)= oirdg1(ji,jj) / krdg(ji,jj,jl1)
+            oirft2(ji,jj)= oirft1(ji,jj) / kraft
+
+            !---------------------------------------------------------------
+            ! 3.3) Compute ridging /rafting fractions, make sure afrac <=1 
+            !---------------------------------------------------------------
+
+            afrac(ji,jj) = ardg1(ji,jj) / aicen_init(ji,jj,jl1) !ridging
+            afrft(ji,jj) = arft1(ji,jj) / aicen_init(ji,jj,jl1) !rafting
+
+            IF (afrac(ji,jj) > 1.0 + epsi11) THEN  !riging
+               large_afrac = .true.
+            ELSEIF (afrac(ji,jj) > 1.0) THEN  ! roundoff error
+               afrac(ji,jj) = 1.0
+            ENDIF
+            IF (afrft(ji,jj) > 1.0 + epsi11) THEN !rafting
+               large_afrft = .true.
+            ELSEIF (afrft(ji,jj) > 1.0) THEN  ! roundoff error
+               afrft(ji,jj) = 1.0
+            ENDIF
+
+            !--------------------------------------------------------------------------
+            ! 3.4) Subtract area, volume, and energy from ridging 
+            !     / rafting category n1.
+            !--------------------------------------------------------------------------
+            vrdg1(ji,jj) = vicen_init(ji,jj,jl1) * afrac(ji,jj) /             &
+               ( 1.0 + ridge_por )
+            vrdg2(ji,jj) = vrdg1(ji,jj) * ( 1. + ridge_por )
+            vsw  (ji,jj) = vrdg1(ji,jj) * ridge_por
+
+            vsrdg(ji,jj) = vsnon_init(ji,jj,jl1) * afrac(ji,jj)
+            esrdg(ji,jj) = esnon_init(ji,jj,jl1) * afrac(ji,jj)
+            srdg1(ji,jj) = smv_i_init(ji,jj,jl1) * afrac(ji,jj) /            &
+               ( 1. + ridge_por )
+            srdg2(ji,jj) = smv_i_init(ji,jj,jl1) * afrac(ji,jj)
+
+            ! rafting volumes, heat contents ...
+            virft(ji,jj) = vicen_init(ji,jj,jl1) * afrft(ji,jj)
+            vsrft(ji,jj) = vsnon_init(ji,jj,jl1) * afrft(ji,jj)
+            esrft(ji,jj) = esnon_init(ji,jj,jl1) * afrft(ji,jj)
+            smrft(ji,jj) = smv_i_init(ji,jj,jl1) * afrft(ji,jj) 
+
+            ! substract everything
+            a_i(ji,jj,jl1)   = a_i(ji,jj,jl1)   - ardg1(ji,jj)  - arft1(ji,jj)
+            v_i(ji,jj,jl1)   = v_i(ji,jj,jl1)   - vrdg1(ji,jj)  - virft(ji,jj)
+            v_s(ji,jj,jl1)   = v_s(ji,jj,jl1)   - vsrdg(ji,jj)  - vsrft(ji,jj)
+            e_s(ji,jj,1,jl1) = e_s(ji,jj,1,jl1) - esrdg(ji,jj)  - esrft(ji,jj)
+            oa_i(ji,jj,jl1)  = oa_i(ji,jj,jl1)  - oirdg1(ji,jj) - oirft1(ji,jj)
+            smv_i(ji,jj,jl1) = smv_i(ji,jj,jl1) - srdg1(ji,jj)  - smrft(ji,jj)
+
+            !-----------------------------------------------------------------
+            ! 3.5) Compute properties of new ridges
+            !-----------------------------------------------------------------
+            !-------------
+            ! Salinity
+            !-------------
+            smsw(ji,jj)  = sss_m(ji,jj) * vsw(ji,jj) * rhoic / rau0       ! salt content of water frozen in voids
+
+            zsrdg2       = srdg1(ji,jj) + smsw(ji,jj)                     ! salt content of new ridge
+
+            srdg2(ji,jj) = MIN( s_i_max * vrdg2(ji,jj) , zsrdg2 )         ! impose a maximum salinity
+            
+            !                                                             ! excess of salt is flushed into the ocean
+            fsalt_rpo(ji,jj) = fsalt_rpo(ji,jj) + ( zsrdg2 - srdg2(ji,jj) ) * rhoic / rdt_ice
+
+            !------------------------------------            
+            ! 3.6 Increment ridging diagnostics
+            !------------------------------------            
+
+            !        jl1 looping 1-jpl
+            !           ij looping 1-icells
+
+            dardg1dt(ji,jj) = dardg1dt(ji,jj) + ardg1(ji,jj) + arft1(ji,jj)
+            dardg2dt(ji,jj) = dardg2dt(ji,jj) + ardg2(ji,jj) + arft2(ji,jj)
+            diag_dyn_gr(ji,jj) = diag_dyn_gr(ji,jj) + ( vrdg2(ji,jj) + virft(ji,jj) ) / rdt_ice
+            opening(ji,jj)  = opening (ji,jj) + opning(ji,jj)*rdt_ice
+
+            IF (con_i) vice_init(ji,jj) = vice_init(ji,jj) + vrdg2(ji,jj) - vrdg1(ji,jj)
+
+            !------------------------------------------            
+            ! 3.7 Put the snow somewhere in the ocean
+            !------------------------------------------            
+
+            !  Place part of the snow lost by ridging into the ocean. 
+            !  Note that esnow_mlt < 0; the ocean must cool to melt snow.
+            !  If the ocean temp = Tf already, new ice must grow.
+            !  During the next time step, thermo_rates will determine whether
+            !  the ocean cools or new ice grows.
+            !        jl1 looping 1-jpl
+            !           ij looping 1-icells
+
+            msnow_mlt(ji,jj) = msnow_mlt(ji,jj)                  &
+               + rhosn*vsrdg(ji,jj)*(1.0-fsnowrdg)   &
+                                !rafting included
+               + rhosn*vsrft(ji,jj)*(1.0-fsnowrft)
+
+            esnow_mlt(ji,jj) = esnow_mlt(ji,jj)                  &
+               + esrdg(ji,jj)*(1.0-fsnowrdg)         &
+                                !rafting included
+               + esrft(ji,jj)*(1.0-fsnowrft)          
+
+            !-----------------------------------------------------------------
+            ! 3.8 Compute quantities used to apportion ice among categories
+            ! in the n2 loop below
+            !-----------------------------------------------------------------
+
+            !        jl1 looping 1-jpl
+            !           ij looping 1-icells
+
+            dhr(ji,jj)  = hrmax(ji,jj,jl1) - hrmin(ji,jj,jl1)
+            dhr2(ji,jj) = hrmax(ji,jj,jl1) * hrmax(ji,jj,jl1)    &
+               - hrmin(ji,jj,jl1)   * hrmin(ji,jj,jl1)
+
+
+         END DO                 ! ij
+
+         !--------------------------------------------------------------------
+         ! 3.9 Compute ridging ice enthalpy, remove it from ridging ice and
+         !      compute ridged ice enthalpy 
+         !--------------------------------------------------------------------
+         DO jk = 1, nlay_i
+!CDIR NODEP
+            DO ij = 1, icells
+               ji = indxi(ij)
+               jj = indxj(ij)
+               ! heat content of ridged ice
+               erdg1(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrac(ji,jj) / & 
+                  ( 1.0 + ridge_por ) 
+               eirft(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrft(ji,jj)
+               e_i(ji,jj,jk,jl1)    = e_i(ji,jj,jk,jl1)             &
+                  - erdg1(ji,jj,jk)        &
+                  - eirft(ji,jj,jk)
+               ! sea water heat content
+               ztmelts          = - tmut * sss_m(ji,jj) + rtt
+               ! heat content per unit volume
+               zdummy0          = - rcp * ( sst_m(ji,jj) + rt0 - rtt ) * vsw(ji,jj)
+
+               ! corrected sea water salinity
+               zindb  = MAX( 0.0, SIGN( 1.0, vsw(ji,jj) - zeps ) )
+               zdummy = zindb * ( srdg1(ji,jj) - srdg2(ji,jj) ) / &
+                  MAX( ridge_por * vsw(ji,jj), zeps )
+
+               ztmelts          = - tmut * zdummy + rtt
+               ersw(ji,jj,jk)   = - rcp * ( ztmelts - rtt ) * vsw(ji,jj)
+
+               ! heat flux
+               fheat_rpo(ji,jj) = fheat_rpo(ji,jj) + ( ersw(ji,jj,jk) - zdummy0 ) / &
+                  rdt_ice
+
+               ! Correct dimensions to avoid big values
+               ersw(ji,jj,jk)   = ersw(ji,jj,jk) / 1.0d+09
+
+               ! Mutliply by ice volume, and divide by number of layers to get heat content in 10^9 J
+               ersw(ji,jj,jk)   = ersw(ji,jj,jk) * &
+                  area(ji,jj) * vsw(ji,jj) / &
+                  nlay_i
+
+               erdg2(ji,jj,jk)  = erdg1(ji,jj,jk) + ersw(ji,jj,jk)
+            END DO ! ij
+         END DO !jk
+
+
+         IF ( con_i ) THEN
+            DO jk = 1, nlay_i
+!CDIR NODEP
+               DO ij = 1, icells
+                  ji = indxi(ij)
+                  jj = indxj(ij)
+                  eice_init(ji,jj) = eice_init(ji,jj) + erdg2(ji,jj,jk) - &
+                     erdg1(ji,jj,jk)
+               END DO ! ij
+            END DO !jk
+         ENDIF
+
+         IF (large_afrac) THEN  ! there is a bug
+!CDIR NODEP
+            DO ij = 1, icells
+               ji = indxi(ij)
+               jj = indxj(ij)
+               IF ( afrac(ji,jj) > 1.0 + epsi11 ) THEN 
+                  WRITE(numout,*) ''
+                  WRITE(numout,*) ' ardg > a_i'
+                  WRITE(numout,*) ' ardg, aicen_init : ', &
+                     ardg1(ji,jj), aicen_init(ji,jj,jl1)
+               ENDIF            ! afrac > 1 + puny
+            ENDDO               ! if
+         ENDIF                  ! large_afrac
+         IF (large_afrft) THEN  ! there is a bug
+!CDIR NODEP
+            DO ij = 1, icells
+               ji = indxi(ij)
+               jj = indxj(ij)
+               IF ( afrft(ji,jj) > 1.0 + epsi11 ) THEN 
+                  WRITE(numout,*) ''
+                  WRITE(numout,*) ' arft > a_i'
+                  WRITE(numout,*) ' arft, aicen_init : ', &
+                     arft1(ji,jj), aicen_init(ji,jj,jl1)
+               ENDIF            ! afrft > 1 + puny
+            ENDDO               ! if
+         ENDIF                  ! large_afrft
+
+         !-------------------------------------------------------------------------------
+         ! 4) Add area, volume, and energy of new ridge to each category jl2
+         !-------------------------------------------------------------------------------
+         !        jl1 looping 1-jpl
+         DO jl2  = ice_cat_bounds(1,1), ice_cat_bounds(1,2) 
+            ! over categories to which ridged ice is transferred
+!CDIR NODEP
+            DO ij = 1, icells
+               ji = indxi(ij)
+               jj = indxj(ij)
+
+               ! Compute the fraction of ridged ice area and volume going to 
+               ! thickness category jl2.
+               ! Transfer area, volume, and energy accordingly.
+
+               IF (hrmin(ji,jj,jl1) .GE. hi_max(jl2) .OR.        &
+                  hrmax(ji,jj,jl1) .LE. hi_max(jl2-1)) THEN
+                  hL = 0.0
+                  hR = 0.0
+               ELSE
+                  hL = MAX (hrmin(ji,jj,jl1), hi_max(jl2-1))
+                  hR = MIN (hrmax(ji,jj,jl1), hi_max(jl2))
+               ENDIF
+
+               ! fraction of ridged ice area and volume going to n2
+               farea = (hR-hL) / dhr(ji,jj) 
+               fvol(ji,jj) = (hR*hR - hL*hL) / dhr2(ji,jj)
+
+               a_i(ji,jj,jl2)    = a_i(ji,jj,jl2) + farea * ardg2(ji,jj)
+               v_i(ji,jj,jl2)    = v_i(ji,jj,jl2) + fvol(ji,jj) * vrdg2(ji,jj)
+               v_s(ji,jj,jl2)    = v_s(ji,jj,jl2)                             &
+                  + fvol(ji,jj) * vsrdg(ji,jj) * fsnowrdg
+               e_s(ji,jj,1,jl2)  = e_s(ji,jj,1,jl2)                           &
+                  + fvol(ji,jj) * esrdg(ji,jj) * fsnowrdg
+               smv_i(ji,jj,jl2)  = smv_i(ji,jj,jl2) + fvol(ji,jj) * srdg2(ji,jj)
+               oa_i(ji,jj,jl2)   = oa_i(ji,jj,jl2)  + farea * oirdg2(ji,jj)
+
+            END DO ! ij
+
+            ! Transfer ice energy to category jl2 by ridging
+            DO jk = 1, nlay_i
+!CDIR NODEP
+               DO ij = 1, icells
+                  ji = indxi(ij)
+                  jj = indxj(ij)
+                  e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2)          &
+                     + fvol(ji,jj)*erdg2(ji,jj,jk)
+               END DO           ! ij
+            END DO !jk
+
+
+         END DO                 ! jl2 (new ridges)            
+
+         DO jl2  = ice_cat_bounds(1,1), ice_cat_bounds(1,2) 
+
+!CDIR NODEP
+            DO ij = 1, icells
+               ji = indxi(ij)
+               jj = indxj(ij)
+               ! Compute the fraction of rafted ice area and volume going to 
+               ! thickness category jl2, transfer area, volume, and energy accordingly.
+
+               IF (hraft(ji,jj,jl1) .LE. hi_max(jl2) .AND.        &
+                  hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN
+                  a_i(ji,jj,jl2) = a_i(ji,jj,jl2) + arft2(ji,jj)
+                  v_i(ji,jj,jl2) = v_i(ji,jj,jl2) + virft(ji,jj)
+                  v_s(ji,jj,jl2) = v_s(ji,jj,jl2)                   &
+                     + vsrft(ji,jj)*fsnowrft
+                  e_s(ji,jj,1,jl2) = e_s(ji,jj,1,jl2)                   &
+                     + esrft(ji,jj)*fsnowrft
+                  smv_i(ji,jj,jl2) = smv_i(ji,jj,jl2)                 &
+                     + smrft(ji,jj)    
+                  oa_i(ji,jj,jl2)  = oa_i(ji,jj,jl2)                  &
+                     + oirft2(ji,jj)    
+               ENDIF ! hraft
+
+            END DO ! ij
+
+            ! Transfer rafted ice energy to category jl2 
+            DO jk = 1, nlay_i
+!CDIR NODEP
+               DO ij = 1, icells
+                  ji = indxi(ij)
+                  jj = indxj(ij)
+                  IF (hraft(ji,jj,jl1) .LE. hi_max(jl2) .AND.        &
+                     hraft(ji,jj,jl1) .GT. hi_max(jl2-1)) THEN
+                     e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2)             &
+                        + eirft(ji,jj,jk)
+                  ENDIF
+               END DO           ! ij
+            END DO !jk
+
+         END DO ! jl2
+
+      END DO ! jl1 (deforming categories)
+
+      ! Conservation check
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vice_final)
+         fieldid = ' v_i : limitd_me '
+         CALL lim_cons_check (vice_init, vice_final, 1.0e-6, fieldid) 
+         WRITE(numout,*) ' vice_init  : ', vice_init(jiindx,jjindx)
+         WRITE(numout,*) ' vice_final : ', vice_final(jiindx,jjindx)
+
+         CALL lim_column_sum_energy (jpl, nlay_i,  e_i, eice_final )
+         fieldid = ' e_i : limitd_me '
+         CALL lim_cons_check (eice_init, eice_final, 1.0e-2, fieldid) 
+         WRITE(numout,*) ' eice_init  : ', eice_init(jiindx,jjindx)
+         WRITE(numout,*) ' eice_final : ', eice_final(jiindx,jjindx)
+      ENDIF
+
+   END SUBROUTINE lim_itd_me_ridgeshift
+
+   !==============================================================================
+
+   SUBROUTINE lim_itd_me_asumr !(subroutine 5/6)
+
+      !!-----------------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_me_asumr ***
+      !! ** Purpose :
+      !!        This routine finds total fractional area
+      !!
+      !! ** Method  :
+      !! Find the total area of ice plus open water in each grid cell.
+      !!
+      !! This is similar to the aggregate_area subroutine except that the
+      !! total area can be greater than 1, so the open water area is 
+      !! included in the sum instead of being computed as a residual. 
+      !!
+      !! ** Arguments :
+
+      INTEGER :: ji, jj, jl
+
+      !-----------------------------------------------------------------
+      ! open water
+      !-----------------------------------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            asum(ji,jj) = ato_i(ji,jj)
+         END DO
+      END DO
+
+      !-----------------------------------------------------------------
+      ! ice categories
+      !-----------------------------------------------------------------
+
+      DO jl = 1, jpl
+         DO jj= 1, jpj
+            DO ji = 1, jpi
+               asum(ji,jj) = asum(ji,jj) + a_i(ji,jj,jl)
+            END DO !ji
+         END DO !jj
+      END DO ! jl
+
+   END SUBROUTINE lim_itd_me_asumr
+
+   !==============================================================================
+
+   SUBROUTINE lim_itd_me_init ! (subroutine 6/6)
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_itd_me_init ***
+      !!
+      !! ** Purpose :   Physical constants and parameters linked 
+      !!                to the mechanical ice redistribution
+      !!
+      !! ** Method  :   Read the namiceitdme namelist 
+      !!                and check the parameters values 
+      !!                called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namiceitdme
+      !!
+      !! history :
+      !!  9.0, LIM3.0 - 02-2006 (M. Vancoppenolle) original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namiceitdme/ ridge_scheme_swi, Cs, Cf, fsnowrdg, fsnowrft,& 
+         Gstar, astar,                                &
+         Hstar, raftswi, hparmeter, Craft, ridge_por, &
+         sal_max_ridge,  partfun_swi, transfun_swi,   &
+         brinstren_swi
+      !!-------------------------------------------------------------------
+
+      ! Define the initial parameters
+      ! -------------------------
+      REWIND( numnam_ice )
+      READ  ( numnam_ice , namiceitdme)
+      IF (lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)' lim_itd_me_init : ice parameters for mechanical ice redistribution '
+         WRITE(numout,*)' ~~~~~~~~~~~~~~~'
+         WRITE(numout,*)'   Switch choosing the ice redistribution scheme           ridge_scheme_swi', ridge_scheme_swi 
+         WRITE(numout,*)'   Fraction of shear energy contributing to ridging        Cs              ', Cs 
+         WRITE(numout,*)'   Ratio of ridging work to PotEner change in ridging      Cf              ', Cf 
+         WRITE(numout,*)'   Fraction of snow volume conserved during ridging        fsnowrdg        ', fsnowrdg 
+         WRITE(numout,*)'   Fraction of snow volume conserved during ridging        fsnowrft        ', fsnowrft 
+         WRITE(numout,*)'   Fraction of total ice coverage contributing to ridging  Gstar           ', Gstar
+         WRITE(numout,*)'   Equivalent to G* for an exponential part function       astar           ', astar
+         WRITE(numout,*)'   Quantity playing a role in max ridged ice thickness     Hstar           ', Hstar
+         WRITE(numout,*)'   Rafting of ice sheets or not                            raftswi         ', raftswi
+         WRITE(numout,*)'   Parmeter thickness (threshold between ridge-raft)       hparmeter       ', hparmeter
+         WRITE(numout,*)'   Rafting hyperbolic tangent coefficient                  Craft           ', Craft  
+         WRITE(numout,*)'   Initial porosity of ridges                              ridge_por       ', ridge_por
+         WRITE(numout,*)'   Maximum salinity of ridging ice                         sal_max_ridge   ', sal_max_ridge
+         WRITE(numout,*)'   Switch for part. function (0) linear (1) exponential    partfun_swi     ', partfun_swi
+         WRITE(numout,*)'   Switch for tran. function (0) linear (1) exponential    transfun_swi    ', transfun_swi
+         WRITE(numout,*)'   Switch for including brine volume in ice strength comp. brinstren_swi   ', brinstren_swi
+      ENDIF
+
+   END SUBROUTINE lim_itd_me_init
+
+   !==============================================================================
+
+   SUBROUTINE lim_itd_me_zapsmall
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_itd_me_zapsmall ***
+      !!
+      !! ** Purpose :   Remove too small sea ice areas and correct salt fluxes
+      !!
+      !!
+      !! history :
+      !! author: William H. Lipscomb, LANL
+      !! Nov 2003:  Modified by Julie Schramm to conserve volume and energy
+      !! Sept 2004: Modified by William Lipscomb; replaced normalize_state with
+      !!            additions to local freshwater, salt, and heat fluxes
+      !!  9.0, LIM3.0 - 02-2006 (M. Vancoppenolle) original code
+      !!-------------------------------------------------------------------
+
+      INTEGER ::   &
+         ji,jj,  & ! horizontal indices
+         jl,     & ! ice category index
+         jk,     & ! ice layer index
+         !           ij,     &   ! combined i/j horizontal index
+         icells      ! number of cells with ice to zap
+
+      !      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+      !           indxi,  & ! compressed indices for i/j directions
+      !           indxj
+
+      INTEGER, DIMENSION(jpi,jpj) :: zmask
+
+
+      REAL(wp) :: &
+         xtmp      ! temporary variable
+
+      DO jl = 1, jpl
+
+         !-----------------------------------------------------------------
+         ! Count categories to be zapped.
+         ! Abort model in case of negative area.
+         !-----------------------------------------------------------------
+         IF( MINVAL(a_i(:,:,jl)) .LT. -epsi11 .AND. ln_nicep ) THEN
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF ( a_i(ji,jj,jl) .LT. -epsi11 ) THEN
+                     WRITE (numout,*) ' ALERTE 98 ' 
+                     WRITE (numout,*) ' Negative ice area: ji, jj, jl: ', ji, jj,jl
+                     WRITE (numout,*) ' a_i    ', a_i(ji,jj,jl)
+                  ENDIF
+               END DO
+            END DO
+         ENDIF
+
+         icells = 0
+         zmask = 0.e0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ( a_i(ji,jj,jl) .GE. -epsi11 .AND. a_i(ji,jj,jl) .LT. 0.0)       &
+                  .OR.                                         &
+                  ( a_i(ji,jj,jl) .GT. 0.0     .AND. a_i(ji,jj,jl) .LE. 1.0e-11 )  &
+                  .OR.                                         &
+                                !new line
+                  ( v_i(ji,jj,jl) .EQ. 0.0     .AND. a_i(ji,jj,jl) .GT. 0.0    )   &
+                  .OR.                                         &
+                  ( v_i(ji,jj,jl) .GT. 0.0     .AND. v_i(ji,jj,jl) .LT. 1.e-12 ) ) THEN
+                  zmask(ji,jj) = 1
+               ENDIF
+            END DO
+         END DO
+         IF( ln_nicep ) WRITE(numout,*) SUM(zmask), ' cells of ice zapped in the ocean '
+
+         !-----------------------------------------------------------------
+         ! Zap ice energy and use ocean heat to melt ice
+         !-----------------------------------------------------------------
+
+         DO jk = 1, nlay_i
+            DO jj = 1 , jpj
+               DO ji = 1 , jpi
+
+                  xtmp = e_i(ji,jj,jk,jl) / area(ji,jj) / rdt_ice
+                  xtmp = xtmp * unit_fac
+                  !              fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * ( 1 - zmask(ji,jj) )
+               END DO           ! ji
+            END DO           ! jj
+         END DO           ! jk
+
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
+
+               !-----------------------------------------------------------------
+               ! Zap snow energy and use ocean heat to melt snow
+               !-----------------------------------------------------------------
+
+               !           xtmp = esnon(i,j,n) / dt ! < 0
+               !           fhnet(i,j)      = fhnet(i,j)      + xtmp
+               !           fhnet_hist(i,j) = fhnet_hist(i,j) + xtmp
+               ! xtmp is greater than 0
+               ! fluxes are positive to the ocean
+               ! here the flux has to be negative for the ocean
+               xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice
+               !           fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp
+
+               xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice !RB   ???????
+
+               t_s(ji,jj,1,jl) = rtt * zmask(ji,jj) + t_s(ji,jj,1,jl) * ( 1 - zmask(ji,jj) )
+
+               !-----------------------------------------------------------------
+               ! zap ice and snow volume, add water and salt to ocean
+               !-----------------------------------------------------------------
+
+               !           xtmp = (rhoi*vicen(i,j,n) + rhos*vsnon(i,j,n)) / dt
+               !           fresh(i,j)      = fresh(i,j)      + xtmp
+               !           fresh_hist(i,j) = fresh_hist(i,j) + xtmp
+
+               !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj)                  ) * & 
+               !                               rhosn * v_s(ji,jj,jl) / rdt_ice
+
+               !           fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj) - sm_i(ji,jj,jl) ) * & 
+               !                               rhoic * v_i(ji,jj,jl) / rdt_ice
+
+               !           emps(i,j)      = emps(i,j)      + xtmp
+               !           fsalt_hist(i,j) = fsalt_hist(i,j) + xtmp
+
+               ato_i(ji,jj)   = a_i(ji,jj,jl)  * zmask(ji,jj) + ato_i(ji,jj)
+               a_i(ji,jj,jl)  = a_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+               v_i(ji,jj,jl)  = v_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+               v_s(ji,jj,jl)  = v_s(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+               t_su(ji,jj,jl) = t_su(ji,jj,jl) * (1 -zmask(ji,jj) ) + t_bo(ji,jj) * zmask(ji,jj)
+               oa_i(ji,jj,jl) = oa_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+               smv_i(ji,jj,jl) = smv_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+
+            END DO                 ! ji
+         END DO                 ! jj
+
+      END DO                 ! jl 
+
+   END SUBROUTINE lim_itd_me_zapsmall
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limitd_me    ***
+   !!                            no sea ice model
+   !!======================================================================
+
+CONTAINS
+
+   SUBROUTINE lim_itd_me           ! Empty routines
+   END SUBROUTINE lim_itd_me
+   SUBROUTINE lim_itd_me_icestrength
+   END SUBROUTINE lim_itd_me_icestrength
+   SUBROUTINE lim_itd_me_ridgeprep
+   END SUBROUTINE lim_itd_me_ridgeprep
+   SUBROUTINE lim_itd_me_ridgeshift
+   END SUBROUTINE lim_itd_me_ridgeshift
+   SUBROUTINE lim_itd_me_asumr
+   END SUBROUTINE lim_itd_me_asumr
+   SUBROUTINE lim_itd_me_sort
+   END SUBROUTINE lim_itd_me_sort
+   SUBROUTINE lim_itd_me_init
+   END SUBROUTINE lim_itd_me_init
+   SUBROUTINE lim_itd_me_zapsmall
+   END SUBROUTINE lim_itd_me_zapsmall
+#endif
+END MODULE limitd_me
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_th.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_th.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limitd_th.F90	(revision 1844)
@@ -0,0 +1,1257 @@
+MODULE limitd_th
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limitd_th ***
+   !!              Thermodynamics of ice thickness distribution
+   !!                   computation of changes in g(h)      
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_ice
+   USE par_oce          ! ocean parameters
+   USE dom_oce
+   USE phycst           ! physical constants (ocean directory) 
+   USE thd_ice
+   USE limistate
+   USE in_out_manager
+   USE ice
+   USE par_ice
+   USE limthd_lac
+   USE limvar
+   USE iceini
+   USE limcons
+   USE prtctl           ! Print control
+   USE lib_mpp 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_itd_th        ! called by ice_stp
+   PUBLIC lim_itd_th_rem
+   PUBLIC lim_itd_th_reb
+   PUBLIC lim_itd_fitline
+   PUBLIC lim_itd_shiftice
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1e-20   ,  &
+      epsi13 = 1e-13   ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+
+CONTAINS
+
+   SUBROUTINE lim_itd_th( kt )
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_th ***
+      !! ** Purpose :
+      !!        This routine computes the thermodynamics of ice thickness
+      !!         distribution
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (12-2005) Martin Vancoppenolle 
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(in) :: kt
+      !! * Local variables
+      INTEGER ::   jl, ja,   &   ! ice category, layers
+         jm,       &   ! ice types    dummy loop index
+         jbnd1,    &
+         jbnd2
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10, &
+         epsi10    =  1.0e-10
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_itd_th  : Thermodynamics of the ice thickness distribution'
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      !------------------------------------------------------------------------------|
+      !  1) Transport of ice between thickness categories.                           |
+      !------------------------------------------------------------------------------|
+      ! Given thermodynamic growth rates, transport ice between
+      ! thickness categories.
+      DO jm = 1, jpm
+         jbnd1 = ice_cat_bounds(jm,1)
+         jbnd2 = ice_cat_bounds(jm,2)
+         IF (ice_ncat_types(jm) .GT. 1 ) CALL lim_itd_th_rem( jbnd1, jbnd2, jm, kt )
+      END DO
+
+      CALL lim_var_glo2eqv ! only for info
+      CALL lim_var_agg(1)
+
+      !------------------------------------------------------------------------------|
+      !  3) Add frazil ice growing in leads.
+      !------------------------------------------------------------------------------|
+
+      CALL lim_thd_lac
+      CALL lim_var_glo2eqv ! only for info
+
+      !----------------------------------------------------------------------------------------
+      !  4) Computation of trend terms and get back to old values      
+      !----------------------------------------------------------------------------------------
+
+      !- Trend terms
+      d_a_i_thd (:,:,:)  = a_i(:,:,:)   - old_a_i(:,:,:) 
+      d_v_s_thd (:,:,:)  = v_s(:,:,:)   - old_v_s(:,:,:)
+      d_v_i_thd (:,:,:)  = v_i(:,:,:)   - old_v_i(:,:,:)  
+      d_e_s_thd(:,:,:,:) = e_s(:,:,:,:) - old_e_s(:,:,:,:) 
+      d_e_i_thd(:,:,:,:) = e_i(:,:,:,:) - old_e_i(:,:,:,:)
+
+      d_smv_i_thd(:,:,:) = 0.0
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &
+         d_smv_i_thd(:,:,:) = smv_i(:,:,:) - old_smv_i(:,:,:)
+
+      IF(ln_ctl) THEN   ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=area , clinfo1=' lim_itd_th  : cell area :')
+         CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_itd_th  : at_i      :')
+         CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_itd_th  : vt_i      :')
+         CALL prt_ctl(tab2d_1=vt_s , clinfo1=' lim_itd_th  : vt_s      :')
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_itd_th  : a_i      : ')
+            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_itd_th  : ht_i     : ')
+            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_itd_th  : ht_s     : ')
+            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_itd_th  : v_i      : ')
+            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_itd_th  : v_s      : ')
+            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_itd_th  : e_s      : ')
+            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_itd_th  : t_su     : ')
+            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_itd_th  : t_snow   : ')
+            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_itd_th  : sm_i     : ')
+            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_itd_th  : smv_i    : ')
+            DO ja = 1, nlay_i
+               CALL prt_ctl_info(' ')
+               CALL prt_ctl_info(' - Layer : ', ivar1=ja)
+               CALL prt_ctl_info('   ~~~~~~~')
+               CALL prt_ctl(tab2d_1=t_i(:,:,ja,jl) , clinfo1= ' lim_itd_th  : t_i      : ')
+               CALL prt_ctl(tab2d_1=e_i(:,:,ja,jl) , clinfo1= ' lim_itd_th  : e_i      : ')
+            END DO
+         END DO
+      ENDIF
+
+      !- Recover Old values
+      a_i(:,:,:)         = old_a_i (:,:,:)
+      v_s(:,:,:)         = old_v_s (:,:,:)
+      v_i(:,:,:)         = old_v_i (:,:,:)
+      e_s(:,:,:,:)       = old_e_s (:,:,:,:)
+      e_i(:,:,:,:)       = old_e_i (:,:,:,:)
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &
+         smv_i(:,:,:)       = old_smv_i (:,:,:)
+
+   END SUBROUTINE lim_itd_th
+   !
+
+   SUBROUTINE lim_itd_th_rem( klbnd, kubnd, ntyp, kt )
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_th_rem ***
+      !! ** Purpose :
+      !!        This routine computes the redistribution of ice thickness
+      !!        after thermodynamic growth of ice thickness
+      !!
+      !! ** Method  : Linear remapping 
+      !!
+      !! ** Arguments :
+      !!           klbnd, kubnd : Starting and ending category index on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References : W.H. Lipscomb, JGR 2001
+      !!
+      !! ** History :
+      !!           largely inspired from CICE (c) W. H. Lipscomb and E.C. Hunke
+      !! 
+      !!           (01-2006) Martin Vancoppenolle, UCL-ASTR, translation from
+      !!                     CICE
+      !!           (06-2006) Adaptation to include salt, age and types
+      !!           (04-2007) Mass conservation checked
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      INTEGER , INTENT (IN) ::  &
+         klbnd ,  &  ! Start thickness category index point
+         kubnd ,  &  ! End point on which the  the computation is applied
+         ntyp  ,  &  ! Number of the type used
+         kt          ! Ocean time step 
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial dummy loop index
+         jj,       &   ! spatial dummy loop index
+         jl,       &   ! ice category dummy loop index
+         zji, zjj, &   ! dummy indices used when changing coordinates
+         nd            ! used for thickness categories
+
+      INTEGER , DIMENSION(jpi,jpj,jpl-1) :: & 
+         zdonor        ! donor category index
+
+      REAL(wp)  ::           &   ! constant values
+         zeps      =  1.0e-10
+
+      REAL(wp)  ::           &  ! constant values for ice enthalpy
+         zindb     ,         &
+         zareamin  ,         &  ! minimum tolerated area in a thickness category
+         zwk1, zwk2,         &  ! all the following are dummy arguments
+         zx1, zx2, zx3,      &  !
+         zetamin   ,         &  ! minimum value of eta
+         zetamax   ,         &  ! maximum value of eta
+         zdh0      ,         &  ! 
+         zda0      ,         &  !
+         zdamax    ,         &  !
+         zhimin
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: &
+         zdhice           ,  &  ! ice thickness increment
+         g0               ,  &  ! coefficients for fitting the line of the ITD
+         g1               ,  &  ! coefficients for fitting the line of the ITD
+         hL               ,  &  ! left boundary for the ITD for each thickness
+         hR               ,  &  ! left boundary for the ITD for each thickness
+         zht_i_o          ,  &  ! old ice thickness
+         dummy_es
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl-1) :: &
+         zdaice           ,  &  ! local increment of ice area 
+         zdvice                 ! local increment of ice volume
+
+      REAL(wp), DIMENSION(jpi,jpj,0:jpl) :: &
+         zhbnew                 ! new boundaries of ice categories
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zhb0, zhb1             ! category boundaries for thinnes categories
+
+      REAL, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+         zvetamin, zvetamax     ! maximum values for etas
+
+      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+         nind_i      ,  &  ! compressed indices for i/j directions
+         nind_j
+
+      INTEGER :: &
+         nbrem             ! number of cells with ice to transfer
+
+      LOGICAL, DIMENSION(jpi,jpj) ::   &  !:
+         zremap_flag             ! compute remapping or not ????
+
+      REAL(wp)  ::           &  ! constant values for ice enthalpy
+         zslope                 ! used to compute local thermodynamic "speeds"
+
+      REAL (wp), DIMENSION(jpi,jpj) :: &  ! 
+         vt_i_init, vt_i_final,   &  !  ice volume summed over categories
+         vt_s_init, vt_s_final,   &  !  snow volume summed over categories
+         et_i_init, et_i_final,   &  !  ice energy summed over categories
+         et_s_init, et_s_final       !  snow energy summed over categories
+
+      CHARACTER (len = 15) :: fieldid
+
+      !!-- End of declarations
+      !!----------------------------------------------------------------------------------------------
+      zhimin = 0.1      !minimum ice thickness tolerated by the model
+      zareamin = zeps   !minimum area in thickness categories tolerated by the conceptors of the model
+
+      !!----------------------------------------------------------------------------------------------
+      !! 0) Conservation checkand changes in each ice category
+      !!----------------------------------------------------------------------------------------------
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vt_i_init)
+         CALL lim_column_sum (jpl,   v_s, vt_s_init)
+         CALL lim_column_sum_energy (jpl, nlay_i,   e_i, et_i_init)
+         dummy_es(:,:,:) = e_s(:,:,1,:)
+         CALL lim_column_sum (jpl, dummy_es(:,:,:) , et_s_init)
+      ENDIF
+
+      !!----------------------------------------------------------------------------------------------
+      !! 1) Compute thickness and changes in each ice category
+      !!----------------------------------------------------------------------------------------------
+      IF (kt == nit000 .AND. lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_itd_th_rem  : Remapping the ice thickness distribution'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+         WRITE(numout,*) ' klbnd :       ', klbnd
+         WRITE(numout,*) ' kubnd :       ', kubnd
+         WRITE(numout,*) ' ntyp  :       ', ntyp 
+      ENDIF
+
+      zdhice(:,:,:) = 0.0
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zindb             = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl)))     !0 if no ice and 1 if yes
+               ht_i(ji,jj,jl)    = v_i(ji,jj,jl) / MAX(a_i(ji,jj,jl),zeps) * zindb
+               zindb             = 1.0-MAX(0.0,SIGN(1.0,-old_a_i(ji,jj,jl))) !0 if no ice and 1 if yes
+               zht_i_o(ji,jj,jl) = old_v_i(ji,jj,jl) / MAX(old_a_i(ji,jj,jl),zeps) * zindb
+               IF (a_i(ji,jj,jl).gt.1e-6) THEN
+                  zdhice(ji,jj,jl) = ht_i(ji,jj,jl) - zht_i_o(ji,jj,jl) 
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      !-----------------------------------------------------------------------------------------------
+      !  2) Compute fractional ice area in each grid cell
+      !-----------------------------------------------------------------------------------------------
+      at_i(:,:) = 0.0
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               at_i(ji,jj) = at_i(ji,jj) + a_i(ji,jj,jl)
+            END DO
+         END DO
+      END DO
+
+      !-----------------------------------------------------------------------------------------------
+      !  3) Identify grid cells with ice
+      !-----------------------------------------------------------------------------------------------
+      nbrem = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( at_i(ji,jj) .gt. zareamin ) THEN
+               nbrem         = nbrem + 1
+               nind_i(nbrem) = ji
+               nind_j(nbrem) = jj
+               zremap_flag(ji,jj) = .true.
+            ELSE
+               zremap_flag(ji,jj) = .false.
+            ENDIF
+         END DO !ji
+      END DO !jj
+
+      !-----------------------------------------------------------------------------------------------
+      !  4) Compute new category boundaries
+      !-----------------------------------------------------------------------------------------------
+      !- 4.1 Compute category boundaries
+      ! Tricky trick see limitd_me.F90
+      ! will be soon removed, CT
+      ! hi_max(kubnd) = 999.99
+      zhbnew(:,:,:) = 0.0
+
+      DO jl = klbnd, kubnd - 1
+         ! jl
+         DO ji = 1, nbrem
+            ! jl, ji
+            zji = nind_i(ji)
+            zjj = nind_j(ji)
+            !
+            IF ( ( zht_i_o(zji,zjj,jl)  .GT.zeps ) .AND. & 
+               ( zht_i_o(zji,zjj,jl+1).GT.zeps ) ) THEN
+               !interpolate between adjacent category growth rates
+               zslope = ( zdhice(zji,zjj,jl+1)     - zdhice(zji,zjj,jl) ) / &
+                  ( zht_i_o   (zji,zjj,jl+1) - zht_i_o   (zji,zjj,jl) )
+               zhbnew(zji,zjj,jl) = hi_max(jl) + zdhice(zji,zjj,jl) + &
+                  zslope * ( hi_max(jl) - zht_i_o(zji,zjj,jl) )
+            ELSEIF (zht_i_o(zji,zjj,jl).gt.zeps) THEN
+               zhbnew(zji,zjj,jl) = hi_max(jl) + zdhice(zji,zjj,jl)
+            ELSEIF (zht_i_o(zji,zjj,jl+1).gt.zeps) THEN
+               zhbnew(zji,zjj,jl) = hi_max(jl) + zdhice(zji,zjj,jl+1)
+            ELSE
+               zhbnew(zji,zjj,jl) = hi_max(jl)
+            ENDIF
+            ! jl, ji
+         END DO !ji
+         ! jl
+
+         !- 4.2 Check that each zhbnew lies between adjacent values of ice thickness
+         DO ji = 1, nbrem
+            ! jl, ji
+            zji = nind_i(ji)
+            zjj = nind_j(ji)
+            ! jl, ji
+            IF ( ( a_i(zji,zjj,jl) .GT.zeps) .AND. & 
+               ( ht_i(zji,zjj,jl).GE. zhbnew(zji,zjj,jl) ) &
+               ) THEN
+               zremap_flag(zji,zjj) = .false.
+            ELSEIF ( ( a_i(zji,zjj,jl+1) .GT. zeps ) .AND. &
+               ( ht_i(zji,zjj,jl+1).LE. zhbnew(zji,zjj,jl) ) &
+               ) THEN
+               zremap_flag(zji,zjj) = .false.
+            ENDIF
+
+            !- 4.3 Check that each zhbnew does not exceed maximal values hi_max  
+            ! jl, ji
+            IF (zhbnew(zji,zjj,jl).gt.hi_max(jl+1)) THEN
+               zremap_flag(zji,zjj) = .false.
+            ENDIF
+            ! jl, ji
+            IF (zhbnew(zji,zjj,jl).lt.hi_max(jl-1)) THEN
+               zremap_flag(zji,zjj) = .false.
+            ENDIF
+            ! jl, ji
+         END DO !ji
+         ! ji
+      END DO !jl
+
+      !-----------------------------------------------------------------------------------------------
+      !  5) Identify cells where ITD is to be remapped
+      !-----------------------------------------------------------------------------------------------
+      nbrem = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( zremap_flag(ji,jj) ) THEN
+               nbrem         = nbrem + 1
+               nind_i(nbrem) = ji
+               nind_j(nbrem) = jj
+            ENDIF
+         END DO !ji
+      END DO !jj
+
+      !-----------------------------------------------------------------------------------------------
+      !  6) Fill arrays with lowermost / uppermost boundaries of 'new' categories
+      !-----------------------------------------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zhb0(ji,jj) = hi_max_typ(0,ntyp) ! 0eme
+            zhb1(ji,jj) = hi_max_typ(1,ntyp) ! 1er
+
+            zhbnew(ji,jj,klbnd-1) = 0.0
+
+            IF ( a_i(ji,jj,kubnd) .GT. zeps ) THEN
+               zhbnew(ji,jj,kubnd) = 3.0*ht_i(ji,jj,kubnd) - 2.0*zhbnew(ji,jj,kubnd-1)
+            ELSE
+               zhbnew(ji,jj,kubnd) = hi_max(kubnd)
+            ENDIF
+
+            IF ( zhbnew(ji,jj,kubnd) .LT. hi_max(kubnd-1) ) &
+               zhbnew(ji,jj,kubnd) = hi_max(kubnd-1)
+
+         END DO !jj
+      END DO !jj
+
+      !-----------------------------------------------------------------------------------------------
+      !  7) Compute g(h) 
+      !-----------------------------------------------------------------------------------------------
+      !- 7.1 g(h) for category 1 at start of time step
+      CALL lim_itd_fitline(klbnd, zhb0, zhb1, zht_i_o(:,:,klbnd), &
+         g0(:,:,klbnd), g1(:,:,klbnd), hL(:,:,klbnd), &
+         hR(:,:,klbnd), zremap_flag)
+
+      !- 7.2 Area lost due to melting of thin ice (first category,  klbnd)
+      DO ji = 1, nbrem
+         zji = nind_i(ji) 
+         zjj = nind_j(ji) 
+
+         !ji
+         IF (a_i(zji,zjj,klbnd) .gt. zeps) THEN
+            zdh0 = zdhice(zji,zjj,klbnd) !decrease of ice thickness in the lower category
+            ! ji, a_i > zeps
+            IF (zdh0 .lt. 0.0) THEN !remove area from category 1
+               ! ji, a_i > zeps; zdh0 < 0
+               zdh0 = MIN(-zdh0,hi_max(klbnd))
+
+               !Integrate g(1) from 0 to dh0 to estimate area melted
+               zetamax = MIN(zdh0,hR(zji,zjj,klbnd)) - hL(zji,zjj,klbnd)
+               IF (zetamax.gt.0.0) THEN
+                  zx1  = zetamax
+                  zx2  = 0.5 * zetamax*zetamax 
+                  zda0 = g1(zji,zjj,klbnd) * zx2 + g0(zji,zjj,klbnd) * zx1 !ice area removed
+                  ! Constrain new thickness <= ht_i
+                  zdamax = a_i(zji,zjj,klbnd) * & 
+                     (1.0 - ht_i(zji,zjj,klbnd)/zht_i_o(zji,zjj,klbnd)) ! zdamax > 0
+                  !ice area lost due to melting of thin ice
+                  zda0   = MIN(zda0, zdamax)
+
+                  ! Remove area, conserving volume
+                  ht_i(zji,zjj,klbnd) = ht_i(zji,zjj,klbnd) & 
+                     * a_i(zji,zjj,klbnd) / ( a_i(zji,zjj,klbnd) - zda0 )
+                  a_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd) - zda0
+                  v_i(zji,zjj,klbnd)  = a_i(zji,zjj,klbnd)*ht_i(zji,zjj,klbnd)
+               ENDIF     ! zetamax > 0
+               ! ji, a_i > zeps
+
+            ELSE ! if ice accretion
+               ! ji, a_i > zeps; zdh0 > 0
+               IF ( ntyp .EQ. 1 ) zhbnew(zji,zjj,klbnd-1) = MIN(zdh0,hi_max(klbnd)) 
+               ! zhbnew was 0, and is shifted to the right to account for thin ice
+               ! growth in openwater (F0 = f1)
+               IF ( ntyp .NE. 1 ) zhbnew(zji,zjj,0) = 0 
+               ! in other types there is
+               ! no open water growth (F0 = 0)
+            ENDIF ! zdh0 
+
+            ! a_i > zeps
+         ENDIF ! a_i > zeps
+
+      END DO ! ji
+
+      !- 7.3 g(h) for each thickness category  
+      DO jl = klbnd, kubnd
+         CALL lim_itd_fitline(jl, zhbnew(:,:,jl-1), zhbnew(:,:,jl), ht_i(:,:,jl), &
+            g0(:,:,jl), g1(:,:,jl), hL(:,:,jl), hR(:,:,jl),     &
+            zremap_flag)
+      END DO
+
+      !-----------------------------------------------------------------------------------------------
+      !  8) Compute area and volume to be shifted across each boundary
+      !-----------------------------------------------------------------------------------------------
+
+      DO jl = klbnd, kubnd - 1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zdonor(ji,jj,jl) = 0
+               zdaice(ji,jj,jl) = 0.0
+               zdvice(ji,jj,jl) = 0.0
+            END DO
+         END DO
+
+         DO ji = 1, nbrem
+            zji = nind_i(ji)
+            zjj = nind_j(ji)
+
+            IF (zhbnew(zji,zjj,jl) .gt. hi_max(jl)) THEN ! transfer from jl to jl+1
+
+               ! left and right integration limits in eta space
+               zvetamin(ji) = MAX(hi_max(jl), hL(zji,zjj,jl)) - hL(zji,zjj,jl)
+               zvetamax(ji) = MIN(zhbnew(zji,zjj,jl), hR(zji,zjj,jl)) - hL(zji,zjj,jl)
+               zdonor(zji,zjj,jl) = jl
+
+            ELSE  ! zhbnew(jl) <= hi_max(jl) ; transfer from jl+1 to jl
+
+               ! left and right integration limits in eta space
+               zvetamin(ji) = 0.0
+               zvetamax(ji) = MIN(hi_max(jl), hR(zji,zjj,jl+1)) - hL(zji,zjj,jl+1)
+               zdonor(zji,zjj,jl) = jl + 1
+
+            ENDIF  ! zhbnew(jl) > hi_max(jl)
+
+            zetamax = MAX(zvetamax(ji), zvetamin(ji)) ! no transfer if etamax < etamin
+            zetamin = zvetamin(ji)
+
+            zx1  = zetamax - zetamin
+            zwk1 = zetamin*zetamin
+            zwk2 = zetamax*zetamax
+            zx2  = 0.5 * (zwk2 - zwk1)
+            zwk1 = zwk1 * zetamin
+            zwk2 = zwk2 * zetamax
+            zx3  = 1.0/3.0 * (zwk2 - zwk1)
+            nd   = zdonor(zji,zjj,jl)
+            zdaice(zji,zjj,jl) = g1(zji,zjj,nd)*zx2 + g0(zji,zjj,nd)*zx1
+            zdvice(zji,zjj,jl) = g1(zji,zjj,nd)*zx3 + g0(zji,zjj,nd)*zx2 + &
+               zdaice(zji,zjj,jl)*hL(zji,zjj,nd)
+
+         END DO ! ji
+      END DO ! jl klbnd -> kubnd - 1
+
+      !!----------------------------------------------------------------------------------------------
+      !! 9) Shift ice between categories
+      !!----------------------------------------------------------------------------------------------
+      CALL lim_itd_shiftice ( klbnd, kubnd, zdonor, zdaice, zdvice )
+
+      !!----------------------------------------------------------------------------------------------
+      !! 10) Make sure ht_i >= minimum ice thickness hi_min
+      !!----------------------------------------------------------------------------------------------
+
+      DO ji = 1, nbrem
+         zji = nind_i(ji)
+         zjj = nind_j(ji)
+         IF ( ( zhimin .GT. 0.0 ) .AND. & 
+            ( ( a_i(zji,zjj,1) .GT. zeps ) .AND. ( ht_i(zji,zjj,1) .LT. zhimin ) ) &
+            ) THEN
+            a_i(zji,zjj,1)  = a_i(zji,zjj,1) * ht_i(zji,zjj,1) / zhimin 
+            ht_i(zji,zjj,1) = zhimin
+            v_i(zji,zjj,1)  = a_i(zji,zjj,1)*ht_i(zji,zjj,1)
+         ENDIF
+      END DO !ji
+
+      !!----------------------------------------------------------------------------------------------
+      !! 11) Conservation check
+      !!----------------------------------------------------------------------------------------------
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vt_i_final)
+         fieldid = ' v_i : limitd_th '
+         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid) 
+
+         CALL lim_column_sum_energy (jpl, nlay_i,  e_i, et_i_final)
+         fieldid = ' e_i : limitd_th '
+         CALL lim_cons_check (et_i_init, et_i_final, 1.0e-3, fieldid) 
+
+         CALL lim_column_sum (jpl,   v_s, vt_s_final)
+         fieldid = ' v_s : limitd_th '
+         CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid) 
+
+         dummy_es(:,:,:) = e_s(:,:,1,:)
+         CALL lim_column_sum (jpl, dummy_es(:,:,:) , et_s_final)
+         fieldid = ' e_s : limitd_th '
+         CALL lim_cons_check (et_s_init, et_s_final, 1.0e-3, fieldid) 
+      ENDIF
+
+   END SUBROUTINE lim_itd_th_rem
+   !
+
+   SUBROUTINE lim_itd_fitline(num_cat, HbL, Hbr, hice, g0, g1, hL, hR, zremap_flag )
+
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_fitline ***
+      !! ** Purpose :
+      !! fit g(h) with a line using area, volume constraints
+      !!
+      !! ** Method  :
+      !! Fit g(h) with a line, satisfying area and volume constraints.
+      !! To reduce roundoff errors caused by large values of g0 and g1,
+      !! we actually compute g(eta), where eta = h - hL, and hL is the
+      !! left boundary.
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL
+      !!          (01-2006) Martin Vancoppenolle 
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      INTEGER, INTENT(in) :: num_cat      ! category index
+
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(IN)   ::   &  !:
+         HbL, HbR        ! left and right category boundaries
+
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(IN)   ::   &  !:
+         hice            ! ice thickness
+
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(OUT)  ::   &  !:
+         g0, g1      , & ! coefficients in linear equation for g(eta)
+         hL          , & ! min value of range over which g(h) > 0
+         hR              ! max value of range over which g(h) > 0
+
+      LOGICAL, DIMENSION(jpi,jpj), INTENT(IN)    ::   &  !:
+         zremap_flag
+
+      INTEGER :: &              
+         ji,jj           ! horizontal indices
+
+      REAL(wp) :: &           
+         zh13        , & ! HbL + 1/3 * (HbR - HbL)
+         zh23        , & ! HbL + 2/3 * (HbR - HbL)
+         zdhr        , & ! 1 / (hR - hL)
+         zwk1, zwk2  , & ! temporary variables
+         zacrith         ! critical minimum concentration in an ice category
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10
+
+      zacrith       = 1.0e-6
+      !!-- End of declarations
+      !!----------------------------------------------------------------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            IF ( zremap_flag(ji,jj) .AND. a_i(ji,jj,num_cat) .gt. zacrith &
+               .AND. hice(ji,jj) .GT. 0.0 ) THEN
+
+               ! Initialize hL and hR
+
+               hL(ji,jj) = HbL(ji,jj)
+               hR(ji,jj) = HbR(ji,jj)
+
+               ! Change hL or hR if hice falls outside central third of range
+
+               zh13 = 1.0/3.0 * (2.0*hL(ji,jj) + hR(ji,jj))
+               zh23 = 1.0/3.0 * (hL(ji,jj) + 2.0*hR(ji,jj))
+
+               IF (hice(ji,jj) < zh13) THEN
+                  hR(ji,jj) = 3.0*hice(ji,jj) - 2.0*hL(ji,jj)
+               ELSEIF (hice(ji,jj) > zh23) THEN
+                  hL(ji,jj) = 3.0*hice(ji,jj) - 2.0*hR(ji,jj)
+               ENDIF
+
+               ! Compute coefficients of g(eta) = g0 + g1*eta
+
+               zdhr = 1.0 / (hR(ji,jj) - hL(ji,jj))
+               zwk1 = 6.0 * a_i(ji,jj,num_cat) * zdhr
+               zwk2 = (hice(ji,jj) - hL(ji,jj)) * zdhr
+               g0(ji,jj) = zwk1 * (2.0/3.0 - zwk2)
+               g1(ji,jj) = 2.0*zdhr * zwk1 * (zwk2 - 0.5)
+
+            ELSE                   ! remap_flag = .false. or a_i < zeps 
+
+               hL(ji,jj) = 0.0
+               hR(ji,jj) = 0.0
+               g0(ji,jj) = 0.0
+               g1(ji,jj) = 0.0
+
+            ENDIF                  ! a_i > zeps
+
+         END DO !ji
+      END DO ! jj
+
+   END SUBROUTINE lim_itd_fitline
+   !
+
+   SUBROUTINE lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice)
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_shiftice ***
+      !! ** Purpose : shift ice across category boundaries, conserving everything
+      !!              ( area, volume, energy, age*vol, and mass of salt )
+      !!
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL
+      !!          (01-2006) Martin Vancoppenolle 
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      INTEGER , INTENT (IN) ::  &
+         klbnd ,  &  ! Start thickness category index point
+         kubnd       ! End point on which the  the computation is applied
+
+      INTEGER , DIMENSION(jpi,jpj,jpl-1), INTENT(IN) :: & 
+         zdonor             ! donor category index
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl-1), INTENT(INOUT) :: & 
+         zdaice     ,  &   ! ice area transferred across boundary
+         zdvice            ! ice volume transferred across boundary
+
+      INTEGER :: &
+         ji,jj,jl,      &  ! horizontal indices, thickness category index
+         jl2,           &  ! receiver category
+         jl1,           &  ! donor category
+         jk,            &  ! ice layer index
+         zji, zjj          ! indices when changing from 2D-1D is done
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: &
+         zaTsfn
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zworka            ! temporary array used here
+
+      REAL(wp) :: &          
+         zdvsnow     ,  &  ! snow volume transferred
+         zdesnow     ,  &  ! snow energy transferred
+         zdeice      ,  &  ! ice energy transferred
+         zdsm_vice      ,  &  ! ice salinity times volume transferred
+         zdo_aice      ,  &  ! ice age times volume transferred
+         zdaTsf      ,  &  ! aicen*Tsfcn transferred
+         zindsn      ,  &  ! snow or not
+         zindb             ! ice or not
+
+      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+         nind_i      ,  &  ! compressed indices for i/j directions
+         nind_j
+
+      INTEGER :: &
+         nbrem             ! number of cells with ice to transfer
+
+      LOGICAL :: &
+         zdaice_negative       , & ! true if daice < -puny
+         zdvice_negative       , & ! true if dvice < -puny
+         zdaice_greater_aicen  , & ! true if daice > aicen
+         zdvice_greater_vicen      ! true if dvice > vicen
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10
+
+      !!-- End of declarations
+
+      !----------------------------------------------------------------------------------------------
+      ! 1) Define a variable equal to a_i*T_su
+      !----------------------------------------------------------------------------------------------
+
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zaTsfn(ji,jj,jl) = a_i(ji,jj,jl)*t_su(ji,jj,jl)
+            END DO ! ji
+         END DO ! jj
+      END DO ! jl
+
+      !----------------------------------------------------------------------------------------------
+      ! 2) Check for daice or dvice out of range, allowing for roundoff error
+      !----------------------------------------------------------------------------------------------
+      ! Note: zdaice < 0 or zdvice < 0 usually happens when category jl
+      ! has a small area, with h(n) very close to a boundary.  Then
+      ! the coefficients of g(h) are large, and the computed daice and
+      ! dvice can be in error. If this happens, it is best to transfer
+      ! either the entire category or nothing at all, depending on which
+      ! side of the boundary hice(n) lies.
+      !-----------------------------------------------------------------
+      DO jl = klbnd, kubnd-1
+
+         zdaice_negative = .false.
+         zdvice_negative = .false.
+         zdaice_greater_aicen = .false.
+         zdvice_greater_vicen = .false.
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               IF (zdonor(ji,jj,jl) .GT. 0) THEN
+                  jl1 = zdonor(ji,jj,jl)
+
+                  IF (zdaice(ji,jj,jl) .LT. 0.0) THEN
+                     IF (zdaice(ji,jj,jl) .GT. -zeps) THEN
+                        IF ( ( jl1.EQ.jl   .AND. ht_i(ji,jj,jl1) .GT. hi_max(jl) )           &
+                           .OR.                                      &
+                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) )           &  
+                           ) THEN                                                             
+                           zdaice(ji,jj,jl) = a_i(ji,jj,jl1)  ! shift entire category
+                           zdvice(ji,jj,jl) = v_i(ji,jj,jl1)
+                        ELSE
+                           zdaice(ji,jj,jl) = 0.0 ! shift no ice
+                           zdvice(ji,jj,jl) = 0.0
+                        ENDIF
+                     ELSE
+                        zdaice_negative = .true.
+                     ENDIF
+                  ENDIF
+
+                  IF (zdvice(ji,jj,jl) .LT. 0.0) THEN
+                     IF (zdvice(ji,jj,jl) .GT. -zeps ) THEN
+                        IF ( ( jl1.EQ.jl .AND. ht_i(ji,jj,jl1).GT.hi_max(jl) )     &
+                           .OR.                                     &
+                           ( jl1.EQ.jl+1 .AND. ht_i(ji,jj,jl1) .LE. hi_max(jl) ) &
+                           ) THEN
+                           zdaice(ji,jj,jl) = a_i(ji,jj,jl1) ! shift entire category
+                           zdvice(ji,jj,jl) = v_i(ji,jj,jl1) 
+                        ELSE
+                           zdaice(ji,jj,jl) = 0.0    ! shift no ice
+                           zdvice(ji,jj,jl) = 0.0
+                        ENDIF
+                     ELSE
+                        zdvice_negative = .true.
+                     ENDIF
+                  ENDIF
+
+                  ! If daice is close to aicen, set daice = aicen.
+                  IF (zdaice(ji,jj,jl) .GT. a_i(ji,jj,jl1) - zeps ) THEN
+                     IF (zdaice(ji,jj,jl) .LT. a_i(ji,jj,jl1)+zeps) THEN
+                        zdaice(ji,jj,jl) = a_i(ji,jj,jl1)
+                        zdvice(ji,jj,jl) = v_i(ji,jj,jl1) 
+                     ELSE
+                        zdaice_greater_aicen = .true.
+                     ENDIF
+                  ENDIF
+
+                  IF (zdvice(ji,jj,jl) .GT. v_i(ji,jj,jl1)-zeps) THEN
+                     IF (zdvice(ji,jj,jl) .LT. v_i(ji,jj,jl1)+zeps) THEN
+                        zdaice(ji,jj,jl) = a_i(ji,jj,jl1)
+                        zdvice(ji,jj,jl) = v_i(ji,jj,jl1) 
+                     ELSE
+                        zdvice_greater_vicen = .true.
+                     ENDIF
+                  ENDIF
+
+               ENDIF               ! donor > 0
+            END DO                   ! i
+         END DO                 ! j
+
+      END DO !jl
+
+      !-------------------------------------------------------------------------------
+      ! 3) Transfer volume and energy between categories
+      !-------------------------------------------------------------------------------
+
+      DO jl = klbnd, kubnd - 1
+         nbrem = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (zdaice(ji,jj,jl) .GT. 0.0 ) THEN ! daice(n) can be < puny
+                  nbrem = nbrem + 1
+                  nind_i(nbrem) = ji
+                  nind_j(nbrem) = jj
+               ENDIF ! tmask
+            END DO
+         END DO
+
+         DO ji = 1, nbrem 
+            zji = nind_i(ji)
+            zjj = nind_j(ji)
+
+            jl1 = zdonor(zji,zjj,jl)
+            zindb             = MAX( 0.0 , SIGN( 1.0 , v_i(zji,zjj,jl1) - zeps ) )
+            zworka(zji,zjj)   = zdvice(zji,zjj,jl) / MAX(v_i(zji,zjj,jl1),zeps) * zindb
+            IF (jl1 .eq. jl) THEN
+               jl2 = jl1+1
+            ELSE                ! n1 = n+1
+               jl2 = jl 
+            ENDIF
+
+            !--------------
+            ! Ice areas
+            !--------------
+
+            a_i(zji,zjj,jl1) = a_i(zji,zjj,jl1) - zdaice(zji,zjj,jl)
+            a_i(zji,zjj,jl2) = a_i(zji,zjj,jl2) + zdaice(zji,zjj,jl)
+
+            !--------------
+            ! Ice volumes
+            !--------------
+
+            v_i(zji,zjj,jl1) = v_i(zji,zjj,jl1) - zdvice(zji,zjj,jl) 
+            v_i(zji,zjj,jl2) = v_i(zji,zjj,jl2) + zdvice(zji,zjj,jl)
+
+            !--------------
+            ! Snow volumes
+            !--------------
+
+            zdvsnow          = v_s(zji,zjj,jl1) * zworka(zji,zjj)
+            v_s(zji,zjj,jl1) = v_s(zji,zjj,jl1) - zdvsnow
+            v_s(zji,zjj,jl2) = v_s(zji,zjj,jl2) + zdvsnow 
+
+            !--------------------
+            ! Snow heat content  
+            !--------------------
+
+            zdesnow              = e_s(zji,zjj,1,jl1) * zworka(zji,zjj)
+            e_s(zji,zjj,1,jl1)   = e_s(zji,zjj,1,jl1) - zdesnow
+            e_s(zji,zjj,1,jl2)   = e_s(zji,zjj,1,jl2) + zdesnow
+
+            !--------------
+            ! Ice age 
+            !--------------
+
+            zdo_aice             = oa_i(zji,zjj,jl1) * zdaice(zji,zjj,jl)
+            oa_i(zji,zjj,jl1)    = oa_i(zji,zjj,jl1) - zdo_aice
+            oa_i(zji,zjj,jl2)    = oa_i(zji,zjj,jl2) + zdo_aice
+
+            !--------------
+            ! Ice salinity
+            !--------------
+
+            zdsm_vice            = smv_i(zji,zjj,jl1) * zworka(zji,zjj)
+            smv_i(zji,zjj,jl1)   = smv_i(zji,zjj,jl1) - zdsm_vice
+            smv_i(zji,zjj,jl2)   = smv_i(zji,zjj,jl2) + zdsm_vice
+
+            !---------------------
+            ! Surface temperature
+            !---------------------
+
+            zdaTsf               = t_su(zji,zjj,jl1) * zdaice(zji,zjj,jl)
+            zaTsfn(zji,zjj,jl1)  = zaTsfn(zji,zjj,jl1) - zdaTsf
+            zaTsfn(zji,zjj,jl2)  = zaTsfn(zji,zjj,jl2) + zdaTsf 
+
+         END DO                 ! ji
+
+         !------------------
+         ! Ice heat content
+         !------------------
+
+         DO jk = 1, nlay_i
+!CDIR NODEP
+            DO ji = 1, nbrem
+               zji = nind_i(ji)
+               zjj = nind_j(ji)
+
+               jl1 = zdonor(zji,zjj,jl)
+               IF (jl1 .EQ. jl) THEN
+                  jl2 = jl+1
+               ELSE             ! n1 = n+1
+                  jl2 = jl 
+               ENDIF
+
+               zdeice = e_i(zji,zjj,jk,jl1) * zworka(zji,zjj)
+               e_i(zji,zjj,jk,jl1) =  e_i(zji,zjj,jk,jl1) - zdeice
+               e_i(zji,zjj,jk,jl2) =  e_i(zji,zjj,jk,jl2) + zdeice 
+            END DO              ! ji
+         END DO                 ! jk
+
+      END DO                   ! boundaries, 1 to ncat-1
+
+      !-----------------------------------------------------------------
+      ! Update ice thickness and temperature
+      !-----------------------------------------------------------------
+
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj
+            DO ji = 1, jpi 
+               IF ( a_i(ji,jj,jl) .GT. zeps ) THEN 
+                  ht_i(ji,jj,jl)  =  v_i(ji,jj,jl) / a_i(ji,jj,jl) 
+                  t_su(ji,jj,jl)  =  zaTsfn(ji,jj,jl) / a_i(ji,jj,jl) 
+                  zindsn          =  1.0 - MAX(0.0,SIGN(1.0,-v_s(ji,jj,jl))) !0 if no ice and 1 if yes
+               ELSE
+                  ht_i(ji,jj,jl)  = 0.0
+                  t_su(ji,jj,jl)  = rtt
+               ENDIF
+            END DO                 ! ji
+         END DO                 ! jj
+      END DO                    ! jl
+
+   END SUBROUTINE lim_itd_shiftice
+   !
+
+   SUBROUTINE lim_itd_th_reb(klbnd, kubnd, ntyp)
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_th_reb ***
+      !! ** Purpose : rebin - rebins thicknesses into defined categories
+      !!
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History : (2005) Translation from CICE
+      !!              (2006) Adaptation to include salt, age and types
+      !!              (2007) Mass conservation checked
+      !!
+      !! authors: William H. Lipscomb, LANL, Elizabeth C. Hunke, LANL
+      !!          (01-2006) Martin Vancoppenolle (adaptation)
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT (in) ::  &
+         klbnd ,  &  ! Start thickness category index point
+         kubnd ,  &  ! End point on which the  the computation is applied
+         ntyp        ! number of the ice type involved in the rebinning process
+
+      INTEGER :: &
+         ji,jj,          &  ! horizontal indices
+         jl                 ! category index
+
+      INTEGER ::   &  !:
+         zshiftflag          ! = .true. if ice must be shifted
+
+      INTEGER, DIMENSION(jpi,jpj,jpl) :: &
+         zdonor             ! donor category index
+
+      REAL(wp), DIMENSION(jpi, jpj, jpl) :: &
+         zdaice         , & ! ice area transferred
+         zdvice             ! ice volume transferred
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10, &
+         epsi10    =  1.0e-10
+
+      REAL (wp), DIMENSION(jpi,jpj) :: &  ! 
+         vt_i_init, vt_i_final,   &  !  ice volume summed over categories
+         vt_s_init, vt_s_final       !  snow volume summed over categories
+
+      CHARACTER (len = 15) :: fieldid
+
+      !!-- End of declarations
+      !------------------------------------------------------------------------------
+
+      !     ! conservation check
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vt_i_init)
+         CALL lim_column_sum (jpl,   v_s, vt_s_init)
+      ENDIF
+
+      !
+      !------------------------------------------------------------------------------
+      ! 1) Compute ice thickness.
+      !------------------------------------------------------------------------------
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj
+            DO ji = 1, jpi 
+               IF (a_i(ji,jj,jl) .GT. zeps) THEN 
+                  ht_i(ji,jj,jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+               ELSE
+                  ht_i(ji,jj,jl) = 0.0
+               ENDIF
+            END DO                 ! i
+         END DO                 ! j
+      END DO                    ! n
+
+      !------------------------------------------------------------------------------
+      ! 2) Make sure thickness of cat klbnd is at least hi_max_typ(klbnd)
+      !------------------------------------------------------------------------------
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+
+            IF (a_i(ji,jj,klbnd) > zeps) THEN
+               IF (ht_i(ji,jj,klbnd) .LE. hi_max_typ(0,ntyp) .AND. hi_max_typ(0,ntyp) .GT. 0.0 ) THEN
+                  a_i(ji,jj,klbnd)  = v_i(ji,jj,klbnd) / hi_max_typ(0,ntyp) 
+                  ht_i(ji,jj,klbnd) = hi_max_typ(0,ntyp)
+               ENDIF
+            ENDIF
+         END DO                    ! i
+      END DO                    ! j
+
+      !------------------------------------------------------------------------------
+      ! 3) If a category thickness is not in bounds, shift the
+      ! entire area, volume, and energy to the neighboring category
+      !------------------------------------------------------------------------------
+      !-------------------------
+      ! Initialize shift arrays
+      !-------------------------
+
+      DO jl = klbnd, kubnd
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               zdonor(ji,jj,jl) = 0
+               zdaice(ji,jj,jl) = 0.0
+               zdvice(ji,jj,jl) = 0.0
+            END DO
+         END DO
+      END DO
+
+      !-------------------------
+      ! Move thin categories up
+      !-------------------------
+
+      DO jl = klbnd, kubnd - 1  ! loop over category boundaries
+
+         !---------------------------------------
+         ! identify thicknesses that are too big
+         !---------------------------------------
+         zshiftflag = 0
+
+         DO jj = 1, jpj 
+            DO ji = 1, jpi 
+               IF (a_i(ji,jj,jl) .GT. zeps .AND. ht_i(ji,jj,jl) .GT. hi_max(jl) ) THEN 
+                  zshiftflag        = 1
+                  zdonor(ji,jj,jl)  = jl 
+                  zdaice(ji,jj,jl)  = a_i(ji,jj,jl)
+                  zdvice(ji,jj,jl)  = v_i(ji,jj,jl)
+               ENDIF
+            END DO                 ! ji
+         END DO                 ! jj
+         IF( lk_mpp ) CALL mpp_max(zshiftflag)
+
+         IF ( zshiftflag == 1 ) THEN
+
+            !------------------------------
+            ! Shift ice between categories
+            !------------------------------
+            CALL lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice)
+
+            !------------------------
+            ! Reset shift parameters
+            !------------------------
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zdonor(ji,jj,jl) = 0
+                  zdaice(ji,jj,jl) = 0.0
+                  zdvice(ji,jj,jl) = 0.0
+               END DO
+            END DO
+
+         ENDIF                  ! zshiftflag
+
+      END DO                    ! jl
+
+      !----------------------------
+      ! Move thick categories down
+      !----------------------------
+
+      DO jl = kubnd - 1, 1, -1       ! loop over category boundaries
+
+         !-----------------------------------------
+         ! Identify thicknesses that are too small
+         !-----------------------------------------
+         zshiftflag = 0
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (a_i(ji,jj,jl+1) .GT. zeps .AND. &
+                  ht_i(ji,jj,jl+1) .LE. hi_max(jl)) THEN
+
+                  zshiftflag = 1
+                  zdonor(ji,jj,jl) = jl + 1
+                  zdaice(ji,jj,jl) = a_i(ji,jj,jl+1) 
+                  zdvice(ji,jj,jl) = v_i(ji,jj,jl+1)
+               ENDIF
+            END DO                 ! ji
+         END DO                 ! jj
+
+         IF(lk_mpp) CALL mpp_max(zshiftflag)
+         IF (zshiftflag==1) THEN
+
+            !------------------------------
+            ! Shift ice between categories
+            !------------------------------
+            CALL lim_itd_shiftice (klbnd, kubnd, zdonor, zdaice, zdvice)
+
+            !------------------------
+            ! Reset shift parameters
+            !------------------------
+            DO jj = 1, jpj 
+               DO ji = 1, jpi 
+                  zdonor(ji,jj,jl)  = 0
+                  zdaice(ji,jj,jl)  = 0.0
+                  zdvice(ji,jj,jl)  = 0.0
+               END DO
+            END DO
+
+         ENDIF                  ! zshiftflag
+
+      END DO                    ! jl
+
+      !------------------------------------------------------------------------------
+      ! 4) Conservation check
+      !------------------------------------------------------------------------------
+
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl,   v_i, vt_i_final)
+         fieldid = ' v_i : limitd_reb '
+         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid) 
+
+         CALL lim_column_sum (jpl,   v_s, vt_s_final)
+         fieldid = ' v_s : limitd_reb '
+         CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid) 
+      ENDIF
+
+   END SUBROUTINE lim_itd_th_reb
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limitd_th    ***
+   !!                              no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_itd_th           ! Empty routines
+   END SUBROUTINE lim_itd_th
+   SUBROUTINE lim_itd_th_ini
+   END SUBROUTINE lim_itd_th_ini
+   SUBROUTINE lim_itd_th_rem
+   END SUBROUTINE lim_itd_th_rem
+   SUBROUTINE lim_itd_fitline
+   END SUBROUTINE lim_itd_fitline
+   SUBROUTINE lim_itd_shiftice
+   END SUBROUTINE lim_itd_shiftice
+   SUBROUTINE lim_itd_th_reb
+   END SUBROUTINE lim_itd_th_reb
+#endif
+END MODULE limitd_th
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limmsh.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limmsh.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limmsh.F90	(revision 1844)
@@ -0,0 +1,127 @@
+MODULE limmsh
+   !!======================================================================
+   !!                     ***  MODULE  limmsh  ***
+   !! LIM ice model :   definition of the ice mesh parameters
+   !!======================================================================
+   !! History :  3.2  !  2008-01 (NEMO team)  LIM-3: adaptation from LIM-2
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_msh   : definition of the ice mesh
+   !!----------------------------------------------------------------------
+   USE phycst         ! physical constants
+   USE dom_oce        ! ocean domain
+   USE dom_ice        ! sea-ice domain
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_msh   ! routine called by ice_ini.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2,  UCL-ASTR-LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_msh
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_msh  ***
+      !!              
+      !! ** Purpose : Definition of the charact. of the numerical grid
+      !!       
+      !! ** Action  : - Initialisation of some variables
+      !!              - Definition of some constants linked with the grid
+      !!              - Definition of the metric coef. for the sea/ice
+      !!              - Initialization of the ice masks (tmsk, umsk)
+      !! 
+      !! Reference  : Deleersnijder et al. Ocean Modelling 100, 7-10 
+      !!--------------------------------------------------------------------- 
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zusden   ! temporary scalar
+      !!---------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_msh : LIM-3 sea-ice model, mesh initialization'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      !                           !==  coriolis factor & Equator position ==!
+      njeq   = INT( jpj / 2 ) 
+      njeqm1 = njeq - 1 
+      !
+      fcor(:,:) = 2. * omega * SIN( gphit(:,:) * rad )   ! coriolis factor
+      !
+      IF( fcor(1,1) * fcor(1,nlcj) < 0.e0 ) THEN   ! local domain include both hemisphere
+         l_jeq = .TRUE.
+         njeq  = 1
+         DO WHILE ( njeq <= jpj .AND. fcor(1,njeq) < 0.e0 )
+            njeq = njeq + 1
+         END DO
+         IF(lwp ) WRITE(numout,*) '          the equator is inside the domain at about njeq = ', njeq
+      ELSEIF( fcor(1,1) < 0.e0 ) THEN
+         l_jeq = .FALSE.
+         njeq = jpj
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the southern hemisphere: njeq = ', njeq
+      ELSE
+         l_jeq = .FALSE.
+         njeq = 2
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the northern hemisphere: njeq = ', njeq
+      ENDIF
+      !
+      njeqm1 = njeq - 1
+
+
+      !                           !==  metric coefficients for sea ice dynamic  ==!
+      wght(:,:,:,:) = 0.e0
+!!gm  Optimisation :  wght to be defined at F-point, not I-point  and change in limrhg
+      DO jj = 2, jpj
+         DO ji = 2, jpi
+            zusden = 1.e0 / (  ( e1t(ji,jj) + e1t(ji-1,jj  ) )   &
+               &             * ( e2t(ji,jj) + e2t(ji  ,jj-1) ) )
+            wght(ji,jj,1,1) = zusden * e1t(ji  ,jj) * e2t(ji,jj  )
+            wght(ji,jj,1,2) = zusden * e1t(ji  ,jj) * e2t(ji,jj-1)
+            wght(ji,jj,2,1) = zusden * e1t(ji-1,jj) * e2t(ji,jj  )
+            wght(ji,jj,2,2) = zusden * e1t(ji-1,jj) * e2t(ji,jj-1)
+         END DO
+      END DO
+      CALL lbc_lnk( wght(:,:,1,1), 'I', 1. )      ! CAUTION: even with the lbc_lnk at ice U-V-point
+      CALL lbc_lnk( wght(:,:,1,2), 'I', 1. )      ! the value of wght at jpj is wrong
+      CALL lbc_lnk( wght(:,:,2,1), 'I', 1. )      ! but it is never used
+      CALL lbc_lnk( wght(:,:,2,2), 'I', 1. )
+!!gm end
+
+      !                           !==  ice masks  ==!
+      tms(:,:) = tmask(:,:,1)             ! ice T-point  : use surface tmask
+      tmu(:,:) = umask(:,:,1)             ! ice U-point  : use surface umask  (C-grid EVP)
+      tmv(:,:) = vmask(:,:,1)             ! ice V-point  : use surface vmask  (C-grid EVP)
+      DO jj = 1, jpjm1                    ! ice F-point  : recompute fmask (due to nn_shlat)
+         DO ji = 1 , jpim1   ! NO vector opt.
+            tmf(ji,jj) =  tms(ji,jj) * tms(ji+1,jj) * tms(ji,jj+1) * tms(ji+1,jj+1)
+         END DO
+      END DO
+      CALL lbc_lnk( tmf(:,:), 'F', 1. )           ! lateral boundary conditions
+
+      !                           !==  unmasked and masked area of T-grid cell
+      area(:,:) = e1t(:,:) * e2t(:,:)
+      !
+   END SUBROUTINE lim_msh
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy Module         NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_msh           ! Dummy routine
+   END SUBROUTINE lim_msh
+#endif
+
+   !!======================================================================
+END MODULE limmsh
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrhg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrhg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrhg.F90	(revision 1844)
@@ -0,0 +1,779 @@
+MODULE limrhg
+   !!======================================================================
+   !!                     ***  MODULE  limrhg  ***
+   !!   Ice rheology : sea ice rheology
+   !!======================================================================
+   !! History :   -   !  2007-03  (M.A. Morales Maqueda, S. Bouillon) Original code
+   !!            3.0  !  2008-03  (M. Vancoppenolle) LIM3
+   !!             -   !  2008-11  (M. Vancoppenolle, S. Bouillon, Y. Aksenov) add surface tilt in ice rheolohy 
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_rhg   : computes ice velocities
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE par_oce
+   USE dom_oce
+   USE dom_ice
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE ice
+   USE iceini
+   USE lbclnk
+   USE lib_mpp
+   USE in_out_manager  ! I/O manager
+   USE limitd_me
+   USE prtctl          ! Print control
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_rhg  ! routine called by lim_dyn
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      rzero   = 0.e0   ,  &
+      rone    = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rhg( k_j1, k_jpj )
+
+      !!-------------------------------------------------------------------
+      !!                 ***  SUBROUTINE lim_rhg  ***
+      !!                          EVP-C-grid
+      !!
+      !! ** purpose : determines sea ice drift from wind stress, ice-ocean
+      !!  stress and sea-surface slope. Ice-ice interaction is described by 
+      !!  a non-linear elasto-viscous-plastic (EVP) law including shear 
+      !!  strength and a bulk rheology (Hunke and Dukowicz, 2002).	
+      !!
+      !!  The points in the C-grid look like this, dear reader
+      !!
+      !!                              (ji,jj)
+      !!                                 |
+      !!                                 |
+      !!                      (ji-1,jj)  |  (ji,jj)
+      !!                             ---------   
+      !!                            |         |
+      !!                            | (ji,jj) |------(ji,jj)
+      !!                            |         |
+      !!                             ---------   
+      !!                     (ji-1,jj-1)     (ji,jj-1)
+      !!
+      !! ** Inputs  : - wind forcing (stress), oceanic currents
+      !!                ice total volume (vt_i) per unit area
+      !!                snow total volume (vt_s) per unit area
+      !!
+      !! ** Action  : - compute u_ice, v_ice : the components of the 
+      !!                sea-ice velocity vector
+      !!              - compute delta_i, shear_i, divu_i, which are inputs
+      !!                of the ice thickness distribution
+      !!
+      !! ** Steps   : 1) Compute ice snow mass, ice strength 
+      !!              2) Compute wind, oceanic stresses, mass terms and
+      !!                 coriolis terms of the momentum equation
+      !!              3) Solve the momentum equation (iterative procedure)
+      !!              4) Prevent high velocities if the ice is thin
+      !!              5) Recompute invariants of the strain rate tensor
+      !!                 which are inputs of the ITD, store stress
+      !!                 for the next time step
+      !!              6) Control prints of residual (convergence)
+      !!                 and charge ellipse.
+      !!                 The user should make sure that the parameters
+      !!                 nevp, telast and creepl maintain stress state
+      !!                 on the charge ellipse for plastic flow
+      !!                 e.g. in the Canadian Archipelago
+      !!
+      !! ** References : Hunke and Dukowicz, JPO97
+      !!                 Bouillon et al., 08, in prep (update this when
+      !!                 published)
+      !!                 Vancoppenolle et al., OM08
+      !!
+      !!-------------------------------------------------------------------
+      ! * Arguments
+      !
+      INTEGER, INTENT(in) :: &
+         k_j1 ,                      & !: southern j-index for ice computation
+         k_jpj                         !: northern j-index for ice computation
+
+      ! * Local variables
+      INTEGER ::   ji, jj              !: dummy loop indices
+
+      INTEGER  :: &
+         jter                          !: temporary integers
+
+      CHARACTER (len=50) ::   charout
+
+      REAL(wp) :: &
+         zt11, zt12, zt21, zt22,     & !: temporary scalars
+         ztagnx, ztagny,             & !: wind stress on U/V points                       
+         delta                         !
+
+      REAL(wp) :: &
+         za,                         & !:
+         zstms,                      & !: temporary scalar for ice strength
+         zsang,                      & !: temporary scalar for coriolis term
+         zmask                         !: mask for the computation of ice mass
+
+      REAL(wp),DIMENSION(jpi,jpj) :: &
+         zpresh        ,             & !: temporary array for ice strength
+         zpreshc       ,             & !: Ice strength on grid cell corners (zpreshc)
+         zfrld1, zfrld2,             & !: lead fraction on U/V points                                    
+         zmass1, zmass2,             & !: ice/snow mass on U/V points                                    
+         zcorl1, zcorl2,             & !: coriolis parameter on U/V points
+         za1ct, za2ct  ,             & !: temporary arrays
+         zc1           ,             & !: ice mass
+         zusw          ,             & !: temporary weight for the computation
+                                !: of ice strength
+         u_oce1, v_oce1,             & !: ocean u/v component on U points                           
+         u_oce2, v_oce2,             & !: ocean u/v component on V points
+         u_ice2,                     & !: ice u component on V point
+         v_ice1                        !: ice v component on U point
+
+      REAL(wp) :: &
+         dtevp,                      & !: time step for subcycling
+         dtotel,                     & !:
+         ecc2,                       & !: square of yield ellipse eccenticity
+         z0,                         & !: temporary scalar
+         zr,                         & !: temporary scalar
+         zcca, zccb,                 & !: temporary scalars
+         zu_ice2,                    & !: 
+         zv_ice1,                    & !:
+         zddc, zdtc,                 & !: temporary array for delta on corners
+         zdst,                       & !: temporary array for delta on centre
+         zdsshx, zdsshy,             & !: term for the gradient of ocean surface
+         sigma1, sigma2                !: internal ice stress
+
+      REAL(wp),DIMENSION(jpi,jpj) :: &
+         zf1, zf2                      !: arrays for internal stresses
+
+      REAL(wp),DIMENSION(jpi,jpj) :: &
+         zdd, zdt,                   & !: Divergence and tension at centre of grid cells
+         zds,                        & !: Shear on northeast corner of grid cells
+         deltat,                     & !: Delta at centre of grid cells
+         deltac,                     & !: Delta on corners
+         zs1, zs2,                   & !: Diagonal stress tensor components zs1 and zs2 
+         zs12                          !: Non-diagonal stress tensor component zs12
+
+      REAL(wp) :: &
+         zresm            ,          & !: Maximal error on ice velocity
+         zindb            ,          & !: ice (1) or not (0)      
+         zdummy                        !: dummy argument
+
+      REAL(wp),DIMENSION(jpi,jpj) :: &
+         zu_ice           ,          & !: Ice velocity on previous time step
+         zv_ice           ,          &
+         zresr                         !: Local error on velocity
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 1) Ice-Snow mass (zc1), ice strength (zpresh)                                !
+      !------------------------------------------------------------------------------!
+      !
+      ! Put every vector to 0
+      zpresh(:,:) = 0.0 ; zc1(:,:) = 0.0
+      zpreshc(:,:) = 0.0
+      u_ice2(:,:)  = 0.0 ; v_ice1(:,:)  = 0.0
+      zdd(:,:)     = 0.0 ; zdt(:,:)     = 0.0 ; zds(:,:)     = 0.0
+
+      ! Ice strength on T-points
+      CALL lim_itd_me_icestrength(ridge_scheme_swi)
+
+      ! Ice mass and temp variables
+!CDIR NOVERRCHK
+      DO jj = k_j1 , k_jpj
+!CDIR NOVERRCHK
+         DO ji = 1 , jpi
+            zc1(ji,jj)    = tms(ji,jj) * ( rhosn * vt_s(ji,jj) + rhoic * vt_i(ji,jj) )
+            zpresh(ji,jj) = tms(ji,jj) *  strength(ji,jj) / 2.
+            ! tmi = 1 where there is ice or on land
+            tmi(ji,jj)    = 1.0 - ( 1.0 - MAX( 0.0 , SIGN ( 1.0 , vt_i(ji,jj) - &
+               epsd ) ) ) * tms(ji,jj)
+         END DO
+      END DO
+
+      ! Ice strength on grid cell corners (zpreshc)
+      ! needed for calculation of shear stress 
+!CDIR NOVERRCHK
+      DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+         DO ji = 2, jpim1 !RB caution no fs_ (ji+1,jj+1)
+            zstms          =  tms(ji+1,jj+1) * wght(ji+1,jj+1,2,2) + &
+               &              tms(ji,jj+1)   * wght(ji+1,jj+1,1,2) + &
+               &              tms(ji+1,jj)   * wght(ji+1,jj+1,2,1) + &
+               &              tms(ji,jj)     * wght(ji+1,jj+1,1,1)
+            zusw(ji,jj)    = 1.0 / MAX( zstms, epsd )
+            zpreshc(ji,jj) = (  zpresh(ji+1,jj+1) * wght(ji+1,jj+1,2,2) + &
+               &                zpresh(ji,jj+1)   * wght(ji+1,jj+1,1,2) + &
+               &                zpresh(ji+1,jj)   * wght(ji+1,jj+1,2,1) + & 
+               &                zpresh(ji,jj)     * wght(ji+1,jj+1,1,1)   &
+               &             ) * zusw(ji,jj)
+         END DO
+      END DO
+
+      CALL lbc_lnk( zpreshc(:,:), 'F', 1. )
+      !
+      !------------------------------------------------------------------------------!
+      ! 2) Wind / ocean stress, mass terms, coriolis terms
+      !------------------------------------------------------------------------------!
+      !
+      !  Wind stress, coriolis and mass terms on the sides of the squares        
+      !  zfrld1: lead fraction on U-points                                      
+      !  zfrld2: lead fraction on V-points                                     
+      !  zmass1: ice/snow mass on U-points                                    
+      !  zmass2: ice/snow mass on V-points                                   
+      !  zcorl1: Coriolis parameter on U-points                             
+      !  zcorl2: Coriolis parameter on V-points                            
+      !  (ztagnx,ztagny): wind stress on U/V points                       
+      !  u_oce1: ocean u component on u points                           
+      !  v_oce1: ocean v component on u points                          
+      !  u_oce2: ocean u component on v points                         
+      !  v_oce2: ocean v component on v points                        
+
+      DO jj = k_j1+1, k_jpj-1
+         DO ji = fs_2, fs_jpim1
+
+            zt11 = tms(ji,jj)*e1t(ji,jj)
+            zt12 = tms(ji+1,jj)*e1t(ji+1,jj)
+            zt21 = tms(ji,jj)*e2t(ji,jj)
+            zt22 = tms(ji,jj+1)*e2t(ji,jj+1)
+
+            ! Leads area.
+            zfrld1(ji,jj) = ( zt12 * ( 1.0 - at_i(ji,jj) ) + &
+               &                        zt11 * ( 1.0 - at_i(ji+1,jj) ) ) / ( zt11 + zt12 + epsd )
+            zfrld2(ji,jj) = ( zt22 * ( 1.0 - at_i(ji,jj) ) + &
+               &                        zt21 * ( 1.0 - at_i(ji,jj+1) ) ) / ( zt21 + zt22 + epsd )
+
+            ! Mass, coriolis coeff. and currents
+            zmass1(ji,jj) = ( zt12*zc1(ji,jj) + zt11*zc1(ji+1,jj) ) / (zt11+zt12+epsd)
+            zmass2(ji,jj) = ( zt22*zc1(ji,jj) + zt21*zc1(ji,jj+1) ) / (zt21+zt22+epsd)
+            zcorl1(ji,jj) = zmass1(ji,jj) * ( e1t(ji+1,jj)*fcor(ji,jj) + &
+               e1t(ji,jj)*fcor(ji+1,jj) ) &
+               / (e1t(ji,jj) + e1t(ji+1,jj) + epsd )
+            zcorl2(ji,jj) = zmass2(ji,jj) * ( e2t(ji,jj+1)*fcor(ji,jj) + &
+               e2t(ji,jj)*fcor(ji,jj+1) ) &
+               / ( e2t(ji,jj+1) + e2t(ji,jj) + epsd )
+            !
+            u_oce1(ji,jj)  = u_oce(ji,jj)
+            v_oce2(ji,jj)  = v_oce(ji,jj)
+
+            ! Ocean has no slip boundary condition
+            v_oce1(ji,jj)  = 0.5*( (v_oce(ji,jj)+v_oce(ji,jj-1))*e1t(ji,jj)    &
+               &                 +(v_oce(ji+1,jj)+v_oce(ji+1,jj-1))*e1t(ji+1,jj)) &
+               &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj)  
+
+            u_oce2(ji,jj)  = 0.5*((u_oce(ji,jj)+u_oce(ji-1,jj))*e2t(ji,jj)     &
+               &                 +(u_oce(ji,jj+1)+u_oce(ji-1,jj+1))*e2t(ji,jj+1)) &
+               &                / (e2t(ji,jj+1)+e2t(ji,jj)) * tmv(ji,jj)
+
+            ! Wind stress at U,V-point
+            ztagnx = ( 1. - zfrld1(ji,jj) ) * utau_ice(ji,jj)
+            ztagny = ( 1. - zfrld2(ji,jj) ) * vtau_ice(ji,jj)
+
+            ! Computation of the velocity field taking into account the ice internal interaction.
+            ! Terms that are independent of the velocity field.
+
+            ! SB On utilise maintenant le gradient de la pente de l'ocean
+            ! include it later
+
+            zdsshx =  (ssh_m(ji+1,jj) - ssh_m(ji,jj))/e1u(ji,jj)
+            zdsshy =  (ssh_m(ji,jj+1) - ssh_m(ji,jj))/e2v(ji,jj)
+
+            za1ct(ji,jj) = ztagnx - zmass1(ji,jj) * grav * zdsshx
+            za2ct(ji,jj) = ztagny - zmass2(ji,jj) * grav * zdsshy
+
+         END DO
+      END DO
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 3) Solution of the momentum equation, iterative procedure
+      !------------------------------------------------------------------------------!
+      !
+      ! Time step for subcycling
+      dtevp  = rdt_ice / nevp
+      dtotel = dtevp / ( 2.0 * telast )
+
+      !-ecc2: square of yield ellipse eccenticrity (reminder: must become a namelist parameter)
+      ecc2 = ecc*ecc
+
+      !-Initialise stress tensor 
+      zs1(:,:)  = stress1_i(:,:) 
+      zs2(:,:)  = stress2_i(:,:)
+      zs12(:,:) = stress12_i(:,:)
+
+      !----------------------!
+      DO jter = 1 , nevp                              !    loop over jter    !
+         !----------------------!        
+         DO jj = k_j1, k_jpj-1
+            zu_ice(:,jj) = u_ice(:,jj) ! velocity at previous time step
+            zv_ice(:,jj) = v_ice(:,jj)
+         END DO
+
+         DO jj = k_j1+1, k_jpj-1
+            DO ji = fs_2, jpim1   !RB bug no vect opt due to tmi
+
+               !  
+               !- Divergence, tension and shear (Section a. Appendix B of Hunke & Dukowicz, 2002)
+               !- zdd(:,:), zdt(:,:): divergence and tension at centre of grid cells
+               !- zds(:,:): shear on northeast corner of grid cells
+               !
+               !- IMPORTANT REMINDER: Dear Gurvan, note that, the way these terms are coded, 
+               !                      there are many repeated calculations. 
+               !                      Speed could be improved by regrouping terms. For
+               !                      the moment, however, the stress is on clarity of coding to avoid
+               !                      bugs (Martin, for Miguel).
+               !
+               !- ALSO: arrays zdd, zdt, zds and delta could 
+               !  be removed in the future to minimise memory demand.
+               !
+               !- MORE NOTES: Note that we are calculating deformation rates and stresses on the corners of
+               !              grid cells, exactly as in the B grid case. For simplicity, the indexation on
+               !              the corners is the same as in the B grid.
+               !
+               !
+               zdd(ji,jj) = ( e2u(ji,jj)*u_ice(ji,jj)                      &
+                  &          -e2u(ji-1,jj)*u_ice(ji-1,jj)                  &
+                  &          +e1v(ji,jj)*v_ice(ji,jj)                      &
+                  &          -e1v(ji,jj-1)*v_ice(ji,jj-1)                  &
+                  &          )                                             &
+                  &         / area(ji,jj)
+
+               zdt(ji,jj) = ( ( u_ice(ji,jj)/e2u(ji,jj)                    &
+                  &            -u_ice(ji-1,jj)/e2u(ji-1,jj)                &
+                  &           )*e2t(ji,jj)*e2t(ji,jj)                      &
+                  &          -( v_ice(ji,jj)/e1v(ji,jj)                    &
+                  &            -v_ice(ji,jj-1)/e1v(ji,jj-1)                &
+                  &           )*e1t(ji,jj)*e1t(ji,jj)                      &
+                  &         )                                              &
+                  &        / area(ji,jj)
+
+               !
+               zds(ji,jj) = ( ( u_ice(ji,jj+1)/e1u(ji,jj+1)                &
+                  &            -u_ice(ji,jj)/e1u(ji,jj)                    &
+                  &           )*e1f(ji,jj)*e1f(ji,jj)                      &
+                  &          +( v_ice(ji+1,jj)/e2v(ji+1,jj)                &
+                  &            -v_ice(ji,jj)/e2v(ji,jj)                    &
+                  &           )*e2f(ji,jj)*e2f(ji,jj)                      &
+                  &         )                                              &
+                  &        / ( e1f(ji,jj) * e2f(ji,jj) ) * ( 2.0 - tmf(ji,jj) ) &
+                  &        * tmi(ji,jj) * tmi(ji,jj+1)                     &
+                  &        * tmi(ji+1,jj) * tmi(ji+1,jj+1)
+
+
+               v_ice1(ji,jj)  = 0.5*( (v_ice(ji,jj)+v_ice(ji,jj-1))*e1t(ji+1,jj)   &
+                  &                 +(v_ice(ji+1,jj)+v_ice(ji+1,jj-1))*e1t(ji,jj)) &
+                  &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj) 
+
+               u_ice2(ji,jj)  = 0.5*( (u_ice(ji,jj)+u_ice(ji-1,jj))*e2t(ji,jj+1)   &
+                  &                 +(u_ice(ji,jj+1)+u_ice(ji-1,jj+1))*e2t(ji,jj)) &
+                  &               /(e2t(ji,jj+1)+e2t(ji,jj)) * tmv(ji,jj)
+
+            END DO
+         END DO
+         CALL lbc_lnk( v_ice1(:,:), 'U', -1. )
+         CALL lbc_lnk( u_ice2(:,:), 'V', -1. )
+
+!CDIR NOVERRCHK
+         DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1
+
+               !- Calculate Delta at centre of grid cells
+               zdst       = (  e2u( ji  , jj   ) * v_ice1(ji,jj)            &
+                  &          - e2u( ji-1, jj   ) * v_ice1(ji-1,jj)          &
+                  &          + e1v( ji  , jj   ) * u_ice2(ji,jj)            &
+                  &          - e1v( ji  , jj-1 ) * u_ice2(ji,jj-1)          &
+                  &          )                                              &
+                  &         / area(ji,jj)
+
+               delta = SQRT( zdd(ji,jj)*zdd(ji,jj) +                        & 
+                  &                       ( zdt(ji,jj)*zdt(ji,jj) + zdst*zdst ) * usecc2 )  
+               deltat(ji,jj) = MAX( SQRT(zdd(ji,jj)**2 +                    &
+                  (zdt(ji,jj)**2 + zdst**2)*usecc2), creepl )
+
+               !-Calculate stress tensor components zs1 and zs2 
+               !-at centre of grid cells (see section 3.5 of CICE user's guide).
+               zs1(ji,jj) = ( zs1(ji,jj) &
+                  &          - dtotel*( ( 1.0 - alphaevp) * zs1(ji,jj) +    &
+                  &            ( delta / deltat(ji,jj) - zdd(ji,jj) / deltat(ji,jj) ) &
+                  * zpresh(ji,jj) ) )                          &       
+                  &        / ( 1.0 + alphaevp * dtotel )
+
+               zs2(ji,jj) = ( zs2(ji,jj)   &
+                  &          - dtotel*((1.0-alphaevp)*ecc2*zs2(ji,jj) -  &
+                  zdt(ji,jj)/deltat(ji,jj)*zpresh(ji,jj)) ) &
+                  &        / ( 1.0 + alphaevp*ecc2*dtotel )
+
+            END DO
+         END DO
+
+         CALL lbc_lnk( zs1(:,:), 'T', 1. )
+         CALL lbc_lnk( zs2(:,:), 'T', 1. )
+
+!CDIR NOVERRCHK
+         DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1
+               !- Calculate Delta on corners
+               zddc  =      ( ( v_ice1(ji,jj+1)/e1u(ji,jj+1)                &
+                  &            -v_ice1(ji,jj)/e1u(ji,jj)                    &
+                  &           )*e1f(ji,jj)*e1f(ji,jj)                       &
+                  &          +( u_ice2(ji+1,jj)/e2v(ji+1,jj)                &
+                  &            -u_ice2(ji,jj)/e2v(ji,jj)                    &
+                  &           )*e2f(ji,jj)*e2f(ji,jj)                       &
+                  &         )                                               &
+                  &        / ( e1f(ji,jj) * e2f(ji,jj) )
+
+               zdtc  =      (-( v_ice1(ji,jj+1)/e1u(ji,jj+1)                &
+                  &            -v_ice1(ji,jj)/e1u(ji,jj)                    &
+                  &           )*e1f(ji,jj)*e1f(ji,jj)                       &
+                  &          +( u_ice2(ji+1,jj)/e2v(ji+1,jj)                &
+                  &            -u_ice2(ji,jj)/e2v(ji,jj)                    &
+                  &           )*e2f(ji,jj)*e2f(ji,jj)                       &
+                  &         )                                               &
+                  &        / ( e1f(ji,jj) * e2f(ji,jj) )
+
+               deltac(ji,jj) = SQRT(zddc**2+(zdtc**2+zds(ji,jj)**2)*usecc2) + creepl
+
+               !-Calculate stress tensor component zs12 at corners (see section 3.5 of CICE user's guide).
+               zs12(ji,jj) = ( zs12(ji,jj)      &
+                  &        - dtotel*( (1.0-alphaevp)*ecc2*zs12(ji,jj) - zds(ji,jj) / &
+                  &          ( 2.0*deltac(ji,jj) ) * zpreshc(ji,jj))) &
+                  &         / ( 1.0 + alphaevp*ecc2*dtotel ) 
+
+            END DO ! ji
+         END DO ! jj
+
+         CALL lbc_lnk( zs12(:,:), 'F', 1. )
+
+         ! Ice internal stresses (Appendix C of Hunke and Dukowicz, 2002)
+         DO jj = k_j1+1, k_jpj-1
+            DO ji = fs_2, fs_jpim1
+               !- contribution of zs1, zs2 and zs12 to zf1
+               zf1(ji,jj) = 0.5*( (zs1(ji+1,jj)-zs1(ji,jj))*e2u(ji,jj) &
+                  &              +(zs2(ji+1,jj)*e2t(ji+1,jj)**2-zs2(ji,jj)*e2t(ji,jj)**2)/e2u(ji,jj) &
+                  &              +2.0*(zs12(ji,jj)*e1f(ji,jj)**2-zs12(ji,jj-1)*e1f(ji,jj-1)**2)/e1u(ji,jj) &
+                  &             ) / ( e1u(ji,jj)*e2u(ji,jj) )
+               ! contribution of zs1, zs2 and zs12 to zf2
+               zf2(ji,jj) = 0.5*( (zs1(ji,jj+1)-zs1(ji,jj))*e1v(ji,jj) &
+                  &              -(zs2(ji,jj+1)*e1t(ji,jj+1)**2 - zs2(ji,jj)*e1t(ji,jj)**2)/e1v(ji,jj) &
+                  &              + 2.0*(zs12(ji,jj)*e2f(ji,jj)**2 -    &
+                  zs12(ji-1,jj)*e2f(ji-1,jj)**2)/e2v(ji,jj) &
+                  &             ) / ( e1v(ji,jj)*e2v(ji,jj) )
+            END DO
+         END DO
+         !
+         ! Computation of ice velocity
+         !
+         ! Both the Coriolis term and the ice-ocean drag are solved semi-implicitly.
+         !
+         IF (MOD(jter,2).eq.0) THEN 
+
+!CDIR NOVERRCHK
+            DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1
+                  zmask        = (1.0-MAX(rzero,SIGN(rone,-zmass1(ji,jj))))*tmu(ji,jj)
+                  zsang        = SIGN ( 1.0 , fcor(ji,jj) ) * sangvg
+                  z0           = zmass1(ji,jj)/dtevp
+
+                  ! SB modif because ocean has no slip boundary condition
+                  zv_ice1       = 0.5*( (v_ice(ji,jj)+v_ice(ji,jj-1))*e1t(ji,jj)         &
+                     &                 +(v_ice(ji+1,jj)+v_ice(ji+1,jj-1))*e1t(ji+1,jj))   &
+                     &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj)
+                  za           = rhoco*SQRT((u_ice(ji,jj)-u_oce1(ji,jj))**2 + &
+                     (zv_ice1-v_oce1(ji,jj))**2) * (1.0-zfrld1(ji,jj))
+                  zr           = z0*u_ice(ji,jj) + zf1(ji,jj) + za1ct(ji,jj) + &
+                     za*(cangvg*u_oce1(ji,jj)-zsang*v_oce1(ji,jj))
+                  zcca         = z0+za*cangvg
+                  zccb         = zcorl1(ji,jj)+za*zsang
+                  u_ice(ji,jj) = (zr+zccb*zv_ice1)/(zcca+epsd)*zmask 
+
+               END DO
+            END DO
+
+            CALL lbc_lnk( u_ice(:,:), 'U', -1. )
+
+!CDIR NOVERRCHK
+            DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1
+
+                  zmask        = (1.0-MAX(rzero,SIGN(rone,-zmass2(ji,jj))))*tmv(ji,jj)
+                  zsang        = SIGN(1.0,fcor(ji,jj))*sangvg
+                  z0           = zmass2(ji,jj)/dtevp
+                  ! SB modif because ocean has no slip boundary condition
+                  zu_ice2       = 0.5*( (u_ice(ji,jj)+u_ice(ji-1,jj))*e2t(ji,jj)     &
+                     &                 + (u_ice(ji,jj+1)+u_ice(ji-1,jj+1))*e2t(ji,jj+1))   &
+                     &               /(e2t(ji,jj+1)+e2t(ji,jj)) * tmv(ji,jj)
+                  za           = rhoco*SQRT((zu_ice2-u_oce2(ji,jj))**2 + & 
+                     (v_ice(ji,jj)-v_oce2(ji,jj))**2)*(1.0-zfrld2(ji,jj))
+                  zr           = z0*v_ice(ji,jj) + zf2(ji,jj) + &
+                     za2ct(ji,jj) + za*(cangvg*v_oce2(ji,jj)+zsang*u_oce2(ji,jj))
+                  zcca         = z0+za*cangvg
+                  zccb         = zcorl2(ji,jj)+za*zsang
+                  v_ice(ji,jj) = (zr-zccb*zu_ice2)/(zcca+epsd)*zmask
+
+               END DO
+            END DO
+
+            CALL lbc_lnk( v_ice(:,:), 'V', -1. )
+
+         ELSE 
+!CDIR NOVERRCHK
+            DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1
+                  zmask        = (1.0-MAX(rzero,SIGN(rone,-zmass2(ji,jj))))*tmv(ji,jj)
+                  zsang        = SIGN(1.0,fcor(ji,jj))*sangvg
+                  z0           = zmass2(ji,jj)/dtevp
+                  ! SB modif because ocean has no slip boundary condition
+                  zu_ice2       = 0.5*( (u_ice(ji,jj)+u_ice(ji-1,jj))*e2t(ji,jj)      &
+                     &                 +(u_ice(ji,jj+1)+u_ice(ji-1,jj+1))*e2t(ji,jj+1))   &
+                     &               /(e2t(ji,jj+1)+e2t(ji,jj)) * tmv(ji,jj)   
+
+                  za           = rhoco*SQRT((zu_ice2-u_oce2(ji,jj))**2 + &
+                     (v_ice(ji,jj)-v_oce2(ji,jj))**2)*(1.0-zfrld2(ji,jj))
+                  zr           = z0*v_ice(ji,jj) + zf2(ji,jj) + &
+                     za2ct(ji,jj) + za*(cangvg*v_oce2(ji,jj)+zsang*u_oce2(ji,jj))
+                  zcca         = z0+za*cangvg
+                  zccb         = zcorl2(ji,jj)+za*zsang
+                  v_ice(ji,jj) = (zr-zccb*zu_ice2)/(zcca+epsd)*zmask
+
+               END DO
+            END DO
+
+            CALL lbc_lnk( v_ice(:,:), 'V', -1. )
+
+!CDIR NOVERRCHK
+            DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1
+                  zmask        = (1.0-MAX(rzero,SIGN(rone,-zmass1(ji,jj))))*tmu(ji,jj)
+                  zsang        = SIGN(1.0,fcor(ji,jj))*sangvg
+                  z0           = zmass1(ji,jj)/dtevp
+                  ! SB modif because ocean has no slip boundary condition
+                  ! GG Bug
+                  !                   zv_ice1       = 0.5*( (v_ice(ji,jj)+v_ice(ji,jj-1))*e1t(ji+1,jj)      &
+                  !                      &                 +(v_ice(ji+1,jj)+v_ice(ji+1,jj-1))*e1t(ji,jj))   &
+                  !                      &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj)
+                  zv_ice1       = 0.5*( (v_ice(ji,jj)+v_ice(ji,jj-1))*e1t(ji,jj)      &
+                     &                 +(v_ice(ji+1,jj)+v_ice(ji+1,jj-1))*e1t(ji+1,jj))   &
+                     &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj)
+
+                  za           = rhoco*SQRT((u_ice(ji,jj)-u_oce1(ji,jj))**2 + &
+                     (zv_ice1-v_oce1(ji,jj))**2)*(1.0-zfrld1(ji,jj))
+                  zr           = z0*u_ice(ji,jj) + zf1(ji,jj) + za1ct(ji,jj) + &
+                     za*(cangvg*u_oce1(ji,jj)-zsang*v_oce1(ji,jj))
+                  zcca         = z0+za*cangvg
+                  zccb         = zcorl1(ji,jj)+za*zsang
+                  u_ice(ji,jj) = (zr+zccb*zv_ice1)/(zcca+epsd)*zmask 
+               END DO ! ji
+            END DO ! jj
+
+            CALL lbc_lnk( u_ice(:,:), 'U', -1. )
+
+         ENDIF
+
+         IF(ln_ctl) THEN
+            !---  Convergence test.
+            DO jj = k_j1+1 , k_jpj-1
+               zresr(:,jj) = MAX( ABS( u_ice(:,jj) - zu_ice(:,jj) ) ,           &
+                  ABS( v_ice(:,jj) - zv_ice(:,jj) ) )
+            END DO
+            zresm = MAXVAL( zresr( 1:jpi , k_j1+1:k_jpj-1 ) )
+            IF( lk_mpp )   CALL mpp_max( zresm )   ! max over the global domain
+         ENDIF
+
+         !                                                   ! ==================== !
+      END DO                                              !  end loop over jter  !
+      !                                                   ! ==================== !
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 4) Prevent ice velocities when the ice is thin
+      !------------------------------------------------------------------------------!
+      !
+      ! If the ice thickness is below 1cm then ice velocity should equal the
+      ! ocean velocity, 
+      ! This prevents high velocity when ice is thin
+!CDIR NOVERRCHK
+      DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+         DO ji = fs_2, fs_jpim1
+            zindb  = MAX( 0.0, SIGN( 1.0, at_i(ji,jj) - 1.0e-6 ) ) 
+            zdummy = zindb * vt_i(ji,jj) / MAX(at_i(ji,jj) , 1.0e-06 )
+            IF ( zdummy .LE. 5.0e-2 ) THEN
+               u_ice(ji,jj) = u_oce(ji,jj)
+               v_ice(ji,jj) = v_oce(ji,jj)
+            ENDIF ! zdummy
+         END DO
+      END DO
+
+      CALL lbc_lnk( u_ice(:,:), 'U', -1. ) 
+      CALL lbc_lnk( v_ice(:,:), 'V', -1. ) 
+
+      DO jj = k_j1+1, k_jpj-1 
+         DO ji = fs_2, fs_jpim1
+            zindb  = MAX( 0.0, SIGN( 1.0, at_i(ji,jj) - 1.0e-6 ) ) 
+            zdummy = zindb * vt_i(ji,jj) / MAX(at_i(ji,jj) , 1.0e-06 )
+            IF ( zdummy .LE. 5.0e-2 ) THEN
+               v_ice1(ji,jj)  = 0.5*( (v_ice(ji,jj)+v_ice(ji,jj-1))*e1t(ji+1,jj)   &
+                  &                 +(v_ice(ji+1,jj)+v_ice(ji+1,jj-1))*e1t(ji,jj)) &
+                  &               /(e1t(ji+1,jj)+e1t(ji,jj)) * tmu(ji,jj)
+
+               u_ice2(ji,jj)  = 0.5*( (u_ice(ji,jj)+u_ice(ji-1,jj))*e2t(ji,jj+1)   &
+                  &                 +(u_ice(ji,jj+1)+u_ice(ji-1,jj+1))*e2t(ji,jj)) &
+                  &               /(e2t(ji,jj+1)+e2t(ji,jj)) * tmv(ji,jj)
+            ENDIF ! zdummy
+         END DO
+      END DO
+
+      CALL lbc_lnk( u_ice2(:,:), 'V', -1. ) 
+      CALL lbc_lnk( v_ice1(:,:), 'U', -1. )
+
+      ! Recompute delta, shear and div, inputs for mechanical redistribution 
+!CDIR NOVERRCHK
+      DO jj = k_j1+1, k_jpj-1
+!CDIR NOVERRCHK
+         DO ji = fs_2, jpim1   !RB bug no vect opt due to tmi
+            !- zdd(:,:), zdt(:,:): divergence and tension at centre 
+            !- zds(:,:): shear on northeast corner of grid cells
+            zindb  = MAX( 0.0, SIGN( 1.0, at_i(ji,jj) - 1.0e-6 ) ) 
+            zdummy = zindb * vt_i(ji,jj) / MAX(at_i(ji,jj) , 1.0e-06 )
+
+            IF ( zdummy .LE. 5.0e-2 ) THEN
+
+               zdd(ji,jj) = ( e2u(ji,jj)*u_ice(ji,jj)                      &
+                  &          -e2u(ji-1,jj)*u_ice(ji-1,jj)                  &
+                  &          +e1v(ji,jj)*v_ice(ji,jj)                      &
+                  &          -e1v(ji,jj-1)*v_ice(ji,jj-1)                  &
+                  &         )                                              &
+                  &         / area(ji,jj)
+
+               zdt(ji,jj) = ( ( u_ice(ji,jj)/e2u(ji,jj)                    &
+                  &            -u_ice(ji-1,jj)/e2u(ji-1,jj)                &
+                  &           )*e2t(ji,jj)*e2t(ji,jj)                      &
+                  &          -( v_ice(ji,jj)/e1v(ji,jj)                    &
+                  &            -v_ice(ji,jj-1)/e1v(ji,jj-1)                &
+                  &           )*e1t(ji,jj)*e1t(ji,jj)                      &
+                  &         )                                              &
+                  &        / area(ji,jj)
+               !
+               ! SB modif because ocean has no slip boundary condition 
+               zds(ji,jj) = ( ( u_ice(ji,jj+1) / e1u(ji,jj+1)              &
+                  &           - u_ice(ji,jj)   / e1u(ji,jj) )              &
+                  &           * e1f(ji,jj) * e1f(ji,jj)                    &
+                  &          + ( v_ice(ji+1,jj) / e2v(ji+1,jj)             &
+                  &            - v_ice(ji,jj)  / e2v(ji,jj) )              &
+                  &           * e2f(ji,jj) * e2f(ji,jj) )                  &
+                  &        / ( e1f(ji,jj) * e2f(ji,jj) ) * ( 2.0 - tmf(ji,jj) ) &
+                  &        * tmi(ji,jj) * tmi(ji,jj+1)                     &
+                  &        * tmi(ji+1,jj) * tmi(ji+1,jj+1)
+
+               zdst       = (  e2u( ji  , jj   ) * v_ice1(ji,jj)          &
+                  &          - e2u( ji-1, jj   ) * v_ice1(ji-1,jj)         &
+                  &          + e1v( ji  , jj   ) * u_ice2(ji,jj)           &
+                  &          - e1v( ji  , jj-1 ) * u_ice2(ji,jj-1)         & 
+                  &          )                                             &
+                  &         / area(ji,jj)
+
+               deltat(ji,jj) = SQRT( zdd(ji,jj)*zdd(ji,jj) + & 
+                  &                          ( zdt(ji,jj)*zdt(ji,jj) + zdst*zdst ) * usecc2 & 
+                  &                          ) + creepl
+
+            ENDIF ! zdummy
+
+         END DO !jj
+      END DO !ji
+      !
+      !------------------------------------------------------------------------------!
+      ! 5) Store stress tensor and its invariants
+      !------------------------------------------------------------------------------!
+      !
+      ! * Invariants of the stress tensor are required for limitd_me
+      ! accelerates convergence and improves stability
+      DO jj = k_j1+1, k_jpj-1
+         DO ji = fs_2, fs_jpim1
+            divu_i (ji,jj) = zdd   (ji,jj)
+            delta_i(ji,jj) = deltat(ji,jj)
+            shear_i(ji,jj) = zds   (ji,jj)
+         END DO
+      END DO
+
+      ! Lateral boundary condition
+      CALL lbc_lnk( divu_i (:,:), 'T', 1. )
+      CALL lbc_lnk( delta_i(:,:), 'T', 1. )
+      CALL lbc_lnk( shear_i(:,:), 'F', 1. )
+
+      ! * Store the stress tensor for the next time step
+      stress1_i (:,:) = zs1 (:,:)
+      stress2_i (:,:) = zs2 (:,:)
+      stress12_i(:,:) = zs12(:,:)
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 6) Control prints of residual and charge ellipse
+      !------------------------------------------------------------------------------!
+      !
+      ! print the residual for convergence
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('lim_rhg  : res =',D23.16, ' iter =',I4)") zresm, jter
+         CALL prt_ctl_info(charout)
+         CALL prt_ctl(tab2d_1=u_ice, clinfo1=' lim_rhg  : u_ice :', tab2d_2=v_ice, clinfo2=' v_ice :')
+      ENDIF
+
+      ! print charge ellipse
+      ! This can be desactivated once the user is sure that the stress state
+      ! lie on the charge ellipse. See Bouillon et al. 08 for more details
+      IF(ln_ctl) THEN
+         CALL prt_ctl_info('lim_rhg  : numit  :',ivar1=numit)
+         CALL prt_ctl_info('lim_rhg  : nwrite :',ivar1=nwrite)
+         CALL prt_ctl_info('lim_rhg  : MOD    :',ivar1=MOD(numit,nwrite))
+         IF( MOD(numit,nwrite) .EQ. 0 ) THEN
+            WRITE(charout,FMT="('lim_rhg  :', I4, I6, I1, I1, A10)") 1000, numit, 0, 0, ' ch. ell. '
+            CALL prt_ctl_info(charout)
+            DO jj = k_j1+1, k_jpj-1
+               DO ji = 2, jpim1
+                  IF (zpresh(ji,jj) .GT. 1.0) THEN
+                     sigma1 = ( zs1(ji,jj) + (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) ) 
+                     sigma2 = ( zs1(ji,jj) - (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) )
+                     WRITE(charout,FMT="('lim_rhg  :', I4, I4, D23.16, D23.16, D23.16, D23.16, A10)")
+                     CALL prt_ctl_info(charout)
+                  ENDIF
+               END DO
+            END DO
+            WRITE(charout,FMT="('lim_rhg  :', I4, I6, I1, I1, A10)") 2000, numit, 0, 0, ' ch. ell. '
+            CALL prt_ctl_info(charout)
+         ENDIF
+      ENDIF
+
+   END SUBROUTINE lim_rhg
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module           NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_rhg( k1 , k2 )         ! Dummy routine
+      WRITE(*,*) 'lim_rhg: You should not have seen this print! error?', k1, k2
+   END SUBROUTINE lim_rhg
+#endif
+
+   !!==============================================================================
+END MODULE limrhg
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limrst.F90	(revision 1844)
@@ -0,0 +1,751 @@
+MODULE limrst
+   !!======================================================================
+   !!                     ***  MODULE  limrst  ***
+   !! Ice restart :  write the ice restart file
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                   LIM sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_rst_opn     : open ice restart file
+   !!   lim_rst_write   : write of the restart file 
+   !!   lim_rst_read    : read  the restart file 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE ice
+   USE par_ice
+   USE in_out_manager
+   USE dom_oce
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_rst_opn    ! routine called by icestep.F90
+   PUBLIC lim_rst_write  ! routine called by icestep.F90
+   PUBLIC lim_rst_read   ! routine called by iceinit.F90
+
+   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write 
+   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rst_opn( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_opn  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      !
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
+
+      ! to get better performances with NetCDF format:
+      ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1)
+      ! except if we write ice restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1
+      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+         IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+         ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out)
+         IF(lwp) THEN
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ice restart binary file: '//clname
+            CASE DEFAULT         ;   WRITE(numout,*) '             open ice restart NetCDF file: '//clname
+            END SELECT
+            IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN   
+               WRITE(numout,*)         '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
+            ELSE   ;   WRITE(numout,*) '             kt = '                         , kt,' date= ', ndastp
+            ENDIF
+         ENDIF
+
+         CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib )
+         lrst_ice = .TRUE.
+      ENDIF
+      !
+   END SUBROUTINE lim_rst_opn
+
+   SUBROUTINE lim_rst_write( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_write  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!
+      !!----------------------------------------------------------------------
+      ! Arguments :
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      ! Local variables :
+      REAL(wp), DIMENSION(jpi,jpj) :: z2d
+      INTEGER :: ji, jj, jk ,jl
+      INTEGER :: iter
+      CHARACTER(len=15) :: znam
+      CHARACTER(len=1)  :: zchar, zchar1
+      !!----------------------------------------------------------------------
+
+      iter = kt + nn_fsbc - 1   ! ice restarts are written at kt == nitrst - nn_fsbc + 1
+
+      IF( iter == nitrst ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_rst_write : write ice restart file  kt =', kt
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'         
+      ENDIF
+
+      ! Write in numriw (if iter == nitrst)
+      ! ------------------ 
+      !                                                                        ! calendar control
+      CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp) )      ! time-step 
+      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter , wp) )        ! date
+
+      ! Prognostic variables 
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'v_i'//'_htc'//zchar
+         z2d(:,:) = v_i(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'v_s'//'_htc'//zchar
+         z2d(:,:) = v_s(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'smv_i'//'_htc'//zchar
+         z2d(:,:) = smv_i(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'oa_i'//'_htc'//zchar
+         z2d(:,:) = oa_i(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'a_i'//'_htc'//zchar
+         z2d(:,:) = a_i(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 't_su'//'_htc'//zchar
+         z2d(:,:) = t_su(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+      END DO
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'tempt_sl1'//'_htc'//zchar
+         z2d(:,:) = e_s(:,:,1,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+      END DO
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         DO jk = 1, nlay_i 
+            WRITE(zchar1,'(I1)') jk
+            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = e_i(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         END DO
+      END DO
+
+      CALL iom_rstput( iter, nitrst, numriw, 'u_ice'     , u_ice      )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ice'     , v_ice      )
+      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq'     , fsbbq      )
+      CALL iom_rstput( iter, nitrst, numriw, 'stress1_i' , stress1_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'stress2_i' , stress2_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'stress12_i', stress12_i )
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'sxice'//'_htc'//zchar
+         z2d(:,:) = sxice(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syice'//'_htc'//zchar
+         z2d(:,:) = syice(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxice'//'_htc'//zchar
+         z2d(:,:) = sxxice(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syyice'//'_htc'//zchar
+         z2d(:,:) = syyice(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxyice'//'_htc'//zchar
+         z2d(:,:) = sxyice(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxsn'//'_htc'//zchar
+         z2d(:,:) = sxsn(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sysn'//'_htc'//zchar
+         z2d(:,:) = sysn(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxsn'//'_htc'//zchar
+         z2d(:,:) = sxxsn(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syysn'//'_htc'//zchar
+         z2d(:,:) = syysn(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxysn'//'_htc'//zchar
+         z2d(:,:) = sxysn(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxa'//'_htc'//zchar
+         z2d(:,:) = sxa(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sya'//'_htc'//zchar
+         z2d(:,:) = sya(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxa'//'_htc'//zchar
+         z2d(:,:) = sxxa(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syya'//'_htc'//zchar
+         z2d(:,:) = syya(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxya'//'_htc'//zchar
+         z2d(:,:) = sxya(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxc0'//'_htc'//zchar
+         z2d(:,:) = sxc0(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syc0'//'_htc'//zchar
+         z2d(:,:) = syc0(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxc0'//'_htc'//zchar
+         z2d(:,:) = sxxc0(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syyc0'//'_htc'//zchar
+         z2d(:,:) = syyc0(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxyc0'//'_htc'//zchar
+         z2d(:,:) = sxyc0(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxsal'//'_htc'//zchar
+         z2d(:,:) = sxsal(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sysal'//'_htc'//zchar
+         z2d(:,:) = sysal(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxsal'//'_htc'//zchar
+         z2d(:,:) = sxxsal(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syysal'//'_htc'//zchar
+         z2d(:,:) = syysal(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxysal'//'_htc'//zchar
+         z2d(:,:) = sxysal(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxage'//'_htc'//zchar
+         z2d(:,:) = sxage(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syage'//'_htc'//zchar
+         z2d(:,:) = syage(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxxage'//'_htc'//zchar
+         z2d(:,:) = sxxage(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'syyage'//'_htc'//zchar
+         z2d(:,:) = syyage(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         znam = 'sxyage'//'_htc'//zchar
+         z2d(:,:) = sxyage(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+      END DO
+
+      CALL iom_rstput( iter, nitrst, numriw, 'sxopw ' ,  sxopw  )
+      CALL iom_rstput( iter, nitrst, numriw, 'syopw ' ,  syopw  )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxopw' ,  sxxopw )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyopw' ,  syyopw )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyopw' ,  sxyopw )
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         DO jk = 1, nlay_i 
+            WRITE(zchar1,'(I1)') jk
+            znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = sxe(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            znam = 'sye'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = sye(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = sxxe(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            znam = 'syye'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = syye(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
+            z2d(:,:) = sxye(:,:,jk,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         END DO
+      END DO
+
+      IF( iter == nitrst ) THEN
+         CALL iom_close( numriw )                         ! close the restart file
+         lrst_ice = .FALSE.
+      ENDIF
+      !
+
+      IF( ln_nicep) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' lim_rst_write : CHUKCHI SEA POINT '
+         WRITE(numout,*) ' ~~~~~~~~~~'
+         WRITE(numout,*) ' ~~~ Arctic'
+
+         ji = jiindx
+         jj = jjindx
+
+         WRITE(numout,*) ' ji, jj ', ji, jj
+         WRITE(numout,*) ' ICE VARIABLES '
+         WRITE(numout,*) ' open water ', ato_i(ji,jj)
+         DO jl = 1, jpl
+            WRITE(numout,*) ' *** CATEGORY NUMBER *** ', jl
+            WRITE(numout,*) ' '
+            WRITE(numout,*) ' a_i        : ', a_i(ji,jj,jl)     
+            WRITE(numout,*) ' v_i        : ', v_i(ji,jj,jl) 
+            WRITE(numout,*) ' v_s        : ', v_s(ji,jj,jl)    
+            WRITE(numout,*) ' e_s        : ', e_s(ji,jj,1,jl)/1.0e9
+            WRITE(numout,*) ' e_i1       : ', e_i(ji,jj,1,jl)/1.0e9      
+            WRITE(numout,*) ' e_i2       : ', e_i(ji,jj,2,jl)/1.0e9      
+            WRITE(numout,*) ' smv_i      : ', smv_i(ji,jj,jl)  
+            WRITE(numout,*) ' oa_i       : ', oa_i(ji,jj,jl)
+            WRITE(numout,*) ' t_su       : ', t_su(ji,jj,jl)
+         END DO
+
+         WRITE(numout,*) ' MOMENTS OF ADVECTION '
+
+         WRITE(numout,*) ' open water '
+         WRITE(numout,*) ' sxopw  ', sxopw(ji,jj)
+         WRITE(numout,*) ' syopw  ', syopw(ji,jj)
+         WRITE(numout,*) ' sxxopw ', sxxopw(ji,jj)
+         WRITE(numout,*) ' syyopw ', syyopw(ji,jj)
+         WRITE(numout,*) ' sxyopw ', sxyopw(ji,jj)
+         DO jl = 1, jpl
+            WRITE(numout,*) ' jl, ice volume content ', jl
+            WRITE(numout,*) ' sxice  ', sxice(ji,jj,jl)
+            WRITE(numout,*) ' syice  ', syice(ji,jj,jl)
+            WRITE(numout,*) ' sxxice ', sxxice(ji,jj,jl)
+            WRITE(numout,*) ' syyice ', syyice(ji,jj,jl)
+            WRITE(numout,*) ' sxyice ', sxyice(ji,jj,jl)
+            WRITE(numout,*) ' jl, snow volume content ', jl
+            WRITE(numout,*) ' sxsn   ', sxsn(ji,jj,jl)
+            WRITE(numout,*) ' sysn   ', sysn(ji,jj,jl)
+            WRITE(numout,*) ' sxxsn  ', sxxsn(ji,jj,jl)
+            WRITE(numout,*) ' syysn  ', syysn(ji,jj,jl)
+            WRITE(numout,*) ' sxysn  ', sxysn(ji,jj,jl)
+            WRITE(numout,*) ' jl, ice area in category ', jl
+            WRITE(numout,*) ' sxa    ', sxa (ji,jj,jl)
+            WRITE(numout,*) ' sya    ', sya (ji,jj,jl)
+            WRITE(numout,*) ' sxxa   ', sxxa (ji,jj,jl)
+            WRITE(numout,*) ' syya   ', syya (ji,jj,jl)
+            WRITE(numout,*) ' sxya   ', sxya (ji,jj,jl)
+            WRITE(numout,*) ' jl, snow temp ', jl
+            WRITE(numout,*) ' sxc0   ', sxc0(ji,jj,jl)
+            WRITE(numout,*) ' syc0   ', syc0(ji,jj,jl)
+            WRITE(numout,*) ' sxxc0  ', sxxc0(ji,jj,jl)
+            WRITE(numout,*) ' syyc0  ', syyc0(ji,jj,jl)
+            WRITE(numout,*) ' sxyc0  ', sxyc0(ji,jj,jl)
+            WRITE(numout,*) ' jl, ice salinity ', jl
+            WRITE(numout,*) ' sxsal  ', sxsal(ji,jj,jl)
+            WRITE(numout,*) ' sysal  ', sysal(ji,jj,jl)
+            WRITE(numout,*) ' sxxsal ', sxxsal(ji,jj,jl)
+            WRITE(numout,*) ' syysal ', syysal(ji,jj,jl)
+            WRITE(numout,*) ' sxysal ', sxysal(ji,jj,jl)
+            WRITE(numout,*) ' jl, ice age      ', jl
+            WRITE(numout,*) ' sxage  ', sxage(ji,jj,jl)
+            WRITE(numout,*) ' syage  ', syage(ji,jj,jl)
+            WRITE(numout,*) ' sxxage ', sxxage(ji,jj,jl)
+            WRITE(numout,*) ' syyage ', syyage(ji,jj,jl)
+            WRITE(numout,*) ' sxyage ', sxyage(ji,jj,jl)
+         END DO
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               WRITE(numout,*) ' jk, jl, ice heat content', jk, jl
+               WRITE(numout,*) ' sxe    ', sxe(ji,jj,jk,jl)
+               WRITE(numout,*) ' sye    ', sye(ji,jj,jk,jl)
+               WRITE(numout,*) ' sxxe   ', sxxe(ji,jj,jk,jl)
+               WRITE(numout,*) ' syye   ', syye(ji,jj,jk,jl)
+               WRITE(numout,*) ' sxye   ', sxye(ji,jj,jk,jl)
+            END DO
+         END DO
+
+      ENDIF
+
+   END SUBROUTINE lim_rst_write
+
+   SUBROUTINE lim_rst_read
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_read  ***
+      !!
+      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
+      !!----------------------------------------------------------------------
+      ! Local variables
+      INTEGER :: ji, jj, jk, jl, indx
+      REAL(wp) ::   zfice, ziter
+      REAL(wp) :: & !parameters for the salinity profile
+         zs_inf, z_slope_s, zsmax, zsmin, zalpha, zindb
+      REAL(wp), DIMENSION(nlay_i) :: zs_zero 
+      REAL(wp), DIMENSION(jpi,jpj) :: z2d
+      CHARACTER(len=15) :: znam
+      CHARACTER(len=1)  :: zchar, zchar1
+      INTEGER           :: jlibalt = jprstlib
+      LOGICAL           :: llok
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_rst_read : read ice NetCDF restart file'
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+      ENDIF
+
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if {cn_icerst_in}.nc exists, then set jlibalt to jpnf90
+        INQUIRE( FILE = TRIM(cn_icerst_in)//'.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+      ENDIF
+
+      CALL iom_open ( cn_icerst_in, numrir, kiolib = jprstlib )
+
+      CALL iom_get( numrir, 'nn_fsbc', zfice )
+      CALL iom_get( numrir, 'kt_ice' , ziter )    
+      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
+      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
+
+      !Control of date
+
+      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
+         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
+         &                   '   verify the file or rerun with the value 0 for the',        &
+         &                   '   control of time parameter  nrstdt' )
+      IF( INT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
+         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
+         &                   '   verify the file or rerun with the value 0 for the',         &
+         &                   '   control of time parameter  nrstdt' )
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'v_i'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         v_i(:,:,jl) = z2d(:,:)
+         znam = 'v_s'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         v_s(:,:,jl) = z2d(:,:) 
+         znam = 'smv_i'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         smv_i(:,:,jl) = z2d(:,:)
+         znam = 'oa_i'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         oa_i(:,:,jl) = z2d(:,:)
+         znam = 'a_i'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         a_i(:,:,jl) = z2d(:,:)
+         znam = 't_su'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         t_su(:,:,jl) = z2d(:,:)
+      END DO
+
+      DO jl = 1, jpl 
+         CALL lbc_lnk( smv_i(:,:,jl) , 'T' ,  1. )
+         CALL lbc_lnk( v_i  (:,:,jl) , 'T' ,  1. )
+         CALL lbc_lnk( a_i  (:,:,jl) , 'T' ,  1. )
+      END DO
+
+      ! we first with bulk ice salinity
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zindb          = MAX( 0.0 , SIGN( 1.0 , v_i(ji,jj,jl) - 1.0e-4 ) ) 
+               sm_i(ji,jj,jl) = smv_i(ji,jj,jl) / MAX(v_i(ji,jj,jl),1.0e-6) * zindb
+               ht_i(ji,jj,jl) = v_i(ji,jj,jl)   / MAX(a_i(ji,jj,jl),1.0e-6) * zindb
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, nlay_i
+         s_i(:,:,jk,:) = sm_i(:,:,:)
+      END DO
+
+      ! Salinity profile
+      !-----------------
+      WRITE(numout,*) ' num_sal - will restart understand salinity profile ', num_sal
+
+      num_sal = 2
+      IF(num_sal.eq.2) THEN
+         !     CALL lim_var_salprof
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zs_inf        = sm_i(ji,jj,jl)
+                     z_slope_s     = 2.0*sm_i(ji,jj,jl)/MAX(0.01,ht_i(ji,jj,jl))
+                     !- slope of the salinity profile
+                     zs_zero(jk)   = z_slope_s * ( FLOAT(jk)-1.0/2.0 ) * &
+                        ht_i(ji,jj,jl) / FLOAT(nlay_i)
+                     zsmax = 4.5
+                     zsmin = 3.5
+                     IF( sm_i(ji,jj,jl) .LT. zsmin ) THEN
+                        zalpha = 1.0
+                     ELSEIF( sm_i(ji,jj,jl) .LT.zsmax ) THEN
+                        zalpha = sm_i(ji,jj,jl) / (zsmin-zsmax) + zsmax / (zsmax-zsmin)
+                     ELSE
+                        zalpha = 0.0
+                     ENDIF
+                     s_i(ji,jj,jk,jl) = zalpha*zs_zero(jk) + ( 1.0 - zalpha )*zs_inf
+                  END DO
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'tempt_sl1'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         e_s(:,:,1,jl) = z2d(:,:)
+      END DO
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         DO jk = 1, nlay_i 
+            WRITE(zchar1,'(I1)') jk
+            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            e_i(:,:,jk,jl) = z2d(:,:)
+         END DO
+      END DO
+
+      CALL iom_get( numrir, jpdom_autoglo, 'u_ice'     , u_ice      )
+      CALL iom_get( numrir, jpdom_autoglo, 'v_ice'     , v_ice      )
+      CALL iom_get( numrir, jpdom_autoglo, 'fsbbq'     , fsbbq      )
+      CALL iom_get( numrir, jpdom_autoglo, 'stress1_i' , stress1_i  )
+      CALL iom_get( numrir, jpdom_autoglo, 'stress2_i' , stress2_i  )
+      CALL iom_get( numrir, jpdom_autoglo, 'stress12_i', stress12_i )
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         znam = 'sxice'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxice(:,:,jl) = z2d(:,:)
+         znam = 'syice'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syice(:,:,jl) = z2d(:,:)
+         znam = 'sxxice'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxice(:,:,jl) = z2d(:,:)
+         znam = 'syyice'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syyice(:,:,jl) = z2d(:,:)
+         znam = 'sxyice'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxyice(:,:,jl) = z2d(:,:)
+         znam = 'sxsn'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxsn(:,:,jl) = z2d(:,:)
+         znam = 'sysn'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sysn(:,:,jl) = z2d(:,:)
+         znam = 'sxxsn'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxsn(:,:,jl) = z2d(:,:)
+         znam = 'syysn'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syysn(:,:,jl) = z2d(:,:)
+         znam = 'sxysn'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxysn(:,:,jl) = z2d(:,:)
+         znam = 'sxa'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxa(:,:,jl) = z2d(:,:)
+         znam = 'sya'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sya(:,:,jl) = z2d(:,:)
+         znam = 'sxxa'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxa(:,:,jl) = z2d(:,:)
+         znam = 'syya'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syya(:,:,jl) = z2d(:,:)
+         znam = 'sxya'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxya(:,:,jl) = z2d(:,:)
+         znam = 'sxc0'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxc0(:,:,jl) = z2d(:,:)
+         znam = 'syc0'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syc0(:,:,jl) = z2d(:,:)
+         znam = 'sxxc0'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxc0(:,:,jl) = z2d(:,:)
+         znam = 'syyc0'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syyc0(:,:,jl) = z2d(:,:)
+         znam = 'sxyc0'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxyc0(:,:,jl) = z2d(:,:)
+         znam = 'sxsal'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxsal(:,:,jl) = z2d(:,:)
+         znam = 'sysal'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sysal(:,:,jl) = z2d(:,:)
+         znam = 'sxxsal'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxsal(:,:,jl) = z2d(:,:)
+         znam = 'syysal'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syysal(:,:,jl) = z2d(:,:)
+         znam = 'sxysal'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxysal(:,:,jl) = z2d(:,:)
+         znam = 'sxage'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxage(:,:,jl) = z2d(:,:)
+         znam = 'syage'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syage(:,:,jl) = z2d(:,:)
+         znam = 'sxxage'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxxage(:,:,jl) = z2d(:,:)
+         znam = 'syyage'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         syyage(:,:,jl) = z2d(:,:)
+         znam = 'sxyage'//'_htc'//zchar
+         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+         sxyage(:,:,jl)= z2d(:,:)
+      END DO
+
+      CALL iom_get( numrir, jpdom_autoglo, 'sxopw ' ,  sxopw  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syopw ' ,  syopw  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxopw' ,  sxxopw )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyopw' ,  syyopw )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyopw' ,  sxyopw )
+
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I1)') jl
+         DO jk = 1, nlay_i 
+            WRITE(zchar1,'(I1)') jk
+            znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            sxe(:,:,jk,jl) = z2d(:,:)
+            znam = 'sye'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            sye(:,:,jk,jl) = z2d(:,:)
+            znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            sxxe(:,:,jk,jl) = z2d(:,:)
+            znam = 'syye'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            syye(:,:,jk,jl) = z2d(:,:)
+            znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            sxye(:,:,jk,jl) = z2d(:,:)
+         END DO
+      END DO
+
+      CALL iom_close( numrir )
+
+      !+++++++++++ CHECK EVERYTHING ++++++++++
+
+      WRITE(numout,*)
+      WRITE(numout,*) ' lim_rst_read  : CHUKCHI SEA POINT '
+      WRITE(numout,*) ' ~~~~~~~~~~'
+      WRITE(numout,*) ' ~~~ Arctic'
+
+      indx = 1
+      ji = 24
+      jj = 24
+      WRITE(numout,*) ' ji, jj ', ji, jj
+      WRITE(numout,*) ' ICE VARIABLES '
+      WRITE(numout,*) ' open water ', ato_i(ji,jj)
+
+      DO jl = 1, jpl
+         WRITE(numout,*) ' *** CATEGORY NUMBER *** ', jl
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' a_i        : ', a_i(ji,jj,jl)     
+         WRITE(numout,*) ' v_i        : ', v_i(ji,jj,jl) 
+         WRITE(numout,*) ' v_s        : ', v_s(ji,jj,jl)    
+         WRITE(numout,*) ' e_i1       : ', e_i(ji,jj,1,jl)/1.0e9      
+         WRITE(numout,*) ' e_i2       : ', e_i(ji,jj,2,jl)/1.0e9      
+         WRITE(numout,*) ' e_s        : ', e_s(ji,jj,1,jl)      
+         WRITE(numout,*) ' smv_i      : ', smv_i(ji,jj,jl)  
+         WRITE(numout,*) ' oa_i       : ', oa_i(ji,jj,jl)
+         WRITE(numout,*) ' t_su       : ', t_su(ji,jj,jl)
+      END DO
+
+      WRITE(numout,*) ' open water '
+      WRITE(numout,*) ' sxopw  ', sxopw(ji,jj)
+      WRITE(numout,*) ' syopw  ', syopw(ji,jj)
+      WRITE(numout,*) ' sxxopw ', sxxopw(ji,jj)
+      WRITE(numout,*) ' syyopw ', syyopw(ji,jj)
+      WRITE(numout,*) ' sxyopw ', sxyopw(ji,jj)
+      DO jl = 1, jpl
+         WRITE(numout,*) ' jl, ice volume content ', jl
+         WRITE(numout,*) ' sxice  ', sxice(ji,jj,jl)
+         WRITE(numout,*) ' syice  ', syice(ji,jj,jl)
+         WRITE(numout,*) ' sxxice ', sxxice(ji,jj,jl)
+         WRITE(numout,*) ' syyice ', syyice(ji,jj,jl)
+         WRITE(numout,*) ' sxyice ', sxyice(ji,jj,jl)
+         WRITE(numout,*) ' jl, snow volume content ', jl
+         WRITE(numout,*) ' sxsn   ', sxsn(ji,jj,jl)
+         WRITE(numout,*) ' sysn   ', sysn(ji,jj,jl)
+         WRITE(numout,*) ' sxxsn  ', sxxsn(ji,jj,jl)
+         WRITE(numout,*) ' syysn  ', syysn(ji,jj,jl)
+         WRITE(numout,*) ' sxysn  ', sxysn(ji,jj,jl)
+         WRITE(numout,*) ' jl, ice area in category ', jl
+         WRITE(numout,*) ' sxa    ', sxa (ji,jj,jl)
+         WRITE(numout,*) ' sya    ', sya (ji,jj,jl)
+         WRITE(numout,*) ' sxxa   ', sxxa (ji,jj,jl)
+         WRITE(numout,*) ' syya   ', syya (ji,jj,jl)
+         WRITE(numout,*) ' sxya   ', sxya (ji,jj,jl)
+         WRITE(numout,*) ' jl, snow temp ', jl
+         WRITE(numout,*) ' sxc0   ', sxc0(ji,jj,jl)
+         WRITE(numout,*) ' syc0   ', syc0(ji,jj,jl)
+         WRITE(numout,*) ' sxxc0  ', sxxc0(ji,jj,jl)
+         WRITE(numout,*) ' syyc0  ', syyc0(ji,jj,jl)
+         WRITE(numout,*) ' sxyc0  ', sxyc0(ji,jj,jl)
+         WRITE(numout,*) ' jl, ice salinity ', jl
+         WRITE(numout,*) ' sxsal  ', sxsal(ji,jj,jl)
+         WRITE(numout,*) ' sysal  ', sysal(ji,jj,jl)
+         WRITE(numout,*) ' sxxsal ', sxxsal(ji,jj,jl)
+         WRITE(numout,*) ' syysal ', syysal(ji,jj,jl)
+         WRITE(numout,*) ' sxysal ', sxysal(ji,jj,jl)
+         WRITE(numout,*) ' jl, ice age      ', jl
+         WRITE(numout,*) ' sxage  ', sxage(ji,jj,jl)
+         WRITE(numout,*) ' syage  ', syage(ji,jj,jl)
+         WRITE(numout,*) ' sxxage ', sxxage(ji,jj,jl)
+         WRITE(numout,*) ' syyage ', syyage(ji,jj,jl)
+         WRITE(numout,*) ' sxyage ', sxyage(ji,jj,jl)
+      END DO
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' jk, jl, ice heat content', jk, jl
+            WRITE(numout,*) ' sxe    ', sxe(ji,jj,jk,jl)
+            WRITE(numout,*) ' sye    ', sye(ji,jj,jk,jl)
+            WRITE(numout,*) ' sxxe   ', sxxe(ji,jj,jk,jl)
+            WRITE(numout,*) ' syye   ', syye(ji,jj,jk,jl)
+            WRITE(numout,*) ' sxye   ', sxye(ji,jj,jk,jl)
+         END DO
+      END DO
+
+      !+++++++++++ END CHECK +++++++++++++++++
+
+   END SUBROUTINE lim_rst_read
+
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :       Empty module            NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_rst_read             ! Empty routine
+   END SUBROUTINE lim_rst_read
+   SUBROUTINE lim_rst_write            ! Empty routine
+   END SUBROUTINE lim_rst_write
+#endif
+
+   !!======================================================================
+END MODULE limrst
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limsbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limsbc.F90	(revision 1844)
@@ -0,0 +1,458 @@
+MODULE limsbc
+   !!======================================================================
+   !!                       ***  MODULE limsbc   ***
+   !!           computation of the flux at the sea ice/ocean interface
+   !!======================================================================
+   !! History :   -   !  2006-07 (M. Vancoppelle)  LIM3 original code
+   !!            3.0  !  2008-03 (C. Tallandier)  surface module
+   !!             -   !  2008-04 (C. Tallandier)  split in 2 + new ice-ocean coupling
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                    LIM 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_sbc  : flux at the ice / ocean interface
+   !!----------------------------------------------------------------------
+   USE oce
+   USE par_oce          ! ocean parameters
+   USE par_ice          ! ice parameters
+   USE dom_oce          ! ocean domain
+   USE sbc_ice          ! Surface boundary condition: sea-ice fields
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE phycst           ! physical constants
+   USE ice              ! LIM sea-ice variables
+   USE iceini           ! ???
+
+   USE lbclnk           ! ocean lateral boundary condition
+   USE in_out_manager   ! I/O manager
+   USE albedo           ! albedo parameters
+   USE prtctl           ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_sbc_flx   ! called by sbc_ice_lim
+   PUBLIC   lim_sbc_tau   ! called by sbc_ice_lim
+
+   REAL(wp)  ::   epsi16 = 1.e-16  ! constant values
+   REAL(wp)  ::   rzero  = 0.e0    
+   REAL(wp)  ::   rone   = 1.e0
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   utau_oce, vtau_oce   !: air-ocean surface i- & j-stress              [N/m2]
+   REAL(wp), DIMENSION(jpi,jpj) ::   tmod_io              !: modulus of the ice-ocean relative velocity   [m/s]
+   REAL(wp), DIMENSION(jpi,jpj) ::   ssu_mb  , ssv_mb     !: before mean ocean surface currents           [m/s]
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM  3.2 ,  UCL-LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_sbc_tau( kt, kcpl )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_sbc_tau ***
+      !!  
+      !! ** Purpose : Update the ocean surface stresses due to the ice
+      !!         
+      !! ** Action  : - compute the ice-ocean stress depending on kcpl:
+      !!              fluxes at the ice-ocean interface.
+      !!     Case 0  :  old LIM-3 way, computed at ice time-step only
+      !!     Case 1  :  at each ocean time step the stresses are computed
+      !!                using the current ocean velocity (now)
+      !!     Case 2  :  combination of half case 0 + half case 1
+      !!     
+      !! ** Outputs : - utau   : sea surface i-stress (ocean referential)
+      !!              - vtau   : sea surface j-stress (ocean referential)
+      !!
+      !! References : Goosse, H. et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90.
+      !!              Tartinville et al. 2001 Ocean Modelling, 3, 95-108.
+      !!---------------------------------------------------------------------
+      INTEGER ::   kt     ! number of ocean iteration
+      INTEGER ::   kcpl   ! ice-ocean coupling indicator: =0  LIM-3 old case
+      !                   !                               =1  stresses computed using now ocean velocity
+      !                   !                               =2  combination of 0 and 1 cases
+      !!
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zfrldu, zat_u, zu_ico, zutaui, zu_u, zu_ij, zu_im1j   ! temporary scalar
+      REAL(wp) ::   zfrldv, zat_v, zv_ico, zvtaui, zv_v, zv_ij, zv_ijm1   !    -         -
+      REAL(wp) ::   zsang, zztmp                                          !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztio_u, ztio_v   ! ocean stress below sea-ice
+#if defined key_coupled    
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb     ! albedo of ice under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalbp    ! albedo of ice under clear sky
+#endif
+     !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_sbc_tau : LIM 3.0 sea-ice - surface ocean momentum fluxes'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1                         !* modulus of the ice-ocean velocity
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1
+               zu_ij   = u_ice(ji  ,jj) - ssu_m(ji  ,jj)               ! (i  ,j)
+               zu_im1j = u_ice(ji-1,jj) - ssu_m(ji-1,jj)               ! (i-1,j)
+               zv_ij   = v_ice(ji,jj  ) - ssv_m(ji,jj  )               ! (i,j  )
+               zv_ijm1 = v_ice(ji,jj-1) - ssv_m(ji,jj-1)               ! (i,j-1)
+               zztmp =  0.5 * ( zu_ij * zu_ij + zu_im1j * zu_im1j   &  ! mean of the square values instead
+                  &           + zv_ij * zv_ij + zv_ijm1 * zv_ijm1 )    ! of the square of the mean values...
+               ! WARNING, here we make an approximation for case 1 and 2: taum is not computed at each time
+               ! step but only every nn_fsbc time step. This avoid mutiple avarage to pass from T -> U,V grids
+               ! and next from U,V grids to T grid. Taum is used in tke, which should not be too sensitive to
+               ! this approximaton...
+               taum(ji,jj) = ( 1. - at_i(ji,jj) ) * taum(ji,jj) + at_i(ji,jj) * rhoco * zztmp
+               tmod_io(ji,jj) = SQRT( zztmp ) 
+            END DO
+         END DO
+         CALL lbc_lnk( taum, 'T', 1. )   ;   CALL lbc_lnk( tmod_io, 'T', 1. )
+      ENDIF
+
+      SELECT CASE( kcpl )
+         !                                        !--------------------------------!
+      CASE( 0 )                                   !  LIM 3 old stress computation  !  (at ice timestep only)
+         !                                        !--------------------------------! 
+         !                                             !* ice stress over ocean with a ice-ocean rotation angle
+         DO jj = 1, jpjm1
+            zsang  = SIGN( 1.e0, gphif(1,jj) ) * sangvg         ! change the sinus angle sign in the south hemisphere
+            DO ji = 1, fs_jpim1
+               zu_u = u_ice(ji,jj) - u_oce(ji,jj)               ! ice velocity relative to the ocean
+               zv_v = v_ice(ji,jj) - v_oce(ji,jj)
+               !                                                ! quadratic drag formulation with rotation
+!!gm still an error in the rotation, but usually the angle is zero (zsang=0, cangvg=1)
+               zutaui   = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji+1,jj) ) * rhoco * ( cangvg * zu_u - zsang * zv_v ) 
+               zvtaui   = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji,jj+1) ) * rhoco * ( cangvg * zv_v + zsang * zu_u ) 
+               !                                                ! bound for too large stress values
+               ! IMPORTANT: the exponential below prevents numerical oscillations in the ice-ocean stress
+               ! This is not physically based. A cleaner solution is offer in CASE kcpl=2
+               ztio_u(ji,jj) = zutaui * EXP( - ( tmod_io(ji,jj) + tmod_io(ji+1,jj) )  )
+               ztio_v(ji,jj) = zvtaui * EXP( - ( tmod_io(ji,jj) + tmod_io(ji,jj+1) )  ) 
+            END DO
+         END DO
+         DO jj = 2, jpjm1                                       ! stress at the surface of the ocean
+            DO ji = fs_2, fs_jpim1   ! vertor opt.
+               zfrldu = 0.5 * ( ato_i(ji,jj) + ato_i(ji+1,jj  ) )   ! open-ocean fraction at U- & V-points (from T-point values)
+               zfrldv = 0.5 * ( ato_i(ji,jj) + ato_i(ji  ,jj+1) )
+               !                                                    ! update surface ocean stress
+               utau(ji,jj) = zfrldu * utau(ji,jj) + ( 1. - zfrldu ) * ztio_u(ji,jj)
+               vtau(ji,jj) = zfrldv * vtau(ji,jj) + ( 1. - zfrldv ) * ztio_v(ji,jj)
+            END DO
+         END DO
+         CALL lbc_lnk( utau, 'U', -1. )   ;   CALL lbc_lnk( vtau, 'V', -1. )   ! lateral boundary condition
+
+         !
+         !                                        !--------------------------------!
+      CASE( 1 )                                   !  Use the now velocity          !  (at each ocean timestep)
+         !                                        !--------------------------------! 
+         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+            utau_oce(:,:) = utau(:,:)                 !* save the air-ocean stresses at ice time-step
+            vtau_oce(:,:) = vtau(:,:)
+         ENDIF
+         !
+        DO jj = 2, jpjm1                              !* ice stress over ocean with a ice-ocean rotation angle
+            zsang  = SIGN(1.e0, gphif(1,jj-1) ) * sangvg        ! change the sinus angle sign in the south hemisphere
+            DO ji = fs_2, fs_jpim1
+               zat_u  = ( at_i(ji,jj) + at_i(ji+1,jj) ) * 0.5   ! ice area at u and V-points
+               zat_v  = ( at_i(ji,jj) + at_i(ji,jj+1) ) * 0.5
+               !                                                ! (u,v) ice-ocean velocity at (U,V)-point, resp.
+               zu_u   = u_ice(ji,jj) - ub(ji,jj,1)
+               zv_v   = v_ice(ji,jj) - vb(ji,jj,1)
+               !                                                ! quadratic drag formulation with rotation
+!!gm still an error in the rotation, but usually the angle is zero (zsang=0, cangvg=1)
+               zutaui   = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji+1,jj) ) * rhoco * ( cangvg * zu_u - zsang * zv_v ) 
+               zvtaui   = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji,jj+1) ) * rhoco * ( cangvg * zv_v + zsang * zu_u ) 
+               !                                                   ! stress at the ocean surface
+               utau(ji,jj) = ( 1.- zat_u ) * utau_oce(ji,jj) + zat_u * zutaui
+               vtau(ji,jj) = ( 1.- zat_v ) * vtau_oce(ji,jj) + zat_v * zvtaui
+            END DO
+         END DO
+         CALL lbc_lnk( utau, 'U', -1. )   ;   CALL lbc_lnk( vtau, 'V', -1. )   ! lateral boundary condition
+
+         !
+         !                                        !--------------------------------!
+      CASE( 2 )                                   !  mixed 0 and 2 cases           !  (at each ocean timestep)
+         !                                        !--------------------------------! 
+         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+            utau_oce(:,:) = utau (:,:)               !* save the air-ocean stresses at ice time-step
+            vtau_oce(:,:) = vtau (:,:)
+            ssu_mb  (:,:) = ssu_m(:,:)               !* save the ice-ocean velocity at ice time-step
+            ssv_mb  (:,:) = ssv_m(:,:)
+         ENDIF
+         DO jj = 2, jpjm1                            !* ice stress over ocean with a ice-ocean rotation angle
+            zsang  = SIGN(1.e0, gphif(1,jj-1) ) * sangvg
+            DO ji = fs_2, fs_jpim1
+               zat_u = ( at_i(ji,jj) + at_i(ji+1,jj) ) * 0.5     ! ice area at u and V-points
+               zat_v = ( at_i(ji,jj) + at_i(ji,jj+1) ) * 0.5 
+               !
+               zu_ico = u_ice(ji,jj) - 0.5 * ( ub(ji,jj,1) + ssu_mb(ji,jj) )   ! ice-oce velocity using ub and ssu_mb
+               zv_ico = v_ice(ji,jj) - 0.5 * ( vb(ji,jj,1) + ssv_mb(ji,jj) )
+               !                                        ! quadratic drag formulation with rotation
+!!gm still an error in the rotation, but usually the angle is zero (zsang=0, cangvg=1)
+               zutaui = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji+1,jj) ) * rhoco * ( cangvg * zu_ico - zsang * zv_ico )
+               zvtaui = 0.5 * ( tmod_io(ji,jj) + tmod_io(ji,jj+1) ) * rhoco * ( cangvg * zv_ico + zsang * zu_ico )
+               !
+               utau(ji,jj) = ( 1.-zat_u ) * utau_oce(ji,jj) + zat_u * zutaui    ! stress at the ocean surface
+               vtau(ji,jj) = ( 1.-zat_v ) * vtau_oce(ji,jj) + zat_v * zvtaui
+            END DO
+         END DO
+         CALL lbc_lnk( utau, 'U', -1. )   ;   CALL lbc_lnk( vtau, 'V', -1. )   ! lateral boundary condition
+         !
+      END SELECT
+
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=utau, clinfo1=' lim_sbc: utau   : ', mask1=umask,   &
+         &                       tab2d_2=vtau, clinfo2=' vtau    : '        , mask2=vmask )
+      !  
+   END SUBROUTINE lim_sbc_tau
+
+
+   SUBROUTINE lim_sbc_flx( kt )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_sbc_flx ***
+      !!  
+      !! ** Purpose :   Update the surface ocean boundary condition for heat 
+      !!              salt and mass over areas where sea-ice is non-zero
+      !!         
+      !! ** Action  : - computes the heat and freshwater/salt fluxes
+      !!              at the ice-ocean interface.
+      !!              - Update the ocean sbc
+      !!     
+      !! ** Outputs : - qsr     : sea heat flux:     solar 
+      !!              - qns     : sea heat flux: non solar
+      !!              - emp     : freshwater budget: volume flux 
+      !!              - emps    : freshwater budget: concentration/dillution 
+      !!              - fr_i    : ice fraction
+      !!              - tn_ice  : sea-ice surface temperature
+      !!              - alb_ice : sea-ice alberdo (lk_cpl=T)
+      !!
+      !! References : Goosse, H. et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90.
+      !!              Tartinville et al. 2001 Ocean Modelling, 3, 95-108.
+      !!---------------------------------------------------------------------
+      INTEGER ::   kt    ! number of iteration
+      !!
+      INTEGER  ::   ji, jj           ! dummy loop indices
+      INTEGER  ::   ifvt, i1mfr, idfr               ! some switches
+      INTEGER  ::   iflt, ial, iadv, ifral, ifrdv
+      REAL(wp) ::   zinda            ! switch for testing the values of ice concentration
+      REAL(wp) ::   zfons            ! salt exchanges at the ice/ocean interface
+      REAL(wp) ::   zpme             ! freshwater exchanges at the ice/ocean interface
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfcm1 , zfcm2    ! solar/non solar heat fluxes
+#if defined key_coupled    
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb     ! albedo of ice under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalbp    ! albedo of ice under clear sky
+#endif
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_sbc_flx : LIM 3.0 sea-ice - heat salt and mass ocean surface fluxes'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+
+      !------------------------------------------!
+      !      heat flux at the ocean surface      !
+      !------------------------------------------!
+      ! pfrld is the lead fraction at the previous time step (actually between TRP and THD)
+      ! changed to old_frld and old ht_i
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zinda   = 1.0 - MAX( rzero , SIGN( rone , - ( 1.0 - pfrld(ji,jj) ) ) )
+            ifvt    = zinda  *  MAX( rzero , SIGN( rone, -phicif  (ji,jj) ) )  !subscripts are bad here
+            i1mfr   = 1.0 - MAX( rzero , SIGN( rone ,  - ( at_i(ji,jj)       ) ) )
+            idfr    = 1.0 - MAX( rzero , SIGN( rone , ( 1.0 - at_i(ji,jj) ) - pfrld(ji,jj) ) )
+            iflt    = zinda  * (1 - i1mfr) * (1 - ifvt )
+            ial     = ifvt   * i1mfr + ( 1 - ifvt ) * idfr
+            iadv    = ( 1  - i1mfr ) * zinda
+            ifral   = ( 1  - i1mfr * ( 1 - ial ) )   
+            ifrdv   = ( 1  - ifral * ( 1 - ial ) ) * iadv 
+
+            ! switch --- 1.0 ---------------- 0.0 --------------------
+            ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+            ! zinda   | if pfrld = 1       | if pfrld < 1            |
+            !  -> ifvt| if pfrld old_ht_i
+            ! i1mfr   | if frld = 1        | if frld  < 1            |
+            ! idfr    | if frld <= pfrld    | if frld > pfrld        |
+            ! iflt    | 
+            ! ial     |
+            ! iadv    |
+            ! ifral
+            ! ifrdv
+
+            !   computation the solar flux at ocean surface
+            zfcm1(ji,jj)   = pfrld(ji,jj) * qsr(ji,jj)  + ( 1. - pfrld(ji,jj) ) * fstric(ji,jj)
+            ! fstric     Solar flux transmitted trough the ice
+            ! qsr        Net short wave heat flux on free ocean
+            ! new line
+            fscmbq(ji,jj) = ( 1.0 - pfrld(ji,jj) ) * fstric(ji,jj)
+
+            !  computation the non solar heat flux at ocean surface
+            zfcm2(ji,jj) = - zfcm1(ji,jj)                  &
+               &           + iflt    * ( fscmbq(ji,jj) )   & ! total abl -> fscmbq is given to the ocean
+               ! fscmbq and ffltbif are obsolete
+               !              &           + iflt * ffltbif(ji,jj) !!! only if one category is used
+               &           + ifral   * ( ial * qcmif(ji,jj) + (1 - ial) * qldif(ji,jj) ) / rdt_ice   &
+               &           + ifrdv   * ( qfvbq(ji,jj) + qdtcn(ji,jj) ) / rdt_ice                     &
+               &           + fhmec(ji,jj)     & ! new contribution due to snow melt in ridging!!
+               &           + fheat_rpo(ji,jj) & ! contribution from ridge formation
+               &           + fheat_res(ji,jj)
+            ! fscmbq  Part of the solar radiation transmitted through the ice and going to the ocean
+            !         computed in limthd_zdf.F90
+            ! ffltbif Total heat content of the ice (brine pockets+ice) / delta_t
+            ! qcmif   Energy needed to bring the ocean surface layer until its freezing (ok)
+            ! qldif   heat balance of the lead (or of the open ocean)
+            ! qfvbq   i think this is wrong!
+            ! ---> Array used to store energy in case of total lateral ablation
+            ! qfvbq latent heat uptake/release after accretion/ablation
+            ! qdtcn Energy from the turbulent oceanic heat flux heat flux coming in the lead
+
+            IF ( num_sal .EQ. 2 ) zfcm2(ji,jj) = zfcm2(ji,jj) + &
+               fhbri(ji,jj) ! new contribution due to brine drainage 
+
+            ! bottom radiative component is sent to the computation of the
+            ! oceanic heat flux
+            fsbbq(ji,jj) = ( 1.0 - ( ifvt + iflt ) ) * fscmbq(ji,jj)     
+
+            ! used to compute the oceanic heat flux at the next time step
+            qsr(ji,jj) = zfcm1(ji,jj)                                       ! solar heat flux 
+            qns(ji,jj) = zfcm2(ji,jj) - fdtcn(ji,jj)                        ! non solar heat flux
+            !                           ! fdtcn : turbulent oceanic heat flux
+
+            !!gm   this IF prevents the vertorisation of the whole loop
+            IF ( ( ji .EQ. jiindx ) .AND. ( jj .EQ. jjindx) ) THEN
+               WRITE(numout,*) ' lim_sbc : heat fluxes '
+               WRITE(numout,*) ' qsr       : ', qsr(jiindx,jjindx)
+               WRITE(numout,*) ' zfcm1     : ', zfcm1(jiindx,jjindx)
+               WRITE(numout,*) ' pfrld     : ', pfrld(jiindx,jjindx)
+               WRITE(numout,*) ' fstric    : ', fstric (jiindx,jjindx)
+               WRITE(numout,*)
+               WRITE(numout,*) ' qns       : ', qns(jiindx,jjindx)
+               WRITE(numout,*) ' zfcm2     : ', zfcm2(jiindx,jjindx)
+               WRITE(numout,*) ' zfcm1     : ', zfcm1(jiindx,jjindx)
+               WRITE(numout,*) ' ifral     : ', ifral
+               WRITE(numout,*) ' ial       : ', ial  
+               WRITE(numout,*) ' qcmif     : ', qcmif(jiindx,jjindx)
+               WRITE(numout,*) ' qldif     : ', qldif(jiindx,jjindx)
+               WRITE(numout,*) ' qcmif / dt: ', qcmif(jiindx,jjindx) / rdt_ice
+               WRITE(numout,*) ' qldif / dt: ', qldif(jiindx,jjindx) / rdt_ice
+               WRITE(numout,*) ' ifrdv     : ', ifrdv
+               WRITE(numout,*) ' qfvbq     : ', qfvbq(jiindx,jjindx)
+               WRITE(numout,*) ' qdtcn     : ', qdtcn(jiindx,jjindx)
+               WRITE(numout,*) ' qfvbq / dt: ', qfvbq(jiindx,jjindx) / rdt_ice
+               WRITE(numout,*) ' qdtcn / dt: ', qdtcn(jiindx,jjindx) / rdt_ice
+               WRITE(numout,*) ' '
+               WRITE(numout,*) ' fdtcn     : ', fdtcn(jiindx,jjindx)
+               WRITE(numout,*) ' fhmec     : ', fhmec(jiindx,jjindx)
+               WRITE(numout,*) ' fheat_rpo : ', fheat_rpo(jiindx,jjindx)
+               WRITE(numout,*) ' fhbri     : ', fhbri(jiindx,jjindx)
+               WRITE(numout,*) ' fheat_res : ', fheat_res(jiindx,jjindx)
+            ENDIF
+            !!gm   end
+         END DO
+      END DO
+
+      !------------------------------------------!
+      !      mass flux at the ocean surface      !
+      !------------------------------------------!
+
+!!gm   optimisation: this loop have to be merged with the previous one
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !  case of realistic freshwater flux (Tartinville et al., 2001) (presently ACTIVATED)
+            !  ------------------------------------------------------------------------------------- 
+            !  The idea of this approach is that the system that we consider is the ICE-OCEAN system
+            !  Thus  FW  flux  =  External ( E-P+snow melt)
+            !       Salt flux  =  Exchanges in the ice-ocean system then converted into FW
+            !                     Associated to Ice formation AND Ice melting
+            !                     Even if i see Ice melting as a FW and SALT flux
+            !        
+
+            !  computing freshwater exchanges at the ice/ocean interface
+            zpme = - emp(ji,jj)     * ( 1.0 - at_i(ji,jj) )  &   !  evaporation over oceanic fraction
+               &   + tprecip(ji,jj) *         at_i(ji,jj)    &   !  total precipitation
+               ! old fashioned way               
+               !              &   - sprecip(ji,jj) * ( 1. - pfrld(ji,jj) )  &   !  remov. snow precip over ice
+               &   - sprecip(ji,jj) * ( 1. - (pfrld(ji,jj)**betas) )  &   !  remov. snow precip over ice
+               &   - rdmsnif(ji,jj) / rdt_ice                &   !  freshwaterflux due to snow melting 
+               ! new contribution from snow falling when ridging
+               &   + fmmec(ji,jj)
+
+            !  computing salt exchanges at the ice/ocean interface
+            !  sice should be the same as computed with the ice model
+            zfons =  ( soce - sice ) * ( rdmicif(ji,jj) / rdt_ice ) 
+            ! SOCE
+            zfons =  ( sss_m(ji,jj) - sice ) * ( rdmicif(ji,jj) / rdt_ice ) 
+
+            !CT useless            !  salt flux for constant salinity
+            !CT useless            fsalt(ji,jj)      =  zfons / ( sss_m(ji,jj) + epsi16 ) + fsalt_res(ji,jj)
+            !  salt flux for variable salinity
+            zinda             = 1.0 - MAX( rzero , SIGN( rone , - ( 1.0 - pfrld(ji,jj) ) ) )
+            !  correcting brine and salt fluxes
+            fsbri(ji,jj)      =  zinda*fsbri(ji,jj)
+            !  converting the salt fluxes from ice to a freshwater flux from ocean
+            fsalt_res(ji,jj)  =  fsalt_res(ji,jj) / ( sss_m(ji,jj) + epsi16 )
+            fseqv(ji,jj)      =  fseqv(ji,jj)     / ( sss_m(ji,jj) + epsi16 )
+            fsbri(ji,jj)      =  fsbri(ji,jj)     / ( sss_m(ji,jj) + epsi16 )
+            fsalt_rpo(ji,jj)  =  fsalt_rpo(ji,jj) / ( sss_m(ji,jj) + epsi16 )
+
+            !  freshwater mass exchange (positive to the ice, negative for the ocean ?)
+            !  actually it's a salt flux (so it's minus freshwater flux)
+            !  if sea ice grows, zfons is positive, fsalt also
+            !  POSITIVE SALT FLUX FROM THE ICE TO THE OCEAN
+            !  POSITIVE FRESHWATER FLUX FROM THE OCEAN TO THE ICE [kg.m-2.s-1]
+
+            emp(ji,jj) = - zpme 
+         END DO
+      END DO
+
+      IF( num_sal == 2 ) THEN      ! variable ice salinity: brine drainage included in the salt flux
+         emps(:,:) = fsbri(:,:) + fseqv(:,:) + fsalt_res(:,:) + fsalt_rpo(:,:) + emp(:,:)
+      ELSE                         ! constant ice salinity:
+         emps(:,:) =              fseqv(:,:) + fsalt_res(:,:) + fsalt_rpo(:,:) + emp(:,:)
+      ENDIF
+
+      !-----------------------------------------------!
+      !   Storing the transmitted variables           !
+      !-----------------------------------------------!
+
+      fr_i  (:,:)   = at_i(:,:)             ! Sea-ice fraction            
+      tn_ice(:,:,:) = t_su(:,:,:)           ! Ice surface temperature                      
+
+#if defined key_coupled            
+      !------------------------------------------------!
+      !    Computation of snow/ice and ocean albedo    !
+      !------------------------------------------------!
+      zalb  (:,:,:) = 0.e0
+      zalbp (:,:,:) = 0.e0
+
+      CALL albedo_ice( t_su, ht_i, ht_s, zalbp, zalb )
+
+      alb_ice(:,:,:) =  0.5 * zalbp(:,:,:) + 0.5 * zalb (:,:,:)   ! Ice albedo (mean clear and overcast skys)
+#endif
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl( tab2d_1=qsr   , clinfo1=' lim_sbc: qsr    : ', tab2d_2=qns , clinfo2=' qns     : ' )
+         CALL prt_ctl( tab2d_1=emp   , clinfo1=' lim_sbc: emp    : ', tab2d_2=emps, clinfo2=' emps    : ' )
+         CALL prt_ctl( tab2d_1=fr_i  , clinfo1=' lim_sbc: fr_i   : ' )
+         CALL prt_ctl( tab3d_1=tn_ice, clinfo1=' lim_sbc: tn_ice : ', kdim=jpl )
+      ENDIF
+      ! 
+   END SUBROUTINE lim_sbc_flx
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Dummy module       NO LIM 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_sbc           ! Dummy routine
+   END SUBROUTINE lim_sbc
+#endif 
+
+   !!======================================================================
+END MODULE limsbc
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtab.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtab.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtab.F90	(revision 1844)
@@ -0,0 +1,82 @@
+MODULE limtab
+   !!======================================================================
+   !!                       ***  MODULE limtab   ***
+   !!              transform 1D (2D) array to a 2D (1D) table
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   tab_2d_1d  : 2-D to 1-D
+   !!   tab_1d_2d  : 1-D to 2-D
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tab_2d_1d  ! called by lim_ther
+   PUBLIC tab_1d_2d  ! called by lim_ther
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tab_2d_1d ( ndim1d, tab1d, tab2d, ndim2d_x, ndim2d_y, tab_ind )
+
+      INTEGER, INTENT(in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT(in) ::  &
+         tab2d
+
+      INTEGER, DIMENSION ( ndim1d), INTENT ( in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT ( out) ::  & 
+         tab1d
+
+      INTEGER ::  &
+         jn , jid, jjd
+
+      DO jn = 1, ndim1d
+         jid        = MOD( tab_ind(jn) - 1, ndim2d_x ) + 1
+         jjd        = ( tab_ind(jn) - 1 ) / ndim2d_x + 1
+         tab1d( jn) = tab2d( jid, jjd)
+      END DO
+
+   END SUBROUTINE tab_2d_1d
+
+
+   SUBROUTINE tab_1d_2d ( ndim1d, tab2d, tab_ind, tab1d, ndim2d_x, ndim2d_y )
+
+      INTEGER, INTENT ( in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      INTEGER, DIMENSION (ndim1d) , INTENT (in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT (in) ::  &
+         tab1d  
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT ( out) :: &
+         tab2d
+
+      INTEGER :: &
+         jn, jid, jjd
+
+      DO jn = 1, ndim1d
+         jid             = MOD( tab_ind(jn) - 1, ndim2d_x) + 1
+         jjd             =    ( tab_ind(jn) - 1 ) / ndim2d_x  + 1
+         tab2d(jid, jjd) = tab1d( jn)
+      END DO
+
+   END SUBROUTINE tab_1d_2d
+
+#endif
+END MODULE limtab
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd.F90	(revision 1844)
@@ -0,0 +1,909 @@
+MODULE limthd
+   !!======================================================================
+   !!                  ***  MODULE limthd   ***
+   !!  LIM-3 :   ice thermodynamic
+   !!======================================================================
+   !! History :  LIM  ! 2000-01 (M.A. Morales Maqueda, H. Goosse, T. Fichefet) LIM-1
+   !!            2.0  ! 2002-07 (C. Ethe, G. Madec)  LIM-2 (F90 rewriting)
+   !!            3.0  ! 2005-11 (M. Vancoppenolle)  LIM-3 : Multi-layer thermodynamics + salinity variations
+   !!             -   ! 2007-04 (M. Vancoppenolle) add lim_thd_glohec and lim_thd_con_dif
+   !!            3.2  ! 2009-07 (M. Vancoppenolle, Y. Aksenov, G. Madec) bug correction in rdmsnif
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_thd      : thermodynamic of sea ice
+   !!   lim_thd_init : initialisation of sea-ice thermodynamic
+   !!----------------------------------------------------------------------
+   USE phycst          ! physical constants
+   USE dom_oce         ! ocean space and time domain variables
+   USE ice             ! LIM sea-ice variables
+   USE par_ice
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE thd_ice         ! LIM thermodynamic sea-ice variables
+   USE dom_ice         ! LIM sea-ice domain
+   USE domvvl
+   USE iceini
+   USE limthd_dif
+   USE limthd_dh
+   USE limthd_sal
+   USE limthd_ent
+   USE limtab
+   USE limvar
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+   USE lbclnk
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_thd    ! called by lim_step
+
+   REAL(wp) ::   epsi20 = 1e-20   ! constant values
+   REAL(wp) ::   epsi16 = 1e-16   !
+   REAL(wp) ::   epsi06 = 1e-06   !
+   REAL(wp) ::   epsi04 = 1e-04   !
+   REAL(wp) ::   zzero  = 0.e0    !
+   REAL(wp) ::   zone   = 1.e0    !
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM  3.2 ,  UCL-LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd( kt )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd  ***       
+      !!  
+      !! ** Purpose : This routine manages the ice thermodynamic.
+      !!         
+      !! ** Action : - Initialisation of some variables
+      !!             - Some preliminary computation (oceanic heat flux
+      !!               at the ice base, snow acc.,heat budget of the leads)
+      !!             - selection of the icy points and put them in an array
+      !!             - call lim_vert_ther for vert ice thermodynamic
+      !!             - back to the geographic grid
+      !!             - selection of points for lateral accretion
+      !!             - call lim_lat_acc  for the ice accretion
+      !!             - back to the geographic grid
+      !!     
+      !! ** References : H. Goosse et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt    ! number of iteration
+      !!
+      INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
+      INTEGER  ::   nbpb             ! nb of icy pts for thermo. cal.
+      REAL(wp) ::   zfric_umin = 5e-03    ! lower bound for the friction velocity
+      REAL(wp) ::   zfric_umax = 2e-02    ! upper bound for the friction velocity
+      REAL(wp) ::   zinda, zindb, zthsnice, zfric_u    ! temporary scalar
+      REAL(wp) ::   zfnsol, zfontn, zfntlat, zpareff   !    -         -
+      REAL(wp) ::   zeps, zareamin, zcoef
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqlbsbq   ! link with lead energy budget qldif
+      !!-------------------------------------------------------------------
+
+      IF( numit == nstart )   CALL lim_thd_init      ! Initialization (first time-step only)
+
+      IF( numit == nstart )   CALL lim_thd_sal_init  ! Initialization (first time-step only)
+      
+      !------------------------------------------------------------------------------!
+      ! 1) Initialization of diagnostic variables                                    !
+      !------------------------------------------------------------------------------!
+      zeps = 1.e-10
+
+      !--------------------
+      ! 1.2) Heat content    
+      !--------------------
+      ! Change the units of heat content; from global units to J.m3
+
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  !Energy of melting q(S,T) [J.m-3]
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / ( area(ji,jj) * MAX( v_i(ji,jj,jl) , epsi06 ) ) * nlay_i
+                  !0 if no ice and 1 if yes
+                  zindb = 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - ht_i(ji,jj,jl) ) ) 
+                  !convert units ! very important that this line is here
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * unit_fac * zindb 
+               END DO
+            END DO
+         END DO
+         DO jk = 1, nlay_s
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  !Energy of melting q(S,T) [J.m-3]
+                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) / ( area(ji,jj) * MAX( v_s(ji,jj,jl) , epsi06 ) ) * nlay_s
+                  !0 if no ice and 1 if yes
+                  zindb = 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - ht_s(ji,jj,jl) ) ) 
+                  !convert units ! very important that this line is here
+                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * unit_fac * zindb 
+               END DO
+            END DO
+         END DO
+      END DO
+
+      !-----------------------------
+      ! 1.3) Set some dummies to 0
+      !-----------------------------
+      rdvosif(:,:) = 0.e0   ! variation of ice volume at surface
+      rdvobif(:,:) = 0.e0   ! variation of ice volume at bottom
+      fdvolif(:,:) = 0.e0   ! total variation of ice volume
+      rdvonif(:,:) = 0.e0   ! lateral variation of ice volume
+      fstric (:,:) = 0.e0   ! part of solar radiation transmitted through the ice
+      ffltbif(:,:) = 0.e0   ! linked with fstric
+      qfvbq  (:,:) = 0.e0   ! linked with fstric
+      rdmsnif(:,:) = 0.e0   ! variation of snow mass per unit area
+      rdmicif(:,:) = 0.e0   ! variation of ice mass per unit area
+      hicifp (:,:) = 0.e0   ! daily thermodynamic ice production. 
+      fsbri  (:,:) = 0.e0   ! brine flux contribution to salt flux to the ocean
+      fhbri  (:,:) = 0.e0   ! brine flux contribution to heat flux to the ocean
+      fseqv  (:,:) = 0.e0   ! equivalent salt flux to the ocean due to ice/growth decay
+
+      !-----------------------------------
+      ! 1.4) Compute global heat content
+      !-----------------------------------
+      qt_i_in  (:,:) = 0.e0
+      qt_s_in  (:,:) = 0.e0
+      qt_i_fin (:,:) = 0.e0
+      qt_s_fin (:,:) = 0.e0
+      sum_fluxq(:,:) = 0.e0
+      fatm     (:,:) = 0.e0
+
+      ! 2) Partial computation of forcing for the thermodynamic sea ice model.      !
+      !-----------------------------------------------------------------------------!
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            zthsnice       = SUM( ht_s(ji,jj,1:jpl) ) + SUM( ht_i(ji,jj,1:jpl) )
+            zindb          = tms(ji,jj) * ( 1.0 - MAX( zzero , SIGN( zone , - zthsnice ) ) ) 
+            phicif(ji,jj)  = vt_i(ji,jj)
+            pfrld(ji,jj)   = 1.0 - at_i(ji,jj)
+            zinda          = 1.0 - MAX( zzero , SIGN( zone , - ( 1.0 - pfrld(ji,jj) ) ) )
+
+            !           !  solar irradiance transmission at the mixed layer bottom and used in the lead heat budget
+            !           !  practically no "direct lateral ablation"
+            !           
+            !           !  net downward heat flux from the ice to the ocean, expressed as a function of ocean 
+            !           !  temperature and turbulent mixing (McPhee, 1992)
+            ! friction velocity
+            zfric_u        = MAX ( MIN( SQRT( ust2s(ji,jj) ) , zfric_umax ) , zfric_umin ) 
+
+            ! here the drag will depend on ice thickness and type (0.006)
+            fdtcn(ji,jj)  = zindb * rau0 * rcp * 0.006  * zfric_u * ( (sst_m(ji,jj) + rt0) - t_bo(ji,jj) ) 
+            ! also category dependent
+            !           !-- Energy from the turbulent oceanic heat flux heat flux coming in the lead 
+            qdtcn(ji,jj)  = zindb * fdtcn(ji,jj) * (1.0 - at_i(ji,jj)) * rdt_ice
+            !                       
+
+            ! still need to be updated : fdtcn !!!!
+            !           !-- Lead heat budget (part 1, next one is in limthd_dh
+            !           !-- qldif -- (or qldif_1d in 1d routines)
+            zfontn         = sprecip(ji,jj) * lfus              ! energy of melting
+            zfnsol         = qns(ji,jj)                         ! total non solar flux
+            qldif(ji,jj)   = tms(ji,jj) * ( qsr(ji,jj)                               &
+               &                               + zfnsol + fdtcn(ji,jj) - zfontn      &
+               &                               + ( 1.0 - zindb ) * fsbbq(ji,jj)  )   &
+               &                               * ( 1.0 - at_i(ji,jj) ) * rdt_ice    
+
+            ! Positive heat budget is used for bottom ablation
+            zfntlat        = 1.0 - MAX( zzero , SIGN( zone ,  - qldif(ji,jj) ) )
+            != 1 if positive heat budget
+            zpareff        = 1.0 - zinda * zfntlat
+            != 0 if ice and positive heat budget and 1 if one of those two is false
+            zqlbsbq(ji,jj) = qldif(ji,jj) * ( 1.0 - zpareff ) / MAX( at_i(ji,jj) * rdt_ice , epsi16 )
+
+            ! Heat budget of the lead, energy transferred from ice to ocean
+            qldif  (ji,jj) = zpareff * qldif(ji,jj)
+            qdtcn  (ji,jj) = zpareff * qdtcn(ji,jj)
+
+            ! Energy needed to bring ocean surface layer until its freezing (qcmif, limflx)
+            qcmif  (ji,jj) =  rau0 * rcp * fse3t(ji,jj,1) * ( t_bo(ji,jj) - (sst_m(ji,jj) + rt0) ) * ( 1. - zinda )
+
+            ! oceanic heat flux (limthd_dh)
+            fbif   (ji,jj) = zindb * (  fsbbq(ji,jj) / MAX( at_i(ji,jj) , epsi20 ) + fdtcn(ji,jj) )
+            !
+         END DO
+      END DO
+
+      !------------------------------------------------------------------------------!
+      ! 3) Select icy points and fulfill arrays for the vectorial grid.            
+      !------------------------------------------------------------------------------!
+
+      DO jl = 1, jpl      !loop over ice categories
+
+         IF( kt == nit000 .AND. lwp ) THEN
+            WRITE(numout,*) ' lim_thd : transfer to 1D vectors. Category no : ', jl 
+            WRITE(numout,*) ' ~~~~~~~~'
+         ENDIF
+
+         zareamin = 1.0e-10
+         nbpb = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( a_i(ji,jj,jl) .gt. zareamin ) THEN     
+                  nbpb      = nbpb  + 1
+                  npb(nbpb) = (jj - 1) * jpi + ji
+               ENDIF
+               ! debug point to follow
+               IF ( (ji.eq.jiindx).AND.(jj.eq.jjindx) ) THEN
+                  jiindex_1d = nbpb
+               ENDIF
+            END DO
+         END DO
+
+         !------------------------------------------------------------------------------!
+         ! 4) Thermodynamic computation
+         !------------------------------------------------------------------------------!
+
+         IF( lk_mpp )   CALL mpp_ini_ice( nbpb )
+
+         IF( nbpb > 0 ) THEN  ! If there is no ice, do nothing.
+
+            !-------------------------
+            ! 4.1 Move to 1D arrays
+            !-------------------------
+
+            CALL tab_2d_1d( nbpb, at_i_b     (1:nbpb), at_i            , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, a_i_b      (1:nbpb), a_i(:,:,jl)     , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, ht_i_b     (1:nbpb), ht_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, ht_s_b     (1:nbpb), ht_s(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+
+            CALL tab_2d_1d( nbpb, t_su_b     (1:nbpb), t_su(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, sm_i_b     (1:nbpb), sm_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+            DO jk = 1, nlay_s
+               CALL tab_2d_1d( nbpb, t_s_b(1:nbpb,jk), t_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+               CALL tab_2d_1d( nbpb, q_s_b(1:nbpb,jk), e_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+            END DO
+            DO jk = 1, nlay_i
+               CALL tab_2d_1d( nbpb, t_i_b(1:nbpb,jk), t_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+               CALL tab_2d_1d( nbpb, q_i_b(1:nbpb,jk), e_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+               CALL tab_2d_1d( nbpb, s_i_b(1:nbpb,jk), s_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+            END DO
+
+            CALL tab_2d_1d( nbpb, tatm_ice_1d(1:nbpb), tatm_ice(:,:)   , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, qsr_ice_1d (1:nbpb), qsr_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, fr1_i0_1d  (1:nbpb), fr1_i0          , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, fr2_i0_1d  (1:nbpb), fr2_i0          , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, qnsr_ice_1d(1:nbpb), qns_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
+
+#if ! defined key_coupled
+            CALL tab_2d_1d( nbpb, qla_ice_1d (1:nbpb), qla_ice(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, dqla_ice_1d(1:nbpb), dqla_ice(:,:,jl)   , jpi, jpj, npb(1:nbpb) )
+#endif
+
+            CALL tab_2d_1d( nbpb, dqns_ice_1d(1:nbpb), dqns_ice(:,:,jl)   , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, t_bo_b     (1:nbpb), t_bo       , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, sprecip_1d (1:nbpb), sprecip    , jpi, jpj, npb(1:nbpb) ) 
+            CALL tab_2d_1d( nbpb, fbif_1d    (1:nbpb), fbif       , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, qldif_1d   (1:nbpb), qldif      , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, rdmicif_1d (1:nbpb), rdmicif    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, rdmsnif_1d (1:nbpb), rdmsnif    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, dmgwi_1d   (1:nbpb), dmgwi      , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, qlbbq_1d   (1:nbpb), zqlbsbq    , jpi, jpj, npb(1:nbpb) )
+
+            CALL tab_2d_1d( nbpb, fseqv_1d   (1:nbpb), fseqv      , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, fsbri_1d   (1:nbpb), fsbri      , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, fhbri_1d   (1:nbpb), fhbri      , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, fstbif_1d  (1:nbpb), fstric     , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nbpb, qfvbq_1d   (1:nbpb), qfvbq      , jpi, jpj, npb(1:nbpb) )
+
+            !--------------------------------
+            ! 4.3) Thermodynamic processes
+            !--------------------------------
+
+            IF( con_i )   CALL lim_thd_enmelt( 1, nbpb )   ! computes sea ice energy of melting
+            IF( con_i )   CALL lim_thd_glohec( qt_i_in, qt_s_in, q_i_layer_in, 1, nbpb, jl )
+
+            !                                 !---------------------------------!
+            CALL lim_thd_dif( 1, nbpb, jl )   ! Ice/Snow Temperature profile    !
+            !                                 !---------------------------------!
+
+            CALL lim_thd_enmelt( 1, nbpb )    ! computes sea ice energy of melting compulsory for limthd_dh
+
+            IF( con_i )   CALL lim_thd_glohec ( qt_i_fin, qt_s_fin, q_i_layer_fin, 1, nbpb, jl ) 
+            IF( con_i )   CALL lim_thd_con_dif( 1 , nbpb , jl )
+
+            !                                 !---------------------------------!
+            CALL lim_thd_dh( 1, nbpb, jl )    ! Ice/Snow thickness              ! 
+            !                                 !---------------------------------!
+
+            !                                 !---------------------------------!
+            CALL lim_thd_ent( 1, nbpb, jl )   ! Ice/Snow enthalpy remapping     !
+            !                                 !---------------------------------!
+
+            !                                 !---------------------------------!
+            CALL lim_thd_sal( 1, nbpb )       ! Ice salinity computation        !
+            !                                 !---------------------------------!
+
+            !           CALL lim_thd_enmelt(1,nbpb)   ! computes sea ice energy of melting
+            IF( con_i )   CALL lim_thd_glohec( qt_i_fin, qt_s_fin, q_i_layer_fin, 1, nbpb, jl ) 
+            IF( con_i )   CALL lim_thd_con_dh ( 1 , nbpb , jl )
+
+            !--------------------------------
+            ! 4.4) Move 1D to 2D vectors
+            !--------------------------------
+
+            CALL tab_1d_2d( nbpb, at_i        , npb, at_i_b(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, ht_i(:,:,jl), npb, ht_i_b(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, ht_s(:,:,jl), npb, ht_s_b(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, a_i (:,:,jl), npb, a_i_b(1:nbpb) , jpi, jpj )
+            CALL tab_1d_2d( nbpb, t_su(:,:,jl), npb, t_su_b(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, sm_i(:,:,jl), npb, sm_i_b(1:nbpb), jpi, jpj )
+
+            DO jk = 1, nlay_s
+               CALL tab_1d_2d( nbpb, t_s(:,:,jk,jl), npb, t_s_b(1:nbpb,jk), jpi, jpj)
+               CALL tab_1d_2d( nbpb, e_s(:,:,jk,jl), npb, q_s_b(1:nbpb,jk), jpi, jpj)
+            END DO
+
+            DO jk = 1, nlay_i
+               CALL tab_1d_2d( nbpb, t_i(:,:,jk,jl), npb, t_i_b(1:nbpb,jk), jpi, jpj)
+               CALL tab_1d_2d( nbpb, e_i(:,:,jk,jl), npb, q_i_b(1:nbpb,jk), jpi, jpj)
+               CALL tab_1d_2d( nbpb, s_i(:,:,jk,jl), npb, s_i_b(1:nbpb,jk), jpi, jpj)
+            END DO
+
+            CALL tab_1d_2d( nbpb, fstric , npb, fstbif_1d (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, qldif  , npb, qldif_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, qfvbq  , npb, qfvbq_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, rdmicif, npb, rdmicif_1d(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, rdmsnif, npb, rdmsnif_1d(1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, dmgwi  , npb, dmgwi_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, rdvosif, npb, dvsbq_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, rdvobif, npb, dvbbq_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, fdvolif, npb, dvlbq_1d  (1:nbpb), jpi, jpj )
+            CALL tab_1d_2d( nbpb, rdvonif, npb, dvnbq_1d  (1:nbpb), jpi, jpj ) 
+            CALL tab_1d_2d( nbpb, fseqv  , npb, fseqv_1d  (1:nbpb), jpi, jpj )
+
+            IF( num_sal == 2 ) THEN
+               CALL tab_1d_2d( nbpb, fsbri, npb, fsbri_1d(1:nbpb), jpi, jpj )
+               CALL tab_1d_2d( nbpb, fhbri, npb, fhbri_1d(1:nbpb), jpi, jpj )
+            ENDIF
+
+            !+++++
+            !temporary stuff for a dummy version
+            CALL tab_1d_2d( nbpb, dh_i_surf2D, npb, dh_i_surf(1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, dh_i_bott2D, npb, dh_i_bott(1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, fsup2D     , npb, fsup     (1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, focea2D    , npb, focea    (1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, s_i_newice , npb, s_i_new  (1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, izero(:,:,jl) , npb, i0    (1:nbpb)      , jpi, jpj )
+            CALL tab_1d_2d( nbpb, qns_ice(:,:,jl), npb, qnsr_ice_1d(1:nbpb), jpi, jpj)
+            !+++++
+
+            IF( lk_mpp )   CALL mpp_comm_free( ncomm_ice ) !RB necessary ??
+         ENDIF
+         !
+      END DO
+
+      !------------------------------------------------------------------------------!
+      ! 5) Global variables, diagnostics
+      !------------------------------------------------------------------------------!
+
+      !------------------------
+      ! 5.1) Ice heat content              
+      !------------------------
+
+      ! Enthalpies are global variables we have to readjust the units
+      zcoef = 1.e0 / ( unit_fac * REAL(nlay_i) )
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            ! Multiply by volume, divide by nlayers so that heat content in 10^9 Joules
+            e_i(:,:,jk,jl) = e_i(:,:,jk,jl) * area(:,:) * a_i(:,:,jl) * ht_i(:,:,jl) * zcoef
+         END DO
+      END DO
+
+      !------------------------
+      ! 5.2) Snow heat content              
+      !------------------------
+
+      ! Enthalpies are global variables we have to readjust the units
+      zcoef = 1.e0 / ( unit_fac * REAL(nlay_s) )
+      DO jl = 1, jpl
+         DO jk = 1, nlay_s
+            ! Multiply by volume, so that heat content in 10^9 Joules
+            e_s(:,:,jk,jl) = e_s(:,:,jk,jl) * area(:,:) * a_i(:,:,jl) * ht_s(:,:,jl) * zcoef
+         END DO
+      END DO
+
+      !----------------------------------
+      ! 5.3) Change thickness to volume
+      !----------------------------------
+      CALL lim_var_eqv2glo
+
+      !--------------------------------------------
+      ! 5.4) Diagnostic thermodynamic growth rates
+      !--------------------------------------------
+      d_v_i_thd(:,:,:) = v_i      (:,:,:) - old_v_i(:,:,:)    ! ice volumes 
+      dv_dt_thd(:,:,:) = d_v_i_thd(:,:,:) / rdt_ice * 86400.0
+
+      IF( con_i )   fbif(:,:) = fbif(:,:) + zqlbsbq(:,:)
+
+      IF(ln_ctl) THEN   ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=area , clinfo1=' lim_thd  : cell area :')
+         CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_thd  : at_i      :')
+         CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_thd  : vt_i      :')
+         CALL prt_ctl(tab2d_1=vt_s , clinfo1=' lim_thd  : vt_s      :')
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_thd  : a_i      : ')
+            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_thd  : ht_i     : ')
+            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_thd  : ht_s     : ')
+            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_thd  : v_i      : ')
+            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_thd  : v_s      : ')
+            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_thd  : e_s      : ')
+            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_thd  : t_su     : ')
+            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_thd  : t_snow   : ')
+            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_thd  : sm_i     : ')
+            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_thd  : smv_i    : ')
+            DO jk = 1, nlay_i
+               CALL prt_ctl_info(' ')
+               CALL prt_ctl_info(' - Layer : ', ivar1=jk)
+               CALL prt_ctl_info('   ~~~~~~~')
+               CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' lim_thd  : t_i      : ')
+               CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' lim_thd  : e_i      : ')
+            END DO
+         END DO
+
+      ENDIF
+
+   END SUBROUTINE lim_thd
+
+
+   SUBROUTINE lim_thd_glohec( eti, ets, etilayer, kideb, kiut, jl )
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_glohec *** 
+      !!                 
+      !! ** Purpose :  Compute total heat content for each category
+      !!               Works with 1d vectors only
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kideb, kiut   ! bounds for the spatial loop
+      INTEGER , INTENT(in   )                         ::   jl            ! category number
+      REAL(wp), INTENT(  out), DIMENSION (jpij,jpl  ) ::   eti, ets      ! vertically-summed heat content for ice & snow
+      REAL(wp), INTENT(  out), DIMENSION (jpij,jkmax) ::   etilayer      ! heat content for ice layers
+      !!
+      INTEGER  ::   ji,jk   ! loop indices
+      REAL(wp) ::   zeps    ! very small value (1.e-10)
+      !!-----------------------------------------------------------------------
+      eti(:,:) = 0.e0
+      ets(:,:) = 0.e0
+      zeps     = 1.e-10
+
+      DO jk = 1, nlay_i                ! total q over all layers, ice [J.m-2]
+         DO ji = kideb, kiut
+            etilayer(ji,jk) = q_i_b(ji,jk) * ht_i_b(ji) / nlay_i
+            eti     (ji,jl) = eti(ji,jl) + etilayer(ji,jk) 
+         END DO
+      END DO
+      DO ji = kideb, kiut              ! total q over all layers, snow [J.m-2]
+         ets(ji,jl) = ets(ji,jl) + q_s_b(ji,1) * ht_s_b(ji) / nlay_s
+      END DO
+
+      IF(lwp) WRITE(numout,*) ' lim_thd_glohec '
+      IF(lwp) WRITE(numout,*) ' qt_i_in : ', eti(jiindex_1d,jl) / rdt_ice
+      IF(lwp) WRITE(numout,*) ' qt_s_in : ', ets(jiindex_1d,jl) / rdt_ice
+      IF(lwp) WRITE(numout,*) ' qt_in   : ', ( eti(jiindex_1d,jl) + ets(jiindex_1d,jl) ) / rdt_ice
+      !
+   END SUBROUTINE lim_thd_glohec
+
+
+   SUBROUTINE lim_thd_con_dif( kideb, kiut, jl )
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_con_dif *** 
+      !!                 
+      !! ** Purpose :   Test energy conservation after heat diffusion
+      !!-------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   kideb, kiut   ! bounds for the spatial loop
+      INTEGER , INTENT(in   ) ::   jl            ! category number
+
+      INTEGER  ::   ji, jk         ! loop indices
+      INTEGER  ::   zji, zjj
+      INTEGER  ::   numce          ! number of points for which conservation is violated
+      REAL(wp) ::   meance         ! mean conservation error
+      REAL(wp) ::   max_cons_err, max_surf_err
+      !!---------------------------------------------------------------------
+
+      max_cons_err =  1.0          ! maximum tolerated conservation error
+      max_surf_err =  0.001        ! maximum tolerated surface error
+
+      !--------------------------
+      ! Increment of energy
+      !--------------------------
+      ! global
+      DO ji = kideb, kiut
+         dq_i(ji,jl) = qt_i_fin(ji,jl) - qt_i_in(ji,jl) + qt_s_fin(ji,jl) - qt_s_in(ji,jl)
+      END DO
+      ! layer by layer
+      dq_i_layer(:,:)    = q_i_layer_fin(:,:) - q_i_layer_in(:,:)
+
+      !----------------------------------------
+      ! Atmospheric heat flux, ice heat budget
+      !----------------------------------------
+
+      DO ji = kideb, kiut
+         zji = MOD( npb(ji) - 1, jpi ) + 1
+         zjj = ( npb(ji) - 1 ) / jpi + 1
+
+         fatm(ji,jl) = qnsr_ice_1d(ji) + (1.0-i0(ji))*qsr_ice_1d(ji)
+
+         sum_fluxq(ji,jl) = fc_su(ji) - fc_bo_i(ji) + qsr_ice_1d(ji)*i0(ji) - fstroc(zji,zjj,jl)
+      END DO
+
+      !--------------------
+      ! Conservation error
+      !--------------------
+
+      DO ji = kideb, kiut
+         cons_error(ji,jl) = ABS( dq_i(ji,jl) / rdt_ice + sum_fluxq(ji,jl) )
+      END DO
+
+      numce = 0
+      meance = 0.0
+      DO ji = kideb, kiut
+         IF ( cons_error(ji,jl) .GT. max_cons_err ) THEN
+            numce = numce + 1
+            meance = meance + cons_error(ji,jl)
+         ENDIF
+      ENDDO
+      IF (numce .GT. 0 ) meance = meance / numce
+
+      WRITE(numout,*) ' Maximum tolerated conservation error : ', max_cons_err
+      WRITE(numout,*) ' After lim_thd_dif, category : ', jl
+      WRITE(numout,*) ' Mean conservation error on big error points ', meance, numit
+      WRITE(numout,*) ' Number of points where there is a cons err gt than c.e. : ', numce, numit
+
+      !-------------------------------------------------------
+      ! Surface error due to imbalance between Fatm and Fcsu
+      !-------------------------------------------------------
+      numce  = 0.0
+      meance = 0.0
+
+      DO ji = kideb, kiut
+         surf_error(ji,jl) = ABS ( fatm(ji,jl) - fc_su(ji) )
+         IF ( ( t_su_b(ji) .LT. rtt ) .AND. ( surf_error(ji,jl) .GT. &
+            max_surf_err ) ) THEN
+            numce = numce + 1 
+            meance = meance + surf_error(ji,jl)
+         ENDIF
+      ENDDO
+      IF (numce .GT. 0 ) meance = meance / numce
+
+      WRITE(numout,*) ' Maximum tolerated surface error : ', max_surf_err
+      WRITE(numout,*) ' After lim_thd_dif, category : ', jl
+      WRITE(numout,*) ' Mean surface error on big error points ', meance, numit
+      WRITE(numout,*) ' Number of points where there is a surf err gt than surf_err : ', numce, numit
+
+      IF (jiindex_1D.GT.0) WRITE(numout,*) ' fc_su      : ', fc_su(jiindex_1d)
+      IF (jiindex_1D.GT.0) WRITE(numout,*) ' fatm       : ', fatm(jiindex_1d,jl)
+      IF (jiindex_1D.GT.0) WRITE(numout,*) ' t_su       : ', t_su_b(jiindex_1d)
+
+      !---------------------------------------
+      ! Write ice state in case of big errors
+      !---------------------------------------
+
+      DO ji = kideb, kiut
+         IF ( ( ( t_su_b(ji) .LT. rtt ) .AND. ( surf_error(ji,jl) .GT. max_surf_err ) ) .OR. &
+            ( cons_error(ji,jl) .GT. max_cons_err  ) ) THEN
+            zji                 = MOD( npb(ji) - 1, jpi ) + 1
+            zjj                 = ( npb(ji) - 1 ) / jpi + 1
+
+            WRITE(numout,*) ' alerte 1     '
+            WRITE(numout,*) ' Untolerated conservation / surface error after '
+            WRITE(numout,*) ' heat diffusion in the ice '
+            WRITE(numout,*) ' Category   : ', jl
+            WRITE(numout,*) ' zji , zjj  : ', zji, zjj
+            WRITE(numout,*) ' lat, lon   : ', gphit(zji,zjj), glamt(zji,zjj)
+            WRITE(numout,*) ' cons_error : ', cons_error(ji,jl)
+            WRITE(numout,*) ' surf_error : ', surf_error(ji,jl)
+            WRITE(numout,*) ' dq_i       : ', - dq_i(ji,jl) / rdt_ice
+            WRITE(numout,*) ' Fdt        : ', sum_fluxq(ji,jl)
+            WRITE(numout,*)
+            !        WRITE(numout,*) ' qt_i_in   : ', qt_i_in(ji,jl)
+            !        WRITE(numout,*) ' qt_s_in   : ', qt_s_in(ji,jl)
+            !        WRITE(numout,*) ' qt_i_fin  : ', qt_i_fin(ji,jl)
+            !        WRITE(numout,*) ' qt_s_fin  : ', qt_s_fin(ji,jl)
+            !        WRITE(numout,*) ' qt        : ', qt_i_fin(ji,jl) + &
+            !                                         qt_s_fin(ji,jl)
+            WRITE(numout,*) ' ht_i       : ', ht_i_b(ji)
+            WRITE(numout,*) ' ht_s       : ', ht_s_b(ji)
+            WRITE(numout,*) ' t_su       : ', t_su_b(ji)
+            WRITE(numout,*) ' t_s        : ', t_s_b(ji,1)
+            WRITE(numout,*) ' t_i        : ', t_i_b(ji,1:nlay_i)
+            WRITE(numout,*) ' t_bo       : ', t_bo_b(ji)
+            WRITE(numout,*) ' q_i        : ', q_i_b(ji,1:nlay_i)
+            WRITE(numout,*) ' s_i        : ', s_i_b(ji,1:nlay_i)
+            WRITE(numout,*) ' tmelts     : ', rtt - tmut*s_i_b(ji,1:nlay_i)
+            WRITE(numout,*)
+            WRITE(numout,*) ' Fluxes '
+            WRITE(numout,*) ' ~~~~~~ '
+            WRITE(numout,*) ' fatm       : ', fatm(ji,jl)
+            WRITE(numout,*) ' fc_su      : ', fc_su    (ji)
+            WRITE(numout,*) ' fstr_inice : ', qsr_ice_1d(ji)*i0(ji)
+            WRITE(numout,*) ' fc_bo      : ', - fc_bo_i  (ji)
+            WRITE(numout,*) ' foc        : ', fbif_1d(ji)
+            WRITE(numout,*) ' fstroc     : ', fstroc   (zji,zjj,jl)
+            WRITE(numout,*) ' i0         : ', i0(ji)
+            WRITE(numout,*) ' qsr_ice    : ', (1.0-i0(ji))*qsr_ice_1d(ji)
+            WRITE(numout,*) ' qns_ice    : ', qnsr_ice_1d(ji)
+            WRITE(numout,*) ' Conduction fluxes : '
+            WRITE(numout,*) ' fc_s      : ', fc_s(ji,0:nlay_s)
+            WRITE(numout,*) ' fc_i      : ', fc_i(ji,0:nlay_i)
+            WRITE(numout,*)
+            WRITE(numout,*) ' Layer by layer ... '
+            WRITE(numout,*) ' dq_snow : ', ( qt_s_fin(ji,jl) - &
+               qt_s_in(ji,jl) )  & 
+               / rdt_ice
+            WRITE(numout,*) ' dfc_snow  : ', fc_s(ji,1) -      &
+               fc_s(ji,0)
+            DO jk = 1, nlay_i
+               WRITE(numout,*) ' layer  : ', jk
+               WRITE(numout,*) ' dq_ice : ', dq_i_layer(ji,jk) / rdt_ice  
+               WRITE(numout,*) ' radab  : ', radab(ji,jk)
+               WRITE(numout,*) ' dfc_i  : ', fc_i(ji,jk) -               &
+                  fc_i(ji,jk-1)
+               WRITE(numout,*) ' tot f  : ', fc_i(ji,jk) -               &
+                  fc_i(ji,jk-1) - radab(ji,jk)
+            END DO
+
+         ENDIF
+
+      END DO
+      !
+   END SUBROUTINE lim_thd_con_dif
+
+
+   SUBROUTINE lim_thd_con_dh(kideb,kiut,jl)
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_con_dh  *** 
+      !!                 
+      !! ** Purpose :   Test energy conservation after enthalpy redistr.
+      !!
+      !! history :
+      !!  9.9  ! 07-04 (M.Vancoppenolle) original code
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::        &
+         kideb, kiut,               &  !: bounds for the spatial loop
+         jl                            !: category number
+
+      REAL(wp)                 ::   &  !: ! goes to trash
+         meance,                    &  !: mean conservation error
+         max_cons_err                  !: maximum tolerated conservation error
+
+      INTEGER ::                    &
+         numce                         !: number of points for which conservation
+      !  is violated
+      INTEGER  ::  ji, zji, zjj        ! loop indices
+      !!---------------------------------------------------------------------
+
+      max_cons_err = 1.0
+
+      !--------------------------
+      ! Increment of energy
+      !--------------------------
+      ! global
+      DO ji = kideb, kiut
+         dq_i(ji,jl) = qt_i_fin(ji,jl) - qt_i_in(ji,jl)  &
+            + qt_s_fin(ji,jl) - qt_s_in(ji,jl)
+      END DO
+      ! layer by layer
+      dq_i_layer(:,:)    = q_i_layer_fin(:,:) - q_i_layer_in(:,:)
+
+      !----------------------------------------
+      ! Atmospheric heat flux, ice heat budget
+      !----------------------------------------
+
+      DO ji = kideb, kiut
+         zji                 = MOD( npb(ji) - 1, jpi ) + 1
+         zjj                 = ( npb(ji) - 1 ) / jpi + 1
+
+         fatm(ji,jl) = &
+            qnsr_ice_1d(ji)                  + & ! atm non solar
+            !         (1.0-i0(ji))*qsr_ice_1d(ji)          ! atm solar
+            qsr_ice_1d(ji)                       ! atm solar
+
+         sum_fluxq(ji,jl)     = fatm(ji,jl) + fbif_1d(ji) - ftotal_fin(ji) & 
+            - fstroc(zji,zjj,jl) 
+         cons_error(ji,jl)   = ABS( dq_i(ji,jl) / rdt_ice + sum_fluxq(ji,jl) )
+      END DO
+
+      !--------------------
+      ! Conservation error
+      !--------------------
+
+      DO ji = kideb, kiut
+         cons_error(ji,jl) = ABS( dq_i(ji,jl) / rdt_ice + sum_fluxq(ji,jl) )
+      END DO
+
+      numce = 0
+      meance = 0.0
+      DO ji = kideb, kiut
+         IF ( cons_error(ji,jl) .GT. max_cons_err ) THEN
+            numce = numce + 1
+            meance = meance + cons_error(ji,jl)
+         ENDIF
+      ENDDO
+      IF (numce .GT. 0 ) meance = meance / numce
+
+      WRITE(numout,*) ' Error report - Category : ', jl
+      WRITE(numout,*) ' ~~~~~~~~~~~~ '
+      WRITE(numout,*) ' Maximum tolerated conservation error : ', max_cons_err
+      WRITE(numout,*) ' After lim_thd_ent, category : ', jl
+      WRITE(numout,*) ' Mean conservation error on big error points ', meance, &
+         numit
+      WRITE(numout,*) ' Number of points where there is a cons err gt than 0.1 W/m2 : ', numce, numit
+
+      !---------------------------------------
+      ! Write ice state in case of big errors
+      !---------------------------------------
+
+      DO ji = kideb, kiut
+         IF ( cons_error(ji,jl) .GT. max_cons_err  ) THEN
+            zji                 = MOD( npb(ji) - 1, jpi ) + 1
+            zjj                 = ( npb(ji) - 1 ) / jpi + 1
+
+            WRITE(numout,*) ' alerte 1 - category : ', jl
+            WRITE(numout,*) ' Untolerated conservation error after limthd_ent '
+            WRITE(numout,*) ' zji , zjj  : ', zji, zjj
+            WRITE(numout,*) ' lat, lon   : ', gphit(zji,zjj), glamt(zji,zjj)
+            WRITE(numout,*) ' * '
+            WRITE(numout,*) ' Ftotal     : ', sum_fluxq(ji,jl)
+            WRITE(numout,*) ' dq_t       : ', - dq_i(ji,jl) / rdt_ice
+            WRITE(numout,*) ' dq_i       : ', - ( qt_i_fin(ji,jl) - qt_i_in(ji,jl) ) / rdt_ice
+            WRITE(numout,*) ' dq_s       : ', - ( qt_s_fin(ji,jl) - qt_s_in(ji,jl) ) / rdt_ice
+            WRITE(numout,*) ' cons_error : ', cons_error(ji,jl)
+            WRITE(numout,*) ' * '
+            WRITE(numout,*) ' Fluxes        --- : '
+            WRITE(numout,*) ' fatm       : ', fatm(ji,jl)
+            WRITE(numout,*) ' foce       : ', fbif_1d(ji)
+            WRITE(numout,*) ' fres       : ', ftotal_fin(ji)
+            WRITE(numout,*) ' fhbri      : ', fhbricat(zji,zjj,jl)
+            WRITE(numout,*) ' * '
+            WRITE(numout,*) ' Heat contents --- : '
+            WRITE(numout,*) ' qt_s_in    : ', qt_s_in(ji,jl) / rdt_ice
+            WRITE(numout,*) ' qt_i_in    : ', qt_i_in(ji,jl) / rdt_ice
+            WRITE(numout,*) ' qt_in      : ', ( qt_i_in(ji,jl) + &
+               qt_s_in(ji,jl) ) / rdt_ice
+            WRITE(numout,*) ' qt_s_fin   : ', qt_s_fin(ji,jl) / rdt_ice
+            WRITE(numout,*) ' qt_i_fin   : ', qt_i_fin(ji,jl) / rdt_ice
+            WRITE(numout,*) ' qt_fin     : ', ( qt_i_fin(ji,jl) + &
+               qt_s_fin(ji,jl) ) / rdt_ice
+            WRITE(numout,*) ' * '
+            WRITE(numout,*) ' Ice variables --- : '
+            WRITE(numout,*) ' ht_i       : ', ht_i_b(ji)
+            WRITE(numout,*) ' ht_s       : ', ht_s_b(ji)
+            WRITE(numout,*) ' dh_s_tot  : ', dh_s_tot(ji)
+            WRITE(numout,*) ' dh_snowice: ', dh_snowice(ji)
+            WRITE(numout,*) ' dh_i_surf : ', dh_i_surf(ji)
+            WRITE(numout,*) ' dh_i_bott : ', dh_i_bott(ji)
+
+         ENDIF
+         !
+      END DO
+      !
+   END SUBROUTINE lim_thd_con_dh
+
+
+   SUBROUTINE lim_thd_enmelt( kideb, kiut )
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_enmelt *** 
+      !!                 
+      !! ** Purpose :   Computes sea ice energy of melting q_i (J.m-3)
+      !!
+      !! ** Method  :   Formula (Bitz and Lipscomb, 1999)
+      !!
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kideb, kiut   ! bounds for the spatial loop
+      !!
+      INTEGER  ::   ji, jk   !dummy loop indices
+      REAL(wp) ::   ztmelts, zeps   ! temporary scalar 
+      !!-------------------------------------------------------------------
+      zeps = 1.e-10
+      !
+      DO jk = 1, nlay_i             ! Sea ice energy of melting
+         DO ji = kideb, kiut
+            ztmelts      =  - tmut  * s_i_b(ji,jk) + rtt 
+            q_i_b(ji,jk) =    rhoic * ( cpic * ( ztmelts - t_i_b(ji,jk) )                                 &
+               &                      + lfus * ( 1.0 - (ztmelts-rtt) / MIN( t_i_b(ji,jk)-rtt, -zeps ) )   &
+               &                      - rcp  * ( ztmelts-rtt  )  ) 
+         END DO
+      END DO
+      DO jk = 1, nlay_s             ! Snow energy of melting
+         DO ji = kideb,kiut
+            q_s_b(ji,jk) = rhosn * ( cpic * ( rtt - t_s_b(ji,jk) ) + lfus )
+         END DO
+      END DO
+      !
+   END SUBROUTINE lim_thd_enmelt
+
+
+   SUBROUTINE lim_thd_init
+
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_init *** 
+      !!                 
+      !! ** Purpose :   Physical constants and parameters linked to the ice 
+      !!              thermodynamics
+      !!
+      !! ** Method  :   Read the namicethd namelist and check the ice-thermo
+      !!              parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicether
+       !!-------------------------------------------------------------------
+      NAMELIST/namicethd/ hmelt , hiccrit, fraz_swi, maxfrazb, vfrazb, Cfrazb,   &
+         &                hicmin, hiclim, amax  ,                                &
+         &                sbeta  , parlat, hakspl, hibspl, exld,                 &
+         &                hakdif, hnzst  , thth  , parsub, alphs, betas,         & 
+         &                kappa_i, nconv_i_thd, maxer_i_thd, thcon_i_swi
+      !!-------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_thd : Ice Thermodynamics'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      REWIND( numnam_ice )                  ! read Namelist numnam_ice
+      READ  ( numnam_ice , namicethd )
+      
+      IF(lwp) THEN                          ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)'   Namelist of ice parameters for ice thermodynamic computation '
+         WRITE(numout,*)'      maximum melting at the bottom                           hmelt        = ', hmelt
+         WRITE(numout,*)'      ice thick. for lateral accretion in NH (SH)             hiccrit(1/2) = ', hiccrit
+         WRITE(numout,*)'      Frazil ice thickness as a function of wind or not       fraz_swi     = ', fraz_swi
+         WRITE(numout,*)'      Maximum proportion of frazil ice collecting at bottom   maxfrazb     = ', maxfrazb
+         WRITE(numout,*)'      Thresold relative drift speed for collection of frazil  vfrazb       = ', vfrazb
+         WRITE(numout,*)'      Squeezing coefficient for collection of frazil          Cfrazb       = ', Cfrazb
+         WRITE(numout,*)'      ice thick. corr. to max. energy stored in brine pocket  hicmin       = ', hicmin  
+         WRITE(numout,*)'      minimum ice thickness                                   hiclim       = ', hiclim 
+         WRITE(numout,*)'      maximum lead fraction                                   amax         = ', amax 
+         WRITE(numout,*)'      numerical carac. of the scheme for diffusion in ice '
+         WRITE(numout,*)'      Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)   sbeta        = ', sbeta
+         WRITE(numout,*)'      percentage of energy used for lateral ablation          parlat       = ', parlat
+         WRITE(numout,*)'      slope of distr. for Hakkinen-Mellor lateral melting     hakspl       = ', hakspl  
+         WRITE(numout,*)'      slope of distribution for Hibler lateral melting        hibspl       = ', hibspl
+         WRITE(numout,*)'      exponent for leads-closure rate                         exld         = ', exld
+         WRITE(numout,*)'      coefficient for diffusions of ice and snow              hakdif       = ', hakdif
+         WRITE(numout,*)'      threshold thick. for comp. of eq. thermal conductivity  zhth         = ', thth 
+         WRITE(numout,*)'      thickness of the surf. layer in temp. computation       hnzst        = ', hnzst
+         WRITE(numout,*)'      switch for snow sublimation  (=1) or not (=0)           parsub       = ', parsub  
+         WRITE(numout,*)'      coefficient for snow density when snow ice formation    alphs        = ', alphs
+         WRITE(numout,*)'      coefficient for ice-lead partition of snowfall          betas        = ', betas
+         WRITE(numout,*)'      extinction radiation parameter in sea ice (1.0)         kappa_i      = ', kappa_i
+         WRITE(numout,*)'      maximal n. of iter. for heat diffusion computation      nconv_i_thd  = ', nconv_i_thd
+         WRITE(numout,*)'      maximal err. on T for heat diffusion computation        maxer_i_thd  = ', maxer_i_thd
+         WRITE(numout,*)'      switch for comp. of thermal conductivity in the ice     thcon_i_swi  = ', thcon_i_swi
+      ENDIF
+      !
+      rcdsn = hakdif * rcdsn 
+      rcdic = hakdif * rcdic
+      !
+   END SUBROUTINE lim_thd_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                               NO  LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd         ! Empty routine
+   END SUBROUTINE lim_thd
+   SUBROUTINE lim_thd_con_dif
+   END SUBROUTINE lim_thd_con_dif
+#endif
+
+   !!======================================================================
+END MODULE limthd
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dh.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 1844)
@@ -0,0 +1,712 @@
+MODULE limthd_dh
+   !!======================================================================
+   !!                       ***  MODULE limthd_dh ***
+   !!  LIM-3 :   thermodynamic growth and decay of the ice 
+   !!======================================================================
+   !! History :  LIM  ! 2003-05 (M. Vancoppenolle) Original code in 1D
+   !!                 ! 2005-06 (M. Vancoppenolle) 3D version 
+   !!            3.2  ! 2009-07 (M. Vancoppenolle, Y. Aksenov, G. Madec) bug correction in rdmsnif & rdmicif
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_thd_dh  : vertical accr./abl. and lateral ablation of sea ice
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+   USE phycst           ! physical constants (OCE directory) 
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE thd_ice
+   USE iceini
+   USE limistate
+   USE in_out_manager
+   USE ice
+   USE par_ice
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_thd_dh   ! called by lim_thd
+
+   REAL(wp) ::   epsi20 = 1e-20   ! constant values
+   REAL(wp) ::   epsi13 = 1e-13   !
+   REAL(wp) ::   epsi16 = 1e-16   !
+   REAL(wp) ::   zzero  = 0.e0    !
+   REAL(wp) ::   zone   = 1.e0    !
+
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2,  UCL-LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_dh(kideb,kiut,jl)
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_dh  ***
+      !!
+      !! ** Purpose :   determines variations of ice and snow thicknesses.
+      !!
+      !! ** Method  :   Ice/Snow surface melting arises from imbalance in surface fluxes
+      !!              Bottom accretion/ablation arises from flux budget
+      !!              Snow thickness can increase by precipitation and decrease by sublimation
+      !!              If snow load excesses Archmiede limit, snow-ice is formed by
+      !!              the flooding of sea-water in the snow
+      !!
+      !!                 1) Compute available flux of heat for surface ablation
+      !!                 2) Compute snow and sea ice enthalpies
+      !!                 3) Surface ablation and sublimation
+      !!                 4) Bottom accretion/ablation
+      !!                 5) Case of Total ablation
+      !!                 6) Snow ice formation
+      !!
+      !! References : Bitz and Lipscomb, 1999, J. Geophys. Res.
+      !!              Fichefet T. and M. Maqueda 1997, J. Geophys. Res., 102(C6), 12609-12646   
+      !!              Vancoppenolle, Fichefet and Bitz, 2005, Geophys. Res. Let. 
+      !!              Vancoppenolle et al.,2009, Ocean Modelling
+      !!------------------------------------------------------------------
+      INTEGER , INTENT(in) ::   kideb, kiut   ! Start/End point on which the  the computation is applied
+      INTEGER , INTENT(in) ::   jl            ! Thickness cateogry number
+      !! 
+      INTEGER  ::   ji , jk        ! dummy loop indices
+      INTEGER  ::   zji, zjj       ! 2D corresponding indices to ji
+      INTEGER  ::   isnow          ! switch for presence (1) or absence (0) of snow
+      INTEGER  ::   isnowic        ! snow ice formation not
+      INTEGER  ::   i_ice_switch   ! ice thickness above a certain treshold or not
+      INTEGER  ::   iter
+
+      REAL(wp) ::   zzfmass_i, zzfmass_s   ! temporary scalar
+      REAL(wp) ::   zhsnew, zihgnew, ztmelts               ! temporary scalar
+      REAL(wp) ::   zhn, zdhcf, zdhbf, zhni, zhnfi, zihg   !
+      REAL(wp) ::   zdhnm, zhnnew, zhisn, zihic            !
+      REAL(wp) ::   zfracs       ! fractionation coefficient for bottom salt entrapment
+      REAL(wp) ::   zds          ! increment of bottom ice salinity
+      REAL(wp) ::   zcoeff       ! dummy argument for snowfall partitioning over ice and leads
+      REAL(wp) ::   zsm_snowice  ! snow-ice salinity
+      REAL(wp) ::   zswi1        ! switch for computation of bottom salinity
+      REAL(wp) ::   zswi12       ! switch for computation of bottom salinity
+      REAL(wp) ::   zswi2        ! switch for computation of bottom salinity
+      REAL(wp) ::   zgrr         ! bottom growth rate
+      REAL(wp) ::   ztform       ! bottom formation temperature
+
+      REAL(wp), DIMENSION(jpij) ::   zh_i        ! ice layer thickness
+      REAL(wp), DIMENSION(jpij) ::   zh_s        ! snow layer thickness
+      REAL(wp), DIMENSION(jpij) ::   ztfs        ! melting point
+      REAL(wp), DIMENSION(jpij) ::   zhsold      ! old snow thickness
+      REAL(wp), DIMENSION(jpij) ::   zqprec      ! energy of fallen snow
+      REAL(wp), DIMENSION(jpij) ::   zqfont_su   ! incoming, remaining surface energy
+      REAL(wp), DIMENSION(jpij) ::   zqfont_bo   ! incoming, bottom energy
+      REAL(wp), DIMENSION(jpij) ::   z_f_surf    ! surface heat for ablation
+      REAL(wp), DIMENSION(jpij) ::   zhgnew      ! new ice thickness
+      REAL(wp), DIMENSION(jpij) ::   zfmass_i    ! 
+
+      REAL(wp), DIMENSION(jpij) ::   zdh_s_mel     ! snow melt 
+      REAL(wp), DIMENSION(jpij) ::   zdh_s_pre     ! snow precipitation 
+      REAL(wp), DIMENSION(jpij) ::   zdh_s_sub     ! snow sublimation
+      REAL(wp), DIMENSION(jpij) ::   zfsalt_melt   ! salt flux due to ice melt
+
+      REAL(wp) , DIMENSION(jpij,jkmax) ::   zdeltah
+
+      ! Pathological cases
+      REAL(wp), DIMENSION(jpij) ::   zfdt_init   ! total incoming heat for ice melt
+      REAL(wp), DIMENSION(jpij) ::   zfdt_final  ! total remaing heat for ice melt
+      REAL(wp), DIMENSION(jpij) ::   zqt_i       ! total ice heat content
+      REAL(wp), DIMENSION(jpij) ::   zqt_s       ! total snow heat content
+      REAL(wp), DIMENSION(jpij) ::   zqt_dummy   ! dummy heat content
+
+      REAL(wp), DIMENSION(jpij,jkmax) ::   zqt_i_lay   ! total ice heat content
+
+      ! Heat conservation 
+      INTEGER  ::   num_iter_max, numce_dh
+      REAL(wp) ::   meance_dh
+      INTEGER , DIMENSION(jpij) ::   innermelt
+      REAL(wp), DIMENSION(jpij) ::   zfbase, zdq_i
+      !!------------------------------------------------------------------
+
+      zfsalt_melt(:)  = 0.0
+      ftotal_fin(:)   = 0.0
+      zfdt_init(:)    = 0.0
+      zfdt_final(:)   = 0.0
+
+      DO ji = kideb, kiut
+         old_ht_i_b(ji) = ht_i_b(ji)
+         old_ht_s_b(ji) = ht_s_b(ji)
+      END DO
+      !
+      !------------------------------------------------------------------------------!
+      !  1) Calculate available heat for surface ablation                            !
+      !------------------------------------------------------------------------------!
+      !
+      DO ji = kideb,kiut
+         isnow         = INT( 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - ht_s_b(ji) ) ) )
+         ztfs(ji)      = isnow * rtt + ( 1.0 - isnow ) * rtt
+         z_f_surf(ji)  = qnsr_ice_1d(ji) + ( 1.0 - i0(ji) ) * qsr_ice_1d(ji) - fc_su(ji)
+         z_f_surf(ji)  = MAX( zzero , z_f_surf(ji) ) * MAX( zzero , SIGN( zone , t_su_b(ji) - ztfs(ji) ) )
+         zfdt_init(ji) = ( z_f_surf(ji) + MAX( fbif_1d(ji) + qlbbq_1d(ji) + fc_bo_i(ji),0.0 ) ) * rdt_ice
+      END DO ! ji
+
+      zqfont_su(:) = 0.0
+      zqfont_bo(:) = 0.0
+      dsm_i_se_1d(:) = 0.0     
+      dsm_i_si_1d(:) = 0.0     
+      !
+      !------------------------------------------------------------------------------!
+      !  2) Computing layer thicknesses and  snow and sea-ice enthalpies.            !
+      !------------------------------------------------------------------------------!
+      !
+      ! Layer thickness
+      DO ji = kideb,kiut
+         zh_i(ji) = ht_i_b(ji) / nlay_i
+         zh_s(ji) = ht_s_b(ji) / nlay_s
+      END DO
+
+      ! Total enthalpy of the snow
+      zqt_s(:) = 0.0
+      DO jk = 1, nlay_s
+         DO ji = kideb,kiut
+            zqt_s(ji) =  zqt_s(ji) + q_s_b(ji,jk) * ht_s_b(ji) / nlay_s
+         END DO
+      END DO
+
+      ! Total enthalpy of the ice
+      zqt_i(:) = 0.0
+      DO jk = 1, nlay_i
+         DO ji = kideb,kiut
+            zqt_i(ji)        =  zqt_i(ji) + q_i_b(ji,jk) * ht_i_b(ji) / nlay_i
+            zqt_i_lay(ji,jk) =              q_i_b(ji,jk) * ht_i_b(ji) / nlay_i
+         END DO
+      END DO
+      !
+      !------------------------------------------------------------------------------|
+      !  3) Surface ablation and sublimation                                         |
+      !------------------------------------------------------------------------------|
+      !
+      !-------------------------
+      ! 3.1 Snow precips / melt
+      !-------------------------
+      ! Snow accumulation in one thermodynamic time step
+      ! snowfall is partitionned between leads and ice
+      ! if snow fall was uniform, a fraction (1-at_i) would fall into leads
+      ! but because of the winds, more snow falls on leads than on sea ice
+      ! and a greater fraction (1-at_i)^beta of the total mass of snow 
+      ! (beta < 1) falls in leads.
+      ! In reality, beta depends on wind speed, 
+      ! and should decrease with increasing wind speed but here, it is 
+      ! considered as a constant. an average value is 0.66
+      ! Martin Vancoppenolle, December 2006
+
+      ! Snow fall
+      DO ji = kideb, kiut
+         zcoeff = ( 1.0 - ( 1.0 - at_i_b(ji) )**betas ) / at_i_b(ji) 
+         zdh_s_pre(ji) = zcoeff * sprecip_1d(ji) * rdt_ice / rhosn
+      END DO
+      zdh_s_mel(:) =  0.0
+
+      ! Melt of fallen snow
+      DO ji = kideb, kiut
+         ! tatm_ice is now in K
+         zqprec   (ji)   =  rhosn * ( cpic * ( rtt - tatm_ice_1d(ji) ) + lfus )  
+         zqfont_su(ji)   =  z_f_surf(ji) * rdt_ice
+         zdeltah  (ji,1) =  MIN( 0.e0 , - zqfont_su(ji) / MAX( zqprec(ji) , epsi13 ) )
+         zqfont_su(ji)   =  MAX( 0.e0 , - zdh_s_pre(ji) - zdeltah(ji,1)              ) * zqprec(ji)
+         zdeltah  (ji,1) =  MAX( - zdh_s_pre(ji) , zdeltah(ji,1) )
+         zdh_s_mel(ji)   =  zdh_s_mel(ji) + zdeltah(ji,1)
+         ! heat conservation
+         qt_s_in(ji,jl)  =  qt_s_in(ji,jl) + zqprec(ji) * zdh_s_pre(ji)
+         zqt_s  (ji)     =  zqt_s  (ji)    + zqprec(ji) * zdh_s_pre(ji)
+         zqt_s  (ji)     =  MAX( zqt_s(ji) - zqfont_su(ji) , 0.e0 ) 
+      END DO
+
+
+      ! Snow melt due to surface heat imbalance
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            zdeltah  (ji,jk) = - zqfont_su(ji) / q_s_b(ji,jk)
+            zqfont_su(ji)    =  MAX( 0.0 , - zh_s(ji) - zdeltah(ji,jk) ) * q_s_b(ji,jk) 
+            zdeltah  (ji,jk) =  MAX( zdeltah(ji,jk) , - zh_s(ji) )
+            zdh_s_mel(ji)    =  zdh_s_mel(ji) + zdeltah(ji,jk)        ! resulting melt of snow    
+         END DO
+      END DO
+
+      ! Apply snow melt to snow depth
+      DO ji = kideb, kiut
+         dh_s_tot(ji)   =  zdh_s_mel(ji) + zdh_s_pre(ji)
+         ! Old and new snow depths
+         zhsold(ji)     =  ht_s_b(ji)
+         zhsnew         =  ht_s_b(ji) + dh_s_tot(ji)
+         ! If snow is still present zhn = 1, else zhn = 0
+         zhn            =  1.0 - MAX( zzero , SIGN( zone , - zhsnew ) )
+         ht_s_b(ji)     =  MAX( zzero , zhsnew )
+         ! Volume and mass variations of snow
+         dvsbq_1d  (ji) =  a_i_b(ji) * ( ht_s_b(ji) - zhsold(ji) - zdh_s_mel(ji) )
+         dvsbq_1d  (ji) =  MIN( zzero, dvsbq_1d(ji) )
+         rdmsnif_1d(ji) =  rdmsnif_1d(ji) + rhosn * dvsbq_1d(ji)
+      END DO ! ji
+
+      !--------------------------
+      ! 3.2 Surface ice ablation 
+      !--------------------------
+      DO ji = kideb, kiut 
+         dh_i_surf(ji) =  0.e0
+         z_f_surf (ji) =  zqfont_su(ji) / rdt_ice ! heat conservation test
+         zdq_i    (ji) =  0.e0
+      END DO ! ji
+
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut 
+            !                                                    ! melt of layer jk
+            zdeltah  (ji,jk) = - zqfont_su(ji) / q_i_b(ji,jk)
+            !                                                    ! recompute heat available
+            zqfont_su(ji)    = MAX( 0.0 , - zh_i(ji) - zdeltah(ji,jk) ) * q_i_b(ji,jk) 
+            !                                                    ! melt of layer jk cannot be higher than its thickness
+            zdeltah  (ji,jk) = MAX( zdeltah(ji,jk) , - zh_i(ji) )
+            !                                                    ! update surface melt
+            dh_i_surf(ji)    = dh_i_surf(ji) + zdeltah(ji,jk) 
+            !                                                    ! for energy conservation
+            zdq_i    (ji)    = zdq_i(ji) + zdeltah(ji,jk) * q_i_b(ji,jk) / rdt_ice
+            !
+            ! contribution to ice-ocean salt flux 
+            zji = MOD( npb(ji) - 1, jpi ) + 1
+            zjj = ( npb(ji) - 1 ) / jpi + 1
+            zfsalt_melt(ji) = zfsalt_melt(ji) + ( sss_m(zji,zjj) - sm_i_b(ji) ) * a_i_b(ji)    &
+               &                              * MIN( zdeltah(ji,jk) , 0.e0 ) * rhoic / rdt_ice 
+         END DO
+      END DO
+
+      !                     !-------------------
+      IF( con_i ) THEN      ! Conservation test
+         !                  !-------------------
+         numce_dh  = 0
+         meance_dh = 0.e0
+         DO ji = kideb, kiut
+            IF ( ( z_f_surf(ji) + zdq_i(ji) ) .GE. 1.0e-3 ) THEN
+               numce_dh  = numce_dh + 1
+               meance_dh = meance_dh + z_f_surf(ji) + zdq_i(ji)
+            ENDIF
+            IF( z_f_surf(ji) + zdq_i(ji) .GE. 1.0e-3  ) THEN!
+               WRITE(numout,*) ' ALERTE heat loss for surface melt '
+               WRITE(numout,*) ' zji, zjj, jl :', zji, zjj, jl
+               WRITE(numout,*) ' ht_i_b  : ', ht_i_b(ji)
+               WRITE(numout,*) ' z_f_surf  : ', z_f_surf(ji)
+               WRITE(numout,*) ' zdq_i   : ', zdq_i(ji)
+               WRITE(numout,*) ' ht_i_b  : ', ht_i_b(ji)
+               WRITE(numout,*) ' fc_bo_i : ', fc_bo_i(ji)
+               WRITE(numout,*) ' fbif_1d : ', fbif_1d(ji)
+               WRITE(numout,*) ' qlbbq_1d: ', qlbbq_1d(ji)
+               WRITE(numout,*) ' s_i_new : ', s_i_new(ji)
+               WRITE(numout,*) ' sss_m   : ', sss_m(zji,zjj)
+            ENDIF
+         END DO
+         !
+         IF( numce_dh > 0 )   meance_dh = meance_dh / numce_dh
+         WRITE(numout,*) ' Error report - Category : ', jl
+         WRITE(numout,*) ' ~~~~~~~~~~~~ '
+         WRITE(numout,*) ' Number of points where there is sur. me. error : ', numce_dh
+         WRITE(numout,*) ' Mean basal growth error on error points : ', meance_dh
+         !
+      ENDIF
+
+      !----------------------
+      ! 3.3 Snow sublimation
+      !----------------------
+
+      DO ji = kideb, kiut
+         ! if qla is positive (upwards), heat goes to the atmosphere, therefore
+         ! snow sublimates, if qla is negative (downwards), snow condensates
+         zdh_s_sub(ji)    =  - parsub * qla_ice_1d(ji) / ( rhosn * lsub ) * rdt_ice
+         dh_s_tot (ji)    =  dh_s_tot(ji) + zdh_s_sub(ji)
+         zdhcf            =  ht_s_b(ji) + zdh_s_sub(ji) 
+         ht_s_b   (ji)    =  MAX( zzero , zdhcf )
+         ! we recompute dh_s_tot 
+         dh_s_tot (ji)    =  ht_s_b(ji) - zhsold(ji)
+         qt_s_in  (ji,jl) =  qt_s_in(ji,jl) + zdh_s_sub(ji)*q_s_b(ji,1)
+      END DO
+
+      zqt_dummy(:) = 0.e0
+      DO jk = 1, nlay_s
+         DO ji = kideb,kiut
+            q_s_b    (ji,jk) = rhosn * ( cpic * ( rtt - t_s_b(ji,jk) ) + lfus )
+            zqt_dummy(ji)    =  zqt_dummy(ji) + q_s_b(ji,jk) * ht_s_b(ji) / nlay_s            ! heat conservation
+         END DO
+      END DO
+
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            ! In case of disparition of the snow, we have to update the snow temperatures
+            zhisn  =  MAX( zzero , SIGN( zone, - ht_s_b(ji) ) )
+            t_s_b(ji,jk) = ( 1.0 - zhisn ) * t_s_b(ji,jk) + zhisn * rtt
+            q_s_b(ji,jk) = ( 1.0 - zhisn ) * q_s_b(ji,jk)
+         END DO
+      END DO
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 4) Basal growth / melt                                                       !
+      !------------------------------------------------------------------------------!
+      !
+      ! Ice basal growth / melt is given by the ratio of heat budget over basal
+      ! ice heat content.  Basal heat budget is given by the difference between
+      ! the inner conductive flux  (fc_bo_i), from the open water heat flux 
+      ! (qlbbqb) and the turbulent ocean flux (fbif). 
+      ! fc_bo_i is positive downwards. fbif and qlbbq are positive to the ice 
+
+      !-----------------------------------------------------
+      ! 4.1 Basal growth - (a) salinity not varying in time 
+      !-----------------------------------------------------
+      IF(  num_sal /= 2  .AND.  num_sal /= 4  ) THEN
+         DO ji = kideb, kiut
+            IF(  ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) < 0.0  ) THEN
+               s_i_new(ji)         =  sm_i_b(ji)
+               ! Melting point in K
+               ztmelts             =  - tmut * s_i_new(ji) + rtt 
+               ! New ice heat content (Bitz and Lipscomb, 1999)
+               ztform              =  t_i_b(ji,nlay_i)  ! t_bo_b crashes in the
+               ! Baltic
+               q_i_b(ji,nlay_i+1)  = rhoic * (  cpic * ( ztmelts - ztform )                                &
+                  &                           + lfus * (  1.0 - ( ztmelts - rtt ) / ( ztform - rtt )  )    &
+                  &                           - rcp  * ( ztmelts - rtt )                                 )
+               ! Basal growth rate = - F*dt / q
+               dh_i_bott(ji)       =  - rdt_ice*( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) / q_i_b(ji,nlay_i+1) 
+            ENDIF
+         END DO
+      ENDIF
+
+      !-------------------------------------------------
+      ! 4.1 Basal growth - (b) salinity varying in time 
+      !-------------------------------------------------
+      IF(  num_sal == 2 .OR.  num_sal == 4  ) THEN
+         ! the growth rate (dh_i_bott) is function of the new ice
+         ! heat content (q_i_b(nlay_i+1)). q_i_b depends on the new ice 
+         ! salinity (snewice). snewice depends on dh_i_bott
+         ! it converges quickly, so, no problem
+         ! See Vancoppenolle et al., OM08 for more info on this
+
+         ! Initial value (tested 1D, can be anything between 1 and 20)
+         num_iter_max = 4
+         s_i_new(:)   = 4.0
+
+         ! Iterative procedure
+         DO iter = 1, num_iter_max
+            DO ji = kideb, kiut
+               IF(  fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) < 0.e0  ) THEN
+                  zji = MOD( npb(ji) - 1, jpi ) + 1
+                  zjj = ( npb(ji) - 1 ) / jpi + 1
+                  ! Melting point in K
+                  ztmelts             =   - tmut * s_i_new(ji) + rtt 
+                  ! New ice heat content (Bitz and Lipscomb, 1999)
+                  q_i_b(ji,nlay_i+1)  =  rhoic * (  cpic * ( ztmelts - t_bo_b(ji) )                             &
+                     &                            + lfus * ( 1.0 - ( ztmelts - rtt ) / ( t_bo_b(ji) - rtt ) )   &
+                     &                            - rcp * ( ztmelts-rtt )                                     )
+                  ! Bottom growth rate = - F*dt / q
+                  dh_i_bott(ji) =  - rdt_ice * ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) / q_i_b(ji,nlay_i+1)
+                  ! New ice salinity ( Cox and Weeks, JGR, 1988 )
+                  ! zswi2  (1) if dh_i_bott/rdt .GT. 3.6e-7
+                  ! zswi12 (1) if dh_i_bott/rdt .LT. 3.6e-7 and .GT. 2.0e-8
+                  ! zswi1  (1) if dh_i_bott/rdt .LT. 2.0e-8
+                  zgrr   = MIN( 1.0e-3, MAX ( dh_i_bott(ji) / rdt_ice , epsi13 ) )
+                  zswi2  = MAX( zzero , SIGN( zone , zgrr - 3.6e-7 ) ) 
+                  zswi12 = MAX( zzero , SIGN( zone , zgrr - 2.0e-8 ) ) * ( 1.0 - zswi2 )
+                  zswi1  = 1. - zswi2 * zswi12 
+                  zfracs = zswi1  * 0.12 + zswi12 * ( 0.8925 + 0.0568 * LOG( 100.0 * zgrr ) )   &
+                     &                   + zswi2  * 0.26 / ( 0.26 + 0.74 * EXP ( - 724300.0 * zgrr ) ) 
+                  zds         = zfracs * sss_m(zji,zjj) - s_i_new(ji)
+                  s_i_new(ji) = zfracs * sss_m(zji,zjj)
+               ENDIF ! fc_bo_i
+            END DO ! ji
+         END DO ! iter
+
+         ! Final values
+         DO ji = kideb, kiut
+            IF( ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) .LT. 0.0  ) THEN
+               ! New ice salinity must not exceed 15 psu
+               s_i_new(ji) = MIN( s_i_new(ji), s_i_max )
+               ! Metling point in K
+               ztmelts     =   - tmut * s_i_new(ji) + rtt 
+               ! New ice heat content (Bitz and Lipscomb, 1999)
+               q_i_b(ji,nlay_i+1)  =  rhoic * (  cpic * ( ztmelts - t_bo_b(ji) )                              &
+                  &                            + lfus * ( 1.0 - ( ztmelts - rtt ) / ( t_bo_b(ji) - rtt ) )    &
+                  &                            - rcp * ( ztmelts - rtt )                                    )
+               ! Basal growth rate = - F*dt / q
+               dh_i_bott(ji)       =  - rdt_ice*( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) / q_i_b(ji,nlay_i+1) 
+               ! Salinity update
+               ! entrapment during bottom growth
+               dsm_i_se_1d(ji) = ( s_i_new(ji) * dh_i_bott(ji) + sm_i_b(ji) * ht_i_b(ji) )    &
+                  &            / MAX( ht_i_b(ji) + dh_i_bott(ji) ,epsi13 ) - sm_i_b(ji)
+            ENDIF ! heat budget
+         END DO
+      ENDIF
+
+      !----------------
+      ! 4.2 Basal melt
+      !----------------
+      meance_dh = 0.0
+      numce_dh  = 0
+      innermelt(:) = 0
+
+      DO ji = kideb, kiut
+         ! heat convergence at the surface > 0
+         IF(  ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) >= 0.e0  ) THEN
+
+            s_i_new(ji)   =  s_i_b(ji,nlay_i)
+            zqfont_bo(ji) =  rdt_ice * ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) )
+
+            zfbase(ji)    =  zqfont_bo(ji) / rdt_ice ! heat conservation test
+            zdq_i(ji)     =  0.e0
+
+            dh_i_bott(ji) =  0.e0
+         ENDIF
+      END DO
+
+      DO jk = nlay_i, 1, -1
+         DO ji = kideb, kiut
+            IF (  ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) .GE. 0.0  ) THEN
+               ztmelts             =   - tmut * s_i_b(ji,jk) + rtt 
+               IF ( t_i_b(ji,jk) .GE. ztmelts ) THEN
+                  zdeltah(ji,jk)  = - zh_i(ji)
+                  dh_i_bott(ji)   = dh_i_bott(ji) + zdeltah(ji,jk)
+                  innermelt(ji)   = 1
+               ELSE  ! normal ablation
+                  zdeltah(ji,jk)  = - zqfont_bo(ji) / q_i_b(ji,jk)
+                  zqfont_bo(ji)   = MAX( 0.0 , - zh_i(ji) - zdeltah(ji,jk) ) * q_i_b(ji,jk)
+                  zdeltah(ji,jk)  = MAX(zdeltah(ji,jk), - zh_i(ji) )
+                  dh_i_bott(ji)   = dh_i_bott(ji) + zdeltah(ji,jk)
+                  zdq_i(ji)       = zdq_i(ji) + zdeltah(ji,jk) * q_i_b(ji,jk) / rdt_ice
+                  ! contribution to salt flux
+                  zji             = MOD( npb(ji) - 1, jpi ) + 1
+                  zjj             = ( npb(ji) - 1 ) / jpi + 1
+                  zfsalt_melt(ji) = zfsalt_melt(ji) + ( sss_m(zji,zjj) - sm_i_b(ji)   ) * a_i_b(ji)   &
+                     &                              * MIN( zdeltah(ji,jk) , 0.0 ) * rhoic / rdt_ice 
+               ENDIF
+            ENDIF
+         END DO ! ji
+      END DO ! jk
+
+      !                     !-------------------
+      IF( con_i ) THEN      ! Conservation test
+      !                     !-------------------
+         DO ji = kideb, kiut
+            IF(  ( fc_bo_i(ji) + fbif_1d(ji) + qlbbq_1d(ji) ) >= 0.e0  ) THEN
+               IF( ( zfbase(ji) + zdq_i(ji) ) >= 1.e-3 ) THEN
+                  numce_dh  = numce_dh + 1
+                  meance_dh = meance_dh + zfbase(ji) + zdq_i(ji)
+               ENDIF
+               IF ( zfbase(ji) + zdq_i(ji) .GE. 1.0e-3  ) THEN
+                  WRITE(numout,*) ' ALERTE heat loss for basal  melt '
+                  WRITE(numout,*) ' zji, zjj, jl :', zji, zjj, jl
+                  WRITE(numout,*) ' ht_i_b  : ', ht_i_b(ji)
+                  WRITE(numout,*) ' zfbase  : ', zfbase(ji)
+                  WRITE(numout,*) ' zdq_i   : ', zdq_i(ji)
+                  WRITE(numout,*) ' ht_i_b  : ', ht_i_b(ji)
+                  WRITE(numout,*) ' fc_bo_i : ', fc_bo_i(ji)
+                  WRITE(numout,*) ' fbif_1d : ', fbif_1d(ji)
+                  WRITE(numout,*) ' qlbbq_1d: ', qlbbq_1d(ji)
+                  WRITE(numout,*) ' s_i_new : ', s_i_new(ji)
+                  WRITE(numout,*) ' sss_m   : ', sss_m(zji,zjj)
+                  WRITE(numout,*) ' dh_i_bott : ', dh_i_bott(ji)
+                  WRITE(numout,*) ' innermelt : ', innermelt(ji)
+               ENDIF
+            ENDIF
+         END DO
+         IF( numce_dh > 0 )   meance_dh = meance_dh / numce_dh
+         WRITE(numout,*) ' Number of points where there is bas. me. error : ', numce_dh
+         WRITE(numout,*) ' Mean basal melt error on error points : ', meance_dh
+         WRITE(numout,*) ' Remaining bottom heat : ', zqfont_bo(jiindex_1d)
+         !
+      ENDIF
+
+      !
+      !------------------------------------------------------------------------------!
+      !  5) Pathological cases                                                       !
+      !------------------------------------------------------------------------------!
+      !
+      !----------------------------------------------
+      ! 5.1 Excessive ablation in a 1-category model
+      !----------------------------------------------
+
+      DO ji = kideb, kiut
+         !                     ! in a 1-category sea ice model, bottom ablation must not exceed hmelt (-0.15)
+         IF( jpl == 1 ) THEN   ;   zdhbf = MAX( hmelt , dh_i_bott(ji) )
+         ELSE                  ;   zdhbf =              dh_i_bott(ji) 
+         ENDIF
+         !                     ! excessive energy is sent to lateral ablation
+         fsup     (ji) =  rhoic * lfus * at_i_b(ji) / MAX( 1.0 - at_i_b(ji) , epsi13 )   &
+            &                          * ( zdhbf - dh_i_bott(ji) ) / rdt_ice
+         dh_i_bott(ji)  = zdhbf
+         !                     !since ice volume is only used for outputs, we keep it global for all categories
+         dvbbq_1d (ji) = a_i_b(ji) * dh_i_bott(ji)
+         !                     !new ice thickness
+         zhgnew   (ji) = ht_i_b(ji) + dh_i_surf(ji) + dh_i_bott(ji)
+         !                     ! diagnostic ( bottom ice growth )
+         zji = MOD( npb(ji) - 1, jpi ) + 1
+         zjj = ( npb(ji) - 1 ) / jpi + 1
+         diag_bot_gr(zji,zjj) = diag_bot_gr(zji,zjj) + MAX(dh_i_bott(ji),0.0)*a_i_b(ji) / rdt_ice
+         diag_sur_me(zji,zjj) = diag_sur_me(zji,zjj) + MIN(dh_i_surf(ji),0.0)*a_i_b(ji) / rdt_ice
+         diag_bot_me(zji,zjj) = diag_bot_me(zji,zjj) + MIN(dh_i_bott(ji),0.0)*a_i_b(ji) / rdt_ice
+      END DO
+
+      !-----------------------------------
+      ! 5.2 More than available ice melts
+      !-----------------------------------
+      ! then heat applied minus heat content at previous time step
+      ! should equal heat remaining 
+      !
+      DO ji = kideb, kiut
+         ! Adapt the remaining energy if too much ice melts
+         !--------------------------------------------------
+         zihgnew    =  1.0 - MAX( zzero , SIGN( zone , - zhgnew(ji) ) ) !1 if ice
+         ! 0 if no more ice
+         zhgnew    (ji) =         zihgnew   * zhgnew(ji)      ! ice thickness is put to 0
+         ! remaining heat
+         zfdt_final(ji) = ( 1.0 - zihgnew ) * ( zqfont_su(ji) +  zqfont_bo(ji) ) 
+
+         ! If snow remains, energy is used to melt snow
+         zhni =  ht_s_b(ji)      ! snow depth at previous time step
+         zihg =  MAX( zzero , SIGN ( zone , - ht_s_b(ji) ) ) ! 0 if snow 
+
+         ! energy of melting of remaining snow
+         zqt_s(ji) =    ( 1. - zihg ) * zqt_s(ji) / MAX( zhni, epsi13 )
+         zdhnm     =  - ( 1. - zihg ) * ( 1. - zihgnew ) * zfdt_final(ji) / MAX( zqt_s(ji) , epsi13 )
+         zhnfi          =  zhni + zdhnm
+         zfdt_final(ji) =  MAX( zfdt_final(ji) + zqt_s(ji) * zdhnm , 0.0 )
+         ht_s_b(ji)     =  MAX( zzero , zhnfi )
+         zqt_s(ji)      =  zqt_s(ji) * ht_s_b(ji)
+
+         ! Mass variations of ice and snow
+         !---------------------------------
+         !                                              ! mass variation of the jl category
+         zzfmass_s = - a_i_b(ji) * ( zhni       - ht_s_b(ji) ) * rhosn   ! snow
+         zzfmass_i =   a_i_b(ji) * ( zhgnew(ji) - ht_i_b(ji) ) * rhoic   ! ice  
+         !
+         zfmass_i(ji) = zzfmass_i                       ! ice variation saved to compute salt flux (see below)
+         !
+         !                                              ! mass variation cumulated over category
+         rdmsnif_1d(ji) = rdmsnif_1d(ji) + zzfmass_s                     ! snow 
+         rdmicif_1d(ji) = rdmicif_1d(ji) + zzfmass_i                     ! ice 
+
+         ! Remaining heat to the ocean 
+         !---------------------------------
+         focea(ji)  = - zfdt_final(ji) / rdt_ice         ! focea is in W.m-2 * dt
+
+      END DO
+
+      ftotal_fin (:) = zfdt_final(:)  / rdt_ice
+
+      !---------------------------
+      ! Salt flux and heat fluxes                    
+      !---------------------------
+      DO ji = kideb, kiut
+         zihgnew    =  1.0 - MAX( zzero , SIGN( zone , - zhgnew(ji) ) )   !1 if ice
+
+         ! Salt flux
+         zji = MOD( npb(ji) - 1, jpi ) + 1
+         zjj = ( npb(ji) - 1 ) / jpi + 1
+         ! new lines
+         IF( num_sal == 4 ) THEN
+            fseqv_1d(ji) = fseqv_1d(ji) +        zihgnew  * zfsalt_melt(ji)                                &
+               &                        + (1.0 - zihgnew) * zfmass_i(ji) * ( sss_m(zji,zjj) - bulk_sal   ) / rdt_ice
+         ELSE
+            fseqv_1d(ji) = fseqv_1d(ji) +        zihgnew  * zfsalt_melt(ji)                                &
+               &                        + (1.0 - zihgnew) * zfmass_i(ji) * ( sss_m(zji,zjj) - sm_i_b(ji) ) / rdt_ice
+         ENDIF
+         ! Heat flux
+         ! excessive bottom ablation energy (fsup) - 0 except if jpl = 1
+         ! excessive total ablation energy (focea) sent to the ocean
+         qfvbq_1d(ji)  = qfvbq_1d(ji) + fsup(ji) + ( 1.0 - zihgnew ) * focea(ji) * a_i_b(ji) * rdt_ice
+
+         zihic   = 1.0 - MAX( zzero , SIGN( zone , -ht_i_b(ji) ) )
+         ! equals 0 if ht_i = 0, 1 if ht_i gt 0
+         fscbq_1d(ji) =  a_i_b(ji) * fstbif_1d(ji)
+         qldif_1d(ji)  = qldif_1d(ji) + fsup(ji) + ( 1.0 - zihgnew ) * focea(ji)    * a_i_b(ji) * rdt_ice   &
+            &                                    + ( 1.0 - zihic   ) * fscbq_1d(ji)             * rdt_ice
+      END DO  ! ji
+
+      !-------------------------------------------
+      ! Correct temperature, energy and thickness
+      !-------------------------------------------
+      DO ji = kideb, kiut
+         zihgnew    =  1.0 - MAX( zzero , SIGN( zone , - zhgnew(ji) ) ) 
+         t_su_b(ji) =  zihgnew * t_su_b(ji) + ( 1.0 - zihgnew ) * rtt
+      END DO  ! ji
+
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut
+            zihgnew      =  1.0 - MAX( zzero , SIGN( zone , - zhgnew(ji) ) ) 
+            t_i_b(ji,jk) =  zihgnew * t_i_b(ji,jk) + ( 1.0 - zihgnew ) * rtt
+            q_i_b(ji,jk) =  zihgnew * q_i_b(ji,jk)
+         END DO
+      END DO  ! ji
+
+      DO ji = kideb, kiut
+         ht_i_b(ji) = zhgnew(ji)
+      END DO  ! ji
+      !
+      !------------------------------------------------------------------------------|
+      !  6) Snow-Ice formation                                                       |
+      !------------------------------------------------------------------------------|
+      ! When snow load excesses Archimede's limit, snow-ice interface goes down under sea-level, 
+      ! flooding of seawater transforms snow into ice dh_snowice is positive for the ice
+      DO ji = kideb, kiut
+         !
+         dh_snowice(ji) = MAX(  zzero , ( rhosn * ht_s_b(ji) + (rhoic-rau0) * ht_i_b(ji) ) / ( rhosn+rau0-rhoic )  )
+         zhgnew(ji)     = MAX(  zhgnew(ji) , zhgnew(ji) + dh_snowice(ji)  )
+         zhnnew         = MIN(  ht_s_b(ji) , ht_s_b(ji) - dh_snowice(ji)  )
+
+         !  Changes in ice volume and ice mass.
+         dvnbq_1d  (ji) =                a_i_b(ji) * ( zhgnew(ji)-ht_i_b(ji) )
+         dmgwi_1d  (ji) = dmgwi_1d(ji) + a_i_b(ji) * ( ht_s_b(ji) - zhnnew ) * rhosn
+
+         rdmicif_1d(ji) = rdmicif_1d(ji) + a_i_b(ji) * ( zhgnew(ji) - ht_i_b(ji) ) * rhoic 
+         rdmsnif_1d(ji) = rdmsnif_1d(ji) + a_i_b(ji) * ( zhnnew     - ht_s_b(ji) ) * rhosn
+
+         !        Equivalent salt flux (1) Snow-ice formation component
+         !        -----------------------------------------------------
+         zji = MOD( npb(ji) - 1, jpi ) + 1
+         zjj =    ( npb(ji) - 1 ) / jpi + 1
+
+         IF( num_sal /= 2 ) THEN   ;   zsm_snowice = sm_i_b(ji)
+         ELSE                      ;   zsm_snowice = ( rhoic - rhosn ) / rhoic * sss_m(zji,zjj) 
+         ENDIF
+         IF( num_sal == 4 ) THEN
+            fseqv_1d(ji) = fseqv_1d(ji) + ( sss_m(zji,zjj) - bulk_sal    ) * a_i_b(ji)   &
+               &                        * ( zhgnew(ji) - ht_i_b(ji) ) * rhoic / rdt_ice
+         ELSE
+            fseqv_1d(ji) = fseqv_1d(ji) + ( sss_m(zji,zjj) - zsm_snowice ) * a_i_b(ji)   &
+               &                        * ( zhgnew(ji) - ht_i_b(ji) ) * rhoic / rdt_ice
+         ENDIF
+         ! entrapment during snow ice formation
+         i_ice_switch = 1.0 - MAX( 0.e0 , SIGN( 1.0 , - ht_i_b(ji) + 1.0e-6 ) )
+         isnowic      = 1.0 - MAX( 0.e0 , SIGN( 1.0 , - dh_snowice(ji)      ) ) * i_ice_switch
+         IF(  num_sal == 2  .OR.  num_sal == 4  )   &
+            dsm_i_si_1d(ji) = ( zsm_snowice*dh_snowice(ji) &
+            &               + sm_i_b(ji) * ht_i_b(ji) / MAX( ht_i_b(ji) + dh_snowice(ji), epsi13)   &
+            &               - sm_i_b(ji) ) * isnowic     
+
+         !  Actualize new snow and ice thickness.
+         ht_s_b(ji)  = zhnnew
+         ht_i_b(ji)  = zhgnew(ji)
+
+         ! Total ablation ! new lines added to debug
+         IF( ht_i_b(ji) <= 0.e0 )   a_i_b(ji) = 0.0
+
+         ! diagnostic ( snow ice growth )
+         zji = MOD( npb(ji) - 1, jpi ) + 1
+         zjj =    ( npb(ji) - 1 ) / jpi + 1
+         diag_sni_gr(zji,zjj)  = diag_sni_gr(zji,zjj) + dh_snowice(ji)*a_i_b(ji) / rdt_ice
+         !
+      END DO !ji
+
+   END SUBROUTINE lim_thd_dh
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                               NO  LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd_dh          ! Empty routine
+   END SUBROUTINE lim_thd_dh
+#endif
+
+   !!======================================================================
+END MODULE limthd_dh
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dif.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 1844)
@@ -0,0 +1,874 @@
+MODULE limthd_dif
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limthd_dif ***
+   !!                       heat diffusion in sea ice 
+   !!                   computation of surface and inner T  
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst           ! physical constants (ocean directory) 
+   USE thd_ice
+   USE iceini
+   USE limistate
+   USE in_out_manager
+   USE ice
+   USE par_ice
+   USE lib_mpp 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_dif        ! called by lim_thd
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1e-20   ,  &
+      epsi13 = 1e-13   ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_dif( kideb , kiut , jl )
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_dif  ***
+      !! ** Purpose :
+      !!           This routine determines the time evolution of snow and sea-ice 
+      !!           temperature profiles.
+      !! ** Method  :
+      !!           This is done by solving the heat equation diffusion with
+      !!           a Neumann boundary condition at the surface and a Dirichlet one
+      !!           at the bottom. Solar radiation is partially absorbed into the ice.
+      !!           The specific heat and thermal conductivities depend on ice salinity
+      !!           and temperature to take into account brine pocket melting. The 
+      !!           numerical
+      !!           scheme is an iterative Crank-Nicolson on a non-uniform multilayer grid 
+      !!           in the ice and snow system.
+      !!
+      !!           The successive steps of this routine are
+      !!           1.  Thermal conductivity at the interfaces of the ice layers
+      !!           2.  Internal absorbed radiation
+      !!           3.  Scale factors due to non-uniform grid
+      !!           4.  Kappa factors
+      !!           Then iterative procedure begins
+      !!           5.  specific heat in the ice
+      !!           6.  eta factors
+      !!           7.  surface flux computation
+      !!           8.  tridiagonal system terms
+      !!           9.  solving the tridiagonal system with Gauss elimination
+      !!           Iterative procedure ends according to a criterion on evolution
+      !!           of temperature
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!           surface temperature : t_su_b
+      !!           ice/snow temperatures   : t_i_b, t_s_b
+      !!           ice salinities          : s_i_b
+      !!           number of layers in the ice/snow: nlay_i, nlay_s
+      !!           profile of the ice/snow layers : z_i, z_s
+      !!           total ice/snow thickness : ht_i_b, ht_s_b
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (02-2003) Martin Vancoppenolle, Louvain-la-Neuve, Belgium
+      !!           (06-2005) Martin Vancoppenolle, 3d version
+      !!           (11-2006) Vectorized by Xavier Fettweis (UCL-ASTR)
+      !!           (04-2007) Energy conservation tested by M. Vancoppenolle
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      INTEGER , INTENT (in) ::  &
+         kideb ,  &  ! Start point on which the  the computation is applied
+         kiut  ,  &  ! End point on which the  the computation is applied
+         jl          ! Category number
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial loop index
+         zji, zjj, &   ! temporary dummy loop index
+         numeq,    &   ! current reference number of equation
+         layer,    &   ! vertical dummy loop index 
+         nconv,    &   ! number of iterations in iterative procedure
+         minnumeqmin, & !
+         maxnumeqmax
+
+      INTEGER , DIMENSION(kiut) :: &
+         numeqmin, &   ! reference number of top equation
+         numeqmax, &   ! reference number of bottom equation
+         isnow         ! switch for presence (1) or absence (0) of snow
+
+      !! * New local variables       
+      REAL(wp) , DIMENSION(kiut,0:nlay_i) ::    &
+         ztcond_i,    & !Ice thermal conductivity
+         zradtr_i,    & !Radiation transmitted through the ice
+         zradab_i,    & !Radiation absorbed in the ice
+         zkappa_i       !Kappa factor in the ice
+
+      REAL(wp) , DIMENSION(kiut,0:nlay_s) ::    &
+         zradtr_s,    & !Radiation transmited through the snow
+         zradab_s,    & !Radiation absorbed in the snow
+         zkappa_s       !Kappa factor in the snow
+
+      REAL(wp) , DIMENSION(kiut,0:nlay_i) :: &
+         ztiold,      & !Old temperature in the ice
+         zeta_i,      & !Eta factor in the ice 
+         ztitemp,     & !Temporary temperature in the ice to check the convergence
+         zspeche_i,   & !Ice specific heat
+         z_i            !Vertical cotes of the layers in the ice
+
+      REAL(wp) , DIMENSION(kiut,0:nlay_s) :: &
+         zeta_s,      & !Eta factor in the snow
+         ztstemp,     & !Temporary temperature in the snow to check the convergence
+         ztsold,      & !Temporary temperature in the snow
+         z_s            !Vertical cotes of the layers in the snow
+
+      REAL(wp) , DIMENSION(kiut,jkmax+2) ::    &
+         zindterm,    & ! Independent term
+         zindtbis,    & ! temporary independent term
+         zdiagbis
+
+      REAL(wp) , DIMENSION(kiut,jkmax+2,3) ::  &
+         ztrid          ! tridiagonal system terms
+
+      REAL(wp), DIMENSION(kiut) ::  &
+         ztfs     ,   & ! ice melting point
+         ztsuold  ,   & ! old surface temperature (before the iterative
+                                !          procedure )
+         ztsuoldit,   & ! surface temperature at previous iteration
+         zh_i     ,   & !ice layer thickness
+         zh_s     ,   & !snow layer thickness
+         zfsw     ,   & !solar radiation absorbed at the surface
+         zf       ,   & ! surface flux function
+         dzf            ! derivative of the surface flux function
+
+      REAL(wp)  ::           &  ! constant values
+         zeps      =  1.0e-10,   & !
+         zg1s      =  2.0,       & !: for the tridiagonal system
+         zg1       =  2.0,       &
+         zgamma    =  18009.0,   & !: for specific heat
+         zbeta     =  0.117,     & !: for thermal conductivity (could be 0.13)
+         zraext_s  =  1.0e08,    & !: extinction coefficient of radiation in the snow
+         zkimin    =  0.10 ,     & !: minimum ice thermal conductivity
+         zht_smin  =  1.0e-4       !: minimum snow depth
+
+      REAL(wp)  ::          &  ! local variables 
+         ztmelt_i,           &  ! ice melting temperature
+         zerritmax              ! current maximal error on temperature 
+
+      REAL(wp), DIMENSION(kiut)  :: &
+         zerrit,             &  ! current error on temperature 
+         zdifcase,           &  ! case of the equation resolution (1->4)
+         zftrice,            &  ! solar radiation transmitted through the ice
+         zihic, zhsu
+
+      !
+      !------------------------------------------------------------------------------!
+      ! 1) Initialization                                                            !
+      !------------------------------------------------------------------------------!
+      !
+      DO ji = kideb , kiut
+         ! is there snow or not
+         isnow(ji)= INT ( 1.0 - MAX( 0.0 , SIGN (1.0, - ht_s_b(ji) ) ) )
+         ! surface temperature of fusion
+         ztfs(ji) = isnow(ji) * rtt + (1.0-isnow(ji)) * rtt
+         ! layer thickness
+         zh_i(ji)              = ht_i_b(ji) / nlay_i
+         zh_s(ji)              = ht_s_b(ji) / nlay_s
+      END DO
+
+      !--------------------
+      ! Ice / snow layers
+      !--------------------
+
+      z_s(:,0)      = 0.0 ! vert. coord. of the up. lim. of the 1st snow layer
+      z_i(:,0)      = 0.0 ! vert. coord. of the up. lim. of the 1st ice layer
+
+      DO layer = 1, nlay_s
+         DO ji = kideb , kiut
+            ! vert. coord of the up. lim. of the layer-th snow layer
+            z_s(ji,layer)      = z_s(ji,layer-1) + ht_s_b(ji) / nlay_s
+         END DO
+      END DO
+
+      DO layer = 1, nlay_i
+         DO ji = kideb , kiut
+            ! vert. coord of the up. lim. of the layer-th ice layer
+            z_i(ji,layer)      = z_i(ji,layer-1) + ht_i_b(ji) / nlay_i
+         END DO
+      END DO
+      !
+      !------------------------------------------------------------------------------|
+      ! 2) Radiations                                                                |
+      !------------------------------------------------------------------------------|
+      !
+      !-------------------
+      ! Computation of i0
+      !-------------------
+      ! i0 describes the fraction of solar radiation which does not contribute
+      ! to the surface energy budget but rather penetrates inside the ice.
+      ! We assume that no radiation is transmitted through the snow
+      ! If there is no no snow
+      ! zfsw    = (1-i0).qsr_ice   is absorbed at the surface 
+      ! zftrice = io.qsr_ice       is below the surface 
+      ! fstbif  = io.qsr_ice.exp(-k(h_i)) transmitted below the ice 
+
+      DO ji = kideb , kiut
+         ! switches
+         isnow(ji)  = INT ( 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - ht_s_b(ji) ) ) ) 
+         ! hs > 0, isnow = 1
+         zhsu(ji)   = hnzst  !threshold for the computation of i0
+         zihic(ji)  = MAX( zzero , 1.0 - ( ht_i_b(ji) / zhsu(ji) ) )     
+
+         i0(ji)     = ( 1.0 - isnow(ji) ) * &
+            ( fr1_i0_1d(ji) + zihic(ji) * fr2_i0_1d(ji) )
+         !fr1_i0_1d = i0 for a thin ice surface
+         !fr1_i0_2d = i0 for a thick ice surface
+         !            a function of the cloud cover
+         !
+         !i0(ji)     =  (1.0-FLOAT(isnow(ji)))*3.0/(100*ht_s_b(ji)+10.0)
+         !formula used in Cice
+      END DO
+
+      !-------------------------------------------------------
+      ! Solar radiation absorbed / transmitted at the surface
+      ! Derivative of the non solar flux
+      !-------------------------------------------------------
+      DO ji = kideb , kiut
+
+         ! Shortwave radiation absorbed at surface
+         zfsw(ji)   =  qsr_ice_1d(ji) * ( 1 - i0(ji) )
+
+         ! Solar radiation transmitted below the surface layer
+         zftrice(ji)=  qsr_ice_1d(ji) * i0(ji)
+
+         ! derivative of incoming nonsolar flux 
+         dzf(ji)   =    dqns_ice_1d(ji)  
+
+      END DO
+
+      !---------------------------------------------------------
+      ! Transmission - absorption of solar radiation in the ice
+      !---------------------------------------------------------
+
+      DO ji = kideb , kiut
+         ! Initialization
+         zradtr_s(ji,0) = zftrice(ji) ! radiation penetrating through snow
+      END DO
+
+      ! Radiation through snow
+      DO layer = 1, nlay_s
+         DO ji = kideb , kiut
+            ! radiation transmitted below the layer-th snow layer
+            zradtr_s(ji,layer) = zradtr_s(ji,0) * EXP ( - zraext_s * ( MAX ( 0.0 , &
+               z_s(ji,layer) ) ) )
+            ! radiation absorbed by the layer-th snow layer
+            zradab_s(ji,layer) = zradtr_s(ji,layer-1) - zradtr_s(ji,layer)
+         END DO
+      END DO
+
+      ! Radiation through ice
+      DO ji = kideb , kiut
+         zradtr_i(ji,0)        = zradtr_s(ji,nlay_s) * isnow(ji) + & 
+            zftrice(ji) * ( 1 - isnow(ji) )
+      END DO
+
+      DO layer = 1, nlay_i
+         DO ji = kideb , kiut
+            ! radiation transmitted below the layer-th ice layer
+            zradtr_i(ji,layer) = zradtr_i(ji,0) * EXP ( - kappa_i * ( MAX ( 0.0 , &
+               z_i(ji,layer) ) ) )
+            ! radiation absorbed by the layer-th ice layer
+            zradab_i(ji,layer) = zradtr_i(ji,layer-1) - zradtr_i(ji,layer)
+         END DO
+      END DO
+
+      ! Radiation transmitted below the ice
+      DO ji = kideb , kiut
+         fstbif_1d(ji)  =  fstbif_1d(ji) + &
+            zradtr_i(ji,nlay_i) * a_i_b(ji) / at_i_b(ji)
+      END DO
+
+      ! +++++
+      ! just to check energy conservation
+      DO ji = kideb , kiut
+         zji                 = MOD( npb(ji) - 1, jpi ) + 1
+         zjj                 = ( npb(ji) - 1 ) / jpi + 1
+         fstroc(zji,zjj,jl)  = &
+            zradtr_i(ji,nlay_i)
+      END DO
+      ! +++++
+
+      DO layer = 1, nlay_i
+         DO ji = kideb , kiut
+            radab(ji,layer) = zradab_i(ji,layer)
+         END DO
+      END DO
+
+
+      !
+      !------------------------------------------------------------------------------|
+      !  3) Iterative procedure begins                                               |
+      !------------------------------------------------------------------------------|
+      !
+      ! Old surface temperature
+      DO ji = kideb, kiut
+         ztsuold(ji)          =  t_su_b(ji) ! temperature at the beg of iter pr.
+         ztsuoldit(ji)        =  t_su_b(ji) ! temperature at the previous iter
+         t_su_b(ji)           =  MIN(t_su_b(ji),ztfs(ji)-0.00001) !necessary
+         zerrit(ji)           =  1000.0     ! initial value of error
+      END DO
+      !RB Min global ??
+
+      ! Old snow temperature
+      DO layer = 1, nlay_s
+         DO ji = kideb , kiut
+            ztsold(ji,layer)     =  t_s_b(ji,layer)
+         END DO
+      END DO
+
+      ! Old ice temperature
+      DO layer = 1, nlay_i
+         DO ji = kideb , kiut
+            ztiold(ji,layer)     =  t_i_b(ji,layer)
+         END DO
+      END DO
+
+      nconv     =  0         ! number of iterations
+      zerritmax =  1000.0    ! maximal value of error on all points
+
+      DO WHILE ((zerritmax > maxer_i_thd).AND.(nconv < nconv_i_thd))
+
+         nconv   =  nconv+1
+
+         !
+         !------------------------------------------------------------------------------|
+         ! 4) Sea ice thermal conductivity                                              |
+         !------------------------------------------------------------------------------|
+         !
+         IF ( thcon_i_swi .EQ. 0 ) THEN
+            ! Untersteiner (1964) formula
+            DO ji = kideb , kiut
+               ztcond_i(ji,0)        = rcdic + zbeta*s_i_b(ji,1) / &
+                  MIN(-zeps,t_i_b(ji,1)-rtt)
+               ztcond_i(ji,0)        = MAX(ztcond_i(ji,0),zkimin)
+            END DO
+         ENDIF
+
+         IF ( thcon_i_swi .EQ. 1 ) THEN
+            ! Pringle et al formula included,
+            ! 2.11 + 0.09 S/T - 0.011.T
+            DO ji = kideb , kiut
+               ztcond_i(ji,0)        = rcdic + 0.09*s_i_b(ji,1) / &
+                  MIN(-zeps,t_i_b(ji,1)-rtt) - &
+                  0.011* ( t_i_b(ji,1) - rtt )  
+               ztcond_i(ji,0)        = MAX(ztcond_i(ji,0),zkimin)
+            END DO
+         ENDIF
+
+         IF ( thcon_i_swi .EQ. 0 ) THEN ! Untersteiner
+            DO layer = 1, nlay_i-1
+               DO ji = kideb , kiut
+                  ztcond_i(ji,layer) = rcdic + zbeta*( s_i_b(ji,layer) &
+                     + s_i_b(ji,layer+1) ) / MIN(-zeps,     &
+                     t_i_b(ji,layer)+t_i_b(ji,layer+1)-2.0*rtt)
+                  ztcond_i(ji,layer)   = MAX(ztcond_i(ji,layer),zkimin)
+               END DO
+            END DO
+         ENDIF
+
+         IF ( thcon_i_swi .EQ. 1 ) THEN ! Pringle
+            DO layer = 1, nlay_i-1
+               DO ji = kideb , kiut
+                  ztcond_i(ji,layer) = rcdic + 0.09*( s_i_b(ji,layer)   &
+                     + s_i_b(ji,layer+1) ) / MIN(-zeps,      &
+                     t_i_b(ji,layer)+t_i_b(ji,layer+1)-2.0*rtt) - &
+                     0.011* ( t_i_b(ji,layer) + t_i_b(ji,layer+1) - 2.0*rtt )  
+                  ztcond_i(ji,layer) = MAX(ztcond_i(ji,layer),zkimin)
+               END DO
+            END DO
+         ENDIF
+
+         IF ( thcon_i_swi .EQ. 0 ) THEN ! Untersteiner
+            DO ji = kideb , kiut
+               ztcond_i(ji,nlay_i)   = rcdic + zbeta*s_i_b(ji,nlay_i) / &
+                  MIN(-zeps,t_bo_b(ji)-rtt)
+               ztcond_i(ji,nlay_i)   = MAX(ztcond_i(ji,nlay_i),zkimin)
+            END DO
+         ENDIF
+
+         IF ( thcon_i_swi .EQ. 1 ) THEN ! Pringle
+            DO ji = kideb , kiut
+               ztcond_i(ji,nlay_i)   = rcdic + 0.09*s_i_b(ji,nlay_i) / &
+                  MIN(-zeps,t_bo_b(ji)-rtt) - &
+                  0.011* ( t_bo_b(ji) - rtt )  
+               ztcond_i(ji,nlay_i)   = MAX(ztcond_i(ji,nlay_i),zkimin)
+            END DO
+         ENDIF
+         !
+         !------------------------------------------------------------------------------|
+         !  5) kappa factors                                                            |
+         !------------------------------------------------------------------------------|
+         !
+         DO ji = kideb, kiut
+
+            !-- Snow kappa factors
+            zkappa_s(ji,0)         = rcdsn / MAX(zeps,zh_s(ji))
+            zkappa_s(ji,nlay_s)    = rcdsn / MAX(zeps,zh_s(ji))
+         END DO
+
+         DO layer = 1, nlay_s-1
+            DO ji = kideb , kiut
+               zkappa_s(ji,layer)  = 2.0 * rcdsn / &
+                  MAX(zeps,2.0*zh_s(ji))
+            END DO
+         END DO
+
+         DO layer = 1, nlay_i-1
+            DO ji = kideb , kiut
+               !-- Ice kappa factors
+               zkappa_i(ji,layer)  = 2.0*ztcond_i(ji,layer)/ &
+                  MAX(zeps,2.0*zh_i(ji)) 
+            END DO
+         END DO
+
+         DO ji = kideb , kiut
+            zkappa_i(ji,0)        = ztcond_i(ji,0)/MAX(zeps,zh_i(ji))
+            zkappa_i(ji,nlay_i)   = ztcond_i(ji,nlay_i) / MAX(zeps,zh_i(ji))
+            !-- Interface
+            zkappa_s(ji,nlay_s)   = 2.0*rcdsn*ztcond_i(ji,0)/MAX(zeps, &
+               (ztcond_i(ji,0)*zh_s(ji) + rcdsn*zh_i(ji)))
+            zkappa_i(ji,0)        = zkappa_s(ji,nlay_s)*isnow(ji) &
+               + zkappa_i(ji,0)*(1.0-isnow(ji))
+         END DO
+         !
+         !------------------------------------------------------------------------------|
+         ! 6) Sea ice specific heat, eta factors                                        |
+         !------------------------------------------------------------------------------|
+         !
+         DO layer = 1, nlay_i
+            DO ji = kideb , kiut
+               ztitemp(ji,layer)   = t_i_b(ji,layer)
+               zspeche_i(ji,layer) = cpic + zgamma*s_i_b(ji,layer)/ &
+                  MAX((t_i_b(ji,layer)-rtt)*(ztiold(ji,layer)-rtt),zeps)
+               zeta_i(ji,layer)    = rdt_ice / MAX(rhoic*zspeche_i(ji,layer)*zh_i(ji), &
+                  zeps)
+            END DO
+         END DO
+
+         DO layer = 1, nlay_s
+            DO ji = kideb , kiut
+               ztstemp(ji,layer) = t_s_b(ji,layer)
+               zeta_s(ji,layer)  = rdt_ice / MAX(rhosn*cpic*zh_s(ji),zeps)
+            END DO
+         END DO
+         !
+         !------------------------------------------------------------------------------|
+         ! 7) surface flux computation                                                  |
+         !------------------------------------------------------------------------------|
+         !
+         DO ji = kideb , kiut
+
+            ! update of the non solar flux according to the update in T_su
+            qnsr_ice_1d(ji) = qnsr_ice_1d(ji) + dqns_ice_1d(ji) * & 
+               ( t_su_b(ji) - ztsuoldit(ji) )
+
+            ! update incoming flux
+            zf(ji)    =   zfsw(ji)              & ! net absorbed solar radiation
+               + qnsr_ice_1d(ji)           ! non solar total flux 
+            ! (LWup, LWdw, SH, LH)
+
+         END DO
+
+         !
+         !------------------------------------------------------------------------------|
+         ! 8) tridiagonal system terms                                                  |
+         !------------------------------------------------------------------------------|
+         !
+         !!layer denotes the number of the layer in the snow or in the ice
+         !!numeq denotes the reference number of the equation in the tridiagonal
+         !!system, terms of tridiagonal system are indexed as following :
+         !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
+
+         !!ice interior terms (top equation has the same form as the others)
+
+         DO numeq=1,jkmax+2
+            DO ji = kideb , kiut
+               ztrid(ji,numeq,1) = 0.
+               ztrid(ji,numeq,2) = 0.
+               ztrid(ji,numeq,3) = 0.
+               zindterm(ji,numeq)= 0.
+               zindtbis(ji,numeq)= 0.
+               zdiagbis(ji,numeq)= 0.
+            ENDDO
+         ENDDO
+
+         DO numeq = nlay_s + 2, nlay_s + nlay_i 
+            DO ji = kideb , kiut
+               layer              = numeq - nlay_s - 1
+               ztrid(ji,numeq,1)  =  - zeta_i(ji,layer)*zkappa_i(ji,layer-1)
+               ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,layer)*(zkappa_i(ji,layer-1) + &
+                  zkappa_i(ji,layer))
+               ztrid(ji,numeq,3)  =  - zeta_i(ji,layer)*zkappa_i(ji,layer)
+               zindterm(ji,numeq) =  ztiold(ji,layer) + zeta_i(ji,layer)* &
+                  zradab_i(ji,layer)
+            END DO
+         ENDDO
+
+         numeq =  nlay_s + nlay_i + 1
+         DO ji = kideb , kiut
+            !!ice bottom term
+            ztrid(ji,numeq,1)  =  - zeta_i(ji,nlay_i)*zkappa_i(ji,nlay_i-1)   
+            ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,nlay_i)*( zkappa_i(ji,nlay_i)*zg1 &
+               +  zkappa_i(ji,nlay_i-1) )
+            ztrid(ji,numeq,3)  =  0.0
+            zindterm(ji,numeq) =  ztiold(ji,nlay_i) + zeta_i(ji,nlay_i)* &
+               ( zradab_i(ji,nlay_i) + zkappa_i(ji,nlay_i)*zg1 &
+               *  t_bo_b(ji) ) 
+         ENDDO
+
+
+         DO ji = kideb , kiut
+            IF ( ht_s_b(ji).gt.0.0 ) THEN
+               !
+               !------------------------------------------------------------------------------|
+               !  snow-covered cells                                                          |
+               !------------------------------------------------------------------------------|
+               !
+               !!snow interior terms (bottom equation has the same form as the others)
+               DO numeq = 3, nlay_s + 1
+                  layer =  numeq - 1
+                  ztrid(ji,numeq,1)   =  - zeta_s(ji,layer)*zkappa_s(ji,layer-1)
+                  ztrid(ji,numeq,2)   =  1.0 + zeta_s(ji,layer)*( zkappa_s(ji,layer-1) + &
+                     zkappa_s(ji,layer) )
+                  ztrid(ji,numeq,3)   =  - zeta_s(ji,layer)*zkappa_s(ji,layer)
+                  zindterm(ji,numeq)  =  ztsold(ji,layer) + zeta_s(ji,layer)* &
+                     zradab_s(ji,layer)
+               END DO
+
+               !!case of only one layer in the ice (ice equation is altered)
+               IF ( nlay_i.eq.1 ) THEN
+                  ztrid(ji,nlay_s+2,3)    =  0.0
+                  zindterm(ji,nlay_s+2)   =  zindterm(ji,nlay_s+2) + zkappa_i(ji,1)* &
+                     t_bo_b(ji) 
+               ENDIF
+
+               IF ( t_su_b(ji) .LT. rtt ) THEN
+
+                  !------------------------------------------------------------------------------|
+                  !  case 1 : no surface melting - snow present                                  |
+                  !------------------------------------------------------------------------------|
+                  zdifcase(ji)    =  1.0
+                  numeqmin(ji)    =  1
+                  numeqmax(ji)    =  nlay_i + nlay_s + 1
+
+                  !!surface equation
+                  ztrid(ji,1,1) = 0.0
+                  ztrid(ji,1,2) = dzf(ji) - zg1s*zkappa_s(ji,0)
+                  ztrid(ji,1,3) = zg1s*zkappa_s(ji,0)
+                  zindterm(ji,1) = dzf(ji)*t_su_b(ji)   - zf(ji)
+
+                  !!first layer of snow equation
+                  ztrid(ji,2,1)  =  - zkappa_s(ji,0)*zg1s*zeta_s(ji,1)
+                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1)*(zkappa_s(ji,1) + zkappa_s(ji,0)*zg1s)
+                  ztrid(ji,2,3)  =  - zeta_s(ji,1)* zkappa_s(ji,1)
+                  zindterm(ji,2) =  ztsold(ji,1) + zeta_s(ji,1)*zradab_s(ji,1)
+
+               ELSE 
+                  !
+                  !------------------------------------------------------------------------------|
+                  !  case 2 : surface is melting - snow present                                  |
+                  !------------------------------------------------------------------------------|
+                  !
+                  zdifcase(ji)    =  2.0
+                  numeqmin(ji)    =  2
+                  numeqmax(ji)    =  nlay_i + nlay_s + 1
+
+                  !!first layer of snow equation
+                  ztrid(ji,2,1)  =  0.0
+                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + &
+                     zkappa_s(ji,0) * zg1s )
+                  ztrid(ji,2,3)  =  - zeta_s(ji,1)*zkappa_s(ji,1) 
+                  zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) *            &
+                     ( zradab_s(ji,1) +                         &
+                     zkappa_s(ji,0) * zg1s * t_su_b(ji) ) 
+               ENDIF
+            ELSE
+               !
+               !------------------------------------------------------------------------------|
+               !  cells without snow                                                          |
+               !------------------------------------------------------------------------------|
+               !
+               IF (t_su_b(ji) .LT. rtt) THEN
+                  !
+                  !------------------------------------------------------------------------------|
+                  !  case 3 : no surface melting - no snow                                       |
+                  !------------------------------------------------------------------------------|
+                  !
+                  zdifcase(ji)      =  3.0
+                  numeqmin(ji)      =  nlay_s + 1
+                  numeqmax(ji)      =  nlay_i + nlay_s + 1
+
+                  !!surface equation	
+                  ztrid(ji,numeqmin(ji),1)   =  0.0
+                  ztrid(ji,numeqmin(ji),2)   =  dzf(ji) - zkappa_i(ji,0)*zg1    
+                  ztrid(ji,numeqmin(ji),3)   =  zkappa_i(ji,0)*zg1
+                  zindterm(ji,numeqmin(ji))  =  dzf(ji)*t_su_b(ji) - zf(ji)
+
+                  !!first layer of ice equation
+                  ztrid(ji,numeqmin(ji)+1,1) =  - zkappa_i(ji,0) * zg1 * zeta_i(ji,1)
+                  ztrid(ji,numeqmin(ji)+1,2) =  1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) & 
+                     + zkappa_i(ji,0) * zg1 )
+                  ztrid(ji,numeqmin(ji)+1,3) =  - zeta_i(ji,1)*zkappa_i(ji,1)  
+                  zindterm(ji,numeqmin(ji)+1)=  ztiold(ji,1) + zeta_i(ji,1)*zradab_i(ji,1)  
+
+                  !!case of only one layer in the ice (surface & ice equations are altered)
+
+                  IF (nlay_i.eq.1) THEN
+                     ztrid(ji,numeqmin(ji),1)    =  0.0
+                     ztrid(ji,numeqmin(ji),2)    =  dzf(ji) - zkappa_i(ji,0)*2.0
+                     ztrid(ji,numeqmin(ji),3)    =  zkappa_i(ji,0)*2.0
+                     ztrid(ji,numeqmin(ji)+1,1)  =  -zkappa_i(ji,0)*2.0*zeta_i(ji,1)
+                     ztrid(ji,numeqmin(ji)+1,2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
+                        zkappa_i(ji,1))
+                     ztrid(ji,numeqmin(ji)+1,3)  =  0.0
+
+                     zindterm(ji,numeqmin(ji)+1) =  ztiold(ji,1) + zeta_i(ji,1)* &
+                        ( zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_b(ji) )
+                  ENDIF
+
+               ELSE
+
+                  !
+                  !------------------------------------------------------------------------------|
+                  ! case 4 : surface is melting - no snow                                        |
+                  !------------------------------------------------------------------------------|
+                  !
+                  zdifcase(ji)    =  4.0
+                  numeqmin(ji)    =  nlay_s + 2
+                  numeqmax(ji)    =  nlay_i + nlay_s + 1
+
+                  !!first layer of ice equation
+                  ztrid(ji,numeqmin(ji),1)      =  0.0
+                  ztrid(ji,numeqmin(ji),2)      =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,1) + zkappa_i(ji,0)* &
+                     zg1)  
+                  ztrid(ji,numeqmin(ji),3)      =  - zeta_i(ji,1) * zkappa_i(ji,1)
+                  zindterm(ji,numeqmin(ji))     =  ztiold(ji,1) + zeta_i(ji,1)*( zradab_i(ji,1) + &
+                     zkappa_i(ji,0) * zg1 * t_su_b(ji) ) 
+
+                  !!case of only one layer in the ice (surface & ice equations are altered)
+                  IF (nlay_i.eq.1) THEN
+                     ztrid(ji,numeqmin(ji),1)  =  0.0
+                     ztrid(ji,numeqmin(ji),2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
+                        zkappa_i(ji,1))
+                     ztrid(ji,numeqmin(ji),3)  =  0.0
+                     zindterm(ji,numeqmin(ji)) =  ztiold(ji,1) + zeta_i(ji,1)* &
+                        (zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_b(ji)) &
+                        + t_su_b(ji)*zeta_i(ji,1)*zkappa_i(ji,0)*2.0
+                  ENDIF
+
+               ENDIF
+            ENDIF
+
+         END DO
+
+         !
+         !------------------------------------------------------------------------------|
+         ! 9) tridiagonal system solving                                                |
+         !------------------------------------------------------------------------------|
+         !
+
+         ! Solve the tridiagonal system with Gauss elimination method.
+         ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON, 
+         ! McGraw-Hill 1984.	
+
+         maxnumeqmax = 0
+         minnumeqmin = jkmax+4
+
+         DO ji = kideb , kiut
+            zindtbis(ji,numeqmin(ji)) =  zindterm(ji,numeqmin(ji))
+            zdiagbis(ji,numeqmin(ji)) =  ztrid(ji,numeqmin(ji),2)
+            minnumeqmin               =  MIN(numeqmin(ji),minnumeqmin)
+            maxnumeqmax               =  MAX(numeqmax(ji),maxnumeqmax)
+         END DO
+
+         DO layer = minnumeqmin+1, maxnumeqmax
+            DO ji = kideb , kiut
+               numeq               =  min(max(numeqmin(ji)+1,layer),numeqmax(ji))
+               zdiagbis(ji,numeq)  =  ztrid(ji,numeq,2) - ztrid(ji,numeq,1)* &
+                  ztrid(ji,numeq-1,3)/zdiagbis(ji,numeq-1)
+               zindtbis(ji,numeq)  =  zindterm(ji,numeq) - ztrid(ji,numeq,1)* &
+                  zindtbis(ji,numeq-1)/zdiagbis(ji,numeq-1)
+            END DO
+         END DO
+
+         DO ji = kideb , kiut
+            ! ice temperatures
+            t_i_b(ji,nlay_i)    =  zindtbis(ji,numeqmax(ji))/zdiagbis(ji,numeqmax(ji))
+         END DO
+
+         DO numeq = nlay_i + nlay_s + 1, nlay_s + 2, -1
+            DO ji = kideb , kiut
+               layer    =  numeq - nlay_s - 1
+               t_i_b(ji,layer)  =  (zindtbis(ji,numeq) - ztrid(ji,numeq,3)* &
+                  t_i_b(ji,layer+1))/zdiagbis(ji,numeq)
+            END DO
+         END DO
+
+         DO ji = kideb , kiut
+            ! snow temperatures      
+            IF (ht_s_b(ji).GT.0) &
+               t_s_b(ji,nlay_s)     =  (zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) &
+               *  t_i_b(ji,1))/zdiagbis(ji,nlay_s+1) &
+               *        MAX(0.0,SIGN(1.0,ht_s_b(ji)-zeps)) 
+
+            ! surface temperature
+            isnow(ji)            = INT(1.0-max(0.0,sign(1.0,-ht_s_b(ji))))
+            ztsuoldit(ji)        = t_su_b(ji)
+            IF (t_su_b(ji) .LT. ztfs(ji)) &
+               t_su_b(ji)           = ( zindtbis(ji,numeqmin(ji)) - ztrid(ji,numeqmin(ji),3)* &
+               ( isnow(ji)*t_s_b(ji,1) + &
+               (1.0-isnow(ji))*t_i_b(ji,1) ) ) / &
+               zdiagbis(ji,numeqmin(ji))  
+         END DO
+         !
+         !--------------------------------------------------------------------------
+         !  10) Has the scheme converged ?, end of the iterative procedure         |
+         !--------------------------------------------------------------------------
+         !
+         ! check that nowhere it has started to melt
+         ! zerrit(ji) is a measure of error, it has to be under maxer_i_thd
+         DO ji = kideb , kiut
+            t_su_b(ji)          =  MAX(MIN(t_su_b(ji),ztfs(ji)),190.0)
+            zerrit(ji)          =  ABS(t_su_b(ji)-ztsuoldit(ji))     
+         END DO
+
+         DO layer  =  1, nlay_s
+            DO ji = kideb , kiut
+               zji                 = MOD( npb(ji) - 1, jpi ) + 1
+               zjj                 = ( npb(ji) - 1 ) / jpi + 1
+               t_s_b(ji,layer)  =  MAX(MIN(t_s_b(ji,layer),rtt),190.0)
+               zerrit(ji)       =  MAX(zerrit(ji),ABS(t_s_b(ji,layer) &
+                  -  ztstemp(ji,layer)))
+            END DO
+         END DO
+
+         DO layer  =  1, nlay_i
+            DO ji = kideb , kiut
+               ztmelt_i         = -tmut*s_i_b(ji,layer) +rtt 
+               t_i_b(ji,layer)  =  MAX(MIN(t_i_b(ji,layer),ztmelt_i),190.0)
+               zerrit(ji)       =  MAX(zerrit(ji),ABS(t_i_b(ji,layer) - ztitemp(ji,layer)))
+            END DO
+         END DO
+
+         ! Compute spatial maximum over all errors
+         ! note that this could be optimized substantially by iterating only
+         ! the non-converging points
+         zerritmax = 0.0
+         DO ji = kideb , kiut
+            zerritmax           =  MAX(zerritmax,zerrit(ji))   
+         END DO
+         IF( lk_mpp ) CALL mpp_max(zerritmax, kcom=ncomm_ice)
+
+      END DO  ! End of the do while iterative procedure
+
+      IF( ln_nicep ) THEN
+         WRITE(numout,*) ' zerritmax : ', zerritmax
+         WRITE(numout,*) ' nconv     : ', nconv
+      ENDIF
+
+      !
+      !--------------------------------------------------------------------------
+      !   11) Fluxes at the interfaces                                          |
+      !--------------------------------------------------------------------------
+      !
+      DO ji = kideb, kiut
+         ! update of latent heat fluxes
+         qla_ice_1d (ji) = qla_ice_1d (ji) + &
+            dqla_ice_1d(ji) * ( t_su_b(ji) - ztsuold(ji) )
+
+         ! surface ice conduction flux
+         isnow(ji)       = int(1.0-max(0.0,sign(1.0,-ht_s_b(ji))))
+         fc_su(ji)       =  - isnow(ji)*zkappa_s(ji,0)*zg1s*(t_s_b(ji,1) - &
+            t_su_b(ji)) &
+            - (1.0-isnow(ji))*zkappa_i(ji,0)*zg1* &
+            (t_i_b(ji,1) - t_su_b(ji))
+
+         ! bottom ice conduction flux
+         fc_bo_i(ji)     =  - zkappa_i(ji,nlay_i)* &
+            ( zg1*(t_bo_b(ji) - t_i_b(ji,nlay_i)) )
+
+      END DO
+
+      !-------------------------!
+      ! Heat conservation       !
+      !-------------------------!
+      IF ( con_i ) THEN
+
+         DO ji = kideb, kiut
+            ! Upper snow value
+            fc_s(ji,0) = - isnow(ji)* &
+               zkappa_s(ji,0) * zg1s * ( t_s_b(ji,1) - &
+               t_su_b(ji) ) 
+            ! Bott. snow value
+            fc_s(ji,1) = - isnow(ji)* &
+               zkappa_s(ji,1) * ( t_i_b(ji,1) - &
+               t_s_b(ji,1) ) 
+         END DO
+
+         ! Upper ice layer
+         DO ji = kideb, kiut
+            fc_i(ji,0) = - isnow(ji) * &  ! interface flux if there is snow
+               ( zkappa_i(ji,0)  * ( t_i_b(ji,1) - t_s_b(ji,nlay_s ) ) ) &
+               - ( 1.0 - isnow(ji) ) * ( zkappa_i(ji,0) * & 
+               zg1 * ( t_i_b(ji,1) - t_su_b(ji) ) ) ! upper flux if not
+         END DO
+
+         ! Internal ice layers
+         DO layer = 1, nlay_i - 1
+            DO ji = kideb, kiut
+               fc_i(ji,layer) = - zkappa_i(ji,layer) * ( t_i_b(ji,layer+1) - &
+                  t_i_b(ji,layer) )
+               zji                 = MOD( npb(ji) - 1, jpi ) + 1
+               zjj                 = ( npb(ji) - 1 ) / jpi + 1
+            END DO
+         END DO
+
+         ! Bottom ice layers
+         DO ji = kideb, kiut
+            fc_i(ji,nlay_i) = - zkappa_i(ji,nlay_i)* &
+               ( zg1*(t_bo_b(ji) - t_i_b(ji,nlay_i)) )
+         END DO
+
+      ENDIF
+
+   END SUBROUTINE lim_thd_dif
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_dif   ***
+   !!                              no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_dif          ! Empty routine
+   END SUBROUTINE lim_thd_dif
+#endif
+END MODULE limthd_dif
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_ent.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_ent.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_ent.F90	(revision 1844)
@@ -0,0 +1,744 @@
+MODULE limthd_ent
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limthd_ent   ***
+   !!                  Redistribution of Enthalpy in the ice
+   !!                        on the new vertical grid
+   !!                       after vertical growth/decay
+   !!======================================================================
+   !!   lim_thd_ent : ice redistribution of enthalpy
+
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE dom_oce
+   USE domain
+   USE in_out_manager
+   USE phycst
+   USE thd_ice
+   USE iceini
+   USE limistate
+   USE ice
+   USE limvar
+   USE par_ice
+   USE lib_mpp 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC  lim_thd_ent     ! called by lim_thd
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1.e-20  ,  &
+      epsi13 = 1.e-13  ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0    ,  &
+      epsi10 = 1.0e-10
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-LOCEAN-IPSL (2005)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_ent(kideb,kiut,jl)
+      !!-------------------------------------------------------------------
+      !!               ***   ROUTINE lim_thd_ent  ***
+      !!
+      !! ** Purpose :
+      !!           This routine computes new vertical grids 
+      !!           in the ice and in the snow, and consistently redistributes 
+      !!           temperatures in the snow / ice. 
+      !!           Redistribution is made so as to ensure to energy conservation
+      !!
+      !!
+      !! ** Method  : linear conservative remapping
+      !!           
+      !! ** Steps : 1) Grid
+      !!            2) Switches
+      !!            3) Snow redistribution
+      !!            4) Ice enthalpy redistribution
+      !!            5) Ice salinity, recover temperature
+      !!
+      !! ** Arguments
+      !!
+      !! ** Inputs / Outputs
+      !!
+      !! ** External
+      !!
+      !! ** References : Bitz & Lipscomb, JGR 99; Vancoppenolle et al., GRL, 2005
+      !!
+      !! ** History  : (05-2003) Martin V. UCL-Astr
+      !!               (07-2005) Martin for 3d adapatation
+      !!               (11-2006) Vectorized by Xavier Fettweis (ASTR)
+      !!               (03-2008) Energy conservation and clean code
+      !! * Arguments
+
+      INTEGER , INTENT(IN)::  &
+         kideb          ,   &  ! start point on which the the computation is applied
+         kiut           ,   &  ! end point on which the the computation is applied
+         jl                    ! thickness category number
+
+      INTEGER ::            &
+         ji,jk          ,   &  !  dummy loop indices
+         zji, zjj       ,   &  !  dummy indices
+         ntop0          ,   &  !  old layer top index
+         nbot1          ,   &  !  new layer bottom index
+         ntop1          ,   &  !  new layer top index
+         limsum         ,   &  !  temporary loop index
+         nlayi0,nlays0  ,   &  !  old number of layers
+         maxnbot0       ,   &  !  old layer bottom index
+         layer0, layer1        !  old/new layer indexes
+
+      INTEGER, DIMENSION(jpij) :: &
+         snswi          ,   &  !  snow switch
+         nbot0          ,   &  !  old layer bottom index
+         icsuind        ,   &  !  ice surface index
+         icsuswi        ,   &  !  ice surface switch
+         icboind        ,   &  !  ice bottom index
+         icboswi        ,   &  !  ice bottom switch
+         snicind        ,   &  !  snow ice index
+         snicswi        ,   &  !  snow ice switch
+         snind                 !  snow index
+
+      REAL(wp) :: &
+         zeps, zeps6    ,   &  ! numerical constant very small
+         ztmelts        ,   &  ! ice melting point
+         zqsnic         ,   &  ! enthalpy of snow ice layer
+         zhsnow         ,   &  ! temporary snow thickness variable
+         zswitch        ,   &  ! dummy switch argument
+         zfac1          ,   &  ! dummy factor
+         zfac2          ,   &  ! dummy factor
+         ztform         ,   &  !: bottom formation temperature
+         zaaa           ,   &  !: dummy factor
+         zbbb           ,   &  !: dummy factor
+         zccc           ,   &  !: dummy factor
+         zdiscrim              !: dummy factor
+
+      REAL(wp), DIMENSION(jpij) :: &  
+         zh_i           ,   &  ! thickness of an ice layer
+         zh_s           ,   &  ! thickness of a snow layer
+         zqsnow         ,   &  ! enthalpy of the snow put in snow ice 	
+         zdeltah               ! temporary variable
+
+      REAL(wp), DIMENSION(jpij,0:jkmax+3) :: &
+         zm0            ,   &  !  old layer-system vertical cotes
+         qm0            ,   &  !  old layer-system heat content
+         z_s            ,   &  !  new snow system vertical cotes
+         z_i            ,   &  !  new ice system vertical cotes
+         zthick0               !  old ice thickness
+
+      REAL(wp), DIMENSION(jpij,0:jkmax+3) :: &
+         zhl0                  ! old and new layer thicknesses
+
+      REAL(wp), DIMENSION(0:jkmax+3,0:jkmax+3) :: &
+         zrl01
+
+      ! Energy conservation
+      REAL(wp), DIMENSION(jpij) :: &
+         zqti_in, zqts_in,         &
+         zqti_fin, zqts_fin
+
+      !------------------------------------------------------------------------------|
+
+      zeps   = 1.0d-20
+      zeps6  = 1.0d-06
+      zthick0(:,:) = 0.0
+      zm0(:,:)     = 0.0
+      qm0(:,:)     = 0.0
+      zrl01(:,:)   = 0.0
+      zhl0(:,:)    = 0.0
+      z_i(:,:)     = 0.0
+      z_s(:,:)     = 0.0
+
+      !
+      !------------------------------------------------------------------------------|
+      !  1) Grid                                                                     |
+      !------------------------------------------------------------------------------|
+      !
+      nlays0        = nlay_s
+      nlayi0        = nlay_i
+
+      DO ji = kideb, kiut
+         zh_i(ji)   = old_ht_i_b(ji) / nlay_i 
+         zh_s(ji)   = old_ht_s_b(ji) / nlay_s
+      ENDDO
+
+      !
+      !------------------------------------------------------------------------------|
+      !  2) Switches                                                                 |
+      !------------------------------------------------------------------------------|
+      !
+      ! 2.1 snind(ji), snswi(ji)
+      ! snow surface behaviour : computation of snind(ji)-snswi(ji)
+      ! snind(ji) : index which equals 
+      ! 	 0 if snow is accumulating
+      ! 	 1 if 1st layer is melting
+      ! 	 2 if 2nd layer is melting ...
+      DO ji = kideb, kiut
+         snind(ji)     = 0
+         zdeltah(ji)   = 0.0
+      ENDDO !ji
+
+      DO jk = 1, nlays0
+         DO ji = kideb, kiut
+            snind(ji)  = jk        *      INT(MAX(0.0,SIGN(1.0,-dh_s_tot(ji)-zdeltah(ji)-zeps))) &
+               + snind(ji) * (1 - INT(MAX(0.0,SIGN(1.0,-dh_s_tot(ji)-zdeltah(ji)-zeps))))
+            zdeltah(ji)= zdeltah(ji) + zh_s(ji)
+         END DO ! ji
+      ENDDO ! jk
+
+      ! snswi(ji) : switch which value equals 1 if snow melts
+      !				   0 if not
+      DO ji = kideb, kiut
+         snswi(ji)     = MAX(0,INT(-dh_s_tot(ji)/MAX(zeps,ABS(dh_s_tot(ji)))))
+      ENDDO ! ji
+
+      ! 2.2 icsuind(ji), icsuswi(ji)
+      ! ice surface behaviour : computation of icsuind(ji)-icsuswi(ji)
+      ! icsuind(ji) : index which equals
+      !	   0 if nothing happens at the surface
+      !	   1 if first layer is melting
+      !	   2 if 2nd layer is reached by melt ...
+      DO ji = kideb, kiut
+         icsuind(ji)   = 0
+         zdeltah(ji)   = 0.0
+      ENDDO !ji
+      DO jk = 1, nlayi0
+         DO ji = kideb, kiut
+            icsuind(ji) = jk          *      INT(MAX(0.0,SIGN(1.0,-dh_i_surf(ji)-zdeltah(ji)-zeps))) &
+               + icsuind(ji) * (1 - INT(MAX(0.0,SIGN(1.0,-dh_i_surf(ji)-zdeltah(ji)-zeps))))
+            zdeltah(ji) = zdeltah(ji) + zh_i(ji)
+         END DO ! ji
+      ENDDO !jk
+
+      ! icsuswi(ji) : switch which equals 
+      ! 	   1 if ice melts at the surface
+      ! 	   0 if not
+      DO ji = kideb, kiut
+         icsuswi(ji)  = MAX(0,INT(-dh_i_surf(ji)/MAX(zeps , ABS(dh_i_surf(ji)) ) ) )
+      ENDDO
+
+      ! 2.3 icboind(ji), icboswi(ji)
+      ! ice bottom behaviour : computation of icboind(ji)-icboswi(ji)
+      ! icboind(ji) : index which equals
+      ! 	   0 if accretion is on the way
+      ! 	   1 if last layer has started to melt
+      ! 	   2 if penultiem layer is melting ... and so on
+      !            N+1 if all layers melt and that snow transforms into ice
+      DO ji = kideb, kiut 
+         icboind(ji)   = 0
+         zdeltah(ji)   = 0.0
+      ENDDO
+      DO jk = nlayi0, 1, -1
+         DO ji = kideb, kiut
+            icboind(ji) = (nlayi0+1-jk) &
+               *      INT(MAX(0.0,SIGN(1.0,-dh_i_bott(ji)-zdeltah(ji)-zeps))) &
+               + icboind(ji) &
+               * (1 - INT(MAX(0.0,SIGN(1.0,-dh_i_bott(ji)-zdeltah(ji)-zeps)))) 
+            zdeltah(ji) = zdeltah(ji) + zh_i(ji)
+         END DO
+      ENDDO
+
+      DO ji = kideb, kiut
+         ! case of total ablation with remaining snow
+         IF ( ( ht_i_b(ji) .GT. zeps ) .AND. &
+            ( ht_i_b(ji) - dh_snowice(ji) .LT. zeps ) ) icboind(ji) = nlay_i + 1
+      END DO
+
+      ! icboswi(ji) : switch which equals 
+      ! 	   1 if ice accretion is on the way
+      ! 	   0 if ablation is on the way
+      DO ji = kideb, kiut 
+         icboswi(ji)     = MAX(0,INT(dh_i_bott(ji) / MAX(zeps,ABS(dh_i_bott(ji)))))
+      ENDDO
+
+      ! 2.4 snicind(ji), snicswi(ji)
+      ! snow ice formation : calcul de snicind(ji)-snicswi(ji)
+      ! snicind(ji) : index which equals 
+      ! 	   0 if no snow-ice forms
+      ! 	   1 if last layer of snow has started to melt
+      ! 	   2 if penultiem layer ...
+      DO ji = kideb, kiut
+         snicind(ji)   = 0
+         zdeltah(ji)   = 0.0
+      ENDDO
+      DO jk = nlays0, 1, -1
+         DO ji = kideb, kiut
+            snicind(ji) = (nlays0+1-jk) &
+               *      INT(MAX(0.0,SIGN(1.0,dh_snowice(ji)-zdeltah(ji)-zeps))) &
+               + snicind(ji) &
+               * (1 - INT(MAX(0.0,SIGN(1.0,dh_snowice(ji)-zdeltah(ji)-zeps))))
+            zdeltah(ji) = zdeltah(ji) + zh_s(ji)
+         END DO
+      ENDDO
+
+      ! snicswi(ji) : switch which equals 
+      ! 	   1 if snow-ice forms
+      ! 	   0 if not
+      DO ji = kideb, kiut
+         snicswi(ji)   = MAX(0,INT(dh_snowice(ji)/MAX(zeps,ABS(dh_snowice(ji)))))
+      ENDDO
+
+      !
+      !------------------------------------------------------------------------------|
+      !  3) Snow redistribution                                                      |
+      !------------------------------------------------------------------------------|
+      !
+      !-------------
+      ! Old profile
+      !-------------
+
+      ! by 'old', it is meant that layers coming from accretion are included, 
+      ! and that interfacial layers which were partly melted are reduced 
+
+      ! indexes of the vectors
+      !------------------------
+      ntop0                =  1
+      maxnbot0             =  0
+
+      DO ji = kideb, kiut
+         nbot0(ji)          =  nlays0  + 1 - snind(ji) + ( 1. - snicind(ji) ) * &
+            snicswi(ji)
+         ! cotes of the top of the layers
+         zm0(ji,0)          =  0.0
+         maxnbot0           =  MAX ( maxnbot0 , nbot0(ji) )
+      ENDDO
+      IF( lk_mpp ) CALL mpp_max( maxnbot0, kcom=ncomm_ice )
+
+      DO jk = 1, maxnbot0
+         DO ji = kideb, kiut
+            !change
+            limsum      = ( 1 - snswi(ji) ) * ( jk - 1 ) +                      &
+               snswi(ji) * ( jk + snind(ji) - 1 )
+            limsum      = MIN( limsum , nlay_s )
+            zm0(ji,jk)  =  dh_s_tot(ji) + zh_s(ji) * limsum
+         END DO
+      ENDDO
+
+      DO ji = kideb, kiut
+         zm0(ji,nbot0(ji)) =  dh_s_tot(ji) - snicswi(ji) * dh_snowice(ji) + &
+            zh_s(ji) * nlays0
+         zm0(ji,1)         =  dh_s_tot(ji) * (1 -snswi(ji) ) +              &
+            snswi(ji) * zm0(ji,1)
+      ENDDO
+
+      DO jk = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            ! layer thickness
+            zthick0(ji,jk)  =  zm0(ji,jk) - zm0(ji,jk-1)
+         END DO
+      ENDDO
+
+      zqts_in(:) = 0.0
+
+      DO ji = kideb, kiut
+         ! layer heat content
+         qm0(ji,1)   =  rhosn * ( cpic * ( rtt - ( 1. - snswi(ji) ) * ( tatm_ice_1d(ji) ) &
+            - snswi(ji) * t_s_b(ji,1) )         &
+            + lfus ) * zthick0(ji,1)
+         zqts_in(ji) =  zqts_in(ji) + qm0(ji,1) 
+      ENDDO
+
+      DO jk = 2, maxnbot0
+         DO ji = kideb, kiut
+            limsum      = ( 1 - snswi(ji) ) * ( jk - 1 ) +                      &
+               snswi(ji) * ( jk + snind(ji) - 1 )
+            limsum      = MIN( limsum , nlay_s )
+            qm0(ji,jk)  = rhosn * ( cpic * ( rtt - t_s_b(ji,limsum) ) + lfus )  &
+               * zthick0(ji,jk)
+            zswitch = 1.0 - MAX (0.0, SIGN ( 1.0, zeps - ht_s_b(ji) ) )
+            zqts_in(ji) = zqts_in(ji) + ( 1. - snswi(ji) ) * qm0(ji,jk) * zswitch
+         END DO ! jk
+      ENDDO ! ji
+
+      !------------------------------------------------
+      ! Energy given by the snow in snow-ice formation
+      !------------------------------------------------
+      ! zqsnow, enthalpy of the flooded snow
+      DO ji = kideb, kiut
+         zqsnow(ji)     =  rhosn*lfus
+         zdeltah(ji)    =  0.0
+      ENDDO
+
+      DO jk =  nlays0, 1, -1
+         DO ji = kideb, kiut
+            zhsnow      =  MAX(0.0,dh_snowice(ji)-zdeltah(ji))
+            zqsnow(ji)  =  zqsnow(ji) + &
+               rhosn*cpic*(rtt-t_s_b(ji,jk))
+            zdeltah(ji) =  zdeltah(ji) + zh_s(ji)
+         END DO
+      ENDDO
+
+      DO ji = kideb, kiut
+         zqsnow(ji) = zqsnow(ji) * dh_snowice(ji)
+      END DO
+
+      !------------------
+      ! new snow profile
+      !------------------
+
+      !--------------
+      ! Vector index   
+      !--------------
+      ntop1    =  1
+      nbot1    =  nlay_s
+
+      !-------------------
+      ! Layer coordinates 
+      !-------------------
+      DO ji = kideb, kiut
+         zh_s(ji)  = ht_s_b(ji) / nlay_s
+         z_s(ji,0) =  0.0
+      ENDDO
+
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            z_s(ji,jk) =  zh_s(ji) * jk
+         END DO
+      ENDDO
+
+      !-----------------
+      ! Layer thickness
+      !-----------------
+      DO layer0 = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            zhl0(ji,layer0) = zm0(ji,layer0) - zm0(ji,layer0-1)
+         END DO
+      ENDDO
+
+      DO layer1 = ntop1, nbot1
+         DO ji = kideb, kiut
+            q_s_b(ji,layer1)= 0.0
+         END DO
+      ENDDO
+
+      !----------------
+      ! Weight factors
+      !----------------
+      DO layer0 = ntop0, maxnbot0
+         DO layer1 = ntop1, nbot1
+            DO ji = kideb, kiut
+               zrl01(layer1,layer0) = MAX(0.0,( MIN(zm0(ji,layer0),z_s(ji,layer1)) &
+                  - MAX(zm0(ji,layer0-1), z_s(ji,layer1-1)))/MAX(zhl0(ji,layer0),epsi10)) 
+               q_s_b(ji,layer1) = q_s_b(ji,layer1) + zrl01(layer1,layer0)*qm0(ji,layer0) &
+                  * MAX(0.0,SIGN(1.0,nbot0(ji)-layer0+zeps))
+            END DO
+         END DO
+      ENDDO
+
+      ! Heat conservation
+      zqts_fin(:) = 0.0
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            zqts_fin(ji) = zqts_fin(ji) + q_s_b(ji,jk)
+         END DO
+      END DO
+
+      IF ( con_i ) THEN
+         DO ji = kideb, kiut
+            IF ( ABS ( zqts_in(ji) - zqts_fin(ji) ) / rdt_ice .GT. 1.0e-6 ) THEN
+               zji                 = MOD( npb(ji) - 1, jpi ) + 1
+               zjj                 = ( npb(ji) - 1 ) / jpi + 1
+               WRITE(numout,*) ' violation of heat conservation : ',             &
+                  ABS ( zqts_in(ji) - zqts_fin(ji) ) / rdt_ice
+               WRITE(numout,*) ' ji, jj   : ', zji, zjj
+               WRITE(numout,*) ' ht_s_b   : ', ht_s_b(ji)
+               WRITE(numout,*) ' zqts_in  : ', zqts_in(ji) / rdt_ice
+               WRITE(numout,*) ' zqts_fin : ', zqts_fin(ji) / rdt_ice
+               WRITE(numout,*) ' dh_snowice : ', dh_snowice(ji)
+               WRITE(numout,*) ' dh_s_tot : ', dh_s_tot(ji)
+               WRITE(numout,*) ' snswi    : ', snswi(ji)
+            ENDIF
+         END DO
+      ENDIF
+
+      !---------------------
+      ! Recover heat content
+      !---------------------
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            q_s_b(ji,jk) = q_s_b(ji,jk) / MAX( zh_s(ji) , zeps )
+         END DO !ji
+      ENDDO !jk  
+
+      !---------------------
+      ! Recover temperature
+      !---------------------
+      zfac1 = 1. / ( rhosn * cpic )
+      zfac2 = lfus / cpic  
+      DO jk = 1, nlay_s
+         DO ji = kideb, kiut
+            zswitch = MAX ( 0.0 , SIGN ( 1.0, zeps - ht_s_b(ji) ) )
+            t_s_b(ji,jk) = rtt                                                  &
+               + ( 1.0 - zswitch ) *                                  &
+               ( - zfac1 * q_s_b(ji,jk) + zfac2 )
+         END DO
+      ENDDO
+      !
+      !------------------------------------------------------------------------------|
+      !  4) Ice redistribution                                                       |
+      !------------------------------------------------------------------------------|
+      !
+      !-------------
+      ! OLD PROFILE 
+      !-------------
+
+      !----------------
+      ! Vector indexes
+      !----------------
+      ntop0          =  1
+      maxnbot0       =  0
+
+      DO ji = kideb, kiut
+         ! reference number of the bottommost layer
+         nbot0(ji)    =  MAX( 1 ,  MIN( nlayi0 + ( 1 - icboind(ji) ) +        &
+            ( 1 - icsuind(ji) ) * icsuswi(ji) + snicswi(ji) ,    &
+            nlay_i + 2 ) )
+         ! maximum reference number of the bottommost layer over all domain
+         maxnbot0     =  MAX( maxnbot0 , nbot0(ji) )
+      ENDDO
+
+      !-------------------------
+      ! Cotes of old ice layers
+      !-------------------------
+      zm0(:,0)    =  0.0
+
+      DO jk = 1, maxnbot0
+         DO ji = kideb, kiut
+            ! jk goes from 1 to nbot0
+            ! the ice layer number goes from 1 to nlay_i
+            ! limsum is the real ice layer number corresponding to present jk
+            limsum    =  ( (icsuswi(ji)*(icsuind(ji)+jk-1) + & 
+               (1-icsuswi(ji))*jk))*(1-snicswi(ji)) + (jk-1)*snicswi(ji)
+            zm0(ji,jk)=  icsuswi(ji)*dh_i_surf(ji) + snicswi(ji)*dh_snowice(ji) &
+               +  limsum * zh_i(ji)
+         END DO
+      ENDDO
+
+      DO ji = kideb, kiut
+         zm0(ji,nbot0(ji)) =  icsuswi(ji)*dh_i_surf(ji) + snicswi(ji)*dh_snowice(ji) + dh_i_bott(ji) &
+            +  zh_i(ji) * nlayi0
+         zm0(ji,1)         =  snicswi(ji)*dh_snowice(ji) + (1-snicswi(ji))*zm0(ji,1)
+      ENDDO
+
+      !-----------------------------
+      ! Thickness of old ice layers
+      !-----------------------------
+      DO jk = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            zthick0(ji,jk) =  zm0(ji,jk) - zm0(ji,jk-1)
+         END DO
+      ENDDO
+
+      !---------------------------
+      ! Inner layers heat content
+      !---------------------------
+      qm0(:,:) =  0.0
+      zqti_in(:) = 0.0
+
+      DO jk = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            limsum =  MAX(1,MIN(snicswi(ji)*(jk-1) + icsuswi(ji)*(jk-1+icsuind(ji)) + &
+               (1-icsuswi(ji))*(1-snicswi(ji))*jk,nlay_i))
+            ztmelts = -tmut * s_i_b(ji,limsum) + rtt
+            qm0(ji,jk) = rhoic * ( cpic * (ztmelts-t_i_b(ji,limsum)) + lfus * ( 1.0-(ztmelts-rtt)/ &
+               MIN((t_i_b(ji,limsum)-rtt),-zeps) ) - rcp*(ztmelts-rtt) ) &
+               * zthick0(ji,jk)
+         END DO
+      ENDDO
+
+      !----------------------------
+      ! Bottom layers heat content
+      !----------------------------
+      DO ji = kideb, kiut        
+         ztmelts    = ( 1.0 - icboswi(ji) ) * (-tmut * s_i_b(ji,nlayi0)) &   ! case of melting ice
+            +      icboswi(ji)      * (-tmut * s_i_new(ji))      &   ! case of forming ice
+            + rtt                        ! this temperature is in Celsius
+
+         ! bottom formation temperature
+         ztform = t_i_b(ji,nlay_i)
+         IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) ztform = t_bo_b(ji)
+         qm0(ji,nbot0(ji)) = ( 1.0 - icboswi(ji) )*qm0(ji,nbot0(ji)) &   ! case of melting ice
+            + icboswi(ji) *                                  &   ! case of forming ice
+            rhoic*( cpic*(ztmelts-ztform)                  &
+            + lfus *( 1.0-(ztmelts-rtt)/             &
+            MIN ( (ztform-rtt) , - epsi10 ) )      & 
+            - rcp*(ztmelts-rtt) )                    &
+            *zthick0(ji,nbot0(ji))
+      ENDDO
+
+      !-----------------------------
+      ! Snow ice layer heat content
+      !-----------------------------
+      DO ji = kideb, kiut
+         ! energy of the flooding seawater
+         zqsnic = rau0 * rcp * ( rtt - t_bo_b(ji) ) * dh_snowice(ji) * &
+            (rhoic - rhosn) / rhoic * snicswi(ji) ! generally positive
+         ! Heat conservation diagnostic
+         qt_i_in(ji,jl) = qt_i_in(ji,jl) + zqsnic 
+
+         qldif_1d(ji)   = qldif_1d(ji) + zqsnic * a_i_b(ji)
+
+         ! enthalpy of the newly formed snow-ice layer
+         ! = enthalpy of snow + enthalpy of frozen water
+         zqsnic         =  zqsnow(ji) + zqsnic
+         qm0(ji,1)      =  snicswi(ji) * zqsnic + ( 1 - snicswi(ji) ) * qm0(ji,1)
+
+      ENDDO ! ji
+
+      DO jk = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            ! Heat conservation
+            zqti_in(ji) = zqti_in(ji) + qm0(ji,jk) &
+               * MAX( 0.0 , SIGN(1.0,ht_i_b(ji)-zeps6+zeps) ) &
+               * MAX( 0.0 , SIGN( 1. , nbot0(ji) - jk + zeps ) )
+         END DO
+      ENDDO
+
+      !-------------
+      ! NEW PROFILE
+      !-------------
+
+      !---------------
+      ! Vectors index
+      !---------------
+
+      ntop1    =  1 
+      nbot1    =  nlay_i
+
+      !------------------
+      ! Layers thickness 
+      !------------------
+      DO ji = kideb, kiut
+         zh_i(ji)      = ht_i_b(ji) / nlay_i
+      ENDDO
+
+      !-------------
+      ! Layer cotes      
+      !-------------
+      z_i(:,0) =  0.0
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut
+            z_i(ji,jk) =  zh_i(ji) * jk
+         END DO
+      ENDDO
+
+      !--thicknesses of the layers
+      DO layer0 = ntop0, maxnbot0
+         DO ji = kideb, kiut
+            zhl0(ji,layer0)   =  zm0(ji,layer0) - zm0(ji,layer0-1) !thicknesses of the layers
+         END DO
+      ENDDO
+
+      !------------------------
+      ! Weights for relayering
+      !------------------------
+
+      q_i_b(:,:) = 0.0
+      DO layer0 = ntop0, maxnbot0
+         DO layer1 = ntop1, nbot1
+            DO ji = kideb, kiut
+               zrl01(layer1,layer0) = MAX(0.0,( MIN(zm0(ji,layer0),z_i(ji,layer1)) &
+                  - MAX(zm0(ji,layer0-1), z_i(ji,layer1-1)))/MAX(zhl0(ji,layer0),epsi10))
+               q_i_b(ji,layer1) = q_i_b(ji,layer1) & 
+                  + zrl01(layer1,layer0)*qm0(ji,layer0) &
+                  * MAX(0.0,SIGN(1.0,ht_i_b(ji)-zeps6+zeps)) &
+                  * MAX(0.0,SIGN(1.0,nbot0(ji)-layer0+zeps))
+            END DO
+         END DO
+      ENDDO
+
+      !-------------------------
+      ! Heat conservation check
+      !-------------------------
+      zqti_fin(:) = 0.0
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut
+            zqti_fin(ji) = zqti_fin(ji) + q_i_b(ji,jk)
+         END DO
+      END DO
+      !
+      DO ji = kideb, kiut
+         IF ( ABS ( zqti_in(ji) - zqti_fin(ji) ) / rdt_ice .GT. 1.0e-6 ) THEN
+            zji                 = MOD( npb(ji) - 1, jpi ) + 1
+            zjj                 = ( npb(ji) - 1 ) / jpi + 1
+            WRITE(numout,*) ' violation of heat conservation : ',             &
+               ABS ( zqti_in(ji) - zqti_fin(ji) ) / rdt_ice
+            WRITE(numout,*) ' ji, jj   : ', zji, zjj
+            WRITE(numout,*) ' ht_i_b   : ', ht_i_b(ji)
+            WRITE(numout,*) ' zqti_in  : ', zqti_in(ji) / rdt_ice
+            WRITE(numout,*) ' zqti_fin : ', zqti_fin(ji) / rdt_ice
+            WRITE(numout,*) ' dh_i_bott: ', dh_i_bott(ji)
+            WRITE(numout,*) ' dh_i_surf: ', dh_i_surf(ji)
+            WRITE(numout,*) ' dh_snowice:', dh_snowice(ji)
+            WRITE(numout,*) ' icsuswi  : ', icsuswi(ji)
+            WRITE(numout,*) ' icboswi  : ', icboswi(ji)
+            WRITE(numout,*) ' snicswi  : ', snicswi(ji)
+         ENDIF
+      END DO
+
+      !----------------------
+      ! Recover heat content 
+      !----------------------
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut
+            q_i_b(ji,jk) = q_i_b(ji,jk) / MAX( zh_i(ji) , zeps )
+         END DO !ji
+      ENDDO !jk  
+
+      ! Heat conservation
+      zqti_fin(:) = 0.0
+      DO jk = 1, nlay_i
+         DO ji = kideb, kiut
+            zqti_fin(ji) = zqti_fin(ji) + q_i_b(ji,jk) * zh_i(ji)
+         END DO
+      END DO
+
+      !
+      !------------------------------------------------------------------------------|
+      !  5) Update salinity and recover temperature                                  |
+      !------------------------------------------------------------------------------|
+      !
+      ! Update salinity (basal entrapment, snow ice formation)
+      DO ji = kideb, kiut
+         sm_i_b(ji) = sm_i_b(ji)                                &
+            + dsm_i_se_1d(ji) + dsm_i_si_1d(ji)
+      END DO !ji
+
+      ! Recover temperature
+      DO jk = 1, nlay_i
+
+         DO ji = kideb, kiut
+
+            ztmelts    =  -tmut*s_i_b(ji,jk) + rtt
+            !Conversion q(S,T) -> T (second order equation)
+            zaaa         =  cpic
+            zbbb         =  ( rcp - cpic ) * ( ztmelts - rtt ) + &
+               q_i_b(ji,jk) / rhoic - lfus
+            zccc         =  lfus * ( ztmelts - rtt )
+            zdiscrim     =  SQRT( MAX(zbbb*zbbb - 4.0*zaaa*zccc,0.0) )
+            t_i_b(ji,jk) =  rtt - ( zbbb + zdiscrim ) / & 
+               ( 2.0 *zaaa )
+         END DO !ji
+
+      END DO !jk
+
+   END SUBROUTINE lim_thd_ent
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_ent   ***
+   !!                             no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_ent          ! Empty routine
+   END SUBROUTINE lim_thd_ent
+#endif
+END MODULE limthd_ent
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_lac.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_lac.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_lac.F90	(revision 1844)
@@ -0,0 +1,816 @@
+MODULE limthd_lac
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac   ***
+   !!                lateral thermodynamic growth of the ice 
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   lim_lat_acr    : lateral accretion of ice
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE dom_oce
+   USE in_out_manager
+   USE phycst
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE thd_ice
+   USE dom_ice
+   USE par_ice
+   USE ice
+   USE iceini
+   USE limtab
+   USE limcons
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_lac     ! called by lim_thd
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1.e-20  ,  &
+      epsi13 = 1.e-13  ,  &
+      epsi11 = 1.e-13  ,  &
+      epsi03 = 1.e-03  ,  &
+      epsi06 = 1.e-06  ,  &
+      zeps   = 1.e-10  ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_lac
+      !!-------------------------------------------------------------------
+      !!               ***   ROUTINE lim_thd_lac  ***
+      !!  
+      !! ** Purpose : Computation of the evolution of the ice thickness and 
+      !!      concentration as a function of the heat balance in the leads.
+      !!      It is only used for lateral accretion
+      !!       
+      !! ** Method  : Ice is formed in the open water when ocean lose heat
+      !!      (heat budget of open water Bl is negative) .
+      !!      Computation of the increase of 1-A (ice concentration) fol-
+      !!      lowing the law :
+      !!      (dA/dt)acc = F[ (1-A)/(1-a) ] * [ Bl / (Li*h0) ]
+      !!       where - h0 is the thickness of ice created in the lead
+      !!             - a is a minimum fraction for leads
+      !!             - F is a monotonic non-increasing function defined as:
+      !!                  F(X)=( 1 - X**exld )**(1.0/exld)
+      !!             - exld is the exponent closure rate (=2 default val.)
+      !! 
+      !! ** Action : - Adjustment of snow and ice thicknesses and heat
+      !!                content in brine pockets
+      !!             - Updating ice internal temperature
+      !!             - Computation of variation of ice volume and mass
+      !!             - Computation of frldb after lateral accretion and 
+      !!               update ht_s_b, ht_i_b and tbif_1d(:,:)      
+      !! 
+      !! ** References : Not available yet
+      !!
+      !! History :
+      !!   3.0  !  12-05 (M. Vancoppenolle)  Thorough rewrite of the routine
+      !!                                     Salinity variations in sea ice, 
+      !!                                     Multi-layer code
+      !!   3.1  !  01-06 (M. Vancoppenolle)  ITD
+      !!   3.2  !  04-07 (M. Vancoppenolle)  Mass and energy conservation tested
+      !!------------------------------------------------------------------------
+      !! * Arguments
+      !! * Local variables
+      INTEGER ::             &
+         ji,jj,jk,jl,jm  ,   &  !: dummy loop indices
+         layer           ,   &  !: layer index
+         nbpac                  !: nb of pts for lateral accretion 
+
+      INTEGER ::             &
+         zji             ,   &  !: ji of dummy test point 
+         zjj             ,   &  !: jj of dummy test point
+         iter                   !: iteration for frazil ice computation
+
+      INTEGER, DIMENSION(jpij) :: &
+         zcatac          ,   &  !:  indexes of categories where new ice grows
+         zswinew                !: switch for new ice or not
+
+      REAL(wp), DIMENSION(jpij) :: &
+         zv_newice       ,   &  !: volume of accreted ice
+         za_newice       ,   &  !: fractional area of accreted ice
+         zh_newice       ,   &  !: thickness of accreted ice
+         ze_newice       ,   &  !: heat content of accreted ice
+         zs_newice       ,   &  !: salinity of accreted ice
+         zo_newice       ,   &  !: age of accreted ice
+         zdv_res         ,   &  !: residual volume in case of excessive heat budget
+         zda_res         ,   &  !: residual area in case of excessive heat budget
+         zat_i_ac        ,   &  !: total ice fraction    
+         zat_i_lev       ,   &  !: total ice fraction for level ice only (type 1)   
+         zdh_frazb       ,   &  !: accretion of frazil ice at the ice bottom
+         zvrel_ac               !: relative ice / frazil velocity (1D vector)
+
+      REAL(wp), DIMENSION(jpij,jpl) :: &
+         zhice_old       ,   &  !: previous ice thickness
+         zdummy          ,   &  !: dummy thickness of new ice 
+         zdhicbot        ,   &  !: thickness of new ice which is accreted vertically
+         zv_old          ,   &  !: old volume of ice in category jl
+         za_old          ,   &  !: old area of ice in category jl
+         za_i_ac         ,   &  !: 1-D version of a_i
+         zv_i_ac         ,   &  !: 1-D version of v_i
+         zoa_i_ac        ,   &  !: 1-D version of oa_i
+         zsmv_i_ac              !: 1-D version of smv_i
+
+      REAL(wp), DIMENSION(jpij,jkmax,jpl) :: &
+         ze_i_ac                !: 1-D version of e_i
+
+      REAL(wp), DIMENSION(jpij) :: &
+         zqbgow          ,   &  !: heat budget of the open water (negative)
+         zdhex                  !: excessively thick accreted sea ice (hlead-hice)
+
+      REAL(wp)  ::           &
+         ztmelts         ,   &  !: melting point of an ice layer
+         zdv             ,   &  !: increase in ice volume in each category
+         zfrazb                 !: fraction of frazil ice accreted at the ice bottom
+
+      ! Redistribution of energy after bottom accretion
+      REAL(wp)  ::           &  !: Energy redistribution
+         zqold           ,   &  !: old ice enthalpy
+         zweight         ,   &  !: weight of redistribution
+         zeps6           ,   &  !: epsilon value
+         zalphai         ,   &  !: factor describing how old and new layers overlap each other [m]
+         zindb            
+
+      REAL(wp), DIMENSION(jpij,jkmax+1,jpl) :: &
+         zqm0            ,   &  !: old layer-system heat content
+         zthick0                !: old ice thickness
+
+      ! Frazil ice collection thickness
+      LOGICAL :: &              !: iterate frazil ice collection thickness
+         iterate_frazil
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zvrel                  !: relative ice / frazil velocity
+
+      REAL(wp) ::            &
+         zgamafr          ,  &  !: mult. coeff. between frazil vel. and wind speed
+         ztenagm          ,  &  !: square root of wind stress
+         zvfrx            ,  &  !: x-component of frazil velocity
+         zvfry            ,  &  !: y-component of frazil velocity
+         zvgx             ,  &  !: x-component of ice velocity
+         zvgy             ,  &  !: y-component of ice velocity
+         ztaux            ,  &  !: x-component of wind stress
+         ztauy            ,  &  !: y-component of wind stress
+         ztwogp           ,  &  !: dummy factor including reduced gravity
+         zvrel2           ,  &  !: square of the relative ice-frazil velocity
+         zf               ,  &  !: F for Newton-Raphson procedure
+         zfp              ,  &  !: dF for Newton-Raphson procedure
+         zhicol_new       ,  &  !: updated collection thickness
+         zsqcd            ,  &  !: 1 / square root of ( airdensity * drag )
+         zhicrit                !: minimum thickness of frazil ice
+
+      ! Variables for energy conservation
+      REAL (wp), DIMENSION(jpi,jpj) :: &  ! 
+         vt_i_init, vt_i_final,   &  !  ice volume summed over categories
+         vt_s_init, vt_s_final,   &  !  snow volume summed over categories
+         et_i_init, et_i_final,   &  !  ice energy summed over categories
+         et_s_init                   !  snow energy summed over categories
+
+      REAL(wp) ::            &
+         zde                         ! :increment of energy in category jl
+
+      CHARACTER (len = 15) :: fieldid
+
+      !!-----------------------------------------------------------------------!
+
+      et_i_init(:,:) = 0.0
+      et_s_init(:,:) = 0.0
+      vt_i_init(:,:) = 0.0
+      vt_s_init(:,:) = 0.0
+      zeps6   = 1.0e-6
+
+      !------------------------------------------------------------------------------!
+      ! 1) Conservation check and changes in each ice category
+      !------------------------------------------------------------------------------!
+      IF ( con_i ) THEN
+         CALL lim_column_sum (jpl, v_i, vt_i_init)
+         CALL lim_column_sum (jpl, v_s, vt_s_init)
+         CALL lim_column_sum_energy (jpl, nlay_i, e_i, et_i_init)
+         CALL lim_column_sum (jpl,   e_s(:,:,1,:) , et_s_init)
+      ENDIF
+
+      !------------------------------------------------------------------------------|
+      ! 2) Convert units for ice internal energy
+      !------------------------------------------------------------------------------|
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  !Energy of melting q(S,T) [J.m-3]
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / &
+                     MAX( area(ji,jj) * v_i(ji,jj,jl) ,  zeps ) * &
+                     nlay_i
+                  zindb      = 1.0-MAX(0.0,SIGN(1.0,-v_i(ji,jj,jl))) !0 if no ice and 1 if yes
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl)*unit_fac*zindb
+               END DO
+            END DO
+         END DO
+      END DO
+
+      !------------------------------------------------------------------------------!
+      ! 3) Collection thickness of ice formed in leads and polynyas
+      !------------------------------------------------------------------------------!    
+      ! hicol is the thickness of new ice formed in open water
+      ! hicol can be either prescribed (frazswi = 0)
+      ! or computed (frazswi = 1)
+      ! Frazil ice forms in open water, is transported by wind
+      ! accumulates at the edge of the consolidated ice edge
+      ! where it forms aggregates of a specific thickness called
+      ! collection thickness.
+
+      ! Note : the following algorithm currently breaks vectorization
+      ! 
+
+      zvrel(:,:) = 0.0
+
+      ! Default new ice thickness 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            hicol(ji,jj) = hiccrit(1)
+         END DO
+      END DO
+
+      IF (fraz_swi.eq.1.0) THEN
+
+         !--------------------
+         ! Physical constants
+         !--------------------
+         hicol(:,:) = 0.0
+
+         zhicrit = 0.04 ! frazil ice thickness
+         ztwogp  = 2. * rau0 / ( grav * 0.3 * ( rau0 - rhoic ) ) ! reduced grav
+         zsqcd   = 1.0 / SQRT( 1.3 * cai ) ! 1/SQRT(airdensity*drag)
+         zgamafr = 0.03
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               IF ( tms(ji,jj) * ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+                  !-------------
+                  ! Wind stress
+                  !-------------
+                  ! C-grid wind stress components
+                  ztaux         = ( utau_ice(ji-1,jj  ) * tmu(ji-1,jj  ) &
+                     &          +   utau_ice(ji  ,jj  ) * tmu(ji  ,jj  ) ) / 2.0
+                  ztauy         = ( vtau_ice(ji  ,jj-1) * tmv(ji  ,jj-1) &
+                     &          +   vtau_ice(ji  ,jj  ) * tmv(ji  ,jj  ) ) / 2.0
+                  ! Square root of wind stress
+                  ztenagm       =  SQRT( SQRT( ztaux * ztaux + ztauy * ztauy ) )
+
+                  !---------------------
+                  ! Frazil ice velocity
+                  !---------------------
+                  zvfrx         = zgamafr * zsqcd * ztaux / MAX(ztenagm,zeps)
+                  zvfry         = zgamafr * zsqcd * ztauy / MAX(ztenagm,zeps)
+
+                  !-------------------
+                  ! Pack ice velocity
+                  !-------------------
+                  ! C-grid ice velocity
+                  zindb = MAX(0.0, SIGN(1.0, at_i(ji,jj) ))
+                  zvgx  = zindb * ( u_ice(ji-1,jj  ) * tmu(ji-1,jj  ) &
+                     + u_ice(ji,jj    ) * tmu(ji  ,jj  ) ) / 2.0
+                  zvgy  = zindb * ( v_ice(ji  ,jj-1) * tmv(ji  ,jj-1) &
+                     + v_ice(ji,jj    ) * tmv(ji  ,jj  ) ) / 2.0
+
+                  !-----------------------------------
+                  ! Relative frazil/pack ice velocity
+                  !-----------------------------------
+                  ! absolute relative velocity
+                  zvrel2        = MAX( ( zvfrx - zvgx ) * ( zvfrx - zvgx ) + &
+                     ( zvfry - zvgy ) * ( zvfry - zvgy )   &
+                     , 0.15 * 0.15 )
+                  zvrel(ji,jj)  = SQRT(zvrel2)
+
+                  !---------------------
+                  ! Iterative procedure
+                  !---------------------
+                  hicol(ji,jj) = zhicrit + 0.1 
+                  hicol(ji,jj) = zhicrit + hicol(ji,jj) /      & 
+                     ( hicol(ji,jj) * hicol(ji,jj) - &
+                     zhicrit * zhicrit ) * ztwogp * zvrel2
+
+                  iter = 1
+                  iterate_frazil = .true.
+
+                  DO WHILE ( iter .LT. 100 .AND. iterate_frazil ) 
+                     zf = ( hicol(ji,jj) - zhicrit ) * ( hicol(ji,jj)**2 - zhicrit**2 ) &
+                        - hicol(ji,jj) * zhicrit * ztwogp * zvrel2
+                     zfp = ( hicol(ji,jj) - zhicrit ) * ( 3.0*hicol(ji,jj) + zhicrit ) &
+                        - zhicrit * ztwogp * zvrel2
+                     zhicol_new = hicol(ji,jj) - zf/zfp
+                     hicol(ji,jj)   = zhicol_new
+
+                     iter = iter + 1
+
+                  END DO ! do while
+
+               ENDIF ! end of selection of pixels where ice forms
+
+            END DO ! loop on ji ends
+         END DO ! loop on jj ends
+
+      ENDIF ! End of computation of frazil ice collection thickness
+
+      !------------------------------------------------------------------------------!
+      ! 4) Identify grid points where new ice forms
+      !------------------------------------------------------------------------------!
+
+      !-------------------------------------
+      ! Select points for new ice formation
+      !-------------------------------------
+      ! This occurs if open water energy budget is negative
+      nbpac = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( tms(ji,jj) * ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+               nbpac = nbpac + 1
+               npac( nbpac ) = (jj - 1) * jpi + ji
+               IF ( (ji.eq.jiindx).AND.(jj.eq.jjindx) ) THEN
+                  jiindex_1d = nbpac
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+
+      IF( ln_nicep ) THEN
+         WRITE(numout,*) 'lim_thd_lac : nbpac = ', nbpac
+      ENDIF
+
+      !------------------------------
+      ! Move from 2-D to 1-D vectors
+      !------------------------------
+      ! If ocean gains heat do nothing 
+      ! 0therwise compute new ice formation
+
+      IF ( nbpac > 0 ) THEN
+
+         CALL tab_2d_1d( nbpac, zat_i_ac  (1:nbpac)     , at_i         ,       &
+            jpi, jpj, npac(1:nbpac) )
+         DO jl = 1, jpl
+            CALL tab_2d_1d( nbpac, za_i_ac(1:nbpac,jl)  , a_i(:,:,jl)  ,       &
+               jpi, jpj, npac(1:nbpac) )
+            CALL tab_2d_1d( nbpac, zv_i_ac(1:nbpac,jl)  , v_i(:,:,jl)  ,       &
+               jpi, jpj, npac(1:nbpac) )
+            CALL tab_2d_1d( nbpac, zoa_i_ac(1:nbpac,jl) , oa_i(:,:,jl) ,       &
+               jpi, jpj, npac(1:nbpac) )
+            CALL tab_2d_1d( nbpac, zsmv_i_ac(1:nbpac,jl), smv_i(:,:,jl),       &
+               jpi, jpj, npac(1:nbpac) )
+            DO jk = 1, nlay_i
+               CALL tab_2d_1d( nbpac, ze_i_ac(1:nbpac,jk,jl), e_i(:,:,jk,jl) , &
+                  jpi, jpj, npac(1:nbpac) )
+            END DO ! jk
+         END DO ! jl
+
+         CALL tab_2d_1d( nbpac, qldif_1d  (1:nbpac)     , qldif ,              &
+            jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d( nbpac, qcmif_1d  (1:nbpac)     , qcmif ,              &
+            jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d( nbpac, t_bo_b    (1:nbpac)     , t_bo  ,              &
+            jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d( nbpac, fseqv_1d  (1:nbpac)     , fseqv ,              &
+            jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d( nbpac, hicol_b   (1:nbpac)     , hicol ,              &
+            jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d( nbpac, zvrel_ac  (1:nbpac)     , zvrel ,              &
+            jpi, jpj, npac(1:nbpac) )
+
+         !------------------------------------------------------------------------------!
+         ! 5) Compute thickness, salinity, enthalpy, age, area and volume of new ice
+         !------------------------------------------------------------------------------!
+
+         !----------------------
+         ! Thickness of new ice
+         !----------------------
+         DO ji = 1, nbpac
+            zh_newice(ji)     = hiccrit(1)
+         END DO
+         IF ( fraz_swi .EQ. 1.0 ) zh_newice(:) = hicol_b(:)
+
+         !----------------------
+         ! Salinity of new ice 
+         !----------------------
+
+         IF ( num_sal .EQ. 1 ) THEN
+            zs_newice(:)      =   bulk_sal
+         ENDIF ! num_sal
+
+         IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN
+
+            DO ji = 1, nbpac
+               zs_newice(ji)  =   MIN( 4.606 + 0.91 / zh_newice(ji) , s_i_max )
+               zji            =   MOD( npac(ji) - 1, jpi ) + 1
+               zjj            =   ( npac(ji) - 1 ) / jpi + 1
+               zs_newice(ji)  =   MIN( 0.5*sss_m(zji,zjj) , zs_newice(ji) )
+            END DO ! jl
+
+         ENDIF ! num_sal
+
+         IF ( num_sal .EQ. 3 ) THEN
+            zs_newice(:)      =   2.3
+         ENDIF ! num_sal
+
+         !-------------------------
+         ! Heat content of new ice
+         !-------------------------
+         ! We assume that new ice is formed at the seawater freezing point
+         DO ji = 1, nbpac
+            ztmelts           = - tmut * zs_newice(ji) + rtt ! Melting point (K)
+            ze_newice(ji)     =   rhoic * ( cpic * ( ztmelts - t_bo_b(ji) )    &
+               + lfus * ( 1.0 - ( ztmelts - rtt )   &
+               / ( t_bo_b(ji) - rtt ) )           &
+               - rcp * ( ztmelts-rtt ) )
+            ze_newice(ji)     =   MAX( ze_newice(ji) , 0.0 ) +                 &
+               MAX( 0.0 , SIGN( 1.0 , - ze_newice(ji) ) )   & 
+               * rhoic * lfus
+         END DO ! ji
+         !----------------
+         ! Age of new ice
+         !----------------
+         DO ji = 1, nbpac
+            zo_newice(ji)     = 0.0
+         END DO ! ji
+
+         !--------------------------
+         ! Open water energy budget 
+         !--------------------------
+         DO ji = 1, nbpac
+            zqbgow(ji)        = qldif_1d(ji) - qcmif_1d(ji) !<0
+         END DO ! ji
+
+         !-------------------
+         ! Volume of new ice
+         !-------------------
+         DO ji = 1, nbpac
+            zv_newice(ji)     = - zqbgow(ji) / ze_newice(ji)
+
+            ! A fraction zfrazb of frazil ice is accreted at the ice bottom
+            zfrazb        = ( TANH ( Cfrazb * ( zvrel_ac(ji) - vfrazb ) )     & 
+               + 1.0 ) / 2.0 * maxfrazb
+            zdh_frazb(ji) = zfrazb*zv_newice(ji)
+            zv_newice(ji) = ( 1.0 - zfrazb ) * zv_newice(ji)
+         END DO
+
+         !---------------------------------
+         ! Salt flux due to new ice growth
+         !---------------------------------
+         IF ( ( num_sal .EQ. 4 ) ) THEN 
+            DO ji = 1, nbpac
+               zji            = MOD( npac(ji) - 1, jpi ) + 1
+               zjj            = ( npac(ji) - 1 ) / jpi + 1
+               fseqv_1d(ji)   = fseqv_1d(ji) +                                     &
+                  ( sss_m(zji,zjj) - bulk_sal      ) * rhoic *       &
+                  zv_newice(ji) / rdt_ice
+            END DO
+         ELSE
+            DO ji = 1, nbpac
+               zji            = MOD( npac(ji) - 1, jpi ) + 1
+               zjj            = ( npac(ji) - 1 ) / jpi + 1
+               fseqv_1d(ji)   = fseqv_1d(ji) +                                     &
+                  ( sss_m(zji,zjj) - zs_newice(ji) ) * rhoic *       &
+                  zv_newice(ji) / rdt_ice
+            END DO ! ji
+         ENDIF
+
+         !------------------------------------
+         ! Diags for energy conservation test
+         !------------------------------------
+         DO ji = 1, nbpac
+            ! Volume
+            zji                  = MOD( npac(ji) - 1, jpi ) + 1
+            zjj                  = ( npac(ji) - 1 ) / jpi + 1
+            vt_i_init(zji,zjj)   = vt_i_init(zji,zjj) + zv_newice(ji)
+            ! Energy
+            zde                  = ze_newice(ji) / unit_fac
+            zde                  = zde * area(zji,zjj) * zv_newice(ji)
+            et_i_init(zji,zjj)   = et_i_init(zji,zjj) + zde
+         END DO
+
+         ! keep new ice volume in memory
+         CALL tab_1d_2d( nbpac, v_newice , npac(1:nbpac), zv_newice(1:nbpac) , &
+            jpi, jpj )
+
+         !-----------------
+         ! Area of new ice
+         !-----------------
+         DO ji = 1, nbpac
+            za_newice(ji)     = zv_newice(ji) / zh_newice(ji)
+            ! diagnostic
+            zji                  = MOD( npac(ji) - 1, jpi ) + 1
+            zjj                  = ( npac(ji) - 1 ) / jpi + 1
+            diag_lat_gr(zji,zjj) = zv_newice(ji) / rdt_ice
+         END DO !ji
+
+         !------------------------------------------------------------------------------!
+         ! 6) Redistribute new ice area and volume into ice categories                  !
+         !------------------------------------------------------------------------------!
+
+         !-----------------------------------------
+         ! Keep old ice areas and volume in memory
+         !-----------------------------------------
+         zv_old(:,:) = zv_i_ac(:,:) 
+         za_old(:,:) = za_i_ac(:,:)
+
+         !-------------------------------------------
+         ! Compute excessive new ice area and volume
+         !-------------------------------------------
+         ! If lateral ice growth gives an ice concentration gt 1, then
+         ! we keep the excessive volume in memory and attribute it later
+         ! to bottom accretion
+         DO ji = 1, nbpac
+            ! vectorize
+            IF ( za_newice(ji) .GT. ( 1.0 - zat_i_ac(ji) ) ) THEN
+               zda_res(ji)    = za_newice(ji) - (1.0 - zat_i_ac(ji) )
+               zdv_res(ji)    = zda_res(ji) * zh_newice(ji) 
+               za_newice(ji)  = za_newice(ji) - zda_res(ji)
+               zv_newice(ji)  = zv_newice(ji) - zdv_res(ji)
+            ELSE
+               zda_res(ji) = 0.0
+               zdv_res(ji) = 0.0
+            ENDIF
+         END DO ! ji
+
+         !------------------------------------------------
+         ! Laterally redistribute new ice volume and area
+         !------------------------------------------------
+         zat_i_ac(:) = 0.0
+
+         DO jl = 1, jpl
+            DO ji = 1, nbpac
+               ! vectorize
+               IF (       ( hi_max(jl-1)  .LT. zh_newice(ji) ) &
+                  .AND. ( zh_newice(ji) .LE. hi_max(jl)    ) ) THEN
+                  za_i_ac(ji,jl) = za_i_ac(ji,jl) + za_newice(ji)
+                  zv_i_ac(ji,jl) = zv_i_ac(ji,jl) + zv_newice(ji)
+                  zat_i_ac(ji)   = zat_i_ac(ji) + za_i_ac(ji,jl)
+                  zcatac(ji)     = jl
+               ENDIF
+            END DO ! ji
+         END DO ! jl
+
+         !----------------------------------
+         ! Heat content - lateral accretion
+         !----------------------------------
+         DO ji = 1, nbpac
+            jl = zcatac(ji) ! categroy in which new ice is put
+            ! zindb = 0 if no ice and 1 if yes
+            zindb            = 1.0 - MAX ( 0.0 , SIGN ( 1.0 , -za_old(ji,jl) ) ) 
+            ! old ice thickness
+            zhice_old(ji,jl)  = zv_old(ji,jl)                                  &
+               / MAX ( za_old(ji,jl) , zeps ) * zindb
+            ! difference in thickness
+            zdhex(ji)      = MAX( 0.0, zh_newice(ji) - zhice_old(ji,jl) ) 
+            ! is ice totally new in category jl ?
+            zswinew(ji)    = MAX( 0.0, SIGN( 1.0 , - za_old(ji,jl) + epsi11 ) )
+         END DO
+
+         DO jk = 1, nlay_i
+            DO ji = 1, nbpac
+               jl = zcatac(ji)
+               zqold              = ze_i_ac(ji,jk,jl) ! [ J.m-3 ]
+               zalphai            = MIN( zhice_old(ji,jl) * jk  / nlay_i ,     &
+                  zh_newice(ji) )                       &
+                  - MIN( zhice_old(ji,jl) * ( jk - 1 )         &
+                  / nlay_i , zh_newice(ji) )
+               ze_i_ac(ji,jk,jl) =                                             &
+                  zswinew(ji)           * ze_newice(ji)                           &
+                  + ( 1.0 - zswinew(ji) ) *                                         &
+                  ( za_old(ji,jl)  * zqold * zhice_old(ji,jl) / nlay_i            &
+                  + za_newice(ji)  * ze_newice(ji) * zalphai                      &
+                  + za_newice(ji)  * ze_newice(ji) * zdhex(ji) / nlay_i ) /       &
+                  ( ( zv_i_ac(ji,jl) ) / nlay_i )
+
+            END DO !ji
+         END DO !jl
+
+         !-----------------------------------------------
+         ! Add excessive volume of new ice at the bottom
+         !-----------------------------------------------
+         ! If the ice concentration exceeds 1, the remaining volume of new ice
+         ! is equally redistributed among all ice categories in which there is
+         ! ice
+
+         ! Fraction of level ice
+         jm = 1
+         zat_i_lev(:) = 0.0
+
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO ji = 1, nbpac
+               zat_i_lev(ji) = zat_i_lev(ji) + za_i_ac(ji,jl) 
+            END DO
+         END DO
+
+         IF( ln_nicep ) WRITE(numout,*) ' zv_i_ac : ', zv_i_ac(jiindx, 1:jpl)
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO ji = 1, nbpac
+               zindb      =  MAX( 0.0, SIGN( 1.0, zdv_res(ji) ) )
+               zv_i_ac(ji,jl) = zv_i_ac(ji,jl) +                               &
+                  zindb * zdv_res(ji) * za_i_ac(ji,jl) /         &
+                  MAX( zat_i_lev(ji) , epsi06 )
+            END DO ! ji
+         END DO ! jl
+         IF( ln_nicep ) WRITE(numout,*) ' zv_i_ac : ', zv_i_ac(jiindx, 1:jpl)
+
+         !---------------------------------
+         ! Heat content - bottom accretion
+         !---------------------------------
+         jm = 1
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO ji = 1, nbpac
+               ! zindb = 0 if no ice and 1 if yes
+               zindb            =  1.0 -  MAX( 0.0 , SIGN( 1.0                 & 
+                  , - za_i_ac(ji,jl ) ) ) 
+               zhice_old(ji,jl) =  zv_i_ac(ji,jl) /                            &
+                  MAX( za_i_ac(ji,jl) , zeps ) * zindb
+               zdhicbot(ji,jl)  =  zdv_res(ji) / MAX( za_i_ac(ji,jl) , zeps )  & 
+                  *  zindb &
+                  +  zindb * zdh_frazb(ji) ! frazil ice 
+               ! may coalesce
+               ! thickness of residual ice
+               zdummy(ji,jl)    = zv_i_ac(ji,jl)/MAX(za_i_ac(ji,jl),zeps)*zindb
+            END DO !ji
+         END DO !jl
+
+         ! old layers thicknesses and enthalpies
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO jk = 1, nlay_i
+               DO ji = 1, nbpac
+                  zthick0(ji,jk,jl)=  zhice_old(ji,jl) / nlay_i
+                  zqm0   (ji,jk,jl)=  ze_i_ac(ji,jk,jl) * zthick0(ji,jk,jl)
+               END DO !ji
+            END DO !jk
+         END DO !jl
+
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO ji = 1, nbpac
+               zthick0(ji,nlay_i+1,jl) =  zdhicbot(ji,jl)
+               zqm0   (ji,nlay_i+1,jl) =  ze_newice(ji)*zdhicbot(ji,jl)
+            END DO ! ji
+         END DO ! jl
+
+         ! Redistributing energy on the new grid
+         ze_i_ac(:,:,:) = 0.0
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO jk = 1, nlay_i
+               DO layer = 1, nlay_i + 1
+                  DO ji = 1, nbpac
+                     zindb            =  1.0 -  MAX( 0.0 , SIGN( 1.0 ,         & 
+                        - za_i_ac(ji,jl ) ) ) 
+                     ! Redistributing energy on the new grid
+                     zweight         =  MAX (  &
+                        MIN( zhice_old(ji,jl) * layer , zdummy(ji,jl) * jk ) -    &
+                        MAX( zhice_old(ji,jl) * ( layer - 1 ) , zdummy(ji,jl) *   &
+                        ( jk - 1 ) ) , 0.0 )                                  &
+                        /  ( MAX(nlay_i * zthick0(ji,layer,jl),zeps) ) * zindb
+                     ze_i_ac(ji,jk,jl) =  ze_i_ac(ji,jk,jl) +                  &
+                        zweight * zqm0(ji,layer,jl)  
+                  END DO ! ji
+               END DO ! layer
+            END DO ! jk
+         END DO ! jl
+
+         DO jl = ice_cat_bounds(jm,1), ice_cat_bounds(jm,2)
+            DO jk = 1, nlay_i
+               DO ji = 1, nbpac
+                  zindb                =  1.0 - MAX( 0.0 , SIGN( 1.0           &
+                     , - zv_i_ac(ji,jl) ) ) !0 if no ice 
+                  ze_i_ac(ji,jk,jl)    = ze_i_ac(ji,jk,jl) /                   &
+                     MAX( zv_i_ac(ji,jl) , zeps)           &
+                     * za_i_ac(ji,jl) * nlay_i * zindb
+               END DO
+            END DO
+         END DO
+
+         !------------
+         ! Update age 
+         !------------
+         DO jl = 1, jpl
+            DO ji = 1, nbpac
+               !--ice age
+               zindb            = 1.0 - MAX( 0.0 , SIGN( 1.0 , -               &
+                  za_i_ac(ji,jl) ) )  ! 0 if no ice and 1 if yes
+               zoa_i_ac(ji,jl)  = za_old(ji,jl) * zoa_i_ac(ji,jl) /            &
+                  MAX( za_i_ac(ji,jl) , zeps ) * zindb   
+            END DO ! ji
+         END DO ! jl   
+
+         !-----------------
+         ! Update salinity
+         !-----------------
+         IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN
+
+            DO jl = 1, jpl
+               DO ji = 1, nbpac
+                  !zindb = 0 if no ice and 1 if yes
+                  zindb            = 1.0 - MAX( 0.0 , SIGN( 1.0 , -               &
+                     zv_i_ac(ji,jl) ) )  ! 0 if no ice and 1 if yes
+                  zdv              = zv_i_ac(ji,jl) - zv_old(ji,jl)
+                  zsmv_i_ac(ji,jl) = ( zsmv_i_ac(ji,jl) + zdv * zs_newice(ji) ) * &
+                     zindb
+               END DO ! ji
+            END DO ! jl   
+
+         ENDIF ! num_sal
+
+
+         !------------------------------------------------------------------------------!
+         ! 8) Change 2D vectors to 1D vectors 
+         !------------------------------------------------------------------------------!
+
+         DO jl = 1, jpl
+            CALL tab_1d_2d( nbpac, a_i(:,:,jl) , npac(1:nbpac) ,               &
+               za_i_ac(1:nbpac,jl) , jpi, jpj )
+            CALL tab_1d_2d( nbpac, v_i(:,:,jl) , npac(1:nbpac) ,               &
+               zv_i_ac(1:nbpac,jl) , jpi, jpj )
+            CALL tab_1d_2d( nbpac, oa_i(:,:,jl), npac(1:nbpac) ,               &
+               zoa_i_ac(1:nbpac,jl), jpi, jpj )
+            IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) &
+               CALL tab_1d_2d( nbpac, smv_i(:,:,jl) , npac(1:nbpac) ,             &
+               zsmv_i_ac(1:nbpac,jl) , jpi, jpj )
+            DO jk = 1, nlay_i
+               CALL tab_1d_2d( nbpac, e_i(:,:,jk,jl) , npac(1:nbpac),          &
+                  ze_i_ac(1:nbpac,jk,jl), jpi, jpj )
+            END DO ! jk
+         END DO !jl
+         CALL tab_1d_2d( nbpac, fseqv , npac(1:nbpac), fseqv_1d  (1:nbpac) ,   &
+            jpi, jpj )
+
+      ENDIF ! nbpac > 0
+
+      !------------------------------------------------------------------------------!
+      ! 9) Change units for e_i
+      !------------------------------------------------------------------------------!    
+
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ! Correct dimensions to avoid big values
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / unit_fac
+
+                  ! Mutliply by ice volume, and divide by number 
+                  ! of layers to get heat content in 10^9 Joules
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * &
+                     area(ji,jj) * v_i(ji,jj,jl) / &
+                     nlay_i
+               END DO
+            END DO
+         END DO
+      END DO
+
+      !------------------------------------------------------------------------------|
+      ! 10) Conservation check and changes in each ice category
+      !------------------------------------------------------------------------------|
+
+      IF ( con_i ) THEN 
+         CALL lim_column_sum (jpl,   v_i, vt_i_final)
+         fieldid = 'v_i, limthd_lac'
+         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid) 
+
+         CALL lim_column_sum_energy(jpl, nlay_i, e_i, et_i_final)
+         fieldid = 'e_i, limthd_lac'
+         CALL lim_cons_check (et_i_final, et_i_final, 1.0e-3, fieldid) 
+
+         CALL lim_column_sum (jpl,   v_s, vt_s_final)
+         fieldid = 'v_s, limthd_lac'
+         CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid) 
+
+         !     CALL lim_column_sum (jpl,   e_s(:,:,1,:) , et_s_init)
+         !     fieldid = 'e_s, limthd_lac'
+         !     CALL lim_cons_check (et_s_init, et_s_final, 1.0e-3, fieldid) 
+
+         IF( ln_nicep ) THEN
+            WRITE(numout,*) ' vt_i_init : ', vt_i_init(jiindx,jjindx)
+            WRITE(numout,*) ' vt_i_final: ', vt_i_final(jiindx,jjindx)
+            WRITE(numout,*) ' et_i_init : ', et_i_init(jiindx,jjindx)
+            WRITE(numout,*) ' et_i_final: ', et_i_final(jiindx,jjindx)
+         ENDIF
+
+      ENDIF
+
+   END SUBROUTINE lim_thd_lac
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac   ***
+   !!                           no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_lac           ! Empty routine
+   END SUBROUTINE lim_thd_lac
+#endif
+END MODULE limthd_lac
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_sal.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_sal.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limthd_sal.F90	(revision 1844)
@@ -0,0 +1,392 @@
+MODULE limthd_sal
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limthd_sal ***
+   !!                   computation salinity variations in
+   !!                               the ice
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   lim_thd_sal : salinity variations in the ice
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst           ! physical constants (ocean directory)
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE thd_ice
+   USE iceini
+   USE ice
+   USE limistate
+   USE in_out_manager
+   USE limvar
+   USE par_ice
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_sal        ! called by lim_thd
+   PUBLIC lim_thd_sal_init   ! called by lim_thd
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1e-20   ,  &
+      epsi13 = 1e-13   ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_sal(kideb,kiut)
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_sal  ***       
+      !! ** Purpose :
+      !!        This routine computes new salinities in the ice
+      !!
+      !! ** Method  :  4 possibilities
+      !!               -> num_sal = 1 -> constant salinity for z,t
+      !!               -> num_sal = 2 -> S = S(z,t) [simple Vancoppenolle et al 2005]
+      !!               -> num_sal = 3 -> S = S(z)   [multiyear ice]
+      !!               -> num_sal = 4 -> S = S(h)   [Cox and Weeks 74]
+      !!           
+      !! ** Steps
+      !!
+      !! ** Arguments
+      !!
+      !! ** Inputs / Outputs
+      !!
+      !! ** External
+      !!
+      !! ** References
+      !!
+      !! ** History  : 
+      !!
+      !! "Je ne suis pour l'instant qu'a 80% de ma condition, mais c'est 
+      !!  les 30% qui restent qui seront les plus difficiles"
+      !!                                           E. Mpenza
+      !!
+      !!-------------------------------------------------------------------
+      !! History :
+      !!   ori  !  03-05 M. Vancoppenolle UCL-ASTR first coding for LIM-1D
+      !!   3.0  !  05-12 Routine rewritten for the 3-D version
+      !!---------------------------------------------------------------------
+      !!
+      !! * Local variables
+      INTEGER, INTENT(in) :: &
+         kideb, kiut             !: thickness category index
+
+      INTEGER ::             &
+         ji, jk ,            &   !: geographic and layer index 
+         zji, zjj
+
+      REAL(wp) ::            &
+         zsold,              &   !: old salinity
+         zeps=1.0e-06   ,    &   !: very small
+         iflush         ,    &   !: flushing (1) or not (0)
+         iaccrbo        ,    &   !: bottom accretion (1) or not (0)
+         igravdr        ,    &   !: gravity drainage or not
+         isnowic        ,    &   !: gravity drainage or not
+         i_ice_switch   ,    &   !: ice thickness above a certain treshold or not
+         ztmelts        ,    &   !: freezing point of sea ice
+         zaaa           ,    &   !: dummy factor
+         zbbb           ,    &   !: dummy factor
+         zccc           ,    &   !: dummy factor
+         zdiscrim                !: dummy factor
+
+      REAL(wp), DIMENSION(jpij) ::          &
+         ze_init        ,    &   !initial total enthalpy
+         zhiold         ,    &
+         zsiold
+
+      !!---------------------------------------------------------------------
+
+      !------------------------------------------------------------------------------|
+      ! 1) Constant salinity, constant in time                                       |
+      !------------------------------------------------------------------------------|
+
+      IF (num_sal.eq.1) THEN
+
+         !         WRITE(numout,*)
+         !         WRITE(numout,*) 'lim_thd_sal : Ice salinity computation module ', &
+         !         num_sal
+         !         WRITE(numout,*) '~~~~~~~~~~~~'
+
+         DO jk = 1, nlay_i
+            DO ji = kideb, kiut
+               s_i_b(ji,jk) =  bulk_sal
+            END DO ! ji
+         END DO ! jk
+
+         DO ji = kideb, kiut
+            sm_i_b(ji)      =  bulk_sal 
+         END DO ! ji
+
+      ENDIF ! num_sal .EQ. 1
+
+      !------------------------------------------------------------------------------|
+      !  Module 2 : Constant salinity varying in time                                |
+      !------------------------------------------------------------------------------|
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN
+
+         !         WRITE(numout,*)
+         !         WRITE(numout,*) 'lim_thd_sal : Ice salinity computation module ', &
+         !         num_sal
+         !         WRITE(numout,*) '~~~~~~~~~~~'
+         !         WRITE(numout,*)
+
+         !---------------------------------
+         ! Thickness at previous time step
+         !---------------------------------
+         DO ji = kideb, kiut
+            zhiold(ji)   =  ht_i_b(ji) - dh_i_bott(ji) - dh_snowice(ji) -     &
+               dh_i_surf(ji)
+         END DO ! ji
+
+         !---------------------
+         ! Global heat content
+         !---------------------
+
+         ze_init(:)  =  0.0
+         DO jk = 1, nlay_i
+            DO ji = kideb, kiut
+               ze_init(ji) = ze_init(ji) + q_i_b(ji,jk) * ht_i_b(ji) / nlay_i
+            END DO ! ji
+         END DO ! jk
+
+         DO ji = kideb, kiut
+
+            !----------
+            ! Switches 
+            !----------
+
+            ! iflush  : 1 if summer 
+            iflush       =  MAX( 0.0 , SIGN ( 1.0 , t_su_b(ji) - rtt ) ) 
+            ! igravdr : 1 if t_su lt t_bo
+            igravdr      =  MAX( 0.0 , SIGN ( 1.0 , t_bo_b(ji) - t_su_b(ji) ) )
+            ! iaccrbo : 1 if bottom accretion
+            iaccrbo      =  MAX( 0.0 , SIGN ( 1.0 , dh_i_bott(ji) ) )
+            ! isnowic : 1 if snow ice formation
+            i_ice_switch = 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - ht_i_b(ji) + 1.0e-2 ) )
+            isnowic      = 1.0 - MAX ( 0.0 , SIGN ( 1.0 , - dh_snowice(ji) ) ) * &
+               i_ice_switch
+
+            !---------------------
+            ! Salinity tendencies
+            !---------------------
+
+            ! drainage by gravity drainage
+            dsm_i_gd_1d(ji) = - igravdr *                                     & 
+               MAX( sm_i_b(ji) - sal_G , 0.0 ) /             &
+               time_G * rdt_ice 
+
+            ! drainage by flushing  
+            dsm_i_fl_1d(ji)  = - iflush *                                     &
+               MAX( sm_i_b(ji) - sal_F , 0.0 ) /             & 
+               time_F * rdt_ice
+
+            !-----------------
+            ! Update salinity   
+            !-----------------
+
+            ! only drainage terms ( gravity drainage and flushing )
+            ! snow ice / bottom sources are added in lim_thd_ent
+            ! to conserve energy
+            zsiold(ji) = sm_i_b(ji)
+            sm_i_b(ji) = sm_i_b(ji)                                           &
+               + dsm_i_fl_1d(ji) + dsm_i_gd_1d(ji)  !                 &
+
+            ! if no ice, salinity eq 0.1
+            i_ice_switch  = 1.0 - MAX ( 0.0, SIGN (1.0 , - ht_i_b(ji) ) )
+            sm_i_b(ji)    = i_ice_switch*sm_i_b(ji) + s_i_min * ( 1.0 -       &
+               i_ice_switch )
+         END DO ! ji
+
+         ! Salinity profile
+         CALL lim_var_salprof1d(kideb,kiut)
+
+         !----------------------------
+         ! Heat flux - brine drainage
+         !----------------------------
+
+         DO ji = kideb, kiut
+            ! iflush  : 1 if summer 
+            iflush       =  MAX( 0.0 , SIGN ( 1.0 , t_su_b(ji) - rtt ) ) 
+            ! igravdr : 1 if t_su lt t_bo
+            igravdr      =  MAX( 0.0 , SIGN ( 1.0 , t_bo_b(ji) - t_su_b(ji) ) ) 
+            ! iaccrbo : 1 if bottom accretion
+            iaccrbo      =  MAX( 0.0 , SIGN ( 1.0 , dh_i_bott(ji) ) )
+
+            fhbri_1d(ji) = 0.0
+         END DO ! ji
+
+         !----------------------------
+         ! Salt flux - brine drainage
+         !----------------------------
+         DO ji = kideb, kiut
+            i_ice_switch  = 1.0 - MAX ( 0.0, SIGN (1.0 , - ht_i_b(ji) ) )
+            fsbri_1d(ji) = fsbri_1d(ji) -  &
+               i_ice_switch * rhoic * a_i_b(ji) * ht_i_b(ji) *  &
+               ( MAX(dsm_i_gd_1d(ji) + dsm_i_fl_1d(ji), &
+               sm_i_b(ji) - zsiold(ji) ) ) / rdt_ice
+            IF ( num_sal .EQ. 4 ) fsbri_1d(ji) = 0.0
+
+         END DO ! ji
+
+         ! Only necessary for conservation check since salinity is modified
+         !--------------------
+         ! Temperature update
+         !--------------------
+         DO jk = 1, nlay_i
+
+            DO ji = kideb, kiut
+
+               ztmelts    =  -tmut*s_i_b(ji,jk) + rtt
+               !Conversion q(S,T) -> T (second order equation)
+               zaaa         =  cpic
+               zbbb         =  ( rcp - cpic ) * ( ztmelts - rtt ) + &
+                  q_i_b(ji,jk) / rhoic - lfus
+               zccc         =  lfus * ( ztmelts - rtt )
+               zdiscrim     =  SQRT( MAX(zbbb*zbbb - 4.0*zaaa*zccc,0.0) )
+               t_i_b(ji,jk) =  rtt - ( zbbb + zdiscrim ) / & 
+                  ( 2.0 *zaaa )
+            END DO !ji
+
+         END DO !jk
+
+      ENDIF ! num_sal .EQ. 2
+
+      !------------------------------------------------------------------------------|
+      !  Module 3 : Profile of salinity, constant in time                            |
+      !------------------------------------------------------------------------------|
+
+      IF ( num_sal .EQ. 3 ) THEN
+
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_thd_sal : Ice salinity computation module ', &
+            num_sal
+         WRITE(numout,*) '~~~~~~~~~~~~'
+
+         CALL lim_var_salprof1d(kideb,kiut)
+
+      ENDIF ! num_sal .EQ. 3
+
+      !------------------------------------------------------------------------------|
+      !  Module 4 : Constant salinity varying in time                                |
+      !------------------------------------------------------------------------------|
+
+      ! Cox and Weeks, 1974
+      IF (num_sal.eq.5) THEN
+
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_thd_sal : Ice salinity computation module ', &
+            num_sal
+         WRITE(numout,*) '~~~~~~~~~~~~'
+
+         DO ji = kideb, kiut
+
+            zsold = sm_i_b(ji)
+
+            IF (ht_i_b(ji).lt.0.4) THEN
+               sm_i_b(ji)    = 14.24 - 19.39*ht_i_b(ji) 
+            ELSE
+               sm_i_b(ji)    =  7.88 - 1.59*ht_i_b(ji)
+               sm_i_b(ji)    = MIN(sm_i_b(ji),zsold)  
+            ENDIF
+
+            IF ( ht_i_b(ji) .GT. 3.06918239 ) THEN 
+               sm_i_b(ji)     = 3.0
+            ENDIF
+
+            DO jk = 1, nlay_i
+               s_i_b(ji,jk)   = sm_i_b(ji)
+            END DO
+
+         END DO ! ji
+
+      ENDIF ! num_sal
+
+      !------------------------------------------------------------------------------|
+      ! 5) Computation of salt flux due to Bottom growth
+      !------------------------------------------------------------------------------|
+
+      IF ( num_sal .EQ. 4 ) THEN
+         DO ji = kideb, kiut
+            zji                 = MOD( npb(ji) - 1, jpi ) + 1
+            zjj                 = ( npb(ji) - 1 ) / jpi + 1
+            fseqv_1d(ji) = fseqv_1d(ji)              + & 
+               ( sss_m(zji,zjj) - bulk_sal    ) * & 
+               rhoic * a_i_b(ji) * &
+               MAX( dh_i_bott(ji) , 0.0 ) / rdt_ice
+         END DO
+      ELSE
+         DO ji = kideb, kiut
+            zji                 = MOD( npb(ji) - 1, jpi ) + 1
+            zjj                 = ( npb(ji) - 1 ) / jpi + 1
+            fseqv_1d(ji) = fseqv_1d(ji)              + & 
+               ( sss_m(zji,zjj) - s_i_new(ji) ) * & 
+               rhoic * a_i_b(ji) * &
+               MAX( dh_i_bott(ji) , 0.0 ) / rdt_ice
+         END DO ! ji
+      ENDIF
+
+      !-- End of salinity computations
+   END SUBROUTINE lim_thd_sal
+   !==============================================================================
+
+   SUBROUTINE lim_thd_sal_init
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_thd_sal_init  ***
+      !!
+      !! ** Purpose :   initialization of ice salinity parameters
+      !!
+      !! ** Method  : Read the namicesal namelist and check the parameter
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicesal
+      !!
+      !! history :
+      !!   3.0  !  July 2005 M. Vancoppenolle  Original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicesal/ num_sal, bulk_sal, sal_G, time_G, sal_F, time_F, &
+         s_i_max, s_i_min, s_i_0, s_i_1
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicesal
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicesal )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_thd_sal_init : Ice parameters for salinity '
+         WRITE(numout,*) '~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) ' switch for salinity num_sal        : ', num_sal
+         WRITE(numout,*) ' bulk salinity value if num_sal = 1 : ', bulk_sal
+         WRITE(numout,*) ' restoring salinity for GD          : ', sal_G
+         WRITE(numout,*) ' restoring time for GD              : ', time_G
+         WRITE(numout,*) ' restoring salinity for flushing    : ', sal_F
+         WRITE(numout,*) ' restoring time for flushing        : ', time_F
+         WRITE(numout,*) ' Maximum tolerated ice salinity     : ', s_i_max
+         WRITE(numout,*) ' Minimum tolerated ice salinity     : ', s_i_min
+         WRITE(numout,*) ' 1st salinity for salinity profile  : ', s_i_0
+         WRITE(numout,*) ' 2nd salinity for salinity profile  : ', s_i_1
+      ENDIF
+
+   END SUBROUTINE lim_thd_sal_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                No sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd_sal        ! Empty routine
+   END SUBROUTINE lim_thd_sal
+#endif
+   !!======================================================================
+END MODULE limthd_sal
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtrp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtrp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limtrp.F90	(revision 1844)
@@ -0,0 +1,632 @@
+MODULE limtrp
+   !!======================================================================
+   !!                       ***  MODULE limtrp   ***
+   !! LIM transport ice model : sea-ice advection/diffusion
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_trp      : advection/diffusion process of sea ice
+   !!   lim_trp_init : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE dom_oce
+   USE in_out_manager  ! I/O manager
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE dom_ice
+   USE ice
+   USE iceini
+   USE limistate
+   USE limadv
+   USE limhdf
+   USE lbclnk
+   USE lib_mpp
+   USE par_ice
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_trp       ! called by ice_step
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC  ::   &  !:
+      bound  = 0.e0           !: boundary condit. (0.0 no-slip, 1.0 free-slip)
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi06 = 1.e-06  ,  &
+      epsi03 = 1.e-03  ,  &
+      epsi16 = 1.e-16  ,  &
+      rzero  = 0.e0    ,  &
+      rone   = 1.e0    ,  &
+      zeps10 = 1.e-10
+
+   !! * Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_trp( kt ) 
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_trp ***
+      !!                    
+      !! ** purpose : advection/diffusion process of sea ice
+      !!
+      !! ** method  : variables included in the process are scalar,   
+      !!     other values are considered as second order. 
+      !!     For advection, a second order Prather scheme is used.  
+      !!
+      !! ** action :
+      !!
+      !! History :
+      !!   1.0  !  00-01 (M.A. Morales Maqueda, H. Goosse, and T. Fichefet)  Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!   2.0  !  04-01 (G. Madec, C. Ethe)  F90, mpp
+      !!   3.0  !  05-11 (M. Vancoppenolle)   Multi-layer sea ice, salinity variations
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !! * Local Variables
+      INTEGER  ::   ji, jj, jk, jl, layer, &  ! dummy loop indices
+         initad           ! number of sub-timestep for the advection
+      INTEGER  ::   ji_maxu, ji_maxv, jj_maxu, jj_maxv
+
+      REAL(wp) ::  &                              
+         zindb  ,  &
+         zindsn ,  &
+         zindic ,  &
+         zusvosn,  &
+         zusvoic,  &
+         zvbord ,  &
+         zcfl   ,  &
+         zusnit ,  &
+         zrtt, zsal, zage, &
+         zbigval, ze, &
+         zmaxu, zmaxv
+
+      REAL(wp), DIMENSION(jpi,jpj)  ::   &  ! temporary workspace
+         zui_u , zvi_v , zsm   ,         &
+         zs0at, zs0ow
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl):: &  ! temporary workspace
+         zs0ice, zs0sn, zs0a   ,         &
+         zs0c0 ,                         &
+         zs0sm , zs0oi
+
+      ! MHE Multilayer heat content
+      REAL(wp), DIMENSION(jpi,jpj,jkmax,jpl)  ::   &  ! temporary workspace
+         zs0e
+
+      !---------------------------------------------------------------------
+
+      IF( numit == nstart  )   CALL lim_trp_init      ! Initialization (first time-step only)
+
+      zsm(:,:) = area(:,:)
+
+      IF( ln_limdyn ) THEN
+         IF( kt == nit000 .AND. lwp ) THEN
+            WRITE(numout,*) ' lim_trp : Ice Advection'
+            WRITE(numout,*) ' ~~~~~~~'
+         ENDIF
+
+         !-----------------------------------------------------------------------------!
+         ! 1) CFL Test                                                             
+         !-----------------------------------------------------------------------------!
+
+         !------------------------------------------
+         ! ice velocities at ocean U- and V-points 
+         !------------------------------------------
+
+         ! zvbord factor between 1 and 2 to take into account slip or no-slip boundary conditions.        
+         zvbord = 1.0 + ( 1.0 - bound )
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1
+               zui_u(ji,jj) = u_ice(ji,jj)
+               zvi_v(ji,jj) = v_ice(ji,jj)
+            END DO
+         END DO
+
+         ! Lateral boundary conditions
+         CALL lbc_lnk( zui_u, 'U', -1. )
+         CALL lbc_lnk( zvi_v, 'V', -1. )
+
+         !-------------------------
+         ! CFL test for stability
+         !-------------------------
+
+         zcfl  = 0.e0
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zui_u(1:jpim1, :     ) ) * rdt_ice / e1u(1:jpim1, :     ) ) )
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zvi_v( :     ,1:jpjm1) ) * rdt_ice / e2v( :     ,1:jpjm1) ) )
+
+         zmaxu = 0.0
+         zmaxv = 0.0
+         DO ji = 1, jpim1
+            DO jj = 1, jpjm1
+               IF ( (ABS(zui_u(ji,jj)) .GT. zmaxu) ) THEN 
+                  zmaxu = MAX(zui_u(ji,jj), zmaxu )
+                  ji_maxu = ji
+                  jj_maxu = jj
+               ENDIF
+               IF ( (ABS(zvi_v(ji,jj)) .GT. zmaxv) ) THEN 
+                  zmaxv = MAX(zvi_v(ji,jj), zmaxv )
+                  ji_maxv = ji
+                  jj_maxv = jj
+               ENDIF
+            END DO
+         END DO
+
+         IF (lk_mpp ) CALL mpp_max(zcfl)
+
+         IF ( zcfl > 0.5 .AND. lwp ) &
+            WRITE(numout,*) 'lim_trp : violation of cfl criterion the ',nday,'th day, cfl = ',zcfl
+
+         !-----------------------------------------------------------------------------!
+         ! 2) Computation of transported fields                                        
+         !-----------------------------------------------------------------------------!
+
+         !------------------------------------------------------
+         ! 1.1) Snow vol, ice vol, salt and age contents, area
+         !------------------------------------------------------
+
+         zs0ow (:,:) =  ato_i(:,:)    * area(:,:)           ! Open water area 
+         DO jl = 1, jpl  !sum over thickness categories
+            ! area -> is the unmasked and masked area of T-grid cell
+            zs0sn (:,:,jl) =  v_s(:,:,jl)    * area(:,:)    ! Snow volume.
+            zs0ice(:,:,jl) =  v_i(:,:,jl)    * area(:,:)    ! Ice volume.
+            zs0a  (:,:,jl) =  a_i(:,:,jl)    * area(:,:)    ! Ice area
+            zs0sm (:,:,jl) =  smv_i(:,:,jl)  * area(:,:)    ! Salt content
+            zs0oi (:,:,jl) =  oa_i (:,:,jl)  * area(:,:)    ! Age content
+
+            !----------------------------------
+            ! 1.2) Ice and snow heat contents
+            !----------------------------------
+
+            zs0c0 (:,:,jl)     = e_s(:,:,1,jl)              ! Snow heat cont.
+            DO jk = 1, nlay_i
+               zs0e(:,:,jk,jl) = e_i(:,:,jk,jl)             ! Ice heat content
+            END DO
+         END DO
+
+         !-----------------------------------------------------------------------------!
+         ! 3) Advection of Ice fields                                              
+         !-----------------------------------------------------------------------------!
+
+         ! If ice drift field is too fast, use an appropriate time step for advection.         
+         initad = 1 + INT( MAX( rzero, SIGN( rone, zcfl-0.5 ) ) )
+         zusnit = 1.0 / REAL( initad ) 
+
+         IF ( MOD( nday , 2 ) == 0) THEN
+            DO jk = 1,initad
+               !--- ice open water area
+               CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0ow(:,:) , sxopw(:,:) , & 
+                  sxxopw(:,:), syopw(:,:) , & 
+                  syyopw(:,:), sxyopw(:,:) )
+               CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0ow(:,:) , sxopw (:,:) , &
+                  sxxopw(:,:), syopw (:,:) , & 
+                  syyopw(:,:), sxyopw(:,:) )
+               DO jl = 1, jpl
+                  !--- ice volume  ---
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0ice(:,:,jl) , sxice (:,:,jl) , & 
+                     sxxice(:,:,jl) , syice (:,:,jl) , & 
+                     syyice(:,:,jl) , sxyice(:,:,jl) )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0ice(:,:,jl) , sxice (:,:,jl) , &
+                     sxxice(:,:,jl) , syice (:,:,jl) , & 
+                     syyice(:,:,jl) , sxyice(:,:,jl) )
+                  !--- snow volume  ---
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0sn (:,:,jl) , sxsn  (:,:,jl) , &
+                     sxxsn (:,:,jl) , sysn  (:,:,jl) , &
+                     syysn (:,:,jl) , sxysn (:,:,jl) )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0sn (:,:,jl) , sxsn  (:,:,jl) , &
+                     sxxsn (:,:,jl) , sysn  (:,:,jl) , &
+                     syysn (:,:,jl) , sxysn (:,:,jl) )
+                  !--- ice salinity ---
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0sm (:,:,jl) , sxsal (:,:,jl) , &
+                     sxxsal(:,:,jl) , sysal (:,:,jl) , &
+                     syysal(:,:,jl) , sxysal(:,:,jl)  )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0sm (:,:,jl) , sxsal (:,:,jl) , &
+                     sxxsal(:,:,jl) , sysal (:,:,jl) , &
+                     syysal(:,:,jl) , sxysal(:,:,jl)  )
+                  !--- ice age      ---     
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0oi (:,:,jl) , sxage (:,:,jl) , &
+                     sxxage(:,:,jl) , syage (:,:,jl) , &
+                     syyage(:,:,jl) , sxyage(:,:,jl)  )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0oi (:,:,jl) , sxage (:,:,jl) , &
+                     sxxage(:,:,jl) , syage (:,:,jl) , &
+                     syyage(:,:,jl) , sxyage(:,:,jl)  )
+                  !--- ice concentrations ---
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0a  (:,:,jl) , sxa   (:,:,jl) , &
+                     sxxa  (:,:,jl) , sya   (:,:,jl) , & 
+                     syya  (:,:,jl) , sxya  (:,:,jl)  )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0a  (:,:,jl) , sxa   (:,:,jl) , & 
+                     sxxa  (:,:,jl) , sya   (:,:,jl) , & 
+                     syya  (:,:,jl) , sxya  (:,:,jl)  )
+                  !--- ice / snow thermal energetic contents ---
+                  CALL lim_adv_x( zusnit, zui_u, rone , zsm, zs0c0 (:,:,jl) , sxc0  (:,:,jl) , & 
+                     sxxc0 (:,:,jl) , syc0  (:,:,jl) , &
+                     syyc0 (:,:,jl) , sxyc0 (:,:,jl)  )
+                  CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, zs0c0 (:,:,jl) , sxc0  (:,:,jl) , &
+                     sxxc0 (:,:,jl) , syc0  (:,:,jl) , &
+                     syyc0 (:,:,jl) , sxyc0 (:,:,jl)  )
+                  DO layer = 1, nlay_i
+                     CALL lim_adv_x( zusnit, zui_u, rone , zsm, &
+                        zs0e(:,:,layer,jl) , sxe (:,:,layer,jl) , & 
+                        sxxe(:,:,layer,jl) , sye (:,:,layer,jl) , &
+                        syye(:,:,layer,jl) , sxye(:,:,layer,jl) )
+                     CALL lim_adv_y( zusnit, zvi_v, rzero, zsm, & 
+                        zs0e(:,:,layer,jl) , sxe (:,:,layer,jl) , & 
+                        sxxe(:,:,layer,jl) , sye (:,:,layer,jl) , &
+                        syye(:,:,layer,jl) , sxye(:,:,layer,jl) )
+                  END DO
+               END DO
+            END DO
+         ELSE
+            DO jk = 1, initad
+               !--- ice volume  ---
+               CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0ow (:,:) , sxopw (:,:) , &
+                  sxxopw(:,:) , syopw (:,:) , & 
+                  syyopw(:,:) , sxyopw(:,:) )
+               CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0ow (:,:) , sxopw (:,:) , & 
+                  sxxopw(:,:) , syopw (:,:) , &
+                  syyopw(:,:) , sxyopw(:,:) )
+               DO jl = 1, jpl
+                  !--- ice volume  ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0ice(:,:,jl) , sxice (:,:,jl) , &
+                     sxxice(:,:,jl) , syice (:,:,jl) , & 
+                     syyice(:,:,jl) , sxyice(:,:,jl) )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0ice(:,:,jl) , sxice (:,:,jl) , & 
+                     sxxice(:,:,jl) , syice (:,:,jl) , &
+                     syyice(:,:,jl) , sxyice(:,:,jl) )
+                  !--- snow volume  ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0sn (:,:,jl) , sxsn  (:,:,jl) , & 
+                     sxxsn (:,:,jl) , sysn  (:,:,jl) , & 
+                     syysn (:,:,jl) , sxysn (:,:,jl) )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0sn (:,:,jl) , sxsn  (:,:,jl) , & 
+                     sxxsn (:,:,jl) , sysn  (:,:,jl) , & 
+                     syysn (:,:,jl) , sxysn (:,:,jl) )
+                  !--- ice salinity ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0sm (:,:,jl) , sxsal (:,:,jl) , &
+                     sxxsal(:,:,jl) , sysal (:,:,jl) , &
+                     syysal(:,:,jl) , sxysal(:,:,jl) )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0sm (:,:,jl) , sxsal (:,:,jl) , &
+                     sxxsal(:,:,jl) , sysal (:,:,jl) , &
+                     syysal(:,:,jl) , sxysal(:,:,jl) )
+                  !--- ice age      ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0oi (:,:,jl) , sxage (:,:,jl) , &
+                     sxxage(:,:,jl) , syage (:,:,jl) , & 
+                     syyage(:,:,jl) , sxyage(:,:,jl)  )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0oi (:,:,jl) , sxage (:,:,jl) , &
+                     sxxage(:,:,jl) , syage (:,:,jl) , &
+                     syyage(:,:,jl) , sxyage(:,:,jl)   )
+                  !--- ice concentration ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0a  (:,:,jl) , sxa   (:,:,jl) , & 
+                     sxxa  (:,:,jl) , sya   (:,:,jl) , & 
+                     syya  (:,:,jl) , sxya  (:,:,jl)  )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0a  (:,:,jl) , sxa   (:,:,jl) , & 
+                     sxxa  (:,:,jl) , sya   (:,:,jl) , & 
+                     syya  (:,:,jl) , sxya  (:,:,jl)  )
+                  !--- ice / snow thermal energetic contents ---
+                  CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0c0 (:,:,jl) , sxc0  (:,:,jl) , & 
+                     sxxc0 (:,:,jl) , syc0  (:,:,jl) , &
+                     syyc0 (:,:,jl) , sxyc0 (:,:,jl)  )
+                  CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0c0 (:,:,jl) , sxc0  (:,:,jl) , &
+                     sxxc0 (:,:,jl) , syc0  (:,:,jl) , &
+                     syyc0 (:,:,jl) , sxyc0 (:,:,jl)  )
+                  DO layer = 1, nlay_i
+                     CALL lim_adv_y( zusnit, zvi_v, rone , zsm, zs0e(:,:,layer,jl) , &
+                        sxe (:,:,layer,jl) , sxxe (:,:,layer,jl) , sye (:,:,layer,jl) , &
+                        syye (:,:,layer,jl), sxye (:,:,layer,jl) )
+                     CALL lim_adv_x( zusnit, zui_u, rzero, zsm, zs0e(:,:,layer,jl) , &
+                        sxe (:,:,layer,jl) , sxxe (:,:,layer,jl) , sye (:,:,layer,jl) , &
+                        syye (:,:,layer,jl), sxye (:,:,layer,jl)  )
+                  END DO
+
+               END DO
+            END DO
+         ENDIF
+
+         !-------------------------------------------
+         ! Recover the properties from their contents
+         !-------------------------------------------
+
+         zs0ow (:,:)       = zs0ow(:,:) / area(:,:)
+         DO jl = 1, jpl
+            zs0ice(:,:,jl) = zs0ice(:,:,jl) / area(:,:)
+            zs0sn (:,:,jl) = zs0sn (:,:,jl) / area(:,:)
+            zs0sm (:,:,jl) = zs0sm (:,:,jl) / area(:,:)
+            zs0oi (:,:,jl) = zs0oi (:,:,jl) / area(:,:)
+            zs0a  (:,:,jl) = zs0a  (:,:,jl) / area(:,:)
+            zs0c0 (:,:,jl) = zs0c0 (:,:,jl) / area(:,:)
+            DO jk = 1, nlay_i
+               zs0e(:,:,jk,jl) = zs0e(:,:,jk,jl) / area(:,:)
+            END DO
+         END DO
+
+         !------------------------------------------------------------------------------!
+         ! 4) Diffusion of Ice fields                  
+         !------------------------------------------------------------------------------!
+
+         !------------------------------------
+         ! 4.1) diffusion of open water area
+         !------------------------------------
+
+         ! Compute total ice fraction
+         zs0at(:,:) = 0.0
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zs0at (ji,jj) = zs0at(ji,jj) + zs0a(ji,jj,jl) !
+               END DO
+            END DO
+         END DO
+
+         ! Masked eddy diffusivity coefficient at ocean U- and V-points
+         DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0at(ji  ,jj) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone, -zs0at(ji+1,jj) ) ) ) * ahiu(ji,jj)
+               pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0at(ji,jj  ) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone,- zs0at(ji,jj+1) ) ) ) * ahiv(ji,jj)
+            END DO !jj
+         END DO ! ji
+
+         ! Diffusion
+         CALL lim_hdf( zs0ow (:,:) )
+
+         !----------------------------------------
+         ! 4.2) Diffusion of other ice variables
+         !----------------------------------------
+         DO jl = 1, jpl
+
+            ! Masked eddy diffusivity coefficient at ocean U- and V-points
+            DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
+               DO ji = 1 , fs_jpim1   ! vector opt.
+                  pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji  ,jj,jl) ) ) )   &
+                     &        * ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji+1,jj,jl) ) ) ) * ahiu(ji,jj)
+                  pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji,jj,jl  ) ) ) )   &
+                     &        * ( 1.0 - MAX( rzero, SIGN( rone,- zs0a(ji,jj+1,jl) ) ) ) * ahiv(ji,jj)
+               END DO !jj
+            END DO ! ji
+
+            CALL lim_hdf( zs0ice (:,:,jl) )
+            CALL lim_hdf( zs0sn  (:,:,jl) )
+            CALL lim_hdf( zs0sm  (:,:,jl) )
+            CALL lim_hdf( zs0oi  (:,:,jl) )
+            CALL lim_hdf( zs0a   (:,:,jl) )
+            CALL lim_hdf( zs0c0  (:,:,jl) )
+            DO jk = 1, nlay_i
+               CALL lim_hdf( zs0e (:,:,jk,jl) )
+            END DO ! jk
+         END DO !jl
+
+         !-----------------------------------------
+         ! 4.3) Remultiply everything by ice area
+         !-----------------------------------------
+         zs0ow(:,:) = MAX(rzero, zs0ow(:,:) * area(:,:) )
+         DO jl = 1, jpl
+            zs0ice(:,:,jl) = MAX( rzero, zs0ice(:,:,jl) * area(:,:) )    !!bug:  est-ce utile
+            zs0sn (:,:,jl) = MAX( rzero, zs0sn (:,:,jl) * area(:,:) )    !!bug:  cf /area  juste apres
+            zs0sm (:,:,jl) = MAX( rzero, zs0sm (:,:,jl) * area(:,:) )    !!bug:  cf /area  juste apres
+            zs0oi (:,:,jl) = MAX( rzero, zs0oi (:,:,jl) * area(:,:) )
+            zs0a  (:,:,jl) = MAX( rzero, zs0a  (:,:,jl) * area(:,:) )    !! suppress both change le resultat
+            zs0c0 (:,:,jl) = MAX( rzero, zs0c0 (:,:,jl) * area(:,:) )
+            DO jk = 1, nlay_i
+               zs0e(:,:,jk,jl) = MAX( rzero, zs0e (:,:,jk,jl) * area(:,:) )
+            END DO ! jk
+         END DO ! jl
+
+         !------------------------------------------------------------------------------!
+         ! 5) Update and limit ice properties after transport                           
+         !------------------------------------------------------------------------------!
+
+         !--------------------------------------------------
+         ! 5.1) Recover mean values over the grid squares.
+         !--------------------------------------------------
+
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zs0e (ji,jj,jk,jl) =  &
+                        MAX( rzero, zs0e (ji,jj,jk,jl) / area(ji,jj) )
+                  END DO
+               END DO
+            END DO
+         END DO
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zs0ow (ji,jj) = MAX( rzero, zs0ow (ji,jj) / area(ji,jj) )
+            END DO
+         END DO
+
+         zs0at(:,:) = 0.0
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zs0sn (ji,jj,jl) = MAX( rzero, zs0sn (ji,jj,jl)/area(ji,jj) )
+                  zs0ice(ji,jj,jl) = MAX( rzero, zs0ice(ji,jj,jl)/area(ji,jj) )
+                  zs0sm (ji,jj,jl) = MAX( rzero, zs0sm (ji,jj,jl)/area(ji,jj) )
+                  zs0oi (ji,jj,jl) = MAX( rzero, zs0oi (ji,jj,jl)/area(ji,jj) )
+                  zs0a  (ji,jj,jl) = MAX( rzero, zs0a  (ji,jj,jl)/area(ji,jj) )
+                  zs0c0 (ji,jj,jl) = MAX( rzero, zs0c0 (ji,jj,jl)/area(ji,jj) )
+                  zs0at (ji,jj)    = zs0at(ji,jj) + zs0a(ji,jj,jl)
+               END DO
+            END DO
+         END DO
+
+         !---------------------------------------------------------
+         ! 5.2) Snow thickness, Ice thickness, Ice concentrations
+         !---------------------------------------------------------
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zindb         = MAX( 0.0 , SIGN( 1.0, zs0at(ji,jj) - zeps10) )
+               zs0ow(ji,jj)  = (1.0 - zindb) + zindb*MAX( zs0ow(ji,jj), 0.00 )
+               ato_i(ji,jj)  = zs0ow(ji,jj)
+            END DO
+         END DO
+
+         ! Remove very small areas 
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zindb         = MAX( 0.0 , SIGN( 1.0, zs0a(ji,jj,jl) - zeps10) )
+
+                  zs0a(ji,jj,jl)  = zindb * MIN( zs0a(ji,jj,jl), 0.99 )
+                  v_s(ji,jj,jl)   = zindb * zs0sn (ji,jj,jl) 
+                  v_i(ji,jj,jl)   = zindb * zs0ice(ji,jj,jl)
+
+                  zindsn          = MAX( rzero, SIGN( rone, v_s(ji,jj,jl) - zeps10 ) )
+                  zindic          = MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - zeps10 ) )
+                  zindb           = MAX( zindsn, zindic )
+                  zs0a (ji,jj,jl) = zindb  * zs0a(ji,jj,jl) !ice concentration
+                  a_i  (ji,jj,jl) = zs0a(ji,jj,jl)
+                  v_s  (ji,jj,jl) = zindsn * v_s(ji,jj,jl)
+                  v_i  (ji,jj,jl) = zindic * v_i(ji,jj,jl)
+               END DO
+            END DO
+         END DO
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zs0at(ji,jj)       = SUM( zs0a(ji,jj,1:jpl) )
+            END DO
+         END DO
+
+         !----------------------
+         ! 5.3) Ice properties
+         !----------------------
+
+         zbigval         =  1.0d+13
+
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+
+                  ! Switches and dummy variables
+                  zusvosn         = 1.0/MAX( v_s(ji,jj,jl) , epsi16 )
+                  zusvoic         = 1.0/MAX( v_i(ji,jj,jl) , epsi16 )
+                  zrtt            = 173.15 * rone 
+                  zindsn          = MAX( rzero, SIGN( rone, v_s(ji,jj,jl) - zeps10 ) )
+                  zindic          = MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - zeps10 ) )
+                  zindb           = MAX( zindsn, zindic )
+
+                  ! Ice salinity and age
+                  zsal            = MAX( MIN( (rhoic-rhosn)/rhoic*sss_m(ji,jj)  , &
+                     zusvoic * zs0sm(ji,jj,jl) ), s_i_min ) * &
+                     v_i(ji,jj,jl)
+                  IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) & 
+                     smv_i(ji,jj,jl) = zindic*zsal + (1.0-zindic)*0.0
+
+                  zage            = MAX( MIN( zbigval, zs0oi(ji,jj,jl) / & 
+                     MAX( a_i(ji,jj,jl), epsi16 )  ), 0.0 ) * &
+                     a_i(ji,jj,jl)
+                  oa_i (ji,jj,jl)  = zindic*zage 
+
+                  ! Snow heat content
+                  ze              =  MIN( MAX( 0.0, zs0c0(ji,jj,jl)*area(ji,jj) ), zbigval )
+                  e_s(ji,jj,1,jl) = zindsn * ze + (1.0 - zindsn) * 0.0      
+
+               END DO !ji
+            END DO !jj
+         END DO ! jl
+
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ! Ice heat content
+                     zindic          =  MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - zeps10 ) )
+                     ze              =  MIN( MAX( 0.0, zs0e(ji,jj,jk,jl)*area(ji,jj) ), zbigval )
+                     e_i(ji,jj,jk,jl) = zindic * ze    + ( 1.0 - zindic ) * 0.0
+                  END DO !ji
+               END DO ! jj
+            END DO ! jk
+         END DO ! jl
+
+      ENDIF
+
+      IF(ln_ctl) THEN   ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=area , clinfo1=' lim_trp  : cell area :')
+         CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_trp  : at_i      :')
+         CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_trp  : vt_i      :')
+         CALL prt_ctl(tab2d_1=vt_s , clinfo1=' lim_trp  : vt_s      :')
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_trp  : a_i      : ')
+            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_trp  : ht_i     : ')
+            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_trp  : ht_s     : ')
+            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_trp  : v_i      : ')
+            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_trp  : v_s      : ')
+            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_trp  : e_s      : ')
+            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_trp  : t_su     : ')
+            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_trp  : t_snow   : ')
+            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_trp  : sm_i     : ')
+            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_trp  : smv_i    : ')
+            DO jk = 1, nlay_i
+               CALL prt_ctl_info(' ')
+               CALL prt_ctl_info(' - Layer : ', ivar1=jk)
+               CALL prt_ctl_info('   ~~~~~~~')
+               CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' lim_trp  : t_i      : ')
+               CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' lim_trp  : e_i      : ')
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE lim_trp
+
+
+   SUBROUTINE lim_trp_init
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_trp_init  ***
+      !!
+      !! ** Purpose :   initialization of ice advection parameters
+      !!
+      !! ** Method  : Read the namicetrp namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicetrp
+      !!
+      !! history :
+      !!   2.0  !  03-08 (C. Ethe)  Original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicetrp/ bound
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicetrp
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicetrp )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_trp_init : Ice parameters for advection '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) ' boundary conditions (0.0 no-slip, 1.0 free-slip) bound  = ', bound
+         WRITE(numout,*) 
+      ENDIF
+
+   END SUBROUTINE lim_trp_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                No sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_trp        ! Empty routine
+   END SUBROUTINE lim_trp
+#endif
+
+   !!======================================================================
+END MODULE limtrp
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limupdate.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limupdate.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limupdate.F90	(revision 1844)
@@ -0,0 +1,1105 @@
+MODULE limupdate
+   !!======================================================================
+   !!                     ***  MODULE  limupdate  ***
+   !!    Update of sea-ice global variables
+   !!    at the end of the time step
+   !!    
+   !!    Ice speed from ice dynamics
+   !!    Ice thickness, Snow thickness, Temperatures, Lead fraction
+   !!      from advection and ice thermodynamics 
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!    lim_update   : computes update of sea-ice global variables 
+   !!                   from trend terms
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE limistate
+   USE limrhg          ! ice rheology
+   USE lbclnk
+
+   USE dom_oce
+   USE oce             ! dynamics and tracers variables
+   USE in_out_manager
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE dom_ice
+   USE phycst          ! Define parameters for the routines
+   USE ice
+   USE iceini
+   USE lbclnk
+   USE limdyn
+   USE limtrp
+   USE limthd
+   USE limsbc
+   USE limdia
+   USE limwri
+   USE limrst
+   USE thd_ice         ! LIM thermodynamic sea-ice variables
+   USE par_ice
+   USE limitd_th
+   USE limvar
+   USE prtctl          ! Print control
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_update ! routine called by ice_step
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_update
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_update  ***
+      !!               
+      !! ** Purpose :  Computes update of sea-ice global variables at 
+      !!               the end of the time step.
+      !!               Address pathological cases
+      !!               This place is very important
+      !!                
+      !! ** Method  :  Mathematical
+      !!
+      !! ** Action  : - 
+      !!
+      !! History : This routine was new for LIM 3.0 
+      !!   3.0  !  04-06  (M. Vancoppenolle) Tendencies
+      !!---------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::      &
+         ji, jj,     & ! geographical indices
+         jk, jl, jm    ! layer, category and type indices
+      INTEGER ::      &
+         jbnd1, jbnd2
+      INTEGER ::      &
+         i_ice_switch
+
+      REAL(wp)  ::           &  ! constant values
+         epsi06 = 1.e-06  ,  &
+         epsi03 = 1.e-03  ,  &
+         epsi16 = 1.e-16  ,  &
+         epsi20 = 1.e-20  ,  &
+         epsi04 = 1.e-04  ,  &
+         epsi10 = 1.e-10  ,  &
+         rzero  = 0.e0    ,  &
+         rone   = 1.e0    ,  &
+         zhimax                   ! maximum thickness tolerated for advection of
+      ! in an ice-free cell
+      REAL(wp) ::            &  ! dummy switches and arguments
+         zindb, zindsn, zindic, zacrith,  &
+         zrtt, zindg, zh, zdvres, zviold,                       &
+         zbigvalue, zvsold, z_da_ex, zamax,                     &
+         z_prescr_hi, zat_i_old,                                &
+         ztmelts, ze_s
+
+      REAL(wp), DIMENSION(jpl) :: z_da_i, z_dv_i
+
+      LOGICAL, DIMENSION(jpi,jpj,jpl) ::  &
+         internal_melt
+
+      INTEGER ::      &
+         ind_im, layer      ! indices for internal melt
+      REAL(wp), DIMENSION(jkmax) :: &
+         zthick0, zqm0      ! thickness of the layers and heat contents for
+      ! internal melt
+      REAL(wp) ::                   &
+         zweight, zesum
+
+
+      !!-------------------------------------------------------------------
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' lim_update '
+         WRITE(numout,*) ' ~~~~~~~~~~ '
+
+         WRITE(numout,*) ' O) Initial values '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      !------------------------------------------------------------------------------
+      ! 1. Update of Global variables                                               |
+      !------------------------------------------------------------------------------
+
+      !---------------------
+      ! Ice dynamics  
+      !---------------------
+
+      u_ice(:,:) = u_ice(:,:) + d_u_ice_dyn(:,:)
+      v_ice(:,:) = v_ice(:,:) + d_v_ice_dyn(:,:)
+
+      !-----------------------------
+      ! Update ice and snow volumes  
+      !-----------------------------
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               v_i(ji,jj,jl)  = v_i(ji,jj,jl) + d_v_i_trp(ji,jj,jl)  &
+                  + d_v_i_thd(ji,jj,jl) 
+               v_s(ji,jj,jl)  = v_s(ji,jj,jl) + d_v_s_trp(ji,jj,jl)  &
+                  + d_v_s_thd(ji,jj,jl)
+            END DO
+         END DO
+      END DO
+
+      !---------------------------------
+      ! Classify the pathological cases
+      !---------------------------------
+      ! (1) v_i (new) > 0; d_v_i_thd + v_i(old) > 0 (easy case)
+      ! (2) v_i (new) > 0; d_v_i_thd + v_i(old) = 0 (total thermodynamic ablation)
+      ! (3) v_i (new) < 0; d_v_i_thd + v_i(old) > 0 (combined total ablation)
+      ! (4) v_i (new) < 0; d_v_i_thd + v_i(old) = 0 (total thermodynamic ablation 
+      ! with negative advection, very pathological )
+      ! (5) v_i (old) = 0; d_v_i_trp > 0 (advection of ice in a free-cell)
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               patho_case(ji,jj,jl) = 1
+               IF ( v_i(ji,jj,jl) .GE. 0.0 ) THEN
+                  IF ( old_v_i(ji,jj,jl) + d_v_i_thd(ji,jj,jl) .LT. epsi10 ) THEN 
+                     patho_case(ji,jj,jl) = 2
+                  ENDIF
+               ELSE
+                  patho_case(ji,jj,jl) = 3
+                  IF ( old_v_i(ji,jj,jl) + d_v_i_thd(ji,jj,jl) .LT. epsi10 ) THEN 
+                     patho_case(ji,jj,jl) = 4
+                  ENDIF
+               ENDIF
+               IF ( ( old_v_i(ji,jj,jl) .LE. epsi10 ) .AND. &
+                  ( d_v_i_trp(ji,jj,jl) .GT. epsi06 ) ) THEN
+                  patho_case(ji,jj,jl) = 5 ! advection of ice in an ice-free
+                  ! cell
+                  IF( ln_nicep ) THEN  
+                     WRITE(numout,*) ' ALERTE patho_case still equal to 5 '
+                     WRITE(numout,*) ' ji , jj   : ', ji, jj
+                     WRITE(numout,*) ' old_v_i   : ', old_v_i(ji,jj,jl)
+                     WRITE(numout,*) ' d_v_i_trp : ', d_v_i_trp(ji,jj,jl)
+                  ENDIF
+
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      !--------------------
+      ! Excessive ablation 
+      !--------------------
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (      ( patho_case(ji,jj,jl) .EQ. 3 ) &
+                  .OR. ( patho_case(ji,jj,jl) .EQ. 4 ) ) THEN
+                  zviold         = old_v_i(ji,jj,jl)
+                  zvsold         = old_v_s(ji,jj,jl)
+                  ! in cases 3 ( combined total ablation )
+                  !      and 4 ( total ablation with negative advection )
+                  ! there is excessive total ablation
+                  ! advection is chosen to be prioritary in order to conserve mass. 
+                  ! dv_i_thd is computed as a residual
+                  ! negative energy has to be kept in memory and to be given to the ocean
+                  ! equivalent salt flux is given to the ocean
+                  !
+                  ! This was the best solution found. Otherwise, mass conservation in advection
+                  ! scheme should have been revised, which could have been a big problem
+                  ! Martin Vancoppenolle (2006, updated 2007)
+
+                  ! is there any ice left ?
+                  zindic        = MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - epsi10 ) ) 
+                  !=1 if hi > 1e-3 and 0 if not
+                  zdvres        = MAX(0.0,-v_i(ji,jj,jl)) !residual volume if too much ice was molten
+                  !this quantity is positive
+                  v_i(ji,jj,jl) = zindic*v_i(ji,jj,jl)    !ice volume cannot be negative
+                  !correct thermodynamic ablation
+                  d_v_i_thd(ji,jj,jl)  = zindic  *  d_v_i_thd(ji,jj,jl) + & 
+                     (1.0-zindic) * (-zviold - d_v_i_trp(ji,jj,jl)) 
+                  ! THIS IS NEW
+                  d_a_i_thd(ji,jj,jl)  = zindic  *  d_a_i_thd(ji,jj,jl) + & 
+                     (1.0-zindic) * (-old_a_i(ji,jj,jl)) 
+
+                  !residual salt flux if ice is over-molten
+                  fsalt_res(ji,jj)  = fsalt_res(ji,jj) + ( sss_m(ji,jj) - sm_i(ji,jj,jl) ) * & 
+                     ( rhoic * zdvres / rdt_ice )
+                  !             fheat_res(ji,jj)  = fheat_res(ji,jj) + rhoic * lfus * zdvres / rdt_ice
+
+                  ! is there any snow left ?
+                  zindsn        = MAX( rzero, SIGN( rone, v_s(ji,jj,jl) - epsi10 ) ) 
+                  zvsold        = v_s(ji,jj,jl)
+                  zdvres        = MAX(0.0,-v_s(ji,jj,jl)) !residual volume if too much ice was molten
+                  !this quantity is positive
+                  v_s(ji,jj,jl) = zindsn*v_s(ji,jj,jl)    !snow volume cannot be negative
+                  !correct thermodynamic ablation
+                  d_v_s_thd(ji,jj,jl)  = zindsn  *  d_v_s_thd(ji,jj,jl) + & 
+                     (1.0-zindsn) * (-zvsold - d_v_s_trp(ji,jj,jl)) 
+                  !unsure correction on salt flux.... maybe future will tell it was not that right
+
+                  !residual salt flux if snow is over-molten
+                  fsalt_res(ji,jj)  = fsalt_res(ji,jj) + sss_m(ji,jj) * & 
+                     ( rhosn * zdvres / rdt_ice )
+                  !this flux will be positive if snow was over-molten
+                  !             fheat_res(ji,jj)  = fheat_res(ji,jj) + rhosn * lfus * zdvres / rdt_ice
+               ENDIF
+            END DO !ji
+         END DO !jj
+      END DO !jl
+
+      IF( ln_nicep ) THEN  
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ABS(fsalt_res(ji,jj)) .GT. 1.0 ) THEN 
+                  WRITE(numout,*) ' ALERTE 1000 : residual salt flux of -> ', &
+                     fsalt_res(ji,jj)
+                  WRITE(numout,*) ' ji, jj : ', ji, jj, ' gphit, glamt : ', &
+                     gphit(ji,jj), glamt(ji,jj)
+               ENDIF
+            END DO
+         END DO
+
+         WRITE(numout,*) ' 1. Before update of Global variables '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      !---------------------------------------------
+      ! Ice concentration and ice heat content
+      !---------------------------------------------
+
+      a_i (:,:,:) = a_i (:,:,:)   + d_a_i_trp(:,:,:)     &
+         + d_a_i_thd(:,:,:)
+      CALL lim_var_glo2eqv ! useless, just for debug
+      IF( ln_nicep ) THEN 
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' t_i : ', t_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+      e_i(:,:,:,:) = e_i(:,:,:,:) + d_e_i_trp(:,:,:,:)  
+      CALL lim_var_glo2eqv ! useless, just for debug
+      IF( ln_nicep) THEN
+      WRITE(numout,*) ' After transport update '
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' t_i : ', t_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+      e_i(:,:,:,:) = e_i(:,:,:,:) + d_e_i_thd(:,:,:,:)  
+      CALL lim_var_glo2eqv ! useless, just for debug
+      IF( ln_nicep ) THEN
+         WRITE(numout,*) ' After thermodyn update '
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' t_i : ', t_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 1. After update of Global variables (2) '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' oa_i : ', oa_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' e_s : ', e_s(jiindx, jjindx, 1, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      !------------------------------
+      ! Snow temperature and ice age
+      !------------------------------
+
+      e_s(:,:,:,:) = e_s(:,:,:,:)        + &
+         d_e_s_trp(:,:,:,:)  + &
+         d_e_s_thd(:,:,:,:)
+
+      oa_i(:,:,:)  = oa_i(:,:,:)         + &
+         d_oa_i_trp(:,:,:)   + &
+         d_oa_i_thd(:,:,:)
+
+      !--------------
+      ! Ice salinity    
+      !--------------
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN ! general case
+
+         IF( ln_nicep ) THEN  
+            WRITE(numout,*) ' Before everything '
+            WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+            WRITE(numout,*) ' oa_i:  ', oa_i(jiindx, jjindx, 1:jpl)
+            DO jk = 1, nlay_i
+               WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+            END DO
+            WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         ENDIF
+
+         smv_i(:,:,:) = smv_i(:,:,:)       + &
+            d_smv_i_thd(:,:,:) + &
+            d_smv_i_trp(:,:,:)
+
+         IF( ln_nicep ) THEN  
+            WRITE(numout,*) ' After advection   '
+            WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+            WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         ENDIF
+
+      ENDIF ! num_sal .EQ. 2
+
+      CALL lim_var_glo2eqv
+
+      !--------------------------------------
+      ! 2. Review of all pathological cases
+      !--------------------------------------
+
+      zrtt          = 173.15 * rone
+      zacrith       = 1.0e-6
+
+      !-------------------------------------------
+      ! 2.1) Advection of ice in an ice-free cell
+      !-------------------------------------------
+      ! should be removed since it is treated after dynamics now
+
+      zhimax = 5.0
+      ! first category
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !--- the thickness of such an ice is often out of bounds
+            !--- thus we recompute a new area while conserving ice volume
+            zat_i_old = SUM(old_a_i(ji,jj,:))
+            zindb          =  MAX( rzero, SIGN( rone, ABS(d_a_i_trp(ji,jj,1)) - epsi10 ) ) 
+            IF (      ( ABS(d_v_i_trp(ji,jj,1))/MAX(ABS(d_a_i_trp(ji,jj,1)),epsi10)*zindb.GT.zhimax) &
+               .AND.( ( v_i(ji,jj,1)/MAX(a_i(ji,jj,1),epsi10)*zindb).GT.zhimax ) &
+               .AND.( zat_i_old.LT.zacrith ) )  THEN ! new line
+               z_prescr_hi      = hi_max(1) / 2.0
+               a_i(ji,jj,1)     = v_i(ji,jj,1) / z_prescr_hi
+            ENDIF
+         END DO
+      END DO
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.1 '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      !change this 14h44
+      zhimax = 20.0 ! line added up
+      ! change this also 17 aug
+      zhimax = 30.0 ! line added up
+
+      DO jl = 2, jpl
+         jm = ice_types(jl)
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zindb          =  MAX( rzero, SIGN( rone, ABS(d_a_i_trp(ji,jj,jl)) - epsi10 ) ) 
+               ! this correction is very tricky... sometimes, advection gets wrong i don't know why
+               ! it makes problems when the advected volume and concentration do not seem to be 
+               ! related with each other
+               ! the new thickness is sometimes very big!
+               ! and sometimes d_a_i_trp and d_v_i_trp have different sign
+               ! which of course is plausible
+               ! but fuck! it fucks everything up :)
+               IF ( (ABS(d_v_i_trp(ji,jj,jl))/MAX(ABS(d_a_i_trp(ji,jj,jl)),epsi10)*zindb.GT.zhimax) &
+                  .AND.(v_i(ji,jj,jl)/MAX(a_i(ji,jj,jl),epsi10)*zindb).GT.zhimax ) THEN
+                  z_prescr_hi  =  ( hi_max_typ(jl-ice_cat_bounds(jm,1)  ,jm) + &
+                     hi_max_typ(jl-ice_cat_bounds(jm,1)+1,jm) ) / &
+                     2.0
+                  a_i(ji,jj,jl) = v_i(ji,jj,jl) / z_prescr_hi
+                  ht_i(ji,jj,jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+               ENDIF
+               zat_i_old = SUM(old_a_i(ji,jj,:))
+
+            END DO ! ji
+         END DO !jj
+      END DO !jl
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.1 initial '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+      ENDIF
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      !----------------------------------------------------
+      ! 2.2) Rebin categories with thickness out of bounds
+      !----------------------------------------------------
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.1 before rebinning '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      DO jm = 1, jpm
+         jbnd1 = ice_cat_bounds(jm,1)
+         jbnd2 = ice_cat_bounds(jm,2)
+         IF (ice_ncat_types(jm) .GT. 1 ) CALL lim_itd_th_reb(jbnd1, jbnd2, jm)
+      END DO
+
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.1 after rebinning'
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+            WRITE(numout,*) ' t_i : ', t_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      !---------------------------------
+      ! 2.3) Melt of an internal layer
+      !---------------------------------
+      internal_melt(:,:,:) = .false.
+
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  ztmelts = - tmut * s_i(ji,jj,jk,jl) + rtt
+                  IF ( ( ( e_i(ji,jj,jk,jl) .LE. 0.0 ) .OR. &
+                     ( t_i(ji,jj,jk,jl) .GE. ztmelts ) ) .AND. &
+                     ( v_i(ji,jj,jl) .GT. 0.0 ) .AND. &
+                     ( a_i(ji,jj,jl) .GT. 0.0 ) ) THEN
+                     !                    WRITE(numout,*) ' Internal layer melt : '
+                     !                    WRITE(numout,*) ' ji, jj, jk, jl : ', ji,jj,jk,jl
+                     !                    WRITE(numout,*) ' e_i : ', e_i(ji,jj,jk,jl)
+                     !                    WRITE(numout,*) ' v_i : ', v_i(ji,jj,jl)
+                     internal_melt(ji,jj,jl) = .true.
+                  ENDIF
+               END DO ! ji
+            END DO ! jj
+         END DO !jk
+      END DO !jl
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               IF ( internal_melt(ji,jj,jl) ) THEN
+                  ! initial ice thickness
+                  !-----------------------
+                  ht_i(ji,jj,jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+                  !             WRITE(numout,*) ' ji,jj,jl : ', ji,jj,jl
+                  !             WRITE(numout,*) ' old ht_i: ', ht_i(ji,jj,jl)
+                  !             WRITE(numout,*) ' Enthalpy at the beg : ', e_i(ji,jj,1:nlay_i,jl)
+                  !             WRITE(numout,*) ' smv_i   : ', smv_i(ji,jj,jl)
+
+                  ! reduce ice thickness
+                  !-----------------------
+                  ind_im = 0
+                  zesum = 0.0
+                  DO jk = 1, nlay_i
+                     ztmelts = - tmut * s_i(ji,jj,jk,jl) + rtt
+                     IF ( ( e_i(ji,jj,jk,jl) .LE. 0.0 ) .OR.  & 
+                        ( t_i(ji,jj,jk,jl) .GE. ztmelts ) ) &
+                        ind_im = ind_im + 1
+                     zesum = zesum + e_i(ji,jj,jk,jl)
+                  END DO
+                  IF (ind_im .LT.nlay_i ) smv_i(ji,jj,jl)= smv_i(ji,jj,jl) / ht_i(ji,jj,jl) * & 
+                     ( ht_i(ji,jj,jl) - ind_im*ht_i(ji,jj,jl) / nlay_i )
+                  ht_i(ji,jj,jl) = ht_i(ji,jj,jl) - ind_im*ht_i(ji,jj,jl) / nlay_i
+                  v_i(ji,jj,jl)  = ht_i(ji,jj,jl) * a_i(ji,jj,jl)
+
+                  !             WRITE(numout,*) ' ind_im  : ', ind_im
+                  !             WRITE(numout,*) ' new ht_i: ', ht_i(ji,jj,jl)
+                  !             WRITE(numout,*) ' smv_i   : ', smv_i(ji,jj,jl)
+                  !             WRITE(numout,*) ' zesum   : ', zesum
+
+                  ! redistribute heat
+                  !-----------------------
+                  ! old thicknesses and enthalpies
+                  ind_im = 0
+                  DO jk = 1, nlay_i
+                     ztmelts = - tmut * s_i(ji,jj,jk,jl) + rtt
+                     IF ( ( e_i(ji,jj,jk,jl) .GT. 0.0 ) .AND.  & 
+                        ( t_i(ji,jj,jk,jl) .LT. ztmelts ) ) THEN
+                        ind_im = ind_im + 1
+                        zthick0(ind_im) = ht_i(ji,jj,jl) * ind_im / nlay_i
+                        zqm0   (ind_im) = MAX( e_i(ji,jj,jk,jl) , 0.0 )
+                     ENDIF
+                  END DO
+
+                  !             WRITE(numout,*) ' Old thickness, enthalpy '
+                  !             WRITE(numout,*) ' Number of layer : ind_im ', ind_im
+                  !             WRITE(numout,*) ' zthick0 : ', zthick0(1:ind_im)
+                  !             WRITE(numout,*) ' zqm0    : ', zqm0(1:ind_im)
+
+                  ! Redistributing energy on the new grid
+                  IF ( ind_im .GT. 0 ) THEN
+
+                     DO jk = 1, nlay_i
+                        e_i(ji,jj,jk,jl) = 0.0
+                        DO layer = 1, ind_im
+                           zweight         = MAX (  &
+                              MIN( ht_i(ji,jj,jl) * layer / ind_im , ht_i(ji,jj,jl) * jk / nlay_i ) -       &
+                              MAX( ht_i(ji,jj,jl) * (layer-1) / ind_im , ht_i(ji,jj,jl) * (jk-1) / nlay_i ) , 0.0 ) &
+                              /  ( ht_i(ji,jj,jl) / ind_im )
+
+                           e_i(ji,jj,jk,jl) =  e_i(ji,jj,jk,jl) + zweight*zqm0(layer)
+                        END DO !layer
+                     END DO ! jk
+
+                     zesum = 0.0
+                     DO jk = 1, nlay_i
+                        zesum = zesum + e_i(ji,jj,jk,jl)
+                     END DO
+
+                     !             WRITE(numout,*) ' Enthalpy at the end : ', e_i(ji,jj,1:nlay_i,jl)
+                     !             WRITE(numout,*) ' Volume   at the end : ', v_i(ji,jj,jl)
+                     !             WRITE(numout,*) ' zesum : ', zesum
+
+                  ELSE ! ind_im .EQ. 0, total melt
+                     e_i(ji,jj,jk,jl) = 0.0
+                  ENDIF
+
+               ENDIF ! internal_melt
+
+            END DO ! ji
+         END DO !jj
+      END DO !jl
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.3 after melt of an internal ice layer '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+            WRITE(numout,*) ' t_i : ', t_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      internal_melt(:,:,:) = .false.
+
+      ! Melt of snow
+      !--------------
+      DO jl = 1, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               ! snow energy of melting
+               ze_s = e_s(ji,jj,1,jl) * unit_fac / area(ji,jj) /              &
+                  MAX( v_s(ji,jj,jl), 1.0e-6 )  ! snow energy of melting
+
+               ! If snow energy of melting smaller then Lf
+               ! Then all snow melts and meltwater, heat go to the ocean
+               IF ( ze_s .LE. rhosn * lfus ) internal_melt(ji,jj,jl) = .true.
+
+               IF( ln_nicep ) THEN  
+                  IF ( (ji.eq.jiindx) .AND. (jj.eq.jjindx) ) THEN
+                     WRITE(numout,*) ' jl    : ', jl
+                     WRITE(numout,*) ' ze_s  : ', ze_s
+                     WRITE(numout,*) ' v_s   : ', v_s(ji,jj,jl)
+                     WRITE(numout,*) ' rhosn : ', rhosn
+                     WRITE(numout,*) ' rhosn : ', lfus 
+                     WRITE(numout,*) ' area  : ', area(ji,jj)
+                     WRITE(numout,*) ' rhosn * lfus : ', rhosn * lfus 
+                     WRITE(numout,*) ' internal_melt : ', internal_melt(ji,jj,jl)
+                  ENDIF
+               ENDIF
+
+            END DO
+         END DO
+      END DO
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               IF ( internal_melt(ji,jj,jl) ) THEN
+                  v_s(ji,jj,jl)   = 0.0
+                  e_s(ji,jj,1,jl) = 0.0
+                  !   ! release heat
+                  fheat_res(ji,jj) = fheat_res(ji,jj)  &
+                     + ze_s * v_s(ji,jj,jl) / rdt_ice
+                  ! release mass
+                  rdmsnif(ji,jj) =  rdmsnif(ji,jj) + rhosn * v_s(ji,jj,jl)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      zbigvalue      = 1.0d+20
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+
+               !switches
+               zindb         = MAX( rzero, SIGN( rone, a_i(ji,jj,jl) - epsi06 ) ) 
+               !switch = 1 if a_i > 1e-06 and 0 if not
+               zindsn        = MAX( rzero, SIGN( rone, v_s(ji,jj,jl) - epsi06 ) ) !=1 if hs > 1e-6 and 0 if not
+               zindic        = MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - epsi04 ) ) !=1 if hi > 1e-3 and 0 if not
+               ! bug fix 25 avril 2007
+               zindb         = zindb*zindic
+
+               !--- 2.3 Correction to ice age 
+               !------------------------------
+               !                IF ((o_i(ji,jj,jl)-1.0)*86400.0.gt.(rdt_ice*float(numit))) THEN
+               !                   o_i(ji,jj,jl) = rdt_ice*FLOAT(numit)/86400.0
+               !                ENDIF
+               IF ((oa_i(ji,jj,jl)-1.0)*86400.0.gt.(rdt_ice*numit*a_i(ji,jj,jl))) THEN
+                  oa_i(ji,jj,jl) = rdt_ice*numit/86400.0*a_i(ji,jj,jl)
+               ENDIF
+               oa_i(ji,jj,jl) = zindb*zindic*oa_i(ji,jj,jl)
+
+               !--- 2.4 Correction to snow thickness
+               !-------------------------------------
+               !          ! snow thickness has to be greater than 0, and if ice concentration smaller than 1e-6 then hs = 0
+               !             v_s(ji,jj,jl)  = MAX( zindb * v_s(ji,jj,jl), 0.0) 
+               ! snow thickness cannot be smaller than 1e-6
+               v_s(ji,jj,jl)  = zindsn*v_s(ji,jj,jl)*zindb
+               v_s(ji,jj,jl)  = v_s(ji,jj,jl) *  MAX( 0.0 , SIGN( 1.0 , v_s(ji,jj,jl) - epsi06 ) )
+
+               !--- 2.5 Correction to ice thickness
+               !-------------------------------------
+               ! ice thickness has to be greater than 0, and if ice concentration smaller than 1e-6 then hi = 0
+               v_i(ji,jj,jl) = MAX( zindb * v_i(ji,jj,jl), 0.0)
+               ! ice thickness cannot be smaller than 1e-3
+               v_i(ji,jj,jl)  = zindic*v_i(ji,jj,jl)
+
+               !--- 2.6 Snow is transformed into ice if the original ice cover disappears
+               !----------------------------------------------------------------------------
+               zindg          = tms(ji,jj) *  MAX( rzero , SIGN( rone , -v_i(ji,jj,jl) ) )
+               v_i(ji,jj,jl)  = v_i(ji,jj,jl) + zindg * rhosn * v_s(ji,jj,jl) / rau0
+               v_s(ji,jj,jl)  = ( rone - zindg ) * v_s(ji,jj,jl) + & 
+                  zindg * v_i(ji,jj,jl) * ( rau0 - rhoic ) / rhosn
+
+               !--- 2.7 Correction to ice concentrations 
+               !--------------------------------------------
+               ! if greater than 0, ice concentration cannot be smaller than 1e-10
+               a_i(ji,jj,jl) = zindb * MAX(zindsn, zindic) * MAX( a_i(ji,jj,jl), epsi06 )
+               ! then ice volume has to be corrected too...
+               ! instead, zap small areas
+
+               !-------------------------
+               ! 2.8) Snow heat content
+               !-------------------------
+
+               e_s(ji,jj,1,jl) = zindsn *                                &
+                  ( MIN ( MAX ( 0.0, e_s(ji,jj,1,jl) ), zbigvalue ) ) + &
+                  ( 1.0 - zindsn ) * 0.0
+
+            END DO ! ji
+         END DO ! jj
+      END DO ! jl
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.8 '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i: ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      !------------------------
+      ! 2.9) Ice heat content 
+      !------------------------
+
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  zindic        = MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - epsi06 ) ) 
+                  ! =1 if v_i > 1e-6 and 0 if not
+                  e_i(ji,jj,jk,jl)= zindic * & 
+                     ( MIN ( MAX ( 0.0, e_i(ji,jj,jk,jl) ), zbigvalue ) ) + &
+                     ( 1.0 - zindic ) * 0.0
+               END DO ! ji
+            END DO ! jj
+         END DO !jk
+      END DO !jl
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.9 '
+         DO jk = 1, nlay_i
+            WRITE(numout,*) ' e_i : ', e_i(jiindx, jjindx, jk, 1:jpl)
+         END DO
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      !---------------------
+      ! 2.11) Ice salinity
+      !---------------------
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN ! general case
+
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj 
+                  DO ji = 1, jpi
+                     ! salinity stays in bounds
+                     smv_i(ji,jj,jl)  =  MAX(MIN((rhoic-rhosn)/rhoic*sss_m(ji,jj),smv_i(ji,jj,jl)), &
+                        0.1 * v_i(ji,jj,jl) )
+                     i_ice_switch    =  1.0-MAX(0.0,SIGN(1.0,-v_i(ji,jj,jl)))
+                     smv_i(ji,jj,jl)  = i_ice_switch*smv_i(ji,jj,jl) + &
+                        0.1*(1.0-i_ice_switch)*v_i(ji,jj,jl)
+                  END DO ! ji
+               END DO ! jj
+            END DO !jk
+         END DO !jl
+
+      ENDIF
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.11 '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i    ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      DO jm = 1, jpm
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+               jl = ice_cat_bounds(jm,1)
+               !--- 2.12 Constrain the thickness of the smallest category above 5 cm
+               !----------------------------------------------------------------------
+               ! the ice thickness of the smallest category should be higher than 5 cm
+               ! we changed hiclim to 10
+               zindb         = MAX( rzero, SIGN( rone, a_i(ji,jj,jl) - epsi06 ) ) 
+               ht_i(ji,jj,jl) = zindb*v_i(ji,jj,jl)/MAX(a_i(ji,jj,jl), epsi06)
+               zh            = MAX( rone , zindb * hiclim  / MAX( ht_i(ji,jj,jl) , epsi20 ) )
+               ht_s(ji,jj,jl) = ht_s(ji,jj,jl)* zh
+               !             v_s(ji,jj,jl)  = v_s(ji,jj,jl) * zh
+               ht_i(ji,jj,jl) = ht_i(ji,jj,jl)* zh
+               !             v_i(ji,jj,jl)  = v_i(ji,jj,jl) * zh
+               a_i (ji,jj,jl) = a_i(ji,jj,jl) /zh
+            END DO !ji
+         END DO !jj
+      END DO !jm
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.12 '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i    ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      !--- 2.13 Total ice concentration should not exceed 1
+      !-----------------------------------------------------
+      zamax = amax
+      ! 2.13.1) individual concentrations cannot exceed zamax
+      !------------------------------------------------------
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      ! 2.13.2) Total ice concentration cannot exceed zamax
+      !----------------------------------------------------
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            ! 0) Excessive area ?
+            z_da_ex =  MAX( at_i(ji,jj) - zamax , 0.0 )        
+
+            ! 1) Count the number of existing categories
+            DO jl  = 1, jpl
+               zindb   =  MAX( rzero, SIGN( rone, v_i(ji,jj,jl) - epsi03 ) ) 
+               zindb   =  MAX( rzero, SIGN( rone, v_i(ji,jj,jl) ) ) 
+               z_da_i(jl) = a_i(ji,jj,jl)*zindb*z_da_ex/MAX(at_i(ji,jj),epsi06)
+               z_dv_i(jl) = v_i(ji,jj,jl)*z_da_i(jl)/MAX(at_i(ji,jj),epsi06)
+               a_i(ji,jj,jl) = a_i(ji,jj,jl) - z_da_i(jl)
+               v_i(ji,jj,jl) = v_i(ji,jj,jl) + z_dv_i(jl)
+
+            END DO
+
+         END DO !ji
+      END DO !jj
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' 2.13 '
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i    ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      IF( ln_nicep ) THEN  
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF (at_i(ji,jj).GT.1.0) THEN
+                  WRITE(numout,*) ' lim_update ! : at_i > 1 -> PAS BIEN -> ALERTE '
+                  WRITE(numout,*) ' ~~~~~~~~~~   at_i     ', at_i(ji,jj)
+                  WRITE(numout,*) ' Point ', ji, jj
+                  WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
+                  DO jl = 1, jpl
+                     WRITE(numout,*) ' a_i ***         ', a_i(ji,jj,jl), ' CAT no ', jl
+                     WRITE(numout,*) ' a_i_old ***     ', old_a_i(ji,jj,jl), ' CAT no ', jl
+                     WRITE(numout,*) ' d_a_i_thd / trp ', d_a_i_thd(ji,jj,jl), d_a_i_trp(ji,jj,jl)
+                  END DO
+                  !             WRITE(numout,*) ' CORRECTION BARBARE '
+                  !             z_da_ex =  MAX( at_i(ji,jj) - zamax , 0.0 )        
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      ! Final thickness distribution rebinning
+      ! --------------------------------------
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' rebinning before'
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i    ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+      ENDIF
+      !old version
+      !    CALL lim_itd_th_reb(1,jpl)
+
+      DO jm = 1, jpm
+         jbnd1 = ice_cat_bounds(jm,1)
+         jbnd2 = ice_cat_bounds(jm,2)
+         IF (ice_ncat_types(jm) .GT. 1 ) CALL lim_itd_th_reb(jbnd1, jbnd2, jm)
+         IF (ice_ncat_types(jm) .EQ. 1 ) THEN
+         ENDIF
+      END DO
+
+      IF( ln_nicep ) THEN  
+         WRITE(numout,*) ' rebinning final'
+         WRITE(numout,*) ' a_i : ', a_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' at_i    ', at_i(jiindx,jjindx)
+         WRITE(numout,*) ' v_i : ', v_i(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' v_s : ', v_s(jiindx, jjindx, 1:jpl)
+         WRITE(numout,*) ' smv_i: ', smv_i(jiindx, jjindx, 1:jpl)
+      ENDIF
+
+      at_i(:,:) = 0.0
+      DO jl = 1, jpl
+         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
+      END DO
+
+      !------------------------------------------------------------------------------
+      ! 2) Corrections to avoid wrong values                                        |
+      !------------------------------------------------------------------------------
+      ! Ice drift
+      !------------
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            IF ( at_i(ji,jj) .EQ. 0.0 ) THEN ! what to do if there is no ice
+               IF ( at_i(ji+1,jj) .EQ. 0.0 ) u_ice(ji,jj)   = 0.0 ! right side
+               IF ( at_i(ji-1,jj) .EQ. 0.0 ) u_ice(ji-1,jj) = 0.0 ! left side
+               IF ( at_i(ji,jj+1) .EQ. 0.0 ) v_ice(ji,jj)   = 0.0 ! upper side
+               IF ( at_i(ji,jj-1) .EQ. 0.0 ) v_ice(ji,jj-1) = 0.0 ! bottom side
+            ENDIF
+         END DO
+      END DO
+      !mask velocities
+      u_ice(:,:) = u_ice(:,:) * tmu(:,:)
+      v_ice(:,:) = v_ice(:,:) * tmv(:,:)
+      !lateral boundary conditions
+      CALL lbc_lnk( u_ice(:,:), 'U', -1. )
+      CALL lbc_lnk( v_ice(:,:), 'V', -1. )
+
+      !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+      ! ALERTES
+      !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+      IF( ln_nicep ) THEN  
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               DO jl = 1, jpl
+                  !                IF ((v_i(ji,jj,jl).NE.0.0).AND.(a_i(ji,jj,jl).EQ.0.0)) THEN
+                  !                   WRITE(numout,*) ' lim_update : incompatible volume and concentration '
+               END DO ! jl
+
+               DO jl = 1, jpl
+                  IF ( (a_i(ji,jj,jl).GT.1.0).OR.(at_i(ji,jj).GT.1.0) ) THEN
+                     zindb          =  MAX( rzero, SIGN( rone, a_i(ji,jj,jl) - epsi06 ) ) 
+                     WRITE(numout,*) ' lim_update : a_i > 1 '
+                     WRITE(numout,*) ' PAS BIEN ----> ALERTE !!! '
+                     WRITE(numout,*) ' ~~~~~~~~~~   at_i     ', at_i(ji,jj)
+                     WRITE(numout,*) ' Point - category', ji, jj, jl
+                     WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
+                     WRITE(numout,*) ' a_i *** a_i_old ', a_i(ji,jj,jl), old_a_i(ji,jj,jl)
+                     WRITE(numout,*) ' v_i *** v_i_old ', v_i(ji,jj,jl), old_v_i(ji,jj,jl)
+                     WRITE(numout,*) ' ht_i ***        ', v_i(ji,jj,jl)/MAX(a_i(ji,jj,jl),epsi06)*zindb 
+                     WRITE(numout,*) ' hi_max(jl), hi_max(jl-1) ', hi_max(jl), hi_max(jl-1)
+                     WRITE(numout,*) ' d_v_i_thd / trp ', d_v_i_thd(ji,jj,jl), d_v_i_trp(ji,jj,jl)
+                     WRITE(numout,*) ' d_a_i_thd / trp ', d_a_i_thd(ji,jj,jl), d_a_i_trp(ji,jj,jl)
+                  ENDIF
+               END DO
+
+            END DO !jj
+         END DO !ji
+
+         WRITE(numout,*) ' TESTOSC1 ', tio_u(jiindx,jjindx), tio_v(jiindx,jjindx)
+         WRITE(numout,*) ' TESTOSC2 ', u_ice(jiindx,jjindx), v_ice(jiindx,jjindx)
+         WRITE(numout,*) ' TESTOSC3 ', u_oce(jiindx,jjindx), v_oce(jiindx,jjindx)
+         WRITE(numout,*) ' TESTOSC4 ', utau (jiindx,jjindx), vtau (jiindx,jjindx)
+      ENDIF
+
+
+      IF(ln_ctl) THEN   ! Control print
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Cell values : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=area       , clinfo1=' lim_update  : cell area   :')
+         CALL prt_ctl(tab2d_1=at_i       , clinfo1=' lim_update  : at_i        :')
+         CALL prt_ctl(tab2d_1=vt_i       , clinfo1=' lim_update  : vt_i        :')
+         CALL prt_ctl(tab2d_1=vt_s       , clinfo1=' lim_update  : vt_s        :')
+         CALL prt_ctl(tab2d_1=strength   , clinfo1=' lim_update  : strength    :')
+         CALL prt_ctl(tab2d_1=u_ice      , clinfo1=' lim_update  : u_ice       :', tab2d_2=v_ice      , clinfo2=' v_ice       :')
+         CALL prt_ctl(tab2d_1=d_u_ice_dyn, clinfo1=' lim_update  : d_u_ice_dyn :', tab2d_2=d_v_ice_dyn, clinfo2=' d_v_ice_dyn :')
+         CALL prt_ctl(tab2d_1=old_u_ice  , clinfo1=' lim_update  : old_u_ice   :', tab2d_2=old_v_ice  , clinfo2=' old_v_ice   :')
+
+         DO jl = 1, jpl
+            CALL prt_ctl_info(' ')
+            CALL prt_ctl_info(' - Category : ', ivar1=jl)
+            CALL prt_ctl_info('   ~~~~~~~~~~')
+            CALL prt_ctl(tab2d_1=ht_i       (:,:,jl)        , clinfo1= ' lim_update  : ht_i        : ')
+            CALL prt_ctl(tab2d_1=ht_s       (:,:,jl)        , clinfo1= ' lim_update  : ht_s        : ')
+            CALL prt_ctl(tab2d_1=t_su       (:,:,jl)        , clinfo1= ' lim_update  : t_su        : ')
+            CALL prt_ctl(tab2d_1=t_s        (:,:,1,jl)      , clinfo1= ' lim_update  : t_snow      : ')
+            CALL prt_ctl(tab2d_1=sm_i       (:,:,jl)        , clinfo1= ' lim_update  : sm_i        : ')
+            CALL prt_ctl(tab2d_1=o_i        (:,:,jl)        , clinfo1= ' lim_update  : o_i         : ')
+            CALL prt_ctl(tab2d_1=a_i        (:,:,jl)        , clinfo1= ' lim_update  : a_i         : ')
+            CALL prt_ctl(tab2d_1=old_a_i    (:,:,jl)        , clinfo1= ' lim_update  : old_a_i     : ')
+            CALL prt_ctl(tab2d_1=d_a_i_trp  (:,:,jl)        , clinfo1= ' lim_update  : d_a_i_trp   : ')
+            CALL prt_ctl(tab2d_1=d_a_i_thd  (:,:,jl)        , clinfo1= ' lim_update  : d_a_i_thd   : ')
+            CALL prt_ctl(tab2d_1=v_i        (:,:,jl)        , clinfo1= ' lim_update  : v_i         : ')
+            CALL prt_ctl(tab2d_1=old_v_i    (:,:,jl)        , clinfo1= ' lim_update  : old_v_i     : ')
+            CALL prt_ctl(tab2d_1=d_v_i_trp  (:,:,jl)        , clinfo1= ' lim_update  : d_v_i_trp   : ')
+            CALL prt_ctl(tab2d_1=d_v_i_thd  (:,:,jl)        , clinfo1= ' lim_update  : d_v_i_thd   : ')
+            CALL prt_ctl(tab2d_1=v_s        (:,:,jl)        , clinfo1= ' lim_update  : v_s         : ')
+            CALL prt_ctl(tab2d_1=old_v_s    (:,:,jl)        , clinfo1= ' lim_update  : old_v_s     : ')
+            CALL prt_ctl(tab2d_1=d_v_s_trp  (:,:,jl)        , clinfo1= ' lim_update  : d_v_s_trp   : ')
+            CALL prt_ctl(tab2d_1=d_v_s_thd  (:,:,jl)        , clinfo1= ' lim_update  : d_v_s_thd   : ')
+            CALL prt_ctl(tab2d_1=e_i        (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : e_i1        : ')
+            CALL prt_ctl(tab2d_1=old_e_i    (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : old_e_i1    : ')
+            CALL prt_ctl(tab2d_1=d_e_i_trp  (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : de_i1_trp   : ')
+            CALL prt_ctl(tab2d_1=d_e_i_thd  (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : de_i1_thd   : ')
+            CALL prt_ctl(tab2d_1=e_i        (:,:,2,jl)/1.0e9, clinfo1= ' lim_update  : e_i2        : ')
+            CALL prt_ctl(tab2d_1=old_e_i    (:,:,2,jl)/1.0e9, clinfo1= ' lim_update  : old_e_i2    : ')
+            CALL prt_ctl(tab2d_1=d_e_i_trp  (:,:,2,jl)/1.0e9, clinfo1= ' lim_update  : de_i2_trp   : ')
+            CALL prt_ctl(tab2d_1=d_e_i_thd  (:,:,2,jl)/1.0e9, clinfo1= ' lim_update  : de_i2_thd   : ')
+            CALL prt_ctl(tab2d_1=e_s        (:,:,1,jl)      , clinfo1= ' lim_update  : e_snow      : ')
+            CALL prt_ctl(tab2d_1=old_e_s    (:,:,1,jl)      , clinfo1= ' lim_update  : old_e_snow  : ')
+            CALL prt_ctl(tab2d_1=d_e_s_trp  (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : d_e_s_trp   : ')
+            CALL prt_ctl(tab2d_1=d_e_s_thd  (:,:,1,jl)/1.0e9, clinfo1= ' lim_update  : d_e_s_thd   : ')
+            CALL prt_ctl(tab2d_1=smv_i      (:,:,jl)        , clinfo1= ' lim_update  : smv_i       : ')
+            CALL prt_ctl(tab2d_1=old_smv_i  (:,:,jl)        , clinfo1= ' lim_update  : old_smv_i   : ')
+            CALL prt_ctl(tab2d_1=d_smv_i_trp(:,:,jl)        , clinfo1= ' lim_update  : d_smv_i_trp : ')
+            CALL prt_ctl(tab2d_1=d_smv_i_thd(:,:,jl)        , clinfo1= ' lim_update  : d_smv_i_thd : ')
+            CALL prt_ctl(tab2d_1=oa_i       (:,:,jl)        , clinfo1= ' lim_update  : oa_i        : ')
+            CALL prt_ctl(tab2d_1=old_oa_i   (:,:,jl)        , clinfo1= ' lim_update  : old_oa_i    : ')
+            CALL prt_ctl(tab2d_1=d_oa_i_trp (:,:,jl)        , clinfo1= ' lim_update  : d_oa_i_trp  : ')
+            CALL prt_ctl(tab2d_1=d_oa_i_thd (:,:,jl)        , clinfo1= ' lim_update  : d_oa_i_thd  : ')
+            CALL prt_ctl(tab2d_1=REAL(patho_case(:,:,jl))   , clinfo1= ' lim_update  : Path. case  : ')
+
+            DO jk = 1, nlay_i
+               CALL prt_ctl_info(' - Layer : ', ivar1=jk)
+               CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' lim_update  : t_i       : ')
+            END DO
+         END DO
+
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Heat / FW fluxes : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=fmmec  , clinfo1= ' lim_update : fmmec : ', tab2d_2=fhmec     , clinfo2= ' fhmec     : ')
+         CALL prt_ctl(tab2d_1=sst_m  , clinfo1= ' lim_update : sst   : ', tab2d_2=sss_m     , clinfo2= ' sss       : ')
+         CALL prt_ctl(tab2d_1=fhbri  , clinfo1= ' lim_update : fhbri : ', tab2d_2=fheat_rpo , clinfo2= ' fheat_rpo : ')
+
+         CALL prt_ctl_info(' ')
+         CALL prt_ctl_info(' - Stresses : ')
+         CALL prt_ctl_info('   ~~~~~~~~~~ ')
+         CALL prt_ctl(tab2d_1=utau       , clinfo1= ' lim_update : utau      : ', tab2d_2=vtau       , clinfo2= ' vtau      : ')
+         CALL prt_ctl(tab2d_1=utau_ice   , clinfo1= ' lim_update : utau_ice  : ', tab2d_2=vtau_ice   , clinfo2= ' vtau_ice  : ')
+         CALL prt_ctl(tab2d_1=u_oce      , clinfo1= ' lim_update : u_oce     : ', tab2d_2=v_oce      , clinfo2= ' v_oce     : ')
+      ENDIF
+
+      !---------------------
+
+   END SUBROUTINE lim_update
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module               No sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_update     ! Empty routine
+   END SUBROUTINE lim_update
+
+#endif
+
+END MODULE limupdate
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limvar.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limvar.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limvar.F90	(revision 1844)
@@ -0,0 +1,759 @@
+MODULE limvar
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                       ***  MODULE limvar ***
+   !!                 Different sets of ice model variables 
+   !!                   how to switch from one to another
+   !!
+   !!                 There are three sets of variables
+   !!                 VGLO : global variables of the model
+   !!                        - v_i (jpi,jpj,jpl)
+   !!                        - v_s (jpi,jpj,jpl)
+   !!                        - a_i (jpi,jpj,jpl)
+   !!                        - t_s (jpi,jpj,jpl)
+   !!                        - e_i (jpi,jpj,nlay_i,jpl)
+   !!                        - smv_i(jpi,jpj,jpl)
+   !!                        - oa_i (jpi,jpj,jpl)
+   !!                 VEQV : equivalent variables sometimes used in the model
+   !!                        - ht_i(jpi,jpj,jpl)
+   !!                        - ht_s(jpi,jpj,jpl)
+   !!                        - t_i (jpi,jpj,nlay_i,jpl)
+   !!                        ...
+   !!                 VAGG : aggregate variables, averaged/summed over all
+   !!                        thickness categories
+   !!                        - vt_i(jpi,jpj)
+   !!                        - vt_s(jpi,jpj)
+   !!                        - at_i(jpi,jpj)
+   !!                        - et_s(jpi,jpj)  !total snow heat content
+   !!                        - et_i(jpi,jpj)  !total ice thermal content 
+   !!                        - smt_i(jpi,jpj) !mean ice salinity
+   !!                        - ot_i(jpi,jpj)  !average ice age
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_ice
+   USE par_oce          ! ocean parameters
+   USE phycst           ! physical constants (ocean directory) 
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE thd_ice
+   USE in_out_manager
+   USE ice
+   USE par_ice
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_var_agg
+   PUBLIC lim_var_glo2eqv
+   PUBLIC lim_var_eqv2glo
+   PUBLIC lim_var_salprof
+   PUBLIC lim_var_bv
+   PUBLIC lim_var_salprof1d
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1e-20   ,  &
+      epsi13 = 1e-13   ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0,  UCL-ASTR-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+
+CONTAINS
+
+   SUBROUTINE lim_var_agg(n)
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_agg  ***
+      !! ** Purpose :
+      !!        This routine aggregates ice-thickness-category variables to  
+      !!                                all-ice variables
+      !!        i.e. it turns VGLO into VAGG
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !! ** Arguments : n = 1, at_i vt_i only
+      !!                n = 2 everything
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (01-2006) Martin Vancoppenolle, UCL-ASTR
+      !!
+      !! note : you could add an argument when you need only at_i, vt_i
+      !!        and when you need everything
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial dummy loop index
+         jj,       &   ! spatial dummy loop index
+         jk,       &   ! vertical layering dummy loop index
+         jl            ! ice category dummy loop index
+
+      REAL ::      zeps, epsi16, zinda, epsi06
+
+      INTEGER, INTENT( in ) ::   n     ! describes what is needed
+
+      !!-- End of declarations
+      !!----------------------------------------------------------------------------------------------
+      zeps = 1.0e-13
+      epsi16 = 1.0e-16
+      epsi06 = 1.0e-6
+
+      !------------------
+      ! Zero everything
+      !------------------
+
+      vt_i(:,:)  = 0.0
+      vt_s(:,:)  = 0.0
+      at_i(:,:)  = 0.0 
+      ato_i(:,:) = 1.0 
+
+      IF ( n .GT. 1 ) THEN
+         et_s(:,:)  = 0.0
+         ot_i(:,:)  = 0.0
+         smt_i(:,:) = 0.0
+         et_i(:,:)  = 0.0
+      ENDIF
+
+      !--------------------
+      ! Compute variables
+      !--------------------
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               vt_i(ji,jj) = vt_i(ji,jj) + v_i(ji,jj,jl) ! ice volume
+               vt_s(ji,jj) = vt_s(ji,jj) + v_s(ji,jj,jl) ! snow volume
+               at_i(ji,jj) = at_i(ji,jj) + a_i(ji,jj,jl) ! ice concentration
+
+               zinda = MAX( zzero , SIGN( zone , at_i(ji,jj) - 0.10 ) ) 
+               icethi(ji,jj) = vt_i(ji,jj) / MAX(at_i(ji,jj),epsi16)*zinda  
+               ! ice thickness
+            END DO
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ato_i(ji,jj) = MAX(1.0 - at_i(ji,jj), 0.0)   ! open water fraction
+         END DO
+      END DO
+
+      IF ( n .GT. 1 ) THEN
+
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  et_s(ji,jj)  = et_s(ji,jj)  +     &       ! snow heat content
+                     e_s(ji,jj,1,jl)
+                  zinda = MAX( zzero , SIGN( zone , vt_i(ji,jj) - 0.10 ) ) 
+                  smt_i(ji,jj) = smt_i(ji,jj) +     &       ! ice salinity
+                     smv_i(ji,jj,jl) / MAX( vt_i(ji,jj) , zeps ) * &
+                     zinda
+                  zinda = MAX( zzero , SIGN( zone , at_i(ji,jj) - 0.10 ) ) 
+                  ot_i(ji,jj)  = ot_i(ji,jj)  +     &       ! ice age
+                     oa_i(ji,jj,jl)  / MAX( at_i(ji,jj) , zeps ) * &
+                     zinda
+               END DO
+            END DO
+         END DO
+
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     et_i(ji,jj) = et_i(ji,jj) + e_i(ji,jj,jk,jl) ! ice heat
+                     ! content
+                  END DO
+               END DO
+            END DO
+         END DO
+
+      ENDIF ! n .GT. 1
+
+   END SUBROUTINE lim_var_agg
+
+   !==============================================================================
+
+   SUBROUTINE lim_var_glo2eqv
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_glo2eqv ***'
+      !! ** Purpose :
+      !!        This routine computes equivalent variables as function of    
+      !!                              global variables 
+      !!        i.e. it turns VGLO into VEQV
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!           kideb , kiut : Starting and ending points on which the 
+      !!                         the computation is applied
+      !!
+      !! ** Inputs / Ouputs : 
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (01-2006) Martin Vancoppenolle, UCL-ASTR
+      !!
+      !!------------------------------------------------------------------
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial dummy loop index
+         jj,       &   ! spatial dummy loop index
+         jk,       &   ! vertical layering dummy loop index
+         jl            ! ice category dummy loop index
+
+      REAL :: zq_i, zaaa, zbbb, zccc, zdiscrim, &
+         ztmelts, zindb, zq_s, zfac1, zfac2
+
+      REAL :: zeps, epsi06
+
+      zeps    = 1.0e-10
+      epsi06  = 1.0e-06
+
+      !!-- End of declarations
+      !!------------------------------------------------------------------------------
+
+      !-------------------------------------------------------
+      ! Ice thickness, snow thickness, ice salinity, ice age
+      !-------------------------------------------------------
+!CDIR NOVERRCHK
+      DO jl = 1, jpl
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zindb          = 1.0-MAX(0.0,SIGN(1.0,- a_i(ji,jj,jl))) !0 if no ice and 1 if yes
+               ht_i(ji,jj,jl) = v_i(ji,jj,jl)   / MAX( a_i(ji,jj,jl) , zeps ) * zindb
+               ht_s(ji,jj,jl) = v_s(ji,jj,jl)   / MAX( a_i(ji,jj,jl) , zeps ) * zindb
+               o_i(ji,jj,jl)  = oa_i(ji,jj,jl)  / MAX( a_i(ji,jj,jl) , zeps ) * zindb
+            END DO
+         END DO
+      END DO
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) )THEN
+
+!CDIR NOVERRCHK
+         DO jl = 1, jpl
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  zindb          = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl))) !0 if no ice and 1 if yes
+                  sm_i(ji,jj,jl) = smv_i(ji,jj,jl) / MAX(v_i(ji,jj,jl),zeps) * zindb
+               END DO
+            END DO
+         END DO
+
+      ENDIF
+
+      ! salinity profile
+      CALL lim_var_salprof
+
+      !-------------------
+      ! Ice temperatures
+      !-------------------
+!CDIR NOVERRCHK
+      DO jl = 1, jpl
+!CDIR NOVERRCHK
+         DO jk = 1, nlay_i
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  !Energy of melting q(S,T) [J.m-3]
+                  zq_i       = e_i(ji,jj,jk,jl) / area(ji,jj) / &
+                     MAX( v_i(ji,jj,jl) , epsi06 ) * nlay_i 
+                  ! zindb = 0 if no ice and 1 if yes
+                  zindb      = 1.0 - MAX( 0.0 , SIGN( 1.0 , - v_i(ji,jj,jl) ) )
+                  !convert units ! very important that this line is here
+                  zq_i       = zq_i * unit_fac * zindb
+                  !Ice layer melt temperature
+                  ztmelts    =  -tmut*s_i(ji,jj,jk,jl) + rtt
+                  !Conversion q(S,T) -> T (second order equation)
+                  zaaa       =  cpic
+                  zbbb       =  ( rcp - cpic ) * ( ztmelts - rtt ) + &
+                     zq_i / rhoic - lfus
+                  zccc       =  lfus * (ztmelts-rtt)
+                  zdiscrim   =  SQRT( MAX(zbbb*zbbb - 4.0*zaaa*zccc,0.0) )
+                  t_i(ji,jj,jk,jl) = rtt + zindb *( - zbbb - zdiscrim ) / & 
+                     ( 2.0 *zaaa )
+                  t_i(ji,jj,jk,jl) = MIN( rtt, MAX(173.15, t_i(ji,jj,jk,jl) ) )
+               END DO
+            END DO
+         END DO
+      END DO
+
+      !--------------------
+      ! Snow temperatures
+      !--------------------
+      zfac1 = 1. / ( rhosn * cpic )
+      zfac2 = lfus / cpic  
+!CDIR NOVERRCHK
+      DO jl = 1, jpl
+!CDIR NOVERRCHK
+         DO jk = 1, nlay_s
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  !Energy of melting q(S,T) [J.m-3]
+                  zq_s       = e_s(ji,jj,jk,jl) / area(ji,jj) / &
+                     MAX( v_s(ji,jj,jl) , epsi06 ) * nlay_s 
+                  ! zindb = 0 if no ice and 1 if yes
+                  zindb      = 1.0 - MAX( 0.0 , SIGN( 1.0 , - v_s(ji,jj,jl) ) )
+                  !convert units ! very important that this line is here
+                  zq_s       = zq_s * unit_fac * zindb
+                  t_s(ji,jj,jk,jl) = rtt + zindb * ( - zfac1 * zq_s + zfac2 )
+                  t_s(ji,jj,jk,jl) = MIN( rtt, MAX(173.15, t_s(ji,jj,jk,jl) ) )
+
+               END DO
+            END DO
+         END DO
+      END DO
+
+      !-------------------
+      ! Mean temperature
+      !-------------------
+      tm_i(:,:) = 0.0
+!CDIR NOVERRCHK
+      DO jl = 1, jpl
+!CDIR NOVERRCHK
+         DO jk = 1, nlay_i
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  zindb          = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl)))
+                  zindb          = zindb*1.0-MAX(0.0,SIGN(1.0,-v_i(ji,jj,jl)))
+                  tm_i(ji,jj) = tm_i(ji,jj) + t_i(ji,jj,jk,jl)*v_i(ji,jj,jl) / &
+                     REAL(nlay_i) / MAX( vt_i(ji,jj) , zeps )
+               END DO
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE lim_var_glo2eqv
+
+   !===============================================================================
+
+   SUBROUTINE lim_var_eqv2glo
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_eqv2glo ***'
+      !! ** Purpose :
+      !!        This routine computes global     variables as function of    
+      !!                              equivalent variables
+      !!        i.e. it turns VEQV into VGLO
+      !! ** Method  :
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References :
+      !!
+      !! ** History :
+      !!           (01-2006) Martin Vancoppenolle, UCL-ASTR
+      !!                     Take it easy man
+      !!                     Life is just a simple game, between 
+      !!                     ups / and downs \ :@)
+      !!
+      !!------------------------------------------------------------------
+
+      v_i(:,:,:)   = ht_i(:,:,:) * a_i(:,:,:)
+      v_s(:,:,:)   = ht_s(:,:,:) * a_i(:,:,:)
+      smv_i(:,:,:) = sm_i(:,:,:) * v_i(:,:,:)
+      oa_i (:,:,:) = o_i (:,:,:) * a_i(:,:,:)
+
+   END SUBROUTINE lim_var_eqv2glo
+
+   !===============================================================================
+
+   SUBROUTINE lim_var_salprof
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_salprof ***'
+      !! ** Purpose :
+      !!        This routine computes salinity profile in function of
+      !!        bulk salinity     
+      !!
+      !! ** Method  : If bulk salinity greater than s_i_1, 
+      !!              the profile is assumed to be constant (S_inf)
+      !!              If bulk salinity lower than s_i_0,
+      !!              the profile is linear with 0 at the surface (S_zero)
+      !!              If it is between s_i_0 and s_i_1, it is a
+      !!              alpha-weighted linear combination of s_inf and s_zero
+      !!
+      !! ** References : Vancoppenolle et al., 2007 (in preparation)
+      !!
+      !! ** History :
+      !!           (08-2006) Martin Vancoppenolle, UCL-ASTR
+      !!                     Take it easy man
+      !!                     Life is just a simple game, between ups 
+      !!                     / and downs \ :@)
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      !! * Local variables
+      INTEGER ::             &
+         ji            ,     & !: spatial dummy loop index
+         jj            ,     & !: spatial dummy loop index
+         jk            ,     & !: vertical layering dummy loop index
+         jl                    !: ice category dummy loop index
+
+      REAL(wp) ::            &
+         dummy_fac0    ,     & !: dummy factor used in computations
+         dummy_fac1    ,     & !: dummy factor used in computations
+         dummy_fac     ,     & !: dummy factor used in computations
+         zind0         ,     & !: switch, = 1 if sm_i lt s_i_0
+         zind01        ,     & !: switch, = 1 if sm_i between s_i_0 and s_i_1
+         zindbal       ,     & !: switch, = 1, if 2*sm_i gt sss_m
+         zargtemp              !: dummy factor
+
+      REAL(wp), DIMENSION(nlay_i) ::      &
+         zs_zero               !: linear salinity profile for salinities under
+      !: s_i_0
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: &
+         z_slope_s     ,     & !: slope of the salinity profile
+         zalpha                !: weight factor for s between s_i_0 and s_i_1
+
+      !!-- End of declarations
+      !!------------------------------------------------------------------------------
+
+      !---------------------------------------
+      ! Vertically constant, constant in time
+      !---------------------------------------
+
+      IF ( num_sal .EQ. 1 ) THEN
+
+         s_i(:,:,:,:) = bulk_sal
+
+      ENDIF
+
+      !-----------------------------------
+      ! Salinity profile, varying in time
+      !-----------------------------------
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) )THEN
+
+         DO jk = 1, nlay_i
+            s_i(:,:,jk,:)  = sm_i(:,:,:)
+         END DO ! jk
+
+         ! Slope of the linear profile zs_zero
+         !-------------------------------------
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z_slope_s(ji,jj,jl) = 2.0 * sm_i(ji,jj,jl) / MAX( 0.01      &
+                     , ht_i(ji,jj,jl) )
+               END DO ! ji
+            END DO ! jj
+         END DO ! jl
+
+         ! Weighting factor between zs_zero and zs_inf
+         !---------------------------------------------
+         dummy_fac0 = 1. / ( ( s_i_0 - s_i_1 ) )
+         dummy_fac1 = s_i_1 / ( s_i_1 - s_i_0 )
+
+         zalpha(:,:,:) = 0.0
+
+!CDIR NOVERRCHK
+         DO jl = 1, jpl
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  ! zind0 = 1 if sm_i le s_i_0 and 0 otherwise
+                  zind0  = MAX( 0.0   , SIGN( 1.0  , s_i_0 - sm_i(ji,jj,jl) ) ) 
+                  ! zind01 = 1 if sm_i is between s_i_0 and s_i_1 and 0 othws 
+                  zind01 = ( 1.0 - zind0 ) *                                  &
+                     MAX( 0.0   , SIGN( 1.0  , s_i_1 - sm_i(ji,jj,jl) ) ) 
+                  ! If 2.sm_i GE sss_m then zindbal = 1
+                  zindbal = MAX( 0.0 , SIGN( 1.0 , 2. * sm_i(ji,jj,jl) -      &
+                     sss_m(ji,jj) ) )
+                  zalpha(ji,jj,jl) = zind0  * 1.0                             &
+                     + zind01 * ( sm_i(ji,jj,jl) * dummy_fac0 + &
+                     dummy_fac1 )
+                  zalpha(ji,jj,jl) = zalpha(ji,jj,jl) * ( 1.0 - zindbal )
+               END DO
+            END DO
+         END DO
+
+         ! Computation of the profile
+         !----------------------------
+         dummy_fac = 1. / nlay_i
+
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ! linear profile with 0 at the surface
+                     zs_zero(jk)      = z_slope_s(ji,jj,jl) * ( jk - 1./2. ) * &
+                        ht_i(ji,jj,jl) * dummy_fac
+                     ! weighting the profile
+                     s_i(ji,jj,jk,jl) = zalpha(ji,jj,jl) * zs_zero(jk) +       &
+                        ( 1.0 - zalpha(ji,jj,jl) ) * sm_i(ji,jj,jl)
+                  END DO ! ji
+               END DO ! jj
+            END DO ! jk
+         END DO ! jl
+
+      ENDIF ! num_sal
+
+      !-------------------------------------------------------
+      ! Vertically varying salinity profile, constant in time
+      !-------------------------------------------------------
+      ! Schwarzacher (1959) multiyear salinity profile (mean = 2.30)
+
+      IF ( num_sal .EQ. 3 ) THEN
+
+         sm_i(:,:,:) = 2.30
+
+!CDIR NOVERRCHK
+         DO jl = 1, jpl
+!CDIR NOVERRCHK
+            DO jk = 1, nlay_i
+!CDIR NOVERRCHK
+               DO jj = 1, jpj
+!CDIR NOVERRCHK
+                  DO ji = 1, jpi
+                     zargtemp  = ( jk - 0.5 ) / nlay_i
+                     s_i(ji,jj,jk,jl) =  1.6 - 1.6 * COS( 3.14169265 * &
+                        ( zargtemp**(0.407/           &
+                        ( 0.573 + zargtemp ) ) ) )
+                  END DO ! ji
+               END DO ! jj
+            END DO ! jk
+         END DO ! jl
+
+      ENDIF ! num_sal
+
+   END SUBROUTINE lim_var_salprof
+
+   !===============================================================================
+
+   SUBROUTINE lim_var_bv
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_bv ***'
+      !! ** Purpose :
+      !!        This routine computes mean brine volume (%) in sea ice
+      !!
+      !! ** Method  : e = - 0.054 * S (ppt) / T (C)
+      !!
+      !! ** Arguments :
+      !!
+      !! ** Inputs / Ouputs : (global commons)
+      !!
+      !! ** External : 
+      !!
+      !! ** References : Vancoppenolle et al., JGR, 2007
+      !!
+      !! ** History :
+      !!           (08-2006) Martin Vancoppenolle, UCL-ASTR
+      !!
+      !!------------------------------------------------------------------
+      !! * Arguments
+
+      !! * Local variables
+      INTEGER ::   ji,       &   ! spatial dummy loop index
+         jj,       &   ! spatial dummy loop index
+         jk,       &   ! vertical layering dummy loop index
+         jl            ! ice category dummy loop index
+
+      REAL :: zbvi,          &   ! brine volume for a single ice category
+         zeps,          &   ! very small value
+         zindb              ! is there ice or not
+
+      !!-- End of declarations
+      !!------------------------------------------------------------------------------
+
+      zeps = 1.0e-13
+      bv_i(:,:) = 0.0
+!CDIR NOVERRCHK
+      DO jl = 1, jpl
+!CDIR NOVERRCHK
+         DO jk = 1, nlay_i
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  zindb          = 1.0-MAX(0.0,SIGN(1.0,-a_i(ji,jj,jl))) !0 if no ice and 1 if yes
+                  zbvi = - zindb * tmut *s_i(ji,jj,jk,jl) /             & 
+                     MIN( t_i(ji,jj,jk,jl) - 273.15 , zeps )         &
+                     * v_i(ji,jj,jl) / REAL(nlay_i)
+                  bv_i(ji,jj) = bv_i(ji,jj) + zbvi  &
+                     / MAX( vt_i(ji,jj) , zeps )
+               END DO
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE lim_var_bv
+
+   !===============================================================================
+
+   SUBROUTINE lim_var_salprof1d(kideb,kiut)
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_thd_salprof1d  ***
+      !!
+      !! ** Purpose :   1d computation of the sea ice salinity profile
+      !!                Works with 1d vectors and is used by thermodynamic
+      !!                modules
+      !!
+      !! history :
+      !!   3.0  !  May  2007 M. Vancoppenolle  Original code
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) :: &
+         kideb, kiut             ! thickness category index
+
+      INTEGER ::             &
+         ji, jk,             &   ! geographic and layer index 
+         zji, zjj
+
+      REAL(wp) ::            &
+         dummy_fac0,         &   ! dummy factors
+         dummy_fac1,         &
+         dummy_fac2,         &
+         zalpha    ,         &   ! weighting factor
+         zind0     ,         &   ! switches as in limvar
+         zind01    ,         &   ! switch
+         zindbal   ,         &   ! switch if in freshwater area
+         zargtemp
+
+      REAL(wp), DIMENSION(jpij) ::            &
+         z_slope_s
+
+      REAL(wp), DIMENSION(jpij,jkmax) ::      &
+         zs_zero
+      !!-------------------------------------------------------------------
+
+      !---------------------------------------
+      ! Vertically constant, constant in time
+      !---------------------------------------
+
+      IF ( num_sal .EQ. 1 ) THEN
+
+         s_i_b(:,:) = bulk_sal
+
+      ENDIF
+
+      !------------------------------------------------------
+      ! Vertically varying salinity profile, varying in time
+      !------------------------------------------------------
+
+      IF ( ( num_sal .EQ. 2 ) .OR. ( num_sal .EQ. 4 ) ) THEN
+
+         ! Slope of the linear profile zs_zero
+         !-------------------------------------
+!CDIR NOVERRCHK
+         DO ji = kideb, kiut 
+            z_slope_s(ji) = 2.0 * sm_i_b(ji) / MAX( 0.01      &
+               , ht_i_b(ji) )
+         END DO ! ji
+
+         ! Weighting factor between zs_zero and zs_inf
+         !---------------------------------------------
+         dummy_fac0 = 1. / ( ( s_i_0 - s_i_1 ) )
+         dummy_fac1 = s_i_1 / ( s_i_1 - s_i_0 )
+         dummy_fac2 = 1. / nlay_i
+
+!CDIR NOVERRCHK
+         DO jk = 1, nlay_i
+!CDIR NOVERRCHK
+            DO ji = kideb, kiut
+               zji    =  MOD( npb(ji) - 1, jpi ) + 1
+               zjj    =  ( npb(ji) - 1 ) / jpi + 1
+               zalpha = 0.0
+               ! zind0 = 1 if sm_i le s_i_0 and 0 otherwise
+               zind0  = MAX( 0.0   , SIGN( 1.0  , s_i_0 - sm_i_b(ji) ) ) 
+               ! zind01 = 1 if sm_i is between s_i_0 and s_i_1 and 0 othws 
+               zind01 = ( 1.0 - zind0 ) *                                  &
+                  MAX( 0.0   , SIGN( 1.0  , s_i_1 - sm_i_b(ji) ) ) 
+               ! if 2.sm_i GE sss_m then zindbal = 1
+               zindbal = MAX( 0.0 , SIGN( 1.0 , 2. * sm_i_b(ji) -      &
+                  sss_m(zji,zjj) ) )
+
+               zalpha = zind0  * 1.0                                       &
+                  + zind01 * ( sm_i_b(ji) * dummy_fac0 +           &
+                  dummy_fac1 )
+               zalpha = zalpha * ( 1.0 - zindbal )
+
+               zs_zero(ji,jk) = z_slope_s(ji) * ( jk - 1./2. ) * &
+                  ht_i_b(ji) * dummy_fac2
+               ! weighting the profile
+               s_i_b(ji,jk) = zalpha * zs_zero(ji,jk) +       &
+                  ( 1.0 - zalpha ) * sm_i_b(ji)
+            END DO ! ji
+         END DO ! jk
+
+      ENDIF ! num_sal
+
+      !-------------------------------------------------------
+      ! Vertically varying salinity profile, constant in time
+      !-------------------------------------------------------
+      ! Schwarzacher (1959) multiyear salinity profile (mean = 2.30)
+
+      IF ( num_sal .EQ. 3 ) THEN
+
+         sm_i_b(:) = 2.30
+
+!CDIR NOVERRCHK
+         DO ji = kideb, kiut
+!CDIR NOVERRCHK
+            DO jk = 1, nlay_i
+               zargtemp  = ( jk - 0.5 ) / nlay_i
+               s_i_b(ji,jk)  =  1.6 - 1.6*cos(3.14169265*(zargtemp**(0.407/ &
+                  (0.573+zargtemp))))
+            END DO ! jk
+         END DO ! ji
+
+      ENDIF ! num_sal
+
+   END SUBROUTINE lim_var_salprof1d
+
+   !===============================================================================
+
+#else
+   !!======================================================================
+   !!                       ***  MODULE limvar  ***
+   !!                          no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_var_agg          ! Empty routines
+   END SUBROUTINE lim_var_agg
+   SUBROUTINE lim_var_glo2eqv      ! Empty routines
+   END SUBROUTINE lim_var_glo2eqv
+   SUBROUTINE lim_var_eqv2glo      ! Empty routines
+   END SUBROUTINE lim_var_eqv2glo
+   SUBROUTINE lim_var_salprof      ! Empty routines
+   END SUBROUTINE lim_var_salprof
+   SUBROUTINE lim_var_bv           ! Emtpy routines
+   END SUBROUTINE lim_var_bv
+   SUBROUTINE lim_var_salprof1d    ! Emtpy routines
+   END SUBROUTINE lim_var_salprof1d
+
+#endif
+END MODULE limvar
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri.F90	(revision 1844)
@@ -0,0 +1,509 @@
+MODULE limwri
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                      LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!======================================================================
+   !!                     ***  MODULE  limwri  ***
+   !!         Ice diagnostics :  write ice output files
+   !!======================================================================
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!  LIM 3.0, UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !!   lim_wri      : write of the diagnostics variables in ouput file 
+   !!   lim_wri_init : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE ioipsl
+   USE dianam          ! build name of file (routine)
+   USE phycst
+   USE dom_oce
+   USE in_out_manager
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE dom_ice
+   USE ice
+   USE iceini
+   USE lbclnk
+   USE par_ice
+   USE limvar
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_wri        ! routine called by lim_step.F90
+
+   !! * Module variables
+   INTEGER, PARAMETER ::   &  !:
+      jpnoumax = 40             !: maximum number of variable for ice output
+   INTEGER  ::                                &
+      noumef          ,                       &  ! number of fields
+      noumefa         ,                       &  ! number of additional fields
+      add_diag_swi    ,                       &  ! additional diagnostics
+      nz                                         ! dimension for the itd field
+
+   REAL(wp)           , DIMENSION(jpnoumax) ::  &
+      cmulti          ,                       &  ! multiplicative constant
+      cadd            ,                       &  ! additive constant
+      cmultia         ,                       &  ! multiplicative constant
+      cadda                                      ! additive constant
+   CHARACTER(len = 35), DIMENSION(jpnoumax) ::  &
+      titn, titna                                ! title of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::  &
+      nam, nama                                  ! name of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::  &
+      uni, unia                                  ! unit of the field
+   INTEGER            , DIMENSION(jpnoumax) ::  &
+      nc, nca                                    ! switch for saving field ( = 1 ) or not ( = 0 )
+
+   REAL(wp)  ::            &  ! constant values
+      epsi16 = 1e-16   ,  &
+      zzero  = 0.e0     ,  &
+      zone   = 1.e0
+
+CONTAINS
+#if defined key_dimgout
+
+# include "limwri_dimg.h90"
+
+#else
+
+   SUBROUTINE lim_wri( kindic )
+      !!-------------------------------------------------------------------
+      !!  This routine computes the average of some variables and write it
+      !!  on the ouput files.
+      !!  ATTENTION cette routine n'est valable que si le pas de temps est
+      !!  egale a une fraction entiere de 1 jours.
+      !!  Diff 1-D 3-D : suppress common also included in etat
+      !!                 suppress cmoymo 11-18
+      !!  modif : 03/06/98
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) :: &
+         kindic                 ! if kindic < 0 there has been an error somewhere
+
+      !! * Local variables
+      REAL(wp),DIMENSION(1) ::   zdept
+
+      REAL(wp) :: &
+         zsto, zjulian,zout, &
+         zindh,zinda,zindb
+      REAL(wp), DIMENSION(jpi,jpj,jpnoumax) :: &
+         zcmo,               &
+         zcmoa                   ! additional fields
+
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zfield
+
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::  &
+         zmaskitd, zoi, zei
+
+      INTEGER ::  ji, jj, jk, jl, jf, ipl ! dummy loop indices
+
+      CHARACTER(len = 40)  :: &
+         clhstnam, clop, &
+         clhstnama
+
+      INTEGER , SAVE ::      &
+         nice, nhorid, ndim, niter, ndepid
+      INTEGER , SAVE ::      &
+         nicea, nhorida, ndimitd
+      INTEGER , DIMENSION( jpij ) , SAVE ::  &
+         ndex51
+      INTEGER , DIMENSION( jpij*jpl ) , SAVE ::  &
+         ndexitd
+      !!-------------------------------------------------------------------
+
+      ipl = jpl
+
+      IF ( numit == nstart ) THEN 
+
+         CALL lim_wri_init 
+
+         IF(lwp) WRITE(numout,*) ' lim_wri, first time step '
+         IF(lwp) WRITE(numout,*) ' add_diag_swi ', add_diag_swi
+
+         !--------------------
+         !  1) Initialization
+         !--------------------
+
+         !-------------
+         ! Normal file
+         !-------------
+
+         zsto     = rdt_ice
+         IF( ln_mskland )   THEN   ;   clop = "ave(only(x))"   ! put 1.e+20 on land (very expensive!!)
+         ELSE                      ;   clop = "ave(x)"         ! no use of the mask value (require less cpu time)
+         ENDIF
+         zout     = nwrite * rdt_ice / nn_fsbc
+         niter    = ( nit000 - 1 ) / nn_fsbc
+         zdept(1) = 0.
+
+         CALL ymds2ju ( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         CALL dia_nam ( clhstnam, nwrite, 'icemod' )
+         CALL histbeg ( clhstnam, jpi, glamt, jpj, gphit, 1, jpi, 1, jpj, niter, zjulian, rdt_ice,   &
+            &           nhorid, nice, domain_id=nidom )
+         CALL histvert( nice, "deptht", "Vertical T levels", "m", 1, zdept, ndepid, "down")
+         CALL wheneq  ( jpij , tmask(:,:,1), 1, 1., ndex51, ndim)
+
+         DO jf = 1 , noumef
+            IF(lwp) WRITE(numout,*) 'jf', jf
+            IF ( nc(jf) == 1 ) THEN
+               CALL histdef( nice, nam(jf), titn(jf), uni(jf), jpi, jpj &
+                  , nhorid, 1, 1, 1, -99, 32, clop, zsto, zout )
+               IF(lwp) WRITE(numout,*) 'nice, nam(jf), titn(jf), uni(jf), nhorid, clop, zsto, zout'
+               IF(lwp) WRITE(numout,*)  nice, nam(jf), titn(jf), uni(jf), nhorid, clop, zsto, zout 
+            ENDIF
+         END DO
+
+         CALL histend(nice)
+
+         !-----------------
+         ! ITD file output
+         !-----------------
+         zsto     = rdt_ice
+         clop     = "ave(x)"
+         zout     = nwrite * rdt_ice / nn_fsbc
+         zdept(1) = 0.
+
+         CALL dia_nam ( clhstnama, nwrite, 'icemoa' )
+         CALL histbeg ( clhstnama, jpi, glamt, jpj, gphit,         &
+            1, jpi, 1, jpj,            & ! zoom
+            niter, zjulian, rdt_ice,   & ! time
+            nhorida,                   & ! ? linked with horizontal ...
+            nicea , domain_id=nidom)                  ! file 
+         CALL histvert( nicea, "icethi", "L levels",               &
+            "m", ipl , hi_mean , nz )
+         DO jl = 1, jpl
+            zmaskitd(:,:,jl) = tmask(:,:,1)
+         END DO
+         CALL wheneq  ( jpij , tmask(:,:,1), 1, 1., ndex51, ndim)
+         CALL wheneq( jpi*jpj*jpl, zmaskitd, 1, 1., ndexitd, ndimitd  )  
+         CALL histdef( nicea, "iice_itd", "Ice area in categories"         , "-"    ,   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histdef( nicea, "iice_hid", "Ice thickness in categories"    , "m"    ,   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histdef( nicea, "iice_hsd", "Snow depth in in categories"    , "m"    ,   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histdef( nicea, "iice_std", "Ice salinity distribution"      , "ppt"  ,   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histdef( nicea, "iice_otd", "Ice age distribution"               , "days",   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histdef( nicea, "iice_etd", "Brine volume distr. "               , "%"    ,   &  
+            jpi, jpj, nhorida, jpl, 1, jpl, nz, 15, clop, zsto, zout )
+         CALL histend(nicea)
+      ENDIF
+
+      !     !-----------------------------------------------------------------------!
+      !     !--2. Computation of instantaneous values                               ! 
+      !     !-----------------------------------------------------------------------!
+
+      !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+      IF( ln_nicep ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_wri : write ice outputs in NetCDF files at time : ', nyear, nmonth, nday, numit
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) ' kindic = ', kindic
+      ENDIF
+      !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+      !-- calculs des valeurs instantanees
+      zcmo( 1:jpi, 1:jpj, 1:jpnoumax ) = 0.0 
+      zcmoa( 1:jpi, 1:jpj, 1:jpnoumax ) = 0.0 
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zindh  = MAX( zzero , SIGN( zone , vt_i(ji,jj) * at_i(ji,jj) - 0.10 ) )
+               zinda  = MAX( zzero , SIGN( zone , at_i(ji,jj) - 0.10 ) )
+               zcmo(ji,jj,17) = zcmo(ji,jj,17) + a_i(ji,jj,jl)*qsr_ice (ji,jj,jl) 
+               zcmo(ji,jj,18) = zcmo(ji,jj,18) + a_i(ji,jj,jl)*qns_ice(ji,jj,jl) 
+               zcmo(ji,jj,27) = zcmo(ji,jj,27) + t_su(ji,jj,jl)*a_i(ji,jj,jl)/MAX(at_i(ji,jj),epsi16)*zinda
+            END DO
+         END DO
+      END DO
+
+      CALL lim_var_bv
+
+      DO jj = 2 , jpjm1
+         DO ji = 2 , jpim1
+            zindh  = MAX( zzero , SIGN( zone , vt_i(ji,jj) * at_i(ji,jj) - 0.10 ) )
+            zinda  = MAX( zzero , SIGN( zone , at_i(ji,jj) - 0.10 ) )
+            zindb  = zindh * zinda
+
+            zcmo(ji,jj,1)  = at_i(ji,jj)
+            zcmo(ji,jj,2)  = vt_i(ji,jj)/MAX(at_i(ji,jj),epsi16)*zinda
+            zcmo(ji,jj,3)  = vt_s(ji,jj)/MAX(at_i(ji,jj),epsi16)*zinda
+            zcmo(ji,jj,4)  = diag_bot_gr(ji,jj) * &
+               86400.0 * zinda !Bottom thermodynamic ice production
+            zcmo(ji,jj,5)  = diag_dyn_gr(ji,jj) * &
+               86400.0 * zinda !Dynamic ice production (rid/raft)
+            zcmo(ji,jj,22) = diag_lat_gr(ji,jj) * &
+               86400.0 * zinda !Lateral thermodynamic ice production
+            zcmo(ji,jj,23) = diag_sni_gr(ji,jj) * &
+               86400.0 * zinda !Snow ice production ice production
+            zcmo(ji,jj,24) = tm_i(ji,jj) - rtt
+
+            zcmo(ji,jj,6)  = fbif  (ji,jj)
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj)        &
+               &                                + u_ice(ji-1,jj) * tmu(ji-1,jj) )    &
+               &                     / 2.0 
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmv(ji,jj)        &
+               &                                + v_ice(ji,jj-1) * tmv(ji,jj-1) )    &
+               &                     / 2.0
+            zcmo(ji,jj,9)  = sst_m(ji,jj)
+            zcmo(ji,jj,10) = sss_m(ji,jj)
+
+            zcmo(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+            zcmo(ji,jj,12) = qsr(ji,jj)
+            zcmo(ji,jj,13) = qns(ji,jj)
+            zcmo(ji,jj,14) = fhbri(ji,jj)
+            zcmo(ji,jj,15) = utau_ice(ji,jj)
+            zcmo(ji,jj,16) = vtau_ice(ji,jj)
+            zcmo(ji,jj,17) = zcmo(ji,jj,17) + (1.0-at_i(ji,jj))*qsr(ji,jj)
+            zcmo(ji,jj,18) = zcmo(ji,jj,18) + (1.0-at_i(ji,jj))*qns(ji,jj)
+            zcmo(ji,jj,19) = sprecip(ji,jj)
+            zcmo(ji,jj,20) = smt_i(ji,jj)
+            zcmo(ji,jj,21) = ot_i(ji,jj)
+            zcmo(ji,jj,25) = et_i(ji,jj)
+            zcmo(ji,jj,26) = et_s(ji,jj)
+            zcmo(ji,jj,28) = fsbri(ji,jj)
+            zcmo(ji,jj,29) = fseqv(ji,jj)
+
+            zcmo(ji,jj,30) = bv_i(ji,jj)
+            zcmo(ji,jj,31) = hicol(ji,jj)
+            zcmo(ji,jj,32) = strength(ji,jj)
+            zcmo(ji,jj,33) = SQRT( zcmo(ji,jj,7)*zcmo(ji,jj,7) + &
+               zcmo(ji,jj,8)*zcmo(ji,jj,8) )
+            zcmo(ji,jj,34) = diag_sur_me(ji,jj) * &
+               86400.0 * zinda ! Surface melt
+            zcmo(ji,jj,35) = diag_bot_me(ji,jj) * &
+               86400.0 * zinda ! Bottom melt
+            zcmo(ji,jj,36) = divu_i(ji,jj)
+            zcmo(ji,jj,37) = shear_i(ji,jj)
+         END DO
+      END DO
+
+      !
+      ! ecriture d'un fichier netcdf
+      !
+      niter = niter + 1
+      DO jf = 1 , noumef
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
+               zfield(ji,jj) = zcmo(ji,jj,jf) * cmulti(jf) + cadd(jf)
+            END DO
+         END DO
+
+         IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+            CALL lbc_lnk( zfield, 'T', -1. )
+         ELSE 
+            CALL lbc_lnk( zfield, 'T',  1. )
+         ENDIF
+
+         IF( ln_nicep ) THEN 
+            WRITE(numout,*)
+            WRITE(numout,*) 'nc(jf), nice, nam(jf), niter, ndim'
+            WRITE(numout,*) nc(jf), nice, nam(jf), niter, ndim
+         ENDIF
+         IF ( nc(jf) == 1 ) CALL histwrite( nice, nam(jf), niter, zfield, ndim, ndex51 )
+
+      END DO
+
+      IF ( ( nn_fsbc * niter ) >= nitend .OR. kindic < 0 ) THEN
+         IF( lwp) WRITE(numout,*) ' Closing the icemod file '
+         CALL histclo( nice )
+      ENDIF
+
+      !-----------------------------
+      ! Thickness distribution file
+      !-----------------------------
+      IF ( add_diag_swi .EQ. 1 ) THEN
+
+         DO jl = 1, jpl 
+            CALL lbc_lnk( a_i(:,:,jl)  , 'T' ,  1. )
+            CALL lbc_lnk( sm_i(:,:,jl) , 'T' ,  1. )
+            CALL lbc_lnk( oa_i(:,:,jl) , 'T' ,  1. )
+            CALL lbc_lnk( ht_i(:,:,jl) , 'T' ,  1. )
+            CALL lbc_lnk( ht_s(:,:,jl) , 'T' ,  1. )
+         END DO
+
+         ! Compute ice age
+         DO jl = 1, jpl 
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zinda = MAX( zzero , SIGN( zone , a_i(ji,jj,jl) - 1.0e-6 ) )
+                  zoi(ji,jj,jl) = oa_i(ji,jj,jl)  / MAX( a_i(ji,jj,jl) , 1.0e-6 ) * &
+                     zinda
+               END DO
+            END DO
+         END DO
+
+         ! Compute brine volume
+         zei(:,:,:) = 0.0
+         DO jl = 1, jpl 
+            DO jk = 1, nlay_i
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zinda = MAX( zzero , SIGN( zone , a_i(ji,jj,jl) - 1.0e-6 ) )
+                     zei(ji,jj,jl) = zei(ji,jj,jl) + 100.0* &
+                        ( - tmut * s_i(ji,jj,jk,jl) / MIN( ( t_i(ji,jj,jk,jl) - rtt ), -1.0e-6 ) ) * &
+                        zinda / nlay_i
+                  END DO
+               END DO
+            END DO
+         END DO
+
+         DO jl = 1, jpl 
+            CALL lbc_lnk( zei(:,:,jl) , 'T' ,  1. )
+         END DO
+
+         CALL histwrite( nicea, "iice_itd", niter, a_i  , ndimitd , ndexitd  )   ! area
+         CALL histwrite( nicea, "iice_hid", niter, ht_i , ndimitd , ndexitd  )   ! thickness
+         CALL histwrite( nicea, "iice_hsd", niter, ht_s , ndimitd , ndexitd  )   ! snow depth
+         CALL histwrite( nicea, "iice_std", niter, sm_i , ndimitd , ndexitd  )   ! salinity
+         CALL histwrite( nicea, "iice_otd", niter, zoi  , ndimitd , ndexitd  )   ! age
+         CALL histwrite( nicea, "iice_etd", niter, zei  , ndimitd , ndexitd  )   ! brine volume
+
+         !     !  Create an output files (output.lim.abort.nc) if S < 0 or u > 20 m/s
+         !     IF( kindic < 0 )   CALL lim_wri_state( 'output.abort' )
+         !     not yet implemented
+
+         IF ( ( nn_fsbc * niter ) >= nitend .OR. kindic < 0 ) THEN
+            IF(lwp) WRITE(numout,*) ' Closing the icemod file '
+            CALL histclo( nicea ) 
+         ENDIF
+
+      ENDIF
+
+   END SUBROUTINE lim_wri
+#endif
+
+   SUBROUTINE lim_wri_init
+      !!-------------------------------------------------------------------
+      !!                    ***   ROUTINE lim_wri_init  ***
+      !!                
+      !! ** Purpose :   ???
+      !!
+      !! ** Method  : Read the namicewri namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicewri
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!-------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   nf      ! ???
+
+      TYPE FIELD 
+         CHARACTER(len = 35) :: ztitle 
+         CHARACTER(len = 8 ) :: zname          
+         CHARACTER(len = 8 ) :: zunit
+         INTEGER             :: znc   
+         REAL                :: zcmulti 
+         REAL                :: zcadd        
+      END TYPE FIELD
+
+      TYPE(FIELD) ::  &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19, field_20, field_21, field_22, field_23, field_24,   &
+         field_25, field_26, field_27, field_28, field_29, field_30,   &
+         field_31, field_32, field_33, field_34, field_35, field_36,   &
+         field_37
+
+      TYPE(FIELD) , DIMENSION(jpnoumax) :: zfield
+
+      NAMELIST/namiceout/ noumef, &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19, field_20, field_21, field_22, field_23, field_24,   &
+         field_25, field_26, field_27, field_28, field_29, field_30,   &
+         field_31, field_32, field_33, field_34, field_35, field_36,   &
+         field_37, add_diag_swi
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicewri
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namiceout )
+
+      zfield(1)  = field_1
+      zfield(2)  = field_2
+      zfield(3)  = field_3
+      zfield(4)  = field_4
+      zfield(5)  = field_5
+      zfield(6)  = field_6
+      zfield(7)  = field_7
+      zfield(8)  = field_8
+      zfield(9)  = field_9
+      zfield(10) = field_10
+      zfield(11) = field_11
+      zfield(12) = field_12
+      zfield(13) = field_13
+      zfield(14) = field_14
+      zfield(15) = field_15
+      zfield(16) = field_16
+      zfield(17) = field_17
+      zfield(18) = field_18
+      zfield(19) = field_19
+      zfield(20) = field_20
+      zfield(21) = field_21
+      zfield(22) = field_22
+      zfield(23) = field_23
+      zfield(24) = field_24
+      zfield(25) = field_25
+      zfield(26) = field_26
+      zfield(27) = field_27
+      zfield(28) = field_28
+      zfield(29) = field_29
+      zfield(30) = field_30
+      zfield(31) = field_31
+      zfield(32) = field_32
+      zfield(33) = field_33
+      zfield(34) = field_34
+      zfield(35) = field_35
+      zfield(36) = field_36
+      zfield(37) = field_37
+
+      DO nf = 1, noumef
+         titn  (nf) = zfield(nf)%ztitle
+         nam   (nf) = zfield(nf)%zname
+         uni   (nf) = zfield(nf)%zunit
+         nc    (nf) = zfield(nf)%znc
+         cmulti(nf) = zfield(nf)%zcmulti
+         cadd  (nf) = zfield(nf)%zcadd
+      END DO
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_wri_init : Ice parameters for outputs'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '    number of fields to be stored         noumef = ', noumef
+         WRITE(numout,*) '           title                            name     unit      Saving (1/0) ',   &
+            &            '    multiplicative constant       additive constant '
+         DO nf = 1 , noumef         
+            WRITE(numout,*) '   ', titn(nf), '   ', nam(nf),'      ', uni(nf),'  ', nc(nf),'        ', cmulti(nf),   &
+               '        ', cadd(nf)
+         END DO
+         WRITE(numout,*) ' add_diag_swi ', add_diag_swi
+      ENDIF
+
+   END SUBROUTINE lim_wri_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module          NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_wri          ! Empty routine
+   END SUBROUTINE lim_wri
+#endif
+
+   !!======================================================================
+END MODULE limwri
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri_dimg.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri_dimg.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/limwri_dimg.h90	(revision 1844)
@@ -0,0 +1,203 @@
+SUBROUTINE lim_wri
+   !!----------------------------------------------------------------------
+   !!  LIM 3.0, UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !!-------------------------------------------------------------------
+   !!  This routine computes the average of some variables and write it
+   !!  on the ouput files.
+   !!  ATTENTION cette routine n'est valable que si le pas de temps est
+   !!  egale a une fraction entiere de 1 jours.
+   !!  Diff 1-D 3-D : suppress common also included in etat
+   !!                 suppress cmoymo 11-18
+   !!  modif : 03/06/98
+   !!-------------------------------------------------------------------
+   !! * Local variables
+   USE  diawri, ONLY : dia_wri_dimg
+   REAL(wp),DIMENSION(1) ::   zdept
+
+   REAL(wp) :: &
+      zsto, zsec, zjulian,zout, &
+      zindh,zinda,zindb,  &
+      ztmu
+   REAL(wp), DIMENSION(jpi,jpj,jpnoumax) :: &
+      zcmo
+   REAL(wp), DIMENSION(jpi,jpj) ::  &
+      zfield
+   INTEGER, SAVE :: nmoyice, &  !: counter for averaging
+      &             nwf         !: number of fields to write on disk
+   INTEGER, SAVE,DIMENSION (:), ALLOCATABLE  :: nsubindex   !: subindex to be saved
+   ! according to namelist
+
+   REAL(wp), SAVE, DIMENSION(jpi,jpj,jpnoumax) :: rcmoy
+#if ! defined key_diainstant
+   LOGICAL, PARAMETER :: ll_dia_inst=.false.      ! local logical variable 
+#else
+   LOGICAL, PARAMETER :: ll_dia_inst=.true.
+#endif
+   INTEGER ::  ji, jj, jf, ii   ! dummy loop indices and array index
+   INTEGER :: iyear, iday, imon ! 
+
+   CHARACTER(LEN=80) :: clname, cltext, clmode
+
+
+   INTEGER , SAVE ::      &
+      nice, nhorid, ndim, niter, ndepid
+   INTEGER , DIMENSION( jpij ) , SAVE ::  &
+      ndex51  
+   !!-------------------------------------------------------------------
+   IF ( numit == nstart ) THEN 
+
+      CALL lim_wri_init 
+
+      nwf = 0 
+      ii  = 0
+
+      IF (lwp ) THEN
+         WRITE(numout,*) 'lim_wri : Write ice outputs in dimg'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '   According to namelist_ice, following fields saved:'
+         DO jf =1, noumef
+            IF (nc(jf) == 1 ) THEN
+               WRITE(numout,* ) '    -',titn(jf), nam(jf), uni(jf)
+            ENDIF
+         END DO
+      ENDIF
+
+      DO jf = 1, noumef
+         IF (nc(jf) == 1 ) nwf = nwf + 1
+      END DO
+
+      ALLOCATE( nsubindex (nwf) )
+
+      DO jf = 1, noumef
+         IF (nc(jf) == 1 ) THEN 
+            ii = ii +1 
+            nsubindex(ii) = jf
+         END IF
+      END DO
+
+      zsto     = rdt_ice
+      zout     = nwrite * rdt_ice / nn_fsbc
+      zsec     = 0.
+      niter    = 0
+      zdept(1) = 0.
+      nmoyice  = 0
+
+   ENDIF
+
+#if ! defined key_diainstant 
+   !-- calculs des valeurs instantanees
+
+   zcmo(:,:, 1:jpnoumax ) = 0.e0 
+   DO jj = 2 , jpjm1
+      DO ji = 2 , jpim1   ! NO vector opt.
+         zindh  = MAX( zzero , SIGN( zone , ht_i(ji,jj,1) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+         zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+         zindb  = zindh * zinda
+         ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+         zcmo(ji,jj,1)  = ht_s (ji,jj,1)
+         zcmo(ji,jj,2)  = ht_i (ji,jj,1)
+         zcmo(ji,jj,3)  = hicifp(ji,jj)
+         zcmo(ji,jj,4)  = frld  (ji,jj)
+         zcmo(ji,jj,5)  = sist  (ji,jj)
+         zcmo(ji,jj,6)  = fbif  (ji,jj)
+         zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+            + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+            / ztmu 
+
+         zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+            + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+            / ztmu
+         zcmo(ji,jj,9)  = sst_m(ji,jj)
+         zcmo(ji,jj,10) = sss_m(ji,jj)
+
+         zcmo(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+         zcmo(ji,jj,12) = qsr(ji,jj)
+         zcmo(ji,jj,13) = qns(ji,jj)
+         ! See thersf for the coefficient
+         zcmo(ji,jj,14) = - emps(ji,jj) * rday * ( sss_m(ji,jj) + epsi16 ) / soce
+         zcmo(ji,jj,15) = utau_ice(ji,jj)
+         zcmo(ji,jj,16) = vtau_ice(ji,jj)
+         zcmo(ji,jj,17) = qsr (ji,jj)
+         zcmo(ji,jj,18) = qns(ji,jj)
+         zcmo(ji,jj,19) = sprecip(ji,jj)
+      END DO
+   END DO
+   ! Cumulates values between outputs           
+   rcmoy(:,:,:)= rcmoy(:,:,:) + zcmo(:,:,:)
+   nmoyice = nmoyice + 1 
+   ! compute mean value if it is time to write on file
+   IF ( MOD(numit,nwrite) == 0 ) THEN
+      rcmoy(:,:,:) = rcmoy(:,:,:) / FLOAT(nmoyice)
+#else  
+      IF ( MOD(numit,nwrite) == 0 ) THEN 
+         !  case of instantaneaous output rcmoy(:,:, 1:jpnoumax ) = 0.e0
+         DO jj = 2 , jpjm1
+            DO ji = 2 , jpim1   ! NO vector opt.
+               zindh  = MAX( zzero , SIGN( zone , ht_i(ji,jj,1) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+               zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+               zindb  = zindh * zinda
+               ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) )
+               rcmoy(ji,jj,1)  = ht_s (ji,jj,1)
+               rcmoy(ji,jj,2)  = ht_i (ji,jj,1)
+               rcmoy(ji,jj,3)  = hicifp(ji,jj)
+               rcmoy(ji,jj,4)  = frld  (ji,jj)
+               rcmoy(ji,jj,5)  = sist  (ji,jj)
+               rcmoy(ji,jj,6)  = fbif  (ji,jj)
+               rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                  + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                  / ztmu
+
+               rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                  + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                  / ztmu
+               rcmoy(ji,jj,9)  = sst_m(ji,jj)
+               rcmoy(ji,jj,10) = sss_m(ji,jj)
+
+               rcmoy(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
+               rcmoy(ji,jj,12) = qsr(ji,jj)
+               rcmoy(ji,jj,13) = qns(ji,jj)
+               ! See thersf for the coefficient
+               rcmoy(ji,jj,14) = - emps(ji,jj) * rday * ( sss_m(ji,jj) + epsi16 ) / soce
+               rcmoy(ji,jj,15) = utau_ice(ji,jj)
+               rcmoy(ji,jj,16) = vtau_ice(ji,jj)
+               rcmoy(ji,jj,17) = qsr(ji,jj)
+               rcmoy(ji,jj,18) = qns(ji,jj)
+               rcmoy(ji,jj,19) = sprecip(ji,jj)
+            END DO
+         END DO
+#endif
+
+         !
+         niter = niter + 1
+         DO jf = 1 , noumef
+            zfield(:,:) = (rcmoy(:,:,jf) * cmulti(jf) + cadd(jf)) * tmask(:,:,1)
+
+            IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+               CALL lbc_lnk( zfield, 'T', -1. )
+            ELSE 
+               CALL lbc_lnk( zfield, 'T',  1. )
+            ENDIF
+            rcmoy(:,:,jf) = zfield(:,:)
+         END DO
+
+         IF (ll_dia_inst) THEN
+            clmode='instantaneous'
+         ELSE
+            WRITE(clmode,'(f5.1,a)' ) nwrite*rdt/86400.,' days average'
+         END IF
+         iyear = ndastp/10000
+         imon = (ndastp-iyear*10000)/100
+         iday = ndastp - imon*100 - iyear*10000
+         WRITE(clname,9000) TRIM(cexper),'ICEMOD',iyear,imon,iday
+         cltext=TRIM(cexper)//' ice modele output'//TRIM(clmode)
+         CALL dia_wri_dimg (clname, cltext, rcmoy, nwf , 'I', nsubindex)
+9000     FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
+
+         rcmoy(:,:,:) = 0.0
+         nmoyice = 0 
+      END IF     !  MOD(numit, nwrite == 0 ) !
+
+   END SUBROUTINE lim_wri
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/par_ice.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/par_ice.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/par_ice.F90	(revision 1844)
@@ -0,0 +1,26 @@
+MODULE par_ice
+   !!======================================================================
+   !!                       ***  MODULE par_ice   ***
+   !! LIM-3 Sea Ice :   definition of parameters
+   !!======================================================================
+   !! History :  3.0  ! 2003-08  (M. Vancoppenolle)  LIM-3
+   !!----------------------------------------------------------------------
+   USE par_oce
+
+   IMPLICIT NONE
+   PUBLIC          
+
+   !                                             !!! ice thermodynamics
+   INTEGER, PUBLIC, PARAMETER ::   jkmax    = 6   !: maximum number of ice layers
+   INTEGER, PUBLIC, PARAMETER ::   nlay_s   = 1   !: number of snow layers
+
+   !                                             !!! ice mechanical redistribution
+   INTEGER, PUBLIC, PARAMETER ::   jpl      = 5   !: number of ice categories
+   INTEGER, PUBLIC, PARAMETER ::   jpm      = 1   !: number of ice types
+
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.2, UCL-ASTR-LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE par_ice
Index: /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/thd_ice.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/thd_ice.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/LIM_SRC_3/thd_ice.F90	(revision 1844)
@@ -0,0 +1,163 @@
+MODULE thd_ice
+   !!======================================================================
+   !!                       ***  MODULE thd_ice  ***
+   !! LIM sea-ice :   Ice thermodynamics in 1D
+   !!=====================================================================
+   !! History :
+   !!   2.0  !  02-11  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!   LIM 3.0, UCL-LOCEAN-IPSL (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !!---------------------------
+   !! * Share Module variables
+   !!---------------------------
+   REAL(wp) , PUBLIC ::   & !!! ** ice-thermo namelist (namicethd) **
+      hmelt   = -0.15  ,  &  !: maximum melting at the bottom; active only for
+                                !: one category
+      hicmin  = 0.2    ,  &  !: (REMOVE)
+      hiclim  = 0.05   ,  &  !: minimum ice thickness
+      amax    = 0.999  ,  &  !: maximum lead fraction
+      sbeta   = 1.0    ,  &  !: numerical scheme for diffusion in ice  (REMOVE)
+      parlat  = 0.0    ,  &  !: (REMOVE)
+      hakspl  = 0.5    ,  &  !: (REMOVE)
+      hibspl  = 0.5    ,  &  !: (REMOVE)
+      exld    = 2.0    ,  &  !: (REMOVE)
+      hakdif  = 1.0    ,  &  !: (REMOVE)
+      thth    = 0.2    ,  &  !: (REMOVE)
+      hnzst   = 0.1    ,  &  !: thick. of the surf. layer in temp. comp.
+      parsub  = 1.0    ,  &  !: switch for snow sublimation or not
+      alphs   = 1.0    ,  &  !: coef. for snow density when snow-ice formation
+      fraz_swi= 1.0    ,  &  !: use of frazil ice collection in function of wind (1.0) or not (0.0)
+      maxfrazb= 0.7    ,  &  !: maximum portion of frazil ice collecting at the ice bottom
+      vfrazb  = 0.41667,  &  !: threshold drift speed for collection of bottom frazil ice
+      Cfrazb  = 5.0          !: squeezing coefficient for collection of bottom frazil ice
+
+   REAL(wp), PUBLIC, DIMENSION(2)  ::  &  !:   
+      hiccrit = (/0.3,0.3/)  !: ice th. for lateral accretion in the NH (SH) (m)
+
+   !!-----------------------------
+   !! * Share 1D Module variables
+   !!-----------------------------
+   !: In ice thermodynamics, to spare memory, the vectors are folded
+   !: from 1D to 2D vectors. The following variables, with ending _1d (or _b)
+   !: are the variables corresponding to 2d vectors
+
+   INTEGER , PUBLIC, DIMENSION(jpij) ::   &  !:
+      npb     ,   &   !: number of points where computations has to be done
+      npac            !: correspondance between the points (lateral accretion)
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !: 
+      qldif_1d    ,     &  !: corresponding to the 2D var  qldif
+      qcmif_1d    ,     &  !: corresponding to the 2D var  qcmif
+      fstbif_1d   ,     &  !:    "                  "      fstric
+      fltbif_1d   ,     &  !:    "                  "      ffltbif
+      fscbq_1d    ,     &  !:    "                  "      fscmcbq
+      qsr_ice_1d  ,     &  !:    "                  "      qsr_ice
+      fr1_i0_1d   ,     &  !:    "                  "      fr1_i0
+      fr2_i0_1d   ,     &  !:    "                  "      fr2_i0
+      qnsr_ice_1d ,     &  !:    "                  "      qns_ice
+      qfvbq_1d    ,     &  !:    "                  "      qfvbq
+      t_bo_b               !:    "                  "      t_bo
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !: 
+      sprecip_1d  ,     &  !:    "                  "      sprecip
+      frld_1d     ,     &  !:    "                  "      frld
+      at_i_b      ,     &  !:    "                  "      frld
+      fbif_1d     ,     &  !:    "                  "      fbif
+      rdmicif_1d  ,     &  !:    "                  "      rdmicif
+      rdmsnif_1d  ,     &  !:    "                  "      rdmsnif
+      qlbbq_1d    ,     &  !:    "                  "      qlbsbq
+      dmgwi_1d    ,     &  !:    "                  "      dmgwi
+      dvsbq_1d    ,     &  !:    "                  "      rdvosif
+      dvbbq_1d    ,     &  !:    "                  "      rdvobif
+      dvlbq_1d    ,     &  !:    "                  "      rdvolif
+      dvnbq_1d    ,     &  !:    "                  "      rdvolif
+      dqns_ice_1d ,     &  !:    "                  "      dqns_ice
+      qla_ice_1d  ,     &  !:    "                  "      qla_ice
+      dqla_ice_1d ,     &  !:    "                  "      dqla_ice
+                                ! to reintegrate longwave flux inside the ice thermodynamics
+!!sm: not used      qtur_ice_1d ,     &  !:    "                  "      qtur_ice
+!!sm: not used      dqtu_ice_1d ,     &  !:    "                  "      dqtu_ice
+!!sm: not used      catm_ice_1d ,     &  !:    "                  "      catm_ice
+      tatm_ice_1d ,     &  !:    "                  "      tatm_ice
+!!sm: not used      evsq_ice_1d ,     &  !:    "                  "      evsq_ice
+!!sm: not used      sbud_ice_1d ,     &  !:    "                  "      sbud_ice
+      fsup        ,     &  !:    Energy flux sent from bottom to lateral ablation if |dhb|> 0.15 m
+      focea       ,     &  !:    Remaining energy in case of total ablation
+      i0          ,     &  !:    fraction of radiation transmitted to the ice interior
+      old_ht_i_b  ,     &  !:    Ice thickness at the beginnning of the time step [m]
+      old_ht_s_b  ,     &  !:    Snow thickness at the beginning of the time step [m]
+      fsbri_1d    ,     &  !:    Salt flux due to brine drainage
+      fhbri_1d    ,     &  !:    Heat flux due to brine drainage
+      fseqv_1d    ,     &  !:    Equivalent Salt flux due to ice growth/decay
+      dsm_i_fl_1d ,     &  !:    Ice salinity variations due to flushing
+      dsm_i_gd_1d ,     &  !:    Ice salinity variations due to gravity drainage
+      dsm_i_se_1d ,     &  !:    Ice salinity variations due to basal salt entrapment
+!!sm: not used      dsm_i_la_1d ,     &  !:    Ice salinity variations due to lateral accretion    
+      dsm_i_si_1d ,     &  !:    Ice salinity variations due to lateral accretion    
+      hicol_b              !:    Ice collection thickness accumulated in fleads
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !:
+      t_su_b      ,     &  !:    "                  "      t_su
+      a_i_b       ,     &  !:                              a_i
+      ht_i_b      ,     &  !:    "                  "      ht_s
+      ht_s_b      ,     &  !:    "                  "      ht_i
+      fc_su       ,     &  !:    Surface Conduction flux 
+      fc_bo_i     ,     &  !:    Bottom  Conduction flux 
+      dh_s_tot    ,     &  !:    Snow accretion/ablation        [m]
+      dh_i_surf   ,     &  !:    Ice surface accretion/ablation [m]
+      dh_i_bott   ,     &  !:    Ice bottom accretion/ablation  [m]
+      dh_snowice  ,     &  !:    Snow ice formation             [m of ice]
+      sm_i_b      ,     &  !:    Ice bulk salinity [ppt]
+      s_i_new     ,     &  !:    Salinity of new ice at the bottom
+      s_snowice   ,     &  !:    Salinity of new snow ice on top of the ice
+      o_i_b                !:    Ice age                        [days]
+
+   REAL(wp), PUBLIC, DIMENSION(jpij,nlay_s) ::   &  !:
+      t_s_b              !: corresponding to the 2D var  t_s
+   REAL(wp), PUBLIC, DIMENSION(jpij,jkmax) ::   &  !:
+      t_i_b,            &  !: corresponding to the 2D var  t_i
+      s_i_b,            &  !: profiled ice salinity
+      q_i_b,            &  !:    Ice  enthalpy per unit volume
+      q_s_b                !:    Snow enthalpy per unit volume
+
+   ! Clean the following ...
+   ! These variables are coded for conservation checks
+   REAL(wp), PUBLIC, DIMENSION(jpij,jpl)    ::   &  !
+      qt_i_in   ,           &  !: ice energy summed over categories (initial)
+      qt_i_fin  ,           &  !: ice energy summed over categories (final)
+      qt_s_in, qt_s_fin  ,  &  !: snow energy summed over categories
+      dq_i, sum_fluxq    ,  &  !: increment of energy, sum of fluxes
+      fatm, foce,           &  !: atmospheric, oceanic, heat flux
+      cons_error, surf_error   !: conservation, surface error
+
+   REAL(wp), PUBLIC, DIMENSION(jpij,jkmax)::   &  !:  goes to trash
+      q_i_layer_in,         &
+      q_i_layer_fin,        &
+      dq_i_layer, radab
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !:
+      ftotal_in  ,          &  !: initial total heat flux
+      ftotal_fin               !: final total heat flux
+
+   REAL(wp), PUBLIC, DIMENSION(jpij,0:nlay_s) ::   &  !:
+      fc_s
+   REAL(wp), PUBLIC, DIMENSION(jpij,0:jkmax)  ::   &  !:
+      fc_i
+   REAL(wp), PUBLIC, DIMENSION(jpij,nlay_s) ::   &  !:
+      de_s_lay
+   REAL(wp), PUBLIC, DIMENSION(jpij,jkmax)  ::   &  !:
+      de_i_lay
+   INTEGER , PUBLIC ::                           &
+      jiindex_1d   ! 1D index of debugging point
+
+   !!======================================================================
+END MODULE thd_ice
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif2model.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif2model.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif2model.F90	(revision 1844)
@@ -0,0 +1,101 @@
+#if defined key_agrif
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE Agrif_Set_numberofcells(Agrif_Gr)
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Set_numberofcells ***
+      !!--------------------------------------------- 
+      USE Agrif_Types
+      IMPLICIT NONE
+
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+
+      IF ( associated(Agrif_Curgrid) )THEN
+#include "SetNumberofcells.h"
+      ENDIF
+
+   END SUBROUTINE Agrif_Set_numberofcells
+
+   SUBROUTINE Agrif_Get_numberofcells(Agrif_Gr)
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Get_numberofcells ***
+      !!--------------------------------------------- 
+      USE Agrif_Types
+      IMPLICIT NONE
+
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+
+#include "GetNumberofcells.h"
+
+   END SUBROUTINE Agrif_Get_numberofcells
+
+   SUBROUTINE Agrif_Allocationcalls(Agrif_Gr)
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Allocationscalls ***
+      !!--------------------------------------------- 
+      USE Agrif_Types 
+#include "include_use_Alloc_agrif.h"
+      IMPLICIT NONE
+
+      Type(Agrif_Grid), Pointer :: Agrif_Gr
+
+#include "allocations_calls_agrif.h"
+
+   END SUBROUTINE Agrif_Allocationcalls
+
+   SUBROUTINE Agrif_probdim_modtype_def()
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_probdim_modtype_def ***
+      !!--------------------------------------------- 
+      USE Agrif_Types
+      IMPLICIT NONE
+
+#include "modtype_agrif.h"
+#include "probdim_agrif.h"
+#include "keys_agrif.h"
+
+      Return
+
+   END SUBROUTINE Agrif_probdim_modtype_def
+
+   SUBROUTINE Agrif_clustering_def()
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_clustering_def ***
+      !!--------------------------------------------- 
+      Use Agrif_Types
+      IMPLICIT NONE
+
+      Return
+
+   END SUBROUTINE Agrif_clustering_def
+
+   SUBROUTINE Agrif_comm_def(modelcomm)
+
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_clustering_def ***
+      !!--------------------------------------------- 
+      Use Agrif_Types
+      Use lib_mpp
+
+      IMPLICIT NONE
+
+      INTEGER :: modelcomm
+
+#if defined key_mpp_mpi
+      modelcomm = mpi_comm_opa
+#endif
+      Return
+
+   END SUBROUTINE Agrif_comm_def
+#else
+   SUBROUTINE Agrif2Model
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif2Model ***
+      !!--------------------------------------------- 
+      WRITE(*,*) 'Impossible to bet here'
+   END SUBROUTINE Agrif2model
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_oce.F90	(revision 1844)
@@ -0,0 +1,39 @@
+MODULE agrif_oce
+   !!======================================================================
+   !!                       ***  MODULE agrif_oce  ***
+   !! AGRIF :   define in memory AGRIF variables
+   !!----------------------------------------------------------------------
+   !! History :  2.0  ! 2007-12  (R. Benshila)  Original code
+   !!----------------------------------------------------------------------
+#if defined key_agrif
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+   USE dom_oce      ! domain parameters
+   
+   IMPLICIT NONE
+   PUBLIC 
+
+   !                                              !!* Namelist namagrif: AGRIF parameters
+   LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !:
+   INTEGER , PUBLIC ::   nn_cln_update = 3         !: update frequency 
+   REAL(wp), PUBLIC ::   rn_sponge_tra = rdt       !: sponge coeff. for tracers
+   REAL(wp), PUBLIC ::   rn_sponge_dyn = rdt       !: sponge coeff. for dynamics
+
+   !                                              !!! OLD namelist names
+   INTEGER , PUBLIC ::   nbclineupdate             !: update frequency 
+   REAL(wp), PUBLIC ::   visc_tra                  !: sponge coeff. for tracers
+   REAL(wp), PUBLIC ::   visc_dyn                  !: sponge coeff. for dynamics
+
+   LOGICAL , PUBLIC :: spongedoneT = .FALSE.   !: tracer   sponge layer indicator
+   LOGICAL , PUBLIC :: spongedoneU = .FALSE.   !: dynamics sponge layer indicator
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   spe1ur, spe2vr ,spbtr2, spe1ur2, spe2vr2, spbtr3   !: ???
+
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE agrif_oce
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 1844)
@@ -0,0 +1,620 @@
+MODULE agrif_opa_interp
+   !!======================================================================
+   !!                   ***  MODULE  agrif_opa_interp  ***
+   !! AGRIF: interpolation package
+   !!======================================================================
+   !! History :  2.0  !  2002-06  (XXX)  Original cade
+   !!             -   !  2005-11  (XXX) 
+   !!            3.2  !  2009-04  (R. Benshila) 
+   !!----------------------------------------------------------------------
+#if defined key_agrif && ! defined key_off_tra
+   !!----------------------------------------------------------------------
+   !!   'key_agrif'                                              AGRIF zoom
+   !!   NOT 'key_off_tra'                               NO off-line tracers
+   !!----------------------------------------------------------------------
+   !!   Agrif_tra     :
+   !!   Agrif_dyn     : 
+   !!   interpu       :
+   !!   interpv       :
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE oce
+   USE dom_oce      
+   USE sol_oce
+   USE agrif_oce
+   USE phycst
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+    
+   PUBLIC   Agrif_tra, Agrif_dyn, interpu, interpv
+
+#  include "domzgr_substitute.h90"  
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+   
+   SUBROUTINE Agrif_tra
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE Agrif_Tra  ***
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zrhox , alpha1, alpha2, alpha3
+      REAL(wp) ::   alpha4, alpha5, alpha6, alpha7
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zta, zsa   ! 3D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF( Agrif_Root() )   RETURN
+
+      Agrif_SpecialValue    = 0.e0
+      Agrif_UseSpecialValue = .TRUE.
+      zta(:,:,:) = 0.e0
+      zsa(:,:,:) = 0.e0
+
+      CALL Agrif_Bc_variable( zta, tn )
+      CALL Agrif_Bc_variable( zsa, sn )
+      Agrif_UseSpecialValue = .FALSE.
+
+      zrhox = Agrif_Rhox()
+
+      alpha1 = ( zrhox - 1. ) * 0.5
+      alpha2 = 1. - alpha1
+
+      alpha3 = ( zrhox - 1. ) / ( zrhox + 1. )
+      alpha4 = 1. - alpha3
+
+      alpha6 = 2. * ( zrhox - 1. ) / ( zrhox + 1. )
+      alpha7 =    - ( zrhox - 1. ) / ( zrhox + 3. )
+      alpha5 = 1. - alpha6 - alpha7
+
+      IF( nbondi == 1 .OR. nbondi == 2 ) THEN
+
+         ta(nlci,:,:) = alpha1 * zta(nlci,:,:) + alpha2 * zta(nlci-1,:,:)
+         sa(nlci,:,:) = alpha1 * zsa(nlci,:,:) + alpha2 * zsa(nlci-1,:,:)
+
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               IF( umask(nlci-2,jj,jk) == 0.e0 ) THEN
+                  ta(nlci-1,jj,jk) = ta(nlci,jj,jk) * tmask(nlci-1,jj,jk)
+                  sa(nlci-1,jj,jk) = sa(nlci,jj,jk) * tmask(nlci-1,jj,jk)
+               ELSE
+                  ta(nlci-1,jj,jk)=(alpha4*ta(nlci,jj,jk)+alpha3*ta(nlci-2,jj,jk))*tmask(nlci-1,jj,jk)
+                  sa(nlci-1,jj,jk)=(alpha4*sa(nlci,jj,jk)+alpha3*sa(nlci-2,jj,jk))*tmask(nlci-1,jj,jk)
+                  IF( un(nlci-2,jj,jk) > 0.e0 ) THEN
+                     ta(nlci-1,jj,jk)=( alpha6*ta(nlci-2,jj,jk)+alpha5*ta(nlci,jj,jk)  &
+                        &             + alpha7*ta(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
+                     sa(nlci-1,jj,jk)=( alpha6*sa(nlci-2,jj,jk)+alpha5*sa(nlci,jj,jk)  &
+                        &             + alpha7*sa(nlci-3,jj,jk) ) * tmask(nlci-1,jj,jk)
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      IF( nbondj == 1 .OR. nbondj == 2 ) THEN
+
+         ta(:,nlcj,:) = alpha1 * zta(:,nlcj,:) + alpha2 * zta(:,nlcj-1,:)
+         sa(:,nlcj,:) = alpha1 * zsa(:,nlcj,:) + alpha2 * zsa(:,nlcj-1,:)
+
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               IF( vmask(ji,nlcj-2,jk) == 0.e0 ) THEN
+                  ta(ji,nlcj-1,jk) = ta(ji,nlcj,jk) * tmask(ji,nlcj-1,jk)
+                  sa(ji,nlcj-1,jk) = sa(ji,nlcj,jk) * tmask(ji,nlcj-1,jk)
+               ELSE
+                  ta(ji,nlcj-1,jk)=(alpha4*ta(ji,nlcj,jk)+alpha3*ta(ji,nlcj-2,jk))*tmask(ji,nlcj-1,jk)        
+                  sa(ji,nlcj-1,jk)=(alpha4*sa(ji,nlcj,jk)+alpha3*sa(ji,nlcj-2,jk))*tmask(ji,nlcj-1,jk)
+                  IF (vn(ji,nlcj-2,jk) > 0.e0 ) THEN
+                     ta(ji,nlcj-1,jk)=( alpha6*ta(ji,nlcj-2,jk)+alpha5*ta(ji,nlcj,jk)  &
+                        &             + alpha7*ta(ji,nlcj-3,jk) ) * tmask(ji,nlcj-1,jk)
+                     sa(ji,nlcj-1,jk)=( alpha6*sa(ji,nlcj-2,jk)+alpha5*sa(ji,nlcj,jk)  &
+                        &             + alpha7*sa(ji,nlcj-3,jk))*tmask(ji,nlcj-1,jk)
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      IF( nbondi == -1 .OR. nbondi == 2 ) THEN
+         ta(1,:,:) = alpha1 * zta(1,:,:) + alpha2 * zta(2,:,:)
+         sa(1,:,:) = alpha1 * zsa(1,:,:) + alpha2 * zsa(2,:,:)      
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               IF( umask(2,jj,jk) == 0.e0 ) THEN
+                  ta(2,jj,jk) = ta(1,jj,jk) * tmask(2,jj,jk)
+                  sa(2,jj,jk) = sa(1,jj,jk) * tmask(2,jj,jk)
+               ELSE
+                  ta(2,jj,jk)=(alpha4*ta(1,jj,jk)+alpha3*ta(3,jj,jk))*tmask(2,jj,jk)        
+                  sa(2,jj,jk)=(alpha4*sa(1,jj,jk)+alpha3*sa(3,jj,jk))*tmask(2,jj,jk)
+                  IF( un(2,jj,jk) < 0.e0 ) THEN
+                     ta(2,jj,jk)=(alpha6*ta(3,jj,jk)+alpha5*ta(1,jj,jk)+alpha7*ta(4,jj,jk))*tmask(2,jj,jk)
+                     sa(2,jj,jk)=(alpha6*sa(3,jj,jk)+alpha5*sa(1,jj,jk)+alpha7*sa(4,jj,jk))*tmask(2,jj,jk)
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+      IF( nbondj == -1 .OR. nbondj == 2 ) THEN
+         ta(:,1,:) = alpha1 * zta(:,1,:) + alpha2 * zta(:,2,:)
+         sa(:,1,:) = alpha1 * zsa(:,1,:) + alpha2 * zsa(:,2,:)
+         DO jk=1,jpk      
+            DO ji=1,jpi
+               IF( vmask(ji,2,jk) == 0.e0 ) THEN
+                  ta(ji,2,jk)=ta(ji,1,jk) * tmask(ji,2,jk)
+                  sa(ji,2,jk)=sa(ji,1,jk) * tmask(ji,2,jk)
+               ELSE
+                  ta(ji,2,jk)=(alpha4*ta(ji,1,jk)+alpha3*ta(ji,3,jk))*tmask(ji,2,jk)
+                  sa(ji,2,jk)=(alpha4*sa(ji,1,jk)+alpha3*sa(ji,3,jk))*tmask(ji,2,jk) 
+                  IF( vn(ji,2,jk) < 0.e0 ) THEN
+                     ta(ji,2,jk)=(alpha6*ta(ji,3,jk)+alpha5*ta(ji,1,jk)+alpha7*ta(ji,4,jk))*tmask(ji,2,jk)
+                     sa(ji,2,jk)=(alpha6*sa(ji,3,jk)+alpha5*sa(ji,1,jk)+alpha7*sa(ji,4,jk))*tmask(ji,2,jk)
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE Agrif_tra
+
+
+   SUBROUTINE Agrif_dyn( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE Agrif_DYN  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) ::   kt
+      !!
+      INTEGER :: ji,jj,jk
+      REAL(wp) :: timeref
+      REAL(wp) :: z2dt, znugdt
+      REAL(wp) :: zrhox, rhoy
+      REAL(wp), DIMENSION(jpi,jpj) :: zua2d, zva2d
+      REAL(wp), DIMENSION(jpi,jpj) :: spgu1,spgv1
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zua, zva
+      !!----------------------------------------------------------------------  
+
+      IF( Agrif_Root() )   RETURN
+
+      zrhox = Agrif_Rhox()
+      rhoy = Agrif_Rhoy()
+
+      timeref = 1.
+
+      ! time step: leap-frog
+      z2dt = 2. * rdt
+      ! time step: Euler if restart from rest
+      IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
+      ! coefficients
+      znugdt =  grav * z2dt    
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = ln_spc_dyn
+
+      zua = 0.
+      zva = 0.
+      CALL Agrif_Bc_variable(zua,un,procname=interpu)
+      CALL Agrif_Bc_variable(zva,vn,procname=interpv)
+      zua2d = 0.
+      zva2d = 0.
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = ln_spc_dyn
+      CALL Agrif_Bc_variable(zua2d,e1u,calledweight=1.,procname=interpu2d)
+      CALL Agrif_Bc_variable(zva2d,e2v,calledweight=1.,procname=interpv2d)
+      Agrif_UseSpecialValue = .FALSE.
+
+
+      IF((nbondi == -1).OR.(nbondi == 2)) THEN
+
+         DO jj=1,jpj
+            laplacu(2,jj) = timeref * (zua2d(2,jj)/(rhoy*e2u(2,jj)))*umask(2,jj,1)
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(1:2,jj,jk) = (zua(1:2,jj,jk)/(rhoy*e2u(1:2,jj)))
+#if ! defined key_zco
+               ua(1:2,jj,jk) = ua(1:2,jj,jk) / fse3u(1:2,jj,jk)
+#endif
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(2,jj,jk) = (ua(2,jj,jk) - z2dt * znugdt * laplacu(2,jj))*umask(2,jj,jk)
+            END DO
+         END DO
+
+         spgu(2,:)=0.
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               spgu(2,jj)=spgu(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
+            END DO
+         END DO
+
+         DO jj=1,jpj
+            IF (umask(2,jj,1).NE.0.) THEN
+               spgu(2,jj)=spgu(2,jj)/hu(2,jj)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(2,jj,jk) = 0.25*(ua(1,jj,jk)+2.*ua(2,jj,jk)+ua(3,jj,jk))
+               ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
+            END DO
+         END DO
+
+         spgu1(2,:)=0.
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               spgu1(2,jj)=spgu1(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
+            END DO
+         END DO
+
+         DO jj=1,jpj
+            IF (umask(2,jj,1).NE.0.) THEN
+               spgu1(2,jj)=spgu1(2,jj)/hu(2,jj)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(2,jj,jk) = (ua(2,jj,jk)+spgu(2,jj)-spgu1(2,jj))*umask(2,jj,jk)
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               va(2,jj,jk) = (zva(2,jj,jk)/(zrhox*e1v(2,jj)))*vmask(2,jj,jk)
+#if ! defined key_zco
+               va(2,jj,jk) = va(2,jj,jk) / fse3v(2,jj,jk)
+#endif           
+            END DO
+         END DO
+
+         sshn(2,:)=sshn(3,:)
+         sshb(2,:)=sshb(3,:)
+
+      ENDIF
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+
+         DO jj=1,jpj
+            laplacu(nlci-2,jj) = timeref * (zua2d(nlci-2,jj)/(rhoy*e2u(nlci-2,jj)))
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(nlci-2:nlci-1,jj,jk) = (zua(nlci-2:nlci-1,jj,jk)/(rhoy*e2u(nlci-2:nlci-1,jj)))
+
+#if ! defined key_zco
+               ua(nlci-2:nlci-1,jj,jk) = ua(nlci-2:nlci-1,jj,jk) / fse3u(nlci-2:nlci-1,jj,jk)
+#endif
+
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)- z2dt * znugdt * laplacu(nlci-2,jj))*umask(nlci-2,jj,jk)
+            END DO
+         END DO
+
+
+         spgu(nlci-2,:)=0.
+
+         do jk=1,jpkm1
+            do jj=1,jpj
+               spgu(nlci-2,jj)=spgu(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)
+            enddo
+         enddo
+
+         DO jj=1,jpj
+            IF (umask(nlci-2,jj,1).NE.0.) THEN
+               spgu(nlci-2,jj)=spgu(nlci-2,jj)/hu(nlci-2,jj)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(nlci-2,jj,jk) = 0.25*(ua(nlci-3,jj,jk)+2.*ua(nlci-2,jj,jk)+ua(nlci-1,jj,jk))
+
+               ua(nlci-2,jj,jk) = ua(nlci-2,jj,jk) * umask(nlci-2,jj,jk)
+
+            END DO
+         END DO
+
+         spgu1(nlci-2,:)=0.
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               spgu1(nlci-2,jj)=spgu1(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)*umask(nlci-2,jj,jk)
+            END DO
+         END DO
+
+         DO jj=1,jpj
+            IF (umask(nlci-2,jj,1).NE.0.) THEN
+               spgu1(nlci-2,jj)=spgu1(nlci-2,jj)/hu(nlci-2,jj)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)+spgu(nlci-2,jj)-spgu1(nlci-2,jj))*umask(nlci-2,jj,jk)
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj-1
+               va(nlci-1,jj,jk) = (zva(nlci-1,jj,jk)/(zrhox*e1v(nlci-1,jj)))*vmask(nlci-1,jj,jk)
+#if ! defined key_zco
+               va(nlci-1,jj,jk) = va(nlci-1,jj,jk) / fse3v(nlci-1,jj,jk)
+#endif
+            END DO
+         END DO
+
+         sshn(nlci-1,:)=sshn(nlci-2,:)
+         sshb(nlci-1,:)=sshb(nlci-2,:)        
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+
+         DO ji=1,jpi
+            laplacv(ji,2) = timeref * (zva2d(ji,2)/(zrhox*e1v(ji,2)))
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,1:2,jk) = (zva(ji,1:2,jk)/(zrhox*e1v(ji,1:2)))
+#if ! defined key_zco
+               va(ji,1:2,jk) = va(ji,1:2,jk) / fse3v(ji,1:2,jk)
+#endif
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,2,jk) = (va(ji,2,jk) - z2dt * znugdt * laplacv(ji,2))*vmask(ji,2,jk)
+            END DO
+         END DO
+
+         spgv(:,2)=0.
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               spgv(ji,2)=spgv(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)
+            END DO
+         END DO
+
+         DO ji=1,jpi
+            IF (vmask(ji,2,1).NE.0.) THEN
+               spgv(ji,2)=spgv(ji,2)/hv(ji,2)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,2,jk)=0.25*(va(ji,1,jk)+2.*va(ji,2,jk)+va(ji,3,jk))
+               va(ji,2,jk)=va(ji,2,jk)*vmask(ji,2,jk)
+            END DO
+         END DO
+
+         spgv1(:,2)=0.
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               spgv1(ji,2)=spgv1(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)*vmask(ji,2,jk)
+            END DO
+         END DO
+
+         DO ji=1,jpi
+            IF (vmask(ji,2,1).NE.0.) THEN
+               spgv1(ji,2)=spgv1(ji,2)/hv(ji,2)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,2,jk) = (va(ji,2,jk)+spgv(ji,2)-spgv1(ji,2))*vmask(ji,2,jk)
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               ua(ji,2,jk) = (zua(ji,2,jk)/(rhoy*e2u(ji,2)))*umask(ji,2,jk) 
+#if ! defined key_zco
+               ua(ji,2,jk) = ua(ji,2,jk) / fse3u(ji,2,jk)
+#endif                
+            END DO
+         END DO
+
+         sshn(:,2)=sshn(:,3)
+         sshb(:,2)=sshb(:,3)
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+
+         DO ji=1,jpi
+            laplacv(ji,nlcj-2) = timeref * (zva2d(ji,nlcj-2)/(zrhox*e1v(ji,nlcj-2)))
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,nlcj-2:nlcj-1,jk) = (zva(ji,nlcj-2:nlcj-1,jk)/(zrhox*e1v(ji,nlcj-2:nlcj-1)))
+#if ! defined key_zco
+               va(ji,nlcj-2:nlcj-1,jk) = va(ji,nlcj-2:nlcj-1,jk) / fse3v(ji,nlcj-2:nlcj-1,jk)
+#endif
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)-z2dt * znugdt * laplacv(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+
+         spgv(:,nlcj-2)=0.
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               spgv(ji,nlcj-2)=spgv(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         DO ji=1,jpi
+            IF (vmask(ji,nlcj-2,1).NE.0.) THEN
+               spgv(ji,nlcj-2)=spgv(ji,nlcj-2)/hv(ji,nlcj-2)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,nlcj-2,jk)=0.25*(va(ji,nlcj-3,jk)+2.*va(ji,nlcj-2,jk)+va(ji,nlcj-1,jk))
+               va(ji,nlcj-2,jk) = va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         spgv1(:,nlcj-2)=0.
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         DO ji=1,jpi
+            IF (vmask(ji,nlcj-2,1).NE.0.) THEN
+               spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)/hv(ji,nlcj-2)
+            ENDIF
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)+spgv(ji,nlcj-2)-spgv1(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               ua(ji,nlcj-1,jk) = (zua(ji,nlcj-1,jk)/(rhoy*e2u(ji,nlcj-1)))*umask(ji,nlcj-1,jk)
+#if ! defined key_zco
+               ua(ji,nlcj-1,jk) = ua(ji,nlcj-1,jk) / fse3u(ji,nlcj-1,jk)
+#endif          
+            END DO
+         END DO
+
+         sshn(:,nlcj-1)=sshn(:,nlcj-2)
+         sshb(:,nlcj-1)=sshb(:,nlcj-2)                
+      ENDIF
+
+   END SUBROUTINE Agrif_dyn
+
+
+   SUBROUTINE interpu(tabres,i1,i2,j1,j2,k1,k2)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji,jj,jk
+      !!----------------------------------------------------------------------  
+
+      DO jk=k1,k2
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj,jk) = e2u(ji,jj) * un(ji,jj,jk)
+#if ! defined key_zco
+               tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3u(ji,jj,jk)
+#endif
+            END DO
+         END DO
+      END DO
+   END SUBROUTINE interpu
+
+
+   SUBROUTINE interpu2d(tabres,i1,i2,j1,j2)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu2d  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) :: i1,i2,j1,j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji,jj
+      !!----------------------------------------------------------------------  
+
+      DO jj=j1,j2
+         DO ji=i1,i2
+            tabres(ji,jj) = e2u(ji,jj) * ((gcx(ji+1,jj) - gcx(ji,jj))/e1u(ji,jj)) &
+               * umask(ji,jj,1)
+         END DO
+      END DO
+
+   END SUBROUTINE interpu2d
+
+
+   SUBROUTINE interpv(tabres,i1,i2,j1,j2,k1,k2)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpv  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji, jj, jk
+      !!----------------------------------------------------------------------  
+
+      DO jk=k1,k2
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj,jk) = e1v(ji,jj) * vn(ji,jj,jk)
+#if ! defined key_zco
+               tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3v(ji,jj,jk)
+#endif           
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE interpv
+
+
+   SUBROUTINE interpv2d(tabres,i1,i2,j1,j2)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interpu2d  ***
+      !!----------------------------------------------------------------------  
+      INTEGER, INTENT(in) :: i1,i2,j1,j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      !!
+      INTEGER :: ji,jj
+      !!----------------------------------------------------------------------  
+
+      DO jj=j1,j2
+         DO ji=i1,i2
+            tabres(ji,jj) = e1v(ji,jj) * ((gcx(ji,jj+1) - gcx(ji,jj))/e2v(ji,jj)) &
+               * vmask(ji,jj,1)
+         END DO
+      END DO
+
+   END SUBROUTINE interpv2d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Empty module                                          no AGRIF zoom
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE Agrif_OPA_Interp_empty
+      WRITE(*,*)  'agrif_opa_interp : You should not have seen this print! error?'
+   END SUBROUTINE Agrif_OPA_Interp_empty
+#endif
+
+   !!======================================================================
+END MODULE agrif_opa_interp
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 1844)
@@ -0,0 +1,428 @@
+#define SPONGE
+
+Module agrif_opa_sponge
+#if defined key_agrif  && ! defined key_off_tra
+   USE par_oce
+   USE oce
+   USE dom_oce
+   USE in_out_manager
+   USE agrif_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC Agrif_Sponge_Tra, Agrif_Sponge_Dyn, interptn, interpsn, interpun, interpvn
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+
+   SUBROUTINE Agrif_Sponge_Tra
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Sponge_Tra ***
+      !!---------------------------------------------
+#include "domzgr_substitute.h90"
+
+      INTEGER :: ji,jj,jk
+      INTEGER :: spongearea
+      REAL(wp) :: timecoeff
+      REAL(wp) :: zta, zsa, zabe1, zabe2, zbtr
+      REAL(wp), DIMENSION(jpi,jpj) :: localviscsponge
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: tbdiff, sbdiff
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztu ,ztv, zsu ,zsv
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  ztab
+
+#if defined SPONGE
+
+      timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      ztab = 0.e0
+      CALL Agrif_Bc_Variable(ztab, ta,calledweight=timecoeff,procname=interptn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      tbdiff(:,:,:) = tb(:,:,:) - ztab(:,:,:)
+
+      ztab = 0.e0
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      CALL Agrif_Bc_Variable(ztab, sa,calledweight=timecoeff,procname=interpsn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      sbdiff(:,:,:) = sb(:,:,:) - ztab(:,:,:)
+
+
+      spongearea = 2 + 2 * Agrif_irhox()
+
+      localviscsponge = 0.
+      
+      IF (.NOT. spongedoneT) THEN
+         spe1ur(:,:) = 0.
+         spe2vr(:,:) = 0.
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+         DO ji = 2, spongearea
+            localviscsponge(ji,:) = visc_tra * (spongearea-ji)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(2:spongearea-1,:)=0.5 * (localviscsponge(2:spongearea-1,:) + localviscsponge(3:spongearea,:)) &
+	       * e2u(2:spongearea-1,:) / e1u(2:spongearea-1,:)
+
+         spe2vr(2:spongearea,1:jpjm1) = 0.5 * (localviscsponge(2:spongearea,1:jpjm1) + &
+	          localviscsponge(2:spongearea,2:jpj)) &
+	        * e1v(2:spongearea,1:jpjm1) / e2v(2:spongearea,1:jpjm1)
+      ENDIF
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+         DO ji = nlci-spongearea + 1,nlci-1
+            localviscsponge(ji,:) = visc_tra * (ji - (nlci-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(nlci-spongearea + 1:nlci-2,:)=0.5 * (localviscsponge(nlci-spongearea + 1:nlci-2,:) + &
+	        localviscsponge(nlci-spongearea + 2:nlci-1,:)) &
+	       * e2u(nlci-spongearea + 1:nlci-2,:) / e1u(nlci-spongearea + 1:nlci-2,:)
+
+         spe2vr(nlci-spongearea + 1:nlci-1,1:jpjm1) = 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-1,1:jpjm1) &
+	           + localviscsponge(nlci-spongearea + 1:nlci-1,2:jpj)) &
+	        * e1v(nlci-spongearea + 1:nlci-1,1:jpjm1) / e2v(nlci-spongearea + 1:nlci-1,1:jpjm1)
+      ENDIF
+
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+         DO jj = 2, spongearea
+            localviscsponge(:,jj) = visc_tra * (spongearea-jj)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(1:jpim1,2:spongearea)=0.5 * (localviscsponge(1:jpim1,2:spongearea) + &
+	        localviscsponge(2:jpi,2:spongearea)) &
+	       * e2u(1:jpim1,2:spongearea) / e1u(1:jpim1,2:spongearea)
+
+         spe2vr(:,2:spongearea-1) = 0.5 * (localviscsponge(:,2:spongearea-1) + &
+	          localviscsponge(:,3:spongearea)) &
+	        * e1v(:,2:spongearea-1) / e2v(:,2:spongearea-1)
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+         DO jj = nlcj-spongearea + 1,nlcj-1
+            localviscsponge(:,jj) = visc_tra * (jj - (nlcj-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(1:jpim1,nlcj-spongearea + 1:nlcj-1)=0.5 * (localviscsponge(1:jpim1,nlcj-spongearea + 1:nlcj-1) + &
+	         localviscsponge(2:jpi,nlcj-spongearea + 1:nlcj-1)) &
+	       * e2u(1:jpim1,nlcj-spongearea + 1:nlcj-1) / e1u(1:jpim1,nlcj-spongearea + 1:nlcj-1)
+
+         spe2vr(:,nlcj-spongearea + 1:nlcj-2) = 0.5 * (localviscsponge(:,nlcj-spongearea + 1:nlcj-2) + &
+	         localviscsponge(:,nlcj-spongearea + 2:nlcj-1)) &
+	        * e1v(:,nlcj-spongearea + 1:nlcj-2) / e2v(:,nlcj-spongearea + 1:nlcj-2)
+      ENDIF
+      
+         spbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:))
+
+         spongedoneT = .TRUE.
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#if defined key_zco
+               zabe1 = umask(ji,jj,jk) * spe1ur(ji,jj)
+               zabe2 = vmask(ji,jj,jk) * spe2vr(ji,jj)
+#else
+               zabe1 = umask(ji,jj,jk) * spe1ur(ji,jj) * fse3u(ji,jj,jk)
+               zabe2 = vmask(ji,jj,jk) * spe2vr(ji,jj) * fse3v(ji,jj,jk)
+#endif
+               ztu(ji,jj,jk) = zabe1 * ( tbdiff(ji+1,jj  ,jk) - tbdiff(ji,jj,jk) )
+               zsu(ji,jj,jk) = zabe1 * ( sbdiff(ji+1,jj  ,jk) - sbdiff(ji,jj,jk) )
+               ztv(ji,jj,jk) = zabe2 * ( tbdiff(ji  ,jj+1,jk) - tbdiff(ji,jj,jk) )
+               zsv(ji,jj,jk) = zabe2 * ( sbdiff(ji  ,jj+1,jk) - sbdiff(ji,jj,jk) )
+            ENDDO
+         ENDDO
+
+         DO jj = 2,jpjm1
+            DO ji = 2,jpim1
+#if defined key_zco
+               zbtr = spbtr2(ji,jj)
+#else
+               zbtr = spbtr2(ji,jj) / fse3t(ji,jj,jk)
+#endif
+               ! horizontal diffusive trends
+               zta = zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)   &
+                  &          + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               zsa = zbtr * (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk)   &
+                  &          + zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = (ta(ji,jj,jk) + zta)
+               sa(ji,jj,jk) = (sa(ji,jj,jk) + zsa)
+            END DO
+         END DO
+
+      ENDDO
+
+#endif
+
+   END SUBROUTINE Agrif_Sponge_Tra
+
+   SUBROUTINE Agrif_Sponge_dyn
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Sponge_dyn ***
+      !!---------------------------------------------
+#include "domzgr_substitute.h90"
+
+      INTEGER :: ji,jj,jk
+      INTEGER :: spongearea
+      REAL(wp) :: timecoeff
+      REAL(wp) :: ze2u, ze1v, zua, zva, zbtr
+      REAL(wp), DIMENSION(jpi,jpj) :: localviscsponge
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztab, ubdiff, vbdiff,rotdiff,hdivdiff
+
+#if defined SPONGE
+
+      timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = ln_spc_dyn
+      ztab = 0.e0
+      CALL Agrif_Bc_Variable(ztab, ua,calledweight=timecoeff,procname=interpun)
+      Agrif_UseSpecialValue = .FALSE.
+
+      ubdiff(:,:,:) = (ub(:,:,:) - ztab(:,:,:))*umask(:,:,:)
+
+      ztab = 0.e0
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = ln_spc_dyn
+      CALL Agrif_Bc_Variable(ztab, va,calledweight=timecoeff,procname=interpvn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      vbdiff(:,:,:) = (vb(:,:,:) - ztab(:,:,:))*vmask(:,:,:)
+
+      spongearea = 2 + 2 * Agrif_irhox()
+
+      localviscsponge = 0.
+
+      IF (.NOT. spongedoneU) THEN
+         spe1ur2(:,:) = 0.
+         spe2vr2(:,:) = 0.
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+         DO ji = 2, spongearea
+            localviscsponge(ji,:) = visc_dyn * (spongearea-ji)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur2(2:spongearea-1,:)=0.5 * (localviscsponge(2:spongearea-1,:) + localviscsponge(3:spongearea,:))
+
+         spe2vr2(2:spongearea,1:jpjm1) = 0.5 * (localviscsponge(2:spongearea,1:jpjm1) + &
+	          localviscsponge(2:spongearea,2:jpj))
+      ENDIF
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+         DO ji = nlci-spongearea + 1,nlci-1
+            localviscsponge(ji,:) = visc_dyn * (ji - (nlci-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur2(nlci-spongearea + 1:nlci-2,:)=0.5 * (localviscsponge(nlci-spongearea + 1:nlci-2,:) + &
+	        localviscsponge(nlci-spongearea + 2:nlci-1,:))
+
+         spe2vr2(nlci-spongearea + 1:nlci-1,1:jpjm1) = 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-1,1:jpjm1) &
+	           + localviscsponge(nlci-spongearea + 1:nlci-1,2:jpj))
+      ENDIF
+
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+         DO jj = 2, spongearea
+            localviscsponge(:,jj) = visc_dyn * (spongearea-jj)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur2(1:jpim1,2:spongearea)=0.5 * (localviscsponge(1:jpim1,2:spongearea) + &
+	        localviscsponge(2:jpi,2:spongearea))
+
+         spe2vr2(:,2:spongearea-1) = 0.5 * (localviscsponge(:,2:spongearea-1) + &
+	          localviscsponge(:,3:spongearea))
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+         DO jj = nlcj-spongearea + 1,nlcj-1
+            localviscsponge(:,jj) = visc_dyn * (jj - (nlcj-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur2(1:jpim1,nlcj-spongearea + 1:nlcj-1)=0.5 * (localviscsponge(1:jpim1,nlcj-spongearea + 1:nlcj-1) + &
+	         localviscsponge(2:jpi,nlcj-spongearea + 1:nlcj-1))
+
+         spe2vr2(:,nlcj-spongearea + 1:nlcj-2) = 0.5 * (localviscsponge(:,nlcj-spongearea + 1:nlcj-2) + &
+	         localviscsponge(:,nlcj-spongearea + 2:nlcj-1))
+      ENDIF
+
+         spongedoneU = .TRUE.
+	 
+	 spbtr3(:,:) = 1./( e1f(:,:) * e2f(:,:))
+      ENDIF
+      
+      IF (.NOT. spongedoneT) THEN
+        spbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:))      
+      ENDIF
+      
+      DO jk=1,jpkm1
+      ubdiff(:,:,jk) = ubdiff(:,:,jk) * spe1ur2(:,:)
+      vbdiff(:,:,jk) = vbdiff(:,:,jk) * spe2vr2(:,:)
+      ENDDO
+      
+      hdivdiff = 0.
+      rotdiff = 0.
+
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         !                                             ! --------
+         ! Horizontal divergence                       !   div
+         !                                             ! --------
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! vector opt.
+#if defined key_zco
+               zbtr = spbtr2(ji,jj)
+               hdivdiff(ji,jj,jk) = (  e2u(ji,jj) * ubdiff(ji,jj,jk) &
+                  - e2u(ji-1,jj  ) * ubdiff(ji-1,jj  ,jk)      &
+                  &               + e1v(ji,jj) * vbdiff(ji,jj,jk) - &
+                  &              e1v(ji  ,jj-1) * vbdiff(ji  ,jj-1,jk)  ) * zbtr
+#else
+               zbtr = spbtr2(ji,jj) / fse3t(ji,jj,jk)
+               hdivdiff(ji,jj,jk) =   &
+                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * & 
+                  ubdiff(ji,jj,jk) - e2u(ji-1,jj  )* &
+                  fse3u(ji-1,jj  ,jk)  * ubdiff(ji-1,jj  ,jk)       &
+                  + e1v(ji,jj)*fse3v(ji,jj,jk) * &
+                  vbdiff(ji,jj,jk) - e1v(ji  ,jj-1)* &
+                  fse3v(ji  ,jj-1,jk)  * vbdiff(ji  ,jj-1,jk)  ) * zbtr
+#endif
+            END DO
+         END DO
+
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1   ! vector opt.
+#if defined key_zco	    
+               zbtr = spbtr3(ji,jj)
+               rotdiff(ji,jj,jk) = (  e2v(ji+1,jj  ) * vbdiff(ji+1,jj  ,jk) - e2v(ji,jj) * vbdiff(ji,jj,jk)    &
+                  &              - e1u(ji  ,jj+1) * ubdiff(ji  ,jj+1,jk) + e1u(ji,jj) * ubdiff(ji,jj,jk)  ) &
+                  &           * fmask(ji,jj,jk) * zbtr
+#else
+               zbtr = spbtr3(ji,jj) * fse3f(ji,jj,jk)
+               rotdiff(ji,jj,jk) = (  e2v(ji+1,jj  ) * vbdiff(ji+1,jj  ,jk) - e2v(ji,jj) * vbdiff(ji,jj,jk)    &
+                  &              - e1u(ji  ,jj+1) * ubdiff(ji  ,jj+1,jk) + e1u(ji,jj) * ubdiff(ji,jj,jk)  ) &
+                  &           * fmask(ji,jj,jk) * zbtr
+#endif		  
+            END DO
+         END DO
+
+      ENDDO
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! vector opt.
+#if defined key_zco
+               ! horizontal diffusive trends
+               ze2u = rotdiff (ji,jj,jk)
+               ze1v = hdivdiff(ji,jj,jk)
+               zua = - (                ze2u                  - &
+                  rotdiff (ji,jj-1,jk) ) / e2u(ji,jj)   &
+                  + ( hdivdiff(ji+1,jj,jk) -     &
+                  ze1v                  ) / e1u(ji,jj)
+
+               zva = + (                ze2u                  - &
+                  rotdiff (ji-1,jj,jk) ) / e1v(ji,jj)   &
+                  + ( hdivdiff(ji,jj+1,jk) -       &
+                  ze1v                  ) / e2v(ji,jj)
+#else
+               ze2u = rotdiff (ji,jj,jk)
+               ze1v = hdivdiff(ji,jj,jk)
+               ! horizontal diffusive trends
+               zua = - ( ze2u - rotdiff (ji,jj-1,jk)) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
+                  + ( hdivdiff(ji+1,jj,jk) - ze1v      &
+                  ) / e1u(ji,jj)
+
+               zva = + ( ze2u - rotdiff (ji-1,jj,jk)) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
+                  + ( hdivdiff(ji,jj+1,jk) - ze1v    &
+                  ) / e2v(ji,jj)
+#endif
+
+               ! add it to the general momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zva
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+#endif
+
+   END SUBROUTINE Agrif_Sponge_dyn
+
+   SUBROUTINE interptn(tabres,i1,i2,j1,j2,k1,k2)
+      !!---------------------------------------------
+      !!   *** ROUTINE interptn ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"       
+      
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+
+      tabres(i1:i2,j1:j2,k1:k2) = tn(i1:i2,j1:j2,k1:k2)
+
+   END SUBROUTINE interptn
+
+   SUBROUTINE interpsn(tabres,i1,i2,j1,j2,k1,k2)
+      !!---------------------------------------------
+      !!   *** ROUTINE interpsn ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"       
+      
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+
+      tabres(i1:i2,j1:j2,k1:k2) = sn(i1:i2,j1:j2,k1:k2)
+
+   END SUBROUTINE interpsn
+
+   SUBROUTINE interpun(tabres,i1,i2,j1,j2,k1,k2)
+      !!---------------------------------------------
+      !!   *** ROUTINE interpun ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"       
+      
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+
+      tabres(i1:i2,j1:j2,k1:k2) = un(i1:i2,j1:j2,k1:k2)
+
+   END SUBROUTINE interpun
+
+   SUBROUTINE interpvn(tabres,i1,i2,j1,j2,k1,k2)
+      !!---------------------------------------------
+      !!   *** ROUTINE interpvn ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"       
+      
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+
+      tabres(i1:i2,j1:j2,k1:k2) = vn(i1:i2,j1:j2,k1:k2)
+
+   END SUBROUTINE interpvn
+
+#else
+CONTAINS
+
+   SUBROUTINE agrif_opa_sponge_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_OPA_sponge_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_opa_sponge : You should not have seen this print! error?'
+   END SUBROUTINE agrif_opa_sponge_empty
+#endif
+
+END MODULE agrif_opa_sponge
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_update.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_update.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_opa_update.F90	(revision 1844)
@@ -0,0 +1,407 @@
+#define TWO_WAY
+
+MODULE agrif_opa_update
+#if defined key_agrif  && ! defined key_off_tra
+   USE par_oce
+   USE oce
+   USE dom_oce
+   USE agrif_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC Agrif_Update_Tra, Agrif_Update_Dyn
+
+   INTEGER, PUBLIC :: nbcline = 0
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE Agrif_Update_Tra( kt )
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Update_Tra ***
+      !!---------------------------------------------
+      INTEGER, INTENT(in) :: kt
+
+      REAL :: ztab(jpi,jpj,jpk)
+
+      IF((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) RETURN
+#if defined TWO_WAY
+      Agrif_UseSpecialValueInUpdate = .TRUE.
+      Agrif_SpecialValueFineGrid = 0.
+
+      IF (MOD(nbcline,nbclineupdate) == 0) THEN
+         CALL Agrif_Update_Variable(ztab,tn, procname=updateT)
+         CALL Agrif_Update_Variable(ztab,sn, procname=updateS)
+      ELSE
+         CALL Agrif_Update_Variable(ztab,tn,locupdate=(/0,2/), procname=updateT)
+         CALL Agrif_Update_Variable(ztab,sn,locupdate=(/0,2/), procname=updateS)
+      ENDIF
+
+      Agrif_UseSpecialValueInUpdate = .FALSE.
+#endif
+
+   END SUBROUTINE Agrif_Update_Tra
+
+   SUBROUTINE Agrif_Update_Dyn( kt )
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Update_Dyn ***
+      !!---------------------------------------------
+      INTEGER, INTENT(in) :: kt
+
+      REAL(wp), DIMENSION(jpi,jpj) :: ztab2d
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztab
+
+      IF ((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) Return
+#if defined TWO_WAY
+
+      IF (mod(nbcline,nbclineupdate) == 0) THEN
+         CALL Agrif_Update_Variable(ztab,un,procname = updateU)
+         CALL Agrif_Update_Variable(ztab,vn,procname = updateV)
+      ELSE
+         CALL Agrif_Update_Variable(ztab,un,locupdate=(/0,1/),procname = updateU)
+         CALL Agrif_Update_Variable(ztab,vn,locupdate=(/0,1/),procname = updateV)         
+      ENDIF
+
+      CALL Agrif_Update_Variable(ztab2d,e1u,procname = updateU2d)
+      CALL Agrif_Update_Variable(ztab2d,e2v,procname = updateV2d)  
+
+      nbcline = nbcline + 1
+
+      Agrif_UseSpecialValueInUpdate = ln_spc_dyn
+      Agrif_SpecialValueFineGrid = 0.
+      CALL Agrif_Update_Variable(ztab2d,sshn,procname = updateSSH)
+      Agrif_UseSpecialValueInUpdate = .FALSE.
+
+
+!Done in step
+!      CALL Agrif_ChildGrid_To_ParentGrid()
+!      CALL recompute_diags( kt )
+!      CALL Agrif_ParentGrid_To_ChildGrid()
+
+#endif
+
+   END SUBROUTINE Agrif_Update_Dyn
+
+   SUBROUTINE recompute_diags( kt )
+      !!---------------------------------------------
+      !!   *** ROUTINE recompute_diags ***
+      !!---------------------------------------------
+      USE divcur
+      USE sshwzv
+      USE cla_div
+
+      INTEGER, INTENT(in) :: kt
+
+      ta = hdivb
+      sa = rotb
+      Call div_cur(kt)
+
+      hdivb = ta
+      rotb  = sa
+
+      IF( n_cla == 1 ) CALL div_cla( kt )
+!      CALL wzv( kt )
+
+   END SUBROUTINE recompute_diags
+
+   SUBROUTINE updateT( tabres, i1, i2, j1, j2, k1, k2, before )
+      !!---------------------------------------------
+      !!           *** ROUTINE updateT ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+      LOGICAL, iNTENT(in) :: before
+
+      INTEGER :: ji,jj,jk
+
+      IF (before) THEN
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj,jk) = tn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ELSE
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  IF( tabres(ji,jj,jk) .NE. 0. ) THEN
+                     tn(ji,jj,jk) = tabres(ji,jj,jk) * tmask(ji,jj,jk)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updateT
+
+   SUBROUTINE updateS( tabres, i1, i2, j1, j2, k1, k2, before )
+      !!---------------------------------------------
+      !!           *** ROUTINE updateS ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2
+      REAL(wp),DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+      LOGICAL, iNTENT(in) :: before
+
+      INTEGER :: ji,jj,jk
+
+      IF (before) THEN
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj,jk) = sn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ELSE
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  IF (tabres(ji,jj,jk).NE.0.) THEN
+                     sn(ji,jj,jk) = tabres(ji,jj,jk) * tmask(ji,jj,jk)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updateS
+
+   SUBROUTINE updateu( tabres, i1, i2, j1, j2, k1, k2, before )
+      !!---------------------------------------------
+      !!           *** ROUTINE updateu ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1, i2, j1, j2, k1, k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+
+      INTEGER :: ji, jj, jk
+      REAL(wp) :: zrhoy
+
+      IF (before) THEN
+         zrhoy = Agrif_Rhoy()
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj,jk) = e2u(ji,jj) * un(ji,jj,jk)
+#if ! defined key_zco
+                  tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3u(ji,jj,jk)
+#endif
+               END DO
+            END DO
+         END DO
+         tabres = zrhoy * tabres
+      ELSE
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  un(ji,jj,jk) = tabres(ji,jj,jk) / (e2u(ji,jj))
+                  un(ji,jj,jk) = un(ji,jj,jk) * umask(ji,jj,jk)
+#if ! defined key_zco
+                  un(ji,jj,jk) = un(ji,jj,jk) / fse3u(ji,jj,jk)
+#endif
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updateu
+
+   SUBROUTINE updatev( tabres, i1, i2, j1, j2, k1, k2, before )
+      !!---------------------------------------------
+      !!           *** ROUTINE updatev ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER :: i1,i2,j1,j2,k1,k2
+      INTEGER :: ji,jj,jk
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2) :: tabres
+      LOGICAL :: before
+
+      REAL(wp) :: zrhox
+
+      IF (before) THEN
+         zrhox = Agrif_Rhox()
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj,jk) = e1v(ji,jj) * vn(ji,jj,jk)
+#if ! defined key_zco
+                  tabres(ji,jj,jk) = tabres(ji,jj,jk) * fse3v(ji,jj,jk)
+#endif
+               END DO
+            END DO
+         END DO
+         tabres = zrhox * tabres
+      ELSE
+         DO jk=k1,k2
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  vn(ji,jj,jk) = tabres(ji,jj,jk) / (e1v(ji,jj))
+                  vn(ji,jj,jk) = vn(ji,jj,jk) * vmask(ji,jj,jk)
+#if ! defined key_zco
+                  vn(ji,jj,jk) = vn(ji,jj,jk) / fse3v(ji,jj,jk)
+#endif
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updatev
+
+   SUBROUTINE updateu2d( tabres, i1, i2, j1, j2, before )
+      !!---------------------------------------------
+      !!          *** ROUTINE updateu2d ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+
+      INTEGER :: ji, jj, jk
+      REAL(wp) :: zrhoy
+      REAL(wp) :: zhinv
+
+      IF (before) THEN
+         zrhoy = Agrif_Rhoy()
+         DO jk = 1,jpkm1
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj) = tabres(ji,jj) + fse3u(ji,jj,jk) * un(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj) = tabres(ji,jj) * e2u(ji,jj)
+            END DO
+         END DO
+         tabres = zrhoy * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               IF(umask(ji,jj,1) .NE. 0.) THEN             
+                  spgu(ji,jj) = 0.e0
+                  DO jk=1,jpk
+                     spgu(ji,jj) = spgu(ji,jj) + fse3u(ji,jj,jk) * un(ji,jj,jk)
+                  END DO
+                  spgu(ji,jj) = spgu(ji,jj) * e2u(ji,jj)
+                  zhinv = (tabres(ji,jj)-spgu(ji,jj))/(hu(ji,jj)*e2u(ji,jj))
+                  Do jk=1,jpk              
+                     un(ji,jj,jk) = un(ji,jj,jk) + zhinv
+                     un(ji,jj,jk) = un(ji,jj,jk) * umask(ji,jj,jk)            
+                  END DO
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updateu2d
+
+   SUBROUTINE updatev2d( tabres, i1, i2, j1, j2, before )
+      !!---------------------------------------------
+      !!          *** ROUTINE updatev2d ***
+      !!---------------------------------------------
+
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+
+      INTEGER :: ji, jj, jk
+      REAL(wp) :: zrhox
+      REAL(wp) :: zhinv
+
+      IF (before) THEN
+         zrhox = Agrif_Rhox()
+         tabres = 0.e0
+         DO jk = 1,jpkm1
+            DO jj=j1,j2
+               DO ji=i1,i2
+                  tabres(ji,jj) = tabres(ji,jj) + fse3v(ji,jj,jk) * vn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj) = tabres(ji,jj) * e1v(ji,jj)
+            END DO
+         END DO
+         tabres = zrhox * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               IF(vmask(ji,jj,1) .NE. 0.) THEN             
+                  spgv(ji,jj) = 0.
+                  DO jk=1,jpk
+                     spgv(ji,jj) = spgv(ji,jj) + fse3v(ji,jj,jk) * vn(ji,jj,jk)
+                  END DO
+                  spgv(ji,jj) = spgv(ji,jj) * e1v(ji,jj)
+                  zhinv = (tabres(ji,jj)-spgv(ji,jj))/(hv(ji,jj)*e1v(ji,jj))
+                  DO jk=1,jpk             
+                     vn(ji,jj,jk) = vn(ji,jj,jk) + zhinv
+                     vn(ji,jj,jk) = vn(ji,jj,jk) * vmask(ji,jj,jk)
+                  END DO
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updatev2d
+
+   SUBROUTINE updateSSH( tabres, i1, i2, j1, j2, before )
+      !!---------------------------------------------
+      !!          *** ROUTINE updateSSH ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1, i2, j1, j2
+      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+
+      INTEGER :: ji, jj
+      REAL(wp) :: zrhox, zrhoy
+
+      IF (before) THEN
+         zrhox = Agrif_Rhox()
+         zrhoy = Agrif_Rhoy()
+         DO jj=j1,j2
+            DO ji=i1,i2
+               tabres(ji,jj) = e1t(ji,jj) * e2t(ji,jj) * sshn(ji,jj)
+            END DO
+         END DO
+         tabres = zrhox * zrhoy * tabres
+      ELSE
+         DO jj=j1,j2
+            DO ji=i1,i2
+               sshn(ji,jj) = tabres(ji,jj) / (e1t(ji,jj) * e2t(ji,jj))
+               sshn(ji,jj) = sshn(ji,jj) * tmask(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE updateSSH
+
+#else
+CONTAINS
+   SUBROUTINE agrif_opa_update_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_opa_update_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_opa_update : You should not have seen this print! error?'
+   END SUBROUTINE agrif_opa_update_empty
+#endif
+END MODULE agrif_opa_update
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_interp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_interp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_interp.F90	(revision 1844)
@@ -0,0 +1,144 @@
+MODULE agrif_top_interp
+#if defined key_agrif && defined key_top
+   USE par_oce
+   USE oce
+   USE dom_oce      
+   USE sol_oce
+   USE agrif_oce
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC Agrif_trc
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+
+   SUBROUTINE Agrif_trc
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_trc ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"  
+#  include "vectopt_loop_substitute.h90"
+      
+      INTEGER :: ji,jj,jk,jn
+      REAL(wp) :: zrhox
+      REAL(wp) :: alpha1, alpha2, alpha3, alpha4
+      REAL(wp) :: alpha5, alpha6, alpha7
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) :: ztra
+      
+      IF (Agrif_Root()) RETURN
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      ztra = 0.e0
+
+      CALL Agrif_Bc_variable(ztra,trn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      zrhox = Agrif_Rhox()
+
+      alpha1 = (zrhox-1.)/2.
+      alpha2 = 1.-alpha1
+
+      alpha3 = (zrhox-1)/(zrhox+1)
+      alpha4 = 1.-alpha3
+
+      alpha6 = 2.*(zrhox-1.)/(zrhox+1.)
+      alpha7 = -(zrhox-1)/(zrhox+3)
+      alpha5 = 1. - alpha6 - alpha7
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+         tra(nlci,:,:,:) = alpha1 * ztra(nlci,:,:,:) + alpha2 * ztra(nlci-1,:,:,:)
+         DO jn=1,jptra 
+            DO jk=1,jpk      
+               DO jj=1,jpj
+                  IF (umask(nlci-2,jj,jk).EQ.0.) THEN
+                     tra(nlci-1,jj,jk,jn) = tra(nlci,jj,jk,jn) * tmask(nlci-1,jj,jk)
+                  ELSE
+                     tra(nlci-1,jj,jk,jn)=(alpha4*tra(nlci,jj,jk,jn)+alpha3*tra(nlci-2,jj,jk,jn))*tmask(nlci-1,jj,jk)
+                     IF (un(nlci-2,jj,jk).GT.0.) THEN
+                        tra(nlci-1,jj,jk,jn)=(alpha6*tra(nlci-2,jj,jk,jn)+alpha5*tra(nlci,jj,jk,jn) &
+                           +alpha7*tra(nlci-3,jj,jk,jn))*tmask(nlci-1,jj,jk)
+                     ENDIF
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+         tra(:,nlcj,:,:) = alpha1 * ztra(:,nlcj,:,:) + alpha2 * ztra(:,nlcj-1,:,:)
+         DO jn=1, jptra            
+            DO jk=1,jpk      
+               DO ji=1,jpi
+                  IF (vmask(ji,nlcj-2,jk).EQ.0.) THEN
+                     tra(ji,nlcj-1,jk,jn) = tra(ji,nlcj,jk,jn) * tmask(ji,nlcj-1,jk)
+                  ELSE
+                     tra(ji,nlcj-1,jk,jn)=(alpha4*tra(ji,nlcj,jk,jn)+alpha3*tra(ji,nlcj-2,jk,jn))*tmask(ji,nlcj-1,jk)        
+                     IF (vn(ji,nlcj-2,jk) .GT. 0.) THEN
+                        tra(ji,nlcj-1,jk,jn)=(alpha6*tra(ji,nlcj-2,jk,jn)+alpha5*tra(ji,nlcj,jk,jn) &
+                           +alpha7*tra(ji,nlcj-3,jk,jn))*tmask(ji,nlcj-1,jk)
+                     ENDIF
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+         tra(1,:,:,:) = alpha1 * ztra(1,:,:,:) + alpha2 * ztra(2,:,:,:)
+         DO jn=1, jptra
+            DO jk=1,jpk      
+               DO jj=1,jpj
+                  IF (umask(2,jj,jk).EQ.0.) THEN
+                     tra(2,jj,jk,jn) = tra(1,jj,jk,jn) * tmask(2,jj,jk)
+                  ELSE
+                     tra(2,jj,jk,jn)=(alpha4*tra(1,jj,jk,jn)+alpha3*tra(3,jj,jk,jn))*tmask(2,jj,jk)        
+                     IF (un(2,jj,jk).LT.0.) THEN
+                        tra(2,jj,jk,jn)=(alpha6*tra(3,jj,jk,jn)+alpha5*tra(1,jj,jk,jn) &
+                           +alpha7*tra(4,jj,jk,jn))*tmask(2,jj,jk)
+                     ENDIF
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+         tra(:,1,:,:) = alpha1 * ztra(:,1,:,:) + alpha2 * ztra(:,2,:,:)
+         DO jn=1, jptra  
+            DO jk=1,jpk      
+               DO ji=1,jpi
+                  IF (vmask(ji,2,jk).EQ.0.) THEN
+                     tra(ji,2,jk,jn)=tra(ji,1,jk,jn) * tmask(ji,2,jk)
+                  ELSE
+                     tra(ji,2,jk,jn)=(alpha4*tra(ji,1,jk,jn)+alpha3*tra(ji,3,jk,jn))*tmask(ji,2,jk)
+                     IF (vn(ji,2,jk) .LT. 0.) THEN
+                        tra(ji,2,jk,jn)=(alpha6*tra(ji,3,jk,jn)+alpha5*tra(ji,1,jk,jn)&
+                           +alpha7*tra(ji,4,jk,jn))*tmask(ji,2,jk)
+                     ENDIF
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+   END SUBROUTINE Agrif_trc
+
+#else
+CONTAINS
+   SUBROUTINE Agrif_TOP_Interp_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_Top_Interp_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_top_interp : You should not have seen this print! error?'
+   END SUBROUTINE Agrif_TOP_Interp_empty
+#endif
+END MODULE agrif_top_interp
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_sponge.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_sponge.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_sponge.F90	(revision 1844)
@@ -0,0 +1,183 @@
+#define SPONGE_TOP
+
+Module agrif_top_sponge
+#if defined key_agrif && defined key_top
+   USE par_oce
+   USE oce
+   USE dom_oce
+   USE in_out_manager
+   USE agrif_oce
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC Agrif_Sponge_Trc, interptrn
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id: agrif_opa_sponge.F90 1156 2008-06-26 16:06:45Z rblod $
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+
+   SUBROUTINE Agrif_Sponge_Trc
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Sponge_Trc ***
+      !!---------------------------------------------
+#include "domzgr_substitute.h90"
+
+      INTEGER :: ji,jj,jk,jl
+      INTEGER :: spongearea
+      REAL(wp) :: timecoeff
+      REAL(wp) :: ztra, zabe1, zabe2, zbtr
+      REAL(wp), DIMENSION(jpi,jpj) :: localviscsponge
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) :: trbdiff
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) :: ztru ,ztrv
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::  ztab
+
+#if defined SPONGE_TOP
+
+      timecoeff = REAL(Agrif_NbStepint(),wp)/Agrif_rhot()
+
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      ztab = 0.e0
+      CALL Agrif_Bc_Variable(ztab, tra,calledweight=timecoeff,procname=interptrn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      trbdiff(:,:,:,:) = trb(:,:,:,:) - ztab(:,:,:,:)
+
+      spongearea = 2 + 2 * Agrif_irhox()
+
+      localviscsponge = 0.
+      
+      IF (.NOT. spongedoneT) THEN
+         spe1ur(:,:) = 0.
+         spe2vr(:,:) = 0.
+
+      IF ((nbondi == -1).OR.(nbondi == 2)) THEN
+         DO ji = 2, spongearea
+            localviscsponge(ji,:) = visc_tra * (spongearea-ji)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(2:spongearea-1,:)=0.5 * (localviscsponge(2:spongearea-1,:) + localviscsponge(3:spongearea,:)) &
+	       * e2u(2:spongearea-1,:) / e1u(2:spongearea-1,:)
+
+         spe2vr(2:spongearea,1:jpjm1) = 0.5 * (localviscsponge(2:spongearea,1:jpjm1) + &
+	          localviscsponge(2:spongearea,2:jpj)) &
+	        * e1v(2:spongearea,1:jpjm1) / e2v(2:spongearea,1:jpjm1)
+      ENDIF
+
+      IF ((nbondi == 1).OR.(nbondi == 2)) THEN
+         DO ji = nlci-spongearea + 1,nlci-1
+            localviscsponge(ji,:) = visc_tra * (ji - (nlci-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(nlci-spongearea + 1:nlci-2,:)=0.5 * (localviscsponge(nlci-spongearea + 1:nlci-2,:) + &
+	        localviscsponge(nlci-spongearea + 2:nlci-1,:)) &
+	       * e2u(nlci-spongearea + 1:nlci-2,:) / e1u(nlci-spongearea + 1:nlci-2,:)
+
+         spe2vr(nlci-spongearea + 1:nlci-1,1:jpjm1) = 0.5 * (localviscsponge(nlci-spongearea + 1:nlci-1,1:jpjm1) &
+	           + localviscsponge(nlci-spongearea + 1:nlci-1,2:jpj)) &
+	        * e1v(nlci-spongearea + 1:nlci-1,1:jpjm1) / e2v(nlci-spongearea + 1:nlci-1,1:jpjm1)
+      ENDIF
+
+
+      IF ((nbondj == -1).OR.(nbondj == 2)) THEN
+         DO jj = 2, spongearea
+            localviscsponge(:,jj) = visc_tra * (spongearea-jj)/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(1:jpim1,2:spongearea)=0.5 * (localviscsponge(1:jpim1,2:spongearea) + &
+	        localviscsponge(2:jpi,2:spongearea)) &
+	       * e2u(1:jpim1,2:spongearea) / e1u(1:jpim1,2:spongearea)
+
+         spe2vr(:,2:spongearea-1) = 0.5 * (localviscsponge(:,2:spongearea-1) + &
+	          localviscsponge(:,3:spongearea)) &
+	        * e1v(:,2:spongearea-1) / e2v(:,2:spongearea-1)
+      ENDIF
+
+      IF ((nbondj == 1).OR.(nbondj == 2)) THEN
+         DO jj = nlcj-spongearea + 1,nlcj-1
+            localviscsponge(:,jj) = visc_tra * (jj - (nlcj-spongearea+1))/real(spongearea-2)
+         ENDDO
+	 
+	 spe1ur(1:jpim1,nlcj-spongearea + 1:nlcj-1)=0.5 * (localviscsponge(1:jpim1,nlcj-spongearea + 1:nlcj-1) + &
+	         localviscsponge(2:jpi,nlcj-spongearea + 1:nlcj-1)) &
+	       * e2u(1:jpim1,nlcj-spongearea + 1:nlcj-1) / e1u(1:jpim1,nlcj-spongearea + 1:nlcj-1)
+
+         spe2vr(:,nlcj-spongearea + 1:nlcj-2) = 0.5 * (localviscsponge(:,nlcj-spongearea + 1:nlcj-2) + &
+	         localviscsponge(:,nlcj-spongearea + 2:nlcj-1)) &
+	        * e1v(:,nlcj-spongearea + 1:nlcj-2) / e2v(:,nlcj-spongearea + 1:nlcj-2)
+      ENDIF
+      
+         spbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:))
+
+         spongedoneT = .TRUE.
+      ENDIF
+
+      DO jl = 1, jptra
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#if defined key_zco
+               zabe1 = umask(ji,jj,jk) * spe1ur(ji,jj)
+               zabe2 = vmask(ji,jj,jk) * spe2vr(ji,jj)
+#else
+               zabe1 = umask(ji,jj,jk) * spe1ur(ji,jj) * fse3u(ji,jj,jk)
+               zabe2 = vmask(ji,jj,jk) * spe2vr(ji,jj) * fse3v(ji,jj,jk)
+#endif
+               ztru(ji,jj,jk,jl) = zabe1 * ( trbdiff(ji+1,jj  ,jk,jl) - trbdiff(ji,jj,jk,jl) )
+               ztrv(ji,jj,jk,jl) = zabe2 * ( trbdiff(ji  ,jj+1,jk,jl) - trbdiff(ji,jj,jk,jl) )
+            ENDDO
+         ENDDO
+
+         DO jj = 2,jpjm1
+            DO ji = 2,jpim1
+#if defined key_zco
+               zbtr = spbtr2(ji,jj)
+#else
+               zbtr = spbtr2(ji,jj) / fse3t(ji,jj,jk)
+#endif
+               ! horizontal diffusive trends
+               ztra = zbtr * (  ztru(ji,jj,jk,jl) - ztru(ji-1,jj,jk,jl)   &
+                  &          + ztrv(ji,jj,jk,jl) - ztrv(ji,jj-1,jk,jl)  )
+               ! add it to the general tracer trends
+               tra(ji,jj,jk,jl) = (tra(ji,jj,jk,jl) + ztra)
+            END DO
+         END DO
+
+      ENDDO
+      ENDDO
+
+#endif
+
+   END SUBROUTINE Agrif_Sponge_Trc
+
+   SUBROUTINE interptrn(tabres,i1,i2,j1,j2,k1,k2,l1,l2)
+      !!---------------------------------------------
+      !!   *** ROUTINE interptn ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"       
+      
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,l1,l2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2,l1:l2), INTENT(inout) :: tabres
+
+      tabres(i1:i2,j1:j2,k1:k2,l1:l2) = trn(i1:i2,j1:j2,k1:k2,l1:l2)
+
+   END SUBROUTINE interptrn
+
+#else
+CONTAINS
+
+   SUBROUTINE agrif_top_sponge_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_top_sponge_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_top_sponge : You should not have seen this print! error?'
+   END SUBROUTINE agrif_top_sponge_empty
+#endif
+
+END MODULE agrif_top_sponge
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_update.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_update.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_top_update.F90	(revision 1844)
@@ -0,0 +1,100 @@
+#define TWO_WAY
+
+MODULE agrif_top_update
+
+#if defined key_agrif && defined key_top
+   USE par_oce
+   USE oce
+   USE dom_oce
+   USE agrif_oce
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC Agrif_Update_Trc
+
+   INTEGER, PUBLIC :: nbcline_trc = 0
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   CONTAINS
+
+   SUBROUTINE Agrif_Update_Trc( kt )
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif_Update_Trc ***
+      !!---------------------------------------------
+      INTEGER, INTENT(in) :: kt
+  
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) :: ztra
+
+      IF ((Agrif_NbStepint() .NE. (Agrif_irhot()-1)).AND.(kt /= 0)) RETURN
+
+#if defined TWO_WAY
+      Agrif_UseSpecialValueInUpdate = .TRUE.
+      Agrif_SpecialValueFineGrid = 0.
+ 
+     IF (MOD(nbcline_trc,nbclineupdate) == 0) THEN
+         CALL Agrif_Update_Variable(ztra,trn, procname=updateTRC)
+      ELSE
+         CALL Agrif_Update_Variable(ztra,trn,locupdate=(/0,2/), procname=updateTRC)
+      ENDIF
+
+      Agrif_UseSpecialValueInUpdate = .FALSE.
+      nbcline_trc = nbcline_trc + 1
+#endif
+
+   END SUBROUTINE Agrif_Update_Trc
+
+   SUBROUTINE updateTRC(tabres,i1,i2,j1,j2,k1,k2,l1,l2,before)
+      !!---------------------------------------------
+      !!   *** ROUTINE UpdateTrc ***
+      !!---------------------------------------------
+#  include "domzgr_substitute.h90"
+
+      INTEGER, INTENT(in) :: i1,i2,j1,j2,k1,k2,l1,l2
+      REAL, DIMENSION(i1:i2,j1:j2,k1:k2,l1:l2), INTENT(inout) :: tabres
+      LOGICAL, INTENT(in) :: before
+   
+      INTEGER :: ji,jj,jk,jl
+
+         IF (before) THEN
+            DO jl=l1,l2
+               DO jk=k1,k2
+                  DO jj=j1,j2
+                     DO ji=i1,i2
+                        tabres(ji,jj,jk,jl) = trn(ji,jj,jk,jl)
+                     ENDDO
+                  ENDDO
+               ENDDO
+            ENDDO
+         ELSE
+            DO jl=l1,l2
+               DO jk=k1,k2
+                  DO jj=j1,j2
+                     DO ji=i1,i2
+                        IF (tabres(ji,jj,jk,jl).NE.0.) THEN
+                           trn(ji,jj,jk,jl) = tabres(ji,jj,jk,jl) * tmask(ji,jj,jk)
+                        ENDIF
+                     ENDDO
+                  ENDDO
+               ENDDO
+            ENDDO
+         ENDIF
+
+   END SUBROUTINE updateTRC
+
+#else
+CONTAINS
+   SUBROUTINE agrif_top_update_empty
+      !!---------------------------------------------
+      !!   *** ROUTINE agrif_Top_update_empty ***
+      !!---------------------------------------------
+      WRITE(*,*)  'agrif_top_update : You should not have seen this print! error?'
+   END SUBROUTINE agrif_top_update_empty
+#endif
+END Module agrif_top_update
Index: /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_user.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/NST_SRC/agrif_user.F90	(revision 1844)
@@ -0,0 +1,536 @@
+#if defined key_agrif
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE Agrif_InitWorkspace
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitWorkspace ***
+      !!----------------------------------------------------------------------
+      USE par_oce
+      USE dom_oce
+      USE Agrif_Util
+      !!
+      IMPLICIT NONE
+      !!
+#if defined key_mpp_dyndist
+      CHARACTER(len=20) :: namelistname
+      INTEGER nummpp
+      NAMELIST/nammpp_dyndist/ jpni, jpnj, jpnij
+#endif
+      !!----------------------------------------------------------------------
+
+#if defined key_mpp_dyndist
+      ! MPP dynamical distribution : read the processor cutting in the namelist
+      IF( Agrif_Nbstepint() == 0 ) THEN
+        nummpp = Agrif_Get_Unit()
+        namelistname='namelist'
+        IF(.NOT. Agrif_Root() )   namelistname=TRIM(Agrif_CFixed())//'_namelist'
+        !
+        OPEN (nummpp,file=namelistname,status='OLD',form='formatted')
+        READ (nummpp,nammpp_dyndist)
+        CLOSE(nummpp)
+      ENDIF
+#endif
+
+      IF( .NOT. Agrif_Root() ) THEN
+         jpiglo  = nbcellsx + 2 + 2*nbghostcells
+         jpjglo  = nbcellsy + 2 + 2*nbghostcells
+         jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
+         jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
+         jpim1   = jpi-1
+         jpjm1   = jpj-1
+         jpkm1   = jpk-1                                        
+         jpij    = jpi*jpj
+         jpidta  = jpiglo
+         jpjdta  = jpjglo
+         jpizoom = 1
+         jpjzoom = 1
+         nperio  = 0
+         jperio  = 0
+      ENDIF
+      !
+   END SUBROUTINE Agrif_InitWorkspace
+
+#if ! defined key_off_tra
+
+   SUBROUTINE Agrif_InitValues
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues ***
+      !!
+      !! ** Purpose :: Declaration of variables to be interpolated
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE oce 
+      USE dom_oce
+      USE opa
+#if defined key_top
+      USE trc
+#endif
+#if defined key_tradmp   ||   defined key_esopa
+      USE tradmp
+#endif
+      USE sol_oce
+      USE in_out_manager
+      USE agrif_opa_update
+      USE agrif_opa_interp
+      USE agrif_opa_sponge
+      USE agrif_top_update
+      USE agrif_top_interp
+      USE agrif_top_sponge
+      !!
+      IMPLICIT NONE
+      !!
+      REAL(wp) :: tabtemp(jpi,jpj,jpk)
+#if defined key_top
+      REAL(wp) :: tabtrtemp(jpi,jpj,jpk,jptra)
+#endif 
+      LOGICAL check_namelist
+      !!----------------------------------------------------------------------
+
+      ! 0. Initializations
+      !-------------------
+#if defined key_orca_r025 || defined key_orca_r05 || defined key_orca_r2 || defined key_orca_r4
+      jp_cfg = -1    ! set special value for jp_cfg on fine grids
+      cp_cfg = "default"
+#endif
+
+      Call opa_init  ! Initializations of each fine grid
+      Call agrif_opa_init
+
+      ! Specific fine grid Initializations
+#if defined key_tradmp || defined key_esopa
+      ! no tracer damping on fine grids
+      lk_tradmp = .FALSE.
+#endif
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      Call Agrif_Set_type(un,(/1,2,0/),(/2,3,0/))
+      Call Agrif_Set_type(vn,(/2,1,0/),(/3,2,0/))
+
+      Call Agrif_Set_type(ua,(/1,2,0/),(/2,3,0/))
+      Call Agrif_Set_type(va,(/2,1,0/),(/3,2,0/))
+
+      Call Agrif_Set_type(e1u,(/1,2/),(/2,3/))
+      Call Agrif_Set_type(e2v,(/2,1/),(/3,2/))
+
+      Call Agrif_Set_type(tn,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sn,(/2,2,0/),(/3,3,0/)) 
+
+      Call Agrif_Set_type(tb,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sb,(/2,2,0/),(/3,3,0/)) 
+
+      Call Agrif_Set_type(ta,(/2,2,0/),(/3,3,0/))
+      Call Agrif_Set_type(sa,(/2,2,0/),(/3,3,0/))       
+
+      Call Agrif_Set_type(sshn,(/2,2/),(/3,3/))
+      Call Agrif_Set_type(gcb,(/2,2/),(/3,3/))
+
+#if defined key_top
+      Call Agrif_Set_type(trb,(/2,2,0,0/),(/3,3,0,0/))
+      Call Agrif_Set_type(trn,(/2,2,0,0/),(/3,3,0,0/))
+      Call Agrif_Set_type(tra,(/2,2,0,0/),(/3,3,0,0/))
+#endif
+      
+      ! 2. Space directions for each variables
+      !---------------------------------------
+      Call Agrif_Set_raf(un,(/'x','y','N'/))
+      Call Agrif_Set_raf(vn,(/'x','y','N'/))
+
+      Call Agrif_Set_raf(ua,(/'x','y','N'/))
+      Call Agrif_Set_raf(va,(/'x','y','N'/))
+
+      Call Agrif_Set_raf(e1u,(/'x','y'/))
+      Call Agrif_Set_raf(e2v,(/'x','y'/))
+
+      Call Agrif_Set_raf(tn,(/'x','y','N'/))
+      Call Agrif_Set_raf(sn,(/'x','y','N'/))
+
+      Call Agrif_Set_raf(tb,(/'x','y','N'/))
+      Call Agrif_Set_raf(sb,(/'x','y','N'/))
+
+      Call Agrif_Set_raf(ta,(/'x','y','N'/))
+      Call Agrif_Set_raf(sa,(/'x','y','N'/))      
+
+      Call Agrif_Set_raf(sshn,(/'x','y'/))
+      Call Agrif_Set_raf(gcb,(/'x','y'/))
+
+#if defined key_top
+      Call Agrif_Set_raf(trn,(/'x','y','N','N'/))
+      Call Agrif_Set_raf(trb,(/'x','y','N','N'/))
+      Call Agrif_Set_raf(tra,(/'x','y','N','N'/))
+#endif
+
+      ! 3. Type of interpolation
+      !------------------------- 
+      Call Agrif_Set_bcinterp(tn,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(sn,interp=AGRIF_linear)
+
+      Call Agrif_Set_bcinterp(ta,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(sa,interp=AGRIF_linear)
+
+      Call Agrif_Set_bcinterp(un,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(vn,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      Call Agrif_Set_bcinterp(ua,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(va,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+      Call Agrif_Set_bcinterp(e1u,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      Call Agrif_Set_bcinterp(e2v,interp1=AGRIF_ppm,interp2=Agrif_linear)
+
+#if defined key_top
+      Call Agrif_Set_bcinterp(trn,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(tra,interp=AGRIF_linear)
+#endif
+
+      ! 4. Location of interpolation
+      !-----------------------------
+      Call Agrif_Set_bc(un,(/0,1/))
+      Call Agrif_Set_bc(vn,(/0,1/))
+
+      Call Agrif_Set_bc(e1u,(/0,0/))
+      Call Agrif_Set_bc(e2v,(/0,0/))
+
+      Call Agrif_Set_bc(tn,(/0,1/))
+      Call Agrif_Set_bc(sn,(/0,1/))
+
+      Call Agrif_Set_bc(ta,(/-3*Agrif_irhox(),0/))
+      Call Agrif_Set_bc(sa,(/-3*Agrif_irhox(),0/))
+
+      Call Agrif_Set_bc(ua,(/-2*Agrif_irhox(),0/))
+      Call Agrif_Set_bc(va,(/-2*Agrif_irhox(),0/))
+
+#if defined key_top
+      Call Agrif_Set_bc(trn,(/0,1/))
+      Call Agrif_Set_bc(tra,(/-3*Agrif_irhox(),0/))
+#endif
+
+      ! 5. Update type
+      !--------------- 
+      Call Agrif_Set_Updatetype(tn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(sn, update = AGRIF_Update_Average)
+
+      Call Agrif_Set_Updatetype(tb, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(sb, update = AGRIF_Update_Average)
+
+      Call Agrif_Set_Updatetype(sshn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(gcb,update = AGRIF_Update_Average)
+
+#if defined key_top
+      Call Agrif_Set_Updatetype(trn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(trb, update = AGRIF_Update_Average)
+#endif
+
+      Call Agrif_Set_Updatetype(un,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
+      Call Agrif_Set_Updatetype(vn,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
+
+      Call Agrif_Set_Updatetype(e1u,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
+      Call Agrif_Set_Updatetype(e2v,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
+
+      ! 6. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      Call Agrif_Bc_variable(tabtemp,tn,calledweight=1.)
+      Call Agrif_Bc_variable(tabtemp,sn,calledweight=1.)
+      Call Agrif_Bc_variable(tabtemp,un,calledweight=1.,procname=interpu)
+      Call Agrif_Bc_variable(tabtemp,vn,calledweight=1.,procname=interpv)
+
+      Call Agrif_Bc_variable(tabtemp,ta,calledweight=1.,procname=interptn)
+      Call Agrif_Bc_variable(tabtemp,sa,calledweight=1.,procname=interpsn)
+
+      Call Agrif_Bc_variable(tabtemp,ua,calledweight=1.,procname=interpun)
+      Call Agrif_Bc_variable(tabtemp,va,calledweight=1.,procname=interpvn)
+
+#if defined key_top
+      Call Agrif_Bc_variable(tabtrtemp,trn,calledweight=1.)
+      Call Agrif_Bc_variable(tabtrtemp,tra,calledweight=1.,procname=interptrn)
+#endif
+      Agrif_UseSpecialValue = .FALSE.
+
+      ! 7. Some controls
+      !-----------------
+      check_namelist = .true.
+            
+      IF( check_namelist ) THEN
+     
+         ! Check time steps           
+         IF( nint(Agrif_Rhot()) * nint(rdt) .ne. Agrif_Parent(rdt) ) THEN
+            WRITE(*,*) 'incompatible time step between grids'
+            WRITE(*,*) 'parent grid value : ',Agrif_Parent(rdt)
+            WRITE(*,*) 'child  grid value : ',nint(rdt)
+            WRITE(*,*) 'value on parent grid should be : ',rdt*Agrif_Rhot()
+            STOP
+         ENDIF
+         
+         ! Check run length
+         IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
+            Agrif_Parent(nit000)+1) .ne. (nitend-nit000+1) ) THEN
+            WRITE(*,*) 'incompatible run length between grids'
+            WRITE(*,*) 'parent grid value : ',(Agrif_Parent(nitend)- &
+               Agrif_Parent(nit000)+1),' time step'
+            WRITE(*,*) 'child  grid value : ', &
+               (nitend-nit000+1),' time step'
+            WRITE(*,*) 'value on child grid should be : ', &
+               Agrif_IRhot() * (Agrif_Parent(nitend)- &
+               Agrif_Parent(nit000)+1)
+            STOP
+         ENDIF
+         
+         ! Check coordinates
+         IF( ln_zps ) THEN
+            ! check parameters for partial steps 
+            IF( Agrif_Parent(e3zps_min) .ne. e3zps_min ) THEN
+               WRITE(*,*) 'incompatible e3zps_min between grids'
+               WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
+               WRITE(*,*) 'child grid  :',e3zps_min
+               WRITE(*,*) 'those values should be identical'
+               STOP
+            ENDIF          
+            IF( Agrif_Parent(e3zps_rat) .ne. e3zps_rat ) THEN
+               WRITE(*,*) 'incompatible e3zps_rat between grids'
+               WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
+               WRITE(*,*) 'child grid  :',e3zps_rat
+               WRITE(*,*) 'those values should be identical'                  
+               STOP
+            ENDIF
+         ENDIF
+#if defined key_top
+        ! Check passive tracer cell
+        IF( ndttrc .ne. 1 ) THEN
+           WRITE(*,*) 'ndttrc should be equal to 1'
+        ENDIF
+#endif
+
+      ENDIF
+
+#if defined key_top
+      CALL Agrif_Update_trc(0)
+#endif
+      CALL Agrif_Update_tra(0)
+      CALL Agrif_Update_dyn(0)
+
+#if defined key_top
+      nbcline_trc = 0
+#endif
+      nbcline = 0
+      !
+   END SUBROUTINE Agrif_InitValues
+
+#else
+
+   SUBROUTINE Agrif_InitValues
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues ***
+      !!
+      !! ** Purpose :: Declaration of variables to be interpolated
+      !!----------------------------------------------------------------------
+      USE Agrif_Util
+      USE oce 
+      USE dom_oce
+      USE opa
+      USE trc
+      USE in_out_manager
+      USE agrif_top_update
+      USE agrif_top_interp
+      USE agrif_top_sponge
+      !!
+      IMPLICIT NONE
+      !!
+      REAL(wp) :: tabtrtemp(jpi,jpj,jpk,jptra)
+      LOGICAL check_namelist
+      !!----------------------------------------------------------------------
+
+      ! 0. Initializations
+      !-------------------
+#if defined key_orca_r025 || defined key_orca_r05 || defined key_orca_r2 || defined key_orca_r4
+      jp_cfg = -1    ! set special value for jp_cfg on fine grids
+      cp_cfg = "default"
+#endif
+
+      Call opa_init  ! Initializations of each fine grid
+      Call agrif_opa_init
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      Call Agrif_Set_type(trb,(/2,2,0,0/),(/3,3,0,0/))
+      Call Agrif_Set_type(trn,(/2,2,0,0/),(/3,3,0,0/))
+      Call Agrif_Set_type(tra,(/2,2,0,0/),(/3,3,0,0/))
+      
+      ! 2. Space directions for each variables
+      !---------------------------------------
+      Call Agrif_Set_raf(trn,(/'x','y','N','N'/))
+      Call Agrif_Set_raf(trb,(/'x','y','N','N'/))
+      Call Agrif_Set_raf(tra,(/'x','y','N','N'/))
+
+      ! 3. Type of interpolation
+      !------------------------- 
+      Call Agrif_Set_bcinterp(trn,interp=AGRIF_linear)
+      Call Agrif_Set_bcinterp(tra,interp=AGRIF_linear)
+
+      ! 4. Location of interpolation
+      !-----------------------------
+      Call Agrif_Set_bc(trn,(/0,1/))
+      Call Agrif_Set_bc(tra,(/-3*Agrif_irhox(),0/))
+
+      ! 5. Update type
+      !--------------- 
+      Call Agrif_Set_Updatetype(trn, update = AGRIF_Update_Average)
+      Call Agrif_Set_Updatetype(trb, update = AGRIF_Update_Average)
+
+      ! 6. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
+      Agrif_SpecialValue=0.
+      Agrif_UseSpecialValue = .TRUE.
+      Call Agrif_Bc_variable(tabtrtemp,trn,calledweight=1.)
+      Call Agrif_Bc_variable(tabtrtemp,tra,calledweight=1.,procname=interptrn)
+      Agrif_UseSpecialValue = .FALSE.
+
+      ! 7. Some controls
+      !-----------------
+      check_namelist = .true.
+            
+      IF( check_namelist ) THEN
+     
+         ! Check time steps           
+         IF( nint(Agrif_Rhot()) * nint(rdt) .ne. Agrif_Parent(rdt) ) THEN
+            WRITE(*,*) 'incompatible time step between grids'
+            WRITE(*,*) 'parent grid value : ',Agrif_Parent(rdt)
+            WRITE(*,*) 'child  grid value : ',nint(rdt)
+            WRITE(*,*) 'value on parent grid should be : ',rdt*Agrif_Rhot()
+            STOP
+         ENDIF
+         
+         ! Check run length
+         IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
+            Agrif_Parent(nit000)+1) .ne. (nitend-nit000+1) ) THEN
+            WRITE(*,*) 'incompatible run length between grids'
+            WRITE(*,*) 'parent grid value : ',(Agrif_Parent(nitend)- &
+               Agrif_Parent(nit000)+1),' time step'
+            WRITE(*,*) 'child  grid value : ', &
+               (nitend-nit000+1),' time step'
+            WRITE(*,*) 'value on child grid should be : ', &
+               Agrif_IRhot() * (Agrif_Parent(nitend)- &
+               Agrif_Parent(nit000)+1)
+            STOP
+         ENDIF
+         
+         ! Check coordinates
+         IF( ln_zps ) THEN
+            ! check parameters for partial steps 
+            IF( Agrif_Parent(e3zps_min) .ne. e3zps_min ) THEN
+               WRITE(*,*) 'incompatible e3zps_min between grids'
+               WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
+               WRITE(*,*) 'child grid  :',e3zps_min
+               WRITE(*,*) 'those values should be identical'
+               STOP
+            ENDIF          
+            IF( Agrif_Parent(e3zps_rat) .ne. e3zps_rat ) THEN
+               WRITE(*,*) 'incompatible e3zps_rat between grids'
+               WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
+               WRITE(*,*) 'child grid  :',e3zps_rat
+               WRITE(*,*) 'those values should be identical'                  
+               STOP
+            ENDIF
+         ENDIF
+        ! Check passive tracer cell
+        IF( ndttrc .ne. 1 ) THEN
+           WRITE(*,*) 'ndttrc should be equal to 1'
+        ENDIF
+
+      ENDIF
+
+      CALL Agrif_Update_trc(0)
+      nbcline_trc = 0
+      !
+   END SUBROUTINE Agrif_InitValues
+
+#endif
+   
+   SUBROUTINE Agrif_detect( g, sizex )
+      !!----------------------------------------------------------------------
+      !!   *** ROUTINE Agrif_detect ***
+      !!----------------------------------------------------------------------
+      USE Agrif_Types
+      !! 
+      INTEGER, DIMENSION(2) :: sizex
+      INTEGER, DIMENSION(sizex(1),sizex(2)) :: g 
+      !!----------------------------------------------------------------------
+      !
+      RETURN
+      !
+   END SUBROUTINE Agrif_detect
+
+
+   SUBROUTINE agrif_opa_init
+      !!----------------------------------------------------------------------
+      !!                     *** ROUTINE agrif_init ***
+      !!----------------------------------------------------------------------
+      USE agrif_oce 
+      USE in_out_manager
+      !!
+      IMPLICIT NONE
+      !!
+      NAMELIST/namagrif/ nn_cln_update, rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )                ! Read namagrif namelist
+      READ  ( numnam, namagrif )
+      !
+      IF(lwp) THEN                    ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'agrif_opa_init : AGRIF parameters'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
+         WRITE(numout,*) '      baroclinic update frequency       nn_cln_update = ', nn_cln_update
+         WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' s'
+         WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' s'
+         WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
+         WRITE(numout,*) 
+      ENDIF
+      !
+      ! convert DOCTOR namelist name into OLD names
+      nbclineupdate = nn_cln_update
+      visc_tra      = rn_sponge_tra
+      visc_dyn      = rn_sponge_dyn
+      !
+    END SUBROUTINE agrif_opa_init
+
+# if defined key_mpp_mpi
+
+   SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
+      !!----------------------------------------------------------------------
+      !!                     *** ROUTINE Agrif_detect ***
+      !!----------------------------------------------------------------------
+      USE dom_oce
+      !!
+      IMPLICIT NONE
+      !!
+      INTEGER :: indglob,indloc,nprocloc,i
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE(i)
+      CASE(1)
+         indglob = indloc + nimppt(nprocloc+1) - 1
+      CASE(2)
+         indglob = indloc + njmppt(nprocloc+1) - 1 
+      CASE(3)
+         indglob = indloc
+      CASE(4)
+         indglob = indloc
+      END SELECT
+      !
+   END SUBROUTINE Agrif_InvLoc
+
+# endif
+
+#else
+   SUBROUTINE Subcalledbyagrif
+      !!----------------------------------------------------------------------
+      !!   *** ROUTINE Subcalledbyagrif ***
+      !!----------------------------------------------------------------------
+      WRITE(*,*) 'Impossible to be here'
+   END SUBROUTINE Subcalledbyagrif
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DIA/dianam.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DIA/dianam.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DIA/dianam.F90	(revision 1844)
@@ -0,0 +1,138 @@
+MODULE dianam
+   !!======================================================================
+   !!                       ***  MODULE  dianam  ***
+   !! Ocean diagnostics:  Builds output file name
+   !!=====================================================================
+   !! History :  OPA  ! 1999-02  (E. Guilyardi)  Creation for 30 days/month
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            3.2  ! 2009-11  (S. Masson) complete rewriting, works for all calendars...
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_nam       : Builds output file name
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE ioipsl, ONLY :  ju2ymds    ! for calendar
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dia_nam
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_nam( cdfnam, kfreq, cdsuff, ldfsec )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_nam  ***
+      !!                   
+      !! ** Purpose :   Builds output file name
+      !!
+      !! ** Method  :   File name is a function of date and output frequency
+      !!      cdfnam=<cexper>_<clave>_<idtbeg>_<idtend>_<cdsuff>
+      !!      <clave> = averaging frequency (DA, MO, etc...)
+      !!      <idtbeg>,<idtend> date of beginning and end of run
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER (len=*), INTENT(  out)           ::   cdfnam   ! file name
+      CHARACTER (len=*), INTENT(in   )           ::   cdsuff   ! to be added at the end of the file name
+      INTEGER          , INTENT(in   )           ::   kfreq    ! output frequency: > 0 in time-step (or seconds see ldfsec)
+      !                                                                            < 0 in months
+      !                                                                            = 0 no frequency
+      LOGICAL          , INTENT(in   ), OPTIONAL ::   ldfsec   ! kfreq in second(in time-step) if .true.(.false. default)
+      !
+      CHARACTER (len=20) ::   clfmt, clfmt0                    ! writing format
+      CHARACTER (len=20) ::   clave                            ! name for output frequency
+      CHARACTER (len=20) ::   cldate1                          ! date of the beginning of run
+      CHARACTER (len=20) ::   cldate2                          ! date of the end       of run
+      LOGICAL            ::   llfsec                           ! local value of ldfsec
+      INTEGER            ::   iyear1, imonth1, iday1           ! year, month, day of the first day of the run
+      INTEGER            ::   iyear2, imonth2, iday2           ! year, month, day of the last  day of the run
+      INTEGER            ::   indg                             ! number of digits needed to write a number     
+      INTEGER            ::   inbsec, inbmn, inbhr             ! output frequency in seconds, minutes and hours
+      INTEGER            ::   inbday, inbmo, inbyr             ! output frequency in days, months and years
+      INTEGER            ::   iyyss, iddss, ihhss, immss       ! number of seconds in 1 year, 1 day, 1 hour and 1 minute
+      INTEGER            ::   iyymo                            ! number of months in 1 year
+      REAL(wp)           ::   zsec1, zsec2                     ! not used
+      REAL(wp)           ::   zdrun, zjul                      ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      ! name for output frequency
+
+      IF( PRESENT(ldfsec) ) THEN   ;   llfsec = ldfsec
+      ELSE                         ;   llfsec = .FALSE.
+      ENDIF
+
+      IF( llfsec .OR. kfreq < 0 ) THEN   ;   inbsec = kfreq                       ! output frequency already in seconds
+      ELSE                               ;   inbsec = kfreq * NINT( rdttra(1) )   ! from time-step to seconds
+      ENDIF
+      iddss = NINT( rday          )                                         ! number of seconds in 1 day
+      ihhss = NINT( rmmss * rhhmm )                                         ! number of seconds in 1 hour
+      immss = NINT( rmmss         )                                         ! number of seconds in 1 minute
+      iyymo = NINT( raamo         )                                         ! number of months  in 1 year
+      iyyss = iddss * nyear_len(1)                                          ! seconds in 1 year (not good: multi years with leap)
+      clfmt0 = "('(a,i',i1,',a)')"                                          ! format '(a,ix,a)' with x to be defined
+      ! 
+      IF(          inbsec == 0           ) THEN   ;   clave = ''            ! no frequency
+      ELSEIF(      inbsec <  0           ) THEN        
+         inbmo = -inbsec                                                    ! frequency in month
+         IF( MOD( inbmo, iyymo  ) == 0 ) THEN                               ! frequency in years
+            inbyr  = inbmo / iyymo
+            indg   = INT(LOG10(REAL(inbyr,wp))) + 1                         ! number of digits needed to write years   frequency
+            WRITE(clfmt, clfmt0) indg             ;   WRITE(clave, clfmt) '_', inbyr , 'y'
+         ELSE                                                               ! frequency in month
+            indg   = INT(LOG10(REAL(inbmo,wp))) + 1                         ! number of digits needed to write months  frequency
+            WRITE(clfmt, clfmt0) indg             ;   WRITE(clave, clfmt) '_', inbmo, 'm'
+         ENDIF
+      ELSEIF( MOD( inbsec, iyyss  ) == 0 ) THEN                             ! frequency in years
+         inbyr  = inbsec / iyyss
+         indg   = INT(LOG10(REAL(inbyr ,wp))) + 1                           ! number of digits needed to write years   frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbyr , 'y'
+      ELSEIF( MOD( inbsec, iddss  ) == 0 ) THEN                             ! frequency in days
+         inbday = inbsec / iddss
+         indg   = INT(LOG10(REAL(inbday,wp))) + 1                           ! number of digits needed to write days    frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbday, 'd'
+         IF( inbday == nmonth_len(nmonth) )           clave = '_1m'
+      ELSEIF( MOD( inbsec, ihhss ) == 0 ) THEN                              ! frequency in hours
+         inbhr  = inbsec / ihhss
+         indg   = INT(LOG10(REAL(inbhr ,wp))) + 1                           ! number of digits needed to write hours   frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbhr , 'h'
+      ELSEIF( MOD( inbsec, immss ) == 0 ) THEN                              ! frequency in minutes
+         inbmn  = inbsec / immss
+         indg   = INT(LOG10(REAL(inbmn ,wp))) + 1                           ! number of digits needed to write minutes frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbmn , 'mn'
+      ELSE                                                                  ! frequency in seconds
+         indg   = INT(LOG10(REAL(inbsec,wp))) + 1                           ! number of digits needed to write seconds frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbsec, 's'
+      ENDIF
+
+      ! date of the beginning and the end of the run
+
+      zdrun = rdttra(1) / rday * REAL( nitend - nit000, wp )                ! length of the run in days
+      zjul  = fjulday - rdttra(1) / rday
+      CALL ju2ymds( zjul        , iyear1, imonth1, iday1, zsec1 )           ! year/month/day of the beginning of run
+      CALL ju2ymds( zjul + zdrun, iyear2, imonth2, iday2, zsec2 )           ! year/month/day of the end       of run
+
+      IF( iyear2 < 10000 ) THEN   ;   clfmt = "(i4.4,2i2.2)"                ! format used to write the date 
+      ELSE                        ;   WRITE(clfmt, "('(i',i1,',2i2.2)')") INT(LOG10(REAL(iyear2,wp))) + 1
+      ENDIF
+
+      WRITE(cldate1, clfmt) iyear1, imonth1, iday1                          ! date of the beginning of run
+      WRITE(cldate2, clfmt) iyear2, imonth2, iday2                          ! date of the end       of run
+ 
+      cdfnam = TRIM(cexper)//TRIM(clave)//"_"//TRIM(cldate1)//"_"//TRIM(cldate2)//"_"//TRIM(cdsuff)
+#if defined key_agrif
+      if ( .NOT. Agrif_Root() ) cdfnam = TRIM(Agrif_CFixed())//'_'//TRIM(cdfnam)
+#endif    
+
+   END SUBROUTINE dia_nam
+
+   !!======================================================================
+END MODULE dianam
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/daymod.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/daymod.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/daymod.F90	(revision 1844)
@@ -0,0 +1,241 @@
+MODULE daymod
+   !!======================================================================
+   !!                       ***  MODULE  daymod  ***
+   !! Ocean        :  calendar 
+   !!=====================================================================
+   !! History :  OPA  ! 1994-09  (M. Pontaud M. Imbard)  Original code
+   !!                 ! 1997-03  (O. Marti)
+   !!                 ! 1997-05  (G. Madec) 
+   !!                 ! 1997-08  (M. Imbard)
+   !!   NEMO     1.0  ! 2003-09  (G. Madec)  F90 + nyear, nmonth, nday
+   !!                 ! 2004-01  (A.M. Treguier) new calculation based on adatrj
+   !!                 ! 2006-08  (G. Madec)  surface module major update
+   !!----------------------------------------------------------------------      
+
+   !!----------------------------------------------------------------------
+   !!   day        : calendar
+   !!  
+   !!           -------------------------------
+   !!           ----------- WARNING -----------
+   !!
+   !!   we suppose that the time step is deviding the number of second of in a day
+   !!             ---> MOD( rday, rdttra(1) ) == 0
+   !!
+   !!           ----------- WARNING -----------
+   !!           -------------------------------
+   !!  
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE ioipsl, ONLY :   ymds2ju   ! for calendar
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   day        ! called by step.F90
+   PUBLIC   day_init   ! called by istate.F90
+
+   INTEGER ::   nsecd, nsecd05, ndt, ndt05
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE day_init
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE day_init  ***
+      !! 
+      !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000 
+      !!                because day will be called at the beginning of step
+      !!
+      !! ** Action  : - nyear        : current year
+      !!              - nmonth       : current month of the year nyear
+      !!              - nday         : current day of the month nmonth
+      !!              - nday_year    : current day of the year nyear
+      !!              - nsec_year    : current time step counted in second since 00h jan 1st of the current year
+      !!              - nsec_month   : current time step counted in second since 00h 1st day of the current month
+      !!              - nsec_day     : current time step counted in second since 00h of the current day
+      !!              - nsec1jan000  : second since Jan. 1st 00h of nit000 year and Jan. 1st 00h of the current year
+      !!              - nmonth_len, nyear_len, nmonth_half, nmonth_end through day_mth
+      !!----------------------------------------------------------------------
+
+      ! all calendar staff is based on the fact that MOD( rday, rdttra(1) ) == 0
+      IF( MOD( rday     , rdttra(1) ) /= 0. )   CALL ctl_stop( 'the time step must devide the number of second of in a day' )
+      IF( MOD( rday     , 2.        ) /= 0. )   CALL ctl_stop( 'the number of second of in a day must be an even number'    )
+      IF( MOD( rdttra(1), 2.        ) /= 0. )   CALL ctl_stop( 'the time step (in second) must be an even number'           )
+      nsecd   = NINT(rday           )
+      nsecd05 = NINT(0.5 * rday     )
+      ndt     = NINT(      rdttra(1))
+      ndt05   = NINT(0.5 * rdttra(1))
+
+
+      ! set the calandar from ndastp (read in restart file and namelist)
+
+      nyear   =   ndastp / 10000
+      nmonth  = ( ndastp - (nyear * 10000) ) / 100
+      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
+
+      CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday )  ! we assume that we start run at 00:00
+      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
+      fjulday = fjulday + 1.                             ! move back to the day at nit000 (and not at nit000 - 1)
+
+      nsec1jan000 = 0
+      CALL day_mth
+      
+      IF ( nday == 0 ) THEN     !   for ex if ndastp = ndate0 - 1
+         nmonth = nmonth - 1  
+         nday = nmonth_len(nmonth)
+      ENDIF
+      IF ( nmonth == 0 ) THEN   ! go at the end of previous year
+         nmonth = 12
+         nyear = nyear - 1
+         nsec1jan000 = nsec1jan000 - nsecd * nyear_len(0)
+         IF( nleapy == 1 )   CALL day_mth
+      ENDIF
+      
+      ! day since january 1st
+      nday_year = nday + SUM( nmonth_len(1:nmonth - 1) )
+      
+      ! number of seconds since the beginning of current year/month at the middle of the time-step
+      nsec_year  = nday_year * nsecd - ndt05   ! 1 time step before the middle of the first time step
+      nsec_month = nday      * nsecd - ndt05   ! because day will be called at the beginning of step
+      nsec_day   =             nsecd - ndt05
+
+      ! control print
+      IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i6)')' ==============>> 1/2 time step before the start of the run DATE Y/M/D = ',   &
+           &                   nyear, '/', nmonth, '/', nday, '  nsec_day:', nsec_day
+
+      ! Up to now, calendar parameters are related to the end of previous run (nit000-1)
+      ! call day to set the calendar parameters at the begining of the current simulaton. needed by iom_init
+      CALL day( nit000 )
+
+      
+   END SUBROUTINE day_init
+
+
+   SUBROUTINE day_mth
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE day_init  ***
+      !! 
+      !! ** Purpose :   calendar values related to the months
+      !!
+      !! ** Action  : - nmonth_len    : length in days of the months of the current year
+      !!              - nyear_len     : length in days of the previous/current year
+      !!              - nmonth_half   : second since the beginning of the year and the halft of the months
+      !!              - nmonth_end    : second since the beginning of the year and the end of the months
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jm               ! dummy loop indice
+      !!----------------------------------------------------------------------
+
+      ! length of the month of the current year (from nleapy, read in namelist)
+      IF ( nleapy < 2 ) THEN 
+         nmonth_len(:) = (/ 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 /)
+         nyear_len(:) = 365
+         IF ( nleapy == 1 ) THEN   ! we are using calandar with leap years
+            IF ( MOD(nyear-1, 4) == 0 .AND. ( MOD(nyear-1, 400) == 0 .OR. MOD(nyear-1, 100) /= 0 ) ) THEN
+               nyear_len(0) = 366
+            ENDIF
+            IF ( MOD(nyear, 4) == 0 .AND. ( MOD(nyear, 400) == 0 .OR. MOD(nyear, 100) /= 0 ) ) THEN
+               nmonth_len(2) = 29
+               nyear_len(1) = 366
+            ENDIF
+         ENDIF
+      ELSE
+         nmonth_len(:) = nleapy   ! all months with nleapy days per year
+         nyear_len(:) = 12 * nleapy
+      ENDIF
+
+      ! half month in second since the begining of the year:
+      ! time since Jan 1st   0     1     2    ...    11    12    13
+      !          ---------*--|--*--|--*--| ... |--*--|--*--|--*--|--------------------------------------
+      !                 <---> <---> <--->  ...  <---> <---> <--->        
+      ! month number      0     1     2    ...    11    12    13
+      !
+      ! nmonth_half(jm) = rday * REAL( 0.5 * nmonth_len(jm) + SUM(nmonth_len(1:jm-1)) )
+      nmonth_half(0) = - nsecd05 * nmonth_len(0)
+      DO jm = 1, 13
+         nmonth_half(jm) = nmonth_half(jm-1) + nsecd05 * ( nmonth_len(jm-1) + nmonth_len(jm) )
+      END DO
+
+      nmonth_end(0) = 0
+      DO jm = 1, 13
+         nmonth_end(jm) = nmonth_end(jm-1) + nsecd * nmonth_len(jm)
+      END DO
+      !           
+   END SUBROUTINE 
+
+
+   SUBROUTINE day( kt )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE day  ***
+      !! 
+      !! ** Purpose :   Compute the date with a day iteration IF necessary.
+      !!
+      !! ** Method  : - ???
+      !!
+      !! ** Action  : - nyear     : current year
+      !!              - nmonth    : current month of the year nyear
+      !!              - nday      : current day of the month nmonth
+      !!              - nday_year : current day of the year nyear
+      !!              - ndastp    : = nyear*10000 + nmonth*100 + nday
+      !!              - adatrj    : date in days since the beginning of the run
+      !!              - nsec_year : current time of the year (in second since 00h, jan 1st)
+      !!----------------------------------------------------------------------      
+      INTEGER, INTENT(in) ::   kt        ! ocean time-step indices
+      !
+      CHARACTER (len=25) ::   charout
+      REAL(wp)           ::   zprec      ! fraction of day corresponding to 0.1 second
+      !!----------------------------------------------------------------------
+      zprec = 0.1 / rday
+      !                                                 ! New time-step
+      nsec_year  = nsec_year  + ndt 
+      nsec_month = nsec_month + ndt                 
+      nsec_day   = nsec_day   + ndt                
+      adatrj  = adatrj  + rdttra(1) / rday
+      fjulday = fjulday + rdttra(1) / rday
+      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
+      IF( ABS(adatrj  - REAL(NINT(adatrj ),wp)) < zprec )   adatrj  = REAL(NINT(adatrj ),wp)   ! avoid truncation error
+      
+      IF( nsec_day > nsecd ) THEN                        ! NEW day
+         !
+         nday      = nday + 1
+         nday_year = nday_year + 1
+         nsec_day  = ndt05
+         !
+         IF( nday == nmonth_len(nmonth) + 1 ) THEN      ! NEW month
+            nday   = 1
+            nmonth = nmonth + 1
+            nsec_month = ndt05
+            IF( nmonth == 13 ) THEN                     ! NEW year
+               nyear     = nyear + 1
+               nmonth    = 1
+               nday_year = 1
+               nsec_year = ndt05
+               nsec1jan000 = nsec1jan000 + nsecd * nyear_len(1)
+               IF( nleapy == 1 )   CALL day_mth
+            ENDIF
+         ENDIF
+         !
+         ndastp = nyear * 10000 + nmonth * 100 + nday   ! NEW date
+         !
+         IF(lwp) WRITE(numout,'(a,i8,a,i4.4,a,i2.2,a,i2.2,a,i3.3)') '======>> time-step =', kt,   &
+              &   '      New day, DATE Y/M/D = ', nyear, '/', nmonth, '/', nday, '      nday_year = ', nday_year
+         IF(lwp) WRITE(numout,'(a,i8,a,i7,a,i5)') '         nsec_year = ', nsec_year,   &
+              &   '   nsec_month = ', nsec_month, '   nsec_day = ', nsec_day
+      ENDIF
+      
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
+         CALL prt_ctl_info(charout)
+      ENDIF
+
+   END SUBROUTINE day
+
+   !!======================================================================
+END MODULE daymod
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dom_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dom_oce.F90	(revision 1844)
@@ -0,0 +1,231 @@
+MODULE dom_oce
+   !!----------------------------------------------------------------------
+   !!                       ***  MODULE dom_oce  ***
+   !!       
+   !! ** Purpose :   Define in memory all the ocean space domain variables
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC           ! allows the acces to par_oce when dom_oce is used
+   !                ! exception to coding rules... to be suppressed ???
+
+   !!----------------------------------------------------------------------
+   !! space domain parameters
+   !! -----------------------
+   LOGICAL, PUBLIC ::   &   !:
+      lzoom      =  .FALSE. ,   &  !: zoom flag
+      lzoom_e    =  .FALSE. ,   &  !: East  zoom type flag
+      lzoom_w    =  .FALSE. ,   &  !: West  zoom type flag
+      lzoom_s    =  .FALSE. ,   &  !: South zoom type flag
+      lzoom_n    =  .FALSE. ,   &  !: North zoom type flag
+      lzoom_arct =  .FALSE. ,   &  !: ORCA    arctic zoom flag
+      lzoom_anta =  .FALSE.        !: ORCA antarctic zoom flag
+
+   INTEGER, PUBLIC ::           & !!: namdom : space domain (bathymetry, mesh)
+      nmsh    =  0                 !: = 1 create a mesh-mask file
+
+   INTEGER, PUBLIC ::         &   !:
+      ! domain parameters linked to mpp
+      nperio,          &  !: type of lateral boundary condition
+      nimpp, njmpp,    &  !: i- & j-indexes for mpp-subdomain left bottom
+      nreci, nrecj,    &  !: overlap region in i and j
+      nproc,           &  !: number for local processor
+      narea,           &  !: number for local area
+      nbondi, nbondj,  &  !: mark of i- and j-direction local boundaries
+      npolj,           &  !: north fold mark (0, 3 or 4)
+      nlci, nlcj,      &  !: i- & j-dimensions of the local subdomain
+      nldi, nlei,      &  !: first and last indoor i- and j-indexes
+      nldj, nlej,      &  !:
+      noea, nowe,      &  !: index of the local neighboring processors in
+      noso, nono,      &  !: east, west, south and north directions
+      npne, npnw,      &  !: index of north east and north west processor
+      npse, npsw,      &  !: index of south east and south west processor
+      nbne, nbnw,      &  !: logical of north east & north west processor
+      nbse, nbsw,      &  !: logical of south east & south west processor
+      nidom
+
+   INTEGER, PUBLIC, DIMENSION(jpi) ::   &   !:
+      mig                 !: local  ==> global  domain i-indice
+   INTEGER, PUBLIC, DIMENSION(jpj) ::   &   !:
+      mjg                 !: local  ==> global  domain j-indice
+   INTEGER, PUBLIC, DIMENSION( jpidta ) ::   &  !:  !!bug ==> other solution?
+      mi0, mi1            !: global ==> local domain i-indice
+      !                   !  (mi0=1 and mi1=0 if the global indice is not in the local domain)
+   INTEGER, PUBLIC, DIMENSION( jpjdta ) ::   &  !:
+      mj0, mj1            !: global ==> local domain j-indice
+      !                   ! (mi0=1 and mi1=0 if the global indice is not in the local domain)
+
+   INTEGER, PUBLIC, DIMENSION(jpnij) ::   &  !:
+      nimppt, njmppt,  &  !: i-, j-indexes for each processor
+      ibonit, ibonjt,  &  !: i-, j- processor neighbour existence
+      nlcit, nlcjt,    &  !: dimensions of every subdomain
+      nldit, nldjt,    &  !: first, last indoor index for each i-domain
+      nleit, nlejt        !: first, last indoor index for each j-domain
+
+   !!----------------------------------------------------------------------
+   !! horizontal curvilinear coordinate and scale factors
+   !! ---------------------------------------------------------------------
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      glamt, glamu,    &  !: longitude of t-, u-, v- and f-points (degre)
+      glamv, glamf,    &  !:
+      gphit, gphiu,    &  !: latitude  of t-, u-, v- and f-points (degre)
+      gphiv, gphif,    &  !:
+      e1t, e2t,        &  !: horizontal scale factors at t-point (m)
+      e1u, e2u,        &  !: horizontal scale factors at u-point (m)
+      e1v, e2v,        &  !: horizontal scale factors at v-point (m)
+      ff                  !: coriolis factor (2.*omega*sin(yphi) ) (s-1)
+
+
+   !!----------------------------------------------------------------------
+   !! vertical coordinate and scale factors
+   !! --------------------------------------
+
+   LOGICAL, PUBLIC ::           & !!: namzgr : vertical coordinate
+      ln_zco     =  .TRUE.  ,   &  !: z-coordinate - full step
+      ln_zps     =  .FALSE. ,   &  !: z-coordinate - partial step
+      ln_sco     =  .FALSE.        !: s-coordinate or hybrid z-s coordinate
+
+#if defined key_zco
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zco = .TRUE.    !: z-coordinate flag (1D arrays)
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zco = .FALSE.   !: z-coordinate flag (3D arrays)
+
+   !! All coordinates
+   !! ---------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      gdep3w        ,    &  !: depth of T-points (sum of e3w) (m)
+      gdept , gdepw ,    &  !: analytical depth at T-W  points (m)
+      e3v   , e3f   ,    &  !: analytical vertical scale factors at  V--F
+      e3t   , e3u   ,    &  !:                                       T--U  points (m)
+      e3vw          ,    &  !: analytical vertical scale factors at  VW--
+      e3w   , e3uw          !:                                        W--UW  points (m)
+#endif
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      hur, hvr,          &  !: inverse of u and v-points ocean depth (1/m)
+      hu , hv               !: depth at u- and v-points (meters)
+
+   !! z-coordinate with full steps (also used in the other cases as reference z-coordinate)
+   !! =-----------------====------
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &  !:
+      gdept_0, gdepw_0,       &  !: reference depth of t- and w-points (m)
+      e3t_0  , e3w_0             !: reference vertical scale factors at T- and W-pts (m)
+
+   !! z-coordinate with partial steps
+   !! =-----------------=======------
+   REAL(wp), PUBLIC ::      & !!: * namelist namdom *
+      e3zps_min = 5.0_wp,   &  !: miminum thickness for partial steps (meters)
+      e3zps_rat = 0.1_wp       !: minimum thickness ration for partial steps
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      hdept, hdepw, e3tp, e3wp   !: ???
+
+   !! s-coordinate and hybrid z-s-coordinate
+   !! =----------------======---------------
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &   !:
+      gsigt, gsigw ,   &  !: model level depth coefficient at t-, w-levels (analytic)
+      gsi3w        ,   &  !: model level depth coefficient at w-level (sum of gsigw)
+      esigt, esigw        !: vertical scale factor coef. at t-, w-levels
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      hbatv , hbatf ,   &  !: ocean depth at the vertical of  V--F
+      hbatt , hbatu ,   &  !:                                 T--U  points (m)
+      scosrf, scobot,   &  !:  ocean surface and bottom topographies (if deviating from coordinate surfaces in HYBRID)
+      hifv  , hiff  ,   &  !: interface depth between stretching    at  V--F
+      hift  , hifu         !: and quasi-uniform spacing                 T--U  points (m)
+
+#if defined key_vvl
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vvl = .TRUE.    !: variable grid flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vvl = .FALSE.   !: fixed grid flag
+#endif
+
+   !!----------------------------------------------------------------------
+   !! masks, bathymetry
+   !! -----------------
+
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      mbathy         !: number of ocean level (=0, 1, ... , jpk-1)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      tmask_i           !: interior domain T-point mask
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      tmask, umask,    &  !: land/ocean mask at T-, U-, V- and F-points
+      vmask, fmask        !:
+
+   REAL(wp), PUBLIC, DIMENSION(jpiglo) ::   &   !:
+      tpol                !: north fold mask (nperio= 3 or 4)
+
+   !!----------------------------------------------------------------------
+   !! time domain
+   !!----------------------------------------------------------------------
+   INTEGER, PUBLIC ::    & !!: * Namelist * ???
+      nacc   = 0 ,       &  !: = 0/1 use of the acceleration of convergence technique
+      neuler                !: restart euler forward option (0=Euler)
+
+
+   REAL(wp), PUBLIC ::       & !!: * Namelist ??? *
+      rdt    = 3600._wp ,    &  !: time step for the dynamics (and tracer if nacc=0)
+      rdtmin = 3600._wp ,    &  !: minimum time step on tracers
+      rdtmax = 3600._wp ,    &  !: maximum time step on tracers
+      rdth   =  800._wp ,    &  !: depth variation of tracer step
+      atfp   = 0.1_wp   ,    &  !: asselin time filter parameter
+      atfp1                     !: asselin time filter coeff. (atfp1= 1-2*atfp)
+
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &  !:
+      rdttra                    !: vertical profile of tracer time step
+
+   !!----------------------------------------------------------------------
+   !! cross land advection
+   !!----------------------------------------------------------------------
+
+   INTEGER, PUBLIC ::       & !!: namelist ???
+      n_cla                    !: flag (0/1) for cross land advection to
+      !                        ! parameterize exchanges through straits
+
+   !!----------------------------------------------------------------------
+   !! calendar variables
+   !! ---------------------------------------------------------------------
+   INTEGER , PUBLIC ::   nyear       !: current year
+   INTEGER , PUBLIC ::   nmonth      !: current month
+   INTEGER , PUBLIC ::   nday        !: current day of the month
+   INTEGER , PUBLIC ::   ndastp      !: time step date in yyyymmdd format
+   INTEGER , PUBLIC ::   nday_year   !: current day counted from jan 1st of the current year
+   INTEGER , PUBLIC ::   nsec_year   !: current time step counted in second since 00h jan 1st of the current year
+   INTEGER , PUBLIC ::   nsec_month  !: current time step counted in second since 00h 1st day of the current month
+   INTEGER , PUBLIC ::   nsec_day    !: current time step counted in second since 00h of the current day
+   REAL(wp), PUBLIC ::   fjulday     !: julian day 
+   REAL(wp), PUBLIC ::   adatrj      !: number of elapsed days since the begining of the whole simulation
+   !                                 !: (cumulative duration of previous runs that may have used different time-step size)
+   INTEGER , PUBLIC, DIMENSION(0: 1) ::   nyear_len     !: length in days of the previous/current year 
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_len    !: length in days of the months of the current year
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_half   !: second since Jan 1st 0h of the current year and the half of the months
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_end    !: second since Jan 1st 0h of the current year and the end of the months
+   INTEGER , PUBLIC                  ::   nsec1jan000   !: second since Jan 1st 0h of nit000 year and Jan 1st 0h the current year
+
+   !!----------------------------------------------------------------------
+   !! agrif domain
+   !!----------------------------------------------------------------------
+#if defined key_agrif
+   LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .TRUE.    !: agrif flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .FALSE.   !: agrif flag
+#endif
+
+#if defined key_off_degrad
+   !! ------------------------------------------------
+   !! Degradation method
+   !! --------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) :: &
+      facvol  !! volume for degraded regions
+#endif
+
+   !!----------------------------------------------------------------------
+END MODULE dom_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domain.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domain.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domain.F90	(revision 1844)
@@ -0,0 +1,388 @@
+MODULE domain
+   !!==============================================================================
+   !!                       ***  MODULE domain   ***
+   !! Ocean initialization : domain initialization
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_init       : initialize the space and time domain
+   !!   dom_nam        : read and contral domain namelists
+   !!   dom_ctl        : control print for the ocean domain
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! 
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+
+   USE domstp          ! domain: set the time-step
+   USE domrea          ! domain: write the meshmask file
+   USE dommsk          ! domain : mask
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dom_init       ! called by opa.F90
+
+   !! * Module variables
+      REAL(wp) ::          & !!: Namelist nam_zgr_sco
+      sbot_min =  300.  ,  &  !: minimum depth of s-bottom surface (>0) (m)
+      sbot_max = 5250.  ,  &  !: maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+      theta    =    6.0 ,  &  !: surface control parameter (0<=theta<=20)
+      thetb    =    0.75,  &  !: bottom control parameter  (0<=thetb<= 1)
+      r_max    =    0.15      !: maximum cut-off r-value allowed (0<r_max<1)
+
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_init  ***
+      !!                    
+      !! ** Purpose :   Domain initialization. Call the routines that are 
+      !!      required to create the arrays which define the space and time
+      !!      domain of the ocean model.
+      !!
+      !! ** Method  :
+      !!      - dom_stp: defined the model time step
+      !!      - dom_rea: read the meshmask file if nmsh=1
+      !!
+      !! History :
+      !!        !  90-10  (C. Levy - G. Madec)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  92-01  (M. Imbard) insert time step initialization
+      !!        !  96-06  (G. Madec) generalized vertical coordinate 
+      !!        !  97-02  (G. Madec) creation of domwri.F
+      !!        !  01-05  (E.Durand - G. Madec) insert closed sea
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   iconf = 0         ! temporary integers
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_init : domain initialization'
+         WRITE(numout,*) '~~~~~~~~'
+      ENDIF
+
+      CALL dom_nam                        ! read namelist ( namrun, namdom, namcla )
+
+      CALL dom_stp                        ! Time step
+
+      CALL dom_rea      ! Create a domain file
+
+      CALL dom_msk      ! Masks
+
+      CALL dom_ctl    ! Domain control
+
+   END SUBROUTINE dom_init
+
+
+   SUBROUTINE dom_nam
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read domaine namelists and print the variables.
+      !!
+      !! ** input   : - namrun namelist
+      !!              - namdom namelist
+      !!              - namcla namelist
+      !!
+      !! History :
+      !!   9.0  !  03-08  (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ioipsl
+      INTEGER ::   ioptio = 0      ! temporary integer
+
+      NAMELIST/namrun/ no    , cexper   , ln_rstart , nrstdt , nit000,         &
+         &             nitend, ndate0   , nleapy    , ninist , nstock,         &
+         &             nwrite, ln_mskland 
+
+      NAMELIST/namctl/ ln_ctl , nprint, nictls, nictle,   &
+         &             njctls, njctle   , nbench   , isplt  , jsplt
+
+      NAMELIST/namzgr/ ln_zco, ln_zps, ln_sco
+
+      NAMELIST/namdom/ e3zps_min, e3zps_rat, nmsh  ,   &
+         &             nacc  , atfp     , rdt      , rdtmin , rdtmax,   &
+         &             rdth 
+
+      NAMELIST/namcla/ n_cla
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_nam  : domain initialization through namelist read'
+         WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      ! Namelist namrun : parameters of the run
+      REWIND( numnam )
+      READ  ( numnam, namrun )
+
+      IF(lwp) THEN
+         WRITE(numout,*) '        Namelist namrun'
+         WRITE(numout,*) '           job number                      no        = ', no
+         WRITE(numout,*) '           experiment name for output      cexper    = ', cexper
+         WRITE(numout,*) '           restart logical                 ln_rstart = ', ln_rstart
+         WRITE(numout,*) '           control of time step            nrstdt    = ', nrstdt
+         WRITE(numout,*) '           number of the first time step   nit000    = ', nit000
+         WRITE(numout,*) '           number of the last time step    nitend    = ', nitend
+         WRITE(numout,*) '           initial calendar date aammjj    ndate0    = ', ndate0
+         WRITE(numout,*) '           leap year calendar (0/1)        nleapy    = ', nleapy
+         WRITE(numout,*) '           initial state output            ninist    = ', ninist
+         WRITE(numout,*) '           frequency of restart file       nstock    = ', nstock
+         WRITE(numout,*) '           frequency of output file        nwrite    = ', nwrite
+         WRITE(numout,*) '           mask land points             ln_mskland   = ', ln_mskland
+      ENDIF
+
+      ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
+      ndastp = ndate0 - 1        ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00
+      adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday
+      SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
+
+      CASE (  1 )
+         CALL ioconf_calendar('gregorian')
+         IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "gregorian", i.e. leap year'
+      CASE (  0 )
+         CALL ioconf_calendar('noleap')
+         IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "noleap", i.e. no leap year'
+      CASE ( 30 )
+         CALL ioconf_calendar('360d')
+         IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "360d", i.e. 360 days in a year'
+      END SELECT
+
+     ! Namelist namctl : print control
+      REWIND( numnam )
+      READ  ( numnam, namctl )
+
+      IF(lwp) THEN
+         WRITE(numout,*) '        Namelist namctl'
+         WRITE(numout,*) '           run control (for debugging)     ln_ctl    = ', ln_ctl
+         WRITE(numout,*) '           level of print                  nprint    = ', nprint
+         WRITE(numout,*) '           Start i indice for SUM control  nictls    = ', nictls
+         WRITE(numout,*) '           End i indice for SUM control    nictle    = ', nictle
+         WRITE(numout,*) '           Start j indice for SUM control  njctls    = ', njctls
+         WRITE(numout,*) '           End j indice for SUM control    njctle    = ', njctle
+         WRITE(numout,*) '           number of proc. following i     isplt     = ', isplt
+         WRITE(numout,*) '           number of proc. following j     jsplt     = ', jsplt
+         WRITE(numout,*) '           benchmark parameter (0/1)       nbench    = ', nbench
+      ENDIF
+
+      ! ... Control the sub-domain area indices for the print control
+      IF(ln_ctl)   THEN
+         IF( lk_mpp ) THEN
+            ! the domain is forced to the real splitted domain in MPI
+            isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj
+         ELSE
+            IF( isplt == 1 .AND. jsplt == 1  ) THEN
+               IF(lwp) WRITE(numout,cform_war)
+               IF(lwp) WRITE(numout,*)'          - isplt & jsplt are equal to 1'
+               IF(lwp) WRITE(numout,*)'          - the print control will be done over the whole domain'
+               IF(lwp) WRITE(numout,*)
+            ENDIF
+
+            ! compute the total number of processors ijsplt
+            ijsplt = isplt*jsplt
+         ENDIF
+
+         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
+         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
+
+         ! Control the indices used for the SUM control
+         IF( nictls+nictle+njctls+njctle == 0 )   THEN
+            ! the print control is done over the default area
+            lsp_area = .FALSE.
+         ELSE
+            ! the print control is done over a specific  area
+            lsp_area = .TRUE.
+            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
+               IF(lwp) WRITE(numout,cform_war)
+               IF(lwp) WRITE(numout,*)'          - nictls must be 1<=nictls>=jpiglo, it is forced to 1'
+               IF(lwp) WRITE(numout,*)
+               nwarn = nwarn + 1
+               nictls = 1
+            ENDIF
+
+            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
+               IF(lwp) WRITE(numout,cform_war)
+               IF(lwp) WRITE(numout,*)'          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo'
+               IF(lwp) WRITE(numout,*)
+               nwarn = nwarn + 1
+               nictle = jpjglo
+            ENDIF
+
+            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
+               IF(lwp) WRITE(numout,cform_war)
+               IF(lwp) WRITE(numout,*)'          - njctls must be 1<=njctls>=jpjglo, it is forced to 1'
+               IF(lwp) WRITE(numout,*)
+               nwarn = nwarn + 1
+               njctls = 1
+            ENDIF
+
+            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
+               IF(lwp) WRITE(numout,cform_war)
+               IF(lwp) WRITE(numout,*)'          - njctle must be 1<=njctle>= jpjglo, it is forced to jpjglo'
+               IF(lwp) WRITE(numout,*)
+               nwarn = nwarn + 1
+               njctle = jpjglo
+            ENDIF
+
+         ENDIF          ! IF( nictls+nictle+njctls+njctle == 0 )
+       ENDIF            ! IF(ln_ctl)
+
+! ... Control of output frequency
+      IF ( nstock == 0 ) THEN
+          IF(lwp)WRITE(numout,cform_war)
+          IF(lwp)WRITE(numout,*) '           nstock = ', nstock, ' it is forced to ', nitend
+          nstock = nitend
+          nwarn = nwarn + 1
+      ENDIF
+      IF ( nwrite == 0 ) THEN
+          IF(lwp)WRITE(numout,cform_war)
+          IF(lwp)WRITE(numout,*) '           nwrite = ', nwrite, ' it is forced to ', nitend
+          nwrite = nitend
+          nwarn = nwarn + 1
+      ENDIF
+
+      ! Read Namelist namzgr : vertical coordinate'
+      ! ---------------------
+      REWIND ( numnam )
+      READ   ( numnam, namzgr )
+
+      ! Parameter control and print
+      ! ---------------------------
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'Namelist namzgr : vertical coordinate'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '          Namelist namzgr : set vertical coordinate'
+         WRITE(numout,*) '             z-coordinate - full steps      ln_zco = ', ln_zco
+         WRITE(numout,*) '             z-coordinate - partial steps   ln_zps = ', ln_zps
+         WRITE(numout,*) '             s- or hybrid z-s-coordinate    ln_sco = ', ln_sco
+      ENDIF
+
+      ! Check Vertical coordinate options
+      ioptio = 0
+      IF( ln_zco ) ioptio = ioptio + 1
+      IF( ln_zps ) ioptio = ioptio + 1
+      IF( ln_sco ) ioptio = ioptio + 1
+      IF ( ioptio /= 1 ) CALL ctl_stop( ' none or several vertical coordinate options used' )
+
+      IF( ln_zco ) THEN
+          IF(lwp) WRITE(numout,*) '          z-coordinate with reduced incore memory requirement'
+          IF( ln_zps .OR. ln_sco ) CALL ctl_stop( ' reduced memory with zps or sco option is impossible' )
+      ENDIF
+
+
+      ! Namelist namdom : space/time domain (bathymetry, mesh, timestep)
+      REWIND( numnam )
+      READ  ( numnam, namdom )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '        Namelist namdom'
+         WRITE(numout,*) '           minimum thickness of partial   e3zps_min = ', e3zps_min, ' (m)'
+         WRITE(numout,*) '              step level                  e3zps_rat = ', e3zps_rat
+         WRITE(numout,*) '           flag write mesh/mask file(s)   nmsh      = ', nmsh
+         WRITE(numout,*) '                = 0   no file created                 '
+         WRITE(numout,*) '                = 1   mesh_mask                       '
+         WRITE(numout,*) '                = 2   mesh and mask                   '
+         WRITE(numout,*) '                = 3   mesh_hgr, msh_zgr and mask      '
+         WRITE(numout,*) '           acceleration of converge       nacc      = ', nacc
+         WRITE(numout,*) '           asselin time filter parameter  atfp      = ', atfp
+         WRITE(numout,*) '           time step                      rdt       = ', rdt
+         WRITE(numout,*) '           minimum time step on tracers   rdtmin    = ', rdtmin
+         WRITE(numout,*) '           maximum time step on tracers   rdtmax    = ', rdtmax
+         WRITE(numout,*) '           depth variation tracer step    rdth      = ', rdth
+      ENDIF
+
+
+
+      ! Default values
+      n_cla = 0
+
+      ! Namelist cross land advection
+      REWIND( numnam )
+      READ  ( numnam, namcla )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '        Namelist namcla'
+         WRITE(numout,*) '           cross land advection        n_cla        = ',n_cla
+      ENDIF
+
+   END SUBROUTINE dom_nam
+
+
+   SUBROUTINE dom_ctl
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_ctl  ***
+      !!
+      !! ** Purpose :   Domain control.
+      !!
+      !! ** Method  :   compute and print extrema of masked scale factors
+      !!
+      !! History :
+      !!   8.5  !  02-08  (G. Madec)    Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   iimi1, ijmi1, iimi2, ijmi2, iima1, ijma1, iima2, ijma2
+      INTEGER, DIMENSION(2) ::   iloc      ! 
+      REAL(wp) ::   ze1min, ze1max, ze2min, ze2max
+      !!----------------------------------------------------------------------
+
+      ! Extrema of the scale factors
+
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) 'dom_ctl : extrema of the masked scale factors'
+      IF(lwp)WRITE(numout,*) '~~~~~~~'
+
+      IF (lk_mpp) THEN
+         CALL mpp_minloc( e1t(:,:), tmask(:,:,1), ze1min, iimi1,ijmi1 )
+         CALL mpp_minloc( e2t(:,:), tmask(:,:,1), ze2min, iimi2,ijmi2 )
+         CALL mpp_maxloc( e1t(:,:), tmask(:,:,1), ze1max, iima1,ijma1 )
+         CALL mpp_maxloc( e2t(:,:), tmask(:,:,1), ze2max, iima2,ijma2 )
+      ELSE
+         ze1min = MINVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze2min = MINVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze1max = MAXVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze2max = MAXVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+
+         iloc  = MINLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iimi1 = iloc(1) + nimpp - 1
+         ijmi1 = iloc(2) + njmpp - 1
+         iloc  = MINLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iimi2 = iloc(1) + nimpp - 1
+         ijmi2 = iloc(2) + njmpp - 1
+         iloc  = MAXLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iima1 = iloc(1) + nimpp - 1
+         ijma1 = iloc(2) + njmpp - 1
+         iloc  = MAXLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iima2 = iloc(1) + nimpp - 1
+         ijma2 = iloc(2) + njmpp - 1
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, iima1, ijma1
+         WRITE(numout,"(14x,'e1t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1min, iimi1, ijmi1
+         WRITE(numout,"(14x,'e2t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2max, iima2, ijma2
+         WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, iimi2, ijmi2
+      ENDIF
+
+   END SUBROUTINE dom_ctl
+
+   !!======================================================================
+END MODULE domain
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domcfg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domcfg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domcfg.F90	(revision 1844)
@@ -0,0 +1,213 @@
+MODULE domcfg
+   !!==============================================================================
+   !!                       ***  MODULE domcfg   ***
+   !! Ocean initialization : domain configuration initialization
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_cfg        : initialize the domain configuration
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dom_cfg        ! called by opa.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_cfg
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_cfg  ***
+      !!                    
+      !! ** Purpose :   set the domain configuration
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!   9.0  !  03-09  (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   iconf = 0         ! temporary integers
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_cfg : set the ocean configuration'
+         WRITE(numout,*) '~~~~~~~      ocean model configuration used :',   &
+            &                             ' cp_cfg = ', cp_cfg, ' jp_cfg = ', jp_cfg
+      ENDIF
+
+      ! Global domain boundary conditions
+      ! ---------------------------------
+      IF(lwp) THEN
+         WRITE(numout,*) '          global domain lateral boundaries'
+
+         IF( jperio == 0 ) WRITE(numout,*) '             jperio= 0, closed'
+         IF( jperio == 1 ) WRITE(numout,*) '             jperio= 1, cyclic east-west'
+         IF( jperio == 2 ) WRITE(numout,*) '             jperio= 2, equatorial symmetric'
+         IF( jperio == 3 ) WRITE(numout,*) '             jperio= 3, north fold with T-point pivot'
+         IF( jperio == 4 ) WRITE(numout,*) '             jperio= 4, cyclic east-west and',   &
+                                                                  ' north fold with T-point pivot'
+         IF( jperio == 5 ) WRITE(numout,*) '             jperio= 5, north fold with F-point pivot'
+         IF( jperio == 6 ) WRITE(numout,*) '             jperio= 6, cyclic east-west and',   &
+                                                                  ' north fold with F-point pivot'
+      ENDIF
+      IF( jperio <  0 .OR. jperio > 6 ) CALL ctl_stop( 'jperio is out of range' )
+
+      ! global domain versus zoom and/or local domain
+      ! ---------------------------------------------
+
+      CALL dom_glo 
+
+   END SUBROUTINE dom_cfg
+
+
+   SUBROUTINE dom_glo
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_glo  ***
+      !!
+      !! ** Purpose :   initialization for global domain, zoom and local domain
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  : - mig  , mjg : 
+      !!              - mi0  , mi1   :
+      !!              - mj0, , mj1   :
+      !!
+      !! History :
+      !!   8.5  !  02-08  (G. Madec)    Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   ji, jj            ! dummy loop argument
+      !!----------------------------------------------------------------------
+
+      ! Local domain 
+      ! ============
+
+      ! local domain indices ==> data domain indices
+      DO ji = 1, jpi
+        mig(ji) = ji + jpizoom - 1 + nimpp - 1
+      END DO
+      DO jj = 1, jpj
+        mjg(jj) = jj + jpjzoom - 1 + njmpp - 1
+      END DO
+
+      ! data domain indices ==> local domain indices
+      ! (return (m.0,m.1)=(1,0) if data domain gridpoint is to the west/south of the 
+      ! local domain, or (m.0,m.1)=(jp.+1,jp.) to the east/north of local domain. 
+      DO ji = 1, jpidta
+        mi0(ji) = MAX( 1, MIN( ji - jpizoom + 1 - nimpp + 1, jpi+1 ) )
+        mi1(ji) = MAX( 0, MIN( ji - jpizoom + 1 - nimpp + 1, jpi   ) )
+      END DO
+      DO jj = 1, jpjdta
+        mj0(jj) = MAX( 1, MIN( jj - jpjzoom + 1 - njmpp + 1, jpj+1 ) )
+        mj1(jj) = MAX( 0, MIN( jj - jpjzoom + 1 - njmpp + 1, jpj   ) )
+      END DO
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_glo : domain: data / local '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '          data input domain    : jpidta = ', jpidta,   &
+            &                                            ' jpjdta = ', jpjdta, ' jpkdta = ', jpkdta
+         WRITE(numout,*) '          global or zoom domain: jpiglo = ', jpiglo,   &
+            &                                            ' jpjglo = ', jpjglo, ' jpk    = ', jpk
+         WRITE(numout,*) '          local domain         : jpi    = ', jpi   ,   &
+            &                                            ' jpj    = ', jpj   , ' jpk    = ', jpk
+         WRITE(numout,*)
+         WRITE(numout,*) '          south-west indices    jpizoom = ', jpizoom,   &
+            &                                           ' jpjzoom = ', jpjzoom
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion local  ==> data i-index domain'
+         WRITE(numout,25)              (mig(ji),ji = 1,jpi)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion data   ==> local  i-index domain'
+         WRITE(numout,*) '             starting index'
+         WRITE(numout,25)              (mi0(ji),ji = 1,jpidta)
+         WRITE(numout,*) '             ending index'
+         WRITE(numout,25)              (mi1(ji),ji = 1,jpidta)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion local  ==> data j-index domain'
+         WRITE(numout,25)              (mjg(jj),jj = 1,jpj)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion data  ==> local j-index domain'
+         WRITE(numout,*) '             starting index'
+         WRITE(numout,25)              (mj0(jj),jj = 1,jpjdta)
+         WRITE(numout,*) '             ending index'
+         WRITE(numout,25)              (mj1(jj),jj = 1,jpjdta)
+      ENDIF
+ 25   FORMAT( 100(10x,19i4,/) )
+
+      ! Zoom domain
+      ! ===========
+
+      ! zoom control
+      IF( jpiglo + jpizoom - 1  >  jpidta .OR.   &
+          jpjglo + jpjzoom - 1  >  jpjdta      ) &
+          &   CALL ctl_stop( ' global or zoom domain exceed the data domain ! ' )
+
+      ! set zoom flag
+      IF ( jpiglo < jpidta .OR. jpjglo < jpjdta )   lzoom = .TRUE.
+
+      ! set zoom type flags
+      IF( lzoom .AND. jpizoom /= 1 )   lzoom_w = .TRUE.                     ! 
+      IF( lzoom .AND. jpjzoom /= 1 )   lzoom_s = .TRUE.
+      IF( lzoom .AND. jpiglo + jpizoom -1 /= jpidta )   lzoom_e = .TRUE.
+      IF( lzoom .AND. jpjglo + jpjzoom -1 /= jpjdta )   lzoom_n = .TRUE.
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '          zoom flags : '
+         WRITE(numout,*) '             lzoom   = ', lzoom  , ' (T = zoom, F = global )'
+         WRITE(numout,*) '             lzoom_e = ', lzoom_e, ' (T = forced closed east  boundary)'
+         WRITE(numout,*) '             lzoom_w = ', lzoom_w, ' (T = forced closed west  boundary)'
+         WRITE(numout,*) '             lzoom_s = ', lzoom_s, ' (T = forced closed South boundary)'
+         WRITE(numout,*) '             lzoom_n = ', lzoom_n, ' (T = forced closed North boundary)'
+      ENDIF
+      IF(  ( lzoom_e .OR. lzoom_w )  .AND.  ( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 )  )   &
+           &   CALL ctl_stop( ' Your zoom choice is inconsistent with east-west cyclic boundary condition' )
+      IF(  lzoom_n  .AND.  ( 3 <= jperio .AND. jperio <= 6 )  )   &
+           &   CALL ctl_stop( ' Your zoom choice is inconsistent with North fold boundary condition' )
+
+
+      ! Pre-defined arctic/antarctic zoom of ORCA configuration flag
+      IF( cp_cfg == "orca" ) THEN
+         SELECT CASE ( jp_cfg )
+         !                                        ! =======================
+         CASE ( 2 )                               !  ORCA_R2 configuration
+            !                                     ! =======================
+            IF(  jpiglo  == 142    .AND. jpjglo  ==  53 .AND.   &
+               & jpizoom ==  21    .AND. jpjzoom ==  97         )   lzoom_arct = .TRUE.
+            IF(  jpiglo  == jpidta .AND. jpjglo  ==  50 .AND.   &
+               & jpizoom ==   1    .AND. jpjzoom ==   1         )   lzoom_anta = .TRUE.
+            !                                     ! =======================
+         CASE ( 05 )                              !  ORCA_R05 configuration
+            !                                     ! =======================
+            IF(  jpiglo  == 562    .AND. jpjglo  == 202 .AND.   &
+               & jpizoom ==  81    .AND. jpjzoom == 301         )   lzoom_arct = .TRUE.
+            IF(  jpiglo  == jpidta .AND. jpjglo  == 187 .AND.   &
+               & jpizoom ==   1    .AND. jpjzoom ==   1         )   lzoom_anta = .TRUE.
+         END SELECT
+         !
+         IF(lwp) WRITE(numout,*) '          ORCA configuration: antarctic/arctic zoom flags : '
+         IF(lwp) WRITE(numout,*) '             lzoom_arct = ', lzoom_arct, ' (T=   arctic zoom, F=global)'
+         IF(lwp) WRITE(numout,*) '             lzoom_anta = ', lzoom_anta, ' (T=antarctic zoom, F=global)'
+         !
+      ENDIF
+         
+   END SUBROUTINE dom_glo
+
+   !!======================================================================
+END MODULE domcfg
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dommsk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dommsk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/dommsk.F90	(revision 1844)
@@ -0,0 +1,178 @@
+MODULE dommsk
+   !!==============================================================================
+   !!                       ***  MODULE dommsk   ***
+   !! Ocean initialization : domain land/sea mask 
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_msk        : compute land/ocean mask
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dom_msk        ! routine called by inidom.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE dom_msk
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dom_msk  ***
+      !!
+      !! ** Purpose :   Compute land/ocean mask arrays at tracer points, hori-
+      !!      zontal velocity points (u & v), vorticity points (f) and baro-
+      !!      tropic stream function  points (b).
+      !!        Set mbathy to the number of non-zero w-levels of a water column
+      !!      (if island in the domain (lk_isl=T), this is done latter in
+      !!      routine solver_init)
+      !!
+      !! ** Method  :   The ocean/land mask is computed from the basin bathy-
+      !!      metry in level (mbathy) which is defined or read in dommba.
+      !!      mbathy equals 0 over continental T-point, -n over the nth 
+      !!      island T-point, and the number of ocean level over the ocean.
+      !!
+      !!      At a given position (ji,jj,jk) the ocean/land mask is given by:
+      !!      t-point : 0. IF mbathy( ji ,jj) =< 0
+      !!                1. IF mbathy( ji ,jj) >= jk
+      !!      u-point : 0. IF mbathy( ji ,jj)  or mbathy(ji+1, jj ) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy(ji+1, jj ) >= jk.
+      !!      v-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1) >= jk.
+      !!      f-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1)
+      !!                   or mbathy(ji+1,jj)  or mbathy(ji+1,jj+1) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1)
+      !!                and mbathy(ji+1,jj) and mbathy(ji+1,jj+1) >= jk.
+      !!      b-point : the same definition as for f-point of the first ocean
+      !!                level (surface level) but with 0 along coastlines.
+      !!
+      !!        The lateral friction is set through the value of fmask along
+      !!      the coast and topography. This value is defined by shlat, a
+      !!      namelist parameter:
+      !!         shlat = 0, free slip  (no shear along the coast)
+      !!         shlat = 2, no slip  (specified zero velocity at the coast)
+      !!         0 < shlat < 2, partial slip   | non-linear velocity profile
+      !!         2 < shlat, strong slip        | in the lateral boundary layer
+      !!
+      !!      N.B. If nperio not equal to 0, the land/ocean mask arrays
+      !!      are defined with the proper value at lateral domain boundaries,
+      !!      but bmask. indeed, bmask defined the domain over which the
+      !!      barotropic stream function is computed. this domain cannot
+      !!      contain identical columns because the matrix associated with
+      !!      the barotropic stream function equation is then no more inverti-
+      !!      ble. therefore bmask is set to 0 along lateral domain boundaries
+      !!      even IF nperio is not zero.
+      !!
+      !!      In case of open boundaries (lk_obc=T):
+      !!        - tmask is set to 1 on the points to be computed bay the open
+      !!          boundaries routines.
+      !!        - bmask is  set to 0 on the open boundaries.
+      !!
+      !!      Set mbathy to the number of non-zero w-levels of a water column
+      !!                  mbathy = min( mbathy, 1 ) + 1
+      !!      (note that the minimum value of mbathy is 2).
+      !!
+      !! ** Action :
+      !!                     tmask    : land/ocean mask at t-point (=0. or 1.)
+      !!                     umask    : land/ocean mask at u-point (=0. or 1.)
+      !!                     vmask    : land/ocean mask at v-point (=0. or 1.)
+      !!                     fmask    : land/ocean mask at f-point (=0. or 1.)
+      !!                          =shlat along lateral boundaries
+      !!                     bmask    : land/ocean mask at barotropic stream
+      !!                          function point (=0. or 1.) and set to
+      !!                          0 along lateral boundaries
+      !!                   mbathy   : number of non-zero w-levels 
+      !!
+      !! History :
+      !!        !  87-07  (G. Madec)  Original code
+      !!        !  91-12  (G. Madec)
+      !!        !  92-06  (M. Imbard)
+      !!        !  93-03  (M. Guyon)  symetrical conditions (M. Guyon)
+      !!        !  96-01  (G. Madec)  suppression of common work arrays
+      !!        !  96-05  (G. Madec)  mask computed from tmask and sup-
+      !!                 pression of the double computation of bmask
+      !!        !  97-02  (G. Madec)  mesh information put in domhgr.F
+      !!        !  97-07  (G. Madec)  modification of mbathy and fmask
+      !!        !  98-05  (G. Roullet)  free surface
+      !!        !  00-03  (G. Madec)  no slip accurate
+      !!        !  01-09  (J.-M. Molines)  Open boundaries
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! *Local declarations
+      INTEGER  ::   ji, jk     ! dummy loop indices
+      INTEGER  ::   iif, iil, ijf, ijl
+      INTEGER, DIMENSION(jpi,jpj) ::  imsk
+
+      !!---------------------------------------------------------------------
+      
+
+
+      ! Interior domain mask (used for global sum)
+      ! --------------------
+
+      tmask_i(:,:) = tmask(:,:,1)
+      iif = jpreci                         ! ???
+      iil = nlci - jpreci + 1
+      ijf = jprecj                         ! ???
+      ijl = nlcj - jprecj + 1
+
+      tmask_i( 1 :iif,   :   ) = 0.e0      ! first columns
+      tmask_i(iil:jpi,   :   ) = 0.e0      ! last  columns (including mpp extra columns)
+      tmask_i(   :   , 1 :ijf) = 0.e0      ! first rows
+      tmask_i(   :   ,ijl:jpj) = 0.e0      ! last  rows (including mpp extra rows)
+
+
+      ! north fold mask
+      tpol(1:jpiglo) = 1.e0 
+      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
+         tpol(jpiglo/2+1:jpiglo) = 0.e0
+      ENDIF
+      IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
+         tpol(     1    :jpiglo) = 0.e0
+      ENDIF
+
+      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot: only half of the nlcj-1 row
+         if (mjg(ijl-1) == jpjglo-1) then
+         DO ji = iif+1, iil-1
+            tmask_i(ji,ijl-1) = tmask_i(ji,ijl-1) * tpol(mig(ji))
+         END DO
+         endif
+      ENDIF 
+
+      ! Control print
+      ! -------------
+      IF( nprint == 1 .AND. lwp ) THEN
+         imsk(:,:) = INT( tmask_i(:,:) )
+         WRITE(numout,*) ' tmask_i : '
+         CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                           1, jpj, 1, 1, numout)
+         WRITE (numout,*)
+         WRITE (numout,*) ' dommsk: tmask for each level'
+         WRITE (numout,*) ' ----------------------------'
+         DO jk = 1, jpk
+            imsk(:,:) = INT( tmask(:,:,jk) )
+
+            WRITE(numout,*)
+            WRITE(numout,*) ' level = ',jk
+            CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                              1, jpj, 1, 1, numout)
+         END DO
+      ENDIF
+
+   END SUBROUTINE dom_msk
+
+END MODULE dommsk
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domngb.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domngb.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domngb.F90	(revision 1844)
@@ -0,0 +1,76 @@
+MODULE domngb
+   !!======================================================================
+   !!                       ***  MODULE  domngb  ***
+   !! Grid search:  find the closest grid point from a given on/lat position
+   !!======================================================================
+   !! History : 3.2  !  2009-11  (S. Masson)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_ngb       : find the closest grid point from a given on/lat position
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE lib_mpp         ! for mppsum
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_ngb    ! routine called in iom.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2008) 
+   !! $Id: domngb.F90 1725 2009-11-12 15:04:08Z smasson $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_ngb( plon, plat, kii, kjj, cdgrid )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dom_ngb  ***
+      !!
+      !! ** Purpose :   find the closest grid point from a given on/lat position
+      !!
+      !! ** Method  :   look for minimum distance in cylindrical projection 
+      !!                -> not good if located at too high latitude...
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp)        , INTENT(in   ) ::   plon, plat   ! longitude,latitude of the point
+      INTEGER         , INTENT(  out) ::   kii, kjj     ! i-,j-index of the closes grid point
+      CHARACTER(len=1), INTENT(in   ) ::   cdgrid       ! grid name 'T', 'U', 'V', 'W'
+      !!
+      INTEGER , DIMENSION(2)        ::   iloc
+      REAL(wp), DIMENSION(jpi,jpj)  ::   zglam, zgphi, zmask, zdist
+      REAL(wp)                      ::   zlon
+      REAL(wp)                      ::   zmini
+      !!--------------------------------------------------------------------
+      
+      zmask(:,:) = 0.
+      SELECT CASE( cdgrid )
+      CASE( 'U' )  ; zglam(:,:) = glamu(:,:) ; zgphi(:,:) = gphiu(:,:) ; zmask(nldi:nlei,nldj:nlej) = umask(nldi:nlei,nldj:nlej,1)
+      CASE( 'V' )  ; zglam(:,:) = glamv(:,:) ; zgphi(:,:) = gphiv(:,:) ; zmask(nldi:nlei,nldj:nlej) = vmask(nldi:nlei,nldj:nlej,1)
+      CASE( 'F' )  ; zglam(:,:) = glamf(:,:) ; zgphi(:,:) = gphif(:,:) ; zmask(nldi:nlei,nldj:nlej) = fmask(nldi:nlei,nldj:nlej,1)
+      CASE DEFAULT ; zglam(:,:) = glamt(:,:) ; zgphi(:,:) = gphit(:,:) ; zmask(nldi:nlei,nldj:nlej) = tmask(nldi:nlei,nldj:nlej,1)
+      END SELECT
+
+      zlon       = MOD( plon       + 720., 360. )                                     ! plon between    0 and 360
+      zglam(:,:) = MOD( zglam(:,:) + 720., 360. )                                     ! glam between    0 and 360
+      IF( zlon > 270. )   zlon = zlon - 360.                                          ! zlon between  -90 and 270
+      IF( zlon <  90. )   WHERE( zglam(:,:) > 180. ) zglam(:,:) = zglam(:,:) - 360.   ! glam between -180 and 180
+
+      zglam(:,:) = zglam(:,:) - zlon
+      zgphi(:,:) = zgphi(:,:) - plat
+      zdist(:,:) = zglam(:,:) * zglam(:,:) + zgphi(:,:) * zgphi(:,:)
+      
+      IF( lk_mpp ) THEN  
+         CALL mpp_minloc( zdist(:,:), zmask, zmini, kii, kjj)
+      ELSE
+         iloc(:) = MINLOC( zdist(:,:), mask = zmask(:,:) == 1.e0 )
+         kii = iloc(1) + nimpp - 1
+         kjj = iloc(2) + njmpp - 1
+      ENDIF
+
+   END SUBROUTINE dom_ngb
+
+   !!======================================================================
+END MODULE domngb
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea.F90	(revision 1844)
@@ -0,0 +1,337 @@
+MODULE domrea
+   !!======================================================================
+   !!                       ***  MODULE domrea  ***
+   !! Ocean initialization : read the ocean domain meshmask file(s)
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_rea        : read mesh and mask file(s)
+   !!                    nmsh = 1  :   mesh_mask file
+   !!                         = 2  :   mesh and mask file
+   !!                         = 3  :   mesh_hgr, mesh_zgr and mask
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC dom_rea        ! routine called by inidom.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_fdir
+   !!----------------------------------------------------------------------
+   !!   'key_fdir' :                                     direct access file
+   !!----------------------------------------------------------------------
+#  include "domrea_fdir.h90"
+
+#elif ( defined key_mpp_mpi || defined key_mpp_shmem ) && defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'     OR
+   !!   'key_mpp_shmem'
+   !!   'key_dimgout' :         each processor makes its own direct access file 
+   !!                      use build_nc_meshmask off line to retrieve 
+   !!                      a ioipsl compliant meshmask file
+   !!----------------------------------------------------------------------
+#  include "domrea_dimg.h90"
+
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                        NetCDF file
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE dom_rea
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_rea  ***
+      !!                   
+      !! ** Purpose :  Read the NetCDF file(s) which contain(s) all the
+      !!      ocean domain informations (mesh and mask arrays). This (these)
+      !!      file(s) is (are) used for visualisation (SAXO software) and
+      !!      diagnostic computation.
+      !!
+      !! ** Method  :   Read in a file all the arrays generated in routines
+      !!      domhgr, domzgr, and dommsk. Note: the file contain depends on
+      !!      the vertical coord. used (z-coord, partial steps, s-coord)
+      !!                    nmsh = 1  :   'mesh_mask.nc' file
+      !!                         = 2  :   'mesh.nc' and mask.nc' files
+      !!                         = 3  :   'mesh_hgr.nc', 'mesh_zgr.nc' and
+      !!                                  'mask.nc' files
+      !!      For huge size domain, use option 2 or 3 depending on your 
+      !!      vertical coordinate.
+      !!
+      !! ** input file : 
+      !!      meshmask.nc  : domain size, horizontal grid-point position,
+      !!                     masks, depth and vertical scale factors
+      !!
+      !! History :
+      !!        !  97-02  (G. Madec)  Original code
+      !!        !  99-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
+      !!   9.0  !  02-08  (G. Madec)  F90 and several file
+      !!        !  06-07  (C. Ethe )  Use of iom module
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk
+      INTEGER  ::                & !!! * temprary units for :
+         inum0 ,                 &  ! 'mesh_mask.nc' file
+         inum1 ,                 &  ! 'mesh.nc'      file
+         inum2 ,                 &  ! 'mask.nc'      file
+         inum3 ,                 &  ! 'mesh_hgr.nc'  file
+         inum4                      ! 'mesh_zgr.nc'  file
+ 
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zprt
+#if ! defined key_zco
+      INTEGER :: ik
+#endif
+      !!----------------------------------------------------------------------
+
+       IF(lwp) WRITE(numout,*)
+       IF(lwp) WRITE(numout,*) 'dom_rea : read NetCDF mesh and mask information file(s)'
+       IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+
+      zprt(:,:) = 0.
+
+      SELECT CASE (nmsh)
+         !                                     ! ============================
+         CASE ( 1 )                            !  create 'mesh_mask.nc' file
+            !                                  ! ============================
+
+            IF(lwp) WRITE(numout,*) '          one file in "mesh_mask.nc" '
+            CALL iom_open( 'mesh_mask', inum0 )
+
+            inum2 = inum0                                            ! put all the informations
+            inum3 = inum0                                            ! in unit inum0
+            inum4 = inum0
+
+            !                                  ! ============================
+         CASE ( 2 )                            !  create 'mesh.nc' and 
+            !                                  !         'mask.nc' files
+            !                                  ! ============================
+
+            IF(lwp) WRITE(numout,*) '          two files in "mesh.nc" and "mask.nc" '
+            CALL iom_open( 'mesh', inum1 )
+            CALL iom_open( 'mask', inum2 )
+
+            inum3 = inum1                                            ! put mesh informations 
+            inum4 = inum1                                            ! in unit inum1 
+
+            !                                  ! ============================
+         CASE ( 3 )                            !  create 'mesh_hgr.nc'
+            !                                  !         'mesh_zgr.nc' and
+            !                                  !         'mask.nc'     files
+            !                                  ! ============================
+
+            IF(lwp) WRITE(numout,*) '          three files in "mesh_hgr.nc" , mesh_zgr.nc" and "mask.nc" '
+            CALL iom_open( 'mesh_hgr', inum3 ) ! create 'mesh_hgr.nc'
+            CALL iom_open( 'mesh_zgr', inum4 ) ! create 'mesh_zgr.nc'
+            CALL iom_open( 'mask'    , inum2 ) ! create 'mask.nc'
+
+         END SELECT
+
+         !                                                         ! masks (inum2) 
+         CALL iom_get( inum2, jpdom_data, 'tmask', tmask )
+         CALL iom_get( inum2, jpdom_data, 'umask', umask )
+         CALL iom_get( inum2, jpdom_data, 'vmask', vmask )
+         CALL iom_get( inum2, jpdom_data, 'fmask', fmask )
+
+#if defined key_c1d
+         ! set umask and vmask equal tmask in 1D configuration
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '**********  1D configuration : set umask and vmask equal tmask ********'
+         IF(lwp) WRITE(numout,*) '**********                                                     ********'
+
+         umask(:,:,:) = tmask(:,:,:)
+         vmask(:,:,:) = tmask(:,:,:)
+#endif
+
+#if defined key_off_degrad
+         CALL iom_get( inum2, jpdom_data, 'facvolt', facvol )
+#endif
+
+         !                                                         ! horizontal mesh (inum3)
+         CALL iom_get( inum3, jpdom_data, 'glamt', glamt )
+         CALL iom_get( inum3, jpdom_data, 'glamu', glamu )
+         CALL iom_get( inum3, jpdom_data, 'glamv', glamv )
+         CALL iom_get( inum3, jpdom_data, 'glamf', glamf )
+
+         CALL iom_get( inum3, jpdom_data, 'gphit', gphit )
+         CALL iom_get( inum3, jpdom_data, 'gphiu', gphiu )
+         CALL iom_get( inum3, jpdom_data, 'gphiv', gphiv )
+         CALL iom_get( inum3, jpdom_data, 'gphif', gphif )
+
+         CALL iom_get( inum3, jpdom_data, 'e1t', e1t )
+         CALL iom_get( inum3, jpdom_data, 'e1u', e1u )
+         CALL iom_get( inum3, jpdom_data, 'e1v', e1v )
+         
+         CALL iom_get( inum3, jpdom_data, 'e2t', e2t )
+         CALL iom_get( inum3, jpdom_data, 'e2u', e2u )
+         CALL iom_get( inum3, jpdom_data, 'e2v', e2v )
+
+         CALL iom_get( inum3, jpdom_data, 'ff', ff )
+
+         CALL iom_get( inum4, jpdom_data, 'mbathy', zprt )
+     
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               mbathy(ji,jj) = MAX( zprt(ji,jj) * tmask(ji,jj,1), 1. ) + 1
+            ENDDO
+         ENDDO
+
+#if ! defined key_zco
+
+         IF( ln_sco ) THEN                                         ! s-coordinate
+            CALL iom_get( inum4, jpdom_data, 'hbatt', hbatt )
+            CALL iom_get( inum4, jpdom_data, 'hbatu', hbatu )
+            CALL iom_get( inum4, jpdom_data, 'hbatv', hbatv )
+            CALL iom_get( inum4, jpdom_data, 'hbatf', hbatf )
+            
+            CALL iom_get( inum4, jpdom_unknown, 'gsigt', gsigt ) ! scaling coef.
+            CALL iom_get( inum4, jpdom_unknown, 'gsigw', gsigw )
+            CALL iom_get( inum4, jpdom_unknown, 'gsi3w', gsi3w ) 
+            CALL iom_get( inum4, jpdom_unknown, 'esigt', esigt )
+            CALL iom_get( inum4, jpdom_unknown, 'esigw', esigw )
+
+            CALL iom_get( inum4, jpdom_data, 'e3t', e3t ) ! scale factors
+            CALL iom_get( inum4, jpdom_data, 'e3u', e3u )
+            CALL iom_get( inum4, jpdom_data, 'e3v', e3v )
+            CALL iom_get( inum4, jpdom_data, 'e3w', e3w )
+
+            CALL iom_get( inum4, jpdom_unknown, 'gdept_0', gdept_0 ) ! depth
+            CALL iom_get( inum4, jpdom_unknown, 'gdepw_0', gdepw_0 )
+         ENDIF
+
+ 
+         IF( ln_zps ) THEN   
+            ! Vertical coordinates and scales factors
+            CALL iom_get( inum4, jpdom_unknown, 'gdept_0', gdept_0 ) ! depth
+            CALL iom_get( inum4, jpdom_unknown, 'gdepw_0', gdepw_0 )
+            CALL iom_get( inum4, jpdom_unknown, 'e3t_0'  , e3t_0   )
+            CALL iom_get( inum4, jpdom_unknown, 'e3w_0'  , e3w_0   )
+                                      ! z-coordinate - partial steps
+            IF( nmsh <= 6 ) THEN                                   !    ! 3D vertical scale factors
+              CALL iom_get( inum4, jpdom_data, 'e3t', e3t ) ! scale factors
+              CALL iom_get( inum4, jpdom_data, 'e3u', e3u )
+              CALL iom_get( inum4, jpdom_data, 'e3v', e3v )
+              CALL iom_get( inum4, jpdom_data, 'e3w', e3w )
+            ELSE                                                   !    ! 2D bottom scale factors
+              CALL iom_get( inum4, jpdom_data, 'e3t_ps', e3tp )
+              CALL iom_get( inum4, jpdom_data, 'e3w_ps', e3wp )
+            END IF
+
+            IF( iom_varid( inum4, 'gdept', ldstop = .FALSE. ) > 0 ) THEN
+              CALL iom_get( inum4, jpdom_data, 'gdept', gdept ) ! scale factors
+              CALL iom_get( inum4, jpdom_data, 'gdepw', gdepw )
+            ELSE                                                   !    ! 2D bottom depth
+              CALL iom_get( inum4, jpdom_data, 'hdept', hdept )   ! depth
+              CALL iom_get( inum4, jpdom_data, 'hdepw', hdepw )
+         
+              DO jk = 1,jpk
+                gdept(:,:,jk) = gdept_0(jk)
+                gdepw(:,:,jk) = gdepw_0(jk)
+              ENDDO
+
+              DO jj = 1, jpj
+                DO ji = 1, jpi
+                  ik = mbathy(ji,jj) - 1
+                  ! ocean point only 
+                  IF( ik > 0 ) THEN
+                     ! max ocean level case
+                     gdepw(ji,jj,ik+1) = hdepw(ji,jj)
+                     gdept(ji,jj,ik  ) = hdept(ji,jj)
+                     gdept(ji,jj,ik+1) = gdept(ji,jj,ik) + e3t(ji,jj,ik)
+                  ENDIF
+                END DO
+              END DO
+
+            ENDIF
+
+         ENDIF
+# endif
+         IF( ln_zco ) THEN
+           ! Vertical coordinates and scales factors
+           CALL iom_get( inum4, jpdom_unknown, 'gdept_0', gdept_0 ) ! depth
+           CALL iom_get( inum4, jpdom_unknown, 'gdepw_0', gdepw_0 )
+           CALL iom_get( inum4, jpdom_unknown, 'e3t_0'  , e3t_0   )
+           CALL iom_get( inum4, jpdom_unknown, 'e3w_0'  , e3w_0   )
+         ENDIF
+
+
+      ! Control printing : Grid informations (if not restart)
+      ! ----------------
+
+      IF(lwp .AND. .NOT.ln_rstart ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '          longitude and e1 scale factors'
+         WRITE(numout,*) '          ------------------------------'
+         WRITE(numout,9300) ( ji, glamt(ji,1), glamu(ji,1),   &
+            glamv(ji,1), glamf(ji,1),   &
+            e1t(ji,1), e1u(ji,1),   &
+            e1v(ji,1), ji = 1, jpi,10)
+9300     FORMAT( 1x, i4, f8.2,1x, f8.2,1x, f8.2,1x, f8.2, 1x,    &
+            f19.10, 1x, f19.10, 1x, f19.10 )
+
+         WRITE(numout,*)
+         WRITE(numout,*) '          latitude and e2 scale factors'
+         WRITE(numout,*) '          -----------------------------'
+         WRITE(numout,9300) ( jj, gphit(1,jj), gphiu(1,jj),   &
+            &                     gphiv(1,jj), gphif(1,jj),   &
+            &                     e2t  (1,jj), e2u  (1,jj),   &
+            &                     e2v  (1,jj), jj = 1, jpj, 10 )
+      ENDIF
+
+
+      IF( nprint == 1 .AND. lwp ) THEN
+         WRITE(numout,*) '          e1u e2u '
+         CALL prihre( e1u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         CALL prihre( e2u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         WRITE(numout,*) '          e1v e2v  '
+         CALL prihre( e1v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         CALL prihre( e2v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level   gdept    gdepw     e3t      e3w  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, gdept_0(jk), gdepw_0(jk), e3t_0(jk), e3w_0(jk), jk = 1, jpk )
+      ENDIF
+
+      DO jk = 1, jpk
+         IF( e3w_0(jk) <= 0. .OR. e3t_0(jk) <= 0. ) CALL ctl_stop ( ' e3w_0 or e3t_0 =< 0 ' )
+         IF( gdepw_0(jk) < 0. .OR. gdept_0(jk) < 0.) CALL ctl_stop( ' gdepw_0 or gdept_0 < 0 ' )
+      END DO
+
+         !                                     ! ============================
+         !                                     !        close the files 
+         !                                     ! ============================
+         SELECT CASE ( nmsh )
+            CASE ( 1 )                
+               CALL iom_close( inum0 )
+            CASE ( 2 )
+               CALL iom_close( inum1 )
+               CALL iom_close( inum2 )
+            CASE ( 3 )
+               CALL iom_close( inum2 )
+               CALL iom_close( inum3 )
+               CALL iom_close( inum4 )
+         END SELECT
+
+   END SUBROUTINE dom_rea
+
+#endif
+
+   !!======================================================================
+END MODULE domrea
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_dimg.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_dimg.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_dimg.h90	(revision 1844)
@@ -0,0 +1,432 @@
+   SUBROUTINE dom_rea
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_rea  ***   'key_mpp'
+      !!
+      !! ** Purpose :   READ the direct access files which contains all the
+      !!      ocean domain informations (mesh and mask arrays). These
+      !!      files are used for visualisation (SAXO software) and
+      !!      diagnostic computation.
+      !!
+      !! ** Method  :   READ in a file all the arrays generated in routines
+      !!      domhgr, domzgr, and dommsk. Note: the file contain depends on
+      !!      the vertical coord. used (z-coord, partial steps, s-coord)
+      !!    For mpp output direct access files are used and each processor
+      !!    uses a record range. Off line program (build_nc_meshmask) can be used
+      !!    to reconstruct the Netcdf files
+      !!                    nmsh = 1  :   'mesh_mask.nc' file
+      !!                         = 2  :   'mesh.nc' and mask.nc' files
+      !!                         = 3  :   'mesh_hgr.nc', 'mesh_zgr.nc' and
+      !!                                  'mask.nc' files
+      !!      For huge size domain, use option 2 or 3 depending on your
+      !!      vertical coordinate.
+      !!
+      !! ** output file :
+      !!      meshmask.nc  : domain size, horizontal grid-point position,
+      !!                     masks, depth and vertical scale factors
+      !!
+      !! History :
+      !!        !  97-02  (G. Madec)  Original code
+      !!        !  99-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
+      !!   9.0  !  02-08  (G. Madec)  F90 and several file
+      !!        !  04-01  (J.M. Molines) MPP i/o
+      !!----------------------------------------------------------------------
+      !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+      !!   $Id$
+      !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE lib_mpp
+      USE dom_oce         ! ocean space and time domain
+
+      !! * Local declarations
+      !! * Local declarations
+      INTEGER  ::                & !!! * temprary units for :
+         inum0 ,                 &  ! 'mesh_mask.nc' file
+         inum1 ,                 &  ! 'mesh.nc'      file
+         inum2 ,                 &  ! 'mask.nc'      file
+         inum3 ,                 &  ! 'mesh_hgr.nc'  file
+         inum4                      ! 'mesh_zgr.nc'  file
+      INTEGER  ::   itime           !  output from restini ???
+      INTEGER  ::   irecl8, irec    ! Record length (bytes) for output file 
+      INTEGER  ::   jk              ! loop index
+      INTEGER  ::   ios1, ios2
+      INTEGER, DIMENSION(11:15)  :: irecv ! index of this array will be inumxxx
+      REAL(wp) ::   zdate0
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zprt                       ! temporary array for bathymetry
+
+      CHARACTER (len=21) ::      &
+         clnam0 = 'mesh_mask',   &  ! filename (mesh and mask informations)
+         clnam1 = 'mesh'     ,   &  ! filename (mesh informations)
+         clnam2 = 'mask'     ,   &  ! filename (mask informations)
+         clnam3 = 'mesh_hgr' ,   &  ! filename (horizontal mesh informations)
+         clnam4 = 'mesh_zgr'        ! filename (vertical   mesh informations)
+      !!----------------------------------------------------------------------
+
+       IF(lwp) WRITE(numout,*)
+       IF(lwp) WRITE(numout,*) 'dom_rea : read direct access  mesh and mask information files'
+       IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+       inum0 = 11
+       irecl8 = jpi*jpj*wp
+       ios1 = 0 ; ios2 = 0
+       IF (ln_zps ) ios1= 1 
+       IF (ln_sco ) ios2= 1
+   
+       SELECT CASE (nmsh )
+          !                                    !==============================
+          CASE ( 1 )                           !  read 'mesh_mask' file
+             !                                 !==============================
+             IF (lwp) WRITE(numout,*) '          one file in "mesh_mask.dimgproc '
+             OPEN(inum0,FILE=trim(clnam0)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp )READ(inum0,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+
+             inum2 = inum0
+             inum3 = inum0
+             inum4 = inum0
+
+            !                                  ! ============================
+         CASE ( 2 )                            !  read 'mesh' and
+            !                                  !         'mask' files
+            !                                  ! ============================
+
+            IF(lwp) WRITE(numout,*) '          two files in "mesh" and "mask" '
+            inum1 = 12
+            inum2 = 13
+            OPEN(inum1,FILE=trim(clnam1)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp) READ(inum1,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+
+             inum3 = inum1
+             inum4 = inum1
+            OPEN(inum2,FILE=trim(clnam2)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp) READ(inum2,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+
+            !                                  ! ============================
+         CASE ( 3 )                            !  read 'mesh_hgr'
+            !                                  !         'mesh_zgr' and
+            !                                  !         'mask'     files
+            !                                  ! ============================
+
+            IF(lwp) WRITE(numout,*) '          three files in "mesh_hgr" , mesh_zgr" and "mask" '
+            inum3 = 14
+            inum2 = 13
+            inum4 = 15
+
+            OPEN(inum3,FILE=trim(clnam3)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp) READ(inum3,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+
+            OPEN(inum2,FILE=trim(clnam2)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp) READ(inum2,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+
+            OPEN(inum4,FILE=trim(clnam4)//'.mpp', &
+                & FORM='UNFORMATTED', ACCESS='DIRECT', RECL = irecl8 )
+             IF (lwp) READ(inum4,REC=1 ) irecl8, nmsh, ios1,ios2 , &
+            &  ndastp, adatrj, jpi,jpj,jpk,  &
+            &  jpni,jpnj,jpnij,jpiglo,jpjglo, &
+            &  nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+         
+         END SELECT
+       
+         irecv(:) = 2
+         ! tmask
+         DO jk=1,jpk
+             irec=irecv(inum2) + (jk -1 ) + jpk * (narea - 1 )
+             READ(inum2,REC=irec) tmask(:,:,jk)
+         END DO
+         irecv(inum2) = irecv(inum2) + jpk * jpnij 
+         !
+         ! umask
+         DO jk=1,jpk
+             irec=irecv(inum2) + (jk -1 ) + jpk * (narea - 1 )
+             READ(inum2,REC=irec) umask(:,:,jk)
+         END DO
+         irecv(inum2) = irecv(inum2) + jpk * jpnij 
+         !
+         ! vmask
+         DO jk=1,jpk
+             irec=irecv(inum2) + (jk -1 ) + jpk * (narea - 1 )
+             READ(inum2,REC=irec) vmask(:,:,jk)
+         END DO
+         irecv(inum2) = irecv(inum2) + jpk * jpnij 
+         !
+         ! fmask
+         DO jk=1,jpk
+             irec=irecv(inum2) + (jk -1 ) + jpk * (narea - 1 )
+             READ(inum2,REC=irec) fmask(:,:,jk)
+         END DO
+         irecv(inum2) = irecv(inum2) + jpk * jpnij 
+         !
+         ! glam
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) glamt(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+       
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) glamu(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) glamv(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) glamf(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+         !
+         ! gphi
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) gphit(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+       
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) gphiu(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) gphiv(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) gphif(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+         !
+         ! e1
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e1t(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+       
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e1u(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e1v(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e1f(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+         !
+         ! e2
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e2t(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+       
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e2u(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e2v(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) e2f(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+         !
+         ! ff
+         irec = irecv(inum3) + (narea - 1 )
+         READ(inum3,REC=irec) ff(:,:)
+         irecv(inum3) = irecv(inum3) + jpnij 
+         !
+         ! mbathy
+         !       note that mbathy has been modified in dommsk or in solver.
+         !       it is the number of non-zero "w" levels in the water, and the minimum
+         !       value (on land) is 2. We define zprt as the number of "T" points in the ocean
+         !       at any location, and zero on land.
+         !
+         irec = irecv(inum4) + (narea - 1 )
+         READ(inum4,REC=irec) zprt(:,:)
+         irecv(inum4) = irecv(inum4) + jpnij 
+
+          mbathy=zprt*tmask(:,:,1)+1
+
+#if ! defined key_zco
+          IF( ln_sco ) THEN                                         ! s-coordinate
+             !
+             ! hbat
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hbatt(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hbatu(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hbatv(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hbatf(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             !
+             ! gsig and esig ( as vectors of jpk per record )
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gsigt(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gsigw(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gsi3w(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) esigt(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) esigw(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+
+             ! e3 (3D)
+             DO jk=1,jpk
+                irec =  irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3t(:,:,jk)
+             ENDIF
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             DO jk=1,jpk
+                irec =  irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3u(:,:,jk)
+             ENDIF
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             DO jk=1,jpk
+                irec =  irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3v(:,:,jk)
+             ENDIF
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             DO jk=1,jpk
+                irec =  irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3w(:,:,jk)
+             ENDIF
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+
+             ! gdep
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gdept_0(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gdepw_0(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             !
+          ENDIF
+             
+          IF( ln_zps ) THEN
+             !
+             ! hdep
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hdept(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec = irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) hdepw(:,:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             !
+             ! e3t_ps (3D)
+             DO jk=1,jpk
+                irec=irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3t(:,:,jk)
+             END DO
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             ! e3u_ps e3v_ps e3w_ps (3D)
+             DO jk=1,jpk
+                irec=irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3u(:,:,jk)
+             END DO
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             DO jk=1,jpk
+                irec=irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3v(:,:,jk)
+             END DO
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             
+             DO jk=1,jpk
+                irec=irecv(inum4) + (jk -1 ) + jpk * (narea - 1 )
+                READ(inum4,REC=irec) e3w(:,:,jk)
+             END DO
+             irecv(inum4) = irecv(inum4) + jpk * jpnij 
+             ! 
+             ! 
+             ! gdep
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gdept_0(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) gdepw_0(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             !
+             ! e3
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) e3t_0(:)
+             irecv(inum4) = irecv(inum4) + jpnij 
+             
+             irec =  irecv(inum4) + (narea - 1 )
+             READ(inum4,REC=irec) e3w_0(:)
+          ENDIF
+#else
+          !
+          ! gdep
+          irec =  irecv(inum4) + (narea - 1 )
+          READ(inum4,REC=irec) gdept_0(:)
+          irecv(inum4) = irecv(inum4) + jpnij 
+          
+          irec =  irecv(inum4) + (narea - 1 )
+          READ(inum4,REC=irec) gdepw_0(:)
+          irecv(inum4) = irecv(inum4) + jpnij 
+          !
+          ! e3
+          irec =  irecv(inum4) + (narea - 1 )
+          READ(inum4,REC=irec) e3t_0(:)
+          irecv(inum4) = irecv(inum4) + jpnij 
+          
+          irec =  irecv(inum4) + (narea - 1 )
+          READ(inum4,REC=irec) e3w_0(:)
+          irecv(inum4) = irecv(inum4) + jpnij 
+         !
+#endif
+         !                                     ! ============================
+         !                                     !        close the files
+         !                                     ! ============================
+         SELECT CASE ( nmsh )
+            CASE ( 1 )
+               CLOSE ( inum0 )
+            CASE ( 2 )
+               CLOSE ( inum1 )
+               CLOSE ( inum2 )
+            CASE ( 3 )
+               CLOSE ( inum2 )
+               CLOSE ( inum3 )
+               CLOSE ( inum4 )
+         END SELECT
+
+   END SUBROUTINE dom_rea
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_fdir.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_fdir.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domrea_fdir.h90	(revision 1844)
@@ -0,0 +1,100 @@
+   !!----------------------------------------------------------------------
+   !!                     ***  domrea_fdir.h90  ***
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE dom_rea
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_rea  ***
+      !!                   
+      !! ** Purpose :   Read a direct access file named meshmask
+      !!        This file contains all ocean domain informations (mesh and
+      !!      mask arrays). It is used for visualisation (SAXO software)
+      !!      and diagnostic computation.
+      !!        Caution, this file is not assigned so that diagnostics can
+      !!      be computed with a 64 bits precision.
+      !!
+      !! History :
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      CHARACTER (len=5) ::   clfield  ! field name
+      INTEGER ::   inum = 11          ! logical unit used for meshmask file
+      INTEGER :: iimlu,ijmlu,ikmlu
+      !!----------------------------------------------------------------------
+
+       IF(lwp) WRITE(numout,*)
+       IF(lwp) WRITE(numout,*) 'dom_rea : read a direct acces mesh_mask file'
+       IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+       ! open meshmask file
+       CALL ctlopn( inum, 'mesh_mask','UNKNOWN', 'UNFORMATTED', 'SEQUENTIAL',   &
+                    1 , numout, lwp, 1 )
+
+
+      ! 0. Domain size
+      ! --------------
+      read(inum) iimlu, ijmlu, ikmlu
+
+
+      ! 1. Horzontal grid-point position
+      ! --------------------------------
+      clfield='GLAMT'   ;    READ(inum) clfield, glamt
+      clfield='GLAMU'   ;    READ(inum) clfield, glamu
+      clfield='GLAMV'   ;    READ(inum) clfield, glamv
+      clfield='GLAMF'   ;    READ(inum) clfield, glamf
+
+      clfield='GPHIT'   ;    READ(inum) clfield, gphit
+      clfield='GPHIU'   ;    READ(inum) clfield, gphiu
+      clfield='GPHIV'   ;    READ(inum) clfield, gphiv
+      clfield='GPHIF'   ;    READ(inum) clfield, gphif
+
+
+      ! 2. Horizontal scale factors
+      ! ---------------------------
+      clfield='E1T  '   ;    READ(inum) clfield, e1t
+      clfield='E1U  '   ;    READ(inum) clfield, e1u
+      clfield='E1V  '   ;    READ(inum) clfield, e1v
+      clfield='E1F  '   ;    READ(inum) clfield, e1f
+
+      clfield='E2T  '   ;    READ(inum) clfield, e2t
+      clfield='E2U  '   ;    READ(inum) clfield, e2u
+      clfield='E2V  '   ;    READ(inum) clfield, e2v
+      clfield='E2F  '   ;    READ(inum) clfield, e2f
+
+
+      ! 3. masks
+      ! --------
+      clfield='TMASK'   ;    READ(inum) clfield, tmask
+      clfield='UMASK'   ;    READ(inum) clfield, umask
+      clfield='VMASK'   ;    READ(inum) clfield, vmask
+      clfield='FMASK'   ;    READ(inum) clfield, fmask
+      clfield='FF   '   ;    READ(inum) clfield, ff
+
+      ! 4. depth and vertical scale factors
+      ! -----------------------------------
+#if ! defined key_zco
+      IF( ln_sco ) THEN
+         clfield='HBATT'   ;    READ(inum) clfield, hbatt
+         clfield='HBATU'   ;    READ(inum) clfield, hbatu
+         clfield='HBATV'   ;    READ(inum) clfield, hbatv
+         clfield='HBATF'   ;    READ(inum) clfield, hbatf
+         clfield='GSIGT'   ;    READ(inum) clfield, gsigt
+         clfield='GSIGW'   ;    READ(inum) clfield, gsigw
+         clfield='GSI3W'   ;    READ(inum) clfield, gsi3w
+         clfield='ESIGT'   ;    READ(inum) clfield, esigt
+         clfield='ESIGW'   ;    READ(inum) clfield, esigw
+      ENDIF
+#else
+      clfield='GDEPT'   ;    READ(inum) clfield, gdept
+      clfield='GDEPW'   ;    READ(inum) clfield, gdepw
+      clfield='E3T  '   ;    READ(inum) clfield, e3t
+      clfield='E3W  '   ;    READ(inum) clfield,  e3w
+#endif
+
+      CLOSE( inum )
+
+   END SUBROUTINE dom_read
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domstp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domstp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domstp.F90	(revision 1844)
@@ -0,0 +1,114 @@
+MODULE domstp
+   !!==============================================================================
+   !!                       ***  MODULE domstp   ***
+   !! Ocean initialization : time domain
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_stp        : ocean time domain initialization
+   !!----------------------------------------------------------------------
+   !! History :
+   !!        !  90-10  (O. Marti)  Original code
+   !!        !  96-01  (G. Madec)  terrain following coordinates
+   !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * routine accessibility
+   PUBLIC dom_stp        ! routine called by inidom.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_stp
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dom_stp  ***
+      !!          
+      !! ** Purpose :   Intialize ocean time step for the run
+      !!
+      !! ** Method  : - Initialization of a coef. use in the Asselin time
+      !!      filter:  atfp1 = 1 - 2 * atfp  where atfp is the Asselin time
+      !!      filter parameter read in namelist
+      !!              - Model time step:
+      !!      nacc = 0 : synchronous time intergration. 
+      !!      There is one time step only, defined by: rdt, rdttra(k)=rdt
+      !!      nacc = 1 : accelerating the convergence. There is 2 different
+      !!      time steps for dynamics and tracers:
+      !!        rdt      : dynamical part
+      !!        rdttra(k): temperature and salinity
+      !!      The tracer time step is a function of vertical level. the model
+      !!      reference time step ( i.e. for wind stress, surface heat and
+      !!      salt fluxes) is the surface tracer time step is rdttra(1).
+      !!         N.B. depth dependent acceleration of convergence is not im-
+      !!      plemented for s-coordinate.
+      !!
+      !! ** Action  : - rdttra   : vertical profile of tracer time step
+      !!              - atfp1    : = 1 - 2*atfp
+      !!
+      !! References :
+      !!      Bryan, K., 1984, J. Phys. Oceanogr., 14, 666-673.
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk              ! dummy loop indice
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_stp : time stepping setting'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! 0. Asselin Time filter
+      ! ----------------------
+      
+      atfp1 = 1. - 2. * atfp
+
+      SELECT CASE ( nacc )
+
+         CASE ( 0 )                ! Synchronous time stepping
+            IF(lwp) WRITE(numout,*)'               synchronous time stepping'
+            IF(lwp) WRITE(numout,*)'               dynamics and tracer time step = ', rdt/3600., ' hours'
+
+            rdttra(:) = rdt
+
+         CASE ( 1 )                ! Accelerating the convergence
+            IF(lwp) WRITE(numout,*) '              no tracer damping in the turbocline'
+            IF(lwp) WRITE(numout,*)'               accelerating the convergence'
+            IF(lwp) WRITE(numout,*)'               dynamics time step = ', rdt/3600., ' hours'
+            IF( ln_sco .AND. rdtmin /= rdtmax )   &
+                 & CALL ctl_stop ( ' depth dependent acceleration of convergence not implemented in s-coordinates' )
+            IF(lwp) WRITE(numout,*)'         tracers   time step :  dt (hours)  level'
+
+            DO jk = 1, jpk
+               IF( gdept_0(jk) <= rdth ) rdttra(jk) = rdtmin
+               IF( gdept_0(jk) >  rdth ) THEN
+                  rdttra(jk) = rdtmin + ( rdtmax - rdtmin )   &
+                                      * ( EXP( ( gdept_0(jk ) - rdth ) / rdth ) - 1. )   &
+                                      / ( EXP( ( gdept_0(jpk) - rdth ) / rdth ) - 1. )
+               ENDIF
+               IF(lwp) WRITE(numout,"(36x,f5.2,5x,i3)") rdttra(jk)/3600., jk
+            END DO  
+
+         CASE DEFAULT              ! E R R O R 
+
+            WRITE(ctmp1,*) ' nacc value e r r o r, nacc= ',nacc
+            CALL ctl_stop( ctmp1 )
+
+      END SELECT
+
+   END SUBROUTINE dom_stp
+
+   !!======================================================================
+END MODULE domstp
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domzgr_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domzgr_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/domzgr_substitute.h90	(revision 1844)
@@ -0,0 +1,135 @@
+   !!----------------------------------------------------------------------
+   !!                    ***  domzgr_substitute.h90   ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsdep. and fse.., the vert. depth and scale
+   !!      factors depending on the vertical coord. used, using CPP macro.
+   !!----------------------------------------------------------------------
+   !! History :  1.0  !  2005-10  (A. Beckmann, G. Madec) generalisation to all coord.
+   !!            3.1  !  2009-02  (G. Madec, M. Leclair)  pure z* coordinate
+   !!----------------------------------------------------------------------
+#if defined key_zco
+! reference for pure z-coordinate (1D - no i,j and time dependency)
+#   define  fsdept_0(i,j,k)  gdept_0(k)
+#   define  fsdepw_0(i,j,k)  gdepw_0(k)
+#   define  fsde3w_0(i,j,k)  gdepw_0(k)
+#   define  fse3t_0(i,j,k)   e3t_0(k)
+#   define  fse3u_0(i,j,k)   e3t_0(k)
+#   define  fse3v_0(i,j,k)   e3t_0(k)
+#   define  fse3f_0(i,j,k)   e3t_0(k)
+#   define  fse3w_0(i,j,k)   e3w_0(k)
+#   define  fse3uw_0(i,j,k)  e3w_0(k)
+#   define  fse3vw_0(i,j,k)  e3w_0(k)
+#else
+! reference for s- or zps-coordinate (3D no time dependency)
+#   define  fsdept_0(i,j,k)  gdept(i,j,k)
+#   define  fsdepw_0(i,j,k)  gdepw(i,j,k)
+#   define  fsde3w_0(i,j,k)  gdep3w(i,j,k)
+#   define  fse3t_0(i,j,k)   e3t(i,j,k)
+#   define  fse3u_0(i,j,k)   e3u(i,j,k)
+#   define  fse3v_0(i,j,k)   e3v(i,j,k)
+#   define  fse3f_0(i,j,k)   e3f(i,j,k)
+#   define  fse3w_0(i,j,k)   e3w(i,j,k)
+#   define  fse3uw_0(i,j,k)  e3uw(i,j,k)
+#   define  fse3vw_0(i,j,k)  e3vw(i,j,k)
+#endif
+#if defined key_vvl
+! s* or z*-coordinate (3D + time dependency) + use of additional now arrays (..._1)
+#   define  fsdept(i,j,k)  gdept_1(i,j,k)
+#   define  fsdepw(i,j,k)  gdepw_1(i,j,k)
+#   define  fsde3w(i,j,k)  gdep3w_1(i,j,k)
+#   define  fse3t(i,j,k)   e3t_1(i,j,k)
+#   define  fse3u(i,j,k)   e3u_1(i,j,k)
+#   define  fse3v(i,j,k)   e3v_1(i,j,k)
+#   define  fse3f(i,j,k)   e3f_1(i,j,k)
+#   define  fse3w(i,j,k)   e3w_1(i,j,k)
+#   define  fse3uw(i,j,k)  e3uw_1(i,j,k)
+#   define  fse3vw(i,j,k)  e3vw_1(i,j,k)
+
+#   define  fsdept_b(i,j,k)  (fsdept_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fsdepw_b(i,j,k)  (fsdepw_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fsde3w_b(i,j,k)  (fsde3w_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k))-sshb(i,j))
+#   define  fse3t_b(i,j,k)   (fse3t_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fse3u_b(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_b(i,j)*muu(i,j,k)))
+#   define  fse3v_b(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_b(i,j)*muv(i,j,k)))
+#   define  fse3f_b(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_b(i,j)*muf(i,j,k)))
+#   define  fse3w_b(i,j,k)   (fse3w_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fse3uw_b(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_b(i,j)*muu(i,j,k)))
+#   define  fse3vw_b(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_b(i,j)*muv(i,j,k)))
+
+#   define  fsdept_n(i,j,k)  (fsdept_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fsdepw_n(i,j,k)  (fsdepw_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fsde3w_n(i,j,k)  (fsde3w_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k))-sshn(i,j))
+#   define  fse3t_n(i,j,k)   (fse3t_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fse3u_n(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_n(i,j)*muu(i,j,k)))
+#   define  fse3v_n(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_n(i,j)*muv(i,j,k)))
+#   define  fse3f_n(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_n(i,j)*muf(i,j,k)))
+#   define  fse3w_n(i,j,k)   (fse3w_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fse3uw_n(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_n(i,j)*muu(i,j,k)))
+#   define  fse3vw_n(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_n(i,j)*muv(i,j,k)))
+
+#   define  fse3t_m(i,j,k)   (fse3t_0(i,j,k)*(1.+ssh_m(i,j)*mut(i,j,k)))
+
+#   define  fsdept_a(i,j,k)  (fsdept_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fsdepw_a(i,j,k)  (fsdepw_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fsde3w_a(i,j,k)  (fsde3w_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k))-ssha(i,j))
+#   define  fse3t_a(i,j,k)   (fse3t_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fse3u_a(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_a(i,j)*muu(i,j,k)))
+#   define  fse3v_a(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_a(i,j)*muv(i,j,k)))
+#   define  fse3f_a(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_a(i,j)*muf(i,j,k)))
+#   define  fse3w_a(i,j,k)   (fse3w_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fse3uw_a(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_a(i,j)*muu(i,j,k)))
+#   define  fse3vw_a(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_a(i,j)*muv(i,j,k)))
+
+#else
+! z- or s-coordinate (1D or 3D + no time dependency) use reference in all cases
+#   define  fsdept(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fsdept_b(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_b(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_b(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_b(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_b(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_b(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_b(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_b(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_b(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_b(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fsdept_n(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_n(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_n(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_n(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_n(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_n(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_n(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_n(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_n(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_n(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fse3t_m(i,j,k)   fse3t_0(i,j,k)
+
+#   define  fsdept_a(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_a(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_a(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_a(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_a(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_a(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_a(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_a(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_a(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_a(i,j,k)  fse3vw_0(i,j,k)
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/phycst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/phycst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/DOM/phycst.F90	(revision 1844)
@@ -0,0 +1,145 @@
+MODULE phycst
+   !!======================================================================
+   !!                    ***  MODULE  phycst  ***
+   !!     Definition of of both ocean and ice parameters used in the code
+   !!=====================================================================
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE in_out_manager   ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC phy_cst          ! routine called by inipar.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::                        &  !:
+      rpi = 3.141592653589793_wp           ,  &  !: pi
+      rad = 3.141592653589793_wp / 180._wp ,  &  !: conversion from degre into radian
+      rsmall = 0.5 * EPSILON( 1. )               !: smallest real computer value
+   
+   REAL(wp), PUBLIC ::          & !:
+      rday = 24.*60.*60.  ,     & !: day (s)
+      rsiyea              ,     & !: sideral year (s)
+      rsiday              ,     & !: sideral day (s)
+      raamo =  12._wp     ,     & !: number of months in one year
+      rjjhh =  24._wp     ,     & !: number of hours in one day
+      rhhmm =  60._wp     ,     & !: number of minutes in one hour
+      rmmss =  60._wp     ,     & !: number of seconds in one minute
+      rjjss               ,     & !: number of seconds in one day
+!!!   omega = 7.292115083046061e-5_wp ,  &  !: change the last digit!
+      omega               ,    &  !: earth rotation parameter
+      ra    = 6371229._wp ,    &  !: earth radius (meter)
+      grav  = 9.80665_wp          !: gravity (m/s2)
+   
+   REAL(wp), PUBLIC ::         &  !:
+      rtt      = 273.16_wp  ,  &  !: triple point of temperature (Kelvin)
+      rt0      = 273.15_wp  ,  &  !: freezing point of water (Kelvin)
+      rau0     = 1020._wp   ,  &  !: volumic mass of reference (kg/m3)
+      rauw     = 1000._wp   ,  &  !: density of pure water (kg/m3)
+      rcp      =    4.e+3_wp,  &  !: ocean specific heat
+      ro0cpr                      !: = 1. / ( rau0 * rcp )
+
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+   
+CONTAINS
+   
+   SUBROUTINE phy_cst
+      !!----------------------------------------------------------------------
+      !!                       ***  ROUTINE phy_cst  ***
+      !!
+      !! ** Purpose :   Print model parameters and set and print the constants
+      !!
+      !! ** Method  :   no
+      !!
+      !! History :
+      !!        !  90-10  (C. Levy - G. Madec)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  91-12  (M. Imbard)
+      !!   8.5  !  02-08  (G. Madec, C. Ethe)  F90, add ice constants 
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      CHARACTER (len=64) ::   cform = "(A9, 3(A13, I7) )" 
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' phy_cst : initialization of ocean parameters and constants'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+
+      ! Ocean Parameters
+      ! ----------------
+      IF(lwp) THEN
+         WRITE(numout,*) '       parameter file'
+         WRITE(numout,*)
+         WRITE(numout,*) '          dimension of model'
+         WRITE(numout,*) '              Local domain      Global domain       Data domain '
+         WRITE(numout,cform) '         ','   jpi     : ', jpi, '   jpiglo  : ', jpiglo, '   jpidta  : ', jpidta
+         WRITE(numout,cform) '         ','   jpj     : ', jpj, '   jpjglo  : ', jpjglo, '   jpjdta  : ', jpjdta
+         WRITE(numout,cform) '         ','   jpk     : ', jpk, '   jpk     : ', jpk   , '   jpkdta  : ', jpkdta
+         WRITE(numout,*)      '        ','   jpij    : ', jpij
+         WRITE(numout,*)
+         WRITE(numout,*) '          mpp local domain info (mpp)'
+         WRITE(numout,*) '             jpni    : ', jpni, '   jpreci  : ', jpreci
+         WRITE(numout,*) '             jpnj    : ', jpnj, '   jprecj  : ', jprecj
+         WRITE(numout,*) '             jpnij   : ', jpnij
+
+         WRITE(numout,*)
+         WRITE(numout,*) '          lateral domain boundary condition type : jperio  = ', jperio
+         WRITE(numout,*) '          domain island (use in rigid-lid case)  : jpisl   = ', jpisl 
+         WRITE(numout,*) '                                                   jpnisl  = ', jpnisl
+      ENDIF
+
+      ! Define constants
+      ! ----------------
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '       constants'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          mathematical constant                 rpi = ', rpi
+
+      rsiyea = 365.25 * rday * 2. * rpi / 6.283076
+      rsiday = rday / ( 1. + rday / rsiyea )
+      omega  = 2. * rpi / rsiday 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          day                                rday   = ', rday,   ' s'
+      IF(lwp) WRITE(numout,*) '          sideral year                       rsiyea = ', rsiyea, ' s'
+      IF(lwp) WRITE(numout,*) '          sideral day                        rsiday = ', rsiday, ' s'
+      IF(lwp) WRITE(numout,*) '          omega                              omega  = ', omega,  ' s-1'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          nb of hours per day                 rjjhh = ', rjjhh, ' hours'
+      IF(lwp) WRITE(numout,*) '          nb of minutes per hour              rhhmm = ', rhhmm, ' mn'
+      IF(lwp) WRITE(numout,*) '          nb of seconds per minute            rmmss = ', rmmss, ' s'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          earth radius                         ra   = ', ra, ' m'
+      IF(lwp) WRITE(numout,*) '          gravity                              grav = ', grav , ' m/s^2'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          triple point of temperature      rtt      = ', rtt     , ' K'
+      IF(lwp) WRITE(numout,*) '          freezing point of water          rt0      = ', rt0     , ' K'
+
+      ro0cpr = 1. / ( rau0 * rcp )
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          volumic mass of pure water         rauw   = ', rauw, ' kg/m^3'
+      IF(lwp) WRITE(numout,*) '          volumic mass of reference          rau0   = ', rau0, ' kg/m^3'
+      IF(lwp) WRITE(numout,*) '          ocean specific heat                rcp    = ', rcp
+      IF(lwp) WRITE(numout,*) '                       1. / ( rau0 * rcp ) = ro0cpr = ', ro0cpr
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion: degre ==> radian          rad = ', rad
+         WRITE(numout,*)
+         WRITE(numout,*) '          smallest real computer value       rsmall = ', rsmall
+      ENDIF
+
+   END SUBROUTINE phy_cst
+
+   !!======================================================================
+END MODULE phycst
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/in_out_manager.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/in_out_manager.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/in_out_manager.F90	(revision 1844)
@@ -0,0 +1,284 @@
+MODULE in_out_manager   
+   !!======================================================================
+   !!                       ***  MODULE  in_out_manager  ***
+   !! Ocean physics:  vertical mixing coefficient compute from the tke 
+   !!                 turbulent closure parameterization
+   !!=====================================================================
+   !! History :   1.0  !  2002-06  (G. Madec)   original code
+   !!             2.0  !  2006-07  (S. Masson)  iom, add ctl_stop, ctl_warn
+   !!             3.0  !  2008-06  (G. Madec)   add ctmp4 to ctmp10
+   !!             3.2  !  2009-08  (S. MAsson)  add new ctl_opn
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ctl_stop   : update momentum and tracer Kz from a tke scheme
+   !!   ctl_warn   : initialization, namelist read, and parameters control
+   !!   getunit    : give the index of an unused logical unit
+   !!----------------------------------------------------------------------
+   USE par_kind        ! kind definition
+   USE par_oce         ! ocean parameter
+   USE lib_print       ! formated print library
+#if defined key_agrif
+   USE Agrif_Util
+#endif
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !!                   namrun namelist parameters
+   !!----------------------------------------------------------------------
+   CHARACTER(len=16)  ::   cn_exp        = "exp0"      !: experiment name used for output filename
+   CHARACTER(len=32)  ::   cn_ocerst_in  = "restart"   !: suffix of ocean restart name (input)
+   CHARACTER(len=32)  ::   cn_ocerst_out = "restart"   !: suffix of ocean restart name (output)
+   LOGICAL            ::   ln_rstart     = .FALSE.     !: start from (F) rest or (T) a restart file
+   INTEGER            ::   nn_no         = 0           !: job number
+   INTEGER            ::   nn_rstctl     = 0           !: control of the time step (0, 1 or 2)
+   INTEGER            ::   nn_rstssh     = 0           !: hand made initilization of ssh or not (1/0)
+   INTEGER            ::   nn_it000      = 1           !: index of the first time step
+   INTEGER            ::   nn_itend      = 10          !: index of the last time step
+   INTEGER            ::   nn_date0      = 961115      !: initial calendar date aammjj
+   INTEGER            ::   nn_leapy      = 0           !: Leap year calendar flag (0/1 or 30)
+   INTEGER            ::   nn_istate     = 0           !: initial state output flag (0/1)
+   INTEGER            ::   nn_write      =   10        !: model standard output frequency
+   INTEGER            ::   nn_stock      =   10        !: restart file frequency
+   LOGICAL            ::   ln_dimgnnn    = .FALSE.     !: type of dimgout. (F): 1 file for all proc
+                                                       !:                  (T): 1 file per proc
+   LOGICAL            ::   ln_mskland    = .FALSE.     !: mask land points in NetCDF outputs (costly: + ~15%)
+   LOGICAL            ::   ln_clobber    = .FALSE.     !: clobber (overwrite) an existing file
+   INTEGER            ::   nn_chunksz    = 0           !: chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+
+   !! conversion of DOCTOR norm namelist name into model name
+   !! (this should disappear in a near futur)
+
+   CHARACTER(len=16)  ::   cexper                      !: experiment name used for output filename
+   INTEGER            ::   no                          !: job number
+   INTEGER            ::   nrstdt                      !: control of the time step (0, 1 or 2)
+   INTEGER            ::   nit000                      !: index of the first time step
+   INTEGER            ::   nitend                      !: index of the last time step
+   INTEGER            ::   ndate0                      !: initial calendar date aammjj
+   INTEGER            ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
+   INTEGER            ::   ninist                      !: initial state output flag (0/1)
+   INTEGER            ::   nwrite                      !: model standard output frequency
+   INTEGER            ::   nstock                      !: restart file frequency
+
+   !!----------------------------------------------------------------------
+   !! was in restart but moved here because of the OFF line... better solution should be found...
+   !!----------------------------------------------------------------------
+   INTEGER            ::   nitrst                 !: time step at which restart file should be written
+
+   !!----------------------------------------------------------------------
+   !!                    output monitoring
+   !!----------------------------------------------------------------------
+   LOGICAL            ::   ln_ctl     = .FALSE.   !: run control for debugging
+   INTEGER            ::   nn_print     =    0    !: level of print (0 no print)
+   INTEGER            ::   nn_ictls     =    0    !: Start i indice for the SUM control
+   INTEGER            ::   nn_ictle     =    0    !: End   i indice for the SUM control
+   INTEGER            ::   nn_jctls     =    0    !: Start j indice for the SUM control
+   INTEGER            ::   nn_jctle     =    0    !: End   j indice for the SUM control
+   INTEGER            ::   nn_isplt     =    1    !: number of processors following i
+   INTEGER            ::   nn_jsplt     =    1    !: number of processors following j
+   INTEGER            ::   nn_bench     =    0    !: benchmark parameter (0/1)
+   INTEGER            ::   nn_bit_cmp   =    0    !: bit reproducibility  (0/1)
+
+   !                                              !: OLD namelist names
+   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench, nbit_cmp   
+
+   INTEGER            ::   ijsplt     =    1      !: nb of local domain = nb of processors
+
+   !!----------------------------------------------------------------------
+   !!                        logical units
+   !!----------------------------------------------------------------------
+   INTEGER            ::   numstp     =   -1      !: logical unit for time step
+   INTEGER            ::   numout     =    6      !: logical unit for output print
+   INTEGER            ::   numnam     =   -1      !: logical unit for namelist
+   INTEGER            ::   numnam_ice =   -1      !: logical unit for ice namelist
+   INTEGER            ::   numevo_ice =   -1      !: logical unit for ice variables (temp. evolution)
+   INTEGER            ::   numsol     =   -1      !: logical unit for solver statistics
+
+   !!----------------------------------------------------------------------
+   !!                          Run control  
+   !!----------------------------------------------------------------------
+   INTEGER            ::   nstop = 0                !: error flag (=number of reason for a premature stop run)
+   INTEGER            ::   nwarn = 0                !: warning flag (=number of warning found during the run)
+   CHARACTER(len=200) ::   ctmp1, ctmp2, ctmp3      !: temporary characters 1 to 3
+   CHARACTER(len=200) ::   ctmp4, ctmp5, ctmp6      !: temporary characters 4 to 6
+   CHARACTER(len=200) ::   ctmp7, ctmp8, ctmp9      !: temporary characters 7 to 9
+   CHARACTER(len=200) ::   ctmp10                   !: temporary character 10
+   CHARACTER (len=64) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
+   CHARACTER (len=64) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
+   LOGICAL            ::   lwp      = .FALSE.       !: boolean : true on the 1st processor only
+   LOGICAL            ::   lsp_area = .TRUE.        !: to make a control print over a specific area
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_opa  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the error number (nstop) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      !
+      nstop = nstop + 1 
+      IF(lwp) THEN
+         WRITE(numout,"(/,' ===>>> : E R R O R',     /,'         ===========',/)") 
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
+         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+      ENDIF
+                               CALL FLUSH(numout    )
+      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
+      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
+      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
+      !
+   END SUBROUTINE ctl_stop
+
+
+   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_warn  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the warning number (nwarn) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      ! 
+      nwarn = nwarn + 1 
+      IF(lwp) THEN
+         WRITE(numout,"(/,' ===>>> : W A R N I N G', /,'         ===============',/)") 
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
+         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+      ENDIF
+      CALL FLUSH(numout)
+      !
+   END SUBROUTINE ctl_warn
+
+
+   SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ctl_opn  ***
+      !!
+      !! ** Purpose :   Open file and check if required file is available.
+      !!
+      !! ** Method  :   Fortan open
+      !!
+      !! History :
+      !!        !  1995-12  (G. Madec)  Original code
+      !!   8.5  !  2002-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+
+      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
+      INTEGER          , INTENT(in   ) ::   klengh    ! record length
+      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
+      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
+      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
+      !!
+      CHARACTER(len=80) ::   clfile
+      INTEGER           ::   iost
+
+      ! adapt filename
+      ! ----------------
+      clfile = TRIM(cdfile)
+      IF( PRESENT( karea ) ) THEN
+         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
+      ENDIF
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
+      knum=Agrif_Get_Unit()
+#else
+      knum=getunit()
+#endif
+
+      iost=0
+      IF( cdacce(1:6) == 'DIRECT' )  THEN
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
+      ELSE
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
+      ENDIF
+      IF( iost == 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*) '     file   : ', clfile,' open ok'
+            WRITE(kout,*) '     unit   = ', knum
+            WRITE(kout,*) '     status = ', cdstat
+            WRITE(kout,*) '     form   = ', cdform
+            WRITE(kout,*) '     access = ', cdacce
+            WRITE(kout,*)
+         ENDIF
+      ENDIF
+100   CONTINUE
+      IF( iost /= 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*)
+            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
+            WRITE(kout,*) ' =======   ===  '
+            WRITE(kout,*) '           unit   = ', knum
+            WRITE(kout,*) '           status = ', cdstat
+            WRITE(kout,*) '           form   = ', cdform
+            WRITE(kout,*) '           access = ', cdacce
+            WRITE(kout,*) '           iostat = ', iost
+            WRITE(kout,*) '           we stop. verify the file '
+            WRITE(kout,*)
+         ENDIF
+         STOP 'ctl_opn bad opening'
+      ENDIF
+      
+   END SUBROUTINE ctl_opn
+
+
+   FUNCTION getunit()
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  getunit  ***
+      !!
+      !! ** Purpose :   return the index of an unused logical unit
+      !!----------------------------------------------------------------------
+      INTEGER :: getunit
+      LOGICAL :: llopn 
+      !!----------------------------------------------------------------------
+      !
+      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
+      llopn = .TRUE.
+      DO WHILE( (getunit < 998) .AND. llopn )
+         getunit = getunit + 1
+         INQUIRE( unit = getunit, opened = llopn )
+      END DO
+      IF( (getunit == 999) .AND. llopn ) THEN
+         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
+         getunit = -1
+      ENDIF
+      !
+   END FUNCTION getunit
+
+   !!=====================================================================
+END MODULE in_out_manager
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom.F90	(revision 1844)
@@ -0,0 +1,1148 @@
+MODULE iom
+   !!=====================================================================
+   !!                    ***  MODULE  iom ***
+   !! Input/Output manager :  Library to read input files
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis cdvar in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+   USE iom_ioipsl      ! NetCDF format with IOIPSL library
+   USE iom_nf90        ! NetCDF format with native NetCDF library
+   USE iom_rstdimg     ! restarts access direct format "dimg" style...
+
+#if defined key_iomput
+   USE domngb          ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE dianam          ! build name of file
+   USE mod_event_client
+   USE mod_attribut
+# endif
+
+   IMPLICIT NONE
+   PUBLIC   !   must be public to be able to access iom_def through iom
+   
+#if defined key_iomput
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .TRUE.        !: iom_put flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag
+#endif
+   PUBLIC iom_init, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put
+
+   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d
+   PRIVATE iom_p2d, iom_p3d
+#if defined key_iomput
+   PRIVATE set_grid
+# endif
+
+   INTERFACE iom_get
+      MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d
+   END INTERFACE
+   INTERFACE iom_rstput
+      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   END INTERFACE
+  INTERFACE iom_put
+     MODULE PROCEDURE iom_p0d, iom_p2d, iom_p3d
+  END INTERFACE
+#if defined key_iomput
+   INTERFACE iom_setkt
+      MODULE PROCEDURE event__set_timestep
+   END INTERFACE
+# endif
+
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   
+      !!
+      !!----------------------------------------------------------------------
+#if defined key_iomput
+      REAL(wp) ::   ztmp
+      !!----------------------------------------------------------------------
+      ! read the xml file
+      CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)...
+
+      ! calendar parameters
+      SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
+      CASE ( 1)   ;   CALL event__set_calendar('gregorian')
+      CASE ( 0)   ;   CALL event__set_calendar('noleap'   )
+      CASE (30)   ;   CALL event__set_calendar('360d'     )
+      END SELECT
+      ztmp = fjulday - adatrj
+      IF( ABS(ztmp  - REAL(NINT(ztmp),wp)) < 0.1 / rday )   ztmp = REAL(NINT(ztmp),wp)   ! avoid truncation error
+      CALL event__set_time_parameters( nit000 - 1, ztmp, rdt )
+
+      ! horizontal grid definition
+      CALL set_scalar
+      CALL set_grid( "grid_T", glamt, gphit )
+      CALL set_grid( "grid_U", glamu, gphiu )
+      CALL set_grid( "grid_V", glamv, gphiv )
+      CALL set_grid( "grid_W", glamt, gphit )
+
+      ! vertical grid definition
+      CALL event__set_vert_axis( "deptht", gdept_0 )
+      CALL event__set_vert_axis( "depthu", gdept_0 )
+      CALL event__set_vert_axis( "depthv", gdept_0 )
+      CALL event__set_vert_axis( "depthw", gdepw_0 )
+      
+      ! automatic definitions of some of the xml attributs
+      CALL set_xmlatt
+
+      ! end file definition
+      CALL event__close_io_definition
+#endif
+
+   END SUBROUTINE iom_init
+
+
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file (return 0 if not found)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   )           ::   cdname   ! File name
+      INTEGER         , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90) 
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
+
+      CHARACTER(LEN=100)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
+      CHARACTER(LEN=100)    ::   cltmpn    ! tempory name to store clname (in writting mode)
+      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" or ".dimg"
+      CHARACTER(LEN=15)     ::   clcpu     ! the cpu number (max jpmax_digits digits)
+      CHARACTER(LEN=100)    ::   clinfo    ! info character
+      LOGICAL               ::   llok      ! check the existence 
+      LOGICAL               ::   llwrt     ! local definition of ldwrt
+      LOGICAL               ::   llnoov    ! local definition to read overlap
+      LOGICAL               ::   llstop    ! local definition of ldstop
+      LOGICAL               ::   lliof     ! local definition of ldiof
+      INTEGER               ::   iolib     ! library do we use to open the file
+      INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
+      INTEGER               ::   iln, ils  ! lengths of character
+      INTEGER               ::   idom      ! type of domain
+      INTEGER               ::   istop     ! 
+      INTEGER, DIMENSION(2,5) ::   idompar ! domain parameters: 
+      ! local number of points for x,y dimensions
+      ! position of first local point for x,y dimensions
+      ! position of last local point for x,y dimensions
+      ! start halo size for x,y dimensions
+      ! end halo size for x,y dimensions
+      !---------------------------------------------------------------------
+      ! Initializations and control
+      ! =============
+      kiomid = -1
+      clinfo = '                    iom_open ~~~  '
+      istop = nstop
+      ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0
+      ! (could be done when defining iom_file in f95 but not in f90)
+#if ! defined key_agrif
+      IF( iom_open_init == 0 ) THEN
+         iom_file(:)%nfid = 0
+         iom_open_init = 1
+      ENDIF
+#else
+      IF( Agrif_Root() ) THEN
+         IF( iom_open_init == 0 ) THEN
+            iom_file(:)%nfid = 0
+            iom_open_init = 1
+         ENDIF
+      ENDIF
+#endif
+      ! do we read or write the file?
+      IF( PRESENT(ldwrt) ) THEN   ;   llwrt = ldwrt
+      ELSE                        ;   llwrt = .FALSE.
+      ENDIF
+      ! do we call ctl_stop if we try to open a non-existing file in read mode?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      ! what library do we use to open the file?
+      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
+      ELSE                         ;   iolib = jpnf90
+      ENDIF
+      ! are we using interpolation on the fly?
+      IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof
+      ELSE                        ;   lliof = .FALSE.
+      ENDIF
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif
+      ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
+      ! =============
+      clname   = trim(cdname)
+#if defined key_agrif
+      IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
+         iln    = INDEX(clname,'/') 
+         cltmpn = clname(1:iln)
+         clname = clname(iln+1:LEN_TRIM(clname))
+         clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      ENDIF
+#endif    
+      ! which suffix should we use?
+      SELECT CASE (iolib)
+      CASE (jpioipsl ) ;   clsuffix = '.nc'
+      CASE (jpnf90   ) ;   clsuffix = '.nc'
+      CASE (jprstdimg) ;   clsuffix = '.dimg'
+      CASE DEFAULT     ;   clsuffix = ''
+         CALL ctl_stop( TRIM(clinfo), 'accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+      END SELECT
+      ! Add the suffix if needed
+      iln = LEN_TRIM(clname)
+      ils = LEN_TRIM(clsuffix)
+      IF( iln <= ils .OR. INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 )   &
+         &   clname = TRIM(clname)//TRIM(clsuffix)
+      cltmpn = clname   ! store this name
+      ! try to find if the file to be opened already exist
+      ! =============
+      INQUIRE( FILE = clname, EXIST = llok )
+      IF( .NOT.llok ) THEN
+         ! we try to add the cpu number to the name
+         IF( iolib == jprstdimg ) THEN   ;   WRITE(clcpu,*) narea
+         ELSE                            ;   WRITE(clcpu,*) narea-1
+         ENDIF
+         clcpu  = TRIM(ADJUSTL(clcpu))
+         iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.)
+         clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+         icnt = 0
+         INQUIRE( FILE = clname, EXIST = llok ) 
+         ! we try different formats for the cpu number by adding 0
+         DO WHILE( .NOT.llok .AND. icnt < jpmax_digits )
+            clcpu  = "0"//trim(clcpu)
+            clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+            INQUIRE( FILE = clname, EXIST = llok )
+            icnt = icnt + 1
+         END DO
+      ENDIF
+      IF( llwrt ) THEN
+         ! check the domain definition
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         idom = jpdom_local_noovlap   ! default definition
+         IF( llnoov ) THEN   ;   idom = jpdom_local_noovlap   ! default definition
+         ELSE                ;   idom = jpdom_local_full      ! default definition
+         ENDIF
+         IF( PRESENT(kdom) )   idom = kdom
+         ! create the domain informations
+         ! =============
+         SELECT CASE (idom)
+         CASE (jpdom_local_full)
+            idompar(:,1) = (/ jpi             , jpj              /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1  /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ jpi - nlei      , jpj - nlej       /)
+         CASE (jpdom_local_noextra)
+            idompar(:,1) = (/ nlci            , nlcj             /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ nlci - nlei     , nlcj - nlej      /)
+         CASE (jpdom_local_noovlap)
+            idompar(:,1) = (/ nlei  - nldi + 1, nlej  - nldj + 1 /)
+            idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /)
+            idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /)
+            idompar(:,4) = (/ 0               , 0                /)
+            idompar(:,5) = (/ 0               , 0                /)
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' )
+         END SELECT
+      ENDIF
+      ! Open the NetCDF or RSTDIMG file
+      ! =============
+      ! do we have some free file identifier?
+      IF( MINVAL(iom_file(:)%nfid) /= 0 )   &
+         &   CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' )
+      ! if no file was found...
+      IF( .NOT. llok ) THEN
+         IF( .NOT. llwrt ) THEN   ! we are in read mode 
+            IF( llstop ) THEN   ;   CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' )
+            ELSE                ;   istop = nstop + 1   ! make sure that istop /= nstop so we don't open the file
+            ENDIF
+         ELSE                     ! we are in write mode so we 
+            clname = cltmpn       ! get back the file name without the cpu number
+         ENDIF
+      ENDIF
+      IF( istop == nstop ) THEN   ! no error within this routine
+         SELECT CASE (iolib)
+         CASE (jpioipsl )   ;   CALL iom_ioipsl_open(  clname, kiomid, llwrt, llok, idompar )
+         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
+         CASE (jprstdimg)   ;   CALL iom_rstdimg_open( clname, kiomid, llwrt, llok, idompar )
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         END SELECT
+      ENDIF
+      !
+   END SUBROUTINE iom_open
+
+
+   SUBROUTINE iom_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_close  ***
+      !!
+      !! ** Purpose : close an input file, or all files opened by iom
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(inout), OPTIONAL ::   kiomid   ! iom identifier of the file to be closed
+      !                                              ! return 0 when file is properly closed
+      !                                              ! No argument: all files opened by iom are closed
+
+      INTEGER ::   jf         ! dummy loop indices
+      INTEGER ::   i_s, i_e   ! temporary integer
+      CHARACTER(LEN=100)    ::   clinfo    ! info character
+      !---------------------------------------------------------------------
+      !
+      clinfo = '                    iom_close ~~~  '
+      IF( PRESENT(kiomid) ) THEN
+         i_s = kiomid
+         i_e = kiomid
+      ELSE
+         i_s = 1
+         i_e = jpmax_files
+#if defined key_iomput
+         CALL event__stop_ioserver
+#endif
+      ENDIF
+
+      IF( i_s > 0 ) THEN
+         DO jf = i_s, i_e
+            IF( iom_file(jf)%nfid > 0 ) THEN
+               SELECT CASE (iom_file(jf)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_close(  jf )
+               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
+               CASE (jprstdimg)   ;   CALL iom_rstdimg_close( jf )
+               CASE DEFAULT
+                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+               END SELECT
+               iom_file(jf)%nfid       = 0          ! free the id 
+               IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok'
+            ELSEIF( PRESENT(kiomid) ) THEN
+               WRITE(ctmp1,*) '--->',  kiomid
+               CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 )
+            ENDIF
+         END DO
+      ENDIF
+      !    
+   END SUBROUTINE iom_close
+
+
+   FUNCTION iom_varid ( kiomid, cdvar, kdimsz, ldstop )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file (return 0 if not found)
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      LOGICAL              , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if looking for non-existing variable (default = .TRUE.)
+      !
+      INTEGER                        ::   iom_varid, iiv, i_nvd
+      LOGICAL                        ::   ll_fnd
+      CHARACTER(LEN=100)             ::   clinfo                   ! info character
+      LOGICAL                        ::   llstop                   ! local definition of ldstop
+      !!-----------------------------------------------------------------------
+      iom_varid = 0                         ! default definition
+      ! do we call ctl_stop if we look for non-existing variable?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      !
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
+         IF( iom_file(kiomid)%nfid == 0 ) THEN 
+            CALL ctl_stop( trim(clinfo), 'the file is not open' )
+         ELSE
+            ll_fnd  = .FALSE.
+            iiv = 0
+            !
+            DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars )
+               iiv = iiv + 1
+               ll_fnd  = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) )
+            END DO
+            !
+            IF( .NOT.ll_fnd ) THEN
+               iiv = iiv + 1
+               IF( iiv <= jpmax_vars ) THEN
+                  SELECT CASE (iom_file(kiomid)%iolib)
+                  CASE (jpioipsl )   ;   iom_varid = iom_ioipsl_varid( kiomid, cdvar, iiv, kdimsz )
+                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz )
+                  CASE (jprstdimg)   ;   iom_varid = -1   ! all variables are listed in iom_file
+                  CASE DEFAULT   
+                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                  END SELECT
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
+                        &                         'increase the parameter jpmax_vars')
+               ENDIF
+               IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' ) 
+            ELSE
+               iom_varid = iiv
+               IF( PRESENT(kdimsz) ) THEN 
+                  i_nvd = iom_file(kiomid)%ndims(iiv)
+                  IF( i_nvd == size(kdimsz) ) THEN
+                     kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv)
+                  ELSE
+                     WRITE(ctmp1,*) i_nvd, size(kdimsz)
+                     CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) )
+                  ENDIF
+               ENDIF
+            ENDIF
+         ENDIF
+      ENDIF
+      !
+   END FUNCTION iom_varid
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_get
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_g0d( kiomid, cdvar, pvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out)                 ::   pvar      ! read field
+      !
+      INTEGER               :: idvar   ! variable id
+      !
+      IF( kiomid > 0 ) THEN
+         idvar = iom_varid( kiomid, cdvar )
+         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar )
+            CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
+            CASE DEFAULT    
+               CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g0d
+
+   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g1d
+
+   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g2d
+
+   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g3d
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
+         &                  pv_r1d, pv_r2d, pv_r3d,   &
+         &                  ktime , kstart, kcount  )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_get_123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! Identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
+      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar      ! Name of the variable
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
+      !
+      LOGICAL                        ::   llnoov      ! local definition to read overlap
+      INTEGER                        ::   jl          ! loop on number of dimension 
+      INTEGER                        ::   idom        ! type of domain
+      INTEGER                        ::   idvar       ! id of the variable
+      INTEGER                        ::   inbdim      ! number of dimensions of the variable
+      INTEGER                        ::   idmspc      ! number of spatial dimensions 
+      INTEGER                        ::   itime       ! record number
+      INTEGER                        ::   istop       ! temporary value of nstop
+      INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER                        ::   ji, jj      ! loop counters
+      INTEGER                        ::   irankpv       ! 
+      INTEGER                        ::   ind1, ind2  ! substring index
+      INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis
+      INTEGER, DIMENSION(jpmax_dims) ::   icnt        ! number of value to read along each axis 
+      INTEGER, DIMENSION(jpmax_dims) ::   idimsz      ! size of the dimensions of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   ishape      ! size of the dimensions of the variable
+      REAL(wp)                       ::   zscf, zofs  ! sacle_factor and add_offset
+      INTEGER                        ::   itmp        ! temporary integer
+      CHARACTER(LEN=100)             ::   clinfo      ! info character
+      CHARACTER(LEN=100)             ::   clname      ! file name
+      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
+      !---------------------------------------------------------------------
+      !
+      clname = iom_file(kiomid)%name   !   esier to read
+      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
+      ! local definition of the domain ?
+      idom = kdom
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif
+      ! check kcount and kstart optionals parameters...
+      IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
+      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
+      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown')
+
+      ! Search for the variable in the data base (eventually actualize data)
+      istop = nstop
+      idvar = iom_varid( kiomid, cdvar )
+      !
+      IF( idvar > 0 ) THEN
+         ! to write iom_file(kiomid)%dimsz in a shorter way !
+         idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
+         inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
+         idmspc = inbdim                                   ! number of spatial dimensions in the file
+         IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
+         IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
+         !
+         ! update idom definition...
+         ! Identify the domain in case of jpdom_auto(glo/dta) definition
+         IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
+            IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
+            ELSE                               ;   idom = jpdom_data
+            ENDIF
+            ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
+            ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
+            IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
+         ENDIF
+         ! Identify the domain in case of jpdom_local definition
+         IF( idom == jpdom_local ) THEN
+            IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
+            ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
+            ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
+            ENDIF
+         ENDIF
+         !
+         ! check the consistency between input array and data rank in the file
+         !
+         ! initializations
+         itime = 1
+         IF( PRESENT(ktime) ) itime = ktime
+
+         irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
+         WRITE(clrankpv, fmt='(i1)') irankpv
+         WRITE(cldmspc , fmt='(i1)') idmspc
+         !
+         IF(     idmspc <  irankpv ) THEN 
+            CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
+               &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
+         ELSEIF( idmspc == irankpv ) THEN
+            IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
+               &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
+         ELSEIF( idmspc >  irankpv ) THEN
+               IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
+                  CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
+                        &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
+                        &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
+                  idmspc = idmspc - 1
+               ELSE
+                  CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
+                     &                         'we do not accept data with more than '//cldmspc//' spatial dimension',   &
+                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+               ENDIF
+         ENDIF
+
+         !
+         ! definition of istart and icnt
+         !
+         icnt  (:) = 1
+         istart(:) = 1
+         istart(idmspc+1) = itime
+
+         IF(              PRESENT(kstart)       ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
+         ELSE
+            IF(           idom == jpdom_unknown ) THEN                                       ; icnt(1:idmspc) = idimsz(1:idmspc)
+            ELSE 
+               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
+                  IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow
+                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow
+                  ENDIF
+                  ! we do not read the overlap                     -> we start to read at nldi, nldj
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
+                  ENDIF
+                  IF( PRESENT(pv_r3d) ) THEN
+                     IF( idom == jpdom_data ) THEN   ; icnt(3) = jpkdta
+                     ELSE                            ; icnt(3) = jpk
+                     ENDIF
+                  ENDIF
+               ENDIF
+            ENDIF
+         ENDIF
+
+         ! check that istart and icnt can be used with this file
+         !-
+         DO jl = 1, jpmax_dims
+            itmp = istart(jl)+icnt(jl)-1
+            IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
+               WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
+               WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
+               CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
+            ENDIF
+         END DO
+
+         ! check that icnt matches the input array
+         !-     
+         IF( idom == jpdom_unknown ) THEN
+            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
+            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
+            IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
+            ctmp1 = 'd'
+         ELSE
+            IF( irankpv == 2 ) THEN
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
+               IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
+               ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
+               ENDIF
+            ENDIF
+            IF( irankpv == 3 ) THEN 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
+               IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
+               ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
+               ENDIF
+            ENDIF
+         ENDIF
+         
+         DO jl = 1, irankpv
+            WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
+            IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
+         END DO
+
+      ENDIF
+
+      ! read the data
+      !-     
+      IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
+         !
+         ! find the right index of the array to be read
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+!         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+!         ENDIF
+         IF( llnoov ) THEN
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ELSE
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ENDIF
+      
+         SELECT CASE (iom_file(kiomid)%iolib)
+         CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE DEFAULT    
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         END SELECT
+
+         IF( istop == nstop ) THEN   ! no additional errors until this point...
+            IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i4,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
+          
+            !--- overlap areas and extra hallows (mpp)
+            IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
+               CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
+               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
+               IF( icnt(3) == jpk ) THEN
+                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
+                  DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
+                  DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
+               ENDIF
+            ENDIF
+            
+            !--- Apply scale_factor and offset
+            zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
+            zofs = iom_file(kiomid)%ofs(idvar)      ! offset
+            IF(     PRESENT(pv_r1d) ) THEN
+               IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
+               IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
+            ELSEIF( PRESENT(pv_r2d) ) THEN
+!CDIR COLLAPSE
+               IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
+!CDIR COLLAPSE
+               IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
+            ELSEIF( PRESENT(pv_r3d) ) THEN
+!CDIR COLLAPSE
+               IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
+!CDIR COLLAPSE
+               IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE iom_get_123d
+
+
+   SUBROUTINE iom_gettime( kiomid, ptime, cdvar, kntime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kiomid     ! file Identifier
+      REAL(wp), DIMENSION(:)     , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL , INTENT(in   ) ::   cdvar      ! time axis name
+      INTEGER         , OPTIONAL , INTENT(  out) ::   kntime     ! number of times in file
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdunits    ! units attribute of time coordinate
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdcalendar ! calendar attribute of 
+      !
+      INTEGER, DIMENSION(1) :: kdimsz
+      INTEGER            ::   idvar    ! id of the variable
+      CHARACTER(LEN=32)  ::   tname    ! local name of time coordinate
+      CHARACTER(LEN=100) ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      !
+      IF ( PRESENT(cdvar) ) THEN
+         tname = cdvar
+      ELSE
+         tname = iom_file(kiomid)%uldname
+      ENDIF
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(tname)
+         IF ( PRESENT(kntime) ) THEN
+            idvar  = iom_varid( kiomid, tname, kdimsz = kdimsz )
+            kntime = kdimsz(1)
+         ELSE
+            idvar = iom_varid( kiomid, tname )
+         ENDIF
+         !
+         ptime(:) = 0. ! default definition
+         IF( idvar > 0 ) THEN
+            IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN
+               IF( iom_file(kiomid)%luld(idvar) ) THEN
+                  IF( iom_file(kiomid)%dimsz(1,idvar) == size(ptime) ) THEN
+                     SELECT CASE (iom_file(kiomid)%iolib)
+                     CASE (jpioipsl )   ;   CALL iom_ioipsl_gettime( kiomid, idvar, ptime, cdunits, cdcalendar )
+                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
+                     CASE (jprstdimg)   ;   CALL ctl_stop( TRIM(clinfo)//' case IO library == jprstdimg not coded...' )
+                     CASE DEFAULT    
+                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                     END SELECT
+                  ELSE
+                     WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
+                     CALL ctl_stop( trim(clinfo), trim(ctmp1) )
+                  ENDIF
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' )
+               ENDIF
+            ELSE
+               CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' )
+            ENDIF
+         ELSE
+            CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE iom_gettime
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_rstput
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in)                         ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp0d
+
+   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(        jpk) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp1d
+
+   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj    ) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp2d
+
+   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp3d
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_put
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_p0d( cdname, pfield0d )
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      REAL(wp)        , INTENT(in) ::   pfield0d
+#if defined key_iomput
+      CALL event__write_field2D( cdname, RESHAPE( (/pfield0d/), (/1,1/) ) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p0d
+
+   SUBROUTINE iom_p2d( cdname, pfield2d )
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pfield2d
+#if defined key_iomput
+      CALL event__write_field2D( cdname, pfield2d(nldi:nlei, nldj:nlej) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p2d
+
+   SUBROUTINE iom_p3d( cdname, pfield3d )
+      CHARACTER(LEN=*)                , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   pfield3d
+#if defined key_iomput
+      CALL event__write_field3D( cdname, pfield3d(nldi:nlei, nldj:nlej, :) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p3d
+   !!----------------------------------------------------------------------
+
+
+#if defined key_iomput
+
+   SUBROUTINE set_grid( cdname, plon, plat )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   define horizontal grids
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plon
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
+
+      CALL event__set_grid_dimension( cdname, jpiglo, jpjglo)
+      CALL event__set_grid_domain( cdname, nlei-nldi+1, nlej-nldj+1, nimpp+nldi-1, njmpp+nldj-1, &
+         &                         plon(nldi:nlei, nldj:nlej), plat(nldi:nlei, nldj:nlej) )
+      CALL event__set_grid_type_nemo( cdname )
+
+   END SUBROUTINE set_grid
+
+
+   SUBROUTINE set_scalar
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   define fake grids for scalar point
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(1,1) ::   zz = 1.
+      !!----------------------------------------------------------------------
+      CALL event__set_grid_dimension( 'scalarpoint', jpnij, 1)
+      CALL event__set_grid_domain   ( 'scalarpoint', 1, 1, narea, 1, zz, zz )
+      CALL event__set_grid_type_nemo( 'scalarpoint' )
+
+   END SUBROUTINE set_scalar
+
+
+   SUBROUTINE set_xmlatt
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   automatic definitions of some of the xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=6),DIMENSION( 8) ::   clsuff                   ! suffix name
+      CHARACTER(len=1),DIMENSION( 3) ::   clgrd                    ! suffix name
+      CHARACTER(len=50)              ::   clname                   ! file name
+      CHARACTER(len=1)               ::   cl1                      ! 1 character
+      CHARACTER(len=2)               ::   cl2                      ! 1 character
+      INTEGER                        ::   idt                      ! time-step in seconds
+      INTEGER                        ::   iddss, ihhss             ! number of seconds in 1 day, 1 hour and 1 year
+      INTEGER                        ::   iyymo                    ! number of months in 1 year
+      INTEGER                        ::   jg, jh, jd, jm, jy       ! loop counters
+      INTEGER                        ::   ix, iy                   ! i-,j- index
+      REAL(wp)        ,DIMENSION(11) ::   zlontao                  ! longitudes of tao    moorings
+      REAL(wp)        ,DIMENSION( 7) ::   zlattao                  ! latitudes  of tao    moorings
+      REAL(wp)        ,DIMENSION( 4) ::   zlonrama                 ! longitudes of rama   moorings
+      REAL(wp)        ,DIMENSION(11) ::   zlatrama                 ! latitudes  of rama   moorings
+      REAL(wp)        ,DIMENSION( 3) ::   zlonpira                 ! longitudes of pirata moorings
+      REAL(wp)        ,DIMENSION( 9) ::   zlatpira                 ! latitudes  of pirata moorings
+      !!----------------------------------------------------------------------
+      ! 
+      idt   = NINT( rdttra(1)     )
+      iddss = NINT( rday          )                                         ! number of seconds in 1 day
+      ihhss = NINT( rmmss * rhhmm )                                         ! number of seconds in 1 hour
+      iyymo = NINT( raamo         )                                         ! number of months in 1 year
+
+      ! frequency of the call of iom_put (attribut: freq_op)
+      CALL event__set_attribut( 'field_definition', attr( field__freq_op, idt           ) )    ! model time-step
+      
+      ! output file names (attribut: name)
+      clsuff(:) = (/ 'grid_T', 'grid_U', 'grid_V', 'grid_W', 'icemod', 'ptrc_T', 'diad_T', 'scalar' /)      
+      DO jg = 1, SIZE(clsuff)                                                                  ! grid type
+         DO jh = 1, 12                                                                         ! 1, 2, 3, 4, 6, 12 hours
+            IF( MOD(12,jh) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jh 
+               CALL dia_nam( clname, jh * ihhss, clsuff(jg), ldfsec = .TRUE. )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'h_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+         DO jd = 1, 5, 2                                                                       ! 1, 3, 5 days
+            WRITE(cl1,'(i1)') jd 
+            CALL dia_nam( clname, jd * iddss, clsuff(jg), ldfsec = .TRUE. )
+            CALL event__set_attribut( cl1//'d_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+         END DO
+         DO jm = 1, 6                                                                          ! 1, 2, 3, 4, 6 months
+            IF( MOD(6,jm) == 0 ) THEN 
+               WRITE(cl1,'(i1)') jm 
+               CALL dia_nam( clname, -jm, clsuff(jg) )
+               CALL event__set_attribut( cl1//'m_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+         DO jy = 1, 10                                                                         ! 1, 2, 5, 10 years  
+            IF( MOD(10,jy) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jy 
+               CALL dia_nam( clname, -jy * iyymo, clsuff(jg) )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'y_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+      END DO
+
+      ! Zooms...
+      clgrd = (/ 'T', 'U', 'W' /) 
+      DO jg = 1, SIZE(clgrd)                                                                   ! grid type
+         cl1 = clgrd(jg)
+         ! Equatorial section (attributs: jbegin, ni, name_suffix)
+         CALL dom_ngb( 0., 0., ix, iy, cl1 )
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__jbegin     , iy     ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__ni         , jpiglo ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( file__name_suffix, '_Eq'  ) )
+      END DO
+      ! TAO moorings (attributs: ibegin, jbegin, name_suffix)
+      zlontao = (/ 137.0, 147.0, 156.0, 165.0, -180.0, -170.0, -155.0, -140.0, -125.0, -110.0, -95.0 /)
+      zlattao = (/  -8.0,  -5.0,  -2.0,   0.0,    2.0,    5.0,    8.0 /)
+      CALL set_mooring( zlontao, zlattao )
+      ! RAMA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonrama = (/  55.0,  67.0, 80.5, 90.0 /)
+      zlatrama = (/ -16.0, -12.0, -8.0, -4.0, -1.5, 0.0, 1.5, 4.0, 8.0, 12.0, 15.0 /)
+      CALL set_mooring( zlonrama, zlatrama )
+      ! PIRATA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonpira = (/ -38.0, -23.0, -10.0 /)
+      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /)
+      CALL set_mooring( zlonpira, zlatpira )
+      
+   END SUBROUTINE set_xmlatt
+
+
+   SUBROUTINE set_mooring( plon, plat)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   automatic definitions of moorings xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(in) ::  plon, plat           ! longitudes/latitudes oft the mooring
+      !
+!!$      CHARACTER(len=1),DIMENSION(4) ::   clgrd = (/ 'T', 'U', 'V', 'W' /)   ! suffix name
+      CHARACTER(len=1),DIMENSION(1) ::   clgrd = (/ 'T' /)        ! suffix name
+      CHARACTER(len=50)             ::   clname                   ! file name
+      CHARACTER(len=1)              ::   cl1                      ! 1 character
+      CHARACTER(len=6)              ::   clon,clat                ! name of longitude, latitude
+      INTEGER                       ::   ji, jj, jg               ! loop counters
+      INTEGER                       ::   ix, iy                   ! i-,j- index
+      REAL(wp)                      ::   zlon, zlat
+      !!----------------------------------------------------------------------
+      DO jg = 1, SIZE(clgrd)
+         cl1 = clgrd(jg)
+         DO ji = 1, SIZE(plon)
+            DO jj = 1, SIZE(plat)
+               zlon = plon(ji)
+               zlat = plat(jj)
+               ! modifications for RAMA moorings
+               IF( zlon ==  67. .AND. zlat ==  15. )   zlon =  65.
+               IF( zlon ==  90. .AND. zlat <=  -4. )   zlon =  95.
+               IF( zlon ==  95. .AND. zlat ==  -4. )   zlat =  -5.
+               ! modifications for PIRATA moorings
+               IF( zlon == -38. .AND. zlat == -19. )   zlon = -34.
+               IF( zlon == -38. .AND. zlat == -14. )   zlon = -32.
+               IF( zlon == -38. .AND. zlat ==  -8. )   zlon = -30.
+               IF( zlon == -38. .AND. zlat ==   0. )   zlon = -35.
+               IF( zlon == -23. .AND. zlat ==  20. )   zlat =  21.
+               IF( zlon == -10. .AND. zlat == -14. )   zlat = -10.
+               IF( zlon == -10. .AND. zlat ==  -8. )   zlat =  -6.
+               IF( zlon == -10. .AND. zlat ==   4. ) THEN   ;   zlon = 0.   ;   zlat = 0.   ;   ENDIF
+               CALL dom_ngb( zlon, zlat, ix, iy, cl1 )
+               IF( zlon >= 0. ) THEN  
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT( zlon), 'e'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')       zlon , 'e'
+                  ENDIF
+               ELSE             
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT(-zlon), 'w'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')      -zlon , 'w'
+                  ENDIF
+               ENDIF
+               IF( zlat >= 0. ) THEN  
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT( zlat), 'n'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')       zlat , 'n'
+                  ENDIF
+               ELSE             
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT(-zlat), 's'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')      -zlat , 's'
+                  ENDIF
+               ENDIF
+               clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__ibegin     , ix                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__jbegin     , iy                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( file__name_suffix, '_'//TRIM(clname) ) )      
+            END DO
+         END DO
+      END DO
+      
+   END SUBROUTINE set_mooring
+
+#else
+
+   SUBROUTINE iom_setkt( kt )
+      INTEGER, INTENT(in   )::   kt 
+      IF( .FALSE. )   WRITE(numout,*) kt   ! useless test to avoid compilation warnings
+   END SUBROUTINE iom_setkt
+
+#endif
+
+
+   !!======================================================================
+END MODULE iom
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_def.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_def.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_def.F90	(revision 1844)
@@ -0,0 +1,73 @@
+MODULE iom_def
+   !!=====================================================================
+   !!                    ***  MODULE  iom_def ***
+   !! IOM variables definitions
+   !!====================================================================
+   !! History :  9.0  ! 06 09  (S. Masson) Original code
+   !!             "   ! 07 07  (D. Storkey) Add uldname
+   !!--------------------------------------------------------------------
+   !!---------------------------------------------------------------------------------
+   !! OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!---------------------------------------------------------------------------------
+
+   USE par_kind
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_data          = 1   !: ( 1  :jpidta, 1  :jpjdta)
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_global        = 2   !: ( 1  :jpiglo, 1  :jpjglo)
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local         = 3   !: One of the 3 following cases
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_full    = 4   !: ( 1  :jpi   , 1  :jpi   )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noextra = 5   !: ( 1  :nlci  , 1  :nlcj  )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noovlap = 6   !: (nldi:nlei  ,nldj:nlej  )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 7   !: No dimension checking
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo       = 8   !: 
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 9   !: 
+
+   INTEGER, PARAMETER, PUBLIC ::   jpioipsl    = 100      !: Use ioipsl (fliocom only) library
+   INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library
+   INTEGER, PARAMETER, PUBLIC ::   jprstdimg   = 102      !: Use restart dimgs (fortran direct acces) library
+#if defined key_dimgout
+   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jprstdimg  !: restarts io library
+#else
+   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library
+#endif
+
+   INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
+   INTEGER, PARAMETER, PUBLIC ::   jp_r4    = 201      !: write REAL(4)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i4    = 202      !: write INTEGER(4)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i2    = 203      !: write INTEGER(2)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i1    = 204      !: write INTEGER(1)
+
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_files  = 50   !: maximum number of simultaneously opened file
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_vars   = 360  !: maximum number of variables in one file
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_dims   =  4   !: maximum number of dimensions for one variable
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_digits =  5   !: maximum number of digits for the cpu number in the file name
+
+!$AGRIF_DO_NOT_TREAT
+   INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
+
+   TYPE, PUBLIC ::   file_descriptor
+      CHARACTER(LEN=240)                        ::   name     !: name of the file
+      INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
+      INTEGER                                   ::   iolib    !: library used to read the file (jpioipsl, jpnf90 or jprstdimg)
+      INTEGER                                   ::   nvars    !: number of identified varibles in the file
+      INTEGER                                   ::   iduld    !: id of the unlimited dimension
+      INTEGER                                   ::   irec     !: writing record position  
+      CHARACTER(LEN=32)                         ::   uldname  !: name of the unlimited dimension
+      CHARACTER(LEN=32), DIMENSION(jpmax_vars)  ::   cn_var   !: names of the variables
+      INTEGER, DIMENSION(jpmax_vars)            ::   nvid     !: id of the variables
+      INTEGER, DIMENSION(jpmax_vars)            ::   ndims    !: number of dimensions of the variables
+      LOGICAL, DIMENSION(jpmax_vars)            ::   luld     !: variable using the unlimited dimension
+      INTEGER, DIMENSION(jpmax_dims,jpmax_vars) ::   dimsz    !: size of variables dimensions 
+      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
+      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
+   END TYPE file_descriptor
+   TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
+!$AGRIF_END_DO_NOT_TREAT
+
+   !!=====================================================================
+END MODULE iom_def
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_ioipsl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_ioipsl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_ioipsl.F90	(revision 1844)
@@ -0,0 +1,436 @@
+MODULE iom_ioipsl
+   !!=====================================================================
+   !!                    ***  MODULE  iom_ioipsl ***
+   !! Input/Output manager :  Library to read input files with IOIPSL (only fliocom module)
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_ioipsl_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE iom_def         ! iom variables definitions
+   USE ioipsl          ! IOIPSL library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_ioipsl_open, iom_ioipsl_close, iom_ioipsl_varid, iom_ioipsl_get, iom_ioipsl_gettime, iom_ioipsl_rstput
+
+   INTERFACE iom_ioipsl_get
+      MODULE PROCEDURE iom_ioipsl_g0d, iom_ioipsl_g123d
+   END INTERFACE
+   INTERFACE iom_ioipsl_rstput
+      MODULE PROCEDURE iom_ioipsl_rp0123d
+   END INTERFACE
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_ioipsl_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file with IOIPSL (only fliocom module)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! ioipsl identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100) ::   clinfo      ! info character
+      CHARACTER(LEN=10 ) ::   clstatus    ! status of opened file (REPLACE or NEW)
+      INTEGER            ::   iln         ! lengths of character
+      INTEGER            ::   istop       ! temporary storage of nstop
+      INTEGER            ::   ifliodom    ! model domain identifier (see flio_dom_set)
+      INTEGER            ::   ioipslid    ! ioipsl identifier of the opened file
+      INTEGER            ::   jl          ! loop variable
+      LOGICAL            ::   llclobber   ! local definition of ln_clobber
+      !---------------------------------------------------------------------
+
+      clinfo = '                    iom_ioipsl_open ~~~  '
+      istop = nstop
+      !
+      llclobber = ldwrt .AND. ln_clobber
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         !                 ! =============
+         IF( ldwrt ) THEN  ! ... in write mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode'
+            CALL flioopfd( TRIM(cdname), ioipslid, "WRITE" )
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            CALL flioopfd( TRIM(cdname), ioipslid )
+         ENDIF
+      ELSE                 ! the file does not exist
+         !                 ! =============
+         iln = INDEX( cdname, '.nc' )
+         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it...
+            IF( llclobber ) THEN   ;   clstatus = 'REPLACE' 
+            ELSE                   ;   clstatus = 'NEW'
+            ENDIF
+            IF( jpnij > 1 ) THEN
+               ! define the domain position regarding to the global domain (mainly useful in mpp)
+               CALL flio_dom_set( jpnij, narea-1, (/1, 2/), (/jpiglo, jpjglo/)   &
+                  &             , kdompar(:,1), kdompar(:,2), kdompar(:,3), kdompar(:,4), kdompar(:,5)   &
+                  &             , 'BOX', ifliodom )        
+               ! Note that fliocrfd may change the value of cdname (add the cpu number...)
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname(1:iln-1)//'... in WRITE mode'
+               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
+                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid, ifliodom, mode = clstatus )
+            ELSE              ! the file should be open for read mode so it must exist...
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname//' in WRITE mode'
+               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
+                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid,           mode = clstatus )
+            ENDIF
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! start to fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name   = TRIM(cdname)
+         iom_file(kiomid)%nfid   = ioipslid
+         iom_file(kiomid)%iolib  = jpioipsl
+         iom_file(kiomid)%nvars  = 0
+         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files
+         CALL flioinqf( ioipslid, id_uld = iom_file(kiomid)%iduld )
+         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
+      ELSE
+         kiomid = 0               ! return error flag
+      ENDIF
+      !
+   END SUBROUTINE iom_ioipsl_open
+
+
+   SUBROUTINE iom_ioipsl_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_ioipsl_close  ***
+      !!
+      !! ** Purpose : close an input file with IOIPSL (only fliocom module) 
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      !---------------------------------------------------------------------
+      !
+      CALL flioclo( iom_file(kiomid)%nfid )
+      !    
+   END SUBROUTINE iom_ioipsl_close
+
+
+   FUNCTION iom_ioipsl_varid ( kiomid, cdvar, kiv, kdimsz )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file with IOIPSL (only fliocom module)
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER              , INTENT(in   )           ::   kiv   ! 
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      !
+      INTEGER                        ::   iom_ioipsl_varid  ! iom variable Id
+      INTEGER                        ::   ioipslid          ! ioipsl file identifier
+      INTEGER                        ::   ji                ! dummy loop index
+      INTEGER                        ::   i_nvd             ! number of dimension of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   idimid            ! dimension ids of the variable
+      LOGICAL                        ::   ll_fnd            ! found test
+      CHARACTER(LEN=100)             ::   clinfo            ! info character
+      !!-----------------------------------------------------------------------
+      clinfo = 'iom_ioipsl_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
+      iom_ioipsl_varid = 0                  ! default definition
+      IF( PRESENT(kdimsz) ) kdimsz(:) = 0   ! default definition
+      ioipslid = iom_file(kiomid)%nfid      ! get back ioipsl file identifier 
+      CALL flioinqv( ioipslid, cdvar, ll_fnd, nb_dims = i_nvd )   ! does the variable exist in the file
+      IF( ll_fnd ) THEN
+         IF( i_nvd <= jpmax_dims ) THEN
+            iom_ioipsl_varid = kiv
+            iom_file(kiomid)%nvars       = kiv
+            iom_file(kiomid)%nvid(kiv)   = -1   ! variable id is not available in ioipsl
+            iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
+            iom_file(kiomid)%ndims(kiv)  = i_nvd
+            CALL flioinqv( ioipslid, cdvar, ll_fnd,   &
+                  &           len_dims = iom_file(kiomid)%dimsz(1:i_nvd,kiv), &   ! dimensions size
+                  &           id_dims  = idimid(1:i_nvd) )                        ! dimensions ids
+            iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
+            DO ji = 1, i_nvd                       ! find the unlimited dimension
+               IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.
+            END DO
+            !---------- Deal with scale_factor and add_offset
+            CALL flioinqa( ioipslid, cdvar, 'scale_factor', ll_fnd )
+            IF( ll_fnd) THEN
+               CALL fliogeta( ioipslid, cdvar, 'scale_factor', iom_file(kiomid)%scf(kiv) )
+            ELSE
+               iom_file(kiomid)%scf(kiv) = 1.
+            END IF
+            CALL flioinqa( ioipslid, cdvar, 'add_offset', ll_fnd )
+            IF( ll_fnd ) THEN
+               CALL fliogeta( ioipslid, cdvar, 'add_offset', iom_file(kiomid)%ofs(kiv) )
+            ELSE
+               iom_file(kiomid)%ofs(kiv) = 0.
+            END IF
+            ! return the simension size
+            IF( PRESENT(kdimsz) ) THEN 
+               IF( i_nvd == SIZE(kdimsz) ) THEN
+                  kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,kiv)
+               ELSE
+                  WRITE(ctmp1,*) i_nvd, SIZE(kdimsz)
+                  CALL ctl_stop( TRIM(clinfo), 'error in kdimsz size'//TRIM(ctmp1) )
+               ENDIF
+            ENDIF
+         ELSE
+            CALL ctl_stop( TRIM(clinfo), 'Too many dimensions in the file '//iom_file(kiomid)%name,   &
+                  &                       'increase the parameter jpmax_vars')
+         ENDIF
+      ELSE  
+         iom_ioipsl_varid = -1   !   variable not found, return error code: -1
+      ENDIF
+      !
+   END FUNCTION iom_ioipsl_varid
+
+
+   SUBROUTINE iom_ioipsl_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_ioipsl_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with IOIPSL (only fliocom module)
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   kiomid    ! Identifier of the file
+      INTEGER , INTENT(in   ) ::   kvid      ! variable id
+      REAL(wp), INTENT(  out) ::   pvar      ! read field
+      !
+      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), pvar )
+      ! 
+   END SUBROUTINE iom_ioipsl_g0d
+
+
+   SUBROUTINE iom_ioipsl_g123d( kiomid, kvid, knbdim, kstart, kcount, kx1, kx2, ky1, ky2,   &
+         &                      pv_r1d, pv_r2d, pv_r3d)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_ioipsl_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with IOIPSL (only fliocom module)
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kvid       ! Name of the variable
+      INTEGER                    , INTENT(in   )           ::   knbdim     ! number of dimensions of the variable
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kstart     ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kcount     ! number of points to be read in each axis
+      INTEGER ,                    INTENT(in   )           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+      !
+      INTEGER               ::   ioipslid   ! ioipsl file identifier
+      CHARACTER(LEN=100)    ::   clvn       ! variable name
+      !---------------------------------------------------------------------
+      clvn = TRIM(iom_file(kiomid)%cn_var(kvid))   ! get back variable name 
+      ioipslid = iom_file(kiomid)%nfid             ! get back IPIPSL file id
+      !
+      IF( PRESENT(pv_r1d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r1d(:                ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ELSEIF( PRESENT(pv_r2d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ELSEIF( PRESENT(pv_r3d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ENDIF
+      !
+      !
+   END SUBROUTINE iom_ioipsl_g123d
+
+
+   SUBROUTINE iom_ioipsl_gettime( kiomid, kvid, ptime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis kvid in the file with IOIPSL (only fliocom module)
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in   ) ::   kiomid     ! file Identifier
+      INTEGER                   , INTENT(in   ) ::   kvid       ! variable id
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdunits    ! units attribute
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdcalendar ! calendar attribute
+      !---------------------------------------------------------------------
+      !
+      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), ptime(:),   &
+            &         start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /) )
+      IF ( PRESENT(cdunits) ) THEN 
+         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "units", cdunits )
+      ENDIF
+      IF ( PRESENT(cdcalendar) ) THEN 
+         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "calendar", cdcalendar )
+      ENDIF
+      !
+   END SUBROUTINE iom_ioipsl_gettime
+
+
+   SUBROUTINE iom_ioipsl_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   &
+         &                                 pv_r0d, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_ioipsl_rstput  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                     , INTENT(in)           ::   kt       ! ocean time-step
+      INTEGER                     , INTENT(in)           ::   kwrite   ! writing time-step
+      INTEGER                     , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)            , INTENT(in)           ::   cdvar    ! variable name
+      INTEGER                     , INTENT(in)           ::   kvid     ! variable id
+      INTEGER                     , INTENT(in), OPTIONAL ::   ktype    ! variable type (default R8)
+      REAL(wp)                    , INTENT(in), OPTIONAL ::   pv_r0d   ! written Od field
+      REAL(wp), DIMENSION(      :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(:, :   ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(:, :, :), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      INTEGER               :: idims                ! number of dimension
+      INTEGER               :: idvar                ! variable id
+      INTEGER               :: itype                ! variable type
+      INTEGER               :: ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER, DIMENSION(4) :: idimsz               ! dimensions size  
+      INTEGER, DIMENSION(4) :: idimid               ! dimensions id
+      CHARACTER(LEN=100)    :: clinfo               ! info character
+      INTEGER               :: ioipslid             ! ioipsl file identifier
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_ioipsl_rp0123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      ioipslid = iom_file(kiomid)%nfid
+      !
+      ! define dimension variables if it is not already done
+      ! ==========================
+      IF( iom_file(kiomid)%nvars == 0 ) THEN
+         ! define the dimension variables if it is not already done
+         CALL fliodefv( ioipslid,'nav_lon', (/1,2/), v_t=flio_r4   , axis='X',   &
+               &                  long_name="Longitude", units="degrees_east" )
+         CALL fliodefv( ioipslid,'nav_lat', (/1,2/), v_t=flio_r4   , axis='Y',   &
+               &                  long_name="Latitude", units="degrees_north" )
+         CALL fliodefv( ioipslid,'nav_lev', (/3/)  , v_t=flio_i4   , axis='Z',   &
+               &                  long_name="Model levels",units="model_levels")
+         CALL fliodefv( ioipslid,'time_counter', (/4/), v_t=flio_r4, axis='T',   &
+               &                  long_name="Time axis", units='seconds since 0001-01-01 00:00:00' )
+         ! update informations structure related the dimension variable we just added...
+         iom_file(kiomid)%nvars       = 4
+         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
+         iom_file(kiomid)%cn_var(1:3) = (/ 'nav_lon', 'nav_lat', 'nav_lev' /)
+         iom_file(kiomid)%cn_var(4)   = 'time_counter'
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
+         ! trick: defined to 0 to say that dimension variables are defined but not yet written
+         iom_file(kiomid)%dimsz(1, 1) = 0   
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
+      ENDIF
+
+      ! define the data if it is not already done
+      ! ===============
+      IF( kvid <= 0 ) THEN
+         ! variable definition
+         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ENDIF
+         IF( PRESENT(ktype) ) THEN   ! variable external type
+            SELECT CASE (ktype)
+            CASE (jp_r8)  ;   itype = flio_r8
+            CASE (jp_r4)  ;   itype = flio_r4
+            CASE (jp_i4)  ;   itype = flio_i4
+            CASE (jp_i2)  ;   itype = flio_i2
+            CASE (jp_i1)  ;   itype = flio_i1   !   fliocom does not handle i1 type of variable
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
+            END SELECT
+         ELSE
+            itype = flio_r8
+         ENDIF
+         IF( PRESENT(pv_r0d) ) THEN   ;   CALL fliodefv (ioipslid, TRIM(cdvar)                 , v_t = itype)
+         ELSE                         ;   CALL fliodefv (ioipslid, TRIM(cdvar), idimid(1:idims), v_t = itype)
+         ENDIF
+         ! update informations structure related the new variable we want to add...
+         idvar                          = iom_file(kiomid)%nvars + 1
+         iom_file(kiomid)%nvars         = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(idvar)   = -1   ! netcdf variable id is not available in ioipsl
+         iom_file(kiomid)%scf(idvar)    = 1.
+         iom_file(kiomid)%ofs(idvar)    = 0.
+         iom_file(kiomid)%ndims(idvar)  = idims
+         IF( .NOT. PRESENT(pv_r0d) ) THEN
+            iom_file(kiomid)%luld(idvar) = .TRUE.
+            CALL flioinqf( ioipslid, ln_dim = idimsz )
+            iom_file(kiomid)%dimsz(1:idims-1,idvar) = idimsz(idimid(1:idims-1))
+         ELSE                               
+            iom_file(kiomid)%luld(idvar) = .FALSE.
+         ENDIF
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' defined ok'
+      ELSE
+         idvar = kvid
+      ENDIF
+
+      ! time step kwrite : write the variable
+      IF( kt == kwrite ) THEN
+         ! on what kind of domain must the data be written?
+         IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
+            idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
+            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
+               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
+               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
+               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+            ELSE 
+               CALL ctl_stop( 'iom_ioipsl_rp0123d: should have been an impossible case...' )
+            ENDIF
+
+            ! write dimension variables if it is not already done
+            ! =============
+            ! trick: is defined to 0 => dimension variable are defined but not yet written
+            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
+               CALL flioputv( ioipslid, 'nav_lon'     , glamt(ix1:ix2, iy1:iy2) )
+               CALL flioputv( ioipslid, 'nav_lat'     , gphit(ix1:ix2, iy1:iy2) )
+               CALL flioputv( ioipslid, 'nav_lev'     , gdept_0 )
+               ! +++ WRONG VALUE: to be improved but not really useful...
+               CALL flioputv( ioipslid, 'time_counter', kt )
+               ! update the values of the variables dimensions size
+               CALL flioinqf( ioipslid, ln_dim = idimsz )
+               iom_file(kiomid)%dimsz(1:2, 1) = idimsz(1:2)
+               iom_file(kiomid)%dimsz(1:2, 2) = idimsz(1:2)
+               iom_file(kiomid)%dimsz(1, 3:4) = (/idimsz(3), 1/)
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
+            ENDIF
+         ENDIF
+
+         ! write the data
+         ! =============
+         IF(     PRESENT(pv_r0d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r0d                      )
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r1d(                  :) )
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r2d(ix1:ix2, iy1:iy2   ) )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r3d(ix1:ix2, iy1:iy2, :) )
+         ENDIF
+         ! add 1 to the size of the temporal dimension (not really useful...)
+         IF( iom_file(kiomid)%luld(idvar) )   iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar)    &
+               &                            = iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar) + 1
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_ioipsl_rp0123d
+
+
+   !!======================================================================
+END MODULE iom_ioipsl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_nf90.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_nf90.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_nf90.F90	(revision 1844)
@@ -0,0 +1,501 @@
+MODULE iom_nf90
+   !!=====================================================================
+   !!                    ***  MODULE  iom_nf90 ***
+   !! Input/Output manager :  Library to read input files with NF90 (only fliocom module)
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_nf90_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+   USE netcdf          ! NetCDF library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_nf90_open, iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput
+
+   INTERFACE iom_nf90_get
+      MODULE PROCEDURE iom_nf90_g0d, iom_nf90_g123d
+   END INTERFACE
+   INTERFACE iom_nf90_rstput
+      MODULE PROCEDURE iom_nf90_rp0123d
+   END INTERFACE
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose : open an input file with NF90
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! nf90 identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100) ::   clinfo           ! info character
+      CHARACTER(LEN=100) ::   cltmp            ! temporary character
+      INTEGER            ::   iln              ! lengths of character
+      INTEGER            ::   istop            ! temporary storage of nstop
+      INTEGER            ::   if90id           ! nf90 identifier of the opened file
+      INTEGER            ::   idmy             ! dummy variable
+      INTEGER            ::   jl               ! loop variable
+      INTEGER            ::   ichunk           ! temporary storage of nn_chunksz
+      INTEGER            ::   imode            ! creation mode flag: NF90_CLOBBER or NF90_NOCLOBBER
+      LOGICAL            ::   llclobber        ! local definition of ln_clobber
+      !---------------------------------------------------------------------
+
+      clinfo = '                    iom_nf90_open ~~~  '
+      istop = nstop   ! store the actual value of nstop
+      IF( nn_chunksz > 0 ) THEN   ;   ichunk = nn_chunksz
+      ELSE                        ;   ichunk = NF90_SIZEHINT_DEFAULT
+      ENDIF
+      !
+      llclobber = ldwrt .AND. ln_clobber
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         !                 ! =============
+         IF( ldwrt ) THEN  ! ... in write mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode'
+            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_WRITE  , if90id, chunksize = ichunk ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                          ), clinfo)
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo)
+         ENDIF
+      ELSE                                       ! the file does not exist (or we overwrite it)
+         !                 ! =============
+         iln = INDEX( cdname, '.nc' )
+         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it...
+            IF( jpnij > 1 ) THEN
+               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea-1, '.nc'
+               cdname = TRIM(cltmp)
+            ENDIF
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in WRITE mode'
+
+            IF( llclobber ) THEN   ;   imode = NF90_CLOBBER 
+            ELSE                   ;   imode = NF90_NOCLOBBER 
+            ENDIF
+            CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                     ), clinfo)
+            ! define dimensions
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x', kdompar(1,1)  , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y', kdompar(2,1)  , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', jpk           , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 't', NF90_UNLIMITED, idmy ), clinfo)
+            ! global attributes
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_local'     , kdompar(:,1)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_first' , kdompar(:,2)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_last'  , kdompar(:,3)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_start', kdompar(:,4)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , kdompar(:,5)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              ), clinfo)
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! start to fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name   = TRIM(cdname)
+         iom_file(kiomid)%nfid   = if90id
+         iom_file(kiomid)%iolib  = jpnf90
+         iom_file(kiomid)%nvars  = 0
+         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
+         CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
+         IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN
+           CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,   &
+        &                                               name = iom_file(kiomid)%uldname), clinfo)
+         ENDIF
+         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
+      ELSE
+         kiomid = 0               ! return error flag
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_open
+
+
+   SUBROUTINE iom_nf90_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_nf90_close  ***
+      !!
+      !! ** Purpose : close an input file with NF90
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      CHARACTER(LEN=100)  ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      !
+      clinfo = '      iom_nf90_close    , file: '//TRIM(iom_file(kiomid)%name)
+      CALL iom_nf90_check(NF90_CLOSE(iom_file(kiomid)%nfid), clinfo)
+      !    
+   END SUBROUTINE iom_nf90_close
+
+
+   FUNCTION iom_nf90_varid ( kiomid, cdvar, kiv, kdimsz )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file with NF90
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER              , INTENT(in   )           ::   kiv   ! 
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      !
+      INTEGER                        ::   iom_nf90_varid   ! iom variable Id
+      INTEGER                        ::   if90id           ! nf90 file identifier
+      INTEGER                        ::   ji               ! dummy loop index
+      INTEGER                        ::   ivarid           ! NetCDF  variable Id
+      INTEGER                        ::   i_nvd            ! number of dimension of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   idimid           ! dimension ids of the variable
+      LOGICAL                        ::   llok             ! ok  test
+      CHARACTER(LEN=100)             ::   clinfo           ! info character
+      !!-----------------------------------------------------------------------
+      clinfo = '          iom_nf90_varid, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      iom_nf90_varid = 0                    ! default definition
+      IF( PRESENT(kdimsz) ) kdimsz(:) = 0   ! default definition
+      if90id = iom_file(kiomid)%nfid        ! get back NetCDF file id
+      !
+      llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! does the variable exist in the file
+      IF( llok ) THEN
+         iom_nf90_varid = kiv
+         iom_file(kiomid)%nvars       = kiv
+         iom_file(kiomid)%nvid(kiv)   = ivarid
+         iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
+         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, ndims = i_nvd), clinfo)   ! number of dimensions
+         iom_file(kiomid)%ndims(kiv)  = i_nvd
+         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, dimids = idimid(1:i_nvd)), clinfo)   ! dimensions ids
+         iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
+         DO ji = 1, i_nvd                       ! dimensions size
+            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)   
+            IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.   ! unlimited dimension? 
+         END DO
+         !---------- Deal with scale_factor and add_offset
+         llok = NF90_Inquire_attribute(if90id, ivarid, 'scale_factor') == nf90_noerr
+         IF( llok) THEN
+            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'scale_factor', iom_file(kiomid)%scf(kiv)), clinfo)
+         ELSE
+            iom_file(kiomid)%scf(kiv) = 1.
+         END IF
+         llok = NF90_Inquire_attribute(if90id, ivarid, 'add_offset') == nf90_noerr
+         IF( llok ) THEN
+            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'add_offset', iom_file(kiomid)%ofs(kiv)), clinfo)
+         ELSE
+            iom_file(kiomid)%ofs(kiv) = 0.
+         END IF
+         ! return the simension size
+         IF( PRESENT(kdimsz) ) THEN 
+            IF( i_nvd == SIZE(kdimsz) ) THEN
+               kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,kiv)
+            ELSE
+               WRITE(ctmp1,*) i_nvd, SIZE(kdimsz)
+               CALL ctl_stop( TRIM(clinfo), 'error in kdimsz size'//TRIM(ctmp1) )
+            ENDIF
+         ENDIF
+      ELSE  
+         iom_nf90_varid = -1   !   variable not found, return error code: -1
+      ENDIF
+      !
+   END FUNCTION iom_nf90_varid
+
+
+   SUBROUTINE iom_nf90_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with NF90
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   kiomid   ! Identifier of the file
+      INTEGER , INTENT(in   ) ::   kvid     ! variable id
+      REAL(wp), INTENT(  out) ::   pvar     ! read field
+      !
+      CHARACTER(LEN=100)      ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_g0d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), pvar), clinfo )
+      ! 
+   END SUBROUTINE iom_nf90_g0d
+
+
+   SUBROUTINE iom_nf90_g123d( kiomid, kvid, knbdim, kstart, kcount, kx1, kx2, ky1, ky2,   &
+         &                    pv_r1d, pv_r2d, pv_r3d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with NF90
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid    ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kvid      ! Name of the variable
+      INTEGER                    , INTENT(in   )           ::   knbdim    ! number of dimensions of the variable
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kstart    ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kcount    ! number of points to be read in each axis
+      INTEGER ,                    INTENT(in   )           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d    ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d    ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d    ! read field (3D case)
+      !
+      CHARACTER(LEN=100) ::   clinfo               ! info character
+      INTEGER            ::   if90id               ! nf90 identifier of the opened file
+      INTEGER            ::   ivid                 ! nf90 variable id
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_g123d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      if90id = iom_file(kiomid)%nfid         ! get back NetCDF file id
+      ivid   = iom_file(kiomid)%nvid(kvid)   ! get back NetCDF var id
+      !
+      IF(     PRESENT(pv_r1d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r1d(:                ), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ELSEIF( PRESENT(pv_r2d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ELSEIF( PRESENT(pv_r3d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_g123d
+
+
+   SUBROUTINE iom_nf90_gettime( kiomid, kvid, ptime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis kvid in the file with NF90
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in   ) ::   kiomid     ! file Identifier
+      INTEGER                   , INTENT(in   ) ::   kvid       ! variable id
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdunits    ! units attribute
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdcalendar ! calendar attribute
+      !
+      CHARACTER(LEN=100) ::   clinfo     ! info character
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_gettime, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), ptime(:),   &
+            &                           start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /)), clinfo)
+      IF ( PRESENT(cdunits) ) THEN 
+         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "units", &
+            &                           values=cdunits), clinfo)
+      ENDIF
+      IF ( PRESENT(cdcalendar) ) THEN 
+         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "calendar", &
+            &                           values=cdcalendar), clinfo)
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_gettime
+
+
+   SUBROUTINE iom_nf90_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   &
+         &                               pv_r0d, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_nf90_rstput  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                     , INTENT(in)           ::   kt       ! ocean time-step
+      INTEGER                     , INTENT(in)           ::   kwrite   ! writing time-step
+      INTEGER                     , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)            , INTENT(in)           ::   cdvar    ! variable name
+      INTEGER                     , INTENT(in)           ::   kvid     ! variable id
+      INTEGER                     , INTENT(in), OPTIONAL ::   ktype    ! variable type (default R8)
+      REAL(wp)                    , INTENT(in), OPTIONAL ::   pv_r0d   ! written Od field
+      REAL(wp), DIMENSION(      :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(:, :   ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(:, :, :), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      INTEGER               :: idims                ! number of dimension
+      INTEGER               :: idvar                ! variable id
+      INTEGER               :: jd                   ! dimension loop counter   
+      INTEGER               :: ix1, ix2, iy1, iy2   ! subdomain indexes   
+      INTEGER, DIMENSION(4) :: idimsz               ! dimensions size  
+      INTEGER, DIMENSION(4) :: idimid               ! dimensions id
+      CHARACTER(LEN=100)    :: clinfo               ! info character
+      CHARACTER(LEN= 12), DIMENSION(4) :: cltmp     ! temporary character
+      INTEGER               :: if90id               ! nf90 file identifier
+      INTEGER               :: idmy                 ! dummy variable
+      INTEGER               :: itype                ! variable type
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_nf90_rp0123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      if90id = iom_file(kiomid)%nfid
+      !
+      ! define dimension variables if it is not already done
+      ! ==========================
+      IF( iom_file(kiomid)%nvars == 0 ) THEN
+         ! are we in define mode?
+         IF( iom_file(kiomid)%irec /= -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = -1
+         ENDIF
+         ! define the dimension variables if it is not already done
+         cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(3)), NF90_FLOAT , (/ 3    /), iom_file(kiomid)%nvid(3) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(4)), NF90_DOUBLE, (/ 4    /), iom_file(kiomid)%nvid(4) ), clinfo)
+         ! update informations structure related the dimension variable we just added...
+         iom_file(kiomid)%nvars       = 4
+         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
+         iom_file(kiomid)%cn_var(1:4) = cltmp
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)  
+         ! trick: defined to 0 to say that dimension variables are defined but not yet written
+         iom_file(kiomid)%dimsz(1, 1)  = 0   
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
+      ENDIF
+      ! define the data if it is not already done
+      ! ===============
+      IF( kvid <= 0 ) THEN
+         idvar = iom_file(kiomid)%nvars + 1
+         ! are we in define mode?
+         IF( iom_file(kiomid)%irec /= -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = -1
+         ENDIF
+         ! variable definition
+         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ENDIF
+         IF( PRESENT(ktype) ) THEN   ! variable external type
+            SELECT CASE (ktype)
+            CASE (jp_r8)  ;   itype = NF90_DOUBLE
+            CASE (jp_r4)  ;   itype = NF90_FLOAT
+            CASE (jp_i4)  ;   itype = NF90_INT
+            CASE (jp_i2)  ;   itype = NF90_SHORT
+            CASE (jp_i1)  ;   itype = NF90_BYTE
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
+            END SELECT
+         ELSE
+            itype = NF90_DOUBLE
+         ENDIF
+         IF( PRESENT(pv_r0d) ) THEN
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype,                    &
+                 &                            iom_file(kiomid)%nvid(idvar) ), clinfo)
+         ELSE
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype, idimid(1:idims),   &
+                 &                            iom_file(kiomid)%nvid(idvar) ), clinfo)
+         ENDIF
+         ! update informations structure related the new variable we want to add...
+         iom_file(kiomid)%nvars         = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%scf(idvar)    = 1.
+         iom_file(kiomid)%ofs(idvar)    = 0.
+         iom_file(kiomid)%ndims(idvar)  = idims
+         IF( .NOT. PRESENT(pv_r0d) ) THEN   ;   iom_file(kiomid)%luld(idvar) = .TRUE.
+         ELSE                               ;   iom_file(kiomid)%luld(idvar) = .FALSE.
+         ENDIF
+         DO jd = 1, idims
+            CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, idimid(jd), len = iom_file(kiomid)%dimsz(jd,idvar) ), clinfo)
+         END DO
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' defined ok'
+      ELSE
+         idvar = kvid
+      ENDIF
+
+      ! time step kwrite : write the variable
+      IF( kt == kwrite ) THEN
+         ! are we in write mode?
+         IF( iom_file(kiomid)%irec == -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = 0
+         ENDIF
+         ! on what kind of domain must the data be written?
+         IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
+            idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
+            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
+               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
+               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
+               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+            ELSE 
+               CALL ctl_stop( 'iom_nf90_rp0123d: should have been an impossible case...' )
+            ENDIF
+
+            ! write dimension variables if it is not already done
+            ! =============
+            ! trick: is defined to 0 => dimension variable are defined but not yet written
+            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lon'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, glamt(ix1:ix2, iy1:iy2) ), clinfo)
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lat'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo)
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gdept_0                 ), clinfo)
+               ! +++ WRONG VALUE: to be improved but not really useful...
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, kt                      ), clinfo)   
+               ! update the values of the variables dimensions size
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 1, len = iom_file(kiomid)%dimsz(1,1) ), clinfo)
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 2, len = iom_file(kiomid)%dimsz(2,1) ), clinfo)
+               iom_file(kiomid)%dimsz(1:2, 2) = iom_file(kiomid)%dimsz(1:2, 1)
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 3, len = iom_file(kiomid)%dimsz(1,3) ), clinfo)
+               iom_file(kiomid)%dimsz(1  , 4) = 1   ! unlimited dimension
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
+            ENDIF
+         ENDIF
+
+         ! write the data
+         ! =============
+         IF(     PRESENT(pv_r0d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r0d                      ), clinfo)
+         ELSEIF( PRESENT(pv_r1d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r1d(                  :) ), clinfo)
+         ELSEIF( PRESENT(pv_r2d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r2d(ix1:ix2, iy1:iy2   ) ), clinfo)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r3d(ix1:ix2, iy1:iy2, :) ), clinfo)
+         ENDIF
+         ! add 1 to the size of the temporal dimension (not really useful...)
+         IF( iom_file(kiomid)%luld(idvar) )   iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar)    &
+               &                            = iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar) + 1
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_nf90_rp0123d
+
+
+   SUBROUTINE iom_nf90_check( kstatus, cdinfo )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_nf90_check  ***
+      !!
+      !! ** Purpose :   check nf90 errors
+      !!--------------------------------------------------------------------
+      INTEGER,          INTENT(in) :: kstatus
+      CHARACTER(LEN=*), INTENT(in) :: cdinfo
+      !---------------------------------------------------------------------
+      IF(kstatus /= nf90_noerr)   CALL ctl_stop( 'iom_nf90_check : '//TRIM(nf90_strerror(kstatus)), TRIM(cdinfo) )
+   END SUBROUTINE iom_nf90_check
+
+
+   !!======================================================================
+END MODULE iom_nf90
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_rstdimg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_rstdimg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/IOM/iom_rstdimg.F90	(revision 1844)
@@ -0,0 +1,503 @@
+MODULE iom_rstdimg
+   !!=====================================================================
+   !!                    ***  MODULE  iom_rstdimg ***
+   !! Input/Output manager :  Library to read input rstdimg files
+   !!====================================================================
+   !! History :  9.0  ! 06 09  (S. Masson) Original code
+   !!--------------------------------------------------------------------
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_rstdimg_open, iom_rstdimg_close, iom_rstdimg_get, iom_rstdimg_rstput
+
+   INTERFACE iom_rstdimg_get
+      MODULE PROCEDURE iom_rstdimg_g0d, iom_rstdimg_g123d
+   END INTERFACE
+   INTERFACE iom_rstdimg_rstput
+      MODULE PROCEDURE iom_rstdimg_rp0d, iom_rstdimg_rp123d
+   END INTERFACE
+
+   INTEGER, PARAMETER ::   jpvnl          = 32   ! variable name length
+      
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_rstdimg_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file read only (return 0 if not found)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! iom identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
+      CHARACTER(LEN=100)                      ::   cltmp                      ! temporary character
+      CHARACTER(LEN=10 )                      ::   clstatus                   ! status of opened file (REPLACE or NEW)
+      INTEGER                                 ::   jv                         ! loop counter
+      INTEGER                                 ::   istop                      ! temporary storage of nstop
+      INTEGER                                 ::   idrst                      ! logical unit of the restart file
+      INTEGER                                 ::   iln                        ! lengths of character
+      INTEGER                                 ::   irecl8                     ! record length
+      INTEGER                                 ::   ios                        ! IO status
+      INTEGER                                 ::   irhd                       ! record of the header infos
+      INTEGER                                 ::   ivnum                      ! number of variables
+      INTEGER                                 ::   ishft                      ! counter shift
+      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
+      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
+      INTEGER                                 ::   ipni, ipnj, ipnij, iarea   ! domain decomposition 
+      INTEGER                                 ::   iiglo, ijglo               ! domain global size 
+      INTEGER                                 ::   jl                         ! loop variable
+      LOGICAL                                 ::   llclobber                  ! local definition of ln_clobber
+      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d     ! name of 0/1/2/3D variables
+      REAL(wp),             DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d     ! value of 0d variables or record
+      !                                                                                   ! position for 1/2/3D variables
+      !---------------------------------------------------------------------
+      clinfo = '                    iom_rstdimg_open ~~~  '
+      istop = nstop      ! store the actual value of nstop
+      ios = 0            ! default definition
+      kiomid = 0         ! default definition
+      llclobber = ldwrt .AND. ln_clobber
+      ! get a free unit
+      idrst = getunit()  ! get a free logical unit for the restart file
+!!$#if defined key_agrif 
+!!$      idrst = Agrif_Get_Unit()      
+!!$#endif 
+      ! Open the file...
+      ! =============
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         ! find the record length
+         OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+            &       , RECL = 8, STATUS = 'old', ACTION = 'read', IOSTAT = ios, ERR = 987 )
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8
+         CLOSE( idrst )
+         ! Open the file with the appropriate record length and parameters
+         IF( ldwrt ) THEN  ! ... in readwrite mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READWRITE mode'
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+               &       , RECL = irecl8, STATUS = 'old', ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+               &       , RECL = irecl8, STATUS = 'old', ACTION = 'read'     , IOSTAT = ios, ERR = 987 )
+         ENDIF
+      ELSE                                       ! the file does not exist (or we overwrite it)
+         iln = INDEX( cdname, '.dimg' )
+         IF( ldwrt ) THEN  ! the file should be open in readwrite mode so we create it...
+            irecl8= MAX( kdompar(1,1) * kdompar(2,1) * wp, ( 8*jpnij + 15 ) * 4 )
+            IF( jpnij > 1 ) THEN
+               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea, '.dimg'
+               cdname = TRIM(cltmp)
+            ENDIF
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in READWRITE mode'
+            
+            IF( llclobber ) THEN   ;   clstatus = 'REPLACE' 
+            ELSE                   ;   clstatus = 'NEW'
+            ENDIF
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'UNFORMATTED', ACCESS = 'DIRECT'   &
+               &       , RECL = irecl8, STATUS = TRIM(clstatus), ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! Performs checks on the file
+      ! =============
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! old file
+         READ( idrst, REC = 1   , IOSTAT = ios, ERR = 987 )              &
+              &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
+              &   ipni, ipnj, ipnij, iarea, iiglo, ijglo
+         READ( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                       &
+            &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
+            &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
+         clinfo = TRIM(clinfo)//' file '//TRIM(cdname)
+         IF( iiglo /= jpiglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in i direction' )
+         IF( ijglo /= jpjglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in j direction' )
+         IF( ldwrt ) THEN
+            IF( inx   /= kdompar(1,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in i direction' )
+            IF( iny   /= kdompar(2,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in j direction' )
+         ENDIF
+         IF( inz   /= jpk          )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in domain size in k direction' )
+         IF( ipni  /= jpni         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along I' )
+         IF( ipnj  /= jpnj         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along J' )
+         IF( ipnij /= jpnij        )   CALL ctl_stop( TRIM(clinfo), 'Total number of processors changed' )
+         IF( iarea /= narea        )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in area numbering ...' )
+      ENDIF
+      ! fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name    = TRIM(cdname)
+         iom_file(kiomid)%nfid    = idrst
+         iom_file(kiomid)%iolib   = jprstdimg
+         iom_file(kiomid)%iduld   = -1
+         IF( ldok ) THEN      ! old file
+            ! read variables informations from the file header
+            IF(  TRIM(clna0d(1)) == 'no0d' )   in0d = 0
+            IF(  TRIM(clna1d(1)) == 'no1d' )   in1d = 0
+            IF(  TRIM(clna2d(1)) == 'no2d' )   in2d = 0
+            IF(  TRIM(clna3d(1)) == 'no3d' )   in3d = 0
+            ivnum = in0d + in1d + in2d + in3d
+            iom_file(kiomid)%nvars            = ivnum
+            iom_file(kiomid)%irec             = 2 + in1d + in2d + inz * in3d
+            iom_file(kiomid)%luld(   1:ivnum) = .FALSE.
+            iom_file(kiomid)%scf(    1:ivnum) = 1.
+            ! scalar variable
+            DO jv = 1, in0d
+               iom_file(kiomid)%cn_var(jv) = TRIM(clna0d(jv))
+               iom_file(kiomid)%nvid(  jv) = 1
+               iom_file(kiomid)%ndims( jv) = 0
+               iom_file(kiomid)%ofs(   jv) = zval0d(jv)   ! warning: trick... we use ofs to store the value
+            END DO
+            ! 1d variable
+            ishft = in0d
+            DO jv = 1, in1d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna1d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval1d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 1
+               iom_file(kiomid)%dimsz(1  , ishft + jv) = jpk
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+            ! 2d variable
+            ishft = in0d + in1d
+            DO jv = 1, in2d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna2d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval2d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 2
+               iom_file(kiomid)%dimsz(1:2, ishft + jv) = (/ inx, iny /)
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+            ! 3d variable
+            ishft = in0d + in1d + in2d 
+            DO jv = 1, in3d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna3d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval3d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 3
+               iom_file(kiomid)%dimsz(1:3, ishft + jv) = (/ inx, iny, jpk /)
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+         ELSE                 ! new file
+            iom_file(kiomid)%nvars = 0
+            iom_file(kiomid)%irec  = 2
+            ! store file informations
+            WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, kdompar(:,1), jpk   ! store domain size
+         ENDIF
+      ENDIF
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo), '   error in opening file '//TRIM(cdname), ctmp1 )
+      ENDIF
+      !
+   END SUBROUTINE iom_rstdimg_open
+
+
+   SUBROUTINE iom_rstdimg_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_close  ***
+      !!
+      !! ** Purpose : close an input file
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      !
+      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
+      INTEGER                                 ::   jv                         ! loop counter
+      INTEGER                                 ::   irecl8                     ! record length
+      INTEGER                                 ::   ios                        ! IO status
+      INTEGER                                 ::   irhd                       ! record of the header infos
+      INTEGER                                 ::   ivnum                      ! number of variables
+      INTEGER                                 ::   idrst                      ! file logical unit
+      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
+      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
+      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d    ! name of 0/1/2/3D variables
+      REAL(wp),          DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d    ! value of 0d variables or record
+      !                                                                               ! position for 1/2/3D variables
+      !---------------------------------------------------------------------
+      !
+      clinfo = '                    iom_rstdimg_close ~~~  '
+      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+      ! test if we can write in the file (test with INQUIRE gives alsways YES even with read only files...)
+      READ(  idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   
+      WRITE( idrst, REC = 1, IOSTAT = ios            ) irecl8, inx, iny, inz   
+      ! We can write in the file => we update its header before closing
+      IF( ios == 0 ) THEN
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   ! get back domain size
+         irhd = iom_file(kiomid)%irec
+         ivnum = iom_file(kiomid)%nvars
+         in0d = 0   ;   in1d = 0   ;   in2d = 0   ;   in3d = 0
+         DO jv = 1, ivnum   ! loop on each variable to get its name and value/record position
+            SELECT CASE (iom_file(kiomid)%ndims(jv))
+            CASE (0)   ! scalar variable
+               in0d = in0d + 1
+               clna0d(in0d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval0d(in0d) = iom_file(kiomid)%ofs(jv)   ! warning: trick... we use ofs to store the value
+            CASE (1)   ! 1d variable
+               in1d = in1d + 1
+               clna1d(in1d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval1d(in1d) = iom_file(kiomid)%nvid(jv)
+            CASE (2)   ! 2d variable
+               in2d = in2d + 1
+               clna2d(in2d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval2d(in2d) = iom_file(kiomid)%nvid(jv)
+            CASE (3)   ! 3d variable
+               in3d = in3d + 1
+               clna3d(in3d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval3d(in3d) = iom_file(kiomid)%nvid(jv)
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo), 'Should not ne there...' )
+            END SELECT
+         END DO
+         ! force to have at least 1 variable in each list (not necessary (?), but safer...)
+         IF( in0d == 0 ) THEN   ;   in0d = 1   ;   clna0d(1) = 'no0d'   ;   zval0d(1) = -1.   ;   ENDIF
+         IF( in1d == 0 ) THEN   ;   in1d = 1   ;   clna1d(1) = 'no1d'   ;   zval1d(1) = -1.   ;   ENDIF
+         IF( in2d == 0 ) THEN   ;   in2d = 1   ;   clna2d(1) = 'no2d'   ;   zval2d(1) = -1.   ;   ENDIF
+         IF( in3d == 0 ) THEN   ;   in3d = 1   ;   clna3d(1) = 'no3d'   ;   zval3d(1) = -1.   ;   ENDIF
+         ! update the file header before closing it
+         WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 )              &
+            &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
+            &   jpni, jpnj, jpnij, narea, jpiglo, jpjglo,              &
+            &   nlcit, nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+         IF( (ivnum * (jpvnl + wp)) > irecl8 ) THEN 
+            CALL ctl_stop( TRIM(clinfo),   &
+                 &   'Last record size is too big... You could reduce the value of jpvnl' )
+         ELSE 
+            WRITE( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                        &
+                 &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
+                 &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
+         ENDIF
+      ELSE
+         ios = 0   ! we cannot write in the file
+      ENDIF
+      !
+      CLOSE( idrst, IOSTAT = ios, ERR = 987 )
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo),   &
+            &   '   error when updating the header of '//TRIM(iom_file(kiomid)%name), ctmp1 )
+      ENDIF
+      !    
+   END SUBROUTINE iom_rstdimg_close
+
+
+   SUBROUTINE iom_rstdimg_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_rstdimg_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with RSTDIMG
+      !!-----------------------------------------------------------------------
+      INTEGER,  INTENT(in   ) ::   kiomid    ! Identifier of the file
+      INTEGER,  INTENT(in   ) ::   kvid      ! variable id
+      REAL(wp), INTENT(  out) ::   pvar      ! read field
+      !---------------------------------------------------------------------
+      !
+      pvar = iom_file(kiomid)%ofs(kvid)   ! warning: trick... we use ofs to store the value
+      !
+   END SUBROUTINE iom_rstdimg_g0d
+
+
+   SUBROUTINE iom_rstdimg_rp0d( kiomid, cdvar, kvid, pv_r0d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
+      !!
+      !! ** Purpose : write a scalar with RSTDIMG
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in) ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)          , INTENT(in) ::   cdvar    ! time axis name
+      INTEGER                   , INTENT(in) ::   kvid     ! variable id
+      REAL(wp)                  , INTENT(in) ::   pv_r0d   ! written 0d field
+      !
+      CHARACTER(LEN=100) ::   clinfo     ! info character
+      INTEGER            ::   idvar      ! variable id
+      !---------------------------------------------------------------------
+      !  
+      clinfo = '                    iom_rstdimg_rp0d ~~~  '
+      IF( kvid <= 0 ) THEN   !   new variable
+         idvar = iom_file(kiomid)%nvars + 1
+      ELSE                   !   the variable already exists in the file
+         idvar = kvid
+      ENDIF
+      IF( idvar <= jpmax_vars ) THEN
+         iom_file(kiomid)%nvars = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(   idvar) = 1   ! useless, Od variables a strored in record 1
+         iom_file(kiomid)%ndims(  idvar) = 0
+         iom_file(kiomid)%luld(   idvar) = .FALSE.
+         iom_file(kiomid)%scf(    idvar) = 1.
+         iom_file(kiomid)%ofs(    idvar) = pv_r0d   ! warning: trick... we use ofs to store the value
+      ELSE
+         CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
+      ENDIF
+   END SUBROUTINE iom_rstdimg_rp0d
+
+
+   SUBROUTINE iom_rstdimg_g123d( kiomid, kdom  , kvid, kx1, kx2, ky1, ky2,   &
+         &                       pv_r1d, pv_r2d, pv_r3d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_rstdimg_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with RSTDIMG
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
+      INTEGER                    , INTENT(in   )           ::   kvid       ! variable id
+      INTEGER ,                    INTENT(inout)           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+
+      CHARACTER(LEN=100) ::   clinfo               ! info character
+      INTEGER            ::   ios                  ! IO status
+      INTEGER            ::   jk                   ! loop counter
+      INTEGER            ::   idrst                ! logical unit of the restart file
+      !---------------------------------------------------------------------
+      clinfo = '                    iom_rstdimg_g123d ~~~  '
+      !
+      IF( kdom == jpdom_data .OR. kdom == jpdom_global ) THEN
+         CALL ctl_stop( TRIM(clinfo), TRIM(iom_file(kiomid)%cn_var(kvid))//': case not coded for rstdimg files' )
+      ELSE
+      !
+         idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+         ! modify the subdomain indexes because we cannot directly extract the appropriate subdomaine
+         IF(     kdom == jpdom_local_full    ) THEN   ;   kx1 = 1   ;   kx2 = jpi    ;   ky1 = 1
+         ELSEIF( kdom == jpdom_local_noextra ) THEN   ;   kx1 = 1   ;   kx2 = nlci   ;   ky1 = 1
+         ENDIF
+         !
+         IF(     PRESENT(pv_r1d) ) THEN   ! read 1D variables
+            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r1d(:)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ! read 2D variables
+            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r2d(kx1:kx2, ky1:ky2    )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ! read 3D variables
+            DO jk = 1, iom_file(kiomid)%dimsz(3,kvid)   ! do loop on each level
+               READ( idrst, REC = iom_file(kiomid)%nvid(kvid) + jk - 1, IOSTAT = ios, ERR = 987 )   pv_r3d(kx1:kx2, ky1:ky2, jk)
+            END DO
+         ENDIF
+987      CONTINUE
+         IF( ios /= 0 ) THEN
+            WRITE(ctmp1,*) '           iostat = ', ios
+            CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE iom_rstdimg_g123d
+
+
+   SUBROUTINE iom_rstdimg_rp123d( kiomid, cdvar, kvid, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
+      !!
+      !! ** Purpose : write a 2D/3D variable with RSTDIMG
+      !!--------------------------------------------------------------------
+      INTEGER                         , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)                , INTENT(in)           ::   cdvar    ! time axis name
+      INTEGER                         , INTENT(in)           ::   kvid     ! variable id
+      REAL(wp), DIMENSION(        jpk), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(jpi,jpj    ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      CHARACTER(LEN=100)    ::   clinfo               ! info character
+      INTEGER               ::   irecl8               ! reacord length
+      INTEGER               ::   ios                  ! IO status
+      INTEGER               ::   idrst                ! reacord length
+      INTEGER               ::   inx, iny, inz        ! x,y,z dimension of the variable
+      INTEGER               ::   idvar                ! variable id
+      INTEGER               ::   istop                ! temporary storage of nstop
+      INTEGER               ::   irec                 ! record number
+      INTEGER               ::   ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER               ::   jk                   ! loop counter
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_rstdimg_rp123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      istop = nstop                   ! store the actual value of nstop
+      irec = iom_file(kiomid)%irec    ! get back the record number of the variable
+      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+      IF( kvid <= 0 ) THEN   !   new variable
+         idvar = iom_file(kiomid)%nvars + 1
+      ELSE                   !   the variable already exists in the file
+         idvar = kvid
+      ENDIF
+      IF( idvar > jpmax_vars )   CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
+      IF( .NOT. PRESENT(pv_r1d) ) THEN
+         ! find which part of data must be written
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz
+         IF(     inx == (nlei - nldi + 1) .AND. iny == (nlej - nldj + 1) ) THEN
+            ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+         ELSEIF( inx == nlci              .AND. iny == nlcj              ) THEN
+            ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+         ELSEIF( inx == jpi               .AND. iny == jpj               ) THEN
+            ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+         ELSE 
+            CALL ctl_stop( clinfo, 'should have been an impossible case...' )
+         ENDIF
+      ENDIF
+      IF( istop == nstop ) THEN
+         ! write the data
+         IF(     PRESENT(pv_r1d) ) THEN   ! 1D variable
+            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r1d(:)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ! 2D variable
+            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r2d(ix1:ix2, iy1:iy2    )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ! 3D variable
+            DO jk = 1, jpk   ! do loop on each level
+               WRITE( idrst, REC = irec + jk - 1, IOSTAT = ios, ERR = 987 ) pv_r3d(ix1:ix2, iy1:iy2, jk)
+            END DO
+         ENDIF
+         ! fill the file informations
+         iom_file(kiomid)%nvars = idvar
+         IF(     PRESENT(pv_r1d) ) THEN
+            iom_file(kiomid)%irec              = irec + 1
+            iom_file(kiomid)%ndims(     idvar) = 1
+            iom_file(kiomid)%dimsz(1  , idvar) = inz
+         ELSEIF( PRESENT(pv_r2d) ) THEN
+            iom_file(kiomid)%irec              = irec + 1
+            iom_file(kiomid)%ndims(     idvar) = 2
+            iom_file(kiomid)%dimsz(1:2, idvar) = (/ inx, iny /)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            iom_file(kiomid)%irec              = irec + inz
+            iom_file(kiomid)%ndims(     idvar) = 3
+            iom_file(kiomid)%dimsz(1:3, idvar) = (/ inx, iny, inz /)
+         ENDIF
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(  idvar) = irec
+         iom_file(kiomid)%luld(  idvar) = .FALSE.
+         iom_file(kiomid)%scf(   idvar) = 1.
+         iom_file(kiomid)%ofs(   idvar) = 0.
+      ENDIF
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
+      ELSE
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_rstdimg_rp123d
+
+
+   !!======================================================================
+END MODULE iom_rstdimg
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv.F90	(revision 1844)
@@ -0,0 +1,92 @@
+MODULE ldfeiv
+   !!======================================================================
+   !!                     ***  MODULE  ldfeiv  ***
+   !! Ocean physics:  variable eddy induced velocity coefficients
+   !!======================================================================
+#if   defined key_traldf_eiv   &&   defined key_traldf_c2d
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_eiv'      and                     eddy induced velocity
+   !!   'key_traldf_c2d'                    2D tracer lateral  mixing coef.
+   !!----------------------------------------------------------------------
+   !!   ldf_eiv      : compute the eddy induced velocity coefficients
+   !!                  Same results but not same routine if 'key_autotasking'
+   !!                  is defined or not
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC ldf_eiv               ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_eiv( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv  ***
+      !!
+      !! ** Purpose :   Compute the eddy induced velocity coefficient from the
+      !!      growth rate of baroclinic instability.
+      !!
+      !! ** Method : Specific to the offline model. Computes the horizontal
+      !!             values from the vertical value
+      !!
+      !! History :
+      !!   9.0  !  06-03  (O. Aumont)  Free form, F90
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step inedx
+
+      !! * Local declarations
+      INTEGER ::   ji, jj           ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'ldf_eiv : eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Average the diffusive coefficient at u- v- points
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            aeiu(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )
+            aeiv(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )
+         END DO
+      END DO
+
+      ! lateral boundary condition on aeiu, aeiv
+      CALL lbc_lnk( aeiu, 'U', 1. )
+      CALL lbc_lnk( aeiv, 'V', 1. )
+
+   END SUBROUTINE ldf_eiv
+
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Dummy module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ldf_eiv( kt )       ! Empty routine
+      WRITE(*,*) 'ldf_eiv: You should not have seen this print! error?', kt
+   END SUBROUTINE ldf_eiv
+#endif
+
+   !!======================================================================
+END MODULE ldfeiv
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfeiv_substitute.h90	(revision 1844)
@@ -0,0 +1,38 @@
+#if defined key_traldf_eiv   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!                   ***  ldfeiv_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsaei. the eddy induced velocity coeff.
+   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+#  if defined key_traldf_c3d
+!   'traldf_c3d' :                           eiv: 3D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(i,j,k)
+#    define   fsaeiv(i,j,k)   aeiv(i,j,k)
+#    define   fsaeiw(i,j,k)   aeiw(i,j,k)
+#  elif defined key_traldf_c2d
+!   'traldf_c2d' :                           eiv: 2D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(i,j)
+#    define   fsaeiv(i,j,k)   aeiv(i,j)
+#    define   fsaeiw(i,j,k)   aeiw(i,j)
+#  elif defined key_traldf_c1d
+!   'traldf_c1d' :                           eiv: 1D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(k)
+#    define   fsaeiv(i,j,k)   aeiv(k)
+#    define   fsaeiw(i,j,k)   aeiw(k)
+#  else
+!   Default option :                          eiv: Constant coefficient
+#    define   fsaeiu(i,j,k)   aeiv0
+#    define   fsaeiv(i,j,k)   aeiv0
+#    define   fsaeiw(i,j,k)   aeiv0
+#  endif
+#else
+!   Default option :                         eiv: dummy variables
+#    define   fsaeiu(i,j,k)   aeiv0
+#    define   fsaeiv(i,j,k)   aeiv0
+#    define   fsaeiw(i,j,k)   aeiv0
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfslp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfslp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldfslp.F90	(revision 1844)
@@ -0,0 +1,769 @@
+MODULE ldfslp
+   !!======================================================================
+   !!                       ***  MODULE  ldfslp  ***
+   !! Ocean physics: slopes of neutral surfaces
+   !!======================================================================
+#if   defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                      Rotation of lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   ldf_slp      : compute the slopes of neutral surface
+   !!   ldf_slp_mxl  : compute the slopes of iso-neutral surface
+   !!   ldf_slp_init : initialization of the slopes computation
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer depth
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC ldf_slp        ! routine called by step.F90
+
+   !! * Share module variables
+   LOGICAL , PUBLIC, PARAMETER ::   lk_ldfslp = .TRUE.     !: slopes flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      uslp, wslpi,         &  !: i_slope at U- and W-points
+      vslp, wslpj             !: j-slope at V- and W-points
+   
+   !! * Module variables
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      omlmask                 ! mask of the surface mixed layer at T-pt
+   REAL(wp), DIMENSION(jpi,jpj) ::   &
+      uslpml, wslpiml,     &  ! i_slope at U- and W-points just below
+   !                          ! the surface mixed layer
+      vslpml, wslpjml         ! j_slope at V- and W-points just below
+   !                          ! the surface mixed layer
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_slp( kt, prd, pn2 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldf_slp  ***
+      !! 
+      !! ** Purpose :   Compute the slopes of neutral surface (slope of iso-
+      !!      pycnal surfaces referenced locally) ('key_traldfiso').
+      !!
+      !! ** Method  :   The slope in the i-direction is computed at U- and 
+      !!      W-points (uslp, wslpi) and the slope in the j-direction is 
+      !!      computed at V- and W-points (vslp, wslpj).
+      !!      They are bounded by 1/100 over the whole ocean, and within the
+      !!      surface layer they are bounded by the distance to the surface
+      !!      ( slope<= depth/l  where l is the length scale of horizontal
+      !!      diffusion (here, aht=2000m2/s ==> l=20km with a typical velocity
+      !!      of 10cm/s)
+      !!        A horizontal shapiro filter is applied to the slopes
+      !!        ln_sco=T, s-coordinate, add to the previously computed slopes
+      !!      the slope of the model level surface.
+      !!        macro-tasked on horizontal slab (jk-loop)  (2, jpk-1)
+      !!      [slopes already set to zero at level 1, and to zero or the ocean
+      !!      bottom slope (ln_sco=T) at level jpk in inildf]
+      !!
+      !! ** Action : - uslp, wslpi, and vslp, wslpj, the i- and  j-slopes 
+      !!               of now neutral surfaces at u-, w- and v- w-points, resp.
+      !!
+      !! History :
+      !!   7.0  !  94-12  (G. Madec, M. Imbard)  Original code
+      !!   8.0  !  97-06  (G. Madec)  optimization, lbc
+      !!   8.1  !  99-10  (A. Jouzeau)  NEW profile
+      !!   8.5  !  99-10  (G. Madec)  Free form, F90
+      !!   9.0  !  05-10  (A. Beckmann)  correction for s-coordinates
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce            , zgru  => ua,  &  ! use ua as workspace
+                           zgrv  => va,  &  ! use va as workspace
+                           zwy   => ta,  &  ! use ta as workspace
+                           zwz   => sa      ! use sa as workspace
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
+         prd,                            &  ! in situ density
+         pn2                                ! Brunt-Vaisala frequency (locally ref.)
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk              ! dummy loop indices
+      INTEGER  ::   ii0, ii1, ij0, ij1,  &  ! temporary integer
+         &          iku, ikv                !    "          "
+      REAL(wp) ::   &
+         zeps, zmg, zm05g,               &  ! temporary scalars
+         zcoef1, zcoef2, zcoef3,         &  !
+         zau, zbu, zav, zbv,             &
+         zai, zbi, zaj, zbj,             &
+         zcofu, zcofv, zcofw,            &
+         z1u, z1v, z1wu, z1wv,           &
+         zalpha
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zww
+      !!----------------------------------------------------------------------
+
+      
+      ! 0. Initialization (first time-step only)
+      !    --------------
+      
+      IF( kt == nit000 ) CALL ldf_slp_init
+      
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+      
+      zeps  =  1.e-20
+      zmg   = -1.0 / grav
+      zm05g = -0.5 / grav
+
+      zww(:,:,:) = 0.e0
+      zwz(:,:,:) = 0.e0
+
+      ! horizontal density gradient computation
+      DO jk = 1, jpk
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zgru(ji,jj,jk) = umask(ji,jj,jk) * ( prd(ji+1,jj  ,jk) - prd(ji,jj,jk) ) 
+               zgrv(ji,jj,jk) = vmask(ji,jj,jk) * ( prd(ji  ,jj+1,jk) - prd(ji,jj,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      IF( ln_zps ) THEN      ! partial steps correction at the bottom ocean level (zps_hde routine)
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               ! last ocean level
+               iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj) ) - 1
+               ikv = MIN ( mbathy(ji,jj), mbathy(ji,jj+1) ) - 1
+               zgru(ji,jj,iku) = gru(ji,jj) 
+               zgrv(ji,jj,ikv) = grv(ji,jj)               
+# if ! defined key_vectopt_loop 
+            END DO
+# endif
+         END DO
+      ENDIF
+
+      ! Slopes of isopycnal surfaces just below the mixed layer
+      ! -------------------------------------------------------
+      
+      CALL ldf_slp_mxl( prd, pn2 )
+      
+      !-------------------synchro---------------------------------------------
+
+      !                                                ! ===============
+      DO jk = 2, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         ! I.  slopes at u and v point
+         ! ===========================
+         
+         
+         ! I.1. Slopes of isopycnal surfaces
+         ! ---------------------------------
+         ! uslp = d/di( prd ) / d/dz( prd )
+         ! vslp = d/dj( prd ) / d/dz( prd )
+         
+         ! Local vertical density gradient evaluated from N^2
+         ! zwy = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwy(ji,jj,jk) = zmg * ( prd(ji,jj,jk) + 1. )                &
+                  &          * ( pn2(ji,jj,jk) + pn2(ji,jj,jk+1) )       &
+                  &          / MAX( tmask(ji,jj,jk) + tmask (ji,jj,jk+1), 1. )
+            END DO
+         END DO
+         
+         ! Slope at u and v points
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! horizontal and vertical density gradient at u- and v-points
+               zau = 1. / e1u(ji,jj) * zgru(ji,jj,jk)
+               zav = 1. / e2v(ji,jj) * zgrv(ji,jj,jk)
+               zbu = 0.5 * ( zwy(ji,jj,jk) + zwy(ji+1,jj  ,jk) )
+               zbv = 0.5 * ( zwy(ji,jj,jk) + zwy(ji  ,jj+1,jk) )
+               ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+               !                   kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbu = MIN( zbu, -100.*ABS( zau ), -7.e+3/fse3u(ji,jj,jk)*ABS( zau ) )
+               zbv = MIN( zbv, -100.*ABS( zav ), -7.e+3/fse3v(ji,jj,jk)*ABS( zav ) )
+               ! uslp and vslp output in zwz and zww, resp.
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj,jk) )
+               zwz (ji,jj,jk) = ( zau / ( zbu - zeps ) * ( 1. - zalpha)   &
+                  &           + zalpha * uslpml(ji,jj)                    &
+                  &                    * 0.5 * ( fsdept(ji+1,jj,jk)+fsdept(ji,jj,jk)-fse3u(ji,jj,1) )   &
+                  &                          / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 5. ) ) * umask(ji,jj,jk)
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji,jj+1,jk) )
+               zww (ji,jj,jk) = ( zav / ( zbv - zeps ) * ( 1. - zalpha)   &
+                  &           + zalpha * vslpml(ji,jj)                    &
+                  &                    * 0.5 * ( fsdept(ji,jj+1,jk)+fsdept(ji,jj,jk)-fse3v(ji,jj,1) )   &
+                  &                          / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 5. ) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   end of slab
+      !                                                ! ===============
+
+
+         ! lateral boundary conditions on zww and zwz
+         CALL lbc_lnk( zwz, 'U', -1. )
+         CALL lbc_lnk( zww, 'V', -1. )
+
+      !                                                ! ===============
+      DO jk = 2, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         
+         ! Shapiro filter applied in the horizontal direction
+         zcofu = 1. / 16.
+         zcofv = 1. / 16.
+         DO jj = 2, jpjm1, jpj-3   ! row jj=2 and =jpjm1 only
+            DO ji = 2, jpim1  
+               !uslop
+               uslp(ji,jj,jk) = zcofu * (       zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +     zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*(zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +     zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.* zwz(ji  ,jj  ,jk)                       )
+               ! vslop
+               vslp(ji,jj,jk) = zcofv * (       zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +     zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*(zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +     zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.* zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+
+         DO jj = 3, jpj-2
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! uslop
+               uslp(ji,jj,jk) = zcofu * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
+               ! vslop
+               vslp(ji,jj,jk) = zcofv * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+
+         ! decrease along coastal boundaries
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z1u  = ( umask(ji,jj+1,jk) + umask(ji,jj-1,jk) )*.5
+               z1v  = ( vmask(ji+1,jj,jk) + vmask(ji-1,jj,jk) )*.5
+               z1wu = ( umask(ji,jj,jk)   + umask(ji,jj,jk+1) )*.5
+               z1wv = ( vmask(ji,jj,jk)   + vmask(ji,jj,jk+1) )*.5
+               uslp(ji,jj,jk) = uslp(ji,jj,jk) * z1u * z1wu
+               vslp(ji,jj,jk) = vslp(ji,jj,jk) * z1v * z1wv
+            END DO
+         END DO
+
+
+         ! II. Computation of slopes at w point
+         ! ====================================
+         
+         
+         ! II.1 Slopes of isopycnal surfaces
+         ! ---------------------------------
+         ! wslpi = mij( d/di( prd ) / d/dz( prd )
+         ! wslpj = mij( d/dj( prd ) / d/dz( prd )
+         
+         
+         ! Local vertical density gradient evaluated from N^2
+         !     zwy = d/dz(prd)= - mk ( prd ) / grav * pn2 -- at w point
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwy (ji,jj,jk) = zm05g * pn2 (ji,jj,jk) *   &
+                  &                     ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. )
+            END DO
+         END DO
+         
+         ! Slope at w point
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! horizontal density i-gradient at w-points
+               zcoef1 = MAX( zeps, umask(ji-1,jj,jk  )+umask(ji,jj,jk  )    &
+                  &               +umask(ji-1,jj,jk-1)+umask(ji,jj,jk-1) )
+               zcoef1 = 1. / ( zcoef1 * e1t (ji,jj) )
+               zai = zcoef1 * (  zgru(ji  ,jj,jk  ) + zgru(ji  ,jj,jk-1)   &
+                  &            + zgru(ji-1,jj,jk-1) + zgru(ji-1,jj,jk  ) ) * tmask (ji,jj,jk)
+               ! horizontal density j-gradient at w-points
+               zcoef2 = MAX( zeps, vmask(ji,jj-1,jk  )+vmask(ji,jj,jk-1)   &
+                  &               +vmask(ji,jj-1,jk-1)+vmask(ji,jj,jk  ) )
+               zcoef2 = 1.0 / ( zcoef2 *  e2t (ji,jj) )
+               zaj = zcoef2 * (  zgrv(ji,jj  ,jk  ) + zgrv(ji,jj  ,jk-1)   &
+                  &            + zgrv(ji,jj-1,jk-1) + zgrv(ji,jj-1,jk  ) ) * tmask (ji,jj,jk)
+               ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
+               !                   static instability:
+               !                   kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbi = MIN( zwy (ji,jj,jk),- 100.*ABS(zai), -7.e+3/fse3w(ji,jj,jk)*ABS(zai) )
+               zbj = MIN( zwy (ji,jj,jk), -100.*ABS(zaj), -7.e+3/fse3w(ji,jj,jk)*ABS(zaj) )
+               ! wslpi and wslpj output in zwz and zww, resp.
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji,jj,jk-1) )
+               zcoef3 = fsdepw(ji,jj,jk) / MAX( hmlp(ji,jj), 10. )
+               zwz(ji,jj,jk) = (     zai / ( zbi - zeps)  * ( 1. - zalpha )   &
+                  &             + zcoef3 * wslpiml(ji,jj) *        zalpha   ) * tmask (ji,jj,jk)
+               zww(ji,jj,jk) = (     zaj / ( zbj - zeps)  * ( 1. - zalpha )   &
+                  &             + zcoef3 * wslpjml(ji,jj) *        zalpha   ) * tmask (ji,jj,jk)
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   end of slab
+      !                                                ! ===============
+
+
+      ! lateral boundary conditions on zwz and zww
+      CALL lbc_lnk( zwz, 'T', -1. )
+      CALL lbc_lnk( zww, 'T', -1. )
+
+      !                                                ! ===============
+      DO jk = 2, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         ! Shapiro filter applied in the horizontal direction
+
+         DO jj = 2, jpjm1, jpj-3   ! row jj=2 and =jpjm1
+            DO ji = 2, jpim1
+               zcofw = tmask(ji,jj,jk)/16.
+               wslpi(ji,jj,jk) = (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                  &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                  &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                  &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zwz(ji  ,jj  ,jk)                        ) * zcofw
+
+               wslpj(ji,jj,jk) = (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                  &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                  &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                  &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zww(ji  ,jj  ,jk)                        ) * zcofw
+            END DO
+         END DO
+         
+         DO jj = 3, jpj-2
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcofw = tmask(ji,jj,jk)/16.
+               wslpi(ji,jj,jk) = (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                  &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                  &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                  &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zwz(ji  ,jj  ,jk)                        ) * zcofw
+
+               wslpj(ji,jj,jk) = (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                  &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                  &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                  &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zww(ji  ,jj  ,jk)                        ) * zcofw
+            END DO
+         END DO
+         
+         ! decrease the slope along the boundaries
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z1u = ( umask(ji,jj,jk) + umask(ji-1,jj,jk) ) *.5
+               z1v = ( vmask(ji,jj,jk) + vmask(ji,jj-1,jk) ) *.5
+               wslpi(ji,jj,jk) = wslpi(ji,jj,jk) * z1u * z1v
+               wslpj(ji,jj,jk) = wslpj(ji,jj,jk) * z1u * z1v
+            END DO
+         END DO
+         
+         
+         ! III. Specific grid points
+         ! -------------------------
+
+         IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
+            !                                        ! =======================
+            ! Horizontal diffusion in                !  ORCA_R4 configuration 
+            ! specific area                          ! =======================
+            !
+            !                                             ! Gibraltar Strait
+            ij0 =  50   ;   ij1 =  53
+            ii0 =  69   ;   ii1 =  71   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ij0 =  51   ;   ij1 =  53
+            ii0 =  68   ;   ii1 =  71   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ii0 =  69   ;   ii1 =  71   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ii0 =  69   ;   ii1 =  71   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+
+            !                                             ! Mediterrannean Sea
+            ij0 =  49   ;   ij1 =  56
+            ii0 =  71   ;   ii1 =  90   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ij0 =  50   ;   ij1 =  56
+            ii0 =  70   ;   ii1 =  90   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ii0 =  71   ;   ii1 =  90   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+            ii0 =  71   ;   ii1 =  90   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk ) = 0.e0
+         ENDIF
+         !                                             ! ===============
+      END DO                                           !   end of slab
+      !                                                ! ===============       
+
+      
+      ! III Lateral boundary conditions on all slopes (uslp , vslp, 
+      ! -------------------------------                wslpi, wslpj )
+      CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+      CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk)
+         CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk)
+      ENDIF
+
+   END SUBROUTINE ldf_slp
+
+
+   SUBROUTINE ldf_slp_mxl( prd, pn2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_slp_mxl  ***
+      !! ** Purpose :
+      !!     Compute the slopes of iso-neutral surface (slope of isopycnal
+      !!   surfaces referenced locally) just above the mixed layer.
+      !!
+      !! ** Method :
+      !!      The slope in the i-direction is computed at u- and w-points
+      !!   (uslp, wslpi) and the slope in the j-direction is computed at
+      !!   v- and w-points (vslp, wslpj).
+      !!   They are bounded by 1/100 over the whole ocean, and within the
+      !!   surface layer they are bounded by the distance to the surface
+      !!   ( slope<= depth/l  where l is the length scale of horizontal
+      !!   diffusion (here, aht=2000m2/s ==> l=20km with a typical velocity
+      !!   of 10cm/s)
+      !!
+      !! ** Action :
+      !!      Compute uslp, wslpi, and vslp, wslpj, the i- and  j-slopes
+      !!   of now neutral surfaces at u-, w- and v- w-points, resp.
+      !!
+      !! History :
+      !!   8.1  !  99-10  (A. Jouzeau)  Original code
+      !!   8.5  !  99-10  (G. Madec)  Free form, F90
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce           , zgru  => ua,  &  ! ua, va used as workspace and set to hor. 
+                          zgrv  => va      ! density gradient in ldf_slp
+
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
+         prd,                           &  ! in situ density
+         pn2                              ! Brunt-Vaisala frequency (locally ref.)
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk             ! dummy loop indices
+      INTEGER  ::   ik, ikm1               ! temporary integers
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zwy                               ! temporary workspace
+      REAL(wp) ::   &
+         zeps, zmg, zm05g,              &  ! temporary scalars
+         zcoef1, zcoef2,                &  !    "         "
+         zau, zbu, zav, zbv,            &  !    "         "
+         zai, zbi, zaj, zbj                !    "         "
+      !!----------------------------------------------------------------------
+
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+
+      zeps  =  1.e-20
+      zmg   = -1.0 / grav
+      zm05g = -0.5 / grav
+
+
+      uslpml (1,:) = 0.e0      ;      uslpml (jpi,:) = 0.e0
+      vslpml (1,:) = 0.e0      ;      vslpml (jpi,:) = 0.e0
+      wslpiml(1,:) = 0.e0      ;      wslpiml(jpi,:) = 0.e0
+      wslpjml(1,:) = 0.e0      ;      wslpjml(jpi,:) = 0.e0
+
+      ! surface mixed layer mask
+
+      ! mask for mixed layer
+      DO jk = 1, jpk
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+# endif
+               ! mixed layer interior (mask = 1) and exterior (mask = 0)
+               ik = nmln(ji,jj) - 1
+               IF( jk <= ik ) THEN
+                  omlmask(ji,jj,jk) = 1.e0
+               ELSE
+                  omlmask(ji,jj,jk) = 0.e0
+               ENDIF
+# if ! defined key_vectopt_loop 
+            END DO
+# endif
+         END DO
+      END DO
+
+
+      ! Slopes of isopycnal surfaces just before bottom of mixed layer
+      ! --------------------------------------------------------------
+      ! uslpml = d/di( prd ) / d/dz( prd )
+      ! vslpml = d/dj( prd ) / d/dz( prd )
+
+      ! Local vertical density gradient evaluated from N^2
+      ! zwy = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+
+      !-----------------------------------------------------------------------
+      zwy(:,jpj) = 0.e0
+      zwy(jpi,:) = 0.e0
+# if defined key_vectopt_loop 
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) )
+            ! if ik = jpk take jpkm1 values
+            ik = MIN( ik,jpkm1 )
+            zwy(ji,jj) = zmg * ( prd(ji,jj,ik) + 1. )   &
+               &             * ( pn2(ji,jj,ik) + pn2(ji,jj,ik+1) )   &
+               &             / MAX( tmask(ji,jj,ik) + tmask (ji,jj,ik+1), 1. )
+# if ! defined key_vectopt_loop 
+         END DO
+# endif
+      END DO
+      ! lateral boundary conditions on zwy
+      CALL lbc_lnk( zwy, 'U', -1. )
+
+      ! Slope at u points
+# if defined key_vectopt_loop 
+      jj = 1
+      DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ! horizontal and vertical density gradient at u-points
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) )
+            ik = MIN( ik,jpkm1 )
+            zau = 1./ e1u(ji,jj) * zgru(ji,jj,ik)
+            zbu = 0.5*( zwy(ji,jj) + zwy(ji+1,jj) )
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+            !                         kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbu = MIN( zbu, -100.*ABS(zau), -7.e+3/fse3u(ji,jj,ik)*ABS(zau) )
+            ! uslpml
+            uslpml (ji,jj) = zau / ( zbu - zeps ) * umask (ji,jj,ik)
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! lateral boundary conditions on uslpml
+      CALL lbc_lnk( uslpml, 'U', -1. )
+
+      ! Local vertical density gradient evaluated from N^2
+      !     zwy = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+      zwy ( :, jpj) = 0.e0
+      zwy ( jpi, :) = 0.e0
+# if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) )
+            ik = MIN( ik,jpkm1 )
+            zwy(ji,jj) = zmg * ( prd(ji,jj,ik) + 1. )   &
+               &             * ( pn2(ji,jj,ik) + pn2(ji,jj,ik+1) )   &
+               &             / MAX( tmask(ji,jj,ik) + tmask (ji,jj,ik+1), 1. )
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! lateral boundary conditions on zwy
+      CALL lbc_lnk( zwy, 'V', -1. )
+
+      ! Slope at v points
+# if defined key_vectopt_loop
+      jj = 1
+      DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ! horizontal and vertical density gradient at v-points
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) )
+            ik = MIN( ik,jpkm1 )
+            zav = 1./ e2v(ji,jj) * zgrv(ji,jj,ik)
+            zbv = 0.5*( zwy(ji,jj) + zwy(ji,jj+1) )
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+            !                         kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbv = MIN( zbv, -100.*ABS(zav), -7.e+3/fse3v(ji,jj,ik)*ABS( zav ) )
+            ! vslpml
+            vslpml (ji,jj) = zav / ( zbv - zeps ) * vmask (ji,jj,ik)
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! lateral boundary conditions on vslpml
+      CALL lbc_lnk( vslpml, 'V', -1. )
+
+      ! wslpiml = mij( d/di( prd ) / d/dz( prd )
+      ! wslpjml = mij( d/dj( prd ) / d/dz( prd )
+
+
+      ! Local vertical density gradient evaluated from N^2
+      ! zwy = d/dz(prd)= - mk ( prd ) / grav * pn2 -- at w point
+# if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+# endif
+            ik = nmln(ji,jj)+1
+            ik = MIN( ik,jpk )
+            ikm1 = MAX ( 1, ik-1)
+            zwy (ji,jj) = zm05g * pn2 (ji,jj,ik) *     &
+               &             ( prd (ji,jj,ik) + prd (ji,jj,ikm1) + 2. )
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! Slope at w point
+# if defined key_vectopt_loop
+      jj = 1
+      DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ik = nmln(ji,jj)+1
+            ik = MIN( ik,jpk )
+            ikm1 = MAX ( 1, ik-1)
+            ! horizontal density i-gradient at w-points
+            zcoef1 = MAX( zeps, umask(ji-1,jj,ik  )+umask(ji,jj,ik  )   &
+               &               +umask(ji-1,jj,ikm1)+umask(ji,jj,ikm1) )
+            zcoef1 = 1. / ( zcoef1 * e1t (ji,jj) )
+            zai = zcoef1 * (  zgru(ji  ,jj,ik  ) + zgru(ji  ,jj,ikm1)   &
+               &            + zgru(ji-1,jj,ikm1) + zgru(ji-1,jj,ik  ) ) * tmask (ji,jj,ik)
+            ! horizontal density j-gradient at w-points
+            zcoef2 = MAX( zeps, vmask(ji,jj-1,ik  )+vmask(ji,jj,ikm1)    &
+               &               +vmask(ji,jj-1,ikm1)+vmask(ji,jj,ik  ) )
+            zcoef2 = 1.0 / ( zcoef2 *  e2t (ji,jj) )
+            zaj = zcoef2 * (  zgrv(ji,jj  ,ik  ) + zgrv(ji,jj  ,ikm1)   &
+               &            + zgrv(ji,jj-1,ikm1) + zgrv(ji,jj-1,ik  ) ) * tmask (ji,jj,ik)
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
+            !                   static instability:
+            !                   kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbi = MIN ( zwy (ji,jj),- 100.*ABS(zai), -7.e+3/fse3w(ji,jj,ik)*ABS(zai) )
+            zbj = MIN ( zwy (ji,jj), -100.*ABS(zaj), -7.e+3/fse3w(ji,jj,ik)*ABS(zaj) )
+            ! wslpiml and wslpjml
+            wslpiml (ji,jj) = zai / ( zbi - zeps) * tmask (ji,jj,ik)
+            wslpjml (ji,jj) = zaj / ( zbj - zeps) * tmask (ji,jj,ik)
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! lateral boundary conditions on wslpiml and wslpjml
+      CALL lbc_lnk( wslpiml, 'W', -1. )
+      CALL lbc_lnk( wslpjml, 'W', -1. )
+
+   END SUBROUTINE ldf_slp_mxl
+
+
+   SUBROUTINE ldf_slp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_slp_init  ***
+      !!
+      !! ** Purpose :   Initialization for the isopycnal slopes computation
+      !!
+      !! ** Method  :   read the nammbf namelist and check the parameter 
+      !!      values called by tra_dmp at the first timestep (nit000)
+      !!
+      !! History :
+      !!  8.5  ! 02-06 (G. Madec) original code
+      !!----------------------------------------------------------------------
+      !! * local declarations
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      
+      
+      ! Parameter control and print
+      ! ---------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'ldf_slp : direction of lateral mixing'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Direction of lateral diffusion (tracers and/or momentum)
+      ! ------------------------------
+      ! set the slope to zero (even in s-coordinates)
+
+      uslp (:,:,:) = 0.e0
+      vslp (:,:,:) = 0.e0
+      wslpi(:,:,:) = 0.e0
+      wslpj(:,:,:) = 0.e0
+
+      uslpml (:,:) = 0.e0
+      vslpml (:,:) = 0.e0
+      wslpiml(:,:) = 0.e0
+      wslpjml(:,:) = 0.e0
+
+      IF( ln_traldf_hor ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '          Horizontal mixing in s-coordinate: slope = slope of s-surfaces'
+         ENDIF
+
+         ! geopotential diffusion in s-coordinates on tracers and/or momentum
+         ! The slopes of s-surfaces are computed once (no call to ldfslp in step)
+         ! The slopes for momentum diffusion are i- or j- averaged of those on tracers
+
+         ! set the slope of diffusion to the slope of s-surfaces
+         !      ( c a u t i o n : minus sign as fsdep has positive value )
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept(ji+1,jj,jk) - fsdept(ji ,jj ,jk) ) * umask(ji,jj,jk)
+                  vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept(ji,jj+1,jk) - fsdept(ji ,jj ,jk) ) * vmask(ji,jj,jk)
+                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw(ji+1,jj,jk) - fsdepw(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
+                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw(ji,jj+1,jk) - fsdepw(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
+               END DO
+            END DO
+         END DO
+
+         ! Lateral boundary conditions on the slopes
+         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+      ENDIF
+
+   END SUBROUTINE ldf_slp_init
+
+#else
+   !!------------------------------------------------------------------------
+   !!   Dummy module :                 NO Rotation of lateral mixing tensor
+   !!------------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_ldfslp = .FALSE.    !: slopes flag
+CONTAINS
+   SUBROUTINE ldf_slp( kt, prd, pn2 )        ! Dummy routine
+      INTEGER, INTENT(in) :: kt 
+      REAL,DIMENSION(:,:,:), INTENT(in) :: prd, pn2
+      WRITE(*,*) 'ldf_slp: You should not have seen this print! error?', kt, prd(1,1,1), pn2(1,1,1)
+   END SUBROUTINE ldf_slp
+#endif
+
+   !!======================================================================
+END MODULE ldfslp
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra.F90	(revision 1844)
@@ -0,0 +1,165 @@
+MODULE ldftra
+   !!======================================================================
+   !!                       ***  MODULE  ldftra  ***
+   !! Ocean physics:  lateral diffusivity coefficient 
+   !!=====================================================================
+   !! History :
+   !!        !  07-97  (G. Madec)  from inimix.F split in 2 routines
+   !!        !  08-97  (G. Madec)  multi dimensional coefficients
+   !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+   !!   9.0  !  05-11  (G. Madec)  
+   !!----------------------------------------------------------------------
+   !!   ldf_tra_init : initialization, namelist read, and parameters control
+   !!   ldf_tra_c3d   : 3D eddy viscosity coefficient initialization
+   !!   ldf_tra_c2d   : 2D eddy viscosity coefficient initialization
+   !!   ldf_tra_c1d   : 1D eddy viscosity coefficient initialization
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE ldfslp          ! ???
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC ldf_tra_init   ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_tra_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_tra_init  ***
+      !! 
+      !! ** Purpose :   initializations of the tracer lateral mixing coeff.
+      !!
+      !! ** Method  :   the Eddy diffusivity and eddy induced velocity ceoff.
+      !!      are defined as follows:
+      !!         default option   : constant coef. aht0, aeiv0 (namelist)
+      !!        'key_traldf_c1d': depth dependent coef. defined in 
+      !!                            in ldf_tra_c1d routine
+      !!        'key_traldf_c2d': latitude and longitude dependent coef.
+      !!                            defined in ldf_tra_c2d routine
+      !!        'key_traldf_c3d': latitude, longitude, depth dependent coef.
+      !!                            defined in ldf_tra_c3d routine
+      !!
+      !!      N.B. User defined include files.  By default, 3d and 2d coef.
+      !!      are set to a constant value given in the namelist and the 1d
+      !!      coefficients are initialized to a hyperbolic tangent vertical
+      !!      profile.
+      !!
+      !!----------------------------------------------------------------------
+      USE ioipsl
+
+      INTEGER ::   ioptio               ! ???
+      LOGICAL ::   ll_print = .FALSE.   ! =T print eddy coef. in numout
+       
+      NAMELIST/namtraldf/ ln_traldf_lap  , ln_traldf_bilap,                &
+         &                 ln_traldf_level, ln_traldf_hor, ln_traldf_iso,   &
+         &                 aht0, ahtb0, aeiv0
+      !!----------------------------------------------------------------------
+
+      !  Define the lateral tracer physics parameters
+      ! =============================================
+    
+      ! Read Namelist namtraldf : Lateral physics on tracers
+      REWIND( numnam )
+      READ  ( numnam, namtraldf )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'ldf_tra_init : lateral tracer physics'
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+         WRITE(numout,*) '          Namelist namtraldf : lateral mixing coefficients'
+         WRITE(numout,*) '             laplacian operator          ln_traldf_lap   = ', ln_traldf_lap
+         WRITE(numout,*) '             bilaplacian operator        ln_traldf_bilap = ', ln_traldf_bilap
+         WRITE(numout,*) '             lateral eddy diffusivity             aht0   = ', aht0
+         WRITE(numout,*) '             background hor. diffusivity          ahtb0  = ', ahtb0
+         WRITE(numout,*) '             eddy induced velocity coef.          aeiv0  = ', aeiv0
+         WRITE(numout,*)
+      ENDIF
+
+      ! Parameter control
+
+      ! ... Check consistency for type and direction :
+      !           ==> will be done in traldf module
+
+      ! ... Space variation of eddy coefficients
+      ioptio = 0
+#if defined key_traldf_c3d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth)'
+      ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c2d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude)'
+      ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c1d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( depth )'
+      ioptio = ioptio + 1
+      IF( .NOT. ln_zco ) &
+           &   CALL ctl_stop( '          key_traldf_c1d can only be used in z-coordinate - full step' )
+#endif
+      IF( ioptio == 0 ) THEN
+          IF(lwp) WRITE(numout,*) '          tracer mixing coef. = constant (default option)'
+        ELSEIF( ioptio > 1 ) THEN
+           CALL ctl_stop('          use only one of the following keys:',   &
+             &           ' key_traldf_c3d, key_traldf_c2d, key_traldf_c1d' )
+      ENDIF
+
+      IF( ln_traldf_bilap ) THEN
+         IF(lwp) WRITE(numout,*) '          biharmonic tracer diffusion'
+         IF( aht0 > 0 .AND. .NOT. lk_esopa )   &
+              &   CALL ctl_stop( '          The horizontal diffusivity coef. aht0 must be negative' )
+      ELSE
+         IF(lwp) WRITE(numout,*) '          harmonic tracer diffusion (default)'
+         IF( aht0 < 0 .AND. .NOT. lk_esopa )   &
+              &   CALL ctl_stop('          The horizontal diffusivity coef. aht0 must be positive' )
+      ENDIF
+
+
+      !  Lateral eddy diffusivity and eddy induced velocity coefficients
+      ! ================================================================
+
+#if defined key_traldf_c3d
+      CALL ldf_tra_c3d( ll_print )      ! aht = 3D coef. = F( longitude, latitude, depth )
+#elif defined key_traldf_c2d
+      CALL ldf_tra_c2d( ll_print )      ! aht = 2D coef. = F( longitude, latitude )
+#elif defined key_traldf_c1d
+      CALL ldf_tra_c1d( ll_print )      ! aht = 1D coef. = F( depth )
+#else
+                                        ! Constant coefficients
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) '          constant eddy diffusivity coef.   ahtu = ahtv = ahtw = aht0 = ', aht0
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) '          constant eddy induced velocity coef.   aeiu = aeiv = aeiw = aeiv0 = ', aeiv0
+      ENDIF
+#endif
+
+   END SUBROUTINE ldf_tra_init
+
+#if defined key_traldf_c3d
+#   include "ldftra_c3d.h90"
+#elif defined key_traldf_c2d
+#   include "ldftra_c2d.h90"
+#elif defined key_traldf_c1d
+#   include "ldftra_c1d.h90"
+#endif
+
+   !!======================================================================
+END MODULE ldftra
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c1d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c1d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c1d.h90	(revision 1844)
@@ -0,0 +1,133 @@
+   !!----------------------------------------------------------------------
+   !!                      ***  ldftra_c1d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c1d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldftra_c1d  ***
+      !!              
+      !! ** Purpose :   1D eddy diffusivity coefficient
+      !!
+      !! ** Method  :   1D eddy diffusivity coefficients ( depth )
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!
+      !!       harmonic operator      : ahtt never used
+      !!          -1-  iso-model level: ahtu = ahtv defined at T-level
+      !!                                ahtw never used
+      !!          -2-  isopycnal or   : ahtu = ahtv defined at T-level
+      !!               geopotential     ahtw defined at w-level
+      !!
+      !!       eddy induced velocity
+      !!         always harmonic      : aeiu = aeiv defined at T-level
+      !!				  aeiw defined at w-level
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, print arrays in numout
+
+      !! * Local variables
+      INTEGER ::   jk                  ! dummy loop indices
+      REAL(wp) ::   &
+         zkah, zahr, za00 , za01,   &  ! temporary scalars
+         zahf, zahs, zahtf, zahts
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN 
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 1D eddy diffusivity and eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   -- ' 
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 1D eddy diffusivity coefficient '
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   -- '
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      ! initialization of the profile
+
+      ! ahts, ahtf: surface and bottom values
+      zahts = aht0
+      zahtf = aht0/4. 
+      ! zkah, zahr: depth of the inflection pt and width of inflection
+      zkah =  -300.
+      zahr =   300.
+      ! computation coefficients
+      za00 = TANH( ( -fsdept(1,1,1  ) - zkah ) / zahr )
+      za01 = TANH( ( -fsdept(1,1,jpk) - zkah ) / zahr )
+      zahf = ( zahts-zahtf ) / ( za00 - za01 )
+      zahs = zahts - zahf * za00
+
+      ! biharmonic operator : (T-point)
+      ! ==================== 
+
+      ! set ahtt at T-level
+      DO jk = 1, jpk
+         ahtt(jk) = zahs + zahf * TANH( (-fsdept(1,1,jk)-zkah) / zahr )
+      END DO
+
+      ! control print
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         aht profile at T-level : '
+         WRITE(numout,*)
+         WRITE(numout,*) ' level    aht          depth t-level '
+         DO jk = 1, jpk
+            WRITE(numout,'(i6,2f12.4)') jk, ahtt(jk), fsdept(1,1,jk)
+         END DO
+      ENDIF
+
+      ! harmonic operator : (U-, V-, W-points)
+      ! ================== 
+
+      ! set ahtu = ahtv at T-level, and ahtw at w-level
+      DO jk = 1, jpk
+         ahtu(jk) = zahs + zahf * TANH( ( -fsdept(1,1,jk) - zkah ) / zahr )
+         ahtv(jk) = ahtu(jk)
+         ahtw(jk) = zahs + zahf * TANH( ( -fsdepw(1,1,jk) - zkah ) / zahr )
+      END DO
+
+      ! control print
+      IF(lwp .AND. ld_print ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aht profile at T-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' level    aht          depth t-level '
+         DO jk = 1, jpk
+            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, ahtu(jk), fsdept(1,1,jk)
+         END DO
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aht profile at W-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  jk      aht          depth w-level '
+         DO jk = 1, jpk
+            IF(lwp)WRITE(numout,"(i6,2f12.4)") jk, ahtw(jk), fsdepw(1,1,jk)
+         END DO
+      ENDIF
+
+# if defined key_traldf_eiv
+      ! set aeiu = aeiv and set aeiw (here same profile as on aht)
+      aeiu(:) = ahtu(:)
+      aeiv(:) = aeiu(:)
+      aeiw(:) = ahtw(:)
+      
+      ! Control print
+      IF(lwp .AND. ld_print ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aeiv profile at T-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  jk      aeiv           depth t-level '
+         DO jk = 1, jpk
+            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, aeiu(jk), fsdept(1,1,jk)
+         END DO
+      ENDIF
+#endif
+
+   END SUBROUTINE ldf_tra_c1d
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c2d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c2d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c2d.h90	(revision 1844)
@@ -0,0 +1,146 @@
+   !!----------------------------------------------------------------------
+   !!                      ***  ldftra_c2d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c2d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldftra_c2d  ***
+      !!              
+      !! ** Purpose :   initializations of horizontally non uniform eddy 
+      !!      diffusivity coefficients
+      !!
+      !! ** Method :
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!       harmonic operator (ahtt never used)
+      !!           iso-model level   : ahtu, ahtv defined at u-, v-points
+      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
+      !!         or geopotential   
+      !!       eddy induced velocity
+      !!           always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, print arrays in numout
+
+      !! * Local variables
+# if defined key_traldf_eiv && defined key_orca_r4
+      INTEGER ::   ji, jj                  ! dummy loop indices
+# endif
+# if defined key_orca_r4
+      INTEGER :: i1, i2, j1, j2
+# endif
+      REAL(wp) ::   za00, zdx_max
+      
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 2D eddy diffusivity and eddy'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   --  induced velocity coefficients'
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 2D eddy diffusivity coefficient'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   --'
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      ! harmonic operator : (U-, V-, W-points)
+      ! ==================
+      IF( ln_traldf_lap ) THEN
+
+         ahtu(:,:) = aht0                ! set ahtu = ahtv at u- and v-points,
+         ahtv(:,:) = aht0                ! and ahtw at w-point (idem T-point)
+         ahtw(:,:) = aht0                ! 
+
+         CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( ahtv, 'V', 1. )   ! (no change of sign)
+         CALL lbc_lnk( ahtw, 'W', 1. )
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtu array'
+            CALL prihre( ahtu, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtv array'
+            CALL prihre( ahtv, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtw array'
+            CALL prihre( ahtw, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+         ENDIF
+      ENDIF
+      
+      ! biharmonic operator : (T-point)
+      ! ====================
+      IF( ln_traldf_bilap ) THEN
+         ! (USER: modify ahtt following your desiderata)
+         ! Here: ahm is proportional to the cube of the maximum of the gridspacing
+         !       in the to horizontal direction
+
+         zdx_max = MAXVAL( e1t(:,:) )
+         IF( lk_mpp )   CALL mpp_max( zdx_max )   ! max over the global domain
+
+         za00 = aht0 / ( zdx_max * zdx_max * zdx_max )
+         ahtt(:,:) = za00 * e1t(:,:) * e1t(:,:) *e1t(:,:)      ! set ahtt at T-point 
+
+         CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: 2D ahtt array'
+            CALL prihre( ahtt, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+         ENDIF
+      ENDIF
+
+# if defined key_traldf_eiv
+      ! set aeiu = aeiv at u- and v-points, and aeiw at w-point (idem T-point)
+      ! (here no space variation)
+      aeiu(:,:) = aeiv0
+      aeiv(:,:) = aeiv0
+      aeiw(:,:) = aeiv0
+      
+      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
+         !                                 ! Cancel eiv in Gibraltar strait
+         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         !                                 ! Cancel eiv in Mediterrannean sea
+         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+      ENDIF
+
+      ! Lateral boundary conditions on ( aeiu, aeiv, aeiw )
+      CALL lbc_lnk( aeiu, 'U', 1. )
+      CALL lbc_lnk( aeiv, 'V', 1. )
+      CALL lbc_lnk( aeiw, 'W', 1. )
+
+      ! Control print
+      IF( lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiu array'
+         CALL prihre(aeiu,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiv array'
+         CALL prihre(aeiv,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiw array'
+         CALL prihre(aeiw,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+# endif
+
+   END SUBROUTINE ldf_tra_c2d
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c3d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c3d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_c3d.h90	(revision 1844)
@@ -0,0 +1,130 @@
+   !!----------------------------------------------------------------------
+   !!                        ***  ldftra_c3d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c3d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldftra_c3d  ***
+      !!                
+      !! ** Purpose :
+      !!     initializations of non uniform horizontal eddy diffusivity coef.
+      !!
+      !! ** Method :
+      !!      3D eddy diffusivity coefficients ( longitude, latitude, depth )
+      !!
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!
+      !!       harmonic operator (ahtt never used)
+      !!         iso-model level   : ahtu, ahtv defined at u-, v-points
+      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
+      !!         or geopotential
+      !!
+      !!       eddy induced velocity
+      !!         always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
+      !!
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ioipsl
+
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk                   ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 3D eddy diffusivity and eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   --  '
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 3D eddy diffusivity coefficient'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   -- '
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+
+      ! biharmonic operator   (T-point)
+      ! -------------------
+
+      ahtt(:,:,:) = aht0              ! set ahtt at T-point (here no space variation)
+
+      CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
+
+      IF(lwp .AND. ld_print ) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtt at k = 1'
+         CALL prihre( ahtt(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+      ENDIF
+
+
+      ! harmonic operator   (U-, V-, W-points)
+      ! ----------------- 
+
+      ahtu(:,:,:) = aht0              ! set ahtu = ahtv at u- and v-points,
+      ahtv(:,:,:) = aht0              ! and ahtw at w-point
+      ahtw(:,:,:) = aht0              ! (here example: no space variation)
+      
+      CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
+      CALL lbc_lnk( ahtv, 'V', 1. )
+      CALL lbc_lnk( ahtw, 'W', 1. )
+
+      IF(lwp .AND. ld_print ) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtu at k = 1'
+         CALL prihre( ahtu(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtv at k = 1'
+         CALL prihre( ahtv(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtw at k = 1'
+         CALL prihre( ahtw(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+      ENDIF
+
+# if defined key_traldf_eiv
+      aeiu(:,:,:) = aeiv0            ! set aeiu = aeiv at u- and v-points,
+      aeiv(:,:,:) = aeiv0            ! and aeiw at w-point
+      aeiw(:,:,:) = aeiv0            ! (here example: no space variation)
+
+      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
+         !                                 ! Cancel eiv in Gibraltar strait
+         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         !                                 ! Cancel eiv in Mediterrannean sea
+         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+      ENDIF
+
+      CALL lbc_lnk( aeiu, 'U', 1. )   ! Lateral boundary conditions 
+      CALL lbc_lnk( aeiv, 'V', 1. )
+      CALL lbc_lnk( aeiw, 'W', 1. )
+# endif
+
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiu at k = 1'
+         CALL prihre(aeiu(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiv at k = 1'
+         CALL prihre(aeiv(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiw at k = 1'
+         CALL prihre(aeiw(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+END SUBROUTINE ldf_tra_c3d
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_oce.F90	(revision 1844)
@@ -0,0 +1,90 @@
+MODULE ldftra_oce
+   !!=====================================================================
+   !!                      ***  MODULE  ldftra_oce  ***
+   !! Ocean physics :  lateral tracer mixing coefficient defined in memory 
+   !!=====================================================================
+   !!
+   !! ** Purpose : - Define in memory lateral tracer mixing coefficients
+   !!
+   !! History :
+   !!   9.0  !  02-11  (G. Madec)  Original code (from common.h)
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !!----------------------------------------------------------------------
+   !! Lateral eddy diffusivity coefficients (tracers)
+   !!----------------------------------------------------------------------
+
+   LOGICAL , PUBLIC ::              & !!: ** lateral mixing namelist (nam_traldf) **
+      ln_traldf_lap   = .TRUE.  ,   &  !: laplacian operator
+      ln_traldf_bilap = .FALSE. ,   &  !: bilaplacian operator
+      ln_traldf_level = .FALSE. ,   &  !: iso-level direction
+      ln_traldf_hor   = .FALSE. ,   &  !: horizontal (geopotential) direction
+      ln_traldf_iso   = .TRUE.         !: iso-neutral direction
+
+   REAL(wp), PUBLIC ::              & !!: ** lateral mixing namelist (namldf) **
+      aht0  = 2000._wp     ,        &  !: lateral eddy diffusivity (m2/s)
+      ahtb0 =    0._wp     ,        &  !: lateral background eddy diffusivity (m2/s)
+      aeiv0 = 2000._wp                 !: eddy induced velocity coefficient (m2/s)
+
+   LOGICAL , PUBLIC ::              &  !: flag of the lateral diff. scheme used 
+      l_traldf_lap         ,        &  !: iso-level laplacian operator
+      l_traldf_bilap       ,        &  !: iso-level bilaplacian operator
+      l_traldf_bilapg      ,        &  !: geopotential bilap. (s-coord)
+      l_traldf_iso         ,        &  !: iso-neutral laplacian or horizontal lapacian (s-coord)
+      l_trazdf_iso         ,        &  !: idem for the vertical component
+      l_trazdf_iso_vo      ,        &  !: idem with vectopt_memory
+      l_traldf_iso_zps                 !: iso-neutral laplacian (partial steps)
+
+#if defined key_traldf_c3d || defined key_off_degrad
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !: ** 3D coefficients **
+#elif defined key_traldf_c2d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   &  !: ** 2D coefficients **
+#elif defined key_traldf_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpk)         ::   &  !: ** 1D coefficients **
+#else
+   REAL(wp), PUBLIC                         ::   &  !: ** 0D coefficients **
+#endif
+      ahtt, ahtu, ahtv, ahtw                !: T-, U-, V-, W-points coefficients
+
+
+#if defined key_traldf_eiv
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_eiv'                              eddy induced velocity
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_traldf_eiv   = .TRUE.   !: eddy induced velocity flag
+      
+# if defined key_traldf_c3d || defined key_off_degrad
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !: ** 3D coefficients **
+# elif defined key_traldf_c2d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   &  !: ** 2D coefficients **
+# elif defined key_traldf_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpk)         ::   &  !: ** 1D coefficients **
+# else
+   REAL(wp), PUBLIC                         ::   &  !: ** 0D coefficients **
+# endif
+      aeiu, aeiv, aeiw                              !: U-, V-, W-points  induced velocity coef. (m2/s)
+
+# if defined key_diaeiv
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::    &  !:
+      u_eiv, v_eiv, w_eiv     !: The three component of the eddy induced velocity (m/s)
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                           NO eddy induced velocity
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_traldf_eiv   = .FALSE.   !: eddy induced velocity flag
+   REAL(wp), PUBLIC ::   aeiu, aeiv, aeiw
+#endif
+
+   !!----------------------------------------------------------------------
+END MODULE ldftra_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/LDF/ldftra_substitute.h90	(revision 1844)
@@ -0,0 +1,35 @@
+   !!----------------------------------------------------------------------
+   !!                    *** ldftra_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsaht. the eddy diffusivity coeff.
+   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+#if defined key_traldf_c3d
+!   'key_traldf_c3d' :                 aht: 3D coefficient
+#       define   fsahtt(i,j,k)   ahtt(i,j,k)
+#       define   fsahtu(i,j,k)   ahtu(i,j,k)
+#       define   fsahtv(i,j,k)   ahtv(i,j,k)
+#       define   fsahtw(i,j,k)   ahtw(i,j,k)
+#elif defined key_traldf_c2d
+!   'key_traldf_c2d' :                 aht: 2D coefficient
+#       define   fsahtt(i,j,k)   ahtt(i,j)
+#       define   fsahtu(i,j,k)   ahtu(i,j)
+#       define   fsahtv(i,j,k)   ahtv(i,j)
+#       define   fsahtw(i,j,k)   ahtw(i,j)
+#elif defined key_traldf_c1d
+!   'key_traldf_c1d' :                aht: 1D coefficient
+#       define   fsahtt(i,j,k)   ahtt(k)
+#       define   fsahtu(i,j,k)   ahtu(k)
+#       define   fsahtv(i,j,k)   ahtv(k)
+#       define   fsahtw(i,j,k)   ahtw(k)
+#else
+!   Default option :             aht: Constant coefficient
+#      define   fsahtt(i,j,k)   aht0
+#      define   fsahtu(i,j,k)   aht0
+#      define   fsahtv(i,j,k)   aht0
+#      define   fsahtw(i,j,k)   aht0
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbc_oce.F90	(revision 1844)
@@ -0,0 +1,28 @@
+MODULE sbc_oce
+   !!======================================================================
+   !!                       ***  MODULE  sbc_oce  ***
+   !! Surface module :   variables defined in core memory 
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+   !! History :  9.0   !  06-06  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   !!----------------------------------------------------------------------
+   !!              Ocean Surface Boundary Condition fields
+   !!----------------------------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utau      !: sea surface i-stress (ocean referential)     [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtau      !: sea surface j-stress (ocean referential)     [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   wndm      !: wind speed module at T-point (=|U10m - Uoce|)[m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns       !: sea heat flux: non solar                     [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr       !: sea heat flux:     solar                     [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp       !: freshwater budget: volume flux               [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emps      !: freshwater budget: concentration/dillution   [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr_i      !: ice fraction (between 0 to 1)
+
+END MODULE sbc_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbcrnf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbcrnf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SBC/sbcrnf.F90	(revision 1844)
@@ -0,0 +1,24 @@
+MODULE sbcrnf
+   !!======================================================================
+   !!                       ***  MODULE  sbcrnf  ***
+   !! Ocean forcing:  river runoff
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!=====================================================================
+   !! History :       !  00-11  (R. Hordoir, E. Durand)  NetCDF FORMAT
+   !!            8.5  !  02-09  (G. Madec)  F90: Free form and module
+   !!            9.0  !  06-07  (G. Madec)  Surface module 
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk      !: river mouth mask (hori.)
+   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z    !: river mouth mask (vert.)
+
+   
+   !!======================================================================
+END MODULE sbcrnf
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SOL/sol_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SOL/sol_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/SOL/sol_oce.F90	(revision 1844)
@@ -0,0 +1,29 @@
+MODULE sol_oce
+   !!======================================================================
+   !!                    ***  MODULE  sol_oce  ***
+   !! Ocean solver :  solver variables defined in memory 
+   !!=====================================================================
+   !!
+   !! ** Purpose :   Define in memory solver variables
+   !!
+   !! History :
+   !!   9.0  !  02-11  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !!-----------------------------------
+   !! elliptic solver: SOR, PCG or FETI
+   !! ----------------------------------
+   INTEGER , PUBLIC ::      & !!: namsol   elliptic solver / island / free surface
+      nsolv    =    1          !: = 1/2/3/4 type of elliptic solver
+
+   !!----------------------------------------------------------------------
+END MODULE sol_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/trabbl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/trabbl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/trabbl.F90	(revision 1844)
@@ -0,0 +1,139 @@
+MODULE trabbl
+   !!==============================================================================
+   !!                       ***  MODULE  trabbl  ***
+   !! Ocean physics :  advective and/or diffusive bottom boundary layer scheme
+   !!==============================================================================
+#if   defined key_trabbl_dif   ||   defined key_trabbl_adv   || defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trabbl_dif'   or            diffusive bottom boundary layer
+   !!----------------------------------------------------------------------
+   !!   tra_bbl_dif  : update the active tracer trends due to the bottom
+   !!                  boundary layer (diffusive only)
+   !!   tra_bbl_init : initialization, namlist read, parameters control
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_bbl_dif    ! routine called by step.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::            &  !!: * bbl namelist *
+      atrbbl = 1.e+3                  !: lateral coeff. for bottom boundary 
+      !                               !  layer scheme (m2/s)
+   REAL(wp) , PUBLIC , DIMENSION(jpi,jpj) :: &
+      bblx, bbly    ! Bottom boundary layer coefficients
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+
+CONTAINS
+
+   SUBROUTINE tra_bbl_dif( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_bbl_dif  ***
+      !!
+      !! ** Purpose :   Compute the before tracer (t & s) trend associated 
+      !!      with the bottom boundary layer and add it to the general trend 
+      !!      of tracer equations. The bottom boundary layer is supposed to be
+      !!      a purely diffusive bottom boundary layer.
+      !!
+      !! ** Method  :   When the product grad( rho) * grad(h) < 0 (where grad 
+      !!      is an along bottom slope gradient) an additional lateral diffu-
+      !!      sive trend along the bottom slope is added to the general tracer
+      !!      trend, otherwise nothing is done.
+      !!      Second order operator (laplacian type) with variable coefficient
+      !!      computed as follow for temperature (idem on s): 
+      !!         difft = 1/(e1t*e2t*e3t) { di-1[ ahbt e2u*e3u/e1u di[ztb] ]
+      !!                                 + dj-1[ ahbt e1v*e3v/e2v dj[ztb] ] }
+      !!      where ztb is a 2D array: the bottom ocean temperature and ahtb
+      !!      is a time and space varying diffusive coefficient defined by:
+      !!         ahbt = zahbp    if grad(rho).grad(h) < 0
+      !!              = 0.       otherwise.
+      !!      Note that grad(.) is the along bottom slope gradient. grad(rho)
+      !!      is evaluated using the local density (i.e. referenced at the
+      !!      local depth). Typical value of ahbt is 2000 m2/s (equivalent to
+      !!      a downslope velocity of 20 cm/s if the condition for slope
+      !!      convection is satified)
+      !!      Add this before trend to the general trend (ta,sa) of the 
+      !!      botton ocean tracer point:
+      !!         ta = ta + difft
+      !!
+      !! ** Action  : - update (ta,sa) at the bottom level with the bottom
+      !!                boundary layer trend
+      !!              - save the trends in bbltrd ('key_diatrends')
+      !!
+      !! References :
+      !!     Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
+      !!
+      !! History :
+      !!   8.0  !  96-06  (L. Mortier)  Original code
+      !!   8.0  !  97-11  (G. Madec)  Optimization
+      !!   8.5  !  02-08  (G. Madec)  free form + modules
+      !!----------------------------------------------------------------------
+      !! * Arguments 
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step
+
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_bbl_init
+
+   END SUBROUTINE tra_bbl_dif
+
+   SUBROUTINE tra_bbl_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_bbl_init  ***
+      !!
+      !! ** Purpose :   Initialization for the bottom boundary layer scheme.
+      !!
+      !! ** Method  :   Read the nam_bbl namelist and check the parameters
+      !!      called by tra_bbl at the first timestep (nit000)
+      !!
+      !! History :
+      !!    8.5  !  02-08  (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      NAMELIST/nambbl/ atrbbl
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist nam_bbl : bottom boundary layer scheme
+      ! --------------------
+      REWIND ( numnam )
+      READ   ( numnam, nambbl )
+
+      ! Parameter control and print
+      ! ---------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_bbl_init : * Diffusive Bottom Boundary Layer'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '          Namelist nambbl : set bbl parameters'
+         WRITE(numout,*)
+         WRITE(numout,*) '          bottom boundary layer coef.    atrbbl = ', atrbbl
+         WRITE(numout,*)
+      ENDIF
+ 
+   END SUBROUTINE tra_bbl_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      No bottom boundary layer scheme
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE tra_bbl_dif (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'tra_bbl_dif: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_bbl_dif
+#endif
+
+   !!======================================================================
+END MODULE trabbl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/traqsr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/traqsr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/traqsr.F90	(revision 1844)
@@ -0,0 +1,82 @@
+MODULE traqsr
+   !!======================================================================
+   !!                       ***  MODULE  traqsr  ***
+   !! Ocean physics: solar radiation penetration in the top ocean levels
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   tra_qsr      : trend due to the solar radiation penetration
+   !!   tra_qsr_init : solar radiation penetration initialization
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_qsr_init ! routine called by opa.F90
+
+   !! * Shared module variables
+   LOGICAL , PUBLIC ::   ln_traqsr  = .TRUE.    !: light absorption (qsr) flag
+   LOGICAL , PUBLIC ::   ln_qsr_bio = .FALSE.   !: bio-optical retroaction
+   REAL(wp), PUBLIC ::   rn_abs     = 0.58_wp   !: fraction absorbed in the very near surface (RGB & 2 bands)
+   REAL(wp), PUBLIC ::   rn_si0     = 0.35_wp   !: very near surface depth of extinction      (RGB & 2 bands)
+   REAL(wp), PUBLIC ::   rn_si2     = 61.8_wp   !: deepest depth of extinction (blue & 0.01 mg.m-3)     (RGB)
+
+
+CONTAINS
+
+   SUBROUTINE tra_qsr_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_qsr_init  ***
+      !!
+      !! ** Purpose :   Initialization for the penetrative solar radiation
+      !!
+      !! ** Method  :   The profile of solar radiation within the ocean is set
+      !!      from two length scale of penetration (xsr1,xsr2) and a ratio
+      !!      (rabs). These parameters are read in the namqsr namelist. The
+      !!      default values correspond to clear water (type I in Jerlov' 
+      !!      (1968) classification.
+      !!         called by tra_qsr at the first timestep (nit000)
+      !!
+      !! ** Action  : - initialize xsr1, xsr2 and rabs
+      !!
+      !! Reference :
+      !!   Jerlov, N. G., 1968 Optical Oceanography, Elsevier, 194pp.
+      !!
+      !! History :
+      !!   8.5  !  02-06  (G. Madec) Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      NAMELIST/namqsr/ ln_qsr_bio, rn_abs, rn_si0, rn_si2
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist nam_qsr : ratio and length of penetration
+      ! --------------------
+      REWIND ( numnam )
+      READ   ( numnam, namqsr )
+
+      ln_qsr_bio = .FALSE. ! Offline mode : No retroaction on dynamics 
+      ! Parameter control and print
+      ! ---------------------------
+      IF(lwp) THEN                ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_qsr_init : penetration of the surface solar radiation'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '    Namelist namqsr : set the parameter of penetration'
+         WRITE(numout,*) '        bio-model            light penetration   ln_qsr_bio = ', ln_qsr_bio
+         WRITE(numout,*) '        RGB & 2 bands: fraction of light (rn_si1)    rn_abs = ', rn_abs
+         WRITE(numout,*) '        RGB & 2 bands: shortess depth of extinction  rn_si0 = ', rn_si0
+         WRITE(numout,*) '        3 bands: longest depth of extinction         rn_si2 = ', rn_si2
+      ENDIF
+      
+
+   END SUBROUTINE tra_qsr_init
+
+   !!======================================================================
+END MODULE traqsr
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/zpshde.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/zpshde.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/TRA/zpshde.F90	(revision 1844)
@@ -0,0 +1,241 @@
+MODULE zpshde
+   !!==============================================================================
+   !!                       ***  MODULE zpshde   ***
+   !! z-coordinate - partial step : Horizontal Derivative
+   !!==============================================================================
+   
+   !!----------------------------------------------------------------------
+   !!   zps_hde      :  Horizontal DErivative of T, S and rd at the last
+   !!                   ocean level (Z-coord. with Partial Steps)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space domain variables
+   USE oce             ! ocean dynamics and tracers variables
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE eosbn2          ! ocean equation of state
+   USE lbclnk          ! lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC zps_hde          ! routine called by step.F90
+
+   !! * module variables
+   INTEGER, DIMENSION(jpi,jpj) ::   &
+      mbatu, mbatv      ! bottom ocean level index at U- and V-points
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE zps_hde ( kt, ptem, psal, prd ,   &
+                            pgtu, pgsu, pgru,   &
+                            pgtv, pgsv, pgrv  )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE zps_hde  ***
+      !!                    
+      !! ** Purpose :   Compute the horizontal derivative of T, S and rd
+      !!      at u- and v-points with a linear interpolation for z-coordinate
+      !!      with partial steps.
+      !!
+      !! ** Method  :   In z-coord with partial steps, scale factors on last 
+      !!      levels are different for each grid point, so that T, S and rd 
+      !!      points are not at the same depth as in z-coord. To have horizontal
+      !!      gradients again, we interpolate T and S at the good depth : 
+      !!      Linear interpolation of T, S   
+      !!         Computation of di(tb) and dj(tb) by vertical interpolation:
+      !!          di(t) = t~ - t(i,j,k) or t(i+1,j,k) - t~
+      !!          dj(t) = t~ - t(i,j,k) or t(i,j+1,k) - t~
+      !!         This formulation computes the two cases:
+      !!                 CASE 1                   CASE 2  
+      !!         k-1  ___ ___________   k-1   ___ ___________
+      !!                    Ti  T~                  T~  Ti+1
+      !!                  _____                        _____
+      !!         k        |   |Ti+1     k           Ti |   |
+      !!                  |   |____                ____|   |
+      !!              ___ |   |   |           ___  |   |   |
+      !!                  
+      !!      case 1->   e3w(i+1) >= e3w(i) ( and e3w(j+1) >= e3w(j) ) then
+      !!          t~ = t(i+1,j  ,k) + (e3w(i+1) - e3w(i)) * dk(Ti+1)/e3w(i+1)
+      !!        ( t~ = t(i  ,j+1,k) + (e3w(j+1) - e3w(j)) * dk(Tj+1)/e3w(j+1)  )
+      !!          or
+      !!      case 2->   e3w(i+1) <= e3w(i) ( and e3w(j+1) <= e3w(j) ) then
+      !!          t~ = t(i,j,k) + (e3w(i) - e3w(i+1)) * dk(Ti)/e3w(i )
+      !!        ( t~ = t(i,j,k) + (e3w(j) - e3w(j+1)) * dk(Tj)/e3w(j ) )
+      !!          Idem for di(s) and dj(s)          
+      !!
+      !!      For rho, we call eos_insitu_2d which will compute rd~(t~,s~) at 
+      !!      the good depth zh from interpolated T and S for the different
+      !!      formulation of the equation of state (eos).
+      !!      Gradient formulation for rho :
+      !!          di(rho) = rd~ - rd(i,j,k) or rd (i+1,j,k) - rd~
+      !!
+      !! ** Action  : - pgtu, pgsu, pgru: horizontal gradient of T, S
+      !!                and rd at U-points 
+      !!              - pgtv, pgsv, pgrv: horizontal gradient of T, S
+      !!                and rd at V-points 
+      !!
+      !! History :
+      !!   8.5  !  02-04  (A. Bozec)  Original code
+      !!   8.5  !  02-08  (G. Madec E. Durand)  Optimization and Free form
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
+         ptem, psal, prd            ! 3D T, S and rd fields
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( out ) ::   &
+         pgtu, pgsu, pgru,       &  ! horizontal grad. of T, S and rd at u- 
+         pgtv, pgsv, pgrv           ! and v-points of the partial step level
+
+      !! * Local declarations
+      INTEGER ::   ji, jj,       &  ! Dummy loop indices
+                   iku,ikv          ! partial step level at u- and v-points
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zti, ztj, zsi, zsj,     &  ! interpolated value of T, S 
+         zri, zrj,               &  ! and rd
+         zhgi, zhgj                 ! depth of interpolation for eos2d
+      REAL(wp) ::   &
+         ze3wu, ze3wv,           &  ! temporary scalars
+         zmaxu1, zmaxu2,         &  !    "         "
+         zmaxv1, zmaxv2             !    "         "
+
+      ! Initialization (first time-step only): compute mbatu and mbatv
+      IF( kt == nit000 ) THEN
+         mbatu(:,:) = 0
+         mbatv(:,:) = 0
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               mbatu(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1, 2 )
+               mbatv(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1, 2 )
+            END DO
+         END DO
+         zti(:,:) = FLOAT( mbatu(:,:) )
+         ztj(:,:) = FLOAT( mbatv(:,:) )
+         ! lateral boundary conditions: T-point, sign unchanged
+         CALL lbc_lnk( zti , 'U', 1. )
+         CALL lbc_lnk( ztj , 'V', 1. )
+         mbatu(:,:) = MAX( INT( zti(:,:) ), 2 )
+         mbatv(:,:) = MAX( INT( ztj(:,:) ), 2 )
+      ENDIF
+      
+
+      ! Interpolation of T and S at the last ocean level
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ! last level
+            iku = mbatu(ji,jj)
+            ikv = mbatv(ji,jj)
+
+            ze3wu  = fse3w(ji+1,jj  ,iku) - fse3w(ji,jj,iku)
+            ze3wv  = fse3w(ji  ,jj+1,ikv) - fse3w(ji,jj,ikv)
+            zmaxu1 =  ze3wu / fse3w(ji+1,jj  ,iku)
+            zmaxu2 = -ze3wu / fse3w(ji  ,jj  ,iku)
+            zmaxv1 =  ze3wv / fse3w(ji  ,jj+1,ikv)
+            zmaxv2 = -ze3wv / fse3w(ji  ,jj  ,ikv)
+
+            ! i- direction
+
+            IF( ze3wu >= 0. ) THEN      ! case 1
+               ! interpolated values of T and S
+               zti(ji,jj) = ptem(ji+1,jj,iku) + zmaxu1 * ( ptem(ji+1,jj,iku-1) - ptem(ji+1,jj,iku) )
+               zsi(ji,jj) = psal(ji+1,jj,iku) + zmaxu1 * ( psal(ji+1,jj,iku-1) - psal(ji+1,jj,iku) )
+               ! depth of the partial step level
+               zhgi(ji,jj) = fsdept(ji,jj,iku)
+               ! gradient of T and S
+               pgtu(ji,jj) = umask(ji,jj,1) * ( zti(ji,jj) - ptem(ji,jj,iku) )
+               pgsu(ji,jj) = umask(ji,jj,1) * ( zsi(ji,jj) - psal(ji,jj,iku) )
+
+            ELSE                        ! case 2
+               ! interpolated values of T and S
+               zti(ji,jj) = ptem(ji,jj,iku) + zmaxu2 * ( ptem(ji,jj,iku-1) - ptem(ji,jj,iku) )
+               zsi(ji,jj) = psal(ji,jj,iku) + zmaxu2 * ( psal(ji,jj,iku-1) - psal(ji,jj,iku) )
+               ! depth of the partial step level
+               zhgi(ji,jj) = fsdept(ji+1,jj,iku)
+               ! gradient of T and S 
+               pgtu(ji,jj) = umask(ji,jj,1) * ( ptem(ji+1,jj,iku) - zti (ji,jj) )
+               pgsu(ji,jj) = umask(ji,jj,1) * ( psal(ji+1,jj,iku) - zsi (ji,jj) )
+            ENDIF
+
+            ! j- direction
+
+            IF( ze3wv >= 0. ) THEN      ! case 1
+               ! interpolated values of T and S
+               ztj(ji,jj) = ptem(ji,jj+1,ikv) + zmaxv1 * ( ptem(ji,jj+1,ikv-1) - ptem(ji,jj+1,ikv) )
+               zsj(ji,jj) = psal(ji,jj+1,ikv) + zmaxv1 * ( psal(ji,jj+1,ikv-1) - psal(ji,jj+1,ikv) )
+               ! depth of the partial step level
+               zhgj(ji,jj) = fsdept(ji,jj,ikv) 
+               ! gradient of T and S
+               pgtv(ji,jj) = vmask(ji,jj,1) * ( ztj(ji,jj) - ptem(ji,jj,ikv) )
+               pgsv(ji,jj) = vmask(ji,jj,1) * ( zsj(ji,jj) - psal(ji,jj,ikv) )
+
+            ELSE                        ! case 2
+               ! interpolated values of T and S
+               ztj(ji,jj) = ptem(ji,jj,ikv) + zmaxv2 * ( ptem(ji,jj,ikv-1) - ptem(ji,jj,ikv) )
+               zsj(ji,jj) = psal(ji,jj,ikv) + zmaxv2 * ( psal(ji,jj,ikv-1) - psal(ji,jj,ikv) ) 
+               ! depth of the partial step level
+               zhgj(ji,jj) = fsdept(ji,jj+1,ikv) 
+               ! gradient of T and S
+               pgtv(ji,jj) = vmask(ji,jj,1) * ( ptem(ji,jj+1,ikv) - ztj(ji,jj) )
+               pgsv(ji,jj) = vmask(ji,jj,1) * ( psal(ji,jj+1,ikv) - zsj(ji,jj) )
+            ENDIF
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! Compute interpolated rd from zti, zsi, ztj, zsj for the 2 cases at the depth of the partial
+      ! step and store it in  zri, zrj for each  case
+      CALL eos( zti, zsi, zhgi, zri )
+      CALL eos( ztj, zsj, zhgj, zrj )
+
+
+      ! Gradient of density at the last level 
+# if defined key_vectopt_loop 
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            iku = mbatu(ji,jj)
+            ikv = mbatv(ji,jj)
+            ze3wu  = fse3w(ji+1,jj  ,iku) - fse3w(ji,jj,iku)
+            ze3wv  = fse3w(ji  ,jj+1,ikv) - fse3w(ji,jj,ikv)
+            IF( ze3wu >= 0. ) THEN    ! i-direction: case 1
+               pgru(ji,jj) = umask(ji,jj,1) * ( zri(ji,jj) - prd(ji,jj,iku) )
+            ELSE                      ! i-direction: case 2
+               pgru(ji,jj) = umask(ji,jj,1) * ( prd(ji+1,jj,iku) - zri(ji,jj) )
+            ENDIF
+            IF( ze3wv >= 0. ) THEN    ! j-direction: case 1
+               pgrv(ji,jj) = vmask(ji,jj,1) * ( zrj(ji,jj) - prd(ji,jj,ikv) )  
+            ELSE                      ! j-direction: case 2
+               pgrv(ji,jj) = vmask(ji,jj,1) * ( prd(ji,jj+1,ikv) - zrj(ji,jj) )
+            ENDIF
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! Lateral boundary conditions on each gradient
+      CALL lbc_lnk( pgtu , 'U', -1. )   ;   CALL lbc_lnk( pgtv , 'V', -1. )
+      CALL lbc_lnk( pgsu , 'U', -1. )   ;   CALL lbc_lnk( pgsv , 'V', -1. )
+      CALL lbc_lnk( pgru , 'U', -1. )   ;   CALL lbc_lnk( pgrv , 'V', -1. )
+
+   END SUBROUTINE zps_hde
+
+   !!======================================================================
+END MODULE zpshde
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.h90	(revision 1844)
@@ -0,0 +1,58 @@
+   !! 
+   !!         ZDF.MATRIXSOLVER
+   !!       ********************
+   !! 
+   !! Matrix inversion
+   !!----------------------------------------------------------------------
+   !!   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+   !!
+   !!        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+   !!        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+   !!        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+   !!        (        ...               )( ...  ) ( ...  )
+   !!        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+   !!
+   !!   m is decomposed in the product of an upper and lower triangular
+   !!   matrix
+   !!   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+   !!   The second member is in 2d array zwy
+   !!   The solution is in 2d array zwx
+   !!   The 2d arry zwt and zwz are work space arrays
+   !!
+   !!   N.B. the starting vertical index (ikst) is equal to 1 except for
+   !!   the resolution of tke matrix where surface tke value is prescribed
+   !!   so that ikstrt=2.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+      ikstp1 = ikst + 1
+      ikenm2 = jpk - 2
+      DO ji = 2, jpim1
+         zwt(ji,ikst) = zwd(ji,ikst)
+      END DO
+      DO jk = ikstp1, jpkm1
+         DO ji = 2, jpim1
+            zwt(ji,jk) = zwd(ji,jk) - zwi(ji,jk) * zws(ji,jk-1) / zwt(ji,jk-1)
+         END DO
+      END DO
+      DO ji = 2, jpim1
+         zwz(ji,ikst) = zwy(ji,ikst)
+      END DO
+      DO jk = ikstp1, jpkm1
+         DO ji = 2, jpim1
+            zwz(ji,jk) = zwy(ji,jk) - zwi(ji,jk) / zwt(ji,jk-1) * zwz(ji,jk-1)
+         END DO
+      END DO
+      DO ji = 2, jpim1
+         zwx(ji,jpkm1) = zwz(ji,jpkm1) / zwt(ji,jpkm1)
+      END DO
+      DO jk = ikenm2, ikst, -1
+         DO ji = 2, jpim1
+            zwx(ji,jk) =( zwz(ji,jk) - zws(ji,jk) * zwx(ji,jk+1) ) / zwt(ji,jk)
+         END DO
+      END DO
+      
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.vopt.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.vopt.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf.matrixsolver.vopt.h90	(revision 1844)
@@ -0,0 +1,69 @@
+   !! 
+   !!         ZDF.MATRIXSOLVER
+   !!       ********************
+   !! 
+   !! Matrix inversion
+   !!----------------------------------------------------------------------
+   !!   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+   !!
+   !!        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+   !!        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+   !!        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+   !!        (        ...               )( ...  ) ( ...  )
+   !!        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+   !!
+   !!   m is decomposed in the product of an upper and lower triangular
+   !!   matrix
+   !!   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+   !!   The second member is in 2d array zwy
+   !!   The solution is in 2d array zwx
+   !!   The 3d arry zwt is a work space array
+   !!   zwy is used and then used as a work space array : its value is modified!
+   !!
+   !!   N.B. the starting vertical index (ikst) is equal to 1 except for
+   !!   the resolution of tke matrix where surface tke value is prescribed
+   !!   so that ikstrt=2.
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+      ikstp1 = ikst + 1
+      ikenm2 = jpk - 2
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,ikst) = zwd(ji,jj,ikst)
+         END DO
+      END DO
+
+      DO jk = ikstp1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      DO jk = ikstp1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwy(ji,jj,jk) = zwy(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * zwy(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            zwx(ji,jj,jpkm1) = zwy(ji,jj,jpkm1) / zwt(ji,jj,jpkm1)
+         END DO
+      END DO
+
+      DO jk = ikenm2, ikst, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwx(ji,jj,jk) = ( zwy(ji,jj,jk) - zws(ji,jj,jk) * zwx(ji,jj,jk+1) ) / zwt(ji,jj,jk)
+            END DO
+         END DO
+      END DO
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdf_oce.F90	(revision 1844)
@@ -0,0 +1,35 @@
+MODULE zdf_oce
+   !!======================================================================
+   !!              ***  MODULE  zdf_oce  ***
+   !! Ocean physics : define vertical mixing variables
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   zdf_init    : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! mesh and scale factors
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Share Module variables
+
+   REAL(wp), PUBLIC ::   & !!: namzdf   vertical diffusion
+      avt0  = 1.e-5_wp     !: vertical eddy diffusivity (m2/s)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      avt                   !: vertical diffusivity coeff. at w-point
+ 
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &   !:
+      avtb            !: background profile of avm and avt
+
+   LOGICAL, PUBLIC ::    &   !:
+      ln_zdfnpc        = .FALSE.        !: convection: non-penetrative convection flag
+ 
+   !!======================================================================
+END MODULE zdf_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfddm.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfddm.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfddm.F90	(revision 1844)
@@ -0,0 +1,140 @@
+MODULE zdfddm
+   !!======================================================================
+   !!                       ***  MODULE  zdfddm  ***
+   !! Ocean physics : double diffusion mixing parameterization
+   !!======================================================================
+#if defined key_zdfddm   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdfddm' :                                     double diffusion
+   !!----------------------------------------------------------------------
+   !!   zdf_ddm       : compute the Ks for salinity
+   !!   zdf_ddm_init  : read namelist and control the parameters
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC zdf_ddm     ! called by step.F90
+
+   !! * Shared module variables
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfddm = .TRUE.    !: double diffusive mixing flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      avs ,               &  !: salinity vertical diffusivity coeff. at w-point
+      rrau                   !: heat/salt buoyancy flux ratio
+
+   !! * Module variables
+   REAL(wp) ::            & !!! * double diffusive mixing namelist *
+      avts  = 1.e-4_wp      ! maximum value of avs for salt fingering
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+
+CONTAINS
+
+   SUBROUTINE zdf_ddm( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_ddm  ***
+      !!                    
+      !! ** Purpose :   Add to the vertical eddy diffusivity coefficient the 
+      !!      effect of salt fingering and diffusive convection. 
+      !!
+      !! ** Method  :   Diapycnal mixing is increased in case of double
+      !!      diffusive mixing (i.e. salt fingering and diffusive layering)
+      !!      following Merryfield et al. (1999). The rate of double diffusive 
+      !!      mixing depend on the buoyancy ratio: Rrau=alpha/beta dk[T]/dk[S]
+      !!      which is computed in rn2.F
+      !!         * salt fingering (Schmitt 1981):
+      !!      for Rrau > 1 and rn2 > 0 : zavfs = avts / ( 1 + (Rrau/hsbfr)^6 )
+      !!      for Rrau > 1 and rn2 > 0 : zavfs = O
+      !!      otherwise                : zavft = 0.7 zavs / Rrau
+      !!         * diffusive layering (Federov 1988):
+      !!      for 0< Rrau < 1 and rn2 > 0 : zavdt = 1.3635e-6  
+      !!                                 * exp( 4.6 exp(-0.54 (1/Rrau-1) ) )
+      !!      otherwise                   : zavdt = 0 
+      !!      for .5 < Rrau < 1 and rn2 > 0 : zavds = zavdt (1.885 Rrau -0.85)
+      !!      for  0 < Rrau <.5 and rn2 > 0 : zavds = zavdt 0.15 Rrau      
+      !!      otherwise                     : zavds = 0 
+      !!         * update the eddy diffusivity:
+      !!      avt = avt + zavft + zavdt
+      !!      avs = avs + zavfs + zavds
+      !!      avmu, avmv are required to remain at least above avt and avs.
+      !!      
+      !! ** Action  :   avt, avs : update vertical eddy diffusivity coef.
+      !!                           for temperature and salinity
+      !!
+      !! References :
+      !!      Merryfield et al., JPO, 29, 1124-1142, 1999.
+      !! History :
+      !!        !  00-08  (G. Madec)  double diffusive mixing
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step indexocean time step
+
+      !!----------------------------------------------------------------------
+
+
+      IF ( kt == nit000 )   CALL zdf_ddm_init          ! Initialization (first time-step only)
+
+
+   END SUBROUTINE zdf_ddm
+   
+   
+   SUBROUTINE zdf_ddm_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_ddm_init  ***
+      !!
+      !! ** Purpose :   Initialization of double diffusion mixing scheme
+      !!
+      !! ** Method  :   Read the nam_ddm namelist and check the parameter values
+      !!      called by zdf_ddm at the first timestep (nit000)
+      !!
+      !! History :
+      !!   8.5  !  02-08  (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      NAMELIST/nam_ddm/ avts
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist nam_ddm : double diffusion mixing scheme
+      ! --------------------
+      REWIND ( numnam )
+      READ   ( numnam, nam_ddm )
+
+
+      ! Parameter control and print
+      ! ---------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_ddm : double diffusive mixing'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '          Namelist nam_ddm : set dd mixing parameter'
+         WRITE(numout,*) '             maximum avs for dd mixing      avts   = ', avts
+         WRITE(numout,*)
+      ENDIF
+
+   END SUBROUTINE zdf_ddm_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :          Dummy module          No double diffusion
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfddm = .FALSE.   !: double diffusion flag
+CONTAINS
+   SUBROUTINE zdf_ddm( kt )           ! Dummy routine
+      WRITE(*,*) 'zdf_ddm: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_ddm
+#endif
+
+   !!======================================================================
+END MODULE zdfddm
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfini.F90	(revision 1844)
@@ -0,0 +1,65 @@
+MODULE zdfini
+   !!======================================================================
+   !!              ***  MODULE  zdfini  ***
+   !! Ocean physics : define vertical mixing variables
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   zdf_init    : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! mesh and scale factors
+   USE zdf_oce         ! TKE vertical mixing          
+   USE ldfslp          ! ???
+
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC zdf_init          ! routine called by opa.F90
+   
+CONTAINS
+
+   SUBROUTINE zdf_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_init  ***
+      !! 
+      !! ** Purpose :   initializations of the vertical ocean physics
+      !!
+      !! ** Method  :   Read namelist nam_zdf, control cpp keys
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code from inimix
+      !!   8.5  !  02-08  (G. Madec)  F90 : free form
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+
+      !! * Namelist
+      NAMELIST/nam_zdf/ avt0, ln_zdfnpc
+
+      ! Read nam_zdf namelist : vertical mixing parameters
+      ! --------------------
+      REWIND( numnam )
+      READ  ( numnam, nam_zdf )
+
+      ! Parameter print
+      ! ---------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_init: vertical physics'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '          Namelist nam_zdf : set vertical mixing mixing parameters'
+         WRITE(numout,*) '             non-penetrative convection       ln_zdfnpc = ', ln_zdfnpc
+         WRITE(numout,*) '             vertical eddy diffusivity           avt0   = ', avt0
+      ENDIF
+
+   END SUBROUTINE zdf_init
+
+   !!======================================================================
+END MODULE zdfini
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfmxl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfmxl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ZDF/zdfmxl.F90	(revision 1844)
@@ -0,0 +1,144 @@
+MODULE zdfmxl
+   !!======================================================================
+   !!                       ***  MODULE  zdfmxl  ***
+   !! Ocean physics: mixed layer depth 
+   !!======================================================================
+   !! History :
+   !!   9.0  !  03-08  (G. Madec)  OpenMP/autotasking optimization
+   !!----------------------------------------------------------------------
+   !!   zdf_mxl      : Compute the turbocline and mixed layer depths.
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC zdf_mxl           ! called by step.F90
+
+   !! * Shared module variables
+   INTEGER, PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      nmln                  !: number of level in the mixed layer
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      hmld ,             &  !: mixing layer depth (turbocline) (m)
+      hmlp ,             &  !: mixed layer depth  (rho=rho0+zdcrit) (m)
+      hmlpt                 !: mixed layer depth at t-points (m)
+
+   !! * module variables
+   REAL(wp) ::   &
+      avt_c = 5.e-4_wp,  &  ! Kz criterion for the turbocline depth
+      rho_c = 0.01_wp       ! density criterion for mixed layer depth
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_mxl( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdfmxl  ***
+      !!                   
+      !! ** Purpose :   Compute the turbocline depth and the mixed layer depth
+      !!      with density criteria.
+      !!
+      !! ** Method  :   The turbocline depth is the depth at which the vertical
+      !!      eddy diffusivity coefficient (resulting from the vertical physics
+      !!      alone, not the isopycnal part, see trazdf.F) fall below a given
+      !!      value defined locally (avt_c here taken equal to 5 cm/s2)
+      !!
+      !! ** Action  :
+      !!
+      !! History :
+      !!        !  94-11  (M. Imbard)  Original code
+      !!   8.0  !  96-01  (E. Guilyardi)  sub mixed layer temp.
+      !!   8.1  !  97-07  (G. Madec)  optimization
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk     ! dummy loop indices
+      INTEGER ::   ik             ! temporary integer
+      INTEGER, DIMENSION(jpi,jpj) ::   &
+         imld                     ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+
+      ! 1. Turbocline depth
+      ! -------------------
+      ! last w-level at which avt<avt_c (starting from the bottom jk=jpk)
+      ! (since avt(.,.,jpk)=0, we have jpk=< imld =< 2 )
+      DO jk = jpk, 2, -1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( avt(ji,jj,jk) < avt_c ) imld(ji,jj) = jk 
+            END DO
+         END DO
+      END DO
+
+      ! Turbocline depth and sub-turbocline temperature
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = imld(ji,jj)
+            hmld (ji,jj) = fsdepw(ji,jj,ik) * tmask(ji,jj,1)
+         END DO
+      END DO
+
+!!gm idea
+!!   
+!!gm  DO jk = jpk, 2, -1
+!!gm     DO jj = 1, jpj
+!!gm        DO ji = 1, jpi
+!!gm           IF( avt(ji,jj,jk) < avt_c ) hmld(ji,jj) = fsdepw(ji,jj,jk) * tmask(ji,jj,1)
+!!gm        END DO
+!!gm     END DO
+!!gm  END DO
+!!gm
+
+      ! 2. Mixed layer depth
+      ! --------------------
+      ! Initialization to the number of w ocean point mbathy
+      nmln(:,:) = mbathy(:,:)
+
+      ! Last w-level at which rhop>=rho surf+rho_c (starting from jpk-1)
+      ! (rhop defined at t-point, thus jk-1 for w-level just above)
+      DO jk = jpkm1, 2, -1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( rhop(ji,jj,jk) > rhop(ji,jj,1) + rho_c )   nmln(ji,jj) = jk
+            END DO
+         END DO
+      END DO
+
+      ! Mixed layer depth
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = nmln(ji,jj)
+            hmlp (ji,jj) = fsdepw(ji,jj,ik) * tmask(ji,jj,1)
+            hmlpt(ji,jj) = fsdept(ji,jj,ik-1)
+         END DO
+      END DO
+
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmld, clinfo2=' hmld : ', ovlap=1 )
+
+   END SUBROUTINE zdf_mxl
+
+   !!======================================================================
+END MODULE zdfmxl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ctlopn.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ctlopn.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/ctlopn.f90	(revision 1844)
@@ -0,0 +1,157 @@
+   SUBROUTINE ctlopn ( knum, cdfile, cdstat, cdform, cdacce,   &
+                       klengh, kout, ldwp, krequ )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ctlopn  ***
+      !!
+      !! ** Purpose :   Open file and check if required file is available.
+      !!
+      !! ** Method  :   Fortan open
+      !!
+      !! History :
+      !!        !  95-12  (G. Madec)  Original code
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      USE in_out_manager 
+
+      IMPLICIT NONE
+
+      INTEGER, INTENT( out ) ::   &
+         knum      ! logical unit to open
+      INTEGER, INTENT( in ) ::   &
+         krequ,    & ! =1 file required (stop if not exist)
+         !           ! =0 file not required (create the file if does not exist)
+         kout,     & ! number of logical units for write
+         klengh      ! record length
+
+      INTEGER ::   iost
+      CHARACTER (len=* ), INTENT( in ) ::   &
+         cdacce,   & ! access specifier
+         cdform,   & ! formatting specifier
+         cdstat      ! disposition specifier
+      CHARACTER (len=* ), INTENT( in ) ::   &
+         cdfile      ! file name to open
+
+      LOGICAL ::  ldwp   ! boolean term for print
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+
+      knum=getunit()
+
+      ! 1. Required file
+      ! ----------------
+
+      IF( krequ == 1 ) THEN
+
+         iost=0
+         IF( cdacce(1:6) == 'DIRECT' )  THEN
+            OPEN( UNIT=knum, FILE=cdfile, FORM=cdform, ACCESS=cdacce,   &
+               STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
+         ELSE
+            OPEN( UNIT=knum, FILE=cdfile, FORM=cdform, ACCESS=cdacce,   &
+               STATUS=cdstat, ERR=100, IOSTAT=iost)
+         ENDIF
+         IF( iost == 0 ) THEN
+            IF(ldwp) THEN
+               WRITE(kout,*) '     file   : ', cdfile,' open ok'
+               WRITE(kout,*) '     unit   = ', knum
+               WRITE(kout,*) '     status = ', cdstat
+               WRITE(kout,*) '     form   = ', cdform
+               WRITE(kout,*) '     access = ', cdacce
+               WRITE(kout,*)
+            ENDIF
+         ENDIF
+100      CONTINUE
+         IF( iost /= 0 ) THEN
+            IF(ldwp) THEN
+               WRITE(kout,*)
+               WRITE(kout,*) ' ===>>>> : bad opening file: ', cdfile
+               WRITE(kout,*) ' =======   ===  '
+               WRITE(kout,*) '           unit   = ', knum
+               WRITE(kout,*) '           status = ', cdstat
+               WRITE(kout,*) '           form   = ', cdform
+               WRITE(kout,*) '           access = ', cdacce
+               WRITE(kout,*) '           iostat = ', iost
+               WRITE(kout,*) '           we stop. verify the file '
+               WRITE(kout,*)
+            ENDIF
+            STOP 'ctlopn bad opening'
+         ENDIF
+         
+         
+         ! 2. Not required, file create if not exist
+         ! -----------------------------------------
+         
+      ELSEIF( krequ == 0 ) THEN
+
+         iost = 0
+         IF( cdacce(1:6) == 'DIRECT' ) THEN
+            OPEN( UNIT=knum, FILE=cdfile, FORM=cdform, ACCESS=cdacce,   &
+               STATUS=cdstat, RECL=klengh, ERR=200, IOSTAT=iost )
+         ELSE
+            OPEN( UNIT=knum, FILE=cdfile, FORM=cdform, ACCESS=cdacce,   &
+               STATUS=cdstat, ERR=200, IOSTAT=iost )
+         ENDIF
+         IF(iost == 0) THEN
+            IF(ldwp) THEN
+               WRITE(kout,*) '     file   : ', cdfile,' open ok'
+               WRITE(kout,*) '     unit   = ', knum
+               WRITE(kout,*) '     status = ', cdstat
+               WRITE(kout,*) '     form   = ', cdform
+               WRITE(kout,*) '     access = ', cdacce
+               WRITE(kout,*)
+            ENDIF
+         ENDIF
+200      CONTINUE
+         IF( iost /= 0 ) THEN
+            iost = 0
+            IF(ldwp) THEN
+               WRITE(kout,*)
+               WRITE(kout,*) '     ===>>>> : file ', cdfile,   &
+                  ' does not exist: it is created'
+               WRITE(kout,*) ' =======   ===  '
+            ENDIF
+            IF( cdacce(1:6) == 'DIRECT' ) THEN
+               OPEN( UNIT=knum, FILE=cdfile, FORM=cdform,   &
+                  ACCESS=cdacce, STATUS=cdstat,   &
+                  RECL=klengh, ERR=210, IOSTAT=iost )
+            ELSE
+               OPEN( UNIT=knum, FILE=cdfile, FORM=cdform,   &
+                  ACCESS=cdacce, STATUS=cdstat, ERR=210,   &
+                  IOSTAT=iost )
+            ENDIF
+            IF(ldwp) THEN
+               WRITE(kout,*) '     file   : ', cdfile,' open ok'
+               WRITE(kout,*) '     unit   = ', knum
+               WRITE(kout,*) '     status = ', cdstat
+               WRITE(kout,*) '     form   = ', cdform
+               WRITE(kout,*) '     access = ', cdacce
+               WRITE(kout,*)
+            ENDIF
+210         CONTINUE
+            IF( iost /= 0 ) THEN
+               IF(ldwp) THEN
+                  WRITE(kout,*) ' logical unit ',knum,' iostat = ', iost
+                  WRITE(kout,*) ' we stop. verify the file ', cdfile
+                  WRITE(kout,*)
+               ENDIF
+               STOP '001'
+            ENDIF
+         ENDIF
+         
+      ELSE
+         
+         IF(ldwp) THEN
+            WRITE(kout,*)
+            WRITE(kout,*) ' ctlopn : invalid option, krequ = ', krequ
+            WRITE(kout,*) ' ~~~~~~   call for file ', cdfile
+            WRITE(kout,*)
+         ENDIF
+
+
+         STOP 'ctlopn invalid option'
+      ENDIF
+      
+   END SUBROUTINE ctlopn
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/dtadyn.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/dtadyn.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/dtadyn.F90	(revision 1844)
@@ -0,0 +1,1070 @@
+MODULE dtadyn
+   !!======================================================================
+   !!                       ***  MODULE  dtadyn  ***
+   !! OFFLINE : interpolation of the physical fields
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dta_dyn_init : initialization, namelist read, and parameters control
+   !!   dta_dyn      : Interpolation of the fields
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE sbc_oce
+   USE ldfslp
+   USE ldfeiv          ! eddy induced velocity coef.      (ldf_eiv routine)
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE zdfmxl
+   USE trabbl
+   USE eosbn2
+   USE zdfddm          ! vertical  physics: double diffusion
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE zpshde
+   USE lib_mpp         ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC dta_dyn_init   ! called by opa.F90
+   PUBLIC dta_dyn        ! called by step.F90
+
+   LOGICAL , PUBLIC :: &
+      lperdyn = .TRUE. , & ! boolean for periodic fields or not
+      lfirdyn = .TRUE.     ! boolean for the first call or not
+
+   INTEGER , PUBLIC :: &
+      ndtadyn = 73 ,  & ! Number of dat in one year
+      ndtatot = 73 ,  & ! Number of data in the input field
+      nsptint = 1 ,   & ! type of spatial interpolation
+      nficdyn = 2       ! number of dynamical fields 
+
+   CHARACTER(len=45)  ::  &
+      cfile_grid_T = 'dyna_grid_T.nc', &   !: name of the grid_T file
+      cfile_grid_U = 'dyna_grid_U.nc', &   !: name of the grid_U file
+      cfile_grid_V = 'dyna_grid_V.nc', &   !: name of the grid_V file
+      cfile_grid_W = 'dyna_grid_W.nc'      !: name of the grid_W file
+   
+   REAL(wp)      ::   &
+      rnspdta  ,       &  !: number of time step per 2 consecutives data
+      rnspdta2            !: rnspdta * 0.5
+
+   INTEGER ::     &
+      ndyn1, ndyn2 , &
+      nlecoff = 0  , & ! switch for the first read
+      numfl_t, numfl_u, &
+      numfl_v, numfl_w
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      tdta   ,   & ! temperature at two consecutive times
+      sdta   ,   & ! salinity at two consecutive times
+      udta   ,   & ! zonal velocity at two consecutive times
+      vdta   ,   & ! meridional velocity at two consecutive times
+      wdta   ,   & ! vertical velocity at two consecutive times
+#if defined key_trc_diatrd
+      hdivdta,   & ! horizontal divergence
+#endif
+      avtdta       ! vertical diffusivity coefficient
+
+   REAL(wp), DIMENSION(jpi,jpj,2) ::       &
+      hmlddta,   & ! mixed layer depth at two consecutive times
+      wspddta,   & ! wind speed at two consecutive times
+      frlddta,   & ! sea-ice fraction at two consecutive times
+      empdta ,   & ! E-P at two consecutive times
+      qsrdta       ! short wave heat flux at two consecutive times
+
+#if defined key_ldfslp
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      uslpdta ,  & ! zonal isopycnal slopes
+      vslpdta ,  & ! meridional isopycnal slopes
+      wslpidta , & ! zonal diapycnal slopes
+      wslpjdta     ! meridional diapycnal slopes
+#endif
+
+#if ! defined key_off_degrad &&  defined key_traldf_c2d
+   REAL(wp), DIMENSION(jpi,jpj,2) ::   &
+      ahtwdta      ! Lateral diffusivity
+# if defined key_trcldf_eiv 
+   REAL(wp), DIMENSION(jpi,jpj,2) ::   &
+      aeiwdta      ! G&M coefficient
+# endif
+#endif
+
+#if defined key_off_degrad
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      ahtudta, ahtvdta, ahtwdta  !  Lateral diffusivity
+# if defined key_trcldf_eiv
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      aeiudta, aeivdta, aeiwdta  ! G&M coefficient
+# endif
+
+#endif
+
+#if defined key_trcbbl_dif   ||   defined key_trcbbl_adv
+   REAL(wp), DIMENSION(jpi,jpj,2) ::       &
+      bblxdta ,  & ! frequency of bbl in the x direction at 2 consecutive times
+      bblydta      ! frequency of bbl in the y direction at 2 consecutive times
+#endif
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dta_dyn( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn  ***
+      !!
+      !! ** Purpose : Prepares dynamics and physics fields from an 
+      !!              OPA9 simulation  for an off-line simulation
+      !!               for passive tracer
+      !!
+      !! ** Method : calculates the position of DATA to read READ DATA 
+      !!             (example month changement) computes slopes IF needed
+      !!             interpolates DATA IF needed
+      !!
+      !! ** History :
+      !!   ! original  : 92-01 (M. Imbard: sub domain)
+      !!   ! addition  : 98-04 (L.Bopp MA Foujols: slopes for isopyc.) 
+      !!   ! addition  : 98-05 (L. Bopp read output of coupled run)
+      !!   ! addition  : 05-03 (O. Aumont and A. El Moussaoui) F90
+      !!   ! addition  : 05-12 (C. Ethe) Adapted for DEGINT
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   iper, iperm1, iswap, izt   
+
+      REAL(wp) :: zpdtan, zpdtpe, zdemi, zt
+      REAL(wp) :: zweigh
+
+      ! 0. Initialization
+      ! -----------------
+
+      IF( lfirdyn ) THEN
+         ! first time step MUST BE nit000
+         IF( kt /= nit000 ) THEN
+            IF (lwp) THEN 
+               WRITE (numout,*) ' kt MUST BE EQUAL to nit000. kt = ',kt ,' nit000 = ',nit000 
+              STOP 'dtadyn'
+            ENDIF
+          ENDIF 
+          ! Initialize the parameters of the interpolation
+          CALL dta_dyn_init
+      ENDIF
+
+      zt       = ( FLOAT (kt) + rnspdta2 ) / rnspdta
+      izt      = INT( zt )
+      zweigh   = zt - FLOAT( INT(zt) )
+
+      IF( lperdyn ) THEN
+         iperm1 = MOD( izt, ndtadyn )
+      ELSE
+         iperm1 = MOD( izt, ndtatot - 1 ) + 1
+      ENDIF
+
+      iper = iperm1 + 1
+      IF( iperm1 == 0 ) THEN
+          IF( lperdyn ) THEN
+              iperm1 = ndtadyn
+          ELSE 
+              IF( lfirdyn ) THEN 
+                  IF (lwp) WRITE (numout,*) & 
+                      &   ' dynamic file is not periodic with or without interpolation  &
+                      &   we take the first value for the previous period iperm1 = 0  '
+              END IF
+          END IF 
+      END IF 
+
+      iswap  = 0
+
+      ! 1. First call lfirdyn = true
+      ! ----------------------------
+
+      IF( lfirdyn ) THEN
+         ! store the information of the period read
+         ndyn1 = iperm1
+         ndyn2 = iper
+         
+         IF (lwp) THEN
+            WRITE (numout,*) ' dynamics data read for the period ndyn1 =',ndyn1, &
+               &             ' and for the period ndyn2 = ',ndyn2
+            WRITE (numout,*) ' time step is : ', kt
+            WRITE (numout,*) ' we have ndtadyn = ',ndtadyn,' records in the dynamic file for one year'
+         END IF
+         !
+         IF( iperm1 /= 0 ) THEN         ! data read for the iperm1 period
+            CALL dynrea( kt, iperm1 ) 
+         ELSE 
+            CALL dynrea( kt, 1 )
+         ENDIF
+         
+#if defined key_ldfslp
+         ! Computes slopes
+         ! Caution : here tn, sn and avt are used as workspace
+         tn (:,:,:) = tdta  (:,:,:,2)
+         sn (:,:,:) = sdta  (:,:,:,2)
+         avt(:,:,:) = avtdta(:,:,:,2)
+         
+         CALL eos( tn, sn, rhd, rhop )   ! Time-filtered in situ density 
+         CALL bn2( tn, sn, rn2 )         ! before Brunt-Vaisala frequency
+         IF( ln_zps )   &
+            &   CALL zps_hde( kt, tn , sn , rhd,  &  ! Partial steps: before Horizontal DErivative
+            &                 gtu, gsu, gru,  &  ! of t, s, rd at the bottom ocean level
+            &                 gtv, gsv, grv )
+         CALL zdf_mxl( kt )              ! mixed layer depth
+         CALL ldf_slp( kt, rhd, rn2 )
+         
+         uslpdta (:,:,:,2) = uslp (:,:,:)
+         vslpdta (:,:,:,2) = vslp (:,:,:)
+         wslpidta(:,:,:,2) = wslpi(:,:,:)
+         wslpjdta(:,:,:,2) = wslpj(:,:,:)
+#endif
+         
+         ! swap from record 2 to 1
+         CALL swap_dyn_data
+         
+         iswap = 1        !  indicates swap
+         
+         CALL dynrea( kt, iper )    ! data read for the iper period
+         
+#if defined key_ldfslp
+         ! Computes slopes
+         ! Caution : here tn, sn and avt are used as workspace
+         tn (:,:,:) = tdta  (:,:,:,2)
+         sn (:,:,:) = sdta  (:,:,:,2)
+         avt(:,:,:) = avtdta(:,:,:,2)
+         
+         CALL eos( tn, sn, rhd, rhop )   ! Time-filtered in situ density 
+         CALL bn2( tn, sn, rn2 )         ! before Brunt-Vaisala frequency
+         IF( ln_zps )   &
+            &   CALL zps_hde( kt, tn , sn , rhd,  &  ! Partial steps: before Horizontal DErivative
+            &                 gtu, gsu, gru,  &  ! of t, s, rd at the bottom ocean level
+            &                 gtv, gsv, grv )
+         CALL zdf_mxl( kt )              ! mixed layer depth
+         CALL ldf_slp( kt, rhd, rn2 )
+         
+         uslpdta (:,:,:,2) = uslp (:,:,:)
+         vslpdta (:,:,:,2) = vslp (:,:,:)
+         wslpidta(:,:,:,2) = wslpi(:,:,:)
+         wslpjdta(:,:,:,2) = wslpj(:,:,:)
+#endif
+         !
+         lfirdyn=.FALSE.    ! trace the first call
+      ENDIF
+      !
+      ! And now what we have to do at every time step
+      ! check the validity of the period in memory
+      !
+      IF( iperm1 /= ndyn1 ) THEN 
+
+         IF( iperm1 == 0. ) THEN
+            IF (lwp) THEN
+               WRITE (numout,*) ' dynamic file is not periodic with periodic interpolation'
+               WRITE (numout,*) ' we take the last value for the last period '
+               WRITE (numout,*) ' iperm1 = 12,   iper = 13  '
+            ENDIF
+            iperm1 = 12
+            iper   = 13
+         ENDIF
+         !
+         ! We have to prepare a new read of data : swap from record 2 to 1
+         !
+         CALL swap_dyn_data
+
+         iswap = 1        !  indicates swap
+         
+         CALL dynrea( kt, iper )    ! data read for the iper period
+
+#if defined key_ldfslp
+         ! Computes slopes
+         ! Caution : here tn, sn and avt are used as workspace
+         tn (:,:,:) = tdta  (:,:,:,2)
+         sn (:,:,:) = sdta  (:,:,:,2)
+         avt(:,:,:) = avtdta(:,:,:,2)
+         
+         CALL eos( tn, sn, rhd, rhop )   ! Time-filtered in situ density 
+         CALL bn2( tn, sn, rn2 )         ! before Brunt-Vaisala frequency
+         IF( ln_zps )   &
+            &   CALL zps_hde( kt, tn , sn , rhd,  &  ! Partial steps: before Horizontal DErivative
+            &                 gtu, gsu, gru,  &  ! of t, s, rd at the bottom ocean level
+            &                 gtv, gsv, grv )
+         CALL zdf_mxl( kt )              ! mixed layer depth
+         CALL ldf_slp( kt, rhd, rn2 )
+         
+         uslpdta (:,:,:,2) = uslp (:,:,:)
+         vslpdta (:,:,:,2) = vslp (:,:,:)
+         wslpidta(:,:,:,2) = wslpi(:,:,:)
+         wslpjdta(:,:,:,2) = wslpj(:,:,:)
+#endif
+       
+         ! store the information of the period read
+         ndyn1 = ndyn2
+         ndyn2 = iper
+
+         IF (lwp) THEN
+            WRITE (numout,*) ' dynamics data read for the period ndyn1 =',ndyn1, &
+               &             ' and for the period ndyn2 = ',ndyn2
+            WRITE (numout,*) ' time step is : ', kt
+         END IF
+         !
+      END IF
+      !
+      ! Compute the data at the given time step
+      !----------------------------------------     
+
+      IF( nsptint == 0 ) THEN   
+         ! No spatial interpolation, data are probably correct
+         ! We have to initialize data if we have changed the period         
+         CALL assign_dyn_data          
+      ELSE IF( nsptint == 1 ) THEN
+         ! linear interpolation
+         CALL linear_interp_dyn_data( zweigh )
+      ELSE 
+         ! other interpolation
+         WRITE (numout,*) ' this kind of interpolation do not exist at the moment : we stop'
+         STOP 'dtadyn'         
+      END IF
+      
+      ! In any case, we need rhop
+      CALL eos( tn, sn, rhd, rhop ) 
+      
+#if ! defined key_off_degrad && defined key_traldf_c2d
+      ! In case of 2D varying coefficients, we need aeiv and aeiu
+      IF( lk_traldf_eiv )   CALL ldf_eiv( kt )      ! eddy induced velocity coefficient
+#endif
+   
+   END SUBROUTINE dta_dyn
+
+   SUBROUTINE dynrea( kt, kenr )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dynrea  ***
+      !!
+      !! ** Purpose : READ dynamics fiels from OPA9 netcdf output
+      !! 
+      !! ** Method : READ the kenr records of DATA and store in
+      !!             in udta(...,2), ....  
+      !! 
+      !! ** History : additions : M. Levy et M. Benjelloul jan 2001 
+      !!              (netcdf FORMAT) 
+      !!              05-03 (O. Aumont and A. El Moussaoui) F90
+      !!              06-07 : (C. Ethe) use of iom module
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt, kenr       ! time index
+      !! * Local declarations
+      INTEGER ::  jkenr
+
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+        zu, zv, zw, zt, zs, zavt ,   &     ! 3-D dynamical fields
+        zhdiv                              ! horizontal divergence
+
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zemp, zqsr, zmld, zice, zwspd, &
+         ztaux, ztauy
+#if defined key_trcbbl_dif   ||   defined key_trcbbl_adv
+      REAL(wp), DIMENSION(jpi,jpj) :: zbblx, zbbly
+#endif
+
+#if ! defined key_off_degrad && defined key_traldf_c2d
+      REAL(wp), DIMENSION(jpi,jpj) :: zahtw 
+#   if defined key_trcldf_eiv
+      REAL(wp), DIMENSION(jpi,jpj) :: zaeiw 
+#  endif
+#endif
+
+#if defined key_off_degrad
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      zahtu, zahtv, zahtw  !  Lateral diffusivity
+# if defined key_trcldf_eiv
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      zaeiu, zaeiv, zaeiw  ! G&M coefficient
+# endif
+#endif
+
+      !---------------------------------------------------------------
+      ! 0. Initialization
+      
+      ! cas d'un fichier non periodique : on utilise deux fois le premier et
+      ! le dernier champ temporel
+
+      jkenr = kenr
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'Dynrea : reading dynamical fields, kenr = ', jkenr
+         WRITE(numout,*) ' ~~~~~~~'
+#if defined key_off_degrad
+         WRITE(numout,*) ' Degraded fields'
+#endif
+         WRITE(numout,*)
+      ENDIF
+
+
+      IF( kt == nit000 .AND. nlecoff == 0 ) THEN
+         nlecoff = 1
+         CALL  iom_open ( cfile_grid_T, numfl_t )
+         CALL  iom_open ( cfile_grid_U, numfl_u )
+         CALL  iom_open ( cfile_grid_V, numfl_v )
+         CALL  iom_open ( cfile_grid_W, numfl_w )
+      ENDIF
+
+      ! file grid-T
+      !---------------
+      CALL iom_get( numfl_t, jpdom_data, 'votemper', zt   (:,:,:), jkenr )
+      CALL iom_get( numfl_t, jpdom_data, 'vosaline', zs   (:,:,:), jkenr )
+      CALL iom_get( numfl_t, jpdom_data, 'somixhgt', zmld (:,:  ), jkenr )
+      CALL iom_get( numfl_t, jpdom_data, 'sowaflcd', zemp (:,:  ), jkenr )
+      CALL iom_get( numfl_t, jpdom_data, 'soshfldo', zqsr (:,:  ), jkenr )
+      CALL iom_get( numfl_t, jpdom_data, 'soicecov', zice (:,:  ), jkenr )
+      IF( iom_varid( numfl_t, 'sowindsp', ldstop = .FALSE. ) > 0 ) THEN 
+         CALL iom_get( numfl_t, jpdom_data, 'sowindsp', zwspd(:,:), jkenr ) 
+      ELSE
+         CALL iom_get( numfl_u, jpdom_data, 'sozotaux', ztaux(:,:), jkenr )
+         CALL iom_get( numfl_v, jpdom_data, 'sometauy', ztauy(:,:), jkenr )
+         CALL tau2wnd( ztaux, ztauy, zwspd )
+      ENDIF
+      ! files grid-U / grid_V
+      CALL iom_get( numfl_u, jpdom_data, 'vozocrtx', zu   (:,:,:), jkenr )
+      CALL iom_get( numfl_v, jpdom_data, 'vomecrty', zv   (:,:,:), jkenr )
+
+#if defined key_trcbbl_dif || defined key_trcbbl_adv
+      IF( iom_varid( numfl_u, 'sobblcox', ldstop = .FALSE. ) > 0  .AND. &
+      &   iom_varid( numfl_v, 'sobblcoy', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numfl_u, jpdom_data, 'sobblcox', zbblx(:,:), jkenr )
+         CALL iom_get( numfl_v, jpdom_data, 'sobblcoy', zbbly(:,:), jkenr )
+      ELSE
+         CALL bbl_sign( zt, zs, zbblx, zbbly )    
+      ENDIF
+#endif
+
+      ! file grid-W
+!!      CALL iom_get ( numfl_w, jpdom_data, 'vovecrtz', zw   (:,:,:), jkenr )
+      ! Computation of vertical velocity using horizontal divergence
+      CALL wzv( zu, zv, zw, zhdiv )
+
+# if defined key_zdfddm
+      CALL iom_get( numfl_w, jpdom_data, 'voddmavs', zavt (:,:,:), jkenr )
+#else
+      CALL iom_get( numfl_w, jpdom_data, 'votkeavt', zavt (:,:,:), jkenr )
+#endif 
+
+#if ! defined key_off_degrad && defined key_traldf_c2d
+      CALL iom_get( numfl_w, jpdom_data, 'soleahtw', zahtw (:,: ), jkenr )
+#  if   defined key_trcldf_eiv 
+      CALL iom_get( numfl_w, jpdom_data, 'soleaeiw', zaeiw (:,: ), jkenr )
+#  endif
+#endif
+
+#if defined key_off_degrad
+      CALL iom_get( numfl_u, jpdom_data, 'vozoahtu', zahtu(:,:,:), jkenr )
+      CALL iom_get( numfl_v, jpdom_data, 'vomeahtv', zahtv(:,:,:), jkenr )
+      CALL iom_get( numfl_w, jpdom_data, 'voveahtw', zahtw(:,:,:), jkenr )
+#  if defined key_trcldf_eiv
+      CALL iom_get( numfl_u, jpdom_data, 'vozoaeiu', zaeiu(:,:,:), jkenr )
+      CALL iom_get( numfl_v, jpdom_data, 'vomeaeiv', zaeiv(:,:,:), jkenr )
+      CALL iom_get( numfl_w, jpdom_data, 'voveaeiw', zaeiw(:,:,:), jkenr )
+#  endif
+#endif
+
+      udta(:,:,:,2) = zu(:,:,:) * umask(:,:,:)
+      vdta(:,:,:,2) = zv(:,:,:) * vmask(:,:,:) 
+      wdta(:,:,:,2) = zw(:,:,:) * tmask(:,:,:)
+
+#if defined key_trc_diatrd
+      hdivdta(:,:,:,2) = zhdiv(:,:,:) * tmask(:,:,:)
+#endif
+
+      tdta(:,:,:,2)   = zt  (:,:,:) * tmask(:,:,:)
+      sdta(:,:,:,2)   = zs  (:,:,:) * tmask(:,:,:)
+      avtdta(:,:,:,2) = zavt(:,:,:) * tmask(:,:,:)
+
+#if ! defined key_off_degrad && defined key_traldf_c2d
+      ahtwdta(:,:,2)  = zahtw(:,:) * tmask(:,:,1)
+#if defined key_trcldf_eiv
+      aeiwdta(:,:,2)  = zaeiw(:,:) * tmask(:,:,1)
+#endif
+#endif
+
+#if defined key_off_degrad
+        ahtudta(:,:,:,2) = zahtu(:,:,:) * umask(:,:,:)
+        ahtvdta(:,:,:,2) = zahtv(:,:,:) * vmask(:,:,:)
+        ahtwdta(:,:,:,2) = zahtw(:,:,:) * tmask(:,:,:)
+#  if defined key_trcldf_eiv
+        aeiudta(:,:,:,2) = zaeiu(:,:,:) * umask(:,:,:)
+        aeivdta(:,:,:,2) = zaeiv(:,:,:) * vmask(:,:,:)
+        aeiwdta(:,:,:,2) = zaeiw(:,:,:) * tmask(:,:,:)
+#  endif
+#endif
+
+      ! fluxes 
+      !
+      wspddta(:,:,2)  = zwspd(:,:) * tmask(:,:,1)
+      frlddta(:,:,2)  = MIN( 1., zice(:,:) ) * tmask(:,:,1)
+      empdta (:,:,2)  = zemp(:,:) * tmask(:,:,1)
+      qsrdta (:,:,2)  = zqsr(:,:) * tmask(:,:,1)
+      hmlddta(:,:,2)  = zmld(:,:) * tmask(:,:,1)
+      
+#if defined key_trcbbl_dif   ||   defined key_trcbbl_adv
+      bblxdta(:,:,2) = MAX( 0., zbblx(:,:) )
+      bblydta(:,:,2) = MAX( 0., zbbly(:,:) )
+
+      WHERE( bblxdta(:,:,2) > 2. ) bblxdta(:,:,2) = 0.
+      WHERE( bblydta(:,:,2) > 2. ) bblydta(:,:,2) = 0.
+#endif
+
+      IF( kt == nitend ) THEN
+         CALL iom_close ( numfl_t )
+         CALL iom_close ( numfl_u )
+         CALL iom_close ( numfl_v )
+         CALL iom_close ( numfl_w )
+      ENDIF
+      
+   END SUBROUTINE dynrea
+
+   SUBROUTINE dta_dyn_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn_init  ***
+      !!
+      !! ** Purpose :   initializations of parameters for the interpolation
+      !!
+      !! ** Method :
+      !!
+      !! History :
+      !!    ! original  : 92-01 (M. Imbard: sub domain)
+      !!    ! 98-04 (L.Bopp MA Foujols: slopes for isopyc.)
+      !!    ! 98-05 (L. Bopp read output of coupled run)
+      !!    ! 05-03 (O. Aumont and A. El Moussaoui) F90
+      !!----------------------------------------------------------------------
+      !! * Modules used
+
+      !! * Local declarations
+
+      REAL(wp) ::   znspyr   !: number of time step per year
+
+      NAMELIST/namdyn/ ndtadyn, ndtatot, nsptint, nficdyn, lperdyn,  &
+      &                cfile_grid_T, cfile_grid_U, cfile_grid_V, cfile_grid_W
+      !!----------------------------------------------------------------------
+
+      !  Define the dynamical input parameters
+      ! ======================================
+
+      ! Read Namelist namdyn : Lateral physics on tracers
+      REWIND( numnam )
+      READ  ( numnam, namdyn )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'namdyn : offline dynamical selection'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '  Namelist namdyn : set parameters for the lecture of the dynamical fields'
+         WRITE(numout,*) 
+         WRITE(numout,*) ' number of elements in the FILE for a year  ndtadyn = ' , ndtadyn
+         WRITE(numout,*) ' total number of elements in the FILE       ndtatot = ' , ndtatot
+         WRITE(numout,*) ' type of interpolation                      nsptint = ' , nsptint
+         WRITE(numout,*) ' number of dynamics FILE                    nficdyn = ' , nficdyn
+         WRITE(numout,*) ' loop on the same FILE                      lperdyn = ' , lperdyn
+         WRITE(numout,*) '  '
+         WRITE(numout,*) ' name of grid_T file                   cfile_grid_T = ', TRIM(cfile_grid_T)    
+         WRITE(numout,*) ' name of grid_U file                   cfile_grid_U = ', TRIM(cfile_grid_U) 
+         WRITE(numout,*) ' name of grid_V file                   cfile_grid_V = ', TRIM(cfile_grid_V) 
+         WRITE(numout,*) ' name of grid_W file                   cfile_grid_W = ', TRIM(cfile_grid_W)      
+         WRITE(numout,*) ' '
+      ENDIF
+
+      znspyr   = nyear_len(1) * rday / rdt  
+      rnspdta  = znspyr / FLOAT( ndtadyn )
+      rnspdta2 = rnspdta * 0.5 
+
+   END SUBROUTINE dta_dyn_init
+
+   SUBROUTINE wzv( pu, pv, pw, phdiv )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE wzv  ***
+      !!
+      !! ** Purpose :   Compute the now vertical velocity after the array swap
+      !!
+      !! ** Method  :
+      !! ** Method  : - Divergence:
+      !!      - compute the now divergence given by :
+      !!         * z-coordinate
+      !!         hdiv = 1/(e1t*e2t) [ di(e2u  u) + dj(e1v  v) ]
+      !!     - Using the incompressibility hypothesis, the vertical
+      !!      velocity is computed by integrating the horizontal divergence
+      !!      from the bottom to the surface.
+      !!        The boundary conditions are w=0 at the bottom (no flux) and,
+      !!      in regid-lid case, w=0 at the sea surface.
+      !!
+      !!
+      !! History :
+      !!   9.0  !  02-07  (G. Madec)  Vector optimization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in  )   :: pu, pv    !:  horizontal velocities
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out )   :: pw        !:  verticla velocity
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) :: phdiv     !:  horizontal divergence
+
+      !! * Local declarations
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zu, zu1, zv, zv1, zet
+
+
+      ! Computation of vertical velocity using horizontal divergence
+      phdiv(:,:,:) = 0.
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zu  = pu(ji  ,jj  ,jk) * umask(ji  ,jj  ,jk) * e2u(ji  ,jj  )
+               zu1 = pu(ji-1,jj  ,jk) * umask(ji-1,jj  ,jk) * e2u(ji-1,jj  )
+               zv  = pv(ji  ,jj  ,jk) * vmask(ji  ,jj  ,jk) * e1v(ji  ,jj  )
+               zv1 = pv(ji  ,jj-1,jk) * vmask(ji  ,jj-1,jk) * e1v(ji  ,jj-1)
+               zet = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+#else
+               zu  = pu(ji  ,jj  ,jk) * umask(ji  ,jj  ,jk) * e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk)
+               zu1 = pu(ji-1,jj  ,jk) * umask(ji-1,jj  ,jk) * e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk)
+               zv  = pv(ji  ,jj  ,jk) * vmask(ji  ,jj  ,jk) * e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk)
+               zv1 = pv(ji  ,jj-1,jk) * vmask(ji  ,jj-1,jk) * e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk)
+               zet = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+#endif
+               phdiv(ji,jj,jk) = ( zu - zu1 + zv - zv1 ) * zet 
+            END DO
+         END DO
+      ENDDO
+
+      ! Lateral boundary conditions on phdiv
+      CALL lbc_lnk( phdiv, 'T', 1. )
+
+
+      ! computation of vertical velocity from the bottom
+      pw(:,:,jpk) = 0.
+      DO jk = jpkm1, 1, -1
+         pw(:,:,jk) = pw(:,:,jk+1) - fse3t(:,:,jk) * phdiv(:,:,jk)
+      END DO
+
+   END SUBROUTINE wzv
+
+   SUBROUTINE tau2wnd( ptaux, ptauy, pwspd )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_tau2wnd  ***
+      !!
+      !! ** Purpose : Estimation of wind speed as a function of wind stress
+      !!
+      !! ** Method  : |tau|=rhoa*Cd*|U|^2
+      !!---------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( in  ) ::  &
+         ptaux, ptauy                              !: wind stress in i-j direction resp.
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( out ) ::  &
+         pwspd                                     !: wind speed 
+      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
+      REAL(wp) ::   ztx, zty, ztau, zcoef ! temporary variables
+      INTEGER  ::   ji, jj                ! dummy indices
+      !!---------------------------------------------------------------------
+      zcoef = 1. / ( zrhoa * zcdrag )
+!CDIR NOVERRCHK
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ztx = ptaux(ji,jj) * umask(ji,jj,1) + ptaux(ji-1,jj  ) * umask(ji-1,jj  ,1)
+            zty = ptauy(ji,jj) * vmask(ji,jj,1) + ptauy(ji  ,jj-1) * vmask(ji  ,jj-1,1)
+            ztau = 0.5 * SQRT( ztx * ztx + zty * zty )
+            pwspd(ji,jj) = SQRT ( ztau * zcoef ) * tmask(ji,jj,1)
+         END DO
+      END DO
+      CALL lbc_lnk( pwspd(:,:), 'T', 1. )
+
+   END SUBROUTINE tau2wnd
+
+#if defined key_trcbbl_dif   ||   defined key_trcbbl_adv
+
+   SUBROUTINE bbl_sign( ptn, psn, pbblx, pbbly )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE bbl_sign  ***
+      !!
+      !! ** Purpose :   Compute the sign of local gradient of density multiplied by the slope
+      !!                along the bottom slope gradient : grad( rho) * grad(h)
+      !!                Need to compute the diffusive bottom boundary layer
+      !!
+      !! ** Method  :   When the product grad( rho) * grad(h) < 0 (where grad
+      !!      is an along bottom slope gradient) an additional lateral diffu-
+      !!      sive trend along the bottom slope is added to the general tracer
+      !!      trend, otherwise nothing is done. See trcbbl.F90
+      !!
+      !!
+      !! History :
+      !!   9.0  !  02-07  (G. Madec)  Vector optimization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in  ) ::  &
+         ptn             ,  &                           !: temperature 
+         psn                                            !: salinity 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( out ) ::  &
+         pbblx , pbbly                                  !: sign of bbl in i-j direction resp. 
+      
+      !! * Local declarations
+      INTEGER  ::   ji, jj                   ! dummy loop indices
+      INTEGER  ::   ik
+      REAL(wp) ::   &
+         ztx, zsx, zhx, zalbetx, zgdrhox,     &  ! temporary scalars
+         zty, zsy, zhy, zalbety, zgdrhoy 
+      REAL(wp), DIMENSION(jpi,jpj) ::    &
+        ztnb, zsnb, zdep
+      REAL(wp) ::    fsalbt, pft, pfs, pfh   ! statement function
+      !!----------------------------------------------------------------------
+      ! ratio alpha/beta
+      ! ================
+      !  fsalbt: ratio of thermal over saline expension coefficients
+      !       pft :  potential temperature in degrees celcius
+      !       pfs :  salinity anomaly (s-35) in psu
+      !       pfh :  depth in meters
+
+      fsalbt( pft, pfs, pfh ) =                                              &
+         ( ( ( -0.255019e-07 * pft + 0.298357e-05 ) * pft                    &
+                                   - 0.203814e-03 ) * pft                    &
+                                   + 0.170907e-01 ) * pft                    &
+                                   + 0.665157e-01                            &
+         +(-0.678662e-05 * pfs - 0.846960e-04 * pft + 0.378110e-02 ) * pfs   &
+         +  ( ( - 0.302285e-13 * pfh                                         &
+                - 0.251520e-11 * pfs                                         &
+                + 0.512857e-12 * pft * pft          ) * pfh                  &
+                                     - 0.164759e-06   * pfs                  &
+             +(   0.791325e-08 * pft - 0.933746e-06 ) * pft                  &
+                                     + 0.380374e-04 ) * pfh
+
+      ! 0. 2D fields of bottom temperature and salinity, and bottom slope
+      ! -----------------------------------------------------------------
+      ! mbathy= number of w-level, minimum value=1 (cf domrea.F90)
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#  endif
+            ik          =  MAX( mbathy(ji,jj) - 1, 1 )    ! vertical index of the bottom ocean T-level
+            ztnb(ji,jj) = ptn(ji,jj,ik) * tmask(ji,jj,1)  ! masked T and S at ocean bottom
+            zsnb(ji,jj) = psn(ji,jj,ik) * tmask(ji,jj,1)
+            zdep(ji,jj) = fsdept(ji,jj,ik)                ! depth of the ocean bottom T-level
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      !!----------------------------------------------------------------------
+      ! 1. Criteria of additional bottom diffusivity: grad(rho).grad(h)<0
+      ! --------------------------------------------
+      ! Sign of the local density gradient along the i- and j-slopes
+      ! multiplied by the slope of the ocean bottom
+
+      SELECT CASE ( neos )
+
+      CASE ( 0 )                 ! Jackett and McDougall (1994) formulation
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! temperature, salinity anomalie and depth
+            ztx = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+            zsx = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+            zhx = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+            !
+            zty = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+            zsy = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+            zhy = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+            ! masked ratio alpha/beta
+            zalbetx = fsalbt( ztx, zsx, zhx ) * umask(ji,jj,1)
+            zalbety = fsalbt( zty, zsy, zhy ) * vmask(ji,jj,1)
+            ! local density gradient along i-bathymetric slope
+            zgdrhox = zalbetx * ( ztnb(ji+1,jj) - ztnb(ji,jj) )   &
+                   -            ( zsnb(ji+1,jj) - zsnb(ji,jj) )
+            ! local density gradient along j-bathymetric slope
+            zgdrhoy = zalbety * ( ztnb(ji,jj+1) - ztnb(ji,jj) )   &
+                   -            ( zsnb(ji,jj+1) - zsnb(ji,jj) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            pbblx(ji,jj) = 0.5 - SIGN( 0.5, -zgdrhox * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            pbbly(ji,jj) = 0.5 - SIGN( 0.5, -zgdrhoy * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      CASE ( 1 )               ! Linear formulation function of temperature only
+                               !
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! local 'density/temperature' gradient along i-bathymetric slope
+            zgdrhox =  ztnb(ji+1,jj) - ztnb(ji,jj)
+            ! local density gradient along j-bathymetric slope
+            zgdrhoy =  ztnb(ji,jj+1) - ztnb(ji,jj)
+            ! sign of local i-gradient of density multiplied by the i-slope
+            pbblx(ji,jj) = 0.5 - SIGN( 0.5, -zgdrhox * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            pbbly(ji,jj) = 0.5 - SIGN( 0.5, -zgdrhoy * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif     
+            ! local density gradient along i-bathymetric slope
+            zgdrhox = - ( rbeta*( zsnb(ji+1,jj) - zsnb(ji,jj) )   &
+                      -  ralpha*( ztnb(ji+1,jj) - ztnb(ji,jj) ) )
+            ! local density gradient along j-bathymetric slope
+            zgdrhoy = - ( rbeta*( zsnb(ji,jj+1) - zsnb(ji,jj) )   &
+                      -  ralpha*( ztnb(ji,jj+1) - ztnb(ji,jj) ) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            pbblx(ji,jj) = 0.5 - SIGN( 0.5, - zgdrhox * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            pbbly(ji,jj) = 0.5 - SIGN( 0.5, -zgdrhoy * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      CASE DEFAULT
+
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop(ctmp1)
+
+      END SELECT
+   
+      ! Lateral boundary conditions
+      CALL lbc_lnk( pbblx, 'U', 1. )
+      CALL lbc_lnk( pbbly, 'V', 1. )
+
+   END SUBROUTINE bbl_sign
+
+#endif
+
+   SUBROUTINE swap_dyn_data
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE swap_dyn_data  ***
+      !!
+      !! ** Purpose :   swap array data
+      !!
+      !! History :
+      !!   9.0  !  07-09  (C. Ethe)
+      !!----------------------------------------------------------------------
+
+
+      ! swap from record 2 to 1
+      tdta   (:,:,:,1) = tdta   (:,:,:,2)
+      sdta   (:,:,:,1) = sdta   (:,:,:,2)
+      avtdta (:,:,:,1) = avtdta (:,:,:,2)
+      udta   (:,:,:,1) = udta   (:,:,:,2)
+      vdta   (:,:,:,1) = vdta   (:,:,:,2)
+      wdta   (:,:,:,1) = wdta   (:,:,:,2)
+#if defined key_trc_diatrd
+      hdivdta(:,:,:,1) = hdivdta(:,:,:,2)
+#endif
+
+#if defined key_ldfslp
+      uslpdta (:,:,:,1) = uslpdta (:,:,:,2)
+      vslpdta (:,:,:,1) = vslpdta (:,:,:,2)
+      wslpidta(:,:,:,1) = wslpidta(:,:,:,2)
+      wslpjdta(:,:,:,1) = wslpjdta(:,:,:,2)
+#endif
+      hmlddta(:,:,1) = hmlddta(:,:,2) 
+      wspddta(:,:,1) = wspddta(:,:,2) 
+      frlddta(:,:,1) = frlddta(:,:,2) 
+      empdta (:,:,1) = empdta (:,:,2) 
+      qsrdta (:,:,1) = qsrdta (:,:,2) 
+
+#if ! defined key_off_degrad && defined key_traldf_c2d
+      ahtwdta(:,:,1) = ahtwdta(:,:,2)
+#  if defined key_trcldf_eiv
+      aeiwdta(:,:,1) = aeiwdta(:,:,2)
+#  endif
+#endif
+
+#if defined key_off_degrad
+      ahtudta(:,:,:,1) = ahtudta(:,:,:,2)
+      ahtvdta(:,:,:,1) = ahtvdta(:,:,:,2)
+      ahtwdta(:,:,:,1) = ahtwdta(:,:,:,2)
+#  if defined key_trcldf_eiv
+      aeiudta(:,:,:,1) = aeiudta(:,:,:,2)
+      aeivdta(:,:,:,1) = aeivdta(:,:,:,2)
+      aeiwdta(:,:,:,1) = aeiwdta(:,:,:,2)
+#  endif
+#endif
+
+#if defined key_trcbbl_dif || defined key_trcbbl_adv
+      bblxdta(:,:,1) = bblxdta(:,:,2)
+      bblydta(:,:,1) = bblydta(:,:,2)
+#endif
+
+   END SUBROUTINE swap_dyn_data
+
+   SUBROUTINE assign_dyn_data
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE assign_dyn_data  ***
+      !!
+      !! ** Purpose :   Assign dynamical data to the data that have been read
+      !!                without time interpolation
+      !!
+      !!----------------------------------------------------------------------
+      
+      tn (:,:,:) = tdta  (:,:,:,2)
+      sn (:,:,:) = sdta  (:,:,:,2)
+      avt(:,:,:) = avtdta(:,:,:,2)
+      
+      un (:,:,:) = udta  (:,:,:,2) 
+      vn (:,:,:) = vdta  (:,:,:,2)
+      wn (:,:,:) = wdta  (:,:,:,2)
+
+#if defined key_trc_diatrd
+      hdivn(:,:,:) = hdivdta(:,:,:,2)
+#endif
+
+#if defined key_zdfddm
+      avs(:,:,:)   = avtdta (:,:,:,2)
+#endif
+
+      
+#if defined key_ldfslp
+      uslp (:,:,:) = uslpdta (:,:,:,2) 
+      vslp (:,:,:) = vslpdta (:,:,:,2) 
+      wslpi(:,:,:) = wslpidta(:,:,:,2) 
+      wslpj(:,:,:) = wslpjdta(:,:,:,2) 
+#endif
+
+      hmld(:,:) = hmlddta(:,:,2) 
+      wndm(:,:) = wspddta(:,:,2) 
+      fr_i(:,:) = frlddta(:,:,2) 
+      emp (:,:) = empdta (:,:,2) 
+      emps(:,:) = emp(:,:) 
+      qsr (:,:) = qsrdta (:,:,2) 
+
+#if ! defined key_off_degrad && defined key_traldf_c2d    
+      ahtw(:,:) = ahtwdta(:,:,2)
+#  if defined key_trcldf_eiv
+      aeiw(:,:) = aeiwdta(:,:,2)
+#  endif
+#endif
+      
+#if defined key_off_degrad
+      ahtu(:,:,:) = ahtudta(:,:,:,2)
+      ahtv(:,:,:) = ahtvdta(:,:,:,2)
+      ahtw(:,:,:) = ahtwdta(:,:,:,2)
+#  if defined key_trcldf_eiv
+      aeiu(:,:,:) = aeiudta(:,:,:,2)
+      aeiv(:,:,:) = aeivdta(:,:,:,2)
+      aeiw(:,:,:) = aeiwdta(:,:,:,2)
+#  endif
+      
+#endif
+      
+#if defined key_trcbbl_dif ||  defined key_trcbbl_adv
+      bblx(:,:) = bblxdta(:,:,2)
+      bbly(:,:) = bblydta(:,:,2)
+#endif
+
+   END SUBROUTINE assign_dyn_data
+
+   SUBROUTINE linear_interp_dyn_data( pweigh )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE linear_interp_dyn_data  ***
+      !!
+      !! ** Purpose :   linear interpolation of data
+      !!
+      !!----------------------------------------------------------------------
+      !! * Argument
+      REAL(wp), INTENT( in ) ::   pweigh       ! weigh
+
+      !! * Local declarations
+      REAL(wp) :: zweighm1
+      !!----------------------------------------------------------------------
+
+      zweighm1 = 1. - pweigh
+      
+      tn (:,:,:) = zweighm1 * tdta  (:,:,:,1) + pweigh * tdta  (:,:,:,2)
+      sn (:,:,:) = zweighm1 * sdta  (:,:,:,1) + pweigh * sdta  (:,:,:,2)
+      avt(:,:,:) = zweighm1 * avtdta(:,:,:,1) + pweigh * avtdta(:,:,:,2)
+      
+      un (:,:,:) = zweighm1 * udta  (:,:,:,1) + pweigh * udta  (:,:,:,2) 
+      vn (:,:,:) = zweighm1 * vdta  (:,:,:,1) + pweigh * vdta  (:,:,:,2)
+      wn (:,:,:) = zweighm1 * wdta  (:,:,:,1) + pweigh * wdta  (:,:,:,2)
+
+#if defined key_trc_diatrd
+      hdivn(:,:,:) = zweighm1 * hdivdta(:,:,:,1) + pweigh * hdivdta(:,:,:,2)
+#endif
+
+#if defined key_zdfddm
+      avs(:,:,:)   = zweighm1 * avtdta (:,:,:,1) + pweigh * avtdta (:,:,:,2)
+#endif
+
+      
+#if defined key_ldfslp
+      uslp (:,:,:) = zweighm1 * uslpdta (:,:,:,1) + pweigh * uslpdta (:,:,:,2) 
+      vslp (:,:,:) = zweighm1 * vslpdta (:,:,:,1) + pweigh * vslpdta (:,:,:,2) 
+      wslpi(:,:,:) = zweighm1 * wslpidta(:,:,:,1) + pweigh * wslpidta(:,:,:,2) 
+      wslpj(:,:,:) = zweighm1 * wslpjdta(:,:,:,1) + pweigh * wslpjdta(:,:,:,2) 
+#endif
+
+      hmld(:,:) = zweighm1 * hmlddta(:,:,1) + pweigh  * hmlddta(:,:,2) 
+      wndm(:,:) = zweighm1 * wspddta(:,:,1) + pweigh  * wspddta(:,:,2) 
+      fr_i(:,:) = zweighm1 * frlddta(:,:,1) + pweigh  * frlddta(:,:,2) 
+      emp (:,:) = zweighm1 * empdta (:,:,1) + pweigh  * empdta (:,:,2) 
+      emps(:,:) = emp(:,:) 
+      qsr (:,:) = zweighm1 * qsrdta (:,:,1) + pweigh  * qsrdta (:,:,2) 
+
+#if ! defined key_off_degrad && defined key_traldf_c2d    
+      ahtw(:,:) = zweighm1 * ahtwdta(:,:,1) + pweigh * ahtwdta(:,:,2)
+#  if defined key_trcldf_eiv
+      aeiw(:,:) = zweighm1 * aeiwdta(:,:,1) + pweigh * aeiwdta(:,:,2)
+#  endif
+#endif
+      
+#if defined key_off_degrad
+      ahtu(:,:,:) = zweighm1 * ahtudta(:,:,:,1) + pweigh * ahtudta(:,:,:,2)
+      ahtv(:,:,:) = zweighm1 * ahtvdta(:,:,:,1) + pweigh * ahtvdta(:,:,:,2)
+      ahtw(:,:,:) = zweighm1 * ahtwdta(:,:,:,1) + pweigh * ahtwdta(:,:,:,2)
+#  if defined key_trcldf_eiv
+      aeiu(:,:,:) = zweighm1 * aeiudta(:,:,:,1) + pweigh * aeiudta(:,:,:,2)
+      aeiv(:,:,:) = zweighm1 * aeivdta(:,:,:,1) + pweigh * aeivdta(:,:,:,2)
+      aeiw(:,:,:) = zweighm1 * aeiwdta(:,:,:,1) + pweigh * aeiwdta(:,:,:,2)
+#  endif
+#endif
+      
+#if defined key_trcbbl_dif   ||   defined key_trcbbl_adv
+      bblx(:,:) = zweighm1 * bblxdta(:,:,1) + pweigh * bblxdta(:,:,2)
+      bbly(:,:) = zweighm1 * bblydta(:,:,1) + pweigh * bblydta(:,:,2)
+#endif
+
+   END SUBROUTINE linear_interp_dyn_data
+
+END MODULE dtadyn
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/eosbn2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/eosbn2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/eosbn2.F90	(revision 1844)
@@ -0,0 +1,755 @@
+MODULE eosbn2
+   !!==============================================================================
+   !!                       ***  MODULE  eosbn2  ***
+   !! Ocean diagnostic variable : equation of state - in situ and potential density
+   !!                                               - Brunt-Vaisala frequency 
+   !!==============================================================================
+   !! History :       !  89-03  (O. Marti)  Original code
+   !!            6.0  !  94-07  (G. Madec, M. Imbard)  add bn2
+   !!            6.0  !  94-08  (G. Madec)  Add Jackett & McDougall eos
+   !!            7.0  !  96-01  (G. Madec)  statement function for e3
+   !!            8.1  !  97-07  (G. Madec)  introduction of neos, OPA8.1
+   !!            8.1  !  97-07  (G. Madec)  density instead of volumic mass
+   !!                 !  99-02  (G. Madec, N. Grima) semi-implicit pressure gradient
+   !!                 !  01-09  (M. Ben Jelloul)  bugfix onlinear eos
+   !!            8.5  !  02-10  (G. Madec)  add eos_init
+   !!            8.5  !  02-11  (G. Madec, A. Bozec)  partial step, eos_insitu_2d
+   !!            9.0  !  03-08  (G. Madec)  F90, free form
+   !!            9.0  !  06-08  (G. Madec)  add tfreez function
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   eos            : generic interface of the equation of state
+   !!   eos_insitu     : Compute the in situ density
+   !!   eos_insitu_pot : Compute the insitu and surface referenced potential
+   !!                    volumic mass
+   !!   eos_insitu_2d  : Compute the in situ density for 2d fields
+   !!   eos_bn2        : Compute the Brunt-Vaisala frequency
+   !!   tfreez         : Compute the surface freezing temperature
+   !!   eos_init       : set eos parameters (namelist)
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE zdfddm          ! vertical physics: double diffusion
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Interface 
+   INTERFACE eos
+      MODULE PROCEDURE eos_insitu, eos_insitu_pot, eos_insitu_2d
+   END INTERFACE 
+   INTERFACE bn2
+      MODULE PROCEDURE eos_bn2
+   END INTERFACE 
+
+   PUBLIC   eos        ! called by step, istate, tranpc and zpsgrd modules
+   PUBLIC   eos_init   ! called by istate module
+   PUBLIC   bn2        ! called by step module
+   PUBLIC   tfreez     ! called by sbcice_... modules
+
+   !!* Namelist (nameos)
+   INTEGER , PUBLIC ::   neos   = 0        !: = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
+   REAL(wp), PUBLIC ::   ralpha = 2.0e-4   !: thermal expension coeff. (linear equation of state)
+   REAL(wp), PUBLIC ::   rbeta  = 7.7e-4   !: saline  expension coeff. (linear equation of state)
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE eos_insitu( ptem, psal, prd )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE eos_insitu  ***
+      !! 
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from 
+      !!       potential temperature and salinity using an equation of state
+      !!       defined through the namelist parameter neos.
+      !!
+      !! ** Method  :   3 cases:
+      !!      neos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!      neos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = 0.0285 - ralpha * t
+      !!      neos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = rbeta * s - ralpha * tn - 1.
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (ptem,psal) are defined over the whole domain.
+      !!
+      !! ** Action  :   compute prd , the in situ density (no units)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density 
+      !!
+      INTEGER ::  ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   &          
+         zt , zs , zh , zsr,   &  ! temporary scalars
+         zr1, zr2, zr3, zr4,   &  !    "         " 
+         zrhop, ze, zbw, zb,   &  !    "         "
+         zd , zc , zaw, za ,   &  !    "         "
+         zb1, za1, zkw, zk0       !    "         "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( neos )
+      !
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+         !
+!CDIR NOVERRCHK
+         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  ! depth
+                  zh = fsdept(ji,jj,jk)
+                  ! square root salinity
+                  zsr= zws(ji,jj,jk)
+                  ! compute volumic mass pure water at atm pressure
+                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
+                     -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+                  ! seawater volumic mass atm pressure
+                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
+                     -4.0899e-3 ) *zt+0.824493
+                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+                  zr4= 4.8314e-4
+
+                  ! potential volumic mass (reference to the surface)
+                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+
+                  ! add the compression terms
+                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+                  zb = zbw + ze * zs
+
+                  zd = -2.042967e-2
+                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
+                  za = ( zd*zsr + zc ) *zs + zaw
+
+                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
+                  zk0= ( zb1*zsr + za1 )*zs + zkw
+
+                  ! masked in situ density anomaly
+                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
+                     - rau0 ) / rau0 * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         !
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  !   ... density and potential volumic mass
+                  prd(ji,jj,jk) = ( 0.0285 - ralpha * zt ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         !
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  !   ... density and potential volumic mass
+                  prd(ji,jj,jk) = (   rbeta  * zs - ralpha * zt ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE DEFAULT
+         !
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=prd, clinfo1=' eos  : ', ovlap=1, kdim=jpk)
+      !
+   END SUBROUTINE eos_insitu
+
+
+   SUBROUTINE eos_insitu_pot( ptem, psal, prd, prhop )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_insitu_pot  ***
+      !!           
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) and the
+      !!      potential volumic mass (Kg/m3) from potential temperature and
+      !!      salinity fields using an equation of state defined through the 
+      !!     namelist parameter neos.
+      !!
+      !! ** Method  :
+      !!      neos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!              rhop(t,s)  = rho(t,s,0)
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!
+      !!      neos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = ( rho(t) - rau0 ) / rau0 = 0.028 - ralpha * t
+      !!              rhop(t,s)  = rho(t,s)
+      !!
+      !!      neos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = ( rho(t,s) - rau0 ) / rau0 
+      !!                       = rbeta * s - ralpha * tn - 1.
+      !!              rhop(t,s)  = rho(t,s)
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (tn,sn) or (ta,sa) are defined over the whole domain.
+      !!
+      !! ** Action  : - prd  , the in situ density (no units)
+      !!              - prhop, the potential volumic mass (Kg/m3)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!                Brown and Campana, Mon. Weather Rev., 1978
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prhop  ! potential density (surface referenced)
+
+      INTEGER  ::  ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   &             ! temporary scalars
+         zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw,   &
+         zb, zd, zc, zaw, za, zb1, za1, zkw, zk0
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( neos )
+      !
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+         !
+!CDIR NOVERRCHK
+         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  ! depth
+                  zh = fsdept(ji,jj,jk)
+                  ! square root salinity
+                  zsr= zws(ji,jj,jk)
+                  ! compute volumic mass pure water at atm pressure
+                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
+                     -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+                  ! seawater volumic mass atm pressure
+                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
+                     -4.0899e-3 ) *zt+0.824493
+                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+                  zr4= 4.8314e-4
+
+                  ! potential volumic mass (reference to the surface)
+                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+
+                  ! save potential volumic mass
+                  prhop(ji,jj,jk) = zrhop * tmask(ji,jj,jk)
+
+                  ! add the compression terms
+                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+                  zb = zbw + ze * zs
+
+                  zd = -2.042967e-2
+                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
+                  za = ( zd*zsr + zc ) *zs + zaw
+
+                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
+                  zk0= ( zb1*zsr + za1 )*zs + zkw
+
+                  ! masked in situ density anomaly
+                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
+                     - rau0 ) / rau0 * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         !
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  !   ... density and potential volumic mass
+                  prd  (ji,jj,jk) = ( 0.0285 - ralpha * zt )        * tmask(ji,jj,jk)
+                  prhop(ji,jj,jk) = ( rau0 * prd(ji,jj,jk) + rau0 ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         !
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem(ji,jj,jk)
+                  zs = psal(ji,jj,jk)
+                  !   ... density and potential volumic mass
+                  prd  (ji,jj,jk) = ( rbeta  * zs - ralpha * zt ) * tmask(ji,jj,jk)
+                  prhop(ji,jj,jk) = ( rau0 * prd(ji,jj,jk) + rau0 )    * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE DEFAULT
+         !
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-p: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
+      !
+   END SUBROUTINE eos_insitu_pot
+
+
+   SUBROUTINE eos_insitu_2d( ptem, psal, pdep, prd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_insitu_2d  ***
+      !!
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from 
+      !!      potential temperature and salinity using an equation of state
+      !!      defined through the namelist parameter neos. * 2D field case
+      !!
+      !! ** Method :
+      !!      neos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!      neos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = 0.0285 - ralpha * t
+      !!      neos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = rbeta * s - ralpha * tn - 1.
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (ptem,psal) are defined over the whole domain.
+      !!
+      !! ** Action  : - prd , the in situ density (no units)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pdep   ! depth                  [m]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   prd    ! in situ density 
+      !!
+      INTEGER  ::  ji, jj                    ! dummy loop indices
+      REAL(wp) ::   &             ! temporary scalars
+         zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw,   &
+         zb, zd, zc, zaw, za, zb1, za1, zkw, zk0,               &
+         zmask
+      REAL(wp), DIMENSION(jpi,jpj) ::   zws
+      !!----------------------------------------------------------------------
+
+      prd(:,:) = 0.e0
+
+      SELECT CASE ( neos )
+      !
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+      !
+!CDIR NOVERRCHK
+         DO jj = 1, jpjm1
+!CDIR NOVERRCHK
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zws(ji,jj) = SQRT( ABS( psal(ji,jj) ) )
+            END DO
+         END DO
+         !                                                ! ===============
+         DO jj = 1, jpjm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zmask = tmask(ji,jj,1)      ! land/sea bottom mask = surf. mask
+
+               zt = ptem (ji,jj)            ! interpolated T
+               zs = psal (ji,jj)            ! interpolated S
+               zsr= zws(ji,jj)            ! square root of interpolated S
+               zh = pdep(ji,jj)            ! depth at the partial step level
+
+               ! compute volumic mass pure water at atm pressure
+               zr1 = ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
+                         -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+               ! seawater volumic mass atm pressure
+               zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 )*zt+7.6438e-5 ) *zt   &
+                         -4.0899e-3 ) *zt+0.824493
+               zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+               zr4= 4.8314e-4
+
+               ! potential volumic mass (reference to the surface)
+               zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+
+               ! add the compression terms
+               ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+               zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+               zb = zbw + ze * zs
+
+               zd = -2.042967e-2
+               zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+               zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt -4.721788
+               za = ( zd*zsr + zc ) *zs + zaw
+
+               zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+               za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+               zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt   &
+                         +2098.925 ) *zt+190925.6
+               zk0= ( zb1*zsr + za1 )*zs + zkw
+
+               ! masked in situ density anomaly
+               prd(ji,jj) = ( zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  ) - rau0 )   &
+                  &       / rau0 * zmask
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         !
+         !                                                ! ===============
+         DO jj = 1, jpjm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO ji = 1, fs_jpim1   ! vector opt.
+               prd(ji,jj) = ( 0.0285 - ralpha * ptem(ji,jj) ) * tmask(ji,jj,1)
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         !
+         !                                                ! ===============
+         DO jj = 1, jpjm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO ji = 1, fs_jpim1   ! vector opt.
+               prd(ji,jj) = ( rbeta * psal(ji,jj) - ralpha * ptem(ji,jj) ) * tmask(ji,jj,1) 
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE DEFAULT
+         !
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
+      !
+   END SUBROUTINE eos_insitu_2d
+
+
+   SUBROUTINE eos_bn2( ptem, psal, pn2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_bn2  ***
+      !!
+      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the time-
+      !!      step of the input arguments
+      !!      
+      !! ** Method :
+      !!       * neos = 0  : UNESCO sea water properties
+      !!         The brunt-vaisala frequency is computed using the polynomial
+      !!      polynomial expression of McDougall (1987):
+      !!            N^2 = grav * beta * ( alpha/beta*dk[ t ] - dk[ s ] )/e3w
+      !!      If lk_zdfddm=T, the heat/salt buoyancy flux ratio Rrau is
+      !!      computed and used in zdfddm module :
+      !!              Rrau = alpha/beta * ( dk[ t ] / dk[ s ] )
+      !!       * neos = 1  : linear equation of state (temperature only)
+      !!            N^2 = grav * ralpha * dk[ t ]/e3w
+      !!       * neos = 2  : linear equation of state (temperature & salinity)
+      !!            N^2 = grav * (ralpha * dk[ t ] - rbeta * dk[ s ] ) / e3w
+      !!      The use of potential density to compute N^2 introduces e r r o r
+      !!      in the sign of N^2 at great depths. We recommand the use of 
+      !!      neos = 0, except for academical studies.
+      !!        Macro-tasked on horizontal slab (jk-loop)
+      !!      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
+      !!      and is never used at this level.
+      !!
+      !! ** Action  : - pn2 : the brunt-vaisala frequency
+      !!
+      !! References :   McDougall, J. Phys. Oceanogr., 17, 1950-1964, 1987.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature   [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity                [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pn2    ! Brunt-Vaisala frequency [s-1]
+
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zgde3w, zt, zs, zh,  &  ! temporary scalars 
+         &          zalbet, zbeta           !    "         "
+#if defined key_zdfddm
+      REAL(wp) ::   zds          ! temporary scalars
+#endif
+      !!----------------------------------------------------------------------
+
+      ! pn2 : first and last levels
+      ! ---------------------------
+      ! bn^2=0. at jk=1 and jpk set in inidtr.F : no computation
+
+
+      ! pn2 : interior points only (2=< jk =< jpkm1 )
+      ! -------------------------- 
+
+      SELECT CASE ( neos )
+      !
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+         !
+         !                                                ! ===============
+         DO jk = 2, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zgde3w = grav / fse3w(ji,jj,jk)
+                  zt = 0.5 * ( ptem(ji,jj,jk) + ptem(ji,jj,jk-1) )          ! potential temperature at w-point
+                  zs = 0.5 * ( psal(ji,jj,jk) + psal(ji,jj,jk-1) ) - 35.0   ! salinity anomaly (s-35) at w-point
+                  zh = fsdepw(ji,jj,jk)                                     ! depth in meters  at w-point
+
+                  zalbet = ( ( ( - 0.255019e-07 * zt + 0.298357e-05 ) * zt   &   ! ratio alpha/beta
+                     &                               - 0.203814e-03 ) * zt   &
+                     &                               + 0.170907e-01 ) * zt   &
+                     &   + 0.665157e-01                                      &
+                     &   +     ( - 0.678662e-05 * zs                         &
+                     &           - 0.846960e-04 * zt + 0.378110e-02 ) * zs   &
+                     &   +   ( ( - 0.302285e-13 * zh                         &
+                     &           - 0.251520e-11 * zs                         &
+                     &           + 0.512857e-12 * zt * zt           ) * zh   &
+                     &           - 0.164759e-06 * zs                         &
+                     &        +(   0.791325e-08 * zt - 0.933746e-06 ) * zt   &
+                     &                               + 0.380374e-04 ) * zh
+
+                  zbeta  = ( ( -0.415613e-09 * zt + 0.555579e-07 ) * zt      &   ! beta
+                     &                            - 0.301985e-05 ) * zt      &
+                     &   + 0.785567e-03                                      &
+                     &   + (     0.515032e-08 * zs                           &
+                     &         + 0.788212e-08 * zt - 0.356603e-06 ) * zs     &
+                     &   +(  (   0.121551e-17 * zh                           &
+                     &         - 0.602281e-15 * zs                           &
+                     &         - 0.175379e-14 * zt + 0.176621e-12 ) * zh     &
+                     &                             + 0.408195e-10   * zs     &
+                     &     + ( - 0.213127e-11 * zt + 0.192867e-09 ) * zt     &
+                     &                             - 0.121555e-07 ) * zh
+
+                  pn2(ji,jj,jk) = zgde3w * zbeta * tmask(ji,jj,jk)           &   ! N^2 
+                     &          * ( zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )   &
+                     &                     - ( psal(ji,jj,jk-1) - psal(ji,jj,jk) ) )
+#if defined key_zdfddm
+                  !                                                         !!bug **** caution a traiter zds=dk[S]= 0 !!!!
+                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )                    ! Rrau = (alpha / beta) (dk[t] / dk[s])
+                  IF ( ABS( zds) <= 1.e-20 ) zds = 1.e-20
+                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
+#endif
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         !
+         !                                                ! ===============
+         DO jk = 2, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zgde3w = grav / fse3w(ji,jj,jk) * tmask(ji,jj,jk)
+                  pn2(ji,jj,jk) = zgde3w * ralpha * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         !
+         !                                                ! ===============
+         DO jk = 2, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zgde3w = grav / fse3w(ji,jj,jk) * tmask(ji,jj,jk)
+                  pn2(ji,jj,jk) = zgde3w * (  ralpha * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )   &
+                     &                      - rbeta  * ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )  )
+               END DO
+            END DO
+#if defined key_zdfddm
+            !                                                ! Rrau = (alpha / beta) (dk[t] / dk[s])
+            zalbet = ralpha / rbeta
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )
+                  IF ( ABS( zds ) <= 1.e-20 ) zds = 1.e-20
+                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
+               END DO
+            END DO
+#endif
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         !
+      CASE DEFAULT
+         !
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=pn2, clinfo1=' bn2  : ', ovlap=1, kdim=jpk)
+#if defined key_zdfddm
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=rrau, clinfo1=' rrau : ', ovlap=1, kdim=jpk)
+#endif
+      !
+   END SUBROUTINE eos_bn2
+
+
+   FUNCTION tfreez( psal ) RESULT( ptf )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!
+      !! ** Purpose :   Compute the sea surface freezing temperature [Celcius]
+      !!
+      !! ** Method  :   UNESCO freezing point at the surface (pressure = 0???)
+      !!       freezing point [Celcius]=(-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s-7.53e-4*p
+      !!       checkvalue: tf= -2.588567 Celsius for s=40.0psu, p=500. decibars
+      !!
+      !! Reference  :   UNESCO tech. papers in the marine science no. 28. 1978
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity             [psu]
+      REAL(wp), DIMENSION(jpi,jpj)                ::   ptf    ! freezing temperature [Celcius]
+      !!----------------------------------------------------------------------
+      ptf(:,:) = ( - 0.0575 + 1.710523e-3 * SQRT( psal(:,:) )   &
+         &                  - 2.154996e-4 *       psal(:,:)   ) * psal(:,:)
+   END FUNCTION tfreez
+
+
+   SUBROUTINE eos_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!
+      !! ** Purpose :   initializations for the equation of state
+      !!
+      !! ** Method  :   Read the namelist nameos and control the parameters
+      !!----------------------------------------------------------------------
+      NAMELIST/nameos/ neos, ralpha, rbeta
+
+      REWIND( numnam )            ! Read Namelist nameos : equation of state
+      READ  ( numnam, nameos )
+
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'eos_init : equation of state'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '          Namelist nameos : set eos parameters'
+         WRITE(numout,*) '             flag for eq. of state and N^2  neos   = ', neos
+         WRITE(numout,*) '             thermal exp. coef. (linear)    ralpha = ', ralpha
+         WRITE(numout,*) '             saline  exp. coef. (linear)    rbeta  = ', rbeta
+      ENDIF
+
+      SELECT CASE ( neos )
+
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of Jackett & McDougall (1994) equation of state and'
+         IF(lwp) WRITE(numout,*) '                 McDougall (1987) Brunt-Vaisala frequency'
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T) = rau0 * ( 1.0285 - ralpha * T )'
+         IF( lk_zdfddm ) CALL ctl_stop( '          double diffusive mixing parameterization requires',   &
+              &                         ' that T and S are used as state variables' )
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T,S) = rau0 * ( rbeta * S - ralpha * T )'
+         !
+      CASE DEFAULT             ! E R R O R in neos 
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( ctmp1 )
+      END SELECT
+
+   END SUBROUTINE eos_init
+
+   !!======================================================================
+END MODULE eosbn2  
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/istate.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/istate.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/istate.F90	(revision 1844)
@@ -0,0 +1,72 @@
+MODULE istate
+   !!======================================================================
+   !!                     ***  MODULE  istate  ***
+   !! Ocean state   :  initial state setting
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   istate_init   : initial state setting
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC istate_init   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE istate_init
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE istate_init  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers.
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!   4.0  !  91-03  ()  Original code
+      !!        !  91-11  (G. Madec)
+      !!   9.0  !  03-09  (G. Madec)  F90: Free form, modules, orthogonality
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      !!----------------------------------------------------------------------
+
+
+      ! Initialization to zero
+      ! ----------------------
+
+      !     before fields       !       now fields        !      after fields       !
+      ;   un   (:,:,:) = 0.e0   ;   ua   (:,:,:) = 0.e0
+      ;   vn   (:,:,:) = 0.e0   ;   va   (:,:,:) = 0.e0
+      ;                         ;   wn   (:,:,:) = 0.e0   
+      ;   hdivn(:,:,:) = 0.e0   ;
+
+      ;   tn   (:,:,:) = 0.e0   ;   ta   (:,:,:) = 0.e0
+      ;   sn   (:,:,:) = 0.e0   ;   sa   (:,:,:) = 0.e0
+
+      rhd  (:,:,:) = 0.e0
+      rhop (:,:,:) = 0.e0
+      rn2  (:,:,:) = 0.e0 
+
+
+   END SUBROUTINE istate_init
+
+   !!=====================================================================
+END MODULE istate
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lbclnk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lbclnk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lbclnk.F90	(revision 1844)
@@ -0,0 +1,714 @@
+MODULE lbclnk
+   !!======================================================================
+   !!                       ***  MODULE  lbclnk  ***
+   !! Ocean        : lateral boundary conditions
+   !!=====================================================================
+#if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'     OR      MPI massively parallel processing library
+   !!   'key_mpp_shmem'         SHMEM massively parallel processing library
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lbc_lnk      : generic interface for mpp_lnk_3d and mpp_lnk_2d
+   !!                  routines defined in lib_mpp
+   !!   lbc_lnk_e    : generic interface for mpp_lnk_2d_e
+   !!                   routinee defined in lib_mpp
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE lib_mpp          ! distributed memory computing library
+
+   INTERFACE lbc_lnk
+      MODULE PROCEDURE mpp_lnk_3d_gather, mpp_lnk_3d, mpp_lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc_lnk_e
+      MODULE PROCEDURE mpp_lnk_2d_e
+   END INTERFACE
+
+   PUBLIC lbc_lnk       ! ocean lateral boundary conditions
+   PUBLIC lbc_lnk_e
+   !!----------------------------------------------------------------------
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                              shared memory computing
+   !!----------------------------------------------------------------------
+   !!   lbc_lnk      : generic interface for lbc_lnk_3d and lbc_lnk_2d
+   !!   lbc_lnk_3d   : set the lateral boundary condition on a 3D variable
+   !!                  on OPA ocean mesh
+   !!   lbc_lnk_2d   : set the lateral boundary condition on a 2D variable
+   !!                  on OPA ocean mesh
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers   
+   USE dom_oce         ! ocean space and time domain 
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE lbc_lnk
+      MODULE PROCEDURE lbc_lnk_3d_gather, lbc_lnk_3d, lbc_lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc_lnk_e
+      MODULE PROCEDURE lbc_lnk_2d
+   END INTERFACE
+
+   PUBLIC lbc_lnk       ! ocean/ice  lateral boundary conditions
+   PUBLIC  lbc_lnk_e 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lbc_lnk_3d_gather( pt3d1, cd_type1, pt3d2, cd_type2, psgn )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d_gather  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type1, cd_type2       ! nature of pt3d grid-points
+         !             !   = T ,  U , V , F or W  gridpoints
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         pt3d1, pt3d2          ! 3D array on which the boundary condition is applied
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   =-1 , the sign is changed if north fold boundary
+         !             !   = 1 , no sign change
+         !             !   = 0 , no sign change and > 0 required (use the inner
+         !             !         row/column if closed boundary)
+
+      
+      !! * Local declarations
+      INTEGER  ::   ji, jk
+      INTEGER  ::   ijt, iju
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+      !!----------------------------------------------------------------------
+      
+      !                                                      ! ===============
+      DO jk = 1, jpk                                         ! Horizontal slab
+         !                                                   ! ===============
+
+         !                                     ! East-West boundaries
+         !                                     ! ====================
+         SELECT CASE ( nperio )
+
+         CASE ( 1 , 4 , 6 )                    ! * cyclic east-west
+            pt3d1( 1 ,:,jk) = pt3d1(jpim1,:,jk)          ! all points
+            pt3d1(jpi,:,jk) = pt3d1(  2  ,:,jk)
+            pt3d2( 1 ,:,jk) = pt3d2(jpim1,:,jk)          
+            pt3d2(jpi,:,jk) = pt3d2(  2  ,:,jk)
+
+         CASE DEFAULT                          ! * closed
+            SELECT CASE ( cd_type1 )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d1( 1 ,:,jk) = 0.e0
+               pt3d1(jpi,:,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d1(jpi,:,jk) = 0.e0
+            END SELECT
+            SELECT CASE ( cd_type2 )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d2( 1 ,:,jk) = 0.e0
+               pt3d2(jpi,:,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d2(jpi,:,jk) = 0.e0
+            END SELECT
+
+         END SELECT
+
+         !                                     ! North-South boundaries
+         !                                     ! ======================
+         SELECT CASE ( nperio )
+
+         CASE ( 2 )                            ! *  south symmetric
+
+            SELECT CASE ( cd_type1 )
+            CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+               pt3d1(:, 1 ,jk) = pt3d1(:,3,jk)
+               pt3d1(:,jpj,jk) = 0.e0
+            CASE ( 'V' , 'F' )                         ! V-, F-points
+               pt3d1(:, 1 ,jk) = psgn * pt3d1(:,2,jk)
+               pt3d1(:,jpj,jk) = 0.e0
+            END SELECT
+            SELECT CASE ( cd_type2 )
+            CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+               pt3d2(:, 1 ,jk) = pt3d2(:,3,jk)
+               pt3d2(:,jpj,jk) = 0.e0
+            CASE ( 'V' , 'F' )                         ! V-, F-points
+               pt3d2(:, 1 ,jk) = psgn * pt3d2(:,2,jk)
+               pt3d2(:,jpj,jk) = 0.e0
+            END SELECT
+
+         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
+
+            pt3d1( 1 ,jpj,jk) = 0.e0
+            pt3d1(jpi,jpj,jk) = 0.e0
+            pt3d2( 1 ,jpj,jk) = 0.e0
+            pt3d2(jpi,jpj,jk) = 0.e0
+
+            SELECT CASE ( cd_type1 )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 2, jpi
+                  ijt = jpi-ji+2
+                  pt3d1(ji, 1 ,jk) = 0.e0
+                  pt3d1(ji,jpj,jk) = psgn * pt3d1(ijt,jpj-2,jk)
+               END DO
+               DO ji = jpi/2+1, jpi
+                  ijt = jpi-ji+2
+                  pt3d1(ji,jpjm1,jk) = psgn * pt3d1(ijt,jpjm1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, jpi-1
+                  iju = jpi-ji+1
+                  pt3d1(ji, 1 ,jk) = 0.e0
+                  pt3d1(ji,jpj,jk) = psgn * pt3d1(iju,jpj-2,jk)
+               END DO
+               DO ji = jpi/2, jpi-1
+                  iju = jpi-ji+1
+                  pt3d1(ji,jpjm1,jk) = psgn * pt3d1(iju,jpjm1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 2, jpi
+                     ijt = jpi-ji+2
+                     pt3d1(ji,  1  ,jk) = 0.e0
+                     pt3d1(ji,jpj-1,jk) = psgn * pt3d1(ijt,jpj-2,jk)
+                     pt3d1(ji,jpj  ,jk) = psgn * pt3d1(ijt,jpj-3,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji+1
+                     pt3d1(ji,jpj-1,jk) = psgn * pt3d1(iju,jpj-2,jk)
+                     pt3d1(ji,jpj  ,jk) = psgn * pt3d1(iju,jpj-3,jk)
+                  END DO
+            END SELECT
+            SELECT CASE ( cd_type2 )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 2, jpi
+                  ijt = jpi-ji+2
+                  pt3d2(ji, 1 ,jk) = 0.e0
+                  pt3d2(ji,jpj,jk) = psgn * pt3d2(ijt,jpj-2,jk)
+               END DO
+               DO ji = jpi/2+1, jpi
+                  ijt = jpi-ji+2
+                  pt3d2(ji,jpjm1,jk) = psgn * pt3d2(ijt,jpjm1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, jpi-1
+                  iju = jpi-ji+1
+                  pt3d2(ji, 1 ,jk) = 0.e0
+                  pt3d2(ji,jpj,jk) = psgn * pt3d2(iju,jpj-2,jk)
+               END DO
+               DO ji = jpi/2, jpi-1
+                  iju = jpi-ji+1
+                  pt3d2(ji,jpjm1,jk) = psgn * pt3d2(iju,jpjm1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 2, jpi
+                     ijt = jpi-ji+2
+                     pt3d2(ji,  1  ,jk) = 0.e0
+                     pt3d2(ji,jpj-1,jk) = psgn * pt3d2(ijt,jpj-2,jk)
+                     pt3d2(ji,jpj  ,jk) = psgn * pt3d2(ijt,jpj-3,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji+1
+                     pt3d2(ji,jpj-1,jk) = psgn * pt3d2(iju,jpj-2,jk)
+                     pt3d2(ji,jpj  ,jk) = psgn * pt3d2(iju,jpj-3,jk)
+                  END DO
+            END SELECT
+
+         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
+
+            pt3d1( 1 ,jpj,jk) = 0.e0
+            pt3d1(jpi,jpj,jk) = 0.e0
+            pt3d2( 1 ,jpj,jk) = 0.e0
+            pt3d2(jpi,jpj,jk) = 0.e0
+
+            SELECT CASE ( cd_type1 )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 1, jpi
+                  ijt = jpi-ji+1
+                  pt3d1(ji, 1 ,jk) = 0.e0
+                  pt3d1(ji,jpj,jk) = psgn * pt3d1(ijt,jpj-1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d1(ji, 1 ,jk) = 0.e0
+                     pt3d1(ji,jpj,jk) = psgn * pt3d1(iju,jpj-1,jk)
+                  END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 1, jpi
+                     ijt = jpi-ji+1
+                     pt3d1(ji, 1 ,jk) = 0.e0
+                     pt3d1(ji,jpj,jk) = psgn * pt3d1(ijt,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi
+                     ijt = jpi-ji+1
+                     pt3d1(ji,jpjm1,jk) = psgn * pt3d1(ijt,jpjm1,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d1(ji,jpj  ,jk) = psgn * pt3d1(iju,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi-1
+                     iju = jpi-ji
+                     pt3d1(ji,jpjm1,jk) = psgn * pt3d1(iju,jpjm1,jk)
+                  END DO
+            END SELECT
+            SELECT CASE ( cd_type2 )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 1, jpi
+                  ijt = jpi-ji+1
+                  pt3d2(ji, 1 ,jk) = 0.e0
+                  pt3d2(ji,jpj,jk) = psgn * pt3d2(ijt,jpj-1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d2(ji, 1 ,jk) = 0.e0
+                     pt3d2(ji,jpj,jk) = psgn * pt3d2(iju,jpj-1,jk)
+                  END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 1, jpi
+                     ijt = jpi-ji+1
+                     pt3d2(ji, 1 ,jk) = 0.e0
+                     pt3d2(ji,jpj,jk) = psgn * pt3d2(ijt,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi
+                     ijt = jpi-ji+1
+                     pt3d2(ji,jpjm1,jk) = psgn * pt3d2(ijt,jpjm1,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d2(ji,jpj  ,jk) = psgn * pt3d2(iju,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi-1
+                     iju = jpi-ji
+                     pt3d2(ji,jpjm1,jk) = psgn * pt3d2(iju,jpjm1,jk)
+                  END DO
+            END SELECT
+
+         CASE DEFAULT                          ! *  closed
+
+            SELECT CASE ( cd_type1 )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d1(:, 1 ,jk) = 0.e0
+               pt3d1(:,jpj,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d1(:,jpj,jk) = 0.e0
+            END SELECT
+            SELECT CASE ( cd_type2 )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d2(:, 1 ,jk) = 0.e0
+               pt3d2(:,jpj,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d2(:,jpj,jk) = 0.e0
+            END SELECT
+
+         END SELECT
+         !                                                   ! ===============
+      END DO                                                 !   End of slab
+      !                                                      ! ===============
+
+   END SUBROUTINE lbc_lnk_3d_gather
+
+
+   SUBROUTINE lbc_lnk_3d( pt3d, cd_type, psgn, cd_mpp )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt3d grid-points
+         !             !   = T ,  U , V , F or W  gridpoints
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         pt3d          ! 3D array on which the boundary condition is applied
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   =-1 , the sign is changed if north fold boundary
+         !             !   = 1 , no sign change
+         !             !   = 0 , no sign change and > 0 required (use the inner
+         !             !         row/column if closed boundary)
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only (here do nothing)
+
+      !! * Local declarations
+      INTEGER  ::   ji, jk
+      INTEGER  ::   ijt, iju
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+      !!----------------------------------------------------------------------
+
+      IF (PRESENT(cd_mpp)) THEN
+         ! only fill the overlap area and extra allows 
+         ! this is in mpp case. In this module, just do nothing
+      ELSE
+      
+      !                                                      ! ===============
+      DO jk = 1, jpk                                         ! Horizontal slab
+         !                                                   ! ===============
+
+         !                                     ! East-West boundaries
+         !                                     ! ====================
+         SELECT CASE ( nperio )
+
+         CASE ( 1 , 4 , 6 )                    ! * cyclic east-west
+            pt3d( 1 ,:,jk) = pt3d(jpim1,:,jk)          ! all points
+            pt3d(jpi,:,jk) = pt3d(  2  ,:,jk)
+
+         CASE DEFAULT                          ! * closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d( 1 ,:,jk) = 0.e0
+               pt3d(jpi,:,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d(jpi,:,jk) = 0.e0
+            END SELECT
+
+         END SELECT
+
+         !                                     ! North-South boundaries
+         !                                     ! ======================
+         SELECT CASE ( nperio )
+
+         CASE ( 2 )                            ! *  south symmetric
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+               pt3d(:, 1 ,jk) = pt3d(:,3,jk)
+               pt3d(:,jpj,jk) = 0.e0
+            CASE ( 'V' , 'F' )                         ! V-, F-points
+               pt3d(:, 1 ,jk) = psgn * pt3d(:,2,jk)
+               pt3d(:,jpj,jk) = 0.e0
+            END SELECT
+
+         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
+
+            pt3d( 1 ,jpj,jk) = 0.e0
+            pt3d(jpi,jpj,jk) = 0.e0
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 2, jpi
+                  ijt = jpi-ji+2
+                  pt3d(ji, 1 ,jk) = 0.e0
+                  pt3d(ji,jpj,jk) = psgn * pt3d(ijt,jpj-2,jk)
+               END DO
+               DO ji = jpi/2+1, jpi
+                  ijt = jpi-ji+2
+                  pt3d(ji,jpjm1,jk) = psgn * pt3d(ijt,jpjm1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, jpi-1
+                  iju = jpi-ji+1
+                  pt3d(ji, 1 ,jk) = 0.e0
+                  pt3d(ji,jpj,jk) = psgn * pt3d(iju,jpj-2,jk)
+               END DO
+               DO ji = jpi/2, jpi-1
+                  iju = jpi-ji+1
+                  pt3d(ji,jpjm1,jk) = psgn * pt3d(iju,jpjm1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 2, jpi
+                     ijt = jpi-ji+2
+                     pt3d(ji,  1  ,jk) = 0.e0
+                     pt3d(ji,jpj-1,jk) = psgn * pt3d(ijt,jpj-2,jk)
+                     pt3d(ji,jpj  ,jk) = psgn * pt3d(ijt,jpj-3,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji+1
+                     pt3d(ji,jpj-1,jk) = psgn * pt3d(iju,jpj-2,jk)
+                     pt3d(ji,jpj  ,jk) = psgn * pt3d(iju,jpj-3,jk)
+                  END DO
+            END SELECT
+
+         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
+
+            pt3d( 1 ,jpj,jk) = 0.e0
+            pt3d(jpi,jpj,jk) = 0.e0
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 1, jpi
+                  ijt = jpi-ji+1
+                  pt3d(ji, 1 ,jk) = 0.e0
+                  pt3d(ji,jpj,jk) = psgn * pt3d(ijt,jpj-1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d(ji, 1 ,jk) = 0.e0
+                     pt3d(ji,jpj,jk) = psgn * pt3d(iju,jpj-1,jk)
+                  END DO
+            CASE ( 'V' )                               ! V-point
+                  DO ji = 1, jpi
+                     ijt = jpi-ji+1
+                     pt3d(ji, 1 ,jk) = 0.e0
+                     pt3d(ji,jpj,jk) = psgn * pt3d(ijt,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi
+                     ijt = jpi-ji+1
+                     pt3d(ji,jpjm1,jk) = psgn * pt3d(ijt,jpjm1,jk)
+                  END DO
+            CASE ( 'F' )                               ! F-point
+                  DO ji = 1, jpi-1
+                     iju = jpi-ji
+                     pt3d(ji,jpj  ,jk) = psgn * pt3d(iju,jpj-2,jk)
+                  END DO
+                  DO ji = jpi/2+1, jpi-1
+                     iju = jpi-ji
+                     pt3d(ji,jpjm1,jk) = psgn * pt3d(iju,jpjm1,jk)
+                  END DO
+            END SELECT
+
+         CASE DEFAULT                          ! *  closed
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d(:, 1 ,jk) = 0.e0
+               pt3d(:,jpj,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d(:,jpj,jk) = 0.e0
+            END SELECT
+
+         END SELECT
+         !                                                   ! ===============
+      END DO                                                 !   End of slab
+      !                                                      ! ===============
+   ENDIF
+   END SUBROUTINE lbc_lnk_3d
+
+
+   SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE lbc_lnk_2d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code
+      !!        !  01-05  (E. Durand)  correction
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt2d grid-point
+         !             !   = T , U , V , F or W  gridpoints
+         !             !   = I sea-ice U-V gridpoint (= F ocean grid point with indice shift)
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   =-1 , the sign is modified following the type of b.c. used
+         !             !   = 1 , no sign change
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only (here do nothing)
+
+      !! * Local declarations
+      INTEGER  ::   ji
+      INTEGER  ::   ijt, iju
+      !!----------------------------------------------------------------------
+      !!  OPA 8.5, LODYC-IPSL (2002)
+      !!----------------------------------------------------------------------
+
+      IF (PRESENT(cd_mpp)) THEN
+         ! only fill the overlap area and extra allows 
+         ! this is in mpp case. In this module, just do nothing
+      ELSE      
+      
+      !                                        ! East-West boundaries
+      !                                        ! ====================
+      SELECT CASE ( nperio )
+
+      CASE ( 1 , 4 , 6 )                       ! * cyclic east-west
+         pt2d( 1 ,:) = pt2d(jpim1,:)
+         pt2d(jpi,:) = pt2d(  2  ,:)
+
+      CASE DEFAULT                             ! * closed 
+         SELECT CASE ( cd_type )
+         CASE ( 'T' , 'U' , 'V' , 'W' )                ! T-, U-, V-, W-points
+            pt2d( 1 ,:) = 0.e0
+            pt2d(jpi,:) = 0.e0
+         CASE ( 'F' )                                  ! F-point, ice U-V point
+            pt2d(jpi,:) = 0.e0 
+         CASE ( 'I' )                                  ! F-point, ice U-V point
+            pt2d( 1 ,:) = 0.e0 
+            pt2d(jpi,:) = 0.e0 
+         END SELECT
+
+      END SELECT
+
+      !                                        ! North-South boundaries
+      !                                        ! ======================
+      SELECT CASE ( nperio )
+
+      CASE ( 2 )                               ! * South symmetric
+
+         SELECT CASE ( cd_type )
+         CASE ( 'T' , 'U' , 'W' )                      ! T-, U-, W-points
+            pt2d(:, 1 ) = pt2d(:,3)
+            pt2d(:,jpj) = 0.e0
+         CASE ( 'V' , 'F' , 'I' )                      ! V-, F-points, ice U-V point
+            pt2d(:, 1 ) = psgn * pt2d(:,2)
+            pt2d(:,jpj) = 0.e0
+         END SELECT
+
+      CASE ( 3 , 4 )                           ! * North fold  T-point pivot
+
+         pt2d( 1 , 1 ) = 0.e0        !!!!!  bug gm ??? !Edmee
+         pt2d( 1 ,jpj) = 0.e0
+         pt2d(jpi,jpj) = 0.e0
+
+         SELECT CASE ( cd_type )
+
+         CASE ( 'T' , 'W' )                            ! T-, W-point
+            DO ji = 2, jpi
+               ijt = jpi-ji+2
+               pt2d(ji, 1 ) = 0.e0
+               pt2d(ji,jpj) = psgn * pt2d(ijt,jpj-2)
+            END DO
+            DO ji = jpi/2+1, jpi
+               ijt = jpi-ji+2
+               pt2d(ji,jpjm1) = psgn * pt2d(ijt,jpjm1)
+            END DO
+
+         CASE ( 'U' )                                  ! U-point
+            DO ji = 1, jpi-1
+               iju = jpi-ji+1
+               pt2d(ji, 1 ) = 0.e0
+               pt2d(ji,jpj) = psgn * pt2d(iju,jpj-2)
+            END DO
+            DO ji = jpi/2, jpi-1
+               iju = jpi-ji+1
+               pt2d(ji,jpjm1) = psgn * pt2d(iju,jpjm1)
+            END DO
+
+         CASE ( 'V' )                                  ! V-point
+            DO ji = 2, jpi
+               ijt = jpi-ji+2
+               pt2d(ji, 1   ) = 0.e0
+               pt2d(ji,jpj-1) = psgn * pt2d(ijt,jpj-2)
+               pt2d(ji,jpj  ) = psgn * pt2d(ijt,jpj-3)
+            END DO
+
+         CASE ( 'F' )                                  ! F-point
+            DO ji = 1, jpi-1
+               iju = jpi - ji + 1
+               pt2d(ji,jpj-1) = psgn * pt2d(iju,jpj-2)
+               pt2d(ji,jpj  ) = psgn * pt2d(iju,jpj-3)
+            END DO
+
+         CASE ( 'I' )                                  ! ice U-V point
+            pt2d(:, 1 ) = 0.e0
+            pt2d(2,jpj) = psgn * pt2d(3,jpj-1)
+            DO ji = 3, jpi
+               iju = jpi - ji + 3
+               pt2d(ji,jpj) = psgn * pt2d(iju,jpj-1)
+            END DO
+
+         END SELECT
+
+      CASE ( 5 , 6 )                           ! * North fold  F-point pivot
+
+         pt2d( 1 , 1 ) = 0.e0           !!bug  ???
+         pt2d( 1 ,jpj) = 0.e0
+         pt2d(jpi,jpj) = 0.e0
+
+         SELECT CASE ( cd_type )
+
+         CASE ( 'T' , 'W' )                            ! T-, W-point
+            DO ji = 1, jpi
+               ijt = jpi-ji+1
+               pt2d(ji, 1 ) = 0.e0
+               pt2d(ji,jpj) = psgn * pt2d(ijt,jpj-1)
+            END DO
+
+         CASE ( 'U' )                                  ! U-point
+            DO ji = 1, jpi-1
+               iju = jpi-ji
+               pt2d(ji, 1 ) = 0.e0
+               pt2d(ji,jpj) = psgn * pt2d(iju,jpj-1)
+            END DO
+
+         CASE ( 'V' )                                  ! V-point
+            DO ji = 1, jpi
+               ijt = jpi-ji+1
+               pt2d(ji, 1 ) = 0.e0
+               pt2d(ji,jpj) = psgn * pt2d(ijt,jpj-2)
+            END DO
+            DO ji = jpi/2+1, jpi
+               ijt = jpi-ji+1
+               pt2d(ji,jpjm1) = psgn * pt2d(ijt,jpjm1)
+            END DO
+
+         CASE ( 'F' )                                  ! F-point
+            DO ji = 1, jpi-1
+               iju = jpi-ji
+               pt2d(ji,jpj  ) = psgn * pt2d(iju,jpj-2)
+            END DO
+            DO ji = jpi/2+1, jpi-1
+               iju = jpi-ji
+               pt2d(ji,jpjm1) = psgn * pt2d(iju,jpjm1)
+            END DO
+
+         CASE ( 'I' )                                  ! ice U-V point
+            pt2d( : , 1 ) = 0.e0
+            pt2d( 2 ,jpj) = 0.e0
+            DO ji = 2 , jpim1
+               ijt = jpi - ji + 2
+               pt2d(ji,jpj)= 0.5 * ( pt2d(ji,jpjm1) + psgn * pt2d(ijt,jpjm1) )
+            END DO
+
+         END SELECT
+
+      CASE DEFAULT                             ! * closed
+
+         SELECT CASE ( cd_type )
+         CASE ( 'T' , 'U' , 'V' , 'W' )                ! T-, U-, V-, W-points
+            pt2d(:, 1 ) = 0.e0
+            pt2d(:,jpj) = 0.e0
+         CASE ( 'F' )                                  ! F-point
+            pt2d(:,jpj) = 0.e0
+         CASE ( 'I' )                                  ! ice U-V point
+            pt2d(:, 1 ) = 0.e0
+            pt2d(:,jpj) = 0.e0
+         END SELECT
+
+      END SELECT
+
+      ENDIF
+      
+   END SUBROUTINE lbc_lnk_2d
+
+#endif
+
+   !!======================================================================
+END MODULE lbclnk
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_cray.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_cray.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_cray.f90	(revision 1844)
@@ -0,0 +1,60 @@
+!  Cray subroutines or functions used by OPA model and possibly 
+!  not found on other platforms.
+!
+!  check their existence
+!  
+!  sdot
+!  wheneq
+!  saxpy
+!  isrchne
+!!----------------------------------------------------------------------
+!!  OPA 9.0 , LOCEAN-IPSL (2005) 
+!! $Id$ 
+!! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+!!----------------------------------------------------------------------
+     FUNCTION sdot( I, X, J, Y, K )
+        DIMENSION X(1), Y(1)
+        SDOT = 0.
+        DO N = 1, I
+        SDOT = SDOT + X(1+(N-1)*J) * Y(1+(N-1)*K)
+        END DO
+     END FUNCTION sdot
+!---------------------------------------------------------
+     SUBROUTINE wheneq ( i, x, j, t, ind, nn )
+        IMPLICIT NONE
+
+        INTEGER , INTENT (  in ) :: i, j
+        INTEGER , INTENT ( out ) :: nn
+        REAL    , INTENT (  in ), DIMENSION (1+(i-1)*j) :: x
+        REAL    , INTENT (  in ) :: t
+        INTEGER , INTENT ( out ), DIMENSION (1+(i-1)*j) :: ind
+        INTEGER :: n, k
+        nn = 0
+        DO n = 1, i
+          k = 1 + (n-1) * j
+          IF ( x ( k) == t ) THEN 
+              nn = nn + 1
+              ind (nn) = k
+          ENDIF
+        END DO 
+
+     END SUBROUTINE wheneq
+!---------------------------------------------------------
+     SUBROUTINE saxpy( I, A, X, J, Y, K )
+        DIMENSION X(1),Y(1)
+        DO N = 1, I
+           Y(1+(N-1)*K)=A*X(1+(N-1)*J)+Y(1+(N-1)*K)
+        END DO
+     END SUBROUTINE saxpy
+!---------------------------------------------------------
+     FUNCTION isrchne( K, X, I, B )
+        DIMENSION X(1)
+        DO N = 1, K
+           IF( X(1+(N-1)*I) /= B ) THEN
+              ISRCHNE = N
+              RETURN
+           ELSE
+              ISRCHNE = N + 1
+           ENDIF
+        END DO
+     END FUNCTION isrchne
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_isml.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_isml.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_isml.f90	(revision 1844)
@@ -0,0 +1,674 @@
+!
+! subroutines for PCG or SOR solvers
+! (used if the ISML library is not available)
+!
+! linrg
+!   gauss
+!   vmov
+!   desremopt
+!   dtrsv
+!   dger
+!   xerbla
+!   lsame
+! folr (empty)
+!
+!!----------------------------------------------------------------------
+!!  OPA 9.0 , LOCEAN-IPSL (2005) 
+!! $Id$ 
+!! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+!!----------------------------------------------------------------------
+   SUBROUTINE linrg(kn,pa,klda,painv,kldainv)
+
+      !! compute inverse matrix
+
+      IMPLICIT NONE 
+      INTEGER kn,klda,kldainv
+      REAL (kind=8) ::   pa(kn,kn),painv(kn,kn)
+      REAL (kind=8) ::   zb(kn,kn)
+      REAL (kind=8) ::   zv(kn)
+      INTEGER iplin(kn)
+      INTEGER ji
+
+      IF( kn /= klda .OR. kn /= kldainv ) THEN 
+          write(0,*)'change your parameters'
+          STOP 
+      ENDIF 
+
+      CALL vmov( kn*kn, pa, painv )
+
+      CALL gauss( kn, painv, iplin, zv )
+
+      zb(:,:) = 0.e0   
+      DO ji = 1, kn
+        zb(ji,ji) = 1.e0
+        CALL desremopt( kn, painv, iplin, zb(1,ji), zb(1,ji), zv )
+      END DO 
+      CALL vmov( kn*kn, zb, painv )
+
+   END SUBROUTINE linrg
+!---------------------------------------------------------
+   SUBROUTINE gauss(kn,pa,kplin,pv)
+
+      IMPLICIT NONE 
+      INTEGER kn
+      INTEGER ji,jj,jk
+      INTEGER ik,ipp
+      REAL (kind=8) ::   pa(kn,kn),pv(kn)
+!!    REAL (kind=8) ::   zpivmax,zalpha
+      REAL (kind=8) ::   zalpha
+      INTEGER kplin(kn)
+      INTEGER isamax
+      EXTERNAL isamax
+
+!  factorisation de Gauss de la matrice a avec pivot partiel . 
+!  initialisation des pointeurs .
+      DO ji=1,kn
+        kplin(ji)=ji
+      END DO 
+      DO jk=1,kn-1
+!  recherche du pivot maximal .
+!!      ik=jk
+!!      zpivmax=dabs(pa(jk,jk))
+!!        DO ji=jk,kn
+!!          IF(dabs(pa(ji,jk)) > zpivmax) THEN 
+!!            zpivmax=dabs(pa(ji,jk))
+!!            ik=ji
+!!          ENDIF 
+!!        END DO 
+        ik=isamax( kn-jk+1, pa(jk,jk) )+jk-1
+!  permutation de la ligne jk et de la ligne ik .
+        IF(jk == 58) THEN
+            PRINT *,'matrix ',(pa(jk,ji),ji=1,kn)
+            PRINT *,' pivot ',ik,kplin(ik),kplin(jk)
+        ENDIF 
+        ipp=kplin(ik)
+        kplin(ik)=kplin(jk)
+        kplin(jk)=ipp
+        DO jj=1,kn
+          pv(jj)=pa(ik,jj)
+          pa(ik,jj)=pa(jk,jj)
+          pa(jk,jj)=pv(jj)
+        END DO 
+        IF(jk == 58) THEN
+            PRINT *,'matrix ',(pa(jk,ji),ji=1,kn)
+            PRINT *,' pivot ',ik,kplin(ik),kplin(jk)
+        ENDIF 
+!  calcul des coefficients de la colonne k ligne a ligne .
+        DO ji=jk+1,kn
+          IF(pa(jk,jk) == 0) THEN 
+              PRINT *,'probleme diagonale nulle',jk,pa(jk,jk)
+              pa(ji,jk)=pa(ji,jk)/1.E-20
+          ENDIF 
+          IF(pa(jk,jk) /= 0) pa(ji,jk)=pa(ji,jk)/pa(jk,jk)
+        END DO 
+!!        DO ji=jk+1,kn
+!!          DO jj=jk+1,kn
+!!            pa(ji,jj)=pa(ji,jj)-pa(ji,jk)*pa(jk,jj)
+!!          END DO 
+!!        END DO 
+        zalpha=-1.
+        CALL dger(kn-jk,kn-jk,zalpha,pa(jk+1,jk),1,pa(jk,jk+1),kn,   &
+            pa(jk+1,jk+1),kn)
+      END DO 
+
+   END SUBROUTINE gauss
+!---------------------------------------------------------
+   FUNCTION isamax( I, X )
+      DIMENSION X(I)
+      ISAMAX = 0
+      XMIN = -1e+50
+      DO N = 1, I
+         IF(ABS(X(N)) > XMIN ) THEN
+            XMIN = X(N)
+            ISAMAX = N
+         ENDIF
+      END DO
+   END FUNCTION isamax
+!---------------------------------------------------------
+   SUBROUTINE vmov(kn,px,py)
+
+      IMPLICIT NONE 
+      INTEGER kn
+      REAL (kind=8) ::   px(kn),py(kn)
+      INTEGER ji
+
+      DO ji=1,kn
+         py(ji)=px(ji)
+      END DO 
+
+   END SUBROUTINE vmov
+!---------------------------------------------------------
+   subroutine desremopt(n,a,plin,y,x,v)
+      implicit none
+      integer n,i,  j0
+!!    integer n,i,j,j0
+      real (kind=8) ::   a(n,n),x(n),y(n),v(n)
+      integer plin(n)
+!  descente remontee du systeme .
+!  initialisation du vecteur resultat .
+!  prise en compte de la permutation des lignes .
+      do i=1,n
+        v(i)=y(plin(i))
+      end do
+      do i=1,n
+        if(v(i) /= 0.) then
+          j0=i-1
+          goto 1
+        endif
+      end do
+1     continue
+!  descente du systeme L v = v , L est a diagonale unitaire .
+!!      do j=j0+1,n
+!!        do i=j+1,n
+!!          v(i)=v(i)-a(i,j)*v(j)
+!!        end do
+!!      end do
+      call dtrsv('L','N','U',n-j0,a(j0+1,j0+1),n,v(j0+1),1)
+!  remontee du systeme U v = v . 
+!!      do j=n,1,-1
+!!        v(j)=v(j)/a(j,j)
+!!        do i=1,j-1
+!!          v(i)=v(i)-a(i,j)*v(j)
+!!        end do
+!!      end do          
+      call dtrsv('U','N','N',n,a,n,v,1)
+!  prise en compte de la permutation des colonnes .
+      do i=1,n
+        x(i)=v(i)
+      end do
+
+   end SUBROUTINE desremopt
+!---------------------------------------------------------
+   SUBROUTINE DTRSV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX )
+!!    .. Scalar Arguments ..
+      INTEGER            INCX, LDA, N
+      CHARACTER (len=1) ::   DIAG, TRANS, UPLO
+!!    .. Array Arguments ..
+!     DOUBLE PRECISION   A( LDA, * ), X( * )
+      REAL (kind=8) ::     A( LDA, * ), X( * )
+!!    ..
+
+!! Purpose
+!! =======
+
+!! DTRSV  solves one of the systems of equations
+
+!!    A*x = b,   or   A'*x = b,
+
+!! where b and x are n element vectors and A is an n by n unit, or
+!! non-unit, upper or lower triangular matrix.
+
+!! No test for singularity or near-singularity is included in this
+!! routine. Such tests must be performed before calling this routine.
+
+!! Parameters
+!! ==========
+
+!! UPLO   - CHARACTER*1.
+!!          On entry, UPLO specifies whether the matrix is an upper or
+!!          lower triangular matrix as follows:
+
+!!             UPLO = 'U' or 'u'   A is an upper triangular matrix.
+
+!!             UPLO = 'L' or 'l'   A is a lower triangular matrix.
+
+!!          Unchanged on exit.
+
+!! TRANS  - CHARACTER*1.
+!!          On entry, TRANS specifies the equations to be solved as
+!!          follows:
+
+!!             TRANS = 'N' or 'n'   A*x = b.
+
+!!             TRANS = 'T' or 't'   A'*x = b.
+
+!!             TRANS = 'C' or 'c'   A'*x = b.
+
+!!          Unchanged on exit.
+
+!! DIAG   - CHARACTER*1.
+!!          On entry, DIAG specifies whether or not A is unit
+!!          triangular as follows:
+
+!!             DIAG = 'U' or 'u'   A is assumed to be unit triangular.
+
+!!             DIAG = 'N' or 'n'   A is not assumed to be unit
+!!                                 triangular.
+
+!!          Unchanged on exit.
+
+!! N      - INTEGER.
+!!          On entry, N specifies the order of the matrix A.
+!!          N must be at least zero.
+!!          Unchanged on exit.
+
+!! A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
+!!          Before entry with  UPLO = 'U' or 'u', the leading n by n
+!!          upper triangular part of the array A must contain the upper
+!!          triangular matrix and the strictly lower triangular part of
+!!          A is not referenced.
+!!          Before entry with UPLO = 'L' or 'l', the leading n by n
+!!          lower triangular part of the array A must contain the lower
+!!          triangular matrix and the strictly upper triangular part of
+!!          A is not referenced.
+!!          Note that when  DIAG = 'U' or 'u', the diagonal elements of
+!!          A are not referenced either, but are assumed to be unity.
+!!          Unchanged on exit.
+
+!! LDA    - INTEGER.
+!!          On entry, LDA specifies the first dimension of A as declared
+!!          in the calling (sub) program. LDA must be at least
+!!          max( 1, n ).
+!!          Unchanged on exit.
+
+!! X      - DOUBLE PRECISION array of dimension at least
+!!          ( 1 + ( n - 1 )*abs( INCX ) ).
+!!          Before entry, the incremented array X must contain the n
+!!          element right-hand side vector b. On exit, X is overwritten
+!!          with the solution vector x.
+
+!! INCX   - INTEGER.
+!!          On entry, INCX specifies the increment for the elements of
+!!          X. INCX must not be zero.
+!!          Unchanged on exit.
+
+
+!! Level 2 Blas routine.
+
+!! -- Written on 22-October-1986.
+!!    Jack Dongarra, Argonne National Lab.
+!!    Jeremy Du Croz, Nag Central Office.
+!!    Sven Hammarling, Nag Central Office.
+!!    Richard Hanson, Sandia National Labs.
+
+
+!!    .. Parameters ..
+!     DOUBLE PRECISION   ZERO
+!     PARAMETER        ( ZERO = 0.0D+0 )
+      REAL (kind=8) ::                 ZERO
+      PARAMETER        ( ZERO = 0.0 )
+!!    .. Local Scalars ..
+!     DOUBLE PRECISION   TEMP
+      REAL (kind=8) ::                 TEMP
+      INTEGER            I, INFO, IX, J, JX, KX
+      LOGICAL            NOUNIT
+!!    .. External Functions ..
+      LOGICAL            LSAME
+      EXTERNAL           LSAME
+!!    .. External Subroutines ..
+      EXTERNAL           XERBLA
+!!    .. Intrinsic Functions ..
+      INTRINSIC          MAX
+!!    ..
+!!    .. Executable Statements ..
+
+!!    Test the input parameters.
+
+      INFO = 0
+      IF     ( .NOT.LSAME( UPLO , 'U' ).AND.   &
+               .NOT.LSAME( UPLO , 'L' )      )THEN
+         INFO = 1
+      ELSE IF( .NOT.LSAME( TRANS, 'N' ).AND.   &
+               .NOT.LSAME( TRANS, 'T' ).AND.   &
+               .NOT.LSAME( TRANS, 'C' )      )THEN
+         INFO = 2
+      ELSE IF( .NOT.LSAME( DIAG , 'U' ).AND.   &
+               .NOT.LSAME( DIAG , 'N' )      )THEN
+         INFO = 3
+      ELSE IF( N < 0 )THEN
+         INFO = 4
+      ELSE IF( LDA < MAX( 1, N ) )THEN
+         INFO = 6
+      ELSE IF( INCX == 0 )THEN
+         INFO = 8
+      END IF
+      IF( INFO /= 0 )THEN
+         CALL XERBLA( 'DTRSV ', INFO )
+         RETURN
+      END IF
+
+!!    Quick return if possible.
+
+      IF( N == 0 )   RETURN
+
+      NOUNIT = LSAME( DIAG, 'N' )
+
+!!    Set up the start point in X if the increment is not unity. This
+!!    will be  ( N - 1 )*INCX  too small for descending loops.
+
+      IF( INCX <= 0 )THEN
+         KX = 1 - ( N - 1 )*INCX
+      ELSE IF( INCX /= 1 )THEN
+         KX = 1
+      END IF
+
+!!    Start the operations. In this version the elements of A are
+!!    accessed sequentially with one pass through A.
+
+      IF( LSAME( TRANS, 'N' ) )THEN
+
+!!       Form  x := inv( A )*x.
+
+         IF( LSAME( UPLO, 'U' ) )THEN
+            IF( INCX == 1 )THEN
+               DO 20, J = N, 1, -1
+                  IF( X( J ) /= ZERO )THEN
+                     IF( NOUNIT )   X( J ) = X( J )/A( J, J )
+                     TEMP = X( J )
+                     DO 10, I = J - 1, 1, -1
+                        X( I ) = X( I ) - TEMP*A( I, J )
+   10                CONTINUE
+                  END IF
+   20          CONTINUE
+            ELSE
+               JX = KX + ( N - 1 )*INCX
+               DO 40, J = N, 1, -1
+                  IF( X( JX ) /= ZERO )THEN
+                     IF( NOUNIT )  X( JX ) = X( JX )/A( J, J )
+                     TEMP = X( JX )
+                     IX   = JX
+                     DO 30, I = J - 1, 1, -1
+                        IX      = IX      - INCX
+                        X( IX ) = X( IX ) - TEMP*A( I, J )
+   30                CONTINUE
+                  END IF
+                  JX = JX - INCX
+   40          CONTINUE
+            END IF
+         ELSE
+            IF( INCX == 1 )THEN
+               DO 60, J = 1, N
+                  IF( X( J ) /= ZERO )THEN
+                     IF( NOUNIT )   X( J ) = X( J )/A( J, J )
+                     TEMP = X( J )
+                     DO 50, I = J + 1, N
+                        X( I ) = X( I ) - TEMP*A( I, J )
+   50                CONTINUE
+                  END IF
+   60          CONTINUE
+            ELSE
+               JX = KX
+               DO 80, J = 1, N
+                  IF( X( JX ) /= ZERO )THEN
+                     IF( NOUNIT )   X( JX ) = X( JX )/A( J, J )
+                     TEMP = X( JX )
+                     IX   = JX
+                     DO 70, I = J + 1, N
+                        IX      = IX      + INCX
+                        X( IX ) = X( IX ) - TEMP*A( I, J )
+   70                CONTINUE
+                  END IF
+                  JX = JX + INCX
+   80          CONTINUE
+            END IF
+         END IF
+      ELSE
+
+!!       Form  x := inv( A' )*x.
+
+         IF( LSAME( UPLO, 'U' ) )THEN
+            IF( INCX == 1 )THEN
+               DO 100, J = 1, N
+                  TEMP = X( J )
+                  DO 90, I = 1, J - 1
+                     TEMP = TEMP - A( I, J )*X( I )
+   90             CONTINUE
+                  IF( NOUNIT )   TEMP = TEMP/A( J, J )
+                  X( J ) = TEMP
+  100          CONTINUE
+            ELSE
+               JX = KX
+               DO 120, J = 1, N
+                  TEMP = X( JX )
+                  IX   = KX
+                  DO 110, I = 1, J - 1
+                     TEMP = TEMP - A( I, J )*X( IX )
+                     IX   = IX   + INCX
+  110             CONTINUE
+                  IF( NOUNIT )   TEMP = TEMP/A( J, J )
+                  X( JX ) = TEMP
+                  JX      = JX   + INCX
+  120          CONTINUE
+            END IF
+         ELSE
+            IF( INCX == 1 )THEN
+               DO 140, J = N, 1, -1
+                  TEMP = X( J )
+                  DO 130, I = N, J + 1, -1
+                     TEMP = TEMP - A( I, J )*X( I )
+  130             CONTINUE
+                  IF( NOUNIT )    TEMP = TEMP/A( J, J )
+                  X( J ) = TEMP
+  140          CONTINUE
+            ELSE
+               KX = KX + ( N - 1 )*INCX
+               JX = KX
+               DO 160, J = N, 1, -1
+                  TEMP = X( JX )
+                  IX   = KX
+                  DO 150, I = N, J + 1, -1
+                     TEMP = TEMP - A( I, J )*X( IX )
+                     IX   = IX   - INCX
+  150             CONTINUE
+                  IF( NOUNIT )    TEMP = TEMP/A( J, J )
+                  X( JX ) = TEMP
+                  JX      = JX   - INCX
+  160          CONTINUE
+            END IF
+         END IF
+      END IF
+
+   END SUBROUTINE DTRSV
+!---------------------------------------------------------
+   SUBROUTINE DGER  ( M, N, ALPHA, X, INCX, Y, INCY, A, LDA )
+!!    .. Scalar Arguments ..
+!     DOUBLE PRECISION   ALPHA
+      REAL (kind=8) ::                 ALPHA
+      INTEGER            INCX, INCY, LDA, M, N
+!!    .. Array Arguments ..
+!     DOUBLE PRECISION   A( LDA, * ), X( * ), Y( * )
+      REAL (kind=8) ::   A( LDA, * ), X( * ), Y( * )
+!!    ..
+
+!! Purpose
+!! =======
+
+!! DGER   performs the rank 1 operation
+
+!!    A := alpha*x*y' + A,
+
+!! where alpha is a scalar, x is an m element vector, y is an n element
+!! vector and A is an m by n matrix.
+
+!! Parameters
+!! ==========
+
+!! M      - INTEGER.
+!!          On entry, M specifies the number of rows of the matrix A.
+!!          M must be at least zero.
+!!          Unchanged on exit.
+
+!! N      - INTEGER.
+!!          On entry, N specifies the number of columns of the matrix A.
+!!          N must be at least zero.
+!!          Unchanged on exit.
+
+!! ALPHA  - DOUBLE PRECISION.
+!!          On entry, ALPHA specifies the scalar alpha.
+!!          Unchanged on exit.
+
+!! X      - DOUBLE PRECISION array of dimension at least
+!!          ( 1 + ( m - 1 )*abs( INCX ) ).
+!!          Before entry, the incremented array X must contain the m
+!!          element vector x.
+!!          Unchanged on exit.
+
+!! INCX   - INTEGER.
+!!          On entry, INCX specifies the increment for the elements of
+!!          X. INCX must not be zero.
+!!          Unchanged on exit.
+
+!! Y      - DOUBLE PRECISION array of dimension at least
+!!          ( 1 + ( n - 1 )*abs( INCY ) ).
+!!          Before entry, the incremented array Y must contain the n
+!!          element vector y.
+!!          Unchanged on exit.
+
+!! INCY   - INTEGER.
+!!          On entry, INCY specifies the increment for the elements of
+!!          Y. INCY must not be zero.
+!!          Unchanged on exit.
+
+!! A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
+!!          Before entry, the leading m by n part of the array A must
+!!          contain the matrix of coefficients. On exit, A is
+!!          overwritten by the updated matrix.
+
+!! LDA    - INTEGER.
+!!          On entry, LDA specifies the first dimension of A as declared
+!!          in the calling (sub) program. LDA must be at least
+!!          max( 1, m ).
+!!          Unchanged on exit.
+
+
+!! Level 2 Blas routine.
+
+!! -- Written on 22-October-1986.
+!!    Jack Dongarra, Argonne National Lab.
+!!    Jeremy Du Croz, Nag Central Office.
+!!    Sven Hammarling, Nag Central Office.
+!!    Richard Hanson, Sandia National Labs.
+
+
+!!    .. Parameters ..
+!     DOUBLE PRECISION   ZERO
+!     PARAMETER        ( ZERO = 0.0D+0 )
+      REAL (kind=8) ::                 ZERO
+      PARAMETER        ( ZERO = 0.0 )
+!!    .. Local Scalars ..
+!     DOUBLE PRECISION   TEMP
+      REAL (kind=8) ::                 TEMP
+      INTEGER            I, INFO, IX, J, JY, KX
+!!    .. External Subroutines ..
+      EXTERNAL           XERBLA
+!!    .. Intrinsic Functions ..
+      INTRINSIC          MAX
+!!    ..
+!!    .. Executable Statements ..
+
+!!    Test the input parameters.
+
+      INFO = 0
+      IF     ( M < 0 )THEN
+         INFO = 1
+      ELSE IF( N < 0 )THEN
+         INFO = 2
+      ELSE IF( INCX == 0 )THEN
+         INFO = 5
+      ELSE IF( INCY == 0 )THEN
+         INFO = 7
+      ELSE IF( LDA < MAX( 1, M ) )THEN
+         INFO = 9
+      END IF
+      IF( INFO /= 0 )THEN
+         CALL XERBLA( 'DGER  ', INFO )
+         RETURN
+      END IF
+
+!!    Quick return if possible.
+
+      IF( ( M == 0 ).OR.( N == 0 ).OR.( ALPHA == ZERO ) )   &
+         RETURN
+
+!!    Start the operations. In this version the elements of A are
+!!    accessed sequentially with one pass through A.
+
+      IF( INCY > 0 )THEN
+         JY = 1
+      ELSE
+         JY = 1 - ( N - 1 )*INCY
+      END IF
+      IF( INCX == 1 )THEN
+         DO 20, J = 1, N
+            IF( Y( JY ) /= ZERO )THEN
+               TEMP = ALPHA*Y( JY )
+               DO 10, I = 1, M
+                  A( I, J ) = A( I, J ) + X( I )*TEMP
+   10          CONTINUE
+            END IF
+            JY = JY + INCY
+   20    CONTINUE
+      ELSE
+         IF( INCX > 0 )THEN
+            KX = 1
+         ELSE
+            KX = 1 - ( M - 1 )*INCX
+         END IF
+         DO 40, J = 1, N
+            IF( Y( JY ) /= ZERO )THEN
+               TEMP = ALPHA*Y( JY )
+               IX   = KX
+               DO 30, I = 1, M
+                  A( I, J ) = A( I, J ) + X( IX )*TEMP
+                  IX        = IX        + INCX
+   30          CONTINUE
+            END IF
+            JY = JY + INCY
+   40    CONTINUE
+      END IF
+
+   END SUBROUTINE DGER
+!---------------------------------------------------------
+   SUBROUTINE XERBLA ( SRNAME, INFO )
+!!    ..    Scalar Arguments ..
+      INTEGER            INFO
+      CHARACTER (len=6) ::    SRNAME
+!!    ..
+
+!! Purpose
+!! =======
+
+!! XERBLA  is an error handler for the Level 2 BLAS routines.
+
+!! It is called by the Level 2 BLAS routines if an input parameter is
+!! invalid.
+
+!! Installers should consider modifying the STOP statement in order to
+!! call system-specific exception-handling facilities.
+
+!! Parameters
+!! ==========
+
+!! SRNAME - CHARACTER*6.
+!!          On entry, SRNAME specifies the name of the routine which
+!!          called XERBLA.
+
+!! INFO   - INTEGER.
+!!          On entry, INFO specifies the position of the invalid
+!!          parameter in the parameter-list of the calling routine.
+
+
+!! Auxiliary routine for Level 2 Blas.
+
+!! Written on 20-July-1986.
+
+!!    .. Executable Statements ..
+
+      WRITE (*,99999) SRNAME, INFO
+
+      STOP
+
+99999 FORMAT ( ' ** On entry to ', A6, ' parameter number ', I2,   &
+               ' had an illegal value' )
+
+   END SUBROUTINE XERBLA
+!-----------------------------------------------------------
+   FUNCTION lsame( c1, c2 )
+      logical lsame
+      CHARACTER (len=*), INTENT(in) ::   c1, c2
+      IF( c1 == c2 ) THEN
+          lsame=.TRUE.
+      ELSE
+          lsame=.FALSE.
+      ENDIF
+   END FUNCTION lsame
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_mpp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_mpp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_mpp.F90	(revision 1844)
@@ -0,0 +1,5560 @@
+MODULE lib_mpp
+   !!======================================================================
+   !!                       ***  MODULE  lib_mpp  ***
+   !! Ocean numerics:  massively parallel processing librairy
+   !!=====================================================================
+#if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'     OR      MPI massively parallel processing library
+   !!   'key_mpp_shmem'         SHMEM massively parallel processing library
+   !!----------------------------------------------------------------------
+   !!   mynode
+   !!   mpparent
+   !!   mppshmem
+   !!   mpp_lnk     : generic interface (defined in lbclnk) for :
+   !!                 mpp_lnk_2d, mpp_lnk_3d
+   !!   mpp_lnk_3d_gather :  Message passing manadgement for two 3D arrays
+   !!   mpp_lnk_e   : interface defined in lbclnk
+   !!   mpplnks
+   !!   mpprecv
+   !!   mppsend
+   !!   mppscatter
+   !!   mppgather
+   !!   mpp_isl    : generic inteface  for :
+   !!                mppisl_int , mppisl_a_int , mppisl_real, mppisl_a_real
+   !!   mpp_min    : generic interface for : 
+   !!                mppmin_int , mppmin_a_int , mppmin_real, mppmin_a_real
+   !!   mpp_max    : generic interface for :
+   !!                mppmax_int , mppmax_a_int , mppmax_real, mppmax_a_real
+   !!   mpp_sum    : generic interface for :
+   !!                mppsum_int , mppsum_a_int , mppsum_real, mppsum_a_real
+   !!   mpp_minloc
+   !!   mpp_maxloc
+   !!   mppsync
+   !!   mppstop
+   !!   mppobc     : variant of mpp_lnk for open boundaries
+   !!   mpp_ini_north
+   !!   mpp_lbc_north
+   !!   mpp_lbc_north_e : variant of mpp_lbc_north for extra outer halo (nsolv=4)
+   !!----------------------------------------------------------------------
+   !! History :
+   !!        !  94 (M. Guyon, J. Escobar, M. Imbard)  Original code
+   !!        !  97  (A.M. Treguier)  SHMEM additions
+   !!        !  98  (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI
+   !!   9.0  !  03  (J.-M. Molines, G. Madec)  F90, free form
+   !!        !  04  (R. Bourdalle Badie)  isend option in mpi
+   !!        !  05  (G. Madec, S. Masson)  npolj=5,6 F-point & ice cases
+   !!        !  05  (R. Redler) Replacement of MPI_COMM_WORLD except for MPI_Abort
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce                    ! ocean space and time domain 
+   USE in_out_manager             ! I/O manager
+
+   IMPLICIT NONE
+
+   PRIVATE
+   PUBLIC  mynode, mpparent, mpp_isl, mpp_min, mpp_max, mpp_sum,  mpp_lbc_north
+   PUBLIC  mpp_lbc_north_e, mpp_minloc, mpp_maxloc, mpp_lnk_3d, mpp_lnk_2d, mpp_lnk_3d_gather, mpp_lnk_2d_e, mpplnks
+   PUBLIC  mpprecv, mppsend, mppscatter, mppgather, mppobc, mpp_ini_north, mppstop, mppsync, mpp_ini_ice, mpp_comm_free
+#if defined key_oasis3 || defined key_oasis4
+   PUBLIC  mppsize, mpprank
+#endif
+
+   !! * Interfaces
+   !! define generic interface for these routine as they are called sometimes
+   !!        with scalar arguments instead of array arguments, which causes problems
+   !!        for the compilation on AIX system as well as NEC and SGI. Ok on COMPACQ
+
+   INTERFACE mpp_isl
+      MODULE PROCEDURE mppisl_a_int, mppisl_int, mppisl_a_real, mppisl_real
+   END INTERFACE
+   INTERFACE mpp_min
+      MODULE PROCEDURE mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real
+   END INTERFACE
+   INTERFACE mpp_max
+      MODULE PROCEDURE mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real
+   END INTERFACE
+   INTERFACE mpp_sum
+      MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real
+   END INTERFACE
+   INTERFACE mpp_lbc_north
+      MODULE PROCEDURE mpp_lbc_north_3d, mpp_lbc_north_2d 
+   END INTERFACE
+  INTERFACE mpp_minloc
+     MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
+  END INTERFACE
+  INTERFACE mpp_maxloc
+     MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
+  END INTERFACE
+
+
+   !! * Share module variables
+   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.       !: mpp flag
+
+   !! The processor number is a required power of two : 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,...
+   INTEGER, PARAMETER ::   &
+      nprocmax = 2**10     ! maximun dimension
+
+#if defined key_mpp_mpi
+   !! ========================= !!
+   !!  MPI  variable definition !!
+   !! ========================= !!
+!$AGRIF_DO_NOT_TREAT
+#  include <mpif.h>
+!$AGRIF_END_DO_NOT_TREAT
+
+   INTEGER ::   &
+      mppsize,  &  ! number of process
+      mpprank,  &  ! process number  [ 0 - size-1 ]
+      mpi_comm_opa ! opa local communicator
+
+   ! variables used in case of sea-ice
+   INTEGER, PUBLIC ::  &       !
+      ngrp_ice,        &       ! group ID for the ice processors (to compute rheology)
+      ncomm_ice,       &       ! communicator made by the processors with sea-ice
+      ndim_rank_ice,   &       ! number of 'ice' processors
+      n_ice_root               ! number (in the comm_ice) of proc 0 in the ice comm
+   INTEGER, DIMENSION(:), ALLOCATABLE ::   &
+      nrank_ice            ! dimension ndim_rank_north, number of the procs belonging to ncomm_north
+   ! variables used in case of north fold condition in mpp_mpi with jpni > 1
+   INTEGER ::      &       !
+      ngrp_world,  &       ! group ID for the world processors
+      ngrp_north,  &       ! group ID for the northern processors (to be fold)
+      ncomm_north, &       ! communicator made by the processors belonging to ngrp_north
+      ndim_rank_north, &   ! number of 'sea' processor in the northern line (can be /= jpni !)
+      njmppmax             ! value of njmpp for the processors of the northern line
+   INTEGER ::      &       !
+      north_root           ! number (in the comm_opa) of proc 0 in the northern comm
+   INTEGER, DIMENSION(:), ALLOCATABLE ::   &
+      nrank_north          ! dimension ndim_rank_north, number of the procs belonging to ncomm_north
+   CHARACTER (len=1) ::  &
+      c_mpi_send = 'S'     ! type od mpi send/recieve (S=standard, B=bsend, I=isend)
+   LOGICAL  ::           &
+      l_isend = .FALSE.    ! isend use indicator (T if c_mpi_send='I')
+   INTEGER ::            & ! size of the buffer in case of mpi_bsend 
+      nn_buffer = 0
+   REAL(kind=wp), ALLOCATABLE, DIMENSION(:) :: tampon  ! buffer in case of bsend
+
+#elif defined key_mpp_shmem
+   !! ========================= !!
+   !! SHMEM variable definition !!
+   !! ========================= !!
+#  include  <fpvm3.h>
+#  include <mpp/shmem.fh>
+
+   CHARACTER (len=80), PARAMETER ::   simfile    = 'pvm3_ndim'   ! file name
+   CHARACTER (len=47), PARAMETER ::   executable = 'opa'         ! executable name
+   CHARACTER, PARAMETER ::            opaall     = ""            ! group name (old def opaall*(*))
+
+   INTEGER, PARAMETER ::   & !! SHMEM control print
+      mynode_print   = 0,  &  ! flag for print, mynode   routine
+      mpprecv_print  = 0,  &  ! flag for print, mpprecv  routine
+      mppsend_print  = 0,  &  ! flag for print, mppsend  routine
+      mppsync_print  = 0,  &  ! flag for print, mppsync  routine
+      mppsum_print   = 0,  &  ! flag for print, mpp_sum  routine
+      mppisl_print   = 0,  &  ! flag for print, mpp_isl  routine
+      mppmin_print   = 0,  &  ! flag for print, mpp_min  routine
+      mppmax_print   = 0,  &  ! flag for print, mpp_max  routine
+      mpparent_print = 0      ! flag for print, mpparent routine
+
+   INTEGER, PARAMETER ::   & !! Variable definition
+      jpvmint = 21            ! ???
+
+   INTEGER, PARAMETER ::   & !! Maximum  dimension of array to sum on the processors
+      jpmsec   = 50000,    &  ! ???
+      jpmpplat =    30,    &  ! ???
+      jpmppsum = MAX( jpisl*jpisl, jpmpplat*jpk, jpmsec )   ! ???
+
+   INTEGER ::   &
+      npvm_ipas ,  &  ! pvm initialization flag
+      npvm_mytid,  &  ! pvm tid
+      npvm_me   ,  &  ! node number [ 0 - nproc-1 ]
+      npvm_nproc,  &  ! real number of nodes
+      npvm_inum       ! ???
+   INTEGER, DIMENSION(0:nprocmax-1) ::   &
+      npvm_tids       ! tids array [ 0 - nproc-1 ]
+
+   INTEGER ::   &
+      nt3d_ipas ,  &  ! pvm initialization flag
+      nt3d_mytid,  &  ! pvm tid
+      nt3d_me   ,  &  ! node number [ 0 - nproc-1 ]
+      nt3d_nproc      ! real number of nodes
+   INTEGER, DIMENSION(0:nprocmax-1) ::   &
+      nt3d_tids       ! tids array [ 0 - nproc-1 ]
+
+   !! real sum reduction
+   INTEGER, DIMENSION(SHMEM_REDUCE_SYNC_SIZE) ::   &
+       nrs1sync_shmem,   &  ! 
+       nrs2sync_shmem
+   REAL(wp), DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       wrs1wrk_shmem,    &  !
+       wrs2wrk_shmem        !
+   REAL(wp), DIMENSION(jpmppsum) ::   &
+       wrstab_shmem         !
+
+   !! minimum and maximum reduction
+   INTEGER, DIMENSION(SHMEM_REDUCE_SYNC_SIZE) ::   &
+       ni1sync_shmem,    &  ! 
+       ni2sync_shmem        ! 
+   REAL(wp), DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       wi1wrk_shmem,     &  !
+       wi2wrk_shmem
+   REAL(wp), DIMENSION(jpmppsum) ::   &
+       wintab_shmem,     &  ! 
+       wi1tab_shmem,     &  ! 
+       wi2tab_shmem         ! 
+       
+       !! value not equal zero for barotropic stream function around islands
+   INTEGER, DIMENSION(SHMEM_REDUCE_SYNC_SIZE) ::   &
+       ni11sync_shmem,   &  !
+       ni12sync_shmem,   &  !
+       ni21sync_shmem,   &  !
+       ni22sync_shmem       !
+   REAL(wp), DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       wi11wrk_shmem,    &  ! 
+       wi12wrk_shmem,    &  !
+       wi21wrk_shmem,    &  !
+       wi22wrk_shmem        !
+   REAL(wp), DIMENSION(jpmppsum) ::   &
+       wiltab_shmem ,    &  !
+       wi11tab_shmem,    &  !
+       wi12tab_shmem,    &  ! 
+       wi21tab_shmem,    &  ! 
+       wi22tab_shmem
+
+   INTEGER, DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       ni11wrk_shmem,    &  !
+       ni12wrk_shmem,    &  !
+       ni21wrk_shmem,    &  !
+       ni22wrk_shmem        !
+   INTEGER, DIMENSION(jpmppsum) ::   &
+       niitab_shmem ,    &  !
+       ni11tab_shmem,    &  !
+       ni12tab_shmem        !
+   INTEGER, DIMENSION(SHMEM_REDUCE_SYNC_SIZE) ::   &
+       nis1sync_shmem,   &  !
+       nis2sync_shmem       !
+   INTEGER, DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       nis1wrk_shmem,    &  ! 
+       nis2wrk_shmem        !
+   INTEGER, DIMENSION(jpmppsum) ::   &
+       nistab_shmem
+
+   !! integer sum reduction
+   INTEGER, DIMENSION(SHMEM_REDUCE_SYNC_SIZE) ::   &
+       nil1sync_shmem,   &  !
+       nil2sync_shmem       !
+   INTEGER, DIMENSION( MAX( SHMEM_REDUCE_MIN_WRKDATA_SIZE, jpmppsum/2+1 ) ) ::   &
+       nil1wrk_shmem,    &  !
+       nil2wrk_shmem        !
+   INTEGER, DIMENSION(jpmppsum) ::   &
+       niltab_shmem
+#endif
+
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2,2) ::   &
+       t4ns, t4sn  ! 3d message passing arrays north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,jpk,2,2) ::   &
+       t4ew, t4we  ! 3d message passing arrays east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2,2) ::   &
+       t4p1, t4p2  ! 3d message passing arrays north fold
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2) ::   &
+       t3ns, t3sn  ! 3d message passing arrays north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,jpk,2) ::   &
+       t3ew, t3we  ! 3d message passing arrays east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2) ::   &
+       t3p1, t3p2  ! 3d message passing arrays north fold
+   REAL(wp), DIMENSION(jpi,jprecj,2) ::   &
+       t2ns, t2sn  ! 2d message passing arrays north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,2) ::   &
+       t2ew, t2we  ! 2d message passing arrays east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,2) ::   &
+       t2p1, t2p2  ! 2d message passing arrays north fold
+   REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,jprecj+jpr2dj,2) ::   &
+       tr2ns, tr2sn  ! 2d message passing arrays north-south & south-north including extra outer halo
+   REAL(wp), DIMENSION(1-jpr2dj:jpj+jpr2dj,jpreci+jpr2di,2) ::   &
+       tr2ew, tr2we  ! 2d message passing arrays east-west & west-east including extra outer halo
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------
+
+CONTAINS
+
+   FUNCTION mynode(localComm)
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mynode  ***
+      !!                    
+      !! ** Purpose :   Find processor unit
+      !!
+      !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+      INTEGER ::   mynode, ierr, code
+      LOGICAL ::   mpi_was_called
+      INTEGER,OPTIONAL ::   localComm
+      NAMELIST/nammpp/ c_mpi_send, nn_buffer
+      !!----------------------------------------------------------------------
+
+      WRITE(numout,*)
+      WRITE(numout,*) 'mynode : mpi initialisation'
+      WRITE(numout,*) '~~~~~~ '
+      WRITE(numout,*)
+
+      ! Namelist namrun : parameters of the run
+      REWIND( numnam )
+      READ  ( numnam, nammpp )
+
+      WRITE(numout,*) '        Namelist nammpp'
+      WRITE(numout,*) '           mpi send type            c_mpi_send = ', c_mpi_send
+
+#if defined key_agrif
+      IF( Agrif_Root() ) THEN
+#endif
+!!bug RB : should be clean to use Agrif in coupled mode
+#if ! defined key_agrif
+         CALL mpi_initialized ( mpi_was_called, code )
+         IF( code /= MPI_SUCCESS ) THEN
+            CALL ctl_stop( ' lib_mpp: Error in routine mpi_initialized' )
+            CALL mpi_abort( mpi_comm_world, code, ierr )
+         ENDIF
+
+         IF( PRESENT(localComm) .and. mpi_was_called ) THEN
+            mpi_comm_opa = localComm
+            SELECT CASE ( c_mpi_send )
+            CASE ( 'S' )                ! Standard mpi send (blocking)
+               WRITE(numout,*) '           Standard blocking mpi send (send)'
+            CASE ( 'B' )                ! Buffer mpi send (blocking)
+               WRITE(numout,*) '           Buffer blocking mpi send (bsend)'
+               CALL mpi_init_opa( ierr ) 
+            CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+               WRITE(numout,*) '           Immediate non-blocking send (isend)'
+               l_isend = .TRUE.
+            CASE DEFAULT
+               WRITE(numout,cform_err)
+               WRITE(numout,*) '           bad value for c_mpi_send = ', c_mpi_send
+               nstop = nstop + 1
+            END SELECT
+         ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN
+            WRITE(numout,*) ' lib_mpp: You cannot provide a local communicator '
+            WRITE(numout,*) '          without calling MPI_Init before ! '
+         ELSE
+#endif
+            SELECT CASE ( c_mpi_send )
+            CASE ( 'S' )                ! Standard mpi send (blocking)
+               WRITE(numout,*) '           Standard blocking mpi send (send)'
+               CALL mpi_init( ierr )
+            CASE ( 'B' )                ! Buffer mpi send (blocking)
+               WRITE(numout,*) '           Buffer blocking mpi send (bsend)'
+               CALL mpi_init_opa( ierr )
+            CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+               WRITE(numout,*) '           Immediate non-blocking send (isend)'
+               l_isend = .TRUE.
+               CALL mpi_init( ierr )
+            CASE DEFAULT
+               WRITE(ctmp1,*) '           bad value for c_mpi_send = ', c_mpi_send
+               CALL ctl_stop( ctmp1 )
+            END SELECT
+
+#if ! defined key_agrif
+            CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code)
+            IF( code /= MPI_SUCCESS ) THEN
+               CALL ctl_stop( ' lib_mpp: Error in routine mpi_comm_dup' )
+               CALL mpi_abort( mpi_comm_world, code, ierr )
+            ENDIF
+            !
+         ENDIF
+#endif
+#if defined key_agrif
+      ELSE
+         SELECT CASE ( c_mpi_send )
+         CASE ( 'S' )                ! Standard mpi send (blocking)
+            WRITE(numout,*) '           Standard blocking mpi send (send)'
+         CASE ( 'B' )                ! Buffer mpi send (blocking)
+            WRITE(numout,*) '           Buffer blocking mpi send (bsend)'
+         CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+            WRITE(numout,*) '           Immediate non-blocking send (isend)'
+            l_isend = .TRUE.
+         CASE DEFAULT
+            WRITE(numout,cform_err)
+            WRITE(numout,*) '           bad value for c_mpi_send = ', c_mpi_send
+            nstop = nstop + 1
+         END SELECT
+      ENDIF
+
+      mpi_comm_opa = mpi_comm_world
+#endif
+        CALL mpi_comm_rank( mpi_comm_opa, mpprank, ierr )
+        CALL mpi_comm_size( mpi_comm_opa, mppsize, ierr )
+      mynode = mpprank
+#else
+      !! * Local variables   (SHMEM version)
+      INTEGER ::   mynode
+      INTEGER ::   &
+           imypid, imyhost, ji, info, iparent_tid
+      !!----------------------------------------------------------------------
+
+      IF( npvm_ipas /= nprocmax ) THEN
+         !         ---   first passage in mynode
+         !         -------------
+         !         enroll in pvm
+         !         -------------
+         CALL pvmfmytid( npvm_mytid )
+         IF( mynode_print /= 0 ) THEN
+            WRITE(numout,*) 'mynode, npvm_ipas =', npvm_ipas, ' nprocmax=', nprocmax
+            WRITE(numout,*) 'mynode, npvm_mytid=', npvm_mytid, ' after pvmfmytid'
+         ENDIF
+
+         !         ---------------------------------------------------------------
+         !         find out IF i am parent or child spawned processes have parents
+         !         ---------------------------------------------------------------
+         CALL mpparent( iparent_tid )
+         IF( mynode_print /= 0 ) THEN
+            WRITE(numout,*) 'mynode, npvm_mytid=', npvm_mytid,   &
+               &            ' after mpparent, npvm_tids(0) = ',   &
+               &            npvm_tids(0), ' iparent_tid=', iparent_tid
+         ENDIF
+         IF( iparent_tid < 0 )  THEN
+            WRITE(numout,*) 'mynode, npvm_mytid=', npvm_mytid,   &
+               &            ' after mpparent, npvm_tids(0) = ',   &
+               &            npvm_tids(0), ' iparent_tid=', iparent_tid
+            npvm_tids(0) = npvm_mytid
+            npvm_me = 0
+            IF( jpnij > nprocmax ) THEN
+               WRITE(ctmp1,*) 'npvm_mytid=', npvm_mytid, ' too great'
+               CALL ctl_stop( ctmp1 )
+
+            ELSE
+               npvm_nproc = jpnij
+            ENDIF
+
+            ! -------------------------
+            ! start up copies of myself
+            ! -------------------------
+            IF( npvm_nproc > 1 ) THEN
+               DO ji = 1, npvm_nproc-1
+                  npvm_tids(ji) = nt3d_tids(ji)
+               END DO
+               info=npvm_nproc-1
+  
+               IF( mynode_print /= 0 ) THEN
+                  WRITE(numout,*) 'mynode, npvm_mytid=',npvm_mytid,   &
+                     &            ' maitre=',executable,' info=', info   &
+                     &            ,' npvm_nproc=',npvm_nproc
+                  WRITE(numout,*) 'mynode, npvm_mytid=',npvm_mytid,   &
+                     &            ' npvm_tids ',(npvm_tids(ji),ji=0,npvm_nproc-1)
+               ENDIF
+
+               ! ---------------------------
+               ! multicast tids array to children
+               ! ---------------------------
+               CALL pvmfinitsend( pvmdefault, info )
+               CALL pvmfpack ( jpvmint, npvm_nproc, 1         , 1, info )
+               CALL pvmfpack ( jpvmint, npvm_tids , npvm_nproc, 1, info )
+               CALL pvmfmcast( npvm_nproc-1, npvm_tids(1), 10, info )
+            ENDIF
+         ELSE
+
+            ! ---------------------------------
+            ! receive the tids array and set me
+            ! ---------------------------------
+            IF( mynode_print /= 0 )   WRITE(numout,*) 'mynode, npvm_mytid=',npvm_mytid, ' pvmfrecv'
+            CALL pvmfrecv( iparent_tid, 10, info )
+            IF( mynode_print /= 0 )   WRITE(numout,*) 'mynode, npvm_mytid=',npvm_mytid, " fin pvmfrecv"
+            CALL pvmfunpack( jpvmint, npvm_nproc, 1         , 1, info )
+            CALL pvmfunpack( jpvmint, npvm_tids , npvm_nproc, 1, info )
+            IF( mynode_print /= 0 ) THEN
+               WRITE(numout,*) 'mynode, npvm_mytid=',npvm_mytid,   &
+                  &            ' esclave=', executable,' info=', info,' npvm_nproc=',npvm_nproc
+               WRITE(numout,*) 'mynode, npvm_mytid=', npvm_mytid,   &
+                  &            'npvm_tids', ( npvm_tids(ji), ji = 0, npvm_nproc-1 )
+            ENDIF
+            DO ji = 0, npvm_nproc-1
+               IF( npvm_mytid == npvm_tids(ji) ) npvm_me = ji
+            END DO
+         ENDIF
+
+         ! ------------------------------------------------------------
+         ! all nproc tasks are equal now
+         ! and can address each other by tids(0) thru tids(nproc-1)
+         ! for each process me => process number [0-(nproc-1)]
+         ! ------------------------------------------------------------
+         CALL pvmfjoingroup ( "bidon", info )
+         CALL pvmfbarrier   ( "bidon", npvm_nproc, info )
+         DO ji = 0, npvm_nproc-1
+            IF( ji == npvm_me ) THEN
+               CALL pvmfjoingroup ( opaall, npvm_inum )
+               IF( npvm_inum /= npvm_me )   WRITE(numout,*) 'mynode not arrived in the good order for opaall'
+            ENDIF
+            CALL pvmfbarrier( "bidon", npvm_nproc, info )
+         END DO
+         CALL pvmfbarrier( opaall, npvm_nproc, info )
+  
+      ELSE
+         ! ---   other passage in mynode
+      ENDIF
+ 
+      npvm_ipas = nprocmax
+      mynode    = npvm_me
+      imypid    = npvm_mytid
+      imyhost   = npvm_tids(0)
+      IF( mynode_print /= 0 ) THEN
+         WRITE(numout,*)'mynode: npvm_mytid=', npvm_mytid, ' npvm_me=', npvm_me,   &
+            &           ' npvm_nproc=', npvm_nproc , ' npvm_ipas=', npvm_ipas
+      ENDIF
+#endif
+   END FUNCTION mynode
+
+
+   SUBROUTINE mpparent( kparent_tid )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpparent  ***
+      !!
+      !! ** Purpose :   use an pvmfparent routine for T3E (key_mpp_shmem)
+      !!              or  only return -1 (key_mpp_mpi)
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(inout) ::   kparent_tid      ! ???
+  
+#if defined key_mpp_mpi
+      ! MPI version : retour -1
+
+      kparent_tid = -1
+
+#else
+      !! * Local variables   (SHMEN onto T3E version)
+      INTEGER ::   &
+           it3d_my_pe, LEADZ, ji, info
+  
+      CALL pvmfmytid( nt3d_mytid )
+      CALL pvmfgetpe( nt3d_mytid, it3d_my_pe )
+      IF( mpparent_print /= 0 ) THEN
+         WRITE(numout,*) 'mpparent: nt3d_mytid= ', nt3d_mytid ,' it3d_my_pe=',it3d_my_pe
+      ENDIF
+      IF( it3d_my_pe == 0 ) THEN
+         !-----------------------------------------------------------------!
+         !     process = 0 => receive other tids                           !
+         !-----------------------------------------------------------------!
+         kparent_tid = -1
+         IF(mpparent_print /= 0 ) THEN
+            WRITE(numout,*) 'mpparent, nt3d_mytid=',nt3d_mytid ,' kparent_tid=',kparent_tid
+         ENDIF
+         !          --- END receive dimension ---
+         IF( jpnij > nprocmax ) THEN
+            WRITE(ctmp1,*) 'mytid=',nt3d_mytid,' too great'
+            CALL ctl_stop( ctmp1 )
+         ELSE
+            nt3d_nproc =  jpnij
+         ENDIF
+         IF( mpparent_print /= 0 ) THEN
+            WRITE(numout,*) 'mpparent, nt3d_mytid=', nt3d_mytid , ' nt3d_nproc=', nt3d_nproc
+         ENDIF
+         !-------- receive tids from others process --------
+         DO ji = 1, nt3d_nproc-1
+            CALL pvmfrecv( ji , 100, info )
+            CALL pvmfunpack( jpvmint, nt3d_tids(ji), 1, 1, info )
+            IF( mpparent_print /= 0 ) THEN
+               WRITE(numout,*) 'mpparent, nt3d_mytid=', nt3d_mytid , ' receive=', nt3d_tids(ji), ' from = ', ji
+            ENDIF
+         END DO
+         nt3d_tids(0) = nt3d_mytid
+         IF( mpparent_print /= 0 ) THEN
+            WRITE(numout,*) 'mpparent, nt3d_mytid=', nt3d_mytid , ' nt3d_tids(ji) =', (nt3d_tids(ji),   &
+                 ji = 0, nt3d_nproc-1 )
+            WRITE(numout,*) 'mpparent, nt3d_mytid=', nt3d_mytid , ' kparent_tid=', kparent_tid
+         ENDIF
+
+      ELSE
+         !!----------------------------------------------------------------!
+         !     process <> 0 => send  other tids                            !
+         !!----------------------------------------------------------------!
+         kparent_tid = 0
+         CALL pvmfinitsend( pvmdataraw, info )
+         CALL pvmfpack( jpvmint, nt3d_mytid, 1, 1, info )
+         CALL pvmfsend( kparent_tid, 100, info )
+      ENDIF
+#endif
+
+   END SUBROUTINE mpparent
+
+#if defined key_mpp_shmem
+
+   SUBROUTINE mppshmem
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppshmem  ***
+      !!
+      !! ** Purpose :   SHMEM ROUTINE
+      !!
+      !!----------------------------------------------------------------------
+      nrs1sync_shmem = SHMEM_SYNC_VALUE
+      nrs2sync_shmem = SHMEM_SYNC_VALUE
+      nis1sync_shmem = SHMEM_SYNC_VALUE
+      nis2sync_shmem = SHMEM_SYNC_VALUE
+      nil1sync_shmem = SHMEM_SYNC_VALUE
+      nil2sync_shmem = SHMEM_SYNC_VALUE
+      ni11sync_shmem = SHMEM_SYNC_VALUE
+      ni12sync_shmem = SHMEM_SYNC_VALUE
+      ni21sync_shmem = SHMEM_SYNC_VALUE
+      ni22sync_shmem = SHMEM_SYNC_VALUE
+      CALL barrier()
+  
+   END SUBROUTINE mppshmem
+
+#endif
+
+   SUBROUTINE mpp_lnk_3d( ptab, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_3d  ***
+      !!
+      !! ** Purpose :   Message passing manadgement
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !! ** Action  :   ptab with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type       ! define the nature of ptab array grid-points
+         !             ! = T , U , V , F , W points
+         !             ! = S : T-point, north fold treatment ???
+         !             ! = G : F-point, north fold treatment ???
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   = -1. , the sign is changed if north fold boundary
+         !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         ptab          ! 3D array on which the boundary condition is applied
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only 
+      REAL(wp)        , INTENT(in   ), OPTIONAL           ::   pval      ! background value (used at closed boundaries)
+
+      !! * Local variables
+      INTEGER ::   ji, jj, jk, jl                        ! dummy loop indices
+      INTEGER ::   imigr, iihom, ijhom, iloc, ijt, iju   ! temporary integers
+      INTEGER ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER ::   ml_stat(MPI_STATUS_SIZE)     ! for key_mpi_isend
+      REAL(wp) ::   zland
+      !!----------------------------------------------------------------------
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+
+      IF( PRESENT( pval ) ) THEN      ! set land value (zero by default)
+         zland = pval
+      ELSE
+         zland = 0.e0
+      ENDIF
+
+      IF( PRESENT( cd_mpp ) ) THEN
+         DO jj = nlcj+1, jpj   ! only fill extra allows last line
+            ptab(1:nlci, jj, :) = ptab(1:nlci, nlej, :)
+         END DO
+         DO ji = nlci+1, jpi   ! only fill extra allows last column
+            ptab(ji    , : , :) = ptab(nlei  , :   , :)
+         END DO
+      ELSE      
+
+         !                                        ! East-West boundaries
+         !                                        ! ====================
+         IF( nbondi == 2 .AND.   &      ! Cyclic east-west
+            &   (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+            ptab( 1 ,:,:) = ptab(jpim1,:,:)
+            ptab(jpi,:,:) = ptab(  2  ,:,:)
+
+         ELSE                           ! closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T', 'U', 'V', 'W' )
+               ptab(     1       :jpreci,:,:) = zland
+               ptab(nlci-jpreci+1:jpi   ,:,:) = zland
+            CASE ( 'F' )
+               ptab(nlci-jpreci+1:jpi   ,:,:) = zland
+            END SELECT 
+         ENDIF
+
+         !                                        ! North-South boundaries
+         !                                        ! ======================
+         SELECT CASE ( cd_type )
+         CASE ( 'T', 'U', 'V', 'W' )
+            ptab(:,     1       :jprecj,:) = zland
+            ptab(:,nlcj-jprecj+1:jpj   ,:) = zland
+         CASE ( 'F' )
+            ptab(:,nlcj-jprecj+1:jpj   ,:) = zland
+         END SELECT
+     
+      ENDIF
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+
+      ! 2.1 Read Dirichlet lateral conditions
+
+      SELECT CASE ( nbondi )
+      CASE ( -1, 0, 1 )    ! all exept 2 
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t3ew(:,jl,:,1) = ptab(jpreci+jl,:,:)
+            t3we(:,jl,:,1) = ptab(iihom +jl,:,:)
+         END DO
+      END SELECT
+
+      ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jpreci * jpj * jpk
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL shmem_put( t3we(1,1,1,2), t3we(1,1,1,1), imigr, noea )
+      CASE ( 0 )
+         CALL shmem_put( t3ew(1,1,1,2), t3ew(1,1,1,1), imigr, nowe )
+         CALL shmem_put( t3we(1,1,1,2), t3we(1,1,1,1), imigr, noea )
+      CASE ( 1 )
+         CALL shmem_put( t3ew(1,1,1,2), t3ew(1,1,1,1), imigr, nowe )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+
+      imigr = jpreci * jpj * jpk
+
+      SELECT CASE ( nbondi ) 
+      CASE ( -1 )
+         CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+         CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+#endif
+
+      ! 2.3 Write Dirichlet lateral conditions
+
+      iihom = nlci-jpreci
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jpreci
+            ptab(jl      ,:,:) = t3we(:,jl,:,2)
+            ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            ptab(jl      ,:,:) = t3we(:,jl,:,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+
+      ! 3.1 Read Dirichlet lateral conditions
+
+      IF( nbondj /= 2 ) THEN
+         ijhom = nlcj-nrecj
+         DO jl = 1, jprecj
+            t3sn(:,jl,:,1) = ptab(:,ijhom +jl,:)
+            t3ns(:,jl,:,1) = ptab(:,jprecj+jl,:)
+         END DO
+      ENDIF
+
+      ! 3.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jprecj * jpi * jpk
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL shmem_put( t3sn(1,1,1,2), t3sn(1,1,1,1), imigr, nono )
+      CASE ( 0 )
+         CALL shmem_put( t3ns(1,1,1,2), t3ns(1,1,1,1), imigr, noso )
+         CALL shmem_put( t3sn(1,1,1,2), t3sn(1,1,1,1), imigr, nono )
+      CASE ( 1 )
+         CALL shmem_put( t3ns(1,1,1,2), t3ns(1,1,1,1), imigr, noso )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+  
+      imigr=jprecj*jpi*jpk
+
+      SELECT CASE ( nbondj )     
+      CASE ( -1 )
+         CALL mppsend( 4, t3sn(1,1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t3ns(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t3ns(1,1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t3sn(1,1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t3ns(1,1,1,2), imigr )
+         CALL mpprecv( 4, t3sn(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 ) 
+         CALL mppsend( 3, t3ns(1,1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t3sn(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+
+#endif
+
+      ! 3.3 Write Dirichlet lateral conditions
+
+      ijhom = nlcj-jprecj
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            ptab(:,ijhom+jl,:) = t3ns(:,jl,:,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jprecj
+            ptab(:,jl      ,:) = t3sn(:,jl,:,2)
+            ptab(:,ijhom+jl,:) = t3ns(:,jl,:,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jprecj
+            ptab(:,jl,:) = t3sn(:,jl,:,2)
+         END DO
+      END SELECT
+
+
+      ! 4. north fold treatment
+      ! -----------------------
+
+      IF (PRESENT(cd_mpp)) THEN
+         ! No north fold treatment (it is assumed to be already OK)
+     
+      ELSE      
+
+      ! 4.1 treatment without exchange (jpni odd)
+      !     T-point pivot  
+
+      SELECT CASE ( jpni )
+
+      CASE ( 1 )  ! only one proc along I, no mpp exchange
+       
+         SELECT CASE ( npolj )
+  
+         CASE ( 3 , 4 )    ! T pivot
+            iloc = jpiglo - 2 * ( nimpp - 1 )
+
+            SELECT CASE ( cd_type )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab(ji,nlcj,jk) = psgn * ptab(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+2
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab(ji,nlcj,jk) = psgn * ptab(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2, nlci-1
+                     iju=iloc-ji+1
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(ijt,nlcj-2,jk)
+                     ptab(ji,nlcj  ,jk) = psgn * ptab(ijt,nlcj-3,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(iju,nlcj-2,jk)
+                     ptab(ji,nlcj  ,jk) = psgn * ptab(iju,nlcj-3,jk)
+                  END DO
+               END DO
+  
+          END SELECT
+       
+         CASE ( 5 , 6 ) ! F pivot
+            iloc=jpiglo-2*(nimpp-1)
+  
+            SELECT CASE ( cd_type )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab(ji,nlcj,jk) = psgn * ptab(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab(ji,nlcj,jk) = psgn * ptab(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab(ji,nlcj  ,jk) = psgn * ptab(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+1
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab(ji,nlcj,jk) = psgn * ptab(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci-1
+                     iju=iloc-ji
+                     ptab(ji,nlcj-1,jk) = psgn * ptab(iju,nlcj-1,jk)
+                  END DO
+               END DO
+            END SELECT  ! cd_type
+
+         END SELECT     !  npolj
+  
+      CASE DEFAULT ! more than 1 proc along I
+         IF ( npolj /= 0 ) CALL mpp_lbc_north (ptab, cd_type, psgn)  ! only for northern procs.
+
+      END SELECT ! jpni 
+
+      ENDIF
+      
+
+      ! 5. East and west directions exchange
+      ! ------------------------------------
+
+      SELECT CASE ( npolj )
+
+      CASE ( 3, 4, 5, 6 )
+
+         ! 5.1 Read Dirichlet lateral conditions
+
+         SELECT CASE ( nbondi )
+
+         CASE ( -1, 0, 1 )
+            iihom = nlci-nreci
+            DO jl = 1, jpreci
+               t3ew(:,jl,:,1) = ptab(jpreci+jl,:,:)
+               t3we(:,jl,:,1) = ptab(iihom +jl,:,:)
+            END DO
+
+         END SELECT
+
+         ! 5.2 Migrations
+
+#if defined key_mpp_shmem
+         !! SHMEM version
+
+         imigr = jpreci * jpj * jpk
+
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL shmem_put( t3we(1,1,1,2), t3we(1,1,1,1), imigr, noea )
+         CASE ( 0 )
+            CALL shmem_put( t3ew(1,1,1,2), t3ew(1,1,1,1), imigr, nowe )
+            CALL shmem_put( t3we(1,1,1,2), t3we(1,1,1,1), imigr, noea )
+         CASE ( 1 )
+            CALL shmem_put( t3ew(1,1,1,2), t3ew(1,1,1,1), imigr, nowe )
+         END SELECT
+
+         CALL barrier()
+         CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+         !! MPI version
+
+         imigr=jpreci*jpj*jpk
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req1 )
+            CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CASE ( 0 )
+            CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+            CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req2 )
+            CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+            CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+            IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+         CASE ( 1 )
+            CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+            CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         END SELECT
+#endif
+
+         ! 5.3 Write Dirichlet lateral conditions
+
+         iihom = nlci-jpreci
+
+         SELECT CASE ( nbondi)
+         CASE ( -1 )
+            DO jl = 1, jpreci
+               ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+            END DO
+         CASE ( 0 ) 
+            DO jl = 1, jpreci
+               ptab(jl      ,:,:) = t3we(:,jl,:,2)
+               ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+            END DO
+         CASE ( 1 )
+            DO jl = 1, jpreci
+               ptab(jl      ,:,:) = t3we(:,jl,:,2)
+            END DO
+         END SELECT
+
+      END SELECT    ! npolj 
+
+   END SUBROUTINE mpp_lnk_3d
+
+
+   SUBROUTINE mpp_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_2d  ***
+      !!                  
+      !! ** Purpose :   Message passing manadgement for 2d array
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type       ! define the nature of pt2d array grid-points
+         !             !  = T , U , V , F , W 
+         !             !  = S : T-point, north fold treatment
+         !             !  = G : F-point, north fold treatment
+         !             !  = I : sea-ice velocity at F-point with index shift
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   = -1. , the sign is changed if north fold boundary
+         !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only 
+      REAL(wp)        , INTENT(in   ), OPTIONAL           ::   pval      ! background value (used at closed boundaries)
+
+      !! * Local variables
+      INTEGER  ::   ji, jj, jl      ! dummy loop indices
+      INTEGER  ::   &
+         imigr, iihom, ijhom,    &  ! temporary integers
+         iloc, ijt, iju             !    "          "
+      INTEGER  ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER  ::   ml_stat(MPI_STATUS_SIZE)     ! for key_mpi_isend
+      REAL(wp) ::   zland
+      !!----------------------------------------------------------------------
+
+      IF( PRESENT( pval ) ) THEN      ! set land value (zero by default)
+         zland = pval
+      ELSE
+         zland = 0.e0
+      ENDIF
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      IF (PRESENT(cd_mpp)) THEN
+         DO jj = nlcj+1, jpj   ! only fill extra allows last line
+            pt2d(1:nlci, jj) = pt2d(1:nlci, nlej)
+         END DO
+         DO ji = nlci+1, jpi   ! only fill extra allows last column
+            pt2d(ji    , : ) = pt2d(nlei  , :   )
+         END DO     
+      ELSE      
+
+         !                                        ! East-West boundaries
+         !                                        ! ====================
+         IF( nbondi == 2 .AND.   &      ! Cyclic east-west
+            &    (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+            pt2d( 1 ,:) = pt2d(jpim1,:)
+            pt2d(jpi,:) = pt2d(  2  ,:)
+
+         ELSE                           ! ... closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T', 'U', 'V', 'W' , 'I' )
+               pt2d(     1       :jpreci,:) = zland
+               pt2d(nlci-jpreci+1:jpi   ,:) = zland
+            CASE ( 'F' )
+               pt2d(nlci-jpreci+1:jpi   ,:) = zland
+            END SELECT
+         ENDIF
+
+         !                                        ! North-South boundaries
+         !                                        ! ======================
+         SELECT CASE ( cd_type )
+         CASE ( 'T', 'U', 'V', 'W' , 'I' )
+            pt2d(:,     1       :jprecj) = zland
+            pt2d(:,nlcj-jprecj+1:jpj   ) = zland
+         CASE ( 'F' )
+            pt2d(:,nlcj-jprecj+1:jpj   ) = zland
+         END SELECT
+
+      ENDIF
+
+
+      ! 2. East and west directions
+      ! ---------------------------
+
+      ! 2.1 Read Dirichlet lateral conditions
+
+      SELECT CASE ( nbondi )
+      CASE ( -1, 0, 1 )    ! all except 2
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t2ew(:,jl,1) = pt2d(jpreci+jl,:)
+            t2we(:,jl,1) = pt2d(iihom +jl,:)
+         END DO
+      END SELECT
+
+      ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jpreci * jpj
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr, noea )
+      CASE ( 0 )
+         CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr, nowe )
+         CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr, noea )
+      CASE ( 1 )
+         CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr, nowe )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * MPI version
+
+      imigr = jpreci * jpj
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t2ew(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t2ew(1,1,2), imigr )
+         CALL mpprecv( 2, t2we(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t2we(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+
+#endif
+
+      ! 2.3 Write Dirichlet lateral conditions
+
+      iihom = nlci - jpreci
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            pt2d(iihom+jl,:) = t2ew(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, jpreci
+            pt2d(jl      ,:) = t2we(:,jl,2)
+            pt2d(iihom+jl,:) = t2ew(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            pt2d(jl      ,:) = t2we(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+
+      ! 3.1 Read Dirichlet lateral conditions
+
+      IF( nbondj /= 2 ) THEN
+         ijhom = nlcj-nrecj
+         DO jl = 1, jprecj
+            t2sn(:,jl,1) = pt2d(:,ijhom +jl)
+            t2ns(:,jl,1) = pt2d(:,jprecj+jl)
+         END DO
+      ENDIF
+
+      ! 3.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jprecj * jpi
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL shmem_put( t2sn(1,1,2), t2sn(1,1,1), imigr, nono )
+      CASE ( 0 )
+         CALL shmem_put( t2ns(1,1,2), t2ns(1,1,1), imigr, noso )
+         CALL shmem_put( t2sn(1,1,2), t2sn(1,1,1), imigr, nono )
+      CASE ( 1 )
+         CALL shmem_put( t2ns(1,1,2), t2ns(1,1,1), imigr, noso )
+      END SELECT 
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * MPI version
+
+      imigr = jprecj * jpi
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t2ns(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t2ns(1,1,2), imigr )
+         CALL mpprecv( 4, t2sn(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t2sn(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+  
+#endif
+
+      ! 3.3 Write Dirichlet lateral conditions
+
+      ijhom = nlcj - jprecj
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            pt2d(:,ijhom+jl) = t2ns(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, jprecj
+            pt2d(:,jl      ) = t2sn(:,jl,2)
+            pt2d(:,ijhom+jl) = t2ns(:,jl,2)
+         END DO
+      CASE ( 1 ) 
+         DO jl = 1, jprecj
+            pt2d(:,jl      ) = t2sn(:,jl,2)
+         END DO
+      END SELECT 
+  
+
+      ! 4. north fold treatment
+      ! -----------------------
+  
+      IF (PRESENT(cd_mpp)) THEN
+         ! No north fold treatment (it is assumed to be already OK)
+     
+      ELSE      
+
+      ! 4.1 treatment without exchange (jpni odd)
+      
+      SELECT CASE ( jpni )
+  
+      CASE ( 1 ) ! only one proc along I, no mpp exchange
+  
+         SELECT CASE ( npolj )
+  
+         CASE ( 3 , 4 )   !  T pivot
+            iloc = jpiglo - 2 * ( nimpp - 1 )
+  
+            SELECT CASE ( cd_type )
+  
+            CASE ( 'T' , 'S', 'W' )
+               DO ji = 2, nlci
+                  ijt=iloc-ji+2
+                  pt2d(ji,nlcj) = psgn * pt2d(ijt,nlcj-2)
+               END DO
+               DO ji = nlci/2+1, nlci
+                  ijt=iloc-ji+2
+                  pt2d(ji,nlcj-1) = psgn * pt2d(ijt,nlcj-1)
+               END DO
+  
+            CASE ( 'U' )
+               DO ji = 1, nlci-1
+                  iju=iloc-ji+1
+                  pt2d(ji,nlcj) = psgn * pt2d(iju,nlcj-2)
+               END DO
+               DO ji = nlci/2, nlci-1
+                  iju=iloc-ji+1
+                  pt2d(ji,nlcj-1) = psgn * pt2d(iju,nlcj-1)
+               END DO
+  
+            CASE ( 'V' )
+               DO ji = 2, nlci
+                  ijt=iloc-ji+2
+                  pt2d(ji,nlcj-1) = psgn * pt2d(ijt,nlcj-2)
+                  pt2d(ji,nlcj  ) = psgn * pt2d(ijt,nlcj-3)
+               END DO
+  
+            CASE ( 'F', 'G' )
+               DO ji = 1, nlci-1
+                  iju=iloc-ji+1
+                  pt2d(ji,nlcj-1) = psgn * pt2d(iju,nlcj-2)
+                  pt2d(ji,nlcj  ) = psgn * pt2d(iju,nlcj-3)
+               END DO
+  
+            CASE ( 'I' )                                  ! ice U-V point
+               pt2d(2,nlcj) = psgn * pt2d(3,nlcj-1)
+               DO ji = 3, nlci
+                  iju = iloc - ji + 3
+                  pt2d(ji,nlcj) = psgn * pt2d(iju,nlcj-1)
+               END DO
+  
+            END SELECT
+  
+         CASE ( 5 , 6 )                 ! F pivot
+            iloc=jpiglo-2*(nimpp-1)
+  
+            SELECT CASE (cd_type )
+  
+            CASE ( 'T', 'S', 'W' )
+               DO ji = 1, nlci
+                  ijt=iloc-ji+1
+                  pt2d(ji,nlcj) = psgn * pt2d(ijt,nlcj-1)
+               END DO
+  
+            CASE ( 'U' )
+               DO ji = 1, nlci-1
+                  iju=iloc-ji
+                  pt2d(ji,nlcj) = psgn * pt2d(iju,nlcj-1)
+               END DO
+
+            CASE ( 'V' )
+               DO ji = 1, nlci
+                  ijt=iloc-ji+1
+                  pt2d(ji,nlcj  ) = psgn * pt2d(ijt,nlcj-2)
+               END DO
+               DO ji = nlci/2+1, nlci
+                  ijt=iloc-ji+1
+                  pt2d(ji,nlcj-1) = psgn * pt2d(ijt,nlcj-1)
+               END DO
+  
+            CASE ( 'F', 'G' )
+               DO ji = 1, nlci-1
+                  iju=iloc-ji
+                  pt2d(ji,nlcj) = psgn * pt2d(iju,nlcj-2)
+               END DO
+               DO ji = nlci/2+1, nlci-1
+                  iju=iloc-ji
+                  pt2d(ji,nlcj-1) = psgn * pt2d(iju,nlcj-1)
+               END DO
+  
+            CASE ( 'I' )                                  ! ice U-V point
+               pt2d( 2 ,nlcj) = zland
+               DO ji = 2 , nlci-1
+                  ijt = iloc - ji + 2
+                  pt2d(ji,nlcj)= 0.5 * ( pt2d(ji,nlcj-1) + psgn * pt2d(ijt,nlcj-1) )
+               END DO
+  
+            END SELECT   ! cd_type
+  
+         END SELECT   ! npolj
+
+      CASE DEFAULT   ! more than 1 proc along I
+         IF( npolj /= 0 )   CALL mpp_lbc_north( pt2d, cd_type, psgn )   ! only for northern procs.
+
+      END SELECT   ! jpni
+
+      ENDIF
+
+      ! 5. East and west directions
+      ! ---------------------------
+
+      SELECT CASE ( npolj )
+
+      CASE ( 3, 4, 5, 6 )
+
+         ! 5.1 Read Dirichlet lateral conditions
+
+         SELECT CASE ( nbondi )
+         CASE ( -1, 0, 1 )
+            iihom = nlci-nreci
+            DO jl = 1, jpreci
+               DO jj = 1, jpj
+                  t2ew(jj,jl,1) = pt2d(jpreci+jl,jj)
+                  t2we(jj,jl,1) = pt2d(iihom +jl,jj)
+               END DO
+            END DO
+         END SELECT
+
+         ! 5.2 Migrations
+
+#if defined key_mpp_shmem
+         !! * SHMEM version
+
+         imigr=jpreci*jpj
+
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr, noea )
+         CASE ( 0 )
+            CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr, nowe )
+            CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr, noea )
+         CASE ( 1 )
+            CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr, nowe )
+         END SELECT
+
+         CALL barrier()
+         CALL shmem_udcflush()
+  
+#elif defined key_mpp_mpi
+         !! * MPI version
+  
+         imigr=jpreci*jpj
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req1 )
+            CALL mpprecv( 1, t2ew(1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CASE ( 0 )
+            CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+            CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req2 )
+            CALL mpprecv( 1, t2ew(1,1,2), imigr )
+            CALL mpprecv( 2, t2we(1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+            IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+         CASE ( 1 )
+            CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+            CALL mpprecv( 2, t2we(1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         END SELECT 
+#endif
+
+         ! 5.3 Write Dirichlet lateral conditions
+  
+         iihom = nlci - jpreci
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            DO jl = 1, jpreci
+               pt2d(iihom+jl,:) = t2ew(:,jl,2)
+            END DO
+         CASE ( 0 )
+            DO jl = 1, jpreci
+               pt2d(jl      ,:) = t2we(:,jl,2)
+               pt2d(iihom+jl,:) = t2ew(:,jl,2)
+            END DO
+         CASE ( 1 )
+            DO jl = 1, jpreci
+               pt2d(jl,:) = t2we(:,jl,2)
+            END DO
+         END SELECT 
+  
+      END SELECT   ! npolj
+  
+   END SUBROUTINE mpp_lnk_2d
+
+
+   SUBROUTINE mpp_lnk_3d_gather( ptab1, cd_type1, ptab2, cd_type2, psgn )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_3d_gather  ***
+      !!
+      !! ** Purpose :   Message passing manadgement for two 3D arrays
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !! ** Action  :   ptab1 and ptab2  with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type1, cd_type2       ! define the nature of ptab array grid-points
+         !                        ! = T , U , V , F , W points
+         !                        ! = S : T-point, north fold treatment ???
+         !                        ! = G : F-point, north fold treatment ???
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   = -1. , the sign is changed if north fold boundary
+         !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         ptab1, ptab2             ! 3D array on which the boundary condition is applied
+
+      !! * Local variables
+      INTEGER ::   ji, jk, jl   ! dummy loop indices
+      INTEGER ::   imigr, iihom, ijhom, iloc, ijt, iju   ! temporary integers
+      INTEGER ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER ::   ml_stat(MPI_STATUS_SIZE)     ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      !                                        ! East-West boundaries
+      !                                        ! ====================
+      IF( nbondi == 2 .AND.   &      ! Cyclic east-west
+         &   (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+         ptab1( 1 ,:,:) = ptab1(jpim1,:,:)
+         ptab1(jpi,:,:) = ptab1(  2  ,:,:)
+         ptab2( 1 ,:,:) = ptab2(jpim1,:,:)
+         ptab2(jpi,:,:) = ptab2(  2  ,:,:)
+
+      ELSE                           ! closed
+         SELECT CASE ( cd_type1 )
+         CASE ( 'T', 'U', 'V', 'W' )
+            ptab1(     1       :jpreci,:,:) = 0.e0
+            ptab1(nlci-jpreci+1:jpi   ,:,:) = 0.e0
+         CASE ( 'F' )
+            ptab1(nlci-jpreci+1:jpi   ,:,:) = 0.e0
+         END SELECT 
+         SELECT CASE ( cd_type2 )
+         CASE ( 'T', 'U', 'V', 'W' )
+            ptab2(     1       :jpreci,:,:) = 0.e0
+            ptab2(nlci-jpreci+1:jpi   ,:,:) = 0.e0
+         CASE ( 'F' )
+            ptab2(nlci-jpreci+1:jpi   ,:,:) = 0.e0
+         END SELECT 
+      ENDIF
+
+      !                                        ! North-South boundaries
+      !                                        ! ======================
+      SELECT CASE ( cd_type1 )
+      CASE ( 'T', 'U', 'V', 'W' )
+         ptab1(:,     1       :jprecj,:) = 0.e0
+         ptab1(:,nlcj-jprecj+1:jpj   ,:) = 0.e0
+      CASE ( 'F' )
+         ptab1(:,nlcj-jprecj+1:jpj   ,:) = 0.e0
+      END SELECT
+
+      SELECT CASE ( cd_type2 )
+      CASE ( 'T', 'U', 'V', 'W' )
+         ptab2(:,     1       :jprecj,:) = 0.e0
+         ptab2(:,nlcj-jprecj+1:jpj   ,:) = 0.e0
+      CASE ( 'F' )
+         ptab2(:,nlcj-jprecj+1:jpj   ,:) = 0.e0
+      END SELECT
+
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+
+      ! 2.1 Read Dirichlet lateral conditions
+
+      SELECT CASE ( nbondi )
+      CASE ( -1, 0, 1 )    ! all exept 2 
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t4ew(:,jl,:,1,1) = ptab1(jpreci+jl,:,:)
+            t4we(:,jl,:,1,1) = ptab1(iihom +jl,:,:)
+            t4ew(:,jl,:,2,1) = ptab2(jpreci+jl,:,:)
+            t4we(:,jl,:,2,1) = ptab2(iihom +jl,:,:)
+         END DO
+      END SELECT
+
+      ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jpreci * jpj * jpk *2
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL shmem_put( t4we(1,1,1,1,2), t4we(1,1,1,1,1), imigr, noea )
+      CASE ( 0 )
+         CALL shmem_put( t4ew(1,1,1,1,2), t4ew(1,1,1,1,1), imigr, nowe )
+         CALL shmem_put( t4we(1,1,1,1,2), t4we(1,1,1,1,1), imigr, noea )
+      CASE ( 1 )
+         CALL shmem_put( t4ew(1,1,1,1,2), t4ew(1,1,1,1,1), imigr, nowe )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+
+      imigr = jpreci * jpj * jpk *2
+
+      SELECT CASE ( nbondi ) 
+      CASE ( -1 )
+         CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+         CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+#endif
+
+      ! 2.3 Write Dirichlet lateral conditions
+
+      iihom = nlci-jpreci
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+            ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jpreci
+            ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+            ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+            ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+            ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+            ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+
+      ! 3.1 Read Dirichlet lateral conditions
+
+      IF( nbondj /= 2 ) THEN
+         ijhom = nlcj-nrecj
+         DO jl = 1, jprecj
+            t4sn(:,jl,:,1,1) = ptab1(:,ijhom +jl,:)
+            t4ns(:,jl,:,1,1) = ptab1(:,jprecj+jl,:)
+            t4sn(:,jl,:,2,1) = ptab2(:,ijhom +jl,:)
+            t4ns(:,jl,:,2,1) = ptab2(:,jprecj+jl,:)
+         END DO
+      ENDIF
+
+      ! 3.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = jprecj * jpi * jpk * 2
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL shmem_put( t4sn(1,1,1,1,2), t4sn(1,1,1,1,1), imigr, nono )
+      CASE ( 0 )
+         CALL shmem_put( t4ns(1,1,1,1,2), t4ns(1,1,1,1,1), imigr, noso )
+         CALL shmem_put( t4sn(1,1,1,1,2), t4sn(1,1,1,1,1), imigr, nono )
+      CASE ( 1 )
+         CALL shmem_put( t4ns(1,1,1,1,2), t4ns(1,1,1,1;,1), imigr, noso )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+  
+      imigr=jprecj * jpi * jpk * 2
+
+      SELECT CASE ( nbondj )     
+      CASE ( -1 )
+         CALL mppsend( 4, t4sn(1,1,1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t4ns(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t4ns(1,1,1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t4sn(1,1,1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t4ns(1,1,1,1,2), imigr )
+         CALL mpprecv( 4, t4sn(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 ) 
+         CALL mppsend( 3, t4ns(1,1,1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t4sn(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+
+#endif
+
+      ! 3.3 Write Dirichlet lateral conditions
+
+      ijhom = nlcj-jprecj
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            ptab1(:,ijhom+jl,:) = t4ns(:,jl,:,1,2)
+            ptab2(:,ijhom+jl,:) = t4ns(:,jl,:,2,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jprecj
+            ptab1(:,jl      ,:) = t4sn(:,jl,:,1,2)
+            ptab1(:,ijhom+jl,:) = t4ns(:,jl,:,1,2)
+            ptab2(:,jl      ,:) = t4sn(:,jl,:,2,2)
+            ptab2(:,ijhom+jl,:) = t4ns(:,jl,:,2,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jprecj
+            ptab1(:,jl,:) = t4sn(:,jl,:,1,2)
+            ptab2(:,jl,:) = t4sn(:,jl,:,2,2)
+         END DO
+      END SELECT
+
+
+      ! 4. north fold treatment
+      ! -----------------------
+
+      ! 4.1 treatment without exchange (jpni odd)
+      !     T-point pivot  
+
+      SELECT CASE ( jpni )
+
+      CASE ( 1 )  ! only one proc along I, no mpp exchange
+
+      SELECT CASE ( npolj )
+  
+         CASE ( 3 , 4 )    ! T pivot
+            iloc = jpiglo - 2 * ( nimpp - 1 )
+
+            SELECT CASE ( cd_type1 )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab1(ji,nlcj,jk) = psgn * ptab1(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+2
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+          
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab1(ji,nlcj,jk) = psgn * ptab1(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2, nlci-1
+                     iju=iloc-ji+1
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(ijt,nlcj-2,jk)
+                     ptab1(ji,nlcj  ,jk) = psgn * ptab1(ijt,nlcj-3,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(iju,nlcj-2,jk)
+                     ptab1(ji,nlcj  ,jk) = psgn * ptab1(iju,nlcj-3,jk)
+                  END DO
+               END DO
+  
+            END SELECT
+            
+            SELECT CASE ( cd_type2 )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab2(ji,nlcj,jk) = psgn * ptab2(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+2
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+          
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab2(ji,nlcj,jk) = psgn * ptab2(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2, nlci-1
+                     iju=iloc-ji+1
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 2, nlci
+                     ijt=iloc-ji+2
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(ijt,nlcj-2,jk)
+                     ptab2(ji,nlcj  ,jk) = psgn * ptab2(ijt,nlcj-3,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji+1
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(iju,nlcj-2,jk)
+                     ptab2(ji,nlcj  ,jk) = psgn * ptab2(iju,nlcj-3,jk)
+                  END DO
+               END DO
+  
+          END SELECT
+       
+         CASE ( 5 , 6 ) ! F pivot
+            iloc=jpiglo-2*(nimpp-1)
+  
+            SELECT CASE ( cd_type1 )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab1(ji,nlcj,jk) = psgn * ptab1(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab1(ji,nlcj,jk) = psgn * ptab1(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab1(ji,nlcj  ,jk) = psgn * ptab1(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+1
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab1(ji,nlcj,jk) = psgn * ptab1(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci-1
+                     iju=iloc-ji
+                     ptab1(ji,nlcj-1,jk) = psgn * ptab1(iju,nlcj-1,jk)
+                  END DO
+               END DO
+            END SELECT  ! cd_type1
+
+            SELECT CASE ( cd_type2 )
+
+            CASE ( 'T' , 'S', 'W' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab2(ji,nlcj,jk) = psgn * ptab2(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'U' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab2(ji,nlcj,jk) = psgn * ptab2(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'V' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci
+                     ijt=iloc-ji+1
+                     ptab2(ji,nlcj  ,jk) = psgn * ptab2(ijt,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci
+                     ijt=iloc-ji+1
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(ijt,nlcj-1,jk)
+                  END DO
+               END DO
+
+            CASE ( 'F', 'G' )
+               DO jk = 1, jpk
+                  DO ji = 1, nlci-1
+                     iju=iloc-ji
+                     ptab2(ji,nlcj,jk) = psgn * ptab2(iju,nlcj-2,jk)
+                  END DO
+                  DO ji = nlci/2+1, nlci-1
+                     iju=iloc-ji
+                     ptab2(ji,nlcj-1,jk) = psgn * ptab2(iju,nlcj-1,jk)
+                  END DO
+               END DO
+
+            END SELECT  ! cd_type2
+
+         END SELECT     !  npolj
+  
+      CASE DEFAULT ! more than 1 proc along I
+         IF ( npolj /= 0 ) THEN
+            CALL mpp_lbc_north (ptab1, cd_type1, psgn)  ! only for northern procs.
+            CALL mpp_lbc_north (ptab2, cd_type2, psgn)  ! only for northern procs.
+         ENDIF
+
+      END SELECT ! jpni 
+
+
+      ! 5. East and west directions exchange
+      ! ------------------------------------
+
+      SELECT CASE ( npolj )
+
+      CASE ( 3, 4, 5, 6 )
+
+         ! 5.1 Read Dirichlet lateral conditions
+
+         SELECT CASE ( nbondi )
+
+         CASE ( -1, 0, 1 )
+            iihom = nlci-nreci
+            DO jl = 1, jpreci
+               t4ew(:,jl,:,1,1) = ptab1(jpreci+jl,:,:)
+               t4we(:,jl,:,1,1) = ptab1(iihom +jl,:,:)
+               t4ew(:,jl,:,2,1) = ptab2(jpreci+jl,:,:)
+               t4we(:,jl,:,2,1) = ptab2(iihom +jl,:,:)
+            END DO
+
+         END SELECT
+
+         ! 5.2 Migrations
+
+#if defined key_mpp_shmem
+         !! SHMEM version
+
+         imigr = jpreci * jpj * jpk * 2
+
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL shmem_put( t4we(1,1,1,1,2), t4we(1,1,1,1,1), imigr, noea )
+         CASE ( 0 )
+            CALL shmem_put( t4ew(1,1,1,1,2), t4ew(1,1,1,1,1), imigr, nowe )
+            CALL shmem_put( t4we(1,1,1,1,2), t4we(1,1,1,1,1), imigr, noea )
+         CASE ( 1 )
+            CALL shmem_put( t4ew(1,1,1,1,2), t4ew(1,1,1,1,1), imigr, nowe )
+         END SELECT
+
+         CALL barrier()
+         CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+         !! MPI version
+
+         imigr = jpreci * jpj * jpk * 2
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req1 )
+            CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CASE ( 0 )
+            CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+            CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req2 )
+            CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+            CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+            IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+         CASE ( 1 )
+            CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+            CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         END SELECT
+#endif
+
+         ! 5.3 Write Dirichlet lateral conditions
+
+         iihom = nlci-jpreci
+
+         SELECT CASE ( nbondi)
+         CASE ( -1 )
+            DO jl = 1, jpreci
+               ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+               ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+            END DO
+         CASE ( 0 ) 
+            DO jl = 1, jpreci
+               ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+               ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+               ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+               ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+            END DO
+         CASE ( 1 )
+            DO jl = 1, jpreci
+               ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+               ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+            END DO
+         END SELECT
+
+      END SELECT    ! npolj 
+
+   END SUBROUTINE mpp_lnk_3d_gather
+
+
+   SUBROUTINE mpp_lnk_2d_e( pt2d, cd_type, psgn )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_2d_e  ***
+      !!                  
+      !! ** Purpose :   Message passing manadgement for 2d array (with halo)
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    jpr2di : number of rows for extra outer halo
+      !!                    jpr2dj : number of columns for extra outer halo
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!   
+      !! History :
+      !!       
+      !!   9.0  !  05-09  (R. Benshila, G. Madec)  original code
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type       ! define the nature of pt2d array grid-points
+         !             !  = T , U , V , F , W 
+         !             !  = S : T-point, north fold treatment
+         !             !  = G : F-point, north fold treatment
+         !             !  = I : sea-ice velocity at F-point with index shift
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   = -1. , the sign is changed if north fold boundary
+         !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+
+      !! * Local variables
+      INTEGER  ::   ji, jl      ! dummy loop indices
+      INTEGER  ::   &
+         imigr, iihom, ijhom,    &  ! temporary integers
+         iloc, ijt, iju             !    "          "
+      INTEGER  ::   &
+         ipreci, iprecj             ! temporary integers
+      INTEGER  ::   ml_req1, ml_req2, ml_err     ! for isend
+      INTEGER  ::   ml_stat(MPI_STATUS_SIZE)     ! for isend
+     !!---------------------------------------------------------------------
+
+      ! take into account outer extra 2D overlap area
+      ipreci = jpreci + jpr2di
+      iprecj = jprecj + jpr2dj
+
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+
+      !                                        ! East-West boundaries
+      !                                        ! ====================
+      IF( nbondi == 2 .AND.   &      ! Cyclic east-west
+         &    (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+         pt2d(1-jpr2di:     1    ,:) = pt2d(jpim1-jpr2di:  jpim1 ,:)
+         pt2d(   jpi  :jpi+jpr2di,:) = pt2d(     2      :2+jpr2di,:)
+
+      ELSE                           ! ... closed
+         SELECT CASE ( cd_type )
+         CASE ( 'T', 'U', 'V', 'W' , 'I' )
+            pt2d(  1-jpr2di   :jpreci    ,:) = 0.e0
+            pt2d(nlci-jpreci+1:jpi+jpr2di,:) = 0.e0
+         CASE ( 'F' )
+            pt2d(nlci-jpreci+1:jpi+jpr2di,:) = 0.e0
+         END SELECT
+      ENDIF
+
+      !                                        ! North-South boundaries
+      !                                        ! ======================
+      SELECT CASE ( cd_type )
+      CASE ( 'T', 'U', 'V', 'W' , 'I' )
+         pt2d(:,  1-jpr2dj   :  jprecj  ) = 0.e0
+         pt2d(:,nlcj-jprecj+1:jpj+jpr2dj) = 0.e0
+      CASE ( 'F' )
+         pt2d(:,nlcj-jprecj+1:jpj+jpr2dj) = 0.e0
+      END SELECT
+
+
+      ! 2. East and west directions
+      ! ---------------------------
+
+      ! 2.1 Read Dirichlet lateral conditions
+
+      SELECT CASE ( nbondi )
+      CASE ( -1, 0, 1 )    ! all except 2
+         iihom = nlci-nreci-jpr2di
+         DO jl = 1, ipreci
+            tr2ew(:,jl,1) = pt2d(jpreci+jl,:)
+            tr2we(:,jl,1) = pt2d(iihom +jl,:)
+         END DO
+      END SELECT
+
+      ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = ipreci * ( jpj + 2*jpr2dj)
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL shmem_put( tr2we(1-jpr2dj,1,2), tr2we(1,1,1), imigr, noea )
+      CASE ( 0 )
+         CALL shmem_put( tr2ew(1-jpr2dj,1,2), tr2ew(1,1,1), imigr, nowe )
+         CALL shmem_put( tr2we(1-jpr2dj,1,2), tr2we(1,1,1), imigr, noea )
+      CASE ( 1 )
+         CALL shmem_put( tr2ew(1-jpr2dj,1,2), tr2ew(1,1,1), imigr, nowe )
+      END SELECT
+
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * MPI version
+
+      imigr = ipreci * ( jpj + 2*jpr2dj)
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+         CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+
+#endif
+
+      ! 2.3 Write Dirichlet lateral conditions
+
+      iihom = nlci - jpreci
+
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, ipreci
+            pt2d(iihom+jl,:) = tr2ew(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, ipreci
+            pt2d(jl-jpr2di,:) = tr2we(:,jl,2)
+            pt2d( iihom+jl,:) = tr2ew(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, ipreci
+            pt2d(jl-jpr2di,:) = tr2we(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+
+      ! 3.1 Read Dirichlet lateral conditions
+
+      IF( nbondj /= 2 ) THEN
+         ijhom = nlcj-nrecj-jpr2dj
+         DO jl = 1, iprecj
+            tr2sn(:,jl,1) = pt2d(:,ijhom +jl)
+            tr2ns(:,jl,1) = pt2d(:,jprecj+jl)
+         END DO
+      ENDIF
+
+      ! 3.2 Migrations
+
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      imigr = iprecj * ( jpi + 2*jpr2di )
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL shmem_put( tr2sn(1-jpr2di,1,2), tr2sn(1,1,1), imigr, nono )
+      CASE ( 0 )
+         CALL shmem_put( tr2ns(1-jpr2di,1,2), tr2ns(1,1,1), imigr, noso )
+         CALL shmem_put( tr2sn(1-jpr2di,1,2), tr2sn(1,1,1), imigr, nono )
+      CASE ( 1 )
+         CALL shmem_put( tr2ns(1-jpr2di,1,2), tr2ns(1,1,1), imigr, noso )
+      END SELECT 
+      CALL barrier()
+      CALL shmem_udcflush()
+
+#elif defined key_mpp_mpi
+      !! * MPI version
+
+      imigr = iprecj * ( jpi + 2*jpr2di )
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL mppsend( 4, tr2sn(1-jpr2di,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, tr2ns(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, tr2ns(1-jpr2di,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, tr2sn(1-jpr2di,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, tr2ns(1-jpr2di,1,2), imigr )
+         CALL mpprecv( 4, tr2sn(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 3, tr2ns(1-jpr2di,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, tr2sn(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+  
+#endif
+
+      ! 3.3 Write Dirichlet lateral conditions
+
+      ijhom = nlcj - jprecj  
+
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, iprecj
+            pt2d(:,ijhom+jl) = tr2ns(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, iprecj
+            pt2d(:,jl-jpr2dj) = tr2sn(:,jl,2)
+            pt2d(:,ijhom+jl ) = tr2ns(:,jl,2)
+         END DO
+      CASE ( 1 ) 
+         DO jl = 1, iprecj
+            pt2d(:,jl-jpr2dj) = tr2sn(:,jl,2)
+         END DO
+      END SELECT 
+  
+
+      ! 4. north fold treatment
+      ! -----------------------
+  
+      ! 4.1 treatment without exchange (jpni odd)
+      
+      SELECT CASE ( jpni )
+  
+      CASE ( 1 ) ! only one proc along I, no mpp exchange
+  
+         SELECT CASE ( npolj )
+  
+         CASE ( 3 , 4 )   !  T pivot
+            iloc = jpiglo - 2 * ( nimpp - 1 )
+  
+            SELECT CASE ( cd_type )
+  
+            CASE ( 'T', 'S', 'W' )
+               DO jl = 0, iprecj-1
+                  DO ji = 2-jpr2di, nlci+jpr2di
+                     ijt=iloc-ji+2
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(ijt,nlcj-2-jl)
+                  END DO
+               END DO
+               DO ji = nlci/2+1, nlci+jpr2di
+                  ijt=iloc-ji+2
+                  pt2d(ji,nlcj-1) = psgn * pt2d(ijt,nlcj-1)
+               END DO
+ 
+            CASE ( 'U' )
+               DO jl =0, iprecj-1
+                  DO ji = 1-jpr2di, nlci-1-jpr2di
+                     iju=iloc-ji+1
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(iju,nlcj-2-jl)
+                  END DO
+               END DO
+               DO ji = nlci/2, nlci-1+jpr2di
+                  iju=iloc-ji+1
+                  pt2d(ji,nlcj-1) = psgn * pt2d(iju,nlcj-1)
+               END DO
+  
+            CASE ( 'V' )
+               DO jl = -1, iprecj-1
+                  DO ji = 2-jpr2di, nlci+jpr2di
+                     ijt=iloc-ji+2
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(ijt,nlcj-3-jl)
+                  END DO
+               END DO
+  
+            CASE ( 'F', 'G' )
+               DO jl = -1, iprecj-1
+                  DO ji = 1-jpr2di, nlci-1+jpr2di
+                     iju=iloc-ji+1
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(iju,nlcj-3-jl)
+                  END DO
+               END DO
+  
+            CASE ( 'I' )                                  ! ice U-V point
+               DO jl = 0, iprecj-1
+                  pt2d(2,nlcj+jl) = psgn * pt2d(3,nlcj-1-jl)
+                  DO ji = 3, nlci+jpr2di
+                     iju = iloc - ji + 3
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(iju,nlcj-1-jl)
+                  END DO
+               END DO
+  
+            END SELECT
+  
+         CASE ( 5 , 6 )                 ! F pivot
+            iloc=jpiglo-2*(nimpp-1)
+  
+            SELECT CASE (cd_type )
+  
+            CASE ( 'T', 'S', 'W' )
+               DO jl = 0, iprecj-1
+                  DO ji = 1-jpr2di, nlci+jpr2di
+                     ijt=iloc-ji+1
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(ijt,nlcj-1-jl)
+                  END DO
+               END DO
+  
+            CASE ( 'U' )
+               DO jl = 0, iprecj-1
+                  DO ji = 1-jpr2di, nlci-1+jpr2di
+                     iju=iloc-ji
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(iju,nlcj-1-jl)
+                  END DO
+               END DO
+ 
+            CASE ( 'V' )
+               DO jl = 0, iprecj-1
+                  DO ji = 1-jpr2di, nlci+jpr2di
+                     ijt=iloc-ji+1
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(ijt,nlcj-2-jl)
+                  END DO
+               END DO 
+               DO ji = nlci/2+1, nlci+jpr2di
+                  ijt=iloc-ji+1
+                  pt2d(ji,nlcj-1) = psgn * pt2d(ijt,nlcj-1)
+               END DO
+  
+            CASE ( 'F', 'G' )
+               DO jl = 0, iprecj-1
+                  DO ji = 1-jpr2di, nlci-1+jpr2di
+                     iju=iloc-ji
+                     pt2d(ji,nlcj+jl) = psgn * pt2d(iju,nlcj-2-jl)
+                  END DO
+               END DO
+               DO ji = nlci/2+1, nlci-1+jpr2di
+                  iju=iloc-ji
+                  pt2d(ji,nlcj-1) = psgn * pt2d(iju,nlcj-1)
+               END DO
+  
+            CASE ( 'I' )                                  ! ice U-V point
+               pt2d( 2 ,nlcj) = 0.e0
+               DO jl = 0, iprecj-1
+                  DO ji = 2 , nlci-1+jpr2di
+                     ijt = iloc - ji + 2
+                     pt2d(ji,nlcj+jl)= 0.5 * ( pt2d(ji,nlcj-1-jl) + psgn * pt2d(ijt,nlcj-1-jl) )
+                  END DO
+               END DO
+  
+            END SELECT   ! cd_type
+  
+         END SELECT   ! npolj
+
+      CASE DEFAULT   ! more than 1 proc along I
+         IF( npolj /= 0 )   CALL mpp_lbc_north_e( pt2d, cd_type, psgn )   ! only for northern procs
+         
+      END SELECT   ! jpni
+
+
+      ! 5. East and west directions
+      ! ---------------------------
+
+      SELECT CASE ( npolj )
+
+      CASE ( 3, 4, 5, 6 )
+
+         ! 5.1 Read Dirichlet lateral conditions
+
+         SELECT CASE ( nbondi )
+         CASE ( -1, 0, 1 )
+            iihom = nlci-nreci-jpr2di
+            DO jl = 1, ipreci
+               tr2ew(:,jl,1) = pt2d(jpreci+jl,:)
+               tr2we(:,jl,1) = pt2d(iihom +jl,:)
+            END DO
+         END SELECT
+
+         ! 5.2 Migrations
+
+#if defined key_mpp_shmem
+         !! * SHMEM version
+
+         imigr = ipreci * ( jpj + 2*jpr2dj )
+
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL shmem_put( tr2we(1-jpr2dj,1,2), tr2we(1,1,1), imigr, noea )
+         CASE ( 0 )
+            CALL shmem_put( tr2ew(1-jpr2dj,1,2), tr2ew(1,1,1), imigr, nowe )
+            CALL shmem_put( tr2we(1-jpr2dj,1,2), tr2we(1,1,1), imigr, noea )
+         CASE ( 1 )
+            CALL shmem_put( tr2ew(1-jpr2dj,1,2), tr2ew(1,1,1), imigr, nowe )
+         END SELECT
+
+         CALL barrier()
+         CALL shmem_udcflush()
+  
+#elif defined key_mpp_mpi
+         !! * MPI version
+  
+         imigr=ipreci* ( jpj + 2*jpr2dj )
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req1 )
+            CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CASE ( 0 )
+            CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+            CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req2 )
+            CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+            CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+            IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+         CASE ( 1 )
+            CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+            CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+            IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         END SELECT 
+#endif
+
+         ! 5.3 Write Dirichlet lateral conditions
+  
+         iihom = nlci - jpreci
+  
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+            DO jl = 1, ipreci
+               pt2d(iihom+jl,:) = tr2ew(:,jl,2)
+            END DO
+         CASE ( 0 )
+            DO jl = 1, ipreci
+               pt2d(jl- jpr2di,:) = tr2we(:,jl,2)
+               pt2d(iihom+jl,:) = tr2ew(:,jl,2)
+            END DO
+         CASE ( 1 )
+            DO jl = 1, ipreci
+               pt2d(jl-jpr2di,:) = tr2we(:,jl,2)
+            END DO
+         END SELECT 
+  
+      END SELECT   ! npolj
+  
+   END SUBROUTINE mpp_lnk_2d_e
+
+
+   SUBROUTINE mpplnks( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpplnks  ***
+      !!
+      !! ** Purpose :   Message passing manadgement for add 2d array local boundary
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask between
+      !!       processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   &
+         ptab                     ! 2D array
+  
+      !! * Local variables
+      INTEGER ::   ji, jl         ! dummy loop indices
+      INTEGER ::   &
+         imigr, iihom, ijhom      ! temporary integers
+      INTEGER ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER ::   ml_stat(MPI_STATUS_SIZE)     ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+
+      ! 1. north fold treatment
+      ! -----------------------
+
+      ! 1.1 treatment without exchange (jpni odd)
+  
+      SELECT CASE ( npolj )
+      CASE ( 4 )
+         DO ji = 1, nlci
+            ptab(ji,nlcj-2) = ptab(ji,nlcj-2) + t2p1(ji,1,1)
+         END DO
+      CASE ( 6 )
+         DO ji = 1, nlci
+            ptab(ji,nlcj-1) = ptab(ji,nlcj-1) + t2p1(ji,1,1)
+         END DO
+
+      ! 1.2 treatment with exchange (jpni greater than 1)
+      ! 
+      CASE ( 3 )
+#if defined key_mpp_shmem
+  
+         !! * SHMEN version
+  
+         imigr=jprecj*jpi
+  
+         CALL shmem_put(t2p1(1,1,2),t2p1(1,1,1),imigr,nono)
+         CALL barrier()
+         CALL shmem_udcflush()
+
+#  elif defined key_mpp_mpi
+       !! * MPI version
+
+       imigr=jprecj*jpi
+
+       CALL mppsend(3,t2p1(1,1,1),imigr,nono, ml_req1)
+       CALL mpprecv(3,t2p1(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+
+#endif      
+
+       ! Write north fold conditions
+
+       DO ji = 1, nlci
+          ptab(ji,nlcj-2) = ptab(ji,nlcj-2)+t2p1(ji,1,2)
+       END DO
+
+    CASE ( 5 )
+
+#if defined key_mpp_shmem
+
+       !! * SHMEN version
+
+       imigr=jprecj*jpi
+
+       CALL shmem_put(t2p1(1,1,2),t2p1(1,1,1),imigr,nono)
+       CALL barrier()
+       CALL shmem_udcflush()
+
+#  elif defined key_mpp_mpi
+       !! * Local variables   (MPI version)
+
+       imigr=jprecj*jpi
+
+       CALL mppsend(3,t2p1(1,1,1),imigr,nono, ml_req1)
+       CALL mpprecv(3,t2p1(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+
+#endif      
+
+       ! Write north fold conditions
+
+       DO ji = 1, nlci
+          ptab(ji,nlcj-1) = ptab(ji,nlcj-1)+t2p1(ji,1,2)
+       END DO
+
+    END SELECT
+
+
+    ! 2. East and west directions
+    ! ---------------------------
+
+    ! 2.1 Read Dirichlet lateral conditions
+
+    iihom = nlci-jpreci
+
+    SELECT CASE ( nbondi )
+
+    CASE ( -1, 0, 1 )  ! all except 2
+       DO jl = 1, jpreci
+             t2ew(:,jl,1) = ptab(  jl    ,:)
+             t2we(:,jl,1) = ptab(iihom+jl,:)
+       END DO
+    END SELECT
+
+    ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+
+    !! * SHMEN version
+
+    imigr=jpreci*jpj
+
+    SELECT CASE ( nbondi )
+
+    CASE ( -1 )
+       CALL shmem_put(t2we(1,1,2),t2we(1,1,1),imigr,noea)
+
+    CASE ( 0 )
+       CALL shmem_put(t2ew(1,1,2),t2ew(1,1,1),imigr,nowe)
+       CALL shmem_put(t2we(1,1,2),t2we(1,1,1),imigr,noea)
+
+    CASE ( 1 )
+       CALL shmem_put(t2ew(1,1,2),t2ew(1,1,1),imigr,nowe)
+
+    END SELECT
+    CALL  barrier()
+    CALL  shmem_udcflush()
+
+#  elif defined key_mpp_mpi
+    !! * Local variables   (MPI version)
+
+    imigr=jpreci*jpj
+
+    SELECT CASE ( nbondi )
+
+    CASE ( -1 )
+       CALL mppsend(2,t2we(1,1,1),imigr,noea, ml_req1)
+       CALL mpprecv(1,t2ew(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+    CASE ( 0 )
+       CALL mppsend(1,t2ew(1,1,1),imigr,nowe, ml_req1)
+       CALL mppsend(2,t2we(1,1,1),imigr,noea, ml_req2)
+       CALL mpprecv(1,t2ew(1,1,2),imigr)
+       CALL mpprecv(2,t2we(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+
+    CASE ( 1 )
+       CALL mppsend(1,t2ew(1,1,1),imigr,nowe, ml_req1)
+       CALL mpprecv(2,t2we(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+
+    END SELECT
+
+#endif
+
+    ! 2.3 Write Dirichlet lateral conditions
+
+       iihom = nlci-nreci
+
+    SELECT CASE ( nbondi )
+
+    CASE ( -1 )
+       DO jl = 1, jpreci
+             ptab(iihom +jl,:) = ptab(iihom +jl,:)+t2ew(:,jl,2)
+       END DO
+
+    CASE ( 0 )
+       DO jl = 1, jpreci
+             ptab(jpreci+jl,:) = ptab(jpreci+jl,:)+t2we(:,jl,2)
+             ptab(iihom +jl,:) = ptab(iihom +jl,:)+t2ew(:,jl,2)
+       END DO
+
+    CASE ( 1 )
+       DO jl = 1, jpreci
+             ptab(jpreci+jl,:) = ptab(jpreci+jl,:)+t2we(:,jl,2)
+       END DO
+    END SELECT
+
+
+    ! 3. North and south directions
+    ! -----------------------------
+
+    ! 3.1 Read Dirichlet lateral conditions
+
+    ijhom = nlcj-jprecj
+
+    SELECT CASE ( nbondj )
+
+    CASE ( -1, 0, 1 )
+       DO jl = 1, jprecj
+             t2sn(:,jl,1) = ptab(:,ijhom+jl)
+             t2ns(:,jl,1) = ptab(:,   jl   )
+       END DO
+
+    END SELECT 
+
+    ! 3.2 Migrations
+
+#if defined key_mpp_shmem
+
+    !! * SHMEN version
+
+    imigr=jprecj*jpi
+
+    SELECT CASE ( nbondj )
+
+    CASE ( -1 )
+       CALL shmem_put(t2sn(1,1,2),t2sn(1,1,1),imigr,nono)
+
+    CASE ( 0 )
+       CALL shmem_put(t2ns(1,1,2),t2ns(1,1,1),imigr,noso)
+       CALL shmem_put(t2sn(1,1,2),t2sn(1,1,1),imigr,nono)
+
+    CASE ( 1 )
+       CALL shmem_put(t2ns(1,1,2),t2ns(1,1,1),imigr,noso)
+
+    END SELECT
+    CALL  barrier()
+    CALL  shmem_udcflush()
+
+#  elif defined key_mpp_mpi
+    !! * Local variables   (MPI version)
+
+    imigr=jprecj*jpi
+
+    SELECT CASE ( nbondj )
+
+    CASE ( -1 )
+       CALL mppsend(4,t2sn(1,1,1),imigr,nono, ml_req1)
+       CALL mpprecv(3,t2ns(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+
+    CASE ( 0 )
+       CALL mppsend(3,t2ns(1,1,1),imigr,noso, ml_req1)
+       CALL mppsend(4,t2sn(1,1,1),imigr,nono, ml_req2)
+       CALL mpprecv(3,t2ns(1,1,2),imigr)
+       CALL mpprecv(4,t2sn(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+
+    CASE ( 1 )
+       CALL mppsend(3,t2ns(1,1,1),imigr,noso, ml_req1)
+       CALL mpprecv(4,t2sn(1,1,2),imigr)
+       IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+    END SELECT
+
+#endif
+
+    ! 3.3 Write Dirichlet lateral conditions
+
+       ijhom = nlcj-nrecj
+
+    SELECT CASE ( nbondj )
+
+    CASE ( -1 )
+       DO jl = 1, jprecj
+             ptab(:,ijhom +jl) = ptab(:,ijhom +jl)+t2ns(:,jl,2)
+       END DO
+
+    CASE ( 0 )
+       DO jl = 1, jprecj
+             ptab(:,jprecj+jl) = ptab(:,jprecj+jl)+t2sn(:,jl,2)
+             ptab(:,ijhom +jl) = ptab(:,ijhom +jl)+t2ns(:,jl,2)
+       END DO
+
+    CASE ( 1 ) 
+       DO jl = 1, jprecj
+             ptab(:,jprecj+jl) = ptab(:,jprecj+jl)+t2sn(:,jl,2)
+       END DO
+
+    END SELECT
+
+  END SUBROUTINE mpplnks
+
+
+   SUBROUTINE mppsend( ktyp, pmess, kbytes, kdest, md_req)
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsend  ***
+      !!                   
+      !! ** Purpose :   Send messag passing array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT(inout) ::   pmess(*)       ! array of real
+      INTEGER , INTENT( in  ) ::   kbytes,     &  ! size of the array pmess
+         &                         kdest ,     &  ! receive process number
+         &                         ktyp,       &  ! Tag of the message
+         &                         md_req         ! Argument for isend
+      !!----------------------------------------------------------------------
+#if defined key_mpp_shmem
+      !! * SHMEM version  :    routine not used
+
+#elif defined key_mpp_mpi
+      !! * MPI version
+      INTEGER ::   iflag
+
+      SELECT CASE ( c_mpi_send )
+      CASE ( 'S' )                ! Standard mpi send (blocking)
+         CALL mpi_send ( pmess, kbytes, mpi_double_precision, kdest, ktyp,   &
+            &                          mpi_comm_opa, iflag )
+      CASE ( 'B' )                ! Buffer mpi send (blocking)
+         CALL mpi_bsend( pmess, kbytes, mpi_double_precision, kdest, ktyp,   &
+            &                          mpi_comm_opa, iflag )
+      CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+         ! Be carefull, one more argument here : the mpi request identifier..
+         CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest, ktyp,   &
+            &                          mpi_comm_opa, md_req, iflag )
+      END SELECT
+#endif
+
+   END SUBROUTINE mppsend
+
+
+   SUBROUTINE mpprecv( ktyp, pmess, kbytes )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpprecv  ***
+      !!
+      !! ** Purpose :   Receive messag passing array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT(inout) ::   pmess(*)       ! array of real
+      INTEGER , INTENT( in  ) ::   kbytes,     &  ! suze of the array pmess
+         &                         ktyp           ! Tag of the recevied message
+      !!----------------------------------------------------------------------
+#if defined key_mpp_shmem
+      !! * SHMEM version  :    routine not used
+
+#  elif defined key_mpp_mpi
+      !! * MPI version
+      INTEGER :: istatus(mpi_status_size)
+      INTEGER :: iflag
+
+      CALL mpi_recv( pmess, kbytes, mpi_double_precision, mpi_any_source, ktyp,   &
+         &                          mpi_comm_opa, istatus, iflag )
+#endif
+
+   END SUBROUTINE mpprecv
+
+
+   SUBROUTINE mppgather( ptab, kp, pio )
+      !!----------------------------------------------------------------------
+      !!                   ***  routine mppgather  ***
+      !!                   
+      !! ** Purpose :   Transfert between a local subdomain array and a work 
+      !!     array which is distributed following the vertical level.
+      !!
+      !! ** Method  :
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj),       INTENT( in  ) ::   ptab   ! subdomain input array
+      INTEGER ,                           INTENT( in  ) ::   kp     ! record length
+      REAL(wp), DIMENSION(jpi,jpj,jpnij), INTENT( out ) ::   pio    ! subdomain input array
+      !!---------------------------------------------------------------------
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      CALL barrier()
+      CALL shmem_put( pio(1,1,npvm_me+1), ptab, jpi*jpj, kp )
+      CALL barrier()
+
+#elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+      INTEGER :: itaille,ierror
+  
+      itaille=jpi*jpj
+      CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille,   &
+         &                            mpi_double_precision, kp , mpi_comm_opa, ierror ) 
+#endif
+
+   END SUBROUTINE mppgather
+
+
+   SUBROUTINE mppscatter( pio, kp, ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppscatter  ***
+      !!
+      !! ** Purpose :   Transfert between awork array which is distributed 
+      !!      following the vertical level and the local subdomain array.
+      !!
+      !! ** Method :
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpnij)  ::  pio        ! output array
+      INTEGER                             ::   kp        ! Tag (not used with MPI
+      REAL(wp), DIMENSION(jpi,jpj)        ::  ptab       ! subdomain array input
+      !!---------------------------------------------------------------------
+#if defined key_mpp_shmem
+      !! * SHMEM version
+
+      CALL barrier()
+      CALL shmem_get( ptab, pio(1,1,npvm_me+1), jpi*jpj, kp )
+      CALL barrier()
+
+#  elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+      INTEGER :: itaille, ierror
+  
+      itaille=jpi*jpj
+
+      CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille,   &
+         &                            mpi_double_precision, kp, mpi_comm_opa, ierror )
+#endif
+
+   END SUBROUTINE mppscatter
+
+
+   SUBROUTINE mppisl_a_int( ktab, kdim )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppisl_a_int  ***
+      !!                   
+      !! ** Purpose :   Massively parallel processors
+      !!                Find the  non zero value
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in  )                  ::   kdim       ! ???
+      INTEGER, INTENT(inout), DIMENSION(kdim) ::   ktab       ! ???
+  
+#if defined key_mpp_shmem
+      !! * Local variables   (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+
+      IF( kdim > jpmppsum ) CALL ctl_stop( 'mppisl_a_int routine : kdim is too big', &
+           &                               'change jpmppsum dimension in mpp.h' )
+
+      DO ji = 1, kdim
+         niitab_shmem(ji) = ktab(ji)
+      END DO
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_min_to_all (ni11tab_shmem,niitab_shmem,kdim,0   &
+              ,0,N$PES,ni11wrk_shmem,ni11sync_shmem)
+         CALL shmem_int8_max_to_all (ni12tab_shmem,niitab_shmem,kdim,0   &
+              ,0,N$PES,ni12wrk_shmem,ni12sync_shmem)
+      ELSE
+         CALL shmem_int8_min_to_all (ni11tab_shmem,niitab_shmem,kdim,0   &
+              ,0,N$PES,ni21wrk_shmem,ni21sync_shmem)
+         CALL shmem_int8_max_to_all (ni12tab_shmem,niitab_shmem,kdim,0   &
+              ,0,N$PES,ni22wrk_shmem,ni22sync_shmem)
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      DO ji = 1, kdim
+         IF( ni11tab_shmem(ji) /= 0. ) THEN
+            ktab(ji) = ni11tab_shmem(ji)
+         ELSE
+            ktab(ji) = ni12tab_shmem(ji)
+         ENDIF
+      END DO
+  
+#  elif defined key_mpp_mpi
+      !! * Local variables   (MPI version)
+      LOGICAL  :: lcommute
+      INTEGER, DIMENSION(kdim) ::   iwork
+      INTEGER  :: mpi_isl,ierror
+  
+      lcommute = .TRUE.
+      CALL mpi_op_create( lc_isl, lcommute, mpi_isl, ierror )
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer   &
+           , mpi_isl, mpi_comm_opa, ierror )
+      ktab(:) = iwork(:)
+#endif
+
+   END SUBROUTINE mppisl_a_int
+
+
+   SUBROUTINE mppisl_int( ktab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppisl_int  ***
+      !!                   
+      !! ** Purpose :   Massively parallel processors
+      !!                Find the non zero value
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT( inout ) ::   ktab        ! 
+
+#if defined key_mpp_shmem
+      !! * Local variables   (SHMEM version)
+      INTEGER, SAVE :: ibool=0
+
+      niitab_shmem(1) = ktab
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_min_to_all (ni11tab_shmem,niitab_shmem,1,0   &
+              ,0,N$PES,ni11wrk_shmem,ni11sync_shmem)
+         CALL shmem_int8_max_to_all (ni12tab_shmem,niitab_shmem,1,0   &
+              ,0,N$PES,ni12wrk_shmem,ni12sync_shmem)
+      ELSE
+         CALL shmem_int8_min_to_all (ni11tab_shmem,niitab_shmem,1,0   &
+              ,0,N$PES,ni21wrk_shmem,ni21sync_shmem)
+         CALL shmem_int8_max_to_all (ni12tab_shmem,niitab_shmem,1,0   &
+              ,0,N$PES,ni22wrk_shmem,ni22sync_shmem)
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      IF( ni11tab_shmem(1) /= 0. ) THEN
+         ktab = ni11tab_shmem(1)
+      ELSE
+         ktab = ni12tab_shmem(1)
+      ENDIF
+  
+#  elif defined key_mpp_mpi
+  
+      !! * Local variables   (MPI version)
+      LOGICAL :: lcommute
+      INTEGER :: mpi_isl,ierror
+      INTEGER ::   iwork
+  
+      lcommute = .TRUE.
+      CALL mpi_op_create(lc_isl,lcommute,mpi_isl,ierror)
+      CALL mpi_allreduce(ktab, iwork, 1,mpi_integer   &
+           ,mpi_isl,mpi_comm_opa,ierror)
+      ktab = iwork
+#endif
+
+   END SUBROUTINE mppisl_int
+
+
+   SUBROUTINE mppmax_a_int( ktab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmax_a_int  ***
+      !! 
+      !! ** Purpose :   Find maximum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT( in  )                  ::   kdim        ! size of array
+      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab        ! input array
+      INTEGER , INTENT(in)   , OPTIONAL        ::   kcom  
+  
+#if defined key_mpp_shmem
+      !! * Local declarations    (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+  
+      IF( kdim > jpmppsum ) CALL ctl_stop( 'mppmax_a_int routine : kdim is too big', &
+           &                               'change jpmppsum dimension in mpp.h' )
+  
+      DO ji = 1, kdim
+         niltab_shmem(ji) = ktab(ji)
+      END DO
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_max_to_all (niltab_shmem,niltab_shmem,kdim,0,0   &
+              ,N$PES,nil1wrk_shmem,nil1sync_shmem )
+      ELSE
+         CALL shmem_int8_max_to_all (niltab_shmem,niltab_shmem,kdim,0,0   &
+              ,N$PES,nil2wrk_shmem,nil2sync_shmem )
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      DO ji = 1, kdim
+         ktab(ji) = niltab_shmem(ji)
+      END DO
+  
+#  elif defined key_mpp_mpi
+  
+      !! * Local variables   (MPI version)
+      INTEGER :: ierror
+      INTEGER :: localcomm
+      INTEGER, DIMENSION(kdim) ::   iwork
+
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) ) localcomm = kcom
+  
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer,   &
+           &                mpi_max, localcomm, ierror )
+  
+      ktab(:) = iwork(:)
+#endif
+
+   END SUBROUTINE mppmax_a_int
+
+
+   SUBROUTINE mppmax_int( ktab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmax_int  ***
+      !!
+      !! ** Purpose :
+      !!     Massively parallel processors
+      !!     Find maximum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(inout) ::   ktab      ! ???
+      INTEGER, INTENT(in), OPTIONAL ::   kcom      ! ???
+  
+      !! * Local declarations
+
+#if defined key_mpp_shmem
+
+      !! * Local variables   (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+  
+      niltab_shmem(1) = ktab
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_max_to_all (niltab_shmem,niltab_shmem, 1,0,0   &
+              ,N$PES,nil1wrk_shmem,nil1sync_shmem )
+      ELSE
+         CALL shmem_int8_max_to_all (niltab_shmem,niltab_shmem, 1,0,0   &
+              ,N$PES,nil2wrk_shmem,nil2sync_shmem )
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      ktab = niltab_shmem(1)
+  
+#  elif defined key_mpp_mpi
+
+      !! * Local variables   (MPI version)
+      INTEGER ::  ierror, iwork
+      INTEGER :: localcomm
+
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) ) localcomm = kcom
+
+      CALL mpi_allreduce(ktab,iwork, 1,mpi_integer   &
+           &              ,mpi_max,localcomm,ierror)
+  
+      ktab = iwork
+#endif
+
+   END SUBROUTINE mppmax_int
+
+
+   SUBROUTINE mppmin_a_int( ktab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmin_a_int  ***
+      !! 
+      !! ** Purpose :   Find minimum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT( in  )                  ::   kdim        ! size of array
+      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab        ! input array
+      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom        ! input array
+  
+#if defined key_mpp_shmem
+      !! * Local declarations    (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+  
+      IF( kdim > jpmppsum ) CALL ctl_stop( 'mppmin_a_int routine : kdim is too big', &
+           &                               'change jpmppsum dimension in mpp.h' )
+  
+      DO ji = 1, kdim
+         niltab_shmem(ji) = ktab(ji)
+      END DO
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_min_to_all (niltab_shmem,niltab_shmem,kdim,0,0   &
+              ,N$PES,nil1wrk_shmem,nil1sync_shmem )
+      ELSE
+         CALL shmem_int8_min_to_all (niltab_shmem,niltab_shmem,kdim,0,0   &
+              ,N$PES,nil2wrk_shmem,nil2sync_shmem )
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      DO ji = 1, kdim
+         ktab(ji) = niltab_shmem(ji)
+      END DO
+  
+#  elif defined key_mpp_mpi
+  
+      !! * Local variables   (MPI version)
+      INTEGER :: ierror
+      INTEGER :: localcomm
+      INTEGER, DIMENSION(kdim) ::   iwork
+  
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) ) localcomm = kcom
+
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer,   &
+           &                mpi_min, localcomm, ierror )
+  
+      ktab(:) = iwork(:)
+#endif
+
+   END SUBROUTINE mppmin_a_int
+
+
+   SUBROUTINE mppmin_int( ktab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmin_int  ***
+      !!
+      !! ** Purpose :
+      !!     Massively parallel processors
+      !!     Find minimum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(inout) ::   ktab      ! ???
+  
+      !! * Local declarations
+
+#if defined key_mpp_shmem
+
+      !! * Local variables   (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+  
+      niltab_shmem(1) = ktab
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_min_to_all (niltab_shmem,niltab_shmem, 1,0,0   &
+              ,N$PES,nil1wrk_shmem,nil1sync_shmem )
+      ELSE
+         CALL shmem_int8_min_to_all (niltab_shmem,niltab_shmem, 1,0,0   &
+              ,N$PES,nil2wrk_shmem,nil2sync_shmem )
+      ENDIF
+      CALL  barrier()
+      ibool=ibool+1
+      ibool=MOD( ibool,2)
+      ktab = niltab_shmem(1)
+  
+#  elif defined key_mpp_mpi
+
+      !! * Local variables   (MPI version)
+      INTEGER ::  ierror, iwork
+  
+      CALL mpi_allreduce(ktab,iwork, 1,mpi_integer   &
+           &              ,mpi_min,mpi_comm_opa,ierror)
+  
+      ktab = iwork
+#endif
+
+   END SUBROUTINE mppmin_int
+
+
+   SUBROUTINE mppsum_a_int( ktab, kdim )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsum_a_int  ***
+      !!                    
+      !! ** Purpose :   Massively parallel processors
+      !!                Global integer sum
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in  )                   ::   kdim      ! ???
+      INTEGER, INTENT(inout), DIMENSION (kdim) ::   ktab      ! ???
+  
+#if defined key_mpp_shmem
+
+      !! * Local variables   (SHMEM version)
+      INTEGER :: ji
+      INTEGER, SAVE :: ibool=0
+
+      IF( kdim > jpmppsum ) CALL ctl_stop( 'mppsum_a_int routine : kdim is too big', &
+           &                               'change jpmppsum dimension in mpp.h' )
+
+      DO ji = 1, kdim
+         nistab_shmem(ji) = ktab(ji)
+      END DO
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_int8_sum_to_all(nistab_shmem,nistab_shmem,kdim,0,0,   &
+              N$PES,nis1wrk_shmem,nis1sync_shmem)
+      ELSE
+         CALL shmem_int8_sum_to_all(nistab_shmem,nistab_shmem,kdim,0,0,   &
+              N$PES,nis2wrk_shmem,nis2sync_shmem)
+      ENDIF
+      CALL  barrier()
+      ibool = ibool + 1
+      ibool = MOD( ibool, 2 )
+      DO ji = 1, kdim
+         ktab(ji) = nistab_shmem(ji)
+      END DO
+  
+#  elif defined key_mpp_mpi
+
+      !! * Local variables   (MPI version)
+      INTEGER :: ierror
+      INTEGER, DIMENSION (kdim) ::  iwork
+  
+      CALL mpi_allreduce(ktab, iwork,kdim,mpi_integer   &
+           ,mpi_sum,mpi_comm_opa,ierror)
+  
+      ktab(:) = iwork(:)
+#endif
+
+   END SUBROUTINE mppsum_a_int
+
+
+  SUBROUTINE mppsum_int( ktab )
+    !!----------------------------------------------------------------------
+    !!                 ***  routine mppsum_int  ***
+    !!                  
+    !! ** Purpose :   Global integer sum
+    !!
+    !!----------------------------------------------------------------------
+    !! * Arguments
+    INTEGER, INTENT(inout) ::   ktab
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER, SAVE :: ibool=0
+
+    nistab_shmem(1) = ktab
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_int8_sum_to_all(nistab_shmem,nistab_shmem, 1,0,0,   &
+            N$PES,nis1wrk_shmem,nis1sync_shmem)
+    ELSE
+       CALL shmem_int8_sum_to_all(nistab_shmem,nistab_shmem, 1,0,0,   &
+            N$PES,nis2wrk_shmem,nis2sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    ktab = nistab_shmem(1)
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER :: ierror, iwork
+
+    CALL mpi_allreduce(ktab,iwork, 1,mpi_integer   &
+         ,mpi_sum,mpi_comm_opa,ierror)
+
+    ktab = iwork
+
+#endif
+
+  END SUBROUTINE mppsum_int
+
+
+  SUBROUTINE mppisl_a_real( ptab, kdim )
+    !!----------------------------------------------------------------------
+    !!                 ***  routine mppisl_a_real  ***
+    !!         
+    !! ** Purpose :   Massively parallel processors
+    !!           Find the non zero island barotropic stream function value
+    !!
+    !!   Modifications:
+    !!        !  93-09 (M. Imbard)
+    !!        !  96-05 (j. Escobar)
+    !!        !  98-05 (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI 
+    !!----------------------------------------------------------------------
+    INTEGER , INTENT( in  )                  ::   kdim      ! ???
+    REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab      ! ???
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER :: ji
+    INTEGER, SAVE :: ibool=0
+
+    IF( kdim > jpmppsum ) CALL ctl_stop( 'mppisl_a_real routine : kdim is too big', &
+         &                               'change jpmppsum dimension in mpp.h' )
+
+    DO ji = 1, kdim
+       wiltab_shmem(ji) = ptab(ji)
+    END DO
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_min_to_all (wi1tab_shmem,wiltab_shmem,kdim,0   &
+            ,0,N$PES,wi11wrk_shmem,ni11sync_shmem)
+       CALL shmem_real8_max_to_all (wi2tab_shmem,wiltab_shmem,kdim,0   &
+            ,0,N$PES,wi12wrk_shmem,ni12sync_shmem)
+    ELSE
+       CALL shmem_real8_min_to_all (wi1tab_shmem,wiltab_shmem,kdim,0   &
+            ,0,N$PES,wi21wrk_shmem,ni21sync_shmem)
+       CALL shmem_real8_max_to_all (wi2tab_shmem,wiltab_shmem,kdim,0   &
+            ,0,N$PES,wi22wrk_shmem,ni22sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    DO ji = 1, kdim
+       IF(wi1tab_shmem(ji) /= 0. ) THEN
+          ptab(ji) = wi1tab_shmem(ji)
+       ELSE
+          ptab(ji) = wi2tab_shmem(ji)
+       ENDIF
+    END DO
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    LOGICAL ::   lcommute = .TRUE.
+    INTEGER ::   mpi_isl, ierror
+    REAL(wp), DIMENSION(kdim) ::  zwork
+
+    CALL mpi_op_create(lc_isl,lcommute,mpi_isl,ierror)
+    CALL mpi_allreduce(ptab, zwork,kdim,mpi_double_precision   &
+         ,mpi_isl,mpi_comm_opa,ierror)
+    ptab(:) = zwork(:)
+
+#endif
+
+  END SUBROUTINE mppisl_a_real
+
+
+   SUBROUTINE mppisl_real( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppisl_real  ***
+      !!                  
+      !! ** Purpose :   Massively parallel processors
+      !!       Find the  non zero island barotropic stream function value
+      !!
+      !!     Modifications:
+      !!        !  93-09 (M. Imbard)
+      !!        !  96-05 (j. Escobar)
+      !!        !  98-05 (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI 
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(inout) ::   ptab
+
+#if defined key_mpp_shmem
+
+      !! * Local variables   (SHMEM version)
+      INTEGER, SAVE :: ibool=0
+
+      wiltab_shmem(1) = ptab
+      CALL  barrier()
+      IF(ibool == 0 ) THEN 
+         CALL shmem_real8_min_to_all (wi1tab_shmem,wiltab_shmem, 1,0   &
+            ,0,N$PES,wi11wrk_shmem,ni11sync_shmem)
+         CALL shmem_real8_max_to_all (wi2tab_shmem,wiltab_shmem, 1,0   &
+            ,0,N$PES,wi12wrk_shmem,ni12sync_shmem)
+      ELSE
+         CALL shmem_real8_min_to_all (wi1tab_shmem,wiltab_shmem, 1,0   &
+            ,0,N$PES,wi21wrk_shmem,ni21sync_shmem)
+         CALL shmem_real8_max_to_all (wi2tab_shmem,wiltab_shmem, 1,0   &
+            ,0,N$PES,wi22wrk_shmem,ni22sync_shmem)
+      ENDIF
+      CALL barrier()
+      ibool = ibool + 1
+      ibool = MOD( ibool, 2 )
+      IF( wi1tab_shmem(1) /= 0. ) THEN
+         ptab = wi1tab_shmem(1)
+      ELSE
+         ptab = wi2tab_shmem(1)
+      ENDIF
+
+#  elif defined key_mpp_mpi
+
+      !! * Local variables   (MPI version)
+      LOGICAL  ::   lcommute = .TRUE.
+      INTEGER  ::   mpi_isl, ierror
+      REAL(wp) ::   zwork
+
+      CALL mpi_op_create( lc_isl, lcommute, mpi_isl, ierror )
+      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision,   &
+         &                                mpi_isl  , mpi_comm_opa, ierror )
+      ptab = zwork
+
+#endif
+
+   END SUBROUTINE mppisl_real
+
+
+  FUNCTION lc_isl( py, px, kdim )
+    INTEGER :: kdim
+    REAL(wp), DIMENSION(kdim) ::  px, py
+    INTEGER :: kdtatyp, ji
+    INTEGER :: lc_isl
+    DO ji = 1, kdim
+       IF( py(ji) /= 0. )   px(ji) = py(ji)
+    END DO
+    lc_isl=0
+
+  END FUNCTION lc_isl
+
+
+  SUBROUTINE mppmax_a_real( ptab, kdim, kcom )
+    !!----------------------------------------------------------------------
+    !!                 ***  routine mppmax_a_real  ***
+    !!                  
+    !! ** Purpose :   Maximum
+    !!
+    !!----------------------------------------------------------------------
+    !! * Arguments
+    INTEGER , INTENT( in  )                  ::   kdim
+    REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
+    INTEGER , INTENT( in  ), OPTIONAL        ::   kcom
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER :: ji
+    INTEGER, SAVE :: ibool=0
+
+    IF( kdim > jpmppsum ) CALL ctl_stop( 'mppmax_a_real routine : kdim is too big', &
+         &                               'change jpmppsum dimension in mpp.h' )
+
+    DO ji = 1, kdim
+       wintab_shmem(ji) = ptab(ji)
+    END DO
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_max_to_all (wintab_shmem,wintab_shmem,kdim,0   &
+            ,0,N$PES,wi1wrk_shmem,ni1sync_shmem)
+    ELSE
+       CALL shmem_real8_max_to_all (wintab_shmem,wintab_shmem,kdim,0   &
+            ,0,N$PES,wi2wrk_shmem,ni2sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    DO ji = 1, kdim
+       ptab(ji) = wintab_shmem(ji)
+    END DO
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER :: ierror
+    INTEGER :: localcomm
+    REAL(wp), DIMENSION(kdim) ::  zwork
+
+    localcomm = mpi_comm_opa
+    IF( PRESENT(kcom) ) localcomm = kcom
+
+    CALL mpi_allreduce(ptab, zwork,kdim,mpi_double_precision   &
+         ,mpi_max,localcomm,ierror)
+    ptab(:) = zwork(:)
+
+#endif
+
+  END SUBROUTINE mppmax_a_real
+
+
+  SUBROUTINE mppmax_real( ptab, kcom )
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppmax_real  ***
+    !!                    
+    !! ** Purpose :   Maximum
+    !!
+    !!----------------------------------------------------------------------
+    !! * Arguments
+    REAL(wp), INTENT(inout) ::   ptab      ! ???
+    INTEGER , INTENT( in  ), OPTIONAL ::   kcom      ! ???
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER, SAVE :: ibool=0
+
+    wintab_shmem(1) = ptab
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_max_to_all (wintab_shmem,wintab_shmem, 1,0   &
+            ,0,N$PES,wi1wrk_shmem,ni1sync_shmem)
+    ELSE
+       CALL shmem_real8_max_to_all (wintab_shmem,wintab_shmem, 1,0   &
+            ,0,N$PES,wi2wrk_shmem,ni2sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    ptab = wintab_shmem(1)
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER  ::   ierror
+    INTEGER  ::   localcomm
+    REAL(wp) ::   zwork
+
+    localcomm = mpi_comm_opa 
+    IF( PRESENT(kcom) ) localcomm = kcom
+
+    CALL mpi_allreduce( ptab, zwork  , 1             , mpi_double_precision,   &
+       &                      mpi_max, localcomm, ierror     )
+    ptab = zwork
+
+#endif
+
+  END SUBROUTINE mppmax_real
+
+
+  SUBROUTINE mppmin_a_real( ptab, kdim, kcom )
+    !!----------------------------------------------------------------------
+    !!                 ***  routine mppmin_a_real  ***
+    !!                  
+    !! ** Purpose :   Minimum
+    !!
+    !!-----------------------------------------------------------------------
+    !! * Arguments
+    INTEGER , INTENT( in  )                  ::   kdim
+    REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
+    INTEGER , INTENT( in  ), OPTIONAL        ::   kcom
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER :: ji
+    INTEGER, SAVE :: ibool=0
+
+    IF( kdim > jpmppsum ) CALL ctl_stop( 'mpprmin routine : kdim is too big', &
+         &                               'change jpmppsum dimension in mpp.h' )
+
+    DO ji = 1, kdim
+       wintab_shmem(ji) = ptab(ji)
+    END DO
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_min_to_all (wintab_shmem,wintab_shmem,kdim,0   &
+            ,0,N$PES,wi1wrk_shmem,ni1sync_shmem)
+    ELSE
+       CALL shmem_real8_min_to_all (wintab_shmem,wintab_shmem,kdim,0   &
+            ,0,N$PES,wi2wrk_shmem,ni2sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    DO ji = 1, kdim
+       ptab(ji) = wintab_shmem(ji)
+    END DO
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER :: ierror
+    INTEGER :: localcomm 
+    REAL(wp), DIMENSION(kdim) ::   zwork
+
+    localcomm = mpi_comm_opa 
+    IF( PRESENT(kcom) ) localcomm = kcom
+
+    CALL mpi_allreduce(ptab, zwork,kdim,mpi_double_precision   &
+         ,mpi_min,localcomm,ierror)
+    ptab(:) = zwork(:)
+
+#endif
+
+  END SUBROUTINE mppmin_a_real
+
+
+  SUBROUTINE mppmin_real( ptab, kcom )
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppmin_real  ***
+    !! 
+    !! ** Purpose :   minimum in Massively Parallel Processing
+    !!                REAL scalar case
+    !!
+    !!-----------------------------------------------------------------------
+    !! * Arguments
+    REAL(wp), INTENT( inout ) ::   ptab        ! 
+    INTEGER , INTENT(  in   ), OPTIONAL :: kcom
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER, SAVE :: ibool=0
+
+    wintab_shmem(1) = ptab
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_min_to_all (wintab_shmem,wintab_shmem, 1,0   &
+            ,0,N$PES,wi1wrk_shmem,ni1sync_shmem)
+    ELSE
+       CALL shmem_real8_min_to_all (wintab_shmem,wintab_shmem, 1,0   &
+            ,0,N$PES,wi2wrk_shmem,ni2sync_shmem)
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    ptab = wintab_shmem(1)
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER  ::   ierror
+    REAL(wp) ::   zwork
+    INTEGER :: localcomm
+
+    localcomm = mpi_comm_opa 
+    IF( PRESENT(kcom) ) localcomm = kcom
+
+    CALL mpi_allreduce( ptab, zwork, 1,mpi_double_precision   &
+         &               ,mpi_min,localcomm,ierror)
+    ptab = zwork
+
+#endif
+
+  END SUBROUTINE mppmin_real
+
+
+  SUBROUTINE mppsum_a_real( ptab, kdim, kcom )
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppsum_a_real  ***
+    !! 
+    !! ** Purpose :   global sum in Massively Parallel Processing
+    !!                REAL ARRAY argument case
+    !!
+    !!-----------------------------------------------------------------------
+    INTEGER , INTENT( in )                     ::   kdim      ! size of ptab
+    REAL(wp), DIMENSION(kdim), INTENT( inout ) ::   ptab      ! input array
+    INTEGER , INTENT( in ), OPTIONAL           :: kcom
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER :: ji
+    INTEGER, SAVE :: ibool=0
+
+    IF( kdim > jpmppsum ) CALL ctl_stop( 'mppsum_a_real routine : kdim is too big', &
+         &                               'change jpmppsum dimension in mpp.h' )
+
+    DO ji = 1, kdim
+       wrstab_shmem(ji) = ptab(ji)
+    END DO
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_sum_to_all (wrstab_shmem,wrstab_shmem,kdim,0   &
+            ,0,N$PES,wrs1wrk_shmem,nrs1sync_shmem )
+    ELSE
+       CALL shmem_real8_sum_to_all (wrstab_shmem,wrstab_shmem,kdim,0   &
+            ,0,N$PES,wrs2wrk_shmem,nrs2sync_shmem )
+    ENDIF
+    CALL  barrier()
+    ibool=ibool+1
+    ibool=MOD( ibool,2)
+    DO ji = 1, kdim
+       ptab(ji) = wrstab_shmem(ji)
+    END DO
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER                   ::   ierror    ! temporary integer
+    INTEGER                   ::   localcomm 
+    REAL(wp), DIMENSION(kdim) ::   zwork     ! temporary workspace 
+    
+
+    localcomm = mpi_comm_opa 
+    IF( PRESENT(kcom) ) localcomm = kcom
+
+    CALL mpi_allreduce(ptab, zwork,kdim,mpi_double_precision   &
+         &              ,mpi_sum,localcomm,ierror)
+    ptab(:) = zwork(:)
+
+#endif
+
+  END SUBROUTINE mppsum_a_real
+
+
+  SUBROUTINE mppsum_real( ptab, kcom )
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppsum_real  ***
+    !!              
+    !! ** Purpose :   global sum in Massively Parallel Processing
+    !!                SCALAR argument case
+    !!
+    !!-----------------------------------------------------------------------
+    REAL(wp), INTENT(inout) ::   ptab        ! input scalar
+    INTEGER , INTENT( in  ), OPTIONAL :: kcom
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    INTEGER, SAVE :: ibool=0
+
+    wrstab_shmem(1) = ptab
+    CALL  barrier()
+    IF(ibool == 0 ) THEN 
+       CALL shmem_real8_sum_to_all (wrstab_shmem,wrstab_shmem, 1,0   &
+            ,0,N$PES,wrs1wrk_shmem,nrs1sync_shmem )
+    ELSE
+       CALL shmem_real8_sum_to_all (wrstab_shmem,wrstab_shmem, 1,0   &
+            ,0,N$PES,wrs2wrk_shmem,nrs2sync_shmem )
+    ENDIF
+    CALL  barrier()
+    ibool = ibool + 1
+    ibool = MOD( ibool, 2 )
+    ptab = wrstab_shmem(1)
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER  ::   ierror
+    INTEGER  ::   localcomm 
+    REAL(wp) ::   zwork
+
+   localcomm = mpi_comm_opa 
+   IF( PRESENT(kcom) ) localcomm = kcom
+ 
+   CALL mpi_allreduce(ptab, zwork, 1,mpi_double_precision   &
+         &              ,mpi_sum,localcomm,ierror)
+    ptab = zwork
+
+#endif
+
+  END SUBROUTINE mppsum_real
+
+  SUBROUTINE mpp_minloc2d(ptab, pmask, pmin, ki,kj )
+    !!------------------------------------------------------------------------
+    !!             ***  routine mpp_minloc  ***
+    !!
+    !! ** Purpose :  Compute the global minimum of an array ptab
+    !!              and also give its global position
+    !!
+    !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
+    !!
+    !! ** Arguments : I : ptab =local 2D array
+    !!                O : pmin = global minimum
+    !!                O : ki,kj = global position of minimum
+    !!
+    !! ** Author : J.M. Molines 10/10/2004
+    !!--------------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_minloc not yet available in SHMEM' )
+# elif key_mpp_mpi
+    !! * Arguments
+    REAL(wp), DIMENSION (jpi,jpj), INTENT (in)  :: ptab ,& ! Local 2D array
+         &                                         pmask   ! Local mask
+    REAL(wp)                     , INTENT (out) :: pmin    ! Global minimum of ptab
+    INTEGER                      , INTENT (out) :: ki,kj   ! index of minimum in global frame
+
+    !! * Local variables
+    REAL(wp) :: zmin   ! local minimum
+    REAL(wp) ,DIMENSION(2,1) :: zain, zaout
+    INTEGER, DIMENSION (2)  :: ilocs
+    INTEGER :: ierror
+
+
+    zmin  = MINVAL( ptab(:,:) , mask= pmask == 1.e0 )
+    ilocs = MINLOC( ptab(:,:) , mask= pmask == 1.e0 )
+
+    ki = ilocs(1) + nimpp - 1
+    kj = ilocs(2) + njmpp - 1
+
+    zain(1,:)=zmin
+    zain(2,:)=ki+10000.*kj
+
+    CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OPA,ierror)
+
+    pmin=zaout(1,1)
+    kj= INT(zaout(2,1)/10000.)
+    ki= INT(zaout(2,1) - 10000.*kj )
+#endif
+
+  END SUBROUTINE mpp_minloc2d
+
+
+  SUBROUTINE mpp_minloc3d(ptab, pmask, pmin, ki,kj ,kk)
+    !!------------------------------------------------------------------------
+    !!             ***  routine mpp_minloc  ***
+    !!
+    !! ** Purpose :  Compute the global minimum of an array ptab
+    !!              and also give its global position
+    !!
+    !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
+    !!
+    !! ** Arguments : I : ptab =local 2D array
+    !!                O : pmin = global minimum
+    !!                O : ki,kj = global position of minimum
+    !!
+    !! ** Author : J.M. Molines 10/10/2004
+    !!--------------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_minloc not yet available in SHMEM' )
+# elif key_mpp_mpi
+    !! * Arguments
+    REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT (in)  :: ptab ,& ! Local 2D array
+         &                                         pmask   ! Local mask
+    REAL(wp)                     , INTENT (out) :: pmin    ! Global minimum of ptab
+    INTEGER                      , INTENT (out) :: ki,kj,kk ! index of minimum in global frame
+
+    !! * Local variables
+    REAL(wp) :: zmin   ! local minimum
+    REAL(wp) ,DIMENSION(2,1) :: zain, zaout
+    INTEGER, DIMENSION (3)  :: ilocs
+    INTEGER :: ierror
+
+
+    zmin  = MINVAL( ptab(:,:,:) , mask= pmask == 1.e0 )
+    ilocs = MINLOC( ptab(:,:,:) , mask= pmask == 1.e0 )
+
+    ki = ilocs(1) + nimpp - 1
+    kj = ilocs(2) + njmpp - 1
+    kk = ilocs(3)
+
+    zain(1,:)=zmin
+    zain(2,:)=ki+10000.*kj+100000000.*kk
+
+    CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OPA,ierror)
+
+    pmin=zaout(1,1)
+    kk= INT(zaout(2,1)/100000000.)
+    kj= INT(zaout(2,1) - kk * 100000000. )/10000
+    ki= INT(zaout(2,1) - kk * 100000000. -kj * 10000. )
+#endif
+
+  END SUBROUTINE mpp_minloc3d
+
+
+  SUBROUTINE mpp_maxloc2d(ptab, pmask, pmax, ki,kj )
+    !!------------------------------------------------------------------------
+    !!             ***  routine mpp_maxloc  ***
+    !!
+    !! ** Purpose :  Compute the global maximum of an array ptab
+    !!              and also give its global position
+    !!
+    !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
+    !!
+    !! ** Arguments : I : ptab =local 2D array
+    !!                O : pmax = global maximum
+    !!                O : ki,kj = global position of maximum
+    !!
+    !! ** Author : J.M. Molines 10/10/2004
+    !!--------------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_maxloc not yet available in SHMEM' )
+# elif key_mpp_mpi
+    !! * Arguments
+    REAL(wp), DIMENSION (jpi,jpj), INTENT (in)  :: ptab ,& ! Local 2D array
+         &                                         pmask   ! Local mask
+    REAL(wp)                     , INTENT (out) :: pmax    ! Global maximum of ptab
+    INTEGER                      , INTENT (out) :: ki,kj   ! index of maximum in global frame
+
+    !! * Local variables
+    REAL(wp) :: zmax   ! local maximum
+    REAL(wp) ,DIMENSION(2,1) :: zain, zaout
+    INTEGER, DIMENSION (2)  :: ilocs
+    INTEGER :: ierror
+
+
+    zmax  = MAXVAL( ptab(:,:) , mask= pmask == 1.e0 )
+    ilocs = MAXLOC( ptab(:,:) , mask= pmask == 1.e0 )
+
+    ki = ilocs(1) + nimpp - 1
+    kj = ilocs(2) + njmpp - 1
+
+    zain(1,:)=zmax
+    zain(2,:)=ki+10000.*kj
+
+    CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OPA,ierror)
+
+    pmax=zaout(1,1)
+    kj= INT(zaout(2,1)/10000.)
+    ki= INT(zaout(2,1) - 10000.*kj )
+#endif
+
+  END SUBROUTINE mpp_maxloc2d
+
+  SUBROUTINE mpp_maxloc3d(ptab, pmask, pmax, ki,kj,kk )
+    !!------------------------------------------------------------------------
+    !!             ***  routine mpp_maxloc  ***
+    !!
+    !! ** Purpose :  Compute the global maximum of an array ptab
+    !!              and also give its global position
+    !!
+    !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
+    !!
+    !! ** Arguments : I : ptab =local 2D array
+    !!                O : pmax = global maximum
+    !!                O : ki,kj = global position of maximum
+    !!
+    !! ** Author : J.M. Molines 10/10/2004
+    !!--------------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_maxloc not yet available in SHMEM' )
+# elif key_mpp_mpi
+    !! * Arguments
+    REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT (in)  :: ptab ,& ! Local 2D array
+         &                                         pmask   ! Local mask
+    REAL(wp)                     , INTENT (out) :: pmax    ! Global maximum of ptab
+    INTEGER                      , INTENT (out) :: ki,kj,kk   ! index of maximum in global frame
+
+    !! * Local variables
+    REAL(wp) :: zmax   ! local maximum
+    REAL(wp) ,DIMENSION(2,1) :: zain, zaout
+    INTEGER, DIMENSION (3)  :: ilocs
+    INTEGER :: ierror
+
+
+    zmax  = MAXVAL( ptab(:,:,:) , mask= pmask == 1.e0 )
+    ilocs = MAXLOC( ptab(:,:,:) , mask= pmask == 1.e0 )
+
+    ki = ilocs(1) + nimpp - 1
+    kj = ilocs(2) + njmpp - 1
+    kk = ilocs(3)
+
+    zain(1,:)=zmax
+    zain(2,:)=ki+10000.*kj+100000000.*kk
+
+    CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OPA,ierror)
+
+    pmax=zaout(1,1)
+    kk= INT(zaout(2,1)/100000000.)
+    kj= INT(zaout(2,1) - kk * 100000000. )/10000
+    ki= INT(zaout(2,1) - kk * 100000000. -kj * 10000. )
+#endif
+
+  END SUBROUTINE mpp_maxloc3d
+
+  SUBROUTINE mppsync()
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppsync  ***
+    !!                   
+    !! ** Purpose :   Massively parallel processors, synchroneous
+    !!
+    !!-----------------------------------------------------------------------
+
+#if defined key_mpp_shmem
+
+    !! * Local variables   (SHMEM version)
+    CALL barrier()
+
+#  elif defined key_mpp_mpi
+
+    !! * Local variables   (MPI version)
+    INTEGER :: ierror
+
+    CALL mpi_barrier(mpi_comm_opa,ierror)
+
+#endif
+
+  END SUBROUTINE mppsync
+
+
+  SUBROUTINE mppstop
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppstop  ***
+    !!                   
+    !! ** purpose :   Stop massilively parallel processors method
+    !!
+    !!----------------------------------------------------------------------
+    !! * Local declarations
+    INTEGER ::   info
+    !!----------------------------------------------------------------------
+
+    ! 1. Mpp synchroneus
+    ! ------------------
+
+    CALL mppsync
+#if defined key_mpp_mpi
+    CALL mpi_finalize( info )
+#endif
+
+  END SUBROUTINE mppstop
+
+
+  SUBROUTINE mppobc( ptab, kd1, kd2, kl, kk, ktype, kij )
+    !!----------------------------------------------------------------------
+    !!                  ***  routine mppobc  ***
+    !! 
+    !! ** Purpose :   Message passing manadgement for open boundary
+    !!     conditions array
+    !!
+    !! ** Method  :   Use mppsend and mpprecv function for passing mask
+    !!       between processors following neighboring subdomains.
+    !!       domain parameters
+    !!                    nlci   : first dimension of the local subdomain
+    !!                    nlcj   : second dimension of the local subdomain
+    !!                    nbondi : mark for "east-west local boundary"
+    !!                    nbondj : mark for "north-south local boundary"
+    !!                    noea   : number for local neighboring processors 
+    !!                    nowe   : number for local neighboring processors
+    !!                    noso   : number for local neighboring processors
+    !!                    nono   : number for local neighboring processors
+    !!
+    !! History :
+    !!        !  98-07 (J.M. Molines) Open boundary conditions
+    !!----------------------------------------------------------------------
+    !! * Arguments
+    INTEGER , INTENT( in ) ::   &
+         kd1, kd2,   &  ! starting and ending indices
+         kl ,        &  ! index of open boundary
+         kk,         &  ! vertical dimension
+         ktype,      &  ! define north/south or east/west cdt
+         !              !  = 1  north/south  ;  = 2  east/west
+         kij            ! horizontal dimension
+    REAL(wp), DIMENSION(kij,kk), INTENT( inout )  ::   &
+         ptab           ! variable array
+
+    !! * Local variables
+    INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
+    INTEGER  ::   &
+         iipt0, iipt1, ilpt1,     &  ! temporary integers
+         ijpt0, ijpt1,            &  !    "          "
+         imigr, iihom, ijhom         !    "          "
+    INTEGER ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+    INTEGER ::   ml_stat(MPI_STATUS_SIZE)     ! for key_mpi_isend
+    REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ztab                        ! temporary workspace
+    !!----------------------------------------------------------------------
+
+
+    ! boundary condition initialization
+    ! ---------------------------------
+
+    ztab(:,:) = 0.e0
+
+    IF( ktype==1 ) THEN                                  ! north/south boundaries
+       iipt0 = MAX( 1, MIN(kd1 - nimpp+1, nlci     ) )
+       iipt1 = MAX( 0, MIN(kd2 - nimpp+1, nlci - 1 ) )
+       ilpt1 = MAX( 1, MIN(kd2 - nimpp+1, nlci     ) )
+       ijpt0 = MAX( 1, MIN(kl  - njmpp+1, nlcj     ) )
+       ijpt1 = MAX( 0, MIN(kl  - njmpp+1, nlcj - 1 ) )
+    ELSEIF( ktype==2 ) THEN                              ! east/west boundaries
+       iipt0 = MAX( 1, MIN(kl  - nimpp+1, nlci     ) )
+       iipt1 = MAX( 0, MIN(kl  - nimpp+1, nlci - 1 ) )
+       ijpt0 = MAX( 1, MIN(kd1 - njmpp+1, nlcj     ) )
+       ijpt1 = MAX( 0, MIN(kd2 - njmpp+1, nlcj - 1 ) )
+       ilpt1 = MAX( 1, MIN(kd2 - njmpp+1, nlcj     ) )
+    ELSE
+       CALL ctl_stop( 'mppobc: bad ktype' )
+    ENDIF
+
+    DO jk = 1, kk
+       IF( ktype==1 ) THEN                               ! north/south boundaries
+          DO jj = ijpt0, ijpt1
+             DO ji = iipt0, iipt1
+                ztab(ji,jj) = ptab(ji,jk)
+             END DO
+          END DO
+       ELSEIF( ktype==2 ) THEN                           ! east/west boundaries
+          DO jj = ijpt0, ijpt1
+             DO ji = iipt0, iipt1
+                ztab(ji,jj) = ptab(jj,jk)
+             END DO
+          END DO
+       ENDIF
+
+
+       ! 1. East and west directions
+       ! ---------------------------
+
+       ! 1.1 Read Dirichlet lateral conditions
+
+       IF( nbondi /= 2 ) THEN
+          iihom = nlci-nreci
+
+          DO jl = 1, jpreci
+             t2ew(:,jl,1) = ztab(jpreci+jl,:)
+             t2we(:,jl,1) = ztab(iihom +jl,:)
+          END DO
+       ENDIF
+
+       ! 1.2 Migrations
+
+#if defined key_mpp_shmem
+       !! *  (SHMEM version)
+       imigr=jpreci*jpj*jpbyt
+
+       IF( nbondi == -1 ) THEN
+          CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr/jpbyt, noea )
+       ELSEIF( nbondi == 0 ) THEN
+          CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr/jpbyt, nowe )
+          CALL shmem_put( t2we(1,1,2), t2we(1,1,1), imigr/jpbyt, noea )
+       ELSEIF( nbondi == 1 ) THEN
+          CALL shmem_put( t2ew(1,1,2), t2ew(1,1,1), imigr/jpbyt, nowe )
+       ENDIF
+       CALL barrier()
+       CALL shmem_udcflush()
+
+#  elif key_mpp_mpi
+       !! * (MPI version)
+
+       imigr=jpreci*jpj
+
+       IF( nbondi == -1 ) THEN
+          CALL mppsend(2,t2we(1,1,1),imigr,noea, ml_req1)
+          CALL mpprecv(1,t2ew(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       ELSEIF( nbondi == 0 ) THEN
+          CALL mppsend(1,t2ew(1,1,1),imigr,nowe, ml_req1)
+          CALL mppsend(2,t2we(1,1,1),imigr,noea, ml_req2)
+          CALL mpprecv(1,t2ew(1,1,2),imigr)
+          CALL mpprecv(2,t2we(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+          IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+       ELSEIF( nbondi == 1 ) THEN
+          CALL mppsend(1,t2ew(1,1,1),imigr,nowe, ml_req1)
+          CALL mpprecv(2,t2we(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       ENDIF
+#endif
+
+
+       ! 1.3 Write Dirichlet lateral conditions
+
+       iihom = nlci-jpreci
+       IF( nbondi == 0 .OR. nbondi == 1 ) THEN
+          DO jl = 1, jpreci
+             ztab(jl,:) = t2we(:,jl,2)
+          END DO
+       ENDIF
+
+       IF( nbondi == -1 .OR. nbondi == 0 ) THEN
+          DO jl = 1, jpreci
+             ztab(iihom+jl,:) = t2ew(:,jl,2)
+          END DO
+       ENDIF
+
+
+       ! 2. North and south directions
+       ! -----------------------------
+
+       ! 2.1 Read Dirichlet lateral conditions
+
+       IF( nbondj /= 2 ) THEN
+          ijhom = nlcj-nrecj
+          DO jl = 1, jprecj
+             t2sn(:,jl,1) = ztab(:,ijhom +jl)
+             t2ns(:,jl,1) = ztab(:,jprecj+jl)
+          END DO
+       ENDIF
+
+       ! 2.2 Migrations
+
+#if defined key_mpp_shmem
+       !! * SHMEM version
+
+       imigr=jprecj*jpi*jpbyt
+
+       IF( nbondj == -1 ) THEN
+          CALL shmem_put( t2sn(1,1,2), t2sn(1,1,1), imigr/jpbyt, nono )
+       ELSEIF( nbondj == 0 ) THEN
+          CALL shmem_put( t2ns(1,1,2), t2ns(1,1,1), imigr/jpbyt, noso )
+          CALL shmem_put( t2sn(1,1,2), t2sn(1,1,1), imigr/jpbyt, nono )
+       ELSEIF( nbondj == 1 ) THEN
+          CALL shmem_put( t2ns(1,1,2), t2ns(1,1,1), imigr/jpbyt, noso )
+       ENDIF
+       CALL barrier()
+       CALL shmem_udcflush()
+
+#  elif key_mpp_mpi
+       !! * Local variables   (MPI version)
+
+       imigr=jprecj*jpi
+
+       IF( nbondj == -1 ) THEN
+          CALL mppsend(4,t2sn(1,1,1),imigr,nono, ml_req1)
+          CALL mpprecv(3,t2ns(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       ELSEIF( nbondj == 0 ) THEN
+          CALL mppsend(3,t2ns(1,1,1),imigr,noso, ml_req1)
+          CALL mppsend(4,t2sn(1,1,1),imigr,nono, ml_req2)
+          CALL mpprecv(3,t2ns(1,1,2),imigr)
+          CALL mpprecv(4,t2sn(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+          IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+       ELSEIF( nbondj == 1 ) THEN
+          CALL mppsend(3,t2ns(1,1,1),imigr,noso, ml_req1)
+          CALL mpprecv(4,t2sn(1,1,2),imigr)
+          IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+       ENDIF
+
+#endif
+
+       ! 2.3 Write Dirichlet lateral conditions
+
+       ijhom = nlcj - jprecj
+       IF( nbondj == 0 .OR. nbondj == 1 ) THEN
+          DO jl = 1, jprecj
+             ztab(:,jl) = t2sn(:,jl,2)
+          END DO
+       ENDIF
+
+       IF( nbondj == 0 .OR. nbondj == -1 ) THEN
+          DO jl = 1, jprecj
+             ztab(:,ijhom+jl) = t2ns(:,jl,2)
+          END DO
+       ENDIF
+
+       IF( ktype==1 .AND. kd1 <= jpi+nimpp-1 .AND. nimpp <= kd2 ) THEN
+          ! north/south boundaries
+          DO jj = ijpt0,ijpt1
+             DO ji = iipt0,ilpt1
+                ptab(ji,jk) = ztab(ji,jj)  
+             END DO
+          END DO
+       ELSEIF( ktype==2 .AND. kd1 <= jpj+njmpp-1 .AND. njmpp <= kd2 ) THEN
+          ! east/west boundaries
+          DO jj = ijpt0,ilpt1
+             DO ji = iipt0,iipt1
+                ptab(jj,jk) = ztab(ji,jj) 
+             END DO
+          END DO
+       ENDIF
+
+    END DO
+
+  END SUBROUTINE mppobc
+
+  SUBROUTINE mpp_comm_free( kcom)
+
+     INTEGER, INTENT(in) :: kcom
+     INTEGER :: ierr
+
+     CALL MPI_COMM_FREE(kcom, ierr)
+
+  END SUBROUTINE mpp_comm_free
+
+
+  SUBROUTINE mpp_ini_ice(pindic)
+    !!----------------------------------------------------------------------
+    !!               ***  routine mpp_ini_ice  ***
+    !!
+    !! ** Purpose :   Initialize special communicator for ice areas
+    !!      condition together with global variables needed in the ddmpp folding
+    !!
+    !! ** Method  : - Look for ice processors in ice routines
+    !!              - Put their number in nrank_ice
+    !!              - Create groups for the world processors and the ice processors
+    !!              - Create a communicator for ice processors
+    !!
+    !! ** output
+    !!      njmppmax = njmpp for northern procs
+    !!      ndim_rank_ice = number of processors in the northern line
+    !!      nrank_north (ndim_rank_north) = number  of the northern procs.
+    !!      ngrp_world = group ID for the world processors
+    !!      ngrp_ice = group ID for the ice processors
+    !!      ncomm_ice = communicator for the ice procs.
+    !!      n_ice_root = number (in the world) of proc 0 in the ice comm.
+    !!
+    !! History :
+    !!        !  03-09 (J.M. Molines, MPI only )
+    !!----------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_ini_ice not available in SHMEM' )
+# elif key_mpp_mpi
+    INTEGER, INTENT(in) :: pindic
+    INTEGER :: ierr
+    INTEGER :: jproc
+    INTEGER :: ii
+    INTEGER, DIMENSION(jpnij) :: kice
+    INTEGER, DIMENSION(jpnij) :: zwork
+    !!----------------------------------------------------------------------
+
+    ! Look for how many procs with sea-ice
+    !
+    kice = 0
+    DO jproc=1,jpnij
+       IF(jproc == narea .AND. pindic .GT. 0) THEN
+          kice(jproc) = 1    
+       ENDIF        
+    END DO
+
+    zwork = 0
+    CALL MPI_ALLREDUCE( kice, zwork,jpnij, mpi_integer,   &
+                       mpi_sum, mpi_comm_opa, ierr )
+    ndim_rank_ice = sum(zwork)          
+
+    ! Allocate the right size to nrank_north
+#if ! defined key_agrif
+    IF(ALLOCATED(nrank_ice)) DEALLOCATE(nrank_ice)
+#else
+    DEALLOCATE(nrank_ice)
+#endif
+
+    ALLOCATE(nrank_ice(ndim_rank_ice))
+
+    ii = 0     
+    nrank_ice = 0
+    DO jproc=1,jpnij
+       IF(zwork(jproc) == 1) THEN
+          ii = ii + 1
+          nrank_ice(ii) = jproc -1 
+       ENDIF        
+    END DO
+
+    ! Create the world group
+    CALL MPI_COMM_GROUP(mpi_comm_opa,ngrp_world,ierr)
+
+    ! Create the ice group from the world group
+    CALL MPI_GROUP_INCL(ngrp_world,ndim_rank_ice,nrank_ice,ngrp_ice,ierr)
+
+    ! Create the ice communicator , ie the pool of procs with sea-ice
+    CALL MPI_COMM_CREATE(mpi_comm_opa,ngrp_ice,ncomm_ice,ierr)
+
+    ! Find proc number in the world of proc 0 in the north
+    ! The following line seems to be useless, we just comment & keep it as reminder
+    ! CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_ice,1,0,ngrp_world,n_ice_root,ierr)
+#endif
+
+  END SUBROUTINE mpp_ini_ice
+
+
+  SUBROUTINE mpp_ini_north
+    !!----------------------------------------------------------------------
+    !!               ***  routine mpp_ini_north  ***
+    !!
+    !! ** Purpose :   Initialize special communicator for north folding 
+    !!      condition together with global variables needed in the mpp folding
+    !!
+    !! ** Method  : - Look for northern processors
+    !!              - Put their number in nrank_north
+    !!              - Create groups for the world processors and the north processors
+    !!              - Create a communicator for northern processors
+    !!
+    !! ** output
+    !!      njmppmax = njmpp for northern procs
+    !!      ndim_rank_north = number of processors in the northern line
+    !!      nrank_north (ndim_rank_north) = number  of the northern procs.
+    !!      ngrp_world = group ID for the world processors
+    !!      ngrp_north = group ID for the northern processors
+    !!      ncomm_north = communicator for the northern procs.
+    !!      north_root = number (in the world) of proc 0 in the northern comm.
+    !!
+    !! History :
+    !!        !  03-09 (J.M. Molines, MPI only )
+    !!----------------------------------------------------------------------
+#ifdef key_mpp_shmem
+    CALL ctl_stop( ' mpp_ini_north not available in SHMEM' )
+# elif key_mpp_mpi
+    INTEGER :: ierr
+    INTEGER :: jproc
+    INTEGER :: ii,ji
+    !!----------------------------------------------------------------------
+
+    njmppmax=MAXVAL(njmppt)
+
+    ! Look for how many procs on the northern boundary
+    !
+    ndim_rank_north=0
+    DO jproc=1,jpnij
+       IF ( njmppt(jproc) == njmppmax ) THEN
+          ndim_rank_north = ndim_rank_north + 1
+       END IF
+    END DO
+
+
+    ! Allocate the right size to nrank_north
+    !
+    ALLOCATE(nrank_north(ndim_rank_north))
+
+    ! Fill the nrank_north array with proc. number of northern procs.
+    ! Note : the rank start at 0 in MPI
+    !
+    ii=0
+    DO ji = 1, jpnij
+       IF ( njmppt(ji) == njmppmax   ) THEN
+          ii=ii+1
+          nrank_north(ii)=ji-1
+       END IF
+    END DO
+    ! create the world group
+    !
+    CALL MPI_COMM_GROUP(mpi_comm_opa,ngrp_world,ierr)
+    !
+    ! Create the North group from the world group
+    CALL MPI_GROUP_INCL(ngrp_world,ndim_rank_north,nrank_north,ngrp_north,ierr)
+
+    ! Create the North communicator , ie the pool of procs in the north group
+    !
+    CALL MPI_COMM_CREATE(mpi_comm_opa,ngrp_north,ncomm_north,ierr)
+
+
+    ! find proc number in the world of proc 0 in the north
+    CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_north,1,0,ngrp_world,north_root,ierr)
+#endif
+
+  END SUBROUTINE mpp_ini_north
+
+
+   SUBROUTINE mpp_lbc_north_3d ( pt3d, cd_type, psgn )
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_lbc_north_3d  ***
+      !!
+      !! ** Purpose :
+      !!      Ensure proper north fold horizontal bondary condition in mpp configuration
+      !!      in case of jpn1 > 1
+      !!
+      !! ** Method :
+      !!      Gather the 4 northern lines of the global domain on 1 processor and 
+      !!      apply lbc north-fold on this sub array. Then scatter the fold array 
+      !!      back to the processors.
+      !!
+      !! History :
+      !!   8.5  !  03-09  (J.M. Molines ) For mpp folding condition at north
+      !!                                  from lbc routine
+      !!   9.0  !  03-12  (J.M. Molines ) encapsulation into lib_mpp, coding rules of lbc_lnk
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt3d grid-points
+         !             !   = T ,  U , V , F or W  gridpoints
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         pt3d          ! 3D array on which the boundary condition is applied
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   = -1. , the sign is changed if north fold boundary
+         !             !   =  1. , the sign is kept  if north fold boundary
+
+      !! * Local declarations
+      INTEGER :: ji, jj, jk, jr, jproc
+      INTEGER :: ierr
+      INTEGER :: ildi,ilei,iilb
+      INTEGER :: ijpj,ijpjm1,ij,ijt,iju
+      INTEGER :: itaille
+      REAL(wp), DIMENSION(jpiglo,4,jpk) :: ztab
+      REAL(wp), DIMENSION(jpi,4,jpk,jpni) :: znorthgloio
+      REAL(wp), DIMENSION(jpi,4,jpk) :: znorthloc
+      !!----------------------------------------------------------------------
+
+    ! If we get in this routine it s because : North fold condition and mpp with more
+    !   than one proc across i : we deal only with the North condition
+
+    ! 0. Sign setting
+    ! ---------------
+
+    ijpj=4
+    ijpjm1=3
+
+    ! put in znorthloc the last 4 jlines of pt3d
+    DO jk = 1, jpk 
+       DO jj = nlcj - ijpj +1, nlcj
+          ij = jj - nlcj + ijpj
+          znorthloc(:,ij,jk) = pt3d(:,jj,jk)
+       END DO
+    END DO
+
+
+    IF (npolj /= 0 ) THEN
+       ! Build in proc 0 of ncomm_north the znorthgloio
+       znorthgloio(:,:,:,:) = 0_wp
+
+#ifdef key_mpp_shmem
+       not done : compiler error
+#elif defined key_mpp_mpi
+       itaille=jpi*jpk*ijpj
+       CALL MPI_GATHER(znorthloc,itaille,MPI_DOUBLE_PRECISION,znorthgloio,itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+#endif
+
+    ENDIF
+
+    IF (narea == north_root+1 ) THEN
+       ! recover the global north array
+       ztab(:,:,:) = 0_wp
+
+       DO jr = 1, ndim_rank_north
+          jproc = nrank_north(jr) + 1
+          ildi  = nldit (jproc)
+          ilei  = nleit (jproc)
+          iilb  = nimppt(jproc)
+          DO jk = 1, jpk 
+             DO jj = 1, 4
+                DO ji = ildi, ilei
+                   ztab(ji+iilb-1,jj,jk) = znorthgloio(ji,jj,jk,jr)
+                END DO
+             END DO
+          END DO
+       END DO
+
+
+       ! Horizontal slab
+       ! ===============
+
+       DO jk = 1, jpk 
+
+
+          ! 2. North-Fold boundary conditions
+          ! ----------------------------------
+
+          SELECT CASE ( npolj )
+
+          CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+
+             ztab( 1    ,ijpj,jk) = 0.e0
+             ztab(jpiglo,ijpj,jk) = 0.e0
+
+             SELECT CASE ( cd_type )
+
+             CASE ( 'T' , 'S' , 'W' )                   ! T-, W-point
+                DO ji = 2, jpiglo
+                   ijt = jpiglo-ji+2
+                   ztab(ji,ijpj,jk) = psgn * ztab(ijt,ijpj-2,jk)
+                END DO
+                DO ji = jpiglo/2+1, jpiglo
+                   ijt = jpiglo-ji+2
+                   ztab(ji,ijpjm1,jk) = psgn * ztab(ijt,ijpjm1,jk)
+                END DO
+
+             CASE ( 'U' )                               ! U-point
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji+1
+                   ztab(ji,ijpj,jk) = psgn * ztab(iju,ijpj-2,jk)
+                END DO
+                DO ji = jpiglo/2, jpiglo-1
+                   iju = jpiglo-ji+1
+                   ztab(ji,ijpjm1,jk) = psgn * ztab(iju,ijpjm1,jk)
+                END DO
+
+             CASE ( 'V' )                               ! V-point
+                DO ji = 2, jpiglo
+                   ijt = jpiglo-ji+2
+                   ztab(ji,ijpj-1,jk) = psgn * ztab(ijt,ijpj-2,jk)
+                   ztab(ji,ijpj  ,jk) = psgn * ztab(ijt,ijpj-3,jk)
+                END DO
+
+             CASE ( 'F' , 'G' )                         ! F-point
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji+1
+                   ztab(ji,ijpj-1,jk) = psgn * ztab(iju,ijpj-2,jk)
+                   ztab(ji,ijpj  ,jk) = psgn * ztab(iju,ijpj-3,jk)
+                END DO
+
+             END SELECT
+
+          CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+
+             ztab( 1    ,ijpj,jk) = 0.e0
+             ztab(jpiglo,ijpj,jk) = 0.e0
+
+             SELECT CASE ( cd_type )
+
+             CASE ( 'T' , 'S' , 'W' )                   ! T-, W-point
+                DO ji = 1, jpiglo
+                   ijt = jpiglo-ji+1
+                   ztab(ji,ijpj,jk) = psgn * ztab(ijt,ijpj-1,jk)
+                END DO
+
+             CASE ( 'U' )                               ! U-point
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji
+                   ztab(ji,ijpj,jk) = psgn * ztab(iju,ijpj-1,jk)
+                END DO
+
+             CASE ( 'V' )                               ! V-point
+                DO ji = 1, jpiglo
+                   ijt = jpiglo-ji+1
+                   ztab(ji,ijpj,jk) = psgn * ztab(ijt,ijpj-2,jk)
+                END DO
+                DO ji = jpiglo/2+1, jpiglo
+                   ijt = jpiglo-ji+1
+                   ztab(ji,ijpjm1,jk) = psgn * ztab(ijt,ijpjm1,jk)
+                END DO
+
+             CASE ( 'F' , 'G' )                         ! F-point
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji
+                   ztab(ji,ijpj  ,jk) = psgn * ztab(iju,ijpj-2,jk)
+                END DO
+                DO ji = jpiglo/2+1, jpiglo-1
+                   iju = jpiglo-ji
+                   ztab(ji,ijpjm1,jk) = psgn * ztab(iju,ijpjm1,jk)
+                END DO
+
+             END SELECT
+
+          CASE DEFAULT                           ! *  closed
+
+             SELECT CASE ( cd_type) 
+
+             CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+                ztab(:, 1  ,jk) = 0.e0
+                ztab(:,ijpj,jk) = 0.e0
+
+             CASE ( 'F' )                               ! F-point
+                ztab(:,ijpj,jk) = 0.e0
+
+             END SELECT
+
+          END SELECT
+
+          !     End of slab
+          !     ===========
+
+       END DO
+
+       !! Scatter back to pt3d
+       DO jr = 1, ndim_rank_north
+          jproc=nrank_north(jr)+1
+          ildi=nldit (jproc)
+          ilei=nleit (jproc)
+          iilb=nimppt(jproc)
+          DO jk=  1, jpk
+             DO jj=1,ijpj
+                DO ji=ildi,ilei
+                   znorthgloio(ji,jj,jk,jr)=ztab(ji+iilb-1,jj,jk)
+                END DO
+             END DO
+          END DO
+       END DO
+
+    ENDIF      ! only done on proc 0 of ncomm_north
+
+#ifdef key_mpp_shmem
+    not done yet in shmem : compiler error
+#elif key_mpp_mpi
+    IF ( npolj /= 0 ) THEN
+       itaille=jpi*jpk*ijpj
+       CALL MPI_SCATTER(znorthgloio,itaille,MPI_DOUBLE_PRECISION,znorthloc,itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+    ENDIF
+#endif
+
+    ! put in the last ijpj jlines of pt3d znorthloc
+    DO jk = 1 , jpk 
+       DO jj = nlcj - ijpj + 1 , nlcj
+          ij = jj - nlcj + ijpj
+          pt3d(:,jj,jk)= znorthloc(:,ij,jk)
+       END DO
+    END DO
+
+  END SUBROUTINE mpp_lbc_north_3d
+
+
+  SUBROUTINE mpp_lbc_north_2d ( pt2d, cd_type, psgn)
+    !!---------------------------------------------------------------------
+    !!                   ***  routine mpp_lbc_north_2d  ***
+    !!
+    !! ** Purpose :
+    !!      Ensure proper north fold horizontal bondary condition in mpp configuration
+    !!      in case of jpn1 > 1 (for 2d array )
+    !!
+    !! ** Method :
+    !!      Gather the 4 northern lines of the global domain on 1 processor and 
+    !!      apply lbc north-fold on this sub array. Then scatter the fold array 
+    !!      back to the processors.
+    !!
+    !! History :
+    !!   8.5  !  03-09  (J.M. Molines ) For mpp folding condition at north
+    !!                                  from lbc routine
+    !!   9.0  !  03-12  (J.M. Molines ) encapsulation into lib_mpp, coding rules of lbc_lnk
+    !!----------------------------------------------------------------------
+
+    !! * Arguments
+    CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt2d grid-points
+    !             !   = T ,  U , V , F or W  gridpoints
+    REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+    REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+    !             !   = -1. , the sign is changed if north fold boundary
+    !             !   =  1. , the sign is kept  if north fold boundary
+
+
+    !! * Local declarations
+
+    INTEGER :: ji, jj,  jr, jproc
+    INTEGER :: ierr
+    INTEGER :: ildi,ilei,iilb
+    INTEGER :: ijpj,ijpjm1,ij,ijt,iju
+    INTEGER :: itaille
+
+    REAL(wp), DIMENSION(jpiglo,4) :: ztab
+    REAL(wp), DIMENSION(jpi,4,jpni) :: znorthgloio
+    REAL(wp), DIMENSION(jpi,4) :: znorthloc
+    !!----------------------------------------------------------------------
+    !!  OPA 8.5, LODYC-IPSL (2002)
+    !!----------------------------------------------------------------------
+    ! If we get in this routine it s because : North fold condition and mpp with more
+    !   than one proc across i : we deal only with the North condition
+
+    ! 0. Sign setting
+    ! ---------------
+
+    ijpj=4
+    ijpjm1=3
+
+
+    ! put in znorthloc the last 4 jlines of pt2d
+    DO jj = nlcj - ijpj +1, nlcj
+       ij = jj - nlcj + ijpj
+       znorthloc(:,ij)=pt2d(:,jj)
+    END DO
+
+    IF (npolj /= 0 ) THEN
+       ! Build in proc 0 of ncomm_north the znorthgloio
+       znorthgloio(:,:,:) = 0_wp
+#ifdef key_mpp_shmem
+       not done : compiler error
+#elif defined key_mpp_mpi
+       itaille=jpi*ijpj
+       CALL MPI_GATHER(znorthloc,itaille,MPI_DOUBLE_PRECISION,znorthgloio,itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+#endif
+    ENDIF
+
+    IF (narea == north_root+1 ) THEN
+       ! recover the global north array
+       ztab(:,:) = 0_wp
+
+       DO jr = 1, ndim_rank_north
+          jproc=nrank_north(jr)+1
+          ildi=nldit (jproc)
+          ilei=nleit (jproc)
+          iilb=nimppt(jproc)
+          DO jj=1,4
+             DO ji=ildi,ilei
+                ztab(ji+iilb-1,jj)=znorthgloio(ji,jj,jr)
+             END DO
+          END DO
+       END DO
+
+
+       ! 2. North-Fold boundary conditions
+       ! ----------------------------------
+
+       SELECT CASE ( npolj )
+
+       CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+
+          ztab( 1    ,ijpj) = 0.e0
+          ztab(jpiglo,ijpj) = 0.e0
+
+          SELECT CASE ( cd_type )
+
+          CASE ( 'T' , 'W' , 'S' )                         ! T-, W-point
+             DO ji = 2, jpiglo
+                ijt = jpiglo-ji+2
+                ztab(ji,ijpj) = psgn * ztab(ijt,ijpj-2)
+             END DO
+             DO ji = jpiglo/2+1, jpiglo
+                ijt = jpiglo-ji+2
+                ztab(ji,ijpjm1) = psgn * ztab(ijt,ijpjm1)
+             END DO
+
+          CASE ( 'U' )                                     ! U-point
+             DO ji = 1, jpiglo-1
+                iju = jpiglo-ji+1
+                ztab(ji,ijpj) = psgn * ztab(iju,ijpj-2)
+             END DO
+             DO ji = jpiglo/2, jpiglo-1
+                iju = jpiglo-ji+1
+                ztab(ji,ijpjm1) = psgn * ztab(iju,ijpjm1)
+             END DO
+
+          CASE ( 'V' )                                     ! V-point
+             DO ji = 2, jpiglo
+                ijt = jpiglo-ji+2
+                ztab(ji,ijpj-1) = psgn * ztab(ijt,ijpj-2)
+                ztab(ji,ijpj  ) = psgn * ztab(ijt,ijpj-3)
+             END DO
+
+          CASE ( 'F' , 'G' )                               ! F-point
+             DO ji = 1, jpiglo-1
+                iju = jpiglo-ji+1
+                ztab(ji,ijpj-1) = psgn * ztab(iju,ijpj-2)
+                ztab(ji,ijpj  ) = psgn * ztab(iju,ijpj-3)
+             END DO
+
+          CASE ( 'I' )                                     ! ice U-V point
+             ztab(2,ijpj) = psgn * ztab(3,ijpj-1)
+             DO ji = 3, jpiglo
+                iju = jpiglo - ji + 3
+                ztab(ji,ijpj) = psgn * ztab(iju,ijpj-1)
+             END DO
+
+          END SELECT
+
+       CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+
+          ztab( 1 ,ijpj) = 0.e0
+          ztab(jpiglo,ijpj) = 0.e0
+
+          SELECT CASE ( cd_type )
+
+          CASE ( 'T' , 'W' ,'S' )                          ! T-, W-point
+             DO ji = 1, jpiglo
+                ijt = jpiglo-ji+1
+                ztab(ji,ijpj) = psgn * ztab(ijt,ijpj-1)
+             END DO
+
+          CASE ( 'U' )                                     ! U-point
+             DO ji = 1, jpiglo-1
+                iju = jpiglo-ji
+                ztab(ji,ijpj) = psgn * ztab(iju,ijpj-1)
+             END DO
+
+          CASE ( 'V' )                                     ! V-point
+             DO ji = 1, jpiglo
+                ijt = jpiglo-ji+1
+                ztab(ji,ijpj) = psgn * ztab(ijt,ijpj-2)
+             END DO
+             DO ji = jpiglo/2+1, jpiglo
+                ijt = jpiglo-ji+1
+                ztab(ji,ijpjm1) = psgn * ztab(ijt,ijpjm1)
+             END DO
+
+          CASE ( 'F' , 'G' )                               ! F-point
+             DO ji = 1, jpiglo-1
+                iju = jpiglo-ji
+                ztab(ji,ijpj  ) = psgn * ztab(iju,ijpj-2)
+             END DO
+             DO ji = jpiglo/2+1, jpiglo-1
+                iju = jpiglo-ji
+                ztab(ji,ijpjm1) = psgn * ztab(iju,ijpjm1)
+             END DO
+
+             CASE ( 'I' )                                  ! ice U-V point
+                ztab( 2 ,ijpj) = 0.e0
+                DO ji = 2 , jpiglo-1
+                   ijt = jpiglo - ji + 2
+                   ztab(ji,ijpj)= 0.5 * ( ztab(ji,ijpj-1) + psgn * ztab(ijt,ijpj-1) )
+                END DO
+
+          END SELECT
+
+       CASE DEFAULT                           ! *  closed : the code probably never go through
+
+            SELECT CASE ( cd_type) 
+  
+            CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
+               ztab(:, 1 ) = 0.e0
+               ztab(:,ijpj) = 0.e0
+
+            CASE ( 'F' )                                   ! F-point
+               ztab(:,ijpj) = 0.e0
+
+            CASE ( 'I' )                                   ! ice U-V point
+               ztab(:, 1 ) = 0.e0
+               ztab(:,ijpj) = 0.e0
+
+            END SELECT
+
+         END SELECT
+
+         !     End of slab
+         !     ===========
+
+         !! Scatter back to pt2d
+         DO jr = 1, ndim_rank_north
+            jproc=nrank_north(jr)+1
+            ildi=nldit (jproc)
+            ilei=nleit (jproc)
+            iilb=nimppt(jproc)
+            DO jj=1,ijpj
+               DO ji=ildi,ilei
+                  znorthgloio(ji,jj,jr)=ztab(ji+iilb-1,jj)
+               END DO
+            END DO
+         END DO
+
+      ENDIF      ! only done on proc 0 of ncomm_north
+
+#ifdef key_mpp_shmem
+      not done yet in shmem : compiler error
+#elif key_mpp_mpi
+      IF ( npolj /= 0 ) THEN
+         itaille=jpi*ijpj
+         CALL MPI_SCATTER(znorthgloio,itaille,MPI_DOUBLE_PRECISION,znorthloc,itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+      ENDIF
+#endif
+
+      ! put in the last ijpj jlines of pt2d znorthloc
+      DO jj = nlcj - ijpj + 1 , nlcj
+         ij = jj - nlcj + ijpj
+         pt2d(:,jj)= znorthloc(:,ij)
+      END DO
+
+   END SUBROUTINE mpp_lbc_north_2d
+
+
+   SUBROUTINE mpp_lbc_north_e ( pt2d, cd_type, psgn)
+    !!---------------------------------------------------------------------
+    !!                   ***  routine mpp_lbc_north_2d  ***
+    !!
+    !! ** Purpose :
+    !!      Ensure proper north fold horizontal bondary condition in mpp configuration
+    !!      in case of jpn1 > 1 (for 2d array with outer extra halo)
+    !!
+    !! ** Method :
+    !!      Gather the 4+2*jpr2dj northern lines of the global domain on 1 processor and 
+    !!      apply lbc north-fold on this sub array. Then scatter the fold array 
+    !!      back to the processors.
+    !!
+    !! History :
+    !!   8.5  !  03-09  (J.M. Molines ) For mpp folding condition at north
+    !!                                  from lbc routine
+    !!   9.0  !  03-12  (J.M. Molines ) encapsulation into lib_mpp, coding rules of lbc_lnk
+    !!   9.0  !  05-09  (R. Benshila )   adapt mpp_lbc_north_2d 
+    !!----------------------------------------------------------------------
+
+    !! * Arguments
+    CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt2d grid-points
+    !             !   = T ,  U , V , F or W  gridpoints
+    REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+    REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+    !             !   = -1. , the sign is changed if north fold boundary
+    !             !   =  1. , the sign is kept  if north fold boundary
+
+
+    !! * Local declarations
+
+    INTEGER :: ji, jj,  jr, jproc, jl
+    INTEGER :: ierr
+    INTEGER :: ildi,ilei,iilb
+    INTEGER :: ijpj,ijpjm1,ij,ijt,iju, iprecj
+    INTEGER :: itaille
+
+    REAL(wp), DIMENSION(jpiglo,1-jpr2dj:4+jpr2dj) :: ztab
+    REAL(wp), DIMENSION(jpi,1-jpr2dj:4+jpr2dj,jpni) :: znorthgloio
+    REAL(wp), DIMENSION(jpi,1-jpr2dj:4+jpr2dj) :: znorthloc
+
+    ! If we get in this routine it s because : North fold condition and mpp with more
+    !   than one proc across i : we deal only with the North condition
+
+    ! 0. Sign setting
+    ! ---------------
+
+    ijpj=4
+    ijpjm1=3
+    iprecj = jpr2dj+jprecj
+
+    ! put in znorthloc the last 4 jlines of pt2d
+    DO jj = nlcj - ijpj + 1 - jpr2dj, nlcj +jpr2dj
+       ij = jj - nlcj + ijpj
+       znorthloc(:,ij)=pt2d(1:jpi,jj)
+    END DO
+
+    IF (npolj /= 0 ) THEN
+       ! Build in proc 0 of ncomm_north the znorthgloio
+       znorthgloio(:,:,:) = 0_wp
+#ifdef key_mpp_shmem
+       not done : compiler error
+#elif defined key_mpp_mpi
+       itaille=jpi*(ijpj+2*jpr2dj)
+       CALL MPI_GATHER(znorthloc(1,1-jpr2dj),itaille,MPI_DOUBLE_PRECISION, &
+                     & znorthgloio(1,1-jpr2dj,1),itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+#endif
+    ENDIF
+
+    IF (narea == north_root+1 ) THEN
+       ! recover the global north array
+       ztab(:,:) = 0_wp
+
+       DO jr = 1, ndim_rank_north
+          jproc=nrank_north(jr)+1
+          ildi=nldit (jproc)
+          ilei=nleit (jproc)
+          iilb=nimppt(jproc)
+          DO jj=1-jpr2dj,ijpj+jpr2dj
+             DO ji=ildi,ilei
+                ztab(ji+iilb-1,jj)=znorthgloio(ji,jj,jr)
+             END DO
+          END DO
+       END DO
+
+
+       ! 2. North-Fold boundary conditions
+       ! ----------------------------------
+
+       SELECT CASE ( npolj )
+
+       CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+
+          ztab( 1    ,ijpj:ijpj+jpr2dj) = 0.e0
+          ztab(jpiglo,ijpj:ijpj+jpr2dj) = 0.e0
+
+          SELECT CASE ( cd_type )
+
+          CASE ( 'T' , 'W' , 'S' )                         ! T-, W-point
+             DO jl =0, iprecj-1
+                DO ji = 2, jpiglo
+                   ijt = jpiglo-ji+2
+                   ztab(ji,ijpj+jl) = psgn * ztab(ijt,ijpj-2-jl)
+                END DO
+             END DO
+             DO ji = jpiglo/2+1, jpiglo
+                ijt = jpiglo-ji+2
+                ztab(ji,ijpjm1) = psgn * ztab(ijt,ijpjm1)
+             END DO
+
+          CASE ( 'U' )                                     ! U-point
+             DO jl =0, iprecj-1
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji+1
+                   ztab(ji,ijpj+jl) = psgn * ztab(iju,ijpj-2-jl)
+                END DO
+             END DO
+             DO ji = jpiglo/2, jpiglo-1
+                iju = jpiglo-ji+1
+                ztab(ji,ijpjm1) = psgn * ztab(iju,ijpjm1)
+             END DO
+
+          CASE ( 'V' )                                     ! V-point
+            DO jl =-1, iprecj-1
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  ztab(ji,ijpj+jl) = psgn * ztab(ijt,ijpj-3-jl)
+               END DO
+            END DO
+
+          CASE ( 'F' , 'G' )                               ! F-point
+            DO jl =-1, iprecj-1
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  ztab(ji,ijpj+jl) = psgn * ztab(iju,ijpj-3-jl)
+               END DO
+             END DO
+
+          CASE ( 'I' )                                     ! ice U-V point
+             DO jl =0, iprecj-1
+                ztab(2,ijpj+jl) = psgn * ztab(3,ijpj-1+jl)
+                DO ji = 3, jpiglo
+                   iju = jpiglo - ji + 3
+                   ztab(ji,ijpj+jl) = psgn * ztab(iju,ijpj-1-jl)
+                END DO
+             END DO
+
+          END SELECT
+
+       CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+
+          ztab( 1 ,ijpj:ijpj+jpr2dj) = 0.e0
+          ztab(jpiglo,ijpj:ijpj+jpr2dj) = 0.e0
+
+          SELECT CASE ( cd_type )
+
+          CASE ( 'T' , 'W' ,'S' )                          ! T-, W-point
+             DO jl = 0, iprecj-1
+                DO ji = 1, jpiglo
+                   ijt = jpiglo-ji+1
+                   ztab(ji,ijpj+jl) = psgn * ztab(ijt,ijpj-1-jl)
+                END DO
+             END DO
+
+          CASE ( 'U' )                                     ! U-point
+             DO jl = 0, iprecj-1
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji
+                   ztab(ji,ijpj+jl) = psgn * ztab(iju,ijpj-1-jl)
+                END DO
+             END DO
+
+          CASE ( 'V' )                                     ! V-point
+             DO jl = 0, iprecj-1
+                DO ji = 1, jpiglo
+                   ijt = jpiglo-ji+1
+                   ztab(ji,ijpj+jl) = psgn * ztab(ijt,ijpj-2-jl)
+                END DO
+             END DO
+             DO ji = jpiglo/2+1, jpiglo
+                ijt = jpiglo-ji+1
+                ztab(ji,ijpjm1) = psgn * ztab(ijt,ijpjm1)
+             END DO
+
+          CASE ( 'F' , 'G' )                               ! F-point
+             DO jl = 0, iprecj-1
+                DO ji = 1, jpiglo-1
+                   iju = jpiglo-ji
+                   ztab(ji,ijpj+jl) = psgn * ztab(iju,ijpj-2-jl)
+                END DO
+             END DO
+             DO ji = jpiglo/2+1, jpiglo-1
+                iju = jpiglo-ji
+                ztab(ji,ijpjm1) = psgn * ztab(iju,ijpjm1)
+             END DO
+
+             CASE ( 'I' )                                  ! ice U-V point
+                ztab( 2 ,ijpj:ijpj+jpr2dj) = 0.e0
+                DO jl = 0, jpr2dj
+                   DO ji = 2 , jpiglo-1
+                      ijt = jpiglo - ji + 2
+                      ztab(ji,ijpj+jl)= 0.5 * ( ztab(ji,ijpj-1-jl) + psgn * ztab(ijt,ijpj-1-jl) )
+                   END DO
+                END DO
+
+          END SELECT
+
+       CASE DEFAULT                           ! *  closed : the code probably never go through
+
+            SELECT CASE ( cd_type) 
+  
+            CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
+               ztab(:, 1:1-jpr2dj     ) = 0.e0
+               ztab(:,ijpj:ijpj+jpr2dj) = 0.e0
+
+            CASE ( 'F' )                                   ! F-point
+               ztab(:,ijpj:ijpj+jpr2dj) = 0.e0
+
+            CASE ( 'I' )                                   ! ice U-V point
+               ztab(:, 1:1-jpr2dj     ) = 0.e0
+               ztab(:,ijpj:ijpj+jpr2dj) = 0.e0
+
+            END SELECT
+
+         END SELECT
+
+         !     End of slab
+         !     ===========
+
+         !! Scatter back to pt2d
+         DO jr = 1, ndim_rank_north
+            jproc=nrank_north(jr)+1
+            ildi=nldit (jproc)
+            ilei=nleit (jproc)
+            iilb=nimppt(jproc)
+            DO jj=1-jpr2dj,ijpj+jpr2dj
+               DO ji=ildi,ilei
+                  znorthgloio(ji,jj,jr)=ztab(ji+iilb-1,jj)
+               END DO
+            END DO
+         END DO
+
+      ENDIF      ! only done on proc 0 of ncomm_north
+
+#ifdef key_mpp_shmem
+      not done yet in shmem : compiler error
+#elif key_mpp_mpi
+      IF ( npolj /= 0 ) THEN
+         itaille=jpi*(ijpj+2*jpr2dj)
+         CALL MPI_SCATTER(znorthgloio(1,1-jpr2dj,1),itaille,MPI_DOUBLE_PRECISION, &
+                        & znorthloc(1,1-jpr2dj),itaille,MPI_DOUBLE_PRECISION,0,ncomm_north,ierr)
+      ENDIF
+#endif
+
+      ! put in the last ijpj jlines of pt2d znorthloc
+      DO jj = nlcj - ijpj  -jpr2dj + 1 , nlcj +jpr2dj
+         ij = jj - nlcj + ijpj 
+         pt2d(1:jpi,jj)= znorthloc(:,ij)
+      END DO
+
+   END SUBROUTINE mpp_lbc_north_e
+
+   SUBROUTINE mpi_init_opa(code)
+     !!---------------------------------------------------------------------
+     !!                   ***  routine mpp_init.opa  ***
+     !!
+     !! ** Purpose :: export and attach a MPI buffer for bsend
+     !!
+     !! ** Method  :: define buffer size in namelist, if 0 no buffer attachment
+     !!            but classical mpi_init
+     !! 
+     !! History :: 01/11 :: IDRIS initial version for IBM only  
+     !!            08/04 :: R. Benshila, generalisation
+     !!
+     !!---------------------------------------------------------------------
+
+      INTEGER                                 :: code, ierr
+      LOGICAL                                 :: mpi_was_called
+ 
+      ! MPI initialization
+      CALL mpi_initialized(mpi_was_called, code)
+      IF ( code /= MPI_SUCCESS ) THEN
+        CALL ctl_stop( ' lib_mpp: Error in routine mpi_initialized' )
+        CALL mpi_abort( mpi_comm_world, code, ierr )
+      ENDIF
+
+      IF ( .NOT. mpi_was_called ) THEN
+         CALL mpi_init(code)
+         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code)
+         IF ( code /= MPI_SUCCESS ) THEN
+            CALL ctl_stop( ' lib_mpp: Error in routine mpi_comm_dup' )
+            CALL mpi_abort( mpi_comm_world, code, ierr )
+         ENDIF
+      ENDIF
+
+      IF( nn_buffer > 0 ) THEN
+         IF ( lwp ) WRITE(numout,*) 'mpi_bsend, buffer allocation of  : ', nn_buffer
+
+         ! Buffer allocation and attachment
+         ALLOCATE(tampon(nn_buffer))
+         CALL mpi_buffer_attach(tampon,nn_buffer,code)
+      ENDIF
+
+   END SUBROUTINE mpi_init_opa
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case:            Dummy module        share memory computing
+   !!----------------------------------------------------------------------
+   INTERFACE mpp_sum
+      MODULE PROCEDURE mpp_sum_a2s, mpp_sum_as, mpp_sum_ai, mpp_sum_s, mpp_sum_i
+   END INTERFACE
+   INTERFACE mpp_max
+      MODULE PROCEDURE mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real
+   END INTERFACE
+   INTERFACE mpp_min
+      MODULE PROCEDURE mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real
+   END INTERFACE
+   INTERFACE mpp_isl
+      MODULE PROCEDURE mppisl_a_int, mppisl_int, mppisl_a_real, mppisl_real
+   END INTERFACE
+   INTERFACE mppobc
+      MODULE PROCEDURE mppobc_1d, mppobc_2d, mppobc_3d, mppobc_4d
+   END INTERFACE
+  INTERFACE mpp_minloc
+     MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
+  END INTERFACE
+  INTERFACE mpp_maxloc
+     MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
+  END INTERFACE
+
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.      !: mpp flag
+   INTEGER :: ncomm_ice
+
+CONTAINS
+
+   FUNCTION mynode(localComm) RESULT (function_value)
+      INTEGER, OPTIONAL :: localComm
+      function_value = 0
+   END FUNCTION mynode
+
+   SUBROUTINE mppsync                       ! Dummy routine
+   END SUBROUTINE mppsync
+
+   SUBROUTINE mpp_sum_as( parr, kdim, kcom )      ! Dummy routine
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_as: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mpp_sum_as
+
+   SUBROUTINE mpp_sum_a2s( parr, kdim, kcom )      ! Dummy routine
+      REAL   , DIMENSION(:,:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_a2s: You should not have seen this print! error?', kdim, parr(1,1), kcom
+   END SUBROUTINE mpp_sum_a2s
+
+   SUBROUTINE mpp_sum_ai( karr, kdim, kcom )      ! Dummy routine
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_ai: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mpp_sum_ai
+
+   SUBROUTINE mpp_sum_s( psca, kcom )            ! Dummy routine
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_s: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mpp_sum_s
+
+   SUBROUTINE mpp_sum_i( kint, kcom )            ! Dummy routine
+      integer               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_i: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mpp_sum_i
+
+   SUBROUTINE mppmax_a_real( parr, kdim, kcom )
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mppmax_a_real
+
+   SUBROUTINE mppmax_real( psca, kcom )
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_real: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mppmax_real
+
+   SUBROUTINE mppmin_a_real( parr, kdim, kcom )
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mppmin_a_real
+
+   SUBROUTINE mppmin_real( psca, kcom )
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_real: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mppmin_real
+
+   SUBROUTINE mppmax_a_int( karr, kdim ,kcom)
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mppmax_a_int
+
+   SUBROUTINE mppmax_int( kint, kcom)
+      INTEGER               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_int: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mppmax_int
+
+   SUBROUTINE mppmin_a_int( karr, kdim, kcom )
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mppmin_a_int
+
+   SUBROUTINE mppmin_int( kint, kcom )
+      INTEGER               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_int: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mppmin_int
+
+   SUBROUTINE mppobc_1d( parr, kd1, kd2, kl, kk, ktype, kij )
+    INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+    REAL, DIMENSION(:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?',   &
+         &        parr(1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_1d
+
+   SUBROUTINE mppobc_2d( parr, kd1, kd2, kl, kk, ktype, kij )
+    INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+    REAL, DIMENSION(:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?',   &
+         &        parr(1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_2d
+
+   SUBROUTINE mppobc_3d( parr, kd1, kd2, kl, kk, ktype, kij )
+    INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+    REAL, DIMENSION(:,:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?',   &
+         &        parr(1,1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_3d
+
+   SUBROUTINE mppobc_4d( parr, kd1, kd2, kl, kk, ktype, kij )
+    INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+    REAL, DIMENSION(:,:,:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?',   &
+         &        parr(1,1,1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_4d
+
+
+   SUBROUTINE mpplnks( parr )            ! Dummy routine
+      REAL, DIMENSION(:,:) :: parr
+      WRITE(*,*) 'mpplnks: You should not have seen this print! error?', parr(1,1)
+   END SUBROUTINE mpplnks
+
+   SUBROUTINE mppisl_a_int( karr, kdim )
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      WRITE(*,*) 'mppisl_a_int: You should not have seen this print! error?', kdim, karr(1)
+   END SUBROUTINE mppisl_a_int
+
+   SUBROUTINE mppisl_int( kint )
+      INTEGER               :: kint
+      WRITE(*,*) 'mppisl_int: You should not have seen this print! error?', kint
+   END SUBROUTINE mppisl_int
+
+   SUBROUTINE mppisl_a_real( parr, kdim )
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      WRITE(*,*) 'mppisl_a_real: You should not have seen this print! error?', kdim, parr(1)
+   END SUBROUTINE mppisl_a_real
+
+   SUBROUTINE mppisl_real( psca )
+      REAL                  :: psca
+      WRITE(*,*) 'mppisl_real: You should not have seen this print! error?', psca
+   END SUBROUTINE mppisl_real
+
+   SUBROUTINE mpp_minloc2d ( ptab, pmask, pmin, ki, kj )
+      REAL                   :: pmin
+      REAL , DIMENSION (:,:) :: ptab, pmask
+      INTEGER :: ki, kj
+      WRITE(*,*) 'mppisl_real: You should not have seen this print! error?', pmin, ki, kj
+      WRITE(*,*) '   "      ":             "                 "            ', ptab(1,1), pmask(1,1)
+   END SUBROUTINE mpp_minloc2d
+
+   SUBROUTINE mpp_minloc3d ( ptab, pmask, pmin, ki, kj, kk )
+      REAL                     :: pmin
+      REAL , DIMENSION (:,:,:) :: ptab, pmask
+      INTEGER :: ki, kj, kk
+      WRITE(*,*) 'mppisl_real: You should not have seen this print! error?', pmin, ki, kj, kk
+      WRITE(*,*) '   "      ":             "                 "            ', ptab(1,1,1), pmask(1,1,1)
+   END SUBROUTINE mpp_minloc3d
+
+   SUBROUTINE mpp_maxloc2d ( ptab, pmask, pmax, ki, kj )
+      REAL                   :: pmax
+      REAL , DIMENSION (:,:) :: ptab, pmask
+      INTEGER :: ki, kj
+      WRITE(*,*) 'mppisl_real: You should not have seen this print! error?', pmax, ki, kj
+      WRITE(*,*) '   "      ":             "                 "            ', ptab(1,1), pmask(1,1)
+   END SUBROUTINE mpp_maxloc2d
+
+   SUBROUTINE mpp_maxloc3d ( ptab, pmask, pmax, ki, kj, kk )
+      REAL                     :: pmax
+      REAL , DIMENSION (:,:,:) :: ptab, pmask
+      INTEGER :: ki, kj, kk
+      WRITE(*,*) 'mppisl_real: You should not have seen this print! error?', pmax, ki, kj, kk
+      WRITE(*,*) '   "      ":             "                 "            ', ptab(1,1,1), pmask(1,1,1)
+   END SUBROUTINE mpp_maxloc3d
+
+   SUBROUTINE mppstop
+      WRITE(*,*) 'mppstop: You should not have seen this print! error?'
+   END SUBROUTINE mppstop
+
+   SUBROUTINE mpp_ini_ice(kcom)
+      INTEGER :: kcom
+      WRITE(*,*) 'mpp_ini_ice: You should not have seen this print! error?',kcom
+   END SUBROUTINE mpp_ini_ice
+
+   SUBROUTINE mpp_comm_free(kcom)
+      INTEGER :: kcom
+      WRITE(*,*) 'mpp_comm_free: You should not have seen this print! error?',kcom
+   END SUBROUTINE mpp_comm_free
+
+#endif
+   !!----------------------------------------------------------------------
+END MODULE lib_mpp
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_print.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_print.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/lib_print.f90	(revision 1844)
@@ -0,0 +1,265 @@
+MODULE lib_print
+   !!======================================================================
+   !!                    ***  MODULE  lib_print  ***
+   !! print librairy :  formated real and integer array print
+   !!=====================================================================
+      
+   !!----------------------------------------------------------------------
+   !!   prihin       : print an integer 2D horizontal field
+   !!   prihre       : print an real 2D horizontal field
+   !!   prizre       : print an real 2D vertical field
+   !!----------------------------------------------------------------------
+   !! * Mules used
+   USE par_kind      ! kind parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC prihin, prihre, prizre
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE prihin( ktab, ki   , kj   , kideb, kifin ,   &
+                      kind, kjdeb, kjfin, kjnd , kscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  prihre  ***
+      !!  
+      !! ** purpose :   Print an integer field
+      !!
+      !! ** method :   format of print is selected with the dummy argument kscale
+      !!
+      !! History :
+      !!        !  90-04 (0. Marti)  Original code
+      !!        !  92-02 (M. Imbard)
+      !!        !  03-07 (G. Madec)  F90, free form
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj,                 &  ! array dimensions
+         kideb, kifin, kind,     &  ! first and last index, increment for i 
+         kjdeb, kjfin, kjnd,     &  ! first and last index, increment for j
+         kscale,                 &  ! kscale=0 or > 5  print ktab with format i8
+      !                             !         kscale=1 print ktab with format i1
+      !                             !         kscale=2 print ktab with format i2
+      !                             !         kscale=3 print ktab with format i3
+      !                             !         kscale=4 print ktab with format i4
+      !                             !         kscale=5 print ktab with format i5
+         kumout                     ! unit in which print
+      INTEGER, DIMENSION(ki,kj), INTENT( in ) ::   &
+         ktab                       ! integer 2D array to be print
+
+      !! * local declarations
+      INTEGER ::   ji, jj, jn       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+      INTEGER ::   iind, ijnd       ! temporary integers
+
+      isca = 10
+      IF( kscale == 0 )   isca = 10
+      IF( kscale == 1 )   isca = 100
+      IF( kscale == 2 )   isca = 60
+      IF( kscale == 3 )   isca = 40
+      IF( kscale == 4 )   isca = 30
+      IF( kscale == 5 )   isca = 20
+
+      iind = MAX( 1, kind )
+      ijnd = MAX( 1, kjnd )
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
+
+        IF( il1 > kifin ) RETURN
+        WRITE(kumout,'(/)')
+        il2 = il1+iind*(isca-1)
+        IF( il2 > kifin )   il2 = kifin
+
+        IF( kscale == 1 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)') il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,100i1)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 2 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,60i2)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 3 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,40i3)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 4 ) THEN
+            WRITE(kumout,'(4x,30i4,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,30i4)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 5 ) THEN
+            WRITE(kumout,'(4x,20i5,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,20i5)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSE
+            WRITE(kumout,'(4x,10i8,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,10i8)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ENDIF
+
+        il1 = il1 + iind * isca
+      END DO  
+
+   END SUBROUTINE prihin
+
+
+   SUBROUTINE prihre( ptab, ki   , kj   , kideb, kifin ,   &
+                      kind, kjdeb, kjfin, kjnd , pscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE prihre  ***
+      !!      
+      !! ** purpose :   Print a real field with the format 10e12.4 or 20f6.2
+      !!
+      !! ** method  :   the print format is selected with the pscale argument
+      !!
+      !! History :
+      !!   1.0  !  86-01  (P. Andrich)  Original code
+      !!        !  89-11  (C. Levy)
+      !!        !  92-02  (M. Imbard)
+      !!        !  92-06  (M. Imbard)
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj,                 &  ! array dimensions
+         kideb, kifin, kind,     &  ! first and last index, increment for i
+         kjdeb, kjfin, kjnd,     &  ! first and last index, increment for j
+         kumout                     ! unit in which print
+      REAL(wp), INTENT( in ) ::   &
+         pscale                     ! = 0  print        ptab with e13.5 format
+         !                          ! else print pscale*ptab with f6.2 format
+      REAL(wp), DIMENSION(ki,kj), INTENT( in ) ::   &
+         ptab                       ! integer 2D array to be print
+
+      !! * Local variables
+      INTEGER ::   ji, jj, jn       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+
+      isca = 10
+      IF( pscale /= 0. )   isca=20
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(kind*isca) + 1
+
+        IF( il1 > kifin )   RETURN
+
+        WRITE(kumout,9100)
+
+        il2 = il1+kind*(isca-1)
+        IF(il2 > kifin) il2 = kifin
+        IF( pscale == 0.) THEN
+            WRITE(kumout,9101) ( ji, ji = il1, il2, kind )
+            DO jj = kjfin, kjdeb, -kjnd
+              WRITE(kumout,9102) jj, ( ptab(ji,jj), ji = il1, il2, kind )
+            END DO  
+        ELSE
+            WRITE(kumout,9103) ( ji, ji = il1, il2, kind )
+            DO jj = kjfin, kjdeb, -kjnd
+              WRITE(kumout,9104) jj, ( pscale*ptab(ji,jj), ji = il1, il2, kind )
+            END DO  
+        ENDIF
+        il1 = il1+kind*isca
+
+      END DO  
+
+      ! formats
+ 9100 FORMAT(/)
+ 9101 FORMAT(10i12, /)
+ 9102 FORMAT(1x, i3, 10(1pe12.4))
+ 9103 FORMAT(3x, 20i6, /)
+ 9104 FORMAT(1x, i3, 1x, 20f6.2)
+
+   END SUBROUTINE prihre
+
+
+   SUBROUTINE prizre( ptab , ki   , kj   , kk   , kjcut ,   &
+                      kideb, kifin, kid  , kkdeb, kkfin ,   &
+                      kkd  , pscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE prizre  ***
+      !!
+      !! ** purpose :   Print a vertical slab from a tridimentional real field
+      !!
+      !!   METHOD :
+      !! ** method  :   the print format is selected with the argument pscale
+      !!
+      !! History :
+      !!      original : 86-01 (o. Marti)
+      !!      addition : 92-02 (M. Imbard)
+      !!      addition : 92-06 (M. Imbard)
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj, kk,             &  ! array dimensions
+         kjcut,                  &  ! index j for the vertical slab
+         kideb, kifin, kid,      &  ! first and last index, increment for i
+         kkdeb, kkfin, kkd,      &  ! first and last index, increment for k
+         kumout                     ! unit in which print
+      REAL(wp), INTENT( in ) ::   &
+         pscale                     ! = 0  print        ptab with e12.4 format
+         !                          ! else print pscale*ptab with f6.2 format
+      REAL(wp), DIMENSION(ki,kj,kk), INTENT( in ) ::   &
+         ptab                       ! integer 3D array to be print
+
+      !! * Local variables
+      INTEGER ::   ji, jn, jk       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+      INTEGER ::   iind, iknd       !    "          "
+
+
+      iind = kid
+      iknd = kkd
+      isca = 10
+      IF( pscale /= 0.) isca = 20
+
+      IF (iind == 0) iind = 1
+      IF (iknd == 0) iknd = 1
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
+
+        IF(il1 > kifin) RETURN
+        WRITE(kumout,9100)
+        il2 = il1+iind*(isca-1)
+        IF(il2 > kifin) il2 = kifin
+
+        IF( pscale == 0.) THEN
+            WRITE(kumout,9101) ( ji, ji = il1, il2, iind )
+            DO jk = kkdeb, kkfin, iknd
+              WRITE (kumout,9102) jk, ( ptab(ji,kjcut,jk), ji = il1, il2, iind )
+            END DO  
+        ELSE
+            WRITE (kumout,9103) ( ji, ji = il1, il2, iind )
+            DO jk = kkdeb, kkfin, iknd
+              WRITE(kumout,9104)jk, ( pscale*ptab(ji,kjcut,jk), ji = il1, il2, iind )
+            END DO  
+        ENDIF
+
+        il1 = il1+iind*isca
+      END DO      
+
+ 9100 FORMAT(/)
+ 9101 FORMAT(10i12, /)
+ 9102 FORMAT(1x, i3, 10(1pe12.4))
+ 9103 FORMAT(3x, 20i6, /)
+ 9104 FORMAT(1x, i3, 1x, 20f6.1)
+
+      END SUBROUTINE prizre
+
+   !!======================================================================
+END MODULE lib_print
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/model.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/model.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/model.f90	(revision 1844)
@@ -0,0 +1,21 @@
+PROGRAM model
+   !!----------------------------------------------------------------------
+   !!                     ***  PROGRAM model  ***
+   !!
+   !! ** Purpose :   encapsulate the opa model so that opa can also be 
+   !!      called together with the adjoint and linear tangent models
+   !!
+   !! History :
+   !!   8.0  !  01-02  (M. Imbard, A. Weaver)  Original code
+   !!   9.0  !  03-10  (G. Madec) F90
+   !!----------------------------------------------------------------------
+   USE opa                  ! OPA system     (opa_model routine)
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+ 
+   CALL opa_model           ! OPA system
+ 
+END PROGRAM model
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/module_example
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/module_example	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/module_example	(revision 1844)
@@ -0,0 +1,211 @@
+MODULE exampl
+   !!======================================================================
+   !!                       ***  MODULE  example  ***
+   !! Ocean physics:  brief description of the purpose of the module
+   !!                 (please no more than 2 lines)
+   !!=====================================================================
+#if defined key_example
+   !!----------------------------------------------------------------------
+   !!   'key_example'  :                brief description of the key option
+   !!----------------------------------------------------------------------
+   !!   exa_mpl      : liste of module subroutine (caution, never use the
+   !!   exa_mpl_init : name of the module for a routine)
+   !!   exa_mpl_stp  : Please try to use 3 letter block for routine names
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE module_name1            ! brief description of the used module
+   USE module_name2            ! ....
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC exa_mpl    ! routine called in xxx.F90 module
+
+   !! * Share Module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      var1    ,   &  !: var1 description (CAUTION always use !: to describe a 
+      !              !  PUBLIC variable simplify the search of where it is declared
+      var2           !: var2 description
+
+   !! * Module variables
+   INTEGER ::                 & !!! ** toto namelist (namtoto) **
+      nflag  =  1                ! default value of nflag 
+   REAL(wp) ::                & !!! ** toto namlist (namtoto) **
+      var3  = 2._wp / 9._wp      ! default value of var3
+   REAL(wp) ::   &  
+      var4          ! var4 description (local permanent variable)
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      tab1          ! coefficient used for horizontal smoothing
+
+   !! * Substitutions
+#  include "exampl_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! or LIM 2.0 , UCL-LOCEAN-IPSL (2005)
+   !! or  TOP 1.0 , LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+# if defined key_autotasking
+   !!----------------------------------------------------------------------
+   !!   'key_autotasking'                              autotasking (j-slab)
+   !!----------------------------------------------------------------------
+#  include "exampl_autotsk.h90"
+
+# else
+   !!----------------------------------------------------------------------
+   !!   Default option :                           vector opt. (k-j-i loop)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE exa_mpl( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE exa_mpl  ***
+      !!
+      !! ** Purpose :   Brief description of the routine
+      !!
+      !! ** Method  :   description of the methodoloy used to achieve the
+      !!      objectives of the routine. Be as clear as possible!
+      !!
+      !! ** Action  : - first action (share memory array/varible modified
+      !!                in this routine
+      !!              - second action .....
+      !!              - .....
+      !!
+      !! References :
+      !!   Give references if exist otherwise suppress these lines
+      !!
+      !! History :
+      !!   9.0  !  03-08  (Autor Names)  Original code
+      !!        !  02-08  (Author names)  brief description of modifications
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE toto_module                ! description od the module
+
+      !! * arguments
+      INTEGER, INTENT( in  ) ::   &  
+         kt                          ! describe it!!!
+
+      !! * local declarations
+      INTEGER ::   ji, jj, jk        ! dummy loop arguments
+      INTEGER ::   &
+         itoto, itata,            &  ! temporary integers
+         ititi                       ! please do not forget the DOCTOR rule:
+         !                           ! local integer: name start with i
+      REAL(wp) ::   &
+         zmlmin, zbbrau,          &  ! temporary scalars
+         zfact1, zfact2, zfact3,  &  !    "         "
+         zbn2, zesurf,            &  ! local scalar: name start with z
+         zemxl                       !
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         ztoto                       ! temporary workspace
+      !!--------------------------------------------------------------------
+
+
+
+      IF( kt == nit000  )   CALL exa_mpl_init    ! Initialization (first time-step only)
+
+      ! Local constant initialization
+      zmlmin = 1.e-8
+      zbbrau =  .5 * ebb / rau0
+      zfact1 = -.5 * rdt * efave
+      zfact2 = 1.5 * rdt * ediss
+      zfact3 = 0.5 * rdt * ediss
+
+
+      SELECT CASE ( npdl )
+
+      CASE ( 0 )           ! describe case 1
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avmv(ji,jj,jk) = ....
+               END DO
+            END DO
+         END DO
+
+      CASE ( 1 )           ! describe case 2
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avmv(ji,jj,jk) = ...
+               END DO
+            END DO
+         END DO
+
+      END SELECT
+
+      ! Lateral boundary conditions (avmu)   (unchanged sign)
+      CALL mpplnk2( avmu, 'U', 1. )
+
+   END SUBROUTINE exa_mpl
+
+# endif
+
+   SUBROUTINE exa_mpl_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE exa_mpl_init  ***
+      !!                   
+      !! ** Purpose :   initialization of ....
+      !!
+      !! ** Method  :   blah blah blah ...
+      !!
+      !! ** input   :   Namlist namexa
+      !!
+      !! ** Action  :   ...  
+      !!
+      !! history :
+      !!   9.0  !  03-08  (Autor Names)  Original code
+      !!----------------------------------------------------------------------
+      !! * local declarations
+      INTEGER ::   ji, jj, jk, jit   ! dummy loop indices
+
+      NAMELIST/namexa/ exa_v1, exa_v2, nexa_0  
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist namexa : example parameters
+      REWIND ( numnam )
+      READ   ( numnam, namexa )
+
+
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'exa_mpl_init : example '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '          Namelist namexa : set example parameters'
+         WRITE(numout,*) '             brief desciption               exa_v1  = ', exa_v1
+         WRITE(numout,*) '             brief desciption               exa_v1  = ', exa_v1
+         WRITE(numout,*) '             brief desciption               nexa_0  = ', nexa_0
+      ENDIF
+
+      ! Parameter control
+#if defined key_toto
+      IF(lwp) WRITE(numout,cform_err)
+      IF(lwp) WRITE(numout,*) '          this part and key_toto are incompatible'
+      nstop = nstop + 1
+#endif
+
+      ! Check nexa_0 values
+      IF( nexa_0 < 0 ) THEN
+         IF(lwp) WRITE(numout,cform_err)
+         IF(lwp) WRITE(numout,*) '          bad flag: nmxl is < 0 or > 3 '
+         nstop = nstop + 1
+      ENDIF
+
+   END SUBROUTINE exa_mpl_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE exa_mpl              ! Empty routine
+   END SUBROUTINE exa_mpl
+#endif
+
+   !!======================================================================
+END MODULE exampl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini.F90	(revision 1844)
@@ -0,0 +1,557 @@
+MODULE mppini
+   !!==============================================================================
+   !!                       ***  MODULE mppini   ***
+   !! Ocean initialization : distributed memory computing initialization
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   mpp_init       : Lay out the global domain over processors
+   !!   mpp_init2      : Lay out the global domain over processors 
+   !!                    with land processor elimination
+   !!   mpp_init_ioispl: IOIPSL initialization in mpp
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain 
+   USE in_out_manager  ! I/O Manager
+   USE sol_oce         ! ocean elliptic solver
+   USE lib_mpp         ! distribued memory computing library
+   USE ioipsl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC mpp_init       ! called by opa.F90
+   PUBLIC mpp_init2      ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if ! defined key_mpp_mpi   &&   ! defined key_mpp_shmem
+   !!----------------------------------------------------------------------
+   !!   Default option :                            shared memory computing
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE mpp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init  ***
+      !!
+      !! ** Purpose :   Lay out the global domain over processors.
+      !!
+      !! ** Method  :   Shared memory computing, set the local processor
+      !!      variables to the value of the global domain
+      !!
+      !! History :
+      !!   9.0  !  04-01  (G. Madec, J.M. Molines)  F90 : free form, north fold jpni >1
+      !!----------------------------------------------------------------------
+      ! No mpp computation
+
+      nimpp  = 1
+      njmpp  = 1
+      nlci   = jpi
+      nlcj   = jpj
+      nldi   = 1
+      nldj   = 1
+      nlei   = jpi
+      nlej   = jpj
+      nperio = jperio
+      nbondi = 2
+      nbondj = 2
+      nidom  = FLIO_DOM_NONE
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'mpp_init(2) : NO massively parallel processing'
+         WRITE(numout,*) '~~~~~~~~~~~: '
+         WRITE(numout,*) '         nperio = ', nperio
+         WRITE(numout,*) '         npolj  = ', npolj
+         WRITE(numout,*) '         nimpp  = ', nimpp
+         WRITE(numout,*) '         njmpp  = ', njmpp
+      ENDIF
+
+      IF(  jpni /= 1 .OR. jpnj /= 1 .OR. jpnij /= 1 ) THEN
+          IF(lwp)WRITE(numout,cform_err)
+          IF(lwp)WRITE(numout,*) 'equality  jpni = jpnj = jpnij = 1 is not satisfied'
+          IF(lwp)WRITE(numout,*) 'the domain is lay out for distributed memory computing! '
+          nstop = nstop + 1
+      ENDIF
+
+   END SUBROUTINE mpp_init
+
+
+   SUBROUTINE mpp_init2 
+      CALL mpp_init                             ! same routine as mpp_init
+   END SUBROUTINE mpp_init2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'          OR         MPI massively parallel processing
+   !!   'key_mpp_shmem'                 SHMEM massively parallel processing
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE mpp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!      Periodic condition is a function of the local domain position
+      !!      (global boundary or neighbouring domain) and of the global
+      !!      periodic
+      !!      Type :         jperio global periodic condition
+      !!                     nperio local  periodic condition
+      !!
+      !! ** Action  : - set domain parameters
+      !!                    nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlci      : first dimension
+      !!                    nlcj      : second dimension
+      !!                    nbondi    : mark for "east-west local boundary"
+      !!                    nbondj    : mark for "north-south local boundary"
+      !!                    nproc     : number for local processor
+      !!                    noea      : number for local neighboring processor
+      !!                    nowe      : number for local neighboring processor
+      !!                    noso      : number for local neighboring processor
+      !!                    nono      : number for local neighboring processor
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   8.5  !  02-08  (G. Madec)  F90 : free form
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::   ji, jj, jn               ! dummy loop indices
+      INTEGER ::   &
+         ii, ij, ifreq, il1, il2,        &  ! temporary integers
+         iresti, irestj, ijm1, imil,     &  !    "          "
+         inum                               ! temporary logical unit
+
+      INTEGER, DIMENSION(jpni,jpnj) ::   &
+         iimppt, ijmppt, ilcit, ilcjt       ! temporary workspace
+      REAL(wp) ::   zidom, zjdom            ! temporary scalars
+      !!----------------------------------------------------------------------
+
+#if defined key_mpp_shmem
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'mpp_init : Message Passing PVM T3E + SHMEM'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+
+      CALL mppshmem                           ! Initialisation of shmem array
+
+#endif
+#if defined key_mpp_mpi
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'mpp_init : Message Passing MPI'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+#endif
+
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !  Computation of local domain sizes ilcit() ilcjt()
+      !  These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array (cf. par_oce.F90).
+      
+      nreci  = 2 * jpreci
+      nrecj  = 2 * jprecj
+      iresti = MOD( jpiglo - nreci , jpni )
+      irestj = MOD( jpjglo - nrecj , jpnj )
+
+      IF(  iresti == 0 )   iresti = jpni
+      DO jj = 1, jpnj
+         DO ji = 1, iresti
+            ilcit(ji,jj) = jpi
+         END DO
+         DO ji = iresti+1, jpni
+            ilcit(ji,jj) = jpi -1
+         END DO
+      END DO
+      
+      IF( irestj == 0 )   irestj = jpnj
+      DO ji = 1, jpni
+         DO jj = 1, irestj
+            ilcjt(ji,jj) = jpj
+         END DO
+         DO jj = irestj+1, jpnj
+            ilcjt(ji,jj) = jpj -1
+         END DO
+      END DO
+      
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '           defines mpp subdomains'
+         WRITE(numout,*) '           ----------------------'
+         WRITE(numout,*) '              iresti=',iresti,' irestj=',irestj
+         WRITE(numout,*) '              jpni=',jpni,' jpnj=',jpnj
+         ifreq = 4
+         il1   = 1
+         DO jn = 1, (jpni-1)/ifreq+1
+            il2 = MIN( jpni, il1+ifreq-1 )
+            WRITE(numout,*)
+            WRITE(numout,9201) (ji,ji = il1,il2)
+            WRITE(numout,9200) ('***',ji = il1,il2-1)
+            DO jj = 1, jpnj
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9202) jj, ( ilcit(ji,jj),ilcjt(ji,jj),ji = il1,il2 )
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9200) ('***',ji = il1,il2-1)
+            END DO
+            il1 = il1+ifreq
+         END DO
+ 9200    FORMAT('     ***',20('*************',a3))
+ 9203    FORMAT('     *     ',20('         *   ',a3))
+ 9201    FORMAT('        ',20('   ',i3,'          '))
+ 9202    FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
+      ENDIF
+
+      zidom = nreci
+      DO ji = 1, jpni
+         zidom = zidom + ilcit(ji,1) - nreci
+      END DO
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilcit(i,1) = ', zidom, ' jpiglo = ', jpiglo
+      
+      zjdom = nrecj
+      DO jj = 1, jpnj
+         zjdom = zjdom + ilcjt(1,jj) - nrecj
+      END DO
+      IF(lwp) WRITE(numout,*)' sum ilcit(1,j) = ', zjdom, ' jpjglo = ', jpjglo
+      IF(lwp) WRITE(numout,*)
+      
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+      
+      iimppt(:,:) = 1
+      ijmppt(:,:) = 1
+      
+      IF( jpni > 1 ) THEN
+         DO jj = 1, jpnj
+            DO ji = 2, jpni
+               iimppt(ji,jj) = iimppt(ji-1,jj) + ilcit(ji-1,jj) - nreci
+            END DO
+         END DO
+      ENDIF
+
+      IF( jpnj > 1 ) THEN
+         DO jj = 2, jpnj
+            DO ji = 1, jpni
+               ijmppt(ji,jj) = ijmppt(ji,jj-1)+ilcjt(ji,jj-1)-nrecj
+            END DO
+         END DO
+      ENDIF
+      
+      ! 3. Subdomain description
+      ! ------------------------
+
+      DO jn = 1, jpnij
+         ii = 1 + MOD( jn-1, jpni )
+         ij = 1 + (jn-1) / jpni
+         nimppt(jn) = iimppt(ii,ij)
+         njmppt(jn) = ijmppt(ii,ij)
+         nlcit (jn) = ilcit (ii,ij)     
+         nlci       = nlcit (jn)     
+         nlcjt (jn) = ilcjt (ii,ij)     
+         nlcj       = nlcjt (jn)
+         nbondj = -1                                   ! general case
+         IF( jn   >  jpni          )   nbondj = 0      ! first row of processor
+         IF( jn   >  (jpnj-1)*jpni )   nbondj = 1      ! last  row of processor
+         IF( jpnj == 1             )   nbondj = 2      ! one processor only in j-direction
+         ibonjt(jn) = nbondj
+         
+         nbondi = 0                                    ! 
+         IF( MOD( jn, jpni ) == 1 )   nbondi = -1      !
+         IF( MOD( jn, jpni ) == 0 )   nbondi =  1      !
+         IF( jpni            == 1 )   nbondi =  2      ! one processor only in i-direction
+         ibonit(jn) = nbondi
+         
+         nldi =  1   + jpreci
+         nlei = nlci - jpreci
+         IF( nbondi == -1 .OR. nbondi == 2 )   nldi = 1
+         IF( nbondi ==  1 .OR. nbondi == 2 )   nlei = nlci
+         nldj =  1   + jprecj
+         nlej = nlcj - jprecj
+         IF( nbondj == -1 .OR. nbondj == 2 )   nldj = 1
+         IF( nbondj ==  1 .OR. nbondj == 2 )   nlej = nlcj
+         nldit(jn) = nldi
+         nleit(jn) = nlei
+         nldjt(jn) = nldj
+         nlejt(jn) = nlej
+      END DO
+      
+
+      ! 4. From global to local
+      ! -----------------------
+
+      nperio = 0
+      IF( jperio == 2 .AND. nbondj == -1 )   nperio = 2
+
+
+      ! 5. Subdomain neighbours
+      ! ----------------------
+
+      nproc = narea - 1
+      noso  = nproc - jpni
+      nowe  = nproc - 1
+      noea  = nproc + 1
+      nono  = nproc + jpni
+      ! great neighbours
+      npnw = nono - 1
+      npne = nono + 1
+      npsw = noso - 1
+      npse = noso + 1
+      nbsw = 1
+      nbnw = 1
+      IF( MOD( nproc, jpni ) == 0 ) THEN
+         nbsw = 0
+         nbnw = 0
+      ENDIF
+      nbse = 1
+      nbne = 1
+      IF( MOD( nproc, jpni ) == jpni-1 ) THEN
+         nbse = 0
+         nbne = 0
+      ENDIF
+      IF(nproc < jpni) THEN
+         nbsw = 0
+         nbse = 0
+      ENDIF
+      IF( nproc >= (jpnj-1)*jpni ) THEN
+         nbnw = 0
+         nbne = 0
+      ENDIF
+      nlcj = nlcjt(narea)  
+      nlci = nlcit(narea)  
+      nldi = nldit(narea)
+      nlei = nleit(narea)
+      nldj = nldjt(narea)
+      nlej = nlejt(narea)
+      nbondi = ibonit(narea)
+      nbondj = ibonjt(narea)
+      nimpp  = nimppt(narea)  
+      njmpp  = njmppt(narea)  
+
+     ! Save processor layout in layout.dat file 
+       IF (lwp) THEN
+        CALL ctlopn( inum, 'layout.dat', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+           &         1, numout, .FALSE., 1 )
+        WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
+        WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
+
+        DO  jn = 1, jpnij
+         WRITE(inum,'(9i5)') jn, nlcit(jn), nlcjt(jn), &
+                                      nldit(jn), nldjt(jn), &
+                                      nleit(jn), nlejt(jn), &
+                                      nimppt(jn), njmppt(jn)
+        END DO
+        CLOSE(inum)   
+      END IF
+
+
+      ! w a r n i n g  narea (zone) /= nproc (processors)!
+
+      IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN
+         IF( jpni == 1 )THEN
+            nbondi = 2
+            nperio = 1
+         ELSE
+            nbondi = 0
+         ENDIF
+         IF( MOD( narea, jpni ) == 0 ) THEN
+            noea = nproc-(jpni-1)
+            npne = npne-jpni
+            npse = npse-jpni
+         ENDIF
+         IF( MOD( narea, jpni ) == 1 ) THEN
+            nowe = nproc+(jpni-1)
+            npnw = npnw+jpni
+            npsw = npsw+jpni
+         ENDIF
+         nbsw = 1
+         nbnw = 1
+         nbse = 1
+         nbne = 1
+         IF( nproc < jpni ) THEN
+            nbsw = 0
+            nbse = 0
+         ENDIF
+         IF( nproc >= (jpnj-1)*jpni ) THEN
+            nbnw = 0
+            nbne = 0
+         ENDIF
+      ENDIF
+      npolj = 0
+      IF( jperio == 3 .OR. jperio == 4 ) THEN
+         ijm1 = jpni*(jpnj-1)
+         imil = ijm1+(jpni+1)/2
+         IF( narea > ijm1 ) npolj = 3
+         IF( MOD(jpni,2) == 1 .AND. narea == imil ) npolj = 4
+         IF( npolj == 3 ) nono = jpni*jpnj-narea+ijm1
+      ENDIF
+      IF( jperio == 5 .OR. jperio == 6 ) THEN
+          ijm1 = jpni*(jpnj-1)
+          imil = ijm1+(jpni+1)/2
+          IF( narea > ijm1) npolj = 5
+          IF( MOD(jpni,2) == 1 .AND. narea == imil ) npolj = 6
+          IF( npolj == 5 ) nono = jpni*jpnj-narea+ijm1
+      ENDIF
+
+      ! FETI method
+
+      IF( nperio == 1 .AND. nsolv == 3 ) THEN 
+         
+         ! general case : Earth == infinite tube
+         
+         nbnw = 1
+         npnw = narea
+         nbne = 1
+         npne = narea
+         nbsw = 1
+         npsw = (narea-2)
+         nbse = 1
+         npse = (narea-2)
+         
+         ! REAL boundary condition
+         
+         IF( nbondj == -1 .OR. nbondj == 2 ) THEN 
+            nbsw = 0
+            nbse = 0
+         ENDIF
+         
+         IF( nbondj == -1 .OR. nbondj == 2 ) THEN 
+            nbsw = 0
+            nbse = 0
+         ENDIF
+         
+         IF( nbondj == 1  .OR. nbondj == 2 ) THEN 
+            nbnw = 0
+            nbne = 0
+         ENDIF
+      ENDIF
+
+      ! Periodicity : no corner if nbondi = 2 and nperio != 1
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' nproc  = ', nproc
+         WRITE(numout,*) ' nowe   = ', nowe  , ' noea   =  ', noea
+         WRITE(numout,*) ' nono   = ', nono  , ' noso   =  ', noso
+         WRITE(numout,*) ' nbondi = ', nbondi
+         WRITE(numout,*) ' nbondj = ', nbondj
+         WRITE(numout,*) ' npolj  = ', npolj
+         WRITE(numout,*) ' nperio = ', nperio
+         WRITE(numout,*) ' nlci   = ', nlci
+         WRITE(numout,*) ' nlcj   = ', nlcj
+         WRITE(numout,*) ' nimpp  = ', nimpp
+         WRITE(numout,*) ' njmpp  = ', njmpp
+         WRITE(numout,*) ' nbse   = ', nbse  , ' npse   = ', npse
+         WRITE(numout,*) ' nbsw   = ', nbsw  , ' npsw   = ', npsw
+         WRITE(numout,*) ' nbne   = ', nbne  , ' npne   = ', npne
+         WRITE(numout,*) ' nbnw   = ', nbnw  , ' npnw   = ', npnw
+      ENDIF
+
+      IF( nperio == 1 .AND. jpni /= 1 )THEN
+         IF(lwp) WRITE(numout,cform_err)
+         IF(lwp) WRITE(numout,*) ' mpp_init: error on cyclicity'
+         nstop = nstop + 1
+      ENDIF
+
+      ! Prepare mpp north fold
+
+      IF (jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+         CALL mpp_ini_north
+      END IF
+
+      ! Prepare NetCDF output file (if necessary)
+      CALL mpp_init_ioipsl
+
+   END SUBROUTINE mpp_init
+
+#  include "mppini_2.h90"
+
+# if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   'key_dimgout'                  NO use of NetCDF files
+   !!----------------------------------------------------------------------
+   SUBROUTINE mpp_init_ioipsl       ! Dummy routine
+   END SUBROUTINE mpp_init_ioipsl  
+# else
+   SUBROUTINE mpp_init_ioipsl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init_ioipsl  ***
+      !!
+      !! ** Purpose :   
+      !!
+      !! ** Method  :   
+      !!
+      !! History :
+      !!   9.0  !  04-03  (G. Madec)  MPP-IOIPSL 
+      !!----------------------------------------------------------------------
+      !! Local declarations
+
+      INTEGER, DIMENSION(2) ::   &
+         iglo, iloc, iabsf, iabsl, ihals, ihale, idid
+      INTEGER ::   &
+         inbondi, inbondj
+      !!----------------------------------------------------------------------
+
+      ! The domain is splitted only horizontally along i- or/and j- direction
+      ! So we need at the most only 1D arrays with 2 elements
+      iglo(1) = jpiglo
+      iglo(2) = jpjglo
+      iloc(1) = nlci
+      iloc(2) = nlcj
+      iabsf(1) = nimppt(narea)
+      iabsf(2) = njmppt(narea)
+      iabsl(:) = iabsf(:) + iloc(:) - 1
+      ihals(1) = jpreci
+      ihals(2) = jprecj
+      ihale(1) = jpreci
+      ihale(2) = jprecj
+      idid(1) = 1
+      idid(2) = 2
+
+      inbondj = -1                                   ! general case
+      IF( narea   >  jpni          )   inbondj = 0      ! first row of processor
+      IF( narea   >  (jpnj-1)*jpni )   inbondj = 1      ! last  row of processor
+      IF( jpnj    == 1             )   inbondj = 2      ! one processor only in j-direction
+      IF( inbondj == -1 .OR. inbondj == 2 )   ihals(2) = 0
+      IF( inbondj ==  1 .OR. inbondj == 2 )   ihale(2) = 0
+         
+      inbondi = 0                                    ! 
+      IF( MOD( narea, jpni ) == 1 )   inbondi = -1      !
+      IF( MOD( narea, jpni ) == 0 )   inbondi =  1      !
+      IF( jpni               == 1 )   inbondi =  2      ! one processor only in i-direction
+      IF( inbondi == -1 .OR. inbondi == 2 )   ihals(1) = 0
+      IF( inbondi ==  1 .OR. inbondi == 2 )   ihale(1) = 0
+
+
+      IF(lwp) THEN
+          WRITE(numout,*) 'mpp_init_ioipsl :   iloc  = ', iloc (1), iloc (2)
+          WRITE(numout,*) '~~~~~~~~~~~~~~~     iabsf = ', iabsf(1), iabsf(2)
+          WRITE(numout,*) '                    ihals = ', ihals(1), ihals(2)
+          WRITE(numout,*) '                    ihale = ', ihale(1), ihale(2)
+      ENDIF
+
+      CALL flio_dom_set ( jpnij, nproc, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom)
+
+   END SUBROUTINE mpp_init_ioipsl  
+
+# endif
+#endif
+
+   !!======================================================================
+END MODULE mppini
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini_2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini_2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/mppini_2.h90	(revision 1844)
@@ -0,0 +1,566 @@
+   SUBROUTINE mpp_init2
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init2  ***
+      !!
+      !! * Purpose :   Lay out the global domain over processors.
+      !!     FOR USING THIS VERSION, A PREPROCESSING TRAITMENT IS RECOMMENDED
+      !!     FOR DEFINING BETTER CUTTING OUT.
+      !!       This routine is used with a the bathymetry file.
+      !!       In this version, the land processors are avoided and the adress
+      !!     processor (nproc, narea,noea, ...) are calculated again.
+      !!     The jpnij parameter can be lesser than jpni x jpnj
+      !!     and this jpnij parameter must be calculated before with an
+      !!     algoritmic preprocessing program.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!      Periodic condition is a function of the local domain position
+      !!      (global boundary or neighbouring domain) and of the global
+      !!      periodic
+      !!      Type :         jperio global periodic condition
+      !!                     nperio local  periodic condition
+      !!
+      !! ** Action :        nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlci      : first dimension
+      !!                    nlcj      : second dimension
+      !!                    nproc     : number for local processor
+      !!                    noea      : number for local neighboring processor
+      !!                    nowe      : number for local neighboring processor
+      !!                    noso      : number for local neighboring processor
+      !!                    nono      : number for local neighboring processor
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   9.0  !  04-01  (G. Madec, J.M Molines)  F90 : free form , north fold jpni > 1
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+   
+      !! Local variables
+      INTEGER :: ji, jj, jn, jproc, jarea     ! dummy loop indices
+      INTEGER ::  inum                        ! temporary logical unit
+      INTEGER ::   &
+         ii, ij, ifreq, il1, il2,          &  ! temporary integers
+         icont, ili, ilj,                  &  !    "          "
+         isurf, ijm1, imil,                &  !    "          "
+         iino, ijno, iiso, ijso,           &  !    "          " 
+         iiea, ijea, iiwe, ijwe,           &  !    "          "
+         iinw, ijnw, iine, ijne,           &  !    "          "
+         iisw, ijsw, iise, ijse,           &  !    "          "
+         iresti, irestj, iproc                !    "          "
+      INTEGER, DIMENSION(jpnij) ::   &
+         iin, ijn          
+      INTEGER, DIMENSION(jpni,jpnj) ::   &
+         iimppt, ijmppt, ilci  , ilcj  ,   &  ! temporary workspace
+         ipproc, ibondj, ibondi, ipolj ,   &  !    "           "
+         ilei  , ilej  , ildi  , ildj  ,   &  !    "           "
+         ioea  , iowe  , ioso  , iono  ,   &  !    "           "
+         ione  , ionw  , iose  , iosw  ,   &  !    "           "
+         ibne  , ibnw  , ibse  , ibsw         !    "           "
+      INTEGER, DIMENSION(jpi,jpj) ::   &
+         imask                                ! temporary global workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zdta                   ! temporary data workspace
+      REAL(wp) ::   zidom , zjdom          ! temporary scalars
+
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+
+#if defined key_mpp_shmem
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) 'mpp_init : Message Passing PVM T3E + SHMEM'
+      IF(lwp)WRITE(numout,*) '~~~~~~~~'
+      IF(lwp)WRITE(numout,*) ' '
+
+      CALL mppshmem     ! Initialisation of shmem array
+
+#endif
+#if defined key_mpp_mpi
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) 'mpp_init : Message Passing MPI'
+      IF(lwp)WRITE(numout,*) '~~~~~~~~'
+      IF(lwp)WRITE(numout,*) ' '
+#endif
+
+      IF( jpni*jpnj < jpnij ) CALL ctl_stop( ' jpnij > jpni x jpnj impossible' )
+
+      ! 0. initialisation
+      ! -----------------
+
+      ! open the file
+      IF ( ln_zps ) THEN
+         CALL iom_open ( 'bathy_meter.nc', inum )   ! Meter bathy in case of partial steps
+         CALL iom_get ( inum, jpdom_data, 'Bathymetry' , zdta )
+      ELSE 
+         CALL iom_open ( 'bathy_level.nc', inum )   ! Level bathymetry
+         CALL iom_get ( inum, jpdom_data, 'Bathy_level', zdta )
+      ENDIF
+      CALL iom_close (inum)
+
+      ! land/sea mask over the global/zoom domain
+
+      imask(:,:)=1
+      WHERE ( zdta(:,:) <= 0. ) imask = 0
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+
+      !  Computation of local domain sizes ilci() ilcj()
+      !  These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array.
+
+      nreci=2*jpreci
+      nrecj=2*jprecj
+      iresti = 1 + MOD( jpiglo - nreci -1 , jpni )
+      irestj = 1 + MOD( jpjglo - nrecj -1 , jpnj )
+
+      ilci(1:iresti      ,:) = jpi
+      ilci(iresti+1:jpni ,:) = jpi-1
+
+      ilcj(:,      1:irestj) = jpj
+      ilcj(:, irestj+1:jpnj) = jpj-1
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' mpp_init2: defines mpp subdomains'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~  ----------------------'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'iresti=',iresti,' irestj=',irestj
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'jpni=',jpni,' jpnj=',jpnj
+
+      zidom = nreci + sum(ilci(:,1) - nreci ) 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilci(i,1)=',zidom,' jpiglo=',jpiglo
+
+      zjdom = nrecj + sum(ilcj(1,:) - nrecj ) 
+      IF(lwp) WRITE(numout,*) ' sum ilcj(1,j)=',zjdom,' jpjglo=',jpjglo
+      IF(lwp) WRITE(numout,*)
+
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+
+      iimppt(:,:) = 1
+      ijmppt(:,:) = 1
+      ipproc(:,:) = -1
+
+      IF( jpni > 1 )THEN
+         DO jj = 1, jpnj
+            DO ji = 2, jpni
+               iimppt(ji,jj) = iimppt(ji-1,jj) + ilci(ji-1,jj) - nreci
+            END DO
+         END DO
+      ENDIF
+
+      IF( jpnj > 1 )THEN
+         DO jj = 2, jpnj
+            DO ji = 1, jpni
+               ijmppt(ji,jj) = ijmppt(ji,jj-1) + ilcj(ji,jj-1) - nrecj
+            END DO
+         END DO
+      ENDIF
+
+
+      ! 3. Subdomain description in the Regular Case
+      ! --------------------------------------------
+
+      nperio = 0
+      icont = -1
+      DO jarea = 1, jpni*jpnj
+         ii = 1 + MOD(jarea-1,jpni)
+         ij = 1 +    (jarea-1)/jpni
+         ili = ilci(ii,ij)
+         ilj = ilcj(ii,ij)
+
+         ibondj(ii,ij) = -1
+         IF( jarea >  jpni          )   ibondj(ii,ij) = 0
+         IF( jarea >  (jpnj-1)*jpni )   ibondj(ii,ij) = 1
+         IF( jpnj  == 1             )   ibondj(ii,ij) = 2
+
+         ibondi(ii,ij) = 0
+         IF( MOD(jarea,jpni) == 1 )   ibondi(ii,ij) = -1
+         IF( MOD(jarea,jpni) == 0 )   ibondi(ii,ij) =  1
+         IF( jpni            == 1 )   ibondi(ii,ij) =  2
+
+         ! 2.4 Subdomain neighbors
+
+         iproc = jarea - 1
+         ioso(ii,ij) = iproc - jpni
+         iowe(ii,ij) = iproc - 1
+         ioea(ii,ij) = iproc + 1
+         iono(ii,ij) = iproc + jpni
+         ildi(ii,ij) = 1 + jpreci
+         ilei(ii,ij) = ili -jpreci
+         ionw(ii,ij) = iono(ii,ij) - 1
+         ione(ii,ij) = iono(ii,ij) + 1
+         iosw(ii,ij) = ioso(ii,ij) - 1
+         iose(ii,ij) = ioso(ii,ij) + 1
+         ibsw(ii,ij) = 1
+         ibnw(ii,ij) = 1
+         IF( MOD(iproc,jpni) == 0 ) THEN
+            ibsw(ii,ij) = 0
+            ibnw(ii,ij) = 0
+         ENDIF
+         ibse(ii,ij) = 1
+         ibne(ii,ij) = 1
+         IF( MOD(iproc,jpni) == jpni-1 ) THEN
+            ibse(ii,ij) = 0
+            ibne(ii,ij) = 0
+         ENDIF
+         IF( iproc < jpni ) THEN
+            ibsw(ii,ij) = 0
+            ibse(ii,ij) = 0
+         ENDIF
+         IF( iproc >= (jpnj-1)*jpni ) THEN
+            ibnw(ii,ij) = 0
+            ibne(ii,ij) = 0
+         ENDIF
+         IF( ibondi(ii,ij) == -1 .OR. ibondi(ii,ij) == 2 ) ildi(ii,ij) = 1
+         IF( ibondi(ii,ij) ==  1 .OR. ibondi(ii,ij) == 2 ) ilei(ii,ij) = ili
+         ildj(ii,ij) =  1  + jprecj
+         ilej(ii,ij) = ilj - jprecj
+         IF( ibondj(ii,ij) == -1 .OR. ibondj(ii,ij) == 2 ) ildj(ii,ij) = 1
+         IF( ibondj(ii,ij) ==  1 .OR. ibondj(ii,ij) == 2 ) ilej(ii,ij) = ilj
+
+         ! warning ii*ij (zone) /= nproc (processors)!
+
+         IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN
+            IF( jpni == 1 )THEN
+               ibondi(ii,ij) = 2
+               nperio = 1
+            ELSE
+               ibondi(ii,ij) = 0
+            ENDIF
+            IF( MOD(jarea,jpni) == 0 ) THEN
+               ioea(ii,ij) = iproc - (jpni-1)
+               ione(ii,ij) = ione(ii,ij) - jpni
+               iose(ii,ij) = iose(ii,ij) - jpni
+            ENDIF
+            IF( MOD(jarea,jpni) == 1 ) THEN
+               iowe(ii,ij) = iproc + jpni - 1
+               ionw(ii,ij) = ionw(ii,ij) + jpni
+               iosw(ii,ij) = iosw(ii,ij) + jpni 
+            ENDIF
+            ibsw(ii,ij) = 1
+            ibnw(ii,ij) = 1
+            ibse(ii,ij) = 1
+            ibne(ii,ij) = 1
+            IF( iproc < jpni ) THEN
+               ibsw(ii,ij) = 0
+               ibse(ii,ij) = 0
+            ENDIF
+            IF( iproc >= (jpnj-1)*jpni ) THEN
+               ibnw(ii,ij) = 0
+               ibne(ii,ij) = 0
+            ENDIF
+         ENDIF
+         ipolj(ii,ij) = 0
+         IF( jperio == 3 .OR. jperio == 4 ) THEN
+            ijm1 = jpni*(jpnj-1)
+            imil = ijm1+(jpni+1)/2
+            IF( jarea > ijm1 ) ipolj(ii,ij) = 3
+            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 4
+            IF( ipolj(ii,ij) == 3 ) iono(ii,ij) = jpni*jpnj-jarea+ijm1
+         ENDIF
+         IF( jperio == 5 .OR. jperio == 6 ) THEN
+            ijm1 = jpni*(jpnj-1)
+            imil = ijm1+(jpni+1)/2
+            IF( jarea > ijm1) ipolj(ii,ij) = 5
+            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 6
+            IF( ipolj(ii,ij) == 5) iono(ii,ij) = jpni*jpnj-jarea+ijm1
+         ENDIF
+
+         isurf = 0
+         DO jj = 1+jprecj, ilj-jprecj
+            DO  ji = 1+jpreci, ili-jpreci
+               IF( imask(ji, jj) == 1) isurf = isurf+1
+            END DO
+         END DO
+         IF(isurf /= 0) THEN
+            icont = icont + 1
+            ipproc(ii,ij) = icont
+            iin(icont+1) = ii
+            ijn(icont+1) = ij
+         ENDIF
+      END DO
+
+      ! Control
+      IF(icont+1 /= jpnij) THEN
+         WRITE(ctmp1,*) ' jpni =',jpni,' jpnj =',jpnj
+         WRITE(ctmp2,*) ' jpnij =',jpnij, '< jpni x jpnj' 
+         WRITE(ctmp3,*) ' ***********, mpp_init2 finds jpnij=',icont+1
+         CALL ctl_stop( ' Eliminate land processors algorithm', '', ctmp1, ctmp2, '', ctmp3 )
+      ENDIF
+
+      ! 4. Subdomain print
+      ! ------------------
+
+      IF(lwp) THEN
+         ifreq = 4
+         il1 = 1
+         DO jn = 1,(jpni-1)/ifreq+1
+            il2 = MIN(jpni,il1+ifreq-1)
+            WRITE(numout,*)
+            WRITE(numout,9401) (ji,ji=il1,il2)
+            WRITE(numout,9400) ('***',ji=il1,il2-1)
+            DO jj = 1, jpnj
+               ! WRITE(numout,9400)
+               WRITE(numout,9403) ('   ',ji=il1,il2-1)
+               WRITE(numout,9402) jj, (ilci(ji,jj),ilcj(ji,jj),ji=il1,il2)
+               WRITE(numout,9404) (ipproc(ji,jj),ji=il1,il2)
+               WRITE(numout,9403) ('   ',ji=il1,il2-1)
+               WRITE(numout,9400) ('***',ji=il1,il2-1)
+               ! WRITE(numout,9400)
+            END DO
+            il1 = il1+ifreq
+         END DO
+ 9400     FORMAT('     ***',20('*************',a3))
+ 9403     FORMAT('     *     ',20('         *   ',a3))
+ 9401     FORMAT('        ',20('   ',i3,'          '))
+ 9402     FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
+ 9404     FORMAT('     *  ',20('      ',i3,'   *   '))
+      ENDIF
+
+
+      ! 5. neighbour treatment
+      ! ----------------------
+
+      DO jarea = 1, jpni*jpnj
+         iproc = jarea-1
+         ii = 1 + MOD(jarea-1,jpni)
+         ij = 1 +    (jarea-1)/jpni
+         IF( ipproc(ii,ij) == -1 .AND. iono(ii,ij) >= 0   &
+            .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN
+            iino = 1 + MOD(iono(ii,ij),jpni)
+            ijno = 1 +    (iono(ii,ij))/jpni
+            IF( ibondj(iino,ijno) == 1 ) ibondj(iino,ijno)=2
+            IF( ibondj(iino,ijno) == 0 ) ibondj(iino,ijno) = -1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ioso(ii,ij) >= 0   &
+            .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN
+            iiso = 1 + MOD(ioso(ii,ij),jpni)
+            ijso = 1 +    (ioso(ii,ij))/jpni
+            IF( ibondj(iiso,ijso) == -1 ) ibondj(iiso,ijso) = 2
+            IF( ibondj(iiso,ijso) ==  0 ) ibondj(iiso,ijso) = 1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ioea(ii,ij) >= 0   &
+            .AND. ioea(ii,ij) <= jpni*jpnj-1) THEN
+            iiea = 1 + MOD(ioea(ii,ij),jpni)
+            ijea = 1 +    (ioea(ii,ij))/jpni
+            IF( ibondi(iiea,ijea) == 1 ) ibondi(iiea,ijea) = 2
+            IF( ibondi(iiea,ijea) == 0 ) ibondi(iiea,ijea) = -1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. iowe(ii,ij) >= 0   &
+            .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN
+            iiwe = 1 + MOD(iowe(ii,ij),jpni)
+            ijwe = 1 +    (iowe(ii,ij))/jpni
+            IF( ibondi(iiwe,ijwe) == -1 ) ibondi(iiwe,ijwe) = 2
+            IF( ibondi(iiwe,ijwe) ==  0 ) ibondi(iiwe,ijwe) = 1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibne(ii,ij) == 1 ) THEN
+            iine = 1 + MOD(ione(ii,ij),jpni)
+            ijne = 1 +    (ione(ii,ij))/jpni
+            IF( ibsw(iine,ijne) == 1 ) ibsw(iine,ijne) = 0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibsw(ii,ij) == 1 ) THEN
+            iisw = 1 + MOD(iosw(ii,ij),jpni)
+            ijsw = 1 +    (iosw(ii,ij))/jpni
+            IF( ibne(iisw,ijsw) == 1 ) ibne(iisw,ijsw) = 0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibnw(ii,ij) == 1 ) THEN
+            iinw = 1 + MOD(ionw(ii,ij),jpni)
+            ijnw = 1 +    (ionw(ii,ij))/jpni
+            IF( ibse(iinw,ijnw) == 1 ) ibse(iinw,ijnw)=0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibse(ii,ij) == 1 ) THEN
+            iise = 1 + MOD(iose(ii,ij),jpni)
+            ijse = 1 +    (iose(ii,ij))/jpni
+            IF( ibnw(iise,ijse) == 1 ) ibnw(iise,ijse) = 0
+         ENDIF
+      END DO
+
+
+      ! 6. Change processor name
+      ! ------------------------
+
+      nproc = narea-1
+      ii = iin(narea)
+      ij = ijn(narea)
+      IF( ioso(ii,ij) >= 0 .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiso = 1 + MOD(ioso(ii,ij),jpni)
+         ijso = 1 +    (ioso(ii,ij))/jpni
+         noso = ipproc(iiso,ijso)
+      ENDIF
+      IF( iowe(ii,ij) >= 0 .AND. iowe(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiwe = 1 + MOD(iowe(ii,ij),jpni)
+         ijwe = 1 +    (iowe(ii,ij))/jpni
+         nowe = ipproc(iiwe,ijwe)
+      ENDIF
+      IF( ioea(ii,ij) >= 0 .AND. ioea(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiea = 1 + MOD(ioea(ii,ij),jpni)
+         ijea = 1 +    (ioea(ii,ij))/jpni
+         noea = ipproc(iiea,ijea)
+      ENDIF
+      IF( iono(ii,ij) >= 0 .AND. iono(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iino = 1 + MOD(iono(ii,ij),jpni)
+         ijno = 1 +    (iono(ii,ij))/jpni
+         nono = ipproc(iino,ijno)
+      ENDIF
+      IF( iose(ii,ij) >= 0 .AND. iose(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iise = 1 + MOD(iose(ii,ij),jpni)
+         ijse = 1 +    (iose(ii,ij))/jpni
+         npse = ipproc(iise,ijse)
+      ENDIF
+      IF( iosw(ii,ij) >= 0 .AND. iosw(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iisw = 1 + MOD(iosw(ii,ij),jpni)
+         ijsw = 1 +    (iosw(ii,ij))/jpni
+         npsw = ipproc(iisw,ijsw)
+      ENDIF
+      IF( ione(ii,ij) >= 0 .AND. ione(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iine = 1 + MOD(ione(ii,ij),jpni)
+         ijne = 1 +    (ione(ii,ij))/jpni
+         npne = ipproc(iine,ijne)
+      ENDIF
+      IF( ionw(ii,ij) >= 0 .AND. ionw(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iinw = 1 + MOD(ionw(ii,ij),jpni)
+         ijnw = 1 +    (ionw(ii,ij))/jpni
+         npnw = ipproc(iinw,ijnw)
+      ENDIF
+      nbnw = ibnw(ii,ij)
+      nbne = ibne(ii,ij)
+      nbsw = ibsw(ii,ij)
+      nbse = ibse(ii,ij)
+      nlcj = ilcj(ii,ij)  
+      nlci = ilci(ii,ij)  
+      nldi = ildi(ii,ij)
+      nlei = ilei(ii,ij)
+      nldj = ildj(ii,ij)
+      nlej = ilej(ii,ij)
+      nbondi = ibondi(ii,ij)
+      nbondj = ibondj(ii,ij)
+      nimpp = iimppt(ii,ij)  
+      njmpp = ijmppt(ii,ij)  
+      DO jproc = 1, jpnij
+         ii = iin(jproc)
+         ij = ijn(jproc)
+         nimppt(jproc) = iimppt(ii,ij)  
+         njmppt(jproc) = ijmppt(ii,ij)  
+         nlcjt(jproc) = ilcj(ii,ij)
+         nlcit(jproc) = ilci(ii,ij)
+         nldit(jproc) = ildi(ii,ij)
+         nleit(jproc) = ilei(ii,ij)
+         nldjt(jproc) = ildj(ii,ij)
+         nlejt(jproc) = ilej(ii,ij)
+      END DO
+
+      ! Save processor layout in ascii file
+      IF (lwp) THEN
+         CALL ctlopn( inum, 'layout.dat', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+            &         1, numout, .FALSE., 1 )
+         WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
+         WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
+
+        DO  jproc = 1, jpnij
+         WRITE(inum,'(9i5)') jproc, nlcit(jproc), nlcjt(jproc), &
+                                      nldit(jproc), nldjt(jproc), &
+                                      nleit(jproc), nlejt(jproc), &
+                                      nimppt(jproc), njmppt(jproc)
+        END DO
+        CLOSE(inum)   
+      END IF
+
+
+      ! FETI method
+
+      IF( nperio == 1 .AND. nsolv == 3 ) THEN 
+
+         ! general CASE : Earth == infinite tube
+
+         nbnw = 1
+         npnw = narea
+         nbne = 1
+         npne = narea
+         nbsw = 1
+         npsw = (narea-2)
+         nbse = 1
+         npse = (narea-2)
+
+         ! REAL boundary condition
+
+         IF( nbondj == -1 .OR. nbondj == 2 ) THEN 
+            nbsw = 0
+            nbse = 0
+         ENDIF
+
+         IF( nbondj == -1 .OR. nbondj == 2 ) THEN 
+            nbsw = 0
+            nbse = 0
+         ENDIF
+
+         IF( nbondj ==  1 .OR. nbondj == 2 ) THEN 
+            nbnw = 0
+            nbne = 0
+         ENDIF
+      ENDIF
+
+      IF( nperio == 1 .AND.jpni /= 1 ) CALL ctl_stop( ' mpp_init2:  error on cyclicity' )
+
+      ! Prepare mpp north fold
+
+      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+         CALL mpp_ini_north
+         IF(lwp) WRITE(numout,*) ' mpp_init2 : North fold boundary prepared for jpni >1'
+      ENDIF
+
+      ! Defined npolj, either 0, 3 , 4 , 5 , 6
+      ! In this case the important thing is that npolj /= 0
+      ! Because if we go through these line it is because jpni >1 and thus
+      ! we must use lbcnorthmpp, which tests only npolj =0 or npolj /= 0
+
+      npolj = 0
+      ij = ijn(narea)
+
+      IF( jperio == 3 .OR. jperio == 4 ) THEN
+         IF( ij == jpnj ) npolj = 3
+      ENDIF
+
+      IF( jperio == 5 .OR. jperio == 6 ) THEN
+         IF( ij == jpnj ) npolj = 5
+      ENDIF
+
+      ! Prepare NetCDF output file (if necessary)
+      CALL mpp_init_ioipsl
+
+      ! Periodicity : no corner if nbondi = 2 and nperio != 1
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' nproc=  ',nproc
+         WRITE(numout,*) ' nowe=   ',nowe
+         WRITE(numout,*) ' noea=   ',noea
+         WRITE(numout,*) ' nono=   ',nono
+         WRITE(numout,*) ' noso=   ',noso
+         WRITE(numout,*) ' nbondi= ',nbondi
+         WRITE(numout,*) ' nbondj= ',nbondj
+         WRITE(numout,*) ' npolj=  ',npolj
+         WRITE(numout,*) ' nperio= ',nperio
+         WRITE(numout,*) ' nlci=   ',nlci
+         WRITE(numout,*) ' nlcj=   ',nlcj
+         WRITE(numout,*) ' nimpp=  ',nimpp
+         WRITE(numout,*) ' njmpp=  ',njmpp
+         WRITE(numout,*) ' nbse=   ',nbse,' npse= ',npse
+         WRITE(numout,*) ' nbsw=   ',nbsw,' npsw= ',npsw
+         WRITE(numout,*) ' nbne=   ',nbne,' npne= ',npne
+         WRITE(numout,*) ' nbnw=   ',nbnw,' npnw= ',npnw
+      ENDIF
+
+   END SUBROUTINE mpp_init2
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/oce.F90	(revision 1844)
@@ -0,0 +1,42 @@
+MODULE oce
+   !!======================================================================
+   !!                      ***  MODULE  oce  ***
+   !! Ocean        :  dynamics and active tracers defined in memory 
+   !!======================================================================
+   !! History :
+   !!   8.5  !  02-11  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! dynamics and tracer fields
+   !! --------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      ! before !  now      !  after  !      ! the after trends becomes the fields
+      ! fields !  fields   !  trends !      ! only in dyn(tra)_zdf and dyn(tra)_nxt
+                  un       ,  ua     ,   &  !: i-horizontal velocity (m/s)
+                  vn       ,  va     ,   &  !: j-horizontal velocity (m/s)
+                  wn       ,             &  !: vertical velocity (m/s)
+                  hdivn    ,             &  !: horizontal divergence (1/s)
+                  tn       ,  ta     ,   &  !: potential temperature (celcius)
+                  sn       ,  sa            !: salinity (psu)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      rhd ,                              &  !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+      rhop,                              &  !: potential volumic mass (kg/m3)
+      rn2                                   !: brunt-vaisala frequency (1/s2)
+
+   !! interpolated gradient
+   !! ---------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &   !:
+      gtu, gsu, gru,      &  !: t-, s- and rd horizontal gradient at u- and 
+      gtv, gsv, grv          !: v-points at bottom ocean level 
+
+   !!----------------------------------------------------------------------
+END MODULE oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/opa.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/opa.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/opa.F90	(revision 1844)
@@ -0,0 +1,354 @@
+MODULE opa
+   !!==============================================================================
+   !!                       ***  MODULE opa   ***
+   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space domain variables
+   USE oce             ! dynamics and tracers variables
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing
+
+   USE domcfg          ! domain configuration               (dom_cfg routine)
+   USE mppini          ! shared/distributed memory setting (mpp_init routine)
+   USE domain          ! domain initialization             (dom_init routine)
+   USE istate          ! initial state setting          (istate_init routine)
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+
+   ! ocean physics
+   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
+   USE traqsr          ! solar radiation penetration   (tra_qsr_init routine)
+
+   USE phycst          ! physical constant                  (par_cst routine)
+   USE dtadyn          ! Lecture and Interpolation of the dynamical fields
+   USE trcini          ! Initilization of the passive tracers
+   USE step            ! OPA time-stepping                  (stp     routine)
+
+   USE iom
+#if defined key_iomput
+   USE  mod_ioclient
+#endif 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Module variables
+   CHARACTER (len=64) ::        &
+      cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
+
+   !! * Routine accessibility
+   PUBLIC opa_model      ! called by model.F90
+   PUBLIC opa_init
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+   !!   $Id$
+   !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE opa_model
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa  ***
+      !!
+      !! ** Purpose :   opa solves the primitive equations on an orthogonal
+      !!      curvilinear mesh on the sphere.
+      !!
+      !! ** Method  : - model general initialization
+      !!              - launch the time-stepping (stp routine)
+      !!
+      !! References :
+      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
+      !!              internal report, IPSL.
+      !!----------------------------------------------------------------------
+      INTEGER ::   istp       ! time step index
+      !!----------------------------------------------------------------------
+
+      CALL opa_init  ! Initializations
+
+      IF( lk_mpp )   CALL mpp_max( nstop )
+
+      ! check that all process are still there... If some process have an error,
+      ! they will never enter in step and other processes will wait until the end of the cpu time!
+      IF( lk_mpp )   CALL mpp_max( nstop )
+
+      istp = nit000
+         !
+      DO WHILE ( istp <= nitend .AND. nstop == 0 )
+         CALL stp( istp )
+         istp = istp + 1
+         IF( lk_mpp )   CALL mpp_max( nstop )
+      END DO
+      !                                     ! ========= !
+      !                                     !  Job end  !
+      !                                     ! ========= !
+
+      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
+
+      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
+         WRITE(numout,cform_err)
+         WRITE(numout,*) nstop, ' error have been found'
+      ENDIF
+
+      CALL opa_closefile
+
+      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
+      !
+   END SUBROUTINE opa_model
+
+
+   SUBROUTINE opa_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa_init ***
+      !!
+      !! ** Purpose :   opa solves the primitive equations on an orthogonal 
+      !!      curvilinear mesh on the sphere.
+      !!
+      !! ** Method  : - model general initialization
+      !!
+      !! References :
+      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
+      !!              internal report, IPSL.
+      !!
+      !! History :
+      !!   4.0  !  90-10  (C. Levy, G. Madec)  Original code
+      !!   7.0  !  91-11  (M. Imbard, C. Levy, G. Madec)
+      !!   7.1  !  93-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
+      !!                   M. Guyon, A. Lazar, P. Delecluse, C. Perigaud,
+      !!                   G. Caniaux, B. Colot, C. Maes ) release 7.1 
+      !!        !  92-06  (L.Terray) coupling implementation
+      !!        !  93-11  (M.A. Filiberti) IGLOO sea-ice 
+      !!   8.0  !  96-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
+      !!                   M. Guyon, A. Lazar, P. Delecluse, L.Terray,
+      !!                   M.A. Filiberti, J. Vialar, A.M. Treguier,
+      !!                   M. Levy)  release 8.0
+      !!   8.1  !  97-06  (M. Imbard, G. Madec)
+      !!   8.2  !  99-11  (M. Imbard, H. Goosse)  LIM sea-ice model 
+      !!        !  99-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP 
+      !!        !  00-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
+      !!   9.0  !  02-08  (G. Madec)  F90: Free form and modules
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+#if defined key_iomput
+      INTEGER :: localComm
+#endif
+      CHARACTER (len=20) ::   namelistname
+      CHARACTER (len=28) ::   file_out
+      NAMELIST/namctl/ ln_ctl, nprint, nictls, nictle,   &
+         &             isplt , jsplt , njctls, njctle, nbench
+
+      !!----------------------------------------------------------------------
+
+      ! Initializations
+      ! ===============
+
+      file_out = 'ocean.output'
+
+      ! open listing and namelist units
+      CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
+         &         'SEQUENTIAL', 1, 6, .FALSE., 1 )
+
+      namelistname = 'namelist'
+      CALL ctlopn( numnam, namelistname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
+         &         1, numout, .FALSE., 1 )
+
+      WRITE(numout,*)
+      WRITE(numout,*) '                 L O D Y C - I P S L'
+      WRITE(numout,*) '                     O P A model'
+      WRITE(numout,*) '            Ocean General Circulation Model'
+      WRITE(numout,*) '               version OPA 9.0  (2005) '
+      WRITE(numout,*)
+      WRITE(numout,*)
+
+      ! Namelist namctl : Control prints & Benchmark
+      REWIND( numnam )
+      READ  ( numnam, namctl )
+
+#if defined key_iomput
+      CALL init_ioclient(localcomm)
+      narea = mynode(localComm)
+#else
+      ! Nodes selection
+      narea = mynode()
+#endif
+
+      ! Nodes selection
+      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
+      lwp   = narea == 1
+
+      ! open additionnal listing
+      IF( ln_ctl )   THEN
+         IF( narea-1 > 0 )   THEN
+            WRITE(file_out,FMT="('ocean.output_',I4.4)") narea-1
+            CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
+               &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
+            lwp = .TRUE.
+            !
+            WRITE(numout,*)
+            WRITE(numout,*) '                 L O D Y C - I P S L'
+            WRITE(numout,*) '                     O P A model'
+            WRITE(numout,*) '            Ocean General Circulation Model'
+            WRITE(numout,*) '               version OPA 9.0  (2005) '
+            WRITE(numout,*) '                   MPI Ocean output '
+            WRITE(numout,*)
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+
+      CALL opa_flg                          ! Control prints & Benchmark
+
+      !                                     ! ============================== !
+      !                                     !  Model general initialization  !
+      !                                     ! ============================== !
+
+      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
+
+                                            ! Domain decomposition
+      IF( jpni * jpnj == jpnij ) THEN
+         CALL mpp_init                          ! standard cutting out
+      ELSE
+         CALL mpp_init2                         ! eliminate land processors
+      ENDIF
+      
+      CALL phy_cst                          ! Physical constants
+      CALL eos_init                         ! Equation of state
+      CALL dom_cfg                          ! Domain configuration
+      CALL dom_init                         ! Domain
+      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
+      CALL trc_ini                           ! Passive tracers
+      CALL dta_dyn( nit000 )                 ! Initialization for the dynamics
+      CALL tra_qsr_init                         ! Solar radiation penetration
+#if ! defined key_off_degrad
+      CALL ldf_tra_init                         ! Lateral ocean tracer physics
+#endif 
+      CALL iom_init                         ! iom_put initialization
+
+      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
+
+   END SUBROUTINE opa_init
+
+   SUBROUTINE opa_flg
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa  ***
+      !!
+      !! ** Purpose :   Initialize logical flags that control the choice of
+      !!      some algorithm or control print
+      !!
+      !! ** Method  :    Read in namilist namflg logical flags
+      !!
+      !! History :
+      !!   9.0  !  03-11  (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+
+      ! Parameter control and print
+      ! ---------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '          Namelist namctl'
+         WRITE(numout,*) '             run control (for debugging)     ln_ctl    = ', ln_ctl
+         WRITE(numout,*) '             level of print                  nprint    = ', nprint
+         WRITE(numout,*) '             Start i indice for SUM control  nictls    = ', nictls
+         WRITE(numout,*) '             End i indice for SUM control    nictle    = ', nictle
+         WRITE(numout,*) '             Start j indice for SUM control  njctls    = ', njctls
+         WRITE(numout,*) '             End j indice for SUM control    njctle    = ', njctle
+         WRITE(numout,*) '             number of proc. following i     isplt     = ', isplt
+         WRITE(numout,*) '             number of proc. following j     jsplt     = ', jsplt
+         WRITE(numout,*) '             benchmark parameter (0/1)       nbench    = ', nbench
+      ENDIF
+
+      ! ... Control the sub-domain area indices for the control prints
+      IF( ln_ctl )   THEN
+         IF( lk_mpp )   THEN
+            ! the domain is forced to the real splitted domain in MPI
+            isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj
+         ELSE
+            IF( isplt == 1 .AND. jsplt == 1  ) THEN
+               CALL ctl_warn( '          - isplt & jsplt are equal to 1',   &
+                    &         '          - the print control will be done over the whole domain' )
+            ENDIF
+
+            ! compute the total number of processors ijsplt
+            ijsplt = isplt*jsplt
+         ENDIF
+
+         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
+         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
+
+         ! Control the indices used for the SUM control
+         IF( nictls+nictle+njctls+njctle == 0 )   THEN
+            ! the print control is done over the default area
+            lsp_area = .FALSE.
+         ELSE
+            ! the print control is done over a specific  area
+            lsp_area = .TRUE.
+            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
+               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
+               nictls = 1
+            ENDIF
+
+            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
+               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
+               nictle = jpiglo
+            ENDIF
+
+            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
+               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
+               njctls = 1
+            ENDIF
+
+            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
+               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
+               njctle = jpjglo
+            ENDIF
+
+         ENDIF          ! IF( nictls+nictle+njctls+njctle == 0 )
+       ENDIF            ! IF(ln_ctl)
+
+      IF( nbench == 1 )   THEN
+         SELECT CASE ( cp_cfg )
+         CASE ( 'gyre' )
+            CALL ctl_warn( '          The Benchmark is activated ' )
+         CASE DEFAULT
+            CALL ctl_stop( '          The Benchmark is based on the GYRE configuration: key_gyre must &
+               &                      be used or set nbench = 0' )
+         END SELECT
+      ENDIF
+
+   END SUBROUTINE opa_flg
+
+   SUBROUTINE opa_closefile
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa_closefile  ***
+      !!
+      !! ** Purpose :   Close the files
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      IF ( lk_mpp ) CALL mppsync
+
+      ! 1. Unit close
+      ! -------------
+
+      CLOSE( numnam )           ! namelist
+      CLOSE( numout )           ! standard model output file
+
+      IF(lwp) CLOSE( numstp )   ! time-step file
+
+      CALL iom_close            ! close all input/output files
+
+   END SUBROUTINE opa_closefile
+
+   !!======================================================================
+END MODULE opa
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R2.h90	(revision 1844)
@@ -0,0 +1,87 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R2.h90  ***
+   !!   Ocean Domain : 2 km resolution Channel (EEL_R2 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &  !:
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER, PARAMETER ::     &  !:
+      jp_cfg = 2   ,         &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 83,          &  !: 1st horizontal dimension ( >= jpi )
+      jpjdta  = 242,         &  !: 2nd    "            "    ( >= jpj )
+      jpkdta  = 30,          &  !: number of levels         ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =     1 ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =     1 ,      &  !: number of islands
+      jpnisl  = jpiglo          !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp  , & !: ???
+      pp_to_be_computed =      0._wp      !: ???
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 3            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used ,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used ,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 2000.0_wp,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = 2000.0_wp       !: meridional grid-spacing (meters )
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+
+   REAL(wp), PARAMETER  ::       &  !:
+      &     ppsur = -2033.194295283385_wp   ,  &  !: Computed in domzgr
+      &     ppa0  =  155.8325369664153_wp   ,  &  !:
+      &     ppa1  =  146.3615918601890_wp   ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R5.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R5.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R5.h90	(revision 1844)
@@ -0,0 +1,86 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R5.h90  ***   
+   !!   Ocean Domain : 5 km resolution Channel (EEL_R5 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &  !:
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER, PARAMETER ::     &  !:
+      jp_cfg = 5      ,      &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files
+      jpidta  = 202   ,      &  !: first horizontal dimension > or = to jpi
+      jpjdta  = 104   ,      &  !: second                     > or = to jpj
+      jpkdta  =  40   ,      &  !: number of levels           > or = to jpk
+
+      ! total domain size      !!! * full domain *
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =   0   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   1   ,      &  !: number of islands
+      jpnisl  = jpiglo          !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp ,  &  !:
+      pp_to_be_computed =      0._wp       !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 2            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 5000.0_wp,   &  !: zonal      grid-spacing (meters)
+      ppe2_m   = 5000.0_wp       !: meridional grid-spacing (meters)
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+   REAL(wp), PARAMETER  ::       &   !:
+      &     ppsur = pp_to_be_computed       ,  &  !: Computed in domzgr, set ppdzmin, pphmax below
+      &     ppa0  = pp_to_be_computed       ,  &  !:
+      &     ppa1  = pp_to_be_computed       ,  &  !:
+      !
+      &     ppkth = 20._wp                  ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr = 16.00000000000_wp             !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = 120._wp               ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = 4000._wp                    !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R6.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R6.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_EEL_R6.h90	(revision 1844)
@@ -0,0 +1,86 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R6.h90  ***   
+   !!   Ocean Domain : 6 km resolution Channel (EEL_R6 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &  !:
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER, PARAMETER ::     &  !:
+      jp_cfg = 6      ,      &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 29,          &  !: 1st lateral dimension ( >= jpi )
+      jpjdta  = 83,          &  !: 2nd    "         "    ( >= jpj )
+      jpkdta  = 30,          &  !: number of levels      ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+
+      ! Domain characteristics
+      jperio  =      1,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =      1,      &  !: number of islands
+      jpnisl  = jpiglo          !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp ,  &  !: ???
+      pp_to_be_computed =      0._wp       !: ???
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 3            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 6000.0_wp,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = 6000.0_wp       !: meridional grid-spacing (meters )
+
+   !!  Coefficients associated with the vertical coordinate system
+
+   REAL(wp), PARAMETER  ::       &  !:
+      &     ppsur = -2033.194295283385_wp   ,  &  !: Computed in domzgr
+      &     ppa0  =  155.8325369664153_wp   ,  &  !:
+      &     ppa1  =  146.3615918601890_wp   ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_GYRE.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_GYRE.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_GYRE.h90	(revision 1844)
@@ -0,0 +1,91 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_GYRE.h90  ***
+   !!   Ocean Domain : GYRE configuration at 1/jp_cfg degree resolution 
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &  !:
+      cp_cfg = "gyre"           !: name of the configuration
+   INTEGER, PARAMETER ::     &  !:
+      jp_cfg =  1   ,        &  !: 
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 30*jp_cfg+2, &  !: 1st horizontal dimension ( >= jpi )
+      jpjdta  = 20*jp_cfg+2, &  !: 2nd    "            "    ( >= jpj )
+      jpkdta  = 101,         &  !: number of levels         ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =     0 ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =     1 ,      &  !: number of islands
+      jpnisl  = jpiglo          !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp  , & !: ???
+      pp_to_be_computed =      0._wp      !: ???
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 5            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+      !                        ! =5  beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   29.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used ,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used ,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,    &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used        !: meridional grid-spacing (meters )
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+
+   REAL(wp), PARAMETER  ::       &  !:
+      &     ppsur = 0.e0      ,  &  !: Computed in domzgr
+      &     ppa0  = 0.e0      ,  &  !:
+      &     ppa1  = 0.e0      ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !    layer number above which  stretching will
+      !                                           !    be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !    for the grid. The highest zacr, the smallest
+      !                                           !    the stretching.
+
+   !!
+   !!  If all ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = 1.0e0   ,  &  !: (meters): depth of the top (first) model layer
+      !                             !            depth of second "w" level
+      &     pphmax  = 5000.         !: (meters): maximum depth of the ocean
+      !                             !            depth of the last "w" level
+
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R025.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R025.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R025.h90	(revision 1844)
@@ -0,0 +1,83 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R025.h90  ***  
+   !!   Ocean Domain : 0.25 degrees resolution global ocean
+   !!                  (0RCA_R025 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &
+      cp_cfg = "orca"           !: name of the configuration
+   INTEGER, PARAMETER ::     &
+      jp_cfg = 025  ,        &  !: resolution of the configuration (degrees)
+      ! Original data size
+      jpidta  = 1442,        &  !: first horizontal dimension > or = to jpi
+      jpjdta  = 1021,        &  !: second                     > or = to jpj
+      jpkdta  = 46 ,         &  !: number of levels           > or = to jpk
+      ! total domain matrix size
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+      ! Domain characteristics
+      jperio  =    4  ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =  150  ,      &  !: number of islands
+      jpnisl  = 3000            !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL,PARAMETER      ::  pp_not_used = 999999_wp , &
+      &                    pp_to_be_computed = 0._wp
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER, PARAMETER ::     & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp), PARAMETER ::       &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!  Coefficients associated with the vertical coordinate system
+
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = pp_to_be_computed ,  &  !: Computed in domzgr, set ppdzmin and pphmax below
+      &     ppa0  = pp_to_be_computed ,  &  !:    "           "
+      &     ppa1  = pp_to_be_computed ,  &  !:    "           "
+      !
+      &     ppkth =  23.563_wp        ,  &  !: (non dimensional): gives the approximate
+      !                                     !: layer number above which  stretching will
+      !                                     !: be maximum. Usually of order jpk/2.
+      &     ppacr =    9.00000000000_wp     !: (non dimensional): stretching factor
+      !                                     !: for the grid. The highest zacr, the smallest
+      !                                     !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = 6._wp           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = 5750._wp              !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R05.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R05.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R05.h90	(revision 1844)
@@ -0,0 +1,115 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R05.h90  ***  
+   !!   Ocean Domain : 0.5 degrees resolution global ocean
+   !!                  (0RCA_R05 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::   &
+      cp_cfg = "orca"           !: name of the configuration
+   INTEGER, PARAMETER ::     &
+      jp_cfg = 05  ,         &  !: resolution of the configuration (degrees)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 722,         &  !: 1st lateral dimension > or = to jpiglo
+      jpjdta  = 511,         &  !: 2nd   "         "     > or = to jpjglo
+      jpkdta  =  31,         &  !: number of levels      > or = to jpkglo
+
+#if defined key_antarctic
+      ! zoom domain size       !!! * antarctic zoom *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 187   ,      &  !: 2nd     "                 "    --> j 
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   1   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   1   ,      &  !: number of islands
+      jpnisl  =   1             !: maximum number of points per island
+
+#elif defined key_arctic
+      ! zoom domain size       !!! *  arctic zoom  *
+      jpiglo  = 562,         &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta-301+1,&  !: 2nd     "                 "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =  81   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom = 301   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   5   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   1   ,      &  !: number of islands
+      jpnisl  =   1             !: maximum number of points per island
+
+#else
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd     "                 "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position    
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =    6  ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   79  ,      &  !: number of islands
+      jpnisl  = 2000            !: maximum number of points per island
+#endif
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999._wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER, PARAMETER   ::   & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) , PARAMETER ::      &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!
+   !! Vertical grid parameter for domzgr
+   !! =====================================
+   !!
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R2.h90	(revision 1844)
@@ -0,0 +1,139 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R2.h90  ***  
+   !!   Ocean Domain : 2 degrees resolution global ocean
+   !!                  (0RCA_R2 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::    &  
+      cp_cfg = "orca"           !: name of the configuration 
+   INTEGER, PARAMETER ::     &
+      jp_cfg = 2,            &  !: resolution of the configuration (degrees)
+
+      ! data size              !!! * size of all input files *
+      jpidta  = 182,         &  !: 1st lateral dimension ( >= jpiglo )
+      jpjdta  = 149,         &  !: 2nd    "       "      ( >= jpjglo )
+      jpkdta  = 31,          &  !: number of levels      ( >= jpk    )
+
+#if defined key_antarctic
+      ! zoom domain size       !!! *  antarctic zoom  * 
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 50,          &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   1   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   3   ,      &  !: number of islands
+      jpnisl  = 400             !: maximum number of points per island
+
+#elif defined key_arctic
+      ! zoom domain size       !!! *  arctic zoom  *
+      jpiglo  = 142   ,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta-97+1, &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position 
+      jpizoom =  21   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =  97   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   3   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =   7   ,      &  !: number of islands
+      jpnisl  = 400             !: maximum number of points per island
+
+#elif defined key_c1d
+      ! global domain size     !!! *  global domain  *
+      jpiglo  = 3     ,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 3     ,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom 
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   133  ,    &  !: in data domain indices (160W,75N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   110  ,    &  !: in data domain indices (160W,50N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   97   ,    &  !: in data domain indices (160W,30N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   86   ,    &  !: in data domain indices (160W,10N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   49   ,    &  !: in data domain indices (160W,30S)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   27   ,    &  !: in data domain indices (160W,60S)
+      jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =    7   ,    &  !: in data domain indices (160W,75S)
+      ! Domain characteristics
+      jperio  =   0   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =  18   ,      &  !: number of islands
+      jpnisl  = 800             !: maximum number of points per island
+#else
+      ! global domain size     !!! *  global domain  *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom 
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   4   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =  18   ,      &  !: number of islands
+      jpnisl  = 800             !: maximum number of points per island
+#endif
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999_wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::       &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+   !!
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R4.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R4.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_ORCA_R4.h90	(revision 1844)
@@ -0,0 +1,83 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R4.h90  ***   
+   !!   Ocean Domain : 4 degrees resolution global ocean
+   !!                  (0RCA_R4 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16), PARAMETER ::    &
+      cp_cfg = "orca"           !: name of the configuration
+   INTEGER, PARAMETER ::     &
+      jp_cfg = 4      ,      &  !: resolution of the configuration (degrees)
+      ! Original data size
+      jpidta  =  92   ,      &  !: first horizontal dimension > or = to jpi
+      jpjdta  =  76   ,      &  !: second                     > or = to jpj
+      jpkdta  =  31   ,      &  !: number of levels           > or = to jpk
+      ! global domain matrix size
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+      ! Domain characteristics
+      jperio  =   4   ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =  11   ,      &  !: number of islands
+      jpnisl  = 800             !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999_wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   INTEGER, PARAMETER ::     & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) , PARAMETER ::      &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_kind.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_kind.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_kind.F90	(revision 1844)
@@ -0,0 +1,39 @@
+MODULE par_kind
+   !!======================================================================
+   !!                   ***  MODULE par_kind  ***
+   !! Ocean :  define the kind of real for the whole model
+   !!======================================================================
+   !! History :
+   !!   8.5   02/06  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTEGER, PUBLIC, PARAMETER ::    &  !:
+      jpbyt   = 8       ,           &  !: real size for mpp communications
+      jpbytda = 4       ,           &  !: real size in input data files 4 or 8
+      jpbi3e  = 4                      !: real size for T3E
+
+   ! Number model from which the SELECTED_*_KIND are requested:
+   !             4 byte REAL       8 byte REAL
+   ! CRAY:           -            precision = 13
+   !                              exponent = 2465
+   ! IEEE:      precision = 6     precision = 15
+   !            exponent = 37     exponent = 307
+
+   INTEGER, PUBLIC, PARAMETER ::        &  !: Floating point section
+      sp = SELECTED_REAL_KIND( 6, 37),  &  !: single precision (real 4)
+      dp = SELECTED_REAL_KIND(12,307),  &  !: double precision (real 8)
+      wp = dp                              !: working precision
+
+   INTEGER, PUBLIC, PARAMETER ::        &  !: Integer section
+      i4 = SELECTED_INT_KIND(9) ,       &  !: single precision (integer 4)
+      i8 = SELECTED_INT_KIND(14)           !: double precision (integer 8)
+
+!!----------------------------------------------------------------------
+END MODULE par_kind
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/par_oce.F90	(revision 1844)
@@ -0,0 +1,199 @@
+MODULE par_oce
+   !!======================================================================
+   !!                        ***  par_oce  ***
+   !! Ocean :   set the ocean parameters
+   !!======================================================================
+   !! History :
+   !!   4.0  !  91     (Imbard, Levy, Madec)  Original code
+   !!   9.0  !  04-01  (G. Madec, J.-M. Molines)  Free form and module
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind          ! kind parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !!   Domain decomposition
+   !!----------------------------------------------------------------------
+   !! * if we dont use massively parallel computer (parameters jpni=jpnj=1)
+   !!      so jpiglo=jpi and jpjglo=jpj
+
+   INTEGER, PUBLIC, PARAMETER ::    &  !:
+      jpni   = 1,                   &  !: number of processors following i 
+      jpnj   = 1,                   &  !: number of processors following j
+      jpnij  = 1,                   &  !: nb of local domain = nb of processors 
+      !                                !  ( <= jpni x jpnj )
+      jpr2di = 0,                   &  !: number of columns for extra outer halo 
+      jpr2dj = 0,                   &  !: number of rows    for extra outer halo 
+      jpreci = 1,                   &  !: number of columns for overlap 
+      jprecj = 1                       !: number of rows    for overlap 
+
+   !! Ocean Domain sizes
+   !! ------------------
+   !!   data           domain   (jpidta,jpjdta)
+   !!   global or zoom domain   (jpiglo,jpjglo)
+   !!   local          domain   ( jpi  , jpj  )
+   
+#if   defined key_orca_r4
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r4'   :                           global ocean : ORCA R4
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R4.h90"
+#elif defined key_orca_r2
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r2'   :                           global ocean : ORCA R4
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R2.h90"
+#elif defined key_orca_r05
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r05'  :                          global ocean : ORCA R05
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R05.h90"
+#elif defined key_orca_r025
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r025' :                         global ocean : ORCA R025
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R025.h90"
+#elif defined key_eel_r2
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r2'    :                                 channel : EEL R2
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R2.h90"
+#elif defined key_eel_r5
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r5'    :                                 channel : EEL R5
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R5.h90"
+#elif defined key_eel_r6
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r6'    :                                 channel : EEL R6
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R6.h90"
+#elif defined key_gyre
+   !!---------------------------------------------------------------------
+   !!   'key_gyre'      :                        mid-latitude basin : GYRE
+   !!---------------------------------------------------------------------
+#             include "par_GYRE.h90"
+#else
+   !!---------------------------------------------------------------------
+   !!   default option  :                               small closed basin
+   !!---------------------------------------------------------------------
+   CHARACTER(len=16), PUBLIC, PARAMETER ::   &  !:
+      cp_cfg = "default"               !: name of the configuration
+   INTEGER, PARAMETER ::            &  !:
+      jp_cfg = 0  ,                 &  !: resolution of the configuration
+
+      ! data size                     !!! * size of all input files *
+      jpidta  = 10,                 &  !: 1st lateral dimension ( >= jpi )
+      jpjdta  = 12,                 &  !: 2nd    "         "    ( >= jpj )
+      jpkdta  = 31,                 &  !: number of levels      ( >= jpk )
+
+      ! global or zoom domain size    !!! * computational domain *
+      jpiglo  = jpidta,             &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,             &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,             &  !: number of vertical levels
+      ! zoom starting position 
+      jpizoom =   1   ,             &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,             &  !: in data domain indices
+
+      ! Domain characteristics
+      jperio  =  0,                 &  !: lateral cond. type (between 0 and 6)
+         !                             !  = 0 closed
+         !                             !  = 1 cyclic East-West
+         !                             !  = 2 equatorial symmetric
+         !                             !  = 3 North fold T-point pivot
+         !                             !  = 4 cyclic East-West AND North fold T-point pivot
+         !                             !  = 5 North fold F-point pivot
+         !                             !  = 6 cyclic East-West AND North fold F-point pivot
+      jpisl   =  0,                 &  !: number of islands (rigid-lid only)
+      jpnisl  =  0                     !: maximum number of points per island
+
+      !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+      !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+      REAL(wp), PARAMETER ::   &  !:
+         pp_not_used       = 999999._wp , &  !:
+         pp_to_be_computed = 999999._wp      !:
+
+
+   !! Horizontal grid parameters for domhgr
+   !! =====================================
+
+   INTEGER, PUBLIC, PARAMETER   ::   &  !:
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+   REAL(wp) , PUBLIC, PARAMETER ::   &   !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =  -35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg =    1.0_wp,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg =    0.5_wp,   &  !: meridional grid-spacing (degrees)
+      ppe1_m   = 5000.0_wp,   &  !: zonal      grid-spacing (degrees)
+      ppe2_m   = 5000.0_wp       !: meridional grid-spacing (degrees)
+
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+
+   REAL(wp), PUBLIC, PARAMETER  ::   &  !:
+      &     ppsur = -4762.96143546300_wp ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp ,  &  !:
+      &     ppkth =    21.43336197938_wp ,  &  !:
+      &     ppacr =     3.00000000000_wp       !:
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+
+   REAL(wp), PUBLIC, PARAMETER ::   &  !:
+      &     ppdzmin = 10._wp             ,  &  !: Minimum vertical spacing
+      &     pphmax  = 5000._wp                 !: Maximum depth
+
+   !!---------------------------------------------------------------------
+#endif
+
+   !!---------------------------------------------------------------------
+   !! Domain Matrix size
+   !!---------------------------------------------------------------------
+   INTEGER, PUBLIC, PARAMETER ::   &  !:
+      jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ,   &  !: first  dimension
+      jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ,   &  !: second dimension
+      jpim1 = jpi-1,                                             &  !: inner domain indices
+      jpjm1 = jpj-1,                                             &  !:   "            "
+      jpkm1 = jpk-1,                                             &  !:   "            "
+      jpij  = jpi*jpj                                               !:  jpi x jpj
+
+   !!---------------------------------------------------------------------
+   !! Optimization/control flags
+   !!---------------------------------------------------------------------
+#if defined key_esopa
+   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .TRUE.   !: flag to activate the all options
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .FALSE.  !: flag to activate the all options
+#endif
+
+#if defined key_vectopt_memory
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_mem  = .TRUE.   !: vector optimization flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_mem  = .FALSE.  !: vector optimization flag
+#endif
+
+#if defined key_vectopt_loop
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_loop = .TRUE.   !: vector optimization flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_loop = .FALSE.  !: vector optimization flag
+#endif
+
+   !!======================================================================
+END MODULE par_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/prtctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/prtctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/prtctl.F90	(revision 1844)
@@ -0,0 +1,575 @@
+MODULE prtctl
+   !!==============================================================================
+   !!                       ***  MODULE prtctl   ***
+   !! Ocean system   : print all SUM trends for each processor domain
+   !!==============================================================================
+   USE dom_oce          ! ocean space and time domain variables
+   USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! distributed memory computing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Module declaration
+   INTEGER, DIMENSION(:), ALLOCATABLE :: numid
+   INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   &  !:
+      nlditl , nldjtl ,   &  !: first, last indoor index for each i-domain
+      nleitl , nlejtl ,   &  !: first, last indoor index for each j-domain
+      nimpptl, njmpptl,   &  !: i-, j-indexes for each processor
+      nlcitl , nlcjtl ,   &  !: dimensions of every subdomain
+      ibonitl, ibonjtl
+
+   REAL(wp), DIMENSION(:), ALLOCATABLE ::   &  !:
+      t_ctll , s_ctll ,   &  !: previous trend values
+      u_ctll , v_ctll
+
+   INTEGER ::   ktime        !: time step
+
+   !! * Routine accessibility
+   PUBLIC prt_ctl         ! called by all subroutines
+   PUBLIC prt_ctl_info    ! called by all subroutines
+   PUBLIC prt_ctl_init    ! called by opa.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+
+CONTAINS
+
+   SUBROUTINE prt_ctl (tab2d_1, tab3d_1, mask1, clinfo1, tab2d_2, tab3d_2, mask2, clinfo2, ovlap, kdim, clinfo3)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl  ***
+      !!
+      !! ** Purpose : - print sum control of 2D or 3D arrays over the same area 
+      !!                in mono and mpp case. This way can be usefull when
+      !!                debugging a new parametrization in mono or mpp. 
+      !!
+      !! ** Method  : 2 possibilities exist when setting the ln_ctl parameter to
+      !!                .true. in the ocean namelist:
+      !!              - to debug a MPI run .vs. a mono-processor one; 
+      !!                the control print will be done over each sub-domain.
+      !!                The nictl[se] and njctl[se] parameters in the namelist must 
+      !!                be set to zero and [ij]splt to the corresponding splitted
+      !!                domain in MPI along respectively i-, j- directions.
+      !!              - to debug a mono-processor run over the whole domain/a specific area; 
+      !!                in the first case the nictl[se] and njctl[se] parameters must be set
+      !!                to zero else to the indices of the area to be controled. In both cases
+      !!                isplt and jsplt must be set to 1.
+      !!              - All arguments of the above calling sequence are optional so their
+      !!                name must be explicitly typed if used. For instance if the 3D
+      !!                array tn(:,:,:) must be passed through the prt_ctl subroutine, 
+      !!                it must looks like: CALL prt_ctl(tab3d_1=tn).
+      !!
+      !!                    tab2d_1 : first 2D array
+      !!                    tab3d_1 : first 3D array
+      !!                    mask1   : mask (3D) to apply to the tab[23]d_1 array
+      !!                    clinfo1 : information about the tab[23]d_1 array
+      !!                    tab2d_2 : second 2D array
+      !!                    tab3d_2 : second 3D array
+      !!                    mask2   : mask (3D) to apply to the tab[23]d_2 array
+      !!                    clinfo2 : information about the tab[23]d_2 array
+      !!                    ovlap   : overlap value
+      !!                    kdim    : k- direction for 3D arrays 
+      !!                    clinfo3 : additional information 
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL :: tab2d_1
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: tab3d_1
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: mask1
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo1
+      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL :: tab2d_2
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: tab3d_2
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: mask2
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo2
+      INTEGER                   , INTENT(in), OPTIONAL :: ovlap
+      INTEGER                   , INTENT(in), OPTIONAL :: kdim
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo3
+
+      !! * Local declarations
+      INTEGER :: overlap, jn, sind, eind, kdir,j_id
+      CHARACTER (len=15) :: cl2
+      REAL(wp) :: zsum1, zsum2, zvctl1, zvctl2
+      REAL(wp), DIMENSION(jpi,jpj) :: ztab2d_1, ztab2d_2
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask1, zmask2, ztab3d_1, ztab3d_2
+      !!----------------------------------------------------------------------
+
+      ! Arrays, scalars initialization 
+      overlap   = 0
+      kdir      = jpkm1
+      cl2       = ''
+      zsum1     = 0.e0
+      zsum2     = 0.e0
+      zvctl1    = 0.e0
+      zvctl2    = 0.e0
+      ztab2d_1(:,:)   = 0.e0
+      ztab2d_2(:,:)   = 0.e0
+      ztab3d_1(:,:,:) = 0.e0
+      ztab3d_2(:,:,:) = 0.e0
+      zmask1  (:,:,:) = 1.e0
+      zmask2  (:,:,:) = 1.e0
+
+      ! Control of optional arguments
+      IF( PRESENT(clinfo2) )  cl2            = clinfo2
+      IF( PRESENT(ovlap)   )  overlap        = ovlap
+      IF( PRESENT(kdim)    )  kdir           = kdim
+      IF( PRESENT(tab2d_1) )  ztab2d_1(:,:)  = tab2d_1(:,:)
+      IF( PRESENT(tab2d_2) )  ztab2d_2(:,:)  = tab2d_2(:,:)
+      IF( PRESENT(tab3d_1) )  ztab3d_1(:,:,:)= tab3d_1(:,:,:)
+      IF( PRESENT(tab3d_2) )  ztab3d_2(:,:,:)= tab3d_2(:,:,:)
+      IF( PRESENT(mask1)   )  zmask1  (:,:,:)= mask1  (:,:,:)
+      IF( PRESENT(mask2)   )  zmask2  (:,:,:)= mask2  (:,:,:)
+
+      IF( lk_mpp )   THEN
+         ! processor number
+         sind = narea
+         eind = narea
+      ELSE
+         ! processors total number
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. the total number of processors ijsplt
+      DO jn = sind, eind
+         ! Set logical unit
+         j_id = numid(jn - narea + 1)
+         ! Set indices for the SUM control
+         IF( .NOT. lsp_area ) THEN
+            IF (lk_mpp )   THEN
+               nictls = MAX( 1, nlditl(jn) - overlap )
+               nictle = nleitl(jn) + overlap * MIN( 1, nlcitl(jn) - nleitl(jn)) 
+               njctls = MAX( 1, nldjtl(jn) - overlap )
+               njctle = nlejtl(jn) + overlap * MIN( 1, nlcjtl(jn) - nlejtl(jn))
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
+               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
+               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nleitl(jn) - 1)
+               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, nlejtl(jn) - 1)
+            ELSE
+               nictls = MAX( 1, nimpptl(jn) + nlditl(jn) - 1 - overlap )
+               nictle = nimpptl(jn) + nleitl(jn) - 1 + overlap * MIN( 1, nlcitl(jn) - nleitl(jn) ) 
+               njctls = MAX( 1, njmpptl(jn) + nldjtl(jn) - 1 - overlap )
+               njctle = njmpptl(jn) + nlejtl(jn) - 1 + overlap * MIN( 1, nlcjtl(jn) - nlejtl(jn) ) 
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
+               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
+               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nimpptl(jn) + nleitl(jn) - 2)
+               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, njmpptl(jn) + nlejtl(jn) - 2)
+            ENDIF
+         ENDIF
+
+         IF ( clinfo3 == 'tra' )  THEN
+             zvctl1 = t_ctll(jn)
+             zvctl2 = s_ctll(jn)
+         ELSEIF ( clinfo3 == 'dyn' )   THEN
+             zvctl1 = u_ctll(jn)
+             zvctl2 = v_ctll(jn)
+         ENDIF
+
+         ! Compute the sum control
+         ! 2D arrays
+         IF( PRESENT(tab2d_1) )   THEN
+            zsum1 = SUM( ztab2d_1(nictls:nictle,njctls:njctle)*zmask1(nictls:nictle,njctls:njctle,1) )
+            zsum2 = SUM( ztab2d_2(nictls:nictle,njctls:njctle)*zmask2(nictls:nictle,njctls:njctle,1) )
+         ENDIF
+
+         ! 3D arrays
+         IF( PRESENT(tab3d_1) )   THEN
+            zsum1 = SUM( ztab3d_1(nictls:nictle,njctls:njctle,1:kdir)*zmask1(nictls:nictle,njctls:njctle,1:kdir) )
+            zsum2 = SUM( ztab3d_2(nictls:nictle,njctls:njctle,1:kdir)*zmask2(nictls:nictle,njctls:njctle,1:kdir) )
+         ENDIF
+
+         ! Print the result
+         IF( PRESENT(clinfo3) )   THEN
+            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1-zvctl1, cl2, zsum2-zvctl2
+            SELECT CASE( clinfo3 )
+            CASE ( 'tra-ta' ) 
+               t_ctll(jn) = zsum1
+            CASE ( 'tra' ) 
+                t_ctll(jn) = zsum1
+                s_ctll(jn) = zsum2
+            CASE ( 'dyn' ) 
+                u_ctll(jn) = zsum1
+                v_ctll(jn) = zsum2 
+            END SELECT
+         ELSEIF ( PRESENT(clinfo2) .OR. PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) )   THEN
+            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1, cl2, zsum2
+         ELSE
+            WRITE(j_id,FMT='(a,D23.16)')clinfo1, zsum1
+         ENDIF
+
+      ENDDO
+
+   END SUBROUTINE prt_ctl
+
+
+   SUBROUTINE prt_ctl_info (clinfo1, ivar1, clinfo2, ivar2, itime)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_info  ***
+      !!
+      !! ** Purpose : - print information without any computation
+      !!
+      !! ** Action  : - input arguments
+      !!                    clinfo1 : information about the ivar1
+      !!                    ivar1   : value to print
+      !!                    clinfo2 : information about the ivar2
+      !!                    ivar2   : value to print
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER (len=*), INTENT(in) ::   clinfo1
+      INTEGER          , INTENT(in), OPTIONAL ::   ivar1
+      CHARACTER (len=*), INTENT(in), OPTIONAL ::   clinfo2
+      INTEGER          , INTENT(in), OPTIONAL ::   ivar2
+      INTEGER          , INTENT(in), OPTIONAL ::   itime
+
+      !! * Local declarations
+      INTEGER :: jn, sind, eind, iltime, j_id
+      !!----------------------------------------------------------------------
+
+      IF( lk_mpp )   THEN
+         ! processor number
+         sind = narea
+         eind = narea
+      ELSE
+         ! total number of processors
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Set to zero arrays at each new time step
+      IF( PRESENT(itime) )   THEN
+         iltime = itime
+         IF( iltime > ktime )   THEN
+            t_ctll(:) = 0.e0   ;   s_ctll(:) = 0.e0
+            u_ctll(:) = 0.e0   ;   v_ctll(:) = 0.e0
+            ktime = iltime
+         ENDIF
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. number of processors ijsplt
+      DO jn = sind, eind
+         
+         ! Set logical unit
+         j_id = numid(jn - narea + 1)
+
+         IF( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, clinfo2, ivar2
+         ELSEIF ( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, clinfo2
+         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, ivar2
+         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1
+         ELSE
+            WRITE(j_id,*)clinfo1
+         ENDIF
+
+      ENDDO
+
+
+      END SUBROUTINE prt_ctl_info
+
+   SUBROUTINE prt_ctl_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_init  ***
+      !!
+      !! ** Purpose :   open ASCII files & compute indices
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   jn, sind, eind, j_id
+      CHARACTER (len=28) :: clfile_out
+      CHARACTER (len=23) :: clb_name
+      CHARACTER (len=19) :: cl_run
+      !!----------------------------------------------------------------------
+
+      ! Allocate arrays
+      ALLOCATE(nlditl (ijsplt))
+      ALLOCATE(nldjtl (ijsplt))
+      ALLOCATE(nleitl (ijsplt))
+      ALLOCATE(nlejtl (ijsplt))
+      ALLOCATE(nimpptl(ijsplt))
+      ALLOCATE(njmpptl(ijsplt))
+      ALLOCATE(nlcitl (ijsplt))
+      ALLOCATE(nlcjtl (ijsplt))
+      ALLOCATE(t_ctll (ijsplt))
+      ALLOCATE(s_ctll (ijsplt))
+      ALLOCATE(u_ctll (ijsplt))
+      ALLOCATE(v_ctll (ijsplt))
+      ALLOCATE(ibonitl(ijsplt))
+      ALLOCATE(ibonjtl(ijsplt))
+
+      ! Initialization 
+      t_ctll(:)=0.e0
+      s_ctll(:)=0.e0
+      u_ctll(:)=0.e0
+      v_ctll(:)=0.e0
+      ktime = 1
+
+      IF( lk_mpp ) THEN
+         sind = narea
+         eind = narea
+         clb_name = "('mpp.output_',I4.4)"
+         cl_run = 'MULTI processor run'
+         ! use indices for each area computed by mpp_init subroutine
+         nlditl(:) = nldit(:) 
+         nleitl(:) = nleit(:) 
+         nldjtl(:) = nldjt(:) 
+         nlejtl(:) = nlejt(:) 
+         !
+         nimpptl(:) = nimppt(:)
+         njmpptl(:) = njmppt(:)
+         !
+         nlcitl(:) = nlcit(:)
+         nlcjtl(:) = nlcjt(:)
+         !
+         ibonitl(:) = ibonit(:)
+         ibonjtl(:) = ibonjt(:)
+      ELSE
+         sind = 1
+         eind = ijsplt
+         clb_name = "('mono.output_',I4.4)"
+         cl_run = 'MONO processor run '
+         ! compute indices for each area as done in mpp_init subroutine
+         CALL sub_dom
+      ENDIF
+
+      ALLOCATE(numid(eind-sind+1))
+
+      DO jn = sind, eind
+         WRITE(clfile_out,FMT=clb_name) jn-1
+         CALL ctlopn( numid(jn -narea + 1), clfile_out, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+            &         1, numout, .FALSE., 1 )
+         j_id = numid(jn -narea + 1)
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                 L O D Y C - I P S L'
+         WRITE(j_id,*) '                     O P A model'
+         WRITE(j_id,*) '            Ocean General Circulation Model'
+         WRITE(j_id,*) '               version OPA 9.0  (2005) '
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                   PROC number: ', jn
+         WRITE(j_id,*)
+         WRITE(j_id,FMT="(19x,a20)")cl_run
+
+         ! Print the SUM control indices
+         IF( .NOT. lsp_area )   THEN
+            nictls = nimpptl(jn) + nlditl(jn) - 1
+            nictle = nimpptl(jn) + nleitl(jn) - 1
+            njctls = njmpptl(jn) + nldjtl(jn) - 1
+            njctle = njmpptl(jn) + nlejtl(jn) - 1
+         ENDIF
+         WRITE(j_id,*) 
+         WRITE(j_id,*) 'prt_ctl :  Sum control indices'
+         WRITE(j_id,*) '~~~~~~~'
+         WRITE(j_id,*)
+         WRITE(j_id,9000)'                                nlej   = ', nlejtl(jn), '              '
+         WRITE(j_id,9000)'                  ------------- njctle = ', njctle, ' -------------'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9002)'           nictls = ', nictls,  '                           nictle = ', nictle
+         WRITE(j_id,9002)'           nldi   = ', nlditl(jn),  '                           nlei   = ', nleitl(jn)
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9004)'  njmpp  = ',njmpptl(jn),'   ------------- njctls = ', njctls, ' -------------'
+         WRITE(j_id,9003)'           nimpp  = ', nimpptl(jn), '        nldj   = ', nldjtl(jn), '              '
+         WRITE(j_id,*)
+         WRITE(j_id,*)
+
+9000     FORMAT(a41,i4.4,a14)
+9001     FORMAT(a59)
+9002     FORMAT(a20,i4.4,a36,i3.3)
+9003     FORMAT(a20,i4.4,a17,i4.4)
+9004     FORMAT(a11,i4.4,a26,i4.4,a14)
+      ENDDO
+
+   END SUBROUTINE prt_ctl_init
+
+
+   SUBROUTINE sub_dom
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sub_dom  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors. 
+      !!                CAUTION: 
+      !!                This part has been extracted from the mpp_init
+      !!                subroutine and names of variables/arrays have been 
+      !!                slightly changed to avoid confusion but the computation
+      !!                is exactly the same. Any modification about indices of
+      !!                each sub-domain in the mppini.F90 module should be reported 
+      !!                here.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!                Periodic condition is a function of the local domain position
+      !!                (global boundary or neighbouring domain) and of the global
+      !!                periodic
+      !!                Type :         jperio global periodic condition
+      !!                               nperio local  periodic condition
+      !!
+      !! ** Action  : - set domain parameters
+      !!                    nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlcil      : first dimension
+      !!                    nlcjl      : second dimension
+      !!                    nbondil    : mark for "east-west local boundary"
+      !!                    nbondjl    : mark for "north-south local boundary"
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   8.5  !  02-08  (G. Madec)  F90 : free form
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::   ji, jj, jn               ! dummy loop indices
+      INTEGER ::   &
+         ii, ij,                         &  ! temporary integers
+         irestil, irestjl,               &  !    "          "
+         ijpi  , ijpj, nlcil,            &  ! temporary logical unit
+         nlcjl , nbondil, nbondjl,       &
+         nrecil, nrecjl, nldil, nleil, nldjl, nlejl
+
+      INTEGER, DIMENSION(:,:), ALLOCATABLE ::   &
+         iimpptl, ijmpptl, ilcitl, ilcjtl       ! temporary workspace
+      REAL(wp) ::   zidom, zjdom            ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !  Computation of local domain sizes ilcitl() ilcjtl()
+      !  These dimensions depend on global sizes isplt,jsplt and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array (cf. par_oce.F90).
+
+      ijpi = ( jpiglo-2*jpreci + (isplt-1) ) / isplt + 2*jpreci
+      ijpj = ( jpjglo-2*jprecj + (jsplt-1) ) / jsplt + 2*jprecj
+
+      ALLOCATE(ilcitl (isplt,jsplt))
+      ALLOCATE(ilcjtl (isplt,jsplt))
+
+      nrecil  = 2 * jpreci
+      nrecjl  = 2 * jprecj
+      irestil = MOD( jpiglo - nrecil , isplt )
+      irestjl = MOD( jpjglo - nrecjl , jsplt )
+
+      IF(  irestil == 0 )   irestil = isplt
+      DO jj = 1, jsplt
+         DO ji = 1, irestil
+            ilcitl(ji,jj) = ijpi
+         END DO
+         DO ji = irestil+1, isplt
+            ilcitl(ji,jj) = ijpi -1
+         END DO
+      END DO
+      
+      IF( irestjl == 0 )   irestjl = jsplt
+      DO ji = 1, isplt
+         DO jj = 1, irestjl
+            ilcjtl(ji,jj) = ijpj
+         END DO
+         DO jj = irestjl+1, jsplt
+            ilcjtl(ji,jj) = ijpj -1
+         END DO
+      END DO
+      
+      zidom = nrecil
+      DO ji = 1, isplt
+         zidom = zidom + ilcitl(ji,1) - nrecil
+      END DO
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilcitl(i,1) = ', zidom, ' jpiglo = ', jpiglo
+      
+      zjdom = nrecjl
+      DO jj = 1, jsplt
+         zjdom = zjdom + ilcjtl(1,jj) - nrecjl
+      END DO
+      IF(lwp) WRITE(numout,*)' sum ilcitl(1,j) = ', zjdom, ' jpjglo = ', jpjglo
+      IF(lwp) WRITE(numout,*)
+      
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+
+      ALLOCATE(iimpptl(isplt,jsplt))
+      ALLOCATE(ijmpptl(isplt,jsplt))
+      
+      iimpptl(:,:) = 1
+      ijmpptl(:,:) = 1
+      
+      IF( isplt > 1 ) THEN
+         DO jj = 1, jsplt
+            DO ji = 2, isplt
+               iimpptl(ji,jj) = iimpptl(ji-1,jj) + ilcitl(ji-1,jj) - nrecil
+            END DO
+         END DO
+      ENDIF
+
+      IF( jsplt > 1 ) THEN
+         DO jj = 2, jsplt
+            DO ji = 1, isplt
+               ijmpptl(ji,jj) = ijmpptl(ji,jj-1)+ilcjtl(ji,jj-1)-nrecjl
+            END DO
+         END DO
+      ENDIF
+      
+      ! 3. Subdomain description
+      ! ------------------------
+
+      DO jn = 1, ijsplt
+         ii = 1 + MOD( jn-1, isplt )
+         ij = 1 + (jn-1) / isplt
+         nimpptl(jn) = iimpptl(ii,ij)
+         njmpptl(jn) = ijmpptl(ii,ij)
+         nlcitl (jn) = ilcitl (ii,ij)     
+         nlcil       = nlcitl (jn)     
+         nlcjtl (jn) = ilcjtl (ii,ij)     
+         nlcjl       = nlcjtl (jn)
+         nbondjl = -1                                    ! general case
+         IF( jn   >  isplt          )   nbondjl = 0      ! first row of processor
+         IF( jn   >  (jsplt-1)*isplt )  nbondjl = 1     ! last  row of processor
+         IF( jsplt == 1             )   nbondjl = 2      ! one processor only in j-direction
+         ibonjtl(jn) = nbondjl
+         
+         nbondil = 0                                     ! 
+         IF( MOD( jn, isplt ) == 1 )   nbondil = -1      !
+         IF( MOD( jn, isplt ) == 0 )   nbondil =  1      !
+         IF( isplt            == 1 )   nbondil =  2      ! one processor only in i-direction
+         ibonitl(jn) = nbondil
+         
+         nldil =  1   + jpreci
+         nleil = nlcil - jpreci
+         IF( nbondil == -1 .OR. nbondil == 2 )   nldil = 1
+         IF( nbondil ==  1 .OR. nbondil == 2 )   nleil = nlcil
+         nldjl =  1   + jprecj
+         nlejl = nlcjl - jprecj
+         IF( nbondjl == -1 .OR. nbondjl == 2 )   nldjl = 1
+         IF( nbondjl ==  1 .OR. nbondjl == 2 )   nlejl = nlcjl
+         nlditl(jn) = nldil
+         nleitl(jn) = nleil
+         nldjtl(jn) = nldjl
+         nlejtl(jn) = nlejl
+      END DO
+
+      DEALLOCATE(iimpptl)
+      DEALLOCATE(ijmpptl)
+      DEALLOCATE(ilcitl)
+      DEALLOCATE(ilcjtl)
+
+   END SUBROUTINE sub_dom
+
+END MODULE prtctl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/step.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/step.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/step.F90	(revision 1844)
@@ -0,0 +1,94 @@
+MODULE step
+   !!======================================================================
+   !!                       ***  MODULE step  ***
+   !! Time-stepping    : manager of the ocean, tracer and ice time stepping
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   stp            : OPA system time-stepping
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE ldftra_oce
+   USE in_out_manager  ! I/O manager
+   USE lbclnk
+   USE trcdia
+   USE daymod          ! calendar                         (day     routine)
+   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
+   USE dtadyn          ! Lecture and interpolation of the dynamical fields
+   USE eosbn2          ! equation of state                (eos_bn2 routine)
+   USE trcrst          ! restart for passive tracers
+   USE stpctl          ! time stepping control            (stp_ctl routine)
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC stp            ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE stp( kstp )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE stp  ***
+      !!                      
+      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
+      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
+      !!              - Tme stepping  of TRC (passive tracer eqs.)
+      !! 
+      !! ** Method  : -1- Update forcings and data  
+      !!              -2- Update ocean physics 
+      !!              -3- Compute the t and s trends 
+      !!              -4- Update t and s 
+      !!              -5- Compute the momentum trends
+      !!              -6- Update the horizontal velocity
+      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
+      !!              -8- Outputs and diagnostics
+      !!
+      !! History :
+      !!        !  91-03  ()  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  92-06  (M. Imbard)  add a first output record
+      !!        !  96-04  (G. Madec)  introduction of dynspg
+      !!        !  96-04  (M.A. Foujols)  introduction of passive tracer
+      !!   8.0  !  97-06  (G. Madec)  new architecture of call
+      !!   8.2  !  97-06  (G. Madec, M. Imbard, G. Roullet)  free surface
+      !!   8.2  !  99-02  (G. Madec, N. Grima)  hpg implicit
+      !!   8.2  !  00-07  (J-M Molines, M. Imbard)  Open Bondary Conditions
+      !!   9.0  !  02-06  (G. Madec)  free form, suppress macro-tasking
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kstp   ! ocean time-step index
+      !! ---------------------------------------------------------------------
+
+      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
+
+      IF( lk_iomput ) CALL iom_setkt( kstp )       ! say to iom that we are at time step kstp
+
+      CALL dta_dyn( kstp )         ! Interpolation of the dynamical fields
+
+      CALL trc_stp( kstp )         ! time-stepping
+
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control, diagnostics and outputs
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                                            ! Time loop: control and print
+       CALL stp_ctl( kstp )
+
+
+   END SUBROUTINE stp
+
+   !!======================================================================
+END MODULE step
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/stpctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/stpctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/stpctl.F90	(revision 1844)
@@ -0,0 +1,71 @@
+MODULE stpctl
+   !!==============================================================================
+   !!                       ***  MODULE  stpctl  ***
+   !! Ocean run control :  gross check of the ocean time stepping
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   stp_ctl      : Control the run
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC stp_ctl           ! routine called by step.F90
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE stp_ctl( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE stp_ctl  ***
+      !!                     
+      !! ** Purpose :   Control the run
+      !!
+      !! ** Method  : - Save the time step in numstp
+      !!              - Print it each 50 time steps
+      !!              - Print solver statistics in numsol 
+      !!              - Stop the run IF problem for the solver ( indec < 0 )
+      !!
+      !! History :
+      !!        !  91-03  ()
+      !!        !  91-11  (G. Madec)
+      !!        !  92-06  (M. Imbard)
+      !!        !  97-06  (A.M. Treguier)
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
+
+      !!----------------------------------------------------------------------
+      !!   OPA 9.0 , LOCEAN-IPSL  (2005)
+      !!   $Id$
+      !!   This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'stp_ctl : time-stepping control'
+         WRITE(numout,*) '~~~~~~~'
+         ! open time.step file
+         CALL ctlopn( numstp, 'time.step', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, 1 )
+      ENDIF
+
+      ! save the current time step in numstp
+      ! ------------------------------------
+      IF(lwp) WRITE(numstp,9100) kt
+      IF(lwp) REWIND(numstp)
+9100  FORMAT(1x, i8)
+
+
+   END SUBROUTINE stp_ctl
+
+   !!======================================================================
+END MODULE stpctl
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/trc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/trc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/trc_oce.F90	(revision 1844)
@@ -0,0 +1,229 @@
+MODULE trc_oce
+   !!======================================================================
+   !!                      ***  MODULE  trc_oce  ***
+   !! Ocean passive tracer  :  share SMS/Ocean variables
+   !!======================================================================
+   !! History :  1.0  !  2004-03  (C. Ethe)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   trc_oce_rgb : tabulated attenuation coefficients for RGB light penetration         
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_oce_rgb        ! routine called by traqsr.F90
+   PUBLIC   trc_oce_rgb_read   ! routine called by traqsr.F90
+   PUBLIC   trc_oce_ext_lev    ! function called by traqsr.F90 at least
+   
+   REAL(wp), PUBLIC , DIMENSION(jpi,jpj,jpk) ::   etot3   !: light absortion coefficient
+
+#if defined key_top && defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_top'   &   'key_pisces'                       PISCES bio-model          
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qsr_bio = .TRUE.   !: bio-model light absorption flag
+#else
+   !!----------------------------------------------------------------------
+   !! Default option                          No bio-model light absorption      
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qsr_bio = .FALSE.   !: bio-model light absorption flag
+#endif
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id: trc_oce.F90 1834 2010-04-14 11:54:19Z cetlod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_oce_rgb( prgb )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_opt_init  ***
+      !!
+      !! ** Purpose :   Initialization of of the optical scheme
+      !!
+      !! ** Method  :   Set a look up table for the optical coefficients
+      !!                i.e. the attenuation coefficient for R-G-B light 
+      !!                tabulated in Chlorophyll class (from JM Andre)
+      !!
+      !! ** Action  :   prgb(3,61) tabulated R-G-B attenuation coef. 
+      !!
+      !! Reference  : Lengaigne et al. 2007, Clim. Dyn., V28, 5, 503-516.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(3,61), INTENT(out) ::   prgb   ! tabulated attenuation coefficient
+      !!
+      INTEGER  ::   jc     ! dummy loop indice
+      INTEGER  ::   irgb   ! temporary integer
+      REAL(wp) ::   zchl   ! temporary scalar
+      REAL(wp), DIMENSION(4,61) ::   zrgb   ! tabulated attenuation coefficient (formerly read in 'kRGB61.txt')
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_oce_rgb : Initialisation of the optical look-up table'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+      !
+      !  Chlorophyll        !     Blue attenuation     !     Green attenuation    !     Red attenuation      !
+      zrgb(1, 1) =  0.010   ;   zrgb(2, 1) = 0.01618   ;   zrgb(3, 1) = 0.07464   ;   zrgb(4, 1) = 0.37807
+      zrgb(1, 2) =  0.011   ;   zrgb(2, 2) = 0.01654   ;   zrgb(3, 2) = 0.07480   ;   zrgb(4, 2) = 0.37823
+      zrgb(1, 3) =  0.013   ;   zrgb(2, 3) = 0.01693   ;   zrgb(3, 3) = 0.07499   ;   zrgb(4, 3) = 0.37840
+      zrgb(1, 4) =  0.014   ;   zrgb(2, 4) = 0.01736   ;   zrgb(3, 4) = 0.07518   ;   zrgb(4, 4) = 0.37859
+      zrgb(1, 5) =  0.016   ;   zrgb(2, 5) = 0.01782   ;   zrgb(3, 5) = 0.07539   ;   zrgb(4, 5) = 0.37879
+      zrgb(1, 6) =  0.018   ;   zrgb(2, 6) = 0.01831   ;   zrgb(3, 6) = 0.07562   ;   zrgb(4, 6) = 0.37900
+      zrgb(1, 7) =  0.020   ;   zrgb(2, 7) = 0.01885   ;   zrgb(3, 7) = 0.07586   ;   zrgb(4, 7) = 0.37923
+      zrgb(1, 8) =  0.022   ;   zrgb(2, 8) = 0.01943   ;   zrgb(3, 8) = 0.07613   ;   zrgb(4, 8) = 0.37948
+      zrgb(1, 9) =  0.025   ;   zrgb(2, 9) = 0.02005   ;   zrgb(3, 9) = 0.07641   ;   zrgb(4, 9) = 0.37976
+      zrgb(1,10) =  0.028   ;   zrgb(2,10) = 0.02073   ;   zrgb(3,10) = 0.07672   ;   zrgb(4,10) = 0.38005
+      zrgb(1,11) =  0.032   ;   zrgb(2,11) = 0.02146   ;   zrgb(3,11) = 0.07705   ;   zrgb(4,11) = 0.38036
+      zrgb(1,12) =  0.035   ;   zrgb(2,12) = 0.02224   ;   zrgb(3,12) = 0.07741   ;   zrgb(4,12) = 0.38070
+      zrgb(1,13) =  0.040   ;   zrgb(2,13) = 0.02310   ;   zrgb(3,13) = 0.07780   ;   zrgb(4,13) = 0.38107
+      zrgb(1,14) =  0.045   ;   zrgb(2,14) = 0.02402   ;   zrgb(3,14) = 0.07821   ;   zrgb(4,14) = 0.38146
+      zrgb(1,15) =  0.050   ;   zrgb(2,15) = 0.02501   ;   zrgb(3,15) = 0.07866   ;   zrgb(4,15) = 0.38189
+      zrgb(1,16) =  0.056   ;   zrgb(2,16) = 0.02608   ;   zrgb(3,16) = 0.07914   ;   zrgb(4,16) = 0.38235
+      zrgb(1,17) =  0.063   ;   zrgb(2,17) = 0.02724   ;   zrgb(3,17) = 0.07967   ;   zrgb(4,17) = 0.38285
+      zrgb(1,18) =  0.071   ;   zrgb(2,18) = 0.02849   ;   zrgb(3,18) = 0.08023   ;   zrgb(4,18) = 0.38338
+      zrgb(1,19) =  0.079   ;   zrgb(2,19) = 0.02984   ;   zrgb(3,19) = 0.08083   ;   zrgb(4,19) = 0.38396
+      zrgb(1,20) =  0.089   ;   zrgb(2,20) = 0.03131   ;   zrgb(3,20) = 0.08149   ;   zrgb(4,20) = 0.38458
+      zrgb(1,21) =  0.100   ;   zrgb(2,21) = 0.03288   ;   zrgb(3,21) = 0.08219   ;   zrgb(4,21) = 0.38526
+      zrgb(1,22) =  0.112   ;   zrgb(2,22) = 0.03459   ;   zrgb(3,22) = 0.08295   ;   zrgb(4,22) = 0.38598
+      zrgb(1,23) =  0.126   ;   zrgb(2,23) = 0.03643   ;   zrgb(3,23) = 0.08377   ;   zrgb(4,23) = 0.38676
+      zrgb(1,24) =  0.141   ;   zrgb(2,24) = 0.03842   ;   zrgb(3,24) = 0.08466   ;   zrgb(4,24) = 0.38761
+      zrgb(1,25) =  0.158   ;   zrgb(2,25) = 0.04057   ;   zrgb(3,25) = 0.08561   ;   zrgb(4,25) = 0.38852
+      zrgb(1,26) =  0.178   ;   zrgb(2,26) = 0.04289   ;   zrgb(3,26) = 0.08664   ;   zrgb(4,26) = 0.38950
+      zrgb(1,27) =  0.200   ;   zrgb(2,27) = 0.04540   ;   zrgb(3,27) = 0.08775   ;   zrgb(4,27) = 0.39056
+      zrgb(1,28) =  0.224   ;   zrgb(2,28) = 0.04811   ;   zrgb(3,28) = 0.08894   ;   zrgb(4,28) = 0.39171
+      zrgb(1,29) =  0.251   ;   zrgb(2,29) = 0.05103   ;   zrgb(3,29) = 0.09023   ;   zrgb(4,29) = 0.39294
+      zrgb(1,30) =  0.282   ;   zrgb(2,30) = 0.05420   ;   zrgb(3,30) = 0.09162   ;   zrgb(4,30) = 0.39428
+      zrgb(1,31) =  0.316   ;   zrgb(2,31) = 0.05761   ;   zrgb(3,31) = 0.09312   ;   zrgb(4,31) = 0.39572
+      zrgb(1,32) =  0.355   ;   zrgb(2,32) = 0.06130   ;   zrgb(3,32) = 0.09474   ;   zrgb(4,32) = 0.39727
+      zrgb(1,33) =  0.398   ;   zrgb(2,33) = 0.06529   ;   zrgb(3,33) = 0.09649   ;   zrgb(4,33) = 0.39894
+      zrgb(1,34) =  0.447   ;   zrgb(2,34) = 0.06959   ;   zrgb(3,34) = 0.09837   ;   zrgb(4,34) = 0.40075
+      zrgb(1,35) =  0.501   ;   zrgb(2,35) = 0.07424   ;   zrgb(3,35) = 0.10040   ;   zrgb(4,35) = 0.40270
+      zrgb(1,36) =  0.562   ;   zrgb(2,36) = 0.07927   ;   zrgb(3,36) = 0.10259   ;   zrgb(4,36) = 0.40480
+      zrgb(1,37) =  0.631   ;   zrgb(2,37) = 0.08470   ;   zrgb(3,37) = 0.10495   ;   zrgb(4,37) = 0.40707
+      zrgb(1,38) =  0.708   ;   zrgb(2,38) = 0.09056   ;   zrgb(3,38) = 0.10749   ;   zrgb(4,38) = 0.40952
+      zrgb(1,39) =  0.794   ;   zrgb(2,39) = 0.09690   ;   zrgb(3,39) = 0.11024   ;   zrgb(4,39) = 0.41216
+      zrgb(1,40) =  0.891   ;   zrgb(2,40) = 0.10374   ;   zrgb(3,40) = 0.11320   ;   zrgb(4,40) = 0.41502
+      zrgb(1,41) =  1.000   ;   zrgb(2,41) = 0.11114   ;   zrgb(3,41) = 0.11639   ;   zrgb(4,41) = 0.41809
+      zrgb(1,42) =  1.122   ;   zrgb(2,42) = 0.11912   ;   zrgb(3,42) = 0.11984   ;   zrgb(4,42) = 0.42142
+      zrgb(1,43) =  1.259   ;   zrgb(2,43) = 0.12775   ;   zrgb(3,43) = 0.12356   ;   zrgb(4,43) = 0.42500
+      zrgb(1,44) =  1.413   ;   zrgb(2,44) = 0.13707   ;   zrgb(3,44) = 0.12757   ;   zrgb(4,44) = 0.42887
+      zrgb(1,45) =  1.585   ;   zrgb(2,45) = 0.14715   ;   zrgb(3,45) = 0.13189   ;   zrgb(4,45) = 0.43304
+      zrgb(1,46) =  1.778   ;   zrgb(2,46) = 0.15803   ;   zrgb(3,46) = 0.13655   ;   zrgb(4,46) = 0.43754
+      zrgb(1,47) =  1.995   ;   zrgb(2,47) = 0.16978   ;   zrgb(3,47) = 0.14158   ;   zrgb(4,47) = 0.44240
+      zrgb(1,48) =  2.239   ;   zrgb(2,48) = 0.18248   ;   zrgb(3,48) = 0.14701   ;   zrgb(4,48) = 0.44765
+      zrgb(1,49) =  2.512   ;   zrgb(2,49) = 0.19620   ;   zrgb(3,49) = 0.15286   ;   zrgb(4,49) = 0.45331
+      zrgb(1,50) =  2.818   ;   zrgb(2,50) = 0.21102   ;   zrgb(3,50) = 0.15918   ;   zrgb(4,50) = 0.45942
+      zrgb(1,51) =  3.162   ;   zrgb(2,51) = 0.22703   ;   zrgb(3,51) = 0.16599   ;   zrgb(4,51) = 0.46601
+      zrgb(1,52) =  3.548   ;   zrgb(2,52) = 0.24433   ;   zrgb(3,52) = 0.17334   ;   zrgb(4,52) = 0.47313
+      zrgb(1,53) =  3.981   ;   zrgb(2,53) = 0.26301   ;   zrgb(3,53) = 0.18126   ;   zrgb(4,53) = 0.48080
+      zrgb(1,54) =  4.467   ;   zrgb(2,54) = 0.28320   ;   zrgb(3,54) = 0.18981   ;   zrgb(4,54) = 0.48909
+      zrgb(1,55) =  5.012   ;   zrgb(2,55) = 0.30502   ;   zrgb(3,55) = 0.19903   ;   zrgb(4,55) = 0.49803
+      zrgb(1,56) =  5.623   ;   zrgb(2,56) = 0.32858   ;   zrgb(3,56) = 0.20898   ;   zrgb(4,56) = 0.50768
+      zrgb(1,57) =  6.310   ;   zrgb(2,57) = 0.35404   ;   zrgb(3,57) = 0.21971   ;   zrgb(4,57) = 0.51810
+      zrgb(1,58) =  7.079   ;   zrgb(2,58) = 0.38154   ;   zrgb(3,58) = 0.23129   ;   zrgb(4,58) = 0.52934
+      zrgb(1,59) =  7.943   ;   zrgb(2,59) = 0.41125   ;   zrgb(3,59) = 0.24378   ;   zrgb(4,59) = 0.54147
+      zrgb(1,60) =  8.912   ;   zrgb(2,60) = 0.44336   ;   zrgb(3,60) = 0.25725   ;   zrgb(4,60) = 0.55457
+      zrgb(1,61) = 10.000   ;   zrgb(2,61) = 0.47804   ;   zrgb(3,61) = 0.27178   ;   zrgb(4,61) = 0.56870
+      !
+      prgb(:,:) = zrgb(2:4,:)
+      !
+      DO jc = 1, 61                         ! check
+         zchl = zrgb(1,jc)
+         irgb = NINT( 41 + 20.* LOG10( zchl ) + 1.e-15 )
+         IF(lwp) WRITE(numout,*) '    jc =', jc, '  Chl = ', zchl, '  irgb = ', irgb
+         IF( irgb /= jc ) THEN
+            IF(lwp) WRITE(numout,*) '    jc =', jc, '  Chl = ', zchl, '  Chl class = ', irgb
+            CALL ctl_stop( 'trc_oce_rgb : inconsistency in Chl tabulated attenuation coeff.' )
+         ENDIF
+      END DO
+      !
+   END SUBROUTINE trc_oce_rgb
+
+
+   SUBROUTINE trc_oce_rgb_read( prgb )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_opt_init  ***
+      !!
+      !! ** Purpose :   Initialization of of the optical scheme
+      !!
+      !! ** Method  :   read the look up table for the optical coefficients
+      !!
+      !! ** input   :   xkrgb(61) precomputed array corresponding to the  
+      !!                          attenuation coefficient (from JM Andre)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(3,61), INTENT(out) ::   prgb   ! tabulated attenuation coefficient
+      !!
+      INTEGER  ::   jchl, jband   ! dummy loop indices
+      INTEGER  ::   numlight
+      REAL(wp) ::   zchl
+      CHARACTER(LEN=20) :: clname
+      !!----------------------------------------------------------------------
+      !
+      clname = 'kRGB61.txt' 
+      CALL ctlopn( numlight, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', 1, numout, .TRUE., 1 )
+      DO jchl = 1, 61
+         READ(numlight,*) zchl, ( prgb(jband,jchl), jband=1,3 )
+      END DO
+      CLOSE( numlight )
+      !
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' trc_oce_rgb_read : optical look-up table read in kRGB61.txt file'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
+      ENDIF
+      !
+   END SUBROUTINE trc_oce_rgb_read
+
+
+   FUNCTION trc_oce_ext_lev( prldex, pqsr_frc ) RESULT( pjl )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE trc_oce_ext_lev  ***
+      !!       
+      !! ** Purpose :   compute max. level for light penetration
+      !!          
+      !! ** Method  :   the function provides the level at which irradiance 
+      !!                becomes negligible (i.e. = 1.e-15 W/m2) for 3 or 2 bands light
+      !!                penetration: I(z) = pqsr_frc * EXP(hext/prldex) = 1.e-15 W/m2
+      !!                # prldex is the longest depth of extinction:
+      !!                   - prldex = 23 m (2 bands case)
+      !!                   - prldex = 62 m (3 bands case: blue waveband & 0.01 mg/m2 for the chlorophyll)
+      !!                # pqsr_frc is the fraction of solar radiation which penetrates,
+      !!                considering Qsr=240 W/m2 and rn_abs = 0.58:
+      !!                   - pqsr_frc = Qsr * (1-rn_abs)   = 1.00e2 W/m2 (2 bands case)
+      !!                   - pqsr_frc = Qsr * (1-rn_abs)/3 = 0.33e2 W/m2 (3 bands case & equi-partition)
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in) ::   prldex    ! longest depth of extinction
+      REAL(wp), INTENT(in) ::   pqsr_frc  ! frac. solar radiation which penetrates 
+      !!
+      INTEGER  ::   jk, pjl            ! levels
+      REAL(wp) ::   zhext              ! deepest level till which light penetrates
+      REAL(wp) ::   zprec = 15._wp     ! precision to reach -LOG10(1.e-15)
+      REAL(wp) ::   zem                ! temporary scalar 
+      !!----------------------------------------------------------------------
+      !
+      ! It is not necessary to compute anything bellow the following depth
+      zhext = prldex * ( LOG(10.e0) * zprec + LOG(pqsr_frc) )
+     
+      ! Level of light extinction
+      pjl = jpkm1
+      DO jk = jpkm1, 1, -1
+         zem = MAXVAL( fsdepw(:,:,jk+1) * tmask(:,:,jk) )
+         IF( zem >= zhext )   pjl = jk                       ! last T-level reached by Qsr
+      END DO
+      !
+   END FUNCTION trc_oce_ext_lev
+
+
+   !!======================================================================
+END MODULE trc_oce
Index: /branches/DEV_r1837_MLF/NEMO/OFF_SRC/vectopt_loop_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OFF_SRC/vectopt_loop_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OFF_SRC/vectopt_loop_substitute.h90	(revision 1844)
@@ -0,0 +1,18 @@
+   !!----------------------------------------------------------------------
+   !!                   ***  vectopt_loop_substitute  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute the inner loop starting and inding indices 
+   !!      to allow unrolling of do-loop using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_vectopt_loop
+#  define fs_2     1
+#  define fs_jpim1 jpi
+#else
+#  define fs_2     2
+#  define fs_jpim1 jpim1
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_oce.F90	(revision 1844)
@@ -0,0 +1,88 @@
+MODULE bdy_oce
+   !!======================================================================
+   !!                       ***  MODULE bdy_oce   ***
+   !! Unstructured Open Boundary Cond. :   define related variables
+   !!======================================================================
+   !! History :  1.0  !  2001-05  (J. Chanut, A. Sellar)  Original code
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version     
+   !!----------------------------------------------------------------------
+#if defined key_bdy 
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'                      Unstructured Open Boundary Condition
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+   USE bdy_par         ! Unstructured boundary parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !! Namelist variables
+   !!----------------------------------------------------------------------
+   CHARACTER(len=80) ::   filbdy_mask        !: Name of unstruct. bdy mask file
+   CHARACTER(len=80) ::   filbdy_data_T      !: Name of unstruct. bdy data file at T points
+   CHARACTER(len=80) ::   filbdy_data_U      !: Name of unstruct. bdy data file at U points
+   CHARACTER(len=80) ::   filbdy_data_V      !: Name of unstruct. bdy data file at V points
+   CHARACTER(len=80) ::   filbdy_data_bt_T   !: Name of unstruct. bdy data file at T points for barotropic variables
+   CHARACTER(len=80) ::   filbdy_data_bt_U   !: Name of unstruct. bdy data file at U points for barotropic variables
+   CHARACTER(len=80) ::   filbdy_data_bt_V   !: Name of unstruct. bdy data file at V points for barotropic variables
+   !
+   LOGICAL ::   ln_bdy_tides = .false.  !: =T apply tidal harmonic forcing along open boundaries
+   LOGICAL ::   ln_bdy_vol  = .false.   !: =T volume correction             
+   LOGICAL ::   ln_bdy_mask = .false.   !: =T read bdymask from file
+   LOGICAL ::   ln_bdy_clim = .false.   !: if true, we assume that bdy data files contain 
+   !                                    !  1 time dump  (-->bdy forcing will be constant) 
+   !                                    !  or 12 months (-->bdy forcing will be cyclic) 
+   LOGICAL ::   ln_bdy_dyn_fla  = .false. !: =T Flather boundary conditions on barotropic velocities
+   LOGICAL ::   ln_bdy_dyn_frs  = .false. !: =T FRS boundary conditions on velocities
+   LOGICAL ::   ln_bdy_tra_frs  = .false. !: =T FRS boundary conditions on tracers (T and S)
+   LOGICAL ::   ln_bdy_ice_frs  = .false. !: =T FRS boundary conditions on seaice (leads fraction, ice depth, snow depth)
+   !
+   INTEGER ::   nb_rimwidth = 7         !: boundary rim width
+   INTEGER ::   nbdy_dta    = 1	        !: = 0 use the initial state as bdy dta or = 1 read it in a NetCDF file
+   INTEGER ::   volbdy      = 1         !: = 0 the total volume will have the variability of the surface Flux E-P 
+   !                                    !  = 1 the volume will be constant during all the integration.
+
+   !!----------------------------------------------------------------------
+   !! Global variables
+   !!----------------------------------------------------------------------
+   REAL(wp), DIMENSION(jpi,jpj) ::   bdytmask   !: Mask defining computational domain at T-points
+   REAL(wp), DIMENSION(jpi,jpj) ::   bdyumask   !: Mask defining computational domain at U-points
+   REAL(wp), DIMENSION(jpi,jpj) ::   bdyvmask   !: Mask defining computational domain at V-points
+
+   !!----------------------------------------------------------------------
+   !! Unstructured open boundary data variables
+   !!----------------------------------------------------------------------
+   INTEGER, DIMENSION(jpbgrd) ::   nblen                  !: Size of bdy data on a proc for each grid type
+   INTEGER, DIMENSION(jpbgrd) ::   nblenrim               !: Size of bdy data on a proc for first rim ind
+   INTEGER, DIMENSION(jpbgrd) ::   nblendta               !: Size of bdy data in file
+
+   INTEGER, DIMENSION(jpbdim,jpbgrd) ::   nbi, nbj        !: i and j indices of bdy dta
+   INTEGER, DIMENSION(jpbdim,jpbgrd) ::   nbr             !: Discrete distance from rim points
+   INTEGER, DIMENSION(jpbdim,jpbgrd) ::   nbmap           !: Indices of data in file for data in memory 
+    
+   REAL(wp) ::   bdysurftot	                          !: Lateral surface of unstructured open boundary
+
+   REAL(wp), DIMENSION(jpbdim)        ::   flagu, flagv   !: Flag for normal velocity compnt for velocity components
+   REAL(wp), DIMENSION(jpbdim,jpbgrd) ::   nbw            !: Rim weights of bdy data
+
+   REAL(wp), DIMENSION(jpbdim)     ::   sshbdy            !: Now clim of bdy sea surface height (Flather)
+   REAL(wp), DIMENSION(jpbdim)     ::   ubtbdy, vbtbdy    !: Now clim of bdy barotropic velocity components
+   REAL(wp), DIMENSION(jpbdim,jpk) ::   tbdy  , sbdy      !: Now clim of bdy temperature and salinity  
+   REAL(wp), DIMENSION(jpbdim,jpk) ::   ubdy  , vbdy	  !: Now clim of bdy velocity components
+   REAL(wp), DIMENSION(jpbdim) ::   sshtide               !: Tidal boundary array : SSH
+   REAL(wp), DIMENSION(jpbdim) ::   utide, vtide          !: Tidal boundary array : U and V
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                NO Unstructured Open Boundary Condition
+   !!----------------------------------------------------------------------
+   LOGICAL ::   ln_bdy_tides = .false.  !: =T apply tidal harmonic forcing along open boundaries
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE bdy_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_par.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_par.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdy_par.F90	(revision 1844)
@@ -0,0 +1,35 @@
+MODULE bdy_par
+   !!======================================================================
+   !!                      ***  MODULE bdy_par   ***
+   !! Unstructured Open Boundary Cond. :   define related parameters
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if defined key_bdy
+   !!----------------------------------------------------------------------
+   !!   'key_bdy' :                    Unstructured Open Boundary Condition
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PUBLIC
+
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_bdy  = .TRUE.  !: Unstructured Ocean Boundary Condition flag
+   INTEGER, PUBLIC, PARAMETER ::   jpbdta  = 5000    !: Max length of bdy field in file
+   INTEGER, PUBLIC, PARAMETER ::   jpbdim  = 5000    !: Max length of bdy field on a processor
+   INTEGER, PUBLIC, PARAMETER ::   jpbtime = 1000    !: Max number of time dumps per file
+   INTEGER, PUBLIC, PARAMETER ::   jpbgrd  = 3	     !: Number of horizontal grid types used  (T, u, v, f)
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :            NO Unstructured open boundary condition
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_bdy = .FALSE.   !: Unstructured Ocean Boundary Condition flag
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE bdy_par
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydta.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 1844)
@@ -0,0 +1,1117 @@
+MODULE bdydta
+   !!======================================================================
+   !!                       ***  MODULE bdydta  ***
+   !! Open boundary data : read the data for the unstructured open boundaries.
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!             -   !  2007-01  (D. Storkey) Update to use IOM module
+   !!             -   !  2007-07  (D. Storkey) add bdy_dta_bt
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if defined key_bdy
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'                     Unstructured Open Boundary Conditions
+   !!----------------------------------------------------------------------
+   !!   bdy_dta    : read u, v, t, s data along open boundaries
+   !!   bdy_dta_bt : read depth-mean velocities and elevation along open
+   !!                boundaries        
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE bdy_oce         ! ocean open boundary conditions
+   USE bdytides        ! tidal forcing at boundaries
+   USE iom
+   USE ioipsl
+   USE in_out_manager  ! I/O logical units
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   bdy_dta      ! routines called by step.F90
+   PUBLIC   bdy_dta_bt 
+
+   INTEGER ::   numbdyt, numbdyu, numbdyv                      !: logical units for T-, U-, & V-points data file, resp.
+   INTEGER ::   ntimes_bdy                                     !: exact number of time dumps in data files
+   INTEGER ::   nbdy_b, nbdy_a                                 !: record of bdy data file for before and after model time step
+   INTEGER ::   numbdyt_bt, numbdyu_bt, numbdyv_bt             !: logical unit for T-, U- & V-points data file, resp.
+   INTEGER ::   ntimes_bdy_bt                                  !: exact number of time dumps in data files
+   INTEGER ::   nbdy_b_bt, nbdy_a_bt                           !: record of bdy data file for before and after model time step
+
+   INTEGER, DIMENSION (jpbtime) ::   istep, istep_bt           !: time array in seconds in each data file
+
+   REAL(wp) ::  zoffset                                        !: time offset between time origin in file & start time of model run
+
+   REAL(wp), DIMENSION(jpbdim,jpk,2) ::   tbdydta, sbdydta     !: time interpolated values of T and S bdy data   
+   REAL(wp), DIMENSION(jpbdim,jpk,2) ::   ubdydta, vbdydta     !: time interpolated values of U and V bdy data 
+   REAL(wp), DIMENSION(jpbdim,2)     ::   ubtbdydta, vbtbdydta !: Arrays used for time interpolation of bdy data   
+   REAL(wp), DIMENSION(jpbdim,2)     ::   sshbdydta            !: bdy data of ssh
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE bdy_dta( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  SUBROUTINE bdy_dta  ***
+      !!                    
+      !! ** Purpose :   Read unstructured boundary data for FRS condition.
+      !!
+      !! ** Method  :   At the first timestep, read in boundary data for two
+      !!                times from the file and time-interpolate. At other 
+      !!                timesteps, check to see if we need another time from 
+      !!                the file. If so read it in. Time interpolate.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                             ! ocean time-step index (for timesplitting option, otherwise zero)
+      !!
+      CHARACTER(LEN=80), DIMENSION(3) ::   clfile               ! names of input files
+      CHARACTER(LEN=70 )              ::   clunits              ! units attribute of time coordinate
+      LOGICAL ::   lect                                         ! flag for reading
+      INTEGER ::   it, ib, ik, igrd                             ! dummy loop indices
+      INTEGER ::   igrd_start, igrd_end                         ! start and end of loops on igrd
+      INTEGER ::   idvar                                        ! netcdf var ID
+      INTEGER ::   iman, i15, imois                             ! Time variables for monthly clim forcing
+      INTEGER ::   ntimes_bdyt, ntimes_bdyu, ntimes_bdyv
+      INTEGER ::   itimer, totime
+      INTEGER ::   ii, ij                                       ! array addresses
+      INTEGER ::   ipi, ipj, ipk, inum                          ! temporary integers (NetCDF read)
+      INTEGER ::   iyear0, imonth0, iday0
+      INTEGER ::   ihours0, iminutes0, isec0
+      INTEGER ::   iyear, imonth, iday, isecs
+      INTEGER, DIMENSION(jpbtime) ::   istept, istepu, istepv   ! time arrays from data files
+      REAL(wp) ::   dayfrac, zxy, zoffsett
+      REAL(wp) ::   zoffsetu, zoffsetv
+      REAL(wp) ::   dayjul0, zdayjulini
+      REAL(wp), DIMENSION(jpbtime)      ::   zstepr             ! REAL time array from data files
+      REAL(wp), DIMENSION(jpbdta,1,jpk) ::   zdta               ! temporary array for data fields
+      !!---------------------------------------------------------------------------
+
+      IF( ln_bdy_dyn_frs .OR. ln_bdy_tra_frs ) THEN  ! If these are both false then this routine 
+                                                     ! does nothing.
+
+      ! -------------------- !
+      !    Initialization    !
+      ! -------------------- !
+
+      lect   = .false.           ! If true, read a time record
+
+      ! Some time variables for monthly climatological forcing:
+      ! *******************************************************
+ !!gm  here  use directely daymod variables
+ 
+      iman = INT( raamo )      ! Number of months in a year
+
+      i15 = INT( 2*REAL( nday, wp ) / ( REAL( nmonth_len(nmonth), wp ) + 0.5 ) )
+      ! i15=0 if the current day is in the first half of the month, else i15=1
+
+      imois = nmonth + i15 - 1            ! imois is the first month record
+      IF( imois == 0 )   imois = iman
+
+      ! Time variable for non-climatological forcing:
+      ! *********************************************
+      itimer = (kt-nit000+1)*rdt      ! current time in seconds for interpolation 
+
+
+      !                                                !-------------------!
+      IF( kt == nit000 ) THEN                          !  First call only  !
+         !                                             !-------------------!
+         istep(:) = 0
+         nbdy_b    = 0
+         nbdy_a    = 0
+
+         ! Get time information from bdy data file
+         ! ***************************************
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)    'bdy_dta : Initialize unstructured boundary data'
+         IF(lwp) WRITE(numout,*)    '~~~~~~~' 
+
+         IF     ( nbdy_dta == 0 ) THEN
+            !
+            IF(lwp) WRITE(numout,*) '          Bdy data are taken from initial conditions'
+            !
+         ELSEIF (nbdy_dta == 1) THEN
+            !
+            IF(lwp) WRITE(numout,*) '          Bdy data are read in netcdf files'
+            !
+            dayfrac = adatrj  - REAL( itimer, wp ) / 86400.   ! day fraction at time step kt-1
+            dayfrac = dayfrac - INT ( dayfrac )               !
+            totime  = ( nitend - nit000 + 1 ) * rdt           ! Total time of the run to verify that all the
+            !                                                 ! necessary time dumps in file are included
+            !
+            clfile(1) = filbdy_data_T
+            clfile(2) = filbdy_data_U
+            clfile(3) = filbdy_data_V
+            !                                                  
+            ! how many files are we to read in?
+            igrd_start = 1
+            igrd_end   = 3
+            IF(.NOT. ln_bdy_tra_frs .AND. .NOT. ln_bdy_ice_frs) THEN
+               ! No T-grid file.
+               igrd_start = 2
+            ELSEIF ( .NOT. ln_bdy_dyn_frs ) THEN
+               ! No U-grid or V-grid file.
+               igrd_end   = 1         
+            ENDIF
+
+            DO igrd = igrd_start, igrd_end                     !  loop over T, U & V grid  !
+               !                                               !---------------------------!
+               CALL iom_open( clfile(igrd), inum )
+               CALL iom_gettime( inum, zstepr, kntime=ntimes_bdy, cdunits=clunits ) 
+
+               SELECT CASE( igrd )
+                  CASE (1) 
+                     numbdyt = inum
+                  CASE (2) 
+                     numbdyu = inum
+                  CASE (3) 
+                     numbdyv = inum
+               END SELECT
+
+               ! Calculate time offset 
+               READ(clunits,7000) iyear0, imonth0, iday0, ihours0, iminutes0, isec0
+               ! Convert time origin in file to julian days 
+               isec0 = isec0 + ihours0*60.*60. + iminutes0*60.
+               CALL ymds2ju(iyear0, imonth0, iday0, REAL(isec0, wp), dayjul0)
+               ! Compute model initialization time 
+               iyear  = ndastp / 10000
+               imonth = ( ndastp - iyear * 10000 ) / 100
+               iday   = ndastp - iyear * 10000 - imonth * 100
+               isecs  = dayfrac * 86400
+               CALL ymds2ju(iyear, imonth, iday, REAL(isecs, wp) , zdayjulini)
+               ! offset from initialization date:
+               zoffset = (dayjul0-zdayjulini)*86400
+               !
+7000           FORMAT('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)
+
+               !! TO BE DONE... Check consistency between calendar from file 
+               !! (available optionally from iom_gettime) and calendar in model 
+               !! when calendar in model available outside of IOIPSL.
+
+               IF(lwp) WRITE(numout,*) 'number of times: ',ntimes_bdy
+               IF(lwp) WRITE(numout,*) 'offset: ',zoffset
+               IF(lwp) WRITE(numout,*) 'totime: ',totime
+               IF(lwp) WRITE(numout,*) 'zstepr: ',zstepr
+
+               ! Check that there are not too many times in the file. 
+               IF( ntimes_bdy > jpbtime ) THEN
+                  WRITE(ctmp1,*) 'Check file: ', clfile(igrd), 'jpbtime= ', jpbtime, ' ntimes_bdy= ', ntimes_bdy
+                  CALL ctl_stop( 'Number of time dumps in files exceed jpbtime parameter', ctmp1 )
+               ENDIF
+
+               ! Check that time array increases:
+        
+               it = 1
+               DO WHILE( zstepr(it+1) > zstepr(it) .AND. it /= ntimes_bdy - 1 )
+                 it = it + 1
+               END DO
+
+               IF( it.NE.ntimes_bdy-1 .AND. ntimes_bdy > 1 ) THEN
+                     WRITE(ctmp1,*) 'Check file: ', clfile(igrd)
+                     CALL ctl_stop( 'Time array in unstructured boundary data files',   &
+                        &           'does not continuously increase.'               , ctmp1 )
+               ENDIF
+               !
+               ! Check that times in file span model run time:
+               IF( zstepr(1) + zoffset > 0 ) THEN
+                     WRITE(ctmp1,*) 'Check file: ', clfile(igrd)
+                     CALL ctl_stop( 'First time dump in bdy file is after model initial time', ctmp1 )
+               END IF
+               IF( zstepr(ntimes_bdy) + zoffset < totime ) THEN
+                     WRITE(ctmp1,*) 'Check file: ', clfile(igrd)
+                     CALL ctl_stop( 'Last time dump in bdy file is before model final time', ctmp1 )
+               END IF
+               !
+               IF    ( igrd == 1 ) THEN
+                 ntimes_bdyt = ntimes_bdy
+                 zoffsett = zoffset
+                 istept(:) = INT( zstepr(:) + zoffset )
+               ELSEIF(igrd == 2 ) THEN
+                 ntimes_bdyu = ntimes_bdy
+                 zoffsetu = zoffset
+                 istepu(:) = INT( zstepr(:) + zoffset )
+               ELSEIF(igrd == 3 ) THEN
+                 ntimes_bdyv = ntimes_bdy
+                 zoffsetv = zoffset
+                 istepv(:) = INT( zstepr(:) + zoffset )
+               ENDIF
+               !
+            END DO                                         ! end loop over T, U & V grid 
+
+            IF (igrd_start == 1 .and. igrd_end == 3) THEN
+               ! Only test differences if we are reading in 3 files
+               ! Verify time consistency between files  
+               IF( ntimes_bdyu /= ntimes_bdyt .OR. ntimes_bdyv /= ntimes_bdyt ) THEN
+                  CALL ctl_stop( 'Bdy data files must have the same number of time dumps',   &
+                  &           'Multiple time frequencies not implemented yet'  )
+               ENDIF
+               ntimes_bdy = ntimes_bdyt
+               !
+               IF( zoffsetu /= zoffsett .OR. zoffsetv /= zoffsett ) THEN
+                  CALL ctl_stop( 'Bdy data files must have the same time origin',   &
+                  &           'Multiple time frequencies not implemented yet' )
+               ENDIF
+               zoffset = zoffsett
+            ENDIF
+
+            IF( igrd_start == 1 ) THEN
+               istep(:) = istept(:)
+            ELSE
+               istep(:) = istepu(:)
+            ENDIF
+
+            ! Check number of time dumps:              
+            IF( ntimes_bdy == 1 .AND. .NOT. ln_bdy_clim ) THEN
+              CALL ctl_stop( 'There is only one time dump in data files',   &
+                 &           'Choose ln_bdy_clim=.true. in namelist for constant bdy forcing.' )
+            ENDIF
+
+            IF( ln_bdy_clim ) THEN
+              IF( ntimes_bdy /= 1 .AND. ntimes_bdy /= 12 ) THEN
+                 CALL ctl_stop( 'For climatological boundary forcing (ln_bdy_clim=.true.),',   &
+                    &           'bdy data files must contain 1 or 12 time dumps.' )
+              ELSEIF( ntimes_bdy ==  1 ) THEN
+                IF(lwp) WRITE(numout,*)
+                IF(lwp) WRITE(numout,*) 'We assume constant boundary forcing from bdy data files'
+              ELSEIF( ntimes_bdy == 12 ) THEN
+                IF(lwp) WRITE(numout,*)
+                IF(lwp) WRITE(numout,*) 'We assume monthly (and cyclic) boundary forcing from bdy data files'
+              ENDIF
+            ENDIF
+
+            ! Find index of first record to read (before first model time). 
+            it = 1
+            DO WHILE( istep(it+1) <= 0 .AND. it <= ntimes_bdy - 1 )
+              it = it + 1
+            END DO
+            nbdy_b = it
+            !
+            WRITE(numout,*) 'Time offset is ',zoffset
+            WRITE(numout,*) 'First record to read is ',nbdy_b
+
+         ENDIF ! endif (nbdy_dta == 1)
+
+
+         ! 1.2  Read first record in file if necessary (ie if nbdy_dta == 1)
+         ! *****************************************************************
+
+         IF( nbdy_dta == 0) THEN      ! boundary data arrays are filled with initial conditions
+            !
+            IF (ln_bdy_tra_frs) THEN
+              igrd = 1            ! T-points data 
+              DO ib = 1, nblen(igrd)
+                ii = nbi(ib,igrd)
+                ij = nbj(ib,igrd)
+                DO ik = 1, jpkm1
+                  tbdy(ib,ik) = tn(ii, ij, ik)
+                  sbdy(ib,ik) = sn(ii, ij, ik)
+                ENDDO
+              END DO
+            ENDIF
+
+            IF(ln_bdy_dyn_frs) THEN
+              igrd = 2            ! U-points data 
+              DO ib = 1, nblen(igrd)
+                ii = nbi(ib,igrd)
+                ij = nbj(ib,igrd)
+                DO ik = 1, jpkm1
+                  ubdy(ib,ik) = un(ii, ij, ik)
+                ENDDO
+              END DO
+
+              igrd = 3            ! V-points data 
+              DO ib = 1, nblen(igrd)            
+                ii = nbi(ib,igrd)
+                ij = nbj(ib,igrd)
+                DO ik = 1, jpkm1
+                  vbdy(ib,ik) = vn(ii, ij, ik)
+                ENDDO
+              END DO
+            ENDIF
+            !
+         ELSEIF( nbdy_dta == 1 ) THEN    ! Set first record in the climatological case:   
+            !
+            IF( ln_bdy_clim .AND. ntimes_bdy == 1 ) THEN
+               nbdy_a = 1
+            ELSEIF( ln_bdy_clim .AND. ntimes_bdy == iman ) THEN
+               nbdy_b = 0
+               nbdy_a = imois
+            ELSE
+               nbdy_a = nbdy_b
+            ENDIF
+   
+            ! Read first record:
+            ipj  = 1
+            ipk  = jpk
+            igrd = 1
+            ipi  = nblendta(igrd)
+
+            IF(ln_bdy_tra_frs) THEN
+               igrd = 1                                           ! Temperature
+               IF( nblendta(igrd) <=  0 ) THEN 
+                  idvar = iom_varid( numbdyt, 'votemper' )
+                  nblendta(igrd) = iom_file(numbdyt)%dimsz(1,idvar)
+               ENDIF
+               WRITE(numout,*) 'Dim size for votemper is ', nblendta(igrd)
+               ipi = nblendta(igrd)
+               CALL iom_get ( numbdyt, jpdom_unknown, 'votemper', zdta(1:ipi,1:ipj,1:ipk), nbdy_a )
+
+               DO ib = 1, nblen(igrd)
+                  DO ik = 1, jpkm1
+                     tbdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                  END DO
+               END DO
+               !
+               igrd = 1                                           ! salinity
+               IF( nblendta(igrd) .le. 0 ) THEN 
+                  idvar = iom_varid( numbdyt, 'vosaline' )
+                  nblendta(igrd) = iom_file(numbdyt)%dimsz(1,idvar)
+               ENDIF
+               WRITE(numout,*) 'Dim size for vosaline is ', nblendta(igrd)
+               ipi = nblendta(igrd)
+               CALL iom_get ( numbdyt, jpdom_unknown, 'vosaline', zdta(1:ipi,1:ipj,1:ipk), nbdy_a )
+
+               DO ib = 1, nblen(igrd)
+                  DO ik = 1, jpkm1
+                     sbdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                  END DO
+               END DO
+            ENDIF  ! ln_bdy_tra_frs
+ 
+            IF(ln_bdy_dyn_frs) THEN
+
+               igrd = 2                                           ! u-velocity
+               IF ( nblendta(igrd) .le. 0 ) THEN 
+                 idvar = iom_varid( numbdyu,'vozocrtx' )
+                 nblendta(igrd) = iom_file(numbdyu)%dimsz(1,idvar)
+               ENDIF
+               WRITE(numout,*) 'Dim size for vozocrtx is ', nblendta(igrd)
+               ipi = nblendta(igrd)
+               CALL iom_get ( numbdyu, jpdom_unknown,'vozocrtx',zdta(1:ipi,1:ipj,1:ipk),nbdy_a )
+               DO ib = 1, nblen(igrd)
+                  DO ik = 1, jpkm1
+                     ubdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                  END DO
+               END DO
+               !
+               igrd = 3                                           ! v-velocity
+               IF ( nblendta(igrd) .le. 0 ) THEN 
+                 idvar = iom_varid( numbdyv,'vomecrty' )
+                 nblendta(igrd) = iom_file(numbdyv)%dimsz(1,idvar)
+               ENDIF
+               WRITE(numout,*) 'Dim size for vomecrty is ', nblendta(igrd)
+               ipi = nblendta(igrd)
+               CALL iom_get ( numbdyv, jpdom_unknown,'vomecrty',zdta(1:ipi,1:ipj,1:ipk),nbdy_a )
+               DO ib = 1, nblen(igrd)
+                  DO ik = 1, jpkm1
+                     vbdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                  END DO
+               END DO
+            ENDIF ! ln_bdy_dyn_frs
+
+
+            IF ((.NOT.ln_bdy_clim) .AND. (istep(1) > 0)) THEN
+               ! First data time is after start of run
+               ! Put first value in both time levels
+               nbdy_b = nbdy_a
+               IF(ln_bdy_tra_frs) THEN
+                 tbdydta(:,:,1) = tbdydta(:,:,2)
+                 sbdydta(:,:,1) = sbdydta(:,:,2)
+               ENDIF
+               IF(ln_bdy_dyn_frs) THEN
+                 ubdydta(:,:,1) = ubdydta(:,:,2)
+                 vbdydta(:,:,1) = vbdydta(:,:,2)
+               ENDIF
+            END IF
+
+         END IF ! nbdy_dta == 0/1
+ 
+         ! In the case of constant boundary forcing fill bdy arrays once for all
+         IF ((ln_bdy_clim).AND.(ntimes_bdy==1)) THEN
+            IF(ln_bdy_tra_frs) THEN
+              tbdy  (:,:) = tbdydta  (:,:,2)
+              sbdy  (:,:) = sbdydta  (:,:,2)
+            ENDIF
+            IF(ln_bdy_dyn_frs) THEN
+              ubdy  (:,:) = ubdydta  (:,:,2)
+              vbdy  (:,:) = vbdydta  (:,:,2)
+            ENDIF
+
+            IF(ln_bdy_tra_frs .or. ln_bdy_ice_frs) CALL iom_close( numbdyt )
+            IF(ln_bdy_dyn_frs) CALL iom_close( numbdyu )
+            IF(ln_bdy_dyn_frs) CALL iom_close( numbdyv )
+         END IF
+
+      ENDIF                                            ! End if nit000
+
+
+      !                                                !---------------------!
+      !                                                !  at each time step  !
+      !                                                !---------------------!
+
+      IF( nbdy_dta == 1 .AND. ntimes_bdy > 1 ) THEN 
+         !
+         ! Read one more record if necessary
+         !**********************************
+
+        IF( ln_bdy_clim .AND. imois /= nbdy_b ) THEN      ! remember that nbdy_b=0 for kt=nit000
+           nbdy_b = imois
+           nbdy_a = imois + 1
+           nbdy_b = MOD( nbdy_b, iman )   ;   IF( nbdy_b == 0 ) nbdy_b = iman
+           nbdy_a = MOD( nbdy_a, iman )   ;   IF( nbdy_a == 0 ) nbdy_a = iman
+           lect=.true.
+        ELSEIF( .NOT.ln_bdy_clim .AND. itimer >= istep(nbdy_a) ) THEN
+
+           IF ( nbdy_a < ntimes_bdy ) THEN
+              nbdy_b = nbdy_a
+              nbdy_a = nbdy_a + 1
+              lect  =.true.
+           ELSE
+              ! We have reached the end of the file
+              ! put the last data time into both time levels
+              nbdy_b = nbdy_a
+              IF(ln_bdy_tra_frs) THEN
+                tbdydta(:,:,1) =  tbdydta(:,:,2)
+                sbdydta(:,:,1) =  sbdydta(:,:,2)
+              ENDIF
+              IF(ln_bdy_dyn_frs) THEN
+                ubdydta(:,:,1) =  ubdydta(:,:,2)
+                vbdydta(:,:,1) =  vbdydta(:,:,2)
+              ENDIF
+            END IF ! nbdy_a < ntimes_bdy
+
+        END IF
+         
+        IF( lect ) THEN
+           ! Swap arrays
+           IF(ln_bdy_tra_frs) THEN
+             tbdydta(:,:,1) =  tbdydta(:,:,2)
+             sbdydta(:,:,1) =  sbdydta(:,:,2)
+           ENDIF
+           IF(ln_bdy_dyn_frs) THEN
+             ubdydta(:,:,1) =  ubdydta(:,:,2)
+             vbdydta(:,:,1) =  vbdydta(:,:,2)
+           ENDIF
+ 
+           ! read another set
+           ipj  = 1
+           ipk  = jpk
+
+           IF(ln_bdy_tra_frs) THEN
+              ! 
+              igrd = 1                                   ! temperature
+              ipi  = nblendta(igrd)
+              CALL iom_get ( numbdyt, jpdom_unknown, 'votemper', zdta(1:ipi,1:ipj,1:ipk), nbdy_a )
+              DO ib = 1, nblen(igrd)
+                 DO ik = 1, jpkm1
+                    tbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik)
+                 END DO
+              END DO
+              !
+              igrd = 1                                   ! salinity
+              ipi  = nblendta(igrd)
+              CALL iom_get ( numbdyt, jpdom_unknown, 'vosaline', zdta(1:ipi,1:ipj,1:ipk), nbdy_a )
+              DO ib = 1, nblen(igrd)
+                 DO ik = 1, jpkm1
+                    sbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik)
+                 END DO
+              END DO
+           ENDIF ! ln_bdy_tra_frs
+
+           IF(ln_bdy_dyn_frs) THEN
+              !
+              igrd = 2                                   ! u-velocity
+              ipi  = nblendta(igrd)
+              CALL iom_get ( numbdyu, jpdom_unknown,'vozocrtx',zdta(1:ipi,1:ipj,1:ipk),nbdy_a )
+              DO ib = 1, nblen(igrd)
+                DO ik = 1, jpkm1
+                  ubdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                END DO
+              END DO
+              !
+              igrd = 3                                   ! v-velocity
+              ipi  = nblendta(igrd)
+              CALL iom_get ( numbdyv, jpdom_unknown,'vomecrty',zdta(1:ipi,1:ipj,1:ipk),nbdy_a )
+              DO ib = 1, nblen(igrd)
+                 DO ik = 1, jpkm1
+                    vbdydta(ib,ik,2) =  zdta(nbmap(ib,igrd),1,ik)
+                 END DO
+              END DO
+           ENDIF ! ln_bdy_dyn_frs
+
+           !
+           IF(lwp) WRITE(numout,*) 'bdy_dta : first record file used nbdy_b ',nbdy_b
+           IF(lwp) WRITE(numout,*) '~~~~~~~~  last  record file used nbdy_a ',nbdy_a
+           IF (.NOT.ln_bdy_clim) THEN
+              IF(lwp) WRITE(numout,*) 'first  record time (s): ', istep(nbdy_b)
+              IF(lwp) WRITE(numout,*) 'model time (s)        : ', itimer
+              IF(lwp) WRITE(numout,*) 'second record time (s): ', istep(nbdy_a)
+           ENDIF
+           !
+       ENDIF ! end lect=.true.
+
+
+       ! Interpolate linearly
+       ! ********************
+       ! 
+       IF( ln_bdy_clim ) THEN   ;   zxy = REAL( nday                  , wp ) / REAL( nmonth_len(nbdy_b), wp ) + 0.5 - i15
+       ELSE                     ;   zxy = REAL( istep(nbdy_b) - itimer, wp ) / REAL( istep(nbdy_b) - istep(nbdy_a), wp )
+       END IF
+
+          IF(ln_bdy_tra_frs) THEN
+             igrd = 1                                   ! temperature & salinity
+             DO ib = 1, nblen(igrd)
+               DO ik = 1, jpkm1
+                 tbdy(ib,ik) = zxy * tbdydta(ib,ik,2) + (1.-zxy) * tbdydta(ib,ik,1)
+                 sbdy(ib,ik) = zxy * sbdydta(ib,ik,2) + (1.-zxy) * sbdydta(ib,ik,1)
+               END DO
+             END DO
+          ENDIF
+
+          IF(ln_bdy_dyn_frs) THEN
+             igrd = 2                                   ! u-velocity
+             DO ib = 1, nblen(igrd)
+               DO ik = 1, jpkm1
+                 ubdy(ib,ik) = zxy * ubdydta(ib,ik,2) + (1.-zxy) * ubdydta(ib,ik,1)   
+               END DO
+             END DO
+             !
+             igrd = 3                                   ! v-velocity
+             DO ib = 1, nblen(igrd)
+               DO ik = 1, jpkm1
+                 vbdy(ib,ik) = zxy * vbdydta(ib,ik,2) + (1.-zxy) * vbdydta(ib,ik,1)   
+               END DO
+             END DO
+          ENDIF
+
+      END IF                       !end if ((nbdy_dta==1).AND.(ntimes_bdy>1))
+    
+
+      !                                                !---------------------!
+      !                                                !     last call       !
+      !                                                !---------------------!
+      IF( kt == nitend ) THEN
+          IF(ln_bdy_tra_frs .or. ln_bdy_ice_frs) CALL iom_close( numbdyt )              ! Closing of the 3 files
+          IF(ln_bdy_dyn_frs) CALL iom_close( numbdyu )
+          IF(ln_bdy_dyn_frs) CALL iom_close( numbdyv )
+      ENDIF
+      !
+      ENDIF ! ln_bdy_dyn_frs .OR. ln_bdy_tra_frs
+
+   END SUBROUTINE bdy_dta
+
+
+   SUBROUTINE bdy_dta_bt( kt, jit )
+      !!---------------------------------------------------------------------------
+      !!                      ***  SUBROUTINE bdy_dta_bt  ***
+      !!                    
+      !! ** Purpose :   Read unstructured boundary data for Flather condition
+      !!
+      !! ** Method  :  At the first timestep, read in boundary data for two
+      !!               times from the file and time-interpolate. At other 
+      !!               timesteps, check to see if we need another time from 
+      !!               the file. If so read it in. Time interpolate.
+      !!---------------------------------------------------------------------------
+!!gm DOCTOR names :   argument integer :  start with "k"
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
+      INTEGER, INTENT( in ) ::   jit         ! barotropic time step index
+      !                                      ! (for timesplitting option, otherwise zero)
+      !!
+      LOGICAL ::   lect                      ! flag for reading
+      INTEGER ::   it, ib, igrd              ! dummy loop indices
+      INTEGER ::   idvar                     ! netcdf var ID
+      INTEGER ::   iman, i15, imois          ! Time variables for monthly clim forcing
+      INTEGER ::   ntimes_bdyt, ntimes_bdyu, ntimes_bdyv
+      INTEGER ::   itimer, totime
+      INTEGER ::   ipi, ipj, ipk, inum       ! temporary integers (NetCDF read)
+      INTEGER ::   iyear0, imonth0, iday0
+      INTEGER ::   ihours0, iminutes0, isec0
+      INTEGER ::   iyear, imonth, iday, isecs
+      INTEGER, DIMENSION(jpbtime) ::   istept, istepu, istepv   ! time arrays from data files
+      REAL(wp) ::   dayfrac, zxy, zoffsett
+      REAL(wp) ::   zoffsetu, zoffsetv
+      REAL(wp) ::   dayjul0, zdayjulini
+      REAL(wp) ::   zinterval_s, zinterval_e                    ! First and last interval in time axis
+      REAL(wp), DIMENSION(jpbtime)      ::   zstepr             ! REAL time array from data files
+      REAL(wp), DIMENSION(jpbdta,1)     ::   zdta               ! temporary array for data fields
+      CHARACTER(LEN=80), DIMENSION(3)   ::   clfile
+      CHARACTER(LEN=70 )                ::   clunits            ! units attribute of time coordinate
+      !!---------------------------------------------------------------------------
+
+!!gm   add here the same style as in bdy_dta
+!!gm      clearly bdy_dta_bt and bdy_dta  can be combined...   
+!!gm      too many things duplicated in the read of data...   simplification can be done
+
+      ! -------------------- !
+      !    Initialization    !
+      ! -------------------- !
+
+      lect   = .false.           ! If true, read a time record
+
+      ! Some time variables for monthly climatological forcing:
+      ! *******************************************************
+ !!gm  here  use directely daymod variables
+ 
+      iman  = INT( raamo ) ! Number of months in a year
+
+      i15 = INT( 2*REAL( nday, wp ) / ( REAL( nmonth_len(nmonth), wp ) + 0.5 ) )
+      ! i15=0 if the current day is in the first half of the month, else i15=1
+
+      imois = nmonth + i15 - 1            ! imois is the first month record
+      IF( imois == 0 ) imois = iman
+
+      ! Time variable for non-climatological forcing:
+      ! *********************************************
+
+      itimer = ((kt-1)-nit000+1)*rdt                      ! current time in seconds for interpolation 
+      itimer = itimer + jit*rdt/REAL(nn_baro,wp)      ! in non-climatological case
+
+      IF ( ln_bdy_tides ) THEN
+
+         ! -------------------------------------!
+         ! Update BDY fields with tidal forcing !
+         ! -------------------------------------!  
+
+         CALL tide_update( kt, jit ) 
+  
+      ENDIF
+
+      IF ( ln_bdy_dyn_fla ) THEN
+
+         ! -------------------------------------!
+         ! Update BDY fields with model data    !
+         ! -------------------------------------!  
+
+      !                                                !-------------------!
+      IF( kt == nit000 ) THEN                          !  First call only  !
+         !                                             !-------------------!
+         istep_bt(:) = 0
+         nbdy_b_bt    = 0
+         nbdy_a_bt    = 0
+
+         ! Get time information from bdy data file
+         ! ***************************************
+
+        IF(lwp) WRITE(numout,*)
+        IF(lwp) WRITE(numout,*)    'bdy_dta_bt :Initialize unstructured boundary data for barotropic variables.'
+        IF(lwp) WRITE(numout,*)    '~~~~~~~' 
+
+        IF( nbdy_dta == 0 ) THEN
+          IF(lwp) WRITE(numout,*)  'Bdy data are taken from initial conditions'
+
+        ELSEIF (nbdy_dta == 1) THEN
+          IF(lwp) WRITE(numout,*)  'Bdy data are read in netcdf files'
+
+          dayfrac = adatrj  - REAL(itimer,wp)/86400. ! day fraction at time step kt-1
+          dayfrac = dayfrac - INT (dayfrac)          !
+          totime = (nitend-nit000+1)*rdt             ! Total time of the run to verify that all the
+                                                     ! necessary time dumps in file are included
+
+          clfile(1) = filbdy_data_bt_T
+          clfile(2) = filbdy_data_bt_U
+          clfile(3) = filbdy_data_bt_V
+
+          DO igrd = 1,3
+
+            CALL iom_open( clfile(igrd), inum )
+            CALL iom_gettime( inum, zstepr, kntime=ntimes_bdy, cdunits=clunits ) 
+
+            SELECT CASE( igrd )
+               CASE (1) 
+                  numbdyt = inum
+               CASE (2) 
+                  numbdyu = inum
+               CASE (3) 
+                  numbdyv = inum
+            END SELECT
+
+            ! Calculate time offset 
+            READ(clunits,7000) iyear0, imonth0, iday0, ihours0, iminutes0, isec0
+            ! Convert time origin in file to julian days 
+            isec0 = isec0 + ihours0*60.*60. + iminutes0*60.
+            CALL ymds2ju(iyear0, imonth0, iday0, REAL(isec0, wp), dayjul0)
+            ! Compute model initialization time 
+            iyear  = ndastp / 10000
+            imonth = ( ndastp - iyear * 10000 ) / 100
+            iday   = ndastp - iyear * 10000 - imonth * 100
+            isecs  = dayfrac * 86400
+            CALL ymds2ju(iyear, imonth, iday, REAL(isecs, wp) , zdayjulini)
+            ! zoffset from initialization date:
+            zoffset = (dayjul0-zdayjulini)*86400
+            !
+
+7000 FORMAT('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)
+
+            !! TO BE DONE... Check consistency between calendar from file 
+            !! (available optionally from iom_gettime) and calendar in model 
+            !! when calendar in model available outside of IOIPSL.
+
+            ! Check that there are not too many times in the file. 
+            IF (ntimes_bdy_bt > jpbtime) CALL ctl_stop( &
+                 'Number of time dumps in bdy file exceed jpbtime parameter', &
+                 'Check file:' // TRIM(clfile(igrd))  )
+
+            ! Check that time array increases (or interp will fail):
+            DO it = 2, ntimes_bdy
+               IF ( zstepr(it-1) >= zstepr(it) ) THEN
+                  CALL ctl_stop('Time array in unstructured boundary data file', &
+                       'does not continuously increase.',               &
+                       'Check file:' // TRIM(clfile(igrd))  )
+                  EXIT
+               END IF
+            END DO
+
+            IF ( .NOT. ln_bdy_clim ) THEN
+               ! Check that times in file span model run time:
+
+               ! Note: the fields may be time means, so we allow nit000 to be before
+               ! first time in the file, provided that it falls inside the meaning
+               ! period of the first field.  Until we can get the meaning period
+               ! from the file, use the interval between fields as a proxy.
+               ! If nit000 is before the first time, use the value at first time
+               ! instead of extrapolating.  This is done by putting time 1 into
+               ! both time levels.
+               ! The same applies to the last time level: see setting of lect below.
+
+               IF ( ntimes_bdy == 1 ) CALL ctl_stop( &
+                    'There is only one time dump in data files', &
+                    'Set ln_bdy_clim=.true. in namelist for constant bdy forcing.' )
+
+               zinterval_s = zstepr(2) - zstepr(1)
+               zinterval_e = zstepr(ntimes_bdy) - zstepr(ntimes_bdy-1)
+
+               IF ( zstepr(1) - zinterval_s / 2.0 > 0 ) THEN	          
+                  IF(lwp) WRITE(numout,*) 'First bdy time relative to nit000:', zstepr(1)
+                  IF(lwp) WRITE(numout,*) 'Interval between first two times: ', zinterval_s
+                  CALL ctl_stop( 'First data time is after start of run', & 
+                       'by more than half a meaning period', &
+                       'Check file: ' // TRIM(clfile(igrd)) )
+               END IF
+
+               IF ( zstepr(ntimes_bdy) + zinterval_e / 2.0 < totime ) THEN
+                  IF(lwp) WRITE(numout,*) 'Last bdy time relative to nit000:', zstepr(ntimes_bdy)
+                  IF(lwp) WRITE(numout,*) 'Interval between last two times: ', zinterval_e
+                  CALL ctl_stop( 'Last data time is before end of run', & 
+                       'by more than half a meaning period', &
+                       'Check file: ' // TRIM(clfile(igrd))  )
+               END IF
+
+            END IF ! .NOT. ln_bdy_clim
+
+            IF ( igrd .EQ. 1) THEN
+              ntimes_bdyt = ntimes_bdy_bt
+              zoffsett = zoffset
+              istept(:) = INT( zstepr(:) + zoffset )
+            ELSE IF (igrd .EQ. 2) THEN
+              ntimes_bdyu = ntimes_bdy_bt
+              zoffsetu = zoffset
+              istepu(:) = INT( zstepr(:) + zoffset )
+            ELSE IF (igrd .EQ. 3) THEN
+              ntimes_bdyv = ntimes_bdy_bt
+              zoffsetv = zoffset
+              istepv(:) = INT( zstepr(:) + zoffset )
+            ENDIF
+
+          ENDDO
+
+      ! Verify time consistency between files  
+
+          IF ( ntimes_bdyu /= ntimes_bdyt .OR. ntimes_bdyv /= ntimes_bdyt ) THEN
+             CALL ctl_stop( &
+             'Time axis lengths differ between bdy data files', &
+             'Multiple time frequencies not implemented yet' )
+          ELSE
+            ntimes_bdy_bt = ntimes_bdyt
+          ENDIF
+
+          IF (zoffsetu.NE.zoffsett .OR. zoffsetv.NE.zoffsett) THEN
+            CALL ctl_stop( & 
+            'Bdy data files must have the same time origin', &
+            'Multiple time frequencies not implemented yet'  )
+          ENDIF
+          zoffset = zoffsett
+
+      !! Check that times are the same in the three files... HERE.
+          istep_bt(:) = istept(:)
+
+      ! Check number of time dumps:              
+          IF (ln_bdy_clim) THEN
+            SELECT CASE ( ntimes_bdy_bt )
+            CASE( 1 )
+              IF(lwp) WRITE(numout,*)
+              IF(lwp) WRITE(numout,*) 'We assume constant boundary forcing from bdy data files'
+              IF(lwp) WRITE(numout,*)             
+            CASE( 12 )
+              IF(lwp) WRITE(numout,*)
+              IF(lwp) WRITE(numout,*) 'We assume monthly (and cyclic) boundary forcing from bdy data files'
+              IF(lwp) WRITE(numout,*) 
+            CASE DEFAULT
+              CALL ctl_stop( &
+                'For climatological boundary forcing (ln_bdy_clim=.true.),',&
+                'bdy data files must contain 1 or 12 time dumps.' )
+            END SELECT
+          ENDIF
+
+      ! Find index of first record to read (before first model time). 
+
+          it=1
+          DO WHILE ( ((istep_bt(it+1)) <= 0 ).AND.(it.LE.(ntimes_bdy_bt-1)))
+            it=it+1
+          END DO
+          nbdy_b_bt = it
+
+          WRITE(numout,*) 'Time offset is ',zoffset
+          WRITE(numout,*) 'First record to read is ',nbdy_b_bt
+
+        ENDIF ! endif (nbdy_dta == 1)
+
+      ! 1.2  Read first record in file if necessary (ie if nbdy_dta == 1)
+      ! *****************************************************************
+
+        IF ( nbdy_dta == 0) THEN
+          ! boundary data arrays are filled with initial conditions
+          igrd = 2            ! U-points data 
+          DO ib = 1, nblen(igrd)              
+            ubtbdy(ib) = un(nbi(ib,igrd), nbj(ib,igrd), 1)
+          END DO
+
+          igrd = 3            ! V-points data 
+          DO ib = 1, nblen(igrd)              
+            vbtbdy(ib) = vn(nbi(ib,igrd), nbj(ib,igrd), 1)
+          END DO
+
+          igrd = 1            ! T-points data 
+          DO ib = 1, nblen(igrd)              
+            sshbdy(ib) = sshn(nbi(ib,igrd), nbj(ib,igrd))
+          END DO
+
+        ELSEIF (nbdy_dta == 1) THEN
+ 
+        ! Set first record in the climatological case:   
+          IF ((ln_bdy_clim).AND.(ntimes_bdy_bt==1)) THEN
+            nbdy_a_bt = 1
+          ELSEIF ((ln_bdy_clim).AND.(ntimes_bdy_bt==iman)) THEN
+            nbdy_b_bt = 0
+            nbdy_a_bt = imois
+          ELSE
+            nbdy_a_bt = nbdy_b_bt
+          END IF
+ 
+         ! Open Netcdf files:
+
+          CALL iom_open ( filbdy_data_bt_T, numbdyt_bt )
+          CALL iom_open ( filbdy_data_bt_U, numbdyu_bt )
+          CALL iom_open ( filbdy_data_bt_V, numbdyv_bt )
+
+         ! Read first record:
+          ipj=1
+          igrd=1
+          ipi=nblendta(igrd)
+
+          ! ssh
+          igrd=1
+          IF ( nblendta(igrd) .le. 0 ) THEN 
+            idvar = iom_varid( numbdyt_bt,'sossheig' )
+            nblendta(igrd) = iom_file(numbdyt_bt)%dimsz(1,idvar)
+          ENDIF
+          WRITE(numout,*) 'Dim size for sossheig is ',nblendta(igrd)
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyt_bt, jpdom_unknown,'sossheig',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            sshbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+ 
+          ! u-velocity
+          igrd=2
+          IF ( nblendta(igrd) .le. 0 ) THEN 
+            idvar = iom_varid( numbdyu_bt,'vobtcrtx' )
+            nblendta(igrd) = iom_file(numbdyu_bt)%dimsz(1,idvar)
+          ENDIF
+          WRITE(numout,*) 'Dim size for vobtcrtx is ',nblendta(igrd)
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyu_bt, jpdom_unknown,'vobtcrtx',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            ubtbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+
+          ! v-velocity
+          igrd=3
+          IF ( nblendta(igrd) .le. 0 ) THEN 
+            idvar = iom_varid( numbdyv_bt,'vobtcrty' )
+            nblendta(igrd) = iom_file(numbdyv_bt)%dimsz(1,idvar)
+          ENDIF
+          WRITE(numout,*) 'Dim size for vobtcrty is ',nblendta(igrd)
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyv_bt, jpdom_unknown,'vobtcrty',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            vbtbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+
+        END IF
+ 
+        ! In the case of constant boundary forcing fill bdy arrays once for all
+        IF ((ln_bdy_clim).AND.(ntimes_bdy_bt==1)) THEN
+
+          ubtbdy  (:) = ubtbdydta  (:,2)
+          vbtbdy  (:) = vbtbdydta  (:,2)
+          sshbdy  (:) = sshbdydta  (:,2)
+
+          CALL iom_close( numbdyt_bt )
+          CALL iom_close( numbdyu_bt )
+          CALL iom_close( numbdyv_bt )
+
+        END IF
+
+      ENDIF ! End if nit000
+
+      ! -------------------- !
+      ! 2. At each time step !
+      ! -------------------- !
+
+      IF ((nbdy_dta==1).AND.(ntimes_bdy_bt>1)) THEN 
+
+      ! 2.1 Read one more record if necessary
+      !**************************************
+
+        IF ( (ln_bdy_clim).AND.(imois/=nbdy_b_bt) ) THEN ! remember that nbdy_b_bt=0 for kt=nit000
+         nbdy_b_bt = imois
+         nbdy_a_bt = imois+1
+         nbdy_b_bt = MOD( nbdy_b_bt, iman )
+         IF( nbdy_b_bt == 0 ) nbdy_b_bt = iman
+         nbdy_a_bt = MOD( nbdy_a_bt, iman )
+         IF( nbdy_a_bt == 0 ) nbdy_a_bt = iman
+         lect=.true.
+
+        ELSEIF ((.NOT.ln_bdy_clim).AND.(itimer >= istep_bt(nbdy_a_bt))) THEN
+          nbdy_b_bt=nbdy_a_bt
+          nbdy_a_bt=nbdy_a_bt+1
+          lect=.true.
+        END IF
+         
+        IF (lect) THEN
+
+        ! Swap arrays
+          sshbdydta(:,1) =  sshbdydta(:,2)
+          ubtbdydta(:,1) =  ubtbdydta(:,2)
+          vbtbdydta(:,1) =  vbtbdydta(:,2)
+ 
+        ! read another set
+
+          ipj=1
+          ipk=jpk
+          igrd=1
+          ipi=nblendta(igrd)
+
+          
+          ! ssh
+          igrd=1
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyt_bt, jpdom_unknown,'sossheig',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            sshbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+
+          ! u-velocity
+          igrd=2
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyu_bt, jpdom_unknown,'vobtcrtx',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            ubtbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+
+          ! v-velocity
+          igrd=3
+          ipi=nblendta(igrd)
+
+          CALL iom_get ( numbdyv_bt, jpdom_unknown,'vobtcrty',zdta(1:ipi,1:ipj),nbdy_a_bt )
+
+          DO ib=1, nblen(igrd)
+            vbtbdydta(ib,2) =  zdta(nbmap(ib,igrd),1)
+          END DO
+
+
+         IF(lwp) WRITE(numout,*) 'bdy_dta : first record file used nbdy_b_bt ',nbdy_b_bt
+         IF(lwp) WRITE(numout,*) '~~~~~~~~  last  record file used nbdy_a_bt ',nbdy_a_bt
+         IF (.NOT.ln_bdy_clim) THEN
+           IF(lwp) WRITE(numout,*) 'first  record time (s): ', istep_bt(nbdy_b_bt)
+           IF(lwp) WRITE(numout,*) 'model time (s)        : ', itimer
+           IF(lwp) WRITE(numout,*) 'second record time (s): ', istep_bt(nbdy_a_bt)
+         ENDIF
+        END IF ! end lect=.true.
+
+
+      ! 2.2   Interpolate linearly:
+      ! ***************************
+    
+        IF (ln_bdy_clim) THEN
+          zxy = REAL( nday, wp ) / REAL( nmonth_len(nbdy_b_bt), wp ) + 0.5 - i15
+        ELSE          
+          zxy = REAL(istep_bt(nbdy_b_bt)-itimer, wp) / REAL(istep_bt(nbdy_b_bt)-istep_bt(nbdy_a_bt), wp)
+        END IF
+
+          igrd=1
+          DO ib=1, nblen(igrd)
+            sshbdy(ib) = zxy      * sshbdydta(ib,2) + &
+                       (1.-zxy) * sshbdydta(ib,1)   
+          END DO
+
+          igrd=2
+          DO ib=1, nblen(igrd)
+            ubtbdy(ib) = zxy      * ubtbdydta(ib,2) + &
+                         (1.-zxy) * ubtbdydta(ib,1)   
+          END DO
+
+          igrd=3
+          DO ib=1, nblen(igrd)
+            vbtbdy(ib) = zxy      * vbtbdydta(ib,2) + &
+                         (1.-zxy) * vbtbdydta(ib,1)   
+          END DO
+
+
+      END IF !end if ((nbdy_dta==1).AND.(ntimes_bdy_bt>1))
+    
+      ! ------------------- !
+      ! Last call kt=nitend !
+      ! ------------------- !
+
+      ! Closing of the 3 files
+      IF( kt == nitend ) THEN
+          CALL iom_close( numbdyt_bt )
+          CALL iom_close( numbdyu_bt )
+          CALL iom_close( numbdyv_bt )
+      ENDIF
+
+      ENDIF ! ln_bdy_dyn_frs
+
+      END SUBROUTINE bdy_dta_bt
+
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                   NO Unstruct Open Boundary Conditions
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE bdy_dta( kt )              ! Empty routine
+      WRITE(*,*) 'bdy_dta: You should not have seen this print! error?', kt
+   END SUBROUTINE bdy_dta
+   SUBROUTINE bdy_dta_bt( kt, kit )      ! Empty routine
+      WRITE(*,*) 'bdy_dta: You should not have seen this print! error?', kt, kit
+   END SUBROUTINE bdy_dta_bt
+#endif
+
+   !!==============================================================================
+END MODULE bdydta
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydyn.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydyn.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdydyn.F90	(revision 1844)
@@ -0,0 +1,190 @@
+MODULE bdydyn
+   !!======================================================================
+   !!                       ***  MODULE  bdydyn  ***
+   !! Unstructured Open Boundary Cond. :   Flow relaxation scheme on velocities
+   !!======================================================================
+   !! History :  1.0  !  2005-02  (J. Chanut, A. Sellar)  Original code
+   !!             -   !  2007-07  (D. Storkey) Move Flather implementation to separate routine.
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!            3.2  !  2008-04  (R. Benshila) consider velocity instead of transport 
+   !!----------------------------------------------------------------------
+#if defined key_bdy 
+   !!----------------------------------------------------------------------
+   !!   'key_bdy' :                    Unstructured Open Boundary Condition
+   !!----------------------------------------------------------------------
+   !!   bdy_dyn_frs    : relaxation of velocities on unstructured open boundary
+   !!   bdy_dyn_fla    : Flather condition for barotropic solution
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE bdy_oce         ! ocean open boundary conditions
+   USE dynspg_oce      ! for barotropic variables
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE bdytides        ! for tidal harmonic forcing at boundary
+   USE in_out_manager  !
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   bdy_dyn_frs   ! routine called in dynspg_flt (free surface case ONLY)
+# if defined key_dynspg_exp || defined key_dynspg_ts
+   PUBLIC   bdy_dyn_fla   ! routine called in dynspg_flt (free surface case ONLY)
+# endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE bdy_dyn_frs( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  SUBROUTINE bdy_dyn_frs  ***
+      !!
+      !! ** Purpose : - Apply the Flow Relaxation Scheme for dynamic in the  
+      !!                case of unstructured open boundaries.
+      !!
+      !! References :- Engedahl H., 1995: Use of the flow relaxation scheme in 
+      !!               a three-dimensional baroclinic ocean model with realistic
+      !!               topography. Tellus, 365-382.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! Main time step counter
+      !!
+      INTEGER  ::   ib, ik, igrd      ! dummy loop indices
+      INTEGER  ::   ii, ij            ! 2D addresses
+      REAL(wp) ::   zwgt              ! boundary weight
+      !!----------------------------------------------------------------------
+      !
+      IF(ln_bdy_dyn_frs) THEN ! If this is false, then this routine does nothing. 
+
+         IF( kt == nit000 ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'bdy_dyn : Flow Relaxation Scheme on momentum'
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
+         ENDIF
+         !
+         igrd = 2                      ! Relaxation of zonal velocity
+         DO ib = 1, nblen(igrd)
+            DO ik = 1, jpkm1
+               ii = nbi(ib,igrd)
+               ij = nbj(ib,igrd)
+               zwgt = nbw(ib,igrd)
+               ua(ii,ij,ik) = ( ua(ii,ij,ik) * ( 1.- zwgt ) + ubdy(ib,ik) * zwgt ) * umask(ii,ij,ik)
+            END DO
+         END DO
+         !
+         igrd = 3                      ! Relaxation of meridional velocity
+         DO ib = 1, nblen(igrd)
+            DO ik = 1, jpkm1
+               ii = nbi(ib,igrd)
+               ij = nbj(ib,igrd)
+               zwgt = nbw(ib,igrd)
+               va(ii,ij,ik) = ( va(ii,ij,ik) * ( 1.- zwgt ) + vbdy(ib,ik) * zwgt ) * vmask(ii,ij,ik)
+            END DO
+         END DO 
+         !
+         CALL lbc_lnk( ua, 'U', -1. )   ! Boundary points should be updated
+         CALL lbc_lnk( va, 'V', -1. )   !
+         !
+      ENDIF ! ln_bdy_dyn_frs
+
+   END SUBROUTINE bdy_dyn_frs
+
+
+#if defined key_dynspg_exp || defined key_dynspg_ts
+!! Option to use Flather with dynspg_flt not coded yet...
+   SUBROUTINE bdy_dyn_fla( pssh )
+      !!----------------------------------------------------------------------
+      !!                 ***  SUBROUTINE bdy_dyn_fla  ***
+      !!             
+      !!              - Apply Flather boundary conditions on normal barotropic velocities 
+      !!                (ln_bdy_dyn_fla=.true. or ln_bdy_tides=.true.)
+      !!
+      !! ** WARNINGS about FLATHER implementation:
+      !!1. According to Palma and Matano, 1998 "after ssh" is used. 
+      !!   In ROMS and POM implementations, it is "now ssh". In the current 
+      !!   implementation (tested only in the EEL-R5 conf.), both cases were unstable. 
+      !!   So I use "before ssh" in the following.
+      !!
+      !!2. We assume that the normal ssh gradient at the bdy is zero. As a matter of 
+      !!   fact, the model ssh just inside the dynamical boundary is used (the outside  
+      !!   ssh in the code is not updated).
+      !!
+      !! References:  Flather, R. A., 1976: A tidal model of the northwest European
+      !!              continental shelf. Mem. Soc. R. Sci. Liege, Ser. 6,10, 141-164.     
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pssh
+
+      INTEGER  ::   ib, igrd                         ! dummy loop indices
+      INTEGER  ::   ii, ij, iim1, iip1, ijm1, ijp1   ! 2D addresses
+      REAL(wp) ::   zcorr                            ! Flather correction
+      REAL(wp) ::   zforc                            ! temporary scalar
+      !!----------------------------------------------------------------------
+
+      ! ---------------------------------!
+      ! Flather boundary conditions     :!
+      ! ---------------------------------! 
+     
+      IF(ln_bdy_dyn_fla .OR. ln_bdy_tides) THEN ! If these are both false, then this routine does nothing. 
+
+         ! Fill temporary array with ssh data (here spgu):
+         igrd = 1
+         spgu(:,:) = 0.0
+         DO ib = 1, nblenrim(igrd)
+            ii = nbi(ib,igrd)
+            ij = nbj(ib,igrd)
+            IF( ln_bdy_dyn_fla ) spgu(ii, ij) = sshbdy(ib)
+            IF( ln_bdy_tides )   spgu(ii, ij) = spgu(ii, ij) + sshtide(ib)
+         END DO
+         !
+         igrd = 2      ! Flather bc on u-velocity; 
+         !             ! remember that flagu=-1 if normal velocity direction is outward
+         !             ! I think we should rather use after ssh ?
+         DO ib = 1, nblenrim(igrd)
+            ii  = nbi(ib,igrd)
+            ij  = nbj(ib,igrd) 
+            iim1 = ii + MAX( 0, INT( flagu(ib) ) )   ! T pts i-indice inside the boundary
+            iip1 = ii - MIN( 0, INT( flagu(ib) ) )   ! T pts i-indice outside the boundary 
+            !
+            zcorr = - flagu(ib) * SQRT( grav * hur_e(ii, ij) ) * ( pssh(iim1, ij) - spgu(iip1,ij) )
+            zforc = ubtbdy(ib) + utide(ib)
+            ua_e(ii,ij) = zforc + zcorr * umask(ii,ij,1) 
+         END DO
+         !
+         igrd = 3      ! Flather bc on v-velocity
+         !             ! remember that flagv=-1 if normal velocity direction is outward
+         DO ib = 1, nblenrim(igrd)
+            ii  = nbi(ib,igrd)
+            ij  = nbj(ib,igrd) 
+            ijm1 = ij + MAX( 0, INT( flagv(ib) ) )   ! T pts j-indice inside the boundary
+            ijp1 = ij - MIN( 0, INT( flagv(ib) ) )   ! T pts j-indice outside the boundary 
+            !
+            zcorr = - flagv(ib) * SQRT( grav * hvr_e(ii, ij) ) * ( pssh(ii, ijm1) - spgu(ii,ijp1) )
+            zforc = vbtbdy(ib) + vtide(ib)
+            va_e(ii,ij) = zforc + zcorr * vmask(ii,ij,1)
+         END DO
+         !
+      ENDIF ! ln_bdy_dyn_fla .or. ln_bdy_tides
+      !
+   END SUBROUTINE bdy_dyn_fla
+#endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                   NO Unstruct Open Boundary Conditions
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE bdy_dyn_frs( kt )      ! Empty routine
+      WRITE(*,*) 'bdy_dyn_frs: You should not have seen this print! error?', kt
+   END SUBROUTINE bdy_dyn_frs
+   SUBROUTINE bdy_dyn_fla( pssh )    ! Empty routine
+      REAL :: pssh(:,:)
+      WRITE(*,*) 'bdy_dyn_fla: You should not have seen this print! error?', pssh(1,1)
+   END SUBROUTINE bdy_dyn_fla
+#endif
+
+   !!======================================================================
+END MODULE bdydyn
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 1844)
@@ -0,0 +1,487 @@
+MODULE bdyini
+   !!======================================================================
+   !!                       ***  MODULE  bdyini  ***
+   !! Unstructured open boundaries : initialisation
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!             -   !  2007-01  (D. Storkey) Update to use IOM module
+   !!             -   !  2007-01  (D. Storkey) Tidal forcing
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if defined key_bdy
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'                     Unstructured Open Boundary Conditions
+   !!----------------------------------------------------------------------
+   !!   bdy_init       : Initialization of unstructured open boundaries
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain
+   USE bdy_oce         ! unstructured open boundary conditions
+   USE bdytides        ! tides at open boundaries initialization (tide_init routine)
+   USE in_out_manager  ! I/O units
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! for mpp_sum  
+   USE iom             ! I/O
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   bdy_init   ! routine called by opa.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE bdy_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_init  ***
+      !!         
+      !! ** Purpose :   Initialization of the dynamics and tracer fields with 
+      !!      unstructured open boundaries.
+      !!
+      !! ** Method  :  Read initialization arrays (mask, indices) to identify 
+      !!               an unstructured open boundary
+      !!
+      !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
+      !!
+      !!----------------------------------------------------------------------      
+      INTEGER ::   ii, ij, ik, igrd, ib, ir   ! dummy loop indices
+      INTEGER ::   icount, icountr
+      INTEGER ::   ib_len, ibr_max
+      INTEGER ::   iw, ie, is, in 
+      INTEGER ::   inum                 ! temporary logical unit
+      INTEGER ::   id_dummy             ! temporary integers
+      INTEGER ::   igrd_start, igrd_end ! start and end of loops on igrd
+      INTEGER, DIMENSION (2)             ::   kdimsz
+      INTEGER, DIMENSION(jpbdta, jpbgrd) ::   nbidta, nbjdta   ! Index arrays: i and j indices of bdy dta
+      INTEGER, DIMENSION(jpbdta, jpbgrd) ::   nbrdta           ! Discrete distance from rim points
+      REAL(wp) :: zefl, zwfl, znfl, zsfl                       ! temporary scalars
+      REAL(wp) , DIMENSION(jpidta,jpjdta) ::   zmask           ! global domain mask
+      REAL(wp) , DIMENSION(jpbdta,1)      ::   zdta            ! temporary array 
+      CHARACTER(LEN=80),DIMENSION(3)      ::   clfile
+      !!
+      NAMELIST/nambdy/filbdy_mask, filbdy_data_T, filbdy_data_U, filbdy_data_V,          &
+         &            ln_bdy_tides, ln_bdy_clim, ln_bdy_vol, ln_bdy_mask,                &
+         &            ln_bdy_dyn_fla, ln_bdy_dyn_frs, ln_bdy_tra_frs,                    &
+         &            nbdy_dta   , nb_rimwidth  , volbdy
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'bdy_init : initialization of unstructured open boundaries'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+      !
+      IF( jperio /= 0 ) CALL ctl_stop( 'Cyclic or symmetric,',   &
+           ' and unstructured open boundary condition are not compatible' )
+
+#if defined key_obc
+      CALL ctl_stop( 'Straight open boundaries,',   &
+           ' and unstructured open boundaries are not compatible' )
+#endif
+
+      ! Read namelist parameters
+      ! ---------------------------
+      REWIND( numnam )
+      READ  ( numnam, nambdy )
+
+      ! control prints
+      IF(lwp) WRITE(numout,*) '         nambdy'
+
+      ! Check nbdy_dta value
+      IF(lwp) WRITE(numout,*) 'nbdy_dta =', nbdy_dta      
+      IF(lwp) WRITE(numout,*) ' '
+      SELECT CASE( nbdy_dta )
+      CASE( 0 )
+        IF(lwp) WRITE(numout,*) '         initial state used for bdy data'        
+      CASE( 1 )
+        IF(lwp) WRITE(numout,*) '         boundary data taken from file'
+      CASE DEFAULT
+        CALL ctl_stop( 'nbdy_dta must be 0 or 1' )
+      END SELECT
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) 'Boundary rim width for the FRS nb_rimwidth = ', nb_rimwidth
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) '         volbdy = ', volbdy
+
+      IF (ln_bdy_vol) THEN
+        SELECT CASE ( volbdy ) ! Check volbdy value
+        CASE( 1 )
+          IF(lwp) WRITE(numout,*) '         The total volume will be constant'
+        CASE( 0 )
+          IF(lwp) WRITE(numout,*) '         The total volume will vary according'
+          IF(lwp) WRITE(numout,*) '         to the surface E-P flux'
+        CASE DEFAULT
+          CALL ctl_stop( 'volbdy must be 0 or 1' )
+        END SELECT
+      ELSE
+        IF(lwp) WRITE(numout,*) 'No volume correction with unstructured open boundaries'
+        IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      IF (ln_bdy_tides) THEN
+        IF(lwp) WRITE(numout,*) ' '
+        IF(lwp) WRITE(numout,*) 'Tidal harmonic forcing at unstructured open boundaries'
+        IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      IF (ln_bdy_dyn_fla) THEN
+        IF(lwp) WRITE(numout,*) ' '
+        IF(lwp) WRITE(numout,*) 'Flather condition on U, V at unstructured open boundaries'
+        IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      IF (ln_bdy_dyn_frs) THEN
+        IF(lwp) WRITE(numout,*) ' '
+        IF(lwp) WRITE(numout,*) 'FRS condition on U and V at unstructured open boundaries'
+        IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      IF (ln_bdy_tra_frs) THEN
+        IF(lwp) WRITE(numout,*) ' '
+        IF(lwp) WRITE(numout,*) 'FRS condition on T & S fields at unstructured open boundaries'
+        IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      ! Read tides namelist 
+      ! ------------------------
+      IF( ln_bdy_tides )   CALL tide_init
+
+      ! Read arrays defining unstructured open boundaries
+      ! -------------------------------------------------
+
+      ! Read global 2D mask at T-points: bdytmask
+      ! *****************************************
+      ! bdytmask = 1  on the computational domain AND on open boundaries
+      !          = 0  elsewhere   
+ 
+      IF( cp_cfg == "eel" .AND. jp_cfg == 5 ) THEN
+         zmask(         :                ,:) = 0.e0
+         zmask(jpizoom+1:jpizoom+jpiglo-2,:) = 1.e0          
+      ELSE IF ( ln_bdy_mask ) THEN
+         CALL iom_open( filbdy_mask, inum )
+         CALL iom_get ( inum, jpdom_data, 'bdy_msk', zmask(:,:) )
+         CALL iom_close( inum )
+      ELSE
+         zmask(:,:) = 1.e0
+      ENDIF
+
+      ! Save mask over local domain      
+      DO ij = 1, nlcj
+         DO ii = 1, nlci
+            bdytmask(ii,ij) = zmask( mig(ii), mjg(ij) )
+         END DO
+      END DO
+
+      ! Derive mask on U and V grid from mask on T grid
+      bdyumask(:,:) = 0.e0
+      bdyvmask(:,:) = 0.e0
+      DO ij=1, jpjm1
+         DO ii=1, jpim1
+            bdyumask(ii,ij)=bdytmask(ii,ij)*bdytmask(ii+1, ij )
+            bdyvmask(ii,ij)=bdytmask(ii,ij)*bdytmask(ii  ,ij+1)  
+         END DO
+      END DO
+
+      ! Lateral boundary conditions
+      CALL lbc_lnk( bdyumask(:,:), 'U', 1. )
+      CALL lbc_lnk( bdyvmask(:,:), 'V', 1. )
+
+      ! Read discrete distance and mapping indices
+      ! ******************************************
+      nbidta(:,:) = 0.e0
+      nbjdta(:,:) = 0.e0
+      nbrdta(:,:) = 0.e0
+
+      IF( cp_cfg == "eel" .AND. jp_cfg == 5 ) THEN
+         icount = 0
+         ! Define west boundary (from ii=2 to ii=1+nb_rimwidth):
+         DO ir = 1, nb_rimwidth         
+            DO ij = 3, jpjglo-2
+               icount=icount+1
+               nbidta(icount,:) = ir + 1 + (jpizoom-1)
+               nbjdta(icount,:) = ij + (jpjzoom-1) 
+               nbrdta(icount,:) = ir
+            END DO
+         END DO
+
+         ! Define east boundary (from ii=jpiglo-1 to ii=jpiglo-nb_rimwidth):
+         DO ir=1,nb_rimwidth         
+            DO ij=3,jpjglo-2
+               icount=icount+1
+               nbidta(icount,:) = jpiglo-ir + (jpizoom-1)
+               nbidta(icount,2) = jpiglo-ir-1 + (jpizoom-1) ! special case for u points
+               nbjdta(icount,:) = ij + (jpjzoom-1)
+               nbrdta(icount,:) = ir
+            END DO
+         END DO
+            
+      ELSE            ! Read indices and distances in unstructured boundary data files 
+
+         IF( ln_bdy_tides ) THEN 
+            ! Read tides input files for preference in case there are
+            ! no bdydata files. 
+            clfile(1) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_T.nc'
+            clfile(2) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_U.nc'
+            clfile(3) = TRIM(filtide)//TRIM(tide_cpt(1))//'_grid_V.nc'
+         ELSE
+            clfile(1) = filbdy_data_T
+            clfile(2) = filbdy_data_U
+            clfile(3) = filbdy_data_V
+         ENDIF          
+
+         ! how many files are we to read in?
+         igrd_start = 1
+         igrd_end   = 3
+         IF(.NOT. ln_bdy_tides ) THEN
+            IF(.NOT. (ln_bdy_dyn_fla) .AND..NOT. (ln_bdy_tra_frs)) THEN
+               ! No T-grid file.
+               igrd_start = 2
+            ELSEIF ( .NOT. ln_bdy_dyn_frs .AND..NOT. ln_bdy_dyn_fla ) THEN
+               ! No U-grid or V-grid file.
+               igrd_end   = 1         
+            ENDIF
+         ENDIF
+
+         DO igrd = igrd_start, igrd_end
+            CALL iom_open( clfile(igrd), inum )
+            id_dummy = iom_varid( inum, 'nbidta', kdimsz=kdimsz )  
+            WRITE(numout,*) 'kdimsz : ',kdimsz
+            ib_len = kdimsz(1)
+            IF( ib_len > jpbdta) CALL ctl_stop(          &
+                'Boundary data array in file too long.', &
+                'File :', TRIM(clfile(igrd)),            &
+                'increase parameter jpbdta.' )
+
+            CALL iom_get( inum, jpdom_unknown, 'nbidta', zdta(1:ib_len,:) )
+            DO ii = 1,ib_len
+               nbidta(ii,igrd) = INT( zdta(ii,1) )
+            END DO
+            CALL iom_get( inum, jpdom_unknown, 'nbjdta', zdta(1:ib_len,:) )
+            DO ii = 1,ib_len
+              nbjdta(ii,igrd) = INT( zdta(ii,1) )
+            END DO
+            CALL iom_get ( inum, jpdom_unknown, 'nbrdta', zdta(1:ib_len,:) )
+            DO ii = 1,ib_len
+              nbrdta(ii,igrd) = INT( zdta(ii,1) )
+            END DO
+            CALL iom_close( inum )
+
+            ! Check that rimwidth in file is big enough:
+            ibr_max = MAXVAL( nbrdta(:,igrd) )
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' Maximum rimwidth in file is ', ibr_max
+            IF(lwp) WRITE(numout,*) ' nb_rimwidth from namelist is ', nb_rimwidth
+            IF (ibr_max < nb_rimwidth) CALL ctl_stop( &
+                'nb_rimwidth is larger than maximum rimwidth in file' )
+            !
+         END DO
+         !
+      ENDIF 
+
+      ! Dispatch mapping indices and discrete distances on each processor
+      ! *****************************************************************
+     
+      iw = mig(1) + 1            ! if monotasking and no zoom, iw=2
+      ie = mig(1) + nlci-1 - 1   ! if monotasking and no zoom, ie=jpim1
+      is = mjg(1) + 1            ! if monotasking and no zoom, is=2
+      in = mjg(1) + nlcj-1 - 1   ! if monotasking and no zoom, in=jpjm1
+
+      DO igrd = igrd_start, igrd_end
+        icount  = 0
+        icountr = 0
+        nblen(igrd) = 0
+        nblenrim(igrd) = 0
+        nblendta(igrd) = 0
+        DO ir=1, nb_rimwidth
+          DO ib = 1, jpbdta
+          ! check if point is in local domain and equals ir
+            IF(  nbidta(ib,igrd) >= iw .AND. nbidta(ib,igrd) <= ie .AND.   &
+               & nbjdta(ib,igrd) >= is .AND. nbjdta(ib,igrd) <= in .AND.   &
+               & nbrdta(ib,igrd) == ir  ) THEN
+               !
+               icount = icount  + 1
+               !
+               IF( ir == 1 )   icountr = icountr+1
+                  IF (icount > jpbdim) THEN
+                     IF(lwp) WRITE(numout,*) 'bdy_ini: jpbdim too small'
+                     nstop = nstop + 1
+                  ELSE
+                     nbi(icount, igrd)  = nbidta(ib,igrd)- mig(1)+1
+                     nbj(icount, igrd)  = nbjdta(ib,igrd)- mjg(1)+1
+                     nbr(icount, igrd)  = nbrdta(ib,igrd)
+                     nbmap(icount,igrd) = ib
+                  ENDIF            
+               ENDIF
+            END DO
+         END DO
+         nblenrim(igrd) = icountr !: length of rim boundary data on each proc
+         nblen   (igrd) = icount  !: length of boundary data on each proc        
+      END DO 
+
+      ! Compute rim weights
+      ! -------------------
+      DO igrd = igrd_start, igrd_end
+         DO ib = 1, nblen(igrd)
+            ! tanh formulation
+            nbw(ib,igrd) = 1.- TANH( FLOAT( nbr(ib,igrd) - 1 ) *0.5 )
+            ! quadratic
+!           nbw(ib,igrd) = (FLOAT(nb_rimwidth+1-nbr(ib,igrd))/FLOAT(nb_rimwidth))**2
+            ! linear
+!           nbw(ib,igrd) =  FLOAT(nb_rimwidth+1-nbr(ib,igrd))/FLOAT(nb_rimwidth)
+         END DO
+      END DO 
+   
+      ! Mask corrections
+      ! ----------------
+      DO ik = 1, jpkm1
+         DO ij = 1, jpj
+            DO ii = 1, jpi
+               tmask(ii,ij,ik) = tmask(ii,ij,ik) * bdytmask(ii,ij)
+               umask(ii,ij,ik) = umask(ii,ij,ik) * bdyumask(ii,ij)
+               vmask(ii,ij,ik) = vmask(ii,ij,ik) * bdyvmask(ii,ij)
+               bmask(ii,ij)    = bmask(ii,ij)    * bdytmask(ii,ij)
+            END DO      
+         END DO
+      END DO
+
+      DO ik = 1, jpkm1
+         DO ij = 2, jpjm1
+            DO ii = 2, jpim1
+               fmask(ii,ij,ik) = fmask(ii,ij,ik) * bdytmask(ii,ij  ) * bdytmask(ii+1,ij  )   &
+                  &                              * bdytmask(ii,ij+1) * bdytmask(ii+1,ij+1)
+            END DO      
+         END DO
+      END DO
+
+      tmask_i (:,:) = tmask(:,:,1) * tmask_i(:,:)             
+      bdytmask(:,:) = tmask(:,:,1)
+
+      ! bdy masks and bmask are now set to zero on boundary points:
+      igrd = 1       ! In the free surface case, bmask is at T-points
+      DO ib = 1, nblenrim(igrd)     
+        bmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0
+      END DO
+      !
+      igrd = 1
+      DO ib = 1, nblenrim(igrd)      
+        bdytmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0
+      END DO
+      !
+      igrd = 2
+      DO ib = 1, nblenrim(igrd)
+        bdyumask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0
+      END DO
+      !
+      igrd = 3
+      DO ib = 1, nblenrim(igrd)
+        bdyvmask(nbi(ib,igrd), nbj(ib,igrd)) = 0.e0
+      END DO
+
+      ! Lateral boundary conditions
+      CALL lbc_lnk( fmask        , 'F', 1. )
+      CALL lbc_lnk( bdytmask(:,:), 'T', 1. )
+      CALL lbc_lnk( bdyumask(:,:), 'U', 1. )
+      CALL lbc_lnk( bdyvmask(:,:), 'V', 1. )
+
+      IF( ln_bdy_vol .OR. ln_bdy_dyn_fla ) THEN      ! Indices and directions of rim velocity components
+         !
+         !flagu = -1 : u component is normal to the dynamical boundary but its direction is outward
+         !flagu =  0 : u is tangential
+         !flagu =  1 : u is normal to the boundary and is direction is inward
+         icount = 0 
+         flagu(:) = 0.e0
+ 
+         igrd = 2      ! u-component 
+         DO ib = 1, nblenrim(igrd)  
+            zefl=bdytmask(nbi(ib,igrd)  , nbj(ib,igrd))
+            zwfl=bdytmask(nbi(ib,igrd)+1, nbj(ib,igrd))
+            IF( zefl + zwfl ==2 ) THEN
+               icount = icount +1
+            ELSE
+               flagu(ib)=-zefl+zwfl
+            ENDIF
+         END DO
+
+         !flagv = -1 : u component is normal to the dynamical boundary but its direction is outward
+         !flagv =  0 : u is tangential
+         !flagv =  1 : u is normal to the boundary and is direction is inward
+         flagv(:) = 0.e0
+
+         igrd = 3      ! v-component
+         DO ib = 1, nblenrim(igrd)  
+            znfl = bdytmask(nbi(ib,igrd), nbj(ib,igrd))
+            zsfl = bdytmask(nbi(ib,igrd), nbj(ib,igrd)+1)
+            IF( znfl + zsfl ==2 ) THEN
+               icount = icount + 1
+            ELSE
+               flagv(ib) = -znfl + zsfl
+            END IF
+         END DO
+ 
+         IF( icount /= 0 ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' E R R O R : Some data velocity points,',   &
+               ' are not boundary points. Check nbi, nbj, indices.'
+            IF(lwp) WRITE(numout,*) ' ========== '
+            IF(lwp) WRITE(numout,*)
+            nstop = nstop + 1
+         ENDIF 
+    
+      ENDIF
+
+      ! Compute total lateral surface for volume correction:
+      ! ----------------------------------------------------
+ 
+      bdysurftot = 0.e0 
+      IF( ln_bdy_vol ) THEN  
+         igrd = 2      ! Lateral surface at U-points
+         DO ib = 1, nblenrim(igrd)
+            bdysurftot = bdysurftot + hu     (nbi(ib,igrd)  ,nbj(ib,igrd))                      &
+               &                    * e2u    (nbi(ib,igrd)  ,nbj(ib,igrd)) * ABS( flagu(ib) )   &
+               &                    * tmask_i(nbi(ib,igrd)  ,nbj(ib,igrd))                      &
+               &                    * tmask_i(nbi(ib,igrd)+1,nbj(ib,igrd))                   
+         END DO
+
+         igrd=3 ! Add lateral surface at V-points
+         DO ib = 1, nblenrim(igrd)
+            bdysurftot = bdysurftot + hv     (nbi(ib,igrd),nbj(ib,igrd)  )                      &
+               &                    * e1v    (nbi(ib,igrd),nbj(ib,igrd)  ) * ABS( flagv(ib) )   &
+               &                    * tmask_i(nbi(ib,igrd),nbj(ib,igrd)  )                      &
+               &                    * tmask_i(nbi(ib,igrd),nbj(ib,igrd)+1)
+         END DO
+
+         IF( lk_mpp )   CALL mpp_sum( bdysurftot )      ! sum over the global domain
+      END IF   
+
+      ! Initialise bdy data arrays
+      ! --------------------------
+      tbdy(:,:) = 0.e0
+      sbdy(:,:) = 0.e0
+      ubdy(:,:) = 0.e0
+      vbdy(:,:) = 0.e0
+      sshbdy(:) = 0.e0
+      ubtbdy(:) = 0.e0
+      vbtbdy(:) = 0.e0
+
+      ! Read in tidal constituents and adjust for model start time
+      ! ----------------------------------------------------------
+      IF( ln_bdy_tides )   CALL tide_data
+      !
+   END SUBROUTINE bdy_init
+
+#else
+   !!---------------------------------------------------------------------------------
+   !!   Dummy module                                   NO unstructured open boundaries
+   !!---------------------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE bdy_init      ! Dummy routine
+   END SUBROUTINE bdy_init
+#endif
+
+   !!=================================================================================
+END MODULE bdyini
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytides.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 1844)
@@ -0,0 +1,733 @@
+MODULE bdytides
+   !!======================================================================
+   !!                       ***  MODULE  bdytides  ***
+   !! Ocean dynamics:   Tidal forcing at open boundaries
+   !!======================================================================
+   !! History :  2.0  !  2007-01  (D.Storkey)  Original code
+   !!            2.3  !  2008-01  (J.Holt)  Add date correction. Origins POLCOMS v6.3 2007
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if defined key_bdy
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'     Unstructured Open Boundary Condition
+   !!----------------------------------------------------------------------
+   !!   PUBLIC
+   !!      tide_init     : read of namelist
+   !!      tide_data     : read in and initialisation of tidal constituents at boundary
+   !!      tide_update   : calculation of tidal forcing at each timestep
+   !!   PRIVATE
+   !!      uvset         :\
+   !!      vday          : | Routines to correct tidal harmonics forcing for
+   !!      shpen         : | start time of integration
+   !!      ufset         : |
+   !!      vset          :/
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE iom
+   USE in_out_manager  ! I/O units
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE bdy_par         ! Unstructured boundary parameters
+   USE bdy_oce         ! ocean open boundary conditions
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tide_init     ! routine called in bdyini
+   PUBLIC   tide_data     ! routine called in bdyini
+   PUBLIC   tide_update   ! routine called in bdydyn
+
+   LOGICAL, PUBLIC            ::   ln_tide_date            !: =T correct tide phases and amplitude for model start date
+
+   INTEGER, PARAMETER ::   jptides_max = 15      !: Max number of tidal contituents
+   INTEGER            ::   ntide                 !: Actual number of tidal constituents
+
+   CHARACTER(len=80), PUBLIC                         ::   filtide    !: Filename root for tidal input files
+   CHARACTER(len= 4), PUBLIC, DIMENSION(jptides_max) ::   tide_cpt   !: Names of tidal components used.
+
+   INTEGER , DIMENSION(jptides_max) ::   nindx        !: ???
+   REAL(wp), DIMENSION(jptides_max) ::   tide_speed   !: Phase speed of tidal constituent (deg/hr)
+   
+   REAL(wp), DIMENSION(jpbdim,jptides_max)  ::   ssh1, ssh2   !: Tidal constituents : SSH
+   REAL(wp), DIMENSION(jpbdim,jptides_max)  ::   u1  , u2     !: Tidal constituents : U
+   REAL(wp), DIMENSION(jpbdim,jptides_max)  ::   v1  , v2     !: Tidal constituents : V
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tide_init
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE tide_init  ***
+      !!                     
+      !! ** Purpose : - Read in namelist for tides
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   itide                  ! dummy loop index 
+      !!
+      NAMELIST/nambdy_tide/ln_tide_date, filtide, tide_cpt, tide_speed
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'tide_init : initialization of tidal harmonic forcing at open boundaries'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~'
+
+      ! Namelist nambdy_tide : tidal harmonic forcing at open boundaries
+      ln_tide_date = .false.
+      filtide(:) = ''
+      tide_speed(:) = 0.0
+      tide_cpt(:) = ''
+      REWIND( numnam )                                ! Read namelist parameters
+      READ  ( numnam, nambdy_tide )
+      !                                               ! Count number of components specified
+      ntide = jptides_max
+      itide = 1
+      DO WHILE( tide_cpt(itide) /= '' )
+         ntide = itide
+         itide = itide + 1
+      END DO
+      !                                               ! find constituents in standard list
+      DO itide = 1, ntide
+         nindx(itide) = 0
+         IF( TRIM( tide_cpt(itide) ) == 'Q1'  )   nindx(itide) =  1
+         IF( TRIM( tide_cpt(itide) ) == 'O1'  )   nindx(itide) =  2
+         IF( TRIM( tide_cpt(itide) ) == 'P1'  )   nindx(itide) =  3
+         IF( TRIM( tide_cpt(itide) ) == 'S1'  )   nindx(itide) =  4
+         IF( TRIM( tide_cpt(itide) ) == 'K1'  )   nindx(itide) =  5
+         IF( TRIM( tide_cpt(itide) ) == '2N2' )   nindx(itide) =  6
+         IF( TRIM( tide_cpt(itide) ) == 'MU2' )   nindx(itide) =  7
+         IF( TRIM( tide_cpt(itide) ) == 'N2'  )   nindx(itide) =  8
+         IF( TRIM( tide_cpt(itide) ) == 'NU2' )   nindx(itide) =  9
+         IF( TRIM( tide_cpt(itide) ) == 'M2'  )   nindx(itide) = 10
+         IF( TRIM( tide_cpt(itide) ) == 'L2'  )   nindx(itide) = 11
+         IF( TRIM( tide_cpt(itide) ) == 'T2'  )   nindx(itide) = 12
+         IF( TRIM( tide_cpt(itide) ) == 'S2'  )   nindx(itide) = 13
+         IF( TRIM( tide_cpt(itide) ) == 'K2'  )   nindx(itide) = 14
+         IF( TRIM( tide_cpt(itide) ) == 'M4'  )   nindx(itide) = 15
+         IF( nindx(itide) == 0  .AND. lwp ) THEN
+            WRITE(ctmp1,*) 'constitunent', itide,':', tide_cpt(itide), 'not in standard list'
+            CALL ctl_warn( ctmp1 )
+         ENDIF
+      END DO
+      !                                               ! Parameter control and print
+      IF( ntide < 1 ) THEN 
+         CALL ctl_stop( '          Did not find any tidal components in namelist nambdy_tide' )
+      ELSE
+         IF(lwp) WRITE(numout,*) '          Namelist nambdy_tide : tidal harmonic forcing at open boundaries'
+         IF(lwp) WRITE(numout,*) '             tidal components specified ', ntide
+         IF(lwp) WRITE(numout,*) '                ', tide_cpt(1:ntide)
+         IF(lwp) WRITE(numout,*) '             associated phase speeds (deg/hr) : '
+         IF(lwp) WRITE(numout,*) '                ', tide_speed(1:ntide)
+      ENDIF
+
+      ! Initialisation of tidal harmonics arrays
+      sshtide(:) = 0.e0
+      utide  (:) = 0.e0
+      vtide  (:) = 0.e0
+      !
+   END SUBROUTINE tide_init
+
+
+   SUBROUTINE tide_data
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE tide_data  ***
+      !!                    
+      !! ** Purpose : - Read in tidal harmonics data and adjust for the start 
+      !!                time of the model run. 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   itide, igrd, ib        ! dummy loop indices
+      CHARACTER(len=80) :: clfile         ! full file name for tidal input file 
+      INTEGER ::   ipi, ipj, inum, idvar  ! temporary integers (netcdf read)
+      INTEGER, DIMENSION(3) :: lendta=0   ! length of data in the file (note may be different from nblendta!)
+      REAL(wp) ::  z_arg, z_atde, z_btde, z1t, z2t           
+      REAL(wp), DIMENSION(jpbdta,1) ::   zdta   ! temporary array for data fields
+      REAL(wp), DIMENSION(jptides_max) :: z_vplu, z_ftc
+      !!------------------------------------------------------------------------------
+
+      ! Open files and read in tidal forcing data
+      ! -----------------------------------------
+
+      ipj = 1
+
+      DO itide = 1, ntide
+         !                                                              ! SSH fields
+         clfile = TRIM(filtide)//TRIM(tide_cpt(itide))//'_grid_T.nc'
+         IF(lwp) WRITE(numout,*) 'Reading data from file ', clfile
+         CALL iom_open( clfile, inum )
+         igrd = 1
+         IF( nblendta(igrd) <= 0 ) THEN 
+            idvar = iom_varid( inum,'z1' )
+            IF(lwp) WRITE(numout,*) 'iom_file(1)%ndims(idvar) : ',iom_file%ndims(idvar)
+            nblendta(igrd) = iom_file(inum)%dimsz(1,idvar)
+            WRITE(numout,*) 'Dim size for z1 is ', nblendta(igrd)
+         ENDIF
+         ipi = nblendta(igrd)
+         CALL iom_get( inum, jpdom_unknown, 'z1', zdta(1:ipi,1:ipj) )
+         DO ib = 1, nblenrim(igrd)
+            ssh1(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_get( inum, jpdom_unknown, 'z2', zdta(1:ipi,1:ipj) )
+         DO ib = 1, nblenrim(igrd)
+            ssh2(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_close( inum )
+         !
+         !                                                              ! U fields
+         clfile = TRIM(filtide)//TRIM(tide_cpt(itide))//'_grid_U.nc'
+         IF(lwp) WRITE(numout,*) 'Reading data from file ', clfile
+         CALL iom_open( clfile, inum )
+         igrd = 2
+         IF( lendta(igrd) <= 0 ) THEN 
+            idvar = iom_varid( inum,'u1' )
+            lendta(igrd) = iom_file(inum)%dimsz(1,idvar)
+            WRITE(numout,*) 'Dim size for u1 is ',lendta(igrd)
+         ENDIF
+         ipi = lendta(igrd)
+         CALL iom_get( inum, jpdom_unknown, 'u1', zdta(1:ipi,1:ipj) )
+         DO ib = 1, nblenrim(igrd)
+            u1(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_get( inum, jpdom_unknown, 'u2', zdta(1:ipi,1:ipj) )
+         DO ib = 1, nblenrim(igrd)
+            u2(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_close( inum )
+         !
+         !                                                              ! V fields
+         clfile = TRIM(filtide)//TRIM(tide_cpt(itide))//'_grid_V.nc'
+         if(lwp) write(numout,*) 'Reading data from file ', clfile
+         CALL iom_open( clfile, inum )
+         igrd = 3
+         IF( lendta(igrd) <= 0 ) THEN 
+            idvar = iom_varid( inum,'v1' )
+            lendta(igrd) = iom_file(inum)%dimsz(1,idvar)
+            WRITE(numout,*) 'Dim size for v1 is ', lendta(igrd)
+         ENDIF
+         ipi = lendta(igrd)
+         CALL iom_get( inum, jpdom_unknown, 'v1', zdta(1:ipi,1:ipj) )
+         DO ib = 1, nblenrim(igrd)
+            v1(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_get( inum, jpdom_unknown, 'v2', zdta(1:ipi,1:ipj) )
+         DO ib=1, nblenrim(igrd)
+            v2(ib,itide) = zdta(nbmap(ib,igrd),1)
+         END DO
+         CALL iom_close( inum )
+         !
+      END DO ! end loop on tidal components
+
+      IF( ln_tide_date ) THEN      ! correct for date factors
+
+!! used nmonth, nyear and nday from daymod....
+         ! Calculate date corrects for 15 standard consituents
+         ! This is the initialisation step, so nday, nmonth, nyear are the 
+         ! initial date/time of the integration.
+           print *, nday,nmonth,nyear
+           nyear  = int(ndate0 / 10000  )                           ! initial year
+           nmonth = int((ndate0 - nyear * 10000 ) / 100 )          ! initial month
+           nday   = int(ndate0 - nyear * 10000 - nmonth * 100)
+
+         CALL uvset( 0, nday, nmonth, nyear, z_ftc, z_vplu )
+
+         IF(lwp) WRITE(numout,*) 'Correcting tide for date:', nday, nmonth, nyear
+
+         DO itide = 1, ntide       ! loop on tidal components
+            !
+            IF( nindx(itide) /= 0 ) THEN
+!!gm use rpi  and rad global variable  
+               z_arg = 3.14159265d0 * z_vplu(nindx(itide)) / 180.0d0
+               z_atde=z_ftc(nindx(itide))*cos(z_arg)
+               z_btde=z_ftc(nindx(itide))*sin(z_arg)
+               IF(lwp) WRITE(numout,'(2i5,8f10.6)') itide, nindx(itide), tide_speed(itide),   &
+                  &                                 z_ftc(nindx(itide)), z_vplu(nindx(itide))
+            ELSE
+               z_atde = 1.0_wp
+               z_btde = 0.0_wp
+            ENDIF
+            !                                         !  elevation         
+            igrd = 1
+            DO ib = 1, nblenrim(igrd)                
+               z1t = z_atde * ssh1(ib,itide) + z_btde * ssh2(ib,itide)
+               z2t = z_atde * ssh2(ib,itide) - z_btde * ssh1(ib,itide)
+               ssh1(ib,itide) = z1t
+               ssh2(ib,itide) = z2t
+            END DO
+            !                                         !  u       
+            igrd = 2
+            DO ib = 1, nblenrim(igrd)                
+               z1t = z_atde * u1(ib,itide) + z_btde * u2(ib,itide)
+               z2t = z_atde * u2(ib,itide) - z_btde * u1(ib,itide)
+               u1(ib,itide) = z1t
+               u2(ib,itide) = z2t
+            END DO
+            !                                         !  v       
+            igrd = 3
+            DO ib = 1, nblenrim(igrd)                
+               z1t = z_atde * v1(ib,itide) + z_btde * v2(ib,itide)
+               z2t = z_atde * v2(ib,itide) - z_btde * v1(ib,itide)
+               v1(ib,itide) = z1t
+               v2(ib,itide) = z2t
+            END DO
+            !
+         END DO   ! end loop on tidal components
+         !
+      ENDIF ! date correction
+      !
+   END SUBROUTINE tide_data
+
+
+   SUBROUTINE tide_update ( kt, jit )
+      !!----------------------------------------------------------------------
+      !!                 ***  SUBROUTINE tide_update  ***
+      !!                
+      !! ** Purpose : - Add tidal forcing to sshbdy, ubtbdy and vbtbdy arrays. 
+      !!                
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! Main timestep counter
+!!gm doctor jit ==> kit
+      INTEGER, INTENT( in ) ::   jit     ! Barotropic timestep counter (for timesplitting option)
+      !!
+      INTEGER  ::   itide, igrd, ib      ! dummy loop indices
+      REAL(wp) ::   z_arg, z_sarg            !            
+      REAL(wp), DIMENSION(jptides_max) :: z_sist, z_cost
+      !!----------------------------------------------------------------------
+
+      ! Note tide phase speeds are in deg/hour, so we need to convert the
+      ! elapsed time in seconds to hours by dividing by 3600.0
+      IF( jit == 0 ) THEN  
+         z_arg = kt * rdt * rad / 3600.0
+      ELSE                              ! we are in a barotropic subcycle (for timesplitting option)
+!         z_arg = ( (kt-1) * rdt + jit * rdt / REAL(nn_baro,lwp) ) * rad / 3600.0
+         z_arg = ( (kt-1) * rdt + jit * rdt / REAL(nn_baro,wp) ) * rad / 3600.0
+      ENDIF
+
+      DO itide = 1, ntide
+         z_sarg = z_arg * tide_speed(itide)
+         z_cost(itide) = COS( z_sarg )
+         z_sist(itide) = SIN( z_sarg )
+      END DO
+
+      ! summing of tidal constituents into BDY arrays
+      sshtide(:) = 0.0
+      utide (:) = 0.0
+      vtide (:) = 0.0
+      !
+      DO itide = 1, ntide
+         igrd=1                              ! SSH on tracer grid.
+         DO ib = 1, nblenrim(igrd)
+            sshtide(ib) =sshtide(ib)+ ssh1(ib,itide)*z_cost(itide) + ssh2(ib,itide)*z_sist(itide)
+            !    if(lwp) write(numout,*) 'z',ib,itide,sshtide(ib), ssh1(ib,itide),ssh2(ib,itide)
+         END DO
+         igrd=2                              ! U grid
+         DO ib=1, nblenrim(igrd)
+            utide(ib) = utide(ib)+ u1(ib,itide)*z_cost(itide) + u2(ib,itide)*z_sist(itide)
+            !    if(lwp) write(numout,*) 'u',ib,itide,utide(ib), u1(ib,itide),u2(ib,itide)
+         END DO
+         igrd=3                              ! V grid
+         DO ib=1, nblenrim(igrd)
+            vtide(ib) = vtide(ib)+ v1(ib,itide)*z_cost(itide) + v2(ib,itide)*z_sist(itide)
+            !    if(lwp) write(numout,*) 'v',ib,itide,vtide(ib), v1(ib,itide),v2(ib,itide)
+         END DO
+      END DO
+      !
+   END SUBROUTINE tide_update
+
+!!gm  doctor naming of dummy argument variables!!!   and all local variables
+
+   SUBROUTINE uvset( ihs, iday, imnth, iyr, f, z_vplu )
+      !!----------------------------------------------------------------------
+      !!                   ***  SUBROUTINE uvset  ***
+      !!                     
+      !! ** Purpose : - adjust tidal forcing for date factors
+      !!                
+      !!----------------------------------------------------------------------
+      implicit none
+      INTEGER, INTENT( in ) ::   ihs     ! Start time hours
+      INTEGER, INTENT( in ) ::   iday    ! start time days
+      INTEGER, INTENT( in ) ::   imnth   ! start time month
+      INTEGER, INTENT( in ) ::   iyr     ! start time year
+      !!
+!!gm  nc is jptides_max ????
+      INTEGER , PARAMETER     ::  nc =15    ! maximum number of constituents
+      CHARACTER(len=8), DIMENSION(nc) :: cname
+      INTEGER                 ::   year, vd, ivdy, ndc, i, k
+      REAL(wp)                ::   ss, h, p, en, p1, rtd
+      REAL(wp), DIMENSION(nc) ::   f                          ! nodal correction
+      REAL(wp), DIMENSION(nc) ::   z_vplu                     ! phase correction
+      REAL(wp), DIMENSION(nc) ::   u, v, zig
+      !!
+      DATA cname/  'q1'    ,    'o1'    ,     'p1'   ,    's1'    ,     'k1'    ,   &
+         &         '2n2'   ,    'mu2'   ,     'n2'   ,    'nu2'   ,     'm2'    ,   &
+         &         'l2'    ,    't2'    ,     's2'   ,    'k2'    ,     'm4'      /
+      DATA zig/ .2338507481, .2433518789, .2610826055, .2617993878,  .2625161701,   &
+         &      .4868657873, .4881373225, .4963669182, .4976384533,  .5058680490,   &
+         &      .5153691799, .5228820265, .5235987756, .5250323419, 1.011736098   /
+      !!----------------------------------------------------------------------
+!
+!     ihs             -  start time gmt on ...
+!     iday/imnth/iyr  -  date   e.g.   12/10/87
+!
+      CALL vday(iday,imnth,iyr,ivdy)
+      vd = ivdy
+!
+!rp   note change of year number for d. blackman shpen
+!rp   if(iyr.ge.1000) year=iyr-1900
+!rp   if(iyr.lt.1000) year=iyr
+      year = iyr
+!
+!.....year  =  year of required data
+!.....vd    =  day of required data..set up for 0000gmt day year
+      ndc = nc
+!.....ndc   =  number of constituents allowed
+!!gm use rpi ?
+      rtd = 360.0 / 6.2831852
+      DO i = 1, ndc
+         zig(i) = zig(i)*rtd
+         ! sigo(i)= zig(i)
+      END DO
+
+!!gm try to avoid RETURN  in F90
+      IF( year == 0 )   RETURN
+      
+         CALL shpen( year, vd, ss, h , p , en, p1 )
+         CALL ufset( p   , en, u , f )
+         CALL vset ( ss  , h , p , en, p1, v )
+         !
+         DO k = 1, nc
+            z_vplu(k) = v(k) + u(k)
+            z_vplu(k) = z_vplu(k) + dble(ihs) * zig(k)
+            DO WHILE( z_vplu(k) < 0    )
+               z_vplu(k) = z_vplu(k) + 360.0
+            END DO
+            DO WHILE( z_vplu(k) > 360. )
+               z_vplu(k) = z_vplu(k) - 360.0
+            END DO
+         END DO
+         !
+      END SUBROUTINE uvset
+
+
+      SUBROUTINE vday( iday, imnth, iy, ivdy )
+      !!----------------------------------------------------------------------
+      !!                   *** SUBROUTINE vday  ***
+      !!                  
+      !! ** Purpose : - adjust tidal forcing for date factors
+      !!                
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   iday, imnth, iy   ! ????
+      INTEGER, INTENT(  out) ::   ivdy              ! ???
+      !! 
+      INTEGER ::   iyr
+      !!------------------------------------------------------------------------------
+
+!!gm   nday_year in day mode is the variable compiuted here, no?
+!!gm      nday_year ,   &  !: curent day counted from jan 1st of the current year
+
+      !calculate day number in year from day/month/year
+       if(imnth.eq.1) ivdy=iday
+       if(imnth.eq.2) ivdy=iday+31
+       if(imnth.eq.3) ivdy=iday+59
+       if(imnth.eq.4) ivdy=iday+90
+       if(imnth.eq.5) ivdy=iday+120
+       if(imnth.eq.6) ivdy=iday+151
+       if(imnth.eq.7) ivdy=iday+181
+       if(imnth.eq.8) ivdy=iday+212
+       if(imnth.eq.9) ivdy=iday+243
+       if(imnth.eq.10) ivdy=iday+273
+       if(imnth.eq.11) ivdy=iday+304
+       if(imnth.eq.12) ivdy=iday+334
+       iyr=iy
+       if(mod(iyr,4).eq.0.and.imnth.gt.2) ivdy=ivdy+1
+       if(mod(iyr,100).eq.0.and.imnth.gt.2) ivdy=ivdy-1
+       if(mod(iyr,400).eq.0.and.imnth.gt.2) ivdy=ivdy+1
+      !
+   END SUBROUTINE vday
+
+!!doctor norme for dummy arguments
+
+   SUBROUTINE shpen( year, vd, s, h, p, en, p1 )
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE shpen  ***
+      !!                   
+      !! ** Purpose : - calculate astronomical arguments for tides
+      !!                this version from d. blackman 30 nove 1990
+      !!
+      !!----------------------------------------------------------------------
+!!gm add INTENT in, out or inout....    DOCTOR name....
+!!gm please do not use variable name with a single letter:  impossible to search in a code
+      INTEGER  ::   year,vd
+      REAL(wp) ::   s,h,p,en,p1
+      !!
+      INTEGER  ::   yr,ilc,icent,it,iday,ild,ipos,nn,iyd
+      REAL(wp) ::   cycle,t,td,delt(84),delta,deltat
+      !!
+      DATA delt /-5.04, -3.90, -2.87, -0.58,  0.71,  1.80,           &
+         &        3.08,  4.63,  5.86,  7.21,  8.58, 10.50, 12.10,    &
+         &       12.49, 14.41, 15.59, 15.81, 17.52, 19.01, 18.39,    &
+         &       19.55, 20.36, 21.01, 21.81, 21.76, 22.35, 22.68,    &
+         &       22.94, 22.93, 22.69, 22.94, 23.20, 23.31, 23.63,    &
+         &       23.47, 23.68, 23.62, 23.53, 23.59, 23.99, 23.80,    &
+         &       24.20, 24.99, 24.97, 25.72, 26.21, 26.37, 26.89,    &
+         &       27.68, 28.13, 28.94, 29.42, 29.66, 30.29, 30.96,    &
+         &       31.09, 31.59, 31.52, 31.92, 32.45, 32.91, 33.39,    &
+         &       33.80, 34.23, 34.73, 35.40, 36.14, 36.99, 37.87,    &
+         &       38.75, 39.70, 40.70, 41.68, 42.82, 43.96, 45.00,    &
+         &       45.98, 47.00, 48.03, 49.10, 50.10, 50.97, 51.81,    &
+         &       52.57 /
+      !!----------------------------------------------------------------------
+
+      cycle = 360.0
+      ilc = 0
+      icent = year / 100
+      yr = year - icent * 100
+      t = icent - 20
+!
+!     for the following equations
+!     time origin is fixed at 00 hr of jan 1st,2000.
+!     see notes by cartwright
+!
+!!gm  old coding style, use CASE instead  and avoid GOTO (obsolescence in fortran 90)
+!!gm obsol(   1): Arithmetic IF statement is used   ===>  remove this in Fortran 90
+      it = icent - 20
+      if (it) 1,2,2
+    1 iday = it/4 -it
+      go to 3
+    2 iday = (it+3)/4 - it
+!
+!     t is in julian century
+!     correction in gegorian calander where only century year divisible
+!     by 4 is leap year.
+!
+    3 continue
+!
+      td = 0.0
+!
+!!gm obsol(   1): Arithmetic IF statement is used   ===>  remove this in Fortran 90
+      if (yr) 4,5,4
+!
+    4 iyd = 365*yr
+      ild = (yr-1)/4
+      if((icent - (icent/4)*4) .eq. 0) ilc = 1
+      td = iyd + ild + ilc
+!
+    5 td = td + iday + vd -1.0 - 0.5
+      t = t + (td/36525.0)
+!
+      ipos=year-1899
+      if (ipos .lt. 0) go to 7
+      if (ipos .gt. 83) go to 6
+!
+      delta = (delt(ipos+1)+delt(ipos))/2.0
+      go to 7
+!
+    6 delta= (65.0-50.5)/20.0*(year-1980)+50.5
+!
+    7 deltat = delta * 1.0e-6
+!
+!!gm   precision of the computation   :  example for s it should be replace by:
+!!gm  s   = 218.3165 + (481267.8813 - 0.0016*t)*t + 152.0*deltat   ==>  more precise  modify the last digits results
+      s   = 218.3165 + 481267.8813*t - 0.0016*t*t + 152.0*deltat
+      h   = 280.4661 + 36000.7698 *t + 0.0003*t*t +  11.0*deltat
+      p   =  83.3535 + 4069.0139  *t - 0.0103*t*t +       deltat
+      en  = 234.9555 + 1934.1363  *t - 0.0021*t*t +       deltat
+      p1  = 282.9384 + 1.7195     *t + 0.0005*t*t
+      !
+      nn = s / cycle
+      s = s - nn * cycle
+      IF( s < 0.e0 )   s = s + cycle
+      !
+      nn = h / cycle
+      h = h - cycle * nn
+      IF( h < 0.e0 )   h = h + cycle
+      !
+      nn = p / cycle
+      p = p - cycle * nn
+      IF( p < 0.e0)   p = p + cycle
+      !
+      nn = en / cycle
+      en = en - cycle * nn
+      IF( en < 0.e0 )   en = en + cycle
+      en = cycle - en
+      !
+      nn = p1 / cycle
+      p1 = p1 - nn * cycle
+      !
+   END SUBROUTINE shpen
+
+
+   SUBROUTINE ufset( p, cn, b, a )
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE ufset  ***
+      !!                    
+      !! ** Purpose : - calculate nodal parameters for the tides
+      !!                
+      !!----------------------------------------------------------------------
+!!gm  doctor naming of dummy argument variables!!!   and all local variables
+!!gm  nc is jptides_max ????
+      integer nc
+      parameter (nc=15)
+      REAL(wp) p,cn
+      !!
+      
+!!gm  rad is already a public variable defined in phycst.F90 ....   ==> doctor norme  local real start with "z"
+      REAL(wp) ::   w1, w2, w3, w4, w5, w6, w7, w8, nw, pw, rad
+      REAL(wp) ::   a(nc), b(nc)
+      INTEGER  ::   ndc, k
+      !!----------------------------------------------------------------------
+
+      ndc = nc
+
+!    a=f       ,  b =u
+!    t is  zero as compared to tifa.
+!! use rad defined in phycst   (i.e.  add a USE phycst at the begining of the module
+      rad = 6.2831852d0/360.0
+      pw = p  * rad
+      nw = cn * rad
+      w1 = cos(   nw )
+      w2 = cos( 2*nw )
+      w3 = cos( 3*nw )
+      w4 = sin(   nw )
+      w5 = sin( 2*nw )
+      w6 = sin( 3*nw )
+      w7 = 1. - 0.2505 * COS( 2*pw      ) - 0.1102 * COS(2*pw-nw )   &
+         &    - 0.156  * COS( 2*pw-2*nw ) - 0.037  * COS(     nw )
+      w8 =    - 0.2505 * SIN( 2*pw      ) - 0.1102 * SIN(2*pw-nw )   &
+         &    - 0.0156 * SIN( 2*pw-2*nw ) - 0.037  * SIN(     nw )
+      !
+      a(1) = 1.0089 + 0.1871 * w1 - 0.0147 * w2 + 0.0014 * w3
+      b(1) =          0.1885 * w4 - 0.0234 * w5 + 0.0033 * w6
+      !   q1
+      a(2) = a(1)
+      b(2) = b(1)
+      !   o1
+      a(3) = 1.0
+      b(3) = 0.0
+      !   p1
+      a(4) = 1.0
+      b(4) = 0.0
+      !   s1
+      a(5) = 1.0060+0.1150*w1- 0.0088*w2 +0.0006*w3
+      b(5) = -0.1546*w4 + 0.0119*w5 -0.0012*w6
+      !   k1
+      a(6) =1.0004 -0.0373*w1+ 0.0002*w2
+      b(6) = -0.0374*w4
+      !  2n2
+      a(7) = a(6)
+      b(7) = b(6)
+      !  mu2
+      a(8) = a(6)
+      b(8) = b(6)
+      !   n2
+      a(9) = a(6)
+      b(9) = b(6)
+      !  nu2
+      a(10) = a(6)
+      b(10) = b(6)
+      !   m2
+      a(11) = SQRT( w7 * w7 + w8 * w8 )
+      b(11) = ATAN( w8 / w7 )
+!!gmuse rpi  instead of 3.141992 ???   true pi is rpi=3.141592653589793_wp  .....   ????
+      IF( w7 < 0.e0 )   b(11) = b(11) + 3.141992
+      !   l2
+      a(12) = 1.0
+      b(12) = 0.0
+      !   t2
+      a(13)= a(12)
+      b(13)= b(12)
+      !   s2
+      a(14) = 1.0241+0.2863*w1+0.0083*w2 -0.0015*w3
+      b(14) = -0.3096*w4 + 0.0119*w5 - 0.0007*w6
+      !   k2
+      a(15) = a(6)*a(6)
+      b(15) = 2*b(6)
+      !   m4
+!!gm  old coding,  remove GOTO and label of lines
+!!gm obsol(   1): Arithmetic IF statement is used   ===>  remove this in Fortran 90
+      DO 40 k = 1,ndc
+         b(k) = b(k)/rad
+32       if (b(k)) 34,35,35
+34       b(k) = b(k) + 360.0
+         go to 32
+35       if (b(k)-360.0) 40,37,37
+37       b(k) = b(k)-360.0
+         go to 35
+40    continue
+      !
+   END SUBROUTINE ufset
+   
+
+   SUBROUTINE vset( s,h,p,en,p1,v)
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE vset  ***
+      !!                   
+      !! ** Purpose : - calculate tidal phases for 0000gmt on start day of run
+      !!                
+      !!----------------------------------------------------------------------
+!!gm  doctor naming of dummy argument variables!!!   and all local variables
+!!gm  nc is jptides_max ????
+!!gm  en argument is not used: suppress it ?
+      integer nc
+      parameter (nc=15)
+      real(wp) s,h,p,en,p1
+      real(wp)   v(nc)
+      !!
+      integer ndc, k
+      !!----------------------------------------------------------------------
+
+      ndc = nc
+      !   v s  are computed here.
+      v(1) =-3*s +h +p +270      ! Q1
+      v(2) =-2*s +h +270.0       ! O1
+      v(3) =-h +270              ! P1
+      v(4) =180                  ! S1
+      v(5) =h +90.0              ! K1
+      v(6) =-4*s +2*h +2*p       ! 2N2
+      v(7) =-4*(s-h)             ! MU2
+      v(8) =-3*s +2*h +p         ! N2
+      v(9) =-3*s +4*h -p         ! MU2
+      v(10) =-2*s +2*h           ! M2
+      v(11) =-s +2*h -p +180     ! L2 
+      v(12) =-h +p1              ! T2
+      v(13) =0                   ! S2
+      v(14) =h+h                 ! K2
+      v(15) =2*v(10)             ! M4
+!
+!!gm  old coding,  remove GOTO and label of lines
+!!gm obsol(   1): Arithmetic IF statement is used   ===>  remove this in Fortran 90
+      do 72 k = 1, ndc
+69       if( v(k) )   70,71,71
+70       v(k) = v(k)+360.0
+         go to 69
+71       if( v(k) - 360.0 )   72,73,73
+73       v(k) = v(k)-360.0
+         go to 71
+72    continue
+      !
+   END SUBROUTINE vset
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module         NO Unstruct Open Boundary Conditions for tides
+   !!----------------------------------------------------------------------
+!!gm  are you sure we need to define filtide and tide_cpt ?
+   CHARACTER(len=80), PUBLIC               ::   filtide                !: Filename root for tidal input files
+   CHARACTER(len=4 ), PUBLIC, DIMENSION(1) ::   tide_cpt               !: Names of tidal components used.
+
+CONTAINS
+   SUBROUTINE tide_init                ! Empty routine
+   END SUBROUTINE tide_init
+   SUBROUTINE tide_data                ! Empty routine
+   END SUBROUTINE tide_data
+   SUBROUTINE tide_update( kt, kit )   ! Empty routine
+      WRITE(*,*) 'tide_update: You should not have seen this print! error?', kt, kit
+   END SUBROUTINE tide_update
+#endif
+
+   !!======================================================================
+END MODULE bdytides
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytra.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytra.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdytra.F90	(revision 1844)
@@ -0,0 +1,87 @@
+MODULE bdytra
+   !!======================================================================
+   !!                       ***  MODULE  bdytra  ***
+   !! Ocean tracers:   Flow Relaxation Scheme of tracers on each open boundary
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if defined key_bdy
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'                     Unstructured Open Boundary Conditions
+   !!----------------------------------------------------------------------
+   !!   bdy_tra        : Relaxation of tracers on unstructured open boundaries
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE bdy_oce         ! ocean open boundary conditions
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC bdy_tra     ! routine called in tranxt.F90 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE bdy_tra( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  SUBROUTINE bdy_tra  ***
+      !!                    
+      !! ** Purpose : Apply the Flow Relaxation Scheme for tracers in the  
+      !!              case of unstructured open boundaries.
+      !! 
+      !! Reference : Engedahl H., 1995, Tellus, 365-382.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt
+      !! 
+      REAL(wp) ::   zwgt           ! boundary weight
+      INTEGER  ::   ib, ik, igrd   ! dummy loop indices
+      INTEGER  ::   ii, ij         ! 2D addresses
+      !!----------------------------------------------------------------------
+      !
+      IF(ln_bdy_tra_frs) THEN ! If this is false, then this routine does nothing. 
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'bdy_tra : Flow Relaxation Scheme for tracers'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+      !
+      igrd = 1                       ! Everything is at T-points here
+      DO ib = 1, nblen(igrd)
+         DO ik = 1, jpkm1
+            ii = nbi(ib,igrd)
+            ij = nbj(ib,igrd)
+            zwgt = nbw(ib,igrd)
+            ta(ii,ij,ik) = ( ta(ii,ij,ik) * (1.-zwgt) + tbdy(ib,ik) * zwgt ) * tmask(ii,ij,ik)         
+            sa(ii,ij,ik) = ( sa(ii,ij,ik) * (1.-zwgt) + sbdy(ib,ik) * zwgt ) * tmask(ii,ij,ik)
+        END DO
+      END DO 
+      !
+      CALL lbc_lnk( ta, 'T', 1. )   ! Boundary points should be updated
+      CALL lbc_lnk( sa, 'T', 1. )   !
+      !
+      ENDIF ! ln_bdy_tra_frs
+
+   END SUBROUTINE bdy_tra
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                   NO Unstruct Open Boundary Conditions
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE bdy_tra(kt)      ! Empty routine
+      WRITE(*,*) 'bdy_tra: You should not have seen this print! error?', kt
+   END SUBROUTINE bdy_tra
+#endif
+
+   !!======================================================================
+END MODULE bdytra
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyvol.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyvol.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/BDY/bdyvol.F90	(revision 1844)
@@ -0,0 +1,167 @@
+MODULE bdyvol
+   !!======================================================================
+   !!                       ***  MODULE  bdyvol  ***
+   !! Ocean dynamic :  Volume constraint when unstructured boundary 
+   !!                  and Free surface are used
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!             -   !  2006-01  (J. Chanut) Bug correction
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!----------------------------------------------------------------------
+#if   defined key_bdy   &&   defined key_dynspg_flt
+   !!----------------------------------------------------------------------
+   !!   'key_bdy'            and      unstructured open boundary conditions
+   !!   'key_dynspg_flt'                              filtered free surface
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE phycst          ! physical constants
+   USE bdy_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! for mppsum
+   USE in_out_manager  ! I/O manager
+   USE sbc_oce         ! ocean surface boundary conditions
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC bdy_vol        ! routine called by dynspg_flt.h90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE bdy_vol( kt )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE bdyvol  ***
+      !!
+      !! ** Purpose :   This routine is called in dynspg_flt to control 
+      !!      the volume of the system. A correction velocity is calculated
+      !!      to correct the total transport through the unstructured OBC. 
+      !!      The total depth used is constant (H0) to be consistent with the 
+      !!      linear free surface coded in OPA 8.2
+      !!
+      !! ** Method  :   The correction velocity (zubtpecor here) is defined calculating
+      !!      the total transport through all open boundaries (trans_bdy) minus
+      !!      the cumulate E-P flux (z_cflxemp) divided by the total lateral 
+      !!      surface (bdysurftot) of the unstructured boundary. 
+      !!         zubtpecor = [trans_bdy - z_cflxemp ]*(1./bdysurftot)
+      !!      with z_cflxemp => sum of (Evaporation minus Precipitation)
+      !!                       over all the domain in m3/s at each time step.
+      !!      z_cflxemp < 0 when precipitation dominate
+      !!      z_cflxemp > 0 when evaporation dominate
+      !!
+      !!      There are 2 options (user's desiderata): 
+      !!         1/ The volume changes according to E-P, this is the default
+      !!            option. In this case the cumulate E-P flux are setting to
+      !!            zero (z_cflxemp=0) to calculate the correction velocity. So
+      !!            it will only balance the flux through open boundaries.
+      !!            (set volbdy to 0 in tne namelist for this option)
+      !!         2/ The volume is constant even with E-P flux. In this case
+      !!            the correction velocity must balance both the flux 
+      !!            through open boundaries and the ones through the free
+      !!            surface. 
+      !!            (set volbdy to 1 in tne namelist for this option)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk, jb, jgrd
+      INTEGER  ::   ii, ij
+      REAL(wp) ::   zubtpecor, z_cflxemp, ztranst, zraur
+      !!-----------------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN 
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)'bdy_vol : Correction of velocities along unstructured OBC'
+         IF(lwp) WRITE(numout,*)'~~~~~~~'
+      END IF 
+
+      ! Calculate the cumulate surface Flux z_cflxemp (m3/s) over all the domain
+      ! -----------------------------------------------------------------------
+      z_cflxemp = 0.e0
+      zraur = 1.e0 / rau0
+      z_cflxemp = SUM ( emp(:,:) * bdytmask(:,:) * e1t(:,:) * e2t(:,:) * zraur )
+      IF( lk_mpp )   CALL mpp_sum( z_cflxemp )   ! sum over the global domain
+
+      ! Barotropic velocity through the unstructured open boundary
+      ! ----------------------------------------------------------
+      zubtpecor = 0.e0
+      jgrd = 2                               ! cumulate u component contribution first 
+      DO jb = 1, nblenrim(jgrd)
+         DO jk = 1, jpkm1
+            ii = nbi(jb,jgrd)
+            ij = nbj(jb,jgrd)
+            zubtpecor = zubtpecor + flagu(jb) * ua(ii,ij, jk) * e2u(ii,ij) * fse3u(ii,ij,jk)
+         END DO
+      END DO
+      jgrd = 3                               ! then add v component contribution
+      DO jb = 1, nblenrim(jgrd)
+         DO jk = 1, jpkm1
+            ii = nbi(jb,jgrd)
+            ij = nbj(jb,jgrd)
+            zubtpecor = zubtpecor + flagv(jb) * va(ii,ij, jk) * e1v(ii,ij) * fse3v(ii,ij,jk) 
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zubtpecor )   ! sum over the global domain
+
+      ! The normal velocity correction
+      ! ------------------------------
+      IF (volbdy==1) THEN   ;   zubtpecor = ( zubtpecor - z_cflxemp) / bdysurftot 
+      ELSE                  ;   zubtpecor =   zubtpecor             / bdysurftot
+      END IF
+
+      ! Correction of the total velocity on the unstructured boundary to respect the mass flux conservation
+      ! -------------------------------------------------------------
+      ztranst = 0.e0
+      jgrd = 2                               ! correct u component
+      DO jb = 1, nblenrim(jgrd)
+         DO jk = 1, jpkm1
+            ii = nbi(jb,jgrd)
+            ij = nbj(jb,jgrd)
+            ua(ii,ij,jk) = ua(ii,ij,jk) - flagu(jb) * zubtpecor * umask(ii,ij,jk)
+            ztranst = ztranst + flagu(jb) * ua(ii,ij,jk) * e2u(ii,ij) * fse3u(ii,ij,jk)
+         END DO
+      END DO
+      jgrd = 3                              ! correct v component
+      DO jb = 1, nblenrim(jgrd)
+         DO jk = 1, jpkm1
+            ii = nbi(jb,jgrd)
+            ij = nbj(jb,jgrd)
+            va(ii,ij,jk) = va(ii,ij,jk) -flagv(jb) * zubtpecor * vmask(ii,ij,jk)
+            ztranst = ztranst + flagv(jb) * va(ii,ij,jk) * e1v(ii,ij) * fse3v(ii,ij,jk)
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( ztranst )   ! sum over the global domain
+ 
+      ! Check the cumulated transport through unstructured OBC once barotropic velocities corrected
+      ! ------------------------------------------------------
+
+      IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)'bdy_vol : time step :', kt
+         IF(lwp) WRITE(numout,*)'~~~~~~~ '
+         IF(lwp) WRITE(numout,*)'          cumulate flux EMP             =', z_cflxemp  , ' (m3/s)'
+         IF(lwp) WRITE(numout,*)'          total lateral surface of OBC  =', bdysurftot, '(m2)'
+         IF(lwp) WRITE(numout,*)'          correction velocity zubtpecor =', zubtpecor , '(m/s)'
+         IF(lwp) WRITE(numout,*)'          cumulated transport ztranst   =', ztranst   , '(m3/s)'
+      END IF 
+      !
+   END SUBROUTINE bdy_vol
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                   NO Unstruct Open Boundary Conditions
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE bdy_vol( kt )        ! Empty routine
+      WRITE(*,*) 'bdy_vol: You should not have seen this print! error?', kt
+   END SUBROUTINE bdy_vol
+#endif
+
+   !!======================================================================
+END MODULE bdyvol
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 1844)
@@ -0,0 +1,217 @@
+MODULE diaar5
+   !!======================================================================
+   !!                       ***  MODULE  diaar5  ***
+   !! AR5 diagnostics
+   !!======================================================================
+   !! History : 3.2  !  2009-11  (S. Masson)  Original code
+   !!----------------------------------------------------------------------
+#if defined key_diaar5
+   !!----------------------------------------------------------------------
+   !!   'key_diaar5'  :                           activate ar5 diagnotics
+   !!----------------------------------------------------------------------
+   !!   exa_mpl       : liste of module subroutine (caution, never use the
+   !!   exa_mpl_init  : name of the module for a routine)
+   !!   exa_mpl_stp   : Please try to use 3 letter block for routine names
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers 
+   USE dom_oce        ! ocean space and time domain
+   USE eosbn2          ! equation of state                (eos_bn2 routine)
+   USE lib_mpp        ! distribued memory computing library
+   USE iom            ! I/O manager library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_ar5   ! routine called in step.F90 module
+
+   LOGICAL, PUBLIC, PARAMETER :: lk_diaar5 = .TRUE.   ! coupled flag
+
+   REAL(wp)                         ::   vol0               ! ocean volume (interior domain)
+   REAL(wp)                         ::   area_tot           ! total ocean surface (interior domain)
+   REAL(wp), DIMENSION(jpi,jpj    ) ::   area               ! cell surface (interior domain)
+   REAL(wp), DIMENSION(jpi,jpj    ) ::   thick0             ! ocean thickness (interior domain)
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   sn0                ! initial salinity
+      
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_ar5( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dia_ar5  ***
+      !!
+      !! ** Purpose :   Brief description of the routine
+      !!
+      !! ** Method  :   description of the methodoloy used to achieve the
+      !!                objectives of the routine. Be as clear as possible!
+      !!
+      !! ** Action  : - first action (share memory array/varible modified
+      !!                in this routine
+      !!              - second action .....
+      !!              - .....
+      !!
+      !! References :   Author et al., Short_name_review, Year
+      !!                Give references if exist otherwise suppress these lines
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
+      REAL(wp) ::   zvolssh, zvol, zssh_steric, zztmp, zarho, ztemp, zsal, zmass
+      REAL(wp), DIMENSION(jpi,jpj    ) ::   zarea_ssh, zbotpres
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zrhd, zrhop
+      !!--------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL dia_ar5_init   ! Initialization (first time-step only)
+
+      CALL iom_put( 'cellthc', fse3t(:,:,:) )
+
+      zarea_ssh(:,:) = area(:,:) * sshn(:,:)
+
+      !                                         ! total volume of liquid seawater
+      zvolssh = SUM( zarea_ssh(:,:) ) 
+      IF( lk_mpp )   CALL mpp_sum( zvolssh )
+      zvol = vol0 + zvolssh
+      
+      CALL iom_put( 'voltot', zvol               )
+      CALL iom_put( 'sshtot', zvolssh / area_tot )
+
+      !                                         ! thermosteric ssh
+      CALL eos( tn, sn0, zrhd )                       ! now in situ density using initial salinity
+      !
+      zbotpres(:,:) = 0.e0                            ! no atmospheric surface pressure, levitating sea-ice
+      DO jk = 1, jpkm1
+         zbotpres(:,:) = zbotpres(:,:) + fse3t(:,:,jk) * zrhd(:,:,jk)
+      END DO
+      IF( .NOT. lk_vvl )   zbotpres(:,:) = zbotpres(:,:) + sshn(:,:) * zrhd(:,:,1)
+      !                                         
+      zarho = SUM( area(:,:) * zbotpres(:,:) ) 
+      IF( lk_mpp )   CALL mpp_sum( zarho )
+      zssh_steric = - zarho / area_tot
+      CALL iom_put( 'sshthster', zssh_steric )
+      
+      !                                         ! steric sea surface height
+      CALL eos( tn, sn, zrhd, zrhop )                 ! now in situ and potential density
+      zrhop(:,:,jpk) = 0.e0
+      CALL iom_put( 'rhop', zrhop )
+      !
+      zbotpres(:,:) = 0.e0                            ! no atmospheric surface pressure, levitating sea-ice
+      DO jk = 1, jpkm1
+         zbotpres(:,:) = zbotpres(:,:) + fse3t(:,:,jk) * zrhd(:,:,jk)
+      END DO
+      IF( .NOT. lk_vvl )   zbotpres(:,:) = zbotpres(:,:) + sshn(:,:) * zrhd(:,:,1)
+      !    
+      zarho = SUM( area(:,:) * zbotpres(:,:) ) 
+      IF( lk_mpp )   CALL mpp_sum( zarho )
+      zssh_steric = - zarho / area_tot
+      CALL iom_put( 'sshsteric', zssh_steric )
+      
+      !                                         ! ocean bottom pressure
+      zztmp = rau0 * grav * 1.e-4                     ! recover pressure from pressure anomaly and cover to dbar = 1.e4 Pa
+      zbotpres(:,:) = zztmp * ( zbotpres(:,:) + sshn(:,:) + thick0(:,:) )
+      CALL iom_put( 'botpres', zbotpres )
+
+      !                                         ! Mean density anomalie, temperature and salinity
+      ztemp = 0.e0
+      zsal  = 0.e0
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zztmp = area(ji,jj) * fse3t(ji,jj,jk)
+               ztemp = ztemp + zztmp * tn  (ji,jj,jk)
+               zsal  = zsal  + zztmp * sn  (ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      IF( .NOT. lk_vvl ) THEN
+         ztemp = ztemp + SUM( zarea_ssh(:,:) * tn  (:,:,1) )
+         zsal  = zsal  + SUM( zarea_ssh(:,:) * sn  (:,:,1) )
+      ENDIF
+      IF( lk_mpp ) THEN  
+         CALL mpp_sum( ztemp )
+         CALL mpp_sum( zsal  )
+      END IF
+      !
+      zmass = rau0 * ( zarho + zvol )                 ! total mass of liquid seawater
+      ztemp = ztemp / zvol                            ! potential temperature in liquid seawater
+      zsal  = zsal  / zvol                            ! Salinity of liquid seawater
+      !
+      CALL iom_put( 'masstot', zmass )
+      CALL iom_put( 'temptot', ztemp )
+      CALL iom_put( 'saltot' , zsal  )
+      !
+   END SUBROUTINE dia_ar5
+
+
+   SUBROUTINE dia_ar5_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_ar5_init  ***
+      !!                   
+      !! ** Purpose :   initialization of ....
+      !!
+      !! ** Method  :   blah blah blah ...
+      !!
+      !! ** input   :   Namlist namexa
+      !!
+      !! ** Action  :   ...  
+      !!----------------------------------------------------------------------
+      INTEGER  ::   inum
+      INTEGER  ::   ik
+      INTEGER  ::   ji, jj, jk  ! dummy loop indices
+      REAL(wp) ::   zztmp  
+      REAL(wp), DIMENSION(jpi,jpj,jpk, 2) ::   zsaldta   ! Jan/Dec levitus salinity
+      !!----------------------------------------------------------------------
+      !
+      area(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)
+
+      area_tot = SUM( area(:,:) )   ;   IF( lk_mpp )   CALL mpp_sum( area_tot )
+
+      vol0        = 0.e0
+      thick0(:,:) = 0.e0
+      DO jk = 1, jpkm1
+         vol0        = vol0        + SUM( area (:,:) * tmask(:,:,jk) ) * e3t_0(jk) 
+         thick0(:,:) = thick0(:,:) +    tmask_i(:,:) * tmask(:,:,jk)   * e3t_0(jk)
+      END DO
+      
+      CALL iom_open ( 'data_1m_salinity_nomask', inum )
+      CALL iom_get  ( inum, jpdom_data, 'vosaline', zsaldta(:,:,:,1), 1  )
+      CALL iom_get  ( inum, jpdom_data, 'vosaline', zsaldta(:,:,:,2), 12 )
+      CALL iom_close( inum )
+      sn0(:,:,:) = 0.5 * ( zsaldta(:,:,:,1) + zsaldta(:,:,:,2) )        
+      sn0(:,:,:) = sn0(:,:,:)*tmask(:,:,:)
+      IF( ln_zps ) THEN               ! z-coord. partial steps
+         DO jj = 1, jpj               ! interpolation of salinity at the last ocean level (i.e. the partial step)
+            DO ji = 1, jpi
+               ik = mbathy(ji,jj) - 1
+               IF( ik > 2 ) THEN
+                  zztmp = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
+                  sn0(ji,jj,ik) = (1.-zztmp) * sn0(ji,jj,ik) + zztmp * sn0(ji,jj,ik-1)
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE dia_ar5_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                         NO diaar5
+   !!----------------------------------------------------------------------
+
+   LOGICAL, PUBLIC, PARAMETER :: lk_diaar5 = .FALSE.   ! coupled flag
+
+CONTAINS
+
+   SUBROUTINE dia_ar5( kt )   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      WRITE(*,*) 'dia_ar5: You should not have seen this print! error?', kt
+   END SUBROUTINE dia_ar5
+#endif
+
+   !!======================================================================
+END MODULE diaar5
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diadimg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diadimg.F90	(revision 1844)
@@ -0,0 +1,202 @@
+MODULE diadimg
+   !!======================================================================
+   !!                     ***  MODULE  diadimg  ***
+   !! Ocean diagnostics :  write ocean output files in dimg direct access format (mpp)
+   !!=====================================================================
+# if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE daymod          ! calendar
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC dia_wri_dimg            ! called by trd_mld (eg)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+  SUBROUTINE dia_wri_dimg(cd_name, cd_text, ptab, klev, cd_type , ksubi )
+    !!-------------------------------------------------------------------------
+    !!        *** ROUTINE dia_wri_dimg ***
+    !!
+    !! ** Purpose : write ptab in the dimg file cd_name, with comment cd_text.
+    !!       ptab has klev x 2D fields
+    !!
+    !! ** Action :
+    !!       Define header variables from the config parameters
+    !!       Open the dimg file on unit inum = 14 ( IEEE I4R4 file )
+    !!       Write header on record 1
+    !!       Write ptab on the following klev records
+    !!
+    !! History :
+    !!   03-12 (J.M. Molines ) : Original. Replace ctl_opn, writn2d
+    !!---------------------------------------------------------------------------
+    !! * Arguments
+    CHARACTER(len=*),INTENT(in) ::   &
+         &                            cd_name,  &  ! dimg file name
+         &                            cd_text      ! comment to write on record #1
+    INTEGER, INTENT(in) ::            klev         ! number of level in ptab to write
+    REAL(wp),INTENT(in), DIMENSION(:,:,:) :: ptab  ! 3D array to write 
+    CHARACTER(LEN=1),INTENT(in) ::    cd_type      ! either 'T', 'W' or '2' , depending on the vertical
+    !                                              ! grid for ptab. 2 stands for 2D file
+    INTEGER, INTENT(in), OPTIONAL, DIMENSION(klev) :: ksubi 
+
+    !! * Local declarations
+    INTEGER :: jk, jn           ! dummy loop indices
+    INTEGER :: irecl4,             &    ! record length in bytes
+         &       inum,             &    ! logical unit (set to 14)
+         &       irec,             &    ! current record to be written
+         &       irecend                ! record number where nclit... are stored
+    REAL(sp)                    :: zdx,zdy,zspval,zwest,ztimm
+    REAL(sp)                    :: zsouth
+    REAL(sp),DIMENSION(jpi,jpj) :: z42d        ! 2d temporary workspace (sp)
+    REAL(sp),DIMENSION(jpk)     :: z4dep       ! vertical level (sp)
+
+    CHARACTER(LEN=80) :: clname                ! name of file in case of dimgnnn
+    CHARACTER(LEN=4) :: clver='@!01'           ! dimg string identifier
+    !!---------------------------------------------------------------------------
+
+    !! * Initialisations
+
+    irecl4 = MAX(jpi*jpj*sp , 84+(18+1+jpk)*sp )
+
+    zspval=0.0_sp    ! special values on land
+    !  the 'numerical' grid is described. The geographical one is in a grid file
+    zdx=1._sp
+    zdy=1._sp
+    zsouth=njmpp * 1._sp
+    zwest=nimpp * 1._sp
+    !  time in days since the historical begining of the run (nit000 = 0 ) 
+    ztimm=adatrj
+
+    SELECT CASE ( cd_type )
+
+    CASE ( 'T')
+       z4dep(:)=gdept_0(:)
+
+    CASE ( 'W' )
+       z4dep(:)=gdepw_0(:)
+
+    CASE ( '2' )
+       z4dep(1:klev) =(/(jk, jk=1,klev)/)
+
+    CASE ( 'I' )
+       z4dep(1:klev) = ksubi(1:klev)
+
+    CASE DEFAULT
+       IF(lwp) WRITE(numout,*) ' E R R O R : bad cd_type in dia_wri_dimg '
+       STOP 'dia_wri_dimg'
+
+    END SELECT
+
+    IF ( ln_dimgnnn  ) THEN
+     irecl4 = MAX(jpi*jpj*sp , 84+(18+jpk)*sp + 8*jpnij*sp  )
+       WRITE(clname,'(a,a,i3.3)') TRIM(cd_name),'.',narea
+       CALL ctl_opn(inum, clname,'UNKNOWN','UNFORMATTED','DIRECT',irecl4,numout,lwp)
+       WRITE(inum,REC=1 ) clver, cd_text, irecl4, &
+            &     jpi,jpj, klev, 1 , 1 ,            &
+            &     zwest, zsouth, zdx, zdy, zspval,  &
+            &     z4dep(1:klev),                    &
+            &     ztimm,                            &
+            &     narea, jpnij,jpiglo,jpjglo,jpizoom, jpjzoom,    &    ! extension to dimg for mpp output
+            &     nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt  !
+
+       !! * Write klev levels
+       IF ( cd_type == 'I' ) THEN
+
+          DO jk = 1, klev
+             irec =1 + jk
+             z42d(:,:) = ptab(:,:,ksubi(jk))
+             WRITE(inum,REC=irec)  z42d(:,:)
+          END DO
+       ELSE
+          DO jk = 1, klev
+             irec =1 + jk
+             z42d(:,:) = ptab(:,:,jk)
+             WRITE(inum,REC=irec)  z42d(:,:)
+          END DO
+       ENDIF
+    ELSE
+       clver='@!03'           ! dimg string identifier
+       ! note that version @!02 is optimized with respect to record length.
+       ! The vertical dep variable is reduced to klev instead of klev*jpnij :
+       !   this is OK for jpnij < 181 (jpk=46)
+       ! for more processors, irecl4 get huge and that's why we switch to '@!03':
+       !  In this case we just add an extra integer to the standard dimg structure,
+       !  which is a record number where the arrays nlci etc... starts (1 per record)
+       
+       !! Standard dimgproc (1 file per variable, all procs. write to this file )
+       !! * Open file
+       CALL ctl_opn(inum, cd_name,'UNKNOWN','UNFORMATTED','DIRECT',irecl4,numout,lwp)
+
+       !! * Write header on record #1
+       irecend=1 + klev*jpnij 
+       IF(lwp) WRITE(inum,REC=1 ) clver, cd_text, irecl4, &
+            &     jpi,jpj, klev, 1 , 1 ,            &
+            &     zwest, zsouth, zdx, zdy, zspval,  &
+            &     z4dep(1:klev),       &
+            &     ztimm,                            &
+            &     narea, jpnij,jpiglo,jpjglo,jpizoom, jpjzoom, irecend 
+       IF (lwp ) THEN
+         WRITE(inum,REC=irecend + 1 ) nlcit
+         WRITE(inum,REC=irecend + 2 ) nlcjt
+         WRITE(inum,REC=irecend + 3 ) nldit
+         WRITE(inum,REC=irecend + 4 ) nldjt
+         WRITE(inum,REC=irecend + 5 ) nleit
+         WRITE(inum,REC=irecend + 6 ) nlejt
+         WRITE(inum,REC=irecend + 7 ) nimppt
+         WRITE(inum,REC=irecend + 8 ) njmppt
+       ENDIF
+      !   &    ! extension to dimg for mpp output
+      !   &     nlcit,nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt  !
+
+       !! * Write klev levels
+       IF ( cd_type == 'I' ) THEN
+
+          DO jk = 1, klev
+             irec =1 + klev * (narea -1) + jk
+             z42d(:,:) = ptab(:,:,ksubi(jk))
+             WRITE(inum,REC=irec)  z42d(:,:)
+          END DO
+       ELSE
+          DO jk = 1, klev
+             irec =1 + klev * (narea -1) + jk
+             z42d(:,:) = ptab(:,:,jk)
+             WRITE(inum,REC=irec)  z42d(:,:)
+          END DO
+       ENDIF
+    ENDIF
+
+    !! * Close the file
+    CLOSE(inum)
+
+  END SUBROUTINE dia_wri_dimg
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dia_wri_dimg( cd_name, cd_exper, ptab, klev, cd_type )
+      REAL, DIMENSION(:,:,:) :: ptab
+      INTEGER :: klev
+      CHARACTER(LEN=80) :: cd_name, cd_exper,cd_type
+      WRITE(*,*) ' This print must never occur ', cd_name, cd_exper,ptab, klev, cd_type
+      WRITE(*,*) ' this routine is here just for compilation '
+   END SUBROUTINE dia_wri_dimg
+# endif
+   !!======================================================================
+END MODULE diadimg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diafwb.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 1844)
@@ -0,0 +1,439 @@
+MODULE diafwb
+   !!======================================================================
+   !!                       ***  MODULE  diafwb  ***
+   !! Ocean diagnostics: freshwater budget
+   !!======================================================================
+   !! History :  8.2  !  01-02  (E. Durand)  Original code
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!            9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!----------------------------------------------------------------------
+#if ( defined key_orca_r2 || defined  key_orca_r4 )  && ! defined key_coupled
+   !!----------------------------------------------------------------------
+   !!   "key_orca_r2 or 4"
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   dia_fwb     : freshwater budget for global ocean configurations
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE sbc_oce         ! ???
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dia_fwb    ! routine called by step.F90
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diafwb = .TRUE.    !: fresh water budget flag
+
+   REAL(wp)               ::   a_emp ,          &
+      &                        a_sshb, a_sshn, a_salb, a_saln
+   REAL(wp), DIMENSION(4) ::   a_flxi, a_flxo, a_temi, a_temo, a_sali, a_salo
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_fwb( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_fwb  ***
+      !!     
+      !! ** Purpose :
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER :: inum             ! temporary logical unit
+      INTEGER :: ji, jj, jk, jt   ! dummy loop indices
+      INTEGER :: ii0, ii1, ij0, ij1
+      REAL(wp) ::   zarea, zvol, zwei
+      REAL(wp) ::  ztemi(4), ztemo(4), zsali(4), zsalo(4), zflxi(4), zflxo(4)
+      REAL(wp) ::  zt, zs, zu  
+      REAL(wp) ::  zsm0, zempnew
+      !!----------------------------------------------------------------------
+
+      ! Mean global salinity
+      zsm0 = 34.72654
+
+      ! To compute emp mean value mean emp
+
+      IF( kt == nit000 ) THEN
+
+         a_emp    = 0.e0
+         a_sshb   = 0.e0 ! valeur de ssh au debut de la simulation
+         a_salb   = 0.e0 ! valeur de sal au debut de la simulation
+         ! sshb used because diafwb called after tranxt (i.e. after the swap)
+         a_sshb = SUM( e1t(:,:) * e2t(:,:) * sshb(:,:) * tmask_i(:,:) )
+         IF( lk_mpp )   CALL mpp_sum( a_sshb )      ! sum over the global domain
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zwei  = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  a_salb = a_salb + ( sb(ji,jj,jk) - zsm0 ) * zwei
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( a_salb )      ! sum over the global domain
+      ENDIF
+      
+      a_emp    = SUM( e1t(:,:) * e2t(:,:) * emp   (:,:) * tmask_i(:,:) )
+      IF( lk_mpp )   CALL mpp_sum( a_emp    )       ! sum over the global domain
+
+      IF( kt == nitend ) THEN
+         a_sshn = 0.e0
+         a_saln = 0.e0
+         zarea = 0.e0
+         zvol  = 0.e0
+         zempnew = 0.e0
+         ! Mean sea level at nitend
+         a_sshn = SUM( e1t(:,:) * e2t(:,:) * sshn(:,:) * tmask_i(:,:) )
+         IF( lk_mpp )   CALL mpp_sum( a_sshn )      ! sum over the global domain
+         zarea  = SUM( e1t(:,:) * e2t(:,:) *             tmask_i(:,:) )
+         IF( lk_mpp )   CALL mpp_sum( zarea  )      ! sum over the global domain
+         
+         DO jk = 1, jpkm1   
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zwei  = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  a_saln = a_saln + ( sn(ji,jj,jk) - zsm0 ) * zwei
+                  zvol  = zvol  + zwei
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( a_saln )      ! sum over the global domain
+         IF( lk_mpp )   CALL mpp_sum( zvol )      ! sum over the global domain
+         
+         ! Conversion in m3
+         a_emp    = a_emp * rdttra(1) * 1.e-3 
+         
+         ! emp correction to bring back the mean ssh to zero
+         zempnew = a_sshn / ( ( nitend - nit000 + 1 ) * rdt ) * 1.e3 / zarea
+
+      ENDIF
+
+
+      ! Calcul des termes de transport 
+      ! ------------------------------
+      
+      ! 1 --> Gibraltar 
+      ! 2 --> Cadiz 
+      ! 3 --> Red Sea
+      ! 4 --> Baltic Sea
+
+      IF( kt == nit000 ) THEN
+         a_flxi(:) = 0.e0
+         a_flxo(:) = 0.e0
+         a_temi(:) = 0.e0
+         a_temo(:) = 0.e0
+         a_sali(:) = 0.e0
+         a_salo(:) = 0.e0
+      ENDIF
+
+      zflxi(:) = 0.e0
+      zflxo(:) = 0.e0
+      ztemi(:) = 0.e0
+      ztemo(:) = 0.e0
+      zsali(:) = 0.e0
+      zsalo(:) = 0.e0
+
+      ! Mean flow at Gibraltar
+
+      IF( cp_cfg == "orca" ) THEN  
+               
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            ii0 = 70   ;   ii1 = 70
+            ij0 = 52   ;   ij1 = 52
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            ii0 = 140   ;   ii1 = 140
+            ij0 = 102   ;   ij1 = 102
+            !                                        ! =======================
+         CASE DEFAULT                                !    ORCA R05 or R025
+            !                                        ! =======================
+            CALL ctl_stop( ' dia_fwb Not yet implemented in ORCA_R05 or R025' )
+            ! 
+         END SELECT
+         ! 
+         DO ji = mi0(ii0), mi1(ii1)
+            DO jj = mj0(ij0), mj1(ij1)
+               DO jk = 1, jpk 
+                  zt = 0.5 * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) )
+                  zs = 0.5 * ( sn(ji,jj,jk) + sn(ji+1,jj,jk) )
+                  zu = un(ji,jj,jk) * fse3t(ji,jj,jk) * e2u(ji,jj)
+
+                  IF( un(ji,jj,jk) > 0.e0 ) THEN 
+                     zflxi(1) = zflxi(1) +    zu
+                     ztemi(1) = ztemi(1) + zt*zu
+                     zsali(1) = zsali(1) + zs*zu
+                  ELSE
+                     zflxo(1) = zflxo(1) +    zu
+                     ztemo(1) = ztemo(1) + zt*zu
+                     zsalo(1) = zsalo(1) + zs*zu
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+      
+      ! Mean flow at Cadiz
+      IF( cp_cfg == "orca" ) THEN
+               
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            ii0 = 69   ;   ii1 = 69
+            ij0 = 52   ;   ij1 = 52
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            ii0 = 137   ;   ii1 = 137
+            ij0 = 101   ;   ij1 = 102
+            !                                        ! =======================
+         CASE DEFAULT                                !    ORCA R05 or R025
+            !                                        ! =======================
+            CALL ctl_stop( ' dia_fwb Not yet implemented in ORCA_R05 or R025' )
+            ! 
+         END SELECT
+         ! 
+         DO ji = mi0(ii0), mi1(ii1)
+            DO jj = mj0(ij0), mj1(ij1)
+               DO jk = 1, jpk 
+                  zt = 0.5 * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) )
+                  zs = 0.5 * ( sn(ji,jj,jk) + sn(ji+1,jj,jk) )
+                  zu = un(ji,jj,jk) * fse3t(ji,jj,jk) * e2u(ji,jj)
+                  
+                  IF( un(ji,jj,jk) > 0.e0 ) THEN 
+                     zflxi(2) = zflxi(2) +    zu
+                     ztemi(2) = ztemi(2) + zt*zu
+                     zsali(2) = zsali(2) + zs*zu
+                  ELSE
+                     zflxo(2) = zflxo(2) +    zu
+                     ztemo(2) = ztemo(2) + zt*zu
+                     zsalo(2) = zsalo(2) + zs*zu
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      ! Mean flow at Red Sea entrance
+      IF( cp_cfg == "orca" ) THEN
+               
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            ii0 = 83   ;   ii1 = 83
+            ij0 = 45   ;   ij1 = 45
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            ii0 = 160   ;   ii1 = 160
+            ij0 = 88    ;   ij1 = 88 
+            !                                        ! =======================
+         CASE DEFAULT                                !    ORCA R05 or R025
+            !                                        ! =======================
+            CALL ctl_stop( ' dia_fwb Not yet implemented in ORCA_R05 or R025' )
+            ! 
+         END SELECT
+         ! 
+         DO ji = mi0(ii0), mi1(ii1)
+            DO jj = mj0(ij0), mj1(ij1)
+               DO jk = 1, jpk 
+                  zt = 0.5 * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) )
+                  zs = 0.5 * ( sn(ji,jj,jk) + sn(ji+1,jj,jk) )
+                  zu = un(ji,jj,jk) * fse3t(ji,jj,jk) * e2u(ji,jj)
+                  
+                  IF( un(ji,jj,jk) > 0.e0 ) THEN 
+                     zflxi(3) = zflxi(3) +    zu
+                     ztemi(3) = ztemi(3) + zt*zu
+                     zsali(3) = zsali(3) + zs*zu
+                  ELSE
+                     zflxo(3) = zflxo(3) +    zu
+                     ztemo(3) = ztemo(3) + zt*zu
+                     zsalo(3) = zsalo(3) + zs*zu
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      ! Mean flow at Baltic Sea entrance
+      IF( cp_cfg == "orca" ) THEN
+               
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            ii0 = 1     ;   ii1 = 1  
+            ij0 = 1     ;   ij1 = 1  
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            ii0 = 146   ;   ii1 = 146 
+            ij0 = 116   ;   ij1 = 116
+            !                                        ! =======================
+         CASE DEFAULT                                !    ORCA R05 or R025
+            !                                        ! =======================
+            CALL ctl_stop( ' dia_fwb Not yet implemented in ORCA_R05 or R025' )
+            ! 
+         END SELECT
+         ! 
+         DO ji = mi0(ii0), mi1(ii1)
+            DO jj = mj0(ij0), mj1(ij1)
+               DO jk = 1, jpk
+                  zt = 0.5 * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) )
+                  zs = 0.5 * ( sn(ji,jj,jk) + sn(ji+1,jj,jk) )
+                  zu = un(ji,jj,jk) * fse3t(ji,jj,jk) * e2u(ji,jj)
+                  
+                  IF( un(ji,jj,jk) > 0.e0 ) THEN 
+                     zflxi(4) = zflxi(4) +    zu
+                     ztemi(4) = ztemi(4) + zt*zu
+                     zsali(4) = zsali(4) + zs*zu
+                  ELSE
+                     zflxo(4) = zflxo(4) +    zu
+                     ztemo(4) = ztemo(4) + zt*zu
+                     zsalo(4) = zsalo(4) + zs*zu
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      ! Sum at each time-step
+      DO jt = 1, 4 
+         !
+         IF( zflxi(jt) /= 0.e0 ) THEN
+            a_flxi(jt) = a_flxi(jt) + zflxi(jt)
+            a_temi(jt) = a_temi(jt) + ztemi(jt)/zflxi(jt)
+            a_sali(jt) = a_sali(jt) + zsali(jt)/zflxi(jt)
+         ENDIF
+         !
+         IF( zflxo(jt) /= 0.e0 ) THEN
+            a_flxo(jt) = a_flxo(jt) + zflxo(jt)
+            a_temo(jt) = a_temo(jt) + ztemo(jt)/zflxo(jt)
+            a_salo(jt) = a_salo(jt) + zsalo(jt)/zflxo(jt)
+         ENDIF
+         !
+      END DO
+
+      IF( kt == nitend ) THEN
+         DO jt = 1, 4 
+            a_flxi(jt) = a_flxi(jt) / ( FLOAT( nitend - nit000 + 1 ) * 1.e6 )
+            a_temi(jt) = a_temi(jt) /   FLOAT( nitend - nit000 + 1 )
+            a_sali(jt) = a_sali(jt) /   FLOAT( nitend - nit000 + 1 )
+            a_flxo(jt) = a_flxo(jt) / ( FLOAT( nitend - nit000 + 1 ) * 1.e6 )
+            a_temo(jt) = a_temo(jt) /   FLOAT( nitend - nit000 + 1 )
+            a_salo(jt) = a_salo(jt) /   FLOAT( nitend - nit000 + 1 )
+         END DO
+         IF( lk_mpp ) THEN
+            CALL mpp_sum( a_flxi, 4 )      ! sum over the global domain
+            CALL mpp_sum( a_temi, 4 )      ! sum over the global domain
+            CALL mpp_sum( a_sali, 4 )      ! sum over the global domain
+
+            CALL mpp_sum( a_flxo, 4 )      ! sum over the global domain
+            CALL mpp_sum( a_temo, 4 )      ! sum over the global domain
+            CALL mpp_sum( a_salo, 4 )      ! sum over the global domain
+         ENDIF
+      ENDIF
+
+
+      ! Ecriture des diagnostiques 
+      ! --------------------------
+
+      IF ( kt == nitend .AND. cp_cfg == "orca" .AND. lwp ) THEN
+
+         CALL ctl_opn( inum, 'STRAIT.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         WRITE(inum,*)
+         WRITE(inum,*)    'Net freshwater budget '
+         WRITE(inum,9010) '  emp    = ',a_emp,   ' m3 =', a_emp   /(FLOAT(nitend-nit000+1)*rdttra(1)) * 1.e-6,' Sv'
+         WRITE(inum,*)
+         WRITE(inum,9010) '  zarea =',zarea
+         WRITE(inum,9010) '  zvol  =',zvol
+         WRITE(inum,*)
+         WRITE(inum,*)    'Mean sea level : '
+         WRITE(inum,9010) '  at nit000 = ',a_sshb        ,' m3 '
+         WRITE(inum,9010) '  at nitend = ',a_sshn        ,' m3 '
+         WRITE(inum,9010) '  diff      = ',(a_sshn-a_sshb),' m3 =', (a_sshn-a_sshb)/(FLOAT(nitend-nit000+1)*rdt) * 1.e-6,' Sv'
+         WRITE(inum,9020) '  mean sea level elevation    =', a_sshn/zarea,' m'
+         WRITE(inum,*)
+         WRITE(inum,*)    'Anomaly of salinity content : '
+         WRITE(inum,9010) '  at nit000 = ',a_salb        ,' psu.m3 '
+         WRITE(inum,9010) '  at nitend = ',a_saln        ,' psu.m3 '
+         WRITE(inum,9010) '  diff      = ',(a_saln-a_salb),' psu.m3'
+         WRITE(inum,*)
+         WRITE(inum,*)    'Mean salinity : '
+         WRITE(inum,9020) '  at nit000 =',a_salb/zvol+zsm0   ,' psu '
+         WRITE(inum,9020) '  at nitend =',a_saln/zvol+zsm0   ,' psu '
+         WRITE(inum,9020) '  diff      =',(a_saln-a_salb)/zvol,' psu'
+         WRITE(inum,9020) '  S-SLevitus=',a_saln/zvol,' psu'
+         WRITE(inum,*)
+         WRITE(inum,*)    'Gibraltar : '
+         WRITE(inum,9030) '  Flux entrant (Sv) :', a_flxi(1)
+         WRITE(inum,9030) '  Flux sortant (Sv) :', a_flxo(1)
+         WRITE(inum,9030) '  T entrant (deg)   :', a_temi(1)
+         WRITE(inum,9030) '  T sortant (deg)   :', a_temo(1)
+         WRITE(inum,9030) '  S entrant (psu)   :', a_sali(1)
+         WRITE(inum,9030) '  S sortant (psu)   :', a_salo(1)
+         WRITE(inum,*)
+         WRITE(inum,*)    'Cadiz : '
+         WRITE(inum,9030) '  Flux entrant (Sv) :', a_flxi(2)
+         WRITE(inum,9030) '  Flux sortant (Sv) :', a_flxo(2)
+         WRITE(inum,9030) '  T entrant (deg)   :', a_temi(2)
+         WRITE(inum,9030) '  T sortant (deg)   :', a_temo(2)
+         WRITE(inum,9030) '  S entrant (psu)   :', a_sali(2)
+         WRITE(inum,9030) '  S sortant (psu)   :', a_salo(2)
+         WRITE(inum,*)
+         WRITE(inum,*)    'Bab el Mandeb : '
+         WRITE(inum,9030) '  Flux entrant (Sv) :', a_flxi(3)
+         WRITE(inum,9030) '  Flux sortant (Sv) :', a_flxo(3)
+         WRITE(inum,9030) '  T entrant (deg)   :', a_temi(3)
+         WRITE(inum,9030) '  T sortant (deg)   :', a_temo(3)
+         WRITE(inum,9030) '  S entrant (psu)   :', a_sali(3)
+         WRITE(inum,9030) '  S sortant (psu)   :', a_salo(3)
+         WRITE(inum,*)
+         WRITE(inum,*)    'Baltic : '
+         WRITE(inum,9030) '  Flux entrant (Sv) :', a_flxi(4)
+         WRITE(inum,9030) '  Flux sortant (Sv) :', a_flxo(4)
+         WRITE(inum,9030) '  T entrant (deg)   :', a_temi(4)
+         WRITE(inum,9030) '  T sortant (deg)   :', a_temo(4)
+         WRITE(inum,9030) '  S entrant (psu)   :', a_sali(4)
+         WRITE(inum,9030) '  S sortant (psu)   :', a_salo(4)
+         CLOSE(inum)
+      ENDIF
+
+ 9005 FORMAT(1X,A,ES24.16)
+ 9010 FORMAT(1X,A,ES12.5,A,F10.5,A)
+ 9020 FORMAT(1X,A,F10.5,A)
+ 9030 FORMAT(1X,A,F9.4,A)
+
+   END SUBROUTINE dia_fwb
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Dummy Module
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diafwb = .FALSE.    !: fresh water budget flag
+CONTAINS
+   SUBROUTINE dia_fwb( kt )        ! Empty routine
+      WRITE(*,*) 'dia_fwb: : You should not have seen this print! error?', kt
+   END SUBROUTINE dia_fwb
+#endif
+
+   !!======================================================================
+END MODULE diafwb
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diagap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diagap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diagap.F90	(revision 1844)
@@ -0,0 +1,267 @@
+MODULE diagap
+   !!======================================================================
+   !!                       ***  MODULE  diagap  ***
+   !! Ocean diagnostics : computation of model-data tracer gap
+   !!======================================================================
+   !! History :  OPA  ! 1991-10  (G. Madec)  Original code
+   !!            7.0  ! 1992-07  (M. Imbard)  Add variance and mpp staff
+   !!   NEMO     1.0  ! 2002-07  (G. Madec)  Free form, F90
+   !!----------------------------------------------------------------------
+#if defined key_diagap
+   !!----------------------------------------------------------------------
+   !!   'key_diagap' :                           model-data gap diagnostics
+   !!----------------------------------------------------------------------
+   !!   dia_gap      : model and data level mean temperature and salinity
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE dtatem          ! ???
+   USE dtasal          ! ???
+   USE dianam          ! build name of file (routine)
+   USE lib_mpp         ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_gap    ! called in step.F90 module
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diagap = .TRUE.   !: model-data diagnostics flag
+
+   !                         !!* Namelist namgap : model-data gap
+   INTEGER ::   nn_gap = 15   ! time step frequency
+   INTEGER ::   nn_prg = 15   ! switch for control print
+
+   INTEGER ::   numgap                      ! logical unit for differences diagnostic
+   INTEGER ::   nhoridg, ndepidg, ndex(1)   ! netcdf files and index common
+
+   REAL(wp) ::   vol                        ! total ocean volume
+
+   REAL(wp), DIMENSION(jpk) ::   volk , volkr   ! level ocean volume and its inverse
+   REAL(wp), DIMENSION(jpk) ::   tdtag, sdtag   ! level mean data temperature & salinity
+   REAL(wp), DIMENSION(jpk) ::   tmodg, smodg   ! level mean model temperature & salinity
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_gap( kt )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE dia_gap  ***
+      !!
+      !! ** Purpose :   Compute model and data level mean T and S profiles
+      !!              and output it in numgap (NetCDF or direct access file)
+      !!
+      !! ** Method :   tracers (model) : tn, sn
+      !!               tracers (data)  : t_dta, s_dta
+      !!               difference between model and data tracers
+      !!               variance between model and data tracers
+      !!
+      !! ** Action  :   output in file numgap
+      !!----------------------------------------------------------------------
+      USE ioipsl
+      !!
+      INTEGER, INTENT(in) ::   kt           ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      INTEGER ::   it, itmod    ! time step indices
+      CHARACTER (len=40) ::   clhstnam
+      CHARACTER (len=40) ::   clop
+      REAL(wp) ::   zbt, zdt    ! temporary scalar
+      REAL(wp) ::   zsto, zout, zmax, zjulian
+      REAL(wp), DIMENSION(jpi) ::   zfoo
+      REAL(wp), DIMENSION(jpj) ::   zloo
+      !!
+      NAMELIST/namgap/ nn_gap, nn_prg
+      !!----------------------------------------------------------------------
+
+      ! 0. initialization
+      ! -----------------
+      zdt = rdt
+      IF( nacc == 1 )   zdt = rdtmin
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dia_gap : level mean model-data gap'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+         REWIND( numnam )            ! Read diagap parameters in namelist namgap
+         READ( numnam, namgap )
+
+         IF(lwp) WRITE(numout,*) '          time step frequency for gap     nn_gap  = ',nn_gap
+         IF(lwp) WRITE(numout,*) '          switch for control print gap    nn_prg  = ',nn_prg
+
+         ! horizontal slab volume (tmask_i to take into account only interior ocean domain)
+         volk(:) = 0.e0
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask_i(ji,jj)
+                  volk(jk) = volk(jk) + tmask(ji,jj,jk) * zbt
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( volk, jpk )   ! sum over the global domain
+
+         volkr(:) = 0.e0
+         DO jk = 1, jpk
+            IF( volk(jk) /= 0.e0 )   volkr(jk) = 1.e0 / volk(jk)
+         END DO
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) '     volume of each horizontal slab (km3) :'
+            DO jk = 1, jpkm1
+               WRITE(numout,9010) jk, volk(jk) * 1.e-9
+            END DO
+         ENDIF
+9010     FORMAT( 9X, 'level ', i3, f15.3 )
+
+         ! basin volume
+         vol = 0.e0
+         DO jk = 1, jpkm1
+            vol = vol + volk(jk)
+         END DO
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '     basin volume : ',vol*1.e-9, '  km3'
+
+         ! OPEN netcdf file 
+
+         ! Define frequency of output and means
+         zsto = nn_gap * zdt
+         IF( ln_mskland )   THEN   ;   clop = "ave(only(x))"   ! put 1.e+20 on land (very expensive!!)
+         ELSE                      ;   clop = "ave(x)"         ! no use of the mask value (require less cpu time)
+         ENDIF
+         zout = nn_gap * zdt
+         zmax = FLOAT( nitend - nit000 + 1 ) * zdt
+         zfoo(1:jpi) = 0.e0
+         zloo(1:jpj) = 0.e0
+
+         ! Compute julian date from starting date of the run
+
+         CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+
+         CALL dia_nam( clhstnam, nn_gap, 'diagap' )
+         IF(lwp) WRITE(numout,*) 'Name of diagap NETCDF file ', clhstnam
+         ! Horizontal grid : zphi()
+         CALL histbeg( clhstnam, 1, zfoo, 1, zloo,   &
+                       1, 1, 1, 1, nit000-1, zjulian, zdt, nhoridg, numgap, domain_id=nidom )
+         ! Vertical grids : gdept, gdepw
+         CALL histvert( numgap, "deptht", "Vertical T levels",   &
+                         "m", jpk, gdept_0, ndepidg, "down" )
+
+         ! define fields to be stored
+         ! mo(temp/sali)(da/mo/va): mean ocean temperature/salinity data/model/differences
+
+          CALL histdef( numgap, "motempda", "Mean Data Temperature","C",   &
+                        1, 1, nhoridg, jpk, 1, jpk, ndepidg, 32, clop,   &
+                        zsto,zout )
+          CALL histdef(numgap, "mosalida", "Mean Data Salinity","PSU",   &
+                        1, 1, nhoridg, jpk, 1, jpk, ndepidg, 32, clop,   &
+                        zsto,zout )
+          CALL histdef(numgap, "motempmo", "Mean Model Temperature","C",   &
+                        1, 1, nhoridg, jpk, 1, jpk, ndepidg, 32, clop,   &
+                        zsto,zout )
+          CALL histdef(numgap, "mosalimo", "Mean Model Salinity","PSU",   &
+                        1, 1, nhoridg, jpk, 1, jpk, ndepidg, 32, clop,   &
+                        zsto,zout )
+          CALL histend( numgap )
+          ndex(1) = 0
+      ENDIF
+
+
+      ! 1. horizontal averaged
+      ! ----------------------
+
+      itmod = kt - nit000 + 1       ! define time axis
+      it = kt 
+      IF( MOD( itmod, nn_gap ) == 0 ) THEN
+
+         ! initialization
+         tdtag(:) = 0.e0
+         sdtag(:) = 0.e0
+         tmodg(:) = 0.e0
+         smodg(:) = 0.e0
+         
+         !  c a u t i o n  : use of tmask_i : average over the interior domain only
+         
+         ! sum
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+              DO ji = 1, jpi
+                zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask_i(ji,jj)
+                tdtag(jk) = tdtag(jk) + zbt * t_dta(ji,jj,jk) * volkr(jk)
+                sdtag(jk) = sdtag(jk) + zbt * s_dta(ji,jj,jk) * volkr(jk)
+                tmodg(jk) = tmodg(jk) + zbt * tn  (ji,jj,jk) * volkr(jk)
+                smodg(jk) = smodg(jk) + zbt * sn  (ji,jj,jk) * volkr(jk)
+              END DO  
+            END DO  
+         END DO
+
+         ! 2. Basin averaged
+         ! -----------------
+         DO jk = 1, jpkm1
+            tdtag(jpk) = tdtag(jpk) + tdtag(jk) * volk(jk) / vol
+            sdtag(jpk) = sdtag(jpk) + sdtag(jk) * volk(jk) / vol
+            tmodg(jpk) = tmodg(jpk) + tmodg(jk) * volk(jk) / vol
+            smodg(jpk) = smodg(jpk) + smodg(jk) * volk(jk) / vol
+         END DO  
+          IF( lk_mpp)   CALL mpp_sum( tdtag, jpk )   ! sum over the global domain
+          IF( lk_mpp)   CALL mpp_sum( sdtag, jpk )
+          IF( lk_mpp)   CALL mpp_sum( tmodg, jpk )
+          IF( lk_mpp)   CALL mpp_sum( smodg, jpk )
+
+          ! 3.  Averaged output in file numgap
+          ! ----------------------------======
+          IF( MOD( itmod, nn_prg ) == 0 ) THEN
+              IF(lwp) THEN
+                  WRITE(numout,*) 'dia_gap: time step = ', kt, 'model - data'
+                  WRITE(numout,9300)
+                  DO jk = 1, jpk
+                    WRITE(numout,9310) tdtag(jk), tmodg(jk), tdtag(jk) - tmodg(jk), jk, fsdept(1,1,jk),   &
+                       &               sdtag(jk), smodg(jk), sdtag(jk) - smodg(jk)
+                  END DO  
+              ENDIF
+          ENDIF
+
+ 9300     FORMAT('  T-data  T-model    diff.   level  depth    S-data  S-model    diff.' )
+ 9310     FORMAT( 3(f8.3,1x),i5,f9.0,2x,3(f8.3,1x) )
+
+          ! Output in file numgap
+
+          ! Netcdf write
+
+          IF (lwp ) THEN   ! Ok even in mpp after the call to mpp_sum
+             CALL histwrite( numgap, "motempda", it, tdtag, jpk, ndex )
+             CALL histwrite( numgap, "mosalida", it, sdtag, jpk, ndex )
+             CALL histwrite( numgap, "motempmo", it, tmodg, jpk, ndex )
+             CALL histwrite( numgap, "mosalimo", it, smodg, jpk, ndex )
+          END IF
+      ENDIF
+
+      ! Closing numgap file
+      IF( kt == nitend ) THEN
+         CALL histclo( numgap )      !   Netcdf file
+      ENDIF 
+      !
+   END SUBROUTINE dia_gap
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Dummy module
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diagap = .FALSE.    !: diagap flag
+CONTAINS
+   SUBROUTINE dia_gap( kt )           ! Dummy routine
+      WRITE(*,*) 'dia_gap: You should not have seen this print! error?', kt
+   END SUBROUTINE dia_gap
+#endif
+
+   !!======================================================================
+END MODULE diagap
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahdy.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahdy.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahdy.F90	(revision 1844)
@@ -0,0 +1,267 @@
+MODULE diahdy
+   !!======================================================================
+   !!                       ***  MODULE  diahdy  ***
+   !! Ocean diagnostics : computation the dynamical heigh
+   !!======================================================================
+#if   defined key_diahdy   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_diahdy' :                          dynamical heigh diagnostics
+   !!----------------------------------------------------------------------
+   !!   dia_hdy      : dynamical heigh computation
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dia_hdy     ! called in step.F90 module
+
+   !! * Shared module variables
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diahdy = .TRUE.   !: dynamical heigh flag
+
+   !! * Module variables
+   REAL(wp), DIMENSION(jpk) ::   &
+      rhosp         ! ???
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      hdy           ! dynamical heigh
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE dia_hdy ( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_hdy  ***
+      !!
+      !! ** Purpose :   Computes the dynamical heigh
+      !!
+      !! ** Method  : Millero + Poisson
+      !!
+      !! References : 
+      !!	A. E. Gill, atmosphere-ocean dynamics 7.7 pp 215
+      !!
+      !! History :
+      !!        !  9x-xx (P. Delecluse, C. Perigaud)  Original code
+      !!        !  93-10  (C. Perigaud)  a trapezoidal vertical integration 
+      !!                                 consistent WITH the code
+      !!        !  93-12  (G. Madec M. Imbard)
+      !!        !  96-03  (N. Ferry)  integration at t-points
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER :: ji, jj, jk
+      INTEGER :: ihdsup, ik
+
+      REAL(wp) :: zgdsup, za, zb, zciint, zfacto, zhd
+      REAL(wp) :: zp, zh, zt, zs, zxk, zq, zsr, zr1, zr2, zr3, zr4
+      REAL(wp) :: ze, zbw, zc, zd, zaw, zb1, za1, zkw, zk0
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zsva
+      REAL(wp), DIMENSION(jpk)         :: zwkx, zwky, zwkz
+      REAL(wp) :: fsatg
+      REAL(wp) :: pfps, pfpt, pfphp  
+
+      ! Adiabatic laspse rate fsatg, defined as the change of temperature
+      ! per unit pressure for adiabatic change of pressure of an element
+      ! of seawater (bryden,h.,1973,deep-sea res.,20,401-408).
+      ! units:
+      !      pressure        pfphp    decibars
+      !      temperature     pfpt     deg celsius (ipts-68)
+      !      salinity        pfps     (ipss-78)
+      !      adiabatic       fsatg    deg. c/decibar
+      ! checkvalue: atg=3.255976e-4 c/dbar for pfps=40 (ipss-78),
+      ! pfpt=40 deg c, pfphp=10000 decibars
+      
+      fsatg(pfps,pfpt,pfphp)   &
+         = (((-2.1687e-16*pfpt+1.8676e-14)*pfpt-4.6206e-13)*pfphp    &
+         +((2.7759e-12*pfpt-1.1351e-10)*(pfps-35.)+((-5.4481e-14*pfpt    &
+         +8.733e-12)*pfpt-6.7795e-10)*pfpt+1.8741e-8))*pfphp    &
+         +(-4.2393e-8*pfpt+1.8932e-6)*(pfps-35.)    &
+         +((6.6228e-10*pfpt-6.836e-8)*pfpt+8.5258e-6)*pfpt+3.5803e-5
+      !!----------------------------------------------------------------------
+
+      ! 1. height dynamic
+      ! -----------------
+      ! depth for reference
+
+      zgdsup = 1500.
+      
+      ! below for hdyn levitus
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dia_hdy : computation of dynamical heigh'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+         IF( .NOT. ln_zco )   &
+              &   CALL ctl_stop( '          ln_zps or ln_sco, Dynamical height diagnostics not yet implemented' )
+         DO jk = 1, jpk
+            IF( gdepw_0(jk) > zgdsup ) GOTO 110
+         END DO
+         IF(lwp) WRITE(numout,*)'problem zgdsup greater than gdepw(jpk)'
+         STOP 'dia_hdy'
+110      CONTINUE
+         ihdsup = jk - 1
+         IF(lwp) WRITE(numout,*)' ihdsup = ', ihdsup
+
+         ! Interpolation coefficients for zgdsup-gdepw(ihdsup) layer
+
+         za = gdepw_0(ihdsup  )
+         zb = gdepw_0(ihdsup+1)
+         IF( za > zgdsup .OR. zb < zgdsup ) THEN
+            IF(lwp) WRITE(numout,*) za, zb, ihdsup, zgdsup
+            IF(lwp) WRITE(numout,*) ' bad ihdsup'
+            STOP
+         ENDIF
+         
+         zciint = (zgdsup - za) / (zb - za)
+
+         ! Computes the specific volume reference in situ temperature
+         
+         DO jk = 1, jpk
+            zp = 0.e0
+            zh = gdept_0(jk)
+            zt = 0.e0
+            zs = 35.
+            zxk= zh * fsatg( zs, zt, zp )
+            zt = zt + 0.5 * zxk
+            zq = zxk
+            zp = zp + 0.5 * zh
+            zxk= zh*fsatg( zs, zt, zp )
+            zt = zt + 0.29289322 * ( zxk - zq )
+            zq = 0.58578644 * zxk + 0.121320344 * zq
+            zxk= zh * fsatg( zs, zt, zp )
+            zt = zt + 1.707106781 * ( zxk - zq )
+            zq = 3.414213562 * zxk - 4.121320344 * zq
+            zp = zp + 0.5 * zh
+            zxk= zh * fsatg( zs, zt, zp )
+            zwkx(jk) = zt + ( zxk - 2.0 * zq ) / 6.0
+         END DO
+
+         ! In situ density (add the compression terms)
+
+         DO jk = 1, jpk
+            zt = zwkx(jk)
+            zs = 35.
+            ! square root salinity
+            zsr = sqrt( abs( zs ) )
+            zwky(jk) = zsr
+            ! compute density pure water at atm pressure
+            zr1= ((((6.536332e-9*zt-1.120083e-6)*zt+1.001685e-4)*zt   &
+               -9.095290e-3)*zt+6.793952e-2)*zt+999.842594
+            ! seawater density atm pressure
+            zr2= (((5.3875e-9*zt-8.2467e-7)*zt+7.6438e-5)*zt   &
+               -4.0899e-3)*zt+8.24493e-1
+            zr3= (-1.6546e-6*zt+1.0227e-4)*zt-5.72466e-3
+            zr4= 4.8314e-4
+            zwkz(jk)= (zr4*zs + zr3*zsr + zr2)*zs + zr1
+         END DO
+
+         DO jk = 1, jpk
+            zt = zwkx(jk)
+            zs = 35.
+            zsr= zwky(jk)
+            zh = gdept_0(jk)
+
+            ze = ( 9.1697e-11*zt+2.0816e-9 ) *zt-9.9348e-8
+            zbw= ( 5.2787e-9*zt-6.12293e-7 ) * zt+8.50935e-6
+            zb = zbw + ze * zs
+
+            zd = 1.91075e-4
+            zc = (-1.6078e-6*zt-1.0981e-5)*zt+2.2838e-3
+            zaw= ((-5.77905e-7*zt+1.16092e-4)*zt+1.43713e-3)*zt+3.239908
+            za = ( zd*zsr + zc)*zs + zaw
+
+            zb1= (-5.3009e-3*zt+1.6483e-1)*zt+7.944e-1
+            za1= ((-6.1670e-4*zt+1.09987e-1)*zt-6.03459)*zt+546.746
+            zkw= (((-5.155288e-4*zt+1.360477e-1)*zt-23.27105)*zt   &
+                +1484.206)*zt+196522.1
+            zk0= (zb1*zsr + za1)*zs + zkw
+            ! evaluate pressure polynomial
+            zwkz(jk) = zwkz(jk) / ( 1.0 - zh / ( zk0+zh*(za+zb*zh) ) )
+         END DO
+
+         DO jk = 1, jpk
+            rhosp(jk) = zwkz(jk)
+         END DO
+      ENDIF
+
+      ! Computes the specific volume anomaly
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) /= 0. ) THEN
+                  zsva(ji,jj,jk) = ( rau0*rhd(ji,jj,jk)+rau0 -rhosp(jk) ) / rhosp(jk)
+               ELSE
+                  zsva(ji,jj,jk)=0.
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! zfacto coefficient to cmg
+      
+      ! zfacto= 1.  e+2
+      !           mg->cmg
+      zfacto = 1.0 * 1.e2
+      
+      ! Fisrt compute at depth ik=ihdsup
+      
+      ik = ihdsup
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zhd = zfacto * zciint * e3t_0(ik) * zsva(ji,jj,ik)
+            hdy(ji,jj,ik) = zhd * tmask(ji,jj,ik) * tmask(ji,jj,ik-1)
+         END DO
+      END DO
+      
+      ! Then compute other terms except level jk=1
+      
+      DO jk = ihdsup-1, 2, -1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zhd = hdy(ji,jj,jk+1) + zfacto * e3t_0(jk) * zsva(ji,jj,jk)
+               hdy(ji,jj,jk) = zhd * tmask(ji,jj,jk) * tmask(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      
+      ! Then compute other the last layer term jk=1
+      
+      ik = 1
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zhd = hdy(ji,jj,ik+1) + zfacto * e3t_0(ik) * zsva(ji,jj,ik)
+            hdy(ji,jj,ik) = zhd * tmask(ji,jj,ik)
+         END DO
+      END DO
+
+   END SUBROUTINE dia_hdy
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                       NO dynamic heigh diagnostics
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diahdy = .FALSE.   !: dynamical heigh flag
+CONTAINS
+   SUBROUTINE dia_hdy( kt )               ! Empty routine
+      WRITE(*,*) 'diahdy: You should not have seen this print! error?', kt
+   END SUBROUTINE dia_hdy
+#endif
+
+   !!======================================================================
+END MODULE diahdy
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahth.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahth.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diahth.F90	(revision 1844)
@@ -0,0 +1,321 @@
+MODULE diahth
+   !!======================================================================
+   !!                       ***  MODULE  diahth  ***
+   !! Ocean diagnostics: thermocline and 20 degree depth
+   !!======================================================================
+   !! History :  OPA  !  1994-09  (J.-P. Boulanger)  Original code
+   !!                 !  1996-11  (E. Guilyardi)  OPA8 
+   !!                 !  1997-08  (G. Madec)  optimization
+   !!                 !  1999-07  (E. Guilyardi)  hd28 + heat content 
+   !!            8.5  !  2002-06  (G. Madec)  F90: Free form and module
+   !!   NEMO     3.2  !  2009-07  (S. Masson) hc300 bugfix + cleaning + add new diag
+   !!----------------------------------------------------------------------
+
+#if   defined key_diahth   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_diahth' :                              thermocline depth diag.
+   !!----------------------------------------------------------------------
+   !!   dia_hth      : Compute varius diagnostics associated with the mixed layer
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dia_hth    ! routine called by step.F90
+
+   !! * Shared module variables
+   LOGICAL , PUBLIC, PARAMETER          ::   lk_diahth = .TRUE.   !: thermocline-20d depths flag
+   ! note: following variables should move to local variables once iom_put is always used 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hth                  !: depth of the max vertical temperature gradient [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hd20                 !: depth of 20 C isotherm                         [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hd28                 !: depth of 28 C isotherm                         [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   htc3                 !: heat content of first 300 m                    [W]
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_hth( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_hth  ***
+      !!
+      !! ** Purpose : Computes
+      !!      the mixing layer depth (turbocline): avt = 5.e-4
+      !!      the depth of strongest vertical temperature gradient
+      !!      the mixed layer depth with density     criteria: rho = rho(10m or surf) + 0.03(or 0.01)
+      !!      the mixed layer depth with temperature criteria: abs( tn - tn(10m) ) = 0.2       
+      !!      the top of the thermochine: tn = tn(10m) - ztem2 
+      !!      the pycnocline depth with density criteria equivalent to a temperature variation 
+      !!                rho = rho10m + (dr/dT)(T,S,10m)*(-0.2 degC) 
+      !!      the barrier layer thickness
+      !!      the maximal verical inversion of temperature and its depth max( 0, max of tn - tn(10m) )
+      !!      the depth of the 20 degree isotherm (linear interpolation)
+      !!      the depth of the 28 degree isotherm (linear interpolation)
+      !!      the heat content of first 300 m
+      !!
+      !! ** Method : 
+      !!
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER                          ::   ji, jj, jk            ! dummy loop arguments
+      INTEGER                          ::   iid, iif, ilevel      ! temporary integers
+      INTEGER, DIMENSION(jpi,jpj)      ::   ik20, ik28            ! levels
+      REAL(wp)                         ::   zavt5 = 5.e-4_wp      ! Kz criterion for the turbocline depth
+      REAL(wp)                         ::   zrho3 = 0.03_wp       ! density     criterion for mixed layer depth
+      REAL(wp)                         ::   zrho1 = 0.01_wp       ! density     criterion for mixed layer depth
+      REAL(wp)                         ::   ztem2 = 0.2_wp        ! temperature criterion for mixed layer depth
+      REAL(wp)                         ::   zthick_0, zcoef       ! temporary scalars
+      REAL(wp)                         ::   zztmp, zzdep          ! temporary scalars inside do loop
+      REAL(wp)                         ::   zu, zv, zw, zut, zvt  ! temporary workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zabs2                 ! MLD: abs( tn - tn(10m) ) = ztem2 
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztm2                  ! Top of thermocline: tn = tn(10m) - ztem2     
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zrho10_3              ! MLD: rho = rho10m + zrho3      
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zpycn                 ! pycnocline: rho = rho10m + (dr/dT)(T,S,10m)*(-0.2 degC)
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztinv                 ! max of temperature inversion
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdepinv               ! depth of temperature inversion
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zrho0_3               ! MLD rho = rho(surf) = 0.03
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zrho0_1               ! MLD rho = rho(surf) = 0.01
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zmaxdzT               ! max of dT/dz
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zthick                ! vertical integration thickness 
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdelr                 ! delta rho equivalent to deltaT = 0.2
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dia_hth : diagnostics of the thermocline depth'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      ! initialization
+      ztinv  (:,:) = 0.e0_wp  
+      zdepinv(:,:) = 0.e0_wp  
+      zmaxdzT(:,:) = 0.e0_wp  
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zztmp = bathy(ji,jj)
+            hth     (ji,jj) = zztmp
+            zabs2   (ji,jj) = zztmp
+            ztm2    (ji,jj) = zztmp
+            zrho10_3(ji,jj) = zztmp
+            zpycn   (ji,jj) = zztmp
+        END DO
+      END DO
+      IF( nla10 > 1 ) THEN 
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zztmp = bathy(ji,jj)
+               zrho0_3(ji,jj) = zztmp
+               zrho0_1(ji,jj) = zztmp
+            END DO
+         END DO
+      ENDIF
+      
+      ! Preliminary computation
+      ! computation of zdelr = (dr/dT)(T,S,10m)*(-0.2 degC)
+      DO jj=1, jpj
+         DO ji=1, jpi
+            IF( tmask(ji,jj,nla10) == 1. ) THEN
+               zu  =  1779.50 + 11.250*tn(ji,jj,nla10) - 3.80*sn(ji,jj,nla10) - 0.0745*tn(ji,jj,nla10)*tn(ji,jj,nla10)   &
+                  &                                                           - 0.0100*tn(ji,jj,nla10)*sn(ji,jj,nla10)
+               zv  =  5891.00 + 38.000*tn(ji,jj,nla10) + 3.00*sn(ji,jj,nla10) - 0.3750*tn(ji,jj,nla10)*tn(ji,jj,nla10)
+               zut =    11.25 -  0.149*tn(ji,jj,nla10) - 0.01*sn(ji,jj,nla10)
+               zvt =    38.00 -  0.750*tn(ji,jj,nla10)
+               zw  = (zu + 0.698*zv) * (zu + 0.698*zv)
+               zdelr(ji,jj) = ztem2 * (1000.*(zut*zv - zvt*zu)/zw)
+            ELSE
+               zdelr(ji,jj) = 0.e0
+            ENDIF
+         END DO
+      END DO
+
+      ! ------------------------------------------------------------- !
+      ! thermocline depth: strongest vertical gradient of temperature !
+      ! turbocline depth (mixing layer depth): avt = zavt5            !
+      ! MLD: rho = rho(1) + zrho3                                     !
+      ! MLD: rho = rho(1) + zrho1                                     !
+      ! ------------------------------------------------------------- !
+      DO jk = jpkm1, 2, -1   ! loop from bottom to 2
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zzdep = fsdepw(ji,jj,jk)
+               zztmp = ( tn(ji,jj,jk-1) - tn(ji,jj,jk) ) / zzdep * tmask(ji,jj,jk)   ! vertical gradient of temperature (dT/dz)
+               zzdep = zzdep * tmask(ji,jj,1)
+
+               IF( zztmp > zmaxdzT(ji,jj) ) THEN                        
+                  zmaxdzT(ji,jj) = zztmp   ;   hth    (ji,jj) = zzdep                ! max and depth of dT/dz
+               ENDIF
+               
+               IF( nla10 > 1 ) THEN 
+                  zztmp = rhop(ji,jj,jk) - rhop(ji,jj,1)                             ! delta rho(1)
+                  IF( zztmp > zrho3 )          zrho0_3(ji,jj) = zzdep                ! > 0.03
+                  IF( zztmp > zrho1 )          zrho0_1(ji,jj) = zzdep                ! > 0.01
+               ENDIF
+
+            END DO
+         END DO
+      END DO
+      
+      CALL iom_put( "mlddzt", hth )            ! depth of the thermocline
+      IF( nla10 > 1 ) THEN 
+         CALL iom_put( "mldr0_3", zrho0_3 )   ! MLD delta rho(surf) = 0.03
+         CALL iom_put( "mldr0_1", zrho0_1 )   ! MLD delta rho(surf) = 0.01
+      ENDIF
+
+      ! ------------------------------------------------------------- !
+      ! MLD: abs( tn - tn(10m) ) = ztem2                              !
+      ! Top of thermocline: tn = tn(10m) - ztem2                      !
+      ! MLD: rho = rho10m + zrho3                                     !
+      ! pycnocline: rho = rho10m + (dr/dT)(T,S,10m)*(-0.2 degC)       !
+      ! temperature inversion: max( 0, max of tn - tn(10m) )          !
+      ! depth of temperature inversion                                !
+      ! ------------------------------------------------------------- !
+      DO jk = jpkm1, nlb10, -1   ! loop from bottom to nlb10
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zzdep = fsdepw(ji,jj,jk) * tmask(ji,jj,1)
+
+               zztmp = tn(ji,jj,nla10) - tn(ji,jj,jk)                  ! - delta T(10m)
+               IF( ABS(zztmp) > ztem2 )      zabs2   (ji,jj) = zzdep   ! abs > 0.2
+               IF(     zztmp  > ztem2 )      ztm2    (ji,jj) = zzdep   ! > 0.2
+               zztmp = -zztmp                                          ! delta T(10m)
+               IF( zztmp >  ztinv(ji,jj) ) THEN                        ! temperature inversion
+                  ztinv(ji,jj) = zztmp   ;   zdepinv (ji,jj) = zzdep   ! max value and depth
+               ENDIF
+
+               zztmp = rhop(ji,jj,jk) - rhop(ji,jj,nla10)              ! delta rho(10m)
+               IF( zztmp > zrho3        )    zrho10_3(ji,jj) = zzdep   ! > 0.03
+               IF( zztmp > zdelr(ji,jj) )    zpycn   (ji,jj) = zzdep   ! > equi. delta T(10m) - 0.2
+
+            END DO
+         END DO
+      END DO
+
+      CALL iom_put( "mld|dt|" , zabs2        )   ! MLD abs(delta t) - 0.2
+      CALL iom_put( "topthdep", ztm2         )   ! T(10) - 0.2
+      CALL iom_put( "mldr10_3", zrho10_3     )   ! MLD delta rho(10m) = 0.03
+      CALL iom_put( "pycndep" , zpycn        )   ! MLD delta rho equi. delta T(10m) = 0.2
+      CALL iom_put( "BLT"     , ztm2 - zpycn )   ! Barrier Layer Thickness
+      CALL iom_put( "tinv"    , ztinv        )   ! max. temp. inv. (t10 ref) 
+      CALL iom_put( "depti"   , zdepinv      )   ! depth of max. temp. inv. (t10 ref) 
+
+
+      ! ----------------------------------- !
+      ! search deepest level above 20C/28C  !
+      ! ----------------------------------- !
+      ik20(:,:) = 1
+      ik28(:,:) = 1
+      DO jk = 1, jpkm1   ! beware temperature is not always decreasing with depth => loop from top to bottom
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zztmp = tn(ji,jj,jk)
+               IF( zztmp >= 20. )   ik20(ji,jj) = jk
+               IF( zztmp >= 28. )   ik28(ji,jj) = jk
+            END DO
+         END DO
+      END DO
+
+      ! --------------------------- !
+      !  Depth of 20C/28C isotherm  !
+      ! --------------------------- !
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+
+            iif = mbathy(ji,jj)
+            zzdep = fsdepw(ji,jj,iif)
+
+            iid = ik20(ji,jj)
+            IF( iid /= 1 ) THEN 
+               ! linear interpolation
+               zztmp =      fsdept(ji,jj,iid  )   &
+                  &  + (    fsdept(ji,jj,iid+1) - fsdept(ji,jj,iid)                       )   &
+                  &  * ( 20.*tmask(ji,jj,iid+1) -     tn(ji,jj,iid)                       )   &
+                  &  / (        tn(ji,jj,iid+1) -     tn(ji,jj,iid) + (1.-tmask(ji,jj,1)) )
+               ! bound by the ocean depth, minimum value, first T-point depth
+               hd20(ji,jj) = MIN( zztmp*tmask(ji,jj,1), zzdep)
+            ELSE 
+               hd20(ji,jj)=0.
+            ENDIF
+
+            iid = ik28(ji,jj)
+            IF( iid /= 1 ) THEN 
+               ! linear interpolation
+               zztmp =      fsdept(ji,jj,iid  )   &
+                  &  + (    fsdept(ji,jj,iid+1) - fsdept(ji,jj,iid)                       )   &
+                  &  * ( 28.*tmask(ji,jj,iid+1) -     tn(ji,jj,iid)                       )   &
+                  &  / (        tn(ji,jj,iid+1) -     tn(ji,jj,iid) + (1.-tmask(ji,jj,1)) )
+               ! bound by the ocean depth, minimum value, first T-point depth
+               hd28(ji,jj) = MIN( zztmp*tmask(ji,jj,1), zzdep )
+            ELSE 
+               hd28(ji,jj) = 0.
+            ENDIF
+
+         END DO
+      END DO
+      CALL iom_put( "20d", hd20 )   ! depth of the 20 isotherm
+      CALL iom_put( "28d", hd28 )   ! depth of the 28 isotherm
+
+      ! ----------------------------- !
+      !  Heat content of first 300 m  !
+      ! ----------------------------- !
+
+      ! find ilevel with (ilevel+1) the deepest W-level above 300m (we assume we can use e3t_0 to do this search...)
+      ilevel = 0
+      zthick_0 = 0.e0_wp
+      DO jk = 1, jpkm1                      
+         zthick_0 = zthick_0 + e3t_0(jk)
+         IF( zthick_0 < 300. )   ilevel = jk
+      END DO
+      ! surface boundary condition
+      IF( lk_vvl ) THEN   ;   zthick(:,:) = 0.e0_wp     ;   htc3(:,:) = 0.e0_wp                                   
+      ELSE                ;   zthick(:,:) = sshn(:,:)   ;   htc3(:,:) = tn(:,:,jk) * sshn(:,:) * tmask(:,:,jk)   
+      ENDIF
+      ! integration down to ilevel
+      DO jk = 1, ilevel
+         zthick(:,:) = zthick(:,:) + fse3t(:,:,jk)
+         htc3  (:,:) = htc3  (:,:) + fse3t(:,:,jk) * tn(:,:,jk) * tmask(:,:,jk)
+      END DO
+      ! deepest layer
+      zthick(:,:) = 300. - zthick(:,:)   !   remaining thickness to reach 300m
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            htc3(ji,jj) = htc3(ji,jj) + tn(ji,jj,ilevel+1) * MIN( fse3t(ji,jj,ilevel+1), zthick(ji,jj) ) * tmask(ji,jj,ilevel+1)
+         END DO
+      END DO
+      ! from temperature to heat contain
+      zcoef = rau0 * rcp
+      htc3(:,:) = zcoef * htc3(:,:)
+      CALL iom_put( "hc300", htc3 )      ! first 300m heat content
+
+
+   END SUBROUTINE dia_hth
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_diahth = .FALSE.  !: thermocline-20d depths flag
+CONTAINS
+   SUBROUTINE dia_hth( kt )         ! Empty routine
+      WRITE(*,*) 'dia_hth: You should not have seen this print! error?', kt
+   END SUBROUTINE dia_hth
+#endif
+
+   !!======================================================================
+END MODULE diahth
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/dianam.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/dianam.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/dianam.F90	(revision 1844)
@@ -0,0 +1,136 @@
+MODULE dianam
+   !!======================================================================
+   !!                       ***  MODULE  dianam  ***
+   !! Ocean diagnostics:  Builds output file name
+   !!=====================================================================
+   !! History :  OPA  ! 1999-02  (E. Guilyardi)  Creation for 30 days/month
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            3.2  ! 2009-11  (S. Masson) complete rewriting, works for all calendars...
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_nam       : Builds output file name
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE ioipsl, ONLY :  ju2ymds    ! for calendar
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dia_nam
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_nam( cdfnam, kfreq, cdsuff, ldfsec )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_nam  ***
+      !!                   
+      !! ** Purpose :   Builds output file name
+      !!
+      !! ** Method  :   File name is a function of date and output frequency
+      !!      cdfnam=<cexper>_<clave>_<idtbeg>_<idtend>_<cdsuff>
+      !!      <clave> = averaging frequency (DA, MO, etc...)
+      !!      <idtbeg>,<idtend> date of beginning and end of run
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER (len=*), INTENT(  out)           ::   cdfnam   ! file name
+      CHARACTER (len=*), INTENT(in   )           ::   cdsuff   ! to be added at the end of the file name
+      INTEGER          , INTENT(in   )           ::   kfreq    ! output frequency: > 0 in time-step (or seconds see ldfsec)
+      !                                                                            < 0 in months
+      !                                                                            = 0 no frequency
+      LOGICAL          , INTENT(in   ), OPTIONAL ::   ldfsec   ! kfreq in second(in time-step) if .true.(.false. default)
+      !
+      CHARACTER (len=20) ::   clfmt, clfmt0                    ! writing format
+      CHARACTER (len=20) ::   clave                            ! name for output frequency
+      CHARACTER (len=20) ::   cldate1                          ! date of the beginning of run
+      CHARACTER (len=20) ::   cldate2                          ! date of the end       of run
+      LOGICAL            ::   llfsec                           ! local value of ldfsec
+      INTEGER            ::   iyear1, imonth1, iday1           ! year, month, day of the first day of the run
+      INTEGER            ::   iyear2, imonth2, iday2           ! year, month, day of the last  day of the run
+      INTEGER            ::   indg                             ! number of digits needed to write a number     
+      INTEGER            ::   inbsec, inbmn, inbhr             ! output frequency in seconds, minutes and hours
+      INTEGER            ::   inbday, inbmo, inbyr             ! output frequency in days, months and years
+      INTEGER            ::   iyyss, iddss, ihhss, immss       ! number of seconds in 1 year, 1 day, 1 hour and 1 minute
+      INTEGER            ::   iyymo                            ! number of months in 1 year
+      REAL(wp)           ::   zsec1, zsec2                     ! not used
+      REAL(wp)           ::   zdrun, zjul                      ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      ! name for output frequency
+
+      IF( PRESENT(ldfsec) ) THEN   ;   llfsec = ldfsec
+      ELSE                         ;   llfsec = .FALSE.
+      ENDIF
+
+      IF( llfsec .OR. kfreq < 0 ) THEN   ;   inbsec = kfreq                       ! output frequency already in seconds
+      ELSE                               ;   inbsec = kfreq * NINT( rdttra(1) )   ! from time-step to seconds
+      ENDIF
+      iddss = NINT( rday          )                                         ! number of seconds in 1 day
+      ihhss = NINT( rmmss * rhhmm )                                         ! number of seconds in 1 hour
+      immss = NINT( rmmss         )                                         ! number of seconds in 1 minute
+      iyymo = NINT( raamo         )                                         ! number of months  in 1 year
+      iyyss = iddss * nyear_len(1)                                          ! seconds in 1 year (not good: multi years with leap)
+      clfmt0 = "('(a,i',i1,',a)')"                                          ! format '(a,ix,a)' with x to be defined
+      ! 
+      IF(          inbsec == 0           ) THEN   ;   clave = ''            ! no frequency
+      ELSEIF(      inbsec <  0           ) THEN        
+         inbmo = -inbsec                                                    ! frequency in month
+         IF( MOD( inbmo, iyymo  ) == 0 ) THEN                               ! frequency in years
+            inbyr  = inbmo / iyymo
+            indg   = INT(LOG10(REAL(inbyr,wp))) + 1                         ! number of digits needed to write years   frequency
+            WRITE(clfmt, clfmt0) indg             ;   WRITE(clave, clfmt) '_', inbyr , 'y'
+         ELSE                                                               ! frequency in month
+            indg   = INT(LOG10(REAL(inbmo,wp))) + 1                         ! number of digits needed to write months  frequency
+            WRITE(clfmt, clfmt0) indg             ;   WRITE(clave, clfmt) '_', inbmo, 'm'
+         ENDIF
+      ELSEIF( MOD( inbsec, iyyss  ) == 0 ) THEN                             ! frequency in years
+         inbyr  = inbsec / iyyss
+         indg   = INT(LOG10(REAL(inbyr ,wp))) + 1                           ! number of digits needed to write years   frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbyr , 'y'
+      ELSEIF( MOD( inbsec, iddss  ) == 0 ) THEN                             ! frequency in days
+         inbday = inbsec / iddss
+         indg   = INT(LOG10(REAL(inbday,wp))) + 1                           ! number of digits needed to write days    frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbday, 'd'
+         IF( inbday == nmonth_len(nmonth) )           clave = '_1m'
+      ELSEIF( MOD( inbsec, ihhss ) == 0 ) THEN                              ! frequency in hours
+         inbhr  = inbsec / ihhss
+         indg   = INT(LOG10(REAL(inbhr ,wp))) + 1                           ! number of digits needed to write hours   frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbhr , 'h'
+      ELSEIF( MOD( inbsec, immss ) == 0 ) THEN                              ! frequency in minutes
+         inbmn  = inbsec / immss
+         indg   = INT(LOG10(REAL(inbmn ,wp))) + 1                           ! number of digits needed to write minutes frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbmn , 'mn'
+      ELSE                                                                  ! frequency in seconds
+         indg   = INT(LOG10(REAL(inbsec,wp))) + 1                           ! number of digits needed to write seconds frequency
+         WRITE(clfmt, clfmt0) indg                ;   WRITE(clave, clfmt) '_', inbsec, 's'
+      ENDIF
+
+      ! date of the beginning and the end of the run
+
+      zdrun = rdttra(1) / rday * REAL( nitend - nit000, wp )                ! length of the run in days
+      zjul  = fjulday - rdttra(1) / rday
+      CALL ju2ymds( zjul        , iyear1, imonth1, iday1, zsec1 )           ! year/month/day of the beginning of run
+      CALL ju2ymds( zjul + zdrun, iyear2, imonth2, iday2, zsec2 )           ! year/month/day of the end       of run
+
+      IF( iyear2 < 10000 ) THEN   ;   clfmt = "(i4.4,2i2.2)"                ! format used to write the date 
+      ELSE                        ;   WRITE(clfmt, "('(i',i1,',2i2.2)')") INT(LOG10(REAL(iyear2,wp))) + 1
+      ENDIF
+
+      WRITE(cldate1, clfmt) iyear1, imonth1, iday1                          ! date of the beginning of run
+      WRITE(cldate2, clfmt) iyear2, imonth2, iday2                          ! date of the end       of run
+ 
+      cdfnam = TRIM(cexper)//TRIM(clave)//"_"//TRIM(cldate1)//"_"//TRIM(cldate2)//"_"//TRIM(cdsuff)
+      IF( .NOT. Agrif_Root() ) cdfnam = TRIM(Agrif_CFixed())//'_'//TRIM(cdfnam)
+
+   END SUBROUTINE dia_nam
+
+   !!======================================================================
+END MODULE dianam
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaptr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 1844)
@@ -0,0 +1,969 @@
+MODULE diaptr
+   !!======================================================================
+   !!                       ***  MODULE  diaptr  ***
+   !! Ocean physics:  Computes meridonal transports and zonal means
+   !!=====================================================================
+   !! History :  1.0  ! 2003-09  (C. Talandier, G. Madec)  Original code
+   !!            2.0  ! 2006-01  (A. Biastoch)  Allow sub-basins computation
+   !!            3.2  ! 2003-03  (O. Marti, S. Flavoni) Add fields
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_ptr      : Poleward Transport Diagnostics module
+   !!   dia_ptr_init : Initialization, namelist read
+   !!   dia_ptr_wri  : Output of poleward fluxes
+   !!   ptr_vjk      : "zonal" sum computation of a "meridional" flux array
+   !!   ptr_tjk      : "zonal" mean computation of a tracer field
+   !!   ptr_vj       : "zonal" and vertical sum computation of a "meridional"
+   !!                : flux array; Generic interface: ptr_vj_3d, ptr_vj_2d
+   !!----------------------------------------------------------------------
+   USE oce           ! ocean dynamics and active tracers
+   USE dom_oce       ! ocean space and time domain
+   USE phycst        ! physical constants
+   USE ldftra_oce    ! ocean active tracers: lateral physics
+   USE dianam
+   USE iom
+   USE ioipsl         
+   USE in_out_manager
+   USE lib_mpp
+   USE lbclnk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE ptr_vj
+      MODULE PROCEDURE ptr_vj_3d, ptr_vj_2d
+   END INTERFACE
+
+   PUBLIC   dia_ptr_init   ! call in opa module
+   PUBLIC   dia_ptr        ! call in step module
+   PUBLIC   ptr_vj         ! call by tra_ldf & tra_adv routines
+   PUBLIC   ptr_vjk        ! call by tra_ldf & tra_adv routines
+
+   !                                           !!** namelist  namptr  **
+   LOGICAL , PUBLIC ::   ln_diaptr  = .FALSE.   !: Poleward transport flag (T) or not (F)
+   LOGICAL , PUBLIC ::   ln_subbas  = .FALSE.   !: Atlantic/Pacific/Indian basins calculation
+   LOGICAL , PUBLIC ::   ln_diaznl  = .FALSE.   !: Add zonal means and meridional stream functions
+   LOGICAL , PUBLIC ::   ln_ptrcomp = .FALSE.   !: Add decomposition : overturning (and gyre, soon ...)
+   INTEGER , PUBLIC ::   nf_ptr     = 15        !: frequency of ptr computation
+   INTEGER , PUBLIC ::   nf_ptr_wri = 15        !: frequency of ptr outputs
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   abasin, pbasin, ibasin, dbasin, sbasin   !: Sub basin masks
+
+   !                                                               !!! poleward heat and salt transport
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_adv    , pst_adv       !: advection
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ldf    , pst_ldf       !: lateral diffusion
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ove_glo, pst_ove_glo   !: global       overturning
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ove_atl, pst_ove_atl   !: Atlantic     overturning
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ove_pac, pst_ove_pac   !: Pacific      overturning
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ove_ind, pst_ove_ind   !: Indian       overturning
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_ove_ipc, pst_ove_ipc   !: Indo-Pacific overturning
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   ht_glo, ht_atl, ht_ind, ht_pac, ht_ipc   !: heat
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   st_glo, st_atl, st_ind, st_pac, st_ipc   !: salt
+
+   INTEGER ::   niter
+   INTEGER ::   nidom_ptr
+   INTEGER ::   numptr                                              !: logical unit for Poleward TRansports
+
+   REAL(wp), DIMENSION(jpj,jpk) ::   tn_jk_glo  , sn_jk_glo       ! global       i-mean temperature and salinity
+   REAL(wp), DIMENSION(jpj,jpk) ::   tn_jk_atl  , sn_jk_atl       ! Atlantic               -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   tn_jk_pac  , sn_jk_pac       ! Pacific                -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   tn_jk_ind  , sn_jk_ind       ! Indian                 -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   tn_jk_ipc  , sn_jk_ipc       ! Indo-Pacific           -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_glo                    ! global       "meridional" Stream-Function
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_atl                    ! Atlantic               -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_pac                    ! Pacific                -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_ind                    ! Indian                 -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_ipc                    ! Indo-Pacific           -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   surf_jk_glo, surf_jk_r_glo   ! surface of global       i-section and its inverse
+   REAL(wp), DIMENSION(jpj,jpk) ::   surf_jk_atl, surf_jk_r_atl   ! surface of Atlantic          -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   surf_jk_pac, surf_jk_r_pac   ! surface of Pacific           -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   surf_jk_ind, surf_jk_r_ind   ! surface of Indian            -              -
+   REAL(wp), DIMENSION(jpj,jpk) ::   surf_jk_ipc, surf_jk_r_ipc   ! surface of Indo-Pacific      -              -
+#if defined key_diaeiv
+   !                                                               !!! eddy induced velocity (bolus)
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_eiv_glo, pst_eiv_glo   !: global       poleward heat and salt bolus advection
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_eiv_atl, pst_eiv_atl   !: Atlantic         -                           -
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_eiv_pac, pst_eiv_pac   !: Pacific          -                           -
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_eiv_ind, pst_eiv_ind   !: Indian           -                           -
+   REAL(wp), PUBLIC, DIMENSION(jpj) ::   pht_eiv_ipc, pst_eiv_ipc   !: Indo-Pacific     -                           -
+
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_eiv_glo   ! global       "meridional" bolus Stream-Function
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_eiv_atl   ! Atlantic          -                   -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_eiv_pac   ! Pacific           -                   -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_eiv_ind   ! Indian            -                   -
+   REAL(wp), DIMENSION(jpj,jpk) ::   v_msf_eiv_ipc   ! Indo-Pacific      -                   -
+#endif
+ 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   FUNCTION ptr_vj_3d( pva )   RESULT ( p_fval )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE ptr_vj_3d  ***
+      !!
+      !! ** Purpose :   "zonal" and vertical sum computation of a "meridional"
+      !!              flux array
+      !!
+      !! ** Method  : - i-k sum of pva using the interior 2D vmask (vmask_i).
+      !!              pva is supposed to be a masked flux (i.e. * vmask*e1v*e3v)
+      !!
+      !! ** Action  : - p_fval: i-k-mean poleward flux of pva
+      !!----------------------------------------------------------------------
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pva   ! mask flux array at V-point
+      !!
+      INTEGER                  ::   ji, jj, jk   ! dummy loop arguments
+      INTEGER                  ::   ijpj         ! ???
+      REAL(wp), DIMENSION(jpj) ::   p_fval       ! function value
+      !!--------------------------------------------------------------------
+      !
+      ijpj = jpj
+      p_fval(:) = 0.e0
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! Vector opt.
+               p_fval(jj) = p_fval(jj) + pva(ji,jj,jk) * tmask_i(ji,jj) 
+            END DO
+         END DO
+      END DO
+      !
+#if defined key_mpp_mpi
+      CALL mpp_sum( p_fval, ijpj, ncomm_znl)     !!bug  I presume
+#endif
+      !
+   END FUNCTION ptr_vj_3d
+
+
+   FUNCTION ptr_vj_2d( pva )   RESULT ( p_fval )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE ptr_vj_2d  ***
+      !!
+      !! ** Purpose :   "zonal" and vertical sum computation of a "meridional"
+      !!      flux array
+      !!
+      !! ** Method  : - i-k sum of pva using the interior 2D vmask (vmask_i).
+      !!      pva is supposed to be a masked flux (i.e. * vmask*e1v*e3v)
+      !!
+      !! ** Action  : - p_fval: i-k-mean poleward flux of pva
+      !!----------------------------------------------------------------------
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj) ::   pva   ! mask flux array at V-point
+      !!
+      INTEGER                  ::   ji,jj    ! dummy loop arguments
+      INTEGER                  ::   ijpj     ! ???
+      REAL(wp), DIMENSION(jpj) ::   p_fval   ! function value
+      !!--------------------------------------------------------------------
+      ! 
+      ijpj = jpj
+      p_fval(:) = 0.e0
+      DO jj = 2, jpjm1
+         DO ji = nldi, nlei   ! No vector optimisation here. Better use a mask ?
+            p_fval(jj) = p_fval(jj) + pva(ji,jj) * tmask_i(ji,jj)
+         END DO
+      END DO
+      !
+#if defined key_mpp_mpi
+      CALL mpp_sum( p_fval, ijpj, ncomm_znl )     !!bug  I presume
+#endif
+      ! 
+   END FUNCTION ptr_vj_2d
+
+
+   FUNCTION ptr_vjk( pva, bmask )   RESULT ( p_fval )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE ptr_vjk  ***
+      !!
+      !! ** Purpose :   "zonal" sum computation of a "meridional" flux array
+      !!
+      !! ** Method  : - i-sum of pva using the interior 2D vmask (vmask_i).
+      !!      pva is supposed to be a masked flux (i.e. * vmask*e1v*e3v)
+      !!
+      !! ** Action  : - p_fval: i-k-mean poleward flux of pva
+      !!----------------------------------------------------------------------
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj,jpk)           ::   pva     ! mask flux array at V-point
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj)    , OPTIONAL ::   bmask   ! Optional 2D basin mask
+      !!
+      INTEGER                      ::   ji, jj, jk   ! dummy loop arguments
+      REAL(wp), DIMENSION(jpj,jpk) ::   p_fval       ! return function value
+#if defined key_mpp_mpi
+      INTEGER, DIMENSION(1) ::   ish
+      INTEGER, DIMENSION(2) ::   ish2
+      REAL(wp), DIMENSION(jpj*jpk) ::   zwork   ! 1D workspace
+#endif
+      !!--------------------------------------------------------------------
+      !
+      p_fval(:,:) = 0.e0
+      !
+      IF( PRESENT( bmask ) ) THEN 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+!!gm here, use of tmask_i  ==> no need of loop over nldi, nlei....
+               DO ji =  nldi, nlei   ! No vector optimisation here. Better use a mask ?
+                  p_fval(jj,jk) = p_fval(jj,jk) + pva(ji,jj,jk) * e1v(ji,jj) * fse3v(ji,jj,jk)   &
+                     &                                          * tmask_i(ji,jj) * bmask(ji,jj)
+               END DO
+            END DO
+         END DO
+      ELSE 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji =  nldi, nlei   ! No vector optimisation here. Better use a mask ?
+                  p_fval(jj,jk) = p_fval(jj,jk) + pva(ji,jj,jk) * e1v(ji,jj) * fse3v(ji,jj,jk)   &
+                     &                                          * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+      END IF
+      !
+#if defined key_mpp_mpi
+      ish(1) = jpj*jpk   ;   ish2(1) = jpj   ;   ish2(2) = jpk
+      zwork(:) = RESHAPE( p_fval, ish )
+      CALL mpp_sum( zwork, jpj*jpk, ncomm_znl )
+      p_fval(:,:) = RESHAPE( zwork, ish2 )
+#endif
+      !
+   END FUNCTION ptr_vjk
+
+
+   FUNCTION ptr_tjk( pta, bmask )   RESULT ( p_fval )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE ptr_tjk  ***
+      !!
+      !! ** Purpose :   "zonal" mean computation of a tracer field
+      !!
+      !! ** Method  : - i-sum of mj(pta) using tmask
+      !!      multiplied by the inverse of the surface of the "zonal" ocean
+      !!      section
+      !!
+      !! ** Action  : - p_fval: i-k-mean poleward flux of pta
+      !!----------------------------------------------------------------------
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pta    ! tracer flux array at T-point
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj), OPTIONAL :: bmask ! Optional 2D basin mask
+      !!
+      INTEGER                     ::   ji, jj, jk   ! dummy loop arguments
+      REAL(wp),DIMENSION(jpj,jpk) ::   p_fval       ! return function value
+#if defined key_mpp_mpi
+      INTEGER, DIMENSION(1) ::   ish
+      INTEGER, DIMENSION(2) ::   ish2
+      REAL(wp),DIMENSION(jpj*jpk) ::   zwork   ! 1D workspace
+#endif
+      !!-------------------------------------------------------------------- 
+      !
+      p_fval(:,:) = 0.e0
+      IF (PRESENT (bmask)) THEN 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji =  nldi, nlei   ! No vector optimisation here. Better use a mask ?
+                  p_fval(jj,jk) = p_fval(jj,jk) + pta(ji,jj,jk)                  &
+                     &                          * e1t(ji,jj) * fse3t(ji,jj,jk)   &
+                     &                          * tmask_i(ji,jj)                 &
+                     &                          * bmask(ji,jj)
+               END DO
+            END DO
+         END DO
+      ELSE 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji =  nldi, nlei   ! No vector optimisation here. Better use a mask ?
+                  p_fval(jj,jk) = p_fval(jj,jk) + pta(ji,jj,jk)                  &
+                     &                          * e1t(ji,jj) * fse3t(ji,jj,jk)   &
+                     &                          * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+      END IF
+      p_fval(:,:) = p_fval(:,:) * 0.5
+#if defined key_mpp_mpi
+      ish(1) = jpj*jpk   ;   ish2(1) = jpj   ;   ish2(2) = jpk
+      zwork(:)= RESHAPE( p_fval, ish )
+      CALL mpp_sum( zwork, jpj*jpk, ncomm_znl )
+      p_fval(:,:)= RESHAPE(zwork,ish2)
+#endif
+      !
+   END FUNCTION ptr_tjk
+
+
+   SUBROUTINE dia_ptr( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_ptr  ***
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step index
+      !!
+      INTEGER  ::   jk, jj, ji   ! dummy loop
+      REAL(wp) ::   zsverdrup    ! conversion from m3/s to Sverdrup
+      REAL(wp) ::   zpwatt       ! conversion from W    to PW
+      REAL(wp) ::   zggram       ! conversion from g    to Pg
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   vt, vs   ! 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .OR. MOD( kt, nf_ptr ) == 0 )   THEN
+
+         IF ( MOD( kt, nf_ptr ) == 0 ) THEN 
+
+            zsverdrup = 1.e-6
+            zpwatt    = 1.e-15
+            zggram    = 1.e-6
+
+            IF ( ln_diaznl ) THEN
+               ! "zonal" mean temperature and salinity at V-points
+               tn_jk_glo(:,:) = ptr_tjk( tn(:,:,:) ) * surf_jk_r_glo(:,:)
+               sn_jk_glo(:,:) = ptr_tjk( sn(:,:,:) ) * surf_jk_r_glo(:,:)
+
+               IF (ln_subbas) THEN 
+                  tn_jk_atl(:,:) = ptr_tjk( tn(:,:,:), abasin(:,:) ) * surf_jk_r_atl(:,:)
+                  sn_jk_atl(:,:) = ptr_tjk( sn(:,:,:), abasin(:,:) ) * surf_jk_r_atl(:,:)
+                  tn_jk_pac(:,:) = ptr_tjk( tn(:,:,:), pbasin(:,:) ) * surf_jk_r_pac(:,:)
+                  sn_jk_pac(:,:) = ptr_tjk( sn(:,:,:), pbasin(:,:) ) * surf_jk_r_pac(:,:)
+                  tn_jk_ind(:,:) = ptr_tjk( tn(:,:,:), ibasin(:,:) ) * surf_jk_r_ind(:,:)
+                  sn_jk_ind(:,:) = ptr_tjk( sn(:,:,:), ibasin(:,:) ) * surf_jk_r_ind(:,:)
+                  tn_jk_ipc(:,:) = ptr_tjk( tn(:,:,:), dbasin(:,:) ) * surf_jk_r_ipc(:,:)
+                  sn_jk_ipc(:,:) = ptr_tjk( sn(:,:,:), dbasin(:,:) ) * surf_jk_r_ipc(:,:)
+               ENDIF
+            ENDIF
+
+            !--------------------------------------------------------
+            ! overturning calculation:
+
+            ! horizontal integral and vertical dz 
+
+#if defined key_diaeiv
+            v_msf_glo(:,:) = ptr_vjk( vn(:,:,:)+v_eiv(:,:,:) ) 
+            IF( ln_subbas .AND. ln_diaznl ) THEN
+               v_msf_atl(:,:) = ptr_vjk( vn(:,:,:)+v_eiv(:,:,:), abasin(:,:)*sbasin(:,:) ) 
+               v_msf_pac(:,:) = ptr_vjk( vn(:,:,:)+v_eiv(:,:,:), pbasin(:,:)*sbasin(:,:) ) 
+               v_msf_ind(:,:) = ptr_vjk( vn(:,:,:)+v_eiv(:,:,:), ibasin(:,:)*sbasin(:,:) ) 
+               v_msf_ipc(:,:) = ptr_vjk( vn(:,:,:)+v_eiv(:,:,:), dbasin(:,:)*sbasin(:,:) ) 
+            ENDIF
+#else
+            v_msf_glo(:,:) = ptr_vjk( vn(:,:,:) ) 
+            IF( ln_subbas .AND. ln_diaznl ) THEN
+               v_msf_atl(:,:) = ptr_vjk( vn(:,:,:), abasin(:,:)*sbasin(:,:) ) 
+               v_msf_pac(:,:) = ptr_vjk( vn(:,:,:), pbasin(:,:)*sbasin(:,:) ) 
+               v_msf_ind(:,:) = ptr_vjk( vn(:,:,:), ibasin(:,:)*sbasin(:,:) ) 
+               v_msf_ipc(:,:) = ptr_vjk( vn(:,:,:), dbasin(:,:)*sbasin(:,:) ) 
+            ENDIF
+#endif
+
+#if defined key_diaeiv
+            v_msf_eiv_glo(:,:) = ptr_vjk( v_eiv(:,:,:) )
+            IF (ln_subbas ) THEN 
+               v_msf_eiv_atl(:,:) = ptr_vjk( v_eiv(:,:,:), abasin(:,:)*sbasin(:,:) )
+               v_msf_eiv_pac(:,:) = ptr_vjk( v_eiv(:,:,:), pbasin(:,:)*sbasin(:,:) )
+               v_msf_eiv_ind(:,:) = ptr_vjk( v_eiv(:,:,:), ibasin(:,:)*sbasin(:,:) )
+               v_msf_eiv_ipc(:,:) = ptr_vjk( v_eiv(:,:,:), dbasin(:,:)*sbasin(:,:) )
+            END IF
+#endif
+
+            ! "Meridional" Stream-Function
+            DO jk = 2,jpk 
+               v_msf_glo(:,jk) = v_msf_glo(:,jk-1) + v_msf_glo(:,jk)
+            END DO
+            v_msf_glo(:,:) = v_msf_glo(:,:) * zsverdrup
+#if defined key_diaeiv
+            ! Bolus "Meridional" Stream-Function
+            DO jk = 2,jpk
+               v_msf_eiv_glo(:,jk) = v_msf_eiv_glo(:,jk-1) + v_msf_eiv_glo(:,jk)
+            END DO
+            v_msf_eiv_glo(:,:) = v_msf_eiv_glo(:,:) * zsverdrup
+            IF ( ln_subbas ) THEN 
+               DO jk = 2,jpk
+                  v_msf_eiv_atl(:,jk) = v_msf_eiv_atl(:,jk-1) + v_msf_eiv_atl(:,jk)
+                  v_msf_eiv_pac(:,jk) = v_msf_eiv_pac(:,jk-1) + v_msf_eiv_pac(:,jk)
+                  v_msf_eiv_ind(:,jk) = v_msf_eiv_ind(:,jk-1) + v_msf_eiv_ind(:,jk)
+                  v_msf_eiv_ipc(:,jk) = v_msf_eiv_ipc(:,jk-1) + v_msf_eiv_ipc(:,jk)
+               END DO
+            ENDIF
+#endif
+            !
+            IF( ln_subbas .AND. ln_diaznl ) THEN
+               DO jk = 2,jpk 
+                  v_msf_atl(:,jk) = v_msf_atl(:,jk-1) + v_msf_atl(:,jk)
+                  v_msf_pac(:,jk) = v_msf_pac(:,jk-1) + v_msf_pac(:,jk)
+                  v_msf_ind(:,jk) = v_msf_ind(:,jk-1) + v_msf_ind(:,jk)
+                  v_msf_ipc(:,jk) = v_msf_ipc(:,jk-1) + v_msf_ipc(:,jk)
+               END DO
+               v_msf_atl(:,:) = v_msf_atl(:,:) * zsverdrup
+               v_msf_pac(:,:) = v_msf_pac(:,:) * zsverdrup
+               v_msf_ind(:,:) = v_msf_ind(:,:) * zsverdrup
+               v_msf_ipc(:,:) = v_msf_ipc(:,:) * zsverdrup
+            ENDIF
+
+            ! Transports
+            ! T times V on T points (include bolus velocities)
+#if defined key_diaeiv 
+            DO jj = 2, jpj
+               DO ji = 1, jpi
+                  vt(ji,jj,:) = tn(ji,jj,:) * ( vn(ji,jj,:) + vn(ji,jj-1,:) + u_eiv(ji,jj,:) + u_eiv(ji,jj-1,:) )*0.5
+                  vs(ji,jj,:) = sn(ji,jj,:) * ( vn(ji,jj,:) + vn(ji,jj-1,:) + v_eiv(ji,jj,:) + v_eiv(ji,jj-1,:) )*0.5
+               END DO
+            END DO
+#else
+            DO jj = 2, jpj
+               DO ji = 1, jpi
+                  vt(ji,jj,:) = tn(ji,jj,:) * ( vn(ji,jj,:) + vn(ji,jj-1,:) )*0.5
+                  vs(ji,jj,:) = sn(ji,jj,:) * ( vn(ji,jj,:) + vn(ji,jj-1,:) )*0.5
+               END DO
+            END DO
+#endif 
+            CALL lbc_lnk( vs, 'V', -1. )   ;   CALL lbc_lnk( vt, 'V', -1. )
+
+            ht_glo(:) = SUM( ptr_vjk( vt(:,:,:)), 2 )
+            st_glo(:) = SUM( ptr_vjk( vs(:,:,:)), 2 )
+
+            IF ( ln_subbas ) THEN 
+               ht_atl(:) = SUM( ptr_vjk( vt (:,:,:), abasin(:,:)*sbasin(:,:)), 2 )
+               ht_pac(:) = SUM( ptr_vjk( vt (:,:,:), pbasin(:,:)*sbasin(:,:)), 2 )
+               ht_ind(:) = SUM( ptr_vjk( vt (:,:,:), ibasin(:,:)*sbasin(:,:)), 2 )
+               ht_ipc(:) = SUM( ptr_vjk( vt (:,:,:), dbasin(:,:)*sbasin(:,:)), 2 )
+               st_atl(:) = SUM( ptr_vjk( vs (:,:,:), abasin(:,:)*sbasin(:,:)), 2 )
+               st_pac(:) = SUM( ptr_vjk( vs (:,:,:), pbasin(:,:)*sbasin(:,:)), 2 )
+               st_ind(:) = SUM( ptr_vjk( vs (:,:,:), ibasin(:,:)*sbasin(:,:)), 2 )
+               st_ipc(:) = SUM( ptr_vjk( vs (:,:,:), dbasin(:,:)*sbasin(:,:)), 2 )
+            ENDIF
+
+            ! poleward tracer transports: 
+            ! overturning components:
+            IF ( ln_ptrcomp ) THEN 
+               pht_ove_glo(:) = SUM( v_msf_glo(:,:) * tn_jk_glo(:,:), 2 )   ! SUM over jk
+               pst_ove_glo(:) = SUM( v_msf_glo(:,:) * sn_jk_glo(:,:), 2 )  
+               IF ( ln_subbas ) THEN 
+                  pht_ove_atl(:) = SUM( v_msf_atl(:,:) * tn_jk_atl(:,:), 2 )   ! SUM over jk
+                  pst_ove_atl(:) = SUM( v_msf_atl(:,:) * sn_jk_atl(:,:), 2 )  
+                  pht_ove_pac(:) = SUM( v_msf_pac(:,:) * tn_jk_pac(:,:), 2 )   ! SUM over jk
+                  pst_ove_pac(:) = SUM( v_msf_pac(:,:) * sn_jk_pac(:,:), 2 )  
+                  pht_ove_ind(:) = SUM( v_msf_ind(:,:) * tn_jk_ind(:,:), 2 )   ! SUM over jk
+                  pst_ove_ind(:) = SUM( v_msf_ind(:,:) * sn_jk_ind(:,:), 2 )  
+                  pht_ove_ipc(:) = SUM( v_msf_ipc(:,:) * tn_jk_ipc(:,:), 2 )   ! SUM over jk
+                  pst_ove_ipc(:) = SUM( v_msf_ipc(:,:) * sn_jk_ipc(:,:), 2 )  
+               END IF
+            END IF
+
+            ! Bolus component
+#if defined key_diaeiv
+            pht_eiv_glo(:) = SUM( v_msf_eiv_glo(:,:) * tn_jk_glo(:,:), 2 )   ! SUM over jk
+            pst_eiv_glo(:) = SUM( v_msf_eiv_glo(:,:) * sn_jk_glo(:,:), 2 )   ! SUM over jk
+            IF ( ln_subbas ) THEN 
+               pht_eiv_atl(:) = SUM( v_msf_eiv_glo(:,:) * tn_jk_atl(:,:), 2 )   ! SUM over jk
+               pst_eiv_atl(:) = SUM( v_msf_eiv_glo(:,:) * sn_jk_atl(:,:), 2 )   ! SUM over jk
+               pht_eiv_pac(:) = SUM( v_msf_eiv_pac(:,:) * tn_jk_pac(:,:), 2 )   ! SUM over jk
+               pst_eiv_pac(:) = SUM( v_msf_eiv_pac(:,:) * sn_jk_pac(:,:), 2 )   ! SUM over jk
+               pht_eiv_ind(:) = SUM( v_msf_eiv_ind(:,:) * tn_jk_ind(:,:), 2 )   ! SUM over jk
+               pst_eiv_ind(:) = SUM( v_msf_eiv_ind(:,:) * sn_jk_ind(:,:), 2 )   ! SUM over jk
+               pht_eiv_ipc(:) = SUM( v_msf_eiv_ipc(:,:) * tn_jk_ipc(:,:), 2 )   ! SUM over jk
+               pst_eiv_ipc(:) = SUM( v_msf_eiv_ipc(:,:) * sn_jk_ipc(:,:), 2 )   ! SUM over jk
+            ENDIF
+#endif
+
+            ! conversion in PW and G g
+            zpwatt = zpwatt * rau0 * rcp
+            pht_adv(:) = pht_adv(:) * zpwatt  
+            pht_ldf(:) = pht_ldf(:) * zpwatt
+            pst_adv(:) = pst_adv(:) * zggram
+            pst_ldf(:) = pst_ldf(:) * zggram
+            IF ( ln_ptrcomp ) THEN 
+               pht_ove_glo(:) = pht_ove_glo(:) * zpwatt
+               pst_ove_glo(:) = pst_ove_glo(:) * zggram
+            END IF
+#if defined key_diaeiv
+            pht_eiv_glo(:) = pht_eiv_glo(:) * zpwatt
+            pst_eiv_glo(:) = pst_eiv_glo(:) * zggram
+#endif
+            IF( ln_subbas ) THEN
+               ht_atl(:) = ht_atl(:) * zpwatt
+               ht_pac(:) = ht_pac(:) * zpwatt
+               ht_ind(:) = ht_ind(:) * zpwatt
+               ht_ipc(:) = ht_ipc(:) * zpwatt
+               st_atl(:) = st_atl(:) * zggram 
+               st_pac(:) = st_pac(:) * zggram
+               st_ind(:) = st_ind(:) * zggram
+               st_ipc(:) = st_ipc(:) * zggram
+            ENDIF
+         ENDIF
+         !
+         CALL dia_ptr_wri( kt )                        ! outputs
+         !
+      ENDIF
+      !
+      IF( kt == nitend )   CALL histclo( numptr )      ! Close the file
+      !
+   END SUBROUTINE dia_ptr
+
+
+   SUBROUTINE dia_ptr_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_ptr_init  ***
+      !!                   
+      !! ** Purpose :   Initialization, namelist read
+      !!----------------------------------------------------------------------
+      INTEGER ::   inum       ! temporary logical unit
+#if defined key_mpp_mpi
+      INTEGER, DIMENSION(1) :: iglo, iloc, iabsf, iabsl, ihals, ihale, idid
+#endif
+      !!
+      NAMELIST/namptr/ ln_diaptr, ln_diaznl, ln_subbas, ln_ptrcomp, nf_ptr, nf_ptr_wri
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )              ! Read Namelist namptr : poleward transport parameters
+      READ   ( numnam, namptr )
+
+      IF(lwp) THEN                   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dia_ptr_init : poleward transport and msf initialization'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namptr : set ptr parameters'
+         WRITE(numout,*) '      Switch for ptr diagnostic (T) or not (F)  ln_diaptr  = ', ln_diaptr
+         WRITE(numout,*) '      Atl/Pac/Ind basins computation            ln_subbas  = ', ln_subbas
+         WRITE(numout,*) '      Frequency of computation                  nf_ptr     = ', nf_ptr
+         WRITE(numout,*) '      Frequency of outputs                      nf_ptr_wri = ', nf_ptr_wri
+      ENDIF
+
+      IF( .NOT. ln_diaptr )   RETURN
+      
+      IF( lk_mpp )   CALL mpp_ini_znl      ! Define MPI communicator for zonal sum
+
+      IF( ln_subbas ) THEN                 ! load sub-basin mask
+         CALL iom_open( 'subbasins', inum )
+         CALL iom_get( inum, jpdom_data, 'atlmsk', abasin )      ! Atlantic basin
+         CALL iom_get( inum, jpdom_data, 'pacmsk', pbasin )      ! Pacific basin
+         CALL iom_get( inum, jpdom_data, 'indmsk', ibasin )      ! Indian basin
+         CALL iom_close( inum )
+         dbasin(:,:) = MAX ( pbasin(:,:), ibasin(:,:) )
+         sbasin(:,:) = tmask (:,:,1)
+         WHERE ( gphit (:,:) < -30.e0) sbasin(:,:) = 0.e0
+      ENDIF
+      
+!!gm CAUTION : this is only valid in fixed volume case !
+
+      ! inverse of the ocean "zonal" v-point section
+      surf_jk_glo(:,:) = ptr_tjk( tmask(:,:,:) )
+      surf_jk_r_glo(:,:) = 0.e0
+      WHERE( surf_jk_glo(:,:) /= 0.e0 )   surf_jk_r_glo(:,:) = 1.e0 / surf_jk_glo(:,:)
+      
+      IF (ln_subbas) THEN
+         surf_jk_atl(:,:) = ptr_tjk( tmask (:,:,:), abasin(:,:) )
+         surf_jk_r_atl(:,:) = 0.e0
+         WHERE( surf_jk_atl(:,:) /= 0.e0 )   surf_jk_r_atl(:,:) = 1.e0 / surf_jk_atl(:,:)
+         !
+         surf_jk_pac(:,:) = ptr_tjk( tmask (:,:,:), pbasin(:,:) )
+         surf_jk_r_pac(:,:) = 0.e0
+         WHERE( surf_jk_pac(:,:) /= 0.e0 )   surf_jk_r_pac(:,:) = 1.e0 / surf_jk_pac(:,:)
+         ! 
+         surf_jk_ind(:,:) = ptr_tjk( tmask (:,:,:), ibasin(:,:) )
+         surf_jk_r_ind(:,:) = 0.e0
+         WHERE( surf_jk_ind(:,:) /= 0.e0 )   surf_jk_r_ind(:,:) = 1.e0 / surf_jk_ind(:,:)
+         !
+         surf_jk_ipc(:,:) = ptr_tjk( tmask (:,:,:), dbasin(:,:) )
+         surf_jk_r_ipc(:,:) = 0.e0
+         WHERE( surf_jk_ipc(:,:) /= 0.e0 )   surf_jk_r_ipc(:,:) = 1.e0 / surf_jk_ipc(:,:)
+      END IF
+
+      
+      !!----------------------------------------------------------------------
+
+#if defined key_mpp_mpi 
+      iglo (1) = jpjglo
+      iloc (1) = nlcj
+      iabsf(1) = njmppt(narea)
+      iabsl(:) = iabsf(:) + iloc(:) - 1
+      ihals(1) = nldj - 1
+      ihale(1) = nlcj - nlej
+      idid (1) = 2
+
+!-$$      IF(lwp) THEN
+!-$$          WRITE(numout,*)
+!-$$          WRITE(numout,*) 'dia_ptr_init :   iloc  = ', iloc 
+!-$$          WRITE(numout,*) '~~~~~~~~~~~~     iabsf = ', iabsf
+!-$$          WRITE(numout,*) '                 ihals = ', ihals
+!-$$          WRITE(numout,*) '                 ihale = ', ihale
+!-$$      ENDIF 
+
+      CALL flio_dom_set ( jpnj, nproc/jpni, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom_ptr)
+#else
+      nidom_ptr = FLIO_DOM_NONE
+#endif
+      ! 
+   END SUBROUTINE dia_ptr_init
+
+
+   SUBROUTINE dia_ptr_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                ***  ROUTINE dia_ptr_wri  ***
+      !!
+      !! ** Purpose :   output of poleward fluxes
+      !!
+      !! ** Method  :   NetCDF file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!
+      INTEGER, SAVE ::   nhoridz, ndepidzt, ndepidzw
+      INTEGER, SAVE :: ndim  , ndim_atl     , ndim_pac     , ndim_ind     , ndim_ipc
+      INTEGER, SAVE ::         ndim_atl_30  , ndim_pac_30  , ndim_ind_30  , ndim_ipc_30
+      INTEGER, SAVE :: ndim_h, ndim_h_atl_30, ndim_h_pac_30, ndim_h_ind_30, ndim_h_ipc_30
+      INTEGER, SAVE, DIMENSION (jpj*jpk) :: ndex  , ndex_atl     , ndex_pac     , ndex_ind     , ndex_ipc
+      INTEGER, SAVE, DIMENSION (jpj*jpk) ::         ndex_atl_30  , ndex_pac_30  , ndex_ind_30  , ndex_ipc_30
+      INTEGER, SAVE, DIMENSION (jpj)     :: ndex_h, ndex_h_atl_30, ndex_h_pac_30, ndex_h_ind_30, ndex_h_ipc_30
+
+      CHARACTER (len=40)       ::   clhstnam, clop, clop_once, cl_comment   ! temporary names
+      INTEGER                  ::   iline, it, itmod, ji, jj, jk            !
+#if defined key_iomput
+      INTEGER                  ::   inum                                    ! temporary logical unit
+#endif
+      REAL(wp)                 ::   zsto, zout, zdt, zjulian                ! temporary scalars
+      REAL(wp), DIMENSION(jpj) ::   zphi, zfoo
+      REAL(wp), DIMENSION(jpj,jpk) :: z_1
+      !!----------------------------------------------------------------------
+
+      ! define time axis
+      it    = kt / nf_ptr
+      itmod = kt - nit000 + 1
+      
+!-$$      IF(lwp) THEN
+!-$$         WRITE(numout,*)
+!-$$         WRITE(numout,*) 'dia_ptr_wri : kt = ', kt, 'it = ', it, ' itmod = ', itmod, ' niter = ', niter
+!-$$         WRITE(numout,*) '~~~~~~~~~~~~'
+!-$$      ENDIF
+
+      ! Initialization
+      ! --------------
+      IF( kt == nit000 ) THEN
+
+         niter = (nit000 - 1) / nf_ptr
+
+!-$$         IF(lwp) THEN
+!-$$            WRITE(numout,*)
+!-$$            WRITE(numout,*) 'dia_ptr_wri : poleward transport and msf writing: initialization , niter = ', niter
+!-$$            WRITE(numout,*) '~~~~~~~~~~~~'
+!-$$         ENDIF
+
+         zdt = rdt
+         IF( nacc == 1 )   zdt = rdtmin
+
+         ! Reference latitude
+         ! ------------------
+         !                                           ! =======================
+         IF( cp_cfg == "orca" ) THEN                 !   ORCA configurations
+            !                                        ! =======================
+
+            IF( jp_cfg == 05  )   iline = 192   ! i-line that passes near the North Pole
+            IF( jp_cfg == 025 )   iline = 384   ! i-line that passes near the North Pole
+            IF( jp_cfg == 1   )   iline =  96   ! i-line that passes near the North Pole
+            IF( jp_cfg == 2   )   iline =  48   ! i-line that passes near the North Pole
+            IF( jp_cfg == 4   )   iline =  24   ! i-line that passes near the North Pole
+            zphi(:) = 0.e0
+            DO ji = mi0(iline), mi1(iline) 
+               zphi(:) = gphiv(ji,:)         ! if iline is in the local domain
+               ! Correct highest latitude for some configurations - will work if domain is parallelized in J ?
+               IF( jp_cfg == 05 ) THEN
+                  DO jj = mj0(jpjdta), mj1(jpjdta) 
+                     zphi( jj ) = zphi(mj0(jpjdta-1)) + (zphi(mj0(jpjdta-1))-zphi(mj0(jpjdta-2)))/2.
+                     zphi( jj ) = MIN( zphi(jj), 90.)
+                  END DO
+               END IF
+               IF( jp_cfg == 1 .OR. jp_cfg == 2 .OR. jp_cfg == 4 ) THEN
+                  DO jj = mj0(jpjdta-1), mj1(jpjdta-1) 
+                     zphi( jj ) = 88.5e0
+                  END DO
+                  DO jj = mj0(jpjdta  ), mj1(jpjdta  ) 
+                     zphi( jj ) = 89.5e0
+                  END DO
+               END IF
+            END DO
+            ! provide the correct zphi to all local domains
+#if defined key_mpp_mpi
+            CALL mpp_sum( zphi, jpj, ncomm_znl )        
+#endif
+
+            !                                        ! =======================
+         ELSE                                        !   OTHER configurations 
+            !                                        ! =======================
+            zphi(:) = gphiv(1,:)             ! assume lat/lon coordinate, select the first i-line
+            !
+         ENDIF
+         !
+         ! Work only on westmost processor (will not work if mppini2 is used)
+#if defined key_mpp_mpi
+         IF ( l_znl_root ) THEN 
+#endif
+            !
+            ! OPEN netcdf file 
+            ! ----------------
+            ! Define frequency of output and means
+            zsto = nf_ptr * zdt
+            IF( ln_mskland )   THEN    ! put 1.e+20 on land (very expensive!!)
+               clop      = "ave(only(x))"
+               clop_once = "once(only(x))"
+            ELSE                       ! no use of the mask value (require less cpu time)
+               clop      = "ave(x)"       
+               clop_once = "once"
+            ENDIF
+
+            zout = nf_ptr_wri * zdt
+            zfoo(:) = 0.e0
+
+            ! Compute julian date from starting date of the run
+
+            CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+            zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+
+#if defined key_iomput
+            ! Requested by IPSL people, use by their postpro...
+            IF(lwp) THEN
+               CALL dia_nam( clhstnam, nf_ptr_wri,' ' )
+               CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+               WRITE(inum,*) clhstnam
+               CLOSE(inum)
+            ENDIF
+#endif
+
+            CALL dia_nam( clhstnam, nf_ptr_wri, 'diaptr' )
+            IF(lwp)WRITE( numout,*)" Name of diaptr NETCDF file : ", clhstnam
+
+            ! Horizontal grid : zphi()
+            CALL histbeg(clhstnam, 1, zfoo, jpj, zphi,   &
+               1, 1, 1, jpj, niter, zjulian, zdt*nf_ptr, nhoridz, numptr, domain_id=nidom_ptr)
+            ! Vertical grids : gdept_0, gdepw_0
+            CALL histvert( numptr, "deptht", "Vertical T levels",   &
+               "m", jpk, gdept_0, ndepidzt, "down" )
+            CALL histvert( numptr, "depthw", "Vertical W levels",   &
+               "m", jpk, gdepw_0, ndepidzw, "down" )
+
+            !
+            CALL wheneq ( jpj*jpk, MIN(surf_jk_glo(:,:), 1.e0), 1, 1., ndex  , ndim  )      ! Lat-Depth
+            CALL wheneq ( jpj    , MIN(surf_jk_glo(:,1), 1.e0), 1, 1., ndex_h, ndim_h )     ! Lat
+
+            IF (ln_subbas) THEN
+               z_1 (:,1) = 1.0e0
+               WHERE ( gphit (jpi/2,:) .LT. -30 ) z_1 (:,1) = 0.e0
+               DO jk = 2, jpk
+                  z_1 (:,jk) = z_1 (:,1)
+               END DO
+
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_atl(:,:)         , 1.e0), 1, 1., ndex_atl     , ndim_atl      ) ! Lat-Depth
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_atl(:,:)*z_1(:,:), 1.e0), 1, 1., ndex_atl_30  , ndim_atl_30   ) ! Lat-Depth
+               CALL wheneq ( jpj    , MIN(surf_jk_atl(:,1)*z_1(:,1), 1.e0), 1, 1., ndex_h_atl_30, ndim_h_atl_30 ) ! Lat
+
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_pac(:,:)         , 1.e0), 1, 1., ndex_pac     , ndim_pac      ) ! Lat-Depth
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_pac(:,:)*z_1(:,:), 1.e0), 1, 1., ndex_pac_30  , ndim_pac_30   ) ! Lat-Depth
+               CALL wheneq ( jpj    , MIN(surf_jk_pac(:,1)*z_1(:,1), 1.e0), 1, 1., ndex_h_pac_30, ndim_h_pac_30 ) ! Lat
+
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_ind(:,:)         , 1.e0), 1, 1., ndex_ind     , ndim_ind      ) ! Lat-Depth
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_ind(:,:)*z_1(:,:), 1.e0), 1, 1., ndex_ind_30  , ndim_ind_30   ) ! Lat-Depth
+               CALL wheneq ( jpj    , MIN(surf_jk_ind(:,1)*z_1(:,1), 1.e0), 1, 1., ndex_h_ind_30, ndim_h_ind_30 ) ! Lat
+
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_ipc(:,:)         , 1.e0), 1, 1., ndex_ipc     , ndim_ipc      ) ! Lat-Depth
+               CALL wheneq ( jpj*jpk, MIN(surf_jk_ipc(:,:)*z_1(:,:), 1.e0), 1, 1., ndex_ipc_30  , ndim_ipc_30   ) ! Lat-Depth
+               CALL wheneq ( jpj    , MIN(surf_jk_ipc(:,1)*z_1(:,1), 1.e0), 1, 1., ndex_h_ipc_30, ndim_h_ipc_30 ) ! Lat
+
+            ENDIF
+
+            ! 
+#if defined key_diaeiv
+            cl_comment = ' (Bolus part included)'
+#else
+            cl_comment = '                      '
+#endif
+            !  Zonal mean T and S
+
+            IF ( ln_diaznl ) THEN 
+               CALL histdef( numptr, "zotemglo", "Zonal Mean Temperature","C" ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+               CALL histdef( numptr, "zosalglo", "Zonal Mean Salinity","PSU"  ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+
+               CALL histdef( numptr, "zosrfglo", "Zonal Mean Surface","m^2"   ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop_once, zsto, zout )
+
+               IF (ln_subbas) THEN 
+                  CALL histdef( numptr, "zotematl", "Zonal Mean Temperature: Atlantic","C" ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosalatl", "Zonal Mean Salinity: Atlantic","PSU"  ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosrfatl", "Zonal Mean Surface: Atlantic","m^2"   ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop_once, zsto, zout )
+
+                  CALL histdef( numptr, "zotempac", "Zonal Mean Temperature: Pacific","C"  ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosalpac", "Zonal Mean Salinity: Pacific","PSU"   ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosrfpac", "Zonal Mean Surface: Pacific","m^2"    ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop_once, zsto, zout )
+
+                  CALL histdef( numptr, "zotemind", "Zonal Mean Temperature: Indian","C"   ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosalind", "Zonal Mean Salinity: Indian","PSU"    ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosrfind", "Zonal Mean Surface: Indian","m^2"     ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop_once, zsto, zout )
+
+                  CALL histdef( numptr, "zotemipc", "Zonal Mean Temperature: Pacific+Indian","C" ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosalipc", "Zonal Mean Salinity: Pacific+Indian","PSU"  ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop, zsto, zout )
+                  CALL histdef( numptr, "zosrfipc", "Zonal Mean Surface: Pacific+Indian","m^2"   ,   &
+                     1, jpj, nhoridz, jpk, 1, jpk, ndepidzt, 32, clop_once, zsto, zout )
+               ENDIF
+
+            ENDIF
+
+            !  Meridional Stream-Function (Eulerian and Bolus)
+
+            CALL histdef( numptr, "zomsfglo", "Meridional Stream-Function: Global"//TRIM(cl_comment),"Sv" ,   &
+               1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+            IF( ln_subbas .AND. ln_diaznl ) THEN
+               CALL histdef( numptr, "zomsfatl", "Meridional Stream-Function: Atlantic"//TRIM(cl_comment),"Sv" ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+               CALL histdef( numptr, "zomsfpac", "Meridional Stream-Function: Pacific"//TRIM(cl_comment),"Sv"  ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+               CALL histdef( numptr, "zomsfind", "Meridional Stream-Function: Indian"//TRIM(cl_comment),"Sv"   ,   &
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+               CALL histdef( numptr, "zomsfipc", "Meridional Stream-Function: Indo-Pacific"//TRIM(cl_comment),"Sv" ,&
+                  1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+            ENDIF
+
+            !  Heat transport 
+
+            CALL histdef( numptr, "sophtadv", "Advective Heat Transport"      ,   &
+               "PW", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            CALL histdef( numptr, "sophtldf", "Diffusive Heat Transport"      ,   &
+               "PW",1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            IF ( ln_ptrcomp ) THEN 
+               CALL histdef( numptr, "sophtove", "Overturning Heat Transport"    ,   &
+                  "PW",1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            END IF
+            IF( ln_subbas ) THEN
+               CALL histdef( numptr, "sohtatl", "Heat Transport Atlantic"//TRIM(cl_comment),  &
+                  "PW", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sohtpac", "Heat Transport Pacific"//TRIM(cl_comment) ,  &
+                  "PW", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sohtind", "Heat Transport Indian"//TRIM(cl_comment)  ,  &
+                  "PW", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sohtipc", "Heat Transport Pacific+Indian"//TRIM(cl_comment), &
+                  "PW", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            ENDIF
+
+
+            !  Salt transport 
+
+            CALL histdef( numptr, "sopstadv", "Advective Salt Transport"      ,   &
+               "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            CALL histdef( numptr, "sopstldf", "Diffusive Salt Transport"      ,   &
+               "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            IF ( ln_ptrcomp ) THEN 
+               CALL histdef( numptr, "sopstove", "Overturning Salt Transport"    ,   &
+                  "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            END IF
+#if defined key_diaeiv
+            ! Eddy induced velocity
+            CALL histdef( numptr, "zomsfeiv", "Bolus Meridional Stream-Function: global",   &
+               "Sv"      , 1, jpj, nhoridz, jpk, 1, jpk, ndepidzw, 32, clop, zsto, zout )
+            CALL histdef( numptr, "sophteiv", "Bolus Advective Heat Transport",   &
+               "PW"      , 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            CALL histdef( numptr, "sopsteiv", "Bolus Advective Salt Transport",   &
+               "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+#endif
+            IF( ln_subbas ) THEN
+               CALL histdef( numptr, "sostatl", "Salt Transport Atlantic"//TRIM(cl_comment)      ,  &
+                  "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sostpac", "Salt Transport Pacific"//TRIM(cl_comment)      ,   &
+                  "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sostind", "Salt Transport Indian"//TRIM(cl_comment)      ,    &
+                  "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+               CALL histdef( numptr, "sostipc", "Salt Transport Pacific+Indian"//TRIM(cl_comment),  &
+                  "Giga g/s", 1, jpj, nhoridz, 1, 1, 1, -99, 32, clop, zsto, zout )
+            ENDIF
+
+            CALL histend( numptr )
+
+         END IF
+#if defined key_mpp_mpi
+      END IF
+#endif
+
+#if defined key_mpp_mpi
+      IF( MOD( itmod, nf_ptr ) == 0 .AND. l_znl_root ) THEN
+#else
+      IF( MOD( itmod, nf_ptr ) == 0  ) THEN
+#endif
+         niter = niter + 1
+
+!-$$         IF(lwp) THEN
+!-$$            WRITE(numout,*)
+!-$$            WRITE(numout,*) 'dia_ptr_wri : write Poleward Transports at time-step : kt = ', kt, &
+!-$$               & 'it = ', it, ' itmod = ', itmod, ' niter = ', niter
+!-$$            WRITE(numout,*) '~~~~~~~~~~'
+!-$$            WRITE(numout,*)
+!-$$         ENDIF
+
+         IF (ln_diaznl ) THEN 
+            CALL histwrite( numptr, "zosrfglo", niter, surf_jk_glo , ndim, ndex )
+            CALL histwrite( numptr, "zotemglo", niter, tn_jk_glo  , ndim, ndex )
+            CALL histwrite( numptr, "zosalglo", niter, sn_jk_glo  , ndim, ndex )
+
+            IF (ln_subbas) THEN 
+               CALL histwrite( numptr, "zosrfatl", niter, surf_jk_atl, ndim_atl, ndex_atl )
+               CALL histwrite( numptr, "zosrfpac", niter, surf_jk_pac, ndim_pac, ndex_pac )
+               CALL histwrite( numptr, "zosrfind", niter, surf_jk_ind, ndim_ind, ndex_ind )
+               CALL histwrite( numptr, "zosrfipc", niter, surf_jk_ipc, ndim_ipc, ndex_ipc )
+
+               CALL histwrite( numptr, "zotematl", niter, tn_jk_atl  , ndim_atl, ndex_atl )
+               CALL histwrite( numptr, "zosalatl", niter, sn_jk_atl  , ndim_atl, ndex_atl )
+               CALL histwrite( numptr, "zotempac", niter, tn_jk_pac  , ndim_pac, ndex_pac )
+               CALL histwrite( numptr, "zosalpac", niter, sn_jk_pac  , ndim_pac, ndex_pac )
+               CALL histwrite( numptr, "zotemind", niter, tn_jk_ind  , ndim_ind, ndex_ind )
+               CALL histwrite( numptr, "zosalind", niter, sn_jk_ind  , ndim_ind, ndex_ind )
+               CALL histwrite( numptr, "zotemipc", niter, tn_jk_ipc  , ndim_ipc, ndex_ipc )
+               CALL histwrite( numptr, "zosalipc", niter, sn_jk_ipc  , ndim_ipc, ndex_ipc )
+            END IF
+         ENDIF
+
+         ! overturning outputs:
+         CALL histwrite( numptr, "zomsfglo", niter, v_msf_glo, ndim, ndex )
+         IF( ln_subbas .AND. ln_diaznl ) THEN
+            CALL histwrite( numptr, "zomsfatl", niter, v_msf_atl , ndim_atl_30, ndex_atl_30 )
+            CALL histwrite( numptr, "zomsfpac", niter, v_msf_pac , ndim_pac_30, ndex_pac_30 )
+            CALL histwrite( numptr, "zomsfind", niter, v_msf_ind , ndim_ind_30, ndex_ind_30 )
+            CALL histwrite( numptr, "zomsfipc", niter, v_msf_ipc , ndim_ipc_30, ndex_ipc_30 )
+         ENDIF
+#if defined key_diaeiv
+         CALL histwrite( numptr, "zomsfeiv", niter, v_msf_eiv_glo, ndim  , ndex   )
+#endif
+
+
+         ! heat transport outputs:
+         IF( ln_subbas ) THEN
+            CALL histwrite( numptr, "sohtatl", niter, ht_atl  , ndim_h_atl_30, ndex_h_atl_30 )
+            CALL histwrite( numptr, "sohtpac", niter, ht_pac  , ndim_h_pac_30, ndex_h_pac_30 )
+            CALL histwrite( numptr, "sohtind", niter, ht_ind  , ndim_h_ind_30, ndex_h_ind_30 )
+            CALL histwrite( numptr, "sohtipc", niter, ht_ipc  , ndim_h_ipc_30, ndex_h_ipc_30 )
+            CALL histwrite( numptr, "sostatl", niter, st_atl  , ndim_h_atl_30, ndex_h_atl_30 )
+            CALL histwrite( numptr, "sostpac", niter, st_pac  , ndim_h_pac_30, ndex_h_pac_30 )
+            CALL histwrite( numptr, "sostind", niter, st_ind  , ndim_h_ind_30, ndex_h_ind_30 )
+            CALL histwrite( numptr, "sostipc", niter, st_ipc  , ndim_h_ipc_30, ndex_h_ipc_30 )
+         ENDIF
+
+         CALL histwrite( numptr, "sophtadv", niter, pht_adv     , ndim_h, ndex_h )
+         CALL histwrite( numptr, "sophtldf", niter, pht_ldf     , ndim_h, ndex_h )
+         CALL histwrite( numptr, "sopstadv", niter, pst_adv     , ndim_h, ndex_h )
+         CALL histwrite( numptr, "sopstldf", niter, pst_ldf     , ndim_h, ndex_h )
+         IF ( ln_ptrcomp ) THEN 
+            CALL histwrite( numptr, "sopstove", niter, pst_ove_glo , ndim_h, ndex_h )
+            CALL histwrite( numptr, "sophtove", niter, pht_ove_glo , ndim_h, ndex_h )
+         ENDIF
+#if defined key_diaeiv
+         CALL histwrite( numptr, "sophteiv", niter, pht_eiv_glo  , ndim_h, ndex_h )
+         CALL histwrite( numptr, "sopsteiv", niter, pst_eiv_glo  , ndim_h, ndex_h )
+#endif
+         !
+      ENDIF
+      !
+   END SUBROUTINE dia_ptr_wri
+
+   !!======================================================================
+END MODULE diaptr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri.F90	(revision 1844)
@@ -0,0 +1,723 @@
+MODULE diawri
+   !!======================================================================
+   !!                     ***  MODULE  diawri  ***
+   !! Ocean diagnostics :  write ocean output files
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE zdf_oce         ! ocean vertical physics
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE sol_oce         ! solver variables
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcssr          ! restoring term toward SST/SSS climatology
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer
+   USE dianam          ! build name of file (routine)
+   USE zdfddm          ! vertical  physics: double diffusion
+   USE diahth          ! thermocline diagnostics
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE diadimg         ! dimg direct access file format output
+   USE diaar5, ONLY :   lk_diaar5
+   USE iom
+   USE ioipsl
+#if defined key_lim2
+   USE limwri_2 
+#endif
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC dia_wri                 ! routines called by step.F90
+   PUBLIC dia_wri_state
+
+   !! * Module variables
+   INTEGER ::   &
+      nid_T, nz_T, nh_T, ndim_T, ndim_hT,      &   ! grid_T file
+      nid_U, nz_U, nh_U, ndim_U, ndim_hU,      &   ! grid_U file
+      nid_V, nz_V, nh_V, ndim_V, ndim_hV,      &   ! grid_V file
+      nid_W, nz_W, nh_W,                       &   ! grid_W file
+      ndex(1)                                      ! ???
+   INTEGER, DIMENSION(jpi*jpj) ::   &
+      ndex_hT, ndex_hU, ndex_hV
+   INTEGER, DIMENSION(jpi*jpj*jpk) ::   &
+      ndex_T, ndex_U, ndex_V
+
+   !! * Substitutions
+#  include "zdfddm_substitute.h90"
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   dia_wri       : create the dimg direct access output file (mpp)
+   !!----------------------------------------------------------------------
+#   include "diawri_dimg.h90"
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                   NetCDF output file
+   !!----------------------------------------------------------------------
+   !!   dia_wri       : create the standart NetCDF output files
+   !!   dia_wri_state : create an output NetCDF file for a single
+   !!                   instantaeous ocean state and forcing fields
+   !!----------------------------------------------------------------------
+# if defined key_iomput
+   SUBROUTINE dia_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :  use iom_put
+      !!
+      !! History :
+      !!   3.2  !  05-11  (B. Lemaire) creation from old diawri
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   z3d => ta   ! use ta as 3D workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER                      ::   ji, jj, jk              ! dummy loop indices
+      REAL(wp)                     ::   zztmp, zztmpx, zztmpy   ! 
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d                     ! 
+      !!----------------------------------------------------------------------
+      ! 
+      ! Output the initial state and forcings
+      IF( ninist == 1 ) THEN                       
+         CALL dia_wri_state( 'output.init', kt )
+         ninist = 0
+      ENDIF
+
+      CALL iom_put( "toce"   , tn                    )    ! temperature
+      CALL iom_put( "soce"   , sn                    )    ! salinity
+      CALL iom_put( "sst"    , tn(:,:,1)             )    ! sea surface temperature
+      CALL iom_put( "sst2"   , tn(:,:,1) * tn(:,:,1) )    ! square of sea surface temperature
+      CALL iom_put( "sss"    , sn(:,:,1)             )    ! sea surface salinity
+      CALL iom_put( "sss2"   , sn(:,:,1) * sn(:,:,1) )    ! square of sea surface salinity
+      CALL iom_put( "uoce"   , un                    )    ! i-current      
+      CALL iom_put( "voce"   , vn                    )    ! j-current
+      
+      CALL iom_put( "avt"    , avt                   )    ! T vert. eddy diff. coef.
+      CALL iom_put( "avm"    , avmu                  )    ! T vert. eddy visc. coef.
+      IF( lk_zdfddm ) THEN
+         CALL iom_put( "avs" , fsavs(:,:,:)          )    ! S vert. eddy diff. coef.
+      ENDIF
+
+      DO jj = 2, jpjm1                                    ! sst gradient
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zztmp      = tn(ji,jj,1)
+            zztmpx     = ( tn(ji+1,jj  ,1) - zztmp ) / e1u(ji,jj) + ( zztmp - tn(ji-1,jj  ,1) ) / e1u(ji-1,jj  )
+            zztmpy     = ( tn(ji  ,jj+1,1) - zztmp ) / e2v(ji,jj) + ( zztmp - tn(ji  ,jj-1,1) ) / e2v(ji  ,jj-1)
+            z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
+               &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
+         END DO
+      END DO
+      CALL lbc_lnk( z2d, 'T', 1. )
+      CALL iom_put( "|sstgrad|2",  z2d               )    ! square of module of sst gradient
+!CDIR NOVERRCHK
+      z2d(:,:) = SQRT( z2d(:,:) )
+      CALL iom_put( "|sstgrad|" ,  z2d               )    ! module of sst gradient
+
+      IF( lk_diaar5 ) THEN
+         z3d(:,:,jpk) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * un(:,:,jk) * e1u(:,:) * fse3u(:,:,jk)
+         END DO
+         CALL iom_put( "u_masstr", z3d )                  ! mass transport in i-direction
+         zztmp = 0.5 * rcp
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * zztmp * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL iom_put( "u_heattr", z2d )                  ! heat transport in i-direction
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e2v(:,:) * fse3v(:,:,jk)
+         END DO
+         CALL iom_put( "v_masstr", z3d )                  ! mass transport in j-direction
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * zztmp * ( tn(ji,jj,jk) + tn(ji,jj+1,jk) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL iom_put( "v_heattr", z2d )                  !  heat transport in i-direction
+      ENDIF
+
+   END SUBROUTINE dia_wri
+
+#else
+   SUBROUTINE dia_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), 
+      !!      define all the NETCDF files and fields
+      !!      At each time step call histdef to compute the mean if ncessary
+      !!      Each nwrite time step, output the instantaneous or mean fields
+      !!
+      !! History :
+      !!        !  91-03  (M.-A. Foujols)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  92-06  (M. Imbard)  correction restart file
+      !!        !  92-07  (M. Imbard)  split into diawri and rstwri
+      !!        !  93-03  (M. Imbard)  suppress writibm
+      !!        !  98-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
+      !!        !  99-02  (E. Guilyardi)  name of netCDF files + variables
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+
+      !! * Local declarations
+      LOGICAL ::   ll_print = .FALSE.    ! =T print and flush numout
+      CHARACTER (len=40) ::           &
+         clhstnam, clop, clmx            ! temporary names
+      INTEGER ::   inum = 11             ! temporary logical unit
+      INTEGER ::   &
+         iimi, iima, ipk, it, itmod,  &  ! temporary integers
+         ijmi, ijma                      !    "          "
+      REAL(wp) ::   &
+         zsto, zout, zmax,            &  ! temporary scalars
+         zjulian, zdt                    !    "         "
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zw2d                            ! temporary workspace
+      !!----------------------------------------------------------------------
+      !
+      ! Output the initial state and forcings
+      IF( ninist == 1 ) THEN                       
+         CALL dia_wri_state( 'output.init', kt )
+         ninist = 0
+      ENDIF
+      !
+      ! 0. Initialisation
+      ! -----------------
+
+      ! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( nacc == 1 ) zdt = rdtmin
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#if defined key_diainstant
+      zsto = nwrite * zdt
+      clop = "inst("//TRIM(clop)//")"
+#else
+      zsto=zdt
+      clop = "ave("//TRIM(clop)//")"
+#endif
+      zout = nwrite * zdt
+      zmax = ( nitend - nit000 + 1 ) * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      it = kt
+      itmod = kt - nit000 + 1
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+
+         ! Define the NETCDF files (one per grid)
+
+         ! Compute julian date from starting date of the run
+         CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) 'Date 0 used :', nit000, ' YEAR ', nyear,   &
+            &                    ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian
+         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,   &
+                                 ' limit storage in depth = ', ipk
+
+         ! WRITE root name in date.file for use by postpro
+         IF(lwp) THEN
+            CALL dia_nam( clhstnam, nwrite,' ' )
+            CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+            WRITE(inum,*) clhstnam
+            CLOSE(inum)
+         ENDIF
+
+         ! Define the T grid FILE ( nid_T )
+
+         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+            &          nit000-1, zjulian, zdt, nh_T, nid_T, domain_id=nidom )
+         CALL histvert( nid_T, "deptht", "Vertical T levels",      &  ! Vertical grid: gdept
+            &           "m", ipk, gdept_0, nz_T, "down" )
+         !                                                            ! Index of ocean points
+         CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_T , ndim_T  )      ! volume
+         CALL wheneq( jpi*jpj    , tmask, 1, 1., ndex_hT, ndim_hT )      ! surface
+
+         ! Define the U grid FILE ( nid_U )
+
+         CALL dia_nam( clhstnam, nwrite, 'grid_U' )
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
+         CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+            &          nit000-1, zjulian, zdt, nh_U, nid_U, domain_id=nidom )
+         CALL histvert( nid_U, "depthu", "Vertical U levels",      &  ! Vertical grid: gdept
+            &           "m", ipk, gdept_0, nz_U, "down" )
+         !                                                            ! Index of ocean points
+         CALL wheneq( jpi*jpj*ipk, umask, 1, 1., ndex_U , ndim_U  )      ! volume
+         CALL wheneq( jpi*jpj    , umask, 1, 1., ndex_hU, ndim_hU )      ! surface
+
+         ! Define the V grid FILE ( nid_V )
+
+         CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
+         CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+            &          nit000-1, zjulian, zdt, nh_V, nid_V, domain_id=nidom )
+         CALL histvert( nid_V, "depthv", "Vertical V levels",      &  ! Vertical grid : gdept
+            &          "m", ipk, gdept_0, nz_V, "down" )
+         !                                                            ! Index of ocean points
+         CALL wheneq( jpi*jpj*ipk, vmask, 1, 1., ndex_V , ndim_V  )      ! volume
+         CALL wheneq( jpi*jpj    , vmask, 1, 1., ndex_hV, ndim_hV )      ! surface
+
+         ! Define the W grid FILE ( nid_W )
+
+         CALL dia_nam( clhstnam, nwrite, 'grid_W' )                   ! filename
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
+            &          nit000-1, zjulian, zdt, nh_W, nid_W, domain_id=nidom )
+         CALL histvert( nid_W, "depthw", "Vertical W levels",      &  ! Vertical grid: gdepw
+            &          "m", ipk, gdepw_0, nz_W, "down" )
+
+
+         ! Declare all the output fields as NETCDF variables
+
+         !                                                                                      !!! nid_T : 3D
+         CALL histdef( nid_T, "votemper", "Temperature"                        , "C"      ,   &  ! tn
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vosaline", "Salinity"                           , "PSU"    ,   &  ! sn
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         !                                                                                      !!! nid_T : 2D
+         CALL histdef( nid_T, "sosstsst", "Sea Surface temperature"            , "C"      ,   &  ! sst
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosaline", "Sea Surface Salinity"               , "PSU"    ,   &  ! sss
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sossheig", "Sea Surface Height"                 , "m"      ,   &  ! ssh
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+!!$#if defined key_lim3 || defined key_lim2 
+!!$         ! sowaflup = sowaflep + sorunoff + sowafldp + a term associated to
+!!$         !    internal damping to Levitus that can be diagnosed from others
+!!$         ! sowaflcd = sowaflep + sorunoff + sowafldp + iowaflup
+!!$         CALL histdef( nid_T, "iowaflup", "Ice=>ocean net freshwater"          , "kg/m2/s",   &  ! fsalt
+!!$            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+!!$         CALL histdef( nid_T, "sowaflep", "atmos=>ocean net freshwater"        , "kg/m2/s",   &  ! fmass
+!!$            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+!!$#endif
+         CALL histdef( nid_T, "sowaflup", "Net Upward Water Flux"              , "Kg/m2/s",   &  ! emp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+!!$         CALL histdef( nid_T, "sorunoff", "Runoffs"                            , "Kg/m2/s",   &  ! runoffs
+!!$            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowaflcd", "concentration/dilution water flux"  , "kg/m2/s",   &  ! emps
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosalflx", "Surface Salt Flux"                  , "Kg/m2/s",   &  ! emps * sn
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux"             , "W/m2"   ,   &  ! qns + qsr
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "soshfldo", "Shortwave Radiation"                , "W/m2"   ,   &  ! qsr
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "somixhgt", "Turbocline Depth"                   , "m"      ,   &  ! hmld
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "somxl010", "Mixed Layer Depth 0.01"             , "m"      ,   &  ! hmlp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "soicecov", "Ice fraction"                       , "[0,1]"  ,   &  ! fr_i
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowindsp", "wind speed at 10m"                  , "m/s"    ,   &  ! wndm
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#if ! defined key_coupled 
+         CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosafldp", "Surface salt flux: damping"         , "Kg/m2/s",   &  ! erp * sn
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+
+
+
+#if ( defined key_coupled && ! defined key_lim3 && ! defined key_lim2 ) 
+         CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosafldp", "Surface salt flux: Damping"         , "Kg/m2/s",   &  ! erp * sn
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+#if defined key_diaspr
+         CALL histdef( nid_T, "sosurfps", "Surface Pressure"                   , "cm"     ,   &  ! sp
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+         clmx ="l_max(only(x))"    ! max index on a period
+         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
+#if defined key_diahth
+         CALL histdef( nid_T, "sothedep", "Thermocline Depth"                  , "m"      ,   & ! hth
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "so20chgt", "Depth of 20C isotherm"              , "m"      ,   & ! hd20
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "so28chgt", "Depth of 28C isotherm"              , "m"      ,   & ! hd28
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sohtc300", "Heat content 300 m"                 , "W"      ,   & ! htc3
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+
+#if defined key_coupled 
+# if defined key_lim3
+         Must be adapted to LIM3
+# else
+         CALL histdef( nid_T,"soicetem" , "Ice Surface Temperature"            , "K"      ,   &  ! tn_ice
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T,"soicealb" , "Ice Albedo"                         , "[0,1]"  ,   &  ! alb_ice
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+# endif 
+#endif 
+
+         CALL histend( nid_T )
+
+         !                                                                                      !!! nid_U : 3D
+         CALL histdef( nid_U, "vozocrtx", "Zonal Current"                      , "m/s"    ,   &  ! un
+            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
+#if defined key_diaeiv
+         CALL histdef( nid_U, "vozoeivu", "Zonal EIV Current"                  , "m/s"    ,   &  ! u_eiv
+            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
+#endif
+         !                                                                                      !!! nid_U : 2D
+         CALL histdef( nid_U, "sozotaux", "Wind Stress along i-axis"           , "N/m2"   ,   &  ! utau
+            &          jpi, jpj, nh_U, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+
+         CALL histend( nid_U )
+
+         !                                                                                      !!! nid_V : 3D
+         CALL histdef( nid_V, "vomecrty", "Meridional Current"                 , "m/s"    ,   &  ! vn
+            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
+#if defined key_diaeiv
+         CALL histdef( nid_V, "vomeeivv", "Meridional EIV Current"             , "m/s"    ,   &  ! v_eiv
+            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
+#endif
+         !                                                                                      !!! nid_V : 2D
+         CALL histdef( nid_V, "sometauy", "Wind Stress along j-axis"           , "N/m2"   ,   &  ! vtau
+            &          jpi, jpj, nh_V, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+
+         CALL histend( nid_V )
+
+         !                                                                                      !!! nid_W : 3D
+         CALL histdef( nid_W, "vovecrtz", "Vertical Velocity"                  , "m/s"    ,   &  ! wn
+            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
+#if defined key_diaeiv
+         CALL histdef( nid_W, "voveeivw", "Vertical EIV Velocity"              , "m/s"    ,   &  ! w_eiv
+            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
+#endif
+         CALL histdef( nid_W, "votkeavt", "Vertical Eddy Diffusivity"          , "m2/s"   ,   &  ! avt
+            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
+         CALL histdef( nid_W, "votkeavm", "Vertical Eddy Viscosity"             , "m2/s"  ,   &  ! avmu
+            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
+
+         IF( lk_zdfddm ) THEN
+            CALL histdef( nid_W,"voddmavs","Salt Vertical Eddy Diffusivity"    , "m2/s"   ,   &  ! avs
+               &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
+         ENDIF
+         !                                                                                      !!! nid_W : 2D
+#if defined key_traldf_c2d
+         CALL histdef( nid_W, "soleahtw", "lateral eddy diffusivity"           , "m2/s"   ,   &  ! ahtw
+            &          jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+# if defined key_traldf_eiv 
+            CALL histdef( nid_W, "soleaeiw", "eddy induced vel. coeff. at w-point", "m2/s",   &  ! aeiw
+               &       jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
+# endif
+#endif
+
+         CALL histend( nid_W )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization'
+         IF(ll_print) CALL FLUSH(numout )
+
+      ENDIF
+
+      ! 2. Start writing data
+      ! ---------------------
+
+      ! ndex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et ndex la liste des indices a sortir
+
+      IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN 
+         WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      ! Write fields on T grid
+      CALL histwrite( nid_T, "votemper", it, tn            , ndim_T , ndex_T  )   ! temperature
+      CALL histwrite( nid_T, "vosaline", it, sn            , ndim_T , ndex_T  )   ! salinity
+      CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface temperature
+      CALL histwrite( nid_T, "sosaline", it, sn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface salinity
+      CALL histwrite( nid_T, "sossheig", it, sshn          , ndim_hT, ndex_hT )   ! sea surface height
+!!$#if  defined key_lim3 || defined key_lim2 
+!!$      CALL histwrite( nid_T, "iowaflup", it, fsalt(:,:)    , ndim_hT, ndex_hT )   ! ice=>ocean water flux
+!!$      CALL histwrite( nid_T, "sowaflep", it, fmass(:,:)    , ndim_hT, ndex_hT )   ! atmos=>ocean water flux
+!!$#endif
+      CALL histwrite( nid_T, "sowaflup", it, emp           , ndim_hT, ndex_hT )   ! upward water flux
+!!$      CALL histwrite( nid_T, "sorunoff", it, runoff        , ndim_hT, ndex_hT )   ! runoff
+      CALL histwrite( nid_T, "sowaflcd", it, emps          , ndim_hT, ndex_hT )   ! c/d water flux
+      zw2d(:,:) = emps(:,:) * sn(:,:,1) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sosalflx", it, zw2d          , ndim_hT, ndex_hT )   ! c/d salt flux
+      CALL histwrite( nid_T, "sohefldo", it, qns + qsr     , ndim_hT, ndex_hT )   ! total heat flux
+      CALL histwrite( nid_T, "soshfldo", it, qsr           , ndim_hT, ndex_hT )   ! solar heat flux
+      CALL histwrite( nid_T, "somixhgt", it, hmld          , ndim_hT, ndex_hT )   ! turbocline depth
+      CALL histwrite( nid_T, "somxl010", it, hmlp          , ndim_hT, ndex_hT )   ! mixed layer depth
+      CALL histwrite( nid_T, "soicecov", it, fr_i          , ndim_hT, ndex_hT )   ! ice fraction   
+      CALL histwrite( nid_T, "sowindsp", it, wndm          , ndim_hT, ndex_hT )   ! wind speed   
+#if ! defined key_coupled
+      CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
+      CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
+      zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
+#endif
+#if ( defined key_coupled && ! defined key_lim3 && ! defined key_lim2 ) 
+      CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
+      CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
+         zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
+#endif
+#if defined key_diaspr
+      CALL histwrite( nid_T, "sosurfps", it, gps           , ndim_hT, ndex_hT )   ! surface pressure
+#endif
+         zw2d(:,:) = FLOAT( nmln(:,:) ) * tmask(:,:,1)
+      CALL histwrite( nid_T, "sobowlin", it, zw2d          , ndim_hT, ndex_hT )   ! ???
+
+#if defined key_diahth
+      CALL histwrite( nid_T, "sothedep", it, hth           , ndim_hT, ndex_hT )   ! depth of the thermocline
+      CALL histwrite( nid_T, "so20chgt", it, hd20          , ndim_hT, ndex_hT )   ! depth of the 20 isotherm
+      CALL histwrite( nid_T, "so28chgt", it, hd28          , ndim_hT, ndex_hT )   ! depth of the 28 isotherm
+      CALL histwrite( nid_T, "sohtc300", it, htc3          , ndim_hT, ndex_hT )   ! first 300m heaat content
+#endif
+
+#if defined key_coupled 
+# if defined key_lim3
+      Must be adapted for LIM3
+      CALL histwrite( nid_T, "soicetem", it, tn_ice        , ndim_hT, ndex_hT )   ! surf. ice temperature
+      CALL histwrite( nid_T, "soicealb", it, alb_ice       , ndim_hT, ndex_hT )   ! ice albedo
+# else
+      CALL histwrite( nid_T, "soicetem", it, tn_ice(:,:,1) , ndim_hT, ndex_hT )   ! surf. ice temperature
+      CALL histwrite( nid_T, "soicealb", it, alb_ice(:,:,1), ndim_hT, ndex_hT )   ! ice albedo
+# endif
+#endif
+         ! Write fields on U grid
+      CALL histwrite( nid_U, "vozocrtx", it, un            , ndim_U , ndex_U )    ! i-current
+#if defined key_diaeiv
+      CALL histwrite( nid_U, "vozoeivu", it, u_eiv         , ndim_U , ndex_U )    ! i-eiv current
+#endif
+      CALL histwrite( nid_U, "sozotaux", it, utau          , ndim_hU, ndex_hU )   ! i-wind stress
+
+         ! Write fields on V grid
+      CALL histwrite( nid_V, "vomecrty", it, vn            , ndim_V , ndex_V  )   ! j-current
+#if defined key_diaeiv
+      CALL histwrite( nid_V, "vomeeivv", it, v_eiv         , ndim_V , ndex_V  )   ! j-eiv current
+#endif
+      CALL histwrite( nid_V, "sometauy", it, vtau          , ndim_hV, ndex_hV )   ! j-wind stress
+
+         ! Write fields on W grid
+      CALL histwrite( nid_W, "vovecrtz", it, wn             , ndim_T, ndex_T )    ! vert. current
+#   if defined key_diaeiv
+      CALL histwrite( nid_W, "voveeivw", it, w_eiv          , ndim_T, ndex_T )    ! vert. eiv current
+#   endif
+      CALL histwrite( nid_W, "votkeavt", it, avt            , ndim_T, ndex_T )    ! T vert. eddy diff. coef.
+      CALL histwrite( nid_W, "votkeavm", it, avmu           , ndim_T, ndex_T )    ! T vert. eddy visc. coef.
+      IF( lk_zdfddm ) THEN
+         CALL histwrite( nid_W, "voddmavs", it, fsavs(:,:,:), ndim_T, ndex_T )    ! S vert. eddy diff. coef.
+      ENDIF
+#if defined key_traldf_c2d
+      CALL histwrite( nid_W, "soleahtw", it, ahtw          , ndim_hT, ndex_hT )   ! lateral eddy diff. coef.
+# if defined key_traldf_eiv
+         CALL histwrite( nid_W, "soleaeiw", it, aeiw       , ndim_hT, ndex_hT )   ! EIV coefficient at w-point
+# endif
+#endif
+
+      ! 3. Close all files
+      ! ---------------------------------------
+      IF( kt == nitend ) THEN
+         CALL histclo( nid_T )
+         CALL histclo( nid_U )
+         CALL histclo( nid_V )
+         CALL histclo( nid_W )
+      ENDIF
+
+   END SUBROUTINE dia_wri
+# endif
+
+#endif
+
+   SUBROUTINE dia_wri_state( cdfile_name, kt )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_wri_state  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ocean state and forcing fields.
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! ** Method  :   NetCDF files using ioipsl
+      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
+      !!      File 'output.abort.nc' is created in case of abnormal job end
+      !!
+      !! History :
+      !!   8.2  !  00-06  (M. Imbard)  Original code (diabort.F)
+      !!   8.5  !  02-06  (A.Bozec, E. Durand)  Original code (diainit.F)
+      !!   9.0  !  02-12  (G. Madec)  merge of diabort and diainit, F90
+      !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
+      INTEGER           , INTENT( in ) ::   kt               ! ocean time-step index
+
+      !! * Local declarations
+      CHARACTER (len=32) :: clname
+      CHARACTER (len=40) :: clop
+      INTEGER  ::   &
+         id_i , nz_i, nh_i       
+      INTEGER, DIMENSION(1) ::   &
+         idex             ! temprary workspace
+      REAL(wp) ::   &
+         zsto, zout, zmax,   &
+         zjulian, zdt
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialisation
+      ! -----------------
+
+      ! Define name, frequency of output and means
+      clname = cdfile_name
+      IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      zdt  = rdt
+      zsto = rdt
+      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
+      zout = rdt
+      zmax = ( nitend - nit000 + 1 ) * zdt
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
+      IF(lwp) WRITE(numout,*) '                and named :', clname, '.nc'
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      ! Compute julian date from starting date of the run
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )         ! time axis 
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      CALL histbeg( clname, jpi, glamt, jpj, gphit,   &
+          1, jpi, 1, jpj, nit000-1, zjulian, zdt, nh_i, id_i, domain_id=nidom )          ! Horizontal grid : glamt and gphit
+      CALL histvert( id_i, "deptht", "Vertical T levels",   &    ! Vertical grid : gdept
+          "m", jpk, gdept_0, nz_i, "down")
+
+      ! Declare all the output fields as NetCDF variables
+
+      CALL histdef( id_i, "vosaline", "Salinity"              , "PSU"    ,   &   ! salinity
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
+         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vomecrty", "Meridional Current"    , "m/s"    ,   &   ! meridonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      CALL histdef( id_i, "vovecrtz", "Vertical Velocity"     , "m/s"    ,   &   ! vertical current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S",   &   ! net freshwater 
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2"   ,   &   ! net heat flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soshfldo", "Shortwave Radiation"   , "W/m2"   ,   &   ! solar flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soicecov", "Ice fraction"          , "[0,1]"  ,   &   ! fr_i
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sozotaux", "Zonal Wind Stress"     , "N/m2"   ,   &   ! i-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+
+#if defined key_lim2
+      CALL lim_wri_state_2( kt, id_i, nh_i )
+#else
+      CALL histend( id_i )
+#endif
+
+      ! 2. Start writing data
+      ! ---------------------
+      ! idex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et idex la liste des indices a sortir
+      idex(1) = 1   ! init to avoid compil warning
+
+      ! Write all fields on T grid
+      CALL histwrite( id_i, "votemper", kt, tn      , jpi*jpj*jpk, idex )    ! now temperature
+      CALL histwrite( id_i, "vosaline", kt, sn      , jpi*jpj*jpk, idex )    ! now salinity
+      CALL histwrite( id_i, "sossheig", kt, sshn     , jpi*jpj    , idex )    ! sea surface height
+      CALL histwrite( id_i, "vozocrtx", kt, un       , jpi*jpj*jpk, idex )    ! now i-velocity
+      CALL histwrite( id_i, "vomecrty", kt, vn       , jpi*jpj*jpk, idex )    ! now j-velocity
+      CALL histwrite( id_i, "vovecrtz", kt, wn       , jpi*jpj*jpk, idex )    ! now k-velocity
+      CALL histwrite( id_i, "sowaflup", kt, emp      , jpi*jpj    , idex )    ! freshwater budget
+      CALL histwrite( id_i, "sohefldo", kt, qsr + qns, jpi*jpj    , idex )    ! total heat flux
+      CALL histwrite( id_i, "soshfldo", kt, qsr      , jpi*jpj    , idex )    ! solar heat flux
+      CALL histwrite( id_i, "soicecov", kt, fr_i     , jpi*jpj    , idex )    ! ice fraction
+      CALL histwrite( id_i, "sozotaux", kt, utau     , jpi*jpj    , idex )    ! i-wind stress
+      CALL histwrite( id_i, "sometauy", kt, vtau     , jpi*jpj    , idex )    ! j-wind stress
+
+      ! 3. Close the file
+      ! -----------------
+      CALL histclo( id_i )
+#if ! defined key_iomput && ! defined key_dimgout
+      IF( ninist /= 1  ) THEN
+         CALL histclo( nid_T )
+         CALL histclo( nid_U )
+         CALL histclo( nid_V )
+         CALL histclo( nid_W )
+      ENDIF
+#endif
+
+   END SUBROUTINE dia_wri_state
+   !!======================================================================
+END MODULE diawri
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri_dimg.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 1844)
@@ -0,0 +1,386 @@
+  !!----------------------------------------------------------------------
+  !!                        ***  diawri_dimg.h90  ***
+  !!----------------------------------------------------------------------
+  !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+  !! $Id$
+  !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+  !!----------------------------------------------------------------------
+
+  SUBROUTINE dia_wri (kt)
+    !!----------------------------------------------------------------------
+    !!           *** routine dia_wri ***
+    !!
+    !! ** Purpose : output dynamics and tracer fields on direct access file
+    !!              suitable for MPP computing
+    !!
+    !! ** define key : 'key_dimgout'
+    !!
+    !! **  Method : Default is to cumulate the values over the interval between
+    !!      2 output, and each nwrite time-steps  the mean value is  computed 
+    !!      and written to the direct access file.
+    !!     If 'key_diainstant' is defined, no mean values are computed and the 
+    !!     instantaneous fields are dump.
+    !!       Each processor creates its own file with its local data
+    !!     Merging all the files is performed off line by a dedicated program
+    !!
+    !! ** Arguments :
+    !!     kt      : time-step number
+    !!     kindinc :  error condition indicator : >=0 :  OK, < 0 : error.
+    !!
+    !! ** Naming convention for files
+    !!
+    !! {cexper}_{var}_y----m--d--.dimg
+    !!   cexper is the name of the experience, given in the namelist
+    !!   var can be either U, V, T, S, KZ, SSH, ...
+    !!   var can also be 2D, which means that each level of the file is a 2D field as described below
+    !!    y----m--d--  is the date at the time of the dump
+    !!    For mpp output, each processor dumps its own memory, on appropriate record range 
+    !!    (direct access : for level jk of a klev field on proc narea irec = 1+ klev*(narea -1) + jk )
+    !!    To be tested with a lot of procs !!!!
+    !!
+    !!  level 1:  utau(:,:) * umask(:,:,1) zonal stress in N.m-2
+    !!  level 2:  vtau(:,:) * vmask(:,:,1) meridional stress in N. m-2
+    !!  level 3:  qsr + qns                total heat flux (W/m2)
+    !!  level 4:  emp (:,:)               E-P flux (mm/day)
+    !!  level 5:  tb  (:,:,1)-sst          model SST -forcing sst (degree C) ! deprecated
+    !!  level 6:  bsfb(:,:)		   streamfunction (m**3/s)
+    !!  level 7:  qsr (:,:)		   solar flux (W/m2)
+    !!  level 8:  qrp (:,:)                relax component of T flux.
+    !!  level 9:  erp (:,:)                relax component of S flux
+    !!  level 10: hmld(:,:)                turbocline depth
+    !!  level 11: hmlp(:,:)                mixed layer depth
+    !!  level 12: fr_i(:,:)                ice fraction (between 0 and 1)
+    !!  level 13: sst(:,:)                 the observed SST we relax to. ! deprecated
+    !!  level 14: qct(:,:)                 equivalent flux due to treshold SST
+    !!  level 15: fbt(:,:)                 feedback term .
+    !!  level 16: emps(:,:)                concentration/dilution water flux
+    !!  level 17: fsalt(:,:)               Ice=>ocean net freshwater
+    !!  level 18: gps(:,:)                 the surface pressure (m).
+    !!  level 19: spgu(:,:)                the surface pressure gradient in X direction.
+    !!  level 20: spgv(:,:)                the surface pressure gradient in Y direction.
+    !! 
+    !! History 
+    !!      original  : 91-03 ()
+    !!      additions : 91-11 (G. Madec)
+    !!      additions : 92-06 (M. Imbard) correction restart file
+    !!      additions : 92-07 (M. Imbard) split into diawri and rstwri
+    !!      additions : 93-03 (M. Imbard) suppress writibm
+    !!      additions : 94-12 (M. Imbard) acces direct files
+    !!      additions : 97-2002 ( Clipper Group ) dimg files
+    !!                  dec 2003 ( J.M. Molines) f90, mpp output for OPA9.0
+    !!   9.0  !  05-05  (S. Theetten) add emps fsalt move gps spgu spgv 2 lines below
+    !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+    !!----------------------------------------------------------------------
+    !! * modules used
+    USE lib_mpp
+
+    !! * Arguments
+    INTEGER ,INTENT(in) :: kt
+
+    !! * local declarations
+    INTEGER :: inbsel, jk
+!!  INTEGER :: iwrite
+    INTEGER :: iyear,imon,iday
+    INTEGER, SAVE :: nmoyct 
+
+#if defined key_diainstant
+    LOGICAL, PARAMETER :: ll_dia_inst=.TRUE.  !: for instantaneous output
+#else
+    LOGICAL, PARAMETER :: ll_dia_inst=.FALSE. !: for average output
+#endif
+
+    REAL(wp), SAVE, DIMENSION (jpi,jpj,jpk) ::  um , vm   ! used to compute mean u, v fields
+    REAL(wp), SAVE, DIMENSION (jpi,jpj,jpk) ::  wm        ! used to compute mean w fields
+    REAL(wp), SAVE, DIMENSION (jpi,jpj,jpk) ::  avtm      ! used to compute mean kz fields
+    REAL(wp), SAVE, DIMENSION (jpi,jpj,jpk) ::  tm , sm   ! used to compute mean t, s fields
+    REAL(wp), SAVE, DIMENSION (jpi,jpj,jpk) ::  fsel      ! used to compute mean 2d fields
+    REAL(wp) :: zdtj
+    !
+    CHARACTER(LEN=80) :: clname
+    CHARACTER(LEN=80) :: cltext
+    CHARACTER(LEN=80) :: clmode
+    CHARACTER(LEN= 4) :: clver
+    !
+    !  Initialization
+    !  ---------------
+    !
+#ifdef key_diaspr
+    inbsel = 20
+#else
+    inbsel = 17
+#endif
+#if defined key_flx_core
+    inbsel = 23
+#endif
+
+    IF( inbsel >  jpk) THEN
+       IF( lwp) WRITE(numout,*)  &
+            ' STOP inbsel =',inbsel,' is larger than jpk=',jpk
+       STOP
+    ENDIF
+
+
+    iyear = ndastp/10000
+    imon = (ndastp-iyear*10000)/100
+    iday = ndastp - imon*100 - iyear*10000
+
+    !     
+    !! dimg format V1.0 should start with the 4 char. string '@!01'
+    !!
+    clver='@!01'
+    !
+    IF( .NOT. ll_dia_inst ) THEN
+       !
+       !! * Mean output section
+       !! ----------------------
+       !
+       IF( kt == nit000 .AND. lwp ) WRITE(numout,*) &
+            'THE OUTPUT FILES CONTAINS THE AVERAGE OF EACH FIELD'
+       !
+       IF( kt == nit000  ) THEN
+          ! reset arrays for average computation
+          nmoyct = 0
+          !
+          um(:,:,:) = 0._wp
+          vm(:,:,:) = 0._wp
+          wm(:,:,:) = 0._wp
+          avtm(:,:,:) = 0._wp
+          tm(:,:,:) = 0._wp
+          sm(:,:,:) = 0._wp
+          fsel(:,:,:) = 0._wp
+          !
+       ENDIF
+
+       !  cumulate values
+       !  ---------------
+
+       nmoyct = nmoyct+1
+       !
+       um(:,:,:)=um(:,:,:) + un (:,:,:)
+       vm(:,:,:)=vm(:,:,:) + vn (:,:,:)
+       wm(:,:,:)=wm(:,:,:) + wn (:,:,:)
+       avtm(:,:,:)=avtm(:,:,:) + avt (:,:,:)
+       tm(:,:,:)=tm(:,:,:) + tn (:,:,:)
+       sm(:,:,:)=sm(:,:,:) + sn (:,:,:)
+       !
+       fsel(:,:,1 ) = fsel(:,:,1 ) + utau(:,:) * umask(:,:,1)
+       fsel(:,:,2 ) = fsel(:,:,2 ) + vtau(:,:) * vmask(:,:,1)
+       fsel(:,:,3 ) = fsel(:,:,3 ) + qsr (:,:) + qns  (:,:) 
+       fsel(:,:,4 ) = fsel(:,:,4 ) + emp (:,:)
+       !        fsel(:,:,5 ) = fsel(:,:,5 ) + tb  (:,:,1)  !RB not used
+       fsel(:,:,6 ) = fsel(:,:,6 ) + sshn(:,:) 
+       fsel(:,:,7 ) = fsel(:,:,7 ) + qsr(:,:)
+       fsel(:,:,8 ) = fsel(:,:,8 ) + qrp (:,:)
+       fsel(:,:,9 ) = fsel(:,:,9 ) + erp (:,:)
+       fsel(:,:,10) = fsel(:,:,10) + hmld(:,:)
+       fsel(:,:,11) = fsel(:,:,11) + hmlp(:,:)
+       fsel(:,:,12) = fsel(:,:,12) + fr_i(:,:)
+       !        fsel(:,:,13) = fsel(:,:,13)   !RB not used
+       !        fsel(:,:,14) = fsel(:,:,14) + qct(:,:)
+       !        fsel(:,:,15) = fsel(:,:,15) + fbt(:,:)
+       fsel(:,:,16) = fsel(:,:,16) + emps(:,:)
+#ifdef key_diaspr   
+       fsel(:,:,18) = fsel(:,:,18) + gps(:,:)/g 
+#endif
+       !
+       ! Output of dynamics and tracer fields and selected fields
+       ! --------------------------------------------------------
+       !
+       !
+       zdtj=rdt/86400.   ! time step in days
+       WRITE(clmode,'(f5.1,a)' ) nwrite*zdtj,' days average'
+
+       !       iwrite=NINT(adatrj/rwrite)
+       !      IF (abs(adatrj-iwrite*rwrite) < zdtj/2.      &
+
+       IF(  ( MOD (kt-nit000+1,nwrite) ==  0 )          &
+            &   .OR. ( kt == 1 .AND. ninist ==1 )  ) THEN
+          ! it is time to make a dump on file 
+          ! compute average
+          um(:,:,:) = um(:,:,:) / nmoyct
+          vm(:,:,:) = vm(:,:,:) / nmoyct
+          wm(:,:,:) = wm(:,:,:) / nmoyct
+          avtm(:,:,:) = avtm(:,:,:) / nmoyct
+          tm(:,:,:) = tm(:,:,:) / nmoyct
+          sm(:,:,:) = sm(:,:,:) / nmoyct
+          !
+          fsel(:,:,:) = fsel(:,:,:) / nmoyct
+          !
+          ! note : the surface pressure is not averaged, but rather 
+          ! computed from the averaged gradients.
+          !
+#ifdef key_diaspr
+          fsel(:,:,18)= gps(:,:)/g
+          fsel(:,:,19)= spgu(:,:)
+          fsel(:,:,20)= spgv(:,:)
+#endif
+          ! mask mean field with tmask except utau vtau (1,2)
+          DO jk=3,inbsel
+            fsel(:,:,jk)=fsel(:,:,jk)*tmask(:,:,1)
+          END DO
+       ENDIF
+       !
+    ELSE   ! ll_dia_inst true
+       !
+       !! * Instantaneous output section
+       !! ------------------------------
+       !
+       IF( kt == nit000 .AND. lwp ) WRITE(numout,*) &
+            'THE OUTPUT FILES CONTAINS INSTANTANEOUS VALUES OF EACH FIELD'
+       !
+       zdtj=rdt/86400.   ! time step in days
+       !  iwrite=NINT(adatrj/rwrite)
+       clmode='instantaneous'
+       !     IF (abs(adatrj-iwrite*rwrite) < zdtj/2.  &
+       IF (  ( MOD (kt-nit000+1,nwrite) ==  0 )          &
+            &   .OR. ( kt == 1 .AND. ninist == 1 )  ) THEN
+          !
+          ! transfer wp arrays to sp arrays for dimg files
+          fsel(:,:,:) = 0._wp
+          !
+          fsel(:,:,1 ) = utau(:,:) * umask(:,:,1)
+          fsel(:,:,2 ) = vtau(:,:) * vmask(:,:,1)
+          fsel(:,:,3 ) = (qsr (:,:) + qns (:,:)) * tmask(:,:,1)
+          fsel(:,:,4 ) = emp (:,:) * tmask(:,:,1)
+          !         fsel(:,:,5 ) = (tb  (:,:,1) - sf_sst(1)%fnow(:,:) ) *tmask(:,:,1) !RB not used
+
+          fsel(:,:,6 ) = sshn(:,:)
+          fsel(:,:,7 ) = qsr (:,:) * tmask(:,:,1)
+          fsel(:,:,8 ) = qrp (:,:) * tmask(:,:,1)
+          fsel(:,:,9 ) = erp (:,:) * tmask(:,:,1)
+          fsel(:,:,10) = hmld(:,:) * tmask(:,:,1)
+          fsel(:,:,11) = hmlp(:,:) * tmask(:,:,1)
+          fsel(:,:,12) = fr_i(:,:) * tmask(:,:,1)
+          !         fsel(:,:,13) = sf_sst(1)%fnow(:,:) !RB not used
+          !         fsel(:,:,14) =  qct(:,:)
+          !         fsel(:,:,15) =  fbt(:,:)
+          fsel(:,:,16) =  emps(:,:) * tmask(:,:,1)
+#ifdef key_diaspr           
+          fsel(:,:,18) =      gps(:,:) /g
+          fsel(:,:,19) =      spgu(:,:)
+          fsel(:,:,20) =      spgv(:,:)
+#endif
+          !
+          !         qct(:,:) = 0._wp
+       ENDIF
+    ENDIF
+    !
+    ! Opening of the datrj.out file with the absolute time in day of each dump
+    ! this file gives a record of the dump date for post processing ( ASCII file )
+    !
+    IF(  ( MOD (kt-nit000+1,nwrite) ==  0 )          &
+         &   .OR. ( kt == 1 .AND. ninist == 1 )  ) THEN
+
+       IF( lwp) WRITE(numout,*)'Days since the begining of the run :',adatrj
+
+       !! * U section
+
+       WRITE(clname,9000) TRIM(cexper),'U',iyear,imon,iday
+       cltext=TRIM(cexper)//' U(m/s) '//TRIM(clmode)
+       !
+       IF( ll_dia_inst) THEN 
+          CALL dia_wri_dimg(clname, cltext, un, jpk, 'T')
+
+       ELSE 
+          CALL dia_wri_dimg(clname, cltext, um, jpk, 'T')
+       ENDIF
+
+       !! * V section
+
+       WRITE(clname,9000) TRIM(cexper),'V',iyear,imon,iday
+       cltext=TRIM(cexper)//' V(m/s) '//TRIM(clmode)
+       !
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, vn, jpk, 'T')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, vm, jpk, 'T')
+       ENDIF
+       !
+
+       !! * KZ section
+
+       WRITE(clname,9000) TRIM(cexper),'KZ',iyear,imon,iday
+       cltext=TRIM(cexper)//' KZ(m2/s) '//TRIM(clmode)
+
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, avt, jpk, 'W')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, avtm, jpk, 'W')
+       ENDIF
+       !
+
+       !! * W section
+
+       WRITE(clname,9000) TRIM(cexper),'W',iyear,imon,iday
+       cltext=TRIM(cexper)//' W(m/s) '//TRIM(clmode)
+
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, wn, jpk, 'W')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, wm, jpk, 'W')
+       ENDIF
+
+       !! * T section
+
+       WRITE(clname,9000) TRIM(cexper),'T',iyear,imon,iday
+       cltext=TRIM(cexper)//' T (DegC) '//TRIM(clmode)
+
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, tn, jpk, 'T')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, tm, jpk, 'T')
+       ENDIF
+       !
+
+       !! * S section
+
+       WRITE(clname,9000) TRIM(cexper),'S',iyear,imon,iday
+       cltext=TRIM(cexper)//' S (PSU) '//TRIM(clmode)
+
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, sn, jpk, 'T')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, sm, jpk, 'T')
+       ENDIF
+       !
+
+       !! * 2D section
+
+       WRITE(clname,9000) TRIM(cexper),'2D',iyear,imon,iday
+       cltext='2D fields '//TRIM(clmode)
+
+       IF( ll_dia_inst) THEN
+          CALL dia_wri_dimg(clname, cltext, fsel, inbsel, '2')
+       ELSE
+          CALL dia_wri_dimg(clname, cltext, fsel, inbsel, '2')
+       ENDIF
+
+       IF( lk_mpp )   CALL mppsync   ! synchronization in mpp
+
+       !! * Log message in numout 
+
+       IF( lwp)WRITE(numout,*) ' '
+       IF( lwp)WRITE(numout,*) ' **** WRITE in dimg file ',kt
+
+       IF( lwp .AND.        ll_dia_inst) WRITE(numout,*) '    instantaneous fields'
+       IF( lwp .AND. .NOT.  ll_dia_inst) WRITE(numout,*) '    average fields with ',nmoyct,'pdt'
+       !
+       !
+       !! * Reset cumulating arrays  and counter to 0 after writing
+       !
+       IF( .NOT. ll_dia_inst ) THEN
+          nmoyct = 0
+          !
+          um(:,:,:) = 0._wp
+          vm(:,:,:) = 0._wp
+          wm(:,:,:) = 0._wp
+          tm(:,:,:) = 0._wp
+          sm(:,:,:) = 0._wp
+          fsel(:,:,:) = 0._wp
+          avtm(:,:,:) = 0._wp
+       ENDIF
+    ENDIF
+    !
+9000 FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
+
+  END SUBROUTINE dia_wri
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/closea.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/closea.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/closea.F90	(revision 1844)
@@ -0,0 +1,376 @@
+MODULE closea
+   !!======================================================================
+   !!                       ***  MODULE  closea  ***
+   !! Closed Seas  : specific treatments associated with closed seas
+   !!======================================================================
+   !! History :   8.2  !  00-05  (O. Marti)  Original code
+   !!             8.5  !  02-06  (E. Durand, G. Madec)  F90
+   !!             9.0  !  06-07  (G. Madec)  add clo_rnf, clo_ups, clo_bat
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_clo    : modification of the ocean domain for closed seas cases
+   !!   sbc_clo    : Special handling of closed seas
+   !!   clo_rnf    : set close sea outflows as river mouths (see sbcrnf)
+   !!   clo_ups    : set mixed centered/upstream scheme in closed sea (see traadv_cen2)
+   !!   clo_bat    : set to zero a field over closed sea (see domzrg)
+   !!----------------------------------------------------------------------
+   USE oce             ! dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE sbc_oce         ! ocean surface boundary conditions
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ???
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dom_clo      ! routine called by domain module
+   PUBLIC sbc_clo      ! routine called by step module
+   PUBLIC clo_rnf      ! routine called by sbcrnf module
+   PUBLIC clo_ups      ! routine called in traadv_cen2(_jki) module
+   PUBLIC clo_bat      ! routine called in domzgr module
+
+   INTEGER, PUBLIC, PARAMETER          ::   jpncs   = 4      !: number of closed sea
+   INTEGER, PUBLIC, DIMENSION(jpncs)   ::   ncstt            !: Type of closed sea
+   INTEGER, PUBLIC, DIMENSION(jpncs)   ::   ncsi1, ncsj1     !: south-west closed sea limits (i,j)
+   INTEGER, PUBLIC, DIMENSION(jpncs)   ::   ncsi2, ncsj2     !: north-east closed sea limits (i,j)
+   INTEGER, PUBLIC, DIMENSION(jpncs)   ::   ncsnr            !: number of point where run-off pours
+   INTEGER, PUBLIC, DIMENSION(jpncs,4) ::   ncsir, ncsjr     !: Location of runoff
+
+   REAL(wp), DIMENSION (jpncs+1)       ::   surf             ! closed sea surface
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_clo
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_clo  ***
+      !!        
+      !! ** Purpose :   Closed sea domain initialization
+      !!
+      !! ** Method  :   if a closed sea is located only in a model grid point
+      !!                just the thermodynamic processes are applied.
+      !!
+      !! ** Action  :   ncsi1(), ncsj1() : south-west closed sea limits (i,j)
+      !!                ncsi2(), ncsj2() : north-east Closed sea limits (i,j)
+      !!                ncsir(), ncsjr() : Location of runoff
+      !!                ncsnr            : number of point where run-off pours
+      !!                ncstt            : Type of closed sea
+      !!                                   =0 spread over the world ocean
+      !!                                   =2 put at location runoff
+      !!----------------------------------------------------------------------
+      INTEGER ::   jc            ! dummy loop indices
+      !!----------------------------------------------------------------------
+      
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)'dom_clo : closed seas '
+      IF(lwp) WRITE(numout,*)'~~~~~~~'
+
+      ! initial values
+      ncsnr(:) = 1  ;  ncsi1(:) = 1  ;  ncsi2(:) = 1  ;  ncsir(:,:) = 1
+      ncstt(:) = 0  ;  ncsj1(:) = 1  ;  ncsj2(:) = 1  ;  ncsjr(:,:) = 1
+
+      ! set the closed seas (in data domain indices)
+      ! -------------------
+
+      IF( cp_cfg == "orca" ) THEN
+         !
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            !                                            ! Caspian Sea
+            ncsnr(1)   =   1  ;  ncstt(1)   =   0           ! spread over the globe
+            ncsi1(1)   =  11  ;  ncsj1(1)   = 103
+            ncsi2(1)   =  17  ;  ncsj2(1)   = 112
+            ncsir(1,1) =   1  ;  ncsjr(1,1) =   1 
+            !                                            ! Great North American Lakes
+            ncsnr(2)   =   1  ;  ncstt(2)   =   2           ! put at St Laurent mouth
+            ncsi1(2)   =  97  ;  ncsj1(2)   = 107
+            ncsi2(2)   = 103  ;  ncsj2(2)   = 111
+            ncsir(2,1) = 110  ;  ncsjr(2,1) = 111
+            !                                            ! Black Sea 1 : west part of the Black Sea 
+            ncsnr(3)   = 1    ; ncstt(3)   =   2            !            (ie west of the cyclic b.c.)
+            ncsi1(3)   = 174  ; ncsj1(3)   = 107            ! put in Med Sea
+            ncsi2(3)   = 181  ; ncsj2(3)   = 112
+            ncsir(3,1) = 171  ; ncsjr(3,1) = 106 
+            !                                            ! Black Sea 2 : est part of the Black Sea 
+            ncsnr(4)   =   1  ;  ncstt(4)   =   2           !               (ie est of the cyclic b.c.)
+            ncsi1(4)   =   2  ;  ncsj1(4)   = 107           ! put in Med Sea
+            ncsi2(4)   =   6  ;  ncsj2(4)   = 112
+            ncsir(4,1) = 171  ;  ncsjr(4,1) = 106 
+            !                                        ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            !                                            ! Caspian Sea
+            ncsnr(1)   =  1  ;  ncstt(1)   =  0  
+            ncsi1(1)   =  4  ;  ncsj1(1)   = 53 
+            ncsi2(1)   =  4  ;  ncsj2(1)   = 56
+            ncsir(1,1) =  1  ;  ncsjr(1,1) =  1
+            !                                            ! Great North American Lakes
+            ncsnr(2)   =  1  ;  ncstt(2)   =  2 
+            ncsi1(2)   = 49  ;  ncsj1(2)   = 55
+            ncsi2(2)   = 51  ;  ncsj2(2)   = 56
+            ncsir(2,1) = 57  ;  ncsjr(2,1) = 55
+            !                                            ! Black Sea
+            ncsnr(3)   =  4  ;  ncstt(3)   =  2  
+            ncsi1(3)   = 88  ;  ncsj1(3)   = 55 
+            ncsi2(3)   = 91  ;  ncsj2(3)   = 56
+            ncsir(3,1) = 86  ;  ncsjr(3,1) = 53
+            ncsir(3,2) = 87  ;  ncsjr(3,2) = 53 
+            ncsir(3,3) = 86  ;  ncsjr(3,3) = 52 
+            ncsir(3,4) = 87  ;  ncsjr(3,4) = 52
+            !                                            ! Baltic Sea
+            ncsnr(4)   =  1  ;  ncstt(4)   =  2
+            ncsi1(4)   = 75  ;  ncsj1(4)   = 59
+            ncsi2(4)   = 76  ;  ncsj2(4)   = 61
+            ncsir(4,1) = 84  ;  ncsjr(4,1) = 59 
+            !                                        ! =======================
+         CASE ( 025 )                                ! ORCA_R025 configuration
+            !                                        ! =======================
+            ncsnr(1)   = 1    ; ncstt(1)   = 0               ! Caspian + Aral sea
+            ncsi1(1)   = 1330 ; ncsj1(1)   = 645
+            ncsi2(1)   = 1400 ; ncsj2(1)   = 795
+            ncsir(1,1) = 1    ; ncsjr(1,1) = 1
+            !                                        
+            ncsnr(2)   = 1    ; ncstt(2)   = 0               ! Azov Sea 
+            ncsi1(2)   = 1284 ; ncsj1(2)   = 722
+            ncsi2(2)   = 1304 ; ncsj2(2)   = 747
+            ncsir(2,1) = 1    ; ncsjr(2,1) = 1
+            !
+         END SELECT
+         !
+      ENDIF
+
+      ! convert the position in local domain indices
+      ! --------------------------------------------
+      DO jc = 1, jpncs
+         ncsi1(jc)   = mi0( ncsi1(jc) )
+         ncsj1(jc)   = mj0( ncsj1(jc) )
+
+         ncsi2(jc)   = mi1( ncsi2(jc) )   
+         ncsj2(jc)   = mj1( ncsj2(jc) )  
+      END DO
+      !
+   END SUBROUTINE dom_clo
+
+
+   SUBROUTINE sbc_clo( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_clo  ***
+      !!                    
+      !! ** Purpose :   Special handling of closed seas
+      !!
+      !! ** Method  :   Water flux is forced to zero over closed sea
+      !!      Excess is shared between remaining ocean, or
+      !!      put as run-off in open ocean.
+      !!
+      !! ** Action  :   emp, emps   updated surface freshwater fluxes at kt
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean model time step
+      !
+      INTEGER                     ::   ji, jj, jc, jn   ! dummy loop indices
+      REAL(wp)                    ::   zze2
+      REAL(wp), DIMENSION (jpncs) ::   zemp
+      !!----------------------------------------------------------------------
+      !
+      !                                                   !------------------!
+      IF( kt == nit000 ) THEN                             !  Initialisation  !
+         !                                                !------------------!
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)'sbc_clo : closed seas '
+         IF(lwp) WRITE(numout,*)'~~~~~~~'
+
+         ! Total surface of ocean
+         surf(jpncs+1) = SUM( e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
+
+         DO jc = 1, jpncs
+            surf(jc) =0.e0
+            DO jj = ncsj1(jc), ncsj2(jc)
+               DO ji = ncsi1(jc), ncsi2(jc)
+                  surf(jc) = surf(jc) + e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj)      ! surface of closed seas
+               END DO 
+            END DO 
+         END DO 
+         IF( lk_mpp )   CALL mpp_sum ( surf, jpncs+1 )       ! mpp: sum over all the global domain
+
+         IF(lwp) WRITE(numout,*)'     Closed sea surfaces'
+         DO jc = 1, jpncs
+            IF(lwp)WRITE(numout,FMT='(1I3,4I4,5X,F16.2)') jc, ncsi1(jc), ncsi2(jc), ncsj1(jc), ncsj2(jc), surf(jc)
+         END DO
+
+         ! jpncs+1 : surface of sea, closed seas excluded
+         DO jc = 1, jpncs
+            surf(jpncs+1) = surf(jpncs+1) - surf(jc)
+         END DO           
+         !
+      ENDIF
+      !                                                   !--------------------!
+      !                                                   !  update emp, emps  !
+      zemp = 0.e0                                         !--------------------!
+      DO jc = 1, jpncs
+         DO jj = ncsj1(jc), ncsj2(jc)
+            DO ji = ncsi1(jc), ncsi2(jc)
+               zemp(jc) = zemp(jc) + e1t(ji,jj) * e2t(ji,jj) * emp(ji,jj) * tmask_i(ji,jj)
+            END DO  
+         END DO 
+      END DO
+      IF( lk_mpp )   CALL mpp_sum ( zemp(:) , jpncs )       ! mpp: sum over all the global domain
+
+      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN      ! Black Sea case for ORCA_R2 configuration
+         zze2    = ( zemp(3) + zemp(4) ) / 2.
+         zemp(3) = zze2
+         zemp(4) = zze2
+      ENDIF
+
+      DO jc = 1, jpncs
+         !
+         IF( ncstt(jc) == 0 ) THEN 
+            ! water/evap excess is shared by all open ocean
+            emp (:,:) = emp (:,:) + zemp(jc) / surf(jpncs+1)
+            emps(:,:) = emps(:,:) + zemp(jc) / surf(jpncs+1)
+         ELSEIF( ncstt(jc) == 1 ) THEN 
+            ! Excess water in open sea, at outflow location, excess evap shared
+            IF ( zemp(jc) <= 0.e0 ) THEN 
+                DO jn = 1, ncsnr(jc)
+                  ji = mi0(ncsir(jc,jn))
+                  jj = mj0(ncsjr(jc,jn)) ! Location of outflow in open ocean
+                  IF (      ji > 1 .AND. ji < jpi   &
+                      .AND. jj > 1 .AND. jj < jpj ) THEN 
+                      emp (ji,jj) = emp (ji,jj) + zemp(jc) /   &
+                         (FLOAT(ncsnr(jc)) * e1t(ji,jj) * e2t(ji,jj))
+                      emps(ji,jj) = emps(ji,jj) + zemp(jc) /   &
+                          (FLOAT(ncsnr(jc)) * e1t(ji,jj) * e2t(ji,jj))
+                  END IF 
+                END DO 
+            ELSE 
+                emp (:,:) = emp (:,:) + zemp(jc) / surf(jpncs+1)
+                emps(:,:) = emps(:,:) + zemp(jc) / surf(jpncs+1)
+            ENDIF
+         ELSEIF( ncstt(jc) == 2 ) THEN 
+            ! Excess e-p+r (either sign) goes to open ocean, at outflow location
+            IF(      ji > 1 .AND. ji < jpi    &
+               .AND. jj > 1 .AND. jj < jpj ) THEN 
+                DO jn = 1, ncsnr(jc)
+                  ji = mi0(ncsir(jc,jn))
+                  jj = mj0(ncsjr(jc,jn)) ! Location of outflow in open ocean
+                  emp (ji,jj) = emp (ji,jj) + zemp(jc)   &
+                      / (FLOAT(ncsnr(jc)) *  e1t(ji,jj) * e2t(ji,jj) )
+                  emps(ji,jj) = emps(ji,jj) + zemp(jc)   &
+                      / (FLOAT(ncsnr(jc)) *  e1t(ji,jj) * e2t(ji,jj) )
+                END DO 
+            ENDIF 
+         ENDIF 
+         !
+         DO jj = ncsj1(jc), ncsj2(jc)
+            DO ji = ncsi1(jc), ncsi2(jc)
+               emp (ji,jj) = emp (ji,jj) - zemp(jc) / surf(jc)
+               emps(ji,jj) = emps(ji,jj) - zemp(jc) / surf(jc)
+            END DO  
+         END DO 
+         !
+      END DO 
+      !
+      CALL lbc_lnk( emp , 'T', 1. )
+      CALL lbc_lnk( emps, 'T', 1. )
+      !
+   END SUBROUTINE sbc_clo
+   
+   
+   SUBROUTINE clo_rnf( p_rnfmsk )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_rnf  ***
+      !!                    
+      !! ** Purpose :   allow the treatment of closed sea outflow grid-points
+      !!                to be the same as river mouth grid-points
+      !!
+      !! ** Method  :   set to 1 the runoff mask (mskrnf, see sbcrnf module)
+      !!                at the closed sea outflow grid-point.
+      !!
+      !! ** Action  :   update (p_)mskrnf (set 1 at closed sea outflow)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_rnfmsk   ! river runoff mask (rnfmsk array)
+      !
+      INTEGER  ::   jc, jn      ! dummy loop indices
+      INTEGER  ::   ii, ij      ! temporary integer
+      !!----------------------------------------------------------------------
+      !
+      DO jc = 1, jpncs
+         IF( ncstt(jc) >= 1 ) THEN            ! runoff mask set to 1 at closed sea outflows
+             DO jn = 1, 4
+               ii = mi0( ncsir(jc,jn) )
+               ij = mj0( ncsjr(jc,jn) )
+               p_rnfmsk(ii,ij) = MAX( p_rnfmsk(ii,ij), 1.0 )
+            END DO 
+         ENDIF 
+      END DO 
+      !
+   END SUBROUTINE clo_rnf
+
+   
+   SUBROUTINE clo_ups( p_upsmsk )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_rnf  ***
+      !!                    
+      !! ** Purpose :   allow the treatment of closed sea outflow grid-points
+      !!                to be the same as river mouth grid-points
+      !!
+      !! ** Method  :   set to 0.5 the upstream mask (upsmsk, see traadv_cen2 
+      !!                module) over the closed seas.
+      !!
+      !! ** Action  :   update (p_)upsmsk (set 0.5 over closed seas)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_upsmsk   ! upstream mask (upsmsk array)
+      !
+      INTEGER  ::   jc, ji, jj      ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      DO jc = 1, jpncs
+         DO jj = ncsj1(jc), ncsj2(jc)
+            DO ji = ncsi1(jc), ncsi2(jc)
+               p_upsmsk(ji,jj) = 0.5            ! mixed upstream/centered scheme over closed seas
+            END DO 
+         END DO 
+       END DO 
+       !
+   END SUBROUTINE clo_ups
+   
+      
+   SUBROUTINE clo_bat( pbat, kbat )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE clo_bat  ***
+      !!                    
+      !! ** Purpose :   suppress closed sea from the domain
+      !!
+      !! ** Method  :   set to 0 the meter and level bathymetry (given in 
+      !!                arguments) over the closed seas.
+      !!
+      !! ** Action  :   set pbat=0 and kbat=0 over closed seas
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pbat   ! bathymetry in meters (bathy array)
+      INTEGER , DIMENSION(jpi,jpj), INTENT(inout) ::   kbat   ! bathymetry in levels (mbathy array)
+      !
+      INTEGER  ::   jc, ji, jj      ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      DO jc = 1, jpncs
+         DO jj = ncsj1(jc), ncsj2(jc)
+            DO ji = ncsi1(jc), ncsi2(jc)
+               pbat(ji,jj) = 0.e0   
+               kbat(ji,jj) = 0   
+            END DO 
+         END DO 
+       END DO 
+       !
+   END SUBROUTINE clo_bat
+
+   !!======================================================================
+END MODULE closea
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/daymod.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/daymod.F90	(revision 1844)
@@ -0,0 +1,340 @@
+MODULE daymod
+   !!======================================================================
+   !!                       ***  MODULE  daymod  ***
+   !! Ocean        :  calendar 
+   !!=====================================================================
+   !! History :  OPA  ! 1994-09  (M. Pontaud M. Imbard)  Original code
+   !!                 ! 1997-03  (O. Marti)
+   !!                 ! 1997-05  (G. Madec) 
+   !!                 ! 1997-08  (M. Imbard)
+   !!   NEMO     1.0  ! 2003-09  (G. Madec)  F90 + nyear, nmonth, nday
+   !!                 ! 2004-01  (A.M. Treguier) new calculation based on adatrj
+   !!                 ! 2006-08  (G. Madec)  surface module major update
+   !!----------------------------------------------------------------------      
+
+   !!----------------------------------------------------------------------
+   !!   day        : calendar
+   !!  
+   !!           -------------------------------
+   !!           ----------- WARNING -----------
+   !!
+   !!   we suppose that the time step is deviding the number of second of in a day
+   !!             ---> MOD( rday, rdttra(1) ) == 0
+   !!
+   !!           ----------- WARNING -----------
+   !!           -------------------------------
+   !!  
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE iom             ! 
+   USE ioipsl, ONLY :   ymds2ju   ! for calendar
+   USE prtctl          ! Print control
+   USE restart         ! 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   day        ! called by step.F90
+   PUBLIC   day_init   ! called by istate.F90
+
+   INTEGER ::   nsecd, nsecd05, ndt, ndt05
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE day_init
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE day_init  ***
+      !! 
+      !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000 
+      !!                because day will be called at the beginning of step
+      !!
+      !! ** Action  : - nyear        : current year
+      !!              - nmonth       : current month of the year nyear
+      !!              - nday         : current day of the month nmonth
+      !!              - nday_year    : current day of the year nyear
+      !!              - nsec_year    : current time step counted in second since 00h jan 1st of the current year
+      !!              - nsec_month   : current time step counted in second since 00h 1st day of the current month
+      !!              - nsec_day     : current time step counted in second since 00h of the current day
+      !!              - nsec1jan000  : second since Jan. 1st 00h of nit000 year and Jan. 1st 00h of the current year
+      !!              - nmonth_len, nyear_len, nmonth_half, nmonth_end through day_mth
+      !!----------------------------------------------------------------------
+
+      ! all calendar staff is based on the fact that MOD( rday, rdttra(1) ) == 0
+      IF( MOD( rday     , rdttra(1) ) /= 0. )   CALL ctl_stop( 'the time step must devide the number of second of in a day' )
+      IF( MOD( rday     , 2.        ) /= 0. )   CALL ctl_stop( 'the number of second of in a day must be an even number'    )
+      IF( MOD( rdttra(1), 2.        ) /= 0. )   CALL ctl_stop( 'the time step (in second) must be an even number'           )
+      nsecd   = NINT(rday           )
+      nsecd05 = NINT(0.5 * rday     )
+      ndt     = NINT(      rdttra(1))
+      ndt05   = NINT(0.5 * rdttra(1))
+
+      CALL day_rst( nit000, 'READ' ) 
+
+      ! set the calandar from ndastp (read in restart file and namelist)
+
+      nyear   =   ndastp / 10000
+      nmonth  = ( ndastp - (nyear * 10000) ) / 100
+      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
+
+      CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday )  ! we assume that we start run at 00:00
+      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
+      fjulday = fjulday + 1.                             ! move back to the day at nit000 (and not at nit000 - 1)
+
+      nsec1jan000 = 0
+      CALL day_mth
+      
+      IF ( nday == 0 ) THEN     !   for ex if ndastp = ndate0 - 1
+         nmonth = nmonth - 1  
+         nday = nmonth_len(nmonth)
+      ENDIF
+      IF ( nmonth == 0 ) THEN   ! go at the end of previous year
+         nmonth = 12
+         nyear = nyear - 1
+         nsec1jan000 = nsec1jan000 - nsecd * nyear_len(0)
+         IF( nleapy == 1 )   CALL day_mth
+      ENDIF
+      
+      ! day since january 1st
+      nday_year = nday + SUM( nmonth_len(1:nmonth - 1) )
+      
+      ! number of seconds since the beginning of current year/month at the middle of the time-step
+      nsec_year  = nday_year * nsecd - ndt05   ! 1 time step before the middle of the first time step
+      nsec_month = nday      * nsecd - ndt05   ! because day will be called at the beginning of step
+      nsec_day   =             nsecd - ndt05
+
+      ! control print
+      IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i6)')' ==============>> 1/2 time step before the start of the run DATE Y/M/D = ',   &
+           &                   nyear, '/', nmonth, '/', nday, '  nsec_day:', nsec_day
+
+      ! Up to now, calendar parameters are related to the end of previous run (nit000-1)
+      ! call day to set the calendar parameters at the begining of the current simulaton. needed by iom_init
+      CALL day( nit000 )
+
+      
+   END SUBROUTINE day_init
+
+
+   SUBROUTINE day_mth
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE day_init  ***
+      !! 
+      !! ** Purpose :   calendar values related to the months
+      !!
+      !! ** Action  : - nmonth_len    : length in days of the months of the current year
+      !!              - nyear_len     : length in days of the previous/current year
+      !!              - nmonth_half   : second since the beginning of the year and the halft of the months
+      !!              - nmonth_end    : second since the beginning of the year and the end of the months
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jm               ! dummy loop indice
+      !!----------------------------------------------------------------------
+
+      ! length of the month of the current year (from nleapy, read in namelist)
+      IF ( nleapy < 2 ) THEN 
+         nmonth_len(:) = (/ 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 /)
+         nyear_len(:) = 365
+         IF ( nleapy == 1 ) THEN   ! we are using calandar with leap years
+            IF ( MOD(nyear-1, 4) == 0 .AND. ( MOD(nyear-1, 400) == 0 .OR. MOD(nyear-1, 100) /= 0 ) ) THEN
+               nyear_len(0) = 366
+            ENDIF
+            IF ( MOD(nyear, 4) == 0 .AND. ( MOD(nyear, 400) == 0 .OR. MOD(nyear, 100) /= 0 ) ) THEN
+               nmonth_len(2) = 29
+               nyear_len(1) = 366
+            ENDIF
+         ENDIF
+      ELSE
+         nmonth_len(:) = nleapy   ! all months with nleapy days per year
+         nyear_len(:) = 12 * nleapy
+      ENDIF
+
+      ! half month in second since the begining of the year:
+      ! time since Jan 1st   0     1     2    ...    11    12    13
+      !          ---------*--|--*--|--*--| ... |--*--|--*--|--*--|--------------------------------------
+      !                 <---> <---> <--->  ...  <---> <---> <--->        
+      ! month number      0     1     2    ...    11    12    13
+      !
+      ! nmonth_half(jm) = rday * REAL( 0.5 * nmonth_len(jm) + SUM(nmonth_len(1:jm-1)) )
+      nmonth_half(0) = - nsecd05 * nmonth_len(0)
+      DO jm = 1, 13
+         nmonth_half(jm) = nmonth_half(jm-1) + nsecd05 * ( nmonth_len(jm-1) + nmonth_len(jm) )
+      END DO
+
+      nmonth_end(0) = 0
+      DO jm = 1, 13
+         nmonth_end(jm) = nmonth_end(jm-1) + nsecd * nmonth_len(jm)
+      END DO
+      !           
+   END SUBROUTINE 
+
+
+   SUBROUTINE day( kt )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE day  ***
+      !! 
+      !! ** Purpose :   Compute the date with a day iteration IF necessary.
+      !!
+      !! ** Method  : - ???
+      !!
+      !! ** Action  : - nyear     : current year
+      !!              - nmonth    : current month of the year nyear
+      !!              - nday      : current day of the month nmonth
+      !!              - nday_year : current day of the year nyear
+      !!              - ndastp    : = nyear*10000 + nmonth*100 + nday
+      !!              - adatrj    : date in days since the beginning of the run
+      !!              - nsec_year : current time of the year (in second since 00h, jan 1st)
+      !!----------------------------------------------------------------------      
+      INTEGER, INTENT(in) ::   kt        ! ocean time-step indices
+      !
+      CHARACTER (len=25) ::   charout
+      REAL(wp)           ::   zprec      ! fraction of day corresponding to 0.1 second
+      !!----------------------------------------------------------------------
+      zprec = 0.1 / rday
+      !                                                 ! New time-step
+      nsec_year  = nsec_year  + ndt 
+      nsec_month = nsec_month + ndt                 
+      nsec_day   = nsec_day   + ndt                
+      adatrj  = adatrj  + rdttra(1) / rday
+      fjulday = fjulday + rdttra(1) / rday
+      IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
+      IF( ABS(adatrj  - REAL(NINT(adatrj ),wp)) < zprec )   adatrj  = REAL(NINT(adatrj ),wp)   ! avoid truncation error
+      
+      IF( nsec_day > nsecd ) THEN                        ! NEW day
+         !
+         nday      = nday + 1
+         nday_year = nday_year + 1
+         nsec_day  = ndt05
+         !
+         IF( nday == nmonth_len(nmonth) + 1 ) THEN      ! NEW month
+            nday   = 1
+            nmonth = nmonth + 1
+            nsec_month = ndt05
+            IF( nmonth == 13 ) THEN                     ! NEW year
+               nyear     = nyear + 1
+               nmonth    = 1
+               nday_year = 1
+               nsec_year = ndt05
+               nsec1jan000 = nsec1jan000 + nsecd * nyear_len(1)
+               IF( nleapy == 1 )   CALL day_mth
+            ENDIF
+         ENDIF
+         !
+         ndastp = nyear * 10000 + nmonth * 100 + nday   ! NEW date
+         !
+         IF(lwp) WRITE(numout,'(a,i8,a,i4.4,a,i2.2,a,i2.2,a,i3.3)') '======>> time-step =', kt,   &
+              &   '      New day, DATE Y/M/D = ', nyear, '/', nmonth, '/', nday, '      nday_year = ', nday_year
+         IF(lwp) WRITE(numout,'(a,i8,a,i7,a,i5)') '         nsec_year = ', nsec_year,   &
+              &   '   nsec_month = ', nsec_month, '   nsec_day = ', nsec_day
+      ENDIF
+      
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
+         CALL prt_ctl_info(charout)
+      ENDIF
+
+      IF( lrst_oce )   CALL day_rst( kt, 'WRITE' )
+      !
+   END SUBROUTINE day
+
+
+   SUBROUTINE day_rst( kt, cdrw )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE ts_rst  ***
+      !! 
+      !!  ** Purpose : Read or write calendar in restart file:
+      !! 
+      !!  WRITE(READ) mode:
+      !!       kt        : number of time step since the begining of the experiment at the 
+      !!                   end of the current(previous) run
+      !!       adatrj(0) : number of elapsed days since the begining of the experiment at the 
+      !!                   end of the current(previous) run (REAL -> keep fractions of day)
+      !!       ndastp    : date at the end of the current(previous) run (coded as yyyymmdd integer)
+      !! 
+      !!   According to namelist parameter nrstdt,
+      !!       nrstdt = 0  no control on the date (nit000 is  arbitrary).
+      !!       nrstdt = 1  we verify that nit000 is equal to the last
+      !!                   time step of previous run + 1.
+      !!       In both those options, the  exact duration of the experiment
+      !!       since the beginning (cumulated duration of all previous restart runs)
+      !!       is not stored in the restart and is assumed to be (nit000-1)*rdt.
+      !!       This is valid is the time step has remained constant.
+      !!
+      !!       nrstdt = 2  the duration of the experiment in days (adatrj)
+      !!                    has been stored in the restart file.
+      !!----------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      !
+      REAL(wp) ::   zkt, zndastp
+      !!----------------------------------------------------------------------
+      
+      IF( TRIM(cdrw) == 'READ' ) THEN
+
+         IF( iom_varid( numror, 'kt', ldstop = .FALSE. ) > 0 ) THEN
+            ! Get Calendar informations
+            CALL iom_get( numror, 'kt', zkt )   ! last time-step of previous run
+            IF(lwp) THEN
+               WRITE(numout,*) ' *** Info read in restart : '
+               WRITE(numout,*) '   previous time-step                               : ', NINT( zkt )
+               WRITE(numout,*) ' *** restart option'
+               SELECT CASE ( nrstdt )
+               CASE ( 0 )   ;   WRITE(numout,*) ' nrstdt = 0 : no control of nit000'
+               CASE ( 1 )   ;   WRITE(numout,*) ' nrstdt = 1 : no control the date at nit000 (use ndate0 read in the namelist)'
+               CASE ( 2 )   ;   WRITE(numout,*) ' nrstdt = 2 : calendar parameters read in restart'
+               END SELECT
+               WRITE(numout,*)
+            ENDIF
+            ! Control of date 
+            IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 )                                         & 
+                 &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 & 
+                 &                  ' verify the restart file or rerun with nrstdt = 0 (namelist)' )
+            ! define ndastp and adatrj
+            IF ( nrstdt == 2 ) THEN 
+               ! read the parameters correspondting to nit000 - 1 (last time step of previous run)
+               CALL iom_get( numror, 'ndastp', zndastp )
+               ndastp = NINT( zndastp )
+               CALL iom_get( numror, 'adatrj', adatrj  )
+            ELSE 
+               ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
+               ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00
+               adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
+               ! note this is wrong if time step has changed during run 
+            ENDIF
+         ELSE
+            ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
+            ndastp = ndate0 - 1        ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00
+            adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
+         ENDIF
+         IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error
+         !
+         IF(lwp) THEN
+            WRITE(numout,*) ' *** Info used values : '
+            WRITE(numout,*) '   date ndastp                                      : ', ndastp
+            WRITE(numout,*) '   number of elapsed days since the begining of run : ', adatrj
+            WRITE(numout,*)
+         ENDIF
+         !
+      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+         !
+         IF( kt == nitrst ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'rst_write : write oce restart file  kt =', kt
+            IF(lwp) WRITE(numout,*) '~~~~~~~'         
+         ENDIF
+         ! calendar control
+         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp) )   ! time-step 
+         CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp) )   ! date
+         CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj            )   ! number of elapsed days since
+         !                                                                     ! the begining of the run [s]
+      ENDIF
+      !
+   END SUBROUTINE day_rst
+
+   !!======================================================================
+END MODULE daymod
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 1844)
@@ -0,0 +1,233 @@
+MODULE dom_oce
+   !!======================================================================
+   !!                       ***  MODULE dom_oce  ***
+   !!       
+   !! ** Purpose :   Define in memory all the ocean space domain variables
+   !!======================================================================
+   !! History :  1.0  ! 2005-10  (A. Beckmann, G. Madec)  reactivate s-coordinate 
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC           ! allows the acces to par_oce when dom_oce is used
+   !                ! exception to coding rules... to be suppressed ???
+
+   !!----------------------------------------------------------------------
+   !! time & space domain namelist
+   !! ----------------------------
+   !                                              !!* Namelist namdom : time & space domain *
+   INTEGER , PUBLIC ::   nn_bathy     =  0         !: = 0/1 ,compute/read the bathymetry file
+   REAL(wp), PUBLIC ::   rn_e3zps_min = 5.0_wp     !: miminum thickness for partial steps (meters)
+   REAL(wp), PUBLIC ::   rn_e3zps_rat = 0.1_wp     !: minimum thickness ration for partial steps
+   INTEGER , PUBLIC ::   nn_msh       = 0          !: = 1 create a mesh-mask file
+   INTEGER , PUBLIC ::   nn_acc       = 0          !: = 0/1 use of the acceleration of convergence technique
+   REAL(wp), PUBLIC ::   rn_atfp      = 0.1_wp     !: asselin time filter parameter
+   REAL(wp), PUBLIC ::   rn_rdt       = 3600._wp   !: time step for the dynamics (and tracer if nacc=0)
+   REAL(wp), PUBLIC ::   rn_rdtmin    = 3600._wp   !: minimum time step on tracers
+   REAL(wp), PUBLIC ::   rn_rdtmax    = 3600._wp   !: maximum time step on tracers
+   REAL(wp), PUBLIC ::   rn_rdth      =  800._wp   !: depth variation of tracer step
+   INTEGER , PUBLIC ::   nn_baro      = 64         !: number of barotropic time steps (key_dynspg_ts)
+   INTEGER , PUBLIC ::   nn_closea    =  0         !: =0 suppress closed sea/lake from the ORCA domain or not (=1)
+
+   !                                          ! old non-DOCTOR names still used in the model
+   INTEGER , PUBLIC ::   ntopo                !: = 0/1 ,compute/read the bathymetry file
+   REAL(wp), PUBLIC ::   e3zps_min            !: miminum thickness for partial steps (meters)
+   REAL(wp), PUBLIC ::   e3zps_rat            !: minimum thickness ration for partial steps
+   INTEGER , PUBLIC ::   nmsh                 !: = 1 create a mesh-mask file
+   INTEGER , PUBLIC ::   nacc                 !: = 0/1 use of the acceleration of convergence technique
+   REAL(wp), PUBLIC ::   atfp                 !: asselin time filter parameter
+   REAL(wp), PUBLIC ::   rdt                  !: time step for the dynamics (and tracer if nacc=0)
+   REAL(wp), PUBLIC ::   rdtmin               !: minimum time step on tracers
+   REAL(wp), PUBLIC ::   rdtmax               !: maximum time step on tracers
+   REAL(wp), PUBLIC ::   rdth                 !: depth variation of tracer step
+   INTEGER , PUBLIC ::   nclosea              !: =0 suppress closed sea/lake from the ORCA domain or not (=1)
+
+
+   !                                         !!! associated variables
+   INTEGER , PUBLIC                 ::   neuler  = 0   !: restart euler forward option (0=Euler)
+   REAL(wp), PUBLIC                 ::   atfp1         !: asselin time filter coeff. (atfp1= 1-2*atfp)
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   rdttra        !: vertical profile of tracer time step
+
+   !                                         !!* Namelist namcla : cross land advection
+   INTEGER, PUBLIC ::   nn_cla = 0            !: =1 cross land advection for exchanges through some straits (ORCA2)
+
+   !                                          ! old non-DOCTOR names still used in the model
+   INTEGER, PUBLIC ::   n_cla = 0             !: =1 cross land advection for exchanges through some straits (ORCA2)
+
+   !!----------------------------------------------------------------------
+   !! space domain parameters
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC ::   lzoom      =  .FALSE.   !: zoom flag
+   LOGICAL, PUBLIC ::   lzoom_e    =  .FALSE.   !: East  zoom type flag
+   LOGICAL, PUBLIC ::   lzoom_w    =  .FALSE.   !: West  zoom type flag
+   LOGICAL, PUBLIC ::   lzoom_s    =  .FALSE.   !: South zoom type flag
+   LOGICAL, PUBLIC ::   lzoom_n    =  .FALSE.   !: North zoom type flag
+   LOGICAL, PUBLIC ::   lzoom_arct =  .FALSE.   !: ORCA    arctic zoom flag
+   LOGICAL, PUBLIC ::   lzoom_anta =  .FALSE.   !: ORCA antarctic zoom flag
+
+   !                                     !!! domain parameters linked to mpp
+   INTEGER, PUBLIC ::   nperio            !: type of lateral boundary condition
+   INTEGER, PUBLIC ::   nimpp, njmpp      !: i- & j-indexes for mpp-subdomain left bottom
+   INTEGER, PUBLIC ::   nreci, nrecj      !: overlap region in i and j
+   INTEGER, PUBLIC ::   nproc             !: number for local processor
+   INTEGER, PUBLIC ::   narea             !: number for local area
+   INTEGER, PUBLIC ::   nbondi, nbondj    !: mark of i- and j-direction local boundaries
+   INTEGER, PUBLIC ::   npolj             !: north fold mark (0, 3 or 4)
+   INTEGER, PUBLIC ::   nlci, nldi, nlei  !: i-dimensions of the local subdomain and its first and last indoor indices
+   INTEGER, PUBLIC ::   nlcj, nldj, nlej  !: i-dimensions of the local subdomain and its first and last indoor indices
+   INTEGER, PUBLIC ::   noea, nowe        !: index of the local neighboring processors in
+   INTEGER, PUBLIC ::   noso, nono        !: east, west, south and north directions
+   INTEGER, PUBLIC ::   npne, npnw        !: index of north east and north west processor
+   INTEGER, PUBLIC ::   npse, npsw        !: index of south east and south west processor
+   INTEGER, PUBLIC ::   nbne, nbnw        !: logical of north east & north west processor
+   INTEGER, PUBLIC ::   nbse, nbsw        !: logical of south east & south west processor
+   INTEGER, PUBLIC ::   nidom             !: ???
+
+   INTEGER, PUBLIC, DIMENSION(jpi)    ::   mig        !: local  ==> global domain i-index
+   INTEGER, PUBLIC, DIMENSION(jpj)    ::   mjg        !: local  ==> global domain j-index
+   INTEGER, PUBLIC, DIMENSION(jpidta) ::   mi0, mi1   !: global ==> local  domain i-index    !!bug ==> other solution?
+   !                                                  ! (mi0=1 and mi1=0 if the global index is not in the local domain)
+   INTEGER, PUBLIC, DIMENSION(jpjdta) ::   mj0, mj1   !: global ==> local  domain j-index     !!bug ==> other solution?
+   !                                                  ! (mi0=1 and mi1=0 if the global index is not in the local domain)
+   INTEGER, PUBLIC, DIMENSION(jpnij)  ::   nimppt, njmppt   !: i-, j-indexes for each processor
+   INTEGER, PUBLIC, DIMENSION(jpnij)  ::   ibonit, ibonjt   !: i-, j- processor neighbour existence
+   INTEGER, PUBLIC, DIMENSION(jpnij)  ::   nlcit , nlcjt    !: dimensions of every subdomain
+   INTEGER, PUBLIC, DIMENSION(jpnij)  ::   nldit , nldjt    !: first, last indoor index for each i-domain
+   INTEGER, PUBLIC, DIMENSION(jpnij)  ::   nleit , nlejt    !: first, last indoor index for each j-domain
+
+   !!----------------------------------------------------------------------
+   !! horizontal curvilinear coordinate and scale factors
+   !! ---------------------------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   glamt, glamu   !: longitude of t-, u-, v- and f-points (degre)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   glamv, glamf   !:
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   gphit, gphiu   !: latitude  of t-, u-, v- and f-points (degre)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   gphiv, gphif   !:
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   e1t, e2t       !: horizontal scale factors at t-point (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   e1u, e2u       !: horizontal scale factors at u-point (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   e1v, e2v       !: horizontal scale factors at v-point (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   e1f, e2f       !: horizontal scale factors at f-point (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ff             !: coriolis factor (2.*omega*sin(yphi) ) (s-1)
+
+   !!----------------------------------------------------------------------
+   !! vertical coordinate and scale factors
+   !! ---------------------------------------------------------------------
+   !                                           !!* Namelist namzgr : vertical coordinate *
+   LOGICAL, PUBLIC ::   ln_zco     =  .TRUE.    !: z-coordinate - full step
+   LOGICAL, PUBLIC ::   ln_zps     =  .FALSE.   !: z-coordinate - partial step
+   LOGICAL, PUBLIC ::   ln_sco     =  .FALSE.   !: s-coordinate or hybrid z-s coordinate
+#if defined key_zco
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zco = .TRUE.    !: z-coordinate flag (1D arrays)
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zco = .FALSE.   !: z-coordinate flag (3D arrays)
+
+   !! All coordinates
+   !! ---------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   gdep3w          !: depth of T-points (sum of e3w) (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   gdept , gdepw   !: analytical depth at T-W  points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3v   , e3f     !: analytical vertical scale factors at  V--F
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3t   , e3u     !:                                       T--U  points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3vw            !: analytical vertical scale factors at  VW--
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3w   , e3uw    !:                                        W--UW  points (m)
+#endif
+#if defined key_vvl
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vvl = .TRUE.    !: variable grid flag
+
+   !! All coordinates
+   !! ---------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   gdep3w_1           !: depth of T-points (sum of e3w) (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   gdept_1, gdepw_1   !: analytical depth at T-W  points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3v_1  , e3f_1     !: analytical vertical scale factors at  V--F
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3t_1  , e3u_1     !:                                       T--U  points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3vw_1             !: analytical vertical scale factors at  VW--
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e3w_1  , e3uw_1    !:                                       W--UW  points (m)
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vvl = .FALSE.   !: fixed grid flag
+#endif
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hur  , hvr    !: inverse of u and v-points ocean depth (1/m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hu   , hv     !: depth at u- and v-points (meters)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hu_0 , hv_0   !: refernce depth at u- and v-points (meters)
+
+   INTEGER, PUBLIC ::   nla10              !: deepest    W level Above  ~10m (nlb10 - 1)
+   INTEGER, PUBLIC ::   nlb10              !: shallowest W level Bellow ~10m (nla10 + 1) 
+
+   !! z-coordinate with full steps (also used in the other cases as reference z-coordinate)
+   !! =-----------------====------
+   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   gdept_0, gdepw_0   !: reference depth of t- and w-points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   e3t_0  , e3w_0     !: reference vertical scale factors at T- and W-pts (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hdept  , hdepw     !: ocean bottom depth at T and W points
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   e3tp   , e3wp      !: ocean bottom level thickness at T and W points
+
+   !! s-coordinate and hybrid z-s-coordinate
+   !! =----------------======---------------
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   gsigt, gsigw   !: model level depth coefficient at t-, w-levels (analytic)
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   gsi3w          !: model level depth coefficient at w-level (sum of gsigw)
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   esigt, esigw   !: vertical scale factor coef. at t-, w-levels
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hbatv , hbatf    !: ocean depth at the vertical of  V--F
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hbatt , hbatu    !:                                 T--U  points (m)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   scosrf, scobot   !: ocean surface and bottom topographies 
+   !                                                          !  (if deviating from coordinate surfaces in HYBRID)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hifv  , hiff     !: interface depth between stretching    at  V--F
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hift  , hifu     !: and quasi-uniform spacing                 T--U  points (m)
+
+   !!----------------------------------------------------------------------
+   !! masks, bathymetry
+   !! ---------------------------------------------------------------------
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   mbathy    !: number of ocean level (=0, 1, ... , jpk-1)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bathy     !: ocean depth (meters)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tmask_i   !: interior domain T-point mask
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bmask     !: land/ocean mask of barotropic stream function
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   tmask, umask, vmask, fmask   !: land/ocean mask at T-, U-, V- and F-points
+
+   REAL(wp), PUBLIC, DIMENSION(jpiglo) ::   tpol, fpol          !: north fold mask (nperio= 3 or 4)
+
+#if defined key_noslip_accurate
+   INTEGER, PUBLIC, DIMENSION            (4,jpk) ::   npcoa          !: ???
+   INTEGER, PUBLIC, DIMENSION(2*(jpi+jpj),4,jpk) ::   nicoa, njcoa   !: ???
+#endif
+
+   !!----------------------------------------------------------------------
+   !! calendar variables
+   !! ---------------------------------------------------------------------
+   INTEGER , PUBLIC ::   nyear       !: current year
+   INTEGER , PUBLIC ::   nmonth      !: current month
+   INTEGER , PUBLIC ::   nday        !: current day of the month
+   INTEGER , PUBLIC ::   ndastp      !: time step date in yyyymmdd format
+   INTEGER , PUBLIC ::   nday_year   !: current day counted from jan 1st of the current year
+   INTEGER , PUBLIC ::   nsec_year   !: current time step counted in second since 00h jan 1st of the current year
+   INTEGER , PUBLIC ::   nsec_month  !: current time step counted in second since 00h 1st day of the current month
+   INTEGER , PUBLIC ::   nsec_day    !: current time step counted in second since 00h of the current day
+   REAL(wp), PUBLIC ::   fjulday     !: julian day 
+   REAL(wp), PUBLIC ::   adatrj      !: number of elapsed days since the begining of the whole simulation
+   !                                 !: (cumulative duration of previous runs that may have used different time-step size)
+   INTEGER , PUBLIC, DIMENSION(0: 1) ::   nyear_len     !: length in days of the previous/current year
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_len    !: length in days of the months of the current year
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_half   !: second since Jan 1st 0h of the current year and the half of the months
+   INTEGER , PUBLIC, DIMENSION(0:13) ::   nmonth_end    !: second since Jan 1st 0h of the current year and the end of the months
+   INTEGER , PUBLIC                  ::   nsec1jan000   !: second since Jan 1st 0h of nit000 year and Jan 1st 0h the current year
+
+   !!----------------------------------------------------------------------
+   !! agrif domain
+   !!----------------------------------------------------------------------
+#if defined key_agrif
+   LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .TRUE.    !: agrif flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .FALSE.   !: agrif flag
+
+CONTAINS
+   LOGICAL FUNCTION Agrif_Root()
+      Agrif_Root = .TRUE.
+   END FUNCTION Agrif_Root
+
+   CHARACTER(len=3) FUNCTION Agrif_CFixed()
+     Agrif_CFixed = '0' 
+   END FUNCTION Agrif_CFixed
+#endif
+
+   !!======================================================================
+END MODULE dom_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domain.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domain.F90	(revision 1844)
@@ -0,0 +1,283 @@
+MODULE domain
+   !!==============================================================================
+   !!                       ***  MODULE domain   ***
+   !! Ocean initialization : domain initialization
+   !!==============================================================================
+   !! History :  OPA  !  1990-10  (C. Levy - G. Madec)  Original code
+   !!                 !  1992-01  (M. Imbard) insert time step initialization
+   !!                 !  1996-06  (G. Madec) generalized vertical coordinate 
+   !!                 !  1997-02  (G. Madec) creation of domwri.F
+   !!                 !  2001-05  (E.Durand - G. Madec) insert closed sea
+   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!            2.0  !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!----------------------------------------------------------------------
+   
+   !!----------------------------------------------------------------------
+   !!   dom_init       : initialize the space and time domain
+   !!   dom_nam        : read and contral domain namelists
+   !!   dom_ctl        : control print for the ocean domain
+   !!----------------------------------------------------------------------
+   USE oce             ! 
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE phycst          ! physical constants
+   USE closea          ! closed seas
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+
+   USE domhgr          ! domain: set the horizontal mesh
+   USE domzgr          ! domain: set the vertical mesh
+   USE domstp          ! domain: set the time-step
+   USE dommsk          ! domain: set the mask system
+   USE domwri          ! domain: write the meshmask file
+   USE domvvl          ! variable volume
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_init   ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!-------------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software is governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!-------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_init  ***
+      !!                    
+      !! ** Purpose :   Domain initialization. Call the routines that are 
+      !!              required to create the arrays which define the space 
+      !!              and time domain of the ocean model.
+      !!
+      !! ** Method  : - dom_msk: compute the masks from the bathymetry file
+      !!              - dom_hgr: compute or read the horizontal grid-point position
+      !!                         and scale factors, and the coriolis factor
+      !!              - dom_zgr: define the vertical coordinate and the bathymetry
+      !!              - dom_stp: defined the model time step
+      !!              - dom_wri: create the meshmask file if nmsh=1
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk                ! dummy loop argument
+      INTEGER ::   iconf = 0         ! temporary integers
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_init : domain initialization'
+         WRITE(numout,*) '~~~~~~~~'
+      ENDIF
+      !
+                             CALL dom_nam      ! read namelist ( namrun, namdom, namcla )
+                             CALL dom_clo      ! Closed seas and lake
+                             CALL dom_hgr      ! Horizontal mesh
+                             CALL dom_zgr      ! Vertical mesh and bathymetry
+                             CALL dom_msk      ! Masks
+      IF( lk_vvl         )   CALL dom_vvl      ! Vertical variable mesh
+      !
+      hu(:,:) = 0.e0                           ! Ocean depth at U- and V-points
+      hv(:,:) = 0.e0
+      DO jk = 1, jpk
+         hu(:,:) = hu(:,:) + fse3u(:,:,jk) * umask(:,:,jk)
+         hv(:,:) = hv(:,:) + fse3v(:,:,jk) * vmask(:,:,jk)
+      END DO
+      !                                        ! Inverse of the local depth
+      hur(:,:) = 1. / ( hu(:,:) + 1.e0 - umask(:,:,1) ) * umask(:,:,1)
+      hvr(:,:) = 1. / ( hv(:,:) + 1.e0 - vmask(:,:,1) ) * vmask(:,:,1)
+
+                             CALL dom_stp      ! time step
+      IF( nmsh /= 0      )   CALL dom_wri      ! Create a domain file
+      IF( .NOT.ln_rstart )   CALL dom_ctl      ! Domain control
+      !
+   END SUBROUTINE dom_init
+
+
+   SUBROUTINE dom_nam
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read domaine namelists and print the variables.
+      !!
+      !! ** input   : - namrun namelist
+      !!              - namdom namelist
+      !!              - namcla namelist
+      !!----------------------------------------------------------------------
+      USE ioipsl
+      NAMELIST/namrun/ nn_no   , cn_exp    , cn_ocerst_in, cn_ocerst_out, ln_rstart , nn_rstctl,   &
+         &             nn_it000, nn_itend  , nn_date0    , nn_leapy     , nn_istate , nn_stock ,   &
+         &             nn_write, ln_dimgnnn, ln_mskland  , ln_clobber   , nn_chunksz
+      NAMELIST/namdom/ nn_bathy , rn_e3zps_min, rn_e3zps_rat, nn_msh   ,   &
+         &             nn_acc   , rn_atfp     , rn_rdt      , rn_rdtmin,   &
+         &             rn_rdtmax, rn_rdth     , nn_baro     , nn_closea
+      NAMELIST/namcla/ nn_cla
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )              ! Namelist namrun : parameters of the run
+      READ  ( numnam, namrun )
+      !
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_nam  : domain initialization through namelist read'
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namrun'
+         WRITE(numout,*) '      job number                      nn_no      = ', nn_no
+         WRITE(numout,*) '      experiment name for output      cn_exp     = ', cn_exp
+         WRITE(numout,*) '      restart logical                 ln_rstart  = ', ln_rstart
+         WRITE(numout,*) '      control of time step            nn_rstctl  = ', nn_rstctl
+         WRITE(numout,*) '      number of the first time step   nn_it000   = ', nn_it000
+         WRITE(numout,*) '      number of the last time step    nn_itend   = ', nn_itend
+         WRITE(numout,*) '      initial calendar date aammjj    nn_date0   = ', nn_date0
+         WRITE(numout,*) '      leap year calendar (0/1)        nn_leapy   = ', nn_leapy
+         WRITE(numout,*) '      initial state output            nn_istate  = ', nn_istate
+         WRITE(numout,*) '      frequency of restart file       nn_stock   = ', nn_stock
+         WRITE(numout,*) '      frequency of output file        nn_write   = ', nn_write
+         WRITE(numout,*) '      multi file dimgout              ln_dimgnnn = ', ln_dimgnnn
+         WRITE(numout,*) '      mask land points                ln_mskland = ', ln_mskland
+         WRITE(numout,*) '      overwrite an existing file      ln_clobber = ', ln_clobber
+         WRITE(numout,*) '      NetCDF chunksize (bytes)        nn_chunksz = ', nn_chunksz
+      ENDIF
+
+      no = nn_no                    ! conversion DOCTOR names into model names (this should disappear soon)
+      cexper = cn_exp
+      nrstdt = nn_rstctl
+      nit000 = nn_it000
+      nitend = nn_itend
+      ndate0 = nn_date0
+      nleapy = nn_leapy
+      ninist = nn_istate
+      nstock = nn_stock
+      nwrite = nn_write
+
+
+      !                             ! control of output frequency
+      IF ( nstock == 0 .OR. nstock > nitend ) THEN
+         WRITE(ctmp1,*) 'nstock = ', nstock, ' it is forced to ', nitend
+         CALL ctl_warn( ctmp1 )
+         nstock = nitend
+      ENDIF
+      IF ( nwrite == 0 ) THEN
+         WRITE(ctmp1,*) 'nwrite = ', nwrite, ' it is forced to ', nitend
+         CALL ctl_warn( ctmp1 )
+         nwrite = nitend
+      ENDIF
+
+      IF( Agrif_Root() ) THEN
+         SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
+         CASE (  1 ) 
+            CALL ioconf_calendar('gregorian')
+            IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "gregorian", i.e. leap year'
+         CASE (  0 )
+            CALL ioconf_calendar('noleap')
+            IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "noleap", i.e. no leap year'
+         CASE ( 30 )
+            CALL ioconf_calendar('360d')
+            IF(lwp) WRITE(numout,*) '   The IOIPSL calendar is "360d", i.e. 360 days in a year'
+         END SELECT
+      ENDIF
+
+      REWIND( numnam )             ! Namelist namdom : space & time domain (bathymetry, mesh, timestep)
+      READ  ( numnam, namdom )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namdom : space & time domain'
+         WRITE(numout,*) '      flag read/compute bathymetry      nn_bathy     = ', nn_bathy
+         WRITE(numout,*) '      minimum thickness of partial      rn_e3zps_min = ', rn_e3zps_min, ' (m)'
+         WRITE(numout,*) '         step level                     rn_e3zps_rat = ', rn_e3zps_rat
+         WRITE(numout,*) '      create mesh/mask file(s)          nn_msh       = ', nn_msh
+         WRITE(numout,*) '           = 0   no file created                 '
+         WRITE(numout,*) '           = 1   mesh_mask                       '
+         WRITE(numout,*) '           = 2   mesh and mask                   '
+         WRITE(numout,*) '           = 3   mesh_hgr, msh_zgr and mask      '
+         WRITE(numout,*) '      ocean time step                      rn_rdt    = ', rn_rdt
+         WRITE(numout,*) '      asselin time filter parameter        rn_atfp   = ', rn_atfp
+         WRITE(numout,*) '      time-splitting: nb of sub time-step  nn_baro   = ', nn_baro
+         WRITE(numout,*) '      acceleration of converge             nn_acc    = ', nn_acc
+         WRITE(numout,*) '        nn_acc=1: surface tracer rdt       rn_rdtmin = ', rn_rdtmin
+         WRITE(numout,*) '                  bottom  tracer rdt       rdtmax    = ', rn_rdtmax
+         WRITE(numout,*) '                  depth of transition      rn_rdth   = ', rn_rdth
+         WRITE(numout,*) '      suppression of closed seas (=0)      nn_closea = ', nn_closea
+      ENDIF
+
+      ntopo     = nn_bathy          ! conversion DOCTOR names into model names (this should disappear soon)
+      e3zps_min = rn_e3zps_min
+      e3zps_rat = rn_e3zps_rat
+      nmsh      = nn_msh
+      nacc      = nn_acc
+      atfp      = rn_atfp
+      rdt       = rn_rdt
+      rdtmin    = rn_rdtmin
+      rdtmax    = rn_rdtmin
+      rdth      = rn_rdth
+      nclosea   = nn_closea
+
+      REWIND( numnam )             ! Namelist cross land advection
+      READ  ( numnam, namcla )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namcla'
+         WRITE(numout,*) '      cross land advection                 nn_cla    = ', nn_cla
+      ENDIF
+
+      n_cla = nn_cla                ! conversion DOCTOR names into model names (this should disappear soon)
+
+      IF( nbit_cmp == 1 .AND. n_cla /= 0 )   CALL ctl_stop( ' Reproductibility tests (nbit_cmp=1) require n_cla = 0' )
+      !
+   END SUBROUTINE dom_nam
+
+
+   SUBROUTINE dom_ctl
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_ctl  ***
+      !!
+      !! ** Purpose :   Domain control.
+      !!
+      !! ** Method  :   compute and print extrema of masked scale factors
+      !!----------------------------------------------------------------------
+      INTEGER ::   iimi1, ijmi1, iimi2, ijmi2, iima1, ijma1, iima2, ijma2
+      INTEGER, DIMENSION(2) ::   iloc   ! 
+      REAL(wp) ::   ze1min, ze1max, ze2min, ze2max
+      !!----------------------------------------------------------------------
+      !
+      IF(lk_mpp) THEN
+         CALL mpp_minloc( e1t(:,:), tmask(:,:,1), ze1min, iimi1,ijmi1 )
+         CALL mpp_minloc( e2t(:,:), tmask(:,:,1), ze2min, iimi2,ijmi2 )
+         CALL mpp_maxloc( e1t(:,:), tmask(:,:,1), ze1max, iima1,ijma1 )
+         CALL mpp_maxloc( e2t(:,:), tmask(:,:,1), ze2max, iima2,ijma2 )
+      ELSE
+         ze1min = MINVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze2min = MINVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze1max = MAXVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+         ze2max = MAXVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
+
+         iloc  = MINLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iimi1 = iloc(1) + nimpp - 1
+         ijmi1 = iloc(2) + njmpp - 1
+         iloc  = MINLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iimi2 = iloc(1) + nimpp - 1
+         ijmi2 = iloc(2) + njmpp - 1
+         iloc  = MAXLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iima1 = iloc(1) + nimpp - 1
+         ijma1 = iloc(2) + njmpp - 1
+         iloc  = MAXLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iima2 = iloc(1) + nimpp - 1
+         ijma2 = iloc(2) + njmpp - 1
+      ENDIF
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_ctl : extrema of the masked scale factors'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, iima1, ijma1
+         WRITE(numout,"(14x,'e1t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1min, iimi1, ijmi1
+         WRITE(numout,"(14x,'e2t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2max, iima2, ijma2
+         WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, iimi2, ijmi2
+      ENDIF
+      !
+   END SUBROUTINE dom_ctl
+
+   !!======================================================================
+END MODULE domain
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domcfg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domcfg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domcfg.F90	(revision 1844)
@@ -0,0 +1,190 @@
+MODULE domcfg
+   !!==============================================================================
+   !!                       ***  MODULE domcfg   ***
+   !! Ocean initialization : domain configuration initialization
+   !!==============================================================================
+   !! History :  1.0  ! 2003-09  (G. Madec)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_cfg        : initialize the domain configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_cfg    ! called by opa.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_cfg
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_cfg  ***
+      !!                    
+      !! ** Purpose :   set the domain configuration
+      !!
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN                   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_cfg : set the ocean configuration'
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   ocean model configuration used :   cp_cfg = ', cp_cfg, ' jp_cfg = ', jp_cfg
+         !
+         WRITE(numout,*) '   global domain lateral boundaries'
+         !
+         IF( jperio == 0 )   WRITE(numout,*) '      jperio= 0, closed'
+         IF( jperio == 1 )   WRITE(numout,*) '      jperio= 1, cyclic east-west'
+         IF( jperio == 2 )   WRITE(numout,*) '      jperio= 2, equatorial symmetric'
+         IF( jperio == 3 )   WRITE(numout,*) '      jperio= 3, north fold with T-point pivot'
+         IF( jperio == 4 )   WRITE(numout,*) '      jperio= 4, cyclic east-west and north fold with T-point pivot'
+         IF( jperio == 5 )   WRITE(numout,*) '      jperio= 5, north fold with F-point pivot'
+         IF( jperio == 6 )   WRITE(numout,*) '      jperio= 6, cyclic east-west and north fold with F-point pivot'
+      ENDIF
+      !
+      IF( jperio <  0 .OR. jperio > 6 )   CALL ctl_stop( 'jperio is out of range' )
+      !
+      CALL dom_glo                   ! global domain versus zoom and/or local domain
+      !
+   END SUBROUTINE dom_cfg
+
+
+   SUBROUTINE dom_glo
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_glo  ***
+      !!
+      !! ** Purpose :   initialization for global domain, zoom and local domain
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  : - mig  , mjg : 
+      !!              - mi0  , mi1   :
+      !!              - mj0, , mj1   :
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj   ! dummy loop argument
+      !!----------------------------------------------------------------------
+
+      !                        ! ============== !
+      !                        !  Local domain  ! 
+      !                        ! ============== !
+      DO ji = 1, jpi                 ! local domain indices ==> data domain indices
+        mig(ji) = ji + jpizoom - 1 + nimpp - 1
+      END DO
+      DO jj = 1, jpj
+        mjg(jj) = jj + jpjzoom - 1 + njmpp - 1
+      END DO
+      !
+      !                              ! data domain indices ==> local domain indices
+      !                                   ! (return (m.0,m.1)=(1,0) if data domain gridpoint is to the west/south of the 
+      !                                   !local domain, or (m.0,m.1)=(jp.+1,jp.) to the east/north of local domain. 
+      DO ji = 1, jpidta
+        mi0(ji) = MAX( 1, MIN( ji - jpizoom + 1 - nimpp + 1, jpi+1 ) )
+        mi1(ji) = MAX( 0, MIN( ji - jpizoom + 1 - nimpp + 1, jpi   ) )
+      END DO
+      DO jj = 1, jpjdta
+        mj0(jj) = MAX( 1, MIN( jj - jpjzoom + 1 - njmpp + 1, jpj+1 ) )
+        mj1(jj) = MAX( 0, MIN( jj - jpjzoom + 1 - njmpp + 1, jpj   ) )
+      END DO
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_glo : domain: data / local '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '          data input domain    : jpidta = ', jpidta,   &
+            &                                            ' jpjdta = ', jpjdta, ' jpkdta = ', jpkdta
+         WRITE(numout,*) '          global or zoom domain: jpiglo = ', jpiglo,   &
+            &                                            ' jpjglo = ', jpjglo, ' jpk    = ', jpk
+         WRITE(numout,*) '          local domain         : jpi    = ', jpi   ,   &
+            &                                            ' jpj    = ', jpj   , ' jpk    = ', jpk
+         WRITE(numout,*)
+         WRITE(numout,*) '          south-west indices    jpizoom = ', jpizoom,   &
+            &                                           ' jpjzoom = ', jpjzoom
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion local  ==> data i-index domain'
+         WRITE(numout,25)              (mig(ji),ji = 1,jpi)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion data   ==> local  i-index domain'
+         WRITE(numout,*) '             starting index'
+         WRITE(numout,25)              (mi0(ji),ji = 1,jpidta)
+         WRITE(numout,*) '             ending index'
+         WRITE(numout,25)              (mi1(ji),ji = 1,jpidta)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion local  ==> data j-index domain'
+         WRITE(numout,25)              (mjg(jj),jj = 1,jpj)
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion data  ==> local j-index domain'
+         WRITE(numout,*) '             starting index'
+         WRITE(numout,25)              (mj0(jj),jj = 1,jpjdta)
+         WRITE(numout,*) '             ending index'
+         WRITE(numout,25)              (mj1(jj),jj = 1,jpjdta)
+      ENDIF
+ 25   FORMAT( 100(10x,19i4,/) )
+
+      !                        ! ============== !
+      !                        !  Zoom domain   !
+      !                        ! ============== !
+      !                              ! zoom control
+      IF( jpiglo + jpizoom - 1  >  jpidta .OR.   &
+          jpjglo + jpjzoom - 1  >  jpjdta      ) &
+          &   CALL ctl_stop( ' global or zoom domain exceed the data domain ! ' )
+
+      !                              ! set zoom flag
+      IF( jpiglo < jpidta .OR. jpjglo < jpjdta )   lzoom = .TRUE.
+
+      !                              ! set zoom type flags
+      IF( lzoom .AND. jpizoom /= 1 )   lzoom_w = .TRUE.                     ! 
+      IF( lzoom .AND. jpjzoom /= 1 )   lzoom_s = .TRUE.
+      IF( lzoom .AND. jpiglo + jpizoom -1 /= jpidta )   lzoom_e = .TRUE.
+      IF( lzoom .AND. jpjglo + jpjzoom -1 /= jpjdta )   lzoom_n = .TRUE.
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '          zoom flags : '
+         WRITE(numout,*) '             lzoom   = ', lzoom  , ' (T = zoom, F = global )'
+         WRITE(numout,*) '             lzoom_e = ', lzoom_e, ' (T = forced closed east  boundary)'
+         WRITE(numout,*) '             lzoom_w = ', lzoom_w, ' (T = forced closed west  boundary)'
+         WRITE(numout,*) '             lzoom_s = ', lzoom_s, ' (T = forced closed South boundary)'
+         WRITE(numout,*) '             lzoom_n = ', lzoom_n, ' (T = forced closed North boundary)'
+      ENDIF
+      IF(  ( lzoom_e .OR. lzoom_w )  .AND.  ( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 )  )   &
+           &   CALL ctl_stop( ' Your zoom choice is inconsistent with east-west cyclic boundary condition' )
+      IF(  lzoom_n  .AND.  ( 3 <= jperio .AND. jperio <= 6 )  )   &
+           &   CALL ctl_stop( ' Your zoom choice is inconsistent with North fold boundary condition' )
+
+      !                              ! Pre-defined arctic/antarctic zoom of ORCA configuration flag
+      IF( cp_cfg == "orca" ) THEN
+         SELECT CASE ( jp_cfg )
+         CASE ( 2 )                               !  ORCA_R2 configuration
+            IF(  jpiglo  == 142    .AND. jpjglo  ==  53 .AND.   &
+               & jpizoom ==  21    .AND. jpjzoom ==  97         )   lzoom_arct = .TRUE.
+            IF(  jpiglo  == jpidta .AND. jpjglo  ==  50 .AND.   &
+               & jpizoom ==   1    .AND. jpjzoom ==   1         )   lzoom_anta = .TRUE.
+            !                             
+         CASE ( 05 )                              !  ORCA_R05 configuration
+            IF(  jpiglo  == 562    .AND. jpjglo  == 202 .AND.   &
+               & jpizoom ==  81    .AND. jpjzoom == 301         )   lzoom_arct = .TRUE.
+            IF(  jpiglo  == jpidta .AND. jpjglo  == 187 .AND.   &
+               & jpizoom ==   1    .AND. jpjzoom ==   1         )   lzoom_anta = .TRUE.
+         END SELECT
+         !
+         IF(lwp) WRITE(numout,*) '          ORCA configuration: antarctic/arctic zoom flags : '
+         IF(lwp) WRITE(numout,*) '             lzoom_arct = ', lzoom_arct, ' (T=   arctic zoom, F=global)'
+         IF(lwp) WRITE(numout,*) '             lzoom_anta = ', lzoom_anta, ' (T=antarctic zoom, F=global)'
+         !
+      ENDIF
+      !
+   END SUBROUTINE dom_glo
+
+   !!======================================================================
+END MODULE domcfg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domhgr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 1844)
@@ -0,0 +1,573 @@
+MODULE domhgr
+   !!==============================================================================
+   !!                       ***  MODULE domhgr   ***
+   !! Ocean initialization : domain initialization
+   !!==============================================================================
+   !! History :       !  88-03  (G. Madec)
+   !!                 !  91-11  (G. Madec)
+   !!                 !  92-06  (M. Imbard)
+   !!                 !  96-01  (G. Madec)  terrain following coordinates
+   !!                 !  97-02  (G. Madec)  print mesh informations
+   !!                 !  99-11  (M. Imbard) NetCDF format with IO-IPSL
+   !!                 !  00-08  (D. Ludicone) Reduced section at Bab el Mandeb
+   !!                 !  01-09  (M. Levy)  eel config: grid in km, beta-plane
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module, namelist
+   !!            9.0  !  04-01  (A.M. Treguier, J.M. Molines) Case 4 (Mercator mesh)
+   !!                           use of parameters in par_CONFIG-Rxx.h90, not in namelist
+   !!                 !  04-05  (A. Koch-Larrouy) Add Gyre configuration 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_hgr        : initialize the horizontal mesh 
+   !!   hgr_read       : read "coordinate" NetCDF file 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Module variables
+   REAL(wp) ::   glam0, gphi0           ! variables corresponding to parameters
+      !                                 ! ppglam0 ppgphi0 set in par_oce
+
+   !! * Routine accessibility
+   PUBLIC dom_hgr        ! called by domain.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_hgr
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_hgr  ***
+      !!
+      !! ** Purpose :   Compute the geographical position (in degre) of the 
+      !!      model grid-points,  the horizontal scale factors (in meters) and 
+      !!      the Coriolis factor (in s-1).
+      !!
+      !! ** Method  :   The geographical position of the model grid-points is
+      !!      defined from analytical functions, fslam and fsphi, the deriva-
+      !!      tives of which gives the horizontal scale factors e1,e2.
+      !!      Defining two function fslam and fsphi and their derivatives in 
+      !!      the two horizontal directions (fse1 and fse2), the model grid-
+      !!      point position and scale factors are given by:
+      !!         t-point:
+      !!      glamt(i,j) = fslam(i    ,j    )   e1t(i,j) = fse1(i    ,j    )
+      !!      gphit(i,j) = fsphi(i    ,j    )   e2t(i,j) = fse2(i    ,j    )
+      !!         u-point:
+      !!      glamu(i,j) = fslam(i+1/2,j    )   e1u(i,j) = fse1(i+1/2,j    )
+      !!      gphiu(i,j) = fsphi(i+1/2,j    )   e2u(i,j) = fse2(i+1/2,j    )
+      !!         v-point:
+      !!      glamv(i,j) = fslam(i    ,j+1/2)   e1v(i,j) = fse1(i    ,j+1/2)
+      !!      gphiv(i,j) = fsphi(i    ,j+1/2)   e2v(i,j) = fse2(i    ,j+1/2)
+      !!            f-point:
+      !!      glamf(i,j) = fslam(i+1/2,j+1/2)   e1f(i,j) = fse1(i+1/2,j+1/2)
+      !!      gphif(i,j) = fsphi(i+1/2,j+1/2)   e2f(i,j) = fse2(i+1/2,j+1/2)
+      !!      Where fse1 and fse2 are defined by:
+      !!         fse1(i,j) = ra * rad * SQRT( (cos(phi) di(fslam))**2
+      !!                                     +          di(fsphi) **2 )(i,j)
+      !!         fse2(i,j) = ra * rad * SQRT( (cos(phi) dj(fslam))**2
+      !!                                     +          dj(fsphi) **2 )(i,j)
+      !!
+      !!        The coriolis factor is given at z-point by:
+      !!                     ff = 2.*omega*sin(gphif)      (in s-1)
+      !!
+      !!        This routine is given as an example, it must be modified
+      !!      following the user s desiderata. nevertheless, the output as
+      !!      well as the way to compute the model grid-point position and
+      !!      horizontal scale factors must be respected in order to insure
+      !!      second order accuracy schemes.
+      !!
+      !! N.B. If the domain is periodic, verify that scale factors are also
+      !!      periodic, and the coriolis term again.
+      !!
+      !! ** Action  : - define  glamt, glamu, glamv, glamf: longitude of t-, 
+      !!                u-, v- and f-points (in degre)
+      !!              - define  gphit, gphiu, gphiv, gphit: latitude  of t-,
+      !!               u-, v-  and f-points (in degre)
+      !!        define e1t, e2t, e1u, e2u, e1v, e2v, e1f, e2f: horizontal
+      !!      scale factors (in meters) at t-, u-, v-, and f-points.
+      !!        define ff: coriolis factor at f-point
+      !!
+      !! References :   Marti, Madec and Delecluse, 1992, JGR
+      !!                Madec, Imbard, 1996, Clim. Dyn.
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj              ! dummy loop indices
+      INTEGER  ::   ii0, ii1, ij0, ij1  ! temporary integers
+      INTEGER  ::   ijeq                ! index of equator T point (used in case 4)
+      REAL(wp) ::   &
+         zti, zui, zvi, zfi,         &  ! temporary scalars
+         ztj, zuj, zvj, zfj,         &  !
+         zphi0, zbeta, znorme,       &  !
+         zarg, zf0, zminff, zmaxff
+      REAL(wp) ::   &
+         zlam1, zcos_alpha, zim1 , zjm1 , ze1, ze1deg,   &
+         zphi1, zsin_alpha, zim05, zjm05
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_hgr : define the horizontal mesh from ithe following par_oce parameters '
+         WRITE(numout,*) '~~~~~~~      type of horizontal mesh           jphgr_msh = ', jphgr_msh
+         WRITE(numout,*) '             position of the first row and     ppglam0  = ', ppglam0
+         WRITE(numout,*) '             column grid-point (degrees)       ppgphi0  = ', ppgphi0
+         WRITE(numout,*) '             zonal      grid-spacing (degrees) ppe1_deg = ', ppe1_deg
+         WRITE(numout,*) '             meridional grid-spacing (degrees) ppe2_deg = ', ppe2_deg
+         WRITE(numout,*) '             zonal      grid-spacing (meters)  ppe1_m   = ', ppe1_m  
+         WRITE(numout,*) '             meridional grid-spacing (meters)  ppe2_m   = ', ppe2_m  
+      ENDIF
+
+
+      SELECT CASE( jphgr_msh )   ! type of horizontal mesh
+
+      CASE ( 0 )                     !  curvilinear coordinate on the sphere read in coordinate.nc file
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          curvilinear coordinate on the sphere read in "coordinate" file'
+
+         CALL hgr_read           ! Defaultl option  :   NetCDF file
+
+         !                                                ! =====================
+         IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
+            !                                             ! =====================
+            IF( n_cla == 0 ) THEN
+               !
+               ii0 = 139   ;   ii1 = 140        ! Gibraltar Strait (e2u = 20 km)
+               ij0 = 102   ;   ij1 = 102   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  20.e3
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '             orca_r2: Gibraltar    : e2u reduced to 20 km'
+               !
+               ii0 = 160   ;   ii1 = 160        ! Bab el Mandeb (e2u = 18 km)
+               ij0 =  88   ;   ij1 =  88   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  18.e3
+                                               e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  30.e3
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb: e2u reduced to 30 km'
+               IF(lwp) WRITE(numout,*) '                                     e1v reduced to 18 km'
+            ENDIF
+
+            ii0 = 145   ;   ii1 = 146        ! Danish Straits (e2u = 10 km)
+            ij0 = 116   ;   ij1 = 116   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r2: Danish Straits : e2u reduced to 10 km'
+            !
+         ENDIF
+
+         !                                                ! ======================
+         IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN   ! ORCA R05 configuration
+            !                                             ! ======================
+            ii0 = 563   ;   ii1 = 564        ! Gibraltar Strait (e2u = 20 km)
+            ij0 = 327   ;   ij1 = 327   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  20.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Gibraltar Strait'
+            !
+            ii0 = 627   ;   ii1 = 628        ! Bosphore Strait (e2u = 10 km)
+            ij0 = 343   ;   ij1 = 343   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Bosphore Strait'
+            !
+            ii0 =  93   ;   ii1 =  94        ! Sumba Strait (e2u = 40 km)
+            ij0 = 232   ;   ij1 = 232   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  40.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Sumba Strait'
+            !
+            ii0 = 103   ;   ii1 = 103        ! Ombai Strait (e2u = 15 km)
+            ij0 = 232   ;   ij1 = 232   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  15.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Ombai Strait'
+            !
+            ii0 =  15   ;   ii1 =  15        ! Palk Strait (e2u = 10 km)
+            ij0 = 270   ;   ij1 = 270   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Palk Strait'
+            !
+            ii0 =  87   ;   ii1 =  87        ! Lombok Strait (e1v = 10 km)
+            ij0 = 232   ;   ij1 = 233   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e1v at the Lombok Strait'
+            !
+            !
+            ii0 = 662   ;   ii1 = 662        ! Bab el Mandeb (e1v = 25 km)
+            ij0 = 276   ;   ij1 = 276   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  25.e3
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e1v at the Bab el Mandeb'
+            !
+         ENDIF
+
+
+         ! N.B. :  General case, lat and long function of both i and j indices:
+         !     e1t(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphit(ji,jj) ) * fsdila( zti, ztj ) )**2   &
+         !                                  + (                           fsdiph( zti, ztj ) )**2  )
+         !     e1u(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiu(ji,jj) ) * fsdila( zui, zuj ) )**2   &
+         !                                  + (                           fsdiph( zui, zuj ) )**2  )
+         !     e1v(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiv(ji,jj) ) * fsdila( zvi, zvj ) )**2   &
+         !                                  + (                           fsdiph( zvi, zvj ) )**2  )
+         !     e1f(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphif(ji,jj) ) * fsdila( zfi, zfj ) )**2   &
+         !                                  + (                           fsdiph( zfi, zfj ) )**2  )
+         !
+         !     e2t(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphit(ji,jj) ) * fsdjla( zti, ztj ) )**2   &
+         !                                  + (                           fsdjph( zti, ztj ) )**2  )
+         !     e2u(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiu(ji,jj) ) * fsdjla( zui, zuj ) )**2   &
+         !                                  + (                           fsdjph( zui, zuj ) )**2  )
+         !     e2v(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiv(ji,jj) ) * fsdjla( zvi, zvj ) )**2   &
+         !                                  + (                           fsdjph( zvi, zvj ) )**2  )
+         !     e2f(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphif(ji,jj) ) * fsdjla( zfi, zfj ) )**2   &
+         !                                  + (                           fsdjph( zfi, zfj ) )**2  )
+
+
+      CASE ( 1 )                     ! geographical mesh on the sphere with regular grid-spacing
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          geographical mesh on the sphere with regular grid-spacing'
+         IF(lwp) WRITE(numout,*) '          given by ppe1_deg and ppe2_deg' 
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - 1 + njmpp - 1 )
+               zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - 1 + njmpp - 1 )
+               zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
+               zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
+         ! Longitude
+               glamt(ji,jj) = ppglam0 + ppe1_deg * zti
+               glamu(ji,jj) = ppglam0 + ppe1_deg * zui
+               glamv(ji,jj) = ppglam0 + ppe1_deg * zvi
+               glamf(ji,jj) = ppglam0 + ppe1_deg * zfi
+         ! Latitude
+               gphit(ji,jj) = ppgphi0 + ppe2_deg * ztj
+               gphiu(ji,jj) = ppgphi0 + ppe2_deg * zuj
+               gphiv(ji,jj) = ppgphi0 + ppe2_deg * zvj
+               gphif(ji,jj) = ppgphi0 + ppe2_deg * zfj
+         ! e1
+               e1t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg
+               e1u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg
+               e1v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg
+               e1f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg
+         ! e2
+               e2t(ji,jj) = ra * rad * ppe2_deg
+               e2u(ji,jj) = ra * rad * ppe2_deg
+               e2v(ji,jj) = ra * rad * ppe2_deg
+               e2f(ji,jj) = ra * rad * ppe2_deg
+            END DO
+         END DO
+
+
+      CASE ( 2:3 )                   ! f- or beta-plane with regular grid-spacing
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          f- or beta-plane with regular grid-spacing'
+         IF(lwp) WRITE(numout,*) '          given by ppe1_m and ppe2_m' 
+
+         ! Position coordinates (in kilometers)
+         !                          ==========
+         glam0 = 0.e0
+         gphi0 = - ppe2_m * 1.e-3
+         
+#if defined key_agrif && defined key_eel_r6
+         IF( .NOT. Agrif_Root() ) THEN
+           glam0  = Agrif_Parent(glam0) + (Agrif_ix())*Agrif_Parent(ppe1_m) * 1.e-3
+           gphi0  = Agrif_Parent(gphi0) + (Agrif_iy())*Agrif_Parent(ppe2_m) * 1.e-3
+           ppe1_m = Agrif_Parent(ppe1_m)/Agrif_Rhox()
+           ppe2_m = Agrif_Parent(ppe2_m)/Agrif_Rhoy()          
+         ENDIF
+#endif         
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               glamt(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( FLOAT( ji - 1 + nimpp - 1 )       )
+               glamu(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( FLOAT( ji - 1 + nimpp - 1 ) + 0.5 )
+               glamv(ji,jj) = glamt(ji,jj)
+               glamf(ji,jj) = glamu(ji,jj)
+   
+               gphit(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( FLOAT( jj - 1 + njmpp - 1 )       )
+               gphiu(ji,jj) = gphit(ji,jj)
+               gphiv(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( FLOAT( jj - 1 + njmpp - 1 ) + 0.5 )
+               gphif(ji,jj) = gphiv(ji,jj)
+            END DO
+         END DO
+
+         ! Horizontal scale factors (in meters)
+         !                              ======
+         e1t(:,:) = ppe1_m      ;      e2t(:,:) = ppe2_m
+         e1u(:,:) = ppe1_m      ;      e2u(:,:) = ppe2_m
+         e1v(:,:) = ppe1_m      ;      e2v(:,:) = ppe2_m
+         e1f(:,:) = ppe1_m      ;      e2f(:,:) = ppe2_m
+
+      CASE ( 4 )                     ! geographical mesh on the sphere, isotropic MERCATOR type
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          geographical mesh on the sphere, MERCATOR type'
+         IF(lwp) WRITE(numout,*) '          longitudinal/latitudinal spacing given by ppe1_deg'
+         IF ( ppgphi0 == -90 ) CALL ctl_stop( ' Mercator grid cannot start at south pole !!!! ' )
+
+         !  Find index corresponding to the equator, given the grid spacing e1_deg
+         !  and the (approximate) southern latitude ppgphi0.
+         !  This way we ensure that the equator is at a "T / U" point, when in the domain.
+         !  The formula should work even if the equator is outside the domain.
+         zarg = rpi / 4. - rpi / 180. * ppgphi0 / 2.
+         ijeq = ABS( 180./rpi * LOG( COS( zarg ) / SIN( zarg ) ) / ppe1_deg )
+         IF(  ppgphi0 > 0 )  ijeq = -ijeq
+
+         IF(lwp) WRITE(numout,*) '          Index of the equator on the MERCATOR grid:', ijeq
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - ijeq + njmpp - 1 )
+               zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - ijeq + njmpp - 1 )
+               zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - ijeq + njmpp - 1 ) + 0.5
+               zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - ijeq + njmpp - 1 ) + 0.5
+         ! Longitude
+               glamt(ji,jj) = ppglam0 + ppe1_deg * zti
+               glamu(ji,jj) = ppglam0 + ppe1_deg * zui
+               glamv(ji,jj) = ppglam0 + ppe1_deg * zvi
+               glamf(ji,jj) = ppglam0 + ppe1_deg * zfi
+         ! Latitude
+               gphit(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* ztj ) )
+               gphiu(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zuj ) )
+               gphiv(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zvj ) )
+               gphif(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zfj ) )
+         ! e1
+               e1t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg
+               e1u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg
+               e1v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg
+               e1f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg
+         ! e2
+               e2t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg
+               e2u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg
+               e2v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg
+               e2f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg
+            END DO
+         END DO
+
+      CASE ( 5 )                   ! beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          beta-plane with regular grid-spacing and rotated domain (GYRE configuration)'
+         IF(lwp) WRITE(numout,*) '          given by ppe1_m and ppe2_m'
+
+         ! Position coordinates (in kilometers)
+         !                          ==========
+
+         ! angle 45deg and ze1=106.e+3 / jp_cfg forced -> zlam1 = -85deg, zphi1 = 29degN
+         zlam1 = -85
+         zphi1 = 29
+         ! resolution in meters
+         ze1 = 106000. / FLOAT(jp_cfg)            
+         ! benchmark: forced the resolution to be about 100 km
+         IF( nbench /= 0 )   ze1 = 106000.e0     
+         zsin_alpha = - SQRT( 2. ) / 2.
+         zcos_alpha =   SQRT( 2. ) / 2.
+         ze1deg = ze1 / (ra * rad)
+         IF( nbench /= 0 )   ze1deg = ze1deg / FLOAT(jp_cfg)        ! benchmark: keep the lat/+lon
+         !                                                          ! at the right jp_cfg resolution
+         glam0 = zlam1 + zcos_alpha * ze1deg * FLOAT( jpjglo-2 )
+         gphi0 = zphi1 + zsin_alpha * ze1deg * FLOAT( jpjglo-2 )
+
+         IF( nprint==1 .AND. lwp )   THEN
+            WRITE(numout,*) '          ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
+            WRITE(numout,*) '          ze1deg', ze1deg, 'glam0', glam0, 'gphi0', gphi0
+         ENDIF
+
+         DO jj = 1, jpj
+           DO ji = 1, jpi
+             zim1 = FLOAT( ji + nimpp - 1 ) - 1.   ;   zim05 = FLOAT( ji + nimpp - 1 ) - 1.5
+             zjm1 = FLOAT( jj + njmpp - 1 ) - 1.   ;   zjm05 = FLOAT( jj + njmpp - 1 ) - 1.5
+
+             glamf(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+             gphif(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+
+             glamt(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+             gphit(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+
+             glamu(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+             gphiu(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+
+             glamv(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+             gphiv(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+           END DO
+          END DO
+
+         ! Horizontal scale factors (in meters)
+         !                              ======
+         e1t(:,:) =  ze1     ;      e2t(:,:) = ze1
+         e1u(:,:) =  ze1     ;      e2u(:,:) = ze1
+         e1v(:,:) =  ze1     ;      e2v(:,:) = ze1
+         e1f(:,:) =  ze1     ;      e2f(:,:) = ze1
+
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for jphgr_msh = ', jphgr_msh
+         CALL ctl_stop( ctmp1 )
+
+      END SELECT
+
+
+      ! Control printing : Grid informations (if not restart)
+      ! ----------------
+
+      IF( lwp .AND. .NOT.ln_rstart ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '          longitude and e1 scale factors'
+         WRITE(numout,*) '          ------------------------------'
+         WRITE(numout,9300) ( ji, glamt(ji,1), glamu(ji,1),   &
+            glamv(ji,1), glamf(ji,1),   &
+            e1t(ji,1), e1u(ji,1),   &
+            e1v(ji,1), e1f(ji,1), ji = 1, jpi,10)
+9300     FORMAT( 1x, i4, f8.2,1x, f8.2,1x, f8.2,1x, f8.2, 1x,    &
+            f19.10, 1x, f19.10, 1x, f19.10, 1x, f19.10 )
+         
+         WRITE(numout,*)
+         WRITE(numout,*) '          latitude and e2 scale factors'
+         WRITE(numout,*) '          -----------------------------'
+         WRITE(numout,9300) ( jj, gphit(1,jj), gphiu(1,jj),   &
+            &                     gphiv(1,jj), gphif(1,jj),   &
+            &                     e2t  (1,jj), e2u  (1,jj),   &
+            &                     e2v  (1,jj), e2f  (1,jj), jj = 1, jpj, 10 )
+      ENDIF
+
+      
+      IF( nprint == 1 .AND. lwp ) THEN
+         WRITE(numout,*) '          e1u e2u '
+         CALL prihre( e1u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         CALL prihre( e2u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         WRITE(numout,*) '          e1v e2v  '
+         CALL prihre( e1v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         CALL prihre( e2v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         WRITE(numout,*) '          e1f e2f  '
+         CALL prihre( e1f,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+         CALL prihre( e2f,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
+      ENDIF
+
+
+      ! ================= !
+      !  Coriolis factor  !
+      ! ================= !
+
+      SELECT CASE( jphgr_msh )   ! type of horizontal mesh
+
+      CASE ( 0, 1, 4 )               ! mesh on the sphere
+
+         ff(:,:) = 2. * omega * SIN( rad * gphif(:,:) ) 
+
+      CASE ( 2 )                     ! f-plane at ppgphi0 
+
+         ff(:,:) = 2. * omega * SIN( rad * ppgphi0 )
+
+         IF(lwp) WRITE(numout,*) '          f-plane: Coriolis parameter = constant = ', ff(1,1)
+
+      CASE ( 3 )                     ! beta-plane
+
+         zbeta   = 2. * omega * COS( rad * ppgphi0 ) / ra                       ! beta at latitude ppgphi0
+         zphi0   = ppgphi0 - FLOAT( jpjglo/2) * ppe2_m / ( ra * rad )           ! latitude of the first row F-points
+         
+#if defined key_agrif && defined key_eel_r6
+         IF( .NOT. Agrif_Root() ) THEN
+           zphi0 = ppgphi0 - FLOAT( Agrif_Parent(jpjglo)/2)*Agrif_Parent(ppe2_m) / (ra * rad)
+         ENDIF
+#endif         
+         zf0     = 2. * omega * SIN( rad * zphi0 )                              ! compute f0 1st point south
+
+         ff(:,:) = ( zf0  + zbeta * gphif(:,:) * 1.e+3 )                        ! f = f0 +beta* y ( y=0 at south)
+         
+         IF(lwp) THEN
+            WRITE(numout,*) 
+            WRITE(numout,*) '          Beta-plane: Beta parameter = constant = ', ff(nldi,nldj)
+            WRITE(numout,*) '          Coriolis parameter varies from ', ff(nldi,nldj),' to ', ff(nldi,nlej)
+         ENDIF
+         IF( lk_mpp ) THEN 
+            zminff=ff(nldi,nldj)
+            zmaxff=ff(nldi,nlej)
+            CALL mpp_min( zminff )   ! min over the global domain
+            CALL mpp_max( zmaxff )   ! max over the global domain
+            IF(lwp) WRITE(numout,*) '          Coriolis parameter varies globally from ', zminff,' to ', zmaxff
+         END IF
+
+      CASE ( 5 )                     ! beta-plane and rotated domain (gyre configuration)
+
+         zbeta = 2. * omega * COS( rad * ppgphi0 ) / ra                     ! beta at latitude ppgphi0
+         zphi0 = 15.e0                                                      ! latitude of the first row F-points
+         zf0   = 2. * omega * SIN( rad * zphi0 )                            ! compute f0 1st point south
+
+         ff(:,:) = ( zf0 + zbeta * ABS( gphif(:,:) - zphi0 ) * rad * ra )   ! f = f0 +beta* y ( y=0 at south)
+
+         IF(lwp) THEN
+            WRITE(numout,*) 
+            WRITE(numout,*) '          Beta-plane and rotated domain : '
+            WRITE(numout,*) '          Coriolis parameter varies in this processor from ', ff(nldi,nldj),' to ', ff(nldi,nlej)
+         ENDIF
+
+         IF( lk_mpp ) THEN 
+            zminff=ff(nldi,nldj)
+            zmaxff=ff(nldi,nlej)
+            CALL mpp_min( zminff )   ! min over the global domain
+            CALL mpp_max( zmaxff )   ! max over the global domain
+            IF(lwp) WRITE(numout,*) '          Coriolis parameter varies globally from ', zminff,' to ', zmaxff
+         END IF
+
+      END SELECT
+
+
+      ! Control of domain for symetrical condition
+      ! ------------------------------------------
+      ! The equator line must be the latitude coordinate axe
+
+      IF( nperio == 2 ) THEN
+         znorme = SQRT( SUM( gphiu(:,2) * gphiu(:,2) ) ) / FLOAT( jpi )
+         IF( znorme > 1.e-13 ) CALL ctl_stop( ' ===>>>> : symmetrical condition: rerun with good equator line' )
+      ENDIF
+
+   END SUBROUTINE dom_hgr
+
+
+   SUBROUTINE hgr_read
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE hgr_read  ***
+      !!
+      !! ** Purpose :   Read a coordinate file in NetCDF format 
+      !!
+      !! ** Method  :   The mesh file has been defined trough a analytical 
+      !!      or semi-analytical method. It is read in a NetCDF file. 
+      !!     
+      !!----------------------------------------------------------------------
+      USE iom
+
+      INTEGER ::   inum   ! temporary logical unit
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'hgr_read : read the horizontal coordinates'
+         WRITE(numout,*) '~~~~~~~~      jpiglo = ', jpiglo, ' jpjglo = ', jpjglo, ' jpk = ', jpk
+      ENDIF
+      
+      CALL iom_open( 'coordinates', inum )
+      
+      CALL iom_get( inum, jpdom_data, 'glamt', glamt )
+      CALL iom_get( inum, jpdom_data, 'glamu', glamu )
+      CALL iom_get( inum, jpdom_data, 'glamv', glamv )
+      CALL iom_get( inum, jpdom_data, 'glamf', glamf )
+      
+      CALL iom_get( inum, jpdom_data, 'gphit', gphit )
+      CALL iom_get( inum, jpdom_data, 'gphiu', gphiu )
+      CALL iom_get( inum, jpdom_data, 'gphiv', gphiv )
+      CALL iom_get( inum, jpdom_data, 'gphif', gphif )
+      
+      CALL iom_get( inum, jpdom_data, 'e1t', e1t )
+      CALL iom_get( inum, jpdom_data, 'e1u', e1u )
+      CALL iom_get( inum, jpdom_data, 'e1v', e1v )
+      CALL iom_get( inum, jpdom_data, 'e1f', e1f )
+      
+      CALL iom_get( inum, jpdom_data, 'e2t', e2t )
+      CALL iom_get( inum, jpdom_data, 'e2u', e2u )
+      CALL iom_get( inum, jpdom_data, 'e2v', e2v )
+      CALL iom_get( inum, jpdom_data, 'e2f', e2f )
+      
+      CALL iom_close( inum )
+      
+    END SUBROUTINE hgr_read
+    
+   !!======================================================================
+END MODULE domhgr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 1844)
@@ -0,0 +1,585 @@
+MODULE dommsk
+   !!======================================================================
+   !!                       ***  MODULE dommsk   ***
+   !! Ocean initialization : domain land/sea mask 
+   !!======================================================================
+   !! History :  OPA  ! 1987-07  (G. Madec)  Original code
+   !!             -   ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
+   !!             -   ! 1996-01  (G. Madec)  suppression of common work arrays
+   !!             -   ! 1996-05  (G. Madec)  mask computed from tmask and sup-
+   !!                 !                      pression of the double computation of bmask
+   !!             -   ! 1997-02  (G. Madec)  mesh information put in domhgr.F
+   !!             -   ! 1997-07  (G. Madec)  modification of mbathy and fmask
+   !!             -   ! 1998-05  (G. Roullet)  free surface
+   !!             -   ! 2000-03  (G. Madec)  no slip accurate
+   !!             -   ! 2001-09  (J.-M. Molines)  Open boundaries
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
+   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_msk        : compute land/ocean mask
+   !!   dom_msk_nsa    : update land/ocean mask when no-slip accurate option is used.
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE obc_oce         ! ocean open boundary conditions
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_msk    ! routine called by inidom.F90
+
+   !                            !!* Namelist namlbc : lateral boundary condition *
+   REAL(wp) ::   rn_shlat = 2.   ! type of lateral boundary condition on velocity
+   
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE dom_msk
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dom_msk  ***
+      !!
+      !! ** Purpose :   Compute land/ocean mask arrays at tracer points, hori-
+      !!      zontal velocity points (u & v), vorticity points (f) and baro-
+      !!      tropic stream function  points (b).
+      !!        Set mbathy to the number of non-zero w-levels of a water column
+      !!
+      !! ** Method  :   The ocean/land mask is computed from the basin bathy-
+      !!      metry in level (mbathy) which is defined or read in dommba.
+      !!      mbathy equals 0 over continental T-point 
+      !!      and the number of ocean level over the ocean.
+      !!
+      !!      At a given position (ji,jj,jk) the ocean/land mask is given by:
+      !!      t-point : 0. IF mbathy( ji ,jj) =< 0
+      !!                1. IF mbathy( ji ,jj) >= jk
+      !!      u-point : 0. IF mbathy( ji ,jj)  or mbathy(ji+1, jj ) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy(ji+1, jj ) >= jk.
+      !!      v-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1) >= jk.
+      !!      f-point : 0. IF mbathy( ji ,jj)  or mbathy( ji ,jj+1)
+      !!                   or mbathy(ji+1,jj)  or mbathy(ji+1,jj+1) =< 0
+      !!                1. IF mbathy( ji ,jj) and mbathy( ji ,jj+1)
+      !!                and mbathy(ji+1,jj) and mbathy(ji+1,jj+1) >= jk.
+      !!      b-point : the same definition as for f-point of the first ocean
+      !!                level (surface level) but with 0 along coastlines.
+      !!
+      !!        The lateral friction is set through the value of fmask along
+      !!      the coast and topography. This value is defined by rn_shlat, a
+      !!      namelist parameter:
+      !!         rn_shlat = 0, free slip  (no shear along the coast)
+      !!         rn_shlat = 2, no slip  (specified zero velocity at the coast)
+      !!         0 < rn_shlat < 2, partial slip   | non-linear velocity profile
+      !!         2 < rn_shlat, strong slip        | in the lateral boundary layer
+      !!
+      !!      N.B. If nperio not equal to 0, the land/ocean mask arrays
+      !!      are defined with the proper value at lateral domain boundaries,
+      !!      but bmask. indeed, bmask defined the domain over which the
+      !!      barotropic stream function is computed. this domain cannot
+      !!      contain identical columns because the matrix associated with
+      !!      the barotropic stream function equation is then no more inverti-
+      !!      ble. therefore bmask is set to 0 along lateral domain boundaries
+      !!      even IF nperio is not zero.
+      !!
+      !!      In case of open boundaries (lk_obc=T):
+      !!        - tmask is set to 1 on the points to be computed bay the open
+      !!          boundaries routines.
+      !!        - bmask is  set to 0 on the open boundaries.
+      !!
+      !!      Set mbathy to the number of non-zero w-levels of a water column
+      !!                  mbathy = min( mbathy, 1 ) + 1
+      !!      (note that the minimum value of mbathy is 2).
+      !!
+      !! ** Action :   tmask    : land/ocean mask at t-point (=0. or 1.)
+      !!               umask    : land/ocean mask at u-point (=0. or 1.)
+      !!               vmask    : land/ocean mask at v-point (=0. or 1.)
+      !!               fmask    : land/ocean mask at f-point (=0. or 1.)
+      !!                          =rn_shlat along lateral boundaries
+      !!               bmask    : land/ocean mask at barotropic stream
+      !!                          function point (=0. or 1.) and set to 0 along lateral boundaries
+      !!               mbathy   : number of non-zero w-levels 
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      INTEGER  ::   iif, iil, ii0, ii1, ii
+      INTEGER  ::   ijf, ijl, ij0, ij1
+      INTEGER , DIMENSION(jpi,jpj) ::  imsk
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwf
+      !!
+      NAMELIST/namlbc/ rn_shlat
+      !!---------------------------------------------------------------------
+      
+      REWIND( numnam )              ! Namelist namlbc : lateral momentum boundary condition
+      READ  ( numnam, namlbc )
+      
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dommsk : ocean mask '
+         WRITE(numout,*) '~~~~~~'
+         WRITE(numout,*) '   Namelist namlbc'
+         WRITE(numout,*) '      lateral momentum boundary cond.    rn_shlat = ',rn_shlat
+      ENDIF
+
+      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral free-slip '
+      ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  no-slip '
+      ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  partial-slip '
+      ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  strong-slip '
+      ELSE
+         WRITE(ctmp1,*) ' rn_shlat is negative = ', rn_shlat
+         CALL ctl_stop( ctmp1 )
+      ENDIF
+
+      ! 1. Ocean/land mask at t-point (computed from mbathy)
+      ! -----------------------------
+      ! N.B. tmask has already the right boundary conditions since mbathy is ok
+      !
+      tmask(:,:,:) = 0.e0
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( REAL( mbathy(ji,jj) - jk ) +.1 >= 0.e0 )   tmask(ji,jj,jk) = 1.e0
+            END DO  
+         END DO  
+      END DO  
+
+!!gm  ????
+#if defined key_zdfkpp
+      IF( cp_cfg == 'orca' ) THEN
+         IF( jp_cfg == 2 )   THEN       ! land point on Bab el Mandeb zonal section
+            ij0 =  87   ;   ij1 =  88
+            ii0 = 160   ;   ii1 = 161
+            tmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 0.e0
+         ELSE
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,cform_war)
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*)'          A mask must be applied on Bab el Mandeb strait'
+            IF(lwp) WRITE(numout,*)'          in case of ORCAs configurations'
+            IF(lwp) WRITE(numout,*)'          This is a problem which is not yet solved'
+            IF(lwp) WRITE(numout,*)
+         ENDIF
+      ENDIF
+#endif
+!!gm end
+
+      ! Interior domain mask (used for global sum)
+      ! --------------------
+      tmask_i(:,:) = tmask(:,:,1)
+      iif = jpreci                         ! ???
+      iil = nlci - jpreci + 1
+      ijf = jprecj                         ! ???
+      ijl = nlcj - jprecj + 1
+
+      tmask_i( 1 :iif,   :   ) = 0.e0      ! first columns
+      tmask_i(iil:jpi,   :   ) = 0.e0      ! last  columns (including mpp extra columns)
+      tmask_i(   :   , 1 :ijf) = 0.e0      ! first rows
+      tmask_i(   :   ,ijl:jpj) = 0.e0      ! last  rows (including mpp extra rows)
+
+      ! north fold mask
+      ! ---------------
+      tpol(1:jpiglo) = 1.e0 
+      fpol(1:jpiglo) = 1.e0
+      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
+         tpol(jpiglo/2+1:jpiglo) = 0.e0
+         fpol(     1    :jpiglo) = 0.e0
+         IF( mjg(nlej) == jpjglo ) THEN                  ! only half of the nlcj-1 row
+            DO ji = iif+1, iil-1
+               tmask_i(ji,nlej-1) = tmask_i(ji,nlej-1) * tpol(mig(ji))
+            END DO
+         ENDIF
+      ENDIF
+      IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
+         tpol(     1    :jpiglo) = 0.e0
+         fpol(jpiglo/2+1:jpiglo) = 0.e0
+      ENDIF
+
+      ! 2. Ocean/land mask at u-,  v-, and z-points (computed from tmask)
+      ! -------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector loop
+               umask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)
+               vmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji  ,jj+1,jk)
+            END DO
+            DO ji = 1, jpim1      ! NO vector opt.
+               fmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)   &
+                  &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( umask, 'U', 1. )      ! Lateral boundary conditions
+      CALL lbc_lnk( vmask, 'V', 1. )
+      CALL lbc_lnk( fmask, 'F', 1. )
+
+
+      ! 4. ocean/land mask for the elliptic equation
+      ! --------------------------------------------
+      bmask(:,:) = tmask(:,:,1)       ! elliptic equation is written at t-point
+      !
+      !                               ! Boundary conditions
+      !                                    ! cyclic east-west : bmask must be set to 0. on rows 1 and jpi
+      IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN
+         bmask( 1 ,:) = 0.e0
+         bmask(jpi,:) = 0.e0
+      ENDIF
+      IF( nperio == 2 ) THEN               ! south symmetric :  bmask must be set to 0. on row 1
+         bmask(:, 1 ) = 0.e0
+      ENDIF
+      !                                    ! north fold : 
+      IF( nperio == 3 .OR. nperio == 4 ) THEN   ! T-pt pivot : bmask set to 0. on row jpj and on half jpjglo-1 row
+         DO ji = 1, jpi                      
+            ii = ji + nimpp - 1
+            bmask(ji,jpj-1) = bmask(ji,jpj-1) * tpol(ii)
+            bmask(ji,jpj  ) = 0.e0
+         END DO
+      ENDIF
+      IF( nperio == 5 .OR. nperio == 6 ) THEN   ! F-pt pivot and T-pt elliptic eq. : bmask set to 0. on row jpj
+         bmask(:,jpj) = 0.e0
+      ENDIF
+      !
+      IF( lk_mpp ) THEN                    ! mpp specificities
+         !                                      ! bmask is set to zero on the overlap region
+         IF( nbondi /= -1 .AND. nbondi /= 2 )   bmask(  1 :jpreci,:) = 0.e0
+         IF( nbondi /=  1 .AND. nbondi /= 2 )   bmask(nlci:jpi   ,:) = 0.e0
+         IF( nbondj /= -1 .AND. nbondj /= 2 )   bmask(:,  1 :jprecj) = 0.e0
+         IF( nbondj /=  1 .AND. nbondj /= 2 )   bmask(:,nlcj:jpj   ) = 0.e0
+         !
+         IF( npolj == 3 .OR. npolj == 4 ) THEN  ! north fold : bmask must be set to 0. on rows jpj-1 and jpj
+            DO ji = 1, nlci
+               ii = ji + nimpp - 1
+               bmask(ji,nlcj-1) = bmask(ji,nlcj-1) * tpol(ii)
+               bmask(ji,nlcj  ) = 0.e0
+            END DO
+         ENDIF
+         IF( npolj == 5 .OR. npolj == 6 ) THEN  ! F-pt pivot and T-pt elliptic eq. : bmask set to 0. on row jpj
+            DO ji = 1, nlci
+               bmask(ji,nlcj  ) = 0.e0
+            END DO
+         ENDIF
+      ENDIF
+
+
+      ! mask for second order calculation of vorticity
+      ! ----------------------------------------------
+      CALL dom_msk_nsa
+
+      
+      ! Lateral boundary conditions on velocity (modify fmask)
+      ! ---------------------------------------     
+      DO jk = 1, jpk
+         zwf(:,:) = fmask(:,:,jk)         
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( fmask(ji,jj,jk) == 0. ) THEN
+                  fmask(ji,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
+                     &                                       zwf(ji-1,jj), zwf(ji,jj-1)  )  )
+               ENDIF
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            IF( fmask(1,jj,jk) == 0. ) THEN
+               fmask(1  ,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
+            ENDIF
+            IF( fmask(jpi,jj,jk) == 0. ) THEN
+               fmask(jpi,jj,jk) = rn_shlat * MIN( 1., MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
+            ENDIF
+         END DO         
+         DO ji = 2, jpim1
+            IF( fmask(ji,1,jk) == 0. ) THEN
+               fmask(ji, 1 ,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
+            ENDIF
+            IF( fmask(ji,jpj,jk) == 0. ) THEN
+               fmask(ji,jpj,jk) = rn_shlat * MIN( 1., MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
+            ENDIF
+         END DO
+      END DO
+      !
+      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA_R2 configuration
+         !                                                 ! Increased lateral friction near of some straits
+         IF( n_cla == 0 ) THEN
+            !                                ! Gibraltar strait  : partial slip (fmask=0.5)
+            ij0 = 101   ;   ij1 = 101
+            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5e0
+            ij0 = 102   ;   ij1 = 102
+            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5e0
+            !
+            !                                ! Bab el Mandeb : partial slip (fmask=1)
+            ij0 =  87   ;   ij1 =  88
+            ii0 = 160   ;   ii1 = 160   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1.e0
+            ij0 =  88   ;   ij1 =  88
+            ii0 = 159   ;   ii1 = 159   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1.e0
+            !
+         ENDIF
+
+         !                                ! Danish straits  : strong slip (fmask > 2)
+! We keep this as an example but it is instable in this case 
+!         ij0 = 115   ;   ij1 = 115
+!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4.0e0
+!         ij0 = 116   ;   ij1 = 116
+!         ii0 = 145   ;   ii1 = 146   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 4.0e0
+         !
+      ENDIF
+      !
+      CALL lbc_lnk( fmask, 'F', 1. )      ! Lateral boundary conditions on fmask
+
+      
+      ! Mbathy set to the number of w-level (minimum value 2)
+      ! -----------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            mbathy(ji,jj) = MAX( 1, mbathy(ji,jj) ) + 1
+         END DO
+      END DO
+      
+      IF( nprint == 1 .AND. lwp ) THEN      ! Control print
+         imsk(:,:) = INT( tmask_i(:,:) )
+         WRITE(numout,*) ' tmask_i : '
+         CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                           1, jpj, 1, 1, numout)
+         WRITE (numout,*)
+         WRITE (numout,*) ' dommsk: tmask for each level'
+         WRITE (numout,*) ' ----------------------------'
+         DO jk = 1, jpk
+            imsk(:,:) = INT( tmask(:,:,jk) )
+
+            WRITE(numout,*)
+            WRITE(numout,*) ' level = ',jk
+            CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                              1, jpj, 1, 1, numout)
+         END DO
+         WRITE(numout,*)
+         WRITE(numout,*) ' dom_msk: vmask for each level'
+         WRITE(numout,*) ' -----------------------------'
+         DO jk = 1, jpk
+            imsk(:,:) = INT( vmask(:,:,jk) )
+            WRITE(numout,*)
+            WRITE(numout,*) ' level = ',jk
+            CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                              1, jpj, 1, 1, numout)
+         END DO
+         WRITE(numout,*)
+         WRITE(numout,*) ' dom_msk: fmask for each level'
+         WRITE(numout,*) ' -----------------------------'
+         DO jk = 1, jpk
+            imsk(:,:) = INT( fmask(:,:,jk) )
+            WRITE(numout,*)
+            WRITE(numout,*) ' level = ',jk
+            CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                              1, jpj, 1, 1, numout )
+         END DO
+         WRITE(numout,*)
+         WRITE(numout,*) ' dom_msk: bmask '
+         WRITE(numout,*) ' ---------------'
+         WRITE(numout,*)
+         imsk(:,:) = INT( bmask(:,:) )
+         CALL prihin( imsk(:,:), jpi, jpj, 1, jpi, 1,   &
+               &                           1, jpj, 1, 1, numout )
+      ENDIF
+      !
+   END SUBROUTINE dom_msk
+
+#if defined key_noslip_accurate
+   !!----------------------------------------------------------------------
+   !!   'key_noslip_accurate' :         accurate no-slip boundary condition
+   !!----------------------------------------------------------------------
+   
+   SUBROUTINE dom_msk_nsa
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dom_msk_nsa  ***
+      !! 
+      !! ** Purpose :
+      !!
+      !! ** Method  :
+      !!
+      !! ** Action :
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk, jl      ! dummy loop indices
+      INTEGER  ::   ine, inw, ins, inn, itest, ierror, iind, ijnd
+      REAL(wp) ::   zaa
+      INTEGER, DIMENSION(jpi*jpj*jpk,3) ::  icoord
+      !!---------------------------------------------------------------------
+      
+
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
+      IF(lwp)WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
+      IF( lk_mpp ) CALL ctl_stop( ' mpp version is not yet implemented' )
+
+      ! mask for second order calculation of vorticity
+      ! ----------------------------------------------
+      ! noslip boundary condition: fmask=1  at convex corner, store
+      ! index of straight coast meshes ( 'west', refering to a coast,
+      ! means west of the ocean, aso)
+      
+      DO jk = 1, jpk
+         DO jl = 1, 4
+            npcoa(jl,jk) = 0
+            DO ji = 1, 2*(jpi+jpj)
+               nicoa(ji,jl,jk) = 0
+               njcoa(ji,jl,jk) = 0
+            END DO
+         END DO
+      END DO
+      
+      IF( jperio == 2 ) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' symetric boundary conditions need special'
+         WRITE(numout,*) ' treatment not implemented. we stop.'
+         STOP
+      ENDIF
+      
+      ! convex corners
+      
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zaa = tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
+                  &+ tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
+               IF( ABS(zaa-3.) <= 0.1 )   fmask(ji,jj,jk) = 1.
+            END DO
+         END DO
+      END DO
+
+      ! north-south straight coast
+
+      DO jk = 1, jpkm1
+         inw = 0
+         ine = 0
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zaa = tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
+               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+                  inw = inw + 1
+                  nicoa(inw,1,jk) = ji
+                  njcoa(inw,1,jk) = jj
+                  IF( nprint == 1 ) WRITE(numout,*) ' west  : ', jk, inw, ji, jj
+               ENDIF
+               zaa = tmask(ji,jj,jk) + tmask(ji,jj+1,jk)
+               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+                  ine = ine + 1
+                  nicoa(ine,2,jk) = ji
+                  njcoa(ine,2,jk) = jj
+                  IF( nprint == 1 ) WRITE(numout,*) ' east  : ', jk, ine, ji, jj
+               ENDIF
+            END DO
+         END DO
+         npcoa(1,jk) = inw
+         npcoa(2,jk) = ine
+      END DO
+
+      ! west-east straight coast
+
+      DO jk = 1, jpkm1
+         ins = 0
+         inn = 0
+         DO jj = 2, jpjm1
+            DO ji =2, jpim1
+               zaa = tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk)
+               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+                  ins = ins + 1
+                  nicoa(ins,3,jk) = ji
+                  njcoa(ins,3,jk) = jj
+                  IF( nprint == 1 ) WRITE(numout,*) ' south : ', jk, ins, ji, jj
+               ENDIF
+               zaa = tmask(ji+1,jj,jk) + tmask(ji,jj,jk)
+               IF( ABS(zaa-2.) <= 0.1 .AND. fmask(ji,jj,jk) == 0 ) THEN
+                  inn = inn + 1
+                  nicoa(inn,4,jk) = ji
+                  njcoa(inn,4,jk) = jj
+                  IF( nprint == 1 ) WRITE(numout,*) ' north : ', jk, inn, ji, jj
+               ENDIF
+            END DO
+         END DO
+         npcoa(3,jk) = ins
+         npcoa(4,jk) = inn
+      END DO
+
+      itest = 2 * ( jpi + jpj )
+      DO jk = 1, jpk
+         IF( npcoa(1,jk) > itest .OR. npcoa(2,jk) > itest .OR.   &
+             npcoa(3,jk) > itest .OR. npcoa(4,jk) > itest ) THEN
+            
+            WRITE(ctmp1,*) ' level jk = ',jk
+            WRITE(ctmp2,*) ' straight coast index arraies are too small.:'
+            WRITE(ctmp3,*) ' npe, npw, nps, npn = ', npcoa(1,jk), npcoa(2,jk),   &
+                &                                     npcoa(3,jk), npcoa(4,jk)
+            WRITE(ctmp4,*) ' 2*(jpi+jpj) = ',itest,'. we stop.'
+            CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4 )
+        ENDIF
+      END DO
+
+      ierror = 0
+      iind = 0
+      ijnd = 0
+      IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) iind = 2
+      IF( nperio == 3 .OR. nperio == 4 .OR. nperio == 5 .OR. nperio == 6 ) ijnd = 2
+      DO jk = 1, jpk
+         DO jl = 1, npcoa(1,jk)
+            IF( nicoa(jl,1,jk)+3 > jpi+iind ) THEN
+               ierror = ierror+1
+               icoord(ierror,1) = nicoa(jl,1,jk)
+               icoord(ierror,2) = njcoa(jl,1,jk)
+               icoord(ierror,3) = jk
+            ENDIF
+         END DO
+         DO jl = 1, npcoa(2,jk)
+            IF(nicoa(jl,2,jk)-2 < 1-iind ) THEN
+               ierror = ierror + 1
+               icoord(ierror,1) = nicoa(jl,2,jk)
+               icoord(ierror,2) = njcoa(jl,2,jk)
+               icoord(ierror,3) = jk
+            ENDIF
+         END DO
+         DO jl = 1, npcoa(3,jk)
+            IF( njcoa(jl,3,jk)+3 > jpj+ijnd ) THEN
+               ierror = ierror + 1
+               icoord(ierror,1) = nicoa(jl,3,jk)
+               icoord(ierror,2) = njcoa(jl,3,jk)
+               icoord(ierror,3) = jk
+            ENDIF
+         END DO
+         DO jl=1,npcoa(4,jk)
+            IF( njcoa(jl,4,jk)-2 < 1) THEN
+               ierror=ierror+1
+               icoord(ierror,1)=nicoa(jl,4,jk)
+               icoord(ierror,2)=njcoa(jl,4,jk)
+               icoord(ierror,3)=jk
+            ENDIF
+         END DO
+      END DO
+      
+      IF( ierror > 0 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '              Problem on lateral conditions'
+         IF(lwp) WRITE(numout,*) '                 Bad marking off at points:'
+         DO jl = 1, ierror
+            IF(lwp) WRITE(numout,*) 'Level:',icoord(jl,3),   &
+               &                  '  Point(',icoord(jl,1),',',icoord(jl,2),')'
+         END DO
+         CALL ctl_stop( 'We stop...' )
+      ENDIF
+
+   END SUBROUTINE dom_msk_nsa
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                      Empty routine
+   !!----------------------------------------------------------------------
+   SUBROUTINE dom_msk_nsa       
+   END SUBROUTINE dom_msk_nsa
+#endif
+   
+   !!======================================================================
+END MODULE dommsk
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domngb.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domngb.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domngb.F90	(revision 1844)
@@ -0,0 +1,76 @@
+MODULE domngb
+   !!======================================================================
+   !!                       ***  MODULE  domngb  ***
+   !! Grid search:  find the closest grid point from a given on/lat position
+   !!======================================================================
+   !! History : 3.2  !  2009-11  (S. Masson)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_ngb       : find the closest grid point from a given on/lat position
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE lib_mpp         ! for mppsum
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_ngb    ! routine called in iom.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_ngb( plon, plat, kii, kjj, cdgrid )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dom_ngb  ***
+      !!
+      !! ** Purpose :   find the closest grid point from a given on/lat position
+      !!
+      !! ** Method  :   look for minimum distance in cylindrical projection 
+      !!                -> not good if located at too high latitude...
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp)        , INTENT(in   ) ::   plon, plat   ! longitude,latitude of the point
+      INTEGER         , INTENT(  out) ::   kii, kjj     ! i-,j-index of the closes grid point
+      CHARACTER(len=1), INTENT(in   ) ::   cdgrid       ! grid name 'T', 'U', 'V', 'W'
+      !!
+      INTEGER , DIMENSION(2)        ::   iloc
+      REAL(wp), DIMENSION(jpi,jpj)  ::   zglam, zgphi, zmask, zdist
+      REAL(wp)                      ::   zlon
+      REAL(wp)                      ::   zmini
+      !!--------------------------------------------------------------------
+      
+      zmask(:,:) = 0.
+      SELECT CASE( cdgrid )
+      CASE( 'U' )  ; zglam(:,:) = glamu(:,:) ; zgphi(:,:) = gphiu(:,:) ; zmask(nldi:nlei,nldj:nlej) = umask(nldi:nlei,nldj:nlej,1)
+      CASE( 'V' )  ; zglam(:,:) = glamv(:,:) ; zgphi(:,:) = gphiv(:,:) ; zmask(nldi:nlei,nldj:nlej) = vmask(nldi:nlei,nldj:nlej,1)
+      CASE( 'F' )  ; zglam(:,:) = glamf(:,:) ; zgphi(:,:) = gphif(:,:) ; zmask(nldi:nlei,nldj:nlej) = fmask(nldi:nlei,nldj:nlej,1)
+      CASE DEFAULT ; zglam(:,:) = glamt(:,:) ; zgphi(:,:) = gphit(:,:) ; zmask(nldi:nlei,nldj:nlej) = tmask(nldi:nlei,nldj:nlej,1)
+      END SELECT
+
+      zlon       = MOD( plon       + 720., 360. )                                     ! plon between    0 and 360
+      zglam(:,:) = MOD( zglam(:,:) + 720., 360. )                                     ! glam between    0 and 360
+      IF( zlon > 270. )   zlon = zlon - 360.                                          ! zlon between  -90 and 270
+      IF( zlon <  90. )   WHERE( zglam(:,:) > 180. ) zglam(:,:) = zglam(:,:) - 360.   ! glam between -180 and 180
+
+      zglam(:,:) = zglam(:,:) - zlon
+      zgphi(:,:) = zgphi(:,:) - plat
+      zdist(:,:) = zglam(:,:) * zglam(:,:) + zgphi(:,:) * zgphi(:,:)
+      
+      IF( lk_mpp ) THEN  
+         CALL mpp_minloc( zdist(:,:), zmask, zmini, kii, kjj)
+      ELSE
+         iloc(:) = MINLOC( zdist(:,:), mask = zmask(:,:) == 1.e0 )
+         kii = iloc(1) + nimpp - 1
+         kjj = iloc(2) + njmpp - 1
+      ENDIF
+
+   END SUBROUTINE dom_ngb
+
+   !!======================================================================
+END MODULE domngb
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domstp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domstp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domstp.F90	(revision 1844)
@@ -0,0 +1,115 @@
+MODULE domstp
+   !!==============================================================================
+   !!                       ***  MODULE domstp   ***
+   !! Ocean initialization : time domain
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_stp        : ocean time domain initialization
+   !!----------------------------------------------------------------------
+   !! History :
+   !!        !  90-10  (O. Marti)  Original code
+   !!        !  96-01  (G. Madec)  terrain following coordinates
+   !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * routine accessibility
+   PUBLIC dom_stp        ! routine called by inidom.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_stp
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dom_stp  ***
+      !!          
+      !! ** Purpose :   Intialize ocean time step for the run
+      !!
+      !! ** Method  : - Initialization of a coef. use in the Asselin time
+      !!      filter:  atfp1 = 1 - 2 * atfp  where atfp is the Asselin time
+      !!      filter parameter read in namelist
+      !!              - Model time step:
+      !!      nacc = 0 : synchronous time intergration. 
+      !!      There is one time step only, defined by: rdt, rdttra(k)=rdt
+      !!      nacc = 1 : accelerating the convergence. There is 2 different
+      !!      time steps for dynamics and tracers:
+      !!        rdt      : dynamical part
+      !!        rdttra(k): temperature and salinity
+      !!      The tracer time step is a function of vertical level. the model
+      !!      reference time step ( i.e. for wind stress, surface heat and
+      !!      salt fluxes) is the surface tracer time step is rdttra(1).
+      !!         N.B. depth dependent acceleration of convergence is not im-
+      !!      plemented for s-coordinate.
+      !!
+      !! ** Action  : - rdttra   : vertical profile of tracer time step
+      !!              - atfp1    : = 1 - 2*atfp
+      !!
+      !! References :
+      !!      Bryan, K., 1984, J. Phys. Oceanogr., 14, 666-673.
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk              ! dummy loop indice
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_stp : time stepping setting'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! 0. Asselin Time filter
+      ! ----------------------
+      
+      atfp1 = 1. - 2. * atfp
+
+      SELECT CASE ( nacc )
+
+         CASE ( 0 )                ! Synchronous time stepping
+            IF(lwp) WRITE(numout,*)'               synchronous time stepping'
+            IF(lwp) WRITE(numout,*)'               dynamics and tracer time step = ', rdt/3600., ' hours'
+
+            rdttra(:) = rdt
+
+         CASE ( 1 )                ! Accelerating the convergence
+            IF(lwp) WRITE(numout,*) '              no tracer damping in the turbocline'
+            IF(lwp) WRITE(numout,*)'               accelerating the convergence'
+            IF(lwp) WRITE(numout,*)'               dynamics time step = ', rdt/3600., ' hours'
+            IF( ln_sco .AND. rdtmin /= rdtmax .AND. lk_vvl )   &
+                 & CALL ctl_stop ( ' depth dependent acceleration of convergence not implemented in s-coordinates &
+                 &                   nor in variable volume' )
+            IF(lwp) WRITE(numout,*)'         tracers   time step :  dt (hours)  level'
+
+            DO jk = 1, jpk
+               IF( gdept_0(jk) <= rdth ) rdttra(jk) = rdtmin
+               IF( gdept_0(jk) >  rdth ) THEN
+                  rdttra(jk) = rdtmin + ( rdtmax - rdtmin )   &
+                                      * ( EXP( ( gdept_0(jk ) - rdth ) / rdth ) - 1. )   &
+                                      / ( EXP( ( gdept_0(jpk) - rdth ) / rdth ) - 1. )
+               ENDIF
+               IF(lwp) WRITE(numout,"(36x,f5.2,5x,i3)") rdttra(jk)/3600., jk
+            END DO  
+
+         CASE DEFAULT              ! E R R O R 
+
+            WRITE(ctmp1,*) ' nacc value e r r o r, nacc= ',nacc
+            CALL ctl_stop( ctmp1 )
+
+      END SELECT
+
+   END SUBROUTINE dom_stp
+
+   !!======================================================================
+END MODULE domstp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 1844)
@@ -0,0 +1,153 @@
+MODULE domvvl
+   !!======================================================================
+   !!                       ***  MODULE domvvl   ***
+   !! Ocean : 
+   !!======================================================================
+   !! History :  2.0  !  2006-06  (B. Levier, L. Marie)  original code
+   !!            3.1  !  2009-02  (G. Madec, M. Leclair, R. Benshila)  pure z* coordinate
+   !!----------------------------------------------------------------------
+#if defined key_vvl
+   !!----------------------------------------------------------------------
+   !!   'key_vvl'                              variable volume
+   !!----------------------------------------------------------------------
+   !!   dom_vvl     : defined coefficients to distribute ssh on each layers
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_vvl    ! called by domain.F90
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ee_t, ee_u, ee_v, ee_f   !: ???
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   mut, muu, muv, muf       !: ??? 
+
+   REAL(wp), DIMENSION(jpk) ::   r2dt   ! vertical profile time-step, = 2 rdttra 
+      !                                 ! except at nit000 (=rdttra) if neuler=0
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS       
+
+   SUBROUTINE dom_vvl
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE dom_vvl  ***
+      !!                   
+      !! ** Purpose :  compute coefficients muX at T-U-V-F points to spread
+      !!               ssh over the whole water column (scale factors)
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zcoefu, zcoefv, zcoeff
+      !!----------------------------------------------------------------------
+
+      IF(lwp)   THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_vvl : Variable volume activated'
+         WRITE(numout,*) '~~~~~~~~  compute coef. used to spread ssh over each layers'
+      ENDIF
+
+      IF( lk_zco )   CALL ctl_stop( 'dom_vvl : key_zco is incompatible with variable volume option key_vvl')
+
+      fsdept(:,:,:) = gdept (:,:,:)
+      fsdepw(:,:,:) = gdepw (:,:,:)
+      fsde3w(:,:,:) = gdep3w(:,:,:)
+      fse3t (:,:,:) = e3t   (:,:,:)
+      fse3u (:,:,:) = e3u   (:,:,:)
+      fse3v (:,:,:) = e3v   (:,:,:)
+      fse3f (:,:,:) = e3f   (:,:,:)
+      fse3w (:,:,:) = e3w   (:,:,:)
+      fse3uw(:,:,:) = e3uw  (:,:,:)
+      fse3vw(:,:,:) = e3vw  (:,:,:)
+
+      !                                 !==  mu computation  ==!
+      ee_t(:,:) = fse3t_0(:,:,1)                ! Lower bound : thickness of the first model level
+      ee_u(:,:) = fse3u_0(:,:,1)
+      ee_v(:,:) = fse3v_0(:,:,1)
+      ee_f(:,:) = fse3f_0(:,:,1)
+      DO jk = 2, jpkm1                          ! Sum of the masked vertical scale factors
+         ee_t(:,:) = ee_t(:,:) + fse3t_0(:,:,jk) * tmask(:,:,jk)
+         ee_u(:,:) = ee_u(:,:) + fse3u_0(:,:,jk) * umask(:,:,jk)
+         ee_v(:,:) = ee_v(:,:) + fse3v_0(:,:,jk) * vmask(:,:,jk)
+         DO jj = 1, jpjm1                      ! f-point : fmask=shlat at coasts, use the product of umask
+            ee_f(:,jj) = ee_f(:,jj) + fse3f_0(:,jj,jk) *  umask(:,jj,jk) * umask(:,jj+1,jk)
+         END DO
+      END DO  
+      !                                         ! Compute and mask the inverse of the local depth at T, U, V and F points
+      ee_t(:,:) = 1. / ee_t(:,:) * tmask(:,:,1)
+      ee_u(:,:) = 1. / ee_u(:,:) * umask(:,:,1)
+      ee_v(:,:) = 1. / ee_v(:,:) * vmask(:,:,1)
+      DO jj = 1, jpjm1                               ! f-point case fmask cannot be used 
+         ee_f(:,jj) = 1. / ee_f(:,jj) * umask(:,jj,1) * umask(:,jj+1,1)
+      END DO
+      CALL lbc_lnk( ee_f, 'F', 1. )                  ! lateral boundary condition on ee_f
+      !
+      DO jk = 1, jpk                            ! mu coefficients
+         mut(:,:,jk) = ee_t(:,:) * tmask(:,:,jk)     ! T-point at T levels
+         muu(:,:,jk) = ee_u(:,:) * umask(:,:,jk)     ! U-point at T levels
+         muv(:,:,jk) = ee_v(:,:) * vmask(:,:,jk)     ! V-point at T levels
+      END DO
+      DO jk = 1, jpk                                 ! F-point : fmask=shlat at coasts, use the product of umask
+         DO jj = 1, jpjm1
+               muf(:,jj,jk) = ee_f(:,jj) * umask(:,jj,jk) * umask(:,jj+1,jk)   ! at T levels
+         END DO
+         muf(:,jpj,jk) = 0.e0
+      END DO
+      CALL lbc_lnk( muf, 'F', 1. )                   ! lateral boundary condition
+
+
+      hu_0(:,:) = 0.e0                          ! Reference ocean depth at U- and V-points
+      hv_0(:,:) = 0.e0
+      DO jk = 1, jpk
+         hu_0(:,:) = hu_0(:,:) + fse3u_0(:,:,jk) * umask(:,:,jk)
+         hv_0(:,:) = hv_0(:,:) + fse3v_0(:,:,jk) * vmask(:,:,jk)
+      END DO
+
+      DO jj = 1, jpjm1                          ! initialise before and now Sea Surface Height at u-, v-, f-points
+         DO ji = 1, jpim1   ! NO vector opt.
+            zcoefu = 0.5  * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )
+            zcoefv = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )
+            zcoeff = 0.25 * umask(ji,jj,1) * umask(ji,jj+1,1)
+            sshu_b(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshb(ji  ,jj)     &
+               &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshb(ji+1,jj) )   
+            sshv_b(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshb(ji,jj  )     &
+               &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshb(ji,jj+1) )   
+            sshf_b(ji,jj) = zcoeff * ( sshb(ji  ,jj) + sshb(ji  ,jj+1)                 &
+               &                     + sshb(ji+1,jj) + sshb(ji+1,jj+1) )               
+            sshu_n(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshn(ji  ,jj)     &
+               &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshn(ji+1,jj) )   
+            sshv_n(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshn(ji,jj  )     & 
+               &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshn(ji,jj+1) )     
+            sshf_n(ji,jj) = zcoeff * ( sshn(ji  ,jj) + sshn(ji  ,jj+1)                 &
+               &                     + sshn(ji+1,jj) + sshn(ji+1,jj+1) )               
+         END DO
+      END DO
+      CALL lbc_lnk( sshu_b, 'U', 1. )   ;   CALL lbc_lnk( sshu_n, 'U', 1. )      ! lateral boundary conditions
+      CALL lbc_lnk( sshv_b, 'V', 1. )   ;   CALL lbc_lnk( sshv_n, 'V', 1. )
+      CALL lbc_lnk( sshf_b, 'F', 1. )   ;   CALL lbc_lnk( sshf_n, 'F', 1. )
+      !
+   END SUBROUTINE dom_vvl
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                      Empty routine
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dom_vvl
+   END SUBROUTINE dom_vvl
+#endif
+
+   !!======================================================================
+END MODULE domvvl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domwri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domwri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domwri.F90	(revision 1844)
@@ -0,0 +1,295 @@
+MODULE domwri
+   !!======================================================================
+   !!                       ***  MODULE domwri  ***
+   !! Ocean initialization : write the ocean domain mesh ask file(s)
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dom_wri        : create and write mesh and mask file(s)
+   !!                    nmsh = 1  :   mesh_mask file
+   !!                         = 2  :   mesh and mask file
+   !!                         = 3  :   mesh_hgr, mesh_zgr and mask
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager
+   USE iom
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dom_wri        ! routine called by inidom.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dom_wri
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_wri  ***
+      !!                   
+      !! ** Purpose :   Create the NetCDF file(s) which contain(s) all the
+      !!      ocean domain informations (mesh and mask arrays). This (these)
+      !!      file(s) is (are) used for visualisation (SAXO software) and
+      !!      diagnostic computation.
+      !!
+      !! ** Method  :   Write in a file all the arrays generated in routines
+      !!      domhgr, domzgr, and dommsk. Note: the file contain depends on
+      !!      the vertical coord. used (z-coord, partial steps, s-coord)
+      !!                    nmsh = 1  :   'mesh_mask.nc' file
+      !!                         = 2  :   'mesh.nc' and mask.nc' files
+      !!                         = 3  :   'mesh_hgr.nc', 'mesh_zgr.nc' and
+      !!                                  'mask.nc' files
+      !!      For huge size domain, use option 2 or 3 depending on your 
+      !!      vertical coordinate.
+      !!
+      !! ** output file : 
+      !!      meshmask.nc  : domain size, horizontal grid-point position,
+      !!                     masks, depth and vertical scale factors
+      !!
+      !! History :
+      !!        !  97-02  (G. Madec)  Original code
+      !!        !  99-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
+      !!   9.0  !  02-08  (G. Madec)  F90 and several file
+      !!----------------------------------------------------------------------
+      INTEGER                          ::   inum0    ! temprary units for 'mesh_mask.nc' file
+      INTEGER                          ::   inum1    ! temprary units for 'mesh.nc'      file
+      INTEGER                          ::   inum2    ! temprary units for 'mask.nc'      file
+      INTEGER                          ::   inum3    ! temprary units for 'mesh_hgr.nc'  file
+      INTEGER                          ::   inum4    ! temprary units for 'mesh_zgr.nc'  file
+      INTEGER                          ::   ji, jj, jk, ik
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zprt     ! temporary array for bathymetry 
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepu    ! 3D depth of U point
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepv    ! 3D depth of V point
+      CHARACTER(len=21)                ::   clnam0   ! filename (mesh and mask informations)
+      CHARACTER(len=21)                ::   clnam1   ! filename (mesh informations)
+      CHARACTER(len=21)                ::   clnam2   ! filename (mask informations)
+      CHARACTER(len=21)                ::   clnam3   ! filename (horizontal mesh informations)
+      CHARACTER(len=21)                ::   clnam4   ! filename (vertical   mesh informations)
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dom_wri : create NetCDF mesh and mask information file(s)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+      
+      clnam0 = 'mesh_mask'  ! filename (mesh and mask informations)
+      clnam1 = 'mesh'       ! filename (mesh informations)
+      clnam2 = 'mask'       ! filename (mask informations)
+      clnam3 = 'mesh_hgr'   ! filename (horizontal mesh informations)
+      clnam4 = 'mesh_zgr'   ! filename (vertical   mesh informations)
+      
+      SELECT CASE ( MOD(nmsh, 3) )
+         !                                  ! ============================
+      CASE ( 1 )                            !  create 'mesh_mask.nc' file
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam0), inum0, ldwrt = .TRUE., kiolib = jprstlib )
+         inum2 = inum0                                            ! put all the informations
+         inum3 = inum0                                            ! in unit inum0
+         inum4 = inum0
+         
+         !                                  ! ============================
+      CASE ( 2 )                            !  create 'mesh.nc' and 
+         !                                  !         'mask.nc' files
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam1), inum1, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam2), inum2, ldwrt = .TRUE., kiolib = jprstlib )
+         inum3 = inum1                                            ! put mesh informations 
+         inum4 = inum1                                            ! in unit inum1 
+         !                                  ! ============================
+      CASE ( 0 )                            !  create 'mesh_hgr.nc'
+         !                                  !         'mesh_zgr.nc' and
+         !                                  !         'mask.nc'     files
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam2), inum2, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam3), inum3, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam4), inum4, ldwrt = .TRUE., kiolib = jprstlib )
+         
+      END SELECT
+      
+      !                                                         ! masks (inum2) 
+      CALL iom_rstput( 0, 0, inum2, 'tmask', tmask, ktype = jp_i1 )     !    ! land-sea mask
+      CALL iom_rstput( 0, 0, inum2, 'umask', umask, ktype = jp_i1 )
+      CALL iom_rstput( 0, 0, inum2, 'vmask', vmask, ktype = jp_i1 )
+      CALL iom_rstput( 0, 0, inum2, 'fmask', fmask, ktype = jp_i1 )
+      
+      
+      zprt = tmask(:,:,1) * dom_uniq('T')                               !    ! unique point mask
+      CALL iom_rstput( 0, 0, inum2, 'tmaskutil', zprt, ktype = jp_i1 )  
+      zprt = umask(:,:,1) * dom_uniq('U')
+      CALL iom_rstput( 0, 0, inum2, 'umaskutil', zprt, ktype = jp_i1 )  
+      zprt = vmask(:,:,1) * dom_uniq('V')
+      CALL iom_rstput( 0, 0, inum2, 'vmaskutil', zprt, ktype = jp_i1 )  
+      zprt = fmask(:,:,1) * dom_uniq('F')
+      CALL iom_rstput( 0, 0, inum2, 'fmaskutil', zprt, ktype = jp_i1 )  
+
+      !                                                         ! horizontal mesh (inum3)
+      CALL iom_rstput( 0, 0, inum3, 'glamt', glamt, ktype = jp_r4 )     !    ! latitude
+      CALL iom_rstput( 0, 0, inum3, 'glamu', glamu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'glamv', glamv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'glamf', glamf, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'gphit', gphit, ktype = jp_r4 )     !    ! longitude
+      CALL iom_rstput( 0, 0, inum3, 'gphiu', gphiu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'gphiv', gphiv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'gphif', gphif, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'e1t', e1t, ktype = jp_r8 )         !    ! e1 scale factors
+      CALL iom_rstput( 0, 0, inum3, 'e1u', e1u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e1v', e1v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e1f', e1f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'e2t', e2t, ktype = jp_r8 )         !    ! e2 scale factors
+      CALL iom_rstput( 0, 0, inum3, 'e2u', e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e2v', e2v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e2f', e2f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'ff', ff, ktype = jp_r8 )           !    ! coriolis factor
+      
+!       note that mbathy has been modified in dommsk or in solver.
+!       it is the number of non-zero "w" levels in the water, and the minimum 
+!       value (on land) is 2. We define zprt as the number of "T" points in the ocean 
+!       at any location, and zero on land. 
+!
+      zprt = tmask(:,:,1)*(mbathy-1)
+      CALL iom_rstput( 0, 0, inum4, 'mbathy', zprt, ktype = jp_i2 )
+            
+#if ! defined key_zco
+      IF( ln_sco ) THEN                                         ! s-coordinate
+         CALL iom_rstput( 0, 0, inum4, 'hbatt', hbatt )         !    ! depth
+         CALL iom_rstput( 0, 0, inum4, 'hbatu', hbatu ) 
+         CALL iom_rstput( 0, 0, inum4, 'hbatv', hbatv )
+         CALL iom_rstput( 0, 0, inum4, 'hbatf', hbatf )
+         
+         CALL iom_rstput( 0, 0, inum4, 'gsigt', gsigt )         !    ! scaling coef.
+         CALL iom_rstput( 0, 0, inum4, 'gsigw', gsigw )  
+         CALL iom_rstput( 0, 0, inum4, 'gsi3w', gsi3w )
+         CALL iom_rstput( 0, 0, inum4, 'esigt', esigt )
+         CALL iom_rstput( 0, 0, inum4, 'esigw', esigw )
+         
+         CALL iom_rstput( 0, 0, inum4, 'e3t', e3t )             !    ! scale factors
+         CALL iom_rstput( 0, 0, inum4, 'e3u', e3u )
+         CALL iom_rstput( 0, 0, inum4, 'e3v', e3v )
+         CALL iom_rstput( 0, 0, inum4, 'e3w', e3w )
+         
+         CALL iom_rstput( 0, 0, inum4, 'gdept_0' , gdept_0 )    !    ! stretched system
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_0' , gdepw_0 )
+      ENDIF
+      
+      IF( ln_zps ) THEN                                         ! z-coordinate - partial steps
+
+         IF( nmsh <= 6 ) THEN                                   !    ! 3D vertical scale factors
+            CALL iom_rstput( 0, 0, inum4, 'e3t', e3t )         
+            CALL iom_rstput( 0, 0, inum4, 'e3u', e3u )
+            CALL iom_rstput( 0, 0, inum4, 'e3v', e3v )
+            CALL iom_rstput( 0, 0, inum4, 'e3w', e3w )
+         ELSE                                                   !    ! 2D bottom scale factors
+            DO jj = 1,jpj   ;   DO ji = 1,jpi
+               ik = NINT( zprt(ji,jj) )   ! take care that mbathy is not what you think it is here !
+               IF ( ik /= 0 ) THEN   ;   e3tp(ji,jj) = e3t(ji,jj,ik)   ;   e3wp(ji,jj) = e3w(ji,jj,ik)
+               ELSE                  ;   e3tp(ji,jj) = 0.              ;   e3wp(ji,jj) = 0.
+               ENDIF
+            END DO   ;   END DO
+            CALL iom_rstput( 0, 0, inum4, 'e3t_ps', e3tp )      
+            CALL iom_rstput( 0, 0, inum4, 'e3w_ps', e3wp )
+         END IF
+
+         IF( nmsh <= 3 ) THEN                                   !    ! 3D depth
+            CALL iom_rstput( 0, 0, inum4, 'gdept', gdept, ktype = jp_r4 )     
+            DO jk = 1,jpk   ;   DO jj = 1, jpjm1   ;   DO ji = 1, fs_jpim1   ! vector opt.
+               zdepu(ji,jj,jk) = MIN( gdept(ji,jj,jk), gdept(ji+1,jj  ,jk) )
+               zdepv(ji,jj,jk) = MIN( gdept(ji,jj,jk), gdept(ji  ,jj+1,jk) )
+            END DO   ;   END DO   ;   END DO
+            CALL lbc_lnk( zdepu, 'U', 1. )   ;   CALL lbc_lnk( zdepv, 'V', 1. ) 
+            CALL iom_rstput( 0, 0, inum4, 'gdepu', zdepu, ktype = jp_r4 )
+            CALL iom_rstput( 0, 0, inum4, 'gdepv', zdepv, ktype = jp_r4 )
+            CALL iom_rstput( 0, 0, inum4, 'gdepw', gdepw, ktype = jp_r4 )
+         ELSE                                                   !    ! 2D bottom depth
+            DO jj = 1,jpj   ;   DO ji = 1,jpi
+               ik = NINT( zprt(ji,jj) )   ! take care that mbathy is not what you think it is here !
+               IF ( ik /= 0 ) THEN   ;   hdept(ji,jj) = gdept(ji,jj,ik)   ;   hdepw(ji,jj) = gdepw(ji,jj,ik+1)
+               ELSE                  ;   hdept(ji,jj) = 0.                ;   hdepw(ji,jj) = 0.
+               ENDIF
+            END DO   ;   END DO
+            CALL iom_rstput( 0, 0, inum4, 'hdept' , hdept, ktype = jp_r4 )     
+            CALL iom_rstput( 0, 0, inum4, 'hdepw' , hdepw, ktype = jp_r4 ) 
+         ENDIF
+
+         CALL iom_rstput( 0, 0, inum4, 'gdept_0', gdept_0 )     !    ! reference z-coord.
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_0', gdepw_0 )
+         CALL iom_rstput( 0, 0, inum4, 'e3t_0'  , e3t_0   )
+         CALL iom_rstput( 0, 0, inum4, 'e3w_0'  , e3w_0   )
+      ENDIF
+      
+#endif
+      
+      IF( ln_zco ) THEN
+         !                                                      ! z-coordinate - full steps
+         CALL iom_rstput( 0, 0, inum4, 'gdept_0', gdept_0 )     !    ! depth
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_0', gdepw_0 )
+         CALL iom_rstput( 0, 0, inum4, 'e3t_0'  , e3t_0   )     !    ! scale factors
+         CALL iom_rstput( 0, 0, inum4, 'e3w_0'  , e3w_0   )
+      ENDIF
+      !                                     ! ============================
+      !                                     !        close the files 
+      !                                     ! ============================
+      SELECT CASE ( nmsh )
+      CASE ( 1 )                
+         CALL iom_close( inum0 )
+      CASE ( 2 )
+         CALL iom_close( inum1 )
+         CALL iom_close( inum2 )
+      CASE ( 3 )
+         CALL iom_close( inum2 )
+         CALL iom_close( inum3 )
+         CALL iom_close( inum4 )
+      END SELECT
+      
+   END SUBROUTINE dom_wri
+
+
+   FUNCTION dom_uniq( cdgrd )   RESULT( puniq )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_uniq  ***
+      !!                   
+      !! ** Purpose :   identify unique point of a grid (TUVF)
+      !!
+      !! ** Method  :   1) aplly lbc_lnk on an array with different values for each element
+      !!                2) check which elements have been changed
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1)            , INTENT(in   ) ::  cdgrd   ! 
+      REAL(wp), DIMENSION(jpi,jpj)                ::  puniq   ! 
+
+      REAL(wp), DIMENSION(jpi,jpj  ) ::  ztstref   ! array with different values for each element 
+      REAL(wp)                       ::  zshift    ! shift value link to the process number
+      LOGICAL , DIMENSION(jpi,jpj,1) ::  lldbl     ! is the point unique or not?
+      INTEGER                        ::  ji        ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      ! build an array with different values for each element 
+      ! in mpp: make sure that these values are different even between process
+      ! -> apply a shift value according to the process number
+      zshift = jpi * jpj * ( narea - 1 )
+      ztstref(:,:) = RESHAPE( (/ (zshift + REAL(ji, wp), ji = 1, jpi*jpj) /), (/ jpi, jpj /) )
+   
+      puniq(:,:) = ztstref(:,:)                   ! default definition
+      CALL lbc_lnk( puniq, cdgrd, 1. )            ! apply boundary conditions
+      lldbl(:,:,1) = puniq(:,:) == ztstref(:,:)   ! check which values have been changed 
+      
+      puniq(:,:) = 1.                             ! default definition
+      ! fill only the inner part of the cpu with llbl converted into real 
+      puniq(nldi:nlei,nldj:nlej) = REAL(COUNT( lldbl(nldi:nlei,nldj:nlej,:), dim = 3 ), wp)
+
+   END FUNCTION dom_uniq
+
+
+   !!======================================================================
+END MODULE domwri
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 1844)
@@ -0,0 +1,1558 @@
+MODULE domzgr
+   !!==============================================================================
+   !!                       ***  MODULE domzgr   ***
+   !! Ocean initialization : domain initialization
+   !!==============================================================================
+   !! History :  OPA  ! 1995-12  (G. Madec)  Original code : s vertical coordinate
+   !!                 ! 1997-07  (G. Madec)  lbc_lnk call
+   !!                 ! 1997-04  (J.-O. Beismann) 
+   !!            8.5  ! 2002-09 (A. Bozec, G. Madec)  F90: Free form and module
+   !!             -   ! 2002-09 (A. de Miranda)  rigid-lid + islands
+   !!  NEMO      1.0  ! 2003-08  (G. Madec)  F90: Free form and module
+   !!             -   ! 2005-10  (A. Beckmann)  modifications for hybrid s-ccordinates & new stretching function
+   !!            2.0  ! 2006-04  (R. Benshila, G. Madec)  add zgr_zco
+   !!            3.0  ! 2008-06  (G. Madec)  insertion of domzgr_zps.h90 & conding style
+   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_zgr          : defined the ocean vertical coordinate system
+   !!       zgr_bat      : bathymetry fields (levels and meters)
+   !!       zgr_bat_zoom : modify the bathymetry field if zoom domain
+   !!       zgr_bat_ctl  : check the bathymetry files
+   !!       zgr_z        : reference z-coordinate 
+   !!       zgr_zco      : z-coordinate 
+   !!       zgr_zps      : z-coordinate with partial steps
+   !!       zgr_sco      : s-coordinate
+   !!       fssig        : sigma coordinate non-dimensional function
+   !!       dfssig       : derivative of the sigma coordinate function    !!gm  (currently missing!)
+   !!---------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE closea          ! closed seas
+   USE c1d             ! 1D configuration
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_zgr    ! called by dom_init.F90
+
+!!gm   DOCTOR name for the namelist parameter...
+   !                                    !!! ** Namelist namzgr_sco **
+   REAL(wp) ::   rn_sbot_min =  300.     ! minimum depth of s-bottom surface (>0) (m)
+   REAL(wp) ::   rn_sbot_max = 5250.     ! maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   REAL(wp) ::   rn_theta    =    6.0    ! surface control parameter (0<=rn_theta<=20)
+   REAL(wp) ::   rn_thetb    =    0.75   ! bottom control parameter  (0<=rn_thetb<= 1)
+   REAL(wp) ::   rn_rmax     =    0.15   ! maximum cut-off r-value allowed (0<rn_rmax<1)
+   LOGICAL  ::   ln_s_sigma  = .false.   ! use hybrid s-sigma -coordinate & stretching function fssig1 (ln_sco=T)
+   REAL(wp) ::   rn_bb       =    0.8    ! stretching parameter for song and haidvogel stretching
+   !                                     ! ( rn_bb=0; top only, rn_bb =1; top and bottom)
+   REAL(wp) ::   rn_hc       = 150.      ! Critical depth for s-sigma coordinates
+ 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS       
+
+   SUBROUTINE dom_zgr
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE dom_zgr  ***
+      !!                   
+      !! ** Purpose :  set the depth of model levels and the resulting 
+      !!      vertical scale factors.
+      !!
+      !! ** Method  : - reference 1D vertical coordinate (gdep._0, e3._0)
+      !!              - read/set ocean depth and ocean levels (bathy, mbathy)
+      !!              - vertical coordinate (gdep., e3.) depending on the 
+      !!                coordinate chosen :
+      !!                   ln_zco=T   z-coordinate   (forced if lk_zco)
+      !!                   ln_zps=T   z-coordinate with partial steps
+      !!                   ln_zco=T   s-coordinate 
+      !!
+      !! ** Action  :   define gdep., e3., mbathy and bathy
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio = 0   ! temporary integer
+      !!
+      NAMELIST/namzgr/ ln_zco, ln_zps, ln_sco
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )                ! Read Namelist namzgr : vertical coordinate'
+      READ   ( numnam, namzgr )
+
+      IF(lwp) THEN                     ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_zgr : vertical coordinate'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '          Namelist namzgr : set vertical coordinate'
+         WRITE(numout,*) '             z-coordinate - full steps      ln_zco = ', ln_zco
+         WRITE(numout,*) '             z-coordinate - partial steps   ln_zps = ', ln_zps
+         WRITE(numout,*) '             s- or hybrid z-s-coordinate    ln_sco = ', ln_sco
+      ENDIF
+
+      ioptio = 0                       ! Check Vertical coordinate options
+      IF( ln_zco ) ioptio = ioptio + 1
+      IF( ln_zps ) ioptio = ioptio + 1
+      IF( ln_sco ) ioptio = ioptio + 1
+      IF ( ioptio /= 1 )   CALL ctl_stop( ' none or several vertical coordinate options used' )
+      IF( lk_zco ) THEN
+          IF(lwp) WRITE(numout,*) '          z-coordinate with reduced incore memory requirement'
+          IF( ln_zps .OR. ln_sco )   CALL ctl_stop( ' reduced memory with zps or sco option is impossible' )
+      ENDIF
+
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+                     CALL zgr_z        ! Reference z-coordinate system (always called)
+                     CALL zgr_bat      ! Bathymetry fields (levels and meters)
+      IF( ln_zco )   CALL zgr_zco      ! z-coordinate
+      IF( ln_zps )   CALL zgr_zps      ! Partial step z-coordinate
+      IF( ln_sco )   CALL zgr_sco      ! s-coordinate or hybrid z-s coordinate
+
+!!bug gm control print:
+      IF( nprint == 1 .AND. lwp )   THEN
+         WRITE(numout,*) ' MIN val mbathy ', MINVAL( mbathy(:,:) ), ' MAX ', MAXVAL( mbathy(:,:) )
+         WRITE(numout,*) ' MIN val depth t ', MINVAL( fsdept(:,:,:) ),   &
+            &                   ' w ',   MINVAL( fsdepw(:,:,:) ), '3w ', MINVAL( fsde3w(:,:,:) )
+         WRITE(numout,*) ' MIN val e3    t ', MINVAL( fse3t(:,:,:) ), ' f ', MINVAL( fse3f(:,:,:) ),  &
+            &                   ' u ',   MINVAL( fse3u(:,:,:) ), ' u ', MINVAL( fse3v(:,:,:) ),  &
+            &                   ' uw',   MINVAL( fse3uw(:,:,:)), ' vw', MINVAL( fse3vw(:,:,:)),   &
+            &                   ' w ',   MINVAL( fse3w(:,:,:) )
+
+         WRITE(numout,*) ' MAX val depth t ', MAXVAL( fsdept(:,:,:) ),   &
+            &                   ' w ',   MAXVAL( fsdepw(:,:,:) ), '3w ', MAXVAL( fsde3w(:,:,:) )
+         WRITE(numout,*) ' MAX val e3    t ', MAXVAL( fse3t(:,:,:) ), ' f ', MAXVAL( fse3f(:,:,:) ),  &
+            &                   ' u ',   MAXVAL( fse3u(:,:,:) ), ' u ', MAXVAL( fse3v(:,:,:) ),  &
+            &                   ' uw',   MAXVAL( fse3uw(:,:,:)), ' vw', MAXVAL( fse3vw(:,:,:)),   &
+            &                   ' w ',   MAXVAL( fse3w(:,:,:) )
+      ENDIF
+!!!bug gm
+
+   END SUBROUTINE dom_zgr
+
+
+   SUBROUTINE zgr_z
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z  ***
+      !!                   
+      !! ** Purpose :   set the depth of model levels and the resulting 
+      !!      vertical scale factors.
+      !!
+      !! ** Method  :   z-coordinate system (use in all type of coordinate)
+      !!        The depth of model levels is defined from an analytical
+      !!      function the derivative of which gives the scale factors.
+      !!        both depth and scale factors only depend on k (1d arrays).
+      !!              w-level: gdepw_0  = fsdep(k)
+      !!                       e3w_0(k) = dk(fsdep)(k)     = fse3(k)
+      !!              t-level: gdept_0  = fsdep(k+0.5)
+      !!                       e3t_0(k) = dk(fsdep)(k+0.5) = fse3(k+0.5)
+      !!
+      !! ** Action  : - gdept_0, gdepw_0 : depth of T- and W-point (m)
+      !!              - e3t_0  , e3w_0   : scale factors at T- and W-levels (m)
+      !!
+      !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk                     ! dummy loop indices
+      REAL(wp) ::   zt, zw                 ! temporary scalars
+      REAL(wp) ::   zsur, za0, za1, zkth   ! Values set from parameters in
+      REAL(wp) ::   zacr, zdzmin, zhmax    ! par_CONFIG_Rxx.h90
+      REAL(wp) ::   zrefdep                ! depth of the reference level (~10m)
+      !!----------------------------------------------------------------------
+
+      ! Set variables from parameters
+      ! ------------------------------
+       zkth = ppkth       ;   zacr = ppacr
+       zdzmin = ppdzmin   ;   zhmax = pphmax
+
+      ! If ppa1 and ppa0 and ppsur are et to pp_to_be_computed
+      !  za0, za1, zsur are computed from ppdzmin , pphmax, ppkth, ppacr
+      !
+      IF(   ppa1  == pp_to_be_computed  .AND.  &
+         &  ppa0  == pp_to_be_computed  .AND.  &
+         &  ppsur == pp_to_be_computed           ) THEN
+         !
+         za1  = (  ppdzmin - pphmax / FLOAT(jpkm1)  )                                                      &
+            & / ( TANH((1-ppkth)/ppacr) - ppacr/FLOAT(jpk-1) * (  LOG( COSH( (jpk - ppkth) / ppacr) )      &
+            &                                                   - LOG( COSH( ( 1  - ppkth) / ppacr) )  )  )
+         za0  = ppdzmin - za1 *              TANH( (1-ppkth) / ppacr )
+         zsur =   - za0 - za1 * ppacr * LOG( COSH( (1-ppkth) / ppacr )  )
+      ELSE
+         za1 = ppa1 ;       za0 = ppa0 ;          zsur = ppsur
+      ENDIF
+
+      IF(lwp) THEN                         ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z   : Reference vertical z-coordinates'
+         WRITE(numout,*) '    ~~~~~~~'
+         IF(  ppkth == 0. ) THEN              
+              WRITE(numout,*) '            Uniform grid with ',jpk-1,' layers'
+              WRITE(numout,*) '            Total depth    :', zhmax
+              WRITE(numout,*) '            Layer thickness:', zhmax/(jpk-1)
+         ELSE
+            IF( ppa1 == 0. .AND. ppa0 == 0. .AND. ppsur == 0. ) THEN
+               WRITE(numout,*) '         zsur, za0, za1 computed from '
+               WRITE(numout,*) '                 zdzmin = ', zdzmin
+               WRITE(numout,*) '                 zhmax  = ', zhmax
+            ENDIF
+            WRITE(numout,*) '           Value of coefficients for vertical mesh:'
+            WRITE(numout,*) '                 zsur = ', zsur
+            WRITE(numout,*) '                 za0  = ', za0
+            WRITE(numout,*) '                 za1  = ', za1
+            WRITE(numout,*) '                 zkth = ', zkth
+            WRITE(numout,*) '                 zacr = ', zacr
+         ENDIF
+      ENDIF
+
+
+      ! Reference z-coordinate (depth - scale factor at T- and W-points)
+      ! ======================
+      IF( ppkth == 0.e0 ) THEN            !  uniform vertical grid       
+         za1 = zhmax / FLOAT(jpk-1) 
+         DO jk = 1, jpk
+            zw = FLOAT( jk )
+            zt = FLOAT( jk ) + 0.5
+            gdepw_0(jk) = ( zw - 1 ) * za1
+            gdept_0(jk) = ( zt - 1 ) * za1
+            e3w_0  (jk) =  za1
+            e3t_0  (jk) =  za1
+         END DO
+      ELSE                                ! Madec & Imbard 1996 function
+         DO jk = 1, jpk
+            zw = FLOAT( jk )
+            zt = FLOAT( jk ) + 0.5
+            gdepw_0(jk) = ( zsur + za0 * zw + za1 * zacr * LOG ( COSH( (zw-zkth) / zacr ) )  )
+            gdept_0(jk) = ( zsur + za0 * zt + za1 * zacr * LOG ( COSH( (zt-zkth) / zacr ) )  )
+            e3w_0  (jk) =          za0      + za1        * TANH(       (zw-zkth) / zacr   )
+            e3t_0  (jk) =          za0      + za1        * TANH(       (zt-zkth) / zacr   )
+         END DO
+         gdepw_0(1) = 0.e0                     ! force first w-level to be exactly at zero
+      ENDIF
+
+!!gm BUG in s-coordinate this does not work!
+      ! deepest/shallowest W level Above/Bellow ~10m
+      zrefdep = 10. - ( 0.1*MINVAL(e3w_0) )                          ! ref. depth with tolerance (10% of minimum layer thickness)
+      nlb10 = MINLOC( gdepw_0, mask = gdepw_0 > zrefdep, dim = 1 )   ! shallowest W level Bellow ~10m
+      nla10 = nlb10 - 1                                              ! deepest    W level Above  ~10m
+!!gm end bug
+
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level   gdept    gdepw     e3t      e3w  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, gdept_0(jk), gdepw_0(jk), e3t_0(jk), e3w_0(jk), jk = 1, jpk )
+      ENDIF
+      DO jk = 1, jpk                      ! control positivity
+         IF( e3w_0  (jk) <= 0.e0 .OR. e3t_0  (jk) <= 0.e0 )   CALL ctl_stop( ' e3w or e3t =< 0 '    )
+         IF( gdepw_0(jk) <  0.e0 .OR. gdept_0(jk) <  0.e0 )   CALL ctl_stop( ' gdepw or gdept < 0 ' )
+      END DO
+      !
+   END SUBROUTINE zgr_z
+
+
+   SUBROUTINE zgr_bat
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_bat  ***
+      !! 
+      !! ** Purpose :   set bathymetry both in levels and meters
+      !!
+      !! ** Method  :   read or define mbathy and bathy arrays
+      !!       * level bathymetry:
+      !!      The ocean basin geometry is given by a two-dimensional array,
+      !!      mbathy, which is defined as follow :
+      !!            mbathy(ji,jj) = 1, ..., jpk-1, the number of ocean level
+      !!                              at t-point (ji,jj).
+      !!                            = 0  over the continental t-point.
+      !!      The array mbathy is checked to verified its consistency with
+      !!      model option. in particular:
+      !!            mbathy must have at least 1 land grid-points (mbathy<=0)
+      !!                  along closed boundary.
+      !!            mbathy must be cyclic IF jperio=1.
+      !!            mbathy must be lower or equal to jpk-1.
+      !!            isolated ocean grid points are suppressed from mbathy
+      !!                  since they are only connected to remaining
+      !!                  ocean through vertical diffusion.
+      !!      ntopo=-1 :   rectangular channel or bassin with a bump 
+      !!      ntopo= 0 :   flat rectangular channel or basin 
+      !!      ntopo= 1 :   mbathy is read in 'bathy_level.nc' NetCDF file
+      !!                   bathy  is read in 'bathy_meter.nc' NetCDF file
+      !!      C A U T I O N : mbathy will be modified during the initializa-
+      !!      tion phase to become the number of non-zero w-levels of a water
+      !!      column, with a minimum value of 1.
+      !!
+      !! ** Action  : - mbathy: level bathymetry (in level index)
+      !!              - bathy : meter bathymetry (in meters)
+      !!----------------------------------------------------------------------
+      USE iom
+      !!
+      INTEGER  ::   ji, jj, jl, jk            ! dummy loop indices
+      INTEGER  ::   inum                      ! temporary logical unit
+      INTEGER  ::   ii_bump, ij_bump, ih      ! bump center position
+      INTEGER  ::   ii0, ii1, ij0, ij1        ! indices
+      REAL(wp) ::   r_bump , h_bump , h_oce   ! bump characteristics 
+      REAL(wp) ::   zi     , zj     , zh      ! temporary scalars
+      INTEGER , DIMENSION(jpidta,jpjdta) ::   idta   ! global domain integer data
+      REAL(wp), DIMENSION(jpidta,jpjdta) ::   zdta   ! global domain scalar data
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_bat : defines level and meter bathymetry'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~'
+
+      !                                               ! ================== ! 
+      IF( ntopo == 0 .OR. ntopo == -1 ) THEN          !   defined by hand  !
+         !                                            ! ================== !
+         !                                            ! global domain level and meter bathymetry (idta,zdta)
+         !
+         IF( ntopo == 0 ) THEN                        ! flat basin
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '         bathymetry field: flat basin'
+            idta(:,:) = jpkm1                            ! before last level
+            zdta(:,:) = gdepw_0(jpk)                     ! last w-point depth
+            h_oce     = gdepw_0(jpk)
+         ELSE                                         ! bump centered in the basin
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '         bathymetry field: flat basin with a bump'
+            ii_bump = jpidta / 2                           ! i-index of the bump center
+            ij_bump = jpjdta / 2                           ! j-index of the bump center
+            r_bump  = 50000.e0                             ! bump radius (meters)       
+            h_bump  = 2700.e0                              ! bump height (meters)
+            h_oce   = gdepw_0(jpk)                         ! background ocean depth (meters)
+            IF(lwp) WRITE(numout,*) '            bump characteristics: '
+            IF(lwp) WRITE(numout,*) '               bump center (i,j)   = ', ii_bump, ii_bump
+            IF(lwp) WRITE(numout,*) '               bump height         = ', h_bump , ' meters'
+            IF(lwp) WRITE(numout,*) '               bump radius         = ', r_bump , ' index'
+            IF(lwp) WRITE(numout,*) '            background ocean depth = ', h_oce  , ' meters'
+            !                                        
+            DO jj = 1, jpjdta                              ! zdta :
+               DO ji = 1, jpidta
+                  zi = FLOAT( ji - ii_bump ) * ppe1_m / r_bump
+                  zj = FLOAT( jj - ij_bump ) * ppe2_m / r_bump
+                  zdta(ji,jj) = h_oce - h_bump * EXP( -( zi*zi + zj*zj ) )
+               END DO
+            END DO
+            !                                              ! idta :
+            IF( ln_sco ) THEN                                   ! s-coordinate (zsc       ): idta()=jpk
+               idta(:,:) = jpkm1
+            ELSE                                                ! z-coordinate (zco or zps): step-like topography
+               idta(:,:) = jpkm1
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpjdta
+                     DO ji = 1, jpidta
+                        IF( gdept_0(jk) < zdta(ji,jj) .AND. zdta(ji,jj) <= gdept_0(jk+1) )   idta(ji,jj) = jk
+                     END DO
+                  END DO
+               END DO
+            ENDIF
+         ENDIF
+         !                                            ! set GLOBAL boundary conditions 
+         !                                            ! Caution : idta on the global domain: use of jperio, not nperio
+         IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN
+            idta( :    , 1    ) = -1                ;      zdta( :    , 1    ) = -1.e0
+            idta( :    ,jpjdta) =  0                ;      zdta( :    ,jpjdta) =  0.e0
+         ELSEIF( jperio == 2 ) THEN
+            idta( :    , 1    ) = idta( : ,  3  )   ;      zdta( :    , 1    ) = zdta( : ,  3  )
+            idta( :    ,jpjdta) = 0                 ;      zdta( :    ,jpjdta) =  0.e0
+            idta( 1    , :    ) = 0                 ;      zdta( 1    , :    ) =  0.e0
+            idta(jpidta, :    ) = 0                 ;      zdta(jpidta, :    ) =  0.e0
+         ELSE
+            ih = 0                                  ;      zh = 0.e0
+            IF( ln_sco )   ih = jpkm1               ;      IF( ln_sco )   zh = h_oce
+            idta( :    , 1    ) = ih                ;      zdta( :    , 1    ) =  zh
+            idta( :    ,jpjdta) = ih                ;      zdta( :    ,jpjdta) =  zh
+            idta( 1    , :    ) = ih                ;      zdta( 1    , :    ) =  zh
+            idta(jpidta, :    ) = ih                ;      zdta(jpidta, :    ) =  zh
+         ENDIF
+
+         !                                            ! local domain level and meter bathymetries (mbathy,bathy)
+         mbathy(:,:) = 0                                   ! set to zero extra halo points
+         bathy (:,:) = 0.e0                                ! (require for mpp case)
+         DO jj = 1, nlcj                                   ! interior values
+            DO ji = 1, nlci
+               mbathy(ji,jj) = idta( mig(ji), mjg(jj) )
+               bathy (ji,jj) = zdta( mig(ji), mjg(jj) )
+            END DO
+         END DO
+         !
+         !                                            ! ================ !
+      ELSEIF( ntopo == 1 ) THEN                       !   read in file   ! (over the local domain)
+         !                                            ! ================ !
+         !
+         IF( ln_zco )   THEN                          ! zco : read level bathymetry 
+            CALL iom_open( 'bathy_level.nc', inum )  
+            CALL iom_get ( inum, jpdom_data, 'Bathy_level', bathy )
+            CALL iom_close (inum)
+            mbathy(:,:) = INT( bathy(:,:) )
+            !                                                ! =====================
+            IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
+               !                                             ! =====================
+               IF( n_cla == 0 ) THEN
+                  !
+                  ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
+                  ij0 = 102   ;   ij1 = 102                  ! (Thomson, Ocean Modelling, 1995)
+                  DO ji = mi0(ii0), mi1(ii1)
+                     DO jj = mj0(ij0), mj1(ij1)
+                        mbathy(ji,jj) = 15
+                     END DO
+                  END DO
+                  IF(lwp) WRITE(numout,*)
+                  IF(lwp) WRITE(numout,*) '             orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
+                  !
+                  ii0 = 160   ;   ii1 = 160                  ! Bab el mandeb Strait open
+                  ij0 = 88    ;   ij1 = 88                   ! (Thomson, Ocean Modelling, 1995)
+                  DO ji = mi0(ii0), mi1(ii1)
+                     DO jj = mj0(ij0), mj1(ij1)
+                        mbathy(ji,jj) = 12
+                     END DO
+                  END DO
+                  IF(lwp) WRITE(numout,*)
+                  IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
+                  !
+               ENDIF
+               !
+            ENDIF
+            !
+         ENDIF
+         IF( ln_zps .OR. ln_sco )   THEN              ! zps or sco : read meter bathymetry
+            CALL iom_open( 'bathy_meter.nc', inum ) 
+            CALL iom_get ( inum, jpdom_data, 'Bathymetry', bathy )
+            CALL iom_close (inum)
+            !                                                ! =====================
+           IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
+              !                                             ! =====================
+              IF( n_cla == 0 ) THEN
+                 !
+                 ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
+                 ij0 = 102   ;   ij1 = 102                  ! (Thomson, Ocean Modelling, 1995)
+                 DO ji = mi0(ii0), mi1(ii1)
+                    DO jj = mj0(ij0), mj1(ij1)
+                       bathy(ji,jj) = 284.e0
+                    END DO
+                 END DO
+                 IF(lwp) WRITE(numout,*)
+                 IF(lwp) WRITE(numout,*) '             orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
+                 !
+                 ii0 = 160   ;   ii1 = 160                  ! Bab el mandeb Strait open
+                 ij0 = 88    ;   ij1 = 88                   ! (Thomson, Ocean Modelling, 1995)
+                 DO ji = mi0(ii0), mi1(ii1)
+                    DO jj = mj0(ij0), mj1(ij1)
+                       bathy(ji,jj) = 137.e0
+                    END DO
+                 END DO
+                 IF(lwp) WRITE(numout,*)
+                 IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
+                 !
+              ENDIF
+              !
+           ENDIF
+            !
+        ENDIF
+         !                                            ! =============== !
+      ELSE                                            !      error      !
+         !                                            ! =============== !
+         WRITE(ctmp1,*) 'parameter , ntopo = ', ntopo
+         CALL ctl_stop( '    zgr_bat : '//trim(ctmp1) )
+      ENDIF
+      !
+      !                                               ! =========================== !
+      IF( nclosea == 0 ) THEN                         !   NO closed seas or lakes   !
+         DO jl = 1, jpncs                             ! =========================== !
+            DO jj = ncsj1(jl), ncsj2(jl)
+               DO ji = ncsi1(jl), ncsi2(jl)
+                  mbathy(ji,jj) = 0                   ! suppress closed seas and lakes from bathymetry
+                  bathy (ji,jj) = 0.e0                
+               END DO
+            END DO
+         END DO
+      ENDIF
+#if defined key_orca_lev10
+      !                                               ! ================= !
+      mbathy(:,:) = 10 * mbathy(:,:)                  !   key_orca_lev10  !
+      !                                               ! ================= !
+      IF( ln_zps .OR. ln_sco )   CALL ctl_stop( ' CAUTION: 300 levels only with level bathymetry' )
+#endif
+      !                                               ! =============== !
+      IF( lzoom        )   CALL zgr_bat_zoom          !   Zoom domain   !
+      !                                               ! =============== !
+
+      !                                               ! =================== !
+      IF( .NOT. lk_c1d )   CALL zgr_bat_ctl           !   Bathymetry check  !
+      !                                               ! =================== !
+   END SUBROUTINE zgr_bat
+
+
+   SUBROUTINE zgr_bat_zoom
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_bat_zoom  ***
+      !!
+      !! ** Purpose : - Close zoom domain boundary if necessary
+      !!              - Suppress Med Sea from ORCA R2 and R05 arctic zoom
+      !!
+      !! ** Method  : 
+      !!
+      !! ** Action  : - update mbathy: level bathymetry (in level index)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ii0, ii1, ij0, ij1   ! temporary integers
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_bat_zoom : modify the level bathymetry for zoom domain'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~'
+      !
+      ! Zoom domain
+      ! ===========
+      !
+      ! Forced closed boundary if required
+      IF( lzoom_s )   mbathy(  : , mj0(jpjzoom):mj1(jpjzoom) )      = 0
+      IF( lzoom_w )   mbathy(      mi0(jpizoom):mi1(jpizoom) , :  ) = 0
+      IF( lzoom_e )   mbathy(      mi0(jpiglo+jpizoom-1):mi1(jpiglo+jpizoom-1) , :  ) = 0
+      IF( lzoom_n )   mbathy(  : , mj0(jpjglo+jpjzoom-1):mj1(jpjglo+jpjzoom-1) )      = 0
+      !
+      ! Configuration specific domain modifications
+      ! (here, ORCA arctic configuration: suppress Med Sea)
+      IF( cp_cfg == "orca" .AND. lzoom_arct ) THEN
+         SELECT CASE ( jp_cfg )
+         !                                        ! =======================
+         CASE ( 2 )                               !  ORCA_R2 configuration
+            !                                     ! =======================
+            IF(lwp) WRITE(numout,*) '                   ORCA R2 arctic zoom: suppress the Med Sea'
+            ii0 = 141   ;   ii1 = 162      ! Sea box i,j indices
+            ij0 =  98   ;   ij1 = 110
+            !                                     ! =======================
+         CASE ( 05 )                              !  ORCA_R05 configuration
+            !                                     ! =======================
+            IF(lwp) WRITE(numout,*) '                   ORCA R05 arctic zoom: suppress the Med Sea'
+            ii0 = 563   ;   ii1 = 642      ! zero over the Med Sea boxe
+            ij0 = 314   ;   ij1 = 370 
+         END SELECT
+         !
+         mbathy( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0   ! zero over the Med Sea boxe
+         !
+      ENDIF
+      !
+   END SUBROUTINE zgr_bat_zoom
+
+
+   SUBROUTINE zgr_bat_ctl
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_bat_ctl  ***
+      !!
+      !! ** Purpose :   check the bathymetry in levels
+      !!
+      !! ** Method  :   The array mbathy is checked to verified its consistency
+      !!      with the model options. in particular:
+      !!            mbathy must have at least 1 land grid-points (mbathy<=0)
+      !!                  along closed boundary.
+      !!            mbathy must be cyclic IF jperio=1.
+      !!            mbathy must be lower or equal to jpk-1.
+      !!            isolated ocean grid points are suppressed from mbathy
+      !!                  since they are only connected to remaining
+      !!                  ocean through vertical diffusion.
+      !!      C A U T I O N : mbathy will be modified during the initializa-
+      !!      tion phase to become the number of non-zero w-levels of a water
+      !!      column, with a minimum value of 1.
+      !!
+      !! ** Action  : - update mbathy: level bathymetry (in level index)
+      !!              - update bathy : meter bathymetry (in meters)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, jl                    ! dummy loop indices
+      INTEGER ::   icompt, ibtest, ikmax         ! temporary integers
+      REAL(wp), DIMENSION(jpi,jpj) ::   zbathy   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_bat_ctl : check the bathymetry'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~'
+
+      !                                          ! Suppress isolated ocean grid points
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)'                   suppress isolated ocean grid points'
+      IF(lwp) WRITE(numout,*)'                   -----------------------------------'
+      icompt = 0
+      DO jl = 1, 2
+         IF( nperio == 1 .OR. nperio  ==  4 .OR. nperio  ==  6 ) THEN
+            mbathy( 1 ,:) = mbathy(jpim1,:)           ! local domain is cyclic east-west
+            mbathy(jpi,:) = mbathy(  2  ,:)
+         ENDIF
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               ibtest = MAX(  mbathy(ji-1,jj), mbathy(ji+1,jj),   &
+                  &           mbathy(ji,jj-1), mbathy(ji,jj+1)  )
+               IF( ibtest < mbathy(ji,jj) ) THEN
+                  IF(lwp) WRITE(numout,*) ' the number of ocean level at ',   &
+                     &   'grid-point (i,j) =  ',ji,jj,' is changed from ', mbathy(ji,jj),' to ', ibtest
+                  mbathy(ji,jj) = ibtest
+                  icompt = icompt + 1
+               ENDIF
+            END DO
+         END DO
+      END DO
+      IF( icompt == 0 ) THEN
+         IF(lwp) WRITE(numout,*)'     no isolated ocean grid points'
+      ELSE
+         IF(lwp) WRITE(numout,*)'    ',icompt,' ocean grid points suppressed'
+      ENDIF
+      IF( lk_mpp ) THEN
+         zbathy(:,:) = FLOAT( mbathy(:,:) )
+         CALL lbc_lnk( zbathy, 'T', 1. )
+         mbathy(:,:) = INT( zbathy(:,:) )
+      ENDIF
+
+      !                                          ! East-west cyclic boundary conditions
+      IF( nperio == 0 ) THEN
+         IF(lwp) WRITE(numout,*) ' mbathy set to 0 along east and west boundary: nperio = ', nperio
+         IF( lk_mpp ) THEN
+            IF( nbondi == -1 .OR. nbondi == 2 ) THEN
+               IF( jperio /= 1 )   mbathy(1,:) = 0
+            ENDIF
+            IF( nbondi == 1 .OR. nbondi == 2 ) THEN
+               IF( jperio /= 1 )   mbathy(nlci,:) = 0
+            ENDIF
+         ELSE
+            IF( ln_zco .OR. ln_zps ) THEN
+               mbathy( 1 ,:) = 0
+               mbathy(jpi,:) = 0
+            ELSE
+               mbathy( 1 ,:) = jpkm1
+               mbathy(jpi,:) = jpkm1
+            ENDIF
+         ENDIF
+      ELSEIF( nperio == 1 .OR. nperio == 4 .OR. nperio ==  6 ) THEN
+         IF(lwp) WRITE(numout,*)' east-west cyclic boundary conditions on mbathy: nperio = ', nperio
+         mbathy( 1 ,:) = mbathy(jpim1,:)
+         mbathy(jpi,:) = mbathy(  2  ,:)
+      ELSEIF( nperio == 2 ) THEN
+         IF(lwp) WRITE(numout,*) '   equatorial boundary conditions on mbathy: nperio = ', nperio
+      ELSE
+         IF(lwp) WRITE(numout,*) '    e r r o r'
+         IF(lwp) WRITE(numout,*) '    parameter , nperio = ', nperio
+         !         STOP 'dom_mba'
+      ENDIF
+
+      !  Boundary condition on mbathy
+      IF( .NOT.lk_mpp ) THEN 
+!!gm     !!bug ???  think about it !
+         !   ... mono- or macro-tasking: T-point, >0, 2D array, no slab
+         zbathy(:,:) = FLOAT( mbathy(:,:) )
+         CALL lbc_lnk( zbathy, 'T', 1. )
+         mbathy(:,:) = INT( zbathy(:,:) )
+      ENDIF
+
+      ! Number of ocean level inferior or equal to jpkm1
+      ikmax = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikmax = MAX( ikmax, mbathy(ji,jj) )
+         END DO
+      END DO
+!!gm  !!! test to do:   ikmax = MAX( mbathy(:,:) )   ???
+      IF( ikmax > jpkm1 ) THEN
+         IF(lwp) WRITE(numout,*) ' maximum number of ocean level = ', ikmax,' >  jpk-1'
+         IF(lwp) WRITE(numout,*) ' change jpk to ',ikmax+1,' to use the exact ead bathymetry'
+      ELSE IF( ikmax < jpkm1 ) THEN
+         IF(lwp) WRITE(numout,*) ' maximum number of ocean level = ', ikmax,' < jpk-1' 
+         IF(lwp) WRITE(numout,*) ' you can decrease jpk to ', ikmax+1
+      ENDIF
+
+      IF( lwp .AND. nprint == 1 ) THEN      ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' bathymetric field :   number of non-zero T-levels '
+         WRITE(numout,*) ' ------------------'
+         CALL prihin( mbathy, jpi, jpj, 1, jpi, 1, 1, jpj, 1, 3, numout )
+         WRITE(numout,*)
+      ENDIF
+      !
+   END SUBROUTINE zgr_bat_ctl
+
+
+   SUBROUTINE zgr_zco
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zco  ***
+      !!
+      !! ** Purpose :   define the z-coordinate system
+      !!
+      !! ** Method  :   set 3D coord. arrays to reference 1D array if lk_zco=T
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk
+      !!----------------------------------------------------------------------
+      !
+      IF( .NOT.lk_zco ) THEN
+         DO jk = 1, jpk
+            fsdept(:,:,jk) = gdept_0(jk)
+            fsdepw(:,:,jk) = gdepw_0(jk)
+            fsde3w(:,:,jk) = gdepw_0(jk)
+            fse3t (:,:,jk) = e3t_0(jk)
+            fse3u (:,:,jk) = e3t_0(jk)
+            fse3v (:,:,jk) = e3t_0(jk)
+            fse3f (:,:,jk) = e3t_0(jk)
+            fse3w (:,:,jk) = e3w_0(jk)
+            fse3uw(:,:,jk) = e3w_0(jk)
+            fse3vw(:,:,jk) = e3w_0(jk)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE zgr_zco
+
+#if defined key_zco
+   !!----------------------------------------------------------------------
+   !!   'key_zco' :                                              "pure" zco (gdep & e3 are 1D arrays)
+   !!----------------------------------------------------------------------
+   SUBROUTINE zgr_zps      ! Empty routine
+   END SUBROUTINE zgr_zps
+   SUBROUTINE zgr_sco      ! Empty routine
+   END SUBROUTINE zgr_sco
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                      zco, zps and/or sco available (gedp & e3 are 3D arrays)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE zgr_zps
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zps  ***
+      !!                     
+      !! ** Purpose :   the depth and vertical scale factor in partial step
+      !!      z-coordinate case
+      !!
+      !! ** Method  :   Partial steps : computes the 3D vertical scale factors
+      !!      of T-, U-, V-, W-, UW-, VW and F-points that are associated with
+      !!      a partial step representation of bottom topography.
+      !!
+      !!        The reference depth of model levels is defined from an analytical
+      !!      function the derivative of which gives the reference vertical
+      !!      scale factors.
+      !!        From  depth and scale factors reference, we compute there new value
+      !!      with partial steps  on 3d arrays ( i, j, k ).
+      !!
+      !!              w-level: gdepw(i,j,k)  = fsdep(k)
+      !!                       e3w(i,j,k) = dk(fsdep)(k)     = fse3(i,j,k)
+      !!              t-level: gdept(i,j,k)  = fsdep(k+0.5)
+      !!                       e3t(i,j,k) = dk(fsdep)(k+0.5) = fse3(i,j,k+0.5)
+      !!
+      !!        With the help of the bathymetric file ( bathymetry_depth_ORCA_R2.nc),
+      !!      we find the mbathy index of the depth at each grid point.
+      !!      This leads us to three cases:
+      !!
+      !!              - bathy = 0 => mbathy = 0
+      !!              - 1 < mbathy < jpkm1    
+      !!              - bathy > gdepw(jpk) => mbathy = jpkm1  
+      !!
+      !!        Then, for each case, we find the new depth at t- and w- levels
+      !!      and the new vertical scale factors at t-, u-, v-, w-, uw-, vw- 
+      !!      and f-points.
+      !! 
+      !!        This routine is given as an example, it must be modified
+      !!      following the user s desiderata. nevertheless, the output as
+      !!      well as the way to compute the model levels and scale factors
+      !!      must be respected in order to insure second order accuracy
+      !!      schemes.
+      !!
+      !!         c a u t i o n : gdept_0, gdepw_0 and e3._0 are positives
+      !!         - - - - - - -   gdept, gdepw and e3. are positives
+      !!      
+      !!  Reference :   Pacanowsky & Gnanadesikan 1997, Mon. Wea. Rev., 126, 3248-3270.
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk       ! dummy loop indices
+      INTEGER  ::   ik, it           ! temporary integers
+      LOGICAL  ::   ll_print         ! Allow  control print for debugging
+      REAL(wp) ::   ze3tp , ze3wp    ! Last ocean level thickness at T- and W-points
+      REAL(wp) ::   zdepwp, zdepth   ! Ajusted ocean depth to avoid too small e3t
+      REAL(wp) ::   zmax, zmin       ! Maximum and minimum depth
+      REAL(wp) ::   zdiff            ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprt   ! 3D workspace
+      !!---------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_zps : z-coordinate with partial steps'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~ '
+      IF(lwp) WRITE(numout,*) '              mbathy is recomputed : bathy_level file is NOT used'
+
+      ll_print=.FALSE.                     ! Local variable for debugging
+!!    ll_print=.TRUE.
+      
+      IF(lwp .AND. ll_print) THEN          ! control print of the ocean depth
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom_zgr_zps:  bathy (in hundred of meters)'
+         CALL prihre( bathy, jpi, jpj, 1,jpi, 1, 1, jpj, 1, 1.e-2, numout )
+      ENDIF
+
+
+      ! bathymetry in level (from bathy_meter)
+      ! ===================
+      zmax = gdepw_0(jpk) + e3t_0(jpk)     ! maximum depth (i.e. the last ocean level thickness <= 2*e3t_0(jpkm1) )
+      zmin = gdepw_0(4)                    ! minimum depth = 3 levels
+
+      mbathy(:,:) = jpkm1                  ! initialize mbathy to the maximum ocean level available
+
+      !                                    ! storage of land and island's number (zera and negative values) in mbathy
+      WHERE( bathy(:,:) <= 0. )   mbathy(:,:) = INT( bathy(:,:) )
+
+      ! bounded value of bathy
+!!gm  bathy(:,:) = MIN(  zmax,  MAX( bathy(:,:), zmin )  )     !!gm : simpler   as zmin is > 0
+      DO jj = 1, jpj
+         DO ji= 1, jpi
+            IF( bathy(ji,jj) <= 0. ) THEN   ;   bathy(ji,jj) = 0.e0
+            ELSE                            ;   bathy(ji,jj) = MIN(  zmax,  MAX( bathy(ji,jj), zmin )  )
+            ENDIF
+         END DO
+      END DO
+
+      ! Compute mbathy for ocean points (i.e. the number of ocean levels)
+      ! find the number of ocean levels such that the last level thickness
+      ! is larger than the minimum of e3zps_min and e3zps_rat * e3t_0 (where
+      ! e3t_0 is the reference level thickness
+      DO jk = jpkm1, 1, -1
+         zdepth = gdepw_0(jk) + MIN( e3zps_min, e3t_0(jk)*e3zps_rat )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( 0. < bathy(ji,jj) .AND. bathy(ji,jj) <= zdepth )   mbathy(ji,jj) = jk-1
+            END DO
+         END DO
+      END DO
+
+      ! Scale factors and depth at T- and W-points
+      DO jk = 1, jpk                        ! intitialization to the reference z-coordinate
+         gdept(:,:,jk) = gdept_0(jk)
+         gdepw(:,:,jk) = gdepw_0(jk)
+         e3t  (:,:,jk) = e3t_0  (jk)
+         e3w  (:,:,jk) = e3w_0  (jk)
+      END DO
+      hdept(:,:) = gdept(:,:,2 )
+      hdepw(:,:) = gdepw(:,:,3 )     
+      ! 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = mbathy(ji,jj)
+            IF( ik > 0 ) THEN               ! ocean point only
+               ! max ocean level case
+               IF( ik == jpkm1 ) THEN
+                  zdepwp = bathy(ji,jj)
+                  ze3tp  = bathy(ji,jj) - gdepw_0(ik)
+                  ze3wp = 0.5 * e3w_0(ik) * ( 1. + ( ze3tp/e3t_0(ik) ) )
+                  e3t(ji,jj,ik  ) = ze3tp
+                  e3t(ji,jj,ik+1) = ze3tp
+                  e3w(ji,jj,ik  ) = ze3wp
+                  e3w(ji,jj,ik+1) = ze3tp
+                  gdepw(ji,jj,ik+1) = zdepwp
+                  gdept(ji,jj,ik  ) = gdept_0(ik-1) + ze3wp
+                  gdept(ji,jj,ik+1) = gdept(ji,jj,ik) + ze3tp
+                  !
+               ELSE                         ! standard case
+                  IF( bathy(ji,jj) <= gdepw_0(ik+1) ) THEN   ;   gdepw(ji,jj,ik+1) = bathy(ji,jj)
+                  ELSE                                       ;   gdepw(ji,jj,ik+1) = gdepw_0(ik+1)
+                  ENDIF
+!gm Bug?  check the gdepw_0
+                  !       ... on ik
+                  gdept(ji,jj,ik) = gdepw_0(ik) + ( gdepw  (ji,jj,ik+1) - gdepw_0(ik) )   &
+                     &                          * ((gdept_0(      ik  ) - gdepw_0(ik) )   &
+                     &                          / ( gdepw_0(      ik+1) - gdepw_0(ik) ))
+                  e3t  (ji,jj,ik) = e3t_0  (ik) * ( gdepw  (ji,jj,ik+1) - gdepw_0(ik) )   & 
+                     &                          / ( gdepw_0(      ik+1) - gdepw_0(ik) ) 
+                  e3w  (ji,jj,ik) = 0.5 * ( gdepw(ji,jj,ik+1) + gdepw_0(ik+1) - 2.*gdepw_0(ik) )   &
+                     &                  * ( e3w_0(ik) / ( gdepw_0(ik+1) - gdepw_0(ik) ) )
+                  !       ... on ik+1
+                  e3w  (ji,jj,ik+1) = e3t  (ji,jj,ik)
+                  e3t  (ji,jj,ik+1) = e3t  (ji,jj,ik)
+                  gdept(ji,jj,ik+1) = gdept(ji,jj,ik) + e3t(ji,jj,ik)
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      !
+      it = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ik = mbathy(ji,jj)
+            IF( ik > 0 ) THEN               ! ocean point only
+               hdept(ji,jj) = gdept(ji,jj,ik  )
+               hdepw(ji,jj) = gdepw(ji,jj,ik+1)
+               e3tp (ji,jj) = e3t(ji,jj,ik  )
+               e3wp (ji,jj) = e3w(ji,jj,ik  )
+               ! test
+               zdiff= gdepw(ji,jj,ik+1) - gdept(ji,jj,ik  )
+               IF( zdiff <= 0. .AND. lwp ) THEN 
+                  it = it + 1
+                  WRITE(numout,*) ' it      = ', it, ' ik      = ', ik, ' (i,j) = ', ji, jj
+                  WRITE(numout,*) ' bathy = ', bathy(ji,jj)
+                  WRITE(numout,*) ' gdept = ', gdept(ji,jj,ik), ' gdepw = ', gdepw(ji,jj,ik+1), ' zdiff = ', zdiff
+                  WRITE(numout,*) ' e3tp  = ', e3t  (ji,jj,ik), ' e3wp  = ', e3w  (ji,jj,ik  )
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+
+      ! Scale factors and depth at U-, V-, UW and VW-points
+      DO jk = 1, jpk                        ! initialisation to z-scale factors
+         e3u (:,:,jk)  = e3t_0(jk)
+         e3v (:,:,jk)  = e3t_0(jk)
+         e3uw(:,:,jk)  = e3w_0(jk)
+         e3vw(:,:,jk)  = e3w_0(jk)
+      END DO
+      DO jk = 1,jpk                         ! Computed as the minimum of neighbooring scale factors
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               e3u (ji,jj,jk) = MIN( e3t(ji,jj,jk), e3t(ji+1,jj,jk))
+               e3v (ji,jj,jk) = MIN( e3t(ji,jj,jk), e3t(ji,jj+1,jk))
+               e3uw(ji,jj,jk) = MIN( e3w(ji,jj,jk), e3w(ji+1,jj,jk) )
+               e3vw(ji,jj,jk) = MIN( e3w(ji,jj,jk), e3w(ji,jj+1,jk) )
+            END DO
+         END DO
+      END DO
+      !                                     ! Boundary conditions
+      CALL lbc_lnk( e3u , 'U', 1. )   ;   CALL lbc_lnk( e3uw, 'U', 1. )
+      CALL lbc_lnk( e3v , 'V', 1. )   ;   CALL lbc_lnk( e3vw, 'V', 1. )
+      !
+      DO jk = 1, jpk                        ! set to z-scale factor if zero (i.e. along closed boundaries)
+         WHERE( e3u (:,:,jk) == 0.e0 )   e3u (:,:,jk) = e3t_0(jk)
+         WHERE( e3v (:,:,jk) == 0.e0 )   e3v (:,:,jk) = e3t_0(jk)
+         WHERE( e3uw(:,:,jk) == 0.e0 )   e3uw(:,:,jk) = e3w_0(jk)
+         WHERE( e3vw(:,:,jk) == 0.e0 )   e3vw(:,:,jk) = e3w_0(jk)
+      END DO
+      
+      ! Scale factor at F-point
+      DO jk = 1, jpk                        ! initialisation to z-scale factors
+         e3f (:,:,jk) = e3t_0(jk)
+      END DO
+      DO jk = 1, jpk                        ! Computed as the minimum of neighbooring V-scale factors
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               e3f(ji,jj,jk) = MIN( e3v(ji,jj,jk), e3v(ji+1,jj,jk) )
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( e3f, 'F', 1. )          ! Boundary conditions
+      !
+      DO jk = 1, jpk                        ! set to z-scale factor if zero (i.e. along closed boundaries)
+         WHERE( e3f(:,:,jk) == 0.e0 )   e3f(:,:,jk) = e3t_0(jk)
+      END DO
+!!gm  bug ? :  must be a do loop with mj0,mj1
+      ! 
+      e3t(:,mj0(1),:) = e3t(:,mj0(2),:)     ! we duplicate factor scales for jj = 1 and jj = 2
+      e3w(:,mj0(1),:) = e3w(:,mj0(2),:) 
+      e3u(:,mj0(1),:) = e3u(:,mj0(2),:) 
+      e3v(:,mj0(1),:) = e3v(:,mj0(2),:) 
+      e3f(:,mj0(1),:) = e3f(:,mj0(2),:) 
+
+      ! Control of the sign
+      IF( MINVAL( e3t  (:,:,:) ) <= 0.e0 )   CALL ctl_stop( '    zgr_zps :   e r r o r   e3t   <= 0' )
+      IF( MINVAL( e3w  (:,:,:) ) <= 0.e0 )   CALL ctl_stop( '    zgr_zps :   e r r o r   e3w   <= 0' )
+      IF( MINVAL( gdept(:,:,:) ) <  0.e0 )   CALL ctl_stop( '    zgr_zps :   e r r o r   gdepw <  0' )
+      IF( MINVAL( gdepw(:,:,:) ) <  0.e0 )   CALL ctl_stop( '    zgr_zps :   e r r o r   gdepw <  0' )
+     
+      ! Compute gdep3w (vertical sum of e3w)
+      gdep3w(:,:,1) = 0.5 * e3w(:,:,1)
+      DO jk = 2, jpk
+         gdep3w(:,:,jk) = gdep3w(:,:,jk-1) + e3w(:,:,jk) 
+      END DO
+          
+      !                                               ! ================= !
+      IF(lwp .AND. ll_print) THEN                     !   Control print   !
+         !                                            ! ================= !
+         DO jj = 1,jpj
+            DO ji = 1, jpi
+               ik = MAX( mbathy(ji,jj), 1 )
+               zprt(ji,jj,1) = e3t   (ji,jj,ik)
+               zprt(ji,jj,2) = e3w   (ji,jj,ik)
+               zprt(ji,jj,3) = e3u   (ji,jj,ik)
+               zprt(ji,jj,4) = e3v   (ji,jj,ik)
+               zprt(ji,jj,5) = e3f   (ji,jj,ik)
+               zprt(ji,jj,6) = gdep3w(ji,jj,ik)
+            END DO
+         END DO
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr e3t(mbathy)'      ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr e3w(mbathy)'      ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr e3u(mbathy)'      ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr e3v(mbathy)'      ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr e3f(mbathy)'      ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'domzgr gdep3w(mbathy)'   ;   CALL prihre(zprt(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF  
+       
+      !                                               ! =============== !
+      IF( lzoom )   CALL zgr_bat_zoom                 !   Zoom domain   !
+      !                                               ! =============== !
+
+      !                                               ! =================== !
+      IF( .NOT. lk_c1d )   CALL zgr_bat_ctl           !   Bathymetry check  !
+      !                                               ! =================== !
+   END SUBROUTINE zgr_zps
+
+
+   FUNCTION fssig( pk ) RESULT( pf )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!       
+      !! ** Purpose :   provide the analytical function in s-coordinate
+      !!          
+      !! ** Method  :   the function provide the non-dimensional position of
+      !!                T and W (i.e. between 0 and 1)
+      !!                T-points at integer values (between 1 and jpk)
+      !!                W-points at integer values - 1/2 (between 0.5 and jpk-0.5)
+      !!
+      !! Reference  :   ???
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ) ::   pk   ! continuous "k" coordinate
+      REAL(wp)                ::   pf   ! sigma value
+      !!----------------------------------------------------------------------
+      !
+      pf =   (   TANH( rn_theta * ( -(pk-0.5) / REAL(jpkm1) + rn_thetb )  )      &
+         &     - TANH( rn_thetb * rn_theta                                )  )   &
+         & * (   COSH( rn_theta                           )                   &
+         &     + COSH( rn_theta * ( 2.e0 * rn_thetb - 1.e0 ) )  )                &
+         & / ( 2.e0 * SINH( rn_theta ) )
+      !
+   END FUNCTION fssig
+
+
+   FUNCTION fssig1( pk1, pbb ) RESULT( pf1 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!
+      !! ** Purpose :   provide the Song and Haidvogel version of the analytical function in s-coordinate
+      !!
+      !! ** Method  :   the function provides the non-dimensional position of
+      !!                T and W (i.e. between 0 and 1)
+      !!                T-points at integer values (between 1 and jpk)
+      !!                W-points at integer values - 1/2 (between 0.5 and jpk-0.5)
+      !!
+      !! Reference  :   ???
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ) ::   pk1   ! continuous "k" coordinate
+      REAL(wp), INTENT(in   ) ::   pbb   ! Stretching coefficient
+      REAL(wp)                ::   pf1   ! sigma value
+      !!----------------------------------------------------------------------
+      !
+      IF ( rn_theta == 0 ) then      ! uniform sigma
+         pf1 = -(pk1-0.5) / REAL( jpkm1 )
+      ELSE                        ! stretched sigma
+         pf1 =   (1.0-pbb) * (sinh( rn_theta*(-(pk1-0.5)/REAL(jpkm1)) ) ) / sinh(rn_theta) + &
+            &    pbb * ( (tanh( rn_theta*( (-(pk1-0.5)/REAL(jpkm1)) + 0.5) ) - tanh(0.5*rn_theta) ) / &
+            &    (2*tanh(0.5*rn_theta) ) )
+      ENDIF
+      !
+   END FUNCTION fssig1
+
+
+   SUBROUTINE zgr_sco
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_sco  ***
+      !!                     
+      !! ** Purpose :   define the s-coordinate system
+      !!
+      !! ** Method  :   s-coordinate
+      !!         The depth of model levels is defined as the product of an
+      !!      analytical function by the local bathymetry, while the vertical
+      !!      scale factors are defined as the product of the first derivative
+      !!      of the analytical function by the bathymetry.
+      !!      (this solution save memory as depth and scale factors are not
+      !!      3d fields)
+      !!          - Read bathymetry (in meters) at t-point and compute the
+      !!         bathymetry at u-, v-, and f-points.
+      !!            hbatu = mi( hbatt )
+      !!            hbatv = mj( hbatt )
+      !!            hbatf = mi( mj( hbatt ) )
+      !!          - Compute gsigt, gsigw, esigt, esigw from an analytical
+      !!         function and its derivative given as function.
+      !!            gsigt(k) = fssig (k    )
+      !!            gsigw(k) = fssig (k-0.5)
+      !!            esigt(k) = fsdsig(k    )
+      !!            esigw(k) = fsdsig(k-0.5)
+      !!      This routine is given as an example, it must be modified
+      !!      following the user s desiderata. nevertheless, the output as
+      !!      well as the way to compute the model levels and scale factors
+      !!      must be respected in order to insure second order a!!uracy
+      !!      schemes.
+      !!
+      !! Reference : Madec, Lott, Delecluse and Crepon, 1996. JPO, 26, 1393-1408.
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk, jl           ! dummy loop argument
+      INTEGER  ::   iip1, ijp1, iim1, ijm1   ! temporary integers
+      REAL(wp) ::   zcoeft, zcoefw, zrmax, ztaper   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zenv, ztmp, zmsk    ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zri , zrj , zhbat   !  -     -
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   gsigw3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   gsigt3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   gsi3w3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigt3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigw3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigtu3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigtv3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigtf3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigwu3
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   esigwv3
+      !!
+      NAMELIST/namzgr_sco/ rn_sbot_max, rn_sbot_min, rn_theta, rn_thetb, rn_rmax, ln_s_sigma, rn_bb, rn_hc
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )                        ! Read Namelist namzgr_sco : sigma-stretching parameters
+      READ  ( numnam, namzgr_sco )
+
+      IF(lwp) THEN                            ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dom:zgr_sco : s-coordinate or hybrid z-s-coordinate'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzgr_sco'
+         WRITE(numout,*) '      sigma-stretching coeffs '
+         WRITE(numout,*) '      maximum depth of s-bottom surface (>0)       rn_sbot_max   = ' ,rn_sbot_max
+         WRITE(numout,*) '      minimum depth of s-bottom surface (>0)       rn_sbot_min   = ' ,rn_sbot_min
+         WRITE(numout,*) '      surface control parameter (0<=rn_theta<=20)  rn_theta      = ', rn_theta
+         WRITE(numout,*) '      bottom  control parameter (0<=rn_thetb<= 1)  rn_thetb      = ', rn_thetb
+         WRITE(numout,*) '      maximum cut-off r-value allowed              rn_rmax       = ', rn_rmax
+         WRITE(numout,*) '      Hybrid s-sigma-coordinate                    ln_s_sigma    = ', ln_s_sigma
+         WRITE(numout,*) '      stretching parameter (song and haidvogel)    rn_bb         = ', rn_bb
+         WRITE(numout,*) '      Critical depth                               rn_hc         = ', rn_hc
+      ENDIF
+
+      gsigw3  = 0.0d0   ;   gsigt3  = 0.0d0   ; gsi3w3 = 0.0d0
+      esigt3  = 0.0d0   ;   esigw3  = 0.0d0 
+      esigtu3 = 0.0d0   ;   esigtv3 = 0.0d0   ; esigtf3 = 0.0d0
+      esigwu3 = 0.0d0   ;   esigwv3 = 0.0d0
+
+      hift(:,:) = rn_sbot_min                     ! set the minimum depth for the s-coordinate
+      hifu(:,:) = rn_sbot_min
+      hifv(:,:) = rn_sbot_min
+      hiff(:,:) = rn_sbot_min
+
+      !                                        ! set maximum ocean depth
+      bathy(:,:) = MIN( rn_sbot_max, bathy(:,:) )
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+           IF (bathy(ji,jj) .gt. 0.0) THEN
+              bathy(ji,jj) = MAX( rn_sbot_min, bathy(ji,jj) )
+           ENDIF
+         END DO
+      END DO
+      !                                        ! =============================
+      !                                        ! Define the envelop bathymetry   (hbatt)
+      !                                        ! =============================
+      ! use r-value to create hybrid coordinates
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zenv(ji,jj) = MAX( bathy(ji,jj), rn_sbot_min )
+         END DO
+      END DO
+      ! 
+      ! Smooth the bathymetry (if required)
+      scosrf(:,:) = 0.e0              ! ocean surface depth (here zero: no under ice-shelf sea)
+      scobot(:,:) = bathy(:,:)        ! ocean bottom  depth
+      !
+      jl = 0
+      zrmax = 1.e0
+      !                                                     ! ================ !
+      DO WHILE ( jl <= 10000 .AND. zrmax > rn_rmax )          !  Iterative loop  !
+         !                                                  ! ================ !
+         jl = jl + 1
+         zrmax = 0.e0
+         zmsk(:,:) = 0.e0
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               iip1 = MIN( ji+1, nlci )      ! force zri = 0 on last line (ji=ncli+1 to jpi)
+               ijp1 = MIN( jj+1, nlcj )      ! force zrj = 0 on last raw  (jj=nclj+1 to jpj)
+               zri(ji,jj) = ABS( zenv(iip1,jj  ) - zenv(ji,jj) ) / ( zenv(iip1,jj  ) + zenv(ji,jj) )
+               zrj(ji,jj) = ABS( zenv(ji  ,ijp1) - zenv(ji,jj) ) / ( zenv(ji  ,ijp1) + zenv(ji,jj) )
+               zrmax = MAX( zrmax, zri(ji,jj), zrj(ji,jj) )
+               IF( zri(ji,jj) > rn_rmax )   zmsk(ji  ,jj  ) = 1.0
+               IF( zri(ji,jj) > rn_rmax )   zmsk(iip1,jj  ) = 1.0
+               IF( zrj(ji,jj) > rn_rmax )   zmsk(ji  ,jj  ) = 1.0
+               IF( zrj(ji,jj) > rn_rmax )   zmsk(ji  ,ijp1) = 1.0
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_max( zrmax )   ! max over the global domain
+         ! lateral boundary condition on zmsk: keep 1 along closed boundary (use of MAX)
+         ztmp(:,:) = zmsk(:,:)   ;   CALL lbc_lnk( zmsk, 'T', 1. )
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+                zmsk(ji,jj) = MAX( zmsk(ji,jj), ztmp(ji,jj) )
+            END DO
+         END DO
+         !
+         IF(lwp)WRITE(numout,*) 'zgr_sco :   iter= ',jl, ' rmax= ', zrmax, ' nb of pt= ', INT( SUM(zmsk(:,:) ) )
+         !
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               iip1 = MIN( ji+1, nlci )     ! last  line (ji=nlci)
+               ijp1 = MIN( jj+1, nlcj )     ! last  raw  (jj=nlcj)
+               iim1 = MAX( ji-1,  1  )      ! first line (ji=nlci)
+               ijm1 = MAX( jj-1,  1  )      ! first raw  (jj=nlcj)
+               IF( zmsk(ji,jj) == 1.0 ) THEN
+                  ztmp(ji,jj) =   (                                                                                   &
+             &      zenv(iim1,ijp1)*zmsk(iim1,ijp1) + zenv(ji,ijp1)*zmsk(ji,ijp1) + zenv(iip1,ijp1)*zmsk(iip1,ijp1)   &
+             &    + zenv(iim1,jj  )*zmsk(iim1,jj  ) + zenv(ji,jj  )*    2.e0      + zenv(iip1,jj  )*zmsk(iip1,jj  )   &
+             &    + zenv(iim1,ijm1)*zmsk(iim1,ijm1) + zenv(ji,ijm1)*zmsk(ji,ijm1) + zenv(iip1,ijm1)*zmsk(iip1,ijm1)   &
+             &                    ) / (                                                                               &
+             &                      zmsk(iim1,ijp1) +               zmsk(ji,ijp1) +                 zmsk(iip1,ijp1)   &
+             &    +                 zmsk(iim1,jj  ) +                   2.e0      +                 zmsk(iip1,jj  )   &
+             &    +                 zmsk(iim1,ijm1) +               zmsk(ji,ijm1) +                 zmsk(iip1,ijm1)   &
+             &                        )
+               ENDIF
+            END DO
+         END DO
+         !
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               IF( zmsk(ji,jj) == 1.0 )   zenv(ji,jj) = MAX( ztmp(ji,jj), bathy(ji,jj) )
+            END DO
+         END DO
+         !
+         ! Apply lateral boundary condition   CAUTION: kept the value when the lbc field is zero
+         ztmp(:,:) = zenv(:,:)   ;   CALL lbc_lnk( zenv, 'T', 1. )
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               IF( zenv(ji,jj) == 0.e0 )   zenv(ji,jj) = ztmp(ji,jj)
+            END DO
+         END DO
+         !                                                  ! ================ !
+      END DO                                                !     End loop     !
+      !                                                     ! ================ !
+      !
+      !                                        ! envelop bathymetry saved in hbatt
+      hbatt(:,:) = zenv(:,:) 
+      IF( MINVAL( gphit(:,:) ) * MAXVAL( gphit(:,:) ) <= 0.e0 ) THEN
+         CALL ctl_warn( ' s-coordinates are tapered in vicinity of the Equator' )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztaper = EXP( -(gphit(ji,jj)/8)**2 )
+               hbatt(ji,jj) = rn_sbot_max * ztaper + hbatt(ji,jj) * (1.-ztaper)
+            END DO
+         END DO
+      ENDIF
+      !
+      IF(lwp) THEN                             ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' domzgr: hbatt field; ocean depth in meters'
+         WRITE(numout,*)
+         CALL prihre( hbatt(1,1), jpi, jpj, 1, jpi, 1, 1, jpj, 1, 0., numout )
+         IF( nprint == 1 )   THEN        
+            WRITE(numout,*) ' bathy  MAX ', MAXVAL( bathy(:,:) ), ' MIN ', MINVAL( bathy(:,:) )
+            WRITE(numout,*) ' hbatt  MAX ', MAXVAL( hbatt(:,:) ), ' MIN ', MINVAL( hbatt(:,:) )
+         ENDIF
+      ENDIF
+
+      !                                        ! ==============================
+      !                                        !   hbatu, hbatv, hbatf fields
+      !                                        ! ==============================
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' zgr_sco: minimum depth of the envelop topography set to : ', rn_sbot_min
+      ENDIF
+      hbatu(:,:) = rn_sbot_min
+      hbatv(:,:) = rn_sbot_min
+      hbatf(:,:) = rn_sbot_min
+      DO jj = 1, jpjm1
+        DO ji = 1, jpim1   ! NO vector opt.
+           hbatu(ji,jj) = 0.5 * ( hbatt(ji  ,jj) + hbatt(ji+1,jj  ) )
+           hbatv(ji,jj) = 0.5 * ( hbatt(ji  ,jj) + hbatt(ji  ,jj+1) )
+           hbatf(ji,jj) = 0.25* ( hbatt(ji  ,jj) + hbatt(ji  ,jj+1)   &
+              &                 + hbatt(ji+1,jj) + hbatt(ji+1,jj+1) )
+        END DO
+      END DO
+      ! 
+      ! Apply lateral boundary condition
+!!gm  ! CAUTION: retain non zero value in the initial file this should be OK for orca cfg, not for EEL
+      zhbat(:,:) = hbatu(:,:)   ;   CALL lbc_lnk( hbatu, 'U', 1. )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( hbatu(ji,jj) == 0.e0 ) THEN
+               IF( zhbat(ji,jj) == 0.e0 )   hbatu(ji,jj) = rn_sbot_min
+               IF( zhbat(ji,jj) /= 0.e0 )   hbatu(ji,jj) = zhbat(ji,jj)
+            ENDIF
+         END DO
+      END DO
+      zhbat(:,:) = hbatv(:,:)   ;   CALL lbc_lnk( hbatv, 'V', 1. )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( hbatv(ji,jj) == 0.e0 ) THEN
+               IF( zhbat(ji,jj) == 0.e0 )   hbatv(ji,jj) = rn_sbot_min
+               IF( zhbat(ji,jj) /= 0.e0 )   hbatv(ji,jj) = zhbat(ji,jj)
+            ENDIF
+         END DO
+      END DO
+      zhbat(:,:) = hbatf(:,:)   ;   CALL lbc_lnk( hbatf, 'F', 1. )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( hbatf(ji,jj) == 0.e0 ) THEN
+               IF( zhbat(ji,jj) == 0.e0 )   hbatf(ji,jj) = rn_sbot_min
+               IF( zhbat(ji,jj) /= 0.e0 )   hbatf(ji,jj) = zhbat(ji,jj)
+            ENDIF
+         END DO
+      END DO
+
+!!bug:  key_helsinki a verifer
+      hift(:,:) = MIN( hift(:,:), hbatt(:,:) )
+      hifu(:,:) = MIN( hifu(:,:), hbatu(:,:) )
+      hifv(:,:) = MIN( hifv(:,:), hbatv(:,:) )
+      hiff(:,:) = MIN( hiff(:,:), hbatf(:,:) )
+
+      IF( nprint == 1 .AND. lwp )   THEN
+         WRITE(numout,*) ' MAX val hif   t ', MAXVAL( hift (:,:) ), ' f ', MAXVAL( hiff (:,:) ),  &
+            &                        ' u ',   MAXVAL( hifu (:,:) ), ' v ', MAXVAL( hifv (:,:) )
+         WRITE(numout,*) ' MIN val hif   t ', MINVAL( hift (:,:) ), ' f ', MINVAL( hiff (:,:) ),  &
+            &                        ' u ',   MINVAL( hifu (:,:) ), ' v ', MINVAL( hifv (:,:) )
+         WRITE(numout,*) ' MAX val hbat  t ', MAXVAL( hbatt(:,:) ), ' f ', MAXVAL( hbatf(:,:) ),  &
+            &                        ' u ',   MAXVAL( hbatu(:,:) ), ' v ', MAXVAL( hbatv(:,:) )
+         WRITE(numout,*) ' MIN val hbat  t ', MINVAL( hbatt(:,:) ), ' f ', MINVAL( hbatf(:,:) ),  &
+            &                        ' u ',   MINVAL( hbatu(:,:) ), ' v ', MINVAL( hbatv(:,:) )
+      ENDIF
+!! helsinki
+
+      !                                            ! =======================
+      !                                            !   s-ccordinate fields     (gdep., e3.)
+      !                                            ! =======================
+      !
+      ! non-dimensional "sigma" for model level depth at w- and t-levels
+
+      IF( ln_s_sigma ) THEN        ! Song and Haidvogel style stretched sigma for depths
+         !                         ! below rn_hc, with uniform sigma in shallower waters
+         DO ji = 1, jpi
+            DO jj = 1, jpj
+
+             IF (hbatt(ji,jj).GT.rn_hc) THEN !deep water, stretched sigma
+               DO jk = 1, jpk
+                  gsigw3(ji,jj,jk) = -fssig1( REAL(jk,wp)-0.5_wp, rn_bb )
+                  gsigt3(ji,jj,jk) = -fssig1( REAL(jk,wp)       , rn_bb )
+               END DO
+             ELSE ! shallow water, uniform sigma
+               DO jk = 1, jpk
+                 gsigw3(ji,jj,jk) =  REAL(jk-1,wp)     /REAL(jpk-1,wp)
+                 gsigt3(ji,jj,jk) = (REAL(jk-1,wp)+0.5)/REAL(jpk-1,wp)
+               END DO
+             ENDIF
+             IF( nprint == 1 .AND. lwp ) WRITE(numout,*) 'gsigw3 1 jpk    ', gsigw3(ji,jj,1), gsigw3(ji,jj,jpk)
+
+
+             DO jk = 1, jpkm1
+                esigt3(ji,jj,jk) = gsigw3(ji,jj,jk+1) - gsigw3(ji,jj,jk)
+                esigw3(ji,jj,jk+1) = gsigt3(ji,jj,jk+1) - gsigt3(ji,jj,jk)
+             END DO
+             esigw3(ji,jj,1  ) = 2.0_wp * (gsigt3(ji,jj,1  ) - gsigw3(ji,jj,1  ))
+             esigt3(ji,jj,jpk) = 2.0_wp * (gsigt3(ji,jj,jpk) - gsigw3(ji,jj,jpk))
+
+             ! Coefficients for vertical depth as the sum of e3w scale factors
+             gsi3w3(ji,jj,1) = 0.5 * esigw3(ji,jj,1)
+             DO jk = 2, jpk
+                gsi3w3(ji,jj,jk) = gsi3w3(ji,jj,jk-1) + esigw3(ji,jj,jk)
+             END DO
+
+             DO jk = 1, jpk
+                zcoeft = ( REAL(jk,wp) - 0.5 ) / REAL(jpkm1,wp)
+                zcoefw = ( REAL(jk,wp) - 1.0 ) / REAL(jpkm1,wp)
+                gdept (ji,jj,jk) = (scosrf(ji,jj)+(hbatt(ji,jj)-rn_hc)*gsigt3(ji,jj,jk)+rn_hc*zcoeft)
+                gdepw (ji,jj,jk) = (scosrf(ji,jj)+(hbatt(ji,jj)-rn_hc)*gsigw3(ji,jj,jk)+rn_hc*zcoefw)
+                gdep3w(ji,jj,jk) = (scosrf(ji,jj)+(hbatt(ji,jj)-rn_hc)*gsi3w3(ji,jj,jk)+rn_hc*zcoeft)
+             END DO
+
+           ENDDO   ! for all jj's
+         ENDDO    ! for all ji's
+
+
+         DO ji=1,jpi
+           DO jj=1,jpj
+
+             DO jk = 1, jpk
+                esigtu3(ji,jj,jk) = ( hbatt(ji,jj)*esigt3(ji,jj,jk)+hbatt(ji+1,jj)*esigt3(ji+1,jj,jk) ) / &
+                                   ( hbatt(ji,jj)+hbatt(ji+1,jj) )
+                esigtv3(ji,jj,jk) = ( hbatt(ji,jj)*esigt3(ji,jj,jk)+hbatt(ji,jj+1)*esigt3(ji,jj+1,jk) ) / &
+                                   ( hbatt(ji,jj)+hbatt(ji,jj+1) )
+                esigtf3(ji,jj,jk) = ( hbatt(ji,jj)*esigt3(ji,jj,jk)+hbatt(ji+1,jj)*esigt3(ji+1,jj,jk) +  &
+                                     hbatt(ji,jj+1)*esigt3(ji,jj+1,jk)+hbatt(ji+1,jj+1)*esigt3(ji+1,jj+1,jk) ) / &
+                                   ( hbatt(ji,jj)+hbatt(ji+1,jj)+hbatt(ji,jj+1)+hbatt(ji+1,jj+1) )
+                esigwu3(ji,jj,jk) = ( hbatt(ji,jj)*esigw3(ji,jj,jk)+hbatt(ji+1,jj)*esigw3(ji+1,jj,jk) ) / &
+                                   ( hbatt(ji,jj)+hbatt(ji+1,jj) )
+                esigwv3(ji,jj,jk) = ( hbatt(ji,jj)*esigw3(ji,jj,jk)+hbatt(ji,jj+1)*esigw3(ji,jj+1,jk) ) / &
+                                   ( hbatt(ji,jj)+hbatt(ji,jj+1) )
+
+                e3t(ji,jj,jk)=((hbatt(ji,jj)-rn_hc)*esigt3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                e3u(ji,jj,jk)=((hbatu(ji,jj)-rn_hc)*esigtu3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                e3v(ji,jj,jk)=((hbatv(ji,jj)-rn_hc)*esigtv3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                e3f(ji,jj,jk)=((hbatf(ji,jj)-rn_hc)*esigtf3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                !
+                e3w (ji,jj,jk)=((hbatt(ji,jj)-rn_hc)*esigw3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                e3uw(ji,jj,jk)=((hbatu(ji,jj)-rn_hc)*esigwu3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+                e3vw(ji,jj,jk)=((hbatv(ji,jj)-rn_hc)*esigwv3(ji,jj,jk) + rn_hc/FLOAT(jpkm1))
+             END DO
+
+           ENDDO
+         ENDDO
+
+      ELSE   ! not ln_s_sigma
+
+         DO jk = 1, jpk
+           gsigw(jk) = -fssig( REAL(jk,wp)-0.5_wp )
+           gsigt(jk) = -fssig( REAL(jk,wp)     )
+         END DO
+         IF( nprint == 1 .AND. lwp ) WRITE(numout,*) 'gsigw 1 jpk    ', gsigw(1), gsigw(jpk)
+         !
+     ! Coefficients for vertical scale factors at w-, t- levels
+!!gm bug :  define it from analytical function, not like juste bellow....
+!!gm        or betteroffer the 2 possibilities....
+         DO jk = 1, jpkm1
+            esigt(jk  ) = gsigw(jk+1) - gsigw(jk)
+            esigw(jk+1) = gsigt(jk+1) - gsigt(jk)
+         END DO
+         esigw( 1 ) = 2.0_wp * (gsigt(1) - gsigw(1)) 
+         esigt(jpk) = 2.0_wp * (gsigt(jpk) - gsigw(jpk))
+
+!!gm  original form
+!!org DO jk = 1, jpk
+!!org    esigt(jk)=fsdsig( FLOAT(jk)     )
+!!org    esigw(jk)=fsdsig( FLOAT(jk)-0.5 )
+!!org END DO
+!!gm
+         !
+         ! Coefficients for vertical depth as the sum of e3w scale factors
+         gsi3w(1) = 0.5 * esigw(1)
+         DO jk = 2, jpk
+            gsi3w(jk) = gsi3w(jk-1) + esigw(jk)
+         END DO
+!!gm: depuw, depvw can be suppressed (modif in ldfslp) and depw=dep3w can be set (save 3 3D arrays)
+         DO jk = 1, jpk
+            zcoeft = ( FLOAT(jk) - 0.5 ) / FLOAT(jpkm1)
+            zcoefw = ( FLOAT(jk) - 1.0 ) / FLOAT(jpkm1)
+            gdept (:,:,jk) = (scosrf(:,:)+(hbatt(:,:)-hift(:,:))*gsigt(jk)+hift(:,:)*zcoeft)
+            gdepw (:,:,jk) = (scosrf(:,:)+(hbatt(:,:)-hift(:,:))*gsigw(jk)+hift(:,:)*zcoefw)
+            gdep3w(:,:,jk) = (scosrf(:,:)+(hbatt(:,:)-hift(:,:))*gsi3w(jk)+hift(:,:)*zcoeft)
+         END DO
+!!gm: e3uw, e3vw can be suppressed  (modif in dynzdf, dynzdf_iso, zdfbfr) (save 2 3D arrays)
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               DO jk = 1, jpk
+                 e3t(ji,jj,jk)=((hbatt(ji,jj)-hift(ji,jj))*esigt(jk) + hift(ji,jj)/FLOAT(jpkm1))
+                 e3u(ji,jj,jk)=((hbatu(ji,jj)-hifu(ji,jj))*esigt(jk) + hifu(ji,jj)/FLOAT(jpkm1))
+                 e3v(ji,jj,jk)=((hbatv(ji,jj)-hifv(ji,jj))*esigt(jk) + hifv(ji,jj)/FLOAT(jpkm1))
+                 e3f(ji,jj,jk)=((hbatf(ji,jj)-hiff(ji,jj))*esigt(jk) + hiff(ji,jj)/FLOAT(jpkm1))
+                 !
+                 e3w (ji,jj,jk)=((hbatt(ji,jj)-hift(ji,jj))*esigw(jk) + hift(ji,jj)/FLOAT(jpkm1))
+                 e3uw(ji,jj,jk)=((hbatu(ji,jj)-hifu(ji,jj))*esigw(jk) + hifu(ji,jj)/FLOAT(jpkm1))
+                 e3vw(ji,jj,jk)=((hbatv(ji,jj)-hifv(ji,jj))*esigw(jk) + hifv(ji,jj)/FLOAT(jpkm1))
+               END DO
+            END DO
+         END DO
+
+      ENDIF ! ln_s_sigma
+
+
+      !
+!!    H. Liu, POL. April 2009. Added for passing the scale check for the new released vvl code.
+
+      fsdept(:,:,:) = gdept (:,:,:)
+      fsdepw(:,:,:) = gdepw (:,:,:)
+      fsde3w(:,:,:) = gdep3w(:,:,:)
+      fse3t (:,:,:) = e3t   (:,:,:)
+      fse3u (:,:,:) = e3u   (:,:,:)
+      fse3v (:,:,:) = e3v   (:,:,:)
+      fse3f (:,:,:) = e3f   (:,:,:)
+      fse3w (:,:,:) = e3w   (:,:,:)
+      fse3uw(:,:,:) = e3uw  (:,:,:)
+      fse3vw(:,:,:) = e3vw  (:,:,:)
+!!
+      ! HYBRID : 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jk = 1, jpkm1
+               IF( scobot(ji,jj) >= fsdept(ji,jj,jk) )   mbathy(ji,jj) = MAX( 2, jk )
+               IF( scobot(ji,jj) == 0.e0             )   mbathy(ji,jj) = 0
+            END DO
+         END DO
+      END DO
+      IF( nprint == 1 .AND. lwp ) WRITE(numout,*) ' MIN val mbathy h90 ', MINVAL( mbathy(:,:) ),   &
+         &                                                       ' MAX ', MAXVAL( mbathy(:,:) )
+
+
+      !                                               ! ===========
+      IF( lzoom )   CALL zgr_bat_zoom                 ! Zoom domain 
+      !                                               ! ===========
+
+      !                                               ! =================== !
+      IF( .NOT. lk_c1d )   CALL zgr_bat_ctl           !   Bathymetry check  !
+      !                                               ! =================== !
+
+      !                                               ! =============
+      IF(lwp) THEN                                    ! Control print
+         !                                            ! =============
+         WRITE(numout,*) 
+         WRITE(numout,*) ' domzgr: vertical coefficients for model level'
+         WRITE(numout, "(9x,'  level    gsigt      gsigw      esigt      esigw      gsi3w')" )
+         WRITE(numout, "(10x,i4,5f11.4)" ) ( jk, gsigt(jk), gsigw(jk), esigt(jk), esigw(jk), gsi3w(jk), jk=1,jpk )
+      ENDIF
+      IF( nprint == 1  .AND. lwp )   THEN         ! min max values over the local domain
+         WRITE(numout,*) ' MIN val mbathy  ', MINVAL( mbathy(:,:)   ), ' MAX ', MAXVAL( mbathy(:,:) )
+         WRITE(numout,*) ' MIN val depth t ', MINVAL( fsdept(:,:,:) ),   &
+            &                          ' w ', MINVAL( fsdepw(:,:,:) ), '3w '  , MINVAL( fsde3w(:,:,:) )
+         WRITE(numout,*) ' MIN val e3    t ', MINVAL( fse3t (:,:,:) ), ' f '  , MINVAL( fse3f (:,:,:) ),   &
+            &                          ' u ', MINVAL( fse3u (:,:,:) ), ' u '  , MINVAL( fse3v (:,:,:) ),   &
+            &                          ' uw', MINVAL( fse3uw(:,:,:) ), ' vw'  , MINVAL( fse3vw(:,:,:) ),   &
+            &                          ' w ', MINVAL( fse3w (:,:,:) )
+
+         WRITE(numout,*) ' MAX val depth t ', MAXVAL( fsdept(:,:,:) ),   &
+            &                          ' w ', MAXVAL( fsdepw(:,:,:) ), '3w '  , MAXVAL( fsde3w(:,:,:) )
+         WRITE(numout,*) ' MAX val e3    t ', MAXVAL( fse3t (:,:,:) ), ' f '  , MAXVAL( fse3f (:,:,:) ),   &
+            &                          ' u ', MAXVAL( fse3u (:,:,:) ), ' u '  , MAXVAL( fse3v (:,:,:) ),   &
+            &                          ' uw', MAXVAL( fse3uw(:,:,:) ), ' vw'  , MAXVAL( fse3vw(:,:,:) ),   &
+            &                          ' w ', MAXVAL( fse3w (:,:,:) )
+      ENDIF
+      !
+      IF(lwp) THEN                                  ! selected vertical profiles
+         WRITE(numout,*)
+         WRITE(numout,*) ' domzgr: vertical coordinates : point (1,1,k) bathy = ', bathy(1,1), hbatt(1,1)
+         WRITE(numout,*) ' ~~~~~~  --------------------'
+         WRITE(numout,"(9x,' level   gdept    gdepw    gde3w     e3t      e3w  ')")
+         WRITE(numout,"(10x,i4,4f9.2)") ( jk, fsdept(1,1,jk), fsdepw(1,1,jk),     &
+            &                                 fse3t (1,1,jk), fse3w (1,1,jk), jk=1,jpk )
+         DO jj = mj0(20), mj1(20)
+            DO ji = mi0(20), mi1(20)
+               WRITE(numout,*)
+               WRITE(numout,*) ' domzgr: vertical coordinates : point (20,20,k)   bathy = ', bathy(ji,jj), hbatt(ji,jj)
+               WRITE(numout,*) ' ~~~~~~  --------------------'
+               WRITE(numout,"(9x,' level   gdept    gdepw    gde3w     e3t      e3w  ')")
+               WRITE(numout,"(10x,i4,4f9.2)") ( jk, fsdept(ji,jj,jk), fsdepw(ji,jj,jk),     &
+                  &                                 fse3t (ji,jj,jk), fse3w (ji,jj,jk), jk=1,jpk )
+            END DO
+         END DO
+         DO jj = mj0(74), mj1(74)
+            DO ji = mi0(100), mi1(100)
+               WRITE(numout,*)
+               WRITE(numout,*) ' domzgr: vertical coordinates : point (100,74,k)   bathy = ', bathy(ji,jj), hbatt(ji,jj)
+               WRITE(numout,*) ' ~~~~~~  --------------------'
+               WRITE(numout,"(9x,' level   gdept    gdepw    gde3w     e3t      e3w  ')")
+               WRITE(numout,"(10x,i4,4f9.2)") ( jk, fsdept(ji,jj,jk), fsdepw(ji,jj,jk),     &
+                  &                                 fse3t (ji,jj,jk), fse3w (ji,jj,jk), jk=1,jpk )
+            END DO
+         END DO
+      ENDIF
+
+!!gm bug?  no more necessary?  if ! defined key_helsinki
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fse3w(ji,jj,jk) <= 0. .OR. fse3t(ji,jj,jk) <= 0. ) THEN
+                  WRITE(ctmp1,*) 'zgr_sco :   e3w   or e3t   =< 0  at point (i,j,k)= ', ji, jj, jk
+                  CALL ctl_stop( ctmp1 )
+               ENDIF
+               IF( fsdepw(ji,jj,jk) < 0. .OR. fsdept(ji,jj,jk) < 0. ) THEN
+                  WRITE(ctmp1,*) 'zgr_sco :   gdepw or gdept =< 0  at point (i,j,k)= ', ji, jj, jk
+                  CALL ctl_stop( ctmp1 )
+               ENDIF
+            END DO
+         END DO
+      END DO
+!!gm bug    #endif
+      !
+   END SUBROUTINE zgr_sco
+
+#endif
+
+   !!======================================================================
+END MODULE domzgr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/domzgr_substitute.h90	(revision 1844)
@@ -0,0 +1,135 @@
+   !!----------------------------------------------------------------------
+   !!                    ***  domzgr_substitute.h90   ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsdep. and fse.., the vert. depth and scale
+   !!      factors depending on the vertical coord. used, using CPP macro.
+   !!----------------------------------------------------------------------
+   !! History :  1.0  !  2005-10  (A. Beckmann, G. Madec) generalisation to all coord.
+   !!            3.1  !  2009-02  (G. Madec, M. Leclair)  pure z* coordinate
+   !!----------------------------------------------------------------------
+#if defined key_zco
+! reference for pure z-coordinate (1D - no i,j and time dependency)
+#   define  fsdept_0(i,j,k)  gdept_0(k)
+#   define  fsdepw_0(i,j,k)  gdepw_0(k)
+#   define  fsde3w_0(i,j,k)  gdepw_0(k)
+#   define  fse3t_0(i,j,k)   e3t_0(k)
+#   define  fse3u_0(i,j,k)   e3t_0(k)
+#   define  fse3v_0(i,j,k)   e3t_0(k)
+#   define  fse3f_0(i,j,k)   e3t_0(k)
+#   define  fse3w_0(i,j,k)   e3w_0(k)
+#   define  fse3uw_0(i,j,k)  e3w_0(k)
+#   define  fse3vw_0(i,j,k)  e3w_0(k)
+#else
+! reference for s- or zps-coordinate (3D no time dependency)
+#   define  fsdept_0(i,j,k)  gdept(i,j,k)
+#   define  fsdepw_0(i,j,k)  gdepw(i,j,k)
+#   define  fsde3w_0(i,j,k)  gdep3w(i,j,k)
+#   define  fse3t_0(i,j,k)   e3t(i,j,k)
+#   define  fse3u_0(i,j,k)   e3u(i,j,k)
+#   define  fse3v_0(i,j,k)   e3v(i,j,k)
+#   define  fse3f_0(i,j,k)   e3f(i,j,k)
+#   define  fse3w_0(i,j,k)   e3w(i,j,k)
+#   define  fse3uw_0(i,j,k)  e3uw(i,j,k)
+#   define  fse3vw_0(i,j,k)  e3vw(i,j,k)
+#endif
+#if defined key_vvl
+! s* or z*-coordinate (3D + time dependency) + use of additional now arrays (..._1)
+#   define  fsdept(i,j,k)  gdept_1(i,j,k)
+#   define  fsdepw(i,j,k)  gdepw_1(i,j,k)
+#   define  fsde3w(i,j,k)  gdep3w_1(i,j,k)
+#   define  fse3t(i,j,k)   e3t_1(i,j,k)
+#   define  fse3u(i,j,k)   e3u_1(i,j,k)
+#   define  fse3v(i,j,k)   e3v_1(i,j,k)
+#   define  fse3f(i,j,k)   e3f_1(i,j,k)
+#   define  fse3w(i,j,k)   e3w_1(i,j,k)
+#   define  fse3uw(i,j,k)  e3uw_1(i,j,k)
+#   define  fse3vw(i,j,k)  e3vw_1(i,j,k)
+
+#   define  fsdept_b(i,j,k)  (fsdept_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fsdepw_b(i,j,k)  (fsdepw_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fsde3w_b(i,j,k)  (fsde3w_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k))-sshb(i,j))
+#   define  fse3t_b(i,j,k)   (fse3t_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fse3u_b(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_b(i,j)*muu(i,j,k)))
+#   define  fse3v_b(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_b(i,j)*muv(i,j,k)))
+#   define  fse3f_b(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_b(i,j)*muf(i,j,k)))
+#   define  fse3w_b(i,j,k)   (fse3w_0(i,j,k)*(1.+sshb(i,j)*mut(i,j,k)))
+#   define  fse3uw_b(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_b(i,j)*muu(i,j,k)))
+#   define  fse3vw_b(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_b(i,j)*muv(i,j,k)))
+
+#   define  fsdept_n(i,j,k)  (fsdept_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fsdepw_n(i,j,k)  (fsdepw_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fsde3w_n(i,j,k)  (fsde3w_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k))-sshn(i,j))
+#   define  fse3t_n(i,j,k)   (fse3t_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fse3u_n(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_n(i,j)*muu(i,j,k)))
+#   define  fse3v_n(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_n(i,j)*muv(i,j,k)))
+#   define  fse3f_n(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_n(i,j)*muf(i,j,k)))
+#   define  fse3w_n(i,j,k)   (fse3w_0(i,j,k)*(1.+sshn(i,j)*mut(i,j,k)))
+#   define  fse3uw_n(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_n(i,j)*muu(i,j,k)))
+#   define  fse3vw_n(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_n(i,j)*muv(i,j,k)))
+
+#   define  fse3t_m(i,j,k)   (fse3t_0(i,j,k)*(1.+ssh_m(i,j)*mut(i,j,k)))
+
+#   define  fsdept_a(i,j,k)  (fsdept_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fsdepw_a(i,j,k)  (fsdepw_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fsde3w_a(i,j,k)  (fsde3w_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k))-ssha(i,j))
+#   define  fse3t_a(i,j,k)   (fse3t_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fse3u_a(i,j,k)   (fse3u_0(i,j,k)*(1.+sshu_a(i,j)*muu(i,j,k)))
+#   define  fse3v_a(i,j,k)   (fse3v_0(i,j,k)*(1.+sshv_a(i,j)*muv(i,j,k)))
+#   define  fse3f_a(i,j,k)   (fse3f_0(i,j,k)*(1.+sshf_a(i,j)*muf(i,j,k)))
+#   define  fse3w_a(i,j,k)   (fse3w_0(i,j,k)*(1.+ssha(i,j)*mut(i,j,k)))
+#   define  fse3uw_a(i,j,k)  (fse3uw_0(i,j,k)*(1.+sshu_a(i,j)*muu(i,j,k)))
+#   define  fse3vw_a(i,j,k)  (fse3vw_0(i,j,k)*(1.+sshv_a(i,j)*muv(i,j,k)))
+
+#else
+! z- or s-coordinate (1D or 3D + no time dependency) use reference in all cases
+#   define  fsdept(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fsdept_b(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_b(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_b(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_b(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_b(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_b(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_b(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_b(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_b(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_b(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fsdept_n(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_n(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_n(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_n(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_n(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_n(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_n(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_n(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_n(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_n(i,j,k)  fse3vw_0(i,j,k)
+
+#   define  fse3t_m(i,j,k)   fse3t_0(i,j,k)
+
+#   define  fsdept_a(i,j,k)  fsdept_0(i,j,k)
+#   define  fsdepw_a(i,j,k)  fsdepw_0(i,j,k)
+#   define  fsde3w_a(i,j,k)  fsde3w_0(i,j,k)
+#   define  fse3t_a(i,j,k)   fse3t_0(i,j,k)
+#   define  fse3u_a(i,j,k)   fse3u_0(i,j,k)
+#   define  fse3v_a(i,j,k)   fse3v_0(i,j,k)
+#   define  fse3f_a(i,j,k)   fse3f_0(i,j,k)
+#   define  fse3w_a(i,j,k)   fse3w_0(i,j,k)
+#   define  fse3uw_a(i,j,k)  fse3uw_0(i,j,k)
+#   define  fse3vw_a(i,j,k)  fse3vw_0(i,j,k)
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/phycst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/phycst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DOM/phycst.F90	(revision 1844)
@@ -0,0 +1,197 @@
+MODULE phycst
+   !!======================================================================
+   !!                    ***  MODULE  phycst  ***
+   !!     Definition of of both ocean and ice parameters used in the code
+   !!=====================================================================
+   !! History :        !  90-10  (C. Levy - G. Madec)  Original code
+   !!                  !  91-11  (G. Madec)
+   !!                  !  91-12  (M. Imbard)
+   !!             8.5  !  02-08  (G. Madec, C. Ethe)  F90, add ice constants
+   !!             9.0  !  06-08  (G. Madec)  style 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   phy_cst  : define and print physical constant and domain parameters
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+   USE in_out_manager   ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   phy_cst     ! routine called by inipar.F90
+
+   REAL(wp), PUBLIC ::   rpi = 3.141592653589793_wp             !: pi
+   REAL(wp), PUBLIC ::   rad = 3.141592653589793_wp / 180._wp   !: conversion from degre into radian
+   REAL(wp), PUBLIC ::   rsmall = 0.5 * EPSILON( 1. )           !: smallest real computer value
+   
+   REAL(wp), PUBLIC ::          & !:
+      rday = 24.*60.*60.  ,     & !: day (s)
+      rsiyea              ,     & !: sideral year (s)
+      rsiday              ,     & !: sideral day (s)
+      raamo =  12._wp     ,     & !: number of months in one year
+      rjjhh =  24._wp     ,     & !: number of hours in one day
+      rhhmm =  60._wp     ,     & !: number of minutes in one hour
+      rmmss =  60._wp     ,     & !: number of seconds in one minute
+!!!   omega = 7.292115083046061e-5_wp ,  &  !: change the last digit!
+      omega               ,    &  !: earth rotation parameter
+      ra    = 6371229._wp ,    &  !: earth radius (meter)
+      grav  = 9.80665_wp          !: gravity (m/s2)
+   
+   REAL(wp), PUBLIC ::         &  !:
+      rtt      = 273.16_wp  ,  &  !: triple point of temperature (Kelvin)
+      rt0      = 273.15_wp  ,  &  !: freezing point of water (Kelvin)
+#if defined key_lim3
+      rt0_snow = 273.16_wp  ,  &  !: melting point of snow  (Kelvin)
+      rt0_ice  = 273.16_wp  ,  &  !: melting point of ice   (Kelvin)
+#else
+      rt0_snow = 273.15_wp  ,  &  !: melting point of snow  (Kelvin)
+      rt0_ice  = 273.05_wp  ,  &  !: melting point of ice   (Kelvin)
+#endif
+      rau0     = 1035._wp   ,  &  !: volumic mass of reference (kg/m3)
+      rauw     = 1000._wp   ,  &  !: volumic mass of pure water (kg/m3)
+      rcp      =    4.e+3_wp,  &  !: ocean specific heat
+      ro0cpr                      !: = 1. / ( rau0 * rcp )
+
+   REAL(wp), PUBLIC ::            &  !:
+#if defined key_lim3
+      rcdsn   =   0.31_wp     ,   &  !: thermal conductivity of snow
+      rcdic   =   2.034396_wp ,   &  !: thermal conductivity of fresh ice
+      cpic    = 2067.0        ,   &
+      ! add the following lines
+      lsub    = 2.834e+6      ,   &  !: pure ice latent heat of sublimation (J.kg-1)
+      lfus    = 0.334e+6      ,   &  !: latent heat of fusion of fresh ice   (J.kg-1)
+      rhoic   = 917._wp       ,   &  !: volumic mass of sea ice (kg/m3)
+      tmut    =   0.054       ,   &  !: decrease of seawater meltpoint with salinity
+#else
+      rcdsn   =   0.22_wp     ,   &  !: conductivity of the snow
+      rcdic   =   2.034396_wp ,   &  !: conductivity of the ice
+      rcpsn   =   6.9069e+5_wp,   &  !: density times specific heat for snow
+      rcpic   =   1.8837e+6_wp,   &  !: volumetric latent heat fusion of sea ice
+      xlsn    = 110.121e+6_wp ,   &  !: volumetric latent heat fusion of snow
+      xlic    = 300.33e+6_wp  ,   &  !: volumetric latent heat fusion of ice
+      xsn     =   2.8e+6      ,   &  !: latent heat of sublimation of snow
+      rhoic   = 900._wp       ,   &  !: volumic mass of sea ice (kg/m3)
+#endif
+      rhosn   = 330._wp       ,   &  !: volumic mass of snow (kg/m3)
+      emic    =   0.97_wp     ,   &  !: emissivity of snow or ice
+      sice    =   6.0_wp      ,   &  !: salinity of ice (psu)
+      soce    =  34.7_wp      ,   &  !: salinity of sea (psu)
+      cevap   =   2.5e+6_wp   ,   &  !: latent heat of evaporation (water)
+      srgamma =   0.9_wp      ,   &  !: correction factor for solar radiation (Oberhuber, 1974)
+      vkarmn  =   0.4_wp      ,   &  !: von Karman constant
+      stefan  =   5.67e-8_wp         !: Stefan-Boltzmann constant 
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+   
+CONTAINS
+   
+   SUBROUTINE phy_cst
+      !!----------------------------------------------------------------------
+      !!                       ***  ROUTINE phy_cst  ***
+      !!
+      !! ** Purpose :   Print model parameters and set and print the constants
+      !!----------------------------------------------------------------------
+      CHARACTER (len=64) ::   cform = "(A12, 3(A13, I7) )" 
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' phy_cst : initialization of ocean parameters and constants'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+
+      ! Ocean Parameters
+      ! ----------------
+      IF(lwp) THEN
+         WRITE(numout,*) '       Domain info'
+         WRITE(numout,*) '          dimension of model'
+         WRITE(numout,*) '                 Local domain      Global domain       Data domain '
+         WRITE(numout,cform) '            ','   jpi     : ', jpi, '   jpiglo  : ', jpiglo, '   jpidta  : ', jpidta
+         WRITE(numout,cform) '            ','   jpj     : ', jpj, '   jpjglo  : ', jpjglo, '   jpjdta  : ', jpjdta
+         WRITE(numout,cform) '            ','   jpk     : ', jpk, '   jpk     : ', jpk   , '   jpkdta  : ', jpkdta
+         WRITE(numout,*)      '           ','   jpij    : ', jpij
+         WRITE(numout,*) '          mpp local domain info (mpp)'
+         WRITE(numout,*) '             jpni    : ', jpni, '   jpreci  : ', jpreci
+         WRITE(numout,*) '             jpnj    : ', jpnj, '   jprecj  : ', jprecj
+         WRITE(numout,*) '             jpnij   : ', jpnij
+         WRITE(numout,*) '          lateral domain boundary condition type : jperio  = ', jperio
+      ENDIF
+
+      ! Define constants
+      ! ----------------
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '       Constants'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          mathematical constant                 rpi = ', rpi
+
+      rsiyea = 365.25 * rday * 2. * rpi / 6.283076
+      rsiday = rday / ( 1. + rday / rsiyea )
+      omega  = 2. * rpi / rsiday 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          day                                rday   = ', rday,   ' s'
+      IF(lwp) WRITE(numout,*) '          sideral year                       rsiyea = ', rsiyea, ' s'
+      IF(lwp) WRITE(numout,*) '          sideral day                        rsiday = ', rsiday, ' s'
+      IF(lwp) WRITE(numout,*) '          omega                              omega  = ', omega,  ' s-1'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          nb of months per year               raamo = ', raamo, ' months'
+      IF(lwp) WRITE(numout,*) '          nb of hours per day                 rjjhh = ', rjjhh, ' hours'
+      IF(lwp) WRITE(numout,*) '          nb of minutes per hour              rhhmm = ', rhhmm, ' mn'
+      IF(lwp) WRITE(numout,*) '          nb of seconds per minute            rmmss = ', rmmss, ' s'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          earth radius                         ra   = ', ra, ' m'
+      IF(lwp) WRITE(numout,*) '          gravity                              grav = ', grav , ' m/s^2'
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          triple point of temperature      rtt      = ', rtt     , ' K'
+      IF(lwp) WRITE(numout,*) '          freezing point of water          rt0      = ', rt0     , ' K'
+      IF(lwp) WRITE(numout,*) '          melting point of snow            rt0_snow = ', rt0_snow, ' K'
+      IF(lwp) WRITE(numout,*) '          melting point of ice             rt0_ice  = ', rt0_ice , ' K'
+
+      ro0cpr = 1. / ( rau0 * rcp )
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          volumic mass of pure water         rauw   = ', rauw, ' kg/m^3'
+      IF(lwp) WRITE(numout,*) '          volumic mass of reference          rau0   = ', rau0, ' kg/m^3'
+      IF(lwp) WRITE(numout,*) '          ocean specific heat                rcp    = ', rcp
+      IF(lwp) WRITE(numout,*) '                       1. / ( rau0 * rcp ) = ro0cpr = ', ro0cpr
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '          thermal conductivity of the snow          = ', rcdsn   , ' J/s/m/K'
+         WRITE(numout,*) '          thermal conductivity of the ice           = ', rcdic   , ' J/s/m/K'
+#if defined key_lim3
+         WRITE(numout,*) '          fresh ice specific heat                   = ', cpic    , ' J/kg/K'
+         WRITE(numout,*) '          latent heat of fusion of fresh ice / snow = ', lfus    , ' J/kg'
+         WRITE(numout,*) '          latent heat of subl.  of fresh ice / snow = ', lsub    , ' J/kg'
+#else
+         WRITE(numout,*) '          density times specific heat for snow      = ', rcpsn   , ' J/m^3/K' 
+         WRITE(numout,*) '          density times specific heat for ice       = ', rcpic   , ' J/m^3/K'
+         WRITE(numout,*) '          volumetric latent heat fusion of sea ice  = ', xlic    , ' J/m' 
+         WRITE(numout,*) '          volumetric latent heat fusion of snow     = ', xlsn    , ' J/m' 
+         WRITE(numout,*) '          latent heat of sublimation of snow        = ', xsn     , ' J/kg' 
+#endif
+         WRITE(numout,*) '          density of sea ice                        = ', rhoic   , ' kg/m^3'
+         WRITE(numout,*) '          density of snow                           = ', rhosn   , ' kg/m^3'
+         WRITE(numout,*) '          emissivity of snow or ice                 = ', emic  
+         WRITE(numout,*) '          salinity of ice                           = ', sice    , ' psu'
+         WRITE(numout,*) '          salinity of sea                           = ', soce    , ' psu'
+         WRITE(numout,*) '          latent heat of evaporation (water)        = ', cevap   , ' J/m^3' 
+         WRITE(numout,*) '          correction factor for solar radiation     = ', srgamma 
+         WRITE(numout,*) '          von Karman constant                       = ', vkarmn 
+         WRITE(numout,*) '          Stefan-Boltzmann constant                 = ', stefan  , ' J/s/m^2/K^4'
+
+         WRITE(numout,*)
+         WRITE(numout,*) '          conversion: degre ==> radian          rad = ', rad
+
+         WRITE(numout,*)
+         WRITE(numout,*) '          smallest real computer value       rsmall = ', rsmall
+      ENDIF
+
+   END SUBROUTINE phy_cst
+
+   !!======================================================================
+END MODULE phycst
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtasal.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtasal.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtasal.F90	(revision 1844)
@@ -0,0 +1,319 @@
+MODULE dtasal
+   !!======================================================================
+   !!                     ***  MODULE  dtasal  ***
+   !! Ocean data  :  read ocean salinity data from monthly atlas data
+   !!=====================================================================
+#if defined key_dtasal   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_dtasal'                                          salinity data
+   !!----------------------------------------------------------------------
+   !!   dta_sal      : read ocean salinity data
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+#if defined key_orca_lev10
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dta_sal   ! called by step.F90 and inidta.F90
+   
+   !! * Shared module variables
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtasal = .TRUE.    !: salinity data flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      s_dta       !: salinity data at given time-step
+
+   !! * Module variables
+   INTEGER ::   &
+      numsdt,           &  !: logical unit for data salinity
+      nsal1, nsal2         ! first and second record used
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      saldta    ! salinity data at two consecutive times
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!   Default option:                                         NetCDF file
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE dta_sal( kt )
+     !!----------------------------------------------------------------------
+     !!                   ***  ROUTINE dta_sal  ***
+     !!        
+     !! ** Purpose :   Reads monthly salinity data
+     !!             
+     !! ** Method  : - Read on unit numsdt the monthly salinity data interpo-
+     !!     lated onto the model grid.
+     !!              - At each time step, a linear interpolation is applied
+     !!     between two monthly values.
+     !!
+     !! History :
+     !!        !  91-03  ()  Original code
+     !!        !  92-07  (M. Imbard)
+     !!   9.0  !  02-06  (G. Madec)  F90: Free form and module 
+     !!----------------------------------------------------------------------
+     !! * Modules used
+     USE iom
+     
+     !! * Arguments
+     INTEGER, INTENT(in) ::   kt             ! ocean time step
+     
+     !! * Local declarations
+     
+     INTEGER ::   ji, jj, jk, jl, jkk   ! dummy loop indicies
+     INTEGER ::   &
+          imois, iman, i15, ik           ! temporary integers
+#  if defined key_tradmp
+     INTEGER ::   &
+          il0, il1, ii0, ii1, ij0, ij1   ! temporary integers         
+# endif
+     REAL(wp) ::   zxy, zl
+#if defined key_orca_lev10
+     REAL(wp), DIMENSION(jpi,jpj,jpkdta,2) :: zsal
+     INTEGER   :: ikr, ikw, ikt, jjk
+     REAL(wp)  :: zfac
+#endif
+     REAL(wp), DIMENSION(jpk,2) ::   &
+          zsaldta            ! auxiliary array for interpolation
+     !!----------------------------------------------------------------------
+     
+     ! 0. Initialization
+     ! -----------------
+     
+     iman  = INT( raamo )
+!!! better but change the results     i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) )
+     i15   = nday / 16
+     imois = nmonth + i15 - 1
+     IF( imois == 0 ) imois = iman
+     
+     ! 1. First call kt=nit000
+     ! -----------------------
+     
+     IF( kt == nit000 ) THEN
+        
+        nsal1 = 0   ! initializations
+        IF(lwp) WRITE(numout,*) ' dta_sal : monthly salinity data in NetCDF file'
+        CALL iom_open ( 'data_1m_salinity_nomask', numsdt ) 
+        
+     ENDIF
+     
+     
+     ! 2. Read monthly file
+     ! -------------------
+     
+     IF( kt == nit000 .OR. imois /= nsal1 ) THEN
+        
+        ! 2.1 Calendar computation
+        
+        nsal1 = imois        ! first file record used 
+        nsal2 = nsal1 + 1    ! last  file record used
+        nsal1 = MOD( nsal1, iman )
+        IF( nsal1 == 0 ) nsal1 = iman
+        nsal2 = MOD( nsal2, iman )
+        IF( nsal2 == 0 ) nsal2 = iman
+        IF(lwp) WRITE(numout,*) 'first record file used nsal1 ', nsal1
+        IF(lwp) WRITE(numout,*) 'last  record file used nsal2 ', nsal2
+        
+        ! 2.3 Read monthly salinity data Levitus 
+        
+#if defined key_orca_lev10
+        if (ln_zps) stop
+        zsal(:,:,:,:) = 0.
+        CALL iom_get (numsdt,jpdom_data,'vosaline',zsal(:,:,:,1),nsal1)
+        CALL iom_get (numsdt,jpdom_data,'vosaline',zsal(:,:,:,2),nsal2)
+#else
+        CALL iom_get (numsdt,jpdom_data,'vosaline',saldta(:,:,:,1),nsal1)
+        CALL iom_get (numsdt,jpdom_data,'vosaline',saldta(:,:,:,2),nsal2)
+#endif
+        
+        IF(lwp) THEN
+           WRITE(numout,*)
+           WRITE(numout,*) ' read Levitus salinity ok'
+           WRITE(numout,*)
+        ENDIF
+        
+#if defined key_tradmp
+        IF( cp_cfg == "orca"  .AND. jp_cfg == 2 ) THEN
+           
+           !                                        ! =======================
+           !                                        !  ORCA_R2 configuration
+           !                                        ! =======================
+           ij0 = 101   ;   ij1 = 109
+           ii0 = 141   ;   ii1 = 155   
+           DO jj = mj0(ij0), mj1(ij1)                  ! Reduced salinity in the Alboran Sea
+              DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                 zsal  (ji,jj,13:13,:) = zsal  (ji,jj,13:13,:) - 0.15
+                 zsal  (ji,jj,14:15,:) = zsal  (ji,jj,14:15,:) - 0.25
+                 zsal  (ji,jj,16:17,:) = zsal  (ji,jj,16:17,:) - 0.30
+                 zsal  (ji,jj,18:25,:) = zsal  (ji,jj,18:25,:) - 0.35
+#else
+                 saldta(ji,jj,13:13,:) = saldta(ji,jj,13:13,:) - 0.15
+                 saldta(ji,jj,14:15,:) = saldta(ji,jj,14:15,:) - 0.25
+                 saldta(ji,jj,16:17,:) = saldta(ji,jj,16:17,:) - 0.30
+                 saldta(ji,jj,18:25,:) = saldta(ji,jj,18:25,:) - 0.35
+#endif
+              END DO
+           END DO
+
+           IF( n_cla == 1 ) THEN 
+              !                                         ! New salinity profile at Gibraltar
+              il0 = 138   ;   il1 = 138   
+              ij0 = 101   ;   ij1 = 102
+              ii0 = 139   ;   ii1 = 139   
+              DO jl = mi0(il0), mi1(il1)
+                 DO jj = mj0(ij0), mj1(ij1)
+                    DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                       zsal  (ji,jj,:,:) = zsal  (jl,jj,:,:)
+#else
+                       saldta(ji,jj,:,:) = saldta(jl,jj,:,:)
+#endif
+                    END DO
+                 END DO
+              END DO
+              !                                         ! New salinity profile at Bab el Mandeb
+              il0 = 164   ;   il1 = 164   
+              ij0 =  87   ;   ij1 =  88
+              ii0 = 161   ;   ii1 = 163   
+              DO jl = mi0(il0), mi1(il1)
+                 DO jj = mj0(ij0), mj1(ij1)
+                    DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                       zsal  (ji,jj,:,:) = zsal  (jl,jj,:,:)
+#else
+                       saldta(ji,jj,:,:) = saldta(jl,jj,:,:)
+#endif
+                    END DO
+                 END DO
+              END DO
+              !
+           ENDIF
+           !
+        ENDIF
+#endif   
+        
+#if defined key_orca_lev10
+        !  interpolate from 31 to 301 level the zsal field result in saldta
+        DO jl = 1, 2
+           DO jjk = 1, 5
+              saldta(:,:,jjk,jl) = zsal(:,:,1,jl)
+           ENDDO
+           DO jk = 1, jpk - 20, 10
+              ikr = INT( jk / 10 ) + 1
+              ikw = (ikr-1) * 10 + 1
+              ikt = ikw + 5
+              DO jjk = ikt , ikt + 9
+                 zfac = ( gdept_0(jjk) - gdepw_0(ikt) ) / ( gdepw_0(ikt+10) - gdepw_0(ikt) )
+                 saldta(:,:,jjk,jl) = zsal(:,:,ikr,jl) + ( zsal(:,:,ikr+1,jl) - zsal(:,:,ikr,jl) ) * zfac
+              END DO
+           END DO
+           DO jjk = jpk-5, jpk
+              saldta(:,:,jjk,jl) = zsal(:,:,jpkdta-1,jl)
+           END DO
+           ! fill the overlap areas
+           CALL lbc_lnk (saldta(:,:,:,jl),'Z',-999.,'no0')
+        END DO
+        
+#endif
+        
+        IF( ln_sco ) THEN
+           DO jl = 1, 2
+              DO jj = 1, jpj                  ! interpolation of salinites
+                 DO ji = 1, jpi
+                    DO jk = 1, jpk
+                       zl=fsdept_0(ji,jj,jk)
+                       IF(zl <  gdept_0(1)) zsaldta(jk,jl) =  saldta(ji,jj,1,jl)
+                       IF(zl >  gdept_0(jpk)) zsaldta(jk,jl) =  saldta(ji,jj,jpkm1,jl)
+                       DO jkk = 1, jpkm1
+                          IF((zl-gdept_0(jkk))*(zl-gdept_0(jkk+1)).le.0.0) THEN
+                             zsaldta(jk,jl) = saldta(ji,jj,jkk,jl)                                  &
+                                  &           + (zl-gdept_0(jkk))/(gdept_0(jkk+1)-gdept_0(jkk))       &
+                                  &                              *(saldta(ji,jj,jkk+1,jl) - saldta(ji,jj,jkk,jl))
+                          ENDIF
+                       END DO
+                    END DO
+                    DO jk = 1, jpkm1
+                       saldta(ji,jj,jk,jl) = zsaldta(jk,jl)
+                    END DO
+                    saldta(ji,jj,jpk,jl) = 0.0
+                 END DO
+              END DO
+           END DO
+           
+           IF(lwp) WRITE(numout,*)
+           IF(lwp) WRITE(numout,*) ' Levitus salinity data interpolated to s-coordinate'
+           IF(lwp) WRITE(numout,*)
+           
+        ELSE
+           !                                  ! Mask
+           DO jl = 1, 2
+              saldta(:,:,:,jl) = saldta(:,:,:,jl)*tmask(:,:,:)
+              saldta(:,:,jpk,jl) = 0.
+              IF( ln_zps ) THEN               ! z-coord. partial steps
+                 DO jj = 1, jpj               ! interpolation of salinity at the last ocean level (i.e. the partial step)
+                    DO ji = 1, jpi
+                       ik = mbathy(ji,jj) - 1
+                       IF( ik > 2 ) THEN
+                          zl = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
+                          saldta(ji,jj,ik,jl) = (1.-zl) * saldta(ji,jj,ik,jl) +zl * saldta(ji,jj,ik-1,jl)
+                       ENDIF
+                    END DO
+                 END DO
+              ENDIF
+           END DO
+        ENDIF
+        
+        
+        IF(lwp) THEN
+           WRITE(numout,*)' salinity Levitus month ',nsal1,nsal2
+           WRITE(numout,*)
+           WRITE(numout,*) ' Levitus month = ',nsal1,'  level = 1'
+           CALL prihre(saldta(:,:,1,1),jpi,jpj,1,jpi,20,1,jpj,20,1.,numout)
+           WRITE(numout,*) ' Levitus month = ',nsal1,'  level = ',jpk/2
+           CALL prihre(saldta(:,:,jpk/2,1),jpi,jpj,1,jpi,20,1,jpj,20,1.,numout)
+           WRITE(numout,*) ' Levitus month = ',nsal1,'  level = ',jpkm1
+           CALL prihre(saldta(:,:,jpkm1,1),jpi,jpj,1,jpi,20,1,jpj,20,1.,numout)
+        ENDIF
+     ENDIF
+     
+     
+     ! 3. At every time step compute salinity data
+     ! -------------------------------------------
+     
+     zxy = FLOAT(nday + 15 - 30*i15)/30.
+     s_dta(:,:,:) = ( 1.- zxy ) * saldta(:,:,:,1) + zxy * saldta(:,:,:,2)
+     
+     ! Close the file
+     ! --------------
+     
+     IF( kt == nitend )   CALL iom_close (numsdt)
+
+   END SUBROUTINE dta_sal
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option:                                    NO salinity data
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtasal = .FALSE.   !: salinity data flag
+CONTAINS
+   SUBROUTINE dta_sal( kt )        ! Empty routine
+      WRITE(*,*) 'dta_sal: You should not have seen this print! error?', kt
+   END SUBROUTINE dta_sal
+#endif
+   !!======================================================================
+END MODULE dtasal
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtatem.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 1844)
@@ -0,0 +1,334 @@
+MODULE dtatem
+   !!======================================================================
+   !!                     ***  MODULE  dtatem  ***
+   !! Ocean data  :  read ocean temperature data from monthly atlas data
+   !!=====================================================================
+#if defined key_dtatem   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_dtatem'                              3D temperature data field
+   !!----------------------------------------------------------------------
+   !!   dta_tem      : read ocean temperature data
+   !!---l-------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+#if defined key_orca_lev10
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+#endif
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dta_tem   ! called by step.F90 and inidta.F90
+
+   !! * Shared module variables
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtatem = .TRUE.   !: temperature data flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      t_dta             !: temperature data at given time-step
+
+   !! * Module variables
+   INTEGER ::   &
+      numtdt,        &  !: logical unit for data temperature
+      ntem1, ntem2  ! first and second record used
+   REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   &
+      temdta            ! temperature data at two consecutive times
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!   Default case                                            NetCDF file
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE dta_tem( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dta_tem  ***
+      !!                    
+      !! ** Purpose :   Reads monthly temperature data 
+      !! 
+      !! ** Method  :   Read on unit numtdt the interpolated temperature 
+      !!      onto the model grid.
+      !!      Data begin at january. 
+      !!      The value is centered at the middle of month.
+      !!      In the opa model, kt=1 agree with january 1.
+      !!      At each time step, a linear interpolation is applied between 
+      !!      two monthly values.
+      !!      Read on unit numtdt
+      !!
+      !! ** Action  :   define t_dta array at time-step kt
+      !!
+      !! History :
+      !!        !  91-03  ()  Original code
+      !!        !  92-07  (M. Imbard)
+      !!        !  99-10  (M.A. Foujols, M. Imbard)  NetCDF FORMAT 
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jl, jk, jkk       ! dummy loop indicies
+      INTEGER ::   &
+         imois, iman, i15 , ik      ! temporary integers
+#  if defined key_tradmp
+      INTEGER ::   &
+         il0, il1, ii0, ii1, ij0, ij1   ! temporary integers
+# endif
+      REAL(wp) ::   zxy, zl
+#if defined key_orca_lev10
+      REAL(wp), DIMENSION(jpi,jpj,jpkdta,2) :: ztem
+      INTEGER   :: ikr, ikw, ikt, jjk 
+      REAL(wp)  :: zfac
+#endif
+      REAL(wp), DIMENSION(jpk,2) ::   &
+         ztemdta            ! auxiliary array for interpolation
+      !!----------------------------------------------------------------------
+      
+      ! 0. Initialization
+      ! -----------------
+      
+      iman  = INT( raamo )
+!!! better but change the results     i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) )
+      i15   = nday / 16
+      imois = nmonth + i15 - 1
+      IF( imois == 0 ) imois = iman
+      
+      ! 1. First call kt=nit000
+      ! -----------------------
+      
+      IF( kt == nit000 ) THEN
+         
+         ntem1= 0   ! initializations
+         IF(lwp) WRITE(numout,*) ' dta_tem : Levitus monthly fields'
+         CALL iom_open ( 'data_1m_potential_temperature_nomask', numtdt ) 
+         
+      ENDIF
+      
+      
+      ! 2. Read monthly file
+      ! -------------------
+      
+      IF( kt == nit000 .OR. imois /= ntem1 ) THEN
+         
+         ! Calendar computation
+         
+         ntem1 = imois        ! first file record used 
+         ntem2 = ntem1 + 1    ! last  file record used
+         ntem1 = MOD( ntem1, iman )
+         IF( ntem1 == 0 )   ntem1 = iman
+         ntem2 = MOD( ntem2, iman )
+         IF( ntem2 == 0 )   ntem2 = iman
+         IF(lwp) WRITE(numout,*) 'first record file used ntem1 ', ntem1
+         IF(lwp) WRITE(numout,*) 'last  record file used ntem2 ', ntem2
+         
+         ! Read monthly temperature data Levitus 
+         
+#if defined key_orca_lev10
+         if (ln_zps) stop
+         ztem(:,:,:,:) = 0.
+         CALL iom_get (numtdt,jpdom_data,'votemper',ztem(:,:,:,1),ntem1)
+         CALL iom_get (numtdt,jpdom_data,'votemper',ztem(:,:,:,2),ntem2)
+#else         
+         CALL iom_get (numtdt,jpdom_data,'votemper',temdta(:,:,:,1),ntem1)
+         CALL iom_get (numtdt,jpdom_data,'votemper',temdta(:,:,:,2),ntem2)
+#endif
+         
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' read Levitus temperature ok'
+         IF(lwp) WRITE(numout,*)
+         
+#if defined key_tradmp
+         IF( cp_cfg == "orca"  .AND. jp_cfg == 2 ) THEN
+            
+            !                                        ! =======================
+            !                                        !  ORCA_R2 configuration
+            !                                        ! ======================= 
+            ij0 = 101   ;   ij1 = 109
+            ii0 = 141   ;   ii1 = 155
+            DO jj = mj0(ij0), mj1(ij1)                      ! Reduced temperature in the Alboran Sea
+               DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                  ztem(  ji,jj, 13:13 ,:) = ztem  (ji,jj, 13:13 ,:) - 0.20
+                  ztem  (ji,jj, 14:15 ,:) = ztem  (ji,jj, 14:15 ,:) - 0.35
+                  ztem  (ji,jj, 16:25 ,:) = ztem  (ji,jj, 16:25 ,:) - 0.40
+#else
+                  temdta(ji,jj, 13:13 ,:) = temdta(ji,jj, 13:13 ,:) - 0.20
+                  temdta(ji,jj, 14:15 ,:) = temdta(ji,jj, 14:15 ,:) - 0.35
+                  temdta(ji,jj, 16:25 ,:) = temdta(ji,jj, 16:25 ,:) - 0.40
+#endif
+               END DO
+            END DO
+            
+            IF( n_cla == 1 ) THEN 
+               !                                         ! New temperature profile at Gibraltar
+               il0 = 138   ;   il1 = 138
+               ij0 = 101   ;   ij1 = 102
+               ii0 = 139   ;   ii1 = 139
+               DO jl = mi0(il0), mi1(il1)
+                  DO jj = mj0(ij0), mj1(ij1)
+                     DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                        ztem  (ji,jj,:,:) = ztem  (jl,jj,:,:)
+#else
+                        temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
+#endif
+                     END DO
+                  END DO
+               END DO
+               !                                         ! New temperature profile at Bab el Mandeb
+               il0 = 164   ;   il1 = 164
+               ij0 =  87   ;   ij1 =  88
+               ii0 = 161   ;   ii1 = 163
+               DO jl = mi0(il0), mi1(il1)
+                  DO jj = mj0(ij0), mj1(ij1)
+                     DO ji = mi0(ii0), mi1(ii1)
+#if defined key_orca_lev10
+                        ztem  (ji,jj,:,:) = ztem  (jl,jj,:,:)
+#else
+                        temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
+#endif
+                     END DO
+                  END DO
+               END DO
+               !
+            ELSE
+               !                                         ! Reduced temperature at Red Sea
+               ij0 =  87   ;   ij1 =  96
+               ii0 = 148   ;   ii1 = 160
+#if defined key_orca_lev10
+               ztem  ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 , : ) = 7.0 
+               ztem  ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 , : ) = 6.5 
+               ztem  ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 , : ) = 6.0
+#else
+               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 , : ) = 7.0 
+               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 , : ) = 6.5 
+               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 , : ) = 6.0
+#endif
+            ENDIF
+            !
+         ENDIF
+#endif
+         
+#if defined key_orca_lev10
+         ! interpolate from 31 to 301 level the ztem field result in temdta
+         DO jl = 1, 2
+            DO jjk = 1, 5
+               temdta(:,:,jjk,jl) = ztem(:,:,1,jl)
+            END DO
+            DO jk = 1, jpk-20,10
+               ik = jk+5
+               ikr =  INT(jk/10) + 1
+               ikw =  (ikr-1) *10 + 1
+               ikt =  ikw + 5
+               DO jjk=ikt,ikt+9
+                  zfac = ( gdept_0(jjk   ) - gdepw_0(ikt) ) / ( gdepw_0(ikt+10) - gdepw_0(ikt) )
+                  temdta(:,:,jjk,jl) = ztem(:,:,ikr,jl) + ( ztem(:,:,ikr+1,jl) - ztem(:,:,ikr,jl) ) * zfac
+               END DO
+            END DO
+            DO jjk = jpk-5, jpk
+               temdta(:,:,jjk,jl) = ztem(:,:,jpkdta-1,jl)
+            END DO
+            ! fill the overlap areas
+            CALL lbc_lnk (temdta(:,:,:,jl),'Z',-999.,'no0')
+         END DO
+#endif
+         
+         IF( ln_sco ) THEN
+            DO jl = 1, 2
+               DO jj = 1, jpj                  ! interpolation of temperatures
+                  DO ji = 1, jpi
+                     DO jk = 1, jpk
+                        zl=fsdept_0(ji,jj,jk)
+                        IF(zl < gdept_0(1)) ztemdta(jk,jl) =  temdta(ji,jj,1,jl)
+                        IF(zl > gdept_0(jpk)) ztemdta(jk,jl) =  temdta(ji,jj,jpkm1,jl)
+                        DO jkk = 1, jpkm1
+                           IF((zl-gdept_0(jkk))*(zl-gdept_0(jkk+1)).le.0.0) THEN
+                              ztemdta(jk,jl) = temdta(ji,jj,jkk,jl)                                 &
+                                   &           + (zl-gdept_0(jkk))/(gdept_0(jkk+1)-gdept_0(jkk))      &
+                                   &                              *(temdta(ji,jj,jkk+1,jl) - temdta(ji,jj,jkk,jl))
+                           ENDIF
+                        END DO
+                     END DO
+                     DO jk = 1, jpkm1
+                        temdta(ji,jj,jk,jl) = ztemdta(jk,jl)
+                     END DO
+                     temdta(ji,jj,jpk,jl) = 0.0
+                  END DO
+               END DO
+            END DO
+            
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' Levitus temperature data interpolated to s-coordinate'
+            IF(lwp) WRITE(numout,*)
+            
+         ELSE
+            
+            !                                  ! Mask
+            DO jl = 1, 2
+               temdta(:,:,:,jl) = temdta(:,:,:,jl) * tmask(:,:,:)
+               temdta(:,:,jpk,jl) = 0.
+               IF( ln_zps ) THEN                ! z-coord. with partial steps
+                  DO jj = 1, jpj                  ! interpolation of temperature at the last level
+                     DO ji = 1, jpi
+                        ik = mbathy(ji,jj) - 1
+                        IF( ik > 2 ) THEN
+                           zl = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
+                           temdta(ji,jj,ik,jl) = (1.-zl) * temdta(ji,jj,ik,jl) + zl * temdta(ji,jj,ik-1,jl)
+                        ENDIF
+                     END DO
+                  END DO
+               ENDIF
+            END DO
+            
+         ENDIF
+         
+         IF(lwp) THEN
+            WRITE(numout,*) ' temperature Levitus month ', ntem1, ntem2
+            WRITE(numout,*)
+            WRITE(numout,*) ' Levitus month = ', ntem1, '  level = 1'
+            CALL prihre( temdta(:,:,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+            WRITE(numout,*) ' Levitus month = ', ntem1, '  level = ', jpk/2
+            CALL prihre( temdta(:,:,jpk/2,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+            WRITE(numout,*) ' Levitus month = ',ntem1,'  level = ', jpkm1
+            CALL prihre( temdta(:,:,jpkm1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+         ENDIF
+      ENDIF
+      
+      
+      ! 2. At every time step compute temperature data
+      ! ----------------------------------------------
+      
+      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+      t_dta(:,:,:) = (1.-zxy) * temdta(:,:,:,1) + zxy * temdta(:,:,:,2)
+      
+      ! Close the file
+      ! --------------
+      
+      IF( kt == nitend )   CALL iom_close (numtdt)
+      
+    END SUBROUTINE dta_tem
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case                           NO 3D temperature data field
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtatem = .FALSE.   !: temperature data flag
+CONTAINS
+   SUBROUTINE dta_tem( kt )        ! Empty routine
+      WRITE(*,*) 'dta_tem: You should not have seen this print! error?', kt
+   END SUBROUTINE dta_tem
+#endif
+   !!======================================================================
+END MODULE dtatem
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/divcur.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/divcur.F90	(revision 1844)
@@ -0,0 +1,384 @@
+MODULE divcur
+   !!==============================================================================
+   !!                       ***  MODULE  divcur  ***
+   !! Ocean diagnostic variable : horizontal divergence and relative vorticity
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   div_cur    : Compute the horizontal divergence and relative
+   !!                vorticity fields
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE obc_oce         ! ocean lateral open boundary condition
+   USE bdy_oce	       ! Unstructured open boundaries variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC div_cur    ! routine called by step.F90 and istate.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_noslip_accurate
+   !!----------------------------------------------------------------------
+   !!   'key_noslip_accurate'                     2nd order centered scheme
+   !!                                                4th order at the coast
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE div_cur( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE div_cur  ***
+      !!
+      !! ** Purpose :   compute the horizontal divergence and the relative
+      !!      vorticity at before and now time-step
+      !!
+      !! ** Method  : 
+      !!      I.  divergence :
+      !!         - save the divergence computed at the previous time-step
+      !!      (note that the Asselin filter has not been applied on hdivb)
+      !!         - compute the now divergence given by :
+      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
+      !!      Note: if lk_zco=T, e3u=e3v=e3t, they are simplified in the
+      !!      above expression
+      !!         - apply lateral boundary conditions on hdivn 
+      !!      II. vorticity :
+      !!         - save the curl computed at the previous time-step
+      !!            rotb = rotn
+      !!      (note that the Asselin time filter has not been applied to rotb)
+      !!         - compute the now curl in tensorial formalism:
+      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
+      !!         - apply lateral boundary conditions on rotn through a call
+      !!      of lbc_lnk routine.
+      !!         - Coastal boundary condition: 'key_noslip_accurate' defined,
+      !!      the no-slip boundary condition is computed using Schchepetkin
+      !!      and O'Brien (1996) scheme (i.e. 4th order at the coast).
+      !!      For example, along east coast, the one-sided finite difference
+      !!      approximation used for di[v] is:
+      !!         di[e2v vn] =  1/(e1f*e2f)
+      !!                    * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) )
+      !!
+      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
+      !!              - update rotb , rotn , the before & now rel. vorticity
+      !!
+      !! History :
+      !!   8.2  !  00-03  (G. Madec)  no slip accurate
+      !!   9.0  !  03-08  (G. Madec)  merged of cur and div, free form, F90
+      !!        !  05-01  (J. Chanut, A. Sellar) unstructured open boundaries
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk     ! dummy loop indices
+      INTEGER ::   ii, ij, jl     ! temporary integer
+      INTEGER ::   ijt, iju       ! temporary integer
+      REAL(wp), DIMENSION(   jpi  ,1:jpj+2) ::   zwu   ! workspace
+      REAL(wp), DIMENSION(-1:jpi+2,  jpj  ) ::   zwv   ! workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity'
+         IF(lwp) WRITE(numout,*) '~~~~~~~   NOT optimal for auto-tasking case'
+      ENDIF
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
+         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
+
+         !                                             ! --------
+         ! Horizontal divergence                       !   div
+         !                                             ! --------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               hdivn(ji,jj,jk) = (  e2u(ji,jj) * un(ji,jj,jk) - e2u(ji-1,jj  ) * un(ji-1,jj  ,jk)      &
+                  &               + e1v(ji,jj) * vn(ji,jj,jk) - e1v(ji  ,jj-1) * vn(ji  ,jj-1,jk)  )   &
+                  &            / ( e1t(ji,jj) * e2t(ji,jj) )
+#else
+               hdivn(ji,jj,jk) =   &
+                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)       &
+                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  )    &
+                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+#endif
+            END DO
+         END DO
+
+#if defined key_obc
+         IF( Agrif_Root() ) THEN
+            ! open boundaries (div must be zero behind the open boundary)
+            !  mpp remark: The zeroing of hdivn can probably be extended to 1->jpi/jpj for the correct row/column
+            IF( lp_obc_east  )   hdivn(nie0p1:nie1p1,nje0  :nje1  ,jk) = 0.e0      ! east
+            IF( lp_obc_west  )   hdivn(niw0  :niw1  ,njw0  :njw1  ,jk) = 0.e0      ! west
+            IF( lp_obc_north )   hdivn(nin0  :nin1  ,njn0p1:njn1p1,jk) = 0.e0      ! north
+            IF( lp_obc_south )   hdivn(nis0  :nis1  ,njs0  :njs1  ,jk) = 0.e0      ! south
+         ENDIF
+#endif         
+#if defined key_bdy
+         ! unstructured open boundaries (div must be zero behind the open boundary)
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               hdivn(ji,jj,jk)=hdivn(ji,jj,jk)*bdytmask(ji,jj)
+            END DO
+         END DO
+#endif         
+         IF( .NOT. AGRIF_Root() ) THEN
+            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
+            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
+            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
+            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
+         ENDIF
+
+         !                                             ! --------
+         ! relative vorticity                          !   rot 
+         !                                             ! --------
+         ! contravariant velocity (extended for lateral b.c.)
+         ! inside the model domain
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwu(ji,jj) = e1u(ji,jj) * un(ji,jj,jk)
+               zwv(ji,jj) = e2v(ji,jj) * vn(ji,jj,jk)
+            END DO  
+         END DO  
+ 
+         ! East-West boundary conditions
+         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN
+            zwv(  0  ,:) = zwv(jpi-2,:)
+            zwv( -1  ,:) = zwv(jpi-3,:)
+            zwv(jpi+1,:) = zwv(  3  ,:)
+            zwv(jpi+2,:) = zwv(  4  ,:)
+         ELSE
+            zwv(  0  ,:) = 0.e0
+            zwv( -1  ,:) = 0.e0
+            zwv(jpi+1,:) = 0.e0
+            zwv(jpi+2,:) = 0.e0
+         ENDIF
+
+         ! North-South boundary conditions
+         IF( nperio == 3 .OR. nperio == 4 ) THEN
+            ! north fold ( Grid defined with a T-point pivot) ORCA 2 degre
+            zwu(jpi,jpj+1) = 0.e0
+            zwu(jpi,jpj+2) = 0.e0
+            DO ji = 1, jpi-1
+               iju = jpi - ji + 1
+               zwu(ji,jpj+1) = - zwu(iju,jpj-3)
+               zwu(ji,jpj+2) = - zwu(iju,jpj-4)
+            END DO
+         ELSEIF( nperio == 5 .OR. nperio == 6 ) THEN
+            ! north fold ( Grid defined with a F-point pivot) ORCA 0.5 degre\
+            zwu(jpi,jpj+1) = 0.e0
+            zwu(jpi,jpj+2) = 0.e0
+            DO ji = 1, jpi-1
+               iju = jpi - ji
+               zwu(ji,jpj  ) = - zwu(iju,jpj-1)
+               zwu(ji,jpj+1) = - zwu(iju,jpj-2)
+               zwu(ji,jpj+2) = - zwu(iju,jpj-3)
+            END DO
+            DO ji = -1, jpi+2
+               ijt = jpi - ji + 1
+               zwv(ji,jpj) = - zwv(ijt,jpj-2)
+            END DO
+            DO ji = jpi/2+1, jpi+2
+               ijt = jpi - ji + 1
+               zwv(ji,jpjm1) = - zwv(ijt,jpjm1)
+            END DO
+         ELSE
+            ! closed
+            zwu(:,jpj+1) = 0.e0
+            zwu(:,jpj+2) = 0.e0
+         ENDIF
+
+         ! relative vorticity (vertical component of the velocity curl) 
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               rotn(ji,jj,jk) = (  zwv(ji+1,jj  ) - zwv(ji,jj)      &
+                                 - zwu(ji  ,jj+1) + zwu(ji,jj)  )   &
+                              * fmask(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
+            END DO
+         END DO
+
+         ! second order accurate scheme along straight coast
+         DO jl = 1, npcoa(1,jk)
+            ii = nicoa(jl,1,jk)
+            ij = njcoa(jl,1,jk)
+            rotn(ii,ij,jk) = 1. / ( e1f(ii,ij) * e2f(ii,ij) )   &
+                           * ( + 4. * zwv(ii+1,ij) - zwv(ii+2,ij) + 0.2 * zwv(ii+3,ij) )
+         END DO
+         DO jl = 1, npcoa(2,jk)
+            ii = nicoa(jl,2,jk)
+            ij = njcoa(jl,2,jk)
+            rotn(ii,ij,jk) = 1./(e1f(ii,ij)*e2f(ii,ij))   &
+               *(-4.*zwv(ii,ij)+zwv(ii-1,ij)-0.2*zwv(ii-2,ij))
+         END DO
+         DO jl = 1, npcoa(3,jk)
+            ii = nicoa(jl,3,jk)
+            ij = njcoa(jl,3,jk)
+            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
+               * ( +4. * zwu(ii,ij+1) - zwu(ii,ij+2) + 0.2 * zwu(ii,ij+3) )
+         END DO
+         DO jl = 1, npcoa(4,jk)
+            ii = nicoa(jl,4,jk)
+            ij = njcoa(jl,4,jk)
+            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
+               * ( -4. * zwu(ii,ij) + zwu(ii,ij-1) - 0.2 * zwu(ii,ij-2) )
+         END DO
+
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      
+      ! 4. Lateral boundary conditions on hdivn and rotn
+      ! ---------------------------------=======---======
+      CALL lbc_lnk( hdivn, 'T', 1. )     ! T-point, no sign change
+      CALL lbc_lnk( rotn , 'F', 1. )     ! F-point, no sign change
+
+   END SUBROUTINE div_cur
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                           2nd order centered schemes
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE div_cur( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE div_cur  ***
+      !!                    
+      !! ** Purpose :   compute the horizontal divergence and the relative
+      !!      vorticity at before and now time-step
+      !!
+      !! ** Method  : - Divergence:
+      !!      - save the divergence computed at the previous time-step
+      !!      (note that the Asselin filter has not been applied on hdivb)
+      !!      - compute the now divergence given by :
+      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
+      !!      Note: if lk_zco=T, e3u=e3v=e3t, they are simplified in the 
+      !!      above expression
+      !!      - apply lateral boundary conditions on hdivn 
+      !!              - Relavtive Vorticity :
+      !!      - save the curl computed at the previous time-step (rotb = rotn)
+      !!      (note that the Asselin time filter has not been applied to rotb)
+      !!      - compute the now curl in tensorial formalism:
+      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
+      !!      - apply lateral boundary conditions on rotn through a call to
+      !!      routine lbc_lnk routine.
+      !!      Note: Coastal boundary condition: lateral friction set through
+      !!      the value of fmask along the coast (see dommsk.F90) and shlat
+      !!      (namelist parameter)
+      !!
+      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
+      !!              - update rotb , rotn , the before & now rel. vorticity
+      !!
+      !! History :
+      !!   1.0  !  87-06  (P. Andrich, D. L Hostis)  Original code
+      !!   4.0  !  91-11  (G. Madec)
+      !!   6.0  !  93-03  (M. Guyon)  symetrical conditions
+      !!   7.0  !  96-01  (G. Madec)  s-coordinates
+      !!   8.0  !  97-06  (G. Madec)  lateral boundary cond., lbc
+      !!   8.1  !  97-08  (J.M. Molines)  Open boundaries
+      !!   9.0  !  02-09  (G. Madec, E. Durand)  Free form, F90
+      !!        !  05-01  (J. Chanut) Unstructured open boundaries
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
+      
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk          ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and'
+         IF(lwp) WRITE(numout,*) '~~~~~~~   relative vorticity'
+      ENDIF
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
+         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
+
+         !                                             ! --------
+         ! Horizontal divergence                       !   div 
+         !                                             ! --------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               hdivn(ji,jj,jk) = (  e2u(ji,jj) * un(ji,jj,jk) - e2u(ji-1,jj  ) * un(ji-1,jj  ,jk)      &
+                  &               + e1v(ji,jj) * vn(ji,jj,jk) - e1v(ji  ,jj-1) * vn(ji  ,jj-1,jk)  )   & 
+                  / ( e1t(ji,jj) * e2t(ji,jj) )
+#else
+               hdivn(ji,jj,jk) =   &
+                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)       &
+                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  )    &
+                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+#endif
+            END DO  
+         END DO  
+
+#if defined key_obc
+         IF( Agrif_Root() ) THEN
+            ! open boundaries (div must be zero behind the open boundary)
+            !  mpp remark: The zeroing of hdivn can probably be extended to 1->jpi/jpj for the correct row/column
+            IF( lp_obc_east  )   hdivn(nie0p1:nie1p1,nje0  :nje1  ,jk) = 0.e0      ! east
+            IF( lp_obc_west  )   hdivn(niw0  :niw1  ,njw0  :njw1  ,jk) = 0.e0      ! west
+            IF( lp_obc_north )   hdivn(nin0  :nin1  ,njn0p1:njn1p1,jk) = 0.e0      ! north
+            IF( lp_obc_south )   hdivn(nis0  :nis1  ,njs0  :njs1  ,jk) = 0.e0      ! south
+         ENDIF
+#endif         
+#if defined key_bdy
+         ! unstructured open boundaries (div must be zero behind the open boundary)
+         DO jj = 1, jpj
+           DO ji = 1, jpi
+             hdivn(ji,jj,jk)=hdivn(ji,jj,jk)*bdytmask(ji,jj)
+           END DO
+         END DO
+#endif        
+         IF( .NOT. AGRIF_Root() ) THEN
+            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
+            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
+            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
+            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
+         ENDIF
+
+         !                                             ! --------
+         ! relative vorticity                          !   rot 
+         !                                             ! --------
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               rotn(ji,jj,jk) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                  &              - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
+                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      
+      ! 4. Lateral boundary conditions on hdivn and rotn
+      ! ---------------------------------=======---======
+      CALL lbc_lnk( hdivn, 'T', 1. )       ! T-point, no sign change
+      CALL lbc_lnk( rotn , 'F', 1. )       ! F-point, no sign change
+
+   END SUBROUTINE div_cur
+   
+#endif
+   !!======================================================================
+END MODULE divcur
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 1844)
@@ -0,0 +1,129 @@
+MODULE dynadv
+   !!==============================================================================
+   !!                       ***  MODULE  dynadv  ***
+   !! Ocean active tracers:  advection scheme control
+   !!==============================================================================
+   !! History :  9.0  !  06-11  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_adv      : compute the momentum advection trend 
+   !!   dyn_adv_ctl  : control the different options of advection scheme
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+
+   USE dynadv_cen2     ! centred flux form advection      (dyn_adv_cen2 routine)
+   USE dynadv_ubs      ! UBS flux form advection          (dyn_adv_ubs  routine)
+   USE dynkeg          ! kinetic energy gradient          (dyn_keg      routine)
+   USE dynzad          ! vertical advection               (dyn_zad      routine)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dyn_adv     ! routine called by step module
+ 
+   LOGICAL, PUBLIC ::   ln_dynadv_vec  = .TRUE.    ! vector form flag
+   LOGICAL, PUBLIC ::   ln_dynadv_cen2 = .FALSE.   ! flux form - 2nd order centered scheme flag
+   LOGICAL, PUBLIC ::   ln_dynadv_ubs  = .FALSE.   ! flux form - 3rd order UBS scheme flag
+   
+   INTEGER ::   nadv   ! choice of the formulation and scheme for the advection
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_adv( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv  ***
+      !!                
+      !! ** Purpose :   compute the ocean momentum advection trend.
+      !!
+      !! ** Method  : - Update (ua,va) with the advection term following nadv
+      !!      NB: in flux form advection (ln_dynadv_cen2 or ln_dynadv_ubs=T) 
+      !!      a metric term is add to the coriolis term while in vector form 
+      !!      it is the relative vorticity which is added to coriolis term
+      !!      (see dynvor module).
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 )   CALL dyn_adv_ctl          ! initialisation & control of options
+
+      SELECT CASE ( nadv )                     ! compute advection trend and add it to general trend
+      CASE ( 0 )     
+                      CALL dyn_keg     ( kt )    ! vector form : horizontal gradient of kinetic energy
+                      CALL dyn_zad     ( kt )    ! vector form : vertical advection
+      CASE ( 1 ) 
+                      CALL dyn_adv_cen2( kt )    ! 2nd order centered scheme
+      CASE ( 2 )   
+                      CALL dyn_adv_ubs ( kt )    ! 3rd order UBS      scheme
+      !
+      CASE (-1 )                                 ! esopa: test all possibility with control print
+                      CALL dyn_keg     ( kt )
+                      CALL dyn_zad     ( kt )
+                      CALL dyn_adv_cen2( kt )
+                      CALL dyn_adv_ubs ( kt )
+      END SELECT
+      !
+   END SUBROUTINE dyn_adv
+
+   
+   SUBROUTINE dyn_adv_ctl
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv_ctl  ***
+      !!                
+      !! ** Purpose :   Control the consistency between namelist options for 
+      !!              momentum advection formulation & scheme and set nadv
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio
+
+      NAMELIST/namdyn_adv/ ln_dynadv_vec, ln_dynadv_cen2 , ln_dynadv_ubs
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               ! Read Namelist namdyn_adv : momentum advection scheme
+      READ   ( numnam, namdyn_adv )
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_adv_ctl : choice/control of the momentum advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '       Namelist namdyn_adv : chose a advection formulation & scheme for momentum'
+         WRITE(numout,*) '          Vector/flux form (T/F)             ln_dynadv_vec  = ', ln_dynadv_vec
+         WRITE(numout,*) '          2nd order centred advection scheme ln_dynadv_cen2 = ', ln_dynadv_cen2
+         WRITE(numout,*) '          3rd order UBS advection scheme     ln_dynadv_ubs  = ', ln_dynadv_ubs
+      ENDIF
+
+      ioptio = 0                      ! Parameter control
+      IF( ln_dynadv_vec  )   ioptio = ioptio + 1
+      IF( ln_dynadv_cen2 )   ioptio = ioptio + 1
+      IF( ln_dynadv_ubs  )   ioptio = ioptio + 1
+      IF( lk_esopa       )   ioptio =          1
+
+      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namdyn_adv' )
+
+      !                               ! Set nadv
+      IF( ln_dynadv_vec  )   nadv =  0 
+      IF( ln_dynadv_cen2 )   nadv =  1
+      IF( ln_dynadv_ubs  )   nadv =  2
+      IF( lk_esopa       )   nadv = -1
+
+      IF(lwp) THEN                    ! Print the choice
+         WRITE(numout,*)
+         IF( nadv ==  0 )   WRITE(numout,*) '         vector form : keg + zad + vor is used'
+         IF( nadv ==  1 )   WRITE(numout,*) '         flux form   : 2nd order scheme is used'
+         IF( nadv ==  2 )   WRITE(numout,*) '         flux form   : UBS       scheme is used'
+         IF( nadv == -1 )   WRITE(numout,*) '         esopa test: use all advection formulation'
+      ENDIF
+      !
+   END SUBROUTINE dyn_adv_ctl
+
+  !!======================================================================
+END MODULE dynadv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_cen2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 1844)
@@ -0,0 +1,162 @@
+MODULE dynadv_cen2
+   !!======================================================================
+   !!                       ***  MODULE  dynadv  ***
+   !! Ocean dynamics: Update the momentum trend with the flux form advection
+   !!                 using a 2nd order centred scheme
+   !!======================================================================
+   !! History :  2.0  ! 2006-08  (G. Madec, S. Theetten)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_adv_cen2       : flux form momentum advection (ln_dynadv_cen2=T)
+   !!                        trends using a 2nd order centred scheme  
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE trdmod_oce     ! ocean variables trends
+   USE trdmod         ! ocean dynamics trends
+   USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_adv_cen2   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_adv_cen2( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv_cen2  ***
+      !!
+      !! ** Purpose :   Compute the now momentum advection trend in flux form
+      !!              and the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time) 
+      !!
+      !! ** Action  :   (ua,va) updated with the now vorticity term trend
+      !!----------------------------------------------------------------------
+      USE oce, ONLY:   zfu => ta   ! use ta as 3D workspace
+      USE oce, ONLY:   zfv => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zbu, zbv     ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zfu_t, zfu_f, zfu_uw   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zfv_t, zfv_f, zfv_vw   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zfw                    !  -      -
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_adv_cen2 : 2nd order flux form momentum advection'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+      ENDIF
+
+      IF( l_trddyn ) THEN           ! Save ua and va trends
+         zfu_uw(:,:,:) = ua(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:)
+      ENDIF
+
+      !                                      ! ====================== !
+      !                                      !  Horizontal advection  !
+      DO jk = 1, jpkm1                       ! ====================== !
+         !                                         ! horizontal volume fluxes
+         zfu(:,:,jk) = 0.25 * e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = 0.25 * e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         !
+         DO jj = 1, jpjm1                          ! horizontal momentum fluxes at T- and F-point
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zfu_t(ji+1,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji+1,jj  ,jk) )
+               zfv_f(ji  ,jj  ,jk) = ( zfv(ji,jj,jk) + zfv(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji  ,jj+1,jk) )
+               zfu_f(ji  ,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji+1,jj  ,jk) )
+               zfv_t(ji  ,jj+1,jk) = ( zfv(ji,jj,jk) + zfv(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji  ,jj+1,jk) )
+            END DO
+         END DO
+         DO jj = 2, jpjm1                          ! divergence of horizontal momentum fluxes
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               !
+               ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj  ,jk) - zfu_t(ji  ,jj  ,jk)    &
+                  &                           + zfv_f(ji  ,jj  ,jk) - zfv_f(ji  ,jj-1,jk)  ) / zbu
+               va(ji,jj,jk) = va(ji,jj,jk) - (  zfu_f(ji  ,jj  ,jk) - zfu_f(ji-1,jj  ,jk)    &
+                  &                           + zfv_t(ji  ,jj+1,jk) - zfv_t(ji  ,jj  ,jk)  ) / zbv
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                          ! save the horizontal advection trend for diagnostic
+         zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:)
+         CALL trd_mod( zfu_uw, zfv_vw, jpdyn_trd_had, 'DYN', kt )
+         zfu_t(:,:,:) = ua(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+
+      !                                      ! ==================== !
+      !                                      !  Vertical advection  !
+      DO jk = 1, jpkm1                       ! ==================== !
+         !                                         ! Vertical volume fluxesÊ
+         zfw(:,:,jk) = 0.25 * e1t(:,:) * e2t(:,:) * wn(:,:,jk)
+         !
+         IF( jk == 1 ) THEN                        ! surface/bottom advective fluxes                   
+            zfu_uw(:,:,jpk) = 0.e0                      ! Bottom  value : flux set to zero
+            zfv_vw(:,:,jpk) = 0.e0
+            !                                           ! Surface value :
+            IF( lk_vvl ) THEN                                ! variable volume : flux set to zero
+               zfu_uw(:,:, 1 ) = 0.e0    
+               zfv_vw(:,:, 1 ) = 0.e0
+            ELSE                                             ! constant volume : advection through the surface
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zfu_uw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji+1,jj  ,1) ) * un(ji,jj,1)
+                     zfv_vw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji  ,jj+1,1) ) * vn(ji,jj,1)
+                  END DO
+               END DO
+            ENDIF
+         ELSE                                      ! interior fluxes
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
+                  zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
+               END DO
+            END DO
+         ENDIF
+      END DO
+      DO jk = 1, jpkm1                             ! divergence of vertical momentum flux divergence
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) =  ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) )    &
+                  &  / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
+               va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) )    &
+                  &  / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                          ! save the vertical advection trend for diagnostic
+         zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:)
+         CALL trd_mod( zfu_t, zfv_t, jpdyn_trd_zad, 'DYN', kt )
+      ENDIF
+      !                                            ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' cen2 adv - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=           ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_adv_cen2
+
+   !!==============================================================================
+END MODULE dynadv_cen2
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_ubs.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 1844)
@@ -0,0 +1,253 @@
+MODULE dynadv_ubs
+   !!======================================================================
+   !!                       ***  MODULE  dynadv_ubs  ***
+   !! Ocean dynamics: Update the momentum trend with the flux form advection
+   !!                 trend using a 3rd order upstream biased scheme
+   !!======================================================================
+   !! History :  2.0  ! 2006-08  (R. Benshila, L. Debreu)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_adv_ubs   : flux form momentum advection using    (ln_dynadv=T)
+   !!                   an 3rd order Upstream Biased Scheme or Quick scheme
+   !!                   combined with 2nd or 4th order finite differences 
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE trdmod         ! ocean dynamics trends
+   USE trdmod_oce     ! ocean variables trends
+   USE prtctl         ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   REAL(wp), PARAMETER :: gamma1 = 1._wp/4._wp  ! =1/4 quick      ; =1/3  3rd order UBS
+   REAL(wp), PARAMETER :: gamma2 = 1._wp/8._wp  ! =0   2nd order  ; =1/8  4th order centred
+
+   PUBLIC   dyn_adv_ubs   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_adv_ubs( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv_ubs  ***
+      !!
+      !! ** Purpose :   Compute the now momentum advection trend in flux form
+      !!              and the general trend of the momentum equation.
+      !!
+      !! ** Method  :   The scheme is the one implemeted in ROMS. It depends 
+      !!      on two parameter gamma1 and gamma2. The former control the 
+      !!      upstream baised part of the scheme and the later the centred 
+      !!      part:     gamma1 = 0    pure centered  (no diffusive part)
+      !!                       = 1/4  Quick scheme
+      !!                       = 1/3  3rd order Upstream biased scheme
+      !!                gamma2 = 0    2nd order finite differencing 
+      !!                       = 1/8  4th order finite differencing
+      !!      For stability reasons, the first term of the fluxes which cor-
+      !!      responds to a second order centered scheme is evaluated using  
+      !!      the now velocity (centered in time) while the second term which  
+      !!      is the diffusive part of the scheme, is evaluated using the 
+      !!      before velocity (forward in time). 
+      !!      Default value (hard coded in the begining of the module) are 
+      !!      gamma1=1/4 and gamma2=1/8.
+      !!
+      !! ** Action : - (ua,va) updated with the 3D advective momentum trends
+      !!
+      !! Reference : Shchepetkin & McWilliams, 2005, Ocean Modelling. 
+      !!----------------------------------------------------------------------
+      USE oce, ONLY:   zfu => ta   ! use ta as 3D workspace
+      USE oce, ONLY:   zfv => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk            ! dummy loop indices
+      REAL(wp) ::   zbu, zbv    ! temporary scalars
+      REAL(wp) ::   zui, zvj, zfuj, zfvi, zl_u, zl_v   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk)   ::   zfu_t, zfu_f     ! temporary workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk)   ::   zfv_t, zfv_f     !    "           "
+      REAL(wp), DIMENSION(jpi,jpj,jpk)   ::   zfw, zfu_uw, zfv_vw
+      REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   zlu_uu, zlu_uv   ! temporary workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk,2) ::   zlv_vv, zlv_vu   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_adv_ubs : UBS flux form momentum advection'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+      zfu_t(:,:,:) = 0.e0
+      zfv_t(:,:,:) = 0.e0
+      zfu_f(:,:,:) = 0.e0
+      zfv_f(:,:,:) = 0.e0
+      !
+      zlu_uu(:,:,:,:) = 0.e0 
+      zlv_vv(:,:,:,:) = 0.e0 
+      zlu_uv(:,:,:,:) = 0.e0 
+      zlv_vu(:,:,:,:) = 0.e0 
+
+      IF( l_trddyn ) THEN           ! Save ua and va trends
+         zfu_uw(:,:,:) = ua(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:)
+      ENDIF
+
+      !                                      ! =========================== !
+      DO jk = 1, jpkm1                       !  Laplacian of the velocity  !
+         !                                   ! =========================== !
+         !                                         ! horizontal volume fluxes
+         zfu(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         !            
+         DO jj = 2, jpjm1                          ! laplacian
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj,jk)-2.*ub (ji,jj,jk)+ub (ji-1,jj,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,1) = ( vb (ji,jj+1,jk)-2.*vb (ji,jj,jk)+vb (ji,jj-1,jk) ) * vmask(ji,jj,jk) 
+               zlu_uv(ji,jj,jk,1) = ( ub (ji,jj+1,jk)-2.*ub (ji,jj,jk)+ub (ji,jj-1,jk) ) * umask(ji,jj,jk)
+               zlv_vu(ji,jj,jk,1) = ( vb (ji+1,jj,jk)-2.*vb (ji,jj,jk)+vb (ji-1,jj,jk) ) * vmask(ji,jj,jk)
+               
+               zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj,jk)-2.*zfu(ji,jj,jk)+zfu(ji-1,jj,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,2) = ( zfv(ji,jj+1,jk)-2.*zfv(ji,jj,jk)+zfv(ji,jj-1,jk) ) * vmask(ji,jj,jk)
+               zlu_uv(ji,jj,jk,2) = ( zfu(ji,jj+1,jk)-2.*zfu(ji,jj,jk)+zfu(ji,jj-1,jk) ) * umask(ji,jj,jk)
+               zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj,jk)-2.*zfv(ji,jj,jk)+zfv(ji-1,jj,jk) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+!!gm BUG !!!  just below this should be +1 in all the communications
+      CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', -1.)   ;   CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', -1.)
+      CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', -1.)   ;   CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', -1.)
+      CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', -1.)   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', -1.)
+      CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', -1.)   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', -1.) 
+
+!!gm corrected:
+      CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', 1. )
+      CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', 1. )
+      CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', 1. )
+      CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', 1. ) 
+!!gm end
+      
+      !                                      ! ====================== !
+      !                                      !  Horizontal advection  !
+      DO jk = 1, jpkm1                       ! ====================== !
+         !                                         ! horizontal volume fluxes
+         zfu(:,:,jk) = 0.25 * e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = 0.25 * e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         !
+         DO jj = 1, jpjm1                          ! horizontal momentum fluxes at T- and F-point
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zui = ( un(ji,jj,jk) + un(ji+1,jj  ,jk) )
+               zvj = ( vn(ji,jj,jk) + vn(ji  ,jj+1,jk) )
+               !
+               IF (zui > 0) THEN   ;   zl_u = zlu_uu(ji  ,jj,jk,1)
+               ELSE                ;   zl_u = zlu_uu(ji+1,jj,jk,1)
+               ENDIF
+               IF (zvj > 0) THEN   ;   zl_v = zlv_vv(ji,jj  ,jk,1)
+               ELSE                ;   zl_v = zlv_vv(ji,jj+1,jk,1)
+               ENDIF
+               !
+               zfu_t(ji+1,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj  ,jk)                               &
+                  &                    - gamma2 * ( zlu_uu(ji,jj,jk,2) + zlu_uu(ji+1,jj  ,jk,2) )  )   &
+                  &                * ( zui - gamma1 * zl_u)
+               zfv_t(ji  ,jj+1,jk) = ( zfv(ji,jj,jk) + zfv(ji  ,jj+1,jk)                               &
+                  &                    - gamma2 * ( zlv_vv(ji,jj,jk,2) + zlv_vv(ji  ,jj+1,jk,2) )  )   &
+                  &                * ( zvj - gamma1 * zl_v)
+               !
+               zfuj = ( zfu(ji,jj,jk) + zfu(ji  ,jj+1,jk) )
+               zfvi = ( zfv(ji,jj,jk) + zfv(ji+1,jj  ,jk) )
+               IF (zfuj > 0) THEN   ;    zl_v = zlv_vu( ji  ,jj  ,jk,1)
+               ELSE                 ;    zl_v = zlv_vu( ji+1,jj,jk,1)
+               ENDIF
+               IF (zfvi > 0) THEN   ;    zl_u = zlu_uv( ji,jj  ,jk,1)
+               ELSE                 ;    zl_u = zlu_uv( ji,jj+1,jk,1)
+               ENDIF
+               !
+               zfv_f(ji  ,jj  ,jk) = ( zfvi - gamma2 * ( zlv_vu(ji,jj,jk,2) + zlv_vu(ji+1,jj  ,jk,2) )  )   &
+                  &                * ( un(ji,jj,jk) + un(ji  ,jj+1,jk) - gamma1 * zl_u )
+               zfu_f(ji  ,jj  ,jk) = ( zfuj - gamma2 * ( zlu_uv(ji,jj,jk,2) + zlu_uv(ji  ,jj+1,jk,2) )  )   &
+                  &                * ( vn(ji,jj,jk) + vn(ji+1,jj  ,jk) - gamma1 * zl_v )
+            END DO
+         END DO
+         DO jj = 2, jpjm1                          ! divergence of horizontal momentum fluxes
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               !
+               ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj  ,jk) - zfu_t(ji  ,jj  ,jk)    &
+                  &                           + zfv_f(ji  ,jj  ,jk) - zfv_f(ji  ,jj-1,jk)  ) / zbu
+               va(ji,jj,jk) = va(ji,jj,jk) - (  zfu_f(ji  ,jj  ,jk) - zfu_f(ji-1,jj  ,jk)    &
+                  &                           + zfv_t(ji  ,jj+1,jk) - zfv_t(ji  ,jj  ,jk)  ) / zbv
+            END DO
+         END DO
+      END DO
+      IF( l_trddyn ) THEN                          ! save the horizontal advection trend for diagnostic
+         zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:)
+         CALL trd_mod( zfu_uw, zfv_vw, jpdyn_trd_had, 'DYN', kt )
+         zfu_t(:,:,:) = ua(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:)
+      ENDIF
+
+      !                                      ! ==================== !
+      !                                      !  Vertical advection  !
+      DO jk = 1, jpkm1                       ! ==================== !
+         !                                         ! Vertical volume fluxesÊ
+         zfw(:,:,jk) = 0.25 * e1t(:,:) * e2t(:,:) * wn(:,:,jk)
+         !
+         IF( jk == 1 ) THEN                        ! surface/bottom advective fluxes                   
+            zfu_uw(:,:,jpk) = 0.e0                      ! Bottom  value : flux set to zero
+            zfv_vw(:,:,jpk) = 0.e0
+            !                                           ! Surface value :
+            IF( lk_vvl ) THEN                                ! variable volume : flux set to zero
+               zfu_uw(:,:, 1 ) = 0.e0    
+               zfv_vw(:,:, 1 ) = 0.e0
+            ELSE                                             ! constant volume : advection through the surface
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zfu_uw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji+1,jj  ,1) ) * un(ji,jj,1)
+                     zfv_vw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji  ,jj+1,1) ) * vn(ji,jj,1)
+                  END DO
+               END DO
+            ENDIF
+         ELSE                                      ! interior fluxes
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
+                  zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
+               END DO
+            END DO
+         ENDIF
+      END DO
+      DO jk = 1, jpkm1                             ! divergence of vertical momentum flux divergence
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) =  ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) )    &
+                  &  / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
+               va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) )    &
+                  &  / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                          ! save the vertical advection trend for diagnostic
+         zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:)
+         CALL trd_mod( zfu_t, zfv_t, jpdyn_trd_zad, 'DYN', kt )
+      ENDIF
+      !                                            ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ubs2 adv - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=           ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_adv_ubs
+
+   !!==============================================================================
+END MODULE dynadv_ubs
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynbfr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynbfr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynbfr.F90	(revision 1844)
@@ -0,0 +1,100 @@
+MODULE dynbfr
+   !!==============================================================================
+   !!                 ***  MODULE  dynbfr  ***
+   !! Ocean dynamics :  bottom friction component of the momentum mixing trend
+   !!==============================================================================
+   !! History :  9.0  !  2008-11  (A. C. Coward)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_bfr      : Update the momentum trend with the bottom friction contribution
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE zdfbfr          ! bottom friction
+
+   USE trdmod          ! ocean active dynamics and tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_bfr    !  routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id: dynzdf.F90 1152 2008-06-26 14:11:13Z rblod $
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE dyn_bfr( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_bfr  ***
+      !!
+      !! ** Purpose :   compute the bottom friction ocean dynamics physics.
+      !!
+      !! ** Action  :   (ua,va)   momentum trend increased by bottom friction trend
+      !!---------------------------------------------------------------------
+      USE oce, ONLY :   ztrdu => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   ztrdv => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !! 
+      INTEGER  ::   ji, jj          ! dummy loop indexes
+      INTEGER  ::   ikbu  , ikbv    ! temporary integers
+      INTEGER  ::   ikbum1, ikbvm1  !    -          -
+      REAL(wp) ::   zinv, zbfru, zbfrv   ! temporary scalar
+      !!---------------------------------------------------------------------
+      !
+      zinv = -1. / ( 2.*rdt )
+
+      IF( l_trddyn )   THEN                      ! temporary save of ua and va trends
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ikbu = MIN( mbathy(ji+1,jj), mbathy(ji,jj) )
+            ikbv = MIN( mbathy(ji,jj+1), mbathy(ji,jj) )
+            ikbum1 = MAX( ikbu-1, 1 )
+            ikbvm1 = MAX( ikbv-1, 1 )
+            !
+            ! Apply stability criteria on absolute value  : Min abs(bfr) => Max (bfr)
+            zbfru = MAX( bfrua(ji,jj), fse3u(ji,jj,ikbu)*zinv )
+            zbfrv = MAX( bfrva(ji,jj), fse3v(ji,jj,ikbv)*zinv )
+            !
+            ua(ji,jj,ikbum1) = ua(ji,jj,ikbum1) + zbfru * ub(ji,jj,ikbum1) / fse3u(ji,jj,ikbu)
+            va(ji,jj,ikbvm1) = va(ji,jj,ikbvm1) + zbfrv * vb(ji,jj,ikbvm1) / fse3v(ji,jj,ikbv)
+            !
+         END DO
+      END DO
+
+      !
+      IF( l_trddyn )   THEN                      ! save the vertical diffusive trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_bfr, 'DYN', kt )
+      ENDIF
+      !                                          ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' bfr  - Ua: ', mask1=umask,               &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_bfr
+
+   !!==============================================================================
+END MODULE dynbfr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 1844)
@@ -0,0 +1,1002 @@
+MODULE dynhpg
+   !!======================================================================
+   !!                       ***  MODULE  dynhpg  ***
+   !! Ocean dynamics:  hydrostatic pressure gradient trend
+   !!======================================================================
+   !! History :  1.0  !  87-09  (P. Andrich, M.-A. Foujols)  hpg_zco: Original code
+   !!            5.0  !  91-11  (G. Madec)
+   !!            7.0  !  96-01  (G. Madec)  hpg_sco: Original code for s-coordinates
+   !!            8.0  !  97-05  (G. Madec)  split dynber into dynkeg and dynhpg
+   !!            8.5  !  02-07  (G. Madec)  F90: Free form and module
+   !!            8.5  !  02-08  (A. Bozec)  hpg_zps: Original code
+   !!            9.0  !  05-10  (A. Beckmann, B.W. An)  various s-coordinate options
+   !!                           Original code for hpg_ctl, hpg_hel hpg_wdj, hpg_djc, hpg_rot 
+   !!            9.0  !  05-11  (G. Madec) style & small optimisation
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_hpg      : update the momentum trend with the now horizontal
+   !!                  gradient of the hydrostatic pressure
+   !!       hpg_ctl  : initialisation and control of options
+   !!       hpg_zco  : z-coordinate scheme
+   !!       hpg_zps  : z-coordinate plus partial steps (interpolation)
+   !!       hpg_sco  : s-coordinate (standard jacobian formulation)
+   !!       hpg_hel  : s-coordinate (helsinki modification)
+   !!       hpg_wdj  : s-coordinate (weighted density jacobian)
+   !!       hpg_djc  : s-coordinate (Density Jacobian with Cubic polynomial)
+   !!       hpg_rot  : s-coordinate (ROTated axes scheme)
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE prtctl          ! Print control
+   USE lbclnk          ! lateral boundary condition 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_hpg    ! routine called by step module
+
+   !                                              !!* Namelist namdyn_hpg : hydrostatic pressure gradient 
+   LOGICAL , PUBLIC ::   ln_hpg_zco    = .TRUE.    !: z-coordinate - full steps
+   LOGICAL , PUBLIC ::   ln_hpg_zps    = .FALSE.   !: z-coordinate - partial steps (interpolation)
+   LOGICAL , PUBLIC ::   ln_hpg_sco    = .FALSE.   !: s-coordinate (standard jacobian formulation)
+   LOGICAL , PUBLIC ::   ln_hpg_hel    = .FALSE.   !: s-coordinate (helsinki modification)
+   LOGICAL , PUBLIC ::   ln_hpg_wdj    = .FALSE.   !: s-coordinate (weighted density jacobian)
+   LOGICAL , PUBLIC ::   ln_hpg_djc    = .FALSE.   !: s-coordinate (Density Jacobian with Cubic polynomial)
+   LOGICAL , PUBLIC ::   ln_hpg_rot    = .FALSE.   !: s-coordinate (ROTated axes scheme)
+   REAL(wp), PUBLIC ::   rn_gamma      = 0.e0      !: weighting coefficient
+   LOGICAL , PUBLIC ::   ln_dynhpg_imp = .FALSE.   !: semi-implicite hpg flag
+   INTEGER , PUBLIC ::   nn_dynhpg_rst = 0         !: add dynhpg implicit variables in restart ot not
+
+   INTEGER  ::   nhpg  =  0   ! = 0 to 6, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_hpg( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_hpg  ***
+      !!
+      !! ** Method  :   Call the hydrostatic pressure gradient routine 
+      !!              using the scheme defined in the namelist
+      !!   
+      !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
+      !!             - Save the trend (l_trddyn=T)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdu, ztrdv   ! 3D temporary workspace
+      !!----------------------------------------------------------------------
+   
+      IF( kt == nit000 )   CALL hpg_ctl      ! initialisation & control of options
+
+      IF( l_trddyn ) THEN                    ! Temporary saving of ua and va trends (l_trddyn)
+         ztrdu(:,:,:) = ua(:,:,:)  
+         ztrdv(:,:,:) = va(:,:,:) 
+      ENDIF      
+
+      SELECT CASE ( nhpg )      ! Hydrastatic pressure gradient computation
+      CASE (  0 )   ;   CALL hpg_zco    ( kt )      ! z-coordinate
+      CASE (  1 )   ;   CALL hpg_zps    ( kt )      ! z-coordinate plus partial steps (interpolation)
+      CASE (  2 )   ;   CALL hpg_sco    ( kt )      ! s-coordinate (standard jacobian formulation)
+      CASE (  3 )   ;   CALL hpg_hel    ( kt )      ! s-coordinate (helsinki modification)
+      CASE (  4 )   ;   CALL hpg_wdj    ( kt )      ! s-coordinate (weighted density jacobian)
+      CASE (  5 )   ;   CALL hpg_djc    ( kt )      ! s-coordinate (Density Jacobian with Cubic polynomial)
+      CASE (  6 )   ;   CALL hpg_rot    ( kt )      ! s-coordinate (ROTated axes scheme)
+      END SELECT
+
+      IF( l_trddyn ) THEN      ! save the hydrostatic pressure gradient trends for momentum trend diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_hpg, 'DYN', kt )
+      ENDIF          
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' hpg  - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_hpg
+
+
+   SUBROUTINE hpg_ctl
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE hpg_ctl  ***
+      !!
+      !! ** Purpose :   initializations for the hydrostatic pressure gradient
+      !!              computation and consistency control
+      !!
+      !! ** Action  :   Read the namelist namdyn_hpg and check the consistency
+      !!      with the type of vertical coordinate used (zco, zps, sco)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio = 0      ! temporary integer
+      !!
+!     NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
+!        &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
+!        &                 ln_dynhpg_imp, nn_dynhpg_rst
+      !!----------------------------------------------------------------------
+
+!     REWIND ( numnam )               ! Namelist namdyn_hpg : already read in opa.F90 module
+!     READ   ( numnam, namdyn_hpg )
+
+      IF(lwp) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_hpg : hydrostatic pressure gradient'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namdyn_hpg : choice of hpg scheme'
+         WRITE(numout,*) '      z-coord. - full steps                             ln_hpg_zco    = ', ln_hpg_zco
+         WRITE(numout,*) '      z-coord. - partial steps (interpolation)          ln_hpg_zps    = ', ln_hpg_zps
+         WRITE(numout,*) '      s-coord. (standard jacobian formulation)          ln_hpg_sco    = ', ln_hpg_sco
+         WRITE(numout,*) '      s-coord. (helsinki modification)                  ln_hpg_hel    = ', ln_hpg_hel
+         WRITE(numout,*) '      s-coord. (weighted density jacobian)              ln_hpg_wdj    = ', ln_hpg_wdj
+         WRITE(numout,*) '      s-coord. (Density Jacobian: Cubic polynomial)     ln_hpg_djc    = ', ln_hpg_djc
+         WRITE(numout,*) '      s-coord. (ROTated axes scheme)                    ln_hpg_rot    = ', ln_hpg_rot
+         WRITE(numout,*) '      weighting coeff. (wdj scheme)                     rn_gamma      = ', rn_gamma
+         WRITE(numout,*) '      time stepping: centered (F) or semi-implicit (T)  ln_dynhpg_imp = ', ln_dynhpg_imp
+         WRITE(numout,*) '      add in restart dynhpg semi-implicit variable      nn_dynhpg_rst = ', nn_dynhpg_rst
+      ENDIF
+
+      IF( .NOT. ln_dynhpg_imp )   nn_dynhpg_rst = 0      ! force no adding dynhpg implicit variables in restart
+
+      IF( lk_vvl .AND. .NOT. ln_hpg_sco )   THEN
+         CALL ctl_stop( 'hpg_ctl : variable volume key_vvl compatible only with the standard jacobian formulation hpg_sco')
+      ENDIF
+
+      !                               ! Set nhpg from ln_hpg_... flags
+      IF( ln_hpg_zco )   nhpg = 0
+      IF( ln_hpg_zps )   nhpg = 1
+      IF( ln_hpg_sco )   nhpg = 2
+      IF( ln_hpg_hel )   nhpg = 3
+      IF( ln_hpg_wdj )   nhpg = 4
+      IF( ln_hpg_djc )   nhpg = 5
+      IF( ln_hpg_rot )   nhpg = 6
+
+      !                               ! Consitency check
+      ioptio = 0 
+      IF( ln_hpg_zco )   ioptio = ioptio + 1
+      IF( ln_hpg_zps )   ioptio = ioptio + 1
+      IF( ln_hpg_sco )   ioptio = ioptio + 1
+      IF( ln_hpg_hel )   ioptio = ioptio + 1
+      IF( ln_hpg_wdj )   ioptio = ioptio + 1
+      IF( ln_hpg_djc )   ioptio = ioptio + 1
+      IF( ln_hpg_rot )   ioptio = ioptio + 1
+      IF ( ioptio /= 1 )   CALL ctl_stop( ' NO or several hydrostatic pressure gradient options used' )
+
+      !
+   END SUBROUTINE hpg_ctl
+
+
+   SUBROUTINE hpg_zco( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_zco  ***
+      !!
+      !! ** Method  :   z-coordinate case, levels are horizontal surfaces.
+      !!      The now hydrostatic pressure gradient at a given level, jk,
+      !!      is computed by taking the vertical integral of the in-situ
+      !!      density gradient along the model level from the suface to that
+      !!      level:    zhpi = grav .....
+      !!                zhpj = grav .....
+      !!      add it to the general momentum trend (ua,va).
+      !!            ua = ua - 1/e1u * zhpi
+      !!            va = va - 1/e2v * zhpj
+      !! 
+      !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk       ! dummy loop indices
+      REAL(wp) ::   zcoef0, zcoef1   ! temporary scalars
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_zco : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   z-coordinate case '
+      ENDIF
+      
+      ! Local constant initialization 
+      zcoef0 = - grav * 0.5
+
+      ! Surface value
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zcoef1 = zcoef0 * fse3w(ji,jj,1)
+            ! hydrostatic pressure gradient
+            zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj,1) - rhd(ji,jj,1) ) / e1u(ji,jj)
+            zhpj(ji,jj,1) = zcoef1 * ( rhd(ji,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
+         END DO
+      END DO
+      !
+      ! interior value (2=<jk=<jpkm1)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcoef1 = zcoef0 * fse3w(ji,jj,jk)
+               ! hydrostatic pressure gradient
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1)   &
+                  &           + zcoef1 * (  ( rhd(ji+1,jj,jk)+rhd(ji+1,jj,jk-1) )   &
+                  &                       - ( rhd(ji  ,jj,jk)+rhd(ji  ,jj,jk-1) )  ) / e1u(ji,jj)
+
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1)   &
+                  &           + zcoef1 * (  ( rhd(ji,jj+1,jk)+rhd(ji,jj+1,jk-1) )   &
+                  &                       - ( rhd(ji,jj,  jk)+rhd(ji,jj  ,jk-1) )  ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_zco
+
+
+   SUBROUTINE hpg_zps( kt )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE hpg_zps  ***
+      !!                    
+      !! ** Method  :   z-coordinate plus partial steps case.  blahblah...
+      !! 
+      !! ** Action  : - Update (ua,va) with the now hydrastatic pressure trend
+      !!---------------------------------------------------------------------- 
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk                       ! dummy loop indices
+      INTEGER  ::   iku, ikv                         ! temporary integers
+      REAL(wp) ::   zcoef0, zcoef1, zcoef2, zcoef3   ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_zps : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   z-coordinate with partial steps - vector optimization'
+      ENDIF
+
+      ! Local constant initialization
+      zcoef0 = - grav * 0.5
+
+      !  Surface value
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zcoef1 = zcoef0 * fse3w(ji,jj,1)
+            ! hydrostatic pressure gradient
+            zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj  ,1) - rhd(ji,jj,1) ) / e1u(ji,jj)
+            zhpj(ji,jj,1) = zcoef1 * ( rhd(ji  ,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
+         END DO
+      END DO
+
+      ! interior value (2=<jk=<jpkm1)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcoef1 = zcoef0 * fse3w(ji,jj,jk)
+               ! hydrostatic pressure gradient
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1)   &
+                  &           + zcoef1 * (  ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) )   &
+                  &                       - ( rhd(ji  ,jj,jk) + rhd(ji  ,jj,jk-1) )  ) / e1u(ji,jj)
+
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1)   &
+                  &           + zcoef1 * (  ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) )   &
+                  &                       - ( rhd(ji,jj,  jk) + rhd(ji,jj  ,jk-1) )  ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! partial steps correction at the last level  (new gradient with  intgrd.F)
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj) ) - 1
+            ikv = MIN ( mbathy(ji,jj), mbathy(ji,jj+1) ) - 1
+            zcoef2 = zcoef0 * MIN( fse3w(ji,jj,iku), fse3w(ji+1,jj  ,iku) )
+            zcoef3 = zcoef0 * MIN( fse3w(ji,jj,ikv), fse3w(ji  ,jj+1,ikv) )
+            ! on i-direction
+            IF ( iku > 2 ) THEN
+               ! subtract old value
+               ua(ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku)
+               ! compute the new one
+               zhpi (ji,jj,iku) = zhpi(ji,jj,iku-1)   &
+                  + zcoef2 * ( rhd(ji+1,jj,iku-1) - rhd(ji,jj,iku-1) + gru(ji,jj) ) / e1u(ji,jj)
+               ! add the new one to the general momentum trend
+               ua(ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku)
+            ENDIF
+            ! on j-direction
+            IF ( ikv > 2 ) THEN
+               ! subtract old value
+               va(ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv)
+               ! compute the new one
+               zhpj (ji,jj,ikv) = zhpj(ji,jj,ikv-1)   &
+                  + zcoef3 * ( rhd(ji,jj+1,ikv-1) - rhd(ji,jj,ikv-1) + grv(ji,jj) ) / e2v(ji,jj)
+               ! add the new one to the general momentum trend
+               va(ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv)
+            ENDIF
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+      !
+   END SUBROUTINE hpg_zps
+
+
+   SUBROUTINE hpg_sco( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_sco  ***
+      !!
+      !! ** Method  :   s-coordinate case. Jacobian scheme.
+      !!      The now hydrostatic pressure gradient at a given level, jk,
+      !!      is computed by taking the vertical integral of the in-situ
+      !!      density gradient along the model level from the suface to that
+      !!      level. s-coordinates (ln_sco): a corrective term is added
+      !!      to the horizontal pressure gradient :
+      !!         zhpi = grav .....  + 1/e1u mi(rhd) di[ grav dep3w ]
+      !!         zhpj = grav .....  + 1/e2v mj(rhd) dj[ grav dep3w ]
+      !!      add it to the general momentum trend (ua,va).
+      !!         ua = ua - 1/e1u * zhpi
+      !!         va = va - 1/e2v * zhpj
+      !!
+      !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp) ::   zcoef0, zuap, zvap, znad   ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, OPA original scheme used'
+      ENDIF
+
+      ! Local constant initialization
+      zcoef0 = - grav * 0.5
+      ! To use density and not density anomaly
+      IF ( lk_vvl ) THEN   ;     znad = 1.            ! Variable volume
+      ELSE                 ;     znad = 0.e0          ! Fixed volume
+      ENDIF
+
+      ! Surface value
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.   
+            ! hydrostatic pressure gradient along s-surfaces
+            zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( fse3w(ji+1,jj  ,1) * ( znad + rhd(ji+1,jj  ,1) )   &
+               &                                  - fse3w(ji  ,jj  ,1) * ( znad + rhd(ji  ,jj  ,1) ) )
+            zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( fse3w(ji  ,jj+1,1) * ( znad + rhd(ji  ,jj+1,1) )   &
+               &                                  - fse3w(ji  ,jj  ,1) * ( znad + rhd(ji  ,jj  ,1) ) )
+            ! s-coordinate pressure gradient correction
+            zuap = -zcoef0 * ( rhd   (ji+1,jj,1) + rhd   (ji,jj,1) + 2*znad )   &
+               &           * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj)
+            zvap = -zcoef0 * ( rhd   (ji,jj+1,1) + rhd   (ji,jj,1) + 2*znad )   &
+               &           * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap
+         END DO  
+      END DO   
+            
+      ! interior value (2=<jk=<jpkm1)
+      DO jk = 2, jpkm1                                  
+         DO jj = 2, jpjm1     
+            DO ji = fs_2, fs_jpim1   ! vector opt.      
+               ! hydrostatic pressure gradient along s-surfaces
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj)   & 
+                  &           * (  fse3w(ji+1,jj,jk) * ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) + 2*znad )   & 
+                  &              - fse3w(ji  ,jj,jk) * ( rhd(ji  ,jj,jk) + rhd(ji  ,jj,jk-1) + 2*znad )  )
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) + zcoef0 / e2v(ji,jj)   &
+                  &           * (  fse3w(ji,jj+1,jk) * ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) + 2*znad )   &
+                  &              - fse3w(ji,jj  ,jk) * ( rhd(ji,jj,  jk) + rhd(ji,jj  ,jk-1) + 2*znad )  )
+               ! s-coordinate pressure gradient correction
+               zuap = -zcoef0 * ( rhd   (ji+1,jj  ,jk) + rhd   (ji,jj,jk) + 2*znad )   &
+                  &           * ( fsde3w(ji+1,jj  ,jk) - fsde3w(ji,jj,jk) ) / e1u(ji,jj)
+               zvap = -zcoef0 * ( rhd   (ji  ,jj+1,jk) + rhd   (ji,jj,jk) + 2*znad )   &
+                  &           * ( fsde3w(ji  ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) + zuap
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) + zvap
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_sco
+
+
+   SUBROUTINE hpg_hel( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_hel  ***
+      !!
+      !! ** Method  :   s-coordinate case.
+      !!      The now hydrostatic pressure gradient at a given level
+      !!      jk is computed by taking the vertical integral of the in-situ 
+      !!      density gradient along the model level from the suface to that 
+      !!      level. s-coordinates (ln_sco): a corrective term is added
+      !!      to the horizontal pressure gradient :
+      !!         zhpi = grav .....  + 1/e1u mi(rhd) di[ grav dep3w ]
+      !!         zhpj = grav .....  + 1/e2v mj(rhd) dj[ grav dep3w ]
+      !!      add it to the general momentum trend (ua,va).
+      !!         ua = ua - 1/e1u * zhpi
+      !!         va = va - 1/e2v * zhpj
+      !!
+      !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
+      !!             - Save the trend (l_trddyn=T)
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   zcoef0, zuap, zvap   ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_hel : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, helsinki modified scheme'
+      ENDIF
+
+      ! Local constant initialization
+      zcoef0 = - grav * 0.5
+ 
+      ! Surface value
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! hydrostatic pressure gradient along s-surfaces
+            zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( fse3t(ji+1,jj  ,1) * rhd(ji+1,jj  ,1)  &
+               &                                  - fse3t(ji  ,jj  ,1) * rhd(ji  ,jj  ,1) )
+            zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( fse3t(ji  ,jj+1,1) * rhd(ji  ,jj+1,1)  &
+               &                                  - fse3t(ji  ,jj  ,1) * rhd(ji  ,jj  ,1) )
+            ! s-coordinate pressure gradient correction
+            zuap = -zcoef0 * ( rhd   (ji+1,jj,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsdept(ji+1,jj,1) - fsdept(ji,jj,1) ) / e1u(ji,jj)
+            zvap = -zcoef0 * ( rhd   (ji,jj+1,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsdept(ji,jj+1,1) - fsdept(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap
+         END DO
+      END DO
+      !
+      ! interior value (2=<jk=<jpkm1)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! hydrostatic pressure gradient along s-surfaces
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) &
+                  &           +  zcoef0 / e1u(ji,jj) * ( fse3t(ji+1,jj,jk  ) * rhd(ji+1,jj,jk)     &
+                  &                                     -fse3t(ji  ,jj,jk  ) * rhd(ji  ,jj,jk)   ) &
+                  &           +  zcoef0 / e1u(ji,jj) * ( fse3t(ji+1,jj,jk-1) * rhd(ji+1,jj,jk-1)   &
+                  &                                     -fse3t(ji  ,jj,jk-1) * rhd(ji  ,jj,jk-1) )
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) &
+                  &           +  zcoef0 / e2v(ji,jj) * ( fse3t(ji,jj+1,jk  ) * rhd(ji,jj+1,jk)   &
+                  &                                     -fse3t(ji,jj  ,jk  ) * rhd(ji,jj,  jk)   ) &
+                  &           +  zcoef0 / e2v(ji,jj) * ( fse3t(ji,jj+1,jk-1) * rhd(ji,jj+1,jk-1) &
+                  &                                     -fse3t(ji,jj  ,jk-1) * rhd(ji,jj,  jk-1) )
+               ! s-coordinate pressure gradient correction
+               zuap = - zcoef0 * ( rhd   (ji+1,jj,jk) + rhd   (ji,jj,jk) )   &
+                  &            * ( fsdept(ji+1,jj,jk) - fsdept(ji,jj,jk) ) / e1u(ji,jj)
+               zvap = - zcoef0 * ( rhd   (ji,jj+1,jk) + rhd   (ji,jj,jk) )   &
+                  &            * ( fsdept(ji,jj+1,jk) - fsdept(ji,jj,jk) ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) + zuap
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) + zvap
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_hel
+
+
+   SUBROUTINE hpg_wdj( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_wdj  ***
+      !!
+      !! ** Method  :   Weighted Density Jacobian (wdj) scheme (song 1998)
+      !!      The weighting coefficients from the namelist parameter rn_gamma
+      !!      (alpha=0.5-rn_gamma ; beta=1-alpha=0.5+rn_gamma
+      !!
+      !! Reference : Song, Mon. Wea. Rev., 126, 3213-3230, 1998.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   zcoef0, zuap, zvap   ! temporary scalars
+      REAL(wp) ::   zalph , zbeta        !    "         "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_wdj : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   Weighted Density Jacobian'
+      ENDIF
+
+      ! Local constant initialization
+      zcoef0 = - grav * 0.5
+      zalph  = 0.5 - rn_gamma    ! weighting coefficients (alpha=0.5-rn_gamma
+      zbeta  = 0.5 + rn_gamma    !                        (beta =1-alpha=0.5+rn_gamma
+
+      ! Surface value (no ponderation)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! hydrostatic pressure gradient along s-surfaces
+            zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * (  fse3w(ji+1,jj  ,1) * rhd(ji+1,jj  ,1)   &
+               &                                   - fse3w(ji  ,jj  ,1) * rhd(ji  ,jj  ,1)  )
+            zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * (  fse3w(ji  ,jj+1,1) * rhd(ji  ,jj+1,1)   &
+               &                                   - fse3w(ji  ,jj  ,1) * rhd(ji,  jj  ,1)  )
+            ! s-coordinate pressure gradient correction
+            zuap = -zcoef0 * ( rhd   (ji+1,jj,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj)
+            zvap = -zcoef0 * ( rhd   (ji,jj+1,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap
+         END DO
+      END DO
+
+      ! Interior value (2=<jk=<jpkm1) (weighted with zalph & zbeta)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj)                            &
+                  &           * (   (            fsde3w(ji+1,jj,jk  ) + fsde3w(ji,jj,jk  )        &
+                  &                            - fsde3w(ji+1,jj,jk-1) - fsde3w(ji,jj,jk-1)    )   &
+                  &               * (  zalph * ( rhd   (ji+1,jj,jk-1) - rhd   (ji,jj,jk-1) )      &
+                  &                  + zbeta * ( rhd   (ji+1,jj,jk  ) - rhd   (ji,jj,jk  ) )  )   &
+                  &             -   (            rhd   (ji+1,jj,jk  ) + rhd   (ji,jj,jk  )        &
+                  &                           - rhd   (ji+1,jj,jk-1) - rhd   (ji,jj,jk-1)     )   &
+                  &               * (  zalph * ( fsde3w(ji+1,jj,jk-1) - fsde3w(ji,jj,jk-1) )      &
+                  &                  + zbeta * ( fsde3w(ji+1,jj,jk  ) - fsde3w(ji,jj,jk  ) )  )  )
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) + zcoef0 / e2v(ji,jj)                            &
+                  &           * (   (           fsde3w(ji,jj+1,jk  ) + fsde3w(ji,jj,jk  )         &
+                  &                           - fsde3w(ji,jj+1,jk-1) - fsde3w(ji,jj,jk-1)     )   &
+                  &               * (  zalph * ( rhd   (ji,jj+1,jk-1) - rhd   (ji,jj,jk-1) )      &
+                  &                  + zbeta * ( rhd   (ji,jj+1,jk  ) - rhd   (ji,jj,jk  ) )  )   &
+                  &             -   (            rhd   (ji,jj+1,jk  ) + rhd   (ji,jj,jk  )        &
+                  &                            - rhd   (ji,jj+1,jk-1) - rhd   (ji,jj,jk-1)    )   &
+                  &               * (  zalph * ( fsde3w(ji,jj+1,jk-1) - fsde3w(ji,jj,jk-1) )      &
+                  &                  + zbeta * ( fsde3w(ji,jj+1,jk  ) - fsde3w(ji,jj,jk  ) )  )  )
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_wdj
+
+
+   SUBROUTINE hpg_djc( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_djc  ***
+      !!
+      !! ** Method  :   Density Jacobian with Cubic polynomial scheme
+      !! 
+      !! Reference: Shchepetkin and McWilliams, J. Geophys. Res., 108(C3), 3090, 2003
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk          ! dummy loop indices
+      REAL(wp) ::   zcoef0, zep, cffw   ! temporary scalars
+      REAL(wp) ::   z1_10, cffu, cffx   !    "         "
+      REAL(wp) ::   z1_12, cffv, cffy   !    "         "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   drhox, dzx, drhou, dzu, rho_i   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   drhoy, dzy, drhov, dzv, rho_j   !  "      "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   drhoz, dzz, drhow, dzw, rho_k   !  "      "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_djc : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, density Jacobian with cubic polynomial scheme'
+      ENDIF
+
+
+      ! Local constant initialization
+      zcoef0 = - grav * 0.5
+      z1_10  = 1.0 / 10.0
+      z1_12  = 1.0 / 12.0
+
+      !----------------------------------------------------------------------------------------
+      !  compute and store in provisional arrays elementary vertical and horizontal differences
+      !----------------------------------------------------------------------------------------
+
+!!bug gm   Not a true bug, but... dzz=e3w  for dzx, dzy verify what it is really
+
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               drhoz(ji,jj,jk) = rhd   (ji  ,jj  ,jk) - rhd   (ji,jj,jk-1)
+               dzz  (ji,jj,jk) = fsde3w(ji  ,jj  ,jk) - fsde3w(ji,jj,jk-1)
+               drhox(ji,jj,jk) = rhd   (ji+1,jj  ,jk) - rhd   (ji,jj,jk  )
+               dzx  (ji,jj,jk) = fsde3w(ji+1,jj  ,jk) - fsde3w(ji,jj,jk  )
+               drhoy(ji,jj,jk) = rhd   (ji  ,jj+1,jk) - rhd   (ji,jj,jk  )
+               dzy  (ji,jj,jk) = fsde3w(ji  ,jj+1,jk) - fsde3w(ji,jj,jk  )
+            END DO
+         END DO
+      END DO
+
+      !-------------------------------------------------------------------------
+      ! compute harmonic averages using eq. 5.18
+      !-------------------------------------------------------------------------
+      zep = 1.e-15
+
+!!bug  gm  drhoz not defined at level 1 and used (jk-1 with jk=2)
+!!bug  gm  idem for drhox, drhoy et ji=jpi and jj=jpj
+
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               cffw = 2.0 * drhoz(ji  ,jj  ,jk) * drhoz(ji,jj,jk-1)
+
+               cffu = 2.0 * drhox(ji+1,jj  ,jk) * drhox(ji,jj,jk  )
+               cffx = 2.0 * dzx  (ji+1,jj  ,jk) * dzx  (ji,jj,jk  )
+  
+               cffv = 2.0 * drhoy(ji  ,jj+1,jk) * drhoy(ji,jj,jk  )
+               cffy = 2.0 * dzy  (ji  ,jj+1,jk) * dzy  (ji,jj,jk  )
+
+               IF( cffw > zep) THEN
+                  drhow(ji,jj,jk) = 2.0 *   drhoz(ji,jj,jk) * drhoz(ji,jj,jk-1)   &
+                     &                  / ( drhoz(ji,jj,jk) + drhoz(ji,jj,jk-1) )
+               ELSE
+                  drhow(ji,jj,jk) = 0.e0
+               ENDIF
+
+               dzw(ji,jj,jk) = 2.0 *   dzz(ji,jj,jk) * dzz(ji,jj,jk-1)   &
+                  &                / ( dzz(ji,jj,jk) + dzz(ji,jj,jk-1) )
+
+               IF( cffu > zep ) THEN
+                  drhou(ji,jj,jk) = 2.0 *   drhox(ji+1,jj,jk) * drhox(ji,jj,jk)   &
+                     &                  / ( drhox(ji+1,jj,jk) + drhox(ji,jj,jk) )
+               ELSE
+                  drhou(ji,jj,jk ) = 0.e0
+               ENDIF
+
+               IF( cffx > zep ) THEN
+                  dzu(ji,jj,jk) = 2.0*dzx(ji+1,jj,jk)*dzx(ji,jj,jk)   &
+                     &            /(dzx(ji+1,jj,jk)+dzx(ji,jj,jk))
+               ELSE
+                  dzu(ji,jj,jk) = 0.e0
+               ENDIF
+
+               IF( cffv > zep ) THEN
+                  drhov(ji,jj,jk) = 2.0 *   drhoy(ji,jj+1,jk) * drhoy(ji,jj,jk)   &
+                     &                  / ( drhoy(ji,jj+1,jk) + drhoy(ji,jj,jk) )
+               ELSE
+                  drhov(ji,jj,jk) = 0.e0
+               ENDIF
+
+               IF( cffy > zep ) THEN
+                  dzv(ji,jj,jk) = 2.0 *   dzy(ji,jj+1,jk) * dzy(ji,jj,jk)   &
+                     &                / ( dzy(ji,jj+1,jk) + dzy(ji,jj,jk) )
+               ELSE
+                  dzv(ji,jj,jk) = 0.e0
+               ENDIF
+
+            END DO
+         END DO
+      END DO
+
+      !----------------------------------------------------------------------------------
+      ! apply boundary conditions at top and bottom using 5.36-5.37
+      !----------------------------------------------------------------------------------
+      drhow(:,:, 1 ) = 1.5 * ( drhoz(:,:, 2 ) - drhoz(:,:,  1  ) ) - 0.5 * drhow(:,:,  2  )
+      drhou(:,:, 1 ) = 1.5 * ( drhox(:,:, 2 ) - drhox(:,:,  1  ) ) - 0.5 * drhou(:,:,  2  )
+      drhov(:,:, 1 ) = 1.5 * ( drhoy(:,:, 2 ) - drhoy(:,:,  1  ) ) - 0.5 * drhov(:,:,  2  )
+
+      drhow(:,:,jpk) = 1.5 * ( drhoz(:,:,jpk) - drhoz(:,:,jpkm1) ) - 0.5 * drhow(:,:,jpkm1)
+      drhou(:,:,jpk) = 1.5 * ( drhox(:,:,jpk) - drhox(:,:,jpkm1) ) - 0.5 * drhou(:,:,jpkm1)
+      drhov(:,:,jpk) = 1.5 * ( drhoy(:,:,jpk) - drhoy(:,:,jpkm1) ) - 0.5 * drhov(:,:,jpkm1)
+
+
+      !--------------------------------------------------------------
+      ! Upper half of top-most grid box, compute and store
+      !-------------------------------------------------------------
+
+!!bug gm   :  e3w-de3w = 0.5*e3w  ....  and de3w(2)-de3w(1)=e3w(2) ....   to be verified
+!          true if de3w is really defined as the sum of the e3w scale factors as, it seems to me, it should be
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            rho_k(ji,jj,1) = -grav * ( fse3w(ji,jj,1) - fsde3w(ji,jj,1) )            &
+               &                   * (  rhd(ji,jj,1)                                 &
+               &                     + 0.5 * ( rhd(ji,jj,2) - rhd(ji,jj,1) )         &
+               &                           * ( fse3w (ji,jj,1) - fsde3w(ji,jj,1) )   &
+               &                           / ( fsde3w(ji,jj,2) - fsde3w(ji,jj,1) )  ) 
+         END DO
+      END DO
+
+!!bug gm    : here also, simplification is possible
+!!bug gm    : optimisation: 1/10 and 1/12 the division should be done before the loop
+
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+
+               rho_k(ji,jj,jk) = zcoef0 * ( rhd   (ji,jj,jk) + rhd   (ji,jj,jk-1) )                                   &
+                  &                     * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) )                                   &
+                  &            - grav * z1_10 * (                                                                     &
+                  &     ( drhow (ji,jj,jk) - drhow (ji,jj,jk-1) )                                                     &
+                  &   * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) - z1_12 * ( dzw  (ji,jj,jk) + dzw  (ji,jj,jk-1) ) )   &
+                  &   - ( dzw   (ji,jj,jk) - dzw   (ji,jj,jk-1) )                                                     &
+                  &   * ( rhd   (ji,jj,jk) - rhd   (ji,jj,jk-1) - z1_12 * ( drhow(ji,jj,jk) + drhow(ji,jj,jk-1) ) )   &
+                  &                             )
+
+               rho_i(ji,jj,jk) = zcoef0 * ( rhd   (ji+1,jj,jk) + rhd   (ji,jj,jk) )                                   &
+                  &                     * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) )                                   &
+                  &            - grav* z1_10 * (                                                                      &
+                  &     ( drhou (ji+1,jj,jk) - drhou (ji,jj,jk) )                                                     &
+                  &   * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzu  (ji+1,jj,jk) + dzu  (ji,jj,jk) ) )   &
+                  &   - ( dzu   (ji+1,jj,jk) - dzu   (ji,jj,jk) )                                                     &
+                  &   * ( rhd   (ji+1,jj,jk) - rhd   (ji,jj,jk) - z1_12 * ( drhou(ji+1,jj,jk) + drhou(ji,jj,jk) ) )   &
+                  &                            )
+
+               rho_j(ji,jj,jk) = zcoef0 * ( rhd   (ji,jj+1,jk) + rhd   (ji,jj,jk) )                                   &
+                  &                     * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) )                                   &
+                  &            - grav* z1_10 * (                                                                      &
+                  &     ( drhov (ji,jj+1,jk) - drhov (ji,jj,jk) )                                                     &
+                  &   * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzv  (ji,jj+1,jk) + dzv  (ji,jj,jk) ) )   &
+                  &   - ( dzv   (ji,jj+1,jk) - dzv   (ji,jj,jk) )                                                     &
+                  &   * ( rhd   (ji,jj+1,jk) - rhd   (ji,jj,jk) - z1_12 * ( drhov(ji,jj+1,jk) + drhov(ji,jj,jk) ) )   &
+                  &                            )
+
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk(rho_k,'W',1.)
+      CALL lbc_lnk(rho_i,'U',1.)
+      CALL lbc_lnk(rho_j,'V',1.)
+
+
+      ! ---------------
+      !  Surface value
+      ! ---------------
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zhpi(ji,jj,1) = ( rho_k(ji+1,jj  ,1) - rho_k(ji,jj,1) - rho_i(ji,jj,1) ) / e1u(ji,jj)
+            zhpj(ji,jj,1) = ( rho_k(ji  ,jj+1,1) - rho_k(ji,jj,1) - rho_j(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
+            va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
+         END DO
+      END DO
+
+      ! ----------------
+      !  interior value   (2=<jk=<jpkm1)
+      ! ----------------
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! hydrostatic pressure gradient along s-surfaces
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1)                                &
+                  &           + (  ( rho_k(ji+1,jj,jk) - rho_k(ji,jj,jk  ) )    &
+                  &              - ( rho_i(ji  ,jj,jk) - rho_i(ji,jj,jk-1) )  ) / e1u(ji,jj)
+               zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1)                                &
+                  &           + (  ( rho_k(ji,jj+1,jk) - rho_k(ji,jj,jk  ) )    &
+                  &               -( rho_j(ji,jj  ,jk) - rho_j(ji,jj,jk-1) )  ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_djc
+
+
+   SUBROUTINE hpg_rot( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE hpg_rot  ***
+      !!
+      !! ** Method  :   rotated axes scheme (Thiem and Berntsen 2005)
+      !!
+      !! Reference: Thiem & Berntsen, Ocean Modelling, In press, 2005.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zhpi => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   zhpj => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk          ! dummy loop indices
+      REAL(wp) ::   zforg, zcoef0, zuap, zmskd1, zmskd1m   ! temporary scalar
+      REAL(wp) ::   zfrot        , zvap, zmskd2, zmskd2m   !    "         "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdistr, zsina, zcosa                ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zhpiorg, zhpirot, zhpitra, zhpine   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zhpjorg, zhpjrot, zhpjtra, zhpjne   !  "      "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:hpg_rot : hydrostatic pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, rotated axes scheme used'
+      ENDIF
+
+      ! -------------------------------
+      !  Local constant initialization
+      ! -------------------------------
+      zcoef0 = - grav * 0.5
+      zforg  = 0.95e0
+      zfrot  = 1.e0 - zforg
+
+      ! inverse of the distance between 2 diagonal T-points (defined at F-point) (here zcoef0/distance)
+      zdistr(:,:) = zcoef0 / SQRT( e1f(:,:)*e1f(:,:) + e2f(:,:)*e1f(:,:) )
+
+      ! sinus and cosinus of diagonal angle at F-point
+      zsina(:,:) = ATAN2( e2f(:,:), e1f(:,:) )
+      zcosa(:,:) = COS( zsina(:,:) )
+      zsina(:,:) = SIN( zsina(:,:) )
+
+      ! ---------------
+      !  Surface value
+      ! ---------------
+      ! compute and add to the general trend the pressure gradients along the axes
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! hydrostatic pressure gradient along s-surfaces
+            zhpiorg(ji,jj,1) = zcoef0 / e1u(ji,jj) * (  fse3t(ji+1,jj,1) * rhd(ji+1,jj,1)   &
+               &                                      - fse3t(ji  ,jj,1) * rhd(ji  ,jj,1)  )
+            zhpjorg(ji,jj,1) = zcoef0 / e2v(ji,jj) * (  fse3t(ji,jj+1,1) * rhd(ji,jj+1,1)   &
+               &                                      - fse3t(ji,jj  ,1) * rhd(ji,jj  ,1)  )
+            ! s-coordinate pressure gradient correction
+            zuap = -zcoef0 * ( rhd   (ji+1,jj  ,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsdept(ji+1,jj  ,1) - fsdept(ji,jj,1) ) / e1u(ji,jj)
+            zvap = -zcoef0 * ( rhd   (ji  ,jj+1,1) + rhd   (ji,jj,1) )   &
+               &           * ( fsdept(ji  ,jj+1,1) - fsdept(ji,jj,1) ) / e2v(ji,jj)
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zforg * ( zhpiorg(ji,jj,1) + zuap )
+            va(ji,jj,1) = va(ji,jj,1) + zforg * ( zhpjorg(ji,jj,1) + zvap )
+         END DO
+      END DO
+
+      ! compute the pressure gradients in the diagonal directions
+      DO jj = 1, jpjm1
+         DO ji = 1, fs_jpim1   ! vector opt.
+            zmskd1 = tmask(ji+1,jj+1,1) * tmask(ji  ,jj,1)      ! mask in the 1st diagnonal
+            zmskd2 = tmask(ji  ,jj+1,1) * tmask(ji+1,jj,1)      ! mask in the 2nd diagnonal
+            ! hydrostatic pressure gradient along s-surfaces
+            zhpitra(ji,jj,1) = zdistr(ji,jj) * zmskd1 * (  fse3t(ji+1,jj+1,1) * rhd(ji+1,jj+1,1)   &
+               &                                         - fse3t(ji  ,jj  ,1) * rhd(ji  ,jj  ,1)  )
+            zhpjtra(ji,jj,1) = zdistr(ji,jj) * zmskd2 * (  fse3t(ji  ,jj+1,1) * rhd(ji  ,jj+1,1)   &
+               &                                         - fse3t(ji+1,jj  ,1) * rhd(ji+1,jj  ,1)  )
+            ! s-coordinate pressure gradient correction
+            zuap = -zdistr(ji,jj) * zmskd1 * ( rhd   (ji+1,jj+1,1) + rhd   (ji  ,jj,1) )   &
+               &                           * ( fsdept(ji+1,jj+1,1) - fsdept(ji  ,jj,1) )
+            zvap = -zdistr(ji,jj) * zmskd2 * ( rhd   (ji  ,jj+1,1) + rhd   (ji+1,jj,1) )   &
+               &                           * ( fsdept(ji  ,jj+1,1) - fsdept(ji+1,jj,1) )
+            ! back rotation
+            zhpine(ji,jj,1) = zcosa(ji,jj) * ( zhpitra(ji,jj,1) + zuap )   &
+               &            - zsina(ji,jj) * ( zhpjtra(ji,jj,1) + zvap )
+            zhpjne(ji,jj,1) = zsina(ji,jj) * ( zhpitra(ji,jj,1) + zuap )   &
+               &            + zcosa(ji,jj) * ( zhpjtra(ji,jj,1) + zvap )
+         END DO
+      END DO
+
+      ! interpolate and add to the general trend the diagonal gradient
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! averaging
+            zhpirot(ji,jj,1) = 0.5 * ( zhpine(ji,jj,1) + zhpine(ji  ,jj-1,1) )
+            zhpjrot(ji,jj,1) = 0.5 * ( zhpjne(ji,jj,1) + zhpjne(ji-1,jj  ,1) )
+            ! add to the general momentum trend
+            ua(ji,jj,1) = ua(ji,jj,1) + zfrot * zhpirot(ji,jj,1) 
+            va(ji,jj,1) = va(ji,jj,1) + zfrot * zhpjrot(ji,jj,1) 
+         END DO
+      END DO
+
+      ! -----------------
+      ! 2. interior value (2=<jk=<jpkm1)
+      ! -----------------
+      ! compute and add to the general trend the pressure gradients along the axes
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! hydrostatic pressure gradient along s-surfaces
+               zhpiorg(ji,jj,jk) = zhpiorg(ji,jj,jk-1)                                                 &
+                  &              +  zcoef0 / e1u(ji,jj) * (  fse3t(ji+1,jj,jk  ) * rhd(ji+1,jj,jk  )   &
+                  &                                        - fse3t(ji  ,jj,jk  ) * rhd(ji  ,jj,jk  )   &
+                  &                                        + fse3t(ji+1,jj,jk-1) * rhd(ji+1,jj,jk-1)   &
+                  &                                        - fse3t(ji  ,jj,jk-1) * rhd(ji  ,jj,jk-1)  )
+               zhpjorg(ji,jj,jk) = zhpjorg(ji,jj,jk-1)                                                 &
+                  &              +  zcoef0 / e2v(ji,jj) * (  fse3t(ji,jj+1,jk  ) * rhd(ji,jj+1,jk  )   &
+                  &                                        - fse3t(ji,jj  ,jk  ) * rhd(ji,jj,  jk  )   &
+                  &                                        + fse3t(ji,jj+1,jk-1) * rhd(ji,jj+1,jk-1)   &
+                  &                                        - fse3t(ji,jj  ,jk-1) * rhd(ji,jj,  jk-1)  )
+               ! s-coordinate pressure gradient correction
+               zuap = - zcoef0 * ( rhd   (ji+1,jj  ,jk) + rhd   (ji,jj,jk) )   &
+                  &            * ( fsdept(ji+1,jj  ,jk) - fsdept(ji,jj,jk) ) / e1u(ji,jj)
+               zvap = - zcoef0 * ( rhd   (ji  ,jj+1,jk) + rhd   (ji,jj,jk) )   &
+                  &            * ( fsdept(ji  ,jj+1,jk) - fsdept(ji,jj,jk) ) / e2v(ji,jj)
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zforg*( zhpiorg(ji,jj,jk) + zuap )
+               va(ji,jj,jk) = va(ji,jj,jk) + zforg*( zhpjorg(ji,jj,jk) + zvap )
+            END DO
+         END DO
+      END DO
+
+      ! compute the pressure gradients in the diagonal directions
+      DO jk = 2, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zmskd1  = tmask(ji+1,jj+1,jk  ) * tmask(ji  ,jj,jk  )      ! level jk   mask in the 1st diagnonal
+               zmskd1m = tmask(ji+1,jj+1,jk-1) * tmask(ji  ,jj,jk-1)      ! level jk-1    "               "     
+               zmskd2  = tmask(ji  ,jj+1,jk  ) * tmask(ji+1,jj,jk  )      ! level jk   mask in the 2nd diagnonal
+               zmskd2m = tmask(ji  ,jj+1,jk-1) * tmask(ji+1,jj,jk-1)      ! level jk-1    "               "     
+               ! hydrostatic pressure gradient along s-surfaces
+               zhpitra(ji,jj,jk) = zhpitra(ji,jj,jk-1)                                                       &
+                  &              + zdistr(ji,jj) * zmskd1  * ( fse3t(ji+1,jj+1,jk  ) * rhd(ji+1,jj+1,jk)     &
+                  &                                           -fse3t(ji  ,jj  ,jk  ) * rhd(ji  ,jj  ,jk) )   &
+                  &              + zdistr(ji,jj) * zmskd1m * ( fse3t(ji+1,jj+1,jk-1) * rhd(ji+1,jj+1,jk-1)   &
+                  &                                           -fse3t(ji  ,jj  ,jk-1) * rhd(ji  ,jj  ,jk-1) )
+               zhpjtra(ji,jj,jk) = zhpjtra(ji,jj,jk-1)                                                       &
+                  &              + zdistr(ji,jj) * zmskd2  * ( fse3t(ji  ,jj+1,jk  ) * rhd(ji  ,jj+1,jk)     &
+                  &                                           -fse3t(ji+1,jj  ,jk  ) * rhd(ji+1,jj,  jk) )   &
+                  &              + zdistr(ji,jj) * zmskd2m * ( fse3t(ji  ,jj+1,jk-1) * rhd(ji  ,jj+1,jk-1)   &
+                  &                                           -fse3t(ji+1,jj  ,jk-1) * rhd(ji+1,jj,  jk-1) )
+               ! s-coordinate pressure gradient correction
+               zuap = - zdistr(ji,jj) * zmskd1 * ( rhd   (ji+1,jj+1,jk) + rhd   (ji  ,jj,jk) )   &
+                  &                            * ( fsdept(ji+1,jj+1,jk) - fsdept(ji  ,jj,jk) )
+               zvap = - zdistr(ji,jj) * zmskd2 * ( rhd   (ji  ,jj+1,jk) + rhd   (ji+1,jj,jk) )   &
+                  &                            * ( fsdept(ji  ,jj+1,jk) - fsdept(ji+1,jj,jk) )
+               ! back rotation
+               zhpine(ji,jj,jk) = zcosa(ji,jj) * ( zhpitra(ji,jj,jk) + zuap )   &
+                  &             - zsina(ji,jj) * ( zhpjtra(ji,jj,jk) + zvap )
+               zhpjne(ji,jj,jk) = zsina(ji,jj) * ( zhpitra(ji,jj,jk) + zuap )   &
+                  &             + zcosa(ji,jj) * ( zhpjtra(ji,jj,jk) + zvap )
+            END DO
+         END DO
+      END DO
+
+      ! interpolate and add to the general trend
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! averaging
+               zhpirot(ji,jj,jk) = 0.5 * ( zhpine(ji,jj,jk) + zhpine(ji  ,jj-1,jk) )
+               zhpjrot(ji,jj,jk) = 0.5 * ( zhpjne(ji,jj,jk) + zhpjne(ji-1,jj  ,jk) )
+               ! add to the general momentum trend
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zfrot * zhpirot(ji,jj,jk) 
+               va(ji,jj,jk) = va(ji,jj,jk) + zfrot * zhpjrot(ji,jj,jk) 
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE hpg_rot
+
+   !!======================================================================
+END MODULE dynhpg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynkeg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 1844)
@@ -0,0 +1,109 @@
+MODULE dynkeg
+   !!======================================================================
+   !!                       ***  MODULE  dynkeg  ***
+   !! Ocean dynamics:  kinetic energy gradient trend
+   !!======================================================================
+   !! History :  1.0  !  87-09  (P. Andrich, m.-a. Foujols)  Original code
+   !!            7.0  !  97-05  (G. Madec)  Split dynber into dynkeg and dynhpg
+   !!            9.0  !  02-07  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   
+   !!----------------------------------------------------------------------
+   !!   dyn_keg      : update the momentum trend with the horizontal tke
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_keg    ! routine called by step module
+   
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_keg( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_keg  ***
+      !!
+      !! ** Purpose :   Compute the now momentum trend due to the horizontal
+      !!      gradient of the horizontal kinetic energy and add it to the 
+      !!      general momentum trend.
+      !!
+      !! ** Method  :   Compute the now horizontal kinetic energy 
+      !!         zhke = 1/2 [ mi-1( un^2 ) + mj-1( vn^2 ) ]
+      !!      Take its horizontal gradient and add it to the general momentum
+      !!      trend (ua,va).
+      !!         ua = ua - 1/e1u di[ zhke ]
+      !!         va = va - 1/e2v dj[ zhke ]
+      !!
+      !! ** Action : - Update the (ua, va) with the hor. ke gradient trend
+      !!             - save this trends (l_trddyn=T) for post-processing
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdu => ta   ! use ta as 3D workspace   
+      USE oce, ONLY :   ztrdv => sa   ! use sa as 3D workspace   
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zu, zv       ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zhke   ! temporary 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_keg : kinetic energy gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      IF( l_trddyn ) THEN           ! Save ua and va trends
+         ztrdu(:,:,:) = ua(:,:,:) 
+         ztrdv(:,:,:) = va(:,:,:) 
+      ENDIF
+      
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         DO jj = 2, jpj         ! Horizontal kinetic energy at T-point
+            DO ji = fs_2, jpi   ! vector opt.
+               zu = 0.25 * (  un(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)   &
+                  &         + un(ji  ,jj  ,jk) * un(ji  ,jj  ,jk)  )
+               zv = 0.25 * (  vn(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)   &
+                  &         + vn(ji  ,jj  ,jk) * vn(ji  ,jj  ,jk)  )
+               zhke(ji,jj,jk) = zv + zu
+            END DO  
+         END DO  
+         DO jj = 2, jpjm1       ! add the gradient of kinetic energy to the general momentum trends
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) - ( zhke(ji+1,jj  ,jk) - zhke(ji,jj,jk) ) / e1u(ji,jj)
+               va(ji,jj,jk) = va(ji,jj,jk) - ( zhke(ji  ,jj+1,jk) - zhke(ji,jj,jk) ) / e2v(ji,jj)
+            END DO 
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+      IF( l_trddyn ) THEN      ! save the Kinetic Energy trends for diagnostic
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_keg, 'DYN', kt )
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' keg  - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_keg
+
+   !!======================================================================
+END MODULE dynkeg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 1844)
@@ -0,0 +1,191 @@
+MODULE dynldf
+   !!======================================================================
+   !!                       ***  MODULE  dynldf  ***
+   !! Ocean physics:  lateral diffusivity trends 
+   !!=====================================================================
+   !! History :  9.0  !  05-11  (G. Madec)  Original code (new step architecture)
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf     : update the dynamics trend with the lateral diffusion
+   !!   dyn_ldf_ctl : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE ldfdyn_oce     ! ocean dynamics lateral physics
+   USE ldfslp         ! lateral mixing: slopes of mixing orientation
+   USE dynldf_bilapg  ! lateral mixing            (dyn_ldf_bilapg routine)
+   USE dynldf_bilap   ! lateral mixing            (dyn_ldf_bilap  routine)
+   USE dynldf_iso     ! lateral mixing            (dyn_ldf_iso    routine)
+   USE dynldf_lap     ! lateral mixing            (dyn_ldf_lap    routine)
+   USE trdmod         ! ocean dynamics and tracer trends
+   USE trdmod_oce     ! ocean variables trends
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! distribued memory computing library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_ldf   ! called by step module 
+
+   INTEGER ::   nldf = 0   ! type of lateral diffusion used defined from ln_dynldf_... namlist logicals)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_ldf( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_ldf  ***
+      !! 
+      !! ** Purpose :   compute the lateral ocean dynamics physics.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdu, ztrdv   ! 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL dyn_ldf_ctl      ! initialisation & control of options
+
+      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+         ztrdu(:,:,:) = ua(:,:,:) 
+         ztrdv(:,:,:) = va(:,:,:) 
+      ENDIF
+
+      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
+      !
+      CASE ( 0 )    ;   CALL dyn_ldf_lap    ( kt )      ! iso-level laplacian
+      CASE ( 1 )    ;   CALL dyn_ldf_iso    ( kt )      ! rotated laplacian (except dk[ dk[.] ] part)
+      CASE ( 2 )    ;   CALL dyn_ldf_bilap  ( kt )      ! iso-level bilaplacian
+      CASE ( 3 )    ;   CALL dyn_ldf_bilapg ( kt )      ! s-coord. horizontal bilaplacian
+      !
+      CASE ( -1 )                                       ! esopa: test all possibility with control print
+                        CALL dyn_ldf_lap    ( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf0 - Ua: ', mask1=umask,   &
+            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                        CALL dyn_ldf_iso    ( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf1 - Ua: ', mask1=umask,   &
+            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                        CALL dyn_ldf_bilap  ( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf2 - Ua: ', mask1=umask,   &
+            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                        CALL dyn_ldf_bilapg ( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf3 - Ua: ', mask1=umask,   &
+            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      END SELECT
+
+      IF( l_trddyn ) THEN                        ! save the horizontal diffusive trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_ldf, 'DYN', kt )
+      ENDIF
+      !                                          ! print sum trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf  - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_ldf
+
+
+   SUBROUTINE dyn_ldf_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_ldf_ctl  ***
+      !! 
+      !! ** Purpose :   initializations of the horizontal ocean dynamics physics
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio, ierr         ! temporary integers 
+      !!----------------------------------------------------------------------
+    
+      !                                   ! Namelist nam_dynldf: already read in ldfdyn module
+
+      IF(lwp) THEN                        ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_ldf_ctl : Choice of the lateral diffusive operator on dynamics'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '       Namelist nam_dynldf : set lateral mixing parameters (type, direction, coefficients)'
+         WRITE(numout,*) '          laplacian operator          ln_dynldf_lap   = ', ln_dynldf_lap
+         WRITE(numout,*) '          bilaplacian operator        ln_dynldf_bilap = ', ln_dynldf_bilap
+         WRITE(numout,*) '          iso-level                   ln_dynldf_level = ', ln_dynldf_level
+         WRITE(numout,*) '          horizontal (geopotential)   ln_dynldf_hor   = ', ln_dynldf_hor
+         WRITE(numout,*) '          iso-neutral                 ln_dynldf_iso   = ', ln_dynldf_iso
+      ENDIF
+
+      !                                   ! control the consistency
+      ioptio = 0
+      IF( ln_dynldf_lap   )   ioptio = ioptio + 1
+      IF( ln_dynldf_bilap )   ioptio = ioptio + 1
+      IF( ioptio /= 1 ) CALL ctl_stop( '          use ONE of the 2 lap/bilap operator type on dynamics' )
+      ioptio = 0
+      IF( ln_dynldf_level )   ioptio = ioptio + 1
+      IF( ln_dynldf_hor   )   ioptio = ioptio + 1
+      IF( ln_dynldf_iso   )   ioptio = ioptio + 1
+      IF( ioptio /= 1 ) CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
+
+      !                                   ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
+      ierr = 0
+      IF ( ln_dynldf_lap ) THEN      ! laplacian operator
+         IF ( ln_zco ) THEN                ! z-coordinate
+            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
+            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
+            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate
+            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed
+            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
+            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! z-coordinate
+            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
+            IF ( ln_dynldf_hor   )   nldf = 1      ! horizontal (   rotation)
+            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+      ENDIF
+
+      IF( ln_dynldf_bilap ) THEN      ! bilaplacian operator
+         IF ( ln_zco ) THEN                ! z-coordinate
+            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
+            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
+            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate
+            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed 
+            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
+            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! z-coordinate
+            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
+            IF ( ln_dynldf_hor   )   nldf = 3      ! horizontal (   rotation)
+            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+      ENDIF
+      
+      IF( lk_esopa )                 nldf = -1     ! esopa test
+
+      IF( ierr == 1 )   CALL ctl_stop( 'iso-level in z-coordinate - partial step, not allowed' )
+      IF( ierr == 2 )   CALL ctl_stop( 'isoneutral bilaplacian operator does not exist' )
+      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
+         IF( .NOT.lk_ldfslp )   CALL ctl_stop( 'the rotation of the diffusive tensor require key_ldfslp' )
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nldf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
+         IF( nldf ==  0 )   WRITE(numout,*) '              laplacian operator'
+         IF( nldf ==  1 )   WRITE(numout,*) '              Rotated laplacian operator'
+         IF( nldf ==  2 )   WRITE(numout,*) '              bilaplacian operator'
+         IF( nldf ==  3 )   WRITE(numout,*) '              Rotated bilaplacian'
+      ENDIF
+      !
+   END SUBROUTINE dyn_ldf_ctl
+
+   !!======================================================================
+END MODULE dynldf
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 1844)
@@ -0,0 +1,238 @@
+MODULE dynldf_bilap
+   !!======================================================================
+   !!                     ***  MODULE  dynldf_bilap  ***
+   !! Ocean dynamics:  lateral viscosity trend
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf_bilap : update the momentum trend with the lateral diffusion
+   !!                   using an iso-level bilaplacian operator
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE in_out_manager  ! I/O manager
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_ldf_bilap  ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldfdyn_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_ldf_bilap( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dyn_ldf_bilap  ***
+      !!
+      !! ** Purpose :   Compute the before trend of the lateral momentum
+      !!      diffusion and add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   The before horizontal momentum diffusion trend is a 
+      !!      bi-harmonic operator (bilaplacian type) which separates the
+      !!      divergent and rotational parts of the flow.
+      !!      Its horizontal components are computed as follow:
+      !!      laplacian:
+      !!          zlu = 1/e1u di[ hdivb ] - 1/(e2u*e3u) dj-1[ e3f rotb ]
+      !!          zlv = 1/e2v dj[ hdivb ] + 1/(e1v*e3v) di-1[ e3f rotb ]
+      !!      third derivative:
+      !!       * multiply by the eddy viscosity coef. at u-, v-point, resp.
+      !!          zlu = ahmu * zlu
+      !!          zlv = ahmv * zlv
+      !!       * curl and divergence of the laplacian
+      !!          zuf = 1/(e1f*e2f) ( di[e2v zlv] - dj[e1u zlu] )
+      !!          zut = 1/(e1t*e2t*e3t) ( di[e2u*e3u zlu] + dj[e1v*e3v zlv] )
+      !!      bilaplacian:
+      !!              diffu = 1/e1u di[ zut ] - 1/(e2u*e3u) dj-1[ e3f zuf ]
+      !!              diffv = 1/e2v dj[ zut ] + 1/(e1v*e3v) di-1[ e3f zuf ]
+      !!      If ln_sco=F and ln_zps=F, the vertical scale factors in the
+      !!      rotational part of the diffusion are simplified
+      !!      Add this before trend to the general trend (ua,va):
+      !!            (ua,va) = (ua,va) + (diffu,diffv)
+      !!      'key_trddyn' defined: the two components of the horizontal
+      !!                               diffusion trend are saved.
+      !!
+      !! ** Action : - Update (ua,va) with the before iso-level biharmonic
+      !!               mixing trend.
+      !!
+      !! History :
+      !!        !  90-09  (G. Madec)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  93-03  (M. Guyon)  symetrical conditions (M. Guyon)
+      !!        !  96-01  (G. Madec)  statement function for e3
+      !!        !  97-07  (G. Madec)  lbc calls
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zua, zva, zbt, ze2u, ze2v ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zcu, zcv                             ! temporary workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zuf, zut, zlu, zlv                   ! temporary workspace
+      !!----------------------------------------------------------------------
+      !!  OPA 8.5, LODYC-IPSL (2002)
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_ldf_bilap : iso-level bilaplacian operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
+      ENDIF
+
+!!bug gm this should be enough
+!!$      zuf(:,:,jpk) = 0.e0
+!!$      zut(:,:,jpk) = 0.e0
+!!$      zlu(:,:,jpk) = 0.e0
+!!$      zlv(:,:,jpk) = 0.e0
+      zuf(:,:,:) = 0.e0
+      zut(:,:,:) = 0.e0
+      zlu(:,:,:) = 0.e0
+      zlv(:,:,:) = 0.e0
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! Laplacian
+         ! ---------
+
+         IF( ln_sco .OR. ln_zps ) THEN   ! s-coordinate or z-coordinate with partial steps
+            zuf(:,:,jk) = rotb(:,:,jk) * fse3f(:,:,jk)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zlu(ji,jj,jk) = - ( zuf(ji,jj,jk) - zuf(ji,jj-1,jk) ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
+                     &         + ( hdivb(ji+1,jj,jk) - hdivb(ji,jj,jk) ) / e1u(ji,jj)
+   
+                  zlv(ji,jj,jk) = + ( zuf(ji,jj,jk) - zuf(ji-1,jj,jk) ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
+                     &         + ( hdivb(ji,jj+1,jk) - hdivb(ji,jj,jk) ) / e2v(ji,jj)
+               END DO
+            END DO
+         ELSE                            ! z-coordinate - full step
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zlu(ji,jj,jk) = - ( rotb (ji  ,jj,jk) - rotb (ji,jj-1,jk) ) / e2u(ji,jj)   &
+                     &         + ( hdivb(ji+1,jj,jk) - hdivb(ji,jj  ,jk) ) / e1u(ji,jj)
+   
+                  zlv(ji,jj,jk) = + ( rotb (ji,jj  ,jk) - rotb (ji-1,jj,jk) ) / e1v(ji,jj)   &
+                     &         + ( hdivb(ji,jj+1,jk) - hdivb(ji  ,jj,jk) ) / e2v(ji,jj)
+               END DO  
+            END DO  
+         ENDIF
+      ENDDO
+
+      ! Boundary conditions on the laplacian  (zlu,zlv)
+      CALL lbc_lnk( zlu, 'U', -1. )
+      CALL lbc_lnk( zlv, 'V', -1. )
+         
+         
+      DO jk = 1, jpkm1
+   
+         ! Third derivative
+         ! ----------------
+         
+         ! Multiply by the eddy viscosity coef. (at u- and v-points)
+         zlu(:,:,jk) = zlu(:,:,jk) * fsahmu(:,:,jk)
+         zlv(:,:,jk) = zlv(:,:,jk) * fsahmv(:,:,jk)
+         
+         ! Contravariant "laplacian"
+         zcu(:,:) = e1u(:,:) * zlu(:,:,jk)
+         zcv(:,:) = e2v(:,:) * zlv(:,:,jk)
+         
+         ! Laplacian curl ( * e3f if s-coordinates or z-coordinate with partial steps)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zuf(ji,jj,jk) = fmask(ji,jj,jk) * (  zcv(ji+1,jj  ) - zcv(ji,jj)      &
+                  &                            - zcu(ji  ,jj+1) + zcu(ji,jj)  )   &
+#if defined key_zco
+                  &                         / ( e1f(ji,jj)*e2f(ji,jj) )
+#else
+                  &       * fse3f(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
+#endif
+            END DO  
+         END DO  
+
+         ! Laplacian Horizontal fluxes
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zlu(ji,jj,jk) = e2u(ji,jj) * zlu(ji,jj,jk)
+               zlv(ji,jj,jk) = e1v(ji,jj) * zlv(ji,jj,jk)
+#else
+               zlu(ji,jj,jk) = e2u(ji,jj) * fse3u(ji,jj,jk) * zlu(ji,jj,jk)
+               zlv(ji,jj,jk) = e1v(ji,jj) * fse3v(ji,jj,jk) * zlv(ji,jj,jk)
+#endif
+            END DO
+         END DO
+
+         ! Laplacian divergence
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+#if defined key_zco
+               zbt = e1t(ji,jj) * e2t(ji,jj)
+#else
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+#endif
+               zut(ji,jj,jk) = (  zlu(ji,jj,jk) - zlu(ji-1,jj  ,jk)   &
+                  &             + zlv(ji,jj,jk) - zlv(ji  ,jj-1,jk) ) / zbt
+            END DO
+         END DO
+      END DO
+
+
+      ! boundary conditions on the laplacian curl and div (zuf,zut)
+!!bug gm no need to do this 2 following lbc...
+      CALL lbc_lnk( zuf, 'F', 1. )
+      CALL lbc_lnk( zut, 'T', 1. )
+
+      DO jk = 1, jpkm1      
+   
+         ! Bilaplacian
+         ! -----------
+
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               ze2u = e2u(ji,jj)
+               ze2v = e1v(ji,jj)
+#else
+               ze2u = e2u(ji,jj) * fse3u(ji,jj,jk)
+               ze2v = e1v(ji,jj) * fse3v(ji,jj,jk)
+#endif
+               ! horizontal biharmonic diffusive trends
+               zua = - ( zuf(ji  ,jj,jk) - zuf(ji,jj-1,jk) ) / ze2u   &
+                  &  + ( zut(ji+1,jj,jk) - zut(ji,jj  ,jk) ) / e1u(ji,jj)
+
+               zva = + ( zuf(ji,jj  ,jk) - zuf(ji-1,jj,jk) ) / ze2v   &
+                  &  + ( zut(ji,jj+1,jk) - zut(ji  ,jj,jk) ) / e2v(ji,jj)
+               ! add it to the general momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zva
+            END DO
+         END DO
+
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE dyn_ldf_bilap
+
+   !!======================================================================
+END MODULE dynldf_bilap
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 1844)
@@ -0,0 +1,476 @@
+MODULE dynldf_bilapg
+   !!======================================================================
+   !!                       ***  MODULE  dynldf_bilapg  ***
+   !! Ocean dynamics:  lateral viscosity trend
+   !!======================================================================
+#if defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                              Rotation of mixing tensor
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf_bilapg : update the momentum trend with the horizontal part
+   !!                    of the horizontal s-coord. bilaplacian diffusion
+   !!   ldfguv         : 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldfdyn_oce      ! ocean dynamics lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE ldfslp          ! iso-neutral slopes available
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_ldf_bilapg ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldfdyn_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_ldf_bilapg( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dyn_ldf_bilapg  ***
+      !!                      
+      !! ** Purpose :   Compute the before trend of the horizontal momentum
+      !!      diffusion and add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   The lateral momentum diffusive trends is provided by a 
+      !!      a 4th order operator rotated along geopotential surfaces. It is 
+      !!      computed using before fields (forward in time) and geopotential
+      !!      slopes computed in routine inildf.
+      !!         -1- compute the geopotential harmonic operator applied to
+      !!      (ub,vb) and multiply it by the eddy diffusivity coefficient
+      !!      (done by a call to ldfgpu and ldfgpv routines) The result is in
+      !!      (zwk1,zwk2) arrays. Applied the domain lateral boundary conditions
+      !!      by call to lbc_lnk.
+      !!         -2- applied to (zwk1,zwk2) the geopotential harmonic operator
+      !!      by a second call to ldfgpu and ldfgpv routines respectively. The
+      !!      result is in (zwk3,zwk4) arrays.
+      !!         -3- Add this trend to the general trend (ta,sa):
+      !!            (ua,va) = (ua,va) + (zwk3,zwk4)
+      !!      'key_trddyn' defined: the trend is saved for diagnostics.
+      !!
+      !! ** Action  : - Update (ua,va) arrays with the before geopotential
+      !!                biharmonic mixing trend.
+      !!              - save the trend in (zwk3,zwk4) ('key_trddyn')
+      !!
+      !! History :
+      !!   8.0  !  97-07  (G. Madec)  Original code
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!----------------------------------------------------------------------
+      !! * Modules used     
+      USE oce, ONLY :    zwk3 => ta,   & ! use ta as 3D workspace   
+                         zwk4 => sa      ! use sa as 3D workspace   
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zwk1, zwk2                ! work array used for rotated biharmonic
+         !                         ! operator on tracers and/or momentum
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_ldf_bilapg : horizontal biharmonic operator in s-coordinate'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
+         zwk1(:,:,:) = 0.e0   ;   zwk3(:,:,:) = 0.e0
+         zwk2(:,:,:) = 0.e0   ;   zwk4(:,:,:) = 0.e0
+      ENDIF
+
+      ! Laplacian of (ub,vb) multiplied by ahm
+      ! --------------------------------------  
+      ! rotated harmonic operator applied to (ub,vb)
+      !     and multiply by ahmu, ahmv (output in (zwk1,zwk2) )
+
+      CALL ldfguv ( ub, vb, zwk1, zwk2, 1 )
+
+
+      ! Lateral boundary conditions on (zwk1,zwk2)
+      CALL lbc_lnk( zwk1, 'U', -1. )
+      CALL lbc_lnk( zwk2, 'V', -1. )
+
+
+      ! Bilaplacian of (ub,vb)
+      ! ---------------------- 
+      ! rotated harmonic operator applied to (zwk1,zwk2) (output in (zwk3,zwk4) )
+
+      CALL ldfguv ( zwk1, zwk2, zwk3, zwk4, 2 )
+
+
+      ! Update the momentum trends			   (j-slab :   2, jpj-1)
+      ! --------------------------
+      !                                                ! ===============
+      DO jj = 2, jpjm1                                 !  Vertical slab
+         !                                             ! ===============
+         DO jk = 1, jpkm1
+            DO ji = 2, jpim1
+               ! add the diffusive trend to the general momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zwk3(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) + zwk4(ji,jj,jk)
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE dyn_ldf_bilapg
+
+
+   SUBROUTINE ldfguv( pu, pv, plu, plv, kahm )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldfguv  ***
+      !!      
+      !! ** Purpose :   Apply a geopotential harmonic operator to (pu,pv)
+      !!      (defined at u- and v-points) and multiply it by the eddy
+      !!      viscosity coefficient (if kahm=1).
+      !!
+      !! ** Method  :   The harmonic operator rotated along geopotential 
+      !!      surfaces is applied to (pu,pv) using the slopes of geopotential
+      !!      surfaces computed in inildf routine. The result is provided in
+      !!      (plu,plv) arrays. It is computed in 2 stepv:
+      !!
+      !!      First step: horizontal part of the operator. It is computed on
+      !!      ==========  pu as follows (idem on pv)
+      !!      horizontal fluxes :
+      !!         zftu = e2u*e3u/e1u di[ pu ] - e2u*uslp dk[ mi(mk(pu)) ]
+      !!         zftv = e1v*e3v/e2v dj[ pu ] - e1v*vslp dk[ mj(mk(pu)) ]
+      !!      take the horizontal divergence of the fluxes (no divided by
+      !!      the volume element :
+      !!         plu  = di-1[ zftu ] +  dj-1[ zftv ]
+      !!
+      !!      Second step: vertical part of the operator. It is computed on
+      !!      ===========  pu as follows (idem on pv)
+      !!      vertical fluxes :
+      !!         zftw = e1t*e2t/e3w * (wslpi^2+wslpj^2)  dk-1[ pu ]
+      !!              -     e2t     *       wslpi        di[ mi(mk(pu)) ]
+      !!              -     e1t     *       wslpj        dj[ mj(mk(pu)) ]
+      !!      take the vertical divergence of the fluxes add it to the hori-
+      !!      zontal component, divide the result by the volume element and
+      !!      if kahm=1, multiply by the eddy diffusivity coefficient:
+      !!         plu  = aht / (e1t*e2t*e3t) { plu + dk[ zftw ] }
+      !!      else:
+      !!         plu  =  1  / (e1t*e2t*e3t) { plu + dk[ zftw ] }
+      !!
+      !! ** Action :
+      !!        plu, plv        : partial harmonic operator applied to
+      !!                          pu and pv (all the components except
+      !!                          second order vertical derivative term)
+      !!      'key_trddyn' defined: the trend is saved for diagnostics.
+      !!
+      !! History :
+      !!   8.0  !  97-07  (G. Madec)  Original code
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
+         pu, pv     ! momentum fields (before u and v for the 1st call, and
+      !             ! laplacian of these fields multiplied by ahm for the 2nd
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   &
+         plu, plv   ! partial harmonic operator applied to
+      !             ! pu and pv (all the components except
+      !             ! second order vertical derivative term)
+      INTEGER, INTENT( in ) ::   &
+         kahm       ! =1 the laplacian is multiplied by the eddy diffusivity coef.
+      !             ! =2 no multiplication
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk       ! dummy loop indices
+      REAL(wp) ::   &
+         zabe1, zabe2, zcof1, zcof2,    &  ! temporary scalars
+         zcoef0, zcoef3, zcoef4
+      REAL(wp) ::   &
+         zbur, zbvr, zmkt, zmkf, zuav, zvav,    &
+         zuwslpi, zuwslpj, zvwslpi, zvwslpj
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ziut, zjuf , zjvt, zivf,       &  ! workspace
+         zdku, zdk1u, zdkv, zdk1v
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         zfuw, zfvw, zdiu, zdiv,        &  ! workspace
+         zdju, zdj1u, zdjv, zdj1v 
+      !!----------------------------------------------------------------------
+
+      !                               ! ********** !   ! ===============
+      DO jk = 1, jpkm1                ! First step !   ! Horizontal slab
+         !                            ! ********** !   ! ===============
+
+         ! I.1 Vertical gradient of pu and pv at level jk and jk+1
+         ! -------------------------------------------------------
+         ! surface boundary condition: zdku(jk=1)=zdku(jk=2)
+         !                             zdkv(jk=1)=zdkv(jk=2)
+
+         zdk1u(:,:) = ( pu(:,:,jk) - pu(:,:,jk+1) ) * umask(:,:,jk+1)
+         zdk1v(:,:) = ( pv(:,:,jk) - pv(:,:,jk+1) ) * vmask(:,:,jk+1)
+
+         IF( jk == 1 ) THEN
+            zdku(:,:) = zdk1u(:,:)
+            zdkv(:,:) = zdk1v(:,:)
+         ELSE
+            zdku(:,:) = ( pu(:,:,jk-1) - pu(:,:,jk) ) * umask(:,:,jk)
+            zdkv(:,:) = ( pv(:,:,jk-1) - pv(:,:,jk) ) * vmask(:,:,jk)
+         ENDIF
+
+         !                                -----f-----
+         ! I.2 Horizontal fluxes on U          |
+         ! ------------------------===     t   u   t
+         !                                     |
+         ! i-flux at t-point              -----f-----
+         DO jj = 1, jpjm1
+            DO ji = 2, jpi
+               zabe1 = e2t(ji,jj) * fse3t(ji,jj,jk) / e1t(ji,jj)
+
+               zmkt  = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
+                              + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
+
+               zcof1 = -e2t(ji,jj) * zmkt   &
+                     * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
+
+               ziut(ji,jj) = tmask(ji,jj,jk) *   &
+                           (  zabe1 * ( pu(ji,jj,jk) - pu(ji-1,jj,jk) )   &
+                            + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
+                                       +zdk1u(ji,jj) + zdku (ji-1,jj) )  )
+            END DO
+         END DO
+
+         ! j-flux at f-point
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zabe2 = e1f(ji,jj) * fse3f(ji,jj,jk) / e2f(ji,jj)
+
+               zmkf  = 1./MAX(  umask(ji,jj+1,jk  )+umask(ji,jj,jk+1)   &
+                              + umask(ji,jj+1,jk+1)+umask(ji,jj,jk  ), 1. )
+
+               zcof2 = -e1f(ji,jj) * zmkf   &
+                     * 0.5  * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
+
+               zjuf(ji,jj) = fmask(ji,jj,jk) *   &
+                           (  zabe2 * ( pu(ji,jj+1,jk) - pu(ji,jj,jk) )   &
+                            + zcof2 * ( zdku (ji,jj+1) + zdk1u(ji,jj)     &
+                                       +zdk1u(ji,jj+1) + zdku (ji,jj) )  )
+            END DO
+         END DO
+
+         !                                 |   t   |
+         ! I.3 Horizontal fluxes on V      |       |
+         ! ------------------------===     f---v---f
+         !                                 |       |
+         ! i-flux at f-point               |   t   |
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zabe1 = e2f(ji,jj) * fse3f(ji,jj,jk) / e1f(ji,jj)
+
+               zmkf  = 1./MAX(  vmask(ji+1,jj,jk  )+vmask(ji,jj,jk+1)   &
+                              + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk  ), 1. )
+
+               zcof1 = -e2f(ji,jj) * zmkf   &
+                     * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
+
+               zivf(ji,jj) = fmask(ji,jj,jk) *   &
+                           (  zabe1 * ( pu(ji+1,jj,jk) - pu(ji,jj,jk) )   &
+                            + zcof1 * ( zdku (ji,jj) + zdk1u(ji+1,jj)     &
+                                       +zdk1u(ji,jj) + zdku (ji+1,jj) )  )
+            END DO
+         END DO
+
+         ! j-flux at t-point
+         DO jj = 2, jpj
+            DO ji = 1, jpim1
+               zabe2 = e1t(ji,jj) * fse3t(ji,jj,jk) / e2t(ji,jj)
+
+               zmkt  = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
+                              + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
+
+               zcof2 = -e1t(ji,jj) * zmkt   &
+                     * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
+
+               zjvt(ji,jj) = tmask(ji,jj,jk) *   &
+                           (  zabe2 * ( pu(ji,jj,jk) - pu(ji,jj-1,jk) )   &
+                            + zcof2 * ( zdku (ji,jj-1) + zdk1u(ji,jj)     &
+                                       +zdk1u(ji,jj-1) + zdku (ji,jj) )  )
+            END DO
+         END DO
+
+
+         ! I.4 Second derivative (divergence) (not divided by the volume)
+         ! ---------------------
+
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               plu(ji,jj,jk) = ziut (ji+1,jj) - ziut (ji,jj  )   &
+                             + zjuf (ji  ,jj) - zjuf (ji,jj-1)
+               plv(ji,jj,jk) = zivf (ji,jj  ) - zivf (ji-1,jj)   &
+                             + zjvt (ji,jj+1) - zjvt (ji,jj  ) 
+            END DO
+         END DO
+
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+      !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,synchro,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+
+      !                             ! ************ !   ! ===============
+      DO jj = 2, jpjm1              !  Second step !   ! Horizontal slab
+         !                          ! ************ !   ! ===============
+
+         ! II.1 horizontal (pu,pv) gradients
+         ! ---------------------------------
+
+         DO jk = 1, jpk
+            DO ji = 2, jpi
+               ! i-gradient of u at jj
+               zdiu (ji,jk) = tmask(ji,jj  ,jk) * ( pu(ji,jj  ,jk) - pu(ji-1,jj  ,jk) )
+               ! j-gradient of u and v at jj
+               zdju (ji,jk) = fmask(ji,jj  ,jk) * ( pu(ji,jj+1,jk) - pu(ji  ,jj  ,jk) )
+               zdjv (ji,jk) = tmask(ji,jj  ,jk) * ( pv(ji,jj  ,jk) - pv(ji  ,jj-1,jk) )
+               ! j-gradient of u and v at jj+1
+               zdj1u(ji,jk) = fmask(ji,jj-1,jk) * ( pu(ji,jj  ,jk) - pu(ji  ,jj-1,jk) )
+               zdj1v(ji,jk) = tmask(ji,jj+1,jk) * ( pv(ji,jj+1,jk) - pv(ji  ,jj  ,jk) )
+            END DO
+         END DO
+         DO jk = 1, jpk
+            DO ji = 1, jpim1
+               ! i-gradient of v at jj
+               zdiv (ji,jk) = fmask(ji,jj  ,jk) * ( pv(ji+1,jj,jk) - pv(ji  ,jj  ,jk) )
+            END DO
+         END DO
+
+
+         ! II.2 Vertical fluxes
+         ! --------------------
+
+         ! Surface and bottom vertical fluxes set to zero
+
+         zfuw(:, 1 ) = 0.e0
+         zfvw(:, 1 ) = 0.e0
+         zfuw(:,jpk) = 0.e0
+         zfvw(:,jpk) = 0.e0
+
+         ! interior (2=<jk=<jpk-1) on pu field
+
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               ! i- and j-slopes at uw-point
+               zuwslpi = 0.5 * ( wslpi(ji+1,jj,jk) + wslpi(ji,jj,jk) )
+               zuwslpj = 0.5 * ( wslpj(ji+1,jj,jk) + wslpj(ji,jj,jk) )
+               ! coef. for the vertical dirative
+               zcoef0 = e1u(ji,jj) * e2u(ji,jj) / fse3u(ji,jj,jk)   &
+                      * ( zuwslpi * zuwslpi + zuwslpj * zuwslpj )
+               ! weights for the i-k, j-k averaging at t- and f-points, resp.
+               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji+1,jj,jk-1)   &
+                             + tmask(ji,jj,jk  )+tmask(ji+1,jj,jk  ), 1. )
+               zmkf = 1./MAX(  fmask(ji,jj-1,jk-1)+fmask(ji,jj,jk-1)   &
+                             + fmask(ji,jj-1,jk  )+fmask(ji,jj,jk  ), 1. )
+               ! coef. for the horitontal derivative
+               zcoef3 = - e2u(ji,jj) * zmkt * zuwslpi
+               zcoef4 = - e1u(ji,jj) * zmkf * zuwslpj
+               ! vertical flux on u field
+               zfuw(ji,jk) = umask(ji,jj,jk) *   &
+                           (  zcoef0 * ( pu  (ji,jj,jk-1) - pu  (ji,jj,jk) )   &
+                            + zcoef3 * ( zdiu (ji,jk-1) + zdiu (ji+1,jk-1)     &
+                                        +zdiu (ji,jk  ) + zdiu (ji+1,jk  ) )   &
+                            + zcoef4 * ( zdj1u(ji,jk-1) + zdju (ji  ,jk-1)     &
+                                        +zdj1u(ji,jk  ) + zdju (ji  ,jk  ) ) )
+            END DO
+         END DO
+
+         ! interior (2=<jk=<jpk-1) on pv field
+
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               ! i- and j-slopes at vw-point
+               zvwslpi = 0.5 * ( wslpi(ji,jj+1,jk) + wslpi(ji,jj,jk) )
+               zvwslpj = 0.5 * ( wslpj(ji,jj+1,jk) + wslpj(ji,jj,jk) )
+               ! coef. for the vertical derivative
+               zcoef0 = e1v(ji,jj) * e2v(ji,jj) / fse3v(ji,jj,jk)   &
+                      * ( zvwslpi * zvwslpi + zvwslpj * zvwslpj )
+               ! weights for the i-k, j-k averaging at f- and t-points, resp.
+               zmkf = 1./MAX(  fmask(ji-1,jj,jk-1)+fmask(ji,jj,jk-1)   &
+                             + fmask(ji-1,jj,jk  )+fmask(ji,jj,jk  ), 1. )
+               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji,jj+1,jk-1)   &
+                             + tmask(ji,jj,jk  )+tmask(ji,jj+1,jk  ), 1. )
+               ! coef. for the horizontal derivatives
+               zcoef3 = - e2v(ji,jj) * zmkf * zvwslpi
+               zcoef4 = - e1v(ji,jj) * zmkt * zvwslpj
+               ! vertical flux on pv field
+               zfvw(ji,jk) = vmask(ji,jj,jk) *   &
+                           (  zcoef0 * ( pv  (ji,jj,jk-1) - pv  (ji,jj,jk) )   &
+                            + zcoef3 * ( zdiv (ji,jk-1) + zdiv (ji-1,jk-1)     &
+                                        +zdiv (ji,jk  ) + zdiv (ji-1,jk  ) )   &
+                            + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji  ,jk-1)     &
+                                        +zdjv (ji,jk  ) + zdj1v(ji  ,jk  ) )  )
+            END DO
+         END DO
+
+
+         ! II.3 Divergence of vertical fluxes added to the horizontal divergence
+         ! ---------------------------------------------------------------------
+
+         IF( kahm == 1 ) THEN
+            ! multiply the laplacian by the eddy viscosity coefficient
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ! eddy coef. divided by the volume element
+                  zbur = fsahmu(ji,jj,jk) / ( e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,jk) )
+                  zbvr = fsahmv(ji,jj,jk) / ( e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk) )
+                  ! vertical divergence
+                  zuav = zfuw(ji,jk) - zfuw(ji,jk+1)
+                  zvav = zfvw(ji,jk) - zfvw(ji,jk+1)
+                  ! harmonic operator applied to (pu,pv) and multiply by ahm
+                  plu(ji,jj,jk) = ( plu(ji,jj,jk) + zuav ) * zbur
+                  plv(ji,jj,jk) = ( plv(ji,jj,jk) + zvav ) * zbvr
+               END DO
+            END DO
+         ELSEIF( kahm == 2 ) THEN
+            ! second call, no multiplication
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ! inverse of the volume element
+                  zbur = 1. / ( e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,jk) )
+                  zbvr = 1. / ( e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk) )
+                  ! vertical divergence
+                  zuav = zfuw(ji,jk) - zfuw(ji,jk+1)
+                  zvav = zfvw(ji,jk) - zfvw(ji,jk+1)
+                  ! harmonic operator applied to (pu,pv) 
+                  plu(ji,jj,jk) = ( plu(ji,jj,jk) + zuav ) * zbur
+                  plv(ji,jj,jk) = ( plv(ji,jj,jk) + zvav ) * zbvr
+               END DO
+            END DO
+         ELSE
+            IF(lwp)WRITE(numout,*) ' ldfguv: kahm= 1 or 2, here =', kahm
+            IF(lwp)WRITE(numout,*) '         We stop'
+            STOP 'ldfguv'
+         ENDIF
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE ldfguv
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                         NO rotation of mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_ldf_bilapg( kt )               ! Dummy routine
+      WRITE(*,*) 'dyn_ldf_bilapg: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_ldf_bilapg
+#endif
+
+   !!======================================================================
+END MODULE dynldf_bilapg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_iso.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 1844)
@@ -0,0 +1,435 @@
+MODULE dynldf_iso
+   !!======================================================================
+   !!                     ***  MODULE  dynldf_iso  ***
+   !! Ocean dynamics:  lateral viscosity trend
+   !!======================================================================
+#if defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                      slopes of the direction of mixing
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf_iso  : update the momentum trend with the horizontal part
+   !!                  of the lateral diffusion using isopycnal or horizon-
+   !!                  tal s-coordinate laplacian operator.
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldfdyn_oce      ! ocean dynamics lateral physics
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE ldfslp          ! iso-neutral slopes 
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_ldf_iso           ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldfdyn_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_ldf_iso( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dyn_ldf_iso  ***
+      !!                       
+      !! ** Purpose :   Compute the before trend of the rotated laplacian
+      !!      operator of lateral momentum diffusion except the diagonal
+      !!      vertical term that will be computed in dynzdf module. Add it
+      !!      to the general trend of momentum equation.
+      !!
+      !! ** Method :
+      !!        The momentum lateral diffusive trend is provided by a 2nd
+      !!      order operator rotated along neutral or geopotential surfaces
+      !!      (in s-coordinates).
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!      Here, u and v components are considered as 2 independent scalar
+      !!      fields. Therefore, the property of splitting divergent and rota-
+      !!      tional part of the flow of the standard, z-coordinate laplacian
+      !!      momentum diffusion is lost.
+      !!      horizontal fluxes associated with the rotated lateral mixing:
+      !!      u-component:
+      !!         ziut = ( ahmt + ahmb0 ) e2t * e3t / e1t  di[ ub ]
+      !!               -      ahmt       e2t * mi-1(uslp) dk[ mi(mk(ub)) ]
+      !!         zjuf = ( ahmf + ahmb0 ) e1f * e3f / e2f  dj[ ub ]
+      !!               -      ahmf       e1f * mi(vslp)   dk[ mj(mk(ub)) ]
+      !!      v-component:
+      !!         zivf = ( ahmf + ahmb0 ) e2t * e3t / e1t  di[ vb ]
+      !!               -      ahmf       e2t * mj(uslp)   dk[ mi(mk(vb)) ]
+      !!         zjvt = ( ahmt + ahmb0 ) e1f * e3f / e2f  dj[ ub ]
+      !!               -      ahmt       e1f * mj-1(vslp) dk[ mj(mk(vb)) ]
+      !!      take the horizontal divergence of the fluxes:
+      !!         diffu = 1/(e1u*e2u*e3u) {  di  [ ziut ] + dj-1[ zjuf ]  }
+      !!         diffv = 1/(e1v*e2v*e3v) {  di-1[ zivf ] + dj  [ zjvt ]  }
+      !!      Add this trend to the general trend (ua,va):
+      !!         ua = ua + diffu
+      !!      CAUTION: here the isopycnal part is with a coeff. of aht. This
+      !!      should be modified for applications others than orca_r2 (!!bug)
+      !!
+      !! ** Action :
+      !!        Update (ua,va) arrays with the before geopotential biharmonic
+      !!      mixing trend.
+      !!        Update (avmu,avmv) to accompt for the diagonal vertical component
+      !!      of the rotated operator in dynzdf module
+      !!
+      !! History :
+      !!   8.0  !  97-07  (G. Madec)  Original code
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!        !  05-11  (G. Madec)  s-coordinate: horizontal diffusion
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk            ! dummy loop indices
+      REAL(wp) ::   &
+         zabe1, zabe2, zcof1, zcof2,   &  ! temporary scalars
+         zmskt, zmskf, zbu, zbv,       &
+         zuah, zvah
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ziut, zjuf, zjvt, zivf,        & ! temporary workspace
+         zdku, zdk1u, zdkv, zdk1v
+
+      REAL(wp) ::   &
+         zcoef0, zcoef3, zcoef4, zmkt, zmkf,   &
+         zuav, zvav, zuwslpi, zuwslpj, zvwslpi, zvwslpj
+      REAL(wp), DIMENSION(jpi,jpk) ::        &
+         zfuw, zdiu, zdju, zdj1u,            & !    "        "
+         zfvw, zdiv, zdjv, zdj1v
+
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_ldf_iso : iso-neutral laplacian diffusive operator or '
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate horizontal diffusive operator'
+      ENDIF
+
+!     ! s-coordinate: Iso-level diffusion on momentum but not on tracer
+      IF( ln_dynldf_hor .AND. ln_traldf_iso ) THEN
+ 
+         ! set the slopes of iso-level
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept(ji+1,jj,jk) - fsdept(ji ,jj ,jk) ) * umask(ji,jj,jk)
+                  vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept(ji,jj+1,jk) - fsdept(ji ,jj ,jk) ) * vmask(ji,jj,jk)
+                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw(ji+1,jj,jk) - fsdepw(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
+                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw(ji,jj+1,jk) - fsdepw(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
+               END DO
+            END DO
+         END DO
+ 
+         ! Lateral boundary conditions on the slopes
+         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+ 
+!!bug
+         if( kt == nit000 ) then
+            IF(lwp) WRITE(numout,*) ' max slop: u',SQRT( MAXVAL(uslp*uslp)), ' v ', SQRT(MAXVAL(vslp)),  &
+               &                             ' wi', sqrt(MAXVAL(wslpi)), ' wj', sqrt(MAXVAL(wslpj))
+         endif
+!!end
+      ENDIF
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         ! Vertical u- and v-shears at level jk and jk+1
+         ! ---------------------------------------------
+         ! surface boundary condition: zdku(jk=1)=zdku(jk=2)
+         !                             zdkv(jk=1)=zdkv(jk=2)
+
+         zdk1u(:,:) = ( ub(:,:,jk) -ub(:,:,jk+1) ) * umask(:,:,jk+1)
+         zdk1v(:,:) = ( vb(:,:,jk) -vb(:,:,jk+1) ) * vmask(:,:,jk+1)
+
+         IF( jk == 1 ) THEN
+            zdku(:,:) = zdk1u(:,:)
+            zdkv(:,:) = zdk1v(:,:)
+         ELSE
+            zdku(:,:) = ( ub(:,:,jk-1) - ub(:,:,jk) ) * umask(:,:,jk)
+            zdkv(:,:) = ( vb(:,:,jk-1) - vb(:,:,jk) ) * vmask(:,:,jk)
+         ENDIF
+
+         !                               -----f-----
+         ! Horizontal fluxes on U             |  
+         ! --------------------===        t   u   t
+         !                                    |  
+         ! i-flux at t-point             -----f-----
+
+         IF( ln_zps ) THEN      ! z-coordinate - partial steps : min(e3u)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, jpi   ! vector opt.
+                  zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * MIN( fse3u(ji,jj,jk), fse3u(ji-1,jj,jk) ) / e1t(ji,jj)
+
+                  zmskt = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
+                     &           + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
+
+                  zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
+   
+                  ziut(ji,jj) = (  zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) )   &
+                     &           + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
+                     &                      +zdk1u(ji,jj) + zdku (ji-1,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ELSE                   ! other coordinate system (zco or sco) : e3t
+            DO jj = 2, jpjm1
+               DO ji = fs_2, jpi   ! vector opt.
+                  zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * fse3t(ji,jj,jk) / e1t(ji,jj)
+
+                  zmskt = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
+                     &           + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
+
+                  zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
+
+                  ziut(ji,jj) = (  zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) )   &
+                     &           + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
+                     &                      +zdk1u(ji,jj) + zdku (ji-1,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+         ! j-flux at f-point
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zabe2 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e1f(ji,jj) * fse3f(ji,jj,jk) / e2f(ji,jj)
+
+               zmskf = 1./MAX(  umask(ji,jj+1,jk  )+umask(ji,jj,jk+1)   &
+                  &           + umask(ji,jj+1,jk+1)+umask(ji,jj,jk  ), 1. )
+
+               zcof2 = - aht0 * e1f(ji,jj) * zmskf * 0.5  * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
+
+               zjuf(ji,jj) = (  zabe2 * ( ub(ji,jj+1,jk) - ub(ji,jj,jk) )   &
+                  &           + zcof2 * ( zdku (ji,jj+1) + zdk1u(ji,jj)     &
+                  &                      +zdk1u(ji,jj+1) + zdku (ji,jj) )  ) * fmask(ji,jj,jk)
+            END DO
+         END DO
+
+         !                                |   t   |
+         ! Horizontal fluxes on V         |       |
+         ! --------------------===        f---v---f
+         !                                |       |
+         ! i-flux at f-point              |   t   |
+
+         DO jj = 2, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zabe1 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e2f(ji,jj) * fse3f(ji,jj,jk) / e1f(ji,jj)
+
+               zmskf = 1./MAX(  vmask(ji+1,jj,jk  )+vmask(ji,jj,jk+1)   &
+                  &           + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk  ), 1. )
+
+               zcof1 = - aht0 * e2f(ji,jj) * zmskf * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
+
+               zivf(ji,jj) = (  zabe1 * ( vb(ji+1,jj,jk) - vb(ji,jj,jk) )   &
+                  &           + zcof1 * ( zdkv (ji,jj) + zdk1v(ji+1,jj)     &
+                  &                      +zdk1v(ji,jj) + zdkv (ji+1,jj) )  ) * fmask(ji,jj,jk)
+            END DO
+         END DO
+
+         ! j-flux at t-point
+         IF( ln_zps ) THEN      ! z-coordinate - partial steps : min(e3u)
+            DO jj = 2, jpj
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * MIN( fse3v(ji,jj,jk), fse3v(ji,jj-1,jk) ) / e2t(ji,jj)
+
+                  zmskt = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
+                     &           + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
+
+                  zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
+
+                  zjvt(ji,jj) = (  zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) )   &
+                     &           + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj)     &
+                     &                      +zdk1v(ji,jj-1) + zdkv (ji,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ELSE                   ! other coordinate system (zco or sco) : e3t
+            DO jj = 2, jpj
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * fse3t(ji,jj,jk) / e2t(ji,jj)
+
+                  zmskt = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
+                     &           + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
+
+                  zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
+
+                  zjvt(ji,jj) = (  zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) )   &
+                     &           + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj)     &
+                     &                      +zdk1v(ji,jj-1) + zdkv (ji,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+
+         ! Second derivative (divergence) and add to the general trend
+         ! -----------------------------------------------------------
+
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1          !! Question vectop possible??? !!bug
+               ! volume elements
+               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               ! horizontal component of isopycnal momentum diffusive trends
+               zuah =( ziut (ji+1,jj) - ziut (ji,jj  ) +   &
+                  &    zjuf (ji  ,jj) - zjuf (ji,jj-1)  ) / zbu
+               zvah =( zivf (ji,jj  ) - zivf (ji-1,jj) +   &
+                  &    zjvt (ji,jj+1) - zjvt (ji,jj  )  ) / zbv
+               ! add the trends to the general trends
+               ua (ji,jj,jk) = ua (ji,jj,jk) + zuah
+               va (ji,jj,jk) = va (ji,jj,jk) + zvah
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+      ! print sum trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ldfh - Ua: ', mask1=umask, &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+
+
+      !                                                ! ===============
+      DO jj = 2, jpjm1                                 !  Vertical slab
+         !                                             ! ===============
+
+ 
+         ! I. vertical trends associated with the lateral mixing
+         ! =====================================================
+         !  (excluding the vertical flux proportional to dk[t]
+
+
+         ! I.1 horizontal momentum gradient
+         ! --------------------------------
+
+         DO jk = 1, jpk
+            DO ji = 2, jpi
+               ! i-gradient of u at jj
+               zdiu (ji,jk) = tmask(ji,jj  ,jk) * ( ub(ji,jj  ,jk) - ub(ji-1,jj  ,jk) )
+               ! j-gradient of u and v at jj
+               zdju (ji,jk) = fmask(ji,jj  ,jk) * ( ub(ji,jj+1,jk) - ub(ji  ,jj  ,jk) )
+               zdjv (ji,jk) = tmask(ji,jj  ,jk) * ( vb(ji,jj  ,jk) - vb(ji  ,jj-1,jk) )
+               ! j-gradient of u and v at jj+1
+               zdj1u(ji,jk) = fmask(ji,jj-1,jk) * ( ub(ji,jj  ,jk) - ub(ji  ,jj-1,jk) )
+               zdj1v(ji,jk) = tmask(ji,jj+1,jk) * ( vb(ji,jj+1,jk) - vb(ji  ,jj  ,jk) )
+            END DO
+         END DO
+         DO jk = 1, jpk
+            DO ji = 1, jpim1
+               ! i-gradient of v at jj
+               zdiv (ji,jk) = fmask(ji,jj  ,jk) * ( vb(ji+1,jj,jk) - vb(ji  ,jj  ,jk) )
+            END DO
+         END DO
+
+
+         ! I.2 Vertical fluxes
+         ! -------------------
+
+         ! Surface and bottom vertical fluxes set to zero
+         DO ji = 1, jpi
+            zfuw(ji, 1 ) = 0.e0
+            zfvw(ji, 1 ) = 0.e0
+            zfuw(ji,jpk) = 0.e0
+            zfvw(ji,jpk) = 0.e0
+         END DO
+
+         ! interior (2=<jk=<jpk-1) on U field
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               zcoef0= 0.5 * aht0 * umask(ji,jj,jk)
+
+               zuwslpi = zcoef0 * ( wslpi(ji+1,jj,jk) + wslpi(ji,jj,jk) )
+               zuwslpj = zcoef0 * ( wslpj(ji+1,jj,jk) + wslpj(ji,jj,jk) )
+
+               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji+1,jj,jk-1)   &
+                             + tmask(ji,jj,jk  )+tmask(ji+1,jj,jk  ), 1. )
+               zmkf = 1./MAX(  fmask(ji,jj-1,jk-1)+fmask(ji,jj,jk-1)   &
+                             + fmask(ji,jj-1,jk  )+fmask(ji,jj,jk  ), 1. )
+
+               zcoef3 = - e2u(ji,jj) * zmkt * zuwslpi
+               zcoef4 = - e1u(ji,jj) * zmkf * zuwslpj
+               ! vertical flux on u field
+               zfuw(ji,jk) = zcoef3 * ( zdiu (ji,jk-1) + zdiu (ji+1,jk-1)     &
+                                       +zdiu (ji,jk  ) + zdiu (ji+1,jk  ) )   &
+                           + zcoef4 * ( zdj1u(ji,jk-1) + zdju (ji  ,jk-1)     &
+                                       +zdj1u(ji,jk  ) + zdju (ji  ,jk  ) )
+               ! update avmu (add isopycnal vertical coefficient to avmu)
+               ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
+               avmu(ji,jj,jk) = avmu(ji,jj,jk) + ( zuwslpi * zuwslpi + zuwslpj * zuwslpj ) / aht0
+            END DO
+         END DO
+
+         ! interior (2=<jk=<jpk-1) on V field
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               zcoef0= 0.5 * aht0 * vmask(ji,jj,jk)
+
+               zvwslpi = zcoef0 * ( wslpi(ji,jj+1,jk) + wslpi(ji,jj,jk) )
+               zvwslpj = zcoef0 * ( wslpj(ji,jj+1,jk) + wslpj(ji,jj,jk) )
+
+               zmkf = 1./MAX(  fmask(ji-1,jj,jk-1)+fmask(ji,jj,jk-1)   &
+                             + fmask(ji-1,jj,jk  )+fmask(ji,jj,jk  ), 1. )
+               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji,jj+1,jk-1)   &
+                             + tmask(ji,jj,jk  )+tmask(ji,jj+1,jk  ), 1. )
+
+               zcoef3 = - e2v(ji,jj) * zmkf * zvwslpi
+               zcoef4 = - e1v(ji,jj) * zmkt * zvwslpj
+               ! vertical flux on v field
+               zfvw(ji,jk) = zcoef3 * ( zdiv (ji,jk-1) + zdiv (ji-1,jk-1)     &
+                                       +zdiv (ji,jk  ) + zdiv (ji-1,jk  ) )   &
+                           + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji  ,jk-1)     &
+                                       +zdjv (ji,jk  ) + zdj1v(ji  ,jk  ) )
+               ! update avmv (add isopycnal vertical coefficient to avmv)
+               ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
+               avmv(ji,jj,jk) = avmv(ji,jj,jk) + ( zvwslpi * zvwslpi + zvwslpj * zvwslpj ) / aht0
+            END DO
+         END DO
+
+
+         ! I.3 Divergence of vertical fluxes added to the general tracer trend
+         ! -------------------------------------------------------------------
+         DO jk = 1, jpkm1
+            DO ji = 2, jpim1
+               ! volume elements
+               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               ! part of the k-component of isopycnal momentum diffusive trends
+               zuav = ( zfuw(ji,jk) - zfuw(ji,jk+1) ) / zbu
+               zvav = ( zfvw(ji,jk) - zfvw(ji,jk+1) ) / zbv
+               ! add the trends to the general trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zuav
+               va(ji,jj,jk) = va(ji,jj,jk) + zvav
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE dyn_ldf_iso
+
+# else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                           NO rotation of mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_ldf_iso( kt )               ! Empty routine
+      WRITE(*,*) 'dyn_ldf_iso: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_ldf_iso
+#endif
+
+   !!======================================================================
+END MODULE dynldf_iso
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_lap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_lap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynldf_lap.F90	(revision 1844)
@@ -0,0 +1,121 @@
+MODULE dynldf_lap
+   !!======================================================================
+   !!                       ***  MODULE  dynldf_lap  ***
+   !! Ocean dynamics:  lateral viscosity trend
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf_lap  : update the momentum trend with the lateral diffusion
+   !!                  using an iso-level harmonic operator
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE trdmod          ! ocean dynamics trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE ldfslp          ! iso-neutral slopes 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_ldf_lap  ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldfdyn_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_ldf_lap( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dyn_ldf_lap  ***
+      !!                       
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The before horizontal momentum diffusion trend is an
+      !!      harmonic operator (laplacian type) which separates the divergent
+      !!      and rotational parts of the flow.
+      !!      Its horizontal components are computed as follow:
+      !!         difu = 1/e1u di[ahmt hdivb] - 1/(e2u*e3u) dj-1[e3f ahmf rotb]
+      !!         difv = 1/e2v dj[ahmt hdivb] + 1/(e1v*e3v) di-1[e3f ahmf rotb]
+      !!      If lk_zco=T, e3f=e3u=e3v, the vertical scale factor are simplified
+      !!      in the rotational part of the diffusion.
+      !!      Add this before trend to the general trend (ua,va):
+      !!            (ua,va) = (ua,va) + (diffu,diffv)
+      !!      'key_trddyn' activated: the two components of the horizontal
+      !!                                 diffusion trend are saved.
+      !!
+      !! ** Action : - Update (ua,va) with the before iso-level harmonic 
+      !!               mixing trend.
+      !!
+      !! History :
+      !!        !  90-09 (G. Madec) Original code
+      !!        !  91-11 (G. Madec)
+      !!        !  96-01 (G. Madec) statement function for e3 and ahm
+      !!   8.5  !  02-06 (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08 (C. Talandier) New trends organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk            ! dummy loop indices
+      REAL(wp) ::   &
+         zua, zva, ze2u, ze1v             ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_ldf : iso-level harmonic (laplacien) operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               ! horizontal diffusive trends
+               ze2u = rotb (ji,jj,jk)*fsahmf(ji,jj,jk)
+               ze1v = hdivb(ji,jj,jk)*fsahmt(ji,jj,jk)
+               zua = - ( ze2u - rotb (ji,jj-1,jk)*fsahmf(ji,jj-1,jk)                   ) / e2u(ji,jj)   &
+                     + ( hdivb(ji+1,jj,jk)*fsahmt(ji+1,jj,jk) - ze1v                   ) / e1u(ji,jj)
+
+               zva = + ( ze2u - rotb (ji-1,jj,jk)*fsahmf(ji-1,jj,jk)                   ) / e1v(ji,jj)   &
+                     + ( hdivb(ji,jj+1,jk)*fsahmt(ji,jj+1,jk) - ze1v                   ) / e2v(ji,jj)
+#else
+               ze2u = rotb (ji,jj,jk)*fsahmf(ji,jj,jk)*fse3f(ji,jj,jk)
+               ze1v = hdivb(ji,jj,jk)*fsahmt(ji,jj,jk)
+               ! horizontal diffusive trends
+               zua = - ( ze2u - rotb (ji,jj-1,jk)*fsahmf(ji,jj-1,jk)*fse3f(ji,jj-1,jk) ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
+                     + ( hdivb(ji+1,jj,jk)*fsahmt(ji+1,jj,jk) - ze1v                   ) / e1u(ji,jj)
+
+               zva = + ( ze2u - rotb (ji-1,jj,jk)*fsahmf(ji-1,jj,jk)*fse3f(ji-1,jj,jk) ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
+                     + ( hdivb(ji,jj+1,jk)*fsahmt(ji,jj+1,jk) - ze1v                   ) / e2v(ji,jj)
+#endif
+
+               ! add it to the general momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zva
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE dyn_ldf_lap
+
+   !!======================================================================
+END MODULE dynldf_lap
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynnxt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 1844)
@@ -0,0 +1,272 @@
+MODULE dynnxt
+   !!=========================================================================
+   !!                       ***  MODULE  dynnxt  ***
+   !! Ocean dynamics: time stepping
+   !!=========================================================================
+   !! History :  OPA  !  1987-02  (P. Andrich, D. L Hostis)  Original code
+   !!                 !  1990-10  (C. Levy, G. Madec)
+   !!            7.0  !  1993-03  (M. Guyon)  symetrical conditions
+   !!            8.0  !  1997-02  (G. Madec & M. Imbard)  opa, release 8.0
+   !!            8.2  !  1997-04  (A. Weaver)  Euler forward step
+   !!             -   !  1997-06  (G. Madec)  lateral boudary cond., lbc routine
+   !!    NEMO    1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2002-10  (C. Talandier, A-M. Treguier) Open boundary cond.
+   !!            2.0  !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            2.3  !  2007-07  (D. Storkey) Calls to BDY routines. 
+   !!            3.2  !  2009-06  (G. Madec, R.Benshila)  re-introduce the vvl option
+   !!-------------------------------------------------------------------------
+  
+   !!-------------------------------------------------------------------------
+   !!   dyn_nxt      : obtain the next (after) horizontal velocity
+   !!-------------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE dynspg_oce      ! type of surface pressure gradient
+   USE dynadv          ! dynamics: vector invariant versus flux form
+   USE domvvl          ! variable volume
+   USE obc_oce         ! ocean open boundary conditions
+   USE obcdyn          ! open boundary condition for momentum (obc_dyn routine)
+   USE obcdyn_bt       ! 2D open boundary condition for momentum (obc_dyn_bt routine)
+   USE obcvol          ! ocean open boundary condition (obc_vol routines)
+   USE bdy_oce         ! unstructured open boundary conditions
+   USE bdydta          ! unstructured open boundary conditions
+   USE bdydyn          ! unstructured open boundary conditions
+   USE agrif_opa_update
+   USE agrif_opa_interp
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! lateral boundary condition (or mpp link)
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC    dyn_nxt   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!-------------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software is governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!-------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_nxt ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_nxt  ***
+      !!                   
+      !! ** Purpose :   Compute the after horizontal velocity. Apply the boundary 
+      !!             condition on the after velocity, achieved the time stepping 
+      !!             by applying the Asselin filter on now fields and swapping 
+      !!             the fields.
+      !!
+      !! ** Method  : * After velocity is compute using a leap-frog scheme:
+      !!                       (ua,va) = (ub,vb) + 2 rdt (ua,va)
+      !!             Note that with flux form advection and variable volume layer
+      !!             (lk_vvl=T), the leap-frog is applied on thickness weighted
+      !!             velocity.
+      !!             Note also that in filtered free surface (lk_dynspg_flt=T),
+      !!             the time stepping has already been done in dynspg module
+      !!
+      !!              * Apply lateral boundary conditions on after velocity 
+      !!             at the local domain boundaries through lbc_lnk call,
+      !!             at the radiative open boundaries (lk_obc=T),
+      !!             at the relaxed   open boundaries (lk_bdy=T), and
+      !!             at the AGRIF zoom     boundaries (lk_agrif=T)
+      !!
+      !!              * Apply the time filter applied and swap of the dynamics
+      !!             arrays to start the next time step:
+      !!                (ub,vb) = (un,vn) + atfp [ (ub,vb) + (ua,va) - 2 (un,vn) ]
+      !!                (un,vn) = (ua,va).
+      !!             Note that with flux form advection and variable volume layer
+      !!             (lk_vvl=T), the time filter is applied on thickness weighted
+      !!             velocity.
+      !!
+      !! ** Action :   ub,vb   filtered before horizontal velocity of next time-step
+      !!               un,vn   now horizontal velocity of next time-step
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+#if ! defined key_dynspg_flt
+      REAL(wp) ::   z2dt         ! temporary scalar
+#endif
+      REAL(wp) ::   zue3a , zue3n , zue3b    ! temporary scalar
+      REAL(wp) ::   zve3a , zve3n , zve3b    !    -         -
+      REAL(wp) ::   ze3u_b, ze3u_n, ze3u_a   !    -         -
+      REAL(wp) ::   ze3v_b, ze3v_n, ze3v_a   !    -         - 
+      REAL(wp) ::   zuf   , zvf              !    -         - 
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_nxt : time stepping'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+#if defined key_dynspg_flt
+      !
+      ! Next velocity :   Leap-frog time stepping already done in dynspg_flt.F routine
+      ! -------------
+
+      ! Update after velocity on domain lateral boundaries      (only local domain required)
+      ! --------------------------------------------------
+      CALL lbc_lnk( ua, 'U', -1. )         ! local domain boundaries
+      CALL lbc_lnk( va, 'V', -1. ) 
+      !
+#else
+      ! Next velocity :   Leap-frog time stepping
+      ! -------------
+      z2dt = 2. * rdt                                 ! Euler or leap-frog time step 
+      IF( neuler == 0 .AND. kt == nit000 )  z2dt = rdt
+      !
+      IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN      ! applied on velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ub(:,:,jk) + z2dt * ua(:,:,jk) ) * umask(:,:,jk)
+            va(:,:,jk) = ( vb(:,:,jk) + z2dt * va(:,:,jk) ) * vmask(:,:,jk)
+         END DO
+      ELSE                                            ! applied on thickness weighted velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = (          ub(:,:,jk) * fse3u_b(:,:,jk)      &
+               &           + z2dt * ua(:,:,jk) * fse3u_n(:,:,jk)  )   &
+               &         / fse3u_a(:,:,jk) * umask(:,:,jk)
+            va(:,:,jk) = (          vb(:,:,jk) * fse3v_b(:,:,jk)      &
+               &           + z2dt * va(:,:,jk) * fse3v_n(:,:,jk)  )   &
+               &         / fse3v_a(:,:,jk) * vmask(:,:,jk)
+         END DO
+      ENDIF
+
+
+      ! Update after velocity on domain lateral boundaries
+      ! --------------------------------------------------      
+      CALL lbc_lnk( ua, 'U', -1. )     !* local domain boundaries
+      CALL lbc_lnk( va, 'V', -1. ) 
+      !
+# if defined key_obc
+      !                                !* OBC open boundaries
+      CALL obc_dyn( kt )
+      !
+      IF ( lk_dynspg_exp .OR. lk_dynspg_ts ) THEN
+         ! Flather boundary condition : - Update sea surface height on each open boundary
+         !                                       sshn   (= after ssh   ) for explicit case
+         !                                       sshn_b (= after ssha_b) for time-splitting case
+         !                              - Correct the barotropic velocities
+         CALL obc_dyn_bt( kt )
+         !
+!!gm ERROR - potential BUG: sshn should not be modified at this stage !!   ssh_nxt not alrady called
+         CALL lbc_lnk( sshn, 'T', 1. )         ! Boundary conditions on sshn
+         !
+         IF( ln_vol_cst )   CALL obc_vol( kt )
+         !
+         IF(ln_ctl)   CALL prt_ctl( tab2d_1=sshn, clinfo1=' ssh      : ', mask1=tmask )
+      ENDIF
+      !
+# elif defined key_bdy 
+      !                                !* BDY open boundaries
+      !RB all this part should be in a specific routine
+      IF( lk_dynspg_exp .OR. lk_dynspg_ts ) THEN       ! except for filtered option
+         !
+         CALL bdy_dyn_frs( kt )
+         !
+         IF( ln_bdy_dyn_fla ) THEN
+            ua_e(:,:) = 0.e0
+            va_e(:,:) = 0.e0
+            ! Set these variables for use in bdy_dyn_fla
+            hur_e(:,:) = hur(:,:)
+            hvr_e(:,:) = hvr(:,:)
+            DO jk = 1, jpkm1   !! Vertically integrated momentum trends
+               ua_e(:,:) = ua_e(:,:) + fse3u(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
+               va_e(:,:) = va_e(:,:) + fse3v(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
+            END DO
+            ua_e(:,:) = ua_e(:,:) * hur(:,:)
+            va_e(:,:) = va_e(:,:) * hvr(:,:)
+            DO jk = 1 , jpkm1
+               ua(:,:,jk) = ua(:,:,jk) - ua_e(:,:)
+               va(:,:,jk) = va(:,:,jk) - va_e(:,:)
+            END DO
+            CALL bdy_dta_bt( kt+1, 0)
+            CALL bdy_dyn_fla( sshn_b )
+            CALL lbc_lnk( ua_e, 'U', -1. )   ! Boundary points should be updated
+            CALL lbc_lnk( va_e, 'V', -1. )   !
+            DO jk = 1 , jpkm1
+               ua(:,:,jk) = ( ua(:,:,jk) + ua_e(:,:) ) * umask(:,:,jk)
+               va(:,:,jk) = ( va(:,:,jk) + va_e(:,:) ) * vmask(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF
+# endif
+      !
+# if defined key_agrif
+      CALL Agrif_dyn( kt )             !* AGRIF zoom boundaries
+# endif
+#endif
+
+      ! Time filter and swap of dynamics arrays
+      ! ------------------------------------------
+      IF( neuler == 0 .AND. kt == nit000 ) THEN        !* Euler at first time-step: only swap
+         DO jk = 1, jpkm1
+            un(:,:,jk) = ua(:,:,jk)                          ! un <-- ua
+            vn(:,:,jk) = va(:,:,jk)
+         END DO
+      ELSE                                             !* Leap-Frog : Asselin filter and swap
+         IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN          ! applied on velocity
+            DO jk = 1, jpkm1                              
+               DO jj = 1, jpj
+                  DO ji = 1, jpi    
+                     zuf = atfp * ( ub(ji,jj,jk) + ua(ji,jj,jk) ) + atfp1 * un(ji,jj,jk)
+                     zvf = atfp * ( vb(ji,jj,jk) + va(ji,jj,jk) ) + atfp1 * vn(ji,jj,jk)
+                     !
+                     ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                     vb(ji,jj,jk) = zvf
+                     un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                     vn(ji,jj,jk) = va(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSE                                                ! applied on thickness weighted velocity
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ze3u_a = fse3u_a(ji,jj,jk)
+                     ze3v_a = fse3v_a(ji,jj,jk)
+                     ze3u_n = fse3u_n(ji,jj,jk)
+                     ze3v_n = fse3v_n(ji,jj,jk)
+                     ze3u_b = fse3u_b(ji,jj,jk)
+                     ze3v_b = fse3v_b(ji,jj,jk)
+                     !
+                     zue3a = ua(ji,jj,jk) * ze3u_a
+                     zve3a = va(ji,jj,jk) * ze3v_a
+                     zue3n = un(ji,jj,jk) * ze3u_n
+                     zve3n = vn(ji,jj,jk) * ze3v_n
+                     zue3b = ub(ji,jj,jk) * ze3u_b
+                     zve3b = vb(ji,jj,jk) * ze3v_b
+                     !
+                     zuf  = ( atfp  * ( zue3b  + zue3a  ) + atfp1 * zue3n  )   &
+                        & / ( atfp  * ( ze3u_b + ze3u_a ) + atfp1 * ze3u_n ) * umask(ji,jj,jk)
+                     zvf  = ( atfp  * ( zve3b  + zve3a  ) + atfp1 * zve3n  )   &
+                        & / ( atfp  * ( ze3v_b + ze3v_a ) + atfp1 * ze3v_n ) * vmask(ji,jj,jk)
+                     !
+                     ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                     vb(ji,jj,jk) = zvf
+                     un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                     vn(ji,jj,jk) = va(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+#if defined key_agrif
+      ! Update velocity at AGRIF zoom boundaries
+      IF (.NOT.Agrif_Root())    CALL Agrif_Update_Dyn( kt )
+#endif      
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt  - Un: ', mask1=umask,   &
+         &                       tab3d_2=vn, clinfo2=' Vn: '       , mask2=vmask )
+      ! 
+   END SUBROUTINE dyn_nxt
+
+   !!=========================================================================
+END MODULE dynnxt
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 1844)
@@ -0,0 +1,183 @@
+MODULE dynspg
+   !!======================================================================
+   !!                       ***  MODULE  dynspg  ***
+   !! Ocean dynamics:  surface pressure gradient control
+   !!======================================================================
+   !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec, V. Garnier)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_spg     : update the dynamics trend with the lateral diffusion
+   !!   dyn_spg_ctl : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE obc_oce        ! ocean open boundary conditions
+   USE dynspg_oce     ! surface pressure gradient variables
+   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
+   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
+   USE dynspg_flt     ! surface pressure gradient     (dyn_spg_flt routine)
+   USE trdmod         ! ocean dynamics trends
+   USE trdmod_oce     ! ocean variables trends
+   USE prtctl         ! Print control                     (prt_ctl routine)
+   USE in_out_manager ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_spg   ! routine called by step module
+
+   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_... 
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_spg( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg  ***
+      !!
+      !! ** Purpose :   achieve the momentum time stepping by computing the
+      !!              last trend, the surface pressure gradient, and performing
+      !!              the Leap-Frog integration.
+      !!gm              In the current version only the filtered solution provide
+      !!gm            the after velocity, in the 2 other (ua,va) are still the trends
+      !!
+      !! ** Method  :   Three schemes:
+      !!              - explicit computation      : the spg is evaluated at now
+      !!              - filtered computation      : the Roulet & madec (2000) technique is used
+      !!              - split-explicit computation: a time splitting technique is used
+      !!
+      !! N.B. : When key_esopa is used all the scheme are tested, regardless 
+      !!        of the physical meaning of the results. 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT(  out) ::   kindic   ! solver flag
+      !!
+      REAL(wp) ::   z2dt   ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdu, ztrdv   ! 3D workspace
+      !!----------------------------------------------------------------------
+
+
+!!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that 
+!!gm             they return the after velocity, not the trends (as in trazdf_imp...)
+!!gm             In this case, change/simplify dynnxt
+
+
+
+      IF( kt == nit000 )   CALL dyn_spg_ctl      ! initialisation & control of options
+
+      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+
+      SELECT CASE ( nspg )                       ! compute surf. pressure gradient trend and add it to the general trend
+      !                                                     
+      CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
+      CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
+      CASE (  2 )   ;   CALL dyn_spg_flt( kt, kindic )      ! filtered
+      !                                                    
+      CASE ( -1 )                                ! esopa: test all possibility with control print
+                        CALL dyn_spg_exp( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, &
+         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                        CALL dyn_spg_ts ( kt )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, &
+         &                           tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                        CALL dyn_spg_flt( kt, kindic )
+                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, &
+         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      END SELECT
+      !                    
+      IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
+         SELECT CASE ( nspg )
+         CASE ( 0, 1 )
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CASE( 2 )
+            z2dt = 2. * rdt
+            IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
+            ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:)
+            ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:)
+         END SELECT
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_spg, 'DYN', kt )
+      ENDIF
+      !                                          ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_spg
+
+
+   SUBROUTINE dyn_spg_ctl
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg_ctl  ***
+      !!                
+      !! ** Purpose :   Control the consistency between cpp options for 
+      !!              surface pressure gradient schemes
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN             ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_spg_ctl : choice of the surface pressure gradient scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '     Explicit free surface                  lk_dynspg_exp = ', lk_dynspg_exp
+         WRITE(numout,*) '     Free surface with time splitting       lk_dynspg_ts  = ', lk_dynspg_ts
+         WRITE(numout,*) '     Filtered free surface cst volume       lk_dynspg_flt = ', lk_dynspg_flt
+      ENDIF
+
+      !                        ! Control of surface pressure gradient scheme options
+      ioptio = 0
+      IF(lk_dynspg_exp)   ioptio = ioptio + 1
+      IF(lk_dynspg_ts )   ioptio = ioptio + 1
+      IF(lk_dynspg_flt)   ioptio = ioptio + 1
+      !
+      IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ioptio == 0 )   &
+           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' )
+      !
+      IF( lk_esopa     )   nspg = -1
+      IF( lk_dynspg_exp)   nspg =  0
+      IF( lk_dynspg_ts )   nspg =  1
+      IF( lk_dynspg_flt)   nspg =  2
+      !
+      IF( lk_esopa     )   nspg = -1
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nspg == -1 )   WRITE(numout,*) '     ESOPA test All scheme used'
+         IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
+         IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
+         IF( nspg ==  2 )   WRITE(numout,*) '     filtered free surface'
+      ENDIF
+
+      !                        ! Control of timestep choice
+      IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN
+         IF( n_cla == 1 )   &
+           &   CALL ctl_stop( ' Crossland advection not implemented for this free surface formulation ' )
+      ENDIF
+
+#if defined key_obc
+      !                        ! Conservation of ocean volume (key_dynspg_flt)
+      IF( lk_dynspg_flt )   ln_vol_cst = .true.
+
+      !                        ! Application of Flather's algorithm at open boundaries
+      IF( lk_dynspg_flt )   ln_obc_fla = .false.
+      IF( lk_dynspg_exp )   ln_obc_fla = .true.
+      IF( lk_dynspg_ts  )   ln_obc_fla = .true.
+#endif
+      !
+   END SUBROUTINE dyn_spg_ctl
+
+  !!======================================================================
+END MODULE dynspg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_exp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_exp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_exp.F90	(revision 1844)
@@ -0,0 +1,116 @@
+MODULE dynspg_exp
+   !!======================================================================
+   !!                   ***  MODULE  dynspg_exp  ***
+   !! Ocean dynamics:  surface pressure gradient trend
+   !!======================================================================
+   !! History :  2.0  !  2005-11  (V. Garnier, G. Madec, L. Bessieres) Original code
+   !!            3.2  !  2009-06  (G. Madec, M. Leclair, R. Benshila) introduce sshwzv module
+   !!----------------------------------------------------------------------
+#if defined key_dynspg_exp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_dynspg_exp'                              explicit free surface
+   !!----------------------------------------------------------------------
+   !!   dyn_spg_exp  : update the momentum trend with the surface 
+   !!                      pressure gradient in the free surface constant  
+   !!                      volume case with vector optimization
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE obc_oce         ! Lateral open boundary condition
+   USE phycst          ! physical constants
+   USE obc_par         ! open boundary condition parameters
+   USE obcdta          ! open boundary condition data     (obc_dta_bt routine)
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE iom             ! I/O library
+   USE restart         ! only for lrst_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_spg_exp   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_spg_exp( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine dyn_spg_exp  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to the surface pressure
+      !!              gradient in case of explicit free surface formulation and 
+      !!              add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   Explicit free surface formulation. Add to the general
+      !!              momentum trend the surface pressure gradient :
+      !!                      (ua,va) = (ua,va) + (spgu,spgv)
+      !!              where spgu = -1/rau0 d/dx(ps) = -g/e1u di( sshn )
+      !!                    spgv = -1/rau0 d/dy(ps) = -g/e2v dj( sshn )
+      !!
+      !! ** Action :   (ua,va)   trend of horizontal velocity increased by 
+      !!                         the surf. pressure gradient trend
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in )  ::   kt         ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk               ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_spg_exp : surface pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   (explicit free surface)'
+         !
+         spgu(:,:) = 0.e0   ;   spgv(:,:) = 0.e0
+         !
+         IF( lk_vvl .AND. lwp ) WRITE(numout,*) '              lk_vvl=T : spg is included in dynhpg'
+      ENDIF
+
+
+!!gm bug ??  Rachid we have to discuss of the call below. I don't understand why it is here and not in ssh_wzv
+      IF( lk_obc )   CALL obc_dta_bt( kt, 0 )      ! OBC: read or estimate ssh and vertically integrated velocities
+!!gm
+
+      IF( .NOT. lk_vvl ) THEN          !* fixed volume : add the surface pressure gradient trend
+         !
+         DO jj = 2, jpjm1                    ! now surface pressure gradient
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj)
+               spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj)
+            END DO 
+         END DO 
+         DO jk = 1, jpkm1                    ! Add it to the general trend
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
+                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+      !
+   END SUBROUTINE dyn_spg_exp
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case :   Empty module   No standart explicit free surface 
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_spg_exp( kt )       ! Empty routine
+      WRITE(*,*) 'dyn_spg_exp: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_spg_exp
+#endif
+
+   !!======================================================================
+END MODULE dynspg_exp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 1844)
@@ -0,0 +1,409 @@
+MODULE dynspg_flt
+   !!======================================================================
+   !!                   ***  MODULE  dynspg_flt  ***
+   !! Ocean dynamics:  surface pressure gradient trend
+   !!======================================================================
+   !! History    OPA  !  1998-05  (G. Roullet)  free surface
+   !!                 !  1998-10  (G. Madec, M. Imbard)  release 8.2
+   !!   NEMO     O.1  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
+   !!            1.0  !  2004-08  (C. Talandier) New trends organization
+   !!             -   !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            2.0  !  2006-07  (S. Masson)  distributed restart using iom
+   !!             -   !  2006-08  (J.Chanut, A.Sellar) Calls to BDY routines. 
+   !!            3.2  !  2009-03  (G. Madec, M. Leclair, R. Benshila) introduce sshwzv module
+   !!----------------------------------------------------------------------
+#if defined key_dynspg_flt   ||   defined key_esopa  
+   !!----------------------------------------------------------------------
+   !!   'key_dynspg_flt'                              filtered free surface
+   !!----------------------------------------------------------------------
+   !!   dyn_spg_flt  : update the momentum trend with the surface pressure gradient in the filtered free surface case 
+   !!   flt_rst      : read/write the time-splitting restart fields in the ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE zdf_oce         ! ocean vertical physics
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE obc_oce         ! Lateral open boundary condition
+   USE sol_oce         ! ocean elliptic solver
+   USE phycst          ! physical constants
+   USE domvvl          ! variable volume
+   USE dynadv          ! advection 
+   USE solmat          ! matrix construction for elliptic solvers
+   USE solver          ! solver initialization
+   USE solpcg          ! preconditionned conjugate gradient solver
+   USE solsor          ! Successive Over-relaxation solver
+   USE obcdyn          ! ocean open boundary condition (obc_dyn routines)
+   USE obcvol          ! ocean open boundary condition (obc_vol routines)
+   USE bdy_oce         ! Unstructured open boundaries condition
+   USE bdydyn          ! Unstructured open boundaries condition (bdy_dyn routine) 
+   USE bdyvol          ! Unstructured open boundaries condition (bdy_vol routine)
+   USE cla_dynspg      ! cross land advection
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE agrif_opa_interp
+   USE iom
+   USE restart         ! only for lrst_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_spg_flt  ! routine called by step.F90
+   PUBLIC   flt_rst      ! routine called by istate.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_spg_flt( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine dyn_spg_flt  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to the surface pressure 
+      !!      gradient in case of filtered free surface formulation  and add
+      !!      it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   Filtered free surface formulation. The surface
+      !!      pressure gradient is given by:
+      !!         spgu = 1/rau0 d/dx(ps) =  1/e1u di( sshn + btda )
+      !!         spgv = 1/rau0 d/dy(ps) =  1/e2v dj( sshn + btda )
+      !!      where sshn is the free surface elevation and btda is the after
+      !!      time derivative of the free surface elevation
+      !!       -1- evaluate the surface presure trend (including the addi-
+      !!      tional force) in three steps:
+      !!        a- compute the right hand side of the elliptic equation:
+      !!            gcb = 1/(e1t e2t) [ di(e2u spgu) + dj(e1v spgv) ]
+      !!         where (spgu,spgv) are given by:
+      !!            spgu = vertical sum[ e3u (ub+ 2 rdt ua ) ]
+      !!                 - grav 2 rdt hu /e1u di[sshn + emp]
+      !!            spgv = vertical sum[ e3v (vb+ 2 rdt va) ]
+      !!                 - grav 2 rdt hv /e2v dj[sshn + emp]
+      !!         and define the first guess from previous computation :
+      !!            zbtd = btda
+      !!            btda = 2 zbtd - btdb
+      !!            btdb = zbtd
+      !!        b- compute the relative accuracy to be reached by the
+      !!         iterative solver
+      !!        c- apply the solver by a call to sol... routine
+      !!       -2- compute and add the free surface pressure gradient inclu-
+      !!      ding the additional force used to stabilize the equation.
+      !!
+      !! ** Action : - Update (ua,va) with the surf. pressure gradient trend
+      !!
+      !! References : Roullet and Madec 1999, JGR.
+      !!---------------------------------------------------------------------
+      USE oce, ONLY :   zub   => ta   ! ta used as workspace
+      USE oce, ONLY :   zvb   => sa   ! ta used as workspace
+      !!
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT(  out) ::   kindic   ! solver convergence flag (<0 if not converge)
+      !!                                   
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   z2dt, z2dtg          ! temporary scalars
+      REAL(wp) ::   zgcb, zbtd   !   -          -
+      REAL(wp) ::   ztdgu, ztdgv         !   -          -
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_spg_flt : surface pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   (free surface constant volume case)'
+       
+         ! set to zero free surface specific arrays
+         spgu(:,:) = 0.e0                     ! surface pressure gradient (i-direction)
+         spgv(:,:) = 0.e0                     ! surface pressure gradient (j-direction)
+         CALL solver_init( nit000 )           ! Elliptic solver initialisation
+
+         ! read filtered free surface arrays in restart file
+         ! when using agrif, sshn, gcx have to be read in istate
+         IF(.NOT. lk_agrif)   CALL flt_rst( nit000, 'READ' )      ! read or initialize the following fields:
+         !                                                        ! gcx, gcxb
+      ENDIF
+
+      ! Local constant initialization
+      z2dt = 2. * rdt                                             ! time step: leap-frog
+      IF( neuler == 0 .AND. kt == nit000   )   z2dt = rdt         ! time step: Euler if restart from rest
+      IF( neuler == 0 .AND. kt == nit000+1 )   CALL sol_mat( kt )
+      z2dtg  = grav * z2dt
+
+      ! Evaluate the masked next velocity (effect of the additional force not included)
+      ! ---------------------------------  
+      IF( lk_vvl ) THEN          ! variable volume  (surface pressure gradient already included in dyn_hpg)
+         !
+         IF( ln_dynadv_vec ) THEN      ! vector form : applied on velocity
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ua(ji,jj,jk) = (  ub(ji,jj,jk) + z2dt * ua(ji,jj,jk)  ) * umask(ji,jj,jk)
+                     va(ji,jj,jk) = (  vb(ji,jj,jk) + z2dt * va(ji,jj,jk)  ) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         ELSE                          ! flux form : applied on thickness weighted velocity
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ua(ji,jj,jk) = (        ub(ji,jj,jk) * fse3u_b(ji,jj,jk)      &
+                        &           + z2dt * ua(ji,jj,jk) * fse3u_n(ji,jj,jk)  )   &
+                        &         / fse3u_a(ji,jj,jk) * umask(ji,jj,jk)
+                     va(ji,jj,jk) = (        vb(ji,jj,jk) * fse3v_b(ji,jj,jk)      &
+                        &           + z2dt * va(ji,jj,jk) * fse3v_n(ji,jj,jk)  )   &
+                        &         / fse3v_a(ji,jj,jk) * vmask(ji,jj,jk)
+                 END DO
+               END DO
+            END DO
+            !
+         ENDIF
+         !
+      ELSE                       ! fixed volume  (add the surface pressure gradient + unweighted time stepping)
+         !
+         DO jj = 2, jpjm1              ! Surface pressure gradient (now)
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj)
+               spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj)
+            END DO 
+         END DO 
+         DO jk = 1, jpkm1              ! unweighted time stepping 
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ua(ji,jj,jk) = (  ub(ji,jj,jk) + z2dt * ( ua(ji,jj,jk) + spgu(ji,jj) )  ) * umask(ji,jj,jk)
+                  va(ji,jj,jk) = (  vb(ji,jj,jk) + z2dt * ( va(ji,jj,jk) + spgv(ji,jj) )  ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+
+#if defined key_obc
+      CALL obc_dyn( kt )      ! Update velocities on each open boundary with the radiation algorithm
+      CALL obc_vol( kt )      ! Correction of the barotropic componant velocity to control the volume of the system
+#endif
+#if defined key_bdy
+      ! Update velocities on unstructured boundary using the Flow Relaxation Scheme
+      CALL bdy_dyn_frs( kt )
+
+      IF (ln_bdy_vol) THEN
+      ! Correction of the barotropic component velocity to control the volume of the system
+        CALL bdy_vol( kt )
+      ENDIF
+#endif
+#if defined key_agrif
+      CALL Agrif_dyn( kt )    ! Update velocities on each coarse/fine interfaces 
+#endif
+#if defined key_orca_r2
+      IF( n_cla == 1 )   CALL dyn_spg_cla( kt )      ! Cross Land Advection (update (ua,va))
+#endif
+
+      ! compute the next vertically averaged velocity (effect of the additional force not included)
+      ! ---------------------------------------------
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            spgu(ji,jj) = 0.e0
+            spgv(ji,jj) = 0.e0
+         END DO
+      END DO
+
+      ! vertical sum
+!CDIR NOLOOPCHG
+      IF( lk_vopt_loop ) THEN          ! vector opt., forced unroll
+         DO jk = 1, jpkm1
+            DO ji = 1, jpij
+               spgu(ji,1) = spgu(ji,1) + fse3u(ji,1,jk) * ua(ji,1,jk)
+               spgv(ji,1) = spgv(ji,1) + fse3v(ji,1,jk) * va(ji,1,jk)
+            END DO
+         END DO
+      ELSE                        ! No  vector opt.
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  spgu(ji,jj) = spgu(ji,jj) + fse3u(ji,jj,jk) * ua(ji,jj,jk)
+                  spgv(ji,jj) = spgv(ji,jj) + fse3v(ji,jj,jk) * va(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      ! transport: multiplied by the horizontal scale factor
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            spgu(ji,jj) = spgu(ji,jj) * e2u(ji,jj)
+            spgv(ji,jj) = spgv(ji,jj) * e1v(ji,jj)
+         END DO
+      END DO
+      CALL lbc_lnk( spgu, 'U', -1. )       ! lateral boundary conditions 
+      CALL lbc_lnk( spgv, 'V', -1. )
+
+      IF( lk_vvl ) CALL sol_mat( kt )      ! build the matrix at kt (vvl case only)
+
+      ! Right hand side of the elliptic equation and first guess
+      ! --------------------------------------------------------
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! Divergence of the after vertically averaged velocity
+            zgcb =  spgu(ji,jj) - spgu(ji-1,jj)   &
+                  + spgv(ji,jj) - spgv(ji,jj-1)
+            gcb(ji,jj) = gcdprc(ji,jj) * zgcb
+            ! First guess of the after barotropic transport divergence
+            zbtd = gcx(ji,jj)
+            gcx (ji,jj) = 2. * zbtd   - gcxb(ji,jj)
+            gcxb(ji,jj) =      zbtd
+         END DO
+      END DO
+      ! applied the lateral boundary conditions
+      IF( nn_solv == 2 .AND. MAX( jpr2di, jpr2dj ) > 0 )   CALL lbc_lnk_e( gcb, c_solver_pt, 1. )   
+
+#if defined key_agrif
+      IF( .NOT. AGRIF_ROOT() ) THEN
+         ! add contribution of gradient of after barotropic transport divergence 
+         IF( nbondi == -1 .OR. nbondi == 2 )   gcb(3     ,:) =   &
+            &    gcb(3     ,:) - z2dtg * z2dt * laplacu(2     ,:) * gcdprc(3     ,:) * hu(2     ,:) * e2u(2     ,:)
+         IF( nbondi ==  1 .OR. nbondi == 2 )   gcb(nlci-2,:) =   &
+            &    gcb(nlci-2,:) + z2dtg * z2dt * laplacu(nlci-2,:) * gcdprc(nlci-2,:) * hu(nlci-2,:) * e2u(nlci-2,:)
+         IF( nbondj == -1 .OR. nbondj == 2 )   gcb(:     ,3) =   &
+            &    gcb(:,3     ) - z2dtg * z2dt * laplacv(:,2     ) * gcdprc(:,3     ) * hv(:,2     ) * e1v(:,2     )
+         IF( nbondj ==  1 .OR. nbondj == 2 )   gcb(:,nlcj-2) =   &
+            &    gcb(:,nlcj-2) + z2dtg * z2dt * laplacv(:,nlcj-2) * gcdprc(:,nlcj-2) * hv(:,nlcj-2) * e1v(:,nlcj-2)
+      ENDIF
+#endif
+
+
+      ! Relative precision (computation on one processor)
+      ! ------------------
+      rnorme =0.e0
+      rnorme = SUM( gcb(1:jpi,1:jpj) * gcdmat(1:jpi,1:jpj) * gcb(1:jpi,1:jpj) * bmask(:,:) )
+      IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain
+
+      epsr = eps * eps * rnorme
+      ncut = 0
+      ! if rnorme is 0, the solution is 0, the solver is not called
+      IF( rnorme == 0.e0 ) THEN
+         gcx(:,:) = 0.e0
+         res   = 0.e0
+         niter = 0
+         ncut  = 999
+      ENDIF
+
+      ! Evaluate the next transport divergence
+      ! --------------------------------------
+      !    Iterarive solver for the elliptic equation (except IF sol.=0)
+      !    (output in gcx with boundary conditions applied)
+      kindic = 0
+      IF( ncut == 0 ) THEN
+         IF    ( nn_solv == 1 ) THEN   ;   CALL sol_pcg( kindic )      ! diagonal preconditioned conjuguate gradient
+         ELSEIF( nn_solv == 2 ) THEN   ;   CALL sol_sor( kindic )      ! successive-over-relaxation
+         ENDIF
+      ENDIF
+
+      ! Transport divergence gradient multiplied by z2dt
+      ! --------------------------------------------====
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ! trend of Transport divergence gradient
+            ztdgu = z2dtg * (gcx(ji+1,jj  ) - gcx(ji,jj) ) / e1u(ji,jj)
+            ztdgv = z2dtg * (gcx(ji  ,jj+1) - gcx(ji,jj) ) / e2v(ji,jj)
+            ! multiplied by z2dt
+#if defined key_obc
+            ! caution : grad D = 0 along open boundaries
+            spgu(ji,jj) = z2dt * ztdgu * obcumask(ji,jj)
+            spgv(ji,jj) = z2dt * ztdgv * obcvmask(ji,jj)
+#elif defined key_bdy
+            ! caution : grad D = 0 along open boundaries
+            ! Remark: The filtering force could be reduced here in the FRS zone
+            !         by multiplying spgu/spgv by (1-alpha) ??  
+            spgu(ji,jj) = z2dt * ztdgu * bdyumask(ji,jj)
+            spgv(ji,jj) = z2dt * ztdgv * bdyvmask(ji,jj)           
+#else
+            spgu(ji,jj) = z2dt * ztdgu
+            spgv(ji,jj) = z2dt * ztdgv
+#endif
+         END DO
+      END DO
+
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() ) THEN
+         ! caution : grad D (fine) = grad D (coarse) at coarse/fine interface
+         IF( nbondi == -1 .OR. nbondi == 2 ) spgu(2     ,:) = z2dtg * z2dt * laplacu(2     ,:) * umask(2     ,:,1)
+         IF( nbondi ==  1 .OR. nbondi == 2 ) spgu(nlci-2,:) = z2dtg * z2dt * laplacu(nlci-2,:) * umask(nlci-2,:,1)
+         IF( nbondj == -1 .OR. nbondj == 2 ) spgv(:,2     ) = z2dtg * z2dt * laplacv(:,2     ) * vmask(:     ,2,1)
+         IF( nbondj ==  1 .OR. nbondj == 2 ) spgv(:,nlcj-2) = z2dtg * z2dt * laplacv(:,nlcj-2) * vmask(:,nlcj-2,1)
+      ENDIF
+#endif
+
+      ! Add the trends multiplied by z2dt to the after velocity
+      ! -------------------------------------------------------
+      !     ( c a u t i o n : (ua,va) here are the after velocity not the
+      !                       trend, the leap-frog time stepping will not
+      !                       be done in dynnxt.F90 routine)
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) + spgu(ji,jj) ) * umask(ji,jj,jk)
+               va(ji,jj,jk) = ( va(ji,jj,jk) + spgv(ji,jj) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! write filtered free surface arrays in restart file
+      ! --------------------------------------------------
+      IF( lrst_oce ) CALL flt_rst( kt, 'WRITE' )
+      !
+   END SUBROUTINE dyn_spg_flt
+
+
+   SUBROUTINE flt_rst( kt, cdrw )
+     !!---------------------------------------------------------------------
+     !!                   ***  ROUTINE ts_rst  ***
+     !!
+     !! ** Purpose : Read or write filtered free surface arrays in restart file
+     !!----------------------------------------------------------------------
+     INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+     CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+     !!----------------------------------------------------------------------
+
+     IF( TRIM(cdrw) == 'READ' ) THEN
+        IF( iom_varid( numror, 'gcx', ldstop = .FALSE. ) > 0 ) THEN
+! Caution : extra-hallow
+! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
+           CALL iom_get( numror, jpdom_autoglo, 'gcx' , gcx (1:jpi,1:jpj) )
+           CALL iom_get( numror, jpdom_autoglo, 'gcxb', gcxb(1:jpi,1:jpj) )
+           IF( neuler == 0 )   gcxb(:,:) = gcx (:,:)
+        ELSE
+           gcx (:,:) = 0.e0
+           gcxb(:,:) = 0.e0
+        ENDIF
+     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+! Caution : extra-hallow
+! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
+        CALL iom_rstput( kt, nitrst, numrow, 'gcx' , gcx (1:jpi,1:jpj) )
+        CALL iom_rstput( kt, nitrst, numrow, 'gcxb', gcxb(1:jpi,1:jpj) )
+     ENDIF
+     !
+   END SUBROUTINE flt_rst
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case :   Empty module   No standart free surface cst volume
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_spg_flt( kt, kindic )       ! Empty routine
+      WRITE(*,*) 'dyn_spg_flt: You should not have seen this print! error?', kt, kindic
+   END SUBROUTINE dyn_spg_flt
+   SUBROUTINE flt_rst    ( kt, cdrw )         ! Empty routine
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      WRITE(*,*) 'flt_rst: You should not have seen this print! error?', kt, cdrw
+   END SUBROUTINE flt_rst
+#endif
+   
+   !!======================================================================
+END MODULE dynspg_flt
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_oce.F90	(revision 1844)
@@ -0,0 +1,48 @@
+MODULE dynspg_oce
+   !!======================================================================
+   !!                       ***  MODULE dynspg_oce  ***
+   !!       
+   !! Ocean dynamics: Define in memory surface pressure gradient variables
+   !!======================================================================
+   !! History :  1.0  !  05-12  (C. Talandier, G. Madec)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC           
+
+   !                                                       !!! Surface pressure gradient logicals
+#if   defined key_dynspg_exp  ||  defined key_esopa
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_exp = .TRUE.   !: Explicit free surface flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_exp = .FALSE.  !: Explicit free surface flag
+#endif
+#if   defined key_dynspg_ts   ||  defined key_esopa
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_ts  = .TRUE.   !: Free surface with time splitting flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_ts  = .FALSE.  !: Free surface with time splitting flag
+#endif
+#if   defined key_dynspg_flt  ||  defined key_esopa
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_flt = .TRUE.   !: Filtered free surface cst volume flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_flt = .FALSE.  !: Filtered free surface cst volume flag
+#endif
+
+!!gm BUG : always required in _ts, only  some of them in vvl
+!    #if   defined key_dynspg_ts   ||   defined key_esopa
+!!gm end
+#if   defined key_dynspg_ts   ||   defined key_vvl   ||   defined key_esopa
+  !                                                                !!! Time splitting scheme (sub-time step variables)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: ua_e  , va_e             ! barotropic velocities (after)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: sshn_e, ssha_e, sshn_b   ! sea surface heigth (now, after, average)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: hu_e  , hv_e             ! now ocean depth ( = Ho+sshn_e )
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: hur_e , hvr_e            ! inverse of the now depth ( = 1/(Ho+sshn_e) )
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!======================================================================
+END MODULE dynspg_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 1844)
@@ -0,0 +1,620 @@
+MODULE dynspg_ts
+   !!======================================================================
+   !! History :   1.0  ! 2004-12  (L. Bessieres, G. Madec)  Original code
+   !!              -   ! 2005-11  (V. Garnier, G. Madec)  optimization
+   !!              -   ! 2006-08  (S. Masson)  distributed restart using iom
+   !!             2.0  ! 2007-07  (D. Storkey) calls to BDY routines
+   !!              -   ! 2008-01  (R. Benshila)  change averaging method
+   !!             3.2  ! 2009-07  (R. Benshila, G. Madec) Complete revisit associated to vvl reactivation
+  !!---------------------------------------------------------------------
+#if defined key_dynspg_ts   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_dynspg_ts'         free surface cst volume with time splitting
+   !!----------------------------------------------------------------------
+   !!   dyn_spg_ts  : compute surface pressure gradient trend using a time-
+   !!                 splitting scheme and add to the general trend 
+   !!   ts_rst      : read/write the time-splitting restart fields in the ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE dynspg_oce      ! surface pressure gradient variables
+   USE phycst          ! physical constants
+   USE domvvl          ! variable volume
+   USE zdfbfr          ! bottom friction
+   USE obcdta          ! open boundary condition data     
+   USE obcfla          ! Flather open boundary condition  
+   USE dynvor          ! vorticity term
+   USE obc_oce         ! Lateral open boundary condition
+   USE obc_par         ! open boundary condition parameters
+   USE bdy_oce         ! unstructured open boundaries
+   USE bdy_par         ! unstructured open boundaries
+   USE bdydta          ! unstructured open boundaries
+   USE bdydyn          ! unstructured open boundaries
+   USE bdytides        ! tidal forcing at unstructured open boundaries.
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE in_out_manager  ! I/O manager
+   USE iom
+   USE restart         ! only for lrst_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dyn_spg_ts  ! routine called by step.F90
+   PUBLIC ts_rst      ! routine called by istate.F90
+
+
+   REAL(wp), DIMENSION(jpi,jpj) ::  ftnw, ftne   ! triad of coriolis parameter
+   REAL(wp), DIMENSION(jpi,jpj) ::  ftsw, ftse   ! (only used with een vorticity scheme)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   un_b, vn_b   ! averaged velocity
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!-------------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software is governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!-------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_spg_ts( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine dyn_spg_ts  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to the surface pressure
+      !!      gradient in case of free surface formulation with time-splitting.
+      !!      Add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   Free surface formulation with time-splitting
+      !!      -1- Save the vertically integrated trend. This general trend is
+      !!          held constant over the barotropic integration.
+      !!          The Coriolis force is removed from the general trend as the
+      !!          surface gradient and the Coriolis force are updated within
+      !!          the barotropic integration.
+      !!      -2- Barotropic loop : updates of sea surface height (ssha_e) and 
+      !!          barotropic velocity (ua_e and va_e) through barotropic 
+      !!          momentum and continuity integration. Barotropic former 
+      !!          variables are time averaging over the full barotropic cycle
+      !!          (= 2 * baroclinic time step) and saved in zuX_b 
+      !!          and zvX_b (X specifying after, now or before).
+      !!      -3- The new general trend becomes :
+      !!          ua = ua - sum_k(ua)/H + ( ua_e - sum_k(ub) )
+      !!
+      !! ** Action : - Update (ua,va) with the surf. pressure gradient trend
+      !!
+      !! References : Griffies et al., (2003): A technical guide to MOM4. NOAA/GFDL
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in)  ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      INTEGER  ::   icycle           ! temporary scalar
+      INTEGER  ::   ikbu, ikbv        ! temporary scalar
+
+      REAL(wp) ::   zraur, zcoef, z2dt_e, z2dt_b     ! temporary scalars
+      REAL(wp) ::   z1_8, zx1, zy1                   !    -         -
+      REAL(wp) ::   z1_4, zx2, zy2                   !     -         -
+      REAL(wp) ::   zu_spg, zu_cor, zu_sld, zu_asp   !     -         -
+      REAL(wp) ::   zv_spg, zv_cor, zv_sld, zv_asp   !     -         -
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zhdiv, zsshb_e
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zbfru  , zbfrv     ! 2D workspace
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zsshun_e, zsshvn_e   ! 2D workspace
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zcu, zwx, zua, zun, zub   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zcv, zwy, zva, zvn, zvb   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zun_e, zub_e, zu_sum      ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zvn_e, zvb_e, zv_sum      !  -      -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zssh_sum                  !  -      -
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN             !* initialisation
+         !
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_spg_ts : surface pressure gradient trend'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~   free surface with time splitting'
+         IF(lwp) WRITE(numout,*) ' Number of sub cycle in 1 time-step (2 rdt) : icycle = ',  2*nn_baro
+         !
+         CALL ts_rst( nit000, 'READ' )   ! read or initialize the following fields: un_b, vn_b  
+         !
+         ua_e  (:,:) = un_b (:,:)
+         va_e  (:,:) = vn_b (:,:)
+         hu_e  (:,:) = hu   (:,:)
+         hv_e  (:,:) = hv   (:,:)
+         hur_e (:,:) = hur  (:,:)
+         hvr_e (:,:) = hvr  (:,:)
+         IF( ln_dynvor_een ) THEN
+            ftne(1,:) = 0.e0   ;   ftnw(1,:) = 0.e0   ;   ftse(1,:) = 0.e0   ;   ftsw(1,:) = 0.e0
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  ftne(ji,jj) = ( ff(ji-1,jj  ) + ff(ji  ,jj  ) + ff(ji  ,jj-1) ) / 3.
+                  ftnw(ji,jj) = ( ff(ji-1,jj-1) + ff(ji-1,jj  ) + ff(ji  ,jj  ) ) / 3.
+                  ftse(ji,jj) = ( ff(ji  ,jj  ) + ff(ji  ,jj-1) + ff(ji-1,jj-1) ) / 3.
+                  ftsw(ji,jj) = ( ff(ji  ,jj-1) + ff(ji-1,jj-1) + ff(ji-1,jj  ) ) / 3.
+               END DO
+            END DO
+         ENDIF
+         !
+      ENDIF
+
+      !                                   !* Local constant initialization
+      z2dt_b = 2.0 * rdt                                    ! baroclinic time step
+      z1_8 = 0.5 * 0.25                                     ! coefficient for vorticity estimates
+      z1_4 = 0.5 * 0.5
+      zraur  = 1. / rau0                                    ! 1 / volumic mass
+      !
+      zhdiv(:,:) = 0.e0                                     ! barotropic divergence
+      zu_sld = 0.e0   ;   zu_asp = 0.e0                     ! tides trends (lk_tide=F)
+      zv_sld = 0.e0   ;   zv_asp = 0.e0
+
+      ! -----------------------------------------------------------------------------
+      !  Phase 1 : Coupling between general trend and barotropic estimates (1st step)
+      ! -----------------------------------------------------------------------------
+      !      
+      !                                   !* e3*d/dt(Ua), e3*Ub, e3*Vn (Vertically integrated)
+      !                                   ! --------------------------
+      zua(:,:) = 0.e0   ;   zun(:,:) = 0.e0   ;   zub(:,:) = 0.e0
+      zva(:,:) = 0.e0   ;   zvn(:,:) = 0.e0   ;   zvb(:,:) = 0.e0
+      !
+      DO jk = 1, jpkm1
+#if defined key_vectopt_loop
+         DO jj = 1, 1         !Vector opt. => forced unrolling
+            DO ji = 1, jpij
+#else 
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#endif
+               !                                                                              ! now trend
+               zua(ji,jj) = zua(ji,jj) + fse3u  (ji,jj,jk) * ua(ji,jj,jk) * umask(ji,jj,jk)
+               zva(ji,jj) = zva(ji,jj) + fse3v  (ji,jj,jk) * va(ji,jj,jk) * vmask(ji,jj,jk)
+               !                                                                              ! now velocity 
+               zun(ji,jj) = zun(ji,jj) + fse3u  (ji,jj,jk) * un(ji,jj,jk)
+               zvn(ji,jj) = zvn(ji,jj) + fse3v  (ji,jj,jk) * vn(ji,jj,jk)               
+               !                                                                              ! before velocity
+               zub(ji,jj) = zub(ji,jj) + fse3u_b(ji,jj,jk) * ub(ji,jj,jk) 
+               zvb(ji,jj) = zvb(ji,jj) + fse3v_b(ji,jj,jk) * vb(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      !                                   !* baroclinic momentum trend (remove the vertical mean trend)
+      DO jk = 1, jpkm1                    ! --------------------------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) - zua(ji,jj) * hur(ji,jj)
+               va(ji,jj,jk) = va(ji,jj,jk) - zva(ji,jj) * hvr(ji,jj)
+            END DO
+         END DO
+      END DO
+
+      !                                   !* barotropic Coriolis trends * H (vorticity scheme dependent)
+      !                                   ! ---------------------------====
+      zwx(:,:) = zun(:,:) * e2u(:,:)                   ! now transport 
+      zwy(:,:) = zvn(:,:) * e1v(:,:)
+      !
+      IF( ln_dynvor_ene .OR. ln_dynvor_mix ) THEN      ! energy conserving or mixed scheme
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
+               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
+               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+               ! energy conserving formulation for planetary vorticity term
+               zcu(ji,jj) = z1_4 * ( ff(ji  ,jj-1) * zy1 + ff(ji,jj) * zy2 )
+               zcv(ji,jj) =-z1_4 * ( ff(ji-1,jj  ) * zx1 + ff(ji,jj) * zx2 )
+            END DO
+         END DO
+         !
+      ELSEIF ( ln_dynvor_ens ) THEN                    ! enstrophy conserving scheme
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 =   z1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) + zwy(ji,jj) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+               zx1 = - z1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) + zwx(ji,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+               zcu(ji,jj)  = zy1 * ( ff(ji  ,jj-1) + ff(ji,jj) )
+               zcv(ji,jj)  = zx1 * ( ff(ji-1,jj  ) + ff(ji,jj) )
+            END DO
+         END DO
+         !
+      ELSEIF ( ln_dynvor_een ) THEN                    ! enstrophy and energy conserving scheme
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcu(ji,jj) = + z1_4 / e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) + ftnw(ji+1,jj) * zwy(ji+1,jj  )   &
+                  &                                + ftse(ji,jj  ) * zwy(ji  ,jj-1) + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
+               zcv(ji,jj) = - z1_4 / e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) + ftse(ji,jj+1) * zwx(ji  ,jj+1)   &
+                  &                                + ftnw(ji,jj  ) * zwx(ji-1,jj  ) + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
+            END DO
+         END DO
+         !
+      ENDIF
+
+      !                                   !* Right-Hand-Side of the barotropic momentum equation
+      !                                   ! ----------------------------------------------------
+      IF( lk_vvl ) THEN                         ! Variable volume : remove both Coriolis and Surface pressure gradient
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcu(ji,jj) = zcu(ji,jj) - grav * (  ( rhd(ji+1,jj  ,1) + 1 ) * sshn(ji+1,jj  )    &
+                  &                              - ( rhd(ji  ,jj  ,1) + 1 ) * sshn(ji  ,jj  )  ) * hu(ji,jj) / e1u(ji,jj)
+               zcv(ji,jj) = zcv(ji,jj) - grav * (  ( rhd(ji  ,jj+1,1) + 1 ) * sshn(ji  ,jj+1)    &
+                  &                              - ( rhd(ji  ,jj  ,1) + 1 ) * sshn(ji  ,jj  )  ) * hv(ji,jj) / e2v(ji,jj)
+            END DO
+         END DO
+      ENDIF
+
+      DO jj = 2, jpjm1                             ! Remove coriolis term (and possibly spg) from barotropic trend
+         DO ji = fs_2, fs_jpim1
+            zua(ji,jj) = zua(ji,jj) - zcu(ji,jj)
+            zva(ji,jj) = zva(ji,jj) - zcv(ji,jj)
+         END DO
+      END DO
+
+                    
+      !                                             ! Remove barotropic contribution of bottom friction 
+      !                                             ! from the barotropic transport trend
+      zcoef = -1. / z2dt_b
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ikbu = MIN( mbathy(ji+1,jj), mbathy(ji,jj) )
+            ikbv = MIN( mbathy(ji,jj+1), mbathy(ji,jj) )
+            !
+            ! Apply stability criteria for bottom friction
+            !RBbug for vvl and external mode we may need to
+            ! use varying fse3
+            zbfru  (ji,jj) = MAX( bfrua(ji,jj), fse3u(ji,jj,ikbu)*zcoef )
+            zbfrv  (ji,jj) = MAX( bfrva(ji,jj), fse3v(ji,jj,ikbv)*zcoef )
+         END DO
+      END DO
+
+      IF( lk_vvl ) THEN
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zua(ji,jj) = zua(ji,jj) - zbfru(ji,jj) * zub(ji,jj)   &
+                  &       / ( hu_0(ji,jj) + sshu_b(ji,jj) + 1.e0 - umask(ji,jj,1) )
+               zva(ji,jj) = zva(ji,jj) - zbfrv(ji,jj) * zvb(ji,jj)   &
+                  &       / ( hv_0(ji,jj) + sshv_b(ji,jj) + 1.e0 - vmask(ji,jj,1) )
+            END DO
+         END DO
+      ELSE
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zua(ji,jj) = zua(ji,jj) - zbfru(ji,jj) * zub(ji,jj) * hur(ji,jj)
+               zva(ji,jj) = zva(ji,jj) - zbfrv(ji,jj) * zvb(ji,jj) * hvr(ji,jj)
+            END DO
+         END DO
+      ENDIF
+
+      !                                   !* d/dt(Ua), Ub, Vn (Vertical mean velocity)
+      !                                   ! -------------------------- 
+      zua(:,:) = zua(:,:) * hur(:,:)
+      zva(:,:) = zva(:,:) * hvr(:,:)
+      !
+      IF( lk_vvl ) THEN
+         zub(:,:) = zub(:,:) * umask(:,:,1) / ( hu_0(:,:) + sshu_b(:,:) + 1.e0 - umask(:,:,1) )
+         zvb(:,:) = zvb(:,:) * vmask(:,:,1) / ( hv_0(:,:) + sshv_b(:,:) + 1.e0 - vmask(:,:,1) )
+      ELSE
+         zub(:,:) = zub(:,:) * hur(:,:)
+         zvb(:,:) = zvb(:,:) * hvr(:,:)
+      ENDIF
+
+      ! -----------------------------------------------------------------------
+      !  Phase 2 : Integration of the barotropic equations with time splitting
+      ! -----------------------------------------------------------------------
+      !
+      !                                             ! ==================== !
+      !                                             !    Initialisations   !
+      !                                             ! ==================== !
+      icycle = 2  * nn_baro            ! Number of barotropic sub time-step
+      
+      !                                ! Start from NOW field
+      hu_e   (:,:) = hu   (:,:)            ! ocean depth at u- and v-points
+      hv_e   (:,:) = hv   (:,:) 
+      hur_e  (:,:) = hur  (:,:)            ! ocean depth inverted at u- and v-points
+      hvr_e  (:,:) = hvr  (:,:)
+!RBbug     zsshb_e(:,:) = sshn (:,:)  
+      zsshb_e(:,:) = sshn_b(:,:)           ! sea surface height (before and now)
+      sshn_e (:,:) = sshn (:,:)
+      
+      zun_e  (:,:) = un_b (:,:)            ! barotropic velocity (external)
+      zvn_e  (:,:) = vn_b (:,:)
+      zub_e  (:,:) = un_b (:,:)
+      zvb_e  (:,:) = vn_b (:,:)
+
+      zu_sum  (:,:) = un_b (:,:)           ! summation
+      zv_sum  (:,:) = vn_b (:,:)
+      zssh_sum(:,:) = sshn (:,:)
+
+#if defined key_obc
+      ! set ssh corrections to 0
+      ! ssh corrections are applied to normal velocities (Flather's algorithm) and averaged over the barotropic loop
+      IF( lp_obc_east  )   sshfoe_b(:,:) = 0.e0
+      IF( lp_obc_west  )   sshfow_b(:,:) = 0.e0
+      IF( lp_obc_south )   sshfos_b(:,:) = 0.e0
+      IF( lp_obc_north )   sshfon_b(:,:) = 0.e0
+#endif
+
+      !                                             ! ==================== !
+      DO jn = 1, icycle                             !  sub-time-step loop  ! (from NOW to AFTER+1)
+         !                                          ! ==================== !
+         z2dt_e = 2. * ( rdt / nn_baro )
+         IF( jn == 1 )   z2dt_e = rdt / nn_baro
+
+         !                                                !* Update the forcing (OBC, BDY and tides)
+         !                                                !  ------------------
+         IF( lk_obc                     )   CALL obc_dta_bt( kt, jn   )
+         IF( lk_bdy  .OR.  ln_bdy_tides )   CALL bdy_dta_bt( kt, jn+1 )
+
+         !                                                !* after ssh_e
+         !                                                !  -----------
+         DO jj = 2, jpjm1                                      ! Horizontal divergence of barotropic transports
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zhdiv(ji,jj) = (   e2u(ji  ,jj) * zun_e(ji  ,jj) * hu_e(ji  ,jj)     &
+                  &             - e2u(ji-1,jj) * zun_e(ji-1,jj) * hu_e(ji-1,jj)     &
+                  &             + e1v(ji,jj  ) * zvn_e(ji,jj  ) * hv_e(ji,jj  )     &
+                  &             - e1v(ji,jj-1) * zvn_e(ji,jj-1) * hv_e(ji,jj-1)   ) / ( e1t(ji,jj) * e2t(ji,jj) )
+            END DO
+         END DO
+         !
+#if defined key_obc
+         !                                                     ! OBC : zhdiv must be zero behind the open boundary
+!!  mpp remark: The zeroing of hdiv can probably be extended to 1->jpi/jpj for the correct row/column
+         IF( lp_obc_east  )   zhdiv(nie0p1:nie1p1,nje0  :nje1  ) = 0.e0      ! east
+         IF( lp_obc_west  )   zhdiv(niw0  :niw1  ,njw0  :njw1  ) = 0.e0      ! west
+         IF( lp_obc_north )   zhdiv(nin0  :nin1  ,njn0p1:njn1p1) = 0.e0      ! north
+         IF( lp_obc_south )   zhdiv(nis0  :nis1  ,njs0  :njs1  ) = 0.e0      ! south
+#endif
+#if defined key_bdy
+         zhdiv(:,:) = zhdiv(:,:) * bdytmask(:,:)               ! BDY mask
+#endif
+         !
+         DO jj = 2, jpjm1                                      ! leap-frog on ssh_e
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ssha_e(ji,jj) = ( zsshb_e(ji,jj) - z2dt_e * ( zraur * emp(ji,jj) + zhdiv(ji,jj) ) ) * tmask(ji,jj,1)
+            END DO
+         END DO
+
+         !                                                !* after barotropic velocities (vorticity scheme dependent)
+         !                                                !  ---------------------------  
+         zwx(:,:) = e2u(:,:) * zun_e(:,:) * hu_e(:,:)           ! now_e transport
+         zwy(:,:) = e1v(:,:) * zvn_e(:,:) * hv_e(:,:)
+         !
+         IF( ln_dynvor_ene .OR. ln_dynvor_mix ) THEN      !==  energy conserving or mixed scheme  ==!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! surface pressure gradient
+                  IF( lk_vvl) THEN
+                     zu_spg = -grav * (  ( rhd(ji+1,jj ,1) + 1 ) * sshn_e(ji+1,jj  )    &
+                        &              - ( rhd(ji  ,jj ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e1u(ji,jj)
+                     zv_spg = -grav * (  ( rhd(ji ,jj+1,1) + 1 ) * sshn_e(ji  ,jj+1)    &
+                        &              - ( rhd(ji ,jj  ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e2v(ji,jj)
+                  ELSE
+                     zu_spg = -grav * ( sshn_e(ji+1,jj) - sshn_e(ji,jj) ) / e1u(ji,jj)
+                     zv_spg = -grav * ( sshn_e(ji,jj+1) - sshn_e(ji,jj) ) / e2v(ji,jj)
+                  ENDIF
+                  ! energy conserving formulation for planetary vorticity term
+                  zy1 = ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
+                  zy2 = ( zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+                  zx1 = ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
+                  zx2 = ( zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+                  zu_cor = z1_4 * ( ff(ji  ,jj-1) * zy1 + ff(ji,jj) * zy2 ) * hur_e(ji,jj)
+                  zv_cor =-z1_4 * ( ff(ji-1,jj  ) * zx1 + ff(ji,jj) * zx2 ) * hvr_e(ji,jj)
+                  ! after velocities with implicit bottom friction
+                  ua_e(ji,jj) = ( zub_e(ji,jj) + z2dt_e * ( zu_cor + zu_spg + zu_sld + zu_asp + zua(ji,jj) ) ) * umask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrua(ji,jj) * hur_e(ji,jj) )
+                  va_e(ji,jj) = ( zvb_e(ji,jj) + z2dt_e * ( zv_cor + zv_spg + zv_sld + zv_asp + zva(ji,jj) ) ) * vmask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrva(ji,jj) * hvr_e(ji,jj) )
+               END DO
+            END DO
+            !
+         ELSEIF ( ln_dynvor_ens ) THEN                    !==  enstrophy conserving scheme  ==!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                   ! surface pressure gradient
+                  IF( lk_vvl) THEN
+                     zu_spg = -grav * (  ( rhd(ji+1,jj ,1) + 1 ) * sshn_e(ji+1,jj  )    &
+                        &              - ( rhd(ji  ,jj ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e1u(ji,jj)
+                     zv_spg = -grav * (  ( rhd(ji ,jj+1,1) + 1 ) * sshn_e(ji  ,jj+1)    &
+                        &              - ( rhd(ji ,jj  ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e2v(ji,jj)
+                  ELSE
+                     zu_spg = -grav * ( sshn_e(ji+1,jj) - sshn_e(ji,jj) ) / e1u(ji,jj)
+                     zv_spg = -grav * ( sshn_e(ji,jj+1) - sshn_e(ji,jj) ) / e2v(ji,jj)
+                  ENDIF
+                  ! enstrophy conserving formulation for planetary vorticity term
+                  zy1 =   z1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) + zwy(ji,jj) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+                  zx1 = - z1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) + zwx(ji,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+                  zu_cor  = zy1 * ( ff(ji  ,jj-1) + ff(ji,jj) ) * hur_e(ji,jj)
+                  zv_cor  = zx1 * ( ff(ji-1,jj  ) + ff(ji,jj) ) * hvr_e(ji,jj)
+                  ! after velocities with implicit bottom friction
+                  ua_e(ji,jj) = ( zub_e(ji,jj) + z2dt_e * ( zu_cor + zu_spg + zu_sld + zu_asp + zua(ji,jj) ) ) * umask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrua(ji,jj) * hur_e(ji,jj) )
+                  va_e(ji,jj) = ( zvb_e(ji,jj) + z2dt_e * ( zv_cor + zv_spg + zv_sld + zv_asp + zva(ji,jj) ) ) * vmask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrva(ji,jj) * hvr_e(ji,jj) )
+               END DO
+            END DO
+            !
+         ELSEIF ( ln_dynvor_een ) THEN                    !==  energy and enstrophy conserving scheme  ==!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! surface pressure gradient
+                  IF( lk_vvl) THEN
+                     zu_spg = -grav * (  ( rhd(ji+1,jj  ,1) + 1 ) * sshn_e(ji+1,jj  )    &
+                        &              - ( rhd(ji  ,jj  ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e1u(ji,jj)
+                     zv_spg = -grav * (  ( rhd(ji  ,jj+1,1) + 1 ) * sshn_e(ji  ,jj+1)    &
+                        &              - ( rhd(ji  ,jj  ,1) + 1 ) * sshn_e(ji  ,jj  )  ) / e2v(ji,jj)
+                  ELSE
+                     zu_spg = -grav * ( sshn_e(ji+1,jj) - sshn_e(ji,jj) ) / e1u(ji,jj)
+                     zv_spg = -grav * ( sshn_e(ji,jj+1) - sshn_e(ji,jj) ) / e2v(ji,jj)
+                  ENDIF
+                  ! energy/enstrophy conserving formulation for planetary vorticity term
+                  zu_cor = + z1_4 / e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) + ftnw(ji+1,jj) * zwy(ji+1,jj  )   &
+                     &                           + ftse(ji,jj  ) * zwy(ji  ,jj-1) + ftsw(ji+1,jj) * zwy(ji+1,jj-1) ) * hur_e(ji,jj)
+                  zv_cor = - z1_4 / e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) + ftse(ji,jj+1) * zwx(ji  ,jj+1)   &
+                     &                           + ftnw(ji,jj  ) * zwx(ji-1,jj  ) + ftne(ji,jj  ) * zwx(ji  ,jj  ) ) * hvr_e(ji,jj)
+                  ! after velocities with implicit bottom friction
+                  ua_e(ji,jj) = ( zub_e(ji,jj) + z2dt_e * ( zu_cor + zu_spg + zu_sld + zu_asp + zua(ji,jj) ) ) * umask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrua(ji,jj) * hur_e(ji,jj) )
+                  va_e(ji,jj) = ( zvb_e(ji,jj) + z2dt_e * ( zv_cor + zv_spg + zv_sld + zv_asp + zva(ji,jj) ) ) * vmask(ji,jj,1)   &
+                     &         / ( 1.e0         - z2dt_e * bfrva(ji,jj) * hvr_e(ji,jj) )
+               END DO
+            END DO
+            ! 
+         ENDIF
+         !                                                !* domain lateral boundary
+         !                                                !  -----------------------
+         !                                                      ! Flather's boundary condition for the barotropic loop :
+         !                                                      !         - Update sea surface height on each open boundary
+         !                                                      !         - Correct the velocity
+
+         IF( lk_obc                   )   CALL obc_fla_ts
+         IF( lk_bdy .OR. ln_bdy_tides )   CALL bdy_dyn_fla( sshn_e ) 
+         !
+         CALL lbc_lnk( ua_e  , 'U', -1. )                      ! local domain boundaries 
+         CALL lbc_lnk( va_e  , 'V', -1. )
+         CALL lbc_lnk( ssha_e, 'T',  1. )
+
+         zu_sum  (:,:) = zu_sum  (:,:) + ua_e  (:,:)           ! Sum over sub-time-steps
+         zv_sum  (:,:) = zv_sum  (:,:) + va_e  (:,:) 
+         zssh_sum(:,:) = zssh_sum(:,:) + ssha_e(:,:) 
+
+         !                                                !* Time filter and swap
+         !                                                !  --------------------
+         IF( jn == 1 ) THEN                                     ! Swap only (1st Euler time step)
+            zsshb_e(:,:) = sshn_e(:,:)
+            zub_e  (:,:) = zun_e (:,:)
+            zvb_e  (:,:) = zvn_e (:,:)
+            sshn_e (:,:) = ssha_e(:,:)
+            zun_e  (:,:) = ua_e  (:,:)
+            zvn_e  (:,:) = va_e  (:,:)
+         ELSE                                                   ! Swap + Filter
+            zsshb_e(:,:) = atfp * ( zsshb_e(:,:) + ssha_e(:,:) ) + atfp1 * sshn_e(:,:)
+            zub_e  (:,:) = atfp * ( zub_e  (:,:) + ua_e  (:,:) ) + atfp1 * zun_e (:,:)
+            zvb_e  (:,:) = atfp * ( zvb_e  (:,:) + va_e  (:,:) ) + atfp1 * zvn_e (:,:)
+            sshn_e (:,:) = ssha_e(:,:)
+            zun_e  (:,:) = ua_e  (:,:)
+            zvn_e  (:,:) = va_e  (:,:)
+         ENDIF
+
+         IF( lk_vvl ) THEN                                !* Update ocean depth (variable volume case only)
+            !                                             !  ------------------
+            DO jj = 1, jpjm1                                    ! Sea Surface Height at u- & v-points
+               DO ji = 1, fs_jpim1   ! Vector opt.
+                  zsshun_e(ji,jj) = 0.5 * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )       &
+                     &                  * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshn_e(ji  ,jj)    &
+                     &                    + e1t(ji+1,jj) * e2t(ji+1,jj) * sshn_e(ji+1,jj) )
+                  zsshvn_e(ji,jj) = 0.5 * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )       &
+                     &                  * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshn_e(ji,jj  )    &
+                     &                    + e1t(ji,jj+1) * e2t(ji,jj+1) * sshn_e(ji,jj+1) )
+               END DO
+            END DO
+            CALL lbc_lnk( zsshun_e, 'U', 1. )                   ! lateral boundaries conditions
+            CALL lbc_lnk( zsshvn_e, 'V', 1. ) 
+            !
+            hu_e (:,:) = hu_0(:,:) + zsshun_e(:,:)              ! Ocean depth at U- and V-points
+            hv_e (:,:) = hv_0(:,:) + zsshvn_e(:,:)
+            hur_e(:,:) = umask(:,:,1) / ( hu_e(:,:) + 1.e0 - umask(:,:,1) )
+            hvr_e(:,:) = vmask(:,:,1) / ( hv_e(:,:) + 1.e0 - vmask(:,:,1) )
+            !
+         ENDIF
+         !                                                 ! ==================== !
+      END DO                                               !        end loop      !
+      !                                                    ! ==================== !
+
+#if defined key_obc
+      IF( lp_obc_east  )   sshfoe_b(:,:) = zcoef * sshfoe_b(:,:)     !!gm totally useless ?????
+      IF( lp_obc_west  )   sshfow_b(:,:) = zcoef * sshfow_b(:,:)
+      IF( lp_obc_north )   sshfon_b(:,:) = zcoef * sshfon_b(:,:)
+      IF( lp_obc_south )   sshfos_b(:,:) = zcoef * sshfos_b(:,:)
+#endif
+
+      ! -----------------------------------------------------------------------------
+      ! Phase 3. update the general trend with the barotropic trend
+      ! -----------------------------------------------------------------------------
+      !
+      !                                   !* Time average ==> after barotropic u, v, ssh
+      zcoef =  1.e0 / ( 2 * nn_baro  + 1 ) 
+      un_b  (:,:) = zcoef * zu_sum  (:,:) 
+      vn_b  (:,:) = zcoef * zv_sum  (:,:) 
+      sshn_b(:,:) = zcoef * zssh_sum(:,:) 
+      ! 
+      !                                   !* update the general momentum trend
+      DO jk=1,jpkm1
+         ua(:,:,jk) = ua(:,:,jk) + ( un_b(:,:) - zub(:,:) ) / z2dt_b
+         va(:,:,jk) = va(:,:,jk) + ( vn_b(:,:) - zvb(:,:) ) / z2dt_b
+      END DO
+      !
+      !                                   !* write time-spliting arrays in the restart
+      IF( lrst_oce )   CALL ts_rst( kt, 'WRITE' )
+      !
+      !
+   END SUBROUTINE dyn_spg_ts
+
+
+   SUBROUTINE ts_rst( kt, cdrw )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE ts_rst  ***
+      !!
+      !! ** Purpose : Read or write time-splitting arrays in restart file
+      !!----------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      !
+      INTEGER ::  ji, jk        ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      IF( TRIM(cdrw) == 'READ' ) THEN
+         IF( iom_varid( numror, 'un_b', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numror, jpdom_autoglo, 'un_b'  , un_b  (:,:) )   ! external velocity issued
+            CALL iom_get( numror, jpdom_autoglo, 'vn_b'  , vn_b  (:,:) )   ! from barotropic loop
+         ELSE
+            un_b (:,:) = 0.e0
+            vn_b (:,:) = 0.e0
+            ! vertical sum
+            IF( lk_vopt_loop ) THEN          ! vector opt., forced unroll
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpij
+                     un_b(ji,1) = un_b(ji,1) + fse3u(ji,1,jk) * un(ji,1,jk)
+                     vn_b(ji,1) = vn_b(ji,1) + fse3v(ji,1,jk) * vn(ji,1,jk)
+                  END DO
+               END DO
+            ELSE                             ! No  vector opt.
+               DO jk = 1, jpkm1
+                  un_b(:,:) = un_b(:,:) + fse3u(:,:,jk) * un(:,:,jk)
+                  vn_b(:,:) = vn_b(:,:) + fse3v(:,:,jk) * vn(:,:,jk)
+               END DO
+            ENDIF
+            un_b (:,:) = un_b(:,:) * hur(:,:)
+            vn_b (:,:) = vn_b(:,:) * hvr(:,:)
+         ENDIF
+      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+         CALL iom_rstput( kt, nitrst, numrow, 'un_b'  , un_b  (:,:) )   ! external velocity issued
+         CALL iom_rstput( kt, nitrst, numrow, 'vn_b'  , vn_b  (:,:) )   ! from barotropic loop
+      ENDIF
+      !
+   END SUBROUTINE ts_rst
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case :   Empty module   No standart free surface cst volume
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE dyn_spg_ts( kt )       ! Empty routine
+      WRITE(*,*) 'dyn_spg_ts: You should not have seen this print! error?', kt
+   END SUBROUTINE dyn_spg_ts
+   SUBROUTINE ts_rst( kt, cdrw )     ! Empty routine
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      WRITE(*,*) 'ts_rst    : You should not have seen this print! error?', kt, cdrw
+   END SUBROUTINE ts_rst    
+#endif
+   
+   !!======================================================================
+END MODULE dynspg_ts
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 1844)
@@ -0,0 +1,705 @@
+MODULE dynvor
+   !!======================================================================
+   !!                       ***  MODULE  dynvor  ***
+   !! Ocean dynamics: Update the momentum trend with the relative and
+   !!                 planetary vorticity trends
+   !!======================================================================
+   !! History :  OPA  !  1989-12  (P. Andrich)  vor_ens: Original code
+   !!            5.0  !  1991-11  (G. Madec) vor_ene, vor_mix: Original code
+   !!            6.0  !  1996-01  (G. Madec)  s-coord, suppress work arrays
+   !!            8.5  !  2002-08  (G. Madec)  F90: Free form and module
+   !!   NEMO     1.0  !  2004-02  (G. Madec)  vor_een: Original code
+   !!             -   !  2003-08  (G. Madec)  add vor_ctl
+   !!             -   !  2005-11  (G. Madec)  add dyn_vor (new step architecture)
+   !!            2.0  !  2006-11  (G. Madec)  flux form advection: add metric term
+   !!            3.2  !  2009-04  (R. Benshila)  vvl: correction of een scheme
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_vor     : Update the momentum trend with the vorticity trend
+   !!       vor_ens : enstrophy conserving scheme       (ln_dynvor_ens=T)
+   !!       vor_ene : energy conserving scheme          (ln_dynvor_ene=T)
+   !!       vor_mix : mixed enstrophy/energy conserving (ln_dynvor_mix=T)
+   !!       vor_een : energy and enstrophy conserving   (ln_dynvor_een=T)
+   !!       vor_ctl : set and control of the different vorticity option
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE dynadv         ! momentum advection (use ln_dynadv_vec value)
+   USE trdmod         ! ocean dynamics trends 
+   USE trdmod_oce     ! ocean variables trends
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_vor   ! routine called by step.F90
+
+   !                                             !!* Namelist namdyn_vor: vorticity term
+   LOGICAL, PUBLIC ::   ln_dynvor_ene = .FALSE.   !: energy conserving scheme
+   LOGICAL, PUBLIC ::   ln_dynvor_ens = .TRUE.    !: enstrophy conserving scheme
+   LOGICAL, PUBLIC ::   ln_dynvor_mix = .FALSE.   !: mixed scheme
+   LOGICAL, PUBLIC ::   ln_dynvor_een = .FALSE.   !: energy and enstrophy conserving scheme
+
+   INTEGER ::   nvor = 0   ! type of vorticity trend used
+   INTEGER ::   ncor = 1   ! coriolis
+   INTEGER ::   nrvm = 2   ! =2 relative vorticity ; =3 metric term
+   INTEGER ::   ntot = 4   ! =4 total vorticity (relative + planetary) ; =5 coriolis + metric term
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3,2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_vor( kt )
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose :   compute the lateral ocean tracer physics.
+      !!
+      !! ** Action : - Update (ua,va) with the now vorticity term trend
+      !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
+      !!               and planetary vorticity trends) ('key_trddyn')
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdu => ta   ! use ta as 3D workspace
+      USE oce, ONLY :   ztrdv => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL vor_ctl          ! initialisation & control of options
+
+      !                                          ! vorticity term 
+      SELECT CASE ( nvor )                       ! compute the vorticity trend and add it to the general trend
+      !
+      CASE ( -1 )                                      ! esopa: test all possibility with control print
+         CALL vor_ene( kt, ntot, ua, va )
+         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor0 - Ua: ', mask1=umask, &
+            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+         CALL vor_ens( kt, ntot, ua, va )
+         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor1 - Ua: ', mask1=umask, &
+            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+         CALL vor_mix( kt )
+         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor2 - Ua: ', mask1=umask, &
+            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+         CALL vor_een( kt, ntot, ua, va )
+         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor3 - Ua: ', mask1=umask, &
+            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+         !
+      CASE ( 0 )                                       ! energy conserving scheme
+         IF( l_trddyn )   THEN
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ene( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ene( kt, ncor, ua, va )                ! planetary vorticity trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+         ELSE
+            CALL vor_ene( kt, ntot, ua, va )                ! total vorticity
+         ENDIF
+         !
+      CASE ( 1 )                                       ! enstrophy conserving scheme
+         IF( l_trddyn )   THEN    
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ens( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ens( kt, ncor, ua, va )                ! planetary vorticity trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+         ELSE
+            CALL vor_ens( kt, ntot, ua, va )                ! total vorticity
+         ENDIF
+         !
+      CASE ( 2 )                                       ! mixed ene-ens scheme
+         IF( l_trddyn )   THEN
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ens( kt, nrvm, ua, va )                ! relative vorticity or metric trend (ens)
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ene( kt, ncor, ua, va )                ! planetary vorticity trend (ene)
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+         ELSE
+            CALL vor_mix( kt )                               ! total vorticity (mix=ens-ene)
+         ENDIF
+         !
+      CASE ( 3 )                                       ! energy and enstrophy conserving scheme
+         IF( l_trddyn )   THEN
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_een( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_een( kt, ncor, ua, va )                ! planetary vorticity trend
+            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
+            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+         ELSE
+            CALL vor_een( kt, ntot, ua, va )                ! total vorticity
+         ENDIF
+         !
+      END SELECT
+
+      !                       ! print sum trends (used for debugging)
+      IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' vor  - Ua: ', mask1=umask, &
+         &                     tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_vor
+
+
+   SUBROUTINE vor_ene( kt, kvor, pua, pva )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE vor_ene  ***
+      !!
+      !! ** Purpose :   Compute the now total vorticity trend and add it to 
+      !!      the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time) 
+      !!      and the Sadourny (1975) flux form formulation : conserves the
+      !!      horizontal kinetic energy.
+      !!      The trend of the vorticity term is given by:
+      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
+      !!          voru = 1/e1u  mj-1[ (rotn+f)/e3f  mi(e1v*e3v vn) ]
+      !!          vorv = 1/e2v  mi-1[ (rotn+f)/e3f  mj(e2u*e3u un) ]
+      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
+      !!          voru = 1/e1u  mj-1[ (rotn+f)  mi(e1v vn) ]
+      !!          vorv = 1/e2v  mi-1[ (rotn+f)  mj(e2u un) ]
+      !!      Add this trend to the general momentum trend (ua,va):
+      !!          (ua,va) = (ua,va) + ( voru , vorv )
+      !!
+      !! ** Action : - Update (ua,va) with the now vorticity term trend
+      !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
+      !!               and planetary vorticity trends) ('key_trddyn')
+      !!
+      !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
+      INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
+      !                                                           ! =nrvm (relative vorticity or metric)
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pua    ! total u-trend
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
+      !!
+      INTEGER  ::   ji, jj, jk         ! dummy loop indices
+      REAL(wp) ::   zx1, zy1, zfact2   ! temporary scalars
+      REAL(wp) ::   zx2, zy2           !    "         "
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwx, zwy, zwz   ! temporary 2D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:vor_ene : vorticity term: energy conserving scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      zfact2 = 0.5 * 0.5      ! Local constant initialization
+
+!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !
+         ! Potential vorticity and horizontal fluxes
+         ! -----------------------------------------
+         SELECT CASE( kvor )      ! vorticity considered
+         CASE ( 1 )   ;   zwz(:,:) =                  ff(:,:)      ! planetary vorticity (Coriolis)
+         CASE ( 2 )   ;   zwz(:,:) =   rotn(:,:,jk)                ! relative  vorticity
+         CASE ( 3 )                                                ! metric term
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
+               END DO
+            END DO
+         CASE ( 4 )   ;   zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) )    ! total (relative + planetary vorticity)
+         CASE ( 5 )                                                ! total (coriolis + metric)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
+                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                               &
+                       &       )
+               END DO
+            END DO
+         END SELECT
+
+         IF( ln_sco ) THEN
+            zwz(:,:) = zwz(:,:) / fse3f(:,:,jk)
+            zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         ELSE
+            zwx(:,:) = e2u(:,:) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * vn(:,:,jk)
+         ENDIF
+
+         ! Compute and add the vorticity term trend
+         ! ----------------------------------------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 = zwy(ji,jj-1) + zwy(ji+1,jj-1)
+               zy2 = zwy(ji,jj  ) + zwy(ji+1,jj  )
+               zx1 = zwx(ji-1,jj) + zwx(ji-1,jj+1)
+               zx2 = zwx(ji  ,jj) + zwx(ji  ,jj+1)
+               pua(ji,jj,jk) = pua(ji,jj,jk) + zfact2 / e1u(ji,jj) * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
+               pva(ji,jj,jk) = pva(ji,jj,jk) - zfact2 / e2v(ji,jj) * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 ) 
+            END DO  
+         END DO  
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE vor_ene
+
+
+   SUBROUTINE vor_mix( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE vor_mix  ***
+      !!
+      !! ** Purpose :   Compute the now total vorticity trend and add it to
+      !!      the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time)
+      !!      Mixte formulation : conserves the potential enstrophy of a hori-
+      !!      zontally non-divergent flow for (rotzu x uh), the relative vor-
+      !!      ticity term and the horizontal kinetic energy for (f x uh), the
+      !!      coriolis term. the now trend of the vorticity term is given by:
+      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
+      !!          voru = 1/e1u  mj-1(rotn/e3f) mj-1[ mi(e1v*e3v vn) ]
+      !!              +1/e1u  mj-1[ f/e3f          mi(e1v*e3v vn) ]
+      !!          vorv = 1/e2v  mi-1(rotn/e3f) mi-1[ mj(e2u*e3u un) ]
+      !!              +1/e2v  mi-1[ f/e3f          mj(e2u*e3u un) ]
+      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
+      !!          voru = 1/e1u  mj-1(rotn) mj-1[ mi(e1v vn) ]
+      !!              +1/e1u  mj-1[ f          mi(e1v vn) ]
+      !!          vorv = 1/e2v  mi-1(rotn) mi-1[ mj(e2u un) ]
+      !!              +1/e2v  mi-1[ f          mj(e2u un) ]
+      !!      Add this now trend to the general momentum trend (ua,va):
+      !!          (ua,va) = (ua,va) + ( voru , vorv )
+      !!
+      !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
+      !!             - Save the trends in (ztrdu,ztrdv) in 2 parts (relative
+      !!               and planetary vorticity trends) ('key_trddyn')
+      !!
+      !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean timestep index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zfact1, zua, zcua, zx1, zy1   ! temporary scalars
+      REAL(wp) ::   zfact2, zva, zcva, zx2, zy2   !    "         "
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwx, zwy, zwz, zww   ! temporary 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:vor_mix : vorticity term: mixed energy/enstrophy conserving scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      zfact1 = 0.5 * 0.25      ! Local constant initialization
+      zfact2 = 0.5 * 0.5
+
+!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, zww )
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !
+         ! Relative and planetary potential vorticity and horizontal fluxes
+         ! ----------------------------------------------------------------
+         IF( ln_sco ) THEN        
+            IF( ln_dynadv_vec ) THEN
+               zww(:,:) = rotn(:,:,jk) / fse3f(:,:,jk)
+            ELSE                       
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zww(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                        &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                        &       * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) * fse3f(ji,jj,jk) )
+                  END DO
+               END DO
+            ENDIF
+            zwz(:,:) = ff  (:,:)    / fse3f(:,:,jk)
+            zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         ELSE
+            IF( ln_dynadv_vec ) THEN
+               zww(:,:) = rotn(:,:,jk)
+            ELSE                       
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zww(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                        &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                        &       * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) )
+                  END DO
+               END DO
+            ENDIF
+            zwz(:,:) = ff (:,:)
+            zwx(:,:) = e2u(:,:) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * vn(:,:,jk)
+         ENDIF
+
+         ! Compute and add the vorticity term trend
+         ! ----------------------------------------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
+               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
+               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+               ! enstrophy conserving formulation for relative vorticity term
+               zua = zfact1 * ( zww(ji  ,jj-1) + zww(ji,jj) ) * ( zy1 + zy2 )
+               zva =-zfact1 * ( zww(ji-1,jj  ) + zww(ji,jj) ) * ( zx1 + zx2 )
+               ! energy conserving formulation for planetary vorticity term
+               zcua = zfact2 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
+               zcva =-zfact2 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
+               ! mixed vorticity trend added to the momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zcua + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zcva + zva
+            END DO  
+         END DO  
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE vor_mix
+
+
+   SUBROUTINE vor_ens( kt, kvor, pua, pva )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE vor_ens  ***
+      !!
+      !! ** Purpose :   Compute the now total vorticity trend and add it to
+      !!      the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time)
+      !!      and the Sadourny (1975) flux FORM formulation : conserves the
+      !!      potential enstrophy of a horizontally non-divergent flow. the
+      !!      trend of the vorticity term is given by:
+      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivative:
+      !!          voru = 1/e1u  mj-1[ (rotn+f)/e3f ]  mj-1[ mi(e1v*e3v vn) ]
+      !!          vorv = 1/e2v  mi-1[ (rotn+f)/e3f ]  mi-1[ mj(e2u*e3u un) ]
+      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
+      !!          voru = 1/e1u  mj-1[ rotn+f ]  mj-1[ mi(e1v vn) ]
+      !!          vorv = 1/e2v  mi-1[ rotn+f ]  mi-1[ mj(e2u un) ]
+      !!      Add this trend to the general momentum trend (ua,va):
+      !!          (ua,va) = (ua,va) + ( voru , vorv )
+      !!
+      !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
+      !!             - Save the trends in (ztrdu,ztrdv) in 2 parts (relative 
+      !!               and planetary vorticity trends) ('key_trddyn')
+      !!
+      !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
+      INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
+         !                                                        ! =nrvm (relative vorticity or metric)
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pua    ! total u-trend
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   zfact1, zuav, zvau   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwx, zwy, zwz   ! temporary 3D workspace
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:vor_ens : vorticity term: enstrophy conserving scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      zfact1 = 0.5 * 0.25      ! Local constant initialization
+
+!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !
+         ! Potential vorticity and horizontal fluxes
+         ! -----------------------------------------
+         SELECT CASE( kvor )      ! vorticity considered
+         CASE ( 1 )   ;   zwz(:,:) =                  ff(:,:)      ! planetary vorticity (Coriolis)
+         CASE ( 2 )   ;   zwz(:,:) =   rotn(:,:,jk)                ! relative  vorticity
+         CASE ( 3 )                                                ! metric term
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
+               END DO
+            END DO
+         CASE ( 4 )   ;   zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) )    ! total (relative + planetary vorticity)
+         CASE ( 5 )                                                ! total (coriolis + metric)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
+                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                                &
+                       &       )
+               END DO
+            END DO
+         END SELECT
+         !
+         IF( ln_sco ) THEN
+            DO jj = 1, jpj                      ! caution: don't use (:,:) for this loop 
+               DO ji = 1, jpi                   ! it causes optimization problems on NEC in auto-tasking
+                  zwz(ji,jj) = zwz(ji,jj) / fse3f(ji,jj,jk)
+                  zwx(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) * un(ji,jj,jk)
+                  zwy(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) * vn(ji,jj,jk)
+               END DO
+            END DO
+         ELSE
+            DO jj = 1, jpj                      ! caution: don't use (:,:) for this loop 
+               DO ji = 1, jpi                   ! it causes optimization problems on NEC in auto-tasking
+                  zwx(ji,jj) = e2u(ji,jj) * un(ji,jj,jk)
+                  zwy(ji,jj) = e1v(ji,jj) * vn(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+         !
+         ! Compute and add the vorticity term trend
+         ! ----------------------------------------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zuav = zfact1 / e1u(ji,jj) * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1)   &
+                  &                         + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) )
+               zvau =-zfact1 / e2v(ji,jj) * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1)   &
+                  &                         + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) )
+               pua(ji,jj,jk) = pua(ji,jj,jk) + zuav * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
+               pva(ji,jj,jk) = pva(ji,jj,jk) + zvau * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
+            END DO  
+         END DO  
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE vor_ens
+
+
+   SUBROUTINE vor_een( kt, kvor, pua, pva )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE vor_een  ***
+      !!
+      !! ** Purpose :   Compute the now total vorticity trend and add it to 
+      !!      the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time) 
+      !!      and the Arakawa and Lamb (1980) flux form formulation : conserves 
+      !!      both the horizontal kinetic energy and the potential enstrophy
+      !!      when horizontal divergence is zero (see the NEMO documentation)
+      !!      Add this trend to the general momentum trend (ua,va).
+      !!
+      !! ** Action : - Update (ua,va) with the now vorticity term trend
+      !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
+      !!               and planetary vorticity trends) ('key_trddyn')
+      !!
+      !! References : Arakawa and Lamb 1980, Mon. Wea. Rev., 109, 18-36
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
+      INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
+      !                                                           ! =nrvm (relative vorticity or metric)
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pua    ! total u-trend
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
+      !!
+      INTEGER  ::   ji, jj, jk         ! dummy loop indices
+      REAL(wp) ::   zfac12, zua, zva   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwx, zwy, zwz            ! temporary 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztnw, ztne, ztsw, ztse   ! temporary 3D workspace
+#if defined key_vvl
+      REAL(wp), DIMENSION(jpi,jpj,jpk)       ::   ze3f
+#else
+      REAL(wp), DIMENSION(jpi,jpj,jpk), SAVE ::   ze3f
+#endif
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn:vor_een : vorticity term: energy and enstrophy conserving scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      IF( kt == nit000 .OR. lk_vvl ) THEN      ! reciprocal of e3 at F-point (masked averaging of e3t)
+         DO jk = 1, jpk
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  ze3f(ji,jj,jk) = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
+                     &             + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) ) * 0.25
+                  IF( ze3f(ji,jj,jk) /= 0.e0 )   ze3f(ji,jj,jk) = 1.e0 / ze3f(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( ze3f, 'F', 1. )
+      ENDIF
+
+      zfac12 = 1.e0 / 12.e0      ! Local constant initialization
+
+      
+!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, ztnw, ztne, ztsw, ztse )
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         
+         ! Potential vorticity and horizontal fluxes
+         ! -----------------------------------------
+         SELECT CASE( kvor )      ! vorticity considered
+         CASE ( 1 )                                                ! planetary vorticity (Coriolis)
+            zwz(:,:) = ff(:,:)      * ze3f(:,:,jk)
+         CASE ( 2 )                                                ! relative  vorticity
+            zwz(:,:) = rotn(:,:,jk) * ze3f(:,:,jk)
+         CASE ( 3 )                                                ! metric term
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) * ze3f(ji,jj,jk)
+               END DO
+            END DO
+            CALL lbc_lnk( zwz, 'F', 1. )
+        CASE ( 4 )                                                ! total (relative + planetary vorticity)
+            zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) ) * ze3f(:,:,jk)
+         CASE ( 5 )                                                ! total (coriolis + metric)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
+                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                                &
+                       &       ) * ze3f(ji,jj,jk)
+               END DO
+            END DO
+            CALL lbc_lnk( zwz, 'F', 1. )
+         END SELECT
+
+         zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+
+         ! Compute and add the vorticity term trend
+         ! ----------------------------------------
+         jj = 2
+         ztne(1,:) = 0   ;   ztnw(1,:) = 0   ;   ztse(1,:) = 0   ;   ztsw(1,:) = 0
+         DO ji = 2, jpi   
+               ztne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
+               ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
+               ztse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
+               ztsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+         END DO
+         DO jj = 3, jpj
+            DO ji = fs_2, jpi   ! vector opt. ok because we start at jj = 3
+               ztne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
+               ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
+               ztse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
+               ztsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zua = + zfac12 / e1u(ji,jj) * (  ztne(ji,jj  ) * zwy(ji  ,jj  ) + ztnw(ji+1,jj) * zwy(ji+1,jj  )   &
+                  &                           + ztse(ji,jj  ) * zwy(ji  ,jj-1) + ztsw(ji+1,jj) * zwy(ji+1,jj-1) )
+               zva = - zfac12 / e2v(ji,jj) * (  ztsw(ji,jj+1) * zwx(ji-1,jj+1) + ztse(ji,jj+1) * zwx(ji  ,jj+1)   &
+                  &                           + ztnw(ji,jj  ) * zwx(ji-1,jj  ) + ztne(ji,jj  ) * zwx(ji  ,jj  ) )
+               pua(ji,jj,jk) = pua(ji,jj,jk) + zua
+               pva(ji,jj,jk) = pva(ji,jj,jk) + zva
+            END DO  
+         END DO  
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE vor_een
+
+
+   SUBROUTINE vor_ctl
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE vor_ctl  ***
+      !!
+      !! ** Purpose :   Control the consistency between cpp options for
+      !!              tracer advection schemes
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio          ! temporary integer
+      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               ! Read Namelist namdyn_vor : Vorticity scheme options
+      READ   ( numnam, namdyn_vor )
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn:vor_ctl : vorticity term : read namelist and control the consistency'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '        Namelist namdyn_vor : oice of the vorticity term scheme'
+         WRITE(numout,*) '           energy    conserving scheme                ln_dynvor_ene = ', ln_dynvor_ene
+         WRITE(numout,*) '           enstrophy conserving scheme                ln_dynvor_ens = ', ln_dynvor_ens
+         WRITE(numout,*) '           mixed enstrophy/energy conserving scheme   ln_dynvor_mix = ', ln_dynvor_mix
+         WRITE(numout,*) '           enstrophy and energy conserving scheme     ln_dynvor_een = ', ln_dynvor_een
+      ENDIF
+
+      ioptio = 0                     ! Control of vorticity scheme options
+      IF( ln_dynvor_ene )   ioptio = ioptio + 1
+      IF( ln_dynvor_ens )   ioptio = ioptio + 1
+      IF( ln_dynvor_mix )   ioptio = ioptio + 1
+      IF( ln_dynvor_een )   ioptio = ioptio + 1
+      IF( lk_esopa      )   ioptio =          1
+
+      IF( ioptio /= 1 ) CALL ctl_stop( ' use ONE and ONLY one vorticity scheme' )
+
+      !                              ! Set nvor (type of scheme for vorticity)
+      IF( ln_dynvor_ene )   nvor =  0
+      IF( ln_dynvor_ens )   nvor =  1
+      IF( ln_dynvor_mix )   nvor =  2
+      IF( ln_dynvor_een )   nvor =  3
+      IF( lk_esopa      )   nvor = -1
+      
+      !                              ! Set ncor, nrvm, ntot (type of vorticity)
+      IF(lwp) WRITE(numout,*)
+      ncor = 1
+      IF( ln_dynadv_vec ) THEN     
+         IF(lwp) WRITE(numout,*) '         Vector form advection : vorticity = Coriolis + relative vorticity'
+         nrvm = 2
+         ntot = 4
+      ELSE                        
+         IF(lwp) WRITE(numout,*) '         Flux form advection   : vorticity = Coriolis + metric term'
+         nrvm = 3
+         ntot = 5
+      ENDIF
+      
+      IF(lwp) THEN                   ! Print the choice
+         WRITE(numout,*)
+         IF( nvor ==  0 )   WRITE(numout,*) '         vorticity scheme : energy conserving scheme'
+         IF( nvor ==  1 )   WRITE(numout,*) '         vorticity scheme : enstrophy conserving scheme'
+         IF( nvor ==  2 )   WRITE(numout,*) '         vorticity scheme : mixed enstrophy/energy conserving scheme'
+         IF( nvor ==  3 )   WRITE(numout,*) '         vorticity scheme : energy and enstrophy conserving scheme'
+         IF( nvor == -1 )   WRITE(numout,*) '         esopa test: use all lateral physics options'
+      ENDIF
+      !
+   END SUBROUTINE vor_ctl
+
+   !!==============================================================================
+END MODULE dynvor
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzad.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 1844)
@@ -0,0 +1,124 @@
+MODULE dynzad
+   !!======================================================================
+   !!                       ***  MODULE  dynzad  ***
+   !! Ocean dynamics : vertical advection trend
+   !!======================================================================
+   !! History :  6.0  !  91-01  (G. Madec) Original code
+   !!            7.0  !  91-11  (G. Madec)
+   !!            7.5  !  96-01  (G. Madec) statement function for e3
+   !!            8.5  !  02-07  (G. Madec) j-k-i case: Original code
+   !!            8.5  !  02-07  (G. Madec) Free form, F90
+   !!----------------------------------------------------------------------
+   
+   !!----------------------------------------------------------------------
+   !!   dyn_zad       : vertical advection momentum trend
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE trdmod_oce     ! ocean variables trends
+   USE trdmod         ! ocean dynamics trends 
+   USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   dyn_zad   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_zad ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dynzad  ***
+      !! 
+      !! ** Purpose :   Compute the now vertical momentum advection trend and 
+      !!      add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   The now vertical advection of momentum is given by:
+      !!         w dz(u) = ua + 1/(e1u*e2u*e3u) mk+1[ mi(e1t*e2t*wn) dk(un) ]
+      !!         w dz(v) = va + 1/(e1v*e2v*e3v) mk+1[ mj(e1t*e2t*wn) dk(vn) ]
+      !!      Add this trend to the general trend (ua,va):
+      !!         (ua,va) = (ua,va) + w dz(u,v)
+      !!
+      !! ** Action  : - Update (ua,va) with the vert. momentum adv. trends
+      !!              - Save the trends in (ztrdu,ztrdv) ('key_trddyn')
+     !!----------------------------------------------------------------------
+      USE oce, ONLY:   zwuw => ta   ! use ta as 3D workspace
+      USE oce, ONLY:   zwvw => sa   ! use sa as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step inedx
+      !!
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   zua, zva        ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zww            ! 2D  workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdu, ztrdv   ! 3D workspace
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) 'dyn_zad : arakawa advection scheme'
+      ENDIF
+
+      IF( l_trddyn )   THEN         ! Save ua and va trends
+         ztrdu(:,:,:) = ua(:,:,:) 
+         ztrdv(:,:,:) = va(:,:,:) 
+      ENDIF
+      
+      DO jk = 2, jpkm1              ! Vertical momentum advection at level w and u- and v- vertical
+         DO jj = 2, jpj                   ! vertical fluxes 
+            DO ji = fs_2, jpi             ! vector opt.
+               zww(ji,jj) = 0.25 * e1t(ji,jj) * e2t(ji,jj) * wn(ji,jj,jk)
+            END DO
+         END DO
+         DO jj = 2, jpjm1                 ! vertical momentum advection at w-point
+            DO ji = fs_2, fs_jpim1        ! vector opt.
+               zwuw(ji,jj,jk) = ( zww(ji+1,jj  ) + zww(ji,jj) ) * ( un(ji,jj,jk-1)-un(ji,jj,jk) )
+               zwvw(ji,jj,jk) = ( zww(ji  ,jj+1) + zww(ji,jj) ) * ( vn(ji,jj,jk-1)-vn(ji,jj,jk) )
+            END DO  
+         END DO   
+      END DO
+      DO jj = 2, jpjm1              ! Surface and bottom values set to zero
+         DO ji = fs_2, fs_jpim1           ! vector opt.
+            zwuw(ji,jj, 1 ) = 0.e0
+            zwvw(ji,jj, 1 ) = 0.e0
+            zwuw(ji,jj,jpk) = 0.e0
+            zwvw(ji,jj,jpk) = 0.e0
+         END DO  
+      END DO
+
+      DO jk = 1, jpkm1              ! Vertical momentum advection at u- and v-points
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1       ! vector opt.
+               !                         ! vertical momentum advective trends
+               zua = - ( zwuw(ji,jj,jk) + zwuw(ji,jj,jk+1) ) / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
+               zva = - ( zwvw(ji,jj,jk) + zwvw(ji,jj,jk+1) ) / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+               !                         ! add the trends to the general momentum trends
+               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+               va(ji,jj,jk) = va(ji,jj,jk) + zva
+            END DO  
+         END DO  
+      END DO
+
+      IF( l_trddyn ) THEN           ! save the vertical advection trends for diagnostic
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod(ztrdu, ztrdv, jpdyn_trd_zad, 'DYN', kt)
+      ENDIF
+      !                             ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' zad  - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_zad
+
+   !!======================================================================
+END MODULE dynzad
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 1844)
@@ -0,0 +1,136 @@
+MODULE dynzdf
+   !!==============================================================================
+   !!                 ***  MODULE  dynzdf  ***
+   !! Ocean dynamics :  vertical component of the momentum mixing trend
+   !!==============================================================================
+   !! History :  9.0  !  05-11  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_zdf      : Update the momentum trend with the vertical diffusion
+   !!       zdf_ctl  : initializations of the vertical diffusion scheme
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+
+   USE dynzdf_exp      ! vertical diffusion: explicit (dyn_zdf_exp     routine)
+   USE dynzdf_imp      ! vertical diffusion: implicit (dyn_zdf_imp     routine)
+
+   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE trdmod          ! ocean active dynamics and tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_zdf    !  routine called by step.F90
+
+   INTEGER  ::   nzdf = 0              ! type vertical diffusion algorithm used 
+      !                                ! defined from ln_zdf...  namlist logicals)
+
+   REAL(wp) ::   r2dt                  ! time-step, = 2 rdttra
+      !                                ! except at nit000 (=rdttra) if neuler=0
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE dyn_zdf( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_zdf  ***
+      !!
+      !! ** Purpose :   compute the vertical ocean dynamics physics.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdu, ztrdv   ! 3D workspace
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL zdf_ctl          ! initialisation & control of options
+
+      !                                          ! set time step
+      IF( neuler == 0 .AND. kt == nit000    ) THEN   ;   r2dt =      rdt      ! = rdtra (restarting with Euler time stepping)
+      ELSEIF(               kt <= nit000 + 1) THEN   ;   r2dt = 2. * rdt      ! = 2 rdttra (leapfrog)
+      ENDIF
+
+      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+
+      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
+      !
+      CASE ( 0 )   ;   CALL dyn_zdf_exp    ( kt, r2dt )      ! explicit scheme
+      CASE ( 1 )   ;   CALL dyn_zdf_imp    ( kt, r2dt )      ! implicit scheme
+      !
+      CASE ( -1 )                                      ! esopa: test all possibility with control print
+                       CALL dyn_zdf_exp    ( kt, r2dt )
+                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf0 - Ua: ', mask1=umask,               &
+            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+                       CALL dyn_zdf_imp    ( kt, r2dt )
+                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf1 - Ua: ', mask1=umask,               &
+            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      END SELECT
+
+      IF( l_trddyn )   THEN                      ! save the vertical diffusive trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_zdf, 'DYN', kt )
+      ENDIF
+      !                                          ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf  - Ua: ', mask1=umask,               &
+            &                    tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+   END SUBROUTINE dyn_zdf
+
+
+   SUBROUTINE zdf_ctl
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE zdf_ctl  ***
+      !!
+      !! ** Purpose :   initializations of the vertical diffusion scheme
+      !!
+      !! ** Method  :   implicit (euler backward) scheme (default)
+      !!                explicit (time-splitting) scheme if ln_zdfexp=T
+      !!----------------------------------------------------------------------
+      USE zdftke_old
+      USE zdftke
+      USE zdfkpp
+      !!----------------------------------------------------------------------
+
+      ! Choice from ln_zdfexp read in namelist in zdfini
+      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
+      ELSE                   ;   nzdf = 1           ! use implicit scheme
+      ENDIF
+
+      ! Force implicit schemes
+      IF( lk_zdftke_old .OR. lk_zdftke .OR. lk_zdfkpp )   nzdf = 1   ! TKE or KPP physics
+      IF( ln_dynldf_iso                               )   nzdf = 1   ! iso-neutral lateral physics
+      IF( ln_dynldf_hor .AND. ln_sco                  )   nzdf = 1   ! horizontal lateral physics in s-coordinate
+
+      IF( lk_esopa )    nzdf = -1                   ! Esopa key: All schemes used
+
+      IF(lwp) THEN                                  ! Print the choice
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn:zdf_ctl : vertical dynamics physics scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
+         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
+         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
+      ENDIF
+      !
+   END SUBROUTINE zdf_ctl
+
+   !!==============================================================================
+END MODULE dynzdf
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_exp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 1844)
@@ -0,0 +1,128 @@
+MODULE dynzdf_exp
+   !!==============================================================================
+   !!                     ***  MODULE  dynzdf_exp  ***
+   !! Ocean dynamics:  vertical component(s) of the momentum mixing trend
+   !!==============================================================================
+   !! History :      !  90-10  (B. Blanke)  Original code
+   !!                !  97-05  (G. Madec)  vertical component of isopycnal
+   !!           8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_zdf_exp  : update the momentum trend with the vertical diffu-
+   !!                  sion using an explicit time-stepping scheme.
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE zdf_oce         ! ocean vertical physics
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_zdf_exp    ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_zdf_exp( kt, p2dt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_zdf_exp  ***
+      !!                   
+      !! ** Purpose :   Compute the trend due to the vert. momentum diffusion
+      !!
+      !! ** Method  :   Explicit forward time stepping with a time splitting
+      !!      technique. The vertical diffusion of momentum is given by:
+      !!         diffu = dz( avmu dz(u) ) = 1/e3u dk+1( avmu/e3uw dk(ub) )
+      !!      Surface boundary conditions: wind stress input
+      !!      Bottom boundary conditions : bottom stress (cf zdfbfr.F90)
+      !!      Add this trend to the general trend ua :
+      !!         ua = ua + dz( avmu dz(u) )
+      !!
+      !! ** Action : - Update (ua,va) with the vertical diffusive trend
+      !!---------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT( in ) ::   kt                           ! ocean time-step index
+      REAL(wp), INTENT( in ) ::   p2dt                         ! time-step 
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk, jl                              ! dummy loop indices
+      REAL(wp) ::   zrau0r, zlavmr, zua, zva                   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpk) ::   zwx, zwy, zwz, zww     ! temporary workspace arrays
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_zdf_exp : vertical momentum diffusion explicit operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+
+      ! Local constant initialization
+      ! -----------------------------
+      zrau0r = 1. / rau0                                   ! inverse of the reference density
+      zlavmr = 1. / float( nn_zdfexp )                      ! inverse of the number of sub time step
+
+      !                                                ! ===============
+      DO jj = 2, jpjm1                                 !  Vertical slab
+         !                                             ! ===============
+
+         ! Surface boundary condition
+         DO ji = 2, jpim1
+            zwy(ji,1) = utau(ji,jj) * zrau0r
+            zww(ji,1) = vtau(ji,jj) * zrau0r
+         END DO  
+
+         ! Initialization of x, z and contingently trends array
+         DO jk = 1, jpk
+            DO ji = 2, jpim1
+               zwx(ji,jk) = ub(ji,jj,jk)
+               zwz(ji,jk) = vb(ji,jj,jk)
+            END DO  
+         END DO  
+
+         ! Time splitting loop
+         DO jl = 1, nn_zdfexp
+
+            ! First vertical derivative
+            DO jk = 2, jpk
+               DO ji = 2, jpim1
+                  zwy(ji,jk) = avmu(ji,jj,jk) * ( zwx(ji,jk-1) - zwx(ji,jk) ) / fse3uw(ji,jj,jk) 
+                  zww(ji,jk) = avmv(ji,jj,jk) * ( zwz(ji,jk-1) - zwz(ji,jk) ) / fse3vw(ji,jj,jk)
+               END DO  
+            END DO  
+
+            ! Second vertical derivative and trend estimation at kt+l*rdt/nn_zdfexp
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  zua = zlavmr*( zwy(ji,jk) - zwy(ji,jk+1) ) / fse3u(ji,jj,jk)
+                  zva = zlavmr*( zww(ji,jk) - zww(ji,jk+1) ) / fse3v(ji,jj,jk)
+                  ua(ji,jj,jk) = ua(ji,jj,jk) + zua
+                  va(ji,jj,jk) = va(ji,jj,jk) + zva
+
+                  zwx(ji,jk) = zwx(ji,jk) + p2dt*zua*umask(ji,jj,jk)
+                  zwz(ji,jk) = zwz(ji,jk) + p2dt*zva*vmask(ji,jj,jk)
+               END DO  
+            END DO  
+
+         END DO  
+
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE dyn_zdf_exp
+
+   !!==============================================================================
+END MODULE dynzdf_exp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 1844)
@@ -0,0 +1,286 @@
+MODULE dynzdf_imp
+   !!==============================================================================
+   !!                    ***  MODULE  dynzdf_imp  ***
+   !! Ocean dynamics:  vertical component(s) of the momentum mixing trend
+   !!==============================================================================
+   !! History :      !  90-10  (B. Blanke)  Original code
+   !!                !  97-05  (G. Madec)  vertical component of isopycnal
+   !!           8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_zdf_imp  : update the momentum trend with the vertical diffu-
+   !!                  sion using a implicit time-stepping.
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE zdf_oce         ! ocean vertical physics
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC dyn_zdf_imp    ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+
+   SUBROUTINE dyn_zdf_imp( kt, p2dt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_zdf_imp  ***
+      !!                   
+      !! ** Purpose :   Compute the trend due to the vert. momentum diffusion
+      !!      and the surface forcing, and add it to the general trend of 
+      !!      the momentum equations.
+      !!
+      !! ** Method  :   The vertical momentum mixing trend is given by :
+      !!             dz( avmu dz(u) ) = 1/e3u dk+1( avmu/e3uw dk(ua) )
+      !!      backward time stepping
+      !!      Surface boundary conditions: wind stress input
+      !!      Bottom boundary conditions : bottom stress (cf zdfbfr.F)
+      !!      Add this trend to the general trend ua :
+      !!         ua = ua + dz( avmu dz(u) )
+      !!
+      !! ** Action : - Update (ua,va) arrays with the after vertical diffusive
+      !!               mixing trend.
+      !!---------------------------------------------------------------------
+      !! * Modules used
+      USE oce, ONLY :  zwd   => ta,   &                ! use ta as workspace
+                       zws   => sa                     ! use sa as workspace
+
+      !! * Arguments
+      INTEGER , INTENT( in ) ::   kt                   ! ocean time-step index
+      REAL(wp), INTENT( in ) ::  p2dt                  ! vertical profile of tracer time-step
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk                          ! dummy loop indices
+      REAL(wp) ::   zrau0r, z2dtf, zcoef, zzws, zrhs   ! temporary scalars
+      REAL(wp) ::   zzwi                               ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwi        ! temporary workspace arrays
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_zdf_imp : vertical momentum diffusion implicit operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+      zrau0r = 1. / rau0      ! inverse of the reference density
+
+      ! 1. Vertical diffusion on u
+      ! ---------------------------
+      ! Matrix and second member construction
+      ! bottom boundary condition: both zwi and zws must be masked as avmu can take
+      ! non zero value at the ocean bottom depending on the bottom friction
+      ! used but the bottom velocities have already been updated with the bottom
+      ! friction velocity in dyn_bfr using values from the previous timestep. There
+      ! is no need to include these in the implicit calculation.
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcoef = - p2dt / fse3u(ji,jj,jk)
+               zzwi          = zcoef * avmu(ji,jj,jk  ) / fse3uw(ji,jj,jk  )
+               zwi(ji,jj,jk) = zzwi * umask(ji,jj,jk)
+               zzws          = zcoef * avmu(ji,jj,jk+1) / fse3uw(ji,jj,jk+1)
+               zws(ji,jj,jk) = zzws * umask(ji,jj,jk+1)
+               zwd(ji,jj,jk) = 1. - zwi(ji,jj,jk) - zzws
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1 
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zwi(ji,jj,1) = 0.
+            zwd(ji,jj,1) = 1. - zws(ji,jj,1)
+         END DO
+      END DO
+
+      ! Matrix inversion starting from the first level
+      !-----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and a lower triangular matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The solution (the after velocity) is in ua
+      !-----------------------------------------------------------------------
+
+      ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1
+      DO jj = 2, jpjm1   
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+!!! change les resultats (derniers digit, pas significativement + rapide 1* de moins)
+!!!         ua(ji,jj,1) = ub(ji,jj,1)  &
+!!!                      + p2dt * ( ua(ji,jj,1) + utau(ji,jj) / ( fse3u(ji,jj,1)*rau0 ) )
+            z2dtf = p2dt / ( fse3u(ji,jj,1)*rau0 )
+            ua(ji,jj,1) = ub(ji,jj,1)  &
+                         + p2dt *  ua(ji,jj,1) + z2dtf * utau(ji,jj)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zrhs = ub(ji,jj,jk) + p2dt * ua(ji,jj,jk)   ! zrhs=right hand side
+               ua(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * ua(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! thrid recurrence : SOLk = ( Lk - Uk * Ek+1 ) / Dk
+      DO jj = 2, jpjm1   
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ua(ji,jj,jpkm1) = ua(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) =( ua(ji,jj,jk) - zws(ji,jj,jk) * ua(ji,jj,jk+1) ) / zwd(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Normalization to obtain the general momentum trend ua
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) - ub(ji,jj,jk) ) / p2dt
+            END DO
+         END DO
+      END DO
+
+
+      ! 2. Vertical diffusion on v
+      ! ---------------------------
+      ! Matrix and second member construction
+      ! bottom boundary condition: both zwi and zws must be masked as avmv can take
+      ! non zero value at the ocean bottom depending on the bottom friction
+      ! used but the bottom velocities have already been updated with the bottom
+      ! friction velocity in dyn_bfr using values from the previous timestep. There
+      ! is no need to include these in the implicit calculation.
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcoef = -p2dt / fse3v(ji,jj,jk)
+               zzwi          = zcoef * avmv(ji,jj,jk  ) / fse3vw(ji,jj,jk  )
+               zwi(ji,jj,jk) =  zzwi * vmask(ji,jj,jk)
+               zzws       = zcoef * avmv(ji,jj,jk+1) / fse3vw(ji,jj,jk+1)
+               zws(ji,jj,jk) =  zzws * vmask(ji,jj,jk+1)
+               zwd(ji,jj,jk) = 1. - zwi(ji,jj,jk) - zzws
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1   
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zwi(ji,jj,1) = 0.e0
+            zwd(ji,jj,1) = 1. - zws(ji,jj,1)
+         END DO
+      END DO
+
+      ! Matrix inversion
+      !-----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and lower triangular
+      !   matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The solution (after velocity) is in 2d array va
+      !-----------------------------------------------------------------------
+
+      ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+!!! change les resultats (derniers digit, pas significativement + rapide 1* de moins)
+!!!         va(ji,jj,1) = vb(ji,jj,1)  &
+!!!                      + p2dt * ( va(ji,jj,1) + vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 ) )
+            z2dtf = p2dt / ( fse3v(ji,jj,1)*rau0 )
+            va(ji,jj,1) = vb(ji,jj,1)  &
+                         + p2dt * va(ji,jj,1) + z2dtf * vtau(ji,jj)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zrhs = vb(ji,jj,jk) + p2dt * va(ji,jj,jk)   ! zrhs=right hand side
+               va(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * va(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! thrid recurrence : SOLk = ( Lk - Uk * SOLk+1 ) / Dk
+      DO jj = 2, jpjm1   
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            va(ji,jj,jpkm1) = va(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               va(ji,jj,jk) =( va(ji,jj,jk) - zws(ji,jj,jk) * va(ji,jj,jk+1) ) / zwd(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Normalization to obtain the general momentum trend va
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               va(ji,jj,jk) = ( va(ji,jj,jk) - vb(ji,jj,jk) ) / p2dt
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE dyn_zdf_imp
+
+   !!==============================================================================
+END MODULE dynzdf_imp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 1844)
@@ -0,0 +1,282 @@
+MODULE sshwzv   
+   !!==============================================================================
+   !!                       ***  MODULE  sshwzv  ***
+   !! Ocean dynamics : sea surface height and vertical velocity
+   !!==============================================================================
+   !! History :  3.1  !  2009-02  (G. Madec, M. Leclair)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ssh_wzv        : after ssh & now vertical velocity
+   !!   ssh_nxt        : filter ans swap the ssh arrays
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE domvvl          ! Variable volume
+   USE divcur          ! hor. divergence and curl      (div & cur routines)
+   USE cla_div         ! cross land: hor. divergence      (div_cla routine)
+   USE iom             ! I/O library
+   USE restart         ! only for lrst_oce
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+   USE phycst
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE obc_par         ! open boundary cond. parameter
+   USE obc_oce
+   USE diaar5, ONLY :   lk_diaar5
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ssh_wzv    ! called by step.F90
+   PUBLIC   ssh_nxt    ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ssh_wzv( kt ) 
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE ssh_wzv  ***
+      !!                   
+      !! ** Purpose :   compute the after ssh (ssha), the now vertical velocity
+      !!              and update the now vertical coordinate (lk_vvl=T).
+      !!
+      !! ** Method  : -
+      !!
+      !!              - Using the incompressibility hypothesis, the vertical 
+      !!      velocity is computed by integrating the horizontal divergence  
+      !!      from the bottom to the surface minus the scale factor evolution.
+      !!        The boundary conditions are w=0 at the bottom (no flux) and.
+      !!
+      !! ** action  :   ssha    : after sea surface height
+      !!                wn      : now vertical velocity
+      !! if lk_vvl=T:   sshu_a, sshv_a, sshf_a  : after sea surface height
+      !!                          at u-, v-, f-point s
+      !!                hu, hv, hur, hvr : ocean depth and its inverse at u-,v-points
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   z3d => ta   ! use ta as 3D workspace
+      !!
+      INTEGER, INTENT(in) ::   kt   ! time step
+      !!
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   zcoefu, zcoefv, zcoeff      ! temporary scalars
+      REAL(wp) ::   z2dt, zraur     ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zhdiv       ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d         ! 2D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'ssh_wzv : after sea surface height and now vertical velocity '
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+         !
+         wn(:,:,jpk) = 0.e0                   ! bottom boundary condition: w=0 (set once for all)
+         !
+         IF( lk_vvl ) THEN                    ! before and now Sea SSH at u-, v-, f-points (vvl case only)
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1                    ! caution: use of Vector Opt. not possible
+                  zcoefu = 0.5  * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )
+                  zcoefv = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )
+                  zcoeff = 0.25 * umask(ji,jj,1) * umask(ji,jj+1,1)
+                  sshu_b(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshb(ji  ,jj)     &
+                     &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshb(ji+1,jj) )
+                  sshv_b(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshb(ji,jj  )     &
+                     &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshb(ji,jj+1) )
+                  sshf_b(ji,jj) = zcoeff * ( sshb(ji  ,jj) + sshb(ji  ,jj+1)                 &
+                     &                     + sshb(ji+1,jj) + sshb(ji+1,jj+1) )
+                  sshu_n(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshn(ji  ,jj)     &
+                     &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshn(ji+1,jj) )
+                  sshv_n(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshn(ji,jj  )     &
+                     &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshn(ji,jj+1) )
+                  sshf_n(ji,jj) = zcoeff * ( sshn(ji  ,jj) + sshn(ji  ,jj+1)                 &
+                     &                     + sshn(ji+1,jj) + sshn(ji+1,jj+1) )
+               END DO
+            END DO
+            CALL lbc_lnk( sshu_b, 'U', 1. )   ;   CALL lbc_lnk( sshu_n, 'U', 1. )
+            CALL lbc_lnk( sshv_b, 'V', 1. )   ;   CALL lbc_lnk( sshv_n, 'V', 1. )
+            CALL lbc_lnk( sshf_b, 'F', 1. )   ;   CALL lbc_lnk( sshf_n, 'F', 1. )
+         ENDIF
+         !
+      ENDIF
+
+      !                                           !------------------------------!
+      IF( lk_vvl ) THEN                           !  Update Now Vertical coord.  !   (only in vvl case)
+      !                                           !------------------------------!
+         DO jk = 1, jpkm1
+            fsdept(:,:,jk) = fsdept_n(:,:,jk)          ! now local depths stored in fsdep. arrays
+            fsdepw(:,:,jk) = fsdepw_n(:,:,jk)
+            fsde3w(:,:,jk) = fsde3w_n(:,:,jk)
+            !
+            fse3t (:,:,jk) = fse3t_n (:,:,jk)          ! vertical scale factors stored in fse3. arrays
+            fse3u (:,:,jk) = fse3u_n (:,:,jk)
+            fse3v (:,:,jk) = fse3v_n (:,:,jk)
+            fse3f (:,:,jk) = fse3f_n (:,:,jk)
+            fse3w (:,:,jk) = fse3w_n (:,:,jk)
+            fse3uw(:,:,jk) = fse3uw_n(:,:,jk)
+            fse3vw(:,:,jk) = fse3vw_n(:,:,jk)
+         END DO
+         !                                             ! now ocean depth (at u- and v-points)
+         hu(:,:) = hu_0(:,:) + sshu_n(:,:)
+         hv(:,:) = hv_0(:,:) + sshv_n(:,:)
+         !                                             ! now masked inverse of the ocean depth (at u- and v-points)
+         hur(:,:) = umask(:,:,1) / ( hu(:,:) + 1.e0 - umask(:,:,1) )
+         hvr(:,:) = vmask(:,:,1) / ( hv(:,:) + 1.e0 - vmask(:,:,1) )
+         !
+      ENDIF
+
+                         CALL div_cur( kt )            ! Horizontal divergence & Relative vorticity
+      IF( n_cla == 1 )   CALL div_cla( kt )            ! Cross Land Advection (Update Hor. divergence)
+
+      ! set time step size (Euler/Leapfrog)
+      z2dt = 2. * rdt 
+      IF( neuler == 0 .AND. kt == nit000 )   z2dt =rdt
+
+      zraur = 1. / rau0
+
+      !                                           !------------------------------!
+      !                                           !   After Sea Surface Height   !
+      !                                           !------------------------------!
+      zhdiv(:,:) = 0.e0
+      DO jk = 1, jpkm1                                 ! Horizontal divergence of barotropic transports
+        zhdiv(:,:) = zhdiv(:,:) + fse3t(:,:,jk) * hdivn(:,:,jk)
+      END DO
+
+      !                                                ! Sea surface elevation time stepping
+      ssha(:,:) = (  sshb(:,:) - z2dt * ( zraur * emp(:,:) + zhdiv(:,:) )  ) * tmask(:,:,1)
+
+#if defined key_obc
+      IF ( Agrif_Root() ) THEN 
+         ssha(:,:) = ssha(:,:) * obctmsk(:,:)
+         CALL lbc_lnk( ssha, 'T', 1. )  ! absolutly compulsory !! (jmm)
+      ENDIF
+#endif
+
+      !                                                ! Sea Surface Height at u-,v- and f-points (vvl case only)
+      IF( lk_vvl ) THEN                                ! (required only in key_vvl case)
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1      ! NO Vector Opt.
+               sshu_a(ji,jj) = 0.5  * umask(ji,jj,1) / ( e1u(ji  ,jj) * e2u(ji  ,jj) )                   &
+                  &                                  * ( e1t(ji  ,jj) * e2t(ji  ,jj) * ssha(ji  ,jj)     &
+                  &                                    + e1t(ji+1,jj) * e2t(ji+1,jj) * ssha(ji+1,jj) )
+               sshv_a(ji,jj) = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj  ) * e2v(ji,jj  ) )                   &
+                  &                                  * ( e1t(ji,jj  ) * e2t(ji,jj  ) * ssha(ji,jj  )     &
+                  &                                    + e1t(ji,jj+1) * e2t(ji,jj+1) * ssha(ji,jj+1) )
+               sshf_a(ji,jj) = 0.25 * umask(ji,jj,1) * umask (ji,jj+1,1)                                 & 
+                  &                                  * ( ssha(ji  ,jj) + ssha(ji  ,jj+1)                 &
+                  &                                    + ssha(ji+1,jj) + ssha(ji+1,jj+1) )
+            END DO
+         END DO
+         CALL lbc_lnk( sshu_a, 'U', 1. )               ! Boundaries conditions
+         CALL lbc_lnk( sshv_a, 'V', 1. )
+         CALL lbc_lnk( sshf_a, 'F', 1. )
+      ENDIF
+
+      !                                           !------------------------------!
+      !                                           !     Now Vertical Velocity    !
+      !                                           !------------------------------!
+      !                                                ! integrate from the bottom the hor. divergence
+      DO jk = jpkm1, 1, -1
+         wn(:,:,jk) = wn(:,:,jk+1) -    fse3t_n(:,:,jk) * hdivn(:,:,jk)   &
+              &                    - (  fse3t_a(:,:,jk)                   &
+              &                       - fse3t_b(:,:,jk) ) * tmask(:,:,jk) / z2dt
+      END DO
+      !
+      CALL iom_put( "woce", wn                    )   ! vertical velocity
+      CALL iom_put( "ssh" , sshn                  )   ! sea surface height
+      CALL iom_put( "ssh2", sshn(:,:) * sshn(:,:) )   ! square of sea surface height
+      IF( lk_diaar5 ) THEN
+         z2d(:,:) = rau0 * e1t(:,:) * e2t(:,:)
+         DO jk = 1, jpk
+            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
+         END DO
+         CALL iom_put( "w_masstr" , z3d                     )   !           vertical mass transport
+         CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )   ! square of vertical mass transport
+      ENDIF
+      !
+   END SUBROUTINE ssh_wzv
+
+
+   SUBROUTINE ssh_nxt( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE ssh_nxt  ***
+      !!
+      !! ** Purpose :   achieve the sea surface  height time stepping by 
+      !!              applying Asselin time filter and swapping the arrays
+      !!              ssha  already computed in ssh_wzv  
+      !!
+      !! ** Method  : - apply Asselin time fiter to now ssh and swap :
+      !!             sshn = ssha + atfp * ( sshb -2 sshn + ssha )
+      !!             sshn = ssha
+      !!
+      !! ** action  : - sshb, sshn   : before & now sea surface height
+      !!                               ready for the next time step
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj               ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'ssh_nxt : next sea surface height (Asselin time filter + swap)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      ! Time filter and swap of the ssh
+      ! -------------------------------
+
+      IF( lk_vvl ) THEN      ! Variable volume levels :   ssh at t-, u-, v, f-points
+         !                   ! ---------------------- !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler time-stepping at first time-step : no filter
+            sshn  (:,:) = ssha  (:,:)                        ! now <-- after  (before already = now)
+            sshu_n(:,:) = sshu_a(:,:)
+            sshv_n(:,:) = sshv_a(:,:)
+            sshf_n(:,:) = sshf_a(:,:)
+         ELSE                                           ! Leap-Frog time-stepping: Asselin filter + swap
+            DO jj = 1, jpj
+               DO ji = 1, jpi                                ! before <-- now filtered
+                  sshb  (ji,jj) = sshn(ji,jj)   + atfp * ( sshb  (ji,jj) - 2 * sshn  (ji,jj) + ssha  (ji,jj) )
+                  sshu_b(ji,jj) = sshu_n(ji,jj) + atfp * ( sshu_b(ji,jj) - 2 * sshu_n(ji,jj) + sshu_a(ji,jj) )
+                  sshv_b(ji,jj) = sshv_n(ji,jj) + atfp * ( sshv_b(ji,jj) - 2 * sshv_n(ji,jj) + sshv_a(ji,jj) )
+                  sshf_b(ji,jj) = sshf_n(ji,jj) + atfp * ( sshf_b(ji,jj) - 2 * sshf_n(ji,jj) + sshf_a(ji,jj) )
+                  sshn  (ji,jj) = ssha  (ji,jj)              ! now <-- after
+                  sshu_n(ji,jj) = sshu_a(ji,jj)
+                  sshv_n(ji,jj) = sshv_a(ji,jj)
+                  sshf_n(ji,jj) = sshf_a(ji,jj)
+               END DO
+            END DO
+         ENDIF
+         !
+      ELSE                   ! fixed levels :   ssh at t-point only
+         !                   ! ------------ !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler time-stepping at first time-step : no filter
+            sshn(:,:) = ssha(:,:)                            ! now <-- after  (before already = now)
+            !
+         ELSE                                           ! Leap-Frog time-stepping: Asselin filter + swap
+            DO jj = 1, jpj
+               DO ji = 1, jpi                                ! before <-- now filtered
+                  sshb(ji,jj) = sshn(ji,jj) + atfp * ( sshb(ji,jj) - 2 * sshn(ji,jj) + ssha(ji,jj) )    
+                  sshn(ji,jj) = ssha(ji,jj)                  ! now <-- after
+               END DO
+            END DO
+         ENDIF
+         !
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl(tab2d_1=sshb    , clinfo1=' sshb  - : ', mask1=tmask, ovlap=1 )
+      !
+   END SUBROUTINE ssh_nxt
+
+   !!======================================================================
+END MODULE sshwzv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo4rk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo4rk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo4rk.F90	(revision 1844)
@@ -0,0 +1,502 @@
+MODULE flo4rk
+   !!======================================================================
+   !!                    ***  MODULE  flo4rk  ***
+   !! Ocean floats :   trajectory computation using a 4th order Runge-Kutta
+   !!======================================================================
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                     float trajectories
+   !!----------------------------------------------------------------------
+   !!   flo_4rk        : Compute the geographical position of floats
+   !!   flo_interp     : interpolation
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE flo_oce         ! ocean drifting floats
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC flo_4rk      ! routine called by floats.F90
+
+   !! * Module variables
+   REAL(wp), DIMENSION (4) ::   &   ! RK4 and Lagrange interpolation
+      tcoef1 = (/  1.0  ,  0.5  ,  0.5  ,  0.0  /) ,  &  ! coeffients  for 
+      tcoef2 = (/  0.0  ,  0.5  ,  0.5  ,  1.0  /) ,  &  ! lagrangian interp.
+      scoef2 = (/  1.0  ,  2.0  ,  2.0  ,  1.0  /) ,  &  ! RK4 coefficients
+      rcoef  = (/-1./6. , 1./2. ,-1./2. , 1./6. /)       ! ???
+   REAL(wp), DIMENSION (3) ::   &
+      scoef1 = (/ .5, .5, 1. /)       ! compute position with interpolated
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flo_4rk( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE flo_4rk  ***
+      !!
+      !!  ** Purpose :   Compute the geographical position (lat,lon,depth)
+      !!       of each float at each time step.
+      !! 
+      !!  ** Method  :   The position of a float is computed with a 4th order
+      !!       Runge-Kutta scheme and and Lagrange interpolation.
+      !!         We need to know the velocity field, the old positions of the
+      !!       floats and the grid defined on the domain.
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::  jfl, jind           ! dummy loop indices
+      REAL(wp), DIMENSION ( jpnfl)  ::   &
+         zgifl, zgjfl, zgkfl,   &     ! index RK  positions
+         zufl, zvfl, zwfl             ! interpolated velocity at the
+      ! float position 
+      REAL(wp), DIMENSION ( jpnfl, 4 )  ::    &
+         zrkxfl, zrkyfl, zrkzfl       ! RK coefficients
+      !!---------------------------------------------------------------------
+    
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'flo_4rk : compute Runge Kutta trajectories for floats '
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Verification of the floats positions. If one of them leave the domain
+      ! domain we replace the float near the border.
+      DO jfl = 1, jpnfl
+         ! i-direction
+         IF( tpifl(jfl) <= 1.5 ) THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the WEST border.'
+            tpifl(jfl) = tpifl(jfl) + 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at i=',tpifl(jfl)
+         ENDIF
+          
+         IF( tpifl(jfl) >= jpi-.5 ) THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the EAST border.'
+            tpifl(jfl) = tpifl(jfl) - 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at i=', tpifl(jfl)
+         ENDIF
+         ! j-direction
+         IF( tpjfl(jfl) <= 1.5 ) THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the SOUTH border.'
+            tpjfl(jfl) = tpjfl(jfl) + 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at j=', tpjfl(jfl)
+         ENDIF
+           
+         IF( tpjfl(jfl) >= jpj-.5 ) THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the NORTH border.'
+            tpjfl(jfl) = tpjfl(jfl) - 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at j=', tpjfl(jfl)
+         ENDIF
+         ! k-direction
+         IF( tpkfl(jfl) <= .5 ) THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the TOP border.'
+            tpkfl(jfl) = tpkfl(jfl) + 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at k=', tpkfl(jfl)
+         ENDIF
+         
+         IF( tpkfl(jfl) >= jpk-.5 )  THEN
+            IF(lwp)WRITE(numout,*)'!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!'
+            IF(lwp)WRITE(numout,*)'The float',jfl,'is out of the domain at the BOTTOM border.'
+            tpkfl(jfl) = tpkfl(jfl) - 1.
+            IF(lwp)WRITE(numout,*)'New initialisation for this float at k=', tpkfl(jfl)
+         ENDIF
+      END DO
+      
+      ! 4 steps of Runge-Kutta algorithme
+      ! initialisation of the positions 
+      
+      DO jfl = 1, jpnfl
+         zgifl(jfl) = tpifl(jfl)
+         zgjfl(jfl) = tpjfl(jfl)
+         zgkfl(jfl) = tpkfl(jfl)
+      END DO
+       
+      DO  jind = 1, 4
+         
+         ! for each step we compute the compute the velocity with Lagrange interpolation
+         CALL flo_interp(zgifl,zgjfl,zgkfl,zufl,zvfl,zwfl,jind)
+         
+         ! computation of Runge-Kutta factor
+         
+         DO jfl = 1, jpnfl
+            zrkxfl(jfl,jind) = rdt*zufl(jfl)
+            zrkyfl(jfl,jind) = rdt*zvfl(jfl)
+            zrkzfl(jfl,jind) = rdt*zwfl(jfl)
+         END DO
+         IF( jind /= 4 ) THEN
+            DO jfl = 1, jpnfl
+               zgifl(jfl) = (tpifl(jfl)) + scoef1(jind)*zrkxfl(jfl,jind)
+               zgjfl(jfl) = (tpjfl(jfl)) + scoef1(jind)*zrkyfl(jfl,jind)
+               zgkfl(jfl) = (tpkfl(jfl)) + scoef1(jind)*zrkzfl(jfl,jind)
+            END DO
+         ENDIF
+      END DO
+      DO jind = 1, 4
+         DO jfl = 1, jpnfl
+            tpifl(jfl) = tpifl(jfl) + scoef2(jind)*zrkxfl(jfl,jind)/6.
+            tpjfl(jfl) = tpjfl(jfl) + scoef2(jind)*zrkyfl(jfl,jind)/6.
+            tpkfl(jfl) = tpkfl(jfl) + scoef2(jind)*zrkzfl(jfl,jind)/6.
+         END DO
+      END DO
+
+   END SUBROUTINE flo_4rk
+
+
+   SUBROUTINE flo_interp( pxt , pyt , pzt ,      &
+      &                   pufl, pvfl, pwfl, kind )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE flointerp  ***
+      !!
+      !! ** Purpose :   Interpolation of the velocity on the float position
+      !! 
+      !! ** Method  :   Lagrange interpolation with the 64 neighboring
+      !!      points. This routine is call 4 time at each time step to
+      !!      compute velocity at the date and the position we need to
+      !!      integrated with RK method.
+      !!
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   &
+         kind,   &
+         jfl, jind1, jind2, jind3,   &
+         zsumu, zsumv, zsumw
+      INTEGER , DIMENSION  ( jpnfl  ) ::   &
+         iilu, ijlu, iklu,     &           ! nearest neighbour INDEX-u
+         iilv, ijlv, iklv,     &           ! nearest neighbour INDEX-v
+         iilw, ijlw, iklw                  ! nearest neighbour INDEX-w
+      INTEGER , DIMENSION  ( jpnfl, 4  ) ::   &
+         iidu, ijdu, ikdu,    &            ! 64 nearest neighbour INDEX-u
+         iidv, ijdv, ikdv,    &            ! 64 nearest neighbour INDEX-v
+         iidw, ijdw, ikdw                  ! 64 nearest neighbour INDEX-w
+      REAL(wp) , DIMENSION  ( jpnfl  ) ::   &
+         pxt , pyt , pzt,     &            ! position of the float
+         pufl, pvfl, pwfl                  ! velocity at this position
+      REAL(wp) , DIMENSION  ( jpnfl, 4, 4, 4 ) ::   &
+         ztufl, ztvfl, ztwfl               ! velocity at choosen time step
+      REAL(wp) , DIMENSION  ( jpnfl, 4 ) ::   &
+         zlagxu, zlagyu, zlagzu,   &       ! Lagrange  coefficients
+         zlagxv, zlagyv, zlagzv,   &
+         zlagxw, zlagyw, zlagzw
+      !!---------------------------------------------------------------------
+      
+      ! Interpolation of U velocity
+
+      ! nearest neightboring point for computation of u       
+      DO jfl = 1, jpnfl
+         iilu(jfl) = INT(pxt(jfl)-.5)
+         ijlu(jfl) = INT(pyt(jfl)-.5)
+         iklu(jfl) = INT(pzt(jfl))
+      END DO
+      
+      !  64 neightboring points for computation of u 
+      DO jind1 = 1, 4
+         DO jfl = 1, jpnfl
+            !  i-direction
+            IF( iilu(jfl) <= 2 ) THEN
+               iidu(jfl,jind1) = jind1
+            ELSE
+               IF( iilu(jfl) >= jpi-1 ) THEN
+                  iidu(jfl,jind1) = jpi + jind1 - 4
+               ELSE
+                  iidu(jfl,jind1) = iilu(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            !  j-direction
+            IF( ijlu(jfl) <= 2 ) THEN
+               ijdu(jfl,jind1) = jind1
+            ELSE
+               IF( ijlu(jfl) >= jpj-1 ) THEN
+                  ijdu(jfl,jind1) = jpj + jind1 - 4
+               ELSE
+                  ijdu(jfl,jind1) = ijlu(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            ! k-direction
+            IF( iklu(jfl) <= 2 ) THEN
+               ikdu(jfl,jind1) = jind1
+            ELSE
+               IF( iklu(jfl) >= jpk-1 ) THEN
+                  ikdu(jfl,jind1) = jpk + jind1 - 4
+               ELSE
+                  ikdu(jfl,jind1) = iklu(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      
+      ! Lagrange coefficients
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            zlagxu(jfl,jind1) = 1.
+            zlagyu(jfl,jind1) = 1.
+            zlagzu(jfl,jind1) = 1.
+         END DO
+      END DO
+      
+      DO jind1 = 1, 4
+         DO jind2 = 1, 4
+            DO jfl= 1, jpnfl
+               IF( jind1 /= jind2 ) THEN
+                  zlagxu(jfl,jind1) = zlagxu(jfl,jind1) * ( pxt(jfl)-(float(iidu(jfl,jind2))+.5) )
+                  zlagyu(jfl,jind1) = zlagyu(jfl,jind1) * ( pyt(jfl)-(float(ijdu(jfl,jind2))) )
+                  zlagzu(jfl,jind1) = zlagzu(jfl,jind1) * ( pzt(jfl)-(float(ikdu(jfl,jind2))) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+      
+      ! velocity when we compute at middle time step
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1, 4
+                  ztufl(jfl,jind1,jind2,jind3) =   &
+                     &   (  tcoef1(kind) * ub(iidu(jfl,jind1),ijdu(jfl,jind2),ikdu(jfl,jind3)) +   &
+                     &      tcoef2(kind) * un(iidu(jfl,jind1),ijdu(jfl,jind2),ikdu(jfl,jind3)) )   &
+                     &      / e1u(iidu(jfl,jind1),ijdu(jfl,jind2)) 
+               END DO
+            END DO
+         END DO
+         
+         zsumu = 0.
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1, 4
+                  zsumu = zsumu + ztufl(jfl,jind1,jind2,jind3) * zlagxu(jfl,jind1) * zlagyu(jfl,jind2)   &
+                     &  * zlagzu(jfl,jind3) * rcoef(jind1)*rcoef(jind2)*rcoef(jind3) 
+               END DO
+            END DO
+         END DO
+         pufl(jfl) = zsumu
+      END DO
+      
+      ! Interpolation of V velocity 
+
+      ! nearest neightboring point for computation of v 
+      DO jfl = 1, jpnfl
+         iilv(jfl) = INT(pxt(jfl)-.5)
+         ijlv(jfl) = INT(pyt(jfl)-.5)
+         iklv(jfl) = INT(pzt(jfl))
+      END DO
+      
+      ! 64 neightboring points for computation of v 
+      DO jind1 = 1, 4
+         DO jfl = 1, jpnfl
+            ! i-direction
+            IF( iilv(jfl) <= 2 ) THEN
+               iidv(jfl,jind1) = jind1
+            ELSE
+               IF( iilv(jfl) >= jpi-1 ) THEN
+                  iidv(jfl,jind1) = jpi + jind1 - 4
+               ELSE
+                  iidv(jfl,jind1) = iilv(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            ! j-direction
+            IF( ijlv(jfl) <= 2 ) THEN
+               ijdv(jfl,jind1) = jind1
+            ELSE
+               IF( ijlv(jfl) >= jpj-1 ) THEN
+                  ijdv(jfl,jind1) = jpj + jind1 - 4
+               ELSE
+                  ijdv(jfl,jind1) = ijlv(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            ! k-direction
+            IF( iklv(jfl) <= 2 ) THEN
+               ikdv(jfl,jind1) = jind1
+            ELSE
+               IF( iklv(jfl) >= jpk-1 ) THEN
+                  ikdv(jfl,jind1) = jpk + jind1 - 4
+               ELSE
+                  ikdv(jfl,jind1) = iklv(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      
+      ! Lagrange coefficients
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            zlagxv(jfl,jind1) = 1.
+            zlagyv(jfl,jind1) = 1.
+            zlagzv(jfl,jind1) = 1.
+         END DO
+      END DO
+      
+      DO jind1 = 1, 4
+         DO jind2 = 1, 4
+            DO jfl = 1, jpnfl
+               IF( jind1 /= jind2 ) THEN
+                  zlagxv(jfl,jind1)= zlagxv(jfl,jind1)*(pxt(jfl) - (float(iidv(jfl,jind2))) )
+                  zlagyv(jfl,jind1)= zlagyv(jfl,jind1)*(pyt(jfl) - (float(ijdv(jfl,jind2))+.5) )
+                  zlagzv(jfl,jind1)= zlagzv(jfl,jind1)*(pzt(jfl) - (float(ikdv(jfl,jind2))) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+      
+      ! velocity when we compute at middle time step
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1 ,4
+                  ztvfl(jfl,jind1,jind2,jind3)=   &
+                     &   ( tcoef1(kind) * vb(iidv(jfl,jind1),ijdv(jfl,jind2),ikdv(jfl,jind3))  +   &
+                     &     tcoef2(kind) * vn(iidv(jfl,jind1),ijdv(jfl,jind2),ikdv(jfl,jind3)) )    & 
+                     &     / e2v(iidv(jfl,jind1),ijdv(jfl,jind2))
+               END DO
+            END DO
+         END DO
+         
+         zsumv=0.
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1, 4
+                  zsumv = zsumv + ztvfl(jfl,jind1,jind2,jind3) * zlagxv(jfl,jind1) * zlagyv(jfl,jind2)   &
+                     &  * zlagzv(jfl,jind3) * rcoef(jind1)*rcoef(jind2)*rcoef(jind3)
+               END DO
+            END DO
+         END DO
+         pvfl(jfl) = zsumv
+      END DO
+      
+      ! Interpolation of W velocity
+
+      ! nearest neightboring point for computation of w 
+      DO jfl = 1, jpnfl
+         iilw(jfl) = INT(pxt(jfl))
+         ijlw(jfl) = INT(pyt(jfl))
+         iklw(jfl) = INT(pzt(jfl)+.5)
+      END DO
+      
+      ! 64 neightboring points for computation of w 
+      DO jind1 = 1, 4
+         DO jfl = 1, jpnfl
+            ! i-direction
+            IF( iilw(jfl) <= 2 ) THEN
+               iidw(jfl,jind1) = jind1
+            ELSE
+               IF( iilw(jfl) >= jpi-1 ) THEN
+                  iidw(jfl,jind1) = jpi + jind1 - 4
+               ELSE
+                  iidw(jfl,jind1) = iilw(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            ! j-direction
+            IF( ijlw(jfl) <= 2 ) THEN
+               ijdw(jfl,jind1) = jind1
+            ELSE
+               IF( ijlw(jfl) >= jpj-1 ) THEN
+                  ijdw(jfl,jind1) = jpj + jind1 - 4
+               ELSE
+                  ijdw(jfl,jind1) = ijlw(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+            ! k-direction
+            IF( iklw(jfl) <= 2 ) THEN
+               ikdw(jfl,jind1) = jind1
+            ELSE
+               IF( iklw(jfl) >= jpk-1 ) THEN
+                  ikdw(jfl,jind1) = jpk + jind1 - 4
+               ELSE
+                  ikdw(jfl,jind1) = iklw(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      DO jind1 = 1, 4
+         DO jfl = 1, jpnfl
+            IF( iklw(jfl) <= 2 ) THEN
+               ikdw(jfl,jind1) = jind1
+            ELSE
+               IF( iklw(jfl) >= jpk-1 ) THEN
+                  ikdw(jfl,jind1) = jpk + jind1 - 4
+               ELSE
+                  ikdw(jfl,jind1) = iklw(jfl) + jind1 - 2
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      
+      ! Lagrange coefficients  for w interpolation
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            zlagxw(jfl,jind1) = 1.
+            zlagyw(jfl,jind1) = 1.
+            zlagzw(jfl,jind1) = 1.
+         END DO
+      END DO
+       
+      DO jind1 = 1, 4
+         DO jind2 = 1, 4
+            DO jfl = 1, jpnfl
+               IF( jind1 /= jind2 ) THEN
+                  zlagxw(jfl,jind1) = zlagxw(jfl,jind1) * (pxt(jfl) - (float(iidw(jfl,jind2))) )
+                  zlagyw(jfl,jind1) = zlagyw(jfl,jind1) * (pyt(jfl) - (float(ijdw(jfl,jind2))) )
+                  zlagzw(jfl,jind1) = zlagzw(jfl,jind1) * (pzt(jfl) - (float(ikdw(jfl,jind2))-.5) )
+               ENDIF
+            END DO
+         END DO
+      END DO
+      
+      ! velocity w  when we compute at middle time step
+      
+      DO jfl = 1, jpnfl
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1, 4
+                  ztwfl(jfl,jind1,jind2,jind3)=   &
+                     &   ( tcoef1(kind) * wb(iidw(jfl,jind1),ijdw(jfl,jind2),ikdw(jfl,jind3))+   &
+                     &     tcoef2(kind) * wn(iidw(jfl,jind1),ijdw(jfl,jind2),ikdw(jfl,jind3)) )  &
+!!bug e3w instead of fse3 
+                     &   / e3w(ikdw(jfl,jind3))
+               END DO
+            END DO
+         END DO
+         
+         zsumw=0.
+         DO jind1 = 1, 4
+            DO jind2 = 1, 4
+               DO jind3 = 1, 4
+                  zsumw = zsumw + ztwfl(jfl,jind1,jind2,jind3) * zlagxw(jfl,jind1) * zlagyw(jfl,jind2)   &
+                     &  * zlagzw(jfl,jind3) * rcoef(jind1)*rcoef(jind2)*rcoef(jind3)
+               END DO
+            END DO
+         END DO
+         pwfl(jfl) = zsumw
+      END DO
+      
+   END SUBROUTINE flo_interp
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flo_4rk                 ! Empty routine
+   END SUBROUTINE flo_4rk
+#endif
+   
+   !!======================================================================
+END MODULE flo4rk
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flo_oce.F90	(revision 1844)
@@ -0,0 +1,55 @@
+MODULE flo_oce
+   !!======================================================================
+   !!                     ***  MODULE flo_oce  ***
+   !! lagrangian floats :   define in memory all floats parameters and variables
+   !!======================================================================
+   !! History :   OPA  ! 1999-10  (CLIPPER projet)
+   !!   NEMO      1.0  ! 2002-11  (G. Madec, A. Bozec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                        drifting floats
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_floats = .TRUE.    !: float flag
+
+   !! float parameters
+   !! ----------------
+   INTEGER, PUBLIC, PARAMETER ::   jpnfl     = 23 ,                !: total number of floats during the run
+   INTEGER, PUBLIC, PARAMETER ::   jpnnewflo =  0 ,                !: number of floats added in a new run
+   INTEGER, PUBLIC, PARAMETER ::   jpnrstflo = jpnfl - jpnnewflo   !: number of floats for the restart
+
+   !! float variables
+   !! ---------------
+   INTEGER, PUBLIC, DIMENSION(jpnfl)  ::   nisobfl   !: =0 for a isobar float , =1 for a float following the w velocity
+   INTEGER, PUBLIC, DIMENSION(jpnfl)  ::   ngrpfl    !: number to identify searcher group
+
+   REAL(wp), PUBLIC, DIMENSION(jpnfl) ::   flxx , flyy , flzz    !: longitude, latitude, depth of float (decimal degree, m >0)
+   REAL(wp), PUBLIC, DIMENSION(jpnfl) ::   tpifl, tpjfl, tpkfl   !: (i,j,k) indices of float position
+
+   REAL(wp), PUBLIC, DIMENSION(jpi, jpj, jpk) ::   wb            !: vertical velocity at previous time step (m s-1).
+   
+   !                                  !!! * namelist namflo : langrangian floats *
+   LOGICAL, PUBLIC  ::   ln_rstflo  = .FALSE.    !: T/F float restart 
+   LOGICAL, PUBLIC  ::   ln_argo    = .FALSE.    !: T/F argo type floats
+   LOGICAL, PUBLIC  ::   ln_flork4  = .FALSE.    !: T/F 4th order Runge-Kutta
+   INTEGER, PUBLIC  ::   nn_writefl = 150       !: frequency of float output file 
+   INTEGER, PUBLIC  ::   nn_stockfl = 450       !: frequency of float restart file
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                 NO drifting floats
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_floats = .FALSE.   !: float flag
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE flo_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floats.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floats.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floats.F90	(revision 1844)
@@ -0,0 +1,113 @@
+MODULE floats
+   !!======================================================================
+   !!                       ***  MODULE  floats  ***
+   !! Ocean floats : floats
+   !!======================================================================
+   !! History :  OPA  !          (CLIPPER)   original Code
+   !!   NEMO     1.0  ! 2002-06  (A. Bozec)  F90, Free form and module
+   !!----------------------------------------------------------------------
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                     float trajectories
+   !!----------------------------------------------------------------------
+   !!   flo_stp   : float trajectories computation
+   !!   flo_init  : initialization of float trajectories computation
+   !!----------------------------------------------------------------------
+   USE flo_oce         ! floats variables
+   USE lib_mpp         ! distributed memory computing
+   USE flodom          ! initialisation Module 
+   USE flowri          ! float output                     (flo_wri routine)
+   USE flo4rk          ! Trajectories, Runge Kutta scheme (flo_4rk routine)
+   USE floblk          ! Trajectories, Blanke scheme      (flo_blk routine)
+
+   IMPLICIT NONE
+   PRIVATE  
+
+   PUBLIC   flo_stp    ! routine called by step.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flo_stp( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE flo_stp  ***
+      !!                    
+      !! ** Purpose :   Compute the geographical position (lat., long., depth)
+      !!      of each float at each time step with one of the algorithm.
+      !! 
+      !! ** Method  :   The position of a float is computed with Bruno Blanke 
+      !!        algorithm by default and with a 4th order Runge-Kutta scheme
+      !!        if ln_flork4 =T
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'flo_stp : call floats routine '
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+         CALL flo_init           ! read the namelist of floats             
+
+         CALL flo_dom            ! compute/read initial position of floats
+
+         wb(:,:,:) = wn(:,:,:)   ! set wb for computation of floats trajectories at the first time step
+      ENDIF
+      !
+      IF( ln_flork4 ) THEN   ;   CALL flo_4rk( kt )        ! Trajectories using a 4th order Runge Kutta scheme
+      ELSE                   ;   CALL flo_blk( kt )        ! Trajectories using Blanke' algorithme
+      ENDIF
+      !
+      IF( lk_mpp )   CALL mppsync   ! synchronization of all the processor
+      !
+      IF( kt == nit000 .OR. MOD( kt, nn_writefl ) == 0 )   CALL flo_wri( kt )      ! trajectories file 
+      IF( kt == nitend .OR. MOD( kt, nn_stockfl ) == 0 )   CALL flo_wri( kt )      ! restart file 
+      !
+      wb(:,:,:) = wn(:,:,:)         ! Save the old vertical velocity field
+      !
+   END SUBROUTINE flo_stp
+
+
+   SUBROUTINE flo_init
+      !!----------------------------------------------------------------
+      !!                 ***  ROUTINE flo_init  ***
+      !!                   
+      !! ** Purpose :   Read the namelist of floats
+      !!----------------------------------------------------------------------
+      USE ioipsl
+      !!
+      NAMELIST/namflo/ ln_rstflo, nn_writefl, nn_stockfl, ln_argo, ln_flork4 
+      !!---------------------------------------------------------------------
+      !
+      REWIND( numnam )              ! Namelist namflo : floats
+      READ  ( numnam, namflo )
+      !
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '         Namelist floats :'
+         WRITE(numout,*) '            restart                          ln_rstflo = ', ln_rstflo
+         WRITE(numout,*) '            frequency of float output file   nn_writefl  = ', nn_writefl
+         WRITE(numout,*) '            frequency of float restart file  nn_stockfl  = ', nn_stockfl
+         WRITE(numout,*) '            Argo type floats                 ln_argo   = ', ln_argo
+         WRITE(numout,*) '            Computation of T trajectories    ln_flork4 = ', ln_flork4
+      ENDIF
+      !
+   END SUBROUTINE flo_init
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flo_stp( kt )          ! Empty routine
+      WRITE(*,*) 'flo_stp: You should not have seen this print! error?', kt
+   END SUBROUTINE flo_stp
+#endif
+
+   !!======================================================================
+ END MODULE floats
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floblk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floblk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/floblk.F90	(revision 1844)
@@ -0,0 +1,428 @@
+MODULE floblk
+   !!======================================================================
+   !!                     ***  MODULE  floblk  ***
+   !! Ocean floats :   trajectory computation
+   !!======================================================================
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                     float trajectories
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!    flotblk     : compute float trajectories with Blanke algorithme
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE flo_oce         ! ocean drifting floats
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC flo_blk      ! routine called by floats.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flo_blk( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE flo_blk  ***
+      !!           
+      !! ** Purpose :   Compute the geographical position,latitude, longitude
+      !!      and depth of each float at each time step.
+      !! 
+      !! ** Method  :   The position of a float is computed with Bruno Blanke
+      !!      algorithm. We need to know the velocity field, the old positions
+      !!      of the floats and the grid defined on the domain.
+      !!
+      !!----------------------------------------------------------------------
+      !! * arguments
+      INTEGER, INTENT( in  ) ::   kt ! ocean time step
+
+      !! * Local declarations
+      INTEGER :: jfl              ! dummy loop arguments
+      INTEGER :: ind, ifin, iloop
+      INTEGER , DIMENSION ( jpnfl )  ::   &
+         iil, ijl, ikl,             &     ! index of nearest mesh
+         iiloc , ijloc,             &
+         iiinfl, ijinfl, ikinfl,    &     ! index of input mesh of the float.
+         iioutfl, ijoutfl, ikoutfl        ! index of output mesh of the float.
+      REAL(wp) , DIMENSION ( jpnfl )  ::    &
+         zgifl, zgjfl, zgkfl,       &     ! position of floats, index on 
+                                          ! velocity mesh.
+         ztxfl, ztyfl, ztzfl,       &     ! time for a float to quit the mesh
+                                          ! across one of the face x,y and z 
+         zttfl,                     &     ! time for a float to quit the mesh 
+         zagefl,                    &     ! time during which, trajectorie of 
+                                          ! the float has been computed
+         zagenewfl,                 &     ! new age of float after calculation 
+                                          ! of new position
+         zufl, zvfl, zwfl,          &     ! interpolated vel. at float position
+         zudfl, zvdfl, zwdfl,       &     ! velocity diff input/output of mesh
+         zgidfl, zgjdfl, zgkdfl           ! direction index of float 
+      REAL(wp)   ::       &
+         zuinfl,zvinfl,zwinfl,      &     ! transport across the input face
+         zuoutfl,zvoutfl,zwoutfl,   &     ! transport across the ouput face
+         zvol,                      &     ! volume of the mesh
+         zsurfz,                    &     ! surface of the face of the mesh 
+         zind
+      REAL(wp), DIMENSION ( 2 )  ::   &
+         zsurfx, zsurfy                   ! surface of the face of the mesh
+      !!---------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'flo_blk : compute Blanke trajectories for floats '
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      ! Initialisation of parameters
+      
+      DO jfl = 1, jpnfl
+         ! ages of floats are put at zero
+         zagefl(jfl) = 0.
+         ! index on the velocity grid 
+         ! We considere k coordinate negative, with this transformation 
+         ! the computation in the 3 direction is the same. 
+         zgifl(jfl) = tpifl(jfl) - 0.5
+         zgjfl(jfl) = tpjfl(jfl) - 0.5
+         zgkfl(jfl) = MIN(-1.,-(tpkfl(jfl)))
+         ! surface drift every 10 days 
+         IF( ln_argo ) THEN
+            IF( MOD(kt,150) >= 146 .OR. MOD(kt,150) == 0 )  zgkfl(jfl) = -1.
+         ENDIF
+         ! index of T mesh
+         iil(jfl) = 1 + INT(zgifl(jfl))
+         ijl(jfl) = 1 + INT(zgjfl(jfl))
+         ikl(jfl) =     INT(zgkfl(jfl))
+      END DO
+       
+      iloop = 0
+222   DO jfl = 1, jpnfl
+# if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+         IF( (iil(jfl) >= (mig(nldi)-jpizoom+1)) .AND. (iil(jfl) <= (mig(nlei)-jpizoom+1)) .AND.   &
+             (ijl(jfl) >= (mjg(nldj)-jpjzoom+1)) .AND. (ijl(jfl) <= (mjg(nlej)-jpjzoom+1)) ) THEN
+            iiloc(jfl) = iil(jfl) - (mig(1)-jpizoom+1) + 1
+            ijloc(jfl) = ijl(jfl) - (mjg(1)-jpjzoom+1) + 1
+# else 
+            iiloc(jfl) = iil(jfl)
+            ijloc(jfl) = ijl(jfl)
+# endif
+            
+            ! compute the transport across the mesh where the float is.            
+!!bug (gm) change e3t into fse3. but never checked 
+            zsurfx(1) = e2u(iiloc(jfl)-1,ijloc(jfl)  ) * fse3u(iiloc(jfl)-1,ijloc(jfl)  ,-ikl(jfl))
+            zsurfx(2) = e2u(iiloc(jfl)  ,ijloc(jfl)  ) * fse3u(iiloc(jfl)  ,ijloc(jfl)  ,-ikl(jfl))
+            zsurfy(1) = e1v(iiloc(jfl)  ,ijloc(jfl)-1) * fse3v(iiloc(jfl)  ,ijloc(jfl)-1,-ikl(jfl))
+            zsurfy(2) = e1v(iiloc(jfl)  ,ijloc(jfl)  ) * fse3v(iiloc(jfl)  ,ijloc(jfl)  ,-ikl(jfl))
+
+            ! for a isobar float zsurfz is put to zero. The vertical velocity will be zero too.
+            zsurfz = e1t(iiloc(jfl),ijloc(jfl)) * e2t(iiloc(jfl),ijloc(jfl))
+            zvol   = zsurfz * fse3t(iiloc(jfl),ijloc(jfl),-ikl(jfl))
+
+            !
+            zuinfl =( ub(iiloc(jfl)-1,ijloc(jfl),-ikl(jfl)) + un(iiloc(jfl)-1,ijloc(jfl),-ikl(jfl)) )/2.*zsurfx(1)
+            zuoutfl=( ub(iiloc(jfl)  ,ijloc(jfl),-ikl(jfl)) + un(iiloc(jfl)  ,ijloc(jfl),-ikl(jfl)) )/2.*zsurfx(2)
+            zvinfl =( vb(iiloc(jfl),ijloc(jfl)-1,-ikl(jfl)) + vn(iiloc(jfl),ijloc(jfl)-1,-ikl(jfl)) )/2.*zsurfy(1)
+            zvoutfl=( vb(iiloc(jfl),ijloc(jfl)  ,-ikl(jfl)) + vn(iiloc(jfl),ijloc(jfl)  ,-ikl(jfl)) )/2.*zsurfy(2)
+            zwinfl =-(wb(iiloc(jfl),ijloc(jfl),-(ikl(jfl)-1))    &
+               &   +  wn(iiloc(jfl),ijloc(jfl),-(ikl(jfl)-1)) )/2. *  zsurfz*nisobfl(jfl)
+            zwoutfl=-(wb(iiloc(jfl),ijloc(jfl),- ikl(jfl)   )   &
+               &   +  wn(iiloc(jfl),ijloc(jfl),- ikl(jfl)   ) )/2. *  zsurfz*nisobfl(jfl)
+            
+            ! interpolation of velocity field on the float initial position            
+            zufl(jfl)=  zuinfl  + ( zgifl(jfl) - float(iil(jfl)-1) ) * ( zuoutfl - zuinfl)
+            zvfl(jfl)=  zvinfl  + ( zgjfl(jfl) - float(ijl(jfl)-1) ) * ( zvoutfl - zvinfl)
+            zwfl(jfl)=  zwinfl  + ( zgkfl(jfl) - float(ikl(jfl)-1) ) * ( zwoutfl - zwinfl)
+            
+            ! faces of input and output
+            ! u-direction
+            IF( zufl(jfl) < 0. ) THEN
+               iioutfl(jfl) = iil(jfl) - 1.
+               iiinfl (jfl) = iil(jfl)
+               zind   = zuinfl
+               zuinfl = zuoutfl
+               zuoutfl= zind
+            ELSE
+               iioutfl(jfl) = iil(jfl)
+               iiinfl (jfl) = iil(jfl) - 1
+            ENDIF
+            ! v-direction       
+            IF( zvfl(jfl) < 0. ) THEN
+               ijoutfl(jfl) = ijl(jfl) - 1.
+               ijinfl (jfl) = ijl(jfl)
+               zind    = zvinfl
+               zvinfl  = zvoutfl
+               zvoutfl = zind
+            ELSE
+               ijoutfl(jfl) = ijl(jfl)
+               ijinfl (jfl) = ijl(jfl) - 1.
+            ENDIF
+            ! w-direction
+            IF( zwfl(jfl) < 0. ) THEN
+               ikoutfl(jfl) = ikl(jfl) - 1.
+               ikinfl (jfl) = ikl(jfl)
+               zind    = zwinfl
+               zwinfl  = zwoutfl
+               zwoutfl = zind
+            ELSE
+               ikoutfl(jfl) = ikl(jfl)
+               ikinfl (jfl) = ikl(jfl) - 1.
+            ENDIF
+            
+            ! compute the time to go out the mesh across a face
+            ! u-direction
+            zudfl (jfl) = zuoutfl - zuinfl
+            zgidfl(jfl) = float(iioutfl(jfl) - iiinfl(jfl))
+            IF( zufl(jfl)*zuoutfl <= 0. ) THEN
+               ztxfl(jfl) = 1.E99
+            ELSE
+               IF( ABS(zudfl(jfl)) >= 1.E-5 ) THEN
+                  ztxfl(jfl)= zgidfl(jfl)/zudfl(jfl) * LOG(zuoutfl/zufl (jfl))
+               ELSE
+                  ztxfl(jfl)=(float(iioutfl(jfl))-zgifl(jfl))/zufl(jfl)
+               ENDIF
+               IF( (ABS(zgifl(jfl)-float(iiinfl (jfl))) <=  1.E-7) .OR.   &
+                   (ABS(zgifl(jfl)-float(iioutfl(jfl))) <=  1.E-7) ) THEN
+                  ztxfl(jfl)=(zgidfl(jfl))/zufl(jfl)
+               ENDIF
+            ENDIF
+            ! v-direction
+            zvdfl (jfl) = zvoutfl - zvinfl
+            zgjdfl(jfl) = float(ijoutfl(jfl)-ijinfl(jfl))
+            IF( zvfl(jfl)*zvoutfl <= 0. ) THEN
+               ztyfl(jfl) = 1.E99
+            ELSE
+               IF( ABS(zvdfl(jfl)) >= 1.E-5 ) THEN
+                  ztyfl(jfl) = zgjdfl(jfl)/zvdfl(jfl) * LOG(zvoutfl/zvfl (jfl))
+               ELSE
+                  ztyfl(jfl) = (float(ijoutfl(jfl)) - zgjfl(jfl))/zvfl(jfl)
+               ENDIF
+               IF( (ABS(zgjfl(jfl)-float(ijinfl (jfl))) <= 1.E-7) .OR.   &
+                   (ABS(zgjfl(jfl)-float(ijoutfl(jfl))) <=  1.E-7) ) THEN
+                  ztyfl(jfl) = (zgjdfl(jfl)) / zvfl(jfl)
+               ENDIF
+            ENDIF
+            ! w-direction        
+            IF( nisobfl(jfl) == 1. ) THEN 
+               zwdfl (jfl) = zwoutfl - zwinfl
+               zgkdfl(jfl) = float(ikoutfl(jfl) - ikinfl(jfl))
+               IF( zwfl(jfl)*zwoutfl <= 0. ) THEN
+                  ztzfl(jfl) = 1.E99
+               ELSE
+                  IF( ABS(zwdfl(jfl)) >= 1.E-5 ) THEN
+                     ztzfl(jfl) = zgkdfl(jfl)/zwdfl(jfl) * LOG(zwoutfl/zwfl (jfl))
+                  ELSE
+                     ztzfl(jfl) = (float(ikoutfl(jfl)) - zgkfl(jfl))/zwfl(jfl)
+                  ENDIF
+                  IF( (ABS(zgkfl(jfl)-float(ikinfl (jfl))) <=  1.E-7) .OR.   &
+                      (ABS(zgkfl(jfl)-float(ikoutfl(jfl))) <= 1.E-7) ) THEN
+                     ztzfl(jfl) = (zgkdfl(jfl)) / zwfl(jfl)
+                  ENDIF
+               ENDIF
+            ENDIF
+            
+            ! the time to go leave the mesh is the smallest time
+                   
+            IF( nisobfl(jfl) == 1. ) THEN 
+               zttfl(jfl) = MIN(ztxfl(jfl),ztyfl(jfl),ztzfl(jfl))
+            ELSE
+               zttfl(jfl) = MIN(ztxfl(jfl),ztyfl(jfl))
+            ENDIF
+            ! new age of the FLOAT
+            zagenewfl(jfl) = zagefl(jfl) + zttfl(jfl)*zvol
+            ! test to know if the "age" of the float is not bigger than the 
+            ! time step
+            IF( zagenewfl(jfl) > rdt ) THEN
+               zttfl(jfl) = (rdt-zagefl(jfl)) / zvol
+               zagenewfl(jfl) = rdt
+            ENDIF
+            
+            ! In the "minimal" direction we compute the index of new mesh
+            ! on i-direction
+            IF( ztxfl(jfl) <=  zttfl(jfl) ) THEN
+               zgifl(jfl) = float(iioutfl(jfl))
+               ind = iioutfl(jfl)
+               IF( iioutfl(jfl) >= iiinfl(jfl) ) THEN
+                  iioutfl(jfl) = iioutfl(jfl) + 1
+               ELSE
+                  iioutfl(jfl) = iioutfl(jfl) - 1
+               ENDIF
+               iiinfl(jfl) = ind
+            ELSE
+               IF( ABS(zudfl(jfl)) >= 1.E-5 ) THEN 
+                  zgifl(jfl) = zgifl(jfl) + zgidfl(jfl)*zufl(jfl)    &
+                     &       * ( EXP( zudfl(jfl)/zgidfl(jfl)*zttfl(jfl) ) - 1. ) /  zudfl(jfl)
+               ELSE
+                  zgifl(jfl) = zgifl(jfl) + zufl(jfl) * zttfl(jfl)
+               ENDIF
+            ENDIF
+            ! on j-direction
+            IF( ztyfl(jfl) <= zttfl(jfl) ) THEN
+               zgjfl(jfl) = float(ijoutfl(jfl))
+               ind = ijoutfl(jfl)
+               IF( ijoutfl(jfl) >= ijinfl(jfl) ) THEN
+                  ijoutfl(jfl) = ijoutfl(jfl) + 1
+               ELSE
+                  ijoutfl(jfl) = ijoutfl(jfl) - 1
+               ENDIF
+               ijinfl(jfl) = ind
+            ELSE
+               IF( ABS(zvdfl(jfl)) >= 1.E-5 ) THEN 
+                  zgjfl(jfl) = zgjfl(jfl)+zgjdfl(jfl)*zvfl(jfl)   &
+                     &       * ( EXP(zvdfl(jfl)/zgjdfl(jfl)*zttfl(jfl)) - 1. ) /  zvdfl(jfl)
+               ELSE
+                  zgjfl(jfl) = zgjfl(jfl)+zvfl(jfl)*zttfl(jfl)
+               ENDIF
+            ENDIF
+            ! on k-direction
+            IF( nisobfl(jfl) == 1. ) THEN
+               IF( ztzfl(jfl) <= zttfl(jfl) ) THEN
+                  zgkfl(jfl) = float(ikoutfl(jfl))
+                  ind = ikoutfl(jfl)
+                  IF( ikoutfl(jfl) >= ikinfl(jfl) ) THEN
+                     ikoutfl(jfl) = ikoutfl(jfl)+1
+                  ELSE
+                     ikoutfl(jfl) = ikoutfl(jfl)-1
+                  ENDIF
+                  ikinfl(jfl) = ind
+               ELSE
+                  IF( ABS(zwdfl(jfl)) >= 1.E-5 ) THEN 
+                     zgkfl(jfl) = zgkfl(jfl)+zgkdfl(jfl)*zwfl(jfl)    &
+                        &       * ( EXP(zwdfl(jfl)/zgkdfl(jfl)*zttfl(jfl)) - 1. ) /  zwdfl(jfl)
+                  ELSE
+                     zgkfl(jfl) = zgkfl(jfl)+zwfl(jfl)*zttfl(jfl)
+                  ENDIF
+               ENDIF
+            ENDIF
+            
+            ! coordinate of the new point on the temperature grid
+            
+            iil(jfl) = MAX(iiinfl(jfl),iioutfl(jfl))
+            ijl(jfl) = MAX(ijinfl(jfl),ijoutfl(jfl))
+            IF( nisobfl(jfl) ==  1 ) ikl(jfl) = MAX(ikinfl(jfl),ikoutfl(jfl))
+!!Alexcadm	 write(*,*)'PE ',narea,
+!!Alexcadm     .    iiinfl(jfl),iioutfl(jfl),ijinfl(jfl)
+!!Alexcadm     .		,ijoutfl(jfl),ikinfl(jfl),
+!!Alexcadm     .	  ikoutfl(jfl),ztxfl(jfl),ztyfl(jfl)
+!!Alexcadm     .		,ztzfl(jfl),zgifl(jfl),
+!!Alexcadm     .  zgjfl(jfl) 
+!!Alexcadm	IF (jfl == 910) write(*,*)'Flotteur 910',
+!!Alexcadm     .    iiinfl(jfl),iioutfl(jfl),ijinfl(jfl)
+!!Alexcadm     .		,ijoutfl(jfl),ikinfl(jfl),
+!!Alexcadm     .	  ikoutfl(jfl),ztxfl(jfl),ztyfl(jfl)
+!!Alexcadm     .		,ztzfl(jfl),zgifl(jfl),
+!!Alexcadm     .  zgjfl(jfl) 
+            ! reinitialisation of the age of FLOAT
+            zagefl(jfl) = zagenewfl(jfl)
+# if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+         ELSE
+            ! we put zgifl, zgjfl, zgkfl, zagefl
+            zgifl (jfl) = 0.
+            zgjfl (jfl) = 0.
+            zgkfl (jfl) = 0.
+            zagefl(jfl) = 0.
+            iil(jfl) = 0
+            ijl(jfl) = 0
+         ENDIF
+# endif
+      END DO
+      
+      ! synchronisation
+      IF( lk_mpp )   CALL mpp_sum( zgifl , jpnfl )   ! sums over the global domain
+      IF( lk_mpp )   CALL mpp_sum( zgjfl , jpnfl )
+      IF( lk_mpp )   CALL mpp_sum( zgkfl , jpnfl )
+      IF( lk_mpp )   CALL mpp_sum( zagefl, jpnfl )
+      IF( lk_mpp )   CALL mpp_sum( iil   , jpnfl )
+      IF( lk_mpp )   CALL mpp_sum( ijl   , jpnfl )
+      
+      ! in the case of open boundaries we need to test if the floats don't
+      ! go out of the domain. If it goes out, the float is put at the 
+      ! middle of the mesh in the domain but the trajectory isn't compute 
+      ! more time.      
+# if defined key_obc
+      DO jfl = 1, jpnfl
+         IF( lp_obc_east ) THEN
+            IF( jped <=  zgjfl(jfl) .AND. zgjfl(jfl) <= jpef .AND. nieob-1 <=  zgifl(jfl) ) THEN
+               zgifl (jfl) = INT(zgifl(jfl)) + 0.5
+               zgjfl (jfl) = INT(zgjfl(jfl)) + 0.5
+               zagefl(jfl) = rdt
+            END IF
+         END IF
+         IF( lp_obc_west ) THEN
+            IF( jpwd <= zgjfl(jfl) .AND. zgjfl(jfl) <= jpwf .AND. niwob >=  zgifl(jfl) ) THEN
+               zgifl (jfl) = INT(zgifl(jfl)) + 0.5
+               zgjfl (jfl) = INT(zgjfl(jfl)) + 0.5
+               zagefl(jfl) = rdt
+            END IF
+         END IF
+         IF( lp_obc_north ) THEN
+            IF( jpnd <=  zgifl(jfl) .AND. zgifl(jfl) <= jpnf .AND. njnob-1 >=  zgjfl(jfl) ) THEN
+               zgifl (jfl) = INT(zgifl(jfl)) + 0.5
+               zgjfl (jfl) = INT(zgjfl(jfl)) + 0.5
+               zagefl(jfl) = rdt
+            END IF
+         END IF
+         IF( lp_obc_south ) THEN
+            IF( jpsd <=  zgifl(jfl) .AND. zgifl(jfl) <= jpsf .AND.  njsob >= zgjfl(jfl) ) THEN
+               zgifl (jfl) = INT(zgifl(jfl)) + 0.5
+               zgjfl (jfl) = INT(zgjfl(jfl)) + 0.5
+               zagefl(jfl) = rdt
+            END IF
+         END IF
+      END DO
+#endif
+
+      ! Test to know if a  float hasn't integrated enought time
+      IF( ln_argo ) THEN
+         ifin = 1
+         DO jfl = 1, jpnfl
+            IF( zagefl(jfl) < rdt )   ifin = 0
+            tpifl(jfl) = zgifl(jfl) + 0.5
+            tpjfl(jfl) = zgjfl(jfl) + 0.5
+         END DO
+      ELSE
+         ifin = 1
+         DO jfl = 1, jpnfl
+            IF( zagefl(jfl) < rdt )   ifin = 0
+            tpifl(jfl) = zgifl(jfl) + 0.5
+            tpjfl(jfl) = zgjfl(jfl) + 0.5
+            IF( nisobfl(jfl) == 1 ) tpkfl(jfl) = -(zgkfl(jfl))
+         END DO
+      ENDIF
+!!Alexcadm	IF (lwp) write(numout,*) '---------'
+!!Alexcadm	IF (lwp) write(numout,*) 'before Erika:',tpifl(880),tpjfl(880),
+!!Alexcadm     .       tpkfl(880),zufl(880),zvfl(880),zwfl(880)
+!!Alexcadm	IF (lwp) write(numout,*) 'first Erika:',tpifl(900),tpjfl(900),
+!!Alexcadm     .       tpkfl(900),zufl(900),zvfl(900),zwfl(900)
+!!Alexcadm	IF (lwp) write(numout,*) 'last Erika:',tpifl(jpnfl),tpjfl(jpnfl),
+!!Alexcadm     .       tpkfl(jpnfl),zufl(jpnfl),zvfl(jpnfl),zwfl(jpnfl)
+      IF( ifin == 0 ) THEN
+         iloop = iloop + 1 
+         GO TO 222
+      ENDIF
+
+   END SUBROUTINE flo_blk
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flo_blk                  ! Empty routine
+   END SUBROUTINE flo_blk 
+#endif
+   
+   !!======================================================================
+END MODULE floblk 
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flodom.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flodom.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flodom.F90	(revision 1844)
@@ -0,0 +1,460 @@
+MODULE flodom
+   !!======================================================================
+   !!                       ***  MODULE  flodom  ***
+   !! Ocean floats :   domain
+   !!======================================================================
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                     float trajectories
+   !!----------------------------------------------------------------------
+   !!   flo_dom        : initialization of floats
+   !!   findmesh       : compute index of position 
+   !!   dstnce         : compute distance between face mesh and floats 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE flo_oce         ! ocean drifting floats
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+
+   IMPLICIT NONE
+
+   !! * Accessibility
+   PRIVATE  dstnce
+   PUBLIC flo_dom     ! routine called by floats.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flo_dom
+      !! ---------------------------------------------------------------------
+      !!                  ***  ROUTINE flo_dom  ***
+      !!                 
+      !!  ** Purpose :   Initialisation of floats
+      !!
+      !!  ** Method  :   We put the floats  in the domain with the latitude,
+      !!       the longitude (degree) and the depth (m).
+      !!
+      !!----------------------------------------------------------------------      
+      !! * Local declarations
+      LOGICAL  :: llinmesh
+      INTEGER  :: ji, jj, jk               ! DO loop index on 3 directions
+      INTEGER  :: jfl, jfl1                ! number of floats   
+      INTEGER  :: inum                     ! logical unit for file read
+      INTEGER, DIMENSION ( jpnfl    )  ::   &
+         iimfl, ijmfl, ikmfl,    &          ! index mesh of floats
+         idomfl,  ivtest, ihtest
+      REAL(wp) :: zdxab, zdyad
+      REAL(wp), DIMENSION ( jpnnewflo+1 )  :: zgifl, zgjfl,  zgkfl
+      !!---------------------------------------------------------------------
+      
+      ! Initialisation with the geographical position or restart
+      
+      IF(lwp) WRITE(numout,*) 'flo_dom : compute initial position of floats'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '           jpnfl = ',jpnfl
+      
+      IF(ln_rstflo) THEN
+         IF(lwp) WRITE(numout,*) '        float restart file read'
+         
+         ! open the restart file 
+         CALL ctl_opn( inum, 'restart_float', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+
+         ! read of the restart file
+         READ(inum) ( tpifl  (jfl), jfl=1, jpnrstflo),   & 
+                        ( tpjfl  (jfl), jfl=1, jpnrstflo),   &
+                        ( tpkfl  (jfl), jfl=1, jpnrstflo),   &
+                        ( nisobfl(jfl), jfl=1, jpnrstflo),   &
+                        ( ngrpfl (jfl), jfl=1, jpnrstflo)    
+         CLOSE(inum)
+
+         ! if we want a  surface drift  ( like PROVOR floats )
+         IF( ln_argo ) THEN
+            DO jfl = 1, jpnrstflo
+               nisobfl(jfl) = 0
+            END DO
+         ENDIF
+
+         IF(lwp) WRITE(numout,*)' flo_dom: END of florstlec'
+         
+         ! It is possible to add new floats.          
+         IF(lwp) WRITE(numout,*)' flo_dom:jpnfl jpnrstflo ',jpnfl,jpnrstflo
+         IF( jpnfl > jpnrstflo ) THEN
+            ! open the init file 
+            CALL ctl_opn( inum, 'init_float', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+            DO jfl = jpnrstflo+1, jpnfl
+               READ(inum,*) flxx(jfl),flyy(jfl),flzz(jfl), nisobfl(jfl),ngrpfl(jfl),jfl1
+            END DO
+            CLOSE(inum)
+            IF(lwp) WRITE(numout,*)' flodom: END reading init_float file'
+            
+            ! Test to find the grid point coordonate with the geographical position            
+            DO jfl = jpnrstflo+1, jpnfl
+               ihtest(jfl) = 0
+               ivtest(jfl) = 0
+               ikmfl(jfl) = 0
+# if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+               DO ji = MAX(nldi,2), nlei
+                  DO jj = MAX(nldj,2), nlej   ! NO vector opt.
+# else
+               DO ji = 2, jpi
+                  DO jj = 2, jpj   ! NO vector opt.
+# endif                     
+                     ! For each float we find the indexes of the mesh                      
+                     CALL findmesh(glamf(ji-1,jj-1),gphif(ji-1,jj-1),   &
+                                   glamf(ji-1,jj  ),gphif(ji-1,jj  ),   &
+                                   glamf(ji  ,jj  ),gphif(ji  ,jj  ),   &
+                                   glamf(ji  ,jj-1),gphif(ji  ,jj-1),   &
+                                   flxx(jfl)       ,flyy(jfl)       ,   &
+                                   glamt(ji  ,jj  ),gphit(ji  ,jj  ), llinmesh)
+                     IF(llinmesh) THEN
+                        iimfl(jfl) = ji
+                        ijmfl(jfl) = jj
+                        ihtest(jfl) = ihtest(jfl)+1
+                        DO jk = 1, jpk-1
+                           IF( (fsdepw(ji,jj,jk) <= flzz(jfl)) .AND. (fsdepw(ji,jj,jk+1) > flzz(jfl)) ) THEN
+                              ikmfl(jfl) = jk
+                              ivtest(jfl) = ivtest(jfl) + 1
+                           ENDIF
+                        END DO
+                     ENDIF
+                  END DO
+               END DO
+               IF(lwp) WRITE(numout,*)'   flo_dom: END findmesh'
+               
+               ! If the float is in a mesh computed by an other processor we put iimfl=ijmfl=-1               
+               IF( ihtest(jfl) ==  0 ) THEN
+                  iimfl(jfl) = -1
+                  ijmfl(jfl) = -1
+               ENDIF
+            END DO
+            
+            ! A zero in the sum of the arrays "ihtest" and "ivtest"             
+# if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+            CALL mpp_sum(ihtest,jpnfl)
+            CALL mpp_sum(ivtest,jpnfl)
+# endif 
+            DO jfl = jpnrstflo+1, jpnfl
+               IF( (ihtest(jfl) > 1 ) .OR. ( ivtest(jfl) > 1) ) THEN
+                  IF(lwp) WRITE(numout,*) 'THE FLOAT',jfl,' IS NOT IN ONLY ONE MESH'
+                  STOP
+               ENDIF
+               IF( (ihtest(jfl) == 0) ) THEN
+                  IF(lwp) WRITE(numout,*)'THE FLOAT',jfl,' IS IN NO MESH'
+                  STOP
+               ENDIF
+            END DO
+            
+            ! We compute the distance between the float and the face of the mesh            
+            DO jfl = jpnrstflo+1, jpnfl               
+               ! Made only if the float is in the domain of the processor              
+               IF( (iimfl(jfl) >= 0) .AND. (ijmfl(jfl) >= 0) ) THEN
+                  
+                  ! TEST TO KNOW IF THE FLOAT IS NOT INITIALISED IN THE COAST
+                  
+                  idomfl(jfl) = 0
+                  IF( tmask(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)) == 0. ) idomfl(jfl) = 1
+                                           
+                  ! Computation of the distance between the float and the faces of the mesh
+                  !            zdxab
+                  !             .
+                  !        B----.---------C
+                  !        |    .         |
+                  !        |<------>flo   |
+                  !        |        ^     |
+                  !        |        |.....|....zdyad
+                  !        |        |     |
+                  !        A--------|-----D
+                  !
+             
+                  zdxab = dstnce( flxx(jfl), flyy(jfl), glamf(iimfl(jfl)-1,ijmfl(jfl)-1), flyy(jfl) )
+                  zdyad = dstnce( flxx(jfl), flyy(jfl), flxx(jfl), gphif(iimfl(jfl)-1,ijmfl(jfl)-1) )
+                  
+                  ! Translation of this distances (in meter) in indexes
+                  
+                  zgifl(jfl-jpnrstflo)= (iimfl(jfl)-0.5) + zdxab/e1u(iimfl(jfl)-1,ijmfl(jfl)) + (mig(1)-jpizoom)
+                  zgjfl(jfl-jpnrstflo)= (ijmfl(jfl)-0.5) + zdyad/e2v(iimfl(jfl),ijmfl(jfl)-1) + (mjg(1)-jpjzoom)
+                  zgkfl(jfl-jpnrstflo) = (( fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1) - flzz(jfl) )* ikmfl(jfl))   &
+                     &                 / (  fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1)                              &
+                     &                    - fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl) ) )                             &
+                     &                 + (( flzz(jfl)-fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)) ) *(ikmfl(jfl)+1))   &
+                     &                 / (  fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1)                              &
+                     &                    - fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)) )
+               ELSE
+                  zgifl(jfl-jpnrstflo) = 0.e0
+                  zgjfl(jfl-jpnrstflo) = 0.e0
+                  zgkfl(jfl-jpnrstflo) = 0.e0
+               ENDIF
+            END DO
+            
+            ! The sum of all the arrays zgifl, zgjfl, zgkfl give 3 arrays with the positions of all the floats.
+            IF( lk_mpp )   THEN
+               CALL mpp_sum( zgjfl, jpnnewflo )   ! sums over the global domain
+               CALL mpp_sum( zgkfl, jpnnewflo )
+               IF(lwp) WRITE(numout,*) (zgifl(jfl),jfl=1,jpnnewflo)
+               IF(lwp) WRITE(numout,*) (zgjfl(jfl),jfl=1,jpnnewflo)
+               IF(lwp) WRITE(numout,*) (zgkfl(jfl),jfl=1,jpnnewflo) 
+            ENDIF
+           
+            DO jfl = jpnrstflo+1, jpnfl
+               tpifl(jfl) = zgifl(jfl-jpnrstflo)
+               tpjfl(jfl) = zgjfl(jfl-jpnrstflo)
+               tpkfl(jfl) = zgkfl(jfl-jpnrstflo)
+            END DO
+         ENDIF
+      ELSE
+         IF(lwp) WRITE(numout,*) '                     init_float read '
+         
+         ! First initialisation of floats
+         ! the initials positions of floats are written in a file
+         ! with a variable to know if it is a isobar float a number 
+         ! to identified who want the trajectories of this float and 
+         ! an index for the number of the float         
+         ! open the init file 
+         CALL ctl_opn( inum, 'init_float', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+         READ(inum) (flxx(jfl)   , jfl=1, jpnfl),   &
+                    (flyy(jfl)   , jfl=1, jpnfl),   &
+                    (flzz(jfl)   , jfl=1, jpnfl),   &
+                    (nisobfl(jfl), jfl=1, jpnfl),   &
+                    (ngrpfl(jfl) , jfl=1, jpnfl)
+         CLOSE(inum)
+            
+         ! Test to find the grid point coordonate with the geographical position         
+         DO jfl = 1, jpnfl
+            ihtest(jfl) = 0
+            ivtest(jfl) = 0
+            ikmfl(jfl) = 0
+# if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+            DO ji = MAX(nldi,2), nlei
+               DO jj = MAX(nldj,2), nlej   ! NO vector opt.
+# else
+            DO ji = 2, jpi
+               DO jj = 2, jpj   ! NO vector opt.
+# endif                  
+                  ! for each float we find the indexes of the mesh 
+                  
+                  CALL findmesh(glamf(ji-1,jj-1),gphif(ji-1,jj-1),   &
+                                glamf(ji-1,jj  ),gphif(ji-1,jj  ),   &
+                                glamf(ji  ,jj  ),gphif(ji  ,jj  ),   &
+                                glamf(ji  ,jj-1),gphif(ji  ,jj-1),   &
+                                flxx(jfl)       ,flyy(jfl)       ,   &
+                                glamt(ji  ,jj  ),gphit(ji  ,jj  ), llinmesh)
+                  IF(llinmesh) THEN
+                     iimfl(jfl)  = ji
+                     ijmfl(jfl)  = jj
+                     ihtest(jfl) = ihtest(jfl)+1
+                     DO jk = 1, jpk-1
+                        IF( (fsdepw(ji,jj,jk) <= flzz(jfl)) .AND. (fsdepw(ji,jj,jk+1) >  flzz(jfl)) ) THEN
+                           ikmfl(jfl)  = jk
+                           ivtest(jfl) = ivtest(jfl) + 1
+                        ENDIF
+                     END DO
+                  ENDIF
+               END DO
+            END DO
+            
+            ! If the float is in a mesh computed by an other processor we put iimfl=ijmfl=-1            
+            IF( ihtest(jfl) == 0 ) THEN
+               iimfl(jfl) = -1
+               ijmfl(jfl) = -1
+            ENDIF
+         END DO
+         
+         ! A zero in the sum of the arrays "ihtest" and "ivtest"          
+         IF( lk_mpp )   CALL mpp_sum(ihtest,jpnfl)   ! sums over the global domain
+         IF( lk_mpp )   CALL mpp_sum(ivtest,jpnfl)
+
+         DO jfl = 1, jpnfl
+            IF( (ihtest(jfl) > 1 ) .OR. ( ivtest(jfl) > 1 )) THEN
+               IF(lwp) WRITE(numout,*) 'THE FLOAT',jfl,' IS NOT IN ONLY ONE MESH'
+            ENDIF
+            IF( ihtest(jfl) == 0 ) THEN 
+               IF(lwp) WRITE(numout,*)'THE FLOAT',jfl,' IS IN NO MESH'
+            ENDIF
+         END DO
+        
+         ! We compute the distance between the float and the face of  the mesh         
+         DO jfl = 1, jpnfl
+            ! Made only if the float is in the domain of the processor
+            IF( (iimfl(jfl) >= 0 ) .AND. ( ijmfl(jfl) >= 0 ) ) THEN
+               
+               ! TEST TO KNOW IF THE FLOAT IS NOT INITIALISED IN THE COAST
+               
+               idomfl(jfl) = 0
+               IF( tmask(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)) == 0. ) idomfl(jfl)=1
+               
+               ! Computation of the distance between the float
+               ! and the faces of the mesh
+               !            zdxab
+               !             .
+               !        B----.---------C
+               !        |    .         |
+               !        |<------>flo   |
+               !        |        ^     |
+               !        |        |.....|....zdyad
+               !        |        |     |
+               !        A--------|-----D
+               
+               zdxab = dstnce(flxx(jfl),flyy(jfl),glamf(iimfl(jfl)-1,ijmfl(jfl)-1),flyy(jfl))                
+               zdyad = dstnce(flxx(jfl),flyy(jfl),flxx(jfl),gphif(iimfl(jfl)-1,ijmfl(jfl)-1))
+               
+               ! Translation of this distances (in meter) in indexes
+               
+               tpifl(jfl) = (iimfl(jfl)-0.5)+zdxab/ e1u(iimfl(jfl)-1,ijmfl(jfl))+(mig(1)-jpizoom)
+               tpjfl(jfl) = (ijmfl(jfl)-0.5)+zdyad/ e2v(iimfl(jfl),ijmfl(jfl)-1)+(mjg(1)-jpjzoom)
+               tpkfl(jfl) = (fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1) - flzz(jfl))*(ikmfl(jfl))                     &
+                          / (fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1) - fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)))   &
+                          + (flzz(jfl) - fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)))*(ikmfl(jfl)+1)                     &
+                          / (fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)+1) - fsdepw(iimfl(jfl),ijmfl(jfl),ikmfl(jfl)))
+            ELSE
+               tpifl (jfl) = 0.e0
+               tpjfl (jfl) = 0.e0
+               tpkfl (jfl) = 0.e0
+               idomfl(jfl) = 0
+            ENDIF
+         END DO
+         
+         ! The sum of all the arrays tpifl, tpjfl, tpkfl give 3 arrays with the positions of all the floats. 
+         IF( lk_mpp )   CALL mpp_sum( tpifl , jpnfl )   ! sums over the global domain
+         IF( lk_mpp )   CALL mpp_sum( tpjfl , jpnfl )
+         IF( lk_mpp )   CALL mpp_sum( tpkfl , jpnfl )
+         IF( lk_mpp )   CALL mpp_sum( idomfl, jpnfl )
+      ENDIF
+            
+      ! Print the initial positions of the floats
+      IF( .NOT. ln_rstflo ) THEN 
+         ! WARNING : initial position not in the sea         
+         DO jfl = 1, jpnfl
+            IF( idomfl(jfl) == 1 ) THEN
+               IF(lwp) WRITE(numout,*)'*****************************'
+               IF(lwp) WRITE(numout,*)'!!!!!!!  WARNING   !!!!!!!!!!'
+               IF(lwp) WRITE(numout,*)'*****************************'
+               IF(lwp) WRITE(numout,*)'The float number',jfl,'is out of the sea.'
+               IF(lwp) WRITE(numout,*)'geographical position',flxx(jfl),flyy(jfl),flzz(jfl)
+               IF(lwp) WRITE(numout,*)'index position',tpifl(jfl),tpjfl(jfl),tpkfl(jfl)
+            ENDIF
+         END DO
+      ENDIF
+
+   END SUBROUTINE flo_dom
+
+
+   SUBROUTINE findmesh( pax, pay, pbx, pby,   &
+                        pcx, pcy, pdx, pdy,   &
+                        px  ,py  ,ptx, pty, ldinmesh )
+      !! -------------------------------------------------------------
+      !!                ***  ROUTINE findmesh  ***
+      !!      
+      !! ** Purpose :   Find the index of mesh for the point spx spy
+      !!
+      !! ** Method  : 
+      !!
+      !! History :
+      !!   8.0  !  98-07 (Y.Drillet)  Original code
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp) ::   &
+         pax, pay, pbx, pby,    &     ! ???
+         pcx, pcy, pdx, pdy,    &     ! ???
+         px, py,                &     ! longitude and latitude
+         ptx, pty                     ! ???
+      LOGICAL ::  ldinmesh            ! ???
+
+      !! * local declarations
+      REAL(wp) ::   &
+         zabt, zbct, zcdt, zdat, zabpt, zbcpt, zcdpt, zdapt,  &
+         psax,psay,psbx,psby,psx,psy
+      REAL(wp) ::  fsline                ! Statement function
+
+      !! * Substitutions
+      fsline(psax, psay, psbx, psby, psx, psy) = psy  * ( psbx - psax )   &
+                                               - psx  * ( psby - psay )   &
+                                               + psax *   psby - psay * psbx
+      !!---------------------------------------------------------------------
+      
+      ! 4 semi plane defined by the 4 points and including the T point
+      zabt = fsline(pax,pay,pbx,pby,ptx,pty)
+      zbct = fsline(pbx,pby,pcx,pcy,ptx,pty)
+      zcdt = fsline(pcx,pcy,pdx,pdy,ptx,pty)
+      zdat = fsline(pdx,pdy,pax,pay,ptx,pty)
+      
+      ! 4 semi plane defined by the 4 points and including the extrememity
+      zabpt = fsline(pax,pay,pbx,pby,px,py)
+      zbcpt = fsline(pbx,pby,pcx,pcy,px,py)
+      zcdpt = fsline(pcx,pcy,pdx,pdy,px,py)
+      zdapt = fsline(pdx,pdy,pax,pay,px,py)
+       
+      ! We compare the semi plane T with the semi plane including the point
+      ! to know if it is in this  mesh.
+      ! For numerical reasons it is possible that for a point which is on
+      ! the line we don't have exactly zero with fsline function. We want 
+      ! that a point can't be in 2 mesh in the same time, so we put the 
+      ! coefficient to zero if it is smaller than 1.E-12
+      
+      IF( ABS(zabpt) <= 1.E-12 ) zabpt = 0.
+      IF( ABS(zbcpt) <= 1.E-12 ) zbcpt = 0.
+      IF( ABS(zcdpt) <= 1.E-12 ) zcdpt = 0.
+      IF( ABS(zdapt) <= 1.E-12 ) zdapt = 0.
+      IF( (zabt*zabpt >  0.) .AND. (zbct*zbcpt >= 0. ) .AND. ( zcdt*zcdpt >= 0. ) .AND. ( zdat*zdapt > 0. )   &
+         .AND. ( px <= MAX(pcx,pdx) ) .AND. ( px >= MIN(pax,pbx) )    &
+         .AND. ( py <= MAX(pby,pcy) ) .AND. ( py >= MIN(pay,pdy) ) ) THEN
+         ldinmesh=.TRUE.
+      ELSE
+         ldinmesh=.FALSE.
+      ENDIF
+
+   END SUBROUTINE findmesh
+
+
+   FUNCTION dstnce( pla1, phi1, pla2, phi2 )
+      !! -------------------------------------------------------------
+      !!                 ***  Function dstnce  ***
+      !!          
+      !! ** Purpose :   returns distance (in m) between two geographical
+      !!                points
+      !! ** Method  : 
+      !!         
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT(in) ::   pla1, phi1, pla2, phi2   ! ???
+
+      !! * Local variables
+      REAL(wp) ::   dly1, dly2, dlx1, dlx2, dlx, dls, dld, dpi
+      REAL(wp) ::   dstnce
+      !!---------------------------------------------------------------------
+      
+      dpi  = 2.* ASIN(1.)
+      dls  = dpi / 180.
+      dly1 = phi1 * dls
+      dly2 = phi2 * dls
+      dlx1 = pla1 * dls
+      dlx2 = pla2 * dls
+
+      dlx = SIN(dly1) * SIN(dly2) + COS(dly1) * COS(dly2) * COS(dlx2-dlx1)
+ 
+      IF( ABS(dlx) > 1.0 ) dlx = 1.0
+
+      dld = ATAN(DSQRT( ( 1-dlx )/( 1+dlx ) )) * 222.24 / dls
+      dstnce = dld * 1000.
+
+   END FUNCTION dstnce
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flo_dom                 ! Empty routine
+   END SUBROUTINE flo_dom
+#endif
+
+   !!======================================================================
+END MODULE flodom
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flowri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flowri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/FLO/flowri.F90	(revision 1844)
@@ -0,0 +1,313 @@
+MODULE flowri
+   !!======================================================================
+   !!                       ***  MODULE  flowri  ***
+   !! lagrangian floats :   outputs
+   !!======================================================================
+   !! History :   OPA  ! 1999-09  (Y. Drillet)  Original code
+   !!                  ! 2000-06  (J.-M. Molines)  Profiling floats for CLS 
+   !!   NEMO      1.0  ! 2002-11  (G. Madec, A. Bozec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+#if   defined key_floats   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_floats'                                     float trajectories
+   !!----------------------------------------------------------------------
+   !!    flowri     : write trajectories of floats in file 
+   !!----------------------------------------------------------------------
+   USE flo_oce         ! ocean drifting floats
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE lib_mpp         ! distribued memory computing library
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   flo_wri    ! routine called by floats.F90
+
+   INTEGER ::   jfl      ! number of floats
+   INTEGER ::   numflo   ! logical unit for drifting floats
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flo_wri( kt )
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE flo_wri  ***
+      !!             
+      !! ** Purpose :   Write position of floats in "trajec_float" file
+      !!      and the temperature and salinity at this position
+      !!      
+      !! ** Method  :   The frequency is nn_writefl
+      !!----------------------------------------------------------------------
+      INTEGER ::   kt   ! time step
+      !!
+      CHARACTER (len=21) ::  clname
+      INTEGER ::   inum   ! temporary logical unit for restart file
+      INTEGER ::   iafl, ibfl, icfl, ia1fl, ib1fl, ic1fl, jfl, irecflo,   &
+      INTEGER ::   iafloc, ibfloc, ia1floc, ib1floc, iafln, ibfln
+      INTEGER  ::    ic, jc , jpn
+      INTEGER, DIMENSION ( jpnij )  :: iproc
+
+      REAL(wp) :: zafl,zbfl,zcfl,zdtj
+      REAL(wp) :: zxxu, zxxu_01,zxxu_10, zxxu_11
+      REAL(wp), DIMENSION (jpk,jpnfl) :: ztemp, zsal
+      !!---------------------------------------------------------------------
+      
+      IF( kt == nit000 .OR. MOD( kt,nn_writefl)== 0 ) THEN 
+
+         ! header of output floats file
+      
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'flo_wri : write in trajec_float file '
+            WRITE(numout,*) '~~~~~~~    '
+         ENDIF
+
+         ! open the file numflo 
+         CALL ctl_opn( numflo, 'trajec_float', 'REPLACE', 'UNFORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+         !      REWIND numflo
+
+         IF( kt == nit000 ) THEN
+            irecflo = NINT( (nitend-nit000) / FLOAT(nn_writefl) )
+            IF(lwp) WRITE(numflo)cexper,no,irecflo,jpnfl,nn_writefl
+         ENDIF
+         zdtj = rdt / 86400.      !!bug   use of 86400 instead of the phycst parameter
+
+         ! translation of index position in geographical position
+
+         IF( lk_mpp ) THEN
+            DO jfl = 1, jpnfl
+               iafl  = INT ( tpifl(jfl) )
+               ibfl  = INT ( tpjfl(jfl) )
+               icfl  = INT ( tpkfl(jfl) )
+               iafln = NINT( tpifl(jfl) )
+               ibfln = NINT( tpjfl(jfl) )
+               ia1fl = iafl + 1
+               ib1fl = ibfl + 1
+               ic1fl = icfl + 1
+               zafl  = tpifl(jfl) - FLOAT( iafl )
+               zbfl  = tpjfl(jfl) - FLOAT( ibfl )
+               zcfl  = tpkfl(jfl) - FLOAT( icfl )
+               IF(   iafl >= mig(nldi)-jpizoom+1 .AND. iafl <= mig(nlei)-jpizoom+1 .AND.   &
+                  &  ibfl >= mjg(nldj)-jpjzoom+1 .AND. ibfl <= mjg(nlej)-jpjzoom+1       ) THEN
+
+                  ! local index
+
+                  iafloc  = iafl -(mig(1)-jpizoom+1) + 1
+                  ibfloc  = ibfl -(mjg(1)-jpjzoom+1) + 1
+                  ia1floc = iafloc + 1
+                  ib1floc = ibfloc + 1
+
+                  flyy(jfl) = (1.-zafl)*(1.-zbfl)*gphit(iafloc ,ibfloc ) + (1.-zafl) * zbfl * gphit(iafloc ,ib1floc)   &
+                     &      +     zafl *(1.-zbfl)*gphit(ia1floc,ibfloc ) +     zafl  * zbfl * gphit(ia1floc,ib1floc)
+                  flxx(jfl) = (1.-zafl)*(1.-zbfl)*glamt(iafloc ,ibfloc ) + (1.-zafl) * zbfl * glamt(iafloc ,ib1floc)   &
+                     &      +     zafl *(1.-zbfl)*glamt(ia1floc,ibfloc ) +     zafl  * zbfl * glamt(ia1floc,ib1floc)
+                  flzz(jfl) = (1.-zcfl)*fsdepw(iafloc,ibfloc,icfl ) + zcfl * fsdepw(iafloc,ibfloc,ic1fl)
+
+                  ! Change  by Alexandra Bozec et Jean-Philippe Boulanger
+                  ! We save  the instantaneous profile of T and S of the column     
+                  ! ztemp(jfl)=tn(iafloc,ibfloc,icfl)
+                  ! zsal(jfl)=sn(iafloc,ibfloc,icfl)
+                  ztemp(1:jpk,jfl) = tn(iafloc,ibfloc,1:jpk)
+                  zsal (1:jpk,jfl) = sn(iafloc,ibfloc,1:jpk)            
+               ELSE
+                  flxx(jfl) = 0.
+                  flyy(jfl) = 0.
+                  flzz(jfl) = 0.
+                  ztemp(1:jpk,jfl) = 0.
+                  zsal (1:jpk,jfl) = 0.
+               ENDIF
+            END DO
+
+            CALL mpp_sum( flxx, jpnfl )   ! sums over the global domain
+            CALL mpp_sum( flyy, jpnfl )
+            CALL mpp_sum( flzz, jpnfl )
+            ! these 2 lines have accendentaly been removed from ATL6-V8 run hence
+            ! giving 0 salinity and temperature on the float trajectory
+!bug RB
+!compilation failed in mpp
+!            CALL mpp_sum( ztemp, jpk*jpnfl )
+!            CALL mpp_sum( zsal , jpk*jpnfl )
+
+         ELSE
+            DO jfl = 1, jpnfl
+               iafl  = INT (tpifl(jfl))
+               ibfl  = INT (tpjfl(jfl))
+               icfl  = INT (tpkfl(jfl))
+               iafln = NINT(tpifl(jfl))
+               ibfln = NINT(tpjfl(jfl))
+               ia1fl = iafl+1
+               ib1fl = ibfl+1
+               ic1fl = icfl+1
+               zafl  = tpifl(jfl) - FLOAT(iafl)
+               zbfl  = tpjfl(jfl) - FLOAT(ibfl)
+               zcfl  = tpkfl(jfl) - FLOAT(icfl)
+               iafloc  = iafl
+               ibfloc  = ibfl
+               ia1floc = iafloc + 1
+               ib1floc = ibfloc + 1
+               !
+               flyy(jfl) = (1.-zafl)*(1.-zbfl)*gphit(iafloc ,ibfloc ) + (1.-zafl) * zbfl * gphit(iafloc ,ib1floc)   &
+                         +     zafl *(1.-zbfl)*gphit(ia1floc,ibfloc ) +     zafl  * zbfl * gphit(ia1floc,ib1floc)
+               flxx(jfl) = (1.-zafl)*(1.-zbfl)*glamt(iafloc ,ibfloc ) + (1.-zafl) * zbfl * glamt(iafloc ,ib1floc)   &
+                         +     zafl *(1.-zbfl)*glamt(ia1floc,ibfloc ) +     zafl  * zbfl * glamt(ia1floc,ib1floc)
+               flzz(jfl) = (1.-zcfl)*fsdepw(iafloc,ibfloc,icfl ) + zcfl * fsdepw(iafloc,ibfloc,ic1fl)
+               !ALEX
+               ! Astuce pour ne pas avoir des flotteurs qui se baladent sur IDL
+               zxxu_11 = glamt(iafloc ,ibfloc )
+               zxxu_10 = glamt(iafloc ,ib1floc)
+               zxxu_01 = glamt(ia1floc,ibfloc )
+               zxxu    = glamt(ia1floc,ib1floc)
+
+               IF( iafloc == 52 )  zxxu_10 = -181
+               IF( iafloc == 52 )  zxxu_11 = -181
+               flxx(jfl)=(1.-zafl)*(1.-zbfl)* zxxu_11 + (1.-zafl)*    zbfl * zxxu_10   &
+                        +    zafl *(1.-zbfl)* zxxu_01 +     zafl *    zbfl * zxxu
+               !ALEX         
+               ! Change  by Alexandra Bozec et Jean-Philippe Boulanger
+               ! We save  the instantaneous profile of T and S of the column     
+               !     ztemp(jfl)=tn(iafloc,ibfloc,icfl)
+               !     zsal(jfl)=sn(iafloc,ibfloc,icfl)
+               ztemp(1:jpk,jfl) = tn(iafloc,ibfloc,1:jpk)
+               zsal (1:jpk,jfl) = sn(iafloc,ibfloc,1:jpk)
+            END DO
+         ENDIF
+
+         !
+         WRITE(numflo) flxx,flyy,flzz,nisobfl,ngrpfl,ztemp,zsal, FLOAT(ndastp)
+      !!
+      !! case when profiles are dumped. In order to save memory, dumps are
+      !! done level by level.
+      !      IF (mod(kt,nflclean) == 0.) THEN
+      !!     IF ( nwflo == nwprofil ) THEN
+      !        DO jk = 1,jpk
+      !         DO jfl=1,jpnfl
+      !         iafl= INT(tpifl(jfl))
+      !         ibfl=INT(tpjfl(jfl))
+      !         iafln=NINT(tpifl(jfl))
+      !         ibfln=NINT(tpjfl(jfl))
+      !# if defined key_mpp_mpi   ||   defined key_mpp_shmem
+      !        IF ( (iafl >= (mig(nldi)-jpizoom+1)) .AND.
+      !     $       (iafl <= (mig(nlei)-jpizoom+1)) .AND.
+      !     $       (ibfl >= (mjg(nldj)-jpjzoom+1)) .AND.
+      !     $       (ibfl <= (mjg(nlej)-jpjzoom+1)) ) THEN
+      !!
+      !! local index
+      !!
+      !         iafloc=iafln-(mig(1)-jpizoom+1)+1
+      !         ibfloc=ibfln-(mjg(1)-jpjzoom+1)+1
+      !!         IF (jk == 1 ) THEN
+      !!      PRINT *,'<<<>>> ',jfl,narea, iafloc ,ibfloc, iafln, ibfln,adatrj
+      !!         ENDIF
+      !# else
+      !         iafloc=iafln
+      !         ibfloc=ibfln
+      !# endif
+      !         ztemp(jfl)=tn(iafloc,ibfloc,jk)
+      !         zsal(jfl)=sn(iaflo!,ibfloc,jk)
+      !# if defined key_mpp_mpi   ||   defined key_mpp_shmem
+      !        ELSE
+      !         ztemp(jfl) = 0.
+      !         zsal(jfl) = 0.
+      !        ENDIF
+      !# endif
+      !! ... next float
+      !        END DO
+      !      IF( lk_mpp )   CALL mpp_sum( ztemp, jpnfl )
+      !      IF( lk_mpp )   CALL mpp_sum( zsal , jpnfl )
+      !
+      !      IF (lwp) THEN 
+      !         WRITE(numflo) ztemp, zsal
+      !      ENDIF
+      !! ... next level jk
+      !      END DO
+      !! ... reset nwflo to 0 for ALL processors, if profile has been written
+      !!       nwflo = 0
+      !      ENDIF
+      !!
+      !      CALL flush (numflo)
+      !! ... time of dumping floats
+      !!      END IF
+      ENDIF
+      
+      IF( (MOD(kt,nn_stockfl) == 0) .OR. ( kt == nitend ) ) THEN 
+         ! Writing the restart file 
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'flo_wri : write in  restart_float file '
+            WRITE(numout,*) '~~~~~~~    '
+         ENDIF
+
+         ! file is opened and closed every time it is used.
+
+         clname = 'restart.float.'
+         ic = 1
+         DO jc = 1, 16
+            IF( cexper(jc:jc) /= ' ' ) ic = jc
+         END DO
+         clname = clname(1:14)//cexper(1:ic)
+         ic = 1
+         DO jc = 1, 48
+            IF( clname(jc:jc) /= ' ' ) ic = jc
+         END DO
+
+         CALL ctl_opn( inum, clname, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+         REWIND inum
+         !
+         DO jpn = 1, jpnij
+            iproc(jpn) = 0
+         END DO
+         !
+         IF(lwp) THEN
+            REWIND(inum)
+            WRITE (inum) tpifl,tpjfl,tpkfl,nisobfl,ngrpfl
+            CLOSE (inum) 
+         ENDIF
+         !
+         ! Compute the number of trajectories for each processor
+         !
+         IF( lk_mpp ) THEN
+            DO jfl = 1, jpnfl
+               IF( (INT(tpifl(jfl)) >= (mig(nldi)-jpizoom+1)) .AND.   &
+                  &(INT(tpifl(jfl)) <= (mig(nlei)-jpizoom+1)) .AND.   &
+                  &(INT(tpjfl(jfl)) >= (mjg(nldj)-jpjzoom+1)) .AND.   &
+                  &(INT(tpjfl(jfl)) <= (mjg(nlej)-jpjzoom+1)) ) THEN
+                  iproc(narea) = iproc(narea)+1
+               ENDIF
+            END DO
+            CALL mpp_sum( iproc, jpnij )
+            !
+            IF(lwp) THEN 
+               WRITE(numout,*) 'DATE',adatrj
+               DO jpn = 1, jpnij
+                  IF( iproc(jpn) /= 0 ) THEN
+                     WRITE(numout,*)'PROCESSOR',jpn-1,'compute',iproc(jpn), 'trajectories.'
+                  ENDIF
+               END DO
+            ENDIF
+         ENDIF
+      ENDIF 
+
+      IF( kt == nitend )   CLOSE( numflo ) 
+    
+   END SUBROUTINE flo_wri
+
+#  else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flo_wri                 ! Empty routine
+   END SUBROUTINE flo_wri
+#endif
+   
+   !!======================================================================
+END MODULE flowri
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 1844)
@@ -0,0 +1,281 @@
+MODULE in_out_manager   
+   !!======================================================================
+   !!                       ***  MODULE  in_out_manager  ***
+   !! Ocean physics:  vertical mixing coefficient compute from the tke 
+   !!                 turbulent closure parameterization
+   !!=====================================================================
+   !! History :   1.0  !  2002-06  (G. Madec)   original code
+   !!             2.0  !  2006-07  (S. Masson)  iom, add ctl_stop, ctl_warn
+   !!             3.0  !  2008-06  (G. Madec)   add ctmp4 to ctmp10
+   !!             3.2  !  2009-08  (S. MAsson)  add new ctl_opn
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ctl_stop   : update momentum and tracer Kz from a tke scheme
+   !!   ctl_warn   : initialization, namelist read, and parameters control
+   !!   getunit    : give the index of an unused logical unit
+   !!----------------------------------------------------------------------
+   USE par_kind        ! kind definition
+   USE par_oce         ! ocean parameter
+   USE lib_print       ! formated print library
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !!                   namrun namelist parameters
+   !!----------------------------------------------------------------------
+   CHARACTER(len=16)  ::   cn_exp        = "exp0"      !: experiment name used for output filename
+   CHARACTER(len=32)  ::   cn_ocerst_in  = "restart"   !: suffix of ocean restart name (input)
+   CHARACTER(len=32)  ::   cn_ocerst_out = "restart"   !: suffix of ocean restart name (output)
+   LOGICAL            ::   ln_rstart     = .FALSE.     !: start from (F) rest or (T) a restart file
+   INTEGER            ::   nn_no         = 0           !: job number
+   INTEGER            ::   nn_rstctl     = 0           !: control of the time step (0, 1 or 2)
+   INTEGER            ::   nn_rstssh     = 0           !: hand made initilization of ssh or not (1/0)
+   INTEGER            ::   nn_it000      = 1           !: index of the first time step
+   INTEGER            ::   nn_itend      = 10          !: index of the last time step
+   INTEGER            ::   nn_date0      = 961115      !: initial calendar date aammjj
+   INTEGER            ::   nn_leapy      = 0           !: Leap year calendar flag (0/1 or 30)
+   INTEGER            ::   nn_istate     = 0           !: initial state output flag (0/1)
+   INTEGER            ::   nn_write      =   10        !: model standard output frequency
+   INTEGER            ::   nn_stock      =   10        !: restart file frequency
+   LOGICAL            ::   ln_dimgnnn    = .FALSE.     !: type of dimgout. (F): 1 file for all proc
+                                                       !:                  (T): 1 file per proc
+   LOGICAL            ::   ln_mskland    = .FALSE.     !: mask land points in NetCDF outputs (costly: + ~15%)
+   LOGICAL            ::   ln_clobber    = .FALSE.     !: clobber (overwrite) an existing file
+   INTEGER            ::   nn_chunksz    = 0           !: chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
+
+   !! conversion of DOCTOR norm namelist name into model name
+   !! (this should disappear in a near futur)
+
+   CHARACTER(len=16)  ::   cexper                      !: experiment name used for output filename
+   INTEGER            ::   no                          !: job number
+   INTEGER            ::   nrstdt                      !: control of the time step (0, 1 or 2)
+   INTEGER            ::   nit000                      !: index of the first time step
+   INTEGER            ::   nitend                      !: index of the last time step
+   INTEGER            ::   ndate0                      !: initial calendar date aammjj
+   INTEGER            ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
+   INTEGER            ::   ninist                      !: initial state output flag (0/1)
+   INTEGER            ::   nwrite                      !: model standard output frequency
+   INTEGER            ::   nstock                      !: restart file frequency
+
+   !!----------------------------------------------------------------------
+   !! was in restart but moved here because of the OFF line... better solution should be found...
+   !!----------------------------------------------------------------------
+   INTEGER            ::   nitrst                 !: time step at which restart file should be written
+
+   !!----------------------------------------------------------------------
+   !!                    output monitoring
+   !!----------------------------------------------------------------------
+   LOGICAL            ::   ln_ctl     = .FALSE.   !: run control for debugging
+   INTEGER            ::   nn_print     =    0    !: level of print (0 no print)
+   INTEGER            ::   nn_ictls     =    0    !: Start i indice for the SUM control
+   INTEGER            ::   nn_ictle     =    0    !: End   i indice for the SUM control
+   INTEGER            ::   nn_jctls     =    0    !: Start j indice for the SUM control
+   INTEGER            ::   nn_jctle     =    0    !: End   j indice for the SUM control
+   INTEGER            ::   nn_isplt     =    1    !: number of processors following i
+   INTEGER            ::   nn_jsplt     =    1    !: number of processors following j
+   INTEGER            ::   nn_bench     =    0    !: benchmark parameter (0/1)
+   INTEGER            ::   nn_bit_cmp   =    0    !: bit reproducibility  (0/1)
+
+   !                                              !: OLD namelist names
+   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench, nbit_cmp   
+
+   INTEGER            ::   ijsplt     =    1      !: nb of local domain = nb of processors
+
+   !!----------------------------------------------------------------------
+   !!                        logical units
+   !!----------------------------------------------------------------------
+   INTEGER            ::   numstp     =   -1      !: logical unit for time step
+   INTEGER            ::   numout     =    6      !: logical unit for output print
+   INTEGER            ::   numnam     =   -1      !: logical unit for namelist
+   INTEGER            ::   numnam_ice =   -1      !: logical unit for ice namelist
+   INTEGER            ::   numevo_ice =   -1      !: logical unit for ice variables (temp. evolution)
+   INTEGER            ::   numsol     =   -1      !: logical unit for solver statistics
+
+   !!----------------------------------------------------------------------
+   !!                          Run control  
+   !!----------------------------------------------------------------------
+   INTEGER            ::   nstop = 0                !: error flag (=number of reason for a premature stop run)
+   INTEGER            ::   nwarn = 0                !: warning flag (=number of warning found during the run)
+   CHARACTER(len=200) ::   ctmp1, ctmp2, ctmp3      !: temporary characters 1 to 3
+   CHARACTER(len=200) ::   ctmp4, ctmp5, ctmp6      !: temporary characters 4 to 6
+   CHARACTER(len=200) ::   ctmp7, ctmp8, ctmp9      !: temporary characters 7 to 9
+   CHARACTER(len=200) ::   ctmp10                   !: temporary character 10
+   CHARACTER (len=64) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
+   CHARACTER (len=64) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
+   LOGICAL            ::   lwp      = .FALSE.       !: boolean : true on the 1st processor only
+   LOGICAL            ::   lsp_area = .TRUE.        !: to make a control print over a specific area
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_opa  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the error number (nstop) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      !
+      nstop = nstop + 1 
+      IF(lwp) THEN
+         WRITE(numout,"(/,' ===>>> : E R R O R',     /,'         ===========',/)") 
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
+         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+      ENDIF
+                               CALL FLUSH(numout    )
+      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
+      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
+      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
+      !
+   END SUBROUTINE ctl_stop
+
+
+   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_warn  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the warning number (nwarn) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      ! 
+      nwarn = nwarn + 1 
+      IF(lwp) THEN
+         WRITE(numout,"(/,' ===>>> : W A R N I N G', /,'         ===============',/)") 
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
+         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+      ENDIF
+      CALL FLUSH(numout)
+      !
+   END SUBROUTINE ctl_warn
+
+
+   SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ctl_opn  ***
+      !!
+      !! ** Purpose :   Open file and check if required file is available.
+      !!
+      !! ** Method  :   Fortan open
+      !!
+      !! History :
+      !!        !  1995-12  (G. Madec)  Original code
+      !!   8.5  !  2002-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+
+      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
+      INTEGER          , INTENT(in   ) ::   klengh    ! record length
+      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
+      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
+      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
+      !!
+      CHARACTER(len=80) ::   clfile
+      INTEGER           ::   iost
+
+      ! adapt filename
+      ! ----------------
+      clfile = TRIM(cdfile)
+      IF( PRESENT( karea ) ) THEN
+         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
+      ENDIF
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
+      knum=Agrif_Get_Unit()
+#else
+      knum=getunit()
+#endif
+
+      iost=0
+      IF( cdacce(1:6) == 'DIRECT' )  THEN
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
+      ELSE
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
+      ENDIF
+      IF( iost == 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*) '     file   : ', clfile,' open ok'
+            WRITE(kout,*) '     unit   = ', knum
+            WRITE(kout,*) '     status = ', cdstat
+            WRITE(kout,*) '     form   = ', cdform
+            WRITE(kout,*) '     access = ', cdacce
+            WRITE(kout,*)
+         ENDIF
+      ENDIF
+100   CONTINUE
+      IF( iost /= 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*)
+            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
+            WRITE(kout,*) ' =======   ===  '
+            WRITE(kout,*) '           unit   = ', knum
+            WRITE(kout,*) '           status = ', cdstat
+            WRITE(kout,*) '           form   = ', cdform
+            WRITE(kout,*) '           access = ', cdacce
+            WRITE(kout,*) '           iostat = ', iost
+            WRITE(kout,*) '           we stop. verify the file '
+            WRITE(kout,*)
+         ENDIF
+         STOP 'ctl_opn bad opening'
+      ENDIF
+      
+   END SUBROUTINE ctl_opn
+
+
+   FUNCTION getunit()
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  getunit  ***
+      !!
+      !! ** Purpose :   return the index of an unused logical unit
+      !!----------------------------------------------------------------------
+      INTEGER :: getunit
+      LOGICAL :: llopn 
+      !!----------------------------------------------------------------------
+      !
+      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
+      llopn = .TRUE.
+      DO WHILE( (getunit < 998) .AND. llopn )
+         getunit = getunit + 1
+         INQUIRE( unit = getunit, opened = llopn )
+      END DO
+      IF( (getunit == 999) .AND. llopn ) THEN
+         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
+         getunit = -1
+      ENDIF
+      !
+   END FUNCTION getunit
+
+   !!=====================================================================
+END MODULE in_out_manager
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom.F90	(revision 1844)
@@ -0,0 +1,1160 @@
+MODULE iom
+   !!=====================================================================
+   !!                    ***  MODULE  iom ***
+   !! Input/Output manager :  Library to read input files
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis cdvar in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+   USE iom_ioipsl      ! NetCDF format with IOIPSL library
+   USE iom_nf90        ! NetCDF format with native NetCDF library
+   USE iom_rstdimg     ! restarts access direct format "dimg" style...
+
+#if defined key_iomput
+   USE sbc_oce, ONLY :   nn_fsbc         ! ocean space and time domain
+   USE domngb          ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE dianam          ! build name of file
+   USE mod_event_client
+   USE mod_attribut
+# endif
+
+   IMPLICIT NONE
+   PUBLIC   !   must be public to be able to access iom_def through iom
+   
+#if defined key_iomput
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .TRUE.        !: iom_put flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag
+#endif
+   PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put
+
+   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d
+   PRIVATE iom_p2d, iom_p3d
+#if defined key_iomput
+   PRIVATE set_grid
+# endif
+
+   INTERFACE iom_get
+      MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d
+   END INTERFACE
+   INTERFACE iom_rstput
+      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   END INTERFACE
+  INTERFACE iom_put
+     MODULE PROCEDURE iom_p0d, iom_p2d, iom_p3d
+  END INTERFACE
+#if defined key_iomput
+   INTERFACE iom_setkt
+      MODULE PROCEDURE event__set_timestep
+   END INTERFACE
+# endif
+
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   
+      !!
+      !!----------------------------------------------------------------------
+#if defined key_iomput
+      REAL(wp) ::   ztmp
+      !!----------------------------------------------------------------------
+      ! read the xml file
+      IF( Agrif_Root() ) CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)...
+      CALL iom_swap
+
+      ! calendar parameters
+      SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
+      CASE ( 1)   ;   CALL event__set_calendar('gregorian')
+      CASE ( 0)   ;   CALL event__set_calendar('noleap'   )
+      CASE (30)   ;   CALL event__set_calendar('360d'     )
+      END SELECT
+      ztmp = fjulday - adatrj
+      IF( ABS(ztmp  - REAL(NINT(ztmp),wp)) < 0.1 / rday )   ztmp = REAL(NINT(ztmp),wp)   ! avoid truncation error
+      CALL event__set_time_parameters( nit000 - 1, ztmp, rdt )
+
+      ! horizontal grid definition
+      CALL set_scalar
+      CALL set_grid( "grid_T", glamt, gphit )
+      CALL set_grid( "grid_U", glamu, gphiu )
+      CALL set_grid( "grid_V", glamv, gphiv )
+      CALL set_grid( "grid_W", glamt, gphit )
+
+      ! vertical grid definition
+      CALL event__set_vert_axis( "deptht", gdept_0 )
+      CALL event__set_vert_axis( "depthu", gdept_0 )
+      CALL event__set_vert_axis( "depthv", gdept_0 )
+      CALL event__set_vert_axis( "depthw", gdepw_0 )
+      
+      ! automatic definitions of some of the xml attributs
+      CALL set_xmlatt
+
+      ! end file definition
+      CALL event__close_io_definition
+#endif
+
+   END SUBROUTINE iom_init
+
+
+   SUBROUTINE iom_swap
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_swap  ***
+      !!
+      !! ** Purpose :  swap context between different agrif grid for xmlio_server
+      !!---------------------------------------------------------------------
+#if defined key_iomput
+
+     IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+        CALL event__swap_context("nemo")
+     ELSE
+        CALL event__swap_context(TRIM(Agrif_CFixed())//"_nemo")
+     ENDIF
+
+#endif
+   END SUBROUTINE iom_swap
+
+
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file (return 0 if not found)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   )           ::   cdname   ! File name
+      INTEGER         , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90) 
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
+
+      CHARACTER(LEN=100)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
+      CHARACTER(LEN=100)    ::   cltmpn    ! tempory name to store clname (in writting mode)
+      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" or ".dimg"
+      CHARACTER(LEN=15)     ::   clcpu     ! the cpu number (max jpmax_digits digits)
+      CHARACTER(LEN=100)    ::   clinfo    ! info character
+      LOGICAL               ::   llok      ! check the existence 
+      LOGICAL               ::   llwrt     ! local definition of ldwrt
+      LOGICAL               ::   llnoov    ! local definition to read overlap
+      LOGICAL               ::   llstop    ! local definition of ldstop
+      LOGICAL               ::   lliof     ! local definition of ldiof
+      INTEGER               ::   iolib     ! library do we use to open the file
+      INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
+      INTEGER               ::   iln, ils  ! lengths of character
+      INTEGER               ::   idom      ! type of domain
+      INTEGER               ::   istop     ! 
+      INTEGER, DIMENSION(2,5) ::   idompar ! domain parameters: 
+      ! local number of points for x,y dimensions
+      ! position of first local point for x,y dimensions
+      ! position of last local point for x,y dimensions
+      ! start halo size for x,y dimensions
+      ! end halo size for x,y dimensions
+      !---------------------------------------------------------------------
+      ! Initializations and control
+      ! =============
+      kiomid = -1
+      clinfo = '                    iom_open ~~~  '
+      istop = nstop
+      ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0
+      ! (could be done when defining iom_file in f95 but not in f90)
+      IF( Agrif_Root() ) THEN
+         IF( iom_open_init == 0 ) THEN
+            iom_file(:)%nfid = 0
+            iom_open_init = 1
+         ENDIF
+      ENDIF
+      ! do we read or write the file?
+      IF( PRESENT(ldwrt) ) THEN   ;   llwrt = ldwrt
+      ELSE                        ;   llwrt = .FALSE.
+      ENDIF
+      ! do we call ctl_stop if we try to open a non-existing file in read mode?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      ! what library do we use to open the file?
+      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
+      ELSE                         ;   iolib = jpnf90
+      ENDIF
+      ! are we using interpolation on the fly?
+      IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof
+      ELSE                        ;   lliof = .FALSE.
+      ENDIF
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
+      ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
+      ! =============
+      clname   = trim(cdname)
+      IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
+         iln    = INDEX(clname,'/') 
+         cltmpn = clname(1:iln)
+         clname = clname(iln+1:LEN_TRIM(clname))
+         clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      ENDIF
+      ! which suffix should we use?
+      SELECT CASE (iolib)
+      CASE (jpioipsl ) ;   clsuffix = '.nc'
+      CASE (jpnf90   ) ;   clsuffix = '.nc'
+      CASE (jprstdimg) ;   clsuffix = '.dimg'
+      CASE DEFAULT     ;   clsuffix = ''
+         CALL ctl_stop( TRIM(clinfo), 'accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+      END SELECT
+      ! Add the suffix if needed
+      iln = LEN_TRIM(clname)
+      ils = LEN_TRIM(clsuffix)
+      IF( iln <= ils .OR. INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 )   &
+         &   clname = TRIM(clname)//TRIM(clsuffix)
+      cltmpn = clname   ! store this name
+      ! try to find if the file to be opened already exist
+      ! =============
+      INQUIRE( FILE = clname, EXIST = llok )
+      IF( .NOT.llok ) THEN
+         ! we try to add the cpu number to the name
+         IF( iolib == jprstdimg ) THEN   ;   WRITE(clcpu,*) narea
+         ELSE                            ;   WRITE(clcpu,*) narea-1
+         ENDIF
+         clcpu  = TRIM(ADJUSTL(clcpu))
+         iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.)
+         clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+         icnt = 0
+         INQUIRE( FILE = clname, EXIST = llok ) 
+         ! we try different formats for the cpu number by adding 0
+         DO WHILE( .NOT.llok .AND. icnt < jpmax_digits )
+            clcpu  = "0"//trim(clcpu)
+            clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+            INQUIRE( FILE = clname, EXIST = llok )
+            icnt = icnt + 1
+         END DO
+      ENDIF
+      IF( llwrt ) THEN
+         ! check the domain definition
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         idom = jpdom_local_noovlap   ! default definition
+         IF( llnoov ) THEN   ;   idom = jpdom_local_noovlap   ! default definition
+         ELSE                ;   idom = jpdom_local_full      ! default definition
+         ENDIF
+         IF( PRESENT(kdom) )   idom = kdom
+         ! create the domain informations
+         ! =============
+         SELECT CASE (idom)
+         CASE (jpdom_local_full)
+            idompar(:,1) = (/ jpi             , jpj              /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1  /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ jpi - nlei      , jpj - nlej       /)
+         CASE (jpdom_local_noextra)
+            idompar(:,1) = (/ nlci            , nlcj             /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ nlci - nlei     , nlcj - nlej      /)
+         CASE (jpdom_local_noovlap)
+            idompar(:,1) = (/ nlei  - nldi + 1, nlej  - nldj + 1 /)
+            idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /)
+            idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /)
+            idompar(:,4) = (/ 0               , 0                /)
+            idompar(:,5) = (/ 0               , 0                /)
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' )
+         END SELECT
+      ENDIF
+      ! Open the NetCDF or RSTDIMG file
+      ! =============
+      ! do we have some free file identifier?
+      IF( MINVAL(iom_file(:)%nfid) /= 0 )   &
+         &   CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' )
+      ! if no file was found...
+      IF( .NOT. llok ) THEN
+         IF( .NOT. llwrt ) THEN   ! we are in read mode 
+            IF( llstop ) THEN   ;   CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' )
+            ELSE                ;   istop = nstop + 1   ! make sure that istop /= nstop so we don't open the file
+            ENDIF
+         ELSE                     ! we are in write mode so we 
+            clname = cltmpn       ! get back the file name without the cpu number
+         ENDIF
+      ENDIF
+      IF( istop == nstop ) THEN   ! no error within this routine
+         SELECT CASE (iolib)
+         CASE (jpioipsl )   ;   CALL iom_ioipsl_open(  clname, kiomid, llwrt, llok, idompar )
+         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
+         CASE (jprstdimg)   ;   CALL iom_rstdimg_open( clname, kiomid, llwrt, llok, idompar )
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         END SELECT
+      ENDIF
+      !
+   END SUBROUTINE iom_open
+
+
+   SUBROUTINE iom_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_close  ***
+      !!
+      !! ** Purpose : close an input file, or all files opened by iom
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(inout), OPTIONAL ::   kiomid   ! iom identifier of the file to be closed
+      !                                              ! return 0 when file is properly closed
+      !                                              ! No argument: all files opened by iom are closed
+
+      INTEGER ::   jf         ! dummy loop indices
+      INTEGER ::   i_s, i_e   ! temporary integer
+      CHARACTER(LEN=100)    ::   clinfo    ! info character
+      !---------------------------------------------------------------------
+      !
+      clinfo = '                    iom_close ~~~  '
+      IF( PRESENT(kiomid) ) THEN
+         i_s = kiomid
+         i_e = kiomid
+      ELSE
+         i_s = 1
+         i_e = jpmax_files
+#if defined key_iomput
+         CALL event__stop_ioserver
+#endif
+      ENDIF
+
+      IF( i_s > 0 ) THEN
+         DO jf = i_s, i_e
+            IF( iom_file(jf)%nfid > 0 ) THEN
+               SELECT CASE (iom_file(jf)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_close(  jf )
+               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
+               CASE (jprstdimg)   ;   CALL iom_rstdimg_close( jf )
+               CASE DEFAULT
+                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+               END SELECT
+               iom_file(jf)%nfid       = 0          ! free the id 
+               IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok'
+            ELSEIF( PRESENT(kiomid) ) THEN
+               WRITE(ctmp1,*) '--->',  kiomid
+               CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 )
+            ENDIF
+         END DO
+      ENDIF
+      !    
+   END SUBROUTINE iom_close
+
+
+   FUNCTION iom_varid ( kiomid, cdvar, kdimsz, ldstop )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file (return 0 if not found)
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      LOGICAL              , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if looking for non-existing variable (default = .TRUE.)
+      !
+      INTEGER                        ::   iom_varid, iiv, i_nvd
+      LOGICAL                        ::   ll_fnd
+      CHARACTER(LEN=100)             ::   clinfo                   ! info character
+      LOGICAL                        ::   llstop                   ! local definition of ldstop
+      !!-----------------------------------------------------------------------
+      iom_varid = 0                         ! default definition
+      ! do we call ctl_stop if we look for non-existing variable?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      !
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
+         IF( iom_file(kiomid)%nfid == 0 ) THEN 
+            CALL ctl_stop( trim(clinfo), 'the file is not open' )
+         ELSE
+            ll_fnd  = .FALSE.
+            iiv = 0
+            !
+            DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars )
+               iiv = iiv + 1
+               ll_fnd  = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) )
+            END DO
+            !
+            IF( .NOT.ll_fnd ) THEN
+               iiv = iiv + 1
+               IF( iiv <= jpmax_vars ) THEN
+                  SELECT CASE (iom_file(kiomid)%iolib)
+                  CASE (jpioipsl )   ;   iom_varid = iom_ioipsl_varid( kiomid, cdvar, iiv, kdimsz )
+                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz )
+                  CASE (jprstdimg)   ;   iom_varid = -1   ! all variables are listed in iom_file
+                  CASE DEFAULT   
+                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                  END SELECT
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
+                        &                         'increase the parameter jpmax_vars')
+               ENDIF
+               IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' ) 
+            ELSE
+               iom_varid = iiv
+               IF( PRESENT(kdimsz) ) THEN 
+                  i_nvd = iom_file(kiomid)%ndims(iiv)
+                  IF( i_nvd == size(kdimsz) ) THEN
+                     kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv)
+                  ELSE
+                     WRITE(ctmp1,*) i_nvd, size(kdimsz)
+                     CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) )
+                  ENDIF
+               ENDIF
+            ENDIF
+         ENDIF
+      ENDIF
+      !
+   END FUNCTION iom_varid
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_get
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_g0d( kiomid, cdvar, pvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out)                 ::   pvar      ! read field
+      !
+      INTEGER               :: idvar   ! variable id
+      !
+      IF( kiomid > 0 ) THEN
+         idvar = iom_varid( kiomid, cdvar )
+         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar )
+            CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
+            CASE DEFAULT    
+               CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g0d
+
+   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g1d
+
+   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g2d
+
+   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g3d
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
+         &                  pv_r1d, pv_r2d, pv_r3d,   &
+         &                  ktime , kstart, kcount  )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_get_123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! Identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
+      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar      ! Name of the variable
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
+      !
+      LOGICAL                        ::   llnoov      ! local definition to read overlap
+      INTEGER                        ::   jl          ! loop on number of dimension 
+      INTEGER                        ::   idom        ! type of domain
+      INTEGER                        ::   idvar       ! id of the variable
+      INTEGER                        ::   inbdim      ! number of dimensions of the variable
+      INTEGER                        ::   idmspc      ! number of spatial dimensions 
+      INTEGER                        ::   itime       ! record number
+      INTEGER                        ::   istop       ! temporary value of nstop
+      INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER                        ::   ji, jj      ! loop counters
+      INTEGER                        ::   irankpv       ! 
+      INTEGER                        ::   ind1, ind2  ! substring index
+      INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis
+      INTEGER, DIMENSION(jpmax_dims) ::   icnt        ! number of value to read along each axis 
+      INTEGER, DIMENSION(jpmax_dims) ::   idimsz      ! size of the dimensions of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   ishape      ! size of the dimensions of the variable
+      REAL(wp)                       ::   zscf, zofs  ! sacle_factor and add_offset
+      INTEGER                        ::   itmp        ! temporary integer
+      CHARACTER(LEN=100)             ::   clinfo      ! info character
+      CHARACTER(LEN=100)             ::   clname      ! file name
+      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
+      !---------------------------------------------------------------------
+      !
+      clname = iom_file(kiomid)%name   !   esier to read
+      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
+      ! local definition of the domain ?
+      idom = kdom
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
+      ! check kcount and kstart optionals parameters...
+      IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
+      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
+      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown')
+
+      ! Search for the variable in the data base (eventually actualize data)
+      istop = nstop
+      idvar = iom_varid( kiomid, cdvar )
+      !
+      IF( idvar > 0 ) THEN
+         ! to write iom_file(kiomid)%dimsz in a shorter way !
+         idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
+         inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
+         idmspc = inbdim                                   ! number of spatial dimensions in the file
+         IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
+         IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
+         !
+         ! update idom definition...
+         ! Identify the domain in case of jpdom_auto(glo/dta) definition
+         IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
+            IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
+            ELSE                               ;   idom = jpdom_data
+            ENDIF
+            ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
+            ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
+            IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
+         ENDIF
+         ! Identify the domain in case of jpdom_local definition
+         IF( idom == jpdom_local ) THEN
+            IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
+            ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
+            ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
+            ENDIF
+         ENDIF
+         !
+         ! check the consistency between input array and data rank in the file
+         !
+         ! initializations
+         itime = 1
+         IF( PRESENT(ktime) ) itime = ktime
+
+         irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
+         WRITE(clrankpv, fmt='(i1)') irankpv
+         WRITE(cldmspc , fmt='(i1)') idmspc
+         !
+         IF(     idmspc <  irankpv ) THEN 
+            CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
+               &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
+         ELSEIF( idmspc == irankpv ) THEN
+            IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
+               &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
+         ELSEIF( idmspc >  irankpv ) THEN
+               IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
+                  CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
+                        &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
+                        &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
+                  idmspc = idmspc - 1
+               ELSE
+                  CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
+                     &                         'we do not accept data with more than '//cldmspc//' spatial dimension',   &
+                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+               ENDIF
+         ENDIF
+
+         !
+         ! definition of istart and icnt
+         !
+         icnt  (:) = 1
+         istart(:) = 1
+         istart(idmspc+1) = itime
+
+         IF(              PRESENT(kstart)       ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
+         ELSE
+            IF(           idom == jpdom_unknown ) THEN                                       ; icnt(1:idmspc) = idimsz(1:idmspc)
+            ELSE 
+               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
+                  IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow
+                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow
+                  ENDIF
+                  ! we do not read the overlap                     -> we start to read at nldi, nldj
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
+                  ENDIF
+                  IF( PRESENT(pv_r3d) ) THEN
+                     IF( idom == jpdom_data ) THEN   ; icnt(3) = jpkdta
+                     ELSE                            ; icnt(3) = jpk
+                     ENDIF
+                  ENDIF
+               ENDIF
+            ENDIF
+         ENDIF
+
+         ! check that istart and icnt can be used with this file
+         !-
+         DO jl = 1, jpmax_dims
+            itmp = istart(jl)+icnt(jl)-1
+            IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
+               WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
+               WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
+               CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
+            ENDIF
+         END DO
+
+         ! check that icnt matches the input array
+         !-     
+         IF( idom == jpdom_unknown ) THEN
+            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
+            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
+            IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
+            ctmp1 = 'd'
+         ELSE
+            IF( irankpv == 2 ) THEN
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
+               IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
+               ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
+               ENDIF
+            ENDIF
+            IF( irankpv == 3 ) THEN 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
+               IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
+               ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
+               ENDIF
+            ENDIF
+         ENDIF
+         
+         DO jl = 1, irankpv
+            WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
+            IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
+         END DO
+
+      ENDIF
+
+      ! read the data
+      !-     
+      IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
+         !
+         ! find the right index of the array to be read
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+!         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+!         ENDIF
+         IF( llnoov ) THEN
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ELSE
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ENDIF
+      
+         SELECT CASE (iom_file(kiomid)%iolib)
+         CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE DEFAULT    
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         END SELECT
+
+         IF( istop == nstop ) THEN   ! no additional errors until this point...
+            IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i4,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
+          
+            !--- overlap areas and extra hallows (mpp)
+            IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
+               CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
+               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
+               IF( icnt(3) == jpk ) THEN
+                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
+                  DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
+                  DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
+               ENDIF
+            ENDIF
+            
+            !--- Apply scale_factor and offset
+            zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
+            zofs = iom_file(kiomid)%ofs(idvar)      ! offset
+            IF(     PRESENT(pv_r1d) ) THEN
+               IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
+               IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
+            ELSEIF( PRESENT(pv_r2d) ) THEN
+!CDIR COLLAPSE
+               IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
+!CDIR COLLAPSE
+               IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
+            ELSEIF( PRESENT(pv_r3d) ) THEN
+!CDIR COLLAPSE
+               IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
+!CDIR COLLAPSE
+               IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE iom_get_123d
+
+
+   SUBROUTINE iom_gettime( kiomid, ptime, cdvar, kntime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kiomid     ! file Identifier
+      REAL(wp), DIMENSION(:)     , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL , INTENT(in   ) ::   cdvar      ! time axis name
+      INTEGER         , OPTIONAL , INTENT(  out) ::   kntime     ! number of times in file
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdunits    ! units attribute of time coordinate
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdcalendar ! calendar attribute of 
+      !
+      INTEGER, DIMENSION(1) :: kdimsz
+      INTEGER            ::   idvar    ! id of the variable
+      CHARACTER(LEN=32)  ::   tname    ! local name of time coordinate
+      CHARACTER(LEN=100) ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      !
+      IF ( PRESENT(cdvar) ) THEN
+         tname = cdvar
+      ELSE
+         tname = iom_file(kiomid)%uldname
+      ENDIF
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(tname)
+         IF ( PRESENT(kntime) ) THEN
+            idvar  = iom_varid( kiomid, tname, kdimsz = kdimsz )
+            kntime = kdimsz(1)
+         ELSE
+            idvar = iom_varid( kiomid, tname )
+         ENDIF
+         !
+         ptime(:) = 0. ! default definition
+         IF( idvar > 0 ) THEN
+            IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN
+               IF( iom_file(kiomid)%luld(idvar) ) THEN
+                  IF( iom_file(kiomid)%dimsz(1,idvar) == size(ptime) ) THEN
+                     SELECT CASE (iom_file(kiomid)%iolib)
+                     CASE (jpioipsl )   ;   CALL iom_ioipsl_gettime( kiomid, idvar, ptime, cdunits, cdcalendar )
+                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
+                     CASE (jprstdimg)   ;   CALL ctl_stop( TRIM(clinfo)//' case IO library == jprstdimg not coded...' )
+                     CASE DEFAULT    
+                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                     END SELECT
+                  ELSE
+                     WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
+                     CALL ctl_stop( trim(clinfo), trim(ctmp1) )
+                  ENDIF
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' )
+               ENDIF
+            ELSE
+               CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' )
+            ENDIF
+         ELSE
+            CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE iom_gettime
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_rstput
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in)                         ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp0d
+
+   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(        jpk) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp1d
+
+   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj    ) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp2d
+
+   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
+            CASE DEFAULT     
+               CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp3d
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_put
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_p0d( cdname, pfield0d )
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      REAL(wp)        , INTENT(in) ::   pfield0d
+#if defined key_iomput
+      CALL event__write_field2D( cdname, RESHAPE( (/pfield0d/), (/1,1/) ) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p0d
+
+   SUBROUTINE iom_p2d( cdname, pfield2d )
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pfield2d
+#if defined key_iomput
+      CALL event__write_field2D( cdname, pfield2d(nldi:nlei, nldj:nlej) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p2d
+
+   SUBROUTINE iom_p3d( cdname, pfield3d )
+      CHARACTER(LEN=*)                , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   pfield3d
+#if defined key_iomput
+      CALL event__write_field3D( cdname, pfield3d(nldi:nlei, nldj:nlej, :) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p3d
+   !!----------------------------------------------------------------------
+
+
+#if defined key_iomput
+
+   SUBROUTINE set_grid( cdname, plon, plat )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   define horizontal grids
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plon
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
+
+      CALL event__set_grid_dimension( cdname, jpiglo, jpjglo)
+      CALL event__set_grid_domain( cdname, nlei-nldi+1, nlej-nldj+1, nimpp+nldi-1, njmpp+nldj-1, &
+         &                         plon(nldi:nlei, nldj:nlej), plat(nldi:nlei, nldj:nlej) )
+      CALL event__set_grid_type_nemo( cdname )
+
+   END SUBROUTINE set_grid
+
+
+   SUBROUTINE set_scalar
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   define fake grids for scalar point
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(1,1) ::   zz = 1.
+      !!----------------------------------------------------------------------
+      CALL event__set_grid_dimension( 'scalarpoint', jpnij, 1)
+      CALL event__set_grid_domain   ( 'scalarpoint', 1, 1, narea, 1, zz, zz )
+      CALL event__set_grid_type_nemo( 'scalarpoint' )
+
+   END SUBROUTINE set_scalar
+
+
+   SUBROUTINE set_xmlatt
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   automatic definitions of some of the xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=6),DIMENSION( 8) ::   clsuff                   ! suffix name
+      CHARACTER(len=1),DIMENSION( 3) ::   clgrd                    ! suffix name
+      CHARACTER(len=50)              ::   clname                   ! file name
+      CHARACTER(len=1)               ::   cl1                      ! 1 character
+      CHARACTER(len=2)               ::   cl2                      ! 1 character
+      INTEGER                        ::   idt                      ! time-step in seconds
+      INTEGER                        ::   iddss, ihhss             ! number of seconds in 1 day, 1 hour and 1 year
+      INTEGER                        ::   iyymo                    ! number of months in 1 year
+      INTEGER                        ::   jg, jh, jd, jm, jy       ! loop counters
+      INTEGER                        ::   ix, iy                   ! i-,j- index
+      REAL(wp)        ,DIMENSION(11) ::   zlontao                  ! longitudes of tao    moorings
+      REAL(wp)        ,DIMENSION( 7) ::   zlattao                  ! latitudes  of tao    moorings
+      REAL(wp)        ,DIMENSION( 4) ::   zlonrama                 ! longitudes of rama   moorings
+      REAL(wp)        ,DIMENSION(11) ::   zlatrama                 ! latitudes  of rama   moorings
+      REAL(wp)        ,DIMENSION( 3) ::   zlonpira                 ! longitudes of pirata moorings
+      REAL(wp)        ,DIMENSION( 9) ::   zlatpira                 ! latitudes  of pirata moorings
+      !!----------------------------------------------------------------------
+      ! 
+      idt   = NINT( rdttra(1)     )
+      iddss = NINT( rday          )                                         ! number of seconds in 1 day
+      ihhss = NINT( rmmss * rhhmm )                                         ! number of seconds in 1 hour
+      iyymo = NINT( raamo         )                                         ! number of months in 1 year
+
+      ! frequency of the call of iom_put (attribut: freq_op)
+      CALL event__set_attribut( 'field_definition', attr( field__freq_op, idt           ) )    ! model time-step
+      CALL event__set_attribut( 'SBC'             , attr( field__freq_op, idt * nn_fsbc ) )    ! SBC time-step
+      
+      ! output file names (attribut: name)
+      clsuff(:) = (/ 'grid_T', 'grid_U', 'grid_V', 'grid_W', 'icemod', 'ptrc_T', 'diad_T', 'scalar' /)      
+      DO jg = 1, SIZE(clsuff)                                                                  ! grid type
+         DO jh = 1, 12                                                                         ! 1, 2, 3, 4, 6, 12 hours
+            IF( MOD(12,jh) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jh 
+               CALL dia_nam( clname, jh * ihhss, clsuff(jg), ldfsec = .TRUE. )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'h_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+         DO jd = 1, 5, 2                                                                       ! 1, 3, 5 days
+            WRITE(cl1,'(i1)') jd 
+            CALL dia_nam( clname, jd * iddss, clsuff(jg), ldfsec = .TRUE. )
+            CALL event__set_attribut( cl1//'d_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+         END DO
+         DO jm = 1, 6                                                                          ! 1, 2, 3, 4, 6 months
+            IF( MOD(6,jm) == 0 ) THEN 
+               WRITE(cl1,'(i1)') jm 
+               CALL dia_nam( clname, -jm, clsuff(jg) )
+               CALL event__set_attribut( cl1//'m_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+         DO jy = 1, 10                                                                         ! 1, 2, 5, 10 years  
+            IF( MOD(10,jy) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jy 
+               CALL dia_nam( clname, -jy * iyymo, clsuff(jg) )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'y_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
+         END DO
+      END DO
+
+      ! Zooms...
+      clgrd = (/ 'T', 'U', 'W' /) 
+      DO jg = 1, SIZE(clgrd)                                                                   ! grid type
+         cl1 = clgrd(jg)
+         ! Equatorial section (attributs: jbegin, ni, name_suffix)
+         CALL dom_ngb( 0., 0., ix, iy, cl1 )
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__jbegin     , iy     ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__ni         , jpiglo ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( file__name_suffix, '_Eq'  ) )
+      END DO
+      ! TAO moorings (attributs: ibegin, jbegin, name_suffix)
+      zlontao = (/ 137.0, 147.0, 156.0, 165.0, -180.0, -170.0, -155.0, -140.0, -125.0, -110.0, -95.0 /)
+      zlattao = (/  -8.0,  -5.0,  -2.0,   0.0,    2.0,    5.0,    8.0 /)
+      CALL set_mooring( zlontao, zlattao )
+      ! RAMA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonrama = (/  55.0,  67.0, 80.5, 90.0 /)
+      zlatrama = (/ -16.0, -12.0, -8.0, -4.0, -1.5, 0.0, 1.5, 4.0, 8.0, 12.0, 15.0 /)
+      CALL set_mooring( zlonrama, zlatrama )
+      ! PIRATA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonpira = (/ -38.0, -23.0, -10.0 /)
+      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /)
+      CALL set_mooring( zlonpira, zlatpira )
+      
+   END SUBROUTINE set_xmlatt
+
+
+   SUBROUTINE set_mooring( plon, plat)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   automatic definitions of moorings xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(in) ::  plon, plat           ! longitudes/latitudes oft the mooring
+      !
+!!$      CHARACTER(len=1),DIMENSION(4) ::   clgrd = (/ 'T', 'U', 'V', 'W' /)   ! suffix name
+      CHARACTER(len=1),DIMENSION(1) ::   clgrd = (/ 'T' /)        ! suffix name
+      CHARACTER(len=50)             ::   clname                   ! file name
+      CHARACTER(len=1)              ::   cl1                      ! 1 character
+      CHARACTER(len=6)              ::   clon,clat                ! name of longitude, latitude
+      INTEGER                       ::   ji, jj, jg               ! loop counters
+      INTEGER                       ::   ix, iy                   ! i-,j- index
+      REAL(wp)                      ::   zlon, zlat
+      !!----------------------------------------------------------------------
+      DO jg = 1, SIZE(clgrd)
+         cl1 = clgrd(jg)
+         DO ji = 1, SIZE(plon)
+            DO jj = 1, SIZE(plat)
+               zlon = plon(ji)
+               zlat = plat(jj)
+               ! modifications for RAMA moorings
+               IF( zlon ==  67. .AND. zlat ==  15. )   zlon =  65.
+               IF( zlon ==  90. .AND. zlat <=  -4. )   zlon =  95.
+               IF( zlon ==  95. .AND. zlat ==  -4. )   zlat =  -5.
+               ! modifications for PIRATA moorings
+               IF( zlon == -38. .AND. zlat == -19. )   zlon = -34.
+               IF( zlon == -38. .AND. zlat == -14. )   zlon = -32.
+               IF( zlon == -38. .AND. zlat ==  -8. )   zlon = -30.
+               IF( zlon == -38. .AND. zlat ==   0. )   zlon = -35.
+               IF( zlon == -23. .AND. zlat ==  20. )   zlat =  21.
+               IF( zlon == -10. .AND. zlat == -14. )   zlat = -10.
+               IF( zlon == -10. .AND. zlat ==  -8. )   zlat =  -6.
+               IF( zlon == -10. .AND. zlat ==   4. ) THEN   ;   zlon = 0.   ;   zlat = 0.   ;   ENDIF
+               CALL dom_ngb( zlon, zlat, ix, iy, cl1 )
+               IF( zlon >= 0. ) THEN  
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT( zlon), 'e'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')       zlon , 'e'
+                  ENDIF
+               ELSE             
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT(-zlon), 'w'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')      -zlon , 'w'
+                  ENDIF
+               ENDIF
+               IF( zlat >= 0. ) THEN  
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT( zlat), 'n'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')       zlat , 'n'
+                  ENDIF
+               ELSE             
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT(-zlat), 's'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')      -zlat , 's'
+                  ENDIF
+               ENDIF
+               clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__ibegin     , ix                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__jbegin     , iy                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( file__name_suffix, '_'//TRIM(clname) ) )      
+            END DO
+         END DO
+      END DO
+      
+   END SUBROUTINE set_mooring
+
+#else
+
+   SUBROUTINE iom_setkt( kt )
+      INTEGER, INTENT(in   )::   kt 
+      IF( .FALSE. )   WRITE(numout,*) kt   ! useless test to avoid compilation warnings
+   END SUBROUTINE iom_setkt
+
+#endif
+
+
+   !!======================================================================
+END MODULE iom
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 1844)
@@ -0,0 +1,73 @@
+MODULE iom_def
+   !!=====================================================================
+   !!                    ***  MODULE  iom_def ***
+   !! IOM variables definitions
+   !!====================================================================
+   !! History :  9.0  ! 06 09  (S. Masson) Original code
+   !!             "   ! 07 07  (D. Storkey) Add uldname
+   !!--------------------------------------------------------------------
+   !!---------------------------------------------------------------------------------
+   !! OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!---------------------------------------------------------------------------------
+
+   USE par_kind
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_data          = 1   !: ( 1  :jpidta, 1  :jpjdta)
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_global        = 2   !: ( 1  :jpiglo, 1  :jpjglo)
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local         = 3   !: One of the 3 following cases
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_full    = 4   !: ( 1  :jpi   , 1  :jpi   )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noextra = 5   !: ( 1  :nlci  , 1  :nlcj  )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noovlap = 6   !: (nldi:nlei  ,nldj:nlej  )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 7   !: No dimension checking
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo       = 8   !: 
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 9   !: 
+
+   INTEGER, PARAMETER, PUBLIC ::   jpioipsl    = 100      !: Use ioipsl (fliocom only) library
+   INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library
+   INTEGER, PARAMETER, PUBLIC ::   jprstdimg   = 102      !: Use restart dimgs (fortran direct acces) library
+#if defined key_dimgout
+   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jprstdimg  !: restarts io library
+#else
+   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library
+#endif
+
+   INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
+   INTEGER, PARAMETER, PUBLIC ::   jp_r4    = 201      !: write REAL(4)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i4    = 202      !: write INTEGER(4)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i2    = 203      !: write INTEGER(2)
+   INTEGER, PARAMETER, PUBLIC ::   jp_i1    = 204      !: write INTEGER(1)
+
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_files  = 50   !: maximum number of simultaneously opened file
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_vars   = 360  !: maximum number of variables in one file
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_dims   =  4   !: maximum number of dimensions for one variable
+   INTEGER, PARAMETER, PUBLIC ::   jpmax_digits =  5   !: maximum number of digits for the cpu number in the file name
+
+!$AGRIF_DO_NOT_TREAT
+   INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
+
+   TYPE, PUBLIC ::   file_descriptor
+      CHARACTER(LEN=240)                        ::   name     !: name of the file
+      INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
+      INTEGER                                   ::   iolib    !: library used to read the file (jpioipsl, jpnf90 or jprstdimg)
+      INTEGER                                   ::   nvars    !: number of identified varibles in the file
+      INTEGER                                   ::   iduld    !: id of the unlimited dimension
+      INTEGER                                   ::   irec     !: writing record position  
+      CHARACTER(LEN=32)                         ::   uldname  !: name of the unlimited dimension
+      CHARACTER(LEN=32), DIMENSION(jpmax_vars)  ::   cn_var   !: names of the variables
+      INTEGER, DIMENSION(jpmax_vars)            ::   nvid     !: id of the variables
+      INTEGER, DIMENSION(jpmax_vars)            ::   ndims    !: number of dimensions of the variables
+      LOGICAL, DIMENSION(jpmax_vars)            ::   luld     !: variable using the unlimited dimension
+      INTEGER, DIMENSION(jpmax_dims,jpmax_vars) ::   dimsz    !: size of variables dimensions 
+      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
+      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
+   END TYPE file_descriptor
+   TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
+!$AGRIF_END_DO_NOT_TREAT
+
+   !!=====================================================================
+END MODULE iom_def
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_ioipsl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_ioipsl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_ioipsl.F90	(revision 1844)
@@ -0,0 +1,436 @@
+MODULE iom_ioipsl
+   !!=====================================================================
+   !!                    ***  MODULE  iom_ioipsl ***
+   !! Input/Output manager :  Library to read input files with IOIPSL (only fliocom module)
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_ioipsl_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE iom_def         ! iom variables definitions
+   USE ioipsl          ! IOIPSL library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_ioipsl_open, iom_ioipsl_close, iom_ioipsl_varid, iom_ioipsl_get, iom_ioipsl_gettime, iom_ioipsl_rstput
+
+   INTERFACE iom_ioipsl_get
+      MODULE PROCEDURE iom_ioipsl_g0d, iom_ioipsl_g123d
+   END INTERFACE
+   INTERFACE iom_ioipsl_rstput
+      MODULE PROCEDURE iom_ioipsl_rp0123d
+   END INTERFACE
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_ioipsl_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file with IOIPSL (only fliocom module)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! ioipsl identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100) ::   clinfo      ! info character
+      CHARACTER(LEN=10 ) ::   clstatus    ! status of opened file (REPLACE or NEW)
+      INTEGER            ::   iln         ! lengths of character
+      INTEGER            ::   istop       ! temporary storage of nstop
+      INTEGER            ::   ifliodom    ! model domain identifier (see flio_dom_set)
+      INTEGER            ::   ioipslid    ! ioipsl identifier of the opened file
+      INTEGER            ::   jl          ! loop variable
+      LOGICAL            ::   llclobber   ! local definition of ln_clobber
+      !---------------------------------------------------------------------
+
+      clinfo = '                    iom_ioipsl_open ~~~  '
+      istop = nstop
+      !
+      llclobber = ldwrt .AND. ln_clobber
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         !                 ! =============
+         IF( ldwrt ) THEN  ! ... in write mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode'
+            CALL flioopfd( TRIM(cdname), ioipslid, "WRITE" )
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            CALL flioopfd( TRIM(cdname), ioipslid )
+         ENDIF
+      ELSE                 ! the file does not exist
+         !                 ! =============
+         iln = INDEX( cdname, '.nc' )
+         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it...
+            IF( llclobber ) THEN   ;   clstatus = 'REPLACE' 
+            ELSE                   ;   clstatus = 'NEW'
+            ENDIF
+            IF( jpnij > 1 ) THEN
+               ! define the domain position regarding to the global domain (mainly useful in mpp)
+               CALL flio_dom_set( jpnij, narea-1, (/1, 2/), (/jpiglo, jpjglo/)   &
+                  &             , kdompar(:,1), kdompar(:,2), kdompar(:,3), kdompar(:,4), kdompar(:,5)   &
+                  &             , 'BOX', ifliodom )        
+               ! Note that fliocrfd may change the value of cdname (add the cpu number...)
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname(1:iln-1)//'... in WRITE mode'
+               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
+                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid, ifliodom, mode = clstatus )
+            ELSE              ! the file should be open for read mode so it must exist...
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname//' in WRITE mode'
+               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
+                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid,           mode = clstatus )
+            ENDIF
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! start to fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name   = TRIM(cdname)
+         iom_file(kiomid)%nfid   = ioipslid
+         iom_file(kiomid)%iolib  = jpioipsl
+         iom_file(kiomid)%nvars  = 0
+         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files
+         CALL flioinqf( ioipslid, id_uld = iom_file(kiomid)%iduld )
+         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
+      ELSE
+         kiomid = 0               ! return error flag
+      ENDIF
+      !
+   END SUBROUTINE iom_ioipsl_open
+
+
+   SUBROUTINE iom_ioipsl_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_ioipsl_close  ***
+      !!
+      !! ** Purpose : close an input file with IOIPSL (only fliocom module) 
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      !---------------------------------------------------------------------
+      !
+      CALL flioclo( iom_file(kiomid)%nfid )
+      !    
+   END SUBROUTINE iom_ioipsl_close
+
+
+   FUNCTION iom_ioipsl_varid ( kiomid, cdvar, kiv, kdimsz )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file with IOIPSL (only fliocom module)
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER              , INTENT(in   )           ::   kiv   ! 
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      !
+      INTEGER                        ::   iom_ioipsl_varid  ! iom variable Id
+      INTEGER                        ::   ioipslid          ! ioipsl file identifier
+      INTEGER                        ::   ji                ! dummy loop index
+      INTEGER                        ::   i_nvd             ! number of dimension of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   idimid            ! dimension ids of the variable
+      LOGICAL                        ::   ll_fnd            ! found test
+      CHARACTER(LEN=100)             ::   clinfo            ! info character
+      !!-----------------------------------------------------------------------
+      clinfo = 'iom_ioipsl_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
+      iom_ioipsl_varid = 0                  ! default definition
+      IF( PRESENT(kdimsz) ) kdimsz(:) = 0   ! default definition
+      ioipslid = iom_file(kiomid)%nfid      ! get back ioipsl file identifier 
+      CALL flioinqv( ioipslid, cdvar, ll_fnd, nb_dims = i_nvd )   ! does the variable exist in the file
+      IF( ll_fnd ) THEN
+         IF( i_nvd <= jpmax_dims ) THEN
+            iom_ioipsl_varid = kiv
+            iom_file(kiomid)%nvars       = kiv
+            iom_file(kiomid)%nvid(kiv)   = -1   ! variable id is not available in ioipsl
+            iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
+            iom_file(kiomid)%ndims(kiv)  = i_nvd
+            CALL flioinqv( ioipslid, cdvar, ll_fnd,   &
+                  &           len_dims = iom_file(kiomid)%dimsz(1:i_nvd,kiv), &   ! dimensions size
+                  &           id_dims  = idimid(1:i_nvd) )                        ! dimensions ids
+            iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
+            DO ji = 1, i_nvd                       ! find the unlimited dimension
+               IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.
+            END DO
+            !---------- Deal with scale_factor and add_offset
+            CALL flioinqa( ioipslid, cdvar, 'scale_factor', ll_fnd )
+            IF( ll_fnd) THEN
+               CALL fliogeta( ioipslid, cdvar, 'scale_factor', iom_file(kiomid)%scf(kiv) )
+            ELSE
+               iom_file(kiomid)%scf(kiv) = 1.
+            END IF
+            CALL flioinqa( ioipslid, cdvar, 'add_offset', ll_fnd )
+            IF( ll_fnd ) THEN
+               CALL fliogeta( ioipslid, cdvar, 'add_offset', iom_file(kiomid)%ofs(kiv) )
+            ELSE
+               iom_file(kiomid)%ofs(kiv) = 0.
+            END IF
+            ! return the simension size
+            IF( PRESENT(kdimsz) ) THEN 
+               IF( i_nvd == SIZE(kdimsz) ) THEN
+                  kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,kiv)
+               ELSE
+                  WRITE(ctmp1,*) i_nvd, SIZE(kdimsz)
+                  CALL ctl_stop( TRIM(clinfo), 'error in kdimsz size'//TRIM(ctmp1) )
+               ENDIF
+            ENDIF
+         ELSE
+            CALL ctl_stop( TRIM(clinfo), 'Too many dimensions in the file '//iom_file(kiomid)%name,   &
+                  &                       'increase the parameter jpmax_vars')
+         ENDIF
+      ELSE  
+         iom_ioipsl_varid = -1   !   variable not found, return error code: -1
+      ENDIF
+      !
+   END FUNCTION iom_ioipsl_varid
+
+
+   SUBROUTINE iom_ioipsl_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_ioipsl_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with IOIPSL (only fliocom module)
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   kiomid    ! Identifier of the file
+      INTEGER , INTENT(in   ) ::   kvid      ! variable id
+      REAL(wp), INTENT(  out) ::   pvar      ! read field
+      !
+      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), pvar )
+      ! 
+   END SUBROUTINE iom_ioipsl_g0d
+
+
+   SUBROUTINE iom_ioipsl_g123d( kiomid, kvid, knbdim, kstart, kcount, kx1, kx2, ky1, ky2,   &
+         &                      pv_r1d, pv_r2d, pv_r3d)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_ioipsl_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with IOIPSL (only fliocom module)
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kvid       ! Name of the variable
+      INTEGER                    , INTENT(in   )           ::   knbdim     ! number of dimensions of the variable
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kstart     ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kcount     ! number of points to be read in each axis
+      INTEGER ,                    INTENT(in   )           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+      !
+      INTEGER               ::   ioipslid   ! ioipsl file identifier
+      CHARACTER(LEN=100)    ::   clvn       ! variable name
+      !---------------------------------------------------------------------
+      clvn = TRIM(iom_file(kiomid)%cn_var(kvid))   ! get back variable name 
+      ioipslid = iom_file(kiomid)%nfid             ! get back IPIPSL file id
+      !
+      IF( PRESENT(pv_r1d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r1d(:                ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ELSEIF( PRESENT(pv_r2d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ELSEIF( PRESENT(pv_r3d) ) THEN
+         CALL fliogetv( ioipslid, clvn, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim), count = kcount(1:knbdim) )
+      ENDIF
+      !
+      !
+   END SUBROUTINE iom_ioipsl_g123d
+
+
+   SUBROUTINE iom_ioipsl_gettime( kiomid, kvid, ptime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis kvid in the file with IOIPSL (only fliocom module)
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in   ) ::   kiomid     ! file Identifier
+      INTEGER                   , INTENT(in   ) ::   kvid       ! variable id
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdunits    ! units attribute
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdcalendar ! calendar attribute
+      !---------------------------------------------------------------------
+      !
+      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), ptime(:),   &
+            &         start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /) )
+      IF ( PRESENT(cdunits) ) THEN 
+         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "units", cdunits )
+      ENDIF
+      IF ( PRESENT(cdcalendar) ) THEN 
+         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "calendar", cdcalendar )
+      ENDIF
+      !
+   END SUBROUTINE iom_ioipsl_gettime
+
+
+   SUBROUTINE iom_ioipsl_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   &
+         &                                 pv_r0d, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_ioipsl_rstput  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                     , INTENT(in)           ::   kt       ! ocean time-step
+      INTEGER                     , INTENT(in)           ::   kwrite   ! writing time-step
+      INTEGER                     , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)            , INTENT(in)           ::   cdvar    ! variable name
+      INTEGER                     , INTENT(in)           ::   kvid     ! variable id
+      INTEGER                     , INTENT(in), OPTIONAL ::   ktype    ! variable type (default R8)
+      REAL(wp)                    , INTENT(in), OPTIONAL ::   pv_r0d   ! written Od field
+      REAL(wp), DIMENSION(      :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(:, :   ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(:, :, :), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      INTEGER               :: idims                ! number of dimension
+      INTEGER               :: idvar                ! variable id
+      INTEGER               :: itype                ! variable type
+      INTEGER               :: ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER, DIMENSION(4) :: idimsz               ! dimensions size  
+      INTEGER, DIMENSION(4) :: idimid               ! dimensions id
+      CHARACTER(LEN=100)    :: clinfo               ! info character
+      INTEGER               :: ioipslid             ! ioipsl file identifier
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_ioipsl_rp0123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      ioipslid = iom_file(kiomid)%nfid
+      !
+      ! define dimension variables if it is not already done
+      ! ==========================
+      IF( iom_file(kiomid)%nvars == 0 ) THEN
+         ! define the dimension variables if it is not already done
+         CALL fliodefv( ioipslid,'nav_lon', (/1,2/), v_t=flio_r4   , axis='X',   &
+               &                  long_name="Longitude", units="degrees_east" )
+         CALL fliodefv( ioipslid,'nav_lat', (/1,2/), v_t=flio_r4   , axis='Y',   &
+               &                  long_name="Latitude", units="degrees_north" )
+         CALL fliodefv( ioipslid,'nav_lev', (/3/)  , v_t=flio_i4   , axis='Z',   &
+               &                  long_name="Model levels",units="model_levels")
+         CALL fliodefv( ioipslid,'time_counter', (/4/), v_t=flio_r4, axis='T',   &
+               &                  long_name="Time axis", units='seconds since 0001-01-01 00:00:00' )
+         ! update informations structure related the dimension variable we just added...
+         iom_file(kiomid)%nvars       = 4
+         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
+         iom_file(kiomid)%cn_var(1:3) = (/ 'nav_lon', 'nav_lat', 'nav_lev' /)
+         iom_file(kiomid)%cn_var(4)   = 'time_counter'
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
+         ! trick: defined to 0 to say that dimension variables are defined but not yet written
+         iom_file(kiomid)%dimsz(1, 1) = 0   
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
+      ENDIF
+
+      ! define the data if it is not already done
+      ! ===============
+      IF( kvid <= 0 ) THEN
+         ! variable definition
+         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ENDIF
+         IF( PRESENT(ktype) ) THEN   ! variable external type
+            SELECT CASE (ktype)
+            CASE (jp_r8)  ;   itype = flio_r8
+            CASE (jp_r4)  ;   itype = flio_r4
+            CASE (jp_i4)  ;   itype = flio_i4
+            CASE (jp_i2)  ;   itype = flio_i2
+            CASE (jp_i1)  ;   itype = flio_i1   !   fliocom does not handle i1 type of variable
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
+            END SELECT
+         ELSE
+            itype = flio_r8
+         ENDIF
+         IF( PRESENT(pv_r0d) ) THEN   ;   CALL fliodefv (ioipslid, TRIM(cdvar)                 , v_t = itype)
+         ELSE                         ;   CALL fliodefv (ioipslid, TRIM(cdvar), idimid(1:idims), v_t = itype)
+         ENDIF
+         ! update informations structure related the new variable we want to add...
+         idvar                          = iom_file(kiomid)%nvars + 1
+         iom_file(kiomid)%nvars         = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(idvar)   = -1   ! netcdf variable id is not available in ioipsl
+         iom_file(kiomid)%scf(idvar)    = 1.
+         iom_file(kiomid)%ofs(idvar)    = 0.
+         iom_file(kiomid)%ndims(idvar)  = idims
+         IF( .NOT. PRESENT(pv_r0d) ) THEN
+            iom_file(kiomid)%luld(idvar) = .TRUE.
+            CALL flioinqf( ioipslid, ln_dim = idimsz )
+            iom_file(kiomid)%dimsz(1:idims-1,idvar) = idimsz(idimid(1:idims-1))
+         ELSE                               
+            iom_file(kiomid)%luld(idvar) = .FALSE.
+         ENDIF
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' defined ok'
+      ELSE
+         idvar = kvid
+      ENDIF
+
+      ! time step kwrite : write the variable
+      IF( kt == kwrite ) THEN
+         ! on what kind of domain must the data be written?
+         IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
+            idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
+            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
+               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
+               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
+               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+            ELSE 
+               CALL ctl_stop( 'iom_ioipsl_rp0123d: should have been an impossible case...' )
+            ENDIF
+
+            ! write dimension variables if it is not already done
+            ! =============
+            ! trick: is defined to 0 => dimension variable are defined but not yet written
+            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
+               CALL flioputv( ioipslid, 'nav_lon'     , glamt(ix1:ix2, iy1:iy2) )
+               CALL flioputv( ioipslid, 'nav_lat'     , gphit(ix1:ix2, iy1:iy2) )
+               CALL flioputv( ioipslid, 'nav_lev'     , gdept_0 )
+               ! +++ WRONG VALUE: to be improved but not really useful...
+               CALL flioputv( ioipslid, 'time_counter', kt )
+               ! update the values of the variables dimensions size
+               CALL flioinqf( ioipslid, ln_dim = idimsz )
+               iom_file(kiomid)%dimsz(1:2, 1) = idimsz(1:2)
+               iom_file(kiomid)%dimsz(1:2, 2) = idimsz(1:2)
+               iom_file(kiomid)%dimsz(1, 3:4) = (/idimsz(3), 1/)
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
+            ENDIF
+         ENDIF
+
+         ! write the data
+         ! =============
+         IF(     PRESENT(pv_r0d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r0d                      )
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r1d(                  :) )
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r2d(ix1:ix2, iy1:iy2   ) )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r3d(ix1:ix2, iy1:iy2, :) )
+         ENDIF
+         ! add 1 to the size of the temporal dimension (not really useful...)
+         IF( iom_file(kiomid)%luld(idvar) )   iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar)    &
+               &                            = iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar) + 1
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_ioipsl_rp0123d
+
+
+   !!======================================================================
+END MODULE iom_ioipsl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 1844)
@@ -0,0 +1,501 @@
+MODULE iom_nf90
+   !!=====================================================================
+   !!                    ***  MODULE  iom_nf90 ***
+   !! Input/Output manager :  Library to read input files with NF90 (only fliocom module)
+   !!====================================================================
+   !! History :  9.0  ! 05 12  (J. Belier) Original code
+   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
+   !!             "   ! 07 07  (D. Storkey) Changes to iom_nf90_gettime
+   !!--------------------------------------------------------------------
+   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+   USE netcdf          ! NetCDF library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_nf90_open, iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput
+
+   INTERFACE iom_nf90_get
+      MODULE PROCEDURE iom_nf90_g0d, iom_nf90_g123d
+   END INTERFACE
+   INTERFACE iom_nf90_rstput
+      MODULE PROCEDURE iom_nf90_rp0123d
+   END INTERFACE
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose : open an input file with NF90
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! nf90 identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100) ::   clinfo           ! info character
+      CHARACTER(LEN=100) ::   cltmp            ! temporary character
+      INTEGER            ::   iln              ! lengths of character
+      INTEGER            ::   istop            ! temporary storage of nstop
+      INTEGER            ::   if90id           ! nf90 identifier of the opened file
+      INTEGER            ::   idmy             ! dummy variable
+      INTEGER            ::   jl               ! loop variable
+      INTEGER            ::   ichunk           ! temporary storage of nn_chunksz
+      INTEGER            ::   imode            ! creation mode flag: NF90_CLOBBER or NF90_NOCLOBBER
+      LOGICAL            ::   llclobber        ! local definition of ln_clobber
+      !---------------------------------------------------------------------
+
+      clinfo = '                    iom_nf90_open ~~~  '
+      istop = nstop   ! store the actual value of nstop
+      IF( nn_chunksz > 0 ) THEN   ;   ichunk = nn_chunksz
+      ELSE                        ;   ichunk = NF90_SIZEHINT_DEFAULT
+      ENDIF
+      !
+      llclobber = ldwrt .AND. ln_clobber
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         !                 ! =============
+         IF( ldwrt ) THEN  ! ... in write mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode'
+            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_WRITE  , if90id, chunksize = ichunk ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                          ), clinfo)
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo)
+         ENDIF
+      ELSE                                       ! the file does not exist (or we overwrite it)
+         !                 ! =============
+         iln = INDEX( cdname, '.nc' )
+         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it...
+            IF( jpnij > 1 ) THEN
+               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea-1, '.nc'
+               cdname = TRIM(cltmp)
+            ENDIF
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in WRITE mode'
+
+            IF( llclobber ) THEN   ;   imode = NF90_CLOBBER 
+            ELSE                   ;   imode = NF90_NOCLOBBER 
+            ENDIF
+            CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                     ), clinfo)
+            ! define dimensions
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x', kdompar(1,1)  , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y', kdompar(2,1)  , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', jpk           , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 't', NF90_UNLIMITED, idmy ), clinfo)
+            ! global attributes
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_local'     , kdompar(:,1)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_first' , kdompar(:,2)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_last'  , kdompar(:,3)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_start', kdompar(:,4)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , kdompar(:,5)       ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              ), clinfo)
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! start to fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name   = TRIM(cdname)
+         iom_file(kiomid)%nfid   = if90id
+         iom_file(kiomid)%iolib  = jpnf90
+         iom_file(kiomid)%nvars  = 0
+         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
+         CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
+         IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN
+           CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,   &
+        &                                               name = iom_file(kiomid)%uldname), clinfo)
+         ENDIF
+         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
+      ELSE
+         kiomid = 0               ! return error flag
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_open
+
+
+   SUBROUTINE iom_nf90_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_nf90_close  ***
+      !!
+      !! ** Purpose : close an input file with NF90
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      CHARACTER(LEN=100)  ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      !
+      clinfo = '      iom_nf90_close    , file: '//TRIM(iom_file(kiomid)%name)
+      CALL iom_nf90_check(NF90_CLOSE(iom_file(kiomid)%nfid), clinfo)
+      !    
+   END SUBROUTINE iom_nf90_close
+
+
+   FUNCTION iom_nf90_varid ( kiomid, cdvar, kiv, kdimsz )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file with NF90
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER              , INTENT(in   )           ::   kiv   ! 
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      !
+      INTEGER                        ::   iom_nf90_varid   ! iom variable Id
+      INTEGER                        ::   if90id           ! nf90 file identifier
+      INTEGER                        ::   ji               ! dummy loop index
+      INTEGER                        ::   ivarid           ! NetCDF  variable Id
+      INTEGER                        ::   i_nvd            ! number of dimension of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   idimid           ! dimension ids of the variable
+      LOGICAL                        ::   llok             ! ok  test
+      CHARACTER(LEN=100)             ::   clinfo           ! info character
+      !!-----------------------------------------------------------------------
+      clinfo = '          iom_nf90_varid, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      iom_nf90_varid = 0                    ! default definition
+      IF( PRESENT(kdimsz) ) kdimsz(:) = 0   ! default definition
+      if90id = iom_file(kiomid)%nfid        ! get back NetCDF file id
+      !
+      llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! does the variable exist in the file
+      IF( llok ) THEN
+         iom_nf90_varid = kiv
+         iom_file(kiomid)%nvars       = kiv
+         iom_file(kiomid)%nvid(kiv)   = ivarid
+         iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
+         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, ndims = i_nvd), clinfo)   ! number of dimensions
+         iom_file(kiomid)%ndims(kiv)  = i_nvd
+         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, dimids = idimid(1:i_nvd)), clinfo)   ! dimensions ids
+         iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
+         DO ji = 1, i_nvd                       ! dimensions size
+            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)   
+            IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.   ! unlimited dimension? 
+         END DO
+         !---------- Deal with scale_factor and add_offset
+         llok = NF90_Inquire_attribute(if90id, ivarid, 'scale_factor') == nf90_noerr
+         IF( llok) THEN
+            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'scale_factor', iom_file(kiomid)%scf(kiv)), clinfo)
+         ELSE
+            iom_file(kiomid)%scf(kiv) = 1.
+         END IF
+         llok = NF90_Inquire_attribute(if90id, ivarid, 'add_offset') == nf90_noerr
+         IF( llok ) THEN
+            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'add_offset', iom_file(kiomid)%ofs(kiv)), clinfo)
+         ELSE
+            iom_file(kiomid)%ofs(kiv) = 0.
+         END IF
+         ! return the simension size
+         IF( PRESENT(kdimsz) ) THEN 
+            IF( i_nvd == SIZE(kdimsz) ) THEN
+               kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,kiv)
+            ELSE
+               WRITE(ctmp1,*) i_nvd, SIZE(kdimsz)
+               CALL ctl_stop( TRIM(clinfo), 'error in kdimsz size'//TRIM(ctmp1) )
+            ENDIF
+         ENDIF
+      ELSE  
+         iom_nf90_varid = -1   !   variable not found, return error code: -1
+      ENDIF
+      !
+   END FUNCTION iom_nf90_varid
+
+
+   SUBROUTINE iom_nf90_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with NF90
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   kiomid   ! Identifier of the file
+      INTEGER , INTENT(in   ) ::   kvid     ! variable id
+      REAL(wp), INTENT(  out) ::   pvar     ! read field
+      !
+      CHARACTER(LEN=100)      ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_g0d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), pvar), clinfo )
+      ! 
+   END SUBROUTINE iom_nf90_g0d
+
+
+   SUBROUTINE iom_nf90_g123d( kiomid, kvid, knbdim, kstart, kcount, kx1, kx2, ky1, ky2,   &
+         &                    pv_r1d, pv_r2d, pv_r3d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with NF90
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid    ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kvid      ! Name of the variable
+      INTEGER                    , INTENT(in   )           ::   knbdim    ! number of dimensions of the variable
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kstart    ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kcount    ! number of points to be read in each axis
+      INTEGER ,                    INTENT(in   )           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d    ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d    ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d    ! read field (3D case)
+      !
+      CHARACTER(LEN=100) ::   clinfo               ! info character
+      INTEGER            ::   if90id               ! nf90 identifier of the opened file
+      INTEGER            ::   ivid                 ! nf90 variable id
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_g123d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      if90id = iom_file(kiomid)%nfid         ! get back NetCDF file id
+      ivid   = iom_file(kiomid)%nvid(kvid)   ! get back NetCDF var id
+      !
+      IF(     PRESENT(pv_r1d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r1d(:                ), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ELSEIF( PRESENT(pv_r2d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ELSEIF( PRESENT(pv_r3d) ) THEN
+         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim),   &
+            &                                                                       count = kcount(1:knbdim)), clinfo )
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_g123d
+
+
+   SUBROUTINE iom_nf90_gettime( kiomid, kvid, ptime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis kvid in the file with NF90
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in   ) ::   kiomid     ! file Identifier
+      INTEGER                   , INTENT(in   ) ::   kvid       ! variable id
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdunits    ! units attribute
+      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdcalendar ! calendar attribute
+      !
+      CHARACTER(LEN=100) ::   clinfo     ! info character
+      !---------------------------------------------------------------------
+      clinfo = 'iom_nf90_gettime, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
+      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), ptime(:),   &
+            &                           start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /)), clinfo)
+      IF ( PRESENT(cdunits) ) THEN 
+         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "units", &
+            &                           values=cdunits), clinfo)
+      ENDIF
+      IF ( PRESENT(cdcalendar) ) THEN 
+         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "calendar", &
+            &                           values=cdcalendar), clinfo)
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_gettime
+
+
+   SUBROUTINE iom_nf90_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   &
+         &                               pv_r0d, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_nf90_rstput  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                     , INTENT(in)           ::   kt       ! ocean time-step
+      INTEGER                     , INTENT(in)           ::   kwrite   ! writing time-step
+      INTEGER                     , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)            , INTENT(in)           ::   cdvar    ! variable name
+      INTEGER                     , INTENT(in)           ::   kvid     ! variable id
+      INTEGER                     , INTENT(in), OPTIONAL ::   ktype    ! variable type (default R8)
+      REAL(wp)                    , INTENT(in), OPTIONAL ::   pv_r0d   ! written Od field
+      REAL(wp), DIMENSION(      :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(:, :   ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(:, :, :), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      INTEGER               :: idims                ! number of dimension
+      INTEGER               :: idvar                ! variable id
+      INTEGER               :: jd                   ! dimension loop counter   
+      INTEGER               :: ix1, ix2, iy1, iy2   ! subdomain indexes   
+      INTEGER, DIMENSION(4) :: idimsz               ! dimensions size  
+      INTEGER, DIMENSION(4) :: idimid               ! dimensions id
+      CHARACTER(LEN=100)    :: clinfo               ! info character
+      CHARACTER(LEN= 12), DIMENSION(4) :: cltmp     ! temporary character
+      INTEGER               :: if90id               ! nf90 file identifier
+      INTEGER               :: idmy                 ! dummy variable
+      INTEGER               :: itype                ! variable type
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_nf90_rp0123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      if90id = iom_file(kiomid)%nfid
+      !
+      ! define dimension variables if it is not already done
+      ! ==========================
+      IF( iom_file(kiomid)%nvars == 0 ) THEN
+         ! are we in define mode?
+         IF( iom_file(kiomid)%irec /= -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = -1
+         ENDIF
+         ! define the dimension variables if it is not already done
+         cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(3)), NF90_FLOAT , (/ 3    /), iom_file(kiomid)%nvid(3) ), clinfo)
+         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(4)), NF90_DOUBLE, (/ 4    /), iom_file(kiomid)%nvid(4) ), clinfo)
+         ! update informations structure related the dimension variable we just added...
+         iom_file(kiomid)%nvars       = 4
+         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
+         iom_file(kiomid)%cn_var(1:4) = cltmp
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)  
+         ! trick: defined to 0 to say that dimension variables are defined but not yet written
+         iom_file(kiomid)%dimsz(1, 1)  = 0   
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
+      ENDIF
+      ! define the data if it is not already done
+      ! ===============
+      IF( kvid <= 0 ) THEN
+         idvar = iom_file(kiomid)%nvars + 1
+         ! are we in define mode?
+         IF( iom_file(kiomid)%irec /= -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = -1
+         ENDIF
+         ! variable definition
+         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
+         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ENDIF
+         IF( PRESENT(ktype) ) THEN   ! variable external type
+            SELECT CASE (ktype)
+            CASE (jp_r8)  ;   itype = NF90_DOUBLE
+            CASE (jp_r4)  ;   itype = NF90_FLOAT
+            CASE (jp_i4)  ;   itype = NF90_INT
+            CASE (jp_i2)  ;   itype = NF90_SHORT
+            CASE (jp_i1)  ;   itype = NF90_BYTE
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
+            END SELECT
+         ELSE
+            itype = NF90_DOUBLE
+         ENDIF
+         IF( PRESENT(pv_r0d) ) THEN
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype,                    &
+                 &                            iom_file(kiomid)%nvid(idvar) ), clinfo)
+         ELSE
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype, idimid(1:idims),   &
+                 &                            iom_file(kiomid)%nvid(idvar) ), clinfo)
+         ENDIF
+         ! update informations structure related the new variable we want to add...
+         iom_file(kiomid)%nvars         = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%scf(idvar)    = 1.
+         iom_file(kiomid)%ofs(idvar)    = 0.
+         iom_file(kiomid)%ndims(idvar)  = idims
+         IF( .NOT. PRESENT(pv_r0d) ) THEN   ;   iom_file(kiomid)%luld(idvar) = .TRUE.
+         ELSE                               ;   iom_file(kiomid)%luld(idvar) = .FALSE.
+         ENDIF
+         DO jd = 1, idims
+            CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, idimid(jd), len = iom_file(kiomid)%dimsz(jd,idvar) ), clinfo)
+         END DO
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' defined ok'
+      ELSE
+         idvar = kvid
+      ENDIF
+
+      ! time step kwrite : write the variable
+      IF( kt == kwrite ) THEN
+         ! are we in write mode?
+         IF( iom_file(kiomid)%irec == -1 ) THEN   ! trick: irec used to know if the file is in define mode or not
+            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)   ;   iom_file(kiomid)%irec = 0
+         ENDIF
+         ! on what kind of domain must the data be written?
+         IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
+            idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
+            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
+               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
+               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
+               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+            ELSE 
+               CALL ctl_stop( 'iom_nf90_rp0123d: should have been an impossible case...' )
+            ENDIF
+
+            ! write dimension variables if it is not already done
+            ! =============
+            ! trick: is defined to 0 => dimension variable are defined but not yet written
+            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lon'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, glamt(ix1:ix2, iy1:iy2) ), clinfo)
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lat'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo)
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gdept_0                 ), clinfo)
+               ! +++ WRONG VALUE: to be improved but not really useful...
+               CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo)
+               CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, kt                      ), clinfo)   
+               ! update the values of the variables dimensions size
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 1, len = iom_file(kiomid)%dimsz(1,1) ), clinfo)
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 2, len = iom_file(kiomid)%dimsz(2,1) ), clinfo)
+               iom_file(kiomid)%dimsz(1:2, 2) = iom_file(kiomid)%dimsz(1:2, 1)
+               CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 3, len = iom_file(kiomid)%dimsz(1,3) ), clinfo)
+               iom_file(kiomid)%dimsz(1  , 4) = 1   ! unlimited dimension
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
+            ENDIF
+         ENDIF
+
+         ! write the data
+         ! =============
+         IF(     PRESENT(pv_r0d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r0d                      ), clinfo)
+         ELSEIF( PRESENT(pv_r1d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r1d(                  :) ), clinfo)
+         ELSEIF( PRESENT(pv_r2d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r2d(ix1:ix2, iy1:iy2   ) ), clinfo)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r3d(ix1:ix2, iy1:iy2, :) ), clinfo)
+         ENDIF
+         ! add 1 to the size of the temporal dimension (not really useful...)
+         IF( iom_file(kiomid)%luld(idvar) )   iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar)    &
+               &                            = iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar) + 1
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_nf90_rp0123d
+
+
+   SUBROUTINE iom_nf90_check( kstatus, cdinfo )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_nf90_check  ***
+      !!
+      !! ** Purpose :   check nf90 errors
+      !!--------------------------------------------------------------------
+      INTEGER,          INTENT(in) :: kstatus
+      CHARACTER(LEN=*), INTENT(in) :: cdinfo
+      !---------------------------------------------------------------------
+      IF(kstatus /= nf90_noerr)   CALL ctl_stop( 'iom_nf90_check : '//TRIM(nf90_strerror(kstatus)), TRIM(cdinfo) )
+   END SUBROUTINE iom_nf90_check
+
+
+   !!======================================================================
+END MODULE iom_nf90
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_rstdimg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_rstdimg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/iom_rstdimg.F90	(revision 1844)
@@ -0,0 +1,503 @@
+MODULE iom_rstdimg
+   !!=====================================================================
+   !!                    ***  MODULE  iom_rstdimg ***
+   !! Input/Output manager :  Library to read input rstdimg files
+   !!====================================================================
+   !! History :  9.0  ! 06 09  (S. Masson) Original code
+   !!--------------------------------------------------------------------
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis kvid in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC iom_rstdimg_open, iom_rstdimg_close, iom_rstdimg_get, iom_rstdimg_rstput
+
+   INTERFACE iom_rstdimg_get
+      MODULE PROCEDURE iom_rstdimg_g0d, iom_rstdimg_g123d
+   END INTERFACE
+   INTERFACE iom_rstdimg_rstput
+      MODULE PROCEDURE iom_rstdimg_rp0d, iom_rstdimg_rp123d
+   END INTERFACE
+
+   INTEGER, PARAMETER ::   jpvnl          = 32   ! variable name length
+      
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_rstdimg_open( cdname, kiomid, ldwrt, ldok, kdompar )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file read only (return 0 if not found)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
+      INTEGER                , INTENT(  out)           ::   kiomid      ! iom identifier of the opened file
+      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
+      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
+      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
+
+      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
+      CHARACTER(LEN=100)                      ::   cltmp                      ! temporary character
+      CHARACTER(LEN=10 )                      ::   clstatus                   ! status of opened file (REPLACE or NEW)
+      INTEGER                                 ::   jv                         ! loop counter
+      INTEGER                                 ::   istop                      ! temporary storage of nstop
+      INTEGER                                 ::   idrst                      ! logical unit of the restart file
+      INTEGER                                 ::   iln                        ! lengths of character
+      INTEGER                                 ::   irecl8                     ! record length
+      INTEGER                                 ::   ios                        ! IO status
+      INTEGER                                 ::   irhd                       ! record of the header infos
+      INTEGER                                 ::   ivnum                      ! number of variables
+      INTEGER                                 ::   ishft                      ! counter shift
+      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
+      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
+      INTEGER                                 ::   ipni, ipnj, ipnij, iarea   ! domain decomposition 
+      INTEGER                                 ::   iiglo, ijglo               ! domain global size 
+      INTEGER                                 ::   jl                         ! loop variable
+      LOGICAL                                 ::   llclobber                  ! local definition of ln_clobber
+      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d     ! name of 0/1/2/3D variables
+      REAL(wp),             DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d     ! value of 0d variables or record
+      !                                                                                   ! position for 1/2/3D variables
+      !---------------------------------------------------------------------
+      clinfo = '                    iom_rstdimg_open ~~~  '
+      istop = nstop      ! store the actual value of nstop
+      ios = 0            ! default definition
+      kiomid = 0         ! default definition
+      llclobber = ldwrt .AND. ln_clobber
+      ! get a free unit
+      idrst = getunit()  ! get a free logical unit for the restart file
+!!$#if defined key_agrif 
+!!$      idrst = Agrif_Get_Unit()      
+!!$#endif 
+      ! Open the file...
+      ! =============
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
+         ! find the record length
+         OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+            &       , RECL = 8, STATUS = 'old', ACTION = 'read', IOSTAT = ios, ERR = 987 )
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8
+         CLOSE( idrst )
+         ! Open the file with the appropriate record length and parameters
+         IF( ldwrt ) THEN  ! ... in readwrite mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READWRITE mode'
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+               &       , RECL = irecl8, STATUS = 'old', ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
+         ELSE              ! ... in read mode
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
+               &       , RECL = irecl8, STATUS = 'old', ACTION = 'read'     , IOSTAT = ios, ERR = 987 )
+         ENDIF
+      ELSE                                       ! the file does not exist (or we overwrite it)
+         iln = INDEX( cdname, '.dimg' )
+         IF( ldwrt ) THEN  ! the file should be open in readwrite mode so we create it...
+            irecl8= MAX( kdompar(1,1) * kdompar(2,1) * wp, ( 8*jpnij + 15 ) * 4 )
+            IF( jpnij > 1 ) THEN
+               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea, '.dimg'
+               cdname = TRIM(cltmp)
+            ENDIF
+            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in READWRITE mode'
+            
+            IF( llclobber ) THEN   ;   clstatus = 'REPLACE' 
+            ELSE                   ;   clstatus = 'NEW'
+            ENDIF
+            OPEN( idrst, FILE = TRIM(cdname), FORM = 'UNFORMATTED', ACCESS = 'DIRECT'   &
+               &       , RECL = irecl8, STATUS = TRIM(clstatus), ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
+         ELSE              ! the file should be open for read mode so it must exist...
+            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
+         ENDIF
+      ENDIF
+      ! Performs checks on the file
+      ! =============
+      IF( ldok .AND. .NOT. llclobber ) THEN      ! old file
+         READ( idrst, REC = 1   , IOSTAT = ios, ERR = 987 )              &
+              &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
+              &   ipni, ipnj, ipnij, iarea, iiglo, ijglo
+         READ( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                       &
+            &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
+            &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
+         clinfo = TRIM(clinfo)//' file '//TRIM(cdname)
+         IF( iiglo /= jpiglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in i direction' )
+         IF( ijglo /= jpjglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in j direction' )
+         IF( ldwrt ) THEN
+            IF( inx   /= kdompar(1,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in i direction' )
+            IF( iny   /= kdompar(2,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in j direction' )
+         ENDIF
+         IF( inz   /= jpk          )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in domain size in k direction' )
+         IF( ipni  /= jpni         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along I' )
+         IF( ipnj  /= jpnj         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along J' )
+         IF( ipnij /= jpnij        )   CALL ctl_stop( TRIM(clinfo), 'Total number of processors changed' )
+         IF( iarea /= narea        )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in area numbering ...' )
+      ENDIF
+      ! fill file informations
+      ! =============
+      IF( istop == nstop ) THEN   ! no error within this routine
+!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
+         kiomid = 0
+         DO jl = jpmax_files, 1, -1
+            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
+         ENDDO
+         iom_file(kiomid)%name    = TRIM(cdname)
+         iom_file(kiomid)%nfid    = idrst
+         iom_file(kiomid)%iolib   = jprstdimg
+         iom_file(kiomid)%iduld   = -1
+         IF( ldok ) THEN      ! old file
+            ! read variables informations from the file header
+            IF(  TRIM(clna0d(1)) == 'no0d' )   in0d = 0
+            IF(  TRIM(clna1d(1)) == 'no1d' )   in1d = 0
+            IF(  TRIM(clna2d(1)) == 'no2d' )   in2d = 0
+            IF(  TRIM(clna3d(1)) == 'no3d' )   in3d = 0
+            ivnum = in0d + in1d + in2d + in3d
+            iom_file(kiomid)%nvars            = ivnum
+            iom_file(kiomid)%irec             = 2 + in1d + in2d + inz * in3d
+            iom_file(kiomid)%luld(   1:ivnum) = .FALSE.
+            iom_file(kiomid)%scf(    1:ivnum) = 1.
+            ! scalar variable
+            DO jv = 1, in0d
+               iom_file(kiomid)%cn_var(jv) = TRIM(clna0d(jv))
+               iom_file(kiomid)%nvid(  jv) = 1
+               iom_file(kiomid)%ndims( jv) = 0
+               iom_file(kiomid)%ofs(   jv) = zval0d(jv)   ! warning: trick... we use ofs to store the value
+            END DO
+            ! 1d variable
+            ishft = in0d
+            DO jv = 1, in1d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna1d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval1d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 1
+               iom_file(kiomid)%dimsz(1  , ishft + jv) = jpk
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+            ! 2d variable
+            ishft = in0d + in1d
+            DO jv = 1, in2d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna2d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval2d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 2
+               iom_file(kiomid)%dimsz(1:2, ishft + jv) = (/ inx, iny /)
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+            ! 3d variable
+            ishft = in0d + in1d + in2d 
+            DO jv = 1, in3d
+               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna3d(jv))
+               iom_file(kiomid)%nvid(      ishft + jv) = zval3d(jv)
+               iom_file(kiomid)%ndims(     ishft + jv) = 3
+               iom_file(kiomid)%dimsz(1:3, ishft + jv) = (/ inx, iny, jpk /)
+               iom_file(kiomid)%ofs(       ishft + jv) = 0.
+            END DO
+         ELSE                 ! new file
+            iom_file(kiomid)%nvars = 0
+            iom_file(kiomid)%irec  = 2
+            ! store file informations
+            WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, kdompar(:,1), jpk   ! store domain size
+         ENDIF
+      ENDIF
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo), '   error in opening file '//TRIM(cdname), ctmp1 )
+      ENDIF
+      !
+   END SUBROUTINE iom_rstdimg_open
+
+
+   SUBROUTINE iom_rstdimg_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_close  ***
+      !!
+      !! ** Purpose : close an input file
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
+      !
+      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
+      INTEGER                                 ::   jv                         ! loop counter
+      INTEGER                                 ::   irecl8                     ! record length
+      INTEGER                                 ::   ios                        ! IO status
+      INTEGER                                 ::   irhd                       ! record of the header infos
+      INTEGER                                 ::   ivnum                      ! number of variables
+      INTEGER                                 ::   idrst                      ! file logical unit
+      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
+      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
+      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d    ! name of 0/1/2/3D variables
+      REAL(wp),          DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d    ! value of 0d variables or record
+      !                                                                               ! position for 1/2/3D variables
+      !---------------------------------------------------------------------
+      !
+      clinfo = '                    iom_rstdimg_close ~~~  '
+      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+      ! test if we can write in the file (test with INQUIRE gives alsways YES even with read only files...)
+      READ(  idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   
+      WRITE( idrst, REC = 1, IOSTAT = ios            ) irecl8, inx, iny, inz   
+      ! We can write in the file => we update its header before closing
+      IF( ios == 0 ) THEN
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   ! get back domain size
+         irhd = iom_file(kiomid)%irec
+         ivnum = iom_file(kiomid)%nvars
+         in0d = 0   ;   in1d = 0   ;   in2d = 0   ;   in3d = 0
+         DO jv = 1, ivnum   ! loop on each variable to get its name and value/record position
+            SELECT CASE (iom_file(kiomid)%ndims(jv))
+            CASE (0)   ! scalar variable
+               in0d = in0d + 1
+               clna0d(in0d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval0d(in0d) = iom_file(kiomid)%ofs(jv)   ! warning: trick... we use ofs to store the value
+            CASE (1)   ! 1d variable
+               in1d = in1d + 1
+               clna1d(in1d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval1d(in1d) = iom_file(kiomid)%nvid(jv)
+            CASE (2)   ! 2d variable
+               in2d = in2d + 1
+               clna2d(in2d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval2d(in2d) = iom_file(kiomid)%nvid(jv)
+            CASE (3)   ! 3d variable
+               in3d = in3d + 1
+               clna3d(in3d) = TRIM(iom_file(kiomid)%cn_var(jv))
+               zval3d(in3d) = iom_file(kiomid)%nvid(jv)
+            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo), 'Should not ne there...' )
+            END SELECT
+         END DO
+         ! force to have at least 1 variable in each list (not necessary (?), but safer...)
+         IF( in0d == 0 ) THEN   ;   in0d = 1   ;   clna0d(1) = 'no0d'   ;   zval0d(1) = -1.   ;   ENDIF
+         IF( in1d == 0 ) THEN   ;   in1d = 1   ;   clna1d(1) = 'no1d'   ;   zval1d(1) = -1.   ;   ENDIF
+         IF( in2d == 0 ) THEN   ;   in2d = 1   ;   clna2d(1) = 'no2d'   ;   zval2d(1) = -1.   ;   ENDIF
+         IF( in3d == 0 ) THEN   ;   in3d = 1   ;   clna3d(1) = 'no3d'   ;   zval3d(1) = -1.   ;   ENDIF
+         ! update the file header before closing it
+         WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 )              &
+            &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
+            &   jpni, jpnj, jpnij, narea, jpiglo, jpjglo,              &
+            &   nlcit, nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
+         IF( (ivnum * (jpvnl + wp)) > irecl8 ) THEN 
+            CALL ctl_stop( TRIM(clinfo),   &
+                 &   'Last record size is too big... You could reduce the value of jpvnl' )
+         ELSE 
+            WRITE( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                        &
+                 &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
+                 &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
+         ENDIF
+      ELSE
+         ios = 0   ! we cannot write in the file
+      ENDIF
+      !
+      CLOSE( idrst, IOSTAT = ios, ERR = 987 )
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo),   &
+            &   '   error when updating the header of '//TRIM(iom_file(kiomid)%name), ctmp1 )
+      ENDIF
+      !    
+   END SUBROUTINE iom_rstdimg_close
+
+
+   SUBROUTINE iom_rstdimg_g0d( kiomid, kvid, pvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_rstdimg_g0d  ***
+      !!
+      !! ** Purpose : read a scalar with RSTDIMG
+      !!-----------------------------------------------------------------------
+      INTEGER,  INTENT(in   ) ::   kiomid    ! Identifier of the file
+      INTEGER,  INTENT(in   ) ::   kvid      ! variable id
+      REAL(wp), INTENT(  out) ::   pvar      ! read field
+      !---------------------------------------------------------------------
+      !
+      pvar = iom_file(kiomid)%ofs(kvid)   ! warning: trick... we use ofs to store the value
+      !
+   END SUBROUTINE iom_rstdimg_g0d
+
+
+   SUBROUTINE iom_rstdimg_rp0d( kiomid, cdvar, kvid, pv_r0d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
+      !!
+      !! ** Purpose : write a scalar with RSTDIMG
+      !!--------------------------------------------------------------------
+      INTEGER                   , INTENT(in) ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)          , INTENT(in) ::   cdvar    ! time axis name
+      INTEGER                   , INTENT(in) ::   kvid     ! variable id
+      REAL(wp)                  , INTENT(in) ::   pv_r0d   ! written 0d field
+      !
+      CHARACTER(LEN=100) ::   clinfo     ! info character
+      INTEGER            ::   idvar      ! variable id
+      !---------------------------------------------------------------------
+      !  
+      clinfo = '                    iom_rstdimg_rp0d ~~~  '
+      IF( kvid <= 0 ) THEN   !   new variable
+         idvar = iom_file(kiomid)%nvars + 1
+      ELSE                   !   the variable already exists in the file
+         idvar = kvid
+      ENDIF
+      IF( idvar <= jpmax_vars ) THEN
+         iom_file(kiomid)%nvars = idvar
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(   idvar) = 1   ! useless, Od variables a strored in record 1
+         iom_file(kiomid)%ndims(  idvar) = 0
+         iom_file(kiomid)%luld(   idvar) = .FALSE.
+         iom_file(kiomid)%scf(    idvar) = 1.
+         iom_file(kiomid)%ofs(    idvar) = pv_r0d   ! warning: trick... we use ofs to store the value
+      ELSE
+         CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
+      ENDIF
+   END SUBROUTINE iom_rstdimg_rp0d
+
+
+   SUBROUTINE iom_rstdimg_g123d( kiomid, kdom  , kvid, kx1, kx2, ky1, ky2,   &
+         &                       pv_r1d, pv_r2d, pv_r3d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_rstdimg_g123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable with RSTDIMG
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
+      INTEGER                    , INTENT(in   )           ::   kvid       ! variable id
+      INTEGER ,                    INTENT(inout)           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+
+      CHARACTER(LEN=100) ::   clinfo               ! info character
+      INTEGER            ::   ios                  ! IO status
+      INTEGER            ::   jk                   ! loop counter
+      INTEGER            ::   idrst                ! logical unit of the restart file
+      !---------------------------------------------------------------------
+      clinfo = '                    iom_rstdimg_g123d ~~~  '
+      !
+      IF( kdom == jpdom_data .OR. kdom == jpdom_global ) THEN
+         CALL ctl_stop( TRIM(clinfo), TRIM(iom_file(kiomid)%cn_var(kvid))//': case not coded for rstdimg files' )
+      ELSE
+      !
+         idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+         ! modify the subdomain indexes because we cannot directly extract the appropriate subdomaine
+         IF(     kdom == jpdom_local_full    ) THEN   ;   kx1 = 1   ;   kx2 = jpi    ;   ky1 = 1
+         ELSEIF( kdom == jpdom_local_noextra ) THEN   ;   kx1 = 1   ;   kx2 = nlci   ;   ky1 = 1
+         ENDIF
+         !
+         IF(     PRESENT(pv_r1d) ) THEN   ! read 1D variables
+            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r1d(:)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ! read 2D variables
+            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r2d(kx1:kx2, ky1:ky2    )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ! read 3D variables
+            DO jk = 1, iom_file(kiomid)%dimsz(3,kvid)   ! do loop on each level
+               READ( idrst, REC = iom_file(kiomid)%nvid(kvid) + jk - 1, IOSTAT = ios, ERR = 987 )   pv_r3d(kx1:kx2, ky1:ky2, jk)
+            END DO
+         ENDIF
+987      CONTINUE
+         IF( ios /= 0 ) THEN
+            WRITE(ctmp1,*) '           iostat = ', ios
+            CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE iom_rstdimg_g123d
+
+
+   SUBROUTINE iom_rstdimg_rp123d( kiomid, cdvar, kvid, pv_r1d, pv_r2d, pv_r3d )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
+      !!
+      !! ** Purpose : write a 2D/3D variable with RSTDIMG
+      !!--------------------------------------------------------------------
+      INTEGER                         , INTENT(in)           ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*)                , INTENT(in)           ::   cdvar    ! time axis name
+      INTEGER                         , INTENT(in)           ::   kvid     ! variable id
+      REAL(wp), DIMENSION(        jpk), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
+      REAL(wp), DIMENSION(jpi,jpj    ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
+      !
+      CHARACTER(LEN=100)    ::   clinfo               ! info character
+      INTEGER               ::   irecl8               ! reacord length
+      INTEGER               ::   ios                  ! IO status
+      INTEGER               ::   idrst                ! reacord length
+      INTEGER               ::   inx, iny, inz        ! x,y,z dimension of the variable
+      INTEGER               ::   idvar                ! variable id
+      INTEGER               ::   istop                ! temporary storage of nstop
+      INTEGER               ::   irec                 ! record number
+      INTEGER               ::   ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER               ::   jk                   ! loop counter
+      !---------------------------------------------------------------------
+      !
+      clinfo = '          iom_rstdimg_rp123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
+      istop = nstop                   ! store the actual value of nstop
+      irec = iom_file(kiomid)%irec    ! get back the record number of the variable
+      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
+      IF( kvid <= 0 ) THEN   !   new variable
+         idvar = iom_file(kiomid)%nvars + 1
+      ELSE                   !   the variable already exists in the file
+         idvar = kvid
+      ENDIF
+      IF( idvar > jpmax_vars )   CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
+      IF( .NOT. PRESENT(pv_r1d) ) THEN
+         ! find which part of data must be written
+         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz
+         IF(     inx == (nlei - nldi + 1) .AND. iny == (nlej - nldj + 1) ) THEN
+            ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
+         ELSEIF( inx == nlci              .AND. iny == nlcj              ) THEN
+            ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
+         ELSEIF( inx == jpi               .AND. iny == jpj               ) THEN
+            ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+         ELSE 
+            CALL ctl_stop( clinfo, 'should have been an impossible case...' )
+         ENDIF
+      ENDIF
+      IF( istop == nstop ) THEN
+         ! write the data
+         IF(     PRESENT(pv_r1d) ) THEN   ! 1D variable
+            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r1d(:)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ! 2D variable
+            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r2d(ix1:ix2, iy1:iy2    )
+         ELSEIF( PRESENT(pv_r3d) ) THEN   ! 3D variable
+            DO jk = 1, jpk   ! do loop on each level
+               WRITE( idrst, REC = irec + jk - 1, IOSTAT = ios, ERR = 987 ) pv_r3d(ix1:ix2, iy1:iy2, jk)
+            END DO
+         ENDIF
+         ! fill the file informations
+         iom_file(kiomid)%nvars = idvar
+         IF(     PRESENT(pv_r1d) ) THEN
+            iom_file(kiomid)%irec              = irec + 1
+            iom_file(kiomid)%ndims(     idvar) = 1
+            iom_file(kiomid)%dimsz(1  , idvar) = inz
+         ELSEIF( PRESENT(pv_r2d) ) THEN
+            iom_file(kiomid)%irec              = irec + 1
+            iom_file(kiomid)%ndims(     idvar) = 2
+            iom_file(kiomid)%dimsz(1:2, idvar) = (/ inx, iny /)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            iom_file(kiomid)%irec              = irec + inz
+            iom_file(kiomid)%ndims(     idvar) = 3
+            iom_file(kiomid)%dimsz(1:3, idvar) = (/ inx, iny, inz /)
+         ENDIF
+         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
+         iom_file(kiomid)%nvid(  idvar) = irec
+         iom_file(kiomid)%luld(  idvar) = .FALSE.
+         iom_file(kiomid)%scf(   idvar) = 1.
+         iom_file(kiomid)%ofs(   idvar) = 0.
+      ENDIF
+987   CONTINUE
+      IF( ios /= 0 ) THEN
+         WRITE(ctmp1,*) '           iostat = ', ios
+         CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
+      ELSE
+         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
+      ENDIF
+      !     
+   END SUBROUTINE iom_rstdimg_rp123d
+
+
+   !!======================================================================
+END MODULE iom_rstdimg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/prtctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/prtctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/prtctl.F90	(revision 1844)
@@ -0,0 +1,574 @@
+MODULE prtctl
+   !!==============================================================================
+   !!                       ***  MODULE prtctl   ***
+   !! Ocean system   : print all SUM trends for each processor domain
+   !!==============================================================================
+   USE dom_oce          ! ocean space and time domain variables
+   USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! distributed memory computing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Module declaration
+   INTEGER, DIMENSION(:), ALLOCATABLE :: numid
+   INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   &  !:
+      nlditl , nldjtl ,   &  !: first, last indoor index for each i-domain
+      nleitl , nlejtl ,   &  !: first, last indoor index for each j-domain
+      nimpptl, njmpptl,   &  !: i-, j-indexes for each processor
+      nlcitl , nlcjtl ,   &  !: dimensions of every subdomain
+      ibonitl, ibonjtl
+
+   REAL(wp), DIMENSION(:), ALLOCATABLE ::   &  !:
+      t_ctll , s_ctll ,   &  !: previous trend values
+      u_ctll , v_ctll
+
+   INTEGER ::   ktime        !: time step
+
+   !! * Routine accessibility
+   PUBLIC prt_ctl         ! called by all subroutines
+   PUBLIC prt_ctl_info    ! called by all subroutines
+   PUBLIC prt_ctl_init    ! called by opa.F90
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+
+CONTAINS
+
+   SUBROUTINE prt_ctl (tab2d_1, tab3d_1, mask1, clinfo1, tab2d_2, tab3d_2, mask2, clinfo2, ovlap, kdim, clinfo3)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl  ***
+      !!
+      !! ** Purpose : - print sum control of 2D or 3D arrays over the same area 
+      !!                in mono and mpp case. This way can be usefull when
+      !!                debugging a new parametrization in mono or mpp. 
+      !!
+      !! ** Method  : 2 possibilities exist when setting the ln_ctl parameter to
+      !!                .true. in the ocean namelist:
+      !!              - to debug a MPI run .vs. a mono-processor one; 
+      !!                the control print will be done over each sub-domain.
+      !!                The nictl[se] and njctl[se] parameters in the namelist must 
+      !!                be set to zero and [ij]splt to the corresponding splitted
+      !!                domain in MPI along respectively i-, j- directions.
+      !!              - to debug a mono-processor run over the whole domain/a specific area; 
+      !!                in the first case the nictl[se] and njctl[se] parameters must be set
+      !!                to zero else to the indices of the area to be controled. In both cases
+      !!                isplt and jsplt must be set to 1.
+      !!              - All arguments of the above calling sequence are optional so their
+      !!                name must be explicitly typed if used. For instance if the 3D
+      !!                array tn(:,:,:) must be passed through the prt_ctl subroutine, 
+      !!                it must looks like: CALL prt_ctl(tab3d_1=tn).
+      !!
+      !!                    tab2d_1 : first 2D array
+      !!                    tab3d_1 : first 3D array
+      !!                    mask1   : mask (3D) to apply to the tab[23]d_1 array
+      !!                    clinfo1 : information about the tab[23]d_1 array
+      !!                    tab2d_2 : second 2D array
+      !!                    tab3d_2 : second 3D array
+      !!                    mask2   : mask (3D) to apply to the tab[23]d_2 array
+      !!                    clinfo2 : information about the tab[23]d_2 array
+      !!                    ovlap   : overlap value
+      !!                    kdim    : k- direction for 3D arrays 
+      !!                    clinfo3 : additional information 
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL :: tab2d_1
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: tab3d_1
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: mask1
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo1
+      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL :: tab2d_2
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: tab3d_2
+      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: mask2
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo2
+      INTEGER                   , INTENT(in), OPTIONAL :: ovlap
+      INTEGER                   , INTENT(in), OPTIONAL :: kdim
+      CHARACTER (len=*)         , INTENT(in), OPTIONAL :: clinfo3
+
+      !! * Local declarations
+      INTEGER :: overlap, jn, sind, eind, kdir,j_id
+      CHARACTER (len=15) :: cl2
+      REAL(wp) :: zsum1, zsum2, zvctl1, zvctl2
+      REAL(wp), DIMENSION(jpi,jpj) :: ztab2d_1, ztab2d_2
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask1, zmask2, ztab3d_1, ztab3d_2
+      !!----------------------------------------------------------------------
+
+      ! Arrays, scalars initialization 
+      overlap   = 0
+      kdir      = jpkm1
+      cl2       = ''
+      zsum1     = 0.e0
+      zsum2     = 0.e0
+      zvctl1    = 0.e0
+      zvctl2    = 0.e0
+      ztab2d_1(:,:)   = 0.e0
+      ztab2d_2(:,:)   = 0.e0
+      ztab3d_1(:,:,:) = 0.e0
+      ztab3d_2(:,:,:) = 0.e0
+      zmask1  (:,:,:) = 1.e0
+      zmask2  (:,:,:) = 1.e0
+
+      ! Control of optional arguments
+      IF( PRESENT(clinfo2) )  cl2            = clinfo2
+      IF( PRESENT(ovlap)   )  overlap        = ovlap
+      IF( PRESENT(kdim)    )  kdir           = kdim
+      IF( PRESENT(tab2d_1) )  ztab2d_1(:,:)  = tab2d_1(:,:)
+      IF( PRESENT(tab2d_2) )  ztab2d_2(:,:)  = tab2d_2(:,:)
+      IF( PRESENT(tab3d_1) )  ztab3d_1(:,:,:)= tab3d_1(:,:,:)
+      IF( PRESENT(tab3d_2) )  ztab3d_2(:,:,:)= tab3d_2(:,:,:)
+      IF( PRESENT(mask1)   )  zmask1  (:,:,:)= mask1  (:,:,:)
+      IF( PRESENT(mask2)   )  zmask2  (:,:,:)= mask2  (:,:,:)
+
+      IF( lk_mpp )   THEN
+         ! processor number
+         sind = narea
+         eind = narea
+      ELSE
+         ! processors total number
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. the total number of processors ijsplt
+      DO jn = sind, eind
+         ! Set logical unit
+         j_id = numid(jn - narea + 1)
+         ! Set indices for the SUM control
+         IF( .NOT. lsp_area ) THEN
+            IF (lk_mpp )   THEN
+               nictls = MAX( 1, nlditl(jn) - overlap )
+               nictle = nleitl(jn) + overlap * MIN( 1, nlcitl(jn) - nleitl(jn)) 
+               njctls = MAX( 1, nldjtl(jn) - overlap )
+               njctle = nlejtl(jn) + overlap * MIN( 1, nlcjtl(jn) - nlejtl(jn))
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
+               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
+               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nleitl(jn) - 1)
+               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, nlejtl(jn) - 1)
+            ELSE
+               nictls = MAX( 1, nimpptl(jn) + nlditl(jn) - 1 - overlap )
+               nictle = nimpptl(jn) + nleitl(jn) - 1 + overlap * MIN( 1, nlcitl(jn) - nleitl(jn) ) 
+               njctls = MAX( 1, njmpptl(jn) + nldjtl(jn) - 1 - overlap )
+               njctle = njmpptl(jn) + nlejtl(jn) - 1 + overlap * MIN( 1, nlcjtl(jn) - nlejtl(jn) ) 
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
+               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
+               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nimpptl(jn) + nleitl(jn) - 2)
+               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, njmpptl(jn) + nlejtl(jn) - 2)
+            ENDIF
+         ENDIF
+
+         IF ( clinfo3 == 'tra' )  THEN
+             zvctl1 = t_ctll(jn)
+             zvctl2 = s_ctll(jn)
+         ELSEIF ( clinfo3 == 'dyn' )   THEN
+             zvctl1 = u_ctll(jn)
+             zvctl2 = v_ctll(jn)
+         ENDIF
+
+         ! Compute the sum control
+         ! 2D arrays
+         IF( PRESENT(tab2d_1) )   THEN
+            zsum1 = SUM( ztab2d_1(nictls:nictle,njctls:njctle)*zmask1(nictls:nictle,njctls:njctle,1) )
+            zsum2 = SUM( ztab2d_2(nictls:nictle,njctls:njctle)*zmask2(nictls:nictle,njctls:njctle,1) )
+         ENDIF
+
+         ! 3D arrays
+         IF( PRESENT(tab3d_1) )   THEN
+            zsum1 = SUM( ztab3d_1(nictls:nictle,njctls:njctle,1:kdir)*zmask1(nictls:nictle,njctls:njctle,1:kdir) )
+            zsum2 = SUM( ztab3d_2(nictls:nictle,njctls:njctle,1:kdir)*zmask2(nictls:nictle,njctls:njctle,1:kdir) )
+         ENDIF
+
+         ! Print the result
+         IF( PRESENT(clinfo3) )   THEN
+            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1-zvctl1, cl2, zsum2-zvctl2
+            SELECT CASE( clinfo3 )
+            CASE ( 'tra-ta' ) 
+               t_ctll(jn) = zsum1
+            CASE ( 'tra' ) 
+                t_ctll(jn) = zsum1
+                s_ctll(jn) = zsum2
+            CASE ( 'dyn' ) 
+                u_ctll(jn) = zsum1
+                v_ctll(jn) = zsum2 
+            END SELECT
+         ELSEIF ( PRESENT(clinfo2) .OR. PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) )   THEN
+            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1, cl2, zsum2
+         ELSE
+            WRITE(j_id,FMT='(a,D23.16)')clinfo1, zsum1
+         ENDIF
+
+      ENDDO
+
+   END SUBROUTINE prt_ctl
+
+
+   SUBROUTINE prt_ctl_info (clinfo1, ivar1, clinfo2, ivar2, itime)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_info  ***
+      !!
+      !! ** Purpose : - print information without any computation
+      !!
+      !! ** Action  : - input arguments
+      !!                    clinfo1 : information about the ivar1
+      !!                    ivar1   : value to print
+      !!                    clinfo2 : information about the ivar2
+      !!                    ivar2   : value to print
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER (len=*), INTENT(in) ::   clinfo1
+      INTEGER          , INTENT(in), OPTIONAL ::   ivar1
+      CHARACTER (len=*), INTENT(in), OPTIONAL ::   clinfo2
+      INTEGER          , INTENT(in), OPTIONAL ::   ivar2
+      INTEGER          , INTENT(in), OPTIONAL ::   itime
+
+      !! * Local declarations
+      INTEGER :: jn, sind, eind, iltime, j_id
+      !!----------------------------------------------------------------------
+
+      IF( lk_mpp )   THEN
+         ! processor number
+         sind = narea
+         eind = narea
+      ELSE
+         ! total number of processors
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Set to zero arrays at each new time step
+      IF( PRESENT(itime) )   THEN
+         iltime = itime
+         IF( iltime > ktime )   THEN
+            t_ctll(:) = 0.e0   ;   s_ctll(:) = 0.e0
+            u_ctll(:) = 0.e0   ;   v_ctll(:) = 0.e0
+            ktime = iltime
+         ENDIF
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. number of processors ijsplt
+      DO jn = sind, eind
+         
+         ! Set logical unit
+         j_id = numid(jn - narea + 1)
+
+         IF( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, clinfo2, ivar2
+         ELSEIF ( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, clinfo2
+         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1, ivar2
+         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
+            WRITE(j_id,*)clinfo1, ivar1
+         ELSE
+            WRITE(j_id,*)clinfo1
+         ENDIF
+
+      ENDDO
+
+
+      END SUBROUTINE prt_ctl_info
+
+   SUBROUTINE prt_ctl_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_init  ***
+      !!
+      !! ** Purpose :   open ASCII files & compute indices
+      !!
+      !! History :
+      !!   9.0  !  05-07  (C. Talandier) original code
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   jn, sind, eind, j_id
+      CHARACTER (len=28) :: clfile_out
+      CHARACTER (len=23) :: clb_name
+      CHARACTER (len=19) :: cl_run
+      !!----------------------------------------------------------------------
+
+      ! Allocate arrays
+      ALLOCATE(nlditl (ijsplt))
+      ALLOCATE(nldjtl (ijsplt))
+      ALLOCATE(nleitl (ijsplt))
+      ALLOCATE(nlejtl (ijsplt))
+      ALLOCATE(nimpptl(ijsplt))
+      ALLOCATE(njmpptl(ijsplt))
+      ALLOCATE(nlcitl (ijsplt))
+      ALLOCATE(nlcjtl (ijsplt))
+      ALLOCATE(t_ctll (ijsplt))
+      ALLOCATE(s_ctll (ijsplt))
+      ALLOCATE(u_ctll (ijsplt))
+      ALLOCATE(v_ctll (ijsplt))
+      ALLOCATE(ibonitl(ijsplt))
+      ALLOCATE(ibonjtl(ijsplt))
+
+      ! Initialization 
+      t_ctll(:)=0.e0
+      s_ctll(:)=0.e0
+      u_ctll(:)=0.e0
+      v_ctll(:)=0.e0
+      ktime = 1
+
+      IF( lk_mpp ) THEN
+         sind = narea
+         eind = narea
+         clb_name = "('mpp.output_',I4.4)"
+         cl_run = 'MULTI processor run'
+         ! use indices for each area computed by mpp_init subroutine
+         nlditl(:) = nldit(:) 
+         nleitl(:) = nleit(:) 
+         nldjtl(:) = nldjt(:) 
+         nlejtl(:) = nlejt(:) 
+         !
+         nimpptl(:) = nimppt(:)
+         njmpptl(:) = njmppt(:)
+         !
+         nlcitl(:) = nlcit(:)
+         nlcjtl(:) = nlcjt(:)
+         !
+         ibonitl(:) = ibonit(:)
+         ibonjtl(:) = ibonjt(:)
+      ELSE
+         sind = 1
+         eind = ijsplt
+         clb_name = "('mono.output_',I4.4)"
+         cl_run = 'MONO processor run '
+         ! compute indices for each area as done in mpp_init subroutine
+         CALL sub_dom
+      ENDIF
+
+      ALLOCATE(numid(eind-sind+1))
+
+      DO jn = sind, eind
+         WRITE(clfile_out,FMT=clb_name) jn-1
+         CALL ctl_opn( numid(jn -narea + 1), clfile_out, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', 1, numout, .FALSE. )
+         j_id = numid(jn -narea + 1)
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                 L O D Y C - I P S L'
+         WRITE(j_id,*) '                     O P A model'
+         WRITE(j_id,*) '            Ocean General Circulation Model'
+         WRITE(j_id,*) '               version OPA 9.0  (2005) '
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                   PROC number: ', jn
+         WRITE(j_id,*)
+         WRITE(j_id,FMT="(19x,a20)")cl_run
+
+         ! Print the SUM control indices
+         IF( .NOT. lsp_area )   THEN
+            nictls = nimpptl(jn) + nlditl(jn) - 1
+            nictle = nimpptl(jn) + nleitl(jn) - 1
+            njctls = njmpptl(jn) + nldjtl(jn) - 1
+            njctle = njmpptl(jn) + nlejtl(jn) - 1
+         ENDIF
+         WRITE(j_id,*) 
+         WRITE(j_id,*) 'prt_ctl :  Sum control indices'
+         WRITE(j_id,*) '~~~~~~~'
+         WRITE(j_id,*)
+         WRITE(j_id,9000)'                                nlej   = ', nlejtl(jn), '              '
+         WRITE(j_id,9000)'                  ------------- njctle = ', njctle, ' -------------'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9002)'           nictls = ', nictls,  '                           nictle = ', nictle
+         WRITE(j_id,9002)'           nldi   = ', nlditl(jn),  '                           nlei   = ', nleitl(jn)
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9004)'  njmpp  = ',njmpptl(jn),'   ------------- njctls = ', njctls, ' -------------'
+         WRITE(j_id,9003)'           nimpp  = ', nimpptl(jn), '        nldj   = ', nldjtl(jn), '              '
+         WRITE(j_id,*)
+         WRITE(j_id,*)
+
+9000     FORMAT(a41,i4.4,a14)
+9001     FORMAT(a59)
+9002     FORMAT(a20,i4.4,a36,i3.3)
+9003     FORMAT(a20,i4.4,a17,i4.4)
+9004     FORMAT(a11,i4.4,a26,i4.4,a14)
+      ENDDO
+
+   END SUBROUTINE prt_ctl_init
+
+
+   SUBROUTINE sub_dom
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sub_dom  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors. 
+      !!                CAUTION: 
+      !!                This part has been extracted from the mpp_init
+      !!                subroutine and names of variables/arrays have been 
+      !!                slightly changed to avoid confusion but the computation
+      !!                is exactly the same. Any modification about indices of
+      !!                each sub-domain in the mppini.F90 module should be reported 
+      !!                here.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!                Periodic condition is a function of the local domain position
+      !!                (global boundary or neighbouring domain) and of the global
+      !!                periodic
+      !!                Type :         jperio global periodic condition
+      !!                               nperio local  periodic condition
+      !!
+      !! ** Action  : - set domain parameters
+      !!                    nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlcil      : first dimension
+      !!                    nlcjl      : second dimension
+      !!                    nbondil    : mark for "east-west local boundary"
+      !!                    nbondjl    : mark for "north-south local boundary"
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   8.5  !  02-08  (G. Madec)  F90 : free form
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::   ji, jj, jn               ! dummy loop indices
+      INTEGER ::   &
+         ii, ij,                         &  ! temporary integers
+         irestil, irestjl,               &  !    "          "
+         ijpi  , ijpj, nlcil,            &  ! temporary logical unit
+         nlcjl , nbondil, nbondjl,       &
+         nrecil, nrecjl, nldil, nleil, nldjl, nlejl
+
+      INTEGER, DIMENSION(:,:), ALLOCATABLE ::   &
+         iimpptl, ijmpptl, ilcitl, ilcjtl       ! temporary workspace
+      REAL(wp) ::   zidom, zjdom            ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !  Computation of local domain sizes ilcitl() ilcjtl()
+      !  These dimensions depend on global sizes isplt,jsplt and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array (cf. par_oce.F90).
+
+      ijpi = ( jpiglo-2*jpreci + (isplt-1) ) / isplt + 2*jpreci
+      ijpj = ( jpjglo-2*jprecj + (jsplt-1) ) / jsplt + 2*jprecj
+
+      ALLOCATE(ilcitl (isplt,jsplt))
+      ALLOCATE(ilcjtl (isplt,jsplt))
+
+      nrecil  = 2 * jpreci
+      nrecjl  = 2 * jprecj
+      irestil = MOD( jpiglo - nrecil , isplt )
+      irestjl = MOD( jpjglo - nrecjl , jsplt )
+
+      IF(  irestil == 0 )   irestil = isplt
+      DO jj = 1, jsplt
+         DO ji = 1, irestil
+            ilcitl(ji,jj) = ijpi
+         END DO
+         DO ji = irestil+1, isplt
+            ilcitl(ji,jj) = ijpi -1
+         END DO
+      END DO
+      
+      IF( irestjl == 0 )   irestjl = jsplt
+      DO ji = 1, isplt
+         DO jj = 1, irestjl
+            ilcjtl(ji,jj) = ijpj
+         END DO
+         DO jj = irestjl+1, jsplt
+            ilcjtl(ji,jj) = ijpj -1
+         END DO
+      END DO
+      
+      zidom = nrecil
+      DO ji = 1, isplt
+         zidom = zidom + ilcitl(ji,1) - nrecil
+      END DO
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilcitl(i,1) = ', zidom, ' jpiglo = ', jpiglo
+      
+      zjdom = nrecjl
+      DO jj = 1, jsplt
+         zjdom = zjdom + ilcjtl(1,jj) - nrecjl
+      END DO
+      IF(lwp) WRITE(numout,*)' sum ilcitl(1,j) = ', zjdom, ' jpjglo = ', jpjglo
+      IF(lwp) WRITE(numout,*)
+      
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+
+      ALLOCATE(iimpptl(isplt,jsplt))
+      ALLOCATE(ijmpptl(isplt,jsplt))
+      
+      iimpptl(:,:) = 1
+      ijmpptl(:,:) = 1
+      
+      IF( isplt > 1 ) THEN
+         DO jj = 1, jsplt
+            DO ji = 2, isplt
+               iimpptl(ji,jj) = iimpptl(ji-1,jj) + ilcitl(ji-1,jj) - nrecil
+            END DO
+         END DO
+      ENDIF
+
+      IF( jsplt > 1 ) THEN
+         DO jj = 2, jsplt
+            DO ji = 1, isplt
+               ijmpptl(ji,jj) = ijmpptl(ji,jj-1)+ilcjtl(ji,jj-1)-nrecjl
+            END DO
+         END DO
+      ENDIF
+      
+      ! 3. Subdomain description
+      ! ------------------------
+
+      DO jn = 1, ijsplt
+         ii = 1 + MOD( jn-1, isplt )
+         ij = 1 + (jn-1) / isplt
+         nimpptl(jn) = iimpptl(ii,ij)
+         njmpptl(jn) = ijmpptl(ii,ij)
+         nlcitl (jn) = ilcitl (ii,ij)     
+         nlcil       = nlcitl (jn)     
+         nlcjtl (jn) = ilcjtl (ii,ij)     
+         nlcjl       = nlcjtl (jn)
+         nbondjl = -1                                    ! general case
+         IF( jn   >  isplt          )   nbondjl = 0      ! first row of processor
+         IF( jn   >  (jsplt-1)*isplt )  nbondjl = 1     ! last  row of processor
+         IF( jsplt == 1             )   nbondjl = 2      ! one processor only in j-direction
+         ibonjtl(jn) = nbondjl
+         
+         nbondil = 0                                     ! 
+         IF( MOD( jn, isplt ) == 1 )   nbondil = -1      !
+         IF( MOD( jn, isplt ) == 0 )   nbondil =  1      !
+         IF( isplt            == 1 )   nbondil =  2      ! one processor only in i-direction
+         ibonitl(jn) = nbondil
+         
+         nldil =  1   + jpreci
+         nleil = nlcil - jpreci
+         IF( nbondil == -1 .OR. nbondil == 2 )   nldil = 1
+         IF( nbondil ==  1 .OR. nbondil == 2 )   nleil = nlcil
+         nldjl =  1   + jprecj
+         nlejl = nlcjl - jprecj
+         IF( nbondjl == -1 .OR. nbondjl == 2 )   nldjl = 1
+         IF( nbondjl ==  1 .OR. nbondjl == 2 )   nlejl = nlcjl
+         nlditl(jn) = nldil
+         nleitl(jn) = nleil
+         nldjtl(jn) = nldjl
+         nlejtl(jn) = nlejl
+      END DO
+
+      DEALLOCATE(iimpptl)
+      DEALLOCATE(ijmpptl)
+      DEALLOCATE(ilcitl)
+      DEALLOCATE(ilcjtl)
+
+   END SUBROUTINE sub_dom
+
+END MODULE prtctl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/restart.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/IOM/restart.F90	(revision 1844)
@@ -0,0 +1,224 @@
+MODULE restart
+   !!======================================================================
+   !!                     ***  MODULE  restart  ***
+   !! Ocean restart :  write the ocean restart file
+   !!======================================================================
+   !! History :        !  99-11  (M. Imbard)  Original code
+   !!             8.5  !  02-08  (G. Madec)  F90: Free form
+   !!             9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!             9.0  !  06-07  (S. Masson)  use IOM for restart
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   rst_opn    : open the ocean restart file
+   !!   rst_write  : write the ocean restart file
+   !!   rst_read   : read the ocean restart file
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE oce             ! ocean dynamics and tracers 
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE c1d             ! re-initialization of u-v mask for the 1D configuration
+   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE zdfddm          ! double diffusion mixing 
+   USE zdfmxl          ! mixed layer depth
+   USE trdmld_oce      ! ocean active mixed layer tracers trends variables
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   rst_opn    ! routine called by step module
+   PUBLIC   rst_write  ! routine called by step module
+   PUBLIC   rst_read   ! routine called by opa  module
+
+   LOGICAL, PUBLIC ::   lrst_oce =  .FALSE.       !: logical to control the oce restart write 
+   INTEGER, PUBLIC ::   numror, numrow            !: logical unit for cean restart (read and write)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE rst_opn( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rst_opn  ***
+      !!                     
+      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
+      !!              + open the restart when we are one time step before nitrst
+      !!                   - restart header is defined when kt = nitrst-1
+      !!                   - restart data  are written when kt = nitrst
+      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN   ! default definitions
+         lrst_oce = .FALSE.   
+         nitrst = nitend
+      ENDIF
+      IF( MOD( kt - 1, nstock ) == 0 ) THEN   
+         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
+         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
+      ENDIF
+      ! to get better performances with NetCDF format:
+      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
+      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
+      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+         IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+         ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
+         IF(lwp) THEN
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ocean restart binary file: '//clname
+            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart NetCDF file: '//clname
+            END SELECT
+            IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
+            ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+            ENDIF
+         ENDIF
+
+         CALL iom_open( clname, numrow, ldwrt = .TRUE., kiolib = jprstlib )
+         lrst_oce = .TRUE.
+      ENDIF
+      !
+   END SUBROUTINE rst_opn
+
+
+   SUBROUTINE rst_write( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rstwrite  ***
+      !!                     
+      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !!
+      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
+      !!      file, save fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step
+      !!----------------------------------------------------------------------
+
+      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics time step
+      CALL iom_rstput( kt, nitrst, numrow, 'rdttra1', rdttra(1) )   ! surface tracer time step
+
+      CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub      )     ! before fields
+      CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb      )
+      CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tb      )
+      CALL iom_rstput( kt, nitrst, numrow, 'sb'     , sb      )
+      CALL iom_rstput( kt, nitrst, numrow, 'rotb'   , rotb    )
+      CALL iom_rstput( kt, nitrst, numrow, 'hdivb'  , hdivb   )
+      CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb    )
+      !
+      CALL iom_rstput( kt, nitrst, numrow, 'un'     , un      )     ! now fields
+      CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn      )
+      CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tn      )
+      CALL iom_rstput( kt, nitrst, numrow, 'sn'     , sn      )
+      CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn    )
+      CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn   )
+      CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn    )
+
+      CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop    )
+#if defined key_zdfkpp
+      CALL iom_rstput( kt, nitrst, numrow, 'rhd'  , rhd   )
+#endif
+
+      IF( kt == nitrst ) THEN
+         CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
+      ENDIF
+      !
+   END SUBROUTINE rst_write
+
+
+   SUBROUTINE rst_read
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read  ***
+      !! 
+      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zrdt, zrdttra1
+      INTEGER  ::   jlibalt = jprstlib
+      LOGICAL  ::   llok
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN                                             ! Contol prints
+         WRITE(numout,*)
+         SELECT CASE ( jprstlib )
+         CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+         CASE ( jprstdimg )   ;   WRITE(numout,*) 'rst_read : read oce binary restart file'
+         END SELECT
+         WRITE(numout,*) '~~~~~~~~'
+      ENDIF
+
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if {cn_ocerst_in}.nc exists, then set jlibalt to jpnf90
+        INQUIRE( FILE = TRIM(cn_ocerst_in)//'.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+      ENDIF
+      CALL iom_open( cn_ocerst_in, numror, kiolib = jlibalt )
+
+      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
+      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
+         CALL iom_get( numror, 'rdt', zrdt )
+         IF( zrdt /= rdt )   neuler = 0
+      ENDIF
+      IF( iom_varid( numror, 'rdttra1', ldstop = .FALSE. ) > 0 )   THEN
+         CALL iom_get( numror, 'rdttra1', zrdttra1 )
+         IF( zrdttra1 /= rdttra(1) )   neuler = 0
+      ENDIF
+      ! 
+      CALL iom_get( numror, jpdom_autoglo, 'ub'   , ub    )        ! before fields
+      CALL iom_get( numror, jpdom_autoglo, 'vb'   , vb    )
+      CALL iom_get( numror, jpdom_autoglo, 'tb'   , tb    )
+      CALL iom_get( numror, jpdom_autoglo, 'sb'   , sb    )
+      CALL iom_get( numror, jpdom_autoglo, 'rotb' , rotb  )
+      CALL iom_get( numror, jpdom_autoglo, 'hdivb', hdivb )
+      CALL iom_get( numror, jpdom_autoglo, 'sshb' , sshb  )
+      !
+      CALL iom_get( numror, jpdom_autoglo, 'un'   , un    )        ! now    fields
+      CALL iom_get( numror, jpdom_autoglo, 'vn'   , vn    )
+      CALL iom_get( numror, jpdom_autoglo, 'tn'   , tn    )
+      CALL iom_get( numror, jpdom_autoglo, 'sn'   , sn    )
+      CALL iom_get( numror, jpdom_autoglo, 'rotn' , rotn  )
+      CALL iom_get( numror, jpdom_autoglo, 'hdivn', hdivn )
+      CALL iom_get( numror, jpdom_autoglo, 'sshn' , sshn  )
+
+      CALL iom_get( numror, jpdom_autoglo, 'rhop' , rhop  )        ! now    potential density
+#if defined key_zdfkpp
+      IF( iom_varid( numror, 'rhd', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'rhd' , rhd  )       ! now    in situ density anomaly
+      ELSE
+         CALL eos( tn, sn, rhd )   ! compute rhd
+      ENDIF
+#endif
+
+      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
+         tb   (:,:,:) = tn   (:,:,:)                             ! all before fields set to now values
+         sb   (:,:,:) = sn   (:,:,:)
+         ub   (:,:,:) = un   (:,:,:)
+         vb   (:,:,:) = vn   (:,:,:)
+         rotb (:,:,:) = rotn (:,:,:)
+         hdivb(:,:,:) = hdivn(:,:,:)
+         sshb (:,:)   = sshn (:,:)
+      ENDIF
+      !
+   END SUBROUTINE rst_read
+
+   !!=====================================================================
+END MODULE restart
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn.F90	(revision 1844)
@@ -0,0 +1,277 @@
+MODULE ldfdyn
+   !!======================================================================
+   !!                       ***  MODULE  ldfdyn  ***
+   !! Ocean physics:  lateral viscosity coefficient 
+   !!=====================================================================
+   !! History :  OPA  ! 1997-07  (G. Madec)  multi dimensional coefficients
+   !!   NEMO     1.0  ! 2002-09  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ldf_dyn_init : initialization, namelist read, and parameters control
+   !!   ldf_dyn_c3d   : 3D eddy viscosity coefficient initialization
+   !!   ldf_dyn_c2d   : 2D eddy viscosity coefficient initialization
+   !!   ldf_dyn_c1d   : 1D eddy viscosity coefficient initialization
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers   
+   USE dom_oce         ! ocean space and time domain 
+   USE ldfdyn_oce      ! ocean dynamics lateral physics
+   USE phycst          ! physical constants
+   USE ldfslp          ! ???
+   USE ioipsl
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ldf_dyn_init   ! called by opa.F90
+
+  INTERFACE ldf_zpf
+     MODULE PROCEDURE ldf_zpf_1d, ldf_zpf_1d_3d, ldf_zpf_3d
+  END INTERFACE
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_dyn_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_dyn_init  ***
+      !!                   
+      !! ** Purpose :   set the horizontal ocean dynamics physics
+      !!
+      !! ** Method  :  
+      !!      -  default option : ahm = constant coef. = rn_ahm_0 (namelist)
+      !!      - 'key_dynldf_c1d': ahm = F(depth)                     see ldf_dyn_c1d.h90
+      !!      - 'key_dynldf_c2d': ahm = F(latitude,longitude)        see ldf_dyn_c2d.h90
+      !!      - 'key_dynldf_c3d': ahm = F(latitude,longitude,depth)  see ldf_dyn_c3d.h90
+      !!
+      !!      N.B. User defined include files.  By default, 3d and 2d coef.
+      !!      are set to a constant value given in the namelist and the 1d
+      !!      coefficients are initialized to a hyperbolic tangent vertical
+      !!      profile.
+      !!
+      !! Reference :   Madec, G. and M. Imbard, 1996: Climate Dynamics, 12, 381-388.
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio         ! ???
+      LOGICAL :: ll_print = .FALSE.    ! Logical flag for printing viscosity coef.
+      !! 
+      NAMELIST/namdyn_ldf/ ln_dynldf_lap  , ln_dynldf_bilap,                  &
+         &                 ln_dynldf_level, ln_dynldf_hor  , ln_dynldf_iso,   &
+         &                 rn_ahm_0       , rn_ahmb_0
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )                  ! Read Namelist namdyn_ldf : Lateral physics
+      READ  ( numnam, namdyn_ldf )
+
+      IF(lwp) THEN                      ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) 'ldf_dyn : lateral momentum physics'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist nam_dynldf : set lateral mixing parameters'
+         WRITE(numout,*) '      laplacian operator          ln_dynldf_lap   = ', ln_dynldf_lap
+         WRITE(numout,*) '      bilaplacian operator        ln_dynldf_bilap = ', ln_dynldf_bilap
+         WRITE(numout,*) '      iso-level                   ln_dynldf_level = ', ln_dynldf_level
+         WRITE(numout,*) '      horizontal (geopotential)   ln_dynldf_hor   = ', ln_dynldf_hor
+         WRITE(numout,*) '      iso-neutral                 ln_dynldf_iso   = ', ln_dynldf_iso
+         WRITE(numout,*) '      horizontal eddy viscosity   rn_ahm_0        = ', rn_ahm_0
+         WRITE(numout,*) '      background viscosity        rn_ahmb_0       = ', rn_ahmb_0
+      ENDIF
+
+      ahm0  = rn_ahm_0                  ! OLD namelist variables defined from DOCTOR namelist variables
+      ahmb0 = rn_ahmb_0
+
+      ! ... check of lateral diffusive operator on tracers
+      !           ==> will be done in trazdf module
+
+      ! ... Space variation of eddy coefficients
+      ioptio = 0
+#if defined key_dynldf_c3d
+      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( latitude, longitude, depth)'
+      ioptio = ioptio+1
+#endif
+#if defined key_dynldf_c2d
+      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( latitude, longitude)'
+      ioptio = ioptio+1
+#endif
+#if defined key_dynldf_c1d
+      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( depth )'
+      ioptio = ioptio+1
+      IF( ln_sco ) CALL ctl_stop( 'key_dynldf_c1d cannot be used in s-coordinate (ln_sco)' )
+#endif
+      IF( ioptio == 0 ) THEN
+          IF(lwp) WRITE(numout,*) '   momentum mixing coef. = constant  (default option)'
+        ELSEIF( ioptio > 1 ) THEN
+           CALL ctl_stop( 'use only one of the following keys: key_dynldf_c3d, key_dynldf_c2d, key_dynldf_c1d' )
+      ENDIF
+
+
+      IF( ln_dynldf_bilap ) THEN
+         IF(lwp) WRITE(numout,*) '   biharmonic momentum diffusion'
+         IF( ahm0 > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal viscosity coef. ahm0 must be negative' )
+      ELSE
+         IF(lwp) WRITE(numout,*) '   harmonic momentum diff. (default)'
+         IF( ahm0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal viscosity coef. ahm0 must be positive' )
+      ENDIF
+
+
+      ! Lateral eddy viscosity
+      ! ======================
+#if defined key_dynldf_c3d
+      CALL ldf_dyn_c3d( ll_print )   ! ahm = 3D coef. = F( longitude, latitude, depth )
+#elif defined key_dynldf_c2d
+      CALL ldf_dyn_c2d( ll_print )   ! ahm = 1D coef. = F( longitude, latitude )
+#elif defined key_dynldf_c1d
+      CALL ldf_dyn_c1d( ll_print )   ! ahm = 1D coef. = F( depth )
+#else
+                                     ! Constant coefficients
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'inildf: constant eddy viscosity coef. '
+      IF(lwp) WRITE(numout,*) '~~~~~~'
+      IF(lwp) WRITE(numout,*) '        ahm1 = ahm2 = ahm0 =  ',ahm0
+#endif
+      !
+   END SUBROUTINE ldf_dyn_init
+
+#if defined key_dynldf_c3d
+#   include "ldfdyn_c3d.h90"
+#elif defined key_dynldf_c2d
+#   include "ldfdyn_c2d.h90"
+#elif defined key_dynldf_c1d
+#   include "ldfdyn_c1d.h90"
+#endif
+
+
+   SUBROUTINE ldf_zpf_1d( ld_print, pdam, pwam, pbot, pdep, pah )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_zpf  ***
+      !!                   
+      !! ** Purpose :   vertical adimensional profile for eddy coefficient
+      !!
+      !! ** Method  :   1D eddy viscosity coefficients ( depth )
+      !!----------------------------------------------------------------------
+      LOGICAL , INTENT(in   )                 ::   ld_print   ! If true, output arrays on numout
+      REAL(wp), INTENT(in   )                 ::   pdam       ! depth of the inflection point
+      REAL(wp), INTENT(in   )                 ::   pwam       ! width of inflection
+      REAL(wp), INTENT(in   )                 ::   pbot       ! bottom value (0<pbot<= 1)
+      REAL(wp), INTENT(in   ), DIMENSION(jpk) ::   pdep       ! depth of the gridpoint (T, U, V, F)
+      REAL(wp), INTENT(inout), DIMENSION(jpk) ::   pah        ! adimensional vertical profile
+      !!
+      INTEGER  ::   jk           ! dummy loop indices
+      REAL(wp) ::   zm00, zm01, zmhb, zmhs       ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      zm00 = TANH( ( pdam - gdept_0(1    ) ) / pwam )
+      zm01 = TANH( ( pdam - gdept_0(jpkm1) ) / pwam )
+      zmhs = zm00 / zm01
+      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
+
+      DO jk = 1, jpk
+         pah(jk) = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(jk) ) / pwam )  )
+      END DO
+
+      IF(lwp .AND. ld_print ) THEN      ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm profile : '
+         WRITE(numout,*)
+         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
+         DO jk = 1, jpk
+            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(jk), pdep(jk)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE ldf_zpf_1d
+
+
+   SUBROUTINE ldf_zpf_1d_3d( ld_print, pdam, pwam, pbot, pdep, pah )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_zpf  ***
+      !!
+      !! ** Purpose :   vertical adimensional profile for eddy coefficient
+      !!
+      !! ** Method  :   1D eddy viscosity coefficients ( depth )
+      !!----------------------------------------------------------------------
+      LOGICAL , INTENT(in   )                         ::   ld_print   ! If true, output arrays on numout
+      REAL(wp), INTENT(in   )                         ::   pdam       ! depth of the inflection point
+      REAL(wp), INTENT(in   )                         ::   pwam       ! width of inflection
+      REAL(wp), INTENT(in   )                         ::   pbot       ! bottom value (0<pbot<= 1)
+      REAL(wp), INTENT(in   ), DIMENSION        (jpk) ::   pdep       ! depth of the gridpoint (T, U, V, F)
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pah        ! adimensional vertical profile
+      !!
+      INTEGER  ::   jk           ! dummy loop indices
+      REAL(wp) ::   zm00, zm01, zmhb, zmhs, zcf  ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      zm00 = TANH( ( pdam - gdept_0(1    ) ) / pwam )
+      zm01 = TANH( ( pdam - gdept_0(jpkm1) ) / pwam )
+      zmhs = zm00 / zm01
+      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
+
+      DO jk = 1, jpk
+         zcf = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(jk) ) / pwam )  )
+         pah(:,:,jk) = zcf
+      END DO
+
+      IF(lwp .AND. ld_print ) THEN      ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm profile : '
+         WRITE(numout,*)
+         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
+         DO jk = 1, jpk
+            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(1,1,jk), pdep(jk)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE ldf_zpf_1d_3d
+
+
+   SUBROUTINE ldf_zpf_3d( ld_print, pdam, pwam, pbot, pdep, pah )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_zpf  ***
+      !!
+      !! ** Purpose :   vertical adimensional profile for eddy coefficient
+      !!
+      !! ** Method  :   3D for partial step or s-coordinate
+      !!----------------------------------------------------------------------
+      LOGICAL , INTENT(in   )                         ::   ld_print   ! If true, output arrays on numout
+      REAL(wp), INTENT(in   )                         ::   pdam       ! depth of the inflection point
+      REAL(wp), INTENT(in   )                         ::   pwam       ! width of inflection
+      REAL(wp), INTENT(in   )                         ::   pbot       ! bottom value (0<pbot<= 1)
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk) ::   pdep       ! dep of the gridpoint (T, U, V, F)
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pah        ! adimensional vertical profile
+      !!
+      INTEGER  ::   jk           ! dummy loop indices
+      REAL(wp) ::   zm00, zm01, zmhb, zmhs       ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      zm00 = TANH( ( pdam - gdept_0(1    ) ) / pwam )   
+      zm01 = TANH( ( pdam - gdept_0(jpkm1) ) / pwam )
+      zmhs = zm00 / zm01
+      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
+
+      DO jk = 1, jpk
+         pah(:,:,jk) = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(:,:,jk) ) / pwam )  )
+      END DO
+
+      IF(lwp .AND. ld_print ) THEN      ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm profile : '
+         WRITE(numout,*)
+         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
+         DO jk = 1, jpk
+            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(1,1,jk), pdep(1,1,jk)
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE ldf_zpf_3d
+
+   !!======================================================================
+END MODULE ldfdyn
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_antarctic.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_antarctic.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_antarctic.h90	(revision 1844)
@@ -0,0 +1,43 @@
+   !!----------------------------------------------------------------------
+   !!  ldfdyn_antarctic.h90        2D (i,j) antarctic zoom viscosity coeff.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+!
+! 1.2 Modify ahm
+! --------------
+ 
+      IF(lwp)WRITE(numout,*) ' inildf: Antarctic ocean'
+      IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
+      IF(lwp)WRITE(numout,*) '         north boundary increase'
+
+      ahm1(:,:) = ahm0
+      ahm2(:,:) = ahm0
+
+      ijpt0=max(1,min(49 -njmpp+1,jpj))
+      ijpt1=max(0,min(49-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*2.
+         ahm1(:,jj)=ahm0*2.
+      END DO
+      ijpt0=max(1,min(48 -njmpp+1,jpj))
+      ijpt1=max(0,min(48-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.9
+         ahm1(:,jj)=ahm0*1.75
+      END DO
+      ijpt0=max(1,min(47 -njmpp+1,jpj))
+      ijpt1=max(0,min(47-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.5
+         ahm1(:,jj)=ahm0*1.25
+      END DO
+      ijpt0=max(1,min(46 -njmpp+1,jpj))
+      ijpt1=max(0,min(46-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.1
+      END DO
+C
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_arctic.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_arctic.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_arctic.h90	(revision 1844)
@@ -0,0 +1,43 @@
+   !!----------------------------------------------------------------------
+   !!  ldftra_arctic.h90              2D (i,j) arctic zoom viscosity coeff.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+! 1.2 Modify ahm 
+! --------------
+      IF(lwp)WRITE(numout,*) ' inildf: Arctic ocean'
+      IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
+      IF(lwp)WRITE(numout,*) '         south and west boundary increase'
+
+
+      ahm1(:,:) = ahm0
+      ahm2(:,:) = ahm0
+
+      ijpt0=max(1,min(98-jpjzoom+1-njmpp+1,jpj))
+      ijpt1=max(0,min(98-jpjzoom+1-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*2.
+         ahm1(:,jj)=ahm0*2.
+      END DO
+      ijpt0=max(1,min(99-jpjzoom+1-njmpp+1,jpj))
+      ijpt1=max(0,min(99-jpjzoom+1-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.9
+         ahm1(:,jj)=ahm0*1.75
+      END DO
+      ijpt0=max(1,min(100-jpjzoom+1-njmpp+1,jpj))
+      ijpt1=max(0,min(100-jpjzoom+1-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.5
+         ahm1(:,jj)=ahm0*1.25
+      END DO
+      ijpt0=max(1,min(101-jpjzoom+1-njmpp+1,jpj))
+      ijpt1=max(0,min(101-jpjzoom+1-njmpp+1,jpj-1))
+      DO jj=ijpt0,ijpt1
+         ahm2(:,jj)=ahm0*1.1
+      END DO
+
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90	(revision 1844)
@@ -0,0 +1,99 @@
+   !!----------------------------------------------------------------------
+   !!                     ***  ldfdyn_c1d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_dyn_c1d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_dyn_c1d  ***
+      !!                   
+      !! ** Purpose :   initializations of the horizontal ocean physics
+      !!
+      !! ** Method  :   1D eddy viscosity coefficients ( depth )
+      !!      ahm3, ahm4 never used
+      !!      biharmonic or harmonic operator : ahm1=ahm2 defined at T-level
+      !!      isopycnal or geopotential harmonic operator
+      !!                                      : ahm1 defined at T-level
+      !!                                      : ahm2 defined at w-level
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !! * Local variables
+      REAL(wp) ::   zdam, zwam, zm00, zm01, zmhf, zmhs
+      REAL(wp) ::   zahmf, zahms
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'inildf: 1D eddy viscosity coefficient'
+      IF(lwp) WRITE(numout,*) '~~~~~~  --'
+      IF(lwp) WRITE(numout,*)
+
+      ! Set ahm1=ahm2   (always at t-level)
+      ! =============
+      ! (USER: modify ahm1 following your desiderata)
+
+      ! initialization of the profile
+      ! ahms, ahmf: surface and bottom values
+      zahms = ahm0
+      zahmf = ahm0/4.
+      ! zdam, zwam: depth of the inflection pt and width of inflection
+      zdam  = -300.
+      zwam  =  300.
+      ! computation coefficients
+      zm00 = TANH( (0-zdam)/zwam )
+      zm01 = TANH( (-fsdept(1,1,jpk)-zdam)/zwam )
+      zmhf = (zahms-zahmf)/(zm00-zm01)
+      zmhs = zahms-zmhf * zm00
+
+      ! set ahm1=ahm2 at T-level
+      DO jk = 1, jpk
+         ahm1(jk) = zmhs + zmhf * TANH( (-fsdept(1,1,jk)-zdam) / zwam )
+         ahm2(jk) = ahm1(jk)
+      END DO
+
+      ! Control print
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm profile : '
+         WRITE(numout,*)
+         WRITE(numout,9100)
+         DO jk = 1, jpk
+            WRITE(numout,9110) jk, ahm1(jk), fsdept(1,1,jk)
+         END DO
+      ENDIF
+ 9100 FORMAT('  jk      ahm       ','  depth t-level ' )
+ 9110 FORMAT(i6,2f12.4,3x,2f12.4)
+
+
+      ! Set ahm3=ahm4   (always defined at w-level)
+      ! =============
+
+      ! define ahm3 from the same vertical profile used for ahm4
+      ! (always defined at w-level)
+      ! (USER: modify ahm1 following your desiderata)
+
+      DO jk = 1, jpk
+         ahm3(jk) = zmhs + zmhf * TANH( (-fsdepw(1,1,jk)-zdam) / zwam )
+         ahm4(jk) = ahm3(jk)
+      END DO
+
+      ! Control print
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm3=ahm4 profile : '
+         WRITE(numout,*)
+         WRITE(numout,9120)
+         DO jk = 1, jpk
+            WRITE(numout,9110) jk, ahm3(jk), fsdepw(1,1,jk)
+         END DO
+      ENDIF
+ 9120 FORMAT('  jk      ahm       ','  depth w-level ' )
+
+   END SUBROUTINE ldf_dyn_c1d
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 1844)
@@ -0,0 +1,289 @@
+   !!----------------------------------------------------------------------
+   !!                      ***  ldfdyn_c2d.h90  ***
+   !!----------------------------------------------------------------------
+   !!   ldf_dyn_c2d  : set the lateral viscosity coefficients
+   !!   ldf_dyn_c2d_orca : specific case for orca r2 and r4
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_dyn_c2d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldf_dyn_c2d  ***
+      !!                  
+      !! ** Purpose :   initializations of the horizontal ocean physics
+      !!
+      !! ** Method :
+      !!      2D eddy viscosity coefficients ( longitude, latitude )
+      !!
+      !!       harmonic operator   : ahm1 is defined at t-point
+      !!                             ahm2 is defined at f-point
+      !!           + isopycnal     : ahm3 is defined at u-point
+      !!           or geopotential   ahm4 is defined at v-point
+      !!           iso-model level : ahm3, ahm4 not used
+      !!
+      !!       biharmonic operator : ahm1 is defined at u-point
+      !!                             ahm2 is defined at v-point
+      !!                           : ahm3, ahm4 not used
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !! * Local variables
+      INTEGER :: ji, jj
+      REAL(wp) ::   za00, zd_max, zetmax, zeumax, zefmax, zevmax
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'ldf_dyn_c2d : 2d lateral eddy viscosity coefficient'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*)
+
+      ! harmonic operator (ahm1, ahm2) : ( T- and F- points) (used for laplacian operators
+      ! ===============================                       whatever its orientation is)
+      IF( ln_dynldf_lap ) THEN
+         ! define ahm1 and ahm2 at the right grid point position
+         ! (USER: modify ahm1 and ahm2 following your desiderata)
+
+         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
+         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
+
+         IF(lwp) WRITE(numout,*) '              laplacian operator: ahm proportional to e1'
+         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
+
+         za00 = ahm0 / zd_max
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
+               zefmax = MAX( e1f(ji,jj), e2f(ji,jj) )
+               ahm1(ji,jj) = za00 * zetmax
+               ahm2(ji,jj) = za00 * zefmax
+            END DO
+         END DO
+
+         IF( ln_dynldf_iso ) THEN
+            IF(lwp) WRITE(numout,*) '              Caution, as implemented now, the isopycnal part of momentum'
+            IF(lwp) WRITE(numout,*) '                 mixing use aht0 as eddy viscosity coefficient. Thus, it is'
+            IF(lwp) WRITE(numout,*) '                 uniform and you must be sure that your ahm is greater than'
+            IF(lwp) WRITE(numout,*) '                 aht0 everywhere in the model domain.'
+         ENDIF
+
+         ! Special case for ORCA R2 and R4 configurations (overwrite the value of ahm1 ahm2)
+         ! ==============================================
+         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) )   CALL ldf_dyn_c2d_orca( ld_print )
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: 2D ahm1 array'
+            CALL prihre(ahm1,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: 2D ahm2 array'
+            CALL prihre(ahm2,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         ENDIF
+      ENDIF
+
+      ! biharmonic operator (ahm3, ahm4) : at U- and V-points (used for bilaplacian operator
+      ! =================================                      whatever its orientation is)
+      IF( ln_dynldf_bilap ) THEN
+         ! (USER: modify ahm3 and ahm4 following your desiderata)
+         ! Here: ahm is proportional to the cube of the maximum of the gridspacing
+         !       in the to horizontal direction
+
+         zd_max = MAX( MAXVAL( e1u(:,:) ), MAXVAL( e2u(:,:) ) )
+         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
+
+         IF(lwp) WRITE(numout,*) '              bi-laplacian operator: ahm proportional to e1**3 '
+         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
+
+         za00 = ahm0 / ( zd_max * zd_max * zd_max )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) )
+               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) )
+               ahm3(ji,jj) = za00 * zeumax * zeumax * zeumax
+               ahm4(ji,jj) = za00 * zevmax * zevmax * zevmax
+            END DO
+         END DO
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahm3 array'
+            CALL prihre(ahm3,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahm4 array'
+            CALL prihre(ahm4,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         ENDIF
+      ENDIF
+
+
+   END SUBROUTINE ldf_dyn_c2d
+
+
+   SUBROUTINE ldf_dyn_c2d_orca( ld_print )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldf_dyn_c2d  ***
+      !!
+      !!                   **** W A R N I N G ****
+      !!
+      !!                ORCA R2 and R4 configurations
+      !!                  
+      !!                   **** W A R N I N G ****
+      !!                  
+      !! ** Purpose :   initializations of the lateral viscosity for orca R2
+      !!
+      !! ** Method  :   blah blah blah...
+      !!
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ldftra_oce, ONLY : aht0
+
+      !! * Arguments
+      LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
+
+      !! * Local variables
+      INTEGER ::   ji, jj, jn      ! dummy loop indices
+      INTEGER ::   inum            ! temporary logical unit
+      INTEGER ::   iim, ijm
+      INTEGER ::   ifreq, il1, il2, ij, ii
+      INTEGER, DIMENSION(jpidta,jpidta) ::   idata
+      INTEGER, DIMENSION(jpi   ,jpj   ) ::   icof
+
+      REAL(wp) ::   zahmeq, zcoft, zcoff, zmsk
+
+      CHARACTER (len=15) ::   clexp
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'inildf: 2d eddy viscosity coefficient'
+      IF(lwp) WRITE(numout,*) '~~~~~~  --'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '        orca ocean model'
+      IF(lwp) WRITE(numout,*)
+
+#if defined key_antarctic
+#     include "ldfdyn_antarctic.h90"
+#elif defined key_arctic
+#     include "ldfdyn_arctic.h90"
+#else
+      ! Read 2d integer array to specify western boundary increase in the
+      ! ===================== equatorial strip (20N-20S) defined at t-points
+
+      CALL ctl_opn( inum, 'ahmcoef', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+      READ(inum,9101) clexp, iim, ijm
+      READ(inum,'(/)')
+      ifreq = 40
+      il1 = 1
+      DO jn = 1, jpidta/ifreq+1
+         READ(inum,'(/)')
+         il2 = MIN( jpidta, il1+ifreq-1 )
+         READ(inum,9201) ( ii, ji = il1, il2, 5 )
+         READ(inum,'(/)')
+         DO jj = jpjdta, 1, -1
+            READ(inum,9202) ij, ( idata(ji,jj), ji = il1, il2 )
+         END DO
+         il1 = il1 + ifreq
+      END DO
+      
+      DO jj = 1, nlcj
+         DO ji = 1, nlci
+            icof(ji,jj) = idata( mig(ji), mjg(jj) )
+         END DO
+      END DO
+      DO jj = nlcj+1, jpj
+         DO ji = 1, nlci
+            icof(ji,jj) = icof(ji,nlcj)
+         END DO
+      END DO
+      DO jj = 1, jpj
+         DO ji = nlci+1, jpi
+            icof(ji,jj) = icof(nlci,jj)
+         END DO
+      END DO
+
+ 9101 FORMAT(1x,a15,2i8)
+ 9201 FORMAT(3x,13(i3,12x))
+ 9202 FORMAT(i3,41i3)
+
+
+      ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
+      ! =================
+      ! define ahm1 and ahm2 at the right grid point position
+      ! (USER: modify ahm1 and ahm2 following your desiderata)
+      
+      
+      ! Decrease ahm to zahmeq m2/s in the tropics
+      ! (from 90 to 20 degre: ahm = constant
+      ! from 20 to  2.5 degre: ahm = decrease in (1-cos)/2
+      ! from  2.5 to  0 degre: ahm = constant
+      ! symmetric in the south hemisphere)
+
+      zahmeq = aht0
+      
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS( gphif(ji,jj) ) >= 20. ) THEN
+               ahm2(ji,jj) =  ahm0
+            ELSEIF( ABS( gphif(ji,jj) ) <= 2.5 ) THEN
+               ahm2(ji,jj) =  zahmeq
+            ELSE
+               ahm2(ji,jj) = zahmeq + (ahm0-zahmeq)/2.   &
+                  * ( 1. - COS( rad * ( ABS(gphif(ji,jj))-2.5 ) * 180. / 17.5 ) )
+            ENDIF
+            IF( ABS( gphit(ji,jj) ) >= 20. ) THEN
+               ahm1(ji,jj) =  ahm0
+            ELSEIF( ABS( gphit(ji,jj) ) <= 2.5 ) THEN
+               ahm1(ji,jj) =  zahmeq
+            ELSE
+               ahm1(ji,jj) = zahmeq + (ahm0-zahmeq)/2.   &
+                  * ( 1. - COS( rad * ( ABS(gphit(ji,jj))-2.5 ) * 180. / 17.5 ) )
+            ENDIF
+         END DO
+      END DO
+
+      ! increase along western boundaries of equatorial strip
+      ! t-point
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            zcoft = FLOAT( icof(ji,jj) ) / 100.
+            ahm1(ji,jj) = zcoft * ahm0 + (1.-zcoft) * ahm1(ji,jj) 
+         END DO
+      END DO
+      ! f-point
+      icof(:,:) = icof(:,:) * tmask(:,:,1)
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1   ! NO vector opt.
+            zmsk = tmask(ji,jj+1,1) + tmask(ji+1,jj+1,1) + tmask(ji,jj,1) + tmask(ji,jj+1,1)
+            IF( zmsk == 0. ) THEN
+               zcoff = 1.
+            ELSE
+               zcoff = FLOAT( icof(ji,jj+1) + icof(ji+1,jj+1) + icof(ji,jj) + icof(ji,jj+1) )   &
+                     / (zmsk * 100.)
+            ENDIF
+            ahm2(ji,jj) = zcoff * ahm0 + (1.-zcoff) * ahm2(ji,jj)
+         END DO
+      END DO
+#endif
+      
+      ! Lateral boundary conditions on ( ahm1, ahm2 )
+      !                                ==============
+      CALL lbc_lnk( ahm1, 'T', 1. )   ! T-point, unchanged sign
+      CALL lbc_lnk( ahm2, 'F', 1. )   ! F-point, unchanged sign
+
+      ! Control print
+      IF( lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: 2D ahm1 array'
+         CALL prihre(ahm1,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: 2D ahm2 array'
+         CALL prihre(ahm2,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+   END SUBROUTINE ldf_dyn_c2d_orca
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90	(revision 1844)
@@ -0,0 +1,469 @@
+   !!----------------------------------------------------------------------
+   !!                        ***  ldfdyn_c3d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   'key_dynldf_c3d'             3D lateral eddy viscosity coefficients
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_dyn_c3d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_dyn_c3d  ***
+      !!                   
+      !! ** Purpose :   initializations of the horizontal ocean physics
+      !!
+      !! ** Method  :   3D eddy viscosity coef. ( longitude, latitude, depth )
+      !!       laplacian operator   : ahm1, ahm2 defined at T- and F-points
+      !!                              ahm2, ahm4 never used
+      !!       bilaplacian operator : ahm1, ahm2 never used
+      !!                           :  ahm3, ahm4 defined at U- and V-points
+      !!       ??? explanation of the default is missing
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ldftra_oce, ONLY : aht0
+
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !! * local variables
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   &
+         zr = 0.2 ,   &  ! maximum of the reduction factor at the bottom ocean
+         !               ! ( 0 < zr < 1 )
+         zh = 500.,   &  ! depth of at which start the reduction ( > dept(1) )
+         zd_max   ,   &  ! maximum grid spacing over the global domain
+         za00, zc, zd    ! temporary scalars
+      REAL(wp) ::        &
+         zetmax, zefmax, &
+         zeumax, zevmax   
+      REAL(wp), DIMENSION(jpk) ::   zcoef   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'ldf_dyn_c3d : 3D lateral eddy viscosity coefficient'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+
+      
+      ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operators
+      ! =================                       whatever its orientation is)
+      IF( ln_dynldf_lap ) THEN
+         ! define ahm1 and ahm2 at the right grid point position
+         ! (USER: modify ahm1 and ahm2 following your desiderata)
+
+         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
+         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
+
+         IF(lwp) WRITE(numout,*) '              laplacian operator: ahm proportional to e1'
+         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
+
+         za00 = ahm0 / zd_max
+
+         IF( ln_dynldf_iso ) THEN
+            IF(lwp) WRITE(numout,*) '              Caution, as implemented now, the isopycnal part of momentum'
+            IF(lwp) WRITE(numout,*) '                 mixing use aht0 as eddy viscosity coefficient. Thus, it is'
+            IF(lwp) WRITE(numout,*) '                 uniform and you must be sure that your ahm is greater than'
+            IF(lwp) WRITE(numout,*) '                 aht0 everywhere in the model domain.'
+         ENDIF
+
+         CALL ldf_zpf( .TRUE. , 1000., 500., 0.25, fsdept(:,:,:), ahm1 )   ! vertical profile
+         CALL ldf_zpf( .TRUE. , 1000., 500., 0.25, fsdept(:,:,:), ahm2 )   ! vertical profile
+         DO jk = 1,jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
+                  zefmax = MAX( e1f(ji,jj), e2f(ji,jj) )
+                  ahm1(ji,jj,jk) = za00 * zetmax * ahm1(ji,jj,jk)
+                  ahm2(ji,jj,jk) = za00 * zefmax * ahm2(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+
+         ! Special case for ORCA R2 and R4 configurations (overwrite the value of ahm1 ahm2)
+         ! ==============================================
+         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '              ORCA R2 or R4: overwrite the previous definition of ahm'
+            IF(lwp) WRITE(numout,*) '              ============='
+            CALL ldf_dyn_c3d_orca( ld_print )
+         ENDIF
+
+      ENDIF
+      
+      ! Control print
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         3D ahm1 array (k=1)'
+         CALL prihre( ahm1(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) '         3D ahm2 array (k=1)'
+         CALL prihre( ahm2(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
+      ENDIF
+
+
+      ! ahm3 and ahm4 at U- and V-points (used for bilaplacian operator
+      ! ================================  whatever its orientation is)
+      ! (USER: modify ahm3 and ahm4 following your desiderata)
+      ! Here: ahm is proportional to the cube of the maximum of the gridspacing
+      !       in the to horizontal direction
+
+      IF( ln_dynldf_bilap ) THEN
+
+         zd_max = MAX( MAXVAL( e1u(:,:) ), MAXVAL( e2u(:,:) ) )
+         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
+
+         IF(lwp) WRITE(numout,*) '              bi-laplacian operator: ahm proportional to e1**3 '
+         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
+
+         za00 = ahm0 / ( zd_max * zd_max * zd_max )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) )
+               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) )
+               ahm3(ji,jj,1) = za00 * zeumax * zeumax * zeumax
+               ahm4(ji,jj,1) = za00 * zevmax * zevmax * zevmax
+            END DO
+         END DO
+
+         zh = MAX( zh, fsdept(1,1,1) )   ! at least the first reach ahm0
+         IF( ln_zco ) THEN               ! z-coordinate, same profile everywhere
+            IF(lwp) WRITE(numout,'(36x," ahm ", 7x)')
+            DO jk = 1, jpk
+               IF( fsdept(1,1,jk) <= zh ) THEN
+                  zcoef(jk) = 1.e0
+               ELSE
+                  zcoef(jk) = 1.e0 + ( zr - 1.e0 )   &
+                     &               * (  1. - EXP( ( fsdept(1,1,jk   ) - zh ) / zh )  )   &
+                     &               / (  1. - EXP( ( fsdept(1,1,jpkm1) - zh ) / zh )  )
+               ENDIF
+               ahm3(:,:,jk) = ahm3(:,:,1) * zcoef(jk)
+               ahm4(:,:,jk) = ahm4(:,:,1) * zcoef(jk)
+               IF(lwp) WRITE(numout,'(34x,E7.2,8x,i3)') zcoef(jk) * ahm0, jk
+            END DO
+         ELSE                            ! partial steps or s-ccordinate
+# if defined key_zco
+            zc = gdept_0(jpkm1)
+# else
+            zc = MAXVAL( fsdept(:,:,jpkm1) )
+# endif
+            IF( lk_mpp )   CALL mpp_max( zc )   ! max over the global domain
+
+            zc = 1. / (  1. - EXP( ( zc - zh ) / zh )  )
+            DO jk = 2, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF( fsdept(ji,jj,jk) <= zh ) THEN
+                        ahm3(ji,jj,jk) = ahm3(ji,jj,1)
+                        ahm4(ji,jj,jk) = ahm4(ji,jj,1)
+                     ELSE
+                        zd = 1.e0 + ( zr - 1.e0 ) * (  1. - EXP( ( fsdept(ji,jj,jk) - zh ) / zh )  ) * zc
+                        ahm3(ji,jj,jk) = ahm3(ji,jj,1) * zd
+                        ahm4(ji,jj,jk) = ahm4(ji,jj,1) * zd
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            ahm3(:,:,jpk) = ahm3(:,:,jpkm1)
+            ahm4(:,:,jpk) = ahm4(:,:,jpkm1)
+            IF(lwp) WRITE(numout,'(36x," ahm ", 7x)')
+            DO jk = 1, jpk
+               IF(lwp) WRITE(numout,'(30x,E10.2,8x,i3)') ahm3(1,1,jk), jk
+            END DO
+         ENDIF
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahm3 array at level 1'
+            CALL prihre(ahm3(:,:,1  ),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahm4 array at level 1'
+            CALL prihre(ahm4(:,:,jpk),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         ENDIF
+      ENDIF
+
+   END SUBROUTINE ldf_dyn_c3d
+
+
+   SUBROUTINE ldf_dyn_c3d_orca( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_dyn_c3d  ***
+      !!                   
+      !! ** Purpose :   ORCA R2 an R4 only
+      !!
+      !! ** Method  :   blah blah blah ....
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ldftra_oce, ONLY : aht0
+
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !! * local variables
+      INTEGER ::   ji, jj, jk, jn      ! dummy loop indices
+      INTEGER ::   ii0, ii1, ij0, ij1  ! temporary integers
+      INTEGER ::   inum                ! temporary logical unit
+      INTEGER ::   iim, ijm
+      INTEGER ::   ifreq, il1, il2, ij, ii
+      INTEGER, DIMENSION(jpidta, jpjdta) ::   idata
+      INTEGER, DIMENSION(jpi   , jpj   ) ::   icof
+
+      REAL(wp) ::   &
+         zahmeq, zcoff, zcoft, zmsk,   & ! ???
+         zemax, zemin, zeref, zahmm
+      REAL(wp), DIMENSION(jpi,jpj) ::   zahm0
+      REAL(wp), DIMENSION(jpk) ::   zcoef
+
+      CHARACTER (len=15) ::   clexp
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'ldfdyn_c3d_orca : 3D eddy viscosity coefficient'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '        orca R2 or R4 ocean model'
+      IF(lwp) WRITE(numout,*) '  reduced in the surface Eq. strip '
+      IF(lwp) WRITE(numout,*)
+
+      ! Read 2d integer array to specify western boundary increase in the
+      ! ===================== equatorial strip (20N-20S) defined at t-points
+
+      CALL ctl_opn( inum, 'ahmcoef', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+      READ(inum,9101) clexp, iim, ijm
+      READ(inum,'(/)')
+      ifreq = 40
+      il1 = 1
+      DO jn = 1, jpidta/ifreq+1
+         READ(inum,'(/)')
+         il2 = MIN( jpidta, il1+ifreq-1 )
+         READ(inum,9201) ( ii, ji = il1, il2, 5 )
+         READ(inum,'(/)')
+         DO jj = jpjdta, 1, -1
+            READ(inum,9202) ij, ( idata(ji,jj), ji = il1, il2 )
+         END DO
+         il1 = il1 + ifreq
+      END DO
+      
+      DO jj = 1, nlcj
+         DO ji = 1, nlci
+            icof(ji,jj) = idata( mig(ji), mjg(jj) )
+         END DO
+      END DO
+      DO jj = nlcj+1, jpj
+         DO ji = 1, nlci
+            icof(ji,jj) = icof(ji,nlcj)
+         END DO
+      END DO
+      DO jj = 1, jpj
+         DO ji = nlci+1, jpi
+            icof(ji,jj) = icof(nlci,jj)
+         END DO
+      END DO
+      
+9101  FORMAT(1x,a15,2i8)
+9201  FORMAT(3x,13(i3,12x))
+9202  FORMAT(i3,41i3)
+      
+      ! Set ahm1 and ahm2
+      ! =================
+      
+      ! define ahm1 and ahm2 at the right grid point position
+      ! (USER: modify ahm1 and ahm2 following your desiderata)
+      ! biharmonic : ahm1 (ahm2) defined at u- (v-) point
+      ! harmonic   : ahm1 (ahm2) defined at t- (f-) point
+      
+      ! first level : as for 2D coefficients
+      
+      ! Decrease ahm to zahmeq m2/s in the tropics
+      ! (from 90 to 20 degre: ahm = constant
+      ! from 20 to  2.5 degre: ahm = decrease in (1-cos)/2
+      ! from  2.5 to  0 degre: ahm = constant
+      ! symmetric in the south hemisphere)
+      
+      IF( jp_cfg == 4 )   THEN
+         zahmeq = 5.0 * aht0
+         zahmm  = min( 160000.0, ahm0)
+         zemax = MAXVAL ( e1t(:,:) * e2t(:,:), tmask(:,:,1) .GE. 0.5 )
+         zemin = MINVAL ( e1t(:,:) * e2t(:,:), tmask(:,:,1) .GE. 0.5 )
+         zeref = MAXVAL ( e1t(:,:) * e2t(:,:),   &
+             &   tmask(:,:,1) .GE. 0.5 .AND. ABS(gphit(:,:)) .GT. 50. )
+ 
+         DO jj = 1, jpj
+           DO ji = 1, jpi
+              zmsk = e1t(ji,jj) * e2t(ji,jj)
+              IF( abs(gphit(ji,jj)) .LE. 15 ) THEN 
+                 zahm0(ji,jj) = ahm0
+              ELSE 
+                 IF( zmsk .GE. zeref ) THEN 
+                    zahm0(ji,jj) = ahm0
+                 ELSE 
+                    zahm0(ji,jj) = zahmm + (ahm0-zahmm)*(1.0 -   &
+                        &          cos((rpi*0.5*(zmsk-zemin)/(zeref-zemin))))
+                 ENDIF 
+              ENDIF 
+           END DO 
+         END DO 
+      ENDIF
+
+      IF( jp_cfg == 2 )   THEN
+         zahmeq     = aht0
+         zahmm      = ahm0
+         zahm0(:,:) = ahm0
+      ENDIF
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS(gphif(ji,jj)) >= 20.) THEN
+               ahm2(ji,jj,1) =  zahm0(ji,jj)
+            ELSEIF( ABS(gphif(ji,jj)) <= 2.5) THEN
+               ahm2(ji,jj,1) =  zahmeq
+            ELSE
+               ahm2(ji,jj,1) = zahmeq + (zahm0(ji,jj)-zahmeq)/2.   &
+                  &            *(1.-COS( rad*(ABS(gphif(ji,jj))-2.5)*180./17.5 ) )
+            ENDIF
+            IF( ABS(gphit(ji,jj)) >= 20.) THEN
+               ahm1(ji,jj,1) =  zahm0(ji,jj)
+            ELSEIF( ABS(gphit(ji,jj)) <= 2.5) THEN
+               ahm1(ji,jj,1) =  zahmeq
+            ELSE
+               ahm1(ji,jj,1) = zahmeq + (zahm0(ji,jj)-zahmeq)/2.   &
+                  &            *(1.-COS( rad*(ABS(gphit(ji,jj))-2.5)*180./17.5 ) )
+            ENDIF
+         END DO
+      END DO
+      
+      ! increase along western boundaries of equatorial strip
+      ! t-point
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            zcoft = float( icof(ji,jj) ) / 100.
+            ahm1(ji,jj,1) = zcoft * zahm0(ji,jj) + (1.-zcoft) * ahm1(ji,jj,1)
+         END DO
+      END DO
+      ! f-point
+      icof(:,:) = icof(:,:) * tmask(:,:,1)
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1   ! NO vector opt.
+            zmsk = tmask(ji,jj+1,1) + tmask(ji+1,jj+1,1) + tmask(ji,jj,1) + tmask(ji,jj+1,1)
+            IF( zmsk == 0. ) THEN
+               zcoff = 1.
+            ELSE
+               zcoff = FLOAT( icof(ji,jj+1) + icof(ji+1,jj+1) + icof(ji,jj) + icof(ji,jj+1) )   &
+                     / (zmsk * 100.)
+            ENDIF
+            ahm2(ji,jj,1) = zcoff * zahm0(ji,jj) + (1.-zcoff) * ahm2(ji,jj,1)
+         END DO
+      END DO
+
+      ! other level: re-increase the coef in the deep ocean
+      
+#if defined key_orca_lev10
+      DO jk = 1, 210
+         zcoef(jk) = 1.
+      END DO
+      DO jk= 211, 230
+         zcoef(jk) = 1. + 0.1 * FLOAT(jk-210)
+      END DO
+      DO jk= 231, 260
+         zcoef(jk) = 3. + 0.2 * FLOAT(jk-230)
+      END DO
+      DO jk= 261, 270
+         zcoef(jk) = 9. + 0.1 * FLOAT(jk-260)
+      END DO
+      DO jk= 271, jpk
+         zcoef(jk) = 10.
+      END DO
+      DO jk= 1, jpk
+         IF(lwp) WRITE(numout,*) 'k= ',jk, 'cof ', zcoef(jk)
+      END DO
+#else
+       DO jk = 1, 21
+         zcoef(jk) = 1.
+      END DO
+      zcoef(22) = 2.
+      zcoef(23) = 3.
+      zcoef(24) = 5.
+      zcoef(25) = 7.
+      zcoef(26) = 9.
+      DO jk = 27, jpk
+         zcoef(jk) = 10.
+      END DO
+#endif
+
+      DO jk = 2, jpk
+         ahm1(:,:,jk) = MIN( zahm0(:,:), zcoef(jk) * ahm1(:,:,1) )
+         ahm2(:,:,jk) = MIN( zahm0(:,:), zcoef(jk) * ahm2(:,:,1) )
+      END DO
+
+      IF( jp_cfg == 4 )   THEN
+         ! Limit AHM in Gibraltar strait
+         ij0 = 50   ;   ij1 = 53
+         ii0 = 69   ;   ii1 = 71
+         DO jk = 1, jpk
+            ahm1(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) = min( zahmm, ahm1 (mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) ) 
+            ahm2(mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) = min( zahmm, ahm2 (mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , jk) )
+         END DO
+      ENDIF
+      
+      ! Lateral boundary conditions on ( ahm1, ahm2 )
+      !                                ==============
+      CALL lbc_lnk( ahm1, 'T', 1. )   ! T-point, unchanged sign
+      CALL lbc_lnk( ahm2, 'F', 1. )   ! F-point, unchanged sign
+
+      ! Control print
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         3D ahm1 array (k=1)'
+         CALL prihre( ahm1(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) '         3D ahm2 array (k=1)'
+         CALL prihre( ahm2(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) '         3D ahm2 array (k=jpk)'
+         CALL prihre( ahm2(:,:,jpk), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
+      ENDIF
+
+
+      ! Set ahm3 and ahm4
+      ! =================
+
+      ! define ahm3 and ahm4 at the right grid point position
+      ! initialization to a constant value
+      !     (USER: modify ahm3 and ahm4 following your desiderata)
+      !     harmonic isopycnal or geopotential:
+      !                          ahm3 (ahm4) defined at u- (v-) point
+      DO jk = 1, jpk
+         DO jj = 2, jpj
+            DO ji = 2, jpi
+               ahm3(ji,jj,jk) = 0.5 * ( ahm2(ji,jj,jk) + ahm2(ji  ,jj-1,jk) )
+               ahm4(ji,jj,jk) = 0.5 * ( ahm2(ji,jj,jk) + ahm2(ji-1,jj  ,jk) )
+            END DO
+         END DO
+      END DO
+      ahm3 ( :, 1, :) = ahm3 ( :, 2, :)
+      ahm4 ( :, 1, :) = ahm4 ( :, 2, :)
+      
+      ! Lateral boundary conditions on ( ahm3, ahm4 )
+      !                                ==============
+      CALL lbc_lnk( ahm3, 'U', 1. )   ! U-point, unchanged sign
+      CALL lbc_lnk( ahm4, 'V', 1. )   ! V-point, unchanged sign
+
+      ! Control print
+
+      IF( lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm3 array level 1'
+         CALL prihre(ahm3(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) '         ahm4 array level 1'
+         CALL prihre(ahm4(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+   END SUBROUTINE ldf_dyn_c3d_orca
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90	(revision 1844)
@@ -0,0 +1,39 @@
+MODULE ldfdyn_oce
+   !!======================================================================
+   !!                  ***  MODULE  ldfdyn_oce  ***
+   !! Ocean physics:  lateral momentum mixing coefficient defined in memory 
+   !!======================================================================
+   !! History :  1.0  ! 2002-11  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !                                                  !!* Namelist namdyn_ldf : lateral mixing *
+   LOGICAL , PUBLIC ::   ln_dynldf_lap   = .TRUE.      !: laplacian operator
+   LOGICAL , PUBLIC ::   ln_dynldf_bilap = .FALSE.     !: bilaplacian operator
+   LOGICAL , PUBLIC ::   ln_dynldf_level = .FALSE.     !: iso-level direction
+   LOGICAL , PUBLIC ::   ln_dynldf_hor   = .TRUE.      !: horizontal (geopotential) direction
+   LOGICAL , PUBLIC ::   ln_dynldf_iso   = .FALSE.     !: iso-neutral direction
+   REAL(wp), PUBLIC ::   rn_ahm_0        = 40000._wp   !: lateral eddy viscosity (m2/s)
+   REAL(wp), PUBLIC ::   rn_ahmb_0       =     0._wp   !: lateral background eddy viscosity (m2/s)
+
+   REAL(wp), PUBLIC ::   ahm0, ahmb0                 ! OLD namelist names
+
+#if defined key_dynldf_c3d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   ahm1, ahm2, ahm3, ahm4  ! ** 3D coefficients **
+#elif defined key_dynldf_c2d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ahm1, ahm2, ahm3, ahm4  ! ** 2D coefficients **
+#elif defined key_dynldf_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpk)         ::   ahm1, ahm2, ahm3, ahm4  ! ** 2D coefficients **
+#else
+   REAL(wp), PUBLIC                         ::   ahm1, ahm2, ahm3, ahm4  ! ** 0D coefficients **
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE ldfdyn_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfdyn_substitute.h90	(revision 1844)
@@ -0,0 +1,36 @@
+   !!----------------------------------------------------------------------
+   !!                    ***  ldfdyn_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsahm., the lateral eddy viscosity coeff. 
+   !!      with a constant, or 1D, or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_dynldf_c3d
+!   ' key_dynldf_c3d' :                  3D coefficient
+#    define   fsahmt(i,j,k)    ahm1(i,j,k)
+#    define   fsahmf(i,j,k)    ahm2(i,j,k)
+#    define   fsahmu(i,j,k)    ahm3(i,j,k)
+#    define   fsahmv(i,j,k)    ahm4(i,j,k)
+#elif defined key_dynldf_c2d
+!   ' key_dynldf_c2d' :                 2D coefficient
+#  define   fsahmt(i,j,k)    ahm1(i,j)
+#  define   fsahmf(i,j,k)    ahm2(i,j)
+#  define   fsahmu(i,j,k)    ahm3(i,j)
+#  define   fsahmv(i,j,k)    ahm4(i,j)
+#elif defined key_dynldf_c1d
+!   'key_dynldf_c1d' :                  1D coefficient
+#  define   fsahmt(i,j,k)    ahm1(k)
+#  define   fsahmf(i,j,k)    ahm1(k)
+#  define   fsahmu(i,j,k)    ahm1(k)
+#  define   fsahmv(i,j,k)    ahm1(k)
+#else
+!   default option :               Constant coefficient
+#  define   fsahmt(i,j,k)   ahm0
+#  define   fsahmf(i,j,k)   ahm0
+#  define   fsahmu(i,j,k)   ahm0
+#  define   fsahmv(i,j,k)   ahm0
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 1844)
@@ -0,0 +1,233 @@
+MODULE ldfeiv
+   !!======================================================================
+   !!                     ***  MODULE  ldfeiv  ***
+   !! Ocean physics:  variable eddy induced velocity coefficients
+   !!======================================================================
+#if   defined key_traldf_eiv   &&   defined key_traldf_c2d
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_eiv'      and                     eddy induced velocity
+   !!   'key_traldf_c2d'                    2D tracer lateral  mixing coef.
+   !!----------------------------------------------------------------------
+   !!   ldf_eiv      : compute the eddy induced velocity coefficients
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE sbcrnf          ! river runoffs
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE phycst          ! physical constants
+   USE ldfslp          ! iso-neutral slopes
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   !! * Routine accessibility
+   PUBLIC ldf_eiv               ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_eiv( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv  ***
+      !!
+      !! ** Purpose :   Compute the eddy induced velocity coefficient from the
+      !!      growth rate of baroclinic instability.
+      !!
+      !! ** Method :
+      !!
+      !! ** Action : - uslp(),  : i- and j-slopes of neutral surfaces
+      !!             - vslp()      at u- and v-points, resp.
+      !!             - wslpi(),  : i- and j-slopes of neutral surfaces
+      !!             - wslpj()     at w-points. 
+      !!
+      !! History :
+      !!   8.1  !  99-03  (G. Madec, A. Jouzeau)  Original code
+      !!   8.5  !  02-06  (G. Madec)  Free form, F90
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step inedx
+      
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   &
+         zfw, ze3w, zn2, zf20,       &  ! temporary scalars
+         zaht, zaht_min
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zn, zah, zhw, zross            ! workspace
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'ldf_eiv : eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+      
+      ! 0. Local initialization
+      ! -----------------------
+      zn   (:,:) = 0.e0
+      zhw  (:,:) = 5.e0
+      zah  (:,:) = 0.e0
+      zross(:,:) = 0.e0
+
+
+      ! 1. Compute lateral diffusive coefficient 
+      ! ----------------------------------------
+
+      DO jk = 1, jpk
+#  if defined key_vectopt_loop  
+!CDIR NOVERRCHK 
+         DO ji = 1, jpij   ! vector opt.
+            ! Take the max of N^2 and zero then take the vertical sum
+            ! of the square root of the resulting N^2 ( required to compute
+            ! internal Rossby radius Ro = .5 * sum_jpk(N) / f
+            zn2 = MAX( rn2b(ji,1,jk), 0.e0 )
+            zn(ji,1) = zn(ji,1) + SQRT( zn2 ) * fse3w(ji,1,jk)
+            ! Compute elements required for the inverse time scale of baroclinic
+            ! eddies using the isopycnal slopes calculated in ldfslp.F :
+            ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
+            ze3w = fse3w(ji,1,jk) * tmask(ji,1,jk)
+               zah(ji,1) = zah(ji,1) + zn2   &
+                              * ( wslpi(ji,1,jk) * wslpi(ji,1,jk)    &
+                                + wslpj(ji,1,jk) * wslpj(ji,1,jk) )   &
+                              * ze3w
+            zhw(ji,1) = zhw(ji,1) + ze3w
+         END DO
+#  else
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK 
+            DO ji = 2, jpim1
+               ! Take the max of N^2 and zero then take the vertical sum 
+               ! of the square root of the resulting N^2 ( required to compute 
+               ! internal Rossby radius Ro = .5 * sum_jpk(N) / f 
+               zn2 = MAX( rn2b(ji,jj,jk), 0.e0 )
+               zn(ji,jj) = zn(ji,jj) + SQRT( zn2 ) * fse3w(ji,jj,jk)
+               ! Compute elements required for the inverse time scale of baroclinic
+               ! eddies using the isopycnal slopes calculated in ldfslp.F : 
+               ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
+               ze3w = fse3w(ji,jj,jk) * tmask(ji,jj,jk)
+               zah(ji,jj) = zah(ji,jj) + zn2   &
+                              * ( wslpi(ji,jj,jk) * wslpi(ji,jj,jk)    &
+                                + wslpj(ji,jj,jk) * wslpj(ji,jj,jk) )  &
+                              * ze3w
+               zhw(ji,jj) = zhw(ji,jj) + ze3w
+            END DO 
+         END DO 
+#  endif
+      END DO 
+
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK 
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zfw = MAX( ABS( 2. * omega * SIN( rad * gphit(ji,jj) ) ) , 1.e-10 )
+            ! Rossby radius at w-point taken < 40km and  > 2km
+            zross(ji,jj) = MAX( MIN( .4 * zn(ji,jj) / zfw, 40.e3 ), 2.e3 )
+            ! Compute aeiw by multiplying Ro^2 and T^-1
+            aeiw(ji,jj) = zross(ji,jj) * zross(ji,jj) * SQRT( zah(ji,jj) / zhw(ji,jj) ) * tmask(ji,jj,1)
+         END DO
+      END DO
+
+      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA R02
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! Take the minimum between aeiw and aeiv0 for depth levels
+               ! lower than 20 (21 in w- point)
+               IF( mbathy(ji,jj) <= 21. ) aeiw(ji,jj) = MIN( aeiw(ji,jj), 1000. )
+            END DO
+         END DO
+      ENDIF
+
+      ! Decrease the coefficient in the tropics (20N-20S) 
+      zf20 = 2. * omega * sin( rad * 20. )
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            aeiw(ji,jj) = MIN( 1., ABS( ff(ji,jj) / zf20 ) ) * aeiw(ji,jj)
+         END DO
+      END DO
+
+      ! ORCA R05: Take the minimum between aeiw  and aeiv0
+      IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               aeiw(ji,jj) = MIN( aeiw(ji,jj), aeiv0 )
+            END DO
+         END DO
+      ENDIF
+
+      ! lateral boundary condition on aeiw 
+      CALL lbc_lnk( aeiw, 'W', 1. )
+
+      ! Average the diffusive coefficient at u- v- points 
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            aeiu(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )
+            aeiv(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )
+         END DO 
+      END DO 
+
+      ! lateral boundary condition on aeiu, aeiv
+      CALL lbc_lnk( aeiu, 'U', 1. )
+      CALL lbc_lnk( aeiv, 'V', 1. )
+
+      IF(ln_ctl)   THEN
+         CALL prt_ctl(tab2d_1=aeiu, clinfo1=' eiv  - u: ', ovlap=1)
+         CALL prt_ctl(tab2d_1=aeiv, clinfo1=' eiv  - v: ', ovlap=1)
+      ENDIF
+
+      ! ORCA R05: add a space variation on aht (=aeiv except at the equator and river mouth)
+      IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN
+         zf20     = 2. * omega * SIN( rad * 20. )
+         zaht_min = 100.                              ! minimum value for aht
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zaht      = ( 1. -  MIN( 1., ABS( ff(ji,jj) / zf20 ) ) ) * ( aht0 - zaht_min )  &
+                  &      + aht0 * rnfmsk(ji,jj)                          ! enhanced near river mouths
+               ahtu(ji,jj) = MAX( MAX( zaht_min, aeiu(ji,jj) ) + zaht, aht0 )
+               ahtv(ji,jj) = MAX( MAX( zaht_min, aeiv(ji,jj) ) + zaht, aht0 )
+               ahtw(ji,jj) = MAX( MAX( zaht_min, aeiw(ji,jj) ) + zaht, aht0 )
+            END DO
+         END DO
+         IF(ln_ctl) THEN
+            CALL prt_ctl(tab2d_1=ahtu, clinfo1=' aht  - u: ', ovlap=1)
+            CALL prt_ctl(tab2d_1=ahtv, clinfo1=' aht  - v: ', ovlap=1)
+            CALL prt_ctl(tab2d_1=ahtw, clinfo1=' aht  - w: ', ovlap=1)
+         ENDIF
+      ENDIF
+
+      IF( aeiv0 == 0.e0 ) THEN
+         aeiu(:,:) = 0.e0
+         aeiv(:,:) = 0.e0
+         aeiw(:,:) = 0.e0
+      ENDIF
+
+      CALL iom_put( "aht2d"    , ahtw )   ! lateral eddy diffusivity
+      CALL iom_put( "aht2d_eiv", aeiw )   ! EIV lateral eddy diffusivity
+
+   END SUBROUTINE ldf_eiv
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Dummy module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ldf_eiv( kt )       ! Empty routine
+      WRITE(*,*) 'ldf_eiv: You should not have seen this print! error?', kt
+   END SUBROUTINE ldf_eiv
+#endif
+
+   !!======================================================================
+END MODULE ldfeiv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfeiv_substitute.h90	(revision 1844)
@@ -0,0 +1,39 @@
+#if defined key_traldf_eiv   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!                   ***  ldfeiv_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsaei. the eddy induced velocity coeff.
+   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#  if defined key_traldf_c3d
+!   'traldf_c3d' :                           eiv: 3D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(i,j,k)
+#    define   fsaeiv(i,j,k)   aeiv(i,j,k)
+#    define   fsaeiw(i,j,k)   aeiw(i,j,k)
+#  elif defined key_traldf_c2d
+!   'traldf_c2d' :                           eiv: 2D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(i,j)
+#    define   fsaeiv(i,j,k)   aeiv(i,j)
+#    define   fsaeiw(i,j,k)   aeiw(i,j)
+#  elif defined key_traldf_c1d
+!   'traldf_c1d' :                           eiv: 1D coefficient
+#    define   fsaeiu(i,j,k)   aeiu(k)
+#    define   fsaeiv(i,j,k)   aeiv(k)
+#    define   fsaeiw(i,j,k)   aeiw(k)
+#  else
+!   Default option :                          eiv: Constant coefficient
+#    define   fsaeiu(i,j,k)   aeiv0
+#    define   fsaeiv(i,j,k)   aeiv0
+#    define   fsaeiw(i,j,k)   aeiv0
+#  endif
+#else
+!   Default option :                         eiv: dummy variables
+#    define   fsaeiu(i,j,k)   aeiv0
+#    define   fsaeiv(i,j,k)   aeiv0
+#    define   fsaeiw(i,j,k)   aeiv0
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 1844)
@@ -0,0 +1,622 @@
+MODULE ldfslp
+   !!======================================================================
+   !!                       ***  MODULE  ldfslp  ***
+   !! Ocean physics: slopes of neutral surfaces
+   !!======================================================================
+   !! History :  OPA  ! 1994-12  (G. Madec, M. Imbard)  Original code
+   !!            8.0  ! 1997-06  (G. Madec)  optimization, lbc
+   !!            8.1  ! 1999-10  (A. Jouzeau)  NEW profile in the mixed layer
+   !!   NEMO     0.5  ! 2002-10  (G. Madec)  Free form, F90
+   !!            1.0  ! 2005-10  (A. Beckmann)  correction for s-coordinates
+   !!----------------------------------------------------------------------
+#if   defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                      Rotation of lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   ldf_slp      : compute the slopes of neutral surface
+   !!   ldf_slp_mxl  : compute the slopes of iso-neutral surface
+   !!   ldf_slp_init : initialization of the slopes computation
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce
+   USE ldfdyn_oce
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer depth
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ldf_slp    ! routine called by step.F90
+
+   LOGICAL , PUBLIC, PARAMETER              ::   lk_ldfslp = .TRUE.   !: slopes flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   uslp, wslpi          !: i_slope at U- and W-points
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   vslp, wslpj          !: j-slope at V- and W-points
+   
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   omlmask           ! mask of the surface mixed layer at T-pt
+   REAL(wp), DIMENSION(jpi,jpj)     ::   uslpml, wslpiml   ! i_slope at U- and W-points just below the mixed layer
+   REAL(wp), DIMENSION(jpi,jpj)     ::   vslpml, wslpjml   ! j_slope at V- and W-points just below the mixed layer
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_slp( kt, prd, pn2 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldf_slp  ***
+      !! 
+      !! ** Purpose :   Compute the slopes of neutral surface (slope of isopycnal
+      !!              surfaces referenced locally) ('key_traldfiso').
+      !! 
+      !! ** Method  :   The slope in the i-direction is computed at U- and 
+      !!      W-points (uslp, wslpi) and the slope in the j-direction is 
+      !!      computed at V- and W-points (vslp, wslpj).
+      !!      They are bounded by 1/100 over the whole ocean, and within the
+      !!      surface layer they are bounded by the distance to the surface
+      !!      ( slope<= depth/l  where l is the length scale of horizontal
+      !!      diffusion (here, aht=2000m2/s ==> l=20km with a typical velocity
+      !!      of 10cm/s)
+      !!        A horizontal shapiro filter is applied to the slopes
+      !!        ln_sco=T, s-coordinate, add to the previously computed slopes
+      !!      the slope of the model level surface.
+      !!        macro-tasked on horizontal slab (jk-loop)  (2, jpk-1)
+      !!      [slopes already set to zero at level 1, and to zero or the ocean
+      !!      bottom slope (ln_sco=T) at level jpk in inildf]
+      !!
+      !! ** Action : - uslp, wslpi, and vslp, wslpj, the i- and  j-slopes 
+      !!               of now neutral surfaces at u-, w- and v- w-points, resp.
+      !!----------------------------------------------------------------------
+      USE oce , zgru  => ua   ! use ua as workspace
+      USE oce , zgrv  => va   ! use va as workspace
+      USE oce , zwy   => ta   ! use ta as workspace
+      USE oce , zwz   => sa   ! use sa as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   prd   ! in situ density
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pn2   ! Brunt-Vaisala frequency (locally ref.)
+      !!
+      INTEGER  ::   ji , jj , jk    ! dummy loop indices
+      INTEGER  ::   ii0, ii1, iku   ! temporary integer
+      INTEGER  ::   ij0, ij1, ikv   ! temporary integer
+      REAL(wp) ::   zeps, zmg, zm05g, zalpha        ! temporary scalars
+      REAL(wp) ::   zcoef1, zcoef2, zcoef3          !    -         -
+      REAL(wp) ::   zcofu , zcofv , zcofw           !    -         -
+      REAL(wp) ::   zau, zbu, zai, zbi, z1u, z1wu   !    -         -
+      REAL(wp) ::   zav, zbv, zaj, zbj, z1v, z1wv   !
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zww     ! 3D workspace
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 )   CALL ldf_slp_init      ! initialization (first time-step only)
+
+      zeps  =  1.e-20                             ! Local constant initialization
+      zmg   = -1.0 / grav
+      zm05g = -0.5 / grav
+      !
+      zww(:,:,:) = 0.e0
+      zwz(:,:,:) = 0.e0
+      !                                           ! horizontal density gradient computation
+      DO jk = 1, jpk
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zgru(ji,jj,jk) = umask(ji,jj,jk) * ( prd(ji+1,jj  ,jk) - prd(ji,jj,jk) ) 
+               zgrv(ji,jj,jk) = vmask(ji,jj,jk) * ( prd(ji  ,jj+1,jk) - prd(ji,jj,jk) ) 
+            END DO
+         END DO
+      END DO
+      IF( ln_zps ) THEN                           ! partial steps correction at the bottom ocean level
+# if defined key_vectopt_loop  
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj) ) - 1               ! last ocean level
+               ikv = MIN ( mbathy(ji,jj), mbathy(ji,jj+1) ) - 1
+               zgru(ji,jj,iku) = gru(ji,jj) 
+               zgrv(ji,jj,ikv) = grv(ji,jj)               
+            END DO
+         END DO
+      ENDIF
+      
+      CALL ldf_slp_mxl( prd, pn2 )                ! Slopes of isopycnal surfaces just below the mixed layer
+
+      
+      ! I.  slopes at u and v point      | uslp = d/di( prd ) / d/dz( prd )
+      ! ===========================      | vslp = d/dj( prd ) / d/dz( prd )
+      !               
+      !                                           !* Local vertical density gradient evaluated from N^2
+      DO jk = 2, jpkm1                            !  zwy = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwy(ji,jj,jk) = zmg * ( prd(ji,jj,jk) + 1. ) * (    pn2  (ji,jj,jk) + pn2  (ji,jj,jk+1)     )   &
+                  &                                         / MAX( tmask(ji,jj,jk) + tmask(ji,jj,jk+1), 1. )
+            END DO
+         END DO
+      END DO
+      DO jk = 2, jpkm1                            !* Slopes at u and v points
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! horizontal and vertical density gradient at u- and v-points
+               zau = 1. / e1u(ji,jj) * zgru(ji,jj,jk)
+               zav = 1. / e2v(ji,jj) * zgrv(ji,jj,jk)
+               zbu = 0.5 * ( zwy(ji,jj,jk) + zwy(ji+1,jj  ,jk) )
+               zbv = 0.5 * ( zwy(ji,jj,jk) + zwy(ji  ,jj+1,jk) )
+               ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+               !                   kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbu = MIN( zbu, -100.*ABS( zau ), -7.e+3/fse3u(ji,jj,jk)*ABS( zau ) )
+               zbv = MIN( zbv, -100.*ABS( zav ), -7.e+3/fse3v(ji,jj,jk)*ABS( zav ) )
+               ! uslp and vslp output in zwz and zww, resp.
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj,jk) )
+               zwz (ji,jj,jk) = ( ( 1. - zalpha) * zau / ( zbu - zeps )                                           &
+                  &                    + zalpha  * uslpml(ji,jj)                                                  &
+                  &                              * 0.5 * ( fsdept(ji+1,jj,jk)+fsdept(ji,jj,jk)-fse3u(ji,jj,1) )   &
+                  &                              / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 5. ) ) * umask(ji,jj,jk)
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji,jj+1,jk) )
+               zww (ji,jj,jk) = ( ( 1. - zalpha) * zav / ( zbv - zeps )                                           &
+                  &                    + zalpha  * vslpml(ji,jj)                                                  &
+                  &                              * 0.5 * ( fsdept(ji,jj+1,jk)+fsdept(ji,jj,jk)-fse3v(ji,jj,1) )   &
+                  &                              / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 5. ) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zwz, 'U', -1. )   ;   CALL lbc_lnk( zww, 'V', -1. )      ! lateral boundary conditions
+      !
+      zcofu = 1. / 16.                            !* horizontal Shapiro filter
+      zcofv = 1. / 16.
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1, jpj-3                        ! rows jj=2 and =jpjm1 only
+            DO ji = 2, jpim1  
+               uslp(ji,jj,jk) = zcofu * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
+               vslp(ji,jj,jk) = zcofv * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+         DO jj = 3, jpj-2                               ! other rows
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               uslp(ji,jj,jk) = zcofu * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
+               vslp(ji,jj,jk) = zcofv * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+         !                                        !* decrease along coastal boundaries
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z1u  = ( umask(ji,jj+1,jk) + umask(ji,jj-1,jk) )*.5
+               z1v  = ( vmask(ji+1,jj,jk) + vmask(ji-1,jj,jk) )*.5
+               z1wu = ( umask(ji,jj,jk)   + umask(ji,jj,jk+1) )*.5
+               z1wv = ( vmask(ji,jj,jk)   + vmask(ji,jj,jk+1) )*.5
+               uslp(ji,jj,jk) = uslp(ji,jj,jk) * z1u * z1wu
+               vslp(ji,jj,jk) = vslp(ji,jj,jk) * z1v * z1wv
+            END DO
+         END DO
+      END DO
+
+
+      ! II.  slopes at w point           | wslpi = mij( d/di( prd ) / d/dz( prd )
+      ! ===========================      | wslpj = mij( d/dj( prd ) / d/dz( prd )
+      !               
+      !                                           !* Local vertical density gradient evaluated from N^2
+      DO jk = 2, jpkm1                            !  zwy = d/dz(prd)= - mk ( prd ) / grav * pn2 -- at w point
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwy(ji,jj,jk) = zm05g * pn2 (ji,jj,jk) * ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. )
+            END DO
+         END DO
+      END DO
+      DO jk = 2, jpkm1                            !* Slopes at w point
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !                                        ! horizontal density i-gradient at w-points
+               zcoef1 = MAX( zeps, umask(ji-1,jj,jk  )+umask(ji,jj,jk  )    &
+                  &               +umask(ji-1,jj,jk-1)+umask(ji,jj,jk-1) )
+               zcoef1 = 1. / ( zcoef1 * e1t (ji,jj) )
+               zai = zcoef1 * (  zgru(ji  ,jj,jk  ) + zgru(ji  ,jj,jk-1)   &
+                  &            + zgru(ji-1,jj,jk-1) + zgru(ji-1,jj,jk  ) ) * tmask (ji,jj,jk)
+               !                                        ! horizontal density j-gradient at w-points
+               zcoef2 = MAX( zeps, vmask(ji,jj-1,jk  )+vmask(ji,jj,jk-1)   &
+                  &               +vmask(ji,jj-1,jk-1)+vmask(ji,jj,jk  ) )
+               zcoef2 = 1.0 / ( zcoef2 *  e2t (ji,jj) )
+               zaj = zcoef2 * (  zgrv(ji,jj  ,jk  ) + zgrv(ji,jj  ,jk-1)   &
+                  &            + zgrv(ji,jj-1,jk-1) + zgrv(ji,jj-1,jk  ) ) * tmask (ji,jj,jk)
+               !                                        ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
+               !                                        ! static instability: kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbi = MIN( zwy (ji,jj,jk),- 100.*ABS(zai), -7.e+3/fse3w(ji,jj,jk)*ABS(zai) )
+               zbj = MIN( zwy (ji,jj,jk), -100.*ABS(zaj), -7.e+3/fse3w(ji,jj,jk)*ABS(zaj) )
+               !                                        ! wslpi and wslpj output in zwz and zww, resp.
+               zalpha = MAX( omlmask(ji,jj,jk), omlmask(ji,jj,jk-1) )
+               zcoef3 = fsdepw(ji,jj,jk) / MAX( hmlp(ji,jj), 10. )
+               zwz(ji,jj,jk) = (     zai / ( zbi - zeps)  * ( 1. - zalpha )   &
+                  &             + zcoef3 * wslpiml(ji,jj) *        zalpha   ) * tmask (ji,jj,jk)
+               zww(ji,jj,jk) = (     zaj / ( zbj - zeps)  * ( 1. - zalpha )   &
+                  &             + zcoef3 * wslpjml(ji,jj) *        zalpha   ) * tmask (ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zwz, 'T', -1. )   ;    CALL lbc_lnk( zww, 'T', -1. )      ! lateral boundary conditions on zwz and zww
+      !
+      !                                           !* horizontal Shapiro filter
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1, jpj-3                        ! rows jj=2 and =jpjm1
+            DO ji = 2, jpim1
+               zcofw = tmask(ji,jj,jk) / 16.
+               wslpi(ji,jj,jk) = (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                  &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                  &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                  &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zwz(ji  ,jj  ,jk)                        ) * zcofw
+
+               wslpj(ji,jj,jk) = (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                  &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                  &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                  &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zww(ji  ,jj  ,jk)                        ) * zcofw
+            END DO
+         END DO  
+         DO jj = 3, jpj-2                               ! other rows
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcofw = tmask(ji,jj,jk) / 16.
+               wslpi(ji,jj,jk) = (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                  &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                  &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                  &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zwz(ji  ,jj  ,jk)                        ) * zcofw
+
+               wslpj(ji,jj,jk) = (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                  &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                  &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                  &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                  &                + 4.*  zww(ji  ,jj  ,jk)                        ) * zcofw
+            END DO
+         END DO
+         !                                        !* decrease along coastal boundaries
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z1u = ( umask(ji,jj,jk) + umask(ji-1,jj,jk) ) *.5
+               z1v = ( vmask(ji,jj,jk) + vmask(ji,jj-1,jk) ) *.5
+               wslpi(ji,jj,jk) = wslpi(ji,jj,jk) * z1u * z1v
+               wslpj(ji,jj,jk) = wslpj(ji,jj,jk) * z1u * z1v
+            END DO
+         END DO
+      END DO
+         
+
+      ! III.  Specific grid points     
+      ! =========================== 
+      !               
+      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN     !  ORCA_R4 configuration: horizontal diffusion in specific area
+         !                                                    ! Gibraltar Strait
+         ij0 =  50   ;   ij1 =  53
+         ii0 =  69   ;   ii1 =  71   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ij0 =  51   ;   ij1 =  53
+         ii0 =  68   ;   ii1 =  71   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ii0 =  69   ;   ii1 =  71   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ii0 =  69   ;   ii1 =  71   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         !
+         !                                                    ! Mediterrannean Sea
+         ij0 =  49   ;   ij1 =  56
+         ii0 =  71   ;   ii1 =  90   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ij0 =  50   ;   ij1 =  56
+         ii0 =  70   ;   ii1 =  90   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ii0 =  71   ;   ii1 =  90   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+         ii0 =  71   ;   ii1 =  90   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0.e0
+      ENDIF
+
+      
+      ! IV. Lateral boundary conditions 
+      ! ===============================
+      CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+      CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk)
+         CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk)
+      ENDIF
+      !
+   END SUBROUTINE ldf_slp
+
+
+   SUBROUTINE ldf_slp_mxl( prd, pn2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_slp_mxl  ***
+      !!
+      !! ** Purpose :   Compute the slopes of iso-neutral surface just below 
+      !!              the mixed layer.
+      !!
+      !! ** Method :
+      !!      The slope in the i-direction is computed at u- and w-points
+      !!   (uslp, wslpi) and the slope in the j-direction is computed at
+      !!   v- and w-points (vslp, wslpj).
+      !!   They are bounded by 1/100 over the whole ocean, and within the
+      !!   surface layer they are bounded by the distance to the surface
+      !!   ( slope<= depth/l  where l is the length scale of horizontal
+      !!   diffusion (here, aht=2000m2/s ==> l=20km with a typical velocity
+      !!   of 10cm/s)
+      !!
+      !! ** Action :   Compute uslp, wslpi, and vslp, wslpj, the i- and  j-slopes
+      !!   of now neutral surfaces at u-, w- and v- w-points, resp.
+      !!----------------------------------------------------------------------
+      USE oce , zgru  => ua   ! ua, va used as workspace and set to hor. 
+      USE oce , zgrv  => va   ! density gradient in ldf_slp
+      !! 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   prd   ! in situ density
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   pn2   ! Brunt-Vaisala frequency (locally ref.)
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      INTEGER  ::   ik, ikm1             ! temporary integers
+      REAL(wp) ::   zeps, zmg, zm05g     ! temporary scalars
+      REAL(wp) ::   zcoef1, zcoef2       !    -         -
+      REAL(wp) ::   zau, zbu, zai, zbi   !    -         -
+      REAL(wp) ::   zav, zbv, zaj, zbj   !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwy   ! 2D workspace
+      !!----------------------------------------------------------------------
+
+      zeps  =  1.e-20                    ! Local constant initialization
+      zmg   = -1.0 / grav
+      zm05g = -0.5 / grav
+      !
+      uslpml (1,:) = 0.e0      ;      uslpml (jpi,:) = 0.e0
+      vslpml (1,:) = 0.e0      ;      vslpml (jpi,:) = 0.e0
+      wslpiml(1,:) = 0.e0      ;      wslpiml(jpi,:) = 0.e0
+      wslpjml(1,:) = 0.e0      ;      wslpjml(jpi,:) = 0.e0
+
+      !                                  ! surface mixed layer mask
+      DO jk = 1, jpk                          ! =1 inside the mixed layer, =0 otherwise
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+# endif
+               ik = nmln(ji,jj) - 1
+               IF( jk <= ik ) THEN   ;   omlmask(ji,jj,jk) = 1.e0
+               ELSE                  ;   omlmask(ji,jj,jk) = 0.e0
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+
+      ! Slopes of isopycnal surfaces just before bottom of mixed layer
+      ! --------------------------------------------------------------
+      ! The slope are computed as in the 3D case.
+      ! A key point here is the definition of the mixed layer at u- and v-points.
+      ! It is assumed to be the maximum of the two neighbouring T-point mixed layer depth.
+      ! Otherwise, a n2 value inside the mixed layer can be involved in the computation
+      ! of the slope, resulting in a too steep diagnosed slope and thus a spurious eddy
+      ! induce velocity field near the base of the mixed layer.
+      !-----------------------------------------------------------------------
+      !
+      zwy(:,jpj) = 0.e0            !* vertical density gradient for u-slope (from N^2)
+      zwy(jpi,:) = 0.e0
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) )       ! avoid spurious recirculation 
+            ik = MIN( ik, jpkm1 )                            ! if ik = jpk take jpkm1 values
+            zwy(ji,jj) = zmg * ( prd(ji,jj,ik) + 1. ) * (    pn2  (ji,jj,ik) + pn2  (ji,jj,ik+1)     )   &
+               &                                      / MAX( tmask(ji,jj,ik) + tmask(ji,jj,ik+1), 1. )
+         END DO
+      END DO
+      CALL lbc_lnk( zwy, 'U', 1. )      ! lateral boundary conditions NO sign change
+
+      !                            !* Slope at u points
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ! horizontal and vertical density gradient at u-points
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) )
+            ik = MIN( ik, jpkm1 )
+            zau = 1./ e1u(ji,jj) * zgru(ji,jj,ik)
+            zbu = 0.5*( zwy(ji,jj) + zwy(ji+1,jj) )
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+            !                         kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbu = MIN( zbu, -100.*ABS(zau), -7.e+3/fse3u(ji,jj,ik)*ABS(zau) )
+            ! uslpml
+            uslpml (ji,jj) = zau / ( zbu - zeps ) * umask (ji,jj,ik)
+         END DO
+      END DO
+      CALL lbc_lnk( uslpml, 'U', -1. )      ! lateral boundary conditions (i-gradient => sign change)
+
+      !                            !* vertical density gradient for v-slope (from N^2)
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) )
+            ik = MIN( ik, jpkm1 )
+            zwy(ji,jj) = zmg * ( prd(ji,jj,ik) + 1. ) * (    pn2  (ji,jj,ik) + pn2  (ji,jj,ik+1)     )   &
+               &                                      / MAX( tmask(ji,jj,ik) + tmask(ji,jj,ik+1), 1. )
+         END DO
+      END DO
+      CALL lbc_lnk( zwy, 'V', 1. )      ! lateral boundary conditions NO sign change
+
+      !                            !* Slope at v points
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ! horizontal and vertical density gradient at v-points
+            ik = MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) )
+            ik = MIN( ik,jpkm1 )
+            zav = 1./ e2v(ji,jj) * zgrv(ji,jj,ik)
+            zbv = 0.5*( zwy(ji,jj) + zwy(ji,jj+1) )
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+            !                         kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbv = MIN( zbv, -100.*ABS(zav), -7.e+3/fse3v(ji,jj,ik)*ABS( zav ) )
+            ! vslpml
+            vslpml (ji,jj) = zav / ( zbv - zeps ) * vmask (ji,jj,ik)
+         END DO
+      END DO
+      CALL lbc_lnk( vslpml, 'V', -1. )      ! lateral boundary conditions (j-gradient => sign change)
+
+
+      !                            !* vertical density gradient for w-slope (from N^2)
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+# endif
+            ik = nmln(ji,jj) + 1
+            ik = MIN( ik, jpk )
+            ikm1 = MAX ( 1, ik-1)
+            zwy (ji,jj) = zm05g * pn2 (ji,jj,ik) *     &
+               &             ( prd (ji,jj,ik) + prd (ji,jj,ikm1) + 2. )
+         END DO
+      END DO
+
+      !                            !* Slopes at w points
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ik = nmln(ji,jj) + 1
+            ik = MIN( ik, jpk )
+            ikm1 = MAX ( 1, ik-1 )
+            ! horizontal density i-gradient at w-points
+            zcoef1 = MAX( zeps, umask(ji-1,jj,ik  )+umask(ji,jj,ik  )   &
+               &               +umask(ji-1,jj,ikm1)+umask(ji,jj,ikm1) )
+            zcoef1 = 1. / ( zcoef1 * e1t (ji,jj) )
+            zai = zcoef1 * (  zgru(ji  ,jj,ik  ) + zgru(ji  ,jj,ikm1)   &
+               &            + zgru(ji-1,jj,ikm1) + zgru(ji-1,jj,ik  ) ) * tmask (ji,jj,ik)
+            ! horizontal density j-gradient at w-points
+            zcoef2 = MAX( zeps, vmask(ji,jj-1,ik  )+vmask(ji,jj,ikm1)    &
+               &               +vmask(ji,jj-1,ikm1)+vmask(ji,jj,ik  ) )
+            zcoef2 = 1.0 / ( zcoef2 *  e2t (ji,jj) )
+            zaj = zcoef2 * (  zgrv(ji,jj  ,ik  ) + zgrv(ji,jj  ,ikm1)   &
+               &            + zgrv(ji,jj-1,ikm1) + zgrv(ji,jj-1,ik  ) ) * tmask (ji,jj,ik)
+            ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
+            !                   static instability:
+            !                   kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+            zbi = MIN ( zwy (ji,jj),- 100.*ABS(zai), -7.e+3/fse3w(ji,jj,ik)*ABS(zai) )
+            zbj = MIN ( zwy (ji,jj), -100.*ABS(zaj), -7.e+3/fse3w(ji,jj,ik)*ABS(zaj) )
+            ! wslpiml and wslpjml
+            wslpiml (ji,jj) = zai / ( zbi - zeps) * tmask (ji,jj,ik)
+            wslpjml (ji,jj) = zaj / ( zbj - zeps) * tmask (ji,jj,ik)
+         END DO
+      END DO
+      CALL lbc_lnk( wslpiml, 'W', -1. )   ;   CALL lbc_lnk( wslpjml, 'W', -1. )      ! lateral boundary conditions
+      !
+   END SUBROUTINE ldf_slp_mxl
+
+
+   SUBROUTINE ldf_slp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_slp_init  ***
+      !!
+      !! ** Purpose :   Initialization for the isopycnal slopes computation
+      !!
+      !! ** Method  :   read the nammbf namelist and check the parameter 
+      !!      values called by tra_dmp at the first timestep (nit000)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      
+      IF(lwp) THEN    
+         WRITE(numout,*)
+         WRITE(numout,*) 'ldf_slp : direction of lateral mixing'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Direction of lateral diffusion (tracers and/or momentum)
+      ! ------------------------------
+      ! set the slope to zero (even in s-coordinates)
+
+      uslp (:,:,:) = 0.e0
+      vslp (:,:,:) = 0.e0
+      wslpi(:,:,:) = 0.e0
+      wslpj(:,:,:) = 0.e0
+
+      uslpml (:,:) = 0.e0
+      vslpml (:,:) = 0.e0
+      wslpiml(:,:) = 0.e0
+      wslpjml(:,:) = 0.e0
+
+      IF( (ln_traldf_hor .OR. ln_dynldf_hor) .AND. .NOT. (lk_vvl .AND. ln_rstart) ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '          Horizontal mixing in s-coordinate: slope = slope of s-surfaces'
+         ENDIF
+
+         ! geopotential diffusion in s-coordinates on tracers and/or momentum
+         ! The slopes of s-surfaces are computed once (no call to ldfslp in step)
+         ! The slopes for momentum diffusion are i- or j- averaged of those on tracers
+
+         ! set the slope of diffusion to the slope of s-surfaces
+         !      ( c a u t i o n : minus sign as fsdep has positive value )
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept(ji+1,jj,jk) - fsdept(ji ,jj ,jk) ) * umask(ji,jj,jk)
+                  vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept(ji,jj+1,jk) - fsdept(ji ,jj ,jk) ) * vmask(ji,jj,jk)
+                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw(ji+1,jj,jk) - fsdepw(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
+                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw(ji,jj+1,jk) - fsdepw(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
+               END DO
+            END DO
+         END DO
+         ! Lateral boundary conditions on the slopes
+         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+      ENDIF
+      !
+   END SUBROUTINE ldf_slp_init
+
+#else
+   !!------------------------------------------------------------------------
+   !!   Dummy module :                 NO Rotation of lateral mixing tensor
+   !!------------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_ldfslp = .FALSE.    !: slopes flag
+CONTAINS
+   SUBROUTINE ldf_slp( kt, prd, pn2 )        ! Dummy routine
+      INTEGER, INTENT(in) :: kt 
+      REAL, DIMENSION(:,:,:), INTENT(in) :: prd, pn2
+      WRITE(*,*) 'ldf_slp: You should not have seen this print! error?', kt, prd(1,1,1), pn2(1,1,1)
+   END SUBROUTINE ldf_slp
+#endif
+
+   !!======================================================================
+END MODULE ldfslp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 1844)
@@ -0,0 +1,161 @@
+MODULE ldftra
+   !!======================================================================
+   !!                       ***  MODULE  ldftra  ***
+   !! Ocean physics:  lateral diffusivity coefficient 
+   !!=====================================================================
+   !! History :        ! 1997-07  (G. Madec)  from inimix.F split in 2 routines
+   !!   NEMO      1.0  ! 2002-09  (G. Madec)  F90: Free form and module
+   !!             2.0  ! 2005-11  (G. Madec)  
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ldf_tra_init : initialization, namelist read, and parameters control
+   !!   ldf_tra_c3d   : 3D eddy viscosity coefficient initialization
+   !!   ldf_tra_c2d   : 2D eddy viscosity coefficient initialization
+   !!   ldf_tra_c1d   : 1D eddy viscosity coefficient initialization
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE ldfslp          ! ???
+   USE in_out_manager  ! I/O manager
+   USE ioipsl
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ldf_tra_init   ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ldf_tra_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_tra_init  ***
+      !! 
+      !! ** Purpose :   initializations of the tracer lateral mixing coeff.
+      !!
+      !! ** Method  :   the Eddy diffusivity and eddy induced velocity ceoff.
+      !!      are defined as follows:
+      !!         default option   : constant coef. aht0, aeiv0 (namelist)
+      !!        'key_traldf_c1d': depth dependent coef. defined in 
+      !!                            in ldf_tra_c1d routine
+      !!        'key_traldf_c2d': latitude and longitude dependent coef.
+      !!                            defined in ldf_tra_c2d routine
+      !!        'key_traldf_c3d': latitude, longitude, depth dependent coef.
+      !!                            defined in ldf_tra_c3d routine
+      !!
+      !!      N.B. User defined include files.  By default, 3d and 2d coef.
+      !!      are set to a constant value given in the namelist and the 1d
+      !!      coefficients are initialized to a hyperbolic tangent vertical
+      !!      profile.
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio               ! temporary integer
+      LOGICAL ::   ll_print = .FALSE.   ! =T print eddy coef. in numout
+      !! 
+      NAMELIST/namtra_ldf/ ln_traldf_lap  , ln_traldf_bilap,                  &
+         &                 ln_traldf_level, ln_traldf_hor  , ln_traldf_iso,   &
+         &                 rn_aht_0       , rn_ahtb_0      , rn_aeiv_0
+      !!----------------------------------------------------------------------
+
+      !  Define the lateral tracer physics parameters
+      ! =============================================
+    
+      REWIND( numnam )                  ! Read Namelist namtra_ldf : Lateral physics on tracers
+      READ  ( numnam, namtra_ldf )
+
+      IF(lwp) THEN                      ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'ldf_tra_init : lateral tracer physics'
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namtra_ldf : lateral mixing coefficients'
+         WRITE(numout,*) '      laplacian operator            ln_traldf_lap   = ', ln_traldf_lap
+         WRITE(numout,*) '      bilaplacian operator          ln_traldf_bilap = ', ln_traldf_bilap
+         WRITE(numout,*) '      lateral eddy diffusivity      rn_aht_0        = ', rn_aht_0
+         WRITE(numout,*) '      background hor. diffusivity   rn_ahtb_0       = ', rn_ahtb_0
+         WRITE(numout,*) '      eddy induced velocity coef.   rn_aeiv_0       = ', rn_aeiv_0
+         WRITE(numout,*)
+      ENDIF
+
+      !                                ! convert DOCTOR namelist names into OLD names
+      aht0  = rn_aht_0
+      ahtb0 = rn_ahtb_0
+      aeiv0 = rn_aeiv_0
+
+      !                                ! Parameter control
+
+      ! ... Check consistency for type and direction :
+      !           ==> will be done in traldf module
+
+      ! ... Space variation of eddy coefficients
+      ioptio = 0
+#if defined key_traldf_c3d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth)'
+      ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c2d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude)'
+      ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c1d
+      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( depth )'
+      ioptio = ioptio + 1
+      IF( .NOT. ln_zco )   CALL ctl_stop( 'key_traldf_c1d can only be used in z-coordinate - full step' )
+#endif
+      IF( ioptio == 0 ) THEN
+          IF(lwp) WRITE(numout,*) '          tracer mixing coef. = constant (default option)'
+        ELSEIF( ioptio > 1 ) THEN
+           CALL ctl_stop('          use only one of the following keys:',   &
+             &           ' key_traldf_c3d, key_traldf_c2d, key_traldf_c1d' )
+      ENDIF
+
+      IF( ln_traldf_bilap ) THEN
+         IF(lwp) WRITE(numout,*) '          biharmonic tracer diffusion'
+         IF( aht0 > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal diffusivity coef. aht0 must be negative' )
+      ELSE
+         IF(lwp) WRITE(numout,*) '          harmonic tracer diffusion (default)'
+         IF( aht0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop('The horizontal diffusivity coef. aht0 must be positive' )
+      ENDIF
+
+
+      !  Lateral eddy diffusivity and eddy induced velocity coefficients
+      ! ================================================================
+#if defined key_traldf_c3d
+      CALL ldf_tra_c3d( ll_print )      ! aht = 3D coef. = F( longitude, latitude, depth )
+#elif defined key_traldf_c2d
+      CALL ldf_tra_c2d( ll_print )      ! aht = 2D coef. = F( longitude, latitude )
+#elif defined key_traldf_c1d
+      CALL ldf_tra_c1d( ll_print )      ! aht = 1D coef. = F( depth )
+#else
+                                        ! Constant coefficients
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) '      constant eddy diffusivity coef.   ahtu = ahtv = ahtw = aht0 = ', aht0
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) '      constant eddy induced velocity coef.   aeiu = aeiv = aeiw = aeiv0 = ', aeiv0
+      ENDIF
+#endif
+      !
+   END SUBROUTINE ldf_tra_init
+
+#if defined key_traldf_c3d
+#   include "ldftra_c3d.h90"
+#elif defined key_traldf_c2d
+#   include "ldftra_c2d.h90"
+#elif defined key_traldf_c1d
+#   include "ldftra_c1d.h90"
+#endif
+
+   !!======================================================================
+END MODULE ldftra
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c1d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c1d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c1d.h90	(revision 1844)
@@ -0,0 +1,133 @@
+   !!----------------------------------------------------------------------
+   !!                      ***  ldftra_c1d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c1d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldftra_c1d  ***
+      !!              
+      !! ** Purpose :   1D eddy diffusivity coefficient
+      !!
+      !! ** Method  :   1D eddy diffusivity coefficients ( depth )
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!
+      !!       harmonic operator      : ahtt never used
+      !!          -1-  iso-model level: ahtu = ahtv defined at T-level
+      !!                                ahtw never used
+      !!          -2-  isopycnal or   : ahtu = ahtv defined at T-level
+      !!               geopotential     ahtw defined at w-level
+      !!
+      !!       eddy induced velocity
+      !!         always harmonic      : aeiu = aeiv defined at T-level
+      !!				  aeiw defined at w-level
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, print arrays in numout
+
+      !! * Local variables
+      INTEGER ::   jk                  ! dummy loop indices
+      REAL(wp) ::   &
+         zkah, zahr, za00 , za01,   &  ! temporary scalars
+         zahf, zahs, zahtf, zahts
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN 
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' ldf_tra_c1d : 1D eddy diffusivity and eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   -- ' 
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' inildf : 1D eddy diffusivity coefficient '
+         IF(lwp) WRITE(numout,*) ' ~~~~~~   -- '
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      ! initialization of the profile
+
+      ! ahts, ahtf: surface and bottom values
+      zahts = aht0
+      zahtf = aht0/4. 
+      ! zkah, zahr: depth of the inflection pt and width of inflection
+      zkah =  -300.
+      zahr =   300.
+      ! computation coefficients
+      za00 = TANH( ( -fsdept(1,1,1  ) - zkah ) / zahr )
+      za01 = TANH( ( -fsdept(1,1,jpk) - zkah ) / zahr )
+      zahf = ( zahts-zahtf ) / ( za00 - za01 )
+      zahs = zahts - zahf * za00
+
+      ! biharmonic operator : (T-point)
+      ! ==================== 
+
+      ! set ahtt at T-level
+      DO jk = 1, jpk
+         ahtt(jk) = zahs + zahf * TANH( (-fsdept(1,1,jk)-zkah) / zahr )
+      END DO
+
+      ! control print
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '         aht profile at T-level : '
+         WRITE(numout,*)
+         WRITE(numout,*) ' level    aht          depth t-level '
+         DO jk = 1, jpk
+            WRITE(numout,'(i6,2f12.4)') jk, ahtt(jk), fsdept(1,1,jk)
+         END DO
+      ENDIF
+
+      ! harmonic operator : (U-, V-, W-points)
+      ! ================== 
+
+      ! set ahtu = ahtv at T-level, and ahtw at w-level
+      DO jk = 1, jpk
+         ahtu(jk) = zahs + zahf * TANH( ( -fsdept(1,1,jk) - zkah ) / zahr )
+         ahtv(jk) = ahtu(jk)
+         ahtw(jk) = zahs + zahf * TANH( ( -fsdepw(1,1,jk) - zkah ) / zahr )
+      END DO
+
+      ! control print
+      IF(lwp .AND. ld_print ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aht profile at T-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' level    aht          depth t-level '
+         DO jk = 1, jpk
+            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, ahtu(jk), fsdept(1,1,jk)
+         END DO
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aht profile at W-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  jk      aht          depth w-level '
+         DO jk = 1, jpk
+            IF(lwp)WRITE(numout,"(i6,2f12.4)") jk, ahtw(jk), fsdepw(1,1,jk)
+         END DO
+      ENDIF
+
+# if defined key_traldf_eiv
+      ! set aeiu = aeiv and set aeiw (here same profile as on aht)
+      aeiu(:) = ahtu(:)
+      aeiv(:) = aeiu(:)
+      aeiw(:) = ahtw(:)
+      
+      ! Control print
+      IF(lwp .AND. ld_print ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '         aeiv profile at T-level : '
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '  jk      aeiv           depth t-level '
+         DO jk = 1, jpk
+            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, aeiu(jk), fsdept(1,1,jk)
+         END DO
+      ENDIF
+#endif
+
+   END SUBROUTINE ldf_tra_c1d
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c2d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c2d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c2d.h90	(revision 1844)
@@ -0,0 +1,172 @@
+   !!----------------------------------------------------------------------
+   !!                      ***  ldftra_c2d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c2d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldftra_c2d  ***
+      !!              
+      !! ** Purpose :   initializations of horizontally non uniform eddy 
+      !!      diffusivity coefficients
+      !!
+      !! ** Method :
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!       harmonic operator (ahtt never used)
+      !!           iso-model level   : ahtu, ahtv defined at u-, v-points
+      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
+      !!         or geopotential   
+      !!       eddy induced velocity
+      !!           always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, print arrays in numout
+
+      !! * Local variables
+      INTEGER ::   ji, jj                  ! dummy loop indices
+# if defined key_orca_r4
+      INTEGER :: i1, i2, j1, j2
+# endif
+      REAL(wp) ::   za00, zd_max, zeumax, zevmax, zetmax
+      
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' ldf_tra_c2d : 2D eddy diffusivity and eddy'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --  induced velocity coefficients'
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' ldf_tra2d : 2D eddy diffusivity coefficient'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --'
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
+      IF( lk_mpp ) CALL mpp_max( zd_max )   ! max over the global domain
+
+      ! harmonic operator : (U-, V-, W-points)
+      ! ==================
+      IF( ln_traldf_lap ) THEN
+  
+         za00 = aht0 / zd_max
+  
+         DO jj = 1, jpj 
+            DO ji = 1, jpi 
+               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) ) 
+               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) ) 
+               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
+               ahtu(ji,jj) = za00 * zeumax ! set ahtu = ahtv at u- and v-points, 
+               ahtv(ji,jj) = za00 * zevmax ! and ahtw at w-point (idem T-point) 
+               ahtw(ji,jj) = za00 * zetmax ! 
+            END DO
+         END DO
+
+         CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( ahtv, 'V', 1. )   ! (no change of sign)
+         CALL lbc_lnk( ahtw, 'W', 1. )
+
+         ! Special case for ORCA R2 and R4 configurations (overwrite the value of ahtu ahtv ahtw)
+         ! ==============================================
+         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) )   THEN
+            ahtu(:,:) = aht0              ! set ahtu = ahtv at u- and v-points,
+            ahtv(:,:) = aht0              ! and ahtw at w-point
+            ahtw(:,:) = aht0              ! (here : no space variation)
+            IF(lwp) WRITE(numout,*) '               ORCA R2 or R4 case'
+            IF(lwp) WRITE(numout,*) '               Constant values used for eddy diffusivity coefficients'
+            IF(lwp) WRITE(numout,*) '               Variation lat/lon only for eddy induced velocity coefficients'
+         ENDIF
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtu array'
+            CALL prihre( ahtu, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtv array'
+            CALL prihre( ahtv, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: ahtw array'
+            CALL prihre( ahtw, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+         ENDIF
+      ENDIF
+      
+      ! biharmonic operator : (T-point)
+      ! ====================
+      IF( ln_traldf_bilap ) THEN
+         ! (USER: modify ahtt following your desiderata)
+         ! Here: ahm is proportional to the cube of the maximum of the gridspacing
+         !       in the to horizontal direction
+
+         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
+         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
+
+         za00 = aht0 / ( zd_max * zd_max * zd_max )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
+               ahtt(ji,jj) = za00 * zetmax * zetmax * zetmax      ! set ahtt at T-point
+            END DO
+         END DO
+
+         CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
+
+         ! Control print
+         IF( lwp .AND. ld_print ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'inildf: 2D ahtt array'
+            CALL prihre( ahtt, jpi, jpj, 1, jpi, 1,   &
+               &                         1, jpj, 1, 1.e-3, numout )
+         ENDIF
+      ENDIF
+
+# if defined key_traldf_eiv
+      ! set aeiu = aeiv at u- and v-points, and aeiw at w-point (idem T-point)
+      ! (here no space variation)
+      aeiu(:,:) = aeiv0
+      aeiv(:,:) = aeiv0
+      aeiw(:,:) = aeiv0
+      
+      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
+         !                                 ! Cancel eiv in Gibraltar strait
+         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
+         !                                 ! Cancel eiv in Mediterrannean sea
+         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
+      ENDIF
+
+      ! Lateral boundary conditions on ( aeiu, aeiv, aeiw )
+      CALL lbc_lnk( aeiu, 'U', 1. )
+      CALL lbc_lnk( aeiv, 'V', 1. )
+      CALL lbc_lnk( aeiw, 'W', 1. )
+
+      ! Control print
+      IF( lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiu array'
+         CALL prihre(aeiu,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiv array'
+         CALL prihre(aeiv,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiw array'
+         CALL prihre(aeiw,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+# endif
+
+   END SUBROUTINE ldf_tra_c2d
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c3d.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c3d.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_c3d.h90	(revision 1844)
@@ -0,0 +1,130 @@
+   !!----------------------------------------------------------------------
+   !!                        ***  ldftra_c3d.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_tra_c3d( ld_print )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldftra_c3d  ***
+      !!                
+      !! ** Purpose :
+      !!     initializations of non uniform horizontal eddy diffusivity coef.
+      !!
+      !! ** Method :
+      !!      3D eddy diffusivity coefficients ( longitude, latitude, depth )
+      !!
+      !!       biharmonic operator    : ahtt = defined at T-level
+      !!                                ahtu,ahtv,ahtw never used
+      !!
+      !!       harmonic operator (ahtt never used)
+      !!         iso-model level   : ahtu, ahtv defined at u-, v-points
+      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
+      !!         or geopotential
+      !!
+      !!       eddy induced velocity
+      !!         always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
+      !!
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ioipsl
+
+      !! * Arguments
+      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
+
+      !!----------------------------------------------------------------------
+
+      IF( lk_traldf_eiv ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' ldf_tra_c3d : 3D eddy diffusivity and eddy induced velocity coefficients'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --  '
+         IF(lwp) WRITE(numout,*) '               Coefficients set to constant'
+         IF(lwp) WRITE(numout,*)
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' ldf_tra_c3d : 3D eddy diffusivity coefficient'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   -- '
+         IF(lwp) WRITE(numout,*) '               Coefficients set to constant'
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+
+      ! biharmonic operator   (T-point)
+      ! -------------------
+
+      ahtt(:,:,:) = aht0              ! set ahtt at T-point (here no space variation)
+
+      CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
+
+      IF(lwp .AND. ld_print ) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtt at k = 1'
+         CALL prihre( ahtt(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+      ENDIF
+
+
+      ! harmonic operator   (U-, V-, W-points)
+      ! ----------------- 
+
+      ahtu(:,:,:) = aht0              ! set ahtu = ahtv at u- and v-points,
+      ahtv(:,:,:) = aht0              ! and ahtw at w-point
+      ahtw(:,:,:) = aht0              ! (here example: no space variation)
+      
+      CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
+      CALL lbc_lnk( ahtv, 'V', 1. )
+      CALL lbc_lnk( ahtw, 'W', 1. )
+
+      IF(lwp .AND. ld_print ) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtu at k = 1'
+         CALL prihre( ahtu(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtv at k = 1'
+         CALL prihre( ahtv(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: ahtw at k = 1'
+         CALL prihre( ahtw(:,:,1), jpi, jpj, 1, jpi, 1,   &
+            &                                1, jpj, 1, 1.e-3, numout )
+      ENDIF
+
+# if defined key_traldf_eiv
+      aeiu(:,:,:) = aeiv0            ! set aeiu = aeiv at u- and v-points,
+      aeiv(:,:,:) = aeiv0            ! and aeiw at w-point
+      aeiw(:,:,:) = aeiv0            ! (here example: no space variation)
+
+      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
+         !                                 ! Cancel eiv in Gibraltar strait
+         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
+         !                                 ! Cancel eiv in Mediterrannean sea
+         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
+      ENDIF
+
+      CALL lbc_lnk( aeiu, 'U', 1. )   ! Lateral boundary conditions 
+      CALL lbc_lnk( aeiv, 'V', 1. )
+      CALL lbc_lnk( aeiw, 'W', 1. )
+# endif
+
+      IF(lwp .AND. ld_print ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiu at k = 1'
+         CALL prihre(aeiu(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiv at k = 1'
+         CALL prihre(aeiv(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+         WRITE(numout,*)
+         WRITE(numout,*) 'inildf: aeiw at k = 1'
+         CALL prihre(aeiw(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
+      ENDIF
+
+END SUBROUTINE ldf_tra_c3d
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_oce.F90	(revision 1844)
@@ -0,0 +1,71 @@
+MODULE ldftra_oce
+   !!=====================================================================
+   !!                      ***  MODULE  ldftra_oce  ***
+   !! Ocean physics :  lateral tracer mixing coefficient defined in memory 
+   !!=====================================================================
+   !! History :  9.0  !  02-11  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !!----------------------------------------------------------------------
+   !! Lateral eddy diffusivity coefficients (tracers)
+   !!----------------------------------------------------------------------
+   !                                                !!* Namelist namtra_ldf : lateral mixing *
+   LOGICAL , PUBLIC ::   ln_traldf_lap   = .TRUE.    !: laplacian operator
+   LOGICAL , PUBLIC ::   ln_traldf_bilap = .FALSE.   !: bilaplacian operator
+   LOGICAL , PUBLIC ::   ln_traldf_level = .FALSE.   !: iso-level direction
+   LOGICAL , PUBLIC ::   ln_traldf_hor   = .FALSE.   !: horizontal (geopotential) direction
+   LOGICAL , PUBLIC ::   ln_traldf_iso   = .TRUE.    !: iso-neutral direction
+   REAL(wp), PUBLIC ::   rn_aht_0        = 2000._wp  !: lateral eddy diffusivity (m2/s)
+   REAL(wp), PUBLIC ::   rn_ahtb_0       =    0._wp  !: lateral background eddy diffusivity (m2/s)
+   REAL(wp), PUBLIC ::   rn_aeiv_0       = 2000._wp  !: eddy induced velocity coefficient (m2/s)
+
+   REAL(wp), PUBLIC ::   aht0, ahtb0, aeiv0         !!: OLD namelist names
+
+#if defined key_traldf_c3d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   ahtt, ahtu, ahtv, ahtw   !: ** 3D coefficients ** at T-, U-, V-, W-points
+#elif defined key_traldf_c2d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ahtt, ahtu, ahtv, ahtw   !: ** 2D coefficients ** at T-, U-, V-, W-points
+#elif defined key_traldf_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpk)         ::   ahtt, ahtu, ahtv, ahtw   !: ** 1D coefficients ** at T-, U-, V-, W-points
+#else
+   REAL(wp), PUBLIC                         ::   ahtt, ahtu, ahtv, ahtw   !: ** 0D coefficients ** at T-, U-, V-, W-points
+#endif
+
+
+#if defined key_traldf_eiv
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_eiv'                              eddy induced velocity
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_traldf_eiv   = .TRUE.   !: eddy induced velocity flag
+      
+# if defined key_traldf_c3d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   aeiu, aeiv, aeiw  !: ** 3D coefficients ** at U-, V-, W-points  [m2/s]
+# elif defined key_traldf_c2d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   aeiu, aeiv, aeiw  !: ** 2D coefficients ** at U-, V-, W-points  [m2/s]
+# elif defined key_traldf_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpk)         ::   aeiu, aeiv, aeiw  !: ** 1D coefficients ** at U-, V-, W-points  [m2/s]
+# else
+   REAL(wp), PUBLIC                         ::   aeiu, aeiv, aeiw  !: ** 0D coefficients ** at U-, V-, W-points  [m2/s]
+# endif
+# if defined key_diaeiv
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   u_eiv, v_eiv, w_eiv   !: eddy induced velocity [m/s]
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                           NO eddy induced velocity
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_traldf_eiv   = .FALSE.   !: eddy induced velocity flag
+   REAL(wp), PUBLIC            ::   aeiu, aeiv, aeiw            !: eddy induced coef. (not used)
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!=====================================================================
+END MODULE ldftra_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/LDF/ldftra_substitute.h90	(revision 1844)
@@ -0,0 +1,36 @@
+   !!----------------------------------------------------------------------
+   !!                    *** ldftra_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsaht. the eddy diffusivity coeff.
+   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_traldf_c3d
+!   'key_traldf_c3d' :                 aht: 3D coefficient
+#       define   fsahtt(i,j,k)   ahtt(i,j,k)
+#       define   fsahtu(i,j,k)   ahtu(i,j,k)
+#       define   fsahtv(i,j,k)   ahtv(i,j,k)
+#       define   fsahtw(i,j,k)   ahtw(i,j,k)
+#elif defined key_traldf_c2d
+!   'key_traldf_c2d' :                 aht: 2D coefficient
+#       define   fsahtt(i,j,k)   ahtt(i,j)
+#       define   fsahtu(i,j,k)   ahtu(i,j)
+#       define   fsahtv(i,j,k)   ahtv(i,j)
+#       define   fsahtw(i,j,k)   ahtw(i,j)
+#elif defined key_traldf_c1d
+!   'key_traldf_c1d' :                aht: 1D coefficient
+#       define   fsahtt(i,j,k)   ahtt(k)
+#       define   fsahtu(i,j,k)   ahtu(k)
+#       define   fsahtv(i,j,k)   ahtv(k)
+#       define   fsahtw(i,j,k)   ahtw(k)
+#else
+!   Default option :             aht: Constant coefficient
+#      define   fsahtt(i,j,k)   aht0
+#      define   fsahtu(i,j,k)   aht0
+#      define   fsahtv(i,j,k)   aht0
+#      define   fsahtw(i,j,k)   aht0
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_oce.F90	(revision 1844)
@@ -0,0 +1,237 @@
+MODULE obc_oce
+   !!==============================================================================
+   !!                       ***  MODULE obc_oce   ***
+   !! Open Boundary Cond. :   define related variables
+   !!==============================================================================
+   !!----------------------------------------------------------------------
+   !!   'key_obc' :                                 Open Boundary Condition
+   !!----------------------------------------------------------------------
+   !! history :
+   !!  8.0   01/91   (CLIPPER)  Original code 
+   !!  8.5   06/02   (C. Talandier)  modules
+   !!        06/04   (F. Durand) ORCA2_ZIND config
+   !!                 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! ocean parameters
+   USE obc_par         ! open boundary condition parameters
+
+#if defined key_obc
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !! open boundary variables
+   !!----------------------------------------------------------------------
+   !
+   !                                  !!* Namelist namobc: open boundary condition *
+   INTEGER           ::   nn_obcdta   = 0        !:  = 0 use the initial state as obc data
+   !                                             !   = 1 read obc data in obcxxx.dta files
+   CHARACTER(len=20) ::   cn_obcdta   = 'annual' !: set to annual  if obc datafile hold 1 year of data
+   !                                             !  set to monthly if obc datafile hold 1 month of data
+   LOGICAL           ::   ln_obc_clim = .true.   !:  obc data files are climatological
+   LOGICAL           ::   ln_obc_fla  = .false.  !:  Flather open boundary condition not used
+   LOGICAL           ::   ln_vol_cst  = .true.   !:  Conservation of the whole volume
+   REAL(wp)          ::   rn_dpein    =  1.      !: damping time scale for inflow at East open boundary
+   REAL(wp)          ::   rn_dpwin    =  1.      !:    "                      "   at West open boundary
+   REAL(wp)          ::   rn_dpsin    =  1.      !:    "                      "   at South open boundary
+   REAL(wp)          ::   rn_dpnin    =  1.      !:    "                      "   at North open boundary
+   REAL(wp)          ::   rn_dpeob    = 15.      !: damping time scale for the climatology at East open boundary
+   REAL(wp)          ::   rn_dpwob    = 15.      !:    "                           "       at West open boundary
+   REAL(wp)          ::   rn_dpsob    = 15.      !:    "                           "       at South open boundary
+   REAL(wp)          ::   rn_dpnob    = 15.      !:    "                           "       at North open boundary
+   REAL(wp)          ::   rn_volemp   =  1.      !: = 0 the total volume will have the variability of the 
+   !                                             !      surface Flux E-P else (volemp = 1) the volume will be constant
+   !                                             !  = 1 the volume will be constant during all the integration.
+
+   !                                  !!! OLD non-DOCTOR name of namelist variables
+   INTEGER  ::   nbobc                 !: number of open boundaries ( 1=< nbobc =< 4 ) 
+   INTEGER  ::   nobc_dta              !:  = 0 use the initial state as obc data
+   REAL(wp) ::   rdpein                !: damping time scale for inflow at East open boundary
+   REAL(wp) ::   rdpwin                !:    "                      "   at West open boundary
+   REAL(wp) ::   rdpsin                !:    "                      "   at South open boundary
+   REAL(wp) ::   rdpnin                !:    "                      "   at North open boundary
+   REAL(wp) ::   rdpeob                !: damping time scale for the climatology at East open boundary
+   REAL(wp) ::   rdpwob                !:    "                           "       at West open boundary
+   REAL(wp) ::   rdpsob                !:    "                           "       at South open boundary
+   REAL(wp) ::   rdpnob                !:    "                           "       at North open boundary
+   REAL(wp) ::   volemp                !: = 0 the total volume will have the variability of the 
+   CHARACTER(len=20) :: cffile
+
+
+   !!General variables for open boundaries:
+   !!--------------------------------------
+   LOGICAL ::              &  !:
+      lfbceast, lfbcwest,  &  !: logical flag for a fixed East and West open boundaries       
+      lfbcnorth, lfbcsouth    !: logical flag for a fixed North and South open boundaries       
+      !                       !  These logical flags are set to 'true' if damping time 
+      !                       !  scale are set to 0 in the namelist, for both inflow and outflow).
+
+   REAL(wp), PUBLIC ::   obcsurftot       !: Total lateral surface of open boundaries
+   
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: &  !:
+      obctmsk,            &  !: mask array identical to tmask, execpt along OBC where it is set to 0
+      !                      !  it used to calculate the cumulate flux E-P in the obcvol.F90 routine
+      obcumask, obcvmask     !: u-, v- Force filtering mask for the open
+      !                      !  boundary condition on grad D
+
+   !!--------------------
+   !! East open boundary:
+   !!--------------------
+   INTEGER ::   nie0  , nie1      !: do loop index in mpp case for jpieob
+   INTEGER ::   nie0p1, nie1p1    !: do loop index in mpp case for jpieob+1
+   INTEGER ::   nie0m1, nie1m1    !: do loop index in mpp case for jpieob-1
+   INTEGER ::   nje0  , nje1      !: do loop index in mpp case for jpjed, jpjef
+   INTEGER ::   nje0p1, nje1m1    !: do loop index in mpp case for jpjedp1,jpjefm1
+   INTEGER ::   nje1m2, nje0m1    !: do loop index in mpp case for jpjefm1-1,jpjed
+
+   REAL(wp), DIMENSION(jpjed:jpjef) ::   &  !:
+      sshfoe,           & !: now climatology of the east boundary sea surface height
+      ubtfoe,vbtfoe       !: now climatology of the east boundary barotropic transport
+     
+   REAL(wp), DIMENSION(jpj,jpk) ::   &  !:
+      ufoe, vfoe,       & !: now climatology of the east boundary velocities 
+      tfoe, sfoe,       & !: now climatology of the east boundary temperature and salinity
+      uclie               !: baroclinic componant of the zonal velocity after radiation 
+      !                   ! in the obcdyn.F90 routine
+
+   REAL(wp), DIMENSION(jpjed:jpjef,jpj) ::   sshfoe_b      !: east boundary ssh correction averaged over the barotropic loop
+      !                                                    !  (if Flather's algoritm applied at open boundary)
+
+   !!-------------------------------
+   !! Arrays for radiative East OBC: 
+   !!-------------------------------
+   REAL(wp), DIMENSION(jpj,jpk,3,3) ::   uebnd, vebnd      !: baroclinic u & v component of the velocity over 3 rows 
+      !                                                    !  and 3 time step (now, before, and before before)
+   REAL(wp), DIMENSION(jpj,jpk,2,2) ::   tebnd, sebnd      !: East boundary temperature and salinity over 2 rows 
+      !                                                    !  and 2 time step (now and before)
+   REAL(wp), DIMENSION(jpj,jpk) ::   u_cxebnd, v_cxebnd    !: Zonal component of the phase speed ratio computed with 
+      !                                                    !  radiation of u and v velocity (respectively) at the 
+      !                                                    !  east open boundary (u_cxebnd = cx rdt )
+   REAL(wp), DIMENSION(jpj,jpk) ::   uemsk, vemsk, temsk   !: 2D mask for the East OB
+
+   ! Note that those arrays are optimized for mpp case 
+   ! (hence the dimension jpj is the size of one processor subdomain)
+
+   !!--------------------
+   !! West open boundary
+   !!--------------------
+   INTEGER ::   niw0  , niw1       !: do loop index in mpp case for jpiwob
+   INTEGER ::   niw0p1, niw1p1     !: do loop index in mpp case for jpiwob+1
+   INTEGER ::   njw0  , njw1       !: do loop index in mpp case for jpjwd, jpjwf
+   INTEGER ::   njw0p1, njw1m1     !: do loop index in mpp case for jpjwdp1,jpjwfm1
+   INTEGER ::   njw1m2, njw0m1     !: do loop index in mpp case for jpjwfm2,jpjwd
+
+   REAL(wp), DIMENSION(jpjwd:jpjwf) ::   &  !:
+      sshfow,           & !: now climatology of the west boundary sea surface height
+      ubtfow,vbtfow       !: now climatology of the west boundary barotropic transport
+
+   REAL(wp), DIMENSION(jpj,jpk) ::   &  !:
+      ufow, vfow,       & !: now climatology of the west velocities 
+      tfow, sfow,       & !: now climatology of the west temperature and salinity
+      ucliw               !: baroclinic componant of the zonal velocity after the radiation 
+      !                   !  in the obcdyn.F90 routine
+
+   REAL(wp), DIMENSION(jpjwd:jpjwf,jpj) ::   sshfow_b    !: west boundary ssh correction averaged over the barotropic loop
+      !                                                  !  (if Flather's algoritm applied at open boundary)
+
+   !!-------------------------------
+   !! Arrays for radiative West OBC
+   !!-------------------------------
+   REAL(wp), DIMENSION(jpj,jpk,3,3) ::   uwbnd, vwbnd     !: baroclinic u & v components of the velocity over 3 rows 
+      !                                                   !  and 3 time step (now, before, and before before)
+   REAL(wp), DIMENSION(jpj,jpk,2,2) ::   twbnd, swbnd     !: west boundary temperature and salinity over 2 rows and 
+      !                                                   !  2 time step (now and before)
+   REAL(wp), DIMENSION(jpj,jpk) ::   u_cxwbnd, v_cxwbnd   !: Zonal component of the phase speed ratio computed with 
+      !                                                   !  radiation of zonal and meridional velocity (respectively) 
+      !                                                   !  at the west open boundary (u_cxwbnd = cx rdt )
+   REAL(wp), DIMENSION(jpj,jpk) ::   uwmsk, vwmsk, twmsk  !: 2D mask for the West OB
+
+   ! Note that those arrays are optimized for mpp case 
+   ! (hence the dimension jpj is the size of one processor subdomain)
+
+   !!---------------------
+   !! North open boundary
+   !!---------------------
+   INTEGER ::   nin0  , nin1       !: do loop index in mpp case for jpind, jpinf
+   INTEGER ::   nin0p1, nin1m1     !: do loop index in mpp case for jpindp1, jpinfm1
+   INTEGER ::   nin1m2, nin0m1     !: do loop index in mpp case for jpinfm1-1,jpind
+   INTEGER ::   njn0  , njn1       !: do loop index in mpp case for jpnob
+   INTEGER ::   njn0p1, njn1p1     !: do loop index in mpp case for jpnob+1
+   INTEGER ::   njn0m1, njn1m1     !: do loop index in mpp case for jpnob-1
+
+   REAL(wp), DIMENSION(jpind:jpinf) ::   &  !:
+      sshfon,           & !: now climatology of the north boundary sea surface height
+      ubtfon,vbtfon       !: now climatology of the north boundary barotropic transport
+
+   REAL(wp), DIMENSION(jpi,jpk) ::   &    !:
+      ufon, vfon,       & !: now climatology of the north boundary velocities
+      tfon, sfon,       & !: now climatology of the north boundary temperature and salinity
+      vclin               !: baroclinic componant of the meridian velocity after the radiation
+      !                   !  in yhe obcdyn.F90 routine
+
+   REAL(wp), DIMENSION(jpind:jpinf,jpj) ::   sshfon_b      !: north boundary ssh correction averaged over the barotropic loop
+      !                                                    !  (if Flather's algoritm applied at open boundary)
+
+   !!--------------------------------
+   !! Arrays for radiative North OBC
+   !!--------------------------------
+   REAL(wp), DIMENSION(jpi,jpk,3,3) ::   unbnd, vnbnd      !: baroclinic u & v components of the velocity over 3
+      !                                                    !  rows and 3 time step (now, before, and before before)
+   REAL(wp), DIMENSION(jpi,jpk,2,2) ::   tnbnd, snbnd      !: north boundary temperature and salinity over
+      !                                                    !  2 rows and 2 time step (now and before)
+   REAL(wp), DIMENSION(jpi,jpk) ::   u_cynbnd, v_cynbnd    !: Meridional component of the phase speed ratio compu-
+      !                                                    !  ted with radiation of zonal and meridional velocity 
+      !                                                    !  (respectively) at the north OB (u_cynbnd = cx rdt )
+   REAL(wp), DIMENSION(jpi,jpk) ::   unmsk, vnmsk, tnmsk   !: 2D mask for the North OB
+
+   ! Note that those arrays are optimized for mpp case 
+   ! (hence the dimension jpj is the size of one processor subdomain)
+   
+   !!---------------------
+   !! South open boundary
+   !!---------------------
+   INTEGER ::   nis0  , nis1       !: do loop index in mpp case for jpisd, jpisf
+   INTEGER ::   nis0p1, nis1m1     !: do loop index in mpp case for jpisdp1, jpisfm1
+   INTEGER ::   nis1m2, nis0m1     !: do loop index in mpp case for jpisfm1-1,jpisd
+   INTEGER ::   njs0  , njs1       !: do loop index in mpp case for jpsob
+   INTEGER ::   njs0p1, njs1p1     !: do loop index in mpp case for jpsob+1
+
+   REAL(wp), DIMENSION(jpisd:jpisf) ::    &   !:
+      sshfos,           & !: now climatology of the south boundary sea surface height
+      ubtfos,vbtfos       !: now climatology of the south boundary barotropic transport
+
+   REAL(wp), DIMENSION(jpi,jpk) ::    &   !:
+      ufos, vfos,       & !: now climatology of the south boundary velocities 
+      tfos, sfos,       & !: now climatology of the south boundary temperature and salinity
+      vclis               !: baroclinic componant of the meridian velocity after the radiation 
+      !                   !  in the obcdyn.F90 routine
+
+   REAL(wp), DIMENSION(jpisd:jpisf,jpj) ::   sshfos_b     !: south boundary ssh correction averaged over the barotropic loop
+      !                                                   !  (if Flather's algoritm applied at open boundary)
+
+   !!--------------------------------
+   !! Arrays for radiative South OBC   (computed by the forward time step in dynspg)
+   !!--------------------------------
+   REAL(wp), DIMENSION(jpi,jpk,3,3) ::   usbnd, vsbnd     !: baroclinic u & v components of the velocity over 3 
+      !                                                   !  rows and 3 time step (now, before, and before before)
+   REAL(wp), DIMENSION(jpi,jpk,2,2) ::   tsbnd, ssbnd     !: south boundary temperature and salinity over
+      !                                                   !  2 rows and 2 time step (now and before)
+   REAL(wp), DIMENSION(jpi,jpk) ::   u_cysbnd, v_cysbnd   !: Meridional component of the phase speed ratio
+      !                                                   !  computed with radiation of zonal and meridional velocity 
+      !                                                   !  (repsectively) at the south OB (u_cynbnd = cx rdt )
+   REAL(wp), DIMENSION(jpi,jpk) ::   usmsk, vsmsk, tsmsk  !: 2D mask for the South OB
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!======================================================================
+END MODULE obc_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par.F90	(revision 1844)
@@ -0,0 +1,100 @@
+MODULE obc_par
+   !!==============================================================================
+   !!                  ***  MODULE obc_par   ***
+   !! Open Boundary Cond. :   define related parameters
+   !!==============================================================================
+#if defined key_obc
+   !!----------------------------------------------------------------------
+   !!   'key_obc' :                                 Open Boundary Condition
+   !!----------------------------------------------------------------------
+   !! history :
+   !!  8.0   01/91   (CLIPPER)  Original code 
+   !!  9.0   06/02   (C. Talandier)  modules
+   !!        06/04   (F. Durand) ORCA_R2_ZIND config
+   !!        06/04   (F. Durand) jptobc is defined as a parameter, 
+   !!	     	     in order to allow time-dependent OBCs fields on input
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_obc = .TRUE.   !: Ocean Boundary Condition flag
+
+# if defined key_eel_r5
+   !!----------------------------------------------------------------------
+   !!   'key_eel_r5' :                                 EEL R5 configuration
+   !!----------------------------------------------------------------------
+#    include "obc_par_EEL_R5.h90"
+
+# elif defined key_pomme_r025
+   !!----------------------------------------------------------------------
+   !!   'key_pomme_r025' :                         POMME R025 configuration
+   !!----------------------------------------------------------------------
+#    include "obc_par_POMME_R025.h90"
+
+# else
+   !!---------------------------------------------------------------------
+   !! open boundary parameter
+   !!---------------------------------------------------------------------
+   INTEGER, PARAMETER ::     &  !: time dimension of the BCS fields on input
+      jptobc  =	      2 
+   !! * EAST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_east = .FALSE.     !: to active or not the East open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpieob  = jpiglo-2,    &  !: i-localization of the East open boundary (must be ocean U-point)
+      jpjed   =        2,    &  !: j-starting indice of the East open boundary (must be land T-point)
+      jpjef   = jpjglo-1,    &  !: j-ending   indice of the East open boundary (must be land T-point)
+      jpjedp1 =  jpjed+1,    &  !: first ocean point         "                 "
+      jpjefm1 =  jpjef-1        !: last  ocean point         "                 "
+
+   !! * WEST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_west = .FALSE.     !: to active or not the West open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpiwob  =	       2,    &  !: i-localization of the West open boundary (must be ocean U-point)
+      jpjwd   =	       2,    &  !: j-starting indice of the West open boundary (must be land T-point)
+      jpjwf   = jpjglo-1,    &  !: j-ending   indice of the West open boundary (must be land T-point)
+      jpjwdp1 =  jpjwd+1,    &  !: first ocean point         "                 "
+      jpjwfm1 =  jpjwf-1        !: last  ocean point         "                 "
+
+   !! * NORTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_north = .FALSE.    !: to active or not the North open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpjnob  = jpjglo-2,    &  !: j-localization of the North open boundary (must be ocean V-point)
+      jpind   =        2,    &  !: i-starting indice of the North open boundary (must be land T-point)
+      jpinf   = jpiglo-1,    &  !: i-ending   indice of the North open boundary (must be land T-point)
+      jpindp1 =  jpind+1,    &  !: first ocean point         "                 "
+      jpinfm1 =  jpinf-1        !: last  ocean point         "                 "
+
+   !! * SOUTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_south = .FALSE.    !: to active or not the South open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpjsob  =        2,    &  !: j-localization of the South open boundary (must be ocean V-point)
+      jpisd   =        2,    &  !: i-starting indice of the South open boundary (must be land T-point)
+      jpisf   = jpiglo-1,    &  !: i-ending   indice of the South open boundary (must be land T-point)
+      jpisdp1 =  jpisd+1,    &  !: first ocean point         "                 "
+      jpisfm1 =  jpisf-1        !: last  ocean point         "                 "
+   
+   INTEGER, PARAMETER ::     &  !:
+      jpnic = 2700              !: maximum number of isolated coastlines points 
+
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                         NO open boundary condition
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_obc = .FALSE.  !: Ocean Boundary Condition flag
+#endif
+
+   !!======================================================================
+END MODULE obc_par
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_EEL_R5.h90	(revision 1844)
@@ -0,0 +1,56 @@
+   !!----------------------------------------------------------------------
+   !!                  ***  obc_par_EEL_R5.h90  ***
+   !!----------------------------------------------------------------------
+   !! open boundary parameter : EEL5 configuration
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   INTEGER, PARAMETER ::     &  !: time dimension for the BCS fields on input
+      jptobc  =	      2 
+
+   !! * EAST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_east = .TRUE.      !: to active or not the East open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpieob  = jpiglo-2,    &  !: i-localization of the East open boundary (must be ocean U-point)
+      jpjed   =        2,    &  !: j-starting indice of the East open boundary (must be land T-point)
+      jpjef   = jpjglo-1,    &  !: j-ending   indice of the East open boundary (must be land T-point)
+      jpjedp1 =  jpjed+1,    &  !: first ocean point         "                 "
+      jpjefm1 =  jpjef-1        !: last  ocean point         "                 "
+
+   !! * WEST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_west = .TRUE.      !: to active or not the West open boundary
+   INTEGER, PARAMETER ::     &
+      jpiwob  =	       2,    &  !: i-localization of the West open boundary (must be ocean U-point)
+      jpjwd   =	       2,    &  !: j-starting indice of the West open boundary (must be land T-point)
+      jpjwf   = jpjglo-1,    &  !: j-ending   indice of the West open boundary (must be land T-point)
+      jpjwdp1 =  jpjwd+1,    &  !: first ocean point         "                 "
+      jpjwfm1 =  jpjwf-1        !: last  ocean point         "                 "
+
+   !! * NORTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_north = .FALSE.    !: to active or not the North open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpjnob  = jpjglo-2,    &  !: j-localization of the North open boundary (must be ocean V-point)
+      jpind   =        2,    &  !: i-starting indice of the North open boundary (must be land T-point)
+      jpinf   = jpiglo-1,    &  !: i-ending   indice of the North open boundary (must be land T-point)
+      jpindp1 =  jpind+1,    &  !: first ocean point         "                 "
+      jpinfm1 =  jpinf-1        !: last  ocean point         "                 "
+
+   !! * SOUTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_south = .FALSE.    !: to active or not the South open boundary
+   INTEGER, PARAMETER ::     &  !:
+      jpjsob  =        2,    &  !: j-localization of the South open boundary (must be ocean V-point)
+      jpisd   =        2,    &  !: i-starting indice of the South open boundary (must be land T-point)
+      jpisf   = jpiglo-1,    &  !: i-ending   indice of the South open boundary (must be land T-point)
+      jpisdp1 =  jpisd+1,    &  !: first ocean point         "                 "
+      jpisfm1 =  jpisf-1        !: last  ocean point         "                 "
+   
+   INTEGER, PARAMETER ::     &  !:
+      jpnic = 2700              !: maximum number of isolated coastlines points 
+   !!---------------------------------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_POMME_R025.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_POMME_R025.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_par_POMME_R025.h90	(revision 1844)
@@ -0,0 +1,87 @@
+   !!----------------------------------------------------------------------
+   !!                  ***  obc_par_POMME_R025.h90  ***
+   !!----------------------------------------------------------------------
+   !! open boundary parameter : POMME configuration
+   !!---------------------------------------------------------------------
+     INTEGER, PARAMETER ::     &  !: time dimension of the BCS fields on input
+      jptobc  =	      14
+
+   !! * EAST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_east = .TRUE.      !:
+   INTEGER, PARAMETER ::     &  !:
+
+      ! * default values *
+      !jpieob = jpiglo-2,    &  !: i-localization of the East open boundary (must be ocean U-point)
+      !jpjed  =        2,    &  !: j-starting indice of the East open boundary (must be land T-point)
+      !jpjef  = jpjglo-1,    &  !: j-ending   indice of the East open boundary (must be land T-point)
+
+      jpieob = jpiglo-2,    &  !: i-localization of the East open boundary (must be ocean U-point)
+      jpjed  =        1,    &  !: j-starting indice of the East open boundary (must be land T-point)
+      jpjef  =   jpjglo,    &  !: j-ending   indice of the East open boundary (must be land T-point)
+
+      jpjedp1 =  jpjed+1,    &  !: first ocean point         "                 "
+      jpjefm1 =  jpjef-1        !: last  ocean point         "                 "
+
+   !! * WEST open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_west = .TRUE.     !: to active or not the West open boundary
+   INTEGER, PARAMETER ::     &  !:
+
+      ! * default values *
+      !jpiwob  =        2,   &  !: i-localization of the West open boundary (must be ocean U-point)
+      !jpjwd   =        2,   &  !: j-starting indice of the West open boundary (must be land T-point)
+      !jpjwf   = jpjglo-1,   &  !: j-ending   indice of the West open boundary (must be land T-point)
+
+      jpiwob  =        2,   &  !: i-localization of the West open boundary (must be ocean U-point)
+      jpjwd   =        1,   &  !: j-starting indice of the West open boundary (must be land T-point)
+      jpjwf   =   jpjglo,   &  !: j-ending   indice of the West open boundary (must be land T-point)
+
+      jpjwdp1 =  jpjwd+1,    &  !: first ocean point         "                 "
+      jpjwfm1 =  jpjwf-1        !: last  ocean point         "                 "
+
+   !! * NORTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_north = .TRUE.     !:
+   INTEGER, PARAMETER ::     &  !:
+
+      ! * default values *
+      !jpjnob = jpjglo-2,    &  !: j-localization of the North open boundary (must be ocean V-point)
+      !jpind  =        2,    &  !: i-starting indice of the North open boundary (must be land T-point)
+      !jpinf  = jpiglo-1,    &  !: i-ending   indice of the North open boundary (must be land T-point)
+
+      jpjnob = jpjglo-2,    &  !: j-localization of the North open boundary (must be ocean V-point)
+      jpind  =        1,    &  !: i-starting indice of the North open boundary (must be land T-point)
+      jpinf  =   jpiglo,    &  !: i-ending   indice of the North open boundary (must be land T-point)
+
+      jpindp1 =  jpind+1,    &  !: first ocean point         "                 "
+      jpinfm1 =  jpinf-1        !: last  ocean point         "                 "
+
+   !! * SOUTH open boundary
+   LOGICAL, PARAMETER ::     &  !:
+      lp_obc_south = .TRUE.     !: INDICE to active or not the South open boundary
+   INTEGER, PARAMETER ::     &  !:
+
+      ! * default values *
+      !jpjsob =        2,    &  !: j-localization of the South open boundary (must be ocean V-point)
+      !jpisd  =        2,    &  !: i-starting indice of the South open boundary (must be land T-point)
+      !jpisf  = jpiglo-1,    &  !: i-ending   indice of the South open boundary (must be land T-point)
+
+      jpjsob =        2,    &  !: j-localization of the South open boundary (must be ocean V-point)
+      jpisd  =        1,    &  !: i-starting indice of the South open boundary (must be land T-point)
+      jpisf  =   jpiglo,    &  !: i-ending   indice of the South open boundary (must be land T-point)
+
+      jpisdp1 =  jpisd+1,    &  !: first ocean point         "                 "
+      jpisfm1 =  jpisf-1        !: last  ocean point         "                 "
+   
+   !! * CHOSE WHERE YOU WANT TO LOCATE THE BAROTROPIC CORRECTION VELOCITY
+   !chd IND025
+   LOGICAL, PARAMETER ::     &  !:
+        lp_obc_east_barotp_corr  = .TRUE.,   & !:
+        lp_obc_west_barotp_corr  = .TRUE.,   & !:
+        lp_obc_north_barotp_corr = .TRUE.,   & !:
+        lp_obc_south_barotp_corr = .TRUE.      !:
+
+   INTEGER, PARAMETER ::     &  !:
+      jpnic = 2700              !: maximum number of isolated coastlines points 
+   !!---------------------------------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obc_vectopt_loop_substitute.h90	(revision 1844)
@@ -0,0 +1,30 @@
+   !!----------------------------------------------------------------------
+   !!                 ***  obc_vectopt_loop_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute the inner loop starting and inding indices 
+   !!      to allow unrolling of do-loop using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_vectopt_loop && defined key_obc && ! defined key_mpp_mpi && ! defined key_mpp_shmem
+#  define fs_niw0  jpiwob 
+#  define fs_niw1  jpiwob
+#  define fs_nie0  jpieob 
+#  define fs_nie1  jpieob
+#  define fs_njn0  jpjnob
+#  define fs_njn1  jpjnob
+#  define fs_njs0  jpjsob
+#  define fs_njs1  jpjsob
+#else
+#  define fs_niw0  niw0 
+#  define fs_niw1  niw1
+#  define fs_nie0  nie0 
+#  define fs_nie1  nie1
+#  define fs_njn0  njn0
+#  define fs_njn1  njn1
+#  define fs_njs0  njs0
+#  define fs_njs1  njs1
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdta.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 1844)
@@ -0,0 +1,1289 @@
+MODULE obcdta
+  !!==============================================================================
+  !!                            ***  MODULE obcdta  ***
+  !! Open boundary data : read the data for the open boundaries.
+  !!==============================================================================
+#if defined key_obc
+  !!------------------------------------------------------------------------------
+  !!   'key_obc'         :                                Open Boundary Conditions
+  !!------------------------------------------------------------------------------
+  !!   obc_dta           : read u, v, t, s data along each open boundary
+  !!------------------------------------------------------------------------------
+  !! * Modules used
+  USE oce             ! ocean dynamics and tracers 
+  USE dom_oce         ! ocean space and time domain
+  USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+  USE phycst          ! physical constants
+  USE obc_oce         ! ocean open boundary conditions
+  USE in_out_manager  ! I/O logical units
+  USE lib_mpp         ! distributed memory computing
+  USE dynspg_oce
+  USE ioipsl          ! now only for  ymds2ju function 
+  USE iom             ! 
+
+  IMPLICIT NONE
+  PRIVATE
+
+  !! * Accessibility
+  PUBLIC obc_dta      ! routines called by step.F90
+  PUBLIC obc_dta_bt   ! routines called by dynspg_ts.F90
+
+  !! * Shared module variables
+  REAL(wp),  DIMENSION(2)              ::  zjcnes_obc   ! 
+  REAL(wp),  DIMENSION(:), ALLOCATABLE :: ztcobc
+  REAL(wp) :: rdt_obc
+  REAL(wp) :: zjcnes
+  INTEGER :: imm0, iyy0, idd0, iyy, imm, idd
+  INTEGER :: nt_a=2, nt_b=1, itobc, ndate0_cnes, nday_year0
+  INTEGER ::  itobce, itobcw, itobcs, itobcn, itobc_b  ! number of time steps in OBC files
+
+  INTEGER ::   &
+       ntobc      , &     !:  where we are in the obc file
+       ntobc_b    , &     !:  first record used
+       ntobc_a            !:  second record used
+
+  CHARACTER (len=40) :: &    ! name of data files
+       cl_obc_eTS   , cl_obc_eU,  &
+       cl_obc_wTS   , cl_obc_wU,  &
+       cl_obc_nTS   , cl_obc_nV,  &
+       cl_obc_sTS   , cl_obc_sV
+
+  ! arrays used for interpolating time dependent data on the boundaries
+  REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uedta, vedta, tedta, sedta    ! East
+  REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uwdta, vwdta, twdta, swdta    ! West
+  REAL(wp), DIMENSION(jpi,jpk,jptobc) :: undta, vndta, tndta, sndta    ! North
+  REAL(wp), DIMENSION(jpi,jpk,jptobc) :: usdta, vsdta, tsdta, ssdta    ! South
+
+  LOGICAL, DIMENSION (jpj,jpk ) :: ltemsk=.TRUE., luemsk=.TRUE., lvemsk=.TRUE.  ! boolean msks
+  LOGICAL, DIMENSION (jpj,jpk ) :: ltwmsk=.TRUE., luwmsk=.TRUE., lvwmsk=.TRUE.  ! used for outliers
+  LOGICAL, DIMENSION (jpi,jpk ) :: ltnmsk=.TRUE., lunmsk=.TRUE., lvnmsk=.TRUE.  ! checks
+  LOGICAL, DIMENSION (jpi,jpk ) :: ltsmsk=.TRUE., lusmsk=.TRUE., lvsmsk=.TRUE.
+
+  !! * Substitutions
+#  include "obc_vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+  SUBROUTINE obc_dta( kt )
+    !!---------------------------------------------------------------------------
+    !!                      ***  SUBROUTINE obc_dta  ***
+    !!                    
+    !! ** Purpose :   Find the climatological  boundary arrays for the specified date, 
+    !!                The boundary arrays are netcdf files. Three possible cases: 
+    !!                - one time frame only in the file (time dimension = 1).
+    !!                in that case the boundary data does not change in time.
+    !!                - many time frames. In that case,  if we have 12 frames
+    !!                we assume monthly fields. 
+    !!                Else, we assume that time_counter is in seconds 
+    !!                since the beginning of either the current year or a reference
+    !!                year given in the namelist.
+    !!                (no check is done so far but one would have to check the "unit"
+    !!                 attribute of variable time_counter).
+    !!
+    !!
+    !! History :
+    !!        !  98-05 (J.M. Molines) Original code
+    !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+    !!
+    !!   9.0  !  04-06 (F. Durand, A-M. Treguier) Netcdf BC files on input
+    !!        !  2007-2008 (C. Langlais, P. Mathiot, J.M. Molines) high frequency boundaries data
+    !!---------------------------------------------------------------------------
+    !! * Arguments
+    INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
+
+    !! * Local declarations
+    INTEGER ::   ji, jj, jk, ii, ij ,it  ! dummy loop indices
+    INTEGER ::  ikprint                                ! frequency for printouts.
+    INTEGER, SAVE :: immfile, iyyfile                     !
+    INTEGER :: nt              !  record indices (incrementation)
+    INTEGER :: istop           ! local error check
+
+    REAL(wp) ::   zxy, znum, zden ! time interpolation weight
+
+    ! variables for the julian day calculation
+    INTEGER :: iyear, imonth, iday
+    REAL(wp) :: zsec , zjulian, zjuliancnes   
+
+    ! IOM STUFF
+    INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers
+    INTEGER, DIMENSION(1)  :: itmp
+    CHARACTER(LEN=25) :: cl_vname
+
+    !!---------------------------------------------------------------------------
+
+    ! 0.  initialisation :
+    ! --------------------
+    IF ( kt == nit000  )  CALL obc_dta_ini ( kt )
+    IF ( nobc_dta == 0 )  RETURN   ! already done in obc_dta_ini
+    IF ( itobc == 1    )  RETURN   ! case of only one time frame in file done in obc_dta_ini
+
+    ! in the following code, we assume that obc data are read from files, with more than 1 time frame in it
+
+    iyyfile=iyy ; immfile = 00  ! set component of the current file name
+    IF ( cffile /= 'annual') immfile = imm   ! 
+    IF ( ln_obc_clim       ) iyyfile = 0000  ! assume that climatological files are labeled y0000
+
+    ! 1. Synchronize time of run with time of data files
+    !---------------------------------------------------
+    ! nday_year is the day number in the current year ( 1 for 01/01 )
+    zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day
+    IF (ln_obc_clim)  THEN 
+      zjcnes = nday_year - 1  + zsec/rday
+    ELSE
+      zjcnes = zjcnes + rdt/rday
+    ENDIF
+
+    ! look for 'before' record number in the current file
+    ntobc = nrecbef ()  ! this function return the record number for 'before', relative to zjcnes
+
+    IF (MOD(kt-1,10)==0) THEN
+       IF (lwp) WRITE(numout,*) 'kt= ',kt,' zjcnes =', zjcnes,' ndastp =',ndastp, 'mm =',imm 
+    END IF
+
+    ! 2. read a new data if necessary 
+    !--------------------------------
+    IF ( ntobc /= ntobc_b ) THEN
+    ! we need to read the 'after' record
+    ! swap working index:
+    nt=nt_b ; nt_b=nt_a ; nt_a=nt
+    ntobc_b = ntobc
+
+    ! new record number :
+    ntobc_a = ntobc_a + 1 
+
+    ! all tricky things related to record number, changing files etc... are managed by obc_read
+     
+    CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile )
+
+    ! update zjcnes_obc
+    zjcnes_obc(nt_b)= ztcobc(ntobc_b)
+    zjcnes_obc(nt_a)= ztcobc(ntobc_a)
+    ENDIF
+
+    ! 3.   interpolation at each time step
+    ! ------------------------------------
+    IF ( ln_obc_clim) THEN
+      znum= MOD(zjcnes           - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) ) ; IF ( znum < 0 ) znum = znum + REAL(nyear_len(1),wp)
+      zden= MOD(zjcnes_obc(nt_a) - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) ) ; IF ( zden < 0 ) zden = zden + REAL(nyear_len(1),wp)
+    ELSE
+      znum= zjcnes           - zjcnes_obc(nt_b)
+      zden= zjcnes_obc(nt_a) - zjcnes_obc(nt_b)
+    ENDIF
+    zxy = znum / zden
+
+    IF( lp_obc_east ) THEN
+       !  fills sfoe, tfoe, ufoe ,vfoe
+       sfoe(:,:) = zxy * sedta (:,:,nt_a) + (1. - zxy)*sedta(:,:,nt_b)
+       tfoe(:,:) = zxy * tedta (:,:,nt_a) + (1. - zxy)*tedta(:,:,nt_b)
+       ufoe(:,:) = zxy * uedta (:,:,nt_a) + (1. - zxy)*uedta(:,:,nt_b)
+       vfoe(:,:) = zxy * vedta (:,:,nt_a) + (1. - zxy)*vedta(:,:,nt_b)
+    ENDIF
+
+    IF( lp_obc_west) THEN
+       !  fills sfow, tfow, ufow ,vfow
+       sfow(:,:) = zxy * swdta (:,:,nt_a) + (1. - zxy)*swdta(:,:,nt_b)
+       tfow(:,:) = zxy * twdta (:,:,nt_a) + (1. - zxy)*twdta(:,:,nt_b)
+       ufow(:,:) = zxy * uwdta (:,:,nt_a) + (1. - zxy)*uwdta(:,:,nt_b)
+       vfow(:,:) = zxy * vwdta (:,:,nt_a) + (1. - zxy)*vwdta(:,:,nt_b)
+    ENDIF
+
+    IF( lp_obc_north) THEN
+       !  fills sfon, tfon, ufon ,vfon
+       sfon(:,:) = zxy * sndta (:,:,nt_a) + (1. - zxy)*sndta(:,:,nt_b)
+       tfon(:,:) = zxy * tndta (:,:,nt_a) + (1. - zxy)*tndta(:,:,nt_b)
+       ufon(:,:) = zxy * undta (:,:,nt_a) + (1. - zxy)*undta(:,:,nt_b)
+       vfon(:,:) = zxy * vndta (:,:,nt_a) + (1. - zxy)*vndta(:,:,nt_b)
+    ENDIF
+
+    IF( lp_obc_south) THEN
+       !  fills sfos, tfos, ufos ,vfos
+       sfos(:,:) = zxy * ssdta (:,:,nt_a) + (1. - zxy)*ssdta(:,:,nt_b)
+       tfos(:,:) = zxy * tsdta (:,:,nt_a) + (1. - zxy)*tsdta(:,:,nt_b)
+       ufos(:,:) = zxy * usdta (:,:,nt_a) + (1. - zxy)*usdta(:,:,nt_b)
+       vfos(:,:) = zxy * vsdta (:,:,nt_a) + (1. - zxy)*vsdta(:,:,nt_b)
+    ENDIF
+  END SUBROUTINE obc_dta
+
+
+  SUBROUTINE obc_dta_ini (kt)
+    !!-----------------------------------------------------------------------------
+    !!                       ***  SUBROUTINE obc_dta_ini  ***
+    !!
+    !! ** Purpose :
+    !!      When obc_dta first call, realize some data initialization
+    !!
+    !! ** Method :
+    !!
+    !! History :
+    !!   9.0  ! 07-10 (J.M. Molines )
+    !!----------------------------------------------------------------------------
+    !! * Argument
+    INTEGER, INTENT(in)  :: kt      ! ocean time-step index
+
+    !! * Local declarations
+    INTEGER ::   ji,jj, it   ! dummy loop indices
+
+    REAL(wp) ::   zxy                                    ! time interpolation weight
+
+    INTEGER ::  ikprint                                ! frequency for printouts.
+
+    INTEGER, SAVE :: immfile, iyyfile                     !
+    INTEGER :: nt              !  record indices (incrementation)
+    INTEGER :: istop           ! local error check
+
+    ! variables for the julian day calculation
+    INTEGER :: iyear, imonth, iday
+    REAL(wp) :: zsec , zjulian, zjuliancnes   
+
+    ! IOM STUFF
+    INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers
+    INTEGER, DIMENSION(1)  :: itmp
+    CHARACTER(LEN=25) :: cl_vname
+
+    IF(lwp) WRITE(numout,*)
+    IF(lwp) WRITE(numout,*)  'obc_dta : find boundary data'
+    IF(lwp) WRITE(numout,*)  '~~~~~~~'
+    IF (lwp) THEN
+       IF ( nobc_dta == 0 ) THEN 
+          WRITE(numout,*)  '          OBC data taken from initial conditions.'
+       ELSE      
+          WRITE(numout,*)  '          OBC data taken from netcdf files.'
+       ENDIF
+    ENDIF
+    nday_year0 = nday_year  ! to remember the day when kt=nit000
+
+    sedta(:,:,:) = 0.e0 ; tedta(:,:,:) = 0.e0 ; uedta(:,:,:) = 0.e0 ; vedta(:,:,:) = 0.e0 ! East
+    swdta(:,:,:) = 0.e0 ; twdta(:,:,:) = 0.e0 ; uwdta(:,:,:) = 0.e0 ; vwdta(:,:,:) = 0.e0 ! West
+    sndta(:,:,:) = 0.e0 ; tndta(:,:,:) = 0.e0 ; undta(:,:,:) = 0.e0 ; vndta(:,:,:) = 0.e0 ! North
+    ssdta(:,:,:) = 0.e0 ; tsdta(:,:,:) = 0.e0 ; usdta(:,:,:) = 0.e0 ; vsdta(:,:,:) = 0.e0 ! South
+
+    sfoe(:,:) = 0.e0  ; tfoe(:,:) = 0.e0 ; ufoe(:,:) = 0.e0 ; vfoe(:,:) = 0.e0   ! East
+    sfow(:,:) = 0.e0  ; tfow(:,:) = 0.e0 ; ufow(:,:) = 0.e0 ; vfow(:,:) = 0.e0   ! West
+    sfon(:,:) = 0.e0  ; tfon(:,:) = 0.e0 ; ufon(:,:) = 0.e0 ; vfon(:,:) = 0.e0   ! North
+    sfos(:,:) = 0.e0  ; tfos(:,:) = 0.e0 ; ufos(:,:) = 0.e0 ; vfos(:,:) = 0.e0   ! South
+
+    IF (nobc_dta == 0 ) THEN   ! boundary data are the initial data of this run (set only at nit000)
+       IF (lp_obc_east) THEN  ! East
+          DO ji = nie0 , nie1    
+             sfoe(nje0p1:nje1m1,:) = temsk(nje0p1:nje1m1,:) * sn (ji+1 , nje0p1:nje1m1 , :)
+             tfoe(nje0p1:nje1m1,:) = temsk(nje0p1:nje1m1,:) * tn (ji+1 , nje0p1:nje1m1 , :)
+             ufoe(nje0p1:nje1m1,:) = uemsk(nje0p1:nje1m1,:) * un (ji   , nje0p1:nje1m1 , :)
+             vfoe(nje0p1:nje1m1,:) = vemsk(nje0p1:nje1m1,:) * vn (ji+1 , nje0p1:nje1m1 , :)
+          END DO
+       ENDIF
+
+       IF (lp_obc_west) THEN  ! West
+          DO ji = niw0 , niw1    
+             sfow(njw0p1:njw1m1,:) = twmsk(njw0p1:njw1m1,:) * sn (ji , njw0p1:njw1m1 , :)
+             tfow(njw0p1:njw1m1,:) = twmsk(njw0p1:njw1m1,:) * tn (ji , njw0p1:njw1m1 , :)
+             ufow(njw0p1:njw1m1,:) = uwmsk(njw0p1:njw1m1,:) * un (ji , njw0p1:njw1m1 , :)
+             vfow(njw0p1:njw1m1,:) = vwmsk(njw0p1:njw1m1,:) * vn (ji , njw0p1:njw1m1 , :)
+          END DO
+       ENDIF
+
+       IF (lp_obc_north) THEN ! North
+          DO jj = njn0 , njn1
+             sfon(nin0p1:nin1m1,:) = tnmsk(nin0p1:nin1m1,:) * sn (nin0p1:nin1m1 , jj+1 , :)
+             tfon(nin0p1:nin1m1,:) = tnmsk(nin0p1:nin1m1,:) * tn (nin0p1:nin1m1 , jj+1 , :)
+             ufon(nin0p1:nin1m1,:) = unmsk(nin0p1:nin1m1,:) * un (nin0p1:nin1m1 , jj+1 , :)
+             vfon(nin0p1:nin1m1,:) = vnmsk(nin0p1:nin1m1,:) * vn (nin0p1:nin1m1 , jj   , :)
+          END DO
+       ENDIF
+
+       IF (lp_obc_south) THEN ! South
+          DO jj = njs0 , njs1
+             sfos(nis0p1:nis1m1,:) = tsmsk(nis0p1:nis1m1,:) * sn (nis0p1:nis1m1 , jj , :)
+             tfos(nis0p1:nis1m1,:) = tsmsk(nis0p1:nis1m1,:) * tn (nis0p1:nis1m1 , jj , :)
+             ufos(nis0p1:nis1m1,:) = usmsk(nis0p1:nis1m1,:) * un (nis0p1:nis1m1 , jj , :)
+             vfos(nis0p1:nis1m1,:) = vsmsk(nis0p1:nis1m1,:) * vn (nis0p1:nis1m1 , jj , :)
+          END DO
+       ENDIF
+       RETURN  ! exit the routine all is done
+    ENDIF  ! nobc_dta = 0 
+
+!!!! In the following OBC data are read from files.
+    ! all logical-mask are initialzed to true when declared
+    WHERE ( temsk == 0 ) ltemsk=.FALSE. 
+    WHERE ( uemsk == 0 ) luemsk=.FALSE. 
+    WHERE ( vemsk == 0 ) lvemsk=.FALSE. 
+
+    WHERE ( twmsk == 0 ) ltwmsk=.FALSE. 
+    WHERE ( uwmsk == 0 ) luwmsk=.FALSE. 
+    WHERE ( vwmsk == 0 ) lvwmsk=.FALSE. 
+
+    WHERE ( tnmsk == 0 ) ltnmsk=.FALSE. 
+    WHERE ( unmsk == 0 ) lunmsk=.FALSE. 
+    WHERE ( vnmsk == 0 ) lvnmsk=.FALSE. 
+
+    WHERE ( tsmsk == 0 ) ltsmsk=.FALSE. 
+    WHERE ( usmsk == 0 ) lusmsk=.FALSE. 
+    WHERE ( vsmsk == 0 ) lvsmsk=.FALSE. 
+
+    iyear=1950;  imonth=01; iday=01;  zsec=0. 
+    ! zjuliancnes : julian day corresonding  to  01/01/1950
+    CALL ymds2ju(iyear, imonth, iday,zsec , zjuliancnes)
+
+    !current year and curent month 
+    iyy=INT(ndastp/10000) ; imm=INT((ndastp -iyy*10000)/100) ; idd=(ndastp-iyy*10000-imm*100)
+    IF (iyy <  1900)  iyy = iyy+1900  ! always assume that years are on 4 digits.
+    CALL ymds2ju(iyy, imm, idd ,zsec , zjulian)
+    ndate0_cnes = zjulian - zjuliancnes   ! jcnes day when call to obc_dta_ini
+
+    iyyfile=iyy ; immfile=0  ! set component of the current file name
+    IF ( cffile /= 'annual') immfile=imm
+    IF ( ln_obc_clim) iyyfile = 0  ! assume that climatological files are labeled y0000
+
+    CALL obc_dta_chktime ( iyyfile, immfile )
+
+    IF ( itobc == 1 ) THEN 
+       ! in this case we will provide boundary data only once.
+       nt_a=1 ; ntobc_a=1
+       CALL obc_read (nit000, nt_a, ntobc_a, iyyfile, immfile) 
+       IF( lp_obc_east ) THEN
+          !  fills sfoe, tfoe, ufoe ,vfoe
+          sfoe(:,:) =  sedta (:,:,1) ; tfoe(:,:) =  tedta (:,:,1)
+          ufoe(:,:) =  uedta (:,:,1) ; vfoe(:,:) =  vedta (:,:,1)
+       ENDIF
+
+       IF( lp_obc_west) THEN
+          !  fills sfow, tfow, ufow ,vfow
+          sfow(:,:) =  swdta (:,:,1) ; tfow(:,:) =  twdta (:,:,1)
+          ufow(:,:) =  uwdta (:,:,1) ; vfow(:,:) =  vwdta (:,:,1)
+       ENDIF
+
+       IF( lp_obc_north) THEN
+          !  fills sfon, tfon, ufon ,vfon
+          sfon(:,:) =  sndta (:,:,1) ; tfon(:,:) =  tndta (:,:,1)
+          ufon(:,:) =  undta (:,:,1) ; vfon(:,:) =  vndta (:,:,1)
+       ENDIF
+
+       IF( lp_obc_south) THEN
+          !  fills sfos, tfos, ufos ,vfos
+          sfos(:,:) =  ssdta (:,:,1) ; tfos(:,:) =  tsdta (:,:,1)
+          ufos(:,:) =  usdta (:,:,1) ; vfos(:,:) =  vsdta (:,:,1)
+       ENDIF
+       RETURN  ! we go out of obc_dta_ini -------------------------------------->>>>>
+    ENDIF
+
+    ! nday_year is the day number in the current year ( 1 for 01/01 )
+    ! we suppose that we always start from the begining of a day
+    !    zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day
+    zsec=0.e0  ! here, kt=nit000, nday_year = ndat_year0 
+
+    IF (ln_obc_clim)  THEN 
+      zjcnes = nday_year - 1  + zsec/rday  ! for clim file time is in days in a year
+    ELSE
+      zjcnes = ndate0_cnes + (nday_year - nday_year0 ) + zsec/rday
+    ENDIF
+
+    ! look for 'before' record number in the current file
+    ntobc = nrecbef ()
+
+    IF (lwp) WRITE(numout,*) 'obc files frequency :',cffile
+    IF (lwp) WRITE(numout,*) ' zjcnes0 =',zjcnes,' ndastp0 =',ndastp
+    IF (lwp) WRITE(numout,*) ' annee0 ',iyy,' month0 ', imm,' day0 ', idd
+    IF (lwp) WRITE(numout,*) 'first file open :',cl_obc_nTS
+
+    ! record initialisation
+    !--------------------
+    nt_b = 1 ; nt_a = 2
+
+    ntobc_a = ntobc + 1
+    ntobc_b = ntobc
+
+    CALL obc_read (kt, nt_b, ntobc_b, iyyfile, immfile)  ! read 'before' fields
+    CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile)  ! read 'after' fields
+
+    zjcnes_obc(nt_b)= ztcobc(ntobc_b)
+    zjcnes_obc(nt_a)= ztcobc(ntobc_a)
+    ! 
+  END SUBROUTINE obc_dta_ini
+
+
+  SUBROUTINE obc_dta_chktime (kyyfile, kmmfile)
+   !
+   ! check the number of time steps in the files and read ztcobc 
+   !
+   ! * Arguments
+   INTEGER, INTENT(in) :: kyyfile, kmmfile
+   ! * local variables
+   INTEGER :: istop       ! error control
+   INTEGER :: ji          ! dummy loop index
+
+    INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers
+    INTEGER, DIMENSION(1)  :: itmp
+    CHARACTER(LEN=25) :: cl_vname
+
+    ntobc_a = 0; itobce =0 ; itobcw = 0; itobcn = 0; itobcs = 0
+    ! build file name
+    WRITE(cl_obc_eTS ,'("obc_east_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile
+    WRITE(cl_obc_wTS ,'("obc_west_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile
+    WRITE(cl_obc_nTS ,'("obc_north_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile
+    WRITE(cl_obc_sTS ,'("obc_south_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile
+
+    cl_vname = 'time_counter'
+    IF ( lp_obc_east ) THEN
+       CALL iom_open ( cl_obc_eTS , id_e )
+       idvar = iom_varid( id_e, cl_vname, kdimsz = itmp ); itobce=itmp(1)
+    ENDIF
+    IF ( lp_obc_west ) THEN
+       CALL iom_open ( cl_obc_wTS , id_w )
+       idvar = iom_varid( id_w, cl_vname, kdimsz = itmp ) ; itobcw=itmp(1)
+    ENDIF
+    IF ( lp_obc_north ) THEN
+       CALL iom_open ( cl_obc_nTS , id_n )
+       idvar = iom_varid( id_n, cl_vname, kdimsz = itmp ) ; itobcn=itmp(1)
+    ENDIF
+    IF ( lp_obc_south ) THEN
+       CALL iom_open ( cl_obc_sTS , id_s )
+       idvar = iom_varid( id_s, cl_vname, kdimsz = itmp ) ; itobcs=itmp(1)
+    ENDIF
+
+    itobc = MAX( itobce, itobcw, itobcn, itobcs )
+    istop = 0
+    IF ( lp_obc_east  .AND. itobce /= itobc ) istop = istop+1 
+    IF ( lp_obc_west  .AND. itobcw /= itobc ) istop = istop+1      
+    IF ( lp_obc_north .AND. itobcn /= itobc ) istop = istop+1
+    IF ( lp_obc_south .AND. itobcs /= itobc ) istop = istop+1 
+    nstop = nstop + istop
+
+    IF ( istop /=  0 )  THEN
+       WRITE(ctmp1,*) ' east, west, north, south: ', itobce, itobcw, itobcn, itobcs
+       CALL ctl_stop( 'obcdta : all files must have the same number of time steps', ctmp1 )
+    ENDIF
+
+    IF ( itobc == 1 ) THEN 
+       IF (lwp) THEN
+          WRITE(numout,*) ' obcdta found one time step only in the OBC files'
+          IF (ln_obc_clim) THEN
+             ! OK no problem
+          ELSE
+             ln_obc_clim=.true.
+             WRITE(numout,*) ' we force ln_obc_clim to T'
+          ENDIF
+       ENDIF
+    ELSE
+       IF ( ALLOCATED(ztcobc) ) DEALLOCATE ( ztcobc )
+       ALLOCATE (ztcobc(itobc))
+       DO ji=1,1   ! use a dummy loop to read ztcobc only once
+          IF ( lp_obc_east ) THEN
+             CALL iom_gettime ( id_e, ztcobc, cl_vname ) ; CALL iom_close (id_e) ; EXIT
+          ENDIF
+          IF ( lp_obc_west ) THEN
+             CALL iom_gettime ( id_w, ztcobc, cl_vname ) ; CALL iom_close (id_w) ; EXIT
+          ENDIF
+          IF ( lp_obc_north ) THEN
+             CALL iom_gettime ( id_n, ztcobc, cl_vname ) ; CALL iom_close (id_n) ; EXIT
+          ENDIF
+          IF ( lp_obc_south ) THEN
+             CALL iom_gettime ( id_s, ztcobc, cl_vname ) ; CALL iom_close (id_s) ; EXIT
+          ENDIF
+       END DO
+       rdt_obc = ztcobc(2)-ztcobc(1)  !  just an information, not used for any computation
+       IF (lwp) WRITE(numout,*) ' obcdta found', itobc,' time steps in the OBC files'
+       IF (lwp) WRITE(numout,*) ' time step of obc data :', rdt_obc,' days'            
+     ENDIF
+     zjcnes = zjcnes - rdt/rday  ! trick : zcnes is always incremented by rdt/rday in obc_dta!
+  END SUBROUTINE obc_dta_chktime
+
+
+#if defined key_dynspg_ts || defined key_dynspg_exp
+  SUBROUTINE obc_dta_bt( kt, kbt )
+    !!---------------------------------------------------------------------------
+    !!                      ***  SUBROUTINE obc_dta  ***
+    !!
+    !! ** Purpose :   time interpolation of barotropic data for time-splitting scheme
+    !!                Data at the boundary must be in m2/s 
+    !!
+    !! History :
+    !!   9.0  !  05-11 (V. garnier) Original code
+    !!---------------------------------------------------------------------------
+    !! * Arguments
+    INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
+    INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index
+
+    !! * Local declarations
+    INTEGER ::   ji, jj, jk, ii, ij   ! dummy loop indices
+    INTEGER ::   id_e, id_w, id_n, id_s, fid  ! file identifiers
+    INTEGER ::   itimo, iman, imois, i15
+    INTEGER ::   itobcm, itobcp, itimom, itimop
+    REAL(wp) ::  zxy
+    INTEGER ::   isrel, ikt           ! number of seconds since 1/1/1992
+    INTEGER ::   iprint              ! frequency for printouts.
+
+    !!---------------------------------------------------------------------------
+
+    ! 1.   First call: check time frames available in files.
+    ! -------------------------------------------------------
+
+    IF( kt == nit000 ) THEN
+
+       ! 1.1  Barotropic tangential velocities set to zero
+       ! -------------------------------------------------
+       IF( lp_obc_east  ) vbtfoe(:) = 0.e0
+       IF( lp_obc_west  ) vbtfow(:) = 0.e0
+       IF( lp_obc_south ) ubtfos(:) = 0.e0
+       IF( lp_obc_north ) ubtfon(:) = 0.e0
+
+       ! 1.2  Sea surface height and normal barotropic velocities set to zero
+       !                               or initial conditions if nobc_dta == 0
+       ! --------------------------------------------------------------------
+
+       IF( lp_obc_east ) THEN
+          ! initialisation to zero
+          sshedta(:,:) = 0.e0
+          ubtedta(:,:) = 0.e0
+          !                                        ! ================== !
+          IF( nobc_dta == 0 )   THEN               ! initial state used !
+             !                                     ! ================== !
+             !  Fills sedta, tedta, uedta (global arrays)
+             !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom?
+             DO ji = nie0, nie1
+                DO jj = nje0p1, nje1m1
+                   ij = jj -1 + njmpp
+                   sshedta(ij,1) = sshn(ji+1,jj) * tmask(ji+1,jj,1)
+                END DO
+             END DO
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_west) THEN
+          ! initialisation to zero
+          sshwdta(:,:) = 0.e0
+          ubtwdta(:,:) = 0.e0
+          !                                        ! ================== !
+          IF( nobc_dta == 0 )   THEN               ! initial state used !
+             !                                     ! ================== !
+             !  Fills swdta, twdta, uwdta (global arrays)
+             !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom?
+             DO ji = niw0, niw1
+                DO jj = njw0p1, njw1m1
+                   ij = jj -1 + njmpp
+                   sshwdta(ij,1) = sshn(ji,jj) * tmask(ji,jj,1)
+                END DO
+             END DO
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_north) THEN
+          ! initialisation to zero
+          sshndta(:,:) = 0.e0
+          vbtndta(:,:) = 0.e0
+          !                                        ! ================== !
+          IF( nobc_dta == 0 )   THEN               ! initial state used !
+             !                                     ! ================== !
+             !  Fills sndta, tndta, vndta (global arrays)
+             !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom?
+             DO jj = njn0, njn1
+                DO ji = nin0p1, nin1m1
+                   DO jk = 1, jpkm1
+                      ii = ji -1 + nimpp
+                      vbtndta(ii,1) = vbtndta(ii,1) + vndta(ii,jk,1)*fse3v(ji,jj,jk)
+                   END DO
+                   sshndta(ii,1) = sshn(ii,jj+1) * tmask(ji,jj+1,1)
+                END DO
+             END DO
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_south) THEN
+          ! initialisation to zero
+          ssdta(:,:,:) = 0.e0
+          tsdta(:,:,:) = 0.e0
+          vsdta(:,:,:) = 0.e0
+          sshsdta(:,:) = 0.e0
+          vbtsdta(:,:) = 0.e0
+          !                                        ! ================== !
+          IF( nobc_dta == 0 )   THEN               ! initial state used !
+             !                                     ! ================== !
+             !  Fills ssdta, tsdta, vsdta (global arrays)
+             !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom?
+             DO jj = njs0, njs1
+                DO ji = nis0p1, nis1m1
+                   DO jk = 1, jpkm1
+                      ii = ji -1 + nimpp
+                      vbtsdta(ii,1) = vbtsdta(ii,1) + vsdta(ii,jk,1)*fse3v(ji,jj,jk)
+                   END DO
+                   sshsdta(ii,1) = sshn(ji,jj) * tmask(ii,jj,1)
+                END DO
+             END DO
+          ENDIF
+       ENDIF
+
+    ENDIF        !       END IF kt == nit000
+
+    !!------------------------------------------------------------------------------------
+    ! 2.      Initialize the time we are at. Does this every time the routine is called,
+    !         excepted when nobc_dta = 0
+    !
+    IF( nobc_dta == 0) THEN
+       itimo = 1
+       zxy   = 0
+    ELSE
+       IF(ntobc == 1) THEN
+          itimo = 1
+       ELSE IF (ntobc == 12) THEN      !   BC are monthly
+          ! we assume we have climatology in that case
+          iman  = 12
+          i15   = nday / 16
+          imois = nmonth + i15 - 1
+          IF( imois == 0 )   imois = iman
+          itimo = imois
+       ELSE
+          IF(lwp) WRITE(numout,*) 'data other than constant or monthly',kt
+          iman  = ntobc
+          itimo = FLOOR( kt*rdt / tcobc(1))
+          isrel=kt*rdt
+       ENDIF
+    ENDIF
+
+    ! 2. Read two records in the file if necessary
+    ! ---------------------------------------------
+
+    IF( nobc_dta == 1 .AND. nlecto == 1 ) THEN
+
+       IF( lp_obc_east ) THEN
+          ! ... Read datafile and set sea surface height and barotropic velocity
+          ! ... initialise the sshedta, ubtedta arrays
+          sshedta(:,0) = sshedta(:,1)
+          ubtedta(:,0) = ubtedta(:,1)
+          CALL iom_open ( 'obceast_TS.nc', id_e )
+          CALL iom_get ( id_e, jpdom_unknown, 'vossurfh', sshedta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_e, jpdom_unknown, 'vossurfh', sshedta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get (id_e, jpdom_unknown, 'vossurfh', sshedta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_e )
+          !
+          CALL iom_open ( 'obceast_U.nc', id_e )
+          CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_e )
+          ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1
+          IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read East OBC barotropic data records ', ntobc1, ntobc2
+             iprint = (jpjef-jpjed+1)/20 +1
+             WRITE(numout,*)
+             WRITE(numout,*) ' Sea surface height record 1'
+             CALL prihre( sshedta(:,1), jpjef-jpjed+1, 1, 1, jpjef-jpjed+1, iprint, 1, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal transport (m2/s) record 1',iprint
+             CALL prihre( ubtedta(:,1), jpjef-jpjed+1, 1, 1, jpjef-jpjed+1, iprint, 1, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_west ) THEN
+          ! ... Read datafile and set temperature, salinity and normal velocity
+          ! ... initialise the swdta, twdta, uwdta arrays
+          sshwdta(:,0) = sshwdta(:,1)
+          ubtwdta(:,0) = ubtwdta(:,1)
+          CALL iom_open ( 'obcwest_TS.nc', id_w )
+          CALL iom_get ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL  ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_w )
+          !
+          CALL iom_open ( 'obcwest_U.nc', id_w )
+          CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_w )
+          ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1
+          IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read West OBC barotropic data records ', ntobc1, ntobc2
+             iprint = (jpjwf-jpjwd+1)/20 +1
+             WRITE(numout,*)
+             WRITE(numout,*) ' Sea surface height record 1  - printout surface level'
+             CALL prihre( sshwdta(:,1), jpjwf-jpjwd+1, 1, 1, jpjwf-jpjwd+1, iprint, 1, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal transport (m2/s) record 1'
+             CALL prihre( ubtwdta(:,1), jpjwf-jpjwd+1, 1, 1, jpjwf-jpjwd+1, iprint, 1, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_north) THEN
+          ! ... Read datafile and set sea surface height and barotropic velocity
+          ! ... initialise the sshndta, ubtndta arrays
+          sshndta(:,0) = sshndta(:,1)
+          vbtndta(:,0) = vbtndta(:,1)
+          CALL iom_open ( 'obcnorth_TS.nc', id_n )
+          CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,1), ktime=ntobc1 )
+          CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_n )
+
+          CALL iom_open ( 'obcnorth_V.nc', id_n )
+          CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,1), ktime=ntobc1 )
+          CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_n )
+
+          ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1
+          IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read North OBC barotropic data records ', ntobc1, ntobc2
+             iprint = (jpinf-jpind+1)/20 +1
+             WRITE(numout,*)
+             WRITE(numout,*) ' Sea surface height record 1  - printout surface level'
+             CALL prihre( sshndta(:,1), jpinf-jpind+1, 1, 1, jpinf-jpind+1, iprint, 1, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal transport (m2/s) record 1'
+             CALL prihre( vbtndta(:,1), jpinf-jpind+1, 1, 1, jpinf-jpind+1, iprint, 1, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+
+       IF( lp_obc_south) THEN
+          ! ... Read datafile and set sea surface height and barotropic velocity
+          ! ... initialise the sshsdta, ubtsdta arrays
+          sshsdta(:,0) = sshsdta(:,1)
+          vbtsdta(:,0) = vbtsdta(:,1)
+          CALL iom_open ( 'obcsouth_TS.nc', id_s )
+          CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_s )
+
+          CALL iom_open ( 'obcsouth_V.nc', id_s )
+          CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,1), ktime=ntobc1 )
+          CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,2), ktime=ntobc2 )
+          IF( lk_dynspg_ts ) THEN
+             CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,3), ktime=ntobc2+1 )
+          ENDIF
+          CALL iom_close ( id_s )
+
+          ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1
+          IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read South OBC barotropic data records ', ntobc1, ntobc2
+             iprint = (jpisf-jpisd+1)/20 +1
+             WRITE(numout,*)
+             WRITE(numout,*) ' Sea surface height record 1  - printout surface level'
+             CALL prihre( sshsdta(:,1), jpisf-jpisd+1, 1, 1, jpisf-jpisd+1, iprint, 1, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal transport (m2/s) record 1'
+             CALL prihre( vbtsdta(:,1), jpisf-jpisd+1, 1, 1, jpisf-jpisd+1, iprint, 1, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+
+    ENDIF        !      end of the test on the condition to read or not the files
+
+    ! 3.  Call at every time step : Linear interpolation of BCs to current time step
+    ! ----------------------------------------------------------------------
+
+    IF( lk_dynspg_ts ) THEN
+       isrel = (kt-1)*rdt + kbt*(rdt/REAL(nn_baro,wp))
+
+       IF( nobc_dta == 1 ) THEN
+          isrel = (kt-1)*rdt + kbt*(rdt/REAL(nn_baro,wp))
+          itimo  = FLOOR(  kt*rdt    / (tcobc(2)-tcobc(1)) )
+          itimom = FLOOR( (kt-1)*rdt / (tcobc(2)-tcobc(1)) )
+          itimop = FLOOR( (kt+1)*rdt / (tcobc(2)-tcobc(1)) )
+          IF( itimom == itimo .AND. itimop == itimo ) THEN
+             itobcm = ntobc1
+             itobcp = ntobc2
+
+          ELSEIF ( itimom <= itimo .AND. itimop == itimo ) THEN
+             IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimo ) THEN
+                itobcm = ntobc1-1
+                itobcp = ntobc2-1
+             ELSE
+                itobcm = ntobc1
+                itobcp = ntobc2
+             ENDIF
+
+          ELSEIF ( itimom == itimo .AND. itimop >= itimo ) THEN
+             IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimop ) THEN
+                itobcm = ntobc1
+                itobcp = ntobc2
+             ELSE
+                itobcm = ntobc1+1
+                itobcp = ntobc2+1
+             ENDIF
+
+          ELSEIF ( itimom == itimo-1 .AND. itimop == itimo+1 ) THEN
+             IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimo ) THEN
+                itobcm = ntobc1-1
+                itobcp = ntobc2-1
+             ELSEIF (  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimop ) THEN
+                itobcm = ntobc1
+                itobcp = ntobc2
+             ELSEIF (  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) == itimop ) THEN
+                itobcm = ntobc1+1
+                itobcp = ntobc2+2
+             ELSE
+                IF(lwp) WRITE(numout, *) 'obc_dta_bt: You should not have seen this print! error 1?'
+             ENDIF
+          ELSE
+             IF(lwp) WRITE(numout, *) 'obc_dta_bt: You should not have seen this print! error 2?'
+          ENDIF
+
+       ENDIF
+
+    ELSE IF( lk_dynspg_exp ) THEN
+       isrel=kt*rdt
+       itobcm = ntobc1
+       itobcp = ntobc2
+    ENDIF
+
+    IF( ntobc == 1 .OR. nobc_dta == 0 ) THEN
+       zxy = 0.e0
+    ELSE IF( ntobc == 12 ) THEN
+       zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+    ELSE
+       zxy = (tcobc(itobcm)-FLOAT(isrel)) / (tcobc(itobcm)-tcobc(itobcp))
+    ENDIF
+
+    IF( lp_obc_east ) THEN           !  fills sshfoe, ubtfoe (local to each processor)
+       DO jj = nje0p1, nje1m1
+          ij = jj -1 + njmpp
+          sshfoe(jj) = ( zxy * sshedta(ij,2) + (1.-zxy) * sshedta(ij,1) ) * temsk(jj,1)
+          ubtfoe(jj) = ( zxy * ubtedta(ij,2) + (1.-zxy) * ubtedta(ij,1) ) * uemsk(jj,1)
+       END DO
+    ENDIF
+
+    IF( lp_obc_west) THEN            !  fills sshfow, ubtfow (local to each processor)
+       DO jj = njw0p1, njw1m1
+          ij = jj -1 + njmpp
+          sshfow(jj) = ( zxy * sshwdta(ij,2) + (1.-zxy) * sshwdta(ij,1) ) * twmsk(jj,1)
+          ubtfow(jj) = ( zxy * ubtwdta(ij,2) + (1.-zxy) * ubtwdta(ij,1) ) * uwmsk(jj,1)
+       END DO
+    ENDIF
+
+    IF( lp_obc_north) THEN           !  fills sshfon, vbtfon (local to each processor)
+       DO ji = nin0p1, nin1m1
+          ii = ji -1 + nimpp
+          sshfon(ji) = ( zxy * sshndta(ii,2) + (1.-zxy) * sshndta(ii,1) ) * tnmsk(ji,1)
+          vbtfon(ji) = ( zxy * vbtndta(ii,2) + (1.-zxy) * vbtndta(ii,1) ) * vnmsk(ji,1)
+       END DO
+    ENDIF
+
+    IF( lp_obc_south) THEN           !  fills sshfos, vbtfos (local to each processor)
+       DO ji = nis0p1, nis1m1
+          ii = ji -1 + nimpp
+          sshfos(ji) = ( zxy * sshsdta(ii,2) + (1.-zxy) * sshsdta(ii,1) ) * tsmsk(ji,1)
+          vbtfos(ji) = ( zxy * vbtsdta(ii,2) + (1.-zxy) * vbtsdta(ii,1) ) * vsmsk(ji,1)
+       END DO
+    ENDIF
+
+  END SUBROUTINE obc_dta_bt
+
+#else
+  !!-----------------------------------------------------------------------------
+  !!   Default option
+  !!-----------------------------------------------------------------------------
+  SUBROUTINE obc_dta_bt ( kt, kbt )       ! Empty routine
+    !! * Arguments
+    INTEGER,INTENT(in) :: kt
+    INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index
+    WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kt
+    WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kbt
+  END SUBROUTINE obc_dta_bt
+#endif
+
+
+  !!==============================================================================
+  SUBROUTINE obc_read (kt, nt_x, ntobc_x, iyy, imm)
+     !!-------------------------------------------------------------------------
+     !!                      ***  ROUTINE obc_read  ***
+     !!
+     !! ** Purpose :  Read the boundary data in files identified by iyy and imm
+     !!               According to the validated open boundaries, return the 
+     !!               following arrays :
+     !!                sedta, tedta : East OBC salinity and temperature
+     !!                uedta, vedta :   "   "  u and v velocity component      
+     !!
+     !!                swdta, twdta : West OBC salinity and temperature
+     !!                uwdta, vwdta :   "   "  u and v velocity component      
+     !!
+     !!                sndta, tndta : North OBC salinity and temperature
+     !!                undta, vndta :   "   "  u and v velocity component      
+     !!
+     !!                ssdta, tsdta : South OBC salinity and temperature
+     !!                usdta, vsdta :   "   "  u and v velocity component      
+     !!
+     !! ** Method  :  These fields are read in the record ntobc_x of the files.
+     !!               The number of records is already known. If  ntobc_x is greater
+     !!               than the number of record, this routine will look for next file,
+     !!               updating the indices (case of inter-annual obcs) or loop at the
+     !!               begining in case of climatological file (ln_obc_clim = true ).
+     !! -------------------------------------------------------------------------
+     !! History:     !  2005  ( P. Mathiot, C. Langlais ) Original code
+     !!              !  2008  ( J,M, Molines ) Use IOM and cleaning
+     !!--------------------------------------------------------------------------
+
+    ! * Arguments
+    INTEGER, INTENT( in ) :: kt, nt_x
+    INTEGER, INTENT( inout ) :: ntobc_x , iyy, imm      ! yes ! inout !
+
+    ! * Local variables
+    CHARACTER (len=40) :: &    ! file names
+         cl_obc_eTS   , cl_obc_eU,  cl_obc_eV,&
+         cl_obc_wTS   , cl_obc_wU,  cl_obc_wV,&
+         cl_obc_nTS   , cl_obc_nU,  cl_obc_nV,&
+         cl_obc_sTS   , cl_obc_sU,  cl_obc_sV
+
+    INTEGER :: ikprint
+    REAL(wp) :: zmin, zmax   ! control of boundary values
+
+    !IOM stuff
+    INTEGER :: id_e, id_w, id_n, id_s, ji, jj
+    INTEGER, DIMENSION(2) :: istart, icount
+   
+    !--------------------------------------------------------------------------
+    IF ( ntobc_x > itobc ) THEN
+      IF (ln_obc_clim) THEN  ! just loop on the same file
+        ntobc_x = 1 
+      ELSE
+        ! need to change file : it is always for an 'after' data
+        IF ( cffile == 'annual' ) THEN ! go to next year file
+          iyy = iyy + 1
+        ELSE IF ( cffile =='monthly' ) THEN  ! go to next month file
+          imm = imm + 1 
+          IF ( imm == 13 ) THEN 
+            imm = 1 ; iyy = iyy + 1
+          ENDIF
+        ELSE
+         ctmp1='obcread : this type of obc file is not supported :( '
+         ctmp2=TRIM(cffile)
+         CALL ctl_stop (ctmp1, ctmp2)
+         ! cffile should be either annual or monthly ...
+        ENDIF
+       ! as the file is changed, need to update itobc etc ...
+        CALL obc_dta_chktime (iyy,imm)
+        ntobc_x = nrecbef() + 1 ! remember : this case occur for an after data
+      ENDIF
+    ENDIF
+
+    IF ( lp_obc_east ) THEN 
+       ! ... Read datafile and set temperature, salinity and normal velocity
+       ! ... initialise the sedta, tedta, uedta arrays
+       WRITE(cl_obc_eTS ,'("obc_east_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_eU  ,'("obc_east_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_eV  ,'("obc_east_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       ! JMM this may change depending on the obc data format ...
+       istart(:)=(/nje0+njmpp-1,1/) ; icount(:)=(/nje1-nje0 +1,jpk/)
+       IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_eTS)
+       IF (nje1 >= nje0 ) THEN
+          CALL iom_open ( cl_obc_eTS , id_e )
+          CALL iom_get ( id_e, jpdom_unknown, 'votemper', tedta(nje0:nje1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_get ( id_e, jpdom_unknown, 'vosaline', sedta(nje0:nje1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close (id_e)
+          !
+          CALL iom_open ( cl_obc_eU , id_e )
+          CALL iom_get  ( id_e, jpdom_unknown, 'vozocrtx', uedta(nje0:nje1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_e )
+          !
+          CALL iom_open ( cl_obc_eV , id_e )
+          CALL iom_get ( id_e, jpdom_unknown, 'vomecrty', vedta(nje0:nje1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_e )
+
+          ! mask the boundary values
+          tedta(:,:,nt_x) = tedta(:,:,nt_x)*temsk(:,:) ;  sedta(:,:,nt_x) = sedta(:,:,nt_x)*temsk(:,:)
+          uedta(:,:,nt_x) = uedta(:,:,nt_x)*uemsk(:,:) ;  vedta(:,:,nt_x) = vedta(:,:,nt_x)*vemsk(:,:)
+
+          ! check any outliers 
+          zmin=MINVAL( sedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(sedta(:,:,nt_x), mask=ltemsk)
+          IF (  zmin < 5 .OR. zmax > 50)   THEN
+             CALL ctl_stop('Error in sedta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( tedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(tedta(:,:,nt_x), mask=ltemsk)
+          IF (  zmin < -10. .OR. zmax > 40)   THEN
+             CALL ctl_stop('Error in tedta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( uedta(:,:,nt_x), mask=luemsk ) ; zmax=MAXVAL(uedta(:,:,nt_x), mask=luemsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in uedta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( vedta(:,:,nt_x), mask=lvemsk ) ; zmax=MAXVAL(vedta(:,:,nt_x), mask=lvemsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in vedta',' routine obcdta')
+          ENDIF
+
+          !               Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1      
+          IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read East OBC data records ', ntobc_x
+             ikprint = jpj/20 +1
+             WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+             CALL prihre( tedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+             CALL prihre( sedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level'
+             CALL prihre( uedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level'
+             CALL prihre( vedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+    ENDIF
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    IF ( lp_obc_west ) THEN
+       ! ... Read datafile and set temperature, salinity and normal velocity
+       ! ... initialise the swdta, twdta, uwdta arrays
+       WRITE(cl_obc_wTS ,'("obc_west_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_wU  ,'("obc_west_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_wV  ,'("obc_west_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       istart(:)=(/njw0+njmpp-1,1/) ; icount(:)=(/njw1-njw0 +1,jpk/)
+       IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_wTS)
+
+       IF ( njw1 >= njw0 ) THEN
+          CALL iom_open ( cl_obc_wTS , id_w )
+          CALL iom_get ( id_w, jpdom_unknown, 'votemper', twdta(njw0:njw1,:,nt_x), & 
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+
+          CALL iom_get ( id_w, jpdom_unknown, 'vosaline', swdta(njw0:njw1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount)
+          CALL iom_close (id_w)
+          !
+          CALL iom_open ( cl_obc_wU , id_w )
+          CALL iom_get  ( id_w, jpdom_unknown, 'vozocrtx', uwdta(njw0:njw1,:,nt_x),&
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_w )
+          !
+          CALL iom_open ( cl_obc_wV , id_w )
+          CALL iom_get ( id_w, jpdom_unknown, 'vomecrty', vwdta(njw0:njw1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_w )
+
+          ! mask the boundary values
+          twdta(:,:,nt_x) = twdta(:,:,nt_x)*twmsk(:,:) ;  swdta(:,:,nt_x) = swdta(:,:,nt_x)*twmsk(:,:)
+          uwdta(:,:,nt_x) = uwdta(:,:,nt_x)*uwmsk(:,:) ;  vwdta(:,:,nt_x) = vwdta(:,:,nt_x)*vwmsk(:,:)
+
+          ! check any outliers
+          zmin=MINVAL( swdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(swdta(:,:,nt_x), mask=ltwmsk)
+          IF (  zmin < 5 .OR. zmax > 50)   THEN
+             CALL ctl_stop('Error in swdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( twdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(twdta(:,:,nt_x), mask=ltwmsk)
+          IF (  zmin < -10. .OR. zmax > 40)   THEN
+             CALL ctl_stop('Error in twdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( uwdta(:,:,nt_x), mask=luwmsk ) ; zmax=MAXVAL(uwdta(:,:,nt_x), mask=luwmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in uwdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( vwdta(:,:,nt_x), mask=lvwmsk ) ; zmax=MAXVAL(vwdta(:,:,nt_x), mask=lvwmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in vwdta',' routine obcdta')
+          ENDIF
+
+
+          IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read West OBC data records ', ntobc_x
+             ikprint = jpj/20 +1
+             WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+             CALL prihre( twdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+             CALL prihre( swdta(:,:,nt_x),jpj,jpk, 1, jpj, ikprint,   jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level'
+             CALL prihre( uwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level'
+             CALL prihre( vwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout )
+          ENDIF
+       END IF
+    ENDIF
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    IF( lp_obc_north) THEN
+       WRITE(cl_obc_nTS ,'("obc_north_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_nV  ,'("obc_north_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_nU  ,'("obc_north_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       istart(:)=(/nin0+nimpp-1,1/) ; icount(:)=(/nin1-nin0 +1,jpk/)
+       IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_nTS)
+       IF ( nin1 >= nin0 ) THEN
+          CALL iom_open ( cl_obc_nTS , id_n )
+          CALL iom_get ( id_n, jpdom_unknown, 'votemper', tndta(nin0:nin1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_get ( id_n, jpdom_unknown, 'vosaline', sndta(nin0:nin1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close (id_n)
+          !
+          CALL iom_open ( cl_obc_nU , id_n )
+          CALL iom_get  ( id_n, jpdom_unknown, 'vozocrtx', undta(nin0:nin1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_n )
+          !
+          CALL iom_open ( cl_obc_nV , id_n )
+          CALL iom_get  ( id_n, jpdom_unknown, 'vomecrty', vndta(nin0:nin1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_n )
+
+          ! mask the boundary values
+          tndta(:,:,nt_x) = tndta(:,:,nt_x)*tnmsk(:,:) ;  sndta(:,:,nt_x) = sndta(:,:,nt_x)*tnmsk(:,:)
+          undta(:,:,nt_x) = undta(:,:,nt_x)*unmsk(:,:) ;  vndta(:,:,nt_x) = vndta(:,:,nt_x)*vnmsk(:,:)
+
+          ! check any outliers
+          zmin=MINVAL( sndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(sndta(:,:,nt_x), mask=ltnmsk)
+          IF (  zmin < 5 .OR. zmax > 50)   THEN
+             CALL ctl_stop('Error in sndta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( tndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(tndta(:,:,nt_x), mask=ltnmsk)
+          IF (  zmin < -10. .OR. zmax > 40)   THEN
+             CALL ctl_stop('Error in tndta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( undta(:,:,nt_x), mask=lunmsk ) ; zmax=MAXVAL(undta(:,:,nt_x), mask=lunmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in undta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( vndta(:,:,nt_x), mask=lvnmsk ) ; zmax=MAXVAL(vndta(:,:,nt_x), mask=lvnmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in vndta',' routine obcdta')
+          ENDIF
+
+          IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read North OBC data records ', ntobc_x
+             ikprint = jpi/20 +1
+             WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+             CALL prihre( tndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+             CALL prihre( sndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level'
+             CALL prihre( vndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Tangential  velocity U  record 1  - printout every 3 level'
+             CALL prihre( undta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+    ENDIF
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    IF( lp_obc_south) THEN 
+       WRITE(cl_obc_sTS ,'("obc_south_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_sV  ,'("obc_south_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       WRITE(cl_obc_sU  ,'("obc_south_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm
+       istart(:)=(/nis0+nimpp-1,1/) ; icount(:)=(/nis1-nis0 +1,jpk/)
+       IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_sTS)
+       IF ( nis1 >= nis0 ) THEN 
+          CALL iom_open ( cl_obc_sTS , id_s )
+          CALL iom_get ( id_s, jpdom_unknown, 'votemper', tsdta(nis0:nis1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_get ( id_s, jpdom_unknown, 'vosaline', ssdta(nis0:nis1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close (id_s)
+          !
+          CALL iom_open ( cl_obc_sU , id_s )
+          CALL iom_get  ( id_s, jpdom_unknown, 'vozocrtx', usdta(nis0:nis1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_s )
+          !
+          CALL iom_open ( cl_obc_sV , id_s )
+          CALL iom_get  ( id_s, jpdom_unknown, 'vomecrty', vsdta(nis0:nis1,:,nt_x), &
+               &               ktime=ntobc_x , kstart=istart, kcount= icount )
+          CALL iom_close ( id_s )
+
+          ! mask the boundary values
+          tsdta(:,:,nt_x) = tsdta(:,:,nt_x)*tsmsk(:,:) ;  ssdta(:,:,nt_x) = ssdta(:,:,nt_x)*tsmsk(:,:)
+          usdta(:,:,nt_x) = usdta(:,:,nt_x)*usmsk(:,:) ;  vsdta(:,:,nt_x) = vsdta(:,:,nt_x)*vsmsk(:,:)
+
+          ! check any outliers
+          zmin=MINVAL( ssdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(ssdta(:,:,nt_x), mask=ltsmsk)
+          IF (  zmin < 5 .OR. zmax > 50)   THEN
+             CALL ctl_stop('Error in ssdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( tsdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(tsdta(:,:,nt_x), mask=ltsmsk)
+          IF (  zmin < -10. .OR. zmax > 40)   THEN
+             CALL ctl_stop('Error in tsdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( usdta(:,:,nt_x), mask=lusmsk ) ; zmax=MAXVAL(usdta(:,:,nt_x), mask=lusmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in usdta',' routine obcdta')
+          ENDIF
+          zmin=MINVAL( vsdta(:,:,nt_x), mask=lvsmsk ) ; zmax=MAXVAL(vsdta(:,:,nt_x), mask=lvsmsk)
+          IF (  zmin < -5. .OR. zmax > 5.)   THEN
+             CALL ctl_stop('Error in vsdta',' routine obcdta')
+          ENDIF
+
+          IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN
+             WRITE(numout,*)
+             WRITE(numout,*) ' Read South OBC data records ', ntobc_x
+             ikprint = jpi/20 +1
+             WRITE(numout,*) ' Temperature  record 1 - printout every 3 level'
+             CALL prihre( tsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Salinity  record 1 - printout every 3 level'
+             CALL prihre( ssdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level'
+             CALL prihre( vsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+             WRITE(numout,*)
+             WRITE(numout,*) ' Tangential velocity U  record 1  - printout every 3 level'
+             CALL prihre( usdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout )
+          ENDIF
+       ENDIF
+    ENDIF
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  END SUBROUTINE obc_read 
+
+  INTEGER FUNCTION nrecbef()
+      !!-----------------------------------------------------------------------
+      !!                     ***    FUNCTION nrecbef   ***
+      !!
+      !!  Purpose : - provide the before record number in files, with respect to zjcnes
+      !!
+      !!    History : 2008-04 : ( J.M. Molines ) Original code
+      !!-----------------------------------------------------------------------
+
+      INTEGER :: it , idum
+
+    idum = itobc
+    DO it =1, itobc
+       IF ( ztcobc(it) > zjcnes ) THEN ;  idum = it - 1 ; EXIT ;  ENDIF
+    ENDDO
+    ! idum can be 0 (climato, before first record)
+    IF ( idum == 0 ) THEN
+       IF ( ln_obc_clim ) THEN
+         idum = itobc
+       ELSE
+         ctmp1='obc_dta: find ntobc == 0 for  non climatological file '
+         ctmp2='consider adding a first record in your data file '
+         CALL ctl_stop(ctmp1, ctmp2)
+       ENDIF
+    ENDIF
+    ! idum can be itobc ( zjcnes > ztcobc (itobc) )
+    !  This is not a problem ...
+    nrecbef = idum
+
+  END FUNCTION nrecbef
+
+#else
+  !!------------------------------------------------------------------------------
+  !!   default option:           Dummy module          NO Open Boundary Conditions
+  !!------------------------------------------------------------------------------
+CONTAINS
+  SUBROUTINE obc_dta( kt )             ! Dummy routine
+    INTEGER, INTENT (in) :: kt
+    WRITE(*,*) 'obc_dta: You should not have seen this print! error?', kt
+  END SUBROUTINE obc_dta
+#endif
+END MODULE obcdta
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn.F90	(revision 1844)
@@ -0,0 +1,702 @@
+MODULE obcdyn
+#if defined key_obc
+   !!=================================================================================
+   !!                       ***  MODULE  obcdyn  ***
+   !! Ocean dynamics:   Radiation of velocities on each open boundary
+   !!=================================================================================
+
+   !!---------------------------------------------------------------------------------
+   !!   obc_dyn        : call the subroutine for each open boundary
+   !!   obc_dyn_east   : radiation of the east open boundary velocities
+   !!   obc_dyn_west   : radiation of the west open boundary velocities
+   !!   obc_dyn_north  : radiation of the north open boundary velocities
+   !!   obc_dyn_south  : radiation of the south open boundary velocities
+   !!----------------------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lbclnk          ! ???
+   USE lib_mpp         ! ???
+   USE in_out_manager  ! I/O manager
+   USE dynspg_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_dyn     ! routine called in dynspg_flt (free surface case)
+
+   !! * Module variables
+   INTEGER ::   ji, jj, jk     ! dummy loop indices
+
+   INTEGER ::      & ! ... boundary space indices 
+      nib   = 1,   & ! nib   = boundary point
+      nibm  = 2,   & ! nibm  = 1st interior point
+      nibm2 = 3,   & ! nibm2 = 2nd interior point
+                     ! ... boundary time indices 
+      nit   = 1,   & ! nit    = now
+      nitm  = 2,   & ! nitm   = before
+      nitm2 = 3      ! nitm2  = before-before
+
+   REAL(wp) ::   rtaue  , rtauw  , rtaun  , rtaus  ,  &
+                 rtauein, rtauwin, rtaunin, rtausin
+
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_dyn ( kt )
+      !!------------------------------------------------------------------------------
+      !!                      SUBROUTINE obc_dyn
+      !!                     ********************
+      !! ** Purpose :
+      !!      Compute  dynamics (u,v) at the open boundaries.
+      !!      if defined key_dynspg_flt: 
+      !!                 this routine is called by dynspg_flt and updates
+      !!                 ua, va which are the actual velocities (not trends)
+      !!
+      !!      The logical variable lp_obc_east, and/or lp_obc_west, and/or lp_obc_north, 
+      !!      and/or lp_obc_south allow the user to determine which boundary is an
+      !!      open one (must be done in the param_obc.h90 file).
+      !!
+      !! ** Reference : 
+      !!      Marchesiello P., 1995, these de l'universite J. Fourier, Grenoble, France.
+      !!
+      !! History :
+      !!        !  95-03 (J.-M. Molines) Original, SPEM
+      !!        !  97-07 (G. Madec, J.-M. Molines) addition
+      !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$ 
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+
+      IF( kt == nit000 .OR. ln_rstart) THEN
+         ! ... Boundary restoring coefficient
+         rtaue = 2. * rdt / rdpeob
+         rtauw = 2. * rdt / rdpwob
+         rtaun = 2. * rdt / rdpnob
+         rtaus = 2. * rdt / rdpsob
+         ! ... Boundary restoring coefficient for inflow ( all boundaries)
+         rtauein = 2. * rdt / rdpein 
+         rtauwin = 2. * rdt / rdpwin
+         rtaunin = 2. * rdt / rdpnin
+         rtausin = 2. * rdt / rdpsin 
+      END IF
+
+      IF( lp_obc_east  )   CALL obc_dyn_east ( kt )
+      IF( lp_obc_west  )   CALL obc_dyn_west ( kt )
+      IF( lp_obc_north )   CALL obc_dyn_north( kt )
+      IF( lp_obc_south )   CALL obc_dyn_south( kt )
+
+      IF( lk_mpp ) THEN
+         IF( kt >= nit000+3 .AND. ln_rstart ) THEN
+            CALL lbc_lnk( ub, 'U', -1. )
+            CALL lbc_lnk( vb, 'V', -1. )
+         END IF
+         CALL lbc_lnk( ua, 'U', -1. )
+         CALL lbc_lnk( va, 'V', -1. )
+      ENDIF
+
+   END SUBROUTINE obc_dyn
+
+
+   SUBROUTINE obc_dyn_east ( kt )
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_east  ***
+      !!              
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on east OBC velocities ua, va using the 
+      !!      phase velocities calculated in obc_rad_east subroutine in obcrad.F90 module
+      !!      If the logical lfbceast is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!    9.0  ! 05-11  (V. Garnier) Surface pressure gradient organization
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbceast is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbceast .OR. lk_dynspg_exp ) THEN
+
+         ! 1.1 U zonal velocity    
+         ! --------------------
+         DO ji = nie0, nie1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * (1.-uemsk(jj,jk)) + &
+                                 uemsk(jj,jk)*ufoe(jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 1.2 V meridional velocity
+         ! -------------------------
+         DO ji = nie0+1, nie1+1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1.-vemsk(jj,jk)) + &
+                                 vfoe(jj,jk)*vemsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbceast is .FALSE.
+      ! -----------------------------------------------------
+ 
+         ! 2.1. u-component of the velocity
+         ! ---------------------------------
+         !
+         !          nibm2      nibm      nib
+         !            |   nibm  |   nib   |///
+         !            |    |    |    |    |///
+         !  jj-line --f----v----f----v----f---
+         !            |    |    |    |    |///
+         !            |         |         |///
+         !  jj-line   u    T    u    T    u///
+         !            |         |         |///
+         !            |    |    |    |    |///
+         !          jpieob-2   jpieob-1   jpieob
+         !                 |         |        
+         !              jpieob-1    jpieob    
+         !  
+         ! ... If free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... (jpjedp1, jpjefm1),jpieob
+         DO ji = nie0, nie1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  z05cx = u_cxebnd(jj,jk)
+                  z05cx = z05cx / e1t(ji,jj)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaue
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtauein is used for relaxation coefficient else rtaue
+                  ztau = (1.-zin ) * rtauein  + zin * rtaue
+                  z05cx = z05cx * zin
+         ! ... update ua with radiative or climatological velocity
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * ( 1. - uemsk(jj,jk) ) +          &
+                                 uemsk(jj,jk) * (  ( 1. - z05cx - ztau )         &
+                                 * uebnd(jj,jk,nib ,nitm) + 2.*z05cx               &
+                                 * uebnd(jj,jk,nibm,nit ) + ztau * ufoe (jj,jk) )  &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2 v-component of the velocity
+         ! -------------------------------
+         !
+         !          nibm2       nibm     nib
+         !            |   nibm  |   nib///|///
+         !            |    |    |    |////|///
+         !  jj-line --v----f----v----f----v---
+         !            |    |    |    |////|///
+         !            |    |    |    |////|///
+         !            | jpieob-1 |  jpieob /|///
+         !            |         |         |   
+         !         jpieob-1    jpieob     jpieob+1
+         !
+         ! ... radiative condition
+         ! ... (jpjedp1, jpjefm1), jpieob+1
+         DO ji = nie0+1, nie1+1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  z05cx = v_cxebnd(jj,jk) 
+                  z05cx = z05cx / e1f(ji-1,jj)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaue
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtauein is used for relaxation coefficient else rtaue
+                  ztau = (1.-zin ) * rtauein  + zin * rtaue
+                  z05cx = z05cx * zin
+         ! ... update va with radiative or climatological velocity
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1. - vemsk(jj,jk) ) +          &
+                                 vemsk(jj,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * vebnd(jj,jk,nib ,nitm) + 2.*z05cx              &
+                                 * vebnd(jj,jk,nibm,nit ) + ztau * vfoe(jj,jk) )  &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_dyn_east
+
+
+   SUBROUTINE obc_dyn_west ( kt )
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_west  ***
+      !!                  
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on west OBC velocities ua, va using the 
+      !!      phase velocities calculated in obc_rad_west subroutine in obcrad.F90 module
+      !!      If the logical lfbcwest is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!    9.0  ! 05-11  (V. Garnier) Surface pressure gradient organization
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcwest is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcwest .OR. lk_dynspg_exp ) THEN
+
+         ! 1.1 U zonal velocity
+         ! ---------------------
+         DO ji = niw0, niw1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * (1.-uwmsk(jj,jk)) + &
+                                 uwmsk(jj,jk)*ufow(jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 1.2 V meridional velocity
+         ! -------------------------
+         DO ji = niw0, niw1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1.-vwmsk(jj,jk)) + &
+                                 vfow(jj,jk)*vwmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcwest is .FALSE.
+      ! -----------------------------------------------------
+ 
+         ! 2.1. u-component of the velocity
+         ! ---------------------------------
+         !
+         !        nib       nibm     nibm2
+         !      ///|   nib   |   nibm  |
+         !      ///|    |    |    |    |
+         !      ---f----v----f----v----f-- jj-line
+         !      ///|    |    |    |    |
+         !      ///|         |         |
+         !      ///u    T    u    T    u   jj-line
+         !      ///|         |         |
+         !      ///|    |    |    |    |
+         !       jpiwob    jpiwob+1    jpiwob+2
+         !              |         |        
+         !            jpiwob+1    jpiwob+2     
+         !
+         ! ... If free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... (jpjwdp1, jpjwfm1), jpiwob
+         DO ji = niw0, niw1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  z05cx = u_cxwbnd(jj,jk)
+                  z05cx = z05cx / e1t(ji+1,jj)
+                  z05cx = max( z05cx, -1. )
+         ! ... z05c  > 0, inflow  zin=0, ztau=1    
+         !          =< 0, outflow zin=1, ztau=rtauw
+                  zin = sign( 1., -1. * z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin )* rtauwin + zin * rtauw
+                  z05cx = z05cx * zin
+         ! ... update un with radiative or climatological velocity
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * ( 1. - uwmsk(jj,jk) ) +          &
+                                 uwmsk(jj,jk) * ( ( 1. + z05cx - ztau )          &
+                                 * uwbnd(jj,jk,nib ,nitm) - 2.*z05cx               &
+                                 * uwbnd(jj,jk,nibm,nit ) + ztau  * ufow (jj,jk) ) &
+                                 / (1. - z05cx)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2 v-component of the velocity
+         ! -------------------------------
+         !
+         !    nib       nibm     nibm2
+         !  ///|///nib   |   nibm  |  nibm2
+         !  ///|////|    |    |    |    |    |
+         !  ---v----f----v----f----v----f----v-- jj-line
+         !  ///|////|    |    |    |    |    |
+         !  ///|////|    |    |    |    |    |
+         ! jpiwob     jpiwob+1    jpiwob+2
+         !          |         |         |   
+         !        jpiwob   jpiwob+1   jpiwob+2    
+         !
+         ! ... radiative condition plus Raymond-Kuo
+         ! ... (jpjwdp1, jpjwfm1),jpiwob
+         DO ji = niw0, niw1
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  z05cx = v_cxwbnd(jj,jk)  
+                  z05cx = z05cx / e1f(ji,jj)
+                  z05cx = max( z05cx, -1. )
+         ! ... z05cx > 0, inflow  zin=0, ztau=1    
+         !          =< 0, outflow zin=1, ztau=rtauw
+                  zin = sign( 1., -1. * z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin )*rtauwin + zin * rtauw
+                  z05cx = z05cx * zin 
+         ! ... update va with radiative or climatological velocity
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1. - vwmsk(jj,jk) ) +          &
+                                 vwmsk(jj,jk) * ( ( 1. + z05cx - ztau )         &
+                                 * vwbnd(jj,jk,nib ,nitm) - 2.*z05cx              &
+                                 * vwbnd(jj,jk,nibm,nit ) + ztau * vfow (jj,jk) ) &
+                                 / (1. - z05cx)
+                END DO
+             END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_dyn_west
+
+   SUBROUTINE obc_dyn_north ( kt )
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_dyn_north
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on north OBC velocities ua, va using the 
+      !!      phase velocities calculated in obc_rad_north subroutine in obcrad.F90 module
+      !!      If the logical lfbcnorth is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!    9.0  ! 05-11  (V. Garnier) Surface pressure gradient organization
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcnorth is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! ---------------------------------------------------------
+ 
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcnorth  .OR. lk_dynspg_exp ) THEN
+
+         ! 1.1 U zonal velocity
+         ! --------------------
+         DO jj = njn0+1, njn1+1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  ua(ji,jj,jk)= ua(ji,jj,jk) * (1.-unmsk(ji,jk)) + &
+                                ufon(ji,jk)*unmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 1.2 V meridional velocity
+         ! -------------------------
+         DO jj = njn0, njn1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  va(ji,jj,jk)= va(ji,jj,jk) * (1.-vnmsk(ji,jk)) + &
+                                vfon(ji,jk)*vnmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcnorth is .FALSE.
+      ! ------------------------------------------------------
+
+         ! 2.1. u-component of the velocity
+         ! --------------------------------
+         !
+         !            ji-row
+         !              |
+         !       nib ///u//////  jpjnob + 1
+         !         /////|//////
+         !     nib -----f-----   jpjnob
+         !              |    
+         !      nibm--  u   ---- jpjnob
+         !              |        
+         !    nibm -----f-----   jpjnob-1
+         !              |        
+         !     nibm2--  u   ---- jpjnob-1
+         !              |        
+         !   nibm2 -----f-----   jpjnob-2
+         !              |
+         !
+         ! ... radiative condition
+         ! ... jpjnob+1,(jpindp1, jpinfm1)
+         DO jj = njn0+1, njn1+1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  z05cx= u_cynbnd(ji,jk) 
+                  z05cx = z05cx / e2f(ji, jj-1)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaun
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtaunin is used for relaxation coefficient else rtaun
+                  ztau = (1.-zin ) * rtaunin  + zin * rtaun
+         ! ... for u, when inflow, ufon is prescribed
+                  z05cx = z05cx * zin
+         ! ... update un with radiative or climatological velocity
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * (1.-unmsk(ji,jk)) +             &
+                                 unmsk(ji,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * unbnd(ji,jk,nib ,nitm) + 2.*z05cx              &
+                                 * unbnd(ji,jk,nibm,nit ) + ztau * ufon (ji,jk) ) &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2 v-component of the velocity
+         ! -------------------------------
+         !
+         !                ji-row    ji-row
+         !              |         |
+         !         /////|/////////////////
+         !    nib  -----f----v----f----  jpjnob
+         !              |         |
+         !      nib  -  u -- T -- u ---- jpjnob
+         !              |         |
+         !   nibm  -----f----v----f----  jpjnob-1
+         !              |         |
+         !     nibm --  u -- T -- u ---  jpjnob-1
+         !              |         |
+         !   nibm2 -----f----v----f----  jpjnob-2
+         !              |         |
+         !
+         ! ... Free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... jpjnob,(jpindp1, jpinfm1)
+         DO jj = njn0, njn1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+         ! ... 2* gradj(v) (T-point i=nibm, time mean)
+                  z05cx = v_cynbnd(ji,jk)
+                  z05cx = z05cx / e2t(ji,jj)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaun
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtaunin is used for relaxation coefficient else rtaun
+                  ztau = (1.-zin ) * rtaunin + zin * rtaun
+                  z05cx = z05cx * zin
+         ! ... update va with radiative or climatological velocity
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1.-vnmsk(ji,jk)) +             &
+                                 vnmsk(ji,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * vnbnd(ji,jk,nib ,nitm) + 2.*z05cx              &
+                                 * vnbnd(ji,jk,nibm,nit ) + ztau * vfon (ji,jk) ) &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+      END IF
+
+   END SUBROUTINE obc_dyn_north
+
+   SUBROUTINE obc_dyn_south ( kt )
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_dyn_south
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on south OBC velocities ua, va using the 
+      !!      phase velocities calculated in obc_rad_south subroutine in obcrad.F90 module
+      !!      If the logical lfbcsouth is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!    9.0  ! 05-11  (V. Garnier) Surface pressure gradient organization
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      REAL(wp) ::   z05cx, ztau, zin
+
+      !!------------------------------------------------------------------------------
+      !!  OPA 8.5, LODYC-IPSL (2002)
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcsouth is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! ---------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcsouth  .OR. lk_dynspg_exp ) THEN
+
+         ! 1.1 U zonal velocity
+         ! --------------------
+         DO jj = njs0, njs1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  ua(ji,jj,jk)= ua(ji,jj,jk) * (1.-usmsk(ji,jk)) + &
+                                usmsk(ji,jk) * ufos(ji,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 1.2 V meridional velocity
+         ! -------------------------
+         DO jj = njs0, njs1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  va(ji,jj,jk)= va(ji,jj,jk) * (1.-vsmsk(ji,jk)) + &
+                                vsmsk(ji,jk) * vfos(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcsouth is .FALSE.
+      ! ------------------------------------------------------
+
+         ! 2.1. u-component of the velocity
+         ! --------------------------------
+         !
+         !            ji-row
+         !              |
+         !   nibm2 -----f-----   jpjsob +2
+         !              |    
+         !    nibm2 --  u   ---- jpjsob +2 
+         !              |        
+         !    nibm -----f-----   jpjsob +1
+         !              |        
+         !    nibm  --  u   ---- jpjsob +1
+         !              |        
+         !    nib  -----f-----   jpjsob
+         !         /////|//////
+         !    nib   ////u/////   jpjsob 
+         !
+         ! ... radiative condition plus Raymond-Kuo
+         ! ... jpjsob,(jpisdp1, jpisfm1)
+         DO jj = njs0, njs1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  z05cx= u_cysbnd(ji,jk) 
+                  z05cx = z05cx / e2f(ji, jj)
+                  z05cx = max( z05cx, -1. )
+         ! ... z05cx > 0, inflow  zin=0, ztau=1 
+         !          =< 0, outflow zin=1, ztau=rtaus
+                  zin = sign( 1., -1. * z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin ) * rtausin + zin * rtaus
+                  z05cx = z05cx * zin 
+         ! ... update ua with radiative or climatological velocity
+                  ua(ji,jj,jk) = ua(ji,jj,jk) * (1.-usmsk(ji,jk)) +              &
+                                 usmsk(ji,jk) * (  ( 1. + z05cx - ztau )         &
+                                 * usbnd(ji,jk,nib ,nitm) - 2.*z05cx               &
+                                 * usbnd(ji,jk,nibm,nit ) + ztau * ufos (ji,jk) )  &
+                                 / (1. - z05cx)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2 v-component of the velocity
+         ! -------------------------------
+         !
+         !                ji-row    ji-row
+         !              |         |
+         !  nibm2  -----f----v----f----  jpjsob+2
+         !              |         |
+         !    nibm   -  u -- T -- u ---- jpjsob+2
+         !              |         |
+         !   nibm  -----f----v----f----  jpjsob+1 
+         !              |         |
+         !   nib    --  u -- T -- u ---  jpjsob+1
+         !              |         |
+         !   nib   -----f----v----f----  jpjsob
+         !         /////////////////////
+         !
+         ! ... Free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... jpjsob,(jpisdp1,jpisfm1)
+         DO jj = njs0, njs1
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  z05cx = v_cysbnd(ji,jk)
+                  z05cx = z05cx / e2t(ji,jj+1)
+                  z05cx = max( z05cx, -1. )
+         ! ... z05c > 0, inflow  zin=0, ztau=1 
+         !         =< 0, outflow zin=1, ztau=rtaus
+                  zin = sign( 1., -1. * z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin )*rtausin + zin * rtaus
+                  z05cx = z05cx * zin
+         ! ... update va with radiative or climatological velocity
+                  va(ji,jj,jk) = va(ji,jj,jk) * (1.-vsmsk(ji,jk)) +             &
+                                 vsmsk(ji,jk) * ( ( 1. + z05cx - ztau )         &
+                                 * vsbnd(ji,jk,nib ,nitm) - 2.*z05cx              &
+                                 * vsbnd(ji,jk,nibm,nit ) + ztau * vfos (ji,jk) ) &
+                                 / (1. - z05cx)
+               END DO
+            END DO
+         END DO
+      END IF
+
+   END SUBROUTINE obc_dyn_south
+#else
+   !!=================================================================================
+   !!                       ***  MODULE  obcdyn  ***
+   !! Ocean dynamics:   Radiation of velocities on each open boundary
+   !!=================================================================================
+CONTAINS
+
+   SUBROUTINE obc_dyn
+                              ! No open boundaries ==> empty routine
+   END SUBROUTINE obc_dyn
+#endif
+
+END MODULE obcdyn
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn_bt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn_bt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcdyn_bt.F90	(revision 1844)
@@ -0,0 +1,362 @@
+MODULE obcdyn_bt
+#if ( defined key_dynspg_ts || defined key_dynspg_exp ) && defined key_obc
+   !!=================================================================================
+   !!                       ***  MODULE  obcdyn_bt  ***
+   !! Ocean dynamics:   Radiation/prescription of sea surface heights
+   !!                   on each open boundary
+   !!=================================================================================
+
+   !!---------------------------------------------------------------------------------
+   !!   obc_dyn_bt        : call the subroutine for each open boundary
+   !!   obc_dyn_bt_east   : Flather's algorithm at the east open boundary
+   !!   obc_dyn_bt_west   : Flather's algorithm at the west open boundary
+   !!   obc_dyn_bt_north  : Flather's algorithm at the north open boundary
+   !!   obc_dyn_bt_south  : Flather's algorithm at the south open boundary
+   !!----------------------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   USE obccli          ! ocean open boundary conditions: climatology
+   USE in_out_manager  ! I/O manager
+   USE dynspg_oce      ! surface pressure gradient     (free surface with time-splitting)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_dyn_bt  ! routine called in dynnxt (explicit free surface case)
+
+   !!---------------------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_dyn_bt ( kt )
+      !!------------------------------------------------------------------------------
+      !!                      SUBROUTINE obc_dyn_bt
+      !!                     ***********************
+      !! ** Purpose :
+      !!      Apply Flather's algorithm at open boundaries for the explicit
+      !!      free surface case and free surface case with time-splitting
+      !!
+      !!      This routine is called in dynnxt.F routine and updates ua, va and sshn. 
+      !!
+      !!      The logical variable lp_obc_east, and/or lp_obc_west, and/or lp_obc_north, 
+      !!      and/or lp_obc_south allow the user to determine which boundary is an
+      !!      open one (must be done in the param_obc.h90 file).
+      !!
+      !! ** Reference : 
+      !!         Flather, R. A., 1976, Mem. Soc. R. Sci. Liege, Ser. 6, 10, 141-164
+      !!
+      !! History :
+      !!   9.0  !  05-12  (V. Garnier) original 
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !!----------------------------------------------------------------------
+
+      IF( lp_obc_east  )   CALL obc_dyn_bt_east 
+      IF( lp_obc_west  )   CALL obc_dyn_bt_west 
+      IF( lp_obc_north )   CALL obc_dyn_bt_north
+      IF( lp_obc_south )   CALL obc_dyn_bt_south
+
+      IF( lk_mpp ) THEN
+         IF( kt >= nit000+3 .AND. ln_rstart ) THEN
+            CALL lbc_lnk( sshb, 'T',  1. )
+            CALL lbc_lnk( ub  , 'U', -1. )
+            CALL lbc_lnk( vb  , 'V', -1. )
+         END IF
+         CALL lbc_lnk( sshn, 'T',  1. )
+         CALL lbc_lnk( ua  , 'U', -1. )
+         CALL lbc_lnk( va  , 'V', -1. )
+      ENDIF
+
+   END SUBROUTINE obc_dyn_bt
+
+# if defined key_dynspg_exp
+   SUBROUTINE obc_dyn_bt_east 
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_bt_east  ***
+      !!              
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on east OBC velocities ua, va 
+      !!      Fix sea surface height (sshn) on east open boundary
+      !!      The logical lfbceast must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO ji = nie0, nie1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua(ji,jj,jk) = ua(ji,jj,jk) + sqrt( grav*hur (ji,jj) )               &
+                  &                      * ( ( sshn(ji,jj) + sshn(ji+1,jj) ) * 0.5  &
+                  &                          - sshfoe(jj) ) * uemsk(jj,jk)
+            END DO
+         END DO
+      END DO
+      DO ji = nie0p1, nie1p1
+         DO jj = 1, jpj
+            sshn(ji,jj) = sshn(ji,jj) * (1.-temsk(jj,1)) + temsk(jj,1)*sshfoe(jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_east
+
+
+   SUBROUTINE obc_dyn_bt_west 
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_bt_west  ***
+      !!                  
+      !! ** Purpose :
+      !!      Apply Flather algorithm on west OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on west open boundary
+      !!      The logical lfbcwest must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO ji = niw0, niw1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua(ji,jj,jk) = ua(ji,jj,jk) - sqrt( grav*hur (ji,jj) )               &
+                  &                      * ( ( sshn(ji,jj) + sshn(ji+1,jj) ) * 0.5  &
+                  &                          - sshfow(jj) ) * uwmsk(jj,jk)
+            END DO
+         END DO
+         DO jj = 1, jpj
+            sshn(ji,jj) = sshn(ji,jj) * (1.-twmsk(jj,1)) + twmsk(jj,1)*sshfow(jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_west
+
+   SUBROUTINE obc_dyn_bt_north 
+      !!------------------------------------------------------------------------------
+      !!                ***  SUBROUTINE obc_dyn_bt_north  ***
+      !!
+      !! ** Purpose :
+      !!      Apply Flather algorithm on north OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on north open boundary
+      !!      The logical lfbcnorth must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO jj = njn0, njn1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va(ji,jj,jk) = va(ji,jj,jk) + sqrt( grav*hvr (ji,jj) )               &
+                  &                      * ( ( sshn(ji,jj) + sshn(ji,jj+1) ) * 0.5  &
+                  &                          - sshfon(ji) ) * vnmsk(ji,jk)
+            END DO
+         END DO
+      END DO
+      DO jj = njn0p1, njn1p1
+         DO ji = 1, jpi
+            sshn(ji,jj)= sshn(ji,jj) * (1.-tnmsk(ji,1)) + sshfon(ji)*tnmsk(ji,1)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_north
+
+   SUBROUTINE obc_dyn_bt_south 
+      !!------------------------------------------------------------------------------
+      !!                ***  SUBROUTINE obc_dyn_bt_south  ***
+      !!                    
+      !! ** Purpose :
+      !!      Apply Flather algorithm on south OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on south open boundary
+      !!      The logical lfbcsouth must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+
+      !!------------------------------------------------------------------------------
+
+      DO jj = njs0, njs1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va(ji,jj,jk) = va(ji,jj,jk) - sqrt( grav*hvr (ji,jj) )               &
+                  &                       * ( ( sshn(ji,jj) + sshn(ji,jj+1) ) * 0.5 &
+                  &                           - sshfos(ji) ) * vsmsk(ji,jk)
+            END DO
+         END DO
+         DO ji = 1, jpi
+            sshn(ji,jj)= sshn(ji,jj) * (1.-tsmsk(ji,1)) + tsmsk(ji,1) * sshfos(ji)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_south
+
+# elif defined key_dynspg_ts
+
+   SUBROUTINE obc_dyn_bt_east 
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_bt_east  ***
+      !!
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on east OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on east open boundary
+      !!      The logical lfbceast must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO ji = nie0, nie1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) + sshfoe_b(ji,jj) ) * uemsk(jj,jk)
+            END DO
+         END DO
+      END DO
+      DO ji = nie0p1, nie1p1
+         DO jj = 1, jpj
+            sshn(ji,jj) = sshn(ji,jj) * (1.-temsk(jj,1)) + temsk(jj,1)*sshn_b(ji,jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_east
+
+   SUBROUTINE obc_dyn_bt_west 
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_dyn_bt_west  ***
+      !!
+      !! ** Purpose :
+      !! ** Purpose :
+      !!      Apply Flather algorithm on west OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on west open boundary
+      !!      The logical lfbcwest must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO ji = niw0, niw1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) + sshfow_b(ji,jj) ) * uwmsk(jj,jk)
+            END DO
+         END DO
+         DO jj = 1, jpj
+            sshn(ji,jj) = sshn(ji,jj) * (1.-twmsk(jj,1)) + twmsk(jj,1)*sshn_b(ji,jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_west
+
+   SUBROUTINE obc_dyn_bt_north 
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_dyn_bt_north
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply Flather algorithm on north OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on north open boundary
+      !!      The logical lfbcnorth must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      DO jj = njn0, njn1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va(ji,jj,jk) = ( va(ji,jj,jk) + sshfon_b(ji,jj) ) * vnmsk(jj,jk)
+            END DO
+         END DO
+      END DO
+      DO jj = njn0p1, njn1p1
+         DO ji = 1, jpi
+            sshn(ji,jj)= sshn(ji,jj) * (1.-tnmsk(ji,1)) + sshn_b(ji,jj)*tnmsk(ji,1)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_north
+
+   SUBROUTINE obc_dyn_bt_south 
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_dyn_bt_south
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply Flather algorithm on south OBC velocities ua, va
+      !!      Fix sea surface height (sshn) on south open boundary
+      !!      The logical lfbcsouth must be .TRUE.
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+
+      !!------------------------------------------------------------------------------
+
+      DO jj = njs0, njs1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va(ji,jj,jk) = ( va(ji,jj,jk) + sshfos_b(ji,jj) ) * vsmsk(jj,jk)
+            END DO
+         END DO
+         DO ji = 1, jpi
+            sshn(ji,jj)= sshn(ji,jj) * (1.-tsmsk(ji,1)) + tsmsk(ji,1) * sshn_b(ji,jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_dyn_bt_south
+
+# endif
+#else
+   !!=================================================================================
+   !!                       ***  MODULE  obcdyn_bt  ***
+   !! Ocean dynamics:   Radiation of velocities on each open boundary
+   !!=================================================================================
+CONTAINS
+
+   SUBROUTINE obc_dyn_bt
+                              ! No open boundaries ==> empty routine
+   END SUBROUTINE obc_dyn_bt
+#endif
+
+END MODULE obcdyn_bt
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcfla.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 1844)
@@ -0,0 +1,225 @@
+MODULE obcfla
+#if defined key_obc && defined key_dynspg_ts
+   !!=================================================================================
+   !!                       ***  MODULE  obcfla  ***
+   !! Ocean dynamics:   Flather's algorithm at open boundaries for the time-splitting
+   !!=================================================================================
+
+   !!---------------------------------------------------------------------------------
+   !!   obc_fla_ts        : call the subroutine for each open boundary
+   !!   obc_fla_ts_east   : Flather on the east  open boundary velocities & ssh
+   !!   obc_fla_ts_west   : Flather on the west  open boundary velocities & ssh
+   !!   obc_fla_ts_north  : Flather on the north open boundary velocities & ssh
+   !!   obc_fla_ts_south  : Flather on the south open boundary velocities & ssh
+   !!----------------------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE dynspg_oce      ! surface pressure gradient variables
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE obcdta          ! ocean open boundary conditions: climatology
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_fla_ts  ! routine called in dynspg_ts (free surface time splitting case)
+
+   !!---------------------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005)
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_fla_ts
+      !!------------------------------------------------------------------------------
+      !!                      SUBROUTINE obc_fla_ts
+      !!                     **********************
+      !! ** Purpose :
+      !!      Apply Flather's algorithm at open boundaries for the time-splitting
+      !!      free surface case (barotropic variables)
+      !!
+      !!      This routine is called in dynspg_ts.F90 routine 
+      !!
+      !!      The logical variable lp_obc_east, and/or lp_obc_west, and/or lp_obc_north,
+      !!      and/or lp_obc_south allow the user to determine which boundary is an
+      !!      open one (must be done in the obc_par.F90 file).
+      !!
+      !! ** Reference :
+      !!         Flather, R. A., 1976, Mem. Soc. R. Sci. Liege, Ser. 6, 10, 141-164
+      !!
+      !! History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+
+      IF( lp_obc_east  )   CALL obc_fla_ts_east 
+      IF( lp_obc_west  )   CALL obc_fla_ts_west 
+      IF( lp_obc_north )   CALL obc_fla_ts_north
+      IF( lp_obc_south )   CALL obc_fla_ts_south
+
+   END SUBROUTINE obc_fla_ts
+
+
+   SUBROUTINE obc_fla_ts_east
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_fla_ts_east  ***
+      !!
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on east OBC velocities ua, va
+      !!      Fix sea surface height (sshn_e) on east open boundary
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      !!------------------------------------------------------------------------------
+
+      DO ji = nie0, nie1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua_e(ji,jj) = (  ubtfoe(jj) + sqrt( grav*hu(ji,jj) )           &
+                  &            * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5  &
+                  &            - sshfoe(jj) )  ) * uemsk(jj,jk)
+            END DO
+         END DO
+      END DO
+      DO ji = nie0p1, nie1p1
+         DO jj = 1, jpj
+            sshfoe_b(ji,jj) = sshfoe_b(ji,jj) + sqrt( grav*hur(ji,jj) )     &
+               &             * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5  &
+               &                 - sshfoe(jj) ) * uemsk(jj,1)
+            ssha_e(ji,jj) = ssha_e(ji,jj) * ( 1. - temsk(jj,1) ) &
+               &            + temsk(jj,1) * sshfoe(jj)
+            va_e(ji,jj) = vbtfoe(jj) * uemsk(jj,jk)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_fla_ts_east
+
+
+   SUBROUTINE obc_fla_ts_west
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_fla_ts_west  ***
+      !! 
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on west OBC velocities ua, va
+      !!      Fix sea surface height (sshn_e) on west open boundary
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      !!------------------------------------------------------------------------------
+
+      DO ji = niw0, niw1
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               ua_e(ji,jj) = ( ubtfow(jj) - sqrt( grav * hu(ji,jj) )          &
+                  &            * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5  &
+                  &                - sshfow(jj) ) ) * uwmsk(jj,jk)
+               va_e(ji,jj) = vbtfow(jj) * uwmsk(jj,jk)
+            END DO
+         END DO
+         DO jj = 1, jpj
+            sshfow_b(ji,jj) = sshfow_b(ji,jj) - sqrt( grav * hur(ji,jj) )     &
+                              * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5   &
+                                 - sshfow(jj) ) * uwmsk(jj,1)
+            ssha_e(ji,jj) = ssha_e(ji,jj) * ( 1. - twmsk(jj,1) ) &
+               &            + twmsk(jj,1)*sshfow(jj)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_fla_ts_west
+
+   SUBROUTINE obc_fla_ts_north
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_fla_ts_north
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on north OBC velocities ua, va
+      !!      Fix sea surface height (sshn_e) on north open boundary
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+      !!------------------------------------------------------------------------------
+
+      DO jj = njn0, njn1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va_e(ji,jj) = ( vbtfon(ji) + sqrt( grav * hv(ji,jj) )           &
+                  &            * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5   &
+                  &                - sshfon(ji) ) ) * vnmsk(ji,jk)
+            END DO
+         END DO
+      END DO
+      DO jj = njn0p1, njn1p1
+         DO ji = 1, jpi
+            sshfon_b(ji,jj) = sshfon_b(ji,jj) + sqrt( grav * hvr(ji,jj) )  &
+               &              * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5    &
+               &                  - sshfon(ji) ) * vnmsk(ji,1)
+            ssha_e(ji,jj) = ssha_e(ji,jj) * ( 1. - tnmsk(ji,1) ) &
+               &            + sshfon(ji) * tnmsk(ji,1)
+            ua_e(ji,jj) = ubtfon(ji) * vnmsk(ji,jk)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_fla_ts_north
+
+   SUBROUTINE obc_fla_ts_south
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_fla_ts_south
+      !!                    *************************
+      !! ** Purpose :
+      !!      Apply Flather's algorithm on south OBC velocities ua, va
+      !!      Fix sea surface height (sshn_e) on south open boundary
+      !!
+      !!  History :
+      !!   9.0  !  05-12  (V. Garnier) original
+      !!------------------------------------------------------------------------------
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk ! dummy loop indices
+
+      !!------------------------------------------------------------------------------
+
+      DO jj = njs0, njs1
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+               va_e(ji,jj) = ( vbtfos(ji) - sqrt( grav * hv(ji,jj) )            &
+                  &            * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5    &
+                  &                - sshfos(ji) ) ) * vsmsk(ji,jk)
+               ua_e(ji,jj) = ubtfos(ji) * vsmsk(ji,jk)
+            END DO
+         END DO
+         DO ji = 1, jpi
+            sshfos_b(ji,jj) = sshfos_b(ji,jj) - sqrt( grav * hvr(ji,jj) )      &
+               &              * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5    &
+               &                  - sshfos(ji) ) * vsmsk(ji,1)
+            ssha_e(ji,jj) = ssha_e(ji,jj) * (1. - tsmsk(ji,1) ) &
+               &            + tsmsk(ji,1) * sshfos(ji)
+         END DO
+      END DO
+
+   END SUBROUTINE obc_fla_ts_south
+#else
+   !!=================================================================================
+   !!                       ***  MODULE  obcfla  ***
+   !! Ocean dynamics:   Flather's algorithm at open boundaries for the time-splitting
+   !!=================================================================================
+CONTAINS
+
+   SUBROUTINE obc_fla_ts
+      WRITE(*,*) 'obc_fla_ts: You should not have seen this print! error?'
+   END SUBROUTINE obc_fla_ts
+#endif
+
+END MODULE obcfla
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcini.F90	(revision 1844)
@@ -0,0 +1,727 @@
+ MODULE obcini
+   !!======================================================================
+   !!                       ***  MODULE  obcini  ***
+   !! OBC initial state :  Open boundary initial state
+   !!======================================================================
+   !! History :  8.0  !  97-07  (J.M. Molines, G. Madec)  Original code
+   !!   NEMO     1.0  !  02-11  (C. Talandier, A-M. Treguier) Free surface, F90
+   !!            2.0  !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!----------------------------------------------------------------------
+#if defined key_obc
+   !!----------------------------------------------------------------------
+   !!   'key_obc'                                  Open Boundary Conditions
+   !!----------------------------------------------------------------------
+   !!   obc_init       : initialization for the open boundary condition
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! for mpp_sum
+   USE in_out_manager  ! I/O units
+   USE dynspg_oce      ! flag lk_dynspg_flt
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   obc_init   ! routine called by opa.F90
+
+   !! * Substitutions
+#  include "obc_vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE obc_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE obc_init  ***
+      !!         
+      !! ** Purpose :   Initialization of the dynamics and tracer fields at 
+      !!              the open boundaries.
+      !!
+      !! ** Method  :   initialization of open boundary variables
+      !!      (u, v) over 3 time step and 3 rows
+      !!      (t, s) over 2 time step and 2 rows
+      !!      if ln_rstart = .FALSE. : no restart, fields set to zero
+      !!      if ln_rstart = .TRUE.  : restart, fields are read in a file 
+      !!      if rdpxxx = 0 then lfbc is set true for this boundary.
+      !!
+      !! ** Input   :   restart.obc file, restart file for open boundaries 
+      !!----------------------------------------------------------------------
+      USE obcrst,   ONLY :   obc_rst_read   ! Make obc_rst_read routine available
+      !!
+      INTEGER  ::   ji, jj, istop , inumfbc
+      INTEGER, DIMENSION(4) ::   icorner
+      REAL(wp), DIMENSION(2) ::   ztestmask
+      !!
+      NAMELIST/namobc/ rn_dpein, rn_dpwin, rn_dpnin, rn_dpsin,       &
+         &             rn_dpeob, rn_dpwob, rn_dpnob, rn_dpsob,       &
+         &             rn_volemp, nn_obcdta, cn_obcdta, rn_volemp,   &
+         &             ln_obc_clim, ln_vol_cst, ln_obc_fla
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )              ! Namelist namobc : open boundaries
+      READ  ( numnam, namobc )
+
+      ! convert DOCTOR namelist name into the OLD names
+      nobc_dta = nn_obcdta
+      cffile   = cn_obcdta
+      rdpein   = rn_dpein
+      rdpwin   = rn_dpwin
+      rdpsin   = rn_dpsin
+      rdpnin   = rn_dpnin
+      rdpeob   = rn_dpeob
+      rdpwob   = rn_dpwob
+      rdpsob   = rn_dpsob
+      rdpnob   = rn_dpnob
+      volemp   = rn_volemp
+      
+
+
+      ! By security we set rdpxin and rdpxob respectively to 1. and 15. if the corresponding OBC is not activated
+      IF( .NOT.lp_obc_east  ) THEN   ;   rdpein = 1.   ;   rdpeob = 15.   ;   END IF
+      IF( .NOT.lp_obc_west  ) THEN   ;   rdpwin = 1.   ;   rdpwob = 15.   ;   END IF
+      IF( .NOT.lp_obc_north ) THEN   ;   rdpnin = 1.   ;   rdpnob = 15.   ;   END IF
+      IF( .NOT.lp_obc_south ) THEN   ;   rdpsin = 1.   ;   rdpsob = 15.   ;   END IF
+
+      ! number of open boudaries and open boundary indicators
+      nbobc = 0
+      IF( lp_obc_east  )   nbobc = nbobc + 1
+      IF( lp_obc_west  )   nbobc = nbobc + 1
+      IF( lp_obc_north )   nbobc = nbobc + 1
+      IF( lp_obc_south )   nbobc = nbobc + 1
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'obc_init : initialization of open boundaries'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '   Number of open boundaries    nbobc = ', nbobc
+      IF(lwp) WRITE(numout,*)
+
+      ! control prints
+      IF(lwp) WRITE(numout,*) '   Namelist namobc'
+      IF(lwp) WRITE(numout,*) '      data in file (=1) or initial state used (=0)   nn_obcdta   = ', nn_obcdta
+      IF(lwp) WRITE(numout,*) '      climatology (true) or not                      ln_obc_clim = ', ln_obc_clim
+      IF(lwp) WRITE(numout,*) '      vol_cst (true) or not:                         ln_vol_cst  = ', ln_vol_cst
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) '   WARNING                                                  '
+      IF(lwp) WRITE(numout,*) '      Flather"s algorithm is applied with explicit free surface scheme                 '
+      IF(lwp) WRITE(numout,*) '      or with free surface time-splitting scheme                                       '
+      IF(lwp) WRITE(numout,*) '      Nor radiation neither relaxation is allowed with explicit free surface scheme:   '
+      IF(lwp) WRITE(numout,*) '      Radiation and/or relaxation is allowed with free surface time-splitting scheme '
+      IF(lwp) WRITE(numout,*) '      depending of the choice of rdpXin = rdpXob  = 0. for open boundaries             '
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '      For the filtered free surface case,                                              '
+      IF(lwp) WRITE(numout,*) '      radiation, relaxation or presciption of data can be applied                      '
+      IF(lwp) WRITE(numout,*)
+
+      IF( lwp.AND.lp_obc_east ) THEN
+         WRITE(numout,*) '      East open boundary :'
+         WRITE(numout,*) '         i index                    jpieob   = ', jpieob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpeob = ', rn_dpeob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpein = ', rn_dpein
+      ENDIF
+
+      IF( lwp.AND.lp_obc_west ) THEN
+         WRITE(numout,*) '      West open boundary :'
+         WRITE(numout,*) '         i index                    jpiwob   = ', jpiwob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpwob = ', rn_dpwob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpwin = ', rn_dpwin
+      ENDIF
+
+      IF( lwp.AND.lp_obc_north ) THEN
+         WRITE(numout,*) '      North open boundary :'
+         WRITE(numout,*) '         j index                    jpjnob   = ', jpjnob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpnob = ', rn_dpnob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpnin = ', rn_dpnin
+      ENDIF
+
+      IF( lwp.AND.lp_obc_south ) THEN
+         WRITE(numout,*) '      South open boundary :'
+         WRITE(numout,*) '         j index                    jpjsob   = ', jpjsob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpsob = ', rn_dpsob
+         WRITE(numout,*) '         damping time scale (days)  rn_dpsin = ', rn_dpsin
+         WRITE(numout,*)
+      ENDIF
+
+      IF( nbobc /= 0 .AND. jperio /= 0 )   &
+         &   CALL ctl_stop( ' Cyclic or symmetric, and open boundary condition are not compatible' )
+
+      ! 1. Initialisation of constants 
+      ! ------------------------------
+      ! ...                          convert rdp$ob in seconds
+      ! Fixed Bdy flag              inbound                outbound
+      lfbceast  = .FALSE.   ;   rdpein = rdpein * rday    ;   rdpeob = rdpeob * rday
+      lfbcwest  = .FALSE.   ;   rdpwin = rdpwin * rday    ;   rdpwob = rdpwob * rday
+      lfbcnorth = .FALSE.   ;   rdpnin = rdpnin * rday    ;   rdpnob = rdpnob * rday
+      lfbcsouth = .FALSE.   ;   rdpsin = rdpsin * rday    ;   rdpsob = rdpsob * rday
+      inumfbc = 0
+      ! ... look for Fixed Boundaries (rdp = 0 )
+      ! ... When specified, lbcxxx flags are set to TRUE and rdpxxx are set to
+      ! ...  a small arbitrary value, (to avoid division by zero further on). 
+      ! ...  rdpxxx is not used anymore.
+      IF( lp_obc_east )  THEN
+         IF( (rdpein+rdpeob) == 0 )  THEN
+            lfbceast = .TRUE.   ;   rdpein = 1e-3   ;   rdpeob = 1e-3
+            inumfbc = inumfbc+1
+         ELSEIF ( (rdpein*rdpeob) == 0 )  THEN
+            CALL ctl_stop( 'obc_init : rn_dpein & rn_dpeob must be both zero or non zero' )
+         END IF
+      END IF
+
+      IF( lp_obc_west )  THEN
+         IF( (rdpwin + rdpwob) == 0 )  THEN
+            lfbcwest = .TRUE.     ;     rdpwin = 1e-3     ;     rdpwob = 1e-3
+            inumfbc = inumfbc+1
+         ELSEIF ( (rdpwin*rdpwob) == 0 )  THEN
+            CALL ctl_stop( 'obc_init : rn_dpwin & rn_dpwob must be both zero or non zero' )
+         END IF
+      END IF
+      IF( lp_obc_north )  THEN
+         IF( (rdpnin + rdpnob) == 0 )  THEN
+            lfbcnorth = .TRUE.     ;     rdpnin = 1e-3     ;     rdpnob = 1e-3
+            inumfbc = inumfbc+1
+         ELSEIF ( (rdpnin*rdpnob) == 0 )  THEN
+            CALL ctl_stop( 'obc_init : rn_dpnin & rn_dpnob must be both zero or non zero' )
+         END IF
+      END IF
+      IF( lp_obc_south )  THEN
+         IF( (rdpsin + rdpsob) == 0 )  THEN
+            lfbcsouth = .TRUE.   ;   rdpsin = 1e-3   ;   rdpsob = 1e-3
+            inumfbc = inumfbc+1
+         ELSEIF ( (rdpsin*rdpsob) == 0 )  THEN
+            CALL ctl_stop( 'obc_init : rn_dpsin & rn_dpsob must be both zero or non zero' )
+         END IF
+      END IF
+
+      ! 2.  Clever mpp indices for loops on the open boundaries. 
+      !     The loops will be performed only on the processors 
+      !     that contain a given open boundary.
+      ! --------------------------------------------------------
+
+      IF( lp_obc_east ) THEN
+         ! ...   mpp initialization
+         nie0   = max( 1, min(jpieob   - nimpp+1, jpi     ) )
+         nie1   = max( 0, min(jpieob   - nimpp+1, jpi - 1 ) )
+         nie0p1 = max( 1, min(jpieob+1 - nimpp+1, jpi     ) )
+         nie1p1 = max( 0, min(jpieob+1 - nimpp+1, jpi - 1 ) )
+         nie0m1 = max( 1, min(jpieob-1 - nimpp+1, jpi     ) )
+         nie1m1 = max( 0, min(jpieob-1 - nimpp+1, jpi - 1 ) )
+         nje0   = max( 2, min(jpjed    - njmpp+1, jpj     ) )
+         nje1   = max( 0, min(jpjef    - njmpp+1, jpj - 1 ) )
+         nje0p1 = max( 1, min(jpjedp1  - njmpp+1, jpj     ) )
+         nje0m1 = max( 1, min(jpjed    - njmpp+1, jpj     ) )
+         nje1m1 = max( 0, min(jpjefm1  - njmpp+1, jpj - 1 ) )
+         nje1m2 = max( 0, min(jpjefm1-1- njmpp+1, jpj - 1 ) )
+         IF(lwp) THEN
+            IF( lfbceast ) THEN
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Specified East Open Boundary'
+            ELSE
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Radiative East Open Boundary'
+            END IF
+         END IF
+      END IF
+
+      IF( lp_obc_west ) THEN
+         ! ...   mpp initialization
+         niw0   = max( 1, min(jpiwob   - nimpp+1, jpi     ) )
+         niw1   = max( 0, min(jpiwob   - nimpp+1, jpi - 1 ) )
+         niw0p1 = max( 1, min(jpiwob+1 - nimpp+1, jpi     ) )
+         niw1p1 = max( 0, min(jpiwob+1 - nimpp+1, jpi - 1 ) )
+         njw0   = max( 2, min(jpjwd    - njmpp+1, jpj     ) )
+         njw1   = max( 0, min(jpjwf    - njmpp+1, jpj - 1 ) )
+         njw0p1 = max( 1, min(jpjwdp1  - njmpp+1, jpj     ) )
+         njw0m1 = max( 1, min(jpjwd    - njmpp+1, jpj     ) )
+         njw1m1 = max( 0, min(jpjwfm1  - njmpp+1, jpj - 1 ) )
+         njw1m2 = max( 0, min(jpjwfm1-1- njmpp+1, jpj - 1 ) )
+         IF(lwp) THEN
+            IF( lfbcwest ) THEN
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Specified West Open Boundary'
+            ELSE
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Radiative West Open Boundary'
+            END IF
+         END IF
+      END IF
+ 
+      IF( lp_obc_north ) THEN
+         ! ...   mpp initialization
+         nin0   = max( 2, min(jpind    - nimpp+1, jpi     ) )
+         nin1   = max( 0, min(jpinf    - nimpp+1, jpi - 1 ) )
+         nin0p1 = max( 1, min(jpindp1  - nimpp+1, jpi     ) )
+         nin0m1 = max( 1, min(jpind    - nimpp+1, jpi     ) )
+         nin1m1 = max( 0, min(jpinfm1  - nimpp+1, jpi - 1 ) )
+         nin1m2 = max( 0, min(jpinfm1-1- nimpp+1, jpi - 1 ) )
+         njn0   = max( 1, min(jpjnob   - njmpp+1, jpj     ) )
+         njn1   = max( 0, min(jpjnob   - njmpp+1, jpj - 1 ) )
+         njn0p1 = max( 1, min(jpjnob+1 - njmpp+1, jpj     ) )
+         njn1p1 = max( 0, min(jpjnob+1 - njmpp+1, jpj - 1 ) )
+         njn0m1 = max( 1, min(jpjnob-1 - njmpp+1, jpj     ) )
+         njn1m1 = max( 0, min(jpjnob-1 - njmpp+1, jpj - 1 ) )
+         IF(lwp) THEN
+            IF( lfbcnorth ) THEN
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Specified North Open Boundary'
+            ELSE
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Radiative North Open Boundary'
+            END IF
+         END IF
+      END IF
+
+      IF( lp_obc_south ) THEN
+         ! ...   mpp initialization
+         nis0   = max( 2, min(jpisd    - nimpp+1, jpi     ) )
+         nis1   = max( 0, min(jpisf    - nimpp+1, jpi - 1 ) )
+         nis0p1 = max( 1, min(jpisdp1  - nimpp+1, jpi     ) )
+         nis0m1 = max( 1, min(jpisd    - nimpp+1, jpi     ) )
+         nis1m1 = max( 0, min(jpisfm1  - nimpp+1, jpi - 1 ) )
+         nis1m2 = max( 0, min(jpisfm1-1- nimpp+1, jpi - 1 ) )
+         njs0   = max( 1, min(jpjsob   - njmpp+1, jpj     ) )
+         njs1   = max( 0, min(jpjsob   - njmpp+1, jpj - 1 ) )
+         njs0p1 = max( 1, min(jpjsob+1 - njmpp+1, jpj     ) )
+         njs1p1 = max( 0, min(jpjsob+1 - njmpp+1, jpj - 1 ) )
+         IF(lwp) THEN
+            IF( lfbcsouth ) THEN
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Specified South Open Boundary'
+            ELSE
+               WRITE(numout,*)'     '
+               WRITE(numout,*)'         Radiative South Open Boundary'
+            END IF
+         END IF
+      END IF
+
+      ! 3. mask correction for OBCs
+      ! ---------------------------
+
+      IF( lp_obc_east ) THEN
+         !... (jpjed,jpjefm1),jpieob
+         bmask(nie0p1:nie1p1,nje0:nje1m1) = 0.e0
+
+         ! ... initilization to zero
+         uemsk(:,:) = 0.e0   ;   vemsk(:,:) = 0.e0   ;   temsk(:,:) = 0.e0
+
+         ! ... set 2D mask on East OBC,  Vopt
+         DO ji = fs_nie0, fs_nie1
+            DO jj = nje0, nje1
+               uemsk(jj,:) = umask(ji,  jj,:) * tmask_i(ji,jj)   * tmask_i(ji+1,jj)
+               vemsk(jj,:) = vmask(ji+1,jj,:) * tmask_i(ji+1,jj) 
+               temsk(jj,:) = tmask(ji+1,jj,:) * tmask_i(ji+1,jj) 
+            END DO
+         END DO
+
+      END IF
+
+      IF( lp_obc_west ) THEN
+         ! ... (jpjwd,jpjwfm1),jpiwob
+         bmask(niw0:niw1,njw0:njw1m1) = 0.e0
+
+         ! ... initilization to zero
+         uwmsk(:,:) = 0.e0   ;   vwmsk(:,:) = 0.e0   ;   twmsk(:,:) = 0.e0  
+
+         ! ... set 2D mask on West OBC,  Vopt
+         DO ji = fs_niw0, fs_niw1
+            DO jj = njw0, njw1
+               uwmsk(jj,:) = umask(ji,jj,:) * tmask_i(ji,jj)   * tmask_i(ji+1,jj)
+               vwmsk(jj,:) = vmask(ji,jj,:) * tmask_i(ji,jj)  
+               twmsk(jj,:) = tmask(ji,jj,:) * tmask_i(ji,jj)
+            END DO
+         END DO
+
+      END IF
+
+      IF( lp_obc_north ) THEN
+         ! ... jpjnob,(jpind,jpisfm1)
+         bmask(nin0:nin1m1,njn0p1:njn1p1) = 0.e0
+
+         ! ... initilization to zero
+         unmsk(:,:) = 0.e0   ;   vnmsk(:,:) = 0.e0   ;   tnmsk(:,:) = 0.e0
+
+         ! ... set 2D mask on North OBC,  Vopt
+         DO jj = fs_njn0, fs_njn1
+            DO ji = nin0, nin1
+               unmsk(ji,:) = umask(ji,jj+1,:) * tmask_i(ji,jj+1) 
+               vnmsk(ji,:) = vmask(ji,jj  ,:) * tmask_i(ji,jj)   * tmask_i(ji,jj+1)
+               tnmsk(ji,:) = tmask(ji,jj+1,:) * tmask_i(ji,jj+1)
+            END DO
+         END DO
+
+      END IF
+
+      IF( lp_obc_south ) THEN 
+         ! ... jpjsob,(jpisd,jpisfm1)
+         bmask(nis0:nis1m1,njs0:njs1) = 0.e0
+
+         ! ... initilization to zero
+         usmsk(:,:) = 0.e0   ;   vsmsk(:,:) = 0.e0   ;   tsmsk(:,:) = 0.e0
+
+         ! ... set 2D mask on South OBC,  Vopt
+         DO jj = fs_njs0, fs_njs1 
+            DO ji = nis0, nis1
+               usmsk(ji,:) = umask(ji,jj,:) * tmask_i(ji,jj) 
+               vsmsk(ji,:) = vmask(ji,jj,:) * tmask_i(ji,jj) * tmask_i(ji,jj+1)
+               tsmsk(ji,:) = tmask(ji,jj,:) * tmask_i(ji,jj)
+            END DO
+         END DO
+
+      END IF
+
+      IF ( ln_vol_cst .OR. lk_dynspg_flt ) THEN
+        ! ... Initialize obcumask and obcvmask for the Force filtering 
+        !     boundary condition in dynspg_flt
+        obcumask(:,:) = umask(:,:,1)
+        obcvmask(:,:) = vmask(:,:,1)
+
+        ! ... Initialize obctmsk on overlap region and obcs. This mask
+        !     is used in obcvol.F90 to calculate cumulate flux E-P. 
+        !     obc Tracer point are outside the domain ( U/V obc points) ==> masked by obctmsk
+        !     - no flux E-P on obcs and overlap region (jpreci = jprecj = 1)
+        obctmsk(:,:) = tmask_i(:,:)     
+
+        IF( lp_obc_east ) THEN
+           ! ... East obc Force filtering mask for the grad D
+           obcumask(nie0  :nie1  ,nje0p1:nje1m1) = 0.e0
+           obcvmask(nie0p1:nie1p1,nje0p1:nje1m1) = 0.e0
+           ! ... set to 0 on East OBC
+           obctmsk(nie0p1:nie1p1,nje0:nje1) = 0.e0
+        END IF
+  
+        IF( lp_obc_west ) THEN
+           ! ... West obc Force filtering mask for the grad D
+           obcumask(niw0:niw1,njw0:njw1) = 0.e0
+           obcvmask(niw0:niw1,njw0:njw1) = 0.e0
+           ! ... set to 0 on West OBC
+           obctmsk(niw0:niw1,njw0:njw1) = 0.e0
+        END IF
+  
+        IF( lp_obc_north ) THEN
+           ! ... North obc Force filtering mask for the grad D
+           obcumask(nin0p1:nin1m1,njn0p1:njn1p1) = 0.e0
+           obcvmask(nin0p1:nin1m1,njn0  :njn1  ) = 0.e0
+           ! ... set to 0 on North OBC
+           obctmsk(nin0:nin1,njn0p1:njn1p1) = 0.e0
+        END IF
+  
+        IF( lp_obc_south ) THEN
+           ! ... South obc Force filtering mask for the grad D
+           obcumask(nis0p1:nis1m1,njs0:njs1) = 0.e0
+           obcvmask(nis0p1:nis1m1,njs0:njs1) = 0.e0
+           ! ... set to 0 on South OBC
+           obctmsk(nis0:nis1,njs0:njs1) = 0.e0
+        END IF
+      ENDIF
+
+      IF ( ln_vol_cst .OR. lk_dynspg_flt  ) THEN
+
+         ! 3.1 Total lateral surface 
+         ! -------------------------
+         obcsurftot = 0.e0
+  
+         IF( lp_obc_east ) THEN ! ... East open boundary lateral surface
+            DO ji = nie0, nie1
+               DO jj = 1, jpj 
+                  obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uemsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END IF
+  
+         IF( lp_obc_west ) THEN ! ... West open boundary lateral surface
+            DO ji = niw0, niw1
+               DO jj = 1, jpj 
+                  obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uwmsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END IF
+
+         IF( lp_obc_north ) THEN ! ... North open boundary lateral surface
+            DO jj = njn0, njn1
+               DO ji = 1, jpi
+                  obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vnmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END IF
+  
+         IF( lp_obc_south ) THEN ! ... South open boundary lateral surface
+            DO jj = njs0, njs1
+               DO ji = 1, jpi
+                  obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vsmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END IF
+  
+         IF( lk_mpp )   CALL mpp_sum( obcsurftot )   ! sum over the global domain
+      ENDIF
+
+      ! 5. Control print on mask 
+      !    The extremities of the open boundaries must be in land
+      !    or else correspond to an "ocean corner" between two open boundaries. 
+      !    corner 1 is southwest, 2 is south east, 3 is northeast, 4 is northwest. 
+      ! --------------------------------------------------------------------------
+
+      icorner(:)=0
+
+      ! ... control of the west boundary
+      IF( lp_obc_west ) THEN
+         IF( jpiwob < 2 .OR.  jpiwob >= jpiglo-2 ) THEN
+            WRITE(ctmp1,*) ' jpiwob exceed ', jpiglo-2, 'or less than 2'
+            CALL ctl_stop( ctmp1 )
+         END IF
+         ztestmask(:)=0.
+         DO ji=niw0,niw1
+            IF( (njw0 + njmpp - 1) == jpjwd ) ztestmask(1)=ztestmask(1)+ tmask(ji,njw0,1)
+            IF( (njw1 + njmpp - 1) == jpjwf ) ztestmask(2)=ztestmask(2)+ tmask(ji,njw1,1)
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF( ztestmask(1) /= 0. ) icorner(1)=icorner(1)+1
+         IF( ztestmask(2) /= 0. ) icorner(4)=icorner(4)+1
+      END IF
+
+      ! ... control of the east boundary
+      IF( lp_obc_east ) THEN
+         IF( jpieob < 4 .OR.  jpieob >= jpiglo ) THEN
+            WRITE(ctmp1,*) ' jpieob exceed ', jpiglo, ' or less than 4'
+            CALL ctl_stop( ctmp1 )
+         END IF
+         ztestmask(:)=0.
+         DO ji=nie0p1,nie1p1
+            IF( (nje0 + njmpp - 1) == jpjed ) ztestmask(1)=ztestmask(1)+ tmask(ji,nje0,1)
+            IF( (nje1 + njmpp - 1) == jpjef ) ztestmask(2)=ztestmask(2)+ tmask(ji,nje1,1)
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+        IF( ztestmask(1) /= 0. ) icorner(2)=icorner(2)+1
+        IF( ztestmask(2) /= 0. ) icorner(3)=icorner(3)+1
+      END IF
+
+      ! ... control of the north boundary
+      IF( lp_obc_north ) THEN
+         IF( jpjnob < 4 .OR.  jpjnob >= jpjglo ) THEN
+            WRITE(ctmp1,*) 'jpjnob exceed ', jpjglo, ' or less than 4'
+            CALL ctl_stop( ctmp1 )
+         END IF
+         ztestmask(:)=0.
+         DO jj=njn0p1,njn1p1
+            IF( (nin0 + nimpp - 1) == jpind ) ztestmask(1)=ztestmask(1)+ tmask(nin0,jj,1)
+            IF( (nin1 + nimpp - 1) == jpinf ) ztestmask(2)=ztestmask(2)+ tmask(nin1,jj,1)
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF( ztestmask(1) /= 0. ) icorner(4)=icorner(4)+1
+         IF( ztestmask(2) /= 0. ) icorner(3)=icorner(3)+1
+      END IF
+
+      ! ... control of the south boundary
+      IF( lp_obc_south ) THEN
+         IF( jpjsob < 2 .OR.  jpjsob >= jpjglo-2 ) THEN
+            WRITE(ctmp1,*) ' jpjsob exceed ', jpjglo-2, ' or less than 2'
+            CALL ctl_stop( ctmp1 )
+         END IF
+         ztestmask(:)=0.
+         DO jj=njs0,njs1
+            IF( (nis0 + nimpp - 1) == jpisd ) ztestmask(1)=ztestmask(1)+ tmask(nis0,jj,1)
+            IF( (nis1 + nimpp - 1) == jpisf ) ztestmask(2)=ztestmask(2)+ tmask(nis1,jj,1)
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF( ztestmask(1) /= 0. ) icorner(1)=icorner(1)+1
+         IF( ztestmask(2) /= 0. ) icorner(2)=icorner(2)+1
+      END IF
+
+      IF( icorner(1) == 2 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' South West ocean corner, two open boudaries'
+         IF(lwp) WRITE(numout,*) ' ========== '
+         IF(lwp) WRITE(numout,*)
+         IF( jpisd /= jpiwob.OR.jpjsob /= jpjwd ) &
+              &   CALL ctl_stop( ' Open boundaries do not fit, we stop' )
+
+      ELSE IF( icorner(1) == 1 ) THEN
+         CALL ctl_stop( ' Open boundaries do not fit at SW corner, we stop' )
+      END IF 
+
+      IF( icorner(2) == 2 ) THEN
+          IF(lwp) WRITE(numout,*)
+          IF(lwp) WRITE(numout,*) ' South East ocean corner, two open boudaries'
+          IF(lwp) WRITE(numout,*) ' ========== '
+          IF(lwp) WRITE(numout,*)
+          IF( jpisf /= jpieob+1.OR.jpjsob /= jpjed ) &
+               &   CALL ctl_stop( ' Open boundaries do not fit, we stop' )
+      ELSE IF( icorner(2) == 1 ) THEN
+         CALL ctl_stop( ' Open boundaries do not fit at SE corner, we stop' )
+      END IF 
+
+      IF( icorner(3) == 2 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' North East ocean corner, two open boudaries'
+         IF(lwp) WRITE(numout,*) ' ========== '
+         IF(lwp) WRITE(numout,*)
+         IF( jpinf /= jpieob+1 .OR. jpjnob+1 /= jpjef ) &
+              &   CALL ctl_stop( ' Open boundaries do not fit, we stop' )
+       ELSE IF( icorner(3) == 1 ) THEN
+          CALL ctl_stop( ' Open boundaries do not fit at NE corner, we stop' )
+       END IF 
+
+      IF( icorner(4) == 2 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' North West ocean corner, two open boudaries'
+         IF(lwp) WRITE(numout,*) ' ========== '
+         IF(lwp) WRITE(numout,*)
+         IF( jpind /= jpiwob.OR.jpjnob+1 /= jpjwf ) &
+              &   CALL ctl_stop( ' Open boundaries do not fit, we stop' )
+       ELSE IF( icorner(4) == 1 ) THEN
+          CALL ctl_stop( ' Open boundaries do not fit at NW corner, we stop' )
+       END IF 
+
+      ! 6. Initialization of open boundary variables (u, v, t, s)
+      ! --------------------------------------------------------------
+      !   only if at least one boundary is  radiative 
+      IF ( inumfbc < nbobc .AND.  ln_rstart ) THEN
+         !  Restart from restart.obc
+         CALL obc_rst_read
+      ELSE
+
+!         ! ... Initialization to zero of radiation arrays.
+!         !     Those have dimensions of local subdomains
+
+          uebnd(:,:,:,:) = 0.e0   ;   unbnd(:,:,:,:) = 0.e0
+          vebnd(:,:,:,:) = 0.e0   ;   vnbnd(:,:,:,:) = 0.e0
+          tebnd(:,:,:,:) = 0.e0   ;   tnbnd(:,:,:,:) = 0.e0
+          sebnd(:,:,:,:) = 0.e0   ;   snbnd(:,:,:,:) = 0.e0
+
+          uwbnd(:,:,:,:) = 0.e0   ;   usbnd(:,:,:,:) = 0.e0
+          vwbnd(:,:,:,:) = 0.e0   ;   vsbnd(:,:,:,:) = 0.e0
+          twbnd(:,:,:,:) = 0.e0   ;   tsbnd(:,:,:,:) = 0.e0
+          swbnd(:,:,:,:) = 0.e0   ;   ssbnd(:,:,:,:) = 0.e0
+
+      END IF
+
+      ! 7. Control print
+      ! -----------------------------------------------------------------
+
+      ! ... control of the east boundary
+      IF( lp_obc_east ) THEN
+         istop = 0
+         IF( jpieob < 4 .OR.  jpieob >= jpiglo ) THEN
+            IF(lwp) WRITE(numout,cform_err)
+            IF(lwp) WRITE(numout,*) '            jpieob exceed ', jpim1, ' or less than 4'
+            istop = istop + 1
+         END IF
+
+         IF( lk_mpp ) THEN
+            ! ... 
+            IF( nimpp > jpieob-5) THEN
+               IF(lwp) WRITE(numout,cform_err)
+               IF(lwp) WRITE(numout,*) '        A sub-domain is too close to the East OBC'
+               IF(lwp) WRITE(numout,*) '        nimpp must be < jpieob-5'
+               istop = istop + 1
+            ENDIF
+         ELSE
+
+            ! ... stop if  e r r o r (s)   detected
+            IF( istop /= 0 ) THEN
+               WRITE(ctmp1,*) istop,' obcini : E R R O R (S) detected : stop'
+               CALL ctl_stop( ctmp1 )
+            ENDIF
+         ENDIF
+      ENDIF
+
+      ! ... control of the west boundary
+      IF( lp_obc_west ) THEN
+         istop = 0
+         IF( jpiwob < 2 .OR.  jpiwob >= jpiglo ) THEN
+            IF(lwp) WRITE(numout,cform_err)
+            IF(lwp) WRITE(numout,*) '            jpiwob exceed ', jpim1, ' or less than 2'
+            istop = istop + 1
+         END IF
+
+         IF( lk_mpp ) THEN
+            IF( (nimpp < jpiwob+5) .AND. (nimpp > 1) ) THEN
+               IF(lwp) WRITE(numout,cform_err)
+               IF(lwp) WRITE(numout,*) '        A sub-domain is too close to the West OBC'
+               IF(lwp) WRITE(numout,*) '        nimpp must be > jpiwob-5 or =1'
+               istop = istop + 1
+            ENDIF
+         ELSE
+   
+            ! ... stop if  e r r o r (s)   detected
+            IF( istop /= 0 ) THEN
+               WRITE(ctmp1,*) istop,' obcini : E R R O R (S) detected : stop'
+               CALL ctl_stop( ctmp1 )
+            ENDIF
+         ENDIF
+      ENDIF
+
+      ! control of the north boundary
+      IF( lp_obc_north ) THEN
+         istop = 0
+         IF( jpjnob < 4 .OR.  jpjnob >= jpjglo ) THEN
+            IF(lwp) WRITE(numout,cform_err)
+            IF(lwp) WRITE(numout,*) '          jpjnob exceed ', jpjm1,' or less than 4'
+            istop = istop + 1
+         END IF
+
+         IF( lk_mpp ) THEN
+            IF( njmpp > jpjnob-5) THEN
+               IF(lwp) WRITE(numout,cform_err)
+               IF(lwp) WRITE(numout,*) '        A sub-domain is too close to the North OBC'
+               IF(lwp) WRITE(numout,*) '        njmpp must be < jpjnob-5'
+               istop = istop + 1
+            ENDIF
+         ELSE
+   
+            ! ... stop if  e r r o r (s)   detected
+            IF( istop /= 0 ) THEN
+                WRITE(ctmp1,*) istop,' obcini : E R R O R (S) detected : stop'
+               CALL ctl_stop( ctmp1 )
+           ENDIF
+         ENDIF
+      ENDIF
+
+      ! control of the south boundary
+      IF( lp_obc_south ) THEN
+         istop = 0
+         IF( jpjsob < 2 .OR. jpjsob >= jpjglo ) THEN
+            IF(lwp) WRITE(numout,cform_err)
+            IF(lwp) WRITE(numout,*) '          jpjsob exceed ', jpjm1,' or less than 2'
+            istop = istop + 1
+         END IF
+
+         IF( lk_mpp ) THEN
+            IF( (njmpp < jpjsob+5) .AND. (njmpp > 1) ) THEN
+               IF(lwp) WRITE(numout,cform_err)
+               IF(lwp) WRITE(numout,*) '        A sub-domain is too close to the South OBC'
+               IF(lwp) WRITE(numout,*) '        njmpp must be > jpjsob+5 or =1'
+               istop = istop + 1
+            ENDIF
+         ELSE
+   
+            ! ... stop if  e r r o r (s)   detected
+            IF( istop /= 0 ) THEN
+               WRITE(ctmp1,*) istop,' obcini : E R R O R (S) detected : stop'
+               CALL ctl_stop( ctmp1 )
+            ENDIF
+         ENDIF
+      ENDIF
+
+   END SUBROUTINE obc_init
+
+#else
+   !!---------------------------------------------------------------------------------
+   !!   Dummy module                                                NO open boundaries
+   !!---------------------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE obc_init      ! Dummy routine
+   END SUBROUTINE obc_init
+#endif
+
+   !!=================================================================================
+END MODULE obcini
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrad.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrad.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrad.F90	(revision 1844)
@@ -0,0 +1,1175 @@
+MODULE obcrad 
+   !!=================================================================================
+   !!                       ***  MODULE  obcrad  ***
+   !! Ocean dynamic :   Phase velocities for each open boundary
+   !!=================================================================================
+#if defined key_obc
+   !!---------------------------------------------------------------------------------
+   !!   obc_rad        : call the subroutine for each open boundary
+   !!   obc_rad_east   : compute the east phase velocities
+   !!   obc_rad_west   : compute the west phase velocities
+   !!   obc_rad_north  : compute the north phase velocities
+   !!   obc_rad_south  : compute the south phase velocities
+   !!---------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! for mppobc
+   USE in_out_manager  ! I/O units
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_rad        ! routine called by step.F90
+
+   !! * Module variables
+   INTEGER ::   ji, jj, jk     ! dummy loop indices
+
+   INTEGER ::      & ! ... boundary space indices 
+      nib   = 1,   & ! nib   = boundary point
+      nibm  = 2,   & ! nibm  = 1st interior point
+      nibm2 = 3,   & ! nibm2 = 2nd interior point
+                     ! ... boundary time indices 
+      nit   = 1,   & ! nit    = now
+      nitm  = 2,   & ! nitm   = before
+      nitm2 = 3      ! nitm2  = before-before
+
+   !! * Substitutions
+#  include "obc_vectopt_loop_substitute.h90"
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_rad ( kt )
+      !!------------------------------------------------------------------------------
+      !!                     SUBROUTINE obc_rad
+      !!                    ********************
+      !! ** Purpose :
+      !!      Perform swap of arrays to calculate radiative phase speeds at the open 
+      !!      boundaries and calculate those phase speeds if the open boundaries are 
+      !!      not fixed. In case of fixed open boundaries does nothing.
+      !!
+      !!     The logical variable lp_obc_east, and/or lp_obc_west, and/or lp_obc_north,
+      !!     and/or lp_obc_south allow the user to determine which boundary is an
+      !!     open one (must be done in the param_obc.h90 file).
+      !! 
+      !! ** Reference : 
+      !!     Marchesiello P., 1995, these de l'universite J. Fourier, Grenoble, France.
+      !!
+      !!  History :
+      !!    8.5  !  02-10  (C. Talandier, A-M. Treguier) Free surface, F90 from the 
+      !!                                                 J. Molines and G. Madec version
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+      !!----------------------------------------------------------------------
+
+      IF( lp_obc_east  .AND. .NOT.lfbceast  )   CALL obc_rad_east ( kt )   ! East open boundary
+
+      IF( lp_obc_west  .AND. .NOT.lfbcwest  )   CALL obc_rad_west ( kt )   ! West open boundary
+
+      IF( lp_obc_north .AND. .NOT.lfbcnorth )   CALL obc_rad_north( kt )   ! North open boundary
+
+      IF( lp_obc_south .AND. .NOT.lfbcsouth )   CALL obc_rad_south( kt )   ! South open boundary
+
+   END SUBROUTINE obc_rad
+
+
+   SUBROUTINE obc_rad_east ( kt )
+      !!------------------------------------------------------------------------------
+      !!                     ***  SUBROUTINE obc_rad_east  ***
+      !!                   
+      !! ** Purpose :
+      !!      Perform swap of arrays to calculate radiative phase speeds at the open 
+      !!      east boundary and calculate those phase speeds if this OBC is not fixed.
+      !!      In case of fixed OBC, this subrountine is not called.
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declarations
+      INTEGER  ::   ij
+      REAL(wp) ::   z05cx, zdt, z4nor2, z2dx, z2dy
+      REAL(wp) ::   zucb, zucbm, zucbm2
+      !!------------------------------------------------------------------------------
+
+      ! 1. Swap arrays before calculating radiative velocities
+      ! ------------------------------------------------------
+
+      ! 1.1  zonal velocity 
+      ! -------------------
+
+      IF( kt > nit000 ) THEN 
+
+         ! ... advance in time (time filter, array swap) 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               uebnd(jj,jk,nib  ,nitm2) = uebnd(jj,jk,nib  ,nitm)*uemsk(jj,jk)
+               uebnd(jj,jk,nibm ,nitm2) = uebnd(jj,jk,nibm ,nitm)*uemsk(jj,jk)
+               uebnd(jj,jk,nibm2,nitm2) = uebnd(jj,jk,nibm2,nitm)*uemsk(jj,jk)
+            END DO
+         END DO
+         ! ... fields nitm <== nit  plus time filter at the boundary 
+         DO ji = fs_nie0, fs_nie1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  uebnd(jj,jk,nib  ,nitm) = uebnd(jj,jk,nib,  nit)*uemsk(jj,jk)
+                  uebnd(jj,jk,nibm ,nitm) = uebnd(jj,jk,nibm ,nit)*uemsk(jj,jk)
+                  uebnd(jj,jk,nibm2,nitm) = uebnd(jj,jk,nibm2,nit)*uemsk(jj,jk)
+         ! ... fields nit <== now (kt+1) 
+         ! ... Total or baroclinic velocity at b, bm and bm2
+                  zucb   = un(ji,jj,jk)
+                  zucbm  = un(ji-1,jj,jk)
+                  zucbm2 = un(ji-2,jj,jk)
+                  uebnd(jj,jk,nib  ,nit) = zucb   *uemsk(jj,jk)
+                  uebnd(jj,jk,nibm ,nit) = zucbm  *uemsk(jj,jk) 
+                  uebnd(jj,jk,nibm2,nit) = zucbm2 *uemsk(jj,jk) 
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(uebnd,jpjed,jpjef,jpieob,jpk*3*3,2,jpj)
+
+         ! ... extremeties nie0, nie1
+         ij = jpjed +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               uebnd(ij,jk,nibm,nitm) = uebnd(ij+1 ,jk,nibm,nitm)
+            END DO
+         END IF
+         ij = jpjef +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               uebnd(ij,jk,nibm,nitm) = uebnd(ij-1 ,jk,nibm,nitm)
+            END DO
+         END IF
+
+         ! 1.2 tangential velocity
+         ! -----------------------
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+         ! ... fields nitm2 <== nitm
+               vebnd(jj,jk,nib  ,nitm2) = vebnd(jj,jk,nib  ,nitm)*vemsk(jj,jk)
+               vebnd(jj,jk,nibm ,nitm2) = vebnd(jj,jk,nibm ,nitm)*vemsk(jj,jk)
+               vebnd(jj,jk,nibm2,nitm2) = vebnd(jj,jk,nibm2,nitm)*vemsk(jj,jk)
+            END DO
+         END DO
+
+         DO ji = fs_nie0+1, fs_nie1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  vebnd(jj,jk,nib  ,nitm) = vebnd(jj,jk,nib,  nit)*vemsk(jj,jk)
+                  vebnd(jj,jk,nibm ,nitm) = vebnd(jj,jk,nibm ,nit)*vemsk(jj,jk)
+                  vebnd(jj,jk,nibm2,nitm) = vebnd(jj,jk,nibm2,nit)*vemsk(jj,jk)
+         ! ... fields nit <== now (kt+1)
+                  vebnd(jj,jk,nib  ,nit) = vn(ji  ,jj,jk)*vemsk(jj,jk)
+                  vebnd(jj,jk,nibm ,nit) = vn(ji-1,jj,jk)*vemsk(jj,jk)
+                  vebnd(jj,jk,nibm2,nit) = vn(ji-2,jj,jk)*vemsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(vebnd,jpjed,jpjef,jpieob+1,jpk*3*3,2,jpj)
+
+         !... extremeties nie0, nie1
+         ij = jpjed +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               vebnd(ij,jk,nibm,nitm) = vebnd(ij+1 ,jk,nibm,nitm)
+            END DO 
+         END IF 
+         ij = jpjef +1 - njmpp 
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN 
+            DO jk = 1,jpkm1 
+               vebnd(ij,jk,nibm,nitm) = vebnd(ij-1 ,jk,nibm,nitm)
+            END DO 
+         END IF 
+
+         ! 1.3 Temperature and salinity
+         ! ----------------------------
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+         ! ... fields nitm <== nit  plus time filter at the boundary
+               tebnd(jj,jk,nib,nitm) = tebnd(jj,jk,nib,nit)*temsk(jj,jk)
+               sebnd(jj,jk,nib,nitm) = sebnd(jj,jk,nib,nit)*temsk(jj,jk)
+            END DO
+         END DO
+
+         DO ji = fs_nie0+1, fs_nie1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  tebnd(jj,jk,nibm,nitm) = tebnd(jj,jk,nibm,nit)*temsk(jj,jk)
+                  sebnd(jj,jk,nibm,nitm) = sebnd(jj,jk,nibm,nit)*temsk(jj,jk)
+         ! ... fields nit <== now (kt+1)
+                  tebnd(jj,jk,nib  ,nit) = tn(ji  ,jj,jk)*temsk(jj,jk)
+                  tebnd(jj,jk,nibm ,nit) = tn(ji-1,jj,jk)*temsk(jj,jk)
+                  sebnd(jj,jk,nib  ,nit) = sn(ji  ,jj,jk)*temsk(jj,jk)
+                  sebnd(jj,jk,nibm ,nit) = sn(ji-1,jj,jk)*temsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(tebnd,jpjed,jpjef,jpieob+1,jpk*2*2,2,jpj)
+         IF( lk_mpp )   CALL mppobc(sebnd,jpjed,jpjef,jpieob+1,jpk*2*2,2,jpj)
+
+         ! ... extremeties nie0, nie1
+         ij = jpjed +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               tebnd(ij,jk,nibm,nitm) = tebnd(ij+1 ,jk,nibm,nitm)
+               sebnd(ij,jk,nibm,nitm) = sebnd(ij+1 ,jk,nibm,nitm)
+            END DO
+         END IF
+         ij = jpjef +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               tebnd(ij,jk,nibm,nitm) = tebnd(ij-1 ,jk,nibm,nitm)
+               sebnd(ij,jk,nibm,nitm) = sebnd(ij-1 ,jk,nibm,nitm)
+            END DO
+         END IF
+
+      END IF     ! End of array swap
+
+      ! 2 - Calculation of radiation velocities
+      ! ---------------------------------------
+
+      IF( kt >= nit000 +3 .OR. ln_rstart ) THEN
+
+         ! 2.1  Calculate the normal velocity U based on phase velocity u_cxebnd
+         ! ---------------------------------------------------------------------
+         !
+         !          nibm2      nibm      nib
+         !            |  nibm   |   nib   |///
+         !            |    |    |    |    |///
+         !  jj-line --f----v----f----v----f---
+         !            |    |    |    |    |///
+         !            |         |         |///
+         !  jj-line   u    T    u    T    u///
+         !            |         |         |///
+         !            |    |    |    |    |///
+         !          jpieob-2   jpieob-1   jpieob
+         !                 |         |        
+         !              jpieob-1    jpieob      
+         !
+         ! ... (jpjedp1, jpjefm1),jpieob
+         DO ji = fs_nie0, fs_nie1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... 2* gradi(u) (T-point i=nibm, time mean)
+                  z2dx = ( uebnd(jj,jk,nibm ,nit) + uebnd(jj,jk,nibm ,nitm2) &
+                           - 2.*uebnd(jj,jk,nibm2,nitm) ) / e1t(ji-1,jj)
+         ! ... 2* gradj(u) (u-point i=nibm, time nitm)
+                  z2dy = ( uebnd(jj+1,jk,nibm,nitm) - uebnd(jj-1,jk,nibm,nitm) ) / e2u(ji-1,jj)
+         ! ... square of the norm of grad(u)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = uebnd(jj,jk,nibm,nitm2) - uebnd(jj,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by 1)               
+                  IF( z4nor2 == 0. ) THEN
+                     z4nor2=.00001
+                  END IF
+                  z05cx = zdt * z2dx / z4nor2
+                  u_cxebnd(jj,jk) = z05cx*uemsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2  Calculate the tangential velocity based on phase velocity v_cxebnd
+         ! -----------------------------------------------------------------------
+         !
+         !          nibm2      nibm      nib
+         !            |   nibm  |   nib///|///
+         !            |    |    |    |////|///
+         !  jj-line --v----f----v----f----v---
+         !            |    |    |    |////|///
+         !            |    |    |    |////|///
+         !            | jpieob-1| jpieob /|///
+         !            |         |         |   
+         !         jpieob-1    jpieob     jpieob+1
+         !
+         ! ... (jpjedp1, jpjefm1), jpieob+1
+         DO ji = fs_nie0+1, fs_nie1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... 2* i-gradient of v (f-point i=nibm, time mean)
+                  z2dx = ( vebnd(jj,jk,nibm ,nit) + vebnd(jj,jk,nibm ,nitm2) &
+                          - 2.*vebnd(jj,jk,nibm2,nitm) ) / e1f(ji-2,jj)
+         ! ... 2* j-gradient of v (v-point i=nibm, time nitm)
+                  z2dy = ( vebnd(jj+1,jk,nibm,nitm) -  vebnd(jj-1,jk,nibm,nitm) ) / e2v(ji-1,jj)
+         ! ... square of the norm of grad(v)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = vebnd(jj,jk,nibm,nitm2) - vebnd(jj,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by 1) and save the unbounded phase
+         !     velocity ratio no divided by e1f for the tracer radiation
+                  IF( z4nor2 == 0. ) THEN
+                     z4nor2=.000001
+                  END IF
+                  z05cx = zdt * z2dx / z4nor2
+                  v_cxebnd(jj,jk) = z05cx*vemsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(v_cxebnd,jpjed,jpjef,jpieob+1,jpk,2,jpj)
+
+         ! ... extremeties nie0, nie1
+         ij = jpjed +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               v_cxebnd(ij,jk) = v_cxebnd(ij+1 ,jk)
+            END DO
+         END IF
+         ij = jpjef +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               v_cxebnd(ij,jk) = v_cxebnd(ij-1 ,jk)
+            END DO
+         END IF
+
+      END IF
+
+   END SUBROUTINE obc_rad_east
+
+
+   SUBROUTINE obc_rad_west ( kt )
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_rad_west  ***
+      !!                    
+      !! ** Purpose :
+      !!      Perform swap of arrays to calculate radiative phase speeds at the open 
+      !!      west boundary and calculate those phase speeds if this OBC is not fixed.
+      !!      In case of fixed OBC, this subrountine is not called.
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declarations
+      INTEGER ::   ij
+      REAL(wp) ::   z05cx, zdt, z4nor2, z2dx, z2dy
+      REAL(wp) ::   zucb, zucbm, zucbm2
+      !!------------------------------------------------------------------------------
+
+      ! 1. Swap arrays before calculating radiative velocities
+      ! ------------------------------------------------------
+
+      ! 1.1  zonal velocity 
+      ! -------------------
+
+      IF( kt > nit000 ) THEN
+
+         ! ... advance in time (time filter, array swap) 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj 
+               uwbnd(jj,jk,nib  ,nitm2) = uwbnd(jj,jk,nib  ,nitm)*uwmsk(jj,jk)
+               uwbnd(jj,jk,nibm ,nitm2) = uwbnd(jj,jk,nibm ,nitm)*uwmsk(jj,jk)
+               uwbnd(jj,jk,nibm2,nitm2) = uwbnd(jj,jk,nibm2,nitm)*uwmsk(jj,jk)
+            END DO
+         END DO
+
+         ! ... fields nitm <== nit  plus time filter at the boundary 
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  uwbnd(jj,jk,nib  ,nitm) = uwbnd(jj,jk,nib  ,nit)*uwmsk(jj,jk)
+                  uwbnd(jj,jk,nibm ,nitm) = uwbnd(jj,jk,nibm ,nit)*uwmsk(jj,jk)
+                  uwbnd(jj,jk,nibm2,nitm) = uwbnd(jj,jk,nibm2,nit)*uwmsk(jj,jk)
+         ! ... total or baroclinic velocity at b, bm and bm2
+                  zucb   = un (ji,jj,jk)
+                  zucbm  = un (ji+1,jj,jk)
+                  zucbm2 = un (ji+2,jj,jk)
+
+         ! ... fields nit <== now (kt+1) 
+                  uwbnd(jj,jk,nib  ,nit) = zucb  *uwmsk(jj,jk)
+                  uwbnd(jj,jk,nibm ,nit) = zucbm *uwmsk(jj,jk)
+                  uwbnd(jj,jk,nibm2,nit) = zucbm2*uwmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(uwbnd,jpjwd,jpjwf,jpiwob,jpk*3*3,2,jpj)
+
+         ! ... extremeties niw0, niw1
+         ij = jpjwd +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               uwbnd(ij,jk,nibm,nitm) = uwbnd(ij+1 ,jk,nibm,nitm)
+            END DO
+         END IF
+         ij = jpjwf +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               uwbnd(ij,jk,nibm,nitm) = uwbnd(ij-1 ,jk,nibm,nitm)
+            END DO
+         END IF
+
+         ! 1.2 tangential velocity
+         ! -----------------------
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj 
+         ! ... fields nitm2 <== nitm
+                  vwbnd(jj,jk,nib  ,nitm2) = vwbnd(jj,jk,nib  ,nitm)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm ,nitm2) = vwbnd(jj,jk,nibm ,nitm)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm2,nitm2) = vwbnd(jj,jk,nibm2,nitm)*vwmsk(jj,jk)
+            END DO
+         END DO
+
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  vwbnd(jj,jk,nib  ,nitm) = vwbnd(jj,jk,nib,  nit)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm ,nitm) = vwbnd(jj,jk,nibm ,nit)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm2,nitm) = vwbnd(jj,jk,nibm2,nit)*vwmsk(jj,jk)
+         ! ... fields nit <== now (kt+1)
+                  vwbnd(jj,jk,nib  ,nit) = vn(ji  ,jj,jk)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm ,nit) = vn(ji+1,jj,jk)*vwmsk(jj,jk)
+                  vwbnd(jj,jk,nibm2,nit) = vn(ji+2,jj,jk)*vwmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(vwbnd,jpjwd,jpjwf,jpiwob,jpk*3*3,2,jpj)
+
+         ! ... extremeties niw0, niw1 
+         ij = jpjwd +1 - njmpp 
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN 
+            DO jk = 1,jpkm1 
+               vwbnd(ij,jk,nibm,nitm) = vwbnd(ij+1 ,jk,nibm,nitm)
+            END DO 
+         END IF
+         ij = jpjwf +1 - njmpp 
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN 
+            DO jk = 1,jpkm1 
+               vwbnd(ij,jk,nibm,nitm) = vwbnd(ij-1 ,jk,nibm,nitm)
+            END DO 
+         END IF 
+ 
+         ! 1.3 Temperature and salinity
+         ! ----------------------------
+ 
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+         ! ... fields nitm <== nit  plus time filter at the boundary
+               twbnd(jj,jk,nib,nitm) = twbnd(jj,jk,nib,nit)*twmsk(jj,jk)
+               swbnd(jj,jk,nib,nitm) = swbnd(jj,jk,nib,nit)*twmsk(jj,jk)
+            END DO
+         END DO
+ 
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  twbnd(jj,jk,nibm ,nitm) = twbnd(jj,jk,nibm ,nit)*twmsk(jj,jk)
+                  swbnd(jj,jk,nibm ,nitm) = swbnd(jj,jk,nibm ,nit)*twmsk(jj,jk)
+         ! ... fields nit <== now (kt+1)
+                  twbnd(jj,jk,nib  ,nit) = tn(ji   ,jj,jk)*twmsk(jj,jk)
+                  twbnd(jj,jk,nibm ,nit) = tn(ji+1 ,jj,jk)*twmsk(jj,jk)
+                  swbnd(jj,jk,nib  ,nit) = sn(ji   ,jj,jk)*twmsk(jj,jk)
+                  swbnd(jj,jk,nibm ,nit) = sn(ji+1 ,jj,jk)*twmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(twbnd,jpjwd,jpjwf,jpiwob,jpk*2*2,2,jpj)
+         IF( lk_mpp )   CALL mppobc(swbnd,jpjwd,jpjwf,jpiwob,jpk*2*2,2,jpj)
+
+         ! ... extremeties niw0, niw1
+         ij = jpjwd +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               twbnd(ij,jk,nibm,nitm) = twbnd(ij+1 ,jk,nibm,nitm)
+               swbnd(ij,jk,nibm,nitm) = swbnd(ij+1 ,jk,nibm,nitm)
+            END DO
+         END IF
+         ij = jpjwf +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               twbnd(ij,jk,nibm,nitm) = twbnd(ij-1 ,jk,nibm,nitm)
+               swbnd(ij,jk,nibm,nitm) = swbnd(ij-1 ,jk,nibm,nitm)
+            END DO
+         END IF
+ 
+      END IF     ! End of array swap
+
+      ! 2 - Calculation of radiation velocities
+      ! ---------------------------------------
+   
+      IF( kt >= nit000 +3 .OR. ln_rstart ) THEN
+  
+         ! 2.1  Calculate the normal velocity U based on phase velocity u_cxwbnd
+         ! ----------------------------------------------------------------------
+         !
+         !          nib       nibm      nibm2
+         !        ///|   nib   |   nibm  |
+         !        ///|    |    |    |    |
+         !        ---f----v----f----v----f-- jj-line
+         !        ///|    |    |    |    |
+         !        ///|         |         |
+         !        ///u    T    u    T    u   jj-line
+         !        ///|         |         |
+         !        ///|    |    |    |    |
+         !         jpiwob    jpiwob+1    jpiwob+2
+         !                |         |        
+         !              jpiwob+1    jpiwob+2     
+         !
+         ! ... If free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... (jpjwdp1, jpjwfm1), jpiwob
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... 2* gradi(u) (T-point i=nibm, time mean)
+                  z2dx = ( - uwbnd(jj,jk,nibm ,nit) -  uwbnd(jj,jk,nibm ,nitm2) &
+                           + 2.*uwbnd(jj,jk,nibm2,nitm) ) / e1t(ji+2,jj)
+         ! ... 2* gradj(u) (u-point i=nibm, time nitm)
+                  z2dy = ( uwbnd(jj+1,jk,nibm,nitm) - uwbnd(jj-1,jk,nibm,nitm) ) / e2u(ji+1,jj)
+         ! ... square of the norm of grad(u)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = uwbnd(jj,jk,nibm,nitm2) - uwbnd(jj,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by -1)
+                  IF( z4nor2 == 0. ) THEN
+                     z4nor2=0.00001
+                  END IF
+                  z05cx = zdt * z2dx / z4nor2
+                  u_cxwbnd(jj,jk)=z05cx*uwmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 2.2  Calculate the tangential velocity based on phase velocity v_cxwbnd
+         ! -----------------------------------------------------------------------
+         !
+         !      nib       nibm     nibm2
+         !    ///|///nib   |   nibm  |  nibm2
+         !    ///|////|    |    |    |    |    |
+         !    ---v----f----v----f----v----f----v-- jj-line
+         !    ///|////|    |    |    |    |    |
+         !    ///|////|    |    |    |    |    |
+         !   jpiwob     jpiwob+1    jpiwob+2
+         !            |         |         |   
+         !          jpiwob   jpiwob+1   jpiwob+2    
+         !
+         ! ... radiative condition plus Raymond-Kuo
+         ! ... (jpjwdp1, jpjwfm1),jpiwob
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... 2* i-gradient of v (f-point i=nibm, time mean)
+                  z2dx = ( - vwbnd(jj,jk,nibm ,nit) - vwbnd(jj,jk,nibm ,nitm2) &
+                           + 2.*vwbnd(jj,jk,nibm2,nitm) ) / e1f(ji+1,jj)
+         ! ... 2* j-gradient of v (v-point i=nibm, time nitm)
+                  z2dy = ( vwbnd(jj+1,jk,nibm,nitm) - vwbnd(jj-1,jk,nibm,nitm) ) / e2v(ji+1,jj)
+         ! ... square of the norm of grad(v)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = vwbnd(jj,jk,nibm,nitm2) - vwbnd(jj,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by -1) and save the unbounded phase
+         !     velocity ratio no divided by e1f for the tracer radiation
+                  IF( z4nor2 == 0) THEN
+                     z4nor2=0.000001
+                  endif
+                  z05cx = zdt * z2dx / z4nor2
+                  v_cxwbnd(jj,jk) = z05cx*vwmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(v_cxwbnd,jpjwd,jpjwf,jpiwob,jpk,2,jpj)
+
+         ! ... extremeties niw0, niw1
+         ij = jpjwd +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               v_cxwbnd(ij,jk) = v_cxwbnd(ij+1 ,jk)
+            END DO
+         END IF
+         ij = jpjwf +1 - njmpp
+         IF( ij >= 2 .AND. ij < jpjm1 ) THEN
+            DO jk = 1,jpkm1
+               v_cxwbnd(ij,jk) = v_cxwbnd(ij-1 ,jk)
+            END DO
+         END IF
+
+      END IF
+
+   END SUBROUTINE obc_rad_west
+
+
+   SUBROUTINE obc_rad_north ( kt )
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_rad_north  ***
+      !!           
+      !! ** Purpose :
+      !!      Perform swap of arrays to calculate radiative phase speeds at the open 
+      !!      north boundary and calculate those phase speeds if this OBC is not fixed.
+      !!      In case of fixed OBC, this subrountine is not called.
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declarations
+      INTEGER  ::   ii
+      REAL(wp) ::   z05cx, zdt, z4nor2, z2dx, z2dy
+      REAL(wp) ::   zvcb, zvcbm, zvcbm2
+      !!------------------------------------------------------------------------------
+
+      ! 1. Swap arrays before calculating radiative velocities
+      ! ------------------------------------------------------
+
+      ! 1.1  zonal velocity 
+      ! -------------------
+
+      IF( kt > nit000 ) THEN 
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm2 <== nitm
+               unbnd(ji,jk,nib  ,nitm2) = unbnd(ji,jk,nib  ,nitm)*unmsk(ji,jk)
+               unbnd(ji,jk,nibm ,nitm2) = unbnd(ji,jk,nibm ,nitm)*unmsk(ji,jk)
+               unbnd(ji,jk,nibm2,nitm2) = unbnd(ji,jk,nibm2,nitm)*unmsk(ji,jk)
+            END DO
+         END DO
+
+         DO jj = fs_njn0+1, fs_njn1+1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  unbnd(ji,jk,nib  ,nitm) = unbnd(ji,jk,nib,  nit)*unmsk(ji,jk)
+                  unbnd(ji,jk,nibm ,nitm) = unbnd(ji,jk,nibm ,nit)*unmsk(ji,jk)
+                  unbnd(ji,jk,nibm2,nitm) = unbnd(ji,jk,nibm2,nit)*unmsk(ji,jk)
+         ! ... fields nit <== now (kt+1)
+                  unbnd(ji,jk,nib  ,nit) = un(ji,jj,  jk)*unmsk(ji,jk)
+                  unbnd(ji,jk,nibm ,nit) = un(ji,jj-1,jk)*unmsk(ji,jk)
+                  unbnd(ji,jk,nibm2,nit) = un(ji,jj-2,jk)*unmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(unbnd,jpind,jpinf,jpjnob+1,jpk*3*3,1,jpi)
+
+         ! ... extremeties njn0,njn1 
+         ii = jpind + 1 - nimpp 
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN 
+            DO jk = 1, jpkm1
+                unbnd(ii,jk,nibm,nitm) = unbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF 
+         ii = jpinf + 1 - nimpp 
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               unbnd(ii,jk,nibm,nitm) = unbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+ 
+         ! 1.2. normal velocity 
+         ! --------------------
+
+         ! ... advance in time (time filter, array swap) 
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm2 <== nitm 
+               vnbnd(ji,jk,nib  ,nitm2) = vnbnd(ji,jk,nib  ,nitm)*vnmsk(ji,jk)
+               vnbnd(ji,jk,nibm ,nitm2) = vnbnd(ji,jk,nibm ,nitm)*vnmsk(ji,jk)
+               vnbnd(ji,jk,nibm2,nitm2) = vnbnd(ji,jk,nibm2,nitm)*vnmsk(ji,jk)
+            END DO
+         END DO
+
+         DO jj = fs_njn0, fs_njn1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  vnbnd(ji,jk,nib  ,nitm) = vnbnd(ji,jk,nib,  nit)*vnmsk(ji,jk)
+                  vnbnd(ji,jk,nibm ,nitm) = vnbnd(ji,jk,nibm ,nit)*vnmsk(ji,jk)
+                  vnbnd(ji,jk,nibm2,nitm) = vnbnd(ji,jk,nibm2,nit)*vnmsk(ji,jk)
+         ! ... fields nit <== now (kt+1)
+         ! ... total or baroclinic velocity at b, bm and bm2
+                  zvcb   = vn (ji,jj,jk)
+                  zvcbm  = vn (ji,jj-1,jk)
+                  zvcbm2 = vn (ji,jj-2,jk)
+         ! ... fields nit <== now (kt+1) 
+                  vnbnd(ji,jk,nib  ,nit) = zvcb  *vnmsk(ji,jk)
+                  vnbnd(ji,jk,nibm ,nit) = zvcbm *vnmsk(ji,jk)
+                  vnbnd(ji,jk,nibm2,nit) = zvcbm2*vnmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(vnbnd,jpind,jpinf,jpjnob,jpk*3*3,1,jpi)
+
+         ! ... extremeties njn0,njn1
+         ii = jpind + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               vnbnd(ii,jk,nibm,nitm) = vnbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF
+         ii = jpinf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               vnbnd(ii,jk,nibm,nitm) = vnbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+
+         ! 1.3 Temperature and salinity
+         ! ----------------------------
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm <== nit  plus time filter at the boundary
+               tnbnd(ji,jk,nib ,nitm) = tnbnd(ji,jk,nib,nit)*tnmsk(ji,jk)
+               snbnd(ji,jk,nib ,nitm) = snbnd(ji,jk,nib,nit)*tnmsk(ji,jk)
+            END DO
+         END DO
+
+         DO jj = fs_njn0+1, fs_njn1+1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  tnbnd(ji,jk,nibm ,nitm) = tnbnd(ji,jk,nibm ,nit)*tnmsk(ji,jk)
+                  snbnd(ji,jk,nibm ,nitm) = snbnd(ji,jk,nibm ,nit)*tnmsk(ji,jk)
+         ! ... fields nit <== now (kt+1)
+                  tnbnd(ji,jk,nib  ,nit) = tn(ji,jj,  jk)*tnmsk(ji,jk)
+                  tnbnd(ji,jk,nibm ,nit) = tn(ji,jj-1,jk)*tnmsk(ji,jk)
+                  snbnd(ji,jk,nib  ,nit) = sn(ji,jj,  jk)*tnmsk(ji,jk)
+                  snbnd(ji,jk,nibm ,nit) = sn(ji,jj-1,jk)*tnmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(tnbnd,jpind,jpinf,jpjnob+1,jpk*2*2,1,jpi)
+         IF( lk_mpp )   CALL mppobc(snbnd,jpind,jpinf,jpjnob+1,jpk*2*2,1,jpi)
+
+         ! ... extremeties  njn0,njn1
+         ii = jpind + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               tnbnd(ii,jk,nibm,nitm) = tnbnd(ii+1,jk,nibm,nitm)
+               snbnd(ii,jk,nibm,nitm) = snbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF
+         ii = jpinf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               tnbnd(ii,jk,nibm,nitm) = tnbnd(ii-1,jk,nibm,nitm)
+               snbnd(ii,jk,nibm,nitm) = snbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+
+      END IF     ! End of array swap
+
+      ! 2 - Calculation of radiation velocities
+      ! ---------------------------------------
+
+      IF( kt >= nit000 +3 .OR. ln_rstart ) THEN
+
+         ! 2.1  Calculate the normal velocity based on phase velocity u_cynbnd
+         ! -------------------------------------------------------------------
+         !
+         !           ji-row
+         !             |
+         !     nib -///u//////  jpjnob + 1
+         !        /////|//////
+         !   nib  -----f-----   jpjnob
+         !             |    
+         !     nibm--  u   ---- jpjnob
+         !             |        
+         !  nibm  -----f-----   jpjnob-1
+         !             |        
+         !    nibm2--  u   ---- jpjnob-1
+         !             |        
+         !  nibm2 -----f-----   jpjnob-2
+         !             |
+         ! ... radiative condition
+         ! ... jpjnob+1,(jpindp1, jpinfm1)
+         DO jj = fs_njn0+1, fs_njn1+1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         ! ... 2* j-gradient of u (f-point i=nibm, time mean)
+                  z2dx = ( unbnd(ji,jk,nibm ,nit) + unbnd(ji,jk,nibm ,nitm2) &
+                        - 2.*unbnd(ji,jk,nibm2,nitm)) / e2f(ji,jj-2)
+         ! ... 2* i-gradient of u (u-point i=nibm, time nitm)
+                  z2dy = ( unbnd(ji+1,jk,nibm,nitm) - unbnd(ji-1,jk,nibm,nitm) ) / e1u(ji,jj-1)
+         ! ... square of the norm of grad(v)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = unbnd(ji,jk,nibm,nitm2) - unbnd(ji,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by 1) and save the unbounded phase
+         !     velocity ratio no divided by e1f for the tracer radiation
+                  IF( z4nor2 == 0.) THEN
+                     z4nor2=.000001
+                  END IF
+                  z05cx = zdt * z2dx / z4nor2
+                  u_cynbnd(ji,jk) = z05cx *unmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(u_cynbnd,jpind,jpinf,jpjnob+1,jpk,1,jpi)
+
+         ! ... extremeties  njn0,njn1
+         ii = jpind + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               u_cynbnd(ii,jk) = u_cynbnd(ii+1,jk)
+            END DO
+         END IF
+         ii = jpinf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               u_cynbnd(ii,jk) = u_cynbnd(ii-1,jk)
+            END DO
+         END IF
+
+         ! 2.2 Calculate the normal velocity based on phase velocity v_cynbnd 
+         ! ------------------------------------------------------------------
+         !
+         !                ji-row  ji-row
+         !                     |
+         !        /////|/////////////////
+         !   nib  -----f----v----f----  jpjnob
+         !             |         |
+         !     nib  -  u -- T -- u ---- jpjnob
+         !             |         |
+         !  nibm  -----f----v----f----  jpjnob-1
+         !             |         |
+         !    nibm --  u -- T -- u ---  jpjnob-1
+         !             |         |
+         !  nibm2 -----f----v----f----  jpjnob-2
+         !             |         |
+         ! ... Free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology 
+         ! ... jpjnob,(jpindp1, jpinfm1)
+         DO jj = fs_njn0, fs_njn1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         ! ... 2* gradj(v) (T-point i=nibm, time mean)
+                  ii = ji -1 + nimpp
+                  z2dx = ( vnbnd(ji,jk,nibm ,nit) + vnbnd(ji,jk,nibm ,nitm2) &
+                          - 2.*vnbnd(ji,jk,nibm2,nitm)) / e2t(ji,jj-1)
+         ! ... 2* gradi(v) (v-point i=nibm, time nitm)
+                  z2dy = ( vnbnd(ji+1,jk,nibm,nitm) - vnbnd(ji-1,jk,nibm,nitm) ) / e1v(ji,jj-1)
+         ! ... square of the norm of grad(u)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = vnbnd(ji,jk,nibm,nitm2) - vnbnd(ji,jk,nibm,nit)
+         ! ... j-phase speed ratio (bounded by 1)
+                  IF( z4nor2 == 0. ) THEN
+                     z4nor2=.00001
+                  END IF
+                  z05cx = zdt * z2dx / z4nor2
+                  v_cynbnd(ji,jk)=z05cx *vnmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_rad_north
+
+
+   SUBROUTINE obc_rad_south ( kt )
+      !!------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_rad_south  ***
+      !!           
+      !! ** Purpose :
+      !!      Perform swap of arrays to calculate radiative phase speeds at the open 
+      !!      south boundary and calculate those phase speeds if this OBC is not fixed.
+      !!      In case of fixed OBC, this subrountine is not called.
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) Free surface, F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declarations
+      INTEGER ::   ii
+      REAL(wp) ::   z05cx, zdt, z4nor2, z2dx, z2dy
+      REAL(wp) ::   zvcb, zvcbm, zvcbm2
+      !!------------------------------------------------------------------------------
+
+      ! 1. Swap arrays before calculating radiative velocities
+      ! ------------------------------------------------------
+
+      ! 1.1  zonal velocity 
+      ! --------------------
+  
+      IF( kt > nit000) THEN 
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm2 <== nitm
+                  usbnd(ji,jk,nib  ,nitm2) = usbnd(ji,jk,nib  ,nitm)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm ,nitm2) = usbnd(ji,jk,nibm ,nitm)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm2,nitm2) = usbnd(ji,jk,nibm2,nitm)*usmsk(ji,jk)
+            END DO
+         END DO
+ 
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  usbnd(ji,jk,nib  ,nitm) = usbnd(ji,jk,nib,  nit)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm ,nitm) = usbnd(ji,jk,nibm ,nit)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm2,nitm) = usbnd(ji,jk,nibm2,nit)*usmsk(ji,jk)
+         ! ... fields nit <== now (kt+1)
+                  usbnd(ji,jk,nib  ,nit) = un(ji,jj  ,jk)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm ,nit) = un(ji,jj+1,jk)*usmsk(ji,jk)
+                  usbnd(ji,jk,nibm2,nit) = un(ji,jj+2,jk)*usmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(usbnd,jpisd,jpisf,jpjsob,jpk*3*3,1,jpi)
+
+         ! ... extremeties njs0,njs1
+         ii = jpisd + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               usbnd(ii,jk,nibm,nitm) = usbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF
+         ii = jpisf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               usbnd(ii,jk,nibm,nitm) = usbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+ 
+         ! 1.2 normal velocity
+         ! -------------------
+ 
+         !.. advance in time (time filter, array swap) 
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm2 <== nitm 
+               vsbnd(ji,jk,nib  ,nitm2) = vsbnd(ji,jk,nib  ,nitm)*vsmsk(ji,jk)
+               vsbnd(ji,jk,nibm ,nitm2) = vsbnd(ji,jk,nibm ,nitm)*vsmsk(ji,jk)
+            END DO
+         END DO
+
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  vsbnd(ji,jk,nib  ,nitm) = vsbnd(ji,jk,nib,  nit)*vsmsk(ji,jk)
+                  vsbnd(ji,jk,nibm ,nitm) = vsbnd(ji,jk,nibm ,nit)*vsmsk(ji,jk)
+                  vsbnd(ji,jk,nibm2,nitm) = vsbnd(ji,jk,nibm2,nit)*vsmsk(ji,jk)
+         ! ... total or baroclinic velocity at b, bm and bm2
+                  zvcb   = vn (ji,jj,jk)
+                  zvcbm  = vn (ji,jj+1,jk)
+                  zvcbm2 = vn (ji,jj+2,jk)
+         ! ... fields nit <== now (kt+1) 
+                  vsbnd(ji,jk,nib  ,nit) = zvcb   *vsmsk(ji,jk)
+                  vsbnd(ji,jk,nibm ,nit) = zvcbm  *vsmsk(ji,jk)
+                  vsbnd(ji,jk,nibm2,nit) = zvcbm2 *vsmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(vsbnd,jpisd,jpisf,jpjsob,jpk*3*3,1,jpi)
+
+         ! ... extremeties njs0,njs1
+         ii = jpisd + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               vsbnd(ii,jk,nibm,nitm) = vsbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF
+         ii = jpisf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               vsbnd(ii,jk,nibm,nitm) = vsbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+
+         ! 1.3 Temperature and salinity
+         ! ----------------------------
+
+         ! ... advance in time (time filter, array swap)
+         DO jk = 1, jpkm1
+            DO ji = 1, jpi
+         ! ... fields nitm <== nit  plus time filter at the boundary
+               tsbnd(ji,jk,nib,nitm) = tsbnd(ji,jk,nib,nit)*tsmsk(ji,jk)
+               ssbnd(ji,jk,nib,nitm) = ssbnd(ji,jk,nib,nit)*tsmsk(ji,jk)
+            END DO
+         END DO
+
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  tsbnd(ji,jk,nibm ,nitm) = tsbnd(ji,jk,nibm ,nit)*tsmsk(ji,jk)
+                  ssbnd(ji,jk,nibm ,nitm) = ssbnd(ji,jk,nibm ,nit)*tsmsk(ji,jk)
+         ! ... fields nit <== now (kt+1)
+                  tsbnd(ji,jk,nib  ,nit) = tn(ji,jj   ,jk)*tsmsk(ji,jk)
+                  tsbnd(ji,jk,nibm ,nit) = tn(ji,jj+1 ,jk)*tsmsk(ji,jk)
+                  ssbnd(ji,jk,nib  ,nit) = sn(ji,jj   ,jk)*tsmsk(ji,jk)
+                  ssbnd(ji,jk,nibm ,nit) = sn(ji,jj+1 ,jk)*tsmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(tsbnd,jpisd,jpisf,jpjsob,jpk*2*2,1,jpi)
+         IF( lk_mpp )   CALL mppobc(ssbnd,jpisd,jpisf,jpjsob,jpk*2*2,1,jpi)
+
+         ! ... extremeties  njs0,njs1
+         ii = jpisd + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               tsbnd(ii,jk,nibm,nitm) = tsbnd(ii+1,jk,nibm,nitm)
+               ssbnd(ii,jk,nibm,nitm) = ssbnd(ii+1,jk,nibm,nitm)
+            END DO
+         END IF
+         ii = jpisf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               tsbnd(ii,jk,nibm,nitm) = tsbnd(ii-1,jk,nibm,nitm)
+               ssbnd(ii,jk,nibm,nitm) = ssbnd(ii-1,jk,nibm,nitm)
+            END DO
+         END IF
+
+      END IF     ! End of array swap
+
+      ! 2 - Calculation of radiation velocities
+      ! ---------------------------------------
+
+      IF( kt >= nit000 +3 .OR. ln_rstart ) THEN
+
+         ! 2.1  Calculate the normal velocity based on phase velocity u_cysbnd
+         ! -------------------------------------------------------------------
+         !
+         !          ji-row
+         !            |
+         ! nibm2 -----f-----   jpjsob +2
+         !            |    
+         !  nibm2 --  u  ----- jpjsob +2 
+         !            |        
+         !  nibm -----f-----   jpjsob +1
+         !            |        
+         !  nibm  --  u  ----- jpjsob +1
+         !            |        
+         !  nib  -----f-----   jpjsob
+         !       /////|//////
+         !  nib   ////u/////   jpjsob 
+         !
+         ! ... radiative condition plus Raymond-Kuo
+         ! ... jpjsob,(jpisdp1, jpisfm1)
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         ! ... 2* j-gradient of u (f-point i=nibm, time mean)
+                  z2dx = (- usbnd(ji,jk,nibm ,nit) - usbnd(ji,jk,nibm ,nitm2) &
+                          + 2.*usbnd(ji,jk,nibm2,nitm) ) / e2f(ji,jj+1)
+         ! ... 2* i-gradient of u (u-point i=nibm, time nitm)
+                  z2dy = ( usbnd(ji+1,jk,nibm,nitm) - usbnd(ji-1,jk,nibm,nitm) ) / e1u(ji, jj+1)
+         ! ... square of the norm of grad(v)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+                  IF( z4nor2 == 0.) THEN
+                     z4nor2 = 0.000001
+                  END IF
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = usbnd(ji,jk,nibm,nitm2) - usbnd(ji,jk,nibm,nit)
+         ! ... i-phase speed ratio (bounded by -1) and save the unbounded phase
+         !     velocity ratio no divided by e1f for the tracer radiation
+                  z05cx = zdt * z2dx / z4nor2
+                  u_cysbnd(ji,jk) = z05cx*usmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mppobc(u_cysbnd,jpisd,jpisf,jpjsob,jpk,1,jpi)
+
+         ! ... extremeties  njs0,njs1
+         ii = jpisd + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               u_cysbnd(ii,jk) = u_cysbnd(ii+1,jk)
+            END DO
+         END IF
+         ii = jpisf + 1 - nimpp
+         IF( ii >= 2 .AND. ii < jpim1 ) THEN
+            DO jk = 1, jpkm1
+               u_cysbnd(ii,jk) = u_cysbnd(ii-1,jk)
+            END DO
+         END IF
+
+         ! 2.2 Calculate the normal velocity based on phase velocity v_cysbnd 
+         ! -------------------------------------------------------------------
+         !
+         !               ji-row  ji-row
+         !            |         |
+         ! nibm2 -----f----v----f----  jpjsob+2
+         !            |         |
+         !  nibm   -  u -- T -- u ---- jpjsob+2
+         !            |         |
+         ! nibm  -----f----v----f----  jpjsob+1 
+         !            |         |
+         ! nib    --  u -- T -- u ---  jpjsob+1
+         !            |         |
+         ! nib   -----f----v----f----  jpjsob
+         !       /////////////////////
+         !
+         ! ... Free surface formulation:
+         ! ... radiative conditions on the total part + relaxation toward climatology
+         ! ... jpjsob,(jpisdp1,jpisfm1)
+         DO jj = fs_njs0, fs_njs1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         ! ... 2* gradj(v) (T-point i=nibm, time mean)
+                  z2dx = ( - vsbnd(ji,jk,nibm ,nit) - vsbnd(ji,jk,nibm ,nitm2) &
+                           + 2.*vsbnd(ji,jk,nibm2,nitm) ) / e2t(ji,jj+1)
+         ! ... 2* gradi(v) (v-point i=nibm, time nitm)
+                  z2dy = ( vsbnd(ji+1,jk,nibm,nitm) - vsbnd(ji-1,jk,nibm,nitm) ) / e1v(ji,jj+1)
+         ! ... square of the norm of grad(u)
+                  z4nor2 = z2dx * z2dx + z2dy * z2dy
+                  IF( z4nor2 == 0.) THEN
+                     z4nor2 = 0.000001
+                  END IF
+         ! ... minus time derivative (leap-frog) at nibm, without / 2 dt
+                  zdt = vsbnd(ji,jk,nibm,nitm2) - vsbnd(ji,jk,nibm,nit)
+         ! ... j-phase speed ratio (bounded by -1)
+                  z05cx = zdt * z2dx / z4nor2
+                  v_cysbnd(ji,jk)=z05cx*vsmsk(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      ENDIF
+ 
+   END SUBROUTINE obc_rad_south
+
+#else
+   !!=================================================================================
+   !!                       ***  MODULE  obcrad  ***
+   !! Ocean dynamic :   Phase velocities for each open boundary
+   !!=================================================================================
+CONTAINS
+   SUBROUTINE obc_rad( kt )            ! No open boundaries ==> empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'obc_rad: You should not have seen this print! error?', kt
+   END SUBROUTINE obc_rad
+#endif
+
+END MODULE obcrad
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcrst.F90	(revision 1844)
@@ -0,0 +1,608 @@
+MODULE obcrst
+#if defined key_obc
+   !!=================================================================================
+   !!                       ***  MODULE  obcrst  ***
+   !! Ocean dynamic :  Input/Output files for restart on OBC
+   !!=================================================================================
+
+   !!---------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! for mppobc
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_rst_read       ! routine called by obc_ini
+   PUBLIC obc_rst_write      ! routine called by step
+
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_rst_write ( kt )
+      !!--------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE obc_rst_write  ***
+      !!                
+      !! ** Purpose :   Write open boundary restart fields in restart.obc.output file 
+      !!
+      !! ** Method  :   restart.obc.output file: Direct access non formatted file.
+      !!      Each nstock time step , save fields which are necessary for restart.
+      !!      - This routine is called if at least the key_obc is defined. It is called
+      !!        at the same time step than rstwrite.
+      !!      - First record holds OBC parameters nbobc,jpieob,jpiwob,jpjnob,jpjsob and 
+      !!        the OBC layout jpjed, jpjef ... for checking purposes.
+      !!      - Following records hold the boundary arrays, in the order east west north
+      !!        south, if they exist.
+      !!      - The writing is realised by vertical slab across the boundary, for bsf, u,
+      !!        v, t, and s boundary arrays. Each record hold a vertical slab.
+      !!      - For mpp, this allows each processor to write only the correct informations
+      !!        it hold. If a processor has no valid informations on boundary, it just 
+      !!        skip the writing part (automatically).
+      !!      - Special care is taken for dumping the starting point of a boundary (jpjed,
+      !!        jpjwd, jpind, jpisd) because of the general definition of nje0 njw0,nin0,
+      !!        nis0. This is done to avoid records to be written by 2 adjacent processors.
+      !!
+      !!  History :
+      !!         ! 97-11 (J.M. Molines) Original code
+      !!         ! 98-11 (J.M. Molines) Bug fix for adjacent processors
+      !!   8.5   ! 02-10 (C. Talandier, A-M. Treguier) F90
+      !!         ! 03-06 (J.M. Molines) Bug fix for adjacent processors
+      !!   9.0   ! 04-02 (G. Madec)  suppression of numwob, use inum
+      !!-----------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk
+      INTEGER ::   inum               ! temporary logical unit
+      INTEGER ::   ibloc, nreclo, jrec, jt, jb 
+      INTEGER ::   jfoe, jfow, ifon, ifos
+      INTEGER ::   ino0, it0
+      !!-----------------------------------------------------------------------------
+
+      ! 1. Output of restart fields (inum)
+      ! ------------------------------------
+ 
+      IF( ( mod(kt,nstock) == 0 ) .OR. ( kt == nitend ) ) THEN
+
+         ! 1.0 Initializations
+         ! -------------------
+         IF(lwp) THEN
+              WRITE(numout,*) ' '
+              WRITE(numout,*) 'obcrst: OBC output for restart with obc_rst_write routine'
+              WRITE(numout,*) '~~~~~~'
+              WRITE(numout,*) '        output done in restart.obc.output file at it= ', kt, ' date= ', ndastp
+         END IF
+
+         ino0 = no
+         it0  = kt
+         ibloc  = 4096*4
+         nreclo = ibloc*( ( ( 26 *jpk + 9 )*jpbyt -1)/ibloc + 1)
+         IF(lwp) WRITE(numout,*) '             '
+         IF(lwp) WRITE(numout,*) '        OBC restart file opened with nreclo = ',nreclo
+
+         ! 1.1 Open file
+         ! -------------
+
+         CALL ctl_opn( inum, 'restart.obc.output', 'UNKNOWN', 'UNFORMATTED', 'DIRECT', nreclo, numout, lwp )
+ 
+         ! 1.2 Write header
+         ! ----------------
+         WRITE (inum,REC=1) ino0,it0,nbobc,jpieob,jpiwob,jpjnob,jpjsob,     &
+                              jpjed,jpjef,jpjwd,jpjwf,jpind,jpinf,jpisd,jpisf
+
+         ! 1.3 Write east boundary array if any.
+         ! -------------------------------------
+         IF( lp_obc_east ) THEN
+            IF( lfbceast ) THEN
+               IF(lwp) THEN
+                  WRITE(numout,*) ' '
+                  WRITE(numout,*) '        No restart file for the fixed east OBC'
+               END IF
+            ELSE
+               IF( jpieob /= 0 ) THEN
+                  IF( nje0+njmpp-1  == jpjed .AND. nie1 >= nie0 ) THEN
+            ! ... dump of jpjed if it is on this proc.
+                     jrec = 2
+                     jfoe = jpjed - njmpp + 1
+                     PRINT *,'Narea =',narea,' write jrec =2 east'
+                     WRITE(inum,REC=jrec)                                    &
+                           ((( uebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( vebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( tebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                           ((( sebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                  ENDIF
+                  DO ji = nie0, nie1
+                     DO jj = nje0, nje1
+            ! ... only interested processors go through the following lines
+            !           jfoe = jj + njmpp -1
+                        jfoe = jj 
+                        jrec = 2 + jj + njmpp -1 -jpjed
+                        WRITE (inum,REC=jrec)                                   &
+                              ((( uebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( vebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( tebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                              ((( sebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                     END DO
+                  END DO
+               END IF
+            END IF
+         END IF
+ 
+         ! 1.4 Write west boundary arrays if any
+         ! -------------------------------------
+         IF( lp_obc_west ) THEN
+            IF( lfbcwest ) THEN
+               IF(lwp) THEN
+                  WRITE(numout,*) ' '
+                  WRITE(numout,*) '        No restart file for the fixed west OBC'
+               END IF
+            ELSE
+               IF( jpiwob /= 0 ) THEN
+                  IF( njw0+njmpp+1 == jpjwd .AND. niw1 >= niw0 ) THEN
+            ! ... dump of jpjwd if it is on this proc.
+                     jrec = 3 + jpjef - jpjed
+            !        jfow = jpjwd
+                     jfow = jpjwd -njmpp + 1
+                     PRINT *,'Narea =',narea,' write jrec =',jrec,' west'
+                     WRITE (inum,REC=jrec)                                   &
+                           ((( uwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( vwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( twbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                           ((( swbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                  END IF
+                  DO ji = niw0, niw1
+                     DO jj = njw0, njw1
+            ! ... only interested processors go through the following lines
+            !           jfow = jj + njmpp -1
+                        jfow = jj 
+                        jrec = 3 + jpjef -jpjed + jj + njmpp -1 -jpjwd
+                        WRITE (inum,REC=jrec)                                   &
+                              ((( uwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( vwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( twbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                              ((( swbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                     END DO
+                  END DO
+               END IF
+            END IF
+         END IF
+ 
+         ! 1.5 Write north boundary arrays if any
+         ! --------------------------------------
+         IF( lp_obc_north ) THEN
+            IF( lfbcnorth ) THEN
+               IF(lwp) THEN
+                  WRITE(numout,*) ' '
+                  WRITE(numout,*) '        No restart file for the fixed north OBC'
+               END IF
+            ELSE
+               IF( jpjnob /= 0) THEN
+                  IF( nin0+nimpp-1 == jpind .AND. njn1 >= njn0 ) THEN
+            ! ... dump of jpind if it is on this proc.
+                     jrec = 4 + jpjef -jpjed + jpjwf -jpjwd
+            !        ifon = jpind
+                     ifon = jpind -nimpp +1
+                     WRITE (inum,REC=jrec)                                   &
+                           ((( unbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( vnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( tnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                           ((( snbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                  END IF
+                  DO jj = njn0, njn1
+                     DO ji = nin0, nin1
+            ! ... only interested processors go through the following lines
+            !           ifon = ji + nimpp -1
+                        ifon = ji 
+                        jrec = 4 + jpjef -jpjed + jpjwf -jpjwd +ji + nimpp -1  -jpind
+                        WRITE (inum,REC=jrec)                                   &
+                              ((( unbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( vnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( tnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                              ((( snbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                     END DO
+                  END DO
+               END IF
+            END IF
+         END IF
+ 
+         ! 1.6 Write south boundary arrays if any
+         ! --------------------------------------
+         IF( lp_obc_south ) THEN
+            IF( lfbcsouth ) THEN
+               IF(lwp) THEN
+                  WRITE(numout,*) ' '
+                  WRITE(numout,*) '        No restart file for the fixed south OBC'
+                  WRITE(numout,*) ' '
+               END IF
+            ELSE
+               IF( jpjsob /= 0 ) THEN
+                  IF( nis0+nimpp-1 == jpisd .AND. njs1 >= njs0 ) THEN
+            ! ... dump of jpisd if it is on this proc.
+                     jrec = 5 + jpjef -jpjed + jpjwf -jpjwd +jpinf -jpind
+            !        ifos = jpisd
+                     ifos = jpisd -nimpp + 1
+                     WRITE (inum,REC=jrec)                                   &
+                           ((( usbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( vsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                           ((( tsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                           ((( ssbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                  END IF
+                  DO jj = njs0, njs1
+                     DO ji = nis0, nis1
+            ! ... only interested processors go through the following lines
+            !           ifos = ji + nimpp -1
+                        ifos = ji 
+                        jrec = 5 + jpjef -jpjed + jpjwf -jpjwd +jpinf -jpind + &
+                              ji + nimpp -1 -jpisd
+                        WRITE (inum,REC=jrec) &
+                              ((( usbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( vsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                              ((( tsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                              ((( ssbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+                     END DO
+                  END DO
+               END IF
+            END IF
+         END IF
+      CLOSE(inum)
+      END IF
+
+   END SUBROUTINE obc_rst_write
+
+
+   SUBROUTINE obc_rst_read
+      !!----------------------------------------------------------------------------
+      !!                   ***  SUBROUTINE obc_rst_read  ***
+      !!                   
+      !! ** Purpose :   Read files for restart at open boundaries
+      !!
+      !! ** Method  :   Read the previous boundary arrays on unit inum
+      !!      The first record indicates previous characterics
+      !!
+      !! History :
+      !!        ! 97-11 (J.M. Molines) Original code
+      !!   8.5  ! 02-10 (C. Talandier, A-M. Treguier) F90
+      !!----------------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   inum = 11            ! temporary logical unit
+      INTEGER ::   ji,jj,jk,ios
+      INTEGER ::   ino0,it0,nbobc0,jpieob0,jpiwob0,jpjnob0,jpjsob0
+      INTEGER ::   ino1,it1,nbobc1,jpieob1,jpiwob1,jpjnob1,jpjsob1
+      INTEGER ::   ied0,ief0,iwd0,iwf0,ind0,inf0,isd0,isf0
+      INTEGER ::   ied1,ief1,iwd1,iwf1,ind1,inf1,isd1,isf1
+      INTEGER ::   ibloc, nreclo, jrec, jt, jb
+      INTEGER ::   jfoe, jfow, ifon, ifos
+      !!-----------------------------------------------------------------------------
+
+      ! 0. Initialisations
+      ! ------------------
+ 
+      ino0    = no
+      it0     = nit000
+      nbobc0  = nbobc
+      jpieob0 = jpieob
+      jpiwob0 = jpiwob
+      jpjnob0 = jpjnob
+      jpjsob0 = jpjsob
+ 
+      ied0   = jpjed
+      ief0   = jpjef
+      iwd0   = jpjwd
+      iwf0   = jpjwf
+      ind0   = jpind
+      inf0   = jpinf
+      isd0   = jpisd
+      isf0   = jpisf
+ 
+      ibloc  = 4096*4
+      nreclo = ibloc *( ( ( 26 *jpk + 9 )*jpbyt -1)/ibloc + 1)
+ 
+      IF(lwp) THEN
+         WRITE(numout,*) 'obcrst: beginning of restart with obc_rst_read routine'
+         WRITE(numout,*) '~~~~~~'
+         WRITE(numout,*) ' '
+         WRITE(numout,*) '        The present run :'
+         WRITE(numout,*) '        number job is  : ',no 
+         WRITE(numout,*) '        with the time nit000 : ',nit000
+         WRITE(numout,*) '        OBC restart file opened with nreclo = ',nreclo 
+      END IF
+ 
+      ! 0.1 Open files
+      ! ---------------
+      CALL ctl_opn( inum, 'restart.obc', 'UNKNOWN', 'UNFORMATTED', 'DIRECT', nreclo, numout, lwp )
+
+      ! 1. Read
+      ! -------
+ 
+      ! 1.1 First record
+      ! -----------------
+      READ(inum,REC=1) ino1,it1,nbobc1,jpieob1,jpiwob1,jpjnob1,     &
+                         jpjsob1,ied1,ief1,iwd1,iwf1,ind1,inf1,isd1,isf1
+ 
+      IF(lwp) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) '        READ inum with number job : ',ino1,' with the time it: ',it1
+         WRITE(numout,*) ' '
+      END IF
+ 
+      ! 1.2 Control of date
+      ! --------------------
+      IF( ( it0-it1 ) /= 1 .AND. abs(nrstdt) == 1 ) THEN
+          CALL ctl_stop( '        ===>>>> : problem with nit000 for the restart',   &
+               &         '        ==============',   &
+               &         '        we stop in obc_rst_read routine. Verify the file or rerun with the value',   &
+               &         '        0 for the control of time parameter nrstdt' )
+             
+      END IF
+ 
+      ! 1.3 Control of number of open boundaries
+      ! ----------------------------------------
+      IF( nbobc1 /= nbobc0 ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '        ===> W A R N I N G: The number of OBC have changed:'
+            WRITE(numout,*) '        Last run : ',nbobc0,' obcs'
+            WRITE(numout,*) '        This run : ',nbobc1,' obcs'
+         END IF
+      END IF
+ 
+      ! 1.4 Control of which boundary is open
+      ! -------------------------------------
+      IF( lp_obc_east .AND. ( jpieob1 /= 0 ) ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '         '
+            WRITE(numout,*) '        East open boundary'
+            IF( jpieob0 /= jpieob1 ) CALL ctl_stop( '         ==>>>> : Problem in obc_rst_read, jpieob have changed' )
+         END IF
+      END IF
+ 
+      IF( lp_obc_west .AND. ( jpiwob1 /= 0 ) ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '         '
+            WRITE(numout,*) '        West open boundary'
+            IF( jpiwob0 /= jpiwob1 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpiwob has changed' )
+         END IF
+      END IF
+ 
+      IF( lp_obc_north .AND. ( jpjnob1 /= 0 ) ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '         '
+            WRITE(numout,*) '        North open boundary'
+            IF( jpjnob0 /= jpjnob1 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjnob has changed' )
+         END IF
+      END IF
+ 
+      IF( lp_obc_south .AND. ( jpjsob1 /= 0 ) ) THEN
+         IF(lwp) THEN
+            WRITE(numout,*) '         '
+            WRITE(numout,*) '        South open boundary'
+            IF( jpjsob0 /= jpjsob1) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjsob has changed' )
+         END IF
+      END IF
+ 
+ 
+      ! 1.5 Control of the limit of the boundaries
+      ! ------------------------------------------
+      IF( lp_obc_east .AND. ( jpieob1 /= 0 ) ) THEN
+         IF( ied1 /= ied0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjed has changed' )
+         IF( ief1 /= ief0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjef has changed' )
+      END IF
+
+      IF( lp_obc_west .AND. ( jpiwob1 /= 0 ) ) THEN
+         IF( iwd1 /= iwd0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjwd has changed' )
+         IF( iwf1 /= iwf0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpjwf has changed' )
+      END IF
+ 
+      IF( lp_obc_north .AND. ( jpjnob1 /= 0 ) ) THEN
+         IF( ind1 /= ind0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpind has changed' )
+         IF( inf1 /= inf0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpinf has changed' )
+      END IF
+ 
+      IF( lp_obc_south .AND. ( jpjsob1 /= 0 ) ) THEN
+         IF( isd1 /= isd0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpisd has changed' )
+         IF( isf1 /= isf0 ) CALL ctl_stop( '        ==>>>> : Problem in obc_rst_read, jpisf has changed' )
+      END IF
+ 
+ 
+      ! 2. Now read the boundary arrays
+      ! -------------------------------
+ 
+      ! 2.1 Read east boundary array if any.
+      ! ------------------------------------
+      IF( lp_obc_east ) THEN
+         IF( jpieob1 /= 0) THEN
+            IF( nje0+njmpp-1 == jpjed .AND. nie1 >= nie0 ) THEN
+      ! ... read of jpjed if it is on this proc.
+               jrec = 2
+      !        jfoe = jpjed
+               jfoe = jpjed -njmpp + 1
+               READ (inum,REC=jrec)                                   &
+                    ((( uebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( vebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( tebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                    ((( sebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+            END IF
+            DO ji = nie0, nie1
+               DO jj = nje0, nje1
+      ! ... only interested processors go through the following lines
+      !           jfoe = jj + njmpp -1
+                  jfoe = jj 
+                  jrec = 2 + jj + njmpp -1 -jpjed
+                  READ (inum,REC=jrec)                                   &
+                       ((( uebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( vebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( tebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                       ((( sebnd(jfoe,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+               END DO
+            END DO
+
+         ELSE
+
+            !  lp_obc_east was not TRUE previously
+         END IF
+
+      END IF
+ 
+      ! 2.2 Read west boundary arrays if any.
+      ! -------------------------------------
+      IF( lp_obc_west ) THEN
+         IF( jpiwob1 /= 0) THEN
+            IF( njw0+njmpp-1 == jpjwd .AND. niw1 >= niw0 ) THEN
+      ! ... read of jpjwd if it is on this proc.
+               jrec = 3 + jpjef - jpjed
+      !        jfow = jpjwd
+               jfow = jpjwd -njmpp + 1
+               READ (inum,REC=jrec)                                   &
+                    ((( uwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( vwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( twbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                    ((( swbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+            END IF
+            DO ji = niw0, niw1
+               DO jj = njw0, njw1
+      ! ... only interested processors go through the following lines
+      !           jfow = jj + njmpp -1
+                  jfow = jj 
+                  jrec = 3 + jpjef -jpjed + jj + njmpp -1 -jpjwd
+                  READ (inum,REC=jrec)                                   &
+                       ((( uwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( vwbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( twbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                       ((( swbnd(jfow,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+               END DO
+            END DO
+
+         ELSE
+
+            !  lp_obc_west was not TRUE previously
+         END IF
+
+      END IF
+ 
+      ! 2.3 Read north boundary arrays if any.
+      ! --------------------------------------
+      IF( lp_obc_north ) THEN
+         IF( jpjnob1 /= 0) THEN
+            IF( nin0+nimpp-1 == jpind .AND. njn1 >= njn0 ) THEN
+      ! ... read of jpind if it is on this proc.
+               jrec = 4 + jpjef -jpjed + jpjwf -jpjwd
+      !        ifon = jpind
+               ifon = jpind -nimpp +1
+               READ (inum,REC=jrec)                                   &
+                    ((( unbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( vnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( tnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), & 
+                    ((( snbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+            END IF
+            DO jj = njn0, njn1
+               DO ji = nin0, nin1
+      ! ... only interested processors go through the following lines
+      !           ifon = ji + nimpp -1
+                  ifon = ji 
+                  jrec = 4 + jpjef -jpjed + jpjwf -jpjwd +ji + nimpp -1  -jpind
+                  READ (inum,REC=jrec)                                   & 
+                       ((( unbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( vnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( tnbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                       ((( snbnd(ifon,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+               END DO
+            END DO
+
+         ELSE
+
+           !  lp_obc_north was not TRUE previously
+         END IF
+
+      END IF
+ 
+      ! 2.4 Read south boundary arrays if any.
+      ! -------------------------------------
+      IF( lp_obc_south ) THEN
+         IF( jpjsob1 /= 0) THEN
+            IF( nis0+nimpp-1 == jpisd .AND. njs1 >= njs0 ) THEN
+      ! ... read of jpisd if it is on this proc.
+               jrec = 5 + jpjef -jpjed + jpjwf -jpjwd +jpinf -jpind
+      !        ifos = jpisd
+               ifos = jpisd -nimpp + 1
+               READ (inum,REC=jrec)                                   &
+                    ((( usbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( vsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                    ((( tsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                    ((( ssbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+            END IF
+            DO jj = njs0, njs1
+               DO ji = nis0, nis1
+      ! ... only interested processors go through the following lines
+      !           ifos = ji + nimpp -1
+                  ifos = ji 
+                  jrec = 5 + jpjef -jpjed + jpjwf -jpjwd +jpinf -jpind +  &
+                        ji + nimpp -1 -jpisd
+                  READ (inum,REC=jrec)                                   & 
+                       ((( usbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( vsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,3),jt=1,3), &
+                       ((( tsbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2), &
+                       ((( ssbnd(ifos,jk,jb,jt),jk=1,jpk),jb=1,2),jt=1,2)
+               END DO
+            END DO
+         ELSE
+            !  lp_obc_south was not TRUE previously
+         END IF
+
+      END IF
+      CLOSE(inum)
+
+      IF( lk_mpp ) THEN
+         IF( lp_obc_east ) THEN
+            CALL mppobc(uebnd,jpjed,jpjef,jpieob,jpk*3*3,2,jpj)
+            CALL mppobc(vebnd,jpjed,jpjef,jpieob+1,jpk*3*3,2,jpj)
+            CALL mppobc(tebnd,jpjed,jpjef,jpieob+1,jpk*2*2,2,jpj)
+            CALL mppobc(sebnd,jpjed,jpjef,jpieob+1,jpk*2*2,2,jpj)
+         ENDIF
+         IF( lp_obc_west ) THEN
+            CALL mppobc(uwbnd,jpjwd,jpjwf,jpiwob,jpk*3*3,2,jpj)
+            CALL mppobc(vwbnd,jpjwd,jpjwf,jpiwob,jpk*3*3,2,jpj)
+            CALL mppobc(twbnd,jpjwd,jpjwf,jpiwob,jpk*2*2,2,jpj)
+            CALL mppobc(swbnd,jpjwd,jpjwf,jpiwob,jpk*2*2,2,jpj)
+         ENDIF
+         IF( lp_obc_north ) THEN 
+            CALL mppobc(unbnd,jpind,jpinf,jpjnob+1,jpk*3*3,1,jpi)
+            CALL mppobc(vnbnd,jpind,jpinf,jpjnob  ,jpk*3*3,1,jpi)
+            CALL mppobc(tnbnd,jpind,jpinf,jpjnob+1,jpk*2*2,1,jpi)
+            CALL mppobc(snbnd,jpind,jpinf,jpjnob+1,jpk*2*2,1,jpi)
+         ENDIF
+         IF( lp_obc_south ) THEN
+            CALL mppobc(usbnd,jpisd,jpisf,jpjsob,jpk*3*3,1,jpi)
+            CALL mppobc(vsbnd,jpisd,jpisf,jpjsob,jpk*3*3,1,jpi)
+            CALL mppobc(tsbnd,jpisd,jpisf,jpjsob,jpk*2*2,1,jpi)
+            CALL mppobc(ssbnd,jpisd,jpisf,jpjsob,jpk*2*2,1,jpi)
+         ENDIF
+      ENDIF
+ 
+   END SUBROUTINE obc_rst_read
+#else
+   !!=================================================================================
+   !!                       ***  MODULE  obcrst  ***
+   !! Ocean dynamic :  Input/Output files for restart on OBC
+   !!=================================================================================
+CONTAINS
+   SUBROUTINE obc_rst_write( kt )           !  No Open boundary ==> empty routine
+      INTEGER,INTENT(in) :: kt
+      WRITE(*,*) 'obc_rst_write: You should not have seen this print! error?', kt
+   END SUBROUTINE obc_rst_write
+   SUBROUTINE obc_rst_read                 !  No Open boundary ==> empty routine
+   END SUBROUTINE obc_rst_read
+#endif
+
+   !!=================================================================================
+END MODULE obcrst
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obctra.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obctra.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obctra.F90	(revision 1844)
@@ -0,0 +1,523 @@
+MODULE obctra
+   !!=================================================================================
+   !!                       ***  MODULE  obctra  ***
+   !! Ocean tracers:   Radiation of tracers on each open boundary
+   !!=================================================================================
+#if defined key_obc
+   !!---------------------------------------------------------------------------------
+   !!   'key_obc'      :                                      Open Boundary Conditions
+   !!---------------------------------------------------------------------------------
+   !!   obc_tra        : call the subroutine for each open boundary
+   !!   obc_tra_east   : radiation of the east open boundary tracers
+   !!   obc_tra_west   : radiation of the west open boundary tracers
+   !!   obc_tra_north  : radiation of the north open boundary tracers
+   !!   obc_tra_south  : radiation of the south open boundary tracers
+   !!----------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! ???
+   USE lbclnk          ! ???
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_tra     ! routine called in tranxt.F90 
+
+   !! * Module variables
+   INTEGER ::      & ! ... boundary space indices 
+      nib   = 1,   & ! nib   = boundary point
+      nibm  = 2,   & ! nibm  = 1st interior point
+      nibm2 = 3,   & ! nibm2 = 2nd interior point
+                     ! ... boundary time indices 
+      nit   = 1,   & ! nit    = now
+      nitm  = 2,   & ! nitm   = before
+      nitm2 = 3      ! nitm2  = before-before
+
+   REAL(wp) ::     &
+      rtaue  , rtauw  , rtaun  , rtaus  ,  &  ! Boundary restoring coefficient
+      rtauein, rtauwin, rtaunin, rtausin      ! Boundary restoring coefficient for inflow 
+
+   !! * Substitutions
+#  include "obc_vectopt_loop_substitute.h90"
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_tra( kt )
+      !!-------------------------------------------------------------------------------
+      !!                 ***  SUBROUTINE obc_tra  ***
+      !!                    
+      !! ** Purpose :   Compute tracer fields (t,s) along the open boundaries.
+      !!      This routine is called by the tranxt.F routine and updates ta,sa
+      !!      which are the actual temperature and salinity fields.
+      !!        The logical variable lp_obc_east, and/or lp_obc_west, and/or lp_obc_north,
+      !!      and/or lp_obc_south allow the user to determine which boundary is an
+      !!      open one (must be done in the param_obc.h90 file).
+      !!
+      !! Reference : 
+      !!   Marchesiello P., 1995, these de l'universite J. Fourier, Grenoble, France.
+      !!
+      !!  History :
+      !!        !  95-03 (J.-M. Molines) Original, SPEM
+      !!        !  97-07 (G. Madec, J.-M. Molines) addition
+      !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) F90
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+      !!----------------------------------------------------------------------
+
+      ! 0. Local constant initialization
+
+      IF( kt == nit000 .OR. ln_rstart) THEN
+         ! ... Boundary restoring coefficient
+         rtaue = 2. * rdt / rdpeob
+         rtauw = 2. * rdt / rdpwob
+         rtaun = 2. * rdt / rdpnob
+         rtaus = 2. * rdt / rdpsob
+         ! ... Boundary restoring coefficient for inflow ( all boundaries)
+         rtauein = 2. * rdt / rdpein 
+         rtauwin = 2. * rdt / rdpwin
+         rtaunin = 2. * rdt / rdpnin
+         rtausin = 2. * rdt / rdpsin 
+      END IF
+
+      IF( lp_obc_east  )   CALL obc_tra_east ( kt )    ! East open boundary
+
+      IF( lp_obc_west  )   CALL obc_tra_west ( kt )    ! West open boundary
+
+      IF( lp_obc_north )   CALL obc_tra_north( kt )    ! North open boundary
+
+      IF( lp_obc_south )   CALL obc_tra_south( kt )    ! South open boundary
+
+      IF( lk_mpp ) THEN                  !!bug ???
+         IF( kt >= nit000+3 .AND. ln_rstart ) THEN
+            CALL lbc_lnk( tb, 'T', 1. )
+            CALL lbc_lnk( sb, 'T', 1. )
+         END IF
+         CALL lbc_lnk( ta, 'T', 1. )
+         CALL lbc_lnk( sa, 'T', 1. )
+      ENDIF
+
+   END SUBROUTINE obc_tra
+
+
+   SUBROUTINE obc_tra_east ( kt )
+      !!------------------------------------------------------------------------------
+      !!                ***  SUBROUTINE obc_tra_east  ***
+      !!                  
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on east OBC tracers ta, sa using the 
+      !!      phase velocities calculated in obc_rad_east subroutine in obcrad.F90 module
+      !!      If the logical lfbceast is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbceast is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbceast ) THEN
+         DO ji = fs_nie0+1, fs_nie1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1. - temsk(jj,jk)) + &
+                                 tfoe(jj,jk)*temsk(jj,jk)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1. - temsk(jj,jk)) + &
+                                 sfoe(jj,jk)*temsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbceast is .FALSE.
+      ! -----------------------------------------------------
+
+         ! Temperature and salinity radiation
+         ! ----------------------------------
+         !
+         !            nibm2      nibm      nib
+         !              |   nibm  |   nib///|///
+         !              |    |    |    |////|///
+         !  jj   line --v----f----v----f----v---
+         !              |    |    |    |////|///
+         !                   |         |///   //
+         !  jj   line   T    u    T    u/// T //
+         !                   |         |///   //
+         !              |    |    |    |////|///
+         !  jj-1 line --v----f----v----f----v---
+         !              |    |    |    |////|///
+         !                jpieob-1    jpieob / ///
+         !              |         |         |
+         !           jpieob-1    jpieob     jpieob+1
+         !
+         ! ... radiative conditions + relaxation toward a climatology
+         !     the phase velocity is taken as the phase velocity of the tangen-
+         !     tial velocity (here vn), which have been saved in (u_cxebnd,v_cxebnd)
+         ! ... (jpjedp1, jpjefm1), jpieob+1
+         DO ji = fs_nie0+1, fs_nie1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... i-phase speed ratio (from averaged of v_cxebnd)
+                  z05cx = ( 0.5 * ( v_cxebnd(jj,jk) + v_cxebnd(jj-1,jk) ) ) / e1t(ji-1,jj)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaue
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtauein is used for relaxation coefficient else rtaue
+                  ztau = (1.-zin ) * rtauein  + zin * rtaue
+                  z05cx = z05cx * zin
+         ! ... update ( ta, sa ) with radiative or climatological (t, s)
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1. - temsk(jj,jk)) +           & 
+                                 temsk(jj,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * tebnd(jj,jk,nib ,nitm) + 2.*z05cx              &
+                                 * tebnd(jj,jk,nibm,nit ) + ztau * tfoe (jj,jk) ) &
+                                 / (1. + z05cx)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1. - temsk(jj,jk)) +           & 
+                                 temsk(jj,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * sebnd(jj,jk,nib ,nitm) + 2.*z05cx              &
+                                 * sebnd(jj,jk,nibm,nit ) + ztau * sfoe (jj,jk) ) &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_tra_east
+
+
+   SUBROUTINE obc_tra_west ( kt )
+      !!------------------------------------------------------------------------------
+      !!                 ***  SUBROUTINE obc_tra_west  ***
+      !!           
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on west OBC tracers ta, sa using the 
+      !!      phase velocities calculated in obc_rad_west subroutine in obcrad.F90 module
+      !!      If the logical lfbcwest is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcwest is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcwest ) THEN
+
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1. - twmsk(jj,jk)) + &
+                                 tfow(jj,jk)*twmsk(jj,jk)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1. - twmsk(jj,jk)) + &
+                                 sfow(jj,jk)*twmsk(jj,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcwest is .FALSE.
+      ! -----------------------------------------------------
+          
+         ! Temperature and salinity radiation
+         ! ----------------------------------
+         !
+         !          nib       nibm     nibm2
+         !     nib///|   nibm  |  nibm2  |
+         !   ///|////|    |    |    |    |   
+         !   ---v----f----v----f----v----f-- jj   line
+         !   ///|////|    |    |    |    |   
+         !   //   ///|         |         |   
+         !   // T ///u    T    u    T    u   jj   line
+         !   //   ///|         |         |   
+         !   ///|////|    |    |    |    |   
+         !   ---v----f----v----f----v----f-- jj-1 line
+         !   ///|////|    |    |    |    |   
+         !         jpiwob    jpiwob+1    jpiwob+2
+         !      |         |         |        
+         !    jpiwob    jpiwob+1   jpiwob+2
+         !
+         ! ... radiative conditions + relaxation toward a climatology
+         ! ... the phase velocity is taken as the phase velocity of the tangen-
+         ! ... tial velocity (here vn), which have been saved in (v_cxwbnd)
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+         ! ... i-phase speed ratio (from averaged of v_cxwbnd)
+                  z05cx = (  0.5 * ( v_cxwbnd(jj,jk) + v_cxwbnd(jj-1,jk) ) ) / e1t(ji+1,jj)
+                  z05cx = max( z05cx, -1. )
+         ! ... z05cx > 0, inflow  zin=0, ztau=1    
+         !           < 0, outflow zin=1, ztau=rtauw
+                  zin = sign( 1., -1.* z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin )*rtauwin + zin * rtauw
+                  z05cx = z05cx * zin
+         ! ... update (ta,sa) with radiative or climatological (t, s)
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1. - twmsk(jj,jk)) +           &
+                                 twmsk(jj,jk) * ( ( 1. + z05cx - ztau )         &
+                                 * twbnd(jj,jk,nib ,nitm) - 2.*z05cx              &
+                                 * twbnd(jj,jk,nibm,nit ) + ztau * tfow (jj,jk) ) &
+                                 / (1. - z05cx)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1. - twmsk(jj,jk)) +           &
+                                 twmsk(jj,jk) * ( ( 1. + z05cx - ztau )         &
+                                 * swbnd(jj,jk,nib ,nitm) - 2.*z05cx              &
+                                 * swbnd(jj,jk,nibm,nit ) + ztau * sfow (jj,jk) ) &
+                                 / (1. - z05cx)
+               END DO
+            END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_tra_west
+
+
+   SUBROUTINE obc_tra_north ( kt )
+      !!------------------------------------------------------------------------------
+      !!                 ***  SUBROUTINE obc_tra_north  ***
+      !!
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on north OBC tracers ta, sa using the 
+      !!      phase velocities calculated in obc_rad_north subroutine in obcrad.F90 module
+      !!      If the logical lfbcnorth is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M. Treguier) F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcnorth is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcnorth ) THEN
+
+         DO jj = fs_njn0+1, fs_njn1+1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  ta(ji,jj,jk)= ta(ji,jj,jk) * (1.-tnmsk(ji,jk)) + &
+                                tnmsk(ji,jk) * tfon(ji,jk)
+                  sa(ji,jj,jk)= sa(ji,jj,jk) * (1.-tnmsk(ji,jk)) + &
+                                tnmsk(ji,jk) * sfon(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcnorth is .FALSE.
+      ! -------------------------------------------------------
+          
+         ! Temperature and salinity radiation
+         ! ----------------------------------
+         !
+         !           ji-1   ji   ji   ji +1
+         !             |
+         !    nib //// u // T // u // T //   jpjnob + 1
+         !        /////|//////////////////
+         !    nib  ----f----v----f----v---   jpjnob
+         !             |         |       
+         !      nibm-- u -- T -- u -- T --   jpjnob
+         !             |         |            
+         !   nibm  ----f----v----f----v---  jpjnob-1
+         !             |         |      
+         !     nibm2-- u -- T -- T -- T --  jpjnob-1
+         !             |         |    
+         !   nibm2 ----f----v----f----v---  jpjnob-2
+         !             |         |
+         !
+         ! ... radiative conditions + relaxation toward a climatology
+         ! ... the phase velocity is taken as the normal phase velocity of the tangen-
+         ! ... tial velocity (here un), which has been saved in (u_cynbnd)
+         ! ... jpjnob+1,(jpindp1, jpinfm1)
+         DO jj = fs_njn0+1, fs_njn1+1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         ! ... j-phase speed ratio (from averaged of vtnbnd)
+         !        (bounded by 1)
+                  z05cx = ( 0.5 * ( u_cynbnd(ji,jk) + u_cynbnd(ji-1,jk) ) ) / e2t(ji,jj-1)
+                  z05cx = min( z05cx, 1. )
+         ! ... z05cx=< 0, inflow  zin=0, ztau=1    
+         !           > 0, outflow zin=1, ztau=rtaun
+                  zin = sign( 1., z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+         ! ... for inflow rtaunin is used for relaxation coefficient else rtaun
+                  ztau = (1.-zin ) * rtaunin + zin * rtaun
+                  z05cx = z05cx * zin
+         ! ... update (ta,sa) with radiative or climatological (t, s)
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1.-tnmsk(ji,jk)) +             &
+                                 tnmsk(ji,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * tnbnd(ji,jk,nib ,nitm) + 2.*z05cx              &
+                                 * tnbnd(ji,jk,nibm,nit ) + ztau * tfon (ji,jk) ) &
+                                 / (1. + z05cx)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1.-tnmsk(ji,jk)) +             &
+                                 tnmsk(ji,jk) * ( ( 1. - z05cx - ztau )         &
+                                 * snbnd(ji,jk,nib ,nitm) + 2.*z05cx              &
+                                 * snbnd(ji,jk,nibm,nit ) + ztau * sfon (ji,jk) ) &
+                                 / (1. + z05cx)
+               END DO
+            END DO
+         END DO
+
+      END IF
+
+   END SUBROUTINE obc_tra_north
+
+
+   SUBROUTINE obc_tra_south ( kt )
+      !!------------------------------------------------------------------------------
+      !!                ***  SUBROUTINE obc_tra_south  ***
+      !!     
+      !! ** Purpose :
+      !!      Apply the radiation algorithm on south OBC tracers ta, sa using the 
+      !!      phase velocities calculated in obc_rad_south subroutine in obcrad.F90 module
+      !!      If the logical lfbcsouth is .TRUE., there is no radiation but only fixed OBC
+      !!
+      !!  History :
+      !!         ! 95-03 (J.-M. Molines) Original from SPEM
+      !!         ! 97-07 (G. Madec, J.-M. Molines) additions
+      !!         ! 97-12 (M. Imbard) Mpp adaptation
+      !!         ! 00-06 (J.-M. Molines) 
+      !!    8.5  ! 02-10 (C. Talandier, A-M Treguier) F90
+      !!------------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt
+
+      !! * Local declaration
+      INTEGER ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   z05cx, ztau, zin
+      !!------------------------------------------------------------------------------
+
+      ! 1. First three time steps and more if lfbcsouth is .TRUE.
+      !    In that case open boundary conditions are FIXED.
+      ! --------------------------------------------------------
+
+      IF( ( kt < nit000+3 .AND. .NOT.ln_rstart ) .OR. lfbcsouth ) THEN
+
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  ta(ji,jj,jk)= ta(ji,jj,jk) * (1.-tsmsk(ji,jk)) + &
+                                tsmsk(ji,jk) * tfos(ji,jk)
+                  sa(ji,jj,jk)= sa(ji,jj,jk) * (1.-tsmsk(ji,jk)) + &
+                                tsmsk(ji,jk) * sfos(ji,jk)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+
+      ! 2. Beyond the fourth time step if lfbcsouth is .FALSE.
+      ! -------------------------------------------------------
+          
+         ! Temperature and salinity radiation
+         ! ----------------------------------
+         !
+         !           ji-1   ji   ji   ji +1
+         !             |         |
+         !   nibm2 ----f----v----f----v---   jpjsob+2
+         !             |         |       
+         !   nibm2 --  u -- T -- u -- T --   jpjsob+2
+         !             |         |            
+         !   nibm  ----f----v----f----v---   jpjsob+1
+         !             |         |      
+         !    nibm --  u -- T -- T -- T --   jpjsob+1
+         !             |         |    
+         !   nib  -----f----v----f----v---   jpjsob
+         !       //////|/////////|//////// 
+         !    nib //// u // T // u // T //   jpjsob 
+         !
+         !... radiative conditions + relaxation toward a climatology
+         !... the phase velocity is taken as the phase velocity of the tangen-
+         !... tial velocity (here un), which has been saved in (u_cysbnd)
+         !... jpjsob,(jpisdp1, jpisfm1)
+         DO jj = fs_njs0, fs_njs1  ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+         !... j-phase speed ratio (from averaged of u_cysbnd)
+         !       (bounded by 1)
+                  z05cx = ( 0.5 * ( u_cysbnd(ji,jk) + u_cysbnd(ji-1,jk) ) ) / e2t(ji,jj+1)
+                  z05cx = max( z05cx, -1. )
+         !... z05cx > 0, inflow  zin=0, ztau=1
+         !          < 0, outflow zin=1, ztau=rtaus
+                  zin = sign( 1., -1.* z05cx )
+                  zin = 0.5*( zin + abs(zin) )
+                  ztau = (1.-zin ) + zin * rtaus
+                  z05cx = z05cx * zin
+         !... update (ta,sa) with radiative or climatological (t, s)
+                  ta(ji,jj,jk) = ta(ji,jj,jk) * (1.-tsmsk(ji,jk)) +             &
+                                 tsmsk(ji,jk) * ( ( 1. + z05cx - ztau )         &
+                                 * tsbnd(ji,jk,nib ,nitm) - 2.*z05cx              &
+                                 * tsbnd(ji,jk,nibm,nit ) + ztau * tfos (ji,jk) ) &
+                                 / (1. - z05cx)
+                  sa(ji,jj,jk) = sa(ji,jj,jk) * (1.-tsmsk(ji,jk)) +             &
+                                 tsmsk(ji,jk) * (  ( 1. + z05cx - ztau )        &
+                                 * ssbnd(ji,jk,nib ,nitm) - 2.*z05cx              &
+                                 * ssbnd(ji,jk,nibm,nit ) + ztau * sfos (ji,jk) ) &
+                                 / (1. - z05cx)
+               END DO
+            END DO
+         END DO
+
+      END IF   
+
+   END SUBROUTINE obc_tra_south
+
+#else
+   !!---------------------------------------------------------------------------------
+   !!   Default option                                                    Empty module
+   !!---------------------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE obc_tra      ! Empty routine
+   END SUBROUTINE obc_tra
+#endif
+
+   !!=================================================================================
+END MODULE obctra
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcvol.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcvol.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/OBC/obcvol.F90	(revision 1844)
@@ -0,0 +1,288 @@
+MODULE obcvol
+   !!=================================================================================
+   !!                       ***  MODULE  obcvol  ***
+   !! Ocean dynamic :  Volume constraint when OBC and Free surface are used
+   !!=================================================================================
+#if   defined key_obc   &&   ! defined key_vvl
+   !!---------------------------------------------------------------------------------
+   !!   'key_obc'               and   NOT                 open boundary conditions
+   !!   'key_vvl'                                         constant volume free surface
+   !!---------------------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE sbc_oce         ! ocean surface boundary conditions
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lib_mpp         ! for mppsum
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC obc_vol        ! routine called by dynspg_flt
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "obc_vectopt_loop_substitute.h90"
+   !!---------------------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE obc_vol ( kt )
+      !!------------------------------------------------------------------------------
+      !!                      ***  ROUTINE obcvol  ***
+      !!
+      !! ** Purpose : 
+      !!      This routine is called in dynspg_flt to control 
+      !!      the volume of the system. A correction velocity is calculated
+      !!      to correct the total transport through the OBC. 
+      !!      The total depth used is constant (H0) to be consistent with the 
+      !!      linear free surface coded in OPA 8.2
+      !!
+      !! ** Method :  
+      !!      The correction velocity (zubtpecor here) is defined calculating
+      !!      the total transport through all open boundaries (trans_obc) minus
+      !!      the cumulate E-P flux (zCflxemp) divided by the total lateral 
+      !!      surface (obcsurftot) of these OBC. 
+      !!
+      !!      zubtpecor = [trans_obc - zCflxemp ]*(1./obcsurftot)
+      !!
+      !!      with zCflxemp => sum of (Evaporation minus Precipitation)
+      !!                       over all the domain in m3/s at each time step.
+      !!
+      !!      zCflxemp < 0 when precipitation dominate
+      !!      zCflxemp > 0 when evaporation dominate
+      !!
+      !!      There are 2 options (user's desiderata): 
+      !!
+      !!         1/ The volume changes according to E-P, this is the default
+      !!            option. In this case the cumulate E-P flux are setting to
+      !!            zero (zCflxemp=0) to calculate the correction velocity. So
+      !!            it will only balance the flux through open boundaries.
+      !!            (set volemp to 0 in tne namelist for this option)
+      !!
+      !!         2/ The volume is constant even with E-P flux. In this case
+      !!            the correction velocity must balance both the flux 
+      !!            through open boundaries and the ones through the free
+      !!            surface. 
+      !!            (set volemp to 1 in tne namelist for this option)
+      !!
+      !! History :
+      !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Original code
+      !!----------------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk
+      REAL(wp) ::   zubtpecor
+      REAL(wp) ::   zCflxemp
+      REAL(wp) ::   ztransw, ztranse, ztransn, ztranss, ztranst
+      !!-----------------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN 
+         IF(lwp) WRITE(numout,*)'        '
+         IF(lwp) WRITE(numout,*)'obc_vol : Correction of velocities along OBC'
+         IF(lwp) WRITE(numout,*)'~~~~~~~'
+         IF(lwp) WRITE(numout,*)'        '
+      END IF 
+
+      ! 1. Calculate the cumulate surface Flux zCflxemp (m3/s) over all the domain.
+      ! ---------------------------------------------------------------------------
+
+      zCflxemp = SUM ( emp(:,:)*obctmsk(:,:)* e1t(:,:) * e2t(:,:)  / rau0 )
+
+      IF( lk_mpp )   CALL mpp_sum( zCflxemp )   ! sum over the global domain
+
+      ! 2. Barotropic velocity for each open boundary
+      ! ---------------------------------------------
+
+      zubtpecor = 0.e0
+
+      ! ... East open boundary
+      IF( lp_obc_east ) THEN                      ! ... Total transport through the East OBC
+         DO ji = fs_nie0, fs_nie1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  zubtpecor = zubtpecor - ua(ji,jj,jk)*e2u(ji,jj)*fse3u(ji,jj,jk) * &
+             &     uemsk(jj,jk)*MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END DO
+      END IF 
+
+      ! ... West open boundary
+      IF( lp_obc_west ) THEN                      ! ... Total transport through the West OBC
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  zubtpecor = zubtpecor + ua(ji,jj,jk)*e2u(ji,jj)*fse3u(ji,jj,jk) * &
+             &    uwmsk(jj,jk) *MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END DO
+       ENDIF
+
+      ! ... North open boundary
+      IF( lp_obc_north ) THEN                     ! ... Total transport through the North OBC
+         DO jj = fs_njn0, fs_njn1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  zubtpecor = zubtpecor - va(ji,jj,jk)*e1v(ji,jj)*fse3v(ji,jj,jk) * &
+             &    vnmsk(ji,jk) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END DO
+       ENDIF
+
+      ! ... South open boundary
+      IF( lp_obc_south ) THEN                     ! ... Total transport through the South OBC
+         DO jj = fs_njs0, fs_njs1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  zubtpecor = zubtpecor + va(ji,jj,jk)*e1v(ji,jj)*fse3v(ji,jj,jk) * &
+             &    vsmsk(ji,jk) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END DO
+       ENDIF
+
+      IF( lk_mpp )   CALL mpp_sum( zubtpecor )   ! sum over the global domain
+
+
+      ! 3. The normal velocity correction
+      ! ---------------------------------
+      IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+         IF(lwp) WRITE(numout,*)'        '
+         IF(lwp) WRITE(numout,*)'obc_vol : time step :', kt
+         IF(lwp) WRITE(numout,*)'~~~~~~~ '
+         IF(lwp) WRITE(numout,*)'          cumulate flux EMP :', zCflxemp,' (m3/s)'
+         IF(lwp) WRITE(numout,*)'          lateral transport :',zubtpecor,'(m3/s)'
+         IF(lwp) WRITE(numout,*)'          net inflow        :',zubtpecor-zCflxemp,'(m3/s)'
+      ENDIF
+
+      zubtpecor = (zubtpecor - zCflxemp*volemp)*(1./obcsurftot)
+
+      IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+         IF(lwp) WRITE(numout,*)'          total lateral surface of OBC :',obcsurftot,'(m2)'
+         IF(lwp) WRITE(numout,*)'          correction velocity zubtpecor :',zubtpecor,'(m/s)'
+         IF(lwp) WRITE(numout,*)'        '
+      END IF 
+
+      ! 4. Correction of the total velocity on each open 
+      !    boundary to respect the mass flux conservation
+      ! -------------------------------------------------
+
+      ztranse = 0.e0   ; ztransw = 0.e0 ; ztransn = 0.e0 ; ztranss = 0.e0
+      ztranst = 0.e0  ! total
+
+      IF( lp_obc_west ) THEN
+         ! ... correction of the west velocity
+         DO ji = fs_niw0, fs_niw1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ua(ji,jj,jk) = ua(ji,jj,jk) - zubtpecor*uwmsk(jj,jk)
+                  ztransw= ztransw + ua(ji,jj,jk)*fse3u(ji,jj,jk)*e2u(ji,jj)*uwmsk(jj,jk) * &
+             &    MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END DO
+
+         IF( lk_mpp )   CALL mpp_sum( ztransw )   ! sum over the global domain
+
+         IF( lwp .AND. MOD( kt, nwrite ) == 0)  WRITE(numout,*)'          West OB transport ztransw :', ztransw,'(m3/s)'
+      END IF 
+
+      IF( lp_obc_east ) THEN
+
+         ! ... correction of the east velocity
+         DO ji = fs_nie0, fs_nie1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  ua(ji,jj,jk) = ua(ji,jj,jk) + zubtpecor*uemsk(jj,jk)
+                  ztranse= ztranse + ua(ji,jj,jk)*fse3u(ji,jj,jk)*e2u(ji,jj)*uemsk(jj,jk) * &
+            &     MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) )
+               END DO
+            END DO
+         END DO
+
+         IF( lk_mpp )   CALL mpp_sum( ztranse )   ! sum over the global domain
+
+         IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+            IF(lwp) WRITE(numout,*)'          East OB transport ztranse :', ztranse,'(m3/s)'
+         END IF 
+
+      END IF 
+
+      IF( lp_obc_north ) THEN
+
+         ! ... correction of the north velocity
+         DO jj = fs_njn0, fs_njn1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji =  1, jpi
+                  va(ji,jj,jk) = va(ji,jj,jk) + zubtpecor*vnmsk(ji,jk)
+                  ztransn= ztransn + va(ji,jj,jk)*fse3v(ji,jj,jk)*e1v(ji,jj)*vnmsk(ji,jk) * &
+           &      MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztransn )   ! sum over the global domain
+
+         IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+            IF(lwp) WRITE(numout,*)'          North OB transport ztransn :', ztransn,'(m3/s)'
+         END IF 
+
+      END IF 
+
+      IF( lp_obc_south ) THEN
+
+         ! ... correction of the south velocity
+         DO jj = fs_njs0, fs_njs1 ! Vector opt.
+            DO jk = 1, jpkm1
+               DO ji =  1, jpi
+                  va(ji,jj,jk) = va(ji,jj,jk) - zubtpecor*vsmsk(ji,jk)
+                  ztranss= ztranss + va(ji,jj,jk)*fse3v(ji,jj,jk)*e1v(ji,jj)*vsmsk(ji,jk) * &
+            &     MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) )
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztranss )   ! sum over the global domain
+
+         IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+            IF(lwp) WRITE(numout,*)'          South OB transport ztranss :', ztranss,'(m3/s)'
+         END IF 
+
+      END IF 
+
+      ! 5. Check the cumulate transport through OBC
+      !    once barotropic velocities corrected
+      ! -------------------------------------------
+
+
+      IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
+         ztranst = ztransw - ztranse + ztranss - ztransn
+         IF(lwp) WRITE(numout,*)'        '
+         IF(lwp) WRITE(numout,*)'          Cumulate transport ztranst =', ztranst,'(m3/s)'
+         IF(lwp) WRITE(numout,*)'          Balance  =', ztranst - zCflxemp ,'(m3/s)'
+         IF(lwp) WRITE(numout,*)'        '
+      END IF 
+
+   END SUBROUTINE obc_vol
+
+#else
+   !!---------------------------------------------------------------------------------
+   !!  Default option :                                                   Empty module
+   !!---------------------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE obc_vol        ! Empty routine
+   END SUBROUTINE obc_vol
+#endif
+
+   !!=================================================================================
+END MODULE obcvol
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/albedo.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/albedo.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/albedo.F90	(revision 1844)
@@ -0,0 +1,212 @@
+MODULE albedo
+   !!======================================================================
+   !!                       ***  MODULE  albedo  ***
+   !! Ocean forcing:  bulk thermohaline forcing of the ocean (or ice)
+   !!=====================================================================
+   !! History :  8.0  ! 2001-04  (LIM 1.0)
+   !!   NEMO     1.0  ! 2003-07  (C. Ethe, G. Madec)  Optimization (old name:shine)
+   !!             -   ! 2004-11  (C. Talandier)  add albedo_init
+   !!             -   ! 2001-06  (M. Vancoppenolle) LIM 3.0
+   !!             -   ! 2006-08  (G. Madec)  cleaning for surface module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   albedo_ice  : albedo for   ice (clear and overcast skies)
+   !!   albedo_oce  : albedo for ocean (clear and overcast skies)
+   !!   albedo_init : initialisation of albedo computation
+   !!----------------------------------------------------------------------
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   albedo_ice   ! routine called sbcice_lim.F90
+   PUBLIC   albedo_oce   ! routine called by ???
+
+   INTEGER  ::   albd_init = 0      !: control flag for initialization
+   REAL(wp) ::   zzero     = 0.e0   ! constant values
+   REAL(wp) ::   zone      = 1.e0   !    "       "
+
+   REAL(wp) ::   c1     = 0.05    ! constants values
+   REAL(wp) ::   c2     = 0.10    !    "        "
+   REAL(wp) ::   rmue   = 0.40    !  cosine of local solar altitude
+
+   !                               !!* namelist namsbc_alb
+   REAL(wp) ::   rn_cloud  = 0.06   !  cloudiness effect on snow or ice albedo (Grenfell & Perovich, 1984)
+#if defined key_lim3
+   REAL(wp) ::   rn_albice = 0.53   !  albedo of melting ice in the arctic and antarctic (Shine & Hendersson-Sellers)
+#else
+   REAL(wp) ::   rn_albice = 0.50   !  albedo of melting ice in the arctic and antarctic (Shine & Hendersson-Sellers)
+#endif
+   REAL(wp) ::   rn_alphd  = 0.80   !  coefficients for linear interpolation used to compute
+   REAL(wp) ::   rn_alphdi = 0.72   !  albedo between two extremes values (Pyane, 1972)
+   REAL(wp) ::   rn_alphc  = 0.65   ! 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 9.0 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE albedo_ice( pt_ice, ph_ice, ph_snw, pa_ice_cs, pa_ice_os )
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE albedo_ice  ***
+      !!          
+      !! ** Purpose :   Computation of the albedo of the snow/ice system 
+      !!                as well as the ocean one
+      !!       
+      !! ** Method  : - Computation of the albedo of snow or ice (choose the 
+      !!                rignt one by a large number of tests
+      !!              - Computation of the albedo of the ocean
+      !!
+      !! References :   Shine and Hendersson-Sellers 1985, JGR, 90(D1), 2243-2250.
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pt_ice      !  ice surface temperature (Kelvin)
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   ph_ice      !  sea-ice thickness
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   ph_snw      !  snow thickness
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pa_ice_cs   !  albedo of ice under clear    sky
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pa_ice_os   !  albedo of ice under overcast sky
+      !!
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
+      INTEGER  ::   ijpl          ! number of ice categories (3rd dim of ice input arrays)
+      REAL(wp) ::   zalbpsnm      ! albedo of ice under clear sky when snow is melting
+      REAL(wp) ::   zalbpsnf      ! albedo of ice under clear sky when snow is freezing
+      REAL(wp) ::   zalbpsn       ! albedo of snow/ice system when ice is coverd by snow
+      REAL(wp) ::   zalbpic       ! albedo of snow/ice system when ice is free of snow
+      REAL(wp) ::   zithsn        ! = 1 for hsn >= 0 ( ice is cov. by snow ) ; = 0 otherwise (ice is free of snow)
+      REAL(wp) ::   zitmlsn       ! = 1 freezinz snow (pt_ice >=rt0_snow) ; = 0 melting snow (pt_ice<rt0_snow)
+      REAL(wp) ::   zihsc1        ! = 1 hsn <= c1 ; = 0 hsn > c1
+      REAL(wp) ::   zihsc2        ! = 1 hsn >= c2 ; = 0 hsn < c2
+      !!
+      LOGICAL , DIMENSION(jpi,jpj,SIZE(pt_ice,3)) ::   llmask
+      REAL(wp), DIMENSION(jpi,jpj,SIZE(pt_ice,3)) ::   zalbfz    ! = rn_alphdi for freezing ice ; = rn_albice for melting ice
+      REAL(wp), DIMENSION(jpi,jpj,SIZE(pt_ice,3)) ::   zficeth   !  function of ice thickness
+      !!---------------------------------------------------------------------
+      
+      ijpl = SIZE( pt_ice, 3 )                     ! number of ice categories
+
+      IF( albd_init == 0 )   CALL albedo_init      ! initialization 
+
+      !---------------------------
+      !  Computation of  zficeth
+      !---------------------------
+      llmask = ( ph_snw == 0.e0 ) .AND. ( pt_ice >= rt0_ice )
+      ! ice free of snow and melts
+      WHERE( llmask )   ;   zalbfz = rn_albice
+      ELSEWHERE         ;   zalbfz = rn_alphdi
+      END WHERE
+
+      DO jl = 1, ijpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( ph_ice(ji,jj,jl) > 1.5 ) THEN
+                  zficeth(ji,jj,jl) = zalbfz(ji,jj,jl)
+               ELSEIF( ph_ice(ji,jj,jl) > 1.0  .AND. ph_ice(ji,jj,jl) <= 1.5 ) THEN
+                  zficeth(ji,jj,jl) = 0.472 + 2.0 * ( zalbfz(ji,jj,jl) - 0.472 ) * ( ph_ice(ji,jj,jl) - 1.0 )
+               ELSEIF( ph_ice(ji,jj,jl) > 0.05 .AND. ph_ice(ji,jj,jl) <= 1.0 ) THEN
+                  zficeth(ji,jj,jl) = 0.2467 + 0.7049 * ph_ice(ji,jj,jl)                               &
+                     &                    - 0.8608 * ph_ice(ji,jj,jl) * ph_ice(ji,jj,jl)                 &
+                     &                    + 0.3812 * ph_ice(ji,jj,jl) * ph_ice(ji,jj,jl) * ph_ice (ji,jj,jl)
+               ELSE
+                  zficeth(ji,jj,jl) = 0.1 + 3.6 * ph_ice(ji,jj,jl) 
+               ENDIF
+            END DO
+         END DO
+      END DO
+      
+      !----------------------------------------------- 
+      !    Computation of the snow/ice albedo system 
+      !-------------------------- ---------------------
+      
+      !    Albedo of snow-ice for clear sky.
+      !-----------------------------------------------    
+      DO jl = 1, ijpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !  Case of ice covered by snow.             
+               !                                        !  freezing snow        
+               zihsc1   = 1.0 - MAX( zzero , SIGN( zone , - ( ph_snw(ji,jj,jl) - c1 ) ) )
+               zalbpsnf = ( 1.0 - zihsc1 ) * (  zficeth(ji,jj,jl)                                             &
+                  &                           + ph_snw(ji,jj,jl) * ( rn_alphd - zficeth(ji,jj,jl) ) / c1  )   &
+                  &     +         zihsc1   * rn_alphd  
+               !                                        !  melting snow                
+               zihsc2   = MAX( zzero , SIGN( zone , ph_snw(ji,jj,jl) - c2 ) )
+               zalbpsnm = ( 1.0 - zihsc2 ) * ( rn_albice + ph_snw(ji,jj,jl) * ( rn_alphc - rn_albice ) / c2 )   &
+                  &     +         zihsc2   *   rn_alphc 
+               !
+               zitmlsn  =  MAX( zzero , SIGN( zone , pt_ice(ji,jj,jl) - rt0_snow ) )   
+               zalbpsn  =  zitmlsn * zalbpsnm + ( 1.0 - zitmlsn ) * zalbpsnf
+            
+               !  Case of ice free of snow.
+               zalbpic  = zficeth(ji,jj,jl) 
+            
+               ! albedo of the system   
+               zithsn   = 1.0 - MAX( zzero , SIGN( zone , - ph_snw(ji,jj,jl) ) )
+               pa_ice_cs(ji,jj,jl) =  zithsn * zalbpsn + ( 1.0 - zithsn ) *  zalbpic
+            END DO
+         END DO
+      END DO
+      
+      !    Albedo of snow-ice for overcast sky.
+      !----------------------------------------------  
+      pa_ice_os(:,:,:) = pa_ice_cs(:,:,:) + rn_cloud       ! Oberhuber correction
+      !
+   END SUBROUTINE albedo_ice
+
+
+   SUBROUTINE albedo_oce( pa_oce_os , pa_oce_cs )
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE albedo_oce  ***
+      !! 
+      !! ** Purpose :   Computation of the albedo of the ocean
+      !!
+      !! ** Method  :   ....
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(out) ::   pa_oce_os   !  albedo of ocean under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(out) ::   pa_oce_cs   !  albedo of ocean under clear sky
+      !!
+      REAL(wp) ::   zcoef   ! temporary scalar
+      !!----------------------------------------------------------------------
+      !
+      zcoef = 0.05 / ( 1.1 * rmue**1.4 + 0.15 )      ! Parameterization of Briegled and Ramanathan, 1982 
+      pa_oce_cs(:,:) = zcoef               
+      pa_oce_os(:,:)  = 0.06                         ! Parameterization of Kondratyev, 1969 and Payne, 1972
+      !
+   END SUBROUTINE albedo_oce
+
+
+   SUBROUTINE albedo_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE albedo_init  ***
+      !!
+      !! ** Purpose :   initializations for the albedo parameters
+      !!
+      !! ** Method  :   Read the namelist namsbc_alb
+      !!----------------------------------------------------------------------
+      NAMELIST/namsbc_alb/ rn_cloud, rn_albice, rn_alphd, rn_alphdi, rn_alphc
+      !!----------------------------------------------------------------------
+      !
+      albd_init = 1                     ! indicate that the initialization has been done
+      !
+      REWIND( numnam )                  ! Read Namelist namsbc_alb : albedo parameters
+      READ  ( numnam, namsbc_alb )
+      !
+      IF(lwp) THEN                      ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'albedo : set albedo parameters'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namsbc_alb : albedo '
+         WRITE(numout,*) '      correction for snow and ice albedo                  rn_cloud  = ', rn_cloud
+         WRITE(numout,*) '      albedo of melting ice in the arctic and antarctic   rn_albice = ', rn_albice
+         WRITE(numout,*) '      coefficients for linear                             rn_alphd  = ', rn_alphd
+         WRITE(numout,*) '      interpolation used to compute albedo                rn_alphdi = ', rn_alphdi
+         WRITE(numout,*) '      between two extremes values (Pyane, 1972)           rn_alphc  = ', rn_alphc
+      ENDIF
+      !
+   END SUBROUTINE albedo_init
+
+   !!======================================================================
+END MODULE albedo
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 1844)
@@ -0,0 +1,338 @@
+MODULE cpl_oasis3
+   !!======================================================================
+   !!                    ***  MODULE cpl_oasis  ***
+   !! Coupled O/A : coupled ocean-atmosphere case using OASIS3 V. prism_2_4
+   !!               special case: NEMO OPA/LIM coupled to ECHAM5
+   !!=====================================================================
+   !! History :   
+   !!   9.0  !  04-06  (R. Redler, NEC Laboratories Europe, St Augustin, Germany) Original code
+   !!   " "  !  04-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Kiel, Germany) revision
+   !!   " "  !  04-11  (V. Gayler, MPI M&D) Grid writing
+   !!   " "  !  05-08  (R. Redler, W. Park) frld initialization, paral(2) revision
+   !!   " "  !  05-09  (R. Redler) extended to allow for communication over root only
+   !!   " "  !  06-01  (W. Park) modification of physical part
+   !!   " "  !  06-02  (R. Redler, W. Park) buffer array fix for root exchange
+   !!----------------------------------------------------------------------
+#if defined key_oasis3
+   !!----------------------------------------------------------------------
+   !!   'key_oasis3'                    coupled Ocean/Atmosphere via OASIS3
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   cpl_prism_init     : initialization of coupled mode communication
+   !!   cpl_prism_define   : definition of grid and fields
+   !!   cpl_prism_snd     : snd out fields in coupled mode
+   !!   cpl_prism_rcv     : receive fields in coupled mode
+   !!   cpl_prism_finalize : finalize the coupled mode communication
+   !!----------------------------------------------------------------------
+   USE mod_prism_proto              ! OASIS3 prism module
+   USE mod_prism_def_partition_proto! OASIS3 prism module for partitioning
+   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grid files
+   USE mod_prism_put_proto          ! OASIS3 prism module for snding
+   USE mod_prism_get_proto          ! OASIS3 prism module for receiving
+   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grids
+   USE par_oce                      ! ocean parameters
+   USE dom_oce                      ! ocean space and time domain
+   USE in_out_manager               ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   IMPLICIT NONE
+   PRIVATE
+!
+   LOGICAL, PUBLIC, PARAMETER :: lk_cpl = .TRUE.   ! coupled flag
+   INTEGER, PUBLIC            :: OASIS_Rcv  = 1    ! return code if received field
+   INTEGER, PUBLIC            :: OASIS_idle = 0    ! return code if nothing done by oasis
+   INTEGER                    :: ncomp_id          ! id returned by prism_init_comp
+   INTEGER                    :: nerror            ! return error code
+
+   INTEGER, PARAMETER :: nmaxfld=40    ! Maximum number of coupling fields
+   
+   TYPE, PUBLIC ::   FLD_CPL            ! Type for coupling field information
+      LOGICAL            ::   laction   ! To be coupled or not
+      CHARACTER(len = 8) ::   clname    ! Name of the coupling field   
+      CHARACTER(len = 1) ::   clgrid    ! Grid type  
+      REAL(wp)           ::   nsgn      ! Control of the sign change
+      INTEGER            ::   nid       ! Id of the field
+   END TYPE FLD_CPL
+
+   TYPE(FLD_CPL), DIMENSION(nmaxfld), PUBLIC :: srcv, ssnd   ! Coupling fields
+
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE :: exfld  ! Temporary buffer for receiving
+
+   !! Routine accessibility
+   PUBLIC cpl_prism_init
+   PUBLIC cpl_prism_define
+   PUBLIC cpl_prism_snd
+   PUBLIC cpl_prism_rcv
+   PUBLIC cpl_prism_finalize
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Header$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE cpl_prism_init (kl_comm) 
+
+      !!-------------------------------------------------------------------
+      !!             ***  ROUTINE cpl_prism_init  ***
+      !!
+      !! ** Purpose :   Initialize coupled mode communication for ocean
+      !!    exchange between AGCM, OGCM and COUPLER. (OASIS3 software)
+      !!
+      !! ** Method  :   OASIS3 MPI communication 
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(   OUT )   :: kl_comm       ! local communicator of the model
+      !!--------------------------------------------------------------------
+
+      ! WARNING: No write in numout in this routine
+      !============================================
+
+      !------------------------------------------------------------------
+      ! 1st Initialize the PRISM system for the application
+      !------------------------------------------------------------------
+      CALL prism_init_comp_proto ( ncomp_id, 'oceanx', nerror )
+      IF ( nerror /= PRISM_Ok ) &
+         CALL prism_abort_proto (ncomp_id, 'cpl_prism_init', 'Failure in prism_init_comp_proto')
+
+      !------------------------------------------------------------------
+      ! 3rd Get an MPI communicator for OPA local communication
+      !------------------------------------------------------------------
+
+      CALL prism_get_localcomm_proto ( kl_comm, nerror )
+      IF ( nerror /= PRISM_Ok ) &
+         CALL prism_abort_proto (ncomp_id, 'cpl_prism_init','Failure in prism_get_localcomm_proto' )
+
+   END SUBROUTINE cpl_prism_init
+
+
+   SUBROUTINE cpl_prism_define (krcv, ksnd)
+
+      !!-------------------------------------------------------------------
+      !!             ***  ROUTINE cpl_prism_define  ***
+      !!
+      !! ** Purpose :   Define grid and field information for ocean
+      !!    exchange between AGCM, OGCM and COUPLER. (OASIS3 software)
+      !!
+      !! ** Method  :   OASIS3 MPI communication 
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT( IN    )   :: krcv, ksnd     ! Number of received and sent coupling fields
+      !
+      INTEGER                    :: id_part
+      INTEGER                    :: paral(5)       ! OASIS3 box partition
+      INTEGER                    :: ishape(2,2)    ! shape of arrays passed to PSMILe
+      INTEGER                    :: ji             ! local loop indicees
+      !!
+      !!--------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cpl_prism_define : initialization in coupled ocean/atmosphere case'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*)
+
+      !
+      ! ... Define the shape for the area that excludes the halo
+      !     For serial configuration (key_mpp_mpi not being active)
+      !     nl* is set to the global values 1 and jp*glo.
+      !
+      ishape(:,1) = (/ 1, nlei-nldi+1 /)
+      ishape(:,2) = (/ 1, nlej-nldj+1 /)
+      !
+      ! ... Allocate memory for data exchange
+      !
+      ALLOCATE(exfld(nlei-nldi+1, nlej-nldj+1), stat = nerror)
+      IF (nerror > 0) THEN
+         CALL prism_abort_proto ( ncomp_id, 'cpl_prism_define', 'Failure in allocating exfld')
+         RETURN
+      ENDIF
+      !
+      ! -----------------------------------------------------------------
+      ! ... Define the partition 
+      ! -----------------------------------------------------------------
+      
+      paral(1) = 2                                              ! box partitioning
+      paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset    
+      paral(3) = nlei-nldi+1                                    ! local extent in i 
+      paral(4) = nlej-nldj+1                                    ! local extent in j
+      paral(5) = jpiglo                                         ! global extent in x
+      
+      IF( ln_ctl ) THEN
+         WRITE(numout,*) ' multiexchg: paral (1:5)', paral
+         WRITE(numout,*) ' multiexchg: jpi, jpj =', jpi, jpj
+         WRITE(numout,*) ' multiexchg: nldi, nlei, nimpp =', nldi, nlei, nimpp
+         WRITE(numout,*) ' multiexchg: nldj, nlej, njmpp =', nldj, nlej, njmpp
+      ENDIF
+      
+      CALL prism_def_partition_proto ( id_part, paral, nerror )
+      !
+      ! ... Announce send variables. 
+      !
+      DO ji = 1, ksnd
+         IF ( ssnd(ji)%laction ) THEN 
+            CALL prism_def_var_proto (ssnd(ji)%nid, ssnd(ji)%clname, id_part, (/ 2, 0/),  &
+               &                      PRISM_Out   , ishape   , PRISM_REAL, nerror)
+            IF ( nerror /= PRISM_Ok ) THEN
+               WRITE(numout,*) 'Failed to define transient ', ji, TRIM(ssnd(ji)%clname)
+               CALL prism_abort_proto ( ssnd(ji)%nid, 'cpl_prism_define', 'Failure in prism_def_var')
+            ENDIF
+         ENDIF
+      END DO
+      !
+      ! ... Announce received variables. 
+      !
+      DO ji = 1, krcv
+         IF ( srcv(ji)%laction ) THEN 
+            CALL prism_def_var_proto ( srcv(ji)%nid, srcv(ji)%clname, id_part, (/ 2, 0/),   &
+               &                      PRISM_In    , ishape   , PRISM_REAL, nerror)
+            IF ( nerror /= PRISM_Ok ) THEN
+               WRITE(numout,*) 'Failed to define transient ', ji, TRIM(srcv(ji)%clname)
+               CALL prism_abort_proto ( srcv(ji)%nid, 'cpl_prism_define', 'Failure in prism_def_var')
+            ENDIF
+         ENDIF
+      END DO
+      
+      !------------------------------------------------------------------
+      ! End of definition phase
+      !------------------------------------------------------------------
+      
+      CALL prism_enddef_proto(nerror)
+      IF ( nerror /= PRISM_Ok )   CALL prism_abort_proto ( ncomp_id, 'cpl_prism_define', 'Failure in prism_enddef')
+      
+   END SUBROUTINE cpl_prism_define
+   
+   
+   SUBROUTINE cpl_prism_snd( kid, kstep, pdata, kinfo )
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_snd  ***
+      !!
+      !! ** Purpose : - At each coupling time-step,this routine sends fields
+      !!      like sst or ice cover to the coupler or remote application.
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      !!
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT(   OUT )   :: kinfo     ! OASIS3 info argument
+      INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    )   :: pdata
+      !!
+      !!
+      !!--------------------------------------------------------------------
+      !
+      ! snd data to OASIS3
+      !
+      CALL prism_put_proto ( ssnd(kid)%nid, kstep, pdata(nldi:nlei, nldj:nlej), kinfo )
+      
+      IF ( ln_ctl ) THEN        
+         IF ( kinfo == PRISM_Sent     .OR. kinfo == PRISM_ToRest .OR.   &
+            & kinfo == PRISM_SentOut  .OR. kinfo == PRISM_ToRestOut ) THEN
+            WRITE(numout,*) '****************'
+            WRITE(numout,*) 'prism_put_proto: Outgoing ', ssnd(kid)%clname
+            WRITE(numout,*) 'prism_put_proto: ivarid ', ssnd(kid)%nid
+            WRITE(numout,*) 'prism_put_proto:  kstep ', kstep
+            WRITE(numout,*) 'prism_put_proto:   info ', kinfo
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata)
+            WRITE(numout,*) '     -     Sum value is ', SUM(pdata)
+            WRITE(numout,*) '****************'
+        ENDIF
+     ENDIF
+    END SUBROUTINE cpl_prism_snd
+
+
+   SUBROUTINE cpl_prism_rcv( kid, kstep, pdata, kinfo )
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_rcv  ***
+      !!
+      !! ** Purpose : - At each coupling time-step,this routine receives fields
+      !!      like stresses and fluxes from the coupler or remote application.
+      !!----------------------------------------------------------------------
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( INOUT )   :: pdata     ! IN to keep the value if nothing is done
+      INTEGER,                      INTENT(   OUT )   :: kinfo     ! OASIS3 info argument
+      !!
+      LOGICAL                :: llaction
+      !!--------------------------------------------------------------------
+      !
+      ! receive local data from OASIS3 on every process
+      !
+      CALL prism_get_proto ( srcv(kid)%nid, kstep, exfld, kinfo )         
+
+      llaction = .false.
+      IF( kinfo == PRISM_Recvd   .OR. kinfo == PRISM_FromRest .OR.   &
+          kinfo == PRISM_RecvOut .OR. kinfo == PRISM_FromRestOut )   llaction = .TRUE.
+
+      IF ( ln_ctl )   WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid
+
+      IF ( llaction ) THEN
+
+         kinfo = OASIS_Rcv
+         pdata(nldi:nlei, nldj:nlej) = exfld(:,:)
+         
+         !--- Fill the overlap areas and extra hallows (mpp)
+         !--- check periodicity conditions (all cases)
+         CALL lbc_lnk( pdata, srcv(kid)%clgrid, srcv(kid)%nsgn )   
+         
+         IF ( ln_ctl ) THEN        
+            WRITE(numout,*) '****************'
+            WRITE(numout,*) 'prism_get_proto: Incoming ', srcv(kid)%clname
+            WRITE(numout,*) 'prism_get_proto: ivarid '  , srcv(kid)%nid
+            WRITE(numout,*) 'prism_get_proto:   kstep', kstep
+            WRITE(numout,*) 'prism_get_proto:   info ', kinfo
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata)
+            WRITE(numout,*) '     -     Sum value is ', SUM(pdata)
+            WRITE(numout,*) '****************'
+         ENDIF
+      
+      ELSE
+         kinfo = OASIS_idle     
+      ENDIF
+
+   END SUBROUTINE cpl_prism_rcv
+
+
+   SUBROUTINE cpl_prism_finalize
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_finalize  ***
+      !!
+      !! ** Purpose : - Finalizes the coupling. If MPI_init has not been
+      !!      called explicitly before cpl_prism_init it will also close
+      !!      MPI communication.
+      !!----------------------------------------------------------------------
+
+      DEALLOCATE(exfld)
+      CALL prism_terminate_proto ( nerror )         
+
+   END SUBROUTINE cpl_prism_finalize
+
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default case                                Forced Ocean/Atmosphere
+   !!----------------------------------------------------------------------
+   !!   Empty module
+   !!----------------------------------------------------------------------
+   USE in_out_manager               ! I/O manager
+   LOGICAL, PUBLIC, PARAMETER :: lk_cpl = .FALSE.   !: coupled flag
+   PUBLIC cpl_prism_init
+   PUBLIC cpl_prism_finalize
+
+CONTAINS
+
+   SUBROUTINE cpl_prism_init (kl_comm) 
+      INTEGER, INTENT(   OUT )   :: kl_comm       ! local communicator of the model
+      kl_comm = -1
+      WRITE(numout,*) 'cpl_prism_init: Error you sould not be there...'
+   END SUBROUTINE cpl_prism_init
+
+   SUBROUTINE cpl_prism_finalize
+      WRITE(numout,*) 'cpl_prism_finalize: Error you sould not be there...'
+   END SUBROUTINE cpl_prism_finalize
+
+#endif
+
+END MODULE cpl_oasis3
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis4.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis4.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/cpl_oasis4.F90	(revision 1844)
@@ -0,0 +1,1214 @@
+MODULE cpl_oasis4
+   !!======================================================================
+   !!                    ***  MODULE cpl_oasis4  ***
+   !! Coupled O/A : coupled ocean-atmosphere case using OASIS4
+   !!               special case: OPA/LIM coupled to ECHAM5
+   !!=====================================================================
+   !! History :   
+   !!   9.0  !  04-06  (R. Redler, NEC Laboratories Europe, St Augustin, Germany) Original code
+   !!   " "  !  04-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Kiel, Germany) revision
+   !!   " "  !  04-11  (V. Gayler, MPI M&D) Grid writing
+   !!   " "  !  05-08  (R. Redler, W. Park) frld initialization, paral(2) revision
+   !!   " "  !  05-09  (R. Redler) extended to allow for communication over root only
+   !!   " "  !  05-09  (R. Redler) extended to allow for communication over root only
+   !!   " "  !  05-12  (R. Hill, Met. Office) Tweaks and hacks to get NEMO/O4 working
+   !!   " "  !  06-02  (R. Redler, W. Park) Bug fixes and updates according to the OASIS3 interface
+   !!   " "  !  06-02  (R. Redler) app/grid/grid_name from namelist
+   !!----------------------------------------------------------------------
+#if defined key_oasis4
+   !!----------------------------------------------------------------------
+   !!   'key_oasis4'                    coupled Ocean/Atmosphere via OASIS4
+   !!----------------------------------------------------------------------
+   !!   cpl_prism_init     : initialization of coupled mode communication
+   !!   cpl_prism_define   : definition of grid and fields
+   !!   cpl_prism_send     : send out fields in coupled mode
+   !!   cpl_prism_recv     : receive fields in coupled mode
+   !!   cpl_prism_finalize : finalize the coupled mode communication
+   !!----------------------------------------------------------------------
+   !! * Modules used
+!##################### WARNING coupled mode ###############################
+!##################### WARNING coupled mode ###############################
+!   Following line must be enabled if coupling with OASIS
+!   USE prism                        ! prism module
+!##################### WARNING coupled mode ###############################
+!##################### WARNING coupled mode ###############################
+#if defined key_mpp_mpi
+   USE lib_mpp, only : mppsize, mpprank   ! message passing
+   USE lib_mpp, only : mppsend            ! message passing
+   USE lib_mpp, only : mpprecv            ! message passing
+#endif
+   USE dom_oce                      ! ocean space and time domain
+   USE in_out_manager               ! I/O manager
+   USE par_oce                      !
+   USE phycst, only : rt0           ! freezing point of sea water
+   USE oasis4_date                  ! OASIS4 date declarations in
+                                    ! PRISM compatible format
+   IMPLICIT NONE
+!
+! Exchange parameters for coupling ORCA-LIM with ECHAM5
+!
+#if defined key_cpl_ocevel
+   INTEGER, PARAMETER         :: nsend =  6
+#else
+   INTEGER, PARAMETER         :: nsend =  4
+#endif
+
+#if defined key_cpl_discharge
+   INTEGER, PARAMETER         :: nrecv = 20
+#else
+   INTEGER, PARAMETER         :: nrecv = 17
+#endif
+
+   INTEGER, DIMENSION(nsend)  :: send_id
+   INTEGER, DIMENSION(nrecv)  :: recv_id
+
+   CHARACTER(len=32)          :: cpl_send (nsend)
+   CHARACTER(len=32)          :: cpl_recv (nrecv)
+
+   CHARACTER(len=16)          :: app_name       ! application name for OASIS use
+   CHARACTER(len=16)          :: comp_name      ! name of this PRISM component
+   CHARACTER(len=16)          :: grid_name      ! name of the grid
+   CHARACTER(len=1)           :: c_mpi_send
+
+! The following now come in via new module oasis4_date
+!   TYPE(PRISM_Time_struct), PUBLIC    :: dates          ! date info for send operation
+!   TYPE(PRISM_Time_struct), PUBLIC    :: dates_bound(2) ! date info for send operation
+!   TYPE(PRISM_Time_struct), PUBLIC    :: dater          ! date info for receive operation
+!   TYPE(PRISM_Time_struct), PUBLIC    :: dater_bound(2) ! date info for receive operation
+!   TYPE(PRISM_Time_struct), PUBLIC    :: tmpdate
+
+   PRIVATE
+
+   INTEGER, PARAMETER         :: localRoot  = 0
+
+   INTEGER                    :: localRank      ! local MPI rank
+   INTEGER                    :: localSize      ! local MPI size
+   INTEGER                    :: localComm      ! local MPI size
+   LOGICAL                    :: commRank       ! true for ranks doing OASIS communication
+   INTEGER                    :: comp_id        ! id returned by prism_init_comp
+
+   INTEGER                    :: range(5)
+
+   LOGICAL, SAVE              :: prism_was_initialized
+   LOGICAL, SAVE              :: prism_was_terminated
+   INTEGER, SAVE              :: write_grid
+
+   INTEGER                    :: ierror         ! return error code
+
+#ifdef key_cpl_rootexchg
+   LOGICAL                               :: rootexchg =.true.     ! logical switch 
+#else
+   LOGICAL                               :: rootexchg =.false.    ! logical switch
+#endif
+
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE :: exfld  ! Temporary buffer for exchange
+   REAL(wp), DIMENSION(:),   ALLOCATABLE :: buffer ! Temporary buffer for exchange
+   INTEGER, DIMENSION(:,:),  ALLOCATABLE :: ranges ! Temporary buffer for exchange
+
+   DOUBLE PRECISION           :: date_incr
+
+   !! Routine accessibility
+   PUBLIC cpl_prism_init
+   PUBLIC cpl_prism_define
+   PUBLIC cpl_prism_send
+   PUBLIC cpl_prism_recv
+   PUBLIC cpl_prism_finalize
+
+   PUBLIC send_id, recv_id
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE cpl_prism_init( localCommunicator )
+
+      IMPLICIT NONE
+
+      !!-------------------------------------------------------------------
+      !!             ***  ROUTINE cpl_prism_init  ***
+      !!
+      !! ** Purpose :   Initialize coupled mode communication for ocean
+      !!    exchange between AGCM, OGCM and COUPLER. (OASIS4 software)
+      !!
+      !! ** Method  :   OASIS4 MPI communication 
+      !!--------------------------------------------------------------------
+      !! * Arguments
+      !!
+      INTEGER, INTENT(OUT)       :: localCommunicator
+      !!
+      !! * Local declarations
+      !!
+
+      NAMELIST/nam_mpp/ app_name, comp_name, c_mpi_send, grid_name
+
+      !!
+      !!--------------------------------------------------------------------
+      !!
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cpl_prism_init : initialization in coupled ocean/atmosphere case'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*)
+     
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_forced_daily
+
+#if !defined key_oasis4
+! The following is not necessarily a valid peice of checking
+
+      IF(lwp) WRITE(numout,cform_err)
+      IF(lwp) WRITE(numout,*) ' key_coupled and key_flx_bulk_* key_flx_forced_daily are incompatible'
+      nstop = nstop + 1
+
+#endif
+
+#endif
+
+      REWIND( numnam )
+      READ  ( numnam, nam_mpp )
+      REWIND( numnam )
+
+      !------------------------------------------------------------------
+      ! 1st Initialize the PRISM system for the application
+      !------------------------------------------------------------------
+
+      CALL prism_initialized (prism_was_initialized, ierror)
+      IF ( ierror /= PRISM_Success ) &
+         CALL prism_abort( comp_id, 'OPA9.0', 'cpl_prism_init: Failure in prism_initialized' )
+
+      IF ( .NOT. prism_was_initialized ) THEN
+         CALL prism_init( app_name, ierror )
+         IF ( ierror /= PRISM_Success ) &
+            CALL prism_abort(comp_id, 'OPA9.0', 'cpl_prism_init: Failure in prism_init')
+         prism_was_initialized = .true.
+      ELSE
+         call prism_abort(comp_id, 'OPA9.0', 'cpl_prism_init: Do not initialize prism twice!')
+      ENDIF
+      !
+      ! Obtain the actual dates and date bounds
+      !
+      ! date is determined by adding days since beginning of
+      !   the run to the corresponding initial date. Note that
+      !   OPA internal info about the start date of the experiment
+      !   is bypassed. Instead we rely sololy on the info provided
+      !   by the SCC.xml file. 
+      !
+      dates   = PRISM_Jobstart_date
+
+      WRITE(6,*) "PRISM JOB START DATE IS", dates
+
+      !
+      ! upper bound is determined by adding half a time step
+      !
+      tmpdate = dates
+      date_incr = rdttra(1)/2.0
+      CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+      dates_bound(2) = tmpdate
+      !
+      ! lower bound is determined by half distance to date from previous run
+      !
+      tmpdate   = dates
+      date_incr = ( adatrj - adatrj0 ) * 43200.0
+      CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+      dates_bound(1) = tmpdate
+
+      dater = dates
+      dater_bound(1) = dates_bound(1) 
+      dater_bound(2) = dates_bound(2) 
+
+      WRITE(6,*) "DATE send and rec BOUNDS",dater_bound
+      WRITE(6,*) "OTHER BITS FOR DATE",rdttra(1)
+      WRITE(6,*) "adatrj/0",adatrj,adatrj0,date_incr
+
+      !------------------------------------------------------------------
+      ! 2nd Initialize the PRISM system for the component
+      !------------------------------------------------------------------
+
+      CALL prism_init_comp ( comp_id, comp_name, ierror )
+      IF ( ierror /= PRISM_Success ) &
+         CALL prism_abort (comp_id, 'OPA9.0', 'cpl_prism_init: Failure in prism_init_comp')
+
+      WRITE(6,*) "COMPLETED INIT_COMP",comp_name,comp_id
+
+      !------------------------------------------------------------------
+      ! 3rd Get an MPI communicator for OPA local communication
+      !------------------------------------------------------------------
+
+      CALL prism_get_localcomm ( comp_id, localComm, ierror )
+      IF ( ierror /= PRISM_Success ) &
+         CALL prism_abort (comp_id, 'OPA9.0', 'cpl_prism_init: Failure in prism_get_localcomm' )
+
+      localCommunicator = localComm
+
+       WRITE(6,*) "COMPLETED GET_LOCALCOMM",comp_name,comp_id
+
+
+   END SUBROUTINE cpl_prism_init
+
+
+   SUBROUTINE cpl_prism_define ()
+
+      IMPLICIT NONE
+
+      !!-------------------------------------------------------------------
+      !!             ***  ROUTINE cpl_prism_define  ***
+      !!
+      !! ** Purpose :   Define grid and field information for ocean
+      !!    exchange between AGCM, OGCM and COUPLER. (OASIS4 software)
+      !!
+      !! ** Method  :   OASIS4 MPI communication 
+      !!--------------------------------------------------------------------
+      !! * Arguments
+      !!
+      !! * Local declarations
+
+      INTEGER                    :: grid_id(2)     ! id returned by prism_def_grid
+
+      INTEGER                    :: upoint_id(2), &
+                                    vpoint_id(2), &
+                                    tpoint_id(2), &
+                                    fpoint_id(2)   ! ids returned by prism_set_points
+
+      INTEGER                    :: umask_id(2), &
+                                    vmask_id(2), &
+                                    tmask_id(2), &
+                                    fmask_id(2)    ! ids returned by prism_set_mask
+
+      INTEGER                    :: grid_type      ! PRISM grid type
+
+      INTEGER                    :: shape(2,3)     ! shape of arrays passed to PSMILe
+      INTEGER                    :: nodim(2)
+      INTEGER                    :: data_type      ! data type of transients
+
+      INTEGER                    :: nbr_corners
+
+      LOGICAL                    :: new_points
+      LOGICAL                    :: new_mask
+      LOGICAL                    :: mask(jpi,jpj,jpk)
+
+      INTEGER                    :: ji, jj, jk     ! local loop indicees
+
+      CHARACTER(len=32)          :: cpl_send (nsend)
+      CHARACTER(len=32)          :: cpl_recv (nrecv)
+
+      CHARACTER(len=32)          :: grid_name      ! name of the grid
+      CHARACTER(len=32)          :: point_name     ! name of the grid points
+
+      REAL(kind=wp), ALLOCATABLE :: rclon(:,:,:)
+      REAL(kind=wp), ALLOCATABLE :: rclat(:,:,:)
+      REAL(kind=wp), ALLOCATABLE :: rcz  (:,:)
+
+      !!--------------------------------------------------------------------
+     
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cpl_prism_define : initialization in coupled ocean/atmosphere case'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*)
+     
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_forced_daily
+
+#if !defined key_oasis4
+! The problem with the following is that it ASSUMES we're only ever coupling to an atmosphere
+! which is not necessarily the case. Prevent this test temporarily for NEMOGAM development.
+
+      IF(lwp) WRITE(numout,cform_err)
+      IF(lwp) WRITE(numout,*) ' key_coupled and key_flx_bulk_... are incompatible'
+      nstop = nstop + 1
+
+#endif
+
+#endif
+
+      ! -----------------------------------------------------------------
+      ! ... Some initialisation
+      ! -----------------------------------------------------------------
+
+      send_id = 0
+      recv_id = 0
+
+#if defined key_mpp_mpi
+
+      ! -----------------------------------------------------------------
+      ! ... Some MPI stuff relevant for optional exchange via root only
+      ! -----------------------------------------------------------------
+
+      commRank = .false.
+
+      localRank = mpprank ! from lib_mpp
+      localSize = mppsize ! from lib_mpp
+
+      IF(lwp) WRITE(numout,*) "CALLING DEFINE"
+
+      IF ( rootexchg ) THEN
+         IF ( localRank == localRoot ) commRank = .true.
+      ELSE
+         commRank = .true.
+      ENDIF
+
+#else
+      !
+      ! For non-parallel configurations the one and only process ("localRoot")
+      ! takes part in the communication
+      ! 
+      localRank = localRoot
+      commRank = .true.
+
+#endif
+
+      ! -----------------------------------------------------------------
+      ! ... Allocate memory for data exchange
+      ! -----------------------------------------------------------------
+
+
+      IF(lwp) WRITE(numout,*) "Abbout to allocate exfld",jpi,jpj
+
+      ALLOCATE(exfld(1:jpi,1:jpj), stat = ierror)
+      IF (ierror > 0) THEN
+         CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in allocating Reals')
+         RETURN
+      ENDIF
+
+      IF ( rootexchg .and. localRank == localRoot ) THEN
+         ALLOCATE(ranges(5,0:localSize-1), stat = ierror)
+         IF (ierror > 0) THEN
+            CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in allocating Integer')
+            RETURN
+         ENDIF
+      ENDIF
+
+      !------------------------------------------------------------------
+      ! 1st Declare the local grid (ORCA tripolar) characteristics for
+      !     surface coupling. The halo regions must be excluded. For
+      !     surface coupling it is sufficient to specify only one
+      !     vertical z-level.
+      !------------------------------------------------------------------
+
+      grid_type = PRISM_irrlonlat_regvrt
+
+      IF(lwp) WRITE(numout,*) "Set grid type"
+
+
+      ! -----------------------------------------------------------------
+      ! ... Define the shape of the valid region without the halo.
+      !     For serial configuration (key_mpp_mpi not being active)
+      !     nl* is set to the global values 1 and jp*glo.
+      ! -----------------------------------------------------------------
+
+      IF ( rootexchg ) THEN
+         shape(1,1) = 1+jpreci
+         shape(2,1) = jpiglo-jpreci
+         shape(1,2) = 1+jpreci
+         shape(2,2) = jpjglo-jpreci
+         shape(1,3) = 1
+         shape(2,3) = 1
+      ELSE
+         shape(1,1) = 1+jpreci
+         shape(2,1) = jpi-jpreci
+         shape(1,2) = 1+jpreci
+         shape(2,2) = jpj-jpreci
+         shape(1,3) = 1
+         shape(2,3) = 1
+      ENDIF
+
+      IF(lwp) WRITE(numout,*) "commrank is", commRank
+
+      IF ( commRank ) THEN
+
+         IF(lwp) WRITE(numout,*) "CALLING DEF_GRID"
+
+         IF(lwp) WRITE(numout,*) "grid name",grid_name
+         IF(lwp) WRITE(numout,*) " shape",shape
+         IF(lwp) WRITE(numout,*) "grid type",grid_type
+
+         CALL prism_def_grid ( grid_id(1), grid_name, comp_id, shape, &
+              grid_type, ierror )
+         IF ( ierror /= PRISM_Success ) THEN
+            PRINT *, 'OPA cpl_prism_define: Failure in prism_def_grid'
+            CALL prism_abort (comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_def_grid')
+         ENDIF
+
+         !------------------------------------------------------------------
+         ! 2nd Declare the geometic information for this grid.
+         !------------------------------------------------------------------
+
+         ! -----------------------------------------------------------------
+         ! ... Redefine shape which may now include the halo region as well.
+         ! -----------------------------------------------------------------
+
+         shape(1,1) = 1
+         shape(2,1) = jpi
+         shape(1,2) = 1
+         shape(2,2) = jpj
+         shape(1,3) = 1
+         shape(2,3) = 1
+
+         IF(lwp) WRITE(numout,*) "redefined shape",shape
+
+         ! -----------------------------------------------------------------
+         ! ... Define the elements, i.e. specify the corner points for each
+         !     volume element. In case OPA runs on level coordinates (regular
+         !     in the vertical) we only need to give the 4 horizontal corners
+         !     for a volume element plus the vertical position of the upper
+         !     and lower face. Nevertheless the volume element has 8 corners.
+         ! -----------------------------------------------------------------
+
+         !
+         ! ... Treat corners in the horizontal plane
+         !
+         ALLOCATE(rclon(shape(1,1):shape(2,1),shape(1,2):shape(2,2),4), &
+              STAT=ierror)
+         IF ( ierror /= 0 ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: error in allocate for rclon')
+
+         ALLOCATE(rclat(shape(1,1):shape(2,1),shape(1,2):shape(2,2),4), &
+              STAT=ierror)
+         IF ( ierror /= 0 ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: error in allocate for rclon')
+
+         nbr_corners = 8
+         !
+         ! ... Set right longitudes and upper latitudes
+         !
+         DO jj = shape(1,2), shape(2,2)
+            DO ji = shape(1,1), shape(2,1)
+               rclon(ji,jj,1) = glamu(ji,jj)
+               rclon(ji,jj,2) = glamu(ji,jj)
+               rclat(ji,jj,2) = gphiv(ji,jj)
+               rclat(ji,jj,3) = gphiv(ji,jj)
+            ENDDO
+         ENDDO
+         !
+         ! ... Set the lower latitudes
+         !
+         DO jj = shape(1,2)+1, shape(2,2)
+            DO ji = shape(1,1), shape(2,1)
+               rclat(ji,jj-1,1) = rclat(ji,jj,2)
+               rclat(ji,jj-1,4) = rclat(ji,jj,3)
+            ENDDO
+         ENDDO
+         !
+         ! ... Set the left longitudes
+         !
+         DO jj = shape(1,2), shape(2,2)
+            DO ji = shape(1,1)+1, shape(2,1)
+               rclon(ji-1,jj,3) = rclon(ji,jj,2)
+               rclon(ji-1,jj,4) = rclon(ji,jj,1)
+            ENDDO
+         ENDDO
+         !
+         ! ... Set the lowermost latitudes 
+         !
+         DO jj = shape(1,2), shape(1,2)
+            DO ji = shape(1,1), shape(2,1)
+               rclat(ji,jj,1) = 2.0*gphit(ji,jj)-rclat(ji,jj,2)
+               rclat(ji,jj,4) = 2.0*gphit(ji,jj)-rclat(ji,jj,4)
+            ENDDO
+         ENDDO
+         !
+         ! ... Set the rightmost latitudes 
+         !
+         DO jj = shape(1,2), shape(2,2)
+            DO ji = shape(1,2), shape(1,2)
+               rclon(ji,jj,3) = 2.0*glamt(ji,jj)-rclon(ji,jj,2)
+               rclon(ji,jj,4) = 2.0*glamt(ji,jj)-rclon(ji,jj,1)
+
+               WRITE(76,*) "rclon", ji, jj, rclon(ji,jj,1), &
+                                            rclon(ji,jj,2), &
+                                            rclon(ji,jj,3), &
+                                            rclon(ji,jj,4)
+
+               WRITE(76,*) "rclat", ji, jj, rclat(ji,jj,1), &
+                                            rclat(ji,jj,2), &
+                                            rclat(ji,jj,3), &
+                                            rclat(ji,jj,4)
+
+            ENDDO
+         ENDDO
+
+         !
+         ! ... Treat corners along the vertical axis
+         !
+         ALLOCATE(rcz(shape(1,3):shape(2,3),2), STAT=ierror)
+         IF ( ierror /= 0 ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: error in allocate for rcz')
+
+         DO jk = shape(1,3), shape(2,3)
+            rcz(jk,1) = gdepw(jk)
+            rcz(jk,2) = gdepw(jk+1)
+         ENDDO
+
+         IF(lwp) WRITE(numout,*) "ABOUT TO CALL SET CORNERS",shape 
+
+         CALL prism_set_corners ( grid_id(1), nbr_corners, shape, rclon, rclat, &
+              rcz, ierror)
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_corners')
+
+         DEALLOCATE(rclon, rclat, rcz)
+
+         ! -----------------------------------------------------------------
+         ! ... Define the gridpoints  
+         ! -----------------------------------------------------------------
+
+         new_points = .TRUE.
+
+         IF(lwp) WRITE(numout,*) "CALLING SET_POINTS"
+
+         !
+         ! ... the u-points
+         !
+         point_name = 'u-points'
+         CALL prism_set_points ( upoint_id(1), point_name, grid_id(1), shape,      &
+              glamu, gphiu, gdept(shape(1,3):shape(2,3)), new_points, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_points upoint_id')
+         !
+         ! ... the v-points
+         !
+
+         IF(lwp) WRITE(numout,*) "CALLING SET_POINTS done u doing v"
+
+         point_name = 'v-points'
+         CALL prism_set_points ( vpoint_id(1), point_name, grid_id(1), shape,      &
+              glamv, gphiv, gdept(shape(1,3):shape(2,3)), new_points, ierror )      
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_points vpoint_id')
+         !
+         ! ... the t-points
+         !
+         ! WRITE(76,*) 'CALLING T POINTS', shape
+         ! WRITE(77,*) 'glamt', glamt
+         ! WRITE(78,*) 'gphit', gphit
+         !
+         point_name = 't-points'
+         CALL prism_set_points ( tpoint_id(1), point_name, grid_id(1), shape,   &
+              glamt, gphit, gdept(shape(1,3):shape(2,3)), new_points, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_points tpoint_id')
+         !
+         ! ... the f-points
+         !
+         point_name = 'f-points'
+         CALL prism_set_points ( fpoint_id(1), point_name, grid_id(1), shape,   &
+              glamf, gphif, gdept(shape(1,3):shape(2,3)), new_points, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_points fpoint_id')
+
+
+         IF(lwp) WRITE(numout,*) "CALLING SET_POINTS done f"
+
+         ! -----------------------------------------------------------------
+         ! ... Convert OPA masks to logicals and define the masks
+         ! -----------------------------------------------------------------
+
+         new_mask = .true.
+
+         mask = (umask == 1)
+         CALL prism_set_mask (umask_id(1), grid_id(1), shape, &
+                 mask(shape(1,1):shape(2,1),                  &
+                      shape(1,2):shape(2,2),                  &
+                      shape(1,3):shape(2,3)),                 &
+              new_mask, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_mask umask_id')
+
+         mask = (vmask == 1)
+         CALL prism_set_mask (vmask_id(1), grid_id(1), shape, &
+                 mask(shape(1,1):shape(2,1),                  &
+                      shape(1,2):shape(2,2),                  &
+                      shape(1,3):shape(2,3)),                 &
+              new_mask, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_mask umask_id')
+
+         mask = (tmask == 1)
+         CALL prism_set_mask (tmask_id(1), grid_id(1), shape, &
+                 mask(shape(1,1):shape(2,1),                  &
+                      shape(1,2):shape(2,2),                  &
+                      shape(1,3):shape(2,3)),                 &
+              new_mask, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_mask umask_id')
+
+         mask = (fmask == 1)
+         CALL prism_set_mask (fmask_id(1), grid_id(1), shape, &
+                 mask(shape(1,1):shape(2,1),                  &
+                      shape(1,2):shape(2,2),                  &
+                      shape(1,3):shape(2,3)),                 &
+              new_mask, ierror )
+         IF ( ierror /= PRISM_Success ) &
+              CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_set_mask umask_id')
+
+         IF(lwp) WRITE(numout,*) "DONE ALL THE SET MASKS"
+
+         ! -----------------------------------------------------------------
+         ! ... Define the angles
+         !   This is needed if zonal tau is not oriented E-W and meridional
+         !   tau is not oriented along N-S but rather along local coordinate
+         !   axis. Please check!!!!
+         ! -----------------------------------------------------------------
+
+!rr      cal prism_set_angles ( ..., ierror ) ! not yet supported by OASIS4
+
+         ! -----------------------------------------------------------------
+         ! ... Define the partition 
+         ! -----------------------------------------------------------------
+         
+         IF ( rootexchg ) THEN
+
+            range(1) = nimpp-1+nldi   ! global start in i
+            range(2) = nlei-nldi+1    ! local size in i of valid region
+            range(3) = njmpp-1+nldj   ! global start in j
+            range(4) = nlej-nldj+1    ! local size in j of valid region
+            range(5) = range(2) &
+                     * range(4)       ! local horizontal size
+            !
+            ! Collect ranges from all NEMO procs on the local root process
+            !
+            CALL mpi_gather(range,  5, MPI_INTEGER, &
+                            ranges, 5, MPI_INTEGER, localRoot, localComm, ierror)
+
+            IF ( localRank == localRoot ) THEN
+
+               maxlen = maxval(ranges(5,:))
+
+               ALLOCATE(buffer(1:maxlen), stat = ierror)
+               IF (ierror > 0) THEN
+                  CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in allocating buffer')
+                  RETURN
+               ENDIF
+
+            ENDIF
+
+         ENDIF
+
+         ! -----------------------------------------------------------------
+         ! ... Define the scalefactors 
+         ! -----------------------------------------------------------------
+
+!rr      WRITE(numout,*) "CALLING SCALEFACTOR"
+!rr      call prism_set_scalefactor ( grid_id(1), shape, e1t, e2t, e3t, ierror )  ! not yet supported by OASIS4
+!rr      WRITE(numout,*) "ABOUT TO DEFINE THE TRANSIENTS"
+
+         !------------------------------------------------------------------
+         ! 3rd Declare the transient variables
+         !------------------------------------------------------------------
+         !
+         ! ... Define symbolic names for the transient fields send by the ocean
+         !     These must be identical to the names specified in the SMIOC file.
+         !
+         cpl_send( 1)='SOSSTSST' ! sea surface temperature              -> sst_io
+         cpl_send( 2)='SITOCEAN' ! sea ice thickness                    -> hicif (only 1 layer available!)
+#if defined key_cpl_albedo
+         cpl_send( 3)='STIOCEAN' ! surface temperature over sea ice     -> tn_ice
+         cpl_send( 4)='SAIOCEAN' ! albedo over sea ice                  -> alb_ice
+#else
+         cpl_send( 3)='SITOCEAN' ! sea ice thickness                    -> hicif (only 1 layer available!)
+         cpl_send( 4)='SNTOCEAN' ! surface snow thickness over sea ice  -> hsnif
+#endif
+#if defined key_cpl_ocevel
+         cpl_send( 5)='SUNOCEAN' ! U-velocity                           -> un
+         cpl_send( 6)='SVNOCEAN' ! V-velocity                           -> vn
+#endif
+         !
+         ! ...  Define symbolic names for transient fields received by the ocean.
+         !      These must be identical to the names specified in the SMIOC file.
+         !
+         ! ...  a) U-Grid fields
+         !
+         cpl_recv( 1)='TXWOCEWU' ! weighted surface downward eastward stress
+         cpl_recv( 2)='TYWOCEWU' ! weighted surface downward northward stress
+         cpl_recv( 3)='TXIOCEWU' ! weighted surface downward eastward stress over ice
+         cpl_recv( 4)='TYIOCEWU' ! weighted surface downward northward stress over ice
+         !
+         ! ...  a) V-Grid fields
+         !
+         cpl_recv( 5)='TXWOCEWV' ! weighted surface downward eastward stress
+         cpl_recv( 6)='TYWOCEWV' ! weighted surface downward northward stress
+         cpl_recv( 7)='TXIOCEWV' ! weighted surface downward eastward stress over ice
+         cpl_recv( 8)='TYIOCEWV' ! weighted surface downward northward stress over ice
+         !
+         ! ...  a) T-Grid fields
+         !
+         cpl_recv( 9)='FRWOCEPE' ! P-E over water                               -> zpew
+         cpl_recv(10)='FRIOCEPE' ! P-E over ice                                 -> zpei
+         cpl_recv(11)='FRROCESN' ! surface downward snow fall                   -> zpsol
+         cpl_recv(12)='FRIOCEEV' ! surface upward snow flux where sea ice       -> zevice
+
+         cpl_recv(13)='QSWOCESR' ! surface net downward shortwave flux          -> qsr_oce
+         cpl_recv(14)='QSWOCENS' ! surface downward non-solar heat flux in air  -> qnsr_oce
+         cpl_recv(15)='QSIOCESR' ! solar heat flux on sea ice                   -> qsr_ice
+         cpl_recv(16)='QSIOCENS' ! non-solar heat flux on sea ice               -> qnsr_ice
+         cpl_recv(17)='QSIOCEDQ' ! non-solar heat flux derivative               -> dqns_ice
+
+#ifdef key_cpl_discharge
+         cpl_recv(18)='FRWOCEIS' ! ice discharge into ocean                     -> calving
+         cpl_recv(19)='FRWOCERD' ! river discharge into ocean                   -> zrunriv
+         cpl_recv(20)='FRWOCECD' ! continental discharge into ocean             -> zruncot
+#endif
+         IF ( wp == 4 ) data_type = PRISM_REAL
+         IF ( wp == 8 ) data_type = PRISM_DOUBLE_PRECISION
+
+         nodim(1) = 3 ! check
+         nodim(2) = 0
+         !
+         ! ... Announce send variables, all on T points. 
+         !
+         DO ji = 1, nsend
+            ! if ( ji == 2 ) ; then ; nodim(2) = 2 ; else ; nodim(2) = 0 ; endif
+            CALL prism_def_var (send_id(ji), cpl_send(ji), grid_id(1), &
+                 tpoint_id(1), tmask_id(1), nodim, shape, data_type, ierror)
+            IF ( ierror /= PRISM_Success ) THEN
+               PRINT *, 'Failed to define transient ', ji, TRIM(cpl_send(ji))
+               CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_def_var')
+            ENDIF
+         ENDDO
+         !
+         nodim(1) = 3 ! check
+         nodim(2) = 0
+         !
+         ! ... Announce recv variables. 
+         !
+         ! ... a) on U points
+         !
+         DO ji = 1, 4
+            CALL prism_def_var (recv_id(ji), cpl_recv(ji), grid_id(1), &
+                 upoint_id(1), umask_id(1), nodim, shape, data_type, ierror)
+            IF ( ierror /= PRISM_Success ) THEN
+               PRINT *, 'Failed to define transient ', ji, TRIM(cpl_recv(ji))
+               CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_def_var')
+            ENDIF
+         ENDDO
+         !
+         ! ... b) on V points
+         !
+         DO ji = 5, 8 
+            CALL prism_def_var (recv_id(ji), cpl_recv(ji), grid_id(1), &
+                 vpoint_id(1), vmask_id(1), nodim, shape, data_type, ierror)
+            IF ( ierror /= PRISM_Success ) THEN
+               PRINT *, 'Failed to define transient ', TRIM(cpl_recv(ji))
+               CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_def_var')
+            ENDIF
+         ENDDO
+         !
+         ! ... c) on T points
+         !
+         DO ji = 9, nrecv
+            CALL prism_def_var (recv_id(ji), "SORUNOFF", grid_id(1), &
+                 tpoint_id(1), tmask_id(1), nodim, shape, data_type, ierror)
+            IF ( ierror /= PRISM_Success ) THEN
+               PRINT *, 'Failed to define transient ', TRIM(cpl_recv(ji))
+               CALL prism_abort ( comp_id, 'OPA9.0', 'OPA cpl_prism_define: Failure in prism_def_var')
+            ENDIF
+         ENDDO
+
+      ENDIF ! commRank
+
+      !------------------------------------------------------------------
+      ! 4th End of definition phase
+      !------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*) "ABOUT TO CALL PRISM_ENDDEF" 
+
+      CALL prism_enddef(ierror)
+
+      IF(lwp) WRITE(numout,*) "DONE ENDDEF",ierror
+
+      IF ( ierror /= PRISM_Success ) &
+         CALL prism_abort ( comp_id, 'OPA9.0', 'cpl_prism_define: Failure in prism_enddef')
+        
+      IF(lwp) WRITE(numout,*) "ALL DONE, EXITING PRISM SET UP PHASE"
+ 
+   END SUBROUTINE cpl_prism_define
+
+
+
+   SUBROUTINE cpl_prism_send( var_id, date, data_array, info )
+
+      IMPLICIT NONE
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_send  ***
+      !!
+      !! ** Purpose : - At each coupling time-step,this routine sends fields
+      !!      like sst or ice cover to the coupler or remote application.
+      !!
+      !! ** Method  : OASIS4
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      !!
+      INTEGER, INTENT( IN )  :: var_id    ! variable Id
+      INTEGER, INTENT( OUT ) :: info      ! variable Id
+      INTEGER, INTENT( IN )  :: date      ! ocean time-step in seconds
+      REAL(wp)               :: data_array(:,:)
+      !!
+      !! * Local declarations
+      !!
+#if defined key_mpp_mpi
+      REAL(wp)               :: global_array(jpiglo,jpjglo)
+      !
+!mpi  INTEGER                :: status(MPI_STATUS_SIZE)
+!mpi  INTEGER                :: type       ! MPI data type
+      INTEGER                :: request    ! MPI isend request
+      INTEGER                :: ji, jj, jn ! local loop indicees
+#else
+      INTEGER                :: ji
+#endif
+      !!
+      INTEGER, SAVE          :: ncount = 0
+      !!
+      !!--------------------------------------------------------------------
+      !!
+      ncount = ncount + 1
+
+#if defined key_mpp_mpi
+
+      request = 0
+
+      IF ( rootexchg ) THEN
+         !
+!mpi     IF ( wp == 4 ) type = MPI_REAL
+!mpi     IF ( wp == 8 ) type = MPI_DOUBLE_PRECISION
+         !
+         ! collect data on the local root process
+         !
+         IF ( localRank /= localRoot ) THEN
+
+            DO jj = nldj, nlej
+               DO ji = nldi, nlei
+                  exfld(ji-nldi+1,jj-nldj+1)=data_array(ji,jj)
+               ENDDO
+            ENDDO
+
+!mpi        CALL mpi_send(exfld, range(5), type, localRoot, localRank, localComm, ierror)
+            CALL mppsend (localRank, exfld, range(5), localRoot, request)
+         ENDIF
+
+         IF ( localRank == localRoot ) THEN
+
+            DO jj = ranges(3,localRoot), ranges(3,localRoot)+ranges(4,localRoot)-1
+               DO ji = ranges(1,localRoot), ranges(1,localRoot)+ranges(2,localRoot)-1
+                  global_array(ji,jj) = data_array(ji,jj) ! workaround
+               ENDDO
+            ENDDO
+
+            DO jn = 1, localSize-1
+
+!mpi           CALL mpi_recv(buffer, ranges(5,jn), type, localRoot, jn, localComm, status, ierror)
+               CALL mpprecv(jn, buffer, ranges(5,jn))
+
+               DO jj = ranges(3,jn), ranges(3,jn)+ranges(4,jn)-1
+                  DO ji = ranges(1,jn), ranges(1,jn)+ranges(2,jn)-1
+                     global_array(ji,jj) = buffer( (jj-ranges(3,jn))*ranges(2,jn) + ji-ranges(1,jn)+1 )
+                  ENDDO
+               ENDDO
+
+            ENDDO
+
+         ENDIF
+         !
+         ! send data from local root to OASIS4
+         !
+         CALL prism_put ( var_id, dates, dates_bound, global_array, info, ierror )      
+
+      ELSE
+         !
+         ! send local data from every process to OASIS4
+         !
+         CALL prism_put ( var_id, dates, dates_bound, data_array, info, ierror )      
+
+      ENDIF !rootexchg
+
+#else
+
+      !
+      ! send local data from every process to OASIS4
+      !
+      IF ( commRank ) &
+      CALL prism_put ( var_id, dates, dates_bound, data_array, info, ierror )      
+
+#endif
+
+      IF ( commRank ) THEN
+
+         IF (l_ctl) THEN
+
+            IF ( info==PRISM_Cpl ) THEN
+               WRITE(numout,*) '****************'
+               DO ji = 1, nsend
+                  IF (var_id == send_id(ji) ) THEN
+                     WRITE(numout,*) 'prism_put_proto: Outgoing ', cpl_send(ji)
+                     EXIT
+                  ENDIF
+               ENDDO
+               WRITE(numout,*) 'prism_put: var_id       ', var_id
+               WRITE(numout,*) 'prism_put:   date       ', date
+               WRITE(numout,*) 'prism_put:   info       ', info
+               WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
+               WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
+               WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
+               WRITE(numout,*) '****************'
+            ENDIF
+
+         ENDIF
+
+         IF ( ncount == nrecv ) THEN
+            !
+            !  3. Update dates and dates_bound for next step. We assume that cpl_prism_send
+            !  is called for all send fields at each time step. Therefore we update
+            !  the date argument to prism_put only every nsend call to cpl_prism_send.
+            !
+            dates_bound(1) = dates_bound(2)
+
+            tmpdate    = dates_bound(2)
+            date_incr  = rdCplttra(1)/2.0
+
+            CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+            dates = tmpdate
+            CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+            dates_bound(2) = tmpdate
+
+            ncount = 0
+
+         ENDIF
+
+      ENDIF ! commRank
+
+   END SUBROUTINE cpl_prism_send
+
+
+
+   SUBROUTINE cpl_prism_recv(  var_id, date, data_array, info )
+
+      IMPLICIT NONE
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_recv  ***
+      !!
+      !! ** Purpose : - At each coupling time-step,this routine receives fields
+      !!      like stresses and fluxes from the coupler or remote application.
+      !!
+      !! ** Method  : OASIS4
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      !!
+      INTEGER, INTENT( IN )  :: var_id    ! variable Id
+      INTEGER, INTENT( OUT ) :: info      ! variable Id
+      INTEGER, INTENT( IN )  :: date      ! ocean time-step in seconds
+      REAL(wp),INTENT( OUT ) :: data_array(:,:)
+      !!
+      !! * Local declarations
+      !!
+#if defined key_mpp_mpi
+      REAL(wp)               :: global_array(jpiglo,jpjglo)
+      !
+      LOGICAL                :: action = .false.
+!mpi  INTEGER                :: status(MPI_STATUS_SIZE)
+!mpi  INTEGER                :: type       ! MPI data type
+      INTEGER                :: request    ! MPI isend request
+      INTEGER                :: ji, jj, jn ! local loop indicees
+#else
+      INTEGER                :: ji
+#endif
+
+      INTEGER, SAVE          :: ncount = 0
+      !!
+      !!--------------------------------------------------------------------
+      !!
+      ncount  = ncount + 1
+
+#ifdef key_mpp_mpi
+
+      request = 0
+
+      IF ( rootexchg ) THEN
+         !
+         ! receive data from OASIS4 on local root
+         !
+         IF ( commRank ) &
+         CALL prism_get (var_id, dater, dater_bound, global_array, info, ierror)
+         CALL MPI_BCAST ( info, 1, MPI_INTEGER, localRoot, localComm, ierror )
+
+      ELSE
+         !
+         ! receive local data from OASIS4 on every process
+         !
+         CALL prism_get (var_id, dater, dater_bound, exfld, info, ierror)
+
+      ENDIF
+
+      action = (info==PRISM_CplIO)
+
+      IF ( rootexchg .and. action ) THEN
+         !
+!mpi     IF ( wp == 4 ) type = MPI_REAL
+!mpi     IF ( wp == 8 ) type = MPI_DOUBLE_PRECISION
+         !
+         ! distribute data to processes
+         !
+         IF ( localRank == localRoot ) THEN
+
+            DO jj = ranges(3,localRoot), ranges(3,localRoot)+ranges(4,localRoot)-1
+               DO ji = ranges(1,localRoot), ranges(1,localRoot)+ranges(2,localRoot)-1
+                  exfld(ji,jj) = global_array(ji,jj)
+               ENDDO
+            ENDDO
+
+            DO jn = 1, localSize-1
+
+               DO jj = ranges(3,jn), ranges(3,jn)+ranges(4,jn)-1
+                  DO ji = ranges(1,jn), ranges(1,jn)+ranges(2,jn)-1
+                     buffer( (jj-ranges(3,jn))*ranges(2,jn) + ji-ranges(1,jn)+1 ) = global_array(ji,jj)
+                  ENDDO
+               ENDDO
+
+!mpi           CALL mpi_send(buffer, ranges(5,jn), type, jn, jn, localComm, ierror)
+               CALL mppsend (jn, buffer, ranges(5,jn), jn, request)  
+
+            ENDDO
+
+         ENDIF
+
+         IF ( localRank /= localRoot ) &
+!mpi         CALL mpi_recv(exfld, range(5), type, localRoot, localRank, localComm, status, ierror)
+             CALL mpprecv(localRank, exfld, range(5))
+      ENDIF
+
+      IF ( action ) THEN
+
+         data_array = 0.0
+
+         DO jj = nldj, nlej
+            DO ji = nldi, nlei
+               data_array(ji,jj)=exfld(ji-nldi+1,jj-nldj+1)
+            ENDDO
+         ENDDO
+
+         IF (l_ctl) THEN        
+            WRITE(numout,*) '****************'
+            DO ji = 1, nrecv
+               IF (var_id == recv_id(ji) ) THEN
+                  WRITE(numout,*) 'prism_get: Incoming ', cpl_recv(ji)
+                  EXIT
+               ENDIF
+            ENDDO
+            WRITE(numout,*) 'prism_get: var_id       ', var_id
+            WRITE(numout,*) 'prism_get:   date       ', date
+            WRITE(numout,*) 'prism_get:   info       ', info
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
+            WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
+            WRITE(numout,*) '****************'
+         ENDIF
+
+      ENDIF
+#else
+
+      CALL prism_get (var_id, dater, dater_bound, exfld, info, ierror)
+
+      IF ( info==PRISM_CplIO ) THEN
+               data_array=exfld
+
+         IF (l_ctl) THEN        
+            WRITE(numout,*) '****************'
+            DO ji = 1, nrecv
+               IF (var_id == recv_id(ji) ) THEN
+                  WRITE(numout,*) 'prism_get: Incoming ', cpl_recv(ji)
+                  EXIT
+               ENDIF
+            ENDDO
+            WRITE(numout,*) 'prism_get: var_id       ', var_id
+            WRITE(numout,*) 'prism_get:   date       ', date
+            WRITE(numout,*) 'prism_get:   info       ', info
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
+            WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
+            WRITE(numout,*) '****************'
+         ENDIF
+
+      ENDIF
+
+#endif
+
+      IF ( ncount == nrecv ) THEN
+         !
+         !  3. Update dater and dater_bound for next step. We assume that cpl_prism_recv
+         !  is called for all recv fields at each time step. Therefore we update
+         !  the date argument to prism_get only every nrecv call to cpl_prism_recv.
+         !
+         dater_bound(1) = dater_bound(2)
+
+         tmpdate    = dater_bound(2)
+         date_incr  = rdttra(1)/2.0
+
+         CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+         dater = tmpdate
+         CALL PRISM_calc_newdate ( tmpdate, date_incr, ierror )
+         dater_bound(2) = tmpdate
+
+         ncount = 0
+
+      ENDIF
+
+   END SUBROUTINE cpl_prism_recv
+
+
+
+   SUBROUTINE cpl_prism_finalize
+
+      IMPLICIT NONE
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_finalize  ***
+      !!
+      !! ** Purpose : - Finalizes the coupling. If MPI_init has not been
+      !!      called explicitly before cpl_prism_init it will also close
+      !!      MPI communication.
+      !!
+      !! ** Method  : OASIS4
+      !!----------------------------------------------------------------------
+
+      DEALLOCATE(exfld)
+
+      if ( prism_was_initialized ) then
+
+         call prism_terminated ( prism_was_terminated, ierror )
+         
+         if ( prism_was_terminated ) then
+            print *, 'prism has already been terminated.'
+         else
+            call prism_terminate ( ierror )
+            prism_was_terminated = .true.
+         endif
+
+      else
+
+         print *, 'Initialize prism before terminating it.'
+
+      endif
+
+
+   END SUBROUTINE cpl_prism_finalize
+
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default case           Dummy module         forced Ocean/Atmosphere
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE cpl_prism_init             ! Dummy routine
+   END SUBROUTINE cpl_prism_init
+   SUBROUTINE cpl_prism_define           ! Dummy routine
+   END SUBROUTINE cpl_prism_define
+   SUBROUTINE cpl_prism_send             ! Dummy routine
+   END SUBROUTINE cpl_prism_send
+   SUBROUTINE cpl_prism_recv             ! Dummy routine
+   END SUBROUTINE cpl_prism_recv
+   SUBROUTINE cpl_prism_finalize         ! Dummy routine
+   END SUBROUTINE cpl_prism_finalize
+
+#endif
+
+END MODULE cpl_oasis4
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/fldread.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/fldread.F90	(revision 1844)
@@ -0,0 +1,1001 @@
+MODULE fldread
+   !!======================================================================
+   !!                       ***  MODULE  fldread  ***
+   !! Ocean forcing:  read input field for surface boundary condition
+   !!=====================================================================
+   !! History :  9.0  !  06-06  (G. Madec) Original code
+   !!                 !  05-08  (S. Alderson) Modified for Interpolation in memory
+   !!                 !         from input grid to model grid
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   fld_read      : read input fields used for the computation of the
+   !!                   surface boundary condition
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! ???
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O manager library
+   USE geo2ocean       ! for vector rotation on to model grid
+
+   IMPLICIT NONE
+   PRIVATE   
+
+   TYPE, PUBLIC ::   FLD_N      !: Namelist field informations
+      CHARACTER(len = 256) ::   clname      ! generic name of the NetCDF flux file
+      INTEGER              ::   nfreqh      ! frequency of each flux file
+      CHARACTER(len = 34)  ::   clvar       ! generic name of the variable in the NetCDF flux file
+      LOGICAL              ::   ln_tint     ! time interpolation or not (T/F)
+      LOGICAL              ::   ln_clim     ! climatology or not (T/F)
+      CHARACTER(len = 7)   ::   cltype      ! type of data file 'daily', 'monthly' or yearly'
+      CHARACTER(len = 34)  ::   wname       ! generic name of a NetCDF weights file to be used, blank if not
+      CHARACTER(len = 34)  ::   vcomp       ! symbolic component name if a vector that needs rotation
+                                           ! a string starting with "U" or "V" for each component   
+                                           ! chars 2 onwards identify which components go together  
+   END TYPE FLD_N
+
+   TYPE, PUBLIC ::   FLD        !: Input field related variables
+      CHARACTER(len = 256)            ::   clrootname   ! generic name of the NetCDF file
+      CHARACTER(len = 256)            ::   clname       ! current name of the NetCDF file
+      INTEGER                         ::   nfreqh       ! frequency of each flux file
+      CHARACTER(len = 34)             ::   clvar        ! generic name of the variable in the NetCDF flux file
+      LOGICAL                         ::   ln_tint      ! time interpolation or not (T/F)
+      LOGICAL                         ::   ln_clim      ! climatology or not (T/F)
+      CHARACTER(len = 7)              ::   cltype       ! type of data file 'daily', 'monthly' or yearly'
+      INTEGER                         ::   num          ! iom id of the jpfld files to be read
+      INTEGER                         ::   nswap_sec    ! swapping time in second since Jan. 1st 00h of nit000 year
+      INTEGER , DIMENSION(2)          ::   nrec_b       ! before record (1: index, 2: second since Jan. 1st 00h of nit000 year)
+      INTEGER , DIMENSION(2)          ::   nrec_a       ! after  record (1: index, 2: second since Jan. 1st 00h of nit000 year)
+      REAL(wp) , ALLOCATABLE, DIMENSION(:,:)   ::   fnow         ! input fields interpolated to now time step
+      REAL(wp) , ALLOCATABLE, DIMENSION(:,:,:) ::   fdta         ! 2 consecutive record of input fields
+      CHARACTER(len = 256)            ::   wgtname      ! current name of the NetCDF weight file acting as a key
+                                                        ! into the WGTLIST structure
+      CHARACTER(len = 34)             ::   vcomp        ! symbolic name for a vector component that needs rotation
+      LOGICAL ,  DIMENSION(2)         ::   rotn         ! flag to indicate whether field has been rotated
+   END TYPE FLD
+
+!$AGRIF_DO_NOT_TREAT
+
+   !! keep list of all weights variables so they're only read in once
+   !! need to add AGRIF directives not to process this structure
+   !! also need to force wgtname to include AGRIF nest number
+   TYPE         ::   WGT        !: Input weights related variables
+      CHARACTER(len = 256)                    ::   wgtname      ! current name of the NetCDF weight file
+      INTEGER , DIMENSION(2)                  ::   ddims        ! shape of input grid
+      INTEGER , DIMENSION(2)                  ::   botleft      ! top left corner of box in input grid containing 
+                                                                ! current processor grid
+      INTEGER , DIMENSION(2)                  ::   topright     ! top right corner of box 
+      INTEGER                                 ::   jpiwgt       ! width of box on input grid
+      INTEGER                                 ::   jpjwgt       ! height of box on input grid
+      INTEGER                                 ::   numwgt       ! number of weights (4=bilinear, 16=bicubic)
+      INTEGER                                 ::   nestid       ! for agrif, keep track of nest we're in
+      INTEGER                                 ::   offset       ! =0 when cyclic grid has coincident first/last columns, 
+                                                                ! =1 when they assumed to be one grid spacing apart      
+                                                                ! =-1 otherwise
+      LOGICAL                                 ::   cyclic       ! east-west cyclic or not
+      INTEGER, DIMENSION(:,:,:), POINTER      ::   data_jpi     ! array of source integers
+      INTEGER, DIMENSION(:,:,:), POINTER      ::   data_jpj     ! array of source integers
+      REAL(wp), DIMENSION(:,:,:), POINTER     ::   data_wgt     ! array of weights on model grid
+      REAL(wp), DIMENSION(:,:), POINTER       ::   fly_dta      ! array of values on input grid
+      REAL(wp), DIMENSION(:,:), POINTER       ::   col2         ! temporary array for reading in columns
+   END TYPE WGT
+
+   INTEGER,     PARAMETER             ::   tot_wgts = 10
+   TYPE( WGT ), DIMENSION(tot_wgts)   ::   ref_wgts     ! array of wgts
+   INTEGER                            ::   nxt_wgt = 1  ! point to next available space in ref_wgts array
+
+!$AGRIF_END_DO_NOT_TREAT
+
+   PUBLIC   fld_read, fld_fill   ! called by sbc... modules
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE fld_read( kt, kn_fsbc, sd )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_read  ***
+      !!                   
+      !! ** Purpose :   provide at each time step the surface ocean fluxes
+      !!                (momentum, heat, freshwater and runoff) 
+      !!
+      !! ** Method  :   READ each input fields in NetCDF files using IOM
+      !!      and intepolate it to the model time-step.
+      !!         Several assumptions are made on the input file:
+      !!      blahblahblah....
+      !!----------------------------------------------------------------------
+      INTEGER  , INTENT(in   )               ::   kt        ! ocean time step
+      INTEGER  , INTENT(in   )               ::   kn_fsbc   ! sbc computation period (in time step) 
+      TYPE(FLD), INTENT(inout), DIMENSION(:) ::   sd        ! input field related variables
+      !!
+      CHARACTER (LEN=34)                     ::   acomp     ! dummy weight name
+      INTEGER                                ::   kf, nf    ! dummy indices
+      INTEGER                                ::   imf       ! size of the structure sd
+      REAL(wp), DIMENSION(jpi,jpj)           ::   utmp, vtmp! temporary arrays for vector rotation
+
+      INTEGER  ::   jf         ! dummy indices
+      INTEGER  ::   kw         ! index into wgts array
+      INTEGER  ::   ireclast   ! last record to be read in the current year file
+      INTEGER  ::   isecend    ! number of second since Jan. 1st 00h of nit000 year at nitend
+      LOGICAL  ::   llnxtyr    ! open next year  file?
+      LOGICAL  ::   llnxtmth   ! open next month file?
+      LOGICAL  ::   llstop     ! stop is the file does not exist
+      REAL(wp) ::   ztinta     ! ratio applied to after  records when doing time interpolation
+      REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
+      CHARACTER(LEN=1000) ::   clfmt   ! write format
+      !!---------------------------------------------------------------------
+      !
+      imf = SIZE( sd )
+      !                                         ! ===================== !
+      DO jf = 1, imf                            !    LOOP OVER FIELD    !
+         !                                      ! ===================== !
+         !
+         IF( kt == nit000 )   CALL fld_init( sd(jf) )
+         !
+         ! read/update the after data?
+         IF( nsec_year + nsec1jan000 > sd(jf)%nswap_sec ) THEN 
+
+            IF( sd(jf)%ln_tint ) THEN         ! time interpolation: swap before record field
+!CDIR COLLAPSE
+               sd(jf)%fdta(:,:,1) = sd(jf)%fdta(:,:,2)
+               sd(jf)%rotn(1)     = sd(jf)%rotn(2)
+            ENDIF
+
+            ! update record informations
+            CALL fld_rec( sd(jf) )
+
+            ! do we have to change the year/month/day of the forcing field?? 
+            IF( sd(jf)%ln_tint ) THEN
+               ! if we do time interpolation we will need to open next year/month/day file before the end of the current one
+               ! if so, we are still before the end of the year/month/day when calling fld_rec so sd(jf)%nrec_a(1) will be
+               ! larger than the record number that should be read for current year/month/day (for ex. 13 for monthly mean file)
+
+               ! last record to be read in the current file
+               IF( sd(jf)%nfreqh == -1 ) THEN                  ;   ireclast = 12
+               ELSE                             
+                  IF(     sd(jf)%cltype == 'monthly'   ) THEN  ;   ireclast = 24 * nmonth_len(nmonth) / sd(jf)%nfreqh 
+                  ELSEIF( sd(jf)%cltype == 'daily'     ) THEN  ;   ireclast = 24                      / sd(jf)%nfreqh
+                  ELSE                                         ;   ireclast = 24 * nyear_len(     1 ) / sd(jf)%nfreqh 
+                  ENDIF
+               ENDIF
+              
+               ! do we need next file data?
+               IF( sd(jf)%nrec_a(1) > ireclast ) THEN
+
+                  sd(jf)%nrec_a(1) = 1              ! force to read the first record of the next file
+
+                  IF( .NOT. sd(jf)%ln_clim ) THEN   ! close the current file and open a new one.
+
+                     llnxtmth = sd(jf)%cltype == 'monthly' .OR. nday == nmonth_len(nmonth)      ! open next month file?
+                     llnxtyr  = sd(jf)%cltype == 'yearly'  .OR. (nmonth == 12 .AND. llnxtmth)   ! open next year  file?
+
+                     ! if the run finishes at the end of the current year/month/day, we will allow next year/month/day file to be
+                     ! not present. If the run continue further than the current year/month/day, next year/month/day file must exist
+                     isecend = nsec_year + nsec1jan000 + (nitend - kt) * NINT(rdttra(1))   ! second at the end of the run 
+                     llstop = isecend > sd(jf)%nswap_sec                                   ! read more than 1 record of next year
+
+                     CALL fld_clopn( sd(jf), nyear  + COUNT((/llnxtyr /))                                           ,         &
+                        &                    nmonth + COUNT((/llnxtmth/)) - 12                 * COUNT((/llnxtyr /)),         &
+                        &                    nday   + 1                   - nmonth_len(nmonth) * COUNT((/llnxtmth/)), llstop )
+
+                     IF( sd(jf)%num <= 0 .AND. .NOT. llstop ) THEN    ! next year file does not exist
+                        CALL ctl_warn('next year/month/day file: '//TRIM(sd(jf)%clname)//     &
+                                &     ' not present -> back to current year/month/day')
+                        CALL fld_clopn( sd(jf), nyear, nmonth, nday )       ! back to the current year/month/day
+                        sd(jf)%nrec_a(1) = ireclast     ! force to read the last record to be read in the current year file
+                     ENDIF
+
+                  ENDIF 
+               ENDIF
+        
+            ELSE
+               ! if we are not doing time interpolation, we must change the year/month/day of the file just after switching
+               ! to the NEW year/month/day. If it is the case, we are at the beginning of the year/month/day when calling 
+               ! fld_rec so sd(jf)%nrec_a(1) = 1
+               IF( sd(jf)%nrec_a(1) == 1 .AND. .NOT. sd(jf)%ln_clim )   CALL fld_clopn( sd(jf), nyear, nmonth, nday )
+            ENDIF
+
+            ! read after data
+            IF( LEN(TRIM(sd(jf)%wgtname)) > 0 ) THEN
+               CALL wgt_list( sd(jf), kw )
+               CALL fld_interp( sd(jf)%num, sd(jf)%clvar, kw, sd(jf)%fdta(:,:,2), sd(jf)%nrec_a(1) )
+            ELSE
+               CALL iom_get( sd(jf)%num, jpdom_data, sd(jf)%clvar, sd(jf)%fdta(:,:,2), sd(jf)%nrec_a(1) )
+            ENDIF
+            sd(jf)%rotn(2) = .FALSE.
+
+         ENDIF
+         !                                      ! ===================== !
+      END DO                                    !  END LOOP OVER FIELD  !
+      !                                         ! ===================== !
+
+      IF( kt == nit000 .AND. lwp ) CALL wgt_print()
+
+      !! Vector fields may need to be rotated onto the local grid direction
+      !! This has to happen before the time interpolations
+      !! (sga: following code should be modified so that pairs arent searched for each time
+
+      DO jf = 1, imf
+         !! find vector rotations required 
+         IF( LEN(TRIM(sd(jf)%vcomp)) > 0 ) THEN
+             !! east-west component has symbolic name starting with 'U'
+             IF( sd(jf)%vcomp(1:1) == 'U' ) THEN
+                !! found an east-west component, look for the north-south component
+                !! which has same symbolic name but with 'U' replaced with 'V'
+                nf = LEN_TRIM( sd(jf)%vcomp )
+                IF( nf == 1) THEN
+                   acomp = 'V'
+                ELSE
+                   acomp = 'V' // sd(jf)%vcomp(2:nf)
+                ENDIF
+                kf = -1
+                DO nf = 1, imf
+                  IF( TRIM(sd(nf)%vcomp) == TRIM(acomp) ) kf = nf
+                END DO
+                IF( kf > 0 ) THEN
+                   !! fields jf,kf are two components which need to be rotated together
+                   DO nf = 1,2
+                      !! check each time level of this pair
+                      IF( .NOT. sd(jf)%rotn(nf) .AND. .NOT. sd(kf)%rotn(nf) ) THEN
+                         utmp(:,:) = 0.0
+                         vtmp(:,:) = 0.0
+                         CALL rot_rep( sd(jf)%fdta(:,:,nf), sd(kf)%fdta(:,:,nf), 'T', 'en->i', utmp(:,:) )
+                         CALL rot_rep( sd(jf)%fdta(:,:,nf), sd(kf)%fdta(:,:,nf), 'T', 'en->j', vtmp(:,:) )
+                         sd(jf)%fdta(:,:,nf) = utmp(:,:)
+                         sd(kf)%fdta(:,:,nf) = vtmp(:,:)
+                         sd(jf)%rotn(nf) = .TRUE.
+                         sd(kf)%rotn(nf) = .TRUE.
+                         IF( lwp .AND. kt == nit000 ) &
+                                   WRITE(numout,*) 'fld_read: vector pair (',  &
+                                                   TRIM(sd(jf)%clvar),',',TRIM(sd(kf)%clvar), &
+                                                   ') rotated on to model grid'
+                      ENDIF
+                   END DO
+                ENDIF
+             ENDIF
+         ENDIF
+      END DO
+
+      !                                         ! ===================== !
+      DO jf = 1, imf                            !    LOOP OVER FIELD    !
+         !                                      ! ===================== !
+         !
+         ! update field at each kn_fsbc time-step
+         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN   
+            !
+            IF( sd(jf)%ln_tint ) THEN
+               IF(lwp .AND. kt - nit000 <= 100 ) THEN 
+                  clfmt = "('fld_read: var ', a, ' kt = ', i8,' Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   &
+                     &    "' records b/a: ', i4.4, '/', i4.4, ' (', f7.2,'/', f7.2, ' days)')"
+                  WRITE(numout, clfmt)  TRIM( sd(jf)%clvar ), kt, nyear, nmonth, nday,   &
+                     & sd(jf)%nrec_b(1), sd(jf)%nrec_a(1), REAL(sd(jf)%nrec_b(2),wp)/rday, REAL(sd(jf)%nrec_a(2),wp)/rday
+               ENDIF
+               !
+               ztinta =  REAL( nsec_year + nsec1jan000 - sd(jf)%nrec_b(2), wp ) / REAL( sd(jf)%nrec_a(2) - sd(jf)%nrec_b(2), wp )
+               ztintb =  1. - ztinta
+!CDIR COLLAPSE
+               sd(jf)%fnow(:,:) = ztintb * sd(jf)%fdta(:,:,1) + ztinta * sd(jf)%fdta(:,:,2)
+            ELSE
+               IF(lwp .AND. kt - nit000 <= 100 ) THEN
+                  clfmt = "('fld_read: var ', a, ' kt = ', i8,' Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   &
+                     &    "' record: ', i4.4, ' at ', f7.2, ' day')"
+                  WRITE(numout, clfmt) TRIM(sd(jf)%clvar), kt, nyear, nmonth, nday, sd(jf)%nrec_a(1), REAL(sd(jf)%nrec_a(2),wp)/rday
+               ENDIF
+!CDIR COLLAPSE
+               sd(jf)%fnow(:,:) = sd(jf)%fdta(:,:,2)   ! piecewise constant field
+ 
+            ENDIF
+            !
+         ENDIF
+
+         IF( kt == nitend )   CALL iom_close( sd(jf)%num )   ! Close the input files
+
+         !                                      ! ===================== !
+      END DO                                    !  END LOOP OVER FIELD  !
+      !                                         ! ===================== !
+   END SUBROUTINE fld_read
+
+
+   SUBROUTINE fld_init( sdjf )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_init  ***
+      !!
+      !! ** Purpose :  - if time interpolation, read before data 
+      !!               - open current year file
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE(FLD), INTENT(inout) ::   sdjf        ! input field related variables
+      !!
+      LOGICAL :: llprevyr       ! are we reading previous year  file?
+      LOGICAL :: llprevmth      ! are we reading previous month file?
+      LOGICAL :: llprevday      ! are we reading previous day   file?
+      LOGICAL :: llprev         ! llprevyr .OR. llprevmth .OR. llprevday
+      INTEGER :: idvar          ! variable id 
+      INTEGER :: inrec          ! number of record existing for this variable
+      INTEGER :: kwgt
+      CHARACTER(LEN=1000) ::   clfmt   ! write format
+      !!---------------------------------------------------------------------
+
+      ! some default definitions...
+      sdjf%num = 0   ! default definition for non-opened file
+      IF( sdjf%ln_clim )   sdjf%clname = TRIM( sdjf%clrootname )   ! file name defaut definition, never change in this case
+      llprevyr  = .FALSE.
+      llprevmth = .FALSE.
+      llprevday = .FALSE.
+            
+      ! define record informations
+      CALL fld_rec( sdjf )
+
+      IF( sdjf%ln_tint ) THEN ! we need to read the previous record and we will put it in the current record structure
+         
+         IF( sdjf%nrec_b(1) == 0  ) THEN   ! we redefine record sdjf%nrec_b(1) with the last record of previous year file
+            IF( sdjf%nfreqh == -1 ) THEN   ! monthly mean
+               IF( sdjf%cltype == 'monthly' ) THEN   ! monthly file
+                  sdjf%nrec_b(1) = 1                                                       ! force to read the unique record
+                  llprevmth = .NOT. sdjf%ln_clim                                           ! use previous month file?
+                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
+               ELSE                                  ! yearly file
+                  sdjf%nrec_b(1) = 12                                                      ! force to read december mean
+                  llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
+               ENDIF
+            ELSE   
+               IF( sdjf%cltype == 'monthly' ) THEN   ! monthly file
+                  sdjf%nrec_b(1) = 24 * nmonth_len(nmonth-1) / sdjf%nfreqh                 ! last record of previous month
+                  llprevmth = .NOT. sdjf%ln_clim                                           ! use previous month file?
+                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
+               ELSEIF( sdjf%cltype == 'daily' ) THEN ! daily file
+                  sdjf%nrec_b(1) = 24 / sdjf%nfreqh                                        ! last record of previous day
+                  llprevday = .NOT. sdjf%ln_clim                                           ! use previous day   file?
+                  llprevmth = llprevday .AND. nday   == 1                                  ! use previous month file?
+                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
+               ELSE                                  ! yearly file
+                  sdjf%nrec_b(1) = 24 * nyear_len(0) / sdjf%nfreqh                         ! last record of year month
+                  llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
+               ENDIF
+            ENDIF
+         ENDIF
+         llprev = llprevyr .OR. llprevmth .OR. llprevday
+
+         CALL fld_clopn( sdjf, nyear  - COUNT((/llprevyr /))                                              ,               &
+            &                  nmonth - COUNT((/llprevmth/)) + 12                   * COUNT((/llprevyr /)),               &
+            &                  nday   - COUNT((/llprevday/)) + nmonth_len(nmonth-1) * COUNT((/llprevmth/)), .NOT. llprev )
+         
+         ! if previous year/month/day file does not exist, we switch to the current year/month/day
+         IF( llprev .AND. sdjf%num <= 0 ) THEN
+            CALL ctl_warn( 'previous year/month/day file: '//TRIM(sdjf%clname)//' not present -> back to current year/month/day')
+            ! we force to read the first record of the current year/month/day instead of last record of previous year/month/day
+            llprev = .false.
+            sdjf%nrec_b(1) = 1
+            CALL fld_clopn( sdjf, nyear, nmonth, nday )
+         ENDIF
+         
+         IF( llprev ) THEN   ! check if the last record sdjf%nrec_n(1) exists in the file
+            idvar = iom_varid( sdjf%num, sdjf%clvar )                                        ! id of the variable sdjf%clvar
+            IF( idvar <= 0 )   RETURN
+            inrec = iom_file( sdjf%num )%dimsz( iom_file( sdjf%num )%ndims(idvar), idvar )   ! size of the last dim of idvar
+            sdjf%nrec_b(1) = MIN( sdjf%nrec_b(1), inrec )   ! make sure we select an existing record
+         ENDIF
+
+         ! read before data into sdjf%fdta(:,:,2) because we will swap data in the following part of fld_read
+         IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN
+            CALL wgt_list( sdjf, kwgt )
+            CALL fld_interp( sdjf%num, sdjf%clvar, kwgt, sdjf%fdta(:,:,2), sdjf%nrec_b(1) )
+         ELSE
+            CALL iom_get( sdjf%num, jpdom_data, sdjf%clvar, sdjf%fdta(:,:,2), sdjf%nrec_b(1) )
+         ENDIF
+         sdjf%rotn(2) = .FALSE.
+
+         clfmt = "('fld_init : time-interpolation for ', a, ' read previous record = ', i4, ' at time = ', f7.2, ' days')"
+         IF(lwp) WRITE(numout, clfmt) TRIM(sdjf%clvar), sdjf%nrec_b(1), REAL(sdjf%nrec_b(2),wp)/rday
+
+         IF( llprev )   CALL iom_close( sdjf%num )   ! close previous year file (-> redefine sdjf%num to 0)
+
+      ENDIF
+
+      IF( sdjf%num <= 0 )   CALL fld_clopn( sdjf, nyear, nmonth, nday )   ! make sure current year/month/day file is opened
+
+      sdjf%nswap_sec = nsec_year + nsec1jan000 - 1   ! force read/update the after data in the following part of fld_read 
+      
+   END SUBROUTINE fld_init
+
+
+   SUBROUTINE fld_rec( sdjf )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_rec  ***
+      !!
+      !! ** Purpose :   compute nrec_a, nrec_b and nswap_sec
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE(FLD), INTENT(inout) ::   sdjf        ! input field related variables
+      !!
+      INTEGER  ::   irec        ! record number
+      INTEGER  ::   isecd       ! rday
+      REAL(wp) ::   ztmp        ! temporary variable
+      INTEGER  ::   ifreq_sec   ! frequency mean (in seconds)
+      !!----------------------------------------------------------------------
+      !
+      IF( sdjf%nfreqh == -1 ) THEN      ! monthly mean
+         !
+         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
+            !
+            !                  INT( ztmp )
+            !                     /|\
+            !                    1 |    *----
+            !                    0 |----(              
+            !                      |----+----|--> time
+            !                      0   /|\   1   (nday/nmonth_len(nmonth))
+            !                           |   
+            !                           |   
+            !       forcing record :  nmonth 
+            !                            
+            ztmp  = REAL( nday, wp ) / REAL( nmonth_len(nmonth), wp ) + 0.5
+         ELSE
+            ztmp  = 0.e0
+         ENDIF
+         irec = nmonth + INT( ztmp )
+
+         IF( sdjf%ln_tint ) THEN   ;   sdjf%nswap_sec = nmonth_half(irec) + nsec1jan000   ! swap at the middle of the month
+         ELSE                      ;   sdjf%nswap_sec = nmonth_end (irec) + nsec1jan000   ! swap at the end    of the month
+         ENDIF
+
+         sdjf%nrec_a(:) = (/ irec, nmonth_half(irec) + nsec1jan000 /)   ! define after  record number and time
+         irec = irec - 1                                                ! move back to previous record
+         sdjf%nrec_b(:) = (/ irec, nmonth_half(irec) + nsec1jan000 /)   ! define before record number and time
+         !
+      ELSE                              ! higher frequency mean (in hours)
+         !
+         ifreq_sec = sdjf%nfreqh * 3600   ! frequency mean (in seconds)
+         ! number of second since the beginning of the file
+         IF(     sdjf%cltype == 'monthly' ) THEN   ;   ztmp = REAL(nsec_month,wp)   ! since 00h on the 1st day of the current month
+         ELSEIF( sdjf%cltype == 'daily'   ) THEN   ;   ztmp = REAL(nsec_day  ,wp)   ! since 00h of the current day
+         ELSE                                      ;   ztmp = REAL(nsec_year ,wp)   ! since 00h on Jan 1 of the current year
+         ENDIF
+         IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record
+            !
+            !                  INT( ztmp )
+            !                     /|\
+            !                    2 |        *-----(
+            !                    1 |  *-----(
+            !                    0 |--(              
+            !                      |--+--|--+--|--+--|--> time
+            !                      0 /|\ 1 /|\ 2 /|\ 3 (nsec_year/ifreq_sec) or (nsec_month/ifreq_sec)
+            !                         |     |     |
+            !                         |     |     |
+            !       forcing record :  1     2     3
+            !                   
+            ztmp= ztmp / ifreq_sec + 0.5
+         ELSE                 
+            !
+            !                  INT( ztmp )
+            !                     /|\
+            !                    2 |           *-----(
+            !                    1 |     *-----(
+            !                    0 |-----(              
+            !                      |--+--|--+--|--+--|--> time
+            !                      0 /|\ 1 /|\ 2 /|\ 3 (nsec_year/ifreq_sec) or (nsec_month/ifreq_sec)
+            !                         |     |     |
+            !                         |     |     |
+            !       forcing record :  1     2     3
+            !                            
+            ztmp= ztmp / ifreq_sec
+         ENDIF
+         irec = 1 + INT( ztmp )
+
+         isecd = NINT(rday)
+         ! after record index and second since Jan. 1st 00h of nit000 year
+         sdjf%nrec_a(:) = (/ irec, ifreq_sec * irec - ifreq_sec / 2 + nsec1jan000 /)
+         IF( sdjf%cltype == 'monthly' )   &   ! add the number of seconds between 00h Jan 1 and the end of previous month
+            sdjf%nrec_a(2) = sdjf%nrec_a(2) + isecd * SUM(nmonth_len(1:nmonth -1))   ! ok if nmonth=1
+         IF( sdjf%cltype == 'daily'   )   &   ! add the number of seconds between 00h Jan 1 and the end of previous day
+            sdjf%nrec_a(2) = sdjf%nrec_a(2) + isecd * ( nday_year - 1 )
+
+         ! before record index and second since Jan. 1st 00h of nit000 year
+         irec = irec - 1.                           ! move back to previous record
+         sdjf%nrec_b(:) = (/ irec, ifreq_sec * irec - ifreq_sec / 2 + nsec1jan000 /)
+         IF( sdjf%cltype == 'monthly' )   &   ! add the number of seconds between 00h Jan 1 and the end of previous month
+            sdjf%nrec_b(2) = sdjf%nrec_b(2) + isecd * SUM(nmonth_len(1:nmonth -1))   ! ok if nmonth=1
+         IF( sdjf%cltype == 'daily'   )   &   ! add the number of seconds between 00h Jan 1 and the end of previous day
+            sdjf%nrec_b(2) = sdjf%nrec_b(2) + isecd * ( nday_year - 1 )
+
+         ! swapping time in second since Jan. 1st 00h of nit000 year
+         IF( sdjf%ln_tint ) THEN   ;   sdjf%nswap_sec =  sdjf%nrec_a(2)                     ! swap at the middle of the record
+         ELSE                      ;   sdjf%nswap_sec =  sdjf%nrec_a(2) + ifreq_sec / 2     ! swap at the end    of the record
+         ENDIF       
+         !
+      ENDIF
+      !
+   END SUBROUTINE fld_rec
+
+
+   SUBROUTINE fld_clopn( sdjf, kyear, kmonth, kday, ldstop )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_clopn  ***
+      !!
+      !! ** Purpose :   update the file name and open the file
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE(FLD), INTENT(inout)           ::   sdjf     ! input field related variables
+      INTEGER  , INTENT(in   )           ::   kyear    ! year value
+      INTEGER  , INTENT(in   )           ::   kmonth   ! month value
+      INTEGER  , INTENT(in   )           ::   kday     ! day value
+      LOGICAL  , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
+
+      IF( sdjf%num /= 0 )   CALL iom_close( sdjf%num )   ! close file if already open
+      ! build the new filename if not climatological data
+      IF( .NOT. sdjf%ln_clim ) THEN   ;   WRITE(sdjf%clname, '(a,"_y",i4.4)' ) TRIM( sdjf%clrootname ), kyear    ! add year
+         IF( sdjf%cltype /= 'yearly' )    WRITE(sdjf%clname, '(a,"m" ,i2.2)' ) TRIM( sdjf%clname     ), kmonth   ! add month
+         IF( sdjf%cltype == 'daily'  )    WRITE(sdjf%clname, '(a,"d" ,i2.2)' ) TRIM( sdjf%clname     ), kday     ! add day
+      ENDIF
+      CALL iom_open( sdjf%clname, sdjf%num, ldstop = ldstop, ldiof =  LEN(TRIM(sdjf%wgtname)) > 0 )
+      !
+   END SUBROUTINE fld_clopn
+
+
+   SUBROUTINE fld_fill( sdf, sdf_n, cdir, cdcaller, cdtitle, cdnam )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_fill  ***
+      !!
+      !! ** Purpose :   fill sdf with sdf_n and control print
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE(FLD)  , DIMENSION(:), INTENT(inout) ::   sdf        ! structure of input fields (file informations, fields read)
+      TYPE(FLD_N), DIMENSION(:), INTENT(in   ) ::   sdf_n      ! array of namelist information structures
+      CHARACTER(len=*)         , INTENT(in   ) ::   cdir       ! Root directory for location of flx files
+      CHARACTER(len=*)         , INTENT(in   ) ::   cdcaller   ! 
+      CHARACTER(len=*)         , INTENT(in   ) ::   cdtitle    ! 
+      CHARACTER(len=*)         , INTENT(in   ) ::   cdnam      ! 
+      !
+      INTEGER  ::   jf       ! dummy indices
+      !!---------------------------------------------------------------------
+
+      DO jf = 1, SIZE(sdf)
+         sdf(jf)%clrootname = TRIM( cdir )//TRIM( sdf_n(jf)%clname )
+         sdf(jf)%nfreqh     = sdf_n(jf)%nfreqh
+         sdf(jf)%clvar      = sdf_n(jf)%clvar
+         sdf(jf)%ln_tint    = sdf_n(jf)%ln_tint
+         sdf(jf)%ln_clim    = sdf_n(jf)%ln_clim
+         IF( sdf(jf)%nfreqh == -1. ) THEN   ;   sdf(jf)%cltype = 'yearly'
+         ELSE                               ;   sdf(jf)%cltype = sdf_n(jf)%cltype
+         ENDIF
+         sdf(jf)%wgtname = " "
+         IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//TRIM( sdf_n(jf)%wname )
+         sdf(jf)%vcomp   = sdf_n(jf)%vcomp
+      END DO
+
+      IF(lwp) THEN      ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) TRIM( cdcaller )//' : '//TRIM( cdtitle )
+         WRITE(numout,*) (/ ('~', jf = 1, LEN_TRIM( cdcaller ) ) /)
+         WRITE(numout,*) '          '//TRIM( cdnam )//' Namelist'
+         WRITE(numout,*) '          list of files and frequency (>0: in hours ; <0 in months)'
+         DO jf = 1, SIZE(sdf)
+            WRITE(numout,*) '               root filename: '  , TRIM( sdf(jf)%clrootname ),   &
+               &                          ' variable name: '  , TRIM( sdf(jf)%clvar      )
+            WRITE(numout,*) '               frequency: '      ,       sdf(jf)%nfreqh      ,   &
+               &                          ' time interp: '    ,       sdf(jf)%ln_tint     ,   &
+               &                          ' climatology: '    ,       sdf(jf)%ln_clim     ,   &
+               &                          ' weights    : '    , TRIM( sdf(jf)%wgtname    ),   &
+               &                          ' pairing    : '    , TRIM( sdf(jf)%vcomp      ),   &
+               &                          ' data type: '      ,       sdf(jf)%cltype
+         END DO
+      ENDIF
+      
+   END SUBROUTINE fld_fill
+
+
+   SUBROUTINE wgt_list( sd, kwgt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE wgt_list  ***
+      !!
+      !! ** Purpose :   search array of WGTs and find a weights file
+      !!                entry, or return a new one adding it to the end
+      !!                if it is a new entry, the weights data is read in and
+      !!                restructured (fld_weight)
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE( FLD ),      INTENT(in)    ::   sd        ! field with name of weights file
+      INTEGER,      INTENT(inout)     ::   kwgt      ! index of weights
+      !!
+      INTEGER                         ::   kw
+      INTEGER                         ::   nestid
+      LOGICAL                         ::   found
+      !!----------------------------------------------------------------------
+      !
+      !! search down linked list 
+      !! weights filename is either present or we hit the end of the list
+      found = .FALSE.
+
+      !! because agrif nest part of filenames are now added in iom_open
+      !! to distinguish between weights files on the different grids, need to track
+      !! nest number explicitly
+      nestid = 0
+#if defined key_agrif
+      nestid = Agrif_Fixed()
+#endif
+      DO kw = 1, nxt_wgt-1
+         IF( TRIM(ref_wgts(kw)%wgtname) == TRIM(sd%wgtname) .AND. &
+             ref_wgts(kw)%nestid == nestid) THEN
+            kwgt = kw
+            found = .TRUE.
+            EXIT
+         ENDIF
+      END DO
+      IF( .NOT.found ) THEN
+         kwgt = nxt_wgt
+         CALL fld_weight( sd )
+      ENDIF
+
+   END SUBROUTINE wgt_list
+
+   SUBROUTINE wgt_print( )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE wgt_print  ***
+      !!
+      !! ** Purpose :   print the list of known weights
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      !!
+      INTEGER                         ::   kw
+      !!----------------------------------------------------------------------
+      !
+
+      DO kw = 1, nxt_wgt-1
+         WRITE(numout,*) 'weight file:  ',TRIM(ref_wgts(kw)%wgtname)
+         WRITE(numout,*) '      ddims:  ',ref_wgts(kw)%ddims(1),ref_wgts(kw)%ddims(2)
+         WRITE(numout,*) '     numwgt:  ',ref_wgts(kw)%numwgt
+         WRITE(numout,*) '     jpiwgt:  ',ref_wgts(kw)%jpiwgt
+         WRITE(numout,*) '     jpjwgt:  ',ref_wgts(kw)%jpjwgt
+         WRITE(numout,*) '    botleft:  ',ref_wgts(kw)%botleft
+         WRITE(numout,*) '   topright:  ',ref_wgts(kw)%topright
+         IF( ref_wgts(kw)%cyclic ) THEN
+            WRITE(numout,*) '       cyclical'
+            IF( ref_wgts(kw)%offset > 0 ) WRITE(numout,*) '                 with offset'
+         ELSE
+            WRITE(numout,*) '       not cyclical'
+         ENDIF
+         IF( ASSOCIATED(ref_wgts(kw)%data_wgt) )  WRITE(numout,*) '       allocated'
+      END DO
+
+   END SUBROUTINE wgt_print
+
+   SUBROUTINE fld_weight( sd )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_weight  ***
+      !!
+      !! ** Purpose :   create a new WGT structure and fill in data from  
+      !!                file, restructuring as required
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      TYPE( FLD ),      INTENT(in)            ::   sd            ! field with name of weights file
+      !!
+      INTEGER                                 ::   jn            ! dummy loop indices
+      INTEGER                                 ::   inum          ! temporary logical unit
+      INTEGER                                 ::   id            ! temporary variable id
+      CHARACTER (len=5)                       ::   aname
+      INTEGER , DIMENSION(3)                  ::   ddims
+      INTEGER , DIMENSION(jpi, jpj)           ::   data_src
+      REAL(wp), DIMENSION(jpi, jpj)           ::   data_tmp
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::   line2, lines  ! temporary array to read 2 lineumns
+      CHARACTER (len=34)                      ::   lonvar
+      LOGICAL                                 ::   cyclical
+      REAL(wp)                                ::   resid, dlon   ! temporary array to read 2 lineumns
+      INTEGER                                 ::   offset        ! temporary integer
+      !!----------------------------------------------------------------------
+      !
+      IF( nxt_wgt > tot_wgts ) THEN
+        CALL ctl_stop("fld_weights: weights array size exceeded, increase tot_wgts")
+      ENDIF
+      !
+      !! new weights file entry, add in extra information
+      !! a weights file represents a 2D grid of a certain shape, so we assume that the current
+      !! input data file is representative of all other files to be opened and processed with the
+      !! current weights file
+
+      !! open input data file (non-model grid)
+      CALL iom_open( sd%clname, inum, ldiof =  LEN(TRIM(sd%wgtname)) > 0 )
+
+      !! get dimensions
+      id = iom_varid( inum, sd%clvar, ddims )
+
+      !! check for an east-west cyclic grid
+      !! try to guess name of longitude variable
+
+      lonvar = 'nav_lon'
+      id = iom_varid(inum, TRIM(lonvar), ldstop=.FALSE.)
+      IF( id <= 0 ) THEN
+         lonvar = 'lon'
+         id = iom_varid(inum, TRIM(lonvar), ldstop=.FALSE.)
+      ENDIF
+
+      offset = -1
+      cyclical = .FALSE.
+      IF( id > 0 ) THEN
+         !! found a longitude variable
+         !! now going to assume that grid is regular so we can read a single row
+
+         !! because input array is 2d, have to present iom with 2d array even though we only need 1d slice
+         !! worse, we cant pass line2(:,1) to iom_get since this is treated as a 1d array which doesnt match input file
+         ALLOCATE( lines(ddims(1),2) )
+         CALL iom_get(inum, jpdom_unknown, lonvar, lines(:,:), 1, kstart=(/1,1/), kcount=(/ddims(1),2/) )
+
+         !! find largest grid spacing
+         lines(1:ddims(1)-1,2) = lines(2:ddims(1),1) - lines(1:ddims(1)-1,1)
+         dlon = MAXVAL( lines(1:ddims(1)-1,2) )
+
+         resid = ABS(ABS(lines(ddims(1),1)-lines(1,1))-360.0)
+         IF( resid < rsmall ) THEN
+            !! end rows overlap in longitude
+            offset = 0
+            cyclical = .TRUE.
+         ELSEIF( resid < 2.0*dlon ) THEN
+            !! also call it cyclic if difference between end points is less than twice dlon from 360
+            offset = 1
+            cyclical = .TRUE.
+         ENDIF
+
+         DEALLOCATE( lines )
+
+      ELSE
+         !! guessing failed
+         !! read in first and last columns of data variable
+         !! since we dont know the name of the longitude variable (or even if there is one)
+         !! we assume that if these two columns are equal, file is cyclic east-west
+
+         !! because input array is 2d, have to present iom with 2d array even though we only need 1d slice
+         !! worse, we cant pass line2(1,:) to iom_get since this is treated as a 1d array which doesnt match input file
+         ALLOCATE( lines(2,ddims(2)), line2(2,ddims(2)) )
+         CALL iom_get(inum, jpdom_unknown, sd%clvar, line2(:,:), 1, kstart=(/1,1/), kcount=(/2,ddims(2)/) )
+         lines(2,:) = line2(1,:)
+
+         CALL iom_get(inum, jpdom_unknown, sd%clvar, line2(:,:), 1, kstart=(/ddims(1)-1,1/), kcount=(/2,ddims(2)/) )
+         lines(1,:) = line2(2,:)
+
+         resid = SUM( ABS(lines(1,:) - lines(2,:)) )
+         IF( resid < ddims(2)*rsmall ) THEN
+            offset = 0
+            cyclical = .TRUE.
+         ENDIF
+
+         DEALLOCATE( lines, line2 )
+      ENDIF
+
+      !! close it
+      CALL iom_close( inum )
+
+      !! now open the weights file
+
+      CALL iom_open ( sd%wgtname, inum )   ! interpolation weights
+      IF ( inum > 0 ) THEN
+
+         ref_wgts(nxt_wgt)%ddims(1) = ddims(1)
+         ref_wgts(nxt_wgt)%ddims(2) = ddims(2)
+         ref_wgts(nxt_wgt)%wgtname = sd%wgtname
+         ref_wgts(nxt_wgt)%offset = -1
+         ref_wgts(nxt_wgt)%cyclic = .FALSE.
+         IF( cyclical ) THEN
+            ref_wgts(nxt_wgt)%offset = offset
+            ref_wgts(nxt_wgt)%cyclic = .TRUE.
+         ENDIF
+         ref_wgts(nxt_wgt)%nestid = 0
+#if defined key_agrif
+         ref_wgts(nxt_wgt)%nestid = Agrif_Fixed()
+#endif
+         !! weights file is stored as a set of weights (wgt01->wgt04 or wgt01->wgt16)
+         !! for each weight wgtNN there is an integer array srcNN which gives the point in
+         !! the input data grid which is to be multiplied by the weight
+         !! they are both arrays on the model grid so the result of the multiplication is
+         !! added into an output array on the model grid as a running sum
+
+         !! two possible cases: bilinear (4 weights) or bicubic (16 weights)
+         id = iom_varid(inum, 'src05', ldstop=.FALSE.)
+         IF( id <= 0) THEN
+            ref_wgts(nxt_wgt)%numwgt = 4
+         ELSE
+            ref_wgts(nxt_wgt)%numwgt = 16
+         ENDIF
+
+         ALLOCATE( ref_wgts(nxt_wgt)%data_jpi(jpi,jpj,4) )
+         ALLOCATE( ref_wgts(nxt_wgt)%data_jpj(jpi,jpj,4) )
+         ALLOCATE( ref_wgts(nxt_wgt)%data_wgt(jpi,jpj,ref_wgts(nxt_wgt)%numwgt) )
+
+         DO jn = 1,4
+            aname = ' '
+            WRITE(aname,'(a3,i2.2)') 'src',jn
+            data_tmp(:,:) = 0
+            CALL iom_get ( inum, jpdom_unknown, aname, data_tmp(1:nlci,1:nlcj), &
+                           kstart=(/nimpp,njmpp/), kcount=(/nlci,nlcj/) )
+            data_src(:,:) = INT(data_tmp(:,:))
+            ref_wgts(nxt_wgt)%data_jpj(:,:,jn) = 1 + (data_src(:,:)-1) / ref_wgts(nxt_wgt)%ddims(1)
+            ref_wgts(nxt_wgt)%data_jpi(:,:,jn) = data_src(:,:) - ref_wgts(nxt_wgt)%ddims(1)*(ref_wgts(nxt_wgt)%data_jpj(:,:,jn)-1)
+         END DO
+
+         DO jn = 1, ref_wgts(nxt_wgt)%numwgt
+            aname = ' '
+            WRITE(aname,'(a3,i2.2)') 'wgt',jn
+            ref_wgts(nxt_wgt)%data_wgt(1:nlci,1:nlcj,jn) = 0.0
+            CALL iom_get ( inum, jpdom_unknown, aname, ref_wgts(nxt_wgt)%data_wgt(1:nlci,1:nlcj,jn), &
+                           kstart=(/nimpp,njmpp/), kcount=(/nlci,nlcj/) )
+         END DO
+         CALL iom_close (inum)
+ 
+         ! find min and max indices in grid
+         ref_wgts(nxt_wgt)%botleft(1) = MINVAL(ref_wgts(nxt_wgt)%data_jpi(1:nlci,1:nlcj,:))
+         ref_wgts(nxt_wgt)%botleft(2) = MINVAL(ref_wgts(nxt_wgt)%data_jpj(1:nlci,1:nlcj,:))
+         ref_wgts(nxt_wgt)%topright(1) = MAXVAL(ref_wgts(nxt_wgt)%data_jpi(1:nlci,1:nlcj,:))
+         ref_wgts(nxt_wgt)%topright(2) = MAXVAL(ref_wgts(nxt_wgt)%data_jpj(1:nlci,1:nlcj,:))
+
+         ! and therefore dimensions of the input box
+         ref_wgts(nxt_wgt)%jpiwgt = ref_wgts(nxt_wgt)%topright(1) - ref_wgts(nxt_wgt)%botleft(1) + 1
+         ref_wgts(nxt_wgt)%jpjwgt = ref_wgts(nxt_wgt)%topright(2) - ref_wgts(nxt_wgt)%botleft(2) + 1
+
+         ! shift indexing of source grid
+         ref_wgts(nxt_wgt)%data_jpi(:,:,:) = ref_wgts(nxt_wgt)%data_jpi(:,:,:) - ref_wgts(nxt_wgt)%botleft(1) + 1
+         ref_wgts(nxt_wgt)%data_jpj(:,:,:) = ref_wgts(nxt_wgt)%data_jpj(:,:,:) - ref_wgts(nxt_wgt)%botleft(2) + 1
+
+         ! create input grid, give it a halo to allow gradient calculations
+         ! SA: +3 stencil is a patch to avoid out-of-bound computation in some configuration. 
+         ! a more robust solution will be given in next release
+         ALLOCATE( ref_wgts(nxt_wgt)%fly_dta(ref_wgts(nxt_wgt)%jpiwgt+3, ref_wgts(nxt_wgt)%jpjwgt+3) )
+         IF( ref_wgts(nxt_wgt)%cyclic ) ALLOCATE( ref_wgts(nxt_wgt)%col2(2,ref_wgts(nxt_wgt)%jpjwgt+3) )
+
+         nxt_wgt = nxt_wgt + 1
+
+      ELSE 
+         CALL ctl_stop( '    fld_weight : unable to read the file ' )
+      ENDIF
+
+   END SUBROUTINE fld_weight
+
+   SUBROUTINE fld_interp(num, clvar, kw, dta, nrec)
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_interp  ***
+      !!
+      !! ** Purpose :   apply weights to input gridded data to create data
+      !!                on model grid
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      INTEGER,          INTENT(in)                        ::   num                 ! stream number
+      CHARACTER(LEN=*), INTENT(in)                        ::   clvar               ! variable name
+      INTEGER,          INTENT(in)                        ::   kw                  ! weights number
+      REAL(wp),         INTENT(inout), DIMENSION(jpi,jpj) ::   dta                 ! output field on model grid
+      INTEGER,          INTENT(in)                        ::   nrec                ! record number to read (ie time slice)
+      !! 
+      INTEGER, DIMENSION(2)                               ::   rec1,recn           ! temporary arrays for start and length
+      INTEGER                                             ::  jk, jn, jm           ! loop counters
+      INTEGER                                             ::  ni, nj               ! lengths
+      INTEGER                                             ::  jpimin,jpiwid        ! temporary indices
+      INTEGER                                             ::  jpjmin,jpjwid        ! temporary indices
+      INTEGER                                             ::  jpi1,jpi2,jpj1,jpj2  ! temporary indices
+      !!----------------------------------------------------------------------
+      !
+
+      !! for weighted interpolation we have weights at four corners of a box surrounding 
+      !! a model grid point, each weight is multiplied by a grid value (bilinear case)
+      !! or by a grid value and gradients at the corner point (bicubic case) 
+      !! so we need to have a 4 by 4 subgrid surrounding each model point to cover both cases
+
+      !! sub grid where we already have weights
+      jpimin = ref_wgts(kw)%botleft(1)
+      jpjmin = ref_wgts(kw)%botleft(2)
+      jpiwid = ref_wgts(kw)%jpiwgt
+      jpjwid = ref_wgts(kw)%jpjwgt
+
+      !! what we need to read into sub grid in order to calculate gradients
+      rec1(1) = MAX( jpimin-1, 1 )
+      rec1(2) = MAX( jpjmin-1, 1 )
+      recn(1) = MIN( jpiwid+2, ref_wgts(kw)%ddims(1)-rec1(1)+1 )
+      recn(2) = MIN( jpjwid+2, ref_wgts(kw)%ddims(2)-rec1(2)+1 )
+
+      !! where we need to read it to
+      jpi1 = 2 + rec1(1) - jpimin
+      jpj1 = 2 + rec1(2) - jpjmin
+      jpi2 = jpi1 + recn(1) - 1
+      jpj2 = jpj1 + recn(2) - 1
+
+      ref_wgts(kw)%fly_dta(:,:) = 0.0
+      CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%fly_dta(jpi1:jpi2,jpj1:jpj2), nrec, rec1, recn)
+
+      !! first four weights common to both bilinear and bicubic
+      !! note that we have to offset by 1 into fly_dta array because of halo
+      dta(:,:) = 0.0
+      DO jk = 1,4
+        DO jn = 1, jpj
+          DO jm = 1,jpi
+            ni = ref_wgts(kw)%data_jpi(jm,jn,jk)
+            nj = ref_wgts(kw)%data_jpj(jm,jn,jk)
+            dta(jm,jn) = dta(jm,jn) + ref_wgts(kw)%data_wgt(jm,jn,jk) * ref_wgts(kw)%fly_dta(ni+1,nj+1)
+          END DO
+        END DO
+      END DO
+
+      IF (ref_wgts(kw)%numwgt .EQ. 16) THEN
+
+        !! fix up halo points that we couldnt read from file
+        IF( jpi1 == 2 ) THEN
+           ref_wgts(kw)%fly_dta(jpi1-1,:) = ref_wgts(kw)%fly_dta(jpi1,:)
+        ENDIF
+        IF( jpi2 + jpimin - 1 == ref_wgts(kw)%ddims(1)+1 ) THEN
+           ref_wgts(kw)%fly_dta(jpi2+1,:) = ref_wgts(kw)%fly_dta(jpi2,:)
+        ENDIF
+        IF( jpj1 == 2 ) THEN
+           ref_wgts(kw)%fly_dta(:,jpj1-1) = ref_wgts(kw)%fly_dta(:,jpj1)
+        ENDIF
+        IF( jpj2 + jpjmin - 1 == ref_wgts(kw)%ddims(2)+1 .AND. jpj2 .lt. jpjwid+2 ) THEN
+           ref_wgts(kw)%fly_dta(:,jpj2+1) = 2.0*ref_wgts(kw)%fly_dta(:,jpj2) - ref_wgts(kw)%fly_dta(:,jpj2-1)
+        ENDIF
+
+        !! if data grid is cyclic we can do better on east-west edges
+        !! but have to allow for whether first and last columns are coincident
+        IF( ref_wgts(kw)%cyclic ) THEN
+           rec1(2) = MAX( jpjmin-1, 1 )
+           recn(1) = 2
+           recn(2) = MIN( jpjwid+2, ref_wgts(kw)%ddims(2)-rec1(2)+1 )
+           jpj1 = 2 + rec1(2) - jpjmin
+           jpj2 = jpj1 + recn(2) - 1
+           IF( jpi1 == 2 ) THEN
+              rec1(1) = ref_wgts(kw)%ddims(1) - 1
+              CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col2(:,jpj1:jpj2), nrec, rec1, recn)
+              ref_wgts(kw)%fly_dta(jpi1-1,jpj1:jpj2) = ref_wgts(kw)%col2(ref_wgts(kw)%offset+1,jpj1:jpj2)
+           ENDIF
+           IF( jpi2 + jpimin - 1 == ref_wgts(kw)%ddims(1)+1 ) THEN
+              rec1(1) = 1
+              CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col2(:,jpj1:jpj2), nrec, rec1, recn)
+              ref_wgts(kw)%fly_dta(jpi2+1,jpj1:jpj2) = ref_wgts(kw)%col2(2-ref_wgts(kw)%offset,jpj1:jpj2)
+           ENDIF
+        ENDIF
+
+        ! gradient in the i direction
+        DO jk = 1,4
+          DO jn = 1, jpj
+            DO jm = 1,jpi
+              ni = ref_wgts(kw)%data_jpi(jm,jn,jk)
+              nj = ref_wgts(kw)%data_jpj(jm,jn,jk)
+              dta(jm,jn) = dta(jm,jn) + ref_wgts(kw)%data_wgt(jm,jn,jk+4) * 0.5 *         &
+                               (ref_wgts(kw)%fly_dta(ni+2,nj+1) - ref_wgts(kw)%fly_dta(ni,nj+1))
+            END DO
+          END DO
+        END DO
+
+        ! gradient in the j direction
+        DO jk = 1,4
+          DO jn = 1, jpj
+            DO jm = 1,jpi
+              ni = ref_wgts(kw)%data_jpi(jm,jn,jk)
+              nj = ref_wgts(kw)%data_jpj(jm,jn,jk)
+              dta(jm,jn) = dta(jm,jn) + ref_wgts(kw)%data_wgt(jm,jn,jk+8) * 0.5 *         &
+                               (ref_wgts(kw)%fly_dta(ni+1,nj+2) - ref_wgts(kw)%fly_dta(ni+1,nj))
+            END DO
+          END DO
+        END DO
+
+        ! gradient in the ij direction
+        DO jk = 1,4
+          DO jn = 1, jpj
+            DO jm = 1,jpi
+              ni = ref_wgts(kw)%data_jpi(jm,jn,jk)
+              nj = ref_wgts(kw)%data_jpj(jm,jn,jk)
+              dta(jm,jn) = dta(jm,jn) + ref_wgts(kw)%data_wgt(jm,jn,jk+12) * 0.25 * ( &
+                               (ref_wgts(kw)%fly_dta(ni+2,nj+2) - ref_wgts(kw)%fly_dta(ni  ,nj+2)) -   &
+                               (ref_wgts(kw)%fly_dta(ni+2,nj  ) - ref_wgts(kw)%fly_dta(ni  ,nj  )))
+            END DO
+          END DO
+        END DO
+
+      END IF
+
+   END SUBROUTINE fld_interp
+  
+END MODULE fldread
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/geo2ocean.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 1844)
@@ -0,0 +1,525 @@
+MODULE geo2ocean
+   !!======================================================================
+   !!                     ***  MODULE  geo2ocean  ***
+   !! Ocean mesh    :  ???
+   !!======================================================================
+   !! History :  OPA  !  07-1996  (O. Marti)  Original code
+   !!   NEMO     1.0  !  02-2008  (G. Madec)  F90: Free form
+   !!            3.0  !  
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   repcmo      : 
+   !!   angle       :
+   !!   geo2oce     :
+   !!   repere      :   old routine suppress it ???
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! mesh and scale factors
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   rot_rep, repcmo, repere, geo2oce, oce2geo   ! only rot_rep should be used
+                                             ! repcmo and repere are keep only for compatibility.
+                                             ! they are only a useless overlay of rot_rep
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   &
+      gsint, gcost,   &  ! cos/sin between model grid lines and NP direction at T point
+      gsinu, gcosu,   &  ! cos/sin between model grid lines and NP direction at U point
+      gsinv, gcosv,   &  ! cos/sin between model grid lines and NP direction at V point
+      gsinf, gcosf       ! cos/sin between model grid lines and NP direction at F point
+
+   LOGICAL ::   lmust_init = .TRUE.        !: used to initialize the cos/sin variables (se above)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE repcmo ( pxu1, pyu1, pxv1, pyv1,   &
+                       px2 , py2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE repcmo  ***
+      !!
+      !! ** Purpose :   Change vector componantes from a geographic grid to a
+      !!      stretched coordinates grid.
+      !!
+      !! ** Method  :   Initialization of arrays at the first call.
+      !!
+      !! ** Action  : - px2 : first  componante (defined at u point)
+      !!              - py2 : second componante (defined at v point)
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   pxu1, pyu1   ! geographic vector componantes at u-point
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   pxv1, pyv1   ! geographic vector componantes at v-point
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   px2          ! i-componante (defined at u-point)
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   py2          ! j-componante (defined at v-point)
+      !!----------------------------------------------------------------------
+      
+      ! Change from geographic to stretched coordinate
+      ! ----------------------------------------------
+      CALL rot_rep( pxu1, pyu1, 'U', 'en->i',px2 )
+      CALL rot_rep( pxv1, pyv1, 'V', 'en->j',py2 )
+      
+   END SUBROUTINE repcmo
+
+
+   SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE rot_rep  ***
+      !!
+      !! ** Purpose :   Rotate the Repere: Change vector componantes between
+      !!                geographic grid <--> stretched coordinates grid.
+      !!
+      !! History :
+      !!   9.2  !  07-04  (S. Masson)  
+      !!                  (O. Marti ) Original code (repere and repcmo)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN ) ::   pxin, pyin   ! vector componantes
+      CHARACTER(len=1),             INTENT( IN ) ::   cd_type      ! define the nature of pt2d array grid-points
+      CHARACTER(len=5),             INTENT( IN ) ::   cdtodo       ! specify the work to do:
+      !!                                                           ! 'en->i' east-north componantes to model i componante
+      !!                                                           ! 'en->j' east-north componantes to model j componante
+      !!                                                           ! 'ij->e' model i-j componantes to east componante
+      !!                                                           ! 'ij->n' model i-j componantes to east componante
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(out) ::   prot      
+
+      !!----------------------------------------------------------------------
+
+      ! Initialization of gsin* and gcos* at first call
+      ! -----------------------------------------------
+
+      IF( lmust_init ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' rot_rep : geographic <--> stretched'
+         IF(lwp) WRITE(numout,*) ' ~~~~~    coordinate transformation'
+
+         CALL angle       ! initialization of the transformation
+         lmust_init = .FALSE.
+
+      ENDIF
+      
+      SELECT CASE (cdtodo)
+      CASE ('en->i')      ! 'en->i' est-north componantes to model i componante
+         SELECT CASE (cd_type)
+         CASE ('T')   ;   prot(:,:) = pxin(:,:) * gcost(:,:) + pyin(:,:) * gsint(:,:)
+         CASE ('U')   ;   prot(:,:) = pxin(:,:) * gcosu(:,:) + pyin(:,:) * gsinu(:,:)
+         CASE ('V')   ;   prot(:,:) = pxin(:,:) * gcosv(:,:) + pyin(:,:) * gsinv(:,:)
+         CASE ('F')   ;   prot(:,:) = pxin(:,:) * gcosf(:,:) + pyin(:,:) * gsinf(:,:)
+         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
+         END SELECT
+      CASE ('en->j')      ! 'en->j' est-north componantes to model j componante
+         SELECT CASE (cd_type)
+         CASE ('T')   ;   prot(:,:) = pyin(:,:) * gcost(:,:) - pxin(:,:) * gsint(:,:)
+         CASE ('U')   ;   prot(:,:) = pyin(:,:) * gcosu(:,:) - pxin(:,:) * gsinu(:,:)
+         CASE ('V')   ;   prot(:,:) = pyin(:,:) * gcosv(:,:) - pxin(:,:) * gsinv(:,:)   
+         CASE ('F')   ;   prot(:,:) = pyin(:,:) * gcosf(:,:) - pxin(:,:) * gsinf(:,:)   
+         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
+         END SELECT
+      CASE ('ij->e')      ! 'ij->e' model i-j componantes to est componante
+         SELECT CASE (cd_type)
+         CASE ('T')   ;   prot(:,:) = pxin(:,:) * gcost(:,:) - pyin(:,:) * gsint(:,:)
+         CASE ('U')   ;   prot(:,:) = pxin(:,:) * gcosu(:,:) - pyin(:,:) * gsinu(:,:)
+         CASE ('V')   ;   prot(:,:) = pxin(:,:) * gcosv(:,:) - pyin(:,:) * gsinv(:,:)
+         CASE ('F')   ;   prot(:,:) = pxin(:,:) * gcosf(:,:) - pyin(:,:) * gsinf(:,:)
+         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
+         END SELECT
+      CASE ('ij->n')      ! 'ij->n' model i-j componantes to est componante
+         SELECT CASE (cd_type)
+         CASE ('T')   ;   prot(:,:) = pyin(:,:) * gcost(:,:) + pxin(:,:) * gsint(:,:)
+         CASE ('U')   ;   prot(:,:) = pyin(:,:) * gcosu(:,:) + pxin(:,:) * gsinu(:,:)
+         CASE ('V')   ;   prot(:,:) = pyin(:,:) * gcosv(:,:) + pxin(:,:) * gsinv(:,:)
+         CASE ('F')   ;   prot(:,:) = pyin(:,:) * gcosf(:,:) + pxin(:,:) * gsinf(:,:)
+         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
+         END SELECT
+      CASE DEFAULT   ;   CALL ctl_stop( 'rot_rep: Syntax Error in the definition of cdtodo' )
+      END SELECT
+      
+   END SUBROUTINE rot_rep
+
+
+   SUBROUTINE angle
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE angle  ***
+      !! 
+      !! ** Purpose :   Compute angles between model grid lines and the North direction
+      !!
+      !! ** Method  :
+      !!
+      !! ** Action  :   Compute (gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf) arrays:
+      !!      sinus and cosinus of the angle between the north-south axe and the 
+      !!      j-direction at t, u, v and f-points
+      !!
+      !! History :
+      !!   7.0  !  96-07  (O. Marti )  Original code
+      !!   8.0  !  98-06  (G. Madec )
+      !!   8.5  !  98-06  (G. Madec )  Free form, F90 + opt.
+      !!   9.2  !  07-04  (S. Masson)  Add T, F points and bugfix in cos lateral boundary
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj      ! dummy loop indices
+      !!
+      REAL(wp) ::   &
+         zlam, zphi,            &  ! temporary scalars
+         zlan, zphh,            &  !    "         "
+         zxnpt, zynpt, znnpt,   &  ! x,y components and norm of the vector: T point to North Pole
+         zxnpu, zynpu, znnpu,   &  ! x,y components and norm of the vector: U point to North Pole
+         zxnpv, zynpv, znnpv,   &  ! x,y components and norm of the vector: V point to North Pole
+         zxnpf, zynpf, znnpf,   &  ! x,y components and norm of the vector: F point to North Pole
+         zxvvt, zyvvt, znvvt,   &  ! x,y components and norm of the vector: between V points below and above a T point
+         zxffu, zyffu, znffu,   &  ! x,y components and norm of the vector: between F points below and above a U point
+         zxffv, zyffv, znffv,   &  ! x,y components and norm of the vector: between F points left  and right a V point
+         zxuuf, zyuuf, znuuf       ! x,y components and norm of the vector: between U points below and above a F point
+      !!----------------------------------------------------------------------
+
+      ! ============================= !
+      ! Compute the cosinus and sinus !
+      ! ============================= !
+      ! (computation done on the north stereographic polar plane)
+
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = fs_2, jpi   ! vector opt.
+
+            ! north pole direction & modulous (at t-point)
+            zlam = glamt(ji,jj)
+            zphi = gphit(ji,jj)
+            zxnpt = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            zynpt = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            znnpt = zxnpt*zxnpt + zynpt*zynpt
+
+            ! north pole direction & modulous (at u-point)
+            zlam = glamu(ji,jj)
+            zphi = gphiu(ji,jj)
+            zxnpu = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            zynpu = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            znnpu = zxnpu*zxnpu + zynpu*zynpu
+
+            ! north pole direction & modulous (at v-point)
+            zlam = glamv(ji,jj)
+            zphi = gphiv(ji,jj)
+            zxnpv = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            zynpv = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            znnpv = zxnpv*zxnpv + zynpv*zynpv
+
+            ! north pole direction & modulous (at f-point)
+            zlam = glamf(ji,jj)
+            zphi = gphif(ji,jj)
+            zxnpf = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            zynpf = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
+            znnpf = zxnpf*zxnpf + zynpf*zynpf
+
+            ! j-direction: v-point segment direction (around t-point)
+            zlam = glamv(ji,jj  )
+            zphi = gphiv(ji,jj  )
+            zlan = glamv(ji,jj-1)
+            zphh = gphiv(ji,jj-1)
+            zxvvt =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            zyvvt =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            znvvt = SQRT( znnpt * ( zxvvt*zxvvt + zyvvt*zyvvt )  )
+            znvvt = MAX( znvvt, 1.e-14 )
+
+            ! j-direction: f-point segment direction (around u-point)
+            zlam = glamf(ji,jj  )
+            zphi = gphif(ji,jj  )
+            zlan = glamf(ji,jj-1)
+            zphh = gphif(ji,jj-1)
+            zxffu =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            zyffu =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu )  )
+            znffu = MAX( znffu, 1.e-14 )
+
+            ! i-direction: f-point segment direction (around v-point)
+            zlam = glamf(ji  ,jj)
+            zphi = gphif(ji  ,jj)
+            zlan = glamf(ji-1,jj)
+            zphh = gphif(ji-1,jj)
+            zxffv =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            zyffv =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv )  )
+            znffv = MAX( znffv, 1.e-14 )
+
+            ! j-direction: u-point segment direction (around f-point)
+            zlam = glamu(ji,jj+1)
+            zphi = gphiu(ji,jj+1)
+            zlan = glamu(ji,jj  )
+            zphh = gphiu(ji,jj  )
+            zxuuf =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            zyuuf =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
+               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
+            znuuf = SQRT( znnpf * ( zxuuf*zxuuf + zyuuf*zyuuf )  )
+            znuuf = MAX( znuuf, 1.e-14 )
+
+            ! cosinus and sinus using scalar and vectorial products
+            gsint(ji,jj) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt
+            gcost(ji,jj) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt
+
+            gsinu(ji,jj) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu
+            gcosu(ji,jj) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu
+
+            gsinf(ji,jj) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf
+            gcosf(ji,jj) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf
+
+            ! (caution, rotation of 90 degres)
+            gsinv(ji,jj) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv
+            gcosv(ji,jj) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv
+
+         END DO
+      END DO
+
+      ! =============== !
+      ! Geographic mesh !
+      ! =============== !
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, jpi   ! vector opt.
+            IF( MOD( ABS( glamv(ji,jj) - glamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
+               gsint(ji,jj) = 0.
+               gcost(ji,jj) = 1.
+            ENDIF
+            IF( MOD( ABS( glamf(ji,jj) - glamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
+               gsinu(ji,jj) = 0.
+               gcosu(ji,jj) = 1.
+            ENDIF
+            IF(      ABS( gphif(ji,jj) - gphif(ji-1,jj) )         < 1.e-8 ) THEN
+               gsinv(ji,jj) = 0.
+               gcosv(ji,jj) = 1.
+            ENDIF
+            IF( MOD( ABS( glamu(ji,jj) - glamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN
+               gsinf(ji,jj) = 0.
+               gcosf(ji,jj) = 1.
+            ENDIF
+         END DO
+      END DO
+
+      ! =========================== !
+      ! Lateral boundary conditions !
+      ! =========================== !
+
+      ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
+      CALL lbc_lnk( gcost, 'T', -1. )   ;   CALL lbc_lnk( gsint, 'T', -1. )
+      CALL lbc_lnk( gcosu, 'U', -1. )   ;   CALL lbc_lnk( gsinu, 'U', -1. )
+      CALL lbc_lnk( gcosv, 'V', -1. )   ;   CALL lbc_lnk( gsinv, 'V', -1. )
+      CALL lbc_lnk( gcosf, 'F', -1. )   ;   CALL lbc_lnk( gsinf, 'F', -1. )
+
+   END SUBROUTINE angle
+
+
+   SUBROUTINE geo2oce ( pxx, pyy, pzz, cgrid,     &
+                        pte, ptn )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE geo2oce  ***
+      !!      
+      !! ** Purpose :
+      !!
+      !! ** Method  :   Change wind stress from geocentric to east/north
+      !!
+      !! History :
+      !!        !         (O. Marti)  Original code
+      !!        !  91-03  (G. Madec)
+      !!        !  92-07  (M. Imbard)
+      !!        !  99-11  (M. Imbard) NetCDF format with IOIPSL
+      !!        !  00-08  (D. Ludicone) Reduced section at Bab el Mandeb
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form
+      !!   3.0  !  07-08  (G. Madec)  geo2oce suppress lon/lat agruments
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::  pxx, pyy, pzz
+      CHARACTER(len=1)            , INTENT(in   ) ::  cgrid
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::  pte, ptn
+      !!
+      REAL(wp), PARAMETER :: rpi = 3.141592653E0
+      REAL(wp), PARAMETER :: rad = rpi / 180.e0
+      INTEGER ::   ig     !
+      !! * Local save
+      REAL(wp), SAVE, DIMENSION(jpi,jpj,4) ::   zsinlon, zcoslon, zsinlat, zcoslat
+      LOGICAL , SAVE, DIMENSION(4)         ::   linit = .FALSE.
+      !!----------------------------------------------------------------------
+
+      SELECT CASE( cgrid)
+         CASE ( 'T' )   
+            ig = 1
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamt(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamt(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphit(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphit(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'U' )   
+            ig = 2
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamu(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamu(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphiu(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphiu(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'V' )   
+            ig = 3
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamv(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamv(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphiv(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphiv(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'F' )   
+            ig = 4
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamf(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamf(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphif(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphif(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE default   
+            WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid
+            CALL ctl_stop( ctmp1 )
+      END SELECT
+      
+      pte = - zsinlon(:,:,ig) * pxx + zcoslon(:,:,ig) * pyy
+      ptn = - zcoslon(:,:,ig) * zsinlat(:,:,ig) * pxx    &
+            - zsinlon(:,:,ig) * zsinlat(:,:,ig) * pyy    &
+            + zcoslat(:,:,ig) * pzz
+!!$   ptv =   zcoslon(:,:,ig) * zcoslat(:,:,ig) * pxx    &
+!!$         + zsinlon(:,:,ig) * zcoslat(:,:,ig) * pyy    &
+!!$         + zsinlat(:,:,ig) * pzz
+      !
+   END SUBROUTINE geo2oce
+
+   SUBROUTINE oce2geo ( pte, ptn, cgrid,     &
+                        pxx , pyy , pzz )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE oce2geo  ***
+      !!      
+      !! ** Purpose :
+      !!
+      !! ** Method  :   Change vector from east/north to geocentric
+      !!
+      !! History :
+      !!        !         (A. Caubel)  oce2geo - Original code
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    ) ::  pte, ptn
+      CHARACTER(len=1)            , INTENT( IN    ) ::  cgrid
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(   OUT ) ::  pxx , pyy , pzz
+      !!
+      REAL(wp), PARAMETER :: rpi = 3.141592653E0
+      REAL(wp), PARAMETER :: rad = rpi / 180.e0
+      INTEGER ::   ig     !
+      !! * Local save
+      REAL(wp), SAVE, DIMENSION(jpi,jpj,4) ::   zsinlon, zcoslon, zsinlat, zcoslat
+      LOGICAL , SAVE, DIMENSION(4)         ::   linit = .FALSE.
+      !!----------------------------------------------------------------------
+
+      SELECT CASE( cgrid)
+         CASE ( 'T' )   
+            ig = 1
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamt(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamt(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphit(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphit(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'U' )   
+            ig = 2
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamu(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamu(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphiu(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphiu(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'V' )   
+            ig = 3
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamv(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamv(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphiv(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphiv(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE ( 'F' )   
+            ig = 4
+            IF( .NOT. linit(ig) ) THEN 
+               zsinlon(:,:,ig) = SIN( rad * glamf(:,:) )
+               zcoslon(:,:,ig) = COS( rad * glamf(:,:) )
+               zsinlat(:,:,ig) = SIN( rad * gphif(:,:) )
+               zcoslat(:,:,ig) = COS( rad * gphif(:,:) )
+               linit(ig) = .TRUE.
+            ENDIF
+         CASE default   
+            WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid
+            CALL ctl_stop( ctmp1 )
+      END SELECT
+
+       pxx = - zsinlon(:,:,ig) * pte - zcoslon(:,:,ig) * zsinlat(:,:,ig) * ptn 
+       pyy =   zcoslon(:,:,ig) * pte - zsinlon(:,:,ig) * zsinlat(:,:,ig) * ptn
+       pzz =   zcoslat(:,:,ig) * ptn
+
+      
+   END SUBROUTINE oce2geo
+
+
+   SUBROUTINE repere ( px1, py1, px2, py2, kchoix, cd_type )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE repere  ***
+      !!        
+      !! ** Purpose :   Change vector componantes between a geopgraphic grid 
+      !!      and a stretched coordinates grid.
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  :
+      !!
+      !! History :
+      !!        !  89-03  (O. Marti)  original code
+      !!        !  92-02  (M. Imbard)
+      !!        !  93-03  (M. Guyon)  symetrical conditions
+      !!        !  98-05  (B. Blanke)
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT( IN   ), DIMENSION(jpi,jpj) ::   &
+         px1, py1          ! two horizontal components to be rotated
+      REAL(wp), INTENT( OUT  ), DIMENSION(jpi,jpj) ::   &
+         px2, py2          ! the two horizontal components in the model repere
+      INTEGER, INTENT( IN ) ::   &
+         kchoix   ! type of transformation
+                  ! = 1 change from geographic to model grid.
+                  ! =-1 change from model to geographic grid
+      CHARACTER(len=1), INTENT( IN ), OPTIONAL ::   cd_type      ! define the nature of pt2d array grid-points
+      !
+      CHARACTER(len=1) ::   cl_type      ! define the nature of pt2d array grid-points (T point by default)
+      !!----------------------------------------------------------------------
+
+      cl_type = 'T'
+      IF( PRESENT(cd_type) )   cl_type = cd_type
+         !
+      SELECT CASE (kchoix)
+      CASE ( 1)      ! change from geographic to model grid.
+         CALL rot_rep( px1, py1, cl_type, 'en->i', px2 )
+         CALL rot_rep( px1, py1, cl_type, 'en->j', py2 )
+      CASE (-1)      ! change from model to geographic grid
+         CALL rot_rep( px1, py1, cl_type, 'ij->e', px2 )
+         CALL rot_rep( px1, py1, cl_type, 'ij->n', py2 )
+      CASE DEFAULT   ;   CALL ctl_stop( 'repere: Syntax Error in the definition of kchoix (1 OR -1' )
+      END SELECT
+      
+   END SUBROUTINE repere
+
+  !!======================================================================
+END MODULE geo2ocean
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/oasis4_date.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/oasis4_date.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/oasis4_date.F90	(revision 1844)
@@ -0,0 +1,33 @@
+MODULE oasis4_date
+   !!---------------------------------------------------------------------
+   !!                     ***  oasis_date.h90  ***  
+   !!   Date and related information required to couple NEMO via OASIS4
+   !!   Made separate from cpl_oasis4 module to allow wider use.
+   !!=====================================================================
+   !! History :   
+   !!   9.0  !  05-12  (R. Hill, Met. Office) Original code
+   !!----------------------------------------------------------------------
+#if defined key_oasis4
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+!##################### WARNING coupled mode ###############################
+!##################### WARNING coupled mode ###############################
+!   Following line must be enabled if coupling with OASIS
+!   USE PRISM
+!##################### WARNING coupled mode ###############################
+!##################### WARNING coupled mode ###############################
+
+   IMPLICIT NONE
+
+   INTEGER :: date_err, date_info
+   !!---------------------------------------------------------------------
+   TYPE(PRISM_Time_struct), PUBLIC    :: dates          ! date info for send operation
+   TYPE(PRISM_Time_struct), PUBLIC    :: dates_bound(2) ! date info for send operation
+   TYPE(PRISM_Time_struct), PUBLIC    :: dater          ! date info for receive operation
+   TYPE(PRISM_Time_struct), PUBLIC    :: dater_bound(2) ! date info for receive operation
+   TYPE(PRISM_Time_struct), PUBLIC    :: tmpdate
+#endif
+END MODULE oasis4_date
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_ice.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 1844)
@@ -0,0 +1,69 @@
+MODULE sbc_ice
+   !!======================================================================
+   !!                 ***  MODULE  sbc_ice  ***
+   !!        parameter and  variables defined in memory in forced mode
+   !!======================================================================
+   !! History :  3.0  !  2006-08  (G. Madec)  Surface module
+   !!            3.2  !  2009-06  (S. Masson) merge with ice_oce
+   !!----------------------------------------------------------------------
+#if defined key_lim3 || defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' or 'key_lim3' :             LIM 2.0 or 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+# if defined key_lim3
+   USE par_ice          ! ice parameters
+# endif
+# if defined key_lim2
+   USE par_ice_2        ! ice parameters
+# endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+# if defined  key_lim2
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim2        = .TRUE.    !: LIM-2 ice model
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim3        = .FALSE.   !: no LIM-3
+   CHARACTER(len=1), PUBLIC            ::   cigr_type      = 'I'       !: 'I'-grid ice-velocity (B-grid lower left corner)
+# endif
+# if defined  key_lim3
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim2        = .FALSE.   !: no LIM-2
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim3        = .TRUE.    !: LIM-3 ice model
+   CHARACTER(len=1), PUBLIC            ::   cigr_type      = 'C'       !: 'C'-grid ice-velocity
+# endif
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qns_ice   !: non solar heat flux over ice                         [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qsr_ice   !: solar heat flux over ice                             [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qla_ice   !: latent flux over ice                                 [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   dqla_ice  !: latent sensibility over ice                          [W/m2/K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   dqns_ice  !: non solar heat flux sensibility over ice (LW+SEN+LA) [W/m2/K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   tn_ice    !: ice surface temperature                              [K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   alb_ice   !: albedo of ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utau_ice    !: u-stress over ice (I-point for LIM2 or U,V-point for LIM3)   [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtau_ice    !: v-stress over ice (I-point for LIM2 or U,V-point for LIM3)   [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr1_i0      !: 1st fraction of sol. rad. which penetrate inside the ice cover
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr2_i0      !: 2nd fraction of sol. rad. which penetrate inside the ice cover
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp_ice     !: solid freshwater budget over ice: sublivation - snow
+
+# if defined key_lim3
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tatm_ice    !: air temperature
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                      NO LIM 2.0 or 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim2        = .FALSE.  !: no LIM-2 ice model
+   LOGICAL         , PUBLIC, PARAMETER ::   lk_lim3        = .FALSE.  !: no LIM-3 ice model
+   CHARACTER(len=1), PUBLIC            ::   cigr_type      = '-'      !: no grid ice-velocity
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   !!======================================================================
+END MODULE sbc_ice
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 1844)
@@ -0,0 +1,77 @@
+MODULE sbc_oce
+   !!======================================================================
+   !!                       ***  MODULE  sbc_oce  ***
+   !! Surface module :   variables defined in core memory 
+   !!======================================================================
+   !! History :  3.0   !  2006-06  (G. Madec)  Original code
+   !!             -    !  2008-08  (G. Madec)  namsbc moved from sbcmod
+   !!----------------------------------------------------------------------
+   USE par_oce          ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   !!----------------------------------------------------------------------
+   !!           Namelist for the Ocean Surface Boundary Condition
+   !!----------------------------------------------------------------------
+   !                                             !! * namsbc namelist *
+   LOGICAL , PUBLIC ::   ln_ana      = .FALSE.   !: analytical boundary condition flag
+   LOGICAL , PUBLIC ::   ln_flx      = .FALSE.   !: flux      formulation
+   LOGICAL , PUBLIC ::   ln_blk_clio = .FALSE.   !: CLIO bulk formulation
+   LOGICAL , PUBLIC ::   ln_blk_core = .FALSE.   !: CORE bulk formulation
+   LOGICAL , PUBLIC ::   ln_cpl      = .FALSE.   !: coupled   formulation (overwritten by key_sbc_coupled )
+   LOGICAL , PUBLIC ::   ln_dm2dc    = .FALSE.   !: Daily mean to Diurnal Cycle short wave (qsr)
+   LOGICAL , PUBLIC ::   ln_rnf      = .FALSE.   !: runoffs / runoff mouths
+   LOGICAL , PUBLIC ::   ln_ssr      = .FALSE.   !: Sea Surface restoring on SST and/or SSS      
+   INTEGER , PUBLIC ::   nn_ice      = 0         !: flag on ice in the surface boundary condition (=0/1/2/3)
+   INTEGER , PUBLIC ::   nn_fwb      = 0         !: FreshWater Budget: 
+   !                                             !:  = 0 unchecked 
+   !                                             !:  = 1 global mean of e-p-r set to zero at each nn_fsbc time step
+   !                                             !:  = 2 annual global mean of e-p-r set to zero
+   INTEGER , PUBLIC ::   nn_ico_cpl  = 0          !: ice-ocean coupling indicator
+   !                                             !:  = 0   LIM-3 old case
+   !                                             !:  = 1   stresses computed using now ocean velocity
+   !                                             !:  = 2   combination of 0 and 1 cases
+
+   !!----------------------------------------------------------------------
+   !!              Ocean Surface Boundary Condition fields
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC ::   lhftau = .FALSE.              !: HF tau contribution: mean of stress module - module of the mean stress
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utau      !: sea surface i-stress (ocean referential)     [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtau      !: sea surface j-stress (ocean referential)     [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   taum      !: module of sea surface stress (at T-point)    [N/m2] 
+   !! wndm is used only in PISCES to compute gases exchanges at the surface of the free ocean or in the leads in sea-ice parts
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   wndm      !: wind speed module at T-point (=|U10m-Uoce|)  [m/s] 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr       !: sea heat flux:     solar                     [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns       !: sea heat flux: non solar                     [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr_tot   !: total     solar heat flux (over sea and ice) [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns_tot   !: total non solar heat flux (over sea and ice) [W/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp       !: freshwater budget: volume flux               [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emps      !: freshwater budget: concentration/dillution   [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp_tot   !: total evaporation - (liquid + solid) precpitation over oce and ice
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tprecip   !: total precipitation           [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sprecip   !: solid precipitation           [Kg/m2/s]
+!!$   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rrunoff       !: runoff
+!!$   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   calving       !: calving
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr_i      !: ice fraction  (between 0 to 1)               -
+#if defined key_cpl_carbon_cycle
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   atm_co2   !: atmospheric pCO2                             [ppm]
+#endif
+
+   !!----------------------------------------------------------------------
+   !!                     Sea Surface Mean fields
+   !!----------------------------------------------------------------------
+   INTEGER , PUBLIC                     ::   nn_fsbc   !: frequency of sbc computation (as well as sea-ice model)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssu_m     !: mean (nn_fsbc time-step) surface sea i-current (U-point) [m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssv_m     !: mean (nn_fsbc time-step) surface sea j-current (V-point) [m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sst_m     !: mean (nn_fsbc time-step) surface sea temperature     [Celsius]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sss_m     !: mean (nn_fsbc time-step) surface sea salinity            [psu]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssh_m     !: mean (nn_fsbc time-step) sea surface height                [m]
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $ Id: $
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+
+END MODULE sbc_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcana.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcana.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcana.F90	(revision 1844)
@@ -0,0 +1,320 @@
+MODULE sbcana
+   !!======================================================================
+   !!                       ***  MODULE  sbcana  ***
+   !! Ocean forcing:  analytical momentum, heat and freshwater forcings
+   !!=====================================================================
+   !! History :  3.0   ! 2006-06  (G. Madec)  Original code
+   !!            3.2   ! 2009-07  (G. Madec)  Style only
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_ana  : set an analytical ocean forcing
+   !!   sbc_gyre : set the GYRE configuration analytical forcing
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_ana    ! routine called in sbcmod module
+   PUBLIC   sbc_gyre   ! routine called in sbcmod module
+
+   !                               !!* Namelist namsbc_ana *
+   INTEGER  ::   nn_tau000 = 1      ! nb of time-step during which the surface stress
+   !                                ! increase from 0 to its nominal value 
+   REAL(wp) ::   rn_utau0  = 0.e0   ! constant wind stress value in i-direction
+   REAL(wp) ::   rn_vtau0  = 0.e0   ! constant wind stress value in j-direction
+   REAL(wp) ::   rn_qns0   = 0.e0   ! non solar heat flux
+   REAL(wp) ::   rn_qsr0   = 0.e0   !     solar heat flux
+   REAL(wp) ::   rn_emp0   = 0.e0   ! net freshwater flux
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ana( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_ana ***
+      !!              
+      !! ** Purpose :   provide at each time-step the ocean surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   Constant and uniform surface forcing specified from
+      !!              namsbc_ana namelist parameters. All the fluxes are time
+      !!              independant except the stresses which increase from zero
+      !!              during the first nn_tau000 time-step 
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set the ocean surface boundary condition, i.e.  
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, emps
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! ocean time step
+      !!
+      REAL(wp)            ::   zfacto                ! local scalar
+      REAL(wp)            ::   zrhoa  = 1.22         ! Air density kg/m3
+      REAL(wp)            ::   zcdrag = 1.5e-3       ! drag coefficient
+      REAL(wp)            ::   ztx, zty, zmod, zcoef ! temporary variables
+      !!
+      NAMELIST/namsbc_ana/ nn_tau000, rn_utau0, rn_vtau0, rn_qns0, rn_qsr0, rn_emp0
+      !!---------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         !
+         REWIND ( numnam )                   ! Read Namelist namsbc : surface fluxes
+         READ   ( numnam, namsbc_ana )
+         !
+         IF(lwp) WRITE(numout,*)' '
+         IF(lwp) WRITE(numout,*)' sbc_ana : Constant surface fluxes read in namsbc_ana namelist'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~ '
+         IF(lwp) WRITE(numout,*)'              spin up of the stress  nn_tau000 = ', nn_tau000, ' time-steps'
+         IF(lwp) WRITE(numout,*)'              constant i-stress      rn_utau0  = ', rn_utau0 , ' N/m2'
+         IF(lwp) WRITE(numout,*)'              constant j-stress      rn_vtau0  = ', rn_vtau0 , ' N/m2'
+         IF(lwp) WRITE(numout,*)'              non solar heat flux    rn_qns0   = ', rn_qns0  , ' W/m2'
+         IF(lwp) WRITE(numout,*)'              solar heat flux        rn_qsr0   = ', rn_qsr0  , ' W/m2'
+         IF(lwp) WRITE(numout,*)'              net heat flux          rn_emp0   = ', rn_emp0  , ' Kg/m2/s'
+         !
+         nn_tau000 = MAX( nn_tau000, 1 )   ! must be >= 1
+         qns   (:,:) = rn_qns0
+         qsr   (:,:) = rn_qsr0
+         emp   (:,:) = rn_emp0
+         emps  (:,:) = rn_emp0
+         !
+      ENDIF
+   
+      ! Increase the surface stress to its nominal value during the first nn_tau000 time-steps
+      IF( kt <= nn_tau000 ) THEN
+         zfacto = 0.5 * (  1. - COS( rpi * FLOAT( kt ) / FLOAT( nn_tau000 ) )  )
+         zcoef = 1. / ( zrhoa * zcdrag ) 
+         ztx = zfacto * rn_utau0
+         zty = zfacto * rn_vtau0
+         zmod = SQRT( ztx * ztx + zty * zty )
+         utau(:,:) = ztx
+         vtau(:,:) = zty
+         taum(:,:) = zmod
+         zmod = SQRT( zmod * zcoef )
+         wndm(:,:) = zmod
+      ENDIF
+      !
+   END SUBROUTINE sbc_ana
+
+
+   SUBROUTINE sbc_gyre( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_ana ***
+      !!              
+      !! ** Purpose :   provide at each time-step the GYRE surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   analytical seasonal cycle for GYRE configuration.
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set the ocean surface boundary condition, i.e.   
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, emps
+      !!
+      !! Reference : Hazeleger, W., and S. Drijfhout, JPO, 30, 677-695, 2000.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt          ! ocean time step
+      !!
+      INTEGER  ::   ji, jj                 ! dummy loop indices
+      INTEGER  ::   zyear0                 ! initial year 
+      INTEGER  ::   zmonth0                ! initial month
+      INTEGER  ::   zday0                  ! initial day
+      INTEGER  ::   zday_year0             ! initial day since january 1st
+      REAL(wp) ::   ztau     , ztau_sais   ! wind intensity and of the seasonal cycle
+      REAL(wp) ::   ztime                  ! time in hour
+      REAL(wp) ::   ztimemax , ztimemin    ! 21th June, and 21th decem. if date0 = 1st january
+      REAL(wp) ::   ztimemax1, ztimemin1   ! 21th June, and 21th decem. if date0 = 1st january
+      REAL(wp) ::   ztimemax2, ztimemin2   ! 21th June, and 21th decem. if date0 = 1st january
+      REAL(wp) ::   ztaun                  ! intensity
+      REAL(wp) ::   zemp_s, zemp_n, zemp_sais, ztstar
+      REAL(wp) ::   zcos_sais1, zcos_sais2, ztrp, zconv, t_star
+      REAL(wp) ::   zsumemp, zsurf
+      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
+      REAL(wp) ::   ztx, zty, zmod, zcoef ! temporary variables
+      REAL(wp) ::   zyydd                 ! number of days in one year
+      !!---------------------------------------------------------------------
+      zyydd = REAL(nyear_len(1),wp)
+
+      ! ---------------------------- !
+      !  heat and freshwater fluxes  !
+      ! ---------------------------- !
+      !same temperature, E-P as in HAZELEGER 2000
+
+      zyear0     =   ndate0 / 10000                             ! initial year
+      zmonth0    = ( ndate0 - zyear0 * 10000 ) / 100            ! initial month
+      zday0      =   ndate0 - zyear0 * 10000 - zmonth0 * 100    ! initial day betwen 1 and 30
+      zday_year0 = ( zmonth0 - 1 ) * 30.+zday0                  ! initial day betwen 1 and 360
+
+      ! current day (in hours) since january the 1st of the current year
+      ztime = REAL( kt ) * rdt / (rmmss * rhhmm)   &       !  total incrementation (in hours)
+         &      - (nyear  - 1) * rjjhh * zyydd             !  minus years since beginning of experiment (in hours)
+
+      ztimemax1 = ((5.*30.)+21.)* 24.                      ! 21th june     at 24h in hours
+      ztimemin1 = ztimemax1 + rjjhh * zyydd / 2            ! 21th december        in hours
+      ztimemax2 = ((6.*30.)+21.)* 24.                      ! 21th july     at 24h in hours
+      ztimemin2 = ztimemax2 - rjjhh * zyydd / 2            ! 21th january         in hours
+      !                                                    ! NB: rjjhh * zyydd / 4 = one seasonal cycle in hours
+
+      ! amplitudes
+      zemp_S    = 0.7       ! intensity of COS in the South
+      zemp_N    = 0.8       ! intensity of COS in the North
+      zemp_sais = 0.1
+      zTstar    = 28.3      ! intemsity from 28.3 a -5 deg
+
+      ! 1/2 period between 21th June and 21th December and between 21th July and 21th January
+      zcos_sais1 = COS( (ztime - ztimemax1) / (ztimemin1 - ztimemax1) * rpi ) 
+      zcos_sais2 = COS( (ztime - ztimemax2) / (ztimemax2 - ztimemin2) * rpi )
+
+      ztrp= - 40.e0        ! retroaction term on heat fluxes (W/m2/K)
+      zconv = 3.16e-5      ! convertion factor: 1 m/yr => 3.16e-5 mm/s
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! domain from 15 deg to 50 deg between 27 and 28  degC at 15N, -3
+            ! and 13 degC at 50N 53.5 + or - 11 = 1/4 period :
+            ! 64.5 in summer, 42.5 in winter
+            t_star = zTstar * ( 1 + 1. / 50. * zcos_sais2 )                &
+               &                    * COS( rpi * (gphit(ji,jj) - 5.)               &
+               &                    / ( 53.5 * ( 1 + 11 / 53.5 * zcos_sais2 ) * 2.) )
+            ! 23.5 deg : tropics
+            qsr (ji,jj) =  230 * COS( 3.1415 * ( gphit(ji,jj) - 23.5 * zcos_sais1 ) / ( 0.9 * 180 ) )
+            qns (ji,jj) = ztrp * ( tb(ji,jj,1) - t_star ) - qsr(ji,jj)
+            IF( gphit(ji,jj) >= 14.845 .AND. 37.2 >= gphit(ji,jj) ) THEN    ! zero at 37.8 deg, max at 24.6 deg
+               emp  (ji,jj) =   zemp_S * zconv   &
+                  &         * SIN( rpi / 2 * (gphit(ji,jj) - 37.2) / (24.6 - 37.2) )  &
+                  &         * ( 1 - zemp_sais / zemp_S * zcos_sais1)
+            ELSE
+               emp (ji,jj) =  - zemp_N * zconv   &
+                  &         * SIN( rpi / 2 * (gphit(ji,jj) - 37.2) / (46.8 - 37.2) )  &
+                  &         * ( 1 - zemp_sais / zemp_N * zcos_sais1 )
+            ENDIF
+         END DO
+      END DO
+      emps(:,:) = emp(:,:)
+
+      ! Compute the emp flux such as its integration on the whole domain at each time is zero
+      IF( nbench /= 1 .AND. nbit_cmp /= 1 ) THEN
+         zsumemp = 0.e0   ;   zsurf = 0.e0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zsumemp = zsumemp + emp(ji,jj) * tmask(ji,jj,1) * tmask_i(ji,jj)
+               zsurf   = zsurf   +              tmask(ji,jj,1) * tmask_i(ji,jj)
+            END DO
+         END DO
+
+         IF( lk_mpp )   CALL mpp_sum( zsumemp  )       ! sum over the global domain
+         IF( lk_mpp )   CALL mpp_sum( zsurf    )       ! sum over the global domain
+
+         ! Default GYRE configuration
+         zsumemp = zsumemp / zsurf
+      ELSE
+         ! Benchmark GYRE configuration (to allow the bit to bit comparison between Mpp/Mono case)
+         zsumemp = 0.e0   ;    zsurf = 0.e0
+      ENDIF
+
+      !salinity terms
+      emp (:,:) = emp(:,:) - zsumemp * tmask(:,:,1)
+      emps(:,:) = emp(:,:)
+
+
+      ! ---------------------------- !
+      !       momentum fluxes        !
+      ! ---------------------------- !
+      ! same wind as in Wico
+      !test date0 : ndate0 = 010203
+      zyear0  =   ndate0 / 10000
+      zmonth0 = ( ndate0 - zyear0 * 10000 ) / 100
+      zday0   =   ndate0 - zyear0 * 10000 - zmonth0 * 100
+      !Calculates nday_year, day since january 1st
+      zday_year0 = (zmonth0-1)*30.+zday0
+
+      !accumulates days of previous months of this year
+      ! day (in hours) since january the 1st
+      ztime = FLOAT( kt ) * rdt / (rmmss * rhhmm)  &  ! incrementation in hour
+         &     - (nyear - 1) * rjjhh * zyydd          !  - nber of hours the precedent years
+      ztimemax = ((5.*30.)+21.)* 24.               ! 21th june     in hours
+      ztimemin = ztimemax + rjjhh * zyydd / 2      ! 21th december in hours
+      !                                            ! NB: rjjhh * zyydd / 4 = 1 seasonal cycle in hours
+
+      ! mean intensity at 0.105 ; srqt(2) because projected with 45deg angle
+      ztau = 0.105 / SQRT( 2. )
+      ! seasonal oscillation intensity
+      ztau_sais = 0.015
+      ztaun = ztau - ztau_sais * COS( (ztime - ztimemax) / (ztimemin - ztimemax) * rpi )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+           ! domain from 15deg to 50deg and 1/2 period along 14deg
+           ! so 5/4 of half period with seasonal cycle
+           utau(ji,jj) = - ztaun * SIN( rpi * (gphiu(ji,jj) - 15.) / (29.-15.) )
+           vtau(ji,jj) =   ztaun * SIN( rpi * (gphiv(ji,jj) - 15.) / (29.-15.) )
+         END DO
+      END DO
+
+      ! module of wind stress and wind speed at T-point
+      zcoef = 1. / ( zrhoa * zcdrag ) 
+!CDIR NOVERRCHK
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = fs_2, fs_jpim1   ! vect. opt.
+            ztx = utau(ji-1,jj  ) + utau(ji,jj) 
+            zty = vtau(ji  ,jj-1) + vtau(ji,jj) 
+            zmod = 0.5 * SQRT( ztx * ztx + zty * zty )
+            taum(ji,jj) = zmod
+            wndm(ji,jj) = SQRT( zmod * zcoef )
+         END DO
+      END DO
+      CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
+
+      ! ---------------------------------- !
+      !  control print at first time-step  !
+      ! ---------------------------------- !
+      IF( kt == nit000 .AND. lwp ) THEN 
+         WRITE(numout,*)
+         WRITE(numout,*)'sbc_gyre : analytical surface fluxes for GYRE configuration'               
+         WRITE(numout,*)'~~~~~~~~ ' 
+         WRITE(numout,*)'           nyear      = ', nyear
+         WRITE(numout,*)'           nmonth     = ', nmonth
+         WRITE(numout,*)'           nday       = ', nday
+         WRITE(numout,*)'           nday_year  = ', nday_year
+         WRITE(numout,*)'           ztime      = ', ztime
+         WRITE(numout,*)'           ztimemax   = ', ztimemax
+         WRITE(numout,*)'           ztimemin   = ', ztimemin
+         WRITE(numout,*)'           ztimemax1  = ', ztimemax1
+         WRITE(numout,*)'           ztimemin1  = ', ztimemin1
+         WRITE(numout,*)'           ztimemax2  = ', ztimemax2
+         WRITE(numout,*)'           ztimemin2  = ', ztimemin2
+         WRITE(numout,*)'           zyear0     = ', zyear0
+         WRITE(numout,*)'           zmonth0    = ', zmonth0
+         WRITE(numout,*)'           zday0      = ', zday0
+         WRITE(numout,*)'           zday_year0 = ', zday_year0
+         WRITE(numout,*)'           zyydd      = ', zyydd
+         WRITE(numout,*)'           zemp_S     = ', zemp_S
+         WRITE(numout,*)'           zemp_N     = ', zemp_N
+         WRITE(numout,*)'           zemp_sais  = ', zemp_sais
+         WRITE(numout,*)'           zTstar     = ', zTstar
+         WRITE(numout,*)'           zsumemp    = ', zsumemp
+         WRITE(numout,*)'           zsurf      = ', zsurf
+         WRITE(numout,*)'           ztrp       = ', ztrp
+         WRITE(numout,*)'           zconv      = ', zconv
+         WRITE(numout,*)'           ndastp     = ', ndastp
+         WRITE(numout,*)'           adatrj     = ', adatrj
+
+      ENDIF
+      !
+   END SUBROUTINE sbc_gyre
+
+   !!======================================================================
+END MODULE sbcana
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_clio.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 1844)
@@ -0,0 +1,1002 @@
+MODULE sbcblk_clio
+   !!======================================================================
+   !!                   ***  MODULE  sbcblk_clio  ***
+   !! Ocean forcing:  bulk thermohaline forcing of the ocean (or ice)
+   !!=====================================================================
+   !! History :  OPA  !  1997-06 (Louvain-La-Neuve)  Original code
+   !!                 !  2001-04 (C. Ethe) add flx_blk_declin
+   !!   NEMO     2.0  !  2002-08 (C. Ethe, G. Madec) F90: Free form and module
+   !!            3.0  !  2008-03 (C. Talandier, G. Madec) surface module + LIM3
+   !!            3.2  !  2009-04 (B. Lemaire) Introduce iom_put
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_blk_clio   : CLIO bulk formulation: read and update required input fields
+   !!   blk_clio_oce   : ocean CLIO bulk formulea: compute momentum, heat and freswater fluxes for the ocean
+   !!   blk_ice_clio   : ice   CLIO bulk formulea: compute momentum, heat and freswater fluxes for the sea-ice
+   !!   blk_clio_qsr_oce : shortwave radiation for ocean computed from the cloud cover
+   !!   blk_clio_qsr_ice : shortwave radiation for ice   computed from the cloud cover
+   !!   flx_blk_declin : solar declinaison
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE fldread         ! read input fields
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE iom             ! I/O manager library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   USE albedo
+   USE prtctl          ! Print control
+#if defined key_lim3
+   USE ice
+   USE sbc_ice         ! Surface boundary condition: ice fields
+#elif defined key_lim2
+   USE ice_2
+#endif
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sbc_blk_clio        ! routine called by sbcmod.F90 
+   PUBLIC blk_ice_clio        ! routine called by sbcice_lim.F90 
+
+   INTEGER , PARAMETER ::   jpfld   = 7           ! maximum number of files to read 
+   INTEGER , PARAMETER ::   jp_utau = 1           ! index of wind stress (i-component)      (N/m2)    at U-point
+   INTEGER , PARAMETER ::   jp_vtau = 2           ! index of wind stress (j-component)      (N/m2)    at V-point
+   INTEGER , PARAMETER ::   jp_wndm = 3           ! index of 10m wind module                 (m/s)    at T-point
+   INTEGER , PARAMETER ::   jp_humi = 4           ! index of specific humidity               ( - )
+   INTEGER , PARAMETER ::   jp_ccov = 5           ! index of cloud cover                     ( - )
+   INTEGER , PARAMETER ::   jp_tair = 6           ! index of 10m air temperature             (Kelvin)
+   INTEGER , PARAMETER ::   jp_prec = 7           ! index of total precipitation (rain+snow) (Kg/m2/s)
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input fields (file informations, fields read)
+
+   INTEGER, PARAMETER  ::   jpintsr = 24          ! number of time step between sunrise and sunset
+   !                                              ! uses for heat flux computation
+   LOGICAL ::   lbulk_init = .TRUE.               ! flag, bulk initialization done or not)
+
+#if ! defined key_lim3                          
+   ! in namicerun with LIM3
+   REAL(wp) ::   cai = 1.40e-3 ! best estimate of atm drag in order to get correct FS export in ORCA2-LIM
+   REAL(wp) ::   cao = 1.00e-3 ! chosen by default  ==> should depends on many things...  !!gmto be updated
+#endif
+
+   REAL(wp) ::   rdtbs2      !:   
+   
+   REAL(wp), DIMENSION(19)  ::  budyko            ! BUDYKO's coefficient (cloudiness effect on LW radiation)
+   DATA budyko / 1.00, 0.98, 0.95, 0.92, 0.89, 0.86, 0.83, 0.80, 0.78, 0.75,   &
+      &          0.72, 0.69, 0.67, 0.64, 0.61, 0.58, 0.56, 0.53, 0.50 /
+   REAL(wp), DIMENSION(20)  :: tauco              ! cloud optical depth coefficient
+   DATA tauco / 6.6, 6.6, 7.0, 7.2, 7.1, 6.8, 6.5, 6.6, 7.1, 7.6,   &
+      &         6.6, 6.1, 5.6, 5.5, 5.8, 5.8, 5.6, 5.6, 5.6, 5.6 /
+   !!
+   REAL(wp), DIMENSION(jpi,jpj) ::   sbudyko      ! cloudiness effect on LW radiation
+   REAL(wp), DIMENSION(jpi,jpj) ::   stauc        ! cloud optical depth 
+   
+   REAL(wp)  ::   zeps    = 1.e-20                ! constant values
+   REAL(wp)  ::   zeps0   = 1.e-13  
+   
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_blk_clio( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_blk_clio  ***
+      !!                   
+      !! ** Purpose :   provide at each time step the surface ocean fluxes
+      !!      (momentum, heat, freshwater and runoff) 
+      !!
+      !! ** Method  : (1) READ each fluxes in NetCDF files:
+      !!      the i-component of the stress                (N/m2)
+      !!      the j-component of the stress                (N/m2)
+      !!      the 10m wind pseed module                    (m/s)
+      !!      the 10m air temperature                      (Kelvin)
+      !!      the 10m specific humidity                    (-)
+      !!      the cloud cover                              (-)
+      !!      the total precipitation (rain+snow)          (Kg/m2/s)
+      !!              (2) CALL blk_oce_clio
+      !!
+      !!      C A U T I O N : never mask the surface stress fields
+      !!                      the stress is assumed to be in the mesh referential
+      !!                      i.e. the (i,j) referential
+      !!
+      !! ** Action  :   defined at each time-step at the air-sea interface
+      !!              - utau, vtau  i- and j-component of the wind stress
+      !!              - taum        wind stress module at T-point
+      !!              - wndm        10m wind module at T-point
+      !!              - qns, qsr    non-slor and solar heat flux
+      !!              - emp, emps   evaporation minus precipitation
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
+      !!
+      INTEGER  ::   ifpr, jfpr         ! dummy indices
+      INTEGER  ::   ierror             ! return error code
+      !!
+      CHARACTER(len=100) ::  cn_dir                            !   Root directory for location of CLIO files
+      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                 ! array of namelist informations on the fields to read
+      TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_wndm, sn_tair      ! informations about the fields to be read
+      TYPE(FLD_N) ::   sn_humi, sn_ccov, sn_prec               !   "                                 "
+      !!
+      NAMELIST/namsbc_clio/ cn_dir, sn_utau, sn_vtau, sn_wndm, sn_humi,   &
+         &                          sn_ccov, sn_tair, sn_prec
+      !!---------------------------------------------------------------------
+
+      !                                         ! ====================== !
+      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
+         !                                      ! ====================== !
+         ! set file information (default values)
+         cn_dir = './'       ! directory in which the model is executed
+
+         ! (NB: frequency positive => hours, negative => months)
+         !            !    file     ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
+         !            !    name     !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
+         sn_utau = FLD_N( 'utau'    ,    24     ,  'utau'    ,  .true.    , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_vtau = FLD_N( 'vtau'    ,    24     ,  'vtau'    ,  .true.    , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_wndm = FLD_N( 'mwnd10m' ,    24     ,  'm_10'    ,  .true.    , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_tair = FLD_N( 'tair10m' ,    24     ,  't_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_humi = FLD_N( 'humi10m' ,    24     ,  'q_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_ccov = FLD_N( 'ccover'  ,    -1     ,  'cloud'   ,  .true.    , .false. ,   'yearly'  , ''       , ''         ) 
+         sn_prec = FLD_N( 'precip'  ,    -1     ,  'precip'  ,  .true.    , .false. ,   'yearly'  , ''       , ''         ) 
+
+         REWIND( numnam )                    ! ... read in namlist namsbc_clio
+         READ  ( numnam, namsbc_clio )
+
+         ! store namelist information in an array
+         slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau   ;   slf_i(jp_wndm) = sn_wndm
+         slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
+         slf_i(jp_ccov) = sn_ccov   ;   slf_i(jp_prec) = sn_prec
+         
+         ! set sf structure
+         ALLOCATE( sf(jpfld), STAT=ierror )
+         IF( ierror > 0 ) THEN
+            CALL ctl_stop( 'sbc_blk_clio: unable to allocate sf structure' )   ;   RETURN
+         ENDIF
+
+         DO ifpr= 1, jpfld
+            ALLOCATE( sf(ifpr)%fnow(jpi,jpj) )
+            ALLOCATE( sf(ifpr)%fdta(jpi,jpj,2) )
+         END DO
+
+
+         ! fill sf with slf_i and control print
+         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_clio', 'flux formulation for ocean surface boundary condition', 'namsbc_clio' )
+         !
+      ENDIF
+      !                                         ! ====================== !
+      !                                         !    At each time-step   !
+      !                                         ! ====================== !
+      !
+      CALL fld_read( kt, nn_fsbc, sf )                ! input fields provided at the current time-step
+      !
+#if defined key_lim3      
+      tatm_ice(:,:) = sf(jp_tair)%fnow(:,:)     !RB ugly patch
+#endif
+      !
+      IF(lwp .AND. nitend-nit000 <= 100 ) THEN
+         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' read monthly CLIO fluxes: ok, kt: ', kt
+            WRITE(numout,*)
+            ifpr = INT(jpi/8)      ;      jfpr = INT(jpj/10)
+            WRITE(numout,*) TRIM(sf(jp_utau)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_utau)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_vtau)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_vtau)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_humi)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_humi)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_wndm)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_wndm)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_ccov)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_ccov)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_prec)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_prec)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+            WRITE(numout,*) TRIM(sf(jp_tair)%clvar),' day: ',ndastp
+            CALL prihre( sf(jp_tair)%fnow,jpi,jpj,1,jpi,ifpr,1,jpj,jfpr,0.,numout )
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+
+      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
+          CALL blk_oce_clio( sf, sst_m )                  ! compute the surface ocean fluxes using CLIO bulk formulea
+      ENDIF                                               ! 
+      !
+   END SUBROUTINE sbc_blk_clio
+
+
+   SUBROUTINE blk_oce_clio( sf, pst )
+      !!---------------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_oce_clio  ***
+      !!                 
+      !!  ** Purpose :   Compute momentum, heat and freshwater fluxes at ocean surface
+      !!               using CLIO bulk formulea
+      !!         
+      !!  ** Method  :   The flux of heat at the ocean surfaces are derived
+      !!       from semi-empirical ( or bulk ) formulae which relate the flux to 
+      !!       the properties of the surface and of the lower atmosphere. Here, we
+      !!       follow the work of Oberhuber, 1988   
+      !!               - momentum flux (stresses) directly read in files at U- and V-points
+      !!               - compute ocean/ice albedos (call albedo_oce/albedo_ice)  
+      !!               - compute shortwave radiation for ocean (call blk_clio_qsr_oce)
+      !!               - compute long-wave radiation for the ocean
+      !!               - compute the turbulent heat fluxes over the ocean
+      !!               - deduce the evaporation over the ocean
+      !!  ** Action  :   Fluxes over the ocean:
+      !!               - utau, vtau  i- and j-component of the wind stress
+      !!               - taum        wind stress module at T-point
+      !!               - wndm        10m wind module at T-point
+      !!               - qns, qsr    non-slor and solar heat flux
+      !!               - emp, emps   evaporation minus precipitation
+      !!  ** Nota    :   sf has to be a dummy argument for AGRIF on NEC
+      !!----------------------------------------------------------------------
+      TYPE(fld), INTENT(in), DIMENSION(:)       ::   sf    ! input data
+      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj) ::   pst   ! surface temperature                      [Celcius]
+      !!
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      !!
+      REAL(wp) ::   zrhova, zcsho, zcleo, zcldeff               ! temporary scalars
+      REAL(wp) ::   zqsato, zdteta, zdeltaq, ztvmoy, zobouks    !    -         -
+      REAL(wp) ::   zpsims, zpsihs, zpsils, zobouku, zxins, zpsimu   !    -         -
+      REAL(wp) ::   zpsihu, zpsilu, zstab,zpsim, zpsih, zpsil   !    -         -
+      REAL(wp) ::   zvatmg, zcmn, zchn, zcln, zcmcmn, zdenum    !    -         -
+      REAL(wp) ::   zdtetar, ztvmoyr, zlxins, zchcm, zclcm      !    -         -
+      REAL(wp) ::   zmt1, zmt2, zmt3, ztatm3, ztamr, ztaevbk    !    -         -
+      REAL(wp) ::   zsst, ztatm, zcco1, zpatm, zcmax, zrmax     !    -         -
+      REAL(wp) ::   zrhoa, zev, zes, zeso, zqatm, zevsqr        !    -         -
+      REAL(wp) ::   ztx2, zty2                                  !    -         -
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqlw        ! long-wave heat flux over ocean
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqla        ! latent heat flux over ocean
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqsb        ! sensible heat flux over ocean
+      !!---------------------------------------------------------------------
+
+      zpatm = 101000.      ! atmospheric pressure  (assumed constant here)
+
+      !------------------------------------!
+      !   momentum fluxes  (utau, vtau )   !
+      !------------------------------------!
+!CDIR COLLAPSE
+      DO jj = 1 , jpj
+         DO ji = 1, jpi
+            utau(ji,jj) = sf(jp_utau)%fnow(ji,jj)
+            vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj)
+         END DO
+      END DO
+
+      !------------------------------------!
+      !   wind stress module (taum )       !
+      !------------------------------------!
+!CDIR NOVERRCHK
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
+            zty2 = vtau(ji  ,jj-1) + vtau(ji,jj)
+            taum(ji,jj) = 0.5 * SQRT( ztx2 * ztx2 + zty2 * zty2 )
+         END DO
+      END DO
+      CALL lbc_lnk( taum, 'T', 1. )
+
+      !------------------------------------!
+      !   store the wind speed  (wndm )    !
+      !------------------------------------!
+!CDIR COLLAPSE
+      DO jj = 1 , jpj
+         DO ji = 1, jpi
+            wndm(ji,jj) = sf(jp_wndm)%fnow(ji,jj)
+         END DO
+      END DO
+
+      !------------------------------------------------!
+      !   Shortwave radiation for ocean and snow/ice   !
+      !------------------------------------------------!
+      
+      CALL blk_clio_qsr_oce( qsr )
+
+      !------------------------!
+      !   Other ocean fluxes   !
+      !------------------------!
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            !
+            zsst  = pst(ji,jj)              + rt0           ! converte Celcius to Kelvin the SST
+            ztatm = sf(jp_tair)%fnow(ji,jj)                 ! and set minimum value far above 0 K (=rt0 over land)
+            zcco1 = 1.0 - sf(jp_ccov)%fnow(ji,jj)           ! fraction of clear sky ( 1 - cloud cover)
+            zrhoa = zpatm / ( 287.04 * ztatm )              ! air density (equation of state for dry air) 
+            ztamr = ztatm - rtt                             ! Saturation water vapour
+            zmt1  = SIGN( 17.269,  ztamr )                  !           ||
+            zmt2  = SIGN( 21.875,  ztamr )                  !          \  /
+            zmt3  = SIGN( 28.200, -ztamr )                  !           \/
+            zes   = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 ) / ( ztatm - 35.86  + MAX( 0.e0, zmt3 ) )  )
+            zev    = sf(jp_humi)%fnow(ji,jj) * zes          ! vapour pressure  
+            zevsqr = SQRT( zev * 0.01 )                     ! square-root of vapour pressure
+            zqatm = 0.622 * zev / ( zpatm - 0.378 * zev )   ! specific humidity 
+
+            !--------------------------------------!
+            !  long-wave radiation over the ocean  !  ( Berliand 1952 ; all latitudes )
+            !--------------------------------------!
+            ztatm3  = ztatm * ztatm * ztatm
+            zcldeff = 1.0 - sbudyko(ji,jj) * sf(jp_ccov)%fnow(ji,jj) * sf(jp_ccov)%fnow(ji,jj)    
+            ztaevbk = ztatm * ztatm3 * zcldeff * ( 0.39 - 0.05 * zevsqr ) 
+            !
+            zqlw(ji,jj) = - emic * stefan * ( ztaevbk + 4. * ztatm3 * ( zsst - ztatm ) ) 
+
+            !--------------------------------------------------
+            !  Latent and sensible heat fluxes over the ocean 
+            !--------------------------------------------------
+            !                                                          ! vapour pressure at saturation of ocean
+            zeso =  611.0 * EXP ( 17.2693884 * ( zsst - rtt ) * tmask(ji,jj,1) / ( zsst - 35.86 ) )
+
+            zqsato = ( 0.622 * zeso ) / ( zpatm - 0.378 * zeso )       ! humidity close to the ocean surface (at saturation)
+
+            ! Drag coefficients from Large and Pond (1981,1982)
+            !                                                          ! Stability parameters
+            zdteta  = zsst - ztatm
+            zdeltaq = zqatm - zqsato
+            ztvmoy  = ztatm * ( 1. + 2.2e-3 * ztatm * zqatm )
+            zdenum  = MAX( sf(jp_wndm)%fnow(ji,jj) * sf(jp_wndm)%fnow(ji,jj) * ztvmoy, zeps )
+            zdtetar = zdteta / zdenum
+            ztvmoyr = ztvmoy * ztvmoy * zdeltaq / zdenum
+            !                                                          ! case of stable atmospheric conditions
+            zobouks = -70.0 * 10. * ( zdtetar + 3.2e-3 * ztvmoyr )
+            zobouks = MAX( 0.e0, zobouks )
+            zpsims = -7.0 * zobouks
+            zpsihs =  zpsims
+            zpsils =  zpsims
+            !                                                          ! case of unstable atmospheric conditions
+            zobouku = MIN(  0.e0, -100.0 * 10.0 * ( zdtetar + 2.2e-3 * ztvmoyr )  )
+            zxins   = ( 1. - 16. * zobouku )**0.25
+            zlxins  = LOG( ( 1. + zxins * zxins ) / 2. )
+            zpsimu  = 2. * LOG( ( 1 + zxins ) * 0.5 )  + zlxins - 2. * ATAN( zxins ) + rpi * 0.5
+            zpsihu  = 2. * zlxins
+            zpsilu  = zpsihu
+            !                                                          ! intermediate values
+            zstab   = MAX( 0.e0, SIGN( 1.e0, zdteta ) )
+            zpsim   = zstab * zpsimu + ( 1.0 - zstab ) * zpsims
+            zpsih   = zstab * zpsihu + ( 1.0 - zstab ) * zpsihs
+            zpsil   = zpsih
+            
+            zvatmg         = MAX( 0.032 * 1.5e-3 * sf(jp_wndm)%fnow(ji,jj) * sf(jp_wndm)%fnow(ji,jj) / grav, zeps )
+            zcmn           = vkarmn / LOG ( 10. / zvatmg )
+            zchn           = 0.0327 * zcmn
+            zcln           = 0.0346 * zcmn
+            zcmcmn         = 1. / ( 1. - zcmn * zpsim / vkarmn )
+            ! sometimes the ratio zchn * zpsih / ( vkarmn * zcmn ) is too close to 1 and zchcm becomes very very big
+            zcmax = 0.1               ! choice for maximum value of the heat transfer coefficient, guided by my intuition
+            zrmax = 1 - 3.e-4 / zcmax ! maximum value of the ratio
+            zchcm = zcmcmn / ( 1. - MIN ( zchn * zpsih / ( vkarmn * zcmn ) , zrmax ) )
+            zclcm          = zchcm
+            !                                                          ! transfert coef. (Large and Pond 1981,1982)
+            zcsho          = zchn * zchcm                                
+            zcleo          = zcln * zclcm 
+
+            zrhova         = zrhoa * sf(jp_wndm)%fnow(ji,jj)
+
+            ! sensible heat flux
+            zqsb(ji,jj) = zrhova * zcsho * 1004.0  * ( zsst - ztatm )  
+         
+            ! latent heat flux (bounded by zero)
+            zqla(ji,jj) = MAX(  0.e0, zrhova * zcleo * 2.5e+06 * ( zqsato - zqatm )  )
+            !               
+         END DO
+      END DO
+      
+      ! ----------------------------------------------------------------------------- !
+      !     III    Total FLUXES                                                       !
+      ! ----------------------------------------------------------------------------- !
+
+!CDIR COLLAPSE
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            qns (ji,jj) = zqlw(ji,jj) - zqsb(ji,jj) - zqla(ji,jj)      ! Downward Non Solar flux
+            emp (ji,jj) = zqla(ji,jj) / cevap - sf(jp_prec)%fnow(ji,jj) / rday * tmask(ji,jj,1)
+         END DO
+      END DO
+      emps(:,:) = emp(:,:)
+      !
+      CALL iom_put( "qlw_oce",   zqlw )   ! output downward longwave  heat over the ocean
+      CALL iom_put( "qsb_oce", - zqsb )   ! output downward sensible  heat over the ocean
+      CALL iom_put( "qla_oce", - zqla )   ! output downward latent    heat over the ocean
+      CALL iom_put( "qns_oce",   qns  )   ! output downward non solar heat over the ocean
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_clio: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
+         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_clio: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
+         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_clio: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
+         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_clio: utau   : ', mask1=umask,   &
+            &         tab2d_2=vtau , clinfo2=' vtau : ', mask2=vmask )
+      ENDIF
+
+   END SUBROUTINE blk_oce_clio
+
+
+   SUBROUTINE blk_ice_clio(  pst   , palb_cs, palb_os ,       &
+      &                      p_taui, p_tauj, p_qns , p_qsr,   &
+      &                      p_qla , p_dqns, p_dqla,          &
+      &                      p_tpr , p_spr ,                  &
+      &                      p_fr1 , p_fr2 , cd_grid, pdim  )
+      !!---------------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_ice_clio  ***
+      !!                 
+      !!  ** Purpose :   Computation of the heat fluxes at ocean and snow/ice
+      !!       surface the solar heat at ocean and snow/ice surfaces and the 
+      !!       sensitivity of total heat fluxes to the SST variations
+      !!         
+      !!  ** Method  :   The flux of heat at the ice and ocean surfaces are derived
+      !!       from semi-empirical ( or bulk ) formulae which relate the flux to 
+      !!       the properties of the surface and of the lower atmosphere. Here, we
+      !!       follow the work of Oberhuber, 1988   
+      !!
+      !!  ** Action  :   call albedo_oce/albedo_ice to compute ocean/ice albedo 
+      !!          computation of snow precipitation
+      !!          computation of solar flux at the ocean and ice surfaces
+      !!          computation of the long-wave radiation for the ocean and sea/ice
+      !!          computation of turbulent heat fluxes over water and ice
+      !!          computation of evaporation over water
+      !!          computation of total heat fluxes sensitivity over ice (dQ/dT)
+      !!          computation of latent heat flux sensitivity over ice (dQla/dT)
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   pst      ! ice surface temperature                   [Kelvin]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   palb_cs  ! ice albedo (clear    sky) (alb_ice_cs)         [%]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   palb_os  ! ice albedo (overcast sky) (alb_ice_os)         [%]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_taui   ! surface ice stress at I-point (i-component) [N/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_tauj   ! surface ice stress at I-point (j-component) [N/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qns    ! non solar heat flux over ice (T-point)      [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qsr    !     solar heat flux over ice (T-point)      [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qla    ! latent    heat flux over ice (T-point)      [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_dqns   ! non solar heat sensistivity  (T-point)      [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_dqla   ! latent    heat sensistivity  (T-point)      [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_tpr    ! total precipitation          (T-point)   [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_spr    ! solid precipitation          (T-point)   [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_fr1    ! 1sr fraction of qsr penetration in ice         [%]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_fr2    ! 2nd fraction of qsr penetration in ice         [%]
+      CHARACTER(len=1), INTENT(in   )             ::   cd_grid  ! type of sea-ice grid ("C" or "B" grid)
+      INTEGER, INTENT(in   )                      ::   pdim     ! number of ice categories
+      !!
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
+      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
+      !!
+      REAL(wp) ::   zcoef, zmt1, zmt2, zmt3, ztatm3             ! temporary scalars
+      REAL(wp) ::   ztaevbk, zind1, zind2, zind3, ztamr         !    -         -
+      REAL(wp) ::   zesi, zqsati, zdesidt                       !    -         -
+      REAL(wp) ::   zdqla, zcldeff, zev, zes, zpatm, zrhova     !    -         -
+      REAL(wp) ::   zcshi, zclei, zrhovaclei, zrhovacshi        !    -         -
+      REAL(wp) ::   ztice3, zticemb, zticemb2, zdqlw, zdqsb     !    -         -
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztatm   ! Tair in Kelvin
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqatm   ! specific humidity
+      REAL(wp), DIMENSION(jpi,jpj) ::   zevsqr  ! vapour pressure square-root
+      REAL(wp), DIMENSION(jpi,jpj) ::   zrhoa   ! air density
+      REAL(wp), DIMENSION(jpi,jpj,pdim) ::   z_qlw, z_qsb
+      !!---------------------------------------------------------------------
+
+      ijpl  = pdim                           ! number of ice categories
+      zpatm = 101000.                        ! atmospheric pressure  (assumed constant  here)
+
+      !------------------------------------!
+      !   momentum fluxes  (utau, vtau )   !
+      !------------------------------------!
+
+      SELECT CASE( cd_grid )
+      CASE( 'C' )                          ! C-grid ice dynamics
+         ! Change from wind speed to wind stress over OCEAN (cao is used)
+         zcoef = cai / cao 
+!CDIR COLLAPSE
+         DO jj = 1 , jpj
+            DO ji = 1, jpi
+               p_taui(ji,jj) = zcoef * utau(ji,jj)
+               p_tauj(ji,jj) = zcoef * vtau(ji,jj)
+            END DO
+         END DO
+      CASE( 'B' )                          ! B-grid ice dynamics
+         ! stress from ocean U- and V-points to ice U,V point
+!CDIR COLLAPSE
+         DO jj = 2, jpj
+            DO ji = 2, jpi   ! B grid : no vector opt.
+               p_taui(ji,jj) = 0.5 * ( utau(ji-1,jj  ) + utau(ji-1,jj-1) )
+               p_tauj(ji,jj) = 0.5 * ( vtau(ji  ,jj-1) + vtau(ji-1,jj-1) )
+            END DO
+         END DO
+         CALL lbc_lnk( p_taui(:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+         CALL lbc_lnk( p_tauj(:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+      END SELECT
+
+
+      !  Determine cloud optical depths as a function of latitude (Chou et al., 1981).
+      !  and the correction factor for taking into account  the effect of clouds 
+      !------------------------------------------------------
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            ztatm (ji,jj) = sf(jp_tair)%fnow(ji,jj)                  ! air temperature in Kelvins 
+      
+            zrhoa(ji,jj) = zpatm / ( 287.04 * ztatm(ji,jj) )         ! air density (equation of state for dry air) 
+      
+            ztamr = ztatm(ji,jj) - rtt                               ! Saturation water vapour
+            zmt1  = SIGN( 17.269,  ztamr )
+            zmt2  = SIGN( 21.875,  ztamr )
+            zmt3  = SIGN( 28.200, -ztamr )
+            zes   = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &
+               &                / ( ztatm(ji,jj) - 35.86  + MAX( 0.e0, zmt3 ) )  )
+
+            zev = sf(jp_humi)%fnow(ji,jj) * zes                      ! vapour pressure  
+            zevsqr(ji,jj) = SQRT( zev * 0.01 )                       ! square-root of vapour pressure
+            zqatm(ji,jj) = 0.622 * zev / ( zpatm - 0.378 * zev )     ! specific humidity 
+
+            !----------------------------------------------------
+            !   Computation of snow precipitation (Ledley, 1985) |
+            !----------------------------------------------------
+            zmt1  =   253.0 - ztatm(ji,jj)            ;   zind1 = MAX( 0.e0, SIGN( 1.e0, zmt1 ) )
+            zmt2  = ( 272.0 - ztatm(ji,jj) ) / 38.0   ;   zind2 = MAX( 0.e0, SIGN( 1.e0, zmt2 ) )
+            zmt3  = ( 281.0 - ztatm(ji,jj) ) / 18.0   ;   zind3 = MAX( 0.e0, SIGN( 1.e0, zmt3 ) )
+            p_spr(ji,jj) = sf(jp_prec)%fnow(ji,jj) / rday   &        ! rday = converte mm/day to kg/m2/s
+               &         * (          zind1      &                   ! solid  (snow) precipitation [kg/m2/s]
+               &            + ( 1.0 - zind1 ) * (          zind2   * ( 0.5 + zmt2 )   &
+               &                                 + ( 1.0 - zind2 ) *  zind3 * zmt3  )   ) 
+
+            !----------------------------------------------------!
+            !  fraction of net penetrative shortwave radiation   !
+            !----------------------------------------------------!
+            ! fraction of qsr_ice which is NOT absorbed in the thin surface layer
+            ! and thus which penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+            p_fr1(ji,jj) = 0.18  * ( 1.e0 - sf(jp_ccov)%fnow(ji,jj) ) + 0.35 * sf(jp_ccov)%fnow(ji,jj) 
+            p_fr2(ji,jj) = 0.82  * ( 1.e0 - sf(jp_ccov)%fnow(ji,jj) ) + 0.65 * sf(jp_ccov)%fnow(ji,jj)
+         END DO
+      END DO
+      CALL iom_put( 'snowpre', p_spr )   ! Snow precipitation 
+      
+      !-----------------------------------------------------------!
+      !  snow/ice Shortwave radiation   (abedo already computed)  !
+      !-----------------------------------------------------------!
+      CALL blk_clio_qsr_ice( palb_cs, palb_os, p_qsr )
+
+      !                                     ! ========================== !
+      DO jl = 1, ijpl                       !  Loop over ice categories  !
+         !                                  ! ========================== !
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+         DO jj = 1 , jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               !-------------------------------------------!
+               !  long-wave radiation over ice categories  !  ( Berliand 1952 ; all latitudes )
+               !-------------------------------------------!
+               ztatm3  = ztatm(ji,jj) * ztatm(ji,jj) * ztatm(ji,jj)
+               zcldeff = 1.0 - sbudyko(ji,jj) * sf(jp_ccov)%fnow(ji,jj) * sf(jp_ccov)%fnow(ji,jj)    
+               ztaevbk = ztatm3 * ztatm(ji,jj) * zcldeff * ( 0.39 - 0.05 * zevsqr(ji,jj) ) 
+               !
+               z_qlw(ji,jj,jl) = - emic * stefan * ( ztaevbk + 4. * ztatm3 * ( pst(ji,jj,jl) - ztatm(ji,jj) ) ) 
+
+               !----------------------------------------
+               !  Turbulent heat fluxes over snow/ice     ( Latent and sensible ) 
+               !----------------------------------------        
+
+               ! vapour pressure at saturation of ice (tmask to avoid overflow in the exponential)
+               zesi =  611.0 * EXP( 21.8745587 * tmask(ji,jj,1) * ( pst(ji,jj,jl) - rtt )/ ( pst(ji,jj,jl) - 7.66 ) )
+               ! humidity close to the ice surface (at saturation)
+               zqsati   = ( 0.622 * zesi ) / ( zpatm - 0.378 * zesi )
+               
+               !  computation of intermediate values
+               zticemb  = pst(ji,jj,jl) - 7.66
+               zticemb2 = zticemb * zticemb  
+               ztice3   = pst(ji,jj,jl) * pst(ji,jj,jl) * pst(ji,jj,jl)
+               zdesidt  = zesi * ( 9.5 * LOG( 10.0 ) * ( rtt - 7.66 )  / zticemb2 )
+               
+               !  Transfer cofficients assumed to be constant (Parkinson 1979 ; Maykut 1982)
+               zcshi    = 1.75e-03
+               zclei    = zcshi
+               
+               !  sensible and latent fluxes over ice
+               zrhova     = zrhoa(ji,jj) * sf(jp_wndm)%fnow(ji,jj)      ! computation of intermediate values
+               zrhovaclei = zrhova * zcshi * 2.834e+06
+               zrhovacshi = zrhova * zclei * 1004.0
+            
+               !  sensible heat flux
+               z_qsb(ji,jj,jl) = zrhovacshi * ( pst(ji,jj,jl) - ztatm(ji,jj) )
+            
+               !  latent heat flux 
+               p_qla(ji,jj,jl) = MAX(  0.e0, zrhovaclei * ( zqsati - zqatm(ji,jj) )  )
+              
+               !  sensitivity of non solar fluxes (dQ/dT) (long-wave, sensible and latent fluxes)
+               zdqlw = 4.0 * emic * stefan * ztice3
+               zdqsb = zrhovacshi
+               zdqla = zrhovaclei * ( zdesidt * ( zqsati * zqsati / ( zesi * zesi ) ) * ( zpatm / 0.622 ) )   
+               !
+               p_dqla(ji,jj,jl) = zdqla                           ! latent flux sensitivity
+               p_dqns(ji,jj,jl) = -( zdqlw + zdqsb + zdqla )      !  total non solar sensitivity
+            END DO
+            !
+         END DO
+         !
+      END DO
+      !
+      ! ----------------------------------------------------------------------------- !
+      !    Total FLUXES                                                       !
+      ! ----------------------------------------------------------------------------- !
+      !
+!CDIR COLLAPSE
+      p_qns(:,:,:) = z_qlw (:,:,:) - z_qsb (:,:,:) - p_qla (:,:,:)      ! Downward Non Solar flux
+!CDIR COLLAPSE
+      p_tpr(:,:)   = sf(jp_prec)%fnow(:,:) / rday                       ! total precipitation [kg/m2/s]
+      !
+!!gm : not necessary as all input data are lbc_lnk...
+      CALL lbc_lnk( p_fr1  (:,:) , 'T', 1. )
+      CALL lbc_lnk( p_fr2  (:,:) , 'T', 1. )
+      DO jl = 1, ijpl
+         CALL lbc_lnk( p_qns (:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( p_dqns(:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( p_qla (:,:,jl) , 'T', 1. )
+         CALL lbc_lnk( p_dqla(:,:,jl) , 'T', 1. )
+      END DO
+
+!!gm : mask is not required on forcing
+      DO jl = 1, ijpl
+         p_qns (:,:,jl) = p_qns (:,:,jl) * tmask(:,:,1)
+         p_qla (:,:,jl) = p_qla (:,:,jl) * tmask(:,:,1)
+         p_dqns(:,:,jl) = p_dqns(:,:,jl) * tmask(:,:,1)
+         p_dqla(:,:,jl) = p_dqla(:,:,jl) * tmask(:,:,1)
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=z_qsb  , clinfo1=' blk_ice_clio: z_qsb  : ', tab3d_2=z_qlw  , clinfo2=' z_qlw  : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=p_qla  , clinfo1=' blk_ice_clio: z_qla  : ', tab3d_2=p_qsr  , clinfo2=' p_qsr  : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=p_dqns , clinfo1=' blk_ice_clio: p_dqns : ', tab3d_2=p_qns  , clinfo2=' p_qns  : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=p_dqla , clinfo1=' blk_ice_clio: p_dqla : ', tab3d_2=pst    , clinfo2=' pst    : ', kdim=ijpl)
+         CALL prt_ctl(tab2d_1=p_tpr  , clinfo1=' blk_ice_clio: p_tpr  : ', tab2d_2=p_spr  , clinfo2=' p_spr  : ')
+         CALL prt_ctl(tab2d_1=p_taui , clinfo1=' blk_ice_clio: p_taui : ', tab2d_2=p_tauj , clinfo2=' p_tauj : ')
+      ENDIF
+
+
+   END SUBROUTINE blk_ice_clio
+
+
+   SUBROUTINE blk_clio_qsr_oce( pqsr_oce )
+      !!---------------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_clio_qsr_oce  ***
+      !!                 
+      !!  ** Purpose :   Computation of the shortwave radiation at the ocean and the
+      !!               snow/ice surfaces. 
+      !!         
+      !!  ** Method  : - computed qsr from the cloud cover for both ice and ocean 
+      !!               - also initialise sbudyko and stauc once for all 
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)     ::   pqsr_oce    ! shortwave radiation  over the ocean
+      !!
+      INTEGER, PARAMETER  ::   jp24 = 24   ! sampling of the daylight period (sunrise to sunset) into 24 equal parts
+      !!      
+      INTEGER  ::   ji, jj, jt    ! dummy loop indices 
+      INTEGER  ::   indaet            !  = -1, 0, 1 for odd, normal and leap years resp.
+      INTEGER  ::   iday              ! integer part of day
+      INTEGER  ::   indxb, indxc      ! index for cloud depth coefficient
+
+      REAL(wp)  ::   zalat , zclat, zcmue, zcmue2    ! local scalars 
+      REAL(wp)  ::   zmt1, zmt2, zmt3                ! 
+      REAL(wp)  ::   zdecl, zsdecl , zcdecl          ! 
+      REAL(wp)  ::   za_oce, ztamr                   !
+
+      REAL(wp) ::   zdl, zlha                        ! local scalars
+      REAL(wp) ::   zlmunoon, zcldcor, zdaycor       !   
+      REAL(wp) ::   zxday, zdist, zcoef, zcoef1      !
+      REAL(wp) ::   zes
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zev          ! vapour pressure
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdlha, zlsrise, zlsset     ! 2D workspace
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   zps, zpc   ! sine (cosine) of latitude per sine (cosine) of solar declination 
+      !!---------------------------------------------------------------------
+
+
+      IF( lbulk_init ) THEN             !   Initilization at first time step only
+         rdtbs2 = nn_fsbc * rdt * 0.5
+         ! cloud optical depths as a function of latitude (Chou et al., 1981).
+         ! and the correction factor for taking into account  the effect of clouds 
+         DO jj = 1, jpj
+            DO ji = 1 , jpi
+               zalat          = ( 90.e0 - ABS( gphit(ji,jj) ) ) /  5.e0
+               zclat          = ( 95.e0 -      gphit(ji,jj)   ) / 10.e0
+               indxb          = 1 + INT( zalat )
+               indxc          = 1 + INT( zclat )
+               zdl            = zclat - INT( zclat )
+               !  correction factor to account for the effect of clouds
+               sbudyko(ji,jj) = budyko(indxb)
+               stauc  (ji,jj) = ( 1.e0 - zdl ) * tauco( indxc ) + zdl * tauco( indxc + 1 )
+            END DO
+         END DO
+         lbulk_init = .FALSE.
+      ENDIF
+
+
+      ! Saturated water vapour and vapour pressure
+      ! ------------------------------------------
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            ztamr = sf(jp_tair)%fnow(ji,jj) - rtt
+            zmt1  = SIGN( 17.269,  ztamr )
+            zmt2  = SIGN( 21.875,  ztamr )
+            zmt3  = SIGN( 28.200, -ztamr )
+            zes = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &              ! Saturation water vapour
+               &                     / ( sf(jp_tair)%fnow(ji,jj) - 35.86  + MAX( 0.e0, zmt3 ) )  )
+            zev(ji,jj) = sf(jp_humi)%fnow(ji,jj) * zes * 1.0e-05                   ! vapour pressure  
+         END DO
+      END DO
+
+      !-----------------------------------!
+      !  Computation of solar irradiance  !
+      !-----------------------------------!
+!!gm : hard coded  leap year ???
+      indaet   = 1                                    ! = -1, 0, 1 for odd, normal and leap years resp.
+      zxday = nday_year + rdtbs2 / rday               ! day of the year at which the fluxes are calculated
+      iday  = INT( zxday )                            ! (centred at the middle of the ice time step)
+      CALL flx_blk_declin( indaet, iday, zdecl )      ! solar declination of the current day
+      zsdecl = SIN( zdecl * rad )                     ! its sine
+      zcdecl = COS( zdecl * rad )                     ! its cosine
+
+
+      !  correction factor added for computation of shortwave flux to take into account the variation of
+      !  the distance between the sun and the earth during the year (Oberhuber 1988)
+      zdist    = zxday * 2. * rpi / REAL(nyear_len(1), wp)
+      zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            !  product of sine (cosine) of latitude and sine (cosine) of solar declination
+            zps(ji,jj) = SIN( gphit(ji,jj) * rad ) * zsdecl
+            zpc(ji,jj) = COS( gphit(ji,jj) * rad ) * zcdecl
+            !  computation of the both local time of sunrise and sunset
+            zlsrise(ji,jj) = ACOS( - SIGN( 1.e0, zps(ji,jj) )    &
+               &                   * MIN(  1.e0, SIGN( 1.e0, zps(ji,jj) ) * ( zps(ji,jj) / zpc(ji,jj) )  )   )
+            zlsset (ji,jj) = - zlsrise(ji,jj)
+            !  dividing the solar day into jp24 segments of length zdlha
+            zdlha  (ji,jj) = ( zlsrise(ji,jj) - zlsset(ji,jj) ) / REAL( jp24, wp )
+         END DO
+      END DO
+
+
+      !---------------------------------------------!
+      !  shortwave radiation absorbed by the ocean  !
+      !---------------------------------------------!
+      pqsr_oce(:,:)   = 0.e0      ! set ocean qsr to zero      
+
+      ! compute and sum ocean qsr over the daylight (i.e. between sunrise and sunset)
+!CDIR NOVERRCHK   
+      DO jt = 1, jp24
+         zcoef = FLOAT( jt ) - 0.5
+!CDIR NOVERRCHK     
+!CDIR COLLAPSE
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
+               zcmue              = MAX( 0.e0 ,   zps(ji,jj) + zpc(ji,jj) * zlha  )   ! cos of local solar altitude
+               zcmue2             = 1368.0 * zcmue * zcmue
+
+               ! ocean albedo depending on the cloud cover (Payne, 1972)
+               za_oce     = ( 1.0 - sf(jp_ccov)%fnow(ji,jj) ) * 0.05 / ( 1.1 * zcmue**1.4 + 0.15 )   &   ! clear sky
+                  &       +         sf(jp_ccov)%fnow(ji,jj)   * 0.06                                     ! overcast
+
+                  ! solar heat flux absorbed by the ocean (Zillman, 1972)
+               pqsr_oce(ji,jj) = pqsr_oce(ji,jj)                                         &
+                  &            + ( 1.0 - za_oce ) * zdlha(ji,jj) * zcmue2                &
+                  &            / ( ( zcmue + 2.7 ) * zev(ji,jj) + 1.085 * zcmue +  0.10 )
+            END DO
+         END DO
+      END DO
+      ! Taking into account the ellipsity of the earth orbit, the clouds AND masked if sea-ice cover > 0%
+      zcoef1 = srgamma * zdaycor / ( 2. * rpi )
+!CDIR COLLAPSE
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zlmunoon = ASIN( zps(ji,jj) + zpc(ji,jj) ) / rad                         ! local noon solar altitude
+            zcldcor  = MIN(  1.e0, ( 1.e0 - 0.62 * sf(jp_ccov)%fnow(ji,jj)   &       ! cloud correction (Reed 1977)
+               &                          + 0.0019 * zlmunoon )                 )
+            pqsr_oce(ji,jj) = zcoef1 * zcldcor * pqsr_oce(ji,jj) * tmask(ji,jj,1)   ! and zcoef1: ellipsity
+         END DO
+      END DO
+
+   END SUBROUTINE blk_clio_qsr_oce
+
+
+   SUBROUTINE blk_clio_qsr_ice( pa_ice_cs, pa_ice_os, pqsr_ice )
+      !!---------------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_clio_qsr_ice  ***
+      !!                 
+      !!  ** Purpose :   Computation of the shortwave radiation at the ocean and the
+      !!               snow/ice surfaces. 
+      !!         
+      !!  ** Method  : - computed qsr from the cloud cover for both ice and ocean 
+      !!               - also initialise sbudyko and stauc once for all 
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pa_ice_cs   ! albedo of ice under clear sky
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pa_ice_os   ! albedo of ice under overcast sky
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqsr_ice    ! shortwave radiation over the ice/snow
+      !!
+      INTEGER, PARAMETER  ::   jp24 = 24   ! sampling of the daylight period (sunrise to sunset) into 24 equal parts
+      !!
+      INTEGER  ::   ji, jj, jl, jt    ! dummy loop indices
+      INTEGER  ::   ijpl              ! number of ice categories (3rd dim of pqsr_ice)
+      INTEGER  ::   indaet            !  = -1, 0, 1 for odd, normal and leap years resp.
+      INTEGER  ::   iday              ! integer part of day
+      !!
+      REAL(wp) ::   zcmue, zcmue2, ztamr          ! temporary scalars 
+      REAL(wp) ::   zmt1, zmt2, zmt3              !    -         -
+      REAL(wp) ::   zdecl, zsdecl, zcdecl         !    -         -
+      REAL(wp) ::   zlha, zdaycor, zes            !    -         -
+      REAL(wp) ::   zxday, zdist, zcoef, zcoef1   !    -         -
+      REAL(wp) ::   zqsr_ice_cs, zqsr_ice_os      !    -         -
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zev                      ! vapour pressure
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdlha, zlsrise, zlsset   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zps, zpc   ! sine (cosine) of latitude per sine (cosine) of solar declination 
+      !!---------------------------------------------------------------------
+
+      ijpl = SIZE(pqsr_ice, 3 )      ! number of ice categories
+      
+      ! Saturated water vapour and vapour pressure
+      ! ------------------------------------------
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi           
+            ztamr = sf(jp_tair)%fnow(ji,jj) - rtt           
+            zmt1  = SIGN( 17.269,  ztamr )
+            zmt2  = SIGN( 21.875,  ztamr )
+            zmt3  = SIGN( 28.200, -ztamr )
+            zes = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &              ! Saturation water vapour
+               &                     / ( sf(jp_tair)%fnow(ji,jj) - 35.86  + MAX( 0.e0, zmt3 ) )  )
+            zev(ji,jj) = sf(jp_humi)%fnow(ji,jj) * zes * 1.0e-05                   ! vapour pressure  
+         END DO
+      END DO
+
+      !-----------------------------------!
+      !  Computation of solar irradiance  !
+      !-----------------------------------!
+!!gm : hard coded  leap year ???
+      indaet   = 1                                    ! = -1, 0, 1 for odd, normal and leap years resp.
+      zxday = nday_year + rdtbs2 / rday               ! day of the year at which the fluxes are calculated
+      iday  = INT( zxday )                            ! (centred at the middle of the ice time step)
+      CALL flx_blk_declin( indaet, iday, zdecl )      ! solar declination of the current day
+      zsdecl = SIN( zdecl * rad )                     ! its sine
+      zcdecl = COS( zdecl * rad )                     ! its cosine
+
+      
+      !  correction factor added for computation of shortwave flux to take into account the variation of
+      !  the distance between the sun and the earth during the year (Oberhuber 1988)
+      zdist    = zxday * 2. * rpi / REAL(nyear_len(1), wp)
+      zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            !  product of sine (cosine) of latitude and sine (cosine) of solar declination
+            zps(ji,jj) = SIN( gphit(ji,jj) * rad ) * zsdecl
+            zpc(ji,jj) = COS( gphit(ji,jj) * rad ) * zcdecl
+            !  computation of the both local time of sunrise and sunset
+            zlsrise(ji,jj) = ACOS( - SIGN( 1.e0, zps(ji,jj) )    &
+               &                   * MIN(  1.e0, SIGN( 1.e0, zps(ji,jj) ) * ( zps(ji,jj) / zpc(ji,jj) )  )   ) 
+            zlsset (ji,jj) = - zlsrise(ji,jj)
+            !  dividing the solar day into jp24 segments of length zdlha
+            zdlha  (ji,jj) = ( zlsrise(ji,jj) - zlsset(ji,jj) ) / REAL( jp24, wp )
+         END DO
+      END DO
+
+
+      !---------------------------------------------!
+      !  shortwave radiation absorbed by the ice    !
+      !---------------------------------------------!
+      ! compute and sum ice qsr over the daylight for each ice categories
+      pqsr_ice(:,:,:) = 0.e0
+      zcoef1 = zdaycor / ( 2. * rpi )       ! Correction for the ellipsity of the earth orbit
+      
+      !                    !----------------------------! 
+      DO jl = 1, ijpl      !  loop over ice categories  !
+         !                 !----------------------------! 
+!CDIR NOVERRCHK   
+         DO jt = 1, jp24   
+            zcoef = FLOAT( jt ) - 0.5
+!CDIR NOVERRCHK     
+!CDIR COLLAPSE
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
+                  zcmue              = MAX( 0.e0 ,   zps(ji,jj) + zpc(ji,jj) * zlha  )   ! cos of local solar altitude
+                  zcmue2             = 1368.0 * zcmue * zcmue
+                  
+                  !  solar heat flux absorbed by the ice/snow system (Shine and Crane 1984 adapted to high albedo) 
+                  zqsr_ice_cs =  ( 1.0 - pa_ice_cs(ji,jj,jl) ) * zdlha(ji,jj) * zcmue2        &   ! clear sky
+                     &        / ( ( 1.0 + zcmue ) * zev(ji,jj) + 1.2 * zcmue + 0.0455 )
+                  zqsr_ice_os = zdlha(ji,jj) * SQRT( zcmue )                                  &   ! overcast sky
+                     &        * ( 53.5 + 1274.5 * zcmue )      * ( 1.0 - 0.996  * pa_ice_os(ji,jj,jl) )    &
+                     &        / (  1.0 + 0.139  * stauc(ji,jj) * ( 1.0 - 0.9435 * pa_ice_os(ji,jj,jl) ) )       
+             
+                  pqsr_ice(ji,jj,jl) = pqsr_ice(ji,jj,jl) + (  ( 1.0 - sf(jp_ccov)%fnow(ji,jj) ) * zqsr_ice_cs    &
+                     &                                       +         sf(jp_ccov)%fnow(ji,jj)   * zqsr_ice_os  )
+               END DO
+            END DO
+         END DO
+         !
+         ! Correction : Taking into account the ellipsity of the earth orbit
+         pqsr_ice(:,:,jl) = pqsr_ice(:,:,jl) * zcoef1 * tmask(:,:,1)
+         !
+         !                 !--------------------------------! 
+      END DO               !  end loop over ice categories  !
+      !                    !--------------------------------! 
+
+
+!!gm  : this should be suppress as input data have been passed through lbc_lnk
+      DO jl = 1, ijpl
+         CALL lbc_lnk( pqsr_ice(:,:,jl) , 'T', 1. )
+      END DO
+      !
+   END SUBROUTINE blk_clio_qsr_ice
+
+
+   SUBROUTINE flx_blk_declin( ky, kday, pdecl )
+      !!---------------------------------------------------------------------------
+      !!               ***  ROUTINE flx_blk_declin  ***
+      !!          
+      !! ** Purpose :   Computation of the solar declination for the day
+      !!       
+      !! ** Method  :   ???
+      !!---------------------------------------------------------------------
+      INTEGER , INTENT(in   ) ::   ky      ! = -1, 0, 1 for odd, normal and leap years resp.
+      INTEGER , INTENT(in   ) ::   kday    ! day of the year ( kday = 1 on january 1)
+      REAL(wp), INTENT(  out) ::   pdecl   ! solar declination
+      !!
+      REAL(wp) ::   a0  =  0.39507671      ! coefficients for solar declinaison computation
+      REAL(wp) ::   a1  = 22.85684301      !     "              ""                 "
+      REAL(wp) ::   a2  = -0.38637317      !     "              ""                 "
+      REAL(wp) ::   a3  =  0.15096535      !     "              ""                 "
+      REAL(wp) ::   a4  = -0.00961411      !     "              ""                 "
+      REAL(wp) ::   b1  = -4.29692073      !     "              ""                 "
+      REAL(wp) ::   b2  =  0.05702074      !     "              ""                 "
+      REAL(wp) ::   b3  = -0.09028607      !     "              ""                 "
+      REAL(wp) ::   b4  =  0.00592797
+      !!
+      REAL(wp) ::   zday   ! corresponding day of type year (cf. ky)
+      REAL(wp) ::   zp     ! temporary scalars
+      !!---------------------------------------------------------------------
+            
+      IF    ( ky == 1 )  THEN   ;   zday = REAL( kday, wp ) - 0.5
+      ELSEIF( ky == 3 )  THEN   ;   zday = REAL( kday, wp ) - 1.
+      ELSE                      ;   zday = REAL( kday, wp )
+      ENDIF
+      
+      zp = rpi * ( 2.0 * zday - 367.0 ) / REAL(nyear_len(1), wp)
+      
+      pdecl  = a0                                                                      &
+         &   + a1 * COS( zp ) + a2 * COS( 2. * zp ) + a3 * COS( 3. * zp ) + a4 * COS( 4. * zp )   &
+         &   + b1 * SIN( zp ) + b2 * SIN( 2. * zp ) + b3 * SIN( 3. * zp ) + b4 * SIN( 4. * zp )
+      !
+   END SUBROUTINE flx_blk_declin
+
+   !!======================================================================
+END MODULE sbcblk_clio
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 1844)
@@ -0,0 +1,870 @@
+MODULE sbcblk_core
+   !!======================================================================
+   !!                       ***  MODULE  sbcblk_core  ***
+   !! Ocean forcing:  momentum, heat and freshwater flux formulation
+   !!=====================================================================
+   !! History :  1.0  !  2004-08  (U. Schweckendiek)  Original code
+   !!            2.0  !  2005-04  (L. Brodeau, A.M. Treguier) additions: 
+   !!                           -  new bulk routine for efficiency
+   !!                           -  WINDS ARE NOW ASSUMED TO BE AT T POINTS in input files !!!!
+   !!                           -  file names and file characteristics in namelist 
+   !!                           -  Implement reading of 6-hourly fields   
+   !!            3.0  !  2006-06  (G. Madec) sbc rewritting   
+   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_blk_core  : bulk formulation as ocean surface boundary condition
+   !!                   (forced mode, CORE bulk formulea)
+   !!   blk_oce_core  : ocean: computes momentum, heat and freshwater fluxes
+   !!   blk_ice_core  : ice  : computes momentum, heat and freshwater fluxes
+   !!   turb_core     : computes the CORE turbulent transfer coefficients 
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE fldread         ! read input fields
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE iom             ! I/O manager library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+#if defined key_lim3
+   USE sbc_ice         ! Surface boundary condition: ice fields
+#endif
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_blk_core       ! routine called in sbcmod module
+   PUBLIC   blk_ice_core       ! routine called in sbc_ice_lim module
+      
+   INTEGER , PARAMETER ::   jpfld   = 9           ! maximum number of files to read 
+   INTEGER , PARAMETER ::   jp_wndi = 1           ! index of 10m wind velocity (i-component) (m/s)    at T-point
+   INTEGER , PARAMETER ::   jp_wndj = 2           ! index of 10m wind velocity (j-component) (m/s)    at T-point
+   INTEGER , PARAMETER ::   jp_humi = 3           ! index of specific humidity               ( - )
+   INTEGER , PARAMETER ::   jp_qsr  = 4           ! index of solar heat                      (W/m2)
+   INTEGER , PARAMETER ::   jp_qlw  = 5           ! index of Long wave                       (W/m2)
+   INTEGER , PARAMETER ::   jp_tair = 6           ! index of 10m air temperature             (Kelvin)
+   INTEGER , PARAMETER ::   jp_prec = 7           ! index of total precipitation (rain+snow) (Kg/m2/s)
+   INTEGER , PARAMETER ::   jp_snow = 8           ! index of snow (solid prcipitation)       (kg/m2/s)
+   INTEGER , PARAMETER ::   jp_tdif = 9           ! index of tau diff associated to HF tau   (N/m2)   at T-point
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input fields (file informations, fields read)
+         
+   !                                             !!! CORE bulk parameters
+   REAL(wp), PARAMETER ::   rhoa =    1.22        ! air density
+   REAL(wp), PARAMETER ::   cpa  = 1000.5         ! specific heat of air
+   REAL(wp), PARAMETER ::   Lv   =    2.5e6       ! latent heat of vaporization
+   REAL(wp), PARAMETER ::   Ls   =    2.839e6     ! latent heat of sublimation
+   REAL(wp), PARAMETER ::   Stef =    5.67e-8     ! Stefan Boltzmann constant
+   REAL(wp), PARAMETER ::   Cice =    1.63e-3     ! transfer coefficient over ice
+
+   !                                !!* Namelist namsbc_core : CORE bulk parameters
+   LOGICAL  ::   ln_2m     = .FALSE.     ! logical flag for height of air temp. and hum
+   LOGICAL  ::   ln_taudif = .FALSE.     ! logical flag to use the "mean of stress module - module of mean stress" data
+   REAL(wp) ::   rn_pfac   = 1.          ! multiplication factor for precipitation
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_blk_core( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_blk_core  ***
+      !!                   
+      !! ** Purpose :   provide at each time step the surface ocean fluxes
+      !!      (momentum, heat, freshwater and runoff) 
+      !!
+      !! ** Method  : (1) READ each fluxes in NetCDF files:
+      !!      the 10m wind velocity (i-component) (m/s)    at T-point
+      !!      the 10m wind velocity (j-component) (m/s)    at T-point
+      !!      the specific humidity               ( - )
+      !!      the solar heat                      (W/m2)
+      !!      the Long wave                       (W/m2)
+      !!      the 10m air temperature             (Kelvin)
+      !!      the total precipitation (rain+snow) (Kg/m2/s)
+      !!      the snow (solid prcipitation)       (kg/m2/s)
+      !!   OPTIONAL parameter (see ln_taudif namelist flag):
+      !!      the tau diff associated to HF tau   (N/m2)   at T-point 
+      !!              (2) CALL blk_oce_core
+      !!
+      !!      C A U T I O N : never mask the surface stress fields
+      !!                      the stress is assumed to be in the mesh referential
+      !!                      i.e. the (i,j) referential
+      !!
+      !! ** Action  :   defined at each time-step at the air-sea interface
+      !!              - utau, vtau  i- and j-component of the wind stress
+      !!              - taum        wind stress module at T-point
+      !!              - wndm        10m wind module at T-point
+      !!              - qns, qsr    non-slor and solar heat flux
+      !!              - emp, emps   evaporation minus precipitation
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
+      !!
+      INTEGER  ::   ierror   ! return error code
+      INTEGER  ::   ifpr     ! dummy loop indice
+      INTEGER  ::   jfld     ! dummy loop arguments
+      !!
+      CHARACTER(len=100) ::  cn_dir   !   Root directory for location of core files
+      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i     ! array of namelist informations on the fields to read
+      TYPE(FLD_N) ::   sn_wndi, sn_wndj, sn_humi, sn_qsr       ! informations about the fields to be read
+      TYPE(FLD_N) ::   sn_qlw , sn_tair, sn_prec, sn_snow      !   "                                 "
+      TYPE(FLD_N) ::   sn_tdif                                 !   "                                 "
+      NAMELIST/namsbc_core/ cn_dir , ln_2m  , ln_taudif, rn_pfac,           &
+         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           &
+         &                  sn_qlw , sn_tair, sn_prec  , sn_snow, sn_tdif
+      !!---------------------------------------------------------------------
+
+      !                                         ! ====================== !
+      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
+         !                                      ! ====================== !
+         ! set file information (default values)
+         cn_dir = './'       ! directory in which the model is executed
+         !
+         ! (NB: frequency positive => hours, negative => months)
+         !            !    file     ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
+         !            !    name     !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
+         sn_wndi = FLD_N( 'uwnd10m' ,    24     ,  'u_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_wndj = FLD_N( 'vwnd10m' ,    24     ,  'v_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_qsr  = FLD_N( 'qsw'     ,    24     ,  'qsw'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_qlw  = FLD_N( 'qlw'     ,    24     ,  'qlw'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_tair = FLD_N( 'tair10m' ,    24     ,  't_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_humi = FLD_N( 'humi10m' ,    24     ,  'q_10'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_prec = FLD_N( 'precip'  ,    -1     ,  'precip'  ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
+         sn_snow = FLD_N( 'snow'    ,    -1     ,  'snow'    ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
+         sn_tdif = FLD_N( 'taudif'  ,    24     ,  'taudif'  ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
+         !
+         REWIND( numnam )                    ! ... read in namlist namsbc_core
+         READ  ( numnam, namsbc_core )
+         !
+         ! store namelist information in an array
+         slf_i(jp_wndi) = sn_wndi   ;   slf_i(jp_wndj) = sn_wndj
+         slf_i(jp_qsr ) = sn_qsr    ;   slf_i(jp_qlw ) = sn_qlw
+         slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
+         slf_i(jp_prec) = sn_prec   ;   slf_i(jp_snow) = sn_snow
+         slf_i(jp_tdif) = sn_tdif
+         !
+         ! do we use HF tau information?
+         lhftau = ln_taudif
+         jfld = jpfld - COUNT( (/.NOT. lhftau/) )
+         !
+         ! set sf structure
+         ALLOCATE( sf(jfld), STAT=ierror )
+         IF( ierror > 0 ) THEN
+            CALL ctl_stop( 'sbc_blk_core: unable to allocate sf structure' )   ;   RETURN
+         ENDIF
+         DO ifpr= 1, jfld
+            ALLOCATE( sf(ifpr)%fnow(jpi,jpj) )
+            ALLOCATE( sf(ifpr)%fdta(jpi,jpj,2) )
+         END DO
+         !
+         ! fill sf with slf_i and control print
+         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_core', 'flux formulattion for ocean surface boundary condition', 'namsbc_core' )
+         !
+      ENDIF
+
+      CALL fld_read( kt, nn_fsbc, sf )                   ! input fields provided at the current time-step
+
+#if defined key_lim3
+      tatm_ice(:,:) = sf(jp_tair)%fnow(:,:)
+#endif
+
+      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
+          CALL blk_oce_core( sf, sst_m, ssu_m, ssv_m )   ! compute the surface ocean fluxes using CLIO bulk formulea
+      ENDIF
+      !                                                  ! using CORE bulk formulea
+   END SUBROUTINE sbc_blk_core
+   
+   
+   SUBROUTINE blk_oce_core( sf, pst, pu, pv )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_core  ***
+      !!
+      !! ** Purpose :   provide the momentum, heat and freshwater fluxes at
+      !!      the ocean surface at each time step
+      !!
+      !! ** Method  :   CORE bulk formulea for the ocean using atmospheric
+      !!      fields read in sbc_read
+      !! 
+      !! ** Outputs : - utau    : i-component of the stress at U-point  (N/m2)
+      !!              - vtau    : j-component of the stress at V-point  (N/m2)
+      !!              - taum    : Wind stress module at T-point         (N/m2)
+      !!              - wndm    : Wind speed module at T-point          (m/s)
+      !!              - qsr     : Solar heat flux over the ocean        (W/m2)
+      !!              - qns     : Non Solar heat flux over the ocean    (W/m2)
+      !!              - evap    : Evaporation over the ocean            (kg/m2/s)
+      !!              - emp(s)  : evaporation minus precipitation       (kg/m2/s)
+      !!
+      !!  ** Nota  :   sf has to be a dummy argument for AGRIF on NEC
+      !!---------------------------------------------------------------------
+      TYPE(fld), INTENT(in), DIMENSION(:)       ::   sf    ! input data
+      REAL(wp),  INTENT(in), DIMENSION(jpi,jpj) ::   pst   ! surface temperature                      [Celcius]
+      REAL(wp),  INTENT(in), DIMENSION(jpi,jpj) ::   pu    ! surface current at U-point (i-component) [m/s]
+      REAL(wp),  INTENT(in), DIMENSION(jpi,jpj) ::   pv    ! surface current at V-point (j-component) [m/s]
+
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      REAL(wp) ::   zcoef_qsatw
+      REAL(wp) ::   zztmp                                 ! temporary variable
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwnd_i, zwnd_j    ! wind speed components at T-point
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqsatw            ! specific humidity at pst
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqlw, zqsb        ! long wave and sensible heat fluxes
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqla, zevap       ! latent heat fluxes and evaporation
+      REAL(wp), DIMENSION(jpi,jpj) ::   Cd                ! transfer coefficient for momentum      (tau)
+      REAL(wp), DIMENSION(jpi,jpj) ::   Ch                ! transfer coefficient for sensible heat (Q_sens)
+      REAL(wp), DIMENSION(jpi,jpj) ::   Ce                ! tansfert coefficient for evaporation   (Q_lat)
+      REAL(wp), DIMENSION(jpi,jpj) ::   zst               ! surface temperature in Kelvin
+      REAL(wp), DIMENSION(jpi,jpj) ::   zt_zu             ! air temperature at wind speed height
+      REAL(wp), DIMENSION(jpi,jpj) ::   zq_zu             ! air spec. hum.  at wind speed height
+      !!---------------------------------------------------------------------
+
+      ! local scalars ( place there for vector optimisation purposes)
+      zcoef_qsatw = 0.98 * 640380. / rhoa
+      
+      zst(:,:) = pst(:,:) + rt0      ! converte Celcius to Kelvin (and set minimum value far above 0 K)
+
+      ! ----------------------------------------------------------------------------- !
+      !      0   Wind components and module at T-point relative to the moving ocean   !
+      ! ----------------------------------------------------------------------------- !
+
+      ! ... components ( U10m - U_oce ) at T-point (unmasked)
+      zwnd_i(:,:) = 0.e0  
+      zwnd_j(:,:) = 0.e0
+#if defined key_vectopt_loop
+!CDIR COLLAPSE
+#endif
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vect. opt.
+            zwnd_i(ji,jj) = (  sf(jp_wndi)%fnow(ji,jj) - 0.5 * ( pu(ji-1,jj  ) + pu(ji,jj) )  )
+            zwnd_j(ji,jj) = (  sf(jp_wndj)%fnow(ji,jj) - 0.5 * ( pv(ji  ,jj-1) + pv(ji,jj) )  )
+         END DO
+      END DO
+      CALL lbc_lnk( zwnd_i(:,:) , 'T', -1. )
+      CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. )
+      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   &
+         &             + zwnd_j(:,:) * zwnd_j(:,:)  ) * tmask(:,:,1)
+
+      ! ----------------------------------------------------------------------------- !
+      !      I   Radiative FLUXES                                                     !
+      ! ----------------------------------------------------------------------------- !
+    
+      ! ocean albedo assumed to be 0.066
+!CDIR COLLAPSE
+      qsr (:,:) = ( 1. - 0.066 ) * sf(jp_qsr)%fnow(:,:) * tmask(:,:,1)                                 ! Short Wave
+!CDIR COLLAPSE
+      zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave
+                      
+      ! ----------------------------------------------------------------------------- !
+      !     II    Turbulent FLUXES                                                    !
+      ! ----------------------------------------------------------------------------- !
+
+      ! ... specific humidity at SST and IST
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+      zqsatw(:,:) = zcoef_qsatw * EXP( -5107.4 / zst(:,:) ) 
+
+      ! ... NCAR Bulk formulae, computation of Cd, Ch, Ce at T-point :
+      IF( ln_2m ) THEN
+         !! If air temp. and spec. hum. are given at different height (2m) than wind (10m) :
+         CALL TURB_CORE_2Z(2.,10., zst   , sf(jp_tair)%fnow,         &
+            &                      zqsatw, sf(jp_humi)%fnow, wndm,   &
+            &                      Cd    , Ch              , Ce  ,   &
+            &                      zt_zu , zq_zu                   )
+      ELSE
+         !! If air temp. and spec. hum. are given at same height than wind (10m) :
+!gm bug?  at the compiling phase, add a copy in temporary arrays...  ==> check perf
+!         CALL TURB_CORE_1Z( 10., zst   (:,:), sf(jp_tair)%fnow(:,:),              &
+!            &                    zqsatw(:,:), sf(jp_humi)%fnow(:,:), wndm(:,:),   &
+!            &                    Cd    (:,:),             Ch  (:,:), Ce  (:,:)  )
+!gm bug
+         CALL TURB_CORE_1Z( 10., zst   , sf(jp_tair)%fnow,         &
+            &                    zqsatw, sf(jp_humi)%fnow, wndm,   &
+            &                    Cd    , Ch              , Ce    )
+      ENDIF
+
+      ! ... tau module, i and j component
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zztmp = rhoa * wndm(ji,jj) * Cd(ji,jj)
+            taum  (ji,jj) = zztmp * wndm  (ji,jj)
+            zwnd_i(ji,jj) = zztmp * zwnd_i(ji,jj)
+            zwnd_j(ji,jj) = zztmp * zwnd_j(ji,jj)
+         END DO
+      END DO
+
+      ! ... add the HF tau contribution to the wind stress module?
+      IF( lhftau ) THEN 
+!CDIR COLLAPSE
+         taum(:,:) = taum(:,:) + sf(jp_tdif)%fnow(:,:)
+      ENDIF
+      CALL iom_put( "taum_oce", taum )   ! output wind stress module
+
+      ! ... utau, vtau at U- and V_points, resp.
+      !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
+      DO jj = 1, jpjm1
+         DO ji = 1, fs_jpim1
+            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) )
+            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) )
+         END DO
+      END DO
+      CALL lbc_lnk( utau(:,:), 'U', -1. )
+      CALL lbc_lnk( vtau(:,:), 'V', -1. )
+
+      !  Turbulent fluxes over ocean
+      ! -----------------------------
+      IF( ln_2m ) THEN
+         ! Values of temp. and hum. adjusted to 10m must be used instead of 2m values
+         zevap(:,:) = MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - zq_zu(:,:) ) * wndm(:,:) )   ! Evaporation
+         zqsb (:,:) =            rhoa*cpa*Ch(:,:)*( zst   (:,:) - zt_zu(:,:) ) * wndm(:,:)     ! Sensible Heat
+      ELSE
+!CDIR COLLAPSE
+         zevap(:,:) = MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - sf(jp_humi)%fnow(:,:) ) * wndm(:,:) )   ! Evaporation
+!CDIR COLLAPSE
+         zqsb (:,:) =            rhoa*cpa*Ch(:,:)*( zst   (:,:) - sf(jp_tair)%fnow(:,:) ) * wndm(:,:)     ! Sensible Heat
+      ENDIF
+!CDIR COLLAPSE
+      zqla (:,:) = Lv * zevap(:,:)                                                              ! Latent Heat
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl( tab2d_1=zqla  , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=Ce , clinfo2=' Ce  : ' )
+         CALL prt_ctl( tab2d_1=zqsb  , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=Ch , clinfo2=' Ch  : ' )
+         CALL prt_ctl( tab2d_1=zqlw  , clinfo1=' blk_oce_core: zqlw   : ', tab2d_2=qsr, clinfo2=' qsr : ' )
+         CALL prt_ctl( tab2d_1=zqsatw, clinfo1=' blk_oce_core: zqsatw : ', tab2d_2=zst, clinfo2=' zst : ' )
+         CALL prt_ctl( tab2d_1=utau  , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
+            &          tab2d_2=vtau  , clinfo2=              ' vtau : '  , mask2=vmask )
+         CALL prt_ctl( tab2d_1=wndm  , clinfo1=' blk_oce_core: wndm   : ')
+         CALL prt_ctl( tab2d_1=zst   , clinfo1=' blk_oce_core: zst    : ')
+      ENDIF
+       
+      ! ----------------------------------------------------------------------------- !
+      !     III    Total FLUXES                                                       !
+      ! ----------------------------------------------------------------------------- !
+     
+!CDIR COLLAPSE
+      qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)      ! Downward Non Solar flux
+!CDIR COLLAPSE
+      emp (:,:) = zevap(:,:) - sf(jp_prec)%fnow(:,:) * rn_pfac * tmask(:,:,1)
+!CDIR COLLAPSE
+      emps(:,:) = emp(:,:)
+      !
+      CALL iom_put( "qlw_oce",   zqlw )                 ! output downward longwave heat over the ocean
+      CALL iom_put( "qsb_oce", - zqsb )                 ! output downward sensible heat over the ocean
+      CALL iom_put( "qla_oce", - zqla )                 ! output downward latent   heat over the ocean
+      CALL iom_put( "qns_oce",   qns  )                 ! output downward non solar heat over the ocean
+      !
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
+         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
+         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_core: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
+         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
+            &         tab2d_2=vtau , clinfo2=              ' vtau  : ' , mask2=vmask )
+      ENDIF
+      !
+   END SUBROUTINE blk_oce_core
+   
+   
+   SUBROUTINE blk_ice_core(  pst   , pui   , pvi   , palb ,   &
+      &                      p_taui, p_tauj, p_qns , p_qsr,   &
+      &                      p_qla , p_dqns, p_dqla,          &
+      &                      p_tpr , p_spr ,                  &
+      &                      p_fr1 , p_fr2 , cd_grid, pdim  ) 
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_ice_core  ***
+      !!
+      !! ** Purpose :   provide the surface boundary condition over sea-ice
+      !!
+      !! ** Method  :   compute momentum, heat and freshwater exchanged
+      !!                between atmosphere and sea-ice using CORE bulk
+      !!                formulea, ice variables and read atmmospheric fields.
+      !!                NB: ice drag coefficient is assumed to be a constant
+      !! 
+      !! caution : the net upward water flux has with mm/day unit
+      !!---------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)      ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin]
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)    ::   pui      ! ice surface velocity (i- and i- components      [m/s]
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)    ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid)
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)      ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_taui   ! i- & j-components of surface ice stress        [N/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid)
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)      ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)      ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)      ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)      ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:)      ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)    ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%]
+      CHARACTER(len=1), INTENT(in   )                ::   cd_grid  ! ice grid ( C or B-grid)
+      INTEGER, INTENT(in   )                         ::   pdim     ! number of ice categories
+      !!
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
+      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
+      REAL(wp) ::   zst2, zst3
+      REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2, zcoef_dqlw, zcoef_dqla, zcoef_dqsb
+      REAL(wp) ::   zcoef_frca                                   ! fractional cloud amount
+      REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f                  ! relative wind module and components at F-point
+      REAL(wp) ::             zwndi_t , zwndj_t                  ! relative wind components at T-point
+      REAL(wp), DIMENSION(jpi,jpj) ::   z_wnds_t                 ! wind speed ( = | U10m - U_ice | ) at T-point
+      REAL(wp), DIMENSION(jpi,jpj,pdim) ::   z_qlw               ! long wave heat flux over ice
+      REAL(wp), DIMENSION(jpi,jpj,pdim) ::   z_qsb               ! sensible  heat flux over ice
+      REAL(wp), DIMENSION(jpi,jpj,pdim) ::   z_dqlw              ! long wave heat sensitivity over ice
+      REAL(wp), DIMENSION(jpi,jpj,pdim) ::   z_dqsb              ! sensible  heat sensitivity over ice
+      !!---------------------------------------------------------------------
+
+      ijpl  = pdim                            ! number of ice categories
+
+      ! local scalars ( place there for vector optimisation purposes)
+      zcoef_wnorm = rhoa * Cice
+      zcoef_wnorm2 = rhoa * Cice * 0.5
+      zcoef_dqlw = 4.0 * 0.95 * Stef
+      zcoef_dqla = -Ls * Cice * 11637800. * (-5897.8)
+      zcoef_dqsb = rhoa * cpa * Cice
+      zcoef_frca = 1.0  - 0.3
+
+!!gm brutal....
+      z_wnds_t(:,:) = 0.e0
+      p_taui  (:,:) = 0.e0
+      p_tauj  (:,:) = 0.e0
+!!gm end
+
+      ! ----------------------------------------------------------------------------- !
+      !    Wind components and module relative to the moving ocean ( U10m - U_ice )   !
+      ! ----------------------------------------------------------------------------- !
+      SELECT CASE( cd_grid )
+      CASE( 'B' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation)
+         !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked)
+#if defined key_vectopt_loop
+!CDIR COLLAPSE
+#endif
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! B grid : no vector opt
+               ! ... scalar wind at I-point (fld being at T-point)
+               zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ) + sf(jp_wndi)%fnow(ji  ,jj  )   &
+                  &              + sf(jp_wndi)%fnow(ji-1,jj-1) + sf(jp_wndi)%fnow(ji  ,jj-1)  ) - pui(ji,jj)
+               zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ) + sf(jp_wndj)%fnow(ji  ,jj  )   &
+                  &              + sf(jp_wndj)%fnow(ji-1,jj-1) + sf(jp_wndj)%fnow(ji  ,jj-1)  ) - pvi(ji,jj)
+               zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f )
+               ! ... ice stress at I-point
+               p_taui(ji,jj) = zwnorm_f * zwndi_f
+               p_tauj(ji,jj) = zwnorm_f * zwndj_f
+               ! ... scalar wind at T-point (fld being at T-point)
+               zwndi_t = sf(jp_wndi)%fnow(ji,jj) - 0.25 * (  pui(ji,jj+1) + pui(ji+1,jj+1)   &
+                  &                                        + pui(ji,jj  ) + pui(ji+1,jj  )  )
+               zwndj_t = sf(jp_wndj)%fnow(ji,jj) - 0.25 * (  pvi(ji,jj+1) + pvi(ji+1,jj+1)   &
+                  &                                        + pvi(ji,jj  ) + pvi(ji+1,jj  )  )
+               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
+            END DO
+         END DO
+         CALL lbc_lnk( p_taui  , 'I', -1. )
+         CALL lbc_lnk( p_tauj  , 'I', -1. )
+         CALL lbc_lnk( z_wnds_t, 'T',  1. )
+         !
+      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean)
+#if defined key_vectopt_loop
+!CDIR COLLAPSE
+#endif
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vect. opt.
+               zwndi_t = (  sf(jp_wndi)%fnow(ji,jj) - 0.5 * ( pui(ji-1,jj  ) + pui(ji,jj) )  )
+               zwndj_t = (  sf(jp_wndj)%fnow(ji,jj) - 0.5 * ( pvi(ji  ,jj-1) + pvi(ji,jj) )  )
+               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
+            END DO
+         END DO
+#if defined key_vectopt_loop
+!CDIR COLLAPSE
+#endif
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vect. opt.
+               p_taui(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji+1,jj) + z_wnds_t(ji,jj) )                          &
+                  &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj) + sf(jp_wndi)%fnow(ji,jj) ) - pui(ji,jj) )
+               p_tauj(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji,jj+1) + z_wnds_t(ji,jj) )                          &
+                  &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1) + sf(jp_wndj)%fnow(ji,jj) ) - pvi(ji,jj) )
+            END DO
+         END DO
+         CALL lbc_lnk( p_taui  , 'U', -1. )
+         CALL lbc_lnk( p_tauj  , 'V', -1. )
+         CALL lbc_lnk( z_wnds_t, 'T',  1. )
+         !
+      END SELECT
+
+      !                                     ! ========================== !
+      DO jl = 1, ijpl                       !  Loop over ice categories  !
+         !                                  ! ========================== !
+!CDIR NOVERRCHK
+!CDIR COLLAPSE
+         DO jj = 1 , jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               ! ----------------------------!
+               !      I   Radiative FLUXES   !
+               ! ----------------------------!
+               zst2 = pst(ji,jj,jl) * pst(ji,jj,jl)
+               zst3 = pst(ji,jj,jl) * zst2
+               ! Short Wave (sw)
+               p_qsr(ji,jj,jl) = ( 1. - palb(ji,jj,jl) ) * sf(jp_qsr)%fnow(ji,jj) * tmask(ji,jj,1)
+               ! Long  Wave (lw)
+               z_qlw(ji,jj,jl) = 0.95 * (  sf(jp_qlw)%fnow(ji,jj)       &                         
+                  &                   - Stef * pst(ji,jj,jl) * zst3  ) * tmask(ji,jj,1)
+               ! lw sensitivity
+               z_dqlw(ji,jj,jl) = zcoef_dqlw * zst3                                               
+
+               ! ----------------------------!
+               !     II    Turbulent FLUXES  !
+               ! ----------------------------!
+
+               ! ... turbulent heat fluxes
+               ! Sensible Heat
+               z_qsb(ji,jj,jl) = rhoa * cpa * Cice * z_wnds_t(ji,jj) * ( pst(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj) )
+               ! Latent Heat
+               p_qla(ji,jj,jl) = MAX( 0.e0, rhoa * Ls  * Cice * z_wnds_t(ji,jj)   &                           
+                  &                    * (  11637800. * EXP( -5897.8 / pst(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj)  ) )
+               ! Latent heat sensitivity for ice (Dqla/Dt)
+               p_dqla(ji,jj,jl) = zcoef_dqla * z_wnds_t(ji,jj) / ( zst2 ) * EXP( -5897.8 / pst(ji,jj,jl) )
+               ! Sensible heat sensitivity (Dqsb_ice/Dtn_ice)
+               z_dqsb(ji,jj,jl) = zcoef_dqsb * z_wnds_t(ji,jj)
+
+               ! ----------------------------!
+               !     III    Total FLUXES     !
+               ! ----------------------------!
+               ! Downward Non Solar flux
+               p_qns (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - p_qla (ji,jj,jl)      
+               ! Total non solar heat flux sensitivity for ice
+               p_dqns(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + p_dqla(ji,jj,jl) )    
+            END DO
+            !
+         END DO
+         !
+      END DO
+      !
+      !--------------------------------------------------------------------
+      ! FRACTIONs of net shortwave radiation which is not absorbed in the
+      ! thin surface layer and penetrates inside the ice cover
+      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 )
+    
+!CDIR COLLAPSE
+      p_fr1(:,:) = ( 0.18 * ( 1.0 - zcoef_frca ) + 0.35 * zcoef_frca )
+!CDIR COLLAPSE
+      p_fr2(:,:) = ( 0.82 * ( 1.0 - zcoef_frca ) + 0.65 * zcoef_frca )
+       
+!CDIR COLLAPSE
+      p_tpr(:,:) = sf(jp_prec)%fnow(:,:) * rn_pfac      ! total precipitation [kg/m2/s]
+!CDIR COLLAPSE
+      p_spr(:,:) = sf(jp_snow)%fnow(:,:) * rn_pfac      ! solid precipitation [kg/m2/s]
+      CALL iom_put( 'snowpre', p_spr )                  ! Snow precipitation 
+      !
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=p_qla   , clinfo1=' blk_ice_core: p_qla  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb  : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw  : ', tab3d_2=p_dqla  , clinfo2=' p_dqla : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=p_dqns  , clinfo1=' blk_ice_core: p_dqns : ', tab3d_2=p_qsr   , clinfo2=' p_qsr  : ', kdim=ijpl)
+         CALL prt_ctl(tab3d_1=pst     , clinfo1=' blk_ice_core: pst    : ', tab3d_2=p_qns   , clinfo2=' p_qns  : ', kdim=ijpl)
+         CALL prt_ctl(tab2d_1=p_tpr   , clinfo1=' blk_ice_core: p_tpr  : ', tab2d_2=p_spr   , clinfo2=' p_spr  : ')
+         CALL prt_ctl(tab2d_1=p_taui  , clinfo1=' blk_ice_core: p_taui : ', tab2d_2=p_tauj  , clinfo2=' p_tauj : ')
+         CALL prt_ctl(tab2d_1=z_wnds_t, clinfo1=' blk_ice_core: z_wnds_t : ')
+      ENDIF
+
+   END SUBROUTINE blk_ice_core
+  
+
+   SUBROUTINE TURB_CORE_1Z(zu, sst, T_a, q_sat, q_a,   &
+      &                        dU, Cd, Ch, Ce   )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE  turb_core  ***
+      !!
+      !! ** Purpose :   Computes turbulent transfert coefficients of surface
+      !!                fluxes according to Large & Yeager (2004)
+      !!
+      !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D
+      !!      Momentum, Latent and sensible heat exchange coefficients
+      !!      Caution: this procedure should only be used in cases when air
+      !!      temperature (T_air), air specific humidity (q_air) and wind (dU)
+      !!      are provided at the same height 'zzu'!
+      !!
+      !! References :
+      !!      Large & Yeager, 2004 : ???
+      !! History :
+      !!        !  XX-XX  (???     )  Original code
+      !!   9.0  !  05-08  (L. Brodeau) Rewriting and optimization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+
+      REAL(wp), INTENT(in) :: zu                 ! altitude of wind measurement       [m]
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj) ::  &
+         sst,       &       ! sea surface temperature         [Kelvin]
+         T_a,       &       ! potential air temperature       [Kelvin]
+         q_sat,     &       ! sea surface specific humidity   [kg/kg]
+         q_a,       &       ! specific air humidity           [kg/kg]
+         dU                 ! wind module |U(zu)-U(0)|        [m/s]
+      REAL(wp), intent(out), DIMENSION(jpi,jpj)  :: &
+         Cd,    &                ! transfert coefficient for momentum       (tau)
+         Ch,    &                ! transfert coefficient for temperature (Q_sens)
+         Ce                      ! transfert coefficient for evaporation  (Q_lat)
+
+      !! * Local declarations
+      REAL(wp), DIMENSION(jpi,jpj)  ::   &
+         dU10,        &       ! dU                                   [m/s]
+         dT,          &       ! air/sea temperature differeence      [K]
+         dq,          &       ! air/sea humidity difference          [K]
+         Cd_n10,      &       ! 10m neutral drag coefficient
+         Ce_n10,      &       ! 10m neutral latent coefficient
+         Ch_n10,      &       ! 10m neutral sensible coefficient
+         sqrt_Cd_n10, &       ! root square of Cd_n10
+         sqrt_Cd,     &       ! root square of Cd
+         T_vpot,      &       ! virtual potential temperature        [K]
+         T_star,      &       ! turbulent scale of tem. fluct.
+         q_star,      &       ! turbulent humidity of temp. fluct.
+         U_star,      &       ! turb. scale of velocity fluct.
+         L,           &       ! Monin-Obukov length                  [m]
+         zeta,        &       ! stability parameter at height zu
+         U_n10,       &       ! neutral wind velocity at 10m         [m]   
+         xlogt, xct, zpsi_h, zpsi_m
+      !!
+      INTEGER :: j_itt
+      INTEGER, PARAMETER :: nb_itt = 3
+      INTEGER, DIMENSION(jpi,jpj)  ::   &
+         stab         ! 1st guess stability test integer
+
+      REAL(wp), PARAMETER ::                        &
+         grav   = 9.8,          &  ! gravity                       
+         kappa  = 0.4              ! von Karman s constant
+
+      !! * Start
+      !! Air/sea differences
+      dU10 = max(0.5, dU)     ! we don't want to fall under 0.5 m/s
+      dT = T_a - sst          ! assuming that T_a is allready the potential temp. at zzu
+      dq = q_a - q_sat
+      !!    
+      !! Virtual potential temperature
+      T_vpot = T_a*(1. + 0.608*q_a)
+      !!
+      !! Neutral Drag Coefficient
+      stab    = 0.5 + sign(0.5,dT)    ! stable : stab = 1 ; unstable : stab = 0 
+      Cd_n10  = 1E-3 * ( 2.7/dU10 + 0.142 + dU10/13.09 )    !   L & Y eq. (6a)
+      sqrt_Cd_n10 = sqrt(Cd_n10)
+      Ce_n10  = 1E-3 * ( 34.6 * sqrt_Cd_n10 )               !   L & Y eq. (6b)
+      Ch_n10  = 1E-3*sqrt_Cd_n10*(18*stab + 32.7*(1-stab)) !   L & Y eq. (6c), (6d)
+      !!
+      !! Initializing transfert coefficients with their first guess neutral equivalents :
+      Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd)
+
+      !! * Now starting iteration loop
+      DO j_itt=1, nb_itt
+         !! Turbulent scales :
+         U_star  = sqrt_Cd*dU10                !   L & Y eq. (7a)
+         T_star  = Ch/sqrt_Cd*dT               !   L & Y eq. (7b)
+         q_star  = Ce/sqrt_Cd*dq               !   L & Y eq. (7c)
+
+         !! Estimate the Monin-Obukov length :
+         L  = (U_star**2)/( kappa*grav*(T_star/T_vpot + q_star/(q_a + 1./0.608)) )
+
+         !! Stability parameters :
+         zeta = zu/L ;  zeta   = sign( min(abs(zeta),10.0), zeta )
+         zpsi_h = psi_h(zeta)
+         zpsi_m = psi_m(zeta)
+
+         !! Shifting the wind speed to 10m and neutral stability :
+         U_n10 = dU10*1./(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)) !  L & Y eq. (9a)
+
+         !! Updating the neutral 10m transfer coefficients :
+         Cd_n10  = 1E-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)              !  L & Y eq. (6a)
+         sqrt_Cd_n10 = sqrt(Cd_n10)
+         Ce_n10  = 1E-3 * (34.6 * sqrt_Cd_n10)                           !  L & Y eq. (6b)
+         stab    = 0.5 + sign(0.5,zeta)
+         Ch_n10  = 1E-3*sqrt_Cd_n10*(18.*stab + 32.7*(1-stab))           !  L & Y eq. (6c), (6d)
+
+         !! Shifting the neutral  10m transfer coefficients to ( zu , zeta ) :
+         !!
+         xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10) - zpsi_m)
+         Cd  = Cd_n10/(xct*xct) ;  sqrt_Cd = sqrt(Cd)
+         !!
+         xlogt = log(zu/10.) - zpsi_h
+         !!
+         xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10
+         Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct
+         !!
+         xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10
+         Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct
+         !!
+      END DO
+      !!
+    END SUBROUTINE TURB_CORE_1Z
+
+
+    SUBROUTINE TURB_CORE_2Z(zt, zu, sst, T_zt, q_sat, q_zt, dU, Cd, Ch, Ce, T_zu, q_zu)
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE  turb_core  ***
+      !!
+      !! ** Purpose :   Computes turbulent transfert coefficients of surface 
+      !!                fluxes according to Large & Yeager (2004).
+      !!
+      !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D
+      !!      Momentum, Latent and sensible heat exchange coefficients
+      !!      Caution: this procedure should only be used in cases when air
+      !!      temperature (T_air) and air specific humidity (q_air) are at 2m
+      !!      whereas wind (dU) is at 10m.
+      !!
+      !! References :
+      !!      Large & Yeager, 2004 : ???
+      !! History :
+      !!   9.0  !  06-12  (L. Brodeau) Original code for 2Z
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in)   :: &
+         zt,      &     ! height for T_zt and q_zt                   [m]
+         zu             ! height for dU                              [m]
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj) ::  &
+         sst,      &     ! sea surface temperature              [Kelvin]
+         T_zt,     &     ! potential air temperature            [Kelvin]
+         q_sat,    &     ! sea surface specific humidity         [kg/kg]
+         q_zt,     &     ! specific air humidity                 [kg/kg]
+         dU              ! relative wind module |U(zu)-U(0)|       [m/s]
+      REAL(wp), INTENT(out), DIMENSION(jpi,jpj)  ::  &
+         Cd,       &     ! transfer coefficient for momentum         (tau)
+         Ch,       &     ! transfer coefficient for sensible heat (Q_sens)
+         Ce,       &     ! transfert coefficient for evaporation   (Q_lat)
+         T_zu,     &     ! air temp. shifted at zu                     [K]
+         q_zu            ! spec. hum.  shifted at zu               [kg/kg]
+
+      !! * Local declarations
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         dU10,        &     ! dU                                [m/s]
+         dT,          &     ! air/sea temperature differeence   [K]
+         dq,          &     ! air/sea humidity difference       [K]
+         Cd_n10,      &     ! 10m neutral drag coefficient
+         Ce_n10,      &     ! 10m neutral latent coefficient
+         Ch_n10,      &     ! 10m neutral sensible coefficient
+         sqrt_Cd_n10, &     ! root square of Cd_n10
+         sqrt_Cd,     &     ! root square of Cd
+         T_vpot_u,    &     ! virtual potential temperature        [K]
+         T_star,      &     ! turbulent scale of tem. fluct.
+         q_star,      &     ! turbulent humidity of temp. fluct.
+         U_star,      &     ! turb. scale of velocity fluct.
+         L,           &     ! Monin-Obukov length                  [m]
+         zeta_u,      &     ! stability parameter at height zu
+         zeta_t,      &     ! stability parameter at height zt
+         U_n10,       &     ! neutral wind velocity at 10m        [m]
+         xlogt, xct, zpsi_hu, zpsi_ht, zpsi_m
+
+      INTEGER :: j_itt
+      INTEGER, PARAMETER :: nb_itt = 3   ! number of itterations
+      INTEGER, DIMENSION(jpi,jpj) :: &
+           &     stab                ! 1st stability test integer
+      REAL(wp), PARAMETER ::                        &
+         grav   = 9.8,      &  ! gravity                       
+         kappa  = 0.4          ! von Karman's constant
+
+      !!  * Start
+
+      !! Initial air/sea differences
+      dU10 = max(0.5, dU)      !  we don't want to fall under 0.5 m/s
+      dT = T_zt - sst 
+      dq = q_zt - q_sat
+
+      !! Neutral Drag Coefficient :
+      stab = 0.5 + sign(0.5,dT)                 ! stab = 1  if dT > 0  -> STABLE
+      Cd_n10  = 1E-3*( 2.7/dU10 + 0.142 + dU10/13.09 ) 
+      sqrt_Cd_n10 = sqrt(Cd_n10)
+      Ce_n10  = 1E-3*( 34.6 * sqrt_Cd_n10 )
+      Ch_n10  = 1E-3*sqrt_Cd_n10*(18*stab + 32.7*(1 - stab))
+
+      !! Initializing transf. coeff. with their first guess neutral equivalents :
+      Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd)
+
+      !! Initializing z_u values with z_t values :
+      T_zu = T_zt ;  q_zu = q_zt
+
+      !!  * Now starting iteration loop
+      DO j_itt=1, nb_itt
+         dT = T_zu - sst ;  dq = q_zu - q_sat ! Updating air/sea differences
+         T_vpot_u = T_zu*(1. + 0.608*q_zu)    ! Updating virtual potential temperature at zu
+         U_star = sqrt_Cd*dU10                ! Updating turbulent scales :   (L & Y eq. (7))
+         T_star  = Ch/sqrt_Cd*dT              !
+         q_star  = Ce/sqrt_Cd*dq              !
+         !!
+         L = (U_star*U_star) &                ! Estimate the Monin-Obukov length at height zu
+              & / (kappa*grav/T_vpot_u*(T_star*(1.+0.608*q_zu) + 0.608*T_zu*q_star))
+         !! Stability parameters :
+         zeta_u  = zu/L  ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u )
+         zeta_t  = zt/L  ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t )
+         zpsi_hu = psi_h(zeta_u)
+         zpsi_ht = psi_h(zeta_t)
+         zpsi_m  = psi_m(zeta_u)
+         !!
+         !! Shifting the wind speed to 10m and neutral stability : (L & Y eq.(9a))
+!        U_n10 = dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - psi_m(zeta_u)))
+         U_n10 = dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m))
+         !!
+         !! Shifting temperature and humidity at zu :          (L & Y eq. (9b-9c))
+!        T_zu = T_zt - T_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t))
+         T_zu = T_zt - T_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht)
+!        q_zu = q_zt - q_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t))
+         q_zu = q_zt - q_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht)
+         !!
+         !! q_zu cannot have a negative value : forcing 0
+         stab = 0.5 + sign(0.5,q_zu) ;  q_zu = stab*q_zu
+         !!
+         !! Updating the neutral 10m transfer coefficients :
+         Cd_n10  = 1E-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)    ! L & Y eq. (6a)
+         sqrt_Cd_n10 = sqrt(Cd_n10)
+         Ce_n10  = 1E-3 * (34.6 * sqrt_Cd_n10)                 ! L & Y eq. (6b)
+         stab    = 0.5 + sign(0.5,zeta_u)
+         Ch_n10  = 1E-3*sqrt_Cd_n10*(18.*stab + 32.7*(1-stab)) ! L & Y eq. (6c-6d)
+         !!
+         !!
+         !! Shifting the neutral 10m transfer coefficients to (zu,zeta_u) :
+!        xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10.) - psi_m(zeta_u))
+         xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)
+         Cd = Cd_n10/(xct*xct) ; sqrt_Cd = sqrt(Cd)
+         !!
+!        xlogt = log(zu/10.) - psi_h(zeta_u)
+         xlogt = log(zu/10.) - zpsi_hu
+         !!
+         xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10
+         Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct
+         !!
+         xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10
+         Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct
+         !!
+         !!
+      END DO
+      !!
+    END SUBROUTINE TURB_CORE_2Z
+
+
+    FUNCTION psi_m(zta)   !! Psis, L & Y eq. (8c), (8d), (8e)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: zta
+
+      REAL(wp), PARAMETER :: pi = 3.141592653589793_wp
+      REAL(wp), DIMENSION(jpi,jpj)             :: psi_m
+      REAL(wp), DIMENSION(jpi,jpj)             :: X2, X, stabit
+      X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.0) ;  X  = sqrt(X2)
+      stabit    = 0.5 + sign(0.5,zta)
+      psi_m = -5.*zta*stabit  &                                                  ! Stable
+           & + (1. - stabit)*(2*log((1. + X)/2) + log((1. + X2)/2) - 2*atan(X) + pi/2)  ! Unstable 
+    END FUNCTION psi_m
+
+    FUNCTION psi_h(zta)    !! Psis, L & Y eq. (8c), (8d), (8e)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: zta
+
+      REAL(wp), DIMENSION(jpi,jpj)             :: psi_h
+      REAL(wp), DIMENSION(jpi,jpj)             :: X2, X, stabit
+      X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.) ;  X  = sqrt(X2)
+      stabit    = 0.5 + sign(0.5,zta)
+      psi_h = -5.*zta*stabit  &                                       ! Stable
+           & + (1. - stabit)*(2.*log( (1. + X2)/2. ))                 ! Unstable
+    END FUNCTION psi_h
+  
+   !!======================================================================
+END MODULE sbcblk_core
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 1844)
@@ -0,0 +1,1407 @@
+MODULE sbccpl
+   !!======================================================================
+   !!                       ***  MODULE  sbccpl  ***
+   !! Surface Boundary Condition :  momentum, heat and freshwater fluxes in coupled mode
+   !!======================================================================
+   !! History :  2.0  !  06-2007  (R. Redler, N. Keenlyside, W. Park) Original code split into flxmod & taumod
+   !!            3.0  !  02-2008  (G. Madec, C Talandier)  surface module
+   !!            3.1  !  02-2009  (G. Madec, S. Masson, E. Maisonave, A. Caubel) generic coupled interface
+   !!----------------------------------------------------------------------
+#if defined key_oasis3 || defined key_oasis4
+   !!----------------------------------------------------------------------
+   !!   'key_oasis3' or 'key_oasis4'   Coupled Ocean/Atmosphere formulation
+   !!----------------------------------------------------------------------
+   !!   namsbc_cpl      : coupled formulation namlist
+   !!   sbc_cpl_init    : initialisation of the coupled exchanges
+   !!   sbc_cpl_rcv     : receive fields from the atmosphere over the ocean (ocean only)
+   !!                     receive stress from the atmosphere over the ocean (ocean-ice case)
+   !!   sbc_cpl_ice_tau : receive stress from the atmosphere over ice
+   !!   sbc_cpl_ice_flx : receive fluxes from the atmosphere over ice
+   !!   sbc_cpl_snd     : send     fields to the atmosphere
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+#if defined key_lim3
+   USE par_ice         ! ice parameters
+#endif
+#if defined key_lim2
+   USE par_ice_2       ! ice parameters
+   USE ice_2           ! ice variables
+#endif
+#if defined key_oasis3
+   USE cpl_oasis3      ! OASIS3 coupling
+#endif
+#if defined key_oasis4
+   USE cpl_oasis4      ! OASIS4 coupling
+#endif
+   USE geo2ocean       ! 
+   USE restart         !
+   USE oce   , ONLY : tn, un, vn
+   USE phycst, ONLY : rt0, rcp
+   USE albedo          !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! NetCDF library
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE phycst, ONLY : xlsn, rhosn, xlic, rhoic
+#if defined key_cpl_carbon_cycle
+   USE p4zflx, ONLY : oce_co2
+#endif
+   USE diaar5, ONLY :   lk_diaar5
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_cpl_rcv       ! routine called by sbc_ice_lim(_2).F90
+   PUBLIC   sbc_cpl_snd       ! routine called by step.F90
+   PUBLIC   sbc_cpl_ice_tau   ! routine called by sbc_ice_lim(_2).F90
+   PUBLIC   sbc_cpl_ice_flx   ! routine called by sbc_ice_lim(_2).F90
+   
+   INTEGER, PARAMETER ::   jpr_otx1   =  1            ! 3 atmosphere-ocean stress components on grid 1
+   INTEGER, PARAMETER ::   jpr_oty1   =  2            ! 
+   INTEGER, PARAMETER ::   jpr_otz1   =  3            ! 
+   INTEGER, PARAMETER ::   jpr_otx2   =  4            ! 3 atmosphere-ocean stress components on grid 2
+   INTEGER, PARAMETER ::   jpr_oty2   =  5            ! 
+   INTEGER, PARAMETER ::   jpr_otz2   =  6            ! 
+   INTEGER, PARAMETER ::   jpr_itx1   =  7            ! 3 atmosphere-ice   stress components on grid 1
+   INTEGER, PARAMETER ::   jpr_ity1   =  8            ! 
+   INTEGER, PARAMETER ::   jpr_itz1   =  9            ! 
+   INTEGER, PARAMETER ::   jpr_itx2   = 10            ! 3 atmosphere-ice   stress components on grid 2
+   INTEGER, PARAMETER ::   jpr_ity2   = 11            ! 
+   INTEGER, PARAMETER ::   jpr_itz2   = 12            ! 
+   INTEGER, PARAMETER ::   jpr_qsroce = 13            ! Qsr above the ocean
+   INTEGER, PARAMETER ::   jpr_qsrice = 14            ! Qsr above the ice
+   INTEGER, PARAMETER ::   jpr_qsrmix = 15 
+   INTEGER, PARAMETER ::   jpr_qnsoce = 16            ! Qns above the ocean
+   INTEGER, PARAMETER ::   jpr_qnsice = 17            ! Qns above the ice
+   INTEGER, PARAMETER ::   jpr_qnsmix = 18
+   INTEGER, PARAMETER ::   jpr_rain   = 19            ! total liquid precipitation (rain)
+   INTEGER, PARAMETER ::   jpr_snow   = 20            ! solid precipitation over the ocean (snow)
+   INTEGER, PARAMETER ::   jpr_tevp   = 21            ! total evaporation
+   INTEGER, PARAMETER ::   jpr_ievp   = 22            ! solid evaporation (sublimation)
+   INTEGER, PARAMETER ::   jpr_sbpr   = 23            ! sublimation - liquid precipitation - solid precipitation
+   INTEGER, PARAMETER ::   jpr_semp   = 24            ! solid freshwater budget (sublimation - snow)
+   INTEGER, PARAMETER ::   jpr_oemp   = 25            ! ocean freshwater budget (evap - precip)
+   INTEGER, PARAMETER ::   jpr_w10m   = 26            ! 10m wind
+   INTEGER, PARAMETER ::   jpr_dqnsdt = 27            ! d(Q non solar)/d(temperature)
+   INTEGER, PARAMETER ::   jpr_rnf    = 28            ! runoffs
+   INTEGER, PARAMETER ::   jpr_cal    = 29            ! calving
+   INTEGER, PARAMETER ::   jpr_taum   = 30            ! wind stress module
+#if ! defined key_cpl_carbon_cycle
+   INTEGER, PARAMETER ::   jprcv      = 30            ! total number of fields received
+#else
+   INTEGER, PARAMETER ::   jpr_co2    = 31
+   INTEGER, PARAMETER ::   jprcv      = 31            ! total number of fields received
+#endif   
+   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction 
+   INTEGER, PARAMETER ::   jps_toce   =  2            ! ocean temperature
+   INTEGER, PARAMETER ::   jps_tice   =  3            ! ice   temperature
+   INTEGER, PARAMETER ::   jps_tmix   =  4            ! mixed temperature (ocean+ice)
+   INTEGER, PARAMETER ::   jps_albice =  5            ! ice   albedo
+   INTEGER, PARAMETER ::   jps_albmix =  6            ! mixed albedo
+   INTEGER, PARAMETER ::   jps_hice   =  7            ! ice  thickness
+   INTEGER, PARAMETER ::   jps_hsnw   =  8            ! snow thickness
+   INTEGER, PARAMETER ::   jps_ocx1   =  9            ! ocean current on grid 1
+   INTEGER, PARAMETER ::   jps_ocy1   = 10            !
+   INTEGER, PARAMETER ::   jps_ocz1   = 11            !
+   INTEGER, PARAMETER ::   jps_ivx1   = 12            ! ice   current on grid 1
+   INTEGER, PARAMETER ::   jps_ivy1   = 13            !
+   INTEGER, PARAMETER ::   jps_ivz1   = 14            !
+#if ! defined key_cpl_carbon_cycle
+   INTEGER, PARAMETER ::   jpsnd      = 14            ! total number of fields sended
+#else
+   INTEGER, PARAMETER ::   jps_co2    = 15
+   INTEGER, PARAMETER ::   jpsnd      = 15            ! total number of fields sended
+#endif   
+   !                                                         !!** namelist namsbc_cpl **
+   ! Send to the atmosphere                                   !
+   CHARACTER(len=100) ::   cn_snd_temperature = 'oce only'    ! 'oce only' 'weighted oce and ice' or 'mixed oce-ice'
+   CHARACTER(len=100) ::   cn_snd_albedo      = 'none'        ! 'none' 'weighted ice' or 'mixed oce-ice'
+   CHARACTER(len=100) ::   cn_snd_thickness   = 'none'        ! 'none' or 'weighted ice and snow'
+   CHARACTER(len=100) ::   cn_snd_crt_nature  = 'none'        ! 'none' 'oce only' 'weighted oce and ice' or 'mixed oce-ice'   
+   CHARACTER(len=100) ::   cn_snd_crt_refere  = 'spherical'   ! 'spherical' or 'cartesian'
+   CHARACTER(len=100) ::   cn_snd_crt_orient  = 'local grid'  ! 'eastward-northward' or 'local grid'
+   CHARACTER(len=100) ::   cn_snd_crt_grid    = 'T'           ! always at 'T' point
+#if defined key_cpl_carbon_cycle 
+   CHARACTER(len=100) ::   cn_snd_co2         = 'none'        ! 'none' or 'coupled'
+#endif
+   ! Received from the atmosphere                             !
+   CHARACTER(len=100) ::   cn_rcv_tau_nature  = 'oce only'    ! 'oce only' 'oce and ice' or 'mixed oce-ice'
+   CHARACTER(len=100) ::   cn_rcv_tau_refere  = 'spherical'   ! 'spherical' or 'cartesian'
+   CHARACTER(len=100) ::   cn_rcv_tau_orient  = 'local grid'  ! 'eastward-northward' or 'local grid'
+   CHARACTER(len=100) ::   cn_rcv_tau_grid    = 'T'           ! 'T', 'U,V', 'U,V,I', 'T,I', or 'T,U,V'
+   CHARACTER(len=100) ::   cn_rcv_w10m        = 'none'        ! 'none' or 'coupled'
+   CHARACTER(len=100) ::   cn_rcv_dqnsdt      = 'none'        ! 'none' or 'coupled'
+   CHARACTER(len=100) ::   cn_rcv_qsr         = 'oce only'    ! 'oce only' 'conservative' 'oce and ice' or 'mixed oce-ice'
+   CHARACTER(len=100) ::   cn_rcv_qns         = 'oce only'    ! 'oce only' 'conservative' 'oce and ice' or 'mixed oce-ice'
+   CHARACTER(len=100) ::   cn_rcv_emp         = 'oce only'    ! 'oce only' 'conservative' or 'oce and ice'
+   CHARACTER(len=100) ::   cn_rcv_rnf         = 'coupled'     ! 'coupled' 'climato' or 'mixed'
+   CHARACTER(len=100) ::   cn_rcv_cal         = 'none'        ! 'none' or 'coupled'
+   CHARACTER(len=100) ::   cn_rcv_taumod      = 'none'        ! 'none' or 'coupled'
+#if defined key_cpl_carbon_cycle 
+   CHARACTER(len=100) ::   cn_rcv_co2         = 'none'        ! 'none' or 'coupled'
+#endif
+
+!!   CHARACTER(len=100), PUBLIC ::   cn_rcv_rnf   !: ???             ==>>  !!gm   treat this case in a different maner
+   
+   CHARACTER(len=100), DIMENSION(4) ::   cn_snd_crt           ! array combining cn_snd_crt_*
+   CHARACTER(len=100), DIMENSION(4) ::   cn_rcv_tau           ! array combining cn_rcv_tau_*
+
+   REAL(wp), DIMENSION(jpi,jpj)       ::   albedo_oce_mix     ! ocean albedo sent to atmosphere (mix clear/overcast sky)
+
+   REAL(wp), DIMENSION(jpi,jpj,jprcv) ::   frcv               ! all fields recieved from the atmosphere
+   INTEGER , DIMENSION(        jprcv) ::   nrcvinfo           ! OASIS info argument
+
+   !! Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+  
+   SUBROUTINE sbc_cpl_init( k_ice )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_init  ***
+      !!
+      !! ** Purpose :   Initialisation of send and recieved information from
+      !!                the atmospheric component
+      !!
+      !! ** Method  : * Read namsbc_cpl namelist 
+      !!              * define the receive interface
+      !!              * define the send    interface
+      !!              * initialise the OASIS coupler
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   k_ice    ! ice management in the sbc (=0/1/2/3)
+      !!
+      INTEGER                      ::   jn           ! dummy loop index
+      REAL(wp), DIMENSION(jpi,jpj) ::   zacs, zaos   ! 2D workspace (clear & overcast sky albedos)
+      !!
+      NAMELIST/namsbc_cpl/  cn_snd_temperature, cn_snd_albedo    , cn_snd_thickness,                 &          
+         cn_snd_crt_nature, cn_snd_crt_refere , cn_snd_crt_orient, cn_snd_crt_grid ,                 &
+         cn_rcv_w10m      , cn_rcv_taumod     ,                                                      &
+         cn_rcv_tau_nature, cn_rcv_tau_refere , cn_rcv_tau_orient, cn_rcv_tau_grid ,                 &
+         cn_rcv_dqnsdt    , cn_rcv_qsr        , cn_rcv_qns       , cn_rcv_emp      , cn_rcv_rnf , cn_rcv_cal
+#if defined key_cpl_carbon_cycle 
+      NAMELIST/namsbc_cpl_co2/  cn_snd_co2, cn_rcv_co2
+#endif
+      !!---------------------------------------------------------------------
+
+      ! ================================ !
+      !      Namelist informations       !
+      ! ================================ !
+
+      REWIND( numnam )                    ! ... read namlist namsbc_cpl
+      READ  ( numnam, namsbc_cpl )
+
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
+         WRITE(numout,*)'~~~~~~~~~~~~'
+         WRITE(numout,*)'   received fields'
+         WRITE(numout,*)'       10m wind module                    cn_rcv_w10m        = ', cn_rcv_w10m 
+         WRITE(numout,*)'       surface stress - nature            cn_rcv_tau_nature  = ', cn_rcv_tau_nature
+         WRITE(numout,*)'                      - referential       cn_rcv_tau_refere  = ', cn_rcv_tau_refere
+         WRITE(numout,*)'                      - orientation       cn_rcv_tau_orient  = ', cn_rcv_tau_orient
+         WRITE(numout,*)'                      - mesh              cn_rcv_tau_grid    = ', cn_rcv_tau_grid
+         WRITE(numout,*)'       non-solar heat flux sensitivity    cn_rcv_dqnsdt      = ', cn_rcv_dqnsdt
+         WRITE(numout,*)'       solar heat flux                    cn_rcv_qsr         = ', cn_rcv_qsr  
+         WRITE(numout,*)'       non-solar heat flux                cn_rcv_qns         = ', cn_rcv_qns
+         WRITE(numout,*)'       freshwater budget                  cn_rcv_emp         = ', cn_rcv_emp
+         WRITE(numout,*)'       runoffs                            cn_rcv_rnf         = ', cn_rcv_rnf
+         WRITE(numout,*)'       calving                            cn_rcv_cal         = ', cn_rcv_cal 
+         WRITE(numout,*)'       stress module                      cn_rcv_taumod      = ', cn_rcv_taumod
+         WRITE(numout,*)'   sent fields'
+         WRITE(numout,*)'       surface temperature                cn_snd_temperature = ', cn_snd_temperature
+         WRITE(numout,*)'       albedo                             cn_snd_albedo      = ', cn_snd_albedo
+         WRITE(numout,*)'       ice/snow thickness                 cn_snd_thickness   = ', cn_snd_thickness  
+         WRITE(numout,*)'       surface current - nature           cn_snd_crt_nature  = ', cn_snd_crt_nature 
+         WRITE(numout,*)'                       - referential      cn_snd_crt_refere  = ', cn_snd_crt_refere 
+         WRITE(numout,*)'                       - orientation      cn_snd_crt_orient  = ', cn_snd_crt_orient
+         WRITE(numout,*)'                       - mesh             cn_snd_crt_grid    = ', cn_snd_crt_grid 
+      ENDIF
+
+#if defined key_cpl_carbon_cycle 
+      REWIND( numnam )                    ! ... read namlist namsbc_cpl_co2
+      READ  ( numnam, namsbc_cpl_co2 )
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl_co2 namelist '
+         WRITE(numout,*)'~~~~~~~~~~~~'
+         WRITE(numout,*)'   received fields'
+         WRITE(numout,*)'       atm co2                            cn_rcv_co2         = ', cn_rcv_co2
+         WRITE(numout,*)'   sent fields'
+         WRITE(numout,*)'      oce co2 flux                        cn_snd_co2         = ', cn_snd_co2
+          WRITE(numout,*)
+      ENDIF
+#endif
+      ! save current & stress in an array and suppress possible blank in the name
+      cn_snd_crt(1) = TRIM( cn_snd_crt_nature )   ;   cn_snd_crt(2) = TRIM( cn_snd_crt_refere )
+      cn_snd_crt(3) = TRIM( cn_snd_crt_orient )   ;   cn_snd_crt(4) = TRIM( cn_snd_crt_grid   )
+      cn_rcv_tau(1) = TRIM( cn_rcv_tau_nature )   ;   cn_rcv_tau(2) = TRIM( cn_rcv_tau_refere )
+      cn_rcv_tau(3) = TRIM( cn_rcv_tau_orient )   ;   cn_rcv_tau(4) = TRIM( cn_rcv_tau_grid   )
+     
+      ! ================================ !
+      !   Define the receive interface   !
+      ! ================================ !
+      nrcvinfo(:) = OASIS_idle   ! needed by nrcvinfo(jpr_otx1) if we do not receive ocean stress 
+
+      ! for each field: define the OASIS name                              (srcv(:)%clname)
+      !                 define receive or not from the namelist parameters (srcv(:)%laction)
+      !                 define the north fold type of lbc                  (srcv(:)%nsgn)
+
+      ! default definitions of srcv
+      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1
+
+      !                                                      ! ------------------------- !
+      !                                                      ! ice and ocean wind stress !   
+      !                                                      ! ------------------------- !
+      !                                                           ! Name 
+      srcv(jpr_otx1)%clname = 'O_OTaux1'      ! 1st ocean component on grid ONE (T or U)
+      srcv(jpr_oty1)%clname = 'O_OTauy1'      ! 2nd   -      -         -     - 
+      srcv(jpr_otz1)%clname = 'O_OTauz1'      ! 3rd   -      -         -     - 
+      srcv(jpr_otx2)%clname = 'O_OTaux2'      ! 1st ocean component on grid TWO (V)
+      srcv(jpr_oty2)%clname = 'O_OTauy2'      ! 2nd   -      -         -     - 
+      srcv(jpr_otz2)%clname = 'O_OTauz2'      ! 3rd   -      -         -     - 
+      !
+      srcv(jpr_itx1)%clname = 'O_ITaux1'      ! 1st  ice  component on grid ONE (T, F, I or U)
+      srcv(jpr_ity1)%clname = 'O_ITauy1'      ! 2nd   -      -         -     - 
+      srcv(jpr_itz1)%clname = 'O_ITauz1'      ! 3rd   -      -         -     - 
+      srcv(jpr_itx2)%clname = 'O_ITaux2'      ! 1st  ice  component on grid TWO (V)
+      srcv(jpr_ity2)%clname = 'O_ITauy2'      ! 2nd   -      -         -     - 
+      srcv(jpr_itz2)%clname = 'O_ITauz2'      ! 3rd   -      -         -     - 
+      ! 
+      ! Vectors: change of sign at north fold ONLY if on the local grid
+      IF( TRIM( cn_rcv_tau(3) ) == 'local grid' )   srcv(jpr_otx1:jpr_itz2)%nsgn = -1.
+      
+      !                                                           ! Set grid and action
+      SELECT CASE( TRIM( cn_rcv_tau(4) ) )      !  'T', 'U,V', 'U,V,I', 'U,V,F', 'T,I', 'T,F', or 'T,U,V'
+      CASE( 'T' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'U,V' ) 
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
+         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_otx1:jpr_itz2)%laction = .TRUE.     ! receive oce and ice components on both grid 1 & 2
+      CASE( 'U,V,T' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'T'        ! ice components given at T-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'U,V,I' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'U,V,F' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'T,I' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'T,F' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'T,U,V' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'T'        ! oce components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
+         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 only
+         srcv(jpr_itx1:jpr_itz2)%laction = .TRUE.     ! receive ice components on grid 1 & 2
+      CASE default   
+         CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_tau(4)' )
+      END SELECT
+      !
+      IF( TRIM( cn_rcv_tau(2) ) == 'spherical' )   &           ! spherical: 3rd component not received
+         &     srcv( (/jpr_otz1, jpr_otz2, jpr_itz1, jpr_itz2/) )%laction = .FALSE. 
+      !
+      IF( TRIM( cn_rcv_tau(1) ) /= 'oce and ice' ) THEN        ! 'oce and ice' case ocean stress on ocean mesh used
+         srcv(jpr_itx1:jpr_itz2)%laction = .FALSE.    ! ice components not received
+         srcv(jpr_itx1)%clgrid = 'U'                  ! ocean stress used after its transformation
+         srcv(jpr_ity1)%clgrid = 'V'                  ! i.e. it is always at U- & V-points for i- & j-comp. resp.
+      ENDIF
+       
+      !                                                      ! ------------------------- !
+      !                                                      !    freshwater budget      !   E-P
+      !                                                      ! ------------------------- !
+      ! we suppose that atmosphere modele do not make the difference between precipiration (liquide or solid)
+      ! over ice of free ocean within the same atmospheric cell.cd 
+      srcv(jpr_rain)%clname = 'OTotRain'      ! Rain = liquid precipitation
+      srcv(jpr_snow)%clname = 'OTotSnow'      ! Snow = solid precipitation
+      srcv(jpr_tevp)%clname = 'OTotEvap'      ! total evaporation (over oce + ice sublimation)
+      srcv(jpr_ievp)%clname = 'OIceEvap'      ! evaporation over ice = sublimation
+      srcv(jpr_sbpr)%clname = 'OSubMPre'      ! sublimation - liquid precipitation - solid precipitation 
+      srcv(jpr_semp)%clname = 'OISubMSn'      ! ice solid water budget = sublimation - solid precipitation
+      srcv(jpr_oemp)%clname = 'OOEvaMPr'      ! ocean water budget = ocean Evap - ocean precip
+      SELECT CASE( TRIM( cn_rcv_emp ) )
+      CASE( 'oce only'      )   ;   srcv(                                 jpr_oemp   )%laction = .TRUE. 
+      CASE( 'conservative'  )   ;   srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_emp' )
+      END SELECT
+
+      !                                                      ! ------------------------- !
+      !                                                      !     Runoffs & Calving     !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_rnf   )%clname = 'O_Runoff'   ;   IF( TRIM( cn_rcv_rnf ) == 'coupled' )   srcv(jpr_rnf)%laction = .TRUE.
+                                                 IF( TRIM( cn_rcv_rnf ) == 'climato' )   THEN   ;   ln_rnf = .TRUE.
+                                                 ELSE                                           ;   ln_rnf = .FALSE.
+                                                 ENDIF
+      srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( cn_rcv_cal ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
+
+      !                                                      ! ------------------------- !
+      !                                                      !    non solar radiation    !   Qns
+      !                                                      ! ------------------------- !
+      srcv(jpr_qnsoce)%clname = 'O_QnsOce'
+      srcv(jpr_qnsice)%clname = 'O_QnsIce'
+      srcv(jpr_qnsmix)%clname = 'O_QnsMix'
+      SELECT CASE( TRIM( cn_rcv_qns ) )
+      CASE( 'oce only'      )   ;   srcv(               jpr_qnsoce   )%laction = .TRUE.
+      CASE( 'conservative'  )   ;   srcv( (/jpr_qnsice, jpr_qnsmix/) )%laction = .TRUE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qnsice, jpr_qnsoce/) )%laction = .TRUE.
+      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qnsmix   )%laction = .TRUE. 
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qns' )
+      END SELECT
+
+      !                                                      ! ------------------------- !
+      !                                                      !    solar radiation        !   Qsr
+      !                                                      ! ------------------------- !
+      srcv(jpr_qsroce)%clname = 'O_QsrOce'
+      srcv(jpr_qsrice)%clname = 'O_QsrIce'
+      srcv(jpr_qsrmix)%clname = 'O_QsrMix'
+      SELECT CASE( TRIM( cn_rcv_qsr ) )
+      CASE( 'oce only'      )   ;   srcv(               jpr_qsroce   )%laction = .TRUE.
+      CASE( 'conservative'  )   ;   srcv( (/jpr_qsrice, jpr_qsrmix/) )%laction = .TRUE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qsrice, jpr_qsroce/) )%laction = .TRUE.
+      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qsrmix   )%laction = .TRUE. 
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qsr' )
+      END SELECT
+
+      !                                                      ! ------------------------- !
+      !                                                      !   non solar sensitivity   !   d(Qns)/d(T)
+      !                                                      ! ------------------------- !
+      srcv(jpr_dqnsdt)%clname = 'O_dQnsdT'   
+      IF( TRIM( cn_rcv_dqnsdt ) == 'coupled' )   srcv(jpr_dqnsdt)%laction = .TRUE.
+      !
+      ! non solar sensitivity mandatory for ice model
+      IF( TRIM( cn_rcv_dqnsdt ) == 'none' .AND. k_ice /= 0 ) &
+         CALL ctl_stop( 'sbc_cpl_init: cn_rcv_dqnsdt must be coupled in namsbc_cpl namelist' )
+      ! non solar sensitivity mandatory for mixed oce-ice solar radiation coupling technique
+      IF( TRIM( cn_rcv_dqnsdt ) == 'none' .AND. TRIM( cn_rcv_qns ) == 'mixed oce-ice' ) &
+         CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between cn_rcv_qns and cn_rcv_dqnsdt' )
+      !                                                      ! ------------------------- !
+      !                                                      !    Ice Qsr penetration    !   
+      !                                                      ! ------------------------- !
+      ! fraction of net shortwave radiation which is not absorbed in the thin surface layer 
+      ! and penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+      ! Coupled case: since cloud cover is not received from atmosphere 
+      !               ===> defined as constant value -> definition done in sbc_cpl_init
+      fr1_i0(:,:) = 0.18
+      fr2_i0(:,:) = 0.82
+      !                                                      ! ------------------------- !
+      !                                                      !      10m wind module      !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_w10m)%clname = 'O_Wind10'   ;   IF( TRIM(cn_rcv_w10m  ) == 'coupled' )   srcv(jpr_w10m)%laction = .TRUE. 
+      !
+      !                                                      ! ------------------------- !
+      !                                                      !   wind stress module      !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_taum)%clname = 'O_TauMod'   ;   IF( TRIM(cn_rcv_taumod) == 'coupled' )   srcv(jpr_taum)%laction = .TRUE.
+      lhftau = srcv(jpr_taum)%laction
+
+#if defined key_cpl_carbon_cycle
+      !                                                      ! ------------------------- !
+      !                                                      !      Atmospheric CO2      !
+      !                                                      ! ------------------------- !
+      srcv(jpr_co2 )%clname = 'O_AtmCO2'   ;   IF( TRIM(cn_rcv_co2   ) == 'coupled' )    srcv(jpr_co2 )%laction = .TRUE.
+#endif
+     
+      ! ================================ !
+      !     Define the send interface    !
+      ! ================================ !
+      ! for each field: define the OASIS name                           (srcv(:)%clname)
+      !                 define send or not from the namelist parameters (srcv(:)%laction)
+      !                 define the north fold type of lbc               (srcv(:)%nsgn)
+      
+      ! default definitions of nsnd
+      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1
+         
+      !                                                      ! ------------------------- !
+      !                                                      !    Surface temperature    !
+      !                                                      ! ------------------------- !
+      ssnd(jps_toce)%clname = 'O_SSTSST'
+      ssnd(jps_tice)%clname = 'O_TepIce'
+      ssnd(jps_tmix)%clname = 'O_TepMix'
+      SELECT CASE( TRIM( cn_snd_temperature ) )
+      CASE( 'oce only'             )   ;   ssnd(   jps_toce             )%laction = .TRUE.
+      CASE( 'weighted oce and ice' )   ;   ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE.
+      CASE( 'mixed oce-ice'        )   ;   ssnd(   jps_tmix             )%laction = .TRUE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_temperature' )
+      END SELECT
+     
+      !                                                      ! ------------------------- !
+      !                                                      !          Albedo           !
+      !                                                      ! ------------------------- !
+      ssnd(jps_albice)%clname = 'O_AlbIce' 
+      ssnd(jps_albmix)%clname = 'O_AlbMix'
+      SELECT CASE( TRIM( cn_snd_albedo ) )
+      CASE( 'none'          )       ! nothing to do
+      CASE( 'weighted ice'  )   ;   ssnd(jps_albice)%laction = .TRUE.
+      CASE( 'mixed oce-ice' )   ;   ssnd(jps_albmix)%laction = .TRUE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_albedo' )
+      END SELECT
+      !
+      ! Need to calculate oceanic albedo if
+      !     1. sending mixed oce-ice albedo or
+      !     2. receiving mixed oce-ice solar radiation 
+      IF ( TRIM ( cn_snd_albedo ) == 'mixed oce-ice' .OR. TRIM ( cn_rcv_qsr ) == 'mixed oce-ice' ) THEN
+         CALL albedo_oce( zaos, zacs )
+         ! Due to lack of information on nebulosity : mean clear/overcast sky
+         albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
+      ENDIF
+
+      !                                                      ! ------------------------- !
+      !                                                      !  Ice fraction & Thickness ! 
+      !                                                      ! ------------------------- !
+      ssnd(jps_fice)%clname = 'OIceFrac'   
+      ssnd(jps_hice)%clname = 'O_IceTck'
+      ssnd(jps_hsnw)%clname = 'O_SnwTck'
+      IF( k_ice /= 0 )   ssnd(jps_fice)%laction = .TRUE.       ! if ice treated in the ocean (even in climato case)
+      IF( TRIM( cn_snd_thickness ) == 'weighted ice and snow' )   ssnd( (/jps_hice, jps_hsnw/) )%laction = .TRUE.
+         
+      !                                                      ! ------------------------- !
+      !                                                      !      Surface current      !
+      !                                                      ! ------------------------- !
+      !        ocean currents              !            ice velocities
+      ssnd(jps_ocx1)%clname = 'O_OCurx1'   ;   ssnd(jps_ivx1)%clname = 'O_IVelx1'
+      ssnd(jps_ocy1)%clname = 'O_OCury1'   ;   ssnd(jps_ivy1)%clname = 'O_IVely1'
+      ssnd(jps_ocz1)%clname = 'O_OCurz1'   ;   ssnd(jps_ivz1)%clname = 'O_IVelz1'
+      !
+      ssnd(jps_ocx1:jps_ivz1)%nsgn = -1    ! vectors: change of the sign at the north fold
+
+      IF( cn_snd_crt(4) /= 'T' )   CALL ctl_stop( 'cn_snd_crt(4) must be equal to T' )
+      ssnd(jps_ocx1:jps_ivz1)%clgrid  = 'T'      ! all oce and ice components on the same unique grid
+
+      ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE.   ! default: all are send
+      IF( TRIM( cn_snd_crt(2) ) == 'spherical' )   ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE. 
+      SELECT CASE( TRIM( cn_snd_crt(1) ) )
+      CASE( 'none'                 )   ;   ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
+      CASE( 'oce only'             )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
+      CASE( 'weighted oce and ice' )   !   nothing to do
+      CASE( 'mixed oce-ice'        )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_snd_crt(1)' )
+      END SELECT
+
+#if defined key_cpl_carbon_cycle
+      !                                                      ! ------------------------- !
+      !                                                      !          CO2 flux         !
+      !                                                      ! ------------------------- !
+      ssnd(jps_co2)%clname = 'O_CO2FLX' ;  IF( TRIM(cn_snd_co2) == 'coupled' )    ssnd(jps_co2 )%laction = .TRUE.
+#endif
+      !
+      ! ================================ !
+      !   initialisation of the coupler  !
+      ! ================================ !
+
+      CALL cpl_prism_define(jprcv, jpsnd)            
+      !
+   END SUBROUTINE sbc_cpl_init
+
+
+   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_rcv  ***
+      !!
+      !! ** Purpose :   provide the stress over the ocean and, if no sea-ice,
+      !!                provide the ocean heat and freshwater fluxes.
+      !!
+      !! ** Method  : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
+      !!                OASIS controls if there is something do receive or not. nrcvinfo contains the info
+      !!                to know if the field was really received or not
+      !!
+      !!              --> If ocean stress was really received:
+      !!
+      !!                  - transform the received ocean stress vector from the received
+      !!                 referential and grid into an atmosphere-ocean stress in 
+      !!                 the (i,j) ocean referencial and at the ocean velocity point. 
+      !!                    The received stress are :
+      !!                     - defined by 3 components (if cartesian coordinate)
+      !!                            or by 2 components (if spherical)
+      !!                     - oriented along geographical   coordinate (if eastward-northward)
+      !!                            or  along the local grid coordinate (if local grid)
+      !!                     - given at U- and V-point, resp.   if received on 2 grids
+      !!                            or at T-point               if received on 1 grid
+      !!                    Therefore and if necessary, they are successively 
+      !!                  processed in order to obtain them 
+      !!                     first  as  2 components on the sphere 
+      !!                     second as  2 components oriented along the local grid
+      !!                     third  as  2 components on the U,V grid 
+      !!
+      !!              --> 
+      !!
+      !!              - In 'ocean only' case, non solar and solar ocean heat fluxes 
+      !!             and total ocean freshwater fluxes  
+      !!
+      !! ** Method  :   receive all fields from the atmosphere and transform 
+      !!              them into ocean surface boundary condition fields 
+      !!
+      !! ** Action  :   update  utau, vtau   ocean stress at U,V grid 
+      !!                        taum, wndm   wind stres and wind speed module at T-point
+      !!                        qns , qsr    non solar and solar ocean heat fluxes   ('ocean only case)
+      !!                        emp = emps   evap. - precip. (- runoffs) (- calving) ('ocean only case)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! ocean model time step index
+      INTEGER, INTENT(in) ::   k_fsbc   ! frequency of sbc (-> ice model) computation 
+      INTEGER, INTENT(in) ::   k_ice    ! ice management in the sbc (=0/1/2/3)
+      !!
+      LOGICAL ::    llnewtx, llnewtau      ! update wind stress components and module??
+      INTEGER  ::   ji, jj, jn             ! dummy loop indices
+      INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdttra did not change since nit000)
+      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars     
+      REAL(wp) ::   zcoef                  ! temporary scalar
+      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
+      REAL(wp) ::   zzx, zzy               ! temporary variables
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty   ! 2D workspace 
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL sbc_cpl_init( k_ice )          ! initialisation
+
+      !                                                 ! Receive all the atmos. fields (including ice information)
+      isec = ( kt - nit000 ) * NINT( rdttra(1) )             ! date of exchanges
+      DO jn = 1, jprcv                                       ! received fields sent by the atmosphere
+         IF( srcv(jn)%laction )   CALL cpl_prism_rcv( jn, isec, frcv(:,:,jn), nrcvinfo(jn) )
+      END DO
+
+      !                                                      ! ========================= !
+      IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  !
+         !                                                   ! ========================= !
+         ! define frcv(:,:,jpr_otx1) and frcv(:,:,jpr_oty1): stress at U/V point along model grid
+         ! => need to be done only when we receive the field
+         IF(  nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
+            !
+            IF( TRIM( cn_rcv_tau(2) ) == 'cartesian' ) THEN            ! 2 components on the sphere
+               !                                                       ! (cartesian to spherical -> 3 to 2 components)
+               !
+               CALL geo2oce( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), frcv(:,:,jpr_otz1),   &
+                  &          srcv(jpr_otx1)%clgrid, ztx, zty )
+               frcv(:,:,jpr_otx1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
+               frcv(:,:,jpr_oty1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
+               !
+               IF( srcv(jpr_otx2)%laction ) THEN
+                  CALL geo2oce( frcv(:,:,jpr_otx2), frcv(:,:,jpr_oty2), frcv(:,:,jpr_otz2),   &
+                     &          srcv(jpr_otx2)%clgrid, ztx, zty )
+                  frcv(:,:,jpr_otx2) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
+                  frcv(:,:,jpr_oty2) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
+               ENDIF
+               !
+            ENDIF
+            !
+            IF( TRIM( cn_rcv_tau(3) ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
+               !                                                       ! (geographical to local grid -> rotate the components)
+               CALL rot_rep( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )   
+               frcv(:,:,jpr_otx1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
+               IF( srcv(jpr_otx2)%laction ) THEN
+                  CALL rot_rep( frcv(:,:,jpr_otx2), frcv(:,:,jpr_oty2), srcv(jpr_otx2)%clgrid, 'en->j', zty )   
+               ELSE
+                  CALL rot_rep( frcv(:,:,jpr_otx1), frcv(:,:,jpr_oty1), srcv(jpr_otx1)%clgrid, 'en->j', zty )  
+               ENDIF
+               frcv(:,:,jpr_oty1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid
+            ENDIF
+            !                              
+            IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
+               DO jj = 2, jpjm1                                          ! T ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     frcv(ji,jj,jpr_otx1) = 0.5 * ( frcv(ji+1,jj  ,jpr_otx1) + frcv(ji,jj,jpr_otx1) )
+                     frcv(ji,jj,jpr_oty1) = 0.5 * ( frcv(ji  ,jj+1,jpr_oty1) + frcv(ji,jj,jpr_oty1) )
+                  END DO
+               END DO
+               CALL lbc_lnk( frcv(:,:,jpr_otx1), 'U',  -1. )   ;   CALL lbc_lnk( frcv(:,:,jpr_oty1), 'V',  -1. )
+            ENDIF
+            llnewtx = .TRUE.
+         ELSE
+            llnewtx = .FALSE.
+         ENDIF
+         !                                                   ! ========================= !
+      ELSE                                                   !   No dynamical coupling   !
+         !                                                   ! ========================= !
+         frcv(:,:,jpr_otx1) = 0.e0                               ! here simply set to zero 
+         frcv(:,:,jpr_oty1) = 0.e0                               ! an external read in a file can be added instead
+         llnewtx = .TRUE.
+         !
+      ENDIF
+      
+      !                                                      ! ========================= !
+      !                                                      !    wind stress module     !   (taum)
+      !                                                      ! ========================= !
+      !
+      IF( .NOT. srcv(jpr_taum)%laction ) THEN                    ! compute wind stress module from its components if not received 
+         ! => need to be done only when otx1 was changed
+         IF( llnewtx ) THEN
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vect. opt.
+                  zzx = frcv(ji-1,jj  ,jpr_otx1) + frcv(ji,jj,jpr_otx1) 
+                  zzy = frcv(ji  ,jj-1,jpr_oty1) + frcv(ji,jj,jpr_oty1) 
+                  frcv(ji,jj,jpr_taum) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
+               END DO
+            END DO
+            CALL lbc_lnk( frcv(:,:,jpr_taum), 'T', 1. )
+            llnewtau = .TRUE.
+         ELSE
+            llnewtau = .FALSE.
+         ENDIF
+      ELSE
+         llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
+         ! Stress module can be negative when received (interpolation problem)
+         IF( llnewtau ) THEN 
+            DO jj = 1, jpj
+               DO ji = 1, jpi 
+                  frcv(ji,jj,jpr_taum) = MAX( 0.0e0, frcv(ji,jj,jpr_taum) )
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+      
+      !                                                      ! ========================= !
+      !                                                      !      10 m wind speed      !   (wndm)
+      !                                                      ! ========================= !
+      !
+      IF( .NOT. srcv(jpr_w10m)%laction ) THEN                    ! compute wind spreed from wind stress module if not received  
+         ! => need to be done only when taumod was changed
+         IF( llnewtau ) THEN 
+            zcoef = 1. / ( zrhoa * zcdrag ) 
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi 
+                  frcv(ji,jj,jpr_w10m) = SQRT( frcv(ji,jj,jpr_taum) * zcoef )
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+      ! u(v)tau and taum will be modified by ice model (wndm will be changed by PISCES)
+      ! -> need to be reset before each call of the ice/fsbc      
+      IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
+         !
+         utau(:,:) = frcv(:,:,jpr_otx1)                   
+         vtau(:,:) = frcv(:,:,jpr_oty1)
+         taum(:,:) = frcv(:,:,jpr_taum)
+         wndm(:,:) = frcv(:,:,jpr_w10m)
+         CALL iom_put( "taum_oce", taum )   ! output wind stress module
+         !  
+      ENDIF
+      !                                                      ! ========================= !
+      IF( k_ice <= 1 ) THEN                                  !  heat & freshwater fluxes ! (Ocean only case)
+         !                                                   ! ========================= !
+         !
+         !                                                       ! non solar heat flux over the ocean (qns)
+         IF( srcv(jpr_qnsoce)%laction )   qns(:,:) = frcv(:,:,jpr_qnsoce)
+         IF( srcv(jpr_qnsmix)%laction )   qns(:,:) = frcv(:,:,jpr_qnsmix)        
+         !   energy for melting solid precipitation over free ocean
+         zcoef = xlsn / rhosn
+         qns(:,:) = qns(:,:) - frcv(:,:,jpr_snow) * zcoef
+         !                                                       ! solar flux over the ocean          (qsr)
+         IF( srcv(jpr_qsroce)%laction )   qsr(:,:) = frcv(:,:,jpr_qsroce) 
+         IF( srcv(jpr_qsrmix)%laction )   qsr(:,:) = frcv(:,:,jpr_qsrmix)
+         !
+         !                                                       ! total freshwater fluxes over the ocean (emp, emps)
+         SELECT CASE( TRIM( cn_rcv_emp ) )                                    ! evaporation - precipitation
+         CASE( 'conservative' )
+            emp(:,:) = frcv(:,:,jpr_tevp) - ( frcv(:,:,jpr_rain) + frcv(:,:,jpr_snow) )
+         CASE( 'oce only', 'oce and ice' )
+            emp(:,:) = frcv(:,:,jpr_oemp)
+         CASE default
+            CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of cn_rcv_emp' )
+         END SELECT
+         !
+         !                                                        ! runoffs and calving (added in emp)
+         IF( srcv(jpr_rnf)%laction )   emp(:,:) = emp(:,:) - frcv(:,:,jpr_rnf)        
+         IF( srcv(jpr_cal)%laction )   emp(:,:) = emp(:,:) - frcv(:,:,jpr_cal)
+         !
+!!gm :  this seems to be internal cooking, not sure to need that in a generic interface 
+!!gm                                       at least should be optional...
+!!         IF( TRIM( cn_rcv_rnf ) == 'coupled' ) THEN     ! add to the total freshwater budget
+!!            ! remove negative runoff
+!!            zcumulpos = SUM( MAX( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) ) 
+!!            zcumulneg = SUM( MIN( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
+!!            IF( lk_mpp )   CALL mpp_sum( zcumulpos )   ! sum over the global domain
+!!            IF( lk_mpp )   CALL mpp_sum( zcumulneg ) 
+!!            IF( zcumulpos /= 0. ) THEN                 ! distribute negative runoff on positive runoff grid points
+!!               zcumulneg = 1.e0 + zcumulneg / zcumulpos
+!!               frcv(:,:,jpr_rnf) = MAX( frcv(:,:,jpr_rnf), 0.e0 ) * zcumulneg
+!!            ENDIF     
+!!            ! add runoff to e-p 
+!!            emp(:,:) = emp(:,:) - frcv(:,:,jpr_rnf)
+!!         ENDIF
+!!gm  end of internal cooking
+         !
+         emps(:,:) = emp(:,:)                                        ! concentration/dilution = emp
+  
+         !                                                           ! 10 m wind speed
+         IF( srcv(jpr_w10m)%laction )   wndm(:,:) = frcv(:,:,jpr_w10m)
+         !
+#if defined  key_cpl_carbon_cycle
+         !                                                              ! atmosph. CO2 (ppm)
+         IF( srcv(jpr_co2)%laction )   atm_co2(:,:) = frcv(:,:,jpr_co2)
+#endif
+
+      ENDIF
+      !
+   END SUBROUTINE sbc_cpl_rcv
+   
+
+   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_ice_tau  ***
+      !!
+      !! ** Purpose :   provide the stress over sea-ice in coupled mode 
+      !!
+      !! ** Method  :   transform the received stress from the atmosphere into
+      !!             an atmosphere-ice stress in the (i,j) ocean referencial
+      !!             and at the velocity point of the sea-ice model (cigr_type):
+      !!                'C'-grid : i- (j-) components given at U- (V-) point 
+      !!                'B'-grid : both components given at I-point 
+      !!
+      !!                The received stress are :
+      !!                 - defined by 3 components (if cartesian coordinate)
+      !!                        or by 2 components (if spherical)
+      !!                 - oriented along geographical   coordinate (if eastward-northward)
+      !!                        or  along the local grid coordinate (if local grid)
+      !!                 - given at U- and V-point, resp.   if received on 2 grids
+      !!                        or at a same point (T or I) if received on 1 grid
+      !!                Therefore and if necessary, they are successively 
+      !!             processed in order to obtain them 
+      !!                 first  as  2 components on the sphere 
+      !!                 second as  2 components oriented along the local grid
+      !!                 third  as  2 components on the cigr_type point 
+      !!
+      !!                In 'oce and ice' case, only one vector stress field 
+      !!             is received. It has already been processed in sbc_cpl_rcv
+      !!             so that it is now defined as (i,j) components given at U-
+      !!             and V-points, respectively. Therefore, here only the third
+      !!             transformation is done and only if the ice-grid is a 'B'-grid. 
+      !!
+      !! ** Action  :   return ptau_i, ptau_j, the stress over the ice at cigr_type point
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(out), DIMENSION(jpi,jpj) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
+      REAL(wp), INTENT(out), DIMENSION(jpi,jpj) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
+      !!
+      INTEGER ::   ji, jj                          ! dummy loop indices
+      INTEGER ::   itx                             ! index of taux over ice
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty   ! 2D workspace
+      !!----------------------------------------------------------------------
+
+      IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1   
+      ELSE                                ;   itx =  jpr_otx1
+      ENDIF
+
+      ! do something only if we just received the stress from atmosphere
+      IF(  nrcvinfo(itx) == OASIS_Rcv ) THEN
+
+         !                                                      ! ======================= !
+         IF( srcv(jpr_itx1)%laction ) THEN                      !   ice stress received   !
+            !                                                   ! ======================= !
+            !  
+            IF( TRIM( cn_rcv_tau(2) ) == 'cartesian' ) THEN            ! 2 components on the sphere
+               !                                                       ! (cartesian to spherical -> 3 to 2 components)
+               CALL geo2oce( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), frcv(:,:,jpr_itz1),   &
+                  &          srcv(jpr_itx1)%clgrid, ztx, zty )
+               frcv(:,:,jpr_itx1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
+               frcv(:,:,jpr_itx1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
+               !
+               IF( srcv(jpr_itx2)%laction ) THEN
+                  CALL geo2oce( frcv(:,:,jpr_itx2), frcv(:,:,jpr_ity2), frcv(:,:,jpr_itz2),   &
+                     &          srcv(jpr_itx2)%clgrid, ztx, zty )
+                  frcv(:,:,jpr_itx2) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
+                  frcv(:,:,jpr_ity2) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
+               ENDIF
+               !
+            ENDIF
+            !
+            IF( TRIM( cn_rcv_tau(3) ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
+               !                                                       ! (geographical to local grid -> rotate the components)
+               CALL rot_rep( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )   
+               frcv(:,:,jpr_itx1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
+               IF( srcv(jpr_itx2)%laction ) THEN
+                  CALL rot_rep( frcv(:,:,jpr_itx2), frcv(:,:,jpr_ity2), srcv(jpr_itx2)%clgrid, 'en->j', zty )   
+               ELSE
+                  CALL rot_rep( frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1), srcv(jpr_itx1)%clgrid, 'en->j', zty )  
+               ENDIF
+               frcv(:,:,jpr_ity1) = zty(:,:)      ! overwrite 2nd component on the 1st grid
+            ENDIF
+            !                                                   ! ======================= !
+         ELSE                                                   !     use ocean stress    !
+            !                                                   ! ======================= !
+            frcv(:,:,jpr_itx1) = frcv(:,:,jpr_otx1)
+            frcv(:,:,jpr_ity1) = frcv(:,:,jpr_oty1)
+            !
+         ENDIF
+
+         !                                                      ! ======================= !
+         !                                                      !     put on ice grid     !
+         !                                                      ! ======================= !
+         !    
+         !                                                  j+1   j     -----V---F
+         ! ice stress on ice velocity point (cigr_type)                  !       |
+         ! (C-grid ==>(U,V) or B-grid ==> I or F)                 j      |   T   U
+         !                                                               |       |
+         !                                                   j    j-1   -I-------|
+         !                                               (for I)         |       |
+         !                                                              i-1  i   i
+         !                                                               i      i+1 (for I)
+         SELECT CASE ( cigr_type )
+            !
+         CASE( 'I' )                                         ! B-grid ==> I
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               DO jj = 2, jpjm1                                   ! (U,V) ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(ji-1,jj  ,jpr_itx1) + frcv(ji-1,jj-1,jpr_itx1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(ji  ,jj-1,jpr_ity1) + frcv(ji-1,jj-1,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'F' )
+               DO jj = 2, jpjm1                                   ! F ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = frcv(ji-1,jj-1,jpr_itx1) 
+                     p_tauj(ji,jj) = frcv(ji-1,jj-1,jpr_ity1)  
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_itx1) + frcv(ji-1,jj  ,jpr_itx1)   &
+                        &                   + frcv(ji,jj-1,jpr_itx1) + frcv(ji-1,jj-1,jpr_itx1) ) 
+                     p_tauj(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_ity1) + frcv(ji-1,jj  ,jpr_ity1)   &
+                        &                   + frcv(ji,jj-1,jpr_ity1) + frcv(ji-1,jj-1,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! I ==> I
+               p_tauj(:,:) = frcv(:,:,jpr_ity1)
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'I' ) THEN 
+               CALL lbc_lnk( p_taui, 'I',  -1. )   ;   CALL lbc_lnk( p_tauj, 'I',  -1. )
+            ENDIF
+            !
+         CASE( 'F' )                                         ! B-grid ==> F
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               DO jj = 2, jpjm1                                   ! (U,V) ==> F
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_itx1) + frcv(ji  ,jj+1,jpr_itx1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_ity1) + frcv(ji+1,jj  ,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               DO jj = 2, jpjm1                                   ! I ==> F
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = frcv(ji+1,jj+1,jpr_itx1) 
+                     p_tauj(ji,jj) = frcv(ji+1,jj+1,jpr_ity1)  
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> F
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_itx1) + frcv(ji+1,jj  ,jpr_itx1)   &
+                        &                   + frcv(ji,jj+1,jpr_itx1) + frcv(ji+1,jj+1,jpr_itx1) ) 
+                     p_tauj(ji,jj) = 0.25 * ( frcv(ji,jj  ,jpr_ity1) + frcv(ji+1,jj  ,jpr_ity1)   &
+                        &                   + frcv(ji,jj+1,jpr_ity1) + frcv(ji+1,jj+1,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'F' )
+               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! F ==> F
+               p_tauj(:,:) = frcv(:,:,jpr_ity1)
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'F' ) THEN 
+               CALL lbc_lnk( p_taui, 'F',  -1. )   ;   CALL lbc_lnk( p_tauj, 'F',  -1. )
+            ENDIF
+            !
+         CASE( 'C' )                                         ! C-grid ==> U,V
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               p_taui(:,:) = frcv(:,:,jpr_itx1)                   ! (U,V) ==> (U,V)
+               p_tauj(:,:) = frcv(:,:,jpr_ity1)
+            CASE( 'F' )
+               DO jj = 2, jpjm1                                   ! F ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_itx1) + frcv(ji  ,jj-1,jpr_itx1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(ji,jj,jpr_ity1) + frcv(ji-1,jj  ,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(ji+1,jj  ,jpr_itx1) + frcv(ji,jj,jpr_itx1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(ji  ,jj+1,jpr_ity1) + frcv(ji,jj,jpr_ity1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               DO jj = 2, jpjm1                                   ! I ==> (U,V)
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(ji+1,jj+1,jpr_itx1) + frcv(ji+1,jj  ,jpr_itx1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(ji+1,jj+1,jpr_ity1) + frcv(ji  ,jj+1,jpr_ity1) )
+                  END DO
+               END DO
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN 
+               CALL lbc_lnk( p_taui, 'U',  -1. )   ;   CALL lbc_lnk( p_tauj, 'V',  -1. )
+            ENDIF
+         END SELECT
+
+         !!gm Should be useless as sbc_cpl_ice_tau only called at coupled frequency
+         ! The receive stress are transformed such that in all case frcv(:,:,jpr_itx1), frcv(:,:,jpr_ity1)
+         ! become the i-component and j-component of the stress at the right grid point 
+         !!gm  frcv(:,:,jpr_itx1) = p_taui(:,:)
+         !!gm  frcv(:,:,jpr_ity1) = p_tauj(:,:)
+         !!gm
+      ENDIF
+      !   
+   END SUBROUTINE sbc_cpl_ice_tau
+   
+
+   SUBROUTINE sbc_cpl_ice_flx( p_frld  ,                                  &
+      &                        pqns_tot, pqns_ice, pqsr_tot , pqsr_ice,   &
+      &                        pemp_tot, pemp_ice, pdqns_ice, psprecip,   &
+      &                        palbi   , psst    , pist                 )
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_ice_flx_rcv  ***
+      !!
+      !! ** Purpose :   provide the heat and freshwater fluxes of the 
+      !!              ocean-ice system.
+      !!
+      !! ** Method  :   transform the fields received from the atmosphere into
+      !!             surface heat and fresh water boundary condition for the 
+      !!             ice-ocean system. The following fields are provided:
+      !!              * total non solar, solar and freshwater fluxes (qns_tot, 
+      !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux)
+      !!             NB: emp_tot include runoffs and calving.
+      !!              * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
+      !!             emp_ice = sublimation - solid precipitation as liquid
+      !!             precipitation are re-routed directly to the ocean and 
+      !!             runoffs and calving directly enter the ocean.
+      !!              * solid precipitation (sprecip), used to add to qns_tot 
+      !!             the heat lost associated to melting solid precipitation
+      !!             over the ocean fraction.
+      !!       ===>> CAUTION here this changes the net heat flux received from
+      !!             the atmosphere
+      !!
+      !!             N.B. - fields over sea-ice are passed in argument so that
+      !!                 the module can be compile without sea-ice.
+      !!                  - the fluxes have been separated from the stress as
+      !!                 (a) they are updated at each ice time step compare to
+      !!                 an update at each coupled time step for the stress, and
+      !!                 (b) the conservative computation of the fluxes over the
+      !!                 sea-ice area requires the knowledge of the ice fraction
+      !!                 after the ice advection and before the ice thermodynamics,
+      !!                 so that the stress is updated before the ice dynamics
+      !!                 while the fluxes are updated after it.
+      !!
+      !! ** Action  :   update at each nf_ice time step:
+      !!                   pqns_tot, pqsr_tot  non-solar and solar total heat fluxes
+      !!                   pqns_ice, pqsr_ice  non-solar and solar heat fluxes over the ice
+      !!                   pemp_tot            total evaporation - precipitation(liquid and solid) (-runoff)(-calving)
+      !!                   pemp_ice            ice sublimation - solid precipitation over the ice
+      !!                   pdqns_ice           d(non-solar heat flux)/d(Temperature) over the ice
+      !!                   sprecip             solid precipitation over the ocean  
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl) ::   p_frld     ! lead fraction                [0 to 1]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pqns_tot   ! total non solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pqns_ice   ! ice   non solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pqsr_tot   ! total     solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pqsr_ice   ! ice       solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pemp_tot   ! total     freshwater budget        [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   pemp_ice   ! solid freshwater budget over ice   [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj    ) ::   psprecip   ! Net solid precipitation (=emp_ice) [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpl) ::   pdqns_ice  ! d(Q non solar)/d(Temperature) over ice
+      ! optional arguments, used only in 'mixed oce-ice' case
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl), OPTIONAL ::   palbi   ! ice albedo 
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj    ), OPTIONAL ::   psst    ! sea surface temperature     [Celcius]
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpl), OPTIONAL ::   pist    ! ice surface temperature     [Kelvin]
+     !!
+      INTEGER ::   ji, jj           ! dummy loop indices
+      INTEGER ::   isec, info       ! temporary integer
+      REAL(wp)::   zcoef, ztsurf    ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj    )::   zcptn    ! rcp * tn(:,:,1)
+      REAL(wp), DIMENSION(jpi,jpj    )::   ztmp     ! temporary array
+      REAL(wp), DIMENSION(jpi,jpj    )::   zsnow    ! snow precipitation 
+      REAL(wp), DIMENSION(jpi,jpj,jpl)::   zicefr   ! ice fraction 
+      !!----------------------------------------------------------------------
+      zicefr(:,:,1) = 1.- p_frld(:,:,1)
+      IF( lk_diaar5 )   zcptn(:,:) = rcp * tn(:,:,1)
+      !
+      !                                                      ! ========================= !
+      !                                                      !    freshwater budget      !   (emp)
+      !                                                      ! ========================= !
+      !
+      !                                                           ! total Precipitations - total Evaporation (emp_tot)
+      !                                                           ! solid precipitation  - sublimation       (emp_ice)
+      !                                                           ! solid Precipitation                      (sprecip)
+      SELECT CASE( TRIM( cn_rcv_emp ) )
+      CASE( 'conservative'  )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
+         pemp_tot(:,:) = frcv(:,:,jpr_tevp) - frcv(:,:,jpr_rain) - frcv(:,:,jpr_snow)
+         pemp_ice(:,:) = frcv(:,:,jpr_ievp) - frcv(:,:,jpr_snow)
+         zsnow   (:,:) = frcv(:,:,jpr_snow)
+                           CALL iom_put( 'rain'         , frcv(:,:,jpr_rain)              )   ! liquid precipitation 
+         IF( lk_diaar5 )   CALL iom_put( 'hflx_rain_cea', frcv(:,:,jpr_rain) * zcptn(:,:) )   ! heat flux from liq. precip. 
+         ztmp(:,:) = frcv(:,:,jpr_tevp) - frcv(:,:,jpr_ievp) * zicefr(:,:,1)
+                           CALL iom_put( 'evap_ao_cea'  , ztmp                            )   ! ice-free oce evap (cell average)
+         IF( lk_diaar5 )   CALL iom_put( 'hflx_evap_cea', ztmp(:,:         ) * zcptn(:,:) )   ! heat flux from from evap (cell ave)
+      CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp
+         pemp_tot(:,:) = p_frld(:,:,1) * frcv(:,:,jpr_oemp) + zicefr(:,:,1) * frcv(:,:,jpr_sbpr) 
+         pemp_ice(:,:) = frcv(:,:,jpr_semp)
+         zsnow   (:,:) = - frcv(:,:,jpr_semp) + frcv(:,:,jpr_ievp)
+      END SELECT
+      psprecip(:,:) = - pemp_ice(:,:)
+      CALL iom_put( 'snowpre'    , zsnow                               )   ! Snow
+      CALL iom_put( 'snow_ao_cea', zsnow(:,:         ) * p_frld(:,:,1) )   ! Snow        over ice-free ocean  (cell average)
+      CALL iom_put( 'snow_ai_cea', zsnow(:,:         ) * zicefr(:,:,1) )   ! Snow        over sea-ice         (cell average)
+      CALL iom_put( 'subl_ai_cea', frcv (:,:,jpr_ievp) * zicefr(:,:,1) )   ! Sublimation over sea-ice         (cell average)
+      !   
+      !                                                           ! runoffs and calving (put in emp_tot)
+      IF( srcv(jpr_rnf)%laction ) THEN 
+         pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_rnf)
+                           CALL iom_put( 'runoffs'      , frcv(:,:,jpr_rnf )              )   ! rivers
+         IF( lk_diaar5 )   CALL iom_put( 'hflx_rnf_cea' , frcv(:,:,jpr_rnf ) * zcptn(:,:) )   ! heat flux from rivers
+      ENDIF
+      IF( srcv(jpr_cal)%laction ) THEN 
+         pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_cal)
+         CALL iom_put( 'calving', frcv(:,:,jpr_cal) )
+      ENDIF
+      !
+!!gm :  this seems to be internal cooking, not sure to need that in a generic interface 
+!!gm                                       at least should be optional...
+!!       ! remove negative runoff                            ! sum over the global domain
+!!       zcumulpos = SUM( MAX( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) ) 
+!!       zcumulneg = SUM( MIN( frcv(:,:,jpr_rnf), 0.e0 ) * e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
+!!       IF( lk_mpp )   CALL mpp_sum( zcumulpos )
+!!       IF( lk_mpp )   CALL mpp_sum( zcumulneg ) 
+!!       IF( zcumulpos /= 0. ) THEN                          ! distribute negative runoff on positive runoff grid points
+!!          zcumulneg = 1.e0 + zcumulneg / zcumulpos
+!!          frcv(:,:,jpr_rnf) = MAX( frcv(:,:,jpr_rnf), 0.e0 ) * zcumulneg
+!!       ENDIF     
+!!       pemp_tot(:,:) = pemp_tot(:,:) - frcv(:,:,jpr_rnf)   ! add runoff to e-p 
+!!
+!!gm  end of internal cooking
+
+
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( cn_rcv_qns ) )                      !   non solar heat fluxes   !   (qns)
+      !                                                      ! ========================= !
+      CASE( 'conservative' )                                      ! the required fields are directly provided
+         pqns_tot(:,:  ) = frcv(:,:,jpr_qnsmix)
+         pqns_ice(:,:,1) = frcv(:,:,jpr_qnsice)
+      CASE( 'oce and ice' )       ! the total flux is computed from ocean and ice fluxes
+         pqns_tot(:,:  ) =  p_frld(:,:,1) * frcv(:,:,jpr_qnsoce) + zicefr(:,:,1) * frcv(:,:,jpr_qnsice)
+         pqns_ice(:,:,1) =  frcv(:,:,jpr_qnsice)
+      CASE( 'mixed oce-ice' )     ! the ice flux is cumputed from the total flux, the SST and ice informations
+         pqns_tot(:,:  ) = frcv(:,:,jpr_qnsmix)
+         pqns_ice(:,:,1) = frcv(:,:,jpr_qnsmix)    &
+            &            + frcv(:,:,jpr_dqnsdt) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:,1)   &
+            &                                                   +          pist(:,:,1)   * zicefr(:,:,1) ) )
+      END SELECT
+      !                                                           ! snow melting heat flux ....
+      !   energy for melting solid precipitation over ice-free ocean
+      zcoef = xlsn / rhosn
+      ztmp(:,:) = p_frld(:,:,1) * zsnow(:,:) * zcoef
+      pqns_tot(:,:) = pqns_tot(:,:) - ztmp(:,:)
+      IF( lk_diaar5 )   CALL iom_put( 'hflx_snow_cea', ztmp + zsnow(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average)
+!!gm
+!!    currently it is taken into account in leads budget but not in the qns_tot, and thus not in 
+!!    the flux that enter the ocean....
+!!    moreover 1 - it is not diagnose anywhere.... 
+!!             2 - it is unclear for me whether this heat lost is taken into account in the atmosphere or not...
+!!
+!! similar job should be done for snow and precipitation temperature
+      !                                                           ! Iceberg melting heat flux ....
+      !   energy for iceberg melting 
+      IF( srcv(jpr_cal)%laction ) THEN 
+         zcoef = xlic / rhoic
+         ztmp(:,:) = frcv(:,:,jpr_cal) * zcoef
+         pqns_tot(:,:) = pqns_tot(:,:) - ztmp(:,:)
+         IF( lk_diaar5 )   CALL iom_put( 'hflx_cal_cea', ztmp + frcv(:,:,jpr_cal) * zcptn(:,:) )   ! heat flux from calving
+      ENDIF
+
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( cn_rcv_qsr ) )                      !      solar heat fluxes    !   (qsr)
+      !                                                      ! ========================= !
+      CASE( 'conservative' )
+         pqsr_tot(:,:  ) = frcv(:,:,jpr_qsrmix)
+         pqsr_ice(:,:,1) = frcv(:,:,jpr_qsrice)
+      CASE( 'oce and ice' )
+         pqsr_tot(:,:  ) =  p_frld(:,:,1) * frcv(:,:,jpr_qsroce) + zicefr(:,:,1) * frcv(:,:,jpr_qsrice)
+         pqsr_ice(:,:,1) =  frcv(:,:,jpr_qsrice)
+      CASE( 'mixed oce-ice' )
+         pqsr_tot(:,:  ) = frcv(:,:,jpr_qsrmix)
+!       Create solar heat flux over ice using incoming solar heat flux and albedos
+!       ( see OASIS3 user guide, 5th edition, p39 )
+         pqsr_ice(:,:,1) = frcv(:,:,jpr_qsrmix) * ( 1.- palbi(:,:,1) )   &
+            &            / (  1.- ( albedo_oce_mix(:,:  ) * p_frld(:,:,1)   &
+            &                     + palbi         (:,:,1) * zicefr(:,:,1) ) )
+      END SELECT
+
+      SELECT CASE( TRIM( cn_rcv_dqnsdt ) )
+      CASE ('coupled')
+          pdqns_ice(:,:,1) = frcv(:,:,jpr_dqnsdt)
+      END SELECT
+
+   END SUBROUTINE sbc_cpl_ice_flx
+   
+   
+   SUBROUTINE sbc_cpl_snd( kt )
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_snd  ***
+      !!
+      !! ** Purpose :   provide the ocean-ice informations to the atmosphere
+      !!
+      !! ** Method  :   send to the atmosphere through a call to cpl_prism_snd
+      !!              all the needed fields (as defined in sbc_cpl_init)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt
+      !!
+      INTEGER ::   ji, jj          ! dummy loop indices
+      INTEGER ::   isec, info      ! temporary integer
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfr_l   ! 1. - fr_i(:,:)
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztmp1, ztmp2
+      REAL(wp), DIMENSION(jpi,jpj) ::   zotx1 , zoty1 , zotz1, zitx1, zity1, zitz1
+      !!----------------------------------------------------------------------
+
+      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
+
+      zfr_l(:,:) = 1.- fr_i(:,:)
+
+      !                                                      ! ------------------------- !
+      !                                                      !    Surface temperature    !   in Kelvin
+      !                                                      ! ------------------------- !
+      SELECT CASE( cn_snd_temperature)
+      CASE( 'oce only'             )   ;   ztmp1(:,:) =   tn(:,:,1) + rt0
+      CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( tn(:,:,1) + rt0 ) * zfr_l(:,:)   
+                                           ztmp2(:,:) =   tn_ice(:,:,1)     *  fr_i(:,:)
+      CASE( 'mixed oce-ice'        )   ;   ztmp1(:,:) = ( tn(:,:,1) + rt0 ) * zfr_l(:,:) + tn_ice(:,:,1) * fr_i(:,:)
+      CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of cn_snd_temperature' )
+      END SELECT
+      IF( ssnd(jps_toce)%laction )   CALL cpl_prism_snd( jps_toce, isec, ztmp1, info )
+      IF( ssnd(jps_tice)%laction )   CALL cpl_prism_snd( jps_tice, isec, ztmp2, info )
+      IF( ssnd(jps_tmix)%laction )   CALL cpl_prism_snd( jps_tmix, isec, ztmp1, info )
+      !
+      !                                                      ! ------------------------- !
+      !                                                      !           Albedo          !
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_albice)%laction ) THEN                         ! ice 
+         ztmp1(:,:) = alb_ice(:,:,1) * fr_i(:,:)
+         CALL cpl_prism_snd( jps_albice, isec, ztmp1, info )
+      ENDIF
+      IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean
+         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:) + alb_ice(:,:,1) * fr_i(:,:)
+         CALL cpl_prism_snd( jps_albmix, isec, ztmp1, info )
+      ENDIF
+      !                                                      ! ------------------------- !
+      !                                                      !  Ice fraction & Thickness ! 
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_fice)%laction )   CALL cpl_prism_snd( jps_fice, isec, fr_i                  , info )
+      IF( ssnd(jps_hice)%laction )   CALL cpl_prism_snd( jps_hice, isec, hicif(:,:) * fr_i(:,:), info )
+      IF( ssnd(jps_hsnw)%laction )   CALL cpl_prism_snd( jps_hsnw, isec, hsnif(:,:) * fr_i(:,:), info )
+      !
+#if defined key_cpl_carbon_cycle
+      !                                                      ! ------------------------- !
+      !                                                      !  CO2 flux from PISCES     ! 
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_co2)%laction )   CALL cpl_prism_snd( jps_co2, isec, oce_co2 , info )
+      !
+#endif
+      IF( ssnd(jps_ocx1)%laction ) THEN                      !      Surface current      !
+         !                                                   ! ------------------------- !
+         !    
+         !                                                  j+1   j     -----V---F
+         ! surface velocity always sent from T point                     !       |
+         !                                                        j      |   T   U
+         !                                                               |       |
+         !                                                   j    j-1   -I-------|
+         !                                               (for I)         |       |
+         !                                                              i-1  i   i
+         !                                                               i      i+1 (for I)
+         SELECT CASE( TRIM( cn_snd_crt(1) ) )
+         CASE( 'oce only'             )      ! C-grid ==> T
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) )
+                  zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) ) 
+               END DO
+            END DO
+         CASE( 'weighted oce and ice' )   
+            SELECT CASE ( cigr_type )
+            CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                     zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)
+                     zitx1(ji,jj) = 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
+                     zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
+               DO jj = 2, jpjm1
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)  
+                     zitx1(ji,jj) = 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
+                        &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     zity1(ji,jj) = 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
+                        &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
+               DO jj = 2, jpjm1
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)  
+                     zitx1(ji,jj) = 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
+                        &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     zity1(ji,jj) = 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
+                        &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            END SELECT
+            CALL lbc_lnk( zitx1, 'T', -1. )   ;   CALL lbc_lnk( zity1, 'T', -1. )
+         CASE( 'mixed oce-ice'        )
+            SELECT CASE ( cigr_type )
+            CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)   &
+                        &         + 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
+                     zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)   &
+                        &         + 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
+               DO jj = 2, jpjm1
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
+                        &         + 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
+                        &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
+                        &         + 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
+                        &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
+               DO jj = 2, jpjm1
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
+                        &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
+                        &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
+                        &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
+                        &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                  END DO
+               END DO
+            END SELECT
+         END SELECT
+         CALL lbc_lnk( zotx1, 'T', -1. )   ;   CALL lbc_lnk( zoty1, 'T', -1. )
+         !
+         !
+         IF( TRIM( cn_snd_crt(3) ) == 'eastward-northward' ) THEN             ! Rotation of the components
+            !                                                                     ! Ocean component
+            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component 
+            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component 
+            zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components 
+            zoty1(:,:) = ztmp2(:,:)
+            IF( ssnd(jps_ivx1)%laction ) THEN                                     ! Ice component
+               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component 
+               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component 
+               zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components 
+               zity1(:,:) = ztmp2(:,:)
+            ENDIF
+         ENDIF
+         !
+         ! spherical coordinates to cartesian -> 2 components to 3 components
+         IF( TRIM( cn_snd_crt(2) ) == 'cartesian' ) THEN
+            ztmp1(:,:) = zotx1(:,:)                     ! ocean currents
+            ztmp2(:,:) = zoty1(:,:)
+            CALL oce2geo ( ztmp1, ztmp2, 'T', zotx1, zoty1, zotz1 )
+            !
+            IF( ssnd(jps_ivx1)%laction ) THEN           ! ice velocities
+               ztmp1(:,:) = zitx1(:,:)
+               ztmp1(:,:) = zity1(:,:)
+               CALL oce2geo ( ztmp1, ztmp2, 'T', zitx1, zity1, zitz1 )
+            ENDIF
+         ENDIF
+         !
+         IF( ssnd(jps_ocx1)%laction )   CALL cpl_prism_snd( jps_ocx1, isec, zotx1, info )   ! ocean x current 1st grid
+         IF( ssnd(jps_ocy1)%laction )   CALL cpl_prism_snd( jps_ocy1, isec, zoty1, info )   ! ocean y current 1st grid
+         IF( ssnd(jps_ocz1)%laction )   CALL cpl_prism_snd( jps_ocz1, isec, zotz1, info )   ! ocean z current 1st grid
+         !
+         IF( ssnd(jps_ivx1)%laction )   CALL cpl_prism_snd( jps_ivx1, isec, zitx1, info )   ! ice   x current 1st grid
+         IF( ssnd(jps_ivy1)%laction )   CALL cpl_prism_snd( jps_ivy1, isec, zity1, info )   ! ice   y current 1st grid
+         IF( ssnd(jps_ivz1)%laction )   CALL cpl_prism_snd( jps_ivz1, isec, zitz1, info )   ! ice   z current 1st grid
+         ! 
+      ENDIF
+   !
+   END SUBROUTINE sbc_cpl_snd
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                            NO coupling
+   !!----------------------------------------------------------------------
+   USE par_kind        ! kind definition
+CONTAINS
+   SUBROUTINE sbc_cpl_snd( kt )
+      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', kt
+   END SUBROUTINE sbc_cpl_snd
+   !
+   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
+      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', kt, k_fsbc, k_ice
+   END SUBROUTINE sbc_cpl_rcv
+   !
+   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
+      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
+      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
+      p_taui(:,:) = 0.   ;   p_tauj(:,:) = 0. ! stupid definition to avoid warning message when compiling...
+      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?'
+   END SUBROUTINE sbc_cpl_ice_tau
+   !
+   SUBROUTINE sbc_cpl_ice_flx( p_frld  ,                                  &
+      &                        pqns_tot, pqns_ice, pqsr_tot , pqsr_ice,   &
+      &                        pemp_tot, pemp_ice, pdqns_ice, psprecip,   &
+      &                        palbi   , psst    , pist                )
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   p_frld     ! lead fraction                [0 to 1]
+      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pqns_tot   ! total non solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqns_ice   ! ice   non solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pqsr_tot   ! total     solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqsr_ice   ! ice       solar heat flux    [W/m2]
+      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pemp_tot   ! total     freshwater budget  [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   pemp_ice   ! ice solid freshwater budget  [Kg/m2/s]
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pdqns_ice  ! d(Q non solar)/d(Temperature) over ice
+      REAL(wp), INTENT(  out), DIMENSION(:,:  ) ::   psprecip   ! solid precipitation          [Kg/m2/s]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   palbi   ! ice albedo
+      REAL(wp), INTENT(in   ), DIMENSION(:,:  ), OPTIONAL ::   psst    ! sea surface temperature      [Celcius]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   pist    ! ice surface temperature      [Kelvin]
+      WRITE(*,*) 'sbc_cpl_snd: You should not have seen this print! error?', p_frld(1,1,1), palbi(1,1,1), psst(1,1), pist(1,1,1) 
+      ! stupid definition to avoid warning message when compiling...
+      pqns_tot(:,:) = 0. ; pqns_ice(:,:,:) = 0. ; pdqns_ice(:,:,:) = 0.
+      pqsr_tot(:,:) = 0. ; pqsr_ice(:,:,:) = 0. 
+      pemp_tot(:,:) = 0. ; pemp_ice(:,:)   = 0. ; psprecip(:,:) = 0.
+   END SUBROUTINE sbc_cpl_ice_flx
+   
+#endif
+
+   !!======================================================================
+END MODULE sbccpl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcflx.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 1844)
@@ -0,0 +1,193 @@
+MODULE sbcflx
+   !!======================================================================
+   !!                       ***  MODULE  sbcflx  ***
+   !! Ocean forcing:  momentum, heat and freshwater flux formulation
+   !!=====================================================================
+   !! History :  9.0   !  06-06  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   namflx   : flux formulation namlist
+   !!   sbc_flx  : flux formulation as ocean surface boundary condition
+   !!              (forced mode, fluxes read in NetCDF files)
+   !!----------------------------------------------------------------------
+   !! question diverses
+   !!  *   ajouter un test sur la division entier de freqh et rdttra ???
+   !!  **  ajoute dans namelist: 1 year forcing files
+   !!                         or forcing file starts at the begining of the run
+   !!  *** we assume that the forcing file start and end with the previous
+   !!      year last record and the next year first record (useful for
+   !!      time interpolation, required even if no time interp???)
+   !!  *   ajouter un test sur la division de la frequence en pas de temps
+   !!  ==> daymod ajout de nsec_year = number of second since the begining of the year
+   !!      assumed to be 0 at 0h january the 1st (i.e. 24h december the 31)
+   !!
+   !!  *** regrouper dtatem et dtasal
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE phycst          ! physical constants
+   USE fldread         ! read input fields
+   USE iom             ! IOM library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sbc_flx       ! routine called by step.F90
+
+   INTEGER , PARAMETER ::   jpfld   = 5   ! maximum number of files to read 
+   INTEGER , PARAMETER ::   jp_utau = 1   ! index of wind stress (i-component) file
+   INTEGER , PARAMETER ::   jp_vtau = 2   ! index of wind stress (j-component) file
+   INTEGER , PARAMETER ::   jp_qtot = 3   ! index of total (non solar+solar) heat file
+   INTEGER , PARAMETER ::   jp_qsr  = 4   ! index of solar heat file
+   INTEGER , PARAMETER ::   jp_emp  = 5   ! index of evaporation-precipation file
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf    ! structure of input fields (file informations, fields read)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_flx( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_flx  ***
+      !!                   
+      !! ** Purpose :   provide at each time step the surface ocean fluxes
+      !!                (momentum, heat, freshwater and runoff) 
+      !!
+      !! ** Method  : - READ each fluxes in NetCDF files:
+      !!                   i-component of the stress              utau  (N/m2)
+      !!                   j-component of the stress              vtau  (N/m2)
+      !!                   net downward heat flux                 qtot  (watt/m2)
+      !!                   net downward radiative flux            qsr   (watt/m2)
+      !!                   net upward freshwater (evapo - precip) emp   (kg/m2/s)
+      !!
+      !!      CAUTION :  - never mask the surface stress fields
+      !!                 - the stress is assumed to be in the mesh referential
+      !!                   i.e. the (i,j) referential
+      !!
+      !! ** Action  :   update at each time-step
+      !!              - utau, vtau  i- and j-component of the wind stress
+      !!              - taum        wind stress module at T-point
+      !!              - wndm        10m wind module at T-point
+      !!              - qns, qsr    non-slor and solar heat flux
+      !!              - emp, emps   evaporation minus precipitation
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!
+      INTEGER  ::   ji, jj, jf            ! dummy indices
+      INTEGER  ::   ierror                ! return error code
+      REAL(wp) ::   zfact                 ! temporary scalar
+      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
+      REAL(wp) ::   ztx, zty, zmod, zcoef ! temporary variables
+      !!
+      CHARACTER(len=100) ::  cn_dir                               ! Root directory for location of flx files
+      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                    ! array of namelist information structures
+      TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp  ! informations about the fields to be read
+      NAMELIST/namsbc_flx/ cn_dir, sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp
+      !!---------------------------------------------------------------------
+      !                                         ! ====================== !
+      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
+         !                                      ! ====================== !
+         ! set file information
+         cn_dir = './'        ! directory in which the model is executed
+         ! ... default values (NB: frequency positive => hours, negative => months)
+         !              !   file    ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
+         !              !   name    !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
+         sn_utau = FLD_N(   'utau'  ,    24     ,  'utau'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_vtau = FLD_N(   'vtau'  ,    24     ,  'vtau'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_qtot = FLD_N(   'qtot'  ,    24     ,  'qtot'    ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_qsr  = FLD_N(   'qsr'   ,    24     ,  'qsr'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_emp  = FLD_N(   'emp'   ,    24     ,  'emp'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+
+         REWIND ( numnam )               ! ... read in namlist namflx
+         READ   ( numnam, namsbc_flx ) 
+
+         ! store namelist information in an array
+         slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau
+         slf_i(jp_qtot) = sn_qtot   ;   slf_i(jp_qsr ) = sn_qsr 
+         slf_i(jp_emp ) = sn_emp
+
+         ! set sf structure
+         ALLOCATE( sf(jpfld), STAT=ierror )
+         IF( ierror > 0 ) THEN   
+            CALL ctl_stop( 'sbc_flx: unable to allocate sf structure' )   ;   RETURN  
+         ENDIF
+         DO ji= 1, jpfld
+            ALLOCATE( sf(ji)%fnow(jpi,jpj) )
+            ALLOCATE( sf(ji)%fdta(jpi,jpj,2) )
+         END DO
+
+
+         ! fill sf with slf_i and control print
+         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_flx', 'flux formulation for ocean surface boundary condition', 'namsbc_flx' )
+         !
+      ENDIF
+
+      CALL fld_read( kt, nn_fsbc, sf )           ! Read input fields and provides the
+      !                                          ! input fields at the current time-step
+
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+         !
+         ! set the ocean fluxes from read fields
+!CDIR COLLAPSE
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               utau(ji,jj) = sf(jp_utau)%fnow(ji,jj)
+               vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj)
+               qns (ji,jj) = sf(jp_qtot)%fnow(ji,jj) - sf(jp_qsr)%fnow(ji,jj)
+               qsr (ji,jj) = sf(jp_qsr )%fnow(ji,jj)
+               emp (ji,jj) = sf(jp_emp )%fnow(ji,jj)
+            END DO
+         END DO
+         
+         ! module of wind stress and wind speed at T-point
+         zcoef = 1. / ( zrhoa * zcdrag ) 
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vect. opt.
+               ztx = utau(ji-1,jj  ) + utau(ji,jj) 
+               zty = vtau(ji  ,jj-1) + vtau(ji,jj) 
+               zmod = 0.5 * SQRT( ztx * ztx + zty * zty )
+               taum(ji,jj) = zmod
+               wndm(ji,jj) = SQRT( zmod * zcoef )
+            END DO
+         END DO
+         CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
+
+         ! Initialization of emps (when no ice model)
+         emps(:,:) = emp (:,:) 
+                  
+         ! control print (if less than 100 time-step asked)
+         IF( nitend-nit000 <= 100 .AND. lwp ) THEN
+            WRITE(numout,*) 
+            WRITE(numout,*) '        read daily momentum, heat and freshwater fluxes OK'
+            DO jf = 1, jpfld
+               IF( jf == jp_utau .OR. jf == jp_vtau )   zfact =     1.
+               IF( jf == jp_qtot .OR. jf == jp_qsr  )   zfact =     0.1
+               IF( jf == jp_emp                     )   zfact = 86400.
+               WRITE(numout,*) 
+               WRITE(numout,*) ' day: ', ndastp , TRIM(sf(jf)%clvar), ' * ', zfact
+               CALL prihre( sf(jf)%fnow, jpi, jpj, 1, jpi, 20, 1, jpj, 10, zfact, numout )
+            END DO
+            CALL FLUSH(numout)
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_flx
+
+   !!======================================================================
+END MODULE sbcflx
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcfwb.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcfwb.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcfwb.F90	(revision 1844)
@@ -0,0 +1,224 @@
+MODULE sbcfwb
+   !!======================================================================
+   !!                       ***  MODULE  sbcfwb  ***
+   !! Ocean fluxes   : domain averaged freshwater budget
+   !!======================================================================
+   !! History :  8.2  !  01-02  (E. Durand)  Original code
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!            9.0  !  06-08  (G. Madec)  Surface module
+   !!            9.2  !  09-07  (C. Talandier) emp mean s spread over erp area 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_fwb      : freshwater budget for global ocean configurations
+   !!                  in free surface and forced mode
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface ocean boundary condition
+   USE phycst          ! physical constants
+   USE sbcrnf          ! ocean runoffs
+   USE sbcssr          ! SS damping terms
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_fwb      ! routine called by step
+
+   REAL(wp) ::   a_fwb_b            ! annual domain averaged freshwater budget
+   REAL(wp) ::   a_fwb              ! for 2 year before (_b) and before year.
+   REAL(wp) ::   empold             ! empold to be suppressed
+   REAL(wp) ::   area               ! global mean ocean surface (interior domain)
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   e1e2_i    ! area of the interior domain (e1t*e2t*tmask_i)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE sbc_fwb( kt, kn_fwb, kn_fsbc )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_fwb  ***
+      !!
+      !! ** Purpose :   Control the mean sea surface drift
+      !!
+      !! ** Method  :   several ways  depending on kn_fwb
+      !!                =0 no control 
+      !!                =1 global mean of emp set to zero at each nn_fsbc time step
+      !!                =2 annual global mean corrected from previous year
+      !!                =3 global mean of emp set to zero at each nn_fsbc time step
+      !!                   & spread out over erp area depending its sign
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT( in ) ::   kn_fsbc  ! 
+      INTEGER, INTENT( in ) ::   kn_fwb   ! ocean time-step index
+      !!
+      INTEGER  ::   inum                  ! temporary logical unit
+      INTEGER  ::   ikty, iyear           ! 
+      REAL(wp) ::   z_emp, z_emp_nsrf, zsum_emp, zsum_erp       ! temporary scalars
+      REAL(wp) ::   zsurf_neg, zsurf_pos, zsurf_tospread
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztmsk_neg, ztmsk_pos, ztmsk_tospread
+      REAL(wp), DIMENSION(jpi,jpj) ::   z_wgt, zerp_cor
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'sbc_fwb : FreshWater Budget correction'
+            WRITE(numout,*) '~~~~~~~'
+            IF( kn_fwb == 1 )   WRITE(numout,*) '          instantaneously set to zero'
+            IF( kn_fwb == 2 )   WRITE(numout,*) '          adjusted from previous year budget'
+            IF( kn_fwb == 3 )   WRITE(numout,*) '          emp set to zero and spread out over erp area'
+            !
+            IF( kn_fwb == 3 .AND. nn_sssr /= 2 )   &
+               &   CALL ctl_stop( 'The option nn_fwb = 3 must be associated to nn_sssr = 2 ' )
+            
+         ENDIF
+         !
+         e1e2_i(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)
+         area = SUM( e1e2_i(:,:) )
+         IF( lk_mpp )   CALL  mpp_sum( area    )   ! sum over the global domain
+         !
+      ENDIF
+      
+
+      SELECT CASE ( kn_fwb )
+      !
+      CASE ( 0 )                               
+         WRITE(ctmp1,*)'sbc_fwb : nn_fwb = ', kn_fwb, ' is not yet associated to an option, choose either 1/2'
+         CALL ctl_stop( ctmp1 )
+         !
+         
+      !
+      CASE ( 1 )                               ! global mean emp set to zero
+         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
+            z_emp = SUM( e1e2_i(:,:) * emp(:,:) ) / area
+            IF( lk_mpp )   CALL  mpp_sum( z_emp    )   ! sum over the global domain
+            emp (:,:) = emp (:,:) - z_emp
+            emps(:,:) = emps(:,:) - z_emp
+         ENDIF
+         !
+      CASE ( 2 )                               ! emp budget adjusted from the previous year
+         ! initialisation
+         IF( kt == nit000 ) THEN
+            ! Read the corrective factor on precipitations (empold)
+            CALL ctl_opn( inum, 'EMPave_old.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+            READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb
+            CLOSE( inum )
+            empold = a_fwb                  ! current year freshwater budget correction
+            !                               ! estimate from the previous year budget
+            IF(lwp)WRITE(numout,*)
+            IF(lwp)WRITE(numout,*)'sbc_fwb : year = ',iyear  , ' freshwater budget correction = ', empold
+            IF(lwp)WRITE(numout,*)'          year = ',iyear-1, ' freshwater budget read       = ', a_fwb
+            IF(lwp)WRITE(numout,*)'          year = ',iyear-2, ' freshwater budget read       = ', a_fwb_b
+         ENDIF   
+         ! 
+         ! Update empold if new year start
+         ikty = 365 * 86400 / rdttra(1)    !!bug  use of 365 days leap year or 360d year !!!!!!!
+         IF( MOD( kt, ikty ) == 0 ) THEN
+            a_fwb_b = a_fwb
+            a_fwb   = SUM( e1e2_i(:,:) * sshn(:,:) )
+            IF( lk_mpp )   CALL  mpp_sum( a_fwb    )   ! sum over the global domain
+            a_fwb   = a_fwb * 1.e+3 / ( area * 86400. * 365. )     ! convert in Kg/m3/s = mm/s
+!!gm        !                                                      !!bug 365d year 
+            empold =  a_fwb                 ! current year freshwater budget correction
+            !                               ! estimate from the previous year budget
+         ENDIF
+         ! 
+         ! correct the freshwater fluxes
+         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
+            emp (:,:) = emp (:,:) + empold
+            emps(:,:) = emps(:,:) + empold
+         ENDIF
+         !
+         ! save empold value in a file
+         IF( kt == nitend .AND. lwp ) THEN
+            CALL ctl_opn( inum, 'EMPave.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
+            WRITE( inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb
+            CLOSE( inum )
+         ENDIF
+         !
+      CASE ( 3 )                               ! global emp set to zero and spread out over erp area
+         !
+         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
+            ! Select <0 and >0 area of erp
+            ztmsk_pos(:,:) = tmask_i(:,:)
+            WHERE( erp < 0.e0 ) ztmsk_pos = 0.e0
+            ztmsk_neg(:,:) = tmask_i(:,:) - ztmsk_pos(:,:)
+
+            ! Area filled by <0 and >0 erp 
+            zsurf_neg = SUM( e1e2_i(:,:)*ztmsk_neg(:,:) )
+            zsurf_pos = SUM( e1e2_i(:,:)*ztmsk_pos(:,:) )
+        
+            ! emp global mean 
+            z_emp = SUM( e1e2_i(:,:) * emp(:,:) ) / area
+            !
+            IF( lk_mpp )   CALL  mpp_sum( z_emp )
+            IF( lk_mpp )   CALL  mpp_sum( zsurf_neg )
+            IF( lk_mpp )   CALL  mpp_sum( zsurf_pos )
+            
+            IF( z_emp < 0.e0 ) THEN
+                ! to spread out over >0 erp area to increase evaporation damping process
+                zsurf_tospread = zsurf_pos
+                ztmsk_tospread(:,:) = ztmsk_pos(:,:)
+            ELSE
+                ! to spread out over <0 erp area to increase precipitation damping process
+                zsurf_tospread = zsurf_neg
+                ztmsk_tospread(:,:) = ztmsk_neg(:,:)
+            ENDIF
+
+            ! emp global mean over <0 or >0 erp area
+            zsum_emp = SUM( e1e2_i(:,:) * z_emp )
+            IF( lk_mpp )   CALL  mpp_sum( zsum_emp )
+            z_emp_nsrf =  zsum_emp / ( zsurf_tospread + rsmall )
+            ! weight to respect erp field 2D structure 
+            zsum_erp = SUM( ztmsk_tospread(:,:) * erp(:,:) * e1e2_i(:,:) )
+            IF( lk_mpp )   CALL  mpp_sum( zsum_erp )
+            z_wgt(:,:) = ztmsk_tospread(:,:) * erp(:,:) / ( zsum_erp + rsmall )
+
+            ! final correction term to apply
+            zerp_cor(:,:) = -1. * z_emp_nsrf * zsurf_tospread * z_wgt(:,:)
+
+            CALL lbc_lnk( zerp_cor, 'T', 1. )
+
+            emp (:,:) = emp (:,:) + zerp_cor(:,:)
+            emps(:,:) = emps(:,:) + zerp_cor(:,:)
+            erp (:,:) = erp (:,:) + zerp_cor(:,:)
+            
+            IF( nprint == 1 .AND. lwp ) THEN
+               IF( z_emp < 0.e0 ) THEN
+                  WRITE(numout,*)'       z_emp < 0'
+                  WRITE(numout,*)'       SUM(erp+)        = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2_i(:,:) )*1.e-3,' m3.s-1'
+               ELSE
+                   WRITE(numout,*)'      z_emp >= 0'
+                   WRITE(numout,*)'      SUM(erp-)        = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2_i(:,:) )*1.e-3,' m3.s-1'
+               ENDIF
+               WRITE(numout,*)'      SUM(empG)        = ', SUM( z_emp*e1e2_i(:,:) )*1.e-3,' m3.s-1'
+               WRITE(numout,*)'      z_emp            = ', z_emp      ,' mm.s-1'
+               WRITE(numout,*)'      z_emp_nsrf       = ', z_emp_nsrf ,' mm.s-1'
+               WRITE(numout,*)'      MIN(zerp_cor)    = ', MINVAL(zerp_cor) 
+               WRITE(numout,*)'      MAX(zerp_cor)    = ', MAXVAL(zerp_cor) 
+            ENDIF
+            !
+         ENDIF
+         !
+      CASE DEFAULT    ! you should never be there
+         WRITE(ctmp1,*)'sbc_fwb : nn_fwb = ', kn_fwb, ' is not permitted for the FreshWater Budget correction, choose either 1/2'
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+   END SUBROUTINE sbc_fwb
+
+   !!======================================================================
+END MODULE sbcfwb
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_if.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_if.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_if.F90	(revision 1844)
@@ -0,0 +1,144 @@
+MODULE sbcice_if
+   !!======================================================================
+   !!                       ***  MODULE  sbcice  ***
+   !! Surface module :  update surface ocean boundary condition over ice
+   !!                   covered area using ice-if model
+   !!======================================================================
+   !! History :  3.0   !  2006-06  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_ice_if     : update sbc in ice-covered area
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE eosbn2          ! equation of state
+   USE sbc_oce         ! surface boundary condition: ocean fields
+   USE fldread         ! read input field
+   USE iom             ! I/O manager library
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_ice_if      ! routine called in sbcmod
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_ice   ! structure of input ice-cover (file informations, fields read)
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ice_if( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_ice_if  ***
+      !!
+      !! ** Purpose :   handle surface boundary condition over ice cover area
+      !!      when sea-ice model are not used
+      !!
+      !! ** Method  : - read sea-ice cover climatology
+      !!              - blah blah blah, ...
+      !!
+      !! ** Action  :   utau, vtau : remain unchanged
+      !!                taum, wndm : remain unchanged
+      !!                qns, qsr   : update heat flux below sea-ice
+      !!                emp, emps  : update freshwater flux below sea-ice
+      !!                fr_i       : update the ice fraction
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in)          ::   kt         ! ocean time step
+      !
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      INTEGER  ::   ierror     ! return error code
+      REAL(wp) ::   ztrp, zsice, zt_fzp, zfr_obs
+      REAL(wp) ::   zqri, zqrj, zqrp, zqi
+      !!
+      CHARACTER(len=100) ::   cn_dir              ! Root directory for location of ice-if files
+      TYPE(FLD_N)        ::   sn_ice              ! informations about the fields to be read
+      NAMELIST/namsbc_iif/ cn_dir, sn_ice
+      !!---------------------------------------------------------------------
+      !                                         ! ====================== !
+      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
+         !                                      ! ====================== !
+         ! set file information
+         cn_dir = './'        ! directory in which the model is executed
+         ! ... default values (NB: frequency positive => hours, negative => months)
+         !             !   file    ! frequency !  variable  ! time intep !  clim  ! 'yearly' or ! weights  ! rotation   !
+         !             !   name    !  (hours)  !   name     !   (T/F)    !  (T/F) !  'monthly'  ! filename ! pairs      ! 
+         sn_ice = FLD_N('ice_cover',    -1    ,  'ice_cov' ,  .true.    , .true. ,   'yearly'  , ''       , ''         )
+
+         REWIND ( numnam )               ! ... read in namlist namiif
+         READ   ( numnam, namsbc_iif )
+
+         ALLOCATE( sf_ice(1), STAT=ierror )
+         IF( ierror > 0 ) THEN
+            CALL ctl_stop( 'sbc_ice_if: unable to allocate sf_ice structure' )   ;   RETURN
+         ENDIF
+         ALLOCATE( sf_ice(1)%fnow(jpi,jpj) )
+         ALLOCATE( sf_ice(1)%fdta(jpi,jpj,2) )
+
+
+         ! fill sf_ice with sn_ice and control print
+         CALL fld_fill( sf_ice, (/ sn_ice /), cn_dir, 'sbc_ice_if', 'ice-if sea-ice model', 'namsbc_iif' )
+         !
+      ENDIF
+
+      CALL fld_read( kt, nn_fsbc, sf_ice )           ! Read input fields and provides the
+      !                                              ! input fields at the current time-step
+      
+      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN
+         !
+         ztrp = -40.             ! restoring terme for temperature (w/m2/k)
+         zsice = - 0.04 / 0.8    ! ratio of isohaline compressibility over isotherme compressibility
+                                 ! ( d rho / dt ) / ( d rho / ds )      ( s = 34, t = -1.8 )
+         
+         fr_i(:,:) = tfreez( sss_m ) * tmask(:,:,1)      ! sea surface freezing temperature [Celcius]
+
+         ! Flux and ice fraction computation
+!CDIR COLLAPSE
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !
+               zt_fzp  = fr_i(ji,jj)                        ! freezing point temperature
+               zfr_obs = sf_ice(1)%fnow(ji,jj)              ! observed ice cover
+               !                                            ! ocean ice fraction (0/1) from the freezing point temperature
+               IF( sst_m(ji,jj) <= zt_fzp ) THEN   ;   fr_i(ji,jj) = 1.e0
+               ELSE                                ;   fr_i(ji,jj) = 0.e0
+               ENDIF
+
+               tn(ji,jj,1) = MAX( tn(ji,jj,1), zt_fzp )     ! avoid over-freezing point temperature
+
+               qsr(ji,jj) = ( 1. - zfr_obs ) * qsr(ji,jj)   ! solar heat flux : zero below observed ice cover
+
+               !                                            ! non solar heat flux : add a damping term 
+               !      # ztrp*(t-(tgel-1.))  if observed ice and no opa ice   (zfr_obs=1 fr_i=0)
+               !      # ztrp*min(0,t-tgel)  if observed ice and opa ice      (zfr_obs=1 fr_i=1)
+               zqri = ztrp * ( tb(ji,jj,1) - ( zt_fzp - 1.) )
+               zqrj = ztrp * MIN( 0., tb(ji,jj,1) - zt_fzp )
+               zqrp = ( zfr_obs * ( (1. - fr_i(ji,jj) ) * zqri    &
+                 &                 +      fr_i(ji,jj)   * zqrj ) ) * tmask(ji,jj,1)
+
+               !                                            ! non-solar heat flux 
+               !      # qns unchanged              if no climatological ice              (zfr_obs=0)
+               !      # qns = zqrp                 if climatological ice and no opa ice  (zfr_obs=1, fr_i=0)
+               !      # qns = zqrp -2(-4) watt/m2  if climatological ice and opa ice     (zfr_obs=1, fr_i=1)
+               !                                   (-2=arctic, -4=antarctic)   
+               zqi = -3. + SIGN( 1.e0, ff(ji,jj) )
+               qns(ji,jj) = ( ( 1.- zfr_obs ) * qns(ji,jj)                             &
+                  &          +      zfr_obs   * fr_i(ji,jj) * zqi ) * tmask(ji,jj,1)   &
+                  &       + zqrp
+            END DO
+         END DO
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_ice_if
+
+   !!======================================================================
+END MODULE sbcice_if
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 1844)
@@ -0,0 +1,672 @@
+MODULE sbcice_lim
+   !!======================================================================
+   !!                       ***  MODULE  sbcice_lim  ***
+   !! Surface module :  update the ocean surface boundary condition over ice
+   !!       &           covered area using LIM sea-ice model
+   !! Sea-Ice model  :  LIM 3.0 Sea ice model time-stepping
+   !!======================================================================
+   !! History :  2.0   !  2006-12  (M. Vancoppenolle) Original code
+   !!            3.0   !  2008-02  (C. Talandier)  Surface module from icestp.F90
+   !!            9.0   !  2008-04  (G. Madec)  sltyle and lim_ctl routine
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                  LIM 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   sbc_ice_lim  : sea-ice model time-stepping and update ocean sbc over ice-covered area
+   !!   lim_ctl       : alerts in case of ice model crash
+   !!   lim_prt_state : ice control print at a given grid point
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE c1d             ! 1d configuration
+   USE dom_oce         ! ocean space and time domain
+   USE lib_mpp
+   USE par_ice         ! sea-ice parameters
+   USE ice
+   USE iceini
+   USE dom_ice
+
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice   fields
+   USE sbcblk_core     ! Surface boundary condition: CORE bulk
+   USE sbcblk_clio     ! Surface boundary condition: CLIO bulk
+   USE albedo
+
+   USE phycst          ! Define parameters for the routines
+   USE eosbn2          ! equation of state
+   USE limdyn          ! Ice dynamics
+   USE limtrp          ! Ice transport
+   USE limthd          ! Ice thermodynamics
+   USE limitd_th       ! Thermodynamics on ice thickness distribution 
+   USE limitd_me       ! Mechanics on ice thickness distribution
+   USE limsbc          ! sea surface boundary condition
+   USE limdia          ! Ice diagnostics
+   USE limwri          ! Ice outputs
+   USE limrst          ! Ice restarts
+   USE limupdate       ! update of global variables
+   USE limvar          ! Ice variables switch
+
+   USE lbclnk
+   USE iom             ! I/O manager library
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sbc_ice_lim  ! routine called by sbcmod.F90
+   
+   CHARACTER(len=1) ::   cl_grid = 'C'     ! type of grid used in ice dynamics
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM 3.0 , UCL-LOCEAN-IPSL  (2008)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ice_lim( kt, kblk, kico )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_ice_lim  ***
+      !!                   
+      !! ** Purpose :   update the ocean surface boundary condition via the 
+      !!                Louvain la Neuve Sea Ice Model time stepping 
+      !!
+      !! ** Method  :   ice model time stepping
+      !!              - call the ice dynamics routine 
+      !!              - call the ice advection/diffusion routine 
+      !!              - call the ice thermodynamics routine 
+      !!              - call the routine that computes mass and 
+      !!                heat fluxes at the ice/ocean interface
+      !!              - save the outputs 
+      !!              - save the outputs for restart when necessary
+      !!
+      !! ** Action  : - time evolution of the LIM sea-ice model
+      !!              - update all sbc variables below sea-ice:
+      !!                utau, vtau, taum, wndm, qns , qsr, emp , emps
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt      ! ocean time step
+      INTEGER, INTENT(in) ::   kblk    ! type of bulk (=3 CLIO, =4 CORE)
+      INTEGER, INTENT(in) ::   kico    ! ice-ocean stress treatment
+      !!
+      INTEGER  ::   jl                 ! loop index
+      REAL(wp) ::   zcoef              ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   alb_ice_os   ! albedo of the ice under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   alb_ice_cs   ! albedo of ice under clear sky
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'sbc_ice_lim : update ocean surface boudary condition' 
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   via Louvain la Neuve Ice Model (LIM-3) time stepping'
+         !
+         CALL ice_init
+         !
+         IF( ln_nicep ) THEN      ! control print at a given point
+            jiindx = 44   ;   jjindx = 140
+            WRITE(numout,*) ' The debugging point is : jiindx : ',jiindx, ' jjindx : ',jjindx
+         ENDIF
+      ENDIF
+
+      !                                        !----------------------!
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only  !
+         !                                     !----------------------!
+         !                                           !  Bulk Formulea !
+         !                                           !----------------!
+         !
+         u_oce(:,:) = ssu_m(:,:)                     ! mean surface ocean current at ice velocity point
+         v_oce(:,:) = ssv_m(:,:)                     ! (C-grid dynamics :  U- & V-points as the ocean)
+         !
+         t_bo(:,:) = tfreez( sss_m ) +  rt0          ! masked sea surface freezing temperature [Kelvin]
+         !                                           ! (set to rt0 over land)
+         CALL albedo_ice( t_su, ht_i, ht_s, alb_ice_cs, alb_ice_os )  ! ... ice albedo
+
+         DO jl = 1, jpl
+            t_su(:,:,jl) = t_su(:,:,jl) +  rt0 * ( 1. - tmask(:,:,1) )
+         END DO
+                                                     ! Bulk formulea - provides the following fields:
+         ! utau_ice, vtau_ice : surface ice stress                     (U- & V-points)   [N/m2]
+         ! qsr_ice , qns_ice  : solar & non solar heat flux over ice   (T-point)         [W/m2]
+         ! qla_ice            : latent heat flux over ice              (T-point)         [W/m2]
+         ! dqns_ice, dqla_ice : non solar & latent heat sensistivity   (T-point)         [W/m2]
+         ! tprecip , sprecip  : total & solid precipitation            (T-point)         [Kg/m2/s]
+         ! fr1_i0  , fr2_i0   : 1sr & 2nd fraction of qsr penetration in ice             [%]
+         !
+         SELECT CASE( kblk )
+         CASE( 3 )                                       ! CLIO bulk formulation
+            CALL blk_ice_clio( t_su , alb_ice_cs, alb_ice_os,                           &
+               &                      utau_ice  , vtau_ice  , qns_ice   , qsr_ice   ,   &
+               &                      qla_ice   , dqns_ice  , dqla_ice  ,               &
+               &                      tprecip   , sprecip   ,                           &
+               &                      fr1_i0    , fr2_i0    , cl_grid, jpl  )
+            !         
+         CASE( 4 )                                       ! CORE bulk formulation
+            CALL blk_ice_core( t_su , u_ice     , v_ice     , alb_ice_cs,               &
+               &                      utau_ice  , vtau_ice  , qns_ice   , qsr_ice   ,   &
+               &                      qla_ice   , dqns_ice  , dqla_ice  ,               &
+               &                      tprecip   , sprecip   ,                           &
+               &                      fr1_i0    , fr2_i0    , cl_grid, jpl  )
+         END SELECT
+
+         !                                           !----------------------!
+         !                                           ! LIM-3  time-stepping !
+         !                                           !----------------------!
+         ! 
+         numit = numit + nn_fsbc                     ! Ice model time step
+         !
+         !                                           ! Store previous ice values
+!!gm : remark   old_...   should becomes ...b  as tn versus tb  
+         old_a_i(:,:,:)   = a_i(:,:,:)     ! ice area
+         old_e_i(:,:,:,:) = e_i(:,:,:,:)   ! ice thermal energy
+         old_v_i(:,:,:)   = v_i(:,:,:)     ! ice volume
+         old_v_s(:,:,:)   = v_s(:,:,:)     ! snow volume 
+         old_e_s(:,:,:,:) = e_s(:,:,:,:)   ! snow thermal energy
+         old_smv_i(:,:,:) = smv_i(:,:,:)   ! salt content
+         old_oa_i(:,:,:)  = oa_i(:,:,:)    ! areal age content
+
+         !                                           ! intialisation to zero    !!gm is it truly necessary ???
+         d_a_i_thd(:,:,:)   = 0.e0 ; d_a_i_trp(:,:,:)   = 0.e0
+         d_v_i_thd(:,:,:)   = 0.e0 ; d_v_i_trp(:,:,:)   = 0.e0
+         d_e_i_thd(:,:,:,:) = 0.e0 ; d_e_i_trp(:,:,:,:) = 0.e0
+         d_v_s_thd(:,:,:)   = 0.e0 ; d_v_s_trp(:,:,:)   = 0.e0
+         d_e_s_thd(:,:,:,:) = 0.e0 ; d_e_s_trp(:,:,:,:) = 0.e0
+         d_smv_i_thd(:,:,:) = 0.e0 ; d_smv_i_trp(:,:,:) = 0.e0
+         d_oa_i_thd(:,:,:)  = 0.e0 ; d_oa_i_trp(:,:,:)  = 0.e0
+         !
+         fseqv(:,:)     = 0.e0
+         fsbri(:,:)     = 0.e0     ; fsalt_res(:,:) = 0.e0
+         fsalt_rpo(:,:) = 0.e0
+         fhmec(:,:)     = 0.e0     ; fhbri(:,:)     = 0.e0
+         fmmec(:,:)     = 0.e0     ; fheat_res(:,:) = 0.e0
+         fheat_rpo(:,:) = 0.e0     ; focea2D(:,:)   = 0.e0
+         fsup2D(:,:)    = 0.e0
+         ! 
+         diag_sni_gr(:,:) = 0.e0   ; diag_lat_gr(:,:) = 0.e0
+         diag_bot_gr(:,:) = 0.e0   ; diag_dyn_gr(:,:) = 0.e0
+         diag_bot_me(:,:) = 0.e0   ; diag_sur_me(:,:) = 0.e0
+         ! dynamical invariants
+         delta_i(:,:) = 0.e0       ; divu_i (:,:) = 0.e0       ;    shear_i(:,:) = 0.e0
+
+                          CALL lim_rst_opn( kt )     ! Open Ice restart file
+         !
+         IF( ln_nicep )   CALL lim_prt_state( jiindx, jjindx, 1, ' - Beginning the time step - ' )   ! control print
+         !
+         IF( .NOT. lk_c1d ) THEN                     ! Ice dynamics & transport (not in 1D case)
+                          CALL lim_dyn( kt )              ! Ice dynamics    ( rheology/dynamics )
+                          CALL lim_trp( kt )              ! Ice transport   ( Advection/diffusion )
+                          CALL lim_var_agg(1)             ! aggregate categories, requested
+                          CALL lim_var_glo2eqv            ! equivalent variables, requested for rafting
+         IF( ln_nicep )   CALL lim_prt_state( jiindx, jjindx,-1, ' - ice dyn & trp - ' )   ! control print
+                          CALL lim_itd_me                 ! Mechanical redistribution ! (ridging/rafting)
+         ENDIF
+         !
+         !                                           ! Ice thermodynamics 
+                          CALL lim_var_glo2eqv            ! equivalent variables
+                          CALL lim_var_agg(1)             ! aggregate ice categories
+                          CALL lim_var_bv                 ! bulk brine volume (diag)
+                          CALL lim_thd( kt )              ! Ice thermodynamics 
+                          zcoef = rdt_ice / 86400.e0      !  Ice natural aging
+                          oa_i(:,:,:) = oa_i(:,:,:) + a_i(:,:,:) * zcoef
+                          CALL lim_var_glo2eqv            ! this CALL is maybe not necessary (Martin)
+         IF( ln_nicep )   CALL lim_prt_state( jiindx, jjindx, 1, ' - ice thermodyn. - ' )   ! control print
+                          CALL lim_itd_th( kt )           !  Remap ice categories, lateral accretion  !
+         !
+         !                                           ! Global variables update |
+                          CALL lim_var_agg( 1 )           ! requested by limupdate
+                          CALL lim_update                 ! Global variables update
+                          CALL lim_var_glo2eqv            ! equivalent variables (outputs)
+                          CALL lim_var_agg(2)             ! aggregate ice thickness categories
+         IF( ln_nicep )   CALL lim_prt_state( jiindx, jjindx, 2, ' - Final state - ' )   ! control print
+         !
+         !                                           ! Fluxes of mass and heat to the ocean |
+                         CALL lim_sbc_flx( kt )           ! Ice/Ocean heat freshwater/salt fluxes
+         IF( ln_limdyn .AND. kico == 0 )   &              ! Ice/Ocean stresses (only in ice-dynamic case)
+            &            CALL lim_sbc_tau( kt, kico )     ! otherwise the atm.-ocean stresses are used everywhere
+         !
+         IF( ln_nicep )   CALL lim_prt_state( jiindx, jjindx, 3, ' - Final state lim_sbc - ' )   ! control print
+         !
+         !                                           ! Diagnostics and outputs 
+         IF( ( MOD( kt+nn_fsbc-1, ninfo ) == 0 .OR. ntmoy == 1 ) .AND. .NOT. lk_mpp )   &
+            &             CALL lim_dia 
+                          CALL lim_wri( 1  )              ! Ice outputs 
+         IF( lrst_ice )   CALL lim_rst_write( kt )        ! Ice restart file 
+                          CALL lim_var_glo2eqv            ! ???
+         !
+         IF( ln_nicep )   CALL lim_ctl               ! alerts in case of model crash
+         !
+      ENDIF                                          ! End sea-ice time step only
+
+      !                                              !--------------------------!
+      ! Ice/Ocean stresses (nn_ico_cpl=1 or 2 cases) !  at all ocean time step  !
+      !                                              !--------------------------!
+      IF( ln_limdyn .AND. kico /= 0 )   &
+         &                CALL lim_sbc_tau( kt, kico ) 
+!!gm   remark, in this case the ocean-ice stress is not saved in diag call above .....  find a solution!!!
+      !
+   END SUBROUTINE sbc_ice_lim
+
+
+   SUBROUTINE lim_ctl
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_ctl *** 
+      !!                 
+      !! ** Purpose :   Alerts in case of model crash
+      !!-------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk,  jl   ! dummy loop indices
+      INTEGER  ::   inb_altests       ! number of alert tests (max 20)
+      INTEGER  ::   ialert_id         ! number of the current alert
+      REAL(wp) ::   ztmelts           ! ice layer melting point
+      CHARACTER (len=30), DIMENSION(20)      ::   cl_alname   ! name of alert
+      INTEGER           , DIMENSION(20)      ::   inb_alp     ! number of alerts positive
+      !!-------------------------------------------------------------------
+
+      inb_altests = 10
+      inb_alp(:) = 0
+
+      ! Alert if incompatible volume and concentration
+      ialert_id = 2 ! reference number of this alert
+      cl_alname(ialert_id) = ' Incompat vol and con         '    ! name of the alert
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF(  v_i(ji,jj,jl) /= 0.e0   .AND.   a_i(ji,jj,jl) == 0.e0   ) THEN
+                  WRITE(numout,*) ' ALERTE 2 :   Incompatible volume and concentration '
+                  WRITE(numout,*) ' at_i     ', at_i(ji,jj)
+                  WRITE(numout,*) ' Point - category', ji, jj, jl
+                  WRITE(numout,*) ' a_i *** a_i_old ', a_i      (ji,jj,jl), old_a_i  (ji,jj,jl)
+                  WRITE(numout,*) ' v_i *** v_i_old ', v_i      (ji,jj,jl), old_v_i  (ji,jj,jl)
+                  WRITE(numout,*) ' d_a_i_thd/trp   ', d_a_i_thd(ji,jj,jl), d_a_i_trp(ji,jj,jl)
+                  WRITE(numout,*) ' d_v_i_thd/trp   ', d_v_i_thd(ji,jj,jl), d_v_i_trp(ji,jj,jl)
+                  inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Alerte if very thick ice
+      ialert_id = 3 ! reference number of this alert
+      cl_alname(ialert_id) = ' Very thick ice               ' ! name of the alert
+      jl = jpl 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF(   ht_i(ji,jj,jl) .GT. 50.0   ) THEN
+               CALL lim_prt_state( ji, jj, 2, ' ALERTE 3 :   Very thick ice ' )
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+            ENDIF
+         END DO
+      END DO
+
+      ! Alert if very fast ice
+      ialert_id = 4 ! reference number of this alert
+      cl_alname(ialert_id) = ' Very fast ice               ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF(   MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) ) .GT. 0.5  .AND.  &
+               &  at_i(ji,jj) .GT. 0.e0   ) THEN
+               CALL lim_prt_state( ji, jj, 1, ' ALERTE 4 :   Very fast ice ' )
+               WRITE(numout,*) ' ice strength             : ', strength(ji,jj)
+               WRITE(numout,*) ' oceanic stress utau      : ', utau(ji,jj) 
+               WRITE(numout,*) ' oceanic stress vtau      : ', vtau(ji,jj)
+               WRITE(numout,*) ' sea-ice stress utau_ice  : ', utau_ice(ji,jj) 
+               WRITE(numout,*) ' sea-ice stress vtau_ice  : ', vtau_ice(ji,jj)
+               WRITE(numout,*) ' oceanic speed u          : ', u_oce(ji,jj)
+               WRITE(numout,*) ' oceanic speed v          : ', v_oce(ji,jj)
+               WRITE(numout,*) ' sst                      : ', sst_m(ji,jj)
+               WRITE(numout,*) ' sss                      : ', sss_m(ji,jj)
+               WRITE(numout,*) 
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+            ENDIF
+         END DO
+      END DO
+
+      ! Alert if there is ice on continents
+      ialert_id = 6 ! reference number of this alert
+      cl_alname(ialert_id) = ' Ice on continents           ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF(   tms(ji,jj) .LE. 0.0   .AND.   at_i(ji,jj) .GT. 0.e0   ) THEN 
+               CALL lim_prt_state( ji, jj, 1, ' ALERTE 6 :   Ice on continents ' )
+               WRITE(numout,*) ' masks s, u, v        : ', tms(ji,jj), tmu(ji,jj), tmv(ji,jj) 
+               WRITE(numout,*) ' sst                  : ', sst_m(ji,jj)
+               WRITE(numout,*) ' sss                  : ', sss_m(ji,jj)
+               WRITE(numout,*) ' at_i(ji,jj)          : ', at_i(ji,jj)
+               WRITE(numout,*) ' v_ice(ji,jj)         : ', v_ice(ji,jj)
+               WRITE(numout,*) ' v_ice(ji,jj-1)       : ', v_ice(ji,jj-1)
+               WRITE(numout,*) ' u_ice(ji-1,jj)       : ', u_ice(ji-1,jj)
+               WRITE(numout,*) ' u_ice(ji,jj)         : ', v_ice(ji,jj)
+               !
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+            ENDIF
+         END DO
+      END DO
+
+!
+!     ! Alert if very fresh ice
+      ialert_id = 7 ! reference number of this alert
+      cl_alname(ialert_id) = ' Very fresh ice               ' ! name of the alert
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+!!gm  test twice sm_i ...  ????  bug?
+               IF( ( ( ABS( sm_i(ji,jj,jl) ) .LT. 0.50) .OR. &
+                     ( ABS( sm_i(ji,jj,jl) ) .LT. 0.50) ) .AND. &
+                             ( a_i(ji,jj,jl) .GT. 0.e0 ) ) THEN
+!                 CALL lim_prt_state(ji,jj,1, ' ALERTE 7 :   Very fresh ice ' )
+!                 WRITE(numout,*) ' sst                  : ', sst_m(ji,jj)
+!                 WRITE(numout,*) ' sss                  : ', sss_m(ji,jj)
+!                 WRITE(numout,*) ' s_i_newice           : ', s_i_newice(ji,jj,1:jpl)
+!                 WRITE(numout,*) 
+                  inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+               ENDIF
+            END DO
+         END DO
+      END DO
+!
+
+!     ! Alert if too old ice
+      ialert_id = 9 ! reference number of this alert
+      cl_alname(ialert_id) = ' Very old   ice               ' ! name of the alert
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ( ( ABS( o_i(ji,jj,jl) ) .GT. rdt_ice ) .OR. &
+                      ( ABS( o_i(ji,jj,jl) ) .LT. 0.00) ) .AND. &
+                             ( a_i(ji,jj,jl) .GT. 0.0 ) ) THEN
+                  CALL lim_prt_state( ji, jj, 1, ' ALERTE 9 :   Wrong ice age ')
+                  inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+               ENDIF
+            END DO
+         END DO
+      END DO
+ 
+      ! Alert on salt flux
+      ialert_id = 5 ! reference number of this alert
+      cl_alname(ialert_id) = ' High salt flux               ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS( emps(ji,jj) ) .GT. 1.0e-2 ) THEN
+               CALL lim_prt_state( ji, jj, 3, ' ALERTE 5 :   High salt flux ' )
+               DO jl = 1, jpl
+                  WRITE(numout,*) ' Category no: ', jl
+                  WRITE(numout,*) ' a_i        : ', a_i      (ji,jj,jl) , ' old_a_i    : ', old_a_i  (ji,jj,jl)   
+                  WRITE(numout,*) ' d_a_i_trp  : ', d_a_i_trp(ji,jj,jl) , ' d_a_i_thd  : ', d_a_i_thd(ji,jj,jl) 
+                  WRITE(numout,*) ' v_i        : ', v_i      (ji,jj,jl) , ' old_v_i    : ', old_v_i  (ji,jj,jl)   
+                  WRITE(numout,*) ' d_v_i_trp  : ', d_v_i_trp(ji,jj,jl) , ' d_v_i_thd  : ', d_v_i_thd(ji,jj,jl) 
+                  WRITE(numout,*) ' '
+               END DO
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+            ENDIF
+         END DO
+      END DO
+
+      ! Alert if qns very big
+      ialert_id = 8 ! reference number of this alert
+      cl_alname(ialert_id) = ' fnsolar very big             ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF(   ABS( qns(ji,jj) ) .GT. 1500.0   .AND.  ( at_i(ji,jj) .GT. 0.0 ) )  THEN
+               !
+               WRITE(numout,*) ' ALERTE 8 :   Very high non-solar heat flux'
+               WRITE(numout,*) ' ji, jj    : ', ji, jj
+               WRITE(numout,*) ' qns       : ', qns(ji,jj)
+               WRITE(numout,*) ' sst       : ', sst_m(ji,jj)
+               WRITE(numout,*) ' sss       : ', sss_m(ji,jj)
+               WRITE(numout,*) ' qcmif     : ', qcmif(ji,jj)
+               WRITE(numout,*) ' qldif     : ', qldif(ji,jj)
+               WRITE(numout,*) ' qcmif     : ', qcmif(ji,jj) / rdt_ice
+               WRITE(numout,*) ' qldif     : ', qldif(ji,jj) / rdt_ice
+               WRITE(numout,*) ' qfvbq     : ', qfvbq(ji,jj)
+               WRITE(numout,*) ' qdtcn     : ', qdtcn(ji,jj)
+               WRITE(numout,*) ' qfvbq / dt: ', qfvbq(ji,jj) / rdt_ice
+               WRITE(numout,*) ' qdtcn / dt: ', qdtcn(ji,jj) / rdt_ice
+               WRITE(numout,*) ' fdtcn     : ', fdtcn(ji,jj) 
+               WRITE(numout,*) ' fhmec     : ', fhmec(ji,jj) 
+               WRITE(numout,*) ' fheat_rpo : ', fheat_rpo(ji,jj) 
+               WRITE(numout,*) ' fheat_res : ', fheat_res(ji,jj) 
+               WRITE(numout,*) ' fhbri     : ', fhbri(ji,jj) 
+               !
+               CALL lim_prt_state( ji, jj, 2, '   ')
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+               !
+            ENDIF
+         END DO
+      END DO
+      !+++++
+ 
+      ! Alert if very warm ice
+      ialert_id = 10 ! reference number of this alert
+      cl_alname(ialert_id) = ' Very warm ice                ' ! name of the alert
+      inb_alp(ialert_id) = 0
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztmelts    =  -tmut * s_i(ji,jj,jk,jl) + rtt
+                  IF( t_i(ji,jj,jk,jl) .GE. ztmelts  .AND.  v_i(ji,jj,jl) .GT. 1.e-6   &
+                     &                               .AND.  a_i(ji,jj,jl) .GT. 0.e0    ) THEN
+                     WRITE(numout,*) ' ALERTE 10 :   Very warm ice'
+                     WRITE(numout,*) ' ji, jj, jk, jl : ', ji, jj, jk, jl
+                     WRITE(numout,*) ' t_i : ', t_i(ji,jj,jk,jl)
+                     WRITE(numout,*) ' e_i : ', e_i(ji,jj,jk,jl)
+                     WRITE(numout,*) ' s_i : ', s_i(ji,jj,jk,jl)
+                     WRITE(numout,*) ' ztmelts : ', ztmelts
+                     inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      END DO
+
+      ialert_id = 1                                 ! reference number of this alert
+      cl_alname(ialert_id) = ' NO alerte 1      '   ! name of the alert
+      WRITE(numout,*)
+      WRITE(numout,*) ' All alerts at the end of ice model '
+      DO ialert_id = 1, inb_altests
+         WRITE(numout,*) ialert_id, cl_alname(ialert_id)//' : ', inb_alp(ialert_id), ' times ! '
+      END DO
+      !
+   END SUBROUTINE lim_ctl
+ 
+   
+   SUBROUTINE lim_prt_state( ki, kj, kn, cd1 )
+      !!-----------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_prt_state *** 
+      !!                 
+      !! ** Purpose :   Writes global ice state on the (i,j) point 
+      !!                in ocean.ouput 
+      !!                3 possibilities exist 
+      !!                n = 1/-1 -> simple ice state (plus Mechanical Check if -1)
+      !!                n = 2    -> exhaustive state
+      !!                n = 3    -> ice/ocean salt fluxes
+      !!
+      !! ** input   :   point coordinates (i,j) 
+      !!                n : number of the option
+      !!-------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   ki, kj, kn    ! ocean gridpoint indices
+      CHARACTER(len=*), INTENT(in) ::   cd1           !
+      !!
+      INTEGER :: jl
+      !!-------------------------------------------------------------------
+
+      WRITE(numout,*) cd1             ! print title
+
+      !----------------
+      !  Simple state
+      !----------------
+
+      IF ( kn == 1 .OR. kn == -1 ) THEN
+         WRITE(numout,*) ' lim_prt_state - Point : ',ki,kj
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
+         WRITE(numout,*) ' Simple state '
+         WRITE(numout,*) ' masks s,u,v   : ', tms(ki,kj), tmu(ki,kj), tmv(ki,kj)
+         WRITE(numout,*) ' lat - long    : ', gphit(ki,kj), glamt(ki,kj)
+         WRITE(numout,*) ' Time step     : ', numit
+         WRITE(numout,*) ' - Ice drift   '
+         WRITE(numout,*) '   ~~~~~~~~~~~ '
+         WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ki-1,kj)
+         WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ki,kj)
+         WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ki,kj-1)
+         WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ki,kj)
+         WRITE(numout,*) ' strength      : ', strength(ki,kj)
+         WRITE(numout,*)
+         WRITE(numout,*) ' - Cell values '
+         WRITE(numout,*) '   ~~~~~~~~~~~ '
+         WRITE(numout,*) ' cell area     : ', area(ki,kj)
+         WRITE(numout,*) ' at_i          : ', at_i(ki,kj)       
+         WRITE(numout,*) ' vt_i          : ', vt_i(ki,kj)       
+         WRITE(numout,*) ' vt_s          : ', vt_s(ki,kj)       
+         DO jl = 1, jpl
+            WRITE(numout,*) ' - Category (', jl,')'
+            WRITE(numout,*) ' a_i           : ', a_i(ki,kj,jl)
+            WRITE(numout,*) ' ht_i          : ', ht_i(ki,kj,jl)
+            WRITE(numout,*) ' ht_s          : ', ht_s(ki,kj,jl)
+            WRITE(numout,*) ' v_i           : ', v_i(ki,kj,jl)
+            WRITE(numout,*) ' v_s           : ', v_s(ki,kj,jl)
+            WRITE(numout,*) ' e_s           : ', e_s(ki,kj,1,jl)/1.0e9
+            WRITE(numout,*) ' e_i           : ', e_i(ki,kj,1:nlay_i,jl)/1.0e9
+            WRITE(numout,*) ' t_su          : ', t_su(ki,kj,jl)
+            WRITE(numout,*) ' t_snow        : ', t_s(ki,kj,1,jl)
+            WRITE(numout,*) ' t_i           : ', t_i(ki,kj,1:nlay_i,jl)
+            WRITE(numout,*) ' sm_i          : ', sm_i(ki,kj,jl)
+            WRITE(numout,*) ' smv_i         : ', smv_i(ki,kj,jl)
+            WRITE(numout,*)
+            WRITE(numout,*) ' Pathological case : ', patho_case(ki,kj,jl)
+         END DO
+      ENDIF
+      IF( kn == -1 ) THEN
+         WRITE(numout,*) ' Mechanical Check ************** '
+         WRITE(numout,*) ' Check what means ice divergence '
+         WRITE(numout,*) ' Total ice concentration ', at_i (ki,kj)
+         WRITE(numout,*) ' Total lead fraction     ', ato_i(ki,kj)
+         WRITE(numout,*) ' Sum of both             ', ato_i(ki,kj) + at_i(ki,kj)
+         WRITE(numout,*) ' Sum of both minus 1     ', ato_i(ki,kj) + at_i(ki,kj) - 1.00
+      ENDIF
+
+
+      !--------------------
+      !  Exhaustive state
+      !--------------------
+
+      IF ( kn .EQ. 2 ) THEN
+         WRITE(numout,*) ' lim_prt_state - Point : ',ki,kj
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
+         WRITE(numout,*) ' Exhaustive state '
+         WRITE(numout,*) ' lat - long ', gphit(ki,kj), glamt(ki,kj)
+         WRITE(numout,*) ' Time step ', numit
+         WRITE(numout,*) 
+         WRITE(numout,*) ' - Cell values '
+         WRITE(numout,*) '   ~~~~~~~~~~~ '
+         WRITE(numout,*) ' cell area     : ', area(ki,kj)
+         WRITE(numout,*) ' at_i          : ', at_i(ki,kj)       
+         WRITE(numout,*) ' vt_i          : ', vt_i(ki,kj)       
+         WRITE(numout,*) ' vt_s          : ', vt_s(ki,kj)       
+         WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ki-1,kj)
+         WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ki,kj)
+         WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ki,kj-1)
+         WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ki,kj)
+         WRITE(numout,*) ' strength      : ', strength(ki,kj)
+         WRITE(numout,*) ' d_u_ice_dyn   : ', d_u_ice_dyn(ki,kj), ' d_v_ice_dyn   : ', d_v_ice_dyn(ki,kj)
+         WRITE(numout,*) ' old_u_ice     : ', old_u_ice(ki,kj)  , ' old_v_ice     : ', old_v_ice(ki,kj)  
+         WRITE(numout,*)
+
+         DO jl = 1, jpl
+              WRITE(numout,*) ' - Category (',jl,')'
+              WRITE(numout,*) '   ~~~~~~~~         ' 
+              WRITE(numout,*) ' ht_i       : ', ht_i(ki,kj,jl)             , ' ht_s       : ', ht_s(ki,kj,jl)
+              WRITE(numout,*) ' t_i        : ', t_i(ki,kj,1:nlay_i,jl)
+              WRITE(numout,*) ' t_su       : ', t_su(ki,kj,jl)             , ' t_s        : ', t_s(ki,kj,1,jl)
+              WRITE(numout,*) ' sm_i       : ', sm_i(ki,kj,jl)             , ' o_i        : ', o_i(ki,kj,jl)
+              WRITE(numout,*) ' a_i        : ', a_i(ki,kj,jl)              , ' old_a_i    : ', old_a_i(ki,kj,jl)   
+              WRITE(numout,*) ' d_a_i_trp  : ', d_a_i_trp(ki,kj,jl)        , ' d_a_i_thd  : ', d_a_i_thd(ki,kj,jl) 
+              WRITE(numout,*) ' v_i        : ', v_i(ki,kj,jl)              , ' old_v_i    : ', old_v_i(ki,kj,jl)   
+              WRITE(numout,*) ' d_v_i_trp  : ', d_v_i_trp(ki,kj,jl)        , ' d_v_i_thd  : ', d_v_i_thd(ki,kj,jl) 
+              WRITE(numout,*) ' v_s        : ', v_s(ki,kj,jl)              , ' old_v_s    : ', old_v_s(ki,kj,jl)  
+              WRITE(numout,*) ' d_v_s_trp  : ', d_v_s_trp(ki,kj,jl)        , ' d_v_s_thd  : ', d_v_s_thd(ki,kj,jl)
+              WRITE(numout,*) ' e_i1       : ', e_i(ki,kj,1,jl)/1.0e9      , ' old_ei1    : ', old_e_i(ki,kj,1,jl)/1.0e9 
+              WRITE(numout,*) ' de_i1_trp  : ', d_e_i_trp(ki,kj,1,jl)/1.0e9, ' de_i1_thd  : ', d_e_i_thd(ki,kj,1,jl)/1.0e9
+              WRITE(numout,*) ' e_i2       : ', e_i(ki,kj,2,jl)/1.0e9      , ' old_ei2    : ', old_e_i(ki,kj,2,jl)/1.0e9  
+              WRITE(numout,*) ' de_i2_trp  : ', d_e_i_trp(ki,kj,2,jl)/1.0e9, ' de_i2_thd  : ', d_e_i_thd(ki,kj,2,jl)/1.0e9
+              WRITE(numout,*) ' e_snow     : ', e_s(ki,kj,1,jl)            , ' old_e_snow : ', old_e_s(ki,kj,1,jl) 
+              WRITE(numout,*) ' d_e_s_trp  : ', d_e_s_trp(ki,kj,1,jl)      , ' d_e_s_thd  : ', d_e_s_thd(ki,kj,1,jl)
+              WRITE(numout,*) ' smv_i      : ', smv_i(ki,kj,jl)            , ' old_smv_i  : ', old_smv_i(ki,kj,jl)   
+              WRITE(numout,*) ' d_smv_i_trp: ', d_smv_i_trp(ki,kj,jl)      , ' d_smv_i_thd: ', d_smv_i_thd(ki,kj,jl) 
+              WRITE(numout,*) ' oa_i       : ', oa_i(ki,kj,jl)             , ' old_oa_i   : ', old_oa_i(ki,kj,jl)
+              WRITE(numout,*) ' d_oa_i_trp : ', d_oa_i_trp(ki,kj,jl)       , ' d_oa_i_thd : ', d_oa_i_thd(ki,kj,jl)
+              WRITE(numout,*) ' Path. case : ', patho_case(ki,kj,jl)
+        END DO !jl
+
+        WRITE(numout,*)
+        WRITE(numout,*) ' - Heat / FW fluxes '
+        WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
+!       WRITE(numout,*) ' fsbri      : ', fsbri(ki,kj)
+!       WRITE(numout,*) ' fseqv      : ', fseqv(ki,kj)
+!       WRITE(numout,*) ' fsalt_res  : ', fsalt_res(ki,kj)
+        WRITE(numout,*) ' fmmec      : ', fmmec(ki,kj)
+        WRITE(numout,*) ' fhmec      : ', fhmec(ki,kj)
+        WRITE(numout,*) ' fhbri      : ', fhbri(ki,kj)
+        WRITE(numout,*) ' fheat_rpo  : ', fheat_rpo(ki,kj)
+        WRITE(numout,*) 
+        WRITE(numout,*) ' sst        : ', sst_m(ki,kj)  
+        WRITE(numout,*) ' sss        : ', sss_m(ki,kj)  
+        WRITE(numout,*) 
+        WRITE(numout,*) ' - Stresses '
+        WRITE(numout,*) '   ~~~~~~~~ '
+        WRITE(numout,*) ' utau_ice   : ', utau_ice(ki,kj) 
+        WRITE(numout,*) ' vtau_ice   : ', vtau_ice(ki,kj)
+        WRITE(numout,*) ' utau       : ', utau(ki,kj) 
+        WRITE(numout,*) ' vtau       : ', vtau(ki,kj)
+        WRITE(numout,*) ' oc. vel. u : ', u_oce(ki,kj)
+        WRITE(numout,*) ' oc. vel. v : ', v_oce(ki,kj)
+     ENDIF
+
+     !---------------------
+     ! Salt / heat fluxes
+     !---------------------
+
+     IF ( kn .EQ. 3 ) THEN
+        WRITE(numout,*) ' lim_prt_state - Point : ',ki,kj
+        WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
+        WRITE(numout,*) ' - Salt / Heat Fluxes '
+        WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
+        WRITE(numout,*) ' lat - long ', gphit(ki,kj), glamt(ki,kj)
+        WRITE(numout,*) ' Time step ', numit
+        WRITE(numout,*)
+        WRITE(numout,*) ' - Heat fluxes at bottom interface ***'
+        WRITE(numout,*) ' qsr        : ', qsr(ki,kj)
+        WRITE(numout,*) ' qns        : ', qns(ki,kj)
+        WRITE(numout,*)
+        WRITE(numout,*) ' - Salt fluxes at bottom interface ***'
+        WRITE(numout,*) ' emps       : ', emps(ki,kj)
+        WRITE(numout,*) ' emp        : ', emp(ki,kj)
+        WRITE(numout,*) ' fsbri      : ', fsbri(ki,kj)
+        WRITE(numout,*) ' fseqv      : ', fseqv(ki,kj)
+        WRITE(numout,*) ' fsalt_res  : ', fsalt_res(ki,kj)
+        WRITE(numout,*) ' fsalt_rpo  : ', fsalt_rpo(ki,kj)
+        WRITE(numout,*) ' - Heat fluxes at bottom interface ***'
+        WRITE(numout,*) ' fheat_res  : ', fheat_res(ki,kj)
+        WRITE(numout,*)
+        WRITE(numout,*) ' - Momentum fluxes '
+        WRITE(numout,*) ' utau      : ', utau(ki,kj) 
+        WRITE(numout,*) ' vtau      : ', vtau(ki,kj)
+      ENDIF
+      WRITE(numout,*) ' '
+      !
+   END SUBROUTINE lim_prt_state
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option           Dummy module      NO LIM 3.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE sbc_ice_lim ( kt, kblk, kico )     ! Dummy routine
+      WRITE(*,*) 'sbc_ice_lim: You should not have seen this print! error?', kt, kblk, kico
+   END SUBROUTINE sbc_ice_lim
+#endif
+
+   !!======================================================================
+END MODULE sbcice_lim
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 1844)
@@ -0,0 +1,213 @@
+MODULE sbcice_lim_2
+   !!======================================================================
+   !!                       ***  MODULE  sbcice_lim_2  ***
+   !! Surface module :  update surface ocean boundary condition over ice
+   !!                   covered area using LIM sea-ice model
+   !! Sea-Ice model  :  LIM 2.0 Sea ice model time-stepping
+   !!======================================================================
+   !! History :  1.0   !  06-2006  (G. Madec)  from icestp_2.F90
+   !!            3.0   !  08-2008  (S. Masson, E. .... ) coupled interface
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   sbc_ice_lim_2  : sea-ice model time-stepping and
+   !!                    update ocean sbc over ice-covered area
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE c1d             ! 1d configuration
+   USE dom_oce         ! ocean space and time domain
+   USE lib_mpp
+   USE ice_2
+   USE par_ice_2
+   USE iceini_2
+   USE dom_ice_2
+
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice   fields
+   USE sbcblk_core     ! Surface boundary condition: CORE bulk
+   USE sbcblk_clio     ! Surface boundary condition: CLIO bulk
+   USE sbccpl          ! Surface boundary condition: coupled interface
+   USE albedo
+
+   USE phycst          ! Define parameters for the routines
+   USE eosbn2          ! equation of state
+   USE limdyn_2
+   USE limtrp_2
+   USE limdmp_2
+   USE limthd_2
+   USE limsbc_2        ! sea surface boundary condition
+   USE limdia_2
+   USE limwri_2
+   USE limrst_2
+
+   USE lbclnk
+   USE iom             ! I/O manager library
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sbc_ice_lim_2 ! routine called by sbcmod.F90
+   
+   CHARACTER(len=1) ::   cl_grid = 'B'     ! type of grid used in ice dynamics
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/SBC  3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ice_lim_2( kt, ksbc )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_ice_lim_2  ***
+      !!                   
+      !! ** Purpose :   update the ocean surface boundary condition via the 
+      !!                Louvain la Neuve Sea Ice Model time stepping 
+      !!
+      !! ** Method  :   ice model time stepping
+      !!              - call the ice dynamics routine 
+      !!              - call the ice advection/diffusion routine 
+      !!              - call the ice thermodynamics routine 
+      !!              - call the routine that computes mass and 
+      !!                heat fluxes at the ice/ocean interface
+      !!              - save the outputs 
+      !!              - save the outputs for restart when necessary
+      !!
+      !! ** Action  : - time evolution of the LIM sea-ice model
+      !!              - update all sbc variables below sea-ice:
+      !!                utau, vtau, taum, wndm, qns , qsr, emp , emps
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt      ! ocean time step
+      INTEGER, INTENT(in) ::   ksbc    ! type of sbc ( =3 CLIO bulk ; =4 CORE bulk ; =5 coupled )
+      !!
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,1) ::   zalb_ice_os   ! albedo of the ice under overcast sky
+      REAL(wp), DIMENSION(jpi,jpj,1) ::   zalb_ice_cs   ! albedo of ice under clear sky
+      REAL(wp), DIMENSION(jpi,jpj,1) ::   zsist        ! surface ice temperature (K)
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'sbc_ice_lim_2 : update ocean surface boudary condition' 
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   via Louvain la Neuve Ice Model (LIM) time stepping'
+
+         CALL ice_init_2
+
+      ENDIF
+
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+         !
+         ! ... mean surface ocean current at ice dynamics point
+         !     B-grid dynamics :  I-point 
+         DO jj = 2, jpj
+            DO ji = 2, jpi   ! B grid : no vector opt.
+               u_oce(ji,jj) = 0.5 * ( ssu_m(ji-1,jj  ) + ssu_m(ji-1,jj-1) ) * tmu(ji,jj)
+               v_oce(ji,jj) = 0.5 * ( ssv_m(ji  ,jj-1) + ssv_m(ji-1,jj-1) ) * tmu(ji,jj)
+            END DO
+         END DO
+         CALL lbc_lnk( u_oce, 'I', -1. )   ! I-point (i.e. F-point with ice indices)
+         CALL lbc_lnk( v_oce, 'I', -1. )   ! I-point (i.e. F-point with ice indices)
+
+         ! ... masked sea surface freezing temperature [Kelvin] (set to rt0 over land)
+         tfu(:,:) = tfreez( sss_m ) +  rt0 
+
+         zsist (:,:,1) = sist (:,:) + rt0 * ( 1. - tmask(:,:,1) )
+
+         ! ... ice albedo (clear sky and overcast sky)
+         CALL albedo_ice( zsist, reshape( hicif, (/jpi,jpj,1/) ), reshape( hsnif, (/jpi,jpj,1/) ), zalb_ice_cs, zalb_ice_os )
+
+         ! ... Sea-ice surface boundary conditions output from bulk formulae :
+         !     - utau_ice   ! surface ice stress i-component (I-point)   [N/m2]
+         !     - vtau_ice   ! surface ice stress j-component (I-point)   [N/m2]
+         !     - qns_ice    ! non solar heat flux over ice   (T-point)   [W/m2]
+         !     - qsr_ice    !     solar heat flux over ice   (T-point)   [W/m2]
+         !     - qla_ice    ! latent    heat flux over ice   (T-point)   [W/m2]
+         !     - dqns_ice   ! non solar heat sensistivity    (T-point)   [W/m2]
+         !     - dqla_ice   ! latent    heat sensistivity    (T-point)   [W/m2]
+         !     - tprecip    ! total precipitation            (T-point)   [Kg/m2/s]
+         !     - sprecip    ! solid precipitation            (T-point)   [Kg/m2/s]
+         !     - fr1_i0     ! 1sr fraction of qsr penetration in ice     [%]
+         !     - fr2_i0     ! 2nd fraction of qsr penetration in ice     [%]
+         !
+         SELECT CASE( ksbc )
+         CASE( 3 )           ! CLIO bulk formulation
+            CALL blk_ice_clio( zsist, zalb_ice_cs, zalb_ice_os,                         &
+               &                      utau_ice   , vtau_ice   , qns_ice    , qsr_ice,   &
+               &                      qla_ice    , dqns_ice   , dqla_ice   ,            &
+               &                      tprecip    , sprecip    ,                         &
+               &                      fr1_i0     , fr2_i0     , cl_grid    , jpl  )
+
+         CASE( 4 )           ! CORE bulk formulation
+            CALL blk_ice_core( zsist, u_ice      , v_ice      , zalb_ice_cs,            &
+               &                      utau_ice   , vtau_ice   , qns_ice    , qsr_ice,   &
+               &                      qla_ice    , dqns_ice   , dqla_ice   ,            &
+               &                      tprecip    , sprecip    ,                         &
+               &                      fr1_i0     , fr2_i0     , cl_grid    , jpl  )
+         CASE( 5 )           ! Coupled formulation : atmosphere-ice stress only (fluxes provided after ice dynamics)
+            CALL sbc_cpl_ice_tau( utau_ice , vtau_ice )
+         END SELECT
+
+         CALL iom_put( 'utau_ice', utau_ice )     ! Wind stress over ice along i-axis at I-point
+         CALL iom_put( 'vtau_ice', vtau_ice )     ! Wind stress over ice along j-axis at I-point
+
+         IF(ln_ctl) THEN         ! print mean trends (used for debugging)
+            CALL prt_ctl_info( 'Ice Forcings ' )
+            CALL prt_ctl( tab2d_1=tprecip ,clinfo1=' sbc_ice_lim: precip  : ', tab2d_2=sprecip , clinfo2=' Snow    : ' )
+            CALL prt_ctl( tab2d_1=utau_ice,clinfo1=' sbc_ice_lim: utau_ice: ', tab2d_2=vtau_ice, clinfo2=' vtau_ice: ' )
+            CALL prt_ctl( tab2d_1=sst_m   ,clinfo1=' sbc_ice_lim: sst     : ', tab2d_2=sss_m   , clinfo2=' sss     : ' )
+            CALL prt_ctl( tab2d_1=u_oce   ,clinfo1=' sbc_ice_lim: u_io    : ', tab2d_2=v_oce   , clinfo2=' v_io    : ' )
+            CALL prt_ctl( tab2d_1=hsnif   ,clinfo1=' sbc_ice_lim: hsnif  1: ', tab2d_2=hicif   , clinfo2=' hicif   : ' )
+            CALL prt_ctl( tab2d_1=frld    ,clinfo1=' sbc_ice_lim: frld   1: ', tab2d_2=sist    , clinfo2=' sist    : ' )
+         ENDIF
+
+         ! ---------------- !
+         !  Ice model step  !
+         ! ---------------- !
+
+                                        CALL lim_rst_opn_2  ( kt )      ! Open Ice restart file
+         IF( .NOT. lk_c1d ) THEN                                        ! Ice dynamics & transport (not in 1D case)
+                                        CALL lim_dyn_2      ( kt )           ! Ice dynamics    ( rheology/dynamics )
+                                        CALL lim_trp_2      ( kt )           ! Ice transport   ( Advection/diffusion )
+            IF( ln_limdmp )             CALL lim_dmp_2      ( kt )           ! Ice damping 
+         ENDIF
+#if defined key_coupled
+         IF( ksbc == 5    )             CALL sbc_cpl_ice_flx( frld   ,                               &
+      &                                                       qns_tot, qns_ice, qsr_tot , qsr_ice,   &
+      &                                                       emp_tot, emp_ice, dqns_ice, sprecip,   &
+      !                                      optional arguments, used only in 'mixed oce-ice' case
+      &                                                       palbi = zalb_ice_cs, psst = sst_m, pist = sist )
+#endif
+                                        CALL lim_thd_2      ( kt )      ! Ice thermodynamics 
+                                        CALL lim_sbc_2      ( kt )      ! Ice/Ocean Mass & Heat fluxes 
+
+         IF( ( MOD( kt+nn_fsbc-1, ninfo ) == 0 .OR. ntmoy == 1 ) .AND. .NOT. lk_mpp )   &
+            &                           CALL lim_dia_2      ( kt )      ! Ice Diagnostics
+# if ! defined key_iomput
+                                        CALL lim_wri_2      ( kt )      ! Ice outputs
+# endif
+         IF( lrst_ice )                 CALL lim_rst_write_2( kt )      ! Ice restart file
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_ice_lim_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option           Dummy module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE sbc_ice_lim_2 ( kt, ksbc )     ! Dummy routine
+      WRITE(*,*) 'sbc_ice_lim_2: You should not have seen this print! error?', kt, ksbc
+   END SUBROUTINE sbc_ice_lim_2
+#endif
+
+   !!======================================================================
+END MODULE sbcice_lim_2
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1844)
@@ -0,0 +1,270 @@
+MODULE sbcmod
+   !!======================================================================
+   !!                       ***  MODULE  sbcmod  ***
+   !! Surface module :  provide to the ocean its surface boundary condition
+   !!======================================================================
+   !! History :  3.0   !  07-2006  (G. Madec)  Original code
+   !!             -    !  08-2008  (S. Masson, E. .... ) coupled interface
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_init       : read namsbc namelist
+   !!   sbc            : surface ocean momentum, heat and freshwater boundary conditions
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcssm          ! surface boundary condition: sea-surface mean variables
+   USE sbcana          ! surface boundary condition: analytical formulation
+   USE sbcflx          ! surface boundary condition: flux formulation
+   USE sbcblk_clio     ! surface boundary condition: bulk formulation : CLIO
+   USE sbcblk_core     ! surface boundary condition: bulk formulation : CORE
+   USE sbcice_if       ! surface boundary condition: ice-if sea-ice model
+   USE sbcice_lim      ! surface boundary condition: LIM 3.0 sea-ice model
+   USE sbcice_lim_2    ! surface boundary condition: LIM 2.0 sea-ice model
+   USE sbccpl          ! surface boundary condition: coupled florulation
+   USE cpl_oasis3, ONLY:lk_cpl      ! are we in coupled mode?
+   USE sbcssr          ! surface boundary condition: sea surface restoring
+   USE sbcrnf          ! surface boundary condition: runoffs
+   USE sbcfwb          ! surface boundary condition: freshwater budget
+   USE closea          ! closed sea
+
+   USE prtctl          ! Print control                    (prt_ctl routine)
+   USE restart         ! ocean restart
+   USE iom
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc        ! routine called by step.F90
+   PUBLIC   sbc_init   ! routine called by opa.F90
+   
+   INTEGER ::   nsbc   ! type of surface boundary condition (deduced from namsbc informations)
+      
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_init
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc_init ***
+      !!
+      !! ** Purpose :   Initialisation of the ocean surface boundary computation
+      !!
+      !! ** Method  :   Read the namsbc namelist and set derived parameters
+      !!
+      !! ** Action  : - read namsbc parameters
+      !!              - nsbc: type of sbc
+      !!----------------------------------------------------------------------
+      INTEGER ::   icpt      ! temporary integer
+      !!
+      NAMELIST/namsbc/ nn_fsbc, ln_ana, ln_flx, ln_blk_clio, ln_blk_core, ln_cpl,   &
+         &             nn_ice , ln_dm2dc, ln_rnf, ln_ssr, nn_fwb, nn_ico_cpl
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'sbc_init : surface boundary condition setting'
+         WRITE(numout,*) '~~~~~~~~ '
+      ENDIF
+
+      REWIND( numnam )                   ! Read Namelist namsbc
+      READ  ( numnam, namsbc )
+
+      ! overwrite namelist parameter using CPP key information
+!!gm here no overwrite, test all option via namelist change: require more incore memory
+!!gm  IF( lk_sbc_cpl       ) THEN   ;   ln_cpl      = .TRUE.   ;   ELSE   ;   ln_cpl      = .FALSE.   ;   ENDIF
+
+      IF ( Agrif_Root() ) THEN
+        IF( lk_lim2 )            nn_ice      = 2
+        IF( lk_lim3 )            nn_ice      = 3
+      ENDIF
+      !
+      IF( cp_cfg == 'gyre' ) THEN
+          ln_ana      = .TRUE.   
+          nn_ice      =   0
+      ENDIF
+      
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*) '        Namelist namsbc (partly overwritten with CPP key setting)'
+         WRITE(numout,*) '           frequency update of sbc (and ice)             nn_fsbc     = ', nn_fsbc
+         WRITE(numout,*) '           Type of sbc : '
+         WRITE(numout,*) '              analytical formulation                     ln_ana      = ', ln_ana
+         WRITE(numout,*) '              flux       formulation                     ln_flx      = ', ln_flx
+         WRITE(numout,*) '              CLIO bulk  formulation                     ln_blk_clio = ', ln_blk_clio
+         WRITE(numout,*) '              CLIO bulk  formulation                     ln_blk_core = ', ln_blk_core
+         WRITE(numout,*) '              coupled    formulation (T if key_sbc_cpl)  ln_cpl      = ', ln_cpl
+         WRITE(numout,*) '           Misc. options of sbc : '
+         WRITE(numout,*) '              ice management in the sbc (=0/1/2/3)       nn_ice      = ', nn_ice 
+         WRITE(numout,*) '              ice-ocean stress computation (=0/1/2)      nn_ico_cpl  = ', nn_ico_cpl
+         WRITE(numout,*) '              daily mean to diurnal cycle qsr            ln_dm2dc    = ', ln_dm2dc 
+         WRITE(numout,*) '              runoff / runoff mouths                     ln_rnf      = ', ln_rnf
+         WRITE(numout,*) '              Sea Surface Restoring on SST and/or SSS    ln_ssr      = ', ln_ssr
+         WRITE(numout,*) '              FreshWater Budget control  (=0/1/2)        nn_fwb      = ', nn_fwb
+         WRITE(numout,*) '              closed sea (=0/1) (set in namdom)          nn_closea   = ', nn_closea
+      ENDIF
+
+      IF( .NOT. ln_rnf ) THEN                      ! no specific treatment in vicinity of river mouths 
+         ln_rnf_mouth  = .false.                      
+         nkrnf         = 0
+         rnfmsk  (:,:) = 0.e0
+         rnfmsk_z(:)   = 0.e0
+      ENDIF
+      IF( nn_ice == 0  )   fr_i(:,:) = 0.e0        ! no ice in the domain, ice fraction is always zero
+
+      !                                            ! restartability   
+      IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 .OR.   &
+          MOD( nstock             , nn_fsbc) /= 0 ) THEN 
+         WRITE(ctmp1,*) 'experiment length (', nitend - nit000 + 1, ') or nstock (', nstock,   &
+            &           ' is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+         CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+      ENDIF
+      !
+      IF( MOD( rday, REAL(nn_fsbc, wp) * rdt ) /= 0 )   &
+         &  CALL ctl_warn( 'nn_fsbc is NOT a multiple of the number of time steps in a day' )
+      !
+      IF( nn_ice == 2 .AND. .NOT.( ln_blk_clio .OR. ln_blk_core .OR. lk_cpl ) )   &
+         &   CALL ctl_stop( 'sea-ice model requires a bulk formulation or coupled configuration' )
+      
+      ! Choice of the Surface Boudary Condition (set nsbc)
+      icpt = 0
+      IF( ln_ana          ) THEN   ;   nsbc =  1   ; icpt = icpt + 1   ;   ENDIF       ! analytical      formulation
+      IF( ln_flx          ) THEN   ;   nsbc =  2   ; icpt = icpt + 1   ;   ENDIF       ! flux            formulation
+      IF( ln_blk_clio     ) THEN   ;   nsbc =  3   ; icpt = icpt + 1   ;   ENDIF       ! CLIO bulk       formulation
+      IF( ln_blk_core     ) THEN   ;   nsbc =  4   ; icpt = icpt + 1   ;   ENDIF       ! CORE bulk       formulation
+      IF( ln_cpl          ) THEN   ;   nsbc =  5   ; icpt = icpt + 1   ;   ENDIF       ! Coupled         formulation
+      IF( cp_cfg == 'gyre') THEN   ;   nsbc =  0                       ;   ENDIF       ! GYRE analytical formulation
+      IF( lk_esopa        )            nsbc = -1                                       ! esopa test, ALL formulations
+
+      IF( icpt /= 1 .AND. .NOT.lk_esopa ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '           E R R O R in setting the sbc, one and only one namelist/CPP key option '
+         WRITE(numout,*) '                     must be choosen. You choose ', icpt, ' option(s)'
+         WRITE(numout,*) '                     We stop'
+         nstop = nstop + 1
+      ENDIF
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nsbc == -1 )   WRITE(numout,*) '              ESOPA test All surface boundary conditions'
+         IF( nsbc ==  0 )   WRITE(numout,*) '              GYRE analytical formulation'
+         IF( nsbc ==  1 )   WRITE(numout,*) '              analytical formulation'
+         IF( nsbc ==  2 )   WRITE(numout,*) '              flux formulation'
+         IF( nsbc ==  3 )   WRITE(numout,*) '              CLIO bulk formulation'
+         IF( nsbc ==  4 )   WRITE(numout,*) '              CORE bulk formulation'
+         IF( nsbc ==  5 )   WRITE(numout,*) '              coupled formulation'
+      ENDIF
+      !
+   END SUBROUTINE sbc_init
+
+
+   SUBROUTINE sbc( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE sbc  ***
+      !!              
+      !! ** Purpose :   provide at each time-step the ocean surface boundary
+      !!                condition (momentum, heat and freshwater fluxes)
+      !!
+      !! ** Method  :   blah blah  to be written ????????? 
+      !!                CAUTION : never mask the surface stress field (tke sbc)
+      !!
+      !! ** Action  : - set the ocean surface boundary condition, i.e.  
+      !!                utau, vtau, qns, qsr, emp, emps, qrp, erp
+      !!              - updte the ice fraction : fr_i
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! ocean time step
+      !!---------------------------------------------------------------------
+
+      CALL iom_setkt( kt + nn_fsbc - 1 )         !  in sbc, iom_put is called every nn_fsbc time step
+      !
+      ! ocean to sbc mean sea surface variables (ss._m)
+      ! ---------------------------------------
+      CALL sbc_ssm( kt )                         ! sea surface mean currents (at U- and V-points), 
+      !                                          ! temperature and salinity (at T-point) over nf_sbc time-step
+      !                                          ! (i.e. sst_m, sss_m, ssu_m, ssv_m)
+
+      ! sbc formulation
+      ! ---------------
+         
+      SELECT CASE( nsbc )                        ! Compute ocean surface boundary condition
+      !                                          ! (i.e. utau,vtau, qns, qsr, emp, emps)
+      CASE(  0 )   ;   CALL sbc_gyre    ( kt )                    ! analytical formulation : GYRE configuration
+      CASE(  1 )   ;   CALL sbc_ana     ( kt )                    ! analytical formulation : uniform sbc
+      CASE(  2 )   ;   CALL sbc_flx     ( kt )                    ! flux formulation
+      CASE(  3 )   ;   CALL sbc_blk_clio( kt )                    ! bulk formulation : CLIO for the ocean
+      CASE(  4 )   ;   CALL sbc_blk_core( kt )                    ! bulk formulation : CORE for the ocean
+      CASE(  5 )   ;   CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! coupled formulation
+      CASE( -1 )                                
+                       CALL sbc_ana     ( kt )                    ! ESOPA, test ALL the formulations
+                       CALL sbc_gyre    ( kt )                    !
+                       CALL sbc_flx     ( kt )                    !
+                       CALL sbc_blk_clio( kt )                    !
+                       CALL sbc_blk_core( kt )                    !
+                       CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   !
+      END SELECT
+
+      ! Misc. Options
+      ! -------------
+
+!!gm  IF( ln_dm2dc       )   CALL sbc_dcy( kt )                 ! Daily mean qsr distributed over the Diurnal Cycle
+      
+      SELECT CASE( nn_ice )                                     ! Update heat and freshwater fluxes over sea-ice areas
+      CASE(  1 )   ;       CALL sbc_ice_if   ( kt )                   ! Ice-cover climatology ("Ice-if" model)
+         !                                                      
+      CASE(  2 )   ;       CALL sbc_ice_lim_2( kt, nsbc )             ! LIM 2.0 ice model
+         !                                                     
+      CASE(  3 )   ;       CALL sbc_ice_lim  ( kt, nsbc, nn_ico_cpl)  ! LIM 3.0 ice model
+      END SELECT                                              
+
+      IF( ln_rnf       )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
+ 
+      IF( ln_ssr       )   CALL sbc_ssr( kt )                   ! add SST/SSS damping term
+
+      IF( nn_fwb  /= 0 )   CALL sbc_fwb( kt, nn_fwb, nn_fsbc )  ! control the freshwater budget
+
+      IF( nclosea == 1 )   CALL sbc_clo( kt )                   ! treatment of closed sea in the model domain 
+      !                                                         ! (update freshwater fluxes)
+      !
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+         CALL iom_put( "emp"    , emp       )                   ! upward water flux
+         CALL iom_put( "emps"   , emps      )                   ! c/d water flux
+         CALL iom_put( "qns+qsr", qns + qsr )                   ! total heat flux   (caution if ln_dm2dc=true, to be 
+         CALL iom_put( "qns"    , qns       )                   ! solar heat flux    moved after the call to iom_setkt)
+         CALL iom_put( "qsr"    ,       qsr )                   ! solar heat flux    moved after the call to iom_setkt)
+         IF(  nn_ice > 0 )   CALL iom_put( "ice_cover", fr_i )  ! ice fraction 
+      ENDIF
+      !
+      CALL iom_setkt( kt )           ! iom_put outside of sbc is called at every time step
+      !
+      CALL iom_put( "utau", utau )   ! i-wind stress   (stress can be updated at 
+      CALL iom_put( "vtau", vtau )   ! j-wind stress    each time step in sea-ice)
+      CALL iom_put( "taum", taum )   ! wind stress module 
+      CALL iom_put( "wspd", wndm )   ! wind speed  module 
+      !
+      IF(ln_ctl) THEN         ! print mean trends (used for debugging)
+         CALL prt_ctl(tab2d_1=fr_i   , clinfo1=' fr_i - : ', mask1=tmask, ovlap=1 )
+         CALL prt_ctl(tab2d_1=emp    , clinfo1=' emp  - : ', mask1=tmask, ovlap=1 )
+         CALL prt_ctl(tab2d_1=emps   , clinfo1=' emps - : ', mask1=tmask, ovlap=1 )
+         CALL prt_ctl(tab2d_1=qns    , clinfo1=' qns  - : ', mask1=tmask, ovlap=1 )
+         CALL prt_ctl(tab2d_1=qsr    , clinfo1=' qsr  - : ', mask1=tmask, ovlap=1 )
+         CALL prt_ctl(tab3d_1=tmask  , clinfo1=' tmask  : ', mask1=tmask, ovlap=1, kdim=jpk )
+         CALL prt_ctl(tab3d_1=tn     , clinfo1=' sst  - : ', mask1=tmask, ovlap=1, kdim=1   )
+         CALL prt_ctl(tab3d_1=sn     , clinfo1=' sss  - : ', mask1=tmask, ovlap=1, kdim=1   )
+         CALL prt_ctl(tab2d_1=utau   , clinfo1=' utau - : ', mask1=umask,                      &
+            &         tab2d_2=vtau   , clinfo2=' vtau - : ', mask2=vmask, ovlap=1 )
+      ENDIF
+      !
+   END SUBROUTINE sbc
+
+   !!======================================================================
+END MODULE sbcmod
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 1844)
@@ -0,0 +1,260 @@
+MODULE sbcrnf
+   !!======================================================================
+   !!                       ***  MODULE  sbcrnf  ***
+   !! Ocean forcing:  river runoff
+   !!=====================================================================
+   !! History :  OPA  !  2000-11  (R. Hordoir, E. Durand)  NetCDF FORMAT
+   !!   NEMO     1.0  !  2002-09  (G. Madec)  F90: Free form and module
+   !!            3.0  !  2006-07  (G. Madec)  Surface module 
+   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_rnf      : monthly runoffs read in a NetCDF file
+   !!   sbc_rnf_init : runoffs initialisation
+   !!   rnf_mouth    : set river mouth mask
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE sbc_oce         ! surface boundary condition variables
+   USE fldread         ! ???
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sbc_rnf          ! routine call in step module
+
+   !                                                     !!* namsbc_rnf namelist *
+   CHARACTER(len=100), PUBLIC ::   cn_dir       = './'    !: Root directory for location of ssr files
+   LOGICAL           , PUBLIC ::   ln_rnf_emp   = .false. !: runoffs into a file to be read or already into precipitation
+   TYPE(FLD_N)       , PUBLIC ::   sn_rnf                 !: information about the runoff file to be read
+   TYPE(FLD_N)       , PUBLIC ::   sn_cnf                 !: information about the runoff mouth file to be read
+   LOGICAL           , PUBLIC ::   ln_rnf_mouth = .false. !: specific treatment in mouths vicinity
+   REAL(wp)          , PUBLIC ::   rn_hrnf      = 0.e0    !: runoffs, depth over which enhanced vertical mixing is used
+   REAL(wp)          , PUBLIC ::   rn_avt_rnf   = 0.e0    !: runoffs, value of the additional vertical mixing coef. [m2/s]
+   REAL(wp)          , PUBLIC ::   rn_rfact     = 1.e0    !: multiplicative factor for runoff
+
+   INTEGER , PUBLIC                     ::   nkrnf = 0   !: number of levels over which Kz is increased at river mouths
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk      !: river mouth mask (hori.)
+   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z    !: river mouth mask (vert.)
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf   ! structure of input SST (file information, fields read)
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_rnf( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_rnf  ***
+      !!       
+      !! ** Purpose :   Introduce a climatological run off forcing
+      !!
+      !! ** Method  :   Set each river mouth with a monthly climatology 
+      !!                provided from different data.
+      !!                CAUTION : upward water flux, runoff forced to be < 0
+      !!
+      !! ** Action  :   runoff updated runoff field at time-step kt
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt          ! ocean time step
+      !!
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      INTEGER  ::   ierror   ! temporary integer
+      !!----------------------------------------------------------------------
+      !                                   
+      IF( kt == nit000 ) THEN  
+         IF( .NOT. ln_rnf_emp ) THEN
+            ALLOCATE( sf_rnf(1), STAT=ierror )
+            IF( ierror > 0 ) THEN
+               CALL ctl_stop( 'sbc_rnf: unable to allocate sf_rnf structure' )   ;   RETURN
+            ENDIF
+            ALLOCATE( sf_rnf(1)%fnow(jpi,jpj) )
+            ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,2) )
+         ENDIF
+         CALL sbc_rnf_init(sf_rnf)
+      ENDIF
+
+      !                                                   !-------------------!
+      IF( .NOT. ln_rnf_emp ) THEN                         !   Update runoff   !
+         !                                                !-------------------!
+         !
+         CALL fld_read( kt, nn_fsbc, sf_rnf )   ! Read Runoffs data and provides it
+         !                                      ! at the current time-step
+
+         ! Runoff reduction only associated to the ORCA2_LIM configuration
+         ! when reading the NetCDF file runoff_1m_nomask.nc
+         IF( cp_cfg == 'orca' .AND. jp_cfg == 2 )   THEN
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( gphit(ji,jj) > 40 .AND. gphit(ji,jj) < 65 )   sf_rnf(1)%fnow(ji,jj) = 0.85 * sf_rnf(1)%fnow(ji,jj)
+               END DO
+            END DO
+         ENDIF
+
+         ! C a u t i o n : runoff is negative and in kg/m2/s 
+
+         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
+            emp (:,:) = emp (:,:) - rn_rfact * ABS( sf_rnf(1)%fnow(:,:) )
+            emps(:,:) = emps(:,:) - rn_rfact * ABS( sf_rnf(1)%fnow(:,:) )
+            CALL iom_put( "runoffs", sf_rnf(1)%fnow )         ! runoffs
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_rnf
+
+
+   SUBROUTINE sbc_rnf_init( sf_rnf )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_rnf_init  ***
+      !!
+      !! ** Purpose :   Initialisation of the runoffs if (ln_rnf=T)
+      !!
+      !! ** Method  : - read the runoff namsbc_rnf namelist
+      !!
+      !! ** Action  : - read parameters
+      !!----------------------------------------------------------------------
+      TYPE(FLD), INTENT(inout), DIMENSION(:) :: sf_rnf   ! input data
+      !!
+      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, sn_rnf, sn_cnf, ln_rnf_mouth,   &
+         &                 rn_hrnf, rn_avt_rnf, rn_rfact
+      !!----------------------------------------------------------------------
+
+      !                                   ! ============
+      !                                   !   Namelist
+      !                                   ! ============
+      ! (NB: frequency positive => hours, negative => months)
+      !            !   file    ! frequency !  variable  ! time intep !  clim  ! 'yearly' or ! weights  ! rotation   !
+      !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F) !  'monthly'  ! filename ! pairs      !
+      sn_rnf = FLD_N( 'runoffs',    -1     , 'sorunoff' ,  .TRUE.    , .true. ,   'yearly'  , ''       , ''         )
+      sn_cnf = FLD_N( 'runoffs',     0     , 'sorunoff' ,  .FALSE.   , .true. ,   'yearly'  , ''       , ''         )
+
+      !
+      REWIND ( numnam )                         ! Read Namelist namsbc_rnf
+      READ   ( numnam, namsbc_rnf )
+
+      !                                         ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'sbc_rnf : runoff '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namsbc_rnf'
+         WRITE(numout,*) '      runoff in a file to be read                ln_rnf_emp   = ', ln_rnf_emp
+         WRITE(numout,*) '      specific river mouths treatment            ln_rnf_mouth = ', ln_rnf_mouth
+         WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf   = ', rn_avt_rnf
+         WRITE(numout,*) '      depth of river mouth additional mixing     rn_hrnf      = ', rn_hrnf
+         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact    
+      ENDIF
+
+      !                                   ! ==================
+      !                                   !   Type of runoff
+      !                                   ! ==================
+      !
+      IF( ln_rnf_emp ) THEN                     ! runoffs directly provided in the precipitations
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
+         !
+      ELSE                                      ! runoffs read in a file : set sf_rnf structure 
+         !
+         ! sf_rnf already allocated in main routine
+         ! fill sf_rnf with sn_rnf and control print
+         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' )
+         !
+      ENDIF
+
+      !                                   ! ========================
+      !                                   !   River mouth vicinity
+      !                                   ! ========================
+      !
+      IF( ln_rnf_mouth ) THEN                   ! Specific treatment in vicinity of river mouths :
+         !                                      !    - Increase Kz in surface layers ( rn_hrnf > 0 )
+         !                                      !    - set to zero SSS damping (ln_ssr=T)
+         !                                      !    - mixed upstream-centered (ln_traadv_cen2=T)
+         !
+         !                                          ! Number of level over which Kz increase
+         nkrnf = 0
+         IF( rn_hrnf > 0.e0 ) THEN
+            nkrnf = 2
+            DO WHILE( nkrnf /= jpkm1 .AND. gdepw_0(nkrnf+1) < rn_hrnf )   ;   nkrnf = nkrnf + 1   ;   END DO
+            IF( ln_sco )   &
+               CALL ctl_warn( 'sbc_rnf: number of levels over which Kz is increased is computed for zco...' )
+         ENDIF
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          Specific treatment used in vicinity of river mouths :'
+         IF(lwp) WRITE(numout,*) '             - Increase Kz in surface layers (if rn_hrnf > 0 )'
+         IF(lwp) WRITE(numout,*) '               by ', rn_avt_rnf,' m2/s  over ', nkrnf, ' w-levels'
+         IF(lwp) WRITE(numout,*) '             - set to zero SSS damping       (if ln_ssr=T)'
+         IF(lwp) WRITE(numout,*) '             - mixed upstream-centered       (if ln_traadv_cen2=T)'
+         !
+         CALL rnf_mouth                             ! set river mouth mask
+         !
+      ELSE                                      ! No treatment at river mouths
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          No specific treatment at river mouths'
+         rnfmsk  (:,:) = 0.e0 
+         rnfmsk_z(:)   = 0.e0
+         nkrnf = 0
+      ENDIF
+
+   END SUBROUTINE sbc_rnf_init
+
+
+   SUBROUTINE rnf_mouth
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE rnf_mouth  ***
+      !!       
+      !! ** Purpose :   define the river mouths mask
+      !!
+      !! ** Method  :   read the river mouth mask (=0/1) in the river runoff
+      !!                climatological file. Defined a given vertical structure. 
+      !!                CAUTION, the vertical structure is hard coded on the 
+      !!                first 5 levels.
+      !!                This fields can be used to:
+      !!                 - set an upstream advection scheme  
+      !!                   (ln_rnf_mouth=T and ln_traadv_cen2=T)
+      !!                 - increase vertical on the top nn_krnf vertical levels 
+      !!                   at river runoff input grid point (nn_krnf>=2, see step.F90)
+      !!                 - set to zero SSS restoring flux at river mouth grid points
+      !!
+      !! ** Action  :   rnfmsk   set to 1 at river runoff input, 0 elsewhere
+      !!                rnfmsk_z vertical structure
+      !!----------------------------------------------------------------------
+      USE closea, ONLY :    clo_rnf   ! rnfmsk update routine
+      !
+      INTEGER           ::   inum        ! temporary integers
+      CHARACTER(len=32) ::   cl_rnfile   ! runoff file name
+      !!----------------------------------------------------------------------
+      ! 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'rnf_mouth : river mouth mask'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
+
+      cl_rnfile = TRIM( cn_dir )//TRIM( sn_cnf%clname )
+      IF( .NOT. sn_cnf%ln_clim ) THEN   ;   WRITE(cl_rnfile, '(a,"_y",i4)' ) TRIM( cl_rnfile ), nyear    ! add year
+         IF( sn_cnf%cltype == 'monthly' )   WRITE(cl_rnfile, '(a,"m",i2)'  ) TRIM( cl_rnfile ), nmonth   ! add month
+      ENDIF
+  
+      ! horizontal mask (read in NetCDF file)
+      CALL iom_open ( cl_rnfile, inum )                           ! open file
+      CALL iom_get  ( inum, jpdom_data, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
+      CALL iom_close( inum )                                      ! close file
+      
+      IF( nclosea == 1 )    CALL clo_rnf( rnfmsk )                ! closed sea inflow set as ruver mouth
+
+      rnfmsk_z(:)   = 0.e0                                        ! vertical structure 
+      rnfmsk_z(1)   = 1.0
+      rnfmsk_z(2)   = 1.0                                         ! **********
+      rnfmsk_z(3)   = 0.5                                         ! HARD CODED on the 5 first levels
+      rnfmsk_z(4)   = 0.25                                        ! **********
+      rnfmsk_z(5)   = 0.125
+      !         
+   END SUBROUTINE rnf_mouth
+   
+   !!======================================================================
+END MODULE sbcrnf
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssm.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 1844)
@@ -0,0 +1,154 @@
+MODULE sbcssm
+   !!======================================================================
+   !!                       ***  MODULE  sbcssm  ***
+   !! Surface module :  provide time-mean ocean surface variables
+   !!======================================================================
+   !! History :  9.0   !  06-07  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_ssm        : calculate sea surface mean currents, temperature,  
+   !!                    and salinity over nn_fsbc time-step
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE prtctl          ! Print control                    (prt_ctl routine)
+   USE restart         ! ocean restart
+   USE iom
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_ssm    ! routine called by step.F90
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ssm( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_oce  ***
+      !!                     
+      !! ** Purpose :   provide ocean surface variable to sea-surface boundary
+      !!                condition computation 
+      !!                
+      !! ** Method  :   compute mean surface velocity (2 components at U and 
+      !!      V-points) [m/s], temperature [Celcius] and salinity [psu] over
+      !!      the periode (kt - nn_fsbc) to kt
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt        ! ocean time step
+      !
+      REAL(wp) ::   zcoef       ! temporary scalar
+      REAL(wp) ::   zf_sbc      ! read sbc frequency 
+      !!---------------------------------------------------------------------
+      !                                                   ! ---------------------------------------- !
+      IF( nn_fsbc == 1 ) THEN                             !      Instantaneous surface fields        !
+         !                                                ! ---------------------------------------- !
+         IF( kt == nit000 ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields, nn_fsbc=1 : instantaneous values'
+            IF(lwp) WRITE(numout,*) '~~~~~~~ '
+         ENDIF
+         !
+         ssu_m(:,:) = ub(:,:,1)
+         ssv_m(:,:) = vb(:,:,1)
+         sst_m(:,:) = tn(:,:,1)
+         sss_m(:,:) = sn(:,:,1)
+         ssh_m(:,:) = sshn(:,:)
+         !
+      ELSE
+         !                                                ! ---------------------------------------- !
+         IF( kt == nit000) THEN                           !       Initialisation: 1st time-step      !
+            !                                             ! ---------------------------------------- !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields'
+            !
+            IF( ln_rstart .AND. iom_varid( numror, 'nn_fsbc', ldstop = .FALSE. ) > 0 ) THEN 
+               CALL iom_get( numror               , 'nn_fsbc', zf_sbc )   ! sbc frequency of previous run
+               CALL iom_get( numror, jpdom_autoglo, 'ssu_m'  , ssu_m  )   ! sea surface mean velocity    (T-point)
+               CALL iom_get( numror, jpdom_autoglo, 'ssv_m'  , ssv_m  )   !   "         "    velocity    (V-point)
+               CALL iom_get( numror, jpdom_autoglo, 'sst_m'  , sst_m  )   !   "         "    temperature (T-point)
+               CALL iom_get( numror, jpdom_autoglo, 'sss_m'  , sss_m  )   !   "         "    salinity    (T-point)
+               CALL iom_get( numror, jpdom_autoglo, 'ssh_m'  , ssh_m  )   !   "         "    height      (T-point)
+               !
+               IF( zf_sbc /= REAL( nn_fsbc, wp ) ) THEN      ! nn_fsbc has changed between 2 runs
+                  IF(lwp) WRITE(numout,*) '~~~~~~~   restart with a change in the frequency of mean ',   &
+                     &                    'from ', zf_sbc, ' to ', nn_fsbc
+                  zcoef = REAL( nn_fsbc - 1, wp ) / zf_sbc
+                  ssu_m(:,:) = zcoef * ssu_m(:,:)
+                  ssv_m(:,:) = zcoef * ssv_m(:,:)
+                  sst_m(:,:) = zcoef * sst_m(:,:)
+                  sss_m(:,:) = zcoef * sss_m(:,:)
+                  ssh_m(:,:) = zcoef * ssh_m(:,:)
+               ELSE
+                  IF(lwp) WRITE(numout,*) '~~~~~~~   mean fields read in the ocean restart file'
+               ENDIF
+            ELSE
+               IF(lwp) WRITE(numout,*) '~~~~~~~   mean fields initialised to instantaneous values'
+               zcoef = REAL( nn_fsbc - 1, wp )
+               ssu_m(:,:) = zcoef * ub(:,:,1)
+               ssv_m(:,:) = zcoef * vb(:,:,1)
+               sst_m(:,:) = zcoef * tn(:,:,1)
+               sss_m(:,:) = zcoef * sn(:,:,1)
+               ssh_m(:,:) = zcoef * sshn(:,:)
+            ENDIF
+            !                                             ! ---------------------------------------- !
+         ELSEIF( MOD( kt - 2 , nn_fsbc ) == 0 ) THEN      !   Initialisation: New mean computation   !
+            !                                             ! ---------------------------------------- !
+            ssu_m(:,:) = 0.e0      ! reset to zero ocean mean sbc fields
+            ssv_m(:,:) = 0.e0
+            sst_m(:,:) = 0.e0
+            sss_m(:,:) = 0.e0
+            ssh_m(:,:) = 0.e0
+         ENDIF
+         !                                                ! ---------------------------------------- !
+         !                                                !        Cumulate at each time step        !
+         !                                                ! ---------------------------------------- !
+         ssu_m(:,:) = ssu_m(:,:) + ub(:,:,1)
+         ssv_m(:,:) = ssv_m(:,:) + vb(:,:,1)
+         sst_m(:,:) = sst_m(:,:) + tn(:,:,1)
+         sss_m(:,:) = sss_m(:,:) + sn(:,:,1)
+         ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
+
+         !                                                ! ---------------------------------------- !
+         IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN          !   Mean value at each nn_fsbc time-step   !
+            !                                             ! ---------------------------------------- !
+            zcoef = 1. / REAL( nn_fsbc, wp )
+            sst_m(:,:) = sst_m(:,:) * zcoef           ! mean SST             [Celcius]
+            sss_m(:,:) = sss_m(:,:) * zcoef           ! mean SSS             [psu]
+            ssu_m(:,:) = ssu_m(:,:) * zcoef           ! mean suface current  [m/s]
+            ssv_m(:,:) = ssv_m(:,:) * zcoef           !
+            ssh_m(:,:) = ssh_m(:,:) * zcoef           ! mean SSH             [m]
+            !
+         ENDIF
+         !                                                ! ---------------------------------------- !
+         IF( lrst_oce ) THEN                              !      Write in the ocean restart file     !
+            !                                             ! ---------------------------------------- !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields written in ocean restart file ',   &
+               &                    'at it= ', kt,' date= ', ndastp
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
+            zf_sbc = REAL( nn_fsbc, wp )
+            CALL iom_rstput( kt, nitrst, numrow, 'nn_fsbc', zf_sbc )    ! sbc frequency
+            CALL iom_rstput( kt, nitrst, numrow, 'ssu_m'  , ssu_m  )    ! sea surface mean fields
+            CALL iom_rstput( kt, nitrst, numrow, 'ssv_m'  , ssv_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'sst_m'  , sst_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'sss_m'  , sss_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m  )
+            !
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_ssm
+
+   !!======================================================================
+END MODULE sbcssm
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 1844)
@@ -0,0 +1,202 @@
+MODULE sbcssr
+   !!======================================================================
+   !!                       ***  MODULE  sbcssr  ***
+   !! Surface module :  heat and fresh water fluxes a restoring term toward observed SST/SSS
+   !!======================================================================
+   !! History :  3.0  !  2006-06  (G. Madec)  Original code
+   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sbc_ssr        : add to sbc a restoring term toward SST/SSS climatology
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition
+   USE phycst          ! physical constants
+   USE sbcrnf          ! surface boundary condition : runoffs
+   USE fldread         ! read input fields
+   USE iom             ! I/O manager
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_ssr    ! routine called in sbcmod
+   
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   erp      !: evaporation damping   [kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qrp      !: heat flux damping        [w/m2]
+
+   !                                           !!* Namelist namsbc_ssr *
+   INTEGER, PUBLIC ::   nn_sstr     =   0       ! SST/SSS restoring indicator
+   INTEGER, PUBLIC ::   nn_sssr     =   0       ! SST/SSS restoring indicator
+   REAL(wp)        ::   rn_dqdt     = -40.e0    ! restoring factor on SST and SSS
+   REAL(wp)        ::   rn_deds     = -27.70    ! restoring factor on SST and SSS
+   LOGICAL         ::   ln_sssr_bnd = .false.   ! flag to bound erp term 
+   REAL(wp)        ::   rn_sssr_bnd =   0.e0    ! ABS(Max./Min.) value of erp term [mm/day]
+
+   REAL(wp) , ALLOCATABLE, DIMENSION(:) ::   buffer   ! Temporary buffer for exchange
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_sst   ! structure of input SST (file informations, fields read)
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_sss   ! structure of input SSS (file informations, fields read)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sbc_ssr( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_ssr  ***
+      !!
+      !! ** Purpose :   Add to heat and/or freshwater fluxes a damping term
+      !!                toward observed SST and/or SSS.
+      !!
+      !! ** Method  : - Read namelist namsbc_ssr
+      !!              - Read observed SST and/or SSS
+      !!              - at each nscb time step
+      !!                   add a retroaction term on qns    (nn_sstr = 1)
+      !!                   add a damping term on emps       (nn_sssr = 1)
+      !!                   add a damping term on emp & emps (nn_sssr = 2)
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt   ! ocean time step
+      !!
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zerp     ! local scalar for evaporation damping
+      REAL(wp) ::   zqrp     ! local scalar for heat flux damping
+      REAL(wp) ::   zsrp     ! local scalar for unit conversion of rn_deds factor
+      REAL(wp) ::   zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
+      INTEGER  ::   ierror   ! return error code
+      !!
+      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
+      TYPE(FLD_N) ::   sn_sst, sn_sss        ! informations about the fields to be read
+      NAMELIST/namsbc_ssr/ cn_dir, nn_sstr, nn_sssr, rn_dqdt, rn_deds, sn_sst, sn_sss, ln_sssr_bnd, rn_sssr_bnd
+      !!----------------------------------------------------------------------
+      !
+      !                                               ! -------------------- !
+      IF( kt == nit000 ) THEN                         ! First call kt=nit000 !
+         !                                            ! -------------------- !
+         !                            !* set file information
+         cn_dir  = './'            ! directory in which the model is executed
+         ! ... default values (NB: frequency positive => hours, negative => months)
+         !            !   file    ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
+         !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
+         sn_sst = FLD_N( 'sst'    ,    24     ,  'sst'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+         sn_sss = FLD_N( 'sss'    ,    -1     ,  'sss'     ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
+
+         REWIND ( numnam )            !* read in namlist namflx
+         READ( numnam, namsbc_ssr ) 
+
+         IF(lwp) THEN                 !* control print
+            WRITE(numout,*)
+            WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
+            WRITE(numout,*) '~~~~~~~ '
+            WRITE(numout,*) '   Namelist namsbc_ssr :'
+            WRITE(numout,*) '      SST restoring term (Yes=1)             nn_sstr     = ', nn_sstr
+            WRITE(numout,*) '      SSS damping term (Yes=1, salt flux)    nn_sssr     = ', nn_sssr
+            WRITE(numout,*) '                       (Yes=2, volume flux) '
+            WRITE(numout,*) '      dQ/dT (restoring magnitude on SST)     rn_dqdt     = ', rn_dqdt, ' W/m2/K'
+            WRITE(numout,*) '      dE/dS (restoring magnitude on SST)     rn_deds     = ', rn_deds, ' mm/day'
+            WRITE(numout,*) '      flag to bound erp term                 ln_sssr_bnd = ', ln_sssr_bnd
+            WRITE(numout,*) '      ABS(Max./Min.) erp threshold           rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
+         ENDIF
+
+         IF( nn_sstr == 1 ) THEN      !* set sf_sst structure
+            !
+            ALLOCATE( sf_sst(1), STAT=ierror )
+            IF( ierror > 0 ) THEN
+               CALL ctl_stop( 'sbc_ssr: unable to allocate sf_sst structure' )   ;   RETURN
+            ENDIF
+            ALLOCATE( sf_sst(1)%fnow(jpi,jpj) )
+            ALLOCATE( sf_sst(1)%fdta(jpi,jpj,2) )
+            !
+            ! fill sf_sst with sn_sst and control print
+            CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr' )
+         ENDIF
+         !
+         IF( nn_sssr >= 1 ) THEN      ! set sf_sss structure
+            !
+            ALLOCATE( sf_sss(1), STAT=ierror )
+            IF( ierror > 0 ) THEN
+               CALL ctl_stop( 'sbc_ssr: unable to allocate sf_sss structure' )   ;   RETURN
+            ENDIF
+            ALLOCATE( sf_sss(1)%fnow(jpi,jpj) )
+            ALLOCATE( sf_sss(1)%fdta(jpi,jpj,2) )
+            !
+            ! fill sf_sss with sn_sss and control print
+            CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr' )
+         ENDIF
+         !
+         ! Initialize qrp and erp if no restoring 
+         IF( nn_sstr /= 1                   )   qrp(:,:) = 0.e0 
+         IF( nn_sssr /= 1 .OR. nn_sssr /= 2 )   erp(:,:) = 0.e0 
+      ENDIF
+
+      IF( nn_sstr + nn_sssr /= 0 ) THEN
+         !
+         IF( nn_sstr == 1)   CALL fld_read( kt, nn_fsbc, sf_sst )   ! Read SST data and provides it at kt
+         IF( nn_sssr >= 1)   CALL fld_read( kt, nn_fsbc, sf_sss )   ! Read SSS data and provides it at kt
+         !
+         !                                         ! ========================= !
+         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN      !    Add restoring term     !
+            !                                      ! ========================= !
+            !
+            IF( nn_sstr == 1 ) THEN                   !* Temperature restoring term
+!CDIR COLLAPSE
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zqrp = rn_dqdt * ( sst_m(ji,jj) - sf_sst(1)%fnow(ji,jj) )
+                     qns(ji,jj) = qns(ji,jj) + zqrp
+                     qrp(ji,jj) = zqrp
+                  END DO
+               END DO
+               CALL iom_put( "qrp", qrp )                             ! heat flux damping
+            ENDIF
+            !
+            IF( nn_sssr == 1 ) THEN                   !* Salinity damping term (salt flux, emps only)
+               zsrp = rn_deds / rday                                  ! from [mm/day] to [kg/m2/s]
+!CDIR COLLAPSE
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) )   &      ! No damping in vicinity of river mouths
+                        &        * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj) )   &
+                        &        / ( sss_m(ji,jj) + 1.e-20   )
+                     emps(ji,jj) = emps(ji,jj) + zerp
+                     erp( ji,jj) = zerp
+                  END DO
+               END DO
+               CALL iom_put( "erp", erp )                             ! freshwater flux damping
+               !
+            ELSEIF( nn_sssr == 2 ) THEN               !* Salinity damping term (volume flux, emp and emps)
+               zsrp = rn_deds / rday                                  ! from [mm/day] to [kg/m2/s]
+               zerp_bnd = rn_sssr_bnd / rday                          !       -              -    
+!CDIR COLLAPSE
+               DO jj = 1, jpj
+                  DO ji = 1, jpi                            
+                     zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) )   &      ! No damping in vicinity of river mouths
+                        &        * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj) )   &
+                        &        / ( sss_m(ji,jj) + 1.e-20   )
+                     IF( ln_sssr_bnd )   zerp = SIGN( 1., zerp ) * MIN( zerp_bnd, ABS(zerp) )
+                     emp (ji,jj) = emp (ji,jj) + zerp
+                     emps(ji,jj) = emps(ji,jj) + zerp
+                     erp (ji,jj) = zerp
+                  END DO
+               END DO
+               CALL iom_put( "erp", erp )                             ! freshwater flux damping
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE sbc_ssr
+      
+   !!======================================================================
+END MODULE sbcssr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/sol_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/sol_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/sol_oce.F90	(revision 1844)
@@ -0,0 +1,56 @@
+MODULE sol_oce
+   !!======================================================================
+   !!                    ***  MODULE  sol_oce  ***
+   !! Ocean solver :  elliptic solver variables defined in memory 
+   !!======================================================================
+   !! History :  1.0  !  02-11  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !                                             !!* Namelist namsol : elliptic solver *
+   INTEGER , PUBLIC ::   nn_solv    =    1        !: = 1/2 type of elliptic solver
+   INTEGER , PUBLIC ::   nn_sol_arp =    0        !: = 0/1 absolute/relative precision convergence test
+   INTEGER , PUBLIC ::   nn_nmin    =  300        !: minimum of iterations for the SOR solver
+   INTEGER , PUBLIC ::   nn_nmax    =  800        !: maximum of iterations for the SOR solver
+   INTEGER , PUBLIC ::   nn_nmod    =   10        !: frequency of test for the SOR solver
+   REAL(wp), PUBLIC ::   rn_eps     =  1.e-6_wp   !: absolute precision of the solver
+   REAL(wp), PUBLIC ::   rn_resmax  = 1.e-14_wp   !: absolute precision for the SOR solver
+   REAL(wp), PUBLIC ::   rn_sor     =   1.92_wp   !: optimal coefficient for the SOR solver
+   REAL(wp), PUBLIC ::   rn_nu      =    1.0_wp   !: strength of the additional force used in free surface
+
+   CHARACTER(len=1), PUBLIC ::   c_solver_pt = 'T'   !: nature of grid-points T (S) for free surface case
+
+   INTEGER , PUBLIC ::   ncut        !: indicator of solver convergence
+   INTEGER , PUBLIC ::   niter       !: number of iteration done by the solver
+
+   REAL(wp), PUBLIC ::   eps, epsr   !: relative precision for SOR & PCG solvers
+   REAL(wp), PUBLIC ::   rnorme      !: intermediate modulus
+   REAL(wp), PUBLIC ::   res         !: solver residu
+   REAL(wp), PUBLIC ::   alph        !: coefficient  =(gcr,gcr)/(gcx,gccd)
+   REAL(wp), PUBLIC ::   beta        !: coefficient  =(rn+1,rn+1)/(rn,rn)
+   REAL(wp), PUBLIC ::   radd        !: coefficient  =(gccd,gcdes)
+   REAL(wp), PUBLIC ::   rr          !: coefficient  =(rn,rn)
+
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj,4) ::   gcp     !: matrix extra-diagonal elements
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcx     !: now    solution of the elliptic eq.
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcxb    !: before solution of the elliptic eq.
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcdprc  !: inverse diagonal preconditioning matrix
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcdmat  !: diagonal preconditioning matrix
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcb     !: second member of the elliptic eq.
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcr     !: residu =b-a.x
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gcdes   !: vector descente
+   REAL(wp), PUBLIC, DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)   ::   gccd    !: gccd= gcdprc^-1.a.d 
+
+#if defined key_agrif
+      REAL(wp), DIMENSION(jpi,jpj) :: laplacu, laplacv
+#endif
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+END MODULE sol_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solmat.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solmat.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solmat.F90	(revision 1844)
@@ -0,0 +1,336 @@
+MODULE solmat
+   !!======================================================================
+   !!                       ***  MODULE  solmat  ***
+   !! solver       : construction of the matrix 
+   !!======================================================================
+   !! History :   1.0  ! 1988-04  (G. Madec)  Original code
+   !!                  ! 1993-03  (M. Guyon)  symetrical conditions
+   !!                  ! 1993-06  (M. Guyon)  suppress pointers
+   !!                  ! 1996-05  (G. Madec)  merge sor and pcg formulations
+   !!                  ! 1996-11  (A. Weaver)  correction to preconditioning
+   !!   NEMO      1.0  ! 1902-08  (G. Madec)  F90: Free form
+   !!              -   ! 1902-11  (C. Talandier, A-M. Treguier) Free surface & Open boundaries
+   !!             2.0  ! 2005-09  (R. Benshila)  add sol_exd for extra outer halo
+   !!              -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!             3.2  ! 2009-06  (S. Masson)  distributed restart using iom
+   !!              -   ! 2009-07  (R. Benshila)  suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sol_mat : Construction of the matrix of used by the elliptic solvers
+   !!   sol_exd :
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sol_oce         ! ocean solver
+   USE phycst          ! physical constants
+   USE obc_oce         ! ocean open boundary conditions
+   USE lbclnk          ! lateral boudary conditions
+   USE lib_mpp         ! distributed memory computing
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sol_mat    ! routine called by inisol.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE sol_mat( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sol_mat  ***
+      !!
+      !! ** Purpose :   Construction of the matrix of used by the elliptic 
+      !!              solvers (either sor or pcg methods).
+      !!
+      !! ** Method  :   The matrix is built for the divergence of the transport 
+      !!              system. a diagonal preconditioning matrix is also defined.
+      !! 
+      !! ** Action  : - gcp    : extra-diagonal elements of the matrix
+      !!              - gcdmat : preconditioning matrix (diagonal elements)
+      !!              - gcdprc : inverse of the preconditioning matrix
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      !!
+      INTEGER ::   ji, jj                    ! dummy loop indices
+      REAL(wp) ::   zcoefs, zcoefw, zcoefe, zcoefn  ! temporary scalars
+      REAL(wp) ::   z2dt, zcoef
+      !!----------------------------------------------------------------------
+
+      
+      ! 1. Construction of the matrix
+      ! -----------------------------
+      zcoef = 0.e0                          ! initialize to zero
+      gcp(:,:,1) = 0.e0
+      gcp(:,:,2) = 0.e0
+      gcp(:,:,3) = 0.e0
+      gcp(:,:,4) = 0.e0
+      !
+      gcdprc(:,:) = 0.e0
+      gcdmat(:,:) = 0.e0
+      !
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;   z2dt = rdt
+      ELSE                                        ;   z2dt = 2. * rdt
+      ENDIF
+
+#if defined key_dynspg_flt && ! defined key_obc
+
+      DO jj = 2, jpjm1                      ! matrix of free surface elliptic system
+         DO ji = 2, jpim1
+            zcoef = z2dt * z2dt * grav * bmask(ji,jj)
+            zcoefs = -zcoef * hv(ji  ,jj-1) * e1v(ji  ,jj-1) / e2v(ji  ,jj-1)    ! south coefficient
+            zcoefw = -zcoef * hu(ji-1,jj  ) * e2u(ji-1,jj  ) / e1u(ji-1,jj  )    ! west coefficient
+            zcoefe = -zcoef * hu(ji  ,jj  ) * e2u(ji  ,jj  ) / e1u(ji  ,jj  )    ! east coefficient
+            zcoefn = -zcoef * hv(ji  ,jj  ) * e1v(ji  ,jj  ) / e2v(ji  ,jj  )    ! north coefficient
+            gcp(ji,jj,1) = zcoefs
+            gcp(ji,jj,2) = zcoefw
+            gcp(ji,jj,3) = zcoefe
+            gcp(ji,jj,4) = zcoefn
+            gcdmat(ji,jj) = e1t(ji,jj) * e2t(ji,jj) * bmask(ji,jj)    &          ! diagonal coefficient
+               &          - zcoefs -zcoefw -zcoefe -zcoefn
+         END DO
+      END DO
+      
+#  elif defined key_dynspg_flt && defined key_obc
+
+      DO jj = 2, jpjm1                      ! matrix of free surface elliptic system with open boundaries
+         DO ji = 2, jpim1
+            zcoef = z2dt * z2dt * grav * bmask(ji,jj)
+            !                                    ! south coefficient
+            IF( lp_obc_south .AND. ( jj == njs0p1 ) ) THEN
+               zcoefs = -zcoef * hv(ji,jj-1) * e1v(ji,jj-1)/e2v(ji,jj-1)*(1.-vsmsk(ji,1))
+            ELSE
+               zcoefs = -zcoef * hv(ji,jj-1) * e1v(ji,jj-1)/e2v(ji,jj-1)
+            END IF
+            gcp(ji,jj,1) = zcoefs
+            !
+            !                                    ! west coefficient
+            IF( lp_obc_west  .AND. ( ji == niw0p1 ) ) THEN
+               zcoefw = -zcoef * hu(ji-1,jj) * e2u(ji-1,jj)/e1u(ji-1,jj)*(1.-uwmsk(jj,1))
+            ELSE
+               zcoefw = -zcoef * hu(ji-1,jj) * e2u(ji-1,jj)/e1u(ji-1,jj)
+            END IF
+            gcp(ji,jj,2) = zcoefw
+            !
+            !                                    ! east coefficient
+            IF( lp_obc_east  .AND. ( ji == nie0 ) ) THEN
+               zcoefe = -zcoef * hu(ji,jj) * e2u(ji,jj)/e1u(ji,jj)*(1.-uemsk(jj,1))
+            ELSE
+               zcoefe = -zcoef * hu(ji,jj) * e2u(ji,jj)/e1u(ji,jj)
+            END IF
+            gcp(ji,jj,3) = zcoefe
+            !
+            !                                    ! north coefficient
+            IF( lp_obc_north .AND. ( jj == njn0 ) ) THEN
+               zcoefn = -zcoef * hv(ji,jj) * e1v(ji,jj)/e2v(ji,jj)*(1.-vnmsk(ji,1))
+            ELSE
+               zcoefn = -zcoef * hv(ji,jj) * e1v(ji,jj)/e2v(ji,jj)
+            END IF
+            gcp(ji,jj,4) = zcoefn
+            !
+            !                                    ! diagonal coefficient
+            gcdmat(ji,jj) = e1t(ji,jj)*e2t(ji,jj)*bmask(ji,jj)   &
+               &            - zcoefs -zcoefw -zcoefe -zcoefn
+         END DO
+      END DO
+#endif
+
+      IF( .NOT. Agrif_Root() ) THEN   ! Fine grid boundaries
+         !
+         IF( nbondi == -1 .OR. nbondi == 2 )   bmask(2     ,:     ) = 0.e0
+         IF( nbondi ==  1 .OR. nbondi == 2 )   bmask(nlci-1,:     ) = 0.e0
+         IF( nbondj == -1 .OR. nbondj == 2 )   bmask(:     ,2     ) = 0.e0
+         IF( nbondj ==  1 .OR. nbondj == 2 )   bmask(:     ,nlcj-1) = 0.e0
+         !
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zcoef = z2dt * z2dt * grav * bmask(ji,jj)
+               !  south coefficient
+               IF( ( nbondj == -1 .OR. nbondj == 2 ) .AND. ( jj == 3 ) ) THEN
+                  zcoefs = -zcoef * hv(ji,jj-1) * e1v(ji,jj-1)/e2v(ji,jj-1)*(1.-vmask(ji,jj-1,1))
+               ELSE
+                  zcoefs = -zcoef * hv(ji,jj-1) * e1v(ji,jj-1)/e2v(ji,jj-1)
+               END IF
+               gcp(ji,jj,1) = zcoefs
+               ! 
+               !  west coefficient
+               IF( ( nbondi == -1 .OR. nbondi == 2 ) .AND. ( ji == 3 )  ) THEN
+                  zcoefw = -zcoef * hu(ji-1,jj) * e2u(ji-1,jj)/e1u(ji-1,jj)*(1.-umask(ji-1,jj,1))
+               ELSE
+                  zcoefw = -zcoef * hu(ji-1,jj) * e2u(ji-1,jj)/e1u(ji-1,jj)
+               END IF
+               gcp(ji,jj,2) = zcoefw
+               !
+               !   east coefficient
+               IF( ( nbondi == 1 .OR. nbondi == 2 ) .AND. ( ji == nlci-2 ) ) THEN
+                  zcoefe = -zcoef * hu(ji,jj) * e2u(ji,jj)/e1u(ji,jj)*(1.-umask(ji,jj,1))
+               ELSE
+                  zcoefe = -zcoef * hu(ji,jj) * e2u(ji,jj)/e1u(ji,jj)
+               END IF
+               gcp(ji,jj,3) = zcoefe
+               !
+               !   north coefficient
+               IF( ( nbondj == 1 .OR. nbondj == 2 ) .AND. ( jj == nlcj-2 ) ) THEN
+                  zcoefn = -zcoef * hv(ji,jj) * e1v(ji,jj)/e2v(ji,jj)*(1.-vmask(ji,jj,1))
+               ELSE
+                  zcoefn = -zcoef * hv(ji,jj) * e1v(ji,jj)/e2v(ji,jj)
+               END IF
+               gcp(ji,jj,4) = zcoefn
+               !
+               ! diagonal coefficient
+               gcdmat(ji,jj) = e1t(ji,jj)*e2t(ji,jj)*bmask(ji,jj)   &
+                  &            - zcoefs -zcoefw -zcoefe -zcoefn
+            END DO
+         END DO
+         ! 
+      ENDIF
+
+      ! 2. Boundary conditions 
+      ! ----------------------
+      
+      ! Cyclic east-west boundary conditions
+      !     ji=2 is the column east of ji=jpim1 and reciprocally,
+      !     ji=jpim1 is the column west of ji=2
+      !     all the coef are already set to zero as bmask is initialized to
+      !     zero for ji=1 and ji=jpj in dommsk.
+      
+      ! Symetrical conditions
+      ! free surface: no specific action
+      ! bsf system: n-s gradient of bsf = 0 along j=2 (perhaps a bug !!!!!!)
+      ! the diagonal coefficient of the southern grid points must be modify to
+      ! account for the existence of the south symmetric bassin.
+      
+      ! North fold boundary condition
+      !     all the coef are already set to zero as bmask is initialized to
+      !     zero on duplicated lignes and portion of lignes
+      
+      ! 3. Preconditioned matrix
+      ! ------------------------
+      
+      ! SOR and PCG solvers
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( bmask(ji,jj) /= 0.e0 )   gcdprc(ji,jj) = 1.e0 / gcdmat(ji,jj)
+         END DO
+      END DO
+         
+      gcp(:,:,1) = gcp(:,:,1) * gcdprc(:,:)
+      gcp(:,:,2) = gcp(:,:,2) * gcdprc(:,:)
+      gcp(:,:,3) = gcp(:,:,3) * gcdprc(:,:)
+      gcp(:,:,4) = gcp(:,:,4) * gcdprc(:,:)
+      IF( nn_solv == 2 )  gccd(:,:) = rn_sor * gcp(:,:,2)
+
+      IF( nn_solv == 2 .AND. MAX( jpr2di, jpr2dj ) > 0) THEN
+         CALL lbc_lnk_e( gcp   (:,:,1), c_solver_pt, 1. )   ! lateral boundary conditions
+         CALL lbc_lnk_e( gcp   (:,:,2), c_solver_pt, 1. )   ! lateral boundary conditions
+         CALL lbc_lnk_e( gcp   (:,:,3), c_solver_pt, 1. )   ! lateral boundary conditions
+         CALL lbc_lnk_e( gcp   (:,:,4), c_solver_pt, 1. )   ! lateral boundary conditions
+         CALL lbc_lnk_e( gcdprc(:,:)  , c_solver_pt, 1. )   ! lateral boundary conditions
+         CALL lbc_lnk_e( gcdmat(:,:)  , c_solver_pt, 1. )   ! lateral boundary conditions         
+         IF( npolj /= 0 ) CALL sol_exd( gcp , c_solver_pt ) ! switch northernelements
+      END IF
+   
+      ! 4. Initialization the arrays used in pcg
+      ! ----------------------------------------
+      gcb  (:,:) = 0.e0
+      gcr  (:,:) = 0.e0
+      gcdes(:,:) = 0.e0
+      gccd (:,:) = 0.e0
+      ! 
+   END SUBROUTINE sol_mat
+
+
+   SUBROUTINE sol_exd( pt3d, cd_type )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine sol_exd  ***
+      !!                  
+      !! ** Purpose :   Reorder gcb coefficient on the extra outer  halo 
+      !!                at north fold in case of T or F pivot
+      !!
+      !! ** Method  :   Perform a circular permutation of the coefficients on 
+      !!                the total area strictly above the pivot point,
+      !!                and on the semi-row of the pivot point   
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1) , INTENT( in ) ::   cd_type   ! define the nature of pt2d array grid-points
+         !                                           !  = T , U , V , F , W 
+         !                                           !  = S : T-point, north fold treatment
+         !                                           !  = G : F-point, north fold treatment
+         !                                           !  = I : sea-ice velocity at F-point with index shift
+      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj,4), INTENT(inout) ::   pt3d   ! 2D field to be treated
+      !!
+      INTEGER  ::   ji, jk   ! dummy loop indices
+      INTEGER  ::   iloc     ! temporary integers
+      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj,4) ::   ztab   ! 2D workspace
+      !!----------------------------------------------------------------------
+
+      ztab = pt3d
+
+      SELECT CASE ( npolj )            ! north fold type
+      ! 
+      CASE ( 3 , 4 )                        !==  T pivot  ==!
+         iloc = jpiglo/2 +1 
+         !   
+         SELECT CASE ( cd_type )
+         ! 
+         CASE ( 'T', 'S', 'U', 'W' )
+            DO jk = 1, 4
+               DO ji = 1-jpr2di, nlci+jpr2di
+                  pt3d(ji,nlcj:nlcj+jpr2dj,jk) = ztab(ji,nlcj:nlcj+jpr2dj,jk+3-2*MOD(jk+3,4))           
+               END DO
+            END DO
+            DO jk =1, 4
+               DO ji = nlci+jpr2di, 1-jpr2di,  -1
+                  IF( ( ji .LT. mi0(iloc) .AND. mi0(iloc) /= 1 ) &
+                     & .OR. ( mi0(iloc) == jpi+1 ) ) EXIT
+                     pt3d(ji,nlcj-1,jk) = ztab(ji,nlcj-1,jk+3-2*MOD(jk+3,4))
+               END DO
+            END DO
+            !
+         CASE ( 'F' ,'G' , 'I', 'V' )
+            DO jk =1, 4
+               DO ji = 1-jpr2di, nlci+jpr2di
+                  pt3d(ji,nlcj-1:nlcj+jpr2dj,jk) = ztab(ji,nlcj-1:nlcj+jpr2dj,jk+3-2*MOD(jk+3,4))           
+               END DO
+            END DO
+            !
+         END SELECT   ! cd_type
+          ! 
+      CASE ( 5 , 6 )                        !==  F pivot  ==!
+         iloc=jpiglo/2
+         !
+         SELECT CASE (cd_type )
+         !
+         CASE ( 'T'  ,'S', 'U', 'W')
+            DO jk =1, 4
+               DO ji = 1-jpr2di, nlci+jpr2di
+                  pt3d(ji,nlcj:nlcj+jpr2dj,jk) = ztab(ji,nlcj:nlcj+jpr2dj,jk+3-2*MOD(jk+3,4))           
+               END DO
+            END DO
+            !
+         CASE ( 'F' ,'G' , 'I', 'V' )
+            DO jk =1, 4
+               DO ji = 1-jpr2di, nlci+jpr2di
+                  pt3d(ji,nlcj:nlcj+jpr2dj,jk) = ztab(ji,nlcj:nlcj+jpr2dj,jk+3-2*MOD(jk+3,4))           
+               END DO
+            END DO
+            DO jk =1, 4
+               DO ji = nlci+jpr2di, 1-jpr2di,  -1
+                  IF( ( ji .LT. mi0(iloc) .AND. mi0(iloc) /= 1 ) .OR. ( mi0(iloc) == jpi+1 ) )   EXIT
+                    pt3d(ji,nlcj-1,jk) = ztab(ji,nlcj-1,jk+3-2*MOD(jk+3,4))
+               END DO
+            END DO
+            !
+         END SELECT   ! cd_type
+         !
+      END SELECT   ! npolj
+      !   
+   END SUBROUTINE sol_exd
+
+   !!======================================================================
+END MODULE solmat
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solpcg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solpcg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solpcg.F90	(revision 1844)
@@ -0,0 +1,215 @@
+MODULE solpcg
+   !!======================================================================
+   !!                     ***  MODULE  solfet
+   !! Ocean solver :  preconditionned conjugate gradient solver
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   sol_pcg    : preconditionned conjugate gradient solver
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE sol_oce         ! ocean solver variables
+   USE lib_mpp         ! distributed memory computing
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sol_pcg    ! 
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE sol_pcg( kindic )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sol_pcg  ***
+      !!                    
+      !! ** Purpose :   Solve the ellipic equation for the transport
+      !!      divergence system  using a diagonal preconditionned
+      !!      conjugate gradient method.
+      !!
+      !! ** Method  :   Diagonal preconditionned conjugate gradient method.
+      !!      the algorithm is multitasked. (case of 5 points matrix)
+      !!      define              pa  = q^-1 * a
+      !!                        pgcb  = q^-1 * gcb
+      !!                 < . ; . >_q  = ( . )^t q ( . )
+      !!      where q is the preconditioning matrix = diagonal matrix of the
+      !!                                              diagonal elements of a
+      !!      Initialization  :
+      !!         x(o) = gcx
+      !!         r(o) = d(o) = pgcb - pa.x(o)
+      !!         rr(o)= < r(o) , r(o) >_q
+      !!      Iteration 1     :
+      !!         standard PCG algorithm
+      !!      Iteration n > 1 :
+      !!         s(n)   = pa.r(n)
+      !!         gam(n) = < r(n) , r(n) >_q
+      !!         del(n) = < r(n) , s(n) >_q
+      !!         bet(n) = gam(n) / gam(n-1)
+      !!         d(n)   = r(n) + bet(n) d(n-1)
+      !!         z(n)   = s(n) + bet(n) z(n-1) 
+      !!         sig(n) = del(n) - bet(n)*bet(n)*sig(n-1) 
+      !!         alp(n) = gam(n) / sig(n) 
+      !!         x(n+1) = x(n) + alp(n) d(n)
+      !!         r(n+1) = r(n) - alp(n) z(n)
+      !!      Convergence test :
+      !!         rr(n+1) / < gcb , gcb >_q   =< epsr
+      !!
+      !! ** Action : - niter  : solver number of iteration done
+      !!             - res    : solver residu reached
+      !!             - gcx()  : solution of the elliptic system
+      !!
+      !! References :
+      !!      Madec et al. 1988, Ocean Modelling, issue 78, 1-6.
+      !!      D Azevedo et al. 1993, Computer Science Technical Report, Tennessee U.
+      !!
+      !! History :
+      !!        !  90-10  (G. Madec)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  93-04  (M. Guyon)  loops and suppress pointers
+      !!        !  95-09  (M. Imbard, J. Escobar)  mpp exchange 
+      !!        !  96-05  (G. Madec)  merge sor and pcg formulations
+      !!        !  96-11  (A. Weaver)  correction to preconditioning
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form
+      !!        !  08-01  (R. Benshila) mpp optimization
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( inout ) ::   kindic   ! solver indicator, < 0 if the conver-
+      !                                      ! gence is not reached: the model is
+      !                                      ! stopped in step
+      !                                      ! set to zero before the call of solpcg
+      !!
+      INTEGER ::   ji, jj, jn                ! dummy loop indices
+      REAL(wp) ::  zgcad                     ! temporary scalars
+      REAL(wp), DIMENSION(2) :: zsum
+      REAL(wp), DIMENSION(jpi,jpj) :: zgcr
+      !!----------------------------------------------------------------------
+
+      ! Initialization of the algorithm with standard PCG
+      ! -------------------------------------------------
+
+      CALL lbc_lnk( gcx, c_solver_pt, 1. )   ! lateral boundary condition
+
+      ! gcr   = gcb-a.gcx
+      ! gcdes = gcr
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zgcad = bmask(ji,jj) * ( gcb(ji,jj  ) -                gcx(ji  ,jj  )   &
+               &                                  - gcp(ji,jj,1) * gcx(ji  ,jj-1)   &
+               &                                  - gcp(ji,jj,2) * gcx(ji-1,jj  )   &
+               &                                  - gcp(ji,jj,3) * gcx(ji+1,jj  )   &
+               &                                  - gcp(ji,jj,4) * gcx(ji  ,jj+1)   )
+            gcr  (ji,jj) = zgcad
+            gcdes(ji,jj) = zgcad
+         END DO
+      END DO
+
+      ! rnorme = (gcr,gcr)
+      rnorme = SUM(  gcr(:,:) * gcdmat(:,:) * gcr(:,:)  )
+      IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain
+
+      CALL lbc_lnk( gcdes, c_solver_pt, 1. )   ! lateral boundary condition
+
+      ! gccd = matrix . gcdes
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            gccd(ji,jj) = bmask(ji,jj)*( gcdes(ji,jj)   &
+               &        +gcp(ji,jj,1)*gcdes(ji,jj-1)+gcp(ji,jj,2)*gcdes(ji-1,jj)   &
+               &        +gcp(ji,jj,4)*gcdes(ji,jj+1)+gcp(ji,jj,3)*gcdes(ji+1,jj)   )
+         END DO
+      END DO 
+
+      ! alph = (gcr,gcr)/(gcdes,gccd)
+      radd = SUM(  gcdes(:,:) * gcdmat(:,:) * gccd(:,:)  )
+      IF( lk_mpp )   CALL mpp_sum( radd )   ! sum over the global domain
+      alph = rnorme /radd
+
+      ! gcx = gcx + alph * gcdes
+      ! gcr = gcr - alph * gccd
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            gcx(ji,jj) = bmask(ji,jj) * ( gcx(ji,jj) + alph * gcdes(ji,jj) )
+            gcr(ji,jj) = bmask(ji,jj) * ( gcr(ji,jj) - alph * gccd (ji,jj) )
+         END DO
+      END DO
+
+      ! Algorithm wtih Eijkhout rearrangement
+      ! -------------------------------------
+        
+      !                                                !================
+      DO jn = 1, nn_nmax                               ! Iterative loop
+         !                                             !================
+
+         CALL lbc_lnk( gcr, c_solver_pt, 1. )   ! lateral boundary condition
+
+         ! zgcr = matrix . gcr
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zgcr(ji,jj) = bmask(ji,jj)*( gcr(ji,jj)   &
+                  &        +gcp(ji,jj,1)*gcr(ji,jj-1)+gcp(ji,jj,2)*gcr(ji-1,jj)   &
+                  &        +gcp(ji,jj,4)*gcr(ji,jj+1)+gcp(ji,jj,3)*gcr(ji+1,jj)   )
+            END DO
+         END DO
+ 
+         ! rnorme = (gcr,gcr)
+         rr = rnorme
+         zsum(1) = SUM(  gcr(:,:) * gcdmat(:,:) * gcr(:,:)  )
+
+         ! zgcad = (zgcr,gcr) 
+         zsum(2) = SUM( gcr(2:jpim1,2:jpjm1) * gcdmat(2:jpim1,2:jpjm1) * zgcr(2:jpim1,2:jpjm1) )
+
+         IF( lk_mpp )   CALL mpp_sum( zsum, 2 )   ! sum over the global domain
+         rnorme = zsum(1)  
+         zgcad  = zsum(2)
+
+         ! test of convergence
+         IF( rnorme < epsr .OR. jn == nn_nmax ) THEN
+            res = SQRT( rnorme )
+            niter = jn
+            ncut = 999
+         ENDIF
+
+         ! beta = (rk+1,rk+1)/(rk,rk)
+         beta = rnorme / rr
+         radd = zgcad - beta*beta*radd
+         alph = rnorme / radd
+
+         ! gcx = gcx + alph * gcdes
+         ! gcr = gcr - alph * gccd
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               gcdes(ji,jj) = gcr (ji,jj) + beta * gcdes(ji,jj) 
+               gccd (ji,jj) = zgcr(ji,jj) + beta * gccd (ji,jj) 
+               gcx  (ji,jj) = gcx (ji,jj) + alph * gcdes(ji,jj) 
+               gcr  (ji,jj) = gcr (ji,jj) - alph * gccd (ji,jj) 
+            END DO
+         END DO
+        
+         ! indicator of non-convergence or explosion
+         IF( jn == nn_nmax .OR. SQRT(epsr)/eps > 1.e+20 ) kindic = -2
+         IF( ncut == 999 ) GOTO 999
+
+         !                                             !================
+      END DO                                           !    End Loop
+      !                                                !================
+     
+999   CONTINUE
+     
+     
+      ! Output in gcx with lateral b.c. applied
+      ! ---------------------------------------
+     
+      CALL lbc_lnk( gcx, c_solver_pt, 1. )
+     
+   END SUBROUTINE sol_pcg
+
+   !!=====================================================================
+END MODULE solpcg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solsor.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solsor.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solsor.F90	(revision 1844)
@@ -0,0 +1,166 @@
+MODULE solsor
+   !!======================================================================
+   !!                     ***  MODULE  solsor  ***
+   !! Ocean solver :  Successive Over-Relaxation solver
+   !!=====================================================================
+   !! History :  OPA  ! 1990-10  (G. Madec)  Original code
+   !!            7.1  ! 1993-04  (G. Madec)  time filter
+   !!                 ! 1996-05  (G. Madec)  merge sor and pcg formulations
+   !!                 ! 1996-11  (A. Weaver)  correction to preconditioning
+   !!   NEMO     1.0  ! 2003-04  (C. Deltel, G. Madec)  Red-Black SOR in free form
+   !!            2.0  ! 2005-09  (R. Benshila, G. Madec)  MPI optimization
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   sol_sor     : Red-Black Successive Over-Relaxation solver
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE sol_oce         ! solver variables
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sol_sor    ! 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+      
+   SUBROUTINE sol_sor( kindic )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sol_sor  ***
+      !!                 
+      !! ** Purpose :   Solve the ellipic equation for the transport 
+      !!      divergence system  using a red-black successive-over-
+      !!      relaxation method.
+      !!       This routine provides a MPI optimization to the existing solsor
+      !!     by reducing the number of call to lbc.
+      !! 
+      !! ** Method  :   Successive-over-relaxation method using the red-black 
+      !!      technique. The former technique used was not compatible with 
+      !!      the north-fold boundary condition used in orca configurations.
+      !!      Compared to the classical sol_sor, this routine provides a 
+      !!      mpp optimization by reducing the number of calls to lnc_lnk
+      !!      The solution is computed on a larger area and the boudary
+      !!      conditions only when the inside domain is reached.
+      !! 
+      !! References :   Madec et al. 1988, Ocean Modelling, issue 78, 1-6.
+      !!                Beare and Stevens 1997 Ann. Geophysicae 15, 1369-1377
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(inout) ::   kindic   ! solver indicator, < 0 if the convergence is not reached:
+      !                                    ! the model is stopped in step (set to zero before the call of solsor)
+      !!
+      INTEGER  ::   ji, jj, jn               ! dummy loop indices
+      INTEGER  ::   ishift, icount
+      INTEGER  ::   ijmppodd, ijmppeven, ijpr2d
+      REAL(wp) ::   ztmp, zres, zres2
+      !!----------------------------------------------------------------------
+      
+      ijmppeven = MOD( nimpp+njmpp+jpr2di+jpr2dj   , 2 )
+      ijmppodd  = MOD( nimpp+njmpp+jpr2di+jpr2dj+1 , 2 )
+      ijpr2d    = MAX( jpr2di , jpr2dj )
+      icount = 0
+      !                                                       ! ==============
+      DO jn = 1, nn_nmax                                      ! Iterative loop 
+         !                                                    ! ==============
+
+         IF( MOD(icount,ijpr2d+1) == 0 )   CALL lbc_lnk_e( gcx, c_solver_pt, 1. )   ! lateral boundary conditions
+        
+         ! Residus
+         ! -------
+
+         ! Guess black update
+         DO jj = 2-jpr2dj, nlcj-1+jpr2dj
+            ishift = MOD( jj-ijmppodd-jpr2dj, 2 )
+            DO ji = 2-jpr2di+ishift, nlci-1+jpr2di, 2
+               ztmp =                  gcb(ji  ,jj  )   &
+                  &   - gcp(ji,jj,1) * gcx(ji  ,jj-1)   &
+                  &   - gcp(ji,jj,2) * gcx(ji-1,jj  )   &
+                  &   - gcp(ji,jj,3) * gcx(ji+1,jj  )   &
+                  &   - gcp(ji,jj,4) * gcx(ji  ,jj+1)
+               ! Estimate of the residual
+               zres = ztmp - gcx(ji,jj)
+               gcr(ji,jj) = zres * gcdmat(ji,jj) * zres
+               ! Guess update
+               gcx(ji,jj) = rn_sor * ztmp + (1-rn_sor) * gcx(ji,jj)
+            END DO
+         END DO
+         icount = icount + 1 
+ 
+         IF( MOD(icount,ijpr2d+1) == 0 )   CALL lbc_lnk_e( gcx, c_solver_pt, 1. )   ! lateral boundary conditions
+
+         ! Guess red update
+         DO jj = 2-jpr2dj, nlcj-1+jpr2dj
+            ishift = MOD( jj-ijmppeven-jpr2dj, 2 )
+            DO ji = 2-jpr2di+ishift, nlci-1+jpr2di, 2
+               ztmp =                  gcb(ji  ,jj  )   &
+                  &   - gcp(ji,jj,1) * gcx(ji  ,jj-1)   &
+                  &   - gcp(ji,jj,2) * gcx(ji-1,jj  )   &
+                  &   - gcp(ji,jj,3) * gcx(ji+1,jj  )   &
+                  &   - gcp(ji,jj,4) * gcx(ji  ,jj+1) 
+               ! Estimate of the residual
+               zres = ztmp - gcx(ji,jj)
+               gcr(ji,jj) = zres * gcdmat(ji,jj) * zres
+               ! Guess update
+               gcx(ji,jj) = rn_sor * ztmp + (1-rn_sor) * gcx(ji,jj)
+            END DO
+         END DO
+         icount = icount + 1
+
+         ! test of convergence
+         IF ( jn > nn_nmin .AND. MOD( jn-nn_nmin, nn_nmod ) == 0 ) THEN
+
+            SELECT CASE ( nn_sol_arp )
+            CASE ( 0 )                 ! absolute precision (maximum value of the residual)
+               zres2 = MAXVAL( gcr(2:nlci-1,2:nlcj-1) )
+               IF( lk_mpp )   CALL mpp_max( zres2 )   ! max over the global domain
+               ! test of convergence
+               IF( zres2 < rn_resmax .OR. jn == nn_nmax ) THEN
+                  res = SQRT( zres2 )
+                  niter = jn
+                  ncut = 999
+               ENDIF
+            CASE ( 1 )                 ! relative precision
+               rnorme = SUM( gcr(2:nlci-1,2:nlcj-1) )
+               IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain
+               ! test of convergence
+               IF( rnorme < epsr .OR. jn == nn_nmax ) THEN
+                  res = SQRT( rnorme )
+                  niter = jn
+                  ncut = 999
+               ENDIF
+            END SELECT
+         
+         !****
+         !     IF(lwp)WRITE(numsol,9300) jn, res, sqrt( epsr ) / eps
+9300     FORMAT('          niter :',i4,' res :',e20.10,' b :',e20.10)
+         !****
+         
+         ENDIF
+         ! indicator of non-convergence or explosion
+         IF( jn == nn_nmax .OR. SQRT(epsr)/eps > 1.e+20 ) kindic = -2
+         IF( ncut == 999 ) GOTO 999
+         
+         !                                                 ! =====================
+      END DO                                               ! END of iterative loop
+      !                                                    ! =====================
+      
+999   CONTINUE
+      
+      !  Output in gcx
+      !  -------------
+      CALL lbc_lnk_e( gcx, c_solver_pt, 1. )    ! boundary conditions
+      !
+   END SUBROUTINE sol_sor
+
+   !!=====================================================================
+END MODULE solsor
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solver.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solver.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/SOL/solver.F90	(revision 1844)
@@ -0,0 +1,124 @@
+MODULE solver
+   !!======================================================================
+   !!                     ***  MODULE  solver  ***
+   !! Ocean solver :  initialization of ocean solver
+   !!=====================================================================
+   !! History :  OPA  ! 1990-10  (G. Madec)  Original code           
+   !!                 ! 1993-02  (O. Marti)                         
+   !!                 ! 1997-02  (G. Madec)  local depth inverse computation
+   !!                 ! 1998-10  (G. Roullet, G. Madec)  free surface 
+   !!   NEMO     1.0  ! 2003-07  (G. Madec)  free form, F90
+   !!            3.2  ! 2009-07  (R. Benshila) suppression of rigid-lid & FETI solver
+   !!----------------------------------------------------------------------
+#if defined key_dynspg_flt   ||   defined key_esopa  
+   !!----------------------------------------------------------------------
+   !!   'key_dynspg_flt'                              filtered free surface
+   !!----------------------------------------------------------------------
+   !!   solver_init: solver initialization
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE sol_oce         ! solver variables
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE solmat          ! matrix of the solver
+   USE obc_oce         ! Lateral open boundary condition
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp
+
+   IMPLICIT NONE
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 9.0 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE solver_init( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE solver_init  ***
+      !!                   
+      !! ** Purpose :   Initialization of the elliptic solver
+      !!      
+      !! ** Method  :   a solver is required when using the filtered free
+      !!              surface. 
+      !!
+      !! ** Action  : - c_solver_pt : nature of the gridpoint at which the solver is applied
+      !!
+      !! References : Jensen, 1986: Adv. Phys. Oceanogr. Num. Mod.,Ed. O Brien,87-110.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      !!
+      NAMELIST/namsol/ nn_solv, nn_sol_arp, nn_nmin, nn_nmax, nn_nmod, rn_eps, rn_resmax, rn_sor
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN                  !* open elliptic solver statistics file (only on the printing processors)
+         CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+
+      REWIND( numnam )              !* Namelist namsol : elliptic solver / free surface
+      READ  ( numnam, namsol )
+
+      IF(lwp) THEN                  !* Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'solver_init : solver to compute the surface pressure gradient'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namsol : set solver parameters'
+         WRITE(numout,*) '      type of elliptic solver            nn_solv    = ', nn_solv
+         WRITE(numout,*) '      absolute/relative (0/1) precision  nn_sol_arp = ', nn_sol_arp
+         WRITE(numout,*) '      minimum iterations for solver      nn_nmin    = ', nn_nmin
+         WRITE(numout,*) '      maximum iterations for solver      nn_nmax    = ', nn_nmax
+         WRITE(numout,*) '      frequency for test                 nn_nmod    = ', nn_nmod
+         WRITE(numout,*) '      absolute precision of solver       rn_eps     = ', rn_eps
+         WRITE(numout,*) '      absolute precision for SOR solver  rn_resmax  = ', rn_resmax
+         WRITE(numout,*) '      optimal coefficient of sor         rn_sor     = ', rn_sor
+         WRITE(numout,*)
+      ENDIF
+      eps = rn_eps
+
+      SELECT CASE( nn_solv )          !* parameter check
+      !
+      CASE ( 1 )                          ! preconditioned conjugate gradient solver
+         IF(lwp) WRITE(numout,*) '   a preconditioned conjugate gradient solver is used'
+         IF( jpr2di /= 0 .AND. jpr2dj /= 0 )   CALL ctl_stop( ' jpr2di and jpr2dj should be equal to zero' )
+         !
+      CASE ( 2 )                          ! successive-over-relaxation solver
+         IF(lwp) WRITE(numout,*) '   a successive-over-relaxation solver with extra outer halo is used'
+         IF(lwp) WRITE(numout,*) '   with jpr2di =', jpr2di, ' and  jpr2dj =', jpr2dj
+         IF( .NOT. lk_mpp .AND. jpr2di /= 0 .AND. jpr2dj /= 0 ) THEN
+             CALL ctl_stop( 'jpr2di and jpr2dj are not equal to zero',   &
+             &              'In this case the algorithm should be used only with the key_mpp_... option' )
+         ELSE
+            IF( ( ( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) .OR. ( jpni /= 1 ) ) &
+              &  .AND. ( jpr2di /= jpr2dj ) )   CALL ctl_stop( 'jpr2di should be equal to jpr2dj' )
+         ENDIF
+         !
+      CASE DEFAULT                        ! error in parameter
+         WRITE(ctmp1,*) '          bad flag value for nn_solv = ', nn_solv
+         CALL ctl_stop( ctmp1 )
+      END SELECT
+      !
+      IF( nbit_cmp == 1 ) THEN            ! reproductibility test SOR required
+         IF( nn_solv /= 2 ) THEN
+            CALL ctl_stop( ' Reproductibility tests (nbit_cmp=1) require the SOR solver: nn_solv = 2' )
+         ELSE IF( MAX( jpr2di, jpr2dj ) > 0 ) THEN
+            CALL ctl_stop( ' Reproductibility tests (nbit_cmp=1) require jpr2di = jpr2dj = 0' )
+         END IF 
+      END IF
+
+      !                             !* Grid-point at which the solver is applied
+!!gm  c_solver_pt should be removed: nomore bsf, only T-point is used
+      IF( lk_mpp ) THEN   ;    c_solver_pt = 'S'   ! S=T with special staff ??? which one?
+      ELSE                ;    c_solver_pt = 'T'
+      ENDIF
+
+      CALL sol_mat( kt )            !* Construction of the elliptic system matrix
+      !
+   END SUBROUTINE solver_init
+#endif
+
+   !!======================================================================
+END MODULE solver
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 1844)
@@ -0,0 +1,634 @@
+MODULE eosbn2
+   !!==============================================================================
+   !!                       ***  MODULE  eosbn2  ***
+   !! Ocean diagnostic variable : equation of state - in situ and potential density
+   !!                                               - Brunt-Vaisala frequency 
+   !!==============================================================================
+   !! History :  OPA  ! 1989-03  (O. Marti)  Original code
+   !!            6.0  ! 1994-07  (G. Madec, M. Imbard)  add bn2
+   !!            6.0  ! 1994-08  (G. Madec)  Add Jackett & McDougall eos
+   !!            7.0  ! 1996-01  (G. Madec)  statement function for e3
+   !!            8.1  ! 1997-07  (G. Madec)  density instead of volumic mass
+   !!             -   ! 1999-02  (G. Madec, N. Grima) semi-implicit pressure gradient
+   !!            8.2  ! 2001-09  (M. Ben Jelloul)  bugfix on linear eos
+   !!   NEMO     1.0  ! 2002-10  (G. Madec)  add eos_init
+   !!             -   ! 2002-11  (G. Madec, A. Bozec)  partial step, eos_insitu_2d
+   !!             -   ! 2003-08  (G. Madec)  F90, free form
+   !!            3.0  ! 2006-08  (G. Madec)  add tfreez function
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   eos            : generic interface of the equation of state
+   !!   eos_insitu     : Compute the in situ density
+   !!   eos_insitu_pot : Compute the insitu and surface referenced potential
+   !!                    volumic mass
+   !!   eos_insitu_2d  : Compute the in situ density for 2d fields
+   !!   eos_bn2        : Compute the Brunt-Vaisala frequency
+   !!   tfreez         : Compute the surface freezing temperature
+   !!   eos_init       : set eos parameters (namelist)
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE zdfddm          ! vertical physics: double diffusion
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Interface 
+   INTERFACE eos
+      MODULE PROCEDURE eos_insitu, eos_insitu_pot, eos_insitu_2d
+   END INTERFACE 
+   INTERFACE bn2
+      MODULE PROCEDURE eos_bn2
+   END INTERFACE 
+
+   PUBLIC   eos        ! called by step, istate, tranpc and zpsgrd modules
+   PUBLIC   eos_init   ! called by istate module
+   PUBLIC   bn2        ! called by step module
+   PUBLIC   tfreez     ! called by sbcice_... modules
+
+   !                                        !!* Namelist (nameos) *
+   INTEGER , PUBLIC ::   nn_eos   = 0        !: = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
+   REAL(wp), PUBLIC ::   rn_alpha = 2.0e-4   !: thermal expension coeff. (linear equation of state)
+   REAL(wp), PUBLIC ::   rn_beta  = 7.7e-4   !: saline  expension coeff. (linear equation of state)
+
+   REAL(wp), PUBLIC ::   ralpbet           !: alpha / beta ratio
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE eos_insitu( ptem, psal, prd )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE eos_insitu  ***
+      !! 
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from 
+      !!       potential temperature and salinity using an equation of state
+      !!       defined through the namelist parameter nn_eos.
+      !!
+      !! ** Method  :   3 cases:
+      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!      nn_eos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = 0.0285 - rn_alpha * t
+      !!      nn_eos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (ptem,psal) are defined over the whole domain.
+      !!
+      !! ** Action  :   compute prd , the in situ density (no units)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density 
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   zt , zs , zh , zsr   ! temporary scalars
+      REAL(wp) ::   zr1, zr2, zr3, zr4   !    -         -
+      REAL(wp) ::   zrhop, ze, zbw, zb   !    -         -
+      REAL(wp) ::   zd , zc , zaw, za    !    -         -
+      REAL(wp) ::   zb1, za1, zkw, zk0   !    -         -
+      REAL(wp) ::   zrau0r               !    -         -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      SELECT CASE( nn_eos )
+      !
+      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
+         zrau0r = 1.e0 / rau0
+!CDIR NOVERRCHK
+         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
+         !  
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem  (ji,jj,jk)
+                  zs = psal  (ji,jj,jk)
+                  zh = fsdept(ji,jj,jk)        ! depth
+                  zsr= zws   (ji,jj,jk)        ! square root salinity
+                  !
+                  ! compute volumic mass pure water at atm pressure
+                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
+                     &      -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+                  ! seawater volumic mass atm pressure
+                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt        &
+                     &                   -4.0899e-3 ) *zt+0.824493
+                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+                  zr4= 4.8314e-4
+                  !
+                  ! potential volumic mass (reference to the surface)
+                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+                  !
+                  ! add the compression terms
+                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+                  zb = zbw + ze * zs
+                  !
+                  zd = -2.042967e-2
+                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
+                  za = ( zd*zsr + zc ) *zs + zaw
+                  !
+                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
+                  zk0= ( zb1*zsr + za1 )*zs + zkw
+                  !
+                  ! masked in situ density anomaly
+                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
+                     &             - rau0  ) * zrau0r * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      CASE( 1 )                !==  Linear formulation function of temperature only  ==!
+         DO jk = 1, jpkm1
+            prd(:,:,jk) = ( 0.0285 - rn_alpha * ptem(:,:,jk) ) * tmask(:,:,jk)
+         END DO
+         !
+      CASE( 2 )                !==  Linear formulation function of temperature and salinity  ==!
+         DO jk = 1, jpkm1
+            prd(:,:,jk) = ( rn_beta  * psal(:,:,jk) - rn_alpha * ptem(:,:,jk) ) * tmask(:,:,jk)
+         END DO
+         !
+      END SELECT
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos  : ', ovlap=1, kdim=jpk )
+      !
+   END SUBROUTINE eos_insitu
+
+
+   SUBROUTINE eos_insitu_pot( ptem, psal, prd, prhop )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_insitu_pot  ***
+      !!           
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) and the
+      !!      potential volumic mass (Kg/m3) from potential temperature and
+      !!      salinity fields using an equation of state defined through the 
+      !!     namelist parameter nn_eos.
+      !!
+      !! ** Method  :
+      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!              rhop(t,s)  = rho(t,s,0)
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!
+      !!      nn_eos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = ( rho(t) - rau0 ) / rau0 = 0.028 - rn_alpha * t
+      !!              rhop(t,s)  = rho(t,s)
+      !!
+      !!      nn_eos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = ( rho(t,s) - rau0 ) / rau0 
+      !!                       = rn_beta * s - rn_alpha * tn - 1.
+      !!              rhop(t,s)  = rho(t,s)
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (tn,sn) or (ta,sa) are defined over the whole domain.
+      !!
+      !! ** Action  : - prd  , the in situ density (no units)
+      !!              - prhop, the potential volumic mass (Kg/m3)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!                Brown and Campana, Mon. Weather Rev., 1978
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prhop  ! potential density (surface referenced)
+
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! temporary scalars
+      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zrau0r       !    -         -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws   ! 3D workspace
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( nn_eos )
+      !
+      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
+         zrau0r = 1.e0 / rau0
+!CDIR NOVERRCHK
+         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
+         !  
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zt = ptem  (ji,jj,jk)
+                  zs = psal  (ji,jj,jk)
+                  zh = fsdept(ji,jj,jk)        ! depth
+                  zsr= zws   (ji,jj,jk)        ! square root salinity
+                  !
+                  ! compute volumic mass pure water at atm pressure
+                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4 )*zt   &
+                     &                       -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+                  ! seawater volumic mass atm pressure
+                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
+                     &                                   -4.0899e-3 ) *zt+0.824493
+                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+                  zr4= 4.8314e-4
+                  !
+                  ! potential volumic mass (reference to the surface)
+                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+                  !
+                  ! save potential volumic mass
+                  prhop(ji,jj,jk) = zrhop * tmask(ji,jj,jk)
+                  !
+                  ! add the compression terms
+                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+                  zb = zbw + ze * zs
+                  !
+                  zd = -2.042967e-2
+                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
+                  za = ( zd*zsr + zc ) *zs + zaw
+                  !
+                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
+                  zk0= ( zb1*zsr + za1 )*zs + zkw
+                  !
+                  ! masked in situ density anomaly
+                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
+                     &             - rau0  ) * zrau0r * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
+         DO jk = 1, jpkm1
+            prd  (:,:,jk) = ( 0.0285 - rn_alpha * ptem(:,:,jk) )        * tmask(:,:,jk)
+            prhop(:,:,jk) = ( 1.e0   +          prd (:,:,jk) ) * rau0 * tmask(:,:,jk)
+         END DO
+         !
+      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
+         DO jk = 1, jpkm1
+            prd  (:,:,jk) = ( rn_beta  * psal(:,:,jk) - rn_alpha * ptem(:,:,jk) )        * tmask(:,:,jk)
+            prhop(:,:,jk) = ( 1.e0   + prd (:,:,jk) )                         * rau0 * tmask(:,:,jk)
+         END DO
+         !
+      END SELECT
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-p: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
+      !
+   END SUBROUTINE eos_insitu_pot
+
+
+   SUBROUTINE eos_insitu_2d( ptem, psal, pdep, prd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_insitu_2d  ***
+      !!
+      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from 
+      !!      potential temperature and salinity using an equation of state
+      !!      defined through the namelist parameter nn_eos. * 2D field case
+      !!
+      !! ** Method :
+      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
+      !!         the in situ density is computed directly as a function of
+      !!         potential temperature relative to the surface (the opa t
+      !!         variable), salt and pressure (assuming no pressure variation
+      !!         along geopotential surfaces, i.e. the pressure p in decibars
+      !!         is approximated by the depth in meters.
+      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
+      !!         with pressure                      p        decibars
+      !!              potential temperature         t        deg celsius
+      !!              salinity                      s        psu
+      !!              reference volumic mass        rau0     kg/m**3
+      !!              in situ volumic mass          rho      kg/m**3
+      !!              in situ density anomalie      prd      no units
+      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
+      !!          t = 40 deg celcius, s=40 psu
+      !!      nn_eos = 1 : linear equation of state function of temperature only
+      !!              prd(t) = 0.0285 - rn_alpha * t
+      !!      nn_eos = 2 : linear equation of state function of temperature and
+      !!               salinity
+      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
+      !!      Note that no boundary condition problem occurs in this routine
+      !!      as (ptem,psal) are defined over the whole domain.
+      !!
+      !! ** Action  : - prd , the in situ density (no units)
+      !!
+      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity               [psu]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pdep   ! depth                  [m]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   prd    ! in situ density 
+      !!
+      INTEGER  ::   ji, jj                    ! dummy loop indices
+      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! temporary scalars
+      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zmask        !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zws   ! 2D workspace
+      !!----------------------------------------------------------------------
+
+      prd(:,:) = 0.e0
+
+      SELECT CASE( nn_eos )
+      !
+      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
+      !
+!CDIR NOVERRCHK
+         DO jj = 1, jpjm1
+!CDIR NOVERRCHK
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zws(ji,jj) = SQRT( ABS( psal(ji,jj) ) )
+            END DO
+         END DO
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zmask = tmask(ji,jj,1)          ! land/sea bottom mask = surf. mask
+               zt    = ptem (ji,jj)            ! interpolated T
+               zs    = psal (ji,jj)            ! interpolated S
+               zsr   = zws  (ji,jj)            ! square root of interpolated S
+               zh    = pdep (ji,jj)            ! depth at the partial step level
+               !
+               ! compute volumic mass pure water at atm pressure
+               zr1 = ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4 )*zt   &
+                  &                        -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+               ! seawater volumic mass atm pressure
+               zr2 = ( ( ( 5.3875e-9*zt-8.2467e-7 )*zt+7.6438e-5 ) *zt   &
+                  &                                   -4.0899e-3 ) *zt+0.824493
+               zr3 = ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+               zr4 = 4.8314e-4
+               !
+               ! potential volumic mass (reference to the surface)
+               zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
+               !
+               ! add the compression terms
+               ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+               zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+               zb = zbw + ze * zs
+               !
+               zd = -2.042967e-2
+               zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+               zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt -4.721788
+               za = ( zd*zsr + zc ) *zs + zaw
+               !
+               zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
+               za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+               zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt   &
+                  &                                       +2098.925 ) *zt+190925.6
+               zk0= ( zb1*zsr + za1 )*zs + zkw
+               !
+               ! masked in situ density anomaly
+               prd(ji,jj) = ( zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  ) - rau0 ) / rau0 * zmask
+            END DO
+         END DO
+         !
+      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               prd(ji,jj) = ( 0.0285 - rn_alpha * ptem(ji,jj) ) * tmask(ji,jj,1)
+            END DO
+         END DO
+         !
+      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               prd(ji,jj) = ( rn_beta * psal(ji,jj) - rn_alpha * ptem(ji,jj) ) * tmask(ji,jj,1) 
+            END DO
+         END DO
+         !
+      END SELECT
+
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
+      !
+   END SUBROUTINE eos_insitu_2d
+
+
+   SUBROUTINE eos_bn2( ptem, psal, pn2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE eos_bn2  ***
+      !!
+      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the time-
+      !!      step of the input arguments
+      !!      
+      !! ** Method :
+      !!       * nn_eos = 0  : UNESCO sea water properties
+      !!         The brunt-vaisala frequency is computed using the polynomial
+      !!      polynomial expression of McDougall (1987):
+      !!            N^2 = grav * beta * ( alpha/beta*dk[ t ] - dk[ s ] )/e3w
+      !!      If lk_zdfddm=T, the heat/salt buoyancy flux ratio Rrau is
+      !!      computed and used in zdfddm module :
+      !!              Rrau = alpha/beta * ( dk[ t ] / dk[ s ] )
+      !!       * nn_eos = 1  : linear equation of state (temperature only)
+      !!            N^2 = grav * rn_alpha * dk[ t ]/e3w
+      !!       * nn_eos = 2  : linear equation of state (temperature & salinity)
+      !!            N^2 = grav * (rn_alpha * dk[ t ] - rn_beta * dk[ s ] ) / e3w
+      !!      The use of potential density to compute N^2 introduces e r r o r
+      !!      in the sign of N^2 at great depths. We recommand the use of 
+      !!      nn_eos = 0, except for academical studies.
+      !!        Macro-tasked on horizontal slab (jk-loop)
+      !!      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
+      !!      and is never used at this level.
+      !!
+      !! ** Action  : - pn2 : the brunt-vaisala frequency
+      !!
+      !! References :   McDougall, J. Phys. Oceanogr., 17, 1950-1964, 1987.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature   [Celcius]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity                [psu]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pn2    ! Brunt-Vaisala frequency [s-1]
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zgde3w, zt, zs, zh, zalbet, zbeta   ! temporary scalars 
+#if defined key_zdfddm
+      REAL(wp) ::   zds   ! temporary scalars
+#endif
+      !!----------------------------------------------------------------------
+
+      ! pn2 : interior points only (2=< jk =< jpkm1 )
+      ! -------------------------- 
+      !
+      SELECT CASE( nn_eos )
+      !
+      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zgde3w = grav / fse3w(ji,jj,jk)
+                  zt = 0.5 * ( ptem(ji,jj,jk) + ptem(ji,jj,jk-1) )          ! potential temperature at w-point
+                  zs = 0.5 * ( psal(ji,jj,jk) + psal(ji,jj,jk-1) ) - 35.0   ! salinity anomaly (s-35) at w-point
+                  zh = fsdepw(ji,jj,jk)                                     ! depth in meters  at w-point
+                  !
+                  zalbet = ( ( ( - 0.255019e-07 * zt + 0.298357e-05 ) * zt   &   ! ratio alpha/beta
+                     &                               - 0.203814e-03 ) * zt   &
+                     &                               + 0.170907e-01 ) * zt   &
+                     &   + 0.665157e-01                                      &
+                     &   +     ( - 0.678662e-05 * zs                         &
+                     &           - 0.846960e-04 * zt + 0.378110e-02 ) * zs   &
+                     &   +   ( ( - 0.302285e-13 * zh                         &
+                     &           - 0.251520e-11 * zs                         &
+                     &           + 0.512857e-12 * zt * zt           ) * zh   &
+                     &           - 0.164759e-06 * zs                         &
+                     &        +(   0.791325e-08 * zt - 0.933746e-06 ) * zt   &
+                     &                               + 0.380374e-04 ) * zh
+                     !
+                  zbeta  = ( ( -0.415613e-09 * zt + 0.555579e-07 ) * zt      &   ! beta
+                     &                            - 0.301985e-05 ) * zt      &
+                     &   + 0.785567e-03                                      &
+                     &   + (     0.515032e-08 * zs                           &
+                     &         + 0.788212e-08 * zt - 0.356603e-06 ) * zs     &
+                     &   +(  (   0.121551e-17 * zh                           &
+                     &         - 0.602281e-15 * zs                           &
+                     &         - 0.175379e-14 * zt + 0.176621e-12 ) * zh     &
+                     &                             + 0.408195e-10   * zs     &
+                     &     + ( - 0.213127e-11 * zt + 0.192867e-09 ) * zt     &
+                     &                             - 0.121555e-07 ) * zh
+                     !
+                  pn2(ji,jj,jk) = zgde3w * zbeta * tmask(ji,jj,jk)           &   ! N^2 
+                     &          * ( zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )   &
+                     &                     - ( psal(ji,jj,jk-1) - psal(ji,jj,jk) ) )
+#if defined key_zdfddm
+                  !                                                         !!bug **** caution a traiter zds=dk[S]= 0 !!!!
+                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )                    ! Rrau = (alpha / beta) (dk[t] / dk[s])
+                  IF ( ABS( zds) <= 1.e-20 ) zds = 1.e-20
+                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
+#endif
+               END DO
+            END DO
+         END DO
+         !
+      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
+         DO jk = 2, jpkm1
+            pn2(:,:,jk) = grav * rn_alpha * ( ptem(:,:,jk-1) - ptem(:,:,jk) ) / fse3w(:,:,jk) * tmask(:,:,jk)
+         END DO
+         !
+      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
+         DO jk = 2, jpkm1
+            pn2(:,:,jk) = grav * (  rn_alpha * ( ptem(:,:,jk-1) - ptem(:,:,jk) )      &
+               &                  - rn_beta  * ( psal(:,:,jk-1) - psal(:,:,jk) )  )   &
+               &               / fse3w(:,:,jk) * tmask(:,:,jk)
+         END DO 
+#if defined key_zdfddm
+         DO jk = 2, jpkm1                                 ! Rrau = (alpha / beta) (dk[t] / dk[s])
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )
+                  IF ( ABS( zds ) <= 1.e-20 ) zds = 1.e-20
+                  rrau(ji,jj,jk) = ralpbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
+               END DO
+            END DO
+         END DO
+#endif
+      END SELECT
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=pn2, clinfo1=' bn2  : ', ovlap=1, kdim=jpk )
+#if defined key_zdfddm
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=rrau, clinfo1=' rrau : ', ovlap=1, kdim=jpk )
+#endif
+      !
+   END SUBROUTINE eos_bn2
+
+
+   FUNCTION tfreez( psal ) RESULT( ptf )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!
+      !! ** Purpose :   Compute the sea surface freezing temperature [Celcius]
+      !!
+      !! ** Method  :   UNESCO freezing point at the surface (pressure = 0???)
+      !!       freezing point [Celcius]=(-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s-7.53e-4*p
+      !!       checkvalue: tf= -2.588567 Celsius for s=40.0psu, p=500. decibars
+      !!
+      !! Reference  :   UNESCO tech. papers in the marine science no. 28. 1978
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity             [psu]
+      REAL(wp), DIMENSION(jpi,jpj)                ::   ptf    ! freezing temperature [Celcius]
+      !!----------------------------------------------------------------------
+      !
+      ptf(:,:) = ( - 0.0575 + 1.710523e-3 * SQRT( psal(:,:) )   &
+         &                  - 2.154996e-4 *       psal(:,:)   ) * psal(:,:)
+      !
+   END FUNCTION tfreez
+
+
+   SUBROUTINE eos_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE eos_init  ***
+      !!
+      !! ** Purpose :   initializations for the equation of state
+      !!
+      !! ** Method  :   Read the namelist nameos and control the parameters
+      !!----------------------------------------------------------------------
+      NAMELIST/nameos/ nn_eos, rn_alpha, rn_beta
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam )            ! Read Namelist nameos : equation of state
+      READ  ( numnam, nameos )
+      !
+      IF(lwp) THEN                ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'eos_init : equation of state'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '          Namelist nameos : set eos parameters'
+         WRITE(numout,*) '             flag for eq. of state and N^2  nn_eos   = ', nn_eos
+         WRITE(numout,*) '             thermal exp. coef. (linear)    rn_alpha = ', rn_alpha
+         WRITE(numout,*) '             saline  exp. coef. (linear)    rn_beta  = ', rn_beta
+      ENDIF
+      !
+      SELECT CASE( nn_eos )         ! check option
+      !
+      CASE( 0 )                        !==  Jackett and McDougall (1994) formulation  ==!
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of Jackett & McDougall (1994) equation of state and'
+         IF(lwp) WRITE(numout,*) '                 McDougall (1987) Brunt-Vaisala frequency'
+         !
+      CASE( 1 )                        !==  Linear formulation = F( temperature )  ==!
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T) = rau0 * ( 1.0285 - rn_alpha * T )'
+         IF( lk_zdfddm ) CALL ctl_stop( '          double diffusive mixing parameterization requires',   &
+              &                         ' that T and S are used as state variables' )
+         !
+      CASE( 2 )                        !==  Linear formulation = F( temperature , salinity )  ==!
+         ralpbet = rn_alpha / rn_beta
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T,S) = rau0 * ( rn_beta * S - rn_alpha * T )'
+         !
+      CASE DEFAULT                     !==  ERROR in nn_eos  ==!
+         WRITE(ctmp1,*) '          bad flag value for nn_eos = ', nn_eos
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+   END SUBROUTINE eos_init
+
+   !!======================================================================
+END MODULE eosbn2  
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv.F90	(revision 1844)
@@ -0,0 +1,196 @@
+MODULE traadv
+   !!==============================================================================
+   !!                       ***  MODULE  traadv  ***
+   !! Ocean active tracers:  advection trend 
+   !!==============================================================================
+   !! History :  2.0  !  05-11  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv      : compute ocean tracer advection trend
+   !!   tra_adv_ctl  : control the different options of advection scheme
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE traadv_cen2     ! 2nd order centered scheme (tra_adv_cen2   routine)
+   USE traadv_tvd      ! TVD      scheme           (tra_adv_tvd    routine)
+   USE traadv_muscl    ! MUSCL    scheme           (tra_adv_muscl  routine)
+   USE traadv_muscl2   ! MUSCL2   scheme           (tra_adv_muscl2 routine)
+   USE traadv_ubs      ! UBS      scheme           (tra_adv_ubs    routine)
+   USE traadv_qck     !! QUICKEST scheme           (tra_adv_qck    routine)
+   USE traadv_eiv      ! eddy induced velocity     (tra_adv_eiv    routine)
+   USE trabbl          ! tracers: bottom boundary layer
+   USE ldftra_oce      ! lateral diffusion coefficient on tracers
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv    ! routine called by step module
+ 
+   !                                                   !!* Namelist namtra_adv *
+   LOGICAL, PUBLIC ::   ln_traadv_cen2   = .TRUE.       ! 2nd order centered scheme flag
+   LOGICAL, PUBLIC ::   ln_traadv_tvd    = .FALSE.      ! TVD scheme flag
+   LOGICAL, PUBLIC ::   ln_traadv_muscl  = .FALSE.      ! MUSCL scheme flag
+   LOGICAL, PUBLIC ::   ln_traadv_muscl2 = .FALSE.      ! MUSCL2 scheme flag
+   LOGICAL, PUBLIC ::   ln_traadv_ubs    = .FALSE.      ! UBS scheme flag
+   LOGICAL, PUBLIC ::   ln_traadv_qck    = .FALSE.      ! QUICKEST scheme flag
+
+   INTEGER ::   nadv   ! choice of the type of advection scheme
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv  ***
+      !!
+      !! ** Purpose :   compute the ocean tracer advection trend.
+      !!
+      !! ** Method  : - Update (ua,va) with the advection term following nadv
+      !!----------------------------------------------------------------------
+#if ( defined key_trabbl_adv || defined key_traldf_eiv )
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zun, zvn, zwn   ! effective velocity
+#else
+      USE oce, ONLY :                       zun => un       ! the effective velocity is the
+      USE oce, ONLY :                       zvn => vn       ! Eulerian velocity
+      USE oce, ONLY :                       zwn => wn       ! 
+#endif
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_adv_ctl          ! initialisation & control of options
+
+#if defined key_trabbl_adv
+      zun(:,:,:) = un(:,:,:) - u_bbl(:,:,:)          ! add the bbl velocity
+      zvn(:,:,:) = vn(:,:,:) - v_bbl(:,:,:)
+      zwn(:,:,:) = wn(:,:,:) + w_bbl(:,:,:)
+#endif
+      IF( lk_traldf_eiv ) THEN                       ! commpute and add the eiv velocity
+         IF( .NOT. lk_trabbl_adv ) THEN 
+            zun(:,:,:) = un(:,:,:)
+            zvn(:,:,:) = vn(:,:,:)
+            zwn(:,:,:) = wn(:,:,:)
+         ENDIF
+         CALL tra_adv_eiv( kt, zun, zvn, zwn ) 
+      ENDIF
+
+      SELECT CASE ( nadv )                           ! compute advection trend and add it to general trend
+      CASE ( 1 )   ;   CALL tra_adv_cen2    ( kt, zun, zvn, zwn )    ! 2nd order centered scheme
+      CASE ( 2 )   ;   CALL tra_adv_tvd     ( kt, zun, zvn, zwn )    ! TVD      scheme
+      CASE ( 3 )   ;   CALL tra_adv_muscl   ( kt, zun, zvn, zwn )    ! MUSCL    scheme
+      CASE ( 4 )   ;   CALL tra_adv_muscl2  ( kt, zun, zvn, zwn )    ! MUSCL2   scheme
+      CASE ( 5 )   ;   CALL tra_adv_ubs     ( kt, zun, zvn, zwn )    ! UBS      scheme
+      CASE ( 6 )   ;   CALL tra_adv_qck     ( kt, zun, zvn, zwn )    ! QUICKEST scheme
+      !
+      CASE (-1 )                                                     ! esopa: test all possibility with control print
+                       CALL tra_adv_cen2    ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv0 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+                       CALL tra_adv_tvd     ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv2 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+                       CALL tra_adv_muscl   ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv3 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+                       CALL tra_adv_muscl2  ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv4 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+                       CALL tra_adv_ubs     ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv5 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+                       CALL tra_adv_qck     ( kt, zun, zvn, zwn )
+                       CALL prt_ctl( tab3d_1=ta, clinfo1=' adv6 - Ta: ', mask1=tmask,               &
+            &                        tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      END SELECT
+       
+      CALL iom_put( "uoce_eff", zun )   ! effective i-current      
+      CALL iom_put( "voce_eff", zvn )   ! effective j-current
+      CALL iom_put( "woce_eff", zwn )   ! effective vert. current
+
+      !                                              ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' adv  - Ta: ', mask1=tmask,               &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_adv
+
+
+   SUBROUTINE tra_adv_ctl
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_ctl  ***
+      !!                
+      !! ** Purpose :   Control the consistency between namelist options for 
+      !!              tracer advection schemes and set nadv
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio
+
+      NAMELIST/namtra_adv/ ln_traadv_cen2 , ln_traadv_tvd,    &
+         &                 ln_traadv_muscl, ln_traadv_muscl2, &
+         &                 ln_traadv_ubs  , ln_traadv_qck
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               ! Read Namelist namtra_adv : tracer advection scheme
+      READ   ( numnam, namtra_adv )
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv_ctl : choice/control of the tracer advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtra_adv : chose a advection scheme for tracers'
+         WRITE(numout,*) '      2nd order advection scheme     ln_traadv_cen2   = ', ln_traadv_cen2
+         WRITE(numout,*) '      TVD advection scheme           ln_traadv_tvd    = ', ln_traadv_tvd
+         WRITE(numout,*) '      MUSCL  advection scheme        ln_traadv_muscl  = ', ln_traadv_muscl
+         WRITE(numout,*) '      MUSCL2 advection scheme        ln_traadv_muscl2 = ', ln_traadv_muscl2
+         WRITE(numout,*) '      UBS    advection scheme        ln_traadv_ubs    = ', ln_traadv_ubs
+         WRITE(numout,*) '      QUICKEST advection scheme      ln_traadv_qck    = ', ln_traadv_qck
+    ENDIF
+
+      ioptio = 0                      ! Parameter control
+      IF( ln_traadv_cen2   )   ioptio = ioptio + 1
+      IF( ln_traadv_tvd    )   ioptio = ioptio + 1
+      IF( ln_traadv_muscl  )   ioptio = ioptio + 1
+      IF( ln_traadv_muscl2 )   ioptio = ioptio + 1
+      IF( ln_traadv_ubs    )   ioptio = ioptio + 1
+      IF( ln_traadv_qck    )   ioptio = ioptio + 1
+      IF( lk_esopa         )   ioptio =          1
+
+      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namtra_adv' )
+
+      IF( n_cla == 1 .AND. .NOT. ln_traadv_cen2 )   &
+         &                CALL ctl_stop( 'cross-land advection only with 2nd order advection scheme' )
+
+      !                              ! Set nadv
+      IF( ln_traadv_cen2   )   nadv =  1
+      IF( ln_traadv_tvd    )   nadv =  2
+      IF( ln_traadv_muscl  )   nadv =  3
+      IF( ln_traadv_muscl2 )   nadv =  4
+      IF( ln_traadv_ubs    )   nadv =  5
+      IF( ln_traadv_qck    )   nadv =  6
+      IF( lk_esopa         )   nadv = -1
+
+      IF(lwp) THEN                   ! Print the choice
+         WRITE(numout,*)
+         IF( nadv ==  1 )   WRITE(numout,*) '         2nd order scheme is used'
+         IF( nadv ==  2 )   WRITE(numout,*) '         TVD       scheme is used'
+         IF( nadv ==  3 )   WRITE(numout,*) '         MUSCL     scheme is used'
+         IF( nadv ==  4 )   WRITE(numout,*) '         MUSCL2    scheme is used'
+         IF( nadv ==  5 )   WRITE(numout,*) '         UBS       scheme is used'
+         IF( nadv ==  6 )   WRITE(numout,*) '         QUICKEST  scheme is used'
+         IF( nadv == -1 )   WRITE(numout,*) '         esopa test: use all advection scheme'
+      ENDIF
+      !
+   END SUBROUTINE tra_adv_ctl
+
+  !!======================================================================
+END MODULE traadv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_cen2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 1844)
@@ -0,0 +1,419 @@
+MODULE traadv_cen2
+   !!======================================================================
+   !!                     ***  MODULE  traadv_cen2  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!======================================================================
+   !! History :  8.2  ! 2001-08  (G. Madec, E. Durand)  trahad+trazad=traadv 
+   !!            1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            9.0  ! 2004-08  (C. Talandier) New trends organization
+   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            2.0  ! 2006-04  (R. Benshila, G. Madec) Step reorganization
+   !!             -   ! 2006-07  (G. madec)  add ups_orca_set routine
+   !!            3.2  ! 2009-07  (G. Madec) add avmb, avtb in restart for cen2 advection
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_cen2 : update the tracer trend with the horizontal and
+   !!                  vertical advection trends using a seconder order
+   !!   ups_orca_set : allow mixed upstream/centered scheme in specific
+   !!                  area (set for orca 2 and 4 only)
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE trdmod_oce      ! ocean variables trends
+   USE eosbn2          ! equation of state
+   USE trdmod          ! ocean active tracers trends 
+   USE closea          ! closed sea
+   USE trabbl          ! advective term in the BBL
+   USE sbcmod          ! surface Boundary Condition
+   USE sbcrnf          ! river runoffs
+   USE in_out_manager  ! I/O manager
+   USE iom             ! IOM library
+   USE lib_mpp
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+   USE zdf_oce         ! ocean vertical physics
+   USE restart         ! ocean restart
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_cen2    ! routine called by step.F90
+   PUBLIC   ups_orca_set    ! routine used by traadv_cen2_jki.F90
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   upsmsk    !: mixed upstream/centered scheme near some straits 
+   !                                                   !  and in closed seas (orca 2 and 4 configurations)
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   btr2   ! inverse of T-point surface [1/(e1t*e2t)]
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_cen2( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_cen2  ***
+      !!                 
+      !! ** Purpose :   Compute the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations.
+      !!
+      !! ** Method  :   The advection is evaluated by a second order centered
+      !!      scheme using now fields (leap-frog scheme). In specific areas
+      !!      (vicinity of major river mouths, some straits, or where tn is
+      !!      approaching the freezing point) it is mixed with an upstream
+      !!      scheme for stability reasons.
+      !!         Part 0 : compute the upstream / centered flag
+      !!                  (3D array, zind, defined at T-point (0<zind<1))
+      !!         Part I : horizontal advection
+      !!       * centered flux:
+      !!               zcenu = e2u*e3u  un  mi(tn)
+      !!               zcenv = e1v*e3v  vn  mj(tn)
+      !!       * upstream flux:
+      !!               zupsu = e2u*e3u  un  (tb(i) or tb(i-1) ) [un>0 or <0]
+      !!               zupsv = e1v*e3v  vn  (tb(j) or tb(j-1) ) [vn>0 or <0]
+      !!       * mixed upstream / centered horizontal advection scheme
+      !!               zcofi = max(zind(i+1), zind(i))
+      !!               zcofj = max(zind(j+1), zind(j))
+      !!               zwx = zcofi * zupsu + (1-zcofi) * zcenu
+      !!               zwy = zcofj * zupsv + (1-zcofj) * zcenv
+      !!       * horizontal advective trend (divergence of the fluxes)
+      !!               zta = 1/(e1t*e2t*e3t) { di-1[zwx] + dj-1[zwy] }
+      !!       * Add this trend now to the general trend of tracer (ta,sa):
+      !!              (ta,sa) = (ta,sa) + ( zta , zsa )
+      !!       * trend diagnostic ('key_trdtra' defined): the trend is
+      !!      saved for diagnostics. The trends saved is expressed as
+      !!      Uh.gradh(T), i.e.
+      !!                     save trend = zta + tn divn
+      !!         In addition, the advective trend in the two horizontal direc-
+      !!      tion is also re-computed as Uh gradh(T). Indeed hadt+tn divn is
+      !!      equal to (in s-coordinates, and similarly in z-coord.):
+      !!         zta+tn*divn=1/(e1t*e2t*e3t) { mi-1( e2u*e3u  un  di[tn] )
+      !!                                      +mj-1( e1v*e3v  vn  mj[tn] )  }
+      !!         NB:in z-coordinate - full step (ln_zco=T) e3u=e3v=e3t, so
+      !!      they vanish from the expression of the flux and divergence.
+      !!
+      !!         Part II : vertical advection
+      !!      For temperature (idem for salinity) the advective trend is com-
+      !!      puted as follows :
+      !!            zta = 1/e3t dk+1[ zwz ]
+      !!      where the vertical advective flux, zwz, is given by :
+      !!            zwz = zcofk * zupst + (1-zcofk) * zcent
+      !!      with
+      !!        zupsv = upstream flux = wn * (tb(k) or tb(k-1) ) [wn>0 or <0]
+      !!        zcenu = centered flux = wn * mk(tn)
+      !!         The surface boundary condition is :
+      !!      variable volume (lk_vvl = T) : zero advective flux
+      !!      lin. free-surf  (lk_vvl = F) : wn(:,:,1) * tn(:,:,1)
+      !!         Add this trend now to the general trend of tracer (ta,sa):
+      !!            (ta,sa) = (ta,sa) + ( zta , zsa )
+      !!         Trend diagnostic ('key_trdtra' defined): the trend is
+      !!      saved for diagnostics. The trends saved is expressed as :
+      !!             save trend =  w.gradz(T) = zta - tn divn.
+      !!
+      !! ** Action :  - update (ta,sa) with the now advective tracer trends
+      !!              - save trends in (ztrdt,ztrds) ('key_trdtra')
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zwx => ua   ! use ua as workspace
+      USE oce, ONLY :   zwy => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pun   ! ocean velocity u-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvn   ! ocean velocity v-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pwn   ! ocean velocity w-component
+      !!
+      INTEGER  ::   ji, jj, jk                       ! dummy loop indices
+      REAL(wp) ::   zbtr, zhw, ze3tr                 ! temporary scalars
+      REAL(wp) ::   zfp_ui, zfp_vj, zfp_w , zfui     !    -         -
+      REAL(wp) ::   zfm_ui, zfm_vj, zfm_w , zfvj     !    -         -
+      REAL(wp) ::   zcofi , zcofj , zcofk            !    -         -
+      REAL(wp) ::   zupsut, zupsus, zcenut, zcenus   !    -         -
+      REAL(wp) ::   zupsvt, zupsvs, zcenvt, zcenvs   !    -         -
+      REAL(wp) ::   zupst , zupss , zcent , zcens    !    -         -
+      REAL(wp) ::   z_hdivn_x, z_hdivn_y, z_hdivn    !    -         -
+      REAL(wp) ::   zice                             !    -         -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztfreez            ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz, ztrdt, zind   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zww, ztrds         !  "      "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_cen2 : 2nd order centered advection scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~   Vector optimization case'
+         IF(lwp) WRITE(numout,*)
+         !
+         upsmsk(:,:) = 0.e0                              ! not upstream by default
+         ! 
+         IF( cp_cfg == "orca" )   CALL ups_orca_set      ! set mixed Upstream/centered scheme near some straits
+         !                                               ! and in closed seas (orca2 and orca4 only)
+         !   
+         btr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )        ! inverse of T-point surface
+         !
+         IF( jp_cfg == 2 .AND. .NOT. ln_rstart ) THEN    ! Increase the background in the surface layers
+            avmb(1) = 10.  * avmb(1)      ;      avtb(1) = 10.  * avtb(1)
+            avmb(2) = 10.  * avmb(2)      ;      avtb(2) = 10.  * avtb(2)
+            avmb(3) =  5.  * avmb(3)      ;      avtb(3) =  5.  * avtb(3)
+            avmb(4) =  2.5 * avmb(4)      ;      avtb(4) =  2.5 * avtb(4)
+         ENDIF
+      ENDIF
+
+      ! Upstream / centered scheme indicator
+      ! ------------------------------------
+!!gm  not strickly exact : the freezing point should be computed at each ocean levels...
+!!gm  not a big deal since cen2 is no more used in global ice-ocean simulations
+      ztfreez(:,:) = tfreez( sn(:,:,1) )
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !                                        ! below ice covered area (if tn < "freezing"+0.1 )
+               IF( tn(ji,jj,jk) <= ztfreez(ji,jj) + 0.1 ) THEN   ;   zice = 1.e0
+               ELSE                                              ;   zice = 0.e0
+               ENDIF
+               zind(ji,jj,jk) = MAX (   &
+                  rnfmsk(ji,jj) * rnfmsk_z(jk),      &  ! near runoff mouths (& closed sea outflows)
+                  upsmsk(ji,jj)               ,      &  ! some of some straits
+                  zice                               &  ! below ice covered area (if tn < "freezing"+0.1 )
+                  &                  ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! I. Horizontal advection
+      !    ====================
+      !
+      DO jk = 1, jpkm1
+         !                        ! Second order centered tracer flux at u- and v-points
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ! upstream indicator
+               zcofi = MAX( zind(ji+1,jj,jk), zind(ji,jj,jk) )
+               zcofj = MAX( zind(ji,jj+1,jk), zind(ji,jj,jk) )
+               ! volume fluxes * 1/2
+               zfui = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zfvj = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+               !
+               ! upstream scheme
+               zfp_ui = zfui + ABS( zfui )
+               zfp_vj = zfvj + ABS( zfvj )
+               zfm_ui = zfui - ABS( zfui )
+               zfm_vj = zfvj - ABS( zfvj )
+               zupsut = zfp_ui * tb(ji,jj,jk) + zfm_ui * tb(ji+1,jj  ,jk)
+               zupsvt = zfp_vj * tb(ji,jj,jk) + zfm_vj * tb(ji  ,jj+1,jk)
+               zupsus = zfp_ui * sb(ji,jj,jk) + zfm_ui * sb(ji+1,jj  ,jk)
+               zupsvs = zfp_vj * sb(ji,jj,jk) + zfm_vj * sb(ji  ,jj+1,jk)
+               ! centered scheme
+               zcenut = zfui * ( tn(ji,jj,jk) + tn(ji+1,jj  ,jk) )
+               zcenvt = zfvj * ( tn(ji,jj,jk) + tn(ji  ,jj+1,jk) )
+               zcenus = zfui * ( sn(ji,jj,jk) + sn(ji+1,jj  ,jk) )
+               zcenvs = zfvj * ( sn(ji,jj,jk) + sn(ji  ,jj+1,jk) )
+               ! mixed centered / upstream scheme
+               zwx(ji,jj,jk) = zcofi * zupsut + (1.-zcofi) * zcenut
+               zwy(ji,jj,jk) = zcofj * zupsvt + (1.-zcofj) * zcenvt
+               zww(ji,jj,jk) = zcofi * zupsus + (1.-zcofi) * zcenus
+               zwz(ji,jj,jk) = zcofj * zupsvs + (1.-zcofj) * zcenvs
+            END DO
+         END DO
+         !                        ! Tracer flux divergence at t-point added to the general trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr = btr2(ji,jj) / fse3t(ji,jj,jk)
+               !
+               ta(ji,jj,jk) = ta(ji,jj,jk) - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk)  &
+                  &                                  + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk)  )
+               sa(ji,jj,jk) = sa(ji,jj,jk) - zbtr * (  zww(ji,jj,jk) - zww(ji-1,jj  ,jk)  &
+                  &                                  + zwz(ji,jj,jk) - zwz(ji  ,jj-1,jk)  )
+            END DO
+         END DO
+      END DO
+
+
+      IF( l_trdtra ) THEN      ! Save the i- and j-advective trends for diagnostic (U.gradz(T) trends)
+         !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid with OBC, BDY, cla, eiv, advective bbl 
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+                  !
+                  ztrdt(ji,jj,jk) = - zbtr * ( zwx(ji,jj,jk) - zwx(ji-1,jj,jk) ) + tn(ji,jj,jk) * z_hdivn_x
+                  ztrds(ji,jj,jk) = - zbtr * ( zww(ji,jj,jk) - zww(ji-1,jj,jk) ) + sn(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)
+         !
+         DO jk = 1, jpkm1           ! T/S MERIDIONAL advection trends
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+                  !
+                  ztrdt(ji,jj,jk) = - zbtr * ( zwy(ji,jj,jk) - zwy(ji,jj-1,jk) ) + tn(ji,jj,jk) * z_hdivn_y          
+                  ztrds(ji,jj,jk) = - zbtr * ( zwz(ji,jj,jk) - zwz(ji,jj-1,jk) ) + sn(ji,jj,jk) * z_hdivn_y
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)
+         !
+         ztrdt(:,:,:) = ta(:,:,:)   ;   ztrds(:,:,:) = sa(:,:,:)       ! Save the horizontal up-to-date ta/sa trends
+         !
+      ENDIF
+
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN      ! "zonal" mean advective heat and salt transport 
+         pht_adv(:) = ptr_vj( zwy(:,:,:) )
+         pst_adv(:) = ptr_vj( zwz(:,:,:) )
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' cen2 had  - Ta: ', mask1=tmask, &
+         &                       tab3d_2=sa, clinfo2=            ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+
+      ! II. Vertical advection
+      !     ==================
+      !
+      zwx(:,:,jpk) = 0.e0     ;    zwy(:,:,jpk) = 0.e0      ! Bottom value  : flux set to zero
+      !
+      IF( lk_vvl ) THEN                                     ! Surface value : zero in variable volume
+         zwx(:,:, 1 ) = 0.e0    ;    zwy(:,:, 1 ) = 0.e0
+      ELSE                                                  !               : linear free surface case
+         zwx(:,:, 1 ) = pwn(:,:,1) * tn(:,:,1)
+         zwy(:,:, 1 ) = pwn(:,:,1) * sn(:,:,1)
+      ENDIF
+      !
+      DO jk = 2, jpk              ! Second order centered tracer flux at w-point
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcofk = MAX( zind(ji,jj,jk-1), zind(ji,jj,jk) )      ! upstream indicator
+               zhw = 0.5 * pwn(ji,jj,jk)                            ! velocity * 1/2
+               !
+               zfp_w = zhw + ABS( zhw )                             ! upstream scheme
+               zfm_w = zhw - ABS( zhw )
+               zupst = zfp_w * tb(ji,jj,jk) + zfm_w * tb(ji,jj,jk-1)
+               zupss = zfp_w * sb(ji,jj,jk) + zfm_w * sb(ji,jj,jk-1)
+               !
+               zcent = zhw * ( tn(ji,jj,jk) + tn(ji,jj,jk-1) )      ! centered scheme
+               zcens = zhw * ( sn(ji,jj,jk) + sn(ji,jj,jk-1) )
+               !
+               zwx(ji,jj,jk) = zcofk * zupst + (1.-zcofk) * zcent   ! mixed centered / upstream scheme
+               zwy(ji,jj,jk) = zcofk * zupss + (1.-zcofk) * zcens
+            END DO
+         END DO
+      END DO
+      !
+      DO jk = 1, jpkm1            ! divergence of Tracer flux added to the general trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ze3tr = 1. / fse3t(ji,jj,jk)
+               ta(ji,jj,jk) =  ta(ji,jj,jk) - ze3tr * ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) )
+               sa(ji,jj,jk) =  sa(ji,jj,jk) - ze3tr * ( zwy(ji,jj,jk) - zwy(ji,jj,jk+1) )
+            END DO
+         END DO
+      END DO
+
+      IF( l_trdtra ) THEN      ! Save the vertical advective trends for diagnostic (W gradz(T) trends)
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+                  !
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  ztrdt(ji,jj,jk) = ta(ji,jj,jk) - ztrdt(ji,jj,jk) - tn(ji,jj,jk) * z_hdivn 
+                  ztrds(ji,jj,jk) = sa(ji,jj,jk) - ztrds(ji,jj,jk) - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)
+      ENDIF
+
+      ! write avmb, avtb in restart (traadv_cen2 requires a modified avmb, avtb that are
+      ! ---------------------------  required in restart file to ensure restartability)
+      ! avmb, avtb will be read in zdfini in restart case as they are used in zdftke, kpp etc...
+      IF( lrst_oce ) THEN
+         CALL iom_rstput( kt, nitrst, numrow, 'avmb', avmb )
+         CALL iom_rstput( kt, nitrst, numrow, 'avtb', avtb )
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' cen2 zad  - Ta: ', mask1=tmask, &
+         &                       tab3d_2=sa, clinfo2=            ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_adv_cen2
+   
+   
+   SUBROUTINE ups_orca_set
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ups_orca_set  ***
+      !!       
+      !! ** Purpose :   add a portion of upstream scheme in area where the
+      !!                centered scheme generates too strong overshoot
+      !!
+      !! ** Method  :   orca (R4 and R2) confiiguration setting. Set upsmsk
+      !!                array to nozero value in some straith. 
+      !!
+      !! ** Action : - upsmsk set to 1 at some strait, 0 elsewhere for orca
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers
+      !!----------------------------------------------------------------------
+      
+      ! mixed upstream/centered scheme near river mouths
+      ! ------------------------------------------------
+      SELECT CASE ( jp_cfg )
+      !                                        ! =======================
+      CASE ( 4 )                               !  ORCA_R4 configuration 
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ii0 =  70   ;   ii1 =  71
+         ij0 =  52   ;   ij1 =  53   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !
+         !                                     ! =======================
+      CASE ( 2 )                               !  ORCA_R2 configuration 
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ij0 = 102   ;   ij1 = 102
+         ii0 = 138   ;   ii1 = 138   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.20
+         ii0 = 139   ;   ii1 = 139   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 140   ;   ii1 = 140   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 = 101   ;   ij1 = 102
+         ii0 = 141   ;   ii1 = 141   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !                                          ! Bab el Mandeb Strait
+         ij0 =  87   ;   ij1 =  88
+         ii0 = 164   ;   ii1 = 164   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.10
+         ij0 =  88   ;   ij1 =  88
+         ii0 = 163   ;   ii1 = 163   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ii0 = 162   ;   ii1 = 162   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 160   ;   ii1 = 161   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 =  89   ;   ij1 =  89
+         ii0 = 158   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ij0 =  90   ;   ij1 =  90
+         ii0 = 160   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         !                                          ! Sound Strait
+         ij0 = 116   ;   ij1 = 116
+         ii0 = 144   ;   ii1 = 144   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ii0 = 145   ;   ii1 = 147   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ii0 = 148   ;   ii1 = 148   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         !
+      END SELECT 
+      
+      ! mixed upstream/centered scheme over closed seas
+      ! -----------------------------------------------
+      CALL clo_ups( upsmsk(:,:) )
+      !
+   END SUBROUTINE ups_orca_set
+
+   !!======================================================================
+END MODULE traadv_cen2
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_eiv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_eiv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_eiv.F90	(revision 1844)
@@ -0,0 +1,185 @@
+MODULE traadv_eiv
+   !!======================================================================
+   !!                    ***  MODULE  traadv_eiv  ***
+   !! Ocean active tracers:  advection trend - eddy induced velocity
+   !!======================================================================
+   !! History :  9.0  !  05-11  (G. Madec)  Original code, from traldf and zdf _iso
+   !!----------------------------------------------------------------------
+#if defined key_traldf_eiv   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_eiv'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_iso : update the tracer trend with the horizontal component
+   !!                 of iso neutral laplacian operator or horizontal 
+   !!                 laplacian operator in s-coordinate
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldfslp          ! iso-neutral slopes
+   USE in_out_manager  ! I/O manager
+   USE iom
+# if defined key_diaeiv
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE diaar5, ONLY :   lk_diaar5
+# endif  
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_eiv   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "ldfeiv_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_eiv( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_eiv  ***
+      !! 
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The eddy induced advection is computed from the slope
+      !!      of iso-neutral surfaces computed in routine ldf_slp as follows:
+      !!         zu_eiv =  1/(e2u e3u)   dk[ aeiu e2u mi(wslpi) ]
+      !!         zv_eiv =  1/(e1v e3v)   dk[ aeiv e1v mj(wslpj)
+      !!         zw_eiv = -1/(e1t e2t) { di[ aeiu e2u mi(wslpi) ]
+      !!                               + dj[ aeiv e1v mj(wslpj) ] }
+      !!      add the eiv component to the model velocity:
+      !!         p.n = p.n + z._eiv
+      !!
+      !! ** Action  : - add to p.n the eiv component
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pun   ! in : 3 ocean velocity components 
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pvn   ! out: 3 ocean velocity components
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pwn   !      increased by the eiv
+      !!
+      INTEGER  ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp) ::   zuwk, zuwk1, zuwi, zuwi1   ! temporary scalar
+      REAL(wp) ::   zvwk, zvwk1, zvwj, zvwj1   !    "         "
+      REAL(wp) ::   zu_eiv, zv_eiv, zw_eiv     !    "         "
+# if defined key_diaeiv
+      REAL(wp) ::   zztmp                      !    "         "
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d    !    "         "
+# endif  
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_eiv : eddy induced advection :'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   add to velocity fields the eiv component'
+# if defined key_diaeiv
+         u_eiv(:,:,:) = 0.e0
+         v_eiv(:,:,:) = 0.e0
+         w_eiv(:,:,:) = 0.e0
+# endif
+      ENDIF
+      !                                             ! =================
+      DO jk = 1, jpkm1                              !  Horizontal slab
+         !                                          ! =================
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj,jk  ) ) * fsaeiu(ji,jj,jk  ) * umask(ji,jj,jk  )
+               zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj,jk+1) ) * fsaeiu(ji,jj,jk+1) * umask(ji,jj,jk+1)
+               zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji,jj+1,jk  ) ) * fsaeiv(ji,jj,jk  ) * vmask(ji,jj,jk  )
+               zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji,jj+1,jk+1) ) * fsaeiv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
+
+               zu_eiv = 0.5 * umask(ji,jj,jk) * ( zuwk - zuwk1 ) / fse3u(ji,jj,jk)
+               zv_eiv = 0.5 * vmask(ji,jj,jk) * ( zvwk - zvwk1 ) / fse3v(ji,jj,jk)
+   
+               pun(ji,jj,jk) = pun(ji,jj,jk) + zu_eiv
+               pvn(ji,jj,jk) = pvn(ji,jj,jk) + zv_eiv
+# if defined key_diaeiv
+               u_eiv(ji,jj,jk) = zu_eiv
+               v_eiv(ji,jj,jk) = zv_eiv
+# endif
+            END DO
+         END DO
+         IF( jk >=2 ) THEN                             ! jk=1 zw_eiv=0, not computed
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+# if defined key_traldf_c2d || defined key_traldf_c3d
+                  zuwi  = ( wslpi(ji,jj,jk)+wslpi(ji-1,jj,jk) ) * fsaeiu(ji-1,jj,jk) * e2u(ji-1,jj) * umask(ji-1,jj,jk)
+                  zuwi1 = ( wslpi(ji,jj,jk)+wslpi(ji+1,jj,jk) ) * fsaeiu(ji  ,jj,jk) * e2u(ji  ,jj) * umask(ji  ,jj,jk)
+                  zvwj  = ( wslpj(ji,jj,jk)+wslpj(ji,jj-1,jk) ) * fsaeiv(ji,jj-1,jk) * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
+                  zvwj1 = ( wslpj(ji,jj,jk)+wslpj(ji,jj+1,jk) ) * fsaeiv(ji,jj  ,jk) * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
+  
+                  zw_eiv = - 0.5 * tmask(ji,jj,jk) * ( zuwi1 - zuwi + zvwj1 - zvwj ) / ( e1t(ji,jj)*e2t(ji,jj) )
+# else
+                  zuwi  = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) ) * e2u(ji-1,jj) * umask(ji-1,jj,jk)
+                  zuwi1 = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) ) * e2u(ji  ,jj) * umask(ji  ,jj,jk)
+                  zvwj  = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) ) * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
+                  zvwj1 = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) ) * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
+
+                  zw_eiv = - 0.5 * tmask(ji,jj,jk) * fsaeiw(ji,jj,jk) * ( zuwi1 - zuwi + zvwj1 - zvwj )  &
+                     &                                                / ( e1t(ji,jj)*e2t(ji,jj) )
+# endif
+                  pwn(ji,jj,jk) = pwn(ji,jj,jk) + zw_eiv
+
+# if defined key_diaeiv
+                  w_eiv(ji,jj,jk) = zw_eiv
+# endif
+               END DO
+            END DO
+         ENDIF
+         !                                          ! =================
+      END DO                                        !    End of slab  
+      !                                             ! =================
+
+# if defined key_diaeiv
+      CALL iom_put( "uoce_eiv", u_eiv )    ! i-eiv current
+      CALL iom_put( "voce_eiv", v_eiv )    ! j-eiv current
+      CALL iom_put( "woce_eiv", w_eiv )    ! vert. eiv current
+      IF( lk_diaar5 ) THEN
+         zztmp = 0.5 * rau0 * rcp 
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + zztmp * u_eiv(ji,jj,jk) * (tn(ji,jj,jk)+tn(ji+1,jj,jk)) * e1u(ji,jj) * fse3u(ji,jj,jk) 
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL iom_put( "ueiv_heattr", z2d )                  ! heat transport in i-direction
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + zztmp * v_eiv(ji,jj,jk) * (tn(ji,jj,jk)+tn(ji,jj+1,jk)) * e2v(ji,jj) * fse3v(ji,jj,jk) 
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL iom_put( "veiv_heattr", z2d )                  !  heat transport in i-direction
+      ENDIF
+# endif  
+      ! 
+    END SUBROUTINE tra_adv_eiv
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :             No rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE tra_adv_eiv( kt, pun, pvn, pwn )              ! Empty routine
+      REAL, DIMENSION(:,:,:) ::   pun, pvn, pwn
+      WRITE(*,*) 'tra_adv_eiv: You should not have seen this print! error?', kt, pun(1,1,1), pvn(1,1,1), pwn(1,1,1)
+   END SUBROUTINE tra_adv_eiv
+#endif
+
+   !!==============================================================================
+END MODULE traadv_eiv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl.F90	(revision 1844)
@@ -0,0 +1,424 @@
+MODULE traadv_muscl
+   !!======================================================================
+   !!                       ***  MODULE  traadv_muscl  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!======================================================================
+   !! History :       !  06-00  (A.Estublier)  for passive tracers
+   !!                 !  01-08  (E.Durand, G.Madec)  adapted for T & S
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_muscl : update the tracer trend with the horizontal
+   !!                   and vertical advection trends using MUSCL scheme
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE trabbl          ! tracers: bottom boundary layer
+   USE lib_mpp         ! distribued memory computing
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link) 
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_muscl  ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_muscl( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE tra_adv_muscl  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to total advection of T and 
+      !!      S using a MUSCL scheme (Monotone Upstream-centered Scheme for
+      !!      Conservation Laws) and add it to the general tracer trend.
+      !!
+      !! ** Method  : MUSCL scheme plus centered scheme at ocean boundaries
+      !!
+      !! ** Action  : - update (ta,sa) with the now advective tracer trends
+      !!              - save trends in (ztrdt,ztrds) ('key_trdtra')
+      !!
+      !! References : Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
+      !!              IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as workspace
+      USE oce, ONLY :   ztrds => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pun   ! ocean velocity u-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvn   ! ocean velocity v-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pwn   ! ocean velocity w-component
+      !!
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   &
+         zu, zv, zw, zeu, zev,           &  
+         zew, zbtr, zstep,               &
+         z0u, z0v, z0w,                  &
+         zzt1, zzt2, zalpha,             &
+         zzs1, zzs2, z2,                 &
+         zta, zsa,                       &
+        z_hdivn_x, z_hdivn_y, z_hdivn
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zt1, zt2, ztp1, ztp2   ! 3D workspace
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zs1, zs2, zsp1, zsp2   !  "      "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv : MUSCL advection scheme'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;    z2 = 1.
+      ELSE                                        ;    z2 = 2.
+      ENDIF
+
+      ! I. Horizontal advective fluxes
+      ! ------------------------------
+      ! first guess of the slopes
+      ! interior values
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1      
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zt1(ji,jj,jk) = umask(ji,jj,jk) * ( tb(ji+1,jj,jk) - tb(ji,jj,jk) )
+               zs1(ji,jj,jk) = umask(ji,jj,jk) * ( sb(ji+1,jj,jk) - sb(ji,jj,jk) )
+               zt2(ji,jj,jk) = vmask(ji,jj,jk) * ( tb(ji,jj+1,jk) - tb(ji,jj,jk) )
+               zs2(ji,jj,jk) = vmask(ji,jj,jk) * ( sb(ji,jj+1,jk) - sb(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      ! bottom values
+      zt1(:,:,jpk) = 0.e0    ;    zt2(:,:,jpk) = 0.e0
+      zs1(:,:,jpk) = 0.e0    ;    zs2(:,:,jpk) = 0.e0
+
+      ! lateral boundary conditions on zt1, zt2 ; zs1, zs2   (changed sign)
+      CALL lbc_lnk( zt1, 'U', -1. )   ;   CALL lbc_lnk( zs1, 'U', -1. )
+      CALL lbc_lnk( zt2, 'V', -1. )   ;   CALL lbc_lnk( zs2, 'V', -1. )
+
+      ! Slopes
+      ! interior values
+      DO jk = 1, jpkm1
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji-1,jj  ,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji-1,jj  ,jk) ) )
+               zsp1(ji,jj,jk) =                    ( zs1(ji,jj,jk) + zs1(ji-1,jj  ,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs1(ji,jj,jk) * zs1(ji-1,jj  ,jk) ) )
+               ztp2(ji,jj,jk) =                    ( zt2(ji,jj,jk) + zt2(ji  ,jj-1,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt2(ji,jj,jk) * zt2(ji  ,jj-1,jk) ) )
+               zsp2(ji,jj,jk) =                    ( zs2(ji,jj,jk) + zs2(ji  ,jj-1,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs2(ji,jj,jk) * zs2(ji  ,jj-1,jk) ) )
+            END DO
+         END DO
+      END DO
+      ! bottom values
+      ztp1(:,:,jpk) = 0.e0    ;    ztp2(:,:,jpk) = 0.e0
+      zsp1(:,:,jpk) = 0.e0    ;    zsp2(:,:,jpk) = 0.e0
+
+      ! Slopes limitation
+      DO jk = 1, jpkm1
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp1(ji  ,jj,jk) ),   &
+                  &                  2.*ABS( zt1 (ji-1,jj,jk) ),   &
+                  &                  2.*ABS( zt1 (ji  ,jj,jk) ) )
+               zsp1(ji,jj,jk) = SIGN( 1., zsp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp1(ji  ,jj,jk) ),   &
+                  &                  2.*ABS( zs1 (ji-1,jj,jk) ),   &
+                  &                  2.*ABS( zs1 (ji  ,jj,jk) ) )
+               ztp2(ji,jj,jk) = SIGN( 1., ztp2(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp2(ji,jj  ,jk) ),   &
+                  &                  2.*ABS( zt2 (ji,jj-1,jk) ),   &
+                  &                  2.*ABS( zt2 (ji,jj  ,jk) ) )
+               zsp2(ji,jj,jk) = SIGN( 1., zsp2(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp2(ji,jj  ,jk) ),   &
+                  &                  2.*ABS( zs2 (ji,jj-1,jk) ),   &
+                  &                  2.*ABS( zs2 (ji,jj  ,jk) ) )
+            END DO
+         END DO
+      END DO        
+
+      ! Advection terms
+      ! interior values
+      DO jk = 1, jpkm1
+         zstep  = z2 * rdttra(jk)
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! volume fluxes
+#if defined key_zco
+               zeu = e2u(ji,jj)                   * pun(ji,jj,jk)
+               zev = e1v(ji,jj)                   * pvn(ji,jj,jk)
+#else
+               zeu = e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zev = e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+#endif
+               ! MUSCL fluxes
+               z0u = SIGN( 0.5, pun(ji,jj,jk) )            
+               zalpha = 0.5 - z0u
+               zu  = z0u - 0.5 * pun(ji,jj,jk) * zstep / e1u(ji,jj)
+               zzt1 = tb(ji+1,jj,jk) + zu*ztp1(ji+1,jj,jk)
+               zzt2 = tb(ji  ,jj,jk) + zu*ztp1(ji  ,jj,jk)
+               zzs1 = sb(ji+1,jj,jk) + zu*zsp1(ji+1,jj,jk)
+               zzs2 = sb(ji  ,jj,jk) + zu*zsp1(ji  ,jj,jk)
+               zt1(ji,jj,jk) = zeu * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+               zs1(ji,jj,jk) = zeu * ( zalpha * zzs1 + (1.-zalpha) * zzs2 )
+               !
+               z0v = SIGN( 0.5, pvn(ji,jj,jk) )            
+               zalpha = 0.5 - z0v
+               zv  = z0v - 0.5 * pvn(ji,jj,jk) * zstep / e2v(ji,jj)
+               zzt1 = tb(ji,jj+1,jk) + zv*ztp2(ji,jj+1,jk)
+               zzt2 = tb(ji,jj  ,jk) + zv*ztp2(ji,jj  ,jk)
+               zzs1 = sb(ji,jj+1,jk) + zv*zsp2(ji,jj+1,jk)
+               zzs2 = sb(ji,jj  ,jk) + zv*zsp2(ji,jj  ,jk)
+               zt2(ji,jj,jk) = zev * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+               zs2(ji,jj,jk) = zev * ( zalpha * zzs1 + (1.-zalpha) * zzs2 )
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary conditions on zt1, zt2 ; zs1, zs2   (changed sign)
+      CALL lbc_lnk( zt1, 'U', -1. )   ;   CALL lbc_lnk( zs1, 'U', -1. ) 
+      CALL lbc_lnk( zt2, 'V', -1. )   ;   CALL lbc_lnk( zs2, 'V', -1. )
+
+      ! Tracer flux divergence at t-point added to the general trend
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+#else
+               zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+#endif
+               ! horizontal advective trends
+               zta = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk  )   &
+                  &           + zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk  ) )
+               zsa = - zbtr * ( zs1(ji,jj,jk) - zs1(ji-1,jj  ,jk  )   &
+                  &           + zs2(ji,jj,jk) - zs2(ji  ,jj-1,jk  ) ) 
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO
+        END DO
+      END DO        
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' muscl had  - Ta: ', mask1=tmask ,  &
+         &                       tab3d_2=sa, clinfo2=             ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      ! Save the horizontal advective trends for diagnostics
+      IF( l_trdtra ) THEN
+         ztrdt(:,:,:) = 0.e0   ;   ztrds(:,:,:) = 0.e0
+         !
+         ! T/S ZONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_x = (  e2u(ji  ,jj) * pun(ji  ,jj,jk)                              &
+                     &         - e2u(ji-1,jj) * pun(ji-1,jj,jk) ) * zbtr
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj,jk) ) + tn(ji,jj,jk) * z_hdivn_x
+                  ztrds(ji,jj,jk) = - zbtr * ( zs1(ji,jj,jk) - zs1(ji-1,jj,jk) ) + sn(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)
+
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_y = (  e1v(ji,jj  ) * pvn(ji,jj  ,jk)                              &
+                     &         - e1v(ji,jj-1) * pvn(ji,jj-1,jk) ) * zbtr
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - zbtr * ( zt2(ji,jj,jk) - zt2(ji,jj-1,jk) ) + tn(ji,jj,jk) * z_hdivn_y          
+                  ztrds(ji,jj,jk) = - zbtr * ( zs2(ji,jj,jk) - zs2(ji,jj-1,jk) ) + sn(ji,jj,jk) * z_hdivn_y
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)
+
+         ! Save the up-to-date ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+         !
+      ENDIF
+
+      ! "zonal" mean advective heat and salt transport
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                    zt2(ji,jj,jk) = zt2(ji,jj,jk) * fse3v(ji,jj,jk)
+                    zs2(ji,jj,jk) = zs2(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         pht_adv(:) = ptr_vj( zt2(:,:,:) )
+         pst_adv(:) = ptr_vj( zs2(:,:,:) )
+      ENDIF
+
+      ! II. Vertical advective fluxes
+      ! -----------------------------
+      
+      ! First guess of the slope
+      ! interior values
+      DO jk = 2, jpkm1
+         zt1(:,:,jk) = tmask(:,:,jk) * ( tb(:,:,jk-1) - tb(:,:,jk) )
+         zs1(:,:,jk) = tmask(:,:,jk) * ( sb(:,:,jk-1) - sb(:,:,jk) )
+      END DO
+      ! surface & bottom boundary conditions
+      zt1 (:,:, 1 ) = 0.e0    ;    zt1 (:,:,jpk) = 0.e0
+      zs1 (:,:, 1 ) = 0.e0    ;    zs1 (:,:,jpk) = 0.e0
+
+      ! Slopes
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji,jj,jk+1) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji,jj,jk+1) ) )
+               zsp1(ji,jj,jk) =                    ( zs1(ji,jj,jk) + zs1(ji,jj,jk+1) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs1(ji,jj,jk) * zs1(ji,jj,jk+1) ) )
+            END DO
+         END DO
+      END DO
+
+      ! Slopes limitation
+      ! interior values
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp1(ji,jj,jk  ) ),   &
+                  &                  2.*ABS( zt1 (ji,jj,jk+1) ),   &
+                  &                  2.*ABS( zt1 (ji,jj,jk  ) ) )
+               zsp1(ji,jj,jk) = SIGN( 1., zsp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp1(ji,jj,jk  ) ),   &
+                  &                  2.*ABS( zs1 (ji,jj,jk+1) ),   &
+                  &                  2.*ABS( zs1 (ji,jj,jk  ) ) )
+            END DO
+         END DO
+      END DO
+      ! surface values
+      ztp1(:,:,1) = 0.e0
+      zsp1(:,:,1) = 0.e0
+
+      ! vertical advective flux
+      ! interior values
+      DO jk = 1, jpkm1
+         zstep  = z2 * rdttra(jk)
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zew = pwn(ji,jj,jk+1)
+               z0w = SIGN( 0.5, pwn(ji,jj,jk+1) )
+               zalpha = 0.5 + z0w
+               zw  = z0w - 0.5 * pwn(ji,jj,jk+1)*zstep / fse3w(ji,jj,jk+1)
+               zzt1 = tb(ji,jj,jk+1) + zw*ztp1(ji,jj,jk+1)
+               zzt2 = tb(ji,jj,jk  ) + zw*ztp1(ji,jj,jk  )
+               zzs1 = sb(ji,jj,jk+1) + zw*zsp1(ji,jj,jk+1)
+               zzs2 = sb(ji,jj,jk  ) + zw*zsp1(ji,jj,jk  )
+               zt1(ji,jj,jk+1) = zew * ( zalpha * zzt1 + (1.-zalpha)*zzt2 )
+               zs1(ji,jj,jk+1) = zew * ( zalpha * zzs1 + (1.-zalpha)*zzs2 )
+            END DO
+         END DO
+      END DO
+      ! surface values
+      IF( lk_vvl ) THEN
+         ! variable volume : flux set to zero
+         zt1(:,:, 1 ) = 0.e0
+         zs1(:,:, 1 ) = 0.e0
+      ELSE
+         ! free surface-constant volume
+         zt1(:,:, 1 ) = pwn(:,:,1) * tb(:,:,1)
+         zs1(:,:, 1 ) = pwn(:,:,1) * sb(:,:,1)
+      ENDIF
+
+      ! bottom values
+      zt1(:,:,jpk) = 0.e0
+      zs1(:,:,jpk) = 0.e0
+
+
+      ! Compute & add the vertical advective trend
+
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr = 1. / fse3t(ji,jj,jk)
+               ! horizontal advective trends
+               zta = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+               zsa = - zbtr * ( zs1(ji,jj,jk) - zs1(ji,jj,jk+1) )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) =  ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) =  sa(ji,jj,jk) + zsa
+            END DO
+         END DO
+      END DO
+
+      ! Save the vertical advective trends for diagnostic
+      ! -------------------------------------------------
+      IF( l_trdtra )   THEN
+         ! Recompute the vertical advection zta & zsa trends computed 
+         ! at the step 2. above in making the difference between the new 
+         ! trends and the previous one: ta()/sa - ztrdt()/ztrds() and substract
+         ! the term tn()/sn()*hdivn() to recover the W gradz(T/S) trends
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_x = e2u(ji,jj)*pun(ji,jj,jk) - e2u(ji-1,jj)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*pvn(ji,jj,jk) - e1v(ji,jj-1)*pvn(ji,jj-1,jk)
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+#endif
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  ztrdt(ji,jj,jk) = ta(ji,jj,jk) - ztrdt(ji,jj,jk) - tn(ji,jj,jk) * z_hdivn 
+                  ztrds(ji,jj,jk) = sa(ji,jj,jk) - ztrds(ji,jj,jk) - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' muscl zad  - Ta: ', mask1=tmask ,   &
+         &                       tab3d_2=sa, clinfo2=             ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_adv_muscl
+
+   !!======================================================================
+END MODULE traadv_muscl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_muscl2.F90	(revision 1844)
@@ -0,0 +1,496 @@
+MODULE traadv_muscl2
+   !!==============================================================================
+   !!                       ***  MODULE  traadv_muscl2  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+   !! History :  9.0  !  02-06  (G. Madec) from traadv_muscl
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_muscl2 : update the tracer trend with the horizontal
+   !!                    and vertical advection trends using MUSCL2 scheme
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE trabbl          ! tracers: bottom boundary layer
+   USE lib_mpp
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link) 
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC tra_adv_muscl2        ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_muscl2( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_adv_muscl2  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to total advection of T and 
+      !!      S using a MUSCL scheme (Monotone Upstream-centered Scheme for
+      !!      Conservation Laws) and add it to the general tracer trend.
+      !!
+      !! ** Method  : MUSCL scheme plus centered scheme at ocean boundaries
+      !!
+      !! ** Action  : - update (ta,sa) with the now advective tracer trends
+      !!              - save trends in (ztrdt,ztrds) ('key_trdtra')
+      !!
+      !! References : Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
+      !!              IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
+      !!----------------------------------------------------------------------
+      USE oce              , ztrdt => ua   ! use ua as workspace
+      USE oce              , ztrds => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pun   ! ocean velocity u-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvn   ! ocean velocity v-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pwn   ! ocean velocity w-component
+      !!
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   &
+         zu, zv, zw, zeu, zev,           &  
+         zew, zbtr, zstep,               &
+         z0u, z0v, z0w,                  &
+         zzt1, zzt2, zalpha,             &
+         zzs1, zzs2, z2,                 &
+         zta, zsa,                       &
+         z_hdivn_x, z_hdivn_y, z_hdivn
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zt1, zt2, ztp1, ztp2   ! 3D workspace
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zs1, zs2, zsp1, zsp2   !  "      "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv_muscl2 : MUSCL2 advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+      ENDIF
+
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;   z2 = 1.
+      ELSE                                        ;   z2 = 2.
+      ENDIF
+
+      ! I. Horizontal advective fluxes
+      ! ------------------------------
+
+      ! first guess of the slopes
+      ! interior values
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1      
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zt1(ji,jj,jk) = umask(ji,jj,jk) * ( tb(ji+1,jj,jk) - tb(ji,jj,jk) )
+               zs1(ji,jj,jk) = umask(ji,jj,jk) * ( sb(ji+1,jj,jk) - sb(ji,jj,jk) )
+               zt2(ji,jj,jk) = vmask(ji,jj,jk) * ( tb(ji,jj+1,jk) - tb(ji,jj,jk) )
+               zs2(ji,jj,jk) = vmask(ji,jj,jk) * ( sb(ji,jj+1,jk) - sb(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      ! bottom values
+      zt1(:,:,jpk) = 0.e0    ;    zt2(:,:,jpk) = 0.e0
+      zs1(:,:,jpk) = 0.e0    ;    zs2(:,:,jpk) = 0.e0
+
+      ! lateral boundary conditions on zt1, zt2 ; zs1, zs2   (changed sign)
+      CALL lbc_lnk( zt1, 'U', -1. )   ;   CALL lbc_lnk( zs1, 'U', -1. )
+      CALL lbc_lnk( zt2, 'V', -1. )   ;   CALL lbc_lnk( zs2, 'V', -1. )
+
+      ! Slopes
+      ! interior values
+      DO jk = 1, jpkm1
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji-1,jj  ,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji-1,jj  ,jk) ) )
+               zsp1(ji,jj,jk) =                    ( zs1(ji,jj,jk) + zs1(ji-1,jj  ,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs1(ji,jj,jk) * zs1(ji-1,jj  ,jk) ) )
+               ztp2(ji,jj,jk) =                    ( zt2(ji,jj,jk) + zt2(ji  ,jj-1,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt2(ji,jj,jk) * zt2(ji  ,jj-1,jk) ) )
+               zsp2(ji,jj,jk) =                    ( zs2(ji,jj,jk) + zs2(ji  ,jj-1,jk) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs2(ji,jj,jk) * zs2(ji  ,jj-1,jk) ) )
+            END DO
+         END DO
+      END DO
+      ! bottom values
+      ztp1(:,:,jpk) = 0.e0    ;    ztp2(:,:,jpk) = 0.e0
+      zsp1(:,:,jpk) = 0.e0    ;    zsp2(:,:,jpk) = 0.e0
+
+      ! Slopes limitation
+      DO jk = 1, jpkm1
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp1(ji  ,jj,jk) ),   &
+                  &                  2.*ABS( zt1 (ji-1,jj,jk) ),   &
+                  &                  2.*ABS( zt1 (ji  ,jj,jk) ) )
+               zsp1(ji,jj,jk) = SIGN( 1., zsp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp1(ji  ,jj,jk) ),   &
+                  &                  2.*ABS( zs1 (ji-1,jj,jk) ),   &
+                  &                  2.*ABS( zs1 (ji  ,jj,jk) ) )
+               ztp2(ji,jj,jk) = SIGN( 1., ztp2(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp2(ji,jj  ,jk) ),   &
+                  &                  2.*ABS( zt2 (ji,jj-1,jk) ),   &
+                  &                  2.*ABS( zt2 (ji,jj  ,jk) ) )
+               zsp2(ji,jj,jk) = SIGN( 1., zsp2(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp2(ji,jj  ,jk) ),   &
+                  &                  2.*ABS( zs2 (ji,jj-1,jk) ),   &
+                  &                  2.*ABS( zs2 (ji,jj  ,jk) ) )
+            END DO
+         END DO
+      END DO        
+
+      ! Advection terms
+      ! interior values
+      DO jk = 1, jpkm1
+         zstep  = z2 * rdttra(jk)
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! volume fluxes
+#if defined key_zco
+               zeu = e2u(ji,jj)                   * pun(ji,jj,jk)
+               zev = e1v(ji,jj)                   * pvn(ji,jj,jk)
+#else
+               zeu = e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zev = e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+#endif
+               ! MUSCL fluxes
+               z0u = SIGN( 0.5, pun(ji,jj,jk) )            
+               zalpha = 0.5 - z0u
+               zu  = z0u - 0.5 * pun(ji,jj,jk) * zstep / e1u(ji,jj)
+               zzt1 = tb(ji+1,jj,jk) + zu*ztp1(ji+1,jj,jk)
+               zzt2 = tb(ji  ,jj,jk) + zu*ztp1(ji  ,jj,jk)
+               zzs1 = sb(ji+1,jj,jk) + zu*zsp1(ji+1,jj,jk)
+               zzs2 = sb(ji  ,jj,jk) + zu*zsp1(ji  ,jj,jk)
+               zt1(ji,jj,jk) = zeu * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+               zs1(ji,jj,jk) = zeu * ( zalpha * zzs1 + (1.-zalpha) * zzs2 )
+               !
+               z0v = SIGN( 0.5, pvn(ji,jj,jk) )            
+               zalpha = 0.5 - z0v
+               zv  = z0v - 0.5 * pvn(ji,jj,jk) * zstep / e2v(ji,jj)
+               zzt1 = tb(ji,jj+1,jk) + zv*ztp2(ji,jj+1,jk)
+               zzt2 = tb(ji,jj  ,jk) + zv*ztp2(ji,jj  ,jk)
+               zzs1 = sb(ji,jj+1,jk) + zv*zsp2(ji,jj+1,jk)
+               zzs2 = sb(ji,jj  ,jk) + zv*zsp2(ji,jj  ,jk)
+               zt2(ji,jj,jk) = zev * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+               zs2(ji,jj,jk) = zev * ( zalpha * zzs1 + (1.-zalpha) * zzs2 )
+            END DO
+         END DO
+      END DO
+
+      !!!!  centered scheme at lateral b.C. if off-shore velocity
+      DO jk = 1, jpkm1
+        DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               IF( umask(ji,jj,jk) == 0. ) THEN
+                  IF( pun(ji+1,jj,jk) > 0. .AND. ji /= jpi ) THEN
+                     zt1(ji+1,jj,jk) = e2u(ji+1,jj) * pun(ji+1,jj,jk) * ( tb(ji+1,jj,jk) + tb(ji+2,jj,jk) ) * 0.5
+                     zs1(ji+1,jj,jk) = e2u(ji+1,jj) * pun(ji+1,jj,jk) * ( sb(ji+1,jj,jk) + sb(ji+2,jj,jk) ) * 0.5
+                  ENDIF
+                  IF( pun(ji-1,jj,jk) < 0. ) THEN
+                     zt1(ji-1,jj,jk) = e2u(ji-1,jj) * pun(ji-1,jj,jk) * ( tb(ji-1,jj,jk) + tb(ji  ,jj,jk) ) * 0.5
+                     zs1(ji-1,jj,jk) = e2u(ji-1,jj) * pun(ji-1,jj,jk) * ( sb(ji-1,jj,jk) + sb(ji  ,jj,jk) ) * 0.5
+                  ENDIF
+               ENDIF
+               IF( vmask(ji,jj,jk) == 0. ) THEN
+                  IF( pvn(ji,jj+1,jk) > 0. .AND. jj /= jpj ) THEN
+                     zt2(ji,jj+1,jk) = e1v(ji,jj+1) * pvn(ji,jj+1,jk) * ( tb(ji,jj+1,jk) + tb(ji,jj+2,jk) ) * 0.5
+                     zs2(ji,jj+1,jk) = e1v(ji,jj+1) * pvn(ji,jj+1,jk) * ( sb(ji,jj+1,jk) + sb(ji,jj+2,jk) ) * 0.5
+                  ENDIF
+                  IF( pvn(ji,jj-1,jk) < 0. ) THEN
+                     zt2(ji,jj-1,jk) = e1v(ji,jj-1) * pvn(ji,jj-1,jk) * ( tb(ji,jj-1,jk) + tb(ji  ,jj,jk) ) * 0.5
+                     zs2(ji,jj-1,jk) = e1v(ji,jj-1) * pvn(ji,jj-1,jk) * ( sb(ji,jj-1,jk) + sb(ji  ,jj,jk) ) * 0.5
+                  ENDIF
+               ENDIF
+#else
+               IF( umask(ji,jj,jk) == 0. ) THEN
+                  IF( pun(ji+1,jj,jk) > 0. .AND. ji /= jpi ) THEN
+                     zt1(ji+1,jj,jk) = e2u(ji+1,jj)* fse3u(ji+1,jj,jk)   &
+                        &            * pun(ji+1,jj,jk) * ( tb(ji+1,jj,jk) + tb(ji+2,jj,jk) ) * 0.5
+                     zs1(ji+1,jj,jk) = e2u(ji+1,jj)* fse3u(ji+1,jj,jk)   &
+                        &            * pun(ji+1,jj,jk) * ( sb(ji+1,jj,jk) + sb(ji+2,jj,jk) ) * 0.5
+                  ENDIF
+                  IF( pun(ji-1,jj,jk) < 0. ) THEN
+                     zt1(ji-1,jj,jk) = e2u(ji-1,jj)* fse3u(ji-1,jj,jk)   &
+                        &            * pun(ji-1,jj,jk) * ( tb(ji-1,jj,jk) + tb(ji  ,jj,jk) ) * 0.5
+                     zs1(ji-1,jj,jk) = e2u(ji-1,jj)* fse3u(ji-1,jj,jk)   &
+                        &            * pun(ji-1,jj,jk) * ( sb(ji-1,jj,jk) + sb(ji  ,jj,jk) ) * 0.5
+                  ENDIF
+               ENDIF
+               IF( vmask(ji,jj,jk) == 0. ) THEN
+                  IF( pvn(ji,jj+1,jk) > 0. .AND. jj /= jpj ) THEN
+                     zt2(ji,jj+1,jk) = e1v(ji,jj+1) * fse3v(ji,jj+1,jk)   &
+                        &            * pvn(ji,jj+1,jk) * ( tb(ji,jj+1,jk) + tb(ji,jj+2,jk) ) * 0.5
+                     zs2(ji,jj+1,jk) = e1v(ji,jj+1) * fse3v(ji,jj+1,jk)   &
+                        &            * pvn(ji,jj+1,jk) * ( sb(ji,jj+1,jk) + sb(ji,jj+2,jk) ) * 0.5
+                  ENDIF
+                  IF( pvn(ji,jj-1,jk) < 0. ) THEN
+                     zt2(ji,jj-1,jk) = e1v(ji,jj-1)* fse3v(ji,jj-1,jk)   &
+                        &            * pvn(ji,jj-1,jk) * ( tb(ji,jj-1,jk) + tb(ji  ,jj,jk) ) * 0.5
+                     zs2(ji,jj-1,jk) = e1v(ji,jj-1)* fse3v(ji,jj-1,jk)   &
+                        &            * pvn(ji,jj-1,jk) * ( sb(ji,jj-1,jk) + sb(ji  ,jj,jk) ) * 0.5
+                  ENDIF
+               ENDIF
+#endif
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary conditions on zt1, zt2 ; zs1, zs2   (changed sign)
+      CALL lbc_lnk( zt1, 'U', -1. )   ;   CALL lbc_lnk( zs1, 'U', -1. ) 
+      CALL lbc_lnk( zt2, 'V', -1. )   ;   CALL lbc_lnk( zs2, 'V', -1. )
+
+      ! Compute & add the horizontal advective trend
+
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+#else
+               zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+#endif
+               ! horizontal advective trends
+               zta = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk  )   &
+                  &           + zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk  ) )
+               zsa = - zbtr * ( zs1(ji,jj,jk) - zs1(ji-1,jj  ,jk  )   &
+                  &           + zs2(ji,jj,jk) - zs2(ji  ,jj-1,jk  ) ) 
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO
+        END DO
+      END DO        
+
+      ! Save the horizontal advective trends for diagnostic
+      IF( l_trdtra ) THEN
+         ztrdt(:,:,:) = 0.e0   ;   ztrds(:,:,:) = 0.e0
+         !
+         ! T/S ZONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_x = (  e2u(ji  ,jj) * pun(ji  ,jj,jk)                              &
+                     &         - e2u(ji-1,jj) * pun(ji-1,jj,jk) ) * zbtr
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj,jk) ) + tn(ji,jj,jk) * z_hdivn_x
+                  ztrds(ji,jj,jk) = - zbtr * ( zs1(ji,jj,jk) - zs1(ji-1,jj,jk) ) + sn(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)
+
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_y = (  e1v(ji,jj  ) * pvn(ji,jj  ,jk)                              &
+                     &         - e1v(ji,jj-1) * pvn(ji,jj-1,jk) ) * zbtr
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - zbtr * ( zt2(ji,jj,jk) - zt2(ji,jj-1,jk) ) + tn(ji,jj,jk) * z_hdivn_y          
+                  ztrds(ji,jj,jk) = - zbtr * ( zs2(ji,jj,jk) - zs2(ji,jj-1,jk) ) + sn(ji,jj,jk) * z_hdivn_y
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)
+
+         ! Save the up-to-date ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' muscl2 had  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=              ' Sa: ', mask2=tmask, clinfo3='tra')
+
+      ! "zonal" mean advective heat and salt transport
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                    zt2(ji,jj,jk) = zt2(ji,jj,jk) * fse3v(ji,jj,jk)
+                    zs2(ji,jj,jk) = zs2(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         pht_adv(:) = ptr_vj( zt2(:,:,:) )
+         pst_adv(:) = ptr_vj( zs2(:,:,:) )
+      ENDIF
+
+      ! II. Vertical advective fluxes
+      ! -----------------------------
+      
+      ! First guess of the slope
+      ! interior values
+      DO jk = 2, jpkm1
+         zt1(:,:,jk) = tmask(:,:,jk) * ( tb(:,:,jk-1) - tb(:,:,jk) )
+         zs1(:,:,jk) = tmask(:,:,jk) * ( sb(:,:,jk-1) - sb(:,:,jk) )
+      END DO
+      ! surface & bottom boundary conditions
+      zt1 (:,:, 1 ) = 0.e0    ;    zt1 (:,:,jpk) = 0.e0
+      zs1 (:,:, 1 ) = 0.e0    ;    zs1 (:,:,jpk) = 0.e0
+
+      ! Slopes
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji,jj,jk+1) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji,jj,jk+1) ) )
+               zsp1(ji,jj,jk) =                    ( zs1(ji,jj,jk) + zs1(ji,jj,jk+1) )   &
+                  &           * ( 0.25 + SIGN( 0.25, zs1(ji,jj,jk) * zs1(ji,jj,jk+1) ) )
+            END DO
+         END DO
+      END DO
+
+      ! Slopes limitation
+      ! interior values
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( ztp1(ji,jj,jk  ) ),   &
+                  &                  2.*ABS( zt1 (ji,jj,jk+1) ),   &
+                  &                  2.*ABS( zt1 (ji,jj,jk  ) ) )
+               zsp1(ji,jj,jk) = SIGN( 1., zsp1(ji,jj,jk) )   &
+                  &           * MIN(    ABS( zsp1(ji,jj,jk  ) ),   &
+                  &                  2.*ABS( zs1 (ji,jj,jk+1) ),   &
+                  &                  2.*ABS( zs1 (ji,jj,jk  ) ) )
+            END DO
+         END DO
+      END DO
+      ! surface values
+      ztp1(:,:,1) = 0.e0
+      zsp1(:,:,1) = 0.e0
+
+      ! vertical advective flux
+      ! interior values
+      DO jk = 1, jpkm1
+         zstep  = z2 * rdttra(jk)
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zew = pwn(ji,jj,jk+1)
+               z0w = SIGN( 0.5, pwn(ji,jj,jk+1) )
+               zalpha = 0.5 + z0w
+               zw  = z0w - 0.5 * pwn(ji,jj,jk+1)*zstep / fse3w(ji,jj,jk+1)
+               zzt1 = tb(ji,jj,jk+1) + zw*ztp1(ji,jj,jk+1)
+               zzt2 = tb(ji,jj,jk  ) + zw*ztp1(ji,jj,jk  )
+               zzs1 = sb(ji,jj,jk+1) + zw*zsp1(ji,jj,jk+1)
+               zzs2 = sb(ji,jj,jk  ) + zw*zsp1(ji,jj,jk  )
+               zt1(ji,jj,jk+1) = zew * ( zalpha * zzt1 + (1.-zalpha)*zzt2 )
+               zs1(ji,jj,jk+1) = zew * ( zalpha * zzs1 + (1.-zalpha)*zzs2 )
+            END DO
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+        DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( tmask(ji,jj,jk+1) == 0. ) THEN
+                  IF( pwn(ji,jj,jk) > 0. ) THEN
+                     zt1(ji,jj,jk) = pwn(ji,jj,jk) * ( tb(ji,jj,jk-1) + tb(ji,jj,jk) ) * 0.5
+                     zs1(ji,jj,jk) = pwn(ji,jj,jk) * ( sb(ji,jj,jk-1) + sb(ji,jj,jk) ) * 0.5
+                  ENDIF
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! surface values
+      IF( lk_vvl ) THEN
+         ! variable volume : flux set to zero
+         zt1(:,:, 1 ) = 0.e0
+         zs1(:,:, 1 ) = 0.e0
+      ELSE
+         ! free surface-constant volume
+         zt1(:,:, 1 ) = pwn(:,:,1) * tb(:,:,1)
+         zs1(:,:, 1 ) = pwn(:,:,1) * sb(:,:,1)
+      ENDIF
+
+      ! bottom values
+      zt1(:,:,jpk) = 0.e0
+      zs1(:,:,jpk) = 0.e0
+
+
+      ! Compute & add the vertical advective trend
+
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1      
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr = 1. / fse3t(ji,jj,jk)
+               ! horizontal advective trends
+               zta = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+               zsa = - zbtr * ( zs1(ji,jj,jk) - zs1(ji,jj,jk+1) )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) =  ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) =  sa(ji,jj,jk) + zsa
+            END DO
+         END DO
+      END DO
+
+      ! Save the vertical advective trends for diagnostic
+      IF( l_trdtra )   THEN
+         ! Recompute the vertical advection zta & zsa trends computed 
+         ! at the step 2. above in making the difference between the new 
+         ! trends and the previous one: ta()/sa - ztrdt()/ztrds() and substract
+         ! the term tn()/sn()*hdivn() to recover the W gradz(T/S) trends
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                  z_hdivn_x = e2u(ji,jj)*pun(ji,jj,jk) - e2u(ji-1,jj)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*pvn(ji,jj,jk) - e1v(ji,jj-1)*pvn(ji,jj-1,jk)
+#else
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+#endif
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  ztrdt(ji,jj,jk) = ta(ji,jj,jk) - ztrdt(ji,jj,jk) - tn(ji,jj,jk) * z_hdivn 
+                  ztrds(ji,jj,jk) = sa(ji,jj,jk) - ztrds(ji,jj,jk) - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' muscl2 zad  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=              ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_adv_muscl2
+
+   !!======================================================================
+END MODULE traadv_muscl2
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_qck.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 1844)
@@ -0,0 +1,503 @@
+MODULE traadv_qck
+   !!==============================================================================
+   !!                       ***  MODULE  traadv_qck  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+   !! History :  3.0  !  2008-07  (G. Reffray)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_qck      : update the tracer trend with the horizontal advection
+   !!                      trends using a 3rd order finite difference scheme
+   !!   tra_adv_qck_i  : 
+   !!   tra_adv_qck_j  : 
+   !!   tra_adv_cen2_k : 2nd centered scheme for the vertical advection
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE trabbl          ! advective term in the BBL
+   USE lib_mpp         ! distribued memory computing
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE dynspg_oce      ! surface pressure gradient variables
+   USE in_out_manager  ! I/O manager
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_qck   ! routine called by step.F90
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   btr2
+   REAL(wp)                     ::   r1_6
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_qck( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_qck  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations.
+      !!
+      !! ** Method :   The advection is evaluated by a third order scheme
+      !!             For a positive velocity u :              u(i)>0
+      !!                                          |--FU--|--FC--|--FD--|------|
+      !!                                             i-1    i      i+1   i+2
+      !!
+      !!             For a negative velocity u :              u(i)<0
+      !!                                          |------|--FD--|--FC--|--FU--|
+      !!                                             i-1    i      i+1   i+2
+      !!             where  FU is the second upwind point
+      !!                    FD is the first douwning point
+      !!                    FC is the central point (or the first upwind point)
+      !!
+      !!      Flux(i) = u(i) * { 0.5(FC+FD)  -0.5C(i)(FD-FC)  -((1-C(i))/6)(FU+FD-2FC) }
+      !!                with C(i)=|u(i)|dx(i)/dt (=Courant number)
+      !!
+      !!         dt = 2*rdtra and the scalar values are tb and sb
+      !!
+      !!       On the vertical, the simple centered scheme used tn and sn
+      !!
+      !!               The fluxes are bounded by the ULTIMATE limiter to
+      !!             guarantee the monotonicity of the solution and to
+      !!            prevent the appearance of spurious numerical oscillations
+      !!
+      !! ** Action : - update (ta,sa) with the now advective tracer trends
+      !!             - save the trends ('key_trdtra')
+      !!
+      !! ** Reference : Leonard (1979, 1991)
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as workspace
+      USE oce, ONLY :   ztrds => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::  kt  ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pun ! effective ocean velocity, u_component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pvn ! effective ocean velocity, v_component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pwn ! effective ocean velocity, w_component
+      !!
+      INTEGER  ::   ji, jj, jk                          ! dummy loop indices
+      REAL(wp) ::   z_hdivn_x, z_hdivn_y, z_hdivn       ! temporary scalars
+      REAL(wp) ::   zbtr, z2                            !    "         "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_qck : 3rd order quickest advection scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+         IF(lwp) WRITE(numout,*)
+         btr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+         r1_6      = 1. / 6.
+      ENDIF
+
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;    z2 = 1.
+      ELSE                                        ;    z2 = 2.
+      ENDIF
+
+      ! I. The horizontal fluxes are computed with the QUICKEST + ULTIMATE scheme
+      !---------------------------------------------------------------------------
+
+      CALL tra_adv_qck_i( pun, tb, tn, ta, ztrdt, z2)
+      CALL tra_adv_qck_i( pun, sb, sn, sa, ztrds, z2)
+
+      IF( l_trdtra ) CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)
+
+      CALL tra_adv_qck_j( kt, pvn, tb, tn, ta, ztrdt, pht_adv, z2)
+      CALL tra_adv_qck_j( kt, pvn, sb, sn, sa, ztrds, pst_adv, z2)  
+
+      IF( l_trdtra ) THEN
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)
+         !
+         ztrdt(:,:,:) = ta(:,:,:)    ! Save the horizontal up-to-date ta/sa trends
+         ztrds(:,:,:) = sa(:,:,:)
+      END IF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' qck had  - Ta: ', mask1=tmask, &
+         &                       tab3d_2=sa, clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      ! II. The vertical fluxes are computed with the 2nd order centered scheme
+      !-------------------------------------------------------------------------
+      !
+      CALL tra_adv_cen2_k( pwn, tn, ta )
+      CALL tra_adv_cen2_k( pwn, sn, sa )
+      !
+      !Save the vertical advective trends for diagnostic
+      ! ----------------------------------------------------
+      IF( l_trdtra )   THEN
+         ! Recompute the vertical advection zta & zsa trends computed
+         ! at the step 2. above in making the difference between the new
+         ! trends and the previous one: ta()/sa - ztrdt()/ztrds() and substract
+         ! the term tn()/sn()*hdivn() to recover the W gradz(T/S) trends
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+                  zbtr      = btr2(ji,jj)
+                  z_hdivn_x = e2u(ji,jj)*pun(ji,jj,jk) - e2u(ji-1,jj)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*pvn(ji,jj,jk) - e1v(ji,jj-1)*pvn(ji,jj-1,jk)
+#else
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+#endif
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  ztrdt(ji,jj,jk) = ta(ji,jj,jk) - ztrdt(ji,jj,jk) - tn(ji,jj,jk) * z_hdivn
+                  ztrds(ji,jj,jk) = sa(ji,jj,jk) - ztrds(ji,jj,jk) - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' qck zad  - Ta: ', mask1=tmask, &
+         &                       tab3d_2=sa, clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_adv_qck
+
+
+   SUBROUTINE tra_adv_qck_i ( pun, tra, tran, traa, ztrdtra, z2 )
+      !!----------------------------------------------------------------------
+      !!
+      !!----------------------------------------------------------------------
+      REAL,     INTENT(in)                            :: z2
+      REAL(wp), INTENT(in)   , DIMENSION(jpi,jpj,jpk) :: pun, tra, tran  ! horizontal effective velocity
+      REAL(wp), INTENT(out)  , DIMENSION(jpi,jpj,jpk) :: ztrdtra
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: traa
+      !
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: za, zbtr, dir, dx, dt     ! temporary scalars
+      REAL(wp) :: z_hdivn_x
+      REAL(wp), DIMENSION(jpi,jpj)     ::  zmask, zupst, zdwst, zc_cfl
+      REAL(wp), DIMENSION(jpi,jpj)     ::  zfu, zfc, zfd, zfho, zmskl, zsc_e 
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zflux
+      !----------------------------------------------------------------------
+
+      zfu   (:,jpj) = 0.e0   ;   zfc   (:,jpj) = 0.e0
+      zfd   (:,jpj) = 0.e0   ;   zc_cfl(:,jpj) = 0.e0
+      zsc_e (:,jpj) = 0.e0   ;   zmskl (:,jpj) = 0.e0
+      zfho  (:,jpj) = 0.e0
+                                                       ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !--- Computation of the ustream and downstream value of the tracer and the mask
+         DO jj = 2, jpjm1
+            DO ji = 2, fs_jpim1   ! vector opt.
+               ! Upstream in the x-direction for the tracer
+               zupst(ji,jj)=tra(ji-1,jj,jk)
+               ! Downstream in the x-direction for the tracer
+               zdwst(ji,jj)=tra(ji+1,jj,jk)
+               ! Mask at the T-points in the x-direction (mask=0 or mask=1)
+               zmask(ji,jj)=tmask(ji-1,jj,jk)+tmask(ji,jj,jk)+tmask(ji+1,jj,jk)-2
+            END DO
+         END DO
+         !
+         !--- Lateral boundary conditions 
+         CALL lbc_lnk( zupst(:,:), 'T', 1. )
+         CALL lbc_lnk( zdwst(:,:), 'T', 1. ) 
+         CALL lbc_lnk( zmask(:,:), 'T', 1. ) 
+         !
+         ! Horizontal advective fluxes
+         ! ---------------------------
+         !
+         dt = z2 * rdttra(jk)
+         !--- tracer flux at u-points
+         DO jj = 1, jpjm1
+            DO ji = 1, jpi
+#if defined key_zco
+               zsc_e(ji,jj) = e2u(ji,jj)
+#else
+               zsc_e(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk)
+#endif
+               dir = 0.5 + sign(0.5,pun(ji,jj,jk))                             ! if pun>0 : dir = 1 otherwise dir = 0
+               dx = dir * e1t(ji,jj) + (1-dir)* e1t(ji+1,jj)
+               zc_cfl (ji,jj) = ABS(pun(ji,jj,jk))*dt/dx                       ! (0<zc_cfl<1 : Courant number on x-direction)
+
+               zfu(ji,jj)   = dir*zupst(ji  ,jj   )+(1-dir)*zdwst(ji+1,jj   )  ! FU in the x-direction for T
+               zfc(ji,jj)   = dir*tra  (ji  ,jj,jk)+(1-dir)*tra  (ji+1,jj,jk)  ! FC in the x-direction for T
+               zfd(ji,jj)   = dir*tra  (ji+1,jj,jk)+(1-dir)*tra  (ji  ,jj,jk)  ! FD in the x-direction for T
+               zmskl(ji,jj) = dir*zmask(ji  ,jj)   +(1-dir)*zmask(ji+1,jj)
+           END DO
+         END DO
+         !
+         !--- QUICKEST scheme
+         ! Tracer flux on the x-direction
+         CALL quickest(zfu,zfd,zfc,zfho,zc_cfl)
+         !--- If the second ustream point is a land point
+         !--- the flux is computed by the 1st order UPWIND scheme
+         zfho(:,:) = zmskl(:,:)*zfho(:,:) + (1.-zmskl(:,:))*zfc(:,:)
+         !--- Computation of fluxes
+         zflux(:,:,jk) = zsc_e(:,:)*pun(:,:,jk)*zfho(:,:)
+         !
+         !--- Tracer flux divergence at t-point added to the general trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !--- horizontal advective trends
+#if defined key_zco
+               zbtr = btr2(ji,jj)
+#else
+               zbtr = btr2(ji,jj) / fse3t(ji,jj,jk)              
+#endif
+               za = - zbtr * ( zflux(ji,jj,jk) - zflux(ji-1,jj,jk) )
+               !--- add it to the general tracer trends
+               traa(ji,jj,jk) = traa(ji,jj,jk) + za
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      !
+      !  Save the horizontal advective trends for diagnostic
+      ! -----------------------------------------------------
+      IF( l_trdtra ) THEN
+         ! T/S ZONAL advection trends
+         ztrdtra(:,:,:) = 0.e0
+         !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = btr2(ji,jj)
+                  z_hdivn_x = (  e2u(ji  ,jj) * pun(ji  ,jj,jk)                              &
+                     &         - e2u(ji-1,jj) * pun(ji-1,jj,jk) ) * zbtr
+#else
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+#endif
+                  ztrdtra(ji,jj,jk) = - zbtr * ( zflux(ji,jj,jk) - zflux(ji-1,jj,jk) ) + tran(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+      END IF
+
+   END SUBROUTINE tra_adv_qck_i
+
+
+   SUBROUTINE tra_adv_qck_j ( kt, pvn, tra, tran, traa, ztrdtra, trd_adv, z2 )
+      !!----------------------------------------------------------------------
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER,  INTENT(in)                            :: kt              ! ocean time-step index
+      REAL,     INTENT(in)                            :: z2
+      REAL(wp), INTENT(in)   , DIMENSION(jpi,jpj,jpk) :: pvn, tra, tran  ! horizontal effective velocity
+      REAL(wp), INTENT(out)  , DIMENSION(jpj)         :: trd_adv
+      REAL(wp), INTENT(out)  , DIMENSION(jpi,jpj,jpk) :: ztrdtra
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: traa
+      !!
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: za, zbtr, dir, dx, dt     ! temporary scalars
+      REAL(wp) :: z_hdivn_y
+      REAL(wp), DIMENSION(jpi,jpj)     ::  zmask, zupst, zdwst, zc_cfl
+      REAL(wp), DIMENSION(jpi,jpj)     ::  zfu, zfc, zfd, zfho, zmskl, zsc_e
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zflux
+      !----------------------------------------------------------------------
+      ! II. Part 2 : y-direction
+      !----------------------------------------------------------------------
+
+      zfu   (:,jpj) = 0.e0   ;   zfc   (:,jpj) = 0.e0
+      zfd   (:,jpj) = 0.e0   ;   zc_cfl(:,jpj) = 0.e0
+      zsc_e (:,jpj) = 0.e0   ;   zmskl (:,jpj) = 0.e0
+      zfho  (:,jpj) = 0.e0
+
+                                                       ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !--- Computation of the ustream and downstream value of the tracer and the mask
+         DO jj = 2, jpjm1
+            DO ji = 2, fs_jpim1   ! vector opt.
+               ! Upstream in the x-direction for the tracer
+               zupst(ji,jj)=tra(ji,jj-1,jk)
+               ! Downstream in the x-direction for the tracer
+               zdwst(ji,jj)=tra(ji,jj+1,jk)
+               ! Mask at the T-points in the x-direction (mask=0 or mask=1)
+               zmask(ji,jj)=tmask(ji,jj-1,jk)+tmask(ji,jj,jk)+tmask(ji,jj+1,jk)-2
+            END DO
+         END DO
+         !
+         !--- Lateral boundary conditions
+         CALL lbc_lnk( zupst(:,:), 'T', 1. )
+         CALL lbc_lnk( zdwst(:,:), 'T', 1. )
+         CALL lbc_lnk( zmask(:,:), 'T', 1. )
+         !
+         ! Horizontal advective fluxes
+         ! ---------------------------
+         !
+         dt = z2 * rdttra(jk)
+         !--- tracer flux at v-points
+         DO jj = 1, jpjm1
+            DO ji = 1, jpi
+#if defined key_zco
+               zsc_e(ji,jj) = e1v(ji,jj)
+#else
+               zsc_e(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk)
+#endif
+               dir = 0.5 + sign(0.5,pvn(ji,jj,jk))                             ! if pvn>0 : dir = 1 otherwise dir = 0
+               dx = dir * e2t(ji,jj) + (1-dir)* e2t(ji,jj+1)
+               zc_cfl(ji,jj) = ABS(pvn(ji,jj,jk))*dt/dx                        ! (0<zc_cfl<1 : Courant number on y-direction)
+
+               zfu(ji,jj)   = dir*zupst(ji,jj     )+(1-dir)*zdwst(ji,jj+1   )  ! FU in the y-direction for T
+               zfc(ji,jj)   = dir*tra  (ji,jj  ,jk)+(1-dir)*tra  (ji,jj+1,jk)  ! FC in the y-direction for T
+               zfd(ji,jj)   = dir*tra  (ji,jj+1,jk)+(1-dir)*tra  (ji,jj  ,jk)  ! FD in the y-direction for T
+               zmskl(ji,jj) = dir*zmask(ji,jj     )+(1-dir)*zmask(ji,jj+1)
+            END DO
+         END DO
+         !
+         !--- QUICKEST scheme
+         ! Tracer flux on the y-direction
+         CALL quickest(zfu,zfd,zfc,zfho,zc_cfl)
+         !--- If the second ustream point is a land point
+         !--- the flux is computed by the 1st order UPWIND scheme
+         zfho(:,:) = zmskl(:,:)*zfho(:,:) + (1.-zmskl(:,:))*zfc(:,:)
+         !--- Computation of fluxes
+         zflux(:,:,jk) = zsc_e(:,:)*pvn(:,:,jk)*zfho(:,:)
+         !
+         !--- Tracer flux divergence at t-point added to the general trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !--- horizontal advective trends
+#if defined key_zco
+               zbtr = btr2(ji,jj)
+#else
+               zbtr = btr2(ji,jj) / fse3t(ji,jj,jk)
+#endif
+               za = - zbtr * ( zflux(ji,jj,jk) - zflux(ji,jj-1,jk) )
+               !--- add it to the general tracer trends
+               traa(ji,jj,jk) = traa(ji,jj,jk) + za
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      !
+      !  Save the horizontal advective trends for diagnostic
+      ! -----------------------------------------------------
+      IF( l_trdtra ) THEN
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+#if defined key_zco
+                  zbtr      = btr2(ji,jj)
+                  z_hdivn_y = (  e1v(ji,jj  ) * pvn(ji,jj  ,jk)                              &
+                     &         - e1v(ji,jj-1) * pvn(ji,jj-1,jk) ) * zbtr
+#else
+                  zbtr      = btr2(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+#endif
+                  ztrdtra(ji,jj,jk) = - zbtr * ( zflux(ji,jj,jk) - zflux(ji,jj-1,jk) ) + tran(ji,jj,jk) * z_hdivn_y
+               END DO
+            END DO
+         END DO
+      END IF
+
+      ! "zonal" mean advective heat and salt transport
+      ! ----------------------------------------------
+
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                    zflux(ji,jj,jk) = zflux(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         trd_adv(:) = ptr_vj( zflux(:,:,:) )
+      ENDIF
+
+   END SUBROUTINE tra_adv_qck_j
+
+
+   SUBROUTINE tra_adv_cen2_k ( pwn, ptn, pta )
+      !!----------------------------------------------------------------------
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk)  :: pwn   ! vertical effective velocity
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk)  :: ptn   ! now tracer
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk)  :: pta   ! tracer general trend
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zflux   ! 3D workspace
+      !!----------------------------------------------------------------------
+      !
+      !                         !==  Vertical advective fluxes  ==!
+      zflux(:,:,jpk) = 0.e0             ! Bottom value : flux set to zero
+      !
+      !                                 ! Surface value
+      IF( lk_vvl ) THEN   ;   zflux(:,:, 1 ) = 0.e0                      ! Variable volume : flux set to zero
+      ELSE                ;   zflux(:,:, 1 ) = pwn(:,:,1) * ptn(:,:,1)   ! Constant volume : advective flux through the surface
+      ENDIF
+      !
+      DO jk = 2, jpkm1                  ! Interior point: second order centered tracer flux at w-point
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zflux(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk-1) + ptn(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      !
+      DO jk = 1, jpkm1          !==  Tracer flux divergence added to the general trend  ==!
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               pta(ji,jj,jk) =  pta(ji,jj,jk) - ( zflux(ji,jj,jk) - zflux(ji,jj,jk+1) )   &
+                  &                           /   fse3t(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tra_adv_cen2_k
+
+
+   SUBROUTINE quickest( fu, fd, fc, fho, fc_cfl )
+      !!----------------------------------------------------------------------
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in)  , DIMENSION(jpi,jpj) :: fu, fd, fc, fc_cfl  
+      REAL(wp), INTENT(out) , DIMENSION(jpi,jpj) :: fho
+      REAL(wp)              , DIMENSION(jpi,jpj) :: zcurv, zcoef1, zcoef2, zcoef3  ! temporary scalars
+      !
+      zcurv (:,:) = fd(:,:) + fu(:,:) - 2.*fc(:,:)
+      zcoef1(:,:) = 0.5*( fc(:,:) + fd(:,:) )
+      zcoef2(:,:) = 0.5*fc_cfl(:,:)*( fd(:,:) - fc(:,:) )
+      zcoef3(:,:) = ( ( 1. - ( fc_cfl(:,:)*fc_cfl(:,:) ) )*r1_6 )*zcurv(:,:)
+      fho   (:,:) = zcoef1(:,:) - zcoef2(:,:) - zcoef3(:,:)                         ! phi_f QUICKEST 
+      !
+      zcoef1(:,:) = fd(:,:) - fu(:,:)                                               ! DEL
+      zcoef2(:,:) = ABS( zcoef1(:,:) )                                              ! ABS(DEL)
+      zcoef3(:,:) = ABS( zcurv(:,:) )                                               ! ABS(CURV)
+      !
+      WHERE ( zcoef3(:,:) >= zcoef2(:,:) ) 
+        fho(:,:) = fc(:,:)
+      ELSEWHERE
+        zcoef3(:,:) = fu(:,:) + ( ( fc(:,:) - fu(:,:) )/MAX(fc_cfl(:,:),1.e-9) )    ! phi_REF
+          WHERE ( zcoef1(:,:) >= 0.e0 )
+            fho(:,:) = MAX(fc(:,:),fho(:,:))
+            fho(:,:) = MIN(fho(:,:),MIN(zcoef3(:,:),fd(:,:)))
+          ELSEWHERE
+            fho(:,:) = MIN(fc(:,:),fho(:,:))
+            fho(:,:) = MAX(fho(:,:),MAX(zcoef3(:,:),fd(:,:)))
+          ENDWHERE
+      ENDWHERE
+      !
+   END SUBROUTINE quickest
+
+   !!======================================================================
+END MODULE traadv_qck
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_tvd.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 1844)
@@ -0,0 +1,491 @@
+MODULE traadv_tvd
+   !!==============================================================================
+   !!                       ***  MODULE  traadv_tvd  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+   !! History :       !  95-12  (L. Mortier)  Original code
+   !!                 !  00-01  (H. Loukos)  adapted to ORCA 
+   !!                 !  00-10  (MA Foujols E.Kestenare)  include file not routine
+   !!                 !  00-12  (E. Kestenare M. Levy)  fix bug in trtrd indexes
+   !!                 !  01-07  (E. Durand G. Madec)  adaptation to ORCA config
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-01  (A. de Miranda, G. Madec, J.M. Molines ): advective bbl
+   !!            9.0  !  08-04  (S. Cravatte) add the i-, j- & k- trends computation
+   !!            " "  !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!----------------------------------------------------------------------
+
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_tvd  : update the tracer trend with the horizontal
+   !!                  and vertical advection trends using a TVD scheme
+   !!   nonosc       : compute monotonic tracer fluxes by a nonoscillatory
+   !!                  algorithm 
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE trabbl          ! Advective term of BBL
+   USE lib_mpp
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link) 
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_tvd    ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_tvd( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_tvd  ***
+      !! 
+      !! **  Purpose :   Compute the now trend due to total advection of 
+      !!       tracers and add it to the general trend of tracer equations
+      !!
+      !! **  Method  :   TVD scheme, i.e. 2nd order centered scheme with
+      !!       corrected flux (monotonic correction)
+      !!       note: - this advection scheme needs a leap-frog time scheme
+      !!
+      !! ** Action : - update (ta,sa) with the now advective tracer trends
+      !!             - save the trends in (ztrdt,ztrds) ('key_trdtra')
+      !!----------------------------------------------------------------------
+      USE oce              , ztrdt => ua   ! use ua as workspace
+      USE oce              , ztrds => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt    ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pun   ! ocean velocity u-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvn   ! ocean velocity v-component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pwn   ! ocean velocity w-component
+      !!
+      INTEGER  ::   ji, jj, jk              ! dummy loop indices
+      REAL(wp) ::                        &  ! temporary scalar
+         ztat, zsat,                     &  !    "         "   
+         z_hdivn_x, z_hdivn_y, z_hdivn
+      REAL(wp) ::   &
+         z2dtt, zbtr, zeu, zev,          &  ! temporary scalar
+         zew, z2, zbtr1,                 &  ! temporary scalar
+         zfp_ui, zfp_vj, zfp_wk,         &  !    "         "
+         zfm_ui, zfm_vj, zfm_wk             !    "         "
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zti, ztu, ztv, ztw   ! temporary workspace
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zsi, zsu, zsv, zsw   !    "           "
+      !!----------------------------------------------------------------------
+
+      zti(:,:,:) = 0.e0   ;   zsi(:,:,:) = 0.e0
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv_tvd : TVD advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;    z2 = 1.
+      ELSE                                        ;    z2 = 2.
+      ENDIF
+
+      ! 1. Bottom value : flux set to zero
+      ! ---------------
+      ztu(:,:,jpk) = 0.e0   ;   zsu(:,:,jpk) = 0.e0
+      ztv(:,:,jpk) = 0.e0   ;   zsv(:,:,jpk) = 0.e0
+      ztw(:,:,jpk) = 0.e0   ;   zsw(:,:,jpk) = 0.e0
+      zti(:,:,jpk) = 0.e0   ;   zsi(:,:,jpk) = 0.e0
+
+
+      ! 2. upstream advection with initial mass fluxes & intermediate update
+      ! --------------------------------------------------------------------
+      ! upstream tracer flux in the i and j direction
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zeu = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zev = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+               ! upstream scheme
+               zfp_ui = zeu + ABS( zeu )
+               zfm_ui = zeu - ABS( zeu )
+               zfp_vj = zev + ABS( zev )
+               zfm_vj = zev - ABS( zev )
+               ztu(ji,jj,jk) = zfp_ui * tb(ji,jj,jk) + zfm_ui * tb(ji+1,jj  ,jk)
+               ztv(ji,jj,jk) = zfp_vj * tb(ji,jj,jk) + zfm_vj * tb(ji  ,jj+1,jk)
+               zsu(ji,jj,jk) = zfp_ui * sb(ji,jj,jk) + zfm_ui * sb(ji+1,jj  ,jk)
+               zsv(ji,jj,jk) = zfp_vj * sb(ji,jj,jk) + zfm_vj * sb(ji  ,jj+1,jk)
+            END DO
+         END DO
+      END DO
+
+      ! upstream tracer flux in the k direction
+      ! Surface value
+      IF( lk_vvl ) THEN
+         ! variable volume : flux set to zero
+         ztw(:,:,1) = 0.e0
+         zsw(:,:,1) = 0.e0
+      ELSE
+         ! free surface-constant volume
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,1)
+               ztw(ji,jj,1) = zew * tb(ji,jj,1)
+               zsw(ji,jj,1) = zew * sb(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+
+      ! Interior value
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,jk)
+               zfp_wk = zew + ABS( zew )
+               zfm_wk = zew - ABS( zew )
+               ztw(ji,jj,jk) = zfp_wk * tb(ji,jj,jk) + zfm_wk * tb(ji,jj,jk-1)
+               zsw(ji,jj,jk) = zfp_wk * sb(ji,jj,jk) + zfm_wk * sb(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! total advective trend
+      DO jk = 1, jpkm1
+         z2dtt = z2 * rdttra(jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr = 1./ ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+               ! total intermediate advective trends
+               ztat = - ( ztu(ji,jj,jk) - ztu(ji-1,jj  ,jk  )   &
+                  &     + ztv(ji,jj,jk) - ztv(ji  ,jj-1,jk  )   &
+                  &     + ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) * zbtr
+               zsat = - ( zsu(ji,jj,jk) - zsu(ji-1,jj  ,jk  )   & 
+                  &     + zsv(ji,jj,jk) - zsv(ji  ,jj-1,jk  )   &
+                  &     + zsw(ji,jj,jk) - zsw(ji  ,jj  ,jk+1) ) * zbtr
+               ! update and guess with monotonic sheme
+               ta(ji,jj,jk) =  ta(ji,jj,jk) + ztat
+               sa(ji,jj,jk) =  sa(ji,jj,jk) + zsat
+               zti (ji,jj,jk) = ( tb(ji,jj,jk) + z2dtt * ztat ) * tmask(ji,jj,jk)
+               zsi (ji,jj,jk) = ( sb(ji,jj,jk) + z2dtt * zsat ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+
+      ! Save the intermediate i / j / k advective trends for diagnostics
+      ! -------------------------------------------------------------------
+      ! Warning : We should use zun instead of un in the computations below, but we
+      ! also use hdivn which is computed with un, vn (check ???). So we use un, vn
+      ! for consistency. Results are therefore approximate with key_trabbl_adv.
+
+      IF( l_trdtra ) THEN
+         ztrdt(:,:,:) = 0.e0   ;   ztrds(:,:,:) = 0.e0
+         ! 
+         ! T/S ZONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  ztrdt(ji,jj,jk) = - ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) ) * zbtr
+                  ztrds(ji,jj,jk) = - ( zsu(ji,jj,jk) - zsu(ji-1,jj,jk) ) * zbtr
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)    ! save the trends
+         !
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  ztrdt(ji,jj,jk) = - ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) ) * zbtr
+                  ztrds(ji,jj,jk) = - ( zsv(ji,jj,jk) - zsv(ji,jj-1,jk) ) * zbtr
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)     ! save the trends
+         !
+         ! T/S VERTICAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.         
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  ztrdt(ji,jj,jk) = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr
+                  ztrds(ji,jj,jk) = - ( zsw(ji,jj,jk) - zsw(ji,jj,jk+1) ) * zbtr
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)     ! save the trends
+         !
+      ENDIF
+
+      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
+      CALL lbc_lnk( zti, 'T', 1. )
+      CALL lbc_lnk( zsi, 'T', 1. )
+
+
+      ! 3. antidiffusive flux : high order minus low order
+      ! --------------------------------------------------
+      ! antidiffusive flux on i and j
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zeu = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zev = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+               ztu(ji,jj,jk) = zeu * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) ) - ztu(ji,jj,jk)
+               zsu(ji,jj,jk) = zeu * ( sn(ji,jj,jk) + sn(ji+1,jj,jk) ) - zsu(ji,jj,jk)
+               ztv(ji,jj,jk) = zev * ( tn(ji,jj,jk) + tn(ji,jj+1,jk) ) - ztv(ji,jj,jk)
+               zsv(ji,jj,jk) = zev * ( sn(ji,jj,jk) + sn(ji,jj+1,jk) ) - zsv(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      
+      ! antidiffusive flux on k
+      ! Surface value
+      ztw(:,:,1) = 0.e0
+      zsw(:,:,1) = 0.e0
+
+      ! Interior value
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,jk)
+               ztw(ji,jj,jk) = zew * ( tn(ji,jj,jk) + tn(ji,jj,jk-1) ) - ztw(ji,jj,jk)
+               zsw(ji,jj,jk) = zew * ( sn(ji,jj,jk) + sn(ji,jj,jk-1) ) - zsw(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Lateral bondary conditions
+      CALL lbc_lnk( ztu, 'U', -1. )   ;   CALL lbc_lnk( zsu, 'U', -1. )
+      CALL lbc_lnk( ztv, 'V', -1. )   ;   CALL lbc_lnk( zsv, 'V', -1. )
+      CALL lbc_lnk( ztw, 'W',  1. )   ;   CALL lbc_lnk( zsw, 'W',  1. )
+
+      ! 4. monotonicity algorithm
+      ! -------------------------
+      CALL nonosc( tb, ztu, ztv, ztw, zti, z2 )
+      CALL nonosc( sb, zsu, zsv, zsw, zsi, z2 )
+
+
+      ! 5. final trend with corrected fluxes
+      ! ------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.  
+               zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+               ! total advective trends
+               ztat = - ( ztu(ji,jj,jk) - ztu(ji-1,jj  ,jk  )   &
+                  &     + ztv(ji,jj,jk) - ztv(ji  ,jj-1,jk  )   &
+                  &     + ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) * zbtr
+               zsat = - ( zsu(ji,jj,jk) - zsu(ji-1,jj  ,jk  )   &
+                  &     + zsv(ji,jj,jk) - zsv(ji  ,jj-1,jk  )   &
+                  &     + zsw(ji,jj,jk) - zsw(ji  ,jj  ,jk+1) ) * zbtr
+               ! add them to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ztat
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsat
+            END DO
+         END DO
+      END DO
+
+
+      ! Save the advective trends for diagnostics
+      ! --------------------------------------------
+
+      IF( l_trdtra ) THEN
+         ztrdt(:,:,:) = 0.e0   ;   ztrds(:,:,:) = 0.e0
+         !
+         ! T/S ZONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+                  !-- Compute T/S zonal advection trends
+                  ztrdt(ji,jj,jk) = - ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) ) * zbtr + tn(ji,jj,jk) * z_hdivn_x
+                  ztrds(ji,jj,jk) = - ( zsu(ji,jj,jk) - zsu(ji-1,jj,jk) ) * zbtr + sn(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt, cnbpas='bis')   ! <<< ADD TO PREVIOUSLY COMPUTED
+         !
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+                  !   N.B. This computation is not valid along OBCs (if any)
+                  zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+                  !-- Compute T/S meridional advection trends
+                  ztrdt(ji,jj,jk) = - ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) ) * zbtr + tn(ji,jj,jk) * z_hdivn_y          
+                  ztrds(ji,jj,jk) = - ( zsv(ji,jj,jk) - zsv(ji,jj-1,jk) ) * zbtr + sn(ji,jj,jk) * z_hdivn_y          
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt, cnbpas='bis')   ! <<< ADD TO PREVIOUSLY COMPUTED
+         !
+         ! T/S VERTICAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr1     = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+#if defined key_zco
+                  zbtr      = zbtr1
+                  z_hdivn_x = e2u(ji,jj)*pun(ji,jj,jk) - e2u(ji-1,jj)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*pvn(ji,jj,jk) - e1v(ji,jj-1)*pvn(ji,jj-1,jk)
+#else
+                  zbtr      = zbtr1 / fse3t(ji,jj,jk)
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+#endif
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  zbtr      = zbtr1 / fse3t(ji,jj,jk)
+                  ztrdt(ji,jj,jk) = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr - tn(ji,jj,jk) * z_hdivn
+                  ztrds(ji,jj,jk) = - ( zsw(ji,jj,jk) - zsw(ji,jj,jk+1) ) * zbtr - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt, cnbpas='bis')   ! <<< ADD TO PREVIOUSLY COMPUTED
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' tvd adv  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      ! "zonal" mean advective heat and salt transport
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         pht_adv(:) = ptr_vj( ztv(:,:,:) )
+         pst_adv(:) = ptr_vj( zsv(:,:,:) )
+      ENDIF
+      !
+   END SUBROUTINE tra_adv_tvd
+
+
+   SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, prdt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE nonosc  ***
+      !!     
+      !! **  Purpose :   compute monotonic tracer fluxes from the upstream 
+      !!       scheme and the before field by a nonoscillatory algorithm 
+      !!
+      !! **  Method  :   ... ???
+      !!       warning : pbef and paft must be masked, but the boundaries
+      !!       conditions on the fluxes are not necessary zalezak (1979)
+      !!       drange (1995) multi-dimensional forward-in-time and upstream-
+      !!       in-space based differencing for fluid
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT( in ) ::   prdt   ! ???
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT( inout ) ::   &
+         pbef,                            & ! before field
+         paft,                            & ! after field
+         paa,                             & ! monotonic flux in the i direction
+         pbb,                             & ! monotonic flux in the j direction
+         pcc                                ! monotonic flux in the k direction
+      !!
+      INTEGER ::   ji, jj, jk               ! dummy loop indices
+      INTEGER ::   ikm1
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zbetup, zbetdo
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zbup, zbdo
+      REAL(wp) ::   zpos, zneg, zbt, za, zb, zc, zbig, zrtrn, z2dtt
+      REAL(wp) ::   zau, zbu, zcu, zav, zbv, zcv
+      REAL(wp) ::   zup, zdo
+      !!----------------------------------------------------------------------
+
+      zbig = 1.e+40
+      zrtrn = 1.e-15
+      zbetup(:,:,jpk) = 0.e0   ;   zbetdo(:,:,jpk) = 0.e0
+
+
+      ! Search local extrema
+      ! --------------------
+      ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land
+      zbup = MAX( pbef * tmask - zbig * ( 1.e0 - tmask ),   &
+         &        paft * tmask - zbig * ( 1.e0 - tmask )  )
+      zbdo = MIN( pbef * tmask + zbig * ( 1.e0 - tmask ),   &
+         &        paft * tmask + zbig * ( 1.e0 - tmask )  )
+
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         z2dtt = prdt * rdttra(jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+
+               ! search maximum in neighbourhood
+               zup = MAX(  zbup(ji  ,jj  ,jk  ),   &
+                  &        zbup(ji-1,jj  ,jk  ), zbup(ji+1,jj  ,jk  ),   &
+                  &        zbup(ji  ,jj-1,jk  ), zbup(ji  ,jj+1,jk  ),   &
+                  &        zbup(ji  ,jj  ,ikm1), zbup(ji  ,jj  ,jk+1)  )
+
+               ! search minimum in neighbourhood
+               zdo = MIN(  zbdo(ji  ,jj  ,jk  ),   &
+                  &        zbdo(ji-1,jj  ,jk  ), zbdo(ji+1,jj  ,jk  ),   &
+                  &        zbdo(ji  ,jj-1,jk  ), zbdo(ji  ,jj+1,jk  ),   &
+                  &        zbdo(ji  ,jj  ,ikm1), zbdo(ji  ,jj  ,jk+1)  )
+
+               ! positive part of the flux
+               zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+
+               ! negative part of the flux
+               zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+
+               ! up & down beta terms
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
+               zbetup(ji,jj,jk) = ( zup            - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt
+               zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo            ) / ( zneg + zrtrn ) * zbt
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on zbetup & zbetdo   (unchanged sign)
+      CALL lbc_lnk( zbetup, 'T', 1. )
+      CALL lbc_lnk( zbetdo, 'T', 1. )
+
+
+      ! 3. monotonic flux in the i & j direction (paa & pbb)
+      ! ----------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zau = MIN( 1.e0, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
+               zbu = MIN( 1.e0, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
+               zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
+               paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1.e0 - zcu) * zbu )
+
+               zav = MIN( 1.e0, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
+               zbv = MIN( 1.e0, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
+               zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
+               pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1.e0 - zcv) * zbv )
+
+      ! monotonic flux in the k direction, i.e. pcc
+      ! -------------------------------------------
+               za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) )
+               zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
+               zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
+               pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1.e0 - zc) * zb )
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on paa, pbb, pcc
+      CALL lbc_lnk( paa, 'U', -1. )      ! changed sign
+      CALL lbc_lnk( pbb, 'V', -1. )      ! changed sign
+      !
+   END SUBROUTINE nonosc
+
+   !!======================================================================
+END MODULE traadv_tvd
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_ubs.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 1844)
@@ -0,0 +1,564 @@
+MODULE traadv_ubs
+   !!==============================================================================
+   !!                       ***  MODULE  traadv_ubs  ***
+   !! Ocean active tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+   !! History :  9.0  !  06-08  (L. Debreu, R. Benshila)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_ubs : update the tracer trend with the horizontal
+   !!                 advection trends using a third order biaised scheme  
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod
+   USE trdmod_oce
+   USE lib_mpp
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE diaptr          ! poleward transport diagnostics
+   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
+   USE prtctl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_ubs   ! routine called by traadv module
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   e1e2tr   ! = 1/(e1t * e2t)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006)  
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_adv_ubs( kt, pun, pvn, pwn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_ubs  ***
+      !!                 
+      !! ** Purpose :   Compute the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations.
+      !!
+      !! ** Method  :   The upstream biased third (UBS) is order scheme based 
+      !!      on an upstream-biased parabolic interpolation (Shchepetkin and McWilliams 2005)
+      !!      It is only used in the horizontal direction.
+      !!      For example the i-component of the advective fluxes are given by :
+      !!                !  e1u e3u un ( mi(Tn) - zltu(i  ) )   if un(i) >= 0
+      !!          zwx = !  or 
+      !!                !  e1u e3u un ( mi(Tn) - zltu(i+1) )   if un(i) < 0
+      !!      where zltu is the second derivative of the before temperature field:
+      !!          zltu = 1/e3t di[ e2u e3u / e1u di[Tb] ]
+      !!      This results in a dissipatively dominant (i.e. hyper-diffusive) 
+      !!      truncation error. The overall performance of the advection scheme 
+      !!      is similar to that reported in (Farrow and Stevens, 1995). 
+      !!      For stability reasons, the first term of the fluxes which corresponds
+      !!      to a second order centered scheme is evaluated using the now velocity 
+      !!      (centered in time) while the second term which is the diffusive part 
+      !!      of the scheme, is evaluated using the before velocity (forward in time). 
+      !!      Note that UBS is not positive. Do not use it on passive tracers.
+      !!      On the vertical, the advection is evaluated using a TVD scheme, as
+      !!      the UBS have been found to be too diffusive.
+      !!
+      !! ** Action : - update (ta,sa) with the now advective tracer trends
+      !!
+      !! Reference : Shchepetkin, A. F., J. C. McWilliams, 2005, Ocean Modelling, 9, 347-404. 
+      !!             Farrow, D.E., Stevens, D.P., 1995, J. Phys. Ocean. 25, 1731Ð1741. 
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   zwx => ua   ! use ua as workspace
+      USE oce, ONLY :   zwy => va   ! use va as workspace
+      !!
+      INTEGER , INTENT(in)                         ::   kt             ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pun   ! effective ocean velocity, u_component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pvn   ! effective ocean velocity, v_component
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::  pwn   ! effective ocean velocity, w_component
+      !!
+      INTEGER  ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp) ::   zta, zsa, zbtr, zcoef                  ! temporary scalars
+      REAL(wp) ::   zfui, zfp_ui, zfm_ui, zcenut, zcenus   !    "         "
+      REAL(wp) ::   zfvj, zfp_vj, zfm_vj, zcenvt, zcenvs   !    "         "
+      REAL(wp) ::   z_hdivn_x, z_hdivn_y, z_hdivn          !    "         "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zeeu, zeev     ! temporary 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz , zww                        ! temporary 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztu , ztv , zltu , zltv, ztrdt   !    "              "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zsu , zsv , zlsu , zlsv, ztrds   !    "              "
+      !!----------------------------------------------------------------------
+
+      zltu(:,:,:) = 0.e0
+      zltv(:,:,:) = 0.e0
+      zlsu(:,:,:) = 0.e0
+      zlsv(:,:,:) = 0.e0
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_ubs :  horizontal UBS advection scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+         !
+         e1e2tr(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+      ENDIF
+
+      ! Save ta and sa trends
+      ztrdt(:,:,:) = ta(:,:,:)
+      ztrds(:,:,:) = sa(:,:,:)
+
+      zcoef = 1./6.
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         !  Initialization of metric arrays (for z- or s-coordinates)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+#if defined key_zco
+               ! z-coordinates, no vertical scale factors
+               zeeu(ji,jj) = e2u(ji,jj) / e1u(ji,jj) * umask(ji,jj,jk)
+               zeev(ji,jj) = e1v(ji,jj) / e2v(ji,jj) * vmask(ji,jj,jk)
+#else
+               ! s-coordinates, vertical scale factor are used
+               zeeu(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj) * umask(ji,jj,jk)
+               zeev(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj) * vmask(ji,jj,jk)
+#endif
+            END DO
+         END DO
+
+         !  Laplacian
+         ! First derivative (gradient)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ztu(ji,jj,jk) = zeeu(ji,jj) * ( tb(ji+1,jj  ,jk) - tb(ji,jj,jk) )
+               zsu(ji,jj,jk) = zeeu(ji,jj) * ( sb(ji+1,jj  ,jk) - sb(ji,jj,jk) )
+               ztv(ji,jj,jk) = zeev(ji,jj) * ( tb(ji  ,jj+1,jk) - tb(ji,jj,jk) )
+               zsv(ji,jj,jk) = zeev(ji,jj) * ( sb(ji  ,jj+1,jk) - sb(ji,jj,jk) )
+            END DO
+         END DO
+         ! Second derivative (divergence)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+               zcoef = 1. / ( 6. * fse3t(ji,jj,jk) )
+#endif         
+               zltu(ji,jj,jk) = (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)  ) * zcoef
+               zlsu(ji,jj,jk) = (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk)  ) * zcoef
+               zltv(ji,jj,jk) = (  ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  ) * zcoef
+               zlsv(ji,jj,jk) = (  zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  ) * zcoef
+            END DO
+         END DO
+         !                                             ! =================
+      END DO                                           !    End of slab
+      !                                                ! =================
+
+      ! Lateral boundary conditions on the laplacian (zlt,zls)   (unchanged sgn)
+      CALL lbc_lnk( zltu, 'T', 1. )   ;    CALL lbc_lnk( zlsu, 'T', 1. )
+      CALL lbc_lnk( zltv, 'T', 1. )   ;    CALL lbc_lnk( zlsv, 'T', 1. )
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         !  Horizontal advective fluxes
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ! volume fluxes * 1/2
+#if defined key_zco
+               zfui = 0.5 * e2u(ji,jj) * pun(ji,jj,jk)
+               zfvj = 0.5 * e1v(ji,jj) * pvn(ji,jj,jk)
+#else
+               zfui = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * pun(ji,jj,jk)
+               zfvj = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * pvn(ji,jj,jk)
+#endif
+               ! upstream scheme
+               zfp_ui = zfui + ABS( zfui )
+               zfp_vj = zfvj + ABS( zfvj )
+               zfm_ui = zfui - ABS( zfui )
+               zfm_vj = zfvj - ABS( zfvj )
+               ! centered scheme
+               zcenut = zfui * ( tn(ji,jj,jk) + tn(ji+1,jj  ,jk) )
+               zcenvt = zfvj * ( tn(ji,jj,jk) + tn(ji  ,jj+1,jk) )
+               zcenus = zfui * ( sn(ji,jj,jk) + sn(ji+1,jj  ,jk) )
+               zcenvs = zfvj * ( sn(ji,jj,jk) + sn(ji  ,jj+1,jk) )
+               ! mixed centered / upstream scheme
+               zwx(ji,jj,jk) = zcenut - zfp_ui * zltu(ji,jj,jk) -zfm_ui * zltu(ji+1,jj,jk)
+               zwy(ji,jj,jk) = zcenvt - zfp_vj * zltv(ji,jj,jk) -zfm_vj * zltv(ji,jj+1,jk)
+               zww(ji,jj,jk) = zcenus - zfp_ui * zlsu(ji,jj,jk) -zfm_ui * zlsu(ji+1,jj,jk)
+               zwz(ji,jj,jk) = zcenvs - zfp_vj * zlsv(ji,jj,jk) -zfm_vj * zlsv(ji,jj+1,jk)
+            END DO
+         END DO
+
+         !  Tracer flux divergence at t-point added to the general trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! horizontal advective trends
+#if defined key_zco
+               zbtr = e1e2tr(ji,jj)
+#else
+               zbtr = e1e2tr(ji,jj) / fse3t(ji,jj,jk)
+#endif
+               zta = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk)   &
+                  &            + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk)  )
+               zsa = - zbtr * (  zww(ji,jj,jk) - zww(ji-1,jj  ,jk)   &
+                  &            + zwz(ji,jj,jk) - zwz(ji  ,jj-1,jk)  )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+      ! Horizontal trend used in tra_adv_ztvd subroutine
+      zltu(:,:,:) = ta(:,:,:) - ztrdt(:,:,:) 
+      zlsu(:,:,:) = sa(:,:,:) - ztrds(:,:,:) 
+
+      ! 3. Save the horizontal advective trends for diagnostic
+      ! ------------------------------------------------------
+      IF( l_trdtra )   THEN
+         ! Recompute the hoizontal advection zta & zsa trends computed 
+         ! at the step 2. above in making the difference between the new 
+         ! trends and the previous one ta()/sa - ztrdt()/ztrds() and add
+         ! the term tn()/sn()*hdivn() to recover the Uh gradh(T/S) trends
+         ztrdt(:,:,:) = 0.e0   ;   ztrds(:,:,:) = 0.e0
+         !
+         ! T/S ZONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+#if defined key_zco
+                  zbtr = e1e2tr(ji,jj)
+                  z_hdivn_x = (  e2u(ji  ,jj) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * pun(ji-1,jj,jk) ) * zbtr
+#else
+                  zbtr = e1e2tr(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * pun(ji  ,jj,jk)          &
+                     &         - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * pun(ji-1,jj,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - ( zwx(ji,jj,jk) - zwx(ji-1,jj,jk) ) * zbtr + tn(ji,jj,jk) * z_hdivn_x
+                  ztrds(ji,jj,jk) = - ( zww(ji,jj,jk) - zww(ji-1,jj,jk) ) * zbtr + sn(ji,jj,jk) * z_hdivn_x
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_xad, 'TRA', kt)    ! save the trends
+         !
+         ! T/S MERIDIONAL advection trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+#if defined key_zco
+                  zbtr      = e1e2tr(ji,jj)
+                  z_hdivn_y = (  e1v(ji,  jj) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * pvn(ji,jj-1,jk) ) * zbtr
+#else
+                  zbtr      = e1e2tr(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * pvn(ji,jj  ,jk)          &
+                     &         - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * pvn(ji,jj-1,jk) ) * zbtr
+#endif
+                  ztrdt(ji,jj,jk) = - ( zwy(ji,jj,jk) - zwy(ji,jj-1,jk) ) * zbtr + tn(ji,jj,jk) * z_hdivn_y          
+                  ztrds(ji,jj,jk) = - ( zwz(ji,jj,jk) - zwz(ji,jj-1,jk) ) * zbtr + sn(ji,jj,jk) * z_hdivn_y
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_yad, 'TRA', kt)     ! save the trends
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' ubs had  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      ! "zonal" mean advective heat and salt transport 
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zwy(ji,jj,jk) = zwy(ji,jj,jk) * fse3v(ji,jj,jk)
+                     zwz(ji,jj,jk) = zwz(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         pht_adv(:) = ptr_vj( zwy(:,:,:) )
+         pst_adv(:) = ptr_vj( zwz(:,:,:) )
+      ENDIF
+
+      ! II. Vertical advection
+      ! ----------------------
+      IF( l_trdtra ) THEN          ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:)
+      ENDIF
+    
+      ! TVD scheme the vertical direction  
+      CALL tra_adv_ztvd(kt, pwn, zltu, zlsu)
+
+      IF( l_trdtra )   THEN         !  Save the final vertical advective trends
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+                  zbtr      = e1e2tr(ji,jj)
+                  z_hdivn_x = e2u(ji,jj)*pun(ji,jj,jk) - e2u(ji-1,jj)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*pvn(ji,jj,jk) - e1v(ji,jj-1)*pvn(ji,jj-1,jk)
+#else
+                  zbtr      = e1e2tr(ji,jj) / fse3t(ji,jj,jk)
+                  z_hdivn_x = e2u(ji,jj)*fse3u(ji,jj,jk)*pun(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk)*pun(ji-1,jj,jk)
+                  z_hdivn_y = e1v(ji,jj)*fse3v(ji,jj,jk)*pvn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk)*pvn(ji,jj-1,jk)
+#endif
+                  z_hdivn   = (z_hdivn_x + z_hdivn_y) * zbtr
+                  zbtr      = e1e2tr(ji,jj) / fse3t(ji,jj,jk)
+                  ztrdt(ji,jj,jk) = ta(ji,jj,jk) - ztrdt(ji,jj,jk) - tn(ji,jj,jk) * z_hdivn
+                  ztrds(ji,jj,jk) = sa(ji,jj,jk) - ztrds(ji,jj,jk) - sn(ji,jj,jk) * z_hdivn
+               END DO
+            END DO
+         END DO
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zad, 'TRA', kt)   ! <<< ADD TO PREVIOUSLY COMPUTED
+         !
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' ubs zad  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra')
+      !
+   END SUBROUTINE tra_adv_ubs
+
+
+   SUBROUTINE tra_adv_ztvd( kt, pwn, zttrd, zstrd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_ztvd  ***
+      !! 
+      !! **  Purpose :   Compute the now trend due to total advection of 
+      !!       tracers and add it to the general trend of tracer equations
+      !!
+      !! **  Method  :   TVD scheme, i.e. 2nd order centered scheme with
+      !!       corrected flux (monotonic correction)
+      !!       note: - this advection scheme needs a leap-frog time scheme
+      !!
+      !! ** Action : - update (ta,sa) with the now advective tracer trends
+      !!             - save the trends in (ztrdt,ztrds) ('key_trdtra')
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in)                         ::   kt             ! ocean time-step
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pwn            ! verical effective velocity
+      REAL(wp), INTENT(in), DIMENSION(jpi,jpj,jpk) ::   zttrd, zstrd   ! lateral advective trends on T & S 
+      !!
+      INTEGER  ::   ji, jj, jk              ! dummy loop indices
+      REAL(wp) ::   z2dtt, zbtr, zew, z2    ! temporary scalar  
+      REAL(wp) ::   ztak, zfp_wk            !    "         "
+      REAL(wp) ::   zsak, zfm_wk            !    "         "
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zti, ztw   ! temporary 3D workspace
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zsi, zsw   !    "              "
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv_ztvd : vertical TVD advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+      ENDIF
+
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;    z2 = 1.
+      ELSE                                        ;    z2 = 2.
+      ENDIF
+
+      !  Bottom value : flux set to zero
+      ! --------------
+      ztw(:,:,jpk) = 0.e0   ;   zsw(:,:,jpk) = 0.e0
+      zti  (:,:,:) = 0.e0   ;   zsi  (:,:,:) = 0.e0
+
+
+      !  upstream advection with initial mass fluxes & intermediate update
+      ! -------------------------------------------------------------------
+      ! Surface value
+      IF( lk_vvl ) THEN
+         ! variable volume : flux set to zero
+         ztw(:,:,1) = 0.e0
+         zsw(:,:,1) = 0.e0
+      ELSE
+         ! free surface-constant volume
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,1)
+               ztw(ji,jj,1) = zew * tb(ji,jj,1)
+               zsw(ji,jj,1) = zew * sb(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+
+      ! Interior value
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,jk)
+               zfp_wk = zew + ABS( zew )
+               zfm_wk = zew - ABS( zew )
+               ztw(ji,jj,jk) = zfp_wk * tb(ji,jj,jk) + zfm_wk * tb(ji,jj,jk-1)
+               zsw(ji,jj,jk) = zfp_wk * sb(ji,jj,jk) + zfm_wk * sb(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! update and guess with monotonic sheme
+      DO jk = 1, jpkm1
+         z2dtt = z2 * rdttra(jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr = 1./ ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+               ztak = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr
+               zsak = - ( zsw(ji,jj,jk) - zsw(ji,jj,jk+1) ) * zbtr
+               ta(ji,jj,jk) =  ta(ji,jj,jk) + ztak
+               sa(ji,jj,jk) =  sa(ji,jj,jk) + zsak 
+               zti (ji,jj,jk) = ( tb(ji,jj,jk) + z2dtt * ( ztak + zttrd(ji,jj,jk) ) ) * tmask(ji,jj,jk)
+               zsi (ji,jj,jk) = ( sb(ji,jj,jk) + z2dtt * ( zsak + zstrd(ji,jj,jk) ) ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
+      CALL lbc_lnk( zti, 'T', 1. )
+      CALL lbc_lnk( zsi, 'T', 1. )
+
+
+      !  antidiffusive flux : high order minus low order
+      ! -------------------------------------------------      
+      ! Surface value
+      ztw(:,:,1) = 0.e0   ;   zsw(:,:,1) = 0.e0
+
+      ! Interior value
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * pwn(ji,jj,jk)
+               ztw(ji,jj,jk) = zew * ( tn(ji,jj,jk) + tn(ji,jj,jk-1) ) - ztw(ji,jj,jk)
+               zsw(ji,jj,jk) = zew * ( sn(ji,jj,jk) + sn(ji,jj,jk-1) ) - zsw(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      !  monotonicity algorithm
+      ! ------------------------
+      CALL nonosc_z( tb, ztw, zti, z2 )
+      CALL nonosc_z( sb, zsw, zsi, z2 )
+
+
+      !  final trend with corrected fluxes
+      ! -----------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.  
+               zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+               ! k- vertical advective trends
+               ztak = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr
+               zsak = - ( zsw(ji,jj,jk) - zsw(ji,jj,jk+1) ) * zbtr
+               ! add them to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ztak
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsak
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tra_adv_ztvd
+
+
+   SUBROUTINE nonosc_z( pbef, pcc, paft, prdt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE nonosc_z  ***
+      !!     
+      !! **  Purpose :   compute monotonic tracer fluxes from the upstream 
+      !!       scheme and the before field by a nonoscillatory algorithm 
+      !!
+      !! **  Method  :   ... ???
+      !!       warning : pbef and paft must be masked, but the boundaries
+      !!       conditions on the fluxes are not necessary zalezak (1979)
+      !!       drange (1995) multi-dimensional forward-in-time and upstream-
+      !!       in-space based differencing for fluid
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   )                          ::   prdt   ! ???
+      REAL(wp), INTENT(inout), DIMENSION (jpi,jpj,jpk) ::   pbef   ! before field
+      REAL(wp), INTENT(inout), DIMENSION (jpi,jpj,jpk) ::   paft   ! after field
+      REAL(wp), INTENT(inout), DIMENSION (jpi,jpj,jpk) ::   pcc    ! monotonic flux in the k direction
+      !!
+      INTEGER  ::   ji, jj, jk               ! dummy loop indices
+      INTEGER  ::   ikm1
+      REAL(wp) ::   zpos, zneg, zbt, za, zb, zc, zbig, zrtrn, z2dtt
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zbetup, zbetdo
+      !!----------------------------------------------------------------------
+
+      zbig = 1.e+40
+      zrtrn = 1.e-15
+      zbetup(:,:,:) = 0.e0   ;   zbetdo(:,:,:) = 0.e0
+
+      ! Search local extrema
+      ! --------------------
+      ! large negative value (-zbig) inside land
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
+      ! search maximum in neighbourhood
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbetup(ji,jj,jk) = MAX(  pbef(ji  ,jj  ,jk  ), paft(ji  ,jj  ,jk  ),   &
+                  &                     pbef(ji  ,jj  ,ikm1), pbef(ji  ,jj  ,jk+1),   &
+                  &                     paft(ji  ,jj  ,ikm1), paft(ji  ,jj  ,jk+1)  )
+            END DO
+         END DO
+      END DO
+      ! large positive value (+zbig) inside land
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
+      ! search minimum in neighbourhood
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbetdo(ji,jj,jk) = MIN(  pbef(ji  ,jj  ,jk  ), paft(ji  ,jj  ,jk  ),   &
+                  &                     pbef(ji  ,jj  ,ikm1), pbef(ji  ,jj  ,jk+1),   &
+                  &                     paft(ji  ,jj  ,ikm1), paft(ji  ,jj  ,jk+1)  )
+            END DO
+         END DO
+      END DO
+
+      ! restore masked values to zero
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:)
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:)
+ 
+
+      ! 2. Positive and negative part of fluxes and beta terms
+      ! ------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         z2dtt = prdt * rdttra(jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! positive & negative part of the flux
+               zpos = MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+               zneg = MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+               ! up & down beta terms
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
+               zbetup(ji,jj,jk) = ( zbetup(ji,jj,jk) - paft(ji,jj,jk) ) / (zpos+zrtrn) * zbt
+               zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zbetdo(ji,jj,jk) ) / (zneg+zrtrn) * zbt
+            END DO
+         END DO
+      END DO
+
+      ! monotonic flux in the k direction, i.e. pcc
+      ! -------------------------------------------
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+
+               za = MIN( 1., zbetdo(ji,jj,jk), zbetup(ji,jj,jk-1) )
+               zb = MIN( 1., zbetup(ji,jj,jk), zbetdo(ji,jj,jk-1) )
+               zc = 0.5 * ( 1.e0 + SIGN( 1.e0, pcc(ji,jj,jk) ) )
+               pcc(ji,jj,jk) = pcc(ji,jj,jk) * ( zc * za + ( 1.e0 - zc) * zb )
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE nonosc_z
+
+   !!======================================================================
+END MODULE traadv_ubs
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbc.F90	(revision 1844)
@@ -0,0 +1,198 @@
+MODULE trabbc
+   !!==============================================================================
+   !!                       ***  MODULE  trabbc  ***
+   !! Ocean active tracers:  bottom boundary condition
+   !!==============================================================================
+   !! History :  8.1  ! 99-10 (G. Madec)  original code
+   !!            8.5  ! 02-08 (G. Madec)  free form + modules
+   !!            8.5  ! 02-11 (A. Bozec)  tra_bbc_init: original code
+   !!----------------------------------------------------------------------
+#if   defined key_trabbc   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trabbc'                                  geothermal heat flux
+   !!----------------------------------------------------------------------
+   !!   tra_bbc      : update the tracer trend at ocean bottom 
+   !!   tra_bbc_init : initialization of geothermal heat flux trend
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE trdmod          ! ocean trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC tra_bbc          ! routine called by step.F90
+
+   !! to be transfert in the namelist ???!   
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbc = .TRUE.   !: bbc flag
+
+   !                                         !!* Namelist nambbc: bottom boundary condition *
+   INTEGER  ::   nn_geoflx     = 1            ! Geothermal flux (0:no flux, 1:constant flux, 2:read in file )
+   REAL(wp) ::   rn_geoflx_cst = 86.4e-3      ! Constant value of geothermal heat flux
+
+   INTEGER , DIMENSION(jpi,jpj) ::   nbotlevt   ! ocean bottom level index at T-pt
+   REAL(wp), DIMENSION(jpi,jpj) ::   qgh_trd0   ! geothermal heating trend
+ 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_bbc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_bbc  ***
+      !!
+      !! ** Purpose :   Compute the bottom boundary contition on temperature 
+      !!              associated with geothermal heating and add it to the 
+      !!              general trend of temperature equations.
+      !!
+      !! ** Method  :   The geothermal heat flux set to its constant value of 
+      !!              86.4 mW/m2 (Stein and Stein 1992, Huang 1999).
+      !!       The temperature trend associated to this heat flux through the
+      !!       ocean bottom can be computed once and is added to the temperature
+      !!       trend juste above the bottom at each time step:
+      !!            ta = ta + Qsf / (rau0 rcp e3T) for k= mbathy -1
+      !!       Where Qsf is the geothermal heat flux.
+      !!
+      !! ** Action  : - update the temperature trends (ta) with the trend of
+      !!                the ocean bottom boundary condition
+      !!
+      !! References : Stein, C. A., and S. Stein, 1992, Nature, 359, 123-129.
+      !!              Emile-Geay and Madec, 2009, Ocean Science.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj    ! dummy loop indices
+      REAL(wp) ::   zqgh_trd  ! geothermal heat flux trend
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_bbc_init      ! Initialization
+
+      IF( l_trdtra )   THEN         ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = 0.e0
+      ENDIF
+
+      ! Add the geothermal heat flux trend on temperature
+
+      SELECT CASE ( nn_geoflx )
+      !
+      CASE ( 1:2 )                !  geothermal heat flux
+#if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+#else
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+#endif
+               zqgh_trd = ro0cpr * qgh_trd0(ji,jj) / fse3t(ji,jj,nbotlevt(ji,jj))
+               ta(ji,jj,nbotlevt(ji,jj)) = ta(ji,jj,nbotlevt(ji,jj)) + zqgh_trd
+            END DO
+         END DO
+      END SELECT
+
+      IF( l_trdtra ) THEN        ! Save the geothermal heat flux trend for diagnostics
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_bbc, 'TRA', kt )
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' bbc  - Ta: ', mask1=tmask, clinfo3='tra-ta' )
+      !
+   END SUBROUTINE tra_bbc
+
+
+   SUBROUTINE tra_bbc_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_bbc_init  ***
+      !!
+      !! ** Purpose :   Compute once for all the trend associated with geothermal
+      !!              heating that will be applied at each time step at the
+      !!              last ocean level
+      !!
+      !! ** Method  :   Read the nambbc namelist and check the parameters.
+      !!
+      !! ** Input   : - Namlist nambbc
+      !!              - NetCDF file  : geothermal_heating.nc ( if necessary )
+      !!
+      !! ** Action  : - read/fix the geothermal heat qgh_trd0
+      !!              - compute the bottom ocean level nbotlevt
+      !!----------------------------------------------------------------------
+      USE iom
+      !!
+      INTEGER  ::   ji, jj              ! dummy loop indices
+      INTEGER  ::   inum                ! temporary logical unit
+      !!
+      NAMELIST/nambbc/nn_geoflx, rn_geoflx_cst 
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )              ! Read Namelist nambbc : bottom momentum boundary condition
+      READ   ( numnam, nambbc )
+
+      IF(lwp) THEN                   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_bbc : temperature Bottom Boundary Condition (bbc), Geothermal heatflux'
+         WRITE(numout,*) '~~~~~~~   '
+         WRITE(numout,*) '   Namelist nambbc : set bbc parameters'
+         WRITE(numout,*) '      Geothermal flux            nn_geoflx     = ', nn_geoflx
+         WRITE(numout,*) '      Constant geothermal flux   rn_geoflx_cst = ', rn_geoflx_cst
+         WRITE(numout,*)
+      ENDIF
+
+      !                              ! level of the ocean bottom at T-point
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            nbotlevt(ji,jj) = MAX( mbathy(ji,jj)-1, 1 )
+         END DO
+      END DO
+
+      SELECT CASE ( nn_geoflx )      ! initialization of geothermal heat flux
+      !
+      CASE ( 0 )                ! no geothermal heat flux
+         IF(lwp) WRITE(numout,*) '      *** no geothermal heat flux'
+         !
+      CASE ( 1 )                ! constant flux
+         IF(lwp) WRITE(numout,*) '      *** constant heat flux  =   ', rn_geoflx_cst
+         !
+         qgh_trd0(:,:) = rn_geoflx_cst
+         !
+      CASE ( 2 )                ! variable geothermal heat flux : read the geothermal fluxes in mW/m2
+         IF(lwp) WRITE(numout,*) '      *** variable geothermal heat flux'
+         CALL iom_open ( 'geothermal_heating.nc', inum )
+         CALL iom_get  ( inum, jpdom_data, 'heatflow', qgh_trd0 )
+         CALL iom_close( inum )
+         !
+         qgh_trd0(:,:) = qgh_trd0(:,:) * 1.e-3 ! conversion in W/m2
+         !
+      CASE DEFAULT
+         WRITE(ctmp1,*) '     bad flag value for nn_geoflx = ', nn_geoflx
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+   END SUBROUTINE tra_bbc_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbc = .FALSE.  !: bbc flag
+CONTAINS
+   SUBROUTINE tra_bbc( kt )           ! Empty routine
+      WRITE(*,*) 'tra_bbc: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_bbc
+#endif
+
+   !!======================================================================
+END MODULE trabbc
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 1844)
@@ -0,0 +1,463 @@
+MODULE trabbl
+   !!==============================================================================
+   !!                       ***  MODULE  trabbl  ***
+   !! Ocean physics :  advective and/or diffusive bottom boundary layer scheme
+   !!==============================================================================
+   !! History :  8.0  !  96-06  (L. Mortier)  Original code
+   !!            8.0  !  97-11  (G. Madec)  Optimization
+   !!            8.5  !  02-08  (G. Madec)  free form + modules
+   !!----------------------------------------------------------------------
+#if   defined key_trabbl_dif   ||   defined key_trabbl_adv   || defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trabbl_dif'   or            diffusive bottom boundary layer
+   !!   'key_trabbl_adv'                 advective bottom boundary layer
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   tra_bbl_dif  : update the active tracer trends due to the bottom
+   !!                  boundary layer (diffusive only)
+   !!   tra_bbl_adv  : update the active tracer trends due to the bottom
+   !!                  boundary layer (advective and/or diffusive)
+   !!   tra_bbl_init : initialization, namlist read, parameters control
+   !!----------------------------------------------------------------------
+   USE oce                ! ocean dynamics and active tracers
+   USE dom_oce            ! ocean space and time domain
+   USE trdmod             ! ocean active tracers trends
+   USE trdmod_oce         ! ocean variables trends
+   USE in_out_manager     ! I/O manager
+   USE lbclnk             ! ocean lateral boundary conditions
+   USE prtctl             ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC tra_bbl_dif    ! routine called by step.F90
+   PUBLIC tra_bbl_adv    ! routine called by step.F90
+
+   !!* Namelist nambbl: bottom boundary layer
+   REAL(wp), PUBLIC ::   rn_ahtbbl = 1.e+3   !: lateral coeff. for bottom boundary layer scheme (m2/s)
+
+# if defined key_trabbl_dif
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_dif = .TRUE.          !: diffusive bottom boundary layer flag
+# else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_dif = .FALSE.         !: diffusive bottom boundary layer flag
+# endif
+
+# if defined key_trabbl_adv
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_adv = .TRUE.   !: advective bottom boundary layer flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   u_bbl      !: 3 components of the velocity
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   v_bbl      !: associated with advective BBL
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   w_bbl      !: (only affect tracer)
+# else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_adv = .FALSE.  !: advective bottom boundary layer flag
+# endif
+
+   INTEGER, DIMENSION(jpi,jpj) ::   mbkt          ! vertical index of the bottom ocean T-level
+   INTEGER, DIMENSION(jpi,jpj) ::   mbku, mbkv    ! vertical index of the bottom ocean U/V-level
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_bbl_dif( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_bbl_dif  ***
+      !!
+      !! ** Purpose :   Compute the before tracer (t & s) trend associated 
+      !!      with the bottom boundary layer and add it to the general trend 
+      !!      of tracer equations. The bottom boundary layer is supposed to be
+      !!      a purely diffusive bottom boundary layer.
+      !!
+      !! ** Method  :   When the product grad( rho) * grad(h) < 0 (where grad 
+      !!      is an along bottom slope gradient) an additional lateral diffu-
+      !!      sive trend along the bottom slope is added to the general tracer
+      !!      trend, otherwise nothing is done.
+      !!      Second order operator (laplacian type) with variable coefficient
+      !!      computed as follow for temperature (idem on s): 
+      !!         difft = 1/(e1t*e2t*e3t) { di-1[ ahbt e2u*e3u/e1u di[ztb] ]
+      !!                                 + dj-1[ ahbt e1v*e3v/e2v dj[ztb] ] }
+      !!      where ztb is a 2D array: the bottom ocean temperature and ahtb
+      !!      is a time and space varying diffusive coefficient defined by:
+      !!         ahbt = zahbp    if grad(rho).grad(h) < 0
+      !!              = 0.       otherwise.
+      !!      Note that grad(.) is the along bottom slope gradient. grad(rho)
+      !!      is evaluated using the local density (i.e. referenced at the
+      !!      local depth). Typical value of ahbt is 2000 m2/s (equivalent to
+      !!      a downslope velocity of 20 cm/s if the condition for slope
+      !!      convection is satified)
+      !!      Add this before trend to the general trend (ta,sa) of the 
+      !!      botton ocean tracer point:
+      !!         ta = ta + difft
+      !!
+      !! ** Action  : - update (ta,sa) at the bottom level with the bottom
+      !!                boundary layer trend
+      !!              - save the trends in ztrdt/ztrds ('key_trdtra')
+      !!
+      !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
+      USE eosbn2                      ! equation of state
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step
+      !!
+      INTEGER  ::   ji, jj                  ! dummy loop indices
+      INTEGER  ::   ik
+      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers
+      INTEGER  ::   iku1, iku2, ikv1,ikv2   ! temporary intergers
+      REAL(wp) ::   ze3u, ze3v              ! temporary scalars
+      INTEGER  ::   iku, ikv
+      REAL(wp) ::   zsign, zt, zs, zh, zalbet   ! temporary scalars
+      REAL(wp) ::   zgdrho, zbtr, zta, zsa
+      REAL(wp), DIMENSION(jpi,jpj) ::   zki, zkj, zkw, zkx, zky, zkz             ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztnb, zsnb, zdep, ztbb, zsbb, zahu, zahv
+      !!
+      REAL(wp) ::    fsalbt, pft, pfs, pfh   ! statement function
+      !!----------------------------------------------------------------------
+      ! ratio alpha/beta
+      ! ================
+      !  fsalbt: ratio of thermal over saline expension coefficients
+      !       pft :  potential temperature in degrees celcius
+      !       pfs :  salinity anomaly (s-35) in psu
+      !       pfh :  depth in meters
+
+      fsalbt( pft, pfs, pfh ) =                                              &
+         ( ( ( -0.255019e-07 * pft + 0.298357e-05 ) * pft                    &
+         &                         - 0.203814e-03 ) * pft                    &
+         &                         + 0.170907e-01 ) * pft                    &
+         &                         + 0.665157e-01                            &
+         +(-0.678662e-05 * pfs - 0.846960e-04 * pft + 0.378110e-02 ) * pfs   &
+         +  ( ( - 0.302285e-13 * pfh                                         &
+         &      - 0.251520e-11 * pfs                                         &
+         &      + 0.512857e-12 * pft * pft          ) * pfh                  &
+         &                           - 0.164759e-06   * pfs                  &
+         &   +(   0.791325e-08 * pft - 0.933746e-06 ) * pft                  &
+         &                           + 0.380374e-04 ) * pfh   
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_bbl_init
+
+      IF( l_trdtra )   THEN         ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+      ENDIF
+
+      ! 0. 2D fields of bottom temperature and salinity, and bottom slope
+      ! -----------------------------------------------------------------
+      ! mbathy= number of w-level, minimum value=1 (cf dommsk.F)
+#  if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#  endif
+            ik = mbkt(ji,jj)                              ! index of the bottom ocean T-level
+            ztnb(ji,jj) = tn(ji,jj,ik) * tmask(ji,jj,1)   ! masked now T and S at ocean bottom 
+            zsnb(ji,jj) = sn(ji,jj,ik) * tmask(ji,jj,1)
+            ztbb(ji,jj) = tb(ji,jj,ik) * tmask(ji,jj,1)   ! masked before T and S at ocean bottom 
+            zsbb(ji,jj) = sb(ji,jj,ik) * tmask(ji,jj,1)
+            zdep(ji,jj) = fsdept(ji,jj,ik)                ! depth of the ocean bottom T-level
+         END DO
+      END DO
+
+      IF( ln_zps ) THEN      ! partial steps correction 
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               iku1 = MAX( mbathy(ji+1,jj  )-1, 1 )
+               iku2 = MAX( mbathy(ji  ,jj  )-1, 1 )
+               ikv1 = MAX( mbathy(ji  ,jj+1)-1, 1 )
+               ikv2 = MAX( mbathy(ji  ,jj  )-1, 1 )
+               ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+               ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+               zahu(ji,jj) = rn_ahtbbl * e2u(ji,jj) * ze3u / e1u(ji,jj) * umask(ji,jj,1)
+               zahv(ji,jj) = rn_ahtbbl * e1v(ji,jj) * ze3v / e2v(ji,jj) * vmask(ji,jj,1)
+            END DO
+         END DO
+      ELSE                    ! z-coordinate - full steps or s-coordinate
+#   if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#   else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#   endif
+               iku = mbku(ji,jj)
+               ikv = mbkv(ji,jj)
+               zahu(ji,jj) = rn_ahtbbl * e2u(ji,jj) * fse3u(ji,jj,iku) / e1u(ji,jj) * umask(ji,jj,1)
+               zahv(ji,jj) = rn_ahtbbl * e1v(ji,jj) * fse3v(ji,jj,ikv) / e2v(ji,jj) * vmask(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+
+      ! 1. Criteria of additional bottom diffusivity: grad(rho).grad(h)<0
+      ! --------------------------------------------
+      ! Sign of the local density gradient along the i- and j-slopes
+      ! multiplied by the slope of the ocean bottom
+
+      SELECT CASE ( nn_eos )
+      !
+      CASE ( 0 )                 !==  Jackett and McDougall (1994) formulation  ==!
+#  if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#  endif
+               ! temperature, salinity anomalie and depth
+               zt = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+               zs = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+               zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+               ! masked ratio alpha/beta
+               zalbet = fsalbt( zt, zs, zh )*umask(ji,jj,1)
+               ! local density gradient along i-bathymetric slope
+               zgdrho = zalbet * ( ztnb(ji+1,jj) - ztnb(ji,jj) )   &
+                      -          ( zsnb(ji+1,jj) - zsnb(ji,jj) )
+               ! sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+               !
+               ! temperature, salinity anomalie and depth
+               zt = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+               zs = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+               zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+               ! masked ratio alpha/beta
+               zalbet = fsalbt( zt, zs, zh )*vmask(ji,jj,1)
+               ! local density gradient along j-bathymetric slope
+               zgdrho = zalbet * ( ztnb(ji,jj+1) - ztnb(ji,jj) )   &
+                      -          ( zsnb(ji,jj+1) - zsnb(ji,jj) )
+               ! sign of local j-gradient of density multiplied by the j-slope
+               zsign = sign( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+            END DO
+         END DO
+         !
+      CASE ( 1 )               !==  Linear formulation function of temperature only  ==!
+#  if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#  endif
+               ! local 'density/temperature' gradient along i-bathymetric slope
+               zgdrho =  ztnb(ji+1,jj) - ztnb(ji,jj) 
+               ! sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+               !
+               ! local density gradient along j-bathymetric slope
+               zgdrho =  ztnb(ji,jj+1) - ztnb(ji,jj) 
+               ! sign of local j-gradient of density multiplied by the j-slope
+               zsign = sign( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+            END DO
+         END DO
+         !
+      CASE ( 2 )               !==  Linear formulation function of temperature and salinity  ==!
+#  if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#  endif      
+               ! local density gradient along i-bathymetric slope
+               zgdrho = - ( rn_beta *( zsnb(ji+1,jj) - zsnb(ji,jj) )   &
+                  &       - rn_alpha*( ztnb(ji+1,jj) - ztnb(ji,jj) ) )
+               ! sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+               !
+               ! local density gradient along j-bathymetric slope
+               zgdrho = - ( rn_beta *( zsnb(ji,jj+1) - zsnb(ji,jj) )   &
+                  &       - rn_alpha*( ztnb(ji,jj+1) - ztnb(ji,jj) ) )   
+               ! sign of local j-gradient of density multiplied by the j-slope
+               zsign = sign( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+            END DO
+         END DO
+         !
+      END SELECT
+
+      ! 2. Additional second order diffusive trends
+      ! -------------------------------------------
+
+      ! first derivative (gradient)
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            zkx(ji,jj) = zki(ji,jj) * ( ztbb(ji+1,jj) - ztbb(ji,jj) )
+            zkz(ji,jj) = zki(ji,jj) * ( zsbb(ji+1,jj) - zsbb(ji,jj) )
+
+            zky(ji,jj) = zkj(ji,jj) * ( ztbb(ji,jj+1) - ztbb(ji,jj) )
+            zkw(ji,jj) = zkj(ji,jj) * ( zsbb(ji,jj+1) - zsbb(ji,jj) )
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      IF( cp_cfg == "orca" ) THEN
+         !
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            ! Gibraltar enhancement of BBL
+            ij0 = 102   ;   ij1 = 102
+            ii0 = 139   ;   ii1 = 140  
+            zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            !
+            ! Red Sea enhancement of BBL
+            ij0 =  88   ;   ij1 =  88
+            ii0 = 161   ;   ii1 = 162
+            zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 10.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 10.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            !
+            !                                        ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            ! Gibraltar enhancement of BBL
+            ij0 =  52   ;   ij1 =  52
+            ii0 =  70   ;   ii1 =  71  
+            zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+            !
+         END SELECT
+      !
+      ENDIF
+
+
+      ! second derivative (divergence) and add to the general tracer trend
+#  if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+#  endif
+            ik = max( mbathy(ji,jj)-1, 1 )
+            zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,ik) )
+            zta = (  zkx(ji,jj) - zkx(ji-1,jj  )    &
+                   + zky(ji,jj) - zky(ji  ,jj-1)  ) * zbtr
+            zsa = (  zkz(ji,jj) - zkz(ji-1,jj  )    &
+                   + zkw(ji,jj) - zkw(ji  ,jj-1)  ) * zbtr
+            ta(ji,jj,ik) = ta(ji,jj,ik) + zta
+            sa(ji,jj,ik) = sa(ji,jj,ik) + zsa
+         END DO
+      END DO
+
+      IF( l_trdtra ) THEN      ! save the BBL lateral diffusion trends for diagnostic
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_bbl, 'TRA', kt)
+      ENDIF
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' bbl  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_bbl_dif
+
+# if defined key_trabbl_adv
+   !!----------------------------------------------------------------------
+   !!   'key_trabbl_adv'                    advective bottom boundary layer
+   !!----------------------------------------------------------------------
+#  include "trabbl_adv.h90"
+# else
+   !!----------------------------------------------------------------------
+   !!   Default option :                 NO advective bottom boundary layer
+   !!----------------------------------------------------------------------
+   SUBROUTINE tra_bbl_adv (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'tra_bbl_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_bbl_adv
+# endif
+
+   SUBROUTINE tra_bbl_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_bbl_init  ***
+      !!
+      !! ** Purpose :   Initialization for the bottom boundary layer scheme.
+      !!
+      !! ** Method  :   Read the nambbl namelist and check the parameters
+      !!      called by tra_bbl at the first timestep (nit000)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj      ! dummy loop indices
+      REAL(wp),  DIMENSION(jpi,jpj) :: zmbk  
+
+      NAMELIST/nambbl/ rn_ahtbbl
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )              ! Read Namelist nambbl : bottom boundary layer scheme
+      READ   ( numnam, nambbl )
+
+      IF(lwp) THEN                   ! Parameter control and print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_bbl_init : '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         IF( lk_trabbl_dif )   WRITE(numout,*) '               * Diffusive Bottom Boundary Layer'
+         IF( lk_trabbl_adv )   WRITE(numout,*) '               * Advective Bottom Boundary Layer'
+         WRITE(numout,*) '       Namelist nambbl : set bbl parameters'
+         WRITE(numout,*) '          bottom boundary layer coef.    rn_ahtbbl = ', rn_ahtbbl
+      ENDIF
+ 
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            mbkt(ji,jj) = MAX( mbathy(ji,jj) - 1, 1 )   ! vertical index of the bottom ocean T-level
+         END DO
+      END DO
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            mbku(ji,jj) = MAX( MIN( mbathy(ji+1,jj  ), mbathy(ji,jj) ) - 1, 1 )
+            mbkv(ji,jj) = MAX( MIN( mbathy(ji  ,jj+1), mbathy(ji,jj) ) - 1, 1 )
+         END DO
+      END DO
+
+      zmbk(:,:) = FLOAT( mbku (:,:) )   
+      CALL lbc_lnk(zmbk,'U',1.)
+      mbku(:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
+
+      zmbk(:,:) = FLOAT( mbkv (:,:) )   
+      CALL lbc_lnk(zmbk,'V',1.)
+      mbkv(:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
+
+# if defined key_trabbl_adv
+      w_bbl(:,:,:) = 0.e0          ! initialisation of w_bbl to zero
+# endif
+      !
+   END SUBROUTINE tra_bbl_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      No bottom boundary layer scheme
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_dif = .FALSE.   !: diff bbl flag
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl_adv = .FALSE.   !: adv  bbl flag
+CONTAINS
+   SUBROUTINE tra_bbl_dif( kt )              ! Empty routine
+      WRITE(*,*) 'tra_bbl_dif: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_bbl_dif
+   SUBROUTINE tra_bbl_adv( kt )              ! Empty routine
+      WRITE(*,*) 'tra_bbl_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_bbl_adv
+#endif
+
+   !!======================================================================
+END MODULE trabbl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl_adv.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl_adv.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trabbl_adv.h90	(revision 1844)
@@ -0,0 +1,426 @@
+   !!----------------------------------------------------------------------
+   !!                     ***  trabbl_adv.h90  ***
+   !!----------------------------------------------------------------------
+   !! History :  8.5  !  02-12  (A. de Miranda, G. Madec)  Original Code 
+   !!            9.0  !  04-01  (A. de Miranda, G. Madec, J.M. Molines )
+   !!----------------------------------------------------------------------     
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE tra_bbl_adv( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_bbl_adv  ***
+      !!                   
+      !! ** Purpose :   Compute the before tracer (t & s) trend associated 
+      !!     with the bottom boundary layer and add it to the general trend
+      !!     of tracer equations. The bottom boundary layer is supposed to be 
+      !!     both an advective and diffusive bottom boundary layer.
+      !!
+      !! ** Method  :   Computes the bottom boundary horizontal and vertical 
+      !!      advection terms. Add it to the general trend : ta =ta + adv_bbl.
+      !!        When the product grad( rho) * grad(h) < 0 (where grad is a
+      !!      along bottom slope gradient) an additional lateral 2nd order
+      !!      diffusion along the bottom slope is added to the general
+      !!      tracer trend, otherwise the additional trend is set to 0.
+      !!      Second order operator (laplacian type) with variable coefficient
+      !!      computed as follow for temperature (idem on s):
+      !!         difft = 1/(e1t*e2t*e3t) { di-1[ ahbt e2u*e3u/e1u di[ztb] ]
+      !!                                 + dj-1[ ahbt e1v*e3v/e2v dj[ztb] ] }
+      !!      where ztb is a 2D array: the bottom ocean te;perature and ahtb
+      !!      is a time and space varying diffusive coefficient defined by:
+      !!         ahbt = zahbp    if grad(rho).grad(h) < 0
+      !!              = 0.       otherwise.
+      !!      Note that grad(.) is the along bottom slope gradient. grad(rho)
+      !!      is evaluated using the local density (i.e. referenced at the
+      !!      local depth). Typical value of ahbt is 2000 m2/s (equivalent to
+      !!      a downslope velocity of 20 cm/s if the condition for slope
+      !!      convection is satified)
+      !!        Add this before trend to the general trend (ta,sa) of the
+      !!      botton ocean tracer point:
+      !!              ta = ta + difft
+      !!
+      !! ** Action  : - update (ta,sa) at the bottom level with the bottom
+      !!                boundary layer trend
+      !!
+      !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
+      !!----------------------------------------------------------------------     
+      USE eosbn2                      ! equation of state
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace 
+      USE iom                           
+      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step 
+      !!
+      INTEGER  ::   ji, jj, jk        ! dummy loop indices
+      INTEGER  ::   ik                ! temporary integers
+      INTEGER  ::   iku, iku1, iku2   !    "          "
+      INTEGER  ::   ikv, ikv1, ikv2   !    "          "
+      REAL(wp) ::   zsign, zh, zalbet     ! temporary scalars
+      REAL(wp) ::   zgdrho, zbtr          !    "         " 
+      REAL(wp) ::   zbt, zsigna           !    "         "
+      REAL(wp) ::   zfui, ze3u, zt, zta   !    "         "
+      REAL(wp) ::   zfvj, ze3v, zs, zsa   !    "         "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zalphax, zwu, zunb   ! temporary 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zalphay, zwv, zvnb   !    "             "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zwx, zwy, zww, zwz   !    "             "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztbb, zsbb           !    "             "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztnb, zsnb, zdep     !    "             "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zhdivn               ! temporary 3D workspace
+      REAL(wp) ::   fsalbt, pft, pfs, pfh   ! statement function
+      !!----------------------------------------------------------------------
+      ! ratio alpha/beta
+      ! ================
+      !  fsalbt: ratio of thermal over saline expension coefficients
+      !       pft :  potential temperature in degrees celcius
+      !       pfs :  salinity anomaly (s-35) in psu
+      !       pfh :  depth in meters
+
+      fsalbt( pft, pfs, pfh ) =                                              &
+         ( ( ( -0.255019e-07 * pft + 0.298357e-05 ) * pft                    &
+                                   - 0.203814e-03 ) * pft                    &
+                                   + 0.170907e-01 ) * pft                    &
+                                   + 0.665157e-01                            &
+         +(-0.678662e-05 * pfs - 0.846960e-04 * pft + 0.378110e-02 ) * pfs   &
+         +  ( ( - 0.302285e-13 * pfh                                         &
+                - 0.251520e-11 * pfs                                         &
+                + 0.512857e-12 * pft * pft          ) * pfh                  &
+                                     - 0.164759e-06   * pfs                  &
+             +(   0.791325e-08 * pft - 0.933746e-06 ) * pft                  &
+                                     + 0.380374e-04 ) * pfh
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_bbl_init    ! initialization at first time-step
+
+      ! 1. 2D fields of bottom temperature and salinity, and bottom slope
+      ! -----------------------------------------------------------------
+      ! mbathy= number of w-level, minimum value=1 (cf dommsk.F)
+
+#if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#endif
+            ik = mbkt(ji,jj)                               ! index of the bottom ocean T-level
+            ztnb(ji,jj) = tn(ji,jj,ik)
+            zsnb(ji,jj) = sn(ji,jj,ik)
+            ztbb(ji,jj) = tb(ji,jj,ik)
+            zsbb(ji,jj) = sb(ji,jj,ik) 
+            zdep(ji,jj) = fsdept(ji,jj,ik)                 ! depth of the ocean bottom T-level
+
+            zunb(ji,jj) = un(ji,jj,mbku(ji,jj)) 
+            zvnb(ji,jj) = vn(ji,jj,mbkv(ji,jj)) 
+         END DO
+      END DO
+
+
+      ! 2. Criteria of additional bottom diffusivity: grad(rho).grad(h)<0
+      ! --------------------------------------------
+      ! Sign of the local density gradient along the i- and j-slopes
+      ! multiplied by the slope of the ocean bottom
+
+      SELECT CASE ( nn_eos )
+      !
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+         !
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               !   ... temperature, salinity anomalie and depth
+               zt = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+               zs = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+               zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+               !   ... masked ratio alpha/beta
+               zalbet = fsalbt( zt, zs, zh ) * umask(ji,jj,1)
+               !   ... local density gradient along i-bathymetric slope
+               zgdrho = zalbet * ( ztnb(ji+1,jj) - ztnb(ji,jj) )   &
+                  &       -      ( zsnb(ji+1,jj) - zsnb(ji,jj) )
+               zgdrho = zgdrho * umask(ji,jj,1)
+               !   ... sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zunb(ji,jj) * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zalphax(ji,jj)=( 0.5 + zsigna ) * ( 0.5 - zsign ) * umask(ji,jj,1)
+               !
+               !   ... temperature, salinity anomalie and depth
+               zt = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+               zs = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+               zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+               !   ... masked ratio alpha/beta
+               zalbet = fsalbt( zt, zs, zh ) * vmask(ji,jj,1)
+               !   ... local density gradient along j-bathymetric slope
+               zgdrho = zalbet * ( ztnb(ji,jj+1) - ztnb(ji,jj) )   &
+                  &       -      ( zsnb(ji,jj+1) - zsnb(ji,jj) )
+               zgdrho = zgdrho*vmask(ji,jj,1)
+               !   ... sign of local j-gradient of density multiplied by the j-slope
+               zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zalphay(ji,jj)=( 0.5 + zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+            END DO
+         END DO
+         !
+      CASE ( 1 )               ! Linear formulation function of temperature only
+         !
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ! local 'density/temperature' gradient along i-bathymetric slope
+               zgdrho =  ( ztnb(ji+1,jj) - ztnb(ji,jj) )
+               ! sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, - zgdrho    * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zunb(ji,jj) * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zalphax(ji,jj)=( 0.5 + zsigna ) * ( 0.5 - zsign ) * umask(ji,jj,1)
+               ! 
+               ! local density gradient along j-bathymetric slope
+               zgdrho =  ( ztnb(ji,jj+1) - ztnb(ji,jj) )
+               ! sign of local j-gradient of density multiplied by the j-slope
+               zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zalphay(ji,jj)=( 0.5 + zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+            END DO
+         END DO
+         !
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+         !
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.            
+               ! local density gradient along i-bathymetric slope
+               zgdrho = - ( rn_beta *( zsnb(ji+1,jj) - zsnb(ji,jj) )   &
+                  &       - rn_alpha*( ztnb(ji+1,jj) - ztnb(ji,jj) ) )
+               ! sign of local i-gradient of density multiplied by the i-slope
+               zsign = SIGN( 0.5, - zgdrho    * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zunb(ji,jj) * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+               zalphax(ji,jj) = ( 0.5 + zsigna ) * ( 0.5 - zsign ) * umask(ji,jj,1)
+               ! 
+               ! local density gradient along j-bathymetric slope
+               zgdrho = - ( rn_beta *( zsnb(ji,jj+1) - zsnb(ji,jj) )   &
+                  &       - rn_alpha*( ztnb(ji,jj+1) - ztnb(ji,jj) ) )   
+               ! sign of local j-gradient of density multiplied by the j-slope
+               zsign = SIGN( 0.5, - zgdrho    * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+               zalphay(ji,jj) = ( 0.5 + zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+            END DO
+         END DO
+         !
+      END SELECT
+
+      ! lateral boundary conditions on zalphax and zalphay   (unchanged sign)
+       CALL lbc_lnk( zalphax, 'U', 1. )   ;   CALL lbc_lnk( zalphay, 'V', 1. )
+
+
+      ! 3. Velocities that are exchanged between ajacent bottom boxes.
+      !---------------------------------------------------------------
+
+      ! ... is equal to zero but where bbl will work.
+      u_bbl(:,:,:) = 0.e0
+      v_bbl(:,:,:) = 0.e0
+
+      IF( ln_zps ) THEN     ! partial steps correction   
+      
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else   
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               iku  = mbku(ji  ,jj  )
+               ikv  = mbkv(ji  ,jj  )  
+               iku1 = mbkt(ji+1,jj  )
+               iku2 = mbkt(ji  ,jj  )
+               ikv1 = mbkt(ji  ,jj+1)
+               ikv2 = mbkt(ji  ,jj  )
+               ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+               ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+               
+               IF( MAX(iku,ikv) >  1 ) THEN
+                  u_bbl(ji,jj,iku) = zalphax(ji,jj) * un(ji,jj,iku) * ze3u / fse3u(ji,jj,iku)
+                  v_bbl(ji,jj,ikv) = zalphay(ji,jj) * vn(ji,jj,ikv) * ze3v / fse3v(ji,jj,ikv)       
+               ENDIF
+            END DO
+         END DO
+
+         ! lateral boundary conditions on u_bbl and v_bbl   (changed sign)
+         CALL lbc_lnk( u_bbl, 'U', -1. )   ;   CALL lbc_lnk( v_bbl, 'V', -1. )
+       
+      ELSE       ! if not partial step loop over the whole domain no lbc call
+
+#if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#endif   
+               iku = mbku(ji,jj)
+               ikv = mbkv(ji,jj)
+               IF( MAX(iku,ikv) >  1 ) THEN
+                  u_bbl(ji,jj,iku) = zalphax(ji,jj) * un(ji,jj,iku) 
+                  v_bbl(ji,jj,ikv) = zalphay(ji,jj) * vn(ji,jj,ikv)       
+               ENDIF
+            END DO
+         END DO
+       
+      ENDIF
+
+
+      ! 5. Along sigma advective trend
+      ! -------------------------------
+      ! ... Second order centered tracer flux at u and v-points
+
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            iku = mbku(ji,jj)
+            ikv = mbkv(ji,jj)
+            zfui = e2u(ji,jj) * fse3u(ji,jj,iku) * u_bbl(ji,jj,iku)
+            zfvj = e1v(ji,jj) * fse3v(ji,jj,ikv) * v_bbl(ji,jj,ikv)
+            ! centered scheme
+!           zwx(ji,jj) = 0.5* zfui * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+!           zwy(ji,jj) = 0.5* zfvj * ( ztnb(ji,jj) + ztnb(ji,jj+1) )
+!           zww(ji,jj) = 0.5* zfui * ( zsnb(ji,jj) + zsnb(ji+1,jj) )
+!           zwz(ji,jj) = 0.5* zfvj * ( zsnb(ji,jj) + zsnb(ji,jj+1) )
+            ! upstream scheme
+            zwx(ji,jj) = ( ( zfui + ABS( zfui ) ) * ztbb(ji  ,jj  )   &
+               &          +( zfui - ABS( zfui ) ) * ztbb(ji+1,jj  ) ) * 0.5
+            zwy(ji,jj) = ( ( zfvj + ABS( zfvj ) ) * ztbb(ji  ,jj  )   &
+               &          +( zfvj - ABS( zfvj ) ) * ztbb(ji  ,jj+1) ) * 0.5
+            zww(ji,jj) = ( ( zfui + ABS( zfui ) ) * zsbb(ji  ,jj  )   &
+               &          +( zfui - ABS( zfui ) ) * zsbb(ji+1,jj  ) ) * 0.5
+            zwz(ji,jj) = ( ( zfvj + ABS( zfvj ) ) * zsbb(ji  ,jj  )   &
+               &          +( zfvj - ABS( zfvj ) ) * zsbb(ji  ,jj+1) ) * 0.5
+         END DO
+      END DO
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ik = mbkt(ji,jj)
+            zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,ik) )
+            ! horizontal advective trends
+            zta = - zbtr * (  zwx(ji,jj) - zwx(ji-1,jj  )   &
+               &            + zwy(ji,jj) - zwy(ji  ,jj-1)  )
+            zsa = - zbtr * (  zww(ji,jj) - zww(ji-1,jj  )   &
+               &            + zwz(ji,jj) - zwz(ji  ,jj-1)  )
+
+            ! add it to the general tracer trends
+            ta(ji,jj,ik) = ta(ji,jj,ik) + zta
+            sa(ji,jj,ik) = sa(ji,jj,ik) + zsa
+         END DO
+      END DO
+
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' bbl  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      ! 6. Vertical advection velocities
+      ! --------------------------------
+      ! ... computes divergence perturbation (velocties to be removed from upper t boxes :
+      DO jk= 1, jpkm1
+         DO jj=1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zwu(ji,jj) = -e2u(ji,jj) * u_bbl(ji,jj,jk) * fse3u(ji,jj,jk)
+               zwv(ji,jj) = -e1v(ji,jj) * v_bbl(ji,jj,jk) * fse3v(ji,jj,jk)
+            END DO
+         END DO
+
+      ! ... horizontal divergence
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zhdivn(ji,jj,jk) = (  zwu(ji,jj) - zwu(ji-1,jj  )   &
+                                   + zwv(ji,jj) - zwv(ji  ,jj-1)  ) / zbt
+            END DO
+         END DO
+      END DO
+
+
+      ! ... horizontal bottom divergence
+
+      IF( ln_zps ) THEN
+ 
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               iku  = mbku(ji  ,jj  )
+               ikv  = mbkv(ji  ,jj  )  
+               iku1 = mbkt(ji+1,jj  )
+               iku2 = mbkt(ji  ,jj  )
+               ikv1 = mbkt(ji  ,jj+1)
+               ikv2 = mbkt(ji  ,jj  )
+               ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+               ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+
+               zwu(ji,jj) = zalphax(ji,jj) * e2u(ji,jj) * ze3u  
+               zwv(ji,jj) = zalphay(ji,jj) * e1v(ji,jj) * ze3v
+            END DO
+         END DO  
+         !
+      ELSE
+         !
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               iku = mbku(ji,jj)
+               ikv = mbkv(ji,jj)
+               zwu(ji,jj) = zalphax(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,iku) 
+               zwv(ji,jj) = zalphay(ji,jj) * e1v(ji,jj) * fse3v(ji,jj,ikv) 
+            END DO
+         END DO
+         !
+      ENDIF
+ 
+
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ik = mbkt(ji,jj)
+            zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,ik)
+            zhdivn(ji,jj,ik) =   &
+               &   (  zwu(ji  ,jj  ) * ( zunb(ji  ,jj  ) - un(ji  ,jj  ,ik) )   &
+               &    - zwu(ji-1,jj  ) * ( zunb(ji-1,jj  ) - un(ji-1,jj  ,ik) )   &
+               &    + zwv(ji  ,jj  ) * ( zvnb(ji  ,jj  ) - vn(ji  ,jj  ,ik) )   &
+               &    - zwv(ji  ,jj-1) * ( zvnb(ji  ,jj-1) - vn(ji  ,jj-1,ik) )   &
+               &   ) / zbt
+
+         END DO
+      END DO
+
+      ! 7. compute additional vertical velocity to be used in t boxes
+      ! -------------------------------------------------------------
+      ! ... Computation from the bottom
+      ! Note that w_bbl(:,:,jpk) has been set to 0 in tra_bbl_init
+      DO jk = jpkm1, 1, -1
+         DO jj= 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               w_bbl(ji,jj,jk) = w_bbl(ji,jj,jk+1) - fse3t(ji,jj,jk)*zhdivn(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( w_bbl, 'W', 1. )      ! Boundary condition on w_bbl   (unchanged sign)
+
+      CALL iom_put( "uoce_bbl", u_bbl )   ! bbl i-current      
+      CALL iom_put( "voce_bbl", v_bbl )   ! bbl j-current
+      CALL iom_put( "woce_bbl", w_bbl )   ! bbl vert. current
+      !
+   END SUBROUTINE tra_bbl_adv
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tradmp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 1844)
@@ -0,0 +1,706 @@
+MODULE tradmp
+   !!======================================================================
+   !!                       ***  MODULE  tradmp  ***
+   !! Ocean physics: internal restoring trend on active tracers (T and S)
+   !!======================================================================
+   !! History :  OPA  ! 1991-03  (O. Marti, G. Madec)  Original code
+   !!                 ! 1992-06  (M. Imbard)  doctor norme
+   !!                 ! 1996-01  (G. Madec)  statement function for e3
+   !!                 ! 1997-05  (G. Madec)  macro-tasked on jk-slab
+   !!                 ! 1998-07  (M. Imbard, G. Madec) ORCA version
+   !!            7.0  ! 2001-02  (M. Imbard)  cofdis, Original code
+   !!            8.1  ! 2001-02  (G. Madec, E. Durand)  cleaning
+   !!  NEMO      1.0  ! 2002-08  (G. Madec, E. Durand)  free form + modules
+   !!            3.2  ! 2009-08  (G. Madec, C. Talandier)  DOCTOR norm for namelist parameter
+   !!----------------------------------------------------------------------
+#if   defined key_tradmp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   key_tradmp                                         internal damping
+   !!----------------------------------------------------------------------
+   !!   tra_dmp      : update the tracer trend with the internal damping
+   !!   tra_dmp_init : initialization, namlist read, parameters control
+   !!   dtacof_zoom  : restoring coefficient for zoom domain
+   !!   dtacof       : restoring coefficient for global domain
+   !!   cofdis       : compute the distance to the coastline
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE zdf_oce         ! ocean vertical physics
+   USE phycst          ! Define parameters for the routines
+   USE dtatem          ! temperature data
+   USE dtasal          ! salinity data
+   USE zdfmxl          ! mixed layer depth
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_dmp    ! routine called by step.F90
+
+#if ! defined key_agrif
+   LOGICAL, PUBLIC, PARAMETER ::   lk_tradmp = .TRUE.     !: internal damping flag
+#else
+   LOGICAL, PUBLIC            ::   lk_tradmp = .TRUE.     !: internal damping flag
+#endif
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   resto    !: restoring coeff. on T and S (s-1)
+   
+   !                             !!* Namelist namtra_dmp : T & S newtonian damping *
+   INTEGER  ::   nn_hdmp =   -1   ! = 0/-1/'latitude' for damping over T and S
+   INTEGER  ::   nn_zdmp =    0   ! = 0/1/2 flag for damping in the mixed layer
+   REAL(wp) ::   rn_surf =   50.  ! surface time scale for internal damping        [days]
+   REAL(wp) ::   rn_bot  =  360.  ! bottom time scale for internal damping         [days]
+   REAL(wp) ::   rn_dep  =  800.  ! depth of transition between rn_surf and rn_bot [meters]
+   INTEGER  ::   nn_file =    2   ! = 1 create a damping.coeff NetCDF file 
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_dmp( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_dmp  ***
+      !!                  
+      !! ** Purpose :   Compute the tracer trend due to a newtonian damping
+      !!      of the tracer field towards given data field and add it to the
+      !!      general tracer trends.
+      !!
+      !! ** Method  :   Newtonian damping towards t_dta and s_dta computed 
+      !!      and add to the general tracer trends:
+      !!                     ta = ta + resto * (t_dta - tb)
+      !!                     sa = sa + resto * (s_dta - sb)
+      !!         The trend is computed either throughout the water column
+      !!      (nlmdmp=0) or in area of weak vertical mixing (nlmdmp=1) or
+      !!      below the well mixed layer (nlmdmp=2)
+      !!
+      !! ** Action  : - (ta,sa)   tracer trends updated with the damping trend
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL tra_dmp_init      ! Initialization
+
+      IF( l_trdtra )   THEN                       ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+      ENDIF
+
+      SELECT CASE ( nn_zdmp ) 
+      !
+      CASE( 0 )                   !==  newtonian damping throughout the water column  ==!
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ta(ji,jj,jk) = ta(ji,jj,jk) + resto(ji,jj,jk) * ( t_dta(ji,jj,jk) - tb(ji,jj,jk) )
+                  sa(ji,jj,jk) = sa(ji,jj,jk) + resto(ji,jj,jk) * ( s_dta(ji,jj,jk) - sb(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 1 )                  !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF( avt(ji,jj,jk) <= 5.e-4 ) THEN
+                     ta(ji,jj,jk) = ta(ji,jj,jk) + resto(ji,jj,jk) * ( t_dta(ji,jj,jk) - tb(ji,jj,jk) )
+                     sa(ji,jj,jk) = sa(ji,jj,jk) + resto(ji,jj,jk) * ( s_dta(ji,jj,jk) - sb(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 2 )                  !==  no damping in the mixed layer   ==!
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
+                     ta(ji,jj,jk) = ta(ji,jj,jk) + resto(ji,jj,jk) * ( t_dta(ji,jj,jk) - tb(ji,jj,jk) )
+                     sa(ji,jj,jk) = sa(ji,jj,jk) + resto(ji,jj,jk) * ( s_dta(ji,jj,jk) - sb(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+
+      IF( l_trdtra )   THEN       ! trend diagnostic
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_dmp, 'TRA', kt )
+      ENDIF
+      !                           ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' dmp  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_dmp
+
+
+   SUBROUTINE tra_dmp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_dmp_init  ***
+      !! 
+      !! ** Purpose :   Initialization for the newtonian damping 
+      !!
+      !! ** Method  :   read the nammbf namelist and check the parameters
+      !!----------------------------------------------------------------------
+      NAMELIST/namtra_dmp/ nn_hdmp, nn_zdmp, rn_surf, rn_bot, rn_dep, nn_file
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )                  ! Read Namelist namtra_dmp : temperature and salinity damping term
+      READ   ( numnam, namtra_dmp )
+      IF( lzoom )   nn_zdmp = 0           ! restoring to climatology at closed north or south boundaries
+
+      IF(lwp) THEN                       ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_dmp : T and S newtonian damping'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namtra_dmp : set damping parameter'
+         WRITE(numout,*) '      T and S damping option         nn_hdmp = ', nn_hdmp
+         WRITE(numout,*) '      mixed layer damping option     nn_zdmp = ', nn_zdmp, '(zoom: forced to 0)'
+         WRITE(numout,*) '      surface time scale (days)      rn_surf = ', rn_surf
+         WRITE(numout,*) '      bottom time scale (days)       rn_bot  = ', rn_bot
+         WRITE(numout,*) '      depth of transition (meters)   rn_dep  = ', rn_dep
+         WRITE(numout,*) '      create a damping.coeff file    nn_file = ', nn_file
+      ENDIF
+
+      SELECT CASE ( nn_hdmp )
+      CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   tracer damping in the Med & Red seas only'
+      CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping poleward of', nn_hdmp, ' degrees'
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for nn_hdmp = ', nn_hdmp
+         CALL ctl_stop(ctmp1)
+      END SELECT
+
+      SELECT CASE ( nn_zdmp )
+      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
+      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
+      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
+      CASE DEFAULT
+         WRITE(ctmp1,*) 'bad flag value for nn_zdmp = ', nn_zdmp
+         CALL ctl_stop(ctmp1)
+      END SELECT
+
+      IF( .NOT.lk_dtasal .OR. .NOT.lk_dtatem )   &
+         &   CALL ctl_stop( 'no temperature and/or salinity data define key_dtatem and key_dtasal' )
+
+      !                          ! Damping coefficients initialization
+      IF( lzoom ) THEN   ;   CALL dtacof_zoom
+      ELSE               ;   CALL dtacof
+      ENDIF
+      !
+   END SUBROUTINE tra_dmp_init
+
+
+   SUBROUTINE dtacof_zoom
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dtacof_zoom  ***
+      !!
+      !! ** Purpose :   Compute the damping coefficient for zoom domain
+      !!
+      !! ** Method  : - set along closed boundary due to zoom a damping over
+      !!                6 points with a max time scale of 5 days.
+      !!              - ORCA arctic/antarctic zoom: set the damping along
+      !!                south/north boundary over a latitude strip.
+      !!
+      !! ** Action  : - resto, the damping coeff. for T and S
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
+      REAL(wp) ::   zlat, zlat0, zlat1, zlat2   ! temporary scalar
+      REAL(wp), DIMENSION(6)  ::   zfact        ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      zfact(1) =  1.
+      zfact(2) =  1. 
+      zfact(3) = 11./12.
+      zfact(4) =  8./12.
+      zfact(5) =  4./12.
+      zfact(6) =  1./12.
+      zfact(:) = zfact(:) / ( 5. * rday )    ! 5 days max restoring time scale
+
+      resto(:,:,:) = 0.e0
+
+      ! damping along the forced closed boundary over 6 grid-points
+      DO jn = 1, 6
+         IF( lzoom_w )   resto( mi0(jn+jpizoom):mi1(jn+jpizoom), : , : )                    = zfact(jn)   ! west  closed
+         IF( lzoom_s )   resto( : , mj0(jn+jpjzoom):mj1(jn+jpjzoom), : )                    = zfact(jn)   ! south closed 
+         IF( lzoom_e )   resto( mi0(jpiglo+jpizoom-1-jn):mi1(jpiglo+jpizoom-1-jn) , : , : ) = zfact(jn)   ! east  closed 
+         IF( lzoom_n )   resto( : , mj0(jpjglo+jpjzoom-1-jn):mj1(jpjglo+jpjzoom-1-jn) , : ) = zfact(jn)   ! north closed
+      END DO
+
+      !                                           ! ====================================================
+      IF( lzoom_arct .AND. lzoom_anta ) THEN      !  ORCA configuration : arctic zoom or antarctic zoom
+         !                                        ! ====================================================
+         IF(lwp) WRITE(numout,*)
+         IF(lwp .AND. lzoom_arct ) WRITE(numout,*) '              dtacof_zoom : ORCA    Arctic zoom'
+         IF(lwp .AND. lzoom_arct ) WRITE(numout,*) '              dtacof_zoom : ORCA Antarctic zoom'
+         IF(lwp) WRITE(numout,*)
+         !
+         !                          ! Initialization : 
+         resto(:,:,:) = 0.e0
+         zlat0 = 10.                     ! zlat0 : latitude strip where resto decreases
+         zlat1 = 30.                     ! zlat1 : resto = 1 before zlat1
+         zlat2 = zlat1 + zlat0           ! zlat2 : resto decreases from 1 to 0 between zlat1 and zlat2
+
+         DO jk = 2, jpkm1           ! Compute arrays resto ; value for internal damping : 5 days
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zlat = ABS( gphit(ji,jj) )
+                  IF( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
+                     resto(ji,jj,jk) = 0.5 * ( 1./(5.*rday) ) * ( 1. - cos(rpi*(zlat2-zlat)/zlat0) ) 
+                  ELSEIF( zlat < zlat1 ) THEN
+                     resto(ji,jj,jk) = 1./(5.*rday)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+      !                             ! Mask resto array
+      resto(:,:,:) = resto(:,:,:) * tmask(:,:,:)
+      !
+   END SUBROUTINE dtacof_zoom
+
+
+   SUBROUTINE dtacof
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dtacof  ***
+      !!
+      !! ** Purpose :   Compute the damping coefficient
+      !!
+      !! ** Method  :   Arrays defining the damping are computed for each grid
+      !!                point for temperature and salinity (resto)
+      !!                Damping depends on distance to coast, depth and latitude
+      !!
+      !! ** Action  : - resto, the damping coeff. for T and S
+      !!----------------------------------------------------------------------
+      USE iom
+      USE ioipsl
+      !!
+      INTEGER ::   ji, jj, jk                   ! dummy loop indices
+      INTEGER ::   ii0, ii1, ij0, ij1           !    -          -
+      INTEGER ::   inum0                        ! logical unit for file restoring damping term
+      INTEGER ::   icot                         ! logical unit for file distance to the coast
+      REAL(wp) ::   zinfl, zlon                 ! temporary scalars
+      REAL(wp) ::   zlat, zlat0, zlat1, zlat2   !    -         -
+      REAL(wp) ::   zsdmp, zbdmp                !    -         -
+      REAL(wp), DIMENSION(jpk)         ::   zhfac
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zmrs
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdct
+      !!----------------------------------------------------------------------
+
+      ! ====================================
+      !  ORCA configuration : global domain
+      ! ====================================
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '              dtacof : Global domain of ORCA'
+      IF(lwp) WRITE(numout,*) '              ------------------------------'
+
+      ! ... Initialization : 
+      resto(:,:,:) = 0.e0
+
+      !                           !-----------------------------------------!
+      IF( nn_hdmp > 0 ) THEN      !  Damping poleward of 'nn_hdmp' degrees  !
+         !                        !-----------------------------------------!
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '              Damping poleward of ', nn_hdmp,' deg.'
+         !
+         CALL iom_open ( 'dist.coast.nc', icot, ldstop = .FALSE. )
+         !
+         IF( icot > 0 ) THEN          ! distance-to-coast read in file
+            CALL iom_get  ( icot, jpdom_data, 'Tcoast', zdct )
+            CALL iom_close( icot )
+         ELSE                         ! distance-to-coast computed and saved in file (output in zdct)
+            CALL cofdis( zdct )
+         ENDIF
+
+         !                            ! Compute arrays resto 
+         zinfl = 1000.e3                   ! distance of influence for damping term
+         zlat0 = 10.                       ! latitude strip where resto decreases
+         zlat1 = REAL( nn_hdmp )           ! resto = 0 between -zlat1 and zlat1
+         zlat2 = zlat1 + zlat0             ! resto increases from 0 to 1 between |zlat1| and |zlat2|
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zlat = ABS( gphit(ji,jj) )
+               IF ( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
+                  resto(ji,jj,1) = 0.5 * ( 1. - cos(rpi*(zlat-zlat1)/zlat0 ) )
+               ELSEIF ( zlat > zlat2 ) THEN
+                  resto(ji,jj,1) = 1.
+               ENDIF
+            END DO
+         END DO
+
+         IF ( nn_hdmp == 20 ) THEN       ! North Indian ocean (20N/30N x 45E/100E) : resto=0
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zlat = gphit(ji,jj)
+                  zlon = MOD( glamt(ji,jj), 360. )
+                  IF ( zlat1 < zlat .AND. zlat < zlat2 .AND. 45. < zlon .AND. zlon < 100. ) THEN
+                     resto(ji,jj,1) = 0.e0
+                  ENDIF
+               END DO
+            END DO
+         ENDIF
+
+         zsdmp = 1./(rn_surf * rday)
+         zbdmp = 1./(rn_bot  * rday)
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zdct(ji,jj,jk) = MIN( zinfl, zdct(ji,jj,jk) )
+                  !   ... Decrease the value in the vicinity of the coast
+                  resto(ji,jj,jk) = resto(ji,jj,1) * 0.5 * ( 1. - COS( rpi*zdct(ji,jj,jk)/zinfl) )
+                  !   ... Vertical variation from zsdmp (sea surface) to zbdmp (bottom)
+                  resto(ji,jj,jk) = resto(ji,jj,jk)      * ( zbdmp + (zsdmp-zbdmp)*EXP(-fsdept(ji,jj,jk)/rn_dep) )
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+
+
+      IF( cp_cfg == "orca" .AND. ( nn_hdmp > 0 .OR. nn_hdmp == -1 ) ) THEN
+
+         !                                         ! =========================
+         !                                         !  Med and Red Sea damping
+         !                                         ! =========================
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) '              ORCA configuration: Damping in Med and Red Seas'
+
+
+         zmrs(:,:) = 0.e0                             ! damping term on the Med or Red Sea
+
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration 
+            !                                        ! =======================
+            ! Mediterranean Sea
+            ij0 =  50   ;   ij1 =  56
+            ii0 =  81   ;   ii1 =  91   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 =  50   ;   ij1 =  55
+            ii0 =  75   ;   ii1 =  80   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 =  52   ;   ij1 =  53
+            ii0 =  70   ;   ii1 =  74   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
+            DO jk = 1, 17
+               zhfac (jk) = 0.5*( 1.- COS( rpi*(jk-1)/16. ) ) / rday
+            END DO
+            DO jk = 18, jpkm1
+               zhfac (jk) = 1./rday
+            END DO
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration 
+            !                                        ! =======================
+            ! Mediterranean Sea
+            ij0 =  96   ;   ij1 = 110
+            ii0 = 157   ;   ii1 = 181   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 = 100   ;   ij1 = 110
+            ii0 = 144   ;   ii1 = 156   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 = 100   ;   ij1 = 103
+            ii0 = 139   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Gibraltar Strait
+            ij0 = 101   ;   ij1 = 102
+            ii0 = 139   ;   ii1 = 141   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.e0
+            ii0 = 142   ;   ii1 = 142   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ii0 = 143   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40e0
+            ii0 = 144   ;   ii1 = 144   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75e0
+            ! Red Sea
+            ij0 =  87   ;   ij1 =  96
+            ii0 = 147   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Bab el Mandeb Strait
+            ij0 =  91   ;   ij1 =  91
+            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.80e0
+            ij0 =  90   ;   ij1 =  90
+            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40e0
+            ij0 =  89   ;   ij1 =  89
+            ii0 = 158   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ij0 =  88   ;   ij1 =  88
+            ii0 = 160   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.e0
+            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
+            DO jk = 1, 17
+               zhfac (jk) = 0.5*( 1.- COS( rpi*(jk-1)/16. ) ) / rday
+            END DO
+            DO jk = 18, jpkm1
+               zhfac (jk) = 1./rday
+            END DO
+            !                                        ! =======================
+         CASE ( 05 )                                 !  ORCA_R05 configuration
+            !                                        ! =======================
+            ! Mediterranean Sea
+            ii0 = 568   ;   ii1 = 574 
+            ij0 = 324   ;   ij1 = 333   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ii0 = 575   ;   ii1 = 658
+            ij0 = 314   ;   ij1 = 366   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Black Sea (remaining part
+            ii0 = 641   ;   ii1 = 651
+            ij0 = 367   ;   ij1 = 372   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Gibraltar Strait
+            ij0 = 324   ;   ij1 = 333
+            ii0 = 565   ;   ii1 = 565   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ii0 = 566   ;   ii1 = 566   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+            ii0 = 567   ;   ii1 = 567   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75
+            ! Red Sea
+            ii0 = 641   ;   ii1 = 665
+            ij0 = 270   ;   ij1 = 310   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Bab el Mandeb Strait
+            ii0 = 666   ;   ii1 = 675
+            ij0 = 270   ;   ij1 = 290   
+            DO ji = mi0(ii0), mi1(ii1)
+               zmrs( ji , mj0(ij0):mj1(ij1) ) = 0.1 * ABS( FLOAT(ji - mi1(ii1)) )
+            END DO 
+            zsdmp = 1./(rn_surf * rday)
+            zbdmp = 1./(rn_bot * rday)
+            DO jk = 1, jpk
+               zhfac (jk) = ( zbdmp + (zsdmp-zbdmp) * EXP(-fsdept(1,1,jk)/rn_dep) )
+            END DO
+            !                                       ! ========================
+         CASE ( 025 )                               !  ORCA_R025 configuration 
+            !                                       ! ========================
+            CALL ctl_stop( ' Not yet implemented in ORCA_R025' )
+            !
+         END SELECT
+
+         DO jk = 1, jpkm1
+            resto(:,:,jk) = zmrs(:,:) * zhfac(jk) + ( 1. - zmrs(:,:) ) * resto(:,:,jk)
+         END DO
+
+         ! Mask resto array and set to 0 first and last levels
+         resto(:,:, : ) = resto(:,:,:) * tmask(:,:,:)
+         resto(:,:, 1 ) = 0.e0
+         resto(:,:,jpk) = 0.e0
+         !                         !--------------------!
+      ELSE                         !     No damping     !
+         !                         !--------------------!
+         CALL ctl_stop( 'Choose a correct value of nn_hdmp or DO NOT defined key_tradmp' )
+      ENDIF
+
+      !                            !--------------------------------!
+      IF( nn_file == 1 ) THEN      !  save damping coef. in a file  !
+         !                         !--------------------------------!
+         IF(lwp) WRITE(numout,*) '              create damping.coeff.nc file'
+         CALL iom_open  ( 'damping.coeff', inum0, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_rstput( 0, 0, inum0, 'Resto', resto )
+         CALL iom_close ( inum0 )
+      ENDIF
+      !
+   END SUBROUTINE dtacof
+
+
+   SUBROUTINE cofdis( pdct )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE cofdis  ***
+      !!
+      !! ** Purpose :   Compute the distance between ocean T-points and the
+      !!      ocean model coastlines. Save the distance in a NetCDF file.
+      !!
+      !! ** Method  :   For each model level, the distance-to-coast is 
+      !!      computed as follows : 
+      !!       - The coastline is defined as the serie of U-,V-,F-points
+      !!      that are at the ocean-land bound.
+      !!       - For each ocean T-point, the distance-to-coast is then 
+      !!      computed as the smallest distance (on the sphere) between the 
+      !!      T-point and all the coastline points.
+      !!       - For land T-points, the distance-to-coast is set to zero.
+      !!      C A U T I O N : Computation not yet implemented in mpp case.
+      !!
+      !! ** Action  : - pdct, distance to the coastline (argument)
+      !!              - NetCDF file 'dist.coast.nc' 
+      !!----------------------------------------------------------------------
+      USE ioipsl      ! IOipsl librairy
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   pdct   ! distance to the coastline
+      !!
+      INTEGER ::   ji, jj, jk, jl      ! dummy loop indices
+      INTEGER ::   iju, ijt            ! temporary integers
+      INTEGER ::   icoast, itime
+      INTEGER ::   icot         ! logical unit for file distance to the coast
+      LOGICAL, DIMENSION(jpi,jpj) ::   llcotu, llcotv, llcotf   ! ???
+      CHARACTER (len=32) ::   clname
+      REAL(wp) ::   zdate0
+      REAL(wp), DIMENSION(jpi,jpj)   ::   zxt, zyt, zzt, zmask   ! cartesian coordinates for T-points
+      REAL(wp), DIMENSION(3*jpi*jpj) ::   zxc, zyc, zzc, zdis    ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization
+      ! -----------------
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cofdis : compute the distance to coastline'
+      IF(lwp) WRITE(numout,*) '~~~~~~'
+      IF(lwp) WRITE(numout,*)
+      IF( lk_mpp ) &
+           & CALL ctl_stop('         Computation not yet implemented with key_mpp_...', &
+           &               '         Rerun the code on another computer or ', &
+           &               '         create the "dist.coast.nc" file using IDL' )
+
+      pdct(:,:,:) = 0.e0
+      zxt(:,:) = cos( rad * gphit(:,:) ) * cos( rad * glamt(:,:) )
+      zyt(:,:) = cos( rad * gphit(:,:) ) * sin( rad * glamt(:,:) )
+      zzt(:,:) = sin( rad * gphit(:,:) )
+
+
+      ! 1. Loop on vertical levels
+      ! --------------------------
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! Define the coastline points (U, V and F)
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zmask(ji,jj) =  ( tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) &
+                   &           + tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk) )
+               llcotu(ji,jj) = ( tmask(ji,jj,  jk) + tmask(ji+1,jj  ,jk) == 1. ) 
+               llcotv(ji,jj) = ( tmask(ji,jj  ,jk) + tmask(ji  ,jj+1,jk) == 1. ) 
+               llcotf(ji,jj) = ( zmask(ji,jj) > 0. ) .AND. ( zmask(ji,jj) < 4. )
+            END DO
+         END DO
+
+         ! Lateral boundaries conditions
+         llcotu(:, 1 ) = umask(:,  2  ,jk) == 1
+         llcotu(:,jpj) = umask(:,jpjm1,jk) == 1
+         llcotv(:, 1 ) = vmask(:,  2  ,jk) == 1
+         llcotv(:,jpj) = vmask(:,jpjm1,jk) == 1
+         llcotf(:, 1 ) = fmask(:,  2  ,jk) == 1
+         llcotf(:,jpj) = fmask(:,jpjm1,jk) == 1
+
+         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN
+            llcotu( 1 ,:) = llcotu(jpim1,:)
+            llcotu(jpi,:) = llcotu(  2  ,:)
+            llcotv( 1 ,:) = llcotv(jpim1,:)
+            llcotv(jpi,:) = llcotv(  2  ,:)
+            llcotf( 1 ,:) = llcotf(jpim1,:)
+            llcotf(jpi,:) = llcotf(  2  ,:)
+         ELSE
+            llcotu( 1 ,:) = umask(  2  ,:,jk) == 1
+            llcotu(jpi,:) = umask(jpim1,:,jk) == 1
+            llcotv( 1 ,:) = vmask(  2  ,:,jk) == 1
+            llcotv(jpi,:) = vmask(jpim1,:,jk) == 1
+            llcotf( 1 ,:) = fmask(  2  ,:,jk) == 1
+            llcotf(jpi,:) = fmask(jpim1,:,jk) == 1
+         ENDIF
+         IF( nperio == 3 .OR. nperio == 4 ) THEN
+            DO ji = 1, jpim1
+               iju = jpi - ji + 1
+               llcotu(ji,jpj  ) = llcotu(iju,jpj-2)
+               llcotf(ji,jpjm1) = llcotf(iju,jpj-2)
+               llcotf(ji,jpj  ) = llcotf(iju,jpj-3)
+            END DO
+            DO ji = jpi/2, jpim1
+               iju = jpi - ji + 1
+               llcotu(ji,jpjm1) = llcotu(iju,jpjm1)
+            END DO
+            DO ji = 2, jpi
+               ijt = jpi - ji + 2
+               llcotv(ji,jpjm1) = llcotv(ijt,jpj-2)
+               llcotv(ji,jpj  ) = llcotv(ijt,jpj-3)
+            END DO
+         ENDIF
+         IF( nperio == 5 .OR. nperio == 6 ) THEN
+            DO ji = 1, jpim1
+               iju = jpi - ji
+               llcotu(ji,jpj  ) = llcotu(iju,jpjm1)
+               llcotf(ji,jpj  ) = llcotf(iju,jpj-2)
+            END DO
+            DO ji = jpi/2, jpim1
+               iju = jpi - ji
+               llcotf(ji,jpjm1) = llcotf(iju,jpjm1)
+            END DO
+            DO ji = 1, jpi
+               ijt = jpi - ji + 1
+               llcotv(ji,jpj  ) = llcotv(ijt,jpjm1)
+            END DO
+            DO ji = jpi/2+1, jpi
+               ijt = jpi - ji + 1
+               llcotv(ji,jpjm1) = llcotv(ijt,jpjm1)
+            END DO
+         ENDIF
+
+         ! Compute cartesian coordinates of coastline points
+         ! and the number of coastline points
+
+         icoast = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( llcotf(ji,jj) ) THEN
+                  icoast = icoast + 1
+                  zxc(icoast) = COS( rad*gphif(ji,jj) ) * COS( rad*glamf(ji,jj) )
+                  zyc(icoast) = COS( rad*gphif(ji,jj) ) * SIN( rad*glamf(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphif(ji,jj) )
+               ENDIF
+               IF( llcotu(ji,jj) ) THEN
+                  icoast = icoast+1
+                  zxc(icoast) = COS( rad*gphiu(ji,jj) ) * COS( rad*glamu(ji,jj) )
+                  zyc(icoast) = COS( rad*gphiu(ji,jj) ) * SIN( rad*glamu(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphiu(ji,jj) )
+               ENDIF
+               IF( llcotv(ji,jj) ) THEN
+                  icoast = icoast+1
+                  zxc(icoast) = COS( rad*gphiv(ji,jj) ) * COS( rad*glamv(ji,jj) )
+                  zyc(icoast) = COS( rad*gphiv(ji,jj) ) * SIN( rad*glamv(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphiv(ji,jj) )
+               ENDIF
+            END DO
+         END DO
+
+         ! Distance for the T-points
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) == 0. ) THEN
+                  pdct(ji,jj,jk) = 0.
+               ELSE
+                  DO jl = 1, icoast
+                     zdis(jl) = ( zxt(ji,jj) - zxc(jl) )**2   &
+                        &     + ( zyt(ji,jj) - zyc(jl) )**2   &
+                        &     + ( zzt(ji,jj) - zzc(jl) )**2
+                  END DO
+                  pdct(ji,jj,jk) = ra * SQRT( MINVAL( zdis(1:icoast) ) )
+               ENDIF
+            END DO
+         END DO
+         !                                                ! ===============
+      END DO                                              !   End of slab
+      !                                                   ! ===============
+
+
+      ! 2. Create the  distance to the coast file in NetCDF format
+      ! ----------------------------------------------------------    
+      clname = 'dist.coast'
+      itime = 0
+      CALL ymds2ju( 0     , 1      , 1     , 0.e0 , zdate0 )
+      CALL restini( 'NONE', jpi    , jpj   , glamt, gphit ,   &
+         &          jpk   , gdept_0, clname, itime, zdate0,   &
+         &          rdt   , icot                         )
+      CALL restput( icot, 'Tcoast', jpi, jpj, jpk, 0, pdct )
+      CALL restclo( icot )
+
+   END SUBROUTINE cofdis
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO internal damping
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_tradmp = .FALSE.    !: internal damping flag
+CONTAINS
+   SUBROUTINE tra_dmp( kt )        ! Empty routine
+      WRITE(*,*) 'tra_dmp: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_dmp
+#endif
+
+   !!======================================================================
+END MODULE tradmp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf.F90	(revision 1844)
@@ -0,0 +1,327 @@
+MODULE traldf
+   !!======================================================================
+   !!                       ***  MODULE  traldf  ***
+   !! Ocean Active tracers : lateral diffusive trends 
+   !!=====================================================================
+   !! History :  9.0  ! 05-11 (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_ldf     : update the tracer trend with the lateral diffusion
+   !!       ldf_ctl : initialization, namelist read, and parameters control
+   !!       ldf_ano : compute lateral diffusion for constant T-S profiles
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE ldfslp          ! ???
+   USE traldf_bilapg   ! lateral mixing            (tra_ldf_bilapg routine)
+   USE traldf_bilap    ! lateral mixing             (tra_ldf_bilap routine)
+   USE traldf_iso      ! lateral mixing               (tra_ldf_iso routine)
+   USE traldf_lap      ! lateral mixing               (tra_ldf_lap routine)
+   USE trdmod          ! ocean active tracers trends
+   USE trdmod_oce      ! ocean variables trends
+   USE prtctl          ! Print control
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_ldf    ! called by step.F90 
+
+   INTEGER, PUBLIC ::   nldf = 0   ! type of lateral diffusion used defined from ln_traldf_... namlist logicals)
+                                   ! (need to be public to be used in vertical diffusion routine)
+#if defined key_traldf_ano
+   REAL, DIMENSION(jpi,jpj,jpk) ::   t0_ldf, s0_ldf   ! lateral diffusion trends of T & S
+      !                                               ! for a constant vertical profile
+#endif
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_ldf( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_ldf  ***
+      !! 
+      !! ** Purpose :   compute the lateral ocean tracer physics.
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdt, ztrds   ! 3D temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL ldf_ctl          ! initialisation & control of options
+
+      IF( l_trdtra )   THEN                      ! temporary save of ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+      ENDIF
+
+      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
+      CASE ( 0 )   ;   CALL tra_ldf_lap   ( kt )      ! iso-level laplacian
+      CASE ( 1 )   ;   CALL tra_ldf_iso   ( kt )      ! rotated laplacian (except dk[ dk[.] ] part)
+      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt )      ! iso-level bilaplacian
+      CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt )      ! s-coord. horizontal bilaplacian
+         !
+      CASE ( -1 )                                     ! esopa: test all possibility with control print
+         CALL tra_ldf_lap    ( kt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf0 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+         CALL tra_ldf_iso    ( kt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf1 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+         CALL tra_ldf_bilap  ( kt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf2 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+         CALL tra_ldf_bilapg ( kt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf3 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      END SELECT
+
+#if defined key_traldf_ano
+      ta(:,:,:) = ta(:,:,:) - t0_ldf(:,:,:)      ! anomaly: substract the reference diffusivity
+      sa(:,:,:) = sa(:,:,:) - s0_ldf(:,:,:)
+#endif
+      IF( l_trdtra )   THEN                      ! save the horizontal diffusive trends for further diagnostics
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_ldf, 'TRA', kt )
+      ENDIF
+      !                                          ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf  - Ta: ', mask1=tmask,               &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_ldf
+
+
+   SUBROUTINE ldf_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_ctl  ***
+      !! 
+      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
+      !!
+      !! ** Method  :   set nldf from the namtra_ldf logicals
+      !!      nldf == -1   ESOPA test: ALL operators are used
+      !!      nldf ==  0   laplacian operator
+      !!      nldf ==  1   Rotated laplacian operator
+      !!      nldf ==  2   bilaplacian operator
+      !!      nldf ==  3   Rotated bilaplacian
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio, ierr         ! temporary integers 
+!      
+!     NAMELIST/namtra_ldf/ ln_traldf_lap  , ln_traldf_bilap,                  &
+!        &                 ln_traldf_level, ln_traldf_hor  , ln_traldf_iso,   &
+!        &                 rn_aht_0       , rn_ahtb_0      , rn_aeiv_0
+      !!----------------------------------------------------------------------
+
+      !  Define the lateral mixing oparator for tracers
+      ! ===============================================
+    
+!     REWIND( numnam )                ! Namelist namtra_ldf already read in ldftra module
+!     READ  ( numnam, namtra_ldf )    
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra:ldf_ctl : lateral tracer diffusive operator'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtra_ldf : set lateral mixing parameters (type, direction, coefficients)'
+         WRITE(numout,*) '      laplacian operator          ln_traldf_lap   = ', ln_traldf_lap
+         WRITE(numout,*) '      bilaplacian operator        ln_traldf_bilap = ', ln_traldf_bilap
+         WRITE(numout,*) '      iso-level                   ln_traldf_level = ', ln_traldf_level
+         WRITE(numout,*) '      horizontal (geopotential)   ln_traldf_hor   = ', ln_traldf_hor
+         WRITE(numout,*) '      iso-neutral                 ln_traldf_iso   = ', ln_traldf_iso
+      ENDIF
+
+      !                               ! control the input
+      ioptio = 0
+      IF( ln_traldf_lap   )   ioptio = ioptio + 1
+      IF( ln_traldf_bilap )   ioptio = ioptio + 1
+      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
+      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
+      ioptio = 0
+      IF( ln_traldf_level )   ioptio = ioptio + 1
+      IF( ln_traldf_hor   )   ioptio = ioptio + 1
+      IF( ln_traldf_iso   )   ioptio = ioptio + 1
+      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
+
+      ! defined the type of lateral diffusion from ln_traldf_... logicals
+      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
+      ierr = 0
+      IF( ln_traldf_lap ) THEN       ! laplacian operator
+         IF ( ln_zco ) THEN                ! z-coordinate
+            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
+            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
+            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate
+            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
+            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
+            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! z-coordinate
+            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
+            IF ( ln_traldf_hor   )   nldf = 1      ! horizontal (   rotation)
+            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         ENDIF
+      ENDIF
+
+      IF( ln_traldf_bilap ) THEN      ! bilaplacian operator
+         IF ( ln_zco ) THEN                ! z-coordinate
+            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
+            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
+            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate
+            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed 
+            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
+            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! z-coordinate
+            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
+            IF ( ln_traldf_hor   )   nldf = 3      ! horizontal (   rotation)
+            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
+         ENDIF
+      ENDIF
+
+      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
+      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
+      IF( lk_traldf_eiv .AND. .NOT.ln_traldf_iso )   &
+           CALL ctl_stop( '          eddy induced velocity on tracers',   &
+           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
+      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
+         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
+         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
+      ENDIF
+
+      IF( lk_esopa ) THEN
+         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
+         nldf = -1
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
+         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
+         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
+         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
+         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
+         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
+      ENDIF
+
+      ! Reference T & S diffusivity (if necessary)
+      ! ===========================
+      CALL ldf_ano
+      !
+   END SUBROUTINE ldf_ctl
+
+#if defined key_traldf_ano
+   !!----------------------------------------------------------------------
+   !!   'key_traldf_ano'               T & S lateral diffusion on anomalies
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ldf_ano
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_ano  ***
+      !!
+      !! ** Purpose :   initializations of 
+      !!----------------------------------------------------------------------
+      USE zdf_oce         ! vertical mixing
+      USE trazdf          ! vertical mixing: double diffusion
+      USE zdfddm          ! vertical mixing: double diffusion
+      !!
+      INTEGER  ::   jk              ! Dummy loop indice
+      LOGICAL  ::   llsave          !
+      REAL(wp) ::   zt0, zs0, z12   ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zt_ref, ztb, zavt   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zs_ref, zsb         ! 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on anomalies'
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      ! defined the T & S reference profiles
+      ! ------------------------------------
+      zt0 =10.e0                               ! homogeneous ocean
+      zs0 =35.e0
+      zt_ref(:,:,:) = 10.0 * tmask(:,:,:)
+      zs_ref(:,:,:) = 35.0 * tmask(:,:,:)
+      IF(lwp) WRITE(numout,*) '              homogeneous ocean T = ', zt0, ' S = ',zs0
+
+      !                                        ! T & S profile (to be coded +namelist parameter
+
+      ! prepare the ldf computation
+      ! ---------------------------
+      llsave = l_trdtra
+      l_trdtra = .false.      ! desactivate trend computation
+      t0_ldf(:,:,:) = 0.e0
+      s0_ldf(:,:,:) = 0.e0
+      ztb   (:,:,:) = tb (:,:,:)
+      zsb   (:,:,:) = sb (:,:,:)
+      ua    (:,:,:) = ta (:,:,:)
+      va    (:,:,:) = sa (:,:,:)
+      zavt  (:,:,:) = avt(:,:,:)
+      IF( lk_zdfddm ) THEN CALL ctl_stop( ' key_traldf_ano with key_zdfddm not implemented' )
+      ! set tb, sb to reference values and avr to zero
+      tb (:,:,:) = zt_ref(:,:,:)
+      sb (:,:,:) = zs_ref(:,:,:)
+      ta (:,:,:) = 0.e0
+      sa (:,:,:) = 0.e0
+      avt(:,:,:) = 0.e0
+
+      ! Compute the ldf trends
+      ! ----------------------
+      CALL tra_ldf( nit000+1 )      ! horizontal components (+1: no more init)
+      CALL tra_zdf( nit000   )      ! vertical component (if necessary nit000 to performed the init)
+
+      ! finalise the computation and recover all arrays
+      ! -----------------------------------------------
+      l_trdtra = llsave
+      z12 = 2.e0
+      IF( neuler == 1)   z12 = 1.e0
+      IF( ln_zdfexp ) THEN      ! ta,sa are the trends
+         t0_ldf(:,:,:) = ta(:,:,:)
+         s0_ldf(:,:,:) = sa(:,:,:)
+      ELSE
+         DO jk = 1, jpkm1
+            t0_ldf(:,:,jk) = ( ta(:,:,jk) - tb(:,:,jk) ) / ( z12 *rdttra(jk) )
+            s0_ldf(:,:,jk) = ( sa(:,:,jk) - tb(:,:,jk) ) / ( z12 *rdttra(jk) )
+         END DO
+      ENDIF
+      tb    (:,:,:) = ztb (:,:,:)
+      sb    (:,:,:) = zsb (:,:,:)
+      ta    (:,:,:) = ua  (:,:,:)
+      sa    (:,:,:) = va  (:,:,:)
+      avt   (:,:,:) = zavt(:,:,:)
+      !
+   END SUBROUTINE ldf_ano
+
+#else
+   !!----------------------------------------------------------------------
+   !!   default option :   Dummy code   NO T & S background profiles
+   !!----------------------------------------------------------------------
+   SUBROUTINE ldf_ano
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on the full fields'
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+   END SUBROUTINE ldf_ano
+#endif
+
+   !!======================================================================
+END MODULE traldf
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 1844)
@@ -0,0 +1,227 @@
+MODULE traldf_bilap
+   !!==============================================================================
+   !!                   ***  MODULE  traldf_bilap  ***
+   !! Ocean active tracers:  horizontal component of the lateral tracer mixing trend
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_bilap : update the tracer trend with the horizontal diffusion
+   !!                   using a iso-level biharmonic operator
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE ldfslp          ! iso-neutral slopes 
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_ldf_bilap   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "ldfeiv_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE tra_ldf_bilap( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_ldf_bilap  ***
+      !!
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   4th order diffusive operator along model level surfaces 
+      !!      evaluated using before fields (forward time scheme). The hor.
+      !!      diffusive trends of temperature (idem for salinity) is given by:
+      !!      Laplacian of tb:
+      !!         zlt   = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(tb) ]
+      !!                                  + dj-1[ e1v*e3v/e2v dj(tb) ]  }
+      !!      Multiply by the eddy diffusivity coef. and insure lateral bc:
+      !!        zlt   = ahtt * zlt
+      !!        call to lbc_lnk
+      !!      Bilaplacian (laplacian of zlt):
+      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(zlt) ]
+      !!                                  + dj-1[ e1v*e3v/e2v dj(zlt) ]  }
+      !!      Note: if key_zco defined, e3t=e3u=e3v, they are simplified.
+      !!
+      !!      Add this trend to the general trend (ta,sa):
+      !!         (ta,sa) = (ta,sa) + ( difft , diffs )
+      !!
+      !! ** Action : - Update (ta,sa) arrays with the before iso-level
+      !!               biharmonic mixing trend.
+      !!
+      !! History :
+      !!        !  91-11  (G. Madec)  Original code
+      !!        !  93-03  (M. Guyon)  symetrical conditions
+      !!        !  95-11  (G. Madec)  suppress volumetric scale factors
+      !!        !  96-01  (G. Madec)  statement function for e3
+      !!        !  96-01  (M. Imbard)  mpp exchange
+      !!        !  97-07  (G. Madec)  optimization, and ahtt
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!        !  05-11  (G. Madec)  zps or sco as default option
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce           , ztu => ua,  &  ! use ua as workspace
+         &                ztv => va      ! use va as workspace
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk             ! dummy loop indices
+      INTEGER ::   iku, ikv               ! temporary integers
+      REAL(wp) ::   zta, zsa              ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   & 
+         zeeu, zeev, zbtr,              & ! 2D workspace
+         zlt, zls
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   & 
+         zsu, zsv                         ! 3D workspace 
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_ldf_bilap : iso-level biharmonic operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
+      ENDIF
+
+
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+
+         ! 0. Initialization of metric arrays (for z- or s-coordinates)
+         ! ----------------------------------
+
+         IF( lk_zco ) THEN      ! z-coordinate (1D arrays): no vertical scale factors
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zbtr(ji,jj) = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+                  zeeu(ji,jj) = e2u(ji,jj) / e1u(ji,jj) * umask(ji,jj,jk)
+                  zeev(ji,jj) = e1v(ji,jj) / e2v(ji,jj) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         ELSE                   ! All coordinates (3D arrays): vertical scale factor are used
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zbtr(ji,jj) = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  zeeu(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj) * umask(ji,jj,jk)
+                  zeev(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+
+         ! 1. Laplacian
+         ! ------------
+
+         ! First derivative (gradient)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ztu(ji,jj,jk) = zeeu(ji,jj) * ( tb(ji+1,jj  ,jk) - tb(ji,jj,jk) )
+               zsu(ji,jj,jk) = zeeu(ji,jj) * ( sb(ji+1,jj  ,jk) - sb(ji,jj,jk) )
+               ztv(ji,jj,jk) = zeev(ji,jj) * ( tb(ji  ,jj+1,jk) - tb(ji,jj,jk) )
+               zsv(ji,jj,jk) = zeev(ji,jj) * ( sb(ji  ,jj+1,jk) - sb(ji,jj,jk) )
+            END DO
+         END DO
+         IF( ln_zps ) THEN      ! set gradient at partial step level
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  ! last level
+                  iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+                  ikv = MIN ( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+                  IF( iku == jk ) THEN
+                     ztu(ji,jj,jk) = zeeu(ji,jj) * gtu(ji,jj)
+                     zsu(ji,jj,jk) = zeeu(ji,jj) * gsu(ji,jj)
+                  ENDIF
+                  IF( ikv == jk ) THEN
+                     ztv(ji,jj,jk) = zeev(ji,jj) * gtv(ji,jj)
+                     zsv(ji,jj,jk) = zeev(ji,jj) * gsv(ji,jj)
+                  ENDIF
+               END DO
+            END DO
+         ENDIF
+
+         ! Second derivative (divergence)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zlt(ji,jj) = zbtr(ji,jj) * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               zls(ji,jj) = zbtr(ji,jj) * (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk) + zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  )
+            END DO
+         END DO
+
+         ! Multiply by the eddy diffusivity coefficient
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zlt(ji,jj) = fsahtt(ji,jj,jk) * zlt(ji,jj)
+               zls(ji,jj) = fsahtt(ji,jj,jk) * zls(ji,jj)
+            END DO
+         END DO
+
+         ! Lateral boundary conditions on the laplacian (zlt,zls)   (unchanged sgn)
+         CALL lbc_lnk( zlt, 'T', 1. )   ;    CALL lbc_lnk( zls, 'T', 1. )
+
+         ! 2. Bilaplacian
+         ! --------------
+
+         ! third derivative (gradient)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ztu(ji,jj,jk) = zeeu(ji,jj) * ( zlt(ji+1,jj  ) - zlt(ji,jj) )
+               zsu(ji,jj,jk) = zeeu(ji,jj) * ( zls(ji+1,jj  ) - zls(ji,jj) )
+               ztv(ji,jj,jk) = zeev(ji,jj) * ( zlt(ji  ,jj+1) - zlt(ji,jj) )
+               zsv(ji,jj,jk) = zeev(ji,jj) * ( zls(ji  ,jj+1) - zls(ji,jj) )
+            END DO
+         END DO
+
+         ! fourth derivative (divergence) and add to the general tracer trend
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! horizontal diffusive trends
+               zta = zbtr(ji,jj) * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               zsa = zbtr(ji,jj) * (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk) + zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           ! Horizontal slab
+      !                                                ! ===============
+
+      ! "zonal" mean lateral diffusive heat and salt transport
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN      ! z-coordinate (1D arrays): multiply by the vertical scale factor
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ztv(ji,jj,jk) = ztv(ji,jj,jk) * fse3v(ji,jj,jk)
+                     zsv(ji,jj,jk) = zsv(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         pht_ldf(:) = ptr_vj( ztv(:,:,:) )
+         pst_ldf(:) = ptr_vj( zsv(:,:,:) )
+      ENDIF
+
+   END SUBROUTINE tra_ldf_bilap
+
+   !!==============================================================================
+END MODULE traldf_bilap
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilapg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 1844)
@@ -0,0 +1,401 @@
+MODULE traldf_bilapg
+   !!==============================================================================
+   !!                       ***  MODULE  traldf_bilapg  ***
+   !! Ocean active tracers:  horizontal component of the lateral tracer mixing trend
+   !!==============================================================================
+#if defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_bilapg : update the tracer trend with the horizontal diffusion
+   !!                    using an horizontal biharmonic operator in s-coordinate 
+   !!   ldfght         :  ???
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE ldfslp          ! iso-neutral slopes available
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE diaptr          ! poleward transport diagnostics 
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_ldf_bilapg    ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "ldfeiv_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE tra_ldf_bilapg( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tra_ldf_bilapg  ***
+      !!                    
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The lateral diffusive trends is provided by a 4th order
+      !!      operator rotated along geopotential surfaces. It is computed
+      !!      using before fields (forward in time) and geopotential slopes
+      !!      computed in routine inildf.
+      !!         -1- compute the geopotential harmonic operator applied to
+      !!      (tb,sb) and multiply it by the eddy diffusivity coefficient
+      !!      (done by a call to ldfght routine, result in (wk1,wk2) arrays).
+      !!      Applied the domain lateral boundary conditions by call to lbc_lnk
+      !!         -2- compute the geopotential harmonic operator applied to
+      !!      (wk1,wk2) by a second call to ldfght routine (result in (wk3,wk4)
+      !!      arrays).
+      !!         -3- Add this trend to the general trend (ta,sa):
+      !!            (ta,sa) = (ta,sa) + (wk3,wk4)
+      !!
+      !! ** Action : - Update (ta,sa) arrays with the before geopotential 
+      !!               biharmonic mixing trend.
+      !!
+      !! History :
+      !!   8.0  !  97-07  (G. Madec)  Original code
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce           , wk1 => ua,  &  ! use ua as workspace
+         &                wk2 => va      ! use va as workspace
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         wk3, wk4                ! work array used for rotated biharmonic
+         !                       ! operator on tracers and/or momentum
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_ldf_bilapg : horizontal biharmonic operator in s-coordinate'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
+      ENDIF
+
+      ! 1. Laplacian of (tb,sb) * aht
+      ! ----------------------------- 
+      ! rotated harmonic operator applied to (tb,sb)
+      ! and multiply by aht (output in (wk1,wk2) )
+
+      CALL ldfght ( kt, tb, sb, wk1, wk2, 1 )
+
+
+      ! Lateral boundary conditions on (wk1,wk2)   (unchanged sign)
+      CALL lbc_lnk( wk1, 'T', 1. )   ;   CALL lbc_lnk( wk2, 'T', 1. )
+
+      ! 2. Bilaplacian of (tb,sb)
+      ! -------------------------
+      ! rotated harmonic operator applied to (wk1,wk2)
+      ! (output in (wk3,wk4) )
+
+      CALL ldfght ( kt, wk1, wk2, wk3, wk4, 2 )
+
+
+      ! 3. Update the tracer trends                    (j-slab :   2, jpj-1)
+      ! ---------------------------
+      !                                                ! ===============
+      DO jj = 2, jpjm1                                 !  Vertical slab
+         !                                             ! ===============
+         DO jk = 1, jpkm1
+            DO ji = 2, jpim1
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + wk3(ji,jj,jk)
+               sa(ji,jj,jk) = sa(ji,jj,jk) + wk4(ji,jj,jk)
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+   END SUBROUTINE tra_ldf_bilapg
+
+
+   SUBROUTINE ldfght ( kt, pt, ps, plt, pls, kaht )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldfght  ***
+      !!          
+      !! ** Purpose :   Apply a geopotential harmonic operator to (pt,ps) and 
+      !!      multiply it by the eddy diffusivity coefficient (if kaht=1).
+      !!      Routine only used in s-coordinates (l_sco=T) with bilaplacian
+      !!      operator (ln_traldf_bilap=T) acting along geopotential surfaces
+      !!      (ln_traldf_hor).
+      !!
+      !! ** Method  :   The harmonic operator rotated along geopotential 
+      !!      surfaces is applied to (pt,ps) using the slopes of geopotential
+      !!      surfaces computed in inildf routine. The result is provided in
+      !!      (plt,pls) arrays. It is computed in 2 steps:
+      !!
+      !!      First step: horizontal part of the operator. It is computed on
+      !!      ==========  pt as follows (idem on ps)
+      !!      horizontal fluxes :
+      !!         zftu = e2u*e3u/e1u di[ pt ] - e2u*uslp dk[ mi(mk(pt)) ]
+      !!         zftv = e1v*e3v/e2v dj[ pt ] - e1v*vslp dk[ mj(mk(pt)) ]
+      !!      take the horizontal divergence of the fluxes (no divided by
+      !!      the volume element :
+      !!         plt  = di-1[ zftu ] +  dj-1[ zftv ]
+      !!
+      !!      Second step: vertical part of the operator. It is computed on
+      !!      ===========  pt as follows (idem on ps)
+      !!      vertical fluxes :
+      !!         zftw = e1t*e2t/e3w * (wslpi^2+wslpj^2)  dk-1[ pt ]
+      !!              -     e2t     *       wslpi        di[ mi(mk(pt)) ]
+      !!              -     e1t     *       wslpj        dj[ mj(mk(pt)) ]
+      !!      take the vertical divergence of the fluxes add it to the hori-
+      !!      zontal component, divide the result by the volume element and
+      !!      if kaht=1, multiply by the eddy diffusivity coefficient:
+      !!         plt  = aht / (e1t*e2t*e3t) { plt + dk[ zftw ] }
+      !!      else:
+      !!         plt  =  1  / (e1t*e2t*e3t) { plt + dk[ zftw ] }
+      !!
+      !! * Action :
+      !!      'key_trdtra' defined: the trend is saved for diagnostics.
+      !!
+      !! History :
+      !!   8.0  !  97-07  (G. Madec)  Original code
+      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in  ) ::   &
+         pt, ps           ! tracer fields (before t and s for 1st call
+      !                   ! and laplacian of these fields for 2nd call.
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   &
+         plt, pls         ! partial harmonic operator applied to
+      !                   ! pt & ps components except
+      !                   ! second order vertical derivative term)
+      INTEGER, INTENT( in ) ::   &
+         kaht             ! =1 multiply the laplacian by the eddy diffusivity coeff.
+      !                   ! =2 no multiplication
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk             ! dummy loop indices
+      REAL(wp) ::   &
+         zabe1, zabe2, zmku, zmkv,     &  ! temporary scalars
+         zbtr, ztah, zsah, ztav, zsav, &
+         zcof0, zcof1, zcof2,          &
+         zcof3, zcof4
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zftu, zfsu,                   &  ! workspace
+         zdkt, zdk1t,                  &
+         zdks, zdk1s
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zftv, zfsv                       ! workspace (only v components for ptr)
+      REAL(wp), DIMENSION(jpi,jpk) ::  &
+         zftw, zfsw,                   &  ! workspace
+         zdit, zdjt, zdj1t,            &
+         zdis, zdjs, zdj1s
+      !!----------------------------------------------------------------------
+
+      !                               ! ********** !   ! ===============
+      DO jk = 1, jpkm1                ! First step !   ! Horizontal slab
+         !                            ! ********** !   ! ===============
+
+         ! I.1 Vertical gradient of pt and ps at level jk and jk+1
+         ! -------------------------------------------------------
+         !     surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
+
+         zdk1t(:,:) = ( pt(:,:,jk) - pt(:,:,jk+1) ) * tmask(:,:,jk+1)
+         zdk1s(:,:) = ( ps(:,:,jk) - ps(:,:,jk+1) ) * tmask(:,:,jk+1)
+
+         IF( jk == 1 ) THEN
+            zdkt(:,:) = zdk1t(:,:)
+            zdks(:,:) = zdk1s(:,:)
+         ELSE
+            zdkt(:,:) = ( pt(:,:,jk-1) - pt(:,:,jk) ) * tmask(:,:,jk)
+            zdks(:,:) = ( ps(:,:,jk-1) - ps(:,:,jk) ) * tmask(:,:,jk)
+         ENDIF
+
+
+         ! I.2 Horizontal fluxes
+         ! ---------------------
+
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zabe1 = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj)
+               zabe2 = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj)
+
+               zmku=1./MAX( tmask(ji+1,jj,jk  )+tmask(ji,jj,jk+1)   &
+                           +tmask(ji+1,jj,jk+1)+tmask(ji,jj,jk  ),1. )
+               zmkv=1./MAX( tmask(ji,jj+1,jk  )+tmask(ji,jj,jk+1)   &
+                           +tmask(ji,jj+1,jk+1)+tmask(ji,jj,jk  ),1. )
+
+               zcof1= -e2u(ji,jj) * uslp(ji,jj,jk) * zmku
+               zcof2= -e1v(ji,jj) * vslp(ji,jj,jk) * zmkv
+
+               zftu(ji,jj)= umask(ji,jj,jk) *   &
+                  (  zabe1 *( pt(ji+1,jj,jk) - pt(ji,jj,jk) )   &
+                   + zcof1 *( zdkt (ji+1,jj) + zdk1t(ji,jj)     &
+                             +zdk1t(ji+1,jj) + zdkt (ji,jj) )  )
+
+               zftv(ji,jj,jk)= vmask(ji,jj,jk) *   &
+                  (  zabe2 *( pt(ji,jj+1,jk) - pt(ji,jj,jk) )   &
+                   + zcof2 *( zdkt (ji,jj+1) + zdk1t(ji,jj)     &
+                             +zdk1t(ji,jj+1) + zdkt (ji,jj) )  )
+
+               zfsu(ji,jj)= umask(ji,jj,jk) *   &
+                  (  zabe1 *( ps(ji+1,jj,jk) - ps(ji,jj,jk) )   &
+                   + zcof1 *( zdks (ji+1,jj) + zdk1s(ji,jj)     &
+                             +zdk1s(ji+1,jj) + zdks (ji,jj) )  )
+
+               zfsv(ji,jj,jk)= vmask(ji,jj,jk) *   &
+                  (  zabe2 *( ps(ji,jj+1,jk) - ps(ji,jj,jk) )   &
+                   + zcof2 *( zdks (ji,jj+1) + zdk1s(ji,jj)     &
+                             +zdk1s(ji,jj+1) + zdks (ji,jj) )  )
+            END DO
+         END DO
+
+
+         ! I.3 Second derivative (divergence) (not divided by the volume)
+         ! ---------------------
+
+         DO jj = 2 , jpjm1
+            DO ji = 2 , jpim1
+               ztah = zftu(ji,jj) - zftu(ji-1,jj) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)
+               zsah = zfsu(ji,jj) - zfsu(ji-1,jj) + zfsv(ji,jj,jk) - zfsv(ji,jj-1,jk)
+               plt(ji,jj,jk) = ztah
+               pls(ji,jj,jk) = zsah
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+ 
+      !!but this should be done somewhere after 
+      ! "zonal" mean diffusive heat and salt transport
+      IF( ln_diaptr .AND. ( kaht == 2 ) .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         pht_ldf(:) = ptr_vj( zftv(:,:,:) )
+         pst_ldf(:) = ptr_vj( zfsv(:,:,:) )
+      ENDIF
+
+      !                             ! ************ !   ! ===============
+      DO jj = 2, jpjm1              !  Second step !   ! Horizontal slab
+         !                          ! ************ !   ! ===============
+
+         ! II.1 horizontal tracer gradient
+         ! -------------------------------
+
+         DO jk = 1, jpk
+            DO ji = 1, jpim1
+               zdit (ji,jk) = ( pt(ji+1,jj  ,jk) - pt(ji,jj  ,jk) ) * umask(ji,jj  ,jk)
+               zdis (ji,jk) = ( ps(ji+1,jj  ,jk) - ps(ji,jj  ,jk) ) * umask(ji,jj  ,jk)
+               zdjt (ji,jk) = ( pt(ji  ,jj+1,jk) - pt(ji,jj  ,jk) ) * vmask(ji,jj  ,jk)
+               zdjs (ji,jk) = ( ps(ji  ,jj+1,jk) - ps(ji,jj  ,jk) ) * vmask(ji,jj  ,jk)
+               zdj1t(ji,jk) = ( pt(ji  ,jj  ,jk) - pt(ji,jj-1,jk) ) * vmask(ji,jj-1,jk)
+               zdj1s(ji,jk) = ( ps(ji  ,jj  ,jk) - ps(ji,jj-1,jk) ) * vmask(ji,jj-1,jk)
+            END DO
+         END DO
+
+
+         ! II.2 Vertical fluxes
+         ! --------------------
+
+         ! Surface and bottom vertical fluxes set to zero
+         zftw(:, 1 ) = 0.e0
+         zfsw(:, 1 ) = 0.e0
+         zftw(:,jpk) = 0.e0
+         zfsw(:,jpk) = 0.e0
+
+         ! interior (2=<jk=<jpk-1)
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               zcof0 = e1t(ji,jj) * e2t(ji,jj) / fse3w(ji,jj,jk)   &
+                     * (  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)        &
+                        + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
+
+               zmku =1./MAX(  umask(ji  ,jj,jk-1)+umask(ji-1,jj,jk)   &
+                             +umask(ji-1,jj,jk-1)+umask(ji  ,jj,jk), 1. )
+
+               zmkv =1./MAX(  vmask(ji,jj  ,jk-1)+vmask(ji,jj-1,jk)   &
+                             +vmask(ji,jj-1,jk-1)+vmask(ji,jj  ,jk), 1. )
+
+               zcof3 = - e2t(ji,jj) * wslpi (ji,jj,jk) * zmku
+               zcof4 = - e1t(ji,jj) * wslpj (ji,jj,jk) * zmkv
+
+               zftw(ji,jk) = tmask(ji,jj,jk) *   &
+                  (  zcof0 * ( pt  (ji,jj,jk-1) - pt  (ji,jj,jk) )   &
+                   + zcof3 * ( zdit (ji  ,jk-1) + zdit (ji-1,jk)     &
+                              +zdit (ji-1,jk-1) + zdit (ji  ,jk) )   &
+                   + zcof4 * ( zdjt (ji  ,jk-1) + zdj1t(ji  ,jk)     &
+                              +zdj1t(ji  ,jk-1) + zdjt (ji  ,jk) )  )
+
+               zfsw(ji,jk) = tmask(ji,jj,jk) *   &
+                  (  zcof0 * ( ps  (ji,jj,jk-1) - ps  (ji,jj,jk) )   &
+                   + zcof3 * ( zdis (ji  ,jk-1) + zdis (ji-1,jk)     &
+                              +zdis (ji-1,jk-1) + zdis (ji  ,jk) )   &
+                   + zcof4 * ( zdjs (ji  ,jk-1) + zdj1s(ji  ,jk)     &
+                              +zdj1s(ji  ,jk-1) + zdjs (ji  ,jk) )  )
+            END DO
+         END DO
+
+
+         ! II.3 Divergence of vertical fluxes added to the horizontal divergence
+         ! ---------------------------------------------------------------------
+
+         IF( kaht == 1 ) THEN
+            ! multiply the laplacian by the eddy diffusivity coefficient
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ! eddy coef. divided by the volume element
+                  zbtr = fsahtt(ji,jj,jk) / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ! vertical divergence
+                  ztav = zftw(ji,jk) - zftw(ji,jk+1)
+                  zsav = zfsw(ji,jk) - zfsw(ji,jk+1)
+                  ! harmonic operator applied to (pt,ps) and multiply by aht
+                  plt(ji,jj,jk) = ( plt(ji,jj,jk) + ztav ) * zbtr
+                  pls(ji,jj,jk) = ( pls(ji,jj,jk) + zsav ) * zbtr
+               END DO
+            END DO
+         ELSEIF( kaht == 2 ) THEN
+            ! second call, no multiplication
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ! inverse of the volume element
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ! vertical divergence
+                  ztav = zftw(ji,jk) - zftw(ji,jk+1)
+                  zsav = zfsw(ji,jk) - zfsw(ji,jk+1)
+                  ! harmonic operator applied to (pt,ps) 
+                  plt(ji,jj,jk) = ( plt(ji,jj,jk) + ztav ) * zbtr
+                  pls(ji,jj,jk) = ( pls(ji,jj,jk) + zsav ) * zbtr
+               END DO
+            END DO
+         ELSE
+            IF(lwp) WRITE(numout,*) ' ldfght: kaht= 1 or 2, here =', kaht
+            IF(lwp) WRITE(numout,*) '         We stop'
+            STOP 'ldfght'
+         ENDIF
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+   END SUBROUTINE ldfght
+
+#else  
+   !!----------------------------------------------------------------------
+   !!   Dummy module :             NO rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE tra_ldf_bilapg( kt )               ! Dummy routine
+      WRITE(*,*) 'tra_ldf_bilapg: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_ldf_bilapg
+#endif
+
+   !!==============================================================================
+END MODULE traldf_bilapg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_iso.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 1844)
@@ -0,0 +1,347 @@
+MODULE traldf_iso
+   !!======================================================================
+   !!                   ***  MODULE  traldf_iso  ***
+   !! Ocean active tracers:  horizontal component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :        !  94-08  (G. Madec, M. Imbard)
+   !!                  !  97-05  (G. Madec)  split into traldf and trazdf
+   !!             8.5  !  02-08  (G. Madec)  Free form, F90
+   !!             9.0  !  05-11  (G. Madec)  merge traldf and trazdf :-)
+   !!----------------------------------------------------------------------
+#if   defined key_ldfslp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'               slope of the lateral diffusive direction
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_iso  : update the tracer trend with the horizontal 
+   !!                  component of a iso-neutral laplacian operator
+   !!                  and with the vertical part of
+   !!                  the isopycnal or geopotential s-coord. operator 
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE iom             !
+   USE ldfslp          ! iso-neutral slopes
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+#if defined key_diaar5
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_ldf_iso   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_ldf_iso( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_ldf_iso  ***
+      !!
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend for a laplacian tensor (ezxcept the dz[ dz[.] ] term) and 
+      !!      add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The horizontal component of the lateral diffusive trends 
+      !!      is provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      1st part :  masked horizontal derivative of T & S ( di[ t ] )
+      !!      ========    with partial cell update if ln_zps=T.
+      !!
+      !!      2nd part :  horizontal fluxes of the lateral mixing operator
+      !!      ========    
+      !!         zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ]
+      !!               - aht       e2u*uslp    dk[ mi(mk(tb)) ]
+      !!         zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ]
+      !!               - aht       e2u*vslp    dk[ mj(mk(tb)) ]
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
+      !!      Add this trend to the general trend (ta,sa):
+      !!         ta = ta + difft
+      !!
+      !!      3rd part: vertical trends of the lateral mixing operator
+      !!      ========  (excluding the vertical flux proportional to dk[t] )
+      !!      vertical fluxes associated with the rotated lateral mixing:
+      !!         zftw =-aht {  e2t*wslpi di[ mi(mk(tb)) ]
+      !!                     + e1t*wslpj dj[ mj(mk(tb)) ]  }
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) dk[ zftw ]
+      !!      Add this trend to the general trend (ta,sa):
+      !!         ta = ta + difft
+      !!
+      !! ** Action :   Update (ta,sa) arrays with the before rotated diffusion
+      !!            trend (except the dk[ dk[.] ] term)
+      !!----------------------------------------------------------------------
+      USE oce           , zftv => ua   ! use ua as workspace
+      USE oce           , zfsv => va   ! use va as workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   iku, ikv     ! temporary integer
+      REAL(wp) ::   zmsku, zabe1, zcof1, zcoef3, zta   ! temporary scalars
+      REAL(wp) ::   zmskv, zabe2, zcof2, zcoef4, zsa   !    "         "
+      REAL(wp) ::   zcoef0, zbtr                       !    "         "
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdkt , zdk1t         ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdks , zdk1s, zfsu   !  "         "
+#if defined key_diaar5
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d                  !  "         "
+      REAL(wp)                         ::   zztmp                !  "         "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zftu                 ! 3D workspace
+#else
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zftu                 ! 2D workspace
+#endif
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdit, zdjt, ztfw     ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdis, zdjs, zsfw     !  "      "
+# if defined key_diaar5
+# endif  
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      !!----------------------------------------------------------------------
+      !!   I - masked horizontal derivative of T & S
+      !!----------------------------------------------------------------------
+!!bug ajout.... why?   ( 1,jpj,:) and (jpi,1,:) should be sufficient....
+      zdit (1,:,:) = 0.e0     ;     zdit (jpi,:,:) = 0.e0
+      zdis (1,:,:) = 0.e0     ;     zdis (jpi,:,:) = 0.e0
+      zdjt (1,:,:) = 0.e0     ;     zdjt (jpi,:,:) = 0.e0
+      zdjs (1,:,:) = 0.e0     ;     zdjs (jpi,:,:) = 0.e0
+!!end
+
+      ! Horizontal temperature and salinity gradient 
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zdit(ji,jj,jk) = ( tb(ji+1,jj  ,jk) - tb(ji,jj,jk) ) * umask(ji,jj,jk)
+               zdis(ji,jj,jk) = ( sb(ji+1,jj  ,jk) - sb(ji,jj,jk) ) * umask(ji,jj,jk)
+               zdjt(ji,jj,jk) = ( tb(ji  ,jj+1,jk) - tb(ji,jj,jk) ) * vmask(ji,jj,jk)
+               zdjs(ji,jj,jk) = ( sb(ji  ,jj+1,jk) - sb(ji,jj,jk) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      IF( ln_zps ) THEN      ! partial steps correction at the last level 
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               ! last level
+               iku = MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+               ikv = MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+               zdit(ji,jj,iku) = gtu(ji,jj) 
+               zdis(ji,jj,iku) = gsu(ji,jj)               
+               zdjt(ji,jj,ikv) = gtv(ji,jj) 
+               zdjs(ji,jj,ikv) = gsv(ji,jj)               
+            END DO
+         END DO
+      ENDIF
+
+      !!----------------------------------------------------------------------
+      !!   II - horizontal trend of T & S (full)
+      !!----------------------------------------------------------------------
+      
+#if defined key_diaar5
+!CDIR PARALLEL DO PRIVATE( zdk1t, zdk1s, zfsu ) 
+#else
+!CDIR PARALLEL DO PRIVATE( zdk1t, zdk1s, zftu, zfsu ) 
+#endif
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! 1. Vertical tracer gradient at level jk and jk+1
+         ! ------------------------------------------------
+         ! surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
+
+         zdk1t(:,:) = ( tb(:,:,jk) - tb(:,:,jk+1) ) * tmask(:,:,jk+1)
+         zdk1s(:,:) = ( sb(:,:,jk) - sb(:,:,jk+1) ) * tmask(:,:,jk+1)
+
+         IF( jk == 1 ) THEN
+            zdkt(:,:) = zdk1t(:,:)
+            zdks(:,:) = zdk1s(:,:)
+         ELSE
+            zdkt(:,:) = ( tb(:,:,jk-1) - tb(:,:,jk) ) * tmask(:,:,jk)
+            zdks(:,:) = ( sb(:,:,jk-1) - sb(:,:,jk) ) * tmask(:,:,jk)
+         ENDIF
+
+
+         ! 2. Horizontal fluxes
+         ! --------------------
+
+         DO jj = 1 , jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zabe1 = ( fsahtu(ji,jj,jk) + ahtb0 ) * e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj)
+               zabe2 = ( fsahtv(ji,jj,jk) + ahtb0 ) * e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj)
+
+               zmsku = 1. / MAX(  tmask(ji+1,jj,jk  ) + tmask(ji,jj,jk+1)   &
+                  &             + tmask(ji+1,jj,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+               zmskv = 1. / MAX(  tmask(ji,jj+1,jk  ) + tmask(ji,jj,jk+1)   &
+                  &             + tmask(ji,jj+1,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+               zcof1 = -fsahtu(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku
+               zcof2 = -fsahtv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv
+
+#if defined key_diaar5
+               zftu(ji,jj,jk) = (  zabe1 * zdit(ji,jj,jk)   &
+#else
+               zftu(ji,jj   ) = (  zabe1 * zdit(ji,jj,jk)   &
+#endif
+                  &              + zcof1 * (  zdkt (ji+1,jj) + zdk1t(ji,jj)      &
+                  &                         + zdk1t(ji+1,jj) + zdkt (ji,jj)  )  ) * umask(ji,jj,jk)
+               zftv(ji,jj,jk) = (  zabe2 * zdjt(ji,jj,jk)   &
+                  &              + zcof2 * (  zdkt (ji,jj+1) + zdk1t(ji,jj)      &
+                  &                         + zdk1t(ji,jj+1) + zdkt (ji,jj)  )  ) * vmask(ji,jj,jk)
+               zfsu(ji,jj   ) = (  zabe1 * zdis(ji,jj,jk)   &
+                  &              + zcof1 * (  zdks (ji+1,jj) + zdk1s(ji,jj)      &
+                  &                         + zdk1s(ji+1,jj) + zdks (ji,jj)  )  ) * umask(ji,jj,jk)
+               zfsv(ji,jj,jk) = (  zabe2 * zdjs(ji,jj,jk)   &
+                  &              + zcof2 * (  zdks (ji,jj+1) + zdk1s(ji,jj)      &
+                  &                         + zdk1s(ji,jj+1) + zdks (ji,jj)  )  ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+
+
+         ! II.4 Second derivative (divergence) and add to the general trend
+         ! ----------------------------------------------------------------
+         DO jj = 2 , jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr= 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+#if defined key_diaar5
+               zta = zbtr * ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)  )
+#else
+               zta = zbtr * ( zftu(ji,jj   ) - zftu(ji-1,jj   ) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)  )
+#endif
+               zsa = zbtr * ( zfsu(ji,jj   ) - zfsu(ji-1,jj   ) + zfsv(ji,jj,jk) - zfsv(ji,jj-1,jk)  )
+               ta (ji,jj,jk) = ta (ji,jj,jk) + zta
+               sa (ji,jj,jk) = sa (ji,jj,jk) + zsa
+            END DO
+         END DO
+         !                                          ! ===============
+      END DO                                        !   End of slab  
+      !                                             ! ===============
+
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN   ! Poleward diffusive heat and salt transports
+         pht_ldf(:) = ptr_vj( zftv(:,:,:) )
+         pst_ldf(:) = ptr_vj( zfsv(:,:,:) )
+      ENDIF
+#if defined key_diaar5
+      zztmp = 0.5 * rau0 * rcp 
+      z2d(:,:) = 0.e0 
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z2d(ji,jj) = z2d(ji,jj) + zztmp * zftu(ji,jj,jk) * ( tn(ji,jj,jk) + tn(ji+1,jj,jk) ) * e1u(ji,jj) * fse3u(ji,jj,jk) 
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( z2d, 'U', -1. )
+      CALL iom_put( "udiff_heattr", z2d )                  ! heat transport in i-direction
+      z2d(:,:) = 0.e0 
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z2d(ji,jj) = z2d(ji,jj) + zztmp * zftv(ji,jj,jk) * ( tn(ji,jj,jk) + tn(ji,jj+1,jk) ) * e2v(ji,jj) * fse3v(ji,jj,jk) 
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( z2d, 'V', -1. )
+      CALL iom_put( "vdiff_heattr", z2d )                  !  heat transport in i-direction
+#endif
+
+      !!----------------------------------------------------------------------
+      !!   III - vertical trend of T & S (extra diagonal terms only)
+      !!----------------------------------------------------------------------
+
+      ! Local constant initialization
+      ! -----------------------------
+      ztfw(1,:,:) = 0.e0     ;     ztfw(jpi,:,:) = 0.e0
+      zsfw(1,:,:) = 0.e0     ;     zsfw(jpi,:,:) = 0.e0
+
+
+      ! Vertical fluxes
+      ! ---------------
+
+      ! Surface and bottom vertical fluxes set to zero
+      ztfw(:,:, 1 ) = 0.e0      ;      ztfw(:,:,jpk) = 0.e0
+      zsfw(:,:, 1 ) = 0.e0      ;      zsfw(:,:,jpk) = 0.e0
+
+      ! interior (2=<jk=<jpk-1)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcoef0 = - fsahtw(ji,jj,jk) * tmask(ji,jj,jk)
+
+               zmsku = 1./MAX(   umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)      &
+                  &            + umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk), 1.  )
+
+               zmskv = 1./MAX(   vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)      &
+                  &            + vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk), 1.  )
+
+               zcoef3 = zcoef0 * e2t(ji,jj) * zmsku * wslpi (ji,jj,jk)
+               zcoef4 = zcoef0 * e1t(ji,jj) * zmskv * wslpj (ji,jj,jk)
+
+               ztfw(ji,jj,jk) = zcoef3 * (   zdit(ji  ,jj  ,jk-1) + zdit(ji-1,jj  ,jk)      &
+                  &                        + zdit(ji-1,jj  ,jk-1) + zdit(ji  ,jj  ,jk)  )   &
+                  &           + zcoef4 * (   zdjt(ji  ,jj  ,jk-1) + zdjt(ji  ,jj-1,jk)      &
+                  &                        + zdjt(ji  ,jj-1,jk-1) + zdjt(ji  ,jj  ,jk)  )
+
+               zsfw(ji,jj,jk) = zcoef3 * (   zdis(ji  ,jj  ,jk-1) + zdis(ji-1,jj  ,jk)      &
+                  &                        + zdis(ji-1,jj  ,jk-1) + zdis(ji  ,jj  ,jk)  )   &
+                  &           + zcoef4 * (   zdjs(ji  ,jj  ,jk-1) + zdjs(ji  ,jj-1,jk)      &
+                  &                        + zdjs(ji  ,jj-1,jk-1) + zdjs(ji  ,jj  ,jk)  )
+            END DO
+         END DO
+      END DO
+
+
+      ! I.5 Divergence of vertical fluxes added to the general tracer trend
+      ! -------------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbtr =  1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+               zta  = (  ztfw(ji,jj,jk) - ztfw(ji,jj,jk+1)  ) * zbtr
+               zsa  = (  zsfw(ji,jj,jk) - zsfw(ji,jj,jk+1)  ) * zbtr
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tra_ldf_iso
+
+#else
+   !!----------------------------------------------------------------------
+   !!   default option :   Dummy code   NO rotation of the diffusive tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE tra_ldf_iso( kt )               ! Empty routine
+      WRITE(*,*) 'tra_ldf_iso: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_ldf_iso
+#endif
+
+   !!==============================================================================
+END MODULE traldf_iso
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_lap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 1844)
@@ -0,0 +1,182 @@
+MODULE traldf_lap
+   !!==============================================================================
+   !!                       ***  MODULE  traldf_lap  ***
+   !! Ocean active tracers:  horizontal component of the lateral tracer mixing trend
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_lap  : update the tracer trend with the horizontal diffusion
+   !!                 using a iso-level harmonic (laplacien) operator.
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE diaptr          ! poleward transport diagnostics
+   USE prtctl          ! Print control
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_ldf_lap  ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE tra_ldf_lap( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_ldf_lap  ***
+      !!                   
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   Second order diffusive operator evaluated using before
+      !!      fields (forward time scheme). The horizontal diffusive trends of 
+      !!      temperature (idem for salinity) is given by:
+      !!          difft = 1/(e1t*e2t*e3t) {  di-1[ aht e2u*e3u/e1u di(tb) ]
+      !!                                   + dj-1[ aht e1v*e3v/e2v dj(tb) ] }
+      !!     Note: key_zco defined, the e3t=e3u=e3v, the trend becomes:  
+      !!          difft = 1/(e1t*e2t) {  di-1[ aht e2u/e1u di(tb) ]
+      !!                               + dj-1[ aht e1v/e2v dj(tb) ] }
+      !!      Add this trend to the general tracer trend (ta,sa):
+      !!          (ta,sa) = (ta,sa) + ( difft , diffs )
+      !!
+      !! ** Action  : - Update (ta,sa) arrays with the before iso-level 
+      !!                harmonic mixing trend.
+      !!
+      !! History :
+      !!   1.0  !  87-06  (P. Andrich, D. L Hostis)  Original code
+      !!        !  91-11  (G. Madec)
+      !!        !  95-11  (G. Madec)  suppress volumetric scale factors
+      !!        !  96-01  (G. Madec)  statement function for e3
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!   9.0  !  04-08  (C. Talandier) New trends organization
+      !!        !  05-11  (G. Madec)  add zps case
+      !!----------------------------------------------------------------------
+      USE oce              , ztu => ua,  &  ! use ua as workspace
+         &                   zsu => va      ! use va as workspace
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+      
+      !! * Local save
+      REAL(wp), DIMENSION(jpi,jpj), SAVE ::   &
+         ze1ur, ze2vr, zbtr2              ! scale factor coefficients
+      
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk             ! dummy loop indices
+      INTEGER ::   iku, ikv               ! temporary integers
+      REAL(wp) ::   &
+         zabe1, zta,                   &  ! temporary scalars
+         zabe2, zsa, zbtr                 !    "         "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         ztv, zsv                         ! 3D workspace
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_ldf_lap : iso-level laplacian diffusion'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+         ze1ur(:,:) = e2u(:,:) / e1u(:,:)
+         ze2vr(:,:) = e1v(:,:) / e2v(:,:)
+         zbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+      ENDIF
+      
+      !                                                  ! =============
+      DO jk = 1, jpkm1                                   ! Vertical slab
+         !                                               ! =============
+         ! 1. First derivative (gradient)
+         ! -------------------
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zabe1 = fsahtu(ji,jj,jk) * umask(ji,jj,jk) * ze1ur(ji,jj)
+               zabe2 = fsahtv(ji,jj,jk) * vmask(ji,jj,jk) * ze2vr(ji,jj)
+#else
+               zabe1 = fsahtu(ji,jj,jk) * umask(ji,jj,jk) * ze1ur(ji,jj) * fse3u(ji,jj,jk)
+               zabe2 = fsahtv(ji,jj,jk) * vmask(ji,jj,jk) * ze2vr(ji,jj) * fse3v(ji,jj,jk)
+#endif
+               ztu(ji,jj,jk) = zabe1 * ( tb(ji+1,jj  ,jk) - tb(ji,jj,jk) )
+               zsu(ji,jj,jk) = zabe1 * ( sb(ji+1,jj  ,jk) - sb(ji,jj,jk) )
+               ztv(ji,jj,jk) = zabe2 * ( tb(ji  ,jj+1,jk) - tb(ji,jj,jk) )
+               zsv(ji,jj,jk) = zabe2 * ( sb(ji  ,jj+1,jk) - sb(ji,jj,jk) )
+            END DO  
+         END DO  
+         IF( ln_zps ) THEN      ! set gradient at partial step level
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ! last level
+                  iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+                  ikv = MIN ( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+                  IF( iku == jk ) THEN
+                     zabe1 = fsahtu(ji,jj,iku) * umask(ji,jj,iku) * ze1ur(ji,jj) * fse3u(ji,jj,iku)
+                     ztu(ji,jj,jk) = zabe1 * gtu(ji,jj)
+                     zsu(ji,jj,jk) = zabe1 * gsu(ji,jj)
+                  ENDIF
+                  IF( ikv == jk ) THEN
+                     zabe2 = fsahtv(ji,jj,ikv) * vmask(ji,jj,ikv) * ze2vr(ji,jj) * fse3v(ji,jj,ikv)
+                     ztv(ji,jj,jk) = zabe2 * gtv(ji,jj)
+                     zsv(ji,jj,jk) = zabe2 * gsv(ji,jj)
+                  ENDIF
+               END DO
+            END DO
+         ENDIF
+         
+         
+         ! 2. Second derivative (divergence)
+         ! --------------------
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+#if defined key_zco
+               zbtr = zbtr2(ji,jj)
+#else
+               zbtr = zbtr2(ji,jj) / fse3t(ji,jj,jk)
+#endif
+               ! horizontal diffusive trends
+               zta = zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)   &
+                  &          + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               zsa = zbtr * (  zsu(ji,jj,jk) - zsu(ji-1,jj,jk)   &
+                  &          + zsv(ji,jj,jk) - zsv(ji,jj-1,jk)  )
+               ! add it to the general tracer trends
+               ta(ji,jj,jk) = ta(ji,jj,jk) + zta
+               sa(ji,jj,jk) = sa(ji,jj,jk) + zsa
+            END DO  
+         END DO  
+         !                                               ! =============
+      END DO                                             !  End of slab  
+      !                                                  ! =============
+
+      ! "zonal" mean lateral diffusive heat and salt transport 
+      IF( ln_diaptr .AND. ( MOD( kt, nf_ptr ) == 0 ) ) THEN
+         IF( lk_zco ) THEN   ! z-coordinate - full step (1D arrays)
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                    ztv(ji,jj,jk) = ztv(ji,jj,jk) * fse3v(ji,jj,jk)
+                    zsv(ji,jj,jk) = zsv(ji,jj,jk) * fse3v(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         pht_ldf(:) = ptr_vj( ztv(:,:,:) )
+         pst_ldf(:) = ptr_vj( zsv(:,:,:) )
+      ENDIF
+
+   END SUBROUTINE tra_ldf_lap
+
+   !!==============================================================================
+END MODULE traldf_lap
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranpc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranpc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranpc.F90	(revision 1844)
@@ -0,0 +1,216 @@
+MODULE tranpc
+   !!==============================================================================
+   !!                       ***  MODULE  tranpc  ***
+   !! Ocean active tracers:  non penetrative convection scheme
+   !!==============================================================================
+   !! History :  1.0  ! 1990-09  (G. Madec)  Original code
+   !!                 ! 1996-01  (G. Madec)  statement function for e3
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  free form F90
+   !!            3.0  ! 2008-06  (G. Madec)  applied on ta, sa and called before tranxt in step.F90
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_npc : apply the non penetrative convection scheme
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE zdf_oce         ! ocean vertical physics
+   USE trdmod          ! ocean active tracer trends
+   USE trdmod_oce      ! ocean variables trends
+   USE eosbn2          ! equation of state (eos routine) 
+   USE lbclnk          ! lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_npc    ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_npc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tranpc  ***
+      !!
+      !! ** Purpose :   Non penetrative convective adjustment scheme. solve 
+      !!      the static instability of the water column on after fields
+      !!      while conserving heat and salt contents.
+      !!
+      !! ** Method  :   The algorithm used converges in a maximium of jpk 
+      !!      iterations. instabilities are treated when the vertical density
+      !!      gradient is less than 1.e-5.
+      !!      l_trdtra=T: the trend associated with this algorithm is saved.
+      !!
+      !! ** Action  : - (ta,sa) after the application od the npc scheme
+      !!              - save the associated trends (ttrd,strd) ('key_trdtra')
+      !!
+      !! References : Madec, et al., 1991, JPO, 21, 9, 1349-1371.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :    ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :    ztrds => va   ! use va as 3D workspace   
+      !! 
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   inpcc        ! number of statically instable water column
+      INTEGER  ::   inpci        ! number of iteration for npc scheme
+      INTEGER  ::   jiter, jkdown, jkp        ! ???
+      INTEGER  ::   ikbot, ik, ikup, ikdown   ! ???
+      REAL(wp) ::   ze3tot, zta, zsa, zraua, ze3dwn
+      REAL(wp), DIMENSION(jpi,jpk)     ::   zwx, zwy, zwz   ! 2D arrays
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zrhop           ! 3D arrays
+      !!----------------------------------------------------------------------
+
+      IF( MOD( kt, nn_npc ) == 0 ) THEN
+
+         inpcc = 0
+         inpci = 0
+
+         CALL eos( ta, sa, rhd, zrhop )         ! Potential density
+
+
+         IF( l_trdtra )   THEN                  ! Save ta and sa trends
+            ztrdt(:,:,:) = ta(:,:,:) 
+            ztrds(:,:,:) = sa(:,:,:) 
+         ENDIF
+
+         !                                                ! ===============
+         DO jj = 1, jpj                                   !  Vertical slab
+            !                                             ! ===============
+            !  Static instability pointer 
+            ! ----------------------------
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  zwx(ji,jk) = ( zrhop(ji,jj,jk) - zrhop(ji,jj,jk+1) ) * tmask(ji,jj,jk+1)
+               END DO
+            END DO
+
+            ! 1.1 do not consider the boundary points
+
+            ! even if east-west cyclic b. c. do not considere ji=1 or jpi
+            DO jk = 1, jpkm1
+               zwx( 1 ,jk) = 0.e0
+               zwx(jpi,jk) = 0.e0
+            END DO
+            ! even if south-symmetric b. c. used, do not considere jj=1
+            IF( jj == 1 )   zwx(:,:) = 0.e0
+
+            DO jk = 1, jpkm1
+               DO ji = 1, jpi
+                  zwx(ji,jk) = 1.
+                  IF( zwx(ji,jk) < 1.e-5 ) zwx(ji,jk) = 0.e0
+               END DO
+            END DO
+
+            zwy(:,1) = 0.e0
+            DO ji = 1, jpi
+               DO jk = 1, jpkm1
+                  zwy(ji,1) = zwy(ji,1) + zwx(ji,jk)
+               END DO
+            END DO
+
+            zwz(1,1) = 0.e0
+            DO ji = 1, jpi
+               zwz(1,1) = zwz(1,1) + zwy(ji,1)
+            END DO
+
+            inpcc = inpcc + NINT( zwz(1,1) )
+
+
+            ! 2. Vertical mixing for each instable portion of the density profil
+            ! ------------------------------------------------------------------
+
+            IF( zwz(1,1) /= 0.e0 ) THEN         ! -->> the density profil is statically instable :
+               DO ji = 1, jpi
+                  IF( zwy(ji,1) /= 0.e0 ) THEN
+                     !
+                     ikbot = mbathy(ji,jj)      ! ikbot: ocean bottom level
+                     !
+                     DO jiter = 1, jpk          ! vertical iteration
+                        !
+                        ! search of ikup : the first static instability from the sea surface
+                        !
+                        ik = 0
+220                     CONTINUE
+                        ik = ik + 1
+                        IF( ik >= ikbot-1 ) GO TO 200
+                        zwx(ji,ik) = zrhop(ji,jj,ik) - zrhop(ji,jj,ik+1)
+                        IF( zwx(ji,ik) <= 0.e0 ) GO TO 220
+                        ikup = ik
+                        ! the density profil is instable below ikup
+                        ! ikdown : bottom of the instable portion of the density profil
+                        ! search of ikdown and vertical mixing from ikup to ikdown
+                        !
+                        ze3tot= fse3t(ji,jj,ikup)
+                        zta   = ta   (ji,jj,ikup)
+                        zsa   = sa   (ji,jj,ikup)
+                        zraua = zrhop(ji,jj,ikup)
+                        !
+                        DO jkdown = ikup+1, ikbot-1
+                           IF( zraua <= zrhop(ji,jj,jkdown) ) THEN
+                              ikdown = jkdown
+                              GO TO 240
+                           ENDIF
+                           ze3dwn =  fse3t(ji,jj,jkdown)
+                           ze3tot =  ze3tot + ze3dwn
+                           zta   = ( zta*(ze3tot-ze3dwn) + ta(ji,jj,jkdown)*ze3dwn )/ze3tot
+                           zsa   = ( zsa*(ze3tot-ze3dwn) + sa(ji,jj,jkdown)*ze3dwn )/ze3tot
+                           zraua = ( zraua*(ze3tot-ze3dwn) + zrhop(ji,jj,jkdown)*ze3dwn )/ze3tot
+                           inpci = inpci+1
+                        END DO
+                        ikdown = ikbot-1
+240                     CONTINUE
+                        !
+                        DO jkp = ikup, ikdown-1
+                           ta(ji,jj,jkp) = zta
+                           sa(ji,jj,jkp) = zsa
+                           zrhop(ji,jj,jkp) = zraua
+                        END DO
+                        IF (ikdown == ikbot-1 .AND. zraua >= zrhop(ji,jj,ikdown) ) THEN
+                           ta(ji,jj,ikdown) = zta
+                           sa(ji,jj,ikdown) = zsa
+                           zrhop(ji,jj,ikdown) = zraua
+                        ENDIF
+                     END DO
+                  ENDIF
+200               CONTINUE
+               END DO
+               ! <<-- no more static instability on slab jj
+            ENDIF
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         ! 
+         IF( l_trdtra )   THEN         ! save the Non penetrative mixing trends for diagnostic
+            ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+            ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+            CALL trd_mod(ztrdt, ztrds, jptra_trd_npc, 'TRA', kt)
+         ENDIF
+      
+         ! Lateral boundary conditions on ( ta, sa )   ( Unchanged sign)
+         ! ------------------------------============
+         CALL lbc_lnk( ta, 'T', 1. )
+         CALL lbc_lnk( sa, 'T', 1. )
+      
+
+         !  2. non penetrative convective scheme statistics
+         !  -----------------------------------------------
+         IF( nn_npcp /= 0 .AND. MOD( kt, nn_npcp ) == 0 ) THEN
+            IF(lwp) WRITE(numout,*)' kt=',kt, ' number of statically instable',   &
+               &                   ' water column : ',inpcc, ' number of iteration : ',inpci
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE tra_npc
+
+   !!======================================================================
+END MODULE tranpc
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 1844)
@@ -0,0 +1,387 @@
+MODULE tranxt
+   !!======================================================================
+   !!                       ***  MODULE  tranxt  ***
+   !! Ocean active tracers:  time stepping on temperature and salinity
+   !!======================================================================
+   !! History :  OPA  !  1991-11  (G. Madec)  Original code
+   !!            7.0  !  1993-03  (M. Guyon)  symetrical conditions
+   !!            8.0  !  1996-02  (G. Madec & M. Imbard)  opa release 8.0
+   !!             -   !  1996-04  (A. Weaver)  Euler forward step
+   !!            8.2  !  1999-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
+   !!  NEMO      1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
+   !!             -   !  2005-04  (C. Deltel) Add Asselin trend in the ML budget
+   !!            2.0  !  2006-02  (L. Debreu, C. Mazauric) Agrif implementation
+   !!            3.0  !  2008-06  (G. Madec)  time stepping always done in trazdf
+   !!            3.1  !  2009-02  (G. Madec, R. Benshila)  re-introduce the vvl option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_nxt       : time stepping on temperature and salinity
+   !!   tra_nxt_fix   : time stepping on temperature and salinity : fixed    volume case
+   !!   tra_nxt_vvl   : time stepping on temperature and salinity : variable volume case
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ???
+   USE domvvl          ! variable volume
+   USE dynspg_oce      ! surface     pressure gradient variables
+   USE dynhpg          ! hydrostatic pressure gradient 
+   USE trdmod_oce      ! ocean variables trends
+   USE trdmod          ! ocean active tracers trends 
+   USE phycst
+   USE obctra          ! open boundary condition (obc_tra routine)
+   USE bdytra          ! Unstructured open boundary condition (bdy_tra routine)
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE agrif_opa_update
+   USE agrif_opa_interp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_nxt    ! routine called by step.F90
+
+   REAL(wp), DIMENSION(jpk) ::   r2dt_t   ! vertical profile time step, =2*rdttra (leapfrog) or =rdttra (Euler)
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_nxt( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tranxt  ***
+      !!
+      !! ** Purpose :   Apply the boundary condition on the after temperature  
+      !!             and salinity fields, achieved the time stepping by adding
+      !!             the Asselin filter on now fields and swapping the fields.
+      !! 
+      !! ** Method  :   At this stage of the computation, ta and sa are the 
+      !!             after temperature and salinity as the time stepping has
+      !!             been performed in trazdf_imp or trazdf_exp module.
+      !!
+      !!              - Apply lateral boundary conditions on (ta,sa) 
+      !!             at the local domain   boundaries through lbc_lnk call, 
+      !!             at the radiative open boundaries (lk_obc=T), 
+      !!             at the relaxed   open boundaries (lk_bdy=T), and
+      !!             at the AGRIF zoom     boundaries (lk_agrif=T)
+      !!
+      !!              - Update lateral boundary conditions on AGRIF children
+      !!             domains (lk_agrif=T)
+      !!
+      !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
+      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :    ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :    ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   jk    ! dummy loop indices
+      REAL(wp) ::   zfact ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_nxt : achieve the time stepping by Asselin filter and array swap'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      ! Update after tracer on domain lateral boundaries
+      ! 
+      CALL lbc_lnk( ta, 'T', 1. )      ! local domain boundaries  (T-point, unchanged sign)
+      CALL lbc_lnk( sa, 'T', 1. )
+      !
+#if defined key_obc
+      CALL obc_tra( kt )               ! OBC open boundaries
+#endif
+#if defined key_bdy
+      CALL bdy_tra( kt )               ! BDY open boundaries
+#endif
+#if defined key_agrif
+      CALL Agrif_tra                   ! AGRIF zoom boundaries
+#endif
+ 
+      ! set time step size (Euler/Leapfrog)
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;   r2dt_t(:) =     rdttra(:)      ! at nit000             (Euler)
+      ELSEIF( kt <= nit000 + 1 )           THEN   ;   r2dt_t(:) = 2.* rdttra(:)      ! at nit000 or nit000+1 (Leapfrog)
+      ENDIF
+
+      ! trends computation initialisation
+      IF( l_trdtra ) THEN              ! store now fields before applying the Asselin filter
+         ztrdt(:,:,:) = tn(:,:,:)      
+         ztrds(:,:,:) = sn(:,:,:)
+      ENDIF
+
+      ! Leap-Frog + Asselin filter time stepping
+      IF( lk_vvl )   THEN   ;   CALL tra_nxt_vvl( kt )      ! variable volume level (vvl)
+      ELSE                  ;   CALL tra_nxt_fix( kt )      ! fixed    volume level
+      ENDIF
+
+#if defined key_agrif
+      ! Update tracer at AGRIF zoom boundaries
+      IF( .NOT.Agrif_Root() )    CALL Agrif_Update_Tra( kt )      ! children only
+#endif      
+
+      ! trends computation
+      IF( l_trdtra ) THEN              ! trend of the Asselin filter (tb filtered - tb)/dt     
+         DO jk = 1, jpkm1
+            zfact = 1.e0 / r2dt_t(jk)             
+            ztrdt(:,:,jk) = ( tb(:,:,jk) - ztrdt(:,:,jk) ) * zfact
+            ztrds(:,:,jk) = ( sb(:,:,jk) - ztrds(:,:,jk) ) * zfact
+         END DO
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_atf, 'TRA', kt )
+      END IF
+
+      !                        ! control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tn, clinfo1=' nxt  - Tn: ', mask1=tmask,   &
+         &                       tab3d_2=sn, clinfo2=       ' Sn: ', mask2=tmask )
+      !
+   END SUBROUTINE tra_nxt
+
+
+   SUBROUTINE tra_nxt_fix( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_nxt_fix  ***
+      !!
+      !! ** Purpose :   fixed volume: apply the Asselin time filter and 
+      !!                swap the tracer fields.
+      !! 
+      !! ** Method  : - Apply a Asselin time filter on now fields.
+      !!              - save in (ta,sa) an average over the three time levels 
+      !!             which will be used to compute rdn and thus the semi-implicit
+      !!             hydrostatic pressure gradient (ln_dynhpg_imp = T)
+      !!              - swap tracer fields to prepare the next time_step.
+      !!                This can be summurized for tempearture as:
+      !!             ztm = (ta+2tn+tb)/4       ln_dynhpg_imp = T
+      !!             ztm = 0                   otherwise
+      !!             tb  = tn + atfp*[ tb - 2 tn + ta ]
+      !!             tn  = ta 
+      !!             ta  = ztm       (NB: reset to 0 after eos_bn2 call)
+      !!
+      !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
+      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   ztm, ztf     ! temporary scalars
+      REAL(wp) ::   zsm, zsf     !    -         -
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_nxt_fix : time stepping'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+      !
+      !                                              ! ----------------------- !
+      IF( ln_dynhpg_imp ) THEN                       ! semi-implicite hpg case !
+         !                                           ! ----------------------- !
+         !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN        ! Euler time-stepping at first time-step
+            DO jk = 1, jpkm1                              ! (only swap)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                                           ! tb <-- tn
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSE                                             ! general case (Leapfrog + Asselin filter
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ztm = 0.25 * ( ta(ji,jj,jk) + 2.* tn(ji,jj,jk) + tb(ji,jj,jk) )       ! mean t
+                     zsm = 0.25 * ( sa(ji,jj,jk) + 2.* sn(ji,jj,jk) + sb(ji,jj,jk) )
+                     ztf = atfp * ( ta(ji,jj,jk) - 2.* tn(ji,jj,jk) + tb(ji,jj,jk) )       ! Asselin filter on t 
+                     zsf = atfp * ( sa(ji,jj,jk) - 2.* sn(ji,jj,jk) + sb(ji,jj,jk) )
+                     tb(ji,jj,jk) = tn(ji,jj,jk) + ztf                                     ! tb <-- filtered tn 
+                     sb(ji,jj,jk) = sn(ji,jj,jk) + zsf
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                                           ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                     ta(ji,jj,jk) = ztm                                                    ! ta <-- mean t
+                     sa(ji,jj,jk) = zsm
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         !                                           ! ----------------------- !
+      ELSE                                           !    explicit hpg case    !
+         !                                           ! ----------------------- !
+         !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN        ! Euler time-stepping at first time-step
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                                           ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSE                                             ! general case (Leapfrog + Asselin filter
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ztf = atfp * ( ta(ji,jj,jk) - 2.* tn(ji,jj,jk) + tb(ji,jj,jk) )       ! Asselin filter on t 
+                     zsf = atfp * ( sa(ji,jj,jk) - 2.* sn(ji,jj,jk) + sb(ji,jj,jk) )
+                     tb(ji,jj,jk) = tn(ji,jj,jk) + ztf                                     ! tb <-- filtered tn 
+                     sb(ji,jj,jk) = sn(ji,jj,jk) + zsf
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                                           ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE tra_nxt_fix
+
+
+   SUBROUTINE tra_nxt_vvl( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tra_nxt_vvl  ***
+      !!
+      !! ** Purpose :   Time varying volume: apply the Asselin time filter  
+      !!                and swap the tracer fields.
+      !! 
+      !! ** Method  : - Apply a thickness weighted Asselin time filter on now fields.
+      !!              - save in (ta,sa) a thickness weighted average over the three 
+      !!             time levels which will be used to compute rdn and thus the semi-
+      !!             implicit hydrostatic pressure gradient (ln_dynhpg_imp = T)
+      !!              - swap tracer fields to prepare the next time_step.
+      !!                This can be summurized for tempearture as:
+      !!             ztm = (e3t_a*ta+2*e3t_n*tn+e3t_b*tb)   ln_dynhpg_imp = T
+      !!                  /(e3t_a   +2*e3t_n   +e3t_b   )    
+      !!             ztm = 0                                otherwise
+      !!             tb  = ( e3t_n*tn + atfp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )
+      !!                  /( e3t_n    + atfp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )
+      !!             tn  = ta 
+      !!             ta  = zt        (NB: reset to 0 after eos_bn2 call)
+      !!
+      !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
+      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step index
+      !!     
+      INTEGER  ::   ji, jj, jk             ! dummy loop indices
+      REAL(wp) ::   ztm , ztc_f , ztf , ztca, ztcn, ztcb   ! temporary scalar
+      REAL(wp) ::   zsm , zsc_f , zsf , zsca, zscn, zscb   !    -         -
+      REAL(wp) ::   ze3mr, ze3fr                           !    -         -
+      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f         !    -         -
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_nxt_vvl : time stepping'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      !                                              ! ----------------------- !
+      IF( ln_dynhpg_imp ) THEN                       ! semi-implicite hpg case !
+         !                                           ! ----------------------- !
+         !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN        ! Euler time-stepping at first time-step
+            DO jk = 1, jpkm1                              ! (only swap)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                    ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSE
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ze3t_b = fse3t_b(ji,jj,jk)
+                     ze3t_n = fse3t_n(ji,jj,jk)
+                     ze3t_a = fse3t_a(ji,jj,jk)
+                     !                                         ! tracer content at Before, now and after
+                     ztcb = tb(ji,jj,jk) *  ze3t_b   ;   zscb = sb(ji,jj,jk) * ze3t_b
+                     ztcn = tn(ji,jj,jk) *  ze3t_n   ;   zscn = sn(ji,jj,jk) * ze3t_n
+                     ztca = ta(ji,jj,jk) *  ze3t_a   ;   zsca = sa(ji,jj,jk) * ze3t_a
+                     !
+                     !                                         ! Asselin filter on thickness and tracer content
+                     ze3t_f = atfp * ( ze3t_a - 2.* ze3t_n + ze3t_b )
+                     ztc_f  = atfp * ( ztca   - 2.* ztcn   + ztcb   ) 
+                     zsc_f  = atfp * ( zsca   - 2.* zscn   + zscb   ) 
+                     !
+                     !                                         ! filtered tracer including the correction 
+                     ze3fr = 1.e0  / ( ze3t_n + ze3t_f )
+                     ztf   = ze3fr * ( ztcn   + ztc_f  )
+                     zsf   = ze3fr * ( zscn   + zsc_f  )
+                     !                                         ! mean thickness and tracer
+                     ze3mr = 1.e0  / ( ze3t_a + 2.* ze3t_n + ze3t_b )
+                     ztm   = ze3mr * ( ztca   + 2.* ztcn   + ztcb   )
+                     zsm   = ze3mr * ( zsca   + 2.* zscn   + zscb   )
+!!gm mean e3t have to be saved and used in dynhpg  or it can be recomputed in dynhpg !!
+!!gm                 e3t_m(ji,jj,jk) = 0.25 / ze3mr
+                     !                                         ! swap of arrays
+                     tb(ji,jj,jk) = ztf                             ! tb <-- tn + filter
+                     sb(ji,jj,jk) = zsf
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                    ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                     ta(ji,jj,jk) = ztm                             ! ta <-- mean t
+                     sa(ji,jj,jk) = zsm
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         !                                           ! ----------------------- !
+      ELSE                                           !    explicit hpg case    !
+         !                                           ! ----------------------- !
+         !
+         IF( neuler == 0 .AND. kt == nit000 ) THEN        ! case of Euler time-stepping at first time-step
+            DO jk = 1, jpkm1                              ! No filter nor thickness weighting computation required
+               DO jj = 1, jpj                             ! ONLY swap
+                  DO ji = 1, jpi
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                                 ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !                                             ! general case (Leapfrog + Asselin filter)
+         ELSE                                             ! apply filter on thickness weighted tracer and swap
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ze3t_b = fse3t_b(ji,jj,jk)
+                     ze3t_n = fse3t_n(ji,jj,jk)
+                     ze3t_a = fse3t_a(ji,jj,jk)
+                     !                                         ! tracer content at Before, now and after
+                     ztcb = tb(ji,jj,jk) *  ze3t_b   ;   zscb = sb(ji,jj,jk) * ze3t_b
+                     ztcn = tn(ji,jj,jk) *  ze3t_n   ;   zscn = sn(ji,jj,jk) * ze3t_n
+                     ztca = ta(ji,jj,jk) *  ze3t_a   ;   zsca = sa(ji,jj,jk) * ze3t_a
+                     !
+                     !                                         ! Asselin filter on thickness and tracer content
+                     ze3t_f = atfp * ( ze3t_a - 2.* ze3t_n + ze3t_b )
+                     ztc_f  = atfp * ( ztca   - 2.* ztcn   + ztcb   ) 
+                     zsc_f  = atfp * ( zsca   - 2.* zscn   + zscb   ) 
+                     !
+                     !                                         ! filtered tracer including the correction 
+                     ze3fr = 1.e0 / ( ze3t_n + ze3t_f )
+                     ztf   =  ( ztcn  + ztc_f ) * ze3fr
+                     zsf   =  ( zscn  + zsc_f ) * ze3fr
+                     !                                         ! swap of arrays
+                     tb(ji,jj,jk) = ztf                             ! tb <-- tn filtered
+                     sb(ji,jj,jk) = zsf
+                     tn(ji,jj,jk) = ta(ji,jj,jk)                    ! tn <-- ta
+                     sn(ji,jj,jk) = sa(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE tra_nxt_vvl
+
+   !!======================================================================
+END MODULE tranxt
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 1844)
@@ -0,0 +1,421 @@
+MODULE traqsr
+   !!======================================================================
+   !!                       ***  MODULE  traqsr  ***
+   !! Ocean physics: solar radiation penetration in the top ocean levels
+   !!======================================================================
+   !! History :  OPA  !  1990-10  (B. Blanke)  Original code
+   !!            7.0  !  1991-11  (G. Madec)
+   !!                 !  1996-01  (G. Madec)  s-coordinates
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
+   !!             -   !  2005-11  (G. Madec) zco, zps, sco coordinate
+   !!            3.2  !  2009-04  (G. Madec & NEMO team) 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_qsr      : trend due to the solar radiation penetration
+   !!   tra_qsr_init : solar radiation penetration initialization
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE trc_oce         ! share SMS/Ocean variables
+   USE trdmod_oce      ! ocean variables trends
+   USE trdmod          ! ocean active tracers trends 
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE prtctl          ! Print control
+   USE iom             ! I/O manager
+   USE fldread         ! read input fields
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_qsr        ! routine called by step.F90 (ln_traqsr=T)
+
+   !                                           !!* Namelist namtra_qsr: penetrative solar radiation
+   LOGICAL , PUBLIC ::   ln_traqsr  = .TRUE.    !: light absorption (qsr) flag
+   LOGICAL , PUBLIC ::   ln_qsr_rgb = .FALSE.   !: Red-Green-Blue light absorption flag  
+   LOGICAL , PUBLIC ::   ln_qsr_2bd = .TRUE.    !: 2 band         light absorption flag
+   LOGICAL , PUBLIC ::   ln_qsr_bio = .FALSE.   !: bio-model      light absorption flag
+   INTEGER , PUBLIC ::   nn_chldta  = 0         !: use Chlorophyll data (=1) or not (=0)
+   REAL(wp), PUBLIC ::   rn_abs     = 0.58_wp   !: fraction absorbed in the very near surface (RGB & 2 bands)
+   REAL(wp), PUBLIC ::   rn_si0     = 0.35_wp   !: very near surface depth of extinction      (RGB & 2 bands)
+   REAL(wp), PUBLIC ::   rn_si1     = 23.0_wp   !: deepest depth of extinction (water type I)       (2 bands)
+   REAL(wp), PUBLIC ::   rn_si2     = 61.8_wp   !: deepest depth of extinction (blue & 0.01 mg.m-3)     (RGB)
+   
+   ! Module variables
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_chl   ! structure of input Chl (file informations, fields read)
+   INTEGER ::   nksr   ! levels below which the light cannot penetrate ( depth larger than 391 m)
+   REAL(wp), DIMENSION(3,61) ::   rkrgb   !: tabulated attenuation coefficients for RGB absorption
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_qsr( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_qsr  ***
+      !!
+      !! ** Purpose :   Compute the temperature trend due to the solar radiation
+      !!      penetration and add it to the general temperature trend.
+      !!
+      !! ** Method  : The profile of the solar radiation within the ocean is defined
+      !!      through 2 wavebands (rn_si0,rn_si1) or 3 wavebands (RGB) and a ratio rn_abs
+      !!      Considering the 2 wavebands case:
+      !!         I(k) = Qsr*( rn_abs*EXP(z(k)/rn_si0) + (1.-rn_abs)*EXP(z(k)/rn_si1) )
+      !!         The temperature trend associated with the solar radiation penetration 
+      !!         is given by : zta = 1/e3t dk[ I ] / (rau0*Cp)
+      !!         At the bottom, boudary condition for the radiation is no flux :
+      !!      all heat which has not been absorbed in the above levels is put
+      !!      in the last ocean level.
+      !!         In z-coordinate case, the computation is only done down to the
+      !!      level where I(k) < 1.e-15 W/m2. In addition, the coefficients 
+      !!      used for the computation are calculated one for once as they
+      !!      depends on k only.
+      !!
+      !! ** Action  : - update ta with the penetrative solar radiation trend
+      !!              - save the trend in ttrd ('key_trdtra')
+      !!
+      !! Reference  : Jerlov, N. G., 1968 Optical Oceanography, Elsevier, 194pp.
+      !!              Lengaigne et al. 2007, Clim. Dyn., V28, 5, 503-516.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      INTEGER  ::   irgb                 ! temporary integers
+      REAL(wp) ::   zchl, zcoef, zsi0r   ! temporary scalars
+      REAL(wp) ::   zc0, zc1, zc2, zc3   !    -         -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zekb, zekg, zekr            ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze0, ze1 , ze2, ze3, zea    ! 3D workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_qsr : penetration of the surface solar radiation'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+         CALL tra_qsr_init
+         IF( .NOT.ln_traqsr )   RETURN
+      ENDIF
+
+      IF( l_trdtra ) THEN      ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = 0.e0
+      ENDIF
+
+      
+      !                                           ! ============================================== !
+      IF( lk_qsr_bio .AND. ln_qsr_bio ) THEN      !  bio-model fluxes  : all vertical coordinates  !
+         !                                        ! ============================================== !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ta(ji,jj,jk) = ta(ji,jj,jk) + ro0cpr * ( etot3(ji,jj,jk) - etot3(ji,jj,jk+1) ) / fse3t(ji,jj,jk) 
+               END DO
+            END DO
+         END DO
+         CALL iom_put( 'qsr3d', etot3 )   ! Shortwave Radiation 3D distribution
+         !                                        ! ============================================== !
+      ELSE                                        !  Ocean alone : 
+         !                                        ! ============================================== !
+         !
+         !                                                ! ------------------------- !
+         IF( ln_qsr_rgb) THEN                             !  R-G-B  light penetration !
+            !                                             ! ------------------------- !
+            ! Set chlorophyl concentration
+            IF( nn_chldta ==1 ) THEN                             !*  Variable Chlorophyll
+               !
+               CALL fld_read( kt, 1, sf_chl )                         ! Read Chl data and provides it at the current time step
+               !         
+!CDIR COLLAPSE
+!CDIR NOVERRCHK
+               DO jj = 1, jpj                                         ! Separation in R-G-B depending of the surface Chl
+!CDIR NOVERRCHK
+                  DO ji = 1, jpi
+                     zchl = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj) ) )
+                     irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
+                     zekb(ji,jj) = rkrgb(1,irgb)
+                     zekg(ji,jj) = rkrgb(2,irgb)
+                     zekr(ji,jj) = rkrgb(3,irgb)
+                  END DO
+               END DO
+               !
+               zsi0r = 1.e0 / rn_si0
+               zcoef  = ( 1. - rn_abs ) / 3.e0                        ! equi-partition in R-G-B
+               ze0(:,:,1) = rn_abs  * qsr(:,:)
+               ze1(:,:,1) = zcoef * qsr(:,:)
+               ze2(:,:,1) = zcoef * qsr(:,:)
+               ze3(:,:,1) = zcoef * qsr(:,:)
+               zea(:,:,1) =         qsr(:,:)
+               !
+               DO jk = 2, nksr+1
+!CDIR NOVERRCHK
+                  DO jj = 1, jpj
+!CDIR NOVERRCHK   
+                     DO ji = 1, jpi
+                        zc0 = ze0(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zsi0r     )
+                        zc1 = ze1(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekb(ji,jj) )
+                        zc2 = ze2(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekg(ji,jj) )
+                        zc3 = ze3(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekr(ji,jj) )
+                        ze0(ji,jj,jk) = zc0
+                        ze1(ji,jj,jk) = zc1
+                        ze2(ji,jj,jk) = zc2
+                        ze3(ji,jj,jk) = zc3
+                        zea(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) * tmask(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+               !
+               DO jk = 1, nksr                                        ! compute and add qsr trend to ta
+                  ta(:,:,jk) = ta(:,:,jk) + ro0cpr * ( zea(:,:,jk) - zea(:,:,jk+1) ) / fse3t(:,:,jk)
+               END DO
+               zea(:,:,nksr+1:jpk) = 0.e0     ! below 400m set to zero
+               CALL iom_put( 'qsr3d', zea )   ! Shortwave Radiation 3D distribution
+               !
+            ELSE                                                 !*  Constant Chlorophyll
+               DO jk = 1, nksr
+                  ta(:,:,jk) = ta(:,:,jk) + etot3(:,:,jk) * qsr(:,:)
+               END DO
+            ENDIF
+
+         ENDIF
+         !                                                ! ------------------------- !
+         IF( ln_qsr_2bd ) THEN                            !  2 band light penetration !
+            !                                             ! ------------------------- !
+            !
+            DO jk = 1, nksr
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ta(ji,jj,jk) = ta(ji,jj,jk) + etot3(ji,jj,jk) * qsr(ji,jj)
+                  END DO
+               END DO
+            END DO
+            !
+         ENDIF
+         !
+      ENDIF
+
+      IF( l_trdtra ) THEN     ! qsr tracers trends saved for diagnostics
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_qsr, 'TRA', kt )
+      ENDIF
+      !                       ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' qsr  - Ta: ', mask1=tmask, clinfo3='tra-ta' )
+      !
+   END SUBROUTINE tra_qsr
+
+
+   SUBROUTINE tra_qsr_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_qsr_init  ***
+      !!
+      !! ** Purpose :   Initialization for the penetrative solar radiation
+      !!
+      !! ** Method  :   The profile of solar radiation within the ocean is set
+      !!      from two length scale of penetration (rn_si0,rn_si1) and a ratio
+      !!      (rn_abs). These parameters are read in the namtra_qsr namelist. The
+      !!      default values correspond to clear water (type I in Jerlov' 
+      !!      (1968) classification.
+      !!         called by tra_qsr at the first timestep (nit000)
+      !!
+      !! ** Action  : - initialize rn_si0, rn_si1 and rn_abs
+      !!
+      !! Reference : Jerlov, N. G., 1968 Optical Oceanography, Elsevier, 194pp.
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk            ! dummy loop indices
+      INTEGER  ::   irgb, ierror          ! temporary integer
+      INTEGER  ::   ioptio, nqsr          ! temporary integer
+      REAL(wp) ::   zc0  , zc1            ! temporary scalars
+      REAL(wp) ::   zc2  , zc3  , zchl    !    -         -
+      REAL(wp) ::   zsi0r, zsi1r, zcoef   !    -         -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zekb, zekg, zekr              ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze0 , ze1 , ze2 , ze3 , zea   ! 3D workspace
+      !!
+      CHARACTER(len=100) ::   cn_dir   ! Root directory for location of ssr files
+      TYPE(FLD_N)        ::   sn_chl   ! informations about the chlorofyl field to be read
+      NAMELIST/namtra_qsr/  sn_chl, cn_dir, ln_traqsr, ln_qsr_rgb, ln_qsr_2bd, ln_qsr_bio,   &
+         &                  nn_chldta, rn_abs, rn_si0, rn_si1, rn_si2
+      !!----------------------------------------------------------------------
+
+      cn_dir = './'       ! directory in which the model is executed
+      ! ... default values (NB: frequency positive => hours, negative => months)
+      !            !     file       ! frequency !  variable  ! time interp !  clim   ! 'yearly' or ! weights  ! rotation   !
+      !            !     name       !  (hours)  !    name    !    (T/F)    !  (T/F)  ! 'monthly'   ! filename ! pairs      !
+      sn_chl = FLD_N( 'chlorophyll' ,    -1     ,  'CHLA'    ,  .true.     , .true.  ,   'yearly'  , ''       , ''         )
+      !
+      REWIND( numnam )            ! Read Namelist namtra_qsr : ratio and length of penetration
+      READ  ( numnam, namtra_qsr )
+      !
+      IF(lwp) THEN                ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_qsr_init : penetration of the surface solar radiation'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtra_qsr : set the parameter of penetration'
+         WRITE(numout,*) '      Light penetration (T) or not (F)         ln_traqsr  = ', ln_traqsr
+         WRITE(numout,*) '      RGB (Red-Green-Blue) light penetration   ln_qsr_rgb = ', ln_qsr_rgb
+         WRITE(numout,*) '      2 band               light penetration   ln_qsr_2bd = ', ln_qsr_2bd
+         WRITE(numout,*) '      bio-model            light penetration   ln_qsr_bio = ', ln_qsr_bio
+         WRITE(numout,*) '      RGB : Chl data (=1) or cst value (=0)    nn_chldta  = ', nn_chldta
+         WRITE(numout,*) '      RGB & 2 bands: fraction of light (rn_si1)    rn_abs = ', rn_abs
+         WRITE(numout,*) '      RGB & 2 bands: shortess depth of extinction  rn_si0 = ', rn_si0
+         WRITE(numout,*) '      2 bands: longest depth of extinction         rn_si1 = ', rn_si1
+         WRITE(numout,*) '      3 bands: longest depth of extinction         rn_si2 = ', rn_si2
+      ENDIF
+
+      IF( ln_traqsr ) THEN     ! control consistency
+         !                      
+         IF( .NOT.lk_qsr_bio .AND. ln_qsr_bio )   THEN
+            CALL ctl_warn( 'No bio model : force ln_qsr_bio = FALSE ' )
+            ln_qsr_bio = .FALSE.
+         ENDIF
+         !
+         ioptio = 0                      ! Parameter control
+         IF( ln_qsr_rgb  )   ioptio = ioptio + 1
+         IF( ln_qsr_2bd  )   ioptio = ioptio + 1
+         IF( ln_qsr_bio  )   ioptio = ioptio + 1
+         !
+         IF( ioptio /= 1 ) THEN
+            ln_qsr_rgb = .TRUE.
+            nn_chldta  = 0
+            ln_qsr_2bd = .FALSE.
+            ln_qsr_bio = .FALSE.
+            CALL ctl_warn( '          Choose ONE type of light penetration in namelist namtra_qsr',   &
+           &               ' otherwise, we force the model to run with RGB light penetration' )
+         ENDIF
+         !
+         IF( ln_qsr_rgb .AND. nn_chldta == 0 )   nqsr =  1 
+         IF( ln_qsr_rgb .AND. nn_chldta == 1 )   nqsr =  2
+         IF( ln_qsr_2bd                      )   nqsr =  3
+         IF( ln_qsr_bio                      )   nqsr =  4
+         !
+         IF(lwp) THEN                   ! Print the choice
+            WRITE(numout,*)
+            IF( nqsr ==  1 )   WRITE(numout,*) '         R-G-B  light penetration - Constant Chlorophyll'
+            IF( nqsr ==  2 )   WRITE(numout,*) '         R-G-B  light penetration - Chl data '
+            IF( nqsr ==  3 )   WRITE(numout,*) '         2 band light penetration'
+            IF( nqsr ==  4 )   WRITE(numout,*) '         bio-model light penetration'
+         ENDIF
+         !
+      ENDIF
+      !                          ! ===================================== !
+      IF( ln_traqsr  ) THEN      !  Initialisation of Light Penetration  !  
+         !                       ! ===================================== !
+         !
+         zsi0r = 1.e0 / rn_si0
+         zsi1r = 1.e0 / rn_si1
+         !                                ! ---------------------------------- !
+         IF( ln_qsr_rgb ) THEN            !  Red-Green-Blue light penetration  !
+            !                             ! ---------------------------------- !
+            !
+            !                                ! level of light extinction
+            nksr = trc_oce_ext_lev( rn_si2, 0.33e2 )
+            IF(lwp) THEN
+               WRITE(numout,*)
+               WRITE(numout,*) '        level max of computation of qsr = ', nksr, ' ref depth = ', gdepw_0(nksr+1), ' m'
+            ENDIF
+            !
+            CALL trc_oce_rgb( rkrgb )           !* tabulated attenuation coef.
+!!gm            CALL trc_oce_rgb_read( rkrgb )           !* tabulated attenuation coef.
+            !
+            IF( nn_chldta == 1 ) THEN           !* Chl data : set sf_chl structure
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '        Chlorophyll read in a file'
+               ALLOCATE( sf_chl(1), STAT=ierror )
+               IF( ierror > 0 ) THEN
+                  CALL ctl_stop( 'tra_qsr_init: unable to allocate sf_chl structure' )   ;   RETURN
+               ENDIF
+               ALLOCATE( sf_chl(1)%fnow(jpi,jpj)   )
+               ALLOCATE( sf_chl(1)%fdta(jpi,jpj,2) )
+               !                                        ! fill sf_chl with sn_chl and control print
+               CALL fld_fill( sf_chl, (/ sn_chl /), cn_dir, 'tra_qsr_init',   &
+                  &                                         'Solar penetration function of read chlorophyll', 'namtra_qsr' )
+               !
+            ELSE                                !* constant Chl : compute once for all the distribution of light (etot3)
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '        Constant Chlorophyll concentration = 0.05'
+               IF(lwp) WRITE(numout,*) '        light distribution computed once for all'
+               !
+               zchl = 0.05                                 ! constant chlorophyll
+               irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
+               zekb(:,:) = rkrgb(1,irgb)                   ! Separation in R-G-B depending of the chlorophyl concentration
+               zekg(:,:) = rkrgb(2,irgb)
+               zekr(:,:) = rkrgb(3,irgb)
+               !
+               zcoef = ( 1. - rn_abs ) / 3.e0              ! equi-partition in R-G-B
+               ze0(:,:,1) = rn_abs
+               ze1(:,:,1) = zcoef
+               ze2(:,:,1) = zcoef 
+               ze3(:,:,1) = zcoef
+               zea(:,:,1) = tmask(:,:,1)                   ! = ( ze0+ze1+z2+ze3 ) * tmask
+               
+               DO jk = 2, nksr+1
+!CDIR NOVERRCHK
+                  DO jj = 1, jpj
+!CDIR NOVERRCHK   
+                     DO ji = 1, jpi
+                        zc0 = ze0(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zsi0r     )
+                        zc1 = ze1(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekb(ji,jj) )
+                        zc2 = ze2(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekg(ji,jj) )
+                        zc3 = ze3(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * zekr(ji,jj) )
+                        ze0(ji,jj,jk) = zc0                 
+                        ze1(ji,jj,jk) = zc1
+                        ze2(ji,jj,jk) = zc2     
+                        ze3(ji,jj,jk) = zc3
+                        zea(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) * tmask(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO 
+               !
+               DO jk = 1, nksr
+                  etot3(:,:,jk) = ro0cpr * ( zea(:,:,jk) - zea(:,:,jk+1) ) / fse3t(:,:,jk)
+               END DO
+               etot3(:,:,nksr+1:jpk) = 0.e0                ! below 400m set to zero
+            ENDIF
+            !
+         ENDIF
+            !                             ! ---------------------------------- !
+         IF( ln_qsr_2bd ) THEN            !    2 bands    light penetration    !
+            !                             ! ---------------------------------- !
+            !
+            !                                ! level of light extinction
+            nksr = trc_oce_ext_lev( rn_si1, 1.e2 )
+            IF(lwp) THEN
+               WRITE(numout,*)
+               WRITE(numout,*) '        level max of computation of qsr = ', nksr, ' ref depth = ', gdepw_0(nksr+1), ' m'
+            ENDIF
+            !
+            DO jk = 1, nksr                    !*  solar heat absorbed at T-point computed once for all
+               DO jj = 1, jpj                              ! top 400 meters
+                  DO ji = 1, jpi
+                     zc0 = rn_abs * EXP( -fsdepw(ji,jj,jk  )*zsi0r ) + (1.-rn_abs) * EXP( -fsdepw(ji,jj,jk  )*zsi1r )
+                     zc1 = rn_abs * EXP( -fsdepw(ji,jj,jk+1)*zsi0r ) + (1.-rn_abs) * EXP( -fsdepw(ji,jj,jk+1)*zsi1r )
+                     etot3(ji,jj,jk) = ro0cpr * (  zc0 * tmask(ji,jj,jk) - zc1 * tmask(ji,jj,jk+1)  ) / fse3t(ji,jj,jk)
+                  END DO
+               END DO
+            END DO 
+            etot3(:,:,nksr+1:jpk) = 0.e0                   ! below 400m set to zero
+            !
+         ENDIF
+         !                       ! ===================================== !
+      ELSE                       !        No light penetration           !                   
+         !                       ! ===================================== !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'tra_qsr_init : NO solar flux penetration'
+            WRITE(numout,*) '~~~~~~~~~~~~'
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE tra_qsr_init
+
+   !!======================================================================
+END MODULE traqsr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 1844)
@@ -0,0 +1,158 @@
+MODULE trasbc
+   !!==============================================================================
+   !!                       ***  MODULE  trasbc  ***
+   !! Ocean active tracers:  surface boundary condition
+   !!==============================================================================
+   !! History :  8.2  !  98-10  (G. Madec, G. Roullet, M. Imbard)  Original code
+   !!            8.2  !  01-02  (D. Ludicone)  sea ice and free surface
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_sbc      : update the tracer trend at ocean surface
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE dom_oce         ! ocean space domain variables
+   USE phycst          ! physical constant
+   USE traqsr          ! solar radiation penetration
+   USE trdmod          ! ocean trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_sbc    ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_sbc ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_sbc  ***
+      !!                   
+      !! ** Purpose :   Compute the tracer surface boundary condition trend of
+      !!      (flux through the interface, concentration/dilution effect)
+      !!      and add it to the general trend of tracer equations.
+      !!
+      !! ** Method :
+      !!      Following Roullet and Madec (2000), the air-sea flux can be divided 
+      !!      into three effects: (1) Fext, external forcing; 
+      !!      (2) Fwi, concentration/dilution effect due to water exchanged 
+      !!         at the surface by evaporation, precipitations and runoff (E-P-R); 
+      !!      (3) Fwe, tracer carried with the water that is exchanged. 
+      !!
+      !!      Fext, flux through the air-sea interface for temperature and salt: 
+      !!            - temperature : heat flux q (w/m2). If penetrative solar
+      !!         radiation q is only the non solar part of the heat flux, the
+      !!         solar part is added in traqsr.F routine.
+      !!            ta = ta + q /(rau0 rcp e3t)  for k=1
+      !!            - salinity    : no salt flux
+      !!
+      !!      The formulation for Fwb and Fwi vary according to the free 
+      !!      surface formulation (linear or variable volume). 
+      !!      * Linear free surface
+      !!            The surface freshwater flux modifies the ocean volume
+      !!         and thus the concentration of a tracer and the temperature.
+      !!         First order of the effect of surface freshwater exchange 
+      !!         for salinity, it can be neglected on temperature (especially
+      !!         as the temperature of precipitations and runoffs is usually
+      !!         unknown).
+      !!            - temperature : we assume that the temperature of both
+      !!         precipitations and runoffs is equal to the SST, thus there
+      !!         is no additional flux since in this case, the concentration
+      !!         dilution effect is balanced by the net heat flux associated
+      !!         to the freshwater exchange (Fwe+Fwi=0):
+      !!            (Tp P - Te E) + SST (P-E) = 0 when Tp=Te=SST
+      !!            - salinity    : evaporation, precipitation and runoff
+      !!         water has a zero salinity (Fwe=0), thus only Fwi remains:
+      !!            sa = sa + emp * sn / e3t   for k=1
+      !!         where emp, the surface freshwater budget (evaporation minus
+      !!         precipitation minus runoff) given in kg/m2/s is divided
+      !!         by 1035 kg/m3 (density of ocena water) to obtain m/s.    
+      !!         Note: even though Fwe does not appear explicitly for 
+      !!         temperature in this routine, the heat carried by the water
+      !!         exchanged through the surface is part of the total heat flux
+      !!         forcing and must be taken into account in the global heat
+      !!         balance).
+      !!      * nonlinear free surface (variable volume, lk_vvl)
+      !!         contrary to the linear free surface case, Fwi is properly 
+      !!         taken into account by using the true layer thicknesses to       
+      !!         calculate tracer content and advection. There is no need to 
+      !!         deal with it in this routine.
+      !!           - temperature: Fwe=SST (P-E+R) is added to Fext.
+      !!           - salinity:  Fwe = 0, there is no surface flux of salt.
+      !!
+      !! ** Action  : - Update the 1st level of (ta,sa) with the trend associated
+      !!                with the tracer surface boundary condition 
+      !!              - save the trend it in ttrd ('key_trdtra')
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
+      USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
+      !!
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj                   ! dummy loop indices
+      REAL(wp) ::   zta, zsa, zsrau, zse3t   ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_sbc : TRAcer Surface Boundary Condition'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      zsrau = 1. / rau0             ! initialization
+#if defined key_zco
+      zse3t = 1. / e3t_0(1)
+#endif
+
+      IF( l_trdtra ) THEN           ! Save ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:) 
+         ztrds(:,:,:) = sa(:,:,:) 
+      ENDIF
+
+      IF( .NOT.ln_traqsr )   qsr(:,:) = 0.e0   ! no solar radiation penetration
+
+      ! Concentration dillution effect on (t,s)
+      DO jj = 2, jpj
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+            zse3t = 1. / fse3t(ji,jj,1)
+#endif
+            IF( lk_vvl) THEN
+               zta = ro0cpr * qns(ji,jj) * zse3t &                   ! temperature : heat flux
+                &    - emp(ji,jj) * zsrau * tn(ji,jj,1)  * zse3t     ! & cooling/heating effet of EMP flux
+               zsa = 0.e0                                            ! No salinity concent./dilut. effect
+            ELSE
+               zta = ro0cpr * qns(ji,jj) * zse3t     ! temperature : heat flux
+               zsa = emps(ji,jj) * zsrau * sn(ji,jj,1)   * zse3t     ! salinity :  concent./dilut. effect
+            ENDIF
+            ta(ji,jj,1) = ta(ji,jj,1) + zta                          ! add the trend to the general tracer trend
+            sa(ji,jj,1) = sa(ji,jj,1) + zsa
+         END DO
+      END DO
+
+      IF( l_trdtra ) THEN      ! save the sbc trends for diagnostic
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_nsr, 'TRA', kt)
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' sbc  - Ta: ', mask1=tmask,   &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+   END SUBROUTINE tra_sbc
+
+   !!======================================================================
+END MODULE trasbc
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 1844)
@@ -0,0 +1,165 @@
+MODULE trazdf
+   !!==============================================================================
+   !!                 ***  MODULE  trazdf  ***
+   !! Ocean active tracers:  vertical component of the tracer mixing trend
+   !!==============================================================================
+   !! History :  9.0  !  05-11  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_zdf      : Update the tracer trend with the vertical diffusion
+   !!       zdf_ctl  : ???
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE dynspg_oce
+
+   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
+   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
+
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   USE phycst
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE domvvl          ! variable volume
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC tra_zdf   !  routine called by step.F90
+
+   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
+      !                                ! defined from ln_zdf...  namlist logicals)
+
+   REAL(wp), DIMENSION(jpk) ::   r2dt  ! vertical profile time-step, = 2 rdttra
+      !                                ! except at nit000 (=rdttra) if neuler=0
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE tra_zdf( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_zdf  ***
+      !!
+      !! ** Purpose :   compute the vertical ocean tracer physics.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+
+      INTEGER  ::   jk                   ! Dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdt, ztrds   ! 3D workspace
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL zdf_ctl          ! initialisation & control of options
+
+      !                                          ! set time step
+      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
+         r2dt(:) =  rdttra(:)                          ! = rdtra (restarting with Euler time stepping)
+      ELSEIF( kt <= nit000 + 1) THEN                ! at nit000 or nit000+1
+         r2dt(:) = 2. * rdttra(:)                      ! = 2 rdttra (leapfrog)
+      ENDIF
+
+      IF( l_trdtra )   THEN                      ! temporary save of ta and sa trends
+         ztrdt(:,:,:) = ta(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:)
+      ENDIF
+
+      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
+      CASE ( -1 )                                       ! esopa: test all possibility with control print
+         CALL tra_zdf_exp    ( kt, r2dt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' zdf0 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+         CALL tra_zdf_imp    ( kt, r2dt )
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' zdf1 - Ta: ', mask1=tmask,               &
+            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+      CASE ( 0 )                                       ! explicit scheme
+         CALL tra_zdf_exp    ( kt, r2dt )
+
+      CASE ( 1 )                                       ! implicit scheme 
+         CALL tra_zdf_imp    ( kt, r2dt )
+
+      END SELECT
+
+      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
+         DO jk = 1, jpkm1
+            ztrdt(:,:,jk) = ( ( ta(:,:,jk) - tb(:,:,jk) ) / r2dt(jk) ) - ztrdt(:,:,jk)
+            ztrds(:,:,jk) = ( ( sa(:,:,jk) - sb(:,:,jk) ) / r2dt(jk) ) - ztrds(:,:,jk)
+         END DO
+         CALL trd_mod( ztrdt, ztrds, jptra_trd_zdf, 'TRA', kt )
+      ENDIF
+
+      !                                          ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' zdf  - Ta: ', mask1=tmask,               &
+         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+
+   END SUBROUTINE tra_zdf
+
+
+   SUBROUTINE zdf_ctl
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE zdf_ctl  ***
+      !!
+      !! ** Purpose :   Choose the vertical mixing scheme
+      !!
+      !! ** Method  :   Set nzdf from ln_zdfexp
+      !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
+      !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
+      !!      NB: rotation of lateral mixing operator or TKE or KPP scheme,
+      !!      the implicit scheme is required.
+      !!----------------------------------------------------------------------
+      USE zdftke_old
+      USE zdftke
+      USE zdfkpp
+      !!----------------------------------------------------------------------
+
+      !  Define the vertical tracer physics scheme
+      ! ==========================================
+
+      ! Choice from ln_zdfexp already read in namelist in zdfini module
+      IF( ln_zdfexp ) THEN               ! use explicit scheme
+         nzdf = 0
+      ELSE                               ! use implicit scheme
+         nzdf = 1
+      ENDIF
+
+      ! Force implicit schemes
+      IF( lk_zdftke_old .OR. lk_zdftke .OR. lk_zdfkpp )   nzdf = 1      ! TKE or KPP physics
+      IF( ln_traldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
+      IF( ln_traldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
+
+      IF( ln_zdfexp .AND. nzdf == 1 )   THEN
+         CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator or TKE ', &
+            &           '          or KPP scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
+      ENDIF
+
+      ! Test: esopa
+      IF( lk_esopa )    nzdf = -1                      ! All schemes used
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra:zdf_ctl : vertical tracer physics scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
+         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
+         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
+      ENDIF
+
+   END SUBROUTINE zdf_ctl
+
+   !!==============================================================================
+END MODULE trazdf
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_exp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_exp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_exp.F90	(revision 1844)
@@ -0,0 +1,154 @@
+MODULE trazdf_exp
+   !!==============================================================================
+   !!                    ***  MODULE  trazdf_exp  ***
+   !! Ocean active tracers:  vertical component of the tracer mixing trend using
+   !!                        a split-explicit time-stepping 
+   !!==============================================================================
+   !! History :  OPA  !  1990-10  (B. Blanke)  Original code
+   !!            7.0  !  1991-11  (G. Madec)
+   !!                 !  1992-06  (M. Imbard)  correction on tracer trend loops
+   !!                 !  1996-01  (G. Madec)  statement function for e3
+   !!                 !  1997-05  (G. Madec)  vertical component of isopycnal
+   !!                 !  1997-07  (G. Madec)  geopotential diffusion in s-coord
+   !!                 !  2000-08  (G. Madec)  double diffusive mixing
+   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2004-08  (C. Talandier) New trends organisation
+   !!             -   !  2005-11  (G. Madec)  New organisation
+   !!            3.0  !  2008-04  (G. Madec)  leap-frog time stepping done in trazdf
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_zdf_exp  : compute the tracer the vertical diffusion trend using a
+   !!                  split-explicit time stepping and provide the after tracer
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE domvvl          ! variablevolume levels
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE zdf_oce         ! ocean vertical physics
+   USE zdfddm          ! ocean vertical physics: double diffusion
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_zdf_exp   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA  3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_zdf_exp( kt, p2dt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_zdf_exp  ***
+      !!                   
+      !! ** Purpose :   Compute the after tracer fields due to the vertical
+      !!      tracer mixing alone, and then due to the whole tracer trend.
+      !!
+      !! ** Method  : - The after tracer fields due to the vertical diffusion
+      !!      of tracers alone is given by:
+      !!                zwx = tb + p2dt difft
+      !!      where difft = dz( avt dz(tb) ) = 1/e3t dk+1( avt/e3w dk(tb) )
+      !!           (if lk_zdfddm=T use avs on salinity instead of avt)
+      !!      difft is evaluated with an Euler split-explit scheme using a
+      !!      no flux boundary condition at both surface and bottomi boundaries.
+      !!      (N.B. bottom condition is applied through the masked field avt).
+      !!              - the after tracer fields due to the whole trend is 
+      !!      obtained in leap-frog environment by :
+      !!          ta = zwx + p2dt ta
+      !!              - in case of variable level thickness (lk_vvl=T) the 
+      !!     the leap-frog is applied on thickness weighted tracer. That is:
+      !!          ta = [ tb*e3tb + e3tn*( zwx - tb + p2dt ta ) ] / e3tn
+      !!
+      !! ** Action : - after tracer fields (ta,sa) 
+      !!---------------------------------------------------------------------
+      INTEGER , INTENT(in)                 ::   kt     ! ocean time-step index
+      REAL(wp), INTENT(in), DIMENSION(jpk) ::   p2dt   ! vertical profile of tracer time-step
+      !!
+      INTEGER  ::   ji, jj, jk, jl            ! dummy loop indices
+      REAL(wp) ::   zlavmr, zave3r, ze3tr     ! temporary scalars
+      REAL(wp) ::   zta, zsa, ze3tb           ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwx, zwy, zwz, zww   ! 3D workspace
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_zdf_exp : explicit vertical mixing'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      ! Initializations
+      ! ---------------
+      zlavmr = 1. / float( nn_zdfexp )                           ! Local constant
+      !
+      zwy(:,:, 1 ) = 0.e0        ;   zww(:,:, 1 ) = 0.e0        ! surface boundary conditions: no flux
+      zwy(:,:,jpk) = 0.e0        ;   zww(:,:,jpk) = 0.e0        ! bottom  boundary conditions: no flux
+      !
+      zwx(:,:,:)   = tb(:,:,:)   ;   zwz(:,:,:)   = sb(:,:,:)   ! zwx and zwz arrays set to before tracer values
+
+      ! Split-explicit loop  (after tracer due to the vertical diffusion alone)
+      ! -------------------
+      !
+      DO jl = 1, nn_zdfexp
+         !                     ! first vertical derivative
+         DO jk = 2, jpk
+            DO jj = 2, jpjm1 
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zave3r = 1.e0 / fse3w_n(ji,jj,jk) 
+                  zwy(ji,jj,jk) =   avt(ji,jj,jk) * ( zwx(ji,jj,jk-1) - zwx(ji,jj,jk) ) * zave3r
+                  zww(ji,jj,jk) = fsavs(ji,jj,jk) * ( zwz(ji,jj,jk-1) - zwz(ji,jj,jk) ) * zave3r
+               END DO
+            END DO
+         END DO
+         !
+         DO jk = 1, jpkm1      ! second vertical derivative   ==> tracer at kt+l*2*rdt/nn_zdfexp
+            DO jj = 2, jpjm1 
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ze3tr = zlavmr / fse3t_n(ji,jj,jk)
+                  zwx(ji,jj,jk) = zwx(ji,jj,jk) + p2dt(jk) * ( zwy(ji,jj,jk) - zwy(ji,jj,jk+1) ) * ze3tr
+                  zwz(ji,jj,jk) = zwz(ji,jj,jk) + p2dt(jk) * ( zww(ji,jj,jk) - zww(ji,jj,jk+1) ) * ze3tr
+               END DO
+            END DO
+         END DO
+         !
+      END DO
+
+      ! After tracer due to all trends
+      ! ------------------------------
+      IF( lk_vvl ) THEN          ! variable level thickness : leap-frog on tracer*e3t
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1 
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ze3tb = fse3t_b(ji,jj,jk) / fse3t(ji,jj,jk)                          ! before e3t
+                  zta   = zwx(ji,jj,jk) - tb(ji,jj,jk) + p2dt(jk) * ta(ji,jj,jk)       ! total trends * 2*rdt
+                  zsa   = zwz(ji,jj,jk) - sb(ji,jj,jk) + p2dt(jk) * sa(ji,jj,jk)     
+                  ta(ji,jj,jk) = (  ze3tb * tb(ji,jj,jk) + zta  ) * tmask(ji,jj,jk)
+                  sa(ji,jj,jk) = (  ze3tb * sb(ji,jj,jk) + zsa  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ELSE                       ! fixed level thickness : leap-frog on tracers
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1 
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ta(ji,jj,jk) = ( zwx(ji,jj,jk) + p2dt(jk) * ta(ji,jj,jk) ) * tmask(ji,jj,jk)
+                  sa(ji,jj,jk) = ( zwz(ji,jj,jk) + p2dt(jk) * sa(ji,jj,jk) ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE tra_zdf_exp
+
+   !!==============================================================================
+END MODULE trazdf_exp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_imp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 1844)
@@ -0,0 +1,366 @@
+MODULE trazdf_imp
+   !!======================================================================
+   !!                 ***  MODULE  trazdf_imp  ***
+   !! Ocean active tracers:  vertical component of the tracer mixing trend
+   !!======================================================================
+   !! History :  OPA  !  1990-10  (B. Blanke)  Original code
+   !!            7.0  !  1991-11  (G. Madec)
+   !!                 !  1992-06  (M. Imbard) correction on tracer trend loops
+   !!                 !  1996-01  (G. Madec) statement function for e3
+   !!                 !  1997-05  (G. Madec) vertical component of isopycnal
+   !!                 !  1997-07  (G. Madec) geopotential diffusion in s-coord
+   !!                 !  2000-08  (G. Madec) double diffusive mixing
+   !!   NEMO     1.0  !  2002-08  (G. Madec) F90: Free form and module
+   !!            2.0  !  2006-11  (G. Madec) New step reorganisation
+   !!            3.2  !  2009-03  (G. Madec)  heat and salt content trends
+   !!----------------------------------------------------------------------
+  
+   !!----------------------------------------------------------------------
+   !!   tra_zdf_imp : Update the tracer trend with the diagonal vertical  
+   !!                 part of the mixing tensor.
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldfslp          ! lateral physics: slope of diffusion
+   USE trdmod          ! ocean active tracers trends 
+   USE trdmod_oce      ! ocean variables trends
+   USE zdfddm          ! ocean vertical physics: double diffusion
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE domvvl          ! variable volume
+   USE ldftra          ! lateral mixing type
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_zdf_imp   !  routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "zdfddm_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+   
+   SUBROUTINE tra_zdf_imp( kt, p2dt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_zdf_imp  ***
+      !!
+      !! ** Purpose :   Compute the trend due to the vertical tracer diffusion
+      !!     including the vertical component of lateral mixing (only for 2nd
+      !!     order operator, for fourth order it is already computed and add
+      !!     to the general trend in traldf.F) and add it to the general trend
+      !!     of the tracer equations.
+      !!
+      !! ** Method  :   The vertical component of the lateral diffusive trends
+      !!      is provided by a 2nd order operator rotated along neutral or geo-
+      !!      potential surfaces to which an eddy induced advection can be 
+      !!      added. It is computed using before fields (forward in time) and 
+      !!      isopycnal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      Second part: vertical trend associated with the vertical physics
+      !!      ===========  (including the vertical flux proportional to dk[t]
+      !!                  associated with the lateral mixing, through the
+      !!                  update of avt)
+      !!      The vertical diffusion of tracers (t & s) is given by:
+      !!             difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(t) )
+      !!      It is computed using a backward time scheme (t=ta).
+      !!      Surface and bottom boundary conditions: no diffusive flux on
+      !!      both tracers (bottom, applied through the masked field avt).
+      !!      Add this trend to the general trend ta,sa :
+      !!         ta = ta + dz( avt dz(t) )
+      !!         (sa = sa + dz( avs dz(t) ) if lk_zdfddm=T )
+      !!
+      !!      Third part: recover avt resulting from the vertical physics
+      !!      ==========  alone, for further diagnostics (for example to
+      !!                  compute the turbocline depth in zdfmxl.F90).
+      !!         avt = zavt
+      !!         (avs = zavs if lk_zdfddm=T )
+      !!
+      !! ** Action  : - Update (ta,sa) with before vertical diffusion trend
+      !!
+      !!---------------------------------------------------------------------
+      USE oce    , ONLY :   zwd   => ua   ! ua used as workspace
+      USE oce    , ONLY :   zws   => va   ! va  -          -
+      !!
+      INTEGER                 , INTENT(in) ::   kt     ! ocean time-step index
+      REAL(wp), DIMENSION(jpk), INTENT(in) ::   p2dt   ! vertical profile of tracer time-step
+      !!
+      INTEGER  ::   ji, jj, jk            ! dummy loop indices
+      REAL(wp) ::   zavi, zrhs, znvvl     ! temporary scalars
+      REAL(wp) ::   ze3tb, ze3tn, ze3ta   ! variable vertical scale factors
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwi, zwt, zavsi   ! workspace arrays
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) 'tra_zdf_imp : implicit vertical mixing'
+         IF(lwp)WRITE(numout,*) '~~~~~~~~~~~ '
+         zavi = 0.e0      ! avoid warning at compilation phase when lk_ldfslp=F
+      ENDIF
+
+      ! I. Local initialization
+      ! -----------------------
+      zwd  (1,:, : ) = 0.e0     ;     zwd  (jpi,:,:) = 0.e0
+      zws  (1,:, : ) = 0.e0     ;     zws  (jpi,:,:) = 0.e0
+      zwi  (1,:, : ) = 0.e0     ;     zwi  (jpi,:,:) = 0.e0
+      zwt  (1,:, : ) = 0.e0     ;     zwt  (jpi,:,:) = 0.e0
+      zavsi(1,:, : ) = 0.e0     ;     zavsi(jpi,:,:) = 0.e0
+      zwt  (:,:,jpk) = 0.e0     ;     zwt  ( : ,:,1) = 0.e0
+      zavsi(:,:,jpk) = 0.e0     ;     zavsi( : ,:,1) = 0.e0
+
+      ! I.1 Variable volume : to take into account vertical variable vertical scale factors
+      ! -------------------
+      IF( lk_vvl ) THEN   ;    znvvl = 1.
+      ELSE                ;    znvvl = 0.e0
+      ENDIF
+
+      ! II. Vertical trend associated with the vertical physics
+      ! =======================================================
+      !     (including the vertical flux proportional to dk[t] associated
+      !      with the lateral mixing, through the avt update)
+      !     dk[ avt dk[ (t,s) ] ] diffusive trends
+
+
+      ! II.0 Matrix construction
+      ! ------------------------
+
+#if defined key_ldfslp
+      ! update and save of avt (and avs if double diffusive mixing)
+      IF( l_traldf_rot ) THEN
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zavi = fsahtw(ji,jj,jk)                       &   ! vertical mixing coef. due to lateral mixing
+                     & * (  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
+                     &    + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
+                  zwt(ji,jj,jk) = avt(ji,jj,jk) + zavi              ! zwt=avt+zavi (total vertical mixing coef. on temperature)
+# if defined key_zdfddm
+                  zavsi(ji,jj,jk) = fsavs(ji,jj,jk) + zavi          ! dd mixing: zavsi = total vertical mixing coef. on salinity
+# endif
+               END DO
+            END DO
+         END DO
+      ELSE                         ! no rotation but key_ldfslp defined
+         zwt  (:,:,:) = avt(:,:,:)
+# if defined key_zdfddm
+         zavsi(:,:,:) = avs(:,:,:)       ! avs /= avt (double diffusion mixing)
+# endif
+      ENDIF   
+#else
+      ! No isopycnal diffusion
+      zwt(:,:,:) = avt(:,:,:)
+# if defined key_zdfddm
+      zavsi(:,:,:) = avs(:,:,:)
+# endif
+
+#endif
+
+      ! Diagonal, inferior, superior  (including the bottom boundary condition via avt masked)
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ze3ta =  ( 1. - znvvl )   &                            ! after scale factor at T-point
+                  &   +        znvvl    * fse3t_a(ji,jj,jk) 
+               ze3tn =    znvvl          &                            ! now   scale factor at T-point
+                  &   + ( 1. - znvvl ) * fse3t_n(ji,jj,jk)
+               zwi(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk  ) / ( ze3tn * fse3w(ji,jj,jk  ) )
+               zws(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk+1) / ( ze3tn * fse3w(ji,jj,jk+1) )
+               zwd(ji,jj,jk) = ze3ta - zwi(ji,jj,jk) - zws(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ze3ta = ( 1. - znvvl )        &                           ! after scale factor at T-point
+               &   +       znvvl      * fse3t_a(ji,jj,1) 
+            zwi(ji,jj,1) = 0.e0
+            zwd(ji,jj,1) = ze3ta - zws(ji,jj,1)
+         END DO
+      END DO
+
+
+      ! II.1. Vertical diffusion on t
+      ! ---------------------------
+
+      !! Matrix inversion from the first level
+      !!----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and lower triangular matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The second member is in 2d array zwy
+      !   The solution is in 2d array zwx
+      !   The 3d arry zwt is a work space array
+      !   zwy is used and then used as a work space array : its value is modified!
+
+      ! first recurrence:   Tk = Dk - Ik Sk-1 / Tk-1   (increasing k)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,1) = zwd(ji,jj,1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1)  /zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            ze3tb = ( 1. - znvvl ) + znvvl * fse3t_b(ji,jj,1)
+            ze3tn = ( 1. - znvvl ) + znvvl * fse3t(ji,jj,1)
+            ta(ji,jj,1) = ze3tb * tb(ji,jj,1) + p2dt(1) * ze3tn * ta(ji,jj,1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ze3tb = ( 1. - znvvl ) + znvvl * fse3t_b(ji,jj,jk)
+               ze3tn = ( 1. - znvvl ) + znvvl * fse3t  (ji,jj,jk)
+               zrhs = ze3tb * tb(ji,jj,jk) + p2dt(jk) * ze3tn * ta(ji,jj,jk)   ! zrhs=right hand side 
+               ta(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * ta(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk
+      ! Save the masked temperature after in ta
+      ! (c a u t i o n:  temperature not its trend, Leap-frog scheme done it will not be done in tranxt)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            ta(ji,jj,jpkm1) = ta(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) * tmask(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ta(ji,jj,jk) = ( ta(ji,jj,jk) - zws(ji,jj,jk) * ta(ji,jj,jk+1) ) / zwt(ji,jj,jk) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! II.2 Vertical diffusion on salinity
+      ! -----------------------------------
+
+#if defined key_zdfddm
+      ! Rebuild the Matrix as avt /= avs
+
+      ! Diagonal, inferior, superior  (including the bottom boundary condition via avs masked)
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ze3ta =  ( 1. - znvvl )                        &         ! after scale factor at T-point
+                  &   +        znvvl   * fse3t_a(ji,jj,jk)           
+               ze3tn =    znvvl                               &         ! now   scale factor at T-point
+                  &   + ( 1. - znvvl ) * fse3t_n(ji,jj,jk)
+               zwi(ji,jj,jk) = - p2dt(jk) * zavsi(ji,jj,jk  ) / ( ze3tn * fse3w(ji,jj,jk  ) )
+               zws(ji,jj,jk) = - p2dt(jk) * zavsi(ji,jj,jk+1) / ( ze3tn * fse3w(ji,jj,jk+1) )
+               zwd(ji,jj,jk) = ze3ta - zwi(ji,jj,jk) - zws(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ze3ta = ( 1. - znvvl ) + znvvl * fse3t_a(ji,jj,1)
+            zwi(ji,jj,1) = 0.e0
+            zwd(ji,jj,1) = ze3ta - zws(ji,jj,1)
+         END DO
+      END DO
+#endif
+
+
+      !! Matrix inversion from the first level
+      !!----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and lower triangular
+      !   matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The second member is in 2d array zwy
+      !   The solution is in 2d array zwx
+      !   The 3d arry zwt is a work space array
+      !   zwy is used and then used as a work space array : its value is modified!
+
+      ! first recurrence:   Tk = Dk - Ik Sk-1 / Tk-1   (increasing k)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,1) = zwd(ji,jj,1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1)  /zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            ze3tb = ( 1. - znvvl )   &                                           ! before scale factor at T-point
+               &   +  znvvl       * fse3t_b(ji,jj,1)
+            ze3tn = ( 1. - znvvl ) + znvvl * fse3t  (ji,jj,1)                    ! now    scale factor at T-point
+            sa(ji,jj,1) = ze3tb * sb(ji,jj,1) + p2dt(1) * ze3tn * sa(ji,jj,1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ze3tb = ( 1. - znvvl )   &                                        ! before scale factor at T-point
+                  &   +  znvvl       * fse3t_b(ji,jj,jk)
+               ze3tn = ( 1. - znvvl ) + znvvl * fse3t  (ji,jj,jk)                ! now    scale factor at T-point
+               zrhs = ze3tb * sb(ji,jj,jk) + p2dt(jk) * ze3tn * sa(ji,jj,jk)     ! zrhs=right hand side
+               sa(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *sa(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk
+      ! Save the masked temperature after in ta
+      ! (c a u t i o n:  temperature not its trend, Leap-frog scheme done it will not be done in tranxt)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            sa(ji,jj,jpkm1) = sa(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) * tmask(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               sa(ji,jj,jk) = ( sa(ji,jj,jk) - zws(ji,jj,jk) * sa(ji,jj,jk+1) ) / zwt(ji,jj,jk) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tra_zdf_imp
+
+   !!==============================================================================
+END MODULE trazdf_imp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/zpshde.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 1844)
@@ -0,0 +1,241 @@
+MODULE zpshde
+   !!==============================================================================
+   !!                       ***  MODULE zpshde   ***
+   !! z-coordinate - partial step : Horizontal Derivative
+   !!==============================================================================
+   
+   !!----------------------------------------------------------------------
+   !!   zps_hde      :  Horizontal DErivative of T, S and rd at the last
+   !!                   ocean level (Z-coord. with Partial Steps)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space domain variables
+   USE oce             ! ocean dynamics and tracers variables
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE eosbn2          ! ocean equation of state
+   USE lbclnk          ! lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC zps_hde          ! routine called by step.F90
+
+   !! * module variables
+   INTEGER, DIMENSION(jpi,jpj) ::   &
+      mbatu, mbatv      ! bottom ocean level index at U- and V-points
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE zps_hde ( kt, ptem, psal, prd ,   &
+                            pgtu, pgsu, pgru,   &
+                            pgtv, pgsv, pgrv  )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE zps_hde  ***
+      !!                    
+      !! ** Purpose :   Compute the horizontal derivative of T, S and rd
+      !!      at u- and v-points with a linear interpolation for z-coordinate
+      !!      with partial steps.
+      !!
+      !! ** Method  :   In z-coord with partial steps, scale factors on last 
+      !!      levels are different for each grid point, so that T, S and rd 
+      !!      points are not at the same depth as in z-coord. To have horizontal
+      !!      gradients again, we interpolate T and S at the good depth : 
+      !!      Linear interpolation of T, S   
+      !!         Computation of di(tb) and dj(tb) by vertical interpolation:
+      !!          di(t) = t~ - t(i,j,k) or t(i+1,j,k) - t~
+      !!          dj(t) = t~ - t(i,j,k) or t(i,j+1,k) - t~
+      !!         This formulation computes the two cases:
+      !!                 CASE 1                   CASE 2  
+      !!         k-1  ___ ___________   k-1   ___ ___________
+      !!                    Ti  T~                  T~  Ti+1
+      !!                  _____                        _____
+      !!         k        |   |Ti+1     k           Ti |   |
+      !!                  |   |____                ____|   |
+      !!              ___ |   |   |           ___  |   |   |
+      !!                  
+      !!      case 1->   e3w(i+1) >= e3w(i) ( and e3w(j+1) >= e3w(j) ) then
+      !!          t~ = t(i+1,j  ,k) + (e3w(i+1) - e3w(i)) * dk(Ti+1)/e3w(i+1)
+      !!        ( t~ = t(i  ,j+1,k) + (e3w(j+1) - e3w(j)) * dk(Tj+1)/e3w(j+1)  )
+      !!          or
+      !!      case 2->   e3w(i+1) <= e3w(i) ( and e3w(j+1) <= e3w(j) ) then
+      !!          t~ = t(i,j,k) + (e3w(i) - e3w(i+1)) * dk(Ti)/e3w(i )
+      !!        ( t~ = t(i,j,k) + (e3w(j) - e3w(j+1)) * dk(Tj)/e3w(j ) )
+      !!          Idem for di(s) and dj(s)          
+      !!
+      !!      For rho, we call eos_insitu_2d which will compute rd~(t~,s~) at 
+      !!      the good depth zh from interpolated T and S for the different
+      !!      formulation of the equation of state (eos).
+      !!      Gradient formulation for rho :
+      !!          di(rho) = rd~ - rd(i,j,k) or rd (i+1,j,k) - rd~
+      !!
+      !! ** Action  : - pgtu, pgsu, pgru: horizontal gradient of T, S
+      !!                and rd at U-points 
+      !!              - pgtv, pgsv, pgrv: horizontal gradient of T, S
+      !!                and rd at V-points 
+      !!
+      !! History :
+      !!   8.5  !  02-04  (A. Bozec)  Original code
+      !!   8.5  !  02-08  (G. Madec E. Durand)  Optimization and Free form
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
+         ptem, psal, prd            ! 3D T, S and rd fields
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( out ) ::   &
+         pgtu, pgsu, pgru,       &  ! horizontal grad. of T, S and rd at u- 
+         pgtv, pgsv, pgrv           ! and v-points of the partial step level
+
+      !! * Local declarations
+      INTEGER ::   ji, jj,       &  ! Dummy loop indices
+                   iku,ikv          ! partial step level at u- and v-points
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zti, ztj, zsi, zsj,     &  ! interpolated value of T, S 
+         zri, zrj,               &  ! and rd
+         zhgi, zhgj                 ! depth of interpolation for eos2d
+      REAL(wp) ::   &
+         ze3wu, ze3wv,           &  ! temporary scalars
+         zmaxu1, zmaxu2,         &  !    "         "
+         zmaxv1, zmaxv2             !    "         "
+
+      ! Initialization (first time-step only): compute mbatu and mbatv
+      IF( kt == nit000 ) THEN
+         mbatu(:,:) = 0
+         mbatv(:,:) = 0
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               mbatu(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1, 2 )
+               mbatv(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1, 2 )
+            END DO
+         END DO
+         zti(:,:) = FLOAT( mbatu(:,:) )
+         ztj(:,:) = FLOAT( mbatv(:,:) )
+         ! lateral boundary conditions: T-point, sign unchanged
+         CALL lbc_lnk( zti , 'U', 1. )
+         CALL lbc_lnk( ztj , 'V', 1. )
+         mbatu(:,:) = MAX( INT( zti(:,:) ), 2 )
+         mbatv(:,:) = MAX( INT( ztj(:,:) ), 2 )
+      ENDIF
+      
+
+      ! Interpolation of T and S at the last ocean level
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            ! last level
+            iku = mbatu(ji,jj)
+            ikv = mbatv(ji,jj)
+
+            ze3wu  = fse3w(ji+1,jj  ,iku) - fse3w(ji,jj,iku)
+            ze3wv  = fse3w(ji  ,jj+1,ikv) - fse3w(ji,jj,ikv)
+            zmaxu1 =  ze3wu / fse3w(ji+1,jj  ,iku)
+            zmaxu2 = -ze3wu / fse3w(ji  ,jj  ,iku)
+            zmaxv1 =  ze3wv / fse3w(ji  ,jj+1,ikv)
+            zmaxv2 = -ze3wv / fse3w(ji  ,jj  ,ikv)
+
+            ! i- direction
+
+            IF( ze3wu >= 0. ) THEN      ! case 1
+               ! interpolated values of T and S
+               zti(ji,jj) = ptem(ji+1,jj,iku) + zmaxu1 * ( ptem(ji+1,jj,iku-1) - ptem(ji+1,jj,iku) )
+               zsi(ji,jj) = psal(ji+1,jj,iku) + zmaxu1 * ( psal(ji+1,jj,iku-1) - psal(ji+1,jj,iku) )
+               ! depth of the partial step level
+               zhgi(ji,jj) = fsdept(ji,jj,iku)
+               ! gradient of T and S
+               pgtu(ji,jj) = umask(ji,jj,1) * ( zti(ji,jj) - ptem(ji,jj,iku) )
+               pgsu(ji,jj) = umask(ji,jj,1) * ( zsi(ji,jj) - psal(ji,jj,iku) )
+
+            ELSE                        ! case 2
+               ! interpolated values of T and S
+               zti(ji,jj) = ptem(ji,jj,iku) + zmaxu2 * ( ptem(ji,jj,iku-1) - ptem(ji,jj,iku) )
+               zsi(ji,jj) = psal(ji,jj,iku) + zmaxu2 * ( psal(ji,jj,iku-1) - psal(ji,jj,iku) )
+               ! depth of the partial step level
+               zhgi(ji,jj) = fsdept(ji+1,jj,iku)
+               ! gradient of T and S 
+               pgtu(ji,jj) = umask(ji,jj,1) * ( ptem(ji+1,jj,iku) - zti (ji,jj) )
+               pgsu(ji,jj) = umask(ji,jj,1) * ( psal(ji+1,jj,iku) - zsi (ji,jj) )
+            ENDIF
+
+            ! j- direction
+
+            IF( ze3wv >= 0. ) THEN      ! case 1
+               ! interpolated values of T and S
+               ztj(ji,jj) = ptem(ji,jj+1,ikv) + zmaxv1 * ( ptem(ji,jj+1,ikv-1) - ptem(ji,jj+1,ikv) )
+               zsj(ji,jj) = psal(ji,jj+1,ikv) + zmaxv1 * ( psal(ji,jj+1,ikv-1) - psal(ji,jj+1,ikv) )
+               ! depth of the partial step level
+               zhgj(ji,jj) = fsdept(ji,jj,ikv) 
+               ! gradient of T and S
+               pgtv(ji,jj) = vmask(ji,jj,1) * ( ztj(ji,jj) - ptem(ji,jj,ikv) )
+               pgsv(ji,jj) = vmask(ji,jj,1) * ( zsj(ji,jj) - psal(ji,jj,ikv) )
+
+            ELSE                        ! case 2
+               ! interpolated values of T and S
+               ztj(ji,jj) = ptem(ji,jj,ikv) + zmaxv2 * ( ptem(ji,jj,ikv-1) - ptem(ji,jj,ikv) )
+               zsj(ji,jj) = psal(ji,jj,ikv) + zmaxv2 * ( psal(ji,jj,ikv-1) - psal(ji,jj,ikv) ) 
+               ! depth of the partial step level
+               zhgj(ji,jj) = fsdept(ji,jj+1,ikv) 
+               ! gradient of T and S
+               pgtv(ji,jj) = vmask(ji,jj,1) * ( ptem(ji,jj+1,ikv) - ztj(ji,jj) )
+               pgsv(ji,jj) = vmask(ji,jj,1) * ( psal(ji,jj+1,ikv) - zsj(ji,jj) )
+            ENDIF
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! Compute interpolated rd from zti, zsi, ztj, zsj for the 2 cases at the depth of the partial
+      ! step and store it in  zri, zrj for each  case
+      CALL eos( zti, zsi, zhgi, zri )
+      CALL eos( ztj, zsj, zhgj, zrj )
+
+
+      ! Gradient of density at the last level 
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
+# else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+# endif
+            iku = mbatu(ji,jj)
+            ikv = mbatv(ji,jj)
+            ze3wu  = fse3w(ji+1,jj  ,iku) - fse3w(ji,jj,iku)
+            ze3wv  = fse3w(ji  ,jj+1,ikv) - fse3w(ji,jj,ikv)
+            IF( ze3wu >= 0. ) THEN    ! i-direction: case 1
+               pgru(ji,jj) = umask(ji,jj,1) * ( zri(ji,jj) - prd(ji,jj,iku) )
+            ELSE                      ! i-direction: case 2
+               pgru(ji,jj) = umask(ji,jj,1) * ( prd(ji+1,jj,iku) - zri(ji,jj) )
+            ENDIF
+            IF( ze3wv >= 0. ) THEN    ! j-direction: case 1
+               pgrv(ji,jj) = vmask(ji,jj,1) * ( zrj(ji,jj) - prd(ji,jj,ikv) )  
+            ELSE                      ! j-direction: case 2
+               pgrv(ji,jj) = vmask(ji,jj,1) * ( prd(ji,jj+1,ikv) - zrj(ji,jj) )
+            ENDIF
+# if ! defined key_vectopt_loop
+         END DO
+# endif
+      END DO
+
+      ! Lateral boundary conditions on each gradient
+      CALL lbc_lnk( pgtu , 'U', -1. )   ;   CALL lbc_lnk( pgtv , 'V', -1. )
+      CALL lbc_lnk( pgsu , 'U', -1. )   ;   CALL lbc_lnk( pgsv , 'V', -1. )
+      CALL lbc_lnk( pgru , 'U', -1. )   ;   CALL lbc_lnk( pgrv , 'V', -1. )
+
+   END SUBROUTINE zps_hde
+
+   !!======================================================================
+END MODULE zpshde
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp.F90	(revision 1844)
@@ -0,0 +1,734 @@
+MODULE trdicp
+   !!======================================================================
+   !!                       ***  MODULE  trdicp  ***
+   !! Ocean diagnostics:  ocean tracers and dynamic trends
+   !!=====================================================================
+   !! History :       !  91-12 (G. Madec)
+   !!                 !  92-06 (M. Imbard) add time step frequency
+   !!                 !  96-01 (G. Madec)  terrain following coordinates
+   !!            8.5  !  02-06 (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-08 (C. Talandier) New trends organization
+   !!----------------------------------------------------------------------
+#if  defined key_trdtra   ||   defined key_trddyn   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trdtra'  or                  active tracers trends diagnostics
+   !!   'key_trddyn'                            momentum trends diagnostics
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   trd_icp          : compute the basin averaged properties for tra/dyn 
+   !!   trd_dwr          : print dynmaic trends in ocean.output file
+   !!   trd_twr          : print tracers trends in ocean.output file
+   !!   trd_icp_init     : initialization step
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE trdmod_oce      ! ocean variables trends
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distibuted memory computing library
+   USE eosbn2          ! equation of state
+   USE phycst          ! physical constants
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE trd_icp
+      MODULE PROCEDURE trd_2d, trd_3d
+   END INTERFACE
+
+   PUBLIC   trd_icp       ! called by trdmod.F90
+   PUBLIC   trd_dwr       ! called by step.F90
+   PUBLIC   trd_twr       ! called by step.F90
+   PUBLIC   trd_icp_init  ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trd_2d( ptrd2dx, ptrd2dy, ktrd , ctype, clpas )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_2d  ***
+      !! 
+      !! ** Purpose : verify the basin averaged properties of tracers and/or
+      !!              momentum equations at every time step frequency nn_trd.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ptrd2dx             ! Temperature or U trend 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ptrd2dy             ! Salinity    or V trend
+      INTEGER                     , INTENT(in   ) ::   ktrd                ! tracer trend index
+      CHARACTER(len=3)            , INTENT(in   ) ::   ctype               ! momentum ('DYN') or tracers ('TRA') trends
+      CHARACTER(len=3)            , INTENT(in   ), OPTIONAL ::   clpas     ! number of passage
+      !!
+      INTEGER  ::   ji, jj                                                 ! loop indices
+      CHARACTER(len=3) ::   cpas                                           ! number of passage
+      REAL(wp) ::   zmsku, zbtu, zbt                                       ! temporary scalars
+      REAL(wp) ::   zmskv, zbtv                                            !    "         "
+      !!----------------------------------------------------------------------
+
+      ! Control of optional arguments
+      cpas = 'fst'
+      IF( PRESENT(clpas) )  cpas = clpas
+
+      ! 1. Mask trends
+      ! --------------
+
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zmsku = tmask_i(ji+1,jj  ) * tmask_i(ji,jj) * umask(ji,jj,1)
+               zmskv = tmask_i(ji  ,jj+1) * tmask_i(ji,jj) * vmask(ji,jj,1)
+               ptrd2dx(ji,jj) = ptrd2dx(ji,jj) * zmsku
+               ptrd2dy(ji,jj) = ptrd2dy(ji,jj) * zmskv
+            END DO
+         END DO
+         ptrd2dx(jpi, : ) = 0.e0      ;      ptrd2dy(jpi, : ) = 0.e0
+         ptrd2dx( : ,jpj) = 0.e0      ;      ptrd2dy( : ,jpj) = 0.e0
+         !
+      CASE( 'TRA' )              ! Tracers
+         ptrd2dx(:,:) = ptrd2dx(:,:) * tmask_i(:,:)
+         ptrd2dy(:,:) = ptrd2dy(:,:) * tmask_i(:,:)
+         !
+      END SELECT
+      
+      ! 2. Basin averaged tracer/momentum trends
+      ! ----------------------------------------
+
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum
+         umo(ktrd) = 0.e0
+         vmo(ktrd) = 0.e0
+         !
+         SELECT CASE( ktrd )
+         !
+         CASE( jpdyn_trd_swf )         ! surface forcing
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  umo(ktrd) = umo(ktrd) + ptrd2dx(ji,jj) * e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,1)
+                  vmo(ktrd) = vmo(ktrd) + ptrd2dy(ji,jj) * e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,1)
+               END DO
+            END DO
+            !
+         END SELECT
+         !
+      CASE( 'TRA' )              ! Tracers
+         IF( cpas == 'fst' )   THEN
+            tmo(ktrd) = 0.e0
+            smo(ktrd) = 0.e0
+         ENDIF
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,1)
+               tmo(ktrd) =  tmo(ktrd) + ptrd2dx(ji,jj) * zbt
+               smo(ktrd) =  smo(ktrd) + ptrd2dy(ji,jj) * zbt
+            END DO
+         END DO
+         !
+      END SELECT
+      
+      ! 3. Basin averaged tracer/momentum square trends
+      ! ----------------------------------------------
+      ! c a u t i o n: field now
+      
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum
+         hke(ktrd) = 0.e0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zbtu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,1)
+               zbtv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,1)
+               hke(ktrd) = hke(ktrd)   &
+               &   + un(ji,jj,1) * ptrd2dx(ji,jj) * zbtu &
+               &   + vn(ji,jj,1) * ptrd2dy(ji,jj) * zbtv
+            END DO
+         END DO
+         !
+      CASE( 'TRA' )              ! Tracers
+         IF( cpas == 'fst' )   THEN
+            t2(ktrd) = 0.e0
+            s2(ktrd) = 0.e0
+         ENDIF
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,1)
+               t2(ktrd) = t2(ktrd) + ptrd2dx(ji,jj) * zbt * tn(ji,jj,1)
+               s2(ktrd) = s2(ktrd) + ptrd2dy(ji,jj) * zbt * sn(ji,jj,1)
+            END DO
+         END DO
+         !      
+      END SELECT
+      !
+   END SUBROUTINE trd_2d
+
+
+   SUBROUTINE trd_3d( ptrd3dx, ptrd3dy, ktrd, ctype, clpas )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_3d  ***
+      !! 
+      !! ** Purpose : verify the basin averaged properties of tracers and/or
+      !!              momentum equations at every time step frequency nn_trd.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptrd3dx            ! Temperature or U trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptrd3dy            ! Salinity    or V trend
+      INTEGER,                          INTENT(in   ) ::   ktrd               ! momentum or tracer trend index
+      CHARACTER(len=3),                 INTENT(in   ) ::   ctype              ! momentum ('DYN') or tracers ('TRA') trends
+      CHARACTER(len=3),                 INTENT(in   ), OPTIONAL ::   clpas    ! number of passage
+      !!
+      INTEGER ::   ji, jj, jk
+      CHARACTER(len=3) ::   cpas                                              ! number of passage
+      REAL(wp) ::   zbt, zbtu, zbtv, zmsku, zmskv                             ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      ! Control of optional arguments
+      cpas = 'fst'
+      IF( PRESENT(clpas) )  cpas = clpas
+
+      ! 1. Mask the trends
+      ! ------------------
+
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum        
+         DO jk = 1, jpk
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zmsku = tmask_i(ji+1,jj  ) * tmask_i(ji,jj) * umask(ji,jj,jk)
+                  zmskv = tmask_i(ji  ,jj+1) * tmask_i(ji,jj) * vmask(ji,jj,jk)
+                  ptrd3dx(ji,jj,jk) = ptrd3dx(ji,jj,jk) * zmsku
+                  ptrd3dy(ji,jj,jk) = ptrd3dy(ji,jj,jk) * zmskv
+               END DO
+            END DO
+         END DO
+         ptrd3dx(jpi, : ,:) = 0.e0      ;      ptrd3dy(jpi, : ,:) = 0.e0
+         ptrd3dx( : ,jpj,:) = 0.e0      ;      ptrd3dy( : ,jpj,:) = 0.e0
+         !
+      CASE( 'TRA' )              ! Tracers
+         DO jk = 1, jpk
+            ptrd3dx(:,:,jk) = ptrd3dx(:,:,jk) * tmask(:,:,jk) * tmask_i(:,:)
+            ptrd3dy(:,:,jk) = ptrd3dy(:,:,jk) * tmask(:,:,jk) * tmask_i(:,:)
+         END DO
+         !
+      END SELECT   
+
+      ! 2. Basin averaged tracer/momentum trends
+      ! ----------------------------------------
+      
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum
+         umo(ktrd) = 0.e0
+         vmo(ktrd) = 0.e0
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zbtu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+                  zbtv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+                  umo(ktrd) = umo(ktrd) + ptrd3dx(ji,jj,jk) * zbtu
+                  vmo(ktrd) = vmo(ktrd) + ptrd3dy(ji,jj,jk) * zbtv
+               END DO
+            END DO
+         END DO
+         !
+      CASE( 'TRA' )              ! Tracers
+         IF( cpas == 'fst' )   THEN
+            tmo(ktrd) = 0.e0
+            smo(ktrd) = 0.e0
+         ENDIF
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) 
+                  tmo(ktrd) =  tmo(ktrd) + ptrd3dx(ji,jj,jk) * zbt
+                  smo(ktrd) =  smo(ktrd) + ptrd3dy(ji,jj,jk) * zbt
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+
+      ! 3. Basin averaged tracer/momentum square trends
+      ! -----------------------------------------------
+      ! c a u t i o n: field now
+      
+      SELECT CASE( ctype )
+      !
+      CASE( 'DYN' )              ! Momentum
+         hke(ktrd) = 0.e0
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zbtu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+                  zbtv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+                  hke(ktrd) = hke(ktrd)   &
+                  &   + un(ji,jj,jk) * ptrd3dx(ji,jj,jk) * zbtu &
+                  &   + vn(ji,jj,jk) * ptrd3dy(ji,jj,jk) * zbtv
+               END DO
+            END DO
+         END DO
+         !
+      CASE( 'TRA' )              ! Tracers
+         IF( cpas == 'fst' )   THEN
+            t2(ktrd) = 0.e0
+            s2(ktrd) = 0.e0
+         ENDIF
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+                  t2(ktrd) = t2(ktrd) + ptrd3dx(ji,jj,jk) * zbt * tn(ji,jj,jk)
+                  s2(ktrd) = s2(ktrd) + ptrd3dy(ji,jj,jk) * zbt * sn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+      !
+   END SUBROUTINE trd_3d
+
+
+
+   SUBROUTINE trd_icp_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_icp_init  ***
+      !! 
+      !! ** Purpose :   Read the namtrd namelist
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zmskt
+#if  defined key_trddyn
+      REAL(wp) ::   zmsku, zmskv
+#endif
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trd_icp_init : integral constraints properties trends'
+         WRITE(numout,*) '~~~~~~~~~~~~~'
+      ENDIF
+
+      ! Total volume at t-points:
+      tvolt = 0.e0
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zmskt = tmask(ji,jj,jk) * tmask_i(ji,jj)
+               tvolt = tvolt + zmskt * e1t(ji,jj) *e2t(ji,jj) * fse3t(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( tvolt )   ! sum over the global domain
+
+      IF(lwp) WRITE(numout,*) '                total ocean volume at T-point   tvolt = ',tvolt
+
+#if  defined key_trddyn
+      ! Initialization of potential to kinetic energy conversion
+      rpktrd = 0.e0
+
+      ! Total volume at u-, v- points:
+      tvolu = 0.e0
+      tvolv = 0.e0
+
+      DO jk = 1, jpk
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zmsku = tmask_i(ji+1,jj  ) * tmask_i(ji,jj) * umask(ji,jj,jk)
+               zmskv = tmask_i(ji  ,jj+1) * tmask_i(ji,jj) * vmask(ji,jj,jk)
+               tvolu = tvolu + zmsku * e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
+               tvolv = tvolv + zmskv * e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( tvolu )   ! sums over the global domain
+      IF( lk_mpp )   CALL mpp_sum( tvolv )
+
+      IF(lwp) THEN
+         WRITE(numout,*) '                total ocean volume at U-point   tvolu = ',tvolu
+         WRITE(numout,*) '                total ocean volume at V-point   tvolv = ',tvolv
+      ENDIF
+#endif
+      !
+   END SUBROUTINE trd_icp_init
+
+
+   SUBROUTINE trd_dwr( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_dwr  ***
+      !! 
+      !! ** Purpose :  write dynamic trends in ocean.output 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt                                  ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   ze1e2w, zcof, zbe1ru, zbe2rv, zbtr, ztz, zth   !    "      scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zkepe, zkx, zky, zkz   ! temporary arrays
+      !!----------------------------------------------------------------------
+
+      ! I. Momentum trends
+      ! -------------------
+
+      IF( MOD(kt,nn_trd) == 0 .OR. kt == nit000 .OR. kt == nitend ) THEN
+
+         ! I.1 Conversion potential energy - kinetic energy
+         ! --------------------------------------------------
+         ! c a u t i o n here, trends are computed at kt+1 (now , but after the swap)
+
+         zkx(:,:,:)   = 0.e0
+         zky(:,:,:)   = 0.e0
+         zkz(:,:,:)   = 0.e0
+         zkepe(:,:,:) = 0.e0
+   
+         CALL eos( tn, sn, rhd, rhop )       ! now potential and in situ densities
+
+         ! Density flux at w-point
+         DO jk = 2, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ze1e2w = 0.5 * e1t(ji,jj) * e2t(ji,jj) * wn(ji,jj,jk) * tmask_i(ji,jj)
+                  zkz(ji,jj,jk) = ze1e2w / rau0 * ( rhop(ji,jj,jk) + rhop(ji,jj,jk-1) )
+               END DO
+            END DO
+         END DO
+         zkz(:,:,1) = 0.e0
+         
+         ! Density flux at u and v-points
+         DO jk = 1, jpk
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zcof   = 0.5 / rau0
+                  zbe1ru = zcof * e2u(ji,jj) * fse3u(ji,jj,jk) * un(ji,jj,jk)
+                  zbe2rv = zcof * e1v(ji,jj) * fse3v(ji,jj,jk) * vn(ji,jj,jk)
+                  zkx(ji,jj,jk) = zbe1ru * ( rhop(ji,jj,jk) + rhop(ji+1,jj,jk) )
+                  zky(ji,jj,jk) = zbe2rv * ( rhop(ji,jj,jk) + rhop(ji,jj+1,jk) )
+               END DO
+            END DO
+         END DO
+         
+         ! Density flux divergence at t-point
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ztz = - zbtr * (    zkz(ji,jj,jk) - zkz(ji,jj,jk+1) )
+                  zth = - zbtr * (  ( zkx(ji,jj,jk) - zkx(ji-1,jj,jk) )   &
+                    &             + ( zky(ji,jj,jk) - zky(ji,jj-1,jk) )  )
+                  zkepe(ji,jj,jk) = (zth + ztz) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         zkepe( : , : ,jpk) = 0.e0
+         zkepe( : ,jpj, : ) = 0.e0
+         zkepe(jpi, : , : ) = 0.e0
+
+         ! I.2 Basin averaged kinetic energy trend
+         ! ----------------------------------------
+         peke = 0.e0
+         DO jk = 1,jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  peke = peke + zkepe(ji,jj,jk) * grav * fsdept(ji,jj,jk)   &
+                     &                     * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! I.3 Sums over the global domain
+         ! ---------------------------------
+         IF( lk_mpp ) THEN
+            CALL mpp_sum( peke )
+            CALL mpp_sum( umo , jptot_dyn )
+            CALL mpp_sum( vmo , jptot_dyn )
+            CALL mpp_sum( hke , jptot_dyn )
+         ENDIF
+
+         ! I.2 Print dynamic trends in the ocean.output file
+         ! --------------------------------------------------
+
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9500) kt
+            WRITE (numout,9501) umo(jpicpd_hpg) / tvolu, vmo(jpicpd_hpg) / tvolv
+            WRITE (numout,9502) umo(jpicpd_keg) / tvolu, vmo(jpicpd_keg) / tvolv
+            WRITE (numout,9503) umo(jpicpd_rvo) / tvolu, vmo(jpicpd_rvo) / tvolv
+            WRITE (numout,9504) umo(jpicpd_pvo) / tvolu, vmo(jpicpd_pvo) / tvolv
+            WRITE (numout,9505) umo(jpicpd_ldf) / tvolu, vmo(jpicpd_ldf) / tvolv
+            WRITE (numout,9506) umo(jpicpd_had) / tvolu, vmo(jpicpd_had) / tvolv
+            WRITE (numout,9507) umo(jpicpd_zad) / tvolu, vmo(jpicpd_zad) / tvolv
+            WRITE (numout,9508) umo(jpicpd_zdf) / tvolu, vmo(jpicpd_zdf) / tvolv
+            WRITE (numout,9509) umo(jpicpd_spg) / tvolu, vmo(jpicpd_spg) / tvolv
+            WRITE (numout,9510) umo(jpicpd_swf) / tvolu, vmo(jpicpd_swf) / tvolv
+            WRITE (numout,9511) umo(jpicpd_dat) / tvolu, vmo(jpicpd_dat) / tvolv
+            WRITE (numout,9512) umo(jpicpd_bfr) / tvolu, vmo(jpicpd_bfr) / tvolv
+            WRITE (numout,9513)
+            WRITE (numout,9514)                                                 &
+            &     (  umo(jpicpd_hpg) + umo(jpicpd_keg) + umo(jpicpd_rvo) + umo(jpicpd_pvo) + umo(jpicpd_ldf)   &
+            &      + umo(jpicpd_had) + umo(jpicpd_zad) + umo(jpicpd_zdf) + umo(jpicpd_spg) + umo(jpicpd_dat)   &
+            &      + umo(jpicpd_swf) + umo(jpicpd_bfr) ) / tvolu,   &
+            &     (  vmo(jpicpd_hpg) + vmo(jpicpd_keg) + vmo(jpicpd_rvo) + vmo(jpicpd_pvo) + vmo(jpicpd_ldf)   &
+            &      + vmo(jpicpd_had) + vmo(jpicpd_zad) + vmo(jpicpd_zdf) + vmo(jpicpd_spg) + vmo(jpicpd_dat)   &
+            &      + vmo(jpicpd_swf) + vmo(jpicpd_bfr) ) / tvolv
+         ENDIF
+
+ 9500    FORMAT(' momentum trend at it= ', i6, ' :', /' ==============================')
+ 9501    FORMAT(' pressure gradient          u= ', e20.13, '    v= ', e20.13)
+ 9502    FORMAT(' ke gradient                u= ', e20.13, '    v= ', e20.13)
+ 9503    FORMAT(' relative vorticity term    u= ', e20.13, '    v= ', e20.13)
+ 9504    FORMAT(' coriolis term              u= ', e20.13, '    v= ', e20.13)
+ 9505    FORMAT(' horizontal diffusion       u= ', e20.13, '    v= ', e20.13)
+ 9506    FORMAT(' horizontal advection       u= ', e20.13, '    v= ', e20.13)
+ 9507    FORMAT(' vertical advection         u= ', e20.13, '    v= ', e20.13)
+ 9508    FORMAT(' vertical diffusion         u= ', e20.13, '    v= ', e20.13)
+ 9509    FORMAT(' surface pressure gradient  u= ', e20.13, '    v= ', e20.13)
+ 9510    FORMAT(' surface wind forcing       u= ', e20.13, '    v= ', e20.13)
+ 9511    FORMAT(' dampimg term               u= ', e20.13, '    v= ', e20.13)
+ 9512    FORMAT(' bottom flux                u= ', e20.13, '    v= ', e20.13)
+ 9513    FORMAT(' -----------------------------------------------------------------------------')
+ 9514    FORMAT(' total trend                u= ', e20.13, '    v= ', e20.13)
+
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9520) kt
+            WRITE (numout,9521) hke(jpicpd_hpg) / tvolt
+            WRITE (numout,9522) hke(jpicpd_keg) / tvolt
+            WRITE (numout,9523) hke(jpicpd_rvo) / tvolt
+            WRITE (numout,9524) hke(jpicpd_pvo) / tvolt
+            WRITE (numout,9525) hke(jpicpd_ldf) / tvolt
+            WRITE (numout,9526) hke(jpicpd_had) / tvolt
+            WRITE (numout,9527) hke(jpicpd_zad) / tvolt
+            WRITE (numout,9528) hke(jpicpd_zdf) / tvolt
+            WRITE (numout,9529) hke(jpicpd_spg) / tvolt
+            WRITE (numout,9530) hke(jpicpd_swf) / tvolt
+            WRITE (numout,9531) hke(jpicpd_dat) / tvolt
+            WRITE (numout,9532) hke(jpicpd_bfr) / tvolt
+            WRITE (numout,9533)
+            WRITE (numout,9534)   &
+            &     (  hke(jpicpd_hpg) + hke(jpicpd_keg) + hke(jpicpd_rvo) + hke(jpicpd_pvo) + hke(jpicpd_ldf)   &
+            &      + hke(jpicpd_had) + hke(jpicpd_zad) + hke(jpicpd_zdf) + hke(jpicpd_spg) + hke(jpicpd_dat)   &
+            &      + hke(jpicpd_swf) + hke(jpicpd_bfr) ) / tvolt
+         ENDIF
+
+ 9520    FORMAT(' kinetic energy trend at it= ', i6, ' :', /' ====================================')
+ 9521    FORMAT(' pressure gradient         u2= ', e20.13)
+ 9522    FORMAT(' ke gradient               u2= ', e20.13)
+ 9523    FORMAT(' relative vorticity term   u2= ', e20.13)
+ 9524    FORMAT(' coriolis term             u2= ', e20.13)
+ 9525    FORMAT(' horizontal diffusion      u2= ', e20.13)
+ 9526    FORMAT(' horizontal advection      u2= ', e20.13)
+ 9527    FORMAT(' vertical advection        u2= ', e20.13)
+ 9528    FORMAT(' vertical diffusion        u2= ', e20.13)
+ 9529    FORMAT(' surface pressure gradient u2= ', e20.13)
+ 9530    FORMAT(' surface wind forcing      u2= ', e20.13)
+ 9531    FORMAT(' dampimg term              u2= ', e20.13)
+ 9532    FORMAT(' bottom flux               u2= ', e20.13)
+ 9533    FORMAT(' --------------------------------------------------')
+ 9534    FORMAT(' total trend               u2= ', e20.13)
+
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9540) kt
+            WRITE (numout,9541) ( hke(jpicpd_keg) + hke(jpicpd_rvo) + hke(jpicpd_had) + hke(jpicpd_zad) ) / tvolt
+            WRITE (numout,9542) ( hke(jpicpd_keg) + hke(jpicpd_had) + hke(jpicpd_zad) ) / tvolt
+            WRITE (numout,9543) ( hke(jpicpd_pvo) ) / tvolt
+            WRITE (numout,9544) ( hke(jpicpd_rvo) ) / tvolt
+            WRITE (numout,9545) ( hke(jpicpd_spg) ) / tvolt
+            WRITE (numout,9546) ( hke(jpicpd_ldf) ) / tvolt
+            WRITE (numout,9547) ( hke(jpicpd_zdf) ) / tvolt
+            WRITE (numout,9548) ( hke(jpicpd_hpg) ) / tvolt, rpktrd / tvolt
+            WRITE (numout,*)
+            WRITE (numout,*)
+         ENDIF
+
+ 9540    FORMAT(' energetic consistency at it= ', i6, ' :', /' =========================================')
+ 9541    FORMAT(' 0 = non linear term(true if key_vorenergy or key_combined): ', e20.13)
+ 9542    FORMAT(' 0 = ke gradient + horizontal + vertical advection         : ', e20.13)
+ 9543    FORMAT(' 0 = coriolis term  (true if key_vorenergy or key_combined): ', e20.13)
+ 9544    FORMAT(' 0 = uh.( rot(u) x uh ) (true if enstrophy conser.)        : ', e20.13)
+ 9545    FORMAT(' 0 = surface pressure gradient                             : ', e20.13)
+ 9546    FORMAT(' 0 > horizontal diffusion                                  : ', e20.13)
+ 9547    FORMAT(' 0 > vertical diffusion                                    : ', e20.13)
+ 9548    FORMAT(' pressure gradient u2 = - 1/rau0 u.dz(rhop)                : ', e20.13, '  u.dz(rhop) =', e20.13)
+         !
+         ! Save potential to kinetic energy conversion for next time step
+         rpktrd = peke
+         !
+      ENDIF
+      !
+   END SUBROUTINE trd_dwr
+
+
+   SUBROUTINE trd_twr( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_twr  ***
+      !! 
+      !! ** Purpose :  write active tracers trends in ocean.output 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !!----------------------------------------------------------------------
+
+      ! I. Tracers trends
+      ! -----------------
+
+      IF( MOD(kt,nn_trd) == 0 .OR. kt == nit000 .OR. kt == nitend ) THEN
+
+         ! I.1 Sums over the global domain
+         ! -------------------------------
+         IF( lk_mpp ) THEN
+            CALL mpp_sum( tmo, jptot_tra )   
+            CALL mpp_sum( smo, jptot_tra )
+            CALL mpp_sum( t2 , jptot_tra )
+            CALL mpp_sum( s2 , jptot_tra )
+         ENDIF
+
+         ! I.2 Print tracers trends in the ocean.output file
+         ! --------------------------------------------------
+         
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9400) kt
+            WRITE (numout,9401) (tmo(jpicpt_xad)+tmo(jpicpt_yad))/ tvolt, (smo(jpicpt_xad)+smo(jpicpt_yad))/ tvolt
+            WRITE (numout,9402)  tmo(jpicpt_zad) / tvolt, smo(jpicpt_zad) / tvolt
+            WRITE (numout,9403)  tmo(jpicpt_ldf) / tvolt, smo(jpicpt_ldf) / tvolt
+            WRITE (numout,9404)  tmo(jpicpt_zdf) / tvolt, smo(jpicpt_zdf) / tvolt
+            WRITE (numout,9405)  tmo(jpicpt_npc) / tvolt, smo(jpicpt_npc) / tvolt
+            WRITE (numout,9406)  tmo(jpicpt_dmp) / tvolt, smo(jpicpt_dmp) / tvolt
+            WRITE (numout,9407)  tmo(jpicpt_qsr) / tvolt
+            WRITE (numout,9408)  tmo(jpicpt_nsr) / tvolt, smo(jpicpt_nsr) / tvolt
+            WRITE (numout,9409) 
+            WRITE (numout,9410) (  tmo(jpicpt_xad) + tmo(jpicpt_yad) + tmo(jpicpt_zad) + tmo(jpicpt_ldf) + tmo(jpicpt_zdf)   &
+            &                    + tmo(jpicpt_npc) + tmo(jpicpt_dmp) + tmo(jpicpt_qsr) + tmo(jpicpt_nsr) ) / tvolt,   &
+            &                   (  smo(jpicpt_xad) + smo(jpicpt_yad) + smo(jpicpt_zad) + smo(jpicpt_ldf) + smo(jpicpt_zdf)   &
+            &                    + smo(jpicpt_npc) + smo(jpicpt_dmp)                   + smo(jpicpt_nsr) ) / tvolt
+         ENDIF
+
+9400     FORMAT(' tracer trend at it= ',i6,' :     temperature',   &
+              '              salinity',/' ============================')
+9401     FORMAT(' horizontal advection        ',e20.13,'     ',e20.13)
+9402     FORMAT(' vertical advection          ',e20.13,'     ',e20.13)
+9403     FORMAT(' horizontal diffusion        ',e20.13,'     ',e20.13)
+9404     FORMAT(' vertical diffusion          ',e20.13,'     ',e20.13)
+9405     FORMAT(' static instability mixing   ',e20.13,'     ',e20.13)
+9406     FORMAT(' damping term                ',e20.13,'     ',e20.13)
+9407     FORMAT(' penetrative qsr             ',e20.13)
+9408     FORMAT(' non solar radiation         ',e20.13,'     ',e20.13)
+9409     FORMAT(' -------------------------------------------------------------------------')
+9410     FORMAT(' total trend                 ',e20.13,'     ',e20.13)
+
+
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9420) kt
+            WRITE (numout,9421) ( t2(jpicpt_xad)+t2(jpicpt_yad) )/ tvolt, ( s2(jpicpt_xad)+s2(jpicpt_yad) )/ tvolt
+            WRITE (numout,9422)   t2(jpicpt_zad) / tvolt, s2(jpicpt_zad) / tvolt
+            WRITE (numout,9423)   t2(jpicpt_ldf) / tvolt, s2(jpicpt_ldf) / tvolt
+            WRITE (numout,9424)   t2(jpicpt_zdf) / tvolt, s2(jpicpt_zdf) / tvolt
+            WRITE (numout,9425)   t2(jpicpt_npc) / tvolt, s2(jpicpt_npc) / tvolt
+            WRITE (numout,9426)   t2(jpicpt_dmp) / tvolt, s2(jpicpt_dmp) / tvolt
+            WRITE (numout,9427)   t2(jpicpt_qsr) / tvolt
+            WRITE (numout,9428)   t2(jpicpt_nsr) / tvolt, s2(jpicpt_nsr) / tvolt
+            WRITE (numout,9429)
+            WRITE (numout,9430) (  t2(jpicpt_xad) + t2(jpicpt_yad) + t2(jpicpt_zad) + t2(jpicpt_ldf) + t2(jpicpt_zdf)   &
+            &                    + t2(jpicpt_npc) + t2(jpicpt_dmp) + t2(jpicpt_qsr) + t2(jpicpt_nsr) ) / tvolt,   &
+            &                   (  s2(jpicpt_xad) + s2(jpicpt_yad) + s2(jpicpt_zad) + s2(jpicpt_ldf) + s2(jpicpt_zdf)   &
+            &                    + s2(jpicpt_npc) + s2(jpicpt_dmp)                  + s2(jpicpt_nsr) ) / tvolt
+         ENDIF
+
+9420     FORMAT(' tracer**2 trend at it= ', i6, ' :      temperature',   &
+            '               salinity', /, ' ===============================')
+9421     FORMAT(' horizontal advection      * t   ', e20.13, '     ', e20.13)
+9422     FORMAT(' vertical advection        * t   ', e20.13, '     ', e20.13)
+9423     FORMAT(' horizontal diffusion      * t   ', e20.13, '     ', e20.13)
+9424     FORMAT(' vertical diffusion        * t   ', e20.13, '     ', e20.13)
+9425     FORMAT(' static instability mixing * t   ', e20.13, '     ', e20.13)
+9426     FORMAT(' damping term              * t   ', e20.13, '     ', e20.13)
+9427     FORMAT(' penetrative qsr           * t   ', e20.13)
+9428     FORMAT(' non solar radiation       * t   ', e20.13, '     ', e20.13)
+9429     FORMAT(' -----------------------------------------------------------------------------')
+9430     FORMAT(' total trend                *t = ', e20.13, '  *s = ', e20.13)
+
+
+         IF(lwp) THEN
+            WRITE (numout,*)
+            WRITE (numout,*)
+            WRITE (numout,9440) kt
+            WRITE (numout,9441) ( tmo(jpicpt_xad)+tmo(jpicpt_yad)+tmo(jpicpt_zad) )/tvolt,   &
+            &                   ( smo(jpicpt_xad)+smo(jpicpt_yad)+smo(jpicpt_zad) )/tvolt
+            WRITE (numout,9442)   tmo(jpicpt_zl1)/tvolt,  smo(jpicpt_zl1)/tvolt
+            WRITE (numout,9443)   tmo(jpicpt_ldf)/tvolt,  smo(jpicpt_ldf)/tvolt
+            WRITE (numout,9444)   tmo(jpicpt_zdf)/tvolt,  smo(jpicpt_zdf)/tvolt
+            WRITE (numout,9445)   tmo(jpicpt_npc)/tvolt,  smo(jpicpt_npc)/tvolt
+            WRITE (numout,9446) ( t2(jpicpt_xad)+t2(jpicpt_yad)+t2(jpicpt_zad) )/tvolt,    &
+            &                   ( s2(jpicpt_xad)+s2(jpicpt_yad)+s2(jpicpt_zad) )/tvolt
+            WRITE (numout,9447)   t2(jpicpt_ldf)/tvolt,   s2(jpicpt_ldf)/tvolt
+            WRITE (numout,9448)   t2(jpicpt_zdf)/tvolt,   s2(jpicpt_zdf)/tvolt
+            WRITE (numout,9449)   t2(jpicpt_npc)/tvolt,   s2(jpicpt_npc)/tvolt
+         ENDIF
+
+9440     FORMAT(' tracer consistency at it= ',i6,   &
+            ' :         temperature','                salinity',/,   &
+            ' ==================================')
+9441     FORMAT(' 0 = horizontal+vertical advection +    ',e20.13,'       ',e20.13)
+9442     FORMAT('     1st lev vertical advection         ',e20.13,'       ',e20.13)
+9443     FORMAT(' 0 = horizontal diffusion               ',e20.13,'       ',e20.13)
+9444     FORMAT(' 0 = vertical diffusion                 ',e20.13,'       ',e20.13)
+9445     FORMAT(' 0 = static instability mixing          ',e20.13,'       ',e20.13)
+9446     FORMAT(' 0 = horizontal+vertical advection * t  ',e20.13,'       ',e20.13)
+9447     FORMAT(' 0 > horizontal diffusion          * t  ',e20.13,'       ',e20.13)
+9448     FORMAT(' 0 > vertical diffusion            * t  ',e20.13,'       ',e20.13)
+9449     FORMAT(' 0 > static instability mixing     * t  ',e20.13,'       ',e20.13)
+         !
+      ENDIF
+      !
+   END SUBROUTINE trd_twr
+
+#   else
+   !!----------------------------------------------------------------------
+   !!   Default case :                                         Empty module
+   !!----------------------------------------------------------------------
+   INTERFACE trd_icp
+      MODULE PROCEDURE trd_2d, trd_3d
+   END INTERFACE
+
+CONTAINS
+   SUBROUTINE trd_2d( ptrd2dx, ptrd2dy, ktrd , ctype, clpas )       ! Empty routine
+      REAL, DIMENSION(:,:) ::   ptrd2dx, ptrd2dy
+      INTEGER                     , INTENT(in   ) ::   ktrd         ! tracer trend index
+      CHARACTER(len=3)            , INTENT(in   ) ::   ctype        ! momentum ('DYN') or tracers ('TRA') trends
+      CHARACTER(len=3), INTENT(in), OPTIONAL ::   clpas             ! number of passage
+      WRITE(*,*) 'trd_2d: You should not have seen this print! error ?', &
+          &       ptrd2dx(1,1), ptrd2dy(1,1), ktrd, ctype, clpas
+   END SUBROUTINE trd_2d
+   SUBROUTINE trd_3d( ptrd3dx, ptrd3dy, ktrd , ctype, clpas )       ! Empty routine
+      REAL, DIMENSION(:,:,:) ::   ptrd3dx, ptrd3dy
+      INTEGER                     , INTENT(in   ) ::   ktrd         ! tracer trend index
+      CHARACTER(len=3)            , INTENT(in   ) ::   ctype        ! momentum ('DYN') or tracers ('TRA') trends
+      CHARACTER(len=3), INTENT(in), OPTIONAL ::   clpas             ! number of passage
+      WRITE(*,*) 'trd_3d: You should not have seen this print! error ?', &
+          &       ptrd3dx(1,1,1), ptrd3dy(1,1,1), ktrd, ctype, clpas
+   END SUBROUTINE trd_3d
+   SUBROUTINE trd_icp_init               ! Empty routine
+   END SUBROUTINE trd_icp_init
+   SUBROUTINE trd_dwr( kt )          ! Empty routine
+      WRITE(*,*) 'trd_dwr: You should not have seen this print! error ?', kt
+   END SUBROUTINE trd_dwr
+   SUBROUTINE trd_twr( kt )          ! Empty routine
+      WRITE(*,*) 'trd_twr: You should not have seen this print! error ?', kt
+   END SUBROUTINE trd_twr
+#endif
+
+   !!======================================================================
+END MODULE trdicp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdicp_oce.F90	(revision 1844)
@@ -0,0 +1,90 @@
+MODULE trdicp_oce
+   !!======================================================================
+   !!                   ***  MODULE trdicp_oce  ***
+   !! Ocean trends :   set tracer and momentum trend variables
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   'key_trdtra'   or                         tracer trends diagnostics
+   !!   'key_trddyn'                            momentum trends diagnostics
+   !!----------------------------------------------------------------------
+   USE par_oce                 ! ocean parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+#if  defined key_trdtra   &&   defined key_trddyn    ||   defined key_esopa
+   LOGICAL, PARAMETER ::   lk_trdtra = .TRUE.    !: tracers  trend flag
+   LOGICAL, PARAMETER ::   lk_trddyn = .TRUE.    !: momentum trend flag
+#elif  defined key_trdtra
+   LOGICAL, PARAMETER ::   lk_trdtra = .TRUE.    !: tracers  trend flag
+   LOGICAL, PARAMETER ::   lk_trddyn = .FALSE.   !: momentum trend flag
+#elif  defined key_trddyn
+   LOGICAL, PARAMETER ::   lk_trdtra = .FALSE.   !: tracers  trend flag
+   LOGICAL, PARAMETER ::   lk_trddyn = .TRUE.    !: momentum trend flag
+#else
+   LOGICAL, PARAMETER ::   lk_trdtra = .FALSE.   !: tracers  trend flag
+   LOGICAL, PARAMETER ::   lk_trddyn = .FALSE.   !: momentum trend flag
+#endif
+
+   !                                        !!! => tracer trends indexes <=
+   INTEGER, PARAMETER ::   jpicpt_xad =  1   !: x- horizontal advection
+   INTEGER, PARAMETER ::   jpicpt_yad =  2   !: y- horizontal advection
+   INTEGER, PARAMETER ::   jpicpt_zad =  3   !: z- vertical   advection
+   INTEGER, PARAMETER ::   jpicpt_ldf =  4   !: lateral       diffusion
+   INTEGER, PARAMETER ::   jpicpt_zdf =  5   !: vertical diffusion (Kz)
+   INTEGER, PARAMETER ::   jpicpt_bbc =  6   !: Bottom Boundary Condition (geoth. flux) 
+   INTEGER, PARAMETER ::   jpicpt_bbl =  7   !: Bottom Boundary Layer (diffusive/convective)
+   INTEGER, PARAMETER ::   jpicpt_npc =  8   !: static instability mixing
+   INTEGER, PARAMETER ::   jpicpt_dmp =  9   !: damping
+   INTEGER, PARAMETER ::   jpicpt_qsr = 10   !: penetrative solar radiation
+   INTEGER, PARAMETER ::   jpicpt_nsr = 11   !: non solar radiation
+   INTEGER, PARAMETER ::   jpicpt_zl1 = 12   !: first level vertical flux
+
+   !                                        !!! => Total tracer trends indexes <=
+   INTEGER, PARAMETER ::   jptot_tra  = 12   !: change it when adding/removing one indice above
+   
+   !                                        !!! => dynamic trends indexes <=
+   INTEGER, PARAMETER ::   jpicpd_hpg =  1   !: hydrostatic pressure gradient 
+   INTEGER, PARAMETER ::   jpicpd_keg =  2   !: kinetic energy gradient
+   INTEGER, PARAMETER ::   jpicpd_rvo =  3   !: relative vorticity
+   INTEGER, PARAMETER ::   jpicpd_pvo =  4   !: planetary vorticity
+   INTEGER, PARAMETER ::   jpicpd_ldf =  5   !: lateral diffusion
+   INTEGER, PARAMETER ::   jpicpd_had =  6   !: horizontal advection
+   INTEGER, PARAMETER ::   jpicpd_zad =  7   !: vertical advection
+   INTEGER, PARAMETER ::   jpicpd_zdf =  8   !: vertical diffusion
+   INTEGER, PARAMETER ::   jpicpd_spg =  9   !: surface pressure gradient
+   INTEGER, PARAMETER ::   jpicpd_dat = 10   !: damping term
+   INTEGER, PARAMETER ::   jpicpd_swf = 11   !: surface wind forcing
+   INTEGER, PARAMETER ::   jpicpd_bfr = 12   !: bottom friction 
+
+   !                                        !!! => Total dynamic trends indexes <=
+   INTEGER, PARAMETER ::   jptot_dyn  = 12   !: change it when adding/removing one indice above
+   
+#if   defined key_trdtra   ||   defined key_trddyn   ||   defined key_esopa
+
+   !! Variables used for diagnostics
+   !!---------------------------------------------------------------------
+   REAL(wp) ::   tvolt        !: volume of the whole ocean computed at t-points
+   REAL(wp) ::   tvolu        !: volume of the whole ocean computed at u-points
+   REAL(wp) ::   tvolv        !: volume of the whole ocean computed at v-points
+
+   !! Tracers trends diagnostics variables
+   !!---------------------------------------------------------------------
+   REAL(wp), DIMENSION(jptot_tra) ::   tmo, smo         !: tracers trends average 
+   REAL(wp), DIMENSION(jptot_tra) ::   t2, s2           !: tracers square trends average 
+   
+   !! Momentum trends diagnostics variables
+   !!---------------------------------------------------------------------
+   REAL(wp), DIMENSION(jptot_dyn) ::   umo, vmo         !: momentum trends average 
+   REAL(wp), DIMENSION(jptot_dyn) ::   hke              !: momentum square trends average 
+   REAL(wp) ::   rpktrd   !: potential to kinetic energy conversion
+   REAL(wp) ::   peke     !: conversion potential energy - kinetic energy trend
+
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE trdicp_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld.F90	(revision 1844)
@@ -0,0 +1,959 @@
+MODULE trdmld
+   !!======================================================================
+   !!                       ***  MODULE  trdmld  ***
+   !! Ocean diagnostics:  mixed layer T-S trends 
+   !!=====================================================================
+   !! History :       !  95-04  (J. Vialard)    Original code
+   !!                 !  97-02  (E. Guilyardi)  Adaptation global + base cmo
+   !!                 !  99-09  (E. Guilyardi)  Re-writing + netCDF output
+   !!            8.5  !  02-06  (G. Madec)      F90: Free form and module
+   !!            9.0  !  04-08  (C. Talandier)  New trends organization
+   !!                 !  05-05  (C. Deltel)     Diagnose trends of time averaged ML T & S
+   !!----------------------------------------------------------------------
+#if   defined key_trdmld   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trdmld'                          mixed layer trend diagnostics
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   trd_mld          : T and S cumulated trends averaged over the mixed layer
+   !!   trd_mld_zint     : T and S trends vertical integration
+   !!   trd_mld_init     : initialization step
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE trdmod_oce      ! ocean variables trends
+   USE ldftra_oce      ! ocean active tracers lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! Define parameters for the routines
+   USE dianam          ! build the name of file (routine)
+   USE ldfslp          ! iso-neutral slopes 
+   USE zdfmxl          ! mixed layer depth
+   USE zdfddm          ! ocean vertical physics: double diffusion
+   USE ioipsl          ! NetCDF library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE diadimg         ! dimg direct access file format output
+   USE trdmld_rst      ! restart for diagnosing the ML trends
+   USE prtctl          ! Print control
+   USE restart         ! for lrst_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trd_mld        ! routine called by step.F90
+   PUBLIC   trd_mld_init   ! routine called by opa.F90
+   PUBLIC   trd_mld_zint   ! routine called by tracers routines
+
+   CHARACTER (LEN=40) ::  clhstnam         ! name of the trends NetCDF file
+   INTEGER ::   nh_t, nmoymltrd
+   INTEGER ::   nidtrd, ndextrd1(jpi*jpj)
+   INTEGER ::   ndimtrd1                        
+   INTEGER ::   ionce, icount                   
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldftra_substitute.h90"
+#  include "zdfddm_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trd_mld_zint( pttrdmld, pstrdmld, ktrd, ctype )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_zint  ***
+      !! 
+      !! ** Purpose :   Compute the vertical average of the 3D fields given as arguments 
+      !!                to the subroutine. This vertical average is performed from ocean
+      !!                surface down to a chosen control surface.
+      !!
+      !! ** Method/usage :
+      !!      The control surface can be either a mixed layer depth (time varying)
+      !!      or a fixed surface (jk level or bowl). 
+      !!      Choose control surface with nn_ctls in namelist NAMTRD :
+      !!        nn_ctls = 0  : use mixed layer with density criterion 
+      !!        nn_ctls = 1  : read index from file 'ctlsurf_idx'
+      !!        nn_ctls > 1  : use fixed level surface jk = nn_ctls
+      !!      Note: in the remainder of the routine, the volume between the 
+      !!            surface and the control surface is called "mixed-layer"
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   ktrd                             ! ocean trend index
+      CHARACTER(len=2), INTENT( in ) :: ctype                     ! surface/bottom (2D arrays) or
+      !                                                           ! interior (3D arrays) physics
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  pttrdmld ! temperature trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  pstrdmld ! salinity trend 
+      INTEGER ::   ji, jj, jk, isum
+      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
+      !!----------------------------------------------------------------------
+
+      ! I. Definition of control surface and associated fields
+      ! ------------------------------------------------------
+      !            ==> only once per time step <== 
+
+      IF( icount == 1 ) THEN        
+         !
+         tmltrd(:,:,:) = 0.e0    ;    smltrd(:,:,:) = 0.e0    ! <<< reset trend arrays to zero
+         
+         ! ... Set nmld(ji,jj) = index of first T point below control surf. or outside mixed-layer
+         IF( nn_ctls == 0 ) THEN       ! * control surface = mixed-layer with density criterion 
+            nmld(:,:) = nmln(:,:)    ! array nmln computed in zdfmxl.F90
+         ELSE IF( nn_ctls == 1 ) THEN  ! * control surface = read index from file 
+            nmld(:,:) = nbol(:,:)
+         ELSE IF( nn_ctls >= 2 ) THEN  ! * control surface = model level
+            nn_ctls = MIN( nn_ctls, jpktrd - 1 )
+            nmld(:,:) = nn_ctls + 1
+         ENDIF
+
+         ! ... Compute ndextrd1 and ndimtrd1 only once
+         IF( ionce == 1 ) THEN
+            !
+            ! Check of validity : nmld(ji,jj) <= jpktrd
+            isum        = 0
+            zvlmsk(:,:) = 0.e0
+
+            IF( jpktrd < jpk ) THEN 
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF( nmld(ji,jj) <= jpktrd ) THEN
+                        zvlmsk(ji,jj) = tmask(ji,jj,1)
+                     ELSE
+                        isum = isum + 1
+                        zvlmsk(ji,jj) = 0.
+                     ENDIF
+                  END DO
+               END DO
+            ENDIF
+
+            ! Index of ocean points (2D only)
+            IF( isum > 0 ) THEN
+               WRITE(numout,*)' Number of invalid points nmld > jpktrd', isum 
+               CALL wheneq( jpi*jpj, zvlmsk(:,:) , 1, 1., ndextrd1, ndimtrd1 )    ! surface
+            ELSE 
+               CALL wheneq( jpi*jpj, tmask(:,:,1), 1, 1., ndextrd1, ndimtrd1 )    ! surface
+            ENDIF                                
+
+            ionce = 0                ! no more pass here
+            !
+         END IF
+         
+         ! ... Weights for vertical averaging
+         wkx(:,:,:) = 0.e0
+         DO jk = 1, jpktrd             ! initialize wkx with vertical scale factor in mixed-layer
+            DO jj = 1,jpj
+               DO ji = 1,jpi
+                  IF( jk - nmld(ji,jj) < 0.e0 )   wkx(ji,jj,jk) = fse3t(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         
+         rmld(:,:) = 0.e0                ! compute mixed-layer depth : rmld
+         DO jk = 1, jpktrd
+            rmld(:,:) = rmld(:,:) + wkx(:,:,jk)
+         END DO
+         
+         DO jk = 1, jpktrd             ! compute integration weights
+            wkx(:,:,jk) = wkx(:,:,jk) / MAX( 1., rmld(:,:) )
+         END DO
+
+         icount = 0                    ! <<< flag = off : control surface & integr. weights
+         !                             !     computed only once per time step
+      END IF
+
+      ! II. Vertical integration of trends in the mixed-layer
+      ! -----------------------------------------------------
+
+      SELECT CASE (ctype)
+      CASE ( '3D' )   ! mean T/S trends in the mixed-layer
+         DO jk = 1, jpktrd
+            tmltrd(:,:,ktrd) = tmltrd(:,:,ktrd) + pttrdmld(:,:,jk) * wkx(:,:,jk)   ! temperature
+            smltrd(:,:,ktrd) = smltrd(:,:,ktrd) + pstrdmld(:,:,jk) * wkx(:,:,jk)   ! salinity
+         END DO
+      CASE ( '2D' )   ! forcing at upper boundary of the mixed-layer
+         tmltrd(:,:,ktrd) = tmltrd(:,:,ktrd) + pttrdmld(:,:,1) * wkx(:,:,1)        ! non penetrative
+         smltrd(:,:,ktrd) = smltrd(:,:,ktrd) + pstrdmld(:,:,1) * wkx(:,:,1)            
+      END SELECT
+      !
+   END SUBROUTINE trd_mld_zint
+    
+
+   SUBROUTINE trd_mld( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld  ***
+      !! 
+      !! ** Purpose :  Compute and cumulate the mixed layer trends over an analysis
+      !!               period, and write NetCDF (or dimg) outputs.
+      !!
+      !! ** Method/usage :
+      !!          The stored trends can be chosen twofold (according to the ln_trdmld_instant 
+      !!          logical namelist variable) :
+      !!          1) to explain the difference between initial and final 
+      !!             mixed-layer T & S (where initial and final relate to the
+      !!             current analysis window, defined by nn_trd in the namelist)
+      !!          2) to explain the difference between the current and previous 
+      !!             TIME-AVERAGED mixed-layer T & S (where time-averaging is
+      !!             performed over each analysis window).
+      !!
+      !! ** Consistency check : 
+      !!        If the control surface is fixed ( nn_ctls > 1 ), the residual term (dh/dt
+      !!        entrainment) should be zero, at machine accuracy. Note that in the case
+      !!        of time-averaged mixed-layer fields, this residual WILL NOT BE ZERO
+      !!        over the first two analysis windows (except if restart).
+      !!        N.B. For ORCA2_LIM, use e.g. nn_trd=5, rn_ucf=1., nn_ctls=8
+      !!             for checking residuals.
+      !!             On a NEC-SX5 computer, this typically leads to:
+      !!                   O(1.e-20) temp. residuals (tml_res) when ln_trdmld_instant=.false.
+      !!                   O(1.e-21) temp. residuals (tml_res) when ln_trdmld_instant=.true.
+      !!
+      !! ** Action :
+      !!       At each time step, mixed-layer averaged trends are stored in the 
+      !!       tmltrd(:,:,jpmld_xxx) array (see trdmld_oce.F90 for definitions of jpmld_xxx).
+      !!       This array is known when trd_mld is called, at the end of the stp subroutine, 
+      !!       except for the purely vertical K_z diffusion term, which is embedded in the
+      !!       lateral diffusion trend.
+      !!
+      !!       In I), this K_z term is diagnosed and stored, thus its contribution is removed
+      !!       from the lateral diffusion trend.
+      !!       In II), the instantaneous mixed-layer T & S are computed, and misc. cumulative
+      !!       arrays are updated.
+      !!       In III), called only once per analysis window, we compute the total trends,
+      !!       along with the residuals and the Asselin correction terms.
+      !!       In IV), the appropriate trends are written in the trends NetCDF file.
+      !!
+      !! References :
+      !!       - Vialard & al.
+      !!       - See NEMO documentation (in preparation)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER :: ji, jj, jk, jl, ik, it, itmod
+      LOGICAL :: lldebug = .TRUE.
+      REAL(wp) :: zavt, zfn, zfn2
+      REAL(wp) ,DIMENSION(jpi,jpj) ::     &
+           ztmltot,  zsmltot,             & ! dT/dt over the anlysis window (including Asselin)
+           ztmlres,  zsmlres,             & ! residual = dh/dt entrainment term
+           ztmlatf,  zsmlatf,             & ! needed for storage only
+           ztmltot2, ztmlres2, ztmltrdm2, & ! \  working arrays to diagnose the trends
+           zsmltot2, zsmlres2, zsmltrdm2, & !  > associated with the time meaned ML T & S
+           ztmlatf2, zsmlatf2               ! /
+      REAL(wp), DIMENSION(jpi,jpj,jpltrd) ::  &
+           ztmltrd2, zsmltrd2               ! only needed for mean diagnostics
+#if defined key_dimgout
+      INTEGER ::  iyear,imon,iday
+      CHARACTER(LEN=80) :: cltext, clmode
+#endif
+      !!----------------------------------------------------------------------
+      
+
+      ! ======================================================================
+      ! I. Diagnose the purely vertical (K_z) diffusion trend
+      ! ======================================================================
+
+      ! ... These terms can be estimated by flux computation at the lower boundary of the ML 
+      !     (we compute (-1/h) * K_z * d_z( T ) and (-1/h) * K_z * d_z( S ))
+      IF( ln_traldf_iso ) THEN
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               ik = nmld(ji,jj)
+               zavt = avt(ji,jj,ik)
+               tmltrd(ji,jj,jpmld_zdf) = - zavt / fse3w(ji,jj,ik) * tmask(ji,jj,ik)  &
+                  &                      * ( tn(ji,jj,ik-1) - tn(ji,jj,ik) )         &
+                  &                      / MAX( 1., rmld(ji,jj) ) * tmask(ji,jj,1)
+               zavt = fsavs(ji,jj,ik)
+               smltrd(ji,jj,jpmld_zdf) = - zavt / fse3w(ji,jj,ik) * tmask(ji,jj,ik)  &
+                  &                      * ( sn(ji,jj,ik-1) - sn(ji,jj,ik) )         &
+                  &                      / MAX( 1., rmld(ji,jj) ) * tmask(ji,jj,1)
+            END DO
+         END DO
+
+         ! ... Remove this K_z trend from the iso-neutral diffusion term (if any)
+         tmltrd(:,:,jpmld_ldf) = tmltrd(:,:,jpmld_ldf) - tmltrd(:,:,jpmld_zdf)
+         smltrd(:,:,jpmld_ldf) = smltrd(:,:,jpmld_ldf) - smltrd(:,:,jpmld_zdf)
+      END IF
+
+      ! ... Lateral boundary conditions
+      DO jl = 1, jpltrd
+         CALL lbc_lnk( tmltrd(:,:,jl), 'T', 1. )
+         CALL lbc_lnk( smltrd(:,:,jl), 'T', 1. )
+      END DO
+
+      ! ======================================================================
+      ! II. Cumulate the trends over the analysis window
+      ! ======================================================================
+
+      ztmltrd2(:,:,:) = 0.e0   ;    zsmltrd2(:,:,:) = 0.e0  ! <<< reset arrays to zero
+      ztmltot2(:,:)   = 0.e0   ;    zsmltot2(:,:)   = 0.e0
+      ztmlres2(:,:)   = 0.e0   ;    zsmlres2(:,:)   = 0.e0
+      ztmlatf2(:,:)   = 0.e0   ;    zsmlatf2(:,:)   = 0.e0
+
+      ! II.1 Set before values of vertically average T and S 
+      ! ----------------------------------------------------
+      IF( kt > nit000 ) THEN
+         !   ... temperature ...                    ... salinity ...
+         tmlb   (:,:) = tml   (:,:)           ; smlb   (:,:) = sml   (:,:)
+         tmlatfn(:,:) = tmltrd(:,:,jpmld_atf) ; smlatfn(:,:) = smltrd(:,:,jpmld_atf)
+      END IF
+
+      ! II.2 Vertically averaged T and S
+      ! --------------------------------
+      tml(:,:) = 0.e0   ;   sml(:,:) = 0.e0
+      DO jk = 1, jpktrd - 1
+         tml(:,:) = tml(:,:) + wkx(:,:,jk) * tn(:,:,jk)
+         sml(:,:) = sml(:,:) + wkx(:,:,jk) * sn(:,:,jk) 
+      END DO
+
+      ! II.3 Initialize mixed-layer "before" arrays for the 1rst analysis window    
+      ! ------------------------------------------------------------------------
+      IF( kt == 2 ) THEN  !  i.e. ( .NOT. ln_rstart ).AND.( kt == nit000 + 1)
+         !
+         !   ... temperature ...                ... salinity ...
+         tmlbb  (:,:) = tmlb   (:,:)   ;   smlbb  (:,:) = smlb   (:,:)
+         tmlbn  (:,:) = tml    (:,:)   ;   smlbn  (:,:) = sml    (:,:)
+         tmlatfb(:,:) = tmlatfn(:,:)   ;   smlatfb(:,:) = smlatfn(:,:)
+         
+         tmltrd_csum_ub (:,:,:) = 0.e0  ;   smltrd_csum_ub (:,:,:) = 0.e0
+         tmltrd_atf_sumb(:,:)   = 0.e0  ;   smltrd_atf_sumb(:,:)   = 0.e0
+
+         rmldbn(:,:) = rmld(:,:)
+
+         IF( ln_ctl ) THEN
+            WRITE(numout,*) '             we reach kt == nit000 + 1 = ', nit000+1
+            CALL prt_ctl(tab2d_1=tmlbb   , clinfo1=' tmlbb   -   : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tmlbn   , clinfo1=' tmlbn   -   : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tmlatfb , clinfo1=' tmlatfb -   : ', mask1=tmask, ovlap=1)
+         END IF
+         !
+      END IF
+
+      IF( ( ln_rstart ) .AND. ( kt == nit000 ) .AND. ( ln_ctl ) ) THEN
+         IF( ln_trdmld_instant ) THEN
+            WRITE(numout,*) '             restart from kt == nit000 = ', nit000
+            CALL prt_ctl(tab2d_1=tmlbb   , clinfo1=' tmlbb   -   : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tmlbn   , clinfo1=' tmlbn   -   : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tmlatfb , clinfo1=' tmlatfb -   : ', mask1=tmask, ovlap=1)
+         ELSE
+            WRITE(numout,*) '             restart from kt == nit000 = ', nit000
+            CALL prt_ctl(tab2d_1=tmlbn          , clinfo1=' tmlbn           -  : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=rmldbn         , clinfo1=' rmldbn          -  : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tml_sumb       , clinfo1=' tml_sumb        -  : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab2d_1=tmltrd_atf_sumb, clinfo1=' tmltrd_atf_sumb -  : ', mask1=tmask, ovlap=1)
+            CALL prt_ctl(tab3d_1=tmltrd_csum_ub , clinfo1=' tmltrd_csum_ub  -  : ', mask1=tmask, ovlap=1, kdim=1)
+         END IF
+      END IF
+
+      ! II.4 Cumulated trends over the analysis period
+      ! ----------------------------------------------
+      !
+      !         [  1rst analysis window ] [     2nd analysis window     ]                       
+      !
+      !     o---[--o-----o-----o-----o--]-[--o-----o-----o-----o-----o--]---o-----o--> time steps
+      !                          nn_trd                           2*nn_trd       etc.
+      !     1      2     3     4    =5 e.g.                          =10
+      !
+      IF( ( kt >= 2 ).OR.( ln_rstart ) ) THEN
+         !
+         nmoymltrd = nmoymltrd + 1
+         
+         ! ... Cumulate over BOTH physical contributions AND over time steps
+         DO jl = 1, jpltrd
+            tmltrdm(:,:) = tmltrdm(:,:) + tmltrd(:,:,jl)
+            smltrdm(:,:) = smltrdm(:,:) + smltrd(:,:,jl)
+         END DO
+
+         ! ... Special handling of the Asselin trend 
+         tmlatfm(:,:) = tmlatfm(:,:) + tmlatfn(:,:)
+         smlatfm(:,:) = smlatfm(:,:) + smlatfn(:,:)
+
+         ! ... Trends associated with the time mean of the ML T/S
+         tmltrd_sum    (:,:,:) = tmltrd_sum    (:,:,:) + tmltrd    (:,:,:) ! tem
+         tmltrd_csum_ln(:,:,:) = tmltrd_csum_ln(:,:,:) + tmltrd_sum(:,:,:)
+         tml_sum       (:,:)   = tml_sum       (:,:)   + tml       (:,:)
+         smltrd_sum    (:,:,:) = smltrd_sum    (:,:,:) + smltrd    (:,:,:) ! sal
+         smltrd_csum_ln(:,:,:) = smltrd_csum_ln(:,:,:) + smltrd_sum(:,:,:)
+         sml_sum       (:,:)   = sml_sum       (:,:)   + sml       (:,:)
+         rmld_sum      (:,:)   = rmld_sum      (:,:)   + rmld      (:,:)   ! rmld
+         !
+      END IF
+
+      ! ======================================================================
+      ! III. Prepare fields for output (get here ONCE PER ANALYSIS PERIOD)
+      ! ======================================================================
+
+      ! Convert to appropriate physical units
+      ! N.B. It may be useful to check IOIPSL time averaging with :
+      !      tmltrd (:,:,:) = 1. ; smltrd (:,:,:) = 1.
+      tmltrd(:,:,:) = tmltrd(:,:,:) * rn_ucf   ! (actually needed for 1:jpltrd-1, but trdmld(:,:,jpltrd)
+      smltrd(:,:,:) = smltrd(:,:,:) * rn_ucf   !  is no longer used, and is reset to 0. at next time step)
+      
+      ! define time axis
+      it = kt
+      itmod = kt - nit000 + 1
+
+      MODULO_NTRD : IF( MOD( itmod, nn_trd ) == 0 ) THEN        ! nitend MUST be multiple of nn_trd
+         !
+         ztmltot (:,:) = 0.e0   ;   zsmltot (:,:) = 0.e0   ! reset arrays to zero
+         ztmlres (:,:) = 0.e0   ;   zsmlres (:,:) = 0.e0
+         ztmltot2(:,:) = 0.e0   ;   zsmltot2(:,:) = 0.e0
+         ztmlres2(:,:) = 0.e0   ;   zsmlres2(:,:) = 0.e0
+      
+         zfn  = float(nmoymltrd)    ;    zfn2 = zfn * zfn
+         
+         ! III.1 Prepare fields for output ("instantaneous" diagnostics) 
+         ! -------------------------------------------------------------
+         
+         !-- Compute total trends
+         ztmltot(:,:) = ( tml(:,:) - tmlbn(:,:) + tmlb(:,:) - tmlbb(:,:) ) / ( 2.*rdt )
+         zsmltot(:,:) = ( sml(:,:) - smlbn(:,:) + smlb(:,:) - smlbb(:,:) ) / ( 2.*rdt )
+         
+         !-- Compute residuals
+         ztmlres(:,:) = ztmltot(:,:) - ( tmltrdm(:,:) - tmlatfn(:,:) + tmlatfb(:,:) )
+         zsmlres(:,:) = zsmltot(:,:) - ( smltrdm(:,:) - smlatfn(:,:) + smlatfb(:,:) )
+      
+         !-- Diagnose Asselin trend over the analysis window 
+         ztmlatf(:,:) = tmlatfm(:,:) - tmlatfn(:,:) + tmlatfb(:,:)
+         zsmlatf(:,:) = smlatfm(:,:) - smlatfn(:,:) + smlatfb(:,:)
+         
+         !-- Lateral boundary conditions
+         !         ... temperature ...                    ... salinity ...
+         CALL lbc_lnk( ztmltot , 'T', 1. )  ;   CALL lbc_lnk( zsmltot , 'T', 1. )
+         CALL lbc_lnk( ztmlres , 'T', 1. )  ;   CALL lbc_lnk( zsmlres , 'T', 1. )
+         CALL lbc_lnk( ztmlatf , 'T', 1. )  ;   CALL lbc_lnk( zsmlatf , 'T', 1. )
+
+#if defined key_diainstant
+         CALL ctl_stop( 'tml_trd : key_diainstant was never checked within trdmld. Comment this to proceed.')
+#endif
+         ! III.2 Prepare fields for output ("mean" diagnostics) 
+         ! ----------------------------------------------------
+         
+         !-- Update the ML depth time sum (to build the Leap-Frog time mean)
+         rmld_sum(:,:) = rmldbn(:,:) + 2 * ( rmld_sum(:,:) - rmld(:,:) ) + rmld(:,:)
+
+         !-- Compute temperature total trends
+         tml_sum (:,:) = tmlbn(:,:) + 2 * ( tml_sum(:,:) - tml(:,:) ) + tml(:,:)
+         ztmltot2(:,:) = ( tml_sum(:,:) - tml_sumb(:,:) ) /  ( 2.*rdt )    ! now in degC/s
+         
+         !-- Compute salinity total trends
+         sml_sum (:,:) = smlbn(:,:) + 2 * ( sml_sum(:,:) - sml(:,:) ) + sml(:,:)
+         zsmltot2(:,:) = ( sml_sum(:,:) - sml_sumb(:,:) ) /  ( 2.*rdt )    ! now in psu/s
+         
+         !-- Compute temperature residuals
+         DO jl = 1, jpltrd
+            ztmltrd2(:,:,jl) = tmltrd_csum_ub(:,:,jl) + tmltrd_csum_ln(:,:,jl)
+         END DO
+
+         ztmltrdm2(:,:) = 0.e0
+         DO jl = 1, jpltrd
+            ztmltrdm2(:,:) = ztmltrdm2(:,:) + ztmltrd2(:,:,jl)
+         END DO
+
+         ztmlres2(:,:) =  ztmltot2(:,:)  -       &
+              ( ztmltrdm2(:,:) - tmltrd_sum(:,:,jpmld_atf) + tmltrd_atf_sumb(:,:) )
+         
+         !-- Compute salinity residuals
+         DO jl = 1, jpltrd
+            zsmltrd2(:,:,jl) = smltrd_csum_ub(:,:,jl) + smltrd_csum_ln(:,:,jl)
+         END DO
+
+         zsmltrdm2(:,:) = 0.
+         DO jl = 1, jpltrd
+            zsmltrdm2(:,:) = zsmltrdm2(:,:) + zsmltrd2(:,:,jl)
+         END DO
+
+         zsmlres2(:,:) =  zsmltot2(:,:)  -       &
+              ( zsmltrdm2(:,:) - smltrd_sum(:,:,jpmld_atf) + smltrd_atf_sumb(:,:) )
+         
+         !-- Diagnose Asselin trend over the analysis window
+         ztmlatf2(:,:) = ztmltrd2(:,:,jpmld_atf) - tmltrd_sum(:,:,jpmld_atf) + tmltrd_atf_sumb(:,:)
+         zsmlatf2(:,:) = zsmltrd2(:,:,jpmld_atf) - smltrd_sum(:,:,jpmld_atf) + smltrd_atf_sumb(:,:)
+
+         !-- Lateral boundary conditions
+         !         ... temperature ...                    ... salinity ...
+         CALL lbc_lnk( ztmltot2, 'T', 1. )  ;   CALL lbc_lnk( zsmltot2, 'T', 1. )
+         CALL lbc_lnk( ztmlres2, 'T', 1. )  ;   CALL lbc_lnk( zsmlres2, 'T', 1. )
+         DO jl = 1, jpltrd
+            CALL lbc_lnk( ztmltrd2(:,:,jl), 'T', 1. ) ! \  these will be output
+            CALL lbc_lnk( zsmltrd2(:,:,jl), 'T', 1. ) ! /  in the NetCDF trends file
+         END DO
+         
+         ! III.3 Time evolution array swap
+         ! -------------------------------
+         
+         ! For T/S instantaneous diagnostics 
+         !   ... temperature ...               ... salinity ...
+         tmlbb  (:,:) = tmlb   (:,:)  ;   smlbb  (:,:) = smlb   (:,:)
+         tmlbn  (:,:) = tml    (:,:)  ;   smlbn  (:,:) = sml    (:,:)
+         tmlatfb(:,:) = tmlatfn(:,:)  ;   smlatfb(:,:) = smlatfn(:,:)
+
+         ! For T mean diagnostics 
+         tmltrd_csum_ub (:,:,:) = zfn * tmltrd_sum(:,:,:) - tmltrd_csum_ln(:,:,:)
+         tml_sumb       (:,:)   = tml_sum(:,:)
+         tmltrd_atf_sumb(:,:)   = tmltrd_sum(:,:,jpmld_atf)
+         
+         ! For S mean diagnostics 
+         smltrd_csum_ub (:,:,:) = zfn * smltrd_sum(:,:,:) - smltrd_csum_ln(:,:,:)
+         sml_sumb       (:,:)   = sml_sum(:,:)
+         smltrd_atf_sumb(:,:)   = smltrd_sum(:,:,jpmld_atf)
+         
+         ! ML depth
+         rmldbn         (:,:)   = rmld    (:,:)
+         
+         IF( ln_ctl ) THEN
+            IF( ln_trdmld_instant ) THEN
+               CALL prt_ctl(tab2d_1=tmlbb   , clinfo1=' tmlbb   -   : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab2d_1=tmlbn   , clinfo1=' tmlbn   -   : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab2d_1=tmlatfb , clinfo1=' tmlatfb -   : ', mask1=tmask, ovlap=1)
+            ELSE
+               CALL prt_ctl(tab2d_1=tmlbn          , clinfo1=' tmlbn           -  : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab2d_1=rmldbn         , clinfo1=' rmldbn          -  : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab2d_1=tml_sumb       , clinfo1=' tml_sumb        -  : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab2d_1=tmltrd_atf_sumb, clinfo1=' tmltrd_atf_sumb -  : ', mask1=tmask, ovlap=1)
+               CALL prt_ctl(tab3d_1=tmltrd_csum_ub , clinfo1=' tmltrd_csum_ub  -  : ', mask1=tmask, ovlap=1, kdim=1)
+            END IF
+         END IF
+
+         ! III.4 Convert to appropriate physical units
+         ! -------------------------------------------
+
+         !    ... temperature ...                         ... salinity ...
+         ztmltot (:,:)   = ztmltot(:,:)   * rn_ucf/zfn  ; zsmltot (:,:)   = zsmltot(:,:)   * rn_ucf/zfn
+         ztmlres (:,:)   = ztmlres(:,:)   * rn_ucf/zfn  ; zsmlres (:,:)   = zsmlres(:,:)   * rn_ucf/zfn
+         ztmlatf (:,:)   = ztmlatf(:,:)   * rn_ucf/zfn  ; zsmlatf (:,:)   = zsmlatf(:,:)   * rn_ucf/zfn
+
+         tml_sum (:,:)   = tml_sum (:,:)  /  (2*zfn) ; sml_sum (:,:)   = sml_sum (:,:)  /  (2*zfn)
+         ztmltot2(:,:)   = ztmltot2(:,:)  * rn_ucf/zfn2 ; zsmltot2(:,:)   = zsmltot2(:,:)  * rn_ucf/zfn2
+         ztmltrd2(:,:,:) = ztmltrd2(:,:,:)* rn_ucf/zfn2 ; zsmltrd2(:,:,:) = zsmltrd2(:,:,:)* rn_ucf/zfn2
+         ztmlatf2(:,:)   = ztmlatf2(:,:)  * rn_ucf/zfn2 ; zsmlatf2(:,:)   = zsmlatf2(:,:)  * rn_ucf/zfn2
+         ztmlres2(:,:)   = ztmlres2(:,:)  * rn_ucf/zfn2 ; zsmlres2(:,:)   = zsmlres2(:,:)  * rn_ucf/zfn2
+
+         rmld_sum(:,:)   = rmld_sum(:,:)  /  (2*zfn)  ! similar to tml_sum and sml_sum
+
+         ! * Debugging information *
+         IF( lldebug ) THEN
+            !
+            WRITE(numout,*)
+            WRITE(numout,*) 'trd_mld : write trends in the Mixed Layer for debugging process:'
+            WRITE(numout,*) '~~~~~~~  '
+            WRITE(numout,*) '          TRA kt = ', kt, 'nmoymltrd = ', nmoymltrd
+            WRITE(numout,*)
+            WRITE(numout,*) '          >>>>>>>>>>>>>>>>>>  TRA TEMPERATURE <<<<<<<<<<<<<<<<<<'
+            WRITE(numout,*) '          TRA ztmlres    : ', SUM(ztmlres(:,:))
+            WRITE(numout,*) '          TRA ztmltot    : ', SUM(ztmltot(:,:))
+            WRITE(numout,*) '          TRA tmltrdm    : ', SUM(tmltrdm(:,:))
+            WRITE(numout,*) '          TRA tmlatfb    : ', SUM(tmlatfb(:,:))
+            WRITE(numout,*) '          TRA tmlatfn    : ', SUM(tmlatfn(:,:))
+            DO jl = 1, jpltrd
+               WRITE(numout,*) '          * TRA TREND INDEX jpmld_xxx = jl = ', jl, &
+                    & ' tmltrd : ', SUM(tmltrd(:,:,jl))
+            END DO
+            WRITE(numout,*) '          TRA ztmlres (jpi/2,jpj/2) : ', ztmlres (jpi/2,jpj/2)
+            WRITE(numout,*) '          TRA ztmlres2(jpi/2,jpj/2) : ', ztmlres2(jpi/2,jpj/2)
+            WRITE(numout,*)
+            WRITE(numout,*) '          >>>>>>>>>>>>>>>>>>  TRA SALINITY <<<<<<<<<<<<<<<<<<'
+            WRITE(numout,*) '          TRA zsmlres    : ', SUM(zsmlres(:,:))
+            WRITE(numout,*) '          TRA zsmltot    : ', SUM(zsmltot(:,:))
+            WRITE(numout,*) '          TRA smltrdm    : ', SUM(smltrdm(:,:))
+            WRITE(numout,*) '          TRA smlatfb    : ', SUM(smlatfb(:,:))
+            WRITE(numout,*) '          TRA smlatfn    : ', SUM(smlatfn(:,:))
+            DO jl = 1, jpltrd
+               WRITE(numout,*) '          * TRA TREND INDEX jpmld_xxx = jl = ', jl, &
+                    & ' smltrd : ', SUM(smltrd(:,:,jl))
+            END DO
+            WRITE(numout,*) '          TRA zsmlres (jpi/2,jpj/2) : ', zsmlres (jpi/2,jpj/2)
+            WRITE(numout,*) '          TRA zsmlres2(jpi/2,jpj/2) : ', zsmlres2(jpi/2,jpj/2)
+            !
+         END IF
+         !
+      END IF MODULO_NTRD
+
+      ! ======================================================================
+      ! IV. Write trends in the NetCDF file
+      ! ======================================================================
+
+      ! IV.1 Code for dimg mpp output
+      ! -----------------------------
+
+#if defined key_dimgout
+
+      IF( MOD( itmod, nn_trd ) == 0 ) THEN
+         iyear =  ndastp/10000
+         imon  = (ndastp-iyear*10000)/100
+         iday  =  ndastp - imon*100 - iyear*10000
+         WRITE(clname,9000) TRIM(cexper),'MLDiags',iyear,imon,iday
+         WRITE(clmode,'(f5.1,a)') nn_trd*rdt/86400.,' days average'
+         cltext = TRIM(cexper)//' mld diags'//TRIM(clmode)
+         CALL dia_wri_dimg (clname, cltext, smltrd, jpltrd, '2')
+      END IF
+
+9000  FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
+
+#else
+      
+      ! IV.2 Code for IOIPSL/NetCDF output
+      ! ----------------------------------
+
+      IF( lwp .AND. MOD( itmod , nn_trd ) == 0 ) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) 'trd_mld : write trends in the NetCDF file :'
+         WRITE(numout,*) '~~~~~~~  '
+         WRITE(numout,*) '          ', TRIM(clhstnam), ' at kt = ', kt
+         WRITE(numout,*) '          N.B. nmoymltrd = ', nmoymltrd
+         WRITE(numout,*) ' '
+      END IF
+         
+      !-- Write the trends for T/S instantaneous diagnostics 
+      IF( ln_trdmld_instant ) THEN           
+
+         CALL histwrite( nidtrd, "mxl_depth", it, rmld(:,:), ndimtrd1, ndextrd1 )
+         
+         !................................. ( ML temperature ) ...................................
+         
+         !-- Output the fields
+         CALL histwrite( nidtrd, "tml"     , it, tml    (:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "tml_tot" , it, ztmltot(:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "tml_res" , it, ztmlres(:,:), ndimtrd1, ndextrd1 ) 
+         
+         DO jl = 1, jpltrd - 1
+            CALL histwrite( nidtrd, trim("tml"//ctrd(jl,2)),            &
+                 &          it, tmltrd (:,:,jl), ndimtrd1, ndextrd1 )
+         END DO
+         
+         CALL histwrite( nidtrd, trim("tml"//ctrd(jpmld_atf,2)),        &
+              &          it, ztmlatf(:,:), ndimtrd1, ndextrd1 )
+         
+         !.................................. ( ML salinity ) .....................................
+         
+         !-- Output the fields
+         CALL histwrite( nidtrd, "sml"     , it, sml    (:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "sml_tot" , it, zsmltot(:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "sml_res" , it, zsmlres(:,:), ndimtrd1, ndextrd1 ) 
+         
+         DO jl = 1, jpltrd - 1
+            CALL histwrite( nidtrd, trim("sml"//ctrd(jl,2)),            &
+                 &          it, smltrd(:,:,jl), ndimtrd1, ndextrd1 )
+         END DO
+         
+         CALL histwrite( nidtrd, trim("sml"//ctrd(jpmld_atf,2)),        &
+              &          it, zsmlatf(:,:), ndimtrd1, ndextrd1 )
+         
+         IF( kt == nitend )   CALL histclo( nidtrd )
+
+      !-- Write the trends for T/S mean diagnostics 
+      ELSE
+         
+         CALL histwrite( nidtrd, "mxl_depth", it, rmld_sum(:,:), ndimtrd1, ndextrd1 ) 
+         
+         !................................. ( ML temperature ) ...................................
+         
+         !-- Output the fields
+         CALL histwrite( nidtrd, "tml"     , it, tml_sum (:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "tml_tot" , it, ztmltot2(:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "tml_res" , it, ztmlres2(:,:), ndimtrd1, ndextrd1 ) 
+         
+         DO jl = 1, jpltrd - 1
+            CALL histwrite( nidtrd, trim("tml"//ctrd(jl,2)),            &
+                 &          it, ztmltrd2(:,:,jl), ndimtrd1, ndextrd1 )
+         END DO
+         
+         CALL histwrite( nidtrd, trim("tml"//ctrd(jpmld_atf,2)),        &
+              &          it, ztmlatf2(:,:), ndimtrd1, ndextrd1 )
+         
+         !.................................. ( ML salinity ) .....................................
+                     
+         !-- Output the fields
+         CALL histwrite( nidtrd, "sml"     , it, sml_sum (:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "sml_tot" , it, zsmltot2(:,:), ndimtrd1, ndextrd1 ) 
+         CALL histwrite( nidtrd, "sml_res" , it, zsmlres2(:,:), ndimtrd1, ndextrd1 ) 
+         
+         DO jl = 1, jpltrd - 1
+            CALL histwrite( nidtrd, trim("sml"//ctrd(jl,2)),            &
+                 &          it, zsmltrd2(:,:,jl), ndimtrd1, ndextrd1 )
+         END DO
+         
+         CALL histwrite( nidtrd, trim("sml"//ctrd(jpmld_atf,2)),        &
+              &          it, zsmlatf2(:,:), ndimtrd1, ndextrd1 )
+         
+         IF( kt == nitend )   CALL histclo( nidtrd )
+
+      END IF
+      
+      ! Compute the control surface (for next time step) : flag = on
+      icount = 1
+      !
+#endif
+
+      IF( MOD( itmod, nn_trd ) == 0 ) THEN
+         !
+         ! III.5 Reset cumulative arrays to zero
+         ! -------------------------------------
+         nmoymltrd = 0
+         
+         !   ... temperature ...               ... salinity ...
+         tmltrdm        (:,:)   = 0.e0   ;   smltrdm        (:,:)   = 0.e0
+         tmlatfm        (:,:)   = 0.e0   ;   smlatfm        (:,:)   = 0.e0
+         tml_sum        (:,:)   = 0.e0   ;   sml_sum        (:,:)   = 0.e0
+         tmltrd_csum_ln (:,:,:) = 0.e0   ;   smltrd_csum_ln (:,:,:) = 0.e0
+         tmltrd_sum     (:,:,:) = 0.e0   ;   smltrd_sum     (:,:,:) = 0.e0
+
+         rmld_sum       (:,:)   = 0.e0
+         !
+      END IF
+
+      ! ======================================================================
+      ! V. Write restart file
+      ! ======================================================================
+
+      IF( lrst_oce )   CALL trd_mld_rst_write( kt ) 
+
+   END SUBROUTINE trd_mld
+
+
+   SUBROUTINE trd_mld_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_init  ***
+      !! 
+      !! ** Purpose :   computation of vertically integrated T and S budgets
+      !!      from ocean surface down to control surface (NetCDF output)
+      !!
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER :: jl
+      INTEGER :: inum   ! logical unit
+
+      REAL(wp) ::   zjulian, zsto, zout
+
+      CHARACTER (LEN=40) ::   clop
+      CHARACTER (LEN=12) ::   clmxl, cltu, clsu
+
+      !!----------------------------------------------------------------------
+
+      ! ======================================================================
+      ! I. initialization
+      ! ======================================================================
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' trd_mld_init : Mixed-layer trends'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~'
+         WRITE(numout,*) '                namelist namtrd read in trd_mod_init                        '
+         WRITE(numout,*)
+      END IF
+
+      ! I.1 Check consistency of user defined preferences
+      ! -------------------------------------------------
+
+      IF( ( lk_trdmld ) .AND. ( MOD( nitend, nn_trd ) /= 0 ) ) THEN
+         WRITE(numout,cform_err)
+         WRITE(numout,*) '                Your nitend parameter, nitend = ', nitend
+         WRITE(numout,*) '                is no multiple of the trends diagnostics frequency        '
+         WRITE(numout,*) '                          you defined, nn_trd   = ', nn_trd
+         WRITE(numout,*) '                This will not allow you to restart from this simulation.  '
+         WRITE(numout,*) '                You should reconsider this choice.                        ' 
+         WRITE(numout,*) 
+         WRITE(numout,*) '                N.B. the nitend parameter is also constrained to be a     '
+         WRITE(numout,*) '                multiple of the sea-ice frequency parameter (typically 5) '
+         nstop = nstop + 1
+      END IF
+
+      IF( ( lk_trdmld ) .AND. ( n_cla == 1 ) ) THEN
+         WRITE(numout,cform_war)
+         WRITE(numout,*) '                You set n_cla = 1. Note that the Mixed-Layer diagnostics  '
+         WRITE(numout,*) '                are not exact along the corresponding straits.            '
+         nwarn = nwarn + 1
+      END IF
+
+      ! I.2 Initialize arrays to zero or read a restart file
+      ! ----------------------------------------------------
+
+      nmoymltrd = 0
+
+      !     ... temperature ...                  ... salinity ...
+      tml            (:,:)   = 0.e0    ;    sml            (:,:)   = 0.e0     ! inst.
+      tmltrdm        (:,:)   = 0.e0    ;    smltrdm        (:,:)   = 0.e0
+      tmlatfm        (:,:)   = 0.e0    ;    smlatfm        (:,:)   = 0.e0
+      tml_sum        (:,:)   = 0.e0    ;    sml_sum        (:,:)   = 0.e0     ! mean
+      tmltrd_sum     (:,:,:) = 0.e0    ;    smltrd_sum     (:,:,:) = 0.e0
+      tmltrd_csum_ln (:,:,:) = 0.e0    ;    smltrd_csum_ln (:,:,:) = 0.e0
+
+      rmld           (:,:)   = 0.e0            
+      rmld_sum       (:,:)   = 0.e0
+
+      IF( ln_rstart .AND. ln_trdmld_restart ) THEN
+         CALL trd_mld_rst_read
+      ELSE
+         !     ... temperature ...                  ... salinity ...
+         tmlb           (:,:)   = 0.e0    ;    smlb           (:,:)   = 0.e0  ! inst.
+         tmlbb          (:,:)   = 0.e0    ;    smlbb          (:,:)   = 0.e0  
+         tmlbn          (:,:)   = 0.e0    ;    smlbn          (:,:)   = 0.e0  
+         tml_sumb       (:,:)   = 0.e0    ;    sml_sumb       (:,:)   = 0.e0  ! mean
+         tmltrd_csum_ub (:,:,:) = 0.e0    ;    smltrd_csum_ub (:,:,:) = 0.e0
+         tmltrd_atf_sumb(:,:)   = 0.e0    ;    smltrd_atf_sumb(:,:)   = 0.e0  
+      END IF
+
+      icount = 1   ;   ionce  = 1                            ! open specifier
+
+      ! I.3 Read control surface from file ctlsurf_idx
+      ! ----------------------------------------------
+ 
+      IF( nn_ctls == 1 ) THEN
+         CALL ctl_opn( inum, 'ctlsurf_idx', 'OLD', 'UNFORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+         READ ( inum ) nbol
+         CLOSE( inum )
+      END IF
+
+      ! ======================================================================
+      ! II. netCDF output initialization
+      ! ======================================================================
+
+#if defined key_dimgout 
+      ???
+#else
+      ! clmxl = legend root for netCDF output
+      IF( nn_ctls == 0 ) THEN      ! control surface = mixed-layer with density criterion
+         clmxl = 'Mixed Layer '  !                   (array nmln computed in zdfmxl.F90)
+      ELSE IF( nn_ctls == 1 ) THEN ! control surface = read index from file 
+         clmxl = '      Bowl '
+      ELSE IF( nn_ctls >= 2 ) THEN ! control surface = model level
+         WRITE(clmxl,'(A10,I2,1X)') 'Levels 1 -', nn_ctls
+      END IF
+
+      ! II.1 Define frequency of output and means
+      ! -----------------------------------------
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#  if defined key_diainstant
+      IF( .NOT. ln_trdmld_instant ) THEN
+         CALL ctl_stop( 'trd_mld : this was never checked. Comment this line to proceed...' )
+      END IF
+      zsto = nn_trd * rdt
+      clop = "inst("//TRIM(clop)//")"
+#  else
+      IF( ln_trdmld_instant ) THEN
+         zsto = rdt                 ! inst. diags : we use IOIPSL time averaging
+      ELSE
+         zsto = nn_trd * rdt          ! mean  diags : we DO NOT use any IOIPSL time averaging
+      END IF
+      clop = "ave("//TRIM(clop)//")"
+#  endif
+      zout = nn_trd * rdt
+
+      IF(lwp) WRITE (numout,*) '                netCDF initialization'
+
+      ! II.2 Compute julian date from starting date of the run
+      ! ------------------------------------------------------
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      IF(lwp) WRITE(numout,*)' '  
+      IF(lwp) WRITE(numout,*)'                Date 0 used :',nit000,    &
+         &                   ' YEAR ', nyear,' MONTH '      , nmonth,   &
+         &                   ' DAY ' , nday, 'Julian day : ', zjulian
+
+
+      ! II.3 Define the T grid trend file (nidtrd)
+      ! ------------------------------------------
+      !-- Define long and short names for the NetCDF output variables
+      !       ==> choose them according to trdmld_oce.F90 <==
+
+      ctrd(jpmld_xad,1) = " Zonal advection"                  ;   ctrd(jpmld_xad,2) = "_xad"
+      ctrd(jpmld_yad,1) = " Meridional advection"             ;   ctrd(jpmld_yad,2) = "_yad"
+      ctrd(jpmld_zad,1) = " Vertical advection"               ;   ctrd(jpmld_zad,2) = "_zad"
+      ctrd(jpmld_ldf,1) = " Lateral diffusion"                ;   ctrd(jpmld_ldf,2) = "_ldf"
+      ctrd(jpmld_for,1) = " Forcing"                          ;   ctrd(jpmld_for,2) = "_for"
+      ctrd(jpmld_zdf,1) = " Vertical diff. (Kz)"              ;   ctrd(jpmld_zdf,2) = "_zdf"
+      ctrd(jpmld_bbc,1) = " Geothermal flux"                  ;   ctrd(jpmld_bbc,2) = "_bbc"
+      ctrd(jpmld_bbl,1) = " Adv/diff. Bottom boundary layer"  ;   ctrd(jpmld_bbl,2) = "_bbl"
+      ctrd(jpmld_dmp,1) = " Tracer damping"                   ;   ctrd(jpmld_dmp,2) = "_dmp"
+      ctrd(jpmld_npc,1) = " Non penetrative convec. adjust."  ;   ctrd(jpmld_npc,2) = "_npc"
+      ctrd(jpmld_atf,1) = " Asselin time filter"              ;   ctrd(jpmld_atf,2) = "_atf"
+                                                                  
+      !-- Create a NetCDF file and enter the define mode 
+      CALL dia_nam( clhstnam, nn_trd, 'trends' )
+      IF(lwp) WRITE(numout,*) ' Name of NETCDF file ', clhstnam
+      CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,                                            &
+      &             1, jpi, 1, jpj, nit000-1, zjulian, rdt, nh_t, nidtrd, domain_id=nidom )
+
+      !-- Define the ML depth variable
+      CALL histdef(nidtrd, "mxl_depth", clmxl//"  Mixed Layer Depth"              , "m",         &
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+
+      !-- Define physical units
+      IF     ( rn_ucf == 1.       ) THEN   ;   cltu = "degC/s"     ;   clsu = "p.s.u./s"
+      ELSEIF ( rn_ucf == 3600.*24.) THEN   ;   cltu = "degC/day"   ;   clsu = "p.s.u./day"
+      ELSE                                 ;   cltu = "unknown?"   ;   clsu = "unknown?"
+      END IF
+
+
+      !-- Define miscellaneous T and S mixed-layer variables 
+
+      IF( jpltrd /= jpmld_atf ) CALL ctl_stop( 'Error : jpltrd /= jpmld_atf' ) ! see below
+
+      !................................. ( ML temperature ) ...................................
+
+      CALL histdef(nidtrd, "tml"      , clmxl//" T Mixed Layer Temperature"       ,  "C",        &
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zsto, zout )           
+      CALL histdef(nidtrd, "tml_tot",   clmxl//" T Total trend"                   , cltu,        & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout )              
+      CALL histdef(nidtrd, "tml_res",   clmxl//" T dh/dt Entrainment (Resid.)"    , cltu,        & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout )                   
+      
+      DO jl = 1, jpltrd - 1      ! <== only true if jpltrd == jpmld_atf
+         CALL histdef(nidtrd, trim("tml"//ctrd(jl,2)), clmxl//" T"//ctrd(jl,1), cltu,            & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) ! IOIPSL: time mean
+      END DO                                                                 ! if zsto=rdt above
+      
+      CALL histdef(nidtrd, trim("tml"//ctrd(jpmld_atf,2)), clmxl//" T"//ctrd(jpmld_atf,1), cltu, & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout ) ! IOIPSL: NO time mean
+      
+      !.................................. ( ML salinity ) .....................................
+     
+      CALL histdef(nidtrd, "sml"      , clmxl//" S Mixed Layer Salinity"          , "p.s.u.",       &
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zsto, zout )           
+      CALL histdef(nidtrd, "sml_tot",   clmxl//" S Total trend"                   , clsu,        & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout )              
+      CALL histdef(nidtrd, "sml_res",   clmxl//" S dh/dt Entrainment (Resid.)"    , clsu,        & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout )                   
+      
+      DO jl = 1, jpltrd - 1      ! <== only true if jpltrd == jpmld_atf
+         CALL histdef(nidtrd, trim("sml"//ctrd(jl,2)), clmxl//" S"//ctrd(jl,1), clsu,            & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) ! IOIPSL: time mean
+      END DO                                                                 ! if zsto=rdt above
+      
+      CALL histdef(nidtrd, trim("sml"//ctrd(jpmld_atf,2)), clmxl//" S"//ctrd(jpmld_atf,1), clsu, & 
+                   jpi, jpj, nh_t, 1  , 1, 1  , -99 , 32, clop, zout, zout ) ! IOIPSL: NO time mean
+
+      !-- Leave IOIPSL/NetCDF define mode
+      CALL histend( nidtrd )
+
+#endif        /* key_dimgout */
+   END SUBROUTINE trd_mld_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trd_mld( kt )             ! Empty routine
+      INTEGER, INTENT( in) ::   kt
+      WRITE(*,*) 'trd_mld: You should not have seen this print! error?', kt
+   END SUBROUTINE trd_mld
+   SUBROUTINE trd_mld_zint( pttrdmld, pstrdmld, ktrd, ctype )
+      REAL, DIMENSION(:,:,:), INTENT( in ) ::   &
+         pttrdmld, pstrdmld                   ! Temperature and Salinity trends
+      INTEGER, INTENT( in ) ::   ktrd         ! ocean trend index
+      CHARACTER(len=2), INTENT( in ) ::   &  
+         ctype                                ! surface/bottom (2D arrays) or
+         !                                    ! interior (3D arrays) physics
+      WRITE(*,*) 'trd_mld_zint: You should not have seen this print! error?', pttrdmld(1,1,1)
+      WRITE(*,*) '  "      "  : You should not have seen this print! error?', pstrdmld(1,1,1)
+      WRITE(*,*) '  "      "  : You should not have seen this print! error?', ctype
+      WRITE(*,*) '  "      "  : You should not have seen this print! error?', ktrd
+   END SUBROUTINE trd_mld_zint
+   SUBROUTINE trd_mld_init              ! Empty routine
+      WRITE(*,*) 'trd_mld_init: You should not have seen this print! error?'
+   END SUBROUTINE trd_mld_init
+#endif
+
+   !!======================================================================
+END MODULE trdmld
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_oce.F90	(revision 1844)
@@ -0,0 +1,89 @@
+MODULE trdmld_oce
+   !!======================================================================
+   !!                   ***  MODULE trdmld_oce  ***
+   !! Ocean trends :   set tracer and momentum trend variables
+   !!======================================================================
+   !! History :  9.0  !  04-08  (C. Talandier)  New trends organization
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+#if defined key_trdmld
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trdmld = .TRUE.    !: ML trend flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trdmld = .FALSE.   !: ML trend flag
+#endif
+   !!* mixed layer trends indices
+   INTEGER, PARAMETER, PUBLIC ::   jpltrd = 11    !: number of mixed-layer trends arrays
+   INTEGER, PUBLIC   & 
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+::   jpktrd = jpk   !: max level for mixed-layer trends diag.
+   !
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_xad =  1   !:  zonal      
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_yad =  2   !:  meridonal   > advection
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_zad =  3   !:  vertical   
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_ldf =  4   !:  lateral diffusion (geopot. or iso-neutral)
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_for =  5   !:  forcing 
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_zdf =  6   !:  vertical diffusion (TKE)
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_bbc =  7   !:  geothermal flux
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_bbl =  8   !:  bottom boundary layer (advective/diffusive)
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_dmp =  9   !:  internal restoring trend
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_npc = 10   !:  non penetrative convective adjustment
+!! INTEGER, PUBLIC, PARAMETER ::   jpmld_xxx = xx   !:  add here any additional trend (add change jpltrd)
+   INTEGER, PUBLIC, PARAMETER ::   jpmld_atf = 11   !:  asselin trend (**MUST BE THE LAST ONE**)
+
+#if   defined  key_trdmld   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trdmld'                         mixed layer trends diagnostics
+   !!----------------------------------------------------------------------
+
+   !! Arrays used for diagnosing mixed-layer trends 
+   !!---------------------------------------------------------------------
+   CHARACTER(LEN=80) , PUBLIC :: clname, ctrd(jpltrd+1,2)
+
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj)     ::   nmld   !: mixed layer depth indexes 
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj)     ::   nbol   !: mixed-layer depth indexes when read from file
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   wkx    !:
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &
+      rmld   ,                      & !: mld depth (m) corresponding to nmld
+      tml    , sml  ,               & !: \ "now" mixed layer temperature/salinity
+      tmlb   , smlb ,               & !: /  and associated "before" fields
+      tmlbb  , smlbb,               & !: \  idem, but valid at the 1rst time step of the
+      tmlbn  , smlbn,               & !: /  current analysis window
+      tmltrdm, smltrdm,             & !: total cumulative trends over the analysis window
+      tml_sum,                      & !: mixed layer T, summed over the current analysis period
+      tml_sumb,                     & !: idem, but from the previous analysis period
+      tmltrd_atf_sumb,              & !: Asselin trends, summed over the previous analysis period
+      sml_sum,                      & !: 
+      sml_sumb,                     & !:    ( idem for salinity )
+      smltrd_atf_sumb,              & !: 
+      rmld_sum, rmldbn                !: needed to compute the leap-frog time mean of the ML depth
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &
+      tmlatfb, tmlatfn ,            & !: "before" Asselin contribution at begining of the averaging
+      smlatfb, smlatfn,             & !: period (i.e. last contrib. from previous such period) and 
+                                      !: "now" Asselin contribution to the ML temp. & salinity trends
+      tmlatfm, smlatfm                !: accumulator for Asselin trends (needed for storage only)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpltrd) ::  &
+      tmltrd,                       & !: \ physical contributions to the total trend (for T/S),
+      smltrd,                       & !: / cumulated over the current analysis window
+      tmltrd_sum,                   & !: sum of these trends over the analysis period
+      tmltrd_csum_ln,               & !: now cumulated sum of the trends over the "lower triangle"
+      tmltrd_csum_ub,               & !: before (prev. analysis period) cumulated sum over the upper triangle
+      smltrd_sum,                   & !: 
+      smltrd_csum_ln,               & !:    ( idem for salinity )
+      smltrd_csum_ub                  !: 
+#endif
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE trdmld_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_rst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_rst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmld_rst.F90	(revision 1844)
@@ -0,0 +1,208 @@
+MODULE trdmld_rst
+   !!=================================================================================
+   !!                       ***  MODULE  trdmld_rst  ***
+   !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
+   !!=================================================================================
+   !! History :  9.0  ! 05-05 (C. Deltel) Original code
+   !!---------------------------------------------------------------------------------
+#if defined key_trdmld
+   !!---------------------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE trdmod_oce      ! ocean variables for trend diagnostics (i.e. icp/mixed-layer/vorticity)
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE restart         ! only for lrst_oce
+
+   IMPLICIT NONE
+   PRIVATE
+  
+   PUBLIC   trd_mld_rst_read    ! routine called by trd_mld_init
+   PUBLIC   trd_mld_rst_write   ! routine called by step.F90
+  
+   INTEGER ::   nummldw         ! logical unit for mld restart
+
+   !!---------------------------------------------------------------------------------
+   !! OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!---------------------------------------------------------------------------------
+  
+CONTAINS
+  
+   SUBROUTINE trd_mld_rst_write( kt )
+      !!--------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE trd_mld_rst_wri  ***
+      !!                
+      !! ** Purpose :   Write mixed-layer diagnostics restart fields.
+      !!--------------------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !
+      CHARACTER (len=35) :: charout
+      INTEGER ::   jk                 ! loop indice
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      !!--------------------------------------------------------------------------------
+
+      ! to get better performances with NetCDF format:
+      ! we open and define the ocean restart_mld file one time step before writing the data (-> at nitrst - 1)
+      ! except if we write ocean restart_mld files every time step or if an ocean restart_mld file was writen at nitend - 1
+      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nstock ) == 0 ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+         IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+         ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trdrst_out)
+         IF(lwp) THEN
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ocean restart_mld binary file: '//clname
+            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart_mld NetCDF file: '//clname
+            END SELECT
+            IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp
+            ELSE                          ;   WRITE(numout,*) '             kt = '             , kt,' date= ', ndastp
+            ENDIF
+         ENDIF
+
+         CALL iom_open( clname, nummldw, ldwrt = .TRUE., kiolib = jprstlib )
+      ENDIF
+
+      IF( kt == nitrst .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trdmld_rst: output for ML diags. restart, with trd_mld_rst_write routine kt =', kt
+         WRITE(numout,*) '~~~~~~~~~~'
+         WRITE(numout,*)
+      ENDIF
+
+      IF( ln_trdmld_instant ) THEN 
+         !-- Temperature
+         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbb'           , tmlbb           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbn'           , tmlbn           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'tmlatfb'         , tmlatfb         )
+
+         !-- Salinity
+         CALL iom_rstput( kt, nitrst, nummldw, 'smlbb'           , smlbb           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'smlbn'           , smlbn           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'smlatfb'         , smlatfb         )
+      ELSE
+         CALL iom_rstput( kt, nitrst, nummldw, 'rmldbn'          , rmldbn          )
+
+         !-- Temperature
+         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbn'           , tmlbn           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'tml_sumb'        , tml_sumb        )
+         DO jk = 1, jpltrd
+            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk
+            ELSE                 ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk
+            ENDIF
+            CALL iom_rstput( kt, nitrst, nummldw, charout,  tmltrd_csum_ub(:,:,jk) )
+         ENDDO
+         CALL iom_rstput( kt, nitrst, nummldw, 'tmltrd_atf_sumb' , tmltrd_atf_sumb )
+
+         !-- Salinity
+         CALL iom_rstput( kt, nitrst, nummldw, 'smlbn'           , smlbn           )
+         CALL iom_rstput( kt, nitrst, nummldw, 'sml_sumb'        , sml_sumb        )
+         DO jk = 1, jpltrd
+            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk
+            ELSE                 ;   WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk
+            ENDIF
+            CALL iom_rstput( kt, nitrst, nummldw, charout , smltrd_csum_ub(:,:,jk) )
+         ENDDO
+         CALL iom_rstput( kt, nitrst, nummldw, 'smltrd_atf_sumb' , smltrd_atf_sumb )
+      ENDIF
+      !
+      IF( kt == nitrst ) THEN
+         CALL iom_close( nummldw )     ! close the restart file (only at last time step)
+         lrst_oce = .FALSE.
+      ENDIF
+      ! 
+      !    
+   END SUBROUTINE trd_mld_rst_write
+
+
+   SUBROUTINE trd_mld_rst_read
+    !!----------------------------------------------------------------------------
+    !!                   ***  SUBROUTINE trd_mld_rst_lec  ***
+    !!                   
+    !! ** Purpose :   Read file for mixed-layer diagnostics restart.
+    !!----------------------------------------------------------------------------
+    INTEGER  ::  inum       ! temporary logical unit
+    !
+    CHARACTER (len=35) :: charout
+    INTEGER ::   jk         ! loop indice
+    INTEGER ::   jlibalt = jprstlib
+    LOGICAL ::   llok
+    !!-----------------------------------------------------------------------------
+
+    IF(lwp)  THEN
+       WRITE(numout,*)
+       WRITE(numout,*) ' trd_mld_rst_read : read the NetCDF MLD restart file'
+       WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
+    ENDIF
+    IF ( jprstlib == jprstdimg ) THEN
+       ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+       ! if {cn_trdrst_in}.nc exists, then set jlibalt to jpnf90
+       INQUIRE( FILE = TRIM(cn_trdrst_in)//'.nc', EXIST = llok )
+       IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+    ENDIF
+
+    CALL iom_open( cn_trdrst_in, inum, kiolib = jlibalt ) 
+
+    IF( ln_trdmld_instant ) THEN 
+       !-- Temperature
+       CALL iom_get( inum, jpdom_autoglo, 'tmlbb'           , tmlbb          )
+       CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          )
+       CALL iom_get( inum, jpdom_autoglo, 'tmlatfb'         , tmlatfb        )
+
+       !-- Salinity
+       CALL iom_get( inum, jpdom_autoglo, 'smlbb'           , smlbb          )
+       CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          )
+       CALL iom_get( inum, jpdom_autoglo, 'smlatfb'         , smlatfb        )
+    ELSE
+       CALL iom_get( inum, jpdom_autoglo, 'rmldbn'          , rmldbn         ) ! needed for rmld_sum
+
+       !-- Temperature
+       CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          ) ! needed for tml_sum
+       CALL iom_get( inum, jpdom_autoglo, 'tml_sumb'        , tml_sumb       )
+       DO jk = 1, jpltrd
+          IF( jk < 10 )   THEN
+             WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk
+          ELSE
+             WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk
+          ENDIF
+          CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub(:,:,jk) )
+       ENDDO
+       CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb' , tmltrd_atf_sumb)
+
+       !-- Salinity
+       CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          ) ! needed for sml_sum
+       CALL iom_get( inum, jpdom_autoglo, 'sml_sumb'        , sml_sumb       )
+       DO jk = 1, jpltrd
+          IF( jk < 10 )   THEN
+             WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk
+          ELSE
+             WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk
+          ENDIF
+          CALL iom_get( inum, jpdom_autoglo, charout, smltrd_csum_ub(:,:,jk) )
+       ENDDO
+       CALL iom_get( inum, jpdom_autoglo, 'smltrd_atf_sumb' , smltrd_atf_sumb)
+
+       CALL iom_close( inum )
+    ENDIF
+
+  END SUBROUTINE trd_mld_rst_read
+  
+#else
+  !!=================================================================================
+  !!                       ***  MODULE  trdmld_rst  ***
+  !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
+  !!=================================================================================
+CONTAINS
+  SUBROUTINE trd_mld_rst_write( kt )           !  No ML diags ==> empty routine
+    WRITE(*,*) 'trd_mld_rst_wri: You should not have seen this print! error?', kt
+  END SUBROUTINE trd_mld_rst_write
+  SUBROUTINE trd_mld_rst_read                  !  No ML Diags ==> empty routine
+  END SUBROUTINE trd_mld_rst_read
+#endif
+
+  !!=================================================================================
+END MODULE trdmld_rst
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod.F90	(revision 1844)
@@ -0,0 +1,289 @@
+MODULE trdmod
+   !!======================================================================
+   !!                       ***  MODULE  trdmod  ***
+   !! Ocean diagnostics:  ocean tracers and dynamic trends
+   !!=====================================================================
+   !! History :  9.0  !  04-08  (C. Talandier) Original code
+   !!                 !  05-04  (C. Deltel)    Add Asselin trend in the ML budget
+   !!----------------------------------------------------------------------
+#if  defined key_trdtra || defined key_trddyn || defined key_trdmld || defined key_trdvor || defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   trd_mod          : Call the trend to be computed
+   !!   trd_mod_init     : Initialization step
+   !!----------------------------------------------------------------------
+   USE oce                     ! ocean dynamics and tracers variables
+   USE dom_oce                 ! ocean space and time domain variables
+   USE zdf_oce                 ! ocean vertical physics variables
+   USE trdmod_oce              ! ocean variables trends
+   USE ldftra_oce              ! ocean active tracers lateral physics
+   USE sbc_oce                 ! surface boundary condition: ocean
+   USE phycst                  ! physical constants
+   USE trdvor                  ! ocean vorticity trends 
+   USE trdicp                  ! ocean bassin integral constraints properties
+   USE trdmld                  ! ocean active mixed layer tracers trends 
+   USE in_out_manager          ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   REAL(wp) ::   r2dt          ! time-step, = 2 rdttra except at nit000 (=rdttra) if neuler=0
+
+   PUBLIC trd_mod              ! called by all dynXX or traXX modules
+   PUBLIC trd_mod_init         ! called by opa.F90 module
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trd_mod( ptrdx, ptrdy, ktrd, ctype, kt, cnbpas )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mod  ***
+      !! 
+      !! ** Purpose : Dispatch all trends computation, e.g. vorticity, mld or 
+      !!              integral constraints
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                                ! time step
+      INTEGER, INTENT( in ) ::   ktrd                              ! tracer trend index
+      CHARACTER(len=3), INTENT( in ) ::   ctype                    ! momentum or tracers trends type 'DYN'/'TRA'
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::   cnbpas         ! number of passage
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdx ! Temperature or U trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdy ! Salinity    or V trend
+      !!
+      INTEGER ::   ji, jj
+      CHARACTER(len=3) ::   ccpas                                  ! number of passage
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztswu, ztswv               ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztbfu, ztbfv               ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2dx, z2dy                 ! workspace arrays
+      !!----------------------------------------------------------------------
+
+      z2dx(:,:)   = 0.e0   ;   z2dy(:,:)   = 0.e0                  ! initialization of workspace arrays
+
+      ! Control of optional arguments
+      ccpas = 'fst'
+      IF( PRESENT(cnbpas) )  ccpas = cnbpas
+
+      IF( neuler == 0 .AND. kt == nit000    ) THEN   ;   r2dt =      rdt      ! = rdtra (restarting with Euler time stepping)
+      ELSEIF(               kt <= nit000 + 1) THEN   ;   r2dt = 2. * rdt      ! = 2 rdttra (leapfrog)
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! I. Integral Constraints Properties for momentum and/or tracers trends
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      IF( ( mod(kt,nn_trd) == 0 .OR. kt == nit000 .OR. kt == nitend) )   THEN
+         !
+         IF( lk_trdtra .AND. ctype == 'TRA' )   THEN       ! active tracer trends
+            SELECT CASE ( ktrd )
+            CASE ( jptra_trd_ldf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_ldf, ctype )   ! lateral diff
+            CASE ( jptra_trd_zdf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_zdf, ctype )   ! vertical diff (Kz)
+            CASE ( jptra_trd_bbc )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_bbc, ctype )   ! bottom boundary cond
+            CASE ( jptra_trd_bbl )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_bbl, ctype )   ! bottom boundary layer
+            CASE ( jptra_trd_npc )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_npc, ctype )   ! static instability mixing
+            CASE ( jptra_trd_dmp )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_dmp, ctype )   ! damping
+            CASE ( jptra_trd_qsr )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_qsr, ctype )   ! penetrative solar radiat.
+            CASE ( jptra_trd_nsr )   
+               z2dx(:,:) = ptrdx(:,:,1)   ;   z2dy(:,:) = ptrdy(:,:,1)
+               CALL trd_icp( z2dx, z2dy, jpicpt_nsr, ctype )                               ! non solar radiation
+            CASE ( jptra_trd_xad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_xad, ctype )   ! x- horiz adv
+            CASE ( jptra_trd_yad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_yad, ctype )   ! y- horiz adv
+            CASE ( jptra_trd_zad )                                                         ! z- vertical adv 
+               CALL trd_icp( ptrdx, ptrdy, jpicpt_zad, ctype, clpas=ccpas )   
+               ! compute the surface flux condition wn(:,:,1)*tn(:,:,1)
+               z2dx(:,:) = wn(:,:,1)*tn(:,:,1)/fse3t(:,:,1)
+               z2dy(:,:) = wn(:,:,1)*sn(:,:,1)/fse3t(:,:,1)
+               CALL trd_icp( z2dx , z2dy , jpicpt_zl1, ctype )                             ! 1st z- vertical adv 
+            END SELECT
+         END IF
+
+         IF( lk_trddyn .AND. ctype == 'DYN' )   THEN       ! momentum trends 
+            !
+            SELECT CASE ( ktrd )
+            CASE ( jpdyn_trd_hpg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_hpg, ctype )   ! hydrost. pressure grad
+            CASE ( jpdyn_trd_keg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_keg, ctype )   ! KE gradient 
+            CASE ( jpdyn_trd_rvo )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_rvo, ctype )   ! relative vorticity 
+            CASE ( jpdyn_trd_pvo )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_pvo, ctype )   ! planetary vorticity
+            CASE ( jpdyn_trd_ldf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_ldf, ctype )   ! lateral diffusion 
+            CASE ( jpdyn_trd_had )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_had, ctype )   ! horizontal advection 
+            CASE ( jpdyn_trd_zad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_zad, ctype )   ! vertical advection 
+            CASE ( jpdyn_trd_spg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_spg, ctype )   ! surface pressure grad.
+            CASE ( jpdyn_trd_dat )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_dat, ctype )   ! damping term
+            CASE ( jpdyn_trd_zdf )                                                         ! vertical diffusion 
+               ! subtract surface forcing/bottom friction trends 
+               ! from vertical diffusive momentum trends
+               ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0
+               ztbfu(:,:) = 0.e0   ;   ztbfv(:,:) = 0.e0  
+               DO jj = 2, jpjm1   
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ! save the surface forcing momentum fluxes
+                     ztswu(ji,jj) = utau(ji,jj) / ( fse3u(ji,jj,1)*rau0 )
+                     ztswv(ji,jj) = vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 )
+                     ! bottom friction contribution now handled explicitly
+                     !
+                     ptrdx(ji,jj,1     ) = ptrdx(ji,jj,1     ) - ztswu(ji,jj)
+                     ptrdy(ji,jj,1     ) = ptrdy(ji,jj,1     ) - ztswv(ji,jj)
+                  END DO
+               END DO
+               !
+               CALL trd_icp( ptrdx, ptrdy, jpicpd_zdf, ctype )   
+               CALL trd_icp( ztswu, ztswv, jpicpd_swf, ctype )                               ! wind stress forcing term
+               ! bottom friction contribution now handled explicitly
+            CASE ( jpdyn_trd_bfr )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_bfr, ctype )     ! bottom friction term
+            END SELECT
+            !
+         END IF
+         !
+      END IF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! II. Vorticity trends
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      IF( lk_trdvor .AND. ctype == 'DYN' )   THEN
+         !
+         SELECT CASE ( ktrd ) 
+         CASE ( jpdyn_trd_hpg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_prg )   ! Hydrostatique Pressure Gradient 
+         CASE ( jpdyn_trd_keg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_keg )   ! KE Gradient 
+         CASE ( jpdyn_trd_rvo )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_rvo )   ! Relative Vorticity 
+         CASE ( jpdyn_trd_pvo )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_pvo )   ! Planetary Vorticity Term 
+         CASE ( jpdyn_trd_ldf )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_ldf )   ! Horizontal Diffusion 
+         CASE ( jpdyn_trd_had )   ;   CALL ctl_warn('Vorticity for horizontal advection trend never checked')   
+         CASE ( jpdyn_trd_zad )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_zad )   ! Vertical Advection 
+         CASE ( jpdyn_trd_spg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_spg )   ! Surface Pressure Grad. 
+         CASE ( jpdyn_trd_dat )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_bev )   ! Beta V  
+         CASE ( jpdyn_trd_zdf )                                                      ! Vertical Diffusion 
+            ! subtract surface forcing/bottom friction trends 
+            ! from vertical diffusive momentum trends
+            ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0
+            ztbfu(:,:) = 0.e0   ;   ztbfv(:,:) = 0.e0  
+            DO jj = 2, jpjm1   
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! save the surface forcing momentum fluxes
+                  ztswu(ji,jj) = utau(ji,jj) / ( fse3u(ji,jj,1)*rau0 )
+                  ztswv(ji,jj) = vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 )
+                  !
+                  ptrdx(ji,jj,1     ) = ptrdx(ji,jj,1     ) - ztswu(ji,jj)
+                  ptrdy(ji,jj,1     ) = ptrdy(ji,jj,1     ) - ztswv(ji,jj)
+               END DO
+            END DO
+            !
+            CALL trd_vor_zint( ptrdx, ptrdy, jpvor_zdf )   
+            CALL trd_vor_zint( ztswu, ztswv, jpvor_swf )                               ! Wind stress forcing term
+         CASE ( jpdyn_trd_bfr )
+            CALL trd_vor_zint( ptrdx, ptrdy, jpvor_bfr )                               ! Bottom friction term
+         END SELECT
+         !
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! III. Mixed layer trends for active tracers
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      IF( lk_trdmld .AND. ctype == 'TRA' )   THEN
+         
+         !-----------------------------------------------------------------------------------------------
+         ! W.A.R.N.I.N.G :
+         ! jptra_trd_ldf : called by traldf.F90
+         !                 at this stage we store:
+         !                  - the lateral geopotential diffusion (here, lateral = horizontal)
+         !                  - and the iso-neutral diffusion if activated 
+         ! jptra_trd_zdf : called by trazdf.F90
+         !                 * in case of iso-neutral diffusion we store the vertical diffusion component in the 
+         !                   lateral trend including the K_z contrib, which will be removed later (see trd_mld)
+         !-----------------------------------------------------------------------------------------------
+
+         SELECT CASE ( ktrd )
+         CASE ( jptra_trd_xad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_xad, '3D' )   ! merid. advection
+         CASE ( jptra_trd_yad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_yad, '3D' )   ! zonal  advection
+         CASE ( jptra_trd_zad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_zad, '3D' )   ! vertical advection
+         CASE ( jptra_trd_ldf )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_ldf, '3D' )   ! lateral diffusive
+         CASE ( jptra_trd_bbl )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_bbl, '3D' )   ! bottom boundary layer
+         CASE ( jptra_trd_zdf )
+            IF( ln_traldf_iso )   THEN
+               CALL trd_mld_zint( ptrdx, ptrdy, jpmld_ldf, '3D' )   ! vertical diffusion (K_z)
+            ELSE
+               CALL trd_mld_zint( ptrdx, ptrdy, jpmld_zdf, '3D' )   ! vertical diffusion (K_z)
+            ENDIF
+         CASE ( jptra_trd_dmp )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_dmp, '3D' )   ! internal 3D restoring (tradmp)
+         CASE ( jptra_trd_qsr )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_for, '3D' )   ! air-sea : penetrative sol radiat
+         CASE ( jptra_trd_nsr )
+            ptrdx(:,:,2:jpk) = 0.e0   ;   ptrdy(:,:,2:jpk) = 0.e0
+            CALL trd_mld_zint( ptrdx, ptrdy, jpmld_for, '2D' )                             ! air-sea : non penetr sol radiat
+         CASE ( jptra_trd_bbc )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_bbc, '3D' )   ! bottom bound cond (geoth flux)
+         CASE ( jptra_trd_atf )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_atf, '3D' )   ! asselin numerical
+         CASE ( jptra_trd_npc )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_npc, '3D' )   ! non penetr convect adjustment
+         END SELECT
+
+      ENDIF
+
+   END SUBROUTINE trd_mod
+
+#   else
+   !!----------------------------------------------------------------------
+   !!   Default case :                                         Empty module
+   !!----------------------------------------------------------------------
+   USE trdmod_oce      ! ocean variables trends
+   USE trdvor          ! ocean vorticity trends 
+   USE trdicp          ! ocean bassin integral constraints properties
+   USE trdmld          ! ocean active mixed layer tracers trends 
+
+CONTAINS
+   SUBROUTINE trd_mod(ptrd3dx, ptrd3dy, ktrd , ctype, kt, cnbpas)   ! Empty routine
+      REAL, DIMENSION(:,:,:), INTENT( in ) ::   &
+          ptrd3dx,                     &                           ! Temperature or U trend 
+          ptrd3dy                                                  ! Salinity    or V trend
+      INTEGER, INTENT( in ) ::   ktrd                              ! momentum or tracer trend index
+      INTEGER, INTENT( in ) ::   kt                                ! Time step
+      CHARACTER(len=3), INTENT( in ) ::  ctype                     ! momentum or tracers trends type
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::   cnbpas         ! number of passage
+      WRITE(*,*) 'trd_3d: You should not have seen this print! error ?', ptrd3dx(1,1,1)
+      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ptrd3dy(1,1,1)
+      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ktrd
+      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ctype
+      WRITE(*,*) ' "   ": You should not have seen this print! error ?', kt
+      WRITE(*,*) ' "   ": You should not have seen this print! error ?', cnbpas
+   END SUBROUTINE trd_mod
+#   endif
+
+   SUBROUTINE trd_mod_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mod_init  ***
+      !! 
+      !! ** Purpose :   Initialization of activated trends
+      !!----------------------------------------------------------------------
+      USE in_out_manager          ! I/O manager
+
+      NAMELIST/namtrd/ nn_trd, nn_ctls, cn_trdrst_in, cn_trdrst_out, ln_trdmld_restart, rn_ucf, ln_trdmld_instant
+      !!----------------------------------------------------------------------
+
+      IF( l_trdtra .OR. l_trddyn )   THEN
+         REWIND( numnam )
+         READ  ( numnam, namtrd )      ! namelist namtrd : trends diagnostic
+
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' trd_mod_init : Momentum/Tracers trends'
+            WRITE(numout,*) ' ~~~~~~~~~~~~~'
+            WRITE(numout,*) '   Namelist namtrd : set trends parameters'
+            WRITE(numout,*) '      frequency of trends diagnostics   nn_trd             = ', nn_trd
+            WRITE(numout,*) '      control surface type              nn_ctls            = ', nn_ctls
+            WRITE(numout,*) '      restart for ML diagnostics        ln_trdmld_restart  = ', ln_trdmld_restart
+            WRITE(numout,*) '      instantaneous or mean ML T/S      ln_trdmld_instant  = ', ln_trdmld_instant
+            WRITE(numout,*) '      unit conversion factor            rn_ucf             = ', rn_ucf
+        ENDIF
+      ENDIF
+      !
+      IF( lk_trddyn .OR. lk_trdtra )    CALL trd_icp_init       ! integral constraints trends
+      IF( lk_trdmld                )    CALL trd_mld_init       ! mixed-layer trends (active  tracers)  
+      IF( lk_trdvor                )    CALL trd_vor_init       ! vorticity trends        
+      !
+   END SUBROUTINE trd_mod_init
+
+   !!======================================================================
+END MODULE trdmod
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdmod_oce.F90	(revision 1844)
@@ -0,0 +1,69 @@
+MODULE trdmod_oce
+   !!======================================================================
+   !!                   ***  MODULE trdmod_oce  ***
+   !! Ocean trends :   set tracer and momentum trend variables
+   !!======================================================================
+   !! History :  9.0  !  04-08  (C. Talandier) Original code
+   !!----------------------------------------------------------------------
+   USE trdicp_oce              ! ocean momentum/tracers bassin properties trends variables
+   USE trdmld_oce              ! ocean active mixed layer tracers trends variables
+   USE trdvor_oce              ! ocean vorticity trends variables
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !                                                     !!* Namelist namtrd:  diagnostics on dynamics/tracer trends *
+   INTEGER , PUBLIC  ::   nn_trd  = 10                    !: time step frequency dynamics and tracers trends
+   INTEGER , PUBLIC  ::   nn_ctls =  0                    !: control surface type for trends vertical integration
+   REAL(wp), PUBLIC  ::   rn_ucf   = 1.                   !: unit conversion factor (for netCDF trends outputs)
+                                                          !: =1. (=86400.) for degC/s (degC/day) and psu/s (psu/day)
+   CHARACTER(len=32) ::   cn_trdrst_in  = "restart_mld"   !: suffix of ocean restart name (input)
+   CHARACTER(len=32) ::   cn_trdrst_out = "restart_mld"   !: suffix of ocean restart name (output)
+   LOGICAL , PUBLIC  ::   ln_trdmld_instant = .FALSE.     !: flag to diagnose inst./mean ML T/S trends
+   LOGICAL , PUBLIC  ::   ln_trdmld_restart = .FALSE.     !: flag to restart mixed-layer diagnostics
+
+# if defined key_trdtra   ||   defined key_trdmld
+   LOGICAL , PUBLIC ::   l_trdtra = .TRUE.              !: tracers  trend flag
+# else
+   LOGICAL , PUBLIC ::   l_trdtra = .FALSE.             !: tracers  trend flag
+# endif
+# if defined key_trddyn   ||   defined key_trdvor
+   LOGICAL , PUBLIC ::   l_trddyn = .TRUE.              !: momentum trend flag
+# else
+   LOGICAL , PUBLIC ::   l_trddyn = .FALSE.             !: momentum trend flag
+# endif
+
+   !                                                   !!! Active tracers trends indexes
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_xad =  1   !: x- horizontal advection
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_yad =  2   !: y- horizontal advection
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_zad =  3   !: z- vertical   advection
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_ldf =  4   !: lateral       diffusion
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_zdf =  5   !: vertical diffusion (Kz)
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_bbc =  6   !: Bottom Boundary Condition (geoth. flux) 
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_bbl =  7   !: Bottom Boundary Layer (diffusive/convective)
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_npc =  8   !: static instability mixing
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_dmp =  9   !: damping
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_qsr = 10   !: penetrative solar radiation
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_nsr = 11   !: non solar radiation
+   INTEGER, PUBLIC, PARAMETER ::   jptra_trd_atf = 12   !: Asselin correction
+   
+   !                                                   !!! Momentum trends indexes
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_hpg =  1   !: hydrostatic pressure gradient 
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_keg =  2   !: kinetic energy gradient
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_rvo =  3   !: relative vorticity
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_pvo =  4   !: planetary vorticity
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_ldf =  5   !: lateral diffusion
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_had =  6   !: horizontal advection
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_zad =  7   !: vertical advection
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_zdf =  8   !: vertical diffusion
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_spg =  9   !: surface pressure gradient
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_dat = 10   !: damping term
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_swf = 11   !: surface wind forcing
+   INTEGER, PUBLIC, PARAMETER ::   jpdyn_trd_bfr = 12   !: bottom friction 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE trdmod_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor.F90	(revision 1844)
@@ -0,0 +1,639 @@
+MODULE trdvor
+   !!======================================================================
+   !!                       ***  MODULE  trdvor  ***
+   !! Ocean diagnostics:  momentum trends
+   !!=====================================================================
+   !! History :  9.0  !  04-06  (L. Brunier, A-M. Treguier) Original code 
+   !!                 !  04-08  (C. Talandier) New trends organization
+   !!----------------------------------------------------------------------
+#if defined key_trdvor   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_trdvor'   : momentum trend diagnostics
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   trd_vor      : momentum trends averaged over the depth
+   !!   trd_vor_zint : vorticity vertical integration
+   !!   trd_vor_init : initialization step
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE trdmod_oce      ! ocean variables trends
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! Define parameters for the routines
+   USE ldfdyn_oce      ! ocean active tracers: lateral physics
+   USE dianam          ! build the name of file (routine)
+   USE zdfmxl          ! mixed layer depth
+   USE ioipsl          ! NetCDF library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE trd_vor_zint
+      MODULE PROCEDURE trd_vor_zint_2d, trd_vor_zint_3d
+   END INTERFACE
+
+   PUBLIC   trd_vor        ! routine called by step.F90
+   PUBLIC   trd_vor_zint   ! routine called by dynamics routines
+   PUBLIC   trd_vor_init   ! routine called by opa.F90
+
+   INTEGER ::                &
+      nh_t, nmoydpvor  ,     &
+      nidvor, nhoridvor,     &
+      ndexvor1(jpi*jpj),     &
+      ndimvor1, icount,      &
+      idebug                    ! (0/1) set it to 1 in case of problem to have more print
+
+   REAL(wp), DIMENSION(jpi,jpj) ::  &
+     vor_avr    ,     &  ! average
+     vor_avrb   ,     &  ! before vorticity (kt-1)
+     vor_avrbb  ,     &  ! vorticity at begining of the nwrite-1 timestep averaging period
+     vor_avrbn  ,     &  ! after vorticity at time step after the
+     rotot      ,     &  ! begining of the NWRITE-1 timesteps
+     vor_avrtot ,     &
+     vor_avrres
+
+   REAL(wp), DIMENSION(jpi,jpj,jpltot_vor)::   vortrd  !: curl of trends
+         
+   CHARACTER(len=12) ::   cvort
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "ldfdyn_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+  
+CONTAINS
+
+   SUBROUTINE trd_vor_zint_2d( putrdvor, pvtrdvor, ktrd )
+      !!----------------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_vor_zint  ***
+      !!
+      !! ** Purpose :   computation of vertically integrated vorticity budgets
+      !!      from ocean surface down to control surface (NetCDF output)
+      !!
+      !! ** Method/usage :
+      !!      integration done over nwrite-1 time steps
+      !!
+      !!
+      !! ** Action :
+      !!            /comvor/   :
+      !!                         vor_avr          average
+      !!                         vor_avrb         vorticity at kt-1
+      !!                         vor_avrbb        vorticity at begining of the NWRITE-1
+      !!                                          time steps averaging period
+      !!                         vor_avrbn         vorticity at time step after the
+      !!                                          begining of the NWRITE-1 time
+      !!                                          steps averaging period
+      !!
+      !!                 trends :
+      !!
+      !!                  vortrd (,, 1) = Pressure Gradient Trend
+      !!                  vortrd (,, 2) = KE Gradient Trend
+      !!                  vortrd (,, 3) = Relative Vorticity Trend
+      !!                  vortrd (,, 4) = Coriolis Term Trend
+      !!                  vortrd (,, 5) = Horizontal Diffusion Trend
+      !!                  vortrd (,, 6) = Vertical Advection Trend
+      !!                  vortrd (,, 7) = Vertical Diffusion Trend
+      !!                  vortrd (,, 8) = Surface Pressure Grad. Trend
+      !!                  vortrd (,, 9) = Beta V
+      !!                  vortrd (,,10) = forcing term
+      !!		  vortrd (,,11) = bottom friction term
+      !!                  rotot(,) : total cumulative trends over nwrite-1 time steps
+      !!                  vor_avrtot(,) : first membre of vrticity equation
+      !!                  vor_avrres(,) : residual = dh/dt entrainment
+      !!
+      !!      trends output in netCDF format using ioipsl
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   ktrd         ! ocean trend index
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         putrdvor,                         &  ! u vorticity trend 
+         pvtrdvor                             ! v vorticity trend
+      !!
+      INTEGER ::   ji, jj
+      INTEGER ::   ikbu, ikbum1, ikbv, ikbvm1
+      REAL(wp), DIMENSION(jpi,jpj) ::   zudpvor, zvdpvor   ! total cmulative trends
+      !!----------------------------------------------------------------------
+
+      ! Initialization
+      zudpvor(:,:) = 0.e0
+      zvdpvor(:,:) = 0.e0
+
+      CALL lbc_lnk( putrdvor,  'U' , -1. )
+      CALL lbc_lnk( pvtrdvor,  'V' , -1. )
+
+      !  =====================================
+      !  I vertical integration of 2D trends
+      !  =====================================
+
+      SELECT CASE (ktrd) 
+
+      CASE (jpvor_bfr)        ! bottom friction
+
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1 
+               ikbu   = min( mbathy(ji+1,jj), mbathy(ji,jj) )
+               ikbum1 = max( ikbu-1, 1 )
+               ikbv   = min( mbathy(ji,jj+1), mbathy(ji,jj) )
+               ikbvm1 = max( ikbv-1, 1 )
+            
+               zudpvor(ji,jj) = putrdvor(ji,jj) * fse3u(ji,jj,ikbum1) * e1u(ji,jj) * umask(ji,jj,ikbum1)
+               zvdpvor(ji,jj) = pvtrdvor(ji,jj) * fse3v(ji,jj,ikbvm1) * e2v(ji,jj) * vmask(ji,jj,ikbvm1)
+            END DO
+         END DO
+
+      CASE (jpvor_swf)        ! wind stress
+
+         zudpvor(:,:) = putrdvor(:,:) * fse3u(:,:,1) * e1u(:,:) * umask(:,:,1)
+         zvdpvor(:,:) = pvtrdvor(:,:) * fse3v(:,:,1) * e2v(:,:) * vmask(:,:,1)
+
+      END SELECT
+
+      ! Average except for Beta.V
+      zudpvor(:,:) = zudpvor(:,:) * hur(:,:)
+      zvdpvor(:,:) = zvdpvor(:,:) * hvr(:,:)
+   
+      ! Curl
+      DO ji=1,jpim1
+         DO jj=1,jpjm1
+            vortrd(ji,jj,ktrd) = ( zvdpvor(ji+1,jj) - zvdpvor(ji,jj)        &
+                 &                - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
+                 &               / ( e1f(ji,jj) * e2f(ji,jj) )
+         END DO
+      END DO
+
+      ! Surface mask
+      vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1)
+
+      IF( idebug /= 0 ) THEN
+         IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
+         CALL FLUSH(numout)
+      ENDIF
+      !
+   END SUBROUTINE trd_vor_zint_2d
+
+
+   SUBROUTINE trd_vor_zint_3d( putrdvor, pvtrdvor, ktrd )
+      !!----------------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_vor_zint  ***
+      !!
+      !! ** Purpose :   computation of vertically integrated vorticity budgets
+      !!      from ocean surface down to control surface (NetCDF output)
+      !!
+      !! ** Method/usage :
+      !!      integration done over nwrite-1 time steps
+      !!
+      !!
+      !! ** Action :
+      !!            /comvor/   :
+      !!                         vor_avr          average
+      !!                         vor_avrb         vorticity at kt-1
+      !!                         vor_avrbb        vorticity at begining of the NWRITE-1
+      !!                                          time steps averaging period
+      !!                         vor_avrbn         vorticity at time step after the
+      !!                                          begining of the NWRITE-1 time
+      !!                                          steps averaging period
+      !!
+      !!                 trends :
+      !!
+      !!                  vortrd (,,1) = Pressure Gradient Trend
+      !!                  vortrd (,,2) = KE Gradient Trend
+      !!                  vortrd (,,3) = Relative Vorticity Trend
+      !!                  vortrd (,,4) = Coriolis Term Trend
+      !!                  vortrd (,,5) = Horizontal Diffusion Trend
+      !!                  vortrd (,,6) = Vertical Advection Trend
+      !!                  vortrd (,,7) = Vertical Diffusion Trend
+      !!                  vortrd (,,8) = Surface Pressure Grad. Trend
+      !!                  vortrd (,,9) = Beta V
+      !!                  vortrd (,,10) = forcing term
+      !!		  vortrd (,,11) = bottom friction term
+      !!                  rotot(,) : total cumulative trends over nwrite-1 time steps
+      !!                  vor_avrtot(,) : first membre of vrticity equation
+      !!                  vor_avrres(,) : residual = dh/dt entrainment
+      !!
+      !!      trends output in netCDF format using ioipsl
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   ktrd         ! ocean trend index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         putrdvor,                         &  ! u vorticity trend 
+         pvtrdvor                             ! v vorticity trend
+      !!
+      INTEGER ::   ji, jj, jk
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zubet,                         &  ! u Beta.V case
+         zvbet,                         &  ! v Beta.V case
+         zudpvor,                       &  ! total cmulative trends
+         zvdpvor                           !   "      "        "
+      !!----------------------------------------------------------------------
+     
+      ! Initialization
+      zubet(:,:) = 0.e0
+      zvbet(:,:) = 0.e0
+      zudpvor(:,:) = 0.e0
+      zvdpvor(:,:) = 0.e0
+
+      !  =====================================
+      !  I vertical integration of 3D trends
+      !  =====================================
+
+      CALL lbc_lnk( putrdvor, 'U' , -1. )
+      CALL lbc_lnk( pvtrdvor, 'V' , -1. )
+
+      ! putrdvor and pvtrdvor terms
+      DO jk = 1,jpk
+        zudpvor(:,:) = zudpvor(:,:) + putrdvor(:,:,jk) * fse3u(:,:,jk) * e1u(:,:) * umask(:,:,jk)
+        zvdpvor(:,:) = zvdpvor(:,:) + pvtrdvor(:,:,jk) * fse3v(:,:,jk) * e2v(:,:) * vmask(:,:,jk)
+      END DO
+
+      ! Save Beta.V term to avoid average before Curl
+      ! Beta.V : intergration, no average
+      IF( ktrd == jpvor_bev ) THEN 
+         zubet(:,:) = zudpvor(:,:)
+         zvbet(:,:) = zvdpvor(:,:)
+      ENDIF
+
+      ! Average except for Beta.V
+      zudpvor(:,:) = zudpvor(:,:) * hur(:,:)
+      zvdpvor(:,:) = zvdpvor(:,:) * hvr(:,:)
+   
+      ! Curl
+      DO ji=1,jpim1
+         DO jj=1,jpjm1
+            vortrd(ji,jj,ktrd) = (  zvdpvor(ji+1,jj) - zvdpvor(ji,jj) -   &
+                 &                ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
+                 &               / ( e1f(ji,jj) * e2f(ji,jj) )
+         END DO
+      END DO
+
+      ! Surface mask
+      vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1)
+
+      ! Special treatement for the Beta.V term
+      ! Compute the Curl of the Beta.V term which is not averaged
+      IF( ktrd == jpvor_bev ) THEN
+         DO ji=1,jpim1
+            DO jj=1,jpjm1
+               vortrd(ji,jj,jpvor_bev) = (  zvbet(ji+1,jj) - zvbet(ji,jj) -   &
+                    &                    ( zubet(ji,jj+1) - zubet(ji,jj) ) ) &
+                    &                   / ( e1f(ji,jj) * e2f(ji,jj) )
+            END DO
+         END DO
+
+         ! Average on the Curl
+         vortrd(:,:,jpvor_bev) = vortrd(:,:,jpvor_bev) * hur(:,:)
+
+         ! Surface mask
+         vortrd(:,:,jpvor_bev) = vortrd(:,:,jpvor_bev) * fmask(:,:,1)
+      ENDIF
+   
+      IF( idebug /= 0 ) THEN
+         IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
+         CALL FLUSH(numout)
+      ENDIF
+      !
+   END SUBROUTINE trd_vor_zint_3d
+
+
+   SUBROUTINE trd_vor( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_vor  ***
+      !! 
+      !! ** Purpose :  computation of cumulated trends over analysis period
+      !!               and make outputs (NetCDF or DIMG format)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj, jk, jl, it, itmod
+      REAL(wp) ::   zmean
+      REAL(wp), DIMENSION(jpi,jpj) ::   zun, zvn
+      !!----------------------------------------------------------------------
+
+      !  =================
+      !  I. Initialization
+      !  =================
+     
+     
+      ! I.1 set before values of vertically average u and v
+      ! ---------------------------------------------------
+
+      IF( kt > nit000 ) THEN
+         vor_avrb(:,:) = vor_avr(:,:)
+      ENDIF
+
+       IF( idebug /= 0 ) THEN
+          WRITE(numout,*) ' debuging trd_vor: I.1 done '
+          CALL FLUSH(numout)
+      ENDIF
+
+      ! I.2 vertically integrated vorticity
+      !  ----------------------------------
+
+      vor_avr(:,:) = 0.
+      zun(:,:)=0
+      zvn(:,:)=0
+      vor_avrtot(:,:)=0
+      vor_avrres(:,:)=0
+      
+      ! Vertically averaged velocity
+      DO jk = 1, jpk - 1
+         zun(:,:)=zun(:,:) + e1u(:,:)*un(:,:,jk)*fse3u(:,:,jk)
+         zvn(:,:)=zvn(:,:) + e2v(:,:)*vn(:,:,jk)*fse3v(:,:,jk)
+      END DO
+ 
+      zun(:,:)=zun(:,:)*hur(:,:)
+      zvn(:,:)=zvn(:,:)*hvr(:,:)
+
+      ! Curl
+      DO ji=1,jpim1
+         DO jj=1,jpjm1
+            vor_avr(ji,jj) = ((zvn(ji+1,jj)-zvn(ji,jj))-   &
+                              (zun(ji,jj+1)-zun(ji,jj)))   &
+                             /( e1f(ji,jj) * e2f(ji,jj) )
+            vor_avr(ji,jj) = vor_avr(ji,jj)*fmask(ji,jj,1)
+         END DO
+      END DO
+      
+      IF(idebug /= 0) THEN
+         WRITE(numout,*) ' debuging trd_vor: I.2 done'
+         CALL FLUSH(numout)
+      ENDIF
+
+      !  =================================
+      !   II. Cumulated trends
+      !  =================================
+
+      ! II.1 set `before' mixed layer values for kt = nit000+1
+      ! ------------------------------------------------------
+      IF( kt == nit000+1 ) THEN
+         vor_avrbb(:,:) = vor_avrb(:,:)
+         vor_avrbn(:,:) = vor_avr (:,:)
+      ENDIF
+
+      IF( idebug /= 0 ) THEN
+         WRITE(numout,*) ' debuging trd_vor: I1.1 done'
+         CALL FLUSH(numout)
+      ENDIF
+
+      ! II.2 cumulated trends over analysis period (kt=2 to nwrite)
+      ! ----------------------
+      ! trends cumulated over nwrite-2 time steps
+
+      IF( kt >= nit000+2 ) THEN
+         nmoydpvor = nmoydpvor + 1
+         DO jl = 1, jpltot_vor
+            IF( jl /= 9 ) THEN
+               rotot(:,:) = rotot(:,:) + vortrd(:,:,jl)
+            ENDIF
+         END DO
+      ENDIF
+
+      IF( idebug /= 0 ) THEN
+         WRITE(numout,*) ' debuging trd_vor: II.2 done'
+         CALL FLUSH(numout)
+      ENDIF
+
+      !  =============================================
+      !   III. Output in netCDF + residual computation
+      !  =============================================
+
+      ! define time axis
+      it = kt
+      itmod = kt - nit000 + 1
+
+      IF( MOD( it, nn_trd ) == 0 ) THEN
+
+         ! III.1 compute total trend
+         ! ------------------------
+         zmean = float(nmoydpvor)
+
+         vor_avrtot(:,:) = ( vor_avr(:,:) - vor_avrbn(:,:) + vor_avrb(:,:) - &
+                             vor_avrbb(:,:) ) /  (zmean * 2. * rdt)
+
+         IF( idebug /= 0 ) THEN
+             WRITE(numout,*) ' zmean = ',zmean
+             WRITE(numout,*) ' debuging trd_vor: III.1 done'
+             CALL FLUSH(numout)
+         ENDIF
+
+         ! III.2 compute residual
+         ! ---------------------
+         vor_avrres(:,:) = vor_avrtot(:,:) - rotot(:,:) / zmean
+
+         ! Boundary conditions
+         CALL lbc_lnk( vor_avrtot, 'F', 1. )
+         CALL lbc_lnk( vor_avrres, 'F', 1. )
+
+         IF( idebug /= 0 ) THEN
+            WRITE(numout,*) ' debuging trd_vor: III.2 done'
+            CALL FLUSH(numout)
+         ENDIF
+
+         ! III.3 time evolution array swap
+         ! ------------------------------
+         vor_avrbb(:,:) = vor_avrb(:,:)
+         vor_avrbn(:,:) = vor_avr(:,:)
+
+         IF( idebug /= 0 ) THEN
+            WRITE(numout,*) ' debuging trd_vor: III.3 done'
+            CALL FLUSH(numout)
+         ENDIF
+
+         nmoydpvor=0
+
+      ENDIF
+
+      ! III.4 write trends to output
+      ! ---------------------------
+
+      IF( kt >=  nit000+1 ) THEN
+
+         IF( lwp .AND. MOD( itmod, nn_trd ) == 0 ) THEN
+            WRITE(numout,*) ''
+            WRITE(numout,*) 'trd_vor : write trends in the NetCDF file at kt = ', kt
+            WRITE(numout,*) '~~~~~~~  '
+         ENDIF
+ 
+         CALL histwrite( nidvor,"sovortPh",it,vortrd(:,:,jpvor_prg),ndimvor1,ndexvor1)  ! grad Ph
+         CALL histwrite( nidvor,"sovortEk",it,vortrd(:,:,jpvor_keg),ndimvor1,ndexvor1)  ! Energy
+         CALL histwrite( nidvor,"sovozeta",it,vortrd(:,:,jpvor_rvo),ndimvor1,ndexvor1)  ! rel vorticity
+         CALL histwrite( nidvor,"sovortif",it,vortrd(:,:,jpvor_pvo),ndimvor1,ndexvor1)  ! coriolis
+         CALL histwrite( nidvor,"sovodifl",it,vortrd(:,:,jpvor_ldf),ndimvor1,ndexvor1)  ! lat diff
+         CALL histwrite( nidvor,"sovoadvv",it,vortrd(:,:,jpvor_zad),ndimvor1,ndexvor1)  ! vert adv
+         CALL histwrite( nidvor,"sovodifv",it,vortrd(:,:,jpvor_zdf),ndimvor1,ndexvor1)  ! vert diff
+         CALL histwrite( nidvor,"sovortPs",it,vortrd(:,:,jpvor_spg),ndimvor1,ndexvor1)  ! grad Ps
+         CALL histwrite( nidvor,"sovortbv",it,vortrd(:,:,jpvor_bev),ndimvor1,ndexvor1)  ! beta.V
+         CALL histwrite( nidvor,"sovowind",it,vortrd(:,:,jpvor_swf),ndimvor1,ndexvor1) ! wind stress
+         CALL histwrite( nidvor,"sovobfri",it,vortrd(:,:,jpvor_bfr),ndimvor1,ndexvor1) ! bottom friction
+         CALL histwrite( nidvor,"1st_mbre",it,vor_avrtot    ,ndimvor1,ndexvor1) ! First membre
+         CALL histwrite( nidvor,"sovorgap",it,vor_avrres    ,ndimvor1,ndexvor1) ! gap between 1st and 2 nd mbre
+         !
+         IF( idebug /= 0 ) THEN
+            WRITE(numout,*) ' debuging trd_vor: III.4 done'
+            CALL FLUSH(numout)
+         ENDIF
+         !
+      ENDIF
+      !
+      IF( MOD( it, nn_trd ) == 0 ) rotot(:,:)=0
+      !
+      IF( kt == nitend )   CALL histclo( nidvor )
+      !
+   END SUBROUTINE trd_vor
+
+
+   SUBROUTINE trd_vor_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_vor_init  ***
+      !! 
+      !! ** Purpose :   computation of vertically integrated T and S budgets
+      !!      from ocean surface down to control surface (NetCDF output)
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zjulian, zsto, zout
+      CHARACTER (len=40) ::   clhstnam
+      CHARACTER (len=40) ::   clop
+      !!----------------------------------------------------------------------
+
+      !  ===================
+      !   I. initialization
+      !  ===================
+
+      cvort='averaged-vor'
+
+      ! Open specifier
+      idebug = 0      ! set it to 1 in case of problem to have more Print
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' trd_vor_init: vorticity trends'
+         WRITE(numout,*) ' ~~~~~~~~~~~~'
+         WRITE(numout,*) ' '
+         WRITE(numout,*) '               ##########################################################################'
+         WRITE(numout,*) '                CAUTION: The interpretation of the vorticity trends is'
+         WRITE(numout,*) '                not obvious, please contact Anne-Marie TREGUIER at: treguier@ifremer.fr '
+         WRITE(numout,*) '               ##########################################################################'
+         WRITE(numout,*) ' '
+      ENDIF
+
+      ! cumulated trends array init
+      nmoydpvor = 0
+      rotot(:,:)=0
+      vor_avrtot(:,:)=0
+      vor_avrres(:,:)=0
+
+      IF( idebug /= 0 ) THEN
+         WRITE(numout,*) ' debuging trd_vor_init: I. done'
+         CALL FLUSH(numout)
+      ENDIF
+
+      !  =================================
+      !   II. netCDF output initialization
+      !  =================================
+
+      !-----------------------------------------
+      ! II.1 Define frequency of output and means
+      ! -----------------------------------------
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#if defined key_diainstant
+      zsto = nwrite*rdt
+      clop = "inst("//TRIM(clop)//")"
+#else
+      zsto = rdt
+      clop = "ave("//TRIM(clop)//")"
+#endif
+      zout = nn_trd*rdt
+
+      IF(lwp) WRITE(numout,*) '               netCDF initialization'
+
+      ! II.2 Compute julian date from starting date of the run
+      ! ------------------------
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      IF(lwp) WRITE(numout,*)' '  
+      IF(lwp) WRITE(numout,*)'               Date 0 used :',nit000,    &
+         &                   ' YEAR ', nyear,' MONTH '      , nmonth,   &
+         &                   ' DAY ' , nday, 'Julian day : ', zjulian
+
+      ! II.3 Define the T grid trend file (nidvor)
+      ! ---------------------------------
+      CALL dia_nam( clhstnam, nn_trd, 'vort' )                  ! filename
+      IF(lwp) WRITE(numout,*) ' Name of NETCDF file ', clhstnam
+      CALL histbeg( clhstnam, jpi, glamf, jpj, gphif,1, jpi,   &  ! Horizontal grid : glamt and gphit
+         &          1, jpj, nit000-1, zjulian, rdt, nh_t, nidvor, domain_id=nidom )
+      CALL wheneq( jpi*jpj, fmask, 1, 1., ndexvor1, ndimvor1 )    ! surface
+
+      ! Declare output fields as netCDF variables
+      CALL histdef( nidvor, "sovortPh", cvort//"grad Ph" , "s-2",        & ! grad Ph
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovortEk", cvort//"Energy", "s-2",          & ! Energy
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovozeta", cvort//"rel vorticity", "s-2",   & ! rel vorticity
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovortif", cvort//"coriolis", "s-2",        & ! coriolis
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovodifl", cvort//"lat diff ", "s-2",       & ! lat diff
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovoadvv", cvort//"vert adv", "s-2",        & ! vert adv
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovodifv", cvort//"vert diff" , "s-2",      & ! vert diff
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovortPs", cvort//"grad Ps", "s-2",         & ! grad Ps
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovortbv", cvort//"Beta V", "s-2",          & ! beta.V
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovowind", cvort//"wind stress", "s-2",     & ! wind stress
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovobfri", cvort//"bottom friction", "s-2", & ! bottom friction
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "1st_mbre", cvort//"1st mbre", "s-2",        & ! First membre
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histdef( nidvor, "sovorgap", cvort//"gap", "s-2",             & ! gap between 1st and 2 nd mbre
+         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
+      CALL histend( nidvor )
+
+      IF( idebug /= 0 ) THEN
+         WRITE(numout,*) ' debuging trd_vor_init: II. done'
+         CALL FLUSH(numout)
+      ENDIF
+      !
+   END SUBROUTINE trd_vor_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+   INTERFACE trd_vor_zint
+      MODULE PROCEDURE trd_vor_zint_2d, trd_vor_zint_3d
+   END INTERFACE
+CONTAINS
+   SUBROUTINE trd_vor( kt )        ! Empty routine
+      WRITE(*,*) 'trd_vor: You should not have seen this print! error?', kt
+   END SUBROUTINE trd_vor
+   SUBROUTINE trd_vor_zint_2d( putrdvor, pvtrdvor, ktrd )
+      REAL, DIMENSION(:,:), INTENT( inout ) ::   putrdvor, pvtrdvor
+      INTEGER, INTENT( in ) ::   ktrd         ! ocean trend index
+      WRITE(*,*) 'trd_vor_zint_2d: You should not have seen this print! error?', putrdvor(1,1)
+      WRITE(*,*) '  "      "     : You should not have seen this print! error?', pvtrdvor(1,1)
+      WRITE(*,*) '  "      "     : You should not have seen this print! error?', ktrd
+   END SUBROUTINE trd_vor_zint_2d
+   SUBROUTINE trd_vor_zint_3d( putrdvor, pvtrdvor, ktrd )
+      REAL, DIMENSION(:,:,:), INTENT( inout ) ::   putrdvor, pvtrdvor
+      INTEGER, INTENT( in ) ::   ktrd         ! ocean trend index
+      WRITE(*,*) 'trd_vor_zint_3d: You should not have seen this print! error?', putrdvor(1,1,1)
+      WRITE(*,*) '  "      "     : You should not have seen this print! error?', pvtrdvor(1,1,1)
+      WRITE(*,*) '  "      "     : You should not have seen this print! error?', ktrd
+   END SUBROUTINE trd_vor_zint_3d
+   SUBROUTINE trd_vor_init              ! Empty routine
+      WRITE(*,*) 'trd_vor_init: You should not have seen this print! error?'
+   END SUBROUTINE trd_vor_init
+#endif
+   !!======================================================================
+END MODULE trdvor
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/TRD/trdvor_oce.F90	(revision 1844)
@@ -0,0 +1,40 @@
+MODULE trdvor_oce
+   !!======================================================================
+   !!                   ***  MODULE trdvor_oce  ***
+   !! Ocean trends :   set vorticity trend variables
+   !!======================================================================
+   !! History :  9.0  ! ???
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+#if defined key_trdvor
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trdvor = .TRUE.     !: momentum trend flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trdvor = .FALSE.    !: momentum trend flag
+#endif
+   !!* vorticity trends index
+   INTEGER, PUBLIC, PARAMETER ::   jpltot_vor = 11  !: Number of vorticity trend terms
+   !
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_prg =  1   !: Pressure Gradient Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_keg =  2   !: KE Gradient Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_rvo =  3   !: Relative Vorticity Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_pvo =  4   !: Planetary Vorticity Term Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_ldf =  5   !: Horizontal Diffusion Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_zad =  6   !: Vertical Advection Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_zdf =  7   !: Vertical Diffusion Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_spg =  8   !: Surface Pressure Grad. Trend
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_bev =  9   !: Beta V
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_swf = 10   !: wind stress forcing term
+   INTEGER, PUBLIC, PARAMETER ::   jpvor_bfr = 11   !: bottom friction term
+
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE trdvor_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf.matrixsolver.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf.matrixsolver.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf.matrixsolver.h90	(revision 1844)
@@ -0,0 +1,57 @@
+!! 
+!!         ZDF.MATRIXSOLVER
+!!       ********************
+!! 
+!! Matrix inversion
+!!----------------------------------------------------------------------
+!   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+!
+!        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+!        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+!        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+!        (        ...               )( ...  ) ( ...  )
+!        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+!
+!   m is decomposed in the product of an upper and lower triangular
+!   matrix
+!   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+!   The second member is in 2d array zwy
+!   The solution is in 2d array zwx
+!   The 2d arry zwt and zwz are work space arrays
+!
+!   N.B. the starting vertical index (ikst) is equal to 1 except for
+!   the resolution of tke matrix where surface tke value is prescribed
+!   so that ikstrt=2.
+!!----------------------------------------------------------------------
+!!  OPA 9.0 , LOCEAN-IPSL (2005) 
+!! $Id$ 
+!! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+!!----------------------------------------------------------------------
+
+      ikstp1 = ikst + 1
+      ikenm2 = jpk - 2
+      DO ji = 2, jpim1
+         zwt(ji,ikst) = zwd(ji,ikst)
+      END DO
+      DO jk = ikstp1, jpkm1
+         DO ji = 2, jpim1
+            zwt(ji,jk) = zwd(ji,jk) - zwi(ji,jk) * zws(ji,jk-1) / zwt(ji,jk-1)
+         END DO
+      END DO
+      DO ji = 2, jpim1
+         zwz(ji,ikst) = zwy(ji,ikst)
+      END DO
+      DO jk = ikstp1, jpkm1
+         DO ji = 2, jpim1
+            zwz(ji,jk) = zwy(ji,jk) - zwi(ji,jk) / zwt(ji,jk-1) * zwz(ji,jk-1)
+         END DO
+      END DO
+      DO ji = 2, jpim1
+         zwx(ji,jpkm1) = zwz(ji,jpkm1) / zwt(ji,jpkm1)
+      END DO
+      DO jk = ikenm2, ikst, -1
+         DO ji = 2, jpim1
+            zwx(ji,jk) =( zwz(ji,jk) - zws(ji,jk) * zwx(ji,jk+1) ) / zwt(ji,jk)
+         END DO
+      END DO
+      
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 1844)
@@ -0,0 +1,45 @@
+MODULE zdf_oce
+   !!======================================================================
+   !!              ***  MODULE  zdf_oce  ***
+   !! Ocean physics : define vertical mixing variables
+   !!=====================================================================
+   !! history :  1.0  !  2002-06  (G. Madec) Original code
+   !!            3.2  !  2009-07  (G.Madec) addition of avm
+   !!----------------------------------------------------------------------
+   USE par_oce         ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+#if defined key_zdfcst   ||   defined key_esopa
+   LOGICAL, PARAMETER, PUBLIC ::   lk_zdfcst        = .TRUE.         !: constant vertical mixing flag
+#else
+   LOGICAL, PARAMETER, PUBLIC ::   lk_zdfcst        = .FALSE.        !: constant vertical mixing flag
+#endif
+
+   !                                           !!* namelist namzdf: vertical diffusion *
+   REAL(wp), PUBLIC ::   rn_avm0   = 1.e-4_wp   !: vertical eddy viscosity (m2/s)
+   REAL(wp), PUBLIC ::   rn_avt0   = 1.e-5_wp   !: vertical eddy diffusivity (m2/s)
+   INTEGER , PUBLIC ::   nn_avb    =  0         !: constant or profile background on avt (=0/1)
+   INTEGER , PUBLIC ::   nn_havtb  = 1          !: horizontal shape or not for avtb (=0/1)
+   LOGICAL , PUBLIC ::   ln_zdfexp = .FALSE.    !: explicit vertical diffusion scheme flag
+   INTEGER , PUBLIC ::   nn_zdfexp = 3          !: number of sub-time step (explicit time stepping)
+   LOGICAL , PUBLIC ::   ln_zdfevd = .TRUE.     !: convection: enhanced vertical diffusion flag
+   INTEGER , PUBLIC ::   nn_evdm   = 1          !: =0/1 flag to apply enhanced avm or not
+   REAL(wp), PUBLIC ::   rn_avevd  = 1._wp      !: vertical eddy coeff. for enhanced vert. diff. (m2/s)
+   LOGICAL , PUBLIC ::   ln_zdfnpc = .FALSE.    !: convection: non-penetrative convection flag
+   INTEGER , PUBLIC ::   nn_npc    =   1        !: non penetrative convective scheme call  frequency
+   INTEGER , PUBLIC ::   nn_npcp   =  15        !: non penetrative convective scheme print frequency
+
+
+   REAL(wp), PUBLIC, DIMENSION        (jpk) ::   avmb, avtb   !: background profile of avm and avt
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   avtb_2d      !: set in tke_init, for other modif than ice
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   avmu, avmv   !: vertical viscosity coeff. at uw- & vw-points   [m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   avm , avt    !: vertical viscosity & diffusivity coeff. at  w-point   [m2/s]
+ 
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE zdf_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfbfr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfbfr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfbfr.F90	(revision 1844)
@@ -0,0 +1,258 @@
+MODULE zdfbfr
+   !!======================================================================
+   !!                       ***  MODULE  zdfbfr  ***
+   !! Ocean physics: Bottom friction
+   !!======================================================================
+   !! History :  OPA  ! 1997-06  (G. Madec, A.-M. Treguier)  Original code
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            3.2  ! 2009-09  (A.C.Coward)  Correction to include barotropic contribution
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_bfr      : update momentum Kz at the ocean bottom due to the type of bottom friction chosen
+   !!   zdf_bfr_init : read in namelist and control the bottom friction parameters.
+   !!   zdf_bfr_2d   : read in namelist and control the bottom friction
+   !!                  parameters.
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_bfr    ! called by step.F90
+   
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bfrua , bfrva   !: Bottom friction coefficients set in zdfbfr
+
+   !                                    !!* Namelist nambfr: bottom friction namelist *
+   INTEGER  ::   nn_bfr    = 0           ! = 0/1/2/3 type of bottom friction 
+   REAL(wp) ::   rn_bfri1  = 4.0e-4_wp   ! bottom drag coefficient (linear case) 
+   REAL(wp) ::   rn_bfri2  = 1.0e-3_wp   ! bottom drag coefficient (non linear case)
+   REAL(wp) ::   rn_bfeb2  = 2.5e-3_wp   ! background bottom turbulent kinetic energy  [m2/s2]
+   REAL(wp) ::   rn_bfrien = 30_wp       ! local factor to enhance coefficient bfri
+   LOGICAL  ::   ln_bfr2d  = .false.     ! logical switch for 2D enhancement
+   
+   REAL(wp), DIMENSION(jpi,jpj) ::   bfrcoef2d = 1.e-3_wp   ! 2D bottom drag coefficient
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_bfr( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zdf_bfr  ***
+      !!                 
+      !! ** Purpose :   compute the bottom friction coefficient.
+      !!
+      !! ** Method  :   Calculate and store part of the momentum trend due    
+      !!              to bottom friction following the chosen friction type 
+      !!              (free-slip, linear, or quadratic). The component
+      !!              calculated here is multiplied by the bottom velocity in
+      !!              dyn_bfr to provide the trend term.
+      !!                The coefficients are updated at each time step only
+      !!              in the quadratic case.
+      !!
+      !! ** Action  :   bfrua , bfrva   bottom friction coefficients
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER  ::   ji, jj         ! dummy loop indices
+      INTEGER  ::   ikbu, ikbum1   ! temporary integers
+      INTEGER  ::   ikbv, ikbvm1   !    -          -
+      REAL(wp) ::   zvu, zuv, zecu, zecv   ! temporary scalars
+      !!----------------------------------------------------------------------
+
+
+      IF( kt == nit000 )   CALL zdf_bfr_init   ! initialisation
+
+      IF( nn_bfr == 2 ) THEN                 ! quadratic botton friction
+         ! Calculate and store the quadratic bottom friction coefficient bfrua and bfrva
+         ! where bfrUa = C_d*SQRT(u_bot^2 + v_bot^2 + e_b) {U=[u,v]}
+         ! from these the trend due to bottom friction:  -F_h/e3U  can be calculated
+         ! where -F_h/e3U_bot = bfrUa*Ub/e3U_bot {U=[u,v]}
+         !
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+!CDIR NOVERRCHK
+            DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = 2, jpim1
+# endif
+               ikbu   = MIN( mbathy(ji+1,jj  ), mbathy(ji,jj) )
+               ikbv   = MIN( mbathy(ji  ,jj+1), mbathy(ji,jj) )
+               ikbum1 = MAX( ikbu-1, 1 )
+               ikbvm1 = MAX( ikbv-1, 1 )
+               !
+               zvu  = 0.25 * (  vn(ji,jj  ,ikbum1) + vn(ji+1,jj  ,ikbum1)     &
+                  &           + vn(ji,jj-1,ikbum1) + vn(ji+1,jj-1,ikbum1)  )
+               zuv  = 0.25 * (  un(ji,jj  ,ikbvm1) + un(ji-1,jj  ,ikbvm1)     &
+                  &           + un(ji,jj+1,ikbvm1) + un(ji-1,jj+1,ikbvm1)  )
+               !
+               zecu = SQRT(  un(ji,jj,ikbum1) * un(ji,jj,ikbum1) + zvu*zvu + rn_bfeb2  )
+               zecv = SQRT(  vn(ji,jj,ikbvm1) * vn(ji,jj,ikbvm1) + zuv*zuv + rn_bfeb2  )
+               !
+               bfrua(ji,jj) = - 0.5 * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji+1,jj  ) ) * zecu 
+               bfrva(ji,jj) = - 0.5 * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji  ,jj+1) ) * zecv
+            END DO
+         END DO
+         !
+         CALL lbc_lnk( bfrua, 'U', 1. )   ;   CALL lbc_lnk( bfrva, 'V', 1. )      ! Lateral boundary condition
+         !
+         IF(ln_ctl)   CALL prt_ctl( tab2d_1=bfrua, clinfo1=' bfr  - u: ', mask1=umask,        &
+            &                       tab2d_2=bfrva, clinfo2=       ' v: ', mask2=vmask,ovlap=1 )
+      ENDIF
+      !
+   END SUBROUTINE zdf_bfr
+
+
+   SUBROUTINE zdf_bfr_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_bfr_init  ***
+      !!                    
+      !! ** Purpose :   Initialization of the bottom friction
+      !!
+      !! ** Method  :   Read the nammbf namelist and check their consistency
+      !!              called at the first timestep (nit000)
+      !!----------------------------------------------------------------------
+      USE iom   ! I/O module for ehanced bottom friction file
+      !!
+      INTEGER ::   inum         ! logical unit for enhanced bottom friction file
+      INTEGER ::   ji, jj       ! dummy loop indexes
+      INTEGER ::   ikbu, ikbv   ! temporary integers
+      INTEGER ::   ictu, ictv   !    -          -
+      REAL(wp) ::  zminbfr, zmaxbfr   ! temporary scalars
+      REAL(wp) ::  zfru, zfrv         !    -         -
+      !!
+      NAMELIST/nambfr/ nn_bfr, rn_bfri1, rn_bfri2, rn_bfeb2, ln_bfr2d, rn_bfrien
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               !* Read Namelist nam_bfr : bottom momentum boundary condition
+      READ   ( numnam, nambfr )
+
+      !                               !* Parameter control and print
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'zdf_bfr : momentum bottom friction'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+      IF(lwp) WRITE(numout,*) '   Namelist nam_bfr : set bottom friction parameters'
+
+      SELECT CASE (nn_bfr)
+
+      CASE( 0 )
+         IF(lwp) WRITE(numout,*) '      free-slip '
+         bfrua(:,:) = 0.e0
+         bfrva(:,:) = 0.e0
+         !
+      CASE( 1 )
+         IF(lwp) WRITE(numout,*) '      linear botton friction'
+         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri1  = ', rn_bfri1
+         IF( ln_bfr2d ) THEN
+            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
+            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
+         ENDIF
+         !
+         bfrcoef2d(:,:) = rn_bfri1  ! initialize bfrcoef2d to the namelist variable
+         !
+         IF(ln_bfr2d) THEN 
+            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
+            CALL iom_open('bfr_coef.nc',inum)
+            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
+            CALL iom_close(inum)
+            bfrcoef2d(:,:)= rn_bfri1 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
+         ENDIF
+         bfrua(:,:) = - bfrcoef2d(:,:)
+         bfrva(:,:) = - bfrcoef2d(:,:)
+         !
+      CASE( 2 )
+         IF(lwp) WRITE(numout,*) '      quadratic botton friction'
+         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri2  = ', rn_bfri2
+         IF(lwp) WRITE(numout,*) '      background tke   rn_bfeb2  = ', rn_bfeb2
+         IF( ln_bfr2d ) THEN
+            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
+            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
+         ENDIF
+         bfrcoef2d(:,:) = rn_bfri2  ! initialize bfrcoef2d to the namelist variable
+         !
+         IF(ln_bfr2d) THEN 
+            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
+            CALL iom_open('bfr_coef.nc',inum)
+            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
+            CALL iom_close(inum)
+            bfrcoef2d(:,:)= rn_bfri2 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
+         ENDIF
+         !
+      CASE DEFAULT
+         IF(lwp) WRITE(ctmp1,*) '         bad flag value for nn_bfr = ', nn_bfr
+         CALL ctl_stop( ctmp1 )
+         !
+      END SELECT
+      !
+      ! Basic stability check on bottom friction coefficient
+      !
+      ictu = 0               ! counter for stability criterion breaches at U-pts
+      ictv = 0               ! counter for stability criterion breaches at V-pts
+      zminbfr =  1.e10_wp    ! initialise tracker for minimum of bottom friction coefficient
+      zmaxbfr = -1.e10_wp    ! initialise tracker for maximum of bottom friction coefficient
+      !
+#  if defined key_vectopt_loop
+      DO jj = 1, 1
+!CDIR NOVERRCHK
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+#  else
+!CDIR NOVERRCHK
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = 2, jpim1
+#  endif
+             ikbu = MIN( mbathy(ji+1,jj  ), mbathy(ji,jj) )
+             ikbv = MIN( mbathy(ji  ,jj+1), mbathy(ji,jj) )
+             zfru = 0.5 * fse3u(ji,jj,ikbu) / rdt
+             zfrv = 0.5 * fse3v(ji,jj,ikbv) / rdt
+             IF( ABS( bfrcoef2d(ji,jj) ) > zfru ) THEN
+                IF( ln_ctl ) THEN
+                   WRITE(numout,*) 'BFR ',narea,nimpp+ji,njmpp+jj,ikbu
+                   WRITE(numout,*) 'BFR ',ABS( bfrcoef2d(ji,jj) ), zfru
+                ENDIF
+                ictu = ictu + 1
+             ENDIF
+             IF( ABS( bfrcoef2d(ji,jj) ) > zfrv ) THEN
+                 IF( ln_ctl ) THEN
+                     WRITE(numout,*) 'BFR ', narea, nimpp+ji, njmpp+jj, ikbv
+                     WRITE(numout,*) 'BFR ', bfrcoef2d(ji,jj), zfrv
+                 ENDIF
+                 ictv = ictv + 1
+             ENDIF
+             zminbfr = MIN(  zminbfr, MIN( zfru, ABS( bfrcoef2d(ji,jj) ) )  )
+             zmaxbfr = MAX(  zmaxbfr, MIN( zfrv, ABS( bfrcoef2d(ji,jj) ) )  )
+         END DO
+      END DO
+      IF( lk_mpp ) THEN
+         CALL mpp_sum( ictu )
+         CALL mpp_sum( ictv )
+         CALL mpp_min( zminbfr )
+         CALL mpp_max( zmaxbfr )
+      ENDIF
+      IF( lwp .AND. ictu + ictv .GT. 0 ) THEN
+         WRITE(numout,*) ' Bottom friction stability check failed at ', ictu, ' U-points '
+         WRITE(numout,*) ' Bottom friction stability check failed at ', ictv, ' V-points '
+         WRITE(numout,*) ' Bottom friction coefficient now ranges from: ', zminbfr, ' to ', zmaxbfr
+         WRITE(numout,*) ' Bottom friction coefficient will be reduced where necessary'
+      ENDIF
+      !
+   END SUBROUTINE zdf_bfr_init
+
+   !!======================================================================
+END MODULE zdfbfr
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 1844)
@@ -0,0 +1,232 @@
+MODULE zdfddm
+   !!======================================================================
+   !!                       ***  MODULE  zdfddm  ***
+   !! Ocean physics : double diffusion mixing parameterization
+   !!======================================================================
+   !! History :  OPA  ! 2000-08  (G. Madec)  double diffusive mixing
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_zdfddm   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdfddm' :                                     double diffusion
+   !!----------------------------------------------------------------------
+   !!   zdf_ddm       : compute the Ks for salinity
+   !!   zdf_ddm_init  : read namelist and control the parameters
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_ddm    ! called by step.F90
+
+   LOGICAL , PUBLIC, PARAMETER ::   lk_zdfddm = .TRUE.  !: double diffusive mixing flag
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   avs    !: salinity vertical diffusivity coeff. at w-point
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   rrau   !: heat/salt buoyancy flux ratio
+
+   !                                  !!* Namelist namzdf_ddm : double diffusive mixing *
+   REAL(wp) ::   rn_avts  = 1.e-4_wp   ! maximum value of avs for salt fingering
+   REAL(wp) ::   rn_hsbfr = 1.6_wp     ! heat/salt buoyancy flux ratio
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_ddm( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_ddm  ***
+      !!                    
+      !! ** Purpose :   Add to the vertical eddy diffusivity coefficient the 
+      !!              effect of salt fingering and diffusive convection. 
+      !!
+      !! ** Method  :   Diapycnal mixing is increased in case of double
+      !!      diffusive mixing (i.e. salt fingering and diffusive layering)
+      !!      following Merryfield et al. (1999). The rate of double diffusive 
+      !!      mixing depend on the buoyancy ratio: Rrau=alpha/beta dk[T]/dk[S]
+      !!      which is computed in rn2.F
+      !!         * salt fingering (Schmitt 1981):
+      !!      for Rrau > 1 and rn2 > 0 : zavfs = rn_avts / ( 1 + (Rrau/rn_hsbfr)^6 )
+      !!      for Rrau > 1 and rn2 > 0 : zavfs = O
+      !!      otherwise                : zavft = 0.7 zavs / Rrau
+      !!         * diffusive layering (Federov 1988):
+      !!      for 0< Rrau < 1 and rn2 > 0 : zavdt = 1.3635e-6  
+      !!                                 * exp( 4.6 exp(-0.54 (1/Rrau-1) ) )
+      !!      otherwise                   : zavdt = 0 
+      !!      for .5 < Rrau < 1 and rn2 > 0 : zavds = zavdt (1.885 Rrau -0.85)
+      !!      for  0 < Rrau <.5 and rn2 > 0 : zavds = zavdt 0.15 Rrau      
+      !!      otherwise                     : zavds = 0 
+      !!         * update the eddy diffusivity:
+      !!      avt = avt + zavft + zavdt
+      !!      avs = avs + zavfs + zavds
+      !!      avmu, avmv are required to remain at least above avt and avs.
+      !!      
+      !! ** Action  :   avt, avs : updated vertical eddy diffusivity coef. for T & S
+      !!
+      !! References :   Merryfield et al., JPO, 29, 1124-1142, 1999.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step indexocean time step
+      !!
+      INTEGER  ::   ji, jj , jk     ! dummy loop indices
+      REAL(wp) ::   zinr, zrr       ! temporary scalars
+      REAL(wp) ::   zavft, zavfs    !    -         -
+      REAL(wp) ::   zavdt, zavds    !    -         -
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmsks, zmskf, zmskd1, zmskd2, zmskd3   ! 2D workspace 
+      !!----------------------------------------------------------------------
+
+      IF ( kt == nit000 )   CALL zdf_ddm_init          ! Initialization (first time-step only)
+
+      !                                                ! ===============
+      DO jk = 2, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! Define the mask 
+         ! ---------------
+         rrau(:,:,jk) = MAX( 1.e-20, rrau(:,:,jk) )         ! only retains positive value of rrau
+
+         DO jj = 1, jpj                                     ! indicators:
+            DO ji = 1, jpi
+               ! stability indicator: msks=1 if rn2>0; 0 elsewhere
+               IF( rn2(ji,jj,jk) + 1.e-12  <= 0. ) THEN
+                  zmsks(ji,jj) = 0.e0
+               ELSE
+                  zmsks(ji,jj) = 1.e0
+               ENDIF
+               ! salt fingering indicator: msksf=1 if rrau>1; 0 elsewhere            
+               IF( rrau(ji,jj,jk) <= 1. ) THEN
+                  zmskf(ji,jj) = 0.e0
+               ELSE
+                  zmskf(ji,jj) = 1.e0
+               ENDIF
+               ! diffusive layering indicators: 
+               !   mskdl1=1 if 0<rrau<1; 0 elsewhere
+               IF( rrau(ji,jj,jk) >= 1. ) THEN
+                  zmskd1(ji,jj) = 0.e0
+               ELSE
+                  zmskd1(ji,jj) = 1.e0
+               ENDIF
+               !   mskdl2=1 if 0<rrau<0.5; 0 elsewhere
+               IF( rrau(ji,jj,jk) >= 0.5 ) THEN
+                  zmskd2(ji,jj) = 0.e0
+               ELSE
+                  zmskd2(ji,jj) = 1.e0
+               ENDIF
+               !   mskdl3=1 if 0.5<rrau<1; 0 elsewhere
+               IF( rrau(ji,jj,jk) <= 0.5 .OR. rrau(ji,jj,jk) >= 1. ) THEN
+                  zmskd3(ji,jj) = 0.e0
+               ELSE
+                  zmskd3(ji,jj) = 1.e0
+               ENDIF
+            END DO
+         END DO
+         ! mask zmsk in order to have avt and avs masked
+         zmsks(:,:) = zmsks(:,:) * tmask(:,:,jk)
+
+
+         ! Update avt and avs
+         ! ------------------
+         ! Constant eddy coefficient: reset to the background value
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zinr = 1./rrau(ji,jj,jk)
+               ! salt fingering
+               zrr = rrau(ji,jj,jk)/rn_hsbfr
+               zrr = zrr * zrr
+               zavfs = rn_avts / ( 1 + zrr*zrr*zrr ) * zmsks(ji,jj) * zmskf(ji,jj)
+               zavft = 0.7 * zavfs * zinr
+               ! diffusive layering
+               zavdt = 1.3635e-6 * EXP(  4.6 * EXP( -0.54*(zinr-1.) )  ) * zmsks(ji,jj) * zmskd1(ji,jj)
+               zavds = zavdt * zmsks(ji,jj) * (  (1.85 * rrau(ji,jj,jk) - 0.85 ) * zmskd3(ji,jj)   &
+                  &                            +  0.15 * rrau(ji,jj,jk)          * zmskd2(ji,jj)  )
+               ! add to the eddy viscosity coef. previously computed
+               avs (ji,jj,jk) = avt(ji,jj,jk) + zavfs + zavds
+               avt (ji,jj,jk) = avt(ji,jj,jk) + zavft + zavdt
+               avm (ji,jj,jk) = avm(ji,jj,jk) + MAX( zavft + zavdt, zavfs + zavds )
+            END DO
+         END DO
+
+
+         ! Increase avmu, avmv if necessary
+         ! --------------------------------
+!!gm to be changed following the definition of avm.
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               avmu(ji,jj,jk) = MAX( avmu(ji,jj,jk),    &
+                  &                  avt(ji,jj,jk), avt(ji+1,jj,jk),   &
+                  &                  avs(ji,jj,jk), avs(ji+1,jj,jk) )  * umask(ji,jj,jk)
+               avmv(ji,jj,jk) = MAX( avmv(ji,jj,jk),    &
+                  &                  avt(ji,jj,jk), avt(ji,jj+1,jk),   &
+                  &                  avs(ji,jj,jk), avs(ji,jj+1,jk) )  * vmask(ji,jj,jk)
+            END DO
+         END DO
+         !                                                ! ===============
+      END DO                                              !   End of slab
+      !                                                   ! ===============
+      !
+      CALL lbc_lnk( avt , 'W', 1. )        ! Lateral boundary conditions   (unchanged sign)
+      CALL lbc_lnk( avs , 'W', 1. )
+      CALL lbc_lnk( avm , 'W', 1. )
+      CALL lbc_lnk( avmu, 'U', 1. ) 
+      CALL lbc_lnk( avmv, 'V', 1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=avt , clinfo1=' ddm  - t: ', tab3d_2=avs , clinfo2=' s: ', ovlap=1, kdim=jpk)
+         CALL prt_ctl(tab3d_1=avmu, clinfo1=' ddm  - u: ', mask1=umask, &
+            &         tab3d_2=avmv, clinfo2=       ' v: ', mask2=vmask, ovlap=1, kdim=jpk)
+      ENDIF
+      !
+   END SUBROUTINE zdf_ddm
+   
+   
+   SUBROUTINE zdf_ddm_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_ddm_init  ***
+      !!
+      !! ** Purpose :   Initialization of double diffusion mixing scheme
+      !!
+      !! ** Method  :   Read the namzdf_ddm namelist and check the parameter values
+      !!              called by zdf_ddm at the first timestep (nit000)
+      !!----------------------------------------------------------------------
+      NAMELIST/namzdf_ddm/ rn_avts, rn_hsbfr
+      !!----------------------------------------------------------------------
+      !
+      REWIND ( numnam )               ! Read Namelist namzdf_ddm : double diffusion mixing scheme
+      READ   ( numnam, namzdf_ddm )
+      !
+      IF(lwp) THEN                    ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_ddm : double diffusive mixing'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_ddm : set dd mixing parameter'
+         WRITE(numout,*) '      maximum avs for dd mixing      rn_avts   = ', rn_avts
+         WRITE(numout,*) '      heat/salt buoyancy flux ratio  rn_hsbfr  = ', rn_hsbfr
+         WRITE(numout,*)
+      ENDIF
+      !
+   END SUBROUTINE zdf_ddm_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :          Dummy module          No double diffusion
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfddm = .FALSE.   !: double diffusion flag
+CONTAINS
+   SUBROUTINE zdf_ddm( kt )           ! Dummy routine
+      WRITE(*,*) 'zdf_ddm: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_ddm
+#endif
+
+   !!======================================================================
+END MODULE zdfddm
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfddm_substitute.h90	(revision 1844)
@@ -0,0 +1,18 @@
+   !!----------------------------------------------------------------------
+   !!                    *** zdfddm_substitute.h90  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute fsaht. the eddy diffusivity coeff.
+   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_zdfddm
+!   'key_zdfddm' :                      avs: 3D array defined in zdfddm module
+#   define   fsavs(i,j,k)   avs(i,j,k)
+#else
+!   Defautl option :                     avs = avt
+#   define   fsavs(i,j,k)   avt(i,j,k)
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfevd.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfevd.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfevd.F90	(revision 1844)
@@ -0,0 +1,137 @@
+MODULE zdfevd
+   !!======================================================================
+   !!                       ***  MODULE  zdfevd  ***
+   !! Ocean physics: parameterization of convection through an enhancement
+   !!                of vertical eddy mixing coefficient
+   !!======================================================================
+   !! History :  OPA  !  1997-06  (G. Madec, A. Lazar)  Original code
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
+   !!             -   !  2005-06  (C. Ethe) KPP parameterization
+   !!            3.2  !  2009-03  (M. Leclair, G. Madec, R. Benshila) test on both before & after
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_evd      : increase the momentum and tracer Kz at the location of
+   !!                  statically unstable portion of the water column (ln_zdfevd=T)
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics variables
+   USE zdfkpp          ! KPP vertical mixing
+   USE in_out_manager  ! I/O manager
+   USE iom             ! for iom_put
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_evd    ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_evd( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_evd  ***
+      !!                   
+      !! ** Purpose :   Local increased the vertical eddy viscosity and diffu-
+      !!      sivity coefficients when a static instability is encountered.
+      !!
+      !! ** Method  :   avt, avm, and the 4 neighbouring avmu, avmv coefficients
+      !!      are set to avevd (namelist parameter) if the water column is 
+      !!      statically unstable (i.e. if rn2 < -1.e-12 )
+      !!
+      !! ** Action  :   avt, avm, avmu, avmv updted in static instability cases
+      !!
+      !! References :   Lazar, A., these de l'universite Paris VI, France, 1997
+      !!----------------------------------------------------------------------
+      USE oce,   zavt_evd  =>   ua          ! use ua as workspace
+      USE oce,   zavm_evd  =>   va          ! use va as workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step indexocean time step
+      !!
+      INTEGER ::   ji, jj, jk               ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'zdf_evd : Enhanced Vertical Diffusion (evd)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+         IF(lwp) WRITE(numout,*)
+      ENDIF
+
+      zavt_evd(:,:,:) = avt(:,:,:)           ! set avt prior to evd application
+
+      SELECT CASE ( nn_evdm )
+ 
+      CASE ( 1 )           ! enhance vertical eddy viscosity and diffusivity (if rn2<-1.e-12)
+
+         zavm_evd(:,:,:) = avm(:,:,:)           ! set avm prior to evd application
+         !
+         DO jk = 1, jpkm1 
+#if defined key_vectopt_loop
+            DO jj = 1, 1                     ! big loop forced
+               DO ji = jpi+2, jpij   
+#else
+            DO jj = 2, jpj             ! no vector opt.
+               DO ji = 2, jpi
+#endif
+#if defined key_zdfkpp
+                  ! no evd mixing in the boundary layer with KPP
+                  IF( ( MIN( rn2(ji,jj,jk),  rn2b(ji,jj,jk) ) <= -1.e-12 ) .AND. ( fsdepw(ji,jj,jk) > hkpp(ji,jj) ) ) THEN
+#else
+                  IF(   MIN( rn2(ji,jj,jk),  rn2b(ji,jj,jk) ) <= -1.e-12 ) THEN
+#endif
+                     avt (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk)
+                     avm (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk)
+                     avmu(ji  ,jj  ,jk) = rn_avevd * umask(ji  ,jj  ,jk)
+                     avmu(ji-1,jj  ,jk) = rn_avevd * umask(ji-1,jj  ,jk)
+                     avmv(ji  ,jj  ,jk) = rn_avevd * vmask(ji  ,jj  ,jk)
+                     avmv(ji  ,jj-1,jk) = rn_avevd * vmask(ji  ,jj-1,jk)
+                  ENDIF
+               END DO
+            END DO
+         END DO 
+         CALL lbc_lnk( avt , 'W', 1. )   ;   CALL lbc_lnk( avm , 'W', 1. )   ! Lateral boundary conditions   (unchanged sign)
+         CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )
+         !
+         zavm_evd(:,:,:) = avm(:,:,:) - zavm_evd(:,:,:)   ! change in avm due to evd
+         CALL iom_put( "avm_evd", zavm_evd )              ! output this change
+         !
+      CASE DEFAULT         ! enhance vertical eddy diffusivity only (if rn2<-1.e-12) 
+         DO jk = 1, jpkm1
+!!!         WHERE( rn2(:,:,jk) <= -1.e-12 ) avt(:,:,jk) = tmask(:,:,jk) * avevd   ! agissant sur T SEUL! 
+#if defined key_vectopt_loop
+            DO jj = 1, 1                     ! big loop forced
+               DO ji = 1, jpij   
+#else
+            DO jj = 1, jpj             ! loop over the whole domain (no lbc_lnk call)
+               DO ji = 1, jpi
+#endif
+#if defined key_zdfkpp
+                  ! no evd mixing in the boundary layer with KPP
+                  IF( ( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) .AND. ( fsdepw(ji,jj,jk) > hkpp(ji,jj) ) ) &          
+#else
+                  IF(   MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) &
+#endif
+                     avt(ji,jj,jk) = rn_avevd * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT 
+
+      zavt_evd(:,:,:) = avt(:,:,:) - zavt_evd(:,:,:)   ! change in avt due to evd
+      CALL iom_put( "avt_evd", zavt_evd )              ! output this change
+      !
+   END SUBROUTINE zdf_evd
+
+   !!======================================================================
+END MODULE zdfevd
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 1844)
@@ -0,0 +1,177 @@
+MODULE zdfini
+   !!======================================================================
+   !!                      ***  MODULE  zdfini  ***
+   !! Ocean physics :   read vertical mixing namelist and check consistancy
+   !!======================================================================
+   !! History :  8.0  ! 1997-06  (G. Madec)  Original code from inimix
+   !!            1.0  ! 2002-08  (G. Madec)  F90 : free form
+   !!             -   ! 2005-06  (C. Ethe) KPP parameterization
+   !!             -   ! 2009-07  (G. Madec) add avmb, avtb in restart for cen2 advection
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_init    : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE par_oce         ! mesh and scale factors
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldfdyn_oce      ! ocean dynamics lateral physics
+   USE zdf_oce         ! TKE vertical mixing          
+   USE lib_mpp         ! distribued memory computing
+   USE zdftke_old      ! TKE vertical mixing  (old scheme)
+   USE zdftke          ! TKE vertical mixing
+   USE zdfkpp          ! KPP vertical mixing          
+   USE zdfddm          ! double diffusion mixing      
+   USE zdfevd          ! enhanced vertical diffusion  
+   USE zdfric          ! Richardson vertical mixing   
+   USE tranpc          ! convection: non penetrative adjustment
+   USE ldfslp          ! iso-neutral slopes
+   USE restart         ! ocean restart
+
+   USE in_out_manager  ! I/O manager
+   USE iom             ! IOM library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_init   ! routine called by opa.F90
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE zdf_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_init  ***
+      !! 
+      !! ** Purpose :   initializations of the vertical ocean physics
+      !!
+      !! ** Method  :   Read namelist namzdf, control logicals 
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio       ! temporary scalar
+      !!
+      NAMELIST/namzdf/ rn_avm0, rn_avt0, nn_avb, nn_havtb, ln_zdfexp, nn_zdfexp,   &
+         &              ln_zdfevd, nn_evdm, rn_avevd, ln_zdfnpc, nn_npc, nn_npcp
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )           !* Read namzdf namelist : vertical mixing parameters
+      READ  ( numnam, namzdf )
+
+      IF(lwp) THEN               !* Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_init: vertical physics'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf : set vertical mixing mixing parameters'
+         WRITE(numout,*) '      vertical eddy viscosity             rn_avm0   = ', rn_avm0
+         WRITE(numout,*) '      vertical eddy diffusivity           rn_avt0   = ', rn_avt0
+         WRITE(numout,*) '      constant background or profile      nn_avb    = ', nn_avb
+         WRITE(numout,*) '      horizontal variation for avtb       nn_havtb  = ', nn_havtb
+         WRITE(numout,*) '      time splitting / backward scheme    ln_zdfexp = ', ln_zdfexp
+         WRITE(numout,*) '      number of time step                 nn_zdfexp = ', nn_zdfexp
+         WRITE(numout,*) '      enhanced vertical diffusion         ln_zdfevd = ', ln_zdfevd
+         WRITE(numout,*) '         applied on momentum (=1/0)       nn_evdm   = ', nn_evdm
+         WRITE(numout,*) '      vertical coefficient for evd        rn_avevd  = ', rn_avevd
+         WRITE(numout,*) '      non-penetrative convection (npc)    ln_zdfnpc = ', ln_zdfnpc
+         WRITE(numout,*) '      npc call  frequency                 nn_npc    = ', nn_npc
+         WRITE(numout,*) '      npc print frequency                 nn_npcp   = ', nn_npcp
+      ENDIF
+
+      !                          !* Parameter & logical controls
+      !                          !  ----------------------------
+      !
+      !                               ! ... check of vertical mixing scheme on tracers
+      !                                              ==> will be done in trazdf module
+      !
+      !                               ! ... check of mixing coefficient
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '   vertical mixing option :'
+      ioptio = 0
+      IF( lk_zdfcst ) THEN
+         IF(lwp) WRITE(numout,*) '      constant eddy diffusion coefficients'
+         ioptio = ioptio+1
+      ENDIF
+      IF( lk_zdfric ) THEN
+         IF(lwp) WRITE(numout,*) '      Richardson dependent eddy coefficients'
+         ioptio = ioptio+1
+      ENDIF
+      IF( lk_zdftke_old ) THEN
+         IF(lwp) WRITE(numout,*) '      TKE dependent eddy coefficients'
+         ioptio = ioptio+1
+      ENDIF
+      IF( lk_zdftke ) THEN
+         IF(lwp) WRITE(numout,*) '      TKE dependent eddy coefficients'
+         ioptio = ioptio+1
+      ENDIF
+      IF( lk_zdfkpp ) THEN
+         IF(lwp) WRITE(numout,*) '      KPP dependent eddy coefficients'
+         ioptio = ioptio+1
+      ENDIF
+      IF( ioptio == 0 .OR. ioptio > 1 .AND. .NOT. lk_esopa ) &
+         &   CALL ctl_stop( ' one and only one vertical diffusion option has to be defined ' )
+      !
+      !                               ! ... Convection
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '   convection :'
+      ioptio = 0
+      IF( ln_zdfnpc ) THEN
+         IF(lwp) WRITE(numout,*) '      use non penetrative convective scheme'
+         ioptio = ioptio+1
+      ENDIF
+      IF( ln_zdfevd ) THEN
+         IF(lwp) WRITE(numout,*) '      use enhanced vertical dif. scheme'
+         ioptio = ioptio+1
+      ENDIF
+      IF( lk_zdftke_old .OR. lk_zdftke ) THEN
+         IF(lwp) WRITE(numout,*) '      use the 1.5 turbulent closure'
+      ENDIF
+      IF( lk_zdfkpp ) THEN
+         IF(lwp) WRITE(numout,*) '      use the KPP closure scheme'
+         IF(lk_mpp) THEN
+            IF(lwp) WRITE(numout,cform_err)
+            IF(lwp) WRITE(numout,*) 'The KPP scheme is not ready to run in MPI'
+         ENDIF
+      ENDIF
+      IF ( ioptio > 1 .AND. .NOT. lk_esopa )   CALL ctl_stop( ' chose between ln_zdfnpc and ln_zdfevd' )
+      IF( ioptio == 0 .AND. .NOT.( lk_zdftke_old .OR. lk_zdftke .OR. lk_zdfkpp ) ) &
+         CALL ctl_stop( ' except for TKE sor KPP physics, a convection scheme is', &
+         &              ' required: ln_zdfevd or ln_zdfnpc logicals' )
+
+
+      !                               !* Background eddy viscosity and diffusivity profil
+      IF( nn_avb == 0 ) THEN                ! Define avmb, avtb from namelist parameter
+         avmb(:) = rn_avm0
+         avtb(:) = rn_avt0                     
+      ELSE                                  ! Background profile of avt (fit a theoretical/observational profile (Krauss 1990)
+         avmb(:) = rn_avm0
+         avtb(:) = rn_avt0 + ( 3.0e-4 - 2 * rn_avt0 ) * 1.0e-4 * gdepw_0(:)   ! m2/s
+         IF(ln_sco .AND. lwp)   CALL ctl_warn( '          avtb profile not valid in sco' )
+      ENDIF
+      !
+      IF( ln_rstart ) THEN                  !  Read avmb, avtb in restart (if exist)
+         ! if ln_traadv_cen, avmb, avtb have been modified in traadv_cen2 module. 
+         ! To ensure the restartability, avmb & avtb are written in the restart 
+         ! file in traadv_cen2 end read here. 
+         IF( iom_varid( numror, 'avmb', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numror, jpdom_unknown, 'avmb', avmb )
+            CALL iom_get( numror, jpdom_unknown, 'avtb', avtb )
+         ENDIF
+      ENDIF
+      !                                     ! 2D shape of the avtb
+      avtb_2d(:,:) = 1.e0                        ! uniform 
+      !
+      IF( nn_havtb == 1 ) THEN                   ! decrease avtb in the equatorial band
+           !  -15S -5S : linear decrease from avt0 to avt0/10.
+           !  -5S  +5N : cst value avt0/10.
+           !   5N  15N : linear increase from avt0/10, to avt0
+           WHERE(-15. <= gphit .AND. gphit < -5 )   avtb_2d = (1.  - 0.09 * (gphit + 15.))
+           WHERE( -5. <= gphit .AND. gphit <  5 )   avtb_2d =  0.1
+           WHERE(  5. <= gphit .AND. gphit < 15 )   avtb_2d = (0.1 + 0.09 * (gphit -  5.))
+      ENDIF
+      !
+   END SUBROUTINE zdf_init
+
+   !!======================================================================
+END MODULE zdfini
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfkpp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 1844)
@@ -0,0 +1,1551 @@
+MODULE zdfkpp
+   !!======================================================================
+   !!                       ***  MODULE  zdfkpp  ***
+   !! Ocean physics:  vertical mixing coefficient compute from the KPP 
+   !!                 turbulent closure parameterization
+   !!=====================================================================
+   !! History :  8.1  ! 00-03 (W.G. Large, J. Chanut) Original code
+   !!            8.1  ! 02-06 (J.M. Molines) for real case CLIPPER  
+   !!            8.2  ! 03-10 (Chanut J.) re-writting
+   !!            9.0  ! 05-01 (C. Ethe) Free form, F90
+   !!----------------------------------------------------------------------
+#if defined key_zdfkpp   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdfkpp'                                             KPP scheme
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   zdf_kpp      : update momentum and tracer Kz from a kpp scheme
+   !!   zdf_kpp_init : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE zdf_oce         ! ocean vertical physics
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE phycst          ! physical constants
+   USE eosbn2          ! equation of state
+   USE zdfddm          ! double diffusion mixing
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE trdmod          ! momentum/tracers trends 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_kpp   ! routine called by step.F90
+   PUBLIC   tra_kpp   ! routine called by step.F90
+
+   LOGICAL , PUBLIC, PARAMETER ::   lk_zdfkpp = .TRUE.    !: KPP vertical mixing flag
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   ghats    !: non-local scalar mixing term (gamma/<ws>o)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   wt0      !: surface temperature flux for non local flux
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   ws0      !: surface salinity flux for non local flux
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   hkpp     !: boundary layer depht
+
+   !                                        !!* Namelist namzdf_kpp *
+   REAL(wp) ::   rn_difmiw  =  1.2e-04_wp    ! constant internal wave viscosity (m2/s)
+   REAL(wp) ::   rn_difsiw  =  1.2e-05_wp    ! constant internal wave diffusivity (m2/s)
+   REAL(wp) ::   rn_riinfty =  0.8_wp        ! local Richardson Number limit for shear instability
+   REAL(wp) ::   rn_difri   =  5.e-03_wp     ! maximum shear mixing at Rig = 0    (m2/s)
+   REAL(wp) ::   rn_bvsqcon = -1.e-09_wp     ! Brunt-Vaisala squared (1/s**2) for maximum convection
+   REAL(wp) ::   rn_difcon  =  1._wp         ! maximum mixing in interior convection (m2/s)
+   INTEGER  ::   nn_ave     =  1             ! = 0/1 flag for horizontal average on avt, avmu, avmv
+
+#if defined key_zdfddm
+   REAL(wp) ::                 & !!! ** Double diffusion Mixing
+      difssf  = 1.e-03_wp   ,  &  ! maximum salt fingering mixing 
+      Rrho0   = 1.9_wp      ,  &  ! limit for salt  fingering mixing 
+      difsdc  = 1.5e-06_wp       ! maximum diffusive convection mixing
+#endif
+   LOGICAL  ::   ln_kpprimix  = .TRUE.       ! Shear instability mixing 
+
+   REAL(wp) ::                 & !!! ** General constants  **
+      epsln   = 1.0e-20_wp   , &  ! a small positive number    
+      pthird  = 1._wp/3._wp  , &  ! 1/3
+      pfourth = 1._wp/4._wp       ! 1/4
+
+   REAL(wp) ::                 & !!! ** Boundary Layer Turbulence Parameters  **
+      vonk     = 0.4_wp     ,  &  ! von Karman's constant
+      epsilon  = 0.1_wp     ,  &  ! nondimensional extent of the surface layer
+      rconc1   = 5.0_wp     ,  &  ! standard flux profile function parmaeters
+      rconc2   = 16.0_wp    ,  &  !         "        "
+      rconcm   = 8.38_wp    ,  &  ! momentum flux profile fit
+      rconam   = 1.26_wp    ,  &  !         "       "
+      rzetam   = -.20_wp    ,  &  !         "       "       
+      rconcs   = 98.96_wp   ,  &  !  scalar  flux profile fit
+      rconas   = -28.86_wp  ,  &  !         "       "
+      rzetas   = -1.0_wp          !         "       "  
+   REAL(wp) ::                 & !!! ** Boundary Layer Depth Diagnostic  **
+      Ricr     = 0.3_wp     ,  &  ! critical bulk Richardson Number
+      rcekman  = 0.7_wp     ,  &  ! coefficient for ekman depth  
+      rcmonob  = 1.0_wp     ,  &  ! coefficient for Monin-Obukhov depth 
+      rconcv   = 1.7_wp     ,  &  ! ratio of interior buoyancy frequency to buoyancy frequency at entrainment depth
+      hbf      = 1.0_wp     ,  &  ! fraction of bound. layer depth to which absorbed solar 
+      !                           ! rad. and contributes to surf. buo. forcing
+      Vtc                         ! function of rconcv,rconcs,epsilon,vonk,Ricr
+   REAL(wp) ::                 & !!! ** Nonlocal Boundary Layer Mixing **
+      rcstar   = 5.0_wp     ,  &  ! coefficient for convective nonlocal transport
+      rcs      = 1.0e-3_wp  ,  &  ! conversion: mm/s ==> m/s   
+      rcg                         ! non-dimensional coefficient for nonlocal transport
+
+#if ! defined key_kppcustom
+   REAL(wp), DIMENSION(jpk,jpk) ::   del   ! array for reference mean values of vertical integration 
+#endif
+
+#if defined key_kpplktb
+   INTEGER, PARAMETER ::       & !!! ** Parameters for lookup table for turbulent velocity scales ** 
+      nilktb   = 892        ,  &  ! number of values for zehat in KPP lookup table
+      njlktb   = 482        ,  &  ! number of values for ustar in KPP lookup table
+      nilktbm1 = nilktb - 1 ,  &  !
+      njlktbm1 = njlktb - 1       !
+
+   REAL(wp), DIMENSION(nilktb,njlktb) ::   wmlktb   ! lookup table for the turbulent vertical velocity scale for momentum
+   REAL(wp), DIMENSION(nilktb,njlktb) ::   wslktb   ! lookup table for the turbulent vertical velocity scale for tracers
+
+   REAL(wp) ::                 &
+      dehatmin = -4.e-7_wp  ,  &  ! minimum limit for zhat in lookup table (m3/s3) 
+      dehatmax = 0._wp      ,  &  ! maximum limit for zhat in lookup table (m3/s3)
+      ustmin   = 0._wp      ,  &  ! minimum limit for ustar in lookup table (m/s)
+      ustmax   = 0.04_wp    ,  &  ! maximum limit for ustar in lookup table (m/s)    
+      dezehat               ,  &  ! delta zhat in lookup table
+      deustar                     ! delta ustar in lookup table
+#endif
+   REAL(wp), DIMENSION(jpk) ::   ratt   ! attenuation coef  (already defines in module traqsr, 
+   !                                    ! but only if the solar radiation penetration is considered)
+   REAL(wp) ::                 & !!! * penetrative solar radiation coefficient *
+      rabs = 0.58_wp        ,  &  ! fraction associated with xsi1
+      xsi1 = 0.35_wp        ,  &  ! first depth of extinction 
+      xsi2 = 23.0_wp              ! second depth of extinction 
+      !                           ! (default values: water type Ib) 
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+      etmean                ,  &  ! coefficient used for horizontal smoothing
+      eumean                ,  &  ! at t-, u- and v-points
+      evmean  
+ 
+#if defined key_c1d
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &
+      rig                   ,  &  ! gradient Richardson number
+      rib                   ,  &  ! bulk Richardson number
+      buof                  ,  &  ! buoyancy forcing
+      mols                        ! moning-Obukhov length scale 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ekdp   ! Ekman depth
+#endif
+
+   INTEGER  ::   jip = 62 , jjp = 111
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+#  include  "zdfddm_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL   (2009)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_kpp ( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zdf_kpp  ***
+      !!
+      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity
+      !!      coefficients and non local mixing using K-profile parameterization
+      !!
+      !! ** Method :   The boundary layer depth hkpp is diagnosed at tracer points
+      !!      from profiles of buoyancy, and shear, and the surface forcing.
+      !!      Above hbl (sigma=-z/hbl <1) the mixing coefficients are computed from 
+      !!
+      !!                      Kx =  hkpp  Wx(sigma) G(sigma)  
+      !!
+      !!             and the non local term ghat = Cs / Ws(sigma) / hkpp
+      !!      Below hkpp  the coefficients are the sum of mixing due to internal waves
+      !!      shear instability and double diffusion.
+      !!
+      !!      -1- Compute the now interior vertical mixing coefficients at all depths. 
+      !!      -2- Diagnose the boundary layer depth. 
+      !!      -3- Compute the now boundary layer vertical mixing coefficients. 
+      !!      -4- Compute the now vertical eddy vicosity and diffusivity.
+      !!      -5- Smoothing
+      !!
+      !!        N.B. The computation is done from jk=2 to jpkm1 
+      !!             Surface value of avt avmu avmv are set once a time to zero
+      !!             in routine zdf_kpp_init.
+      !!
+      !! ** Action  :   update the non-local terms ghats
+      !!                update avt, avmu, avmv (before vertical eddy coef.)
+      !!
+      !! References : Large W.G., Mc Williams J.C. and Doney S.C.              
+      !!         Reviews of Geophysics, 32, 4, November 1994
+      !!         Comments in the code refer to this paper, particularly 
+      !!         the equation number. (LMD94, here after)
+      !!----------------------------------------------------------------------
+#if defined  key_zdfddm
+      USE oce     , zviscos => ua,      &  ! temp. array for viscosities use ua as workspace
+         &          zdiffut => ta,      &  ! temp. array for diffusivities use sa as workspace
+         &          zdiffus => sa          ! temp. array for diffusivities use sa as workspace
+#else
+      USE oce     , zviscos => ua,      &  ! temp. array for viscosities use ua as workspace
+         &          zdiffut => ta          ! temp. array for diffusivities use sa as workspace
+#endif
+      !!
+      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
+      !!
+      INTEGER ::   ji, jj, jk              ! dummy loop indices
+      INTEGER ::   ikbot, jkmax, jkm1, jkp2   !
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   & !!! Surface buoyancy forcing, friction velocity
+         zBo, zBosol, zustar              !
+                      !
+      REAL(wp) ::                       &  !
+         ztx, zty, zflageos,            &  !
+         zstabl, zbuofdep,zucube,       &  !
+         zrhos, zalbet, zbeta,          &  !
+         zthermal, zhalin, zatt1           !
+     
+      REAL(wp) ::                       & !!! Bulk richardson number
+         zref, zt, zs, zh,              &  !
+         zu, zv, zrh,                   &  !
+         zrib, zrinum,                  &  !
+         zdVsq, zVtsq                      !
+      
+      REAL(wp) ::                       & !!! Velocity scales
+         zehat, zeta, zhrib, zsig,      &  !
+         zscale, zwst, zws, zwm
+
+#if defined key_kpplktb
+      INTEGER ::                        & !!! Lookup table or Analytical functions 
+         il, jl                            !
+      REAL(wp) ::                       &  !
+         ud, zfrac, ufrac,              &  !
+         zwam, zwbm, zwas, zwbs            !
+#else
+     REAL(wp) ::                        &  !
+        zwsun, zwmun,                   & 
+        zcons, zconm, zwcons, zwconm      !
+#endif
+ 
+     REAL(wp) ::                       & !!! In situ density
+         zsr, zbw, ze,                  &  !
+         zb, zd, zc, zaw, za,           &  !
+         zb1, za1, zkw, zk0,            &  !
+         zcomp , zrhd, zrhdr,zbvzed       !
+
+#if ! defined key_kppcustom     
+     !! * local declarations
+      INTEGER ::                        &
+         jm                                ! dummy loop indices
+      REAL(wp) ::                       & !!! Compression terms
+         zr1, zr2, zr3, zr4,            &  !
+         zrhop                             !
+#endif
+ 
+      REAL(wp) ::                       &  !
+         zflag, ztemp, zrn2,            &  !
+         zdep21, zdep32, zdep43
+
+      REAL(wp) ::                       & !!! Interior richardson mixing
+         zdku2, zdkv2, ze3sqr,          &  !
+         zsh2, zri, zfri                   !
+
+      REAL(wp), DIMENSION(jpi,0:2) ::  &  !!! Moning-Obukov limitation
+         zmoek
+      REAL(wp), DIMENSION(jpi)     ::  &
+         zmoa, zekman                
+      REAL(wp)                     ::  &
+         zmob, zek
+
+      REAL(wp), DIMENSION(jpi,4) ::     &  !!! The pipe 
+         zdepw, zdift, zvisc
+      REAL(wp), DIMENSION(jpi,3) ::     & 
+         zdept
+      REAL(wp), DIMENSION(jpi,2) ::     &  
+         zriblk
+      REAL(wp), DIMENSION(jpi,jpk) ::   &  !
+         zmask                          
+      REAL(wp), DIMENSION(jpi) ::       &  ! 
+         zhmax, zria, zhbl 
+      REAL(wp) ::                       &  !
+         zflagri, zflagek,              &  !
+         zflagmo, zflagh, zflagkb          !
+      REAL(wp), DIMENSION(jpi)     ::   & !!! Shape function (G)
+         za2m, za3m, zkmpm,             &
+         za2t, za3t, zkmpt
+      REAL(wp) ::                       &  !
+         zdelta, zdelta2,               &  !
+         zdzup, zdzdn, zdzh,            &  !
+         zvath, zgat1, zdat1,           &  !
+         zkm1m, zkm1t
+      REAL(wp), DIMENSION(jpi,jpk) ::   & !!! Boundary layer diffusivities/viscosities
+         zblcm, zblct                          
+#if defined key_zdfddm
+      REAL(wp) ::                       & !!! double diffusion mixing
+         zrrau, zds,                    &
+         zavdds, zavddt,zinr 
+      REAL(wp), DIMENSION(jpi,4) ::     &  
+        zdifs
+      REAL(wp), DIMENSION(jpi)     ::   &
+         za2s, za3s, zkmps
+      REAL(wp) ::                       & 
+         zkm1s
+      REAL(wp), DIMENSION(jpi,jpk) ::   & 
+         zblcs                     
+#endif
+      !!--------------------------------------------------------------------
+
+
+      ! Initialization (first time-step only)
+      ! --------------
+      IF( kt == nit000  )   CALL zdf_kpp_init
+     
+      zviscos(:,:,:) = 0.
+      zblcm  (:,:  ) = 0. 
+      zdiffut(:,:,:) = 0.
+      zblct  (:,:  ) = 0. 
+#if defined key_zdfddm
+      zdiffus(:,:,:) = 0.
+      zblcs  (:,:  ) = 0. 
+#endif
+      ghats(:,:,:) = 0.
+     
+      zBo   (:,:) = 0.
+      zBosol(:,:) = 0.
+      zustar(:,:) = 0.
+
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! I. Interior diffusivity and viscosity at w points ( T interfaces)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1 
+               ! Mixing due to internal waves breaking
+               ! -------------------------------------
+               avmu(ji,jj,jk)  = rn_difmiw 
+               avt (ji,jj,jk)  = rn_difsiw             
+               ! Mixing due to vertical shear instability
+               ! -------------------------------------               
+               IF( ln_kpprimix ) THEN          
+                  ! Compute the gradient Richardson  number at interfaces (zri):
+                  ! LMD94, eq. 27 (is vertical smoothing needed : Rig=N^2 / (dz(u))^2 + (dz(v))^2
+                  zdku2 =   ( un(ji - 1,jj,jk - 1) - un(ji - 1,jj,jk) ) &
+                     &    * ( un(ji - 1,jj,jk - 1) - un(ji - 1,jj,jk) ) &
+                     &    + ( un(ji    ,jj,jk - 1) - un(ji    ,jj,jk) ) &
+                     &    * ( un(ji    ,jj,jk - 1) - un(ji    ,jj,jk) )  
+                  
+                  zdkv2 =   ( vn(ji,jj - 1,jk - 1) - vn(ji,jj - 1,jk) ) &
+                     &    * ( vn(ji,jj - 1,jk - 1) - vn(ji,jj - 1,jk) ) &
+                     &    + ( vn(ji,    jj,jk - 1) - vn(ji,    jj,jk) ) &
+                     &    * ( vn(ji,    jj,jk - 1) - vn(ji,    jj,jk) )  
+
+                  ze3sqr = 1. / ( fse3w(ji,jj,jk) * fse3w(ji,jj,jk) )
+                  ! Square of vertical shear  at interfaces
+                  zsh2   = 0.5 * ( zdku2 + zdkv2 ) * ze3sqr
+                  zri    = MAX( rn2(ji,jj,jk), 0. ) / ( zsh2 + epsln ) 
+#if defined key_c1d
+                  ! save the gradient richardson number
+                  rig(ji,jj,jk) = zri * tmask(ji,jj,jk)
+#endif                  
+                  ! Evaluate f of Ri (zri) for shear instability store in zfri
+                  ! LMD94, eq. 28a,b,c, figure 3 ; Rem: p1 is 3, hard coded
+                  zfri  = MAX( zri , 0. )
+                  zfri  = MIN( zfri / rn_riinfty , 1.0 )
+                  zfri  = ( 1.0 - zfri * zfri )
+                  zfri  = zfri * zfri  * zfri
+                  ! add shear contribution to mixing coef. 
+                  avmu(ji,jj,jk) =  avmu(ji,jj,jk) + rn_difri * zfri   
+                  avt (ji,jj,jk) =  avt (ji,jj,jk) + rn_difri * zfri    
+               ENDIF
+#if defined key_zdfddm 
+               avs (ji,jj,jk) =  avt (ji,jj,jk)              
+               !  Double diffusion mixing ; NOT IN ROUTINE ZDFDDM.F90
+               ! ------------------------------------------------------------------
+               ! only retains positive value of rrau
+               zrrau = MAX( rrau(ji,jj,jk), epsln )
+               zds   = sn(ji,jj,jk-1) - sn(ji,jj,jk)
+               IF( zrrau > 1. .AND. zds > 0.) THEN
+                  !
+                  ! Salt fingering case.
+                  !---------------------
+                  ! Compute interior diffusivity for double diffusive mixing of
+                  ! salinity. Upper bound "zrrau" by "Rrho0"; (Rrho0=1.9, difcoefnuf=0.001).
+                  ! After that set interior diffusivity for double diffusive mixing
+                  ! of temperature
+                  zavdds = MIN( zrrau, Rrho0 )
+                  zavdds = ( zavdds - 1.0 ) / ( Rrho0 - 1.0 )
+                  zavdds = 1.0 - zavdds * zavdds 
+                  zavdds = zavdds * zavdds * zavdds 
+                  zavdds = difssf * zavdds 
+                  zavddt = 0.7 * zavdds
+               ELSEIF( zrrau < 1. .AND. zrrau > 0. .AND. zds < 0.) THEN
+                  !
+                  ! Diffusive convection case.
+                  !---------------------------
+                  ! Compute interior diffusivity for double diffusive mixing of
+                  ! temperature (Marmorino and Caldwell, 1976); 
+                  ! Compute interior diffusivity for double diffusive mixing of salinity 
+                  zinr   = 1. / zrrau
+                  zavddt = 0.909 * EXP( 4.6 * EXP( -0.54* ( zinr - 1. ) ) ) 
+                  zavddt = difsdc * zavddt
+                  IF( zrrau < 0.5) THEN
+                     zavdds = zavddt * 0.15 * zrrau
+                  ELSE
+                     zavdds = zavddt * (1.85 * zrrau - 0.85 ) 
+                  ENDIF
+               ELSE
+                  zavddt = 0.
+                  zavdds = 0.
+               ENDIF 
+               ! Add double diffusion contribution to temperature and salinity  mixing coefficients.
+               avt (ji,jj,jk) =  avt (ji,jj,jk) +  zavddt 
+               avs (ji,jj,jk) =  avs (ji,jj,jk) +  zavdds         
+#endif                      
+            END DO
+         END DO
+      END DO
+
+
+      ! Radiative (zBosol) and non radiative (zBo) surface buoyancy
+      !JMM at the time zdfkpp is called, q still holds the sum q + qsr
+      !---------------------------------------------------------------------
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1     
+            IF( nn_eos < 1) THEN   
+               zt     = tn(ji,jj,1)
+               zs     = sn(ji,jj,1) - 35.0
+               zh     = fsdept(ji,jj,1)
+               !  potential volumic mass
+               zrhos  = rhop(ji,jj,1)
+               zalbet = ( ( ( - 0.255019e-07 * zt + 0.298357e-05 ) * zt   &   ! ratio alpha/beta
+                  &                               - 0.203814e-03 ) * zt   &
+                  &                               + 0.170907e-01 ) * zt   &
+                  &   + 0.665157e-01                                      &
+                  &   +     ( - 0.678662e-05 * zs                         &
+                  &           - 0.846960e-04 * zt + 0.378110e-02 ) * zs   &
+                  &   +   ( ( - 0.302285e-13 * zh                         &
+                  &           - 0.251520e-11 * zs                         &
+                  &           + 0.512857e-12 * zt * zt           ) * zh   &
+                  &           - 0.164759e-06 * zs                         &
+                  &        +(   0.791325e-08 * zt - 0.933746e-06 ) * zt   &
+                  &                               + 0.380374e-04 ) * zh
+
+               zbeta  = ( ( -0.415613e-09 * zt + 0.555579e-07 ) * zt      &   ! beta
+                  &                            - 0.301985e-05 ) * zt      &
+                  &   + 0.785567e-03                                      &
+                  &   + (     0.515032e-08 * zs                           &
+                  &         + 0.788212e-08 * zt - 0.356603e-06 ) * zs     &
+                  &   +(  (   0.121551e-17 * zh                           &
+                  &         - 0.602281e-15 * zs                           &
+                  &         - 0.175379e-14 * zt + 0.176621e-12 ) * zh     &
+                  &                             + 0.408195e-10   * zs     &
+                  &     + ( - 0.213127e-11 * zt + 0.192867e-09 ) * zt     &
+                  &                             - 0.121555e-07 ) * zh
+
+               zthermal = zbeta * zalbet / ( rcp * zrhos + epsln )
+               zhalin   = zbeta * sn(ji,jj,1) * rcs
+            ELSE
+               zrhos    = rhop(ji,jj,1) + rau0 * ( 1. - tmask(ji,jj,1) )
+               zthermal = rn_alpha / ( rcp * zrhos + epsln )
+               zhalin   = rn_beta * sn(ji,jj,1) * rcs
+            ENDIF
+            ! Radiative surface buoyancy force
+            zBosol(ji,jj) = grav * zthermal * qsr(ji,jj)
+            ! Non radiative surface buoyancy force
+            zBo   (ji,jj) = grav * zthermal * qns(ji,jj) -  grav * zhalin * emps(ji,jj)
+            ! Surface Temperature flux for non-local term
+            wt0(ji,jj) = - ( qsr(ji,jj) + qns(ji,jj) )* ro0cpr * tmask(ji,jj,1)
+            ! Surface salinity flux for non-local term
+            ws0(ji,jj) = - ( emps(ji,jj) * sn(ji,jj,1) * rcs ) * tmask(ji,jj,1)
+         ENDDO
+      ENDDO
+
+      zflageos = 0.5 + SIGN( 0.5, nn_eos - 1. ) 
+      !  Compute surface buoyancy forcing, Monin Obukhov and Ekman depths  
+      !------------------------------------------------------------------    
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            !  Reference surface density = density at first T point level   
+            zrhos         = rhop(ji,jj,1) + zflageos * rau0 * ( 1. - tmask(ji,jj,1) )  
+            ! Friction velocity (zustar), at T-point : LMD94 eq. 2
+            zustar(ji,jj) = SQRT( taum(ji,jj) / ( zrhos +  epsln ) )
+         ENDDO
+      ENDDO
+
+!CDIR NOVERRCHK  
+      !                                               ! ===============
+      DO jj = 2, jpjm1                                 !  Vertical slab
+         !                                             ! ===============
+         
+         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+         ! II Compute Boundary layer mixing coef. and diagnose the new boundary layer depth
+         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+         
+         ! Initialization
+         jkmax       = 0
+         zdept (:,:) = 0.
+         zdepw (:,:) = 0.
+         zriblk(:,:) = 0.
+         zmoek (:,:) = 0.
+         zvisc (:,:) = 0.
+         zdift (:,:) = 0.
+#if defined key_zdfddm
+         zdifs (:,:) = 0.
+#endif
+         zmask (:,:) = 0.
+         DO ji = fs_2, fs_jpim1
+            zria(ji ) = 0.
+            ! Maximum boundary layer depth
+            ikbot     = mbathy(ji,jj) - 1 ! ikbot is the last T point in the water
+            zhmax(ji) = fsdept(ji,jj,ikbot) - 0.001      
+            ! Compute Monin obukhov length scale at the surface and Ekman depth:
+            zbuofdep   = zBo(ji,jj) + zBosol(ji,jj) * ratt(1)
+            zekman(ji) = rcekman * zustar(ji,jj) / ( ABS( ff(ji,jj) ) + epsln )
+            zucube     = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj) 
+            zmoa(ji)   = zucube / ( vonk * ( zbuofdep + epsln ) )   
+#if defined key_c1d
+            ! store the surface buoyancy forcing
+            zstabl        = 0.5 + SIGN( 0.5, zbuofdep )
+            buof(ji,jj,1) = zbuofdep * tmask(ji,jj,1)
+            ! store the moning-oboukov length scale at surface
+            zmob          = zstabl * zmoa(ji) + ( 1.0 - zstabl ) * fsdept(ji,jj,1)
+            mols(ji,jj,1) = MIN( zmob , zhmax(ji) ) * tmask(ji,jj,1)
+            ! store Ekman depth
+            zek           = zstabl * zekman(ji) + ( 1.0 - zstabl ) * fsdept(ji,jj,1)  
+            ekdp(ji,jj )  = MIN( zek , zhmax(ji) ) * tmask(ji,jj,1)  
+#endif 
+         END DO     
+         ! Compute the pipe
+         ! ---------------------
+         DO jk = 2, jpkm1
+            DO ji = fs_2, fs_jpim1
+               ! Compute bfsfc = Bo + radiative contribution down to hbf*depht
+               zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * ratt(jk)
+               ! Flag (zstabl  = 1) if positive forcing
+               zstabl   =  0.5 + SIGN(  0.5, zbuofdep)
+
+               !   Compute bulk richardson number zrib at depht 
+               !-------------------------------------------------------
+               !                           [Br - B(d)] * d         zrinum
+               !             Rib(z) = ----------------------- = -------------
+               !                       |Vr - V(d)|^2 + Vt(d)^2   zdVsq + zVtsq
+               !
+               ! First compute zt,zs,zu,zv = means in the surface layer < epsilon*depht  
+               ! Else surface values are taken at the first T level.
+               ! For stability, resolved vertical shear is computed with "before velocities".
+               zref = epsilon * fsdept(ji,jj,jk)
+#if defined key_kppcustom
+               ! zref = gdept(1)
+               zref = fsdept(ji,jj,1)
+               zt   = tn(ji,jj,1)
+               zs   = sn(ji,jj,1)
+               zrh  = rhop(ji,jj,1)
+               zu   = ( ub(ji,jj,1) + ub(ji - 1,jj    ,1) ) / MAX( 1. , umask(ji,jj,1) + umask(ji - 1,jj   ,1) )
+               zv   = ( vb(ji,jj,1) + vb(ji    ,jj - 1,1) ) / MAX( 1. , vmask(ji,jj,1) + vmask(ji   ,jj - 1,1) )
+#else
+               zt   = 0.
+               zs   = 0.
+               zu   = 0.
+               zv   = 0.
+               zrh  = 0.
+               ! vertically integration over the upper epsilon*gdept(jk) ; del () array is computed once in zdf_kpp_init
+               DO jm = 1, jpkm1
+                  zt   = zt  + del(jk,jm) * tn(ji,jj,jm)
+                  zs   = zs  + del(jk,jm) * sn(ji,jj,jm)
+                  zu   = zu  + 0.5 * del(jk,jm) &
+                     &            * ( ub(ji,jj,jm) + ub(ji - 1,jj,jm) ) &
+                     &            / MAX( 1. , umask(ji,jj,jm) + umask(ji - 1,jj,jm) )
+                  zv   = zv  + 0.5 * del(jk,jm) &
+                     &            * ( vb(ji,jj,jm) + vb(ji,jj - 1,jm) ) &
+                     &            / MAX( 1. , vmask(ji,jj,jm) + vmask(ji,jj - 1,jm) )
+                  zrh  = zrh + del(jk,jm) * rhop(ji,jj,jm)
+               END DO
+#endif
+               zsr = SQRT( ABS( sn(ji,jj,jk) ) )
+               ! depth
+               zh = fsdept(ji,jj,jk)
+               ! compute compression terms on density
+               ze  = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
+               zbw = (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
+               zb  = zbw + ze * zs
+               
+               zd  = -2.042967e-2
+               zc  =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
+               zaw = ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
+               za  = ( zd*zsr + zc ) *zs + zaw
+               
+               zb1 =   (-0.1909078*zt+7.390729 ) *zt-55.87545
+               za1 = ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
+               zkw = ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
+               zk0 = ( zb1*zsr + za1 )*zs + zkw
+               zcomp =   1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )
+               
+#if defined key_kppcustom
+               ! potential density of water(zrh = zt,zs at level jk):
+               zrhdr = zrh / zcomp
+#else
+               ! potential density of water(ztref,zsref at level jk):
+               ! compute volumic mass pure water at atm pressure
+               IF ( nn_eos < 1 ) THEN
+                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
+                     &       -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
+                  ! seawater volumic mass atm pressure
+                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
+                     &   -4.0899e-3 ) *zt+0.824493
+                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
+                  zr4= 4.8314e-4              
+                  ! potential volumic mass (reference to the surface)
+                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1                 
+                  zrhdr = zrhop / zcomp
+               ELSE
+                  zrhdr = zrh / zcomp
+               ENDIF
+#endif
+               
+               ! potential density of ambiant water at level jk :
+               zrhd   = ( rhd(ji,jj,jk) * rau0 + rau0 )  
+               
+               ! And now the Rib number numerator .
+               zrinum = grav * ( zrhd - zrhdr ) / rau0
+               zrinum = zrinum * ( fsdept(ji,jj,jk) - zref ) * tmask(ji,jj,jk)
+           
+               ! Resolved shear contribution to Rib at depth T-point (zdVsq)
+               ztx    =   ( ub( ji , jj ,jk)   +  ub(ji - 1, jj ,jk) ) &
+                  &     / MAX( 1. , umask( ji , jj ,jk) + umask(ji - 1, jj ,jk) )   
+               zty    =   ( vb( ji , jj ,jk)   +  vb(ji  ,jj - 1,jk) ) &
+                  &     / MAX( 1., vmask( ji , jj ,jk) + vmask(ji  ,jj - 1,jk) ) 
+               
+               zdVsq  = ( zu - ztx ) * ( zu - ztx ) + ( zv - zty ) * ( zv - zty )
+               
+               ! Scalar turbulent velocity scale zws for hbl=gdept
+               zscale = zstabl + ( 1.0 - zstabl ) * epsilon
+               zehat  = vonk * zscale * fsdept(ji,jj,jk) * zbuofdep
+               zucube = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)              
+               zeta   = zehat / ( zucube + epsln )
+               
+               IF( zehat > 0. ) THEN
+                  ! Stable case
+                  zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
+               ELSE
+                  ! Unstable case
+#if defined key_kpplktb
+                  ! use lookup table
+                  zd     = zehat - dehatmin
+                  il     = INT( zd / dezehat )
+                  il     = MIN( il, nilktbm1 )
+                  il     = MAX( il, 1 )
+                  
+                  ud     = zustar(ji,jj) - ustmin
+                  jl     = INT( ud / deustar )
+                  jl     = MIN( jl, njlktbm1 )
+                  jl     = MAX( jl, 1 )
+                  
+                  zfrac  = zd / dezehat - FLOAT( il )  
+                  ufrac  = ud / deustar - FLOAT( jl )
+                  zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
+                  zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
+                  !
+                  zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
+#else
+                  ! use analytical functions:
+                  zcons  = 0.5 + SIGN( 0.5 , ( rzetas - zeta ) )
+                  zwcons = vonk * zustar(ji,jj) * ( ( ABS( rconas - rconcs * zeta ) )**pthird ) 
+                  zwsun  = vonk * zustar(ji,jj) * SQRT( ABS ( 1.0 - rconc2 * zeta ) )
+                  !
+                  zws    = zcons * zwcons +  ( 1.0 - zcons) * zwsun
+#endif
+               ENDIF
+               
+               ! Turbulent shear contribution to Rib (zVtsq) bv frequency at levels  ( ie T-point jk)
+               zrn2   = 0.5 * ( rn2(ji,jj,jk) + rn2(ji,jj,jk+1) )   
+               zbvzed = SQRT( ABS( zrn2 ) ) 
+               zVtsq  = fsdept(ji,jj,jk) * zws * zbvzed  * Vtc
+               
+               ! Finally, the bulk Richardson number at depth fsdept(i,j,k) 
+               zrib  = zrinum   / ( zdVsq + zVtsq + epsln )
+ 
+               ! Find subscripts around the boundary layer depth, build the pipe
+               ! ----------------------------------------------------------------
+
+               ! Flag (zflagri = 1) if zrib < Ricr  
+               zflagri = 0.5 + SIGN( 0.5, ( Ricr - zrib ) )
+               !  Flag (zflagh  = 1) if still within overall boundary layer
+               zflagh  = 0.5 + SIGN( 0.5, ( fsdept(ji,jj,1) - zdept(ji,2) ) )
+               
+               ! Ekman layer depth
+               zek     = zstabl * zekman(ji) + ( 1.0 - zstabl ) * zhmax(ji)
+               zflag   = 0.5 + SIGN( 0.5, ( zek - fsdept(ji,jj,jk-1) ) )
+               zek     = zflag * zek + ( 1.0 - zflag ) * zhmax(ji)
+               zflagek = 0.5 + SIGN( 0.5, ( zek - fsdept(ji,jj,jk) ) )
+               ! Flag (zflagmo = 1) if still within stable Monin-Obukhov and in water
+               zmob    = zucube / ( vonk * ( zbuofdep + epsln ) )  
+               ztemp   = zstabl * zmob + ( 1.0 - zstabl) * zhmax(ji)
+               ztemp   = MIN( ztemp , zhmax(ji) ) 
+               zflagmo = 0.5 + SIGN( 0.5, ( ztemp - fsdept(ji,jj,jk) ) )             
+
+               ! No limitation by Monin Obukhov or Ekman depths:
+!               zflagek = 1.0
+!               zflagmo = 0.5 + SIGN( 0.5, ( zhmax(ji) - fsdept(ji,jj,jk) ) )
+
+               ! Load  pipe via zflagkb  for later calculations
+               ! Flag (zflagkb = 1) if zflagh = 1 and (zflagri = 0 or zflagek = 0 or zflagmo = 0)
+               zflagkb = zflagh * ( 1.0 - ( zflagri * zflagek * zflagmo ) )
+
+               zmask(ji,jk) = zflagh
+               jkp2         = MIN( jk+2 , ikbot )
+               jkm1         = MAX( jk-1 , 2 )
+               jkmax        = MAX( jkmax, jk * INT( REAL( zflagh+epsln ) ) ) 
+
+               zdept(ji,1)  = zdept(ji,1) + zflagkb * fsdept(ji,jj,jk-1) 
+               zdept(ji,2)  = zdept(ji,2) + zflagkb * fsdept(ji,jj,jk  ) 
+               zdept(ji,3)  = zdept(ji,3) + zflagkb * fsdept(ji,jj,jk+1) 
+
+               zdepw(ji,1)  = zdepw(ji,1) + zflagkb * fsdepw(ji,jj,jk-1) 
+               zdepw(ji,2)  = zdepw(ji,2) + zflagkb * fsdepw(ji,jj,jk  ) 
+               zdepw(ji,3)  = zdepw(ji,3) + zflagkb * fsdepw(ji,jj,jk+1)
+               zdepw(ji,4)  = zdepw(ji,4) + zflagkb * fsdepw(ji,jj,jkp2)  
+
+               zriblk(ji,1) = zriblk(ji,1) + zflagkb * zria(ji)
+               zriblk(ji,2) = zriblk(ji,2) + zflagkb * zrib
+
+               zmoek (ji,0) = zmoek (ji,0) + zflagkb * zek
+               zmoek (ji,1) = zmoek (ji,1) + zflagkb * zmoa(ji)
+               zmoek (ji,2) = zmoek (ji,2) + zflagkb * ztemp  
+               ! Save Monin Obukhov depth
+               zmoa  (ji)   = zmob
+           
+               zvisc(ji,1) = zvisc(ji,1) + zflagkb * avmu(ji,jj,jkm1)
+               zvisc(ji,2) = zvisc(ji,2) + zflagkb * avmu(ji,jj,jk  )
+               zvisc(ji,3) = zvisc(ji,3) + zflagkb * avmu(ji,jj,jk+1)
+               zvisc(ji,4) = zvisc(ji,4) + zflagkb * avmu(ji,jj,jkp2)
+               
+               zdift(ji,1) = zdift(ji,1) + zflagkb * avt (ji,jj,jkm1)
+               zdift(ji,2) = zdift(ji,2) + zflagkb * avt (ji,jj,jk  )
+               zdift(ji,3) = zdift(ji,3) + zflagkb * avt (ji,jj,jk+1)
+               zdift(ji,4) = zdift(ji,4) + zflagkb * avt (ji,jj,jkp2)
+
+#if defined key_zdfddm
+               zdifs(ji,1) = zdifs(ji,1) + zflagkb * avs (ji,jj,jkm1)
+               zdifs(ji,2) = zdifs(ji,2) + zflagkb * avs (ji,jj,jk  )
+               zdifs(ji,3) = zdifs(ji,3) + zflagkb * avs (ji,jj,jk+1)
+               zdifs(ji,4) = zdifs(ji,4) + zflagkb * avs (ji,jj,jkp2)
+#endif               
+               ! Save the Richardson number 
+               zria  (ji)   = zrib  
+#if defined key_c1d
+               ! store buoyancy length scale
+               buof(ji,jj,jk) = zbuofdep * tmask(ji,jj,jk) 
+               ! store Monin Obukhov
+               zmob           = zstabl * zmob + ( 1.0 - zstabl) * fsdept(ji,jj,1)
+               mols(ji,jj,jk) = MIN( zmob , zhmax(ji) ) * tmask(ji,jj,jk) 
+               ! Bulk Richardson number
+               rib(ji,jj,jk)  = zrib * tmask(ji,jj,jk)             
+#endif               
+            END DO
+         END DO
+         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+         ! III PROCESS THE PIPE
+         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+         
+         DO ji = fs_2, fs_jpim1 
+            
+            ! Find the boundary layer depth zhbl
+            ! ----------------------------------------
+            
+            ! Interpolate monin Obukhov and critical Ri mumber depths   
+            ztemp = zdept(ji,2) - zdept(ji,1)
+            zflag = ( Ricr - zriblk(ji,1) ) / ( zriblk(ji,2) - zriblk(ji,1)  + epsln )
+            zhrib = zdept(ji,1) + zflag * ztemp      
+
+            IF( zriblk(ji,2) < Ricr ) zhrib = zhmax(ji) 
+         
+            IF( zmoek(ji,2) < zdept(ji,2) ) THEN
+               IF ( zmoek(ji,1) < 0. ) THEN
+                  zmob = zdept(ji,2) - epsln
+               ELSE
+                  zmob = ztemp + zmoek(ji,1) - zmoek(ji,2)
+                  zmob = ( zmoek(ji,1) * zdept(ji,2) - zmoek(ji,2) * zdept(ji,1) ) / zmob
+                  zmob = MAX( zmob , zdept(ji,1) + epsln )                
+               ENDIF
+            ELSE           
+               zmob = zhmax(ji) 
+            ENDIF
+            ztemp   = MIN( zmob , zmoek(ji,0) )
+                         
+            ! Finally, the boundary layer depth, zhbl 
+            zhbl(ji) = MAX( fsdept(ji,jj,1) + epsln, MIN( zhrib , ztemp ) )
+            
+            ! Save hkpp for further diagnostics (optional)
+            hkpp(ji,jj) = zhbl(ji) * tmask(ji,jj,1) 
+          
+            ! Correct mask if zhbl < fsdepw(ji,jj,2) for no viscosity/diffusivity enhancement at fsdepw(ji,jj,2)
+            !     zflag = 1 if zhbl(ji) > fsdepw(ji,jj,2)
+            IF( zhbl(ji) < fsdepw(ji,jj,2) ) zmask(ji,2) = 0.
+          
+            
+            !  Velocity scales at depth zhbl
+            ! -----------------------------------
+            
+            !  Compute bouyancy forcing down to zhbl
+            ztemp    = -hbf * zhbl(ji)
+            zatt1    = 1.0 - ( rabs * EXP( ztemp / xsi1 ) + ( 1.0 - rabs ) * EXP( ztemp / xsi2 ) )
+            zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * zatt1
+            zstabl   = 0.5 + SIGN( 0.5 , zbuofdep ) 
+
+            zbuofdep = zbuofdep + zstabl * epsln
+
+            zscale = zstabl + ( 1.0 - zstabl ) * epsilon          
+            zehat  = vonk * zscale * zhbl(ji) * zbuofdep
+            zucube = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)              
+            zeta   = zehat / ( zucube + epsln )
+            
+            IF( zehat > 0. ) THEN
+               ! Stable case
+               zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
+               zwm  = zws
+            ELSE
+               ! Unstable case
+#if defined key_kpplktb
+               ! use lookup table
+               zd     = zehat - dehatmin
+               il     = INT( zd / dezehat )
+               il     = MIN( il, nilktbm1 )
+               il     = MAX( il, 1 )
+               
+               ud     = zustar(ji,jj) - ustmin
+               jl     = INT( ud / deustar )
+               jl     = MIN( jl, njlktbm1 )
+               jl     = MAX( jl, 1 )
+               
+               zfrac  = zd / dezehat - FLOAT( il )  
+               ufrac  = ud / deustar - FLOAT( jl )
+               zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
+               zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
+               zwam   = ( 1. - zfrac ) * wmlktb(il,jl+1) + zfrac * wmlktb(il+1,jl+1)
+               zwbm   = ( 1. - zfrac ) * wmlktb(il,jl  ) + zfrac * wmlktb(il+1,jl  )
+               !
+               zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
+               zwm    = ( 1. - ufrac ) * zwbm + ufrac * zwam
+#else
+               ! use analytical functions
+               zconm  = 0.5 + SIGN( 0.5, ( rzetam - zeta) )
+               zcons  = 0.5 + SIGN( 0.5, ( rzetas - zeta) )
+               
+               ! Momentum : zeta < rzetam (zconm = 1)
+               ! Scalars  : zeta < rzetas (zcons = 1) 
+               zwconm = zustar(ji,jj) * vonk * ( ( ABS( rconam - rconcm * zeta) )**pthird )
+               zwcons = zustar(ji,jj) * vonk * ( ( ABS( rconas - rconcs * zeta) )**pthird )
+               
+               ! Momentum : rzetam <= zeta < 0 (zconm = 0)
+               ! Scalars  : rzetas <= zeta < 0 (zcons = 0)	
+               zwmun  = SQRT( ABS( 1.0 - rconc2 * zeta ) )
+               zwsun  = vonk * zustar(ji,jj) * zwmun
+               zwmun  = vonk * zustar(ji,jj) * SQRT(zwmun)
+               !
+               zwm    = zconm * zwconm + ( 1.0 - zconm ) * zwmun
+               zws    = zcons * zwcons + ( 1.0 - zcons ) * zwsun
+               
+#endif
+            ENDIF
+            
+            
+            ! Viscosity, diffusivity values and derivatives at h
+            ! --------------------------------------------------------
+            
+            ! check between at which interfaces is located zhbl(ji)
+            ! ztemp = 1, zdepw(ji,2) < zhbl <  zdepw(ji,3)
+            ! ztemp = 0, zdepw(ji,1) < zhbl <  zdepw(ji,2)
+            ztemp  =  0.5 + SIGN( 0.5, ( zhbl(ji) - zdepw(ji,2) ) )  
+            zdep21 =   zdepw(ji,2) - zdepw(ji,1) + epsln
+            zdep32 =   zdepw(ji,3) - zdepw(ji,2) + epsln
+            zdep43 =   zdepw(ji,4) - zdepw(ji,3) + epsln  
+            
+            ! Compute R as in LMD94, eq D5b
+            zdelta =  ( zhbl(ji) - zdepw(ji,2) ) *         ztemp   / zdep32   &
+               &    + ( zhbl(ji) - zdepw(ji,1) ) * ( 1.0 - ztemp ) / zdep21 
+            
+            ! Compute the vertical derivative of viscosities (zdzh) at z=zhbl(ji)
+            zdzup  =  ( zvisc(ji,2) - zvisc(ji,3) ) *         ztemp   / zdep32 &
+               &    + ( zvisc(ji,1) - zvisc(ji,2) ) * ( 1.0 - ztemp ) / zdep21
+            
+            zdzdn  =  ( zvisc(ji,3) - zvisc(ji,4) ) *         ztemp   / zdep43 &
+               &    + ( zvisc(ji,2) - zvisc(ji,3) ) * ( 1.0 - ztemp ) / zdep32
+            
+            ! LMD94, eq D5b :          
+            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
+            zdzh   = MAX( zdzh , 0. )
+            
+            ! Compute viscosities (zvath) at z=zhbl(ji), LMD94 eq D5a
+            zvath  =          ztemp   * ( zvisc(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
+               &    + ( 1.0 - ztemp ) * ( zvisc(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
+            
+            ! Compute G (zgat1) and its derivative (zdat1) at z=hbl(ji), LMD94 eq 18
+            
+            ! Vertical derivative of velocity scale divided by velocity scale squared at z=hbl(ji) 
+            ! (non zero only in stable conditions)
+            zflag  =  -zstabl * rconc1 * zbuofdep / ( zucube * zustar(ji,jj) + epsln )
+            
+            ! G at its derivative at z=hbl:
+            zgat1  = zvath  / ( zhbl(ji) * ( zwm + epsln )  )
+            zdat1  = -zdzh  / ( zwm + epsln ) -  zflag * zvath / zhbl(ji)
+            
+            ! G coefficients, LMD94 eq 17
+            za2m(ji) = -2.0 + 3.0 * zgat1 - zdat1
+            za3m(ji) =  1.0 - 2.0 * zgat1 + zdat1
+
+            
+            ! Compute the vertical derivative of temperature diffusivities (zdzh) at z=zhbl(ji)
+            zdzup  =  ( zdift(ji,2) - zdift(ji,3) ) *         ztemp   / zdep32 &
+               &    + ( zdift(ji,1) - zdift(ji,2) ) * ( 1.0 - ztemp ) / zdep21
+            
+            zdzdn  =  ( zdift(ji,3) - zdift(ji,4) ) *         ztemp   / zdep43 &
+               &    + ( zdift(ji,2) - zdift(ji,3) ) * ( 1.0 - ztemp ) / zdep32
+            
+            ! LMD94, eq D5b :          
+            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
+            zdzh   = MAX( zdzh , 0. )
+            
+            
+            ! Compute diffusivities (zvath) at z=zhbl(ji), LMD94 eq D5a
+            zvath  =          ztemp   * ( zdift(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
+               &    + ( 1.0 - ztemp ) * ( zdift(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
+                        
+            ! G at its derivative at z=hbl:
+            zgat1  = zvath  / ( zhbl(ji) * ( zws + epsln )  )
+            zdat1  = -zdzh  / ( zws + epsln ) -  zflag * zvath / zhbl(ji)
+            
+            ! G coefficients, LMD94 eq 17
+            za2t(ji) = -2.0 + 3.0 * zgat1 - zdat1
+            za3t(ji) =  1.0 - 2.0 * zgat1 + zdat1
+
+#if defined key_zdfddm
+            ! Compute the vertical derivative of salinities diffusivities (zdzh) at z=zhbl(ji)
+            zdzup  =  ( zdifs(ji,2) - zdifs(ji,3) ) *         ztemp   / zdep32 &
+               &    + ( zdifs(ji,1) - zdifs(ji,2) ) * ( 1.0 - ztemp ) / zdep21
+            
+            zdzdn  =  ( zdifs(ji,3) - zdifs(ji,4) ) *         ztemp   / zdep43 &
+               &    + ( zdifs(ji,2) - zdifs(ji,3) ) * ( 1.0 - ztemp ) / zdep32
+            
+            ! LMD94, eq D5b :          
+            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
+            zdzh   = MAX( zdzh , 0. )           
+            
+            ! Compute diffusivities (zvath) at z=zhbl(ji), LMD94 eq D5a
+            zvath  =          ztemp   * ( zdifs(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
+               &    + ( 1.0 - ztemp ) * ( zdifs(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
+                        
+            ! G at its derivative at z=hbl:
+            zgat1  = zvath  / ( zhbl(ji) * ( zws + epsln )  )
+            zdat1  = -zdzh  / ( zws + epsln ) -  zflag * zvath / zhbl(ji)
+            
+            ! G coefficients, LMD94 eq 17
+            za2s(ji) = -2.0 + 3.0 * zgat1 - zdat1
+            za3s(ji) =  1.0 - 2.0 * zgat1 + zdat1
+#endif
+
+            !-------------------turn off interior matching here------
+            !          za2(ji,1) = -2.0
+            !          za3(ji,1) =  1.0
+            !          za2(ji,2) = -2.0
+            !          za3(ji,2) =  1.0
+            !--------------------------------------------------------
+            
+            !  Compute Enhanced Mixing Coefficients (LMD94,eq D6)
+            ! ---------------------------------------------------------------
+            
+            ! Delta 
+            zdelta  = ( zhbl(ji)  - zdept(ji,1) ) / ( zdept(ji,2) - zdept(ji,1) + epsln )
+            zdelta2 = zdelta * zdelta
+            
+            !  Mixing coefficients at first level above h (zdept(ji,1)) 
+            ! and at first interface in the pipe (zdepw(ji,2))
+            
+            ! At first T level above h (zdept(ji,1)) (always in the boundary layer)
+            zsig    = zdept(ji,1) / zhbl(ji)
+            ztemp   = zstabl * zsig  + ( 1.0 - zstabl ) * MIN( zsig , epsilon )
+            zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
+            zeta    = zehat / ( zucube + epsln)
+            zwst    = vonk * zustar(ji,jj) / ( ABS( 1.0 + rconc1 * zeta ) + epsln)
+            zwm     = zstabl * zwst + ( 1.0 - zstabl ) * zwm
+            zws     = zstabl * zwst + ( 1.0 - zstabl ) * zws
+
+            zkm1m  = zhbl(ji) * zwm * zsig * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
+            zkm1t  = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
+#if defined key_zdfddm
+            zkm1s  = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
+#endif                        
+            ! At first W level in the pipe (zdepw(ji,2)) (not always in the boundary layer ):
+            zsig    = MIN( zdepw(ji,2) / zhbl(ji) , 1.0 )
+            ztemp   = zstabl * zsig + ( 1.0 - zstabl ) * MIN( zsig , epsilon )
+            zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
+            zeta    = zehat / ( zucube + epsln )
+            zwst    = vonk * zustar(ji,jj) / ( ABS( 1.0 + rconc1 * zeta ) + epsln)
+            zws     = zstabl * zws + ( 1.0 - zstabl ) * zws
+            zwm     = zstabl * zws + ( 1.0 - zstabl ) * zwm
+
+            zkmpm(ji) = zhbl(ji) * zwm * zsig * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
+            zkmpt(ji) = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
+#if defined key_zdfddm
+            zkmps(ji) = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
+#endif  
+      
+            ! check if this point is in the boundary layer,else take interior viscosity/diffusivity:
+            zflag       = 0.5 + SIGN( 0.5, ( zhbl(ji) - zdepw(ji,2) ) )
+            zkmpm(ji) = zkmpm(ji) * zflag + ( 1.0 - zflag ) * zvisc(ji,2)
+            zkmpt(ji) = zkmpt(ji) * zflag + ( 1.0 - zflag ) * zdift(ji,2)
+#if defined key_zdfddm
+            zkmps(ji) = zkmps(ji) * zflag + ( 1.0 - zflag ) * zdifs(ji,2)
+#endif
+
+            ! Enhanced viscosity/diffusivity at zdepw(ji,2)
+            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1m + zdelta2 * zkmpm(ji)
+            zkmpm(ji) = ( 1.0 - zdelta ) * zvisc(ji,2) + zdelta * ztemp
+            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1t + zdelta2 * zkmpt(ji)
+            zkmpt(ji) = ( 1.0 - zdelta ) * zdift(ji,2) + zdelta * ztemp
+#if defined key_zdfddm
+            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1s + zdelta2 * zkmps(ji)
+            zkmps(ji) = ( 1.0 - zdelta ) * zdifs(ji,2) + zdelta * ztemp
+#endif            
+
+         END DO
+         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+         ! IV. Compute vertical eddy viscosity and diffusivity coefficients
+         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+         
+         DO jk  = 2, jkmax
+            
+            ! Compute turbulent velocity scales on the interfaces
+            ! --------------------------------------------------------
+            DO  ji = fs_2, fs_jpim1
+               zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * zatt1
+               zstabl   = 0.5 + SIGN( 0.5 , zbuofdep ) 
+               zbuofdep = zbuofdep + zstabl * epsln          
+               zsig    = fsdepw(ji,jj,jk) / zhbl(ji)
+               ztemp   = zstabl * zsig + ( 1. - zstabl ) * MIN( zsig , epsilon )
+               zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
+               zucube  = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)
+               zeta    = zehat / ( zucube + epsln )
+
+               IF( zehat > 0. ) THEN
+                  ! Stable case
+                  zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
+                  zwm  = zws
+               ELSE
+                  ! Unstable case
+#if defined key_kpplktb
+                  ! use lookup table
+                  zd     = zehat - dehatmin
+                  il     = INT( zd / dezehat )
+                  il     = MIN( il, nilktbm1 )
+                  il     = MAX( il, 1 )
+                  
+                  ud     = zustar(ji,jj) - ustmin
+                  jl     = INT( ud / deustar )
+                  jl     = MIN( jl, njlktbm1 )
+                  jl     = MAX( jl, 1 )
+                  
+                  zfrac  = zd / dezehat - FLOAT( il )  
+                  ufrac  = ud / deustar - FLOAT( jl )
+                  zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
+                  zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
+                  zwam   = ( 1. - zfrac ) * wmlktb(il,jl+1) + zfrac * wmlktb(il+1,jl+1)
+                  zwbm   = ( 1. - zfrac ) * wmlktb(il,jl  ) + zfrac * wmlktb(il+1,jl  )
+                  !
+                  zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
+                  zwm    = ( 1. - ufrac ) * zwbm + ufrac * zwam
+#else
+                  ! use analytical functions
+                  zconm  = 0.5 + SIGN( 0.5, ( rzetam - zeta) )
+                  zcons  = 0.5 + SIGN( 0.5, ( rzetas - zeta) )
+                  
+                  ! Momentum : zeta < rzetam (zconm = 1)
+                  ! Scalars  : zeta < rzetas (zcons = 1) 
+                  zwconm = zustar(ji,jj) * vonk * ( ( ABS( rconam - rconcm * zeta) )**pthird )
+                  zwcons = zustar(ji,jj) * vonk * ( ( ABS( rconas - rconcs * zeta) )**pthird )
+                  
+                  ! Momentum : rzetam <= zeta < 0 (zconm = 0)
+                  ! Scalars  : rzetas <= zeta < 0 (zcons = 0)	
+                  zwmun  = SQRT( ABS( 1.0 - rconc2 * zeta ) )
+                  zwsun  = vonk * zustar(ji,jj) * zwmun
+                  zwmun  = vonk * zustar(ji,jj) * SQRT(zwmun)
+                  !
+                  zwm    = zconm * zwconm + ( 1.0 - zconm ) * zwmun
+                  zws    = zcons * zwcons + ( 1.0 - zcons ) * zwsun
+                  
+#endif
+               ENDIF
+               
+               zblcm(ji,jk) = zhbl(ji) * zwm * zsig  * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
+               zblct(ji,jk) = zhbl(ji) * zws * zsig  * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
+#if defined key_zdfddm
+               zblcs(ji,jk) = zhbl(ji) * zws * zsig  * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
+#endif              
+               !  Compute Nonlocal transport term = ghats * <ws>o
+               ! ----------------------------------------------------
+               ghats(ji,jj,jk-1) = ( 1. - zstabl ) * rcg / ( zws * zhbl(ji) + epsln ) * tmask(ji,jj,jk)
+
+            END DO
+         END DO     
+         !  Combine interior and boundary layer coefficients and nonlocal term
+         ! -----------------------------------------------------------------------
+         DO jk = 2, jpkm1   
+            DO ji = fs_2, fs_jpim1
+               zflag = zmask(ji,jk) * zmask(ji,jk+1)
+               zviscos(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )         * avmu (ji,jj,jk) & ! interior viscosities
+                  &              +                        zflag   * zblcm(ji,jk    ) & ! boundary layer viscosities
+                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmpm(ji       )   ! viscosity enhancement at W_level near zhbl
+               
+               zviscos(ji,jj,jk) = zviscos(ji,jj,jk) * tmask(ji,jj,jk)   
+
+            
+               zdiffut(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )          * avt (ji,jj,jk) & ! interior diffusivities 
+                  &              +                        zflag   * zblct(ji,jk   ) & ! boundary layer diffusivities
+                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmpt(ji      )   ! diffusivity enhancement at W_level near zhbl
+                       
+               zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) * tmask(ji,jj,jk) 
+#if defined key_zdfddm
+               zdiffus(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )          * avs (ji,jj,jk) & ! interior diffusivities 
+                  &              +                        zflag   * zblcs(ji,jk   ) & ! boundary layer diffusivities
+                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmps(ji      )   ! diffusivity enhancement at W_level near zhbl
+                       
+               zdiffus(ji,jj,jk) = zdiffus(ji,jj,jk) * tmask(ji,jj,jk) 
+#endif               
+               ! Non local flux in the boundary layer only
+               ghats(ji,jj,jk-1) = zmask(ji,jk) * ghats(ji,jj,jk-1)
+
+            ENDDO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+
+      ! Lateral boundary conditions on zvicos and zdiffus  (sign unchanged)
+      CALL lbc_lnk( zviscos(:,:,:), 'U', 1. )  ; CALL lbc_lnk( zdiffut(:,:,:), 'W', 1. )  
+#if defined key_zdfddm  
+      CALL lbc_lnk( zdiffus(:,:,:), 'W', 1. ) 
+#endif
+
+      SELECT CASE ( nn_ave )
+         !
+         CASE ( 0 )             ! no viscosity and diffusivity smoothing
+
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     avmu(ji,jj,jk) = ( zviscos(ji,jj,jk) + zviscos(ji+1,jj,jk) ) &
+                        &  / MAX( 1., tmask(ji,jj,jk) + tmask (ji + 1,jj,jk) ) * umask(ji,jj,jk)
+                     
+                     avmv(ji,jj,jk) = ( zviscos(ji,jj,jk) + zviscos(ji,jj+1,jk) ) &
+                        &  / MAX( 1., tmask(ji,jj,jk) + tmask (ji,jj+1,jk) ) * vmask(ji,jj,jk)
+                     
+                     avt (ji,jj,jk) =  zdiffut(ji,jj,jk) * tmask(ji,jj,jk)  
+#if defined key_zdfddm     
+                     avs (ji,jj,jk) =  zdiffus(ji,jj,jk) * tmask(ji,jj,jk)  
+#endif
+                  END DO
+               END DO
+            END DO
+            
+         CASE ( 1 )                ! viscosity and diffusivity smoothing
+            !                      
+            !           ( 1/2  1  1/2 )              ( 1/2  1/2 )             ( 1/2  1  1/2 )
+            ! avt = 1/8 ( 1    2  1   )   avmu = 1/4 ( 1    1   )   avmv= 1/4 ( 1/2  1  1/2 )
+            !           ( 1/2  1  1/2 )              ( 1/2  1/2 )
+  
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+
+                     avmu(ji,jj,jk) = (      zviscos(ji  ,jj  ,jk) + zviscos(ji+1,jj  ,jk)   &
+                        &              +.5*( zviscos(ji  ,jj-1,jk) + zviscos(ji+1,jj-1,jk)   &
+                        &                   +zviscos(ji  ,jj+1,jk) + zviscos(ji+1,jj+1,jk) ) ) * eumean(ji,jj,jk)
+                     
+                     avmv(ji,jj,jk) = (      zviscos(ji  ,jj  ,jk) + zviscos(ji  ,jj+1,jk)   &
+                        &              +.5*( zviscos(ji-1,jj  ,jk) + zviscos(ji-1,jj+1,jk)   &
+                        &                   +zviscos(ji+1,jj  ,jk) + zviscos(ji+1,jj+1,jk) ) ) * evmean(ji,jj,jk)
+ 
+                     avt (ji,jj,jk) = ( .5*( zdiffut(ji-1,jj+1,jk) + zdiffut(ji-1,jj-1,jk)    &
+                        &                   +zdiffut(ji+1,jj+1,jk) + zdiffut(ji+1,jj-1,jk) )  &
+                        &              +1.*( zdiffut(ji-1,jj  ,jk) + zdiffut(ji  ,jj+1,jk)    &
+                        &                   +zdiffut(ji  ,jj-1,jk) + zdiffut(ji+1,jj  ,jk) )  &
+                        &              +2.*  zdiffut(ji  ,jj  ,jk)                          ) * etmean(ji,jj,jk)
+#if defined key_zdfddm   
+                     avs (ji,jj,jk) = ( .5*( zdiffus(ji-1,jj+1,jk) + zdiffus(ji-1,jj-1,jk)    &
+                        &                   +zdiffus(ji+1,jj+1,jk) + zdiffus(ji+1,jj-1,jk) )  &
+                        &              +1.*( zdiffus(ji-1,jj  ,jk) + zdiffus(ji  ,jj+1,jk)    &
+                        &                   +zdiffus(ji  ,jj-1,jk) + zdiffus(ji+1,jj  ,jk) )  &
+                        &              +2.*  zdiffus(ji  ,jj  ,jk)                          ) * etmean(ji,jj,jk)  
+#endif                
+                  END DO
+               END DO
+            END DO
+         
+         END SELECT
+
+         DO jk = 2, jpkm1                       ! vertical slab
+            !
+            !  Minimum value on the eddy diffusivity
+            ! ----------------------------------------
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avt(ji,jj,jk) = MAX( avt(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk)
+#if defined key_zdfddm  
+                  avs(ji,jj,jk) = MAX( avs(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk)
+#endif
+               END DO
+            END DO
+
+            !
+            ! Minimum value on the eddy viscosity
+            ! ----------------------------------------
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  avmu(ji,jj,jk) = MAX( avmu(ji,jj,jk), avmb(jk) ) * umask(ji,jj,jk)
+                  avmv(ji,jj,jk) = MAX( avmv(ji,jj,jk), avmb(jk) ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+            !
+         END DO
+
+         ! Lateral boundary conditions on avt  (sign unchanged)
+         CALL lbc_lnk( hkpp(:,:), 'T', 1. )
+
+         ! Lateral boundary conditions on avt  (sign unchanged)
+         CALL lbc_lnk( avt(:,:,:), 'W', 1. )
+#if defined key_zdfddm  
+         CALL lbc_lnk( avs(:,:,:), 'W', 1. )  
+#endif
+         ! Lateral boundary conditions (avmu,avmv) (U- and V- points, sign unchanged)
+         CALL lbc_lnk( avmu(:,:,:), 'U', 1. )   ;    CALL lbc_lnk( avmv(:,:,:), 'V', 1. )  
+ 
+         IF(ln_ctl) THEN
+#if defined key_zdfddm
+            CALL prt_ctl(tab3d_1=avt , clinfo1=' kpp - t: ', tab3d_2=avs , clinfo2=' s: ', ovlap=1, kdim=jpk)
+#else
+            CALL prt_ctl(tab3d_1=avt , clinfo1=' kpp - t: ', ovlap=1, kdim=jpk)
+#endif
+            CALL prt_ctl(tab3d_1=avmu, clinfo1=' kpp - u: ', mask1=umask,  &
+               &         tab3d_2=avmv, clinfo2=      ' v: ', mask2=vmask, ovlap=1, kdim=jpk)
+         ENDIF
+
+   END SUBROUTINE zdf_kpp
+
+
+   SUBROUTINE tra_kpp( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_kpp  ***
+      !!
+      !! ** Purpose :   compute and add to the tracer trend the non-local
+      !!      tracer flux
+      !!
+      !! ** Method  :   ???
+      !!
+      !! history :
+      !!     9.0  ! 05-11 (G. Madec)  Original code
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce, ONLY :    ztrdt => ua,       & ! use ua as 3D workspace
+                         ztrds => va          ! use va as 3D workspace
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      INTEGER :: ji, jj, jk
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_kpp : KPP non-local tracer fluxes'
+         IF(lwp) WRITE(numout,*) '~~~~~~~   '
+      ENDIF
+
+
+      ! Save ta and sa trends
+      IF( l_trdtra )   THEN
+         ztrdt(:,:,:) = ta(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:)
+      ENDIF
+
+      ! add non-local temperature and salinity flux ( in convective case only)
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ta(ji,jj,jk) =  ta(ji,jj,jk)                           &
+                  &         - ( ghats(ji,jj,jk  ) * avt(ji,jj,jk  )   &
+                  &           - ghats(ji,jj,jk+1) * avt(ji,jj,jk+1) ) * wt0(ji,jj) / fse3t(ji,jj,jk)
+               sa(ji,jj,jk) = sa(ji,jj,jk)                              &
+                  &         - ( ghats(ji,jj,jk  ) * fsavs(ji,jj,jk  )   &
+                  &           - ghats(ji,jj,jk+1) * fsavs(ji,jj,jk+1) ) * ws0(ji,jj) / fse3t(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! save the non-local tracer flux trends for diagnostic
+      IF( l_trdtra )   THEN
+         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
+         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
+!!bug gm jpttdzdf ==> jpttkpp
+         CALL trd_mod(ztrdt, ztrds, jptra_trd_zdf, 'TRA', kt)
+      ENDIF
+
+      IF(ln_ctl) THEN  
+         CALL prt_ctl( tab3d_1=ta, clinfo1=' kpp  - Ta: ', mask1=tmask,   &
+         &             tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      ENDIF
+
+   END SUBROUTINE tra_kpp
+
+
+   SUBROUTINE zdf_kpp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_kpp_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
+      !!      viscosity when using a kpp turbulent closure scheme
+      !!
+      !! ** Method  :   Read the namkpp namelist and check the parameters
+      !!      called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namlist namkpp
+      !!
+      !!
+      !! history :
+      !!     8.1  ! 00-02 (J. Chanut) KPP Mixing
+      !!     9.0  ! 05-01 (C. Ethe) F90 : free form
+      !!----------------------------------------------------------------------
+      !! * local declarations
+
+      INTEGER    ::   &
+         ji, jj, jk             ! dummy loop indices
+      
+#if ! defined key_kppcustom
+      INTEGER    ::   &
+         jm                       ! dummy loop indices     
+      REAL(wp)   ::              & !!! tempory scalars
+         zref, zdist
+#endif
+
+#if defined key_kpplktb
+      REAL(wp)   ::              & !!! tempory scalars
+         zustar,    &
+         zucube, zustvk,         & 
+         zeta, zehat
+#endif
+      REAL(wp)   ::             & !!! tempory scalars
+         zhbf
+      LOGICAL ::                &
+         ll_kppcustom,          &  ! 1st ocean level taken as surface layer
+         ll_kpplktb                ! Lookup table for turbul. velocity scales 
+      !!
+      NAMELIST/namzdf_kpp/ ln_kpprimix, rn_difmiw, rn_difsiw, rn_riinfty, rn_difri, rn_bvsqcon, rn_difcon, nn_ave
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               ! Read Namelist namkpp : K-Profile Parameterisation
+      READ   ( numnam, namzdf_kpp )
+
+      IF(lwp) THEN                    ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_kpp_init : K-Profile Parameterisation'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_kpp : set tke mixing parameters'
+         WRITE(numout,*) '     Shear instability mixing                      ln_kpprimix = ', ln_kpprimix
+         WRITE(numout,*) '     max. internal wave viscosity                  rn_difmiw   = ', rn_difmiw
+         WRITE(numout,*) '     max. internal wave diffusivity                rn_difsiw   = ', rn_difsiw
+         WRITE(numout,*) '     Richardson Number limit for shear instability rn_riinfty  = ', rn_riinfty
+         WRITE(numout,*) '     max. shear mixing at Rig = 0                  rn_difri    = ', rn_difri
+         WRITE(numout,*) '     Brunt-Vaisala squared for max. convection     rn_bvsqcon  = ', rn_bvsqcon
+         WRITE(numout,*) '     max. mix. in interior convec.                 rn_difcon   = ', rn_difcon
+         WRITE(numout,*) '     horizontal average flag                       nn_ave      = ', nn_ave
+      ENDIF
+
+      ll_kppcustom = .FALSE.
+      ll_kpplktb   = .FALSE.
+
+#if defined key_kppcustom
+      ll_kppcustom = .TRUE.
+#endif
+#if defined key_kpplktb
+      ll_kpplktb   = .TRUE.
+#endif
+      IF(lwp) THEN
+         WRITE(numout,*) '     Lookup table for turbul. velocity scales ll_kpplktb   = ', ll_kpplktb
+         WRITE(numout,*) '     1st ocean level taken as surface layer   ll_kppcustom = ', ll_kppcustom
+      ENDIF
+      
+      IF( lk_zdfddm) THEN
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) '    Double diffusion mixing on temperature and salinity '
+            WRITE(numout,*) '    CAUTION : done in routine zdfkpp, not in routine zdfddm '
+         ENDIF
+      ENDIF
+      
+         
+
+      !set constants not in namelist
+      !-----------------------------
+      Vtc  = rconcv * SQRT( 0.2 / ( rconcs * epsilon ) ) / ( vonk * vonk * Ricr )
+      rcg  = rcstar * vonk * ( rconcs * vonk * epsilon )**pthird
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '     Constant value for unreso. turbul. velocity shear Vtc = ', Vtc
+         WRITE(numout,*) '     Non-dimensional coef. for nonlocal transport      rcg = ', rcg
+       ENDIF
+
+      ! ratt is the attenuation coefficient for solar flux
+      ! Should be different is s_coordinate
+      DO jk = 1, jpk
+         zhbf     = - fsdept(1,1,jk) * hbf
+         ratt(jk) = 1.0 - ( rabs * EXP( zhbf / xsi1 ) + ( 1.0 - rabs ) * EXP( zhbf / xsi2 ) )        
+      ENDDO
+
+      ! Horizontal average : initialization of weighting arrays 
+      ! -------------------
+      
+      SELECT CASE ( nn_ave )
+
+      CASE ( 0 )                ! no horizontal average
+         IF(lwp) WRITE(numout,*) '          no horizontal average on avt, avmu, avmv'
+         IF(lwp) WRITE(numout,*) '          only in very high horizontal resolution !'
+         ! weighting mean arrays etmean, eumean and evmean
+         !           ( 1  1 )                                          ( 1 )
+         ! avt = 1/4 ( 1  1 )     avmu = 1/2 ( 1  1 )       avmv=  1/2 ( 1 )
+         !                          
+         etmean(:,:,:) = 0.e0
+         eumean(:,:,:) = 0.e0
+         evmean(:,:,:) = 0.e0
+         
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1   ! vector opt.
+                  etmean(ji,jj,jk) = tmask(ji,jj,jk)                     &
+                  &  / MAX( 1.,  umask(ji-1,jj  ,jk) + umask(ji,jj,jk)   &
+                  &            + vmask(ji  ,jj-1,jk) + vmask(ji,jj,jk)  )
+                  
+                  eumean(ji,jj,jk) = umask(ji,jj,jk)                     &
+                  &  / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji+1,jj  ,jk)  )
+
+                  evmean(ji,jj,jk) = vmask(ji,jj,jk)                     &
+                  &  / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji  ,jj+1,jk)  )
+               END DO
+            END DO
+         END DO
+
+      CASE ( 1 )                ! horizontal average 
+         IF(lwp) WRITE(numout,*) '          horizontal average on avt, avmu, avmv'
+         ! weighting mean arrays etmean, eumean and evmean
+         !           ( 1/2  1  1/2 )              ( 1/2  1/2 )             ( 1/2  1  1/2 )
+         ! avt = 1/8 ( 1    2  1   )   avmu = 1/4 ( 1    1   )   avmv= 1/4 ( 1/2  1  1/2 )
+         !           ( 1/2  1  1/2 )              ( 1/2  1/2 )
+         etmean(:,:,:) = 0.e0
+         eumean(:,:,:) = 0.e0
+         evmean(:,:,:) = 0.e0
+         
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  etmean(ji,jj,jk) = tmask(ji, jj,jk)                           &
+                     & / MAX( 1., 2.* tmask(ji,jj,jk)                           &
+                     &      +.5 * ( tmask(ji-1,jj+1,jk) + tmask(ji-1,jj-1,jk)   &
+                     &             +tmask(ji+1,jj+1,jk) + tmask(ji+1,jj-1,jk) ) &
+                     &      +1. * ( tmask(ji-1,jj  ,jk) + tmask(ji  ,jj+1,jk)   &
+                     &             +tmask(ji  ,jj-1,jk) + tmask(ji+1,jj  ,jk) ) )
+                  
+                  eumean(ji,jj,jk) = umask(ji,jj,jk)                        &
+                     &  / MAX( 1.,   tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk)   &
+                     &       +.5 * ( tmask(ji,jj-1,jk) + tmask(ji+1,jj-1,jk)   &
+                     &              +tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) )  )
+                  
+                  evmean(ji,jj,jk) = vmask(ji,jj,jk)                        &
+                     &  / MAX( 1.,   tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
+                     &       +.5 * ( tmask(ji-1,jj,jk) + tmask(ji-1,jj+1,jk)   &
+                     &              +tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk) )  )
+               END DO
+            END DO
+         END DO
+
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for nn_ave = ', nn_ave
+         CALL ctl_stop( ctmp1 )
+
+      END SELECT
+ 
+      ! Initialization of vertical eddy coef. to the background value
+      ! -------------------------------------------------------------
+      DO jk = 1, jpk
+         avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
+         avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
+         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
+      END DO
+
+      ! zero the surface flux for non local term and kpp mixed layer depth
+      ! ------------------------------------------------------------------
+      ghats(:,:,:) = 0.
+      wt0  (:,:  ) = 0.
+      ws0  (:,:  ) = 0.
+      hkpp (:,:  ) = 0. ! just a diagnostic (not essential)
+
+#if ! defined key_kppcustom
+      ! compute arrays (del, wz) for reference mean values 
+      ! (increase speed for vectorization key_kppcustom not defined)
+      del(1:jpk, 1:jpk) = 0.
+      DO jk = 1, jpk
+         zref = epsilon * fsdept(1,1,jk)    
+         DO jm = 1 , jpk
+            zdist = zref - fsdepw(1,1,jm)   
+            IF( zdist > 0.  ) THEN
+               del(jk,jm) = MIN( zdist, fse3t(1,1,jm) ) / zref   
+            ELSE
+               del(jk,jm) = 0.
+            ENDIF
+         ENDDO
+      ENDDO
+#endif
+
+#if defined key_kpplktb
+      ! build lookup table for turbulent velocity scales
+      dezehat = ( dehatmax - dehatmin ) / nilktbm1
+      deustar = ( ustmax   - ustmin   ) / njlktbm1
+ 
+      DO jj = 1, njlktb
+         zustar = ( jj - 1) * deustar + ustmin
+         zustvk = vonk * zustar 
+         zucube = zustar * zustar * zustar 
+         DO ji = 1 , nilktb
+            zehat = ( ji - 1 ) * dezehat + dehatmin
+            zeta   = zehat / ( zucube + epsln )
+            IF( zehat >= 0 ) THEN             ! Stable case
+               wmlktb(ji,jj) = zustvk / ABS( 1.0 + rconc1 * zeta + epsln )                        
+               wslktb(ji,jj) = wmlktb(ji,jj)
+            ELSE                                ! Unstable case 
+               IF( zeta > rzetam ) THEN
+                  wmlktb(ji,jj) = zustvk * ABS( 1.0    - rconc2 * zeta )**pfourth
+               ELSE
+                  wmlktb(ji,jj) = zustvk * ABS( rconam - rconcm * zeta )**pthird
+               ENDIF
+               
+               IF( zeta > rzetas ) THEN
+                  wslktb(ji,jj) = zustvk * SQRT( ABS( 1.0 - rconc2 * zeta ) )
+               ELSE
+                  wslktb(ji,jj) = zustvk * ABS( rconas - rconcs * zeta )**pthird
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+#endif
+   END SUBROUTINE zdf_kpp_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                        NO KPP scheme
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfkpp = .FALSE.   !: KPP flag
+CONTAINS
+   SUBROUTINE zdf_kpp( kt )          ! Empty routine
+      WRITE(*,*) 'zdf_kpp: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_kpp
+   SUBROUTINE tra_kpp( kt )          ! Empty routine
+      WRITE(*,*) 'tra_kpp: You should not have seen this print! error?', kt
+   END SUBROUTINE tra_kpp
+#endif
+
+   !!======================================================================
+END MODULE zdfkpp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 1844)
@@ -0,0 +1,99 @@
+MODULE zdfmxl
+   !!======================================================================
+   !!                       ***  MODULE  zdfmxl  ***
+   !! Ocean physics: mixed layer depth 
+   !!======================================================================
+   !! History :  1.0  ! 2003-08  (G. Madec)  original code
+   !!            3.2  ! 2009-07  (S. Masson, G. Madec)  IOM + merge of DO-loop
+   !!----------------------------------------------------------------------
+   !!   zdf_mxl      : Compute the turbocline and mixed layer depths.
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_mxl    ! called by step.F90
+
+   INTEGER , PUBLIC, DIMENSION(jpi,jpj) ::   nmln    !: number of level in the mixed layer (used by TOP)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmld    !: mixing layer depth (turbocline)      [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   hmlpt   !: mixed layer depth at t-points        [m]
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_mxl( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdfmxl  ***
+      !!                   
+      !! ** Purpose :   Compute the turbocline depth and the mixed layer depth
+      !!              with density criteria.
+      !!
+      !! ** Method  :   The mixed layer depth is the shallowest W depth with 
+      !!      the density of the corresponding T point (just bellow) bellow a
+      !!      given value defined locally as rho(10m) + zrho_c
+      !!               The turbocline depth is the depth at which the vertical
+      !!      eddy diffusivity coefficient (resulting from the vertical physics
+      !!      alone, not the isopycnal part, see trazdf.F) fall below a given
+      !!      value defined locally (avt_c here taken equal to 5 cm/s2)
+      !!
+      !! ** Action  :   nmln, hmld, hmlp, hmlpt
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !!
+      INTEGER                     ::   ji, jj, jk          ! dummy loop indices
+      INTEGER                     ::   iikn, iiki          ! temporary integer within a do loop
+      INTEGER, DIMENSION(jpi,jpj) ::   imld                ! temporary workspace
+      REAL(wp)                    ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth
+      REAL(wp)                    ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      ! w-level of the mixing and mixed layers
+      nmln(:,:) = mbathy(:,:)          ! Initialization to the number of w ocean point mbathy
+      imld(:,:) = mbathy(:,:)
+      DO jk = jpkm1, nlb10, -1         ! from the bottom to nlb10
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + zrho_c )   nmln(ji,jj) = jk      ! Mixed layer
+               IF( avt (ji,jj,jk) < zavt_c                     )   imld(ji,jj) = jk      ! Turbocline 
+            END DO
+         END DO
+      END DO
+      ! depth of the mixing and mixed layers
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            iiki = imld(ji,jj)
+            iikn = nmln(ji,jj)
+            hmld (ji,jj) = fsdepw(ji,jj,iiki  ) * tmask(ji,jj,1)    ! Turbocline depth 
+            hmlp (ji,jj) = fsdepw(ji,jj,iikn  ) * tmask(ji,jj,1)    ! Mixed layer depth
+            hmlpt(ji,jj) = fsdept(ji,jj,iikn-1)                     ! depth of the last T-point inside the mixed layer
+         END DO
+      END DO
+      CALL iom_put( "mldr10_1", hmlp )   ! mixed layer depth
+      CALL iom_put( "mldkz5"  , hmld )   ! turbocline depth
+      
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 )
+      !
+   END SUBROUTINE zdf_mxl
+
+   !!======================================================================
+END MODULE zdfmxl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfric.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 1844)
@@ -0,0 +1,201 @@
+MODULE zdfric
+   !!======================================================================
+   !!                       ***  MODULE  zdfric  ***
+   !! Ocean physics:  vertical mixing coefficient compute from the local
+   !!                 Richardson number dependent formulation
+   !!======================================================================
+   !! History :  OPA  ! 1987-09  (P. Andrich)  Original code
+   !!            4.0  ! 1991-11  (G. Madec)
+   !!            7.0  ! 1996-01  (G. Madec)  complet rewriting of multitasking suppression of common work arrays
+   !!            8.0  ! 1997-06 (G. Madec)  complete rewriting of zdfmix
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_zdfric   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdfric'                                             Kz = f(Ri)
+   !!----------------------------------------------------------------------
+   !!   zdf_ric      : update momentum and tracer Kz from the Richardson
+   !!                  number computation
+   !!   zdf_ric_init : initialization, namelist read, & parameters control
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_ric    ! called by step.F90
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfric = .TRUE.   !: Richardson vertical mixing flag
+
+   !                                    !!* Namelist namzdf_ric : Richardson number dependent Kz *
+   INTEGER  ::   nn_ric   = 2            ! coefficient of the parameterization
+   REAL(wp) ::   rn_avmri = 100.e-4_wp   ! maximum value of the vertical eddy viscosity
+   REAL(wp) ::   rn_alp   =   5._wp      ! coefficient of the parameterization
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   tmric                    ! coef. for the horizontal mean at t-point
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE zdf_ric( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE zdfric  ***
+      !!                    
+      !! ** Purpose :   Compute the before eddy viscosity and diffusivity as
+      !!              a function of the local richardson number.
+      !!
+      !! ** Method  :   Local richardson number dependent formulation of the 
+      !!              vertical eddy viscosity and diffusivity coefficients. 
+      !!                The eddy coefficients are given by:
+      !!                    avm = avm0 + avmb
+      !!                    avt = avm0 / (1 + rn_alp*ri)
+      !!              with ri  = N^2 / dz(u)**2
+      !!                       = e3w**2 * rn2/[ mi( dk(ub) )+mj( dk(vb) ) ]
+      !!                   avm0= rn_avmri / (1 + rn_alp*ri)**nn_ric
+      !!      Where ri is the before local Richardson number,
+      !!            rn_avmri is the maximum value reaches by avm and avt 
+      !!            avmb and avtb are the background (or minimum) values
+      !!            and rn_alp, nn_ric are adjustable parameters.
+      !!      Typical values used are : avm0=1.e-2 m2/s, avmb=1.e-6 m2/s
+      !!      avtb=1.e-7 m2/s, rn_alp=5. and nn_ric=2.
+      !!      a numerical threshold is impose on the vertical shear (1.e-20)
+      !!        N.B. the mask are required for implicit scheme, and surface
+      !!      and bottom value already set in zdfini.F90
+      !!
+      !! References : Pacanowski & Philander 1981, JPO, 1441-1451.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step indexocean time step
+      !!
+      INTEGER  ::   ji, jj, jk               ! dummy loop indices
+      REAL(wp) ::   zcoef, zdku, zdkv, zri, z05alp     ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwx ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000  ) CALL zdf_ric_init            ! Initialization (first time-step only)
+
+      !                                                ! ===============
+      DO jk = 2, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! Richardson number (put in zwx(ji,jj))
+         ! -----------------
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zcoef = 0.5 / fse3w(ji,jj,jk)
+               !                                            ! shear of horizontal velocity
+               zdku = zcoef * (  ub(ji-1,jj,jk-1) + ub(ji,jj,jk-1)   &
+                  &             -ub(ji-1,jj,jk  ) - ub(ji,jj,jk  )  )
+               zdkv = zcoef * (  vb(ji,jj-1,jk-1) + vb(ji,jj,jk-1)   &
+                  &             -vb(ji,jj-1,jk  ) - vb(ji,jj,jk  )  )
+               !                                            ! richardson number (minimum value set to zero)
+               zri = rn2(ji,jj,jk) / ( zdku*zdku + zdkv*zdkv + 1.e-20 )
+               zwx(ji,jj) = MAX( zri, 0.e0 )
+            END DO
+         END DO
+         CALL lbc_lnk( zwx, 'W', 1. )                       ! Boundary condition   (sign unchanged)
+
+
+         ! Vertical eddy viscosity and diffusivity coefficients
+         ! -------------------------------------------------------
+         z05alp = 0.5 * rn_alp
+         DO jj = 1, jpjm1                                   ! Eddy viscosity coefficients (avm)
+            DO ji = 1, jpim1
+               avmu(ji,jj,jk) = umask(ji,jj,jk)   &
+                  &           * rn_avmri / ( 1. + z05alp*( zwx(ji+1,jj)+zwx(ji,jj) ) )**nn_ric
+               avmv(ji,jj,jk) = vmask(ji,jj,jk)   &
+                  &           * rn_avmri / ( 1. + z05alp*( zwx(ji,jj+1)+zwx(ji,jj) ) )**nn_ric
+            END DO
+         END DO
+         DO jj = 2, jpjm1                                   ! Eddy diffusivity coefficients (avt)
+            DO ji = 2, jpim1
+               avt(ji,jj,jk) = tmric(ji,jj,jk) / ( 1. + rn_alp * zwx(ji,jj) )   &
+                  &          * (  avmu(ji,jj,jk) + avmu(ji-1, jj ,jk)        &
+                  &             + avmv(ji,jj,jk) + avmv( ji ,jj-1,jk)  )     &
+                  &          + avtb(jk) * tmask(ji,jj,jk)
+               !                                            ! Add the background coefficient on eddy viscosity
+               avmu(ji,jj,jk) = avmu(ji,jj,jk) + avmb(jk) * umask(ji,jj,jk)
+               avmv(ji,jj,jk) = avmv(ji,jj,jk) + avmb(jk) * vmask(ji,jj,jk)
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      !
+      CALL lbc_lnk( avt , 'W', 1. )                         ! Boundary conditions   (unchanged sign)
+      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )
+      !
+   END SUBROUTINE zdf_ric
+
+
+   SUBROUTINE zdf_ric_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE zdfbfr_init  ***
+      !!                    
+      !! ** Purpose :   Initialization of the vertical eddy diffusivity and
+      !!      viscosity coef. for the Richardson number dependent formulation.
+      !!
+      !! ** Method  :   Read the namzdf_ric namelist and check the parameter values
+      !!
+      !! ** input   :   Namelist namzdf_ric
+      !!
+      !! ** Action  :   increase by 1 the nstop flag is setting problem encounter
+      !!----------------------------------------------------------------------
+      INTEGER :: ji, jj, jk        ! dummy loop indices
+      !!
+      NAMELIST/namzdf_ric/ rn_avmri, rn_alp, nn_ric
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam )               ! Read Namelist namzdf_ric : richardson number dependent Kz
+      READ  ( numnam, namzdf_ric )
+      !
+      IF(lwp) THEN                   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_ric : Ri depend vertical mixing scheme'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_ric : set Kz(Ri) parameters'
+         WRITE(numout,*) '      maximum vertical viscosity     rn_avmri = ', rn_avmri
+         WRITE(numout,*) '      coefficient                    rn_alp   = ', rn_alp
+         WRITE(numout,*) '      coefficient                    nn_ric   = ', nn_ric
+      ENDIF
+      !
+      DO jk = 1, jpk                 ! weighting mean array tmric for 4 T-points which accounts for coastal boundary conditions.
+         DO jj = 2, jpj              
+            DO ji = 2, jpi
+               tmric(ji,jj,jk) =  tmask(ji,jj,jk)                                  &
+                  &            / MAX( 1.,  umask(ji-1,jj  ,jk) + umask(ji,jj,jk)   &
+                  &                      + vmask(ji  ,jj-1,jk) + vmask(ji,jj,jk)  )
+            END DO
+         END DO
+      END DO
+      tmric(:,1,:) = 0.e0
+      !
+      DO jk = 1, jpk                 ! Initialization of vertical eddy coef. to the background value
+         avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
+         avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
+         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
+      END DO
+      !
+   END SUBROUTINE zdf_ric_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :              NO Richardson dependent vertical mixing
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfric = .FALSE.   !: Richardson mixing flag
+CONTAINS
+   SUBROUTINE zdf_ric( kt )        ! Dummy routine
+      WRITE(*,*) 'zdf_ric: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_ric
+#endif
+
+   !!======================================================================
+END MODULE zdfric
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 1844)
@@ -0,0 +1,837 @@
+MODULE zdftke
+   !!======================================================================
+   !!                       ***  MODULE  zdftke  ***
+   !! Ocean physics:  vertical mixing coefficient computed from the tke 
+   !!                 turbulent closure parameterization
+   !!=====================================================================
+   !! History :  OPA  !  1991-03  (b. blanke)  Original code
+   !!            7.0  !  1991-11  (G. Madec)   bug fix
+   !!            7.1  !  1992-10  (G. Madec)   new mixing length and eav
+   !!            7.2  !  1993-03  (M. Guyon)   symetrical conditions
+   !!            7.3  !  1994-08  (G. Madec, M. Imbard)  nn_pdl flag
+   !!            7.5  !  1996-01  (G. Madec)   s-coordinates
+   !!            8.0  !  1997-07  (G. Madec)   lbc
+   !!            8.1  !  1999-01  (E. Stretta) new option for the mixing length
+   !!  NEMO      1.0  !  2002-06  (G. Madec) add tke_init routine
+   !!             -   !  2004-10  (C. Ethe )  1D configuration
+   !!            2.0  !  2006-07  (S. Masson)  distributed restart using iom
+   !!            3.0  !  2008-05  (C. Ethe,  G.Madec) : update TKE physics:
+   !!                 !           - tke penetration (wind steering)
+   !!                 !           - suface condition for tke & mixing length
+   !!                 !           - Langmuir cells
+   !!             -   !  2008-05  (J.-M. Molines, G. Madec)  2D form of avtb
+   !!             -   !  2008-06  (G. Madec)  style + DOCTOR name for namelist parameters
+   !!             -   !  2008-12  (G. Reffray) stable discretization of the production term 
+   !!            3.2  !  2009-06  (G. Madec, S. Masson) TKE restart compatible with key_cpl 
+   !!                 !                                + cleaning of the parameters + bugs correction
+   !!----------------------------------------------------------------------
+#if defined key_zdftke   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdftke'                                   TKE vertical physics
+   !!----------------------------------------------------------------------
+   !!   zdf_tke       : update momentum and tracer Kz from a tke scheme
+   !!   tke_tke       : tke time stepping: update tke at now time step (en)
+   !!   tke_avn       : compute mixing length scale and deduce avm and avt
+   !!   tke_init      : initialization, namelist read, and parameters control
+   !!   tke_rst       : read/write tke restart in ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers 
+   USE dom_oce        ! ocean space and time domain
+   USE domvvl         ! ocean space and time domain : variable volume layer
+   USE zdf_oce        ! ocean vertical physics
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE phycst         ! physical constants
+   USE zdfmxl         ! mixed layer
+   USE restart        ! only for lrst_oce
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O manager library
+   USE zdfbfr          ! bottom friction
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_tke    ! routine called in step module
+   PUBLIC   tke_rst    ! routine called in step module
+
+   LOGICAL , PUBLIC, PARAMETER              ::   lk_zdftke = .TRUE.  !: TKE vertical mixing flag
+
+#if defined key_c1d
+   !                                                                !!* 1D cfg only *
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e_dis, e_mix        !: dissipation and mixing turbulent lengh scales
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e_pdl, e_ric        !: prandl and local Richardson numbers
+#endif
+
+   !                                       !!! ** Namelist  namzdf_tke  **
+   LOGICAL  ::   ln_mxl0   = .FALSE.         ! mixing length scale surface value as function of wind stress or not
+   INTEGER  ::   nn_mxl    =  2              ! type of mixing length (=0/1/2/3)
+   REAL(wp) ::   rn_lmin0  = 0.4_wp          ! surface  min value of mixing length   [m]
+   REAL(wp) ::   rn_lmin   = 0.1_wp          ! interior min value of mixing length   [m]
+   INTEGER  ::   nn_pdl    =  1              ! Prandtl number or not (ratio avt/avm) (=0/1)
+   REAL(wp) ::   rn_ediff  = 0.1_wp          ! coefficient for avt: avt=rn_ediff*mxl*sqrt(e)
+   REAL(wp) ::   rn_ediss  = 0.7_wp          ! coefficient of the Kolmogoroff dissipation 
+   REAL(wp) ::   rn_ebb    = 3.75_wp         ! coefficient of the surface input of tke
+   REAL(wp) ::   rn_emin   = 0.7071e-6_wp    ! minimum value of tke           [m2/s2]
+   REAL(wp) ::   rn_emin0  = 1.e-4_wp        ! surface minimum value of tke   [m2/s2]
+   REAL(wp) ::   rn_bshear = 1.e-20          ! background shear (>0)
+   INTEGER  ::   nn_etau   = 0               ! type of depth penetration of surface tke (=0/1/2)
+   INTEGER  ::   nn_htau   = 0               ! type of tke profile of penetration (=0/1)
+   REAL(wp) ::   rn_efr    = 1.0_wp          ! fraction of TKE surface value which penetrates in the ocean
+   REAL(wp) ::   rn_addhft = 0.0_wp          ! add offset   applied to HF tau
+   REAL(wp) ::   rn_sclhft = 1.0_wp          ! scale factor applied to HF tau
+   LOGICAL  ::   ln_lc     = .FALSE.         ! Langmuir cells (LC) as a source term of TKE or not
+   REAL(wp) ::   rn_lc     = 0.15_wp         ! coef to compute vertical velocity of Langmuir cells
+
+   REAL(wp) ::   ri_cri   ! critic Richardson number (deduced from rn_ediff and rn_ediss values)
+
+   REAL(wp), DIMENSION(jpi,jpj)     ::   htau      ! depth of tke penetration (nn_htau)
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   en        ! now turbulent kinetic energy   [m2/s2]
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   dissl     ! now mixing lenght of dissipation
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id: zdftke2.F90 1201 2008-09-24 13:24:21Z rblod $
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_tke( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zdf_tke  ***
+      !!
+      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity
+      !!              coefficients using a turbulent closure scheme (TKE).
+      !!
+      !! ** Method  :   The time evolution of the turbulent kinetic energy (tke)
+      !!              is computed from a prognostic equation :
+      !!         d(en)/dt = avm (d(u)/dz)**2             ! shear production
+      !!                  + d( avm d(en)/dz )/dz         ! diffusion of tke
+      !!                  + avt N^2                      ! stratif. destruc.
+      !!                  - rn_ediss / emxl en**(2/3)    ! Kolmogoroff dissipation
+      !!      with the boundary conditions:
+      !!         surface: en = max( rn_emin0, rn_ebb * taum )
+      !!         bottom : en = rn_emin
+      !!      The associated critical Richardson number is: ri_cri = 2/(2+rn_ediss/rn_ediff) 
+      !!
+      !!        The now Turbulent kinetic energy is computed using the following 
+      !!      time stepping: implicit for vertical diffusion term, linearized semi
+      !!      implicit for kolmogoroff dissipation term, and explicit forward for 
+      !!      both buoyancy and shear production terms. Therefore a tridiagonal 
+      !!      linear system is solved. Note that buoyancy and shear terms are
+      !!      discretized in a energy conserving form (Bruchard 2002).
+      !!
+      !!        The dissipative and mixing length scale are computed from en and
+      !!      the stratification (see tke_avn)
+      !!
+      !!        The now vertical eddy vicosity and diffusivity coefficients are
+      !!      given by: 
+      !!              avm = max( avtb, rn_ediff * zmxlm * en^1/2 )
+      !!              avt = max( avmb, pdl * avm                 )  
+      !!              eav = max( avmb, avm )
+      !!      where pdl, the inverse of the Prandtl number is 1 if nn_pdl=0 and
+      !!      given by an empirical funtion of the localRichardson number if nn_pdl=1 
+      !!
+      !! ** Action  :   compute en (now turbulent kinetic energy)
+      !!                update avt, avmu, avmv (before vertical eddy coef.)
+      !!
+      !! References : Gaspar et al., JGR, 1990,
+      !!              Blanke and Delecluse, JPO, 1991
+      !!              Mellor and Blumberg, JPO 2004
+      !!              Axell, JGR, 2002
+      !!              Bruchard OM 2002
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 )   CALL tke_init     ! initialisation 
+                           !
+                           CALL tke_tke      ! now tke (en)
+                           !
+                           CALL tke_avn      ! now avt, avm, avmu, avmv
+      !
+   END SUBROUTINE zdf_tke
+
+
+   SUBROUTINE tke_tke
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tke_tke  ***
+      !!
+      !! ** Purpose :   Compute the now Turbulente Kinetic Energy (TKE)
+      !!
+      !! ** Method  : - TKE surface boundary condition
+      !!              - source term due to Langmuir cells (ln_lc=T)
+      !!              - source term due to shear (saved in avmu, avmv arrays)
+      !!              - Now TKE : resolution of the TKE equation by inverting
+      !!                a tridiagonal linear system by a "methode de chasse"
+      !!              - increase TKE due to surface and internal wave breaking
+      !!
+      !! ** Action  : - en : now turbulent kinetic energy)
+      !!              - avmu, avmv : production of TKE by shear at u and v-points
+      !!                (= Kz dz[Ub] * dz[Un] )
+      !! ---------------------------------------------------------------------
+      USE oce,   zdiag  =>   ua   ! use ua as workspace
+      USE oce,   zd_up  =>   va   ! use va as workspace
+      USE oce,   zd_lw  =>   ta   ! use ta as workspace
+      !!
+      INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
+!!$      INTEGER  ::   ikbu, ikbv, ikbum1, ikbvm1      ! temporary scalar
+!!$      INTEGER  ::   ikbt, ikbumm1, ikbvmm1          ! temporary scalar
+      REAL(wp) ::   zrhoa  = 1.22                   ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3                 ! drag coefficient
+      REAL(wp) ::   zbbrau, zesh2                   ! temporary scalars
+      REAL(wp) ::   zfact1, zfact2, zfact3          !    -         -
+      REAL(wp) ::   ztx2  , zty2  , zcof            !    -         -
+      REAL(wp) ::   ztau  , zdif                    !    -         -
+      REAL(wp) ::   zus   , zwlc  , zind            !    -         -
+      REAL(wp) ::   zzd_up, zzd_lw                  !    -         -
+!!$      REAL(wp) ::   zebot                           !    -         -
+      INTEGER , DIMENSION(jpi,jpj)     ::   imlc    ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhlc    !  -      -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpelc   ! 3D workspace
+      !!--------------------------------------------------------------------
+      !
+      zbbrau = rn_ebb / rau0       ! Local constant initialisation
+      zfact1 = -.5 * rdt 
+      zfact2 = 1.5 * rdt * rn_ediss
+      zfact3 = 0.5       * rn_ediss
+      !
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     !  Surface boundary condition on tke
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      DO jj = 2, jpjm1            ! en(1)   = rn_ebb taum / rau0  (min value rn_emin0)
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            en(ji,jj,1) = MAX( rn_emin0, zbbrau * taum(ji,jj) ) * tmask(ji,jj,1)
+         END DO
+      END DO
+      !
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     !  Bottom boundary condition on tke
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      ! Tests to date have found the bottom boundary condition on tke to have very little effect.
+      ! The condition is coded here for completion but commented out until there is proof that the
+      ! computational cost is justified
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      !                     en(bot)   = (rn_ebb0/rau0)*0.5*sqrt(u_botfr^2+v_botfr^2) (min value rn_emin)
+!CDIR NOVERRCHK
+!!    DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+!!       DO ji = fs_2, fs_jpim1   ! vector opt.
+!!          ikbu = MIN( mbathy(ji+1,jj), mbathy(ji,jj) )
+!!          ikbv = MIN( mbathy(ji,jj+1), mbathy(ji,jj) )
+!!          ikbum1 = MAX( ikbu-1, 1 )
+!!          ikbvm1 = MAX( ikbv-1, 1 )
+!!          ikbu = MIN( mbathy(ji,jj), mbathy(ji-1,jj) )
+!!          ikbv = MIN( mbathy(ji,jj), mbathy(ji,jj-1) )
+!!          ikbumm1 = MAX( ikbu-1, 1 )
+!!          ikbvmm1 = MAX( ikbv-1, 1 )
+!!          ikbt = MAX( mbathy(ji,jj), 1 )
+!!          ztx2 = bfrua(ji-1,jj) * ub(ji-1,jj,ikbumm1) + &
+!!                 bfrua(ji  ,jj) * ub(ji  ,jj  ,ikbum1 )
+!!          zty2 = bfrva(ji,jj  ) * vb(ji  ,jj  ,ikbvm1) + &
+!!                 bfrva(ji,jj-1) * vb(ji  ,jj-1,ikbvmm1 )
+!!          zebot = 0.001875_wp * SQRT( ztx2 * ztx2 + zty2 * zty2 )   !  where 0.001875 = (rn_ebb0/rau0) * 0.5 = 3.75*0.5/1000.
+!!          en (ji,jj,ikbt) = MAX( zebot, rn_emin ) * tmask(ji,jj,1)
+!!       END DO
+!!    END DO
+      !
+      !
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( ln_lc ) THEN      !  Langmuir circulation source term added to tke
+         !                  !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+         !
+         !                        !* total energy produce by LC : cumulative sum over jk
+         zpelc(:,:,1) =  MAX( rn2b(:,:,1), 0. ) * fsdepw(:,:,1) * fse3w(:,:,1)
+         DO jk = 2, jpk
+            zpelc(:,:,jk)  = zpelc(:,:,jk-1) + MAX( rn2b(:,:,jk), 0. ) * fsdepw(:,:,jk) * fse3w(:,:,jk)
+         END DO
+         !                        !* finite Langmuir Circulation depth
+         zcof = 0.5 * 0.016 * 0.016 / ( zrhoa * zcdrag )
+         imlc(:,:) = mbathy(:,:)         ! Initialization to the number of w ocean point mbathy
+         DO jk = jpkm1, 2, -1
+            DO jj = 1, jpj               ! Last w-level at which zpelc>=0.5*us*us 
+               DO ji = 1, jpi            !      with us=0.016*wind(starting from jpk-1)
+                  zus  = zcof * taum(ji,jj)
+                  IF( zpelc(ji,jj,jk) > zus )   imlc(ji,jj) = jk
+               END DO
+            END DO
+         END DO
+         !                               ! finite LC depth
+# if defined key_vectopt_loop
+         DO jj = 1, 1
+            DO ji = 1, jpij   ! vector opt. (forced unrolling)
+# else
+         DO jj = 1, jpj 
+            DO ji = 1, jpi
+# endif
+               zhlc(ji,jj) = fsdepw(ji,jj,imlc(ji,jj))
+            END DO
+         END DO
+# if defined key_c1d
+         hlc(:,:) = zhlc(:,:) * tmask(:,:,1)      ! c1d configuration: save finite Langmuir Circulation depth
+# endif
+         zcof = 0.016 / SQRT( zrhoa * zcdrag )
+!CDIR NOVERRCHK
+         DO jk = 2, jpkm1         !* TKE Langmuir circulation source term added to en
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zus  = zcof * SQRT( taum(ji,jj) )           ! Stokes drift
+                  !                                           ! vertical velocity due to LC
+                  zind = 0.5 - SIGN( 0.5, fsdepw(ji,jj,jk) - zhlc(ji,jj) )
+                  zwlc = zind * rn_lc * zus * SIN( rpi * fsdepw(ji,jj,jk) / zhlc(ji,jj) )
+                  !                                           ! TKE Langmuir circulation source term
+                  en(ji,jj,jk) = en(ji,jj,jk) + rdt * ( zwlc * zwlc * zwlc ) / zhlc(ji,jj) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+      !
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     !  Now Turbulent kinetic energy (output in en)
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     ! Resolution of a tridiagonal linear system by a "methode de chasse"
+      !                     ! computation from level 2 to jpkm1  (e(1) already computed and e(jpk)=0 ).
+      !                     ! zdiag : diagonal zd_up : upper diagonal zd_lw : lower diagonal
+      !
+      DO jk = 2, jpkm1           !* Shear production at uw- and vw-points (energy conserving form)
+         DO jj = 1, jpj                 ! here avmu, avmv used as workspace
+            DO ji = 1, jpi
+               avmu(ji,jj,jk) = avmu(ji,jj,jk) * ( un(ji,jj,jk-1) - un(ji,jj,jk) )   &
+                  &                            * ( ub(ji,jj,jk-1) - ub(ji,jj,jk) )   & 
+                  &           / (  fse3uw_n(ji,jj,jk)         &
+                  &              * fse3uw_b(ji,jj,jk) )
+               avmv(ji,jj,jk) = avmv(ji,jj,jk) * ( vn(ji,jj,jk-1) - vn(ji,jj,jk) )   &
+                  &                            * ( vb(ji,jj,jk-1) - vb(ji,jj,jk) )   &
+                  &                            / (  fse3vw_n(ji,jj,jk)               &
+                  &                              *  fse3vw_b(ji,jj,jk)  )
+            END DO
+         END DO
+      END DO
+      !
+      DO jk = 2, jpkm1           !* Matrix and right hand side in en
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcof   = zfact1 * tmask(ji,jj,jk)
+               zzd_up = zcof * ( avm  (ji,jj,jk+1) + avm  (ji,jj,jk  ) )   &  ! upper diagonal
+                  &          / ( fse3t(ji,jj,jk  ) * fse3w(ji,jj,jk  ) )
+               zzd_lw = zcof * ( avm  (ji,jj,jk  ) + avm  (ji,jj,jk-1) )   &  ! lower diagonal
+                  &          / ( fse3t(ji,jj,jk-1) * fse3w(ji,jj,jk  ) )
+                  !                                                           ! shear prod. at w-point weightened by mask
+               zesh2  =  ( avmu(ji-1,jj,jk) + avmu(ji,jj,jk) ) / MAX( 1.e0 , umask(ji-1,jj,jk) + umask(ji,jj,jk) )   &
+                  &    + ( avmv(ji,jj-1,jk) + avmv(ji,jj,jk) ) / MAX( 1.e0 , vmask(ji,jj-1,jk) + vmask(ji,jj,jk) )    
+                  !
+               zd_up(ji,jj,jk) = zzd_up            ! Matrix (zdiag, zd_up, zd_lw)
+               zd_lw(ji,jj,jk) = zzd_lw
+               zdiag(ji,jj,jk) = 1.e0 - zzd_lw - zzd_up + zfact2 * dissl(ji,jj,jk) * tmask(ji,jj,jk)
+               !
+               !                                   ! right hand side in en
+               en(ji,jj,jk) = en(ji,jj,jk) + rdt * (  zesh2  -   avt(ji,jj,jk) * rn2(ji,jj,jk)    &
+                  &                                 + zfact3 * dissl(ji,jj,jk) * en (ji,jj,jk)  ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !                          !* Matrix inversion from level 2 (tke prescribed at level 1)
+      DO jk = 3, jpkm1                             ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               zdiag(ji,jj,jk) = zdiag(ji,jj,jk) - zd_lw(ji,jj,jk) * zd_up(ji,jj,jk-1) / zdiag(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1                             ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1
+         DO ji = fs_2, fs_jpim1    ! vector opt.
+            zd_lw(ji,jj,2) = en(ji,jj,2) - zd_lw(ji,jj,2) * en(ji,jj,1)    ! Surface boudary conditions on tke
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               zd_lw(ji,jj,jk) = en(ji,jj,jk) - zd_lw(ji,jj,jk) / zdiag(ji,jj,jk-1) *zd_lw(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1                             ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk
+         DO ji = fs_2, fs_jpim1    ! vector opt.
+            en(ji,jj,jpkm1) = zd_lw(ji,jj,jpkm1) / zdiag(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 2, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               en(ji,jj,jk) = ( zd_lw(ji,jj,jk) - zd_up(ji,jj,jk) * en(ji,jj,jk+1) ) / zdiag(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      DO jk = 2, jpkm1                             ! set the minimum value of tke
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               en(ji,jj,jk) = MAX( en(ji,jj,jk), rn_emin ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                            !  TKE due to surface and internal wave breaking
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( nn_etau == 1 ) THEN           !* penetration throughout the water column
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   &
+                     &                                               * ( 1.e0 - fr_i(ji,jj) )  * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ELSEIF( nn_etau == 2 ) THEN       !* act only at the base of the mixed layer (jk=nmln)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               jk = nmln(ji,jj)
+               en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   &
+                  &                                               * ( 1.e0 - fr_i(ji,jj) )  * tmask(ji,jj,jk)
+            END DO
+         END DO
+      ELSEIF( nn_etau == 3 ) THEN       !* penetration throughout the water column
+!CDIR NOVERRCHK
+         DO jk = 2, jpkm1
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
+                  zty2 = vtau(ji  ,jj-1) + vtau(ji,jj)
+                  ztau = 0.5 * SQRT( ztx2 * ztx2 + zty2 * zty2 )      ! module of the mean stress 
+                  zdif = taum(ji,jj) - ztau                           ! mean of the module - module of the mean 
+                  zdif = rn_sclhft * MAX( 0.e0, zdif + rn_addhft )    ! apply some modifications...
+                  en(ji,jj,jk) = en(ji,jj,jk) + zbbrau * zdif * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   &
+                     &                                        * ( 1.e0 - fr_i(ji,jj) ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+      CALL lbc_lnk( en, 'W', 1. )      ! Lateral boundary conditions (sign unchanged)
+      !
+   END SUBROUTINE tke_tke
+
+
+   SUBROUTINE tke_avn
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE tke_avn  ***
+      !!
+      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity
+      !!
+      !! ** Method  :   At this stage, en, the now TKE, is known (computed in 
+      !!              the tke_tke routine). First, the now mixing lenth is 
+      !!      computed from en and the strafification (N^2), then the mixings
+      !!      coefficients are computed.
+      !!              - Mixing length : a first evaluation of the mixing lengh
+      !!      scales is:
+      !!                      mxl = sqrt(2*en) / N  
+      !!      where N is the brunt-vaisala frequency, with a minimum value set
+      !!      to rn_lmin (rn_lmin0) in the interior (surface) ocean.
+      !!        The mixing and dissipative length scale are bound as follow : 
+      !!         nn_mxl=0 : mxl bounded by the distance to surface and bottom.
+      !!                        zmxld = zmxlm = mxl
+      !!         nn_mxl=1 : mxl bounded by the e3w and zmxld = zmxlm = mxl
+      !!         nn_mxl=2 : mxl bounded such that the vertical derivative of mxl is 
+      !!                    less than 1 (|d/dz(mxl)|<1) and zmxld = zmxlm = mxl
+      !!         nn_mxl=3 : mxl is bounded from the surface to the bottom usings
+      !!                    |d/dz(xml)|<1 to obtain lup, and from the bottom to 
+      !!                    the surface to obtain ldown. the resulting length 
+      !!                    scales are:
+      !!                        zmxld = sqrt( lup * ldown ) 
+      !!                        zmxlm = min ( lup , ldown )
+      !!              - Vertical eddy viscosity and diffusivity:
+      !!                      avm = max( avtb, rn_ediff * zmxlm * en^1/2 )
+      !!                      avt = max( avmb, pdlr * avm )  
+      !!      with pdlr=1 if nn_pdl=0, pdlr=1/pdl=F(Ri) otherwise.
+      !!
+      !! ** Action  : - avt : now vertical eddy diffusivity (w-point)
+      !!              - avmu, avmv : now vertical eddy viscosity at uw- and vw-points
+      !!----------------------------------------------------------------------
+      USE oce,     zmpdl  =>   ua   ! use ua as workspace
+      USE oce,     zmxlm  =>   va   ! use va as workspace
+      USE oce,     zmxld  =>   ta   ! use ta as workspace
+      !!
+      INTEGER  ::   ji, jj, jk            ! dummy loop arguments
+      REAL(wp) ::   zrn2, zraug           ! temporary scalars
+      REAL(wp) ::   zdku                  !    -         -
+      REAL(wp) ::   zdkv                  !    -         -
+      REAL(wp) ::   zcoef, zav            !    -         -
+      REAL(wp) ::   zpdlr, zri, zsqen     !    -         -
+      REAL(wp) ::   zemxl, zemlm, zemlp   !    -         -
+      !!--------------------------------------------------------------------
+
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     !  Mixing length
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      !                     !* Buoyancy length scale: l=sqrt(2*e/n**2)
+      !
+      IF( ln_mxl0 ) THEN         ! surface mixing length = F(stress) : l=vkarmn*2.e5*taum/(rau0*g)
+!!gm  this should be useless
+         zmxlm(:,:,1) = 0.e0
+!!gm end
+         zraug = vkarmn * 2.e5 / ( rau0 * grav )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zmxlm(ji,jj,1) = MAX(  rn_lmin0,  zraug * taum(ji,jj)  )
+            END DO
+         END DO
+      ELSE                       ! surface set to the minimum value
+         zmxlm(:,:,1) = rn_lmin0
+      ENDIF
+      zmxlm(:,:,jpk) = rn_lmin   ! bottom set to the interior minium value
+      !
+!CDIR NOVERRCHK
+      DO jk = 2, jpkm1           ! interior value : l=sqrt(2*e/n**2)
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zrn2 = MAX( rn2(ji,jj,jk), rsmall )
+               zmxlm(ji,jj,jk) = MAX(  rn_lmin,  SQRT( 2. * en(ji,jj,jk) / zrn2 )  )
+            END DO
+         END DO
+      END DO
+      !
+!!gm  CAUTION: to be added here the bottom boundary condition on zmxlm
+      !
+      !                     !* Physical limits for the mixing length
+      !
+      zmxld(:,:, 1 ) = zmxlm(:,:,1)   ! surface set to the minimum value
+      zmxld(:,:,jpk) = rn_lmin        ! bottom  set to the minimum value
+      !
+      SELECT CASE ( nn_mxl )
+      !
+      CASE ( 0 )           ! bounded by the distance to surface and bottom
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( fsdepw(ji,jj,jk), zmxlm(ji,jj,jk),   &
+                  &            fsdepw(ji,jj,mbathy(ji,jj)) - fsdepw(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 1 )           ! bounded by the vertical scale factor
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( fse3w(ji,jj,jk), zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 2 )           ! |dk[xml]| bounded by e3t :
+         DO jk = 2, jpkm1         ! from the surface to the bottom :
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxlm(ji,jj,jk) = MIN( zmxlm(ji,jj,jk-1) + fse3t(ji,jj,jk-1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         DO jk = jpkm1, 2, -1     ! from the bottom to the surface :
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( zmxlm(ji,jj,jk+1) + fse3t(ji,jj,jk+1), zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 3 )           ! lup and ldown, |dk[xml]| bounded by e3t :
+         DO jk = 2, jpkm1         ! from the surface to the bottom : lup
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxld(ji,jj,jk) = MIN( zmxld(ji,jj,jk-1) + fse3t(ji,jj,jk-1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         DO jk = jpkm1, 2, -1     ! from the bottom to the surface : ldown
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxlm(ji,jj,jk) = MIN( zmxlm(ji,jj,jk+1) + fse3t(ji,jj,jk+1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+!CDIR NOVERRCHK
+         DO jk = 2, jpkm1
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemlm = MIN ( zmxld(ji,jj,jk),  zmxlm(ji,jj,jk) )
+                  zemlp = SQRT( zmxld(ji,jj,jk) * zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemlm
+                  zmxld(ji,jj,jk) = zemlp
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+      !
+# if defined key_c1d
+      e_dis(:,:,:) = zmxld(:,:,:)      ! c1d configuration : save mixing and dissipation turbulent length scales
+      e_mix(:,:,:) = zmxlm(:,:,:)
+# endif
+
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                     !  Vertical eddy viscosity and diffusivity  (avmu, avmv, avt)
+      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1            !* vertical eddy viscosity & diffivity at w-points
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zsqen = SQRT( en(ji,jj,jk) )
+               zav   = rn_ediff * zmxlm(ji,jj,jk) * zsqen
+               avm  (ji,jj,jk) = MAX( zav,                  avmb(jk) ) * tmask(ji,jj,jk)
+               avt  (ji,jj,jk) = MAX( zav, avtb_2d(ji,jj) * avtb(jk) ) * tmask(ji,jj,jk)
+               dissl(ji,jj,jk) = zsqen / zmxld(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( avm, 'W', 1. )      ! Lateral boundary conditions (sign unchanged)
+      !
+      DO jk = 2, jpkm1            !* vertical eddy viscosity at u- and v-points
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               avmu(ji,jj,jk) = 0.5 * ( avm(ji,jj,jk) + avm(ji+1,jj  ,jk) ) * umask(ji,jj,jk)
+               avmv(ji,jj,jk) = 0.5 * ( avm(ji,jj,jk) + avm(ji  ,jj+1,jk) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! Lateral boundary conditions
+      !
+      IF( nn_pdl == 1 ) THEN      !* Prandtl number case: update avt
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zcoef = 0.5 / ( fse3w(ji,jj,jk) * fse3w(ji,jj,jk) )
+                  !                                          ! shear
+                  zdku = avmu(ji-1,jj,jk) * ( un(ji-1,jj,jk-1) - un(ji-1,jj,jk) ) * ( ub(ji-1,jj,jk-1) - ub(ji-1,jj,jk) )   &
+                    &  + avmu(ji  ,jj,jk) * ( un(ji  ,jj,jk-1) - un(ji  ,jj,jk) ) * ( ub(ji  ,jj,jk-1) - ub(ji  ,jj,jk) )
+                  zdkv = avmv(ji,jj-1,jk) * ( vn(ji,jj-1,jk-1) - vn(ji,jj-1,jk) ) * ( vb(ji,jj-1,jk-1) - vb(ji,jj-1,jk) )   &
+                    &  + avmv(ji,jj  ,jk) * ( vn(ji,jj  ,jk-1) - vn(ji,jj  ,jk) ) * ( vb(ji,jj  ,jk-1) - vb(ji,jj  ,jk) )
+                  !                                          ! local Richardson number
+                  zri   = MAX( rn2b(ji,jj,jk), 0. ) * avm(ji,jj,jk) / (zcoef * (zdku + zdkv + rn_bshear ) )
+                  zpdlr = MAX(  0.1,  0.2 / MAX( 0.2 , zri )  )
+!!gm and even better with the use of the "true" ri_crit=0.22222...  (this change the results!)
+!!gm              zpdlr = MAX(  0.1,  ri_crit / MAX( ri_crit , zri )  )
+                  avt(ji,jj,jk)   = MAX( zpdlr * avt(ji,jj,jk), avtb_2d(ji,jj) * avtb(jk) ) * tmask(ji,jj,jk)
+# if defined key_c1d
+                  e_pdl(ji,jj,jk) = zpdlr * tmask(ji,jj,jk)    ! c1d configuration : save masked Prandlt number
+                  e_ric(ji,jj,jk) = zri * tmask(ji,jj,jk)                            ! c1d config. : save Ri
+# endif
+              END DO
+            END DO
+         END DO
+      ENDIF
+      CALL lbc_lnk( avt, 'W', 1. )                      ! Lateral boundary conditions on avt  (sign unchanged)
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl( tab3d_1=en  , clinfo1=' tke  - e: ', tab3d_2=avt, clinfo2=' t: ', ovlap=1, kdim=jpk)
+         CALL prt_ctl( tab3d_1=avmu, clinfo1=' tke  - u: ', mask1=umask,                   &
+            &          tab3d_2=avmv, clinfo2=       ' v: ', mask2=vmask, ovlap=1, kdim=jpk )
+      ENDIF
+      !
+   END SUBROUTINE tke_avn
+
+
+   SUBROUTINE tke_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tke_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
+      !!              viscosity when using a tke turbulent closure scheme
+      !!
+      !! ** Method  :   Read the namzdf_tke namelist and check the parameters
+      !!              called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namlist namzdf_tke
+      !!
+      !! ** Action  :   Increase by 1 the nstop flag is setting problem encounter
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+      !!
+      NAMELIST/namzdf_tke/ rn_ediff, rn_ediss , rn_ebb   , rn_emin  ,   &
+         &                 rn_emin0, rn_bshear, nn_mxl   , ln_mxl0  ,   &
+         &                 rn_lmin , rn_lmin0 , nn_pdl   , nn_etau  ,   &
+         &                 nn_htau , rn_efr   , rn_addhft, rn_sclhft,   &
+         &                 ln_lc   , rn_lc 
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )               !* Read Namelist namzdf_tke : Turbulente Kinetic Energy
+      READ   ( numnam, namzdf_tke )
+      
+      ri_cri = 2. / ( 2. + rn_ediss / rn_ediff )      ! resulting critical Richardson number
+
+      IF(lwp) THEN                    !* Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_tke : tke turbulent closure scheme - initialisation'
+         WRITE(numout,*) '~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_tke : set tke mixing parameters'
+         WRITE(numout,*) '      coef. to compute avt                        rn_ediff  = ', rn_ediff
+         WRITE(numout,*) '      Kolmogoroff dissipation coef.               rn_ediss  = ', rn_ediss
+         WRITE(numout,*) '      tke surface input coef.                     rn_ebb    = ', rn_ebb
+         WRITE(numout,*) '      minimum value of tke                        rn_emin   = ', rn_emin
+         WRITE(numout,*) '      surface minimum value of tke                rn_emin0  = ', rn_emin0
+         WRITE(numout,*) '      background shear (>0)                       rn_bshear = ', rn_bshear
+         WRITE(numout,*) '      mixing length type                          nn_mxl    = ', nn_mxl
+         WRITE(numout,*) '      prandl number flag                          nn_pdl    = ', nn_pdl
+         WRITE(numout,*) '      surface mixing length = F(stress) or not    ln_mxl0   = ', ln_mxl0
+         WRITE(numout,*) '      surface  mixing length minimum value        rn_lmin0  = ', rn_lmin0
+         WRITE(numout,*) '      interior mixing length minimum value        rn_lmin0  = ', rn_lmin0
+         WRITE(numout,*) '      test param. to add tke induced by wind      nn_etau   = ', nn_etau
+         WRITE(numout,*) '      flag for computation of exp. tke profile    nn_htau   = ', nn_htau
+         WRITE(numout,*) '      fraction of en which pene. the thermocline  rn_efr    = ', rn_efr
+         WRITE(numout,*) '      add offset   applied to HF tau              rn_addhft = ', rn_addhft
+         WRITE(numout,*) '      scale factor applied to HF tau              rn_sclhft = ', rn_sclhft
+         WRITE(numout,*) '      flag to take into acc.  Langmuir circ.      ln_lc     = ', ln_lc
+         WRITE(numout,*) '      coef to compute verticla velocity of LC     rn_lc     = ', rn_lc
+         WRITE(numout,*)
+         WRITE(numout,*) '      critical Richardson nb with your parameters  ri_cri = ', ri_cri
+      ENDIF
+
+      !                               !* Check of some namelist values
+      IF( nn_mxl  < 0     .OR.  nn_mxl  > 3   )   CALL ctl_stop( 'bad flag: nn_mxl is  0, 1 or 2 ' )
+      IF( nn_pdl  < 0     .OR.  nn_pdl  > 1   )   CALL ctl_stop( 'bad flag: nn_pdl is  0 or 1    ' )
+      IF( nn_htau < 0     .OR.  nn_htau > 2   )   CALL ctl_stop( 'bad flag: nn_htau is 0, 1 or 2 ' )
+      IF( rn_lc   < 0.15  .OR.  rn_lc   > 0.2 )   CALL ctl_stop( 'bad value: rn_lc must be between 0.15 and 0.2 ' )
+      IF( rn_sclhft == 0. .AND. nn_etau == 3  )   CALL ctl_stop( 'force null HF tau to penetrate the thermocline...' )
+      IF( .NOT. lhftau    .AND. nn_etau == 3  )   CALL ctl_stop( 'bad flag: nn_etau == 3 must be used with HF tau' )
+
+      IF( nn_etau == 2  )   CALL zdf_mxl( nit000 )      ! Initialization of nmln 
+
+      !                               !* depth of penetration of surface tke
+      IF( nn_etau /= 0 ) THEN      
+         SELECT CASE( nn_htau )             ! Choice of the depth of penetration
+         CASE( 0 )                                    ! constant depth penetration (here 10 meters)
+            htau(:,:) = 10.e0
+         CASE( 1 )                                    ! F(latitude) : 0.5m to 30m at high lat.
+            DO jj = 1, jpj
+               DO ji = 1, jpi  
+                  htau(ji,jj) = MAX( 0.5, 3./4. * MIN( 40., 60.*ABS( SIN( rpi/180. * gphit(ji,jj) ) ) )   )
+               END DO
+            END DO
+         CASE( 2 )                                    ! constant depth penetration (here 30 meters)
+            htau(:,:) = 30.e0
+         END SELECT
+      ENDIF
+
+      !                               !* set vertical eddy coef. to the background value
+      DO jk = 1, jpk
+         avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
+         avm (:,:,jk) = avmb(jk) * tmask(:,:,jk)
+         avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
+         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
+      END DO
+      dissl(:,:,:) = 1.e-12
+      !                               !* read or initialize all required files 
+      CALL tke_rst( nit000, 'READ' )
+      !
+   END SUBROUTINE tke_init
+
+
+   SUBROUTINE tke_rst( kt, cdrw )
+     !!---------------------------------------------------------------------
+     !!                   ***  ROUTINE tke_rst  ***
+     !!                     
+     !! ** Purpose :   Read or write TKE file (en) in restart file
+     !!
+     !! ** Method  :   use of IOM library
+     !!                if the restart does not contain TKE, en is either 
+     !!                set to rn_emin or recomputed 
+     !!----------------------------------------------------------------------
+     INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+     CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+     !
+     INTEGER ::   jit, jk   ! dummy loop indices
+     INTEGER ::   id1, id2, id3, id4, id5, id6
+     !!----------------------------------------------------------------------
+     !
+     IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
+        !                                   ! ---------------
+        IF( ln_rstart ) THEN                   !* Read the restart file
+           id1 = iom_varid( numror, 'en'   , ldstop = .FALSE. )
+           id2 = iom_varid( numror, 'avt'  , ldstop = .FALSE. )
+           id3 = iom_varid( numror, 'avm'  , ldstop = .FALSE. )
+           id4 = iom_varid( numror, 'avmu' , ldstop = .FALSE. )
+           id5 = iom_varid( numror, 'avmv' , ldstop = .FALSE. )
+           id6 = iom_varid( numror, 'dissl', ldstop = .FALSE. )
+           !
+           IF( id1 > 0 ) THEN                       ! 'en' exists
+              CALL iom_get( numror, jpdom_autoglo, 'en', en )
+              IF( MIN( id2, id3, id4, id5, id6 ) > 0 ) THEN        ! all required arrays exist
+                 CALL iom_get( numror, jpdom_autoglo, 'avt'  , avt   )
+                 CALL iom_get( numror, jpdom_autoglo, 'avm'  , avm   )
+                 CALL iom_get( numror, jpdom_autoglo, 'avmu' , avmu  )
+                 CALL iom_get( numror, jpdom_autoglo, 'avmv' , avmv  )
+                 CALL iom_get( numror, jpdom_autoglo, 'dissl', dissl )
+              ELSE                                                 ! one at least array is missing
+                 CALL tke_avn                                          ! compute avt, avm, avmu, avmv and dissl (approximation)
+              ENDIF
+           ELSE                                     ! No TKE array found: initialisation
+              IF(lwp) WRITE(numout,*) ' ===>>>> : previous run without tke scheme, en computed by iterative loop'
+              en (:,:,:) = rn_emin * tmask(:,:,:)
+              CALL tke_avn                               ! recompute avt, avm, avmu, avmv and dissl (approximation)
+              DO jit = nit000 + 1, nit000 + 10   ;   CALL zdf_tke( jit )   ;   END DO
+           ENDIF
+        ELSE                                   !* Start from rest
+           en(:,:,:) = rn_emin * tmask(:,:,:)
+           DO jk = 1, jpk                           ! set the Kz to the background value
+              avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
+              avm (:,:,jk) = avmb(jk) * tmask(:,:,jk)
+              avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
+              avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
+           END DO
+        ENDIF
+        !
+     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file
+        !                                   ! -------------------
+        IF(lwp) WRITE(numout,*) '---- tke-rst ----'
+        CALL iom_rstput( kt, nitrst, numrow, 'en'   , en    )
+        CALL iom_rstput( kt, nitrst, numrow, 'avt'  , avt   )
+        CALL iom_rstput( kt, nitrst, numrow, 'avm'  , avm   )
+        CALL iom_rstput( kt, nitrst, numrow, 'avmu' , avmu  )
+        CALL iom_rstput( kt, nitrst, numrow, 'avmv' , avmv  )
+        CALL iom_rstput( kt, nitrst, numrow, 'dissl', dissl )
+        !
+     ENDIF
+     !
+   END SUBROUTINE tke_rst
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                        NO TKE scheme
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftke = .FALSE.   !: TKE flag
+CONTAINS
+   SUBROUTINE zdf_tke( kt )          ! Empty routine
+      WRITE(*,*) 'zdf_tke: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_tke
+   SUBROUTINE tke_rst( kt, cdrw )
+     CHARACTER(len=*) ::   cdrw
+     WRITE(*,*) 'tke_rst: You should not have seen this print! error?', kt, cdwr
+   END SUBROUTINE tke_rst
+#endif
+
+   !!======================================================================
+END MODULE zdftke
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke_old.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke_old.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftke_old.F90	(revision 1844)
@@ -0,0 +1,910 @@
+MODULE zdftke_old
+   !!======================================================================
+   !!                       ***  MODULE  zdftke_old  ***
+   !! Ocean physics:  vertical mixing coefficient computed from the tke 
+   !!                 turbulent closure parameterization
+   !!=====================================================================
+   !! History :   OPA  !  1991-03  (b. blanke)  Original code
+   !!             7.0  !  1991-11  (G. Madec)   bug fix
+   !!             7.1  !  1992-10  (G. Madec)   new mixing length and eav
+   !!             7.2  !  1993-03  (M. Guyon)   symetrical conditions
+   !!             7.3  !  1994-08  (G. Madec, M. Imbard)  nn_pdl flag
+   !!             7.5  !  1996-01  (G. Madec)   s-coordinates
+   !!             8.0  !  1997-07  (G. Madec)   lbc
+   !!             8.1  !  1999-01  (E. Stretta) new option for the mixing length
+   !!  NEMO       1.0  !  2002-06  (G. Madec) add zdf_tke_init routine
+   !!              -   !  2002-08  (G. Madec)  rn_cri and Free form, F90
+   !!              -   !  2004-10  (C. Ethe )  1D configuration
+   !!             2.0  !  2006-07  (S. Masson)  distributed restart using iom
+   !!             3.0  !  2008-05  (C. Ethe,  G.Madec) : update TKE physics:
+   !!                              - tke penetration (wind steering)
+   !!                              - suface condition for tke & mixing length
+   !!                              - Langmuir cells
+   !!              -   !  2008-05  (J.-M. Molines, G. Madec)  2D form of avtb
+   !!              -   !  2008-06  (G. Madec)  style + DOCTOR name for namelist parameters
+   !!----------------------------------------------------------------------
+#if defined key_zdftke_old   ||   defined key_esopa
+   !!----------------------------------------------------------------------
+   !!   'key_zdftke_old'                               TKE vertical physics
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   zdf_tke_old  : update momentum and tracer Kz from a tke scheme
+   !!   zdf_tke_init : initialization, namelist read, and parameters control
+   !!   tke_rst      : read/write tke restart in ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE zdf_oce         ! ocean vertical physics
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE phycst          ! physical constants
+   USE zdfmxl          ! mixed layer
+   USE restart         ! only for lrst_oce
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl          ! Print control
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O manager library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_tke_old   ! routine called in step module
+
+   LOGICAL , PUBLIC, PARAMETER              ::   lk_zdftke_old = .TRUE.  !: TKE vertical mixing flag
+   REAL(wp), PUBLIC                         ::   eboost              !: multiplicative coeff of the shear product.
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   en                  !: now turbulent kinetic energy
+# if defined key_vectopt_memory
+   !                                                                !!! key_vectopt_memory
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   etmean              !: coefficient used for horizontal smoothing
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   eumean, evmean      !: at t-, u- and v-points
+# endif
+#if defined key_c1d
+   !                                                                !!! 1D cfg only
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e_dis, e_mix        !: dissipation and mixing turbulent lengh scales
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   e_pdl, e_ric        !: prandl and local Richardson numbers
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   hlc                 !: save finite Langmuir Circulation depth
+#endif
+
+   !                                       !!! ** Namelist  namzdf_tke  **
+   LOGICAL  ::   ln_rstke = .FALSE.         ! =T restart with tke from a run without tke
+   LOGICAL  ::   ln_mxl0  = .FALSE.         ! mixing length scale surface value as function of wind stress or not
+   LOGICAL  ::   ln_lc    = .FALSE.         ! Langmuir cells (LC) as a source term of TKE or not
+   INTEGER  ::   nn_itke  = 50              ! number of restart iterative loops
+   INTEGER  ::   nn_mxl   =  2              ! type of mixing length (=0/1/2/3)
+   INTEGER  ::   nn_pdl   =  1              ! Prandtl number or not (ratio avt/avm) (=0/1)
+   INTEGER  ::   nn_ave   =  1              ! horizontal average or not on avt, avmu, avmv (=0/1)
+   REAL(wp) ::   rn_ediff = 0.1_wp          ! coefficient for avt: avt=rn_ediff*mxl*sqrt(e)
+   REAL(wp) ::   rn_ediss = 0.7_wp          ! coefficient of the Kolmogoroff dissipation 
+   REAL(wp) ::   rn_ebb   = 3.75_wp         ! coefficient of the surface input of tke
+   REAL(wp) ::   rn_efave = 1._wp           ! coefficient for ave : ave=rn_efave*avm
+   REAL(wp) ::   rn_emin  = 0.7071e-6_wp    ! minimum value of tke (m2/s2)
+   REAL(wp) ::   rn_emin0 = 1.e-4_wp        ! surface minimum value of tke (m2/s2)
+   REAL(wp) ::   rn_cri   = 2._wp / 9._wp   ! critic Richardson number
+   INTEGER  ::   nn_etau  = 0               ! type of depth penetration of surface tke (=0/1/2)
+   INTEGER  ::   nn_htau  = 0               ! type of tke profile of penetration (=0/1)
+   REAL(wp) ::   rn_lmin0 = 0.4_wp          ! surface  min value of mixing length
+   REAL(wp) ::   rn_lmin  = 0.1_wp          ! interior min value of mixing length
+   REAL(wp) ::   rn_efr   = 1.0_wp          ! fraction of TKE surface value which penetrates in the ocean
+   REAL(wp) ::   rn_lc    = 0.15_wp         ! coef to compute vertical velocity of Langmuir cells
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_tke_old( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zdf_tke_old  ***
+      !!
+      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity
+      !!      coefficients using a 1.5 turbulent closure scheme.
+      !!
+      !! ** Method  :   The time evolution of the turbulent kinetic energy 
+      !!      (tke) is computed from a prognostic equation :
+      !!         d(en)/dt = eboost eav (d(u)/dz)**2         ! shear production
+      !!                  + d( rn_efave eav d(en)/dz )/dz   ! diffusion of tke
+      !!                  + grav/rau0 pdl eav d(rau)/dz     ! stratif. destruc.
+      !!                  - rn_ediss / emxl en**(2/3)       ! dissipation
+      !!      with the boundary conditions:
+      !!         surface: en = max( rn_emin0, rn_ebb sqrt(utau^2 + vtau^2) )
+      !!         bottom : en = rn_emin
+      !!      -1- The dissipation and mixing turbulent lengh scales are computed
+      !!         from the usual diagnostic buoyancy length scale:  
+      !!         mxl= sqrt(2*en)/N  where N is the brunt-vaisala frequency
+      !!         with mxl = rn_lmin at the bottom minimum value of 0.4
+      !!      Four cases : 
+      !!         nn_mxl=0 : mxl bounded by the distance to surface and bottom.
+      !!                  zmxld = zmxlm = mxl
+      !!         nn_mxl=1 : mxl bounded by the vertical scale factor.
+      !!                  zmxld = zmxlm = mxl
+      !!         nn_mxl=2 : mxl bounded such that the vertical derivative of mxl 
+      !!                  is less than 1 (|d/dz(xml)|<1). 
+      !!                  zmxld = zmxlm = mxl
+      !!         nn_mxl=3 : lup = mxl bounded using |d/dz(xml)|<1 from the surface 
+      !!                        to the bottom
+      !!                  ldown = mxl bounded using |d/dz(xml)|<1 from the bottom 
+      !!                        to the surface
+      !!                  zmxld = sqrt (lup*ldown) ; zmxlm = min(lup,ldown)
+      !!      -2- Compute the now Turbulent kinetic energy. The time differencing
+      !!      is implicit for vertical diffusion term, linearized for kolmo-
+      !!      goroff dissipation term, and explicit forward for both buoyancy
+      !!      and dynamic production terms. Thus a tridiagonal linear system is
+      !!      solved.
+      !!         Note that - the shear production is multiplied by eboost in order
+      !!      to set the critic richardson number to rn_cri (namelist parameter)
+      !!                   - the destruction by stratification term is multiplied
+      !!      by the Prandtl number (defined by an empirical funtion of the local 
+      !!      Richardson number) if nn_pdl=1 (namelist parameter)
+      !!      coefficient (zesh2):
+      !!      -3- Compute the now vertical eddy vicosity and diffusivity
+      !!      coefficients from en (before the time stepping) and zmxlm:
+      !!              avm = max( avtb, rn_ediff*zmxlm*en^1/2 )
+      !!              avt = max( avmb, pdl*avm )  (pdl=1 if nn_pdl=0)
+      !!              eav = max( avmb, avm )
+      !!      avt and avm are horizontally averaged to avoid numerical insta-
+      !!      bilities.
+      !!        N.B. The computation is done from jk=2 to jpkm1 except for
+      !!      en. Surface value of avt avmu avmv are set once a time to
+      !!      their background value in routine zdf_tke_init.
+      !!
+      !! ** Action  :   compute en (now turbulent kinetic energy)
+      !!                update avt, avmu, avmv (before vertical eddy coef.)
+      !!
+      !! References : Gaspar et al., JGR, 1990,
+      !!              Blanke and Delecluse, JPO, 1991
+      !!              Mellor and Blumberg, JPO 2004
+      !!              Axell, JGR, 2002
+      !!----------------------------------------------------------------------
+      USE oce,     zwd    =>   ua   ! use ua as workspace
+      USE oce,     zmxlm  =>   va   ! use va as workspace
+      USE oce,     zmxld  =>   ta   ! use ta as workspace
+      USE oce,     ztkelc =>   sa   ! use sa as workspace
+      !
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !
+      INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
+      REAL(wp) ::   zbbrau, zrn2, zesurf            ! temporary scalars
+      REAL(wp) ::   zfact1, ztx2, zdku              !    -         -
+      REAL(wp) ::   zfact2, zty2, zdkv              !    -         -
+      REAL(wp) ::   zfact3, zcoef, zcof, zav        !    -         -
+      REAL(wp) ::   zsh2, zpdl, zri, zsqen, zesh2   !    -         -
+      REAL(wp) ::   zemxl, zemlm, zemlp             !    -         -
+      REAL(wp) ::   zraug, zus, zwlc, zind          !    -         -
+      INTEGER , DIMENSION(jpi,jpj)     ::   imlc    ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhtau   !  -      -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhlc    !  -      -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpelc   ! 3D workspace
+      !!--------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL zdf_tke_init      ! Initialization (first time-step only)
+
+      !                                            ! Local constant initialization
+      zbbrau =  .5 * rn_ebb / rau0
+      zfact1 = -.5 * rdt * rn_efave
+      zfact2 = 1.5 * rdt * rn_ediss
+      zfact3 = 0.5 * rdt * rn_ediss
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! I.  Mixing length
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      ! Buoyancy length scale: l=sqrt(2*e/n**2)
+      ! ---------------------
+      IF( ln_mxl0 ) THEN         ! surface mixing length = F(stress) : l=vkarmn*2.e5*sqrt(utau^2 + vtau^2)/(rau0*g)
+!!gm  this should be useless
+         zmxlm(:,:,1) = 0.e0
+!!gm end
+         zraug = 0.5 * vkarmn * 2.e5 / ( rau0 * grav )
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
+               zty2 = vtau(ji  ,jj-1) + vtau(ji,jj)
+               zmxlm(ji,jj,1) = MAX(  rn_lmin0,  zraug * SQRT( ztx2 * ztx2 + zty2 * zty2 )  )
+            END DO
+         END DO
+      ELSE                       ! surface set to the minimum value
+         zmxlm(:,:,1) = rn_lmin0
+      ENDIF
+      zmxlm(:,:,jpk) = rn_lmin   ! bottom set to the interior minium value
+      !
+!CDIR NOVERRCHK
+      DO jk = 2, jpkm1           ! interior value : l=sqrt(2*e/n**2)
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zrn2 = MAX( rn2b(ji,jj,jk), rsmall )
+               zmxlm(ji,jj,jk) = MAX(  rn_lmin,  SQRT( 2. * en(ji,jj,jk) / zrn2 )  )
+            END DO
+         END DO
+      END DO
+
+      ! Physical limits for the mixing length
+      ! -------------------------------------
+      zmxld(:,:, 1 ) = zmxlm(:,:,1)   ! surface set to the minimum value
+      zmxld(:,:,jpk) = rn_lmin        ! bottom  set to the minimum value
+
+      SELECT CASE ( nn_mxl )
+      !
+      CASE ( 0 )           ! bounded by the distance to surface and bottom
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( fsdepw(ji,jj,jk), zmxlm(ji,jj,jk),   &
+                  &            fsdepw(ji,jj,mbathy(ji,jj)) - fsdepw(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 1 )           ! bounded by the vertical scale factor
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( fse3w(ji,jj,jk), zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 2 )           ! |dk[xml]| bounded by e3t :
+         DO jk = 2, jpkm1         ! from the surface to the bottom :
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxlm(ji,jj,jk) = MIN( zmxlm(ji,jj,jk-1) + fse3t(ji,jj,jk-1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         DO jk = jpkm1, 2, -1     ! from the bottom to the surface :
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemxl = MIN( zmxlm(ji,jj,jk+1) + fse3t(ji,jj,jk+1), zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemxl
+                  zmxld(ji,jj,jk) = zemxl
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 3 )           ! lup and ldown, |dk[xml]| bounded by e3t :
+         DO jk = 2, jpkm1         ! from the surface to the bottom : lup
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxld(ji,jj,jk) = MIN( zmxld(ji,jj,jk-1) + fse3t(ji,jj,jk-1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         DO jk = jpkm1, 2, -1     ! from the bottom to the surface : ldown
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zmxlm(ji,jj,jk) = MIN( zmxlm(ji,jj,jk+1) + fse3t(ji,jj,jk+1), zmxlm(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+!CDIR NOVERRCHK
+         DO jk = 2, jpkm1
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zemlm = MIN ( zmxld(ji,jj,jk),  zmxlm(ji,jj,jk) )
+                  zemlp = SQRT( zmxld(ji,jj,jk) * zmxlm(ji,jj,jk) )
+                  zmxlm(ji,jj,jk) = zemlm
+                  zmxld(ji,jj,jk) = zemlp
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+
+# if defined key_c1d
+      ! c1d configuration : save mixing and dissipation turbulent length scales
+      e_dis(:,:,:) = zmxld(:,:,:)
+      e_mix(:,:,:) = zmxlm(:,:,:)
+# endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! II  TKE Langmuir circulation source term
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( ln_lc ) THEN
+         !
+         ! Computation of total energy produce by LC : cumulative sum over jk
+         zpelc(:,:,1) =  MAX( rn2b(:,:,1), 0. ) * fsdepw(:,:,1) * fse3w(:,:,1)
+         DO jk = 2, jpk
+            zpelc(:,:,jk)  = zpelc(:,:,jk-1) + MAX( rn2b(:,:,jk), 0. ) * fsdepw(:,:,jk) * fse3w(:,:,jk)
+         END DO
+         !
+         ! Computation of finite Langmuir Circulation depth
+         ! Initialization to the number of w ocean point mbathy
+         imlc(:,:) = mbathy(:,:)
+         DO jk = jpkm1, 2, -1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ! Last w-level at which zpelc>=0.5*us*us with us=0.016*wind(starting from jpk-1)
+                  zus  = 0.000128 * wndm(ji,jj) * wndm(ji,jj)
+                  IF( zpelc(ji,jj,jk) > zus )   imlc(ji,jj) = jk
+               END DO
+            END DO
+         END DO
+         !
+         ! finite LC depth
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zhlc(ji,jj) = fsdepw(ji,jj,imlc(ji,jj))
+            END DO
+         END DO
+         !
+# if defined key_c1d
+         hlc(:,:) = zhlc(:,:) * tmask(:,:,1)      ! c1d configuration: save finite Langmuir Circulation depth
+# endif
+         !
+         ! TKE Langmuir circulation source term
+!CDIR NOVERRCHK
+         DO jk = 2, jpkm1
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! Stokes drift
+                  zus  = 0.016 * wndm(ji,jj)
+                  ! computation of vertical velocity due to LC
+                  zind = 0.5 - SIGN( 0.5, fsdepw(ji,jj,jk) - zhlc(ji,jj) )
+                  zwlc = zind * rn_lc * zus * SIN( rpi * fsdepw(ji,jj,jk) / zhlc(ji,jj) )
+                  ! TKE Langmuir circulation source term
+                  ztkelc(ji,jj,jk) = ( zwlc * zwlc * zwlc ) / zhlc(ji,jj)
+               END DO
+            END DO
+         END DO
+         !
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! III  Tubulent kinetic energy time stepping
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      ! 1. Vertical eddy viscosity on tke (put in zmxlm) and first estimate of avt
+      ! ---------------------------------------------------------------------
+!CDIR NOVERRCHK
+      DO jk = 2, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zsqen = SQRT( en(ji,jj,jk) )
+               zav   = rn_ediff * zmxlm(ji,jj,jk) * zsqen
+               avt  (ji,jj,jk) = MAX( zav, avtb_2d(ji,jj) * avtb(jk) ) * tmask(ji,jj,jk)
+               zmxlm(ji,jj,jk) = MAX( zav, avmb(jk) ) * tmask(ji,jj,jk)
+               zmxld(ji,jj,jk) = zsqen / zmxld(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! 2. Surface boundary condition on tke and its eddy viscosity (zmxlm)
+      ! -------------------------------------------------
+      ! en(1)   = rn_ebb sqrt(utau^2+vtau^2) / rau0  (min value rn_emin0)
+      ! zmxlm(1) = avmb(1) and zmxlm(jpk) = 0.
+!CDIR NOVERRCHK
+      DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
+            zty2 = vtau(ji  ,jj-1) + vtau(ji,jj)
+            zesurf = zbbrau * SQRT( ztx2 * ztx2 + zty2 * zty2 )
+            en (ji,jj,1) = MAX( zesurf, rn_emin0 ) * tmask(ji,jj,1)
+            zav  =  rn_ediff * zmxlm(ji,jj,1) * SQRT( en(ji,jj,1) )
+            zmxlm(ji,jj,1  ) = MAX( zav, avmb(1)                  ) * tmask(ji,jj,1)
+            avt  (ji,jj,1  ) = MAX( zav, avtb(1) * avtb_2d(ji,jj) ) * tmask(ji,jj,1)
+            zmxlm(ji,jj,jpk) = 0.e0
+         END DO
+      END DO
+
+      ! 3. Now Turbulent kinetic energy (output in en)
+      ! -------------------------------
+      ! Resolution of a tridiagonal linear system by a "methode de chasse"
+      ! computation from level 2 to jpkm1  (e(1) already computed and e(jpk)=0 ). 
+
+      SELECT CASE ( nn_pdl )
+      !
+      CASE ( 0 )           ! No Prandtl number
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !                                                             ! shear prod. - stratif. destruction
+                  zcoef = 0.5 / fse3w(ji,jj,jk)
+                  zdku = zcoef * (  ub(ji-1, jj ,jk-1) + ub(ji,jj,jk-1)   &          ! shear
+                     &            - ub(ji-1, jj ,jk  ) - ub(ji,jj,jk  )  )
+                  zdkv = zcoef * (  vb( ji ,jj-1,jk-1) + vb(ji,jj,jk-1)   &
+                     &            - vb( ji ,jj-1,jk  ) - vb(ji,jj,jk  )  )
+                  zesh2 =  eboost * ( zdku*zdku + zdkv*zdkv ) - rn2b(ji,jj,jk)        ! coefficient (zesh2)
+                  !
+                  !                                                             ! Matrix
+                  zcof = zfact1 * tmask(ji,jj,jk)
+                  !                                                                  ! lower diagonal
+                  avmv(ji,jj,jk) = zcof * ( zmxlm(ji,jj,jk  ) + zmxlm(ji,jj,jk-1) )   &
+                     &                  / ( fse3t(ji,jj,jk-1) * fse3w(ji,jj,jk  ) )
+                  !                                                                  ! upper diagonal
+                  avmu(ji,jj,jk) = zcof * ( zmxlm(ji,jj,jk+1) + zmxlm(ji,jj,jk  ) )   &
+                     &                  / ( fse3t(ji,jj,jk  ) * fse3w(ji,jj,jk) )
+                  !                                                                  ! diagonal
+                  zwd(ji,jj,jk) = 1. - avmv(ji,jj,jk) - avmu(ji,jj,jk) + zfact2 * zmxld(ji,jj,jk)
+                  !
+                  !                                                             ! right hand side in en 
+                  IF( .NOT. ln_lc ) THEN                                             ! No Langmuir cells
+                     en(ji,jj,jk) = en(ji,jj,jk) + zfact3 * zmxld (ji,jj,jk) * en(ji,jj,jk)   &
+                        &                        +   rdt  * zmxlm (ji,jj,jk) * zesh2
+                  ELSE                                                               ! Langmuir cell source term
+                     en(ji,jj,jk) = en(ji,jj,jk) + zfact3 * zmxld (ji,jj,jk) * en(ji,jj,jk)   &
+                        &                        +   rdt  * zmxlm (ji,jj,jk) * zesh2          &
+                        &                        +   rdt  * ztkelc(ji,jj,jk)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 1 )           ! Prandtl number
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !                                                             ! shear prod. - stratif. destruction
+                  zcoef = 0.5 / fse3w(ji,jj,jk)                                     
+                  zdku = zcoef * (  ub(ji-1,jj  ,jk-1) + ub(ji,jj,jk-1)   &          ! shear
+                  &               - ub(ji-1,jj  ,jk  ) - ub(ji,jj,jk  )  )
+                  zdkv = zcoef * (  vb(ji  ,jj-1,jk-1) + vb(ji,jj,jk-1)   &
+                  &               - vb(ji  ,jj-1,jk  ) - vb(ji,jj,jk  )  )
+                  zsh2 = zdku * zdku + zdkv * zdkv                                   ! square of shear
+                  zri  = MAX( rn2b(ji,jj,jk), 0. ) / ( zsh2 + 1.e-20 )                ! local Richardson number
+# if defined key_c1d
+                  e_ric(ji,jj,jk) = zri * tmask(ji,jj,jk)                            ! c1d config. : save Ri 
+# endif
+                  zpdl = 1.0                                                         ! Prandtl number
+                  IF( zri >= 0.2 )   zpdl = 0.2 / zri
+                  zpdl = MAX( 0.1, zpdl )
+                  zesh2 = eboost * zsh2 - zpdl * rn2b(ji,jj,jk)                       ! coefficient (esh2)
+                  !
+                  !                                                             ! Matrix
+                  zcof = zfact1 * tmask(ji,jj,jk)
+                  !                                                                 ! lower diagonal
+                  avmv(ji,jj,jk) = zcof * ( zmxlm(ji,jj,jk  ) + zmxlm(ji,jj,jk-1) )   &
+                  &                     / ( fse3t(ji,jj,jk-1) * fse3w(ji,jj,jk  ) )
+                  !                                                                 ! upper diagonal
+                  avmu(ji,jj,jk) = zcof * ( zmxlm(ji,jj,jk+1) + zmxlm(ji,jj,jk  ) )   &
+                  &                     / ( fse3t(ji,jj,jk  ) * fse3w(ji,jj,jk) )
+                  !                                                                 ! diagonal
+                  zwd(ji,jj,jk) = 1. - avmv(ji,jj,jk) - avmu(ji,jj,jk) + zfact2 * zmxld(ji,jj,jk)
+                  !
+                  !                                                             ! right hand side in en 
+                  IF( .NOT. ln_lc ) THEN                                             ! No Langmuir cells
+                     en(ji,jj,jk) = en(ji,jj,jk) + zfact3 * zmxld (ji,jj,jk) * en   (ji,jj,jk)   &
+                        &                        +   rdt  * zmxlm (ji,jj,jk) * zesh2
+                  ELSE                                                               ! Langmuir cell source term
+                     en(ji,jj,jk) = en(ji,jj,jk) + zfact3 * zmxld (ji,jj,jk) * en   (ji,jj,jk)   &
+                        &                        +   rdt  * zmxlm (ji,jj,jk) * zesh2             &
+                        &                        +   rdt  * ztkelc(ji,jj,jk)
+                  ENDIF
+                  zmxld(ji,jj,jk) = zpdl * tmask(ji,jj,jk)                      ! store masked Prandlt number in zmxld array
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+
+# if defined key_c1d
+      e_pdl(:,:,2:jpkm1) = zmxld(:,:,2:jpkm1)      ! c1d configuration : save masked Prandlt number
+      e_pdl(:,:,      1) = e_pdl(:,:,      2)
+      e_pdl(:,:,    jpk) = e_pdl(:,:,  jpkm1)      
+# endif
+
+      ! 4. Matrix inversion from level 2 (tke prescribed at level 1)
+      !!--------------------------------
+      DO jk = 3, jpkm1                             ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               zwd(ji,jj,jk) = zwd(ji,jj,jk) - avmv(ji,jj,jk) * avmu(ji,jj,jk-1) / zwd(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1                             ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1
+         DO ji = fs_2, fs_jpim1    ! vector opt.
+            avmv(ji,jj,2) = en(ji,jj,2) - avmv(ji,jj,2) * en(ji,jj,1)    ! Surface boudary conditions on tke
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               avmv(ji,jj,jk) = en(ji,jj,jk) - avmv(ji,jj,jk) / zwd(ji,jj,jk-1) *avmv(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1                             ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk
+         DO ji = fs_2, fs_jpim1    ! vector opt.
+            en(ji,jj,jpkm1) = avmv(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 2, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1    ! vector opt.
+               en(ji,jj,jk) = ( avmv(ji,jj,jk) - avmu(ji,jj,jk) * en(ji,jj,jk+1) ) / zwd(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      DO jk = 2, jpkm1                             ! set the minimum value of tke
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               en(ji,jj,jk) = MAX( en(ji,jj,jk), rn_emin ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+     
+      ! 5. Add extra TKE due to surface and internal wave breaking (nn_etau /= 0)
+      !!----------------------------------------------------------
+      IF( nn_etau /= 0 ) THEN        ! extra tke : en = en + rn_efr * en(1) * exp( -z/zhtau )
+         !
+         SELECT CASE( nn_htau )           ! Choice of the depth of penetration
+         CASE( 0 )                                    ! constant depth penetration (here 10 meters)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zhtau(ji,jj) = 10.
+               END DO
+            END DO
+         CASE( 1 )                                    ! meridional profile  1
+            DO jj = 2, jpjm1                          ! ( 0.5m in the tropics to a maximum of 30 m at high lat.)
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zhtau(ji,jj) = MAX( 0.5, 3./4. * MIN( 40., 60.*ABS( SIN( rpi/180. * gphit(ji,jj) ) ) )   )
+               END DO
+            END DO
+         END SELECT
+         ! 
+         IF( nn_etau == 1 ) THEN          ! extra term throughout the water column
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     en(ji,jj,jk) = en(ji,jj,jk)   &
+                        &         + rn_efr * en(ji,jj,1)*EXP( -fsdepw(ji,jj,jk) / zhtau(ji,jj) ) &
+                        &                  * ( 1.e0 - fr_i(ji,jj) )  * tmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSEIF( nn_etau == 2 ) THEN      ! extra term only at the base of the mixed layer
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  jk = nmln(ji,jj)
+                  en(ji,jj,jk) = en(ji,jj,jk)    &
+                     &         + rn_efr * en(ji,jj,1)*EXP( -fsdepw(ji,jj,jk) / zhtau(ji,jj) ) &
+                     &                   * ( 1.e0 - fr_i(ji,jj) )  * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+         !
+      ENDIF
+
+
+      ! Lateral boundary conditions (sign unchanged)
+      CALL lbc_lnk( en, 'W', 1. )   ;   CALL lbc_lnk( avt, 'W', 1. )
+
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! IV.  Before vertical eddy vicosity and diffusivity coefficients
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      SELECT CASE ( nn_ave )
+      CASE ( 0 )                                     ! no horizontal average 
+         DO jk = 2, jpkm1                                 ! only vertical eddy viscosity 
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avmu(ji,jj,jk) = ( avt  (ji,jj,jk) + avt  (ji+1,jj  ,jk) ) * umask(ji,jj,jk)   &
+                  &     / MAX( 1.,   tmask(ji,jj,jk) + tmask(ji+1,jj  ,jk) )
+                  avmv(ji,jj,jk) = ( avt  (ji,jj,jk) + avt  (ji  ,jj+1,jk) ) * vmask(ji,jj,jk)   &
+                  &     / MAX( 1.,   tmask(ji,jj,jk) + tmask(ji  ,jj+1,jk) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! Lateral boundary conditions
+         !
+      CASE ( 1 )                                     ! horizontal average                         ( 1/2  1/2 )
+         !                                                ! Vertical eddy viscosity    avmu = 1/4 ( 1    1   )
+         !                                                !                                       ( 1/2  1/2 )
+         !                                                !
+         !                                                !                                       ( 1/2  1   1/2 )            
+         !                                                !                            avmv = 1/4 ( 1/2  1   1/2 )      
+         DO jk = 2, jpkm1                                
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+# if defined key_vectopt_memory
+                  !                                       ! caution : vectopt_memory change the solution
+                  !                                       !           (last digit of the solver stat)
+                  avmu(ji,jj,jk) = (      avt(ji,jj  ,jk) + avt(ji+1,jj  ,jk)   &
+                     &              +.5*( avt(ji,jj-1,jk) + avt(ji+1,jj-1,jk)   &
+                     &                   +avt(ji,jj+1,jk) + avt(ji+1,jj+1,jk) ) ) * eumean(ji,jj,jk)
+
+                  avmv(ji,jj,jk) = (      avt(ji  ,jj,jk) + avt(ji  ,jj+1,jk)   &
+                     &              +.5*( avt(ji-1,jj,jk) + avt(ji-1,jj+1,jk)   &
+                     &                   +avt(ji+1,jj,jk) + avt(ji+1,jj+1,jk) ) ) * evmean(ji,jj,jk)
+# else
+                  avmu(ji,jj,jk) = (   avt  (ji,jj  ,jk) + avt  (ji+1,jj  ,jk)   &
+                     &           +.5*( avt  (ji,jj-1,jk) + avt  (ji+1,jj-1,jk)   &
+                     &                +avt  (ji,jj+1,jk) + avt  (ji+1,jj+1,jk) ) ) * umask(ji,jj,jk)   &
+                     &    / MAX( 1.,   tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk)   &
+                     &           +.5*( tmask(ji,jj-1,jk) + tmask(ji+1,jj-1,jk)   &
+                     &                +tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) )  )
+
+                  avmv(ji,jj,jk) = (   avt  (ji  ,jj,jk) + avt  (ji  ,jj+1,jk)   &
+                     &           +.5*( avt  (ji-1,jj,jk) + avt  (ji-1,jj+1,jk)   &
+                     &                +avt  (ji+1,jj,jk) + avt  (ji+1,jj+1,jk) ) ) * vmask(ji,jj,jk)   &
+                     &   /  MAX( 1.,   tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
+                     &           +.5*( tmask(ji-1,jj,jk) + tmask(ji-1,jj+1,jk)   &
+                     &                +tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk) )  )
+# endif
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! Lateral boundary conditions 
+         !
+         !                                                ! Vertical eddy diffusivity             (1 2 1)
+         !                                                !                            avt = 1/16 (2 4 2)
+         !                                                !                                       (1 2 1)
+         DO jk = 2, jpkm1         
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#  if defined key_vectopt_memory
+                  avt(ji,jj,jk) = ( avmu(ji,jj,jk) + avmu(ji-1,jj  ,jk)                          &
+                     &            + avmv(ji,jj,jk) + avmv(ji  ,jj-1,jk)  ) * etmean(ji,jj,jk)
+#  else
+                  avt(ji,jj,jk) = ( avmu (ji,jj,jk) + avmu (ji-1,jj  ,jk)                        &
+                     &            + avmv (ji,jj,jk) + avmv (ji  ,jj-1,jk)  ) * tmask(ji,jj,jk)   &
+                     &  / MAX( 1.,  umask(ji,jj,jk) + umask(ji-1,jj  ,jk)                        &
+                     &            + vmask(ji,jj,jk) + vmask(ji  ,jj-1,jk)  )
+#  endif
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+      !
+      IF( nn_pdl == 1 ) THEN                            ! Ponderation by the Prandtl number (nn_pdl=1)
+         DO jk = 2, jpkm1 
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zpdl = zmxld(ji,jj,jk)
+                  avt(ji,jj,jk) = MAX( zpdl * avt(ji,jj,jk), avtb_2d(ji,jj) * avtb(jk) ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jk = 2, jpkm1                                  ! Minimum value on the eddy viscosity
+         avmu(:,:,jk) = MAX( avmu(:,:,jk), avmb(jk) ) * umask(:,:,jk)
+         avmv(:,:,jk) = MAX( avmv(:,:,jk), avmb(jk) ) * vmask(:,:,jk)
+      END DO
+
+      CALL lbc_lnk( avt, 'W', 1. )                      ! Lateral boundary conditions on avt  (sign unchanged)
+
+      IF( lrst_oce )   CALL tke_rst( kt, 'WRITE' )      ! write en in restart file
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl( tab3d_1=en  , clinfo1=' tke  - e: ', tab3d_2=avt, clinfo2=' t: ', ovlap=1, kdim=jpk)
+         CALL prt_ctl( tab3d_1=avmu, clinfo1=' tke  - u: ', mask1=umask,                   &
+            &          tab3d_2=avmv, clinfo2=       ' v: ', mask2=vmask, ovlap=1, kdim=jpk )
+      ENDIF
+      !
+   END SUBROUTINE zdf_tke_old
+
+
+   SUBROUTINE zdf_tke_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_tke_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
+      !!      viscosity when using a tke turbulent closure scheme
+      !!
+      !! ** Method  :   Read the namzdf_tke namelist and check the parameters
+      !!      called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namlist namzdf_tke
+      !!
+      !! ** Action  :   Increase by 1 the nstop flag is setting problem encounter
+      !!
+      !!----------------------------------------------------------------------
+      USE dynzdf_exp
+      USE trazdf_exp
+      !
+# if defined key_vectopt_memory
+      INTEGER ::   ji, jj, jk   ! dummy loop indices
+# else
+      INTEGER ::           jk   ! dummy loop indices
+# endif
+      !!
+      NAMELIST/namzdf_tke/ ln_rstke, rn_ediff, rn_ediss, rn_ebb  , rn_efave, rn_emin,   &
+         &                 rn_emin0, rn_cri  , nn_itke , nn_mxl  , nn_pdl  , nn_ave ,   &
+         &                 ln_mxl0 , rn_lmin , rn_lmin0, nn_etau,   &
+         &                 nn_htau , rn_efr  , ln_lc   , rn_lc 
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist namzdf_tke : Turbulente Kinetic Energy
+      ! --------------------
+      REWIND ( numnam )
+      READ   ( numnam, namzdf_tke )
+
+      ! Compute boost associated with the Richardson critic
+      !     (control values: rn_cri = 0.3   ==> eboost=1.25 for nn_pdl=1)
+      !     (                rn_cri = 0.222 ==> eboost=1.               )
+      eboost = rn_cri * ( 2. + rn_ediss / rn_ediff ) / 2.
+
+
+
+      ! Parameter control and print
+      ! ---------------------------
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_tke_init : tke turbulent closure scheme (old scheme)'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '          Namelist namzdf_tke : set tke mixing parameters'
+         WRITE(numout,*) '             restart with tke from no tke              ln_rstke = ', ln_rstke
+         WRITE(numout,*) '             coef. to compute avt                      rn_ediff = ', rn_ediff
+         WRITE(numout,*) '             Kolmogoroff dissipation coef.             rn_ediss = ', rn_ediss
+         WRITE(numout,*) '             tke surface input coef.                   rn_ebb   = ', rn_ebb
+         WRITE(numout,*) '             tke diffusion coef.                       rn_efave = ', rn_efave
+         WRITE(numout,*) '             minimum value of tke                      rn_emin  = ', rn_emin
+         WRITE(numout,*) '             surface minimum value of tke              rn_emin0 = ', rn_emin0
+         WRITE(numout,*) '             number of restart iter loops              nn_itke  = ', nn_itke
+         WRITE(numout,*) '             mixing length type                        nn_mxl   = ', nn_mxl
+         WRITE(numout,*) '             prandl number flag                        nn_pdl   = ', nn_pdl
+         WRITE(numout,*) '             horizontal average flag                   nn_ave   = ', nn_ave
+         WRITE(numout,*) '             critic Richardson nb                      rn_cri   = ', rn_cri
+         WRITE(numout,*) '                and its associated coeff.              eboost   = ', eboost
+         WRITE(numout,*) '             surface mixing length = F(stress) or not  ln_mxl0  = ', ln_mxl0
+         WRITE(numout,*) '             surface  mixing length minimum value      rn_lmin0 = ', rn_lmin0
+         WRITE(numout,*) '             interior mixing length minimum value      rn_lmin0 = ', rn_lmin0
+         WRITE(numout,*) '             test param. to add tke induced by wind    nn_etau  = ', nn_etau
+         WRITE(numout,*) '             flag for computation of exp. tke profile  nn_htau  = ', nn_htau
+         WRITE(numout,*) '             % of rn_emin0 which pene. the thermocline rn_efr   = ', rn_efr
+         WRITE(numout,*) '             flag to take into acc.  Langmuir circ.    ln_lc    = ', ln_lc
+         WRITE(numout,*) '             coef to compute verticla velocity of LC   rn_lc    = ', rn_lc
+         WRITE(numout,*)
+      ENDIF
+
+      ! Check of some namelist values
+      IF( nn_mxl  < 0    .OR. nn_mxl  > 3   )   CALL ctl_stop( 'bad flag: nn_mxl is  0, 1 or 2 ' )
+      IF( nn_pdl  < 0    .OR. nn_pdl  > 1   )   CALL ctl_stop( 'bad flag: nn_pdl is  0 or 1    ' )
+      IF( nn_ave  < 0    .OR. nn_ave  > 1   )   CALL ctl_stop( 'bad flag: nn_ave is  0 or 1    ' )
+      IF( nn_htau < 0    .OR. nn_htau > 1   )   CALL ctl_stop( 'bad flag: nn_htau is 0 or 1    ' )
+      IF( rn_lc   < 0.15 .OR. rn_lc   > 0.2 )   CALL ctl_stop( 'bad value: rn_lc must be between 0.15 and 0.2 ' )
+
+      IF( nn_etau == 2 )   CALL zdf_mxl( nit000 )      ! Initialization of nmln 
+
+      ! Horizontal average : initialization of weighting arrays 
+      ! -------------------
+      !
+      SELECT CASE ( nn_ave )
+      ! Notice: mean arrays have not to by defined at local domain boundaries due to the vertical nature of TKE
+      !
+      CASE ( 0 )                ! no horizontal average
+         IF(lwp) WRITE(numout,*) '          no horizontal average on avt, avmu, avmv'
+         IF(lwp) WRITE(numout,*) '          only in very high horizontal resolution !'
+# if defined key_vectopt_memory
+         ! caution vectopt_memory change the solution (last digit of the solver stat)
+         ! weighting mean arrays etmean, eumean and evmean
+         !           ( 1  1 )                                          ( 1 )
+         ! avt = 1/4 ( 1  1 )     avmu = 1/2 ( 1  1 )       avmv=  1/2 ( 1 )
+         !                          
+         etmean(:,:,:) = 0.e0
+         eumean(:,:,:) = 0.e0
+         evmean(:,:,:) = 0.e0
+         !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  etmean(ji,jj,jk) = tmask(ji,jj,jk) / MAX( 1.,  umask(ji,jj,jk) + umask(ji-1,jj  ,jk)   &
+                  &                                            + vmask(ji,jj,jk) + vmask(ji  ,jj-1,jk) )
+                  eumean(ji,jj,jk) = umask(ji,jj,jk) / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji+1,jj  ,jk) )
+                  evmean(ji,jj,jk) = vmask(ji,jj,jk) / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji  ,jj+1,jk) )
+               END DO
+            END DO
+         END DO
+# endif
+         !
+      CASE ( 1 )                ! horizontal average 
+         IF(lwp) WRITE(numout,*) '          horizontal average on avt, avmu, avmv'
+# if defined key_vectopt_memory
+         ! caution vectopt_memory change the solution (last digit of the solver stat)
+         ! weighting mean arrays etmean, eumean and evmean
+         !           ( 1  1 )              ( 1/2  1/2 )             ( 1/2  1  1/2 )
+         ! avt = 1/4 ( 1  1 )   avmu = 1/4 ( 1    1   )   avmv= 1/4 ( 1/2  1  1/2 )
+         !                                 ( 1/2  1/2 )
+         etmean(:,:,:) = 0.e0
+         eumean(:,:,:) = 0.e0
+         evmean(:,:,:) = 0.e0
+         !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  etmean(ji,jj,jk) = tmask(ji,jj,jk) / MAX( 1.,   umask(ji-1,jj  ,jk) + umask(ji  ,jj  ,jk)   &
+                  &                                       +       vmask(ji  ,jj-1,jk) + vmask(ji  ,jj  ,jk) )
+                  eumean(ji,jj,jk) = umask(ji,jj,jk) / MAX( 1.,   tmask(ji  ,jj  ,jk) + tmask(ji+1,jj  ,jk)   &
+                  &                                       +.5 * ( tmask(ji  ,jj-1,jk) + tmask(ji+1,jj-1,jk)   &
+                  &                                             + tmask(ji  ,jj+1,jk) + tmask(ji+1,jj+1,jk) )  )
+                  evmean(ji,jj,jk) = vmask(ji,jj,jk) / MAX( 1.,   tmask(ji  ,jj  ,jk) + tmask(ji  ,jj+1,jk)   &
+                  &                                       +.5 * ( tmask(ji-1,jj  ,jk) + tmask(ji-1,jj+1,jk)   &
+                  &                                             + tmask(ji+1,jj  ,jk) + tmask(ji+1,jj+1,jk) )  )
+               END DO
+            END DO
+         END DO
+# endif
+         !
+      END SELECT
+
+      ! Initialization of vertical eddy coef. to the background value
+      ! -------------------------------------------------------------
+      DO jk = 1, jpk
+         avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
+         avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
+         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
+      END DO
+
+
+      ! read or initialize turbulent kinetic energy ( en )
+      ! -------------------------------------------------
+      CALL tke_rst( nit000, 'READ' )
+      !
+   END SUBROUTINE zdf_tke_init
+
+
+   SUBROUTINE tke_rst( kt, cdrw )
+     !!---------------------------------------------------------------------
+     !!                   ***  ROUTINE ts_rst  ***
+     !!                     
+     !! ** Purpose :   Read or write TKE file (en) in restart file
+     !!
+     !! ** Method  :   use of IOM library
+     !!                if the restart does not contain TKE, en is either 
+     !!                set to rn_emin or recomputed (nn_itke/=0)
+     !!----------------------------------------------------------------------
+     INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+     CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+     !
+     INTEGER ::   jit   ! dummy loop indices
+     !!----------------------------------------------------------------------
+     !
+     IF( TRIM(cdrw) == 'READ' ) THEN
+        IF( ln_rstart ) THEN
+           IF( iom_varid( numror, 'en', ldstop = .FALSE. ) > 0 .AND. .NOT.(ln_rstke) ) THEN 
+              CALL iom_get( numror, jpdom_autoglo, 'en', en )
+           ELSE
+              IF( lwp .AND. iom_varid( numror, 'en', ldstop = .FALSE. ) > 0 )   &
+                 &                       WRITE(numout,*) ' ===>>>> : previous run without tke scheme'
+              IF( lwp .AND. ln_rstke )   WRITE(numout,*) ' ===>>>> : We do not use en from the restart file'
+              IF( lwp                )   WRITE(numout,*) ' ===>>>> : en is set by iterative loop'
+              en (:,:,:) = rn_emin * tmask(:,:,:)
+              DO jit = 2, nn_itke + 1
+                 CALL zdf_tke_old( jit )
+              END DO
+           ENDIF
+        ELSE
+           en(:,:,:) = rn_emin * tmask(:,:,:)      ! no restart: en set to its minimum value
+        ENDIF
+     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+        CALL iom_rstput( kt, nitrst, numrow, 'en', en )
+     ENDIF
+     !
+   END SUBROUTINE tke_rst
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                        NO TKE scheme
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftke_old = .FALSE.   !: TKE flag
+CONTAINS
+   SUBROUTINE zdf_tke_old( kt )          ! Empty routine
+      WRITE(*,*) 'zdf_tke_old: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_tke_old
+#endif
+
+   !!======================================================================
+END MODULE zdftke_old
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftmx.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 1844)
@@ -0,0 +1,505 @@
+MODULE zdftmx
+   !!========================================================================
+   !!                       ***  MODULE  zdftmx  ***
+   !! Ocean physics: vertical tidal mixing coefficient
+   !!========================================================================
+   !! History :  1.0  !  2004-04  (L. Bessieres, G. Madec)  Original code
+   !!             -   !  2006-08  (A. Koch-Larrouy) Indonesian strait
+   !!----------------------------------------------------------------------
+#if defined key_zdftmx
+   !!----------------------------------------------------------------------
+   !!   'key_zdftmx'                                  Tidal vertical mixing
+   !!----------------------------------------------------------------------
+   !!   zdf_tmx      : global     momentum & tracer Kz with tidal induced Kz
+   !!   tmx_itf      : Indonesian momentum & tracer Kz with tidal induced Kz 
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables
+   USE zdf_oce         ! ocean vertical physics variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE eosbn2          ! ocean equation of state
+   USE phycst          ! physical constants
+   USE prtctl          ! Print control
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O Manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_tmx    ! called in step module 
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftmx = .TRUE.    !: tidal mixing flag
+
+   !                                  !!* Namelist  namzdf_tmx : tidal mixing *
+   REAL(wp) ::  rn_htmx    = 500.      ! vertical decay scale for turbulence (meters)
+   REAL(wp) ::  rn_n2min   = 1.e-8     ! threshold of the Brunt-Vaisala frequency (s-1)
+   REAL(wp) ::  rn_tfe     = 1./3.     ! tidal dissipation efficiency (St Laurent et al. 2002)
+   REAL(wp) ::  rn_me      = 0.2       ! mixing efficiency (Osborn 1980)
+   LOGICAL  ::  ln_tmx_itf = .TRUE.    ! Indonesian Through Flow (ITF): Koch-Larrouy et al. (2007) parameterization
+   REAL(wp) ::  rn_tfe_itf = 1.        ! ITF tidal dissipation efficiency (St Laurent et al. 2002)
+
+   REAL(wp), DIMENSION(jpi,jpj)     ::   en_tmx     ! energy available for tidal mixing (W/m2)
+   REAL(wp), DIMENSION(jpi,jpj)     ::   mask_itf   ! mask to use over Indonesian area
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   az_tmx     ! coefficient used to evaluate the tidal induced Kz
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zdf_tmx( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_tmx  ***
+      !!                   
+      !! ** Purpose :   add to the vertical mixing coefficients the effect of
+      !!              tidal mixing (Simmons et al 2004).
+      !!
+      !! ** Method  : - tidal-induced vertical mixing is given by:
+      !!                  Kz_tides = az_tmx / max( rn_n2min, N^2 )
+      !!              where az_tmx is a coefficient that specified the 3D space 
+      !!              distribution of the faction of tidal energy taht is used
+      !!              for mixing. Its expression is set in zdf_tmx_init routine,
+      !!              following Simmons et al. 2004.
+      !!                NB: a specific bounding procedure is performed on av_tide
+      !!              so that the input tidal energy is actually almost used. The
+      !!              basic maximum value is 60 cm2/s, but values of 300 cm2/s 
+      !!              can be reached in area where bottom stratification is too 
+      !!              weak.
+      !!
+      !!              - update av_tide in the Indonesian Through Flow area
+      !!              following Koch-Larrouy et al. (2007) parameterisation
+      !!              (see tmx_itf routine).
+      !!
+      !!              - update the model vertical eddy viscosity and diffusivity: 
+      !!                     avt  = avt  +    av_tides
+      !!                     avm  = avm  +    av_tides
+      !!                     avmu = avmu + mi(av_tides)
+      !!                     avmv = avmv + mj(av_tides)
+      !!
+      !! ** Action  :   avt, avm, avmu, avmv   increased by tidal mixing
+      !!
+      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
+      !!              Koch-Larrouy et al. 2007, GRL.
+      !!----------------------------------------------------------------------
+      USE oce, zav_tide  =>   ua    ! use ua as workspace
+      !!
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step 
+      !!
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   ztpc         ! scalar workspace
+      REAL(wp), DIMENSION(jpi,jpj) ::   zkz   ! temporary 2D workspace
+      !!----------------------------------------------------------------------
+
+      !                        
+      IF( kt == nit000  )   CALL zdf_tmx_init      ! Initialization (first time-step only)
+
+      !                          ! ----------------------- !
+      !                          !  Standard tidal mixing  !  (compute zav_tide)
+      !                          ! ----------------------- !
+      !                             !* First estimation (with n2 bound by rn_n2min) bounded by 60 cm2/s
+      zav_tide(:,:,:) = MIN(  60.e-4, az_tmx(:,:,:) / MAX( rn_n2min, rn2(:,:,:) )  )
+
+      zkz(:,:) = 0.e0               !* Associated potential energy consummed over the whole water column
+      DO jk = 2, jpkm1
+         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zav_tide(:,:,jk)* tmask(:,:,jk)
+      END DO
+
+      DO jj = 1, jpj                !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
+         DO ji = 1, jpi
+            IF( zkz(ji,jj) /= 0.e0 )   zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
+         END DO
+      END DO
+
+      DO jk = 2, jpkm1              !* Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zav_tide bound by 300 cm2/s
+         zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. )   !kz max = 300 cm2/s
+      END DO
+
+      IF( kt == nit000 ) THEN       !* check at first time-step: diagnose the energy consumed by zav_tide
+         ztpc = 0.e0
+         DO jk= 1, jpk
+            DO jj= 1, jpj
+               DO ji= 1, jpi
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj)   &
+                     &         * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         ztpc= rau0 / ( rn_tfe * rn_me ) * ztpc
+         IF(lwp) WRITE(numout,*) 
+         IF(lwp) WRITE(numout,*) '          N Total power consumption by av_tide    : ztpc = ', ztpc * 1.e-12 ,'TW'
+      ENDIF
+       
+      !                          ! ----------------------- !
+      !                          !    ITF  tidal mixing    !  (update zav_tide)
+      !                          ! ----------------------- !
+      IF( ln_tmx_itf )   CALL tmx_itf( kt, zav_tide )
+
+      !                          ! ----------------------- !
+      !                          !   Update  mixing coefs  !                          
+      !                          ! ----------------------- !
+      DO jk = 2, jpkm1              !* update momentum & tracer diffusivity with tidal mixing
+         avt(:,:,jk) = avt(:,:,jk) + zav_tide(:,:,jk)
+         avm(:,:,jk) = avm(:,:,jk) + zav_tide(:,:,jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1  ! vector opt.
+               avmu(ji,jj,jk) = avmu(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji+1,jj  ,jk) ) * umask(ji,jj,jk)
+               avmv(ji,jj,jk) = avmv(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji  ,jj+1,jk) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! lateral boundary condition
+
+      !                             !* output tidal mixing coefficient
+      CALL iom_put( "av_tide", zav_tide )
+
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_tide , clinfo1=' tmx - av_tide: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
+      !
+   END SUBROUTINE zdf_tmx
+
+
+   SUBROUTINE tmx_itf( kt, pav )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tmx_itf  ***
+      !!                   
+      !! ** Purpose :   modify the vertical eddy diffusivity coefficients 
+      !!              (pav) in the Indonesian Through Flow area (ITF).
+      !!
+      !! ** Method  : - Following Koch-Larrouy et al. (2007), in the ITF defined
+      !!                by msk_itf (read in a file, see tmx_init), the tidal
+      !!                mixing coefficient is computed with :
+      !!                  * q=1 (i.e. all the tidal energy remains trapped in
+      !!                         the area and thus is used for mixing)
+      !!                  * the vertical distribution of the tifal energy is a
+      !!                    proportional to N above the thermocline (d(N^2)/dz > 0)
+      !!                    and to N^2 below the thermocline (d(N^2)/dz < 0)
+      !!
+      !! ** Action  :   av_tide   updated in the ITF area (msk_itf)
+      !!
+      !! References :  Koch-Larrouy et al. 2007, GRL 
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   kt   ! ocean time-step
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pav  ! Tidal mixing coef.
+      !! 
+      INTEGER  ::   ji, jj, jk    ! dummy loop indices
+      REAL(wp) ::   zcoef, ztpc   ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zkz                        ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zsum1 , zsum2 , zsum       !  -      -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zempba_3d_1, zempba_3d_2   ! 3D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zempba_3d  , zdn2dz        !  -      -
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zavt_itf                   !  -      -
+      !!----------------------------------------------------------------------
+
+      !                             ! compute the form function using N2 at each time step
+      zempba_3d_1(:,:,jpk) = 0.e0
+      zempba_3d_2(:,:,jpk) = 0.e0
+      DO jk = 1, jpkm1             
+         zdn2dz     (:,:,jk) = rn2(:,:,jk) - rn2(:,:,jk+1)           ! Vertical profile of dN2/dz
+!CDIR NOVERRCHK
+         zempba_3d_1(:,:,jk) = SQRT(  MAX( 0.e0, rn2(:,:,jk) )  )    !    -        -    of N
+         zempba_3d_2(:,:,jk) =        MAX( 0.e0, rn2(:,:,jk) )       !    -        -    of N^2
+      END DO
+      !
+      zsum (:,:) = 0.e0
+      zsum1(:,:) = 0.e0
+      zsum2(:,:) = 0.e0
+      DO jk= 2, jpk
+         zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk)
+         zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk)                
+      END DO
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( zsum1(ji,jj) /= 0.e0 )   zsum1(ji,jj) = 1.e0 / zsum1(ji,jj)
+            IF( zsum2(ji,jj) /= 0.e0 )   zsum2(ji,jj) = 1.e0 / zsum2(ji,jj)                
+         END DO
+      END DO
+
+      DO jk= 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zcoef = 0.5 - SIGN( 0.5, zdn2dz(ji,jj,jk) )       ! =0 if dN2/dz > 0, =1 otherwise 
+               ztpc  = zempba_3d_1(ji,jj,jk) * zsum1(ji,jj) *        zcoef     &
+                  &  + zempba_3d_2(ji,jj,jk) * zsum2(ji,jj) * ( 1. - zcoef )
+               !
+               zempba_3d(ji,jj,jk) =               ztpc 
+               zsum     (ji,jj)    = zsum(ji,jj) + ztpc * fse3w(ji,jj,jk)
+            END DO
+         END DO
+       END DO
+       DO jj = 1, jpj
+          DO ji = 1, jpi
+             IF( zsum(ji,jj) > 0.e0 )   zsum(ji,jj) = 1.e0 / zsum(ji,jj)                
+          END DO
+       END DO
+
+      !                             ! first estimation bounded by 10 cm2/s (with n2 bounded by rn_n2min) 
+      zcoef = rn_tfe_itf / ( rn_tfe * rau0 )
+      DO jk = 1, jpk
+         zavt_itf(:,:,jk) = MIN(  10.e-4, zcoef * en_tmx(:,:) * zsum(:,:) * zempba_3d(:,:,jk)   &
+            &                                      / MAX( rn_n2min, rn2(:,:,jk) ) * tmask(:,:,jk)  )
+      END DO           
+
+      zkz(:,:) = 0.e0               ! Associated potential energy consummed over the whole water column
+      DO jk = 2, jpkm1
+         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * tmask(:,:,jk)
+      END DO
+
+      DO jj = 1, jpj                ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
+         DO ji = 1, jpi
+            IF( zkz(ji,jj) /= 0.e0 )   zkz(ji,jj) = en_tmx(ji,jj) * rn_tfe_itf / rn_tfe / zkz(ji,jj)
+         END DO
+      END DO
+
+      DO jk = 2, jpkm1              ! Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zavt_itf bound by 300 cm2/s
+         zavt_itf(:,:,jk) = zavt_itf(:,:,jk) * MIN( zkz(:,:), 120./10. )   ! kz max = 120 cm2/s
+      END DO
+
+      IF( kt == nit000 ) THEN       ! diagnose the nergy consumed by zavt_itf
+         ztpc = 0.e0
+         DO jk= 1, jpk
+            DO jj= 1, jpj
+               DO ji= 1, jpi
+                  ztpc = ztpc + e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) )   &
+                     &                     * zavt_itf(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         ztpc= rau0 * ztpc / ( rn_me * rn_tfe_itf )
+         IF(lwp) WRITE(numout,*) '          N Total power consumption by zavt_itf: ztpc = ', ztpc * 1.e-12 ,'TW'
+      ENDIF
+
+      !                             ! Update pav with the ITF mixing coefficient
+      DO jk = 2, jpkm1
+         pav(:,:,jk) = pav     (:,:,jk) * ( 1.e0 - mask_itf(:,:) )   &
+            &        + zavt_itf(:,:,jk) *          mask_itf(:,:) 
+      END DO
+      !
+   END SUBROUTINE tmx_itf
+
+
+   SUBROUTINE zdf_tmx_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_tmx_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the vertical tidal mixing, Reading
+      !!              of M2 and K1 tidal energy in nc files
+      !!
+      !! ** Method  : - Read the namtmx namelist and check the parameters
+      !!
+      !!              - Read the input data in NetCDF files :
+      !!              M2 and K1 tidal energy. The total tidal energy, en_tmx, 
+      !!              is the sum of M2, K1 and S2 energy where S2 is assumed 
+      !!              to be: S2=(1/2)^2 * M2
+      !!              mask_itf, a mask array that determine where substituing 
+      !!              the standard Simmons et al. (2005) formulation with the
+      !!              one of Koch_Larrouy et al. (2007).
+      !!
+      !!              - Compute az_tmx, a 3D coefficient that allows to compute
+      !!             the standard tidal-induced vertical mixing as follows:
+      !!                  Kz_tides = az_tmx / max( rn_n2min, N^2 )
+      !!             with az_tmx a bottom intensified coefficient is given by:
+      !!                 az_tmx(z) = en_tmx / ( rau0 * rn_htmx ) * EXP( -(H-z)/rn_htmx )
+      !!                                                  / ( 1. - EXP( - H   /rn_htmx ) ) 
+      !!             where rn_htmx the characteristic length scale of the bottom 
+      !!             intensification, en_tmx the tidal energy, and H the ocean depth
+      !!
+      !! ** input   :   - Namlist namtmx
+      !!                - NetCDF file : M2_ORCA2.nc, K1_ORCA2.nc, and mask_itf.nc
+      !!
+      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
+      !!              - defined az_tmx used to compute tidal-induced mixing
+      !!
+      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
+      !!              Koch-Larrouy et al. 2007, GRL.
+      !!----------------------------------------------------------------------
+      USE oce,   zav_tide  =>   ua   ! use ua as workspace
+      !!
+      INTEGER ::   ji, jj, jk    ! dummy loop indices
+      INTEGER ::   inum          ! temporary logical unit
+      REAL(wp) ::   ztpc, ze_z   ! total power consumption
+      REAL(wp), DIMENSION(jpi,jpj) ::  zem2, zek1   ! read M2 and K1 tidal energy
+      REAL(wp), DIMENSION(jpi,jpj) ::  zkz          ! total M2, K1 and S2 tidal energy
+      REAL(wp), DIMENSION(jpi,jpj) ::  zfact        ! used for vertical structure function
+      REAL(wp), DIMENSION(jpi,jpj) ::  zhdep        ! Ocean depth 
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zpc      ! power consumption
+      !!
+      NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
+      !!----------------------------------------------------------------------
+
+      REWIND( numnam )               ! Read Namelist namtmx : Tidal Mixing
+      READ  ( numnam, namzdf_tmx )
+
+      IF(lwp) THEN                   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_tmx_init : tidal mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_tmx : set tidal mixing parameters'
+         WRITE(numout,*) '      Vertical decay scale for turbulence   = ', rn_htmx 
+         WRITE(numout,*) '      Brunt-Vaisala frequency threshold     = ', rn_n2min
+         WRITE(numout,*) '      Tidal dissipation efficiency          = ', rn_tfe
+         WRITE(numout,*) '      Mixing efficiency                     = ', rn_me
+         WRITE(numout,*) '      ITF specific parameterisation         = ', ln_tmx_itf
+         WRITE(numout,*) '      ITF tidal dissipation efficiency      = ', rn_tfe_itf
+      ENDIF
+
+      IF( ln_tmx_itf ) THEN          ! read the Indonesian Through Flow mask
+         CALL iom_open('mask_itf',inum)
+         CALL iom_get (inum, jpdom_data, 'tmaskitf',mask_itf,1) ! 
+         CALL iom_close(inum)
+      ENDIF
+
+      ! read M2 tidal energy flux : W/m2  ( zem2 < 0 )
+      CALL iom_open('M2rowdrg',inum)
+      CALL iom_get (inum, jpdom_data, 'field',zem2,1) ! 
+      CALL iom_close(inum)
+
+      ! read K1 tidal energy flux : W/m2  ( zek1 < 0 )
+      CALL iom_open('K1rowdrg',inum)
+      CALL iom_get (inum, jpdom_data, 'field',zek1,1) ! 
+      CALL iom_close(inum)
+ 
+      ! Total tidal energy ( M2, S2 and K1  with S2=(1/2)^2 * M2 )
+      ! only the energy available for mixing is taken into account,
+      ! (mixing efficiency tidal dissipation efficiency)
+      en_tmx(:,:) = - rn_tfe * rn_me * ( zem2(:,:) * 1.25 + zek1(:,:) ) * tmask(:,:,1)
+
+      ! Vertical structure (az_tmx)
+      DO jj = 1, jpj                ! part independent of the level
+         DO ji = 1, jpi
+            zhdep(ji,jj) = fsdepw(ji,jj,mbathy(ji,jj))       ! depth of the ocean
+            zfact(ji,jj) = rau0 * rn_htmx * ( 1. - EXP( -zhdep(ji,jj) / rn_htmx ) )
+            IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = en_tmx(ji,jj) / zfact(ji,jj)
+         END DO
+      END DO
+      DO jk= 1, jpk                 ! complete with the level-dependent part
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               az_tmx(ji,jj,jk) = zfact(ji,jj) * EXP( -( zhdep(ji,jj)-fsdepw(ji,jj,jk) ) / rn_htmx ) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      IF( nprint == 1 .AND. lwp ) THEN
+         ! Control print
+         ! Total power consumption due to vertical mixing
+         ! zpc = rau0 * 1/rn_me * rn2 * zav_tide
+         zav_tide(:,:,:) = 0.e0
+         DO jk = 2, jpkm1
+            zav_tide(:,:,jk) = az_tmx(:,:,jk) / MAX( rn_n2min, rn2(:,:,jk) )
+         END DO
+
+         ztpc = 0.e0
+         zpc(:,:,:) = MAX(rn_n2min,rn2(:,:,:)) * zav_tide(:,:,:)
+         DO jk= 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
+
+         WRITE(numout,*) 
+         WRITE(numout,*) '          Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
+
+
+         ! control print 2
+         zav_tide(:,:,:) = MIN( zav_tide(:,:,:), 60.e-4 )   
+         zkz(:,:) = 0.e0
+         DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zkz(ji,jj) = zkz(ji,jj) + fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) ) * rau0 * zav_tide(ji,jj,jk)* tmask(ji,jj,jk)
+            END DO
+         END DO
+         END DO
+         ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zkz(ji,jj) /= 0.e0 )   THEN
+                   zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
+               ENDIF
+            END DO
+         END DO
+         ztpc = 1.e50
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zkz(ji,jj) /= 0.e0 )   THEN
+                   ztpc = Min( zkz(ji,jj), ztpc)
+               ENDIF
+            END DO
+         END DO
+         WRITE(numout,*) '          Min de zkz ', ztpc, ' Max = ', maxval(zkz(:,:) )
+
+         DO jk = 2, jpkm1
+            zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. )   !kz max = 300 cm2/s
+         END DO
+         ztpc = 0.e0
+         zpc(:,:,:) = Max(0.e0,rn2(:,:,:)) * zav_tide(:,:,:)
+         DO jk= 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
+         WRITE(numout,*) '          2 Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
+
+         DO jk = 1, jpk
+            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zav_tide(:,:,jk)     * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
+            ztpc = 1.E50
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( zav_tide(ji,jj,jk) /= 0.e0 )   ztpc =Min( ztpc, zav_tide(ji,jj,jk) )
+               END DO
+            END DO
+            WRITE(numout,*) '            N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',ztpc*1.e4,   &
+               &       'max= ', MAXVAL(zav_tide(:,:,jk) )*1.e4, ' cm2/s'
+         END DO
+
+         WRITE(numout,*) '          e_tide : ', SUM( e1t*e2t*en_tmx ) / ( rn_tfe * rn_me ) * 1.e-12, 'TW'
+         WRITE(numout,*) 
+         WRITE(numout,*) '          Initial profile of tidal vertical mixing'
+         DO jk = 1, jpk
+            DO jj = 1,jpj
+               DO ji = 1,jpi
+                  zkz(ji,jj) = az_tmx(ji,jj,jk) /MAX( rn_n2min, rn2(ji,jj,jk) )
+               END DO
+            END DO
+            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
+            WRITE(numout,*) '                jk= ', jk,'   ', ze_z * 1.e4,' cm2/s'
+         END DO
+         DO jk = 1, jpk
+            zkz(:,:) = az_tmx(:,:,jk) /rn_n2min
+            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
+            WRITE(numout,*) 
+            WRITE(numout,*) '          N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',MINVAL(zkz)*1.e4,   &
+               &       'max= ', MAXVAL(zkz)*1.e4, ' cm2/s'
+         END DO
+         !
+      ENDIF
+
+   END SUBROUTINE zdf_tmx_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module                NO Tidal MiXing
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftmx = .FALSE.   !: tidal mixing flag
+CONTAINS
+   SUBROUTINE zdf_tmx( kt )          ! Empty routine
+      WRITE(*,*) 'zdf_tmx: You should not have seen this print! error?', kt
+   END SUBROUTINE zdf_tmx
+#endif
+
+   !!======================================================================
+END MODULE zdftmx
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_interp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_interp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_interp.F90	(revision 1844)
@@ -0,0 +1,15 @@
+MODULE agrif_opa_interp
+   !!======================================================================
+   !!                       ***  MODULE agrif_opa_interp  ***
+   !!  Dummy module
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                     NO agrif use
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+END MODULE agrif_opa_interp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_sponge.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_sponge.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_sponge.F90	(revision 1844)
@@ -0,0 +1,15 @@
+MODULE agrif_opa_sponge
+   !!======================================================================
+   !!                       ***  MODULE agrif_opa_sponge  ***
+   !!  Dummy module
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                     NO agrif use
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+END MODULE agrif_opa_sponge
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_update.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_update.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/agrif_opa_update.F90	(revision 1844)
@@ -0,0 +1,15 @@
+MODULE agrif_opa_update
+   !!======================================================================
+   !!                       ***  MODULE agrif_opa_update  ***
+   !!  Dummy module
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                     NO agrif use
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+END MODULE agrif_opa_update
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla.F90	(revision 1844)
@@ -0,0 +1,781 @@
+MODULE cla
+   !!==============================================================================
+   !!                         ***  MODULE  cla  ***
+   !! Cross Land Advection : parameterize ocean exchanges through straits by a
+   !!                        specified advection across land.
+   !!==============================================================================
+#if defined key_orca_r2
+   !!----------------------------------------------------------------------
+   !!   'key_orca_r2'   :                             ORCA R2 configuration
+   !!----------------------------------------------------------------------
+   !!   tra_cla           : update the tracer trend with the horizontal 
+   !!                       and vertical advection trends at straits
+   !!   tra_bab_el_mandeb : 
+   !!   tra_gibraltar     :
+   !!   tra_hormuz        :
+   !!   tra_cla_init      :
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tra_cla        ! routine called by step.F90
+
+   !! * Modules variables   
+   REAL(wp) :: zempmed, zempred
+
+   REAL(wp) :: zisw_rs, zurw_rs, zbrw_rs          ! Imposed transport Red Sea 
+   REAL(wp) :: zisw_ms, zmrw_ms, zurw_ms, zbrw_ms ! Imposed transport Med Sea 
+   REAL(wp) :: zisw_pg, zbrw_pg                   ! Imposed transport Persic Gulf 
+
+   REAL(wp), DIMENSION(jpk) ::   &
+      zu1_rs_i, zu2_rs_i, zu3_rs_i,              &  ! Red Sea velocities
+      zu1_ms_i, zu2_ms_i, zu3_ms_i,              &  ! Mediterranean Sea velocities
+      zu_pg                                         ! Persic Gulf velocities
+   REAL(wp), DIMENSION (jpk) :: zthor, zshor        ! Temperature, salinity Hormuz 
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE tra_cla( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tra_cla  ***
+      !!                   
+      !! ** Purpose :   Update the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations
+      !!      at some straits ( Bab el Mandeb, Gibraltar, Hormuz ).
+      !!
+      !! ** Method  :   ...
+      !!         Add this trend now to the general trend of tracer (ta,sa):
+      !!            (ta,sa) = (ta,sa) + ( zta , zsa )
+      !!
+      !! ** Action  :   update (ta,sa) with the now advective tracer trends
+      !!
+      !! History :
+      !!        !         (A. Bozec)  original code  
+      !!   8.5  !  02-11  (A. Bozec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
+      !!----------------------------------------------------------------------
+ 
+      ! cross land advection for straits
+
+      ! Initialization
+      IF( kt == nit000 )   CALL tra_cla_init
+
+
+      ! Bab el Mandeb strait horizontal advection
+
+      CALL tra_bab_el_mandeb 
+
+      ! Gibraltar strait horizontal advection
+
+      CALL tra_gibraltar
+
+      ! Hormuz Strait ( persian Gulf) horizontal advection
+
+      CALL tra_hormuz 
+
+   END SUBROUTINE tra_cla
+
+
+   SUBROUTINE tra_bab_el_mandeb
+      !!---------------------------------------------------------------------
+      !!             ***  ROUTINE tra_bab_el_mandeb  ***
+      !!
+      !! ** Purpose :   Update the horizontal advective trend of tracers
+      !!      correction in Bab el Mandeb strait and
+      !!      add it to the general trend of tracer equations.
+      !!
+      !! ** Method :
+      !!     We impose transport at Bab el Mandeb and knowing T and S in
+      !!     surface and depth at each side of the  strait, we deduce T and S
+      !!     of the deep outflow of the Red Sea in the Indian ocean . 
+      !!                                          |
+      !!            |/ \|            N          |\ /|
+      !!            |_|_|______      |          |___|______
+      !!        88  |   |<-       W - - E    88 |   |<-
+      !!        87  |___|______      |       87 |___|->____
+      !!             160 161         S           160 161 
+      !!       horizontal view                horizontal view
+      !!          surface                        depth
+      !!    
+      !!     The horizontal advection is evaluated by a second order cen-
+      !!     tered scheme using now fields (leap-frog scheme). In specific
+      !!     areas (vicinity of major river mouths, some straits, or tn
+      !!     approaching the freezing point) it is mixed with an upstream 
+      !!     scheme for stability reasons. 
+      !!
+      !!         C A U T I O N : the trend saved is the centered trend only.
+      !!      It doesn't take into account the upstream part of the scheme.
+      !!
+      !! ** history :
+      !!           !  02-11  (A. Bozec) Original code 
+      !!      8.5  !  02-11  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::  ji, jj, jk               ! dummy loop indices
+      REAL(wp) :: zsu, zvt
+      REAL(wp) :: zsumt, zsumt1, zsumt2, zsumt3, zsumt4
+      REAL(wp) :: zsums, zsums1, zsums2, zsums3, zsums4
+      REAL(wp) :: zt, zs
+      REAL(wp) :: zwei
+      REAL(wp), DIMENSION (jpk) ::  zu1_rs, zu2_rs, zu3_rs
+      !!---------------------------------------------------------------------
+
+      ! Initialization of vertical sum for T and S transport
+      ! ----------------------------------------------------
+
+      zsumt  = 0.e0       ! East  Bab el Mandeb surface north point (T)
+      zsums  = 0.e0       ! East  Bab el Mandeb surface north point (S)
+      zsumt1 = 0.e0       ! East  Bab el Mandeb depth   south point (T)
+      zsums1 = 0.e0       ! East  Bab el Mandeb depth   south point (S)
+      zsumt2 = 0.e0       ! West  Bab el Mandeb surface             (T)
+      zsums2 = 0.e0       ! West  Bab el Mandeb surface             (S)
+      zsumt3 = 0.e0       ! West  Bab el Mandeb depth               (T)
+      zsums3 = 0.e0       ! West  Bab el Mandeb depth               (S)
+      zsumt4 = 0.e0       ! East  Bab el Mandeb depth   north point (T) 
+      zsums4 = 0.e0       ! East  Bab el Mandeb depth   north point (S) 
+      
+      ! EMP of the Red Sea 
+      ! ------------------
+
+      zempred = 0.e0
+      zwei = 0.e0
+      DO jj = mj0(87), mj1(96)
+         DO ji = mi0(148), mi1(160)
+            zwei    = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempred = zempred + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempred )      ! sum with other processors value
+
+      ! convert in m3
+      zempred = zempred * 1.e-3
+
+      ! Velocity profile at each point
+      ! ------------------------------
+
+      zu1_rs(:) = zu1_rs_i(:)
+      zu2_rs(:) = zu2_rs_i(:)
+      zu3_rs(:) = zu3_rs_i(:)
+
+      ! velocity profile at 161,88 East Bab el Mandeb North point 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1, 8                                      
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu1_rs(jk) = zu1_rs(jk) - ( zempred / 8. ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )     
+            END DO
+         END DO
+      END DO
+
+      ! velocity profile at 161, 88 West Bab el Mandeb 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  10                                     
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu3_rs(jk) = zu3_rs(jk) + ( zempred / 10. ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      
+      ! Balance of temperature and salinity
+      ! -----------------------------------
+
+      ! east Bab el Mandeb surface vertical sum of transport* S,T
+      DO jk =  1, 19
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(161), mi1(161) 
+               zsumt  = zsumt  + tn(ji,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zu1_rs(jk)  
+               zsums  = zsums  + sn(ji,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zu1_rs(jk) 
+            END DO
+         END DO
+      END DO
+
+      ! west Bab el Mandeb surface vertical sum of transport* S,T
+      DO jk =  1, 10
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(161), mi1(161) 
+               zsumt2 = zsumt2 + tn(ji,jj,jk) * e1v(ji-1,jj) * fse3v(ji-1,jj,jk) * zu3_rs(jk)
+               zsums2 = zsums2 + sn(ji,jj,jk) * e1v(ji-1,jj) * fse3v(ji-1,jj,jk) * zu3_rs(jk)
+            END DO
+         END DO
+      END DO
+
+      ! west Bab el Mandeb deeper
+      DO jj = mj0(89), mj1(89) 
+         DO ji = mi0(160), mi1(160) 
+            zsumt3 = tn(ji,jj,16) * e1v(ji,jj-1) * fse3v(ji,jj-1,16) * zu3_rs(16)
+            zsums3 = sn(ji,jj,16) * e1v(ji,jj-1) * fse3v(ji,jj-1,16) * zu3_rs(16)
+         END DO
+      END DO
+
+      ! east  Bab el Mandeb deeper  
+      DO jk =  20, 21
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(161), mi1(161) 
+               zsumt4 =  zsumt4 + tn(ji,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zu1_rs(jk)
+               zsums4 =  zsums4 + sn(ji,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zu1_rs(jk) 
+            END DO
+         END DO
+      END DO
+
+      ! Total transport  
+      zsumt1 = -( zsumt3 + zsumt2 + zsumt + zsumt4 )
+      zsums1 = -( zsums3 + zsums2 + zsums + zsums4 )
+
+      ! Temperature and Salinity at East Bab el Mandeb, Level 21
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zt = zsumt1 / ( zu2_rs(21) * e2u(ji,jj-1) * fse3u(ji,jj-1,21) )
+            zs = zsums1 / ( zu2_rs(21) * e2u(ji,jj-1) * fse3u(ji,jj-1,21) )
+         END DO
+      END DO
+      
+      ! New Temperature and Salinity at East Bab el Mandeb
+      ! --------------------------------------------------
+
+      ! north point 	
+      DO jk = 1, jpk
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(161), mi1(161) 
+               zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e2u(ji-1,jj) * fse3u(ji-1,jj,jk)
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu1_rs(jk) * tn(ji,jj,jk)
+               sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu1_rs(jk) * sn(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! south point
+      jk =  21
+      DO jj = mj0(87), mj1(87) 
+         DO ji = mi0(161), mi1(161) 
+            zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+            zsu = e2u(ji-1,jj) * fse3u(ji-1,jj,jk)
+            ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu2_rs(jk) * zt
+            sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu2_rs(jk) * zs
+         END DO
+      END DO
+
+
+      ! New Temperature and Salinity at West Bab el Mandeb 
+      ! --------------------------------------------------
+
+      ! surface	
+      DO jk = 1, 10
+         DO jj = mj0(89), mj1(89) 
+            DO ji = mi0(160), mi1(160) 
+               zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e1v(ji,jj-1) * fse3v(ji,jj-1,jk)
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu3_rs(jk) * tn(ji+1,jj-1,jk)
+               sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu3_rs(jk) * sn(ji+1,jj-1,jk)
+            END DO
+         END DO
+      END DO
+      ! deeper
+      jk =  16
+      DO jj = mj0(89), mj1(89) 
+         DO ji = mi0(160), mi1(160) 
+            zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+            zsu = e1v(ji,jj-1) * fse3v(ji,jj-1,jk)
+            ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu3_rs(jk) * tn(ji,jj,jk)
+            sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu3_rs(jk) * sn(ji,jj,jk)
+         END DO
+      END DO
+
+   END SUBROUTINE tra_bab_el_mandeb
+
+
+   SUBROUTINE tra_gibraltar
+      !!---------------------------------------------------------------------
+      !!               ***  ROUTINE tra_gibraltar  ***
+      !!
+      !! ** Purpose :
+      !!        Update the horizontal advective trend of tracers (t & s)
+      !!        correction in Gibraltar  and
+      !!        add it to the general trend of tracer equations.
+      !!
+      !! ** Method :
+      !!      We impose transport at Gibraltar and knowing T and S in
+      !!      surface and deeper at each side of the strait, we deduce T and S
+      !!      of the outflow of the Mediterranean Sea in the Atlantic ocean .
+      !!                                
+      !!          ________________      N        ________________
+      !! 102           |    |->         |           <-|    |<-
+      !! 101      ___->|____|_____   W - - E     ___->|____|_____
+      !!           139   140  141       |         139   140  141
+      !!          horizontal view       S        horizontal view
+      !!            surface                          depth
+      !!         C A U T I O N : the trend saved is the centered trend only.
+      !!      It doesn't take into account the upstream part of the scheme.
+      !!
+      !! ** history :
+      !!           !  02-06  (A. Bozec) Original code 
+      !!      8.5  !  02-11  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::  ji, jj, jk               ! dummy loop indices
+      REAL(wp) :: zsu, zvt
+      REAL(wp) :: zsumt, zsumt1, zsumt2, zsumt3, zsumt4
+      REAL(wp) :: zsums, zsums1, zsums2, zsums3, zsums4
+      REAL(wp) :: zt, zs
+      REAL(wp) :: zwei
+      REAL(wp), DIMENSION (jpk) ::  zu1_ms, zu2_ms, zu3_ms
+      !!---------------------------------------------------------------------
+      
+      ! Initialization of vertical sum for T and S transport
+      ! ----------------------------------------------------
+
+      zsumt  = 0.e0        ! West Gib. surface south point ( T )
+      zsums  = 0.e0        ! West Gib. surface south point ( S )
+      zsumt1 = 0.e0        ! East Gib. surface north point ( T )
+      zsums1 = 0.e0        ! East Gib. surface north point ( S )
+      zsumt2 = 0.e0        ! East Gib. depth   north point ( T )
+      zsums2 = 0.e0        ! East Gib. depth   north point ( S )
+      zsumt3 = 0.e0        ! West Gib. depth   south point ( T ) 
+      zsums3 = 0.e0        ! West Gib. depth   south point ( S ) 
+      zsumt4 = 0.e0        ! West Gib. depth   north point ( T ) 
+      zsums4 = 0.e0        ! West Gib. depth   north point ( S ) 
+      
+      ! EMP of Mediterranean Sea 
+      ! ------------------------
+ 
+      zempmed = 0.e0
+      zwei = 0.e0
+      DO jj = mj0(96),mj1(110)
+         DO ji = mi0(141),mi1(181)
+            zwei    = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempmed = zempmed + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempmed )      ! sum with other processors value
+
+
+      ! minus 2 points in Red Sea and 3 in Atlantic ocean
+      DO jj = mj0(96),mj1(96)
+         DO ji = mi0(148),mi1(148)
+            zempmed = zempmed  -  emp(ji  ,jj) * tmask(ji  ,jj,1) * e1t(ji  ,jj) * e2t(ji  ,jj)   &
+                               -  emp(ji+1,jj) * tmask(ji+1,jj,1) * e1t(ji+1,jj) * e2t(ji+1,jj)   
+         END DO
+      END DO
+
+      ! convert in m3
+      zempmed = zempmed * 1.e-3
+
+      ! Velocity profile at each point
+      ! ------------------------------
+
+      zu1_ms(:) = zu1_ms_i(:)
+      zu2_ms(:) = zu2_ms_i(:)
+      zu3_ms(:) = zu3_ms_i(:)
+
+      ! velocity profile at 139,101  South point + emp on surface 
+      DO jk = 1, 14                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms(jk) = zu1_ms(jk) + ( zempmed / 14. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      ! profile at East Gibraltar    
+      ! velocity profile at 141,102  + emp on surface 
+      DO  jk = 1, 14                     
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu3_ms(jk) = zu3_ms(jk) +  ( zempmed / 14. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) ) 
+            END DO
+         END DO
+      END DO
+     
+      ! Balance of temperature and salinity
+      ! -----------------------------------
+
+      ! west gibraltar surface vertical sum of transport* S,T
+      DO  jk =  1, 14 
+         DO jj = mj0(101), mj1(101) 
+            DO ji = mi0(139), mi1(139) 
+               zsumt  = zsumt + tn(ji, jj,jk) * e2u(ji, jj) * fse3u(ji, jj,jk) * zu1_ms(jk)  
+               zsums  = zsums + sn(ji, jj,jk) * e2u(ji, jj) * fse3u(ji, jj,jk) * zu1_ms(jk) 
+            END DO
+         END DO
+      END DO
+
+      ! east Gibraltar surface  vertical sum of transport* S,T
+      DO  jk =  1, 14 
+         DO jj = mj0(101), mj1(101) 
+            DO ji = mi0(139), mi1(139) 
+               zsumt1 = zsumt1 + tn(ji, jj,jk) * e2u(ji+1, jj+1) * fse3u(ji+1, jj+1,jk) * zu3_ms(jk)
+               zsums1 = zsums1 + sn(ji, jj,jk) * e2u(ji+1, jj+1) * fse3u(ji+1, jj+1,jk) * zu3_ms(jk)
+            END DO
+         END DO
+      END DO
+
+      ! east Gibraltar deeper  vertical sum of transport* S,T
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(141), mi1(141) 
+            zsumt2 = tn(ji, jj,21) * e2u(ji-1, jj) * fse3u(ji-1, jj,21) * zu3_ms(21)
+            zsums2 = sn(ji, jj,21) * e2u(ji-1, jj) * fse3u(ji-1, jj,21) * zu3_ms(21)
+         END DO
+      END DO
+      
+      ! west Gibraltar deeper vertical sum of transport* S,T
+      DO  jk =  21, 22 
+         DO jj = mj0(101), mj1(101) 
+            DO ji = mi0(139), mi1(139) 
+               zsumt3 = zsumt3 + tn(ji, jj,jk) * e2u(ji, jj) * fse3u(ji, jj,jk) * zu1_ms(jk)
+               zsums3 = zsums3 + sn(ji, jj,jk) * e2u(ji, jj) * fse3u(ji, jj,jk) * zu1_ms(jk)
+            END DO
+         END DO
+      END DO
+
+      ! Total transport = 0.
+      zsumt4 = zsumt2 + zsumt1 - zsumt - zsumt3
+      zsums4 = zsums2 + zsums1 - zsums - zsums3
+
+      ! Temperature and Salinity at West gibraltar , Level 22
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zt = zsumt4 / ( zu2_ms(22) * e2u(ji-1, jj) * fse3u(ji-1, jj, 22) )
+            zs = zsums4 / ( zu2_ms(22) * e2u(ji-1, jj) * fse3u(ji-1, jj, 22) )
+         END DO
+      END DO
+      
+      ! New Temperature and Salinity trend at West Gibraltar
+      ! ----------------------------------------------------
+
+      ! south point 	
+      DO jk = 1, 22
+         DO jj = mj0(101), mj1(101) 
+            DO ji = mi0(139), mi1(139) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji, jj) * fse3u(ji, jj,jk)
+               ta(ji, jj,jk) = ta(ji, jj,jk) - ( 1. / zvt ) * zsu * zu1_ms(jk) * tn(ji, jj,jk)
+               sa(ji, jj,jk) = sa(ji, jj,jk) - ( 1. / zvt ) * zsu * zu1_ms(jk) * sn(ji, jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! north point 
+      DO jk = 15, 20
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(139), mi1(139) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji, jj) * fse3u(ji, jj,jk)
+               ta(ji, jj,jk) = ta(ji, jj,jk) - ( 1. / zvt ) * zsu * zu2_ms(jk) * tn(ji, jj-1,jk)
+               sa(ji, jj,jk) = sa(ji, jj,jk) - ( 1. / zvt ) * zsu * zu2_ms(jk) * sn(ji, jj-1,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Gibraltar outflow, north point deeper
+      jk =  22
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(139), mi1(139) 
+            zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+            zsu = e2u(ji, jj) * fse3u(ji, jj,jk)
+            ta(ji, jj,jk) = ta(ji, jj,jk) - ( 1. / zvt ) * zsu * zu2_ms(jk) * zt
+            sa(ji, jj,jk) = sa(ji, jj,jk) - ( 1. / zvt ) * zsu * zu2_ms(jk) * zs
+         END DO
+      END DO
+
+
+      ! New Temperature and Salinity at East Gibraltar 
+      ! ----------------------------------------------
+
+      ! surface	
+      DO jk = 1, 14
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(141), mi1(141) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji-1, jj) * fse3u(ji-1, jj,jk)
+               ta(ji, jj,jk) = ta(ji, jj,jk) + ( 1. / zvt ) * zsu * zu3_ms(jk) * tn(ji-2, jj-1,jk)
+               sa(ji, jj,jk) = sa(ji, jj,jk) + ( 1. / zvt ) * zsu * zu3_ms(jk) * sn(ji-2, jj-1,jk)
+            END DO
+         END DO
+      END DO
+      ! deeper
+      jk =  21
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(141), mi1(141) 
+            zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+            zsu = e2u(ji-1, jj) * fse3u(ji-1, jj,jk)
+            ta(ji, jj,jk) = ta(ji, jj,jk) + ( 1. / zvt ) * zsu * zu3_ms(jk) * tn(ji, jj,jk)
+            sa(ji, jj,jk) = sa(ji, jj,jk) + ( 1. / zvt ) * zsu * zu3_ms(jk) * sn(ji, jj,jk)
+         END DO
+      END DO
+
+   END SUBROUTINE tra_gibraltar
+
+
+   SUBROUTINE tra_hormuz
+      !!---------------------------------------------------------------------
+      !!               ***  ROUTINE tra_hormuz  ***
+      !!
+      !! ** Purpose :   Update the horizontal advective trend of tracers
+      !!        correction in Hormuz.
+      !!
+      !! ** Method :   We impose transport at Hormuz .
+      !!                                
+      !! ** history :
+      !!           !  02-11  (A. Bozec) Original code 
+      !!      8.5  !  02-11  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::  ji, jj, jk              ! dummy loop indices
+      REAL(wp) :: zsu, zvt
+      !!---------------------------------------------------------------------
+      
+      ! New trend at Hormuz strait
+      ! --------------------------
+      DO jk = 1, 8   
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e2u(ji-1,jj) * fse3u(ji-1,jj,jk)
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu_pg(jk) * tn(ji,jj,jk) 
+               sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu_pg(jk) * sn(ji,jj,jk) 
+            END DO
+         END DO
+      END DO
+      DO jk = 16, 18
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e2u(ji-1,jj) * fse3u(ji-1,jj,jk)
+               ta(ji,jj,jk) = ta(ji,jj,jk) + ( 1. / zvt ) * zsu * zu_pg(jk) * zthor(jk)
+               sa(ji,jj,jk) = sa(ji,jj,jk) + ( 1. / zvt ) * zsu * zu_pg(jk) * zshor(jk)
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE tra_hormuz
+
+
+   SUBROUTINE tra_cla_init
+      !!---------------------------------------------------------------------
+      !!               ***  ROUTINE tra_cla_init  ***
+      !!
+      !! ** Purpose :   Initialization of variables
+      !!
+      !! ** history :
+      !!      9.0  !  02-11  (A. Bozec) Original code
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::  ji, jj, jk              ! dummy loop indices
+      !!---------------------------------------------------------------------
+
+      ! Control print
+      ! -------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'tra_cla_init : cross land advection on tracer '
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+
+      ! Initialization at Bab el Mandeb
+      ! -------------------------------
+
+      ! imposed transport
+      zisw_rs = 0.4e6        ! inflow surface water
+      zurw_rs = 0.2e6        ! upper recirculation water
+!!Alex      zbrw_rs = 1.2e6        ! bottom  recirculation water
+      zbrw_rs = 0.5e6        ! bottom  recirculation water
+
+      ! initialization of the velocity at Bab el Mandeb
+      zu1_rs_i(:) = 0.e0      ! velocity profile at 161,88 South point
+      zu2_rs_i(:) = 0.e0      ! velocity profile at 161,87 North point
+      zu3_rs_i(:) = 0.e0      ! velocity profile at 160,88 East  point
+
+      ! velocity profile at 161,88 East Bab el Mandeb North point 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1, 8                                      
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu1_rs_i(jk) = -( zisw_rs / 8. ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )     
+            END DO
+         END DO
+      END DO
+
+      ! recirculation water 
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zu1_rs_i(20) = -(           zurw_rs ) / ( e2u(ji,jj) * fse3u(ji,jj,20) )
+            zu1_rs_i(21) = -( zbrw_rs - zurw_rs ) / ( e2u(ji,jj) * fse3u(ji,jj,21) )
+         END DO
+      END DO
+      
+      ! velocity profile at 161,87 East Bab el Mandeb South point
+      DO jj = mj0(87), mj1(87) 
+         DO ji = mi0(160), mi1(160) 
+            zu2_rs_i(21) =  ( zbrw_rs + zisw_rs ) / ( e2u(ji,jj) * fse3u(ji,jj,21) )
+         END DO
+      END DO
+
+      ! velocity profile at 161, 88 West Bab el Mandeb 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  10                                     
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu3_rs_i(jk) =  ( zisw_rs / 10. ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      ! deeper
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zu3_rs_i(16)  = - zisw_rs /( e1v(ji,jj) * fse3v(ji,jj,16) )
+         END DO
+      END DO
+
+
+      ! Initialization at Gibraltar
+      ! ---------------------------
+
+      ! imposed transport
+      zisw_ms = 0.8e6         ! atlantic-mediterranean  water
+      zmrw_ms = 0.7e6         ! middle recirculation water
+      zurw_ms = 2.5e6         ! upper  recirculation water 
+      zbrw_ms = 3.5e6         ! bottom recirculation water 
+
+      ! initialization of the velocity
+      zu1_ms_i(:) = 0.e0       ! velocity profile at 139,101 South point
+      zu2_ms_i(:) = 0.e0       ! velocity profile at 139,102 North point
+      zu3_ms_i(:) = 0.e0       ! velocity profile at 141,102 East  point
+
+      ! velocity profile at 139,101  South point
+      DO jk = 1, 14                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms_i(jk) = ( zisw_ms / 14. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk)) 
+            END DO
+         END DO
+      END DO
+
+      ! middle recirculation ( uncounting in the balance )
+      DO jk = 15, 20                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms_i(jk) = ( zmrw_ms / 6. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu1_ms_i(21) =  (           zurw_ms ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,21) )
+            zu1_ms_i(22) =  ( zbrw_ms - zurw_ms ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,22) )
+         END DO
+      END DO
+
+      ! velocity profile at 139,102  North point
+      ! middle recirculation ( uncounting in the balance )
+      DO jk = 15, 20                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu2_ms_i(jk) = -( zmrw_ms / 6. ) / ( e2u(ji-1, jj) * fse3u(ji-1, jj,jk) ) 
+            END DO
+         END DO
+      END DO 
+
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu2_ms_i(22) = -( zisw_ms + zbrw_ms ) / ( e2u(ji-1, jj) * fse3u(ji-1, jj,22) )
+         END DO
+      END DO 
+
+      ! profile at East Gibraltar   
+      ! velocity profile at 141,102 
+      DO  jk = 1, 14                     
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu3_ms_i(jk) =  ( zisw_ms / 14. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      ! deeper 
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu3_ms_i(21) = -zisw_ms / ( e2u(ji, jj) * fse3u(ji, jj,21) )
+         END DO
+      END DO
+
+
+      ! Initialization at Hormuz
+      ! ------------------------
+
+      ! imposed transport
+      zisw_pg = 4. * 0.25e6      ! surface and bottom  water
+
+      ! initialization of the velocity
+      zu_pg(:) = 0.e0       ! velocity profile at 139,101 South point
+
+      ! Velocity profile 
+      DO jk = 1, 8 
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zu_pg(jk) = -( zisw_pg / 8. ) /  ( e2u(ji-1,jj) * fse3u(ji-1,jj,jk) )
+            END DO
+         END DO
+      END DO
+     DO jk = 16, 18
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zu_pg(jk) =  ( zisw_pg / 3. )  / ( e2u(ji-1,jj) * fse3u(ji-1,jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      ! Temperature and Salinity at Hormuz
+      zthor(:) = 0.e0
+      zshor(:) = 0.e0
+
+      zthor(16) = 18.4
+      zshor(16) = 36.27
+      !
+      zthor(17) = 17.8
+      zshor(17) = 36.4
+      !
+      zthor(18) = 16.
+      zshor(18) = 36.27
+ 
+   END SUBROUTINE tra_cla_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                              NO cross land advection
+   !!----------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+CONTAINS
+   SUBROUTINE tra_cla( kt ) 
+      INTEGER, INTENT(in) ::   kt    ! ocean time-step indice
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_cla : No use of cross land advection'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+   END SUBROUTINE tra_cla
+#endif
+
+   !!======================================================================
+END MODULE cla
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_div.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_div.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_div.F90	(revision 1844)
@@ -0,0 +1,541 @@
+MODULE cla_div
+   !!==============================================================================
+   !!                    ***  MODULE  cla_div  ***
+   !! Ocean diagnostic variable : specific update of the horizontal divergence
+   !!                             CAUTION: Specific to ORCA_R2
+   !!==============================================================================
+#if defined key_orca_r2
+   !!----------------------------------------------------------------------
+   !!   'key_orca_r2'                                 global ocean model R2
+   !!----------------------------------------------------------------------
+   !!   div_cla      : 
+   !!   div_bab_el_mandeb
+   !!   div_gibraltar
+   !!   div_hormuz
+   !!   div_cla_init :
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Module variables
+   REAL(wp) :: zempmed, zempred       ! EMP of Mediterranean and Red Sea 
+
+   REAL(wp) :: zisw_rs, zbrw_rs, zurw_rs          ! imposed transport at Red Sea
+   REAL(wp) :: zisw_ms, zbrw_ms, zurw_ms, zmrw_ms ! imposed transport at Mediterranean Sea
+   REAL(wp) :: zisw_pg, zbrw_pg                   ! imposed transport at Persic Gulf
+
+   REAL(wp), DIMENSION (jpk) ::   &
+      zu1_rs_i, zu2_rs_i, zu3_rs_i,                   & ! Red Sea velocities
+      zu1_ms_i, zu2_ms_i, zu3_ms_i,                   & ! Mediterranean Sea velocities
+      zu_pg                                             ! Persic Gulf velocities
+   
+   !! * Routine accessibility
+   PUBLIC div_cla     ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE div_cla ( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE div_cla  ***
+      !!
+      !! ** Purpose :   update the horizontal divergence of the velocity field
+      !!      for at some straits ( Gibraltar, Bab el Mandeb and Hormuz ).
+      !!
+      !! ** Method  :   With imposed transport at each strait, we compute 
+      !!      corresponding velocities and update horizontal divergence.
+      !!        Apply lateral boundary conditions on hdivn through a call
+      !!      to routine lbc_lnk.
+      !!
+      !! ** Action  :   update hdivn array : the now horizontal divergence
+      !!
+      !! History :
+      !!   8.5  !  02-11 (A. Bozec)  Free form, F90
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!----------------------------------------------------------------------
+
+      ! Correction of the Divergence at some straits
+            
+      IF( kt == nit000 )     CALL div_cla_init    ! Initialization
+
+      CALL div_bab_el_mandeb                        ! New divergence at Bab el Mandeb 
+
+      CALL div_gibraltar                            ! New divergence at Gibraltar
+
+      CALL div_hormuz                               ! Hormuz Strait ( persian Gulf)
+
+      ! Lateral boundary conditions on hdivn
+      CALL lbc_lnk( hdivn, 'T', 1. )
+
+   END SUBROUTINE div_cla
+
+   SUBROUTINE div_bab_el_mandeb
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE div_bab_el_mandeb  ***
+      !!       
+      !! ** Purpose :   Update  the now horizontal divergence of the velocity 
+      !!     field in Bab el Mandeb ( Red Sea strait ).
+      !!
+      !! ** Method  :   Set the velocity field at each side of the strait :
+      !!                                          |
+      !!            |/ \|            N          |\ /|
+      !!            |_|_|______      |          |___|______
+      !!        88  |   |<-       W - - E    88 |   |<-
+      !!        87  |___|______      |       87 |___|->____
+      !!             160 161         S           160 161 
+      !!       horizontal view                horizontal view
+      !!          surface                        depth
+      !!      The now divergence is given by :
+      !!         hdivn = 1/(e1t*e2t) [ di(e2u  un) + dj(e1v  vn) ]
+      !!
+      !! ** History :
+      !!           !         (A. Bozec) Original code 
+      !!      8.5  !  02-11  (A. Bozec) F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER  :: ji, jj, jk   ! dummy loop indices
+      REAL(wp) :: zsu, zvt, zwei   ! temporary scalar
+      REAL(wp), DIMENSION (jpk) ::  zu1_rs, zu2_rs, zu3_rs
+      !!---------------------------------------------------------------------
+      
+      ! EMP on the Red Sea 
+      ! ------------------
+
+      zempred = 0.e0
+      zwei = 0.e0
+      DO jj = mj0(87), mj1(96)
+         DO ji = mi0(148), mi1(160) 
+            zwei    = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempred = zempred + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempred )      ! sum with other processors value
+
+
+      ! convert in m3
+      zempred = zempred * 1.e-3         
+
+      ! Velocity profile at each point
+      ! ------------------------------
+
+      zu1_rs(:) = zu1_rs_i(:)
+      zu2_rs(:) = zu2_rs_i(:)
+      zu3_rs(:) = zu3_rs_i(:)
+
+      ! velocity profile at 161,88 North point 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  8                                      
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu1_rs(jk) = zu1_rs(jk) - ( zempred / 8. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      ! velocity profile at 160,88 North  point
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  10                                     
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu3_rs(jk) = zu3_rs(jk) + ( zempred / 10. ) / ( e1v(ji, jj) * fse3v(ji, jj,jk) )
+            END DO
+         END DO
+      END DO
+       
+      ! Divergence at each point of the straits
+      ! ---------------------------------------
+
+      ! compute the new divergence at 161,88 
+      DO jk = 1, 21
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(161), mi1(161) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji-1, jj) * fse3u(ji-1, jj,jk)
+               hdivn(ji, jj  ,jk) = hdivn(ji, jj  ,jk) - ( 1. / zvt ) * zsu * zu1_rs(jk)
+            END DO
+         END DO
+      END DO
+
+      ! compute the new divergence at 161,87 
+      DO jk = 1, 21
+         DO jj = mj0(87), mj1(87) 
+            DO ji = mi0(161), mi1(161) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji-1, jj) * fse3u(ji-1, jj,jk)
+               hdivn(ji, jj,jk) = hdivn(ji, jj,jk) - ( 1. / zvt ) * zsu * zu2_rs(jk)
+            END DO
+         END DO
+      END DO
+
+      ! compute the divergence at 160,89 
+      DO jk = 1, 18
+         DO jj = mj0(89), mj1(89) 
+            DO ji = mi0(160), mi1(160) 
+               zvt = e1t(ji, jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e1v(ji, jj-1) * fse3v(ji, jj-1,jk)
+               hdivn(ji, jj,jk) = hdivn(ji, jj,jk) - ( 1. / zvt ) * zsu * zu3_rs(jk)
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE div_bab_el_mandeb
+
+   SUBROUTINE div_gibraltar
+      !! -------------------------------------------------------------------
+      !!                 ***  ROUTINE div_gibraltar  ***
+      !!        
+      !! ** Purpose :   update the now horizontal divergence of the velocity 
+      !!     field in Gibraltar.
+      !!
+      !! ** Method :
+      !!          ________________      N        ________________
+      !! 102           |    |->         |           <-|    |<-
+      !! 101      ___->|____|_____   W - - E     ___->|____|_____
+      !!           139   140  141       |         139   140  141
+      !!          horizontal view       S        horizontal view
+      !!            surface                          depth
+      !!      The now divergence is given by :
+      !!         hdivn = 1/(e1t*e2t) [ di(e2u  un) + dj(e1v  vn) ]
+      !!
+      !! ** History :
+      !!           !         (A. Bozec) Original code 
+      !!      8.5  !  02-10  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER  :: ji, jj, jk   ! dummy loop indices
+      REAL(wp) :: zsu, zvt
+      REAL(wp) :: zwei
+      REAL(wp), DIMENSION (jpk) ::  zu1_ms, zu2_ms, zu3_ms
+      !!---------------------------------------------------------------------
+      
+      ! EMP on the Mediterranean Sea 
+      ! ----------------------------
+
+      zempmed = 0.e0
+      zwei = 0.e0
+      DO jj = mj0(96), mj1(110)
+         DO ji = mi0(141),mi1(181)
+            zwei    = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempmed = zempmed + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempmed )      ! sum with other processors value
+
+      ! minus 2 points in Red Sea and 3 in Atlantic 
+      DO jj = mj0(96), mj1(96)
+         DO ji = mi0(148),mi1(148)
+            zempmed = zempmed -  emp(ji  , jj) * tmask(ji  , jj,1) * e1t(ji  , jj) * e2t(ji  , jj)   &
+                              -  emp(ji+1, jj) * tmask(ji+1, jj,1) * e1t(ji+1, jj) * e2t(ji+1, jj)   
+         END DO
+      END DO
+
+      ! convert in m3
+      zempmed = zempmed * 1.e-3
+
+      ! Velocity profile at each point
+      ! ------------------------------
+
+      zu1_ms(:) = zu1_ms_i(:)
+      zu2_ms(:) = zu2_ms_i(:)
+      zu3_ms(:) = zu3_ms_i(:)
+
+      ! velocity profile at 139,101 South point 
+      ! we imposed zisw + EMP above the Mediterranean Sea 
+      DO jk = 1, 14                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms(jk) =  zu1_ms(jk) + ( zempmed / 14. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk) ) 
+            END DO
+         END DO
+      END DO
+      
+      ! velocity profile at 141,102  East point
+      ! flux in surface inflow of the Atlantic ocean + EMP   
+      DO  jk = 1, 14                     
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu3_ms(jk) = zu3_ms(jk) +  ( zempmed / 14. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) ) 
+            END DO
+         END DO
+      END DO
+     
+      ! Divergence at each point of the straits
+      ! ---------------------------------------
+
+      ! compute the new divergence at 139,101 South point  
+      DO jk = 1, jpk
+         DO jj = mj0(101), mj1(101) 
+            DO ji = mi0(139), mi1(139) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji, jj) * fse3u(ji, jj,jk)
+               hdivn(ji, jj,jk) = hdivn(ji, jj,jk) + ( 1. / zvt ) * zsu * zu1_ms(jk) 
+            END DO
+         END DO
+      END DO
+
+      ! compute the new divergence at 139,102 deep North point
+      DO jk = 1, jpk
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(139), mi1(139) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji, jj) * fse3u(ji, jj,jk)
+               hdivn(ji, jj,jk) = hdivn(ji, jj,jk) + ( 1. / zvt ) * zsu * zu2_ms(jk) 
+            END DO
+         END DO
+      END DO
+
+      ! compute the divergence at 141,102 East point
+      DO jk = 1, jpk
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(141), mi1(141) 
+               zvt = e1t(ji, jj) * e2t(ji, jj) * fse3t(ji, jj,jk)
+               zsu = e2u(ji-1, jj) * fse3u(ji-1, jj,jk)
+               hdivn(ji, jj,jk) = hdivn(ji, jj,jk) - ( 1. / zvt ) * zsu * zu3_ms(jk)
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE div_gibraltar
+
+   SUBROUTINE div_hormuz
+      !! -------------------------------------------------------------------
+      !!                   ***  ROUTINE div_hormuz  ***
+      !!              
+      !! ** Purpose :   update the now horizontal divergence of the velocity 
+      !!     field in Hormuz ( Persic Gulf strait ) .
+      !!
+      !! ** Method :
+      !!      The now divergence is given by :
+      !!         hdivn = 1/(e1t*e2t) [ di(e2u  un) + dj(e1v  vn) ]
+      !!
+      !! ** History :
+      !!           !         (A. Bozec) Original code 
+      !!      8.5  !  02-10  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER  :: ji, jj, jk   ! dummy loop indices
+      REAL(wp) :: zsu, zvt     ! temporary scalars
+      !!---------------------------------------------------------------------
+
+      ! New divergence at Hormuz 
+      ! ------------------------
+      DO jk = 1, jpk
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zvt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+               zsu = e2u(ji-1,jj) * fse3u(ji-1,jj,jk)
+               hdivn(ji,jj,jk) = hdivn(ji,jj,jk) - ( 1. / zvt ) * zsu * zu_pg(jk)
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE div_hormuz
+
+
+   SUBROUTINE div_cla_init
+      !! -------------------------------------------------------------------
+      !!                   ***  ROUTINE div_cla_init  ***
+      !!           
+      !! ** Purpose :   Initialization of variables at all straits  
+      !!
+      !! ** History :
+      !!           !         (A. Bozec) Original code 
+      !!      8.5  !  02-10  (A. Bozec) F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER  :: ji, jj, jk   ! dummy loop indices
+      !!---------------------------------------------------------------------
+
+      ! Control print
+      ! -------------
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'divmod_cross_land : cross land advection on divergence '
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) ' '
+
+      ! Initialization at Bab el Mandeb
+      ! -------------------------------
+
+      ! imposed transport
+      zisw_rs = 0.4e6             ! inflow surface water
+      zurw_rs = 0.2e6             ! upper recirculation water
+!Alex      zbrw = 1.2e6        ! bottom  recirculation water
+      zbrw_rs = 0.5e6             ! bottom  recirculation water
+
+      ! initialization of the velocity
+      zu1_rs_i(:) = 0.e0          ! velocity profile at 161,88 South point
+      zu2_rs_i(:) = 0.e0          ! velocity profile at 161,87 North point
+      zu3_rs_i(:) = 0.e0          ! velocity profile at 160,88 East  point
+
+      ! velocity profile at 161,88 North point 
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  8                                      
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu1_rs_i(jk) = -( zisw_rs / 8. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      ! recirculation water 
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zu1_rs_i(20) =            - zurw_rs   / ( e2u(ji, jj) * fse3u(ji, jj,20) )
+            zu1_rs_i(21) = -( zbrw_rs - zurw_rs ) / ( e2u(ji, jj) * fse3u(ji, jj,21) )
+         END DO
+      END DO
+      
+      ! velocity profile at 161,87 South point
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zu2_rs_i(21) =  ( zbrw_rs + zisw_rs ) / ( e2u(ji, jj-1 ) * fse3u(ji, jj-1,21) )
+         END DO
+      END DO
+
+      ! velocity profile at 160,88 North  point
+      ! we imposed zisw_rs + EMP above the Red Sea 
+      DO jk = 1,  10                                     
+         DO jj = mj0(88), mj1(88) 
+            DO ji = mi0(160), mi1(160) 
+               zu3_rs_i(jk) = ( zisw_rs / 10. ) / ( e1v(ji, jj) * fse3v(ji, jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      ! deeper
+      DO jj = mj0(88), mj1(88) 
+         DO ji = mi0(160), mi1(160) 
+            zu3_rs_i(16)  = - zisw_rs / ( e1v(ji, jj) * fse3v(ji, jj,16) )
+         END DO
+      END DO
+      
+
+      ! Initialization at Gibraltar
+      ! ---------------------------
+
+      ! imposed transport
+      zisw_ms = 0.8e6             ! inflow surface  water
+      zmrw_ms = 0.7e6             ! middle recirculation water
+      zurw_ms = 2.5e6             ! upper  recirculation water
+      zbrw_ms = 3.5e6             ! bottom recirculation water
+
+      ! initialization of the velocity
+      zu1_ms_i(:) = 0.e0          ! velocity profile at 139,101 South point
+      zu2_ms_i(:) = 0.e0          ! velocity profile at 139,102 North point
+      zu3_ms_i(:) = 0.e0          ! velocity profile at 141,102 East  point
+
+      ! velocity profile at 139,101 South point 
+      DO jk = 1, 14                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms_i(jk) =  ( zisw_ms / 14. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      ! recirculation water 
+      DO jk = 15, 20                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu1_ms_i(jk) =  ( zmrw_ms / 6. ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu1_ms_i(21) =  (           zurw_ms ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,21) )
+            zu1_ms_i(22) =  ( zbrw_ms - zurw_ms ) / ( e2u(ji-1, jj-1) * fse3u(ji-1, jj-1,22) )
+         END DO
+      END DO
+      
+      ! velocity profile at 139,102 North point
+      DO jk = 15, 20                      
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu2_ms_i(jk) = -( zmrw_ms / 6. ) / ( e2u(ji-1, jj) * fse3u(ji-1, jj,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      ! outflow of Mediterranean sea + recirculation
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu2_ms_i(22) = -( zisw_ms + zbrw_ms ) / ( e2u(ji-1, jj) * fse3u(ji-1, jj,22) )
+         END DO
+      END DO
+      
+      ! velocity profile at 141,102  East point
+      ! flux in surface inflow of the Atlantic ocean    
+      DO  jk = 1, 14                     
+         DO jj = mj0(102), mj1(102) 
+            DO ji = mi0(140), mi1(140) 
+               zu3_ms_i(jk) =  ( zisw_ms / 14. ) / ( e2u(ji, jj) * fse3u(ji, jj,jk) ) 
+            END DO
+         END DO
+      END DO
+
+      ! deeper 
+      DO jj = mj0(102), mj1(102) 
+         DO ji = mi0(140), mi1(140) 
+            zu3_ms_i(21) = - zisw_ms / ( e2u(ji, jj) * fse3u(ji, jj,21) )
+         END DO
+      END DO
+
+      ! Initialization at Hormuz
+      ! ------------------------
+
+      ! imposed transport
+      zisw_pg = 4. * 0.25e6       ! inflow surface  water
+      zbrw_pg = 4. * 0.25e6       ! bottom recirculation water
+
+      ! initialization of the velocity
+      zu_pg(:) = 0.e0           ! velocity profile at 172,94 
+
+      ! velocity profile 
+      DO jk = 1, 8 
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zu_pg(jk) = -( zisw_pg / 8. ) / ( e2u(ji-1,jj) * fse3u(ji-1,jj, jk) )
+            END DO
+         END DO
+      END DO
+
+      DO jk = 16, 18
+         DO jj = mj0(94), mj1(94) 
+            DO ji = mi0(172), mi1(172) 
+               zu_pg(jk) =  ( zbrw_pg / 3. ) / ( e2u(ji-1,jj) * fse3u(ji-1,jj, jk) )
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE div_cla_init
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                            Dummy module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE div_cla( kt )
+      WRITE(*,*) 'div_cla: You should have not see this print! error?', kt
+   END SUBROUTINE div_cla
+#endif
+   
+   !!======================================================================
+END MODULE cla_div
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_dynspg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_dynspg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/cla_dynspg.F90	(revision 1844)
@@ -0,0 +1,241 @@
+MODULE cla_dynspg
+   !!======================================================================
+   !!                       ***  cla_dynspg  ***
+   !!======================================================================
+   !!   dyn_spg      : update the momentum trend with the surface pressure
+   !!                  gradient in the free surface constant volume case
+   !!                  with vector optimization
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE zdf_oce         ! ocean vertical physics
+   USE obc_oce         ! Lateral open boundary condition
+   USE sol_oce         ! solver variables
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE phycst          ! physical constants
+   USE solpcg          ! preconditionned conjugate gradient solver
+   USE solsor          ! Successive Over-relaxation solver
+   USE obcdyn          ! ocean open boundary condition (obc_dyn routines)
+   USE obcvol          ! ocean open boundary condition (obc_vol routines)
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC dyn_spg_cla   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dyn_spg_cla( kt ) 
+      !!----------------------------------------------------------------------
+      !!              ***  routine dyn_spg_cross_land  ***
+      !!
+      !! ** Purpose :
+      !!
+      !! ** Method :
+      !!
+      !! ** Action :
+      !!
+      !! History :
+      !!        !         (A. Bozec)  Original code
+      !!   8.5  !  02-11  (A. Bozec)  F90: Free form and module
+      !!---------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      INTEGER  ::   ii0, ii1, ij0, ij1        ! temporary integer
+      REAL(wp) ::    &    
+         zempmed, zempred,   &                ! EMP on Med Sea ans Red Sea
+         zwei,   &                            !              
+         zisw_rs, zurw_rs, zbrw_rs,      &    ! imposed transport Red sea
+         zisw_ms, zurw_ms, zbrw_ms, zmrw_ms   ! imposed transport Med Sea
+      !!----------------------------------------------------------------------
+
+      ! Different velocities for straits ( Gibraltar, Bab el Mandeb...)
+         
+      ! Control print
+      ! -------------
+      IF( kt == nit000 ) THEN 
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dynspg_cross_land : cross land advection on surface '
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~   pressure '
+         IF(lwp) WRITE(numout,*) ' '
+      ENDIF
+
+      ! EMP on Mediterranean Sea and Red Sea 
+      ! ------------------------------------
+      ! compute the emp in Mediterranean Sea
+      zempmed = 0.e0
+      zwei = 0.e0
+      ij0 =  96   ;   ij1 = 110
+      ii0 = 141   ;   ii1 = 181
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            zwei    = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempmed = zempmed + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempmed )      ! sum with other processors value
+
+      ! minus 2 points in Red Sea and 3 in Atlantic 
+      ij0 =  96   ;   ij1 =  96
+      ii0 = 148   ;   ii1 = 148
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            zempmed = zempmed - emp(ji  ,jj) * tmask(ji  ,jj,1) * e1t(ji  ,jj) * e2t(ji  ,jj)   &
+               &              - emp(ji+1,jj) * tmask(ji+1,jj,1) * e1t(ji+1,jj) * e2t(ji+1,jj)   
+         END DO
+      END DO
+      ! we convert in m3
+      zempmed = zempmed * 1.e-3
+
+      ! compute the emp in Red Sea   
+      zempred = 0.e0
+      zwei = 0.e0
+      ij0 =  87   ;   ij1 =  96
+      ii0 = 148   ;   ii1 = 160
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            zwei      = tmask(ji,jj,1) * e1t(ji,jj) * e2t(ji,jj)
+            zempred   = zempred + emp(ji,jj) * zwei
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( zempred )      ! sum with other processors value
+
+      ! we convert in m3
+      zempred = zempred * 1.e-3
+
+      ! New Transport at Bab el Mandeb and Gibraltar
+      ! --------------------------------------------
+
+      ! imposed transport at Bab el Mandeb
+      zisw_rs = 0.4e6        ! inflow surface water
+      zurw_rs = 0.2e6        ! upper recirculation water
+!!Alex      zbrw_rs = 1.2e6        ! bottom  recirculation water
+      zbrw_rs = 0.5e6        ! bottom  recirculation water
+
+      ! imposed transport at Gibraltar
+      zisw_ms  = 0.8e6          ! atlantic-mediterranean  water
+      zmrw_ms  = 0.7e6          ! middle recirculation water
+      zurw_ms  = 2.5e6          ! upper  recirculation water 
+      zbrw_ms  = 3.5e6          ! bottom recirculation water 
+
+      ! Different velocities for straits ( Gibraltar, Bab el Mandeb )
+      ! -------------------------------------------------------------
+
+      ! Bab el Mandeb
+      ! -------------
+      ! 160,88 north point Bab el Mandeb
+      ij0 =  88   ;   ij1 =  88
+      ii0 = 160   ;   ii1 = 160
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj  ,: ) = 0.e0  !  North East Bab el Mandeb 
+         END DO
+      END DO
+      !                              ! surface
+      DO jk = 1,  8                                      
+         DO jj = mj0(ij0), mj1(ij1)
+            DO ji = mi0(ii0),mi1(ii1)
+               ua(ji, jj,jk) = -( ( zisw_rs + zempred ) / 8. ) / ( e2u(ji, jj) * fse3t(ji, jj,jk) )     
+            END DO
+         END DO
+      END DO
+      !                              ! deeper
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji, jj,21) = - zbrw_rs / ( e2u(ji, jj) * fse3t(ji, jj,21) )
+         END DO
+      END DO
+
+      ! 160,87 south point Bab el Mandeb
+      ij0 =  87   ;   ij1 =  87
+      ii0 = 160   ;   ii1 = 160
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj  ,: ) = 0.e0  !  South East Bab el Mandeb 
+         END DO
+      END DO
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji, jj,21) =  ( zisw_rs + zbrw_rs ) / ( e2u(ji,jj )*fse3t(ji, jj,21) )      
+         END DO
+      END DO
+
+      ! Gibraltar
+      ! ---------
+
+      ! initialisation of velocity at concerned points 
+      ! 139, 101 south point in Gibraltar 
+      ij0 = 101   ;   ij1 = 101
+      ii0 = 139   ;   ii1 = 139
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj  ,: ) = 0.e0  !  South West Gibraltar
+            ua(ji,jj+1,: ) = 0.e0  !  North West Gibraltar
+         END DO
+      END DO
+      !                            ! surface
+      DO jk = 1, 14                      
+         DO jj = mj0(ij0), mj1(ij1)
+            DO ji = mi0(ii0),mi1(ii1)
+               ua(ji,jj,jk) =  ( ( zisw_ms + zempmed ) / 14. ) / ( e2u(ji,jj) * fse3t(ji,jj,jk) ) 
+            END DO
+         END DO
+      END DO
+      !                            ! middle circulation
+      DO jk = 15, 20                      
+         DO jj = mj0(ij0), mj1(ij1)
+            DO ji = mi0(ii0),mi1(ii1)
+               ua(ji,jj,jk) =  ( zmrw_ms / 6. ) / ( e2u(ji,jj) * fse3t(ji,jj,jk) ) 
+            END DO
+         END DO
+      END DO
+      !                            ! deeper 
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj,21) =             zurw_ms   / ( e2u(ji,jj) * fse3t(ji,jj,21) )
+            ua(ji,jj,22) = ( zbrw_ms - zurw_ms ) / ( e2u(ji,jj) * fse3t(ji,jj,22) )
+         END DO
+      END DO
+
+      ! 139,102 north point in Gibraltar
+      ij0 = 102   ;   ij1 = 102
+      ii0 = 139   ;   ii1 = 139
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj  ,: ) = 0.e0  !  North West Gibraltar
+         END DO
+      END DO
+      DO jk = 15, 20                      
+         DO jj = mj0(ij0), mj1(ij1)
+            DO ji = mi0(ii0),mi1(ii1)
+               ua(ji,jj,jk) = -( zmrw_ms / 6. ) / ( e2u(ji,jj) * fse3t(ji,jj,jk) ) 
+            END DO
+         END DO
+      END DO
+      !                            ! deeper
+      DO jj = mj0(ij0), mj1(ij1)
+         DO ji = mi0(ii0),mi1(ii1)
+            ua(ji,jj,22) = -( zisw_ms + zbrw_ms ) / ( e2u(ji,jj) * fse3t(ji,jj,22) )
+         END DO
+      END DO
+
+   END SUBROUTINE dyn_spg_cla
+
+   !!======================================================================
+END MODULE cla_dynspg
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/istate.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/istate.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/istate.F90	(revision 1844)
@@ -0,0 +1,553 @@
+MODULE istate
+   !!======================================================================
+   !!                     ***  MODULE  istate  ***
+   !! Ocean state   :  initial state setting
+   !!=====================================================================
+   !! History :   4.0  !  89-12  (P. Andrich)  Original code
+   !!             5.0  !  91-11  (G. Madec)  rewritting
+   !!             6.0  !  96-01  (G. Madec)  terrain following coordinates
+   !!             8.0  !  01-09  (M. Levy, M. Ben Jelloul)  istate_eel
+   !!             8.0  !  01-09  (M. Levy, M. Ben Jelloul)  istate_uvg
+   !!             9.0  !  03-08  (G. Madec)  F90: Free form, modules
+   !!             9.0  !  03-09  (G. Madec, C. Talandier)  add EEL R5
+   !!             9.0  !  04-05  (A. Koch-Larrouy)  istate_gyre 
+   !!             9.0  !  06-07  (S. Masson)  distributed restart using iom
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   istate_init   : initial state setting
+   !!   istate_tem    : analytical profile for initial Temperature
+   !!   istate_sal    : analytical profile for initial Salinity
+   !!   istate_eel    : initial state setting of EEL R5 configuration
+   !!   istate_gyre   : initial state setting of GYRE configuration
+   !!   istate_uvg    : initial velocity in geostropic balance
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers 
+   USE dom_oce         ! ocean space and time domain 
+   USE daymod          ! 
+   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE zdf_oce         ! ocean vertical physics
+   USE phycst          ! physical constants
+   USE dtatem          ! temperature data                 (dta_tem routine)
+   USE dtasal          ! salinity data                    (dta_sal routine)
+   USE restart         ! ocean restart                   (rst_read routine)
+   USE in_out_manager  ! I/O manager
+   USE iom
+   USE c1d             ! re-initialization of u-v mask for the 1D configuration
+   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE domvvl          ! varying vertical mesh
+   USE dynspg_oce      ! pressure gradient schemes
+   USE dynspg_flt      ! pressure gradient schemes
+   USE dynspg_exp      ! pressure gradient schemes
+   USE dynspg_ts       ! pressure gradient schemes
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   istate_init   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE istate_init
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE istate_init  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracer fields.
+      !!----------------------------------------------------------------------
+      USE eosbn2          ! eq. of state, Brunt Vaisala frequency (eos     routine)
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'istate_ini : Initialization of the dynamics and tracers'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+      rhd  (:,:,:) = 0.e0
+      rhop (:,:,:) = 0.e0
+      rn2  (:,:,:) = 0.e0 
+
+      IF( ln_rstart ) THEN                    ! Restart from a file
+         !                                    ! -------------------
+         neuler = 1                              ! Set time-step indicator at nit000 (leap-frog)
+         CALL rst_read                           ! Read the restart file
+         CALL day_init                           ! model calendar (using both namelist and restart infos)
+      ELSE
+         !                                    ! Start from rest
+         !                                    ! ---------------
+         numror = 0                              ! define numror = 0 -> no restart file to read
+         neuler = 0                              ! Set time-step indicator at nit000 (euler forward)
+         CALL day_init                           ! model calendar (using both namelist and restart infos)
+         !                                       ! Initialization of ocean to zero
+         !     before fields       !       now fields          
+             ub   (:,:,:) = 0.e0   ;   un   (:,:,:) = 0.e0   ; sshb(:,:) = 0.e0
+             vb   (:,:,:) = 0.e0   ;   vn   (:,:,:) = 0.e0   ; sshn(:,:) = 0.e0
+             rotb (:,:,:) = 0.e0   ;   rotn (:,:,:) = 0.e0
+             hdivb(:,:,:) = 0.e0   ;   hdivn(:,:,:) = 0.e0
+         !
+         IF( cp_cfg == 'eel' ) THEN
+            CALL istate_eel                      ! EEL   configuration : start from pre-defined
+            !                                    !                       velocity and thermohaline fields
+         ELSEIF( cp_cfg == 'gyre' ) THEN         
+            CALL istate_gyre                     ! GYRE  configuration : start from pre-defined temperature
+            !                                    !                       and salinity fields 
+         ELSE
+            !                                    ! Other configurations: Initial temperature and salinity fields
+#if defined key_dtatem
+            CALL dta_tem( nit000 )                  ! read 3D temperature data
+            tb(:,:,:) = t_dta(:,:,:)                ! use temperature data read
+            tn(:,:,:) = t_dta(:,:,:)
+#else
+            IF(lwp) WRITE(numout,*)                 ! analytical temperature profile
+            IF(lwp) WRITE(numout,*)'             Temperature initialization using an analytic profile'
+            CALL istate_tem
+#endif
+#if defined key_dtasal
+            CALL dta_sal( nit000 )                  ! read 3D salinity data
+            sb(:,:,:) = s_dta(:,:,:)                ! use salinity data read
+            sn(:,:,:) = s_dta(:,:,:)
+#else
+            ! No salinity data
+            IF(lwp)WRITE(numout,*)                  ! analytical salinity profile
+            IF(lwp)WRITE(numout,*)'             Salinity initialisation using a constant value'
+            CALL istate_sal
+#endif
+         ENDIF
+
+         CALL eos( tb, sb, rhd, rhop )        ! before potential and in situ densities
+         
+         IF( ln_zps .AND. .NOT. lk_c1d )   &
+            &             CALL zps_hde( nit000, tb, sb, rhd,  &  ! Partial steps: before Horizontal DErivative
+            &                                  gtu, gsu, gru, &  ! of t, s, rd at the bottom ocean level
+            &                                  gtv, gsv, grv )
+         
+      ENDIF
+      !
+      IF( lk_agrif ) THEN
+         ! read free surface arrays in restart file
+         IF( ln_rstart ) THEN
+            IF( lk_dynspg_flt )   CALL flt_rst( nit000, 'READ' )      ! read or initialize the following fields
+            !                                                         ! gcx, gcxb for agrif_opa_init
+         ENDIF                                                        ! explicit case not coded yet with AGRIF
+      ENDIF
+      !
+   END SUBROUTINE istate_init
+
+
+   SUBROUTINE istate_tem
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE istate_tem  ***
+      !!   
+      !! ** Purpose :   Intialization of the temperature field with an 
+      !!      analytical profile or a file (i.e. in EEL configuration)
+      !!
+      !! ** Method  :   Use Philander analytic profile of temperature
+      !!
+      !! References :  Philander ???
+      !!----------------------------------------------------------------------
+      INTEGER :: ji, jj, jk
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'istate_tem : initial temperature profile'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               tn(ji,jj,jk) = (  ( ( 7.5 - 0.*ABS(gphit(ji,jj))/30. )   &
+                  &               *( 1.-TANH((fsdept(ji,jj,jk)-80.)/30.) )   &
+                  &            + 10.*(5000.-fsdept(ji,jj,jk))/5000.)  ) * tmask(ji,jj,jk)
+               tb(ji,jj,jk) = tn(ji,jj,jk)
+          END DO
+        END DO
+      END DO
+
+      IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
+         &                 1     , jpi   , 5     , 1     , jpk   ,   &
+         &                 1     , 1.    , numout                  )
+      !
+   END SUBROUTINE istate_tem
+
+
+   SUBROUTINE istate_sal
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE istate_sal  ***
+      !!
+      !! ** Purpose :   Intialize the salinity field with an analytic profile
+      !!
+      !! ** Method  :   Use to a constant value 35.5
+      !!              
+      !! ** Action  :   Initialize sn and sb
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zsal = 35.50_wp
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'istate_sal : initial salinity : ', zsal
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+      sn(:,:,:) = zsal * tmask(:,:,:)
+      sb(:,:,:) = sn(:,:,:)
+      
+   END SUBROUTINE istate_sal
+
+
+   SUBROUTINE istate_eel
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE istate_eel  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers for EEL R5
+      !!      configuration (channel with or without a topographic bump)
+      !!
+      !! ** Method  : - set temprature field
+      !!              - set salinity field
+      !!              - set velocity field including horizontal divergence
+      !!                and relative vorticity fields
+      !!----------------------------------------------------------------------
+      USE eosbn2     ! eq. of state, Brunt Vaisala frequency (eos     routine)
+      USE divcur     ! hor. divergence & rel. vorticity      (div_cur routine)
+      USE iom
+ 
+      INTEGER  ::   inum              ! temporary logical unit
+      INTEGER  ::   ji, jj, jk        ! dummy loop indices
+      INTEGER  ::   ijloc
+      REAL(wp) ::   zh1, zh2, zslope, zcst, zfcor   ! temporary scalars
+      REAL(wp) ::   zt1  = 15._wp,               &  ! surface temperature value (EEL R5)
+         &          zt2  =  5._wp,               &  ! bottom  temperature value (EEL R5)
+         &          zsal = 35.0_wp,              &  ! constant salinity (EEL R2, R5 and R6)
+         &          zueel = 0.1_wp                  ! constant uniform zonal velocity (EEL R5)
+      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   zssh  ! initial ssh over the global domain
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( jp_cfg ) 
+         !                                              ! ====================
+         CASE ( 5 )                                     ! EEL R5 configuration
+            !                                           ! ====================
+
+            ! set temperature field with a linear profile
+            ! -------------------------------------------
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: linear temperature profile'
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+            zh1 = gdept_0(  1  )
+            zh2 = gdept_0(jpkm1)
+
+            zslope = ( zt1 - zt2 ) / ( zh1 - zh2 )
+            zcst   = ( zt1 * ( zh1 - zh2) - ( zt1 - zt2 ) * zh1 ) / ( zh1 - zh2 )
+
+            DO jk = 1, jpk
+               tn(:,:,jk) = ( zt2 + zt1 * exp( - fsdept(:,:,jk) / 1000 ) ) * tmask(:,:,jk)
+               tb(:,:,jk) = tn(:,:,jk)
+            END DO
+
+            IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
+               &                 1     , jpi   , 5     , 1     , jpk   ,   &
+               &                 1     , 1.    , numout                  )
+
+            ! set salinity field to a constant value
+            ! --------------------------------------
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+            sn(:,:,:) = zsal * tmask(:,:,:)
+            sb(:,:,:) = sn(:,:,:)
+      
+
+            ! set the dynamics: U,V, hdiv, rot (and ssh if necessary)
+            ! ----------------
+            ! Start EEL5 configuration with barotropic geostrophic velocities 
+            ! according the sshb and sshn SSH imposed.
+            ! we assume a uniform grid (hence the use of e1t(1,1) for delta_y)
+            ! we use the Coriolis frequency at mid-channel.   
+    
+            ub(:,:,:) = zueel * umask(:,:,:)
+            un(:,:,:) = ub(:,:,:)
+            ijloc = mj0(INT(jpjglo-1)/2)
+            zfcor = ff(1,ijloc)
+
+            DO jj = 1, jpjglo
+               zssh(:,jj) = - (FLOAT(jj)- FLOAT(jpjglo-1)/2.)*zueel*e1t(1,1)*zfcor/grav 
+            END DO
+
+            IF(lwp) THEN
+               WRITE(numout,*) ' Uniform zonal velocity for EEL R5:',zueel
+               WRITE(numout,*) ' Geostrophic SSH profile as a function of y:'
+               WRITE(numout,'(12(1x,f6.2))') zssh(1,:)
+            ENDIF
+
+            DO jj = 1, nlcj
+               DO ji = 1, nlci
+                  sshb(ji,jj) = zssh( mig(ji) , mjg(jj) ) * tmask(ji,jj,1)
+               END DO
+            END DO
+            sshb(nlci+1:jpi,      :   ) = 0.e0      ! set to zero extra mpp columns
+            sshb(      :   ,nlcj+1:jpj) = 0.e0      ! set to zero extra mpp rows
+
+            sshn(:,:) = sshb(:,:)                   ! set now ssh to the before value
+
+            IF( nn_rstssh /= 0 ) THEN  
+               nn_rstssh = 0                           ! hand-made initilization of ssh 
+               CALL ctl_warn( 'istate_eel: force nn_rstssh = 0' )
+            ENDIF
+
+            ! horizontal divergence and relative vorticity (curl)
+            CALL div_cur( nit000 )
+
+            ! N.B. the vertical velocity will be computed from the horizontal divergence field
+            ! in istate by a call to wzv routine
+
+
+            !                                     ! ==========================
+         CASE ( 2 , 6 )                           ! EEL R2 or R6 configuration
+            !                                     ! ==========================
+ 
+            ! set temperature field with a NetCDF file
+            ! ----------------------------------------
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R2 or R6: read initial temperature in a NetCDF file'
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+            CALL iom_open ( 'eel.initemp', inum )
+            CALL iom_get ( inum, jpdom_data, 'initemp', tb ) ! read before temprature (tb)
+            CALL iom_close( inum )
+     
+            tn(:,:,:) = tb(:,:,:)                            ! set nox temperature to tb
+
+            IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
+               &                 1     , jpi   , 5     , 1     , jpk   ,   &
+               &                 1     , 1.    , numout                  )
+
+
+            ! set salinity field to a constant value
+            ! --------------------------------------
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+ 
+            sn(:,:,:) = zsal * tmask(:,:,:)
+            sb(:,:,:) = sn(:,:,:)
+
+            !                                    ! ===========================
+         CASE DEFAULT                            ! NONE existing configuration
+            !                                    ! ===========================
+            WRITE(ctmp1,*) 'EEL with a ', jp_cfg,' km resolution is not coded'
+            CALL ctl_stop( ctmp1 )
+
+      END SELECT
+
+   END SUBROUTINE istate_eel
+
+
+   SUBROUTINE istate_gyre
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE istate_gyre  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers for GYRE
+      !!      configuration (double gyre with rotated domain)
+      !!
+      !! ** Method  : - set temprature field
+      !!              - set salinity field
+      !!----------------------------------------------------------------------
+      INTEGER :: ji, jj, jk  ! dummy loop indices
+      INTEGER            ::   inum          ! temporary logical unit
+      INTEGER, PARAMETER ::   ntsinit = 0   ! (0/1) (analytical/input data files) T&S initialization
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( ntsinit)
+
+      CASE ( 0 )                  ! analytical T/S profil deduced from LEVITUS
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'istate_gyre : initial analytical T and S profil deduced from LEVITUS '
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  tn(ji,jj,jk) = (  16. - 12. * TANH( (fsdept(ji,jj,jk) - 400) / 700 )         )   &
+                       &           * (-TANH( (500-fsdept(ji,jj,jk)) / 150 ) + 1) / 2               &
+                       &       + (      15. * ( 1. - TANH( (fsdept(ji,jj,jk)-50.) / 1500.) )       &
+                       &                - 1.4 * TANH((fsdept(ji,jj,jk)-100.) / 100.)               &    
+                       &                + 7.  * (1500. - fsdept(ji,jj,jk)) / 1500.             )   & 
+                       &           * (-TANH( (fsdept(ji,jj,jk) - 500) / 150) + 1) / 2
+                  tn(ji,jj,jk) = tn(ji,jj,jk) * tmask(ji,jj,jk)
+                  tb(ji,jj,jk) = tn(ji,jj,jk)
+
+                  sn(ji,jj,jk) =  (  36.25 - 1.13 * TANH( (fsdept(ji,jj,jk) - 305) / 460 )  )  &
+                     &              * (-TANH((500 - fsdept(ji,jj,jk)) / 150) + 1) / 2          &
+                     &          + (  35.55 + 1.25 * (5000. - fsdept(ji,jj,jk)) / 5000.         &
+                     &                - 1.62 * TANH( (fsdept(ji,jj,jk) - 60.  ) / 650. )       &
+                     &                + 0.2  * TANH( (fsdept(ji,jj,jk) - 35.  ) / 100. )       &
+                     &                + 0.2  * TANH( (fsdept(ji,jj,jk) - 1000.) / 5000.)    )  &
+                     &              * (-TANH((fsdept(ji,jj,jk) - 500) / 150) + 1) / 2 
+                  sn(ji,jj,jk) = sn(ji,jj,jk) * tmask(ji,jj,jk)
+                  sb(ji,jj,jk) = sn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+      CASE ( 1 )                  ! T/S data fields read in dta_tem.nc/data_sal.nc files
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'istate_gyre : initial T and S read from dta_tem.nc/data_sal.nc files'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+         IF(lwp) WRITE(numout,*) '              NetCDF FORMAT'
+
+         ! Read temperature field
+         ! ----------------------
+         CALL iom_open ( 'data_tem', inum )
+         CALL iom_get ( inum, jpdom_data, 'votemper', tn ) 
+         CALL iom_close( inum )
+
+         tn(:,:,:) = tn(:,:,:) * tmask(:,:,:) 
+         tb(:,:,:) = tn(:,:,:)
+
+         ! Read salinity field
+         ! -------------------
+         CALL iom_open ( 'data_sal', inum )
+         CALL iom_get ( inum, jpdom_data, 'vosaline', sn ) 
+         CALL iom_close( inum )
+
+         sn(:,:,:)  = sn(:,:,:) * tmask(:,:,:) 
+         sb(:,:,:)  = sn(:,:,:)
+
+      END SELECT
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '              Initial temperature and salinity profiles:'
+         WRITE(numout, "(9x,' level   gdept_0   temperature   salinity   ')" )
+         WRITE(numout, "(10x, i4, 3f10.2)" ) ( jk, gdept_0(jk), tn(2,2,jk), sn(2,2,jk), jk = 1, jpk )
+      ENDIF
+
+   END SUBROUTINE istate_gyre
+
+
+   SUBROUTINE istate_uvg
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE istate_uvg  ***
+      !!
+      !! ** Purpose :   Compute the geostrophic velocities from (tn,sn) fields
+      !!
+      !! ** Method  :   Using the hydrostatic hypothesis the now hydrostatic 
+      !!      pressure is computed by integrating the in-situ density from the
+      !!      surface to the bottom.
+      !!                 p=integral [ rau*g dz ]
+      !!----------------------------------------------------------------------
+      USE dynspg          ! surface pressure gradient             (dyn_spg routine)
+      USE divcur          ! hor. divergence & rel. vorticity      (div_cur routine)
+      USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+
+      INTEGER ::   ji, jj, jk        ! dummy loop indices
+      INTEGER ::   indic             ! ???
+      REAL(wp) ::   zmsv, zphv, zmsu, zphu, zalfg     ! temporary scalars
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zprn     ! workspace
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*) 'istate_uvg : Start from Geostrophy'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+
+      ! Compute the now hydrostatic pressure
+      ! ------------------------------------
+
+      zalfg = 0.5 * grav * rau0
+      
+      zprn(:,:,1) = zalfg * fse3w(:,:,1) * ( 1 + rhd(:,:,1) )       ! Surface value
+
+      DO jk = 2, jpkm1                                              ! Vertical integration from the surface
+         zprn(:,:,jk) = zprn(:,:,jk-1)   &
+            &         + zalfg * fse3w(:,:,jk) * ( 2. + rhd(:,:,jk) + rhd(:,:,jk-1) )
+      END DO  
+
+      ! Compute geostrophic balance
+      ! ---------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vertor opt.
+               zmsv = 1. / MAX(  umask(ji-1,jj+1,jk) + umask(ji  ,jj+1,jk)   &
+                               + umask(ji-1,jj  ,jk) + umask(ji  ,jj  ,jk) , 1.  )
+               zphv = ( zprn(ji  ,jj+1,jk) - zprn(ji-1,jj+1,jk) ) * umask(ji-1,jj+1,jk) / e1u(ji-1,jj+1)   &
+                    + ( zprn(ji+1,jj+1,jk) - zprn(ji  ,jj+1,jk) ) * umask(ji  ,jj+1,jk) / e1u(ji  ,jj+1)   &
+                    + ( zprn(ji  ,jj  ,jk) - zprn(ji-1,jj  ,jk) ) * umask(ji-1,jj  ,jk) / e1u(ji-1,jj  )   &
+                    + ( zprn(ji+1,jj  ,jk) - zprn(ji  ,jj  ,jk) ) * umask(ji  ,jj  ,jk) / e1u(ji  ,jj  )
+               zphv = 1. / rau0 * zphv * zmsv * vmask(ji,jj,jk)
+
+               zmsu = 1. / MAX(  vmask(ji+1,jj  ,jk) + vmask(ji  ,jj  ,jk)   &
+                               + vmask(ji+1,jj-1,jk) + vmask(ji  ,jj-1,jk) , 1.  )
+               zphu = ( zprn(ji+1,jj+1,jk) - zprn(ji+1,jj  ,jk) ) * vmask(ji+1,jj  ,jk) / e2v(ji+1,jj  )   &
+                    + ( zprn(ji  ,jj+1,jk) - zprn(ji  ,jj  ,jk) ) * vmask(ji  ,jj  ,jk) / e2v(ji  ,jj  )   &
+                    + ( zprn(ji+1,jj  ,jk) - zprn(ji+1,jj-1,jk) ) * vmask(ji+1,jj-1,jk) / e2v(ji+1,jj-1)   &
+                    + ( zprn(ji  ,jj  ,jk) - zprn(ji  ,jj-1,jk) ) * vmask(ji  ,jj-1,jk) / e2v(ji  ,jj-1)
+               zphu = 1. / rau0 * zphu * zmsu * umask(ji,jj,jk)
+
+               ! Compute the geostrophic velocities
+               un(ji,jj,jk) = -2. * zphu / ( ff(ji,jj) + ff(ji  ,jj-1) )
+               vn(ji,jj,jk) =  2. * zphv / ( ff(ji,jj) + ff(ji-1,jj  ) )
+            END DO
+         END DO
+      END DO
+
+      IF(lwp) WRITE(numout,*) '         we force to zero bottom velocity'
+
+      ! Susbtract the bottom velocity (level jpk-1 for flat bottom case)
+      ! to have a zero bottom velocity
+
+      DO jk = 1, jpkm1
+         un(:,:,jk) = ( un(:,:,jk) - un(:,:,jpkm1) ) * umask(:,:,jk)
+         vn(:,:,jk) = ( vn(:,:,jk) - vn(:,:,jpkm1) ) * vmask(:,:,jk)
+      END DO
+
+      CALL lbc_lnk( un, 'U', -1. )
+      CALL lbc_lnk( vn, 'V', -1. )
+      
+      ub(:,:,:) = un(:,:,:)
+      vb(:,:,:) = vn(:,:,:)
+      
+      ! WARNING !!!!!
+      ! after initializing u and v, we need to calculate the initial streamfunction bsf.
+      ! Otherwise, only the trend will be computed and the model will blow up (inconsistency).
+      ! to do that, we call dyn_spg with a special trick:
+      ! we fill ua and va with the velocities divided by dt, and the streamfunction will be brought to the
+      ! right value assuming the velocities have been set up in one time step.
+      ! we then set bsfd to zero (first guess for next step is d(psi)/dt = 0.)
+      !  sets up s false trend to calculate the barotropic streamfunction.
+
+      ua(:,:,:) = ub(:,:,:) / rdt
+      va(:,:,:) = vb(:,:,:) / rdt
+
+      ! calls dyn_spg. we assume euler time step, starting from rest.
+      indic = 0
+      CALL dyn_spg( nit000, indic )       ! surface pressure gradient
+
+      ! the new velocity is ua*rdt
+
+      CALL lbc_lnk( ua, 'U', -1. )
+      CALL lbc_lnk( va, 'V', -1. )
+
+      ub(:,:,:) = ua(:,:,:) * rdt
+      vb(:,:,:) = va(:,:,:) * rdt
+      ua(:,:,:) = 0.e0
+      va(:,:,:) = 0.e0
+      un(:,:,:) = ub(:,:,:)
+      vn(:,:,:) = vb(:,:,:)
+       
+      ! Compute the divergence and curl
+
+      CALL div_cur( nit000 )            ! now horizontal divergence and curl
+
+      hdivb(:,:,:) = hdivn(:,:,:)       ! set the before to the now value
+      rotb (:,:,:) = rotn (:,:,:)       ! set the before to the now value
+      !
+   END SUBROUTINE istate_uvg
+
+   !!=====================================================================
+END MODULE istate
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbclnk.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbclnk.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbclnk.F90	(revision 1844)
@@ -0,0 +1,309 @@
+MODULE lbclnk
+   !!======================================================================
+   !!                       ***  MODULE  lbclnk  ***
+   !! Ocean        : lateral boundary conditions
+   !!=====================================================================
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if   defined key_mpp_mpi   ||   defined key_mpp_shmem
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'     OR      MPI massively parallel processing library
+   !!   'key_mpp_shmem'         SHMEM massively parallel processing library
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lbc_lnk      : generic interface for mpp_lnk_3d and mpp_lnk_2d
+   !!                  routines defined in lib_mpp
+   !!   lbc_lnk_e    : generic interface for mpp_lnk_2d_e
+   !!                   routinee defined in lib_mpp
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE lib_mpp          ! distributed memory computing library
+
+   INTERFACE lbc_lnk
+      MODULE PROCEDURE mpp_lnk_3d_gather, mpp_lnk_3d, mpp_lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc_lnk_e
+      MODULE PROCEDURE mpp_lnk_2d_e
+   END INTERFACE
+
+   PUBLIC lbc_lnk       ! ocean lateral boundary conditions
+   PUBLIC lbc_lnk_e
+   !!----------------------------------------------------------------------
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                              shared memory computing
+   !!----------------------------------------------------------------------
+   !!   lbc_lnk      : generic interface for lbc_lnk_3d and lbc_lnk_2d
+   !!   lbc_lnk_3d   : set the lateral boundary condition on a 3D variable
+   !!                  on OPA ocean mesh
+   !!   lbc_lnk_2d   : set the lateral boundary condition on a 2D variable
+   !!                  on OPA ocean mesh
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers   
+   USE dom_oce         ! ocean space and time domain 
+   USE in_out_manager  ! I/O manager
+   USE lbcnfd          ! north fold
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE lbc_lnk
+      MODULE PROCEDURE lbc_lnk_3d_gather, lbc_lnk_3d, lbc_lnk_2d
+   END INTERFACE
+
+   INTERFACE lbc_lnk_e
+      MODULE PROCEDURE lbc_lnk_2d
+   END INTERFACE
+
+   PUBLIC lbc_lnk       ! ocean/ice  lateral boundary conditions
+   PUBLIC  lbc_lnk_e 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lbc_lnk_3d_gather( pt3d1, cd_type1, pt3d2, cd_type2, psgn )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d_gather  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)     Original code
+      !!   8.5  !  02-09  (G. Madec)     F90: Free form and module
+      !!        !  09-03  (R. Benshila)  External north fold treatment  
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type1, cd_type2       ! nature of pt3d grid-points
+      !             !   = T ,  U , V , F or W  gridpoints
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         pt3d1, pt3d2          ! 3D array on which the boundary condition is applied
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+      !             !   =-1 , the sign is changed if north fold boundary
+      !             !   = 1 , no sign change
+      !             !   = 0 , no sign change and > 0 required (use the inner
+      !             !         row/column if closed boundary)
+
+      CALL lbc_lnk_3d( pt3d1, cd_type1, psgn)
+      CALL lbc_lnk_3d( pt3d2, cd_type2, psgn)
+
+   END SUBROUTINE lbc_lnk_3d_gather
+
+
+   SUBROUTINE lbc_lnk_3d( pt3d, cd_type, psgn, cd_mpp, pval )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!        !  09-03  (R. Benshila)  External north fold treatment  
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt3d grid-points
+      !             !   = T ,  U , V , F or W  gridpoints
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   &
+         pt3d          ! 3D array on which the boundary condition is applied
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+      !             !   =-1 , the sign is changed if north fold boundary
+      !             !   = 1 , no sign change
+      !             !   = 0 , no sign change and > 0 required (use the inner
+      !             !         row/column if closed boundary)
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only (here do nothing)
+      REAL(wp)        , INTENT(in   ), OPTIONAL           ::   pval      ! background value (used at closed boundaries)
+
+      !! * Local declarations
+      REAL(wp) ::   zland
+
+      IF( PRESENT( pval ) ) THEN      ! set land value (zero by default)
+         zland = pval
+      ELSE
+         zland = 0.e0
+      ENDIF
+
+
+      IF( PRESENT( cd_mpp ) ) THEN
+         ! only fill the overlap area and extra allows 
+         ! this is in mpp case. In this module, just do nothing
+      ELSE
+
+         !                                     !  East-West boundaries
+         !                                     ! ======================
+         SELECT CASE ( nperio )
+         !
+         CASE ( 1 , 4 , 6 )                       !**  cyclic east-west
+            pt3d( 1 ,:,:) = pt3d(jpim1,:,:)            ! all points
+            pt3d(jpi,:,:) = pt3d(  2  ,:,:)
+            !
+         CASE DEFAULT                             !**  East closed  --  West closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d( 1 ,:,:) = zland
+               pt3d(jpi,:,:) = zland
+            CASE ( 'F' )                               ! F-point
+               pt3d(jpi,:,:) = zland
+            END SELECT
+            !
+         END SELECT
+
+         !                                     ! North-South boundaries
+         !                                     ! ======================
+         SELECT CASE ( nperio )
+         !
+         CASE ( 2 )                               !**  South symmetric  --  North closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+               pt3d(:, 1 ,:) = pt3d(:,3,:)
+               pt3d(:,jpj,:) = zland
+            CASE ( 'V' , 'F' )                         ! V-, F-points
+               pt3d(:, 1 ,:) = psgn * pt3d(:,2,:)
+               pt3d(:,jpj,:) = zland
+            END SELECT
+            !
+         CASE ( 3 , 4 , 5 , 6 )                   !**  North fold  T or F-point pivot  --  South closed
+            SELECT CASE ( cd_type )                    ! South : closed
+            CASE ( 'T' , 'U' , 'V' , 'W' , 'I' )             ! all points except F-point
+               pt3d(:, 1 ,:) = zland
+            END SELECT
+            !                                          ! North fold
+            pt3d( 1 ,jpj,:) = zland
+            pt3d(jpi,jpj,:) = zland
+            CALL lbc_nfd( pt3d(:,:,:), cd_type, psgn )
+            !
+         CASE DEFAULT                             !**  North closed  --  South closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d(:, 1 ,:) = zland
+               pt3d(:,jpj,:) = zland
+            CASE ( 'F' )                               ! F-point
+               pt3d(:,jpj,:) = zland
+            END SELECT
+            !
+         END SELECT
+
+      ENDIF
+
+   END SUBROUTINE lbc_lnk_3d
+
+
+   SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE lbc_lnk_2d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions (non mpp case)
+      !!
+      !! ** Method  :
+      !!
+      !! History :
+      !!        !  97-06  (G. Madec)  Original code
+      !!        !  01-05  (E. Durand)  correction
+      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
+      !!        !  09-03  (R. Benshila)  External north fold treatment  
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1), INTENT( in ) ::   &
+         cd_type       ! nature of pt2d grid-point
+         !             !   = T , U , V , F or W  gridpoints
+         !             !   = I sea-ice U-V gridpoint (= F ocean grid point with indice shift)
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+         !             !   =-1 , the sign is modified following the type of b.c. used
+         !             !   = 1 , no sign change
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         pt2d          ! 2D array on which the boundary condition is applied
+      CHARACTER(len=3), INTENT( in ), OPTIONAL ::    &
+         cd_mpp        ! fill the overlap area only (here do nothing)
+      REAL(wp)        , INTENT(in   ), OPTIONAL           ::   pval      ! background value (used at closed boundaries)
+
+      !! * Local declarations
+      REAL(wp) ::   zland
+
+      IF( PRESENT( pval ) ) THEN      ! set land value (zero by default)
+         zland = pval
+      ELSE
+         zland = 0.e0
+      ENDIF
+
+      IF (PRESENT(cd_mpp)) THEN
+         ! only fill the overlap area and extra allows 
+         ! this is in mpp case. In this module, just do nothing
+      ELSE      
+      
+         !                                     ! East-West boundaries
+         !                                     ! ====================
+         SELECT CASE ( nperio )
+         !
+         CASE ( 1 , 4 , 6 )                       !** cyclic east-west
+            pt2d( 1 ,:) = pt2d(jpim1,:)               ! all points
+            pt2d(jpi,:) = pt2d(  2  ,:)
+            !
+         CASE DEFAULT                             !** East closed  --  West closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )            ! T-, U-, V-, W-points
+               pt2d( 1 ,:) = zland
+               pt2d(jpi,:) = zland
+            CASE ( 'F' )                              ! F-point
+               pt2d(jpi,:) = zland
+            END SELECT
+            !
+         END SELECT
+ 
+         !                                     ! North-South boundaries
+         !                                     ! ======================
+         SELECT CASE ( nperio )
+         !
+         CASE ( 2 )                               !**  South symmetric  --  North closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'W' )                   ! T-, U-, W-points
+               pt2d(:, 1 ) = pt2d(:,3)
+               pt2d(:,jpj) = zland
+            CASE ( 'V' , 'F' )                         ! V-, F-points
+               pt2d(:, 1 ) = psgn * pt2d(:,2)
+               pt2d(:,jpj) = zland
+            END SELECT
+            !
+         CASE ( 3 , 4 , 5 , 6 )                   !**  North fold  T or F-point pivot  --  South closed
+            SELECT CASE ( cd_type )                    ! South : closed
+            CASE ( 'T' , 'U' , 'V' , 'W' , 'I' )             ! all points except F-point
+               pt2d(:, 1 ) = zland
+            END SELECT
+            !                                          ! North fold
+            pt2d( 1 ,1  ) = zland 
+            pt2d( 1 ,jpj) = zland 
+            pt2d(jpi,jpj) = zland
+            CALL lbc_nfd( pt2d(:,:), cd_type, psgn )
+            !
+         CASE DEFAULT                             !**  North closed  --  South closed
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt2d(:, 1 ) = zland
+               pt2d(:,jpj) = zland
+            CASE ( 'F' )                               ! F-point
+               pt2d(:,jpj) = zland
+            END SELECT
+            !
+         END SELECT
+
+      ENDIF
+      
+   END SUBROUTINE lbc_lnk_2d
+
+#endif
+
+   !!======================================================================
+END MODULE lbclnk
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbcnfd.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbcnfd.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lbcnfd.F90	(revision 1844)
@@ -0,0 +1,319 @@
+MODULE lbcnfd
+   !!======================================================================
+   !!                       ***  MODULE  lbcnfd  ***
+   !! Ocean        : north fold  boundary conditions
+   !!======================================================================
+   !!             9.0  !  09-03  (R. Benshila) Initial version 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers   
+   USE dom_oce         ! ocean space and time domain 
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE lbc_nfd
+      MODULE PROCEDURE lbc_nfd_3d, lbc_nfd_2d
+   END INTERFACE
+
+   PUBLIC lbc_nfd       ! north fold conditions
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lbc_nfd_3d( pt3d, cd_type, psgn )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine lbc_nfd_3d  ***
+      !!
+      !! ** Purpose :   3D lateral boundary condition : North fold treatment
+      !!       without processor exchanges. 
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  :   pt3d with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type       ! define the nature of ptab array grid-points
+      !             ! = T , U , V , F , W points
+      !             ! = S : T-point, north fold treatment ???
+      !             ! = G : F-point, north fold treatment ???
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+      !             !   = -1. , the sign is changed if north fold boundary
+      !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(:,:,:), INTENT( inout ) ::   &
+         pt3d          ! 3D array on which the boundary condition is applied
+
+      !! * Local declarations
+      INTEGER  ::   ji, jk
+      INTEGER  ::   ijt, iju, ijpj, ijpjm1
+
+
+      SELECT CASE ( jpni )
+      CASE ( 1 )  ! only one proc along I
+         ijpj = nlcj
+      CASE DEFAULT 
+         ijpj   = 4
+      END SELECT
+      ijpjm1 = ijpj-1
+
+      DO jk = 1, jpk
+
+         SELECT CASE ( npolj )
+
+         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  pt3d(ji,ijpj,jk) = psgn * pt3d(ijt,ijpj-2,jk)
+               END DO
+               DO ji = jpiglo/2+1, jpiglo
+                  ijt = jpiglo-ji+2
+                  pt3d(ji,ijpjm1,jk) = psgn * pt3d(ijt,ijpjm1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  pt3d(ji,ijpj,jk) = psgn * pt3d(iju,ijpj-2,jk)
+               END DO
+               DO ji = jpiglo/2, jpiglo-1
+                  iju = jpiglo-ji+1
+                  pt3d(ji,ijpjm1,jk) = psgn * pt3d(iju,ijpjm1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  pt3d(ji,ijpj-1,jk) = psgn * pt3d(ijt,ijpj-2,jk)
+                  pt3d(ji,ijpj  ,jk) = psgn * pt3d(ijt,ijpj-3,jk)
+               END DO
+            CASE ( 'F' )                               ! F-point
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  pt3d(ji,ijpj-1,jk) = psgn * pt3d(iju,ijpj-2,jk)
+                  pt3d(ji,ijpj  ,jk) = psgn * pt3d(iju,ijpj-3,jk)
+               END DO
+            END SELECT
+
+         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
+
+            SELECT CASE ( cd_type )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  pt3d(ji,ijpj,jk) = psgn * pt3d(ijt,ijpj-1,jk)
+               END DO
+            CASE ( 'U' )                               ! U-point
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  pt3d(ji,ijpj,jk) = psgn * pt3d(iju,ijpj-1,jk)
+               END DO
+            CASE ( 'V' )                               ! V-point
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  pt3d(ji,ijpj,jk) = psgn * pt3d(ijt,ijpj-2,jk)
+               END DO
+               DO ji = jpiglo/2+1, jpiglo
+                  ijt = jpiglo-ji+1
+                  pt3d(ji,ijpjm1,jk) = psgn * pt3d(ijt,ijpjm1,jk)
+               END DO
+            CASE ( 'F' )                               ! F-point
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  pt3d(ji,ijpj  ,jk) = psgn * pt3d(iju,ijpj-2,jk)
+               END DO
+               DO ji = jpiglo/2+1, jpiglo-1
+                  iju = jpiglo-ji
+                  pt3d(ji,ijpjm1,jk) = psgn * pt3d(iju,ijpjm1,jk)
+               END DO
+            END SELECT
+
+         CASE DEFAULT                           ! *  closed : the code probably never go through
+
+            SELECT CASE ( cd_type)
+            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
+               pt3d(:, 1  ,jk) = 0.e0
+               pt3d(:,ijpj,jk) = 0.e0
+            CASE ( 'F' )                               ! F-point
+               pt3d(:,ijpj,jk) = 0.e0
+            END SELECT
+
+         END SELECT     !  npolj
+
+      END DO
+
+   END SUBROUTINE lbc_nfd_3d
+
+
+   SUBROUTINE lbc_nfd_2d( pt2d, cd_type, psgn, pr2dj )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine lbc_nfd_2d  ***
+      !!
+      !! ** Purpose :   2D lateral boundary condition : North fold treatment
+      !!       without processor exchanges. 
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  :   pt2d with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      CHARACTER(len=1) , INTENT( in ) ::   &
+         cd_type       ! define the nature of ptab array grid-points
+      !             ! = T , U , V , F , W points
+      !             ! = S : T-point, north fold treatment ???
+      !             ! = G : F-point, north fold treatment ???
+      REAL(wp), INTENT( in ) ::   &
+         psgn          ! control of the sign change
+      !             !   = -1. , the sign is changed if north fold boundary
+      !             !   =  1. , the sign is kept  if north fold boundary
+      REAL(wp), DIMENSION(:,:), INTENT( inout ) ::   &
+         pt2d          ! 3D array on which the boundary condition is applied
+      INTEGER, OPTIONAL, INTENT(in) :: pr2dj
+
+      !! * Local declarations
+      INTEGER  ::   ji, jl, ipr2dj
+      INTEGER  ::   ijt, iju, ijpj, ijpjm1
+
+      SELECT CASE ( jpni )
+      CASE ( 1 )  ! only one proc along I
+         ijpj = nlcj
+      CASE DEFAULT 
+         ijpj = 4
+      END SELECT
+
+
+      IF( PRESENT(pr2dj) ) THEN
+         ipr2dj = pr2dj
+         IF (jpni .GT. 1) ijpj = ijpj + ipr2dj
+      ELSE
+         ipr2dj = 0 
+      ENDIF
+
+      ijpjm1 = ijpj-1
+
+
+      SELECT CASE ( npolj )
+
+      CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+
+         SELECT CASE ( cd_type )
+
+         CASE ( 'T', 'S', 'W' )
+            DO jl = 0, ipr2dj
+               DO ji = 2, jpiglo
+                  ijt=jpiglo-ji+2
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(ijt,ijpj-2-jl)
+               END DO
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt=jpiglo-ji+2
+               pt2d(ji,ijpj-1) = psgn * pt2d(ijt,ijpj-1)
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO jl =0, ipr2dj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(iju,ijpj-2-jl)
+               END DO
+            END DO
+            DO ji = jpiglo/2, jpiglo-1
+               iju = jpiglo-ji+1
+               pt2d(ji,ijpjm1) = psgn * pt2d(iju,ijpjm1)
+            END DO
+         CASE ( 'V' )                                     ! V-point
+            DO jl =-1, ipr2dj
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(ijt,ijpj-3-jl)
+               END DO
+            END DO
+         CASE ( 'F' , 'G' )                               ! F-point
+            DO jl =-1, ipr2dj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(iju,ijpj-3-jl)
+               END DO
+            END DO
+         CASE ( 'I' )                                     ! ice U-V point
+            DO jl =0, ipr2dj
+               pt2d(2,ijpj+jl) = psgn * pt2d(3,ijpj-1+jl)
+               DO ji = 3, jpiglo
+                  iju = jpiglo - ji + 3
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(iju,ijpj-1-jl)
+               END DO
+            END DO
+         END SELECT
+
+      CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+
+         SELECT CASE ( cd_type )
+         CASE ( 'T' , 'W' ,'S' )                          ! T-, W-point
+            DO jl = 0, ipr2dj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(ijt,ijpj-1-jl)
+               END DO
+            END DO
+         CASE ( 'U' )                                     ! U-point
+            DO jl = 0, ipr2dj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(iju,ijpj-1-jl)
+               END DO
+            END DO
+         CASE ( 'V' )                                     ! V-point
+            DO jl = 0, ipr2dj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(ijt,ijpj-2-jl)
+               END DO
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt = jpiglo-ji+1
+               pt2d(ji,ijpjm1) = psgn * pt2d(ijt,ijpjm1)
+            END DO
+         CASE ( 'F' , 'G' )                               ! F-point
+            DO jl = 0, ipr2dj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  pt2d(ji,ijpj+jl) = psgn * pt2d(iju,ijpj-2-jl)
+               END DO
+            END DO
+            DO ji = jpiglo/2+1, jpiglo-1
+               iju = jpiglo-ji
+               pt2d(ji,ijpjm1) = psgn * pt2d(iju,ijpjm1)
+            END DO
+         CASE ( 'I' )                                  ! ice U-V point
+            pt2d( 2 ,ijpj:ijpj+ipr2dj) = 0.e0
+            DO jl = 0, ipr2dj
+               DO ji = 2 , jpiglo-1
+                  ijt = jpiglo - ji + 2
+                  pt2d(ji,ijpj+jl)= 0.5 * ( pt2d(ji,ijpj-1-jl) + psgn * pt2d(ijt,ijpj-1-jl) )
+               END DO
+            END DO
+         END SELECT
+
+      CASE DEFAULT                           ! *  closed : the code probably never go through
+
+         SELECT CASE ( cd_type)
+         CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
+            pt2d(:, 1:1-ipr2dj     ) = 0.e0
+            pt2d(:,ijpj:ijpj+ipr2dj) = 0.e0
+         CASE ( 'F' )                                   ! F-point
+            pt2d(:,ijpj:ijpj+ipr2dj) = 0.e0
+         CASE ( 'I' )                                   ! ice U-V point
+            pt2d(:, 1:1-ipr2dj     ) = 0.e0
+            pt2d(:,ijpj:ijpj+ipr2dj) = 0.e0
+         END SELECT
+
+      END SELECT
+
+   END SUBROUTINE lbc_nfd_2d
+
+   !!======================================================================
+END MODULE lbcnfd
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_cray.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_cray.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_cray.f90	(revision 1844)
@@ -0,0 +1,30 @@
+!  Cray subroutines or functions used by OPA model and possibly 
+!  not found on other platforms.
+!
+!  check their existence
+!  
+!  wheneq
+!!----------------------------------------------------------------------
+!!  OPA 9.0 , LOCEAN-IPSL (2005) 
+!! $Id$ 
+!! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+!!----------------------------------------------------------------------
+     SUBROUTINE wheneq ( i, x, j, t, ind, nn )
+        IMPLICIT NONE
+
+        INTEGER , INTENT (  in ) :: i, j
+        INTEGER , INTENT ( out ) :: nn
+        REAL    , INTENT (  in ), DIMENSION (1+(i-1)*j) :: x
+        REAL    , INTENT (  in ) :: t
+        INTEGER , INTENT ( out ), DIMENSION (1+(i-1)*j) :: ind
+        INTEGER :: n, k
+        nn = 0
+        DO n = 1, i
+          k = 1 + (n-1) * j
+          IF ( x ( k) == t ) THEN 
+              nn = nn + 1
+              ind (nn) = k
+          ENDIF
+        END DO 
+
+     END SUBROUTINE wheneq
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_mpp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_mpp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_mpp.F90	(revision 1844)
@@ -0,0 +1,2460 @@
+MODULE lib_mpp
+   !!======================================================================
+   !!                       ***  MODULE  lib_mpp  ***
+   !! Ocean numerics:  massively parallel processing library
+   !!=====================================================================
+   !! History :  OPA  !  1994  (M. Guyon, J. Escobar, M. Imbard)  Original code
+   !!            7.0  !  1997  (A.M. Treguier)  SHMEM additions
+   !!            8.0  !  1998  (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI
+   !!                 !  1998  (J.M. Molines) Open boundary conditions
+   !!   NEMO     1.0  !  2003  (J.-M. Molines, G. Madec)  F90, free form
+   !!                 !  2003  (J.M. Molines) add mpp_ini_north(_3d,_2d)
+   !!             -   !  2004  (R. Bourdalle Badie)  isend option in mpi
+   !!                 !  2004  (J.M. Molines) minloc, maxloc
+   !!             -   !  2005  (G. Madec, S. Masson)  npolj=5,6 F-point & ice cases
+   !!             -   !  2005  (R. Redler) Replacement of MPI_COMM_WORLD except for MPI_Abort
+   !!             -   !  2005  (R. Benshila, G. Madec)  add extra halo case
+   !!             -   !  2008  (R. Benshila) add mpp_ini_ice
+   !!            3.2  !  2009  (R. Benshila) SHMEM suppression, north fold in lbc_nfd
+   !!            3.2  !  2009  (O. Marti)    add mpp_ini_znl 
+   !!----------------------------------------------------------------------
+#if   defined key_mpp_mpi  
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'             MPI massively parallel processing library
+   !!----------------------------------------------------------------------
+   !!   mynode      : indentify the processor unit
+   !!   mpp_lnk     : interface (defined in lbclnk) for message passing of 2d or 3d arrays (mpp_lnk_2d, mpp_lnk_3d)
+   !!   mpp_lnk_3d_gather :  Message passing manadgement for two 3D arrays
+   !!   mpp_lnk_e   : interface (defined in lbclnk) for message passing of 2d array with extra halo (mpp_lnk_2d_e)
+   !!   mpprecv     :
+   !!   mppsend     :   SUBROUTINE mpp_ini_znl
+   !!   mppscatter  :
+   !!   mppgather   :
+   !!   mpp_min     : generic interface for mppmin_int , mppmin_a_int , mppmin_real, mppmin_a_real
+   !!   mpp_max     : generic interface for mppmax_int , mppmax_a_int , mppmax_real, mppmax_a_real
+   !!   mpp_sum     : generic interface for mppsum_int , mppsum_a_int , mppsum_real, mppsum_a_real
+   !!   mpp_minloc  :
+   !!   mpp_maxloc  :
+   !!   mppsync     :
+   !!   mppstop     :
+   !!   mppobc      : variant of mpp_lnk for open boundary condition
+   !!   mpp_ini_north : initialisation of north fold
+   !!   mpp_lbc_north : north fold processors gathering
+   !!   mpp_lbc_north_e : variant of mpp_lbc_north for extra outer halo
+   !!----------------------------------------------------------------------
+   !! History :
+   !!        !  94 (M. Guyon, J. Escobar, M. Imbard)  Original code
+   !!        !  97  (A.M. Treguier)  SHMEM additions
+   !!        !  98  (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI
+   !!   9.0  !  03  (J.-M. Molines, G. Madec)  F90, free form
+   !!        !  04  (R. Bourdalle Badie)  isend option in mpi
+   !!        !  05  (G. Madec, S. Masson)  npolj=5,6 F-point & ice cases
+   !!        !  05  (R. Redler) Replacement of MPI_COMM_WORLD except for MPI_Abort
+   !!        !  09  (R. Benshila) SHMEM suppression, north fold in lbc_nfd
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!---------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce                    ! ocean space and time domain 
+   USE in_out_manager             ! I/O manager
+   USE lbcnfd                     ! north fold treatment
+
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   mynode, mppstop, mppsync, mpp_comm_free
+   PUBLIC   mpp_ini_north, mpp_lbc_north, mpp_lbc_north_e
+   PUBLIC   mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc
+   PUBLIC   mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e
+   PUBLIC   mpprecv, mppsend, mppscatter, mppgather
+   PUBLIC   mppobc, mpp_ini_ice, mpp_ini_znl
+#if defined key_oasis3 || defined key_oasis4
+   PUBLIC   mppsize, mpprank
+#endif
+
+   !! * Interfaces
+   !! define generic interface for these routine as they are called sometimes
+   !! with scalar arguments instead of array arguments, which causes problems
+   !! for the compilation on AIX system as well as NEC and SGI. Ok on COMPACQ
+   INTERFACE mpp_min
+      MODULE PROCEDURE mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real
+   END INTERFACE
+   INTERFACE mpp_max
+      MODULE PROCEDURE mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real
+   END INTERFACE
+   INTERFACE mpp_sum
+      MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real
+   END INTERFACE
+   INTERFACE mpp_lbc_north
+      MODULE PROCEDURE mpp_lbc_north_3d, mpp_lbc_north_2d 
+   END INTERFACE
+   INTERFACE mpp_minloc
+      MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
+   END INTERFACE
+   INTERFACE mpp_maxloc
+      MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
+   END INTERFACE
+
+
+   !! ========================= !!
+   !!  MPI  variable definition !!
+   !! ========================= !!
+!$AGRIF_DO_NOT_TREAT
+#  include <mpif.h>
+!$AGRIF_END_DO_NOT_TREAT
+   
+   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.    !: mpp flag
+
+   INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
+   
+   INTEGER ::   mppsize        ! number of process
+   INTEGER ::   mpprank        ! process number  [ 0 - size-1 ]
+!$AGRIF_DO_NOT_TREAT
+   INTEGER, PUBLIC ::   mpi_comm_opa   ! opa local communicator
+!$AGRIF_END_DO_NOT_TREAT
+
+   ! variables used in case of sea-ice
+   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice
+   INTEGER ::   ngrp_ice        !  group ID for the ice processors (for rheology)
+   INTEGER ::   ndim_rank_ice   !  number of 'ice' processors
+   INTEGER ::   n_ice_root      !  number (in the comm_ice) of proc 0 in the ice comm
+   INTEGER, DIMENSION(:), ALLOCATABLE ::   nrank_ice     ! dimension ndim_rank_ice
+
+   ! variables used for zonal integration
+   INTEGER, PUBLIC ::   ncomm_znl       !: communicator made by the processors on the same zonal average
+   LOGICAL, PUBLIC ::   l_znl_root      ! True on the 'left'most processor on the same row
+   INTEGER ::   ngrp_znl        ! group ID for the znl processors
+   INTEGER ::   ndim_rank_znl   ! number of processors on the same zonal average
+   INTEGER, DIMENSION(:), ALLOCATABLE ::   nrank_znl  ! dimension ndim_rank_znl, number of the procs into the same znl domain
+   
+   ! North fold condition in mpp_mpi with jpni > 1
+   INTEGER ::   ngrp_world        ! group ID for the world processors
+   INTEGER ::   ngrp_opa          ! group ID for the opa processors
+   INTEGER ::   ngrp_north        ! group ID for the northern processors (to be fold)
+   INTEGER ::   ncomm_north       ! communicator made by the processors belonging to ngrp_north
+   INTEGER ::   ndim_rank_north   ! number of 'sea' processor in the northern line (can be /= jpni !)
+   INTEGER ::   njmppmax          ! value of njmpp for the processors of the northern line
+   INTEGER ::   north_root        ! number (in the comm_opa) of proc 0 in the northern comm
+   INTEGER, DIMENSION(:), ALLOCATABLE ::   nrank_north   ! dimension ndim_rank_north
+
+   ! Type of send : standard, buffered, immediate
+   CHARACTER(len=1) ::   cn_mpi_send = 'S'    ! type od mpi send/recieve (S=standard, B=bsend, I=isend)
+   LOGICAL          ::   l_isend = .FALSE.   ! isend use indicator (T if cn_mpi_send='I')
+   INTEGER          ::   nn_buffer = 0       ! size of the buffer in case of mpi_bsend 
+      
+   REAL(wp), ALLOCATABLE, DIMENSION(:) :: tampon  ! buffer in case of bsend
+
+   ! message passing arrays
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2,2) ::   t4ns, t4sn   ! 2 x 3d for north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,jpk,2,2) ::   t4ew, t4we   ! 2 x 3d for east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2,2) ::   t4p1, t4p2   ! 2 x 3d for north fold
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2)   ::   t3ns, t3sn   ! 3d for north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,jpk,2)   ::   t3ew, t3we   ! 3d for east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,jpk,2)   ::   t3p1, t3p2   ! 3d for north fold
+   REAL(wp), DIMENSION(jpi,jprecj,2)       ::   t2ns, t2sn   ! 2d for north-south & south-north
+   REAL(wp), DIMENSION(jpj,jpreci,2)       ::   t2ew, t2we   ! 2d for east-west & west-east
+   REAL(wp), DIMENSION(jpi,jprecj,2)       ::   t2p1, t2p2   ! 2d for north fold
+   REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,jprecj+jpr2dj,2) ::   tr2ns, tr2sn  ! 2d for north-south & south-north + extra outer halo
+   REAL(wp), DIMENSION(1-jpr2dj:jpj+jpr2dj,jpreci+jpr2di,2) ::   tr2ew, tr2we  ! 2d for east-west   & west-east   + extra outer halo
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   FUNCTION mynode(ldtxt, localComm)
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mynode  ***
+      !!                    
+      !! ** Purpose :   Find processor unit
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt 
+      INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm
+      INTEGER ::   mynode, ierr, code
+      LOGICAL ::   mpi_was_called
+      
+      NAMELIST/nammpp/ cn_mpi_send, nn_buffer
+      !!----------------------------------------------------------------------
+      !
+      WRITE(ldtxt(1),*)
+      WRITE(ldtxt(2),*) 'mynode : mpi initialisation'
+      WRITE(ldtxt(3),*) '~~~~~~ '
+      !
+      REWIND( numnam )               ! Namelist namrun : parameters of the run
+      READ  ( numnam, nammpp )
+      !                              ! control print
+      WRITE(ldtxt(4),*) '   Namelist nammpp'
+      WRITE(ldtxt(5),*) '      mpi send type                      cn_mpi_send = ', cn_mpi_send
+      WRITE(ldtxt(6),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer
+
+      CALL mpi_initialized ( mpi_was_called, code )
+      IF( code /= MPI_SUCCESS ) THEN
+         WRITE(*, cform_err)
+         WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized'
+         CALL mpi_abort( mpi_comm_world, code, ierr )
+      ENDIF
+
+      IF( mpi_was_called ) THEN
+         !
+         SELECT CASE ( cn_mpi_send )
+         CASE ( 'S' )                ! Standard mpi send (blocking)
+            WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)'
+         CASE ( 'B' )                ! Buffer mpi send (blocking)
+            WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)'
+            CALL mpi_init_opa( ierr ) 
+         CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+            WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)'
+            l_isend = .TRUE.
+         CASE DEFAULT
+            WRITE(ldtxt(7),cform_err)
+            WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send
+            nstop = nstop + 1
+         END SELECT
+      ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN
+         WRITE(ldtxt(7),*) ' lib_mpp: You cannot provide a local communicator '
+         WRITE(ldtxt(8),*) '          without calling MPI_Init before ! '
+         nstop = nstop + 1
+      ELSE
+         SELECT CASE ( cn_mpi_send )
+         CASE ( 'S' )                ! Standard mpi send (blocking)
+            WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)'
+            CALL mpi_init( ierr )
+         CASE ( 'B' )                ! Buffer mpi send (blocking)
+            WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)'
+            CALL mpi_init_opa( ierr )
+         CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+            WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)'
+            l_isend = .TRUE.
+            CALL mpi_init( ierr )
+         CASE DEFAULT
+            WRITE(ldtxt(7),cform_err)
+            WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send
+            nstop = nstop + 1
+         END SELECT
+         !
+      ENDIF
+
+      IF( PRESENT(localComm) ) THEN 
+         IF( Agrif_Root() ) THEN
+            mpi_comm_opa = localComm
+         ENDIF
+      ELSE
+         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code)
+         IF( code /= MPI_SUCCESS ) THEN
+            WRITE(*, cform_err)
+            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup'
+            CALL mpi_abort( mpi_comm_world, code, ierr )
+         ENDIF
+      ENDIF 
+
+      CALL mpi_comm_rank( mpi_comm_opa, mpprank, ierr )
+      CALL mpi_comm_size( mpi_comm_opa, mppsize, ierr )
+      mynode = mpprank
+      !
+   END FUNCTION mynode
+
+
+   SUBROUTINE mpp_lnk_3d( ptab, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_3d  ***
+      !!
+      !! ** Purpose :   Message passing manadgement
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !! ** Action  :   ptab with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab     ! 3D array on which the boundary condition is applied
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points
+      !                                                             ! = T , U , V , F , W points
+      REAL(wp)                        , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary
+      !                                                             ! =  1. , the sign is kept
+      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
+      REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
+      !!
+      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices
+      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
+      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
+      REAL(wp) ::   zland
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
+      ELSE                         ;   zland = 0.e0      ! zero by default
+      ENDIF
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      IF( PRESENT( cd_mpp ) ) THEN      ! only fill added line/raw with existing values
+         !
+         ! WARNING ptab is defined only between nld and nle
+         DO jk = 1, jpk
+            DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
+               ptab(nldi  :nlei  , jj          ,jk) = ptab(nldi:nlei,     nlej,jk)   
+               ptab(1     :nldi-1, jj          ,jk) = ptab(nldi     ,     nlej,jk)
+               ptab(nlei+1:nlci  , jj          ,jk) = ptab(     nlei,     nlej,jk)
+            END DO
+            DO ji = nlci+1, jpi                 ! added column(s) (full)
+               ptab(ji           ,nldj  :nlej  ,jk) = ptab(     nlei,nldj:nlej,jk)
+               ptab(ji           ,1     :nldj-1,jk) = ptab(     nlei,nldj     ,jk)
+               ptab(ji           ,nlej+1:jpj   ,jk) = ptab(     nlei,     nlej,jk)
+            END DO
+         END DO
+         !
+      ELSE                              ! standard close or cyclic treatment 
+         !
+         !                                   ! East-West boundaries
+         !                                        !* Cyclic east-west
+         IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+            ptab( 1 ,:,:) = ptab(jpim1,:,:)
+            ptab(jpi,:,:) = ptab(  2  ,:,:)
+         ELSE                                     !* closed
+            IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:,:) = zland    ! south except F-point
+                                         ptab(nlci-jpreci+1:jpi   ,:,:) = zland    ! north
+         ENDIF
+         !                                   ! North-South boundaries (always closed)
+         IF( .NOT. cd_type == 'F' )   ptab(:,     1       :jprecj,:) = zland       ! south except F-point
+                                      ptab(:,nlcj-jprecj+1:jpj   ,:) = zland       ! north
+         !
+      ENDIF
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+      ! we play with the neigbours AND the row number because of the periodicity 
+      !
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t3ew(:,jl,:,1) = ptab(jpreci+jl,:,:)
+            t3we(:,jl,:,1) = ptab(iihom +jl,:,:)
+         END DO
+      END SELECT  
+      !
+      !                           ! Migrations
+      imigr = jpreci * jpj * jpk
+      !
+      SELECT CASE ( nbondi ) 
+      CASE ( -1 )
+         CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t3ew(1,1,1,2), imigr )
+         CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t3ew(1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t3we(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      iihom = nlci-jpreci
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jpreci
+            ptab(jl      ,:,:) = t3we(:,jl,:,2)
+            ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            ptab(jl      ,:,:) = t3we(:,jl,:,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+      ! always closed : we play only with the neigbours
+      !
+      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+         ijhom = nlcj-nrecj
+         DO jl = 1, jprecj
+            t3sn(:,jl,:,1) = ptab(:,ijhom +jl,:)
+            t3ns(:,jl,:,1) = ptab(:,jprecj+jl,:)
+         END DO
+      ENDIF
+      !
+      !                           ! Migrations
+      imigr = jprecj * jpi * jpk
+      !
+      SELECT CASE ( nbondj )     
+      CASE ( -1 )
+         CALL mppsend( 4, t3sn(1,1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t3ns(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t3ns(1,1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t3sn(1,1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t3ns(1,1,1,2), imigr )
+         CALL mpprecv( 4, t3sn(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 ) 
+         CALL mppsend( 3, t3ns(1,1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t3sn(1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = nlcj-jprecj
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            ptab(:,ijhom+jl,:) = t3ns(:,jl,:,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jprecj
+            ptab(:,jl      ,:) = t3sn(:,jl,:,2)
+            ptab(:,ijhom+jl,:) = t3ns(:,jl,:,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jprecj
+            ptab(:,jl,:) = t3sn(:,jl,:,2)
+         END DO
+      END SELECT
+
+
+      ! 4. north fold treatment
+      ! -----------------------
+      !
+      IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN
+         !
+         SELECT CASE ( jpni )
+         CASE ( 1 )     ;   CALL lbc_nfd      ( ptab, cd_type, psgn )   ! only 1 northern proc, no mpp
+         CASE DEFAULT   ;   CALL mpp_lbc_north( ptab, cd_type, psgn )   ! for all northern procs.
+         END SELECT
+         !
+      ENDIF
+      !
+   END SUBROUTINE mpp_lnk_3d
+
+
+   SUBROUTINE mpp_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_2d  ***
+      !!                  
+      !! ** Purpose :   Message passing manadgement for 2d array
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d     ! 2D array on which the boundary condition is applied
+      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type  ! define the nature of ptab array grid-points
+      !                                                         ! = T , U , V , F , W and I points
+      REAL(wp)                    , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary
+      !                                                         ! =  1. , the sign is kept
+      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
+      REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
+      !!
+      INTEGER  ::   ji, jj, jl   ! dummy loop indices
+      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
+      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
+      REAL(wp) ::   zland
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
+      ELSE                         ;   zland = 0.e0      ! zero by default
+      ENDIF
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      !
+      IF( PRESENT( cd_mpp ) ) THEN      ! only fill added line/raw with existing values
+         !
+         ! WARNING pt2d is defined only between nld and nle
+         DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
+            pt2d(nldi  :nlei  , jj          ) = pt2d(nldi:nlei,     nlej)   
+            pt2d(1     :nldi-1, jj          ) = pt2d(nldi     ,     nlej)
+            pt2d(nlei+1:nlci  , jj          ) = pt2d(     nlei,     nlej)
+         END DO
+         DO ji = nlci+1, jpi                 ! added column(s) (full)
+            pt2d(ji           ,nldj  :nlej  ) = pt2d(     nlei,nldj:nlej)
+            pt2d(ji           ,1     :nldj-1) = pt2d(     nlei,nldj     )
+            pt2d(ji           ,nlej+1:jpj   ) = pt2d(     nlei,     nlej)
+         END DO
+         !
+      ELSE                              ! standard close or cyclic treatment 
+         !
+         !                                   ! East-West boundaries
+         IF( nbondi == 2 .AND.   &                ! Cyclic east-west
+            &    (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+            pt2d( 1 ,:) = pt2d(jpim1,:)                                    ! west
+            pt2d(jpi,:) = pt2d(  2  ,:)                                    ! east
+         ELSE                                     ! closed
+            IF( .NOT. cd_type == 'F' )   pt2d(     1       :jpreci,:) = zland    ! south except F-point
+                                         pt2d(nlci-jpreci+1:jpi   ,:) = zland    ! north
+         ENDIF
+         !                                   ! North-South boundaries (always closed)
+            IF( .NOT. cd_type == 'F' )   pt2d(:,     1       :jprecj) = zland    !south except F-point
+                                         pt2d(:,nlcj-jprecj+1:jpj   ) = zland    ! north
+         !
+      ENDIF
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+      ! we play with the neigbours AND the row number because of the periodicity 
+      !
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t2ew(:,jl,1) = pt2d(jpreci+jl,:)
+            t2we(:,jl,1) = pt2d(iihom +jl,:)
+         END DO
+      END SELECT
+      !
+      !                           ! Migrations
+      imigr = jpreci * jpj
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t2ew(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t2ew(1,1,2), imigr )
+         CALL mpprecv( 2, t2we(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t2we(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      iihom = nlci - jpreci
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            pt2d(iihom+jl,:) = t2ew(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, jpreci
+            pt2d(jl      ,:) = t2we(:,jl,2)
+            pt2d(iihom+jl,:) = t2ew(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            pt2d(jl      ,:) = t2we(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+      ! always closed : we play only with the neigbours
+      !
+      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+         ijhom = nlcj-nrecj
+         DO jl = 1, jprecj
+            t2sn(:,jl,1) = pt2d(:,ijhom +jl)
+            t2ns(:,jl,1) = pt2d(:,jprecj+jl)
+         END DO
+      ENDIF
+      !
+      !                           ! Migrations
+      imigr = jprecj * jpi
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t2ns(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t2ns(1,1,2), imigr )
+         CALL mpprecv( 4, t2sn(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t2sn(1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = nlcj - jprecj
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            pt2d(:,ijhom+jl) = t2ns(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, jprecj
+            pt2d(:,jl      ) = t2sn(:,jl,2)
+            pt2d(:,ijhom+jl) = t2ns(:,jl,2)
+         END DO
+      CASE ( 1 ) 
+         DO jl = 1, jprecj
+            pt2d(:,jl      ) = t2sn(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 4. north fold treatment
+      ! -----------------------
+      !
+      IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN
+         !
+         SELECT CASE ( jpni )
+         CASE ( 1 )     ;   CALL lbc_nfd      ( pt2d, cd_type, psgn )   ! only 1 northern proc, no mpp
+         CASE DEFAULT   ;   CALL mpp_lbc_north( pt2d, cd_type, psgn )   ! for all northern procs.
+         END SELECT
+         !
+      ENDIF
+      !
+   END SUBROUTINE mpp_lnk_2d
+
+
+   SUBROUTINE mpp_lnk_3d_gather( ptab1, cd_type1, ptab2, cd_type2, psgn )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_3d_gather  ***
+      !!
+      !! ** Purpose :   Message passing manadgement for two 3D arrays
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !! ** Action  :   ptab1 and ptab2  with update value at its periphery
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab1     ! first and second 3D array on which 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab2     ! the boundary condition is applied
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1  ! nature of ptab1 and ptab2 arrays 
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type2  ! i.e. grid-points = T , U , V , F or W points
+      REAL(wp)                        , INTENT(in   ) ::   psgn      ! =-1 the sign change across the north fold boundary
+      !!                                                             ! =  1. , the sign is kept
+      INTEGER  ::   jl   ! dummy loop indices
+      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
+      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      !                                      ! East-West boundaries
+      !                                           !* Cyclic east-west
+      IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+         ptab1( 1 ,:,:) = ptab1(jpim1,:,:)
+         ptab1(jpi,:,:) = ptab1(  2  ,:,:)
+         ptab2( 1 ,:,:) = ptab2(jpim1,:,:)
+         ptab2(jpi,:,:) = ptab2(  2  ,:,:)
+      ELSE                                        !* closed
+         IF( .NOT. cd_type1 == 'F' )   ptab1(     1       :jpreci,:,:) = 0.e0    ! south except at F-point
+         IF( .NOT. cd_type2 == 'F' )   ptab2(     1       :jpreci,:,:) = 0.e0
+                                       ptab1(nlci-jpreci+1:jpi   ,:,:) = 0.e0    ! north
+                                       ptab2(nlci-jpreci+1:jpi   ,:,:) = 0.e0
+      ENDIF
+
+      
+      !                                      ! North-South boundaries
+      IF( .NOT. cd_type1 == 'F' )   ptab1(:,     1       :jprecj,:) = 0.e0    ! south except at F-point
+      IF( .NOT. cd_type2 == 'F' )   ptab2(:,     1       :jprecj,:) = 0.e0
+                                    ptab1(:,nlcj-jprecj+1:jpj   ,:) = 0.e0    ! north
+                                    ptab2(:,nlcj-jprecj+1:jpj   ,:) = 0.e0
+
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+      ! we play with the neigbours AND the row number because of the periodicity 
+      !
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+         iihom = nlci-nreci
+         DO jl = 1, jpreci
+            t4ew(:,jl,:,1,1) = ptab1(jpreci+jl,:,:)
+            t4we(:,jl,:,1,1) = ptab1(iihom +jl,:,:)
+            t4ew(:,jl,:,2,1) = ptab2(jpreci+jl,:,:)
+            t4we(:,jl,:,2,1) = ptab2(iihom +jl,:,:)
+         END DO
+      END SELECT
+      !
+      !                           ! Migrations
+      imigr = jpreci * jpj * jpk *2
+      !
+      SELECT CASE ( nbondi ) 
+      CASE ( -1 )
+         CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, t4ew(1,1,1,1,2), imigr )
+         CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, t4ew(1,1,1,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, t4we(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      iihom = nlci - jpreci
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, jpreci
+            ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+            ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jpreci
+            ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+            ptab1(iihom+jl,:,:) = t4ew(:,jl,:,1,2)
+            ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+            ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jpreci
+            ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
+            ptab2(jl      ,:,:) = t4we(:,jl,:,2,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+      ! always closed : we play only with the neigbours
+      !
+      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+         ijhom = nlcj - nrecj
+         DO jl = 1, jprecj
+            t4sn(:,jl,:,1,1) = ptab1(:,ijhom +jl,:)
+            t4ns(:,jl,:,1,1) = ptab1(:,jprecj+jl,:)
+            t4sn(:,jl,:,2,1) = ptab2(:,ijhom +jl,:)
+            t4ns(:,jl,:,2,1) = ptab2(:,jprecj+jl,:)
+         END DO
+      ENDIF
+      !
+      !                           ! Migrations
+      imigr = jprecj * jpi * jpk * 2
+      !
+      SELECT CASE ( nbondj )     
+      CASE ( -1 )
+         CALL mppsend( 4, t4sn(1,1,1,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, t4ns(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, t4ns(1,1,1,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, t4sn(1,1,1,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, t4ns(1,1,1,1,2), imigr )
+         CALL mpprecv( 4, t4sn(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
+      CASE ( 1 ) 
+         CALL mppsend( 3, t4ns(1,1,1,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, t4sn(1,1,1,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = nlcj - jprecj
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, jprecj
+            ptab1(:,ijhom+jl,:) = t4ns(:,jl,:,1,2)
+            ptab2(:,ijhom+jl,:) = t4ns(:,jl,:,2,2)
+         END DO
+      CASE ( 0 ) 
+         DO jl = 1, jprecj
+            ptab1(:,jl      ,:) = t4sn(:,jl,:,1,2)
+            ptab1(:,ijhom+jl,:) = t4ns(:,jl,:,1,2)
+            ptab2(:,jl      ,:) = t4sn(:,jl,:,2,2)
+            ptab2(:,ijhom+jl,:) = t4ns(:,jl,:,2,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, jprecj
+            ptab1(:,jl,:) = t4sn(:,jl,:,1,2)
+            ptab2(:,jl,:) = t4sn(:,jl,:,2,2)
+         END DO
+      END SELECT
+
+
+      ! 4. north fold treatment
+      ! -----------------------
+      IF( npolj /= 0 ) THEN
+         !
+         SELECT CASE ( jpni )
+         CASE ( 1 )                                           
+            CALL lbc_nfd      ( ptab1, cd_type1, psgn )   ! only for northern procs.
+            CALL lbc_nfd      ( ptab2, cd_type2, psgn )
+         CASE DEFAULT
+            CALL mpp_lbc_north( ptab1, cd_type1, psgn )   ! for all northern procs.
+            CALL mpp_lbc_north (ptab2, cd_type2, psgn)
+         END SELECT 
+         !
+      ENDIF
+      !
+   END SUBROUTINE mpp_lnk_3d_gather
+
+
+   SUBROUTINE mpp_lnk_2d_e( pt2d, cd_type, psgn )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_2d_e  ***
+      !!                  
+      !! ** Purpose :   Message passing manadgement for 2d array (with halo)
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    jpr2di : number of rows for extra outer halo
+      !!                    jpr2dj : number of columns for extra outer halo
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
+      CHARACTER(len=1)                                            , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
+      !                                                                                         ! = T , U , V , F , W and I points
+      REAL(wp)                                                    , INTENT(in   ) ::   psgn     ! =-1 the sign change across the
+      !!                                                                                        ! north boundary, =  1. otherwise
+      INTEGER  ::   jl   ! dummy loop indices
+      INTEGER  ::   imigr, iihom, ijhom        ! temporary integers
+      INTEGER  ::   ipreci, iprecj             ! temporary integers
+      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
+      !!----------------------------------------------------------------------
+
+      ipreci = jpreci + jpr2di      ! take into account outer extra 2D overlap area
+      iprecj = jprecj + jpr2dj
+
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      ! Order matters Here !!!!
+      !
+      !                                      !* North-South boundaries (always colsed)
+      IF( .NOT. cd_type == 'F' )   pt2d(:,  1-jpr2dj   :  jprecj  ) = 0.e0    ! south except at F-point
+                                   pt2d(:,nlcj-jprecj+1:jpj+jpr2dj) = 0.e0    ! north
+                                
+      !                                      ! East-West boundaries
+      !                                           !* Cyclic east-west
+      IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
+         pt2d(1-jpr2di:     1    ,:) = pt2d(jpim1-jpr2di:  jpim1 ,:)       ! east
+         pt2d(   jpi  :jpi+jpr2di,:) = pt2d(     2      :2+jpr2di,:)       ! west
+         !
+      ELSE                                        !* closed
+         IF( .NOT. cd_type == 'F' )   pt2d(  1-jpr2di   :jpreci    ,:) = 0.e0    ! south except at F-point
+                                      pt2d(nlci-jpreci+1:jpi+jpr2di,:) = 0.e0    ! north
+      ENDIF
+      !
+
+      ! north fold treatment
+      ! -----------------------
+      IF( npolj /= 0 ) THEN
+         !
+         SELECT CASE ( jpni )
+         CASE ( 1 )     ;   CALL lbc_nfd        ( pt2d(1:jpi,1:jpj+jpr2dj), cd_type, psgn, pr2dj=jpr2dj )
+         CASE DEFAULT   ;   CALL mpp_lbc_north_e( pt2d                    , cd_type, psgn               )
+         END SELECT 
+         !
+      ENDIF
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+      ! we play with the neigbours AND the row number because of the periodicity 
+      !
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+         iihom = nlci-nreci-jpr2di
+         DO jl = 1, ipreci
+            tr2ew(:,jl,1) = pt2d(jpreci+jl,:)
+            tr2we(:,jl,1) = pt2d(iihom +jl,:)
+         END DO
+      END SELECT
+      !
+      !                           ! Migrations
+      imigr = ipreci * ( jpj + 2*jpr2dj)
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, tr2we(1-jpr2dj,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, tr2ew(1-jpr2dj,1,2), imigr )
+         CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, tr2ew(1-jpr2dj,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, tr2we(1-jpr2dj,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      iihom = nlci - jpreci
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, ipreci
+            pt2d(iihom+jl,:) = tr2ew(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, ipreci
+            pt2d(jl-jpr2di,:) = tr2we(:,jl,2)
+            pt2d( iihom+jl,:) = tr2ew(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, ipreci
+            pt2d(jl-jpr2di,:) = tr2we(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+      ! always closed : we play only with the neigbours
+      !
+      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+         ijhom = nlcj-nrecj-jpr2dj
+         DO jl = 1, iprecj
+            tr2sn(:,jl,1) = pt2d(:,ijhom +jl)
+            tr2ns(:,jl,1) = pt2d(:,jprecj+jl)
+         END DO
+      ENDIF
+      !
+      !                           ! Migrations
+      imigr = iprecj * ( jpi + 2*jpr2di )
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL mppsend( 4, tr2sn(1-jpr2di,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, tr2ns(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, tr2ns(1-jpr2di,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, tr2sn(1-jpr2di,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, tr2ns(1-jpr2di,1,2), imigr )
+         CALL mpprecv( 4, tr2sn(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 3, tr2ns(1-jpr2di,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, tr2sn(1-jpr2di,1,2), imigr )
+         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = nlcj - jprecj  
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, iprecj
+            pt2d(:,ijhom+jl) = tr2ns(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, iprecj
+            pt2d(:,jl-jpr2dj) = tr2sn(:,jl,2)
+            pt2d(:,ijhom+jl ) = tr2ns(:,jl,2)
+         END DO
+      CASE ( 1 ) 
+         DO jl = 1, iprecj
+            pt2d(:,jl-jpr2dj) = tr2sn(:,jl,2)
+         END DO
+      END SELECT
+
+   END SUBROUTINE mpp_lnk_2d_e
+
+
+   SUBROUTINE mppsend( ktyp, pmess, kbytes, kdest, md_req )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsend  ***
+      !!                   
+      !! ** Purpose :   Send messag passing array
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(inout) ::   pmess(*)   ! array of real
+      INTEGER , INTENT(in   ) ::   kbytes     ! size of the array pmess
+      INTEGER , INTENT(in   ) ::   kdest      ! receive process number
+      INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
+      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      !!
+      INTEGER ::   iflag
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE ( cn_mpi_send )
+      CASE ( 'S' )                ! Standard mpi send (blocking)
+         CALL mpi_send ( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_opa        , iflag )
+      CASE ( 'B' )                ! Buffer mpi send (blocking)
+         CALL mpi_bsend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_opa        , iflag )
+      CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
+         ! be carefull, one more argument here : the mpi request identifier..
+         CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_opa, md_req, iflag )
+      END SELECT
+      !
+   END SUBROUTINE mppsend
+
+
+   SUBROUTINE mpprecv( ktyp, pmess, kbytes )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpprecv  ***
+      !!
+      !! ** Purpose :   Receive messag passing array
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(inout) ::   pmess(*)   ! array of real
+      INTEGER , INTENT(in   ) ::   kbytes     ! suze of the array pmess
+      INTEGER , INTENT(in   ) ::   ktyp       ! Tag of the recevied message
+      !!
+      INTEGER :: istatus(mpi_status_size)
+      INTEGER :: iflag
+      !!----------------------------------------------------------------------
+      !
+      CALL mpi_recv( pmess, kbytes, mpi_double_precision, mpi_any_source, ktyp, mpi_comm_opa, istatus, iflag )
+      !
+   END SUBROUTINE mpprecv
+
+
+   SUBROUTINE mppgather( ptab, kp, pio )
+      !!----------------------------------------------------------------------
+      !!                   ***  routine mppgather  ***
+      !!                   
+      !! ** Purpose :   Transfert between a local subdomain array and a work 
+      !!     array which is distributed following the vertical level.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj),       INTENT(in   ) ::   ptab   ! subdomain input array
+      INTEGER ,                           INTENT(in   ) ::   kp     ! record length
+      REAL(wp), DIMENSION(jpi,jpj,jpnij), INTENT(  out) ::   pio    ! subdomain input array
+      !!
+      INTEGER :: itaille, ierror   ! temporary integer
+      !!---------------------------------------------------------------------
+      !
+      itaille = jpi * jpj
+      CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille     ,   &
+         &                            mpi_double_precision, kp , mpi_comm_opa, ierror ) 
+      !
+   END SUBROUTINE mppgather
+
+
+   SUBROUTINE mppscatter( pio, kp, ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppscatter  ***
+      !!
+      !! ** Purpose :   Transfert between awork array which is distributed 
+      !!      following the vertical level and the local subdomain array.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpnij)  ::  pio        ! output array
+      INTEGER                             ::   kp        ! Tag (not used with MPI
+      REAL(wp), DIMENSION(jpi,jpj)        ::  ptab       ! subdomain array input
+      !!
+      INTEGER :: itaille, ierror   ! temporary integer
+      !!---------------------------------------------------------------------
+      !
+      itaille=jpi*jpj
+      !
+      CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille     ,   &
+         &                            mpi_double_precision, kp  , mpi_comm_opa, ierror )
+      !
+   END SUBROUTINE mppscatter
+
+
+   SUBROUTINE mppmax_a_int( ktab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmax_a_int  ***
+      !! 
+      !! ** Purpose :   Find maximum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                  ::   kdim   ! size of array
+      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array
+      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom   ! 
+      !!
+      INTEGER :: ierror, localcomm   ! temporary integer
+      INTEGER, DIMENSION(kdim) ::   iwork
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_max, localcomm, ierror )
+      !
+      ktab(:) = iwork(:)
+      !
+   END SUBROUTINE mppmax_a_int
+
+
+   SUBROUTINE mppmax_int( ktab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmax_int  ***
+      !!
+      !! ** Purpose :   Find maximum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(inout)           ::   ktab      ! ???
+      INTEGER, INTENT(in   ), OPTIONAL ::   kcom      ! ???
+      !! 
+      INTEGER ::   ierror, iwork, localcomm   ! temporary integer
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_max, localcomm, ierror)
+      !
+      ktab = iwork
+      !
+   END SUBROUTINE mppmax_int
+
+
+   SUBROUTINE mppmin_a_int( ktab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmin_a_int  ***
+      !! 
+      !! ** Purpose :   Find minimum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT( in  )                  ::   kdim        ! size of array
+      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab        ! input array
+      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom        ! input array
+      !!
+      INTEGER ::   ierror, localcomm   ! temporary integer
+      INTEGER, DIMENSION(kdim) ::   iwork
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_min, localcomm, ierror )
+      !
+      ktab(:) = iwork(:)
+      !
+   END SUBROUTINE mppmin_a_int
+
+
+   SUBROUTINE mppmin_int( ktab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmin_int  ***
+      !!
+      !! ** Purpose :   Find minimum value in an integer layout array
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(inout) ::   ktab      ! ???
+      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom        ! input array
+      !!
+      INTEGER ::  ierror, iwork, localcomm
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+     CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_min, localcomm, ierror )
+      !
+      ktab = iwork
+      !
+   END SUBROUTINE mppmin_int
+
+
+   SUBROUTINE mppsum_a_int( ktab, kdim )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsum_a_int  ***
+      !!                    
+      !! ** Purpose :   Global integer sum, 1D array case
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   )                   ::   kdim      ! ???
+      INTEGER, INTENT(inout), DIMENSION (kdim) ::   ktab      ! ???
+      !!
+      INTEGER :: ierror
+      INTEGER, DIMENSION (kdim) ::  iwork
+      !!----------------------------------------------------------------------
+      !
+      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_sum, mpi_comm_opa, ierror )
+      !
+      ktab(:) = iwork(:)
+      !
+   END SUBROUTINE mppsum_a_int
+
+
+   SUBROUTINE mppsum_int( ktab )
+      !!----------------------------------------------------------------------
+      !!                 ***  routine mppsum_int  ***
+      !!                  
+      !! ** Purpose :   Global integer sum
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(inout) ::   ktab
+      !! 
+      INTEGER :: ierror, iwork
+      !!----------------------------------------------------------------------
+      !
+      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_sum, mpi_comm_opa, ierror )
+      !
+      ktab = iwork
+      !
+   END SUBROUTINE mppsum_int
+
+
+   SUBROUTINE mppmax_a_real( ptab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                 ***  routine mppmax_a_real  ***
+      !!                  
+      !! ** Purpose :   Maximum
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                  ::   kdim
+      REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
+      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom
+      !!
+      INTEGER :: ierror, localcomm
+      REAL(wp), DIMENSION(kdim) ::  zwork
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa
+      IF( PRESENT(kcom) ) localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_max, localcomm, ierror )
+      ptab(:) = zwork(:)
+      !
+   END SUBROUTINE mppmax_a_real
+
+
+   SUBROUTINE mppmax_real( ptab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmax_real  ***
+      !!                    
+      !! ** Purpose :   Maximum
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(inout)           ::   ptab   ! ???
+      INTEGER , INTENT(in   ), OPTIONAL ::   kcom   ! ???
+      !!
+      INTEGER  ::   ierror, localcomm
+      REAL(wp) ::   zwork
+      !!----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_max, localcomm, ierror )
+      ptab = zwork
+      !
+   END SUBROUTINE mppmax_real
+
+
+   SUBROUTINE mppmin_a_real( ptab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                 ***  routine mppmin_a_real  ***
+      !!                  
+      !! ** Purpose :   Minimum of REAL, array case
+      !!
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                  ::   kdim
+      REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
+      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom
+      !!
+      INTEGER :: ierror, localcomm
+      REAL(wp), DIMENSION(kdim) ::   zwork
+      !!-----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) ) localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_min, localcomm, ierror )
+      ptab(:) = zwork(:)
+      !
+   END SUBROUTINE mppmin_a_real
+
+
+   SUBROUTINE mppmin_real( ptab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppmin_real  ***
+      !! 
+      !! ** Purpose :   minimum of REAL, scalar case
+      !!
+      !!-----------------------------------------------------------------------
+      REAL(wp), INTENT(inout)           ::   ptab        ! 
+      INTEGER , INTENT(in   ), OPTIONAL :: kcom
+      !!
+      INTEGER  ::   ierror
+      REAL(wp) ::   zwork
+      INTEGER :: localcomm
+      !!-----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_min, localcomm, ierror )
+      ptab = zwork
+      !
+   END SUBROUTINE mppmin_real
+
+
+   SUBROUTINE mppsum_a_real( ptab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsum_a_real  ***
+      !! 
+      !! ** Purpose :   global sum, REAL ARRAY argument case
+      !!
+      !!-----------------------------------------------------------------------
+      INTEGER , INTENT( in )                     ::   kdim      ! size of ptab
+      REAL(wp), DIMENSION(kdim), INTENT( inout ) ::   ptab      ! input array
+      INTEGER , INTENT( in ), OPTIONAL           :: kcom
+      !!
+      INTEGER                   ::   ierror    ! temporary integer
+      INTEGER                   ::   localcomm 
+      REAL(wp), DIMENSION(kdim) ::   zwork     ! temporary workspace 
+      !!-----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) )   localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_sum, localcomm, ierror )
+      ptab(:) = zwork(:)
+      !
+   END SUBROUTINE mppsum_a_real
+
+
+   SUBROUTINE mppsum_real( ptab, kcom )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsum_real  ***
+      !!              
+      !! ** Purpose :   global sum, SCALAR argument case
+      !!
+      !!-----------------------------------------------------------------------
+      REAL(wp), INTENT(inout)           ::   ptab   ! input scalar
+      INTEGER , INTENT(in   ), OPTIONAL ::   kcom
+      !!
+      INTEGER  ::   ierror, localcomm 
+      REAL(wp) ::   zwork
+      !!-----------------------------------------------------------------------
+      !
+      localcomm = mpi_comm_opa 
+      IF( PRESENT(kcom) ) localcomm = kcom
+      !
+      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_sum, localcomm, ierror )
+      ptab = zwork
+      !
+   END SUBROUTINE mppsum_real
+
+
+   SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki,kj )
+      !!------------------------------------------------------------------------
+      !!             ***  routine mpp_minloc  ***
+      !!
+      !! ** Purpose :   Compute the global minimum of an array ptab
+      !!              and also give its global position
+      !!
+      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
+      !!
+      !!--------------------------------------------------------------------------
+      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   ptab    ! Local 2D array
+      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pmask   ! Local mask
+      REAL(wp)                     , INTENT(  out) ::   pmin    ! Global minimum of ptab
+      INTEGER                      , INTENT(  out) ::   ki, kj   ! index of minimum in global frame
+      !!
+      INTEGER , DIMENSION(2)   ::   ilocs
+      INTEGER :: ierror
+      REAL(wp) ::   zmin   ! local minimum
+      REAL(wp), DIMENSION(2,1) ::   zain, zaout
+      !!-----------------------------------------------------------------------
+      !
+      zmin  = MINVAL( ptab(:,:) , mask= pmask == 1.e0 )
+      ilocs = MINLOC( ptab(:,:) , mask= pmask == 1.e0 )
+      !
+      ki = ilocs(1) + nimpp - 1
+      kj = ilocs(2) + njmpp - 1
+      !
+      zain(1,:)=zmin
+      zain(2,:)=ki+10000.*kj
+      !
+      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OPA,ierror)
+      !
+      pmin = zaout(1,1)
+      kj = INT(zaout(2,1)/10000.)
+      ki = INT(zaout(2,1) - 10000.*kj )
+      !
+   END SUBROUTINE mpp_minloc2d
+
+
+   SUBROUTINE mpp_minloc3d( ptab, pmask, pmin, ki, kj ,kk)
+      !!------------------------------------------------------------------------
+      !!             ***  routine mpp_minloc  ***
+      !!
+      !! ** Purpose :   Compute the global minimum of an array ptab
+      !!              and also give its global position
+      !!
+      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
+      !!
+      !!--------------------------------------------------------------------------
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   ptab         ! Local 2D array
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   pmask        ! Local mask
+      REAL(wp)                         , INTENT(  out) ::   pmin         ! Global minimum of ptab
+      INTEGER                          , INTENT(  out) ::   ki, kj, kk   ! index of minimum in global frame
+      !!
+      INTEGER  ::   ierror
+      REAL(wp) ::   zmin     ! local minimum
+      INTEGER , DIMENSION(3)   ::   ilocs
+      REAL(wp), DIMENSION(2,1) ::   zain, zaout
+      !!-----------------------------------------------------------------------
+      !
+      zmin  = MINVAL( ptab(:,:,:) , mask= pmask == 1.e0 )
+      ilocs = MINLOC( ptab(:,:,:) , mask= pmask == 1.e0 )
+      !
+      ki = ilocs(1) + nimpp - 1
+      kj = ilocs(2) + njmpp - 1
+      kk = ilocs(3)
+      !
+      zain(1,:)=zmin
+      zain(2,:)=ki+10000.*kj+100000000.*kk
+      !
+      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OPA,ierror)
+      !
+      pmin = zaout(1,1)
+      kk   = INT( zaout(2,1) / 100000000. )
+      kj   = INT( zaout(2,1) - kk * 100000000. ) / 10000
+      ki   = INT( zaout(2,1) - kk * 100000000. -kj * 10000. )
+      !
+   END SUBROUTINE mpp_minloc3d
+
+
+   SUBROUTINE mpp_maxloc2d( ptab, pmask, pmax, ki, kj )
+      !!------------------------------------------------------------------------
+      !!             ***  routine mpp_maxloc  ***
+      !!
+      !! ** Purpose :   Compute the global maximum of an array ptab
+      !!              and also give its global position
+      !!
+      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
+      !!
+      !!--------------------------------------------------------------------------
+      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   ptab     ! Local 2D array
+      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pmask    ! Local mask
+      REAL(wp)                     , INTENT(  out) ::   pmax     ! Global maximum of ptab
+      INTEGER                      , INTENT(  out) ::   ki, kj   ! index of maximum in global frame
+      !!  
+      INTEGER  :: ierror
+      INTEGER, DIMENSION (2)   ::   ilocs
+      REAL(wp) :: zmax   ! local maximum
+      REAL(wp), DIMENSION(2,1) ::   zain, zaout
+      !!-----------------------------------------------------------------------
+      !
+      zmax  = MAXVAL( ptab(:,:) , mask= pmask == 1.e0 )
+      ilocs = MAXLOC( ptab(:,:) , mask= pmask == 1.e0 )
+      !
+      ki = ilocs(1) + nimpp - 1
+      kj = ilocs(2) + njmpp - 1
+      !
+      zain(1,:) = zmax
+      zain(2,:) = ki + 10000. * kj
+      !
+      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OPA,ierror)
+      !
+      pmax = zaout(1,1)
+      kj   = INT( zaout(2,1) / 10000.     )
+      ki   = INT( zaout(2,1) - 10000.* kj )
+      !
+   END SUBROUTINE mpp_maxloc2d
+
+
+   SUBROUTINE mpp_maxloc3d( ptab, pmask, pmax, ki, kj, kk )
+      !!------------------------------------------------------------------------
+      !!             ***  routine mpp_maxloc  ***
+      !!
+      !! ** Purpose :  Compute the global maximum of an array ptab
+      !!              and also give its global position
+      !!
+      !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
+      !!
+      !!--------------------------------------------------------------------------
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   ptab         ! Local 2D array
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   pmask        ! Local mask
+      REAL(wp)                         , INTENT(  out) ::   pmax         ! Global maximum of ptab
+      INTEGER                          , INTENT(  out) ::   ki, kj, kk   ! index of maximum in global frame
+      !!   
+      REAL(wp) :: zmax   ! local maximum
+      REAL(wp), DIMENSION(2,1) ::   zain, zaout
+      INTEGER , DIMENSION(3)   ::   ilocs
+      INTEGER :: ierror
+      !!-----------------------------------------------------------------------
+      !
+      zmax  = MAXVAL( ptab(:,:,:) , mask= pmask == 1.e0 )
+      ilocs = MAXLOC( ptab(:,:,:) , mask= pmask == 1.e0 )
+      !
+      ki = ilocs(1) + nimpp - 1
+      kj = ilocs(2) + njmpp - 1
+      kk = ilocs(3)
+      !
+      zain(1,:)=zmax
+      zain(2,:)=ki+10000.*kj+100000000.*kk
+      !
+      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OPA,ierror)
+      !
+      pmax = zaout(1,1)
+      kk   = INT( zaout(2,1) / 100000000. )
+      kj   = INT( zaout(2,1) - kk * 100000000. ) / 10000
+      ki   = INT( zaout(2,1) - kk * 100000000. -kj * 10000. )
+      !
+   END SUBROUTINE mpp_maxloc3d
+
+
+   SUBROUTINE mppsync()
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppsync  ***
+      !!                   
+      !! ** Purpose :   Massively parallel processors, synchroneous
+      !!
+      !!-----------------------------------------------------------------------
+      INTEGER :: ierror
+      !!-----------------------------------------------------------------------
+      !
+      CALL mpi_barrier( mpi_comm_opa, ierror )
+      !
+   END SUBROUTINE mppsync
+
+
+   SUBROUTINE mppstop
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppstop  ***
+      !!                   
+      !! ** purpose :   Stop massilively parallel processors method
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   info
+      !!----------------------------------------------------------------------
+      !
+      CALL mppsync
+      CALL mpi_finalize( info )
+      !
+   END SUBROUTINE mppstop
+
+
+   SUBROUTINE mppobc( ptab, kd1, kd2, kl, kk, ktype, kij )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mppobc  ***
+      !! 
+      !! ** Purpose :   Message passing manadgement for open boundary
+      !!     conditions array
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
+      !!       between processors following neighboring subdomains.
+      !!       domain parameters
+      !!                    nlci   : first dimension of the local subdomain
+      !!                    nlcj   : second dimension of the local subdomain
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors 
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in   )                     ::   kd1, kd2   ! starting and ending indices
+      INTEGER , INTENT(in   )                     ::   kl         ! index of open boundary
+      INTEGER , INTENT(in   )                     ::   kk         ! vertical dimension
+      INTEGER , INTENT(in   )                     ::   ktype      ! define north/south or east/west cdt
+      !                                                           !  = 1  north/south  ;  = 2  east/west
+      INTEGER , INTENT(in   )                     ::   kij        ! horizontal dimension
+      REAL(wp), INTENT(inout), DIMENSION(kij,kk)  ::   ptab       ! variable array
+      !! 
+      INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
+      INTEGER  ::   iipt0, iipt1, ilpt1   ! temporary integers
+      INTEGER  ::   ijpt0, ijpt1          !    -          -
+      INTEGER  ::   imigr, iihom, ijhom   !    -          -
+      INTEGER ::   ml_req1, ml_req2, ml_err    ! for key_mpi_isend
+      INTEGER ::   ml_stat(MPI_STATUS_SIZE)    ! for key_mpi_isend
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztab   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      ! boundary condition initialization
+      ! ---------------------------------
+      ztab(:,:) = 0.e0
+      !
+      IF( ktype==1 ) THEN                                  ! north/south boundaries
+         iipt0 = MAX( 1, MIN(kd1 - nimpp+1, nlci     ) )
+         iipt1 = MAX( 0, MIN(kd2 - nimpp+1, nlci - 1 ) )
+         ilpt1 = MAX( 1, MIN(kd2 - nimpp+1, nlci     ) )
+         ijpt0 = MAX( 1, MIN(kl  - njmpp+1, nlcj     ) )
+         ijpt1 = MAX( 0, MIN(kl  - njmpp+1, nlcj - 1 ) )
+      ELSEIF( ktype==2 ) THEN                              ! east/west boundaries
+         iipt0 = MAX( 1, MIN(kl  - nimpp+1, nlci     ) )
+         iipt1 = MAX( 0, MIN(kl  - nimpp+1, nlci - 1 ) )
+         ijpt0 = MAX( 1, MIN(kd1 - njmpp+1, nlcj     ) )
+         ijpt1 = MAX( 0, MIN(kd2 - njmpp+1, nlcj - 1 ) )
+         ilpt1 = MAX( 1, MIN(kd2 - njmpp+1, nlcj     ) )
+      ELSE
+         CALL ctl_stop( 'mppobc: bad ktype' )
+      ENDIF
+      
+      ! Communication level by level
+      ! ----------------------------
+!!gm Remark : this is very time consumming!!!
+      !                                         ! ------------------------ !
+      DO jk = 1, kk                             !   Loop over the levels   !
+         !                                      ! ------------------------ !
+         !
+         IF( ktype == 1 ) THEN                               ! north/south boundaries
+            DO jj = ijpt0, ijpt1
+               DO ji = iipt0, iipt1
+                  ztab(ji,jj) = ptab(ji,jk)
+               END DO
+            END DO
+         ELSEIF( ktype == 2 ) THEN                           ! east/west boundaries
+            DO jj = ijpt0, ijpt1
+               DO ji = iipt0, iipt1
+                  ztab(ji,jj) = ptab(jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+
+         ! 1. East and west directions
+         ! ---------------------------
+         !
+         IF( nbondi /= 2 ) THEN         ! Read Dirichlet lateral conditions
+            iihom = nlci-nreci
+            DO jl = 1, jpreci
+               t2ew(:,jl,1) = ztab(jpreci+jl,:)
+               t2we(:,jl,1) = ztab(iihom +jl,:)
+            END DO
+         ENDIF
+         !
+         !                              ! Migrations
+         imigr=jpreci*jpj
+         !
+         IF( nbondi == -1 ) THEN
+            CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req1 )
+            CALL mpprecv( 1, t2ew(1,1,2), imigr )
+            IF(l_isend)   CALL mpi_wait( ml_req1, ml_stat, ml_err )
+         ELSEIF( nbondi == 0 ) THEN
+            CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+            CALL mppsend( 2, t2we(1,1,1), imigr, noea, ml_req2 )
+            CALL mpprecv( 1, t2ew(1,1,2), imigr )
+            CALL mpprecv( 2, t2we(1,1,2), imigr )
+            IF(l_isend)   CALL mpi_wait( ml_req1, ml_stat, ml_err )
+            IF(l_isend)   CALL mpi_wait( ml_req2, ml_stat, ml_err )
+         ELSEIF( nbondi == 1 ) THEN
+            CALL mppsend( 1, t2ew(1,1,1), imigr, nowe, ml_req1 )
+            CALL mpprecv( 2, t2we(1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait( ml_req1, ml_stat, ml_err )
+         ENDIF
+         !
+         !                              ! Write Dirichlet lateral conditions
+         iihom = nlci-jpreci
+         !
+         IF( nbondi == 0 .OR. nbondi == 1 ) THEN
+            DO jl = 1, jpreci
+               ztab(jl,:) = t2we(:,jl,2)
+            END DO
+         ENDIF
+         IF( nbondi == -1 .OR. nbondi == 0 ) THEN
+            DO jl = 1, jpreci
+               ztab(iihom+jl,:) = t2ew(:,jl,2)
+            END DO
+         ENDIF
+
+
+         ! 2. North and south directions
+         ! -----------------------------
+         !
+         IF( nbondj /= 2 ) THEN         ! Read Dirichlet lateral conditions
+            ijhom = nlcj-nrecj
+            DO jl = 1, jprecj
+               t2sn(:,jl,1) = ztab(:,ijhom +jl)
+               t2ns(:,jl,1) = ztab(:,jprecj+jl)
+            END DO
+         ENDIF
+         !
+         !                              ! Migrations
+         imigr = jprecj * jpi
+         !
+         IF( nbondj == -1 ) THEN
+            CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req1 )
+            CALL mpprecv( 3, t2ns(1,1,2), imigr )
+            IF(l_isend) CALL mpi_wait( ml_req1, ml_stat, ml_err )
+         ELSEIF( nbondj == 0 ) THEN
+            CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+            CALL mppsend( 4, t2sn(1,1,1), imigr, nono, ml_req2 )
+            CALL mpprecv( 3, t2ns(1,1,2), imigr )
+            CALL mpprecv( 4, t2sn(1,1,2), imigr )
+            IF( l_isend )   CALL mpi_wait( ml_req1, ml_stat, ml_err )
+            IF( l_isend )   CALL mpi_wait( ml_req2, ml_stat, ml_err )
+         ELSEIF( nbondj == 1 ) THEN
+            CALL mppsend( 3, t2ns(1,1,1), imigr, noso, ml_req1 )
+            CALL mpprecv( 4, t2sn(1,1,2), imigr)
+            IF( l_isend )   CALL mpi_wait( ml_req1, ml_stat, ml_err )
+         ENDIF
+         !
+         !                              ! Write Dirichlet lateral conditions
+         ijhom = nlcj - jprecj
+         IF( nbondj == 0 .OR. nbondj == 1 ) THEN
+            DO jl = 1, jprecj
+               ztab(:,jl) = t2sn(:,jl,2)
+            END DO
+         ENDIF
+         IF( nbondj == 0 .OR. nbondj == -1 ) THEN
+            DO jl = 1, jprecj
+               ztab(:,ijhom+jl) = t2ns(:,jl,2)
+            END DO
+         ENDIF
+         IF( ktype==1 .AND. kd1 <= jpi+nimpp-1 .AND. nimpp <= kd2 ) THEN
+            DO jj = ijpt0, ijpt1            ! north/south boundaries
+               DO ji = iipt0,ilpt1
+                  ptab(ji,jk) = ztab(ji,jj)  
+               END DO
+            END DO
+         ELSEIF( ktype==2 .AND. kd1 <= jpj+njmpp-1 .AND. njmpp <= kd2 ) THEN
+            DO jj = ijpt0, ilpt1            ! east/west boundaries
+               DO ji = iipt0,iipt1
+                  ptab(jj,jk) = ztab(ji,jj) 
+               END DO
+            END DO
+         ENDIF
+         !
+      END DO
+      !
+   END SUBROUTINE mppobc
+   
+
+   SUBROUTINE mpp_comm_free( kcom )
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kcom
+      !!
+      INTEGER :: ierr
+      !!----------------------------------------------------------------------
+      !
+      CALL MPI_COMM_FREE(kcom, ierr)
+      !
+   END SUBROUTINE mpp_comm_free
+
+
+   SUBROUTINE mpp_ini_ice( pindic )
+      !!----------------------------------------------------------------------
+      !!               ***  routine mpp_ini_ice  ***
+      !!
+      !! ** Purpose :   Initialize special communicator for ice areas
+      !!      condition together with global variables needed in the ddmpp folding
+      !!
+      !! ** Method  : - Look for ice processors in ice routines
+      !!              - Put their number in nrank_ice
+      !!              - Create groups for the world processors and the ice processors
+      !!              - Create a communicator for ice processors
+      !!
+      !! ** output
+      !!      njmppmax = njmpp for northern procs
+      !!      ndim_rank_ice = number of processors with ice
+      !!      nrank_ice (ndim_rank_ice) = ice processors
+      !!      ngrp_world = group ID for the world processors
+      !!      ngrp_ice = group ID for the ice processors
+      !!      ncomm_ice = communicator for the ice procs.
+      !!      n_ice_root = number (in the world) of proc 0 in the ice comm.
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: pindic
+      !!
+      INTEGER :: ierr
+      INTEGER :: jjproc
+      INTEGER :: ii
+      INTEGER, DIMENSION(jpnij) :: kice
+      INTEGER, DIMENSION(jpnij) :: zwork
+      !!----------------------------------------------------------------------
+      !
+      ! Look for how many procs with sea-ice
+      !
+      kice = 0
+      DO jjproc = 1, jpnij
+         IF( jjproc == narea .AND. pindic .GT. 0 )   kice(jjproc) = 1    
+      END DO
+      !
+      zwork = 0
+      CALL MPI_ALLREDUCE( kice, zwork, jpnij, mpi_integer, mpi_sum, mpi_comm_opa, ierr )
+      ndim_rank_ice = SUM( zwork )          
+
+      ! Allocate the right size to nrank_north
+#if ! defined key_agrif
+      IF( ALLOCATED ( nrank_ice ) )   DEALLOCATE( nrank_ice )
+#else
+      IF( ASSOCIATED( nrank_ice ) )   DEALLOCATE( nrank_ice )
+#endif
+      ALLOCATE( nrank_ice(ndim_rank_ice) )
+      !
+      ii = 0     
+      nrank_ice = 0
+      DO jjproc = 1, jpnij
+         IF( zwork(jjproc) == 1) THEN
+            ii = ii + 1
+            nrank_ice(ii) = jjproc -1 
+         ENDIF
+      END DO
+
+      ! Create the world group
+      CALL MPI_COMM_GROUP( mpi_comm_opa, ngrp_world, ierr )
+
+      ! Create the ice group from the world group
+      CALL MPI_GROUP_INCL( ngrp_world, ndim_rank_ice, nrank_ice, ngrp_ice, ierr )
+
+      ! Create the ice communicator , ie the pool of procs with sea-ice
+      CALL MPI_COMM_CREATE( mpi_comm_opa, ngrp_ice, ncomm_ice, ierr )
+
+      ! Find proc number in the world of proc 0 in the north
+      ! The following line seems to be useless, we just comment & keep it as reminder
+      ! CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_ice,1,0,ngrp_world,n_ice_root,ierr)
+      !
+   END SUBROUTINE mpp_ini_ice
+
+
+   SUBROUTINE mpp_ini_znl
+      !!----------------------------------------------------------------------
+      !!               ***  routine mpp_ini_znl  ***
+      !!
+      !! ** Purpose :   Initialize special communicator for computing zonal sum
+      !!
+      !! ** Method  : - Look for processors in the same row
+      !!              - Put their number in nrank_znl
+      !!              - Create group for the znl processors
+      !!              - Create a communicator for znl processors
+      !!              - Determine if processor should write znl files
+      !!
+      !! ** output
+      !!      ndim_rank_znl = number of processors on the same row
+      !!      ngrp_znl = group ID for the znl processors
+      !!      ncomm_znl = communicator for the ice procs.
+      !!      n_znl_root = number (in the world) of proc 0 in the ice comm.
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr
+      INTEGER :: jproc
+      INTEGER :: ii
+      INTEGER, DIMENSION(jpnij) :: kwork
+      !
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_world     : ', ngrp_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_world : ', mpi_comm_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_opa   : ', mpi_comm_opa
+      !
+      IF ( jpnj == 1 ) THEN
+         ngrp_znl  = ngrp_world
+         ncomm_znl = mpi_comm_opa
+      ELSE
+         !
+         CALL MPI_ALLGATHER ( njmpp, 1, mpi_integer, kwork, 1, mpi_integer, mpi_comm_opa, ierr )
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - kwork pour njmpp : ', kwork
+         !-$$        CALL flush(numout)
+         !
+         ! Count number of processors on the same row
+         ndim_rank_znl = 0
+         DO jproc=1,jpnij
+            IF ( kwork(jproc) == njmpp ) THEN
+               ndim_rank_znl = ndim_rank_znl + 1
+            ENDIF
+         END DO
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ndim_rank_znl : ', ndim_rank_znl
+         !-$$        CALL flush(numout)
+         ! Allocate the right size to nrank_znl
+#if ! defined key_agrif
+         IF (ALLOCATED (nrank_znl)) DEALLOCATE(nrank_znl)
+#else
+         IF (ASSOCIATED(nrank_znl)) DEALLOCATE(nrank_znl)
+#endif
+         ALLOCATE(nrank_znl(ndim_rank_znl))
+         ii = 0     
+         nrank_znl (:) = 0
+         DO jproc=1,jpnij
+            IF ( kwork(jproc) == njmpp) THEN
+               ii = ii + 1
+               nrank_znl(ii) = jproc -1 
+            ENDIF
+         END DO
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - nrank_znl : ', nrank_znl
+         !-$$        CALL flush(numout)
+
+         ! Create the opa group
+         CALL MPI_COMM_GROUP(mpi_comm_opa,ngrp_opa,ierr)
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_opa : ', ngrp_opa
+         !-$$        CALL flush(numout)
+
+         ! Create the znl group from the opa group
+         CALL MPI_GROUP_INCL  ( ngrp_opa, ndim_rank_znl, nrank_znl, ngrp_znl, ierr )
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_znl ', ngrp_znl
+         !-$$        CALL flush(numout)
+
+         ! Create the znl communicator from the opa communicator, ie the pool of procs in the same row
+         CALL MPI_COMM_CREATE ( mpi_comm_opa, ngrp_znl, ncomm_znl, ierr )
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ncomm_znl ', ncomm_znl
+         !-$$        CALL flush(numout)
+         !
+      END IF
+
+      ! Determines if processor if the first (starting from i=1) on the row
+      IF ( jpni == 1 ) THEN 
+         l_znl_root = .TRUE.
+      ELSE
+         l_znl_root = .FALSE.
+         kwork (1) = nimpp
+         CALL mpp_min ( kwork(1), kcom = ncomm_znl)
+         IF ( nimpp == kwork(1)) l_znl_root = .TRUE.
+      END IF
+
+   END SUBROUTINE mpp_ini_znl
+
+
+   SUBROUTINE mpp_ini_north
+      !!----------------------------------------------------------------------
+      !!               ***  routine mpp_ini_north  ***
+      !!
+      !! ** Purpose :   Initialize special communicator for north folding 
+      !!      condition together with global variables needed in the mpp folding
+      !!
+      !! ** Method  : - Look for northern processors
+      !!              - Put their number in nrank_north
+      !!              - Create groups for the world processors and the north processors
+      !!              - Create a communicator for northern processors
+      !!
+      !! ** output
+      !!      njmppmax = njmpp for northern procs
+      !!      ndim_rank_north = number of processors in the northern line
+      !!      nrank_north (ndim_rank_north) = number  of the northern procs.
+      !!      ngrp_world = group ID for the world processors
+      !!      ngrp_north = group ID for the northern processors
+      !!      ncomm_north = communicator for the northern procs.
+      !!      north_root = number (in the world) of proc 0 in the northern comm.
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   ierr
+      INTEGER ::   jjproc
+      INTEGER ::   ii, ji
+      !!----------------------------------------------------------------------
+      !
+      njmppmax = MAXVAL( njmppt )
+      !
+      ! Look for how many procs on the northern boundary
+      ndim_rank_north = 0
+      DO jjproc = 1, jpnij
+         IF( njmppt(jjproc) == njmppmax )   ndim_rank_north = ndim_rank_north + 1
+      END DO
+      !
+      ! Allocate the right size to nrank_north
+#if ! defined key_agrif
+      IF (ALLOCATED (nrank_north)) DEALLOCATE(nrank_north)
+#else
+      IF (ASSOCIATED(nrank_north)) DEALLOCATE(nrank_north)
+#endif
+      ALLOCATE( nrank_north(ndim_rank_north) )
+
+      ! Fill the nrank_north array with proc. number of northern procs.
+      ! Note : the rank start at 0 in MPI
+      ii = 0
+      DO ji = 1, jpnij
+         IF ( njmppt(ji) == njmppmax   ) THEN
+            ii=ii+1
+            nrank_north(ii)=ji-1
+         END IF
+      END DO
+      !
+      ! create the world group
+      CALL MPI_COMM_GROUP( mpi_comm_opa, ngrp_world, ierr )
+      !
+      ! Create the North group from the world group
+      CALL MPI_GROUP_INCL( ngrp_world, ndim_rank_north, nrank_north, ngrp_north, ierr )
+      !
+      ! Create the North communicator , ie the pool of procs in the north group
+      CALL MPI_COMM_CREATE( mpi_comm_opa, ngrp_north, ncomm_north, ierr )
+      !
+   END SUBROUTINE mpp_ini_north
+
+
+   SUBROUTINE mpp_lbc_north_3d( pt3d, cd_type, psgn )
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_lbc_north_3d  ***
+      !!
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
+      !!              in mpp configuration in case of jpn1 > 1
+      !!
+      !! ** Method  :   North fold condition and mpp with more than one proc
+      !!              in i-direction require a specific treatment. We gather 
+      !!              the 4 northern lines of the global domain on 1 processor
+      !!              and apply lbc north-fold on this sub array. Then we
+      !!              scatter the north fold array back to the processors.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d      ! 3D array on which the b.c. is applied
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
+      !                                                              !   = T ,  U , V , F or W  gridpoints
+      REAL(wp)                        , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold 
+      !!                                                             ! =  1. , the sign is kept
+      INTEGER ::   ji, jj, jr
+      INTEGER ::   ierr, itaille, ildi, ilei, iilb
+      INTEGER ::   ijpj, ijpjm1, ij, iproc
+      REAL(wp), DIMENSION(jpiglo,4,jpk)      ::   ztab
+      REAL(wp), DIMENSION(jpi   ,4,jpk)      ::   znorthloc
+      REAL(wp), DIMENSION(jpi   ,4,jpk,jpni) ::   znorthgloio
+      !!----------------------------------------------------------------------
+      !   
+      ijpj   = 4
+      ijpjm1 = 3
+      !
+      DO jj = nlcj - ijpj +1, nlcj          ! put in znorthloc the last 4 jlines of pt3d
+         ij = jj - nlcj + ijpj
+         znorthloc(:,ij,:) = pt3d(:,jj,:)
+      END DO
+      !
+      !                                     ! Build in procs of ncomm_north the znorthgloio
+      itaille = jpi * jpk * ijpj
+      CALL MPI_ALLGATHER( znorthloc  , itaille, MPI_DOUBLE_PRECISION,                &
+         &                znorthgloio, itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+      !
+      !                                     ! recover the global north array
+      DO jr = 1, ndim_rank_north
+         iproc = nrank_north(jr) + 1
+         ildi  = nldit (iproc)
+         ilei  = nleit (iproc)
+         iilb  = nimppt(iproc)
+         DO jj = 1, 4
+            DO ji = ildi, ilei
+               ztab(ji+iilb-1,jj,:) = znorthgloio(ji,jj,:,jr)
+            END DO
+         END DO
+      END DO
+      !
+      CALL lbc_nfd( ztab, cd_type, psgn )   ! North fold boundary condition
+      !
+      DO jj = nlcj-ijpj+1, nlcj             ! Scatter back to pt3d
+         ij = jj - nlcj + ijpj
+         DO ji= 1, nlci
+            pt3d(ji,jj,:) = ztab(ji+nimpp-1,ij,:)
+         END DO
+      END DO
+      !
+   END SUBROUTINE mpp_lbc_north_3d
+
+
+   SUBROUTINE mpp_lbc_north_2d( pt2d, cd_type, psgn)
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_lbc_north_2d  ***
+      !!
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
+      !!              in mpp configuration in case of jpn1 > 1 (for 2d array )
+      !!
+      !! ** Method  :   North fold condition and mpp with more than one proc
+      !!              in i-direction require a specific treatment. We gather 
+      !!              the 4 northern lines of the global domain on 1 processor
+      !!              and apply lbc north-fold on this sub array. Then we
+      !!              scatter the north fold array back to the processors.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d      ! 3D array on which the b.c. is applied
+      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
+      !                                                          !   = T ,  U , V , F or W  gridpoints
+      REAL(wp)                    , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold 
+      !!                                                             ! =  1. , the sign is kept
+      INTEGER ::   ji, jj, jr
+      INTEGER ::   ierr, itaille, ildi, ilei, iilb
+      INTEGER ::   ijpj, ijpjm1, ij, iproc
+      REAL(wp), DIMENSION(jpiglo,4)      ::   ztab
+      REAL(wp), DIMENSION(jpi   ,4)      ::   znorthloc
+      REAL(wp), DIMENSION(jpi   ,4,jpni) ::   znorthgloio
+      !!----------------------------------------------------------------------
+      !
+      ijpj   = 4
+      ijpjm1 = 3
+      !
+      DO jj = nlcj-ijpj+1, nlcj             ! put in znorthloc the last 4 jlines of pt2d
+         ij = jj - nlcj + ijpj
+         znorthloc(:,ij) = pt2d(:,jj)
+      END DO
+
+      !                                     ! Build in procs of ncomm_north the znorthgloio
+      itaille = jpi * ijpj
+      CALL MPI_ALLGATHER( znorthloc  , itaille, MPI_DOUBLE_PRECISION,        &
+         &                znorthgloio, itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+      !
+      DO jr = 1, ndim_rank_north            ! recover the global north array
+         iproc = nrank_north(jr) + 1
+         ildi=nldit (iproc)
+         ilei=nleit (iproc)
+         iilb=nimppt(iproc)
+         DO jj = 1, 4
+            DO ji = ildi, ilei
+               ztab(ji+iilb-1,jj) = znorthgloio(ji,jj,jr)
+            END DO
+         END DO
+      END DO
+      !
+      CALL lbc_nfd( ztab, cd_type, psgn )   ! North fold boundary condition
+      !
+      !
+      DO jj = nlcj-ijpj+1, nlcj             ! Scatter back to pt2d
+         ij = jj - nlcj + ijpj
+         DO ji = 1, nlci
+            pt2d(ji,jj) = ztab(ji+nimpp-1,ij)
+         END DO
+      END DO
+      !
+   END SUBROUTINE mpp_lbc_north_2d
+
+
+   SUBROUTINE mpp_lbc_north_e( pt2d, cd_type, psgn)
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_lbc_north_2d  ***
+      !!
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
+      !!              in mpp configuration in case of jpn1 > 1 and for 2d 
+      !!              array with outer extra halo
+      !!
+      !! ** Method  :   North fold condition and mpp with more than one proc
+      !!              in i-direction require a specific treatment. We gather 
+      !!              the 4+2*jpr2dj northern lines of the global domain on 1 
+      !!              processor and apply lbc north-fold on this sub array. 
+      !!              Then we scatter the north fold array back to the processors.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
+      CHARACTER(len=1)                                            , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
+      !                                                                                         !   = T ,  U , V , F or W -points
+      REAL(wp)                                                    , INTENT(in   ) ::   psgn     ! = -1. the sign change across the  
+      !!                                                                                        ! north fold, =  1. otherwise
+      INTEGER ::   ji, jj, jr
+      INTEGER ::   ierr, itaille, ildi, ilei, iilb
+      INTEGER ::   ijpj, ij, iproc
+      REAL(wp), DIMENSION(jpiglo,4+2*jpr2dj)      ::   ztab
+      REAL(wp), DIMENSION(jpi   ,4+2*jpr2dj)      ::   znorthloc
+      REAL(wp), DIMENSION(jpi   ,4+2*jpr2dj,jpni) ::   znorthgloio
+      !!----------------------------------------------------------------------
+      !
+      ijpj=4
+
+      ij=0
+      ! put in znorthloc the last 4 jlines of pt2d
+      DO jj = nlcj - ijpj + 1 - jpr2dj, nlcj +jpr2dj
+         ij = ij + 1
+         DO ji = 1, jpi
+            znorthloc(ji,ij)=pt2d(ji,jj)
+         END DO
+      END DO
+      !
+      itaille = jpi * ( ijpj + 2 * jpr2dj )
+      CALL MPI_ALLGATHER( znorthloc(1,1)    , itaille, MPI_DOUBLE_PRECISION,    &
+         &                znorthgloio(1,1,1), itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+      !
+      DO jr = 1, ndim_rank_north            ! recover the global north array
+         iproc = nrank_north(jr) + 1
+         ildi = nldit (iproc)
+         ilei = nleit (iproc)
+         iilb = nimppt(iproc)
+         DO jj = 1, ijpj+2*jpr2dj
+            DO ji = ildi, ilei
+               ztab(ji+iilb-1,jj) = znorthgloio(ji,jj,jr)
+            END DO
+         END DO
+      END DO
+
+
+      ! 2. North-Fold boundary conditions
+      ! ----------------------------------
+      CALL lbc_nfd( ztab(:,:), cd_type, psgn, pr2dj = jpr2dj )
+
+      ij = jpr2dj
+      !! Scatter back to pt2d
+      DO jj = nlcj - ijpj + 1 , nlcj +jpr2dj
+      ij  = ij +1 
+         DO ji= 1, nlci
+            pt2d(ji,jj) = ztab(ji+nimpp-1,ij)
+         END DO
+      END DO
+      !
+   END SUBROUTINE mpp_lbc_north_e
+
+
+   SUBROUTINE mpi_init_opa( code )
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_init.opa  ***
+      !!
+      !! ** Purpose :: export and attach a MPI buffer for bsend
+      !!
+      !! ** Method  :: define buffer size in namelist, if 0 no buffer attachment
+      !!            but classical mpi_init
+      !! 
+      !! History :: 01/11 :: IDRIS initial version for IBM only  
+      !!            08/04 :: R. Benshila, generalisation
+      !!---------------------------------------------------------------------
+      INTEGER                                 :: code, ierr
+      LOGICAL                                 :: mpi_was_called
+      !!---------------------------------------------------------------------
+      !
+      CALL mpi_initialized( mpi_was_called, code )      ! MPI initialization
+      IF ( code /= MPI_SUCCESS ) THEN
+         CALL ctl_stop( ' lib_mpp: Error in routine mpi_initialized' )
+         CALL mpi_abort( mpi_comm_world, code, ierr )
+      ENDIF
+      !
+      IF( .NOT. mpi_was_called ) THEN
+         CALL mpi_init( code )
+         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code )
+         IF ( code /= MPI_SUCCESS ) THEN
+            CALL ctl_stop( ' lib_mpp: Error in routine mpi_comm_dup' )
+            CALL mpi_abort( mpi_comm_world, code, ierr )
+         ENDIF
+      ENDIF
+      !
+      IF( nn_buffer > 0 ) THEN
+         IF ( lwp ) WRITE(numout,*) 'mpi_bsend, buffer allocation of  : ', nn_buffer
+         ! Buffer allocation and attachment
+         ALLOCATE( tampon(nn_buffer) )
+         CALL mpi_buffer_attach( tampon, nn_buffer,code )
+      ENDIF
+      !
+   END SUBROUTINE mpi_init_opa
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case:            Dummy module        share memory computing
+   !!----------------------------------------------------------------------
+   INTERFACE mpp_sum
+      MODULE PROCEDURE mpp_sum_a2s, mpp_sum_as, mpp_sum_ai, mpp_sum_s, mpp_sum_i
+   END INTERFACE
+   INTERFACE mpp_max
+      MODULE PROCEDURE mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real
+   END INTERFACE
+   INTERFACE mpp_min
+      MODULE PROCEDURE mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real
+   END INTERFACE
+   INTERFACE mppobc
+      MODULE PROCEDURE mppobc_1d, mppobc_2d, mppobc_3d, mppobc_4d
+   END INTERFACE
+   INTERFACE mpp_minloc
+      MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
+   END INTERFACE
+   INTERFACE mpp_maxloc
+      MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
+   END INTERFACE
+
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.      !: mpp flag
+   INTEGER :: ncomm_ice
+
+CONTAINS
+
+   FUNCTION mynode( ldtxt, localComm ) RESULT (function_value)
+      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt 
+      INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm
+      IF( PRESENT( localComm ) .OR. .NOT.PRESENT( localComm ) )   function_value = 0
+      IF( .FALSE. )   ldtxt(:) = 'never done'
+   END FUNCTION mynode
+
+   SUBROUTINE mppsync                       ! Dummy routine
+   END SUBROUTINE mppsync
+
+   SUBROUTINE mpp_sum_as( parr, kdim, kcom )      ! Dummy routine
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_as: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mpp_sum_as
+
+   SUBROUTINE mpp_sum_a2s( parr, kdim, kcom )      ! Dummy routine
+      REAL   , DIMENSION(:,:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_a2s: You should not have seen this print! error?', kdim, parr(1,1), kcom
+   END SUBROUTINE mpp_sum_a2s
+
+   SUBROUTINE mpp_sum_ai( karr, kdim, kcom )      ! Dummy routine
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_ai: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mpp_sum_ai
+
+   SUBROUTINE mpp_sum_s( psca, kcom )            ! Dummy routine
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_s: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mpp_sum_s
+
+   SUBROUTINE mpp_sum_i( kint, kcom )            ! Dummy routine
+      integer               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mpp_sum_i: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mpp_sum_i
+
+   SUBROUTINE mppmax_a_real( parr, kdim, kcom )
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mppmax_a_real
+
+   SUBROUTINE mppmax_real( psca, kcom )
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_real: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mppmax_real
+
+   SUBROUTINE mppmin_a_real( parr, kdim, kcom )
+      REAL   , DIMENSION(:) :: parr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
+   END SUBROUTINE mppmin_a_real
+
+   SUBROUTINE mppmin_real( psca, kcom )
+      REAL                  :: psca
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_real: You should not have seen this print! error?', psca, kcom
+   END SUBROUTINE mppmin_real
+
+   SUBROUTINE mppmax_a_int( karr, kdim ,kcom)
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mppmax_a_int
+
+   SUBROUTINE mppmax_int( kint, kcom)
+      INTEGER               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmax_int: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mppmax_int
+
+   SUBROUTINE mppmin_a_int( karr, kdim, kcom )
+      INTEGER, DIMENSION(:) :: karr
+      INTEGER               :: kdim
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
+   END SUBROUTINE mppmin_a_int
+
+   SUBROUTINE mppmin_int( kint, kcom )
+      INTEGER               :: kint
+      INTEGER, OPTIONAL     :: kcom 
+      WRITE(*,*) 'mppmin_int: You should not have seen this print! error?', kint, kcom
+   END SUBROUTINE mppmin_int
+
+   SUBROUTINE mppobc_1d( parr, kd1, kd2, kl, kk, ktype, kij )
+      INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+      REAL, DIMENSION(:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?', parr(1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_1d
+
+   SUBROUTINE mppobc_2d( parr, kd1, kd2, kl, kk, ktype, kij )
+      INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+      REAL, DIMENSION(:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?', parr(1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_2d
+
+   SUBROUTINE mppobc_3d( parr, kd1, kd2, kl, kk, ktype, kij )
+      INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+      REAL, DIMENSION(:,:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?', parr(1,1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_3d
+
+   SUBROUTINE mppobc_4d( parr, kd1, kd2, kl, kk, ktype, kij )
+      INTEGER  ::   kd1, kd2, kl , kk, ktype, kij
+      REAL, DIMENSION(:,:,:,:) ::   parr           ! variable array
+      WRITE(*,*) 'mppobc: You should not have seen this print! error?', parr(1,1,1,1), kd1, kd2, kl, kk, ktype, kij
+   END SUBROUTINE mppobc_4d
+
+   SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki, kj )
+      REAL                   :: pmin
+      REAL , DIMENSION (:,:) :: ptab, pmask
+      INTEGER :: ki, kj
+      WRITE(*,*) 'mpp_minloc2d: You should not have seen this print! error?', pmin, ki, kj, ptab(1,1), pmask(1,1)
+   END SUBROUTINE mpp_minloc2d
+
+   SUBROUTINE mpp_minloc3d( ptab, pmask, pmin, ki, kj, kk )
+      REAL                     :: pmin
+      REAL , DIMENSION (:,:,:) :: ptab, pmask
+      INTEGER :: ki, kj, kk
+      WRITE(*,*) 'mpp_minloc3d: You should not have seen this print! error?', pmin, ki, kj, kk, ptab(1,1,1), pmask(1,1,1)
+   END SUBROUTINE mpp_minloc3d
+
+   SUBROUTINE mpp_maxloc2d( ptab, pmask, pmax, ki, kj )
+      REAL                   :: pmax
+      REAL , DIMENSION (:,:) :: ptab, pmask
+      INTEGER :: ki, kj
+      WRITE(*,*) 'mpp_maxloc2d: You should not have seen this print! error?', pmax, ki, kj, ptab(1,1), pmask(1,1)
+   END SUBROUTINE mpp_maxloc2d
+
+   SUBROUTINE mpp_maxloc3d( ptab, pmask, pmax, ki, kj, kk )
+      REAL                     :: pmax
+      REAL , DIMENSION (:,:,:) :: ptab, pmask
+      INTEGER :: ki, kj, kk
+      WRITE(*,*) 'mpp_maxloc3d: You should not have seen this print! error?', pmax, ki, kj, kk, ptab(1,1,1), pmask(1,1,1)
+   END SUBROUTINE mpp_maxloc3d
+
+   SUBROUTINE mppstop
+      WRITE(*,*) 'mppstop: You should not have seen this print! error?'
+   END SUBROUTINE mppstop
+
+   SUBROUTINE mpp_ini_ice( kcom )
+      INTEGER :: kcom
+      WRITE(*,*) 'mpp_ini_ice: You should not have seen this print! error?', kcom
+   END SUBROUTINE mpp_ini_ice
+
+   SUBROUTINE mpp_ini_znl
+      WRITE(*,*) 'mpp_ini_znl: You should not have seen this print! error?'
+   END SUBROUTINE mpp_ini_znl
+
+   SUBROUTINE mpp_comm_free( kcom )
+      INTEGER :: kcom
+      WRITE(*,*) 'mpp_comm_free: You should not have seen this print! error?', kcom
+   END SUBROUTINE mpp_comm_free
+
+#endif
+   !!----------------------------------------------------------------------
+END MODULE lib_mpp
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_print.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_print.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/lib_print.f90	(revision 1844)
@@ -0,0 +1,265 @@
+MODULE lib_print
+   !!======================================================================
+   !!                    ***  MODULE  lib_print  ***
+   !! print librairy :  formated real and integer array print
+   !!=====================================================================
+      
+   !!----------------------------------------------------------------------
+   !!   prihin       : print an integer 2D horizontal field
+   !!   prihre       : print an real 2D horizontal field
+   !!   prizre       : print an real 2D vertical field
+   !!----------------------------------------------------------------------
+   !! * Mules used
+   USE par_kind      ! kind parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC prihin, prihre, prizre
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE prihin( ktab, ki   , kj   , kideb, kifin ,   &
+                      kind, kjdeb, kjfin, kjnd , kscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  prihre  ***
+      !!  
+      !! ** purpose :   Print an integer field
+      !!
+      !! ** method :   format of print is selected with the dummy argument kscale
+      !!
+      !! History :
+      !!        !  90-04 (0. Marti)  Original code
+      !!        !  92-02 (M. Imbard)
+      !!        !  03-07 (G. Madec)  F90, free form
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj,                 &  ! array dimensions
+         kideb, kifin, kind,     &  ! first and last index, increment for i 
+         kjdeb, kjfin, kjnd,     &  ! first and last index, increment for j
+         kscale,                 &  ! kscale=0 or > 5  print ktab with format i8
+      !                             !         kscale=1 print ktab with format i1
+      !                             !         kscale=2 print ktab with format i2
+      !                             !         kscale=3 print ktab with format i3
+      !                             !         kscale=4 print ktab with format i4
+      !                             !         kscale=5 print ktab with format i5
+         kumout                     ! unit in which print
+      INTEGER, DIMENSION(ki,kj), INTENT( in ) ::   &
+         ktab                       ! integer 2D array to be print
+
+      !! * local declarations
+      INTEGER ::   ji, jj, jn       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+      INTEGER ::   iind, ijnd       ! temporary integers
+
+      isca = 10
+      IF( kscale == 0 )   isca = 10
+      IF( kscale == 1 )   isca = 100
+      IF( kscale == 2 )   isca = 60
+      IF( kscale == 3 )   isca = 40
+      IF( kscale == 4 )   isca = 30
+      IF( kscale == 5 )   isca = 20
+
+      iind = MAX( 1, kind )
+      ijnd = MAX( 1, kjnd )
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
+
+        IF( il1 > kifin ) RETURN
+        WRITE(kumout,'(/)')
+        il2 = il1+iind*(isca-1)
+        IF( il2 > kifin )   il2 = kifin
+
+        IF( kscale == 1 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)') il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,100i1)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 2 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,60i2)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 3 ) THEN
+            WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,40i3)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 4 ) THEN
+            WRITE(kumout,'(4x,30i4,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,30i4)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSEIF( kscale == 5 ) THEN
+            WRITE(kumout,'(4x,20i5,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,20i5)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ELSE
+            WRITE(kumout,'(4x,10i8,/)') ( ji, ji = il1, il2, iind )
+            DO jj = kjfin, kjdeb, -ijnd
+              WRITE (kumout,'(1x,i3,10i8)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
+            END DO  
+        ENDIF
+
+        il1 = il1 + iind * isca
+      END DO  
+
+   END SUBROUTINE prihin
+
+
+   SUBROUTINE prihre( ptab, ki   , kj   , kideb, kifin ,   &
+                      kind, kjdeb, kjfin, kjnd , pscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE prihre  ***
+      !!      
+      !! ** purpose :   Print a real field with the format 10e12.4 or 20f6.2
+      !!
+      !! ** method  :   the print format is selected with the pscale argument
+      !!
+      !! History :
+      !!   1.0  !  86-01  (P. Andrich)  Original code
+      !!        !  89-11  (C. Levy)
+      !!        !  92-02  (M. Imbard)
+      !!        !  92-06  (M. Imbard)
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj,                 &  ! array dimensions
+         kideb, kifin, kind,     &  ! first and last index, increment for i
+         kjdeb, kjfin, kjnd,     &  ! first and last index, increment for j
+         kumout                     ! unit in which print
+      REAL(wp), INTENT( in ) ::   &
+         pscale                     ! = 0  print        ptab with e13.5 format
+         !                          ! else print pscale*ptab with f6.2 format
+      REAL(wp), DIMENSION(ki,kj), INTENT( in ) ::   &
+         ptab                       ! integer 2D array to be print
+
+      !! * Local variables
+      INTEGER ::   ji, jj, jn       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+
+      isca = 10
+      IF( pscale /= 0. )   isca=20
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(kind*isca) + 1
+
+        IF( il1 > kifin )   RETURN
+
+        WRITE(kumout,9100)
+
+        il2 = il1+kind*(isca-1)
+        IF(il2 > kifin) il2 = kifin
+        IF( pscale == 0.) THEN
+            WRITE(kumout,9101) ( ji, ji = il1, il2, kind )
+            DO jj = kjfin, kjdeb, -kjnd
+              WRITE(kumout,9102) jj, ( ptab(ji,jj), ji = il1, il2, kind )
+            END DO  
+        ELSE
+            WRITE(kumout,9103) ( ji, ji = il1, il2, kind )
+            DO jj = kjfin, kjdeb, -kjnd
+              WRITE(kumout,9104) jj, ( pscale*ptab(ji,jj), ji = il1, il2, kind )
+            END DO  
+        ENDIF
+        il1 = il1+kind*isca
+
+      END DO  
+
+      ! formats
+ 9100 FORMAT(/)
+ 9101 FORMAT(10i12, /)
+ 9102 FORMAT(1x, i3, 10(1pe12.4))
+ 9103 FORMAT(3x, 20i6, /)
+ 9104 FORMAT(1x, i3, 1x, 20f6.2)
+
+   END SUBROUTINE prihre
+
+
+   SUBROUTINE prizre( ptab , ki   , kj   , kk   , kjcut ,   &
+                      kideb, kifin, kid  , kkdeb, kkfin ,   &
+                      kkd  , pscale, kumout )
+      !!----------------------------------------------------------------------
+      !!                      ***  ROUTINE prizre  ***
+      !!
+      !! ** purpose :   Print a vertical slab from a tridimentional real field
+      !!
+      !!   METHOD :
+      !! ** method  :   the print format is selected with the argument pscale
+      !!
+      !! History :
+      !!      original : 86-01 (o. Marti)
+      !!      addition : 92-02 (M. Imbard)
+      !!      addition : 92-06 (M. Imbard)
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ki, kj, kk,             &  ! array dimensions
+         kjcut,                  &  ! index j for the vertical slab
+         kideb, kifin, kid,      &  ! first and last index, increment for i
+         kkdeb, kkfin, kkd,      &  ! first and last index, increment for k
+         kumout                     ! unit in which print
+      REAL(wp), INTENT( in ) ::   &
+         pscale                     ! = 0  print        ptab with e12.4 format
+         !                          ! else print pscale*ptab with f6.2 format
+      REAL(wp), DIMENSION(ki,kj,kk), INTENT( in ) ::   &
+         ptab                       ! integer 3D array to be print
+
+      !! * Local variables
+      INTEGER ::   ji, jn, jk       ! dummy loop indices
+      INTEGER ::   isca, il1, il2   ! temporary integers
+      INTEGER ::   iind, iknd       !    "          "
+
+
+      iind = kid
+      iknd = kkd
+      isca = 10
+      IF( pscale /= 0.) isca = 20
+
+      IF (iind == 0) iind = 1
+      IF (iknd == 0) iknd = 1
+
+      il1 = kideb
+
+      DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
+
+        IF(il1 > kifin) RETURN
+        WRITE(kumout,9100)
+        il2 = il1+iind*(isca-1)
+        IF(il2 > kifin) il2 = kifin
+
+        IF( pscale == 0.) THEN
+            WRITE(kumout,9101) ( ji, ji = il1, il2, iind )
+            DO jk = kkdeb, kkfin, iknd
+              WRITE (kumout,9102) jk, ( ptab(ji,kjcut,jk), ji = il1, il2, iind )
+            END DO  
+        ELSE
+            WRITE (kumout,9103) ( ji, ji = il1, il2, iind )
+            DO jk = kkdeb, kkfin, iknd
+              WRITE(kumout,9104)jk, ( pscale*ptab(ji,kjcut,jk), ji = il1, il2, iind )
+            END DO  
+        ENDIF
+
+        il1 = il1+iind*isca
+      END DO      
+
+ 9100 FORMAT(/)
+ 9101 FORMAT(10i12, /)
+ 9102 FORMAT(1x, i3, 10(1pe12.4))
+ 9103 FORMAT(3x, 20i6, /)
+ 9104 FORMAT(1x, i3, 1x, 20f6.1)
+
+      END SUBROUTINE prizre
+
+   !!======================================================================
+END MODULE lib_print
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/model.f90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/model.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/model.f90	(revision 1844)
@@ -0,0 +1,21 @@
+PROGRAM model
+   !!----------------------------------------------------------------------
+   !!                     ***  PROGRAM model  ***
+   !!
+   !! ** Purpose :   encapsulate the opa model so that opa can also be 
+   !!      called together with the adjoint and linear tangent models
+   !!
+   !! History :
+   !!   8.0  !  01-02  (M. Imbard, A. Weaver)  Original code
+   !!   9.0  !  03-10  (G. Madec) F90
+   !!----------------------------------------------------------------------
+   USE opa                  ! OPA system     (opa_model routine)
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+ 
+   CALL opa_model           ! OPA system
+ 
+END PROGRAM model
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/module_example
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/module_example	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/module_example	(revision 1844)
@@ -0,0 +1,168 @@
+MODULE exampl
+   !!======================================================================
+   !!                       ***  MODULE  exampl  ***
+   !! Ocean physics:  brief description of the purpose of the module
+   !!                 (please no more than 2 lines)
+   !!======================================================================
+   !! History : 3.0  !  2008-06  (Author Names)  Original code
+   !!            -   !  2008-08  (Author names)  brief description of modifications
+   !!           3.1  !  2008-12  (Author names)        -              -
+   !!----------------------------------------------------------------------
+
+#if defined key_example
+   !!----------------------------------------------------------------------
+   !!   'key_example'  :                brief description of the key option
+   !!----------------------------------------------------------------------
+   !!   exa_mpl       : liste of module subroutine (caution, never use the
+   !!   exa_mpl_init  : name of the module for a routine)
+   !!   exa_mpl_stp   : Please try to use 3 letter block for routine names
+   !!----------------------------------------------------------------------
+   USE module_name1   ! brief description of the used module
+   USE module_name2   ! ....
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   exa_mpl   ! routine called in xxx.F90 module
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   var1         !: var1 description. CAUTION always use !: to describe
+   !                                                          !  a PUBLIC variable: simplify its search : 
+   !                                                          !  grep var1 *90 | grep '!:'
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   var2, var2   !: several variable on a same line OK, but 
+   !                                                          !  DO NOT use continuation lines in declaration
+
+   !                             !!! ** namelist nam_xxx **
+   LOGICAL  ::   ln_opt = 1       ! give the default value of each namelist parameter
+   CHARACTER::   cn_tex = 'T'     ! short description  of the variable
+   INTEGER  ::   nn_opt = 1       ! please respect the DOCTOR norm for namelist variable
+   REAL(wp) ::   rn_var = 2._wp   ! (it becomes easy to identify them in the code)
+
+   INTEGER                          ::   nint    ! nint  description (local permanent variable)
+   REAL(wp)                         ::   var     ! var         -                -
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   array   ! array       -                -
+
+   !! * Substitutions
+#  include "exampl_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE exa_mpl  ***
+      !!
+      !! ** Purpose :   Brief description of the routine
+      !!
+      !! ** Method  :   description of the methodoloy used to achieve the
+      !!                objectives of the routine. Be as clear as possible!
+      !!
+      !! ** Action  : - first action (share memory array/varible modified
+      !!                in this routine
+      !!              - second action .....
+      !!              - .....
+      !!
+      !! References :   Author et al., Short_name_review, Year
+      !!                Give references if exist otherwise suppress these lines
+      !!----------------------------------------------------------------------
+      USE toto_module      ! description od the module
+      !!
+      INTEGER , INTENT(in   )                     ::   kt      ! short description 
+      INTEGER , INTENT(inout)                     ::   pvar1   !   -         -
+      REAL(wp), INTENT(  out)                     ::   pvar2   !   -         -
+      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   pvar2   !   -         -
+      !!
+      INTEGER  ::   ji, jj, jk       ! dummy loop arguments  (DOCTOR : start with j, but not jp)
+      INTEGER  ::   itoto, itata     ! temporary integers    (DOCTOR : start with i
+      REAL(wp) ::   zmlmin, zbbrau   ! temporary scalars     (DOCTOR : start with z)
+      REAL(wp) ::   zfact1, zfact2   ! do not use continuation lines in declaration
+      REAL(wp), DIMENSION(jpi,jpk) ::   ztoto   ! 2D workspace
+      !!--------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL exa_mpl_init    ! Initialization (first time-step only)
+
+      zmlmin = 1.e-8                             ! Local constant initialization
+      zbbrau =  .5 * ebb / rau0
+      zfact1 = -.5 * rdt * efave
+      zfact2 = 1.5 * rdt * ediss
+
+      SELECT CASE ( npdl )                       ! short description of the action
+      !
+      CASE ( 0 )                                      ! describe case 1
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avmv(ji,jj,jk) = ....
+               END DO
+            END DO
+         END DO
+         !
+      CASE ( 1 )                                      ! describe case 2
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  avmv(ji,jj,jk) = ...
+               END DO
+            END DO
+         END DO
+         !
+      END SELECT
+
+      CALL mpplnk2( avmu, 'U', 1. )              ! Lateral boundary conditions (avmu)   (unchanged sign)
+      !
+   END SUBROUTINE exa_mpl
+
+
+   SUBROUTINE exa_mpl_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE exa_mpl_init  ***
+      !!                   
+      !! ** Purpose :   initialization of ....
+      !!
+      !! ** Method  :   blah blah blah ...
+      !!
+      !! ** input   :   Namlist namexa
+      !!
+      !! ** Action  :   ...  
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, jk, jit   ! dummy loop indices
+      !!
+      NAMELIST/namexa/ exa_v1, exa_v2, nexa_0       
+      !!----------------------------------------------------------------------
+      !
+      REWIND ( numnam )                          ! Read Namelist namexa : example parameters
+      READ   ( numnam, namexa )
+      !
+      IF(lwp) THEN                               ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'exa_mpl_init : example '
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '          Namelist namexa : set example parameters'
+         WRITE(numout,*) '             brief desciption               exa_v1  = ', exa_v1
+         WRITE(numout,*) '             brief desciption               exa_v1  = ', exa_v1
+         WRITE(numout,*) '             brief desciption               nexa_0  = ', nexa_0
+      ENDIF
+      !
+      !                                          ! Parameter control
+      IF( ln_opt  )   CALL ctl_stop( 'this work and option xxx are incompatible'   )
+      IF( ln_opt2 )   CALL ctl_warn( 'this work and option yyy may cause problems' )
+      ENDIF
+      !
+   END SUBROUTINE exa_mpl_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                         NO example
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab )              ! Empty routine
+      REAL::   ptab(:,:)
+      WRITE(*,*) 'exa_mpl: You should not have seen this print! error?', kt, pvar1, pvar2, ptab(1,1)
+   END SUBROUTINE exa_mpl
+#endif
+
+   !!======================================================================
+END MODULE exampl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini.F90	(revision 1844)
@@ -0,0 +1,493 @@
+MODULE mppini
+   !!==============================================================================
+   !!                       ***  MODULE mppini   ***
+   !! Ocean initialization : distributed memory computing initialization
+   !!==============================================================================
+
+   !!----------------------------------------------------------------------
+   !!   mpp_init       : Lay out the global domain over processors
+   !!   mpp_init2      : Lay out the global domain over processors 
+   !!                    with land processor elimination
+   !!   mpp_init_ioispl: IOIPSL initialization in mpp
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce         ! ocean space and time domain 
+   USE in_out_manager  ! I/O Manager
+   USE lib_mpp         ! distribued memory computing library
+   USE ioipsl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC mpp_init       ! called by opa.F90
+   PUBLIC mpp_init2      ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if ! defined key_mpp_mpi
+   !!----------------------------------------------------------------------
+   !!   Default option :                            shared memory computing
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE mpp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init  ***
+      !!
+      !! ** Purpose :   Lay out the global domain over processors.
+      !!
+      !! ** Method  :   Shared memory computing, set the local processor
+      !!      variables to the value of the global domain
+      !!
+      !! History :
+      !!   9.0  !  04-01  (G. Madec, J.M. Molines)  F90 : free form, north fold jpni >1
+      !!----------------------------------------------------------------------
+
+      ! No mpp computation
+      nimpp  = 1
+      njmpp  = 1
+      nlci   = jpi
+      nlcj   = jpj
+      nldi   = 1
+      nldj   = 1
+      nlei   = jpi
+      nlej   = jpj
+      nperio = jperio
+      nbondi = 2
+      nbondj = 2
+      nidom  = FLIO_DOM_NONE
+      npolj = jperio
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'mpp_init(2) : NO massively parallel processing'
+         WRITE(numout,*) '~~~~~~~~~~~: '
+         WRITE(numout,*) '         nperio = ', nperio
+         WRITE(numout,*) '         npolj  = ', npolj
+         WRITE(numout,*) '         nimpp  = ', nimpp
+         WRITE(numout,*) '         njmpp  = ', njmpp
+      ENDIF
+
+      IF(  jpni /= 1 .OR. jpnj /= 1 .OR. jpnij /= 1 ) &
+          CALL ctl_stop( 'equality  jpni = jpnj = jpnij = 1 is not satisfied',   &
+          &              'the domain is lay out for distributed memory computing! ' )
+
+   END SUBROUTINE mpp_init
+
+
+   SUBROUTINE mpp_init2 
+      CALL mpp_init                             ! same routine as mpp_init
+   END SUBROUTINE mpp_init2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   'key_mpp_mpi'          OR         MPI massively parallel processing
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE mpp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!      Periodic condition is a function of the local domain position
+      !!      (global boundary or neighbouring domain) and of the global
+      !!      periodic
+      !!      Type :         jperio global periodic condition
+      !!                     nperio local  periodic condition
+      !!
+      !! ** Action  : - set domain parameters
+      !!                    nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlci      : first dimension
+      !!                    nlcj      : second dimension
+      !!                    nbondi    : mark for "east-west local boundary"
+      !!                    nbondj    : mark for "north-south local boundary"
+      !!                    nproc     : number for local processor
+      !!                    noea      : number for local neighboring processor
+      !!                    nowe      : number for local neighboring processor
+      !!                    noso      : number for local neighboring processor
+      !!                    nono      : number for local neighboring processor
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   8.5  !  02-08  (G. Madec)  F90 : free form
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::   ji, jj, jn               ! dummy loop indices
+      INTEGER ::   &
+         ii, ij, ifreq, il1, il2,        &  ! temporary integers
+         iresti, irestj, ijm1, imil,     &  !    "          "
+         inum                               ! temporary logical unit
+
+      INTEGER, DIMENSION(jpni,jpnj) ::   &
+         iimppt, ijmppt, ilcit, ilcjt       ! temporary workspace
+      REAL(wp) ::   zidom, zjdom            ! temporary scalars
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'mpp_init : Message Passing MPI'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~'
+
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !  Computation of local domain sizes ilcit() ilcjt()
+      !  These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array (cf. par_oce.F90).
+      
+      nreci  = 2 * jpreci
+      nrecj  = 2 * jprecj
+      iresti = MOD( jpiglo - nreci , jpni )
+      irestj = MOD( jpjglo - nrecj , jpnj )
+
+      IF(  iresti == 0 )   iresti = jpni
+      DO jj = 1, jpnj
+         DO ji = 1, iresti
+            ilcit(ji,jj) = jpi
+         END DO
+         DO ji = iresti+1, jpni
+            ilcit(ji,jj) = jpi -1
+         END DO
+      END DO
+      
+      IF( irestj == 0 )   irestj = jpnj
+      DO ji = 1, jpni
+         DO jj = 1, irestj
+            ilcjt(ji,jj) = jpj
+         END DO
+         DO jj = irestj+1, jpnj
+            ilcjt(ji,jj) = jpj -1
+         END DO
+      END DO
+      
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) '           defines mpp subdomains'
+         WRITE(numout,*) '           ----------------------'
+         WRITE(numout,*) '           iresti=',iresti,' irestj=',irestj
+         WRITE(numout,*) '           jpni  =',jpni  ,' jpnj  =',jpnj
+         ifreq = 4
+         il1   = 1
+         DO jn = 1, (jpni-1)/ifreq+1
+            il2 = MIN( jpni, il1+ifreq-1 )
+            WRITE(numout,*)
+            WRITE(numout,9200) ('***',ji = il1,il2-1)
+            DO jj = jpnj, 1, -1
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9202) jj, ( ilcit(ji,jj),ilcjt(ji,jj),ji = il1,il2 )
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9200) ('***',ji = il1,il2-1)
+            END DO
+            WRITE(numout,9201) (ji,ji = il1,il2)
+            il1 = il1+ifreq
+         END DO
+ 9200    FORMAT('     ***',20('*************',a3))
+ 9203    FORMAT('     *     ',20('         *   ',a3))
+ 9201    FORMAT('        ',20('   ',i3,'          '))
+ 9202    FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
+      ENDIF
+
+      zidom = nreci
+      DO ji = 1, jpni
+         zidom = zidom + ilcit(ji,1) - nreci
+      END DO
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilcit(i,1) = ', zidom, ' jpiglo = ', jpiglo
+      
+      zjdom = nrecj
+      DO jj = 1, jpnj
+         zjdom = zjdom + ilcjt(1,jj) - nrecj
+      END DO
+      IF(lwp) WRITE(numout,*)' sum ilcit(1,j) = ', zjdom, ' jpjglo = ', jpjglo
+      IF(lwp) WRITE(numout,*)
+      
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+      
+      iimppt(:,:) = 1
+      ijmppt(:,:) = 1
+      
+      IF( jpni > 1 ) THEN
+         DO jj = 1, jpnj
+            DO ji = 2, jpni
+               iimppt(ji,jj) = iimppt(ji-1,jj) + ilcit(ji-1,jj) - nreci
+            END DO
+         END DO
+      ENDIF
+
+      IF( jpnj > 1 ) THEN
+         DO jj = 2, jpnj
+            DO ji = 1, jpni
+               ijmppt(ji,jj) = ijmppt(ji,jj-1)+ilcjt(ji,jj-1)-nrecj
+            END DO
+         END DO
+      ENDIF
+      
+      ! 3. Subdomain description
+      ! ------------------------
+
+      DO jn = 1, jpnij
+         ii = 1 + MOD( jn-1, jpni )
+         ij = 1 + (jn-1) / jpni
+         nimppt(jn) = iimppt(ii,ij)
+         njmppt(jn) = ijmppt(ii,ij)
+         nlcit (jn) = ilcit (ii,ij)     
+         nlci       = nlcit (jn)     
+         nlcjt (jn) = ilcjt (ii,ij)     
+         nlcj       = nlcjt (jn)
+         nbondj = -1                                   ! general case
+         IF( jn   >  jpni          )   nbondj = 0      ! first row of processor
+         IF( jn   >  (jpnj-1)*jpni )   nbondj = 1      ! last  row of processor
+         IF( jpnj == 1             )   nbondj = 2      ! one processor only in j-direction
+         ibonjt(jn) = nbondj
+         
+         nbondi = 0                                    ! 
+         IF( MOD( jn, jpni ) == 1 )   nbondi = -1      !
+         IF( MOD( jn, jpni ) == 0 )   nbondi =  1      !
+         IF( jpni            == 1 )   nbondi =  2      ! one processor only in i-direction
+         ibonit(jn) = nbondi
+         
+         nldi =  1   + jpreci
+         nlei = nlci - jpreci
+         IF( nbondi == -1 .OR. nbondi == 2 )   nldi = 1
+         IF( nbondi ==  1 .OR. nbondi == 2 )   nlei = nlci
+         nldj =  1   + jprecj
+         nlej = nlcj - jprecj
+         IF( nbondj == -1 .OR. nbondj == 2 )   nldj = 1
+         IF( nbondj ==  1 .OR. nbondj == 2 )   nlej = nlcj
+         nldit(jn) = nldi
+         nleit(jn) = nlei
+         nldjt(jn) = nldj
+         nlejt(jn) = nlej
+      END DO
+      
+
+      ! 4. From global to local
+      ! -----------------------
+
+      nperio = 0
+      IF( jperio == 2 .AND. nbondj == -1 )   nperio = 2
+
+
+      ! 5. Subdomain neighbours
+      ! ----------------------
+
+      nproc = narea - 1
+      noso  = nproc - jpni
+      nowe  = nproc - 1
+      noea  = nproc + 1
+      nono  = nproc + jpni
+      ! great neighbours
+      npnw = nono - 1
+      npne = nono + 1
+      npsw = noso - 1
+      npse = noso + 1
+      nbsw = 1
+      nbnw = 1
+      IF( MOD( nproc, jpni ) == 0 ) THEN
+         nbsw = 0
+         nbnw = 0
+      ENDIF
+      nbse = 1
+      nbne = 1
+      IF( MOD( nproc, jpni ) == jpni-1 ) THEN
+         nbse = 0
+         nbne = 0
+      ENDIF
+      IF(nproc < jpni) THEN
+         nbsw = 0
+         nbse = 0
+      ENDIF
+      IF( nproc >= (jpnj-1)*jpni ) THEN
+         nbnw = 0
+         nbne = 0
+      ENDIF
+      nlcj = nlcjt(narea)  
+      nlci = nlcit(narea)  
+      nldi = nldit(narea)
+      nlei = nleit(narea)
+      nldj = nldjt(narea)
+      nlej = nlejt(narea)
+      nbondi = ibonit(narea)
+      nbondj = ibonjt(narea)
+      nimpp  = nimppt(narea)  
+      njmpp  = njmppt(narea)  
+
+     ! Save processor layout in layout.dat file 
+       IF (lwp) THEN
+        CALL ctl_opn( inum, 'layout.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
+        WRITE(inum,'(a)') '   jpnij     jpi     jpj     jpk  jpiglo  jpjglo'
+        WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
+        WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
+
+        DO  jn = 1, jpnij
+         WRITE(inum,'(9i5)') jn, nlcit(jn), nlcjt(jn), &
+                                      nldit(jn), nldjt(jn), &
+                                      nleit(jn), nlejt(jn), &
+                                      nimppt(jn), njmppt(jn)
+        END DO
+        CLOSE(inum)   
+      END IF
+
+
+      ! w a r n i n g  narea (zone) /= nproc (processors)!
+
+      IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN
+         IF( jpni == 1 )THEN
+            nbondi = 2
+            nperio = 1
+         ELSE
+            nbondi = 0
+         ENDIF
+         IF( MOD( narea, jpni ) == 0 ) THEN
+            noea = nproc-(jpni-1)
+            npne = npne-jpni
+            npse = npse-jpni
+         ENDIF
+         IF( MOD( narea, jpni ) == 1 ) THEN
+            nowe = nproc+(jpni-1)
+            npnw = npnw+jpni
+            npsw = npsw+jpni
+         ENDIF
+         nbsw = 1
+         nbnw = 1
+         nbse = 1
+         nbne = 1
+         IF( nproc < jpni ) THEN
+            nbsw = 0
+            nbse = 0
+         ENDIF
+         IF( nproc >= (jpnj-1)*jpni ) THEN
+            nbnw = 0
+            nbne = 0
+         ENDIF
+      ENDIF
+      npolj = 0
+      IF( jperio == 3 .OR. jperio == 4 ) THEN
+         ijm1 = jpni*(jpnj-1)
+         imil = ijm1+(jpni+1)/2
+         IF( narea > ijm1 ) npolj = 3
+         IF( MOD(jpni,2) == 1 .AND. narea == imil ) npolj = 4
+         IF( npolj == 3 ) nono = jpni*jpnj-narea+ijm1
+      ENDIF
+      IF( jperio == 5 .OR. jperio == 6 ) THEN
+          ijm1 = jpni*(jpnj-1)
+          imil = ijm1+(jpni+1)/2
+          IF( narea > ijm1) npolj = 5
+          IF( MOD(jpni,2) == 1 .AND. narea == imil ) npolj = 6
+          IF( npolj == 5 ) nono = jpni*jpnj-narea+ijm1
+      ENDIF
+
+      ! Periodicity : no corner if nbondi = 2 and nperio != 1
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' nproc  = ', nproc
+         WRITE(numout,*) ' nowe   = ', nowe  , ' noea   =  ', noea
+         WRITE(numout,*) ' nono   = ', nono  , ' noso   =  ', noso
+         WRITE(numout,*) ' nbondi = ', nbondi
+         WRITE(numout,*) ' nbondj = ', nbondj
+         WRITE(numout,*) ' npolj  = ', npolj
+         WRITE(numout,*) ' nperio = ', nperio
+         WRITE(numout,*) ' nlci   = ', nlci
+         WRITE(numout,*) ' nlcj   = ', nlcj
+         WRITE(numout,*) ' nimpp  = ', nimpp
+         WRITE(numout,*) ' njmpp  = ', njmpp
+         WRITE(numout,*) ' nbse   = ', nbse  , ' npse   = ', npse
+         WRITE(numout,*) ' nbsw   = ', nbsw  , ' npsw   = ', npsw
+         WRITE(numout,*) ' nbne   = ', nbne  , ' npne   = ', npne
+         WRITE(numout,*) ' nbnw   = ', nbnw  , ' npnw   = ', npnw
+      ENDIF
+
+      IF( nperio == 1 .AND. jpni /= 1 ) CALL ctl_stop( ' mpp_init: error on cyclicity' )
+
+      ! Prepare mpp north fold
+
+      IF (jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+         CALL mpp_ini_north
+      END IF
+
+      ! Prepare NetCDF output file (if necessary)
+      CALL mpp_init_ioipsl
+
+   END SUBROUTINE mpp_init
+
+#  include "mppini_2.h90"
+
+# if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   'key_dimgout'                  NO use of NetCDF files
+   !!----------------------------------------------------------------------
+   SUBROUTINE mpp_init_ioipsl       ! Dummy routine
+   END SUBROUTINE mpp_init_ioipsl  
+# else
+   SUBROUTINE mpp_init_ioipsl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init_ioipsl  ***
+      !!
+      !! ** Purpose :   
+      !!
+      !! ** Method  :   
+      !!
+      !! History :
+      !!   9.0  !  04-03  (G. Madec )  MPP-IOIPSL 
+      !!   " "  !  08-12  (A. Coward)  addition in case of jpni*jpnj < jpnij
+      !!----------------------------------------------------------------------
+      !! Local declarations
+
+      INTEGER, DIMENSION(2) ::   &
+         iglo, iloc, iabsf, iabsl, ihals, ihale, idid
+      !!----------------------------------------------------------------------
+
+      ! The domain is split only horizontally along i- or/and j- direction
+      ! So we need at the most only 1D arrays with 2 elements.
+      ! Set idompar values equivalent to the jpdom_local_noextra definition
+      ! used in IOM. This works even if jpnij .ne. jpni*jpnj.
+      iglo(1) = jpiglo
+      iglo(2) = jpjglo
+      iloc(1) = nlci
+      iloc(2) = nlcj
+      iabsf(1) = nimppt(narea)
+      iabsf(2) = njmppt(narea)
+      iabsl(:) = iabsf(:) + iloc(:) - 1
+      ihals(1) = nldi - 1
+      ihals(2) = nldj - 1
+      ihale(1) = nlci - nlei
+      ihale(2) = nlcj - nlej
+      idid(1) = 1
+      idid(2) = 2
+
+      IF(lwp) THEN
+          WRITE(numout,*)
+          WRITE(numout,*) 'mpp_init_ioipsl :   iloc  = ', iloc (1), iloc (2)
+          WRITE(numout,*) '~~~~~~~~~~~~~~~     iabsf = ', iabsf(1), iabsf(2)
+          WRITE(numout,*) '                    ihals = ', ihals(1), ihals(2)
+          WRITE(numout,*) '                    ihale = ', ihale(1), ihale(2)
+      ENDIF
+
+      CALL flio_dom_set ( jpnij, nproc, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom)
+
+   END SUBROUTINE mpp_init_ioipsl  
+
+# endif
+#endif
+
+   !!======================================================================
+END MODULE mppini
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini_2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini_2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/mppini_2.h90	(revision 1844)
@@ -0,0 +1,525 @@
+   SUBROUTINE mpp_init2
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init2  ***
+      !!
+      !! * Purpose :   Lay out the global domain over processors.
+      !!     FOR USING THIS VERSION, A PREPROCESSING TRAITMENT IS RECOMMENDED
+      !!     FOR DEFINING BETTER CUTTING OUT.
+      !!       This routine is used with a the bathymetry file.
+      !!       In this version, the land processors are avoided and the adress
+      !!     processor (nproc, narea,noea, ...) are calculated again.
+      !!     The jpnij parameter can be lesser than jpni x jpnj
+      !!     and this jpnij parameter must be calculated before with an
+      !!     algoritmic preprocessing program.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!      Periodic condition is a function of the local domain position
+      !!      (global boundary or neighbouring domain) and of the global
+      !!      periodic
+      !!      Type :         jperio global periodic condition
+      !!                     nperio local  periodic condition
+      !!
+      !! ** Action :        nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlci      : first dimension
+      !!                    nlcj      : second dimension
+      !!                    nproc     : number for local processor
+      !!                    noea      : number for local neighboring processor
+      !!                    nowe      : number for local neighboring processor
+      !!                    noso      : number for local neighboring processor
+      !!                    nono      : number for local neighboring processor
+      !!
+      !! History :
+      !!        !  94-11  (M. Guyon)  Original code
+      !!        !  95-04  (J. Escobar, M. Imbard)
+      !!        !  98-02  (M. Guyon)  FETI method
+      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
+      !!   9.0  !  04-01  (G. Madec, J.M Molines)  F90 : free form , north fold jpni > 1
+      !!----------------------------------------------------------------------
+      USE in_out_manager  ! I/O Manager
+      USE iom
+      !! 
+      INTEGER :: ji, jj, jn, jproc, jarea     ! dummy loop indices
+      INTEGER ::  inum                        ! temporary logical unit
+      INTEGER ::   &
+         ii, ij, ifreq, il1, il2,          &  ! temporary integers
+         icont, ili, ilj,                  &  !    "          "
+         isurf, ijm1, imil,                &  !    "          "
+         iino, ijno, iiso, ijso,           &  !    "          " 
+         iiea, ijea, iiwe, ijwe,           &  !    "          "
+         iinw, ijnw, iine, ijne,           &  !    "          "
+         iisw, ijsw, iise, ijse,           &  !    "          "
+         iresti, irestj, iproc                !    "          "
+      INTEGER, DIMENSION(jpnij) ::   &
+         iin, ijn          
+      INTEGER, DIMENSION(jpni,jpnj) ::   &
+         iimppt, ijmppt, ilci  , ilcj  ,   &  ! temporary workspace
+         ipproc, ibondj, ibondi, ipolj ,   &  !    "           "
+         ilei  , ilej  , ildi  , ildj  ,   &  !    "           "
+         ioea  , iowe  , ioso  , iono  ,   &  !    "           "
+         ione  , ionw  , iose  , iosw  ,   &  !    "           "
+         ibne  , ibnw  , ibse  , ibsw         !    "           "
+      INTEGER,  DIMENSION(jpiglo,jpjglo) ::   &
+         imask                                ! temporary global workspace
+      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   &
+         zdta                   ! temporary data workspace
+      REAL(wp) ::   zidom , zjdom          ! temporary scalars
+
+      ! read namelist for ln_zco
+      NAMELIST/namzgr/ ln_zco, ln_zps, ln_sco
+
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+      !! $Id$
+      !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+      !!----------------------------------------------------------------------
+      
+      REWIND ( numnam )              ! Read Namelist namzgr : vertical coordinate'
+      READ   ( numnam, namzgr )
+
+      IF(lwp)WRITE(numout,*)
+      IF(lwp)WRITE(numout,*) 'mpp_init : Message Passing MPI'
+      IF(lwp)WRITE(numout,*) '~~~~~~~~'
+      IF(lwp)WRITE(numout,*) ' '
+
+      IF( jpni*jpnj < jpnij ) CALL ctl_stop( ' jpnij > jpni x jpnj impossible' )
+
+      ! 0. initialisation
+      ! -----------------
+
+      ! open the file
+      ! Remember that at this level in the code, mpp is not yet initialized, so
+      ! the file must be open with jpdom_unknown, and kstart amd kcount forced 
+      IF ( ln_zco ) THEN 
+         CALL iom_open ( 'bathy_level.nc', inum )   ! Level bathymetry
+         CALL iom_get ( inum, jpdom_unknown, 'Bathy_level', zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) )
+      ELSE
+         CALL iom_open ( 'bathy_meter.nc', inum )   ! Meter bathy in case of partial steps
+         CALL iom_get ( inum, jpdom_unknown, 'Bathymetry' , zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) )
+      ENDIF
+      CALL iom_close (inum)
+
+      ! land/sea mask over the global/zoom domain
+
+      imask(:,:)=1
+      WHERE ( zdta(:,:) <= 0. ) imask = 0
+
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+
+      !  Computation of local domain sizes ilci() ilcj()
+      !  These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array.
+
+      nreci=2*jpreci
+      nrecj=2*jprecj
+      iresti = 1 + MOD( jpiglo - nreci -1 , jpni )
+      irestj = 1 + MOD( jpjglo - nrecj -1 , jpnj )
+
+      ilci(1:iresti      ,:) = jpi
+      ilci(iresti+1:jpni ,:) = jpi-1
+
+      ilcj(:,      1:irestj) = jpj
+      ilcj(:, irestj+1:jpnj) = jpj-1
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' mpp_init2: defines mpp subdomains'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~  ----------------------'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'iresti=',iresti,' irestj=',irestj
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'jpni=',jpni,' jpnj=',jpnj
+
+      zidom = nreci + sum(ilci(:,1) - nreci ) 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilci(i,1)=',zidom,' jpiglo=',jpiglo
+
+      zjdom = nrecj + sum(ilcj(1,:) - nrecj ) 
+      IF(lwp) WRITE(numout,*) ' sum ilcj(1,j)=',zjdom,' jpjglo=',jpjglo
+      IF(lwp) WRITE(numout,*)
+
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+
+      iimppt(:,:) = 1
+      ijmppt(:,:) = 1
+      ipproc(:,:) = -1
+
+      IF( jpni > 1 )THEN
+         DO jj = 1, jpnj
+            DO ji = 2, jpni
+               iimppt(ji,jj) = iimppt(ji-1,jj) + ilci(ji-1,jj) - nreci
+            END DO
+         END DO
+      ENDIF
+
+      IF( jpnj > 1 )THEN
+         DO jj = 2, jpnj
+            DO ji = 1, jpni
+               ijmppt(ji,jj) = ijmppt(ji,jj-1) + ilcj(ji,jj-1) - nrecj
+            END DO
+         END DO
+      ENDIF
+
+
+      ! 3. Subdomain description in the Regular Case
+      ! --------------------------------------------
+
+      nperio = 0
+      icont = -1
+      DO jarea = 1, jpni*jpnj
+         ii = 1 + MOD(jarea-1,jpni)
+         ij = 1 +    (jarea-1)/jpni
+         ili = ilci(ii,ij)
+         ilj = ilcj(ii,ij)
+
+         ibondj(ii,ij) = -1
+         IF( jarea >  jpni          )   ibondj(ii,ij) = 0
+         IF( jarea >  (jpnj-1)*jpni )   ibondj(ii,ij) = 1
+         IF( jpnj  == 1             )   ibondj(ii,ij) = 2
+
+         ibondi(ii,ij) = 0
+         IF( MOD(jarea,jpni) == 1 )   ibondi(ii,ij) = -1
+         IF( MOD(jarea,jpni) == 0 )   ibondi(ii,ij) =  1
+         IF( jpni            == 1 )   ibondi(ii,ij) =  2
+
+         ! 2.4 Subdomain neighbors
+
+         iproc = jarea - 1
+         ioso(ii,ij) = iproc - jpni
+         iowe(ii,ij) = iproc - 1
+         ioea(ii,ij) = iproc + 1
+         iono(ii,ij) = iproc + jpni
+         ildi(ii,ij) = 1 + jpreci
+         ilei(ii,ij) = ili -jpreci
+         ionw(ii,ij) = iono(ii,ij) - 1
+         ione(ii,ij) = iono(ii,ij) + 1
+         iosw(ii,ij) = ioso(ii,ij) - 1
+         iose(ii,ij) = ioso(ii,ij) + 1
+         ibsw(ii,ij) = 1
+         ibnw(ii,ij) = 1
+         IF( MOD(iproc,jpni) == 0 ) THEN
+            ibsw(ii,ij) = 0
+            ibnw(ii,ij) = 0
+         ENDIF
+         ibse(ii,ij) = 1
+         ibne(ii,ij) = 1
+         IF( MOD(iproc,jpni) == jpni-1 ) THEN
+            ibse(ii,ij) = 0
+            ibne(ii,ij) = 0
+         ENDIF
+         IF( iproc < jpni ) THEN
+            ibsw(ii,ij) = 0
+            ibse(ii,ij) = 0
+         ENDIF
+         IF( iproc >= (jpnj-1)*jpni ) THEN
+            ibnw(ii,ij) = 0
+            ibne(ii,ij) = 0
+         ENDIF
+         IF( ibondi(ii,ij) == -1 .OR. ibondi(ii,ij) == 2 ) ildi(ii,ij) = 1
+         IF( ibondi(ii,ij) ==  1 .OR. ibondi(ii,ij) == 2 ) ilei(ii,ij) = ili
+         ildj(ii,ij) =  1  + jprecj
+         ilej(ii,ij) = ilj - jprecj
+         IF( ibondj(ii,ij) == -1 .OR. ibondj(ii,ij) == 2 ) ildj(ii,ij) = 1
+         IF( ibondj(ii,ij) ==  1 .OR. ibondj(ii,ij) == 2 ) ilej(ii,ij) = ilj
+
+         ! warning ii*ij (zone) /= nproc (processors)!
+
+         IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) THEN
+            IF( jpni == 1 )THEN
+               ibondi(ii,ij) = 2
+               nperio = 1
+            ELSE
+               ibondi(ii,ij) = 0
+            ENDIF
+            IF( MOD(jarea,jpni) == 0 ) THEN
+               ioea(ii,ij) = iproc - (jpni-1)
+               ione(ii,ij) = ione(ii,ij) - jpni
+               iose(ii,ij) = iose(ii,ij) - jpni
+            ENDIF
+            IF( MOD(jarea,jpni) == 1 ) THEN
+               iowe(ii,ij) = iproc + jpni - 1
+               ionw(ii,ij) = ionw(ii,ij) + jpni
+               iosw(ii,ij) = iosw(ii,ij) + jpni 
+            ENDIF
+            ibsw(ii,ij) = 1
+            ibnw(ii,ij) = 1
+            ibse(ii,ij) = 1
+            ibne(ii,ij) = 1
+            IF( iproc < jpni ) THEN
+               ibsw(ii,ij) = 0
+               ibse(ii,ij) = 0
+            ENDIF
+            IF( iproc >= (jpnj-1)*jpni ) THEN
+               ibnw(ii,ij) = 0
+               ibne(ii,ij) = 0
+            ENDIF
+         ENDIF
+         ipolj(ii,ij) = 0
+         IF( jperio == 3 .OR. jperio == 4 ) THEN
+            ijm1 = jpni*(jpnj-1)
+            imil = ijm1+(jpni+1)/2
+            IF( jarea > ijm1 ) ipolj(ii,ij) = 3
+            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 4
+            IF( ipolj(ii,ij) == 3 ) iono(ii,ij) = jpni*jpnj-jarea+ijm1
+         ENDIF
+         IF( jperio == 5 .OR. jperio == 6 ) THEN
+            ijm1 = jpni*(jpnj-1)
+            imil = ijm1+(jpni+1)/2
+            IF( jarea > ijm1) ipolj(ii,ij) = 5
+            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 6
+            IF( ipolj(ii,ij) == 5) iono(ii,ij) = jpni*jpnj-jarea+ijm1
+         ENDIF
+
+         isurf = 0
+         DO jj = 1+jprecj, ilj-jprecj
+            DO  ji = 1+jpreci, ili-jpreci
+               IF( imask(ji+iimppt(ii,ij)-1, jj+ijmppt(ii,ij)-1) == 1) isurf = isurf+1
+            END DO
+         END DO
+         IF(isurf /= 0) THEN
+            icont = icont + 1
+            ipproc(ii,ij) = icont
+            iin(icont+1) = ii
+            ijn(icont+1) = ij
+         ENDIF
+      END DO
+
+      ! Control
+      IF(icont+1 /= jpnij) THEN
+         WRITE(ctmp1,*) ' jpni =',jpni,' jpnj =',jpnj
+         WRITE(ctmp2,*) ' jpnij =',jpnij, '< jpni x jpnj' 
+         WRITE(ctmp3,*) ' ***********, mpp_init2 finds jpnij=',icont+1
+         CALL ctl_stop( ' Eliminate land processors algorithm', '', ctmp1, ctmp2, '', ctmp3 )
+      ENDIF
+
+      ! 4. Subdomain print
+      ! ------------------
+
+      IF(lwp) THEN
+         ifreq = 4
+         il1 = 1
+         DO jn = 1,(jpni-1)/ifreq+1
+            il2 = MIN(jpni,il1+ifreq-1)
+            WRITE(numout,*)
+            WRITE(numout,9400) ('***',ji=il1,il2-1)
+            DO jj = jpnj, 1, -1
+               WRITE(numout,9403) ('   ',ji=il1,il2-1)
+               WRITE(numout,9402) jj, (ilci(ji,jj),ilcj(ji,jj),ji=il1,il2)
+               WRITE(numout,9404) (ipproc(ji,jj),ji=il1,il2)
+               WRITE(numout,9403) ('   ',ji=il1,il2-1)
+               WRITE(numout,9400) ('***',ji=il1,il2-1)
+            END DO
+            WRITE(numout,9401) (ji,ji=il1,il2)
+            il1 = il1+ifreq
+         END DO
+ 9400     FORMAT('     ***',20('*************',a3))
+ 9403     FORMAT('     *     ',20('         *   ',a3))
+ 9401     FORMAT('        ',20('   ',i3,'          '))
+ 9402     FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
+ 9404     FORMAT('     *  ',20('      ',i3,'   *   '))
+      ENDIF
+
+
+      ! 5. neighbour treatment
+      ! ----------------------
+
+      DO jarea = 1, jpni*jpnj
+         iproc = jarea-1
+         ii = 1 + MOD(jarea-1,jpni)
+         ij = 1 +    (jarea-1)/jpni
+         IF( ipproc(ii,ij) == -1 .AND. iono(ii,ij) >= 0   &
+            .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN
+            iino = 1 + MOD(iono(ii,ij),jpni)
+            ijno = 1 +    (iono(ii,ij))/jpni
+            IF( ibondj(iino,ijno) == 1 ) ibondj(iino,ijno)=2
+            IF( ibondj(iino,ijno) == 0 ) ibondj(iino,ijno) = -1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ioso(ii,ij) >= 0   &
+            .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN
+            iiso = 1 + MOD(ioso(ii,ij),jpni)
+            ijso = 1 +    (ioso(ii,ij))/jpni
+            IF( ibondj(iiso,ijso) == -1 ) ibondj(iiso,ijso) = 2
+            IF( ibondj(iiso,ijso) ==  0 ) ibondj(iiso,ijso) = 1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ioea(ii,ij) >= 0   &
+            .AND. ioea(ii,ij) <= jpni*jpnj-1) THEN
+            iiea = 1 + MOD(ioea(ii,ij),jpni)
+            ijea = 1 +    (ioea(ii,ij))/jpni
+            IF( ibondi(iiea,ijea) == 1 ) ibondi(iiea,ijea) = 2
+            IF( ibondi(iiea,ijea) == 0 ) ibondi(iiea,ijea) = -1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. iowe(ii,ij) >= 0   &
+            .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN
+            iiwe = 1 + MOD(iowe(ii,ij),jpni)
+            ijwe = 1 +    (iowe(ii,ij))/jpni
+            IF( ibondi(iiwe,ijwe) == -1 ) ibondi(iiwe,ijwe) = 2
+            IF( ibondi(iiwe,ijwe) ==  0 ) ibondi(iiwe,ijwe) = 1
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibne(ii,ij) == 1 ) THEN
+            iine = 1 + MOD(ione(ii,ij),jpni)
+            ijne = 1 +    (ione(ii,ij))/jpni
+            IF( ibsw(iine,ijne) == 1 ) ibsw(iine,ijne) = 0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibsw(ii,ij) == 1 ) THEN
+            iisw = 1 + MOD(iosw(ii,ij),jpni)
+            ijsw = 1 +    (iosw(ii,ij))/jpni
+            IF( ibne(iisw,ijsw) == 1 ) ibne(iisw,ijsw) = 0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibnw(ii,ij) == 1 ) THEN
+            iinw = 1 + MOD(ionw(ii,ij),jpni)
+            ijnw = 1 +    (ionw(ii,ij))/jpni
+            IF( ibse(iinw,ijnw) == 1 ) ibse(iinw,ijnw)=0
+         ENDIF
+         IF( ipproc(ii,ij) == -1 .AND. ibse(ii,ij) == 1 ) THEN
+            iise = 1 + MOD(iose(ii,ij),jpni)
+            ijse = 1 +    (iose(ii,ij))/jpni
+            IF( ibnw(iise,ijse) == 1 ) ibnw(iise,ijse) = 0
+         ENDIF
+      END DO
+
+
+      ! 6. Change processor name
+      ! ------------------------
+
+      nproc = narea-1
+      ii = iin(narea)
+      ij = ijn(narea)
+      IF( ioso(ii,ij) >= 0 .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiso = 1 + MOD(ioso(ii,ij),jpni)
+         ijso = 1 +    (ioso(ii,ij))/jpni
+         noso = ipproc(iiso,ijso)
+      ENDIF
+      IF( iowe(ii,ij) >= 0 .AND. iowe(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiwe = 1 + MOD(iowe(ii,ij),jpni)
+         ijwe = 1 +    (iowe(ii,ij))/jpni
+         nowe = ipproc(iiwe,ijwe)
+      ENDIF
+      IF( ioea(ii,ij) >= 0 .AND. ioea(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iiea = 1 + MOD(ioea(ii,ij),jpni)
+         ijea = 1 +    (ioea(ii,ij))/jpni
+         noea = ipproc(iiea,ijea)
+      ENDIF
+      IF( iono(ii,ij) >= 0 .AND. iono(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iino = 1 + MOD(iono(ii,ij),jpni)
+         ijno = 1 +    (iono(ii,ij))/jpni
+         nono = ipproc(iino,ijno)
+      ENDIF
+      IF( iose(ii,ij) >= 0 .AND. iose(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iise = 1 + MOD(iose(ii,ij),jpni)
+         ijse = 1 +    (iose(ii,ij))/jpni
+         npse = ipproc(iise,ijse)
+      ENDIF
+      IF( iosw(ii,ij) >= 0 .AND. iosw(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iisw = 1 + MOD(iosw(ii,ij),jpni)
+         ijsw = 1 +    (iosw(ii,ij))/jpni
+         npsw = ipproc(iisw,ijsw)
+      ENDIF
+      IF( ione(ii,ij) >= 0 .AND. ione(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iine = 1 + MOD(ione(ii,ij),jpni)
+         ijne = 1 +    (ione(ii,ij))/jpni
+         npne = ipproc(iine,ijne)
+      ENDIF
+      IF( ionw(ii,ij) >= 0 .AND. ionw(ii,ij) <= (jpni*jpnj-1) ) THEN 
+         iinw = 1 + MOD(ionw(ii,ij),jpni)
+         ijnw = 1 +    (ionw(ii,ij))/jpni
+         npnw = ipproc(iinw,ijnw)
+      ENDIF
+      nbnw = ibnw(ii,ij)
+      nbne = ibne(ii,ij)
+      nbsw = ibsw(ii,ij)
+      nbse = ibse(ii,ij)
+      nlcj = ilcj(ii,ij)  
+      nlci = ilci(ii,ij)  
+      nldi = ildi(ii,ij)
+      nlei = ilei(ii,ij)
+      nldj = ildj(ii,ij)
+      nlej = ilej(ii,ij)
+      nbondi = ibondi(ii,ij)
+      nbondj = ibondj(ii,ij)
+      nimpp = iimppt(ii,ij)  
+      njmpp = ijmppt(ii,ij)  
+      DO jproc = 1, jpnij
+         ii = iin(jproc)
+         ij = ijn(jproc)
+         nimppt(jproc) = iimppt(ii,ij)  
+         njmppt(jproc) = ijmppt(ii,ij)  
+         nlcjt(jproc) = ilcj(ii,ij)
+         nlcit(jproc) = ilci(ii,ij)
+         nldit(jproc) = ildi(ii,ij)
+         nleit(jproc) = ilei(ii,ij)
+         nldjt(jproc) = ildj(ii,ij)
+         nlejt(jproc) = ilej(ii,ij)
+      END DO
+
+      ! Save processor layout in ascii file
+      IF (lwp) THEN
+         CALL ctl_opn( inum, 'layout.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
+         WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
+         WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
+
+        DO  jproc = 1, jpnij
+         WRITE(inum,'(9i5)') jproc, nlcit(jproc), nlcjt(jproc), &
+                                      nldit(jproc), nldjt(jproc), &
+                                      nleit(jproc), nlejt(jproc), &
+                                      nimppt(jproc), njmppt(jproc)
+        END DO
+        CLOSE(inum)   
+      END IF
+
+      IF( nperio == 1 .AND.jpni /= 1 ) CALL ctl_stop( ' mpp_init2:  error on cyclicity' )
+
+      ! Prepare mpp north fold
+
+      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+         CALL mpp_ini_north
+         IF(lwp) WRITE(numout,*) ' mpp_init2 : North fold boundary prepared for jpni >1'
+      ENDIF
+
+      ! Defined npolj, either 0, 3 , 4 , 5 , 6
+      ! In this case the important thing is that npolj /= 0
+      ! Because if we go through these line it is because jpni >1 and thus
+      ! we must use lbcnorthmpp, which tests only npolj =0 or npolj /= 0
+
+      npolj = 0
+      ij = ijn(narea)
+
+      IF( jperio == 3 .OR. jperio == 4 ) THEN
+         IF( ij == jpnj ) npolj = 3
+      ENDIF
+
+      IF( jperio == 5 .OR. jperio == 6 ) THEN
+         IF( ij == jpnj ) npolj = 5
+      ENDIF
+
+      ! Prepare NetCDF output file (if necessary)
+      CALL mpp_init_ioipsl
+
+      ! Periodicity : no corner if nbondi = 2 and nperio != 1
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' nproc=  ',nproc
+         WRITE(numout,*) ' nowe=   ',nowe
+         WRITE(numout,*) ' noea=   ',noea
+         WRITE(numout,*) ' nono=   ',nono
+         WRITE(numout,*) ' noso=   ',noso
+         WRITE(numout,*) ' nbondi= ',nbondi
+         WRITE(numout,*) ' nbondj= ',nbondj
+         WRITE(numout,*) ' npolj=  ',npolj
+         WRITE(numout,*) ' nperio= ',nperio
+         WRITE(numout,*) ' nlci=   ',nlci
+         WRITE(numout,*) ' nlcj=   ',nlcj
+         WRITE(numout,*) ' nimpp=  ',nimpp
+         WRITE(numout,*) ' njmpp=  ',njmpp
+         WRITE(numout,*) ' nbse=   ',nbse,' npse= ',npse
+         WRITE(numout,*) ' nbsw=   ',nbsw,' npsw= ',npsw
+         WRITE(numout,*) ' nbne=   ',nbne,' npne= ',npne
+         WRITE(numout,*) ' nbnw=   ',nbnw,' npnw= ',npnw
+      ENDIF
+
+   END SUBROUTINE mpp_init2
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/oce.F90	(revision 1844)
@@ -0,0 +1,56 @@
+MODULE oce
+   !!======================================================================
+   !!                      ***  MODULE  oce  ***
+   !! Ocean        :  dynamics and active tracers defined in memory 
+   !!======================================================================
+   !! History :  0.1  !  2002-11  (G. Madec)  F90: Free form and module
+   !!            1.0  !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.1  !  2009-02  (G. Madec, M. Leclair)  pure z* coordinate
+   !!----------------------------------------------------------------------
+   USE par_oce      ! ocean parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC ::   l_traldf_rot    = .FALSE.  !: rotated laplacian operator for lateral diffusion
+
+   !! dynamics and tracer fields             !  before  !  now     !  after   ! the after trends becomes the fields
+   !! --------------------------             !  fields  !  fields  !  trends  ! only after tra_zdf and dyn_spg
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   ub     ,  un      ,  ua      !: i-horizontal velocity      [m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   vb     ,  vn      ,  va      !: j-horizontal velocity      [m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::             wn                 !: vertical velocity          [m/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   rotb   ,  rotn               !: relative vorticity         [s-1]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   hdivb  ,  hdivn              !: horizontal divergence      [s-1]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   tb     ,  tn      ,  ta      !: potential temperature      [Celcius]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   sb     ,  sn      ,  sa      !: salinity                   [psu]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   rn2b   ,  rn2                !: brunt-vaisala frequency**2 [s-2]
+   !
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   rhd    !: in situ density anomalie rhd=(rho-rau0)/rau0     [no units]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   rhop   !: potential volumic mass                           [kg/m3]
+
+   !! advection scheme choice
+   !! -----------------------
+   CHARACTER(len=3), PUBLIC  ::   l_adv   !: flag for the advection scheme used (= 'ce2', 'tvd', 'mus' or ...)
+
+   !! surface pressure gradient
+   !! -------------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   spgu, spgv      !: horizontal surface pressure gradient
+
+   !! interpolated gradient (only used in zps case)
+   !! ---------------------
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   gtu, gsu, gru   !: horizontal gradient of T, S and rd at bottom u-point
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   gtv, gsv, grv   !: horizontal gradient of T, S and rd at bottom v-point 
+
+   !! free surface                       !  before  !  now     !  after   !
+   !! ------------                       !  fields  !  fields  !  trends  !
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sshb   ,  sshn    ,  ssha    !: sea surface height at t-point [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sshu_b ,  sshu_n  ,  sshu_a  !: sea surface height at u-point [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sshv_b ,  sshv_n  ,  sshv_a  !: sea surface height at u-point [m]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sshf_b ,  sshf_n  ,  sshf_a  !: sea surface height at f-point [m]
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2008) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/opa.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/opa.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/opa.F90	(revision 1844)
@@ -0,0 +1,410 @@
+MODULE opa
+   !!==============================================================================
+   !!                       ***  MODULE opa   ***
+   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
+   !!==============================================================================
+   !! History :  OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
+   !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
+   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
+   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes )  release 7.1 
+   !!             -   ! 1992-06  (L.Terray)  coupling implementation
+   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice 
+   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
+   !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy)  release 8.0
+   !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
+   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model 
+   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP 
+   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
+   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
+   !!             -   ! 2004-08  (C. Talandier) New trends organization
+   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
+   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
+   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
+   !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
+   !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
+   !!   opa_init       : initialization of the opa model
+   !!   opa_flg        : initialisation of algorithm flag 
+   !!   opa_closefile  : close remaining files
+   !!----------------------------------------------------------------------
+   USE oce             ! dynamics and tracers variables
+   USE dom_oce         ! ocean space domain variables
+   USE sbc_oce         ! surface boundary condition: ocean
+   USE trdmod_oce      ! ocean variables trends
+   USE domcfg          ! domain configuration               (dom_cfg routine)
+   USE mppini          ! shared/distributed memory setting (mpp_init routine)
+   USE domain          ! domain initialization             (dom_init routine)
+   USE obc_par         ! open boundary cond. parameters
+   USE obcini          ! open boundary cond. initialization (obc_ini routine)
+   USE bdy_par         ! unstructured open boundary cond. parameters
+   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
+   USE istate          ! initial state setting          (istate_init routine)
+   USE sbcmod          ! surface boundary condition 
+   USE eosbn2          ! equation of state                 (eos_init routine)
+   USE dynhpg          ! hydrostatic pressure gradient
+   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
+   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
+   USE zdfini
+   USE phycst          ! physical constant                  (par_cst routine)
+   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
+   USE diaptr          ! poleward transports           (dia_ptr_init routine)
+   USE step            ! OPA time-stepping                  (stp     routine)
+#if defined key_oasis3
+   USE cpl_oasis3      ! OASIS3 coupling
+#elif defined key_oasis4
+   USE cpl_oasis4      ! OASIS4 coupling (not working)
+#endif
+   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
+   USE prtctl          ! Print control                 (prt_ctl_init routine)
+   USE c1d             ! 1D configuration
+   USE dyncor_c1d      ! Coriolis factor at T-point
+   USE step_c1d        ! Time stepping loop for the 1D configuration
+#if defined key_top
+   USE trcini          ! passive tracer initialisation
+#endif
+   
+   USE iom
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing
+#if defined key_iomput
+   USE mod_ioclient
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   opa_model   ! called by model.F90
+   PUBLIC   opa_init    ! needed by AGRIF
+
+   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE opa_model
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa  ***
+      !!
+      !! ** Purpose :   opa solves the primitive equations on an orthogonal 
+      !!              curvilinear mesh on the sphere.
+      !!
+      !! ** Method  : - model general initialization
+      !!              - launch the time-stepping (stp routine)
+      !!              - finalize the run by closing files and communications
+      !!
+      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
+      !!              Madec, 2008, internal report, IPSL.
+      !!----------------------------------------------------------------------
+      INTEGER ::   istp       ! time step index
+      !!----------------------------------------------------------------------
+
+#if defined key_agrif
+      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
+#endif
+
+      !                            !-----------------------!
+      CALL opa_init                !==  Initialisations  ==!
+      !                            !-----------------------!
+
+      ! check that all process are still there... If some process have an error,
+      ! they will never enter in step and other processes will wait until the end of the cpu time!
+      IF( lk_mpp )   CALL mpp_max( nstop )
+
+      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
+
+      !                            !-----------------------!
+      !                            !==   time stepping   ==!
+      !                            !-----------------------!
+      istp = nit000
+      IF( lk_c1d ) THEN                 !==  1D configuration  ==!
+         DO WHILE ( istp <= nitend .AND. nstop == 0 )
+            CALL stp_c1d( istp )
+            istp = istp + 1
+         END DO
+      ELSE                              !==  3D ocean with  ==!
+         DO WHILE ( istp <= nitend .AND. nstop == 0 )
+#if defined key_agrif
+            CALL Agrif_Step( stp )           ! AGRIF: time stepping
+#else
+            CALL stp( istp )                 ! standard time stepping
+#endif
+            istp = istp + 1
+            IF( lk_mpp )   CALL mpp_max( nstop )
+         END DO
+      ENDIF
+       
+      !                            !------------------------!
+      !                            !==  finalize the run  ==!
+      !                            !------------------------!
+      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
+      !
+      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
+         WRITE(numout,cform_err)
+         WRITE(numout,*) nstop, ' error have been found' 
+      ENDIF
+      !
+      CALL opa_closefile
+#if defined key_oasis3 || defined key_oasis4
+      IF( Agrif_Root() ) THEN
+         CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
+     ENDIF 
+#else
+      IF( lk_mpp )   CALL mppstop       ! end mpp communications
+#endif
+      !
+   END SUBROUTINE opa_model
+
+
+   SUBROUTINE opa_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa_init  ***
+      !!
+      !! ** Purpose :   initialization of the opa model
+      !!
+      !!----------------------------------------------------------------------
+#if defined key_oasis3 || defined key_oasis4 || defined key_iomput
+      INTEGER :: ilocal_comm
+#endif
+      CHARACTER(len=80),dimension(10) ::   cltxt = ''
+      INTEGER                         ::   ji   ! local loop indices
+      !!
+      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
+         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench, nn_bit_cmp
+      !!----------------------------------------------------------------------
+      !
+      !                             ! open Namelist file
+      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+      !
+      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
+      !
+      !                             !--------------------------------------------!
+      !                             !  set communicator & select the local node  !
+      !                             !--------------------------------------------!
+#if defined key_iomput
+# if defined key_oasis3 || defined key_oasis4
+      IF( Agrif_Root() ) THEN
+         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
+         CALL init_ioclient()                    ! io_server will get its communicators (if needed) from oasis (we don't see it)
+      ENDIF
+# else
+      IF( Agrif_Root() ) THEN
+         CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
+      ENDIF
+# endif
+      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
+
+#else
+# if defined key_oasis3 || defined key_oasis4
+      IF( Agrif_Root() ) THEN
+         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
+      ENDIF
+      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt)
+# else
+      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
+# endif
+#endif
+      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
+
+      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
+
+      IF(lwp) THEN                            ! open listing units
+         !
+         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
+         !
+         WRITE(numout,*)
+         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
+         WRITE(numout,*) '                       NEMO team'
+         WRITE(numout,*) '            Ocean General Circulation Model'
+         WRITE(numout,*) '                  version 3.2  (2009) '
+         WRITE(numout,*)
+         WRITE(numout,*)
+         DO ji = 1, SIZE(cltxt) 
+            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
+         END DO
+         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
+         !
+      ENDIF
+      !                             !--------------------------------!
+      !                             !  Model general initialization  !
+      !                             !--------------------------------!
+
+      CALL opa_flg                          ! Control prints & Benchmark
+
+                                            ! Domain decomposition
+      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
+      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
+      ENDIF
+      
+      CALL phy_cst                          ! Physical constants
+      CALL eos_init                         ! Equation of state
+      CALL dom_cfg                          ! Domain configuration
+      CALL dom_init                         ! Domain
+!!gm c1d case can be moved in dom_init routine
+      IF( lk_c1d ) THEN                          ! 1D configuration 
+         CALL cor_c1d                            ! Coriolis defined at T-point
+         umask(:,:,:) = tmask(:,:,:)             ! U, V and T-points are the same
+         vmask(:,:,:) = tmask(:,:,:)             ! 
+      ENDIF
+!!gm c1d end
+
+      IF( ln_ctl )   CALL prt_ctl_init      ! Print control
+
+      IF( lk_obc )   CALL obc_init          ! Open boundaries 
+      IF( lk_bdy )   CALL bdy_init          ! Unstructured open boundaries
+
+      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
+
+      !                                     ! Ocean physics
+      CALL sbc_init                             ! Read namsbc namelist : surface module (needed for iom_init)
+      CALL ldf_tra_init                         ! Lateral ocean tracer physics
+      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
+      CALL zdf_init                             ! Vertical ocean physics
+
+#if defined key_top
+      CALL trc_ini                          ! Passive tracers
+#endif
+
+      !                                     ! diagnostics
+      CALL iom_init                             ! iom_put initialization
+      CALL dia_ptr_init                         ! Poleward TRansports initialization
+      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
+      !
+   END SUBROUTINE opa_init
+
+
+   SUBROUTINE opa_flg
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa  ***
+      !!
+      !! ** Purpose :   Initialise logical flags that control the choice of
+      !!              some algorithm or control print
+      !!
+      !! ** Method  : - print namctl information
+      !!              - Read in namilist namflg logical flags
+      !!----------------------------------------------------------------------
+      NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
+         &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
+         &                 ln_dynhpg_imp, nn_dynhpg_rst
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN                 ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namctl'
+         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
+         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
+         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
+         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
+         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
+         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
+         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
+         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
+         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
+         WRITE(numout,*) '      bit comparison mode (0/1)       nn_bit_cmp = ', nn_bit_cmp
+      ENDIF
+
+      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
+      nictls    = nn_ictls
+      nictle    = nn_ictle
+      njctls    = nn_jctls
+      njctle    = nn_jctle
+      isplt     = nn_isplt
+      jsplt     = nn_jsplt
+      nbench    = nn_bench
+      nbit_cmp  = nn_bit_cmp
+
+      !                           ! Parameter control
+      !
+      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
+         IF( lk_mpp ) THEN
+            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
+         ELSE
+            IF( isplt == 1 .AND. jsplt == 1  ) THEN
+               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
+                  &           ' - the print control will be done over the whole domain' )
+            ENDIF
+            ijsplt = isplt * jsplt            ! total number of processors ijsplt
+         ENDIF
+         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
+         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
+         !
+         !                              ! indices used for the SUM control
+         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
+            lsp_area = .FALSE.                        
+         ELSE                                             ! print control done over a specific  area
+            lsp_area = .TRUE.
+            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
+               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
+               nictls = 1
+            ENDIF
+            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
+               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
+               nictle = jpiglo
+            ENDIF
+            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
+               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
+               njctls = 1
+            ENDIF
+            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
+               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
+               njctle = jpjglo
+            ENDIF
+         ENDIF
+      ENDIF
+
+      IF( nbench == 1 )   THEN            ! Benchmark 
+         SELECT CASE ( cp_cfg )
+         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
+         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
+            &                                 ' key_gyre must be used or set nbench = 0' )
+         END SELECT
+      ENDIF
+
+      IF( nbit_cmp == 1 )   THEN          ! Bit compare
+         CALL ctl_warn( ' Bit comparison enabled. Single and multiple processor results must bit compare', &
+              &         ' WARNING: RESULTS ARE NOT PHYSICAL.' )
+      ENDIF
+
+      REWIND( numnam )              ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase
+      READ  ( numnam, namdyn_hpg )
+      !
+   END SUBROUTINE opa_flg
+
+
+   SUBROUTINE opa_closefile
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE opa_closefile  ***
+      !!
+      !! ** Purpose :   Close the files
+      !!----------------------------------------------------------------------
+      USE dtatem        ! temperature data
+      USE dtasal        ! salinity data
+      !!----------------------------------------------------------------------
+      !
+      IF( lk_mpp )   CALL mppsync
+      !
+      CALL iom_close                                 ! close all input/output files managed by iom_*
+      !
+      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
+      IF( numsol     /= -1 )   CLOSE( numsol     )   ! solver file
+      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
+      IF( numnam_ice /= -1 )   CLOSE( numnam_ice )   ! ice namelist
+      IF( numevo_ice /= -1 )   CLOSE( numevo_ice )   ! ice variables (temp. evolution)
+      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
+      numout = 6   ! redefine numout in case it is used after this point...
+      !
+   END SUBROUTINE opa_closefile
+
+   !!======================================================================
+END MODULE opa
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R2.h90	(revision 1844)
@@ -0,0 +1,96 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R2.h90  ***
+   !!   Ocean Domain : 2 km resolution Channel (EEL_R2 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 2   ,         &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 83,          &  !: 1st horizontal dimension ( >= jpi )
+      jpjdta  = 242,         &  !: 2nd    "            "    ( >= jpj )
+      jpkdta  = 30,          &  !: number of levels         ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =     1           !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp  , & !: ???
+      pp_to_be_computed =      0._wp      !: ???
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 3            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used ,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used ,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 2000.0_wp,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = 2000.0_wp       !: meridional grid-spacing (meters )
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+   REAL(wp) &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::     &  !:
+      &     ppsur = -2033.194295283385_wp   ,  &  !: Computed in domzgr
+      &     ppa0  =  155.8325369664153_wp   ,  &  !:
+      &     ppa1  =  146.3615918601890_wp   ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R5.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R5.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R5.h90	(revision 1844)
@@ -0,0 +1,96 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R5.h90  ***   
+   !!   Ocean Domain : 5 km resolution Channel (EEL_R5 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 5      ,      &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files
+      jpidta  =  66   ,      &  !: first horizontal dimension > or = to jpi
+      jpjdta  =  66   ,      &  !: second                     > or = to jpj
+      jpkdta  =  31   ,      &  !: number of levels           > or = to jpk
+
+      ! total domain size      !!! * full domain *
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =   1             !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp ,  &  !:
+      pp_to_be_computed =      0._wp       !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 2            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = 43.436430714_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 8000.0_wp,   &  !: zonal      grid-spacing (meters)
+      ppe2_m   = 8000.0_wp       !: meridional grid-spacing (meters)
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+   REAL(wp), PARAMETER  ::       &   !:
+      &     ppsur = -4762.96143546300_wp    ,  &  !: Computed in domzgr, set ppdzmin, pphmax below
+      &     ppa0  =   255.58049070440_wp    ,  &  !:
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      !
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R6.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R6.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_EEL_R6.h90	(revision 1844)
@@ -0,0 +1,96 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_EEL_R6.h90  ***   
+   !!   Ocean Domain : 6 km resolution Channel (EEL_R6 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "eel"            !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::     &
+      jp_cfg = 6      ,      &  !: resolution of the configuration (km)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 29,          &  !: 1st lateral dimension ( >= jpi )
+      jpjdta  = 83,          &  !: 2nd    "         "    ( >= jpj )
+      jpkdta  = 30,          &  !: number of levels      ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+
+      ! Domain characteristics
+      jperio  =      1          !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp ,  &  !: ???
+      pp_to_be_computed =      0._wp       !: ???
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 3            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = 6000.0_wp,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = 6000.0_wp       !: meridional grid-spacing (meters )
+
+   !!  Coefficients associated with the vertical coordinate system
+
+   REAL(wp), PARAMETER  ::       &  !:
+      &     ppsur = -2033.194295283385_wp   ,  &  !: Computed in domzgr
+      &     ppa0  =  155.8325369664153_wp   ,  &  !:
+      &     ppa1  =  146.3615918601890_wp   ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_GYRE.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_GYRE.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_GYRE.h90	(revision 1844)
@@ -0,0 +1,101 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_GYRE.h90  ***
+   !!   Ocean Domain : GYRE configuration at 1/jp_cfg degree resolution 
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "gyre"           !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg =  1   ,        &  !: 
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 30*jp_cfg+2, &  !: 1st horizontal dimension ( >= jpi )
+      jpjdta  = 20*jp_cfg+2, &  !: 2nd    "            "    ( >= jpj )
+      jpkdta  = 31,          &  !: number of levels         ( >= jpk )
+
+      ! global domain size     !!! * full domain *
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+
+      ! Domain characteristics
+      jperio  =     0           !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &  !:
+      pp_not_used       = 999999._wp  , & !: ???
+      pp_to_be_computed =      0._wp      !: ???
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER,PARAMETER   ::    & !:
+      jphgr_msh = 5            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+      !                        ! =5  beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::     &  !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =   29.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used ,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used ,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,    &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used        !: meridional grid-spacing (meters )
+   !!
+   !!  Coefficients associated with the vertical coordinate system
+   !!
+
+   REAL(wp), PARAMETER  ::       &  !:
+      &     ppsur = -2033.194295283385_wp   ,  &  !: 
+      &     ppa0  =  155.8325369664153_wp   ,  &  !:
+      &     ppa1  =  146.3615918601890_wp   ,  &  !:
+      !
+      &     ppkth =  17.28520372419791_wp   ,  &  !: (non dimensional): gives the approximate
+      !                                           !    layer number above which  stretching will
+      !                                           !    be maximum. Usually of order jpk/2.
+      &     ppacr =  5.000000000000000_wp         !: (non dimensional): stretching factor
+      !                                           !    for the grid. The highest zacr, the smallest
+      !                                           !    the stretching.
+
+   !!
+   !!  If all ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &  !:
+      &     ppdzmin = pp_not_used   ,  &  !: (meters): depth of the top (first) model layer
+      !                             !            depth of second "w" level
+      &     pphmax  = pp_not_used         !: (meters): maximum depth of the ocean
+      !                             !            depth of the last "w" level
+
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R025.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R025.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R025.h90	(revision 1844)
@@ -0,0 +1,89 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R025.h90  ***  
+   !!   Ocean Domain : 0.25 degrees resolution global ocean
+   !!                  (0RCA_R025 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "orca"           !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 025  ,        &  !: resolution of the configuration (degrees)
+      ! Original data size
+      jpidta  = 1442,        &  !: first horizontal dimension > or = to jpi
+      jpjdta  = 1021,        &  !: second                     > or = to jpj
+      jpkdta  = 46 ,         &  !: number of levels           > or = to jpk
+      ! total domain matrix size
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+      ! Domain characteristics
+      jperio  =    4            !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL,PARAMETER      ::  pp_not_used = 999999_wp , &
+      &                    pp_to_be_computed = 0._wp
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER, PARAMETER ::     & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp), PARAMETER ::       &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!  Coefficients associated with the vertical coordinate system
+
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = pp_to_be_computed ,  &  !: Computed in domzgr, set ppdzmin and pphmax below
+      &     ppa0  = pp_to_be_computed ,  &  !:    "           "
+      &     ppa1  = pp_to_be_computed ,  &  !:    "           "
+      !
+      &     ppkth =  23.563_wp        ,  &  !: (non dimensional): gives the approximate
+      !                                     !: layer number above which  stretching will
+      !                                     !: be maximum. Usually of order jpk/2.
+      &     ppacr =    9.00000000000_wp     !: (non dimensional): stretching factor
+      !                                     !: for the grid. The highest zacr, the smallest
+      !                                     !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = 6._wp           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = 5750._wp              !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R05.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R05.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R05.h90	(revision 1844)
@@ -0,0 +1,133 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R05.h90  ***  
+   !!   Ocean Domain : 0.5 degrees resolution global ocean
+   !!                  (0RCA_R05 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "orca"           !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 05  ,         &  !: resolution of the configuration (degrees)
+
+      ! data size              !!! * size of all the input files *
+      jpidta  = 722,         &  !: 1st lateral dimension > or = to jpiglo
+      jpjdta  = 511,         &  !: 2nd   "         "     > or = to jpjglo
+      jpkdta  =  31             !: number of levels      > or = to jpkglo
+
+#if defined key_antarctic
+      ! zoom domain size       !!! *  antarctic zoom  * 
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 187   ,      &  !: 2nd     "                 "    --> j 
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   1             !: lateral cond. type (between 0 and 6)
+
+#elif defined key_arctic
+      ! zoom domain size       !!! *  arctic zoom  *
+   INTEGER    &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      ! zoom domain size       !!! *  arctic zoom  *
+      jpiglo  = 562,         &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta-301+1,&  !: 2nd     "                 "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =  81   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom = 301   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   5             !: lateral cond. type (between 0 and 6)
+
+#else
+      ! global domain size     !!! *  global domain  *
+   INTEGER    &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd     "                 "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position    
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =    6            !: lateral cond. type (between 0 and 6)
+#endif
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999._wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER, PARAMETER   ::   & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) , PARAMETER ::      &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!
+   !! Vertical grid parameter for domzgr
+   !! =====================================
+   !!
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R2.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R2.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R2.h90	(revision 1844)
@@ -0,0 +1,160 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R2.h90  ***  
+   !!   Ocean Domain : 2 degrees resolution global ocean
+   !!                  (0RCA_R2 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "orca"           !: name of the configuration 
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 2,            &  !: resolution of the configuration (degrees)
+
+      ! data size              !!! * size of all input files *
+      jpidta  = 182,         &  !: 1st lateral dimension ( >= jpiglo )
+      jpjdta  = 149,         &  !: 2nd    "       "      ( >= jpjglo )
+      jpkdta  = 31              !: number of levels      ( >= jpk    ) 
+
+#if defined key_antarctic
+      ! zoom domain size       !!! *  antarctic zoom  * 
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 50,          &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   1             !: lateral cond. type (between 0 and 6)
+
+#elif defined key_arctic
+      ! zoom domain size       !!! *  arctic zoom  *
+   INTEGER    &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = 142   ,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta-97+1, &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! zoom starting position 
+      jpizoom =  21   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =  97   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   3             !: lateral cond. type (between 0 and 6)
+
+#elif defined key_c1d
+      ! global domain size     !!! *  global domain  *
+   INTEGER    &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = 3     ,      &  !: 1st dimension of global domain --> i
+      jpjglo  = 3     ,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom 
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   133  ,    &  !: in data domain indices (160W,75N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   110  ,    &  !: in data domain indices (160W,50N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   97   ,    &  !: in data domain indices (160W,30N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   86   ,    &  !: in data domain indices (160W,10N)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   49   ,    &  !: in data domain indices (160W,30S)
+      ! jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      ! jpjzoom =   27   ,    &  !: in data domain indices (160W,60S)
+      jpizoom =   61   ,    &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =    7   ,    &  !: in data domain indices (160W,75S)
+      ! Domain characteristics
+      jperio  =   0            !: lateral cond. type (between 0 and 6)
+#else
+      ! global domain size     !!! *  global domain  *
+   INTEGER    &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jpiglo  = jpidta,      &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom 
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data domain indices
+      ! Domain characteristics
+      jperio  =   4             !: lateral cond. type (between 0 and 6)
+
+#endif
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999_wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+
+   INTEGER,PARAMETER   ::    & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) ,PARAMETER ::       &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+   !!
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R4.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R4.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_ORCA_R4.h90	(revision 1844)
@@ -0,0 +1,89 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R4.h90  ***   
+   !!   Ocean Domain : 4 degrees resolution global ocean
+   !!                  (0RCA_R4 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+       ::    &  
+     cp_cfg = "orca"           !: name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 4      ,      &  !: resolution of the configuration (degrees)
+      ! Original data size
+      jpidta  =  92   ,      &  !: first horizontal dimension > or = to jpi
+      jpjdta  =  76   ,      &  !: second                     > or = to jpj
+      jpkdta  =  31   ,      &  !: number of levels           > or = to jpk
+      ! global domain matrix size
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+      ! Domain characteristics
+      jperio  =   4             !: lateral cond. type (between 0 and 6)
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL(wp), PARAMETER ::   &
+      pp_not_used       = 999999_wp , &  !:
+      pp_to_be_computed = 0._wp          !:
+
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   INTEGER, PARAMETER ::     & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        ! = 0 curvilinear coordinate on the sphere
+      !                        !     read in coordinate.nc file
+      !                        ! = 1 geographical mesh on the sphere
+      !                        !     with regular grid-spacing
+      !                        ! = 2 f-plane with regular grid-spacing
+      !                        ! = 3 beta-plane with regular grid-spacing
+      !                        ! = 4 Mercator grid with T/U point at the equator  with
+      !                        !     isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp) , PARAMETER ::      &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            ! latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = -4762.96143546300_wp    ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp    ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp    ,  &  !:
+      &     ppkth =    21.43336197938_wp    ,  &  !: (non dimensional): gives the approximate
+      !                                           !: layer number above which  stretching will
+      !                                           !: be maximum. Usually of order jpk/2.
+      &     ppacr =     3.00000000000_wp          !: (non dimensional): stretching factor
+      !                                           !: for the grid. The highest zacr, the smallest
+      !                                           !: the stretching.
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = pp_not_used           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = pp_not_used                 !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_POMME_R025.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_POMME_R025.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_POMME_R025.h90	(revision 1844)
@@ -0,0 +1,103 @@
+   !!---------------------------------------------------------------------
+   !!                     ***  par_ORCA_R025.h90  ***  
+   !!   Ocean Domain : 0.25 degrees resolution global ocean
+   !!                  (0RCA_R025 configuration)
+   !!---------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/par_ORCA_R025.h90,v 1.6 2006/03/10 10:55:34 opalod Exp $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+   CHARACTER (len=16)      &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      ::    &  
+      cp_cfg = "pomme"          !: POMME025 name of the configuration
+   INTEGER     &
+#if !defined key_agrif
+      , PARAMETER  &
+#endif
+      :: &
+      jp_cfg = 025  ,        &  !: resolution of the configuration (degrees)
+      ! Original data size
+
+      ! ORCA025 global grid size
+      jpiglo_ORCA025 = 1442, &
+      jpjglo_ORCA025 = 1021, &  ! not used currently
+
+      ! POMME "global" domain localisation in the ORCA025 global grid
+      jpi_iw    = 1059,      & 
+      jpi_ie    = 1088,      &  
+      jpj_js    = 661,       &
+      jpj_jn    = 700,       &
+
+      jpidta  = ( jpi_ie - jpi_iw + 1 ), &   !: =30 first horizontal dimension > or = to jpi
+      jpjdta  = ( jpj_jn - jpj_js + 1 ), &   !: =40 second                     > or = to jpj
+      jpkdta  = 46 ,         &  !: number of levels           > or = to jpk
+
+      ! total domain matrix size
+      jpiglo  = jpidta,      &  !: first  dimension of global domain --> i
+      jpjglo  = jpjdta,      &  !: second dimension of global domain --> j
+      jpk     = jpkdta,      &  !: number of vertical levels
+      ! starting position of the zoom
+      jpizoom =   1   ,      &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,      &  !: in data indices
+      ! Domain characteristics
+      jperio  =    0  ,      &  !: lateral cond. type (between 0 and 6)
+      jpisl   =  150  ,      &  !: number of islands
+      jpnisl  = 3000            !: maximum number of points per island
+
+   !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+   !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+   REAL,PARAMETER      ::  pp_not_used = 999999_wp , &
+      &                    pp_to_be_computed = 0._wp
+   !!
+   !! Coefficients associated with the horizontal coordinate system (jphgr_msh /= 0 )
+   !!
+   INTEGER, PARAMETER ::     & !
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+      !   ppglam0 , ppgphi0: coordinates of the lower leftmost T point of the grid.
+      !   The mercator grid starts only approximately at gphi0 because
+      !   of the constraint that the equator be a T point.
+   REAL(wp), PARAMETER ::       &  !
+      ppglam0  = pp_not_used,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  = pp_not_used,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                            !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg = pp_not_used,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg = pp_not_used,   &  !: meridional grid-spacing (degrees)
+      !
+      ppe1_m   = pp_not_used,   &  !: zonal      grid-spacing (meters )
+      ppe2_m   = pp_not_used       !: meridional grid-spacing (meters )
+
+   !!  Coefficients associated with the vertical coordinate system
+
+   REAL(wp), PARAMETER  ::       &
+      &     ppsur = pp_to_be_computed ,  &  !: Computed in domzgr, set ppdzmin and pphmax below
+      &     ppa0  = pp_to_be_computed ,  &  !:    "           "
+      &     ppa1  = pp_to_be_computed ,  &  !:    "           "
+      !
+      &     ppkth =  23.563_wp        ,  &  !: (non dimensional): gives the approximate
+      !                                     !: layer number above which  stretching will
+      !                                     !: be maximum. Usually of order jpk/2.
+      &     ppacr =    9.00000000000_wp     !: (non dimensional): stretching factor
+      !                                     !: for the grid. The highest zacr, the smallest
+      !                                     !: the stretching.
+
+   !!
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+   !!
+   REAL(wp), PARAMETER ::        &
+      &     ppdzmin = 6._wp           ,  &  !: (meters) vertical thickness of the top layer
+      &     pphmax  = 5750._wp              !: (meters) Maximum depth of the ocean gdepw(jpk)
+   !!---------------------------------------------------------------------
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_kind.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_kind.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_kind.F90	(revision 1844)
@@ -0,0 +1,39 @@
+MODULE par_kind
+   !!======================================================================
+   !!                   ***  MODULE par_kind  ***
+   !! Ocean :  define the kind of real for the whole model
+   !!======================================================================
+   !! History :
+   !!   8.5   02/06  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTEGER, PUBLIC, PARAMETER ::    &  !:
+      jpbyt   = 8       ,           &  !: real size for mpp communications
+      jpbytda = 4       ,           &  !: real size in input data files 4 or 8
+      jpbi3e  = 4                      !: real size for T3E
+
+   ! Number model from which the SELECTED_*_KIND are requested:
+   !             4 byte REAL       8 byte REAL
+   ! CRAY:           -            precision = 13
+   !                              exponent = 2465
+   ! IEEE:      precision = 6     precision = 15
+   !            exponent = 37     exponent = 307
+
+   INTEGER, PUBLIC, PARAMETER ::        &  !: Floating point section
+      sp = SELECTED_REAL_KIND( 6, 37),  &  !: single precision (real 4)
+      dp = SELECTED_REAL_KIND(12,307),  &  !: double precision (real 8)
+      wp = dp                              !: working precision
+
+   INTEGER, PUBLIC, PARAMETER ::        &  !: Integer section
+      i4 = SELECTED_INT_KIND(9) ,       &  !: single precision (integer 4)
+      i8 = SELECTED_INT_KIND(14)           !: double precision (integer 8)
+
+!!----------------------------------------------------------------------
+END MODULE par_kind
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/par_oce.F90	(revision 1844)
@@ -0,0 +1,225 @@
+MODULE par_oce
+   !!======================================================================
+   !!                        ***  par_oce  ***
+   !! Ocean :   set the ocean parameters
+   !!======================================================================
+   !! History :
+   !!   4.0  !  91     (Imbard, Levy, Madec)  Original code
+   !!   9.0  !  04-01  (G. Madec, J.-M. Molines)  Free form and module
+   !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind          ! kind parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !!   Domain decomposition
+   !!----------------------------------------------------------------------
+   !! * if we dont use massively parallel computer (parameters jpni=jpnj=1)
+   !!      so jpiglo=jpi and jpjglo=jpj
+
+#if ! defined key_mpp_dyndist 
+   INTEGER, PUBLIC, PARAMETER ::    &  !: 
+      jpni   = 1,                   &  !: number of processors following i 
+      jpnj   = 1,                   &  !: number of processors following j
+      jpnij  = 1                       !: nb of local domain = nb of processors 
+      !                                !  ( <= jpni x jpnj )
+#else
+   INTEGER, PUBLIC ::               &  !
+      jpni      ,                   &  !: number of processors following i 
+      jpnj      ,                   &  !: number of processors following j
+      jpnij                            !: nb of local domain = nb of processors 
+      !                                !  ( <= jpni x jpnj )
+#endif
+
+   INTEGER, PUBLIC, PARAMETER ::    &  !:
+      jpr2di = 0,                   &  !: number of columns for extra outer halo 
+      jpr2dj = 0,                   &  !: number of rows    for extra outer halo 
+      jpreci = 1,                   &  !: number of columns for overlap 
+      jprecj = 1                       !: number of rows    for overlap 
+
+   !! Ocean Domain sizes
+   !! ------------------
+   !!   data           domain   (jpidta,jpjdta)
+   !!   global or zoom domain   (jpiglo,jpjglo)
+   !!   local          domain   ( jpi  , jpj  )
+   
+#if   defined key_orca_r4
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r4'   :                           global ocean : ORCA R4
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R4.h90"
+#elif defined key_orca_r2
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r2'   :                           global ocean : ORCA R4
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R2.h90"
+#elif defined key_orca_r05
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r05'  :                          global ocean : ORCA R05
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R05.h90"
+#elif defined key_orca_r025
+   !!---------------------------------------------------------------------
+   !!   'key_orca_r025' :                         global ocean : ORCA R025
+   !!---------------------------------------------------------------------
+#             include "par_ORCA_R025.h90"
+#elif defined key_eel_r2
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r2'    :                                 channel : EEL R2
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R2.h90"
+#elif defined key_eel_r5
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r5'    :                                 channel : EEL R5
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R5.h90"
+#elif defined key_eel_r6
+   !!---------------------------------------------------------------------
+   !!   'key_eel_r6'    :                                 channel : EEL R6
+   !!---------------------------------------------------------------------
+#             include "par_EEL_R6.h90"
+#elif defined key_gyre
+   !!---------------------------------------------------------------------
+   !!   'key_gyre'      :                        mid-latitude basin : GYRE
+   !!---------------------------------------------------------------------
+#             include "par_GYRE.h90"
+#elif defined key_pomme_r025
+   !!---------------------------------------------------------------------
+   !!   'key_pomme_r025':                        regional basin : POMME025
+   !!---------------------------------------------------------------------
+#             include "par_POMME_R025.h90"
+#else
+   !!---------------------------------------------------------------------
+   !!   default option  :                               small closed basin
+   !!---------------------------------------------------------------------
+   CHARACTER(len=16), PUBLIC, PARAMETER ::   &  !:
+      cp_cfg = "default"               !: name of the configuration
+   INTEGER, PARAMETER ::            &  !:
+      jp_cfg = 0  ,                 &  !: resolution of the configuration
+
+      ! data size                     !!! * size of all input files *
+      jpidta  = 10,                 &  !: 1st lateral dimension ( >= jpi )
+      jpjdta  = 12,                 &  !: 2nd    "         "    ( >= jpj )
+      jpkdta  = 31,                 &  !: number of levels      ( >= jpk )
+
+      ! global or zoom domain size    !!! * computational domain *
+      jpiglo  = jpidta,             &  !: 1st dimension of global domain --> i
+      jpjglo  = jpjdta,             &  !: 2nd    "                  "    --> j
+      jpk     = jpkdta,             &  !: number of vertical levels
+      ! zoom starting position 
+      jpizoom =   1   ,             &  !: left bottom (i,j) indices of the zoom
+      jpjzoom =   1   ,             &  !: in data domain indices
+
+      ! Domain characteristics
+      jperio  =  0                     !: lateral cond. type (between 0 and 6)
+         !                             !  = 0 closed
+         !                             !  = 1 cyclic East-West
+         !                             !  = 2 equatorial symmetric
+         !                             !  = 3 North fold T-point pivot
+         !                             !  = 4 cyclic East-West AND North fold T-point pivot
+         !                             !  = 5 North fold F-point pivot
+         !                             !  = 6 cyclic East-West AND North fold F-point pivot
+
+      !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
+      !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
+      REAL(wp), PARAMETER ::   &  !:
+         pp_not_used       = 999999._wp , &  !:
+         pp_to_be_computed = 999999._wp      !:
+
+
+   !! Horizontal grid parameters for domhgr
+   !! =====================================
+
+   INTEGER, PUBLIC, PARAMETER   ::   &  !:
+      jphgr_msh = 0            !: type of horizontal mesh
+      !                        !  = 0 curvilinear coordinate on the sphere
+      !                        !      read in coordinate.nc file
+      !                        !  = 1 geographical mesh on the sphere
+      !                        !      with regular grid-spacing
+      !                        !  = 2 f-plane with regular grid-spacing
+      !                        !  = 3 beta-plane with regular grid-spacing
+      !                        !  = 4 Mercator grid with T/U point at the equator  with
+      !                        !      isotropic resolution (e1_deg)
+
+   REAL(wp) , PUBLIC, PARAMETER ::   &   !:
+      ppglam0  =    0.0_wp,   &  !: longitude of first raw and column T-point (jphgr_msh = 1)
+      ppgphi0  =  -35.0_wp,   &  !: latitude  of first raw and column T-point (jphgr_msh = 1)
+      !                          !  latitude for the Coriolis or Beta parameter (jphgr_msh = 2 or 3)
+      ppe1_deg =    1.0_wp,   &  !: zonal      grid-spacing (degrees)
+      ppe2_deg =    0.5_wp,   &  !: meridional grid-spacing (degrees)
+      ppe1_m   = 5000.0_wp,   &  !: zonal      grid-spacing (degrees)
+      ppe2_m   = 5000.0_wp       !: meridional grid-spacing (degrees)
+
+   !! Vertical grid parameter for domzgr
+   !! ==================================
+
+   REAL(wp), PUBLIC, PARAMETER  ::   &  !:
+      &     ppsur = -4762.96143546300_wp ,  &  !: ORCA r4, r2 and r05 coefficients
+      &     ppa0  =   255.58049070440_wp ,  &  !: (default coefficients)
+      &     ppa1  =   245.58132232490_wp ,  &  !:
+      &     ppkth =    21.43336197938_wp ,  &  !:
+      &     ppacr =     3.00000000000_wp       !:
+
+   !!  If both ppa0 ppa1 and ppsur are specified to 0, then
+   !!  they are computed from ppdzmin, pphmax , ppkth, ppacr in dom_zgr
+
+   REAL(wp), PUBLIC, PARAMETER ::   &  !:
+      &     ppdzmin = 10._wp             ,  &  !: Minimum vertical spacing
+      &     pphmax  = 5000._wp                 !: Maximum depth
+
+   !!---------------------------------------------------------------------
+#endif
+
+   !!---------------------------------------------------------------------
+   !! Domain Matrix size
+   !!---------------------------------------------------------------------
+   INTEGER  &  !:
+#if !defined key_agrif
+      ,PARAMETER  &
+#endif
+    :: &
+      jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ,   &  !: first  dimension
+      jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ,   &  !: second dimension
+      jpim1 = jpi-1,                                             &  !: inner domain indices
+      jpjm1 = jpj-1,                                             &  !:   "            "
+      jpkm1 = jpk-1,                                             &  !:   "            "
+      jpij  = jpi*jpj                                               !:  jpi x jpj
+
+#if defined key_agrif
+   !!---------------------------------------------------------------------
+   !! Agrif variables
+   !!---------------------------------------------------------------------
+   INTEGER, PUBLIC, PARAMETER :: nbghostcells = 1
+   INTEGER, PUBLIC :: nbcellsx = jpiglo - 2 - 2*nbghostcells
+   INTEGER, PUBLIC :: nbcellsy = jpjglo - 2 - 2*nbghostcells
+#endif
+   !!---------------------------------------------------------------------
+   !! Optimization/control flags
+   !!---------------------------------------------------------------------
+#if defined key_esopa
+   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .TRUE.   !: flag to activate the all options
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .FALSE.  !: flag to activate the all options
+#endif
+
+#if defined key_vectopt_memory
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_mem  = .TRUE.   !: vector optimization flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_mem  = .FALSE.  !: vector optimization flag
+#endif
+
+#if defined key_vectopt_loop
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_loop = .TRUE.   !: vector optimization flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_vopt_loop = .FALSE.  !: vector optimization flag
+#endif
+
+   !!======================================================================
+END MODULE par_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/step.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/step.F90	(revision 1844)
@@ -0,0 +1,351 @@
+MODULE step
+   !!======================================================================
+   !!                       ***  MODULE step  ***
+   !! Time-stepping    : manager of the ocean, tracer and ice time stepping
+   !!======================================================================
+   !! History :  OPA  !  1991-03  (G. Madec)  Original code
+   !!             -   !  1991-11  (G. Madec)
+   !!             -   !  1992-06  (M. Imbard)  add a first output record
+   !!             -   !  1996-04  (G. Madec)  introduction of dynspg
+   !!             -   !  1996-04  (M.A. Foujols)  introduction of passive tracer
+   !!            8.0  !  1997-06  (G. Madec)  new architecture of call
+   !!            8.2  !  1997-06  (G. Madec, M. Imbard, G. Roullet)  free surface
+   !!             -   !  1999-02  (G. Madec, N. Grima)  hpg implicit
+   !!             -   !  2000-07  (J-M Molines, M. Imbard)  Open Bondary Conditions
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  free form, suppress macro-tasking
+   !!             -   !  2004-08  (C. Talandier) New trends organization
+   !!             -   !  2005-01  (C. Ethe) Add the KPP closure scheme
+   !!             -   !  2005-11  (G. Madec)  Reorganisation of tra and dyn calls
+   !!             -   !  2006-01  (L. Debreu, C. Mazauric)  Agrif implementation
+   !!             -   !  2006-07  (S. Masson)  restart using iom
+   !!            3.2  !  2009-02  (G. Madec, R. Benshila)  reintroduicing z*-coordinate
+   !!             -   !  2009-06  (S. Masson, G. Madec)  TKE restart compatible with key_cpl
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp            : OPA system time-stepping
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE zdf_oce         ! ocean vertical physics variables
+   USE ldftra_oce      ! ocean tracer   - trends
+   USE ldfdyn_oce      ! ocean dynamics - trends
+   USE in_out_manager  ! I/O manager
+   USE iom             !
+   USE lbclnk
+
+   USE daymod          ! calendar                         (day     routine)
+
+   USE dtatem          ! ocean temperature data           (dta_tem routine)
+   USE dtasal          ! ocean salinity    data           (dta_sal routine)
+   USE sbcmod          ! surface boundary condition       (sbc     routine)
+   USE sbcrnf          ! surface boundary condition: runoff variables
+   USE sbccpl          ! surface boundary condition: coupled formulation (call send at end of step)
+   USE cpl_oasis3, ONLY : lk_cpl
+
+#if defined key_top
+   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
+#endif
+
+   USE traqsr          ! solar radiation penetration      (tra_qsr routine)
+   USE trasbc          ! surface boundary condition       (tra_sbc routine)
+   USE trabbc          ! bottom boundary condition        (tra_bbc routine)
+   USE trabbl          ! bottom boundary layer            (tra_bbl routine)
+   USE tradmp          ! internal damping                 (tra_dmp routine)
+   USE traadv          ! advection scheme control     (tra_adv_ctl routine)
+   USE traldf          ! lateral mixing                   (tra_ldf routine)
+   USE cla             ! cross land advection             (tra_cla routine)
+   !   zdfkpp          ! KPP non-local tracer fluxes      (tra_kpp routine)
+   USE trazdf          ! vertical mixing                  (tra_zdf routine)
+   USE tranxt          ! time-stepping                    (tra_nxt routine)
+   USE tranpc          ! non-penetrative convection       (tra_npc routine)
+
+   USE eosbn2          ! equation of state                (eos_bn2 routine)
+
+   USE dynadv          ! advection                        (dyn_adv routine)
+   USE dynbfr          ! Bottom friction terms            (dyn_bfr routine)
+   USE dynvor          ! vorticity term                   (dyn_vor routine)
+   USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
+   USE dynldf          ! lateral momentum diffusion       (dyn_ldf routine)
+   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
+   USE dynspg_oce      ! surface pressure gradient        (dyn_spg routine)
+   USE dynspg          ! surface pressure gradient        (dyn_spg routine)
+   USE dynnxt          ! time-stepping                    (dyn_nxt routine)
+
+   USE obc_par         ! open boundary condition variables
+   USE obcdta          ! open boundary condition data     (obc_dta routine)
+   USE obcrst          ! open boundary cond. restart      (obc_rst routine)
+   USE obcrad          ! open boundary cond. radiation    (obc_rad routine)
+
+   USE bdy_par         ! unstructured open boundary data variables
+   USE bdydta          ! unstructured open boundary data  (bdy_dta routine)
+
+   USE sshwzv          ! vertical velocity and ssh        (ssh_wzv routine)
+
+   USE ldfslp          ! iso-neutral slopes               (ldf_slp routine)
+   USE ldfeiv          ! eddy induced velocity coef.      (ldf_eiv routine)
+
+   USE zdftmx          ! tide-induced vertical mixing     (zdf_tmx routine)
+   USE zdfbfr          ! bottom friction                  (zdf_bfr routine)
+   USE zdftke_old      ! old TKE vertical mixing      (zdf_tke_old routine)
+   USE zdftke          ! TKE vertical mixing              (zdf_tke routine)
+   USE zdfkpp          ! KPP vertical mixing              (zdf_kpp routine)
+   USE zdfddm          ! double diffusion mixing          (zdf_ddm routine)
+   USE zdfevd          ! enhanced vertical diffusion      (zdf_evd routine)
+   USE zdfric          ! Richardson vertical mixing       (zdf_ric routine)
+   USE zdfmxl          ! Mixed-layer depth                (zdf_mxl routine)
+
+   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
+
+   USE diawri          ! Standard run outputs             (dia_wri routine)
+   USE trdicp          ! Ocean momentum/tracers trends    (trd_wri routine)
+   USE trdmld          ! mixed-layer trends               (trd_mld routine)
+   USE trdmld_rst      ! restart for mixed-layer trends
+   USE trdmod_oce      ! ocean momentum/tracers trends
+   USE trdvor          ! vorticity budget                 (trd_vor routine)
+   USE diagap          ! hor. mean model-data gap         (dia_gap routine)
+   USE diahdy          ! dynamic height                   (dia_hdy routine)
+   USE diaptr          ! poleward transports              (dia_ptr routine)
+   USE diaar5          ! AR5 diagnosics                   (dia_ar5 routine)
+   USE diahth          ! thermocline depth                (dia_hth routine)
+   USE diafwb          ! freshwater budget                (dia_fwb routine)
+   USE flo_oce         ! floats variables
+   USE floats          ! floats computation               (flo_stp routine)
+
+   USE stpctl          ! time stepping control            (stp_ctl routine)
+   USE restart         ! ocean restart                    (rst_wri routine)
+   USE prtctl          ! Print control                    (prt_ctl routine)
+
+#if defined key_agrif
+   USE agrif_opa_sponge ! Momemtum and tracers sponges
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   stp        ! called by opa.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "zdfddm_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_agrif
+   SUBROUTINE stp( )
+      INTEGER             ::   kstp   ! ocean time-step index
+#else
+   SUBROUTINE stp( kstp )
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
+#endif
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE stp  ***
+      !!                      
+      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
+      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
+      !!              - Tme stepping  of TRC (passive tracer eqs.)
+      !! 
+      !! ** Method  : -1- Update forcings and data  
+      !!              -2- Update ocean physics 
+      !!              -3- Compute the t and s trends 
+      !!              -4- Update t and s 
+      !!              -5- Compute the momentum trends
+      !!              -6- Update the horizontal velocity
+      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
+      !!              -8- Outputs and diagnostics
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk       ! dummy loop indice
+      INTEGER ::   indic    ! error indicator if < 0
+      !! ---------------------------------------------------------------------
+
+#if defined key_agrif
+      kstp = nit000 + Agrif_Nb_Step()
+!      IF( Agrif_Root() .and. lwp) Write(*,*) '---'
+!      IF(lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp
+# if defined key_iomput
+      IF( Agrif_Nbstepint() == 0) CALL iom_swap
+# endif   
+#endif   
+      indic = 1                                       ! reset to no error condition
+
+      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
+
+      CALL iom_setkt( kstp )                          ! say to iom that we are at time step kstp
+      
+      CALL rst_opn( kstp )                            ! Open the restart file
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update data, open boundaries, surface boundary condition (including sea-ice)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
+      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
+                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
+      IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
+      IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
+      IF( lk_bdy     )   CALL bdy_dta( kstp )         ! update dynamic and tracer data at unstructured open boundary
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      !  Ocean dynamics : ssh, wn, hdiv, rot                                 !
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL ssh_wzv( kstp )         ! after ssh & vertical velocity
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Ocean physics update                (ua, va, ta, sa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL bn2( tb, sb, rn2b )     ! before Brunt-Vaisala frequency
+                         CALL bn2( tn, sn, rn2  )     ! now    Brunt-Vaisala frequency
+      !
+      !  VERTICAL PHYSICS   
+                         CALL zdf_bfr( kstp )         ! bottom friction
+      !                                               ! Vertical eddy viscosity and diffusivity coefficients
+      IF( lk_zdfric     )   CALL zdf_ric    ( kstp )  ! Richardson number dependent Kz
+      IF( lk_zdftke_old )   CALL zdf_tke_old( kstp )  ! TKE closure scheme for Kz (old scheme)
+      IF( lk_zdftke     )   CALL zdf_tke    ( kstp )  ! TKE closure scheme for Kz
+      IF( lk_zdfkpp     )   CALL zdf_kpp    ( kstp )  ! KPP closure scheme for Kz
+      IF( lk_zdfcst     )   THEN                      ! Constant Kz (reset avt, avm[uv] to the background value)
+         avt (:,:,:) = rn_avt0 * tmask(:,:,:)
+         avmu(:,:,:) = rn_avm0 * umask(:,:,:)
+         avmv(:,:,:) = rn_avm0 * vmask(:,:,:)
+      ENDIF
+      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
+         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
+      ENDIF
+      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
+
+      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
+
+      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
+         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
+                         CALL zdf_mxl( kstp )         ! mixed layer depth
+
+                                                      ! write tke information in the restart file
+      IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
+      !
+      !  LATERAL  PHYSICS 
+      !
+      IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
+                         CALL eos( tb, sb, rhd )                ! before in situ density
+         IF( ln_zps )    CALL zps_hde( kstp, tb, sb, rhd,  &    ! Partial steps: before horizontal gradient
+            &                              gtu, gsu, gru,  &    ! of t, s, rd at the last ocean level
+            &                              gtv, gsv, grv )
+                         CALL ldf_slp( kstp, rhd, rn2b )        ! before slope of the lateral mixing
+      ENDIF
+#if defined key_traldf_c2d
+      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient
+#  endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! diagnostics and outputs             (ua, va, ta, sa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats
+      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
+      IF( lk_diagap  )   CALL dia_gap( kstp )         ! basin averaged diagnostics
+      IF( lk_diahdy  )   CALL dia_hdy( kstp )         ! dynamical heigh diagnostics
+      IF( lk_diafwb  )   CALL dia_fwb( kstp )         ! Fresh water budget diagnostics
+      IF( ln_diaptr  )   CALL dia_ptr( kstp )         ! Poleward TRansports diagnostics
+      IF( lk_diaar5  )   CALL dia_ar5( kstp )         ! ar5 diag
+                         CALL dia_wri( kstp )         ! ocean model: outputs
+
+#if defined key_top
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Passive Tracer Model
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL trc_stp( kstp )         ! time-stepping
+#endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Active tracers                              (ua, va used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                             ta(:,:,:) = 0.e0               ! set tracer trends to zero
+                             sa(:,:,:) = 0.e0
+
+                             CALL tra_sbc    ( kstp )       ! surface boundary condition
+      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
+      IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
+      IF( lk_trabbl_dif  )   CALL tra_bbl_dif( kstp )       ! diffusive bottom boundary layer scheme
+      IF( lk_trabbl_adv  )   CALL tra_bbl_adv( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
+      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
+                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
+      IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection)
+      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
+                             CALL tra_ldf    ( kstp )       ! lateral mixing
+#if defined key_agrif
+      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
+#endif
+                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields
+
+      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos)
+         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )            ! update after fields by non-penetrative convection
+                             CALL tra_nxt    ( kstp )            ! tracer fields at next time step
+                             CALL eos( ta, sa, rhd, rhop )       ! Time-filtered in situ density for hpg computation
+         IF( ln_zps      )   CALL zps_hde( kstp, ta, sa, rhd,   &   ! Partial steps: time filtered hor. derivative
+            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
+            &                                   gtv, gsv, grv )
+         
+      ELSE                                                  ! centered hpg  (eos then time stepping)
+                             CALL eos( tn, sn, rhd, rhop )       ! now in situ density for hpg computation
+         IF( ln_zps      )   CALL zps_hde( kstp, tn, sn, rhd,   &   ! Partial steps: now horizontal derivative
+            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
+            &                                   gtv, gsv, grv )
+         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )       ! update after fields by non-penetrative convection
+                             CALL tra_nxt    ( kstp )       ! tracer fields at next time step
+      ENDIF 
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Dynamics                                    (ta, sa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                               ua(:,:,:) = 0.e0             ! set dynamics trends to zero
+                               va(:,:,:) = 0.e0
+
+                               CALL dyn_adv( kstp )         ! advection (vector or flux form)
+                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis
+                               CALL dyn_ldf( kstp )         ! lateral mixing
+#if defined key_agrif
+      IF(.NOT. Agrif_Root())   CALL Agrif_Sponge_dyn        ! momemtum sponge
+#endif
+                               CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
+                               CALL dyn_bfr( kstp )           ! bottom friction   
+                               CALL dyn_zdf( kstp )         ! vertical diffusion
+                               indic=0
+                               CALL dyn_spg( kstp, indic )  ! surface pressure gradient
+                               CALL dyn_nxt( kstp )         ! lateral velocity at next time step
+
+                               CALL ssh_nxt( kstp )         ! sea surface height at next time step
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control and restarts
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                               CALL stp_ctl( kstp, indic )
+      IF( indic < 0        )   THEN
+                               CALL ctl_stop( 'step: indic < 0' )
+                               CALL dia_wri_state( 'output.abort', kstp )
+      ENDIF
+      IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file
+      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
+      IF( lk_obc           )   CALL obc_rst_write( kstp )   ! write open boundary restart file
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Trends                              (ua, va, ta, sa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( nstop == 0 ) THEN                         
+         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics 
+         IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
+         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer 
+         IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Coupled mode
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_cpl           )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
+      !
+      !
+   END SUBROUTINE stp
+
+   !!======================================================================
+END MODULE step
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/stpctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/stpctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/stpctl.F90	(revision 1844)
@@ -0,0 +1,176 @@
+MODULE stpctl
+   !!======================================================================
+   !!                       ***  MODULE  stpctl  ***
+   !! Ocean run control :  gross check of the ocean time stepping
+   !!======================================================================
+   !! History :  OPA  ! 1991-03  (G. Madec) Original code
+   !!            6.0  ! 1992-06  (M. Imbard)
+   !!            8.0  ! 1997-06  (A.M. Treguier)
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            2.0  ! 2009-07  (G. Madec)  Add statistic for time-spliting
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp_ctl      : Control the run
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE sol_oce         ! ocean space and time domain variables 
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   USE dynspg_oce      ! pressure gradient schemes 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC stp_ctl           ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE stp_ctl( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE stp_ctl  ***
+      !!                     
+      !! ** Purpose :   Control the run
+      !!
+      !! ** Method  : - Save the time step in numstp
+      !!              - Print it each 50 time steps
+      !!              - Print solver statistics in numsol 
+      !!              - Stop the run IF problem for the solver ( indec < 0 )
+      !!
+      !! ** Actions :   'time.step' file containing the last ocean time-step
+      !!                
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
+      INTEGER, INTENT( inout ) ::   kindic  ! indicator of solver convergence
+      !!
+      INTEGER  ::   ji, jj, jk              ! dummy loop indices
+      INTEGER  ::   ii, ij, ik              ! temporary integers
+      REAL(wp) ::   zumax, zsmin, zssh2     ! temporary scalars
+      INTEGER, DIMENSION(3) ::   ilocu      ! 
+      INTEGER, DIMENSION(2) ::   ilocs      ! 
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'stp_ctl : time-stepping control'
+         WRITE(numout,*) '~~~~~~~'
+         ! open time.step file
+         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+
+      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
+      IF(lwp) REWIND( numstp )                       !  --------------------------
+
+      !                                              !* Test maximum of velocity (zonal only)
+      !                                              !  ------------------------
+      !! zumax = MAXVAL( ABS( un(:,:,:) ) )                ! slower than the following loop on NEC SX5
+      zumax = 0.e0
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zumax = MAX(zumax,ABS(un(ji,jj,jk)))
+          END DO 
+        END DO 
+      END DO        
+      IF( lk_mpp )   CALL mpp_max( zumax )                 ! max over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax
+      !
+      IF( zumax > 20.e0 ) THEN
+         IF( lk_mpp ) THEN
+            CALL mpp_maxloc(ABS(un),umask,zumax,ii,ij,ik)
+         ELSE
+            ilocu = MAXLOC( ABS( un(:,:,:) ) )
+            ii = ilocu(1) + nimpp - 1
+            ij = ilocu(2) + njmpp - 1
+            ik = ilocu(3)
+         ENDIF
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s'
+            WRITE(numout,*) ' ====== '
+            WRITE(numout,9400) kt, zumax, ii, ij, ik
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5)
+
+      !                                              !* Test minimum of salinity
+      !                                              !  ------------------------
+      !! zsmin = MINVAL( sn(:,:,1), mask = tmask(:,:,1) == 1.e0 )  slower than the following loop on NEC SX5
+      zsmin = 100.e0
+      DO jj = 2, jpjm1
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,sn(ji,jj,1))
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_min( zsmin )                ! min over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin
+      !
+      IF( zsmin < 0.) THEN 
+         IF (lk_mpp) THEN
+            CALL mpp_minloc ( sn(:,:,1),tmask(:,:,1), zsmin, ii,ij )
+         ELSE
+            ilocs = MINLOC( sn(:,:,1), mask = tmask(:,:,1) == 1.e0 )
+            ii = ilocs(1) + nimpp - 1
+            ij = ilocs(2) + njmpp - 1
+         ENDIF
+         !
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
+            WRITE(numout,*) '======= '
+            WRITE(numout,9500) kt, zsmin, ii, ij
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
+
+      ! log file (solver or ssh statistics)
+      ! --------
+      IF( lk_dynspg_flt ) THEN      ! elliptic solver statistics (if required)
+         !
+         IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps       ! Solver
+         !
+         IF( kindic < 0 .AND. zsmin > 0.e0 .AND. zumax <= 20.e0 ) THEN   ! create a abort file if problem found 
+            IF(lwp) THEN
+               WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode'
+               WRITE(numout,*) ' ====== '
+               WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps
+               WRITE(numout,*)
+               WRITE(numout,*) ' stpctl: output of last fields'
+               WRITE(numout,*) ' ======  '
+            ENDIF
+         ENDIF
+         !
+      ELSE                                   !* ssh statistics (and others...)
+         IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
+            CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         ENDIF
+         !
+         zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) )
+         IF( lk_mpp )   CALL mpp_sum( zssh2 )      ! sum over the global domain
+         !
+         IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin      ! ssh statistics
+         !
+      ENDIF
+
+9200  FORMAT('it:', i8, ' iter:', i4, ' r: ',e16.10, ' b: ',e16.10 )
+9300  FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10)
+      !
+   END SUBROUTINE stp_ctl
+
+   !!======================================================================
+END MODULE stpctl
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/trc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/trc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/trc_oce.F90	(revision 1844)
@@ -0,0 +1,227 @@
+MODULE trc_oce
+   !!======================================================================
+   !!                      ***  MODULE  trc_oce  ***
+   !! Ocean passive tracer  :  share SMS/Ocean variables
+   !!======================================================================
+   !! History :  1.0  !  2004-03  (C. Ethe)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   trc_oce_rgb : tabulated attenuation coefficients for RGB light penetration         
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE in_out_manager  ! I/O manager
+   USE dom_oce         ! ocean space and time domain
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_oce_rgb        ! routine called by traqsr.F90
+   PUBLIC   trc_oce_rgb_read   ! routine called by traqsr.F90
+   PUBLIC   trc_oce_ext_lev    ! function called by traqsr.F90 at least
+   
+   REAL(wp), PUBLIC , DIMENSION(jpi,jpj,jpk) ::   etot3   !: light absortion coefficient
+
+#if defined key_top && defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_top'   &   'key_pisces'                       PISCES bio-model          
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qsr_bio = .TRUE.   !: bio-model light absorption flag
+#else
+   !!----------------------------------------------------------------------
+   !! Default option                          No bio-model light absorption      
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qsr_bio = .FALSE.   !: bio-model light absorption flag
+#endif
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_oce_rgb( prgb )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_opt_init  ***
+      !!
+      !! ** Purpose :   Initialization of of the optical scheme
+      !!
+      !! ** Method  :   Set a look up table for the optical coefficients
+      !!                i.e. the attenuation coefficient for R-G-B light 
+      !!                tabulated in Chlorophyll class (from JM Andre)
+      !!
+      !! ** Action  :   prgb(3,61) tabulated R-G-B attenuation coef. 
+      !!
+      !! Reference  : Lengaigne et al. 2007, Clim. Dyn., V28, 5, 503-516.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(3,61), INTENT(out) ::   prgb   ! tabulated attenuation coefficient
+      !!
+      INTEGER  ::   jc     ! dummy loop indice
+      INTEGER  ::   irgb   ! temporary integer
+      REAL(wp) ::   zchl   ! temporary scalar
+      REAL(wp), DIMENSION(4,61) ::   zrgb   ! tabulated attenuation coefficient (formerly read in 'kRGB61.txt')
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_oce_rgb : Initialisation of the optical look-up table'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+      !
+      !  Chlorophyll        !     Blue attenuation     !     Green attenuation    !     Red attenuation      !
+      zrgb(1, 1) =  0.010   ;   zrgb(2, 1) = 0.01618   ;   zrgb(3, 1) = 0.07464   ;   zrgb(4, 1) = 0.37807
+      zrgb(1, 2) =  0.011   ;   zrgb(2, 2) = 0.01654   ;   zrgb(3, 2) = 0.07480   ;   zrgb(4, 2) = 0.37823
+      zrgb(1, 3) =  0.013   ;   zrgb(2, 3) = 0.01693   ;   zrgb(3, 3) = 0.07499   ;   zrgb(4, 3) = 0.37840
+      zrgb(1, 4) =  0.014   ;   zrgb(2, 4) = 0.01736   ;   zrgb(3, 4) = 0.07518   ;   zrgb(4, 4) = 0.37859
+      zrgb(1, 5) =  0.016   ;   zrgb(2, 5) = 0.01782   ;   zrgb(3, 5) = 0.07539   ;   zrgb(4, 5) = 0.37879
+      zrgb(1, 6) =  0.018   ;   zrgb(2, 6) = 0.01831   ;   zrgb(3, 6) = 0.07562   ;   zrgb(4, 6) = 0.37900
+      zrgb(1, 7) =  0.020   ;   zrgb(2, 7) = 0.01885   ;   zrgb(3, 7) = 0.07586   ;   zrgb(4, 7) = 0.37923
+      zrgb(1, 8) =  0.022   ;   zrgb(2, 8) = 0.01943   ;   zrgb(3, 8) = 0.07613   ;   zrgb(4, 8) = 0.37948
+      zrgb(1, 9) =  0.025   ;   zrgb(2, 9) = 0.02005   ;   zrgb(3, 9) = 0.07641   ;   zrgb(4, 9) = 0.37976
+      zrgb(1,10) =  0.028   ;   zrgb(2,10) = 0.02073   ;   zrgb(3,10) = 0.07672   ;   zrgb(4,10) = 0.38005
+      zrgb(1,11) =  0.032   ;   zrgb(2,11) = 0.02146   ;   zrgb(3,11) = 0.07705   ;   zrgb(4,11) = 0.38036
+      zrgb(1,12) =  0.035   ;   zrgb(2,12) = 0.02224   ;   zrgb(3,12) = 0.07741   ;   zrgb(4,12) = 0.38070
+      zrgb(1,13) =  0.040   ;   zrgb(2,13) = 0.02310   ;   zrgb(3,13) = 0.07780   ;   zrgb(4,13) = 0.38107
+      zrgb(1,14) =  0.045   ;   zrgb(2,14) = 0.02402   ;   zrgb(3,14) = 0.07821   ;   zrgb(4,14) = 0.38146
+      zrgb(1,15) =  0.050   ;   zrgb(2,15) = 0.02501   ;   zrgb(3,15) = 0.07866   ;   zrgb(4,15) = 0.38189
+      zrgb(1,16) =  0.056   ;   zrgb(2,16) = 0.02608   ;   zrgb(3,16) = 0.07914   ;   zrgb(4,16) = 0.38235
+      zrgb(1,17) =  0.063   ;   zrgb(2,17) = 0.02724   ;   zrgb(3,17) = 0.07967   ;   zrgb(4,17) = 0.38285
+      zrgb(1,18) =  0.071   ;   zrgb(2,18) = 0.02849   ;   zrgb(3,18) = 0.08023   ;   zrgb(4,18) = 0.38338
+      zrgb(1,19) =  0.079   ;   zrgb(2,19) = 0.02984   ;   zrgb(3,19) = 0.08083   ;   zrgb(4,19) = 0.38396
+      zrgb(1,20) =  0.089   ;   zrgb(2,20) = 0.03131   ;   zrgb(3,20) = 0.08149   ;   zrgb(4,20) = 0.38458
+      zrgb(1,21) =  0.100   ;   zrgb(2,21) = 0.03288   ;   zrgb(3,21) = 0.08219   ;   zrgb(4,21) = 0.38526
+      zrgb(1,22) =  0.112   ;   zrgb(2,22) = 0.03459   ;   zrgb(3,22) = 0.08295   ;   zrgb(4,22) = 0.38598
+      zrgb(1,23) =  0.126   ;   zrgb(2,23) = 0.03643   ;   zrgb(3,23) = 0.08377   ;   zrgb(4,23) = 0.38676
+      zrgb(1,24) =  0.141   ;   zrgb(2,24) = 0.03842   ;   zrgb(3,24) = 0.08466   ;   zrgb(4,24) = 0.38761
+      zrgb(1,25) =  0.158   ;   zrgb(2,25) = 0.04057   ;   zrgb(3,25) = 0.08561   ;   zrgb(4,25) = 0.38852
+      zrgb(1,26) =  0.178   ;   zrgb(2,26) = 0.04289   ;   zrgb(3,26) = 0.08664   ;   zrgb(4,26) = 0.38950
+      zrgb(1,27) =  0.200   ;   zrgb(2,27) = 0.04540   ;   zrgb(3,27) = 0.08775   ;   zrgb(4,27) = 0.39056
+      zrgb(1,28) =  0.224   ;   zrgb(2,28) = 0.04811   ;   zrgb(3,28) = 0.08894   ;   zrgb(4,28) = 0.39171
+      zrgb(1,29) =  0.251   ;   zrgb(2,29) = 0.05103   ;   zrgb(3,29) = 0.09023   ;   zrgb(4,29) = 0.39294
+      zrgb(1,30) =  0.282   ;   zrgb(2,30) = 0.05420   ;   zrgb(3,30) = 0.09162   ;   zrgb(4,30) = 0.39428
+      zrgb(1,31) =  0.316   ;   zrgb(2,31) = 0.05761   ;   zrgb(3,31) = 0.09312   ;   zrgb(4,31) = 0.39572
+      zrgb(1,32) =  0.355   ;   zrgb(2,32) = 0.06130   ;   zrgb(3,32) = 0.09474   ;   zrgb(4,32) = 0.39727
+      zrgb(1,33) =  0.398   ;   zrgb(2,33) = 0.06529   ;   zrgb(3,33) = 0.09649   ;   zrgb(4,33) = 0.39894
+      zrgb(1,34) =  0.447   ;   zrgb(2,34) = 0.06959   ;   zrgb(3,34) = 0.09837   ;   zrgb(4,34) = 0.40075
+      zrgb(1,35) =  0.501   ;   zrgb(2,35) = 0.07424   ;   zrgb(3,35) = 0.10040   ;   zrgb(4,35) = 0.40270
+      zrgb(1,36) =  0.562   ;   zrgb(2,36) = 0.07927   ;   zrgb(3,36) = 0.10259   ;   zrgb(4,36) = 0.40480
+      zrgb(1,37) =  0.631   ;   zrgb(2,37) = 0.08470   ;   zrgb(3,37) = 0.10495   ;   zrgb(4,37) = 0.40707
+      zrgb(1,38) =  0.708   ;   zrgb(2,38) = 0.09056   ;   zrgb(3,38) = 0.10749   ;   zrgb(4,38) = 0.40952
+      zrgb(1,39) =  0.794   ;   zrgb(2,39) = 0.09690   ;   zrgb(3,39) = 0.11024   ;   zrgb(4,39) = 0.41216
+      zrgb(1,40) =  0.891   ;   zrgb(2,40) = 0.10374   ;   zrgb(3,40) = 0.11320   ;   zrgb(4,40) = 0.41502
+      zrgb(1,41) =  1.000   ;   zrgb(2,41) = 0.11114   ;   zrgb(3,41) = 0.11639   ;   zrgb(4,41) = 0.41809
+      zrgb(1,42) =  1.122   ;   zrgb(2,42) = 0.11912   ;   zrgb(3,42) = 0.11984   ;   zrgb(4,42) = 0.42142
+      zrgb(1,43) =  1.259   ;   zrgb(2,43) = 0.12775   ;   zrgb(3,43) = 0.12356   ;   zrgb(4,43) = 0.42500
+      zrgb(1,44) =  1.413   ;   zrgb(2,44) = 0.13707   ;   zrgb(3,44) = 0.12757   ;   zrgb(4,44) = 0.42887
+      zrgb(1,45) =  1.585   ;   zrgb(2,45) = 0.14715   ;   zrgb(3,45) = 0.13189   ;   zrgb(4,45) = 0.43304
+      zrgb(1,46) =  1.778   ;   zrgb(2,46) = 0.15803   ;   zrgb(3,46) = 0.13655   ;   zrgb(4,46) = 0.43754
+      zrgb(1,47) =  1.995   ;   zrgb(2,47) = 0.16978   ;   zrgb(3,47) = 0.14158   ;   zrgb(4,47) = 0.44240
+      zrgb(1,48) =  2.239   ;   zrgb(2,48) = 0.18248   ;   zrgb(3,48) = 0.14701   ;   zrgb(4,48) = 0.44765
+      zrgb(1,49) =  2.512   ;   zrgb(2,49) = 0.19620   ;   zrgb(3,49) = 0.15286   ;   zrgb(4,49) = 0.45331
+      zrgb(1,50) =  2.818   ;   zrgb(2,50) = 0.21102   ;   zrgb(3,50) = 0.15918   ;   zrgb(4,50) = 0.45942
+      zrgb(1,51) =  3.162   ;   zrgb(2,51) = 0.22703   ;   zrgb(3,51) = 0.16599   ;   zrgb(4,51) = 0.46601
+      zrgb(1,52) =  3.548   ;   zrgb(2,52) = 0.24433   ;   zrgb(3,52) = 0.17334   ;   zrgb(4,52) = 0.47313
+      zrgb(1,53) =  3.981   ;   zrgb(2,53) = 0.26301   ;   zrgb(3,53) = 0.18126   ;   zrgb(4,53) = 0.48080
+      zrgb(1,54) =  4.467   ;   zrgb(2,54) = 0.28320   ;   zrgb(3,54) = 0.18981   ;   zrgb(4,54) = 0.48909
+      zrgb(1,55) =  5.012   ;   zrgb(2,55) = 0.30502   ;   zrgb(3,55) = 0.19903   ;   zrgb(4,55) = 0.49803
+      zrgb(1,56) =  5.623   ;   zrgb(2,56) = 0.32858   ;   zrgb(3,56) = 0.20898   ;   zrgb(4,56) = 0.50768
+      zrgb(1,57) =  6.310   ;   zrgb(2,57) = 0.35404   ;   zrgb(3,57) = 0.21971   ;   zrgb(4,57) = 0.51810
+      zrgb(1,58) =  7.079   ;   zrgb(2,58) = 0.38154   ;   zrgb(3,58) = 0.23129   ;   zrgb(4,58) = 0.52934
+      zrgb(1,59) =  7.943   ;   zrgb(2,59) = 0.41125   ;   zrgb(3,59) = 0.24378   ;   zrgb(4,59) = 0.54147
+      zrgb(1,60) =  8.912   ;   zrgb(2,60) = 0.44336   ;   zrgb(3,60) = 0.25725   ;   zrgb(4,60) = 0.55457
+      zrgb(1,61) = 10.000   ;   zrgb(2,61) = 0.47804   ;   zrgb(3,61) = 0.27178   ;   zrgb(4,61) = 0.56870
+      !
+      prgb(:,:) = zrgb(2:4,:)
+      !
+      DO jc = 1, 61                         ! check
+         zchl = zrgb(1,jc)
+         irgb = NINT( 41 + 20.* LOG10( zchl ) + 1.e-15 )
+         IF(lwp) WRITE(numout,*) '    jc =', jc, '  Chl = ', zchl, '  irgb = ', irgb
+         IF( irgb /= jc ) THEN
+            IF(lwp) WRITE(numout,*) '    jc =', jc, '  Chl = ', zchl, '  Chl class = ', irgb
+            CALL ctl_stop( 'trc_oce_rgb : inconsistency in Chl tabulated attenuation coeff.' )
+         ENDIF
+      END DO
+      !
+   END SUBROUTINE trc_oce_rgb
+
+
+   SUBROUTINE trc_oce_rgb_read( prgb )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_opt_init  ***
+      !!
+      !! ** Purpose :   Initialization of of the optical scheme
+      !!
+      !! ** Method  :   read the look up table for the optical coefficients
+      !!
+      !! ** input   :   xkrgb(61) precomputed array corresponding to the  
+      !!                          attenuation coefficient (from JM Andre)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(3,61), INTENT(out) ::   prgb   ! tabulated attenuation coefficient
+      !!
+      INTEGER  ::   jchl, jband   ! dummy loop indices
+      INTEGER  ::   numlight
+      REAL(wp) ::   zchl
+      !!----------------------------------------------------------------------
+      !
+      CALL ctl_opn( numlight, 'kRGB61.txt', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+      DO jchl = 1, 61
+         READ(numlight,*) zchl, ( prgb(jband,jchl), jband=1,3 )
+      END DO
+      CLOSE( numlight )
+      !
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' trc_oce_rgb_read : optical look-up table read in kRGB61.txt file'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
+      ENDIF
+      !
+   END SUBROUTINE trc_oce_rgb_read
+
+
+   FUNCTION trc_oce_ext_lev( prldex, pqsr_frc ) RESULT( pjl )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE trc_oce_ext_lev  ***
+      !!       
+      !! ** Purpose :   compute max. level for light penetration
+      !!          
+      !! ** Method  :   the function provides the level at which irradiance 
+      !!                becomes negligible (i.e. = 1.e-15 W/m2) for 3 or 2 bands light
+      !!                penetration: I(z) = pqsr_frc * EXP(hext/prldex) = 1.e-15 W/m2
+      !!                # prldex is the longest depth of extinction:
+      !!                   - prldex = 23 m (2 bands case)
+      !!                   - prldex = 62 m (3 bands case: blue waveband & 0.01 mg/m2 for the chlorophyll)
+      !!                # pqsr_frc is the fraction of solar radiation which penetrates,
+      !!                considering Qsr=240 W/m2 and rn_abs = 0.58:
+      !!                   - pqsr_frc = Qsr * (1-rn_abs)   = 1.00e2 W/m2 (2 bands case)
+      !!                   - pqsr_frc = Qsr * (1-rn_abs)/3 = 0.33e2 W/m2 (3 bands case & equi-partition)
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in) ::   prldex    ! longest depth of extinction
+      REAL(wp), INTENT(in) ::   pqsr_frc  ! frac. solar radiation which penetrates 
+      !!
+      INTEGER  ::   jk, pjl            ! levels
+      REAL(wp) ::   zhext              ! deepest level till which light penetrates
+      REAL(wp) ::   zprec = 15._wp     ! precision to reach -LOG10(1.e-15)
+      REAL(wp) ::   zem                ! temporary scalar 
+      !!----------------------------------------------------------------------
+      !
+      ! It is not necessary to compute anything bellow the following depth
+      zhext = prldex * ( LOG(10.e0) * zprec + LOG(pqsr_frc) )
+     
+      ! Level of light extinction
+      pjl = jpkm1
+      DO jk = jpkm1, 1, -1
+         zem = MAXVAL( fsdepw(:,:,jk+1) * tmask(:,:,jk) )
+         IF( zem >= zhext )   pjl = jk                       ! last T-level reached by Qsr
+      END DO
+      !
+   END FUNCTION trc_oce_ext_lev
+
+
+   !!======================================================================
+END MODULE trc_oce
Index: /branches/DEV_r1837_MLF/NEMO/OPA_SRC/vectopt_loop_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/OPA_SRC/vectopt_loop_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/OPA_SRC/vectopt_loop_substitute.h90	(revision 1844)
@@ -0,0 +1,18 @@
+   !!----------------------------------------------------------------------
+   !!                   ***  vectopt_loop_substitute  ***
+   !!----------------------------------------------------------------------
+   !! ** purpose :   substitute the inner loop starting and inding indices 
+   !!      to allow unrolling of do-loop using CPP macro.
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+#if defined key_vectopt_loop
+#  define fs_2     1
+#  define fs_jpim1 jpi
+#else
+#  define fs_2     2
+#  define fs_jpim1 jpim1
+#endif
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/par_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/par_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/par_c14b.F90	(revision 1844)
@@ -0,0 +1,70 @@
+MODULE par_c14b
+   !!======================================================================
+   !!                        ***  par_c14b ***
+   !! TOP :   set the C14 bomb parameters
+   !!======================================================================
+   !! History :   2.0  !  2008-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id: par_cfc.F90 1152 2008-06-26 14:11:13Z rblod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_lobster, ONLY : jp_lobster      !: number of tracers in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_2d   !: number of 2D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_3d   !: number of 3D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_trd  !: number of biological diag in LOBSTER
+
+   USE par_pisces , ONLY : jp_pisces       !: number of tracers in PISCES
+   USE par_pisces , ONLY : jp_pisces_2d    !: number of 2D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_3d    !: number of 3D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_trd   !: number of biological diag in PISCES
+
+   USE par_cfc    , ONLY : jp_cfc          !: number of tracers in CFC
+   USE par_cfc    , ONLY : jp_cfc_2d       !: number of 2D diag in CFC
+   USE par_cfc    , ONLY : jp_cfc_3d       !: number of 3D diag in CFC
+   USE par_cfc    , ONLY : jp_cfc_trd      !: number of biological diag in CFC
+
+
+   IMPLICIT NONE
+   PUBLIC
+
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp      = jp_lobster     + jp_pisces     + jp_cfc     !: cum. number of pass. tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_2d   = jp_lobster_2d  + jp_pisces_2d  + jp_cfc_2d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_3d   = jp_lobster_3d  + jp_pisces_3d  + jp_cfc_3d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_trd  = jp_lobster_trd + jp_pisces_trd + jp_cfc_trd !:
+   
+#if defined key_c14b
+   !!---------------------------------------------------------------------
+   !!   'key_c14b'   :                                   C14 bomb tracer
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_c14b     = .TRUE.      !: C14 bomb flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b     =  1          !: number of passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_2d  =  2          !: additional 2d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_3d  =  1          !: additional 3d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_trd =  0          !: number of sms trends for C14
+   
+   ! assign an index in trc arrays for each CFC prognostic variables
+   INTEGER, PUBLIC, PARAMETER ::   jpc14       = jp_lp + 1   !: C14 bomb 
+#else
+   !!---------------------------------------------------------------------
+   !!   Default     :                                       No C14 tracer
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_c14b     = .FALSE.     !: C14 bomb flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b     =  0          !: No C14 tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_2d  =  0          !: No C14 additional 2d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_3d  =  0          !: No C14 additional 3d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b_trd =  0          !: number of sms trends for C14
+#endif
+
+   ! Starting/ending C14 do-loop indices (N.B. no C14 : jp_c14b0 > jp_c14b1 the do-loop are never done)
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0     = jp_lp + 1                !: First index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1     = jp_lp + jp_c14b          !: Last  index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0_2d  = jp_lp_2d  + 1            !: First index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1_2d  = jp_lp_2d  + jp_c14b_2d   !: Last  index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0_3d  = jp_lp_3d  + 1            !: First index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1_3d  = jp_lp_3d  + jp_c14b_3d   !: Last  index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b0_trd = jp_lp_trd + 1            !: First index of C14 tracer
+   INTEGER, PUBLIC, PARAMETER ::   jp_c14b1_trd = jp_lp_trd + jp_c14b_trd  !: Last  index of C14 tracer
+
+   !!======================================================================
+END MODULE par_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcctl_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcctl_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcctl_c14b.F90	(revision 1844)
@@ -0,0 +1,94 @@
+MODULE trcctl_c14b
+   !!======================================================================
+   !!                         ***  trcctl_c14b.F90  ***
+   !! TOP :                Control of C14 chemical model
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2005-10 (C. Ethe) assign a parameter to name individual tracers
+   !!----------------------------------------------------------------------
+
+#if defined key_c14b
+
+   USE oce_trc
+   USE trc
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl_c14b      ! called by ???
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id: trcctl_cfc.F90 1146 2008-06-25 11:42:56Z rblod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl_c14b
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_c14b  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' C14 bomb Model '
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! Check number of tracers
+      ! -----------------------   
+      IF( jp_c14b > 1) THEN 
+          IF(lwp) THEN 
+              WRITE (numout,*) ' ===>>>> : w a r n i n g '
+              WRITE (numout,*) ' =======   ============= '
+              WRITE (numout,*)                             &
+              &   ' STOP, change jp_c14b to 1 in par_C14b module '  
+          END IF 
+          STOP 'TRC_CTL'
+      END IF 
+
+      ! Check tracer names
+      ! ------------------
+      IF ( ctrcnm(jpc14) /= 'C14B' ) THEN 
+           ctrcnm(jpc14)  = 'C14B'
+           ctrcnl(jpc14)  = 'Bomb C14 concentration'
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE (numout,*) ' ===>>>> : w a r n i n g '
+         WRITE (numout,*) ' =======   ============= '
+         WRITE (numout,*) ' we force tracer names'
+         WRITE(numout,*) ' tracer nb: ',jpc14,' name = ',ctrcnm(jpc14), ctrcnl(jpc14)
+         WRITE(numout,*) ' '
+      ENDIF 
+
+
+      ! Check tracer units
+      ! ------------------
+      IF( ctrcun(jpc14) /= 'ration' ) THEN
+          ctrcun(jpc14) = 'ration'
+          IF(lwp) THEN
+             WRITE (numout,*) ' ===>>>> : w a r n i n g '
+             WRITE (numout,*) ' =======   ============= '
+             WRITE (numout,*) ' we force tracer unit'
+             WRITE(numout,*) ' tracer  ',ctrcnm(jpc14), 'UNIT= ',ctrcun(jpc14)
+             WRITE(numout,*) ' '
+          ENDIF 
+       ENDIF 
+      !
+   END SUBROUTINE trc_ctl_c14b
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                         No Bomb c14
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl_c14b                      ! Dummy routine
+   END SUBROUTINE trc_ctl_c14b
+#endif
+
+   !!======================================================================
+END MODULE trcctl_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcini_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcini_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcini_c14b.F90	(revision 1844)
@@ -0,0 +1,174 @@
+MODULE trcini_c14b
+   !!======================================================================
+   !!                         ***  MODULE trcini_c14b  ***
+   !! TOP :   initialisation of the C14 bomb tracer
+   !!======================================================================
+   !! History : Original ! 2005-10  (Z. Lachkar) 
+   !!               2.0  ! 2007-12  (C. Ethe ) 
+   !!----------------------------------------------------------------------
+#if defined key_c14b
+   !!----------------------------------------------------------------------
+   !!   'key_c14b'                                          C14 bomb tracer
+   !!----------------------------------------------------------------------
+   !! trc_ini_c14b      : C14 model initialisation
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_c14b     ! C14 sms trends
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_ini_c14b   ! called by trcini.F90 module
+
+   INTEGER  ::   &     ! With respect to data file !!
+     jpybeg = 1765 , & !: starting year for C14
+     jpyend = 2002     !: ending year for C14
+
+   INTEGER  ::   &   
+      nrec   ,  & ! number of year in CO2 Concentrations file
+      nmaxrec 
+
+   INTEGER  ::   inum1, inum2               ! unit number
+
+   REAL(wp) ::     &
+     ys40 = -40. ,    &             ! 40 degrees south
+     ys20 = -20. ,    &             ! 20 degrees south
+     yn20 =  20. ,    &             ! 20 degrees north
+     yn40 =  40.                    ! 40 degrees north
+
+   !!---------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id: trcini_cfc.F90 1146 2008-06-25 11:42:56Z rblod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ini_c14b
+      !!-------------------------------------------------------------------
+      !!                     ***  trc_ini_c14b  ***  
+      !!
+      !! ** Purpose :   initialization for C14 model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jl, jm
+      REAL(wp) ::   zyear
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_cfc: initialisation of CFC chemical model'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
+
+
+      ! Initialization of boundaries conditions
+      ! --------------------------------------- 
+      qtr_c14(:,:) = 0.e0
+      
+      ! Initialization of qint in case of  no restart 
+      !----------------------------------------------
+      IF( .NOT. ln_rsttr ) THEN    
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'Initialization de qint ; No restart : qint equal zero '
+         ENDIF
+         trn     (:,:,:,jpc14) = 0.e0
+         qint_c14(:,:        ) = 0.e0
+      ENDIF
+
+
+      ! Read CO2 atmospheric concentrations file...
+      ! read CO2 data from year jpybeg to year jpyend
+      !------------------------------------------------
+
+      nrec    = ( jpyend - jpybeg + 1 )     ! number of year in CO2 Concentrations file
+      nmaxrec = 2 * nrec
+
+      IF(lwp) WRITE(numout,*) 'Read CO2 atmospheric concentrations file '
+  
+      CALL ctl_opn( inum1, 'splco2.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+      REWIND(inum1)
+      
+      DO jm = 1, 5        ! Skip over 1st six descriptor lines
+         READ(inum1,'(1x)')
+      END DO
+
+      ! get  CO2 data
+      DO jm = 1, nmaxrec
+         READ(inum1, *)  zyear, spco2(jm)
+         IF (lwp) WRITE(numout, '(f7.1,f9.4)')  zyear, spco2(jm)
+      END DO
+      WRITE(numout,*)
+      CLOSE(inum1)
+
+      IF (lwp) WRITE(numout,*) 'Read C-14 atmospheric concentrations file '
+
+      CALL ctl_opn( inum2, 'atmc14.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+      REWIND(inum2)
+
+      ! Skip over 1st descriptor line
+      READ(inum2, '(1x)')
+
+      ! READ FILE
+      DO jm = 1, nrec
+         READ(inum2,*) zyear, bomb(jm,1), bomb(jm,2), bomb(jm,3)
+         IF (lwp) WRITE(numout, '(f7.1, 3f9.4)') zyear, bomb(jm,1), bomb(jm,2), bomb(jm,3)
+      END DO
+      CLOSE(inum2)
+
+      ! Conversion unit : Now atm units are in real C-14 [per mil]
+      ! C-14(Orr) = C-14(per mil)/10.0
+       DO jm = 1, nrec
+         bomb(jm,1) = ( bomb(jm,1 ) + 17.40 ) * 0.1
+         bomb(jm,2) = ( bomb(jm,2 ) + 10.40 ) * 0.1
+         bomb(jm,3) = ( bomb(jm,3 ) + 14.65 ) * 0.1
+       END DO
+
+       ! Linear  interpolation of the C-14 source fonction
+       ! in linear latitude band  (20N,40N) and (20S,40S)
+       !------------------------------------------------------
+       DO jj = 1 , jpj
+          DO ji = 1 , jpi
+            IF( gphit(ji,jj) >= yn40 ) THEN
+                 fareaz(ji,jj,1) = 0.
+                 fareaz(ji,jj,2) = 0.
+                 fareaz(ji,jj,3) = 1.
+            ELSE IF( gphit(ji,jj ) <= ys40) THEN
+                 fareaz(ji,jj,1) = 1.
+                 fareaz(ji,jj,2) = 0.
+                 fareaz(ji,jj,3) = 0.
+            ELSE IF( gphit(ji,jj) >= yn20 ) THEN
+                 fareaz(ji,jj,1) = 0.
+                 fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / yn40 )
+                 fareaz(ji,jj,3) = 2. * gphit(ji,jj) / yn40 - 1.
+            ELSE IF( gphit(ji,jj) <= ys20 ) THEN
+                 fareaz(ji,jj,1) = 2. * gphit(ji,jj) / ys40 - 1.
+                 fareaz(ji,jj,2) = 2. * ( 1. - gphit(ji,jj) / ys40 )
+                 fareaz(ji,jj,3) = 0.
+            ELSE
+                 fareaz(ji,jj,1) = 0.
+                 fareaz(ji,jj,2) = 1.
+                 fareaz(ji,jj,3) = 0.
+            ENDIF
+          END DO
+        END DO
+
+      !
+      IF(lwp) WRITE(numout,*) 'Initialization of C14 bomb tracer done'
+      IF(lwp) WRITE(numout,*) ' '
+
+   END SUBROUTINE trc_ini_c14b
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                    No C14 bomb tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini_c14b             ! Empty routine
+   END SUBROUTINE trc_ini_c14b
+#endif
+
+   !!======================================================================
+END MODULE trcini_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trclsm_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trclsm_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trclsm_c14b.F90	(revision 1844)
@@ -0,0 +1,157 @@
+MODULE trclsm_c14b
+   !!======================================================================
+   !!                         ***  MODULE trclsm_c14b  ***
+   !! TOP :   initialisation of some run parameters for C14 chemical model
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trclsm.cfc.h90
+   !!----------------------------------------------------------------------
+#if defined key_c14b
+   !!----------------------------------------------------------------------
+   !!   'key_c14b'                                         C14 bomb tracer
+   !!----------------------------------------------------------------------
+   !! trc_lsm_c14b      : C14 model initialisation
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_c14b     ! C14b specific variable
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_lsm_c14b   ! called by trclsm.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id: trclsm_cfc.F90 1146 2008-06-25 11:42:56Z rblod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lsm_c14b
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_lsm_c14b  ***
+      !!                 
+      !! ** Purpose :   Definition some run parameter for C14 model
+      !!
+      !! ** Method  :   Read the namc14 namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namelist_c14b
+      !!----------------------------------------------------------------------
+      INTEGER ::   numnatb
+
+#if defined key_trc_diaadd && ! defined key_iomput
+      ! definition of additional diagnostic as a structure
+      INTEGER ::   jl, jn
+      TYPE DIAG
+         CHARACTER(len = 20)  :: snamedia   !: short name
+         CHARACTER(len = 80 ) :: lnamedia   !: long name
+         CHARACTER(len = 20 ) :: unitdia    !: unit
+      END TYPE DIAG
+
+      TYPE(DIAG) , DIMENSION(jp_c14b_2d) :: c14dia2d
+      TYPE(DIAG) , DIMENSION(jp_c14b_3d) :: c14dia3d
+#endif
+      !!
+      NAMELIST/namc14date/ ndate_beg_b, nyear_res_b
+#if defined key_trc_diaadd && ! defined key_iomput
+      NAMELIST/namc14dia/nwritedia, c14dia2d, c14dia3d     ! additional diagnostics
+#endif
+      !!-------------------------------------------------------------------
+
+      ndate_beg_b = 650101            ! default namelist value
+      nyear_res_b = 1955
+
+      !                             ! Open namelist file
+      CALL ctl_opn( numnatb, 'namelist_c14b', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+         
+      READ( numnatb , namc14date )     ! read namelist
+
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' trc_lsm: Read namdates, namelist for C14 chemical model'
+         WRITE(numout,*) ' ~~~~~~~'
+         WRITE(numout,*) '    initial calendar date (aammjj) for C14  ndate_beg_b = ', ndate_beg_b
+         WRITE(numout,*) '    restoring time constant (year)          nyear_res_b = ', nyear_res_b
+      ENDIF
+      nyear_beg_b = ndate_beg_b / 10000
+      IF(lwp) WRITE(numout,*) '    initial year (aa)                  nyear_beg_b = ', nyear_beg_b
+      !
+#if defined key_trc_diaadd && ! defined key_iomput
+
+      ! Namelist namc14dia
+      ! -------------------
+      nwritedia = 10                   ! default values
+
+      DO jl = 1, jp_c14b_2d
+         jn = jp_c14b0_2d + jl - 1
+         WRITE(ctrc2d(jn),'("2D_",I1)') jn                      ! short name
+         WRITE(ctrc2l(jn),'("2D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc2u(jn) = ' '                                       ! units
+      END DO
+      !                                 ! 3D output arrays
+      DO jl = 1, jp_c14b_3d
+         jn = jp_c14b0_3d + jl - 1
+         WRITE(ctrc3d(jn),'("3D_",I1)') jn                      ! short name
+         WRITE(ctrc3l(jn),'("3D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc3u(jn) = ' '                                       ! units
+      END DO
+
+      REWIND( numnatb )               ! read natrtd
+      READ  ( numnatb, namc14dia )
+
+      DO jl = 1, jp_c14b_2d
+         jn = jp_c14b0_2d + jl - 1
+         ctrc2d(jn) = c14dia2d(jl)%snamedia
+         ctrc2l(jn) = c14dia2d(jl)%lnamedia
+         ctrc2u(jn) = c14dia2d(jl)%unitdia
+      END DO
+
+      DO jl = 1, jp_c14b_3d
+         jn = jp_c14b0_3d + jl - 1
+         ctrc3d(jn) = c14dia3d(jl)%snamedia
+         ctrc3l(jn) = c14dia3d(jl)%lnamedia
+         ctrc3u(jn) = c14dia3d(jl)%unitdia
+      END DO
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : natadd'
+         WRITE(numout,*) '    frequency of outputs for additional arrays nwritedia = ', nwritedia
+         DO jl = 1, jp_c14b_3d
+            jn = jp_c14b0_3d + jl - 1
+            WRITE(numout,*) '   3d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc3d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc3l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc3u(jn))
+            WRITE(numout,*) ' '
+         END DO
+
+         DO jl = 1, jp_c14b_2d
+            jn = jp_c14b0_2d + jl - 1
+            WRITE(numout,*) '   2d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc2d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc2l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc2u(jn))
+            WRITE(numout,*) ' '
+         END DO
+      ENDIF
+
+#endif
+
+   END SUBROUTINE trc_lsm_c14b
+   
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                                No 14C
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lsm_c14b                      ! Empty routine
+   END  SUBROUTINE  trc_lsm_c14b
+#endif  
+
+   !!======================================================================
+END MODULE trclsm_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcrst_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 1844)
@@ -0,0 +1,91 @@
+MODULE trcrst_c14b
+   !!======================================================================
+   !!                       ***  MODULE trcrst_c14b  ***
+   !! TOP :   create, write, read the restart files of c14b tracer
+   !!======================================================================
+   !! History :   1.0  !  2010-01 (C. Ethe) Original
+   !!----------------------------------------------------------------------
+#if defined key_c14b
+   !!----------------------------------------------------------------------
+   !!   'key_c14b'                                               c14b tracers
+   !!----------------------------------------------------------------------
+   !!   trc_rst_read_c14b   : read  restart file
+   !!   trc_rst_wri_c14b    : write restart file
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_c14b          ! c14b sms trends
+   USE in_out_manager  ! I/O manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  trc_rst_read_c14b   ! called by trcini.F90 module
+   PUBLIC  trc_rst_wri_c14b   ! called by trcini.F90 module
+
+CONTAINS
+   
+   SUBROUTINE trc_rst_read_c14b( knum ) 
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_c14b  ***  
+      !!
+      !! ** Purpose : Read in restart file specific variables from c14b model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: knum  ! unit of the restart file
+      INTEGER              :: jn    ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_read_c14b : Read specific variables from c14b model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+      
+      DO jn = jp_c14b0, jp_c14b1
+         CALL iom_get( knum, jpdom_autoglo, 'qint_'//ctrcnm(jn), qint_c14(:,:,jn) ) 
+      END DO
+
+   END SUBROUTINE trc_rst_read_c14b
+
+   SUBROUTINE trc_rst_wri_c14b( kt, kitrst, knum )
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_c14b  ***
+      !!
+      !! ** Purpose : Read in restart file specific variables from c14b model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: kt      ! time step
+      INTEGER, INTENT(in)  :: kitrst  ! time step of restart write
+      INTEGER, INTENT(in)  :: knum    ! unit of the restart file
+      INTEGER              :: jn      ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_wri_c14b : Write specific variables from c14b model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      DO jn = jp_c14b0, jp_c14b1
+         CALL iom_rstput( kt, kitrst, kum, 'qint_'//ctrcnm(jn), qint_c14(:,:,jn) )
+      END DO
+
+   END SUBROUTINE trc_rst_wri_c14b
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read_c14b( knum )
+     INTEGER, INTENT(in)  :: knum
+     WRITE(*,*) 'trc_rst_wri_c14b: You should not have seen this print! error?', knum
+   END SUBROUTINE trc_rst_read_c14b
+
+   SUBROUTINE trc_rst_wri_c14b( kt, kitrst, knum )
+     INTEGER, INTENT(in)  :: kt, kitrst, knum
+     WRITE(*,*) 'trc_rst_wri_c14b: You should not have seen this print! error?', kt, kitrst, knum
+   END SUBROUTINE trc_rst_wri_c14b
+#endif
+
+   !!======================================================================
+END MODULE trcrst_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcsms_c14b.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 1844)
@@ -0,0 +1,326 @@
+MODULE trcsms_c14b
+   !!======================================================================
+   !!                      ***  MODULE trcsms_c14b  ***
+   !! TOP : Bomb C14 main module
+   !!======================================================================
+   !! History     -   ! 1994-05 ( J. Orr ) origial code
+   !!            1.0  ! 2006-02 ( J.M. Molines )  Free form + modularity
+   !!            2.0  ! 2008-12 ( C. Ethe ) reorganisation
+   !!----------------------------------------------------------------------
+#if defined key_c14b
+   !!----------------------------------------------------------------------
+   !!   'key_c14b'                                         Bomb C14 tracer
+   !!----------------------------------------------------------------------
+   !!   trc_sms_c14b  :  compute and add C14 suface forcing to C14 trends
+   !!----------------------------------------------------------------------
+   USE oce_trc      ! Ocean variables
+   USE par_trc      ! TOP parameters
+   USE trc          ! TOP variables
+   USE trdmld_trc_oce
+   USE trdmld_trc
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC   trc_sms_c14b       ! called in ???    
+
+   !! * Module variables
+   INTEGER , PUBLIC, PARAMETER ::   jpmaxrec  = 240           ! temporal parameter 
+   INTEGER , PUBLIC, PARAMETER ::   jpmaxrec2 = 2 * jpmaxrec  ! 
+   INTEGER , PUBLIC, PARAMETER ::   jpzon     = 3             ! number of zones
+
+   INTEGER , PUBLIC    ::   ndate_beg_b      ! initial calendar date (aammjj) for C14
+   INTEGER , PUBLIC    ::   nyear_beg_b      ! initial year for C14
+   INTEGER , PUBLIC    ::   nyear_res_b      ! restoring time constant (year)
+   INTEGER , PUBLIC    ::   nyear_beg        ! initial year (aa) 
+
+   REAL(wp), PUBLIC, DIMENSION(jpmaxrec,jpzon) ::  bomb   !: C14 atm data (3 zones)
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj ,jpzon) ::  fareaz !: Spatial Interpolation Factors
+   REAL(wp), PUBLIC, DIMENSION(jpmaxrec2)      ::  spco2  !: Atmospheric CO2
+  
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   qtr_c14      !: flux at surface
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)     ::   qint_c14     !: cumulative flux
+
+   REAL(wp) :: xlambda, xdecay, xaccum       ! C14 decay coef.  
+
+   REAL(wp) ::   xconv1 = 1.0          ! conversion from to 
+   REAL(wp) ::   xconv2 = 0.01/3600.   ! conversion from cm/h to m/s: 
+   REAL(wp) ::   xconv3 = 1.0e+3       ! conversion from mol/l/atm to mol/m3/atm
+
+  !! * Substitutions
+#  include "top_substitute.h90"
+
+  !!----------------------------------------------------------------------
+  !!  TOP 1.0 , LOCEAN-IPSL (2005) 
+  !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/SMS/trcc14bomb.F90,v 1.2 2005/11/14 16:42:43 opalod Exp $ 
+  !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+  !!----------------------------------------------------------------------
+
+CONTAINS
+
+  SUBROUTINE trc_sms_c14b( kt )
+     !!----------------------------------------------------------------------
+     !!                  ***  ROUTINE trc_sms_c14b  ***
+     !!
+     !! ** Purpose :   Compute the surface boundary contition on C14bomb
+     !!      passive tracer associated with air-mer fluxes and add it to 
+     !!      the general trend of tracers equations.
+     !!
+     !! ** Original comments from J. Orr :
+     !!
+     !!      Calculates the input of Bomb C-14 to the surface layer of OPA
+     !!
+     !!      James Orr, LMCE, 28 October 1992
+     !!
+     !!      Initial approach mimics that of Toggweiler, Dixon, & Bryan (1989)
+     !!      (hereafter referred to as TDB) with constant gas exchange,
+     !!      although in this case, a perturbation approach is used for
+     !!      bomb-C14 so that both the ocean and atmosphere begin at zero.
+     !!      This saves tremendous amounts of computer time since no
+     !!      equilibrum run is first required (i.e., for natural C-14).
+     !!      Note: Many sensitivity tests can be run with this approach and
+     !!            one never has to make a run for natural C-14; otherwise,
+     !!            a run for natural C-14 must be run each time that one
+     !!            changes a model parameter!
+     !!
+     !!
+     !!      19 August 1993: Modified to consider Atmospheric C-14 fom IPCC.
+     !!      That is, the IPCC has provided a C-14 atmospheric record (courtesy
+     !!      of Martin Heimann) for model calibration.  This model spans from
+     !!      preindustrial times to present, in a format different than that
+     !!      given by TDB.  It must be converted to the ORR C-14 units used
+     !!      here, although in this case, the perturbation includes not only
+     !!      bomb C-14 but changes due to the Suess effect.
+     !!
+     !!----------------------------------------------------------------------
+     !! * Arguments
+     INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
+
+     !! * Local declarations
+     INTEGER ::  &
+       ji, jj, jk, jz
+
+     INTEGER ::   &
+       iyear_beg,              &
+       iyear_beg1, iyear_end1, &
+       imonth1, im1, im2,      &
+       iyear_beg2, iyear_end2, &
+       imonth2, in1, in2
+         
+     REAL(wp), DIMENSION(jpi,jpj) ::  & 
+       zatmbc14
+
+     REAL(wp), DIMENSION(jpzon)   ::  &
+       zonbc14              !: time interp atm C14
+
+     REAL(wp) ::     &
+       zpco2at              !: time interp atm C02
+
+     REAL(wp) ::     &      !: dummy variables
+       zt, ztp, zsk, &
+       zsol ,        &      !: solubility
+       zsch ,        &      !: schmidt number
+       zv2  ,        &      !: wind speed ( square)
+       zpv  ,        &      !: piston velocity 
+       zdemi, ztra
+#if defined key_trc_dia3d  && defined key_iomput
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zw3d
+#endif
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 )  THEN
+         ! Computation of decay coeffcient
+         zdemi   = 5730.
+         xlambda = LOG(2.) / zdemi / ( nyear_len(1) * rday )
+         xdecay  = EXP( - xlambda * rdt )
+         xaccum  = 1.0 -  xdecay
+      ENDIF
+
+      ! Temporal interpolation
+      ! ----------------------
+      iyear_beg = nyear - 1954 + ( nyear_res_b - 1700 - nyear_beg_b  ) ! JMM Very dangerous 
+                                                                       ! nyear=0001 for 1955
+      ! For Atmospheric C14 concentrations:
+      iyear_beg1 = iyear_beg
+      imonth1    = nmonth
+      IF ( imonth1 <= 6 ) THEN
+         iyear_beg1 = iyear_beg1 - 1
+         im1       =  6 - imonth1 + 1
+         im2       =  6 + imonth1 - 1
+      ELSE
+         im1       = 12 - imonth1 + 7
+         im2       =      imonth1 - 7
+      ENDIF
+      iyear_end1 = iyear_beg1 + 1
+
+      iyear_beg1 = MAX( iyear_beg1, 1   )
+      iyear_end1 = MIN( iyear_end1, 241 )
+
+
+      ! For Atmospheric CO2 concentrations:
+      iyear_beg2 = 2 * iyear_beg - 1
+      imonth2    = INT( nmonth / 2. )
+
+      IF ( imonth2 <= 3 ) THEN
+         iyear_beg2 = iyear_beg2 - 1 
+         in1       = 3 - imonth2 + 1
+         in2       = 3 + imonth2 - 1
+      ELSE
+         in1       = 6 - imonth2 + 4
+         in2       =     imonth2 - 4
+      ENDIF
+      
+      iyear_end2 = iyear_beg2 + 1
+      
+      iyear_beg2 = MAX( iyear_beg2, 1   )
+      iyear_end2 = MIN( iyear_end2, 482 )
+
+
+      !  ----------------------------------------------------------------
+      !  As explained by the TDB 89 papers, C-14/C-12 is the same
+      !  as C-14 concentration in this special case (no fractionation
+      !  effects in this model, which thus allow direct comparison
+      !  to del-C-14, after unit change from above).
+      ! -----------------------------------------------------------------------
+      !  Calc C-14 in atmosphere based on interp of IPCC (M. Heimann) data
+      !        - Compare input to calculated C-14 for each time in record
+      !-------------------------------------------------------------------------
+      
+      
+      !  Temporal and spatial interpolation at time k
+      ! --------------------------------------------------
+      
+      ! Compute atmospheric C-14 for each zone (90-20S, 20S-20N, 20-90N)
+      DO jz = 1, jpzon
+         zonbc14(jz) = (  bomb(iyear_beg1,jz) * FLOAT( im1 )  &
+              &         + bomb(iyear_end1,jz) * FLOAT( im2 ) ) / 12.
+         ! C-14 exactly starts at zero :
+         ! JMM +Zouhair : Slightly negative values are set to 0 (when perturbation approaches)
+         zonbc14(jz) = MAX( zonbc14(jz), 0. )
+      END DO
+      
+      
+      !  For each (i,j)-box, with information from the fractional area
+      !  (zonmean), computes area-weighted mean to give the atmospheric C-14
+      !  ----------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zatmbc14(ji,jj) =   zonbc14(1) * fareaz(ji,jj,1)  &
+                 &           +  zonbc14(2) * fareaz(ji,jj,2)  &
+                 &           +  zonbc14(3) * fareaz(ji,jj,3)
+         END DO
+      END DO
+      
+      ! time interpolation of CO2 concentrations to it time step  
+      zpco2at = (  spco2(iyear_beg2) * FLOAT( in1 )              &
+           &     + spco2(iyear_end2) * FLOAT( in2 ) ) / 6.
+
+      IF (lwp) THEN
+          WRITE(numout, *) 'time : ', kt, ' CO2 year begin/end :',iyear_beg2,'/',iyear_end2,   &
+          &                ' CO2 concen : ',zpco2at 
+          WRITE(numout, *) 'time : ', kt, ' C14 year begin/end :',iyear_beg1,'/',iyear_end1,   &
+          &                ' C14B concen (Z1/Z2/Z3) : ',zonbc14(1),'/',zonbc14(2),'/',zonbc14(3)
+      ENDIF
+
+      !  Determine seasonally variable gas exchange coefficient 
+      !----------------------------------------------------------
+      !  Computes the Schmidt number of CO2 in seawater using the formulation
+      !  presented by Wanninkhof (1992, J. Geophys. Res., 97,7373-7382).  
+      ! -------------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi  
+            !  Computation of solubility  
+            IF (tmask(ji,jj,1) >  0.) THEN
+               ztp  = ( tn(ji,jj,1) + 273.16 ) * 0.01
+               zsk  = 0.023517 + ztp * ( -0.023656 + 0.0047036 * ztp )
+               zsol = EXP( -60.2409 + 93.4517 / ztp  + 23.3585 * LOG( ztp ) + zsk * sn(ji,jj,1) )
+               ! convert solubilities [mol/(l * atm)] -> [mol/(m^3 * ppm)]
+               zsol = zsol * 1.0e-03
+            ELSE
+               zsol = 0.
+            ENDIF
+
+            ! speed transfert : Formulation of Wanninkhof (1992, JGR, 97,7373-7382)
+            ! JMM/Zouhair : coef of 0.25 rather than 0.3332 for CORe wind speed
+
+            ! Computes the Schmidt number of CO2 in seawater
+            zt   = tn(ji,jj,1)
+            zsch = 2073.1 + zt * ( -125.62 + zt * (3.6276 - 0.043219 * zt ) )
+
+            ! Wanninkhof Piston velocity and convert from units [cm/hr] -> [m/s]
+            zv2  = wndm(ji,jj) * wndm(ji,jj)
+            zsch = zsch / 660.
+            zpv  = ( 0.25  * zv2 / SQRT(zsch) ) * xconv2 * tmask(ji,jj,1)
+
+            ! Flux of Bomb C-14 from air-sea : speed*(conc. at equil-conc. at surf)
+            ! in C-14 (orr-model-units) / m**2 * s
+            qtr_c14(ji,jj) = -zpv * zsol * zpco2at                                   &
+                 &                       * ( trb(ji,jj,1,jpc14) - zatmbc14(ji,jj) )  &
+#if defined key_off_degrad
+                 &                       * facvol(ji,jj,1)                           &
+#endif
+                  &                      * tmask(ji,jj,1) * ( 1. - fr_i(ji,jj) ) / 2.
+
+            ! Add the surface flux to the trend
+            tra(ji,jj,1,jpc14) = tra(ji,jj,1,jpc14) + qtr_c14(ji,jj) / fse3t(ji,jj,1) 
+            
+            ! cumulation of surface flux at each time step
+            qint_c14(ji,jj) = qint_c14(ji,jj) + qtr_c14(ji,jj) * rdt
+
+# if defined key_trc_diaadd && ! defined key_iomput
+            ! Save 2D diagnostics
+            trc2d(ji,jj,jp_c14b0_2d    ) = qtr_c14 (ji,jj)
+            trc2d(ji,jj,jp_c14b0_2d + 1) = qint_c14(ji,jj)
+# endif 
+         END DO
+      END DO
+
+      ! Computation of decay effects on tracer concentration
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#if ! defined key_off_degrad
+               ztra = trn(ji,jj,jk,jpc14) * xaccum
+#else
+               ztra = trn(ji,jj,jk,jpc14) * ( 1. - EXP( -xlambda * rdt * facvol(ji,jj,jk) ) )
+#endif
+               tra(ji,jj,jk,jpc14) = tra(ji,jj,jk,jpc14) - ztra / rdt
+#if defined key_trc_dia3d
+               ! Save 3D diagnostics
+# if ! defined key_iomput
+               trc3d(ji,jj,jk,jp_c14b0_3d ) = ztra    !  radioactive decay
+# else 
+               zw3d(ji,jj,jk) = ztra    !  radioactive decay
+# endif
+#endif
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd  && defined key_iomput
+      CALL iom_put( "qtrC14b"  , qtr_c14  )
+      CALL iom_put( "qintC14b" , qint_c14 )
+#endif
+#if defined key_trc_dia3d  && defined key_iomput
+      CALL iom_put( "fdecay" , zw3d )
+#endif
+      IF( l_trdtrc ) THEN
+         CALL trd_mod_trc( tra(:,:,:,jpc14), jpc14, jptrc_trd_sms, kt )   ! save trends
+      END IF
+
+    END SUBROUTINE trc_sms_c14b
+
+#else
+    !!----------------------------------------------------------------------
+    !!   Default option                                         Dummy module
+    !!----------------------------------------------------------------------
+CONTAINS
+  SUBROUTINE trc_sms_c14b( kt )       ! Empty routine
+    WRITE(*,*) 'trc_freons: You should not have seen this print! error?', kt
+  END SUBROUTINE trc_sms_c14b
+#endif
+
+  !!======================================================================
+END MODULE trcsms_c14b
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/par_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/par_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/par_cfc.F90	(revision 1844)
@@ -0,0 +1,65 @@
+MODULE par_cfc
+   !!======================================================================
+   !!                        ***  par_cfc  ***
+   !! TOP :   set the CFC parameters
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_lobster, ONLY : jp_lobster      !: number of tracers in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_2d   !: number of 2D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_3d   !: number of 3D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_trd  !: number of biological diag in LOBSTER
+
+   USE par_pisces , ONLY : jp_pisces       !: number of tracers in PISCES
+   USE par_pisces , ONLY : jp_pisces_2d    !: number of 2D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_3d    !: number of 3D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_trd   !: number of biological diag in PISCES
+
+   IMPLICIT NONE
+   PUBLIC
+
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp      = jp_lobster     + jp_pisces     !: cumulative number of passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_2d   = jp_lobster_2d  + jp_pisces_2d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_3d   = jp_lobster_3d  + jp_pisces_3d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lp_trd  = jp_lobster_trd + jp_pisces_trd !:
+   
+#if defined key_cfc
+   !!---------------------------------------------------------------------
+   !!   'key_cfc'   :                                          CFC tracers
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_cfc     = .TRUE.      !: CFC flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc     =  2          !: number of passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_2d  =  2          !: additional 2d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_3d  =  0          !: additional 3d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_trd =  0          !: number of sms trends for CFC
+   
+   ! assign an index in trc arrays for each CFC prognostic variables
+   INTEGER, PUBLIC, PARAMETER ::   jpc11       = jp_lp + 1   !: CFC-11 
+   INTEGER, PUBLIC, PARAMETER ::   jpc12       = jp_lp + 2   !: CFC-12   
+#else
+   !!---------------------------------------------------------------------
+   !!   Default     :                                       No CFC tracers
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_cfc     = .FALSE.     !: CFC flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc     =  0          !: No CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_2d  =  0          !: No CFC additional 2d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_3d  =  0          !: No CFC additional 3d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc_trd =  0          !: number of sms trends for CFC
+#endif
+
+   ! Starting/ending CFC do-loop indices (N.B. no CFC : jp_cfc0 > jp_cfc1 the do-loop are never done)
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc0     = jp_lp + 1       !: First index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc1     = jp_lp + jp_cfc  !: Last  index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc0_2d  = jp_lp_2d  + 1       !: First index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc1_2d  = jp_lp_2d  + jp_cfc_2d  !: Last  index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc0_3d  = jp_lp_3d  + 1       !: First index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc1_3d  = jp_lp_3d  + jp_cfc_3d  !: Last  index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc0_trd = jp_lp_trd + 1       !: First index of CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_cfc1_trd = jp_lp_trd + jp_cfc_trd  !: Last  index of CFC tracers
+
+   !!======================================================================
+END MODULE par_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcctl_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcctl_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcctl_cfc.F90	(revision 1844)
@@ -0,0 +1,100 @@
+MODULE trcctl_cfc
+   !!======================================================================
+   !!                         ***  trcctl.cfc.F90  ***
+   !! TOP :                Control of CFC chemical model
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2005-10 (C. Ethe) assign a parameter to name individual tracers
+   !!----------------------------------------------------------------------
+
+#if defined key_cfc
+
+   USE oce_trc
+   USE trc
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl_cfc      ! called by ???
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl_cfc
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_cfc  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+      INTEGER :: jl, jn
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' CFC Model '
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! Check number of tracers
+      ! -----------------------   
+      IF( jp_cfc > 2) THEN 
+          IF(lwp) THEN 
+              WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
+              WRITE (numout,*)                             &
+              &   ' STOP, change jp_cfc to 1 or 2 in par_CFC module '  
+          END IF 
+          STOP 'TRC_CTL'
+      END IF 
+
+      ! Check tracer names
+      ! ------------------
+      IF ( ctrcnm(jpc11) /= 'CFC11' .OR. ctrcnm(jpc12) /= 'CFC12' ) THEN 
+            ctrcnm(jpc11) = 'CFC11'
+            ctrcnl(jpc11) = 'Chlorofuorocarbone 11 concentration'
+            ctrcnm(jpc12) = 'CFC12'
+            ctrcnl(jpc12) = 'Chlorofuorocarbone 12 concentration' 
+      ENDIF
+
+      IF(lwp) THEN
+         WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
+         WRITE (numout,*) ' we force tracer names'
+         DO jl = 1, jp_cfc
+            jn = jp_cfc0 + jl - 1
+            WRITE(numout,*) ' tracer nb: ',jn,' name = ',ctrcnm(jn), ctrcnl(jn)
+         END DO
+         WRITE(numout,*) ' '
+      ENDIF 
+
+
+      ! Check tracer units
+      ! ------------------
+      DO jl = 1, jp_cfc
+         jn = jp_cfc0 + jl - 1
+        IF( ctrcun(jn) /= 'mole/m3' ) THEN
+            ctrcun(jn) = 'mole/m3'
+            IF(lwp) THEN
+               WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
+               WRITE (numout,*) ' we force tracer unit'
+               WRITE(numout,*) ' tracer  ',ctrcnm(jn), 'UNIT= ',ctrcun(jn)
+               WRITE(numout,*) ' '
+            ENDIF 
+         ENDIF 
+      END DO              
+      !
+   END SUBROUTINE trc_ctl_cfc
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                                No CFC
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl_cfc                      ! Dummy routine
+   END SUBROUTINE trc_ctl_cfc
+#endif
+
+   !!======================================================================
+END MODULE trcctl_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcini_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcini_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcini_cfc.F90	(revision 1844)
@@ -0,0 +1,151 @@
+MODULE trcini_cfc
+   !!======================================================================
+   !!                         ***  MODULE trcini_cfc  ***
+   !! TOP :   initialisation of the CFC tracers
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trcini.cfc.h90
+   !!----------------------------------------------------------------------
+#if defined key_cfc
+   !!----------------------------------------------------------------------
+   !!   'key_cfc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !! trc_ini_cfc      : CFC model initialisation
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_cfc          ! CFC sms trends
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_ini_cfc   ! called by trcini.F90 module
+
+   INTEGER  ::   inum                   ! unit number
+   REAL(wp) ::   ylats = -10.           ! 10 degrees south
+   REAL(wp) ::   ylatn =  10.           ! 10 degrees north
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ini_cfc
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_ini_cfc  ***  
+      !!
+      !! ** Purpose :   initialization for cfc model
+      !!
+      !! ** Method  : - Read the namcfc namelist and check the parameter values
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jn, jl, jm, js
+      REAL(wp) ::   zyy  ,  zyd
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_cfc: initialisation of CFC chemical model'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
+
+
+      ! Initialization of boundaries conditions
+      ! --------------------------------------- 
+      xphem (:,:)    = 0.e0
+      DO jl = 1, jp_cfc
+         jn = jp_cfc0 + jl - 1
+         DO jm = 1, jphem
+            DO js = 1, jpyear
+               p_cfc(js,jm,jn) = 0.0
+            END DO
+         END DO
+      END DO
+      
+      
+      ! Initialization of qint in case of  no restart 
+      !----------------------------------------------
+      qtr_cfc(:,:,:) = 0.e0
+      IF( .NOT. ln_rsttr ) THEN    
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'Initialization de qint ; No restart : qint equal zero '
+         ENDIF
+         DO jl = 1, jp_cfc
+            jn = jp_cfc0 + jl - 1
+            trn     (:,:,:,jn) = 0.e0
+            qint_cfc(:,:  ,jn) = 0.e0
+         END DO
+      ENDIF
+
+
+      !   READ CFC partial pressure atmospheric value :
+      !     p11(year,nt) = PCFC11  in northern (1) and southern (2) hemisphere 
+      !     p12(year,nt) = PCFC12  in northern (1) and southern (2) hemisphere 
+      !--------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*) 'read of formatted file cfc1112atm'
+      
+      CALL ctl_opn( inum, 'cfc1112.atm', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+      REWIND(inum)
+      
+      DO jm = 1, 6        ! Skip over 1st six descriptor lines
+         READ(inum,'(1x)')
+      END DO
+   
+      DO jn = 31, 98      !   Read file
+         READ(inum,*) zyy, p_cfc(jn,1,1), p_cfc(jn,1,2), p_cfc(jn,2,1), p_cfc(jn,2,2)
+         WRITE(numout,'(f7.2, 4f8.2)' ) &
+            &         zyy, p_cfc(jn,1,1), p_cfc(jn,1,2), p_cfc(jn,2,1), p_cfc(jn,2,2)
+      END DO
+
+      p_cfc(32,1:2,1) = 5.e-4      ! modify the values of the first years
+      p_cfc(33,1:2,1) = 8.e-4
+      p_cfc(34,1:2,1) = 1.e-6
+      p_cfc(35,1:2,1) = 2.e-3
+      p_cfc(36,1:2,1) = 4.e-3
+      p_cfc(37,1:2,1) = 6.e-3
+      p_cfc(38,1:2,1) = 8.e-3
+      p_cfc(39,1:2,1) = 1.e-2
+      
+      IF(lwp) THEN        ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Year   p11HN    p11HS    p12HN    p12HS '
+         DO jn = 30, 100
+            WRITE(numout, '( 1I4, 4F9.2)')   &
+               &         jn, p_cfc(jn,1,1), p_cfc(jn,2,1), p_cfc(jn,1,2), p_cfc(jn,2,2)
+         END DO
+      ENDIF
+
+
+      ! Interpolation factor of atmospheric partial pressure
+      ! Linear interpolation between 2 hemispheric function of latitud between ylats and ylatn
+      !---------------------------------------------------------------------------------------
+      zyd = ylatn - ylats      
+      DO jj = 1 , jpj
+         DO ji = 1 , jpi
+            IF(     gphit(ji,jj) >= ylatn ) THEN   ;   xphem(ji,jj) = 1.e0
+            ELSEIF( gphit(ji,jj) <= ylats ) THEN   ;   xphem(ji,jj) = 0.e0
+            ELSE                                   ;   xphem(ji,jj) = ( gphit(ji,jj) - ylats) / zyd
+            ENDIF
+         END DO
+      END DO
+      !
+
+      IF(lwp) WRITE(numout,*) 'Initialization of CFC tracers done'
+      IF(lwp) WRITE(numout,*) ' '
+
+   END SUBROUTINE trc_ini_cfc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                         No CFC tracers
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini_cfc             ! Empty routine
+   END SUBROUTINE trc_ini_cfc
+#endif
+
+   !!======================================================================
+END MODULE trcini_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trclsm_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trclsm_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trclsm_cfc.F90	(revision 1844)
@@ -0,0 +1,132 @@
+MODULE trclsm_cfc
+   !!======================================================================
+   !!                         ***  MODULE trclsm_cfc  ***
+   !! TOP :   initialisation of some run parameters for CFC chemical model
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trclsm.cfc.h90
+   !!----------------------------------------------------------------------
+#if defined key_cfc
+   !!----------------------------------------------------------------------
+   !!   'key_cfc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !! trc_lsm_cfc      : CFC model initialisation
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_cfc      ! CFC specific variable
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_lsm_cfc   ! called by trclsm.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lsm_cfc
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_lsm_cfc  ***
+      !!                 
+      !! ** Purpose :   Definition some run parameter for CFC model
+      !!
+      !! ** Method  :   Read the namcfc namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namcfc
+      !!----------------------------------------------------------------------
+      INTEGER ::   numnatc
+#if defined key_trc_diaadd && ! defined key_iomput
+      ! definition of additional diagnostic as a structure
+      INTEGER :: jl, jn
+      TYPE DIAG
+         CHARACTER(len = 20)  :: snamedia   !: short name
+         CHARACTER(len = 80 ) :: lnamedia   !: long name
+         CHARACTER(len = 20 ) :: unitdia    !: unit
+      END TYPE DIAG
+
+      TYPE(DIAG) , DIMENSION(jp_cfc_2d) :: cfcdia2d
+#endif
+      !!
+      NAMELIST/namcfcdate/ ndate_beg, nyear_res
+#if defined key_trc_diaadd && ! defined key_iomput
+      NAMELIST/namcfcdia/nwritedia, cfcdia2d     ! additional diagnostics
+#endif
+      !!-------------------------------------------------------------------
+
+      ndate_beg = 300101            ! default namelist value
+      nyear_res = 1950
+
+      !                             ! Open namelist file
+      CALL ctl_opn( numnatc, 'namelist_cfc', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+         
+      READ( numnatc , namcfcdate )     ! read namelist
+
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' trc_lsm: Read namdates, namelist for CFC chemical model'
+         WRITE(numout,*) ' ~~~~~~~'
+         WRITE(numout,*) '    initial calendar date (aammjj) for CFC  ndate_beg = ', ndate_beg
+         WRITE(numout,*) '    restoring time constant (year)          nyear_res = ', nyear_res
+      ENDIF
+      nyear_beg = ndate_beg / 10000
+      IF(lwp) WRITE(numout,*) '    initial year (aa)                       nyear_beg = ', nyear_beg
+      !
+#if defined key_trc_diaadd && ! defined key_iomput
+
+      ! Namelist namcfcdia
+      ! -------------------
+      nwritedia = 10                   ! default values
+
+      DO jl = 1, jp_cfc_2d
+         jn = jp_cfc0_2d + jl - 1 
+         WRITE(ctrc2d(jn),'("2D_",I1)') jn                      ! short name
+         WRITE(ctrc2l(jn),'("2D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc2u(jn) = ' '                                       ! units
+      END DO
+
+      REWIND( numnatc )               ! read natrtd
+      READ  ( numnatc, namcfcdia )
+
+      DO jl = 1, jp_cfc_2d
+         jn = jp_cfc0_2d + jl - 1
+         ctrc2d(jn) = cfcdia2d(jl)%snamedia
+         ctrc2l(jn) = cfcdia2d(jl)%lnamedia
+         ctrc2u(jn) = cfcdia2d(jl)%unitdia
+      END DO
+
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : natadd'
+         WRITE(numout,*) '    frequency of outputs for additional arrays nwritedia = ', nwritedia
+         DO jl = 1, jp_cfc_2d
+            jn = jp_cfc0_2d + jl - 1
+            WRITE(numout,*) '   2d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc2d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc2l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc2u(jn))
+            WRITE(numout,*) ' '
+         END DO
+      ENDIF
+#endif
+
+   END SUBROUTINE trc_lsm_cfc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                                No CFC
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lsm_cfc                      ! Empty routine
+   END  SUBROUTINE  trc_lsm_cfc
+#endif  
+
+   !!======================================================================
+END MODULE trclsm_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcrst_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 1844)
@@ -0,0 +1,91 @@
+MODULE trcrst_cfc
+   !!======================================================================
+   !!                       ***  MODULE trcrst_cfc  ***
+   !! TOP :   create, write, read the restart files of CFC tracer
+   !!======================================================================
+   !! History :   1.0  !  2010-01 (C. Ethe) Original
+   !!----------------------------------------------------------------------
+#if defined key_cfc
+   !!----------------------------------------------------------------------
+   !!   'key_cfc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !!   trc_rst_read_cfc   : read  restart file
+   !!   trc_rst_wri_cfc    : write restart file
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_cfc          ! CFC sms trends
+   USE in_out_manager  ! I/O manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  trc_rst_read_cfc   ! called by trcini.F90 module
+   PUBLIC  trc_rst_wri_cfc   ! called by trcini.F90 module
+
+CONTAINS
+   
+   SUBROUTINE trc_rst_read_cfc( knum ) 
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_cfc  ***  
+      !!
+      !! ** Purpose : Read in restart file specific variables from CFC model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: knum  ! unit of the restart file
+      INTEGER              :: jn    ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_read_cfc : Read specific variables from CFC model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+      
+      DO jn = jp_cfc0, jp_cfc1
+         CALL iom_get( knum, jpdom_autoglo, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jn) ) 
+      END DO
+
+   END SUBROUTINE trc_rst_read_cfc
+
+   SUBROUTINE trc_rst_wri_cfc( kt, kitrst, knum )
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_cfc  ***
+      !!
+      !! ** Purpose : Read in restart file specific variables from CFC model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: kt      ! time step
+      INTEGER, INTENT(in)  :: kitrst  ! time step of restart write
+      INTEGER, INTENT(in)  :: knum    ! unit of the restart file
+      INTEGER              :: jn      ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_wri_cfc : Write specific variables from CFC model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      DO jn = jp_cfc0, jp_cfc1
+         CALL iom_rstput( kt, kitrst, knum, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jn) )
+      END DO
+
+   END SUBROUTINE trc_rst_wri_cfc
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read_cfc( knum )
+     INTEGER, INTENT(in)  :: knum
+     WRITE(*,*) 'trc_rst_wri_cfc: You should not have seen this print! error?', knum
+   END SUBROUTINE trc_rst_read_cfc
+
+   SUBROUTINE trc_rst_wri_cfc( kt, kitrst, knum )
+     INTEGER, INTENT(in)  :: kt, kitrst, knum
+     WRITE(*,*) 'trc_rst_wri_cfc: You should not have seen this print! error?', kt, kitrst, knum
+   END SUBROUTINE trc_rst_wri_cfc
+#endif
+
+   !!======================================================================
+END MODULE trcrst_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcsms_cfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 1844)
@@ -0,0 +1,254 @@
+MODULE trcsms_cfc
+   !!======================================================================
+   !!                      ***  MODULE trcsms_cfc  ***
+   !! TOP : CFC main model
+   !!======================================================================
+   !! History :    -   !  1999-10  (JC. Dutay)  original code
+   !!             1.0  !  2004-03 (C. Ethe) free form + modularity
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  reorganisation
+   !!----------------------------------------------------------------------
+#if defined key_cfc
+   !!----------------------------------------------------------------------
+   !!   'key_cfc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !!   trc_sms_cfc     :  compute and add CFC suface forcing to CFC trends
+   !!   trc_cfc_cst :  sets constants for CFC surface forcing computation
+   !!----------------------------------------------------------------------
+   USE oce_trc      ! Ocean variables
+   USE par_trc      ! TOP parameters
+   USE trc          ! TOP variables
+   USE trdmld_trc_oce
+   USE trdmld_trc
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sms_cfc       ! called in ???    
+
+   INTEGER , PUBLIC, PARAMETER ::   jpyear = 100   ! temporal parameter 
+   INTEGER , PUBLIC, PARAMETER ::   jphem  =   2   ! parameter for the 2 hemispheres
+   INTEGER , PUBLIC    ::   ndate_beg      ! initial calendar date (aammjj) for CFC
+   INTEGER , PUBLIC    ::   nyear_res      ! restoring time constant (year)
+   INTEGER , PUBLIC    ::   nyear_beg      ! initial year (aa) 
+   
+   REAL(wp), PUBLIC, DIMENSION(jpyear,jphem, jp_cfc) ::   p_cfc    ! partial hemispheric pressure for CFC          
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)              ::   xphem    ! spatial interpolation factor for patm
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj     ,jp_cfc) ::   qtr_cfc  ! flux at surface
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj     ,jp_cfc) ::   qint_cfc ! cumulative flux 
+
+   REAL(wp), DIMENSION(4,jp_cfc) ::   soa   ! coefficient for solubility of CFC [mol/l/atm]
+   REAL(wp), DIMENSION(3,jp_cfc) ::   sob   !    "               "
+   REAL(wp), DIMENSION(4,jp_cfc) ::   sca   ! coefficients for schmidt number in degre Celcius
+      
+   !                          ! coefficients for conversion
+   REAL(wp) ::   xconv1 = 1.0          ! conversion from to 
+   REAL(wp) ::   xconv2 = 0.01/3600.   ! conversion from cm/h to m/s: 
+   REAL(wp) ::   xconv3 = 1.0e+3       ! conversion from mol/l/atm to mol/m3/atm
+   REAL(wp) ::   xconv4 = 1.0e-12      ! conversion from mol/m3/atm to mol/m3/pptv 
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sms_cfc( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sms_cfc  ***
+      !!
+      !! ** Purpose :   Compute the surface boundary contition on CFC 11 
+      !!             passive tracer associated with air-mer fluxes and add it 
+      !!             to the general trend of tracers equations.
+      !!
+      !! ** Method  : - get the atmospheric partial pressure - given in pico -
+      !!              - computation of solubility ( in 1.e-12 mol/l then in 1.e-9 mol/m3)
+      !!              - computation of transfert speed ( given in cm/hour ----> cm/s )
+      !!              - the input function is given by : 
+      !!                speed * ( concentration at equilibrium - concentration at surface )
+      !!              - the input function is in pico-mol/m3/s and the
+      !!                CFC concentration in pico-mol/m3
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jn, jl, jm, js
+      INTEGER ::   iyear_beg, iyear_end
+      INTEGER ::   im1, im2
+
+      REAL(wp) ::   ztap, zdtap        
+      REAL(wp) ::   zt1, zt2, zt3, zv2
+      REAL(wp) ::   zsol      ! solubility
+      REAL(wp) ::   zsch      ! schmidt number 
+      REAL(wp) ::   zpp_cfc   ! atmospheric partial pressure of CFC
+      REAL(wp) ::   zca_cfc   ! concentration at equilibrium
+      REAL(wp) ::   zak_cfc   ! transfert coefficients
+
+      REAL(wp), DIMENSION(jphem,jp_cfc)   ::   zpatm       ! atmospheric function
+      REAL(wp), DIMENSION(jpi,jpj,jpk)    ::   ztrcfc      ! use for CFC sms trend
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 )   CALL trc_cfc_cst
+
+      ! Temporal interpolation
+      ! ----------------------
+      iyear_beg = nyear + ( nyear_res - 1900 - nyear_beg  )
+      IF ( nmonth <= 6 ) THEN
+         iyear_beg = iyear_beg - 2 + nyear_beg
+         im1       =  6 - nmonth + 1
+         im2       =  6 + nmonth - 1
+      ELSE
+         iyear_beg = iyear_beg - 1 + nyear_beg
+         im1       = 12 - nmonth + 7
+         im2       =      nmonth - 7
+      ENDIF
+      iyear_end = iyear_beg + 1
+
+      !                                                  !------------!
+      DO jl = 1, jp_cfc                                  !  CFC loop  !
+         !                                               !------------!
+         jn = jp_cfc0 + jl - 1
+         ! time interpolation at time kt
+         DO jm = 1, jphem
+            zpatm(jm,jl) = (  p_cfc(iyear_beg, jm, jl) * FLOAT (im1)  &
+               &           +  p_cfc(iyear_end, jm, jl) * FLOAT (im2) ) / 12.
+         END DO
+         
+         !                                                         !------------!
+         DO jj = 1, jpj                                            !  i-j loop  !
+            DO ji = 1, jpi                                         !------------!
+ 
+               ! space interpolation
+               zpp_cfc  =       xphem(ji,jj)   * zpatm(1,jl)   &
+                  &     + ( 1.- xphem(ji,jj) ) * zpatm(2,jl)
+
+               ! Computation of concentration at equilibrium : in picomol/l
+               ! coefficient for solubility for CFC-11/12 in  mol/l/atm
+               IF( tmask(ji,jj,1) .GE. 0.5 ) THEN
+                  ztap  = ( tn(ji,jj,1) + 273.16 ) * 0.01
+                  zdtap = sob(1,jl) + ztap * ( sob(2,jl) + ztap * sob(3,jl) ) 
+                  zsol  =  EXP( soa(1,jl) + soa(2,jl) / ztap + soa(3,jl) * LOG( ztap )   &
+                     &                    + soa(4,jl) * ztap * ztap + sn(ji,jj,1) * zdtap ) 
+               ELSE
+                  zsol  = 0.e0
+               ENDIF
+               ! conversion from mol/l/atm to mol/m3/atm and from mol/m3/atm to mol/m3/pptv    
+               zsol = xconv4 * xconv3 * zsol * tmask(ji,jj,1)  
+               ! concentration at equilibrium
+               zca_cfc = xconv1 * zpp_cfc * zsol * tmask(ji,jj,1)             
+  
+               ! Computation of speed transfert
+               !    Schmidt number
+               zt1  = tn(ji,jj,1)
+               zt2  = zt1 * zt1 
+               zt3  = zt1 * zt2
+               zsch = sca(1,jl) + sca(2,jl) * zt1 + sca(3,jl) * zt2 + sca(4,jl) * zt3
+
+               !    speed transfert : formulae of wanninkhof 1992
+               zv2     = wndm(ji,jj) * wndm(ji,jj)
+               zsch    = zsch / 660.
+               zak_cfc = ( 0.39 * xconv2 * zv2 / SQRT(zsch) ) * tmask(ji,jj,1)
+
+               ! Input function  : speed *( conc. at equil - concen at surface )
+               ! trn in pico-mol/l idem qtr; ak in en m/s
+               qtr_cfc(ji,jj,jl) = -zak_cfc * ( trb(ji,jj,1,jn) - zca_cfc )   &
+#if defined key_off_degrad
+                  &                         * facvol(ji,jj,1)                           &
+#endif
+                  &                         * tmask(ji,jj,1) * ( 1. - fr_i(ji,jj) )
+
+               ! Add the surface flux to the trend
+               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + qtr_cfc(ji,jj,jl) / fse3t(ji,jj,1) 
+
+               ! cumulation of surface flux at each time step
+               qint_cfc(ji,jj,jl) = qint_cfc(ji,jj,jl) + qtr_cfc(ji,jj,jl) * rdt
+               !                                               !----------------!
+            END DO                                             !  end i-j loop  !
+         END DO                                                !----------------!
+         !                                                  !----------------!
+      END DO                                                !  end CFC loop  !
+      !                                                     !----------------!
+
+#if defined key_trc_diaadd 
+      ! Save diagnostics , just for CFC11
+# if ! defined key_iomput
+      trc2d(:,:,jp_cfc0_2d    ) = qtr_cfc (:,:,1)
+      trc2d(:,:,jp_cfc0_2d + 1) = qint_cfc(:,:,1)
+# else
+      CALL iom_put( "qtrCFC11"  , qtr_cfc (:,:,1) )
+      CALL iom_put( "qintCFC11" , qint_cfc(:,:,1) )
+# endif
+#endif
+
+      IF( l_trdtrc ) THEN
+          DO jn = jp_cfc0, jp_cfc1
+            ztrcfc(:,:,:) = tra(:,:,:,jn)
+            CALL trd_mod_trc( ztrcfc, jn, jptrc_trd_sms, kt )   ! save trends
+          END DO
+      END IF
+
+   END SUBROUTINE trc_sms_cfc
+
+   SUBROUTINE trc_cfc_cst
+      !!---------------------------------------------------------------------
+      !!                     ***  trc_cfc_cst  ***  
+      !!
+      !! ** Purpose : sets constants for CFC model
+      !!---------------------------------------------------------------------
+
+
+        ! coefficient for CFC11 
+        !----------------------
+
+        ! Solubility
+        soa(1,1) = -229.9261 
+        soa(2,1) =  319.6552
+        soa(3,1) =  119.4471
+        soa(4,1) =  -1.39165
+
+        sob(1,1) =  -0.142382
+        sob(2,1) =   0.091459
+        sob(3,1) =  -0.0157274
+
+        ! Schmidt number 
+        sca(1,1) = 3501.8
+        sca(2,1) = -210.31
+        sca(3,1) =  6.1851
+        sca(4,1) = -0.07513
+
+        ! coefficient for CFC12 
+        !----------------------
+
+        ! Solubility
+        soa(1,2) = -218.0971
+        soa(2,2) =  298.9702
+        soa(3,2) =  113.8049
+        soa(4,2) =  -1.39165
+
+        sob(1,2) =  -0.143566
+        sob(2,2) =   0.091015
+        sob(3,2) =  -0.0153924
+
+        ! schmidt number 
+        sca(1,2) =  3845.4 
+        sca(2,2) =  -228.95
+        sca(3,2) =  6.1908 
+        sca(4,2) =  -0.067430
+
+   END SUBROUTINE trc_cfc_cst
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                         No CFC tracers
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_sms_cfc( kt )       ! Empty routine
+      WRITE(*,*) 'trc_sms_cfc: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms_cfc
+#endif
+
+   !!======================================================================
+END MODULE trcsms_cfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_interp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_interp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_interp.F90	(revision 1844)
@@ -0,0 +1,16 @@
+MODULE agrif_top_interp
+   !!======================================================================
+   !!                   ***  MODULE agrif_top_interp  ***
+   !! TOP :   Dummy module when AGRIF is not used
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                               NO AGRIF
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+   !!======================================================================
+END MODULE agrif_top_interp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_sponge.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_sponge.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_sponge.F90	(revision 1844)
@@ -0,0 +1,15 @@
+MODULE agrif_top_sponge
+   !!======================================================================
+   !!                       ***  MODULE agrif_top_sponge  ***
+   !!  Dummy module
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                     NO agrif use
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Id: agrif_opa_sponge.F90 1152 2008-06-26 14:11:13Z rblod $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+END MODULE agrif_top_sponge
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_update.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_update.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/DUMMY/agrif_top_update.F90	(revision 1844)
@@ -0,0 +1,16 @@
+MODULE agrif_top_update
+   !!======================================================================
+   !!                   ***  MODULE agrif_top_update  ***
+   !! TOP :   Dummy module when AGRIF is not used
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                               NO AGRIF
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
+   !!----------------------------------------------------------------------
+
+   !!======================================================================
+END MODULE agrif_top_update
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/par_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/par_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/par_lobster.F90	(revision 1844)
@@ -0,0 +1,60 @@
+MODULE par_lobster
+   !!======================================================================
+   !!                        ***  par_lobster  ***
+   !! TOP :   set the LOBSTER parameters
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PUBLIC
+
+#if defined key_lobster
+   !!---------------------------------------------------------------------
+   !!   'key_lobster'   :                                LOBSTER bio-model
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_lobster     = .TRUE.    !: LOBSTER flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster     =  6        !: number of LOBSTER tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_2d  = 19        !: additional 2d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_3d  =  3        !: additional 3d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_trd = 17       !: number of sms trends for LOBSTER
+
+   ! assign an index in trc arrays for each LOBSTER prognostic variables
+   INTEGER, PUBLIC, PARAMETER ::   jpdet          =  1        !: detritus                    [mmoleN/m3]
+   INTEGER, PUBLIC, PARAMETER ::   jpzoo          =  2        !: zooplancton concentration   [mmoleN/m3]
+   INTEGER, PUBLIC, PARAMETER ::   jpphy          =  3        !: phytoplancton concentration [mmoleN/m3]
+   INTEGER, PUBLIC, PARAMETER ::   jpno3          =  4        !: nitrate concentration       [mmoleN/m3]
+   INTEGER, PUBLIC, PARAMETER ::   jpnh4          =  5        !: ammonium concentration      [mmoleN/m3]
+   INTEGER, PUBLIC, PARAMETER ::   jpdom          =  6        !: dissolved organic matter    [mmoleN/m3]
+
+   ! productive layer depth
+   INTEGER, PUBLIC, PARAMETER ::   jpkb           = 12        !: first vertical layers where biology is active
+   INTEGER, PUBLIC, PARAMETER ::   jpkbm1         = jpkb - 1  !: first vertical layers where biology is active
+
+#else
+   !!---------------------------------------------------------------------
+   !!   Default                                           No LOBSTER model
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_lobster     = .FALSE.   !: LOBSTER flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster     =  0        !: No LOBSTER tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_2d  =  0        !: No LOBSTER additional 2d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_3d  =  0        !: No LOBSTER additional 3d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_lobster_trd =  0        !: number of sms trends for LOBSTER
+#endif
+
+   ! Starting/ending LOBSTER do-loop indices (N.B. no LOBSTER : jpl_lob < jpf_lob the do-loop are never done)
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob0     =          1       !: First index of LOBSTER tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob1     = jp_lobster       !: Last  index of LOBSTER tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob0_2d  =          1       !: First index of LOBSTER 2D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob1_2d  = jp_lobster_2d    !: Last  index of LOBSTER 2D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob0_3d  =          1       !: First index of LOBSTER 3D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob1_3d  = jp_lobster_3d    !: Last  index of LOBSTER 3D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob0_trd =          1       !: First index of LOBSTER bio. diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_lob1_trd = jp_lobster_trd   !: Last  index of LOBSTER bio. diag
+
+   !!======================================================================
+END MODULE par_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 1844)
@@ -0,0 +1,117 @@
+MODULE sms_lobster 
+   !!----------------------------------------------------------------------
+   !!                     ***  sms_lobster.F90  ***  
+   !! TOP :   LOBSTER 1 Source Minus Sink variables
+   !!----------------------------------------------------------------------
+   !! History :    -   !  1999-09 (M. Levy)  original code
+   !!              -   !  2000-12 (O. Aumont, E. Kestenare) add sediment 
+   !!             1.0  !  2005-10 (C. Ethe) F90
+   !!             1.0  !  2005-03  (A-S Kremeur) add fphylab, fzoolab, fdetlab, fdbod
+   !!              -   !  2005-06  (A-S Kremeur) add sedpocb, sedpocn, sedpoca
+   !!             2.0  !  2007-04  (C. Deltel, G. Madec) Free form and modules
+   !!----------------------------------------------------------------------
+
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                         LOBSTER model
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE par_trc
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+   !!  biological parameters
+   !! ----------------------
+   REAL(wp) ::   apmin    !: minimum phytoplancton concentration              (NAMELIST)
+   REAL(wp) ::   azmin    !: minimum zooplancton concentration                (NAMELIST)
+   REAL(wp) ::   anmin    !: minimum nutrients concentration                  (NAMELIST)
+   REAL(wp) ::   admin    !: minimum detritus concentration                   (NAMELIST)
+   REAL(wp) ::   redf     !: redfield ratio c:n                               (NAMELIST)
+   REAL(wp) ::   reddom   !: redfield ratio c:n for DOM                       
+   REAL(wp) ::   slopet   !: van t hoff coefficient                           (NAMELIST)
+   REAL(wp) ::   toptp    !: optimal photosynthesis temperature               (NAMELIST) 
+   REAL(wp) ::   aknut    !: half-saturation nutrient                         (NAMELIST)
+   REAL(wp) ::   psinut   !: inhibition of nitrate uptake by ammonium         (NAMELIST)
+   REAL(wp) ::   akno3    !: half-saturation for nitrate                      (NAMELIST)
+   REAL(wp) ::   aknh4    !: half-saturation for ammonium                     (NAMELIST)
+   REAL(wp) ::   rcchl    !: ???                                              
+   REAL(wp) ::   rgamma   !: phytoplankton exudation fraction                 (NAMELIST)
+   REAL(wp) ::   toptgz   !: optimal temperature for zooplankton growth       (NAMELIST)
+   REAL(wp) ::   tmaxgz   !: maximal temperature for zooplankton growth       (NAMELIST) 
+   REAL(wp) ::   rgz      !: widtht of zooplankton temperature FUNCTION       (NAMELIST)
+   REAL(wp) ::   rppz     !: zooplankton nominal preference for phytoplancton food (NAMELIST)
+   REAL(wp) ::   taus     !: maximum specific zooplankton grazing rate        (NAMELIST)
+   REAL(wp) ::   aks      !: half saturation constant for total zooplankton grazing (NAMELIST)
+   REAL(wp) ::   filmax   !: maximum mass clearance rate for zooplankton      (NAMELIST)
+   REAL(wp) ::   rpnaz    !: non-assimilated phytoplankton by zooplancton     (NAMELIST)
+   REAL(wp) ::   rdnaz    !: non-assimilated detritus by zooplankton          (NAMELIST) 
+   REAL(wp) ::   eggzoo   !: minimum for zooplankton concentration            (NAMELIST)
+   REAL(wp) ::   tauzn    !: zooplancton specific excretion rate              (NAMELIST)
+   REAL(wp) ::   tmmaxp   !: maximal phytoplancton mortality rate             (NAMELIST)
+   REAL(wp) ::   tmminp   !: minimal phytoplancton mortality rate             (NAMELIST)
+   REAL(wp) ::   tmmaxz   !: maximal zooplankton mortality rate               (NAMELIST)
+   REAL(wp) ::   tmminz   !: minimal zooplankton mortality rate               (NAMELIST)
+   REAL(wp) ::   anumin   !: nutrient threshold for phytoplankton mortality   (NAMELIST)
+   REAL(wp) ::   afdmin   !: food threshold for zooplankton mortality         (NAMELIST)
+   REAL(wp) ::   taudn    !: detrital breakdown rate                          (NAMELIST)
+   REAL(wp) ::   vsed     !: sedimentation speed                              (NAMELIST)
+   REAL(wp) ::   tmumax   !: maximal phytoplankton growth rate                (NAMELIST)
+   REAL(wp) ::   aki      !: light photosynthesis half saturation constant    (NAMELIST)
+   REAL(wp) ::   tmaxr    !: maximum coefficient for passive tracer damping   (NAMELIST)
+   REAL(wp) ::   tminr    !: minimum coefficient for passive tracer damping   (NAMELIST)
+   REAL(wp) ::   fdoml    !: fraction of exsudation that goes to nh4 (should be labile dom)
+   REAL(wp) ::   taunn    !: nitrification rate
+   REAL(wp) ::   taudomn  !: slow remineralization rate of semi-labile dom to nh4
+   REAL(wp) ::   xhr      !: coeff for Martin's remineralistion profile
+   REAL(wp) ::   fphylab  !: NH4 fraction of phytoplankton excretion
+   REAL(wp) ::   fzoolab  !: NH4 fraction of zooplankton excretion
+   REAL(wp) ::   fdetlab  !: NH4 fraction of detritus dissolution
+   REAL(wp) ::   fdbod    !: zooplankton mortality fraction that goes to detritus
+
+   REAL(wp), DIMENSION(jpk,jp_lobster) ::   remdmp   !: depth dependant damping coefficient of passive tracers 
+   
+   !! Optical parameters                                
+   !! ------------------                                
+   REAL(wp) ::   xkr0       !: water coefficient absorption in red      (NAMELIST)
+   REAL(wp) ::   xkg0       !: water coefficient absorption in green    (NAMELIST)
+   REAL(wp) ::   xkrp       !: pigment coefficient absorption in red    (NAMELIST)
+   REAL(wp) ::   xkgp       !: pigment coefficient absorption in green  (NAMELIST)
+   REAL(wp) ::   xlr        !: exposant for pigment absorption in red   (NAMELIST)
+   REAL(wp) ::   xlg        !: exposant for pigment absorption in green (NAMELIST)
+   REAL(wp) ::   rpig       !: chla/chla+phea ratio                     (NAMELIST)
+                                                        
+   INTEGER , DIMENSION(jpi,jpj)     ::   neln    !: number of levels in the euphotic layer
+   REAL(wp), DIMENSION(jpi,jpj)     ::   xze     !: euphotic layer depth
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xpar    !: par (photosynthetic available radiation)
+
+   !! Sediment parameters                               
+   !! -------------------                               
+   REAL(wp) ::   sedlam       !: time coefficient of POC remineralization in sediments
+   REAL(wp) ::   sedlostpoc   !: ???
+   REAL(wp) ::   areacot      !: ???
+                                                        
+   REAL(wp), DIMENSION(jpi,jpj)     ::   dminl   !: fraction of sinking POC released in sediments
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   dmin3   !: fraction of sinking POC released at each level
+                                                        
+   REAL(wp), DIMENSION(jpi,jpj) ::   sedpocb     !: mass of POC in sediments
+   REAL(wp), DIMENSION(jpi,jpj) ::   sedpocn     !: mass of POC in sediments
+   REAL(wp), DIMENSION(jpi,jpj) ::   sedpoca     !: mass of POC in sediments
+                                                        
+   REAL(wp), DIMENSION(jpi,jpj) ::   fbod        !: rapid sinking particles
+   REAL(wp), DIMENSION(jpi,jpj) ::   cmask       !: ???
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     NO LOBSTER model 
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE sms_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcbio.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 1844)
@@ -0,0 +1,506 @@
+MODULE trcbio
+   !!======================================================================
+   !!                         ***  MODULE trcbio  ***
+   !! TOP :   LOBSTER
+   !!======================================================================
+   !! History :    -   !  1999-07  (M. Levy) Original code
+   !!              -   !  2000-12  (E. Kestenare) assign a parameter to name individual tracers
+   !!              -   !  2001-03  (M. Levy)  LNO3 + dia2d 
+   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                     LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !!   trc_bio        :  
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc             ! 
+   USE sms_lobster     ! 
+   USE lbclnk          ! 
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE iom
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_bio    ! called in ???
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_bio( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_bio  ***
+      !!
+      !! ** Purpose :   compute the now trend due to biogeochemical processes
+      !!              and add it to the general trend of passive tracers equations
+      !!
+      !! ** Method  :   each now biological flux is calculated in function of now
+      !!              concentrations of tracers.
+      !!              depending on the tracer, these fluxes are sources or sinks.
+      !!              the total of the sources and sinks for each tracer
+      !!              is added to the general trend.
+      !!        
+      !!                      tra = tra + zf...tra - zftra...
+      !!                                     |         |
+      !!                                     |         |
+      !!                                  source      sink
+      !!        
+      !!              IF 'key_trc_diabio' defined , the biogeochemical trends
+      !!              for passive tracers are saved for futher diagnostics.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      INTEGER  ::   ji, jj, jk, jl
+      REAL(wp) ::   zdet, zzoo, zphy, zno3, znh4, zdom      ! now concentrations
+      REAL(wp) ::   zlno3, zlnh4, zle, zlt                  ! limitation terms for phyto
+      REAL(wp) ::   zno3phy, znh4phy, zphynh4, zphydom
+      REAL(wp) ::   zphydet, zphyzoo, zdetzoo
+      REAL(wp) ::   zzoonh4, zzoodom, zzoodet, zdetnh4, zdetdom
+      REAL(wp) ::   znh4no3, zdomnh4, zppz, zpdz, zpppz, zppdz, zfood
+      REAL(wp) ::   zfilpz, zfildz, zphya, zzooa, zno3a
+      REAL(wp) ::   znh4a, zdeta, zdoma, zzoobod, zboddet, zdomaju
+#if defined key_trc_diaadd
+      REAL(wp) ::   ze3t
+#endif
+#if defined key_trc_diaadd && defined key_iomput
+      REAL(wp), DIMENSION(jpi,jpj,17)     :: zw2d
+# if defined key_trc_dia3d
+      REAL(wp), DIMENSION(jpi,jpj,jpk,3) :: zw3d
+# endif
+#endif
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrbio
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' trc_bio: LOBSTER bio-model'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+      ENDIF
+
+      fbod(:,:) = 0.e0
+#if defined key_trc_diaadd && ! defined key_iomput
+      DO jl = jp_lob0_2d, jp_lob1_2d
+         trc2d(:,:,jl) = 0.e0
+      END DO 
+#endif
+#if defined key_trc_diaadd && defined key_iomput
+      zw2d(:,:,:) = 0.e0
+# if defined key_trc_dia3d
+      zw3d(:,:,:,:) = 0.e0
+# endif
+#endif
+
+      IF( l_trdtrc )THEN
+         ALLOCATE( ztrbio(jpi,jpj,jpk,jp_lobster_trd) )
+         ztrbio(:,:,:,:) = 0.
+      ENDIF
+
+      !                                      ! -------------------------- !
+      DO jk = 1, jpkbm1                      !  Upper ocean (bio-layers)  !
+         !                                   ! -------------------------- !
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1 
+               ! trophic variables( det, zoo, phy, no3, nh4, dom)
+               ! ------------------------------------------------
+
+               ! negative trophic variables DO not contribute to the fluxes
+               zdet = MAX( 0.e0, trn(ji,jj,jk,jpdet) )
+               zzoo = MAX( 0.e0, trn(ji,jj,jk,jpzoo) )
+               zphy = MAX( 0.e0, trn(ji,jj,jk,jpphy) )
+               zno3 = MAX( 0.e0, trn(ji,jj,jk,jpno3) )
+               znh4 = MAX( 0.e0, trn(ji,jj,jk,jpnh4) )
+               zdom = MAX( 0.e0, trn(ji,jj,jk,jpdom) )
+
+               ! Limitations
+               zlt   = 1.
+               zle   = 1. - EXP( -xpar(ji,jj,jk) / aki / zlt )
+               ! psinut,akno3,aknh4 added by asklod AS Kremeur 2005-03
+               zlno3 = zno3 * EXP( -psinut * znh4 ) / ( akno3 + zno3 )
+               zlnh4 = znh4 / (znh4+aknh4) 
+
+               ! sinks and sources
+               !    phytoplankton production and exsudation
+               zno3phy = tmumax * zle * zlt * zlno3 * zphy
+               znh4phy = tmumax * zle * zlt * zlnh4 * zphy
+
+               !    fphylab added by asklod AS Kremeur 2005-03
+               zphydom = rgamma * (1 - fphylab) * (zno3phy + znh4phy)
+               zphynh4 = rgamma * fphylab * (zno3phy + znh4phy)
+
+               ! zooplankton production
+               !    preferences
+               zppz = rppz
+               zpdz = 1. - rppz
+               zpppz = ( zppz * zphy ) / ( ( zppz * zphy + zpdz * zdet ) + 1.e-13 )
+               zppdz = ( zpdz * zdet ) / ( ( zppz * zphy + zpdz * zdet ) + 1.e-13 )
+               zfood = zpppz * zphy + zppdz * zdet
+               !    filtration
+               zfilpz = taus * zpppz / (aks + zfood)
+               zfildz = taus * zppdz / (aks + zfood)
+               !    grazing
+               zphyzoo = zfilpz * zphy * zzoo
+               zdetzoo = zfildz * zdet * zzoo
+
+               ! fecal pellets production
+               zzoodet = rpnaz * zphyzoo + rdnaz * zdetzoo
+ 
+               ! zooplankton liquide excretion
+               zzoonh4 = tauzn * fzoolab * zzoo 
+               zzoodom = tauzn * (1 - fzoolab) * zzoo
+
+               ! mortality
+               !    phytoplankton mortality 
+               zphydet = tmminp * zphy
+
+               !    zooplankton mortality
+               !    closure : flux fbod is redistributed below level jpkbio
+               zzoobod = tmminz * zzoo * zzoo
+               fbod(ji,jj) = fbod(ji,jj) + (1-fdbod) * zzoobod * fse3t(ji,jj,jk)
+               zboddet = fdbod * zzoobod
+
+               ! detritus and dom breakdown
+               zdetnh4 = taudn * fdetlab * zdet
+               zdetdom = taudn * (1 - fdetlab) * zdet 
+
+               zdomnh4 = taudomn * zdom
+
+               ! flux added to express how the excess of nitrogen from
+               ! PHY, ZOO and DET to DOM goes directly to NH4 (flux of ajustment)
+               zdomaju = (1 - redf/reddom) * (zphydom + zzoodom + zdetdom)
+
+               ! Nitrification
+               znh4no3 = taunn * znh4
+
+               ! determination of trends
+               !    total trend for each biological tracer
+               zphya =   zno3phy + znh4phy - zphynh4 - zphydom - zphyzoo - zphydet
+               zzooa =   zphyzoo + zdetzoo - zzoodet - zzoodom - zzoonh4 - zzoobod
+               zno3a = - zno3phy + znh4no3
+               znh4a = - znh4phy - znh4no3 + zphynh4 + zzoonh4 + zdomnh4 + zdetnh4 + zdomaju
+               zdeta =   zphydet + zzoodet - zdetzoo - zdetnh4 - zdetdom + zboddet
+               zdoma =   zphydom + zzoodom + zdetdom - zdomnh4 - zdomaju
+
+               ! tracer flux at totox-point added to the general trend
+               tra(ji,jj,jk,jpdet) = tra(ji,jj,jk,jpdet) + zdeta
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) + zzooa
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) + zphya
+               tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) + zno3a
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + znh4a
+               tra(ji,jj,jk,jpdom) = tra(ji,jj,jk,jpdom) + zdoma
+
+#if defined key_trc_diabio
+               trbio(ji,jj,jk,jp_lob0_trd     ) = zno3phy
+               trbio(ji,jj,jk,jp_lob0_trd +  1) = znh4phy
+               trbio(ji,jj,jk,jp_lob0_trd +  2) = zphynh4
+               trbio(ji,jj,jk,jp_lob0_trd +  3) = zphydom
+               trbio(ji,jj,jk,jp_lob0_trd +  4) = zphyzoo
+               trbio(ji,jj,jk,jp_lob0_trd +  5) = zphydet
+               trbio(ji,jj,jk,jp_lob0_trd +  6) = zdetzoo
+               trbio(ji,jj,jk,jp_lob0_trd +  8) = zzoodet
+               trbio(ji,jj,jk,jp_lob0_trd +  9) = zzoobod
+               trbio(ji,jj,jk,jp_lob0_trd + 10) = zzoonh4
+               trbio(ji,jj,jk,jp_lob0_trd + 11) = zzoodom
+               trbio(ji,jj,jk,jp_lob0_trd + 12) = znh4no3
+               trbio(ji,jj,jk,jp_lob0_trd + 13) = zdomnh4
+               trbio(ji,jj,jk,jp_lob0_trd + 14) = zdetnh4
+               trbio(ji,jj,jk,jp_lob0_trd + 15) = zdetdom
+#endif
+               IF( l_trdtrc ) THEN
+                  ztrbio(ji,jj,jk,jp_lob0_trd     ) = zno3phy
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  1) = znh4phy
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  2) = zphynh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  3) = zphydom
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  4) = zphyzoo
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  5) = zphydet
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  6) = zdetzoo
+                  !  trend number 8 in trcsed
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  8) = zzoodet
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  9) = zzoobod
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 10) = zzoonh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 11) = zzoodom
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 12) = znh4no3
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 13) = zdomnh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 14) = zdetnh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 15) = zdetdom
+                  !  trend number 17 in trcexp
+                ENDIF
+
+#if defined key_trc_diaadd
+               ! convert fluxes in per day
+               ze3t = fse3t(ji,jj,jk) * 86400.
+#if ! defined key_iomput
+               trc2d(ji,jj,jp_lob0_2d    ) = trc2d(ji,jj, jp_lob0_2d    ) + zno3phy * ze3t 
+               trc2d(ji,jj,jp_lob0_2d + 1) = trc2d(ji,jj, jp_lob0_2d + 1) + znh4phy * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 2) = trc2d(ji,jj, jp_lob0_2d + 2) + zphydom * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 3) = trc2d(ji,jj, jp_lob0_2d + 3) + zphynh4 * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 4) = trc2d(ji,jj, jp_lob0_2d + 4) + zphyzoo * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 5) = trc2d(ji,jj, jp_lob0_2d + 5) + zphydet * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 6) = trc2d(ji,jj, jp_lob0_2d + 6) + zdetzoo * ze3t
+               ! trend number 8 is in trcsed.F            
+               trc2d(ji,jj,jp_lob0_2d +  8) = trc2d(ji,jj,jp_lob0_2d +  8) + zzoodet * ze3t
+               trc2d(ji,jj,jp_lob0_2d +  9) = trc2d(ji,jj,jp_lob0_2d +  9) + zzoobod * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 10) = trc2d(ji,jj,jp_lob0_2d + 10) + zzoonh4 * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 11) = trc2d(ji,jj,jp_lob0_2d + 11) + zzoodom * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 12) = trc2d(ji,jj,jp_lob0_2d + 12) + znh4no3 * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 13) = trc2d(ji,jj,jp_lob0_2d + 13) + zdomnh4 * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 14) = trc2d(ji,jj,jp_lob0_2d + 14) + zdetnh4 * ze3t             
+               trc2d(ji,jj,jp_lob0_2d + 15) = trc2d(ji,jj,jp_lob0_2d + 15) + (  zno3phy + znh4phy - zphynh4   &
+                  &                                 - zphydom - zphyzoo - zphydet ) * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 16) = trc2d(ji,jj,jp_lob0_2d + 16) + (  zphyzoo + zdetzoo - zzoodet   &
+                  &                                 - zzoobod - zzoonh4 - zzoodom ) * ze3t
+               trc2d(ji,jj,jp_lob0_2d + 17) = trc2d(ji,jj,jp_lob0_2d + 17) + zdetdom * ze3t
+               ! trend number 19 is in trcexp.F
+#else
+               zw2d(ji,jj,1)  = zw2d(ji,jj,1)  + zno3phy * ze3t 
+               zw2d(ji,jj,2)  = zw2d(ji,jj,2)  + znh4phy * ze3t
+               zw2d(ji,jj,3)  = zw2d(ji,jj,3)  + zphydom * ze3t
+               zw2d(ji,jj,4)  = zw2d(ji,jj,4)  + zphynh4 * ze3t
+               zw2d(ji,jj,5)  = zw2d(ji,jj,5)  + zphyzoo * ze3t
+               zw2d(ji,jj,6)  = zw2d(ji,jj,6)  + zphydet * ze3t
+               zw2d(ji,jj,7)  = zw2d(ji,jj,7)  + zdetzoo * ze3t
+               zw2d(ji,jj,8)  = zw2d(ji,jj,8)  + zzoodet * ze3t
+               zw2d(ji,jj,9)  = zw2d(ji,jj,9)  + zzoobod * ze3t
+               zw2d(ji,jj,10) = zw2d(ji,jj,10) + zzoonh4 * ze3t
+               zw2d(ji,jj,11) = zw2d(ji,jj,11) + zzoodom * ze3t
+               zw2d(ji,jj,12) = zw2d(ji,jj,12) + znh4no3 * ze3t
+               zw2d(ji,jj,13) = zw2d(ji,jj,13) + zdomnh4 * ze3t
+               zw2d(ji,jj,14) = zw2d(ji,jj,14) + zdetnh4 * ze3t             
+               zw2d(ji,jj,15) = zw2d(ji,jj,15) + ( zno3phy + znh4phy - zphynh4 - zphydom - zphyzoo - zphydet ) * ze3t
+               zw2d(ji,jj,16) = zw2d(ji,jj,16) + ( zphyzoo + zdetzoo - zzoodet - zzoobod - zzoonh4 - zzoodom ) * ze3t
+               zw2d(ji,jj,17) = zw2d(ji,jj,17) + zdetdom * ze3t
+#endif
+#if defined key_trc_dia3d 
+# if ! defined key_iomput
+               trc3d(ji,jj,jk,jp_lob0_3d    ) = zno3phy * 86400     
+               trc3d(ji,jj,jk,jp_lob0_3d + 1) = znh4phy * 86400     
+               trc3d(ji,jj,jk,jp_lob0_3d + 2) = znh4no3 * 86400   
+# else
+               zw3d(ji,jj,jk,1) = zno3phy * 86400     
+               zw3d(ji,jj,jk,2) = znh4phy * 86400     
+               zw3d(ji,jj,jk,3) = znh4no3 * 86400   
+# endif
+#endif  
+#endif
+            END DO
+         END DO
+      END DO
+
+      !                                      ! -------------------------- !
+      DO jk = jpkb, jpkm1                    !  Upper ocean (bio-layers)  !
+         !                                   ! -------------------------- !
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1 
+               ! remineralisation of all quantities towards nitrate 
+
+               !    trophic variables( det, zoo, phy, no3, nh4, dom)
+               !       negative trophic variables DO not contribute to the fluxes
+               zdet = MAX( 0.e0, trn(ji,jj,jk,jpdet) )
+               zzoo = MAX( 0.e0, trn(ji,jj,jk,jpzoo) )
+               zphy = MAX( 0.e0, trn(ji,jj,jk,jpphy) )
+               zno3 = MAX( 0.e0, trn(ji,jj,jk,jpno3) )
+               znh4 = MAX( 0.e0, trn(ji,jj,jk,jpnh4) )
+               zdom = MAX( 0.e0, trn(ji,jj,jk,jpdom) )
+
+               !    Limitations
+               zlt   = 0.e0
+               zle   = 0.e0
+               zlno3 = 0.e0
+               zlnh4 = 0.e0
+
+               !    sinks and sources
+               !       phytoplankton production and exsudation
+               zno3phy = 0.e0
+               znh4phy = 0.e0
+               zphydom = 0.e0
+               zphynh4 = 0.e0
+
+               !    zooplankton production
+               zphyzoo = 0.e0      ! grazing
+               zdetzoo = 0.e0
+
+               zzoodet = 0.e0      ! fecal pellets production
+
+               zzoonh4 = tauzn * fzoolab * zzoo         ! zooplankton liquide excretion
+               zzoodom = tauzn * (1 - fzoolab) * zzoo
+
+               !    mortality
+               zphydet = tmminp * zphy      ! phytoplankton mortality 
+
+               zzoobod = 0.e0               ! zooplankton mortality
+               zboddet = 0.e0               ! closure : flux fbod is redistributed below level jpkbio
+
+               !    detritus and dom breakdown
+               zdetnh4 = taudn * fdetlab * zdet
+               zdetdom = taudn * (1 - fdetlab) * zdet 
+
+               zdomnh4 = taudomn * zdom
+               zdomaju = (1 - redf/reddom) * (zphydom + zzoodom + zdetdom)
+
+               !    Nitrification
+               znh4no3 = taunn * znh4
+
+
+               ! determination of trends
+               !     total trend for each biological tracer
+               zphya =   zno3phy + znh4phy - zphynh4 - zphydom - zphyzoo - zphydet
+               zzooa =   zphyzoo + zdetzoo - zzoodet - zzoodom - zzoonh4 - zzoobod
+               zno3a = - zno3phy + znh4no3
+               znh4a = - znh4phy - znh4no3 + zphynh4 + zzoonh4 + zdomnh4 + zdetnh4 + zdomaju
+               zdeta = zphydet + zzoodet  - zdetzoo - zdetnh4 - zdetdom + zboddet
+               zdoma = zphydom + zzoodom + zdetdom - zdomnh4 - zdomaju
+
+               ! tracer flux at totox-point added to the general trend
+               tra(ji,jj,jk,jpdet) = tra(ji,jj,jk,jpdet) + zdeta
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) + zzooa
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) + zphya
+               tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) + zno3a
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + znh4a
+               tra(ji,jj,jk,jpdom) = tra(ji,jj,jk,jpdom) + zdoma
+               !
+#if defined key_trc_diabio
+               trbio(ji,jj,jk,jp_lob0_trd     ) = zno3phy
+               trbio(ji,jj,jk,jp_lob0_trd +  1) = znh4phy
+               trbio(ji,jj,jk,jp_lob0_trd +  2) = zphynh4
+               trbio(ji,jj,jk,jp_lob0_trd +  3) = zphydom
+               trbio(ji,jj,jk,jp_lob0_trd +  4) = zphyzoo
+               trbio(ji,jj,jk,jp_lob0_trd +  5) = zphydet
+               trbio(ji,jj,jk,jp_lob0_trd +  6) = zdetzoo
+               trbio(ji,jj,jk,jp_lob0_trd +  8) = zzoodet
+               trbio(ji,jj,jk,jp_lob0_trd +  9) = zzoobod
+               trbio(ji,jj,jk,jp_lob0_trd + 10) = zzoonh4
+               trbio(ji,jj,jk,jp_lob0_trd + 11) = zzoodom
+               trbio(ji,jj,jk,jp_lob0_trd + 12) = znh4no3
+               trbio(ji,jj,jk,jp_lob0_trd + 13) = zdomnh4
+               trbio(ji,jj,jk,jp_lob0_trd + 14) = zdetnh4
+               trbio(ji,jj,jk,jp_lob0_trd + 15) = zdetdom
+#endif
+               IF( l_trdtrc ) THEN
+                  ztrbio(ji,jj,jk,jp_lob0_trd     ) = zno3phy
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  1) = znh4phy
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  2) = zphynh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  3) = zphydom
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  4) = zphyzoo
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  5) = zphydet
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  6) = zdetzoo
+                  !  trend number 8 in trcsed
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  8) = zzoodet
+                  ztrbio(ji,jj,jk,jp_lob0_trd +  9) = zzoobod
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 10) = zzoonh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 11) = zzoodom
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 12) = znh4no3
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 13) = zdomnh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 14) = zdetnh4
+                  ztrbio(ji,jj,jk,jp_lob0_trd + 15) = zdetdom
+                  !  trend number 17 in trcexp
+                ENDIF
+#if defined key_trc_diaadd && defined key_trc_dia3d
+# if ! defined key_iomput
+               trc3d(ji,jj,jk,jp_lob0_3d    ) =  zno3phy * 86400     
+               trc3d(ji,jj,jk,jp_lob0_3d + 1) =  znh4phy * 86400     
+               trc3d(ji,jj,jk,jp_lob0_3d + 2) =  znh4no3 * 86400     
+# else
+               zw3d(ji,jj,jk,1) = zno3phy * 86400     
+               zw3d(ji,jj,jk,2) = znh4phy * 86400     
+               zw3d(ji,jj,jk,3) = znh4no3 * 86400   
+# endif
+#endif
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd
+      ! Lateral boundary conditions 
+# if ! defined key_iomput
+      DO jl = jp_lob0_2d, jp_lob1_2d
+          CALL lbc_lnk( trc2d(:,:,jl),'T', 1. )
+      END DO 
+# else
+      DO jl = 1, 17 
+          CALL lbc_lnk( zw2d(:,:,jl),'T', 1. )
+      END DO
+      ! Save diagnostics
+      CALL iom_put( "TNO3PHY", zw2d(:,:,1) )
+      CALL iom_put( "TNH4PHY", zw2d(:,:,2) )
+      CALL iom_put( "TPHYDOM", zw2d(:,:,3) )
+      CALL iom_put( "TPHYNH4", zw2d(:,:,4) )
+      CALL iom_put( "TPHYZOO", zw2d(:,:,5) )
+      CALL iom_put( "TPHYDET", zw2d(:,:,6) )
+      CALL iom_put( "TDETZOO", zw2d(:,:,7) )
+      CALL iom_put( "TZOODET", zw2d(:,:,8) )
+      CALL iom_put( "TZOOBOD", zw2d(:,:,9) )
+      CALL iom_put( "TZOONH4", zw2d(:,:,10) )
+      CALL iom_put( "TZOODOM", zw2d(:,:,11) )
+      CALL iom_put( "TNH4NO3", zw2d(:,:,12) )
+      CALL iom_put( "TDOMNH4", zw2d(:,:,13) )
+      CALL iom_put( "TDETNH4", zw2d(:,:,14) )
+      CALL iom_put( "TPHYTOT", zw2d(:,:,15) )
+      CALL iom_put( "TZOOTOT", zw2d(:,:,16) )
+      CALL iom_put( "TDETDOM", zw2d(:,:,17) )
+# endif
+#endif
+
+#if defined key_trc_diaadd && defined key_trc_dia3d
+      ! Lateral boundary conditions 
+# if ! defined key_iomput
+      DO jl = jp_lob0_3d, jp_lob1_3d
+          CALL lbc_lnk( trc3d(:,:,1,jl),'T', 1. )
+      END DO 
+# else
+      DO jl = 1, 3
+          CALL lbc_lnk( zw3d(:,:,:,jl),'T', 1. )
+      END DO
+      ! save diagnostics
+      CALL iom_put( "FNO3PHY", zw3d(:,:,:,1) )
+      CALL iom_put( "FNH4PHY", zw3d(:,:,:,2) )
+      CALL iom_put( "FNH4NO3", zw3d(:,:,:,3) )
+# endif 
+#endif
+
+#if defined key_trc_diabio
+      ! Lateral boundary conditions on trcbio
+      DO jl = jp_lob0_trd, jp_lob1_trd
+          CALL lbc_lnk( trbio(:,:,1,jl),'T', 1. )
+      END DO 
+#endif
+      !
+      IF( l_trdtrc ) THEN
+         DO jl = jp_lob0_trd, jp_lob1_trd
+            CALL trd_mod_trc( ztrbio(:,:,:,jl), jl, kt )   ! handle the trend
+         END DO
+      ENDIF
+
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('bio')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+   END SUBROUTINE trc_bio
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_bio( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_bio: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_bio
+#endif 
+
+   !!======================================================================
+END MODULE  trcbio
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcctl_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcctl_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcctl_lobster.F90	(revision 1844)
@@ -0,0 +1,113 @@
+MODULE trcctl_lobster
+   !!======================================================================
+   !!                         ***  trcctl_lobster.F90  ***
+   !! TOP :                Control of LOBSTER biological model
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2000-12 (E. Kestenare) assign a parameter to name individual tracers
+   !!----------------------------------------------------------------------
+
+#if defined key_lobster
+
+   USE oce_trc
+   USE trc
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl_lobster     ! called by ???
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl_lobster
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_lobster  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+      INTEGER :: jl, jn
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' use LOBSTER biological model '
+
+      ! Check number of tracers
+      ! -----------------------
+      IF (jp_lobster /= 6) THEN 
+          IF (lwp) THEN 
+              WRITE (numout,*) ' ===>>>> : w a r n i n g '
+              WRITE (numout,*) ' =======   ============= '
+              WRITE (numout,*)                             &
+              &   ' STOP, change jp_lobster to 6 in '           &
+              &   ,'par_lobster.F90 '  
+          END IF 
+          STOP 'TRC_CTL'
+      END IF 
+
+      ! Check tracer names
+      ! ------------------
+      IF(   ctrcnm(jpdet) /= 'DET' .OR. ctrcnm(jpzoo) /= 'ZOO' .OR.   &
+         &  ctrcnm(jpphy) /= 'PHY' .OR. ctrcnm(jpno3) /= 'NO3' .OR.   &
+         &  ctrcnm(jpnh4) /= 'NH4' .OR. ctrcnm(jpdom) /= 'DOM' .OR.   & 
+         &  ctrcnl(jpdet) /= 'Detritus'                        .OR.   &
+         &  ctrcnl(jpzoo) /= 'Zooplankton concentration'       .OR.   &
+         &  ctrcnl(jpphy) /= 'Phytoplankton concentration'     .OR.   &
+         &  ctrcnl(jpno3) /= 'Nitrate concentration'           .OR.   &
+         &  ctrcnl(jpnh4) /= 'Ammonium concentration'          .OR.   &
+         &  ctrcnl(jpdom) /= 'Dissolved organic matter' ) THEN 
+         ctrcnm(jpdet)='DET'
+         ctrcnl(jpdet)='Detritus'
+         ctrcnm(jpzoo)='ZOO'
+         ctrcnl(jpzoo)='Zooplankton concentration'
+         ctrcnm(jpphy)='PHY'
+         ctrcnl(jpphy)='Phytoplankton concentration'
+         ctrcnm(jpno3)='NO3'
+         ctrcnl(jpno3)='Nitrate concentration'
+         ctrcnm(jpnh4)='NH4'
+         ctrcnl(jpnh4)='Ammonium concentration'
+         ctrcnm(jpdom)='DOM'
+         ctrcnl(jpdom)='Dissolved organic matter'          
+         IF(lwp) THEN
+            WRITE (numout,*) ' ===>>>> : w a r n i n g '
+            WRITE (numout,*) ' =======   ============= '
+            WRITE (numout,*) ' we force tracer names'
+            DO jl = 1, jp_lobster
+               jn = jp_lob0 + jl - 1
+               WRITE(numout,*) ' tracer nb: ',jn,' name = ',ctrcnm(jn), ctrcnl(jn)
+            END DO
+            WRITE(numout,*) ' '
+         ENDIF 
+      ENDIF 
+
+      ! Check tracer units
+      DO jl = 1, jp_lobster
+         jn = jp_lob0 + jl - 1
+         IF( ctrcun(jn) /= 'mmole-N/m3') THEN
+            ctrcun(jn) = 'mmole-N/m3'
+            IF(lwp) THEN
+               WRITE (numout,*) ' ===>>>> : w a r n i n g '
+               WRITE (numout,*) ' =======   ============= '
+               WRITE (numout,*) ' we force tracer unit'
+               WRITE(numout,*) ' tracer  ',ctrcnm(jn), 'UNIT= ',ctrcun(jn)
+            ENDIF 
+         ENDIF 
+      END DO              
+   END SUBROUTINE trc_ctl_lobster
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                          No LOBSTER
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl_lobster                 ! Dummy routine
+   END SUBROUTINE trc_ctl_lobster
+#endif
+
+   !!======================================================================
+END MODULE trcctl_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcexp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 1844)
@@ -0,0 +1,188 @@
+MODULE trcexp
+   !!======================================================================
+   !!                         ***  MODULE p4sed  ***
+   !! TOP :   PISCES Compute loss of organic matter in the sediments
+   !!======================================================================
+   !! History :    -   !  1999    (O. Aumont, C. Le Quere)  original code
+   !!              -   !  2001-05 (O. Aumont, E. Kestenare) add sediment computations
+   !!             1.0  !  2005-06 (A.-S. Kremeur) new temporal integration for sedpoc
+   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                     LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !!   trc_exp        :  Compute loss of organic matter in the sediments
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE sms_lobster
+   USE lbclnk
+   USE trc
+   USE trctrp_lec
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_exp    ! called in p4zprg.F90
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_exp( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_exp  ***
+      !!
+      !! ** Purpose :   MODELS EXPORT OF BIOGENIC MATTER (POC ''SOFT
+      !!              TISSUE'') AND ITS DISTRIBUTION IN WATER COLUMN
+      !!
+      !! ** Method  : - IN THE SURFACE LAYER POC IS PRODUCED ACCORDING TO
+      !!              NURTRIENTS AVAILABLE AND GROWTH CONDITIONS. NUTRIENT UPTAKE
+      !!              KINETICS FOLLOW MICHAELIS-MENTON FORMULATION. 
+      !!              THE TOTAL PARTICLE AMOUNT PRODUCED, IS DISTRIBUTED IN THE WATER
+      !!              COLUMN BELOW THE SURFACE LAYER.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      INTEGER  ::   ji, jj, jk, jl, ikbot
+      REAL(wp) ::   zgeolpoc, zfact, zwork, ze3t
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrbio
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' trc_exp: LOBSTER export'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+      ENDIF
+
+      ! VERTICAL DISTRIBUTION OF NEWLY PRODUCED BIOGENIC
+      ! POC IN THE WATER COLUMN
+      ! (PARTS OF NEWLY FORMED MATTER REMAINING IN THE DIFFERENT
+      ! LAYERS IS DETERMINED BY DMIN3 DEFINED IN sms_lobster.F90
+      ! ----------------------------------------------------------------------
+
+      IF( l_trdtrc )THEN
+         ALLOCATE( ztrbio(jpi,jpj,jpk) )
+         ztrbio(:,:,:) = tra(:,:,:,jpno3)
+      ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ze3t = 1. / fse3t(ji,jj,jk)
+               tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) + ze3t * dmin3(ji,jj,jk) * fbod(ji,jj)
+            END DO
+         END DO
+      END DO
+
+      ! Find the last level of the water column
+      ! Compute fluxes due to sinking particles (slow)
+   
+
+      zgeolpoc = 0.e0         !     Initialization
+      ! Release of nutrients from the "simple" sediment
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            ikbot = mbathy(ji,jj) - 1
+            tra(ji,jj,ikbot,jpno3) = tra(ji,jj,ikbot,jpno3) + sedlam * sedpocn(ji,jj) / fse3t(ji,jj,ikbot) 
+            ! Deposition of organic matter in the sediment
+            zwork = vsed * trn(ji,jj,ikbot,jpdet)
+            sedpoca(ji,jj) = ( zwork + dminl(ji,jj) * fbod(ji,jj)   &
+               &           - sedlam * sedpocn(ji,jj) - sedlostpoc * sedpocn(ji,jj) ) * rdt
+            zgeolpoc = zgeolpoc + sedlostpoc * sedpocn(ji,jj) * e1t(ji,jj) * e2t(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            tra(ji,jj,1,jpno3) = tra(ji,jj,1,jpno3) + zgeolpoc * cmask(ji,jj) / areacot / fse3t(ji,jj,1)
+         END DO
+      END DO
+
+      CALL lbc_lnk( sedpocn, 'T', 1. )
+ 
+      ! Oa & Ek: diagnostics depending on jpdia2d !          left as example
+#if defined key_trc_diaadd
+# if ! defined key_iomput
+      trc2d(:,:,jp_lob0_2d + 18) = sedpocn(:,:)
+# else
+     CALL iom_put( "SEDPOC" , sedpocn )
+# endif
+#endif
+
+      ! Leap-frog scheme (only in explicit case, otherwise the 
+      ! ----------------  time stepping is already done in trczdf)
+      IF( l_trczdf_exp .AND. (ln_trcadv_cen2 .OR. ln_trcadv_tvd) ) THEN
+         zfact = 2. * rdttra(jk) * FLOAT( ndttrc ) 
+         IF( neuler == 0 .AND. kt == nittrc000 )   zfact = rdttra(jk) * FLOAT(ndttrc) 
+         sedpoca(:,:) =  sedpocb(:,:) + zfact * sedpoca(:,:) 
+      ENDIF
+
+      
+      ! Time filter and swap of arrays
+      ! ------------------------------
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd  ) THEN         ! centred or tvd scheme
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  sedpocb(ji,jj) = sedpocn(ji,jj)
+                  sedpocn(ji,jj) = sedpoca(ji,jj)
+                  sedpoca(ji,jj) = 0.e0
+               END DO
+            END DO
+         ELSE
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  sedpocb(ji,jj) = atfp  * ( sedpocb(ji,jj) + sedpoca(ji,jj) )    &
+                     &           + atfp1 *   sedpocn(ji,jj)
+                  sedpocn(ji,jj) = sedpoca(ji,jj)
+                  sedpoca(ji,jj) = 0.e0
+               END DO
+            END DO
+         ENDIF
+      ELSE                                                   !  case of smolar scheme or muscl
+         sedpocb(:,:) = sedpoca(:,:)
+         sedpocn(:,:) = sedpoca(:,:)
+         sedpoca(:,:) = 0.e0
+      ENDIF
+      !
+      IF( l_trdtrc ) THEN
+         ztrbio(:,:,:) = tra(:,:,:,jpno3) - ztrbio(:,:,:)
+         jl = jp_lob0_trd + 16
+         CALL trd_mod_trc( ztrbio, jl, kt )   ! handle the trend
+      ENDIF
+
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('exp')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+   END SUBROUTINE trc_exp
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_exp( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_exp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_exp
+#endif 
+
+   !!======================================================================
+END MODULE  trcexp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 1844)
@@ -0,0 +1,271 @@
+MODULE trcini_lobster
+   !!======================================================================
+   !!                         ***  MODULE trcini_lobster  ***
+   !! TOP :   initialisation of the LOBSTER biological model
+   !!======================================================================
+   !! History :    -   !  1999-09  (M. Levy) Original code
+   !!              -   !  2000-12  (0. Aumont, E. Kestenare) add sediment 
+   !!             1.0  !  2004-03  (C. Ethe) Modularity
+   !!              -   !  2005-03  (O. Aumont, A. El Moussaoui) F90
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trcini.lobster1.h90
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                     LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !! trc_ini_lobster  : LOBSTER model initialisation
+   !!----------------------------------------------------------------------
+   USE par_trc         ! TOP parameters
+   USE sms_lobster     ! Source Minus Sink variables
+   USE oce_trc         ! ocean variables
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_ini_lobster   ! called by trcini.F90 module
+
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ini_lobster
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE trc_ini_lobster  ***
+      !! ** purpose :   specific initialisation for LOBSTER bio-model
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk, jn
+      REAL(wp) ::   ztest, zfluo, zfluu
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zrro
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdm0
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_lobster :   LOBSTER biochemical model initialisation'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
+
+
+      ! initialization of fields for optical model
+      ! --------------------------------------------
+      xze (:,:)   = 5.e0
+      xpar(:,:,:) = 0.e0
+
+      ! initialization for passive tracer remineralisation-damping  array
+      ! -----------------------------------------------------------------
+
+      DO jn = jp_lob0, jp_lob1
+         remdmp(:,jn) = tminr
+      END DO
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' trcini: compute remineralisation-damping  '
+         WRITE(numout,*) '         arrays for tracers'
+      ENDIF
+
+      ! initialization of biological variables
+      ! ------------------------------------------
+
+      ! Calculate vertical distribution of newly formed biogenic poc
+      ! in the water column in the case of max. possible bottom depth
+      ! ------------------------------------------------------------
+
+      zdm0   = 0.e0
+      zrro = 1.e0
+      DO jk = jpkb,jpkm1
+         DO jj =1, jpj
+            DO ji =1, jpi
+               zfluo = ( fsdepw(ji,jj,jk  ) / fsdepw(ji,jj,jpkb) )**xhr 
+               zfluu = ( fsdepw(ji,jj,jk+1) / fsdepw(ji,jj,jpkb) )**xhr
+               IF( zfluo.GT.1. )   zfluo = 1.e0
+               zdm0(ji,jj,jk) = zfluo - zfluu
+               IF( jk <= jpkb-1 )   zdm0(ji,jj,jk) = 0.e0
+               zrro(ji,jj) = zrro(ji,jj) - zdm0(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      zdm0(:,:,jpk) = zrro(:,:)
+
+      ! Calculate vertical distribution of newly formed biogenic poc
+      ! in the water column with realistic topography (first "dry" layer
+      ! contains total fraction, which has passed to the upper layers)
+      ! ----------------------------------------------------------------------
+      dminl = 0.
+      dmin3 = zdm0
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) == 0. ) THEN
+                  dminl(ji,jj) = dminl(ji,jj) + dmin3(ji,jj,jk)
+                  dmin3(ji,jj,jk) = 0.e0
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 0 )   dmin3(ji,jj,1) = 0.e0
+         END DO
+      END DO
+
+      ! Coastal mask 
+      ! ------------   
+      cmask = 0.e0
+      DO ji = 2, jpi-1
+         DO jj = 2, jpj-1
+            if (tmask(ji,jj,1) == 1) then
+               ztest=tmask(ji+1,jj,1)*tmask(ji-1,jj,1)*tmask(ji,jj+1,1)*tmask(ji,jj-1,1)
+               IF (ztest == 0) cmask(ji,jj) = 1.
+            endif
+         END DO
+      END DO
+
+      cmask( 1 ,:) = cmask(jpi-1,:)
+      cmask(jpi,:) = cmask( 2   ,:)
+
+      !!gm BUG !!!!!   not valid in mpp and also not valid for north fold   !!!!!
+
+      ! Coastal surface
+      ! ---------------
+      areacot = 0.e0
+      DO ji = 2, jpi-1
+         DO jj = 2, jpj-1
+            areacot = areacot + e1t(ji,jj) * e2t(ji,jj) * cmask(ji,jj)
+         END DO
+      END DO
+      !
+
+      ! Initialization of tracer concentration in case of  no restart 
+      !-------------------------------------------------------------
+      IF( .NOT. ln_rsttr ) THEN    
+
+# if defined key_eel_r6 || defined key_eel_r2
+         ! LOBSTER initialisation for EEL
+         ! ----------------------
+         ! here: analytical initialisation used in Levy et al. (2001)
+         
+         DO jk = 1, 7
+            trn(:,:,jk,jpdet) = 0.016 * tmask(:,:,jk)
+            trn(:,:,jk,jpzoo) = 0.018 * tmask(:,:,jk)
+            trn(:,:,jk,jpphy) = 0.036 * tmask(:,:,jk) 
+            trn(:,:,jk,jpno3) = 1.e-5 * tmask(:,:,jk)
+            trn(:,:,jk,jpnh4) = 5.e-4 * tmask(:,:,jk)
+            trn(:,:,jk,jpdom) = 0.017 * tmask(:,:,jk)
+         END DO
+         
+         trn(:,:, 8,jpdet) = 0.020   * tmask(:,:, 8)
+         trn(:,:, 8,jpzoo) = 0.027   * tmask(:,:, 8)
+         trn(:,:, 8,jpphy) = 0.041   * tmask(:,:, 8)
+         trn(:,:, 8,jpno3) = 0.00022 * tmask(:,:, 8)
+         trn(:,:, 8,jpnh4) = 0.0033  * tmask(:,:, 8)
+         trn(:,:, 8,jpdom) = 0.021   * tmask(:,:, 8)
+         
+         trn(:,:, 9,jpdet) = 0.0556  * tmask(:,:, 9)
+         trn(:,:, 9,jpzoo) = 0.123   * tmask(:,:, 9)
+         trn(:,:, 9,jpphy) = 0.122   * tmask(:,:, 9)
+         trn(:,:, 9,jpno3) = 0.028   * tmask(:,:, 9)
+         trn(:,:, 9,jpnh4) = 0.024   * tmask(:,:, 9)
+         trn(:,:, 9,jpdom) = 0.06    * tmask(:,:, 9)
+         
+         trn(:,:,10,jpdet) = 0.025   * tmask(:,:,10)
+         trn(:,:,10,jpzoo) = 0.016   * tmask(:,:,10)
+         trn(:,:,10,jpphy) = 0.029   * tmask(:,:,10)
+         trn(:,:,10,jpno3) = 2.462   * tmask(:,:,10)
+         trn(:,:,10,jpnh4) = 0.04    * tmask(:,:,10)
+         trn(:,:,10,jpdom) = 0.022   * tmask(:,:,10)
+         
+         trn(:,:,11,jpdet) = 0.0057  * tmask(:,:,11)
+         trn(:,:,11,jpzoo) = 0.0005  * tmask(:,:,11)
+         trn(:,:,11,jpphy) = 0.0006  * tmask(:,:,11)
+         trn(:,:,11,jpno3) = 3.336   * tmask(:,:,11)
+         trn(:,:,11,jpnh4) = 0.005   * tmask(:,:,11)
+         trn(:,:,11,jpdom) = 0.004   * tmask(:,:,11)
+         
+         trn(:,:,12,jpdet) = 0.002   * tmask(:,:,12)
+         trn(:,:,12,jpzoo) = 1.e-6   * tmask(:,:,12)
+         trn(:,:,12,jpphy) = 5.e-6   * tmask(:,:,12)
+         trn(:,:,12,jpno3) = 4.24    * tmask(:,:,12)
+         trn(:,:,12,jpnh4) = 0.001   * tmask(:,:,12)
+         trn(:,:,12,jpdom) = 3.e-5   * tmask(:,:,12)
+         
+         DO jk=13,jpk
+            trn(:,:,jk,jpdet) = 0.e0
+            trn(:,:,jk,jpzoo) = 0.e0
+            trn(:,:,jk,jpphy) = 0.e0
+            trn(:,:,jk,jpnh4) = 0.e0
+            trn(:,:,jk,jpdom) = 0.e0
+         END DO
+         
+         trn(:,:,13,jpno3) = 5.31  * tmask(:,:,13)
+         trn(:,:,14,jpno3) = 6.73  * tmask(:,:,14)
+         trn(:,:,15,jpno3) = 8.32  * tmask(:,:,15)
+         trn(:,:,16,jpno3) = 10.13 * tmask(:,:,16)
+         trn(:,:,17,jpno3) = 11.95 * tmask(:,:,17)
+         trn(:,:,18,jpno3) = 13.57 * tmask(:,:,18)
+         trn(:,:,19,jpno3) = 15.08 * tmask(:,:,19)
+         trn(:,:,20,jpno3) = 16.41 * tmask(:,:,20)
+         trn(:,:,21,jpno3) = 17.47 * tmask(:,:,21)
+         trn(:,:,22,jpno3) = 18.29 * tmask(:,:,22)
+         trn(:,:,23,jpno3) = 18.88 * tmask(:,:,23)
+         trn(:,:,24,jpno3) = 19.30 * tmask(:,:,24)
+         trn(:,:,25,jpno3) = 19.68 * tmask(:,:,25)
+         trn(:,:,26,jpno3) = 19.91 * tmask(:,:,26)
+         trn(:,:,27,jpno3) = 19.99 * tmask(:,:,27)
+         trn(:,:,28,jpno3) = 20.01 * tmask(:,:,28)
+         trn(:,:,29,jpno3) = 20.01 * tmask(:,:,29)
+         trn(:,:,30,jpno3) = 20.01 * tmask(:,:,30)
+
+# elif defined key_gyre
+         ! LOBSTER initialisation for GYRE
+         ! ----------------------
+         ! here:  init NO3=f(density) by asklod AS Kremeur 2005-07
+         trn(:,:,:,jpdet) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jpzoo) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jpnh4) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jpphy) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jpdom) = 1.0 * tmask(:,:,:)
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( rhd(ji,jj,jk) <= 24.5e-3 ) THEN
+                     trn(ji,jj,jk,jpno3) = 2. * tmask(ji,jj,jk)
+                  ELSE
+                     trn(ji,jj,jk,jpno3) = ( 15.55 * ( rhd(ji,jj,jk) * 1000. ) - 380.11 ) * tmask(ji,jj,jk)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+#endif
+
+      ENDIF
+
+      !  initialize the POC in sediments
+      sedpocb(:,:) = 0.e0
+      sedpocn(:,:) = 0.e0
+      sedpoca(:,:) = 0.e0
+
+
+      IF(lwp) WRITE(numout,*) 'Initialization of LOBSTER tracers done'
+      IF(lwp) WRITE(numout,*) ' '
+
+
+   END SUBROUTINE trc_ini_lobster
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                   No LOBSTER bio-model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini_lobster             ! Empty routine
+   END SUBROUTINE trc_ini_lobster
+#endif
+
+   !!======================================================================
+END MODULE trcini_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trclsm_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trclsm_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trclsm_lobster.F90	(revision 1844)
@@ -0,0 +1,393 @@
+MODULE trclsm_lobster
+   !!======================================================================
+   !!                      ***  MODULE trclsm_lobster  ***
+   !! TOP :   initialisation of some run parameters for LOBSTER bio-model
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) from trclsm.lobster1.h90
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'   :                                 LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !! trc_lsm_lobster      : LOBSTER model namelist read
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE sms_lobster     ! sms trends
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_lsm_lobster   ! called by trclsm.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lsm_lobster
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_lsm_lobster  ***  
+      !!
+      !! ** Purpose :   read LOBSTER namelist
+      !!
+      !! ** input   :   file 'namelist.trc.sms' containing the following
+      !!             namelist: natbio, natopt, and natdbi ("key_trc_diabio")
+      !!----------------------------------------------------------------------
+      INTEGER ::   numnatl
+      !!
+#if defined key_trc_diaadd && ! defined key_iomput
+      INTEGER :: jl, jn
+      ! definition of additional diagnostic as a structure
+      TYPE DIAG
+         CHARACTER(len = 20)  :: snamedia   !: short name
+         CHARACTER(len = 80 ) :: lnamedia   !: long name
+         CHARACTER(len = 20 ) :: unitdia    !: unit
+      END TYPE DIAG
+
+      TYPE(DIAG) , DIMENSION(jp_lobster_2d) :: lobdia2d
+      TYPE(DIAG) , DIMENSION(jp_lobster_3d) :: lobdia3d
+#endif
+#if defined key_trc_diabio || defined key_trdmld_trc
+      INTEGER :: js, jd
+      ! definition of additional diagnostic as a structure
+      TYPE DIABIO
+         CHARACTER(len = 20)  :: snamebio   !: short name
+         CHARACTER(len = 80 ) :: lnamebio   !: long name
+         CHARACTER(len = 20 ) :: unitbio    !: unit
+      END TYPE DIABIO
+
+      TYPE(DIABIO) , DIMENSION(jp_lobster_trd) :: lobdiabio
+#endif
+
+      NAMELIST/namlobphy/ apmin, tmumax, rgamma, fphylab, tmmaxp, tmminp, &
+         &                rcchl, aki, toptp 
+      NAMELIST/namlobnut/ anmin, akno3, aknh4, taunn, psinut
+      NAMELIST/namlobzoo/ azmin, eggzoo, rgz, rppz, taus, aks, rpnaz,     &
+         &                rdnaz, tauzn, fzoolab, fdbod, tmmaxz, tmminz
+      NAMELIST/namlobdet/ admin, taudn, fdetlab, vsed
+      NAMELIST/namlobdom/ taudomn
+      NAMELIST/namlobsed/ sedlam, sedlostpoc
+      NAMELIST/namlobrat/ redf, reddom, slopet, tmaxr, tminr, xhr,        &
+         &                filmax, toptgz, tmaxgz, anumin, afdmin
+
+      NAMELIST/namlobopt/ xkg0, xkr0, xkgp, xkrp, xlg, xlr, rpig
+#if defined key_trc_diaadd && ! defined key_iomput
+      NAMELIST/namlobdia/nwritedia, lobdia3d, lobdia2d     ! additional diagnostics
+#endif
+#if defined key_trc_diabio || defined key_trdmld_trc
+      NAMELIST/namlobdbi/nwritebio, lobdiabio
+#endif
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_lsm_lobster : read LOBSTER namelists'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
+
+      !                               ! Open the namelist file
+      !                               ! ----------------------
+      CALL ctl_opn( numnatl, 'namelist_lobster', 'OLD', 'FORMATTED', 'SEQUENTIAL', 1, numout, .FALSE. )
+
+      ! namlobphy : parameters for phytoplankton
+      apmin   = 0. 
+      tmumax  = 0. 
+      rgamma  = 0. 
+      fphylab = 0.  
+      tmmaxp  = 0.
+      tmminp  = 0.
+      rcchl   = 0. 
+      aki     = 0. 
+      toptp   = 0. 
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobphy )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobphy'
+          WRITE(numout,*) '    minimum phytoplancton concentration                  apmin     =', apmin
+          WRITE(numout,*) '    phyto max growth rate                                tmumax    =', 86400 * tmumax, ' d'
+          WRITE(numout,*) '    phytoplankton exudation fraction                     rgamma    =', rgamma
+          WRITE(numout,*) '    NH4 fraction of phytoplankton exsudation             fphylab   =', fphylab
+          WRITE(numout,*) '    maximal phyto mortality rate                         tmmaxp    =', 86400 * tmmaxp
+          WRITE(numout,*) '    minimal phyto mortality rate                         tmminp    =', 86400 * tmminp
+          WRITE(numout,*) '    carbone/chlorophyl ratio                             rcchl     =', rcchl
+          WRITE(numout,*) '    light hlaf saturation constant                       aki       =', aki
+          WRITE(numout,*) '    optimal photosynthesis temperature                   toptp     =', toptp
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobnut : parameters for nutrients
+      anmin  = 0.
+      psinut = 0.
+      akno3  = 0.
+      aknh4  = 0.
+      taunn  = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobnut )
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobnut'
+          WRITE(numout,*) '    minimum nutrients     concentration                  anmin     =', anmin
+          WRITE(numout,*) '    half-saturation nutrient for no3 uptake              akno3     =', akno3
+          WRITE(numout,*) '    half-saturation nutrient for nh4 uptake              aknh4     =', aknh4
+          WRITE(numout,*) '    nitrification rate                                   taunn     =', taunn
+          WRITE(numout,*) '    inhibition of no3 uptake by nh4                      psinut    =', psinut
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobzoo : parameters for zooplankton
+      azmin   = 0.
+      rgz     = 0.
+      rppz    = 0.
+      taus    = 0.
+      aks     = 0.
+      rpnaz   = 0.
+      rdnaz   = 0.
+      eggzoo  = 0.
+      tauzn   = 0.
+      tmmaxz  = 0.
+      tmminz  = 0.
+      fzoolab = 0.
+      fdbod   = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobzoo )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobzoo'
+          WRITE(numout,*) '    minimum zooplancton   concentration                  azmin     =', azmin
+          WRITE(numout,*) '    minimum  for zoo concentration                       eggzoo    =', eggzoo
+          WRITE(numout,*) '    widtht of zoo temperature FUNCTION                   rgz       =', rgz
+          WRITE(numout,*) '    zoo preference for phyto                             rppz      =', rppz
+          WRITE(numout,*) '    maximal zoo grazing rate                             taus      =', 86400 * taus, ' d'
+          WRITE(numout,*) '    half saturation constant for zoo food                aks       =', aks
+          WRITE(numout,*) '    non-assimilated phyto by zoo                         rpnaz     =', rpnaz
+          WRITE(numout,*) '    non-assimilated detritus by zoo                      rdnaz     =', rdnaz
+          WRITE(numout,*) '    zoo specific excretion rate                          tauzn     =', 86400 * tauzn
+          WRITE(numout,*) '    maximal zoo mortality rate                           tmmaxz    =', 86400 * tmmaxz
+          WRITE(numout,*) '    minimal zoo mortality rate                           tmminz    =', 86400 * tmminz
+          WRITE(numout,*) '    NH4 fraction of zooplankton excretion                fzoolab   =', fzoolab
+          WRITE(numout,*) '    Zooplankton mortality fraction that goes to detritus fdbod     =', fdbod
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobdet : parameters for detritus
+      admin   = 0.
+      taudn   = 0.
+      vsed    = 0.
+      fdetlab = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobdet )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobdet'
+          WRITE(numout,*) '    minimum detritus      concentration                  admin     =', admin
+          WRITE(numout,*) '    detrital breakdown rate                              taudn     =', 86400 * taudn , ' d'
+          WRITE(numout,*) '    detritus sedimentation speed                         vsed      =', 86400 * vsed  , ' d'
+          WRITE(numout,*) '    NH4 fraction of detritus dissolution                 fdetlab   =', fdetlab
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobdom : parameters for DOM
+      taudomn = 0.
+
+      REWIND( numnatl ) 
+      READ  ( numnatl, namlobdom )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobdom'
+          WRITE(numout,*) '    dom remineralisation rate                            taudomn   =', taudomn
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobsed : parameters from aphotic layers to sediment
+      sedlam     = 0.
+      sedlostpoc = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobsed )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobsed'
+          WRITE(numout,*) '    time coeff of POC in sediments                       sedlam    =', sedlam
+          WRITE(numout,*) '    Sediment geol loss for POC                           sedlostpoc=', sedlostpoc
+          WRITE(numout,*) ' '
+      ENDIF
+
+      ! namlobrat : general coefficient
+      redf   = 0.
+      reddom = 0.
+      slopet = 0.
+      tmaxr  = 1./(     4.*rday)*0.
+      tminr  = 1./(24.*30.*rday)*0.
+      xhr    = 0.
+      filmax = 0.
+      toptgz = 0.
+      tmaxgz = 0.
+      anumin = 0.
+      afdmin = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobrat )
+
+      IF(lwp) THEN
+          WRITE(numout,*) ' Namelist namlobrat'
+          WRITE(numout,*) '    redfield ratio  c:n for phyto                        redf      =', redf 
+          WRITE(numout,*) '    redfield ratio  c:n for DOM                          reddom    =', reddom 
+          WRITE(numout,*) '    van t hoff coefficient                               slopet    =', slopet
+          WRITE(numout,*) '    maximum damping for d z or p                         tmaxr     =', tmaxr
+          WRITE(numout,*) '    damping-remineralisation rate                        tminr     =', tminr
+          WRITE(numout,*) '    coeff for martin''s remineralistion                  xhr       =', xhr
+          WRITE(numout,*) '    maximal mass clearance rate for zoo                  filmax    =', filmax
+          WRITE(numout,*) '    optimal temperature for zoo growth                   toptgz    =', toptgz
+          WRITE(numout,*) '    maximal temperature for zoo growth                   tmaxgz    =', tmaxgz
+          WRITE(numout,*) '    nutrient threshold for phyto mort                    anumin    =', anumin
+          WRITE(numout,*) '    food threshold for zoo mort                          afdmin    =', afdmin
+          WRITE(numout,*) ' '
+      ENDIF
+
+
+      ! namlobopt : optical parameters
+      xkg0  = 0. 
+      xkr0  = 0.
+      xkgp  = 0.
+      xkrp  = 0.
+      xlg   = 0.
+      xlr   = 0.
+      rpig  = 0.
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobopt )
+
+      IF(lwp) THEN                         
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist namlobopt'
+         WRITE(numout,*) '    green   water absorption coeff                       xkg0  = ', xkg0
+         WRITE(numout,*) '    red water absorption coeff                           xkr0  = ', xkr0
+         WRITE(numout,*) '    pigment red absorption coeff                         xkrp  = ', xkrp
+         WRITE(numout,*) '    pigment green absorption coeff                       xkgp  = ', xkgp
+         WRITE(numout,*) '    green chl exposant                                   xlg   = ', xlg
+         WRITE(numout,*) '    red   chl exposant                                   xlr   = ', xlr
+         WRITE(numout,*) '    chla/chla+phea ratio                                 rpig  = ', rpig
+         WRITE(numout,*) ' '
+      ENDIF
+
+#if defined key_trc_diaadd && ! defined key_iomput
+
+      ! Namelist namlobdia
+      ! -------------------
+      nwritedia = 10                   ! default values
+
+      DO jl = 1, jp_lobster_2d
+         jn = jp_lob0_2d + jl - 1
+         WRITE(ctrc2d(jn),'("2D_",I1)') jn                      ! short name
+         WRITE(ctrc2l(jn),'("2D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc2u(jn) = ' '                                       ! units
+      END DO
+      !                                 ! 3D output arrays
+      DO jl = 1, jp_lobster_3d
+         jn = jp_lob0_3d + jl - 1
+         WRITE(ctrc3d(jn),'("3D_",I1)') jn                      ! short name
+         WRITE(ctrc3l(jn),'("3D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc3u(jn) = ' '                                       ! units
+      END DO
+
+      REWIND( numnatl )               ! read natrtd
+      READ  ( numnatl, namlobdia )
+
+      DO jl = 1, jp_lobster_2d
+         jn = jp_lob0_2d + jl - 1
+         ctrc2d(jn) = lobdia2d(jl)%snamedia
+         ctrc2l(jn) = lobdia2d(jl)%lnamedia
+         ctrc2u(jn) = lobdia2d(jl)%unitdia
+      END DO
+
+      DO jl = 1, jp_lobster_3d
+         jn = jp_lob0_3d + jl - 1
+         ctrc3d(jn) = lobdia3d(jl)%snamedia
+         ctrc3l(jn) = lobdia3d(jl)%lnamedia
+         ctrc3u(jn) = lobdia3d(jl)%unitdia
+      END DO
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : natadd'
+         WRITE(numout,*) '    frequency of outputs for additional arrays nwritedia = ', nwritedia
+         DO jl = 1, jp_lobster_3d
+            jn = jp_lob0_3d + jl - 1
+            WRITE(numout,*) '   3d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc3d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc3l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc3u(jn))
+            WRITE(numout,*) ' '
+         END DO
+
+         DO jl = 1, jp_lobster_2d
+            jn = jp_lob0_2d + jl - 1
+            WRITE(numout,*) '   2d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc2d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc2l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc2u(jn))
+            WRITE(numout,*) ' '
+         END DO
+      ENDIF
+#endif
+
+#if defined key_trc_diabio || defined key_trdmld_trc
+      ! namlobdbi : bio diagnostics
+      nwritebio = 10                     ! default values
+
+      DO js = 1, jp_lobster_trd
+         jd = jp_lob0_trd + js - 1
+         IF(     jd <  10 ) THEN   ;   WRITE (ctrbio(jd),'("BIO_",I1)') jd      ! short name
+         ELSEIF (jd < 100 ) THEN   ;   WRITE (ctrbio(jd),'("BIO_",I2)') jd   
+         ELSE                      ;   WRITE (ctrbio(jd),'("BIO_",I3)') jd
+         ENDIF
+         WRITE(ctrbil(jd),'("BIOLOGICAL TREND NUMBER ",I2)') jd                 ! long name
+         ctrbiu(jd) = 'mmoleN/m3/s '                                            ! units
+      END DO
+
+      REWIND( numnatl )
+      READ  ( numnatl, namlobdbi ) 
+ 
+      DO js = 1, jp_lobster_trd
+         jd = jp_lob0_trd + js - 1
+         ctrbio(jd) = lobdiabio(js)%snamebio
+         ctrbil(jd) = lobdiabio(js)%lnamebio
+         ctrbiu(jd) = lobdiabio(js)%unitbio
+      END DO
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : namlobdbi'
+         WRITE(numout,*) '    frequency of outputs for biological trends nwritebio = ', nwritebio
+         DO js = 1, jp_lobster_trd
+            jd = jp_lob0_trd + js - 1
+            WRITE(numout,*) '   biological trend No : ',jd
+            WRITE(numout,*) '   short name         : ', TRIM(ctrbio(jd))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrbil(jd))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrbiu(jd))
+            WRITE(numout,*) ' '
+         END DO
+      END IF
+#endif
+      !
+   END SUBROUTINE trc_lsm_lobster
+   
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                            No LOBSTER
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lsm_lobster                      ! Empty routine
+   END  SUBROUTINE  trc_lsm_lobster
+#endif  
+
+   !!======================================================================
+END MODULE trclsm_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcopt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 1844)
@@ -0,0 +1,154 @@
+MODULE trcopt
+   !!======================================================================
+   !!                         ***  MODULE trcopt  ***
+   !! TOP :   LOBSTER Compute the light availability in the water column
+   !!======================================================================
+   !! History :    -   !  1995-05  (M. Levy) Original code
+   !!              -   !  1999-09  (J.-M. Andre, M. Levy) 
+   !!              -   !  1999-11  (C. Menkes, M.-A. Foujols) itabe initial
+   !!              -   !  2000-02  (M.A. Foujols) change x**y par exp(y*log(x))
+   !!   NEMO      2.0  !  2007-12  (C. Deltel, G. Madec)  F90
+   !!             3.2  !  2009-04  (C. Ethe, G. Madec)  minor optimisation + style
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                     LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !!   trc_opt        :   Compute the light availability in the water column
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc
+   USE sms_lobster
+   USE prtctl_trc      ! Print control for debbuging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_opt   ! called in trcprg.F90
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_opt( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_opt  ***
+      !!
+      !! ** Purpose :   computes the light propagation in the water column
+      !!              and the euphotic layer depth
+      !!
+      !! ** Method  :   local par is computed in w layers using light propagation
+      !!              mean par in t layers are computed by integration
+      !!
+!!gm please remplace the '???' by true comments
+      !! ** Action  :   xpar   ???
+      !!                neln   ???
+      !!                xze    ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! index of the time stepping
+      !!
+      INTEGER  ::   ji, jj, jk          ! dummy loop indices
+      CHARACTER (len=25) ::   charout   ! temporary character
+      REAL(wp) ::   zpig                ! log of the total pigment
+      REAL(wp) ::   zkr, zkg            ! total absorption coefficient in red and green
+      REAL(wp) ::   zcoef               ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar100         ! irradiance at euphotic layer depth
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar0m          ! irradiance just below the surface
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zparr, zparg    ! red and green compound of par
+
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' trc_opt : LOBSTER optic-model'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~ '
+      ENDIF
+
+      !                                          ! surface irradiance
+      zpar0m (:,:)   = qsr   (:,:) * 0.43        ! ------------------
+      zpar100(:,:)   = zpar0m(:,:) * 0.01
+      xpar   (:,:,1) = zpar0m(:,:)
+      zparr  (:,:,1) = zpar0m(:,:) * 0.5
+      zparg  (:,:,1) = zpar0m(:,:) * 0.5
+
+!!gm optimisation : introduce zcoef and LOG computed once for all
+
+      !                                          ! Photosynthetically Available Radiation (PAR)
+      zcoef = 12 * redf / rcchl / rpig           ! --------------------------------------
+      DO jk = 2, jpk                                  ! local par at w-levels
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+!!gm           zpig = MAX( TINY(0.), trn(ji,jj,jk-1,jpphy) ) * zcoef
+!!gm           zkr  = xkr0 + xkrp * EXP( xlr * LOG(zpig) )
+!!gm           zkg  = xkg0 + xkgp * EXP( xlg * LOG(zpig) )
+               zpig = LOG(  MAX( TINY(0.), trn(ji,jj,jk-1,jpphy) ) * zcoef  )
+               zkr  = xkr0 + xkrp * EXP( xlr * zpig )
+               zkg  = xkg0 + xkgp * EXP( xlg * zpig )
+               zparr(ji,jj,jk) = zparr(ji,jj,jk-1) * EXP( -zkr * fse3t(ji,jj,jk-1) )
+               zparg(ji,jj,jk) = zparg(ji,jj,jk-1) * EXP( -zkg * fse3t(ji,jj,jk-1) )
+            END DO
+        END DO
+      END DO
+!!gm optimisation : suppress one division
+      DO jk = 1, jpkm1                                ! mean par at t-levels
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zpig = LOG(  MAX( TINY(0.), trn(ji,jj,jk,jpphy) ) * zcoef  )
+               zkr  = xkr0 + xkrp * EXP( xlr * zpig )
+               zkg  = xkg0 + xkgp * EXP( xlg * zpig )
+!!gm           zparr(ji,jj,jk) = zparr(ji,jj,jk) / zkr / fse3t(ji,jj,jk) * ( 1 - EXP( -zkr * fse3t(ji,jj,jk) ) )
+!!gm           zparg(ji,jj,jk) = zparg(ji,jj,jk) / zkg / fse3t(ji,jj,jk) * ( 1 - EXP( -zkg * fse3t(ji,jj,jk) ) )
+               zparr(ji,jj,jk) = zparr(ji,jj,jk) / ( zkr * fse3t(ji,jj,jk) ) * ( 1 - EXP( -zkr * fse3t(ji,jj,jk) ) )
+               zparg(ji,jj,jk) = zparg(ji,jj,jk) / ( zkg * fse3t(ji,jj,jk) ) * ( 1 - EXP( -zkg * fse3t(ji,jj,jk) ) )
+               xpar (ji,jj,jk) = MAX( zparr(ji,jj,jk) + zparg(ji,jj,jk), 1.e-15 )
+            END DO
+         END DO
+      END DO
+
+      !                                          ! Euphotic layer
+      !                                          ! --------------
+      neln(:,:) = 1                                   ! euphotic layer level
+      DO jk = 1, jpk                                  ! (i.e. 1rst T-level strictly below EL bottom)
+         DO jj = 1, jpj
+           DO ji = 1, jpi
+              IF( xpar(ji,jj,jk) >= zpar100(ji,jj) )   neln(ji,jj) = jk + 1 
+              !                                       ! nb. this is to ensure compatibility with
+              !                                       ! nmld_trc definition in trd_mld_trc_zint
+           END DO
+         END DO
+      END DO
+      !                                               ! Euphotic layer depth
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            xze(ji,jj) = fsdepw(ji,jj,neln(ji,jj))
+         END DO
+      END DO 
+
+
+      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('opt')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
+      ENDIF
+      !
+   END SUBROUTINE trc_opt
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_opt( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_opt: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_opt
+#endif 
+
+   !!======================================================================
+END MODULE  trcopt
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 1844)
@@ -0,0 +1,88 @@
+MODULE trcrst_lobster
+   !!======================================================================
+   !!                       ***  MODULE trcrst_lobster  ***
+   !! TOP :   create, write, read the restart files of LOBSTER tracer
+   !!======================================================================
+   !! History :   1.0  !  2010-01 (C. Ethe) Original
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                               lobster tracers
+   !!----------------------------------------------------------------------
+   !!   trc_rst_read_lobster   : read  restart file
+   !!   trc_rst_wri_lobster    : write restart file
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_lobster          ! lobster sms trends
+   USE sms_lobster          ! lobster sms trends
+   USE in_out_manager  ! I/O manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  trc_rst_read_lobster   ! called by trcini.F90 module
+   PUBLIC  trc_rst_wri_lobster   ! called by trcini.F90 module
+
+CONTAINS
+   
+   SUBROUTINE trc_rst_read_lobster( knum ) 
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_lobster  ***  
+      !!
+      !! ** Purpose : Read in restart file specific variables from lobster model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: knum  ! unit of the restart file
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_read_lobster : Read specific variables from lobster model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      CALL iom_get( knum, jpdom_autoglo, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) ) 
+      CALL iom_get( knum, jpdom_autoglo, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) ) 
+
+   END SUBROUTINE trc_rst_read_lobster
+
+   SUBROUTINE trc_rst_wri_lobster( kt, kitrst, knum )
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_lobster  ***
+      !!
+      !! ** Purpose : Read in restart file specific variables from lobster model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: kt      ! time step
+      INTEGER, INTENT(in)  :: kitrst  ! time step of restart write
+      INTEGER, INTENT(in)  :: knum    ! unit of the restart file
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_wri_lobster : Write specific variables from lobster model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      CALL iom_rstput( kt, kitrst, knum, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) )
+      CALL iom_rstput( kt, kitrst, knum, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) )
+
+   END SUBROUTINE trc_rst_wri_lobster
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read_lobster( knum )
+     INTEGER, INTENT(in)  :: knum
+     WRITE(*,*) 'trc_rst_wri_lobster: You should not have seen this print! error?',knum
+   END SUBROUTINE trc_rst_read_lobster
+
+   SUBROUTINE trc_rst_wri_lobster( kt, kitrst, knum )
+     INTEGER, INTENT(in)  :: kt, kitrst, knum
+     WRITE(*,*) 'trc_rst_wri_lobster: You should not have seen this print! error?', kt, kitrst, knum
+   END SUBROUTINE trc_rst_wri_lobster
+#endif
+
+   !!======================================================================
+END MODULE trcrst_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsed.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 1844)
@@ -0,0 +1,160 @@
+MODULE trcsed
+   !!======================================================================
+   !!                         ***  MODULE p4sed  ***
+   !! TOP :   PISCES Compute loss of organic matter in the sediments
+   !!======================================================================
+   !! History :    -   !  1995-06 (M. Levy)  original code
+   !!              -   !  2000-12 (E. Kestenare)  clean up
+   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90 + simplifications
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                     LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !!   trc_sed        :  Compute loss of organic matter in the sediments
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc
+   USE sms_lobster
+   USE lbclnk
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE iom
+   USE prtctl_trc      ! Print control for debbuging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sed    ! called in ???
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sed( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sed  ***
+      !!
+      !! ** Purpose :   compute the now trend due to the vertical sedimentation of
+      !!              detritus and add it to the general trend of detritus equations
+      !!
+      !! ** Method  :   this ROUTINE compute not exactly the advection but the
+      !!              transport term, i.e.  dz(wt) and dz(ws)., dz(wtr)
+      !!              using an upstream scheme
+      !!              the now vertical advection of tracers is given by:
+      !!                      dz(trn wn) = 1/bt dk+1( e1t e2t vsed (trn) )
+      !!              add this trend now to the general trend of tracer (ta,sa,tra):
+      !!                             tra = tra + dz(trn wn)
+      !!        
+      !!              IF 'key_trc_diabio' is defined, the now vertical advection
+      !!              trend of passive tracers is saved for futher diagnostics.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      INTEGER  ::   ji, jj, jk, jl
+      REAL(wp) ::   ztra
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwork
+#if defined key_trc_diaadd && defined key_iomput
+      REAL(wp), DIMENSION(jpi,jpj) ::  zw2d
+#endif
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrbio
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' trc_sed: LOBSTER sedimentation'
+         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+      ENDIF
+
+      ! sedimentation of detritus  : upstream scheme
+      ! --------------------------------------------
+
+      ! for detritus sedimentation only - jpdet
+      zwork(:,:,1  ) = 0.e0      ! surface value set to zero
+      zwork(:,:,jpk) = 0.e0      ! bottom value  set to zero
+
+#if defined key_trc_diaadd && defined key_iomput
+      zw2d(:,:) = 0.
+# endif
+
+      IF( l_trdtrc )THEN
+         ALLOCATE( ztrbio(jpi,jpj,jpk) )
+         ztrbio(:,:,:) = tra(:,:,:,jpdet)
+      ENDIF
+
+      ! tracer flux at w-point: we use -vsed (downward flux)  with simplification : no e1*e2
+      DO jk = 2, jpkm1
+         zwork(:,:,jk) = -vsed * trn(:,:,jk-1,jpdet)
+      END DO
+
+      ! tracer flux divergence at t-point added to the general trend
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1,jpi
+               ztra  = - ( zwork(ji,jj,jk) - zwork(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
+               tra(ji,jj,jk,jpdet) = tra(ji,jj,jk,jpdet) + ztra
+#if defined key_trc_diabio
+               trbio(ji,jj,jk,jp_lob0_trd + 7) = ztra
+#endif
+#if defined key_trc_diaadd
+# if ! defined key_iomput
+               trc2d(ji,jj,jp_lob0_2d + 7) = trc2d(ji,jj,jp_lob0_2d + 7) + ztra * fse3t(ji,jj,jk) * 86400.
+# else
+               zw2d(ji,jj) = zw2d(ji,jj) + ztra * fse3t(ji,jj,jk) * 86400.
+# endif
+#endif
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diabio
+      jl = jp_lob0_trd + 7
+      CALL lbc_lnk (trbio(:,:,1,jl), 'T', 1. )    ! Lateral boundary conditions on trcbio
+#endif
+#if defined key_trc_diaadd
+# if ! defined key_iomput
+      jl = jp_lob0_2d + 7
+      CALL lbc_lnk( trc2d(:,:,jl), 'T', 1. )      ! Lateral boundary conditions on trc2d
+# else
+      CALL lbc_lnk( zw2d(:,:), 'T', 1. )      ! Lateral boundary conditions on zw2d
+      CALL iom_put( "TDETSED", zw2d )
+# endif
+#endif
+      !
+
+      IF( l_trdtrc ) THEN
+         ztrbio(:,:,:) = tra(:,:,:,jpdet) - ztrbio(:,:,:)
+         jl = jp_lob0_trd + 7
+         CALL trd_mod_trc( ztrbio, jl, kt )   ! handle the trend
+      ENDIF
+
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sed')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+   END SUBROUTINE trc_sed
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_sed( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sed: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sed
+#endif 
+
+   !!======================================================================
+END MODULE  trcsed
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 1844)
@@ -0,0 +1,82 @@
+MODULE trcsms_lobster
+   !!======================================================================
+   !!                         ***  MODULE trcsms_lobster  ***
+   !! TOP :   Time loop of LOBSTER model
+   !!======================================================================
+   !! History :   1.0  !            M. Levy
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+#if defined key_lobster
+   !!----------------------------------------------------------------------
+   !!   'key_lobster'                                       LOBSTER bio-model
+   !!----------------------------------------------------------------------
+   !!   trcsms_lobster        :  Time loop of passive tracers sms
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc
+   USE trcbio
+   USE trcopt
+   USE trcsed
+   USE trcexp
+   USE trdmld_trc_oce
+   USE trdmld_trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sms_lobster    ! called in trcsms.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sms_lobster( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sms_lobster  ***
+      !!
+      !! ** Purpose :  Managment of the call to Biological sources and sinks 
+      !!               routines of LOBSTER bio-model 
+      !!
+      !! ** Method  : - ???
+      !! -------------------------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      INTEGER :: jn
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrlob   ! used for lobster sms trends
+      !!
+
+      CALL trc_opt( kt )      ! optical model
+
+      CALL trc_bio( kt )      ! biological model
+
+      CALL trc_sed( kt )      ! sedimentation model
+
+      CALL trc_exp( kt )      ! export
+
+      IF( l_trdtrc ) THEN
+          DO jn = jp_lob0, jp_lob1
+            ztrlob(:,:,:) = tra(:,:,:,jn)
+            CALL trd_mod_trc( ztrlob, jn, jptrc_trd_sms, kt )   ! save trends
+          END DO
+      END IF
+
+      IF( lk_trdmld_trc )  CALL trd_mld_bio( kt )   ! trends: Mixed-layer
+
+   END SUBROUTINE trc_sms_lobster
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                     No passive tracer
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_sms_lobster( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sms_lobster: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms_lobster
+#endif 
+
+   !!======================================================================
+END MODULE  trcsms_lobster
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/par_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/par_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/par_my_trc.F90	(revision 1844)
@@ -0,0 +1,76 @@
+MODULE par_my_trc
+   !!======================================================================
+   !!                        ***  par_my_trc  ***
+   !! TOP :   set the MY_TRC parameters
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_lobster, ONLY : jp_lobster      !: number of tracers in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_2d   !: number of 2D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_3d   !: number of 3D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_trd  !: number of biological diag in LOBSTER
+
+   USE par_pisces , ONLY : jp_pisces       !: number of tracers in PISCES
+   USE par_pisces , ONLY : jp_pisces_2d    !: number of 2D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_3d    !: number of 3D diag in PISCES
+   USE par_pisces , ONLY : jp_pisces_trd   !: number of biological diag in PISCES
+
+   USE par_cfc    , ONLY : jp_cfc          !: number of tracers in CFC
+   USE par_cfc    , ONLY : jp_cfc_2d       !: number of tracers in CFC
+   USE par_cfc    , ONLY : jp_cfc_3d       !: number of tracers in CFC
+   USE par_cfc    , ONLY : jp_cfc_trd      !: number of tracers in CFC
+
+   USE par_c14b   , ONLY : jp_c14b         !: number of tracers in C14
+   USE par_c14b   , ONLY : jp_c14b_2d      !: number of tracers in C14
+   USE par_c14b   , ONLY : jp_c14b_3d      !: number of tracers in C14
+   USE par_c14b   , ONLY : jp_c14b_trd     !: number of tracers in C14
+
+   IMPLICIT NONE
+   PUBLIC
+
+   INTEGER, PUBLIC, PARAMETER ::   jp_lpc      = jp_lobster     + jp_pisces     + jp_cfc     + jp_c14b     !: 
+   INTEGER, PUBLIC, PARAMETER ::   jp_lpc_2d   = jp_lobster_2d  + jp_pisces_2d  + jp_cfc_2d  + jp_c14b_2d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lpc_3d   = jp_lobster_3d  + jp_pisces_3d  + jp_cfc_3d  + jp_c14b_3d  !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_lpc_trd  = jp_lobster_trd + jp_pisces_trd + jp_cfc_trd + jp_c14b_trd !:
+
+#if defined key_my_trc
+   !!---------------------------------------------------------------------
+   !!   'key_my_trc'                     user defined tracers (MY_TRC)
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_my_trc     = .TRUE.   !: PTS flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc     =  2       !: number of PTS tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_2d  =  0       !: additional 2d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_3d  =  0       !: additional 3d output arrays ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_trd =  0       !: number of sms trends for MY_TRC
+
+   ! assign an index in trc arrays for each PTS prognostic variables
+   INTEGER, PUBLIC, PARAMETER ::   jpmyt1 = jp_lpc + 1     !: 1st MY_TRC tracer
+   INTEGER, PUBLIC, PARAMETER ::   jpmyt2 = jp_lpc + 2     !: 2nd MY_TRC tracer
+
+#else
+   !!---------------------------------------------------------------------
+   !!   Default                           No user defined tracers (MY_TRC)
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_my_trc     = .FALSE.  !: MY_TRC flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc     =  0       !: No MY_TRC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_2d  =  0       !: No MY_TRC additional 2d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_3d  =  0       !: No MY_TRC additional 3d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_my_trc_trd =  0       !: number of sms trends for MY_TRC
+#endif
+
+   ! Starting/ending PISCES do-loop indices (N.B. no PISCES : jpl_pcs < jpf_pcs the do-loop are never done)
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt0     = jp_lpc     + 1              !: First index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt1     = jp_lpc     + jp_my_trc      !: Last  index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt0_2d  = jp_lpc_2d  + 1              !: First index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt1_2d  = jp_lpc_2d  + jp_my_trc_2d   !: Last  index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt0_3d  = jp_lpc_3d  + 1              !: First index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt1_3d  = jp_lpc_3d  + jp_my_trc_3d   !: Last  index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt0_trd = jp_lpc_trd + 1              !: First index of MY_TRC passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_myt1_trd = jp_lpc_trd + jp_my_trc_trd  !: Last  index of MY_TRC passive tracers
+
+   !!======================================================================
+END MODULE par_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcctl_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcctl_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcctl_my_trc.F90	(revision 1844)
@@ -0,0 +1,62 @@
+MODULE trcctl_my_trc
+   !!======================================================================
+   !!                         ***  trcctl_my_trc.F90  ***
+   !! TOP :                Control of MY_TRC biogeochemical model
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2000-12 (C. Ethe) assign a parameter to name individual tracers
+   !!----------------------------------------------------------------------
+
+#if defined key_my_trc
+
+   USE oce_trc
+   USE trc
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl_my_trc     ! called by ???
+
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl_my_trc
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_pisces  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+
+      INTEGER :: jl, jn
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' use COLOR tracer '
+
+      DO jn = 1, jp_my_trc
+         jn = jp_myt0 + jl - 1
+         WRITE(ctrcnm(jn),'(a,i2.2)') 'CLR',jn
+         ctrcnl(jn)='Color concentration'
+         ctrcun(jn)='N/A'
+      END DO
+
+
+   END SUBROUTINE trc_ctl_my_trc
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                            No PISCES
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl_my_trc               ! Dummy routine
+   END SUBROUTINE trc_ctl_my_trc
+#endif
+
+   !!======================================================================
+END MODULE trcctl_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 1844)
@@ -0,0 +1,60 @@
+MODULE trcini_my_trc
+   !!======================================================================
+   !!                         ***  MODULE trcini_my_trc  ***
+   !! TOP :   initialisation of the MY_TRC tracers
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) Original code
+   !!----------------------------------------------------------------------
+#if defined key_my_trc
+   !!----------------------------------------------------------------------
+   !!   'key_my_trc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !! trc_ini_my_trc   : MY_TRC model initialisation
+   !!----------------------------------------------------------------------
+   USE par_trc         ! TOP parameters
+   USE oce_trc
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_ini_my_trc   ! called by trcini.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ini_my_trc
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_ini_my_trc  ***  
+      !!
+      !! ** Purpose :   initialization for MY_TRC model
+      !!
+      !! ** Method  : - Read the namcfc namelist and check the parameter values
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_my_trc: initialisation of MY_TRC model'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+      
+      IF( .NOT. ln_rsttr ) trn(:,:,:,jp_myt0:jp_myt1) = 0.
+
+      !
+   END SUBROUTINE trc_ini_my_trc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                        No MY_TRC model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini_my_trc             ! Empty routine
+   END SUBROUTINE trc_ini_my_trc
+#endif
+
+   !!======================================================================
+END MODULE trcini_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trclsm_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trclsm_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trclsm_my_trc.F90	(revision 1844)
@@ -0,0 +1,58 @@
+MODULE trclsm_my_trc
+   !!======================================================================
+   !!                      ***  MODULE trclsm_my_trc  ***
+   !! TOP :   initialisation of some run parameters for LOBSTER bio-model
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) Original code
+   !!----------------------------------------------------------------------
+#if defined key_my_trc
+   !!----------------------------------------------------------------------
+   !!   'key_my_trc'   :                                       MY_TRC model
+   !!----------------------------------------------------------------------
+   !! trc_lsm_my_trc      : MY_TRC model initialisation
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_lsm_my_trc   ! called by trclsm.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lsm_my_trc
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_lsm_my_trc  ***  
+      !!
+      !! ** Purpose :   read MY_TRC namelist
+      !!
+      !! ** input   :   file 'namelist.trc.sms' containing the following
+      !!             namelist: natbio, natopt, and natdbi ("key_trc_diabio")
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_lsm_my_trc : read MY_TRC namelists'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
+      !
+   END SUBROUTINE trc_lsm_my_trc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                             No MY_TRC
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lsm_my_trc                      ! Empty routine
+   END  SUBROUTINE  trc_lsm_my_trc
+#endif  
+
+   !!======================================================================
+END MODULE trclsm_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90	(revision 1844)
@@ -0,0 +1,51 @@
+MODULE trcrst_my_trc
+   !!======================================================================
+   !!                       ***  MODULE trcrst_my_trc  ***
+   !! TOP :   create, write, read the restart files of MY_TRC tracer
+   !!======================================================================
+   !! History :   1.0  !  2010-01 (C. Ethe)  Original
+   !!----------------------------------------------------------------------
+#if defined key_my_trc
+   !!----------------------------------------------------------------------
+   !!   'key_my_trc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !!   trc_rst_read_my_trc   : read  restart file
+   !!   trc_rst_wri_my_trc    : write restart file
+   !!----------------------------------------------------------------------
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  trc_rst_read_my_trc   ! called by trcini.F90 module
+   PUBLIC  trc_rst_wri_my_trc   ! called by trcini.F90 module
+
+CONTAINS
+   
+   SUBROUTINE trc_rst_read_my_trc( knum ) 
+     INTEGER, INTENT(in)  :: knum
+     WRITE(*,*) 'trc_rst_read_my_trc: No specific variables to read on unit', knum
+   END SUBROUTINE trc_rst_read_my_trc
+
+   SUBROUTINE trc_rst_wri_my_trc( kt, kirst, knum )
+     INTEGER, INTENT(in)  :: kt, kirst, knum
+     WRITE(*,*) 'trc_rst_wri_my_trc: No specific variables to write on unit' ,knum, ' at time ', kt, kirst
+   END SUBROUTINE trc_rst_wri_my_trc
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read_my_trc( knum )
+     INTEGER, INTENT(in)  :: knum
+     WRITE(*,*) 'trc_rst_read_my_trc: You should not have seen this print! error?', knum
+   END SUBROUTINE trc_rst_read_my_trc
+
+   SUBROUTINE trc_rst_wri_my_trc( kt, kirst, knum )
+     INTEGER, INTENT(in)  :: kt, kirst, knum
+     WRITE(*,*) 'trc_rst_wri_my_trc: You should not have seen this print! error?', kt, kirst, knum
+   END SUBROUTINE trc_rst_wri_my_trc
+#endif
+
+   !!======================================================================
+END MODULE trcrst_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 1844)
@@ -0,0 +1,84 @@
+MODULE trcsms_my_trc
+   !!======================================================================
+   !!                         ***  MODULE trcsms_my_trc  ***
+   !! TOP :   Main module of the MY_TRC tracers
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) Original code
+   !!----------------------------------------------------------------------
+#if defined key_my_trc
+   !!----------------------------------------------------------------------
+   !!   'key_my_trc'                                               CFC tracers
+   !!----------------------------------------------------------------------
+   !! trc_sms_my_trc   : MY_TRC model main routine 
+   !!----------------------------------------------------------------------
+   USE par_trc         ! TOP parameters
+   USE oce_trc         ! Ocean variables
+   USE trc             ! TOP variables
+   USE trdmld_trc_oce
+   USE trdmld_trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sms_my_trc   ! called by trcsms.F90 module
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sms_my_trc( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_sms_my_trc  ***  
+      !!
+      !! ** Purpose :   main routine of MY_TRC model
+      !!
+      !! ** Method  : - 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt   ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk)    ::   ztrmyt 
+      INTEGER :: jn
+
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_sms_my_trc:  MY_TRC model'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      WHERE( (glamt <= 170) .AND. (glamt >= 160) .AND. (gphit <= -74) .AND. (gphit >=-75.6) )
+        trn(:,:,1,jpmyt1) = 1.
+        trb(:,:,1,jpmyt1) = 1.
+        tra(:,:,1,jpmyt1) = 0.
+      END WHERE
+
+      WHERE( ((glamt <= -165) .OR. (glamt >= 160)) .AND. (gphit <= -76) .AND. (gphit >=-80)) 
+        trn(:,:,1,jpmyt2) = 1.
+        trb(:,:,1,jpmyt2) = 1.
+        tra(:,:,1,jpmyt2) = 0.
+      END WHERE
+
+      ! Save the trends in the ixed layer
+      IF( l_trdtrc ) THEN
+          DO jn = jp_myt0, jp_myt1
+            ztrmyt(:,:,:) = tra(:,:,:,jn)
+            CALL trd_mod_trc( ztrmyt, jn, jptrc_trd_sms, kt )   ! save trends
+          END DO
+      END IF
+      !
+   END SUBROUTINE trc_sms_my_trc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                                        No MY_TRC model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_sms_my_trc( kt )             ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sms_my_trc: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms_my_trc
+#endif
+
+   !!======================================================================
+END MODULE trcsms_my_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zbio.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 1844)
@@ -0,0 +1,148 @@
+MODULE p4zbio
+   !!======================================================================
+   !!                         ***  MODULE p4zbio  ***
+   !! TOP :   PISCES bio-model
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_bio        :   computes the interactions between the different
+   !!                      compartments of PISCES
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc         ! 
+   USE sms_pisces      ! 
+   USE p4zsink         ! 
+   USE p4zopt          ! 
+   USE p4zlim          ! 
+   USE p4zprod         !
+   USE p4zmort         !
+   USE p4zmicro        ! 
+   USE p4zmeso         ! 
+   USE p4zrem          ! 
+   USE prtctl_trc
+   USE iom
+  
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  p4z_bio    
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !:
+      xnegtr            ! Array used to indicate negative tracer values
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_bio ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_bio  ***
+      !!
+      !! ** Purpose :   Ecosystem model in the whole ocean: computes the
+      !!              different interactions between the different compartments
+      !!              of PISCES
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  ::  ji, jj, jk, jn
+      REAL(wp) ::  ztra
+#if defined key_kriest
+      REAL(wp) ::  zcoef1, zcoef2
+#endif
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+      !     ASSIGN THE SHEAR RATE THAT IS USED FOR AGGREGATION
+      !     OF PHYTOPLANKTON AND DETRITUS
+
+      xdiss(:,:,:) = 1.
+!!gm the use of nmld should be better here?
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) > hmld(ji,jj) )   xdiss(ji,jj,jk) = 0.01
+            END DO 
+         END DO
+      END DO
+
+          
+      CALL p4z_sink ( kt, jnt )     ! vertical flux of particulate organic matter
+      CALL p4z_opt  ( kt, jnt )     ! Optic: PAR in the water column
+      CALL p4z_lim  ( kt, jnt )     ! co-limitations by the various nutrients
+      CALL p4z_prod ( kt, jnt )     ! phytoplankton growth rate over the global ocean. 
+      !                             ! (for each element : C, Si, Fe, Chl )
+      CALL p4z_rem  ( kt, jnt )     ! remineralization terms of organic matter+scavenging of Fe
+      CALL p4z_mort ( kt, jnt )     ! phytoplankton mortality
+      !                             ! zooplankton sources/sinks routines 
+      CALL p4z_micro( kt, jnt )           ! microzooplankton
+      CALL p4z_meso ( kt, jnt )           ! mesozooplankton
+
+      !                             ! test if tracers concentrations fall below 0.
+      xnegtr(:,:,:) = 1.e0
+      DO jn = jp_pcs0, jp_pcs1
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( ( trn(ji,jj,jk,jn) + tra(ji,jj,jk,jn) ) < 0.e0 ) THEN 
+                     ztra             = ABS(  ( trn(ji,jj,jk,jn) - rtrn ) &
+                                            / ( tra(ji,jj,jk,jn) + rtrn ) )
+                     xnegtr(ji,jj,jk) = MIN( xnegtr(ji,jj,jk),  ztra )
+                  ENDIF
+              END DO
+            END DO
+         END DO
+      END DO
+      !                                ! where at least 1 tracer concentration becomes negative
+      !                                ! 
+      DO jn = jp_pcs0, jp_pcs1
+         trn(:,:,:,jn) = trn(:,:,:,jn) + xnegtr(:,:,:) * tra(:,:,:,jn)
+      END DO
+
+
+      tra(:,:,:,:) = 0.e0
+
+#if defined key_kriest
+      ! 
+      zcoef1 = 1.e0 / xkr_massp 
+      zcoef2 = 1.e0 / xkr_massp / 1.1
+      DO jk = 1,jpkm1
+         trn(:,:,jk,jpnum) = MAX(  trn(:,:,jk,jpnum), trn(:,:,jk,jppoc) * zcoef1 / xnumm(jk)  )
+         trn(:,:,jk,jpnum) = MIN(  trn(:,:,jk,jpnum), trn(:,:,jk,jppoc) * zcoef2              )
+      END DO
+#endif
+
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('bio ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+      !
+   END SUBROUTINE p4z_bio
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_bio                         ! Empty routine
+   END SUBROUTINE p4z_bio
+#endif 
+
+   !!======================================================================
+END MODULE  p4zbio
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zche.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 1844)
@@ -0,0 +1,338 @@
+MODULE p4zche
+   !!======================================================================
+   !!                         ***  MODULE p4zche  ***
+   !! TOP :   PISCES Sea water chemistry computed following OCMIP protocol
+   !!======================================================================
+   !! History :    -   !  1988     (E. Maier-Reimer)  Original code
+   !!              -   !  1998     (O. Aumont)  addition
+   !!              -   !  1999     (C. Le Quere)  modification
+   !!             1.0  !  2004     (O. Aumont)  modification
+   !!              -   !  2006     (R. Gangsto)  modification
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_che        :  Sea water chemistry computed following OCMIP protocol
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc         !
+   USE sms_pisces      ! 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_che  
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      sio3eq, fekeq           !: chemistry of Fe and Si
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2)   ::   &   !:
+      chemc                   !: Solubilities of O2 and CO2
+
+   !! * Module variables
+
+   REAL(wp) :: &
+      salchl = 1./1.80655 ! conversion factor for salinity --> chlorinity (Wooster et al. 1969)
+
+   REAL(wp) :: &            ! coeff. for apparent solubility equilibrium 
+      akcc1 = -171.9065 , &    ! Millero et al. 1995 from Mucci 1983
+      akcc2 = -0.077993 , &  
+      akcc3 = 2839.319  , &  
+      akcc4 = 71.595    , &  
+      akcc5 = -0.77712  , &  
+      akcc6 = 0.0028426 , &  
+      akcc7 = 178.34    , &  
+      akcc8 = -0.07711  , &  
+      akcc9 = 0.0041249
+
+   REAL(wp) :: &             ! universal gas constants
+      rgas = 83.143, &
+      oxyco = 1./22.4144
+
+   REAL(wp) :: &             ! borat constants
+      bor1 = 0.00023, &
+      bor2 = 1./10.82
+
+   REAL(wp) :: &              !
+      ca0 = -162.8301  , &
+      ca1 = 218.2968   , &
+      ca2 = 90.9241    , &
+      ca3 = -1.47696   , &
+      ca4 = 0.025695   , &
+      ca5 = -0.025225  , &
+      ca6 = 0.0049867
+
+   REAL(wp) :: &              ! coeff. for 1. dissoc. of carbonic acid (Edmond and Gieskes, 1970)   
+      c10 = -3670.7   , &
+      c11 = 62.008    , &
+      c12 = -9.7944   , &
+      c13 = 0.0118    , &
+      c14 = -0.000116
+
+   REAL(wp) :: &              ! coeff. for 2. dissoc. of carbonic acid (Millero, 1995)   
+      c20 = -1394.7   , &
+      c21 = -4.777    , &
+      c22 = 0.0184    , &
+      c23 = -0.000118
+
+   REAL(wp) :: &             ! constants for calculate concentrations 
+      st1  = 0.14     , &    ! for sulfate (Morris & Riley 1966)
+      st2  = 1./96.062, &
+      ks0  = 141.328  , &
+      ks1  = -4276.1  , &
+      ks2  = -23.093  , &
+      ks3  = -13856.  , &
+      ks4  = 324.57   , &
+      ks5  = -47.986  , &
+      ks6  = 35474.   , &
+      ks7  = -771.54  , &
+      ks8  = 114.723  , &
+      ks9  = -2698.   , &
+      ks10 = 1776.    , &
+      ks11 = 1.       , &
+      ks12 = -0.001005 
+
+   REAL(wp) :: &             ! constants for calculate concentrations 
+      ft1  = 0.000067   , &  ! fluorides (Dickson & Riley 1979 )
+      ft2  = 1./18.9984 , &
+      kf0  = -12.641    , &
+      kf1  = 1590.2     , &
+      kf2  = 1.525      , &
+      kf3  = 1.0        , &
+      kf4  =-0.001005
+
+   REAL(wp) :: &              ! coeff. for 1. dissoc. of boric acid (Dickson and Goyet, 1994)
+      cb0  = -8966.90, &
+      cb1  = -2890.53, &
+      cb2  = -77.942 , &
+      cb3  = 1.728   , &
+      cb4  = -0.0996 , &
+      cb5  = 148.0248, &
+      cb6  = 137.1942, &
+      cb7  = 1.62142 , &
+      cb8  = -24.4344, &
+      cb9  = -25.085 , &
+      cb10 = -0.2474 , &
+      cb11 = 0.053105
+
+   REAL(wp) :: &             ! coeff. for dissoc. of water (Dickson and Riley, 1979 )
+      cw0 = -13847.26  , &
+      cw1 = 148.9652   , &
+      cw2 = -23.6521   , &
+      cw3 = 118.67     , &
+      cw4 = -5.977     , &
+      cw5 = 1.0495     , &
+      cw6 = -0.01615
+ 
+   REAL(wp) :: &              ! volumetric solubility constants for o2 in ml/l (Weiss, 1974)
+      ox0 = -58.3877   , &
+      ox1 = 85.8079    , &
+      ox2 = 23.8439    , &
+      ox3 = -0.034892  , &
+      ox4 = 0.015568   , &
+      ox5 = -0.0019387 
+
+   REAL(wp), DIMENSION(5)  :: &  ! coeff. for seawater pressure correction 
+      devk1, devk2, devk3,    &  ! (millero 95)
+      devk4, devk5
+
+   DATA devk1 / -25.5    , -15.82    , -29.48  , -25.60     , -48.76    /   
+   DATA devk2 / 0.1271   , -0.0219   , 0.1622  , 0.2324     , 0.5304    /   
+   DATA devk3 / 0.       , 0.        , 2.608E-3,  -3.6246E-3, 0.        /   
+   DATA devk4 / -3.08E-3 , 1.13E-3   , -2.84E-3, -5.13E-3   , -11.76E-3 /   
+   DATA devk5 / 0.0877E-3, -0.1475E-3,  0.     , 0.0794E-3  , 0.3692E-3 /
+
+   !!* Substitution
+#include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_che
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_che  ***
+      !!
+      !! ** Purpose :   Sea water chemistry computed following OCMIP protocol
+      !!
+      !! ** Method  : - ...
+      !!---------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   ztkel, zsal , zqtt  , zbuf1 , zbuf2
+      REAL(wp) ::   zpres, ztc  , zcl   , zcpexp, zoxy  , zcpexp2
+      REAL(wp) ::   zsqrt, ztr  , zlogt , zcek1
+      REAL(wp) ::   zlqtt, zqtt2, zsal15, zis   , zis2 , zisqrt
+      REAL(wp) ::   zckb , zck1 , zck2  , zckw  , zak1 , zak2  , zakb , zaksp0, zakw
+      REAL(wp) ::   zst  , zft  , zcks  , zckf  , zaksp1
+      !!---------------------------------------------------------------------
+
+      ! CHEMICAL CONSTANTS - SURFACE LAYER
+      ! ----------------------------------
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+
+            !                             ! SET ABSOLUTE TEMPERATURE
+            ztkel = tn(ji,jj,1) + 273.16
+            zqtt  = ztkel * 0.01
+            zqtt2 = zqtt * zqtt
+            zsal  = sn(ji,jj,1) + (1.- tmask(ji,jj,1) ) * 35.
+            zlqtt = LOG( zqtt )
+
+            !                             ! LN(K0) OF SOLUBILITY OF CO2 (EQ. 12, WEISS, 1980)
+            !                             !     AND FOR THE ATMOSPHERE FOR NON IDEAL GAS
+            zcek1 = ca0 + ca1 / zqtt + ca2 * zlqtt + ca3 * zqtt2 + zsal*( ca4 + ca5 * zqtt + ca6 * zqtt2 )
+
+            !                             ! LN(K0) OF SOLUBILITY OF O2 and N2 (EQ. 4, WEISS, 1970)
+            zoxy  = ox0 + ox1 / zqtt + ox2 * zlqtt + zsal * ( ox3 + ox4 * zqtt + ox5 * zqtt2 )
+
+            !                             ! SET SOLUBILITIES OF O2 AND CO2
+            chemc(ji,jj,1) = EXP( zcek1 ) * 1.e-6 * rhop(ji,jj,1) / 1000.
+            chemc(ji,jj,2) = EXP( zoxy  ) * oxyco
+
+         END DO
+      END DO
+
+      ! CHEMICAL CONSTANTS - DEEP OCEAN
+      ! -------------------------------
+!CDIR NOVERRCHK
+      DO jk = 1, jpk
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+
+               ! SET PRESSION
+               zpres   = 1.025e-1 * fsdept(ji,jj,jk)
+
+               ! SET ABSOLUTE TEMPERATURE
+               ztkel   = tn(ji,jj,jk) + 273.16
+               zqtt    = ztkel * 0.01
+               zsal    = sn(ji,jj,jk) + ( 1.-tmask(ji,jj,jk) ) * 35.
+               zsqrt  = SQRT( zsal )
+               zsal15  = zsqrt * zsal
+               zlogt  = LOG( ztkel )
+               ztr    = 1. / ztkel
+               zis    = 19.924 * zsal / ( 1000.- 1.005 * zsal )
+               zis2   = zis * zis
+               zisqrt = SQRT( zis )
+               ztc     = tn(ji,jj,jk) + ( 1.- tmask(ji,jj,jk) ) * 20.
+
+               ! CHLORINITY (WOOSTER ET AL., 1969)
+               zcl     = zsal * salchl
+
+               ! TOTAL SULFATE CONCENTR. [MOLES/kg soln]
+               zst     = st1 * zcl * st2
+
+               ! TOTAL FLUORIDE CONCENTR. [MOLES/kg soln]
+               zft     = ft1 * zcl * ft2
+
+               ! DISSOCIATION CONSTANT FOR SULFATES on free H scale (Dickson 1990)
+               zcks    = EXP(  ks1 * ztr + ks0 + ks2 * zlogt                           &
+                  &                     + ( ks3 * ztr + ks4 + ks5 * zlogt ) * zisqrt   &
+                  &                     + ( ks6 * ztr + ks7 + ks8 * zlogt ) * zis      &
+                  &                     + ks9 * ztr * zis * zisqrt + ks10 * ztr *zis2 + LOG( ks11 + ks12 *zsal )  )
+
+               ! DISSOCIATION CONSTANT FOR FLUORIDES on free H scale (Dickson and Riley 79)
+               zckf    = EXP(  kf1 * ztr + kf0 + kf2 * zisqrt + LOG( kf3 + kf4 * zsal )  )
+
+               ! DISSOCIATION CONSTANT FOR CARBONATE AND BORATE
+               zckb    = ( cb0 + cb1 * zsqrt + cb2  * zsal + cb3 * zsal15 + cb4 * zsal * zsal ) * ztr   &
+                  &    + ( cb5 + cb6 * zsqrt + cb7  * zsal )                                            &
+                  &    + ( cb8 + cb9 * zsqrt + cb10 * zsal ) * zlogt + cb11 * zsqrt * ztkel             &
+                  &    + LOG(  ( 1.+ zst / zcks + zft / zckf ) / ( 1.+ zst / zcks )  )
+!!gm zsal**2 to be replaced by a *...
+               zck1    = c10 * ztr + c11 + c12 * zlogt + c13 * zsal + c14 * zsal**2
+               zck2    = c20 * ztr + c21 + c22 * zsal   + c23 * zsal**2
+
+               ! PKW (H2O) (DICKSON AND RILEY, 1979)
+               zckw    = cw0 * ztr + cw1 + cw2 * zlogt + ( cw3 * ztr + cw4 + cw5 * zlogt ) * zsqrt + cw6 * zsal
+
+
+               ! APPARENT SOLUBILITY PRODUCT K'SP OF CALCITE IN SEAWATER
+               !       (S=27-43, T=2-25 DEG C) at pres =0 (atmos. pressure) (MUCCI 1983)
+               zaksp0  = akcc1 + akcc2 * ztkel + akcc3 * ztr + akcc4 * LOG10( ztkel )   &
+                  &   + ( akcc5 + akcc6 * ztkel + akcc7 * ztr ) * zsqrt + akcc8 * zsal + akcc9 * zsal15
+
+               ! K1, K2 OF CARBONIC ACID, KB OF BORIC ACID, KW (H2O) (LIT.?)
+               zak1    = 10**(zck1)
+               zak2    = 10**(zck2)
+               zakb    = EXP( zckb  )
+               zakw    = EXP( zckw )
+               zaksp1  = 10**(zaksp0)
+
+               ! FORMULA FOR CPEXP AFTER EDMOND & GIESKES (1970)
+               !        (REFERENCE TO CULBERSON & PYTKOQICZ (1968) AS MADE
+               !        IN BROECKER ET AL. (1982) IS INCORRECT; HERE RGAS IS
+               !        TAKEN TENFOLD TO CORRECT FOR THE NOTATION OF pres  IN
+               !        DBAR INSTEAD OF BAR AND THE EXPRESSION FOR CPEXP IS
+               !        MULTIPLIED BY LN(10.) TO ALLOW USE OF EXP-FUNCTION
+               !        WITH BASIS E IN THE FORMULA FOR AKSPP (CF. EDMOND
+               !        & GIESKES (1970), P. 1285-1286 (THE SMALL
+               !        FORMULA ON P. 1286 IS RIGHT AND CONSISTENT WITH THE
+               !        SIGN IN PARTIAL MOLAR VOLUME CHANGE AS SHOWN ON P. 1285))
+               zcpexp  = zpres /(rgas*ztkel)
+               zcpexp2 = zpres * zpres/(rgas*ztkel)
+
+               ! KB OF BORIC ACID, K1,K2 OF CARBONIC ACID PRESSURE
+               !        CORRECTION AFTER CULBERSON AND PYTKOWICZ (1968)
+               !        (CF. BROECKER ET AL., 1982)
+
+               zbuf1  = -(devk1(1)+devk2(1)*ztc+devk3(1)*ztc*ztc)
+               zbuf2  = 0.5*(devk4(1)+devk5(1)*ztc)
+               ak13(ji,jj,jk) = zak1 * EXP( zbuf1 * zcpexp + zbuf2 * zcpexp2 )
+
+               zbuf1  =     - ( devk1(2) + devk2(2) * ztc + devk3(2) * ztc * ztc )
+               zbuf2  = 0.5 * ( devk4(2) + devk5(2) * ztc )
+               ak23(ji,jj,jk) = zak2 * EXP( zbuf1 * zcpexp + zbuf2 * zcpexp2 )
+
+               zbuf1  =     - ( devk1(3) + devk2(3) * ztc + devk3(3) * ztc * ztc )
+               zbuf2  = 0.5 * ( devk4(3) + devk5(3) * ztc )
+               akb3(ji,jj,jk) = zakb * EXP( zbuf1 * zcpexp + zbuf2 * zcpexp2 )
+
+               zbuf1  =     - ( devk1(4) + devk2(4) * ztc + devk3(4) * ztc * ztc )
+               zbuf2  = 0.5 * ( devk4(4) + devk5(4) * ztc )
+               akw3(ji,jj,jk) = zakw * EXP( zbuf1 * zcpexp + zbuf2 * zcpexp2 )
+
+
+               ! APPARENT SOLUBILITY PRODUCT K'SP OF CALCITE 
+               !        AS FUNCTION OF PRESSURE FOLLOWING MILLERO
+               !        (P. 1285) AND BERNER (1976)
+               zbuf1  =     - ( devk1(5) + devk2(5) * ztc + devk3(5) * ztc * ztc )
+               zbuf2  = 0.5 * ( devk4(5) + devk5(5) * ztc )
+               aksp(ji,jj,jk) = zaksp1 * EXP( zbuf1 * zcpexp + zbuf2 * zcpexp2 )
+
+
+               ! TOTAL BORATE CONCENTR. [MOLES/L]
+               borat(ji,jj,jk) = bor1 * zcl * bor2
+
+               ! Iron and SIO3 saturation concentration from ...
+               sio3eq(ji,jj,jk) = EXP(  LOG( 10.) * ( 6.44 - 968. / ztkel )  ) * 1.e-6
+               fekeq (ji,jj,jk) = 10**( 17.27 - 1565.7 / ( 273.15 + ztc ) )
+
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE p4z_che
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_che( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'p4z_che: You should not have seen this print! error?', kt
+   END SUBROUTINE p4z_che
+#endif 
+
+   !!======================================================================
+END MODULE  p4zche
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zflx.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1844)
@@ -0,0 +1,289 @@
+MODULE p4zflx
+   !!======================================================================
+   !!                         ***  MODULE p4zflx  ***
+   !! TOP :   PISCES CALCULATES GAS EXCHANGE AND CHEMISTRY AT SEA SURFACE
+   !!======================================================================
+   !! History :    -   !  1988-07  (E. MAIER-REIMER) Original code
+   !!              -   !  1998     (O. Aumont) additions
+   !!              -   !  1999     (C. Le Quere) modifications
+   !!             1.0  !  2004     (O. Aumont) modifications
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_flx       :   CALCULATES GAS EXCHANGE AND CHEMISTRY AT SEA SURFACE
+   !!   p4z_flx_init  :   Read the namelist
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc
+   USE sms_pisces
+   USE prtctl_trc
+   USE p4zche
+   USE iom
+#if defined key_cpl_carbon_cycle
+   USE sbc_oce , ONLY :  atm_co2
+#endif
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_flx  
+
+   REAL(wp) :: &  ! pre-industrial atmospheric [co2] (ppm) 	
+      atcox  = 0.20946 ,    &  !:
+      atcco2 = 278.            !:
+
+   REAL(wp) :: &
+      xconv  = 0.01/3600      !: coefficients for conversion 
+
+   INTEGER  ::  nspyr         !: number of timestep per year
+
+#if defined key_cpl_carbon_cycle
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &
+      oce_co2            !: ocean carbon flux
+   REAL(wp) :: &
+      t_atm_co2_flx,  &  !: Total atmospheric carbon flux per year
+      t_oce_co2_flx      !: Total ocean carbon flux per year
+#endif
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_flx ( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_flx  ***
+      !!
+      !! ** Purpose :   CALCULATES GAS EXCHANGE AND CHEMISTRY AT SEA SURFACE
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt
+      INTEGER  ::   ji, jj, jrorr
+      REAL(wp) ::   ztc, ztc2, ztc3, zws, zkgwan
+      REAL(wp) ::   zfld, zflu, zfld16, zflu16, zfact
+      REAL(wp) ::   zph, zah2, zbot, zdic, zalk, zsch_o2, zalka, zsch_co2
+      REAL(wp), DIMENSION(jpi,jpj) ::   zkgco2, zkgo2, zh2co3
+#if defined key_trc_diaadd && defined key_iomput
+      REAL(wp), DIMENSION(jpi,jpj) ::  zcflx, zoflx, zkg, zdpco2, zdpo2
+#endif
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+
+      IF( kt == nittrc000  )   CALL p4z_flx_init      ! Initialization (first time-step only)
+
+      ! SURFACE CHEMISTRY (PCO2 AND [H+] IN
+      !     SURFACE LAYER); THE RESULT OF THIS CALCULATION
+      !     IS USED TO COMPUTE AIR-SEA FLUX OF CO2
+
+      DO jrorr = 1, 10
+
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+
+               ! DUMMY VARIABLES FOR DIC, H+, AND BORATE
+               zbot  = borat(ji,jj,1)
+               zfact = rhop(ji,jj,1) / 1000. + rtrn
+               zdic  = trn(ji,jj,1,jpdic) / zfact
+               zph   = MAX( hi(ji,jj,1), 1.e-10 ) / zfact
+               zalka = trn(ji,jj,1,jptal) / zfact
+
+               ! CALCULATE [ALK]([CO3--], [HCO3-])
+               zalk  = zalka - (  akw3(ji,jj,1) / zph - zph + zbot / ( 1.+ zph / akb3(ji,jj,1) )  )
+
+               ! CALCULATE [H+] AND [H2CO3]
+               zah2   = SQRT(  (zdic-zalk)**2 + 4.* ( zalk * ak23(ji,jj,1)   &
+                  &                                        / ak13(ji,jj,1) ) * ( 2.* zdic - zalk )  )
+               zah2   = 0.5 * ak13(ji,jj,1) / zalk * ( ( zdic - zalk ) + zah2 )
+               zh2co3(ji,jj) = ( 2.* zdic - zalk ) / ( 2.+ ak13(ji,jj,1) / zah2 ) * zfact
+               hi(ji,jj,1)   = zah2 * zfact
+            END DO
+         END DO
+      END DO
+
+
+      ! --------------
+      ! COMPUTE FLUXES
+      ! --------------
+
+      ! FIRST COMPUTE GAS EXCHANGE COEFFICIENTS
+      ! -------------------------------------------
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            ztc  = MIN( 35., tn(ji,jj,1) )
+            ztc2 = ztc * ztc
+            ztc3 = ztc * ztc2 
+            ! Compute the schmidt Number both O2 and CO2
+            zsch_co2 = 2073.1 - 125.62 * ztc + 3.6276 * ztc2 - 0.043126 * ztc3
+            zsch_o2  = 1953.4 - 128.0  * ztc + 3.9918 * ztc2 - 0.050091 * ztc3
+            !  wind speed 
+            zws  = wndm(ji,jj) * wndm(ji,jj)
+            ! Compute the piston velocity for O2 and CO2
+            zkgwan = 0.3 * zws  + 2.5 * ( 0.5246 + 0.016256 * ztc + 0.00049946  * ztc2 )
+# if defined key_off_degrad
+            zkgwan = zkgwan * xconv * ( 1.- fr_i(ji,jj) ) * tmask(ji,jj,1) * facvol(ji,jj,1)
+#else
+            zkgwan = zkgwan * xconv * ( 1.- fr_i(ji,jj) ) * tmask(ji,jj,1)
+#endif 
+            ! compute gas exchange for CO2 and O2
+            zkgco2(ji,jj) = zkgwan * SQRT( 660./ zsch_co2 )
+            zkgo2 (ji,jj) = zkgwan * SQRT( 660./ zsch_o2 )
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Compute CO2 flux for the sea and air
+#if ! defined key_cpl_carbon_cycle
+            zfld = atcco2 * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
+            zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
+#else
+            zfld = atm_co2(ji,jj) * tmask(ji,jj,1) * chemc(ji,jj,1) * zkgco2(ji,jj)
+            zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)
+            ! compute flux of carbon
+            oce_co2(ji,jj) = ( zfld - zflu ) * rfact &
+               &             * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * 1000.
+#endif
+            tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) / fse3t(ji,jj,1)
+
+            ! Compute O2 flux 
+            zfld16 = atcox * chemc(ji,jj,2) * tmask(ji,jj,1) * zkgo2(ji,jj)
+            zflu16 = trn(ji,jj,1,jpoxy) * tmask(ji,jj,1) * zkgo2(ji,jj)
+            tra(ji,jj,1,jpoxy) = tra(ji,jj,1,jpoxy) + ( zfld16 - zflu16 ) / fse3t(ji,jj,1)
+
+#if defined key_trc_diaadd 
+            ! Save diagnostics
+#  if ! defined key_iomput
+            trc2d(ji,jj,jp_pcs0_2d    ) = ( zfld - zflu )     * 1000. * tmask(ji,jj,1)
+            trc2d(ji,jj,jp_pcs0_2d + 1) = ( zfld16 - zflu16 ) * 1000. * tmask(ji,jj,1)
+            trc2d(ji,jj,jp_pcs0_2d + 2) = zkgco2(ji,jj) * tmask(ji,jj,1)
+            trc2d(ji,jj,jp_pcs0_2d + 3) = ( atcco2 - zh2co3(ji,jj) / ( chemc(ji,jj,1) + rtrn ) ) &
+               &                            * tmask(ji,jj,1)
+#  else
+            zcflx(ji,jj) = ( zfld - zflu ) * 1000.  * tmask(ji,jj,1)
+            zoflx(ji,jj) = ( zfld16 - zflu16 ) * 1000. * tmask(ji,jj,1)
+            zkg  (ji,jj) = zkgco2(ji,jj) * tmask(ji,jj,1)
+            zdpco2(ji,jj) = ( atcco2 - zh2co3(ji,jj)      / ( chemc(ji,jj,1) + rtrn ) ) &
+              &             * tmask(ji,jj,1)
+            zdpo2 (ji,jj) = ( atcox  - trn(ji,jj,1,jpoxy) / ( chemc(ji,jj,2) + rtrn ) ) &
+              &             * tmask(ji,jj,1)
+#  endif
+#endif
+         END DO
+      END DO
+
+#if defined key_cpl_carbon_cycle
+      ! Total Flux of Carbon
+      DO jj = 1, jpj 
+        DO ji = 1, jpi
+           t_atm_co2_flx = t_atm_co2_flx + atm_co2(ji,jj) * tmask_i(ji,jj)
+           t_oce_co2_flx = t_oce_co2_flx + oce_co2(ji,jj) * tmask_i(ji,jj)
+        END DO
+      END DO
+
+      IF( MOD( kt, nspyr ) == 0 ) THEN
+        IF( lk_mpp ) THEN
+          CALL mpp_sum( t_atm_co2_flx )   ! sum over the global domain
+          CALL mpp_sum( t_oce_co2_flx )   ! sum over the global domain
+        ENDIF
+        ! Conversion in GtC/yr ; negative for outgoing from ocean
+        t_oce_co2_flx = (-1.) * t_oce_co2_flx  * 12. / 1.e15
+        !
+        WRITE(numout,*) ' Atmospheric pCO2    :'
+        WRITE(numout,*) '-------------------- : ',kt,'  ',t_atm_co2_flx
+        WRITE(numout,*) '(ppm)'
+        WRITE(numout,*) 'Total Flux of Carbon out of the ocean :'
+        WRITE(numout,*) '-------------------- : ',t_oce_co2_flx
+        WRITE(numout,*) '(GtC/yr)'
+        t_atm_co2_flx = 0.
+        t_oce_co2_flx = 0.
+# if defined key_iomput
+        CALL iom_put( "tatpco2" , t_atm_co2_flx  )
+        CALL iom_put( "tco2flx" , t_oce_co2_flx  )
+#endif
+      ENDIF
+#endif
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('flx ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+# if defined key_trc_diaadd && defined key_iomput
+      CALL iom_put( "Cflx" , zcflx  )
+      CALL iom_put( "Oflx" , zoflx  )
+      CALL iom_put( "Kg"   , zkg    )
+      CALL iom_put( "Dpco2", zdpco2 )
+      CALL iom_put( "Dpo2" , zdpo2  )
+#endif
+
+   END SUBROUTINE p4z_flx
+
+   SUBROUTINE p4z_flx_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_flx_init  ***
+      !!
+      !! ** Purpose :   Initialization of atmospheric conditions
+      !!
+      !! ** Method  :   Read the nampisext namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !! ** input   :   Namelist nampisext
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampisext/ atcco2
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampisext )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for air-sea exchange, nampisext'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    Atmospheric pCO2      atcco2      =', atcco2
+      ENDIF
+
+      ! number of time step per year  
+      nspyr = INT( nyear_len(1) * rday / rdt )
+
+#if defined key_cpl_carbon_cycle
+      ! Initialization of Flux of Carbon
+      oce_co2(:,:) = 0.
+      t_atm_co2_flx = 0.
+      t_oce_co2_flx = 0.
+#endif
+
+   END SUBROUTINE p4z_flx_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_flx( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'p4z_flx: You should not have seen this print! error?', kt
+   END SUBROUTINE p4z_flx
+#endif 
+
+   !!======================================================================
+END MODULE  p4zflx
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zint.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zint.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zint.F90	(revision 1844)
@@ -0,0 +1,89 @@
+MODULE p4zint
+   !!======================================================================
+   !!                         ***  MODULE p4zint  ***
+   !! TOP :   PISCES interpolation and computation of various accessory fields
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_int        :  interpolation and computation of various accessory fields
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc
+   USE sms_pisces
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_int  
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+      tgfunc,            &  !:  Temp. dependancy of various biological rates
+      tgfunc2               !:  Temp. dependancy of mesozooplankton rates 
+
+   !! * Module variables
+   REAL(wp) :: &
+      xksilim = 16.5E-6        ! Half-saturation constant for the computation of the Si half-saturation constant
+
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_int
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_int  ***
+      !!
+      !! ** Purpose :   interpolation and computation of various accessory fields
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      !!
+      INTEGER  ::   ji, jj
+      REAL(wp) ::   zdum
+      !!---------------------------------------------------------------------
+
+      ! Computation of phyto and zoo metabolic rate
+      ! -------------------------------------------
+
+      tgfunc (:,:,:) = EXP( 0.063913 * tn(:,:,:) )
+      tgfunc2(:,:,:) = EXP( 0.07608  * tn(:,:,:) )
+
+      ! Computation of the silicon dependant half saturation
+      ! constant for silica uptake
+      ! ---------------------------------------------------
+
+      DO ji = 1, jpi
+         DO jj = 1, jpj
+            zdum = trn(ji,jj,1,jpsil) * trn(ji,jj,1,jpsil)
+            xksimax(ji,jj) = MAX( xksimax(ji,jj), ( 1.+ 7.* zdum / ( xksilim * xksilim + zdum ) ) * 1e-6 )
+         END DO
+      END DO
+
+      IF( nday_year == 365 ) THEN
+         xksi    = xksimax
+         xksimax = 0.e0
+      ENDIF
+      !
+   END SUBROUTINE p4z_int
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_int                   ! Empty routine
+      WRITE(*,*) 'p4z_int: You should not have seen this print! error?'
+   END SUBROUTINE p4z_int
+#endif 
+
+   !!======================================================================
+END MODULE  p4zint
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlim.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlim.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlim.F90	(revision 1844)
@@ -0,0 +1,225 @@
+MODULE p4zlim
+   !!======================================================================
+   !!                         ***  MODULE p4zlim  ***
+   !! TOP :   PISCES 
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_lim        :   Compute the nutrients limitation terms 
+   !!   p4z_lim_init   :   Read the namelist 
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc         ! 
+   USE sms_pisces      ! 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC p4z_lim    
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+     conc0     = 2.e-6_wp      ,  &  !:
+     conc1     = 10.e-6_wp     ,  &  !:
+     conc2     = 2.e-11_wp     ,  &  !:
+     conc2m    = 8.E-11_wp     ,  &  !:
+     conc3     = 1.e-10_wp     ,  &  !:
+     conc3m    = 4.e-10_wp     ,  &  !:
+     concnnh4  = 1.e-7_wp      ,  &  !:
+     concdnh4  = 5.e-7_wp      ,  &  !:
+     xksi1     = 2.E-6_wp      ,  &  !:
+     xksi2     = 3.33E-6_wp    ,  &  !:
+     xkdoc     = 417.E-6_wp    ,  &  !:
+     caco3r    = 0.3_wp              !:
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_lim( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_lim  ***
+      !!
+      !! ** Purpose :   Compute the co-limitations by the various nutrients
+      !!              for the various phytoplankton species
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zlim1, zlim2, zlim3, zlim4, zno3, zferlim
+      REAL(wp) ::   zconctemp, zconctemp2, zconctempn, zconctempn2
+      REAL(wp) ::   ztemp, zdenom
+      !!---------------------------------------------------------------------
+
+
+      IF( ( kt * jnt ) == nittrc000  )   CALL p4z_lim_init      ! Initialization (first time-step only)
+
+
+!  Tuning of the iron concentration to a minimum
+!  level that is set to the detection limit
+!  -------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zno3=trn(ji,jj,jk,jpno3)
+               zferlim = MAX( 1.5e-11*(zno3/40E-6)**2, 3e-12 )
+               zferlim = MIN( zferlim, 1.5e-11 )
+               trn(ji,jj,jk,jpfer) = MAX( trn(ji,jj,jk,jpfer), zferlim )
+            END DO
+         END DO
+      END DO
+
+!  Computation of a variable Ks for iron on diatoms
+!  taking into account that increasing biomass is
+!  made of generally bigger cells
+!  ------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zconctemp   = MAX( 0.e0 , trn(ji,jj,jk,jpdia)-5e-7 )
+               zconctemp2  = trn(ji,jj,jk,jpdia) - zconctemp
+               zconctempn  = MAX( 0.e0 , trn(ji,jj,jk,jpphy)-1e-6 )
+               zconctempn2 = trn(ji,jj,jk,jpphy) - zconctempn
+               concdfe(ji,jj,jk) = ( zconctemp2 * conc3 + conc3m * zconctemp)   &
+                  &              / ( trn(ji,jj,jk,jpdia) + rtrn )
+               concdfe(ji,jj,jk) = MAX( conc3, concdfe(ji,jj,jk) )
+               concnfe(ji,jj,jk) = ( zconctempn2 * conc2 + conc2m * zconctempn)   &
+                  &              / ( trn(ji,jj,jk,jpphy) + rtrn )
+               concnfe(ji,jj,jk) = MAX( conc2, concnfe(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+    
+!      Michaelis-Menten Limitation term for nutrients
+!      Small flagellates
+!      -----------------------------------------------
+              zdenom = 1. / &
+                  & ( conc0 * concnnh4 + concnnh4 * trn(ji,jj,jk,jpno3) + conc0 * trn(ji,jj,jk,jpnh4) )
+               xnanono3(ji,jj,jk) = trn(ji,jj,jk,jpno3) * concnnh4 * zdenom
+               xnanonh4(ji,jj,jk) = trn(ji,jj,jk,jpnh4) * conc0    * zdenom
+
+               zlim1 = xnanono3(ji,jj,jk) + xnanonh4(ji,jj,jk)
+               zlim2 = trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + concnnh4          ) 
+               zlim3 = trn(ji,jj,jk,jpfer) / ( trn(ji,jj,jk,jpfer) + concnfe(ji,jj,jk) )
+               xlimphy(ji,jj,jk) = MIN( zlim1, zlim2, zlim3 )
+               zlim1 = trn(ji,jj,jk,jpnh4) / ( concnnh4 + trn(ji,jj,jk,jpnh4) )
+               zlim3 = trn(ji,jj,jk,jpfer) / ( conc2    + trn(ji,jj,jk,jpfer) )
+               zlim4 = trn(ji,jj,jk,jpdoc) / ( xkdoc   + trn(ji,jj,jk,jpdoc) )
+               xlimbac(ji,jj,jk) = MIN( zlim1, zlim2, zlim3 ) * zlim4
+
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!   Michaelis-Menten Limitation term for nutrients Diatoms
+!   ----------------------------------------------
+              zdenom = 1. / &
+                  & ( conc1 * concdnh4 + concdnh4 * trn(ji,jj,jk,jpno3) + conc1 * trn(ji,jj,jk,jpnh4) )
+
+               xdiatno3(ji,jj,jk) = trn(ji,jj,jk,jpno3) * concdnh4 * zdenom
+               xdiatnh4(ji,jj,jk) = trn(ji,jj,jk,jpnh4) * conc1    * zdenom 
+
+               zlim1 = xdiatno3(ji,jj,jk) + xdiatnh4(ji,jj,jk)
+               zlim2 = trn(ji,jj,jk,jppo4) / ( trn(ji,jj,jk,jppo4) + concdnh4          )
+               zlim3 = trn(ji,jj,jk,jpsil) / ( trn(ji,jj,jk,jpsil) + xksi   (ji,jj)    )
+               zlim4 = trn(ji,jj,jk,jpfer) / ( trn(ji,jj,jk,jpfer) + concdfe(ji,jj,jk) )
+               xlimdia(ji,jj,jk) = MIN( zlim1, zlim2, zlim3, zlim4 )
+
+            END DO
+         END DO
+      END DO
+
+
+      ! Compute the fraction of nanophytoplankton that is made of calcifiers
+      ! --------------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztemp = MAX( 0., tn(ji,jj,jk) )
+               xfracal(ji,jj,jk) = caco3r * xlimphy(ji,jj,jk)   &
+                  &                       * MAX( 0.0001, ztemp / ( 2.+ ztemp ) )   &
+                  &                       * MAX( 1., trn(ji,jj,jk,jpphy) * 1.e6 / 2. )
+               xfracal(ji,jj,jk) = MIN( 0.8 , xfracal(ji,jj,jk) )
+               xfracal(ji,jj,jk) = MAX( 0.01, xfracal(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE p4z_lim
+
+   SUBROUTINE p4z_lim_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_lim_init  ***
+      !!
+      !! ** Purpose :   Initialization of nutrient limitation parameters
+      !!
+      !! ** Method  :   Read the nampislim namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampislim
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampislim/ conc0, conc1, conc2, conc2m, conc3, conc3m,   &
+         &             concnnh4, concdnh4, xksi1, xksi2, xkdoc, caco3r
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampislim )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for nutrient limitations, nampislim'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    mean rainratio                            caco3r    =', caco3r
+         WRITE(numout,*) '    NO3, PO4 half saturation                  conc0      =', conc0
+         WRITE(numout,*) '    half saturation constant for Si uptake    xksi1     =', xksi1
+         WRITE(numout,*) '    half saturation constant for Si/C         xksi2     =', xksi2
+         WRITE(numout,*) '    2nd half-sat. of DOC remineralization     xkdoc    =', xkdoc
+         WRITE(numout,*) '    Phosphate half saturation for diatoms     conc1     =', conc1
+         WRITE(numout,*) '    Iron half saturation for phyto            conc2     =', conc2
+         WRITE(numout,*) '    Max iron half saturation for phyto        conc2m    =', conc2m
+         WRITE(numout,*) '    Iron half saturation for diatoms          conc3     =', conc3
+         WRITE(numout,*) '    Maxi iron half saturation for diatoms     conc3m    =', conc3m
+         WRITE(numout,*) '    NH4 half saturation for phyto             concnnh4  =', concnnh4
+         WRITE(numout,*) '    NH4 half saturation for diatoms           concdnh4  =', concdnh4
+      ENDIF
+
+   END SUBROUTINE p4z_lim_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_lim                   ! Empty routine
+   END SUBROUTINE p4z_lim
+#endif 
+
+   !!======================================================================
+END MODULE  p4zlim
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlys.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlys.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zlys.F90	(revision 1844)
@@ -0,0 +1,234 @@
+MODULE p4zlys
+   !!======================================================================
+   !!                         ***  MODULE p4zlys  ***
+   !! TOP :   PISCES 
+   !!======================================================================
+   !! History :    -   !  1988-07  (E. MAIER-REIMER) Original code
+   !!              -   !  1998     (O. Aumont) additions
+   !!              -   !  1999     (C. Le Quere) modifications
+   !!             1.0  !  2004     (O. Aumont) modifications
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_lys        :   Compute the CaCO3 dissolution 
+   !!   p4z_lys_init   :   Read the namelist parameters
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc
+   USE sms_pisces
+   USE prtctl_trc
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_lys    ! called in p4zprg.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+     kdca = 0.327e3_wp   ,  &  !:
+     nca  = 1.0_wp             !:
+
+   !! * Module variables
+   REAL(wp) :: &
+      calcon = 1.03E-2        ! mean calcite concentration [Ca2+] in sea water [mole/kg solution]
+
+   INTEGER ::               &
+     rmtss                    !: number of seconds per month
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_lys( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_lys  ***
+      !!
+      !! ** Purpose :   CALCULATES DEGREE OF CACO3 SATURATION IN THE WATER
+      !!                COLUMN, DISSOLUTION/PRECIPITATION OF CACO3 AND LOSS
+      !!                OF CACO3 TO THE CACO3 SEDIMENT POOL.
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt ! ocean time step
+      INTEGER  ::   ji, jj, jk, jn
+      REAL(wp) ::   zbot, zalk, zdic, zph, zremco3, zah2
+      REAL(wp) ::   zdispot, zfact, zalka
+      REAL(wp) ::   zomegaca, zexcess, zexcess0
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zco3
+#if defined key_trc_dia3d && defined key_iomput
+      REAL(wp) ::   zrfact2
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zcaldiss
+#endif
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000  )   CALL p4z_lys_init      ! Initialization (first time-step only)
+
+      zco3(:,:,:) = 0.
+
+# if defined key_trc_dia3d && defined key_iomput
+      zcaldiss(:,:,:) = 0.
+# endif
+      !     -------------------------------------------
+      !     COMPUTE [CO3--] and [H+] CONCENTRATIONS
+      !     -------------------------------------------
+      
+      DO jn = 1, 5                               !  BEGIN OF ITERATION
+         !
+!CDIR NOVERRCHK
+         DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+
+                  ! SET DUMMY VARIABLE FOR TOTAL BORATE
+                  zbot  = borat(ji,jj,jk)
+
+                  ! SET DUMMY VARIABLE FOR TOTAL BORATE
+                  zbot  = borat(ji,jj,jk)
+                  zfact = rhop (ji,jj,jk) / 1000. + rtrn
+
+                  ! SET DUMMY VARIABLE FOR [H+]
+                  zph   = hi(ji,jj,jk) * tmask(ji,jj,jk) / zfact + ( 1.-tmask(ji,jj,jk) ) * 1.e-9
+
+                  ! SET DUMMY VARIABLE FOR [SUM(CO2)]GIVEN 
+                  zdic  = trn(ji,jj,jk,jpdic) / zfact
+                  zalka = trn(ji,jj,jk,jptal) / zfact
+
+                  ! CALCULATE [ALK]([CO3--], [HCO3-])
+                  zalk  = zalka - (  akw3(ji,jj,jk) / zph - zph   &
+                     &             + zbot / (1.+ zph / akb3(ji,jj,jk) )  )
+
+                  ! CALCULATE [H+] and [CO3--]
+                  zah2 = SQRT( (zdic-zalk)*(zdic-zalk)+   &
+                     &     4.*(zalk*ak23(ji,jj,jk)/ak13(ji,jj,jk))   &
+                     &     *(2*zdic-zalk))
+
+                  zah2=0.5*ak13(ji,jj,jk)/zalk*((zdic-zalk)+zah2)
+                  zco3(ji,jj,jk) = zalk/(2.+zah2/ak23(ji,jj,jk))*zfact
+
+                  hi(ji,jj,jk)  = zah2*zfact
+
+               END DO
+            END DO
+         END DO
+         !
+      END DO 
+
+      !     ---------------------------------------------------------
+      !        CALCULATE DEGREE OF CACO3 SATURATION AND CORRESPONDING
+      !        DISSOLOUTION AND PRECIPITATION OF CACO3 (BE AWARE OF
+      !        MGCO3)
+      !     ---------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               ! DEVIATION OF [CO3--] FROM SATURATION VALUE
+               zomegaca = ( calcon * zco3(ji,jj,jk) ) / aksp(ji,jj,jk)
+
+               ! SET DEGREE OF UNDER-/SUPERSATURATION
+               zexcess0 = MAX( 0., ( 1.- zomegaca ) )
+               zexcess  = zexcess0**nca
+
+               ! AMOUNT CACO3 (12C) THAT RE-ENTERS SOLUTION
+               !       (ACCORDING TO THIS FORMULATION ALSO SOME PARTICULATE
+               !       CACO3 GETS DISSOLVED EVEN IN THE CASE OF OVERSATURATION)
+# if defined key_off_degrad
+              zdispot = kdca * zexcess * trn(ji,jj,jk,jpcal) * facvol(ji,jj,jk)
+# else
+              zdispot = kdca * zexcess * trn(ji,jj,jk,jpcal)
+# endif
+
+              !  CHANGE OF [CO3--] , [ALK], PARTICULATE [CACO3],
+              !       AND [SUM(CO2)] DUE TO CACO3 DISSOLUTION/PRECIPITATION
+              zremco3 = zdispot / rmtss
+              zco3(ji,jj,jk) = zco3(ji,jj,jk) + zremco3 * rfact
+              tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) + 2. * zremco3
+              tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) -      zremco3
+              tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) +      zremco3
+
+# if defined key_trc_dia3d && defined key_iomput
+              zcaldiss(ji,jj,jk) = zremco3  ! calcite dissolution
+# endif
+            END DO
+         END DO
+      END DO
+
+# if defined key_trc_diaadd &&  defined key_trc_dia3d
+#  if ! defined key_iomput
+      trc3d(:,:,:,jp_pcs0_3d    ) = hi  (:,:,:)          * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 1) = zco3(:,:,:)          * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 2) = aksp(:,:,:) / calcon * tmask(:,:,:)
+#  else
+      zrfact2 = 1.e3 * rfact2r
+      CALL iom_put( "PH"    , hi      (:,:,:)           * tmask(:,:,:) )
+      CALL iom_put( "CO3"   , zco3    (:,:,:)           * tmask(:,:,:) )
+      CALL iom_put( "CO3sat", aksp    (:,:,:) / calcon  * tmask(:,:,:) )
+      CALL iom_put( "DCAL"  , zcaldiss(:,:,:) * zrfact2 * tmask(:,:,:) )
+#  endif
+# endif
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('lys ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_lys
+
+   SUBROUTINE p4z_lys_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_lys_init  ***
+      !!
+      !! ** Purpose :   Initialization of CaCO3 dissolution parameters
+      !!
+      !! ** Method  :   Read the nampiscal namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampiscal
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampiscal/ kdca, nca
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampiscal )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for CaCO3 dissolution, nampiscal'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    diss. rate constant calcite (per month)   kdca      =', kdca
+         WRITE(numout,*) '    order of reaction for calcite dissolution nca       =', nca
+      ENDIF
+
+      ! Number of seconds per month 
+      rmtss =  nyear_len(1) * rday / raamo
+
+   END SUBROUTINE p4z_lys_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_lys( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'p4z_lys: You should not have seen this print! error?', kt
+   END SUBROUTINE p4z_lys
+#endif 
+   !!======================================================================
+END MODULE  p4zlys
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmeso.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmeso.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmeso.F90	(revision 1844)
@@ -0,0 +1,388 @@
+MODULE p4zmeso
+   !!======================================================================
+   !!                         ***  MODULE p4zmeso  ***
+   !! TOP :   PISCES Compute the sources/sinks for mesozooplankton
+   !!======================================================================
+   !! History :   1.0  !  2002     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_meso       :   Compute the sources/sinks for mesozooplankton
+   !!   p4z_meso_init  :   Initialization of the parameters for mesozooplankton
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc         ! 
+   USE sms_pisces      ! 
+   USE prtctl_trc
+   USE p4zint
+   USE p4zsink
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_meso         ! called in p4zbio.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+      xprefc   = 1.0_wp     ,  &  !: 
+      xprefp   = 0.2_wp     ,  &  !:
+      xprefz   = 1.0_wp     ,  &  !:
+      xprefpoc = 0.0_wp     ,  &  !:
+      resrat2  = 0.005_wp   ,  &  !:
+      mzrat2   = 0.03_wp    ,  &  !:
+      grazrat2 = 0.7_wp     ,  &  !:
+      xkgraz2  = 20E-6_wp   ,  &  !:
+      unass2   = 0.3_wp     ,  &  !:
+      sigma2   = 0.6_wp     ,  &  !:
+      epsher2  = 0.33_wp    ,  &  !:   
+      grazflux = 5.E3_wp 
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_meso( kt,jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_meso  ***
+      !!
+      !! ** Purpose :   Compute the sources/sinks for mesozooplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompadi, zcompaph, zcompapoc, zcompaz
+      REAL(wp) :: zfact, zstep, zcompam, zdenom, zgraze2
+      REAL(wp) :: zgrarem2, zgrafer2, zgrapoc2, zprcaca, zmortz2
+#if defined key_kriest
+      REAL znumpoc
+#endif
+      REAL(wp),DIMENSION(jpi,jpj,jpk) :: zrespz2,ztortz2,zgrazd,zgrazz,zgrazpof
+      REAL(wp),DIMENSION(jpi,jpj,jpk) :: zgrazn,zgrazpoc,zgraznf,zgrazf
+      REAL(wp),DIMENSION(jpi,jpj,jpk) :: zgrazfff,zgrazffe
+      CHARACTER (len=25) :: charout
+#if defined key_trc_diaadd && defined key_trc_dia3d && defined key_iomput
+      REAL(wp) :: zrfact2
+#endif
+
+      !!---------------------------------------------------------------------
+
+
+      IF( ( kt * jnt ) == nittrc000  )   CALL p4z_meso_init      ! Initialization (first time-step only)
+
+      zrespz2 (:,:,:) = 0.
+      ztortz2 (:,:,:) = 0.
+      zgrazd  (:,:,:) = 0.
+      zgrazz  (:,:,:) = 0.
+      zgrazpof(:,:,:) = 0.
+      zgrazn  (:,:,:) = 0.
+      zgrazpoc(:,:,:) = 0.
+      zgraznf (:,:,:) = 0.
+      zgrazf  (:,:,:) = 0.
+      zgrazfff(:,:,:) = 0.
+      zgrazffe(:,:,:) = 0.
+
+      zstep = rfact2 / rday      ! Time step duration for biology
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zcompam = MAX( ( trn(ji,jj,jk,jpmes) - 1.e-9 ), 0.e0 )
+# if defined key_off_degrad
+               zfact   = zstep * tgfunc(ji,jj,jk) * zcompam * facvol(ji,jj,jk)
+# else
+               zfact   = zstep * tgfunc(ji,jj,jk) * zcompam
+# endif
+
+!     Respiration rates of both zooplankton
+!     -------------------------------------
+               zrespz2(ji,jj,jk)  = resrat2 * zfact * ( 1. + 3. * nitrfac(ji,jj,jk) )        &
+                  &     * trn(ji,jj,jk,jpmes) / ( xkmort + trn(ji,jj,jk,jpmes) )
+
+!     Zooplankton mortality. A square function has been selected with
+!     no real reason except that it seems to be more stable and may
+!     mimic predation.
+!     ---------------------------------------------------------------
+               ztortz2(ji,jj,jk) = mzrat2 * 1.e6 * zfact * trn(ji,jj,jk,jpmes)
+               !
+            END DO
+         END DO
+      END DO
+
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               zcompadi  = MAX( ( trn(ji,jj,jk,jpdia) - 1.e-8 ), 0.e0 )
+               zcompaz   = MAX( ( trn(ji,jj,jk,jpzoo) - 1.e-8 ), 0.e0 )
+               zcompaph  = MAX( ( trn(ji,jj,jk,jpphy) - 2.e-7 ), 0.e0 )
+               zcompapoc = MAX( ( trn(ji,jj,jk,jppoc) - 1.e-8 ), 0.e0 )
+
+!     Microzooplankton grazing
+!     ------------------------
+               zdenom = 1. / (  xkgraz2 + xprefc   * trn(ji,jj,jk,jpdia)   &
+                  &                     + xprefz   * trn(ji,jj,jk,jpzoo)   &
+                  &                     + xprefp   * trn(ji,jj,jk,jpphy)   &
+                  &                     + xprefpoc * trn(ji,jj,jk,jppoc)  )
+
+               zgraze2 = grazrat2 * zstep * Tgfunc2(ji,jj,jk) * zdenom    &
+# if defined key_off_degrad
+                  &     * facvol(ji,jj,jk)          &
+# endif
+                  &     * trn(ji,jj,jk,jpmes)
+
+               zgrazd(ji,jj,jk)   = zgraze2 * xprefc   * zcompadi
+               zgrazz(ji,jj,jk)   = zgraze2 * xprefz   * zcompaz
+               zgrazn(ji,jj,jk)   = zgraze2 * xprefp   * zcompaph
+               zgrazpoc(ji,jj,jk) = zgraze2 * xprefpoc * zcompapoc
+
+               zgraznf(ji,jj,jk)  = zgrazn(ji,jj,jk)   * trn(ji,jj,jk,jpnfe) &
+                  &                                     / (trn(ji,jj,jk,jpphy) + rtrn)
+               zgrazf(ji,jj,jk)   = zgrazd(ji,jj,jk)   * trn(ji,jj,jk,jpdfe) &
+                  &                                    / (trn(ji,jj,jk,jpdia) + rtrn)
+               zgrazpof(ji,jj,jk) = zgrazpoc(ji,jj,jk) * trn(ji,jj,jk,jpsfe) &
+                  &                                   / (trn(ji,jj,jk,jppoc) + rtrn)
+            END DO
+         END DO
+      END DO
+      
+      
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               
+!    Mesozooplankton flux feeding on GOC
+!    ----------------------------------
+# if ! defined key_kriest
+#   if ! defined key_off_degrad
+               zgrazffe(ji,jj,jk) = grazflux * zstep * wsbio4(ji,jj,jk)          &
+                  &                 * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jpgoc) * trn(ji,jj,jk,jpmes)
+#   else
+               zgrazffe(ji,jj,jk) = grazflux * zstep * wsbio4(ji,jj,jk) * facvol(ji,jj,jk)         &
+                  &                 * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jpgoc) * trn(ji,jj,jk,jpmes)
+#  endif
+               zgrazfff(ji,jj,jk) = zgrazffe(ji,jj,jk)       &
+                  &                 * trn(ji,jj,jk,jpbfe) / (trn(ji,jj,jk,jpgoc) + rtrn)
+# else
+!!--------------------------- KRIEST3 -------------------------------------------
+!!               zgrazffe(ji,jj,jk) = 0.5 * 1.3e-2 / 5.5e-7 * 0.3 * zstep * wsbio3(ji,jj,jk)     &
+!!                  &     * tgfunc(ji,jj,jk) * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpmes)    &
+#  if defined key_off_degrad
+!!                  &     * facvol(ji,jj,jk)          &
+#  endif
+!!                  &     /  (trn(ji,jj,jk,jppoc) * 1.e7 + 0.1)
+!!--------------------------- KRIEST3 -------------------------------------------
+
+#  if ! defined key_off_degrad
+              zgrazffe(ji,jj,jk) = grazflux * zstep * wsbio3(ji,jj,jk)     &
+                  &                * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpmes)
+#  else
+              zgrazffe(ji,jj,jk) = grazflux * zstep * wsbio3(ji,jj,jk) * facvol(ji,jj,jk)    &
+                  &               * tgfunc2(ji,jj,jk) * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpmes)
+#  endif
+
+               zgrazfff(ji,jj,jk) = zgrazffe(ji,jj,jk)      &
+                  &                * trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)
+# endif
+            END DO
+         END DO
+      END DO
+      
+#if defined key_trc_dia3d
+      ! Total grazing ( grazing by microzoo is already computed in p4zmicro ) 
+      grazing(:,:,:) = grazing(:,:,:) + (  zgrazd  (:,:,:) + zgrazz  (:,:,:) + zgrazn(:,:,:) &
+                     &                   + zgrazpoc(:,:,:) + zgrazffe(:,:,:)  )
+#endif
+
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+
+!    Mesozooplankton efficiency
+!    --------------------------
+               zgrarem2 = ( zgrazd(ji,jj,jk) + zgrazz(ji,jj,jk) + zgrazn(ji,jj,jk) &
+                  &     + zgrazpoc(ji,jj,jk) + zgrazffe(ji,jj,jk) )   &
+                  &     * ( 1. - epsher2 - unass2 )
+#if ! defined key_kriest
+               zgrafer2 = (zgrazf(ji,jj,jk) + zgraznf(ji,jj,jk) + zgrazz(ji,jj,jk) &
+                  &     * ferat3 + zgrazpof(ji,jj,jk) + zgrazfff (ji,jj,jk))*(1.-epsher2-unass2) &
+                  &     + epsher2 * ( &
+                  &      zgrazd(ji,jj,jk)   * MAX((trn(ji,jj,jk,jpdfe) / (trn(ji,jj,jk,jpdia) + rtrn)-ferat3),0.) &
+                  &     + zgrazn(ji,jj,jk)   * MAX((trn(ji,jj,jk,jpnfe) / (trn(ji,jj,jk,jpphy) + rtrn)-ferat3),0.) &
+                  &    + zgrazpoc(ji,jj,jk) * MAX((trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)-ferat3),0.) &
+                  &    + zgrazffe(ji,jj,jk) * MAX((trn(ji,jj,jk,jpbfe) / (trn(ji,jj,jk,jpgoc) + rtrn)-ferat3),0.)  )
+#else
+               zgrafer2 = (zgrazf(ji,jj,jk) + zgraznf(ji,jj,jk) + zgrazz(ji,jj,jk) &
+                  &    * ferat3 + zgrazpof(ji,jj,jk) + zgrazfff(ji,jj,jk) )*(1.-epsher2-unass2) &
+                  &    + epsher2 * ( &
+                  &    zgrazd(ji,jj,jk)   * MAX((trn(ji,jj,jk,jpdfe) / (trn(ji,jj,jk,jpdia) + rtrn)-ferat3),0.) &
+                  &    + zgrazn(ji,jj,jk)   * MAX((trn(ji,jj,jk,jpnfe) / (trn(ji,jj,jk,jpphy) + rtrn)-ferat3),0.) &
+                  &    + zgrazpoc(ji,jj,jk) * MAX((trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)-ferat3),0.) &
+                  &    + zgrazffe(ji,jj,jk) * MAX((trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)-ferat3),0.)  )
+
+#endif
+               zgrapoc2 = (zgrazd(ji,jj,jk) + zgrazz(ji,jj,jk)  + zgrazn(ji,jj,jk) &
+                  &    + zgrazpoc(ji,jj,jk) + zgrazffe(ji,jj,jk)) * unass2
+
+               tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) + zgrarem2 * sigma2
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + zgrarem2 * sigma2
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zgrarem2 * (1.-sigma2)
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2ut * zgrarem2 * sigma2
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zgrafer2
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zgrarem2 * sigma2
+               
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zgrapoc2
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + zgrapoc2 * xkr_dmeso
+#else
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zgrapoc2
+#endif
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !
+               !   Update the arrays TRA which contain the biological sources and sinks
+               !   --------------------------------------------------------------------
+               zmortz2 = ztortz2(ji,jj,jk) + zrespz2(ji,jj,jk)
+               tra(ji,jj,jk,jpmes) = tra(ji,jj,jk,jpmes) - zmortz2  &
+                  &    + epsher2 * ( zgrazd(ji,jj,jk) + zgrazz(ji,jj,jk) + zgrazn(ji,jj,jk) &
+                  &    + zgrazpoc(ji,jj,jk) + zgrazffe(ji,jj,jk) )
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zgrazd(ji,jj,jk)
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) - zgrazz(ji,jj,jk)
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zgrazn(ji,jj,jk)
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zgrazn(ji,jj,jk) * trn(ji,jj,jk,jpnch)  &
+                  &    / ( trn(ji,jj,jk,jpphy) + rtrn )
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zgrazd(ji,jj,jk) * trn(ji,jj,jk,jpdch) &
+                  &    / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpbsi) = tra(ji,jj,jk,jpbsi) - zgrazd(ji,jj,jk) * trn(ji,jj,jk,jpbsi) &
+                  &    / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) +  zgrazd(ji,jj,jk) * trn(ji,jj,jk,jpbsi) &
+                  &    / ( trn(ji,jj,jk,jpdia) + rtrn )
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) -  zgraznf(ji,jj,jk)
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) -  zgrazf(ji,jj,jk)
+
+               zprcaca = xfracal(ji,jj,jk) * unass2 * zgrazn(ji,jj,jk)
+#if defined key_trc_dia3d
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+#endif
+               zprcaca = part * zprcaca
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2. * zprcaca
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) + zprcaca
+#if defined key_kriest
+               znumpoc = trn(ji,jj,jk,jpnum) / ( trn(ji,jj,jk,jppoc) + rtrn )
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortz2  &
+                  &    - zgrazpoc(ji,jj,jk) - zgrazffe(ji,jj,jk)    
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) - zgrazpoc(ji,jj,jk) * znumpoc &
+                  &    + zmortz2  * xkr_dmeso &
+                  &    - zgrazffe(ji,jj,jk)   * znumpoc * wsbio4(ji,jj,jk) &
+                  &    / ( wsbio3(ji,jj,jk) + rtrn )
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + ferat3 * zmortz2 &
+               &       + unass2 * ( ferat3 * zgrazz(ji,jj,jk) + zgraznf(ji,jj,jk) &
+               &       + zgrazf(ji,jj,jk) + zgrazpof(ji,jj,jk) + zgrazfff(ji,jj,jk) ) &
+               &       - zgrazfff(ji,jj,jk) - zgrazpof(ji,jj,jk)
+#else
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zgrazpoc(ji,jj,jk)
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zmortz2 - zgrazffe(ji,jj,jk)
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zgrazpof(ji,jj,jk)
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + ferat3 * zmortz2 &
+               &       + unass2 * ( ferat3 * zgrazz(ji,jj,jk) + zgraznf(ji,jj,jk) &
+               &       + zgrazf(ji,jj,jk) + zgrazpof(ji,jj,jk) + zgrazfff(ji,jj,jk) ) &
+               &       - zgrazfff(ji,jj,jk)
+#endif
+
+            END DO
+         END DO
+      END DO
+      !
+#if defined key_trc_diaadd && defined key_trc_dia3d && defined key_iomput
+      zrfact2 = 1.e3 * rfact2r
+      ! Total grazing of phyto by zoo
+      grazing(:,:,:) = grazing(:,:,:) * zrfact2 * tmask(:,:,:)
+      ! Calcite production
+      prodcal(:,:,:) = prodcal(:,:,:) * zrfact2 * tmask(:,:,:)
+      IF( jnt == nrdttrc ) then 
+         CALL iom_put( "GRAZ" , grazing  )  ! Total grazing of phyto by zooplankton
+         CALL iom_put( "PCAL" , prodcal  )  ! Calcite production
+      ENDIF
+#endif
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('meso')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_meso
+
+   SUBROUTINE p4z_meso_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_meso_init  ***
+      !!
+      !! ** Purpose :   Initialization of mesozooplankton parameters
+      !!
+      !! ** Method  :   Read the nampismes namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampismes
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampismes/ grazrat2,resrat2,mzrat2,xprefc, xprefp, &
+         &             xprefz, xprefpoc, xkgraz2, epsher2, sigma2, unass2, grazflux
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampismes )
+
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' ' 
+         WRITE(numout,*) ' Namelist parameters for mesozooplankton, nampismes'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    zoo preference for phyto                  xprefc    =', xprefc
+         WRITE(numout,*) '    zoo preference for POC                    xprefp    =', xprefp
+         WRITE(numout,*) '    zoo preference for zoo                    xprefz    =', xprefz
+         WRITE(numout,*) '    zoo preference for poc                    xprefpoc  =', xprefpoc
+         WRITE(numout,*) '    exsudation rate of mesozooplankton        resrat2   =', resrat2
+         WRITE(numout,*) '    mesozooplankton mortality rate            mzrat2    =', mzrat2
+         WRITE(numout,*) '    maximal mesozoo grazing rate              grazrat2  =', grazrat2
+         WRITE(numout,*) '    mesozoo flux feeding rate                 grazflux  =', grazflux
+         WRITE(numout,*) '    non assimilated fraction of P by mesozoo  unass2    =', unass2
+         WRITE(numout,*) '    Efficicency of Mesozoo growth             epsher2   =', epsher2
+         WRITE(numout,*) '    Fraction of mesozoo excretion as DOM      sigma2    =', sigma2
+         WRITE(numout,*) '    half sturation constant for grazing 2     xkgraz2   =', xkgraz2
+      ENDIF
+
+   END SUBROUTINE p4z_meso_init
+
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_meso                    ! Empty routine
+   END SUBROUTINE p4z_meso
+#endif 
+
+   !!======================================================================
+END MODULE  p4zmeso
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmicro.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmicro.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmicro.F90	(revision 1844)
@@ -0,0 +1,293 @@
+MODULE p4zmicro
+   !!======================================================================
+   !!                         ***  MODULE p4zmicro  ***
+   !! TOP :   PISCES Compute the sources/sinks for microzooplankton
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_micro       :   Compute the sources/sinks for microzooplankton
+   !!   p4z_micro_init  :   Initialize and read the appropriate namelist
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc         ! 
+   USE sms_pisces      ! 
+   USE prtctl_trc
+   USE p4zint
+   USE p4zsink
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_micro    ! called in p4zbio.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+      xpref2c = 0.0_wp       ,  &  !:
+      xpref2p = 0.5_wp       ,  &  !:
+      xpref2d = 0.5_wp       ,  &  !:
+      resrat  = 0.03_wp      ,  &  !:
+      mzrat   = 0.0_wp       ,  &  !:
+      grazrat = 4.0_wp       ,  &  !:
+      xkgraz  = 20E-6_wp     ,  &  !:
+      unass   = 0.3_wp       ,  &  !:
+      sigma1  = 0.6_wp       ,  &  !:
+      epsher  = 0.33_wp
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_micro( kt,jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_micro  ***
+      !!
+      !! ** Purpose :   Compute the sources/sinks for microzooplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompadi, zcompadi2, zcompaz , zcompaph, zcompapoc
+      REAL(wp) :: zgraze  , zdenom  , zdenom2
+      REAL(wp) :: zfact   , zstep   , zinano , zidiat, zipoc
+      REAL(wp) :: zgrarem, zgrafer, zgrapoc, zprcaca, zmortz
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zrespz,ztortz
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zgrazp, zgrazm, zgrazsd
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zgrazmf, zgrazsf, zgrazpf
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+      IF( ( kt * jnt ) == nittrc000  )   CALL p4z_micro_init      ! Initialization (first time-step only)
+
+      zrespz (:,:,:) = 0.
+      ztortz (:,:,:) = 0.
+      zgrazp (:,:,:) = 0.
+      zgrazm (:,:,:) = 0.
+      zgrazsd(:,:,:) = 0.
+      zgrazmf(:,:,:) = 0.
+      zgrazsf(:,:,:) = 0.
+      zgrazpf(:,:,:) = 0.
+
+#if defined key_trc_dia3d
+      grazing(:,:,:) = 0.  !: Initialisation of  grazing
+#endif
+
+      zstep = rfact2 / rday      ! Time step duration for biology
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zcompaz = MAX( ( trn(ji,jj,jk,jpzoo) - 1.e-9 ), 0.e0 )
+# if defined key_off_degrad
+               zfact   = zstep * tgfunc(ji,jj,jk) * zcompaz *facvol(ji,jj,jk)
+# else
+               zfact   = zstep * tgfunc(ji,jj,jk) * zcompaz
+# endif
+
+!     Respiration rates of both zooplankton
+!     -------------------------------------
+
+               zrespz(ji,jj,jk) = resrat * zfact  * ( 1.+ 3.* nitrfac(ji,jj,jk) )     &
+                  &            * trn(ji,jj,jk,jpzoo) / ( xkmort + trn(ji,jj,jk,jpzoo) )
+
+!     Zooplankton mortality. A square function has been selected with
+!     no real reason except that it seems to be more stable and may
+!     mimic predation.
+!     ---------------------------------------------------------------
+               ztortz(ji,jj,jk) = mzrat * 1.e6 * zfact * trn(ji,jj,jk,jpzoo)
+
+            END DO
+         END DO
+      END DO
+
+
+ 
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               zcompadi  = MAX( ( trn(ji,jj,jk,jpdia) - 1.e-8 ), 0.e0 )
+               zcompadi2 = MIN( zcompadi, 5.e-7 )
+               zcompaph  = MAX( ( trn(ji,jj,jk,jpphy) - 2.e-7 ), 0.e0 )
+               zcompapoc = MAX( ( trn(ji,jj,jk,jppoc) - 1.e-8 ), 0.e0 )
+               
+               !     Microzooplankton grazing
+               !     ------------------------
+               zdenom2 = 1./ ( xpref2p * zcompaph + xpref2c * zcompapoc + xpref2d * zcompadi2 + rtrn )
+
+               zgraze = grazrat * zstep * tgfunc(ji,jj,jk)     &
+# if defined key_off_degrad
+                  &      * facvol(ji,jj,jk)         &
+# endif
+                  &      * trn(ji,jj,jk,jpzoo)
+
+               zinano = xpref2p * zcompaph  * zdenom2
+               zipoc  = xpref2c * zcompapoc * zdenom2
+               zidiat = xpref2d * zcompadi2 * zdenom2
+
+               zdenom = 1./ ( xkgraz + zinano * zcompaph + zipoc * zcompapoc + zidiat * zcompadi2 )
+
+               zgrazp(ji,jj,jk)  = zgraze * zinano * zcompaph * zdenom
+               zgrazm(ji,jj,jk)  = zgraze * zipoc  * zcompapoc * zdenom
+               zgrazsd(ji,jj,jk) = zgraze * zidiat * zcompadi2 * zdenom
+
+               zgrazpf (ji,jj,jk) = zgrazp(ji,jj,jk)  * trn(ji,jj,jk,jpnfe) / (trn(ji,jj,jk,jpphy) + rtrn)
+               zgrazmf(ji,jj,jk)  = zgrazm(ji,jj,jk)  * trn(ji,jj,jk,jpsfe) / (trn(ji,jj,jk,jppoc) + rtrn)
+               zgrazsf(ji,jj,jk)  = zgrazsd(ji,jj,jk) * trn(ji,jj,jk,jpdfe) / (trn(ji,jj,jk,jpdia) + rtrn)
+
+            END DO
+         END DO
+      END DO
+      
+#if defined key_trc_dia3d
+      ! Grazing by microzooplankton
+      grazing(:,:,:) = grazing(:,:,:) + zgrazp(:,:,:) + zgrazm(:,:,:) + zgrazsd(:,:,:) 
+#endif
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+!    Various remineralization and excretion terms
+!    --------------------------------------------
+
+               zgrarem = (  zgrazp(ji,jj,jk) + zgrazm(ji,jj,jk)  + zgrazsd(ji,jj,jk)  ) &
+                  &          * ( 1.- epsher - unass )
+               zgrafer = (  zgrazpf(ji,jj,jk) + zgrazsf(ji,jj,jk)  + zgrazmf(ji,jj,jk)  ) &
+                  &        * ( 1.- epsher - unass ) + epsher *  &
+                  &  ( zgrazm(ji,jj,jk)  * MAX((trn(ji,jj,jk,jpsfe) /(trn(ji,jj,jk,jppoc)+ rtrn)-ferat3),0.e0) &
+                  &   + zgrazp(ji,jj,jk)  * MAX((trn(ji,jj,jk,jpnfe)/(trn(ji,jj,jk,jpphy)+ rtrn)-ferat3),0.e0) &
+                  &   + zgrazsd(ji,jj,jk) * MAX((trn(ji,jj,jk,jpdfe)/(trn(ji,jj,jk,jpdia)+ rtrn)-ferat3),0.e0 )  )
+               zgrapoc = (  zgrazp(ji,jj,jk) + zgrazm(ji,jj,jk) + zgrazsd(ji,jj,jk)  ) * unass
+
+               !  Update of the TRA arrays
+               !  ------------------------
+
+               tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) + zgrarem * sigma1
+               tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) + zgrarem * sigma1
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zgrarem * (1.-sigma1)
+               tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2ut * zgrarem * sigma1
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zgrafer
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zgrapoc
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) + zgrarem * sigma1
+#if defined key_kriest
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + zgrapoc * xkr_ddiat
+#endif
+            END DO
+         END DO
+      END DO
+
+!
+!   Update the arrays TRA which contain the biological sources and sinks
+!   --------------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zmortz = ztortz(ji,jj,jk) + zrespz(ji,jj,jk)
+               tra(ji,jj,jk,jpzoo) = tra(ji,jj,jk,jpzoo) - zmortz  &
+                 &     + epsher * ( zgrazp(ji,jj,jk) + zgrazm(ji,jj,jk) + zgrazsd(ji,jj,jk))
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zgrazp(ji,jj,jk)
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zgrazsd(ji,jj,jk)
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zgrazp(ji,jj,jk)  &
+                 &     * trn(ji,jj,jk,jpnch)/(trn(ji,jj,jk,jpphy)+rtrn)
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zgrazsd(ji,jj,jk) &
+                 &     * trn(ji,jj,jk,jpdch)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpbsi) = tra(ji,jj,jk,jpbsi) - zgrazsd(ji,jj,jk) &
+                 &     * trn(ji,jj,jk,jpbsi)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) + zgrazsd(ji,jj,jk) &
+                 &     * trn(ji,jj,jk,jpbsi)/(trn(ji,jj,jk,jpdia)+rtrn)
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) - zgrazpf(ji,jj,jk)
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) - zgrazsf(ji,jj,jk)
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortz - zgrazm(ji,jj,jk)
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + ferat3 * zmortz   &
+                 &     + unass * ( zgrazpf(ji,jj,jk) + zgrazsf (ji,jj,jk)) &
+                 &     - (1.-unass) * zgrazmf(ji,jj,jk)
+               zprcaca = xfracal(ji,jj,jk) * unass * zgrazp(ji,jj,jk)
+#if defined key_trc_dia3d
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+#endif
+               zprcaca = part * zprcaca
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2. * zprcaca
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) + zprcaca
+#if defined key_kriest
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ( zmortz - zgrazm(ji,jj,jk) ) * xkr_ddiat
+#endif
+            END DO
+         END DO
+      END DO
+      !
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('micro')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+   END SUBROUTINE p4z_micro
+
+
+   SUBROUTINE p4z_micro_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_micro_init  ***
+      !!
+      !! ** Purpose :   Initialization of microzooplankton parameters
+      !!
+      !! ** Method  :   Read the nampiszoo namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampiszoo
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampiszoo/ grazrat,resrat,mzrat,xpref2c, xpref2p, &
+         &             xpref2d, xkgraz, epsher, sigma1, unass
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampiszoo )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for microzooplankton, nampiszoo'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    zoo preference for POC                    xpref2c    =', xpref2c
+         WRITE(numout,*) '    zoo preference for nano                   xpref2p    =', xpref2p
+         WRITE(numout,*) '    zoo preference for diatoms                xpref2d    =', xpref2d
+         WRITE(numout,*) '    exsudation rate of microzooplankton       resrat    =', resrat
+         WRITE(numout,*) '    microzooplankton mortality rate           mzrat     =', mzrat
+         WRITE(numout,*) '    maximal microzoo grazing rate             grazrat   =', grazrat
+         WRITE(numout,*) '    non assimilated fraction of P by microzoo unass     =', unass
+         WRITE(numout,*) '    Efficicency of microzoo growth            epsher    =', epsher
+         WRITE(numout,*) '    Fraction of microzoo excretion as DOM     sigma1    =', sigma1
+         WRITE(numout,*) '    half sturation constant for grazing 1     xkgraz    =', xkgraz
+      ENDIF
+
+   END SUBROUTINE p4z_micro_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_micro                    ! Empty routine
+   END SUBROUTINE p4z_micro
+#endif 
+
+   !!======================================================================
+END MODULE  p4zmicro
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmort.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmort.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zmort.F90	(revision 1844)
@@ -0,0 +1,285 @@
+MODULE p4zmort
+   !!======================================================================
+   !!                         ***  MODULE p4zmort  ***
+   !! TOP :   PISCES Compute the mortality terms for phytoplankton
+   !!======================================================================
+   !! History :   1.0  !  2002     (O. Aumont)  Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_mort       :   Compute the mortality terms for phytoplankton
+   !!   p4z_mort_init  :   Initialize the mortality params for phytoplankton
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE trc         ! 
+   USE sms_pisces      ! 
+   USE p4zsink
+   USE prtctl_trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_mort    
+
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+     wchl   = 0.001_wp    ,  &  !:
+     wchld  = 0.02_wp     ,  &  !:
+     mprat  = 0.01_wp     ,  &  !:
+     mprat2 = 0.01_wp     ,  &  !:
+     mpratm = 0.01_wp           !:
+
+   !! * Module variables
+   REAL(wp) :: zstep
+
+
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_mort( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_mort  ***
+      !!
+      !! ** Purpose :   Calls the different subroutine to initialize and compute
+      !!                the different phytoplankton mortality terms
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      !!---------------------------------------------------------------------
+
+      IF( ( kt * jnt ) == nittrc000  )   CALL p4z_mort_init      ! Initialization (first time-step only)
+
+      zstep = rfact2 / rday      ! Time step duration for biology
+
+      CALL p4z_nano            ! nanophytoplankton
+
+      CALL p4z_diat            ! diatoms
+
+   END SUBROUTINE p4z_mort
+
+
+   SUBROUTINE p4z_nano
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_nano  ***
+      !!
+      !! ** Purpose :   Compute the mortality terms for nanophytoplankton
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcompaph
+      REAL(wp) :: zfactfe,zfactch,zprcaca,zfracal
+      REAL(wp) :: ztortp,zrespp,zmortp
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+
+#if defined key_trc_dia3d
+     prodcal(:,:,:) = 0.  !: Initialisation of calcite production variable
+#endif
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zcompaph = MAX( ( trn(ji,jj,jk,jpphy) - 1e-8 ), 0.e0 )
+
+!     Squared mortality of Phyto similar to a sedimentation term during
+!     blooms (Doney et al. 1996)
+!     -----------------------------------------------------------------
+               zrespp = wchl * 1.e6 * zstep * xdiss(ji,jj,jk)   &
+# if defined key_off_degrad
+                  &        * facvol(ji,jj,jk)     &
+# endif
+                  &        * zcompaph * trn(ji,jj,jk,jpphy)
+
+!     Phytoplankton mortality. This mortality loss is slightly
+!     increased when nutrients are limiting phytoplankton growth
+!     as observed for instance in case of iron limitation.
+!     ----------------------------------------------------------
+               ztortp = mprat * zstep * trn(ji,jj,jk,jpphy)          &
+# if defined key_off_degrad
+                  &          * facvol(ji,jj,jk)     &
+# endif
+                  &   / ( xkmort + trn(ji,jj,jk,jpphy) ) * zcompaph
+
+
+               zmortp = zrespp + ztortp
+
+               !   Update the arrays TRA which contains the biological sources and sinks
+
+               zfactfe = trn(ji,jj,jk,jpnfe)/(trn(ji,jj,jk,jpphy)+rtrn)
+               zfactch = trn(ji,jj,jk,jpnch)/(trn(ji,jj,jk,jpphy)+rtrn)
+
+               tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) - zmortp
+               tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) - zmortp * zfactch
+               tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) - zmortp * zfactfe
+               zprcaca = xfracal(ji,jj,jk) * zmortp
+#if defined key_trc_dia3d
+               prodcal(ji,jj,jk) = prodcal(ji,jj,jk) + zprcaca  ! prodcal=prodcal(nanophy)+prodcal(microzoo)+prodcal(mesozoo)
+#endif
+               zfracal = 0.5 * xfracal(ji,jj,jk)
+               tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprcaca
+               tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - 2. * zprcaca
+               tra(ji,jj,jk,jpcal) = tra(ji,jj,jk,jpcal) + zprcaca
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortp * xkr_dnano + zrespp * xkr_ddiat
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp * zfactfe
+#else
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zfracal * zmortp
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + ( 1. - zfracal ) * zmortp
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + ( 1. - zfracal ) * zmortp * zfactfe
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zfracal * zmortp * zfactfe
+#endif
+            END DO
+         END DO
+      END DO
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('nano')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_nano
+
+   SUBROUTINE p4z_diat
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_diat  ***
+      !!
+      !! ** Purpose :   Compute the mortality terms for diatoms
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zfactfe,zfactsi,zfactch, zcompadi
+      REAL(wp) ::  zrespp2, ztortp2, zmortp2
+      CHARACTER (len=25) :: charout
+ 
+      !!---------------------------------------------------------------------
+
+
+!    Aggregation term for diatoms is increased in case of nutrient
+!    stress as observed in reality. The stressed cells become more
+!    sticky and coagulate to sink quickly out of the euphotic zone
+!     ------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zcompadi = MAX( ( trn(ji,jj,jk,jpdia) - 1e-8), 0. )
+
+!    Aggregation term for diatoms is increased in case of nutrient
+!    stress as observed in reality. The stressed cells become more
+!    sticky and coagulate to sink quickly out of the euphotic zone
+!     ------------------------------------------------------------
+
+               zrespp2  = 1.e6 * zstep * (  wchl + wchld * ( 1.- xlimdia(ji,jj,jk) )  )    &
+# if defined key_off_degrad
+                  &       * facvol(ji,jj,jk)       &
+# endif
+                  &       * xdiss(ji,jj,jk) * zcompadi * trn(ji,jj,jk,jpdia)
+                                                                               
+
+!     Phytoplankton mortality. 
+!     ------------------------
+               ztortp2  = mprat2 * zstep * trn(ji,jj,jk,jpdia)     &
+# if defined key_off_degrad
+                  &        * facvol(ji,jj,jk)       &
+# endif
+                  &      / ( xkmort + trn(ji,jj,jk,jpdia) ) * zcompadi
+
+                zmortp2 = zrespp2 + ztortp2
+
+!   Update the arrays tra which contains the biological sources and sinks
+!   ---------------------------------------------------------------------
+               zfactch = trn(ji,jj,jk,jpdch) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactfe = trn(ji,jj,jk,jpdfe) / ( trn(ji,jj,jk,jpdia) + rtrn )
+               zfactsi = trn(ji,jj,jk,jpbsi) / ( trn(ji,jj,jk,jpdia) + rtrn )
+
+               tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) - zmortp2 
+               tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) - zmortp2 * zfactch
+               tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) - zmortp2 * zfactfe
+               tra(ji,jj,jk,jpbsi) = tra(ji,jj,jk,jpbsi) - zmortp2 * zfactsi
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) + zmortp2 * zfactsi
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zmortp2  
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + ztortp2 * xkr_ddiat + zrespp2 * xkr_daggr
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zmortp2 * zfactfe
+#else
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zrespp2 + 0.5 * ztortp2
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + 0.5 * ztortp2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + 0.5 * ztortp2 * zfactfe
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + ( zrespp2 + 0.5 * ztortp2 ) * zfactfe
+#endif
+            END DO
+         END DO
+      END DO
+      !
+        IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('diat')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+             
+   END SUBROUTINE p4z_diat
+
+   SUBROUTINE p4z_mort_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_mort_init  ***
+      !!
+      !! ** Purpose :   Initialization of phytoplankton parameters
+      !!
+      !! ** Method  :   Read the nampismort namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampismort
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampismort/ wchl, wchld, mprat, mprat2, mpratm
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampismort )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for phytoplankton mortality, nampismort'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    quadratic mortality of phytoplankton      wchl      =', wchl
+         WRITE(numout,*) '    maximum quadratic mortality of diatoms    wchld     =', wchld
+         WRITE(numout,*) '    phytoplankton mortality rate              mprat     =', mprat
+         WRITE(numout,*) '    Diatoms mortality rate                    mprat2    =', mprat2
+         WRITE(numout,*) '    Phytoplankton minimum mortality rate      mpratm    =', mpratm
+      ENDIF
+
+   END SUBROUTINE p4z_mort_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_mort                    ! Empty routine
+   END SUBROUTINE p4z_mort
+#endif 
+
+   !!======================================================================
+END MODULE  p4zmort
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zopt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 1844)
@@ -0,0 +1,255 @@
+MODULE p4zopt
+   !!======================================================================
+   !!                         ***  MODULE p4zopt  ***
+   !! TOP - PISCES : Compute the light availability in the water column
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!             3.2  !  2009-04  (C. Ethe, G. Madec)  optimisaion
+   !!----------------------------------------------------------------------
+#if defined  key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_opt       : light availability in the water column
+   !!----------------------------------------------------------------------
+   USE trc            ! tracer variables
+   USE oce_trc        ! tracer-ocean share variables
+   USE trc_oce        ! ocean-tracer share variables
+   USE sms_pisces     ! Source Minus Sink of PISCES
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_opt   ! called in p4zbio.F90 module
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   etot, enano, ediat   !: PAR for phyto, nano and diat 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   emoy                 !: averaged PAR in the mixed layer
+
+   INTEGER  ::   nksrp   ! levels below which the light cannot penetrate ( depth larger than 391 m)
+   REAL(wp) ::   &
+      parlux = 0.43 / 3.e0
+
+   REAL(wp), DIMENSION(3,61), PUBLIC ::   xkrgb  !: tabulated attenuation coefficients for RGB absorption
+   
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_opt(kt, jnt)
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_opt  ***
+      !!
+      !! ** Purpose :   Compute the light availability in the water column
+      !!              depending on the depth and the chlorophyll concentration
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  ::   ji, jj, jk, jc
+      INTEGER  ::   irgb
+      REAL(wp) ::   zchl, zxsi0r
+      REAL(wp) ::   zc0 , zc1 , zc2, zc3
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zdepmoy, zetmp
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zekg, zekr, zekb
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze1 , ze2 , ze3, ze0
+      !!---------------------------------------------------------------------
+
+
+      !                                        !* tabulated attenuation coef. 
+      IF( kt * jnt == nittrc000 ) THEN
+         !                                ! level of light extinction
+         nksrp = trc_oce_ext_lev( rn_si2, 0.33e2 )
+         IF(lwp) THEN
+           WRITE(numout,*)
+           WRITE(numout,*) ' level max of computation of qsr = ', nksrp, ' ref depth = ', gdepw_0(nksrp+1), ' m'
+         ENDIF
+!!         CALL trc_oce_rgb( xkrgb )     ! tabulated attenuation coefficients
+         CALL trc_oce_rgb_read( xkrgb )     ! tabulated attenuation coefficients
+         etot (:,:,:) = 0.e0
+         enano(:,:,:) = 0.e0
+         ediat(:,:,:) = 0.e0
+         IF( ln_qsr_bio ) etot3(:,:,:) = 0.e0
+      ENDIF
+
+
+!     Initialisation of variables used to compute PAR
+!     -----------------------------------------------
+      ze1 (:,:,jpk) = 0.e0
+      ze2 (:,:,jpk) = 0.e0
+      ze3 (:,:,jpk) = 0.e0
+
+      !                                        !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
+      DO jk = 1, jpkm1                         !  --------------------------------------------------------
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zchl = ( trn(ji,jj,jk,jpnch) + trn(ji,jj,jk,jpdch) + rtrn ) * 1.e6
+               zchl = MIN(  10. , MAX( 0.03, zchl )  )
+               irgb = NINT( 41 + 20.* LOG10( zchl ) + rtrn )
+               !                                                         
+               zekb(ji,jj,jk) = xkrgb(1,irgb) * fse3t(ji,jj,jk)
+               zekg(ji,jj,jk) = xkrgb(2,irgb) * fse3t(ji,jj,jk)
+               zekr(ji,jj,jk) = xkrgb(3,irgb) * fse3t(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+!!gm  Potential BUG  must discuss with Olivier about this implementation....
+!!gm           the questions are : - PAR at T-point or mean PAR over T-level....
+!!gm                               - shallow water: no penetration of light through the bottom....
+
+
+      !                                        !* Photosynthetically Available Radiation (PAR)
+      !                                        !  --------------------------------------
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            zc1 = parlux * qsr(ji,jj) * EXP( -0.5 * zekb(ji,jj,1) )
+            zc2 = parlux * qsr(ji,jj) * EXP( -0.5 * zekg(ji,jj,1) )
+            zc3 = parlux * qsr(ji,jj) * EXP( -0.5 * zekr(ji,jj,1) )
+            ze1  (ji,jj,1) = zc1
+            ze2  (ji,jj,1) = zc2
+            ze3  (ji,jj,1) = zc3
+            etot (ji,jj,1) = (       zc1 +        zc2 +       zc3 )
+            enano(ji,jj,1) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
+            ediat(ji,jj,1) = ( 1.6 * zc1 + 0.69 * zc2 + 0.7 * zc3 )
+         END DO
+      END DO
+
+    
+      DO jk = 2, nksrp      
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zc1 = ze1(ji,jj,jk-1) * EXP( -0.5 * ( zekb(ji,jj,jk-1) + zekb(ji,jj,jk) ) )
+               zc2 = ze2(ji,jj,jk-1) * EXP( -0.5 * ( zekg(ji,jj,jk-1) + zekg(ji,jj,jk) ) )
+               zc3 = ze3(ji,jj,jk-1) * EXP( -0.5 * ( zekr(ji,jj,jk-1) + zekr(ji,jj,jk) ) )
+               ze1  (ji,jj,jk) = zc1
+               ze2  (ji,jj,jk) = zc2
+               ze3  (ji,jj,jk) = zc3
+               etot (ji,jj,jk) = (       zc1 +        zc2 +       zc3 )
+               enano(ji,jj,jk) = ( 2.1 * zc1 + 0.42 * zc2 + 0.4 * zc3 )
+               ediat(ji,jj,jk) = ( 1.6 * zc1 + 0.69 * zc2 + 0.7 * zc3 )
+            END DO
+         END DO
+      END DO
+
+      IF( ln_qsr_bio ) THEN                    !* heat flux accros w-level (used in the dynamics)
+         !                                     !  ------------------------
+         zxsi0r = 1.e0 / rn_si0
+         !
+         ze0  (:,:,1) = rn_abs * qsr(:,:)
+         ze1  (:,:,1) = parlux * qsr(:,:)             ! surface value : separation in R-G-B + near surface 
+         ze2  (:,:,1) = parlux * qsr(:,:)
+         ze3  (:,:,1) = parlux * qsr(:,:)
+         etot3(:,:,1) =          qsr(:,:) * tmask(:,:,1)
+         !
+         DO jk = 2, nksrp+1
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi
+                  zc0 = ze0(ji,jj,jk-1) * EXP( -fse3t(ji,jj,jk-1) * zxsi0r )
+                  zc1 = ze1(ji,jj,jk-1) * EXP( -zekb(ji,jj,jk-1 ) )
+                  zc2 = ze2(ji,jj,jk-1) * EXP( -zekg(ji,jj,jk-1 ) )
+                  zc3 = ze3(ji,jj,jk-1) * EXP( -zekr(ji,jj,jk-1 ) )
+                  ze0(ji,jj,jk) = zc0
+                  ze1(ji,jj,jk) = zc1
+                  ze2(ji,jj,jk) = zc2
+                  ze3(ji,jj,jk) = zc3
+                  etot3(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) * tmask(ji,jj,jk)
+              END DO
+              !
+            END DO
+            !
+        END DO
+        !
+      ENDIF
+
+      !                                        !* Euphotic depth and level
+      neln(:,:) = 1                            !  ------------------------
+      heup(:,:) = 300.
+
+      DO jk = 2, nksrp
+         DO jj = 1, jpj
+           DO ji = 1, jpi
+              IF( etot(ji,jj,jk) >= 0.0043 * qsr(ji,jj) )  THEN
+                 neln(ji,jj) = jk+1                    ! Euphotic level : 1rst T-level strictly below Euphotic layer
+                 !                                     ! nb: ensure the compatibility with nmld_trc definition in trd_mld_trc_zint
+                 heup(ji,jj) = fsdepw(ji,jj,jk+1)      ! Euphotic layer depth
+              ENDIF
+           END DO
+        END DO
+      END DO
+ 
+      heup(:,:) = MIN( 300., heup(:,:) )
+
+      !                                        !* mean light over the mixed layer
+      zdepmoy(:,:)   = 0.e0                    !  -------------------------------
+      zetmp  (:,:)   = 0.e0
+      emoy   (:,:,:) = 0.e0
+
+      DO jk = 1, nksrp
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
+                  zetmp  (ji,jj) = zetmp  (ji,jj) + etot(ji,jj,jk) * fse3t(ji,jj,jk)
+                  zdepmoy(ji,jj) = zdepmoy(ji,jj) + fse3t(ji,jj,jk)
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+      emoy(:,:,:) = etot(:,:,:)
+      !
+      DO jk = 1, nksrp
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) &
+       &           emoy(ji,jj,jk) = zetmp(ji,jj) / ( zdepmoy(ji,jj) + rtrn )
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd
+# if ! defined key_iomput
+      ! save for outputs
+      trc2d(:,:,  jp_pcs0_2d + 10) = heup(:,:  ) * tmask(:,:,1)  
+      trc3d(:,:,:,jp_pcs0_3d + 3)  = etot(:,:,:) * tmask(:,:,:)
+# else
+      ! write diagnostics 
+      IF( jnt == nrdttrc ) then 
+         CALL iom_put( "Heup", heup(:,:  ) * tmask(:,:,1) )  ! euphotic layer deptht
+         CALL iom_put( "PAR" , etot(:,:,:) * tmask(:,:,:) )  ! Photosynthetically Available Radiation
+      ENDIF
+# endif
+#endif
+      !
+   END SUBROUTINE p4z_opt
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                   No PISCES bio-model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE p4z_opt                   ! Empty routine
+   END SUBROUTINE p4z_opt
+#endif 
+
+   !!======================================================================
+END MODULE  p4zopt
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zprod.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 1844)
@@ -0,0 +1,447 @@
+MODULE p4zprod
+   !!======================================================================
+   !!                         ***  MODULE p4zprod  ***
+   !! TOP :   PISCES 
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_prod       :  
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE sms_pisces      ! 
+   USE prtctl_trc
+   USE p4zopt
+   USE p4zint
+   USE p4zlim
+   USE iom
+
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_prod    ! called in p4zbio.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+     pislope   = 3.0_wp          ,  &  !:
+     pislope2  = 3.0_wp          ,  &  !:
+     excret    = 10.e-5_wp       , &   !:
+     excret2   = 0.05_wp         , &   !:
+     chlcnm    = 0.033_wp        , &   !:
+     chlcdm    = 0.05_wp         , &   !:
+     fecnm     = 10.E-6_wp       , &   !:
+     fecdm     = 15.E-6_wp       , &   !:
+     grosip    = 0.151_wp
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk)  ::        &
+     &                   prmax
+   
+   REAL(wp) ::   &
+      texcret                    ,  &  !: 1 - excret 
+      texcret2                   ,  &  !: 1 - excret2        
+      rpis180                    ,  &  !: rpi / 180
+      tpp                              !: Total primary production
+
+   INTEGER  ::  nspyr                  !: number of timesteps per year
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_prod( kt , jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_prod  ***
+      !!
+      !! ** Purpose :   Compute the phytoplankton production depending on
+      !!              light, temperature and nutrient availability
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zsilfac, zfact
+      REAL(wp) ::   zprdiachl, zprbiochl, zsilim, ztn, zadap, zadap2
+      REAL(wp) ::   zlim, zsilfac2, zsiborn, zprod, zetot2, zmax, zproreg, zproreg2
+      REAL(wp) ::   zmxltst, zmxlday, zlim1
+      REAL(wp) ::   zpislopen  , zpislope2n
+      REAL(wp) ::   zrum, zcodel, zargu, zvol
+#if defined key_trc_diaadd && defined key_trc_dia3d
+      REAL(wp) ::   zrfact2
+#endif
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zmixnano   , zmixdiat, zstrn
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpislopead , zpislopead2
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprdia     , zprbio, zysopt
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprorca    , zprorcad, zprofed
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zprofen   , zprochln, zprochld
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpronew    , zpronewd
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+
+      IF( ( kt * jnt ) == nittrc000  )   CALL p4z_prod_init      ! Initialization (first time-step only)
+
+
+      zprorca (:,:,:) = 0.0
+      zprorcad(:,:,:) = 0.0
+      zprofed(:,:,:) = 0.0
+      zprofen(:,:,:) = 0.0
+      zprochln(:,:,:) = 0.0
+      zprochld(:,:,:) = 0.0
+      zpronew (:,:,:) = 0.0
+      zpronewd(:,:,:) = 0.0
+      zprdia  (:,:,:) = 0.0
+      zprbio  (:,:,:) = 0.0
+      zysopt  (:,:,:) = 0.0
+
+      ! Computation of the optimal production
+
+# if defined key_off_degrad
+      prmax(:,:,:) = 0.6 / rday * tgfunc(:,:,:) * facvol(:,:,:)
+# else
+      prmax(:,:,:) = 0.6 / rday * tgfunc(:,:,:)
+# endif
+
+      ! compute the day length depending on latitude and the day
+      IF(lwp) write(numout,*)
+      IF(lwp) write(numout,*) 'p4zday : - Julian day ', nday_year
+      IF(lwp) write(numout,*) '~~~~~~'
+
+      IF( nleapy == 1 .AND. MOD( nyear, 4 ) == 0 ) THEN
+         zrum = FLOAT( nday_year - 80 ) / 366.
+      ELSE
+         zrum = FLOAT( nday_year - 80 ) / 365.
+      ENDIF
+      zcodel = ASIN(  SIN( zrum * rpi * 2. ) * SIN( rpis180 * 23.5 )  )
+
+      ! day length in hours
+      zstrn(:,:) = 0.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zargu = TAN( zcodel ) * TAN( gphit(ji,jj) * rpis180 )
+            zargu = MAX( -1., MIN(  1., zargu ) )
+            zstrn(ji,jj) = MAX( 0.0, 24. - 2. * ACOS( zargu ) / rpis180 / 15. )
+         END DO
+      END DO
+
+
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+
+               ! Computation of the P-I slope for nanos and diatoms
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                   ztn    = MAX( 0., tn(ji,jj,jk) - 15. )
+                   zadap  = 0.+ 1.* ztn / ( 2.+ ztn )
+                   zadap2 = 0.e0
+
+                   zfact  = EXP( -0.21 * emoy(ji,jj,jk) )
+
+                   zpislopead (ji,jj,jk) = pislope  * ( 1.+ zadap  * zfact )
+                   zpislopead2(ji,jj,jk) = pislope2 * ( 1.+ zadap2 * zfact )
+
+                   zpislopen = zpislopead(ji,jj,jk) * trn(ji,jj,jk,jpnch)                 &
+                     &         / ( trn(ji,jj,jk,jpphy) * 12.                   + rtrn )   &
+                     &         / ( prmax(ji,jj,jk) * rday * xlimphy(ji,jj,jk) + rtrn )
+
+                   zpislope2n = zpislopead2(ji,jj,jk) * trn(ji,jj,jk,jpdch)                &
+                     &          / ( trn(ji,jj,jk,jpdia) * 12.                   + rtrn )   &
+                     &          / ( prmax(ji,jj,jk) * rday * xlimdia(ji,jj,jk) + rtrn )
+
+                   ! Computation of production function
+                   zprbio(ji,jj,jk) = prmax(ji,jj,jk) * &
+                     &                (  1.- EXP( -zpislopen * enano(ji,jj,jk) )  )
+                   zprdia(ji,jj,jk) = prmax(ji,jj,jk) * &
+                     &                (  1.- EXP( -zpislope2n * ediat(ji,jj,jk) )  )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+                IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                   !    Si/C of diatoms
+                   !    ------------------------
+                   !    Si/C increases with iron stress and silicate availability
+                   !    Si/C is arbitrariliy increased for very high Si concentrations
+                   !    to mimic the very high ratios observed in the Southern Ocean (silpot2)
+
+                  zlim1  = trn(ji,jj,jk,jpsil) / ( trn(ji,jj,jk,jpsil) + xksi1 )
+                  zlim   = xdiatno3(ji,jj,jk) + xdiatnh4(ji,jj,jk)
+
+                  zsilim = MIN( zprdia(ji,jj,jk)    / ( rtrn + prmax(ji,jj,jk) ),                 &
+                  &          trn(ji,jj,jk,jpfer) / ( concdfe(ji,jj,jk) + trn(ji,jj,jk,jpfer) ),   &
+                  &          trn(ji,jj,jk,jppo4) / ( concdnh4 + trn(ji,jj,jk,jppo4) ),            &
+                  &          zlim )
+                  zsilfac = 5.4 * EXP( -4.23 * zsilim ) * MAX( 0.e0, MIN( 1., 2.2 * ( zlim1 - 0.5 ) )  ) + 1.e0
+                  zsiborn = MAX( 0.e0, ( trn(ji,jj,jk,jpsil) - 15.e-6 ) )
+                  zsilfac2 = 1.+ 3.* zsiborn / ( zsiborn + xksi2 )
+                  zsilfac = MIN( 6.4,zsilfac * zsilfac2)
+                  zysopt(ji,jj,jk) = grosip * zlim1 * zsilfac
+
+              ENDIF
+            END DO
+         END DO
+      END DO
+
+      !  Computation of the limitation term due to
+      !  A mixed layer deeper than the euphotic depth
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zmxltst = MAX( 0.e0, hmld(ji,jj) - heup(ji,jj) )
+            zmxlday = zmxltst**2 / rday
+            zmixnano(ji,jj) = 1.- zmxlday / ( 1.+ zmxlday )
+            zmixdiat(ji,jj) = 1.- zmxlday / ( 3.+ zmxlday )
+         END DO
+      END DO
+ 
+      !  Mixed-layer effect on production                                                                               
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
+                  zprbio(ji,jj,jk) = zprbio(ji,jj,jk) * zmixnano(ji,jj)
+                  zprdia(ji,jj,jk) = zprdia(ji,jj,jk) * zmixdiat(ji,jj)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+
+      WHERE( zstrn(:,:) < 1.e0 ) zstrn(:,:) = 24.
+      zstrn(:,:) = 24. / zstrn(:,:)
+
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !     Computation of the various production terms for nanophyto.
+                  zetot2 = enano(ji,jj,jk) * zstrn(ji,jj)
+                  zmax = MAX( 0.1, xlimphy(ji,jj,jk) )
+                  zpislopen = zpislopead(ji,jj,jk)          &
+                  &         * trn(ji,jj,jk,jpnch) / ( rtrn + trn(ji,jj,jk,jpphy) * 12.)         &
+                  &         / ( prmax(ji,jj,jk) * rday * zmax + rtrn )
+
+                  zprbiochl = prmax(ji,jj,jk) * (  1.- EXP( -zpislopen * zetot2 )  )
+
+                  zprorca(ji,jj,jk) = zprbio(ji,jj,jk)  * xlimphy(ji,jj,jk) * trn(ji,jj,jk,jpphy) * rfact2
+
+                  zpronew(ji,jj,jk) = zprorca(ji,jj,jk) * xnanono3(ji,jj,jk)    &
+                  &             / ( xnanono3(ji,jj,jk) + xnanonh4(ji,jj,jk) + rtrn )
+                  zprod = rday * zprorca(ji,jj,jk) * zprbiochl * trn(ji,jj,jk,jpphy) *zmax
+
+                  zprofen(ji,jj,jk) = (fecnm)**2 * zprod / chlcnm            &
+                  &              / (  zpislopead(ji,jj,jk) * zetot2 * trn(ji,jj,jk,jpnfe) + rtrn  )
+
+                  zprochln(ji,jj,jk) = chlcnm * 144. * zprod                  &
+                  &              / (  zpislopead(ji,jj,jk) * zetot2 * trn(ji,jj,jk,jpnch) + rtrn  )
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               IF( etot(ji,jj,jk) > 1.E-3 ) THEN
+                  !  Computation of the various production terms for diatoms
+                  zetot2 = ediat(ji,jj,jk) * zstrn(ji,jj)
+                  zmax = MAX( 0.1, xlimdia(ji,jj,jk) )
+                  zpislope2n = zpislopead2(ji,jj,jk) * trn(ji,jj,jk,jpdch)        &
+                  &           / ( rtrn + trn(ji,jj,jk,jpdia) * 12.)        &
+                  &           / ( prmax(ji,jj,jk) * rday * zmax + rtrn )
+
+                  zprdiachl = prmax(ji,jj,jk) * (  1.- EXP( -zetot2 * zpislope2n )  )
+
+                  zprorcad(ji,jj,jk) = zprdia(ji,jj,jk) * xlimdia(ji,jj,jk) * trn(ji,jj,jk,jpdia) * rfact2
+
+                  zpronewd(ji,jj,jk) = zprorcad(ji,jj,jk) * xdiatno3(ji,jj,jk)     &
+                  &              / ( xdiatno3(ji,jj,jk) + xdiatnh4(ji,jj,jk) + rtrn )
+
+                  zprod = rday * zprorcad(ji,jj,jk) * zprdiachl * trn(ji,jj,jk,jpdia) * zmax
+
+                  zprofed(ji,jj,jk) = (fecdm)**2 * zprod / chlcdm                   &
+                  &              / ( zpislopead2(ji,jj,jk) * zetot2 * trn(ji,jj,jk,jpdfe) + rtrn )
+
+                  zprochld(ji,jj,jk) = chlcdm * 144. * zprod       &
+                  &              / ( zpislopead2(ji,jj,jk) * zetot2 * trn(ji,jj,jk,jpdch) + rtrn )
+
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+
+      !   Update the arrays TRA which contain the biological sources and sinks
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+           DO ji =1 ,jpi
+              zproreg  = zprorca(ji,jj,jk) - zpronew(ji,jj,jk)
+              zproreg2 = zprorcad(ji,jj,jk) - zpronewd(ji,jj,jk)
+              tra(ji,jj,jk,jppo4) = tra(ji,jj,jk,jppo4) - zprorca(ji,jj,jk) - zprorcad(ji,jj,jk)
+              tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) - zpronew(ji,jj,jk) - zpronewd(ji,jj,jk)
+              tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) - zproreg - zproreg2
+              tra(ji,jj,jk,jpphy) = tra(ji,jj,jk,jpphy) + zprorca(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jpnch) = tra(ji,jj,jk,jpnch) + zprochln(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jpnfe) = tra(ji,jj,jk,jpnfe) + zprofen(ji,jj,jk) * texcret
+              tra(ji,jj,jk,jpdia) = tra(ji,jj,jk,jpdia) + zprorcad(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdch) = tra(ji,jj,jk,jpdch) + zprochld(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdfe) = tra(ji,jj,jk,jpdfe) + zprofed(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpbsi) = tra(ji,jj,jk,jpbsi) + zprorcad(ji,jj,jk) * zysopt(ji,jj,jk) * texcret2
+              tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + &
+              &                     excret2 * zprorcad(ji,jj,jk) + excret * zprorca(ji,jj,jk)
+              tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) + o2ut * ( zproreg + zproreg2) &
+              &                    + ( o2ut + o2nit ) * ( zpronew(ji,jj,jk) + zpronewd(ji,jj,jk) )
+              tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) &
+              &                     - texcret * zprofen(ji,jj,jk) - texcret2 * zprofed(ji,jj,jk)
+              tra(ji,jj,jk,jpsil) = tra(ji,jj,jk,jpsil) &
+              &                     - texcret2 * zprorcad(ji,jj,jk) * zysopt(ji,jj,jk)
+              tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) - zprorca(ji,jj,jk) - zprorcad(ji,jj,jk)
+              tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) &
+              &                    + rno3 * ( zpronew(ji,jj,jk) + zpronewd(ji,jj,jk) )
+          END DO
+        END DO
+     END DO
+
+     ! Total primary production per year
+     DO jk = 1, jpkm1
+        DO jj = 1, jpj
+          DO ji = 1, jpi
+             zvol = cvol(ji,jj,jk)
+#if defined key_off_degrad
+             zvol = zvol * facvol(ji,jj,jk)
+#endif
+             tpp  = tpp + ( zprorca(ji,jj,jk) + zprorcad(ji,jj,jk) ) &
+                          * zvol * tmask(ji,jj,jk) * tmask_i(ji,jj)
+          END DO
+        END DO
+      END DO
+
+
+      IF( MOD( kt, nspyr ) == 0 .AND. jnt == nrdttrc ) THEN
+        IF( lk_mpp ) CALL mpp_sum( tpp )
+        WRITE(numout,*) 'Total PP :'
+        WRITE(numout,*) '-------------------- : ',tpp * 12. / 1.E12
+        WRITE(numout,*) '(GtC/yr)'
+        tpp = 0.
+      ENDIF
+
+#if defined key_trc_diaadd && defined key_trc_dia3d && ! defined key_iomput
+      !   Supplementary diagnostics
+      zrfact2 = 1.e3 * rfact2r
+      trc3d(:,:,:,jp_pcs0_3d + 4)  = zprorca (:,:,:) * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 5)  = zprorcad(:,:,:) * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 6)  = zpronew (:,:,:) * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 7)  = zpronewd(:,:,:) * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 8)  = zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) * zysopt(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 9)  = zprofed (:,:,:) * zrfact2 * tmask(:,:,:)
+#  if ! defined key_kriest
+      trc3d(:,:,:,jp_pcs0_3d + 10) = zprofen (:,:,:) * zrfact2 * tmask(:,:,:)
+#  endif
+#endif
+
+#if defined key_trc_diaadd && defined key_trc_dia3d && defined key_iomput
+      zrfact2 = 1.e3 * rfact2r
+      IF ( jnt == nrdttrc ) then
+         CALL iom_put( "PPPHY" , zprorca (:,:,:) * zrfact2 * tmask(:,:,:) )  ! primary production by nanophyto
+         CALL iom_put( "PPPHY2", zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) )  ! primary production by diatom
+         CALL iom_put( "PPNEWN", zpronew (:,:,:) * zrfact2 * tmask(:,:,:) )  ! new primary production by nanophyto
+         CALL iom_put( "PPNEWD", zpronewd(:,:,:) * zrfact2 * tmask(:,:,:) )  ! new primary production by diatom
+         CALL iom_put( "PBSi"  , zprorcad(:,:,:) * zrfact2 * tmask(:,:,:) * zysopt(:,:,:) ) ! biogenic silica production
+         CALL iom_put( "PFeD"  , zprofed (:,:,:) * zrfact2 * tmask(:,:,:) )  ! biogenic iron production by diatom
+         CALL iom_put( "PFeN"  , zprofen (:,:,:) * zrfact2 * tmask(:,:,:) )  ! biogenic iron production by nanophyto
+      ENDIF
+#endif
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('prod')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_prod
+
+   SUBROUTINE p4z_prod_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_prod_init  ***
+      !!
+      !! ** Purpose :   Initialization of phytoplankton production parameters
+      !!
+      !! ** Method  :   Read the nampisprod namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampisprod
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampisprod/ pislope, pislope2, excret, excret2, chlcnm, chlcdm,   &
+         &              fecnm, fecdm, grosip
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampisprod )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for phytoplankton growth, nampisprod'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    mean Si/C ratio                           grosip    =', grosip
+         WRITE(numout,*) '    P-I slope                                 pislope   =', pislope
+         WRITE(numout,*) '    excretion ratio of nanophytoplankton      excret    =', excret
+         WRITE(numout,*) '    excretion ratio of diatoms                excret2   =', excret2
+         WRITE(numout,*) '    P-I slope  for diatoms                    pislope2  =', pislope2
+         WRITE(numout,*) '    Minimum Chl/C in nanophytoplankton        chlcnm    =', chlcnm
+         WRITE(numout,*) '    Minimum Chl/C in diatoms                  chlcdm    =', chlcdm
+         WRITE(numout,*) '    Maximum Fe/C in nanophytoplankton         fecnm     =', fecnm
+         WRITE(numout,*) '    Minimum Fe/C in diatoms                   fecdm     =', fecdm
+      ENDIF
+
+      ! number of timesteps per year
+      nspyr  = INT( nyear_len(1) * rday / rdt )
+
+      rpis180   = rpi / 180.
+      texcret   = 1.0 - excret
+      texcret2  = 1.0 - excret2
+      tpp       = 0.
+
+   END SUBROUTINE p4z_prod_init
+
+
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_prod                    ! Empty routine
+   END SUBROUTINE p4z_prod
+#endif 
+
+   !!======================================================================
+END MODULE  p4zprod
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zrem.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 1844)
@@ -0,0 +1,470 @@
+MODULE p4zrem
+   !!======================================================================
+   !!                         ***  MODULE p4zrem  ***
+   !! TOP :   PISCES Compute remineralization/scavenging of organic compounds
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_top'       and                                      TOP models
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_rem       :   Compute remineralization/scavenging of organic compounds
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE sms_pisces      ! 
+   USE prtctl_trc
+   USE p4zint
+   USE p4zopt
+   USE p4zmeso
+   USE p4zprod
+   USE p4zche
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_rem    ! called in p4zbio.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC ::   &
+     xremik  = 0.3_wp      ,  & !:
+     xremip  = 0.025_wp    ,  & !:
+     nitrif  = 0.05_wp     ,  & !:
+     xsirem  = 0.015_wp    ,  & !:
+     xlam1   = 0.005_wp    ,  & !:
+     oxymin  = 1.e-6_wp         !:
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::    & !:
+     &                   denitr                     !: denitrification array
+
+   REAL(wp) ::   &
+     xstep            !: Time step duration for biology
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_rem(kt, jnt)
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_rem  ***
+      !!
+      !! ** Purpose :   Compute remineralization/scavenging of organic compounds
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zremip, zremik , zlam1b
+      REAL(wp) ::   zkeq  , zfeequi, zsiremin
+      REAL(wp) ::   zsatur, zsatur2, znusil
+      REAL(wp) ::   zbactfer, zorem, zorem2, zofer
+      REAL(wp) ::   zosil, zdenom1, zscave, zaggdfe
+#if ! defined key_kriest
+      REAL(wp) ::   zofer2, zdenom, zdenom2
+#endif
+      REAL(wp) ::   zlamfac, zonitr
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztempbac
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepbac, zfesatur, zolimi
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+
+      IF( ( kt * jnt ) == nittrc000  )  THEN
+         CALL p4z_rem_init                ! Initialization (first time-step only)
+         xstep = rfact2 / rday            ! Time step duration for the biology
+         nitrfac(:,:,:) = 0.0
+         denitr (:,:,:) = 0.0  
+      ENDIF
+
+
+       ! Initialisation of temprary arrys
+       zdepbac (:,:,:) = 0.0
+       zfesatur(:,:,:) = 0.0
+       zolimi  (:,:,:) = 0.0
+       ztempbac(:,:)   = 0.0
+
+!      Computation of the mean phytoplankton concentration as
+!      a crude estimate of the bacterial biomass
+!      --------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( fsdept(ji,jj,jk) < 120. ) THEN
+                  zdepbac(ji,jj,jk) = MIN( 0.7 * ( trn(ji,jj,jk,jpzoo) + 2.* trn(ji,jj,jk,jpmes) ), 4.e-6 )
+                  ztempbac(ji,jj)   = zdepbac(ji,jj,jk)
+               ELSE
+                  zdepbac(ji,jj,jk) = MIN( 1., 120./ fsdept(ji,jj,jk) ) * ztempbac(ji,jj)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!    DENITRIFICATION FACTOR COMPUTED FROM O2 LEVELS
+!    ----------------------------------------------
+
+               nitrfac(ji,jj,jk) = MAX(  0.e0, 0.4 * ( 6.e-6  - trn(ji,jj,jk,jpoxy) )    &
+                  &                                / ( oxymin + trn(ji,jj,jk,jpoxy) )  )
+            END DO
+         END DO
+      END DO
+
+      nitrfac(:,:,:) = MIN( 1., nitrfac(:,:,:) )
+
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!     DOC ammonification. Depends on depth, phytoplankton biomass
+!     and a limitation term which is supposed to be a parameterization
+!     of the bacterial activity. 
+!     ----------------------------------------------------------------
+               zremik = xremik * xstep / 1.e-6 * xlimbac(ji,jj,jk)         &
+# if defined key_off_degrad
+                  &            * facvol(ji,jj,jk)              &
+# endif
+                  &            * zdepbac(ji,jj,jk)
+               zremik = MAX( zremik, 5.5e-4 * xstep )
+
+!     Ammonification in oxic waters with oxygen consumption
+!     -----------------------------------------------------
+               zolimi(ji,jj,jk) = MIN(  ( trn(ji,jj,jk,jpoxy) - rtrn ) / o2ut,  &
+                  &                    zremik * ( 1.- nitrfac(ji,jj,jk) ) * trn(ji,jj,jk,jpdoc)  ) 
+
+!     Ammonification in suboxic waters with denitrification
+!     -------------------------------------------------------
+               denitr(ji,jj,jk) = MIN(  ( trn(ji,jj,jk,jpno3) - rtrn ) / rdenit,   &
+                  &                     zremik * nitrfac(ji,jj,jk) * trn(ji,jj,jk,jpdoc)  )
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zolimi (ji,jj,jk) = MAX( 0.e0, zolimi (ji,jj,jk) )
+               denitr (ji,jj,jk) = MAX( 0.e0, denitr (ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!    NH4 nitrification to NO3. Ceased for oxygen concentrations
+!    below 2 umol/L. Inhibited at strong light 
+!    ----------------------------------------------------------
+               zonitr  = nitrif * xstep * trn(ji,jj,jk,jpnh4) / ( 1.+ emoy(ji,jj,jk) )     &
+# if defined key_off_degrad
+                  &      * facvol(ji,jj,jk)              &
+# endif
+                  &      * ( 1.- nitrfac(ji,jj,jk) )
+
+!
+!   Update of the tracers trends
+!   ----------------------------
+
+              tra(ji,jj,jk,jpnh4) = tra(ji,jj,jk,jpnh4) - zonitr
+              tra(ji,jj,jk,jpno3) = tra(ji,jj,jk,jpno3) + zonitr
+              tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) - o2nit * zonitr
+              tra(ji,jj,jk,jptal) = tra(ji,jj,jk,jptal) - rno3  * zonitr
+
+            END DO
+         END DO
+      END DO
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem1')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!    Bacterial uptake of iron. No iron is available in DOC. So
+!    Bacteries are obliged to take up iron from the water. Some
+!    studies (especially at Papa) have shown this uptake to be
+!    significant
+!    ----------------------------------------------------------
+               zbactfer = 15.e-6 * rfact2 * 4.* 0.4 * prmax(ji,jj,jk)           &
+                  &               * ( xlimphy(ji,jj,jk) * zdepbac(ji,jj,jk))**2           &
+                  &                  / ( xkgraz2 + zdepbac(ji,jj,jk) )                    &
+                  &                  * ( 0.5 + SIGN( 0.5, trn(ji,jj,jk,jpfer) -2.e-11 )  )
+
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) - zbactfer
+#if defined key_kriest
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zbactfer
+#else
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zbactfer
+#endif
+
+            END DO
+         END DO
+      END DO
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem2')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!    POC disaggregation by turbulence and bacterial activity. 
+!    -------------------------------------------------------------
+               zremip = xremip * xstep * tgfunc(ji,jj,jk)   &
+# if defined key_off_degrad
+                  &            * facvol(ji,jj,jk)              &
+# endif
+                  &            * ( 1.- 0.5 * nitrfac(ji,jj,jk) )
+
+!    POC disaggregation rate is reduced in anoxic zone as shown by
+!    sediment traps data. In oxic area, the exponent of the martin s
+!    law is around -0.87. In anoxic zone, it is around -0.35. This
+!    means a disaggregation constant about 0.5 the value in oxic zones
+!    -----------------------------------------------------------------
+               zorem  = zremip * trn(ji,jj,jk,jppoc)
+               zofer  = zremip * trn(ji,jj,jk,jpsfe)
+#if ! defined key_kriest
+               zorem2 = zremip * trn(ji,jj,jk,jpgoc)
+               zofer2 = zremip * trn(ji,jj,jk,jpbfe)
+#else
+               zorem2 = zremip * trn(ji,jj,jk,jpnum)
+#endif
+
+!  Update the appropriate tracers trends
+!  -------------------------------------
+
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) + zorem
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) + zofer
+#if defined key_kriest
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zorem
+               tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) - zorem2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zofer
+#else
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zorem2 - zorem
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) - zorem2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zofer2 - zofer
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) - zofer2
+#endif
+
+            END DO
+         END DO
+      END DO
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem3')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!     Remineralization rate of BSi depedant on T and saturation
+!     ---------------------------------------------------------
+               zsatur  = ( sio3eq(ji,jj,jk) - trn(ji,jj,jk,jpsil) ) / ( sio3eq(ji,jj,jk) + rtrn )
+               zsatur  = MAX( rtrn, zsatur )
+               zsatur2 = zsatur * ( 1. + tn(ji,jj,jk) / 400.)**4
+               znusil  = 0.225  * ( 1. + tn(ji,jj,jk) / 15.) * zsatur + 0.775 * zsatur2**9
+#    if defined key_off_degrad
+               zsiremin = xsirem * xstep * znusil * facvol(ji,jj,jk)
+# else
+               zsiremin = xsirem * xstep * znusil
+#    endif
+               zosil = zsiremin * trn(ji,jj,jk,jpdsi)
+
+               tra(ji,jj,jk,jpdsi) = tra(ji,jj,jk,jpdsi) - zosil
+               tra(ji,jj,jk,jpsil) = tra(ji,jj,jk,jpsil) + zosil
+
+               !
+            END DO
+         END DO
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem4')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+      zfesatur(:,:,:) = 0.6e-9
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+!
+!      Compute de different ratios for scavenging of iron
+!      --------------------------------------------------
+
+#if  defined key_kriest
+                zdenom1 = trn(ji,jj,jk,jppoc) / &
+           &           ( trn(ji,jj,jk,jppoc) + trn(ji,jj,jk,jpdsi) + trn(ji,jj,jk,jpcal) + rtrn )
+#else
+                zdenom = 1. / ( trn(ji,jj,jk,jppoc) + trn(ji,jj,jk,jpgoc)  &
+           &            + trn(ji,jj,jk,jpdsi) + trn(ji,jj,jk,jpcal) + rtrn )
+
+                zdenom1 = trn(ji,jj,jk,jppoc) * zdenom
+                zdenom2 = trn(ji,jj,jk,jpgoc) * zdenom
+#endif
+
+
+!     scavenging rate of iron. this scavenging rate depends on the
+!     load in particles on which they are adsorbed. The
+!     parameterization has been taken from studies on Th
+!     ------------------------------------------------------------
+               zkeq = fekeq(ji,jj,jk)
+               zfeequi = ( -( 1. + zfesatur(ji,jj,jk) * zkeq - zkeq * trn(ji,jj,jk,jpfer) )               &
+                  &        + SQRT( ( 1. + zfesatur(ji,jj,jk) * zkeq - zkeq * trn(ji,jj,jk,jpfer) )**2       &
+                  &               + 4. * trn(ji,jj,jk,jpfer) * zkeq) ) / ( 2. * zkeq )
+
+#if defined key_kriest
+               zlam1b = 3.e-5 + xlam1 * (  trn(ji,jj,jk,jppoc)                   &
+                  &                      + trn(ji,jj,jk,jpcal) + trn(ji,jj,jk,jpdsi)  ) * 1.e6
+#else
+               zlam1b = 3.e-5 + xlam1 * (  trn(ji,jj,jk,jppoc) + trn(ji,jj,jk,jpgoc)   &
+                  &                      + trn(ji,jj,jk,jpcal) + trn(ji,jj,jk,jpdsi)  ) * 1.e6
+#endif
+
+# if defined key_off_degrad
+               zscave = zfeequi * zlam1b * xstep  * facvol(ji,jj,jk)
+# else
+               zscave = zfeequi * zlam1b * xstep
+# endif
+
+!  Increased scavenging for very high iron concentrations
+!  found near the coasts due to increased lithogenic particles
+!  and let s say it unknown processes (precipitation, ...)
+!  -----------------------------------------------------------
+               zlamfac = MAX( 0.e0, ( gphit(ji,jj) + 55.) / 30. )
+               zlamfac = MIN( 1.  , zlamfac )
+#if ! defined key_kriest
+               zlam1b = (  80.* ( trn(ji,jj,jk,jpdoc) + 35.e-6 )                           &
+                  &     + 698.*   trn(ji,jj,jk,jppoc) + 1.05e4 * trn(ji,jj,jk,jpgoc)  )                    &
+                  &   * xdiss(ji,jj,jk) + 1E-4 * (1.-zlamfac)                &
+                  &   + xlam1 * MAX( 0.e0, ( trn(ji,jj,jk,jpfer) * 1.e9 - 1.)  )
+#else
+               zlam1b = (  80.* (trn(ji,jj,jk,jpdoc) + 35E-6)           &
+                  &     + 698.*  trn(ji,jj,jk,jppoc)  )                    &
+                  &   * xdiss(ji,jj,jk) + 1E-4 * (1.-zlamfac)           &
+                  &   + xlam1 * MAX( 0.e0, ( trn(ji,jj,jk,jpfer) * 1.e9 - 1.)  )
+#endif
+
+# if defined key_off_degrad
+               zaggdfe = zlam1b * xstep * 0.5 * ( trn(ji,jj,jk,jpfer) - zfeequi ) * facvol(ji,jj,jk)
+# else
+               zaggdfe = zlam1b * xstep * 0.5 * ( trn(ji,jj,jk,jpfer) - zfeequi )
+# endif
+
+               tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) - zscave - zaggdfe
+
+#if defined key_kriest
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zscave * zdenom1
+#else
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) + zscave * zdenom1
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zscave * zdenom2
+#endif
+
+            END DO
+         END DO
+      END DO
+      !
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem5')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+!     Update the arrays TRA which contain the biological sources and sinks
+!     --------------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         tra(:,:,jk,jppo4) = tra(:,:,jk,jppo4) + zolimi(:,:,jk) + denitr(:,:,jk)
+         tra(:,:,jk,jpnh4) = tra(:,:,jk,jpnh4) + zolimi(:,:,jk) + denitr(:,:,jk)
+         tra(:,:,jk,jpno3) = tra(:,:,jk,jpno3) - denitr(:,:,jk) * rdenit
+         tra(:,:,jk,jpdoc) = tra(:,:,jk,jpdoc) - zolimi(:,:,jk) - denitr(:,:,jk)
+         tra(:,:,jk,jpoxy) = tra(:,:,jk,jpoxy) - zolimi(:,:,jk) * o2ut
+         tra(:,:,jk,jpdic) = tra(:,:,jk,jpdic) + zolimi(:,:,jk) + denitr(:,:,jk)
+         tra(:,:,jk,jptal) = tra(:,:,jk,jptal) + denitr(:,:,jk) * rno3 * rdenit
+     END DO
+
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rem6')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_rem
+
+   SUBROUTINE p4z_rem_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_rem_init  ***
+      !!
+      !! ** Purpose :   Initialization of remineralization parameters
+      !!
+      !! ** Method  :   Read the nampisrem namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampisrem
+      !!
+      !!----------------------------------------------------------------------
+
+      NAMELIST/nampisrem/ xremik, xremip, nitrif, xsirem, xlam1, oxymin
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampisrem )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist parameters for remineralization, nampisrem'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    remineralisation rate of POC              xremip    =', xremip
+         WRITE(numout,*) '    remineralization rate of DOC              xremik    =', xremik
+         WRITE(numout,*) '    remineralization rate of Si               xsirem    =', xsirem
+         WRITE(numout,*) '    scavenging rate of Iron                   xlam1     =', xlam1
+         WRITE(numout,*) '    NH4 nitrification rate                    nitrif    =', nitrif
+         WRITE(numout,*) '    halk saturation constant for anoxia       oxymin    =', oxymin
+      ENDIF
+
+   END SUBROUTINE p4z_rem_init
+
+
+
+
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_rem                    ! Empty routine
+   END SUBROUTINE p4z_rem
+#endif 
+
+   !!======================================================================
+END MODULE p4zrem
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsed.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsed.F90	(revision 1844)
@@ -0,0 +1,637 @@
+MODULE p4zsed
+   !!======================================================================
+   !!                         ***  MODULE p4sed  ***
+   !! TOP :   PISCES Compute loss of organic matter in the sediments
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   p4z_sed        :  Compute loss of organic matter in the sediments
+   !!   p4z_sbc        :  Read and interpolate time-varying nutrients fluxes
+   !!   p4z_sed_init   :  Initialization of p4z_sed
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE sms_pisces
+   USE lib_mpp
+   USE prtctl_trc
+   USE p4zbio
+   USE p4zint
+   USE p4zopt
+   USE p4zsink
+   USE p4zrem
+   USE p4zlim
+   USE lbclnk
+   USE iom
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_sed   
+
+   !! * Shared module variables
+   LOGICAL, PUBLIC ::    &
+     ln_dustfer  = .FALSE.      ,  &  !:
+     ln_river    = .FALSE.      ,  &  !:
+     ln_ndepo    = .FALSE.      ,  &  !:
+     ln_sedinput = .FALSE.            !:
+
+   REAL(wp), PUBLIC ::   &
+     sedfeinput = 1.E-9_wp   ,  &  !:
+     dustsolub  = 0.014_wp         !:
+
+   !! * Module variables
+   INTEGER ::                   &
+     ryyss,                     &  !: number of seconds per year
+     rmtss                         !: number of seconds per month
+
+   INTEGER ::                   &
+      numdust,                  &  !: logical unit for surface fluxes data
+      nflx1 , nflx2,            &  !: first and second record used
+      nflx11, nflx12      ! ???
+   REAL(wp), DIMENSION(jpi,jpj,2) ::    &  !:
+     dustmo                                !: 2 consecutive set of dust fields 
+   REAL(wp), DIMENSION(jpi,jpj)   ::    &
+     rivinp, cotdep, nitdep, dust
+   REAL(wp), DIMENSION(jpi,jpj,jpk)  ::   &
+     ironsed
+   REAL(wp) :: sumdepsi, rivalkinput, rivpo4input, nitdepinput
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Header:$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE p4z_sed(kt, jnt)
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sed  ***
+      !!
+      !! ** Purpose :   Compute loss of organic matter in the sediments. This
+      !!              is by no way a sediment model. The loss is simply 
+      !!              computed to balance the inout from rivers and dust
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, jnt ! ocean time step
+      INTEGER  ::   ji, jj, jk
+      INTEGER  ::   ikt
+#if ! defined key_sed
+      REAL(wp) ::   zsumsedsi, zsumsedpo4, zsumsedcal
+#endif
+      REAL(wp) ::   zconctmp , zdenitot  , znitrpottot
+      REAL(wp) ::   zlim, zconctmp2, zstep, zfact
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zsidep
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znitrpot, zirondep
+#if defined key_diaadd || defined key_trc_dia3d 
+      REAL(wp) :: zrfact2
+# if defined key_iomput
+     REAL(wp), DIMENSION(jpi,jpj)    ::    zw2d 
+# endif
+#endif
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+
+      IF( ( kt * jnt ) == nittrc000   )   CALL p4z_sed_init      ! Initialization (first time-step only)
+      IF( (jnt == 1) .and. ( ln_dustfer ) )  CALL p4z_sbc( kt )
+
+      zstep = rfact2 / rday      ! Time step duration for the biology
+
+      zirondep(:,:,:) = 0.e0          ! Initialisation of variables used to compute deposition
+      zsidep  (:,:)   = 0.e0
+
+      ! Iron and Si deposition at the surface
+      ! -------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zirondep(ji,jj,1) = ( dustsolub * dust(ji,jj) / ( 55.85 * rmtss ) + 3.e-10 / ryyss )   &
+               &             * rfact2 / fse3t(ji,jj,1)
+            zsidep  (ji,jj)   = 8.8 * 0.075 * dust(ji,jj) * rfact2 / ( fse3t(ji,jj,1) * 28.1 * rmtss )
+         END DO
+      END DO
+
+      ! Iron solubilization of particles in the water column
+      ! ----------------------------------------------------
+
+      DO jk = 2, jpkm1
+         zirondep(:,:,jk) = dust(:,:) / ( 10. * 55.85 * rmtss ) * rfact2 * 1.e-4
+      END DO
+
+      ! Add the external input of nutrients, carbon and alkalinity
+      ! ----------------------------------------------------------
+
+      trn(:,:,1,jppo4) = trn(:,:,1,jppo4) + rivinp(:,:) * rfact2 
+      trn(:,:,1,jpno3) = trn(:,:,1,jpno3) + (rivinp(:,:) + nitdep(:,:)) * rfact2
+      trn(:,:,1,jpfer) = trn(:,:,1,jpfer) + rivinp(:,:) * 3.e-5 * rfact2
+      trn(:,:,1,jpsil) = trn(:,:,1,jpsil) + zsidep (:,:) + cotdep(:,:)   * rfact2 / 6.
+      trn(:,:,1,jpdic) = trn(:,:,1,jpdic) + rivinp(:,:) * 2.631 * rfact2
+      trn(:,:,1,jptal) = trn(:,:,1,jptal) + (cotdep(:,:) - rno3*(rivinp(:,:) +  nitdep(:,:) ) ) * rfact2
+
+
+      ! Add the external input of iron which is 3D distributed
+      ! (dust, river and sediment mobilization)
+      ! ------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         trn(:,:,jk,jpfer) = trn(:,:,jk,jpfer) + zirondep(:,:,jk) + ironsed(:,:,jk) * rfact2
+      END DO
+
+
+#if ! defined key_sed
+      ! Initialisation of variables used to compute Sinking Speed
+      zsumsedsi  = 0.e0
+      zsumsedpo4 = 0.e0
+      zsumsedcal = 0.e0
+
+      ! Loss of biogenic silicon, Caco3 organic carbon in the sediments. 
+      ! First, the total loss is computed.
+      ! The factor for calcite comes from the alkalinity effect
+      ! -------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj)-1, 1 )
+            zfact = e1t(ji,jj) * e2t(ji,jj) / rday * tmask_i(ji,jj)
+# if defined key_kriest
+            zsumsedsi  = zsumsedsi  + zfact *  trn(ji,jj,ikt,jpdsi) * wscal (ji,jj,ikt)
+            zsumsedpo4 = zsumsedpo4 + zfact *  trn(ji,jj,ikt,jppoc) * wsbio3(ji,jj,ikt)
+# else
+            zsumsedsi  = zsumsedsi  + zfact *  trn(ji,jj,ikt,jpdsi) * wsbio4(ji,jj,ikt)
+            zsumsedpo4 = zsumsedpo4 + zfact *( trn(ji,jj,ikt,jpgoc) * wsbio4(ji,jj,ikt)   &
+               &       + trn(ji,jj,ikt,jppoc) * wsbio3(ji,jj,ikt) )
+# endif
+            zsumsedcal = zsumsedcal + zfact *  trn(ji,jj,ikt,jpcal) * wscal (ji,jj,ikt) * 2.e0
+         END DO
+      END DO
+
+      IF( lk_mpp ) THEN
+         CALL mpp_sum( zsumsedsi  )   ! sums over the global domain
+         CALL mpp_sum( zsumsedcal )   ! sums over the global domain
+         CALL mpp_sum( zsumsedpo4 )   ! sums over the global domain
+      ENDIF
+
+#endif
+
+      ! Then this loss is scaled at each bottom grid cell for
+      ! equilibrating the total budget of silica in the ocean.
+      ! Thus, the amount of silica lost in the sediments equal
+      ! the supply at the surface (dust+rivers)
+      ! ------------------------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj) - 1, 1 )
+            zconctmp = trn(ji,jj,ikt,jpdsi) * zstep / fse3t(ji,jj,ikt)   &
+# if ! defined key_kriest
+     &             * wscal (ji,jj,ikt)
+# else
+     &             * wsbio4(ji,jj,ikt)
+# endif
+            trn(ji,jj,ikt,jpdsi) = trn(ji,jj,ikt,jpdsi) - zconctmp
+
+#if ! defined key_sed
+            trn(ji,jj,ikt,jpsil) = trn(ji,jj,ikt,jpsil) + zconctmp   &
+            &      * ( 1.- ( sumdepsi + rivalkinput / ryyss / 6. ) / zsumsedsi )
+#endif
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj) - 1, 1 )
+            zconctmp = trn(ji,jj,ikt,jpcal) * wscal(ji,jj,ikt) * zstep / fse3t(ji,jj,ikt)
+            trn(ji,jj,ikt,jpcal) = trn(ji,jj,ikt,jpcal) - zconctmp
+
+#if ! defined key_sed
+            trn(ji,jj,ikt,jptal) = trn(ji,jj,ikt,jptal) + zconctmp   &
+               &   * ( 1.- ( rivalkinput / ryyss ) / zsumsedcal ) * 2.e0
+            trn(ji,jj,ikt,jpdic) = trn(ji,jj,ikt,jpdic) + zconctmp   &
+               &   * ( 1.- ( rivalkinput / ryyss ) / zsumsedcal )
+#endif
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj) - 1, 1 )
+            zfact = zstep / fse3t(ji,jj,ikt)
+# if ! defined key_kriest
+            zconctmp  = trn(ji,jj,ikt,jpgoc)
+            zconctmp2 = trn(ji,jj,ikt,jppoc)
+            trn(ji,jj,ikt,jpgoc) = trn(ji,jj,ikt,jpgoc) - zconctmp  * wsbio4(ji,jj,ikt) * zfact
+            trn(ji,jj,ikt,jppoc) = trn(ji,jj,ikt,jppoc) - zconctmp2 * wsbio3(ji,jj,ikt) * zfact
+#if ! defined key_sed
+            trn(ji,jj,ikt,jpdoc) = trn(ji,jj,ikt,jpdoc)    &
+            &      + ( zconctmp  * wsbio4(ji,jj,ikt) + zconctmp2 * wsbio3(ji,jj,ikt) ) * zfact   &
+            &      * ( 1.- rivpo4input / (ryyss * zsumsedpo4 ) )
+#endif
+            trn(ji,jj,ikt,jpbfe) = trn(ji,jj,ikt,jpbfe) - trn(ji,jj,ikt,jpbfe) * wsbio4(ji,jj,ikt) * zfact
+            trn(ji,jj,ikt,jpsfe) = trn(ji,jj,ikt,jpsfe) - trn(ji,jj,ikt,jpsfe) * wsbio3(ji,jj,ikt) * zfact
+
+# else
+            zconctmp  = trn(ji,jj,ikt,jpnum)
+            zconctmp2 = trn(ji,jj,ikt,jppoc)
+            trn(ji,jj,ikt,jpnum) = trn(ji,jj,ikt,jpnum)   &
+            &      - zconctmp  * wsbio4(ji,jj,ikt) * zfact
+            trn(ji,jj,ikt,jppoc) = trn(ji,jj,ikt,jppoc)   &
+            &      - zconctmp2 * wsbio3(ji,jj,ikt) * zfact
+#if ! defined key_sed
+            trn(ji,jj,ikt,jpdoc) = trn(ji,jj,ikt,jpdoc)    &
+            &      + ( zconctmp2 * wsbio3(ji,jj,ikt) )   &
+            &      * zfact * ( 1.- rivpo4input / ( ryyss * zsumsedpo4 ) )
+#endif
+            trn(ji,jj,ikt,jpsfe) = trn(ji,jj,ikt,jpsfe)   &
+            &      - trn(ji,jj,ikt,jpsfe) * wsbio3(ji,jj,ikt) * zfact
+
+# endif
+         END DO
+      END DO
+
+      ! Nitrogen fixation (simple parameterization). The total gain
+      ! from nitrogen fixation is scaled to balance the loss by 
+      ! denitrification
+      ! -------------------------------------------------------------
+
+      zdenitot = 0.e0
+      DO jk = 1, jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               zdenitot = zdenitot + denitr(ji,jj,jk) * rdenit * cvol(ji,jj,jk) * xnegtr(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      IF( lk_mpp )   CALL mpp_sum( zdenitot )      ! sum over the global domain
+
+      ! Potential nitrogen fixation dependant on temperature and iron
+      ! -------------------------------------------------------------
+
+!CDIR NOVERRCHK
+      DO jk = 1, jpk
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               zlim = ( 1.- xnanono3(ji,jj,jk) - xnanonh4(ji,jj,jk) )
+               IF( zlim <= 0.2 )   zlim = 0.01
+               znitrpot(ji,jj,jk) = MAX( 0.e0, ( 0.6 * tgfunc(ji,jj,jk) - 2.15 ) / rday )   &
+# if defined key_off_degrad
+               &                  * facvol(ji,jj,jk)   &
+# endif
+               &                  * zlim * rfact2 * trn(ji,jj,jk,jpfer)   &
+               &                  / ( conc3 + trn(ji,jj,jk,jpfer) ) * ( 1.- EXP( -etot(ji,jj,jk) / 50.) )
+            END DO
+         END DO 
+      END DO
+
+      znitrpottot = 0.e0
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               znitrpottot = znitrpottot + znitrpot(ji,jj,jk) * cvol(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      IF( lk_mpp )   CALL mpp_sum( znitrpottot )  ! sum over the global domain
+
+      ! Nitrogen change due to nitrogen fixation
+      ! ----------------------------------------
+
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+# if ! defined key_c1d && ( defined key_orca_r4 || defined key_orca_r2 || defined key_orca_r05 || defined key_orca_r025 )
+!!             zfact = znitrpot(ji,jj,jk) * zdenitot / znitrpottot
+               zfact = znitrpot(ji,jj,jk) * 1.e-7
+# else
+               zfact = znitrpot(ji,jj,jk) * 1.e-7
+# endif
+               trn(ji,jj,jk,jpnh4) = trn(ji,jj,jk,jpnh4) + zfact
+               trn(ji,jj,jk,jpoxy) = trn(ji,jj,jk,jpoxy) + zfact   * o2nit
+               trn(ji,jj,jk,jppo4) = trn(ji,jj,jk,jppo4) + 30./ 46.* zfact
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd || defined key_trc_dia3d
+      zrfact2 = 1.e+3 * rfact2r
+#  if  ! defined key_iomput
+      trc2d(:,:,jp_pcs0_2d + 11) = zirondep(:,:,1)         * zrfact2 * fse3t(:,:,1) * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 12) = znitrpot(:,:,1) * 1.e-7 * zrfact2 * fse3t(:,:,1) * tmask(:,:,1)
+# else
+      ! surface downward net flux of iron
+      zw2d(:,:)   =  ( zirondep(:,:,1) + ironsed(:,:,1) * rfact2 ) * zrfact2 * fse3t(:,:,1) * tmask(:,:,1) 
+      IF( jnt == nrdttrc ) CALL iom_put( "Irondep", zw2d )
+      ! nitrogen fixation at surface
+      zw2d(:,:)   =  znitrpot(:,:,1) * 1.e-7 * zrfact2  * fse3t(:,:,1) * tmask(:,:,1)
+      IF( jnt == nrdttrc ) CALL iom_put( "Nfix" , zw2d )
+# endif
+# endif
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sed ')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_sed
+
+   SUBROUTINE p4z_sbc(kt)
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_sbc  ***
+      !!
+      !! ** Purpose :   Read and interpolate the external sources of 
+      !!                nutrients
+      !!
+      !! ** Method  :   Read the files and interpolate the appropriate variables
+      !!
+      !! ** input   :   external netcdf files
+      !!
+      !!----------------------------------------------------------------------
+      !! * arguments
+      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
+
+      !! * Local declarations
+      INTEGER ::   &
+         imois, imois2,       &  ! temporary integers
+         i15  , iman             !    "          "
+      REAL(wp) ::   &
+         zxy                     !    "         "
+
+
+      !!---------------------------------------------------------------------
+
+      ! Initialization
+      ! --------------
+
+      i15 = nday / 16
+      iman  = INT( raamo )
+      imois = nmonth + i15 - 1
+      IF( imois == 0 ) imois = iman
+      imois2 = nmonth
+
+      ! 1. first call kt=nit000
+      ! -----------------------
+
+      IF( kt == nit000 ) THEN
+         ! initializations
+         nflx1  = 0
+         nflx11 = 0
+         ! open the file
+         IF(lwp) THEN
+            WRITE(numout,*) ' '
+            WRITE(numout,*) ' **** Routine p4z_sbc'
+         ENDIF
+         CALL iom_open ( 'dust.orca.nc', numdust )
+      ENDIF
+
+
+     ! Read monthly file
+      ! ----------------
+
+      IF( kt == nit000 .OR. imois /= nflx1 ) THEN
+
+         ! Calendar computation
+
+         ! nflx1 number of the first file record used in the simulation
+         ! nflx2 number of the last  file record
+
+         nflx1 = imois
+         nflx2 = nflx1+1
+         nflx1 = MOD( nflx1, iman )
+         nflx2 = MOD( nflx2, iman )
+         IF( nflx1 == 0 )   nflx1 = iman
+         IF( nflx2 == 0 )   nflx2 = iman
+         IF(lwp) WRITE(numout,*) 'first record file used nflx1 ',nflx1
+         IF(lwp) WRITE(numout,*) 'last  record file used nflx2 ',nflx2
+
+         ! Read monthly fluxes data
+
+         ! humidity
+         CALL iom_get ( numdust, jpdom_data, 'dust', dustmo(:,:,1), nflx1 )
+         CALL iom_get ( numdust, jpdom_data, 'dust', dustmo(:,:,2), nflx2 )
+
+         IF(lwp .AND. nitend-nit000 <= 100 ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' read clio flx ok'
+            WRITE(numout,*)
+               WRITE(numout,*)
+               WRITE(numout,*) 'Clio month: ',nflx1,'  field: dust'
+               CALL prihre( dustmo(:,:,1),jpi,jpj,1,jpi,20,1,jpj,10,1e9,numout )
+         ENDIF
+
+      ENDIF
+
+     ! 3. at every time step interpolation of fluxes
+      ! ---------------------------------------------
+
+      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30
+      dust(:,:) = ( (1.-zxy) * dustmo(:,:,1) + zxy * dustmo(:,:,2) )
+
+      IF( kt == nitend ) CALL iom_close (numdust)
+
+   END SUBROUTINE p4z_sbc
+
+
+   SUBROUTINE p4z_sed_init
+
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_sed_init  ***
+      !!
+      !! ** Purpose :   Initialization of the external sources of nutrients
+      !!
+      !! ** Method  :   Read the files and compute the budget
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   external netcdf files
+      !!
+      !!----------------------------------------------------------------------
+
+      INTEGER ::   ji, jj, jk, jm
+      INTEGER , PARAMETER ::   jpmois = 12, jpan = 1
+      INTEGER :: numriv, numbath, numdep
+
+
+      REAL(wp) ::   zcoef
+      REAL(wp) ::   expide, denitide,zmaskt
+      REAL(wp) , DIMENSION (jpi,jpj)     ::   riverdoc, river, ndepo
+      REAL(wp) , DIMENSION (jpi,jpj,jpk) ::   cmask
+      REAL(wp) , DIMENSION(jpi,jpj,12)    ::   zdustmo
+
+      NAMELIST/nampissed/ ln_dustfer, ln_river, ln_ndepo, ln_sedinput, sedfeinput, dustsolub
+
+
+      REWIND( numnat )                     ! read numnat
+      READ  ( numnat, nampissed )
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' Namelist : nampissed '
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~ '
+         WRITE(numout,*) '    Dust input from the atmosphere           ln_dustfer  = ', ln_dustfer
+         WRITE(numout,*) '    River input of nutrients                 ln_river    = ', ln_river
+         WRITE(numout,*) '    Atmospheric deposition of N              ln_ndepo    = ', ln_ndepo
+         WRITE(numout,*) '    Fe input from sediments                  ln_sedinput = ', ln_sedinput
+         WRITE(numout,*) '    Coastal release of Iron                  sedfeinput  =', sedfeinput
+         WRITE(numout,*) '    Solubility of the dust                   dustsolub   =', dustsolub
+      ENDIF
+
+      ! Dust input from the atmosphere
+      ! ------------------------------
+      IF( ln_dustfer ) THEN 
+         IF(lwp) WRITE(numout,*) '    Initialize dust input from atmosphere '
+         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
+         CALL iom_open ( 'dust.orca.nc', numdust )
+         DO jm = 1, jpmois
+            CALL iom_get( numdust, jpdom_data, 'dust', zdustmo(:,:,jm), jm )
+         END DO
+         CALL iom_close( numdust )
+      ELSE
+         zdustmo(:,:,:) = 0.e0
+         dust(:,:) = 0.0
+      ENDIF
+
+      ! Nutrient input from rivers
+      ! --------------------------
+      IF( ln_river ) THEN
+         IF(lwp) WRITE(numout,*) '    Initialize the nutrient input by rivers from river.orca.nc file'
+         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         CALL iom_open ( 'river.orca.nc', numriv )
+         CALL iom_get  ( numriv, jpdom_data, 'riverdic', river   (:,:), jpan )
+         CALL iom_get  ( numriv, jpdom_data, 'riverdoc', riverdoc(:,:), jpan )
+         CALL iom_close( numriv )
+      ELSE
+         river   (:,:) = 0.e0
+         riverdoc(:,:) = 0.e0
+      endif
+
+      ! Nutrient input from dust
+      ! ------------------------
+      IF( ln_ndepo ) THEN
+         IF(lwp) WRITE(numout,*) '    Initialize the nutrient input by dust from ndeposition.orca.nc'
+         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         CALL iom_open ( 'ndeposition.orca.nc', numdep )
+         CALL iom_get  ( numdep, jpdom_data, 'ndep', ndepo(:,:), jpan )
+         CALL iom_close( numdep )
+      ELSE
+         ndepo(:,:) = 0.e0
+      ENDIF
+
+      ! Coastal and island masks
+      ! ------------------------
+      IF( ln_sedinput ) THEN     
+         IF(lwp) WRITE(numout,*) '    Computation of an island mask to enhance coastal supply of iron'
+         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         IF(lwp) WRITE(numout,*) '       from bathy.orca.nc file '
+         CALL iom_open ( 'bathy.orca.nc', numbath )
+         CALL iom_get  ( numbath, jpdom_data, 'bathy', cmask(:,:,:), jpan )
+         CALL iom_close( numbath )
+         !
+         DO jk = 1, 5
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  IF( tmask(ji,jj,jk) /= 0. ) THEN
+                     zmaskt = tmask(ji+1,jj,jk) * tmask(ji-1,jj,jk) * tmask(ji,jj+1,jk)    &
+                        &                       * tmask(ji,jj-1,jk) * tmask(ji,jj,jk+1)
+                     IF( zmaskt == 0. )   cmask(ji,jj,jk ) = 0.1
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  expide   = MIN( 8.,( fsdept(ji,jj,jk) / 500. )**(-1.5) )
+                  denitide = -0.9543 + 0.7662 * LOG( expide ) - 0.235 * LOG( expide )**2
+                  cmask(ji,jj,jk) = cmask(ji,jj,jk) * MIN( 1., EXP( denitide ) / 0.5 )
+               END DO
+            END DO
+         END DO
+      ELSE
+         cmask(:,:,:) = 0.e0
+      ENDIF
+
+      CALL lbc_lnk( cmask , 'T', 1. )      ! Lateral boundary conditions on cmask   (sign unchanged)
+
+
+      ! Number of seconds per year and per month
+      ryyss = nyear_len(1) * rday
+      rmtss = ryyss / raamo
+
+      ! total atmospheric supply of Si
+      ! ------------------------------
+      sumdepsi = 0.e0
+      DO jm = 1, jpmois
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               sumdepsi = sumdepsi + zdustmo(ji,jj,jm) / (12.*rmtss) * 8.8        &
+                  &     * 0.075/28.1 * e1t(ji,jj) * e2t(ji,jj) * tmask(ji,jj,1) * tmask_i(ji,jj)
+            END DO
+         END DO
+      END DO
+      IF( lk_mpp )  CALL mpp_sum( sumdepsi )  ! sum over the global domain
+
+      ! N/P and Si releases due to coastal rivers
+      ! -----------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zcoef = ryyss * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,1) * tmask(ji,jj,1) * tmask_i(ji,jj)
+            cotdep(ji,jj) =  river(ji,jj)                  *1E9 / ( 12. * zcoef + rtrn )
+            rivinp(ji,jj) = (river(ji,jj)+riverdoc(ji,jj)) *1E9 / ( 31.6* zcoef + rtrn )
+            nitdep(ji,jj) = 7.6 * ndepo(ji,jj)                  / ( 14E6*ryyss*fse3t(ji,jj,1) + rtrn )
+         END DO
+      END DO
+      ! Lateral boundary conditions on ( cotdep, rivinp, nitdep )   (sign unchanged)
+      CALL lbc_lnk( cotdep , 'T', 1. )  ;  CALL lbc_lnk( rivinp , 'T', 1. )  ;  CALL lbc_lnk( nitdep , 'T', 1. )
+
+      rivpo4input = 0.e0
+      rivalkinput = 0.e0
+      nitdepinput = 0.e0
+      DO jj = 2 , jpjm1
+         DO ji = fs_2, fs_jpim1
+            zcoef = cvol(ji,jj,1) * ryyss
+            rivpo4input = rivpo4input + rivinp(ji,jj) * zcoef
+            rivalkinput = rivalkinput + cotdep(ji,jj) * zcoef
+            nitdepinput = nitdepinput + nitdep(ji,jj) * zcoef
+         END DO
+     END DO
+      IF( lk_mpp ) THEN
+         CALL mpp_sum( rivpo4input )  ! sum over the global domain
+         CALL mpp_sum( rivalkinput )  ! sum over the global domain
+         CALL mpp_sum( nitdepinput )  ! sum over the global domain
+      ENDIF
+
+
+      ! Coastal supply of iron
+      ! -------------------------
+      DO jk = 1, jpkm1
+         ironsed(:,:,jk) = sedfeinput * cmask(:,:,jk) / ( fse3t(:,:,jk) * rday )
+      END DO
+      CALL lbc_lnk( ironsed , 'T', 1. )      ! Lateral boundary conditions on ( ironsed )   (sign unchanged)
+
+
+   END SUBROUTINE p4z_sed_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_sed                         ! Empty routine
+   END SUBROUTINE p4z_sed
+#endif 
+
+   !!======================================================================
+END MODULE  p4zsed
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsink.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 1844)
@@ -0,0 +1,742 @@
+MODULE p4zsink
+   !!======================================================================
+   !!                         ***  MODULE p4zsink  ***
+   !! TOP :   PISCES Compute vertical flux of particulate matter due to gravitational sinking
+   !!======================================================================
+   !! History :   1.0  !  2004     (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   p4z_sink       :  Compute vertical flux of particulate matter due to gravitational sinking
+   !!----------------------------------------------------------------------
+   USE trc
+   USE oce_trc         !
+   USE sms_pisces
+   USE prtctl_trc
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   p4z_sink    ! called in p4zbio.F90
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+     wsbio3, wsbio4,      &    !: POC and GOC sinking speeds
+     wscal                     !: Calcite and BSi sinking speeds
+
+   !! * Module variables
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &   !:
+     sinking, sinking2,   &    !: POC sinking fluxes (different meanings depending on the parameterization
+     sinkcal, sinksil,    &    !: CaCO3 and BSi sinking fluxes
+     sinkfer                   !: Small BFe sinking flux
+
+   REAL(wp) ::   &
+     xstep , xstep2            !: Time step duration for biology
+
+   INTEGER  :: &
+      iksed  = 10              !
+
+#if  defined key_kriest
+   REAL(wp)          ::       &   
+      xkr_sfact    = 250.  ,  &   !: Sinking factor
+      xkr_stick    = 0.2   ,  &   !: Stickiness
+      xkr_nnano    = 2.337 ,  &   !: Nbr of cell in nano size class
+      xkr_ndiat    = 3.718 ,  &   !: Nbr of cell in diatoms size class
+      xkr_nmeso    = 7.147 ,  &   !: Nbr of cell in mesozoo  size class
+      xkr_naggr    = 9.877        !: Nbr of cell in aggregates  size class
+
+   REAL(wp)          ::       &   
+      xkr_frac
+
+   REAL(wp), PUBLIC ::        &
+      xkr_dnano            ,  &   !: Size of particles in nano pool
+      xkr_ddiat            ,  &   !: Size of particles in diatoms pool
+      xkr_dmeso            ,  &   !: Size of particles in mesozoo pool
+      xkr_daggr            ,  &   !: Size of particles in aggregates pool
+      xkr_wsbio_min        ,  &   !: min vertical particle speed
+      xkr_wsbio_max               !: max vertical particle speed
+
+   REAL(wp), PUBLIC, DIMENSION(jpk) ::   &   !:
+      xnumm                       !:     maximum number of particles in aggregates
+
+#endif
+
+#if ! defined key_kriest
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &   !:
+     sinkfer2                  !: Big Fe sinking flux
+#endif 
+
+   !!* Substitution
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_kriest
+
+   SUBROUTINE p4z_sink ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                ***  ROUTINE p4z_sink  ***
+      !!
+      !! ** Purpose :   Compute vertical flux of particulate matter due to
+      !!              gravitational sinking - Kriest parameterization
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zagg1, zagg2, zagg3, zagg4, zagg5, zaggsi, zaggsh
+      REAL(wp) :: zagg , zaggdoc, znumdoc
+      REAL(wp) :: znum , zeps, zfm, zgm, zsm
+      REAL(wp) :: zdiv , zdiv1, zdiv2, zdiv3, zdiv4, zdiv5
+      REAL(wp) :: zval1, zval2, zval3, zval4
+#if defined key_trc_diaadd
+      REAL(wp) :: zrfact2
+      INTEGER  :: ik1
+#endif
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znum3d
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+      IF( ( kt * jnt ) == nittrc000  )  THEN 
+          CALL p4z_sink_init   ! Initialization (first time-step only)
+          xstep  = rfact2 / rday      ! Time step duration for biology
+          xstep2 = rfact2 /  2.
+      ENDIF
+
+!     Initialisation of variables used to compute Sinking Speed
+!     ---------------------------------------------------------
+
+       znum3d(:,:,:) = 0.e0
+       zval1 = 1. + xkr_zeta
+       zval2 = 1. + xkr_zeta + xkr_eta
+       zval3 = 1. + xkr_eta
+
+!     Computation of the vertical sinking speed : Kriest et Evans, 2000
+!     -----------------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) /= 0.e0 ) THEN
+                  znum = trn(ji,jj,jk,jppoc) / ( trn(ji,jj,jk,jpnum) + rtrn ) / xkr_massp
+! -------------- To avoid sinking speed over 50 m/day -------
+                  znum  = MIN( xnumm(jk), znum )
+                  znum  = MAX( 1.1      , znum )
+                  znum3d(ji,jj,jk) = znum
+!------------------------------------------------------------
+                  zeps  = ( zval1 * znum - 1. )/ ( znum - 1. )
+                  zfm   = xkr_frac**( 1. - zeps )
+                  zgm   = xkr_frac**( zval1 - zeps )
+                  zdiv  = MAX( 1.e-4, ABS( zeps - zval2 ) ) * SIGN( 1., ( zeps - zval2 ) )
+                  zdiv1 = zeps - zval3
+                  wsbio3(ji,jj,jk) = xkr_wsbio_min * ( zeps - zval1 ) / zdiv    &
+     &                             - xkr_wsbio_max *   zgm * xkr_eta  / zdiv
+                  wsbio4(ji,jj,jk) = xkr_wsbio_min *   ( zeps-1. )    / zdiv1   &
+     &                             - xkr_wsbio_max *   zfm * xkr_eta  / zdiv1
+                  IF( znum == 1.1)   wsbio3(ji,jj,jk) = wsbio4(ji,jj,jk)
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      wscal(:,:,:) = MAX( wsbio3(:,:,:), 50. )
+
+
+!   INITIALIZE TO ZERO ALL THE SINKING ARRAYS
+!   -----------------------------------------
+
+      sinking (:,:,:) = 0.e0
+      sinking2(:,:,:) = 0.e0
+      sinkcal (:,:,:) = 0.e0
+      sinkfer (:,:,:) = 0.e0
+      sinksil (:,:,:) = 0.e0
+
+!   Compute the sedimentation term using p4zsink2 for all
+!   the sinking particles
+!   -----------------------------------------------------
+
+      CALL p4z_sink2( wsbio3, sinking , jppoc )
+      CALL p4z_sink2( wsbio4, sinking2, jpnum )
+      CALL p4z_sink2( wsbio3, sinkfer , jpsfe )
+      CALL p4z_sink2( wscal , sinksil , jpdsi )
+      CALL p4z_sink2( wscal , sinkcal , jpcal )
+
+!  Exchange between organic matter compartments due to
+!  coagulation/disaggregation
+!  ---------------------------------------------------
+
+      zval1 = 1. + xkr_zeta
+      zval2 = 1. + xkr_eta
+      zval3 = 3. + xkr_eta
+      zval4 = 4. + xkr_eta
+
+      DO jk = 1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               IF( tmask(ji,jj,jk) /= 0.e0 ) THEN
+
+                  znum = trn(ji,jj,jk,jppoc)/(trn(ji,jj,jk,jpnum)+rtrn) / xkr_massp
+! -------------- To avoid sinking speed over 50 m/day -------
+                  znum  = min(xnumm(jk),znum)
+                  znum  = MAX( 1.1,znum)
+!------------------------------------------------------------
+                  zeps  = ( zval1 * znum - 1.) / ( znum - 1.)
+                  zdiv  = MAX( 1.e-4, ABS( zeps - zval3) ) * SIGN( 1., zeps - zval3 )
+                  zdiv1 = MAX( 1.e-4, ABS( zeps - 4.   ) ) * SIGN( 1., zeps - 4.    )
+                  zdiv2 = zeps - 2.
+                  zdiv3 = zeps - 3.
+                  zdiv4 = zeps - zval2
+                  zdiv5 = 2.* zeps - zval4
+                  zfm   = xkr_frac**( 1.- zeps )
+                  zsm   = xkr_frac**xkr_eta
+
+!    Part I : Coagulation dependant on turbulence
+!    ----------------------------------------------
+
+                  zagg1 = ( 0.163 * trn(ji,jj,jk,jpnum)**2               &
+                     &            * 2.*( (zfm-1.)*(zfm*xkr_mass_max**3-xkr_mass_min**3)    &
+                     &            * (zeps-1)/zdiv1 + 3.*(zfm*xkr_mass_max-xkr_mass_min)    &
+                     &            * (zfm*xkr_mass_max**2-xkr_mass_min**2)                  &
+                     &            * (zeps-1.)**2/(zdiv2*zdiv3))            &
+# if defined key_off_degrad
+                     &                 *facvol(ji,jj,jk)       &
+# endif
+                     &    )
+
+                  zagg2 = (  2*0.163*trn(ji,jj,jk,jpnum)**2*zfm*                       &
+                     &                   ((xkr_mass_max**3+3.*(xkr_mass_max**2          &
+                     &                    *xkr_mass_min*(zeps-1.)/zdiv2                 &
+                     &                    +xkr_mass_max*xkr_mass_min**2*(zeps-1.)/zdiv3)    &
+                     &                    +xkr_mass_min**3*(zeps-1)/zdiv1)                  &
+                     &                    -zfm*xkr_mass_max**3*(1.+3.*((zeps-1.)/           &
+                     &                    (zeps-2.)+(zeps-1.)/zdiv3)+(zeps-1.)/zdiv1))      &
+#    if defined key_off_degrad
+                     &                 *facvol(ji,jj,jk)             &
+#    endif
+                     &    )
+
+                  zagg3 = (  0.163*trn(ji,jj,jk,jpnum)**2*zfm**2*8. * xkr_mass_max**3   &
+#    if defined key_off_degrad
+                     &                 *facvol(ji,jj,jk)             &
+#    endif
+                     &    )
+
+                  zaggsh = ( zagg1 + zagg2 + zagg3 ) * rfact2 * xdiss(ji,jj,jk) / 1000.
+
+!    Aggregation of small into large particles
+!    Part II : Differential settling
+!    ----------------------------------------------
+
+                  zagg4 = (  2.*3.141*0.125*trn(ji,jj,jk,jpnum)**2*                       &
+                     &                 xkr_wsbio_min*(zeps-1.)**2                         &
+                     &                 *(xkr_mass_min**2*((1.-zsm*zfm)/(zdiv3*zdiv4)      &
+                     &                 -(1.-zfm)/(zdiv*(zeps-1.)))-                       &
+                     &                 ((zfm*zfm*xkr_mass_max**2*zsm-xkr_mass_min**2)     &
+                     &                 *xkr_eta)/(zdiv*zdiv3*zdiv5) )                     &
+# if defined key_off_degrad
+                     &                 *facvol(ji,jj,jk)        &
+# endif
+                     &    )
+
+                  zagg5 = (  2.*3.141*0.125*trn(ji,jj,jk,jpnum)**2                         &
+                     &                 *(zeps-1.)*zfm*xkr_wsbio_min                        &
+                     &                 *(zsm*(xkr_mass_min**2-zfm*xkr_mass_max**2)         &
+                     &                 /zdiv3-(xkr_mass_min**2-zfm*zsm*xkr_mass_max**2)    &
+                     &                 /zdiv)                   &
+# if defined key_off_degrad
+                     &                 *facvol(ji,jj,jk)        &
+# endif
+                     &    )
+
+                  zaggsi = ( zagg4 + zagg5 ) * xstep / 10.
+
+                  zagg = 0.5 * xkr_stick * ( zaggsh + zaggsi )
+
+!     Aggregation of DOC to small particles
+!     --------------------------------------
+
+                  zaggdoc = ( 0.4 * trn(ji,jj,jk,jpdoc)               &
+                     &        + 1018.  * trn(ji,jj,jk,jppoc)  ) * xstep    &
+# if defined key_off_degrad
+                     &        * facvol(ji,jj,jk)                              &
+# endif
+                     &        * xdiss(ji,jj,jk) * trn(ji,jj,jk,jpdoc)
+
+                  znumdoc = trn(ji,jj,jk,jpnum) / ( trn(ji,jj,jk,jppoc) + rtrn )
+                  tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) + zaggdoc
+                  tra(ji,jj,jk,jpnum) = tra(ji,jj,jk,jpnum) + zaggdoc * znumdoc - zagg
+                  tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) - zaggdoc
+
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd
+      zrfact2 = 1.e3 * rfact2r
+      ik1 = iksed + 1
+#  if ! defined key_iomput
+      trc2d(:,:  ,jp_pcs0_2d + 4)  = sinking (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:  ,jp_pcs0_2d + 5)  = sinking2(:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:  ,jp_pcs0_2d + 6)  = sinkfer (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:  ,jp_pcs0_2d + 7)  = sinksil (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:  ,jp_pcs0_2d + 8)  = sinkcal (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc3d(:,:,:,jp_pcs0_3d + 11) = sinking (:,:,:)      * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 12) = sinking2(:,:,:)      * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 13) = sinksil (:,:,:)      * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 14) = sinkcal (:,:,:)      * zrfact2 * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 15) = znum3d  (:,:,:)                * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 16) = wsbio3  (:,:,:)                * tmask(:,:,:)
+      trc3d(:,:,:,jp_pcs0_3d + 17) = wsbio4  (:,:,:)                * tmask(:,:,:)
+#else
+      IF( jnt == nrdttrc ) then
+        CALL iom_put( "POCFlx"  , sinking (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! POC export
+        CALL iom_put( "NumFlx"  , sinking2 (:,:,:)     * zrfact2 * tmask(:,:,:) )  ! Num export
+        CALL iom_put( "SiFlx"   , sinksil (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! Silica export
+        CALL iom_put( "CaCO3Flx", sinkcal (:,:,:)      * zrfact2 * tmask(:,:,:) )  ! Calcite export
+        CALL iom_put( "xnum"    , znum3d  (:,:,:)                * tmask(:,:,:) )  ! Number of particles in aggregats
+        CALL iom_put( "W1"      , wsbio3  (:,:,:)                * tmask(:,:,:) )  ! sinking speed of POC
+        CALL iom_put( "W2"      , wsbio4  (:,:,:)                * tmask(:,:,:) )  ! sinking speed of aggregats
+        CALL iom_put( "PMO"     , sinking (:,:,ik1) * zrfact2 * tmask(:,:,1) )  ! POC export at 100m
+        CALL iom_put( "PMO2"    , sinking2(:,:,ik1) * zrfact2 * tmask(:,:,1) )  ! Num export at 100m
+        CALL iom_put( "ExpFe1"  , sinkfer (:,:,ik1) * zrfact2 * tmask(:,:,1) )  ! Export of iron at 100m
+        CALL iom_put( "ExpSi"   , sinksil (:,:,ik1) * zrfact2 * tmask(:,:,1) )  ! export of silica at 100m
+        CALL iom_put( "ExpCaCO3", sinkcal (:,:,ik1) * zrfact2 * tmask(:,:,1) )  ! export of calcite at 100m
+     ENDIF
+#  endif
+
+#endif
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sink')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_sink
+
+   SUBROUTINE p4z_sink_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE p4z_sink_init  ***
+      !!
+      !! ** Purpose :   Initialization of sinking parameters
+      !!                Kriest parameterization only
+      !!
+      !! ** Method  :   Read the nampiskrs namelist and check the parameters
+      !!      called at the first timestep (nittrc000)
+      !!
+      !! ** input   :   Namelist nampiskrs
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk, jn, kiter
+      REAL(wp) ::   znum, zdiv
+      REAL(wp) ::   zws, zwr, zwl,wmax, znummax
+      REAL(wp) ::   zmin, zmax, zl, zr, xacc
+
+      NAMELIST/nampiskrs/ xkr_sfact, xkr_stick ,  &
+         &                xkr_nnano, xkr_ndiat, xkr_nmeso, xkr_naggr
+
+      !!----------------------------------------------------------------------
+      REWIND( numnat )                     ! read nampiskrs
+      READ  ( numnat, nampiskrs )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampiskrs'
+         WRITE(numout,*) '    Sinking factor                           xkr_sfact    = ', xkr_sfact
+         WRITE(numout,*) '    Stickiness                               xkr_stick    = ', xkr_stick
+         WRITE(numout,*) '    Nbr of cell in nano size class           xkr_nnano    = ', xkr_nnano
+         WRITE(numout,*) '    Nbr of cell in diatoms size class        xkr_ndiat    = ', xkr_ndiat
+         WRITE(numout,*) '    Nbr of cell in mesozoo size class        xkr_nmeso    = ', xkr_nmeso
+         WRITE(numout,*) '    Nbr of cell in aggregates size class     xkr_naggr    = ', xkr_naggr
+     ENDIF
+
+
+     ! max and min vertical particle speed
+     xkr_wsbio_min = xkr_sfact * xkr_mass_min**xkr_eta
+     xkr_wsbio_max = xkr_sfact * xkr_mass_max**xkr_eta
+     WRITE(numout,*) ' max and min vertical particle speed ', xkr_wsbio_min, xkr_wsbio_max
+
+     !
+     !    effect of the sizes of the different living pools on particle numbers
+     !    nano = 2um-20um -> mean size=6.32 um -> ws=2.596 -> xnum=xnnano=2.337
+     !    diat and microzoo = 10um-200um -> 44.7 -> 8.732 -> xnum=xndiat=3.718
+     !    mesozoo = 200um-2mm -> 632.45 -> 45.14 -> xnum=xnmeso=7.147
+     !    aggregates = 200um-10mm -> 1414 -> 74.34 -> xnum=xnaggr=9.877
+     !    doc aggregates = 1um
+     ! ----------------------------------------------------------
+
+     xkr_dnano = 1. / ( xkr_massp * xkr_nnano )
+     xkr_ddiat = 1. / ( xkr_massp * xkr_ndiat )
+     xkr_dmeso = 1. / ( xkr_massp * xkr_nmeso )
+     xkr_daggr = 1. / ( xkr_massp * xkr_naggr )
+
+      !!---------------------------------------------------------------------
+      !!    'key_kriest'                                                  ???
+      !!---------------------------------------------------------------------
+      !  COMPUTATION OF THE VERTICAL PROFILE OF MAXIMUM SINKING SPEED
+      !  Search of the maximum number of particles in aggregates for each k-level.
+      !  Bissection Method
+      !--------------------------------------------------------------------
+      WRITE(numout,*)
+      WRITE(numout,*)'    kriest : Compute maximum number of particles in aggregates'
+
+      xacc     =  0.001
+      kiter    = 50
+      zmin     =  1.10
+      zmax     = xkr_mass_max / xkr_mass_min
+      xkr_frac = zmax
+
+      DO jk = 1,jpk
+         zl = zmin
+         zr = zmax
+         wmax = 0.5 * fse3t(1,1,jk) * rday / rfact2
+         zdiv = xkr_zeta + xkr_eta - xkr_eta * zl
+         znum = zl - 1.
+         zwl =  xkr_wsbio_min * xkr_zeta / zdiv &
+            & - ( xkr_wsbio_max * xkr_eta * znum * &
+            &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+            & - wmax
+
+         zdiv = xkr_zeta + xkr_eta - xkr_eta * zr
+         znum = zr - 1.
+         zwr =  xkr_wsbio_min * xkr_zeta / zdiv &
+            & - ( xkr_wsbio_max * xkr_eta * znum * &
+            &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+            & - wmax
+iflag:  DO jn = 1, kiter
+           IF( zwl == 0.e0 ) THEN
+              znummax = zl
+           ELSE IF ( zwr == 0.e0 ) THEN
+              znummax = zr
+           ELSE
+              znummax = ( zr + zl ) / 2.
+              zdiv = xkr_zeta + xkr_eta - xkr_eta * znummax
+              znum = znummax - 1.
+              zws =  xkr_wsbio_min * xkr_zeta / zdiv &
+                 & - ( xkr_wsbio_max * xkr_eta * znum * &
+                 &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                 & - wmax
+              IF( zws * zwl < 0. ) THEN
+                 zr = znummax
+              ELSE
+                 zl = znummax
+              ENDIF
+              zdiv = xkr_zeta + xkr_eta - xkr_eta * zl
+              znum = zl - 1.
+              zwl =  xkr_wsbio_min * xkr_zeta / zdiv &
+                 & - ( xkr_wsbio_max * xkr_eta * znum * &
+                 &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                 & - wmax
+
+              zdiv = xkr_zeta + xkr_eta - xkr_eta * zr
+              znum = zr - 1.
+              zwr =  xkr_wsbio_min * xkr_zeta / zdiv &
+                 & - ( xkr_wsbio_max * xkr_eta * znum * &
+                 &     xkr_frac**( -xkr_zeta / znum ) / zdiv ) &
+                 & - wmax
+
+              IF ( ABS ( zws )  <= xacc ) EXIT iflag
+
+           ENDIF
+
+        END DO iflag
+
+        xnumm(jk) = znummax
+        WRITE(numout,*) '       jk = ', jk, ' wmax = ', wmax,' xnum max = ', xnumm(jk)
+
+     END DO
+
+  END SUBROUTINE p4z_sink_init
+
+#else
+
+   SUBROUTINE p4z_sink ( kt, jnt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sink  ***
+      !!
+      !! ** Purpose :   Compute vertical flux of particulate matter due to 
+      !!                gravitational sinking
+      !!
+      !! ** Method  : - ???
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt, jnt
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zagg1, zagg2, zagg3, zagg4
+      REAL(wp) ::   zagg , zaggfe, zaggdoc, zaggdoc2
+      REAL(wp) ::   zfact, zwsmax
+#if defined key_trc_dia3d
+      REAL(wp) ::   zrfact2
+      INTEGER  ::   ik1
+#endif
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( ( kt * jnt ) == nittrc000  )  THEN
+          xstep  = rfact2 / rday      ! Timestep duration for biology
+          xstep2 = rfact2 /  2.
+      ENDIF
+
+!    Sinking speeds of detritus is increased with depth as shown
+!    by data and from the coagulation theory
+!    -----------------------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji=1,jpi
+               zfact = MAX( 0., fsdepw(ji,jj,jk+1)-hmld(ji,jj) ) / 4000.
+               wsbio4(ji,jj,jk) = wsbio2 + ( 200.- wsbio2 ) * zfact
+            END DO
+         END DO
+      END DO
+
+!      LIMIT THE VALUES OF THE SINKING SPEEDS 
+!      TO AVOID NUMERICAL INSTABILITIES
+
+      wsbio3(:,:,:) = wsbio
+!
+! OA Below, this is garbage. the ideal would be to find a time-splitting
+! OA algorithm that does not increase the computing cost by too much
+! OA In ROMS, I have included a time-splitting procedure. But it is 
+! OA too expensive as the loop is computed globally. Thus, a small e3t
+! OA at one place determines the number of subtimesteps globally
+! OA AWFULLY EXPENSIVE !! Not able to find a better approach. Damned !!
+
+      DO jk = 1,jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwsmax = 0.8 * fse3t(ji,jj,jk) / xstep
+               wsbio4(ji,jj,jk) = MIN( wsbio4(ji,jj,jk), zwsmax )
+               wsbio3(ji,jj,jk) = MIN( wsbio3(ji,jj,jk), zwsmax )
+            END DO
+         END DO
+      END DO
+
+      wscal(:,:,:) = wsbio4(:,:,:)
+
+!   INITIALIZE TO ZERO ALL THE SINKING ARRAYS
+!   -----------------------------------------
+
+      sinking (:,:,:) = 0.e0
+      sinking2(:,:,:) = 0.e0
+      sinkcal (:,:,:) = 0.e0
+      sinkfer (:,:,:) = 0.e0
+      sinksil (:,:,:) = 0.e0
+      sinkfer2(:,:,:) = 0.e0
+
+!   Compute the sedimentation term using p4zsink2 for all
+!   the sinking particles
+!   -----------------------------------------------------
+
+      CALL p4z_sink2( wsbio3, sinking , jppoc )
+      CALL p4z_sink2( wsbio3, sinkfer , jpsfe )
+      CALL p4z_sink2( wsbio4, sinking2, jpgoc )
+      CALL p4z_sink2( wsbio4, sinkfer2, jpbfe )
+      CALL p4z_sink2( wsbio4, sinksil , jpdsi )
+      CALL p4z_sink2( wscal , sinkcal , jpcal )
+
+!  Exchange between organic matter compartments due to
+!  coagulation/disaggregation
+!  ---------------------------------------------------
+
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zfact = xstep * xdiss(ji,jj,jk)
+               !  Part I : Coagulation dependent on turbulence
+# if defined key_off_degrad
+               zagg1 = 940.* zfact * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jppoc) * facvol(ji,jj,jk)
+               zagg2 = 1.054e4 * zfact * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpgoc) * facvol(ji,jj,jk)
+# else
+               zagg1 = 940.* zfact * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jppoc)
+               zagg2 = 1.054e4 * zfact * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpgoc)
+# endif
+
+               ! Part II : Differential settling
+
+               !  Aggregation of small into large particles
+# if defined key_off_degrad
+               zagg3 = 0.66 * xstep * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpgoc) * facvol(ji,jj,jk)
+               zagg4 = 0.e0 * xstep * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jppoc) * facvol(ji,jj,jk)
+# else
+               zagg3 = 0.66 * xstep * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jpgoc)
+               zagg4 = 0.e0 * xstep * trn(ji,jj,jk,jppoc) * trn(ji,jj,jk,jppoc)
+# endif
+               zagg   = zagg1 + zagg2 + zagg3 + zagg4
+               zaggfe = zagg * trn(ji,jj,jk,jpsfe) / ( trn(ji,jj,jk,jppoc) + rtrn )
+
+               ! Aggregation of DOC to small particles
+#if defined key_off_degrad
+               zaggdoc = ( 80.* trn(ji,jj,jk,jpdoc) + 698. * trn(ji,jj,jk,jppoc) )       &
+                  &      * facvol(ji,jj,jk)  * zfact * trn(ji,jj,jk,jpdoc)
+               zaggdoc2 = 1.05e4 * zfact * trn(ji,jj,jk,jpgoc)   &
+                  &      * facvol(ji,jj,jk) * trn(ji,jj,jk,jpdoc)
+#else
+               zaggdoc = ( 80.* trn(ji,jj,jk,jpdoc) + 698. * trn(ji,jj,jk,jppoc) )    &
+                  &      *  zfact * trn(ji,jj,jk,jpdoc)
+               zaggdoc2 = 1.05e4 * zfact * trn(ji,jj,jk,jpgoc) * trn(ji,jj,jk,jpdoc)
+#endif
+               !  Update the trends
+               tra(ji,jj,jk,jppoc) = tra(ji,jj,jk,jppoc) - zagg + zaggdoc
+               tra(ji,jj,jk,jpgoc) = tra(ji,jj,jk,jpgoc) + zagg + zaggdoc2
+               tra(ji,jj,jk,jpsfe) = tra(ji,jj,jk,jpsfe) - zaggfe
+               tra(ji,jj,jk,jpbfe) = tra(ji,jj,jk,jpbfe) + zaggfe
+               tra(ji,jj,jk,jpdoc) = tra(ji,jj,jk,jpdoc) - zaggdoc - zaggdoc2
+               !
+            END DO
+         END DO
+      END DO
+
+#if defined key_trc_diaadd
+      zrfact2 = 1.e3 * rfact2r
+      ik1  = iksed + 1
+#  if ! defined key_iomput
+      trc2d(:,:,jp_pcs0_2d + 4) = sinking (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 5) = sinking2(:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 6) = sinkfer (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 7) = sinkfer2(:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 8) = sinksil (:,:,ik1) * zrfact2 * tmask(:,:,1)
+      trc2d(:,:,jp_pcs0_2d + 9) = sinkcal (:,:,ik1) * zrfact2 * tmask(:,:,1)
+#  else
+      IF( jnt == nrdttrc )  then
+         CALL iom_put( "EPC100"  , ( sinking(:,:,ik1) + sinking2(:,:,ik1) ) * zrfact2 * tmask(:,:,1) ) ! Export of carbon at 100m
+         CALL iom_put( "EPFE100" , ( sinkfer(:,:,ik1) + sinkfer2(:,:,ik1) ) * zrfact2 * tmask(:,:,1) ) ! Export of iron at 100m
+         CALL iom_put( "EPCAL100",   sinkcal(:,:,ik1)                       * zrfact2 * tmask(:,:,1) ) ! Export of calcite  at 100m
+         CALL iom_put( "EPSI100" ,   sinksil(:,:,ik1)                       * zrfact2 * tmask(:,:,1) ) ! Export of biogenic silica at 100m
+      ENDIF
+#endif
+#endif
+      !
+       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sink')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
+       ENDIF
+
+   END SUBROUTINE p4z_sink
+
+#endif
+
+   SUBROUTINE p4z_sink2( pwsink, psinkflx, jp_tra )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE p4z_sink2  ***
+      !!
+      !! ** Purpose :   Compute the sedimentation terms for the various sinking
+      !!     particles. The scheme used to compute the trends is based
+      !!     on MUSCL.
+      !!
+      !! ** Method  : - this ROUTINE compute not exactly the advection but the
+      !!      transport term, i.e.  div(u*tra).
+      !!---------------------------------------------------------------------
+      INTEGER , INTENT(in   )                         ::   jp_tra    ! tracer index index      
+      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk) ::   pwsink    ! sinking speed
+      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   psinkflx  ! sinking fluxe
+      !!
+      INTEGER  ::   ji, jj, jk, jn
+      REAL(wp) ::   zigma,zew,zign, zflx
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  ztraz, zakz
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zwsink2
+      !!---------------------------------------------------------------------
+
+
+      ztraz(:,:,:) = 0.e0
+      zakz (:,:,:) = 0.e0
+
+      DO jk = 1, jpkm1
+# if defined key_off_degrad
+         zwsink2(:,:,jk+1) = -pwsink(:,:,jk) / rday * tmask(:,:,jk+1) * facvol(:,:,jk)
+# else
+         zwsink2(:,:,jk+1) = -pwsink(:,:,jk) / rday * tmask(:,:,jk+1)
+# endif
+      END DO
+      zwsink2(:,:,1) = 0.e0
+
+
+      ! Vertical advective flux
+      DO jn = 1, 2
+         !  first guess of the slopes interior values
+         DO jk = 2, jpkm1
+            ztraz(:,:,jk) = ( trn(:,:,jk-1,jp_tra) - trn(:,:,jk,jp_tra) ) * tmask(:,:,jk)
+         END DO
+         ztraz(:,:,1  ) = 0.0
+         ztraz(:,:,jpk) = 0.0
+
+         ! slopes
+         DO jk = 2, jpkm1
+            DO jj = 1,jpj
+               DO ji = 1, jpi
+                  zign = 0.25 + SIGN( 0.25, ztraz(ji,jj,jk) * ztraz(ji,jj,jk+1) )
+                  zakz(ji,jj,jk) = ( ztraz(ji,jj,jk) + ztraz(ji,jj,jk+1) ) * zign
+               END DO
+            END DO
+         END DO
+         
+         ! Slopes limitation
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zakz(ji,jj,jk) = SIGN( 1., zakz(ji,jj,jk) ) *        &
+                     &             MIN( ABS( zakz(ji,jj,jk) ), 2. * ABS(ztraz(ji,jj,jk+1)), 2. * ABS(ztraz(ji,jj,jk) ) )
+               END DO
+            END DO
+         END DO
+         
+         ! vertical advective flux
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj      
+               DO ji = 1, jpi    
+                  zigma = zwsink2(ji,jj,jk+1) * xstep2 / fse3w(ji,jj,jk+1)
+                  zew   = zwsink2(ji,jj,jk+1)
+                  psinkflx(ji,jj,jk+1) = -zew * ( trn(ji,jj,jk,jp_tra) - 0.5 * ( 1 + zigma ) * zakz(ji,jj,jk) ) * xstep2
+               END DO
+            END DO
+         END DO
+         !
+         ! Boundary conditions
+         psinkflx(:,:,1  ) = 0.e0
+         psinkflx(:,:,jpk) = 0.e0
+         
+         DO jk=1,jpkm1
+            DO jj = 1,jpj
+               DO ji = 1, jpi
+                  zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
+                  trn(ji,jj,jk,jp_tra) = trn(ji,jj,jk,jp_tra) + zflx
+               END DO
+            END DO
+         END DO
+
+      ENDDO
+
+      DO jk=1,jpkm1
+         DO jj = 1,jpj
+            DO ji = 1, jpi
+               zflx = ( psinkflx(ji,jj,jk) - psinkflx(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
+               trb(ji,jj,jk,jp_tra) = trb(ji,jj,jk,jp_tra) + 2. * zflx
+            END DO
+         END DO
+      END DO
+
+      trn(:,:,:,jp_tra) = trb(:,:,:,jp_tra)
+      psinkflx(:,:,:)   = 2. * psinkflx(:,:,:)
+
+      !
+   END SUBROUTINE p4z_sink2
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE p4z_sink                    ! Empty routine
+   END SUBROUTINE p4z_sink
+#endif 
+
+   !!======================================================================
+END MODULE  p4zsink
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/par_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/par_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/par_pisces.F90	(revision 1844)
@@ -0,0 +1,126 @@
+MODULE par_pisces
+   !!======================================================================
+   !!                        ***  par_pisces  ***
+   !! TOP :   set the PISCES parameters
+   !!======================================================================
+   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_lobster, ONLY : jp_lobster      !: number of tracers in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_2d   !: number of 2D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_3d   !: number of 3D diag in LOBSTER
+   USE par_lobster, ONLY : jp_lobster_trd  !: number of biological diag in LOBSTER
+
+   IMPLICIT NONE
+   PUBLIC
+
+   INTEGER, PUBLIC, PARAMETER ::   jp_l      = jp_lobster      !: cumulative number of already defined TRC
+   INTEGER, PUBLIC, PARAMETER ::   jp_l_2d   = jp_lobster_2d   !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_l_3d   = jp_lobster_3d   !:
+   INTEGER, PUBLIC, PARAMETER ::   jp_l_trd  = jp_lobster_trd  !:
+
+#if defined key_pisces  &&  defined key_kriest
+   !!---------------------------------------------------------------------
+   !!   'key_pisces' & 'key_kriest'                 PISCES bio-model + ???
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
+   LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .TRUE.  !: Kriest flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  23     !: number of passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  =  13     !: additional 2d output ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_3d  =  18     !: additional 3d output ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_trd =   1     !: number of sms trends for PISCES
+
+   ! assign an index in trc arrays for each LOBSTER prognostic variables
+   !    WARNING: be carefull about the order when reading the restart
+        !   !!gm  this warning should be obsolet with IOM
+   INTEGER, PUBLIC, PARAMETER ::   jpdic = jp_l +  1    !: dissolved inoganic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jptal = jp_l +  2    !: total alkalinity 
+   INTEGER, PUBLIC, PARAMETER ::   jpoxy = jp_l +  3    !: oxygen carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpcal = jp_l +  4    !: calcite  concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppo4 = jp_l +  5    !: phosphate concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppoc = jp_l +  6    !: small particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsil = jp_l +  7    !: silicate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpphy = jp_l +  8    !: phytoplancton concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpzoo = jp_l +  9    !: zooplancton concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdoc = jp_l + 10    !: dissolved organic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpdia = jp_l + 11    !: Diatoms Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpmes = jp_l + 12    !: Mesozooplankton Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpbsi = jp_l + 13    !: (big) Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpfer = jp_l + 14    !: Iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnum = jp_l + 15    !: Big iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsfe = jp_l + 16    !: number of particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdfe = jp_l + 17    !: Diatoms iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdsi = jp_l + 18    !: Diatoms Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnfe = jp_l + 19    !: Nano iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnch = jp_l + 20    !: Nano Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdch = jp_l + 21    !: Diatoms Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpno3 = jp_l + 22    !: Nitrates Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnh4 = jp_l + 23    !: Ammonium Concentration
+
+#elif defined key_pisces
+   !!---------------------------------------------------------------------
+   !!   'key_pisces'   :                         standard PISCES bio-model
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .TRUE.  !: PISCES flag 
+   LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .FALSE. !: Kriest flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces     = 24      !: number of PISCES passive tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  = 13      !: additional 2d output ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_3d  = 11      !: additional 3d output ('key_trc_diaadd')
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_trd =  1      !: number of sms trends for PISCES
+
+   ! assign an index in trc arrays for each LOBSTER prognostic variables
+   !    WARNING: be carefull about the order when reading the restart
+        !   !!gm  this warning should be obsolet with IOM
+   INTEGER, PUBLIC, PARAMETER ::   jpdic = jp_l +  1    !: dissolved inoganic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jptal = jp_l +  2    !: total alkalinity 
+   INTEGER, PUBLIC, PARAMETER ::   jpoxy = jp_l +  3    !: oxygen carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpcal = jp_l +  4    !: calcite  concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppo4 = jp_l +  5    !: phosphate concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jppoc = jp_l +  6    !: small particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsil = jp_l +  7    !: silicate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpphy = jp_l +  8    !: phytoplancton concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpzoo = jp_l +  9    !: zooplancton concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdoc = jp_l + 10    !: dissolved organic carbon concentration 
+   INTEGER, PUBLIC, PARAMETER ::   jpdia = jp_l + 11    !: Diatoms Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpmes = jp_l + 12    !: Mesozooplankton Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpbsi = jp_l + 13    !: (big) Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpfer = jp_l + 14    !: Iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpbfe = jp_l + 15    !: Big iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpgoc = jp_l + 16    !: big particulate organic phosphate concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpsfe = jp_l + 17    !: Small iron particles Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdfe = jp_l + 18    !: Diatoms iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdsi = jp_l + 19    !: Diatoms Silicate Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnfe = jp_l + 20    !: Nano iron Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnch = jp_l + 21    !: Nano Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpdch = jp_l + 22    !: Diatoms Chlorophyll Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpno3 = jp_l + 23    !: Nitrates Concentration
+   INTEGER, PUBLIC, PARAMETER ::   jpnh4 = jp_l + 24    !: Ammonium Concentration
+
+#else
+   !!---------------------------------------------------------------------
+   !!   Default                                   No CFC geochemical model
+   !!---------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_pisces     = .FALSE.  !: CFC flag 
+   LOGICAL, PUBLIC, PARAMETER ::   lk_kriest     = .FALSE.  !: Kriest flag 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces     =  0       !: No CFC tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_2d  =  0       !: No CFC additional 2d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_3d  =  0       !: No CFC additional 3d output arrays 
+   INTEGER, PUBLIC, PARAMETER ::   jp_pisces_trd =  0       !: number of sms trends for PISCES
+#endif
+
+   ! Starting/ending PISCES do-loop indices (N.B. no PISCES : jpl_pcs < jpf_pcs the do-loop are never done)
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs0     = jp_l + 1                  !: First index of PISCES tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs1     = jp_l + jp_pisces          !: Last  index of PISCES tracers
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs0_2d  = jp_l_2d + 1               !: First index of 2D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs1_2d  = jp_l_2d + jp_pisces_2d    !: Last  index of 2D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs0_3d  = jp_l_3d + 1               !: First index of 3D diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs1_3d  = jp_l_3d + jp_pisces_3d    !: Last  index of 3d diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs0_trd = jp_l_trd + 1              !: First index of bio diag
+   INTEGER, PUBLIC, PARAMETER ::   jp_pcs1_trd = jp_l_trd + jp_pisces_trd  !: Last  index of bio diag
+
+
+   !!======================================================================
+END MODULE par_pisces
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/sms_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 1844)
@@ -0,0 +1,97 @@
+MODULE sms_pisces   
+   !!----------------------------------------------------------------------
+   !!                     ***  sms_pisces.F90  ***  
+   !! TOP :   PISCES Source Minus Sink variables
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2000-02 (O. Aumont) original code
+   !!             3.2  !  2009-04 (C. Ethe & NEMO team) style
+   !!----------------------------------------------------------------------
+
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                         PISCES model
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE par_trc
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!*  Time variables
+   INTEGER  ::   nrdttrc           !: ???
+   INTEGER  ::   ndayflxtr         !: ???
+   REAL(wp) ::   rfact , rfactr    !: ???
+   REAL(wp) ::   rfact2, rfact2r   !: ???
+
+   !!*  Biological parameters 
+   REAL(wp) ::   part              !: ???
+   REAL(wp) ::   rno3              !: ???
+   REAL(wp) ::   o2ut              !: ???
+   REAL(wp) ::   po4r              !: ???
+   REAL(wp) ::   rdenit            !: ???
+   REAL(wp) ::   o2nit             !: ???
+   REAL(wp) ::   wsbio, wsbio2     !: ???
+   REAL(wp) ::   xkmort            !: ???
+   REAL(wp) ::   ferat3            !: ???
+
+   !!* Damping 
+   LOGICAL  ::   ln_pisdmp         !: relaxation or not of nutrients to a mean value
+                                   !: when initialize from a restart file 
+   LOGICAL  ::   ln_pisclo         !: Restoring or not of nutrients to initial value
+                                   !: on close seas
+
+   !!*  Biological fluxes for light
+   INTEGER , DIMENSION(jpi,jpj)     ::   neln       !: number of T-levels + 1 in the euphotic layer
+   REAL(wp), DIMENSION(jpi,jpj)     ::   heup       !: euphotic layer depth
+
+   !!*  Biological fluxes for primary production
+   REAL(wp), DIMENSION(jpi,jpj)     ::   xksi       !: ???
+   REAL(wp), DIMENSION(jpi,jpj)     ::   xksimax    !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xnanono3   !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiatno3   !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xnanonh4   !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiatnh4   !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimphy    !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimdia    !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   concdfe    !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   concnfe    !: ???
+
+   !!*  SMS for the organic matter
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xfracal    !: ??
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   nitrfac    !: ??
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xlimbac    !: ??
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   xdiss      !: ??
+#if defined key_trc_dia3d
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   prodcal    !: Calcite production
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   grazing    !: Total zooplankton grazing
+#endif
+
+   !!* Variable for chemistry of the CO2 cycle
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   akb3       !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ak13       !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ak23       !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   aksp       !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   akw3       !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   borat      !: ???
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   hi         !: ???
+
+#if defined key_kriest
+   !!*  Kriest parameter for aggregation
+   REAL(wp) ::   xkr_eta                            !: ???
+   REAL(wp) ::   xkr_zeta                           !: ???
+   REAL(wp) ::   xkr_massp                          !: ???
+   REAL(wp) ::   xkr_mass_min, xkr_mass_max         !: ???
+#endif
+
+#else
+   !!----------------------------------------------------------------------   
+   !!  Empty module :                                     NO PISCES model
+   !!----------------------------------------------------------------------
+#endif
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.2 , LOCEAN-IPSL (2009) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!======================================================================   
+END MODULE sms_pisces    
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcctl_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcctl_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcctl_pisces.F90	(revision 1844)
@@ -0,0 +1,69 @@
+MODULE trcctl_pisces
+   !!======================================================================
+   !!                         ***  trcctl_pisces.F90  ***
+   !! TOP :                Control of PISCES biogeochemical model
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2000-12 (C. Ethe) assign a parameter to name individual tracers
+   !!----------------------------------------------------------------------
+
+#if defined key_pisces
+
+   USE oce_trc
+   USE trc
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl_pisces     ! called by ???
+
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl_pisces
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_pisces  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' use PISCES biological model '
+
+   ! Check number of tracers
+   ! -----------------------
+#if  defined key_kriest
+      IF( jp_pisces /= 23) THEN 
+#else
+      IF( jp_pisces /= 24) THEN
+#endif
+          IF (lwp) THEN 
+              WRITE (numout,*) ' ===>>>> : w a r n i n g '
+              WRITE (numout,*) ' =======   ============= '
+              WRITE (numout,*)                               &
+              &   ' STOP, change jp_pisces',               & 
+              &   ' in par_pisces.F90'  
+          END IF 
+          STOP 'TRC_CTL'
+      END IF 
+
+   END SUBROUTINE trc_ctl_pisces
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                            No PISCES
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl_pisces                 ! Dummy routine
+   END SUBROUTINE trc_ctl_pisces
+#endif
+
+   !!======================================================================
+END MODULE trcctl_pisces
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 1844)
@@ -0,0 +1,141 @@
+MODULE trcini_pisces
+   !!======================================================================
+   !!                         ***  MODULE trcini_pisces  ***
+   !! TOP :   initialisation of the PISCES biochemical model
+   !!======================================================================
+   !! History :    -   !  1988-07  (E. Maier-Reiner) Original code
+   !!              -   !  1999-10  (O. Aumont, C. Le Quere)
+   !!              -   !  2002     (O. Aumont)  PISCES
+   !!             1.0  !  2005-03  (O. Aumont, A. El Moussaoui) F90
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec) from trcini.pisces.h90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !! trc_ini_pisces   : PISCES biochemical model initialisation
+   !!----------------------------------------------------------------------
+   USE par_trc         ! TOP parameters
+   USE sms_pisces      ! Source Minus Sink variables
+   USE trc
+   USE oce_trc         ! ocean variables
+   USE p4zche 
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_ini_pisces   ! called by trcini.F90 module
+
+   !! * Module variables
+   REAL(wp) :: &
+      sco2   =  2.312e-3         , &
+      alka0  =  2.423e-3         , &
+      oxyg0  =  177.6e-6         , &
+      po4    =  2.174e-6         , &
+      bioma0 =  1.000e-8         , &
+      silic1 =  91.65e-6         , &
+      no3    =  31.04e-6 * 7.6
+
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ini_pisces
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_ini_pisces ***
+      !!
+      !! ** Purpose :   Initialisation of the PISCES biochemical model
+      !!----------------------------------------------------------------------
+
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_pisces :   PISCES biochemical model initialisation'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+
+      !                                            ! Time-step
+      rfact   = rdttra(1) * float(ndttrc)          ! ---------
+      rfactr  = 1. / rfact
+      rfact2  = rfact / float(nrdttrc)
+      rfact2r = 1. / rfact2
+
+      IF(lwp) WRITE(numout,*) '    Tracer  time step    rfact  = ', rfact, ' rdt = ', rdt
+      IF(lwp) write(numout,*) '    Biology time step    rfact2 = ', rfact2
+
+
+
+      ! Set biological ratios
+      ! ---------------------
+      rno3   = (16.+2.) / 122.
+      po4r   =   1.e0   / 122.
+      o2nit  =  32.     / 122.
+      rdenit =  97.6    /  16.
+      o2ut   = 140.     / 122.
+
+      CALL p4z_che        ! initialize the chemical constants
+
+      ndayflxtr = 0      !  Initialize a counter for the computation of chemistry
+
+      ! Initialization of tracer concentration in case of  no restart 
+      !--------------------------------------------------------------
+      IF( .NOT. ln_rsttr ) THEN  
+         
+         trn(:,:,:,jpdic) = sco2
+         trn(:,:,:,jpdoc) = bioma0
+         trn(:,:,:,jptal) = alka0
+         trn(:,:,:,jpoxy) = oxyg0
+         trn(:,:,:,jpcal) = bioma0
+         trn(:,:,:,jppo4) = po4 / po4r
+         trn(:,:,:,jppoc) = bioma0
+#  if ! defined key_kriest
+         trn(:,:,:,jpgoc) = bioma0
+         trn(:,:,:,jpbfe) = bioma0 * 5.e-6
+#  else
+         trn(:,:,:,jpnum) = bioma0 / ( 6. * xkr_massp )
+#  endif
+         trn(:,:,:,jpsil) = silic1
+         trn(:,:,:,jpbsi) = bioma0 * 0.15
+         trn(:,:,:,jpdsi) = bioma0 * 5.e-6
+         trn(:,:,:,jpphy) = bioma0
+         trn(:,:,:,jpdia) = bioma0
+         trn(:,:,:,jpzoo) = bioma0
+         trn(:,:,:,jpmes) = bioma0
+         trn(:,:,:,jpfer) = 0.6E-9
+         trn(:,:,:,jpsfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpdfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpnfe) = bioma0 * 5.e-6
+         trn(:,:,:,jpnch) = bioma0 * 12. / 55.
+         trn(:,:,:,jpdch) = bioma0 * 12. / 55.
+         trn(:,:,:,jpno3) = no3
+         trn(:,:,:,jpnh4) = bioma0
+
+         ! initialize the half saturation constant for silicate
+         ! ----------------------------------------------------
+         xksi(:,:)    = 2.e-6
+         xksimax(:,:) = xksi(:,:)
+
+      ENDIF
+
+      IF(lwp) WRITE(numout,*) 'Initialization of PISCES tracers done'
+      IF(lwp) WRITE(numout,*) ' '
+
+      !
+   END SUBROUTINE trc_ini_pisces
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                            No PISCES biochemical model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini_pisces             ! Empty routine
+   END SUBROUTINE trc_ini_pisces
+#endif
+
+   !!======================================================================
+END MODULE trcini_pisces
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90	(revision 1844)
@@ -0,0 +1,207 @@
+MODULE trclsm_pisces
+   !!======================================================================
+   !!                      ***  MODULE trclsm_lobster  ***
+   !! TOP :   initialisation of some run parameters for PISCES bio-model
+   !!======================================================================
+   !! History :    -   !  1999-10 (M.A. Foujols, M. Levy) original code
+   !!              -   !  2000-01 (L. Bopp) hamocc3, p3zd
+   !!             1.0  !  2003-08 (C. Ethe)  module F90
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec) from trclsm.pisces.h90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'   :                                   PISCES bio-model
+   !!----------------------------------------------------------------------
+   !! trc_lsm_pisces       : PISCES model namelist read
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE sms_pisces      ! sms trends
+   USE in_out_manager  ! I/O manager
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_lsm_pisces   ! called by trclsm.F90 module
+
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lsm_pisces
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_lsm_pisces  ***  
+      !!
+      !! ** Purpose :   read PISCES namelist
+      !!
+      !! ** input   :   file 'namelist.trc.sms' containing the following
+      !!             namelist: natext, natbio, natsms
+      !!                       natkriest ("key_kriest")
+      !!----------------------------------------------------------------------
+      !!
+#if defined key_trc_diaadd && ! defined key_iomput
+      INTEGER ::  jl, jn
+      ! definition of additional diagnostic as a structure
+      TYPE DIAG
+         CHARACTER(len = 20)  :: snamedia   !: short name
+         CHARACTER(len = 80 ) :: lnamedia   !: long name
+         CHARACTER(len = 20 ) :: unitdia    !: unit
+      END TYPE DIAG
+
+      TYPE(DIAG) , DIMENSION(jp_pisces_2d) :: pisdia2d
+      TYPE(DIAG) , DIMENSION(jp_pisces_3d) :: pisdia3d
+#endif
+
+      NAMELIST/nampisbio/ part, nrdttrc, wsbio, xkmort, ferat3, wsbio2
+#if defined key_kriest
+      NAMELIST/nampiskrp/ xkr_eta, xkr_zeta, xkr_mass_min, xkr_mass_max
+#endif
+#if defined key_trc_diaadd && ! defined key_iomput
+      NAMELIST/nampisdia/ nwritedia, pisdia3d, pisdia2d     ! additional diagnostics
+#endif
+      NAMELIST/nampisdmp/ ln_pisdmp, ln_pisclo
+
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_lsm_pisces : read PISCES namelists'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+
+      !                               ! Open the namelist file
+      !                               ! ----------------------
+      CALL ctl_opn( numnat, 'namelist_pisces', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+
+      REWIND( numnat )                    
+      READ  ( numnat, nampisbio )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*) ' Namelist : nampisbio'
+         WRITE(numout,*) '    part of calcite not dissolved in guts     part      =', part
+         WRITE(numout,*) '    frequence pour la biologie                nrdttrc   =', nrdttrc
+         WRITE(numout,*) '    POC sinking speed                         wsbio     =', wsbio
+         WRITE(numout,*) '    half saturation constant for mortality    xkmort    =', xkmort
+         WRITE(numout,*) '    Fe/C in zooplankton                       ferat3    =', ferat3
+         WRITE(numout,*) '    Big particles sinking speed               wsbio2    =', wsbio2
+      ENDIF
+
+#if defined key_kriest
+
+      !                               ! nampiskrp : kriest parameters
+      !                               ! -----------------------------
+      xkr_eta      = 0.62        
+      xkr_zeta     = 1.62        
+      xkr_mass_min = 0.0002     
+      xkr_mass_max = 1.      
+
+      REWIND( numnat )                     ! read natkriest
+      READ  ( numnat, nampiskrp )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampiskrp'
+         WRITE(numout,*) '    Sinking  exponent                        xkr_eta      = ', xkr_eta
+         WRITE(numout,*) '    N content exponent                       xkr_zeta     = ', xkr_zeta
+         WRITE(numout,*) '    Minimum mass for Aggregates              xkr_mass_min = ', xkr_mass_min
+         WRITE(numout,*) '    Maximum mass for Aggregates              xkr_mass_max = ', xkr_mass_max
+         WRITE(numout,*)
+     ENDIF
+
+
+     ! Computation of some variables
+     xkr_massp = 5.7E-6 * 7.6 * xkr_mass_min**xkr_zeta
+
+#endif
+      !
+#if defined key_trc_diaadd && ! defined key_iomput
+
+      ! Namelist namlobdia
+      ! -------------------
+      nwritedia = 10                   ! default values
+
+      DO jl = 1, jp_pisces_2d
+         jn = jp_pcs0_2d + jl - 1
+         WRITE(ctrc2d(jn),'("2D_",I1)') jn                      ! short name
+         WRITE(ctrc2l(jn),'("2D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc2u(jn) = ' '                                       ! units
+      END DO
+      !                                 ! 3D output arrays
+      DO jl = 1, jp_pisces_3d
+         jn = jp_pcs0_3d + jl - 1
+         WRITE(ctrc3d(jn),'("3D_",I1)') jn                      ! short name
+         WRITE(ctrc3l(jn),'("3D DIAGNOSTIC NUMBER ",I2)') jn    ! long name
+         ctrc3u(jn) = ' '                                       ! units
+      END DO
+
+      REWIND( numnat )               ! read natrtd
+      READ  ( numnat, nampisdia )
+
+      DO jl = 1, jp_pisces_2d
+         jn = jp_pcs0_2d + jl - 1
+         ctrc2d(jn) = pisdia2d(jl)%snamedia
+         ctrc2l(jn) = pisdia2d(jl)%lnamedia
+         ctrc2u(jn) = pisdia2d(jl)%unitdia
+      END DO
+
+      DO jl = 1, jp_pisces_3d
+         jn = jp_pcs0_3d + jl - 1
+         ctrc3d(jn) = pisdia3d(jl)%snamedia
+         ctrc3l(jn) = pisdia3d(jl)%lnamedia
+         ctrc3u(jn) = pisdia3d(jl)%unitdia
+      END DO
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : natadd'
+         WRITE(numout,*) '    frequency of outputs for additional arrays nwritedia = ', nwritedia
+         DO jl = 1, jp_pisces_3d
+            jn = jp_pcs0_3d + jl - 1
+            WRITE(numout,*) '   3d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc3d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc3l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc3u(jn))
+            WRITE(numout,*) ' '
+         END DO
+
+         DO jl = 1, jp_pisces_2d
+            jn = jp_pcs0_2d + jl - 1
+            WRITE(numout,*) '   2d output field No : ',jn
+            WRITE(numout,*) '   short name         : ', TRIM(ctrc2d(jn))
+            WRITE(numout,*) '   long name          : ', TRIM(ctrc2l(jn))
+            WRITE(numout,*) '   unit               : ', TRIM(ctrc2u(jn))
+            WRITE(numout,*) ' '
+         END DO
+      ENDIF
+#endif
+
+      REWIND( numnat )
+      READ  ( numnat, nampisdmp )
+
+      IF(lwp) THEN                         ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : nampisdmp'
+         WRITE(numout,*) '    Relaxation of tracer to glodap mean value            ln_pisdmp      =', ln_pisdmp
+         WRITE(numout,*) '    Restoring of tracer to initial value  on closed seas  ln_pisclo      =', ln_pisclo
+         WRITE(numout,*) ' '
+      ENDIF
+
+   END SUBROUTINE trc_lsm_pisces
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                   No PISCES bio-model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lsm_pisces                      ! Empty routine
+   END  SUBROUTINE  trc_lsm_pisces
+#endif  
+
+   !!======================================================================
+END MODULE trclsm_pisces
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 1844)
@@ -0,0 +1,301 @@
+MODULE trcrst_pisces
+   !!======================================================================
+   !!                       ***  MODULE trcrst_pisces  ***
+   !! TOP :   create, write, read the restart files of PISCES tracer
+   !!======================================================================
+   !! History :   1.0  !  2010-01 (C. Ethe) Original
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                               pisces tracers
+   !!----------------------------------------------------------------------
+   !!   trc_rst_read_pisces   : read  restart file
+   !!   trc_rst_wri_pisces    : write restart file
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! Ocean variables
+   USE par_trc         ! TOP parameters
+   USE trc             ! TOP variables
+   USE trcsms_pisces          ! pisces sms trends
+   USE sms_pisces          ! pisces sms variables
+   USE in_out_manager  ! I/O manager
+   USE iom
+   USE trcdta
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC  trc_rst_read_pisces   ! called by trcini.F90 module
+   PUBLIC  trc_rst_wri_pisces   ! called by trcini.F90 module
+
+CONTAINS
+   
+   SUBROUTINE trc_rst_read_pisces( knum ) 
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_pisces  ***  
+      !!
+      !! ** Purpose : Read in restart file specific variables from pisces model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: knum  ! unit of the restart file
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+      !!----------------------------------------------------------------------
+
+      !
+      IF( lk_dtatrc .AND. ln_pisclo ) CALL pis_dmp_clo  ! restoring of nutrients on close seas
+      IF( ln_pisdmp )                 CALL pis_dmp_ini  ! relaxation of some tracers
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_read_pisces : Read specific variables from pisces model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+      ! 
+      IF( iom_varid( knum, 'PH', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( knum, jpdom_autoglo, 'PH' , hi(:,:,:)  )
+      ELSE
+         ! Set PH from  total alkalinity, borat (???), akb3 (???) and ak23 (???)
+         ! --------------------------------------------------------
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztmas   = tmask(ji,jj,jk)
+                  ztmas1  = 1. - tmask(ji,jj,jk)
+                  zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
+                  zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
+                  zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
+                  hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
+               END DO
+            END DO
+         END DO
+      ENDIF
+      CALL iom_get( knum, jpdom_autoglo, 'Silicalim', xksi(:,:) ) 
+      IF( iom_varid( knum, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( knum, jpdom_autoglo, 'Silicamax' , xksimax(:,:)  )
+      ELSE
+         xksimax(:,:) = xksi(:,:)
+      ENDIF
+
+   END SUBROUTINE trc_rst_read_pisces
+
+   SUBROUTINE trc_rst_wri_pisces( kt, kitrst, knum )
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_rst_read_pisces  ***
+      !!
+      !! ** Purpose : Read in restart file specific variables from pisces model
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  :: kt      ! time step
+      INTEGER, INTENT(in)  :: kitrst  ! time step of restart write
+      INTEGER, INTENT(in)  :: knum    ! unit of the restart file
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_rst_wri_pisces : Write specific variables from pisces model '
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      CALL iom_rstput( kt, kitrst, knum, 'PH', hi(:,:,:) )
+      CALL iom_rstput( kt, kitrst, knum, 'Silicalim', xksi(:,:) ) 
+      CALL iom_rstput( kt, kitrst, knum, 'Silicamax', xksimax(:,:) )
+
+   END SUBROUTINE trc_rst_wri_pisces
+
+   SUBROUTINE pis_dmp_ini
+      !!----------------------------------------------------------------------
+      !!                    ***  pis_dmp_ini  ***
+      !!
+      !! ** purpose  : Relaxation of some tracers
+      !!----------------------------------------------------------------------
+      INTEGER  :: ji, jj, jk
+      REAL(wp) ::  &
+         alkmean = 2426. ,  & ! mean value of alkalinity ( Glodap ; for Goyet 2391. )
+         po4mean = 2.165 ,  & ! mean value of phosphates
+         no3mean = 30.90 ,  & ! mean value of nitrate
+         silmean = 91.51      ! mean value of silicate
+
+      REAL(wp) :: zarea, zvol, zalksum, zpo4sum, zno3sum, zsilsum
+
+
+      IF(lwp)  WRITE(numout,*)
+
+      IF( cp_cfg == "orca" .AND. .NOT. lk_trc_c1d ) THEN      ! ORCA condiguration (not 1D) !
+         !                                                    ! --------------------------- !
+         ! set total alkalinity, phosphate, nitrate & silicate
+
+         zalksum = 0.e0
+         zpo4sum = 0.e0
+         zno3sum = 0.e0
+         zsilsum = 0.e0
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zvol = cvol(ji,jj,jk)
+#  if defined key_off_degrad
+                  zvol = zvol * facvol(ji,jj,jk)
+#  endif
+                  zalksum = zalksum + trn(ji,jj,jk,jptal) * zvol
+                  zpo4sum = zpo4sum + trn(ji,jj,jk,jppo4) * zvol
+                  zno3sum = zno3sum + trn(ji,jj,jk,jpno3) * zvol
+                  zsilsum = zsilsum + trn(ji,jj,jk,jpsil) * zvol
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( zalksum )     ! sum over the global domain
+         IF( lk_mpp )   CALL mpp_sum( zpo4sum )     ! sum over the global domain
+         IF( lk_mpp )   CALL mpp_sum( zno3sum )     ! sum over the global domain
+         IF( lk_mpp )   CALL mpp_sum( zsilsum )     ! sum over the global domain
+         zarea   = 1. / areatot * 1.e6
+         zalksum = zalksum * zarea
+         zpo4sum = zpo4sum * zarea / 122.
+         zno3sum = zno3sum * zarea / 7.6
+         zsilsum = zsilsum * zarea
+
+         IF(lwp) WRITE(numout,*) '       TALK mean : ', zalksum
+         trn(:,:,:,jptal) = trn(:,:,:,jptal) * alkmean / zalksum
+            
+         IF(lwp) WRITE(numout,*) '       PO4  mean : ', zpo4sum
+         trn(:,:,:,jppo4) = trn(:,:,:,jppo4) * po4mean / zpo4sum
+
+         IF(lwp) WRITE(numout,*) '       NO3  mean : ', zno3sum
+         trn(:,:,:,jpno3) = trn(:,:,:,jpno3) * no3mean / zno3sum
+
+         IF(lwp) WRITE(numout,*) '       SiO3 mean : ', zsilsum
+         trn(:,:,:,jpsil) = MIN( 400.e-6,trn(:,:,:,jpsil) * silmean / zsilsum )
+         !
+      ENDIF
+
+!#if defined key_kriest
+!     !! Initialize number of particles from a standart restart file
+!     !! The name of big organic particles jpgoc has been only change
+!     !! and replace by jpnum but the values here are concentration
+!     trn(:,:,:,jppoc) = trn(:,:,:,jppoc) + trn(:,:,:,jpnum) 
+!     trn(:,:,:,jpnum) = trn(:,:,:,jppoc) / ( 6. * xkr_massp )
+!#endif
+
+   END SUBROUTINE pis_dmp_ini
+
+   SUBROUTINE pis_dmp_clo   
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE pis_dmp_clo  ***
+      !!
+      !! ** Purpose :   Closed sea domain initialization
+      !!
+      !! ** Method  :   if a closed sea is located only in a model grid point
+      !!                we restore to initial data
+      !!
+      !! ** Action  :   ictsi1(), ictsj1() : south-west closed sea limits (i,j)
+      !!                ictsi2(), ictsj2() : north-east Closed sea limits (i,j)
+      !!----------------------------------------------------------------------
+      INTEGER, PARAMETER           ::   npicts   = 4       !: number of closed sea
+      INTEGER, DIMENSION(npicts)   ::   ictsi1, ictsj1     !: south-west closed sea limits (i,j)
+      INTEGER, DIMENSION(npicts)   ::   ictsi2, ictsj2     !: north-east closed sea limits (i,j)
+      INTEGER :: ji, jj, jk, jn, jc            ! dummy loop indices
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*)' pis_dmp_clo : closed seas '
+      IF(lwp) WRITE(numout,*)'~~~~~~~'
+
+      ! initial values
+      ictsi1(:) = 1  ;  ictsi2(:) = 1
+      ictsj1(:) = 1  ;  ictsj2(:) = 1
+
+      ! set the closed seas (in data domain indices)
+      ! -------------------
+
+      IF( cp_cfg == "orca" ) THEN
+         !
+         SELECT CASE ( jp_cfg )
+         !                                           ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration
+            !                                        ! =======================
+            !                                            ! Caspian Sea
+            ictsi1(1)   =  11  ;  ictsj1(1)   = 103
+            ictsi2(1)   =  17  ;  ictsj2(1)   = 112
+            !                                            ! Great North American Lakes
+            ictsi1(2)   =  97  ;  ictsj1(2)   = 107
+            ictsi2(2)   = 103  ;  ictsj2(2)   = 111
+            !                                            ! Black Sea 1 : west part of the Black Sea
+            ictsi1(3)   = 174  ; ictsj1(3)   = 107
+            ictsi2(3)   = 181  ; ictsj2(3)   = 112
+            !                                            ! Black Sea 2 : est part of the Black Sea
+            ictsi1(4)   =   2  ;  ictsj1(4)   = 107
+            ictsi2(4)   =   6  ;  ictsj2(4)   = 112
+            !                                        ! =======================
+         CASE ( 4 )                                  !  ORCA_R4 configuration
+            !                                        ! =======================
+            !                                            ! Caspian Sea
+            ictsi1(1)   =  4  ;  ictsj1(1)   = 53
+            ictsi2(1)   =  4  ;  ictsj2(1)   = 56
+            !                                            ! Great North American Lakes
+            ictsi1(2)   = 49  ;  ictsj1(2)   = 55
+            ictsi2(2)   = 51  ;  ictsj2(2)   = 56
+            !                                            ! Black Sea
+            ictsi1(3)   = 88  ;  ictsj1(3)   = 55
+            ictsi2(3)   = 91  ;  ictsj2(3)   = 56
+            !                                            ! Baltic Sea
+            ictsi1(4)   = 75  ;  ictsj1(4)   = 59
+            ictsi2(4)   = 76  ;  ictsj2(4)   = 61
+            !                                        ! =======================
+            !                                        ! =======================
+         CASE ( 025 )                                ! ORCA_R025 configuration
+            !                                        ! =======================
+                                                     ! Caspian + Aral sea
+            ictsi1(1)   = 1330 ; ictsj1(1)   = 645
+            ictsi2(1)   = 1400 ; ictsj2(1)   = 795
+            !                                        ! Azov Sea
+            ictsi1(2)   = 1284 ; ictsj1(2)   = 722
+            ictsi2(2)   = 1304 ; ictsj2(2)   = 747
+            !
+         END SELECT
+         !
+      ENDIF
+
+      ! convert the position in local domain indices
+      ! --------------------------------------------
+      DO jc = 1, npicts
+         ictsi1(jc)   = mi0( ictsi1(jc) )
+         ictsj1(jc)   = mj0( ictsj1(jc) )
+
+         ictsi2(jc)   = mi1( ictsi2(jc) )
+         ictsj2(jc)   = mj1( ictsj2(jc) )
+      END DO
+
+#if defined key_dtatrc
+      ! Restore close seas values to initial data
+      CALL trc_dta( nittrc000 ) 
+      DO jn = 1, jptra
+         IF( lutini(jn) ) THEN
+            DO jc = 1, npicts
+               DO jk = 1, jpkm1
+                  DO jj = ictsj1(jc), ictsj2(jc)
+                     DO ji = ictsi1(jc), ictsi2(jc)
+                        trn(ji,jj,jk,jn) = trdta(ji,jj,jk,jn) * tmask(ji,jj,jk) 
+                        trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn)
+                     ENDDO
+                  ENDDO
+               ENDDO
+            ENDDO
+         ENDIF
+      ENDDO
+#endif
+   !
+   END SUBROUTINE pis_dmp_clo
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read_pisces( knum )
+      INTEGER, INTENT(in)  :: knum
+      WRITE(*,*) 'trc_rst_read_pisces: You should not have seen this print! error?', knum
+   END SUBROUTINE trc_rst_read_pisces
+
+   SUBROUTINE trc_rst_wri_pisces( kt, kitrst, knum )
+     INTEGER, INTENT(in)  :: kt, kitrst, knum
+     WRITE(*,*) 'trc_rst_wri_pisces: You should not have seen this print! error?', kt, kitrst, knum
+   END SUBROUTINE trc_rst_wri_pisces
+#endif
+
+   !!======================================================================
+END MODULE trcrst_pisces
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/PISCES/trcsms_pisces.F90	(revision 1844)
@@ -0,0 +1,152 @@
+MODULE trcsms_pisces
+   !!======================================================================
+   !!                         ***  MODULE trcsms_pisces  ***
+   !! TOP :   PISCES Source Minus Sink manager
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (O. Aumont) Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
+   !!----------------------------------------------------------------------
+#if defined key_pisces
+   !!----------------------------------------------------------------------
+   !!   'key_pisces'                                       PISCES bio-model
+   !!----------------------------------------------------------------------
+   !!   trcsms_pisces        :  Time loop of passive tracers sms
+   !!----------------------------------------------------------------------
+   USE oce_trc         !
+   USE trc
+   USE sms_pisces
+   USE lbclnk
+   USE lib_mpp
+   
+   USE p4zint          ! 
+   USE p4zche          ! 
+   USE p4zbio          ! 
+   USE p4zsed          ! 
+   USE p4zlys          ! 
+   USE p4zflx          ! 
+
+   USE trdmld_trc_oce
+   USE trdmld_trc
+
+   USE sedmodel
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sms_pisces    ! called in trcsms.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sms_pisces( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sms_pisces  ***
+      !!
+      !! ** Purpose :   Managment of the call to Biological sources and sinks 
+      !!              routines of PISCES bio-model
+      !!
+      !! ** Method  : - at each new day ...
+      !!              - several calls of bio and sed ???
+      !!              - ...
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      INTEGER ::   jnt, jn
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrpis   ! used for pisces sms trends
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000  .AND. .NOT. ln_rsttr )   CALL trc_sms_pisces_init    ! Initialization (first time-step only)
+
+      IF( ndayflxtr /= nday ) THEN      ! New days
+         !
+         ndayflxtr = nday
+
+         CALL p4z_che          ! computation of chemical constants
+         CALL p4z_int          ! computation of various rates for biogeochemistry
+         !
+      ENDIF
+
+
+      DO jnt = 1, nrdttrc          ! Potential time splitting if requested
+         !
+         CALL p4z_bio (kt, jnt)    ! Compute soft tissue production (POC)
+         CALL p4z_sed (kt, jnt)    ! compute soft tissue remineralisation
+         !
+         trb(:,:,:,:) = trn(:,:,:,:)
+         !
+      END DO
+
+      CALL p4z_lys( kt )             ! Compute CaCO3 saturation
+      CALL p4z_flx( kt )             ! Compute surface fluxes
+
+      DO jn = jp_pcs0, jp_pcs1
+        CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
+        CALL lbc_lnk( trb(:,:,:,jn), 'T', 1. )
+        CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )
+      END DO
+
+      IF( l_trdtrc ) THEN
+          DO jn = jp_pcs0, jp_pcs1
+            ztrpis(:,:,:) = tra(:,:,:,jn)
+            CALL trd_mod_trc( ztrpis, jn, jptrc_trd_sms, kt )   ! save trends
+          END DO
+      END IF
+
+      IF( lk_sed ) THEN 
+         !
+         CALL sed_model( kt )     !  Main program of Sediment model
+         !
+         DO jn = jp_pcs0, jp_pcs1
+           CALL lbc_lnk( trn(:,:,:,jn), 'T', 1. )
+         END DO
+         !
+      ENDIF
+
+   END SUBROUTINE trc_sms_pisces
+
+   SUBROUTINE trc_sms_pisces_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_sms_pisces_init  ***
+      !!
+      !! ** Purpose :   Initialization of PH variable
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+
+      ! Initialization of chemical variables of the carbon cycle
+      ! --------------------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztmas   = tmask(ji,jj,jk)
+               ztmas1  = 1. - tmask(ji,jj,jk)
+               zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
+               zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
+               zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
+               hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
+            END DO
+         END DO
+      END DO
+
+   END SUBROUTINE trc_sms_pisces_init
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                   No PISCES bio-model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_sms_pisces( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sms_pisces: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms_pisces
+#endif 
+
+   !!======================================================================
+END MODULE trcsms_pisces 
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/par_sed.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/par_sed.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/par_sed.F90	(revision 1844)
@@ -0,0 +1,64 @@
+MODULE par_sed
+   !!======================================================================
+   !!                        ***  par_sed  ***
+   !! Sediment :   set sediment parameter
+   !!======================================================================
+   !! History :
+   !!        !  06-12  (C. Ethe)  Orignal
+   !!----------------------------------------------------------------------
+#if defined key_sed
+   !! Domain characteristics
+   USE par_kind
+   USE par_oce , ONLY :       &
+      jpi      =>   jpi   ,  & !: first  dimension of grid --> i
+      jpj      =>   jpj   ,  & !: second dimension of grid --> j
+      jpim1    =>   jpim1 ,  & !: jpi - 1
+      jpjm1    =>   jpjm1 ,  & !: jpj - 1
+      jpij     =>   jpij       !: jpi x jpj
+
+#if ! defined key_sed_off
+   USE par_pisces
+#endif
+
+#if defined key_kriest
+   INTEGER, PARAMETER :: jpdta = 11
+#else
+   INTEGER, PARAMETER :: jpdta = 12
+#endif
+
+
+   ! Vertical sediment geometry
+   INTEGER, PARAMETER :: &
+      jpksed   = 11         ,   & !: number of sediment layers
+      jpksedm1 = jpksed - 1 
+      
+   ! sediment tracer species
+   INTEGER, PARAMETER :: &
+      jpsol = 4,         &  !: number of solid component
+      jpwat = 7,         &   !: number of pore water component
+      jpwatp1 = jpwat + 1
+
+   
+   ! pore water components       
+   INTEGER, PARAMETER :: &
+      jwsil  = 1,        & !: silic acid
+      jwoxy  = 2,        & !: oxygen
+      jwdic  = 3,        & !: dissolved inorganic carbon
+      jwno3  = 4,        & !: nitrate
+      jwpo4  = 5,        & !: phosphate
+      jwalk  = 6,        & !: alkalinity
+      jwc13  = 7           !: dissolved inorganic carbon 13
+
+   ! solid components       
+   INTEGER, PARAMETER ::  &
+      jsopal  = 1,        & !: opal sediment
+      jsclay  = 2,        & !: clay
+      jspoc   = 3,        & !: organic carbon
+      jscal   = 4           !: calcite
+
+   INTEGER, PARAMETER ::  &
+      jptrased   = jpsol + jpwat , &
+      jpdia3dsed = 3          , &
+      jpdia2dsed = 7
+#endif
+END MODULE par_sed
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sed.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sed.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sed.F90	(revision 1844)
@@ -0,0 +1,224 @@
+MODULE sed
+   !!======================================================================
+   !!                        ***  sed  ***
+   !! Sediment :   set sediment global variables
+   !!======================================================================
+#if defined key_sed
+   !! History :
+   !!        !  06-12  (C. Ethe)  Orignal
+   !!----------------------------------------------------------------------
+   USE par_sed
+
+   USE in_out_manager
+
+   USE dom_oce , ONLY :       &
+      nidom    =>   nidom  ,  & !:
+      glamt    =>   glamt  ,  & !: longitude of t-point (degre)
+      gphit    =>   gphit  ,  & !: latitude  of t-point (degre)
+      e3t_0    =>   e3t_0  ,  & !: reference depth of t-points (m)
+      mbathy   =>   mbathy ,  & !: bathymetry
+      tmask    =>   tmask  ,  & !: land/ocean mask at t-points
+      rdt      =>   rdt         !: time step for the dynamics
+
+      nyear     =>   nyear    ,   & !: Current year
+      nmonth    =>   nmonth   ,   & !: Current month
+      nday      =>   nday     ,   & !: Current day
+      ndastp    =>   ndastp   ,   & !: time step date in year/month/day aammjj
+      nday_year =>   nday_year,   & !: curent day counted from jan 1st of the current year
+      adatrj    =>   adatrj         !: number of elapsed days since the begining of the run
+   !                                !: it is the accumulated duration of previous runs
+   !                                !: that may have been run with different time steps.
+
+
+#if ! defined key_sed_off
+
+   USE oce , ONLY :            &
+      tn      =>    tn    ,  & !: pot. temperature (celsius)
+      sn      =>    sn         !: salinity (psu)
+
+   USE trc, ONLY :  &
+      trn        , & !: tracer 
+      nittrc000  , & !: 1st time step of tracer model
+      nwritetrc      !: outputs frequency of tracer model
+
+   USE p4zsink, ONLY :  &
+      sinking  ,     & !: sinking flux for POC
+#if ! defined key_kriest
+      sinking2 ,     & !: sinking flux for GOC
+#endif
+      sinkcal ,      & !: sinking flux for calcite 
+      sinksil          !: sinking flux for opal ( dsi )
+
+   USE sms_pisces, ONLY :  &
+      akb3  ,     & 
+      ak13  ,     & 
+      ak23  ,     & 
+      akw3  ,     & 
+      aksp  ,     & 
+      borat 
+
+#endif   
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpdta) :: &
+      trc_data           !: tracer data to share with sediment model
+
+   INTEGER, PUBLIC :: &
+      nitsed000, nitsedend, nwrised, nfreq
+
+   REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   &
+      pwcp  ,      &     !: pore water sediment data at given time-step
+      pwcp0              !: pore water sediment data at initial time
+
+   REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   &
+      solcp ,      &     !: solid sediment data at given time-step
+      solcp0             !: solid sediment at initial time
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE ::   &
+      pwcp_dta           !: pore water data at given time-step
+
+   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE ::   &
+      rainrm_dta,  &     !: rain data at at initial time
+      rainrm    ,  &     !: rain data at given time-step
+      rainrg    ,  &     !: rain of each solid component in [g/(cm**2.s)]
+      fromsed   ,  &     !:
+      tosed     ,  &     !:
+      rloss              !: 
+
+   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE  ::   &
+      tokbot             !: 
+
+   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  ::   & 
+      temp  ,      &     !: temperature
+      salt  ,      &     !: salinity
+      press ,      &     !: pressure
+      raintg,      &     !: total massic flux rained in each cell (sum of sol. comp.)
+      dzdep              !: total thickness of solid material rained [cm] in each cell
+
+   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE  ::   &
+      hipor  ,     &     !: [h+] in mol/kg*densSW 
+      co3por             !: [co3--]solid sediment at initial time
+
+   REAL(wp), PUBLIC, DIMENSION(jpsol) ::   &
+      mol_wgt            !: molecular weight of solid sediment data
+
+   
+   !! Geometry
+   INTEGER, PUBLIC, SAVE :: &
+      jpoce ,  &             !: sediment points
+      indoce
+
+   INTEGER , PUBLIC, DIMENSION(:) , ALLOCATABLE  ::   &  !:
+      iarroce      !: ! Computation of 1D array of sediments points
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: &
+      epkbot             !: ocean bottom layer thickness
+
+   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  :: &
+      dzkbot             !: ocean bottom layer thickness in meters
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpksed) :: &
+      tmasksed           !: sediment mask
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: &
+      sbathy
+ 
+   REAL(wp), PUBLIC, DIMENSION(jpksed) :: &
+      dz      ,    &     !: sediment layers thickness
+      por     ,    &     !: porosity profile     
+      por1    ,    &     !: 1 - por 
+      profsed ,    &     !: depth of middle of each layer
+      volw    ,    &     !: volume of pore water cell fraction
+      vols    ,    &     !: volume of solid cell fraction
+      diff    ,    &     !: diffusion ceofficient
+      rdtsed             !: 
+
+   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE :: &
+      dz3d   ,     &     !: 
+      volw3d ,     &     !: 
+      vols3d             !: 
+
+   REAL(wp)  ::    &
+      dens               !: density of solid material
+
+   !! Namelist
+   REAL(wp), PUBLIC, DIMENSION(5) :: &   
+      reac               !: reactivity rc in  [l.mol-1.s-1]
+
+   REAL(wp), PUBLIC       :: &   
+      sat_sil,      &     !: saturation concentration for silicate in [mol.l-1]
+      sat_clay,     &     !:                              clay    
+      reac_sil,     &     !: reactivity rc in  [l.mol-1.s-1]
+      reac_clay,    &     
+      reac_poc,     &     
+      reac_no3,     &     
+      reac_cal         
+
+   REAL(wp), PUBLIC    :: &   
+      so2ut   ,     &     !:
+      srno3   ,     &     !: 
+      spo4r   ,     &     !:
+      srDnit  ,     &     !: 
+      sthro2              !: threshold O2 concen. in [mol.l-1]
+
+   REAL(wp), PUBLIC    :: &   
+      pdb    = 0.0112372, & !: 13C/12C in PD Belemnite
+      rc13P  = 0.980    , & !: 13C/12C in POC = rc13P*PDB
+      rc13Ca = 1.001        !: 13C/12C in CaCO3 = rc13Ca*PDB
+
+   REAL(wp) , PUBLIC ::   &
+      dtsed  ,     &     !: sedimentation time step
+      db                 !: bioturb coefficient in [cm2.s-1]
+
+   !! Chemistry
+   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  :: &
+      densSW ,     &
+      borats ,     &
+      calcon2,     &
+      akbs   ,     &
+      ak1s   ,     &
+      ak2s   ,     &
+      akws   ,     &
+      ak12s  ,     &
+      ak1ps  ,     &
+      ak2ps  ,     &
+      ak3ps  ,     &
+      ak12ps ,     &
+      ak123ps,     &
+      aksis  ,     & 
+      aksps 
+
+   !! Inputs / Outputs
+   CHARACTER( len = 80 ), DIMENSION(jptrased) :: &
+      sedtrcl
+   CHARACTER( len = 20 ), DIMENSION(jptrased) :: &
+      sedtrcd , sedtrcu
+
+   CHARACTER( len = 80 ), DIMENSION(jpdia3dsed) :: &
+      seddia3l 
+   CHARACTER( len = 20 ), DIMENSION(jpdia3dsed) :: &
+      seddia3d , seddia3u
+
+   CHARACTER( len = 80 ), DIMENSION(jpdia2dsed) :: &
+      seddia2l 
+   CHARACTER( len = 20 ), DIMENSION(jpdia2dsed) :: &
+      seddia2d , seddia2u
+
+   REAL(wp), DIMENSION(jpi,jpj,jpksed,jptrased) :: &
+      trcsedi
+   REAL(wp), DIMENSION(jpi,jpj,jpksed,jpdia3dsed) :: &
+      flxsedi3d
+   REAL(wp), DIMENSION(jpi,jpj,jpdia2dsed) :: &
+      flxsedi2d
+
+   !! Units
+   INTEGER, PUBLIC :: &
+     numsed = 27
+	
+#else
+   !!======================================================================
+   !! No Sediment model
+   !!======================================================================
+#endif
+
+END MODULE sed
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedadv.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedadv.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedadv.F90	(revision 1844)
@@ -0,0 +1,458 @@
+MODULE sedadv
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  sedadv  ***
+   !!    Sediment : vertical advection and burial
+   !!=====================================================================
+   !! * Modules used
+   !!----------------------------------------------------------------------
+   !!   sed_adv :
+   !!----------------------------------------------------------------------
+   USE sed     ! sediment global variable
+
+   PUBLIC sed_adv
+
+   !! * Module variable
+   INTEGER, PARAMETER  ::   &
+      nztime = jpksed         ! number of time step between sunrise and sunset
+   !      
+   
+   REAL(wp), DIMENSION(jpksed), SAVE :: &
+      dvolsp, dvolsm, &
+      c2por, ckpor
+
+   REAL(wp), SAVE :: &
+      por1clay , &
+      cpor   
+
+   REAL(wp) :: &
+      eps = 1.e-13
+
+CONTAINS
+
+   SUBROUTINE sed_adv( kt )
+      !!-------------------------------------------------------------------------
+      !!                  ***  ROUTINE sed_adv  ***
+      !!
+      !! ** Purpose : vertical solid sediment advection and burial 
+      !!
+      !! ** Method  : At each grid point the 1-dimensional solid sediment column
+      !!              is shifted according the rain added to the top layer and
+      !!              the gaps produced through redissolution so that in the end
+      !!              the original sediment mixed layer geometry is reestablished.
+      !!
+      !!
+      !!   History :
+      !!        !  98-08 (E. Maier-Reimer, Christoph Heinze )  Original code
+      !!        !  04-10 (N. Emprin, M. Gehlen ) F90
+      !!        !  06-04 (C. Ethe)  Re-organization
+      !!-------------------------------------------------------------------------
+      !!* Arguments
+      INTEGER, INTENT(in) ::  &
+         kt                     ! time step
+      ! * local variables
+
+      INTEGER ::  &
+         ji, jk, js
+
+      INTEGER ::  &
+         jn, ntimes, ikwneg
+      
+      REAL(wp), DIMENSION(jpksed,jpsol) :: zsolcpno
+      REAL(wp), DIMENSION(jpksed)       :: zfilled, zfull, zfromup, zempty
+     
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zgap, zwb
+      REAL(wp), DIMENSION(jpoce,jpsol)      :: zrainrf
+
+      REAL(wp), DIMENSION(nztime) ::  zraipush
+
+      REAL(wp) :: &
+         zkwnup, zkwnlo, zfrac, &
+         zfromce, zrest
+
+
+      !------------------------------------------------------------------------
+
+
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' '
+         WRITE(numsed,*) ' sed_adv : vertical sediment advection  '
+         WRITE(numsed,*) ' '
+         por1clay = dens * por1(jpksed) * dz(jpksed) / mol_wgt(jsclay)
+         cpor     = por1(jpksed) / por1(2)
+         DO jk = 2, jpksed
+            c2por(jk) = por1(2)      / por1(jk)
+            ckpor(jk) = por1(jpksed) / por1(jk)
+         ENDDO
+         DO jk = jpksedm1, 2, -1
+            dvolsp(jk) = vols(jk+1) / vols(jk)
+         ENDDO
+         DO jk = 3, jpksed
+           dvolsm(jk) = vols(jk-1) / vols(jk)
+        ENDDO
+      ENDIF
+
+
+      ALLOCATE( zgap (jpoce,jpksed) )    ;   ALLOCATE( zwb(jpoce,jpksed) )
+
+
+      ! Initialization of data for mass balance calculation
+      !---------------------------------------------------
+      fromsed(:,:) = 0.
+      tosed  (:,:) = 0. 
+      rloss  (:,:) = 0.
+
+
+      ! Initiate gap 
+      !--------------
+      zgap(:,:) = 0.
+      DO js = 1, jpsol
+         DO jk = 1, jpksed
+            DO ji = 1, jpoce
+               zgap(ji,jk) = zgap(ji,jk) + solcp(ji,jk,js)
+            END DO
+         ENDDO
+      ENDDO
+
+      zgap(1:jpoce,1:jpksed) = 1. - zgap(1:jpoce,1:jpksed)   
+
+
+      ! Initiate burial rates
+      !-----------------------
+      zwb(:,:) = 0.
+      DO jk = 2, jpksed
+         zfrac =  dtsed / ( dens * por1(jk) )     
+         DO ji = 1, jpoce
+            zwb(ji,jk) = zfrac * raintg(ji)
+         END DO
+      ENDDO
+
+
+      DO ji = 1, jpoce
+         zwb(ji,2) = zwb(ji,2) - zgap(ji,2) * dz(2)
+      ENDDO
+
+      DO jk = 3, jpksed
+         zfrac = por1(jk-1) / por1(jk)
+         DO ji = 1, jpoce
+            zwb(ji,jk) = zwb(ji,jk-1) * zfrac - zgap(ji,jk) * dz(jk)
+         END DO
+      ENDDO
+
+
+      zrainrf(:,:) = 0.
+      DO ji = 1, jpoce
+         IF( raintg(ji) /= 0. )  &
+            &   zrainrf(ji,:) = rainrg(ji,:) / raintg(ji)
+      ENDDO
+
+
+      ! Computation of full and empty solid fraction in each layer
+      ! for all 'burial' case
+      !----------------------------------------------------------
+
+
+      DO ji = 1, jpoce
+
+         ! computation of total weight fraction in sediment
+         !-------------------------------------------------
+         zfilled(:) = 0.
+         DO js = 1, jpsol
+            DO jk = 2, jpksed
+               zfilled(jk) = zfilled(jk) + solcp(ji,jk,js)
+            ENDDO
+         ENDDO
+         
+         DO js = 1, jpsol
+            DO jk = 2, jpksed
+               zsolcpno(jk,js) = solcp(ji,jk,js) / zfilled(jk)
+            ENDDO
+         ENDDO
+
+         ! burial  3 cases: 
+         ! zwb > 0 ==> rain > total rection loss 
+         ! zwb = 0 ==> rain = 0
+         ! zwb < 0 ==> rain > 0 and rain < total reaction loss
+         !----------------------------------------------------------------
+
+         IF( zwb(ji,jpksed) > 0. ) THEN
+
+            zfull (jpksed) = zfilled(jpksed)
+            zempty(jpksed) = 1. - zfull(jpksed)
+            DO jk = jpksedm1, 2, -1
+               zfull (jk) = zfilled(jk)
+               zfull (jk) = zfull(jk) - zempty(jk+1) * dvolsp(jk)
+               zempty(jk) = 1. - zfull(jk)
+            ENDDO
+
+            ! Computation of solid sediment species
+            !--------------------------------------
+            ! push entire sediment column downward to account rest of rain
+            DO js = 1, jpsol
+               DO jk = jpksed, 3, -1
+                  solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
+               ENDDO
+
+               solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
+
+               DO jk = 2, jpksed
+                  zsolcpno(jk,js) = solcp(ji,jk,js)
+               END DO
+            ENDDO
+
+            zrest = zwb(ji,jpksed) * cpor
+            ! what is remaining is less than dz(2)
+            IF( zrest <= dz(2) ) THEN           
+
+               zfromup(2) = zrest / dz(2)
+               DO jk = 3, jpksed
+                  zfromup(jk) = zwb(ji,jpksed) * ckpor(jk) / dz(jk)
+               ENDDO
+               DO js = 1, jpsol
+                  zfromce = 1. - zfromup(2)
+                  solcp(ji,2,js) = zfromce * zsolcpno(2,js) + zfromup(2) * zrainrf(ji,js)
+                  DO jk = 3, jpksed
+                     zfromce = 1. - zfromup(jk)
+                     solcp(ji,jk,js) = zfromce * zsolcpno(jk,js) + zfromup(jk) * zsolcpno(jk-1,js)
+                  ENDDO
+                  fromsed(ji,js) = 0.
+                  ! quantities to push in deeper sediment
+                  tosed  (ji,js) = zsolcpno(jpksed,js) &
+                     &           * zwb(ji,jpksed) * dens * por1(jpksed) / mol_wgt(js)
+               ENDDO
+               
+            ELSE ! what is remaining is great than dz(2)
+
+               ntimes = INT( zrest / dz(2) ) + 1
+               IF( ntimes > nztime ) THEN
+                  WRITE( numsed,* ) ' sedadv : rest too large at sediment point ji = ', ji
+                  STOP
+               ENDIF
+               zraipush(1) = dz(2)
+               zrest = zrest - zraipush(1)
+               DO jn = 2, ntimes
+                  IF( zrest >= dz(2) ) THEN
+                     zraipush(jn) = dz(2)
+                     zrest = zrest - zraipush(jn)
+                  ELSE
+                     zraipush(jn) = zrest
+                     zrest = 0.
+                  ENDIF
+               ENDDO
+
+               DO jn = 1, ntimes
+                  DO js = 1, jpsol
+                     DO jk = 2, jpksed
+                        zsolcpno(jk,js) = solcp(ji,jk,js)
+                     END DO
+                  ENDDO
+                  
+                  zfromup(2) = zraipush(jn) / dz(2)
+                  DO jk = 3, jpksed
+                     zfromup(jk) = ( zraipush(jn) / dz(jk) ) * c2por(jk)
+                  ENDDO
+
+                  DO js = 1, jpsol
+                     zfromce = 1. - zfromup(2)
+                     solcp(ji,2,js) = zfromce * zsolcpno(2,js) + zfromup(2) * zrainrf(ji,js)
+                     DO jk = 3, jpksed
+                        zfromce = 1. - zfromup(jk)
+                        solcp(ji,jk,js) = zfromce * zsolcpno(jk,js) + zfromup(jk) * zsolcpno(jk-1,js)
+                     ENDDO
+                     fromsed(ji,js) = 0.
+                     tosed  (ji,js) = tosed(ji,js) + zsolcpno(jpksed,js) * zraipush(jn) &
+                        &             * dens * por1(2) / mol_wgt(js)
+                  ENDDO
+               ENDDO
+ 
+            ENDIF
+
+         ELSE IF( raintg(ji) < eps ) THEN ! rain  = 0
+!! Nadia    rloss(:,:) = rainrm(:,:)   bug ??????           
+
+            rloss(ji,1:jpsol) = rainrm(ji,1:jpsol)
+
+            zfull (2) = zfilled(2)
+            zempty(2) = 1. - zfull(2)
+            DO jk = 3, jpksed
+               zfull (jk) = zfilled(jk)
+               zfull (jk) = zfull (jk) - zempty(jk-1) * dvolsm(jk)
+               zempty(jk) = 1. - zfull(jk)
+            ENDDO
+
+            ! fill boxes with weight fraction from underlying box
+            DO js = 1, jpsol
+               DO jk = 2, jpksedm1
+                  solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js)
+               END DO
+               solcp(ji,jpksed,js) = zsolcpno(jpksed,js) * zfull(jpksed)
+               tosed  (ji,js) = 0.
+               fromsed(ji,js) = 0.
+            ENDDO
+            ! for the last layer, one make go up clay 
+            solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
+            !! C. Heinze      fromsed(ji,jsclay) = zempty(jpksed) * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
+            fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
+
+         ELSE  ! rain > 0 and rain < total reaction loss
+
+
+            DO jk = 2, jpksed
+               zfull (jk) = zfilled(jk)
+               zempty(jk) = 1. - zfull(jk)
+            ENDDO
+
+            ! Determination of indice of layer - ikwneg - where advection is reversed
+            !------------------------------------------------------------------------
+ iflag:     DO jk = 2, jpksed
+               IF( zwb(ji,jk) < 0.  ) THEN
+                  ikwneg = jk
+                  EXIT iflag
+               ENDIF
+            ENDDO iflag
+
+            ! computation of zfull and zempty 
+            ! 3 cases : a/ ikwneg=2, b/ikwneg=3...jpksedm1, c/ikwneg=jpksed    
+            !-------------------------------------------------------------      
+            IF( ikwneg == 2 ) THEN ! advection is reversed in the first sediment layer
+
+               zkwnup = rdtsed(ikwneg) * raintg(ji) / dz(ikwneg)
+               zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
+               zfull (ikwneg+1) = zfilled(ikwneg+1) - zkwnlo * dvolsm(ikwneg+1)
+               zempty(ikwneg+1) = 1. - zfull(ikwneg+1)
+               DO jk = ikwneg+2, jpksed
+                  zfull (jk) = zfilled(jk) - zempty(jk-1) * dvolsm(jk)
+                  zempty(jk) = 1. - zfull(jk)
+               ENDDO
+               DO js = 1, jpsol
+                  solcp(ji,2,js) = zfull(2) * zsolcpno(2,js)+ zkwnlo * zsolcpno(3,js) &
+                     &                                      + zkwnup * zrainrf(ji,js)
+                  DO jk = 3, jpksedm1
+                     solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js)
+                  ENDDO
+                  solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
+                  tosed(ji,js)   = 0.
+                  fromsed(ji,js) = 0.
+               ENDDO
+               solcp(ji,jpksed,jsclay) =  solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
+               !! C. Heinze  fromsed(ji,jsclay) = zempty(jpksed) * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
+               fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
+               
+            ELSE IF( ikwneg == jpksed ) THEN
+
+               zkwnup = ABS( zwb(ji,ikwneg-1) ) * dvolsm(ikwneg) / dz(ikwneg)
+               zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
+               zfull (ikwneg-1) = zfilled(ikwneg-1) - zkwnup * dvolsp(ikwneg-1)
+               zempty(ikwneg-1) = 1. - zfull(ikwneg-1)
+               DO jk = ikwneg-2, 2, -1
+                  zfull (jk) = zfilled(jk) - zempty(jk+1) * dvolsp(jk)
+                  zempty(jk) = 1. - zfull(jk) 
+               ENDDO
+               DO  js = 1, jpsol
+                  solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
+               ENDDO
+               DO  js = 1, jpsol              
+                  DO jk = jpksedm1, 3, -1
+                     solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
+                  ENDDO
+                  solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js) &
+                     &                       + zkwnup * zsolcpno(jpksedm1,js)
+                  tosed(ji,js)   = 0.
+                  fromsed(ji,js) = 0.
+               ENDDO
+               solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zkwnlo * 1.
+               ! Heinze  fromsed(ji,jsclay) = zkwnlo * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
+               fromsed(ji,jsclay) = zkwnlo * 1.* por1clay
+            ELSE   ! 2 < ikwneg(ji) <= jpksedm1
+
+               zkwnup = ABS( zwb(ji,ikwneg-1) ) * por1(ikwneg-1) / ( dz(ikwneg) * por1(ikwneg) )
+               zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
+
+               IF( ikwneg > 3 ) THEN
+
+                  zfull (ikwneg-1) = zfilled(ikwneg-1) - zkwnup * dvolsp(ikwneg-1)
+                  zempty(ikwneg-1) = 1. - zfull(ikwneg-1) 
+                  DO jk = ikwneg-2, 2, -1
+                     zfull (jk) = zfilled(jk) - zempty(jk+1) * dvolsp(jk)
+                     zempty(jk)    = 1. - zfull(jk) 
+                  ENDDO
+                  DO js = 1, jpsol
+                     solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
+                  ENDDO
+                  DO js = 1, jpsol
+                     DO jk = ikwneg-1, 3, -1
+                        solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
+                     ENDDO
+                  ENDDO
+               ELSE ! ikw = 3
+
+
+                  zfull (2) = zfilled(2) - zkwnup * dvolsm(3)
+                  zempty(2) = 1. - zfull(2)
+                  DO js = 1, jpsol
+                     solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
+                  ENDDO
+               ENDIF
+
+               IF( ikwneg < jpksedm1) THEN
+
+                  zfull (ikwneg+1) = zfilled(ikwneg+1) - zkwnlo * dvolsm(ikwneg+1)
+                  zempty(ikwneg+1) = 1. - zfull(ikwneg+1) 
+                  DO jk = ikwneg+2, jpksed
+                     zfull (jk) = zfilled(jk) - zempty(jk-1) * dvolsm(jk)
+                     zempty(jk) = 1. - zfull(jk)
+                  ENDDO
+                  DO js = 1, jpsol
+                     DO jk = ikwneg+1, jpksedm1
+                        solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js) 
+                     ENDDO
+                     solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
+                  ENDDO
+                  solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
+               ELSE
+
+                  zfull (jpksed) = zfilled(jpksed) - zkwnlo * dvolsm(jpksed)
+                  zempty(jpksed) = 1. - zfull(jpksed)                
+                  DO js = 1, jpsol
+                     solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
+                  ENDDO
+                  solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
+               ENDIF ! jpksedm1
+               
+               ! ikwneg = jpksedm1  ; ikwneg+1 = jpksed ; ikwneg-1 = jpksed - 2
+               DO js = 1, jpsol
+                  solcp(ji,ikwneg,js) =  zfull(ikwneg) * zsolcpno(ikwneg  ,js) &
+                     &                +  zkwnup        * zsolcpno(ikwneg-1,js) &
+                     &                +  zkwnlo        * zsolcpno(ikwneg+1,js)   
+                  tosed  (ji,js)   = 0.
+                  fromsed(ji,js)   = 0.
+               ENDDO
+               ! Heinze  fromsed(ji,jsclay) = zempty * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
+               fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
+            ENDIF ! ikwneg(ji) = 2
+         ENDIF  ! zwb > 0
+      ENDDO  ! ji = 1, jpoce
+
+      rainrm(:,:) = 0.
+      rainrg(:,:) = 0.
+      raintg(:)   = 0.
+
+
+      DEALLOCATE( zgap  ) ;  DEALLOCATE( zwb )
+
+
+   END SUBROUTINE sed_adv
+#else
+   !!======================================================================
+   !! MODULE sedbtb  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_adv( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_adv
+
+   !!======================================================================
+
+#endif
+END MODULE sedadv
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedarr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedarr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedarr.F90	(revision 1844)
@@ -0,0 +1,129 @@
+MODULE sedarr
+   !!======================================================================
+   !!                       ***  MODULE sedarr   ***
+   !!              transform 1D (2D) array to a 2D (1D) table
+   !!======================================================================
+#if defined key_sed
+   !!----------------------------------------------------------------------
+   !!   arr_2d_1d  : 2-D to 1-D
+   !!   arr_1d_2d  : 1-D to 2-D
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_sed
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE pack_arr
+      MODULE PROCEDURE pack_arr_2d_1d , pack_arr_3d_2d 
+   END INTERFACE
+
+   INTERFACE unpack_arr
+      MODULE PROCEDURE unpack_arr_1d_2d , unpack_arr_2d_3d 
+   END INTERFACE
+
+   !! * Routine accessibility
+   PUBLIC pack_arr
+   PUBLIC unpack_arr
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/LIM_SRC/limtab.F90,v 1.2 2005/03/27 18:34:42 opalod Exp $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE pack_arr_2d_1d ( ndim1d, tab1d, tab2d, tab_ind )
+
+      INTEGER, INTENT(in) ::  ndim1d
+      REAL(wp), DIMENSION (jpi, jpj), INTENT(in) :: tab2d
+      INTEGER, DIMENSION (ndim1d), INTENT (in) :: tab_ind
+      REAL(wp), DIMENSION(ndim1d), INTENT (out) ::  tab1d
+
+      INTEGER ::  jn, jid, jjd
+        
+      DO jn = 1, ndim1d
+         jid        = MOD( tab_ind(jn) - 1, jpi ) + 1
+         jjd        = ( tab_ind(jn) - 1 ) / jpi + 1
+         tab1d(jn)  = tab2d(jid, jjd)
+      END DO 
+
+   END SUBROUTINE pack_arr_2d_1d
+
+   SUBROUTINE unpack_arr_1d_2d ( ndim1d, tab2d, tab_ind, tab1d )
+
+      INTEGER, INTENT ( in) ::  ndim1d
+      INTEGER, DIMENSION (ndim1d) , INTENT (in) ::   tab_ind
+      REAL(wp), DIMENSION(ndim1d), INTENT (in) ::   tab1d  
+      REAL(wp), DIMENSION (jpi, jpj), INTENT ( out) ::  tab2d
+      INTEGER ::  jn, jid, jjd
+
+      DO jn = 1, ndim1d
+         jid             = MOD( tab_ind(jn) - 1, jpi) + 1
+         jjd             =    ( tab_ind(jn) - 1 ) / jpi  + 1
+         tab2d(jid, jjd) = tab1d(jn)
+      END DO
+
+   END SUBROUTINE unpack_arr_1d_2d
+
+   SUBROUTINE pack_arr_3d_2d ( ndim1d, tab2d, tab3d, tab_ind )
+
+      INTEGER, INTENT(in) :: ndim1d      
+      REAL(wp), DIMENSION(jpi,jpj,jpksed), INTENT(in) ::   tab3d      
+      INTEGER, DIMENSION(ndim1d), INTENT (in) ::   tab_ind      
+      REAL(wp), DIMENSION(ndim1d,jpksed), INTENT (out) ::    tab2d 
+      INTEGER, DIMENSION(ndim1d) ::  jid, jjd        
+      INTEGER ::    jk, jn , ji, jj
+      
+      DO jn = 1, ndim1d
+         jid(jn) = MOD( tab_ind(jn) - 1, jpi ) + 1
+         jjd(jn) = ( tab_ind(jn) - 1 ) / jpi + 1
+      END DO
+ 
+      DO jk = 1, jpksed
+         DO jn = 1, ndim1d
+            ji = jid(jn)
+            jj = jjd(jn)
+            tab2d(jn,jk)  = tab3d(ji,jj,jk) 
+         ENDDO
+      ENDDO
+      
+   END SUBROUTINE pack_arr_3d_2d
+
+
+   SUBROUTINE unpack_arr_2d_3d ( ndim1d, tab3d, tab_ind, tab2d )
+
+      INTEGER, INTENT(in) :: ndim1d      
+      REAL(wp), DIMENSION(ndim1d,jpksed), INTENT(in) ::   tab2d      
+      INTEGER, DIMENSION(ndim1d), INTENT (in) ::   tab_ind      
+      REAL(wp), DIMENSION(jpi,jpj,jpksed), INTENT (out) ::    tab3d 
+      INTEGER, DIMENSION(ndim1d) ::  jid, jjd        
+      INTEGER ::   jk, jn , ji, jj
+
+     DO jn = 1, ndim1d
+         jid(jn) = MOD( tab_ind(jn) - 1, jpi ) + 1
+         jjd(jn) = ( tab_ind(jn) - 1 ) / jpi + 1
+      END DO
+ 
+      DO jk = 1, jpksed
+         DO jn = 1, ndim1d
+            ji = jid(jn)
+            jj = jjd(jn)
+            tab3d(ji, jj, jk) = tab2d(jn,jk)
+         ENDDO
+      ENDDO
+
+   END SUBROUTINE unpack_arr_2d_3d
+
+#else
+   !!======================================================================
+   !! MODULE sedarr  :   Dummy module
+   !!======================================================================
+CONTAINS
+   SUBROUTINE pack_arr         ! Empty routine
+   END SUBROUTINE  pack_arr
+   SUBROUTINE unpack_arr         ! Empty routine
+   END SUBROUTINE  unpack_arr
+   !!======================================================================
+#endif
+END MODULE sedarr
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedbtb.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedbtb.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedbtb.F90	(revision 1844)
@@ -0,0 +1,93 @@
+MODULE sedbtb
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  sedbtb  ***
+   !!    Sediment : bioturbation of the solid components
+   !!=====================================================================
+   !! * Modules used
+   USE sed     ! sediment global variable
+   USE sedmat  ! linear system of equations
+
+   PUBLIC sed_btb
+
+
+CONTAINS
+   
+   SUBROUTINE sed_btb( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sed_btb  ***
+      !!
+      !! ** Purpose :  performs bioturbation of the solid sediment components
+      !!
+      !! ** Method  :  ``diffusion'' of solid sediment components. 
+      !!
+      !!   History :
+      !!        !  98-08 (E. Maier-Reimer, Christoph Heinze )  Original code
+      !!        !  04-10 (N. Emprin, M. Gehlen ) F90
+      !!        !  06-04 (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      !!* Arguments
+      INTEGER, INTENT(in) ::  &
+         kt              ! time step
+
+      ! * local variables
+
+      INTEGER :: &
+         ji, jk, js
+
+      REAL(wp), DIMENSION(:,:,:) , ALLOCATABLE ::  &
+         zsol                      ! solution
+      !------------------------------------------------------------------------
+
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' sed_btb : Bioturbation  '
+         WRITE(numsed,*) ' '
+      ENDIF
+
+      ! Initializations
+      !----------------
+      ALLOCATE( zsol(jpoce,jpksedm1,jpsol) )
+
+      zsol(:,:,:) = 0.
+
+
+      ! right hand side of coefficient matrix
+      !--------------------------------------
+      DO js = 1, jpsol
+         DO jk = 1, jpksedm1
+            DO ji = 1, jpoce
+               zsol(ji,jk,js) = solcp(ji,jk+1,js)
+            ENDDO
+         ENDDO
+      ENDDO
+
+      CALL sed_mat( jpsol, jpoce, jpksedm1, zsol )
+
+
+      ! store solution of the tridiagonal system
+      !------------------------
+      DO js = 1, jpsol
+         DO jk = 1, jpksedm1
+            DO ji = 1, jpoce
+               solcp(ji,jk+1,js) = zsol(ji,jk,js)
+            ENDDO
+         ENDDO
+      ENDDO
+     
+      DEALLOCATE( zsol )
+
+   END SUBROUTINE sed_btb
+#else
+   !!======================================================================
+   !! MODULE sedbtb  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_btb( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_btb: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_btb
+
+   !!======================================================================
+
+#endif
+END MODULE sedbtb
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedchem.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedchem.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedchem.F90	(revision 1844)
@@ -0,0 +1,579 @@
+MODULE sedchem
+
+#if defined key_sed 
+   !!======================================================================
+   !!                        ***  Module sedchem  ***
+   !! sediment :   Variable for chemistry of the CO2 cycle
+   !!======================================================================
+   !!   modules used
+   USE sed     ! sediment global variable
+   USE sedarr
+
+   !! * Accessibility
+   PUBLIC sed_chem   
+
+   !! * Module variables
+   REAL(wp) :: &
+      salchl = 1./1.80655 , & ! conversion factor for salinity --> chlorinity (Wooster et al. 1969)
+      calcon = 1.03E-2        ! mean calcite concentration [Ca2+] in sea water [mole/kg solution] 
+
+   REAL(wp) :: &              ! coeff. for 1. dissoc. of carbonic acid (Millero, 1995)   
+      c10 = 3670.7   , &
+      c11 = 62.008   , &
+      c12 = 9.7944   , &
+      c13 = 0.0118   , &
+      c14 = 0.000116
+
+   REAL(wp) :: &              ! coeff. for 2. dissoc. of carbonic acid (Millero, 1995)   
+      c20 = 1394.7   , &
+      c21 = 4.777    , &
+      c22 = 0.       , &
+      c23 = 0.0184   , &
+      c24 = 0.000118
+
+   REAL(wp) :: &              ! coeff. for 1. dissoc. of boric acid (Dickson and Goyet, 1994)
+      cb0  = -8966.90, &
+      cb1  = -2890.53, &
+      cb2  = -77.942 , &
+      cb3  = 1.728   , &
+      cb4  = -0.0996 , &
+      cb5  = 148.0248, &
+      cb6  = 137.1942, &
+      cb7  = 1.62142 , &
+      cb8  = -24.4344, &
+      cb9  = -25.085 , &
+      cb10 = -0.2474 , &
+      cb11 = 0.053105
+
+   REAL(wp) :: &             ! borat constants
+      bor1 = 0.000232, &
+      bor2 = 1./10.811
+
+   REAL(wp) :: &             ! constants for calculate concentrations 
+      st1  = 0.14     , &    ! for sulfate (Morris & Riley 1966)
+      st2  = 1./96.062, &
+      ks0  = 141.328  , &
+      ks1  = -4276.1  , &
+      ks2  = -23.093  , &
+      ks3  = -13856.  , &
+      ks4  = 324.57   , &
+      ks5  = -47.986  , &
+      ks6  = 35474.   , &
+      ks7  = -771.54  , &
+      ks8  = 114.723  , &
+      ks9  = -2698.   , &
+      ks10 = 1776.    , &
+      ks11 = 1.       , &
+      ks12 = -0.001005 
+
+   REAL(wp) :: &             ! constants for calculate concentrations 
+      ft1  = 0.000067   , &  ! fluorides (Dickson & Riley 1979 )
+      ft2  = 1./18.9984 , &
+      kf0  = -12.641    , &
+      kf1  = 1590.2     , &
+      kf2  = 1.525      , &
+      kf3  = 1.0        , &
+      kf4  =-0.001005
+
+   REAL(wp) :: &             ! coeff. for dissoc. of water (Dickson and Riley, 1979 )
+      cw0 = -13847.26  , &
+      cw1 = 148.9802   , &
+      cw2 = -23.6521   , &
+      cw3 = 118.67     , &
+      cw4 = -5.977     , &
+      cw5 = 1.0495     , &
+      cw6 = -0.01615
+ 
+   REAL(wp) :: &             ! coeff. for dissoc. of phosphate (Millero (1974)
+      cp10 = 115.54    , &
+      cp11 = -4576.752 , &
+      cp12 = -18.453   , &
+      cp13 = -106.736  , &
+      cp14 = 0.69171   , &
+      cp15 = -0.65643  , &
+      cp16 = -0.01844  , &
+      cp20 = 172.1033  , &
+      cp21 = -8814.715 , &
+      cp22 = -27.927   , &
+      cp23 = -160.340  , &
+      cp24 = 1.3566    , &
+      cp25 = 0.37335   , &
+      cp26 = -0.05778  , &
+      cp30 = -18.126   , &
+      cp31 = -3070.75  , &
+      cp32 = 17.27039  , &
+      cp33 = 2.81197   , &
+      cp34 = -44.99486 , &
+      cp35 = -0.09984
+
+   REAL(wp) :: &             ! coeff. for dissoc. of silicates (Millero (1974)  
+      cs10 = 117.40    , &  
+      cs11 = -8904.2   , & 
+      cs12 = -19.334   , & 
+      cs13 = -458.79   , & 
+      cs14 = 3.5913    , & 
+      cs15 = 188.74    , & 
+      cs16 = -1.5998   , & 
+      cs17 = -12.1652  , & 
+      cs18 = 0.07871   , & 
+      cs19 = 0.        , & 
+      cs20 = 1.        , & 
+      cs21 = -0.001005
+
+   REAL(wp) :: &            ! coeff. for apparent solubility equilibrium 
+      ! akcc1 = -34.452 , & ! of calcite (Ingle,1975,  1800, eq. 6)
+      ! akcc2 = -39.866 , &  
+      ! akcc3 = 110.21  , &  
+      ! akcc4 = -7.5752E-6  
+      akcc1 = -171.9065 , &    ! Millero et al. 1995 from Mucci 1983
+      akcc2 = -0.077993 , &  
+      akcc3 = 2839.319  , &  
+      akcc4 = 71.595    , &  
+      akcc5 = -0.77712  , &  
+      akcc6 = 0.0028426 , &  
+      akcc7 = 178.34    , &  
+      akcc8 = -0.07711  , &  
+      akcc9 = 0.0041249
+
+   REAL(wp) :: &                 ! universal gas constant
+      rgas = 83.145              ! bar.cm3/(mol.K) or R=8.31451 J/(g.mol.K)
+
+
+   ! coeff. for seawater pressure correction (millero 95)		
+   REAL(wp), DIMENSION(8)  :: & 
+      devk1, devk2, devk3, devk4, devk5
+
+   DATA devk1/ -25.5   , -15.82    , -29.48  , -25.60    , -48.76    , -14.51   , -23.12   , -26.57   /   
+   DATA devk2/ 0.1271  , -0.0219   , 0.1622  , 0.2324    , -0.5304   , 0.1211   ,  0.1758  , 0.2020   /   
+   DATA devk3/ 0.      , 0.        , 2.608E-3, -3.6246E-3, 0.        , -0.321E-3, -2.647E-3, -3.042E-3/   
+   DATA devk4/-3.08E-3 , 1.13E-3   , -2.84E-3, -5.13E-3  , -11.76E-3 , -2.67E-3 , -5.15E-3 , -4.08E-3 /   
+   DATA devk5/0.0877E-3, -0.1475E-3, 0.      , 0.0794E-3 , -0.3692E-3, 0.0427E-3,  0.09E-3 , 0.0714E-3/
+
+
+   ! coeff. for density of sea water (Millero & Poisson 1981) 
+   REAL(wp), DIMENSION(5)  :: Adsw                       
+   DATA Adsw/8.24493E-1, -4.0899E-3, 7.6438E-5 , -8.246E-7, 5.3875E-9 /
+
+   REAL(wp), DIMENSION(3)  :: Bdsw 
+   DATA Bdsw / -5.72466E-3, 1.0227E-4, -1.6546E-6 /
+
+   REAL(wp)  :: Cdsw = 4.8314E-4
+
+   REAL(wp), DIMENSION(6)  :: Ddsw                    
+   DATA Ddsw / 999.842594 , 6.793952E-2 , -9.095290E-3, 1.001685E-4, -1.120083E-6, 6.536332E-9/
+
+
+   !! * Module variables
+   REAL(wp), DIMENSION(jpi,jpj,10) :: &
+      chem_data
+
+CONTAINS
+
+   SUBROUTINE sed_chem( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_chem  ***
+      !!
+      !! ** Purpose :   set chemical constants
+      !!
+      !!   History :
+      !!        !  04-10  (N. Emprin, M. Gehlen )  Original code
+      !!        !  06-04  (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      !!* Arguments
+      INTEGER, INTENT(in) ::  &
+         kt                     ! time step
+
+#if ! defined key_sed_off
+      INTEGER :: &
+         ji, jj, ikt
+
+      REAL(wp) :: &
+         ztkel, ztc, ztc2, zpres, ztr ,   &
+         zsal, zsal2, zsqrt, zsal15   ,   &
+         zis, zis2, zisqrt            ,   &
+         zdens0, zaw, zbw, zcw        ,   &
+         zbuf1, zbuf2 ,   & 
+         zcpexp, zcpexp2              ,   &
+         zck1p, zck2p, zck3p, zcksi   
+
+     REAL(wp), DIMENSION(jpi,jpj,6) :: &
+        zchem_data
+
+#endif
+      !!----------------------------------------------------------------------
+
+      IF( MOD( kt - 1, nfreq ) /= 0 ) RETURN
+
+      WRITE(numsed,*) ' Getting Chemical constants from tracer model at time kt = ', kt
+      WRITE(numsed,*) ' '
+
+
+#if defined key_sed_off
+      CALL sed_chem_off
+#else
+      ! reading variables
+      zchem_data(:,:,:) = 0.
+      DO jj = 1,jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj)-1, 1 )
+            IF ( tmask(ji,jj,ikt) == 1 ) THEN
+               zchem_data(ji,jj,1) = ak13 (ji,jj,ikt)
+               zchem_data(ji,jj,2) = ak23 (ji,jj,ikt)
+               zchem_data(ji,jj,3) = akb3 (ji,jj,ikt)
+               zchem_data(ji,jj,4) = akw3 (ji,jj,ikt)
+               zchem_data(ji,jj,5) = aksp (ji,jj,ikt)
+               zchem_data(ji,jj,6) = borat(ji,jj,ikt)
+            ENDIF
+         ENDDO
+      ENDDO
+
+      CALL pack_arr ( jpoce, ak1s  (1:jpoce), zchem_data(1:jpi,1:jpj,1), iarroce(1:jpoce) )
+      CALL pack_arr ( jpoce, ak2s  (1:jpoce), zchem_data(1:jpi,1:jpj,2), iarroce(1:jpoce) )
+      CALL pack_arr ( jpoce, akbs  (1:jpoce), zchem_data(1:jpi,1:jpj,3), iarroce(1:jpoce) )
+      CALL pack_arr ( jpoce, akws  (1:jpoce), zchem_data(1:jpi,1:jpj,4), iarroce(1:jpoce) )
+      CALL pack_arr ( jpoce, aksps (1:jpoce), zchem_data(1:jpi,1:jpj,5), iarroce(1:jpoce) )
+      CALL pack_arr ( jpoce, borats(1:jpoce), zchem_data(1:jpi,1:jpj,6), iarroce(1:jpoce) )
+
+      DO ji = 1, jpoce
+         ztkel   = temp(ji) + 273.16
+         ztc     = temp(ji)
+         ztc2    = ztc * ztc
+         zpres   = press(ji)
+         ! zqtt    = ztkel * 0.01
+         zsal    = salt(ji)
+         zsal2   = zsal * zsal 
+         zsqrt   = SQRT( zsal )
+         zsal15  = zsqrt * zsal
+         zlogt   = LOG( ztkel )
+         ztr     = 1./ ztkel
+         ! zis=ionic strength (ORNL/CDIAC-74, DOE 94,Dickson and Goyet)
+         zis     = 19.924 * zsal / ( 1000. - 1.005 * zsal )
+         zis2    = zis * zis
+         zisqrt  = SQRT( zis )
+
+         ! Density of Sea Water - F(temp,sal) [kg/m3]
+         zdens0 =  Ddsw(1) + Ddsw(2) * ztc + Ddsw(3) * ztc2 &
+                  + Ddsw(4) * ztc * ztc2 + Ddsw(5) * ztc2 * ztc2 &
+                  + Ddsw(6) * ztc * ztc2 * ztc2
+         zaw =  Adsw(1) + Adsw(2) * ztc + Adsw(3)* ztc2 + Adsw(4) * ztc * ztc2 &
+              + Adsw(5) * ztc2 * ztc2
+         zbw =  Bdsw(1) + Bdsw(2) * ztc + Bdsw(3) * ztc2
+         zcw =  Cdsw
+         densSW(ji) = zdens0 + zaw * zsal + zbw * zsal15 + zcw * zsal * zsal
+         densSW(ji) = densSW(ji) * 1E-3   ! to get dens in [kg/l]
+
+         ! FORMULA FOR CPEXP AFTER EDMOND AND GIESKES (1970) 
+         ! (REFERENCE TO CULBERSON AND PYTKOQICZ (1968) AS MADE IN BROECKER ET AL. (1982) 
+         ! IS INCORRECT; HERE RGAS IS TAKEN TENFOLD TO CORRECT FOR THE NOTATION OF pres  IN
+         ! DBAR INSTEAD OF BAR AND THE EXPRESSION FOR CPEXP IS MULTIPLIED BY LN(10.) 
+         ! TO ALLOW USE OF EXP-FUNCTION WITH BASIS E IN THE FORMULA FOR AKSPP 
+         ! (CF. EDMOND AND GIESKES (1970), P. 1285 AND P. 1286 (THE SMALL FORMULA ON P. 1286 
+         ! IS RIGHT AND CONSISTENT WITH THE SIGN IN PARTIAL MOLAR VOLUME CHANGE AS SHOWN ON P. 1285)
+         !-----------------------------------------------------------------------------------------
+         zcpexp  = zpres / ( rgas*ztkel )
+         zcpexp2 = zpres * zcpexp
+
+         ! For Phodphates (phosphoric acid) (DOE 1994)
+         !----------------------------------------------
+         zck1p = cp10 + cp11*ztr + cp12*zlogt + ( cp13*ztr + cp14 ) * zsqrt &
+            &      + ( cp15*ztr + cp16 ) * zsal
+         zck2p = cp20 + cp21*ztr + cp22*zlogt + ( cp23*ztr + cp24 ) * zsqrt &
+            &      + ( cp25*ztr + cp26 ) * zsal
+         zck3p = cp30 + cp31*ztr + ( cp32*ztr + cp33 ) *  zsqrt &
+            &      + ( cp34*ztr + cp35 ) * zsal
+
+         ! For silicates (DOE 1994) change to mol/kg soln) (OCMIP)
+         !--------------------------------------------------------
+         zcksi = cs10 + cs11*ztr + cs12*zlogt + ( cs13*ztr + cs14) * zisqrt &
+            &      + ( cs15*ztr + cs16 ) * zis &
+            &      + ( cs17*ztr + cs18 ) * zis2 &
+            &      + LOG( 1. + cs19*zsal ) + LOG( cs20 + cs21*zsal )
+
+
+         !K1, K2 of carbonic acid, KB of boric acid, KW (H2O)
+         !---------------------------------------------------
+         zak1p  = EXP ( zck1p  )
+         zak2p  = EXP ( zck2p  )
+         zak3p  = EXP ( zck3p  )
+         zaksil = EXP ( zcksi  )
+
+         zbuf1       = - ( devk1(3) + devk2(3)*ztc + devk3(3)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(3) + devk5(3)*ztc )
+         aksis(ji)     = zaksil * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(6) + devk2(6)*ztc + devk3(6)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(6) + devk5(6)*ztc )
+         ak1ps(ji)   = zak1p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+ 
+         zbuf1       = - ( devk1(7) + devk2(7)*ztc + devk3(7)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(7) + devk5(7)*ztc )
+         ak2ps(ji)   = zak2p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(8) + devk2(8)*ztc + devk3(8)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(8) + devk5(8)*ztc )
+         ak3ps(ji)   = zak3p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         ak12s  (ji) = ak1s (ji) * ak2s (ji)
+         ak12ps (ji) = ak1ps(ji) * ak2ps(ji)
+         ak123ps(ji) = ak1ps(ji) * ak2ps(ji) * ak3ps(ji)
+
+         calcon2(ji) = 0.01028 * ( salt(ji) / 35. ) * densSW(ji)
+      ENDDO
+#endif
+
+   END SUBROUTINE sed_chem
+
+#if defined key_sed_off
+
+   SUBROUTINE sed_chem_off
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_chem_off  ***
+      !!                    
+      !! ** Purpose :   compute chemical constants
+      !!
+      !!   History :
+      !!        !  04-10  (N. Emprin, M. Gehlen )  Original code
+      !!        !  06-04  (C. Ethe)  Re-organization 
+      !!----------------------------------------------------------------------  
+      !! * Local declarations
+      INTEGER :: &
+         ji
+
+      REAL(wp) :: &
+         ztkel, ztc, ztc2, zpres, ztr ,   &
+         zsal, zsal2, zsqrt, zsal15   ,   &
+         zis, zis2, zisqrt            ,   &
+         zdens0, zaw, zbw, zcw        ,   &
+         zchl, zst, zft, zbuf1, zbuf2 ,   & 
+         zcpexp, zcpexp2              ,   &
+         zckb, zck1, zck2, zckw       ,   &
+         zck1p, zck2p, zck3p, zcksi   ,   &
+         zak1, zak2, zakb, zakw       ,   &        
+         zaksp0, zksp, zks, zkf 
+
+
+      ! CHEMICAL CONSTANTS - DEEP OCEAN
+      !-------------------------------------
+      ! [chem constants]=mol/kg solution (or (mol/kg sol)2 for akws and aksp)
+
+      DO ji = 1, jpoce
+         ztkel   = temp(ji) + 273.16
+         ztc     = temp(ji)
+         ztc2    = ztc * ztc
+         zpres   = press(ji)
+         ! zqtt    = ztkel * 0.01
+         zsal    = salt(ji)
+         zsal2   = zsal * zsal 
+         zsqrt   = SQRT( zsal )
+         zsal15  = zsqrt * zsal
+         zlogt   = LOG( ztkel )
+         ztr     = 1./ ztkel
+         ! zis=ionic strength (ORNL/CDIAC-74, DOE 94,Dickson and Goyet)
+         zis     = 19.924 * zsal / ( 1000. - 1.005 * zsal )
+         zis2    = zis * zis
+         zisqrt  = SQRT( zis )
+
+
+         ! Density of Sea Water - F(temp,sal) [kg/m3]
+         zdens0 =  Ddsw(1) + Ddsw(2) * ztc + Ddsw(3) * ztc2 &
+                  + Ddsw(4) * ztc * ztc2 + Ddsw(5) * ztc2 * ztc2 &
+                  + Ddsw(6) * ztc * ztc2 * ztc2
+         zaw =  Adsw(1) + Adsw(2) * ztc + Adsw(3)* ztc2 + Adsw(4) * ztc * ztc2 &
+              + Adsw(5) * ztc2 * ztc2
+         zbw =  Bdsw(1) + Bdsw(2) * ztc + Bdsw(3) * ztc2
+         zcw =  Cdsw
+         densSW(ji) = zdens0 + zaw * zsal + zbw * zsal15 + zcw * zsal * zsal
+         densSW(ji) = densSW(ji) * 1E-3   ! to get dens in [kg/l]
+
+
+         ! FORMULA FOR CPEXP AFTER EDMOND AND GIESKES (1970) 
+         ! (REFERENCE TO CULBERSON AND PYTKOQICZ (1968) AS MADE IN BROECKER ET AL. (1982) 
+         ! IS INCORRECT; HERE RGAS IS TAKEN TENFOLD TO CORRECT FOR THE NOTATION OF pres  IN
+         ! DBAR INSTEAD OF BAR AND THE EXPRESSION FOR CPEXP IS MULTIPLIED BY LN(10.) 
+         ! TO ALLOW USE OF EXP-FUNCTION WITH BASIS E IN THE FORMULA FOR AKSPP 
+         ! (CF. EDMOND AND GIESKES (1970), P. 1285 AND P. 1286 (THE SMALL FORMULA ON P. 1286 
+         ! IS RIGHT AND CONSISTENT WITH THE SIGN IN PARTIAL MOLAR VOLUME CHANGE AS SHOWN ON P. 1285)
+         !-----------------------------------------------------------------------------------------
+         zcpexp  = zpres / ( rgas*ztkel )
+         zcpexp2 = zpres * zcpexp
+
+
+         ! chlorinity (WOOSTER ET AL., 1969)
+         !---------------------------------------
+         zchl = zsal * salchl
+
+         ! total sulfate concentration [mol/kg soln]
+         ! --------------------------------------
+         zst = st1 * zchl * st2
+
+         ! total fluoride concentration [mol/kg soln]
+         ! --------------------------------------
+         zft = ft1 * zchl * ft2
+
+         ! dissociation constant for carbonate (Mehrback 74 - Dickson & Millero 87)
+         !---------------------------------------------------------------------------
+         zck1 = c10*ztr - c11 + c12*zlogt - c13*zsal + c14*zsal2
+         zck2 = c20*ztr + c21 - c22*zlogt - c23*zsal + c24*zsal2
+
+         ! dissociation constant for sulfates (Dickson 1990)
+         !--------------------------------------------------
+         zks = EXP(  ks0 + ks1*ztr + ks2*zlogt &
+            &    + ( ks3*ztr + ks4 + ks5*zlogt ) * zisqrt &
+            &    + ( ks6*ztr + ks7 + ks8*zlogt ) * zis    &
+            &    +   ks9*ztr*zis*zisqrt + ks10*ztr*zis2   &
+            &    +   LOG( ks11 + ks12*zsal ) )
+
+         ! dissociation constant for fluorides (Dickson and Riley 79)
+         !--------------------------------------------------
+         zkf = EXP( kf0 + kf1*ztr + kf2*zisqrt + LOG( kf3 + kf4*zsal ) )
+
+         ! dissociation constant for borates (Doe 94)
+         !--------------------------------------------------
+         zckb = (  cb0 + cb1*zsqrt + cb2*zsal + cb3*zsal15 + cb4*zsal2) * ztr &
+            &  + ( cb5 + cb6*zsqrt + cb7*zsal) &
+            &  + ( cb8 + cb9*zsqrt + cb10*zsal) * zlogt &
+            &  +   cb11*zsqrt*ztkel + LOG( ( 1. + zst/zks + zft/zkf ) / ( 1. + zst/zks ) ) 
+
+         ! PKW (H2O) (DICKSON AND RILEY, 1979)
+         !--------------------------------------
+         zckw =   cw0*ztr + cw1 + cw2*zlogt &
+            & +( cw3*ztr + cw4 + cw5*zlogt )* zsqrt + cw6*zsal
+         
+         ! For Phodphates (phosphoric acid) (DOE 1994)
+         !----------------------------------------------
+         zck1p = cp10 + cp11*ztr + cp12*zlogt + ( cp13*ztr + cp14 ) * zsqrt &
+            &      + ( cp15*ztr + cp16 ) * zsal
+         zck2p = cp20 + cp21*ztr + cp22*zlogt + ( cp23*ztr + cp24 ) * zsqrt &
+            &      + ( cp25*ztr + cp26 ) * zsal
+         zck3p = cp30 + cp31*ztr + ( cp32*ztr + cp33 ) *  zsqrt &
+            &      + ( cp34*ztr + cp35 ) * zsal
+
+         ! For silicates (DOE 1994) change to mol/kg soln) (OCMIP)
+         !--------------------------------------------------------
+         zcksi = cs10 + cs11*ztr + cs12*zlogt + ( cs13*ztr + cs14) * zisqrt &
+            &      + ( cs15*ztr + cs16 ) * zis &
+            &      + ( cs17*ztr + cs18 ) * zis2 &
+            &      + LOG( 1. + cs19*zsal ) + LOG( cs20 + cs21*zsal )
+
+         ! apparent solublity product K'SP of calcite in seawater
+         ! (S=27-43, T=2-25 DEG C) AT pres =0 (INGLE, 1975, EQ. 6)
+         ! prob: olivier a log = ln et C. Heize a LOG10(sal)
+         ! aksp0 = 1.E-7*(akcc1+akcc2*sal**(1./3.)+akcc3*log(sal)+akcc4*tkel*tkel)
+         ! aksp0 = 1.E-7*(akcc1+akcc2*sal**(1./3.)+akcc3*log10(sal)+akcc4*tkel*tkel)
+         !--------------------------------------------------------------------
+         zaksp0 = akcc1 + akcc2*ztkel + akcc3*ztr + akcc4 * LOG10(ztkel) &
+            &  + ( akcc5 + akcc6*ztkel+ akcc7*ztr ) * zsqrt &
+            &  +  akcc8*zsal + akcc9*zsal15
+
+         !K1, K2 of carbonic acid, KB of boric acid, KW (H2O)
+         !---------------------------------------------------
+         zak1   = 10**( -zck1  )
+         zak2   = 10**( -zck2  )
+         zakb   = EXP ( zckb   ) 
+         zakw   = EXP ( zckw   )
+         zksp   = 10**( zaksp0 )
+
+
+
+         ! KB of boric acid, K1,K2 of carbonic acid pressure correction 
+         ! after Culberson and  AND Pytkowicz (1968) (CF. BROECKER ET AL., 1982) Millero 95
+         !--------------------------------------------------------------------------------
+         zbuf1       = - ( devk1(1) + devk2(1)*ztc + devk3(1)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(1) + devk5(1)*ztc )
+         ak1s(ji)    = zak1 * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = -( devk1(2) + devk2(2)*ztc + devk3(2)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(2) + devk5(2)*ztc )
+         ak2s(ji)    = zak2 * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(3) + devk2(3)*ztc + devk3(3)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(3) + devk5(3) * ztc )
+         akbs(ji)    = zakb * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(4) + devk2(4)*ztc + devk3(4)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(4) + devk5(4)*ztc )
+         akws(ji)    = zakw * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+
+         ! APPARENT SOLUBILITY PRODUCT K''SP OF CALCITE (OR ARAGONITE)
+         ! AS FUNCTION OF PRESSURE FOLLWING EDMOND AND GIESKES (1970)
+         ! (P. 1285) AND BERNER (1976)
+         !-----------------------------------------------------------------
+         ! aksp(ji) = aksp0*exp(zcpexp*(devks-devkst*tc))
+         ! or following Mucci
+         zbuf1      = - ( devk1(5) + devk2(5)*ztc + devk3(5)*ztc2 )
+         zbuf2      = 0.5 *( devk4(5) + devk5(5)*ztc )
+         aksps(ji)   = zksp * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         ! For Phodphates (phosphoric acid) (DOE 1994)
+         !----------------------------------------------
+         zck1p = cp10 + cp11*ztr + cp12*zlogt + ( cp13*ztr + cp14 ) * zsqrt &
+            &      + ( cp15*ztr + cp16 ) * zsal
+         zck2p = cp20 + cp21*ztr + cp22*zlogt + ( cp23*ztr + cp24 ) * zsqrt &
+            &      + ( cp25*ztr + cp26 ) * zsal
+         zck3p = cp30 + cp31*ztr + ( cp32*ztr + cp33 ) *  zsqrt &
+            &      + ( cp34*ztr + cp35 ) * zsal
+
+         ! For silicates (DOE 1994) change to mol/kg soln) (OCMIP)
+         !--------------------------------------------------------
+         zcksi = cs10 + cs11*ztr + cs12*zlogt + ( cs13*ztr + cs14) * zisqrt &
+            &      + ( cs15*ztr + cs16 ) * zis &
+            &      + ( cs17*ztr + cs18 ) * zis2 &
+            &      + LOG( 1. + cs19*zsal ) + LOG( cs20 + cs21*zsal )
+
+
+         !K1, K2 of carbonic acid, KB of boric acid, KW (H2O)
+         !---------------------------------------------------
+         zak1p  = EXP ( zck1p  )
+         zak2p  = EXP ( zck2p  )
+         zak3p  = EXP ( zck3p  )
+         zaksil = EXP ( zcksi  )
+
+         zbuf1       = - ( devk1(3) + devk2(3)*ztc + devk3(3)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(3) + devk5(3)*ztc )
+         aksis(ji)     = zaksil * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(6) + devk2(6)*ztc + devk3(6)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(6) + devk5(6)*ztc )
+         ak1ps(ji)   = zak1p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+ 
+         zbuf1       = - ( devk1(7) + devk2(7)*ztc + devk3(7)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(7) + devk5(7)*ztc )
+         ak2ps(ji)   = zak2p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         zbuf1       = - ( devk1(8) + devk2(8)*ztc + devk3(8)*ztc2 )
+         zbuf2       = 0.5 * ( devk4(8) + devk5(8)*ztc )
+         ak3ps(ji)   = zak3p * EXP( zbuf1*zcpexp + zbuf2*zcpexp2 )
+
+         ! total borat concentration. [mol/l]
+         ! or from Millero 1995 [mol/l] : borat(l) = 0.000416_8*(sal/35._8)*densSW(l)
+         ! --------------------------------------------------------------------------
+         borats(ji) = bor1 * zchl * bor2 * densSW(ji)
+
+         ak12s  (ji) = ak1s (ji) * ak2s (ji)
+         ak12ps (ji) = ak1ps(ji) * ak2ps(ji)
+         ak123ps(ji) = ak1ps(ji) * ak2ps(ji) * ak3ps(ji)
+
+         calcon2(ji) = 0.01028 * ( zsal / 35. ) * densSW(ji)
+
+      ENDDO
+
+   END SUBROUTINE sed_chem_off
+
+#endif
+
+#else
+   !!======================================================================
+   !! MODULE sedchem  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_chem( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_chem
+
+   !!======================================================================
+
+#endif
+
+END MODULE sedchem
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedco3.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedco3.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedco3.F90	(revision 1844)
@@ -0,0 +1,212 @@
+MODULE sedco3
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  sedco3  ***
+   !!    Sediment : carbonate in sediment pore water
+   !!=====================================================================
+   !! * Modules used
+   USE sed     ! sediment global variable
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC sed_co3     
+
+
+   !! * Module variables
+   REAL(wp) ::           & !! 
+      epsmax   =  1.e-12      ! convergence limite value
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0   !   LODYC-IPSL   (2003)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+
+   SUBROUTINE sed_co3( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_co3  ***
+      !!
+      !! ** Purpose :  carbonate ion and proton concentration 
+      !!               in sediment pore water
+      !!
+      !! ** Methode :  - solving nonlinear equation for [H+] with given alkalinity
+      !!               and total co2 
+      !!               - one dimensional newton-raphson algorithm for [H+])
+      !!
+      !!   History :
+      !!        !  98-08 (E. Maier-Reimer, Christoph Heinze )  Original code
+      !!        !  04-10 (N. Emprin, M. Gehlen ) coupled with PISCES
+      !!        !  06-04 (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT(in)  :: &
+         kt   ! time step
+
+      !
+      !---Local variables
+      INTEGER :: &
+         jiter, ji, jk, ipt    ! dummy loop indices
+
+      INTEGER :: &
+         itermax    ,  &  ! maximum number of Newton-Raphson iterations
+         itime            ! number of time to perform Newton-Raphson algorithm
+
+      LOGICAL :: &
+         lconv = .FALSE.           ! flag for convergence
+
+      REAL(wp) ::      & 
+         brems            ! relaxation. parameter
+
+      REAL(wp) ::      &  ! temporay variables
+         zresm, zresm1, zhipor_min , &
+         zalk, zbor, zsil, zpo4, zdic, &
+         zh_old, zh_old2, zh_old3, zh_old4, &
+         zuu, zvv, zduu, zdvv , &
+         zup, zvp, zdup, zdvp , &
+         zah_old, zah_olds,     &
+         zh_new, zh_new2,       &
+         zco3
+
+
+     !!----------------------------------------------------------------------
+
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' sed_co3 : carbonate ion and proton concentration calculation  '
+         WRITE(numsed,*) ' '
+      ENDIF
+
+      itermax     = 30
+      brems       = 1.
+      itime       = 0
+
+
+      DO jk = 1, jpksed
+10001    CONTINUE
+         IF( itime <= 2 ) THEN
+            lconv  = .FALSE.
+            IF( itime > 0 ) THEN  
+               ! increase max number of iterations and relaxation parameter
+               itermax = 200
+!!               brems   = 0.3
+               IF( itime == 2 ) hipor(1:jpoce,jk) = 3.e-9 ! re-initilazation of [H] values
+            ENDIF
+
+iflag:      DO jiter = 1, itermax
+
+                ! Store previous hi field.   
+               zresm = -1.e10
+               ipt = 1
+               DO ji = 1, jpoce
+                  ! dissociation constant are in mol/kg of solution
+                  ! convert pwcp concentration [mol/l] in mol/kg for solution
+                  zalk    = pwcp(ji,jk,jwalk) / densSW(ji)
+                  zh_old  = hipor(ji,jk) / densSW(ji)
+                  zh_old2 = zh_old  * zh_old
+                  zh_old3 = zh_old2 * zh_old
+                  zh_old4 = zh_old3 * zh_old
+                  zbor    = borats(ji) / densSW(ji)
+                  zsil    = pwcp(ji,jk,jwsil) / densSW(ji)
+                  zpo4    = pwcp(ji,jk,jwpo4) / densSW(ji)
+                  zdic    = pwcp(ji,jk,jwdic) / densSW(ji)               
+                  ! intermediate calculation 
+                  zuu     = zdic * ( ak1s(ji) / zh_old + 2.* ak12s(ji) / zh_old2 )
+                  zvv     = 1. + ak1s(ji) / zh_old + ak12s(ji) / zh_old2
+                  zduu    = zdic * ( -ak1s(ji) / zh_old2 - 4. * ak12s(ji) / zh_old3 )
+                  zdvv    = -ak1s(ji) / zh_old2 - 2. * ak12s(ji) / zh_old3
+                  zup     = zpo4 * ( ak12ps(ji) / zh_old2 + 2. * ak123ps(ji) / zh_old3 - 1.)
+                  zvp     = 1. + ak1ps(ji) / zh_old + ak12ps(ji) / zh_old2 + ak123ps(ji) / zh_old3
+                  zdup    = zpo4 * ( -2. * ak12ps(ji) / zh_old3 - 6. * ak123ps(ji) / zh_old4 )
+                  zdvp    = -ak1ps(ji) / zh_old2 - 2.* ak12ps(ji) / zh_old3 - 3. * ak123ps(ji) / zh_old4
+                  
+                  zah_old  = zuu / zvv + zbor / ( 1. + zh_old / akbs(ji) ) + &
+                     &      akws(ji) / zh_old - zh_old + zsil / ( 1. + zh_old / aksis(ji) ) + &
+                     &      zup / zvp
+                  
+                  zah_olds = ( ( zduu * zvv - zdvv * zuu ) / ( zvv * zvv ) )      - &
+                     &        zbor / akbs(ji) * ( 1. + zh_old / akbs(ji) )**(-2) - &
+                     &        akws(ji) / zh_old2 - 1. -                            &
+                     &        zsil / aksis(ji) * ( 1. + zh_old / aksis(ji) )**(-2) + &
+                     &       ( ( zdup * zvp - zdvp * zup ) / ( zvp * zvp ) )
+                  !
+                  zh_new = zh_old - brems * ( zah_old - zalk ) / zah_olds
+                  ! 
+                  zresm1 = ABS( zh_new - zh_old )
+                  IF( zresm1 > zresm ) THEN 
+                     zresm = zresm1  
+                  ENDIF
+                  !
+                  zh_new2  = zh_new * zh_new
+                  zco3   = ( ak12s(ji) * zdic ) / ( ak12s(ji) + ak1s(ji) * zh_new + zh_new2)
+                  ! again in mol/l
+                  hipor (ji,jk) = zh_new * densSW(ji)
+                  co3por(ji,jk) = zco3   * densSW(ji)
+                  
+               ENDDO  ! end loop ji
+               
+               ! convergence test
+               IF( zresm <= epsmax ) THEN
+                  lconv = .TRUE.
+                  !minimum value of hipor
+                  zhipor_min = MINVAL( hipor(1:jpoce,jk ) )
+                  EXIT iflag
+               ENDIF
+
+            ENDDO iflag
+
+            IF( lconv ) THEN
+!               WRITE(numsed,*) ' convergence after iter =', jiter, ' iterations ;  res =',zresm  
+               IF( zhipor_min < 0. ) THEN 
+                  IF ( itime == 0 ) THEN
+!                     WRITE(numsed,*) '    but hipor < 0 ; try one more time for jk = ', jk 
+!                     WRITE(numsed,*) '    with re-initialization of initial PH field '       
+                     itime = 2
+                     GOTO 10001
+                  ELSE
+!                     WRITE(numsed,*) ' convergence after iter =', jiter, ' iterations ;  res =',zresm 
+!                     WRITE(numsed,*) '    but hipor < 0, again for second time for jk = ', jk 
+!                     WRITE(numsed,*) ' We stop : STOP '
+                     STOP
+                  ENDIF
+               ELSE
+!                  WRITE(numsed,*) ' successfull convergence for level jk = ',jk,&
+!                     &               '  after iter =', jiter, ' iterations ;  res =',zresm  
+!                  WRITE(numsed,*) ' '
+                  itime = 0
+               ENDIF
+            ELSE
+               itime = itime + 1
+               WRITE(numsed,*) ' No convergence for jk = ', jk, ' after ', itime, '  try'            
+               IF ( itime == 1 ) THEN
+                  WRITE(numsed,*) ' try one more time with more iterations and higher relax. value'
+                  GOTO 10001
+               ELSE IF ( itime == 2 ) THEN
+                  WRITE(numsed,*) ' try one more time for with more iterations, higher relax. value'               
+                  WRITE(numsed,*) ' and with re-initialization of initial PH field ' 
+               ELSE       
+                  WRITE(numsed,*) ' No more... we stop '
+                  STOP
+               ENDIF
+            ENDIF
+         ENDIF
+     ENDDO
+
+   END SUBROUTINE sed_co3
+#else
+   !!======================================================================
+   !! MODULE sedco3  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_co3( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_co3: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_co3
+
+   !!======================================================================
+
+#endif
+
+END MODULE sedco3
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddsr.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddsr.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddsr.F90	(revision 1844)
@@ -0,0 +1,552 @@
+MODULE seddsr
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  seddsr  ***
+   !!    Sediment : dissolution and reaction in pore water
+   !!=====================================================================
+   !! * Modules used
+   USE sed     ! sediment global variable
+   USE sedmat  ! linear system of equations
+   USE sedco3  ! carbonate ion and proton concentration 
+
+   PUBLIC sed_dsr
+
+   !! * Module variables
+
+   REAL(wp), DIMENSION(:), PUBLIC, ALLOCATABLE :: &
+      cons_o2   , &
+      cons_no3  , &
+      sour_no3  , &
+      sour_c13
+
+    REAL(wp), DIMENSION(jpsol), PUBLIC :: &
+       dens_mol_wgt
+  
+CONTAINS
+   
+   SUBROUTINE sed_dsr( kt ) 
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_dsr  ***
+      !! 
+      !!  ** Purpose :  computes pore water dissolution and reaction
+      !!
+      !!  ** Methode :  implicit simultaneous computation of undersaturation
+      !!               resulting from diffusive pore water transport and chemical
+      !!               pore water reactions. Solid material is consumed according
+      !!               to redissolution and remineralisation
+      !!
+      !!  ** Remarks :
+      !!              - undersaturation : deviation from saturation concentration
+      !!              - reaction rate   : sink of undersaturation from dissolution
+      !!                                 of solid material 
+      !!
+      !!   History :
+      !!        !  98-08 (E. Maier-Reimer, Christoph Heinze )  Original code
+      !!        !  04-10 (N. Emprin, M. Gehlen ) f90
+      !!        !  06-04 (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      !! Arguments
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      ! --- local variables
+      INTEGER :: &
+         ji, jk, js, jw
+      
+      INTEGER  ::    &
+         nv                        ! number of variables in linear tridiagonal eq
+   
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: &
+         zrearat,  &            ! reaction rate in pore water
+         zundsat                ! undersaturation ; indice jpwatp1 is for calcite   
+     
+      REAL(wp), DIMENSION(:) , ALLOCATABLE :: &    ! temp. variables
+         zmo2_0 , zmo2_1 ,    &          ! mass balance calculation
+         zmno3_0, zmno3_1, zmno3_2,    &
+         zmc13_0, zmc13_1, zmc13_2, zmc13_3
+ 
+      REAL(wp), DIMENSION(:,:,:) , ALLOCATABLE :: &    ! temp. variables
+         zvolc
+
+      REAL(wp)  ::  &
+         zsolid1, zsolid2, zsolid3, &
+         zvolw, zreasat
+      
+      !!
+      !!----------------------------------------------------------------------
+
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' sed_dsr : Dissolution reaction '
+         WRITE(numsed,*) ' '
+         dens_mol_wgt(1:jpsol) = dens / mol_wgt(1:jpsol)
+
+         ALLOCATE( cons_o2 (jpoce) ) ;   ALLOCATE( cons_no3(jpoce) ) 
+         ALLOCATE( sour_no3(jpoce) ) ;   ALLOCATE( sour_c13(jpoce) )  
+    
+      ENDIF
+
+      ! Initialization of data for mass balance calculation
+      !---------------------------------------------------
+
+      tokbot(:,:)  = 0.
+      cons_o2 (:)  = 0. 
+      cons_no3(:)  = 0.  
+      sour_no3(:)  = 0.  
+      sour_c13(:)  = 0.       
+   
+      ! Initializations
+      !----------------------
+      ALLOCATE( zmo2_0 (jpoce) ) ;  ALLOCATE( zmo2_1 (jpoce) ) 
+      ALLOCATE( zmno3_0(jpoce) ) ;  ALLOCATE( zmno3_1(jpoce) )  ;  ALLOCATE( zmno3_2(jpoce) ) 
+      ALLOCATE( zmc13_0(jpoce) ) ;  ALLOCATE( zmc13_1(jpoce) )  ;  ALLOCATE( zmc13_2(jpoce) ) ;  ALLOCATE( zmc13_3(jpoce) ) 
+
+      zmo2_0 (:) = 0.  ; zmo2_1 (:) = 0.
+      zmno3_0(:) = 0.  ; zmno3_1(:) = 0.  ;  zmno3_2(:) = 0.
+      zmc13_0(:) = 0.  ; zmc13_1(:) = 0.  ;  zmc13_2(:) = 0.  ; zmc13_3(:) = 0.
+      
+      ALLOCATE( zrearat(jpoce,jpksed,3) ) ;  ALLOCATE( zundsat(jpoce,jpksed,3) )      
+      zrearat(:,:,:)   = 0.    ;   zundsat(:,:,:) = 0. 
+
+
+      ALLOCATE( zvolc(jpoce,jpksed,jpsol) ) 
+      zvolc(:,:,:)   = 0.
+
+      !--------------------------------------------------------------------
+      ! Temporary accomodation to take account of  particule rain deposition
+      !---------------------------------------------------------------------
+      
+      
+      ! 1. Change of geometry
+      !    Increase of dz3d(2) thickness : dz3d(2) = dz3d(2)+dzdep
+      !    Warning : no change for dz(2)
+      !---------------------------------------------------------
+      dz3d(1:jpoce,2) = dz3d(1:jpoce,2) + dzdep(1:jpoce)
+
+      
+      ! New values for volw3d(:,2) and vols3d(:,2)
+      ! Warning : no change neither for volw(2) nor  vols(2)
+      !------------------------------------------------------
+      volw3d(1:jpoce,2) = dz3d(1:jpoce,2) * por(2)
+      vols3d(1:jpoce,2) = dz3d(1:jpoce,2) * por1(2)
+
+      ! Conversion of volume units
+      !----------------------------
+      DO js = 1, jpsol
+         DO jk = 1, jpksed
+            DO ji = 1, jpoce    
+               zvolc(ji,jk,js) = ( vols3d(ji,jk) * dens_mol_wgt(js) ) /  &
+                  &              ( volw3d(ji,jk) * 1.e-3 )     
+            ENDDO
+         ENDDO
+      ENDDO
+
+      ! 2. Change of previous solid fractions (due to volum changes) for k=2
+      !---------------------------------------------------------------------
+
+      DO js = 1, jpsol
+         DO ji = 1, jpoce
+            solcp(ji,2,js) = solcp(ji,2,js) * dz(2) / dz3d(ji,2)
+         ENDDO
+      END DO
+
+      ! 3. New solid fractions (including solid rain fractions) for k=2  
+      !------------------------------------------------------------------   
+      DO js = 1, jpsol
+         DO ji = 1, jpoce
+            solcp(ji,2,js) = solcp(ji,2,js) + &
+            &           ( rainrg(ji,js) / raintg(ji) ) * ( dzdep(ji) / dz3d(ji,2) )
+            ! rainrm are temporary cancel
+            rainrm(ji,js) = 0.
+         END DO
+      ENDDO
+
+      ! 4.  Adjustment of bottom water concen.(pwcp(1)): 
+      !     We impose that pwcp(2) is constant. Including dzdep in dz3d(:,2) we assume 
+      !     that dzdep has got a porosity of por(2). So pore water volum of jk=2 increase.
+      !     To keep pwcp(2) cste we must compensate this "increase" by a slight adjusment
+      !     of bottom water concentration.
+      !     This adjustment is compensate at the end of routine
+      !-------------------------------------------------------------
+      DO jw = 1, jpwat
+         DO ji = 1, jpoce
+            pwcp(ji,1,jw) = pwcp(ji,1,jw) - &
+               &            pwcp(ji,2,jw) * dzdep(ji) * por(2) / dzkbot(ji)
+         END DO
+      ENDDO
+
+ 
+      !----------------------------------------------------------
+      ! 5.  Beginning of  Pore Water diffusion and solid reaction
+      !---------------------------------------------------------
+      
+      !-----------------------------------------------------------------------------
+      ! For jk=2,jpksed, and for couple 
+      !  1 : jwsil/jsopal  ( SI/Opal )
+      !  2 : jsclay/jsclay ( clay/clay ) 
+      !  3 : jwoxy/jspoc   ( O2/POC )
+      !  reaction rate is a function of solid=concentration in solid reactif in [mol/l] 
+      !  and undersaturation in [mol/l].
+      !  Solid weight fractions should be in ie [mol/l])
+      !  second member and solution are in zundsat variable
+      !-------------------------------------------------------------------------
+
+      !number of variables
+      nv  = 3
+     
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            ! For Silicic Acid and clay
+            zundsat(ji,jk,1) = sat_sil   - pwcp(ji,jk,jwsil)
+            zundsat(ji,jk,2) = sat_clay
+            ! For O2
+            zundsat(ji,jk,3) = pwcp(ji,jk,jwoxy) / so2ut 
+         ENDDO
+      ENDDO
+      
+      
+      ! Definition of reaction rates [rearat]=sans dim 
+      ! For jk=1 no reaction (pure water without solid) for each solid compo
+      DO ji = 1, jpoce
+         zrearat(ji,1,:) = 0.
+      ENDDO
+
+
+      ! left hand side of coefficient matrix
+      DO jk = 2, jpksed
+         DO ji = 1, jpoce
+            zsolid1 = zvolc(ji,jk,jsopal) * solcp(ji,jk,jsopal)
+            zsolid2 = zvolc(ji,jk,jsclay) * solcp(ji,jk,jsclay)
+            zsolid3 = zvolc(ji,jk,jspoc)  * solcp(ji,jk,jspoc)
+
+            zrearat(ji,jk,1)  = ( reac_sil * dtsed * zsolid1 ) / &
+               &                ( 1. + reac_sil * dtsed * zundsat(ji,jk,1 ) )
+            zrearat(ji,jk,2)  = ( reac_clay * dtsed * zsolid2 ) / &
+               &                ( 1. + reac_clay * dtsed * zundsat(ji,jk,2 ) )
+            zrearat(ji,jk,3)  = ( reac_poc  * dtsed * zsolid3 ) / &
+               &                ( 1. + reac_poc  * dtsed * zundsat(ji,jk,3 ) )
+         ENDDO
+      ENDDO
+
+
+      CALL sed_mat( nv, jpoce, jpksed, zrearat, zundsat )
+
+
+      ! New solid concentration values (jk=2 to jksed) for each couple 
+      DO js = 1, nv
+         DO jk = 2, jpksed
+            DO ji = 1, jpoce
+               zreasat = zrearat(ji,jk,js) * zundsat(ji,jk,js) / zvolc(ji,jk,js)
+               solcp(ji,jk,js) = solcp(ji,jk,js) - zreasat
+            ENDDO
+         ENDDO
+      ENDDO
+      ! mass of O2/NO3 before POC remin. for mass balance check 
+      ! det. of o2 consomation/NO3 production Mc13
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zvolw = volw3d(ji,jk) * 1.e-3
+            zmo2_0 (ji)  = zmo2_0 (ji) + pwcp(ji,jk,jwoxy) * zvolw
+            zmno3_0(ji)  = zmno3_0(ji) + pwcp(ji,jk,jwno3) * zvolw
+            zmc13_0(ji)  = zmc13_0(ji) + pwcp(ji,jk,jwc13) * zvolw
+         ENDDO
+      ENDDO
+
+      ! New pore water concentrations    
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            ! Acid Silicic 
+            pwcp(ji,jk,jwsil)  = sat_sil - zundsat(ji,jk,1)            
+            ! For O2 (in mol/l)
+            pwcp(ji,jk,jwoxy)  = zundsat(ji,jk,3) * so2ut 
+            zreasat = zrearat(ji,jk,3) * zundsat(ji,jk,3)    ! oxygen         
+            ! For DIC
+            pwcp(ji,jk,jwdic)  = pwcp(ji,jk,jwdic) + zreasat
+            ! For nitrates
+            pwcp(ji,jk,jwno3)  = pwcp(ji,jk,jwno3) + zreasat * srno3            
+            ! For Phosphate (in mol/l)
+            pwcp(ji,jk,jwpo4)  = pwcp(ji,jk,jwpo4) + zreasat * spo4r            
+            ! For alkalinity
+            pwcp(ji,jk,jwalk)  = pwcp(ji,jk,jwalk) - zreasat * ( srno3 + 2.* spo4r )           
+            ! For DIC13
+            pwcp(ji,jk,jwc13)  = pwcp(ji,jk,jwc13) + zreasat * rc13P * pdb
+         ENDDO
+      ENDDO
+
+
+      ! Mass of O2 for mass balance check and det. of o2 consomation
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zvolw = volw3d(ji,jk) * 1.e-3
+            zmo2_1 (ji) = zmo2_1 (ji) + pwcp(ji,jk,jwoxy) * zvolw
+            zmno3_1(ji) = zmno3_1(ji) + pwcp(ji,jk,jwno3) * zvolw
+            zmc13_1(ji) = zmc13_1(ji) + pwcp(ji,jk,jwc13) * zvolw
+         ENDDO
+      ENDDO
+
+      DO ji = 1, jpoce
+         cons_o2 (ji) = zmo2_0 (ji) - zmo2_1 (ji)
+         sour_no3(ji) = zmno3_1(ji) - zmno3_0(ji)     
+         sour_c13(ji) = zmc13_1(ji) - zmc13_0(ji) 
+      ENDDO
+ 
+
+      !--------------------------------------------------------------------
+      ! Begining POC denitrification and NO3- diffusion
+      ! (indice n°5 for couple POC/NO3- ie solcp(:,:,jspoc)/pwcp(:,:,jwno3))
+      !--------------------------------------------------------------------
+
+      nv = 1
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zundsat(ji,jk,1) = pwcp(ji,jk,jwno3) / srDnit
+         ENDDO
+      ENDDO
+      DO jk = 2, jpksed
+         DO ji = 1, jpoce
+            IF( pwcp(ji,jk,jwoxy) < sthrO2 ) THEN
+               zsolid1 = zvolc(ji,jk,jspoc) * solcp(ji,jk,jspoc)
+               zrearat(ji,jk,1) = ( reac_no3 * dtsed * zsolid1 ) / &
+                  &                    ( 1. + reac_no3 * dtsed * zundsat(ji,jk,1 ) )
+            ELSE
+               zrearat(ji,jk,1) = 0.
+            ENDIF
+         END DO
+      END DO
+
+
+      ! solves tridiagonal system
+      CALL sed_mat( nv, jpoce, jpksed, zrearat, zundsat )
+
+
+      ! New solid concentration values (jk=2 to jksed) for each couple 
+      DO jk = 2, jpksed
+         DO ji = 1, jpoce
+            zreasat = zrearat(ji,jk,1) * zundsat(ji,jk,1) / zvolc(ji,jk,jspoc)
+            solcp(ji,jk,jspoc) = solcp(ji,jk,jspoc) - zreasat
+         ENDDO
+      ENDDO
+
+      ! New dissolved concentrations
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zreasat = zrearat(ji,jk,1) * zundsat(ji,jk,1)    
+            ! For nitrates
+            pwcp(ji,jk,jwno3)  =  zundsat(ji,jk,1) * srDnit
+            ! For DIC
+            pwcp(ji,jk,jwdic)  = pwcp(ji,jk,jwdic) + zreasat
+            ! For Phosphate (in mol/l)
+            pwcp(ji,jk,jwpo4)  = pwcp(ji,jk,jwpo4) + zreasat * spo4r            
+            ! For alkalinity
+            pwcp(ji,jk,jwalk)  = pwcp(ji,jk,jwalk) + zreasat * ( srDnit - 2.* spo4r )           
+            ! For DIC13
+            pwcp(ji,jk,jwc13)  = pwcp(ji,jk,jwc13) + zreasat * rc13P * pdb
+         ENDDO
+      ENDDO
+
+
+      ! Mass of O2 for mass balance check and det. of o2 consomation
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zvolw = volw3d(ji,jk) * 1.e-3
+            zmno3_2(ji) = zmno3_2(ji) + pwcp(ji,jk ,jwno3) * zvolw
+            zmc13_2(ji) = zmc13_2(ji) + pwcp(ji,jk ,jwc13) * zvolw   
+         ENDDO
+      ENDDO
+
+      DO ji = 1, jpoce
+         cons_no3(ji) = zmno3_1(ji) - zmno3_2(ji)  
+         sour_c13(ji) = sour_c13(ji) + zmc13_2(ji) - zmc13_1(ji)     
+      ENDDO
+
+
+      !---------------------------
+      ! Solves PO4 diffusion 
+      !----------------------------
+
+      nv = 1
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zundsat(ji,jk,1) = pwcp(ji,jk,jwpo4)
+            zrearat(ji,jk,1) = 0.
+         ENDDO
+      ENDDO
+
+
+      ! solves tridiagonal system
+      CALL sed_mat( nv, jpoce, jpksed, zrearat, zundsat )
+
+
+      ! New undsaturation values and dissolved concentrations
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            pwcp(ji,jk,jwpo4) = zundsat(ji,jk,1)
+         ENDDO
+      ENDDO
+
+
+      !---------------------------------------------------------------
+      ! Performs CaCO3 particle deposition and redissolution (indice 9)
+      !--------------------------------------------------------------
+
+      ! computes co3por from the updated pwcp concentrations (note [co3por] = mol/l)
+
+      CALL sed_co3( kt )
+
+
+      nv = 1
+      ! *densSW(l)**2 converts aksps [mol2/kg sol2] into [mol2/l2] to get [undsat] in [mol/l]
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zundsat(ji,jk,1) = aksps(ji) * densSW(ji) * densSW(ji) / calcon2(ji) &
+               &                     - co3por(ji,jk)
+            ! positive values of undersaturation
+            zundsat(ji,jk,1) = MAX( 0., zundsat(ji,jk,1) )            
+         ENDDO
+      ENDDO
+
+      DO jk = 2, jpksed
+         DO ji = 1, jpoce
+            zsolid1 = zvolc(ji,jk,jscal) * solcp(ji,jk,jscal)
+            zrearat(ji,jk,1) = ( reac_cal * dtsed * zsolid1 ) / &
+                  &               ( 1. + reac_cal * dtsed * zundsat(ji,jk,1) )
+         END DO
+      END DO
+
+
+      ! solves tridiagonal system
+      CALL sed_mat( nv, jpoce, jpksed, zrearat, zundsat )
+
+
+      ! New solid concentration values (jk=2 to jksed) for cacO3
+      DO jk = 2, jpksed
+         DO ji = 1, jpoce
+            zreasat = zrearat(ji,jk,1) * zundsat(ji,jk,1) / zvolc(ji,jk,jscal)
+            solcp(ji,jk,jscal) = solcp(ji,jk,jscal) - zreasat
+         ENDDO
+      ENDDO
+
+      ! New dissolved concentrations
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zreasat = zrearat(ji,jk,1) * zundsat(ji,jk,1)    
+            ! For DIC
+            pwcp(ji,jk,jwdic)  = pwcp(ji,jk,jwdic) + zreasat
+            ! For alkalinity
+            pwcp(ji,jk,jwalk)  = pwcp(ji,jk,jwalk) + 2.* zreasat 
+            ! For DIC13
+            pwcp(ji,jk,jwc13)  = pwcp(ji,jk,jwc13) + zreasat * rc13Ca * pdb
+         ENDDO
+      ENDDO
+
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zmc13_3(ji) = zmc13_3(ji) + pwcp(ji,jk,jwc13) * volw3d(ji,jk) * 1.e-3                  
+         ENDDO
+      ENDDO
+
+      DO ji = 1, jpoce     
+         sour_c13(ji) = sour_c13(ji) + zmc13_3(ji) - zmc13_2(ji)   
+      ENDDO
+      
+      !-------------------------------------------------
+      ! Beginning DIC, Alkalinity and DIC13 diffusion
+      !-------------------------------------------------
+      
+      nv = 3
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce      
+            zundsat(ji,jk,1) = pwcp(ji,jk,jwdic)
+            zundsat(ji,jk,2) = pwcp(ji,jk,jwalk)
+            zundsat(ji,jk,3) = pwcp(ji,jk,jwc13)
+      
+            zrearat(ji,jk,1) = 0.
+            zrearat(ji,jk,2) = 0.
+            zrearat(ji,jk,3) = 0.
+      
+         ENDDO
+      ENDDO
+
+
+      ! solves tridiagonal system
+      CALL sed_mat( nv, jpoce, jpksed, zrearat, zundsat )
+
+
+      ! New dissolved concentrations      
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce                      
+            pwcp(ji,jk,jwdic) = zundsat(ji,jk,1)
+            pwcp(ji,jk,jwalk) = zundsat(ji,jk,2)
+            pwcp(ji,jk,jwc13) = zundsat(ji,jk,3)
+         ENDDO
+      ENDDO            
+      
+      !----------------------------------
+      !   Back to initial geometry
+      !-----------------------------
+      
+      !---------------------------------------------------------------------
+      !   1/ Compensation for ajustement of the bottom water concentrations
+      !      (see note n° 1 about *por(2))
+      !--------------------------------------------------------------------
+      DO jw = 1, jpwat
+         DO ji = 1, jpoce
+            pwcp(ji,1,jw) = pwcp(ji,1,jw) + &
+               &            pwcp(ji,2,jw) * dzdep(ji) * por(2) / dzkbot(ji)
+         END DO
+      ENDDO
+      
+      !-----------------------------------------------------------------------
+      !    2/ Det of new rainrg taking account of the new weight fraction obtained 
+      !      in dz3d(2) after diffusion/reaction (react/diffu are also in dzdep!)
+      !      This new rain (rgntg rm) will be used in advection/burial routine
+      !------------------------------------------------------------------------
+      DO js = 1, jpsol
+         DO ji = 1, jpoce
+            rainrg(ji,js) = raintg(ji) * solcp(ji,2,js)
+            rainrm(ji,js) = rainrg(ji,js) / mol_wgt(js)
+         END DO
+      ENDDO
+      
+      !  New raintg
+      raintg(:) = 0.
+      DO js = 1, jpsol
+         DO ji = 1, jpoce
+            raintg(ji) = raintg(ji) + rainrg(ji,js)
+         END DO
+      ENDDO
+      
+      !--------------------------------
+      !    3/ back to initial geometry
+      !--------------------------------
+      DO ji = 1, jpoce
+         dz3d  (ji,2) = dz(2)
+         volw3d(ji,2) = dz3d(ji,2) * por(2)
+         vols3d(ji,2) = dz3d(ji,2) * por1(2)
+      ENDDO
+      
+      !----------------------------------------------------------------------
+      !    4/ Saving new amount of material in dzkbot for mass balance check
+      !       tokbot in [mol] (implicit *1cm*1cm for spacial dim)
+      !----------------------------------------------------------------------
+      DO jw = 1, jpwat 
+         DO ji = 1, jpoce
+            tokbot(ji,jw) = pwcp(ji,1,jw) * 1.e-3 * dzkbot(ji)
+         END DO
+      ENDDO
+
+      DEALLOCATE( zmo2_0  ) ;  DEALLOCATE( zmno3_1 )  ;  DEALLOCATE( zmno3_2 ) 
+      DEALLOCATE( zmc13_0 ) ;  DEALLOCATE( zmc13_1 )  ;  DEALLOCATE( zmc13_2 ) ;  DEALLOCATE( zmc13_3 ) 
+      
+      DEALLOCATE( zrearat ) ;  DEALLOCATE( zundsat )  ;  DEALLOCATE( zvolc )   
+      
+   END SUBROUTINE sed_dsr
+#else
+   !!======================================================================
+   !! MODULE seddsr  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_dsr ( kt )
+     INTEGER, INTENT(in) :: kt
+     WRITE(*,*) 'sed_dsr: You should not have seen this print! error?', kt
+  END SUBROUTINE sed_dsr
+#endif
+   
+END MODULE seddsr
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddta.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddta.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/seddta.F90	(revision 1844)
@@ -0,0 +1,281 @@
+MODULE seddta
+   !!======================================================================
+   !!                     ***  MODULE  seddta  ***
+   !! Sediment data  :  read sediment input data from a file
+   !!=====================================================================
+#if defined key_sed
+   !! * Modules used
+   USE sed
+   USE sedarr
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC sed_dta   ! 
+
+   !! *  Module variables
+   REAL(wp), DIMENSION(:), ALLOCATABLE :: &
+      smask       ! mask for sediments points
+
+   REAL(wp) ::  &
+      rsecday  , &  ! number of second per a day
+      conv1    , &  ! [m/day]--->[cm/s]  
+      conv2         ! [kg/m2/month]-->[g/cm2/s] ( 1 month has 30 days )
+
+   INTEGER ::     &
+     numbio 
+
+#if defined key_sed_off
+   INTEGER ::     &
+     numoce
+#endif
+
+CONTAINS
+
+   !!---------------------------------------------------------------------------
+   !!   sed_dta  : read the NetCDF data file in online version using module iom
+   !!---------------------------------------------------------------------------
+
+   SUBROUTINE sed_dta( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_dta  ***
+      !!                    
+      !! ** Purpose :   Reads data from a netcdf file and 
+      !!                initialization of rain and pore water (k=1) components
+      !! 
+      !!
+      !!   History :
+      !!        !  04-10  (N. Emprin, M. Gehlen )  Original code
+      !!        !  06-04  (C. Ethe)  Re-organization ; Use of iom
+      !!----------------------------------------------------------------------
+
+      !! Arguments
+      INTEGER, INTENT(in) :: &
+         kt
+
+      !! * Local declarations
+      INTEGER  ::  ji, jj, js, jw, ikt
+
+      REAL(wp) , DIMENSION (jpi,jpj) :: zdta
+#if ! defined key_kriest
+      REAL(wp) , DIMENSION (:), ALLOCATABLE  :: zdtap , zdtag
+#endif 
+
+
+      !----------------------------------------------------------------------
+
+      ! Initialization of sediment variable 
+      ! Spatial dimension is merged, and unity converted if needed
+      !-------------------------------------------------------------
+
+      WRITE(numsed,*)
+      WRITE(numsed,*) ' sed_dta : Bottom layer fields'
+      WRITE(numsed,*) ' ~~~~~~'
+      WRITE(numsed,*) ' Data from SMS model'
+      WRITE(numsed,*)
+
+
+      ! open file
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' sed_dta : Sediment fields'
+         CALL iom_open ( 'data_bio_bot'     , numbio )
+#if defined key_sed_off
+         CALL iom_open( 'data_oce_bot', numoce)
+#endif
+         rsecday = 60.* 60. * 24.
+         conv1   = 1.0e+2 / rsecday 
+         conv2   = 1.0e+3 / ( 1.0e+4 * rsecday * 30. ) 
+
+         ! Compute sediment mask
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikt = MAX( INT( sbathy(ji,jj) ) - 1, 1 )
+               zdta(ji,jj) = tmask(ji,jj,ikt) 
+            ENDDO
+         ENDDO
+         ALLOCATE( smask(jpoce) )
+         smask(:) = 0.
+         CALL pack_arr( jpoce, smask(1:jpoce), zdta(1:jpi,1:jpj), iarroce(1:jpoce) )
+      ENDIF
+
+
+#if ! defined key_kriest   
+      ! Initialization of temporaries arrays  
+      ALLOCATE( zdtap   (jpoce) )    ;   zdtap(:)    = 0. 
+      ALLOCATE( zdtag   (jpoce) )    ;   zdtag(:)    = 0.  
+#endif
+
+
+      IF( MOD( kt - 1, nfreq ) == 0 ) THEN
+         ! reading variables
+         WRITE(numsed,*)
+         WRITE(numsed,*) ' sed_dta : Bottom layer fields at time  kt = ', kt
+         ! reading variables
+         trc_data(:,:,:) = 0.
+#if ! defined key_sed_off
+         DO jj = 1,jpj
+            DO ji = 1, jpi
+               ikt = MAX( mbathy(ji,jj)-1, 1 )
+               IF ( tmask(ji,jj,ikt) == 1 ) THEN
+                  trc_data(ji,jj,1)  = trn  (ji,jj,ikt,jptal)
+                  trc_data(ji,jj,2)  = trn  (ji,jj,ikt,jpdic)
+                  trc_data(ji,jj,3)  = trn  (ji,jj,ikt,jpno3) / 7.6
+                  trc_data(ji,jj,4)  = trn  (ji,jj,ikt,jppo4) / 122.
+                  trc_data(ji,jj,5)  = trn  (ji,jj,ikt,jpoxy)
+                  trc_data(ji,jj,6)  = trn  (ji,jj,ikt,jpsil)
+#   if ! defined key_kriest
+                  trc_data(ji,jj,7 ) = sinksil (ji,jj,ikt)
+                  trc_data(ji,jj,8 ) = sinking (ji,jj,ikt)
+                  trc_data(ji,jj,9 ) = sinking2(ji,jj,ikt)
+                  trc_data(ji,jj,10) = sinkcal (ji,jj,ikt)
+                  trc_data(ji,jj,11) = tn      (ji,jj,ikt)
+                  trc_data(ji,jj,12) = sn      (ji,jj,ikt)
+#   else
+                  trc_data(ji,jj,7 ) = sinksil (ji,jj,ikt)
+                  trc_data(ji,jj,8 ) = sinking (ji,jj,ikt)
+                  trc_data(ji,jj,9 ) = sinkcal (ji,jj,ikt)
+                  trc_data(ji,jj,10) = tn      (ji,jj,ikt)
+                  trc_data(ji,jj,11) = sn      (ji,jj,ikt)       
+#   endif
+               ENDIF
+            ENDDO
+         ENDDO
+
+#else
+         CALL iom_get( numbio, jpdom_data, 'ALKBOT'     , trc_data(:,:,1 ) )
+         CALL iom_get( numbio, jpdom_data, 'DICBOT'     , trc_data(:,:,2 ) )
+         CALL iom_get( numbio, jpdom_data, 'NO3BOT'     , trc_data(:,:,3 ) )
+         CALL iom_get( numbio, jpdom_data, 'PO4BOT'     , trc_data(:,:,4 ) )
+         CALL iom_get( numbio, jpdom_data, 'O2BOT'      , trc_data(:,:,5 ) )
+         CALL iom_get( numbio, jpdom_data, 'SIBOT'      , trc_data(:,:,6 ) )
+#   if ! defined key_kriest
+         CALL iom_get( numbio, jpdom_data, 'OPALFLXBOT' , trc_data(:,:,7 ) ) 
+         CALL iom_get( numbio, jpdom_data, 'POCFLXBOT'  , trc_data(:,:,8 ) ) 
+         CALL iom_get( numbio, jpdom_data, 'GOCFLXBOT'  , trc_data(:,:,9 ) ) 
+         CALL iom_get( numbio, jpdom_data, 'CACO3FLXBOT', trc_data(:,:,10) ) 
+         CALL iom_get( numoce, jpdom_data, 'TBOT'       , trc_data(:,:,11) ) 
+         CALL iom_get( numoce, jpdom_data, 'SBOT'       , trc_data(:,:,12) ) 
+#   else
+         CALL iom_get( numbio, jpdom_data, 'OPALFLXBOT' , trc_data(:,:,7 ) ) 
+         CALL iom_get( numbio, jpdom_data, 'POCFLXBOT'  , trc_data(:,:,8 ) ) 
+         CALL iom_get( numbio, jpdom_data, 'CACO3FLXBOT', trc_data(:,:,9 ) ) 
+         CALL iom_get( numoce, jpdom_data, 'TBOT'       , trc_data(:,:,10) ) 
+         CALL iom_get( numoce, jpdom_data, 'SBOT'       , trc_data(:,:,11) ) 
+#   endif
+#endif
+
+         ! Pore water initial concentration [mol/l] in  k=1
+         !-------------------------------------------------
+
+          ! Alkalinity ( 1 umol = 10-6equivalent )
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwalk), trc_data(1:jpi,1:jpj,1), iarroce(1:jpoce) )
+         ! DIC 
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwdic), trc_data(1:jpi,1:jpj,2), iarroce(1:jpoce) )
+         ! Nitrates (1 umol/l = 10-6 mol/l)
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwno3), trc_data(1:jpi,1:jpj,3), iarroce(1:jpoce) )
+         ! Phosphates (1 umol/l = 10-6 mol/l)
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwpo4), trc_data(1:jpi,1:jpj,4), iarroce(1:jpoce) )
+         ! Oxygen (1 umol/l = 10-6 mol/l)
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwoxy), trc_data(1:jpi,1:jpj,5), iarroce(1:jpoce) )        
+         ! Silicic Acid [mol.l-1]
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwsil), trc_data(1:jpi,1:jpj,6), iarroce(1:jpoce) )                  
+         ! DIC13 (mol/l)obtained from dc13 and DIC (12) and PDB 
+         CALL iom_get ( numbio,jpdom_data,'DC13',zdta(:,:) )
+         CALL pack_arr ( jpoce,  pwcp_dta(1:jpoce,jwc13), zdta(1:jpi,1:jpj), iarroce(1:jpoce) )
+         pwcp_dta(1:jpoce,jwc13) = pdb * ( pwcp_dta(1:jpoce,jwc13) * 1.0e-3 + 1.0 )  &
+            &                          *   pwcp_dta(1:jpoce,jwdic)         
+         
+         !  Solid components : 
+         !-----------------------
+#if ! defined key_kriest
+         !  Sinking fluxes for OPAL in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce, rainrm_dta(1:jpoce,jsopal), trc_data(1:jpi,1:jpj,7), iarroce(1:jpoce) ) 
+         rainrm_dta(1:jpoce,jsopal) = rainrm_dta(1:jpoce,jsopal) * 1e-4
+         !  Sinking fluxes for POC in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce, zdtap(1:jpoce), trc_data(1:jpi,1:jpj,8) , iarroce(1:jpoce) )      
+         CALL pack_arr ( jpoce, zdtag(1:jpoce), trc_data(1:jpi,1:jpj,9) , iarroce(1:jpoce) )
+         rainrm_dta(1:jpoce,jspoc) =   ( zdtap(1:jpoce) +  zdtag(1:jpoce) ) * 1e-4
+         !  Sinking fluxes for Calcite in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce,  rainrm_dta(1:jpoce,jscal), trc_data(1:jpi,1:jpj,10), iarroce(1:jpoce) )
+         rainrm_dta(1:jpoce,jscal) = rainrm_dta(1:jpoce,jscal) * 1e-4
+         ! vector temperature [°C] and salinity 
+         CALL pack_arr ( jpoce,  temp(1:jpoce), trc_data(1:jpi,1:jpj,11), iarroce(1:jpoce) )
+         CALL pack_arr ( jpoce,  salt(1:jpoce), trc_data(1:jpi,1:jpj,12), iarroce(1:jpoce) )
+#else
+         !  Sinking fluxes for OPAL in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce, rainrm_dta(1:jpoce,jsopal), trc_data(1:jpi,1:jpj,7), iarroce(1:jpoce) ) 
+         rainrm_dta(1:jpoce,jsopal) = rainrm_dta(1:jpoce,jsopal) * 1e-4
+         !  Sinking fluxes for POC in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce, rainrm_dta(1:jpoce,jspoc), trc_data(1:jpi,1:jpj,8) , iarroce(1:jpoce) )      
+         rainrm_dta(1:jpoce,jspoc) = rainrm_dta(1:jpoce,jspoc) * 1e-4
+         !  Sinking fluxes for Calcite in mol.m-2.s-1 ; conversion in mol.cm-2.s-1
+         CALL pack_arr ( jpoce,  rainrm_dta(1:jpoce,jscal), trc_data(1:jpi,1:jpj,9), iarroce(1:jpoce) )
+         rainrm_dta(1:jpoce,jscal) = rainrm_dta(1:jpoce,jscal) * 1e-4
+         ! vector temperature [°C] and salinity 
+         CALL pack_arr ( jpoce,  temp(1:jpoce), trc_data(1:jpi,1:jpj,10), iarroce(1:jpoce) )
+         CALL pack_arr ( jpoce,  salt(1:jpoce), trc_data(1:jpi,1:jpj,11), iarroce(1:jpoce) )
+
+#endif
+        
+         ! Clay rain rate in [mol/(cm**2.s)] 
+         ! inputs data in [kg.m-2.mois-1] ---> 1e+3/(1e+4*60*24*60*60) [g.cm-2.s-1]   
+         ! divided after by molecular weight g.mol-1      
+         zdta(:,:)   = 0.
+         CALL iom_get( numbio, jpdom_data, 'CLAY', zdta(:,:) ) 
+         CALL pack_arr ( jpoce, rainrm_dta(1:jpoce,jsclay) , zdta(1:jpi,1:jpj), iarroce(1:jpoce) )      
+         rainrm_dta(1:jpoce,jsclay) = rainrm_dta(1:jpoce,jsclay) * conv2 / mol_wgt(jsclay)
+
+      ENDIF
+
+      ! sediment pore water at 1st layer (k=1)
+      DO jw = 1, jpwat
+         pwcp(1:jpoce,1,jw) = pwcp_dta(1:jpoce,jw) * smask(1:jpoce)
+      ENDDO
+
+      !  rain
+      DO js = 1, jpsol
+         rainrm(1:jpoce,js) = rainrm_dta(1:jpoce,js) * smask(1:jpoce)
+      ENDDO
+
+      ! Calculation of raintg of each sol. comp.: rainrm in [g/(cm**2.s)]
+      DO js = 1, jpsol
+         rainrg(1:jpoce,js) = rainrm(1:jpoce,js) *  mol_wgt(js)
+      ENDDO
+
+      ! Calculation of raintg = total massic flux rained in each cell (sum of sol. comp.)
+      raintg(:) = 0.
+      DO js = 1, jpsol
+         raintg(1:jpoce) = raintg(1:jpoce) + rainrg(1:jpoce,js)
+      ENDDO
+
+      ! computation of dzdep = total thickness of solid material rained [cm] in each cell
+      dzdep(1:jpoce) = raintg(1:jpoce) * rdtsed(2) 
+
+
+#if ! defined key_kriest
+      DEALLOCATE( zdtap    ) ;  DEALLOCATE( zdtag    ) 
+#endif      
+
+      IF( kt == nitsedend )   THEN
+         CALL iom_close ( numbio )
+#if defined key_sed_off
+         CALL iom_close ( numoce )
+#endif
+      ENDIF
+      
+   END SUBROUTINE sed_dta
+
+#else
+   !!======================================================================
+   !! MODULE seddta  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_dta ( kt )
+     INTEGER, INTENT(in) :: kt
+     WRITE(*,*) 'sed_stp: You should not have seen this print! error?', kt 
+  END SUBROUTINE sed_dta
+#endif
+
+END MODULE seddta
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedini.F90	(revision 1844)
@@ -0,0 +1,860 @@
+MODULE sedini
+   !!======================================================================
+   !!              ***  MODULE  sedini  ***
+   !! Sediment : define sediment variables
+   !!=====================================================================
+#if defined key_sed
+
+   !!----------------------------------------------------------------------
+   !!   sed_init    : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE sed     ! sediment global variable
+   USE seddta
+   USE sedrst
+   USE sedco3
+   USE sedchem
+   USE sedarr
+   USE iom
+   USE in_out_manager  ! I/O manager
+
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! Module variables
+   REAL(wp)    ::  &
+      sisat   =  800.  ,  &  !: saturation for si    [ mol.l-1]
+      claysat =    0.  ,  &  !: saturation for clay  [ mol.l-1]
+      rcopal  =   40.  ,  &  !: reactivity for si    [l.mol-1.an-1]
+      rcclay  =    0.  ,  &  !: reactivity for clay  [l.mol-1.an-1]
+      dcoef   =  8.e-6       !: diffusion coefficient (*por)   [cm**2/s]
+
+   REAL(wp)    ::  &
+      redO2   =  172.  ,  &  !: Redfield coef for Oxygene
+      redNo3  =   16.  ,  &  !: Redfield coef for Nitrates
+      redPo4  =    1.  ,  &  !: Redfield coef for Phosphates
+      redC    =  122.  ,  &  !: Redfield coef for Carbone
+      redDnit =  97.6  ,  &  !: Redfield coef for denitrification    
+      rcorg   =   50.  ,  &  !: reactivity for POC/O2 [l.mol-1.an-1]    
+      o2seuil =    1.  ,  &  !: threshold O2 concentration for [mol.l-1]     
+      rcorgN  =   50.       !: reactivity for POC/No3 [l.mol-1.an-1]
+
+   REAL(wp)    ::  &
+      rccal   = 1000.        !: reactivity for calcite         [l.mol-1.an-1]
+
+   REAL(wp)    ::  &
+      dbiot   = 15.          !: coefficient for bioturbation    [cm**2.(1000an-1)]
+
+   LOGICAL     :: &
+      ln_rst_sed = .TRUE.    !: initialisation from a restart file or not
+
+   REAL(wp)    ::  &
+      ryear = 365. * 24. * 3600. !:  1 year converted in second
+
+   !! *  Routine accessibility
+   PUBLIC sed_init          ! routine called by opa.F90
+
+CONTAINS
+
+
+   SUBROUTINE sed_init
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_init  ***
+      !!
+      !! ** Purpose :  Initialization of sediment module
+      !!               - Reading namelist
+      !!               - Read the deepest water layer thickness
+      !!                 ( using as mask ) in Netcdf file
+      !!               - Convert unity if necessary
+      !!               - sets initial sediment composition
+      !!                 ( only clay or reading restart file )
+      !!               - sets sediment grid, porosity and others constants
+      !!
+      !!   History :
+      !!        !  04-10  (N. Emprin, M. Gehlen )  Original code
+      !!        !  06-07  (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      INTEGER :: ji, jj, ikt
+#if defined key_sed_off
+      INTEGER  :: numblt         
+      INTEGER  :: nummsh   
+      REAL(wp) , DIMENSION(jpi,jpj) :: zdta
+#endif
+      !!----------------------------------------------------------------------
+
+
+      ! Reading namelist.sed variables
+      !---------------------------------------
+
+      CALL ctl_opn( numsed, 'sediment.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+
+      WRITE(numsed,*)
+      WRITE(numsed,*) '                 L S C E - C E A'
+      WRITE(numsed,*) '                 SEDIMENT model'
+      WRITE(numsed,*) '                version 2.0  (2007) '
+      WRITE(numsed,*)
+      WRITE(numsed,*)
+
+    
+      WRITE(numsed,*) ' sed_init : Initialization of sediment module  '
+      WRITE(numsed,*) ' '
+
+      ! Determination of sediments number of points and allocate global variables
+#if defined key_sed_off
+      ! Reading Netcdf Pisces file for deepest water layer thickness [m]
+      ! This data will be used as mask to merdge space in 1D vector
+      !----------------------------------------------------------------
+
+      CALL iom_open ( 'mesh_mask'  , nummsh )   
+      CALL iom_open ( 'e3tbot'     , numblt )
+
+      ! mask sediment points for outputs
+      CALL iom_get( nummsh, jpdom_data, 'tmask' , tmask )
+      CALL iom_get( nummsh, jpdom_data, 'mbathy', sbathy )
+      
+      ! longitude/latitude values
+      CALL iom_get ( nummsh, jpdom_data,'nav_lon', glamt(:,:) )
+      CALL iom_get ( nummsh, jpdom_data,'nav_lat', gphit(:,:) )
+    
+      ! bottom layer thickness
+      CALL iom_get  ( numblt, jpdom_data, 'E3TBOT', zdta(:,:) )
+      epkbot(:,:) = 0.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( INT( sbathy(ji,jj) )  - 1, 1 )
+            IF( tmask(ji,jj,ikt) == 1 ) epkbot(ji,jj) = zdta(ji,jj)
+         ENDDO
+      ENDDO
+
+      CALL iom_close( nummsh )  
+      CALL iom_close( numblt ) 
+#else
+
+      epkbot(:,:) = 0.
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj) - 1, 1 )
+            IF( tmask(ji,jj,ikt) == 1 ) epkbot(ji,jj) = e3t_0(ikt)
+         ENDDO
+      ENDDO
+#endif     
+
+
+      ! computation of total number of ocean points
+      !--------------------------------------------
+      jpoce  = COUNT( epkbot(:,:) > 0. )
+
+
+      ! Allocate memory size of global variables
+      ALLOCATE( pwcp (jpoce,jpksed,jpwat) )  ;  ALLOCATE( pwcp0 (jpoce,jpksed,jpwat) ) ;  ALLOCATE( pwcp_dta  (jpoce,jpwat) )
+      ALLOCATE( solcp(jpoce,jpksed,jpsol) )  ;  ALLOCATE( solcp0(jpoce,jpksed,jpsol) ) ;  ALLOCATE( rainrm_dta(jpoce,jpsol) )
+      ALLOCATE( rainrm(jpoce,jpsol) )        ;  ALLOCATE( rainrg(jpoce,jpsol) )        ;  ALLOCATE( raintg(jpoce) ) 
+      ALLOCATE( dzdep(jpoce) )               ;  ALLOCATE( iarroce(jpoce) )             ;  ALLOCATE( dzkbot(jpoce) )
+      ALLOCATE( temp(jpoce) )                ;  ALLOCATE( salt(jpoce) )                
+      ALLOCATE( press(jpoce) )               ;  ALLOCATE( densSW(jpoce) ) 
+      ALLOCATE( hipor(jpoce,jpksed) )        ;  ALLOCATE( co3por(jpoce,jpksed) ) 
+      ALLOCATE( dz3d(jpoce,jpksed) )         ;  ALLOCATE( volw3d(jpoce,jpksed) )       ;  ALLOCATE( vols3d(jpoce,jpksed) )
+
+      ! Initialization of global variables
+      pwcp  (:,:,:) = 0.  ;  pwcp0 (:,:,:) = 0.  ; pwcp_dta  (:,:) = 0.  
+      solcp (:,:,:) = 0.  ;  solcp0(:,:,:) = 0.  ; rainrm_dta(:,:) = 0.
+      rainrm(:,:  ) = 0.  ;  rainrg(:,:  ) = 0.  ; raintg    (:  ) = 0. 
+      dzdep (:    ) = 0.  ;  iarroce(:   ) = 0   ; dzkbot    (:  ) = 0.
+      temp  (:    ) = 0.  ;  salt   (:   ) = 0.  
+      press (:    ) = 0.  ;  densSW (:   ) = 0. 
+      hipor (:,:  ) = 0.  ;  co3por (:,: ) = 0.  
+      dz3d  (:,:  ) = 0.  ;  volw3d (:,: ) = 0.  ;  vols3d   (:,:) = 0. 
+
+      ! Chemical variables      
+      ALLOCATE( akbs  (jpoce) )  ;  ALLOCATE( ak1s   (jpoce) )  ;  ALLOCATE( ak2s  (jpoce) ) ;  ALLOCATE( akws  (jpoce) )     
+      ALLOCATE( ak1ps (jpoce) )  ;  ALLOCATE( ak2ps  (jpoce) )  ;  ALLOCATE( ak3ps (jpoce) ) ;  ALLOCATE( aksis (jpoce) )    
+      ALLOCATE( aksps (jpoce) )  ;  ALLOCATE( ak12s  (jpoce) )  ;  ALLOCATE( ak12ps(jpoce) ) ;  ALLOCATE( ak123ps(jpoce) )    
+      ALLOCATE( borats(jpoce) )  ;  ALLOCATE( calcon2(jpoce) )    
+
+      akbs  (:) = 0. ;   ak1s   (:) = 0. ;  ak2s  (:) = 0. ;   akws   (:) = 0.
+      ak1ps (:) = 0. ;   ak2ps  (:) = 0. ;  ak3ps (:) = 0. ;   aksis  (:) = 0.
+      aksps (:) = 0. ;   ak12s  (:) = 0. ;  ak12ps(:) = 0. ;   ak123ps(:) = 0.
+      borats(:) = 0. ;   calcon2(:) = 0.
+
+      ! Mass balance calculation  
+      ALLOCATE( fromsed(jpoce, jpsol) ) ; ALLOCATE( tosed(jpoce, jpsol) ) ;  ALLOCATE( rloss(jpoce, jpsol) )
+      ALLOCATE( tokbot (jpoce, jpwat) ) 
+
+      fromsed(:,:) = 0.    ;   tosed(:,:) = 0. ;  rloss(:,:) = 0.  ;   tokbot(:,:) = 0. 
+
+      ! Read sediment Namelist
+      !-------------------------
+      CALL sed_init_nam
+    
+      ! Initialization of sediment geometry
+      !------------------------------------
+      CALL sed_init_geom
+
+
+      ! sets initial sediment composition
+      ! ( only clay or reading restart file )
+      !---------------------------------------
+      CALL sed_init_data
+
+
+      CALL sed_init_wri
+
+
+   END SUBROUTINE sed_init
+
+
+   SUBROUTINE sed_init_geom
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_init_geom  ***
+      !!
+      !! ** Purpose :  Initialization of sediment geometry
+      !!               - Read the deepest water layer thickness
+      !!                 ( using as mask ) in Netcdf file
+      !!               - sets sediment grid, porosity and molecular weight
+      !!                 and others constants
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  Original
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      !! * local declarations
+      INTEGER ::  &
+        ji, jj, jk
+ 
+#if defined key_sed_off
+      REAL(wp) , DIMENSION (jpi,jpj) :: zdta
+      INTEGER  ::  numpres
+#endif
+      !---------------------------------------------------------- 
+
+      WRITE(numsed,*) ' sed_init_geom : Initialization of sediment geometry '
+      WRITE(numsed,*) ' '
+
+      ! Computation of 1D array of sediments points
+      indoce = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF (  epkbot(ji,jj) > 0. ) THEN
+               indoce          = indoce + 1
+               iarroce(indoce) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+
+      IF( indoce .NE. jpoce ) THEN
+         WRITE(numsed,*) ' '
+         WRITE(numsed,*) 'Warning : number of ocean points indoce = ', indoce, &
+            &     ' doesn''t match  number of point where epkbot>0  jpoce = ', jpoce
+         WRITE(numsed,*) ' '
+         WRITE(numsed,*) ' '
+         STOP
+      ELSE
+         WRITE(numsed,*) ' '
+         WRITE(numsed,*) ' total number of ocean points jpoce =  ',jpoce
+         WRITE(numsed,*) ' '
+      ENDIF
+
+#if defined key_sed_off
+
+      ! Reading Netcdf Pisces file for deepest water layer thickness [m]
+      ! This data will be used as mask to merdge space in 1D vector
+      !----------------------------------------------------------------
+      CALL iom_open ( 'pressbot'   , numpres )
+      
+      ! pressure  in  bars      
+      CALL iom_get ( numpres, jpdom_data,'BATH', zdta(:,:) )
+      CALL pack_arr ( jpoce, press(1:jpoce), zdta(1:jpi,1:jpj), iarroce(1:jpoce) )
+      press(1:jpoce) = press(1:jpoce) * 1.025e-1 
+
+      CALL iom_close ( numpres )
+#endif
+
+
+      ! mask sediment points for outputs
+      DO jk = 1, jpksed
+         tmasksed(:,:,jk) = tmask(:,:,1)
+      ENDDO
+
+      ! initialization of dzkbot in [cm]
+      !------------------------------------------------    
+      CALL pack_arr ( jpoce, dzkbot(1:jpoce), epkbot(1:jpi,1:jpj), iarroce(1:jpoce) )
+      dzkbot(1:jpoce) = dzkbot(1:jpoce) * 1.e+2 
+
+      ! Geometry and  constants 
+      ! sediment layer thickness [cm]
+      ! (1st layer= diffusive layer = pur water) 
+      !------------------------------------------
+      dz(1)  = 0.1
+      dz(2)  = 0.3
+      dz(3)  = 0.3
+      dz(4)  = 0.5
+      dz(5)  = 0.5
+      dz(6)  = 0.5
+      dz(7)  = 1.
+      dz(8)  = 1.
+      dz(9)  = 1.
+      dz(10) = 2.45
+      dz(11) = 2.45
+
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            dz3d(ji,jk) = dz(jk)
+         END DO
+      ENDDO
+
+      ! Depth(jk)= depth of middle of each layer
+      !----------------------------------------
+      profsed(1) = -dz(1)/ 2.
+      DO jk = 2, jpksed
+         profsed(jk) = profsed(jk-1) + dz(jk-1) / 2. + dz(jk) / 2.
+      ENDDO
+
+      !  Porosity profile [0]
+      !---------------------
+      por(1)  = 1.
+      por(2)  = 0.95
+      por(3)  = 0.9
+      por(4)  = 0.85
+      por(5)  = 0.81
+      por(6)  = 0.75
+      por(7)  = 0.75      
+      por(8)  = 0.75      
+      por(9)  = 0.75      
+      por(10) = 0.75
+      por(11) = 0.75
+ 
+      ! inverse of  Porosity profile
+      !-----------------------------
+      por1(:) = 1. - por(:)
+
+      ! Volumes of pore water and solid fractions (vector and array)
+      !     WARNING : volw(1) and vols(1) are sublayer volums
+      volw(:) = dz(:) * por(:)
+      vols(:) = dz(:) * por1(:)
+
+      ! temporary new value for dz3d(:,1) 
+      dz3d(1:jpoce,1) = dzkbot(1:jpoce)
+
+      ! WARNING : volw3d(:,1) and vols3d(:,1) are deepest water column volums
+      DO jk = 1, jpksed
+         volw3d(1:jpoce,jk) = dz3d(1:jpoce,jk) * por (jk)
+         vols3d(1:jpoce,jk) = dz3d(1:jpoce,jk) * por1(jk)
+      ENDDO
+
+      ! Back to the old sublayer vlaue for dz3d(:,1)
+      dz3d(1:jpoce,1) = dz(1)
+
+
+      !---------------------------------------------
+      ! Molecular weight [g/mol] for solid species
+      !---------------------------------------------
+
+
+      ! opal=sio2*0.4(h20)=28+2*16+0.4*(2+16)
+      !---------------------------------------
+      mol_wgt(jsopal) = 28. + 2. * 16. + 0.4 * ( 2. + 16. )  
+
+      !  clay
+      !  some kind of Illit (according to Pape)
+      !  K0.58(Al 1.38 Fe(III)0.37Fe(II)0.04Mg0.34)[(OH)2|(Si3.41Al0.59)O10]
+      !--------------------------------------------------------------------
+      mol_wgt(jsclay) = 0.58 * 39. + 1.38 * 27. + ( 0.37 + 0.04 ) * 56.+ &
+         &              0.34 * 24. + 2. * ( 16. + 1. ) + 3.41 * 38. +    &
+         &              0.59 * 27. + 10. * 16.
+
+      ! for chemistry Poc : C(122)H(244)O(86)N(16)P(1)
+      ! But den sity of Poc is an Hydrated material (= POC + 30H2O)
+      ! So C(122)H(355)O(120)N(16)P(1)
+      !------------------------------------------------------------
+      mol_wgt(jspoc) = ( 122. * 12. + 355. + 120. * 16.+ &
+         &                16. * 14. + 31. ) / 122.
+
+      ! CaCO3
+      !---------
+      mol_wgt(jscal) = 40. + 12. + 3. * 16.
+
+      ! Density of solid material in sediment [g/cm**3]
+      !------------------------------------------------
+      dens = 2.6
+
+      ! Initialization of diffusion coefficient as function of porosity [cm**2/s]
+      !--------------------------------------------------------------------
+      diff(:) = dcoef * por(:)
+
+
+      ! Initialization of time step as function of porosity [cm**2/s]
+      !------------------------------------------------------------------
+      rdtsed(2:jpksed) = dtsed / ( dens * por1(2:jpksed) )
+     
+   END SUBROUTINE sed_init_geom
+
+   SUBROUTINE sed_init_nam
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_init_nam  ***
+      !!
+      !! ** Purpose :  Initialization of sediment geometry
+      !!               - Reading namelist and defines constants variables
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  Original
+      !!----------------------------------------------------------------------
+
+      INTEGER :: &
+         numnamsed = 28
+
+      TYPE PSED
+         CHARACTER(len = 20)  :: snamesed   !: short name
+         CHARACTER(len = 80 ) :: lnamesed   !: long name
+         CHARACTER(len = 20 ) :: unitsed    !: unit
+      END TYPE PSED
+
+      TYPE(PSED) , DIMENSION(jpsol     ) :: sedsol
+      TYPE(PSED) , DIMENSION(jpwat     ) :: sedwat
+      TYPE(PSED) , DIMENSION(jpdia3dsed) :: seddiag3d
+      TYPE(PSED) , DIMENSION(jpdia2dsed) :: seddiag2d
+
+      NAMELIST/nam_time/nfreq
+      NAMELIST/nam_trased/sedsol, sedwat
+      NAMELIST/nam_diased/seddiag3d, seddiag2d
+      NAMELIST/nam_reac/sisat, claysat, rcopal, rcclay, dcoef 
+      NAMELIST/nam_poc/redO2, redNo3, redPo4, redC, redDnit, &
+         &           rcorg, o2seuil, rcorgN
+      NAMELIST/nam_cal/rccal
+      NAMELIST/nam_dc13/pdb, rc13P, rc13Ca
+      NAMELIST/nam_btb/dbiot
+      NAMELIST/nam_rst/ln_rst_sed
+
+      INTEGER :: jn, jn1
+      !-------------------------------------------------------
+
+      WRITE(numsed,*) ' sed_init_nam : Read namelists '
+      WRITE(numsed,*) ' '
+
+      ! ryear = 1 year converted in second
+      !------------------------------------
+      WRITE(numsed,*) ' '
+      WRITE(numsed,*) 'number of seconds in one year : ryear = ', ryear
+      WRITE(numsed,*) ' '     
+
+      ! Reading namelist.sed variables
+      !---------------------------------
+      CALL ctl_opn( numnamsed, 'namelist.sediment', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+
+      dtsed = rdt
+#if ! defined key_sed_off
+      nitsed000 = nittrc000
+      nitsedend = nitend
+      nwrised   = nwritetrc
+#else
+      nitsed000 = nit000
+      nitsedend = nitend
+      nwrised   = nwrite
+#endif
+     ! Diffraction/reaction parameters
+      !----------------------------------
+      READ( numnamsed, nam_time )
+      WRITE(numsed,*) ' namelist nam_time'
+
+#if ! defined key_sed_off
+      nfreq     = 1
+#endif
+
+      WRITE(numsed,*) ' sedimentation time step              dtsed      = ', dtsed
+      WRITE(numsed,*) ' 1st time step for sediment.          nitsed000  = ', nitsed000
+      WRITE(numsed,*) ' last time step for sediment.         nitsedend  = ', nitsedend
+      WRITE(numsed,*) ' frequency of sediment outputs        nwrised    = ', nwrised
+      WRITE(numsed,*) ' frequency of restoring inputs data   nfreq      = ', nfreq
+      WRITE(numsed,*) ' '
+
+      REWIND( numnamsed )               ! read nattrc
+      READ  ( numnamsed, nam_trased )
+
+      DO jn = 1, jpsol
+         sedtrcd(jn) = sedsol(jn)%snamesed
+         sedtrcl(jn) = sedsol(jn)%lnamesed
+         sedtrcu(jn) = sedsol(jn)%unitsed
+      END DO
+
+      DO jn = 1, jpwat
+         jn1 = jn + jpsol
+         sedtrcd(jn1) = sedwat(jn)%snamesed
+         sedtrcl(jn1) = sedwat(jn)%lnamesed
+         sedtrcu(jn1) = sedwat(jn)%unitsed
+      END DO
+
+      WRITE(numsed,*) ' namelist nam_trased'
+      WRITE(numsed,*) ' '
+      DO jn = 1, jptrased
+         WRITE(numsed,*) 'name of 3d output sediment field number :',jn,' : ',TRIM(sedtrcd(jn))
+         WRITE(numsed,*) 'long name ', TRIM(sedtrcl(jn))
+         WRITE(numsed,*) ' in unit = ', TRIM(sedtrcu(jn))
+         WRITE(numsed,*) ' '
+      END DO
+      WRITE(numsed,*) ' '
+
+      
+      REWIND( numnamsed )
+      READ( numnamsed, nam_diased )
+
+      DO jn = 1, jpdia3dsed
+         seddia3d(jn) = seddiag3d(jn)%snamesed
+         seddia3l(jn) = seddiag3d(jn)%lnamesed
+         seddia3u(jn) = seddiag3d(jn)%unitsed
+      END DO
+
+      DO jn = 1, jpdia2dsed
+         seddia2d(jn) = seddiag2d(jn)%snamesed
+         seddia2l(jn) = seddiag2d(jn)%lnamesed
+         seddia2u(jn) = seddiag2d(jn)%unitsed
+      END DO
+
+      WRITE(numsed,*) ' namelist nam_diased'
+      WRITE(numsed,*) ' '
+      DO jn = 1, jpdia3dsed
+         WRITE(numsed,*) 'name of 3D output diag number :',jn, ' : ', TRIM(seddia3d(jn))
+         WRITE(numsed,*) 'long name ', TRIM(seddia3l(jn))
+         WRITE(numsed,*) ' in unit = ',TRIM(seddia3u(jn))
+         WRITE(numsed,*) ' '
+      END DO
+
+      DO jn = 1, jpdia2dsed
+         WRITE(numsed,*) 'name of 2D output diag number :',jn, ' : ', TRIM(seddia2d(jn))
+         WRITE(numsed,*) 'long name ', TRIM(seddia2l(jn))
+         WRITE(numsed,*) ' in unit = ',TRIM(seddia2u(jn))
+         WRITE(numsed,*) ' '
+      END DO
+
+      WRITE(numsed,*) ' '
+
+
+      ! Diffraction/reaction parameters
+      !----------------------------------
+      REWIND( numnamsed )
+      READ( numnamsed, nam_reac )
+      WRITE(numsed,*) ' namelist nam_reac'
+      WRITE(numsed,*) ' saturation for si    sisat   = ', sisat
+      WRITE(numsed,*) ' saturation for clay  claysat = ', claysat
+      WRITE(numsed,*) ' reactivity for Si    rcopal  = ', rcopal
+      WRITE(numsed,*) ' reactivity for clay  rcclay  = ', rcclay
+      WRITE(numsed,*) ' diff. coef for por.  dcoef   = ', dcoef
+      WRITE(numsed,*) ' '
+
+
+      ! Unity conversion to get saturation conc. psat in [mol.l-1]
+      ! and reactivity rc in  [l.mol-1.s-1]
+      !----------------------------------------------------------
+      sat_sil   = sisat   * 1.e-6   
+      sat_clay  = claysat * 1.e-6
+
+      reac_sil  = rcopal / ryear     
+      reac_clay  = rcclay / ryear
+
+
+      ! Additional parameter linked to POC/O2/No3/Po4
+      !----------------------------------------------
+      REWIND( numnamsed )
+      READ( numnamsed, nam_poc )
+      WRITE(numsed,*) ' namelist nam_poc'
+      WRITE(numsed,*) ' Redfield coef for oxy     redO2   = ', redO2
+      WRITE(numsed,*) ' Redfield coef for no3     redNo3  = ', redNo3
+      WRITE(numsed,*) ' Redfield coef for po4     redPo4  = ', redPo4
+      WRITE(numsed,*) ' Redfield coef for carbone redC    = ', redC
+      WRITE(numsed,*) ' Redfield coef for denitri redDnit = ', redDnit
+      WRITE(numsed,*) ' reactivity for POC/O2     rcorg   = ', rcorg
+      WRITE(numsed,*) ' threshold O2 concen.      o2seuil = ', o2seuil
+      WRITE(numsed,*) ' reactivity for POC/NO3    rcorgN  = ', rcorgN
+      WRITE(numsed,*) ' '
+
+
+      so2ut  = redO2   / redC
+      srno3  = redNo3  / redC
+      spo4r  = redPo4  / redC
+      srDnit = redDnit / redC
+      sthro2 = o2seuil * 1.e-6 ! threshold O2 concen. in [mol.l-1]
+      ! reactivity rc in  [l.mol-1.s-1]
+      reac_poc  = rcorg / ryear
+      reac_no3 = rcorgN  / ryear
+
+
+      ! Carbonate parameters
+      !---------------------
+      READ( numnamsed, nam_cal )
+      WRITE(numsed,*) ' namelist  nam_cal'
+      WRITE(numsed,*) ' reactivity for calcite rccal = ', rccal
+      WRITE(numsed,*) ' '
+
+      ! reactivity rc in  [l.mol-1.s-1]      
+      reac_cal = rccal / ryear
+
+
+      ! C13  parameters
+      !----------------
+      READ( numnamsed, nam_dc13 )
+      WRITE(numsed,*) ' namelist nam_dc13 ' 
+      WRITE(numsed,*) ' 13C/12C in PD Belemnite        PDB    = ', pdb
+      WRITE(numsed,*) ' 13C/12C in POC = rc13P*PDB     rc13P  = ', rc13P
+      WRITE(numsed,*) ' 13C/12C in CaCO3 = rc13Ca*PDB  rc13Ca = ', rc13Ca
+      WRITE(numsed,*) ' '
+
+      
+      ! Bioturbation parameter
+      !------------------------
+      READ( numnamsed, nam_btb )
+      WRITE(numsed,*) ' namelist nam_btb ' 
+      WRITE(numsed,*) ' coefficient for bioturbation   dbiot    = ', dbiot
+      WRITE(numsed,*) ' '
+
+      ! Unity convertion to get bioturb coefficient in [cm2.s-1]
+      db = dbiot / ( ryear * 1000. )
+
+      ! Initial value (t=0) for sediment pore water and solid components
+      !----------------------------------------------------------------
+      READ( numnamsed, nam_rst )
+      WRITE(numsed,*) ' namelist  nam_rst ' 
+      WRITE(numsed,*) '  boolean term for restart (T or F) ln_rst_sed = ', ln_rst_sed 
+      WRITE(numsed,*) ' '
+
+      CLOSE( numnamsed )
+
+   END SUBROUTINE sed_init_nam
+
+   SUBROUTINE sed_init_data
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_init_data  ***
+      !!
+      !! ** Purpose :  Initialization of sediment module
+      !!               - sets initial sediment composition
+      !!                 ( only clay or reading restart file )
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  original
+      !!----------------------------------------------------------------------
+ 
+      ! local variables
+      INTEGER :: &
+         ji, jk, zhipor
+
+      !--------------------------------------------------------------------
+ 
+
+      IF( .NOT. ln_rst_sed ) THEN
+
+          WRITE(numsed,*) ' Initilization of default values of sediment components'
+
+         ! default values for initial pore water concentrations [mol/l]
+         pwcp(:,:,:) = 0.
+         ! default value for initial solid component (fraction of dry weight dim=[0])
+         ! clay
+         solcp(:,:,:) = 0.
+         solcp(:,2:jpksed,jsclay) = 1.
+
+         ! Initialization of [h+] and [co3--]
+
+         zhipor = 8.
+         ! Initialization of [h+] in mol/kg
+         DO jk = 1, jpksed
+            DO ji = 1, jpoce
+               hipor (ji,jk) = 10.**( -1. * zhipor )
+            ENDDO
+         ENDDO
+
+         co3por(:,:) = 0.
+
+      ELSE   
+  
+         WRITE(numsed,*) ' Initilization of Sediment components from restart'
+
+         CALL sed_rst_read
+
+      ENDIF
+
+
+      ! Load initial Pisces Data for bot. wat. Chem and fluxes
+      CALL sed_dta ( nitsed000 ) 
+
+      ! Initialization of chemical constants
+      CALL sed_chem ( nitsed000 )
+
+      ! Stores initial sediment data for mass balance calculation
+      pwcp0 (1:jpoce,1:jpksed,1:jpwat ) = pwcp (1:jpoce,1:jpksed,1:jpwat ) 
+      solcp0(1:jpoce,1:jpksed,1:jpsol ) = solcp(1:jpoce,1:jpksed,1:jpsol) 
+
+      ! Conversion of [h+] in mol/Kg to get it in mol/l ( multiplication by density)
+      DO jk = 1, jpksed
+         hipor(1:jpoce,jk) = hipor(1:jpoce,jk) * densSW(1:jpoce)
+      ENDDO
+
+
+      ! In default case - no restart - sedco3 is run to initiate [h+] and [co32-]
+      ! Otherwise initiate values of pH and co3 read in restart
+      IF( .NOT. ln_rst_sed ) THEN
+         ! sedco3 is run to initiate[h+] [co32-] in mol/l of solution
+         CALL sed_co3 ( nitsed000 )
+
+      ENDIF
+            
+   END SUBROUTINE sed_init_data
+
+   SUBROUTINE sed_init_wri
+
+      INTEGER :: jk
+
+      WRITE(numsed,*)' '
+      WRITE(numsed,*)'======== Write summary of initial state   ============'
+      WRITE(numsed,*)' '
+      WRITE(numsed,*)' '
+      WRITE(numsed,*)'-------------------------------------------------------------------'
+      WRITE(numsed,*)' Initial Conditions '
+      WRITE(numsed,*)'-------------------------------------------------------------------'
+      WRITE(numsed,*)'dzm = dzkbot minimum to calculate ', 0.
+      WRITE(numsed,*)'Local zone : jpi, jpj : ',jpi, jpj
+      WRITE(numsed,*)'jpoce = ',jpoce,' nbtot pts = ',jpij,' nb earth pts = ',jpij - jpoce
+      WRITE(numsed,*)'sublayer thickness dz(1) [cm] : ', dz(1)
+      WRITE(numsed,*)'Coeff diff for k=1 (cm2/s) : ',diff(1)
+      WRITE(numsed,*)' nb solid comp : ',jpsol
+      WRITE(numsed,*)'(1=opal,2=clay,3=POC,4=CaCO3)'
+      WRITE(numsed,*)'weight mol 1,2,3,4'
+      WRITE(numsed,'(4(F0.2,3X))')mol_wgt(jsopal),mol_wgt(jsclay),mol_wgt(jspoc),mol_wgt(jscal)
+      WRITE(numsed,*)'nb dissolved comp',jpwat
+      WRITE(numsed,*)'(1=silicic acid,2="dissolved" clay,3=O2,4=DIC,5=Nitrate,&
+         &6=Phosphates,7=Alk))'
+      WRITE(numsed,*)'Psat (umol/l) for silicic Acid and "dissolved" clay'
+      WRITE(numsed,'(2(F0.2,3X))') sat_sil * 1e+6,  sat_clay * 1e+6
+      WRITE(numsed,*)'reaction rate rc for Op/si,Clay,POC/O2,caco3, POC/No3 (an-1)'
+      WRITE(numsed,'(5(F0.2,3X))') reac_sil * ryear, reac_clay * ryear, reac_poc * ryear, &
+                                   reac_cal * ryear, reac_no3 * ryear
+      WRITE(numsed,*)'redfield coef C,O,N P Dit '
+      WRITE(numsed,'(5(F0.2,3X))')1./spo4r,so2ut/spo4r,srno3/spo4r,spo4r/spo4r,srDnit/spo4r
+      WRITE(numsed,*)'threshold for stating denitrification [mol/l]'
+      WRITE(numsed,'(1PE8.2)') sthrO2
+      WRITE(numsed,*)'-------------------------------------------------------------------'
+      WRITE(numsed,*)'Min-Max-Mean'
+      WRITE(numsed,*)'For each variable : min, max, moy value observed on selected local zone'
+      WRITE(numsed,*)'-------------------------------------------------------------------'
+      WRITE(numsed,*)'thickness of the last wet layer dzkbot [m]'
+      WRITE(numsed,'(3(F0.2,3X))') MINVAL(dzkbot(1:jpoce))/100.,MAXVAL(dzkbot(1:jpoce))/100.,&
+         &SUM(dzkbot(1:jpoce))/jpoce/100.
+      WRITE(numsed,*)'temp [°C]'
+      WRITE(numsed,'(3(F0.2,3X))') MINVAL(temp(1:jpoce)),MAXVAL(temp(1:jpoce)),&
+         &                         SUM(temp(1:jpoce))/jpoce
+      WRITE(numsed,*)'salt o/oo'
+      WRITE(numsed,'(3(F0.2,3X))')MINVAL(salt(1:jpoce)),MAXVAL(salt(1:jpoce)),&
+         &                        SUM(salt(1:jpoce))/jpoce
+#if defined key_sed_off
+      WRITE(numsed,*)'pressure [bar] (depth in m is about 10*pressure)'
+      WRITE(numsed,'(3(F0.2,3X))') MINVAL(press(1:jpoce)),MAXVAL(press(1:jpoce)),&
+         &                         SUM(press(1:jpoce))/jpoce
+#endif
+      WRITE(numsed,*)'density of Sea Water'
+      WRITE(numsed,'(3(F0.2,3X))') MINVAL(densSW(1:jpoce)), MAXVAL(densSW(1:jpoce)),&
+         &                         SUM(densSW(1:jpoce))/jpoce
+      WRITE(numsed,*)''
+      WRITE(numsed,*)'     Dissolved Components '
+      WRITE(numsed,*)'     ====================='
+      WRITE(numsed,*)'[Si(OH)4] dissolved (1)(k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwsil))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwsil))*1.e+6,&
+         &                         SUM(pwcp(1:jpoce,1,jwsil))*1.e+6/jpoce,&
+         &                         MINVAL(pwcp(1:jpoce,1,jwsil)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[O2]    dissolved (3) (k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwoxy))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwoxy))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwoxy))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwoxy)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[DIC]    dissolved (4) (k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwdic))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwdic))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwdic))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwdic)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[NO3]    dissolved (5) (k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwno3))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwno3))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwno3))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwno3)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[PO4]    dissolved (6) (k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwpo4))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwpo4))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwpo4))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwpo4)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[Alk]    dissolved (7) (k=1)(µequi)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwalk))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwalk))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwalk))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwalk)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)'[DIC13]  dissolved (8) (k=1)(µmol/l)(and min value in mol/kg  of solution)'
+      WRITE(numsed,'(4(F0.3,2X))') MINVAL(pwcp(1:jpoce,1,jwc13))*1.e+6,MAXVAL(pwcp(1:jpoce,1,jwc13))*1.e+6,&
+         &SUM(pwcp(1:jpoce,1,jwc13))*1.e+6/jpoce,&
+         &MINVAL(pwcp(1:jpoce,1,jwc13)*1.e+6/densSW(1:jpoce))
+      WRITE(numsed,*)''
+      WRITE(numsed,*)'     Solid Components '
+      WRITE(numsed,*)'     ====================='
+      WRITE(numsed,*)'nmole of Opale rained per dt'
+      WRITE(numsed,'(3(1PE9.3,2X))') MINVAL(rainrm(1:jpoce,jsopal))*dtsed,MAXVAL(rainrm(1:jpoce,jsopal))*dtsed,&
+         &SUM(rainrm(1:jpoce,1))*dtsed/jpoce
+      WRITE(numsed,*)'nmole of Clay rained per dt'
+      WRITE(numsed,'(3(1PE9.3,2X))') MINVAL(rainrm(1:jpoce,jsclay))*dtsed,MAXVAL(rainrm(1:jpoce,jsclay))*dtsed,&
+         &SUM(rainrm(1:jpoce,jsclay))*dtsed/jpoce
+      WRITE(numsed,*)'nmole of POC rained per dt'
+      WRITE(numsed,'(3(1PE9.3,2X))') MINVAL(rainrm(1:jpoce,jspoc))*dtsed,MAXVAL(rainrm(1:jpoce,jspoc))*dtsed,&
+         &SUM(rainrm(1:jpoce,jspoc))*dtsed/jpoce
+      WRITE(numsed,*)'nmole of CaCO3 rained per dt'
+      WRITE(numsed,'(3(1PE9.3,2X))') MINVAL(rainrm(1:jpoce,jscal))*dtsed,MAXVAL(rainrm(1:jpoce,jscal))*dtsed,&
+         &SUM(rainrm(1:jpoce,jscal))*dtsed/jpoce
+      WRITE(numsed,*)' '
+      WRITE(numsed,*)'Weight frac of opal rained (%) '
+      WRITE(numsed,'(3(F0.3,7X))') MINVAL(rainrg(1:jpoce,jsopal)/raintg(1:jpoce))*100.,&
+         &MAXVAL(rainrg(1:jpoce,jsopal)/raintg(1:jpoce))*100.,&
+         & SUM(rainrg(1:jpoce,jsopal)/raintg(1:jpoce))*100./jpoce
+      WRITE(numsed,*)'Weight frac of clay  rained (%) '
+      WRITE(numsed,'(3(F0.3,7X))') MINVAL(rainrg(1:jpoce,jsclay)/raintg(1:jpoce))*100.,&
+         &MAXVAL(rainrg(1:jpoce,jsclay)/raintg(1:jpoce))*100.,&
+         &SUM(rainrg(1:jpoce,jsclay)/raintg(1:jpoce))*100./jpoce
+      WRITE(numsed,*)'Weight frac of POC rained (%)'
+      WRITE(numsed,'(3(F0.3,7X))') MINVAL(rainrg(1:jpoce,jspoc)/raintg(1:jpoce))*100.,&
+         &MAXVAL(rainrg(1:jpoce,jspoc)/raintg(1:jpoce))*100.,&
+         &SUM(rainrg(1:jpoce,jspoc)/raintg(1:jpoce))*100./jpoce
+      WRITE(numsed,*)'Weight frac of CaCO3  rained (%)'
+      WRITE(numsed,'(3(F0.3,7X))') MINVAL(rainrg(1:jpoce,jscal)/raintg(1:jpoce))*100.,&
+         &MAXVAL(rainrg(1:jpoce,jscal)/raintg(1:jpoce))*100.,&
+         &SUM(rainrg(1:jpoce,jscal)/raintg(1:jpoce))*100./jpoce
+      WRITE(numsed,*)''
+      WRITE(numsed,*)' Thickness of sediment layer added by particule rain, dzdep cm '
+      WRITE(numsed,*)' =============================================================='
+      WRITE(numsed,'(3(F0.5,2X))') MINVAL(dzdep(1:jpoce)),MAXVAL(dzdep(1:jpoce)),SUM(dzdep(1:jpoce))/jpoce
+      WRITE(numsed,*)''
+      WRITE(numsed,*)' chemical constants K1,pK1,K2,pK2,Kw,pKw and Kb pKb (min max) [mol/kgsol] or [mol/kgsol]2 '
+      WRITE(numsed,*)' ========================================================================================='
+      WRITE(numsed,'(4(1PE10.3,2X))')MINVAL(ak1s(1:jpoce)),MAXVAL(ak1s(1:jpoce)),-LOG10(MINVAL(ak1s(1:jpoce))),&
+         &-LOG10(MAXVAL(ak1s(1:jpoce)))
+      WRITE(numsed,'(4(1PE10.3,2X))')MINVAL(ak2s(1:jpoce)),MAXVAL(ak2s(1:jpoce)),-LOG10(MINVAL(ak2s(1:jpoce))),&
+         &-LOG10(MAXVAL(ak2s(1:jpoce)))
+      WRITE(numsed,'(4(1PE10.3,2X))')MINVAL(akws(1:jpoce)),MAXVAL(akws(1:jpoce)),-LOG10(MINVAL(akws(1:jpoce))),&
+         &-LOG10(MAXVAL(akws(1:jpoce)))
+      WRITE(numsed,'(4(1PE10.3,2X))')MINVAL(akbs(1:jpoce)),MAXVAL(akbs(1:jpoce)),-LOG10(MINVAL(akbs(1:jpoce))),&
+         &-LOG10(MAXVAL(akbs(1:jpoce)))
+      WRITE(numsed,*)'and boron'
+      WRITE(numsed,'(2(1PE10.3,2X))')MINVAL(borats(1:jpoce)),MAXVAL(borats(1:jpoce))
+      WRITE(numsed,*)''
+      WRITE(numsed,*)' Compo of initial sediment for point jpoce'
+      WRITE(numsed,*)' ========================================='
+      WRITE(numsed,*)'solcp(1),   solcp(2),   solcp(3),   solcp(4),   hipor,      pH,         co3por'
+      DO jk = 1,jpksed
+         WRITE(numsed,'(7(1PE10.3,2X))')solcp(jpoce,jk,jsopal),solcp(jpoce,jk,jsclay),solcp(jpoce,jk,jspoc),solcp(jpoce,jk,jscal),&
+            &       hipor(jpoce,jk),-LOG10(hipor(jpoce,jk)/densSW(jpoce)),co3por(jpoce,jk)
+      ENDDO
+      WRITE(numsed,'(A82)')'pwcp(1),    pwcp(2),    pwcp(3),    pwcp(4),    pwcp(5),    pwcp(6),    pwcp(7)'
+      DO jk = 1, jpksed
+         WRITE(numsed,'(7(1PE10.3,2X))')pwcp(jpoce,jk,jwsil),pwcp(jpoce,jk,jwoxy),pwcp(jpoce,jk,jwdic),&
+            & pwcp(jpoce,jk,jwno3),pwcp(jpoce,jk,jwpo4),pwcp(jpoce,jk,jwalk),pwcp(jpoce,jk,jwc13)
+      ENDDO
+      WRITE(numsed,*) ' '
+      WRITE(numsed,*) ' End Of Initialization '
+      WRITE(numsed,*) ' '
+!
+   END SUBROUTINE sed_init_wri
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      NO Sediment model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE sed_ini              ! Empty routine
+   END SUBROUTINE sed_ini
+#endif
+
+
+END MODULE sedini
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmat.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmat.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmat.F90	(revision 1844)
@@ -0,0 +1,273 @@
+MODULE sedmat
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  sedmat  ***
+   !!    Sediment : linear system of equations
+   !!=====================================================================
+   !! * Modules used
+   !!----------------------------------------------------------------------
+
+   USE sed     ! sediment global variable
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC sed_mat 
+
+   INTERFACE sed_mat
+      MODULE PROCEDURE sed_mat_dsr, sed_mat_btb
+   END INTERFACE
+
+   INTEGER, PARAMETER :: nmax = 30 
+
+
+ CONTAINS
+
+    SUBROUTINE sed_mat_dsr( nvar, ndim, nlev, preac, psol )
+       !!---------------------------------------------------------------------
+       !!                  ***  ROUTINE sed_mat_dsr  ***
+       !!
+       !! ** Purpose :  solves tridiagonal system of linear equations 
+       !!
+       !! ** Method  : 
+       !!        1 - computes left hand side of linear system of equations
+       !!            for dissolution reaction
+       !!         For mass balance in kbot+sediment :
+       !!              dz3d  (:,1) = dz(1) = 0.5 cm
+       !!              volw3d(:,1) = dzkbot ( see sedini.F90 ) 
+       !!              dz(2)       = 0.3 cm 
+       !!              dz3d(:,2)   = 0.3 + dzdep   ( see seddsr.F90 )     
+       !!              volw3d(:,2) and vols3d(l,2) are thickened ( see seddsr.F90 ) 
+       !!
+       !!         2 - forward/backward substitution. 
+       !!
+       !!   History :
+       !!        !  04-10 (N. Emprin, M. Gehlen ) original
+       !!        !  06-04 (C. Ethe)  Module Re-organization
+       !!----------------------------------------------------------------------
+       !! * Arguments
+       INTEGER , INTENT(in) :: &
+          nvar , &  ! number of variables
+          ndim , &  ! number of points
+          nlev      ! number of sediment levels
+
+       REAL(wp), DIMENSION(ndim,nlev,nvar), INTENT(in) :: &
+          preac     ! reaction rates
+
+       REAL(wp), DIMENSION(ndim,nlev,nvar), INTENT(inout) :: &
+          psol         ! solution ( undersaturation values )
+
+
+       !---Local declarations
+       INTEGER  ::  &
+          ji, jk, jn
+
+       REAL(wp), DIMENSION(ndim,nlev) :: za, zb, zc, zr
+       REAL(wp), DIMENSION(ndim)      :: zbet
+       REAL(wp), DIMENSION(ndim,nmax) :: zgamm
+
+       REAL(wp) ::  &
+          aplus,aminus   ,  & 
+          rplus,rminus   ,  &
+          dxplus,dxminus
+
+       !----------------------------------------------------------------------
+
+
+       ! Computation left hand side of linear system of 
+       ! equations for dissolution reaction
+       !---------------------------------------------
+
+
+       ! first sediment level          
+       DO ji = 1, ndim
+          aplus  = ( ( volw3d(ji,1) / dz3d(ji,1) ) + &
+                     ( volw3d(ji,2) / dz3d(ji,2) ) ) / 2.
+          dxplus = ( dz3d(ji,1) + dz3d(ji,2) ) / 2.
+          rplus  = ( dtsed / volw3d(ji,1) ) * diff(1) * aplus / dxplus 
+
+          za(ji,1) = 0.
+          zb(ji,1) = 1. + rplus
+          zc(ji,1) = -rplus
+       ENDDO
+ 
+       DO jk = 2, nlev - 1
+          DO ji = 1, ndim
+             aminus  = ( ( volw3d(ji,jk-1) / dz3d(ji,jk-1) ) + &
+                &        ( volw3d(ji,jk  ) / dz3d(ji,jk  ) ) ) / 2.
+             dxminus = ( dz3d(ji,jk-1) + dz3d(ji,jk) ) / 2.
+
+             aplus   = ( ( volw3d(ji,jk  ) / dz3d(ji,jk  ) ) + &
+                &        ( volw3d(ji,jk+1) / dz3d(ji,jk+1) ) ) / 2.
+             dxplus  = ( dz3d(ji,jk) + dz3d(ji,jk+1) ) / 2
+             !
+             rminus  = ( dtsed / volw3d(ji,jk) ) * diff(jk-1) * aminus / dxminus
+             rplus   = ( dtsed / volw3d(ji,jk) ) * diff(jk)   * aplus / dxplus
+             !     
+             za(ji,jk) = -rminus
+             zb(ji,jk) = 1. + rminus + rplus 
+             zc(ji,jk) = -rplus
+          END DO
+       END DO
+
+       DO ji = 1, ndim
+          aminus  = ( ( volw3d(ji,nlev-1) / dz3d(ji,nlev-1) ) + &
+             &        ( volw3d(ji,nlev)  / dz3d(ji,nlev) ) ) / 2.
+          dxminus = ( dz3d(ji,nlev-1) + dz3d(ji,nlev) ) / 2.
+          rminus  = ( dtsed / volw3d(ji,nlev) ) * diff(nlev-1) * aminus / dxminus
+          !
+          za(ji,nlev) = -rminus
+          zb(ji,nlev) = 1. + rminus
+          zc(ji,nlev) = 0.
+       END DO
+
+
+       ! solves tridiagonal system of linear equations 
+       ! -----------------------------------------------
+
+       DO jn = 1, nvar
+
+          zr  (:,:)    = psol(:,:,jn)
+          zbet(:  )    = zb(:,1) + preac(:,1,jn)
+          psol(:,1,jn) = zr(:,1) / zbet(:)
+          ! 
+          DO jk = 2, nlev
+             DO ji = 1, ndim
+                zgamm(ji,jk)   =  zc(ji,jk-1) / zbet(ji)
+                zbet(ji)       = ( zb(ji,jk) + preac(ji,jk,jn) ) - za(ji,jk) * zgamm(ji,jk)
+                psol(ji,jk,jn) = ( zr(ji,jk) - za(ji,jk) * psol(ji,jk-1,jn) ) / zbet(ji)
+             END DO
+          ENDDO
+          ! 
+          DO jk = nlev - 1, 1, -1
+             DO ji = 1,ndim
+                psol(ji,jk,jn) = psol(ji,jk,jn) - zgamm(ji,jk+1) * psol(ji,jk+1,jn)
+             END DO
+          ENDDO
+
+       ENDDO
+
+
+    END SUBROUTINE sed_mat_dsr
+
+    
+    SUBROUTINE sed_mat_btb( nvar, ndim, nlev, psol )
+       !!---------------------------------------------------------------------
+       !!                  ***  ROUTINE sed_mat_btb  ***
+       !!
+       !! ** Purpose :  solves tridiagonal system of linear equations 
+       !!
+       !! ** Method  : 
+       !!        1 - computes left hand side of linear system of equations
+       !!            for dissolution reaction
+       !!
+       !!         2 - forward/backward substitution. 
+       !!
+       !!   History :
+       !!        !  04-10 (N. Emprin, M. Gehlen ) original
+       !!        !  06-04 (C. Ethe)  Module Re-organization
+       !!----------------------------------------------------------------------
+       !! * Arguments
+       INTEGER , INTENT(in) :: &
+          nvar , &  ! number of variables
+          ndim , &  ! number of points
+          nlev      ! number of sediment levels
+
+      REAL(wp), DIMENSION(ndim,nlev,nvar), INTENT(inout) :: &
+          psol      ! solution
+
+       !---Local declarations
+       INTEGER  ::  &
+          ji, jk, jn
+
+       REAL(wp) ::  &
+          aplus,aminus   ,  & 
+          rplus,rminus   ,  &
+          dxplus,dxminus 
+
+       REAL(wp), DIMENSION(nlev)      :: za, zb, zc
+       REAL(wp), DIMENSION(ndim,nlev) :: zr
+       REAL(wp), DIMENSION(nmax)      :: zgamm 
+       REAL(wp) ::  zbet
+
+ 
+       !----------------------------------------------------------------------
+
+       ! Computation left hand side of linear system of 
+       ! equations for dissolution reaction
+       !---------------------------------------------
+
+
+       ! first sediment level          
+       aplus  = ( ( vols(2) / dz(2) ) + ( vols(3) / dz(3) ) ) / 2.
+       dxplus = ( dz(2) + dz(3) ) / 2.
+       rplus  = ( dtsed / vols(2) ) * db * aplus / dxplus 
+
+       za(1) = 0.
+       zb(1) = 1. + rplus
+       zc(1) = -rplus
+
+             
+       DO jk = 2, nlev - 1
+          aminus  = ( ( vols(jk) / dz(jk) ) + ( vols(jk+1) / dz(jk+1) ) ) / 2.
+          dxminus = ( dz(jk) + dz(jk+1) ) / 2.
+          rminus  = ( dtsed / vols(jk+1) ) * db * aminus / dxminus
+          !
+          aplus   = ( ( vols(jk+1) / dz(jk+1  ) ) + ( vols(jk+2) / dz(jk+2) ) ) / 2.
+          dxplus  = ( dz(jk+1) + dz(jk+2) ) / 2.
+          rplus   = ( dtsed / vols(jk+1) ) * db * aplus / dxplus
+          !     
+          za(jk) = -rminus
+          zb(jk) = 1. + rminus + rplus 
+          zc(jk) = -rplus
+       ENDDO
+ 
+       aminus  = ( ( vols(nlev) / dz(nlev) ) + ( vols(nlev+1) / dz(nlev+1) ) ) / 2.
+       dxminus = ( dz(nlev) + dz(nlev+1) ) / 2.
+       rminus  = ( dtsed / vols(nlev+1) ) * db * aminus / dxminus
+       !
+ 
+       za(nlev) = -rminus
+       zb(nlev) = 1. + rminus
+       zc(nlev) = 0.
+
+
+       ! solves tridiagonal system of linear equations 
+       ! -----------------------------------------------    
+       DO jn = 1, nvar
+          
+          zr  (:,:)    = psol(:,:,jn)
+          zbet         = zb(1)
+          psol(:,1,jn) = zr(:,1) / zbet
+          ! 
+          DO jk = 2, nlev
+             zgamm(jk) =  zc(jk-1) / zbet
+             zbet      =  zb(jk) - za(jk) * zgamm(jk)
+             DO ji = 1, ndim
+                psol(ji,jk,jn) = ( zr(ji,jk) - za(jk) * psol(ji,jk-1,jn) ) / zbet
+             END DO
+          ENDDO
+          ! 
+          DO jk = nlev - 1, 1, -1
+             DO ji = 1,ndim
+                psol(ji,jk,jn) = psol(ji,jk,jn) - zgamm(jk+1) * psol(ji,jk+1,jn)
+             END DO
+          ENDDO
+
+       ENDDO
+
+       
+    END SUBROUTINE sed_mat_btb
+
+
+#else
+   !!======================================================================
+   !! MODULE sedmat  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_mat         ! Empty routine
+   END SUBROUTINE sed_mat
+   !!======================================================================
+#endif
+
+ END MODULE sedmat
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmbc.F90	(revision 1844)
@@ -0,0 +1,335 @@
+MODULE sedmbc
+#if defined key_sed
+   !!======================================================================
+   !!              ***  MODULE  sedmbc  ***
+   !! Sediment : mass balance calculation
+   !!=====================================================================
+
+   !!----------------------------------------------------------------------
+   !!   sed_mbc    : 
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE sed     ! sediment global variable
+   USE seddsr
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC sed_mbc
+
+   !! * Module variables
+   REAL(wp), DIMENSION(jpsol) :: &
+      rain_tot     ,  &      !
+      fromsed_tot  ,  &      ! 
+      tosed_tot    ,  &      !
+      rloss_tot              !
+
+   REAL(wp), DIMENSION(jpwat) :: &
+      diss_in_tot  ,  &      !
+      diss_out_tot           !
+
+   REAL(wp)  :: &
+      cons_tot_o2  ,  &      !
+      sour_tot_no3 ,  &      !
+      cons_tot_no3 ,  &      !
+      sour_tot_c13           !
+
+   REAL(wp) ::  &
+      src13p  , &
+      src13ca
+
+CONTAINS
+
+
+   SUBROUTINE sed_mbc( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_mbc  ***
+      !!
+      !! ** Purpose :  computation of total tracer inventories for checking
+      !!               mass conservation.
+      !!
+      !!
+      !! ** Method   : tracer inventories of each reservoir are computed and added
+      !!               subsequently.
+      !!
+      !!   History :
+      !!        !  04-10  (N. Emprin, M. Gehlen )  Original code
+      !!        !  06-07  (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+
+      !! Arguments
+      INTEGER, INTENT(in) :: &
+         kt
+
+      !! local declarations
+      INTEGER  :: &
+         ji, js, jw, jk
+
+      REAL(wp) ::  &
+         zinit, zfinal, &
+         zinput, zoutput
+
+      REAL(wp) ::  &
+         zdsw, zvol
+
+      REAL, DIMENSION(jpsol) ::  &
+         zsolcp_inv_i, zsolcp_inv_f
+
+      REAL, DIMENSION(jpwat) ::  &
+         zpwcp_inv_i, zpwcp_inv_f
+       
+      REAL(wp) :: &
+         zdelta_sil, zdelta_clay, &
+         zdelta_co2, zdelta_oxy,  &
+         zdelta_po4, zdelta_no3,  &
+         zdelta_c13, zdelta_c13b
+
+      !!----------------------------------------------------------------------
+      ! Initilization
+      !---------------
+      IF( kt == nitsed000 ) THEN
+         cons_tot_o2  = 0.
+         sour_tot_no3 = 0.
+         cons_tot_no3 = 0.
+         sour_tot_c13 = 0.
+
+         DO js = 1, jpsol
+            rain_tot   (js) = 0.
+            fromsed_tot(js) = 0.
+            tosed_tot  (js) = 0.
+            rloss_tot  (js) = 0.
+         ENDDO
+
+         DO jw = 1, jpwat
+            diss_in_tot (jw) = 0.
+            diss_out_tot(jw) = 0.
+         ENDDO
+
+         src13p  = rc13P  * pdb
+         src13ca = rc13Ca * pdb
+      ENDIF
+
+
+      ! Calculation of the cumulativ input and output
+      ! for mass balance check
+      !----------------------------------------------
+
+      ! cumulativ solid
+      DO js = 1, jpsol
+         DO ji = 1, jpoce
+            ! input [mol]
+            rain_tot   (js) = rain_tot   (js) + dtsed * rainrm_dta(ji,js)
+            fromsed_tot(js) = fromsed_tot(js) + fromsed(ji,js)
+            ! output [mol]
+            tosed_tot  (js) = tosed_tot (js) + tosed(ji,js)
+            rloss_tot  (js) = rloss_tot (js) + rloss(ji,js)
+         ENDDO
+      ENDDO
+
+      ! cumulativ dissolved
+      DO jw = 1, jpwat
+         DO ji = 1, jpoce
+            ! input [mol]
+            diss_in_tot (jw) = diss_in_tot (jw) + pwcp_dta(ji,jw) * 1.e-3 * dzkbot(ji)
+            ! output [mol]
+            diss_out_tot(jw) = diss_out_tot(jw) + tokbot(ji,jw)
+         ENDDO
+      ENDDO
+
+      ! cumulativ o2 and no3 consomation
+      DO ji = 1, jpoce
+         cons_tot_o2  = cons_tot_o2  + cons_o2 (ji)
+         sour_tot_no3 = sour_tot_no3 + sour_no3(ji)
+         cons_tot_no3 = cons_tot_no3 + cons_no3(ji)
+         sour_tot_c13 = sour_tot_c13 + sour_c13(ji)
+      ENDDO
+     
+
+      ! Mass balance check
+      !---------------------
+      IF( kt == nitsedend ) THEN
+         ! initial and final inventories for solid component (mole/dx.dy) in sediment
+         zsolcp_inv_i(:) = 0.
+         zsolcp_inv_f(:) = 0.
+         zpwcp_inv_i (:) = 0.       
+         zpwcp_inv_f (:) = 0.        
+         DO js = 1, jpsol
+            zdsw = dens / mol_wgt(js)
+            DO jk = 2, jpksed
+               DO ji = 1, jpoce
+                  zvol = vols3d(ji,jk) * zdsw
+                  zsolcp_inv_i(js) = zsolcp_inv_i(js) + solcp0(ji,jk,js) * zvol 
+                  zsolcp_inv_f(js) = zsolcp_inv_f(js) + solcp (ji,jk,js) * zvol
+               ENDDO
+            END DO
+         ENDDO
+
+         ! initial and final inventories for dissolved component (mole/dx.dy) in sediment
+         DO jw = 1, jpwat
+            DO jk = 2, jpksed
+               DO ji = 1, jpoce 
+                  zvol = volw3d(ji,jk) * 1.e-3
+                  zpwcp_inv_i(jw) = zpwcp_inv_i(jw) + pwcp0(ji,jk,jw) * zvol
+                  zpwcp_inv_f(jw) = zpwcp_inv_f(jw) + pwcp (ji,jk,jw) * zvol
+               ENDDO
+            END DO
+         ENDDO
+
+         ! mass balance for Silica/opal
+         zinit      = zsolcp_inv_i(jsopal) + zpwcp_inv_i(jwsil)
+         zfinal     = zsolcp_inv_f(jsopal) + zpwcp_inv_f(jwsil)
+         zinput     = rain_tot    (jsopal) + diss_in_tot (jwsil)
+         zoutput    = tosed_tot   (jsopal) + rloss_tot  (jsopal) + diss_out_tot(jwsil)
+         zdelta_sil = ( zfinal + zoutput ) - ( zinit + zinput )
+
+
+         ! mass balance for Clay
+         zinit      = zsolcp_inv_i(jsclay) 
+         zfinal     = zsolcp_inv_f(jsclay) 
+         zinput     = rain_tot   (jsclay) + fromsed_tot(jsclay) 
+         zoutput    = tosed_tot  (jsclay) + rloss_tot  (jsclay) 
+         zdelta_clay= ( zfinal + zoutput ) - ( zinit + zinput )
+
+         ! mass balance for carbon ( carbon in POC, CaCo3, DIC )
+         zinit      = zsolcp_inv_i(jspoc) + zsolcp_inv_i(jscal) + zpwcp_inv_i(jwdic)
+         zfinal     = zsolcp_inv_f(jspoc) + zsolcp_inv_f(jscal) + zpwcp_inv_f(jwdic)
+         zinput     = rain_tot   (jspoc) + rain_tot   (jscal) + diss_in_tot(jwdic)
+         zoutput    = tosed_tot  (jspoc) + tosed_tot  (jscal) + diss_out_tot(jwdic) &
+            &       + rloss_tot  (jspoc) + rloss_tot  (jscal) 
+         zdelta_co2 = ( zfinal + zoutput ) - ( zinit + zinput )
+
+         ! mass balance for oxygen : O2 is in POC remineralization
+         zinit      = zpwcp_inv_i(jwoxy)
+         zfinal     = zpwcp_inv_f(jwoxy)
+         zinput     = diss_in_tot(jwoxy)
+         zoutput    = diss_out_tot(jwoxy) + cons_tot_o2
+         zdelta_oxy = ( zfinal + zoutput ) - ( zinit + zinput )
+
+         ! mass balance for phosphate ( PO4 in POC and dissolved phosphates )
+         zinit      = zsolcp_inv_i(jspoc) * spo4r + zpwcp_inv_i(jwpo4)
+         zfinal     = zsolcp_inv_f(jspoc) * spo4r + zpwcp_inv_f(jwpo4)
+         zinput     = rain_tot   (jspoc) * spo4r + diss_in_tot(jwpo4)
+         zoutput    = tosed_tot  (jspoc) * spo4r + diss_out_tot(jwpo4) &
+            &       + rloss_tot  (jspoc) * spo4r
+         zdelta_po4 = ( zfinal + zoutput ) - ( zinit + zinput )
+
+
+         ! mass balance for Nitrate
+         zinit      = zpwcp_inv_i  (jwno3)
+         zfinal     = zpwcp_inv_f  (jwno3)
+         zinput     = diss_in_tot (jwno3) + sour_tot_no3
+         zoutput    = diss_out_tot(jwno3) + cons_tot_no3
+         zdelta_no3 = ( zfinal + zoutput ) - ( zinit + zinput )
+
+         ! mass balance for DIC13
+         zinit      =  zpwcp_inv_i(jwc13)   &
+            &        + src13p * zsolcp_inv_i(jspoc) + src13Ca * zsolcp_inv_i(jscal) 
+         zfinal     =  zpwcp_inv_f(jwc13)   &
+            &        + src13p * zsolcp_inv_f(jspoc) + src13Ca * zsolcp_inv_f(jscal)
+         zinput     =  diss_in_tot (jwc13)  &
+            &        + src13p * rain_tot(jspoc) + src13Ca * rain_tot(jscal)
+         zoutput    =  diss_out_tot(jwc13)  &
+            &        + src13p * tosed_tot(jspoc) + src13Ca * tosed_tot(jscal) &   
+            &        + src13p * rloss_tot(jspoc) + src13Ca * rloss_tot(jscal)
+         zdelta_c13 = ( zfinal + zoutput ) - ( zinit + zinput )
+
+         ! other mass balance for DIC13
+         zinit      = zpwcp_inv_i  (jwc13)
+         zfinal     = zpwcp_inv_f  (jwc13)
+         zinput     = diss_in_tot (jwc13) + sour_tot_c13
+         zoutput    = diss_out_tot(jwc13)
+         zdelta_c13b= ( zfinal + zoutput ) - ( zinit + zinput )    
+
+      END IF
+
+      IF( kt == nitsedend) THEN 
+
+         WRITE(numsed,*)
+         WRITE(numsed,*)'==================    General mass balance   ==================  '
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)' Initial total solid Masses (mole/dx.dy) (k=2-11) '
+         WRITE(numsed,*)' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numsed,*)'    Opale,      Clay,       POC,        CaCO3,         C13'
+         WRITE(numsed,'(4x,5(1PE10.3,2X))')zsolcp_inv_i(jsopal),zsolcp_inv_i(jsclay),zsolcp_inv_i(jspoc), &
+            & zsolcp_inv_i(jscal),( src13P * zsolcp_inv_i(jspoc) + src13Ca * zsolcp_inv_i(jscal) )
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)' Initial total dissolved Masses (mole/dx.dy) (k=2-11) '
+         WRITE(numsed,*)' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         WRITE(numsed,*)'    Si,         O2,         DIC,        Nit         Phos,       DIC13'
+         WRITE(numsed,'(4x,6(1PE10.3,2X))') zpwcp_inv_i(jwsil), zpwcp_inv_i(jwoxy), &
+            & zpwcp_inv_i(jwdic), zpwcp_inv_i(jwno3), zpwcp_inv_i(jwpo4), zpwcp_inv_i(jwc13)
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)'  Solid inputs :  Opale,      Clay,       POC,        CaCO3,         C13'
+         WRITE(numsed,'(A4,10X,5(1PE10.3,2X))')'Rain : ',rain_tot(jsopal),rain_tot(jsclay),rain_tot(jspoc),&
+            & rain_tot(jscal),( src13P * rain_tot(jspoc) + src13Ca * rain_tot(jscal) )
+         WRITE(numsed,'(A12,6x,4(1PE10.3,2X))')' From Sed : ',fromsed_tot(jsopal), fromsed_tot(jsclay), &
+            & fromsed_tot(jspoc), fromsed_tot(jscal)
+         WRITE(numsed,*)'Diss. inputs : Si,    O2,         DIC,         Nit,       Phos,       DIC13'
+         WRITE(numsed,'(A9,1x,6(1PE10.3,2X))')' From Pisc : ', diss_in_tot(jwsil), &
+            & diss_in_tot(jwoxy), diss_in_tot(jwdic), diss_in_tot(jwno3), diss_in_tot(jwpo4), &
+            & diss_in_tot(jwc13)
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)'Solid output : Opale,      Clay,       POC,        CaCO3,          C13'
+         WRITE(numsed,'(A6,8x,5(1PE10.3,2X))')'To sed', tosed_tot(jsopal),tosed_tot(jsclay),tosed_tot(jspoc),&
+            & tosed_tot(jscal),( src13P * tosed_tot(jspoc) + src13Ca * tosed_tot(jscal) )
+         WRITE(numsed,'(A5,9x,5(1PE10.3,2X))')'Perdu', rloss_tot(jsopal),rloss_tot(jsclay),rloss_tot(jspoc),&
+            & rloss_tot(jscal),( src13P * rloss_tot(jspoc) + src13Ca * rloss_tot(jscal) )
+         WRITE(numsed,*)'Diss. output : Si,     O2,        DIC,          Nit,       Phos,       DIC13 '  
+         WRITE(numsed,'(A7,2x,6(1PE10.3,2X))')'To kbot', diss_out_tot(jwsil), &
+            & diss_out_tot(jwoxy), diss_out_tot(jwdic), diss_out_tot(jwno3), diss_out_tot(jwpo4), &
+            & diss_out_tot(jwc13)
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)' Total consomation in POC remineralization [mol]:  O2,         NO3'
+         WRITE(numsed,'(51x,2(1PE10.3,2X))') cons_tot_o2,cons_tot_no3
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)'Final solid  Masses (mole/dx.dy) (k=2-11)'
+         WRITE(numsed,*)'    Opale,      Clay,       POC,        CaCO3,          C13'
+         WRITE(numsed,'(4x,5(1PE10.3,2X))')zsolcp_inv_f(jsopal),zsolcp_inv_f(jsclay),zsolcp_inv_f(jspoc), &
+            & zsolcp_inv_f(jscal),( src13P * zsolcp_inv_f(jspoc) + src13Ca * zsolcp_inv_f(jscal) )
+         WRITE(numsed,*)' '
+         WRITE(numsed,*)'Final dissolved  Masses (mole/dx.dy) (k=2-11)'
+         WRITE(numsed,*)'    Si,        O2,         DIC,        Nit,        Phos,    DIC13'
+         WRITE(numsed,'(4x,6(1PE10.3,2X))') zpwcp_inv_f(jwsil), zpwcp_inv_f(jwoxy), &
+            & zpwcp_inv_f(jwdic), zpwcp_inv_f(jwno3), zpwcp_inv_f(jwpo4), zpwcp_inv_f(jwc13)
+         WRITE(numsed,*)' '     
+         WRITE(numsed,*)'Delta : Opale,      Clay,       C,          O,          N,          P,        C13'
+         WRITE(numsed,'(7x,7(1PE11.3,1X))') zdelta_sil, zdelta_clay, zdelta_co2, zdelta_oxy, zdelta_no3,&
+            &                          zdelta_po4, zdelta_c13
+         WRITE(numsed,*)' ' 
+         WRITE(numsed,*)'deltaC13bis : ',zdelta_c13b     
+
+         WRITE(numsed,*)'=========================================================================='
+         WRITE(numsed,*)' Composition of final sediment for point jpoce'
+         WRITE(numsed,*)' ========================================='
+         WRITE(numsed,*)'Opale,      Clay,       POC,        CaCo3,      hipor,      pH,         co3por'
+         DO jk = 1,jpksed
+            WRITE(numsed,'(4(F8.4,4X),3(1PE10.3,2X))') solcp(jpoce,jk,jsopal)*100.,solcp(jpoce,jk,jsclay)*100.,&
+               &       solcp(jpoce,jk,jspoc)*100.,solcp(jpoce,jk,jscal)*100.,&
+               &       hipor(jpoce,jk),-LOG10(hipor(jpoce,jk)/densSW(jpoce)),co3por(jpoce,jk)
+         ENDDO
+         WRITE(numsed,*)'Silicic A.,  Oxygen,     DIC,        Nitrats,    Phosphats,  Alkal.,     DIC13'
+         DO jk = 1, jpksed
+            WRITE(numsed,'(8(1PE10.3,2X))')pwcp(jpoce,jk,jwsil),pwcp(jpoce,jk,jwoxy),&
+               & pwcp(jpoce,jk,jwdic),pwcp(jpoce,jk,jwno3),pwcp(jpoce,jk,jwpo4),pwcp(jpoce,jk,jwalk),pwcp(jpoce,jk,jwc13)
+         ENDDO
+         WRITE(numsed,*)'densSW at the end : ',densSW(jpoce)
+         WRITE(numsed,*)'=========================================================================='
+
+      ENDIF
+  
+   END SUBROUTINE sed_mbc
+
+
+#else
+   !!======================================================================
+   !! MODULE sedmbc :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_mbc( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_mbc: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_mbc
+#endif
+END MODULE sedmbc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmodel.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmodel.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedmodel.F90	(revision 1844)
@@ -0,0 +1,56 @@
+MODULE sedmodel
+#if defined key_sed
+   !!======================================================================
+   !!                       ***  MODULE sedmodel   ***
+   !!   Sediment model : Main routine of sediment model 
+   !!======================================================================
+   USE sed
+   USE sedini   ! sediment variables initialization
+   USE sedstp   ! time stepping
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC sed_model  ! called by step.F90
+
+   LOGICAL, PUBLIC, PARAMETER ::   lk_sed = .TRUE.     !: sediment flag
+
+CONTAINS
+
+   SUBROUTINE sed_model ( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sed_model  ***
+      !!
+      !! ** Purpose :   main routine of sediment model
+      !!
+      !!
+      !! ** Method  : - model general initialization
+      !!              - launch the time-stepping (stp routine)
+      !!
+      !!   History :
+      !!        !  07-02 (C. Ethe)  Original
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+
+
+      IF( kt == nit000 ) CALL sed_init       ! Initialization of sediment model
+
+                         CALL sed_stp( kt )  ! Time stepping of Sediment model
+
+
+   END SUBROUTINE sed_model
+
+#else
+   !!======================================================================
+   !! MODULE sedmodel  :   Dummy module 
+   !!======================================================================
+   LOGICAL, PUBLIC, PARAMETER ::   lk_sed = .FALSE.     !: sediment flag
+CONTAINS
+   SUBROUTINE sed_model( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_stp: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_model
+#endif
+
+END MODULE sedmodel
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedrst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedrst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedrst.F90	(revision 1844)
@@ -0,0 +1,296 @@
+MODULE sedrst
+#if defined key_sed
+   !!======================================================================
+   !!                       *** MODULE sedrst ***
+   !!   Read and write the restart files for sediment
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   !! ==============
+   USE sed
+   USE sedarr
+
+
+   !! * Accessibility
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC sed_rst_read
+   PUBLIC sed_rst_wri
+
+   !! * Module variables
+   INTEGER, PUBLIC ::   numrsr, numrsw   !: logical unit for sed restart (read and write)
+   
+   
+CONTAINS
+
+
+   SUBROUTINE sed_rst_read 
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_rst_read  ***
+      !!
+      !! ** Purpose :  Initialization of sediment module
+      !!               - sets initial sediment composition
+      !!                 ( only clay or reading restart file )
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  original
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+
+      !! * local declarations
+      INTEGER :: &
+         ji, jk, jn
+      REAL(wp), DIMENSION(jpi,jpj,jpksed,jptrased) :: &
+         zdta
+
+      REAL(wp), DIMENSION(jpi,jpj,jpksed,2) :: &
+         zdta1
+
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: &
+         zhipor
+
+      REAL(wp) :: zkt
+      CHARACTER(len = 20) ::   cltra
+      INTEGER             ::   jlibalt = jprstlib
+      LOGICAL             ::   llok
+      !--------------------------------------------------------------------
+ 
+
+      WRITE(numsed,*) ' '      
+      WRITE(numsed,*) ' Initilization of Sediment components from restart'
+      WRITE(numsed,*) ' '
+
+      ALLOCATE( zhipor(jpoce,jpksed) ) 
+
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if restart_sed.nc exists, then set jlibalt to jpnf90
+        INQUIRE( FILE = 'restart_sed.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+      ENDIF
+
+      CALL iom_open( 'restart_sed', numrsr, kiolib = jlibalt )     
+      CALL iom_get( numrsr, 'kt'     , zkt      )   ! time-step
+ 
+      DO jn = 1, jptrased
+         cltra = sedtrcd(jn)
+         CALL iom_get( numrsr, jpdom_unknown, cltra, zdta(:,:,:,jn), &
+            &          kstart=(/1,1,1/), kcount=(/jpi,jpj,jpksed/) )
+      ENDDO
+        
+
+      CALL pack_arr( jpoce, solcp(1:jpoce,1:jpksed,jsopal), &
+         &            zdta(1:jpi,1:jpj,1:jpksed,1), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, solcp(1:jpoce,1:jpksed,jsclay), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,2), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, solcp(1:jpoce,1:jpksed,jspoc), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,3), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, solcp(1:jpoce,1:jpksed,jscal), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,4), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwsil), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,5), iarroce(1:jpoce) )
+
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwoxy), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,6), iarroce(1:jpoce) )
+
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwdic), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,7), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwno3), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,8), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwpo4), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,9), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwalk), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,10), iarroce(1:jpoce) )
+
+      CALL pack_arr( jpoce, pwcp(1:jpoce,1:jpksed,jwc13), &
+         &             zdta(1:jpi,1:jpj,1:jpksed,11), iarroce(1:jpoce) )
+
+      DO jn = 1, 2
+         cltra = seddia3d(jn)
+         CALL iom_get( numrsr, jpdom_unknown, cltra, zdta1(:,:,:,jn), &
+            &          kstart=(/1,1,1/), kcount=(/jpi,jpj,jpksed/) )
+      ENDDO
+
+      zhipor(:,:) = 0.
+      CALL pack_arr( jpoce, zhipor(1:jpoce,1:jpksed), &
+         &             zdta1(1:jpi,1:jpj,1:jpksed,1), iarroce(1:jpoce) )
+
+      ! Initialization of [h+] in mol/kg
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            hipor (ji,jk) = 10.**( -1. * zhipor(ji,jk) )
+         ENDDO
+      ENDDO
+      
+      CALL pack_arr( jpoce, co3por(1:jpoce,1:jpksed), &
+         &             zdta1(1:jpi,1:jpj,1:jpksed,2), iarroce(1:jpoce) )
+
+      ! Initialization of sediment composant only ie jk=2 to jk=jpksed 
+      ! ( nothing in jk=1)
+      solcp(1:jpoce,1,:) = 0.
+      pwcp (1:jpoce,1,:) = 0.
+
+      DEALLOCATE( zhipor )
+     
+   END SUBROUTINE sed_rst_read
+
+   SUBROUTINE sed_rst_wri( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_rst_wri  ***
+      !!
+      !! ** Purpose :  save field which are necessary for sediment restart
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  original
+      !!----------------------------------------------------------------------
+      !!* Modules used
+      USE ioipsl
+      !! *Arguments
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      !! * local declarations
+
+      CHARACTER (len=50) :: clname,cln
+
+      INTEGER ::  &
+         ic,jc,jn,      &
+         itime
+
+     REAL(wp) ::  &
+         zdate0
+
+     REAL(wp), DIMENSION(1) :: &
+        zinfo
+
+      CHARACTER(len = 20)  ::  cltra 
+
+      INTEGER   :: ji, jk
+      REAL(wp), DIMENSION(:,:) , ALLOCATABLE  :: zdta   
+      !! -----------------------------------------------------------------------
+
+      ALLOCATE( zdta(jpoce,jpksed) )
+
+      IF( MOD(kt,nstock) == 0 .OR. kt == nitsedend ) THEN
+         
+         !! 0. initialisations
+         !! ------------------
+         
+         IF(lwp) WRITE(numsed,*) ' '
+         IF(lwp) WRITE(numsed,*) 'sed_rst_write : write the sediment restart file in NetCDF format ',   &
+            'at it= ',kt
+         IF(lwp) WRITE(numsed,*) '~~~~~~~~~'
+         
+         !! 1. WRITE in nutwrs
+         !! ------------------
+
+         ic = 1
+         DO jc = 1,16
+            IF( cexper(jc:jc) /= ' ') ic = jc
+         END DO
+         WRITE( cln,'("_",i5.5,i2.2,i2.2,"_restart.sed")') nyear, nmonth, nday
+         clname = cexper(1:ic)//cln
+         itime = 0
+         CALL ymds2ju( nyear, nmonth, nday, rdt, zdate0 )
+         zdate0 = zdate0 - adatrj   !   set calendar origin to the beginning of the experiment
+         CALL restini( 'NONE', jpi, jpj, glamt, gphit, jpksed, dz, &
+            &         clname, itime, zdate0, dtsed*nstock, numrsw, domain_id=nidom )
+         zinfo(1) = REAL( kt)
+         CALL restput( numrsw, 'kt', 1,1, 1,0, zinfo  )
+
+
+
+         ! Back to 2D geometry
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,1) , iarroce(1:jpoce), &
+            &                    solcp(1:jpoce,1:jpksed,jsopal ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,2) , iarroce(1:jpoce), &
+            &                    solcp(1:jpoce,1:jpksed,jsclay ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,3) , iarroce(1:jpoce), &
+            &                    solcp(1:jpoce,1:jpksed,jspoc  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,4) , iarroce(1:jpoce), &
+            &                    solcp(1:jpoce,1:jpksed,jscal  ) )   
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,5) , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwsil  )  )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,6)  , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwoxy  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,7)  , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwdic  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,8)  , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwno3  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,9)  , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwpo4  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,10)  , iarroce(1:jpoce), &
+            &                    pwcp(1:jpoce,1:jpksed,jwalk  ) )
+         
+         CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,11)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwc13  ) )
+         
+         ! porosity
+         zdta(:,:) = 0.
+         DO jk = 1, jpksed
+            DO ji = 1, jpoce
+               zdta(ji,jk) = -LOG10( hipor(ji,jk) / densSW(ji) )
+            ENDDO
+         ENDDO
+         CALL unpack_arr( jpoce, flxsedi3d(1:jpi,1:jpj,1:jpksed,1)  , iarroce(1:jpoce), &
+            &                   zdta(1:jpoce,1:jpksed)  )
+         
+         CALL unpack_arr( jpoce, flxsedi3d(1:jpi,1:jpj,1:jpksed,2)  , iarroce(1:jpoce), &
+            &                   co3por(1:jpoce,1:jpksed)  )
+      
+         ! prognostic variables
+         ! --------------------
+
+
+         DO jn = 1, jptrased
+            cltra = sedtrcd(jn)
+            CALL restput( numrsw, cltra, jpi, jpj, jpksed, 0, trcsedi(:,:,:,jn) )
+         ENDDO
+
+         DO jn = 1, 2
+            cltra = seddia3d(jn)
+            CALL restput( numrsw, cltra, jpi, jpj, jpksed, 0, flxsedi3d(:,:,:,jn) )
+         ENDDO
+
+
+         CALL restclo( numrsw )
+
+      ENDIF
+
+      DEALLOCATE( zdta )  
+         
+   END SUBROUTINE sed_rst_wri
+#else
+   !!======================================================================
+   !! MODULE sedrst :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_rst_read                      ! Empty routines
+   END SUBROUTINE sed_rst_read
+   SUBROUTINE sed_rst_wri( kt )
+      INTEGER, INTENT ( in ) :: kt
+      WRITE(*,*) 'sed_rst_wri: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_rst_wri   
+#endif
+
+END MODULE sedrst
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedsfc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedsfc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedsfc.F90	(revision 1844)
@@ -0,0 +1,79 @@
+MODULE sedsfc
+   !!======================================================================
+   !!              ***  MODULE  sedsfc  ***
+   !!    Sediment : Data at sediment surface
+   !!=====================================================================
+#if defined key_sed && ! defined key_sed_off
+   !! * Modules used
+   USE sed     ! sediment global variable
+   USE sedarr
+   USE seddta
+
+   PUBLIC sed_sfc
+
+CONTAINS
+
+   SUBROUTINE sed_sfc( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sed_sfc ***
+      !!
+      !! ** Purpose :  Give data from sediment model to tracer model
+      !!
+      !!
+      !!   History :
+      !!        !  06-04 (C. Ethe)  Orginal code
+      !!----------------------------------------------------------------------
+      !!* Arguments
+      INTEGER, INTENT(in) ::  &
+         kt              ! time step
+
+      ! * local variables
+      INTEGER :: &
+         ji, jj, ikt     ! dummy loop indices
+
+
+      !------------------------------------------------------------------------
+
+      IF( kt == nitsed000 ) THEN
+         WRITE(numsed,*) ' sed_sfc : Give data from sediment model to tracer model  '
+         WRITE(numsed,*) ' '
+      ENDIF
+
+      ! reading variables
+
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,1), iarroce(1:jpoce), pwcp(1:jpoce,1,jwalk) )
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,2), iarroce(1:jpoce), pwcp(1:jpoce,1,jwdic) )
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,3), iarroce(1:jpoce), pwcp(1:jpoce,1,jwno3) )
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,4), iarroce(1:jpoce), pwcp(1:jpoce,1,jwpo4) )
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,5), iarroce(1:jpoce), pwcp(1:jpoce,1,jwoxy) )
+      CALL unpack_arr ( jpoce, trc_data(1:jpi,1:jpj,6), iarroce(1:jpoce), pwcp(1:jpoce,1,jwsil) )
+
+
+      DO jj = 1,jpj
+         DO ji = 1, jpi
+            ikt = MAX( mbathy(ji,jj)-1, 1 )
+            IF ( tmask(ji,jj,ikt) == 1 ) THEN
+               trn(ji,jj,ikt,jptal) = trc_data(ji,jj,1)
+               trn(ji,jj,ikt,jpdic) = trc_data(ji,jj,2)
+               trn(ji,jj,ikt,jpno3) = trc_data(ji,jj,3) * 7.6
+               trn(ji,jj,ikt,jppo4) = trc_data(ji,jj,4) * 122.
+               trn(ji,jj,ikt,jpoxy) = trc_data(ji,jj,5)
+               trn(ji,jj,ikt,jpsil) = trc_data(ji,jj,6)
+            ENDIF
+         ENDDO
+      ENDDO
+
+   END SUBROUTINE sed_sfc
+
+#else
+   !!======================================================================
+   !! MODULE sedsfc  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_sfc ( kt )
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_sfc: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_sfc
+#endif
+
+END MODULE sedsfc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedstp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedstp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedstp.F90	(revision 1844)
@@ -0,0 +1,77 @@
+MODULE sedstp
+#if defined key_sed
+   !!======================================================================
+   !!                       ***  MODULE sedstp   ***
+   !!   Sediment model : Sediment model time-stepping
+   !!======================================================================
+   USE sed      ! sediment global variables
+   USE seddta   ! data read
+   USE sedchem  ! chemical constant
+   USE sedco3   ! carbonate in sediment pore water
+   USE seddsr   ! dissolution reaction
+   USE sedbtb   ! bioturbation
+   USE sedadv   ! vertical advection
+   USE sedmbc   ! mass balance calculation
+   USE sedsfc   ! sediment surface data
+   USE sedrst   ! restart
+   USE sedwri   ! outputs
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC sed_stp  ! called by step.F90
+
+CONTAINS
+
+   SUBROUTINE sed_stp ( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sed_stp  ***
+      !!
+      !! ** Purpose :   Sediment time stepping
+      !!                Simulation of pore water chemistry
+      !!
+      !! ** Action  :
+      !!
+      !!
+      !!   History :
+      !!        !  98-08 (E. Maier-Reimer, Christoph Heinze )  Original code
+      !!        !  04-10 (N. Emprin, M. Gehlen ) coupled with PISCES
+      !!        !  06-04 (C. Ethe)  Re-organization
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+
+      !!----------------------------------------------------------------------
+
+      IF( kt /= nitsed000 )  THEN
+        CALL sed_dta( kt )       ! Load  Data for bot. wat. Chem and fluxes
+        CALL sed_chem( kt )      ! update of chemical constant to account for salinity, temperature changes
+      ENDIF
+      CALL sed_dsr( kt )         ! Dissolution reaction
+      CALL sed_adv( kt )         ! advection
+      CALL sed_btb( kt )         ! Bioturbation
+
+      IF ( ( MOD( kt, nwrised ) == 0 ) .OR. ( MOD( kt, nstock ) == 0 ) .OR. ( kt == nitsedend )  )   &
+      CALL sed_co3( kt )         ! pH actualization for saving
+      CALL sed_mbc( kt )         ! cumulation for mass balance calculation
+#if ! defined key_sed_off
+      CALL sed_sfc( kt )         ! Give back new bottom wat chem to tracer model
+#endif
+      CALL sed_rst_wri( kt )   ! restart file output
+      CALL sed_wri( kt )         ! outputs
+
+      IF( kt == nitsedend )  CLOSE( numsed )
+
+   END SUBROUTINE sed_stp
+
+#else
+   !!======================================================================
+   !! MODULE sedstp  :   Dummy module 
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_stp( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_stp: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_stp
+#endif
+END MODULE sedstp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedwri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedwri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/SED/sedwri.F90	(revision 1844)
@@ -0,0 +1,273 @@
+MODULE sedwri
+#if defined key_sed
+   !!======================================================================
+   !!                     ***  MODULE  sedwri  ***
+   !!         Sediment diagnostics :  write sediment output files
+   !!======================================================================
+   USE sed
+   USE sedarr
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC sed_wri 
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!                                                   NetCDF output file
+   !!----------------------------------------------------------------------
+   SUBROUTINE sed_wri( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE sed_wri  ***
+      !!
+      !! ** Purpose :  output of sediment passive tracer
+      !!
+      !!   History :
+      !!        !  06-07  (C. Ethe)  original
+      !!----------------------------------------------------------------------
+      !! * Local variables
+      USE ioipsl
+      USE dianam    ! build name of file (routine)
+
+      INTEGER, INTENT(in) :: kt
+
+      CHARACTER(len = 60)  ::  clhstnam, clop
+      INTEGER , SAVE :: nised, nhorised, ndimt52, ndimt51, ndepsed
+      REAL(wp), SAVE :: zjulian
+      INTEGER , DIMENSION(jpij*jpksed) , SAVE :: ndext52  
+      INTEGER , DIMENSION(jpij) , SAVE :: ndext51
+      REAL(wp) :: zsto,zout, zdt
+      INTEGER :: iimi, iima, ijmi, ijma,ipk, it, itmod
+      INTEGER :: jn
+      CHARACTER(len = 20)  ::  cltra , cltrau
+      CHARACTER(len = 80)  ::  cltral
+
+      INTEGER   :: ji, jk, js, jw
+      REAL(wp)  :: zrate
+      REAL(wp), DIMENSION(:,:) , ALLOCATABLE  :: zdta, zflx
+
+      !!-------------------------------------------------------------------
+
+
+      ! Initialisation
+      ! ----------------- 
+
+
+      ! Define frequency of output and means
+      zdt = dtsed
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#if defined key_diainstant
+      zsto = nwrised * zdt
+      clop = "inst("//TRIM(clop)//")"
+#else
+      zsto = zdt
+      clop = "ave("//TRIM(clop)//")"
+#endif
+      zout = nwrised * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpksed
+
+      ! define time axis
+      it = kt
+      itmod = kt - nitsed000 + 1
+
+
+      ! 1.  Initilisations
+      ! -----------------------------------------------------------------
+      WRITE(numsed,*) ' '
+      WRITE(numsed,*) 'sed_wri kt = ', kt
+      WRITE(numsed,*) ' '
+      
+      ALLOCATE( zdta(jpoce,jpksed) )    ;   ALLOCATE( zflx(jpoce,jpwatp1) )
+
+
+      ! 2.  Back to 2D geometry
+      ! -----------------------------------------------------------------
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,1) , iarroce(1:jpoce), &
+         &                    solcp(1:jpoce,1:jpksed,jsopal ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,2) , iarroce(1:jpoce), &
+         &                    solcp(1:jpoce,1:jpksed,jsclay ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,3) , iarroce(1:jpoce), &
+         &                    solcp(1:jpoce,1:jpksed,jspoc  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,4) , iarroce(1:jpoce), &
+         &                    solcp(1:jpoce,1:jpksed,jscal  ) )   
+            
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,5) , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwsil  )  )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,6)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwoxy  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,7)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwdic  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,8)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwno3  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,9)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwpo4  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,10)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwalk  ) )
+      
+      CALL unpack_arr( jpoce, trcsedi(1:jpi,1:jpj,1:jpksed,11)  , iarroce(1:jpoce), &
+         &                    pwcp(1:jpoce,1:jpksed,jwc13  ) )
+      
+      ! porosity
+      zdta(:,:) = 0.
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zdta(ji,jk) = -LOG10( hipor(ji,jk) / densSW(ji) )
+         ENDDO
+      ENDDO
+      CALL unpack_arr( jpoce, flxsedi3d(1:jpi,1:jpj,1:jpksed,1)  , iarroce(1:jpoce), &
+         &                   zdta(1:jpoce,1:jpksed)  )
+      
+      CALL unpack_arr( jpoce, flxsedi3d(1:jpi,1:jpj,1:jpksed,2)  , iarroce(1:jpoce), &
+         &                   co3por(1:jpoce,1:jpksed)  )
+      
+      
+      ! computation of delta 13C
+      zdta(:,:) = 0.
+      DO jk = 1, jpksed
+         DO ji = 1, jpoce
+            zdta(ji,jk) = ( ( pwcp(ji,jk,jwc13) / pwcp(ji,jk,jwdic) / pdb ) - 1. ) &
+               &              * 1000.
+         ENDDO
+      ENDDO
+      CALL unpack_arr( jpoce, flxsedi3d(1:jpi,1:jpj,1:jpksed,3)  , iarroce(1:jpoce), &
+         &                   zdta(1:jpoce,1:jpksed)  )
+      
+ 
+      zflx(:,:) = 0.    
+      ! Calculation of fluxes mol/cm2/s
+      DO jw = 1, jpwat
+         DO ji = 1, jpoce
+            zflx(ji,jw) = ( pwcp(ji,1,jw) - pwcp_dta(ji,jw) ) &
+               &         * 1.e-3 * dzkbot(ji) / dtsed
+         ENDDO
+      ENDDO
+      ! Calculation of accumulation rate per dt
+      DO js = 1, jpsol
+         zrate =  mol_wgt(js) / ( dens * por1(jpksed) ) / dtsed
+         DO ji = 1, jpoce
+            zflx(ji,jpwatp1) = zflx(ji,jpwatp1) + ( tosed(ji,js) - fromsed(ji,js) ) * zrate
+         ENDDO
+      ENDDO
+
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,1), iarroce(1:jpoce), zflx(1:jpoce,1)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,2), iarroce(1:jpoce), zflx(1:jpoce,2)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,3), iarroce(1:jpoce), zflx(1:jpoce,3)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,4), iarroce(1:jpoce), zflx(1:jpoce,4)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,5), iarroce(1:jpoce), zflx(1:jpoce,5)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,6), iarroce(1:jpoce), zflx(1:jpoce,6)  )
+      CALL unpack_arr( jpoce, flxsedi2d(1:jpi,1:jpj,7), iarroce(1:jpoce), zflx(1:jpoce,8)  )
+
+
+      ! 3. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      IF( kt == nitsed000 ) THEN
+
+         ! Define the NETCDF files        
+         CALL ymds2ju ( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         CALL dia_nam ( clhstnam, nwrised, 'sed_T' )
+         CALL histbeg ( clhstnam, jpi, glamt, jpj, gphit,     &
+            &             iimi, iima-iimi+1, ijmi, ijma-ijmi+1,         &
+            &             nitsed000-1, zjulian, zdt,  nhorised, nised , domain_id=nidom )
+         CALL histvert( nised,'deptht','Vertic.sed.T levels','m',ipk, profsed, ndepsed, 'down' )
+         CALL wheneq  ( jpi*jpj*ipk, tmasksed, 1, 1., ndext52, ndimt52 )
+         CALL wheneq  ( jpi*jpj, tmasksed(:,:,1), 1, 1., ndext51, ndimt51 )
+
+         ! Declare all the output fields as NETCDF variables
+
+         DO jn = 1, jptrased
+            cltra  = sedtrcd(jn)   ! short title for sediment variable
+            cltral = sedtrcl(jn)   ! long title for  sediment variable
+            cltrau = sedtrcu(jn)   ! unit for  sediment variable
+
+            CALL histdef( nised, cltra,cltral,cltrau, jpi, jpj, nhorised, &
+               &          ipk, 1, ipk, ndepsed, 32, clop, zsto, zout )
+         ENDDO
+
+         ! 3D diagnostic
+         DO jn = 1, jpdia3dsed
+            cltra  = seddia3d(jn)   ! short title for 3D diagnostic
+            cltral = seddia3l(jn)   ! long title for 3D diagnostic
+            cltrau = seddia3u(jn)   ! UNIT for 3D diagnostic
+
+            CALL histdef( nised, cltra,cltral,cltrau, jpi, jpj, nhorised, &
+               &          ipk, 1, ipk, ndepsed, 32, clop, zsto, zout  )
+         ENDDO
+
+         ! Fluxes
+         DO jn = 1, jpdia2dsed
+            cltra  = seddia2d(jn)   ! short title for 2D diagnostic
+            cltral = seddia2l(jn)   ! long title for 2D diagnostic
+            cltrau = seddia2u(jn)   ! UNIT for 2D diagnostic
+            
+            CALL histdef( nised, cltra,cltral,cltrau, jpi, jpj, nhorised, &
+               &          1, 1, 1, -99, 32, clop, zsto, zout )
+         ENDDO
+
+
+         CALL histend( nised )
+
+         WRITE(numsed,*)
+         WRITE(numsed,*) 'End of NetCDF sediment output file Initialization'
+
+       ENDIF
+
+       ! Start writing data
+       ! ---------------------
+       DO jn = 1, jptrased
+          cltra = sedtrcd(jn) ! short title for 3D diagnostic
+          CALL histwrite( nised, cltra, it, trcsedi(:,:,:,jn), ndimt52, ndext52 )
+       END DO
+
+       DO jn = 1, jpdia3dsed
+          cltra = seddia3d(jn) ! short title for 3D diagnostic
+          CALL histwrite( nised, cltra, it, flxsedi3d(:,:,:,jn), ndimt52, ndext52 )
+       END DO
+
+       DO jn = 1, jpdia2dsed
+             cltra = seddia2d(jn) ! short title for 2D diagnostic
+             CALL histwrite( nised, cltra, it, flxsedi2d(:,:,jn  ), ndimt51, ndext51 )
+       END DO
+
+
+      ! 3. Closing all files
+      ! --------------------
+      IF( kt == nitsedend  ) THEN
+          CALL histclo( nised )
+      ENDIF
+
+      DEALLOCATE( zdta )    ;   DEALLOCATE( zflx )
+
+   END SUBROUTINE sed_wri
+
+#else
+   !!======================================================================
+   !! MODULE sedwri  :   Dummy module
+   !!======================================================================
+CONTAINS
+   SUBROUTINE sed_wri( kt )         ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'sed_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE sed_wri
+
+   !!======================================================================
+#endif
+
+END MODULE sedwri
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_cen2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_cen2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_cen2.F90	(revision 1844)
@@ -0,0 +1,516 @@
+MODULE trcadv_cen2
+   !!======================================================================
+   !!                       ***  MODULE  trcadv_cen2  ***
+   !! Ocean passive tracers:  horizontal & vertical advective tracer trend
+   !!======================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_adv_cen2 : update the tracer trend with the horizontal
+   !!                  and vertical advection trends using a 2nd order 
+   !!                  centered finite difference scheme
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE trcbbl              ! advective passive tracers in the BBL
+   USE prtctl_trc
+   USE trdmld_trc
+   USE trdmld_trc_oce          ! ocean variables trends
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_adv_cen2    ! routine called by trcstp.F90
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   upsmsk    !: mixed upstream/centered scheme near some straits
+   !                                                   !  and in closed seas (orca 2 and 4 configurations)
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!   Default option :             2nd order centered scheme (k-j-i loop)
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE trc_adv_cen2( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_adv_cen2  ***
+      !!                 
+      !! ** Purpose :   Compute the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations.
+      !!
+      !! ** Method  :   The advection is evaluated by a second order centered
+      !!      scheme using now fields (leap-frog scheme). In specific areas
+      !!      (vicinity of major river mouths, some straits, or where tn is
+      !!      is approaching the freezing point) it is mixed with an upstream
+      !!      scheme for stability reasons.
+      !!        Part 0 : compute the upstream / centered flag
+      !!                 (3D array, zind, defined at T-point (0<zind<1))
+      !!        Part I : horizontal advection
+      !!      * centered flux:
+      !!         * s-coordinate (ln_sco=T) or
+      !!         * z-coordinate with partial steps (ln_zps=T),
+      !!        the vertical scale factors e3. are inside the derivatives:
+      !!               zcenu = e2u*e3u  un  mi(tn)
+      !!               zcenv = e1v*e3v  vn  mj(tn)
+      !!         * z-coordinate (default key), e3t=e3u=e3v:
+      !!               zcenu = e2u  un  mi(tn)
+      !!               zcenv = e1v  vn  mj(tn)
+      !!      * horizontal advective trend (divergence of the fluxes)
+      !!         * s-coordinate (ln_sco=T) or
+      !!         * z-coordinate with partial steps (ln_zps=T)
+      !!               ztra = 1/(e1t*e2t*e3t) { di-1[zwx] + dj-1[zwy] }
+      !!         * z-coordinate (default key), e3t=e3u=e3v:
+      !!               ztra = 1/(e1t*e2t) { di-1[zwx] + dj-1[zwy] }
+      !!      * Add this trend now to the general trend of tracer tra:
+      !!              tra = tra + ztra
+      !!      * trend diagnostic ('key_trdmld_trc'): the trend is saved
+      !!      for diagnostics. The trends saved is expressed as
+      !!      Uh.gradh(T)
+      !!
+      !!         Part II : vertical advection
+      !!      For any tracer  the advective trend is computed as follows :
+      !!            ztra = 1/e3t dk+1[ zwz ]
+      !!      where the vertical advective flux, zwz, is given by :
+      !!            zwz = zcofk * zupst + (1-zcofk) * zcent
+      !!      with 
+      !!        zupsv = upstream flux = wn * (trb(k) or trb(k-1) ) [wn>0 or <0]
+      !!        zcenu = centered flux = wn * mk(trn)
+      !!         The surface boundary condition is : 
+      !!      variable volume : zero advective flux
+      !!      fixed    volume ("default option) : wn(:,:,1) * trn(:,:,1)
+      !!         Add this trend now to the general trend of tracer tra :
+      !!            tra = tra + ztra
+      !!         Trend diagnostic ('key_trdmld_trc'): the trend is saved for
+      !!      diagnostics. The trends saved is expressed as :
+      !!             save trend =  w.gradz(T) = ztra - trn divn.
+      !!
+      !! ** Action : - update tra with the now advective tracer trends
+      !!             - save the trends in trtrd ('key_trdmld_trc')
+      !!
+      !! History :
+      !!   8.2  !  01-08  (M-A Filiberti, and M.Levy)  trahad+trazad = traadv 
+      !!   8.5  !  02-06  (G. Madec, C. Ethe)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE oce_trc            , zwx => ua,  &  ! use ua as workspace
+         &                     zwy => va      ! use va as workspace
+#if defined key_trcbbl_adv
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  &  ! temporary arrays
+         &         zun, zvn, zwn
+#else
+      USE oce_trc            , zun => un,  &  ! When no bbl, zun == un
+         &                     zvn => vn,  &  ! When no bbl, zvn == vn
+         &                     zwn => wn      ! When no bbl, zwn == wn
+#endif
+
+ 
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+ 
+      !! * Local save
+      REAL(wp), DIMENSION(jpi,jpj), SAVE ::   &
+         zbtr2
+ 
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk, jn             ! dummy loop indices
+      REAL(wp) ::                           &
+         zbtr, ztra, zfui, zfvj,            &  ! temporary scalars
+         zhw, ze3tr, zcofi, zcofj,          &  !    "         "
+         zupsut, zupsvt,                    &  !    "         "
+         zfp_ui, zfp_vj, zfm_ui, zfm_vj,    &  !    "         "
+         zcofk, zupst, zcent,               &  !    "         "
+         zfp_w, zfm_w,                      &  !    "         "
+         zcenut, zcenvt                        ! 
+
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zind                              ! temporary workspace arrays
+
+      REAL(wp) ::                           &
+         ztai, ztaj,                        &  ! temporary scalars
+         zfui1, zfvj1                          !    "         "
+
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+#if defined key_lim3 || defined key_lim2
+      REAL(wp) ::                           &
+         ztfreez                               ! freezing point
+#endif
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_adv_cen2 : 2nd order centered advection scheme'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~   Vector optimization case'
+         IF(lwp) WRITE(numout,*)
+ 
+         upsmsk(:,:) = 0.e0                              ! not upstream by default
+         IF( cp_cfg == "orca" )   CALL ups_orca_set      ! set mixed Upstream/centered scheme near some straits
+         !                                               ! and in closed seas (orca2 and orca4 only)
+         zbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+      ENDIF
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+#if defined key_trcbbl_adv
+
+      ! Advective bottom boundary layer 
+      ! -------------------------------
+      zun(:,:,:) = un(:,:,:) - u_trc_bbl(:,:,:)
+      zvn(:,:,:) = vn(:,:,:) - v_trc_bbl(:,:,:)
+      zwn(:,:,:) = wn(:,:,:) + w_trc_bbl(:,:,:)
+#endif
+
+      ! Upstream / centered scheme indicator
+      ! ------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#if defined key_lim3 || defined key_lim2
+               ztfreez = ( - 0.0575 + 1.710523e-3 * SQRT( sn(ji,jj,1) )   &
+                 &                  - 2.154996e-4 *       sn(ji,jj,1)   ) * sn(ji,jj,1)
+
+               zind(ji,jj,jk) = MAX (   &
+                  rnfmsk(ji,jj) * rnfmsk_z(jk),      &  ! near runoff mouths (& closed sea outflows)
+                  upsmsk(ji,jj)                      &  ! some of some straits
+                  !                                     ! below ice covered area (if tn < "freezing"+0.1 )
+                  , MAX(  0., SIGN( 1., ztfreez + 0.1 - tn(ji,jj,jk) )  ) * tmask(ji,jj,jk)   &
+                  &                  )
+
+#else
+               zind(ji,jj,jk) = MAX (   &
+                  rnfmsk(ji,jj) * rnfmsk_z(jk),      &  ! near runoff mouths (& closed sea outflows)
+                  upsmsk(ji,jj)                      &  ! some of some straits
+                  &                  )
+#endif
+            END DO
+         END DO
+      END DO
+
+
+
+      DO jn = 1, jptra
+         ! I. Horizontal advective fluxes
+         ! ------------------------------
+         
+         ! Second order centered tracer flux at u and v-points
+         
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+               ! upstream indicator
+                  zcofi = MAX( zind(ji+1,jj,jk), zind(ji,jj,jk) )
+                  zcofj = MAX( zind(ji,jj+1,jk), zind(ji,jj,jk) )
+                  ! volume fluxes * 1/2
+#if ! defined key_zco
+                  zfui = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * zun(ji,jj,jk)
+                  zfvj = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * zvn(ji,jj,jk)
+#else
+                  zfui = 0.5 * e2u(ji,jj) * zun(ji,jj,jk)
+                  zfvj = 0.5 * e1v(ji,jj) * zvn(ji,jj,jk)
+#endif
+               ! upstream scheme
+                  zfp_ui = zfui + ABS( zfui )
+                  zfp_vj = zfvj + ABS( zfvj )
+                  zfm_ui = zfui - ABS( zfui )
+                  zfm_vj = zfvj - ABS( zfvj )
+                  zupsut = zfp_ui * trb(ji,jj,jk,jn) + zfm_ui * trb(ji+1,jj  ,jk,jn)
+                  zupsvt = zfp_vj * trb(ji,jj,jk,jn) + zfm_vj * trb(ji  ,jj+1,jk,jn)
+                  ! centered scheme
+                  zcenut = zfui * ( trn(ji,jj,jk,jn) + trn(ji+1,jj  ,jk,jn) )
+                  zcenvt = zfvj * ( trn(ji,jj,jk,jn) + trn(ji  ,jj+1,jk,jn) )
+                  ! mixed centered / upstream scheme
+                  zwx(ji,jj,jk) = zcofi * zupsut + (1.-zcofi) * zcenut
+                  zwy(ji,jj,jk) = zcofj * zupsvt + (1.-zcofj) * zcenvt                
+               END DO
+            END DO
+
+
+            ! 2. Tracer flux divergence at t-point added to the general trend
+            ! -------------------------
+
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+                  zbtr = zbtr2(ji,jj) / fse3t(ji,jj,jk)
+#else
+                  zbtr = zbtr2(ji,jj) 
+#endif
+                  ! horizontal advective trends
+                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk)   &
+                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk)  )
+
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+
+#if defined key_trc_diatrd
+                  ! recompute the trends in i- and j-direction as Uh gradh(T)
+# if ! defined key_zco
+                  zfui = 0.5 * e2u(ji  ,jj) * fse3u(ji,  jj,jk) * zun(ji,  jj,jk)
+                  zfui1= 0.5 * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zun(ji-1,jj,jk)
+                  zfvj = 0.5 * e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * zvn(ji,jj  ,jk)
+                  zfvj1= 0.5 * e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * zvn(ji,jj-1,jk)
+# else
+                  zfui = 0.5 * e2u(ji  ,jj) * zun(ji,  jj,jk)
+                  zfui1= 0.5 * e2u(ji-1,jj) * zun(ji-1,jj,jk)
+                  zfvj = 0.5 * e1v(ji,jj  ) * zvn(ji,jj  ,jk)
+                  zfvj1= 0.5 * e1v(ji,jj-1) * zvn(ji,jj-1,jk)
+# endif
+                  ztai = - zbtr * ( zfui  * ( trn(ji+1,jj  ,jk,jn) - trn(ji,  jj,jk,jn) )   &
+                     &                + zfui1 * ( trn(ji,  jj,  jk,jn) - trn(ji-1,jj,jk,jn) ) )
+                  ztaj = - zbtr * ( zfvj  * ( trn(ji  ,jj+1,jk,jn) - trn(ji,jj  ,jk,jn) )    &
+                     &                + zfvj1 * ( trn(ji  ,jj  ,jk,jn) - trn(ji,jj-1,jk,jn) ) )
+                  ! save i- and j- advective trends computed as Uh gradh(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = ztai
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = ztaj
+#endif
+
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+
+         ! 3. Save the horizontal advective trends for diagnostics
+         ! -------------------------------------------------------
+         TRDTRC_XY : IF( l_trdtrc )THEN
+
+            ! 3.1) Passive tracer ZONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ! recompute the trends in i-direction as Uh gradh(T)
+# if  ! defined key_zco
+                     zbtr = zbtr2(ji,jj) / fse3t(ji,jj,jk)
+                     zfui = 0.5 * e2u(ji  ,jj) * fse3u(ji,  jj,jk) * zun(ji,  jj,jk)
+                     zfui1= 0.5 * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zun(ji-1,jj,jk)
+# else
+                     zbtr = zbtr2(ji,jj)
+                     zfui = 0.5 * e2u(ji  ,jj) * zun(ji,  jj,jk)
+                     zfui1= 0.5 * e2u(ji-1,jj) * zun(ji-1,jj,jk)
+# endif
+                     ztai = - zbtr * ( zfui  * ( trn(ji+1,jj  ,jk,jn) - trn(ji,  jj,jk,jn) )    &
+                          &          + zfui1 * ( trn(ji,  jj,  jk,jn) - trn(ji-1,jj,jk,jn) ) )
+
+                     ! save i- and j- advective trends computed as Uh gradh(T)
+                     ztrtrd(ji,jj,jk) = ztai
+                  END DO
+               END DO
+            END DO
+
+            IF( luttrd(jn) ) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_xad, kt)   ! handle the trend
+
+            ! 3.2)  Passive tracer MERIDIONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ! recompute the trends in j-direction as Uh gradh(T)
+# if ! defined key_zco
+                     zbtr = zbtr2(ji,jj) / fse3t(ji,jj,jk)
+                     zfvj = 0.5 * e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * zvn(ji,jj  ,jk)
+                     zfvj1= 0.5 * e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * zvn(ji,jj-1,jk)
+# else
+                     zbtr = zbtr2(ji,jj)
+                     zfvj = 0.5 * e1v(ji,jj  ) * zvn(ji,jj  ,jk)
+                     zfvj1= 0.5 * e1v(ji,jj-1) * zvn(ji,jj-1,jk)
+# endif
+                     ztaj = - zbtr * ( zfvj  * ( trn(ji  ,jj+1,jk,jn) - trn(ji,jj  ,jk,jn) )    &
+                          &          + zfvj1 * ( trn(ji  ,jj  ,jk,jn) - trn(ji,jj-1,jk,jn) ) )
+
+                     ! save i- and j- advective trends computed as Uh gradh(T)
+                     ztrtrd(ji,jj,jk) = ztaj
+                  END DO
+               END DO
+            END DO
+
+            IF( luttrd(jn) ) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_yad, kt)   ! handle the trend
+
+         ENDIF TRDTRC_XY
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('centered2 - had')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+      
+      ! II. Vertical advection
+      ! ----------------------
+      DO jn = 1, jptra
+
+         ! Bottom value : flux set to zero
+         zwx(:,:,jpk) = 0.e0 
+
+         ! Surface value
+         IF ( lk_vvl ) THEN
+            ! variable volume: flux set to zero
+            zwx(:,:, 1 ) = 0.e0  
+         ELSE
+            ! free surface-constant volume
+            zwx(:,:, 1 ) = zwn(:,:,1) * trn(:,:,1,jn)
+         ENDIF
+
+         ! 1. Vertical advective fluxes
+         ! ----------------------------
+
+         ! Second order centered tracer flux at w-point
+
+         DO jk = 2, jpk
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! upstream indicator
+                  zcofk = MAX( zind(ji,jj,jk-1), zind(ji,jj,jk) )
+                  ! velocity * 1/2
+                  zhw = 0.5 * zwn(ji,jj,jk)
+                  ! upstream scheme
+                  zfp_w = zhw + ABS( zhw )
+                  zfm_w = zhw - ABS( zhw )
+                  zupst = zfp_w * trb(ji,jj,jk,jn) + zfm_w * trb(ji,jj,jk-1,jn)
+                  ! centered scheme
+                  zcent = zhw * ( trn(ji,jj,jk,jn) + trn(ji,jj,jk-1,jn) )
+                  ! centered scheme
+                  zwx(ji,jj,jk) = zcofk * zupst + (1.-zcofk) * zcent
+               END DO
+            END DO
+         END DO
+
+
+         ! 2. Tracer flux divergence at t-point added to the general trend
+         ! -------------------------
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ze3tr = 1. / fse3t(ji,jj,jk)
+                  ! vertical advective trends
+                  ztra = - ze3tr * ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) =  tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! save the vertical advective trends computed as w gradz(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+#endif
+
+               END DO
+            END DO
+         END DO
+
+         ! 3. Save the vertical advective trends for diagnostic 
+         ! ----------------------------------------------------
+
+         TRDTRC_Z : IF( l_trdtrc )THEN
+            ztrtrd(:,:,:) = 0.e0
+
+            ! Compute T/S vertical advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ze3tr = 1. / fse3t(ji,jj,jk)
+                     ! vertical advective trends 
+                     ztra = - ze3tr * ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) )
+                     ! save the vertical advective trends computed as w gradz(T)
+                     ztrtrd(ji,jj,jk) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+
+            IF( luttrd(jn) ) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zad, kt)  ! handle the trend
+
+         ENDIF TRDTRC_Z
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('centered - zad')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_adv_cen2
+
+   SUBROUTINE ups_orca_set
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ups_orca_set  ***
+      !!
+      !! ** Purpose :   add a portion of upstream scheme in area where the
+      !!                centered scheme generates too strong overshoot
+      !!
+      !! ** Method  :   orca (R4 and R2) confiiguration setting. Set upsmsk
+      !!                array to nozero value in some straith.
+      !!
+      !! ** Action : - upsmsk set to 1 at some strait, 0 elsewhere for orca
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers
+      !!----------------------------------------------------------------------
+
+      ! mixed upstream/centered scheme near river mouths
+      ! ------------------------------------------------
+      SELECT CASE ( jp_cfg )
+      !                                        ! =======================
+      CASE ( 4 )                               !  ORCA_R4 configuration
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ii0 =  70   ;   ii1 =  71
+         ij0 =  52   ;   ij1 =  53   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !
+         !                                     ! =======================
+      CASE ( 2 )                               !  ORCA_R2 configuration
+         !                                     ! =======================
+         !                                          ! Gibraltar Strait
+         ij0 = 102   ;   ij1 = 102
+         ii0 = 138   ;   ii1 = 138   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.20
+         ii0 = 139   ;   ii1 = 139   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 140   ;   ii1 = 140   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 = 101   ;   ij1 = 102
+         ii0 = 141   ;   ii1 = 141   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !                                          ! Bab el Mandeb Strait
+         ij0 =  87   ;   ij1 =  88
+         ii0 = 164   ;   ii1 = 164   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.10
+         ij0 =  88   ;   ij1 =  88
+         ii0 = 163   ;   ii1 = 163   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ii0 = 162   ;   ii1 = 162   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+         ii0 = 160   ;   ii1 = 161   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         ij0 =  89   ;   ij1 =  89
+         ii0 = 158   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         ij0 =  90   ;   ij1 =  90
+         ii0 = 160   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
+         !                                          ! Sound Strait
+         ij0 = 116   ;   ij1 = 116
+         ii0 = 145   ;   ii1 = 147   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
+         !
+      END SELECT
+
+   END SUBROUTINE ups_orca_set
+
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_adv_cen2( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_adv_cen2: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_adv_cen2
+#endif
+   !!======================================================================
+END MODULE trcadv_cen2
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl.F90	(revision 1844)
@@ -0,0 +1,420 @@
+MODULE trcadv_muscl
+   !!==============================================================================
+   !!                       ***  MODULE  trcadv_muscl  ***
+   !! Ocean passive tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_adv_muscl : update the tracer trend with the horizontal
+   !!                   and vertical advection trends using MUSCL scheme
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE trcbbl          ! advective passive tracers in the BBL
+   USE lib_mpp
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce          ! ocean variables trends
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_adv_muscl  ! routine called by trcstp.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcadv_muscl.F90,v 1.13 2007/10/12 09:26:30 opalod Exp $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_adv_muscl( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE trc_adv_muscl  ***
+      !!          
+      !! ** Purpose :   Compute the now trend due to total advection of any pas-
+      !!      sive tracer using a MUSCL scheme (Monotone Upstream-centered Scheme
+      !!      for Conservation Laws) and add it to the general tracer trend.
+      !!
+      !! ** Method  :
+      !!
+      !! ** Action  : - update tra with the now advective tracer trends
+      !!              - save trends ('key_trdmld_trc')
+      !!
+      !! References :                
+      !!      Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
+      !!	IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
+      !!
+      !! History :
+      !!        !  06-00  (A.Estublier)  for passive tracers
+      !!   9.0  !  03-04  (C. Ethe, G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * modules used
+#if defined key_trcbbl_adv
+      USE oce_trc            , zun => ua,  &  ! use ua as workspace
+         &                     zvn => va      ! use va as workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwn
+#else
+      USE oce_trc            , zun => un,  &  ! When no bbl, zun == un
+                               zvn => vn,  &  !              zvn == vn
+                               zwn => wn      !              zwn == wn
+#endif
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk,jn            ! dummy loop indices
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   &
+         zt1, zt2, ztp1, ztp2
+
+      REAL(wp) ::   zu, zv, zw, zeu, zev, zew, zbtr, ztra
+      REAL(wp) ::   z0u, z0v, z0w
+      REAL(wp) ::   zzt1, zzt2, zalpha, z2dtt
+      REAL(wp) ::   zfui, zfvj
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+#if defined key_trc_diatrd
+      REAL(wp) ::   ztai, ztaj
+#endif
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+
+      IF( kt == nittrc000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_adv : MUSCL advection scheme'
+         WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+       IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+#if defined key_trcbbl_adv
+      ! Advective bottom boundary layer
+      ! -------------------------------
+      zun(:,:,:) = un (:,:,:) - u_trc_bbl(:,:,:)
+      zvn(:,:,:) = vn (:,:,:) - v_trc_bbl(:,:,:)
+      zwn(:,:,:) = wn (:,:,:) + w_trc_bbl(:,:,:)
+#endif
+
+ 
+
+      DO jn = 1, jptra
+
+         ! I. Horizontal advective fluxes
+         ! ------------------------------
+
+         ! first guess of the slopes
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1      
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zt1(ji,jj,jk) = umask(ji,jj,jk) * ( trb(ji+1,jj,jk,jn) - trb(ji,jj,jk,jn) )
+                  zt2(ji,jj,jk) = vmask(ji,jj,jk) * ( trb(ji,jj+1,jk,jn) - trb(ji,jj,jk,jn) )
+               END DO
+            END DO
+         END DO
+         ! bottom values
+         zt1(:,:,jpk) = 0.e0
+         zt2(:,:,jpk) = 0.e0
+
+         ! lateral boundary conditions on zt1, zt2
+         CALL lbc_lnk( zt1, 'U', -1. )   
+         CALL lbc_lnk( zt2, 'V', -1. ) 
+
+
+         ! Slopes
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji-1,jj  ,jk) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji-1,jj  ,jk) ) )
+                  ztp2(ji,jj,jk) =                    ( zt2(ji,jj,jk) + zt2(ji  ,jj-1,jk) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt2(ji,jj,jk) * zt2(ji  ,jj-1,jk) ) )
+               END DO
+            END DO
+         END DO
+         ! bottom values
+         ztp1(:,:,jpk) = 0.e0
+         ztp2(:,:,jpk) = 0.e0
+
+         ! Slopes limitation
+         DO jk = 1, jpkm1
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp1(ji  ,jj,jk) ),   &
+                     &                  2.*ABS( zt1 (ji-1,jj,jk) ),   &
+                     &                  2.*ABS( zt1 (ji  ,jj,jk) ) )
+
+                  ztp2(ji,jj,jk) = SIGN( 1., ztp2(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp2(ji,jj  ,jk) ),   &
+                     &                  2.*ABS( zt2 (ji,jj-1,jk) ),   &
+                     &                  2.*ABS( zt2 (ji,jj  ,jk) ) )
+
+               END DO
+            END DO
+         END DO
+
+         ! Advection terms
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! volume fluxes
+#if ! defined key_zco
+                  zeu = e2u(ji,jj) * fse3u(ji,jj,jk) * zun(ji,jj,jk)
+                  zev = e1v(ji,jj) * fse3v(ji,jj,jk) * zvn(ji,jj,jk)
+#else
+                  zeu = e2u(ji,jj) * zun(ji,jj,jk)
+                  zev = e1v(ji,jj) * zvn(ji,jj,jk)
+#endif
+                  ! MUSCL fluxes
+                  z2dtt = rdttra(jk) * FLOAT(ndttrc)
+                  z0u = SIGN( 0.5, zun(ji,jj,jk) )            
+                  zalpha = 0.5 - z0u
+                  zu  = z0u - 0.5 * zun(ji,jj,jk) * z2dtt / e1u(ji,jj)
+                  zzt1 = trb(ji+1,jj,jk,jn) + zu*ztp1(ji+1,jj,jk)
+                  zzt2 = trb(ji  ,jj,jk,jn) + zu*ztp1(ji  ,jj,jk)
+                  zt1(ji,jj,jk) = zeu * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+                  z0v = SIGN( 0.5, zvn(ji,jj,jk) )            
+                  zalpha = 0.5 - z0v
+                  zv  = z0v - 0.5 * zvn(ji,jj,jk) * z2dtt / e2v(ji,jj)
+                  zzt1 = trb(ji,jj+1,jk,jn) + zv*ztp2(ji,jj+1,jk)
+                  zzt2 = trb(ji,jj  ,jk,jn) + zv*ztp2(ji,jj  ,jk)
+                  zt2(ji,jj,jk) = zev * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+               END DO
+            END DO
+         END DO
+
+         ! lateral boundary conditions on zt1, zt2 (changed sign)
+         CALL lbc_lnk( zt1, 'U', -1. ) 
+         CALL lbc_lnk( zt2, 'V', -1. ) 
+
+         ! Compute and add the horizontal advective trend
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+#else
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+#endif
+                  ! horizontal advective trends
+                  ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk  )   &
+                     &            + zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk  ) )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! recompute the trends in i- and j-direction as Uh gradh(T)
+#   if ! defined key_zco
+                  zfui =  e2u(ji  ,jj) * fse3u(ji,  jj,jk) * un(ji,  jj,jk)   &
+                     & -  e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * un(ji-1,jj,jk)
+                  zfvj =  e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * vn(ji,jj  ,jk)   &
+                     & -  e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk)
+#   else
+                  zfui = e2u(ji  ,jj) * un(ji,  jj,jk)   &
+                     & - e2u(ji-1,jj) * un(ji-1,jj,jk)
+                  zfvj = e1v(ji,jj  ) * vn(ji,jj  ,jk)   &
+                     & - e1v(ji,jj-1) * vn(ji,jj-1,jk)
+#   endif
+                  ztai =-zbtr * (  zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk) - trn(ji,jj,jk,jn) * zfui  )
+                  ztaj =-zbtr * (  zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk) - trn(ji,jj,jk,jn) * zfvj  )
+                  ! save i- and j- advective trends computed as Uh gradh(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = ztai
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = ztaj
+#endif
+
+               END DO
+            END DO
+         END DO
+
+         ! 3. Save the horizontal advective trends for diagnostics
+         ! -------------------------------------------------------
+         TRDTRC_XY : IF( l_trdtrc ) THEN
+
+            ! 3.1) Passive tracer ZONAL advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     zfui = e2u(ji  ,jj) * fse3u(ji,  jj,jk) * zun(ji,  jj,jk)   &
+                        & - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * zun(ji-1,jj,jk)
+#else
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                     zfui = e2u(ji  ,jj) * zun(ji,  jj,jk)  - e2u(ji-1,jj) * zun(ji-1,jj,jk)
+#endif
+                     ! recompute the trends in i- direction as Uh gradh(T)
+                     ztrtrd(ji,jj,jk) = - zbtr*( zt1(ji,jj,jk) - zt1(ji-1,jj,jk) - trn(ji,jj,jk,jn)*zfui )
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_xad, kt )
+
+            ! 3.2)  Passive tracer MERIDIONAL advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ! recompute the trends in i- and j-direction as Uh gradh(T)
+#if ! defined key_zco
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     zfvj = e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * zvn(ji,jj  ,jk)   &
+                        & - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * zvn(ji,jj-1,jk)
+#else
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                     zfvj = e1v(ji,jj  ) * zvn(ji,jj  ,jk) - e1v(ji,jj-1) * zvn(ji,jj-1,jk)
+#endif
+                     ztrtrd(ji,jj,jk) = - zbtr*( zt2(ji,jj,jk) - zt2(ji,jj-1,jk) - trn(ji,jj,jk,jn)*zfvj )
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_yad, kt )
+
+         ENDIF TRDTRC_XY
+
+      ENDDO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('muscl - had')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+         ! II. Vertical advective fluxes
+         ! -----------------------------
+
+      DO jn = 1, jptra
+         ! First guess of the slope
+         ! interior values
+         DO jk = 2, jpkm1
+            zt1(:,:,jk) = tmask(:,:,jk) * ( trb(:,:,jk-1,jn) - trb(:,:,jk,jn) )
+         END DO
+         ! surface and bottom boundary conditions
+         zt1 (:,:, 1 ) = 0.e0 
+         zt1 (:,:,jpk) = 0.e0
+         ! Slopes
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji,jj,jk+1) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji,jj,jk+1) ) )
+               END DO
+            END DO
+         END DO
+
+         ! Slopes limitation
+         ! interior values
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp1(ji,jj,jk  ) ),   &
+                     &                  2.*ABS( zt1 (ji,jj,jk+1) ),   &
+                     &                  2.*ABS( zt1 (ji,jj,jk  ) ) )
+               END DO
+            END DO
+         END DO
+         ! surface values
+         ztp1(:,:,1) = 0. 
+         ! vertical advective flux
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2dtt = rdttra(jk) * FLOAT(ndttrc)
+                  zew = zwn(ji,jj,jk+1)
+                  z0w = SIGN( 0.5, zwn(ji,jj,jk+1) )
+                  zalpha = 0.5 + z0w
+                  zw  = z0w - 0.5 * zwn(ji,jj,jk+1)*z2dtt / fse3w(ji,jj,jk+1)
+                  zzt1 = trb(ji,jj,jk+1,jn) + zw*ztp1(ji,jj,jk+1)
+                  zzt2 = trb(ji,jj,jk  ,jn) + zw*ztp1(ji,jj,jk  )
+                  zt1(ji,jj,jk+1) = zew * ( zalpha * zzt1 + (1.-zalpha)*zzt2 )
+               END DO
+            END DO
+         END DO
+         ! surface values
+         IF( lk_vvl ) THEN
+            ! variable volume: flux set to zero
+            zt1(:,:, 1 ) = 0.e0
+         ELSE
+            ! free surface-constant volume
+            zt1(:,:, 1 ) = zwn(:,:,1) * trb(:,:,1,jn)
+         ENDIF
+
+         ! bottom values
+         zt1(:,:,jpk) = 0.e0
+
+         ! Compute & add the vertical advective trend
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / fse3t(ji,jj,jk)
+                  ! horizontal advective trends
+                  ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) =  tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! save the vertical advective trends computed as w gradz(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+#endif
+
+               END DO
+            END DO
+         END DO
+
+         ! 3. Save the vertical advective trends for diagnostic
+         ! ----------------------------------------------------
+         TRDTRC_Z : IF( l_trdtrc )THEN
+
+            ! Compute T/S vertical advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr = 1. / fse3t(ji,jj,jk)
+                     ! horizontal advective trends
+                     ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+                     ! save the vertical advective trends computed as w gradz(T)
+                     ztrtrd(ji,jj,jk) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zad, kt)
+
+         END IF TRDTRC_Z
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('muscl - zad')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+END SUBROUTINE trc_adv_muscl
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_adv_muscl( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_adv_muscl: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_adv_muscl
+#endif
+
+   !!======================================================================
+END MODULE trcadv_muscl
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl2.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl2.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_muscl2.F90	(revision 1844)
@@ -0,0 +1,499 @@
+MODULE trcadv_muscl2
+   !!==============================================================================
+   !!                       ***  MODULE  trcadv_muscl2  ***
+   !! Ocean passive tracers:  horizontal & vertical advective trend
+   !!==============================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   tra_adv_muscl2 : update the tracer trend with the horizontal
+   !!                    and vertical advection trends using MUSCL2 scheme
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE trcbbl          ! advective passive tracers in the BBL
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce          ! ocean variables trends
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_adv_muscl2        ! routine called by trcstp.F90
+
+   !! * Module variable
+   REAL(wp), DIMENSION(jpk) ::   &
+      rdttrc                     ! vertical profile of tracer time-step
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_adv_muscl2( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_adv_muscl2  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to total advection of passi-
+      !!      ve tracer using a MUSCL scheme (Monotone Upstream-
+      !!      Centered Scheme for Conservation Laws) and add it to the general
+      !!      tracer trend.
+      !!
+      !! ** Method : MUSCL scheme plus centered scheme at ocean boundaries
+      !!
+      !! ** Action : - update tra with the now advective tracer trends
+      !!             - save trends ('key_trdmld_trc')
+      !!
+      !! References :                
+      !!      Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
+      !!	IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
+      !!
+      !! History :
+      !!        !  06-00  (A.Estublier)  for passive tracers
+      !!   9.0  !  03-04  (C. Ethe, G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * modules used
+#if defined key_trcbbl_adv
+      USE oce_trc            , zun => ua,  &  ! use ua as workspace
+         &                     zvn => va      ! use va as workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwn
+#else
+      USE oce_trc            , zun => un,  &  ! When no bbl, zun == un
+                               zvn => vn,  &  !              zvn == vn
+                               zwn => wn      !              zwn == wn
+#endif
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt         ! ocean time-step
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk,jn               ! dummy loop indices
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   &
+         zt1, zt2, ztp1, ztp2
+      REAL(wp) ::   zu, zv, zw, zeu, zev, zew, zbtr, ztra
+      REAL(wp) ::   z0u, z0v, z0w
+      REAL(wp) ::   zzt1, zzt2, zalpha
+      REAL(wp) ::   zfui, zfvj
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+#if defined key_trc_diatrd
+      REAL(wp) ::   ztai, ztaj
+#endif
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_adv_muscl2 : MUSCL2 advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+         rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)
+      ENDIF
+      
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+#if defined key_trcbbl_adv        
+      ! Advective bottom boundary layer
+      ! -------------------------------
+      zun(:,:,:) = un (:,:,:) - u_trc_bbl(:,:,:)
+      zvn(:,:,:) = vn (:,:,:) - v_trc_bbl(:,:,:)
+      zwn(:,:,:) = wn (:,:,:) + w_trc_bbl( :,:,:)
+#endif
+
+
+      DO jn = 1, jptra
+
+         ! I. Horizontal advective fluxes
+         ! ------------------------------
+
+         ! first guess of the slopes
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1      
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zt1(ji,jj,jk) = umask(ji,jj,jk) * ( trb(ji+1,jj,jk,jn) - trb(ji,jj,jk,jn) )
+                  zt2(ji,jj,jk) = vmask(ji,jj,jk) * ( trb(ji,jj+1,jk,jn) - trb(ji,jj,jk,jn) )
+               END DO
+            END DO
+         END DO
+         ! bottom values
+         zt1(:,:,jpk) = 0.e0
+         zt2(:,:,jpk) = 0.e0
+
+         ! lateral boundary conditions on zt1, zt2  (changed sign)
+         CALL lbc_lnk( zt1, 'U', -1. )
+         CALL lbc_lnk( zt2, 'V', -1. )
+
+         ! Slopes
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji-1,jj  ,jk) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji-1,jj  ,jk) ) )
+                  ztp2(ji,jj,jk) =                    ( zt2(ji,jj,jk) + zt2(ji  ,jj-1,jk) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt2(ji,jj,jk) * zt2(ji  ,jj-1,jk) ) )
+               END DO
+            END DO
+         END DO
+         ! bottom values
+         ztp1(:,:,jpk) = 0.e0 
+         ztp2(:,:,jpk) = 0.e0
+
+         ! Slopes limitation
+         DO jk = 1, jpkm1
+            DO jj = 2, jpj
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp1(ji  ,jj,jk) ),   &
+                     &                  2.*ABS( zt1 (ji-1,jj,jk) ),   &
+                     &                  2.*ABS( zt1 (ji  ,jj,jk) ) )
+
+                  ztp2(ji,jj,jk) = SIGN( 1., ztp2(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp2(ji,jj  ,jk) ),   &
+                     &                  2.*ABS( zt2 (ji,jj-1,jk) ),   &
+                     &                  2.*ABS( zt2 (ji,jj  ,jk) ) )
+               END DO
+            END DO
+         END DO
+
+         ! Advection terms
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! volume fluxes
+#if ! defined key_zco
+                  zeu = e2u(ji,jj) * fse3u(ji,jj,jk) * zun(ji,jj,jk)
+                  zev = e1v(ji,jj) * fse3v(ji,jj,jk) * zvn(ji,jj,jk)
+#else
+                  zeu = e2u(ji,jj) * zun(ji,jj,jk)
+                  zev = e1v(ji,jj) * zvn(ji,jj,jk)
+#endif
+                  ! MUSCL fluxes
+                  z0u = SIGN( 0.5, zun(ji,jj,jk) )            
+                  zalpha = 0.5 - z0u
+                  zu  = z0u - 0.5 * zun(ji,jj,jk) * rdttrc(jk) / e1u(ji,jj)
+                  zzt1 = trb(ji+1,jj,jk,jn) + zu*ztp1(ji+1,jj,jk)
+                  zzt2 = trb(ji  ,jj,jk,jn) + zu*ztp1(ji  ,jj,jk)
+                  zt1(ji,jj,jk) = zeu * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+
+                  z0v = SIGN( 0.5, zvn(ji,jj,jk) )            
+                  zalpha = 0.5 - z0v
+                  zv  = z0v - 0.5 * zvn(ji,jj,jk) * rdttrc(jk) / e2v(ji,jj)
+                  zzt1 = trb(ji,jj+1,jk,jn) + zv*ztp2(ji,jj+1,jk)
+                  zzt2 = trb(ji,jj  ,jk,jn) + zv*ztp2(ji,jj  ,jk)
+                  zt2(ji,jj,jk) = zev * ( zalpha * zzt1 + (1.-zalpha) * zzt2 )
+
+               END DO
+            END DO
+         END DO
+
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+                  zev = e1v(ji,jj) * fse3v(ji,jj,jk)
+                  IF( umask(ji,jj,jk) == 0. ) THEN
+                     IF( zun(ji+1,jj,jk) > 0. .AND. ji /= jpi ) THEN
+                        zt1(ji+1,jj,jk) = e2u(ji+1,jj)* fse3u(ji+1,jj,jk)   &
+                           &            * zun(ji+1,jj,jk) * ( trb(ji+1,jj,jk,jn) + trb(ji+2,jj,jk,jn) ) * 0.5
+                     ENDIF
+                     IF( zun(ji-1,jj,jk) < 0. ) THEN
+                        zt1(ji-1,jj,jk) = e2u(ji-1,jj)* fse3u(ji-1,jj,jk)   &
+                           &            * zun(ji-1,jj,jk) * ( trb(ji-1,jj,jk,jn) + trb(ji  ,jj,jk,jn) ) * 0.5
+                     ENDIF
+                  ENDIF
+                  IF( vmask(ji,jj,jk) == 0. ) THEN
+                     IF( zvn(ji,jj+1,jk) > 0. .AND. jj /= jpj ) THEN
+                        zt2(ji,jj+1,jk) = e1v(ji,jj+1) * fse3v(ji,jj+1,jk)   &
+                           &            * zvn(ji,jj+1,jk) * ( trb(ji,jj+1,jk,jn) + trb(ji,jj+2,jk,jn) ) * 0.5
+                     ENDIF
+                     IF( zvn(ji,jj-1,jk) < 0. ) THEN
+                        zt2(ji,jj-1,jk) = e1v(ji,jj-1)* fse3v(ji,jj-1,jk)   &
+                           &            * zvn(ji,jj-1,jk) * ( trb(ji,jj-1,jk,jn) + trb(ji  ,jj,jk,jn) ) * 0.5
+                     ENDIF
+                  ENDIF
+
+#else
+                  IF( umask(ji,jj,jk) == 0. ) THEN
+                     IF( zun(ji+1,jj,jk) > 0. .AND. ji /= jpi ) THEN
+                        zt1(ji+1,jj,jk) = e2u(ji+1,jj) * zun(ji+1,jj,jk) * ( trb(ji+1,jj,jk,jn) + trb(ji+2,jj,jk,jn) ) * 0.5
+                     ENDIF
+                     IF( zun(ji-1,jj,jk) < 0. ) THEN
+                        zt1(ji-1,jj,jk) = e2u(ji-1,jj) * zun(ji-1,jj,jk) * ( trb(ji-1,jj,jk,jn) + trb(ji  ,jj,jk,jn) ) * 0.5
+                     ENDIF
+                  ENDIF
+                  IF( vmask(ji,jj,jk) == 0. ) THEN
+                     IF( zvn(ji,jj+1,jk) > 0. .AND. jj /= jpj ) THEN
+                        zt2(ji,jj+1,jk) = e1v(ji,jj+1) * zvn(ji,jj+1,jk) * ( trb(ji,jj+1,jk,jn) + trb(ji,jj+2,jk,jn) ) * 0.5
+                     ENDIF
+                     IF( zvn(ji,jj-1,jk) < 0. ) THEN
+                        zt2(ji,jj-1,jk) = e1v(ji,jj-1) * zvn(ji,jj-1,jk) * ( trb(ji,jj-1,jk,jn) + trb(ji  ,jj,jk,jn) ) * 0.5
+                     ENDIF
+                  ENDIF
+#endif
+               END DO
+            END DO
+         END DO
+
+         ! lateral boundary conditions on zt1, zt2   (changed sign)
+         CALL lbc_lnk( zt1, 'U', -1. )
+         CALL lbc_lnk( zt2, 'V', -1. )
+
+         ! Compute and add the horizontal advective trend
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#if ! defined key_zco
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+#else
+                  zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+#endif
+                  ! horizontal advective trends
+                  ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk  )   &
+                     &            + zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk  ) )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! recompute the trends in i- and j-direction as Uh gradh(T)
+#   if ! defined key_zco
+                  zfui =  e2u(ji  ,jj) * fse3u(ji,  jj,jk) * un(ji,  jj,jk)   &
+                     & -  e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * un(ji-1,jj,jk)
+                  zfvj =  e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * vn(ji,jj  ,jk)   &
+                     & -  e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk)
+#   else
+                  zfui = e2u(ji  ,jj) * un(ji,  jj,jk)   &
+                     & - e2u(ji-1,jj) * un(ji-1,jj,jk)
+                  zfvj = e1v(ji,jj  ) * vn(ji,jj  ,jk)   &
+                     & - e1v(ji,jj-1) * vn(ji,jj-1,jk)
+#   endif
+                  ztai =-zbtr * (  zt1(ji,jj,jk) - zt1(ji-1,jj  ,jk) - trn(ji,jj,jk,jn) * zfui  )
+                  ztaj =-zbtr * (  zt2(ji,jj,jk) - zt2(ji  ,jj-1,jk) - trn(ji,jj,jk,jn) * zfvj  )
+                  ! save i- and j- advective trends computed as Uh gradh(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = ztai
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = ztaj
+
+#endif
+
+               END DO
+            END DO
+         END DO
+
+         ! 3. Save the horizontal advective trends for diagnostics
+         ! -------------------------------------------------------
+
+         TRDTRC_XY : IF( l_trdtrc ) THEN
+
+            ! 3.1) Passive tracer ZONAL advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.  
+#if ! defined key_zco
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     zfui = e2u(ji  ,jj) * fse3u(ji,  jj,jk) * un(ji,  jj,jk)   &
+                        & - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * un(ji-1,jj,jk)
+#else
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                     zfui = e2u(ji  ,jj) * un(ji,  jj,jk)   &
+                        & - e2u(ji-1,jj) * un(ji-1,jj,jk)
+#endif
+                     ! recompute the trends in i- direction as Uh gradh(T)
+                     ztrtrd(ji,jj,jk) = - zbtr*( zt1(ji,jj,jk) - zt1(ji-1,jj,jk) - trn(ji,jj,jk,jn)*zfui )
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_xad, kt )
+
+            ! 3.2)  Passive tracer MERIDIONAL advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ! recompute the trends in i- and j-direction as Uh gradh(T)
+#if ! defined key_zco
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     zfvj = e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * vn(ji,jj  ,jk)   &
+                        & - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk)
+#else
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) )
+                     zfvj = e1v(ji,jj  ) * vn(ji,jj  ,jk)   &
+                        & - e1v(ji,jj-1) * vn(ji,jj-1,jk)
+#endif
+                     ztrtrd(ji,jj,jk) = - zbtr*( zt2(ji,jj,jk) - zt2(ji,jj-1,jk) - trn(ji,jj,jk,jn)*zfvj )
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_yad, kt )
+
+         ENDIF TRDTRC_XY
+
+         !                           !=============
+      END DO                         ! tracer loop
+      !                              !=============
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('muscl2 - had')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+      ! II. Vertical advective fluxes
+      ! -----------------------------
+
+      DO jn = 1, jptra
+
+         ! First guess of the slope
+         ! interior values
+         DO jk = 2, jpkm1
+            zt1(:,:,jk) = tmask(:,:,jk) * ( trb(:,:,jk-1,jn) - trb(:,:,jk,jn) )
+         END DO
+         ! surface and bottom boundary conditions
+         zt1 (:,:, 1 ) = 0.e0 
+         zt1 (:,:,jpk) = 0.e0
+
+         ! Slopes
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztp1(ji,jj,jk) =                    ( zt1(ji,jj,jk) + zt1(ji,jj,jk+1) )   &
+                     &           * ( 0.25 + SIGN( 0.25, zt1(ji,jj,jk) * zt1(ji,jj,jk+1) ) )
+               END DO
+            END DO
+         END DO
+
+         ! Slopes limitation
+         ! interior values
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ztp1(ji,jj,jk) = SIGN( 1., ztp1(ji,jj,jk) )   &
+                     &           * MIN(    ABS( ztp1(ji,jj,jk  ) ),   &
+                     &                  2.*ABS( zt1 (ji,jj,jk+1) ),   &
+                     &                  2.*ABS( zt1 (ji,jj,jk  ) ) )
+               END DO
+            END DO
+         END DO
+
+         ! surface values
+         ztp1(:,:,1) = 0. 
+
+         ! vertical advective flux
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zew = zwn(ji,jj,jk+1)
+                  z0w = SIGN( 0.5, zwn(ji,jj,jk+1) )
+                  zalpha = 0.5 + z0w
+                  zw  = z0w - 0.5 * zwn(ji,jj,jk+1)* rdttrc(jk)/ fse3w(ji,jj,jk+1)
+                  zzt1 = trb(ji,jj,jk+1,jn) + zw*ztp1(ji,jj,jk+1)
+                  zzt2 = trb(ji,jj,jk  ,jn) + zw*ztp1(ji,jj,jk  )
+                  zt1(ji,jj,jk+1) = zew * ( zalpha * zzt1 + (1.-zalpha)*zzt2 )
+               END DO
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF( tmask(ji,jj,jk+1) == 0. ) THEN
+                     IF( zwn(ji,jj,jk) > 0. ) THEN
+                        zt1(ji,jj,jk) = zwn(ji,jj,jk) * ( trb(ji,jj,jk-1,jn) + trb(ji,jj,jk,jn) ) * 0.5
+                     ENDIF
+                  ENDIF
+               END DO
+            END DO
+         END DO
+
+         ! surface values
+         IF( lk_vvl ) THEN
+            ! variable volume: flux set to zero
+            zt1(:,:, 1 ) = 0.e0
+         ELSE
+            ! free surface-constant volume
+            zt1(:,:, 1 ) = zwn(:,:,1) * trb(:,:,1,jn)
+         ENDIF
+
+         ! bottom values
+         zt1(:,:,jpk) = 0.e0
+
+         ! Compute & add the vertical advective trend
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / fse3t(ji,jj,jk)
+                  ! horizontal advective trends
+                  ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) =  tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! save the vertical advective trends computed as w gradz(T)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+#endif
+
+               END DO
+            END DO
+         END DO
+
+
+         ! 3. Save the vertical advective trends for diagnostic
+         ! ----------------------------------------------------
+
+         TRDTRC_Z : IF( l_trdtrc )THEN
+
+            ! Compute T/S vertical advection trends
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr = 1. / fse3t(ji,jj,jk)
+                     ! horizontal advective trends
+                     ztra = - zbtr * ( zt1(ji,jj,jk) - zt1(ji,jj,jk+1) )
+                     ! save the vertical advective trends computed as w gradz(T)
+                     ztrtrd(ji,jj,jk) = ztra - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+                  END DO 
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zad, kt)
+
+         END IF TRDTRC_Z
+
+         !                            !=============
+      END DO                          ! tracer loop
+      !                               !=============
+
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('muscl2 - zad')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+   END SUBROUTINE trc_adv_muscl2
+
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_adv_muscl2( kt ) 
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_adv_muscl2: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_adv_muscl2
+#endif
+
+   !!======================================================================
+END MODULE trcadv_muscl2
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_smolar.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_smolar.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_smolar.F90	(revision 1844)
@@ -0,0 +1,561 @@
+MODULE trcadv_smolar
+   !!======================================================================
+   !!                       ***  MODULE  trcadv_smolar  ***
+   !! Ocean passive tracers:  horizontal & vertical advective trend
+   !!======================================================================
+   !! History :       !  87-06  (pa-dl) Original
+   !!                 !  91-11  (G. Madec)
+   !!                 !  94-08  (A. Czaja)
+   !!                 !  95-09  (M. Levy) passive tracers
+   !!                 !  98-03  (M.A. Foujols) lateral boundary conditions
+   !!                 !  99-02  (M.A. Foujols) lbc in conjonction with ORCA
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-10  (MA Foujols and E.Kestenare) INCLUDE instead of routine
+   !!                 !  01-05  (E.Kestenare) fix bug in trtrd indexes
+   !!                 !  02-05  (M-A Filiberti, and M.Levy) correction in trtrd computation
+   !!           9.0   !  03-04  (C. Ethe)  F90: Free form and module
+   !!                 !  07-02  (C. Deltel) Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   trc_adv_smolar : update the passive tracer trend with the horizontal
+   !!                  and vertical advection trends using a Smolarkiewicz 
+   !!                  FCT scheme
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trc                 ! ocean passive tracers variables
+   USE trp_trc
+   USE lbclnk              ! ocean lateral boundary conditions (or mpp link)
+   USE trcbbl              ! advective passive tracers in the BBL
+   USE prtctl_trc          ! Print control for debbuging
+   USE trctrp_lec
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_adv_smolar   ! routine called by trcstp.F90
+
+   REAL(wp), DIMENSION(jpk) ::   rdttrc    ! vertical profile of tracer time-step
+ 
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcadv_smolar.F90,v 1.11 2006/04/10 15:38:54 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE trc_adv_smolar( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_adv_smolar  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to total advection of passi-
+      !!                ve tracer using a Smolarkiewicz FCT (Flux Corrected
+      !!                Transport) scheme and add it to the general tracer trend.
+      !!
+      !! ** Method  :   Computation of not exactly the advection but the
+      !!                transport term, i.e.  div(u*tra). 
+      !!                Computes the now horizontal and vertical advection with
+      !!                the complete 3d method.
+      !! 
+      !!       Note : - sc is an empirical factor to be used with care
+      !!              - this advection scheme needs an euler-forward time scheme
+      !!
+      !! ** Action : - update tra with the now advective tracer trends
+      !!             - save trends ('key_trdmld_trc')
+      !!
+      !! References :   Smolarkiewicz, 1983, Mon. Wea. Rev. p. 479-486
+      !!----------------------------------------------------------------------
+#if defined key_trcbbl_adv
+      USE oce_trc            , zun => ua,  &  ! use ua as workspace
+         &                     zvn => va      ! use va as workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwn
+#else
+      USE oce_trc            , zun => un,  &  ! When no bbl, zun == un
+           &                   zvn => vn,  &  !              zvn == vn
+           &                   zwn => wn      !              zwn == wn
+#endif
+      INTEGER, INTENT( in ) ::   kt                        ! ocean time-step
+      INTEGER :: ji, jj, jk,jt, jn                         ! dummy loop indices
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zti, ztj   
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zaa, zbb, zcc
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zx , zy , zz
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zkx, zky, zkz
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zbuf
+      REAL(wp) :: zgm, zgz
+      REAL(wp) :: zbtr, ztra
+      REAL(wp) :: zfp_ui, zfp_vj, zfm_ui, zfm_vj, zfp_w, zfm_w
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrtrd
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000  .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_adv_smolar : SMOLARKIEWICZ advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+         rdttrc(:) = rdttra(:) * FLOAT(ndttrc)
+      ENDIF
+      
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk,3) )
+     
+#if defined key_trcbbl_adv        
+      ! Advective bottom boundary layer
+      ! -------------------------------
+      zun(:,:,:) = un (:,:,:) - u_trc_bbl(:,:,:)
+      zvn(:,:,:) = vn (:,:,:) - v_trc_bbl(:,:,:)
+      zwn(:,:,:) = wn (:,:,:) + w_trc_bbl(:,:,:)
+#endif
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         ! 1. tracer flux in the 3 directions
+         ! ----------------------------------
+         
+         !--1.1 Horizontal advection
+         IF( l_trdtrc ) ztrtrd(:,:,:,:) = 0.e0             ! trends
+
+         DO jk = 1, jpk                                       ! Horizontal slab
+
+            ! ... Initialisations
+            zbuf(:,:,jk) = 0.e0    ;    ztj(:,:,jk) = 0.e0
+            zx  (:,:,jk) = 0.e0    ;    zy (:,:,jk) = 0.e0
+            zz  (:,:,jk) = 0.e0
+            
+            IF( l_trdtrc ) ztrtrd(:,:,:,:) = 0.e0             ! trends
+
+            ! ... Horizontal mass flux at u v and t-points
+            zaa(:,:,jk)  = e2u(:,:) * fse3u(:,:,jk) * zun(:,:,jk)
+            zbb(:,:,jk)  = e1v(:,:) * fse3v(:,:,jk) * zvn(:,:,jk)
+            zcc(:,:,jk)  = e1t(:,:) *   e2t(:,:)    * zwn(:,:,jk)
+            zti(:,:,jk)  = trn(:,:,jk,jn)
+
+#if defined key_trc_diatrd
+            IF (luttrd(jn)) trtrd(:,:,jk,ikeep(jn),1) = 0.
+            IF (luttrd(jn)) trtrd(:,:,jk,ikeep(jn),2) = 0.
+            IF (luttrd(jn)) trtrd(:,:,jk,ikeep(jn),3) = 0.
+#endif
+
+            ! ... Horizontal tracer flux in the i and j direction
+            zkx( 1,  :,jk) = 0.e0     ;      zky(  :,  1,jk) = 0.e0
+            zkx(jpi, :,jk) = 0.e0     ;      zky(  :,jpj,jk) = 0.e0
+            
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1    ! Vector opt.
+                  
+                  ! Upstream advection scheme using mass fluxes calculated above
+                  zfp_ui = 0.5 * ( zaa(ji,jj,jk) + ABS( zaa(ji,jj,jk) ) )
+                  zfp_vj = 0.5 * ( zbb(ji,jj,jk) + ABS( zbb(ji,jj,jk) ) )
+                  zfm_ui = 0.5 * ( zaa(ji,jj,jk) - ABS( zaa(ji,jj,jk) ) )
+                  zfm_vj = 0.5 * ( zbb(ji,jj,jk) - ABS( zbb(ji,jj,jk) ) )
+                  
+                  ! Tracer fluxes
+                  zkx(ji,jj,jk) = zfp_ui * zti(ji,jj,jk) + zfm_ui * zti(ji+1,jj  ,jk) 
+                  zky(ji,jj,jk) = zfp_vj * zti(ji,jj,jk) + zfm_vj * zti(ji  ,jj+1,jk)             
+               END DO
+            END DO
+            
+         END DO                                               ! Horizontal slab
+         
+         ! ... Lateral boundary conditions on zk[xy]
+         CALL lbc_lnk( zkx, 'U', -1. )
+         CALL lbc_lnk( zky, 'V', -1. )
+         
+         !--1.2 Vertical advection
+         IF( lk_vvl ) THEN
+            ! variable volume: flux set to zero
+            zkz(:,:, 1 ) = 0.e0  
+         ELSE
+            ! free surface-constant volume
+            zkz(:,:, 1 ) = zwn(:,:,1) * trn(:,:,1,jn) * tmask(ji,jj,1)
+         ENDIF
+         
+         DO jk = 2, jpk     ! Vector opt. ???
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zfp_w = 0.5 * ( zcc(ji,jj,jk) + ABS( zcc(ji,jj,jk) ) )
+                  zfm_w = 0.5 * ( zcc(ji,jj,jk) - ABS( zcc(ji,jj,jk) ) )        
+                  zkz(ji,jj,jk) = zfp_w * zti(ji,jj,jk) + zfm_w * zti(ji,jj,jk-1)     
+               END DO
+            END DO
+         END DO
+         
+         ! 2. Compute after field using an upstream advection scheme
+         ! ---------------------------------------------------------
+         
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1  ! Vector opt.
+                  zbtr = 1./(e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk))
+                  ztj(ji,jj,jk) = - zbtr *                                &
+                       &         ( zkx(ji,jj,jk) - zkx(ji-1,jj  ,jk  )    &
+                       &         + zky(ji,jj,jk) - zky(ji  ,jj-1,jk  )    &
+                       &         + zkz(ji,jj,jk) - zkz(ji  ,jj  ,jk+1) )
+#if defined key_trc_diatrd
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) -  &
+                       &                                        zbtr*( zkx(ji,jj,jk) - zkx(ji-1,jj,jk) )
+
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) -  &
+                       &                                        zbtr*( zky(ji,jj,jk) - zky(ji,jj-1,jk) )
+
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3) -  &
+                       &                                        zbtr*( zkz(ji,jj,jk) - zkz(ji,jj,jk+1) )
+#endif
+
+               END DO
+            END DO
+         END DO
+         
+         ! 3. Diagnose passive tracer trends (part 1/3)
+         ! --------------------------------------------
+
+         IF( l_trdtrc ) THEN
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! Vector opt.
+                     zbtr = 1./(e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk))
+                     ztrtrd(ji,jj,jk,1) = ztrtrd(ji,jj,jk,1) - zbtr*( zkx(ji,jj,jk) - zkx(ji-1,jj  ,jk  ) )
+                     ztrtrd(ji,jj,jk,2) = ztrtrd(ji,jj,jk,2) - zbtr*( zky(ji,jj,jk) - zky(ji  ,jj-1,jk  ) )
+                     ztrtrd(ji,jj,jk,3) = ztrtrd(ji,jj,jk,3) - zbtr*( zkz(ji,jj,jk) - zkz(ji  ,jj  ,jk+1) )
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         
+         ! 4. Antidiffusive correction loop
+         ! --------------------------------
+         !                                      ! -----------------------------
+         DO jt = 1, ncortrc                     ! antidiffusive correction loop
+            !                                   ! -----------------------------
+            
+            !--4.1 Compute intermediate field zti
+            DO jk = 1, jpkm1
+               zti (:,:,jk) = zti (:,:,jk) + rdttrc(jk) * ztj(:,:,jk)
+            END DO
+            zbuf(:,:,:) = zbuf(:,:,:) + ztj(:,:,:)
+            
+            CALL lbc_lnk( zti, 'T', 1. )    ! lateral boundary
+            
+            !--4.2 Compute the antidiffusive fluxes
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zx(ji,jj,jk) = ( abs(zaa(ji,jj,jk)) - rdttrc(jk)                     &
+                          &              *zaa(ji,jj,jk)**2/                               &
+                          &              (e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,jk) ) )       &
+                          &              *(zti(ji + 1,jj,jk) - zti( ji ,jj,jk))           &
+                          &              /(zti( ji ,jj,jk) + zti(ji + 1,jj,jk) + rtrn)    &
+                          &              * rsc
+                     
+                     zy(ji,jj,jk) = ( abs(zbb(ji,jj,jk)) - rdttrc(jk)                     &
+                          &              *zbb(ji,jj,jk)**2/                               &
+                          &              (e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk) ) )       &
+                          &              *(zti(ji,jj + 1,jk) - zti(ji, jj ,jk))           &
+                          &              /(zti(ji, jj ,jk) + zti(ji,jj + 1,jk) + rtrn)    &
+                          &              * rsc
+                  END DO
+               END DO
+            END DO
+            
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zz(ji,jj,jk) = ( abs(zcc(ji,jj,jk)) - rdttrc(jk)*zcc(ji,jj,jk)**2    &  
+                          &              /( e1t(ji,jj)*e2t(ji,jj)*fse3w(ji,jj,jk) ) )     &
+                          &               *( zti(ji,jj,jk) - zti(ji,jj,jk - 1) )/         &
+                          &                ( zti(ji,jj,jk) + zti(ji,jj,jk - 1) + rtrn )* rsc*( -1.)
+                  END DO
+               END DO
+            END DO
+            
+            !--4.3 Cross terms
+            CROSSTERMS: IF( crosster ) THEN
+               !
+               DO jk = 2, jpkm1
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1    ! Vector opt.
+                        zx(ji,jj,jk) = zx(ji,jj,jk)                                               &
+                             &                  - 0.5*rdttrc(jk)*rsc*zaa(ji,jj,jk)*0.25*          &
+                             &                  (    (zbb(ji  ,jj - 1,jk  ) + zbb(ji + 1,jj - 1   &
+                             &                  ,jk  ) + zbb(ji + 1,jj  ,jk  ) + zbb(ji  ,jj      &
+                             &                  ,jk))* (zti(ji  ,jj + 1,jk  ) + zti(ji + 1,jj +   &
+                             &                  1,jk  ) - zti(ji + 1,jj - 1,jk  ) - zti(ji  ,jj   &
+                             &                  - 1,jk  ))/ (zti(ji  ,jj + 1,jk  ) + zti(ji + 1   &
+                             &                  ,jj + 1,jk  ) + zti(ji + 1,jj - 1,jk  ) + zti(ji  &
+                             &                  ,jj - 1,jk  ) + rtrn) + (zcc(ji  ,jj  ,jk  ) +    &
+                             &                  zcc(ji + 1,jj  ,jk  ) + zcc(ji  ,jj  ,jk + 1) +   &
+                             &                  zcc(ji + 1,jj  ,jk + 1))* (zti(ji  ,jj  ,jk - 1)  &
+                             &                  + zti(ji + 1,jj  ,jk - 1) - zti(ji  ,jj  ,jk + 1  &
+                             &                  )- zti(ji + 1,jj  ,jk + 1))/ (zti(ji  ,jj  ,jk -  &
+                             &                  1) + zti(ji + 1,jj  ,jk - 1) + zti(ji  ,jj  ,jk   &
+                             &                  +1) + zti(ji + 1,jj  ,jk + 1) + rtrn))/(e1u(ji    &
+                             &                  ,jj)*e2u(ji,jj)*fse3u(ji,jj,jk))*vmask(ji  ,jj -  &
+                             &                  1,jk  )*vmask(ji + 1,jj - 1,jk  )*vmask(ji + 1    &
+                             &                  ,jj,jk)*vmask(ji  ,jj  ,jk  )*tmask(ji  ,jj  ,jk  &
+                             &                  )*tmask(ji + 1,jj  ,jk  )*tmask(ji  ,jj  ,jk + 1  &
+                             &                  )*tmask(ji + 1,jj  ,jk + 1)
+                        zy(ji,jj,jk) = zy(ji,jj,jk)                                               &   
+                             &                  - 0.5*rdttrc(jk)*rsc*zbb(ji,jj,jk)*0.25*          &   
+                             &                  (    (zaa(ji - 1,jj  ,jk  ) + zaa(ji - 1,jj + 1   &   
+                             &                  ,jk  ) + zaa(ji  ,jj  ,jk  ) + zaa(ji  ,jj + 1    &   
+                             &                  ,jk))* (zti(ji + 1,jj + 1,jk  ) + zti(ji + 1,jj   &   
+                             &                  ,jk  ) - zti(ji - 1,jj + 1,jk  ) - zti(ji - 1,jj  &   
+                             &                  ,jk  ))/ (zti(ji + 1,jj + 1,jk  ) + zti(ji + 1    &   
+                             &                  ,jj  ,jk  ) + zti(ji - 1,jj + 1,jk  ) + zti(ji    &   
+                             &                  - 1,jj  ,jk  ) + rtrn) + (zcc(ji  ,jj  ,jk  )     &   
+                             &                  + zcc(ji  ,jj  ,jk + 1) + zcc(ji  ,jj + 1,jk  )   &   
+                             &                  + zcc(ji  ,jj + 1,jk + 1))* (zti(ji  ,jj  ,jk -   &   
+                             &                  1) + zti(ji  ,jj + 1,jk - 1) - zti(ji  ,jj  ,jk   &   
+                             &                  +1) - zti(ji  ,jj + 1,jk + 1))/ (zti(ji  ,jj      &   
+                             &                  ,jk- 1) + zti(ji  ,jj + 1,jk - 1) + zti(ji  ,jj   &   
+                             &                  ,jk+ 1) + zti(ji  ,jj + 1,jk + 1) + rtrn))        &   
+                             &                  /(e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk))          &   
+                             &                  *umask(ji - 1,jj,jk  )*umask(ji - 1,jj + 1,jk  )  &   
+                             &                  *umask(ji  ,jj,jk  )*umask(ji  ,jj + 1,jk  )      &   
+                             &                  *tmask(ji  ,jj,jk)*tmask(ji  ,jj  ,jk + 1)        &   
+                             &                  *tmask(ji  ,jj + 1,jk)*tmask(ji  ,jj + 1,jk + 1)      
+                        zz(ji,jj,jk) = zz(ji,jj,jk)                                               &   
+                             &                  - 0.5*rdttrc(jk)*rsc*zcc(ji,jj,jk)*0.25*          &   
+                             &                  (    (zaa(ji - 1,jj  ,jk  ) + zaa(ji  ,jj  ,jk    &   
+                             &                  ) + zaa(ji  ,jj  ,jk - 1) + zaa(ji - 1,jj  ,jk -  &   
+                             &                  1))*(zti(ji + 1,jj  ,jk - 1) + zti(ji + 1,jj      &   
+                             &                  ,jk  ) - zti(ji - 1,jj  ,jk  ) - zti(ji - 1,jj    &   
+                             &                  ,jk - 1))/(zti(ji + 1,jj  ,jk - 1) + zti(ji + 1   &   
+                             &                  ,jj,jk  ) + zti(ji - 1,jj  ,jk  ) + zti(ji - 1    &   
+                             &                  ,jj,jk - 1) + rtrn) + (zbb(ji  ,jj - 1,jk  )      &   
+                             &                  + zbb(ji  ,jj  ,jk  ) + zbb(ji  ,jj  ,jk - 1)     &   
+                             &                  + zbb(ji  ,jj - 1,jk - 1))*(zti(ji  ,jj + 1,jk -  &   
+                             &                  1) + zti(ji  ,jj + 1,jk  ) - zti(ji  ,jj - 1,jk   &   
+                             &                  ) - zti(ji  ,jj - 1,jk - 1))/(zti(ji  ,jj + 1,jk  &   
+                             &                  - 1) + zti(ji  ,jj + 1,jk  ) + zti(ji  ,jj - 1    &   
+                             &                  ,jk  ) + zti(ji  ,jj - 1,jk - 1) + rtrn))         &   
+                             &                  /(e1t(ji,jj)*e2t(ji,jj)*fse3w(ji,jj,jk))          &   
+                             &                  *umask(ji - 1,jj,jk  )*umask(ji  ,jj  ,jk  )      &   
+                             &                  *umask(ji  ,jj,jk- 1)*umask(ji - 1,jj  ,jk - 1)   &   
+                             &                  *vmask(ji  ,jj- 1,jk)*vmask(ji  ,jj  ,jk  )       &   
+                             &                  *vmask(ji  ,jj  ,jk-1)*vmask(ji  ,jj - 1,jk - 1)       
+                     END DO
+                  END DO
+               END DO
+               
+               DO jj = 2,jpjm1
+                     DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zx(ji,jj,1) = zx(ji,jj,1)                                                    &   
+                          &                - 0.5*rdttrc(jk)*rsc*zaa(ji,jj,1)*0.25*                &   
+                          &                ( (zbb(ji  ,jj - 1,1  ) + zbb(ji + 1,jj - 1,1  )       &   
+                          &                + zbb(ji + 1,jj  ,1  ) + zbb(ji  ,jj  ,1  ))           &   
+                          &                *(zti(ji  ,jj + 1,1  ) + zti(ji + 1,jj + 1,1  )        &   
+                          &                - zti(ji + 1,jj - 1,1  ) - zti(ji  ,jj - 1,1  ))       &   
+                          &                /(zti(ji  ,jj + 1,1  ) + zti(ji + 1,jj + 1,1  )        &   
+                          &                + zti(ji + 1,jj - 1,1  ) + zti(ji  ,jj - 1,1  ) +      &   
+                          &                rtrn))/(e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,1))          &   
+                          &                *vmask(ji  ,jj - 1,1  )*vmask(ji + 1,jj - 1,1  )       &   
+                          &                *vmask(ji + 1,jj  ,1  )*vmask(ji  ,jj  ,1  )    
+                     zy(ji,jj,1) = zy(ji,jj,1)                                                    &   
+                          &                - 0.5*rdttrc(jk)*rsc*zbb(ji,jj,1)*0.25*                &   
+                          &                ( (zaa(ji-1  ,jj ,1  ) + zaa(ji - 1,jj + 1,1  )        &   
+                          &                + zaa(ji ,jj  ,1  ) + zaa(ji  ,jj + 1  ,1  ))          &   
+                          &                *(zti(ji + 1,jj + 1,1  ) + zti(ji + 1,jj ,1  )         &   
+                          &                - zti(ji - 1,jj + 1,1  ) - zti(ji - 1,jj ,1  ))        &   
+                          &                /(zti(ji + 1,jj + 1,1  ) + zti(ji + 1,jj ,1  )         &   
+                          &                + zti(ji - 1,jj + 1,1  ) + zti(ji - 1,jj ,1  ) +       &   
+                          &                rtrn))/(e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,1))          &   
+                          &                *umask(ji - 1,jj,1  )*umask(ji - 1,jj + 1,1  )         &   
+                          &                *umask(ji    ,jj,1  )*umask(ji  ,jj + 1 ,1  )    
+                  END DO
+               END DO
+               !
+            ENDIF CROSSTERMS
+           
+            ! ... Lateral boundary conditions on z[xyz]
+            CALL lbc_lnk( zx, 'U', -1. )    ;    CALL lbc_lnk( zy, 'V', -1. )
+            CALL lbc_lnk( zz, 'W',  1. )
+
+            !--4.4 Reinitialization
+            zaa(:,:,:) = zx(:,:,:)
+            zbb(:,:,:) = zy(:,:,:)
+            zcc(:,:,:) = zz(:,:,:)
+
+            ! 5. Advection by antidiffusive mass fluxes & upstream scheme
+            ! -----------------------------------------------------------
+            
+            ! ... Horizontal
+            DO jk = 1, jpk
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zfp_ui = 0.5 * ( zaa(ji,jj,jk) + ABS( zaa(ji,jj,jk) ) )
+                     zfp_vj = 0.5 * ( zbb(ji,jj,jk) + ABS( zbb(ji,jj,jk) ) )
+                     zfm_ui = 0.5 * ( zaa(ji,jj,jk) - ABS( zaa(ji,jj,jk) ) )
+                     zfm_vj = 0.5 * ( zbb(ji,jj,jk) - ABS( zbb(ji,jj,jk) ) )            
+                     zkx(ji,jj,jk) = zfp_ui * zti(ji,jj,jk) + zfm_ui * zti(ji+1,jj  ,jk) 
+                     zky(ji,jj,jk) = zfp_vj * zti(ji,jj,jk) + zfm_vj * zti(ji  ,jj+1,jk)             
+                  END DO
+               END DO
+            END DO
+
+            ! ... Lateral boundary conditions on zk[xy]
+            CALL lbc_lnk( zkx, 'U', -1. )
+            CALL lbc_lnk( zky, 'V', -1. )
+            
+            ! ... Vertical
+            DO jk = 2, jpk
+               DO jj = 1, jpj
+                  DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zfp_w = 0.5 * ( zcc(ji,jj,jk) + ABS( zcc(ji,jj,jk) ) )
+                     zfm_w = 0.5 * ( zcc(ji,jj,jk) - ABS( zcc(ji,jj,jk) ) )       
+                     zkz(ji,jj,jk) = zfp_w * zti(ji,jj,jk) + zfm_w * zti(ji,jj,jk-1)     
+                  END DO
+               END DO
+            END DO
+
+            ! ... Compute ztj
+            DO jk = 1,jpkm1
+               DO jj = 2,jpjm1
+                  DO ji = fs_2, fs_jpim1    ! Vector opt.
+                     zbtr = 1./(e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk))
+                     ztj(ji,jj,jk) = - zbtr *                                     &  
+                          &              ( zkx(ji,jj,jk) - zkx(ji-1,jj  ,jk  )    &  
+                          &              + zky(ji,jj,jk) - zky(ji  ,jj-1,jk  )    &  
+                          &              + zkz(ji,jj,jk) - zkz(ji  ,jj  ,jk+1) )
+#if defined key_trc_diatrd
+                     IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) -    &
+                          &                                        zbtr*( zkx(ji,jj,jk) - zkx(ji - 1,jj,jk) )
+
+                     IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) -    &
+                          &                                        zbtr*( zky(ji,jj,jk) - zky(ji,jj - 1,jk) )
+
+                     IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3) -    &
+                          &                                        zbtr*( zkz(ji,jj,jk) - zkz(ji,jj,jk + 1) )
+#endif
+
+                  END DO
+               END DO
+            END DO
+
+            ! 6. Diagnose passive tracer trends (part 2/3)
+            ! --------------------------------------------
+            IF( l_trdtrc ) THEN
+               DO jk = 1, jpkm1
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1    ! Vector opt.
+                        zbtr = 1./(e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk))
+                        ztrtrd(ji,jj,jk,1) = ztrtrd(ji,jj,jk,1) - zbtr*( zkx(ji,jj,jk) - zkx(ji - 1,jj,jk) )   
+                        ztrtrd(ji,jj,jk,2) = ztrtrd(ji,jj,jk,2) - zbtr*( zky(ji,jj,jk) - zky(ji,jj - 1,jk) )
+                        ztrtrd(ji,jj,jk,3) = ztrtrd(ji,jj,jk,3) - zbtr*( zkz(ji,jj,jk) - zkz(ji,jj,jk + 1) )
+                     END DO
+                  END DO
+               END DO
+            ENDIF
+            !                            ! ------------------------------------
+         END DO                          ! End of antidiffusive correction loop
+         !                               ! ------------------------------------
+
+         ! 7. Trend due to horizontal and vertical advection of tracer jn
+         ! --------------------------------------------------------------
+         
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1     ! Vector opt.
+                  ztra = ( zbuf(ji,jj,jk) + ztj(ji,jj,jk) ) * tmask(ji,jj,jk)
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+               END DO
+            END DO
+         END DO
+
+
+         ! 8. Convert the transport trend into advection trend (part 3/3)
+         ! --------------------------------------------------------------
+
+         IF( l_trdtrc ) THEN
+            ! ... Update the trends array
+            DO jk = 1, jpk
+               DO jj = 2, jpjm1
+                  DO  ji = fs_2, fs_jpim1
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     zgm = zbtr * trn(ji,jj,jk,jn) *                                           &  
+                          &  (   zun(ji  ,jj,jk) * e2u(ji  ,jj) * fse3u(ji  ,jj,jk)            &  
+                          &    - zun(ji-1,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk)  )
+            
+                     zgz = zbtr * trn(ji,jj,jk,jn) *                                           &  
+                          &  (   zvn(ji,jj  ,jk) * e1v(ji,jj  ) * fse3v(ji,jj  ,jk)            &  
+                          &    - zvn(ji,jj-1,jk) * e1v(ji,jj-1) * fse3v(ji,jj-1,jk)  )
+            
+                     ztrtrd(ji,jj,jk,1) = ztrtrd(ji,jj,jk,1) + zgm
+                     ztrtrd(ji,jj,jk,2) = ztrtrd(ji,jj,jk,2) + zgz
+                     ztrtrd(ji,jj,jk,3) = ztrtrd(ji,jj,jk,3) - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+ 
+            ! ... Lateral boundary conditions on trtrd:
+            CALL lbc_lnk( ztrtrd(:,:,:,1), 'T', 1. )
+            CALL lbc_lnk( ztrtrd(:,:,:,2), 'T', 1. )
+            CALL lbc_lnk( ztrtrd(:,:,:,3), 'T', 1. )
+ 
+            ! ... Miscellaneous trends diagnostics
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd(:,:,:,1), jn, jptrc_trd_xad, kt )
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd(:,:,:,2), jn, jptrc_trd_yad, kt )
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd(:,:,:,3), jn, jptrc_trd_zad, kt )
+         ENDIF
+
+         !  Convert the transport trend into advection trend
+         ! ---------------------------------------------------
+
+#if defined key_trc_diatrd
+        DO jk = 1,jpk
+          DO jj = 2,jpjm1
+             DO ji = fs_2, fs_jpim1     ! Vector opt.
+                zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                zgm = zbtr * trn(ji,jj,jk,jn) *                                       &
+                     &    (  zun(ji  ,jj,jk) * e2u(ji  ,jj) * fse3u(ji  ,jj,jk)       &
+                     &     - zun(ji-1,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk)    )
+
+                zgz = zbtr * trn(ji,jj,jk,jn) *                                       &
+                     &    (  zvn(ji,jj  ,jk) * e1v(ji,jj  ) * fse3v(ji,jj  ,jk)       &
+                     &     - zvn(ji,jj-1,jk) * e1v(ji,jj-1) * fse3v(ji,jj-1,jk)   )
+
+                IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) + zgm
+                IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) + zgz
+                IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3)         &
+                     &                                      - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+             END DO
+          END DO
+       END DO
+
+       ! Lateral boundary conditions on trtrd
+       IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),1), 'T', 1. )
+       IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),2), 'T', 1. )
+       IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),3), 'T', 1. )
+#endif
+
+       
+       !                                                 ! ==================
+    END DO                                               ! END of tracer loop
+    !                                                    ! ==================
+
+    IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+ 
+    IF( ln_ctl ) THEN      ! print mean trends (used for debugging)
+       WRITE(charout, FMT="('smolar - adv')")
+       CALL prt_ctl_trc_info(charout)
+       CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+    ENDIF
+    
+  END SUBROUTINE trc_adv_smolar
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_adv_smolar( kt ) 
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_adv_smolar: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_adv_smolar
+#endif
+
+   !!======================================================================
+END MODULE trcadv_smolar
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_tvd.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_tvd.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcadv_tvd.F90	(revision 1844)
@@ -0,0 +1,620 @@
+MODULE trcadv_tvd
+   !!======================================================================
+   !!                       ***  MODULE  trcadv_tvd  ***
+   !! Ocean passive tracers:  horizontal & vertical advective trend
+   !!======================================================================
+   !! History :       !  95-12  (L. Mortier)  Original code
+   !!                 !  00-01  (H. Loukos)  adapted to ORCA 
+   !!                 !  00-10  (MA Foujols E.Kestenare)  include file not routine
+   !!                 !  00-12  (E. Kestenare M. Levy)  fix bug in trtrd indexes
+   !!                 !  01-07  (E. Durand G. Madec)  adaptation to ORCA config
+   !!            9.0  !  02-06  (C. Ethe, G. Madec)  F90: Free form and module
+   !!                 !  07-02  (C. Deltel) Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   trc_adv_tvd  : update the passive tracer trend with the horizontal
+   !!                  and vertical advection trends using a TVD scheme
+   !!   nonosc       : compute monotonic tracer fluxes by a nonoscillatory
+   !!                  algorithm 
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trc                 ! ocean passive tracers variables
+   USE trp_trc
+   USE lbclnk              ! ocean lateral boundary conditions (or mpp link)
+   USE trcbbl              ! advective passive tracers in the BBL
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_adv_tvd    ! routine called by trcstp.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcadv_tvd.F90,v 1.12 2006/04/10 15:38:54 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_adv_tvd( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_adv_tvd  ***
+      !! 
+      !! **  Purpose :   Compute the now trend due to total advection of 
+      !!       tracers and add it to the general trend of tracer equations
+      !!
+      !! **  Method  :   TVD scheme, i.e. 2nd order centered scheme with
+      !!       corrected flux (monotonic correction)
+      !!       note: - this advection scheme needs a leap-frog time scheme
+      !!
+      !! ** Action : - update tra with the now advective tracer trends
+      !!             - save the trends ('key_trdmld_trc)
+      !!----------------------------------------------------------------------
+#if defined key_trcbbl_adv
+      USE oce_trc            , zun => ua,  &  ! use ua as workspace
+           &                   zvn => va      ! use va as workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwn
+#else
+      USE oce_trc            , zun => un,  &  ! When no bbl, zun == un
+           &                   zvn => vn,  &  !             zvn == vn
+           &                   zwn => wn      !             zwn == wn
+#endif
+      INTEGER, INTENT( in ) ::   kt                        ! ocean time-step
+      INTEGER  ::   ji, jj, jk, jn                         ! dummy loop indices
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztu, ztv
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zti, ztw
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd  ! trends
+      !!
+      REAL(wp) ::   z_hdivn_x, z_hdivn_y                   ! temporary scalars
+      REAL(wp) ::   z2dtt, zbtr, zeu, zev, zew, z2
+      REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk
+      REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk
+#if defined key_trc_diatrd
+      REAL(wp) ::   zgm, zgz
+#endif
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      zti(:,:,:) = 0.e0
+
+      IF( kt == nittrc000  .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_adv_tvd : TVD advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+      IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+         z2=1.
+      ELSE
+         z2=2.
+      ENDIF
+
+#if defined key_trcbbl_adv
+      ! Advective Bottom boundary layer: add the velocity
+      ! -------------------------------------------------
+      zun(:,:,:) = un (:,:,:) - u_trc_bbl(:,:,:)
+      zvn(:,:,:) = vn (:,:,:) - v_trc_bbl(:,:,:)
+      zwn(:,:,:) = wn (:,:,:) + w_trc_bbl(:,:,:)
+#endif
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+
+         ! ============================================================
+         ! I.              Intermediate advective trends
+         ! ============================================================
+
+         ! 1. Bottom value : flux set to zero
+         ! ----------------------------------
+         ztu(:,:,jpk) = 0.e0    ;    ztv(:,:,jpk) = 0.e0
+         ztw(:,:,jpk) = 0.e0    ;    zti(:,:,jpk) = 0.e0
+
+
+         ! 2. Upstream advection with initial mass fluxes & intermediate update
+         ! --------------------------------------------------------------------
+
+         ! ... Upstream tracer flux in the i and j direction
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+               !??? CD DO ji = fs_2, fs_jpim1    ! Vector opt.
+                  zeu = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * zun(ji,jj,jk)
+                  zev = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * zvn(ji,jj,jk)
+                  zfp_ui = zeu + ABS( zeu )   ! upstream scheme
+                  zfm_ui = zeu - ABS( zeu )
+                  zfp_vj = zev + ABS( zev )
+                  zfm_vj = zev - ABS( zev )
+                  ztu(ji,jj,jk) = zfp_ui * trb(ji,jj,jk,jn) + zfm_ui * trb(ji+1,jj  ,jk,jn)
+                  ztv(ji,jj,jk) = zfp_vj * trb(ji,jj,jk,jn) + zfm_vj * trb(ji  ,jj+1,jk,jn)
+               END DO
+            END DO
+         END DO
+
+         ! ... Upstream tracer flux in the k direction
+         ! Surface value
+         IF( lk_vvl ) THEN
+            ! variable volume: flux set to zero
+            ztw(:,:,1) = 0.e0
+         ELSE
+            ! free surface-constant volume
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zew = e1t(ji,jj) * e2t(ji,jj) * zwn(ji,jj,1)
+                  ztw(ji,jj,1) = zew * trb(ji,jj,1,jn)
+               END DO
+            END DO
+         ENDIF
+
+         ! Interior value
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi   ! CD ??? Vector opt. 
+                  zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * zwn(ji,jj,jk)
+                  zfp_wk = zew + ABS( zew )
+                  zfm_wk = zew - ABS( zew )
+                  ztw(ji,jj,jk) = zfp_wk * trb(ji,jj,jk,jn) + zfm_wk * trb(ji,jj,jk-1,jn)
+               END DO
+            END DO
+         END DO
+
+         ! ... Total intermediate advective trend (flux divergence)
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1./ ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  zti(ji,jj,jk) = - ( ztu(ji,jj,jk) - ztu(ji-1,jj  ,jk  )   &
+                     &              + ztv(ji,jj,jk) - ztv(ji  ,jj-1,jk  )   &
+                     &              + ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) * zbtr
+#if defined key_trc_diatrd
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) -  &
+                        &                          zbtr * ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) )
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) -  &
+                        &                          zbtr * ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3) -  &
+                        &                          zbtr * ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) )
+#endif
+               END DO
+            END DO
+         END DO
+         
+         ! 3. Save the intermediate i / j / k advective trends for diagnostics
+         ! -------------------------------------------------------------------
+
+         IF( l_trdtrc ) THEN
+
+            ! 3.1) Passive tracer ZONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+
+                     !-- Compute zonal divergence by splitting hdivn (see divcur.F90)
+                     !   N.B. This computation is not valid along OBCs (if any)
+                     zbtr = 1./ ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * un(ji  ,jj,jk)          &
+                          &       - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * un(ji-1,jj,jk) ) * zbtr
+
+                     !-- Compute zonal advection trends
+                     ztrtrd(ji,jj,jk) = - ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) ) * zbtr &
+                          &             + trb(ji,jj,jk,jn) * z_hdivn_x
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_xad, kt)    ! save the trends
+
+            ! 3.2) Passive tracer MERIDIONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+ 
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+
+                     !-- Compute merid. divergence by splitting hdivn (see divcur.F90)
+                     !   N.B. This computation is not valid along OBCs (if any)
+                     zbtr      = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * vn(ji,jj  ,jk)          &
+                          &       - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk) ) * zbtr
+
+                     !-- Compute merid. advection trends
+                     ztrtrd(ji,jj,jk) = - ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) ) * zbtr &
+                          &             + trb(ji,jj,jk,jn) * z_hdivn_y
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_yad, kt)     ! save the trends
+
+            ! 3.3) Passive tracer VERTICAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! Vector opt.
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     ztrtrd(ji,jj,jk) = - ( ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) * zbtr   &
+                          &             - trb(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zad, kt)     ! save the trends
+
+         ENDIF
+
+         ! 4. Update and guess with monotonic sheme
+         ! ----------------------------------------
+         DO jk = 1, jpkm1
+            z2dtt = z2 * rdttra(jk) * FLOAT(ndttrc)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  tra(ji,jj,jk,jn) =  tra(ji,jj,jk,jn) + zti(ji,jj,jk)
+                  zti (ji,jj,jk) = ( trb(ji,jj,jk,jn) + z2dtt * zti(ji,jj,jk) ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! 5. Lateral boundary conditions on zti, zsi (unchanged sign)
+         ! -----------------------------------------------------------
+         CALL lbc_lnk( zti, 'T', 1. )
+
+
+         ! ============================================================
+         ! II.              Corrected advective trends
+         ! ============================================================
+
+         ! 1. Antidiffusive flux : high order minus low order
+         ! --------------------------------------------------
+         ! Antidiffusive flux on i and j
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zeu = 0.5 * e2u(ji,jj) * fse3u(ji,jj,jk) * zun(ji,jj,jk)
+                  zev = 0.5 * e1v(ji,jj) * fse3v(ji,jj,jk) * zvn(ji,jj,jk)
+                  ztu(ji,jj,jk) = zeu * ( trn(ji,jj,jk,jn) + trn(ji+1,jj,jk,jn) ) - ztu(ji,jj,jk)
+                  ztv(ji,jj,jk) = zev * ( trn(ji,jj,jk,jn) + trn(ji,jj+1,jk,jn) ) - ztv(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! Antidiffusive flux on k
+         ztw(:,:,1) = 0.e0    ! surface value
+         DO jk = 2, jpkm1     ! interior value
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zew = 0.5 * e1t(ji,jj) * e2t(ji,jj) * zwn(ji,jj,jk)
+                  ztw(ji,jj,jk) = zew * ( trn(ji,jj,jk,jn) + trn(ji,jj,jk-1,jn) ) - ztw(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! Lateral bondary conditions
+         CALL lbc_lnk( ztu, 'U', -1. )
+         CALL lbc_lnk( ztv, 'V', -1. )
+         CALL lbc_lnk( ztw, 'W',  1. )
+
+         ! 2. Monotonicity algorithm
+         ! -------------------------
+         CALL nonosc( trb(:,:,:,jn), ztu, ztv, ztw, zti, z2 )
+
+
+         ! 3. Final trend with corrected fluxes
+         ! ------------------------------------
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn)   &
+                     &         - ( ztu(ji,jj,jk) - ztu(ji-1,jj  ,jk  )   &
+                     &           + ztv(ji,jj,jk) - ztv(ji  ,jj-1,jk  )   &
+                     &           + ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) * zbtr
+#if defined key_trc_diatrd
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) -  &
+                        &                          zbtr * ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) )
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) -  &
+                        &                          zbtr * ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )
+                  IF ( luttrd(jn) ) &
+                     trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3) -  &
+                        &                          zbtr * ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) )
+#endif
+
+               END DO
+            END DO
+         END DO
+
+#if defined key_trc_diatrd
+         DO jk = 1,jpk
+            DO jj = 2,jpjm1
+               DO  ji = 2,jpim1
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  zgm = zbtr * trn(ji,jj,jk,jn) *     &
+                     &         (  zun(ji  ,jj,jk) * e2u(ji  ,jj) * fse3u(ji  ,jj,jk)    &
+                     &          - zun(ji-1,jj,jk) * e2u(ji-1,jj) * fse3u(ji-1,jj,jk) )
+
+                  zgz = zbtr * trn(ji,jj,jk,jn) *     &
+                     &         (  zvn(ji,jj  ,jk) * e1v(ji,jj  ) * fse3v(ji,jj  ,jk)    &
+                     &          - zvn(ji,jj-1,jk) * e1v(ji,jj-1) * fse3v(ji,jj-1,jk) )
+
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),1) = trtrd(ji,jj,jk,ikeep(jn),1) + zgm
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),2) = trtrd(ji,jj,jk,ikeep(jn),2) + zgz
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = trtrd(ji,jj,jk,ikeep(jn),3)    &
+                     &            - trn(ji,jj,jk,jn) * hdivn(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         ! Lateral boundary conditions on trtrd:
+
+         IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),1), 'T', 1. )
+         IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),2), 'T', 1. )
+         IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),3), 'T', 1. )
+#endif
+
+         ! 4. Save the advective trends for diagnostics
+         ! --------------------------------------------
+         ! Warning : mass fluxes should probably be converted into advection 
+         ! terms in the computations below ???
+
+         IF( l_trdtrc ) THEN
+            
+            ! 4.1) Passive tracer ZONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     ztrtrd(ji,jj,jk) = - ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) ) * zbtr
+                  END DO
+               END DO
+            END DO
+            
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_xad, kt)   ! <<< ADD TO PREVIOUSLY COMPUTED
+
+            ! 4.2) Passive tracer MERIDIONAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     ztrtrd(ji,jj,jk) = - ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) ) * zbtr 
+                  END DO
+               END DO
+            END DO
+            
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_yad, kt)   ! <<< ADD TO PREVIOUSLY COMPUTED
+            
+            ! 4.3) Passive tracer VERTICAL advection trends
+            ztrtrd(:,:,:) = 0.e0
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                     ztrtrd(ji,jj,jk) = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr
+                  END DO
+               END DO
+            END DO
+            
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zad, kt)   ! <<< ADD TO PREVIOUSLY COMPUTED
+            
+         ENDIF
+
+
+      END DO
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('tvd - adv')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_adv_tvd
+
+
+   SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, prdt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE nonosc  ***
+      !!     
+      !! **  Purpose :   compute monotonic tracer fluxes from the upstream 
+      !!       scheme and the before field by a nonoscillatory algorithm 
+      !!
+      !! **  Method  :   ... ???
+      !!       warning : pbef and paft must be masked, but the boundaries
+      !!       conditions on the fluxes are not necessary zalezak (1979)
+      !!       drange (1995) multi-dimensional forward-in-time and upstream-
+      !!       in-space based differencing for fluid
+      !!
+      !! History :
+      !!        !  97-04  (L. Mortier) Original code
+      !!        !  00-02  (H. Loukos)  rewritting for opa8
+      !!        !  00-10  (M.A Foujols, E. Kestenare)  lateral b.c.
+      !!        !  01-03  (E. Kestenare)  add key_passivetrc
+      !!        !  01-07  (E. Durand G. Madec)  adapted for T & S
+      !!   8.5  !  02-06  (G. Madec)  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT( in ) ::   &
+         prdt                               ! ???
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT( inout ) ::   &
+         pbef,                            & ! before field
+         paft,                            & ! after field
+         paa,                             & ! monotonic flux in the i direction
+         pbb,                             & ! monotonic flux in the j direction
+         pcc                                ! monotonic flux in the k direction
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk               ! dummy loop indices
+      INTEGER ::   ikm1
+      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   zbetup, zbetdo
+      REAL(wp) ::   zpos, zneg, zbt, za, zb, zc, zbig, zrtrn, z2dtt
+      !!----------------------------------------------------------------------
+
+      zbig = 1.e+40
+      zrtrn = 1.e-15
+      zbetup(:,:,:) = 0.e0   ;   zbetdo(:,:,:) = 0.e0
+
+      ! Search local extrema
+      ! --------------------
+      ! large negative value (-zbig) inside land
+      ! large negative value (-zbig) inside land
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
+      ! search maximum in neighbourhood
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbetup(ji,jj,jk) = MAX(  pbef(ji  ,jj  ,jk  ), paft(ji  ,jj  ,jk  ),   &
+                  &                     pbef(ji-1,jj  ,jk  ), pbef(ji+1,jj  ,jk  ),   &
+                  &                     paft(ji-1,jj  ,jk  ), paft(ji+1,jj  ,jk  ),   &
+                  &                     pbef(ji  ,jj-1,jk  ), pbef(ji  ,jj+1,jk  ),   &
+                  &                     paft(ji  ,jj-1,jk  ), paft(ji  ,jj+1,jk  ),   &
+                  &                     pbef(ji  ,jj  ,ikm1), pbef(ji  ,jj  ,jk+1),   &
+                  &                     paft(ji  ,jj  ,ikm1), paft(ji  ,jj  ,jk+1)  )
+            END DO
+         END DO
+      END DO
+      ! large positive value (+zbig) inside land
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
+      ! search minimum in neighbourhood
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zbetdo(ji,jj,jk) = MIN(  pbef(ji  ,jj  ,jk  ), paft(ji  ,jj  ,jk  ),   &
+                  &                     pbef(ji-1,jj  ,jk  ), pbef(ji+1,jj  ,jk  ),   &
+                  &                     paft(ji-1,jj  ,jk  ), paft(ji+1,jj  ,jk  ),   &
+                  &                     pbef(ji  ,jj-1,jk  ), pbef(ji  ,jj+1,jk  ),   &
+                  &                     paft(ji  ,jj-1,jk  ), paft(ji  ,jj+1,jk  ),   &
+                  &                     pbef(ji  ,jj  ,ikm1), pbef(ji  ,jj  ,jk+1),   &
+                  &                     paft(ji  ,jj  ,ikm1), paft(ji  ,jj  ,jk+1)  )
+            END DO
+         END DO
+      END DO
+
+      ! restore masked values to zero
+      pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:)
+      paft(:,:,:) = paft(:,:,:) * tmask(:,:,:)
+ 
+
+      ! 2. Positive and negative part of fluxes and beta terms
+      ! ------------------------------------------------------
+
+      DO jk = 1, jpkm1
+         z2dtt = prdt * rdttra(jk) * FLOAT(ndttrc)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ! positive & negative part of the flux
+               zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+               zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+               ! up & down beta terms
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
+               zbetup(ji,jj,jk) = ( zbetup(ji,jj,jk) - paft(ji,jj,jk) ) / (zpos+zrtrn) * zbt
+               zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zbetdo(ji,jj,jk) ) / (zneg+zrtrn) * zbt
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on zbetup & zbetdo   (unchanged sign)
+      CALL lbc_lnk( zbetup, 'T', 1. )
+      CALL lbc_lnk( zbetdo, 'T', 1. )
+
+
+      ! 3. monotonic flux in the i direction, i.e. paa
+      ! ----------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zc = paa(ji,jj,jk)
+               IF( zc >= 0. ) THEN
+                  za = MIN( 1., zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
+                  paa(ji,jj,jk) = za * zc
+               ELSE
+                  zb = MIN( 1., zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
+                  paa(ji,jj,jk) = zb * zc
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on paa   (changed sign)
+      CALL lbc_lnk( paa, 'U', -1. )
+
+
+      ! 4. monotonic flux in the j direction, i.e. pbb
+      ! ----------------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zc = pbb(ji,jj,jk)
+               IF( zc >= 0. ) THEN
+                  za = MIN( 1., zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
+                  pbb(ji,jj,jk) = za * zc
+               ELSE
+                  zb = MIN( 1., zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
+                  pbb(ji,jj,jk) = zb * zc
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on pbb   (changed sign)
+      CALL lbc_lnk( pbb, 'V', -1. )
+
+
+      ! monotonic flux in the k direction, i.e. pcc
+      ! -------------------------------------------
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zc = pcc(ji,jj,jk)
+               IF( zc >= 0. ) THEN
+                  za = MIN( 1., zbetdo(ji,jj,jk), zbetup(ji,jj,jk-1) )
+                  pcc(ji,jj,jk) = za * zc
+               ELSE
+                  zb = MIN( 1., zbetup(ji,jj,jk), zbetdo(ji,jj,jk-1) )
+                  pcc(ji,jj,jk) = zb * zc
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! lateral boundary condition on pcc   (unchanged sign)
+      CALL lbc_lnk( pcc, 'W', 1. )
+
+   END SUBROUTINE nonosc
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_adv_tvd( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_adv_tvd: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_adv_tvd
+#endif
+
+   !!======================================================================
+END MODULE trcadv_tvd
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbc.F90	(revision 1844)
@@ -0,0 +1,251 @@
+MODULE trcbbc
+   !!======================================================================
+   !!                       ***  MODULE  trcbbc  ***
+   !! Ocean passive tracers:  bottom boundary condition
+   !!======================================================================
+   !! History :  8.1  !  99-10  (G. Madec)  original code
+   !!            8.5  !  02-08  (G. Madec)  free form + modules
+   !!                 !  02-11  (A. Bozec)  trc_bbc_init
+   !!            9.0  !  04-03  (C. Ethe)  adpated for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top && defined key_trcbbc
+   !!----------------------------------------------------------------------
+   !!   'key_trcbbc'                                  geothermal heat flux
+   !!----------------------------------------------------------------------
+   !!   trc_bbc      : update the tracer trend at ocean bottom 
+   !!   trc_bbc_init : initialization of geothermal heat flux trend
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trc                 ! ocean passive tracers variables
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_bbc          ! routine called by trcstp.F90
+
+   !! >>>>>>>>>>>>>>>>>>>>>>>>> MOVE TO NAMELIST >>>>>>>>>>>>>>>>>>>>>>>>>>
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbc = .TRUE.   !: bbc flag
+   
+   INTEGER ::   ngeo_trc_flux = 1              !!! ** bbc namelist (nambbc) **
+   !                                           ! Geothermal flux (0:no flux, 1:constant flux,
+   !                                           !                  2:read in file )
+   REAL(wp) ::   ngeo_trc_flux_const = 86.4e-3 !!! ** bbc namlist **
+   !                                           ! Constant value of geothermal heat flux
+
+   INTEGER, DIMENSION(jpi,jpj) ::   nbotlevt   ! ocean bottom level index at T-pt
+   REAL(wp), DIMENSION(jpi,jpj) ::   qgh_trd   ! geothermal heating trend
+   !! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!  TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcbbc.F90,v 1.11 2006/09/12 11:10:13 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_bbc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_bbc  ***
+      !!
+      !! ** Purpose :   Compute the bottom boundary contition on passive tracer 
+      !!      associated with geothermal heating and add it to the general
+      !!      trend of tracers equations.
+      !!
+      !! ** Method  :   The geothermal heat flux set to its constant value of 
+      !!       86.4 mW/m2 (Stein and Stein 1992, Huang 1999).
+      !!       The temperature trend associated to this heat flux through the
+      !!       ocean bottom can be computed once and is added to the temperature
+      !!       trend juste above the bottom at each time step:
+      !!            tra = tra + Qsf / (rau0 rcp e3T) for k= mbathy -1
+      !!       Where Qsf is the geothermal heat flux.
+      !!
+      !! ** Action  : - update the temperature trends tra with the trend of
+      !!                the ocean bottom boundary condition
+      !!
+      !! References :
+      !!      Stein, C. A., and S. Stein, 1992, Nature, 359, 123-129.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                         ! ocean time-step index
+
+#if defined key_vectopt_loop 
+      INTEGER ::   ji, jn                                   ! dummy loop indices
+#else
+      INTEGER ::   ji, jj, jn                               ! dummy loop indices
+#endif
+      REAL(wp) ::   ztra                                    ! temporary scalar
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd   ! trends
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization
+      ! -----------------
+
+      IF( kt == nittrc000 )   CALL trc_bbc_init
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+
+      ! 1. Add the geothermal heat flux trend on temperature
+      ! ----------------------------------------------------
+
+      SELECT CASE ( ngeo_trc_flux )
+
+      CASE ( 1:2 )                !  geothermal heat flux
+
+         !                                                       ! ===========
+         DO jn = 1, jptra                                        ! tracer loop
+            !                                                    ! ===========
+            IF( l_trdtrc )  ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
+
+
+#if defined key_vectopt_loop
+            DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+               tra(ji,1,nbotlevt(ji,1),jn) = tra(ji,1,nbotlevt(ji,1),jn) + qgh_trd(ji,1)
+            END DO
+#else
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  tra(ji,jj,nbotlevt(ji,jj),jn) = tra(ji,jj,nbotlevt(ji,jj),jn) + qgh_trd(ji,jj)
+               END DO
+            END DO
+#endif
+            
+            IF( l_trdtrc ) THEN
+               ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+               IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_bbc, kt)
+            END IF
+
+            !                                                    ! ===========
+         END DO                                                  ! tracer loop
+         !                                                       ! ===========
+
+         IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+         IF( ln_ctl ) THEN     ! print mean trends (used for debugging)
+            WRITE(charout, FMT="('bbc')")
+            CALL prt_ctl_trc_info(charout)
+            CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+         ENDIF
+      END SELECT
+
+   END SUBROUTINE trc_bbc
+
+
+   SUBROUTINE trc_bbc_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_bbc_init  ***
+      !!
+      !! ** Purpose :   Compute once for all the trend associated with geo-
+      !!      thermal heating that will be applied at each time step at the
+      !!      bottom ocean level
+      !!
+      !! ** Method  :   Read the namtopbbc namelist and check the parameters.
+      !!      called at the first time step (nittrc000)
+      !!
+      !! ** Input   : - Namlist namtopbbc
+      !!              - NetCDF file  : passivetrc_geothermal_heating.nc 
+      !!                               ( if necessary )
+      !!
+      !! ** Action  : - compute the heat geothermal trend qgh_trd
+      !!              - compute the bottom ocean level nbotlevt
+      !!----------------------------------------------------------------------
+      USE iom
+
+      CHARACTER (len=32) ::   clname
+      INTEGER  ::   ji, jj              ! dummy loop indices
+      INTEGER  ::   inum                ! temporary logical unit
+
+      NAMELIST/namtopbbc/ngeo_trc_flux, ngeo_trc_flux_const 
+      !!----------------------------------------------------------------------
+
+      ! Read Namelist nambbc : bottom momentum boundary condition
+      REWIND ( numnat )
+      READ   ( numnat, namtopbbc )
+
+      ! Control print
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'trc_bbc : Passive tracers Bottom Boundary Condition (bbc)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~   Geothermal heatflux'
+      IF(lwp) WRITE(numout,*) '          Namelist namtrcbbc : set bbc parameters'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '             Geothermal flux           ngeo_trc_flux       = ', ngeo_trc_flux
+      IF(lwp) WRITE(numout,*) '             Constant geothermal flux  ngeo_trc_flux_const = ', ngeo_trc_flux_const
+      IF(lwp) WRITE(numout,*)
+
+      ! level of the ocean bottom at T-point
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            nbotlevt(ji,jj) = MAX( mbathy(ji,jj)-1, 1 )
+         END DO
+      END DO
+
+      ! initialization of geothermal heat flux
+
+      SELECT CASE ( ngeo_trc_flux )
+
+      CASE ( 0 )                ! no geothermal heat flux
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '             *** no geothermal heat flux'
+
+      CASE ( 1 )                ! constant flux
+         IF(lwp) WRITE(numout,*) '             *** constant heat flux  =   ', ngeo_trc_flux_const
+         qgh_trd(:,:) = ngeo_trc_flux_const
+
+      CASE ( 2 )                ! variable geothermal heat flux
+         ! read the geothermal fluxes in mW/m2
+         CALL iom_open ( 'geothermal_heating_trc.nc', inum )
+         CALL iom_get ( inum, jpdom_data, 'heatflow', qgh_trd )
+         CALL iom_close (inum)
+
+         qgh_trd(:,:) = qgh_trd(:,:) * 1.e-3 ! conversion in W/m2
+
+      CASE DEFAULT
+         WRITE(ctmp1,*) '     bad flag value for ngeo_flux = ', ngeo_flux
+         CALL ctl_stop( ctmp1 )
+
+      END SELECT
+
+      ! geothermal heat flux trend
+
+      SELECT CASE ( ngeo_trc_flux )
+
+      CASE ( 1:2 )                !  geothermal heat flux
+
+#if defined key_vectopt_loop
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+            qgh_trd(ji,1) = ro0cpr * qgh_trd(ji,1) / fse3t(ji,1,nbotlevt(ji,1) )
+         END DO
+#else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               qgh_trd(ji,jj) = ro0cpr * qgh_trd(ji,jj) / fse3t(ji,jj,nbotlevt(ji,jj))
+            END DO
+         END DO
+#endif
+
+      END SELECT
+
+   END SUBROUTINE trc_bbc_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbc = .FALSE.  !: bbc flag
+CONTAINS
+   SUBROUTINE trc_bbc( kt )           ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_bbc: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_bbc
+#endif
+
+   !!======================================================================
+END MODULE trcbbc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl.F90	(revision 1844)
@@ -0,0 +1,558 @@
+MODULE trcbbl
+   !!======================================================================
+   !!                       ***  MODULE  trcbbl  ***
+   !! Ocean passive tracers physics :  advective and/or diffusive bottom boundary 
+   !!                                  layer scheme
+   !!======================================================================
+   !! History :  8.0  !  96-06  (L. Mortier)  Original code
+   !!            8.0  !  97-11  (G. Madec)  Optimization
+   !!            8.5  !  02-08  (G. Madec)  free form + modules
+   !!            9.0  !  04-03  (C. Ethe)   Adaptation for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if  defined key_top && ( defined key_trcbbl_dif   ||   defined key_trcbbl_adv ) && ! defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_trcbbl_dif'   or            diffusive bottom boundary layer
+   !!   'key_trcbbl_adv'                 advective bottom boundary layer
+   !!----------------------------------------------------------------------
+   !!   trc_bbl_dif  : update the passive tracer trends due to the bottom
+   !!                  boundary layer (diffusive only)
+   !!   trc_bbl_adv  : update the passive tracer trends due to the bottom
+   !!                  boundary layer (advective and/or diffusive)
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trc                 ! ocean passive tracers variables
+   USE trctrp_lec          ! passive tracers transport
+   USE prtctl_trc          ! Print control for debbuging
+   USE eosbn2
+   USE lbclnk
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_bbl_dif    ! routine called by step.F90
+   PUBLIC trc_bbl_adv    ! routine called by step.F90
+
+# if defined key_trcbbl_dif
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_dif = .TRUE.   !: diffusive bottom boundary layer flag
+# else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_dif = .FALSE.  !: diffusive bottom boundary layer flag
+# endif
+
+# if defined key_trcbbl_adv
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_adv = .TRUE.   !: advective bottom boundary layer flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   u_trc_bbl  !: veloc. involved in the advective BBL
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   v_trc_bbl  !: veloc. involved in the advective BBL
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   w_trc_bbl  !: vertic. increment of veloc. due to adv. BBL
+   !                                                        !  only affect tracer vertical advection
+# else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_adv = .FALSE.  !: advective bottom boundary layer flag
+# endif
+
+   INTEGER, DIMENSION(jpi,jpj) ::   mbkt, mbku, mbkv
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcbbl.F90,v 1.12 2006/09/12 11:10:13 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_bbl_dif( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_bbl_dif  ***
+      !!
+      !! ** Purpose :   Compute the before tracer trend associated 
+      !!      with the bottom boundary layer and add it to the general trend 
+      !!      of tracer equations. The bottom boundary layer is supposed to be
+      !!      a purely diffusive bottom boundary layer.
+      !!
+      !! ** Method  :   When the product grad( rho) * grad(h) < 0 (where grad 
+      !!      is an along bottom slope gradient) an additional lateral diffu-
+      !!      sive trend along the bottom slope is added to the general tracer
+      !!      trend, otherwise nothing is done.
+      !!      Second order operator (laplacian type) with variable coefficient
+      !!      computed as follow for temperature (idem on s): 
+      !!         difft = 1/(e1t*e2t*e3t) { di-1[ ahbt e2u*e3u/e1u di[ztb] ]
+      !!                                 + dj-1[ ahbt e1v*e3v/e2v dj[ztb] ] }
+      !!      where ztb is a 2D array: the bottom ocean temperature and ahtb
+      !!      is a time and space varying diffusive coefficient defined by:
+      !!         ahbt = zahbp    if grad(rho).grad(h) < 0
+      !!              = 0.       otherwise.
+      !!      Note that grad(.) is the along bottom slope gradient. grad(rho)
+      !!      is evaluated using the local density (i.e. referenced at the
+      !!      local depth). Typical value of ahbt is 2000 m2/s (equivalent to
+      !!      a downslope velocity of 20 cm/s if the condition for slope
+      !!      convection is satified)
+      !!      Add this before trend to the general trend tra of the 
+      !!      botton ocean tracer point:
+      !!         tra = tra + difft
+      !!
+      !! ** Action  : - update tra at the bottom level with the bottom
+      !!                boundary layer trend
+      !!
+      !! References :
+      !!     Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrtrd => ua                      ! use ua as 3D workspace   
+      !!
+      INTEGER, INTENT( in ) ::   kt                         ! ocean time-step
+      INTEGER ::   ji, jj, jn                               ! dummy loop indices
+      INTEGER ::   ik, iku, ikv
+      INTEGER ::   ii0, ii1, ij0, ij1                       ! temporary integers
+      INTEGER ::   iku1, iku2, ikv1, ikv2                   ! temporary intergers
+      REAL(wp) ::  ze3u, ze3v                              ! temporary scalars
+      REAL(wp) ::  zbtr, ztra
+#if ! defined key_off_tra
+      REAL(wp) ::   zgdrho, zalbet, zsign, zt, zs, zh
+      REAL(wp), DIMENSION(jpi,jpj) ::   zki, zkj
+#endif
+      REAL(wp), DIMENSION(jpi,jpj) ::   zkx, zky  ! temporary workspace arrays
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztnb, zsnb, zdep
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztrb, zahu, zahv
+
+      CHARACTER (len=22) :: charout
+      REAL(wp) ::   fsalbt, pft, pfs, pfh                   ! statement function
+      !!----------------------------------------------------------------------
+      ! ratio alpha/beta
+      ! ================
+      !  fsalbt: ratio of thermal over saline expension coefficients
+      !       pft :  potential temperature in degrees celcius
+      !       pfs :  salinity anomaly (s-35) in psu
+      !       pfh :  depth in meters
+
+      fsalbt( pft, pfs, pfh ) =                                              &
+         ( ( ( -0.255019e-07 * pft + 0.298357e-05 ) * pft                    &
+                                   - 0.203814e-03 ) * pft                    &
+                                   + 0.170907e-01 ) * pft                    &
+                                   + 0.665157e-01                            &
+         +(-0.678662e-05 * pfs - 0.846960e-04 * pft + 0.378110e-02 ) * pfs   &
+         +  ( ( - 0.302285e-13 * pfh                                         &
+                - 0.251520e-11 * pfs                                         &
+                + 0.512857e-12 * pft * pft          ) * pfh                  &
+                                     - 0.164759e-06   * pfs                  &
+             +(   0.791325e-08 * pft - 0.933746e-06 ) * pft                  &
+                                     + 0.380374e-04 ) * pfh   
+      !!----------------------------------------------------------------------
+
+
+      IF( kt == nittrc000 )   CALL trc_bbl_init
+
+
+      ! 0. 2D fields of bottom temperature and salinity, and bottom slope
+      ! -----------------------------------------------------------------
+      ! mbathy= number of w-level, minimum value=1 (cf dommsk.F)
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#  endif
+            ik = mbkt(ji,jj)                              ! index of the bottom ocean T-level
+            ztnb(ji,jj) = tn(ji,jj,ik) * tmask(ji,jj,1)   ! masked now T and S at ocean bottom 
+            zsnb(ji,jj) = sn(ji,jj,ik) * tmask(ji,jj,1)
+            zdep(ji,jj) = fsdept(ji,jj,ik)                ! depth of the ocean bottom T-level
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      IF( ln_zps ) THEN      ! partial steps correction
+
+#   if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#   else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#   endif
+               iku1 = MAX( mbathy(ji+1,jj  )-1, 1 )
+               iku2 = MAX( mbathy(ji  ,jj  )-1, 1 )
+               ikv1 = MAX( mbathy(ji  ,jj+1)-1, 1 )
+               ikv2 = MAX( mbathy(ji  ,jj  )-1, 1 )
+               ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+               ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+               zahu(ji,jj) = atrcbbl * e2u(ji,jj) * ze3u / e1u(ji,jj) * umask(ji,jj,1)
+               zahv(ji,jj) = atrcbbl * e1v(ji,jj) * ze3v / e2v(ji,jj) * vmask(ji,jj,1)
+#   if ! defined key_vectopt_loop
+            END DO
+#   endif
+         END DO
+      ELSE                  ! z-coordinate - full steps or s-coordinate
+#   if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#   else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#   endif
+               iku = mbku(ji,jj)
+               ikv = mbkv(ji,jj)
+               zahu(ji,jj) = atrcbbl * e2u(ji,jj) * fse3u(ji,jj,iku) / e1u(ji,jj) * umask(ji,jj,1)
+               zahv(ji,jj) = atrcbbl * e1v(ji,jj) * fse3v(ji,jj,ikv) / e2v(ji,jj) * vmask(ji,jj,1)
+#   if ! defined key_vectopt_loop
+            END DO
+#   endif
+         END DO
+      ENDIF
+
+#if defined key_off_tra
+      !!=====================================================================
+      !!                I. OFFLINE VERSION OF DIFFUSIVE BBL
+      !!=====================================================================
+      
+      ! 1. Criteria of additional bottom diffusivity : grad(rho).grad(h) < 0
+      ! --------------------------------------------------------------------
+      
+      !    Only used in the online version of diffusive BBL (see below)
+      
+      ! 2. Additional second order diffusive trends
+      ! -------------------------------------------
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========       
+
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)
+     
+         ! first derivative (gradient)         
+#  if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#  endif
+               ik = mbkt(ji,jj) 
+               ztrb(ji,jj) = trb(ji,jj,ik,jn) * tmask(ji,jj,1)
+#  if ! defined key_vectopt_loop
+            END DO
+#  endif
+         END DO
+
+#  if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#  endif
+               zkx(ji,jj) = bblx(ji,jj) * zahu(ji,jj) * ( ztrb(ji+1,jj) - ztrb(ji,jj) )
+               zky(ji,jj) = bbly(ji,jj) * zahv(ji,jj) * ( ztrb(ji,jj+1) - ztrb(ji,jj) )
+#  if ! defined key_vectopt_loop
+            END DO
+#  endif
+         END DO
+
+#else
+      !!=====================================================================
+      !!               II. ONLINE VERSION OF DIFFUSIVE BBL
+      !!=====================================================================
+
+      ! 1. Criteria of additional bottom diffusivity : grad(rho).grad(h) < 0
+      ! --------------------------------------------------------------------
+      ! Sign of the local density gradient along the i- and j-slopes
+      ! multiplied by the slope of the ocean bottom
+      SELECT CASE ( nn_eos )
+
+      CASE ( 0 )                 ! Jackett and McDougall (1994) formulation
+         
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! temperature, salinity anomalie and depth
+            zt = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+            zs = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+            zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+            ! masked ratio alpha/beta
+            zalbet = fsalbt( zt, zs, zh )*umask(ji,jj,1)
+            ! local density gradient along i-bathymetric slope
+            zgdrho = zalbet * ( ztnb(ji+1,jj) - ztnb(ji,jj) )   &
+                   -          ( zsnb(ji+1,jj) - zsnb(ji,jj) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! temperature, salinity anomalie and depth
+            zt = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+            zs = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+            zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+            ! masked ratio alpha/beta
+            zalbet = fsalbt( zt, zs, zh )*vmask(ji,jj,1)
+            ! local density gradient along j-bathymetric slope
+            zgdrho = zalbet * ( ztnb(ji,jj+1) - ztnb(ji,jj) )   &
+                   -          ( zsnb(ji,jj+1) - zsnb(ji,jj) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            zsign = SIGN( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+            zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+      
+      CASE ( 1 )                 ! Linear formulation function of temperature only
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! local density gradient along i-bathymetric slope
+            zgdrho =  ( ztnb(ji+1,jj) - ztnb(ji,jj) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+#  if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+#  endif
+            ! local density gradient along j-bathymetric slope
+            zgdrho =  ( ztnb(ji,jj+1) - ztnb(ji,jj) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            zsign = SIGN( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+            zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+
+#  if ! defined key_vectopt_loop
+         END DO
+#  endif
+      END DO
+
+      CASE ( 2 )                 ! Linear formulation function of temperature and salinity
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+            ! local density gradient along i-bathymetric slope
+            zgdrho = - ( rn_beta*( zsnb(ji+1,jj) - zsnb(ji,jj) )   &
+                     -  rn_alpha*( ztnb(ji+1,jj) - ztnb(ji,jj) ) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+ 	    zki(ji,jj) = ( 0.5 - zsign ) * zahu(ji,jj)
+        END DO
+      END DO
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+            ! local density gradient along j-bathymetric slope
+            zgdrho = - ( rn_beta*( zsnb(ji,jj+1) - zsnb(ji,jj) )   &
+                     -  rn_alpha*( ztnb(ji,jj+1) - ztnb(ji,jj) ) )
+            ! sign of local j-gradient of density multiplied by the j-slope
+            zsign = sign( 0.5, -zgdrho * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+            zkj(ji,jj) = ( 0.5 - zsign ) * zahv(ji,jj)
+         END DO
+      END DO
+
+      CASE DEFAULT
+
+         WRITE(ctmp1,*) '          bad flag value for nn_eos = ', nn_eos
+         CALL ctl_stop( ctmp1 )
+
+      END SELECT
+      
+      ! 2. Additional second order diffusive trends
+      ! -------------------------------------------
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)
+
+         ! first derivative (gradient)
+#  if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+#  endif
+               ik = mbkt(ji,jj)
+               ztrb(ji,jj) = trb(ji,jj,ik,jn) * tmask(ji,jj,1)
+#  if ! defined key_vectopt_loop
+            END DO
+#  endif
+         END DO
+#  if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+#  endif
+               zkx(ji,jj) = zki(ji,jj) * ( ztrb(ji+1,jj) - ztrb(ji,jj) )
+               zky(ji,jj) = zkj(ji,jj) * ( ztrb(ji,jj+1) - ztrb(ji,jj) )
+#  if ! defined key_vectopt_loop
+            END DO
+#  endif
+         END DO
+#endif
+
+      !!=====================================================================
+      !!     III. COMMON CODE FOR OFFLINE/ONLINE VERSIONS OF DIFFUSIVE BBL
+      !!=====================================================================
+
+         IF( cp_cfg == "orca" ) THEN
+            
+            SELECT CASE ( jp_cfg )
+               !                                        ! =======================
+            CASE ( 2 )                                  !  ORCA_R2 configuration
+               !                                        ! =======================
+               ! Gibraltar enhancement of BBL
+               ij0 = 102   ;   ij1 = 102
+               ii0 = 139   ;   ii1 = 140  
+               zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               
+               ! Red Sea enhancement of BBL
+               ij0 =  88   ;   ij1 =  88
+               ii0 = 161   ;   ii1 = 162
+               zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 10.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 10.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               
+               !                                        ! =======================
+            CASE ( 4 )                                  !  ORCA_R4 configuration
+               !                                        ! =======================
+               ! Gibraltar enhancement of BBL
+               ij0 =  52   ;   ij1 =  52
+               ii0 =  70   ;   ii1 =  71  
+               zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zkx( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 4.e0 * zky( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) )
+               
+            END SELECT
+            
+         ENDIF
+         
+         ! second derivative (divergence) and add to the general tracer trend
+#  if defined key_vectopt_loop
+         jj = 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+#  else
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+#  endif
+               ik = MAX( mbathy(ji,jj)-1, 1 )
+               zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,ik) )
+               ztra = (  zkx(ji,jj) - zkx(ji-1,jj  )    &
+                  &    + zky(ji,jj) - zky(ji  ,jj-1)  ) * zbtr
+               tra(ji,jj,ik,jn) = tra(ji,jj,ik,jn) + ztra
+#  if ! defined key_vectopt_loop
+            END DO
+#  endif
+         END DO
+
+         ! save the trends for diagnostic
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_bbl, kt )
+         END IF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('bbl - dif')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_bbl_dif
+
+# if defined key_trcbbl_adv
+   !!----------------------------------------------------------------------
+   !!   'key_trcbbl_adv'                    advective bottom boundary layer
+   !!----------------------------------------------------------------------
+#  include "trcbbl_adv.h90"
+# else
+   !!----------------------------------------------------------------------
+   !!   Default option :                 NO advective bottom boundary layer
+   !!----------------------------------------------------------------------
+   SUBROUTINE trc_bbl_adv (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_bbl_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_bbl_adv
+# endif
+
+   SUBROUTINE trc_bbl_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_bbl_init  ***
+      !!
+      !! ** Purpose :   Initialization for the bottom boundary layer scheme.
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj
+      REAL(wp),  DIMENSION(jpi,jpj) ::   zmbk  
+      !!----------------------------------------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            mbkt(ji,jj) = MAX( mbathy(ji,jj) - 1, 1 )   ! vertical index of the bottom ocean T-level
+         END DO
+      END DO
+      
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            mbku(ji,jj) = MAX( MIN( mbathy(ji+1,jj  ), mbathy(ji,jj) ) - 1, 1 )
+            mbkv(ji,jj) = MAX( MIN( mbathy(ji  ,jj+1), mbathy(ji,jj) ) - 1, 1 )
+         END DO
+      END DO
+
+      zmbk(:,:) = FLOAT( mbku (:,:) )   
+      CALL lbc_lnk(zmbk,'U',1.)
+      mbku (:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
+	
+      zmbk(:,:) = FLOAT( mbkv (:,:) )   
+      CALL lbc_lnk(zmbk,'V',1.)
+      mbkv (:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
+
+# if defined key_trcbbl_adv
+      w_trc_bbl(:,:,:) = 0.e0    ! initialisation of w_trc_bbl to zero
+# endif
+
+   END SUBROUTINE trc_bbl_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      No bottom boundary layer scheme
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_dif = .FALSE.   !: diff bbl flag
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trcbbl_adv = .FALSE.   !: adv  bbl flag
+CONTAINS
+   SUBROUTINE trc_bbl_dif (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_bbl_dif: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_bbl_dif
+   SUBROUTINE trc_bbl_adv (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_bbl_adv: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_bbl_adv
+#endif
+
+   !!======================================================================
+END MODULE trcbbl
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl_adv.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl_adv.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcbbl_adv.h90	(revision 1844)
@@ -0,0 +1,490 @@
+   !!----------------------------------------------------------------------
+   !!                     ***  trcbbl_adv.h90  ***
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE trc_bbl_adv( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_bbl_adv  ***
+      !!                   
+      !! ** Purpose :   Compute the before tracer trend associated 
+      !!     with the bottom boundary layer and add it to the general trend
+      !!     of tracer equations. The bottom boundary layer is supposed to be 
+      !!     both an advective and diffusive bottom boundary layer.
+      !!
+      !! ** Method  :   Computes the bottom boundary horizontal and vertical 
+      !!      advection terms. Add it to the general trend : tra =tra + adv_bbl.
+      !!        When the product grad( rho) * grad(h) < 0 (where grad is a
+      !!      along bottom slope gradient) an additional lateral 2nd order
+      !!      diffusion along the bottom slope is added to the general
+      !!      tracer trend, otherwise the additional trend is set to 0.
+      !!      Second order operator (laplacian type) with variable coefficient
+      !!      computed as follow for temperature (idem on s):
+      !!         difft = 1/(e1t*e2t*e3t) { di-1[ ahbt e2u*e3u/e1u di[ztb] ]
+      !!                                 + dj-1[ ahbt e1v*e3v/e2v dj[ztb] ] }
+      !!      where ztb is a 2D array: the bottom ocean te;perature and ahtb
+      !!      is a time and space varying diffusive coefficient defined by:
+      !!         ahbt = zahbp    if grad(rho).grad(h) < 0
+      !!              = 0.       otherwise.
+      !!      Note that grad(.) is the along bottom slope gradient. grad(rho)
+      !!      is evaluated using the local density (i.e. referenced at the
+      !!      local depth). Typical value of ahbt is 2000 m2/s (equivalent to
+      !!      a downslope velocity of 20 cm/s if the condition for slope
+      !!      convection is satified)
+      !!        Add this before trend to the general trend tra of the
+      !!      botton ocean tracer point:
+      !!              tra = tra + difft
+      !!
+      !! ** Action  : - update tra at the bottom level with the bottom
+      !!                boundary layer trend
+      !!
+      !! References :
+      !!     Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
+      !!
+      !! History :
+      !!   8.5  !  02-12  (A. de Miranda, G. Madec)  Original Code 
+      !!   9.0  !  04-01  (A. de Miranda, G. Madec, J.M. Molines )
+      !!   9.0  !  04-03  (C. Ethe) Adaptation for Passive tracers 
+      !!----------------------------------------------------------------------     
+      !gh
+      
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt        ! ocean time-step 
+      
+      !! * Local declarations
+      INTEGER :: ji, jj, jk, jn            ! dummy loop indices
+      INTEGER :: ik, iku, ikv              ! temporary integers
+
+      REAL(wp) ::   &
+         zsign, zt, zs, zh, zalbet,     &  ! temporary scalars
+         zgdrho, zbtr, ztra                !    "         " 
+      REAL(wp), DIMENSION(jpi,jpj) ::   &  
+      	 ztnb, zsnb, zdep, ztrb  	   ! temporary workspace arrays 
+      REAL(wp), DIMENSION(jpi,jpj) ::   &  ! temporary workspace arrays
+         zalphax, zwu, zunb,            &  !    "                  "
+         zalphay, zwv, zvnb,            &  !    "                  "
+         zwx, zwy, zww, zwz,            &  !    "                  "
+         zti, zsi ,ztmin,ztmax, zsmin,zsmax!    "                  "
+	                           !    "                  "
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zhdivn                            ! temporary workspace arrays
+      REAL(wp) ::   &
+         zfui, zfvj, zbt,  zsigna,  	&  ! temporary scalars
+	 iku1,iku2,ikv1,ikv2,  		&  ! temporary scalars
+	 ze3u,ze3v,  			&  ! temporary scalars
+	 z2,z2dtt           			! temporary scalars
+      REAL(wp) ::   &
+         fsalbt, pft, pfs, pfh             ! statement function
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+      ! ratio alpha/beta
+      ! ================
+      !  fsalbt: ratio of thermal over saline expension coefficients
+      !       pft :  potential temperature in degrees celcius
+      !       pfs :  salinity anomaly (s-35) in psu
+      !       pfh :  depth in meters
+
+      fsalbt( pft, pfs, pfh ) =                                              &
+         ( ( ( -0.255019e-07 * pft + 0.298357e-05 ) * pft                    &
+                                   - 0.203814e-03 ) * pft                    &
+                                   + 0.170907e-01 ) * pft                    &
+                                   + 0.665157e-01                            &
+         +(-0.678662e-05 * pfs - 0.846960e-04 * pft + 0.378110e-02 ) * pfs   &
+         +  ( ( - 0.302285e-13 * pfh                                         &
+                - 0.251520e-11 * pfs                                         &
+                + 0.512857e-12 * pft * pft          ) * pfh                  &
+                                     - 0.164759e-06   * pfs                  &
+             +(   0.791325e-08 * pft - 0.933746e-06 ) * pft                  &
+                                     + 0.380374e-04 ) * pfh
+      !!----------------------------------------------------------------------
+
+	IF( kt == nit000 )   CALL trc_bbl_init    ! initialization at first time-step
+	
+      ! 1. 2D fields of bottom temperature and salinity, and bottom slope
+      ! -----------------------------------------------------------------
+      ! mbathy= number of w-level, minimum value=1 (cf dommsk.F)
+
+#if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#endif
+            ik = mbkt(ji,jj)                    ! index of the bottom ocean T-level
+            ztnb(ji,jj) = tn(ji,jj,ik)   	! masked now T at the ocean bottom 
+            zsnb(ji,jj) = sn(ji,jj,ik)  	! masked now S at the ocean bottom
+            zdep(ji,jj) = fsdept(ji,jj,ik)                 ! depth of the ocean bottom T-level
+!gh
+            zunb(ji,jj) = un(ji,jj,mbku(ji,jj)) 
+            zvnb(ji,jj) = vn(ji,jj,mbkv(ji,jj)) 
+#if ! defined key_vectopt_loop
+         END DO
+#endif
+      END DO
+
+      ! 2. Criteria of additional bottom diffusivity: grad(rho).grad(h)<0
+      ! --------------------------------------------
+      ! Sign of the local density gradient along the i- and j-slopes
+      ! multiplied by the slope of the ocean bottom
+
+      SELECT CASE ( nn_eos )
+
+      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+      !   ... temperature, salinity anomalie and depth
+          zt = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+          zs = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+          zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+      !   ... masked ratio alpha/beta
+          zalbet = fsalbt( zt, zs, zh )*umask(ji,jj,1)
+      !   ... local density gradient along i-bathymetric slope
+          zgdrho = zalbet*( ztnb(ji+1,jj) - ztnb(ji,jj) )   &
+                     -    ( zsnb(ji+1,jj) - zsnb(ji,jj) )
+          zgdrho = zgdrho * umask(ji,jj,1)
+      !   ... sign of local i-gradient of density multiplied by the i-slope
+          zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+	  zsigna= SIGN( 0.5, zunb(ji,jj) * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+          zalphax(ji,jj) = ( 0.5 + zsigna ) * ( 0.5-zsign ) * umask(ji,jj,1)
+        END DO
+      END DO
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+      !   ... temperature, salinity anomalie and depth
+          zt = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+          zs = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+          zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+      !   ... masked ratio alpha/beta
+          zalbet = fsalbt( zt, zs, zh )*vmask(ji,jj,1)
+      !   ... local density gradient along j-bathymetric slope
+          zgdrho = zalbet*( ztnb(ji,jj+1) - ztnb(ji,jj) )   &
+                     -    ( zsnb(ji,jj+1) - zsnb(ji,jj) )
+          zgdrho = zgdrho * vmask(ji,jj,1)
+      !   ... sign of local j-gradient of density multiplied by the j-slope
+          zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+	  zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+          zalphay(ji,jj) = ( 0.5 + zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+        END DO
+      END DO
+
+
+      CASE ( 1 )               ! Linear formulation function of temperature only
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+            ! temperature, salinity anomalie and depth
+            zt = 0.5 * ( ztnb(ji,jj) + ztnb(ji+1,jj) )
+            zs = 0.5 * ( zsnb(ji,jj) + zsnb(ji+1,jj) ) - 35.0
+            zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
+!gh            ! masked ratio alpha/beta
+            ! local density gradient along i-bathymetric slope
+            zgdrho =  ( ztnb(ji+1,jj) - ztnb(ji,jj) )   
+            ! sign of local i-gradient of density multiplied by the i-slope
+            zsign = SIGN( 0.5, - zgdrho    * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+	    zsigna= SIGN( 0.5, zunb(ji,jj) * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+            zalphax(ji,jj) = ( 0.5 - zsigna ) * ( 0.5 - zsign ) * umask(ji,jj,1)
+         END DO
+      END DO
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+            ! temperature, salinity anomalie and depth
+            zt = 0.5 * ( ztnb(ji,jj+1) + ztnb(ji,jj) )
+            zs = 0.5 * ( zsnb(ji,jj+1) + zsnb(ji,jj) ) - 35.0
+            zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
+!gh             ! masked ratio alpha/beta
+            ! local density gradient along j-bathymetric slope
+            zgdrho =  ( ztnb(ji,jj+1) - ztnb(ji,jj) )   
+            ! sign of local j-gradient of density multiplied by the j-slope
+            zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+	    zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+            zalphay(ji,jj) = ( 0.5 - zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+         END DO
+      END DO
+       
+      CASE ( 2 )               ! Linear formulation function of temperature and salinity
+ DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+	    ! local density gradient along i-bathymetric slope
+            zgdrho = - ( rn_beta*( zsnb(ji+1,jj) - zsnb(ji,jj) )   &
+                     -  rn_alpha*( ztnb(ji+1,jj) - ztnb(ji,jj) ) )
+            ! sign of local i-gradient of density multiplied by the i-slope
+            zsign = SIGN( 0.5, - zgdrho * ( zdep(ji+1,jj) - zdep(ji,jj) ) )
+	    zsigna= SIGN( 0.5, zunb(ji,jj)*(  zdep(ji+1,jj) - zdep(ji,jj) ))
+            zalphax(ji,jj)=(0.5-zsigna)*(0.5-zsign)*umask(ji,jj,1)
+        END DO
+      END DO
+
+      DO jj = 1, jpjm1
+        DO ji = 1, fs_jpim1   ! vector opt.
+	   ! local density gradient along j-bathymetric slope
+            zgdrho = - ( rn_beta*( zsnb(ji,jj+1) - zsnb(ji,jj) )   &
+                   -    rn_alpha*( ztnb(ji,jj+1) - ztnb(ji,jj) ) )   
+            ! sign of local j-gradient of density multiplied by the j-slope
+            zsign = SIGN( 0.5, -zgdrho     * ( zdep(ji,jj+1) - zdep(ji,jj) ) )  
+	    zsigna= SIGN( 0.5, zvnb(ji,jj) * ( zdep(ji,jj+1) - zdep(ji,jj) ) )
+            zalphay(ji,jj) = ( 0.5 - zsigna ) * ( 0.5 - zsign ) * vmask(ji,jj,1)
+         END DO
+      END DO
+
+       
+      CASE DEFAULT
+
+         IF(lwp) WRITE(numout,cform_err)
+         IF(lwp) WRITE(numout,*) '          bad flag value for nn_eos = ', nn_eos
+         nstop = nstop + 1
+
+      END SELECT
+
+      ! lateral boundary conditions on zalphax and zalphay   (unchanged sign)
+       CALL lbc_lnk( zalphax, 'U', 1. )   ;   CALL lbc_lnk( zalphay, 'V', 1. )
+
+
+      ! 3. Velocities that are exchanged between ajacent bottom boxes.
+      !---------------------------------------------------------------
+      ! ... is equal to zero but where bbl will work.
+       u_trc_bbl(:,:,:) = 0.e0
+       v_trc_bbl(:,:,:) = 0.e0
+       
+       
+!gh	  
+       IF( ln_zps ) THEN
+      ! partial steps correction   
+      
+#if defined key_vectopt_loop
+       jj = 1
+       DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+#else
+       DO jj = 1, jpjm1
+          DO ji = 1, jpim1
+#endif
+             iku  = mbku(ji  ,jj  )
+             ikv  = mbkv(ji  ,jj  )  
+             iku1 = mbkt(ji+1,jj  )
+             iku2 = mbkt(ji  ,jj  )
+             ikv1 = mbkt(ji  ,jj+1)
+             ikv2 = mbkt(ji  ,jj  )
+             ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+             ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+             
+             IF( MAX(iku,ikv) >  1 ) THEN
+                u_trc_bbl(ji,jj,iku) = zalphax(ji,jj) * un(ji,jj,iku) * ze3u / fse3u(ji,jj,iku)
+                v_trc_bbl(ji,jj,ikv) = zalphay(ji,jj) * vn(ji,jj,ikv) * ze3v / fse3v(ji,jj,ikv)       
+             ENDIF
+#if ! defined key_vectopt_loop
+          END DO
+#endif
+       END DO
+
+      ! lateral boundary conditions on u_trc_bbl and v_trc_bbl   (changed sign)
+       CALL lbc_lnk( u_trc_bbl, 'U', -1. )   ;   CALL lbc_lnk( v_trc_bbl, 'V', -1. )
+       
+    ELSE    ! z-coordinate - full steps or s-coordinate	 
+       ! if not partial step loop over the whole domain no lbc call
+
+#if defined key_vectopt_loop
+      jj = 1
+      DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#else
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#endif
+            iku = mbku(ji,jj)
+            ikv = mbkv(ji,jj)
+            IF( MAX(iku,ikv) >  1 ) THEN
+               u_trc_bbl(ji,jj,iku) = zalphax(ji,jj) * un(ji,jj,iku) 
+               v_trc_bbl(ji,jj,ikv) = zalphay(ji,jj) * vn(ji,jj,ikv)       
+            ENDIF
+#if ! defined key_vectopt_loop
+         END DO
+#endif
+          END DO
+       
+       ENDIF
+       
+       DO jn = 1, jptra
+
+#if defined key_vectopt_loop
+          jj = 1
+          DO ji = 1, jpij   ! vector opt. (forced unrolling)
+#else
+          DO jj = 1, jpj
+             DO ji = 1, jpi
+#endif
+                ik = mbkt(ji,jj)                               ! index of the bottom ocean T-level
+                ztrb(ji,jj) = trb(ji,jj,ik,jn) * tmask(ji,jj,1)    ! masked now T at the ocean bottom 
+#if ! defined key_vectopt_loop
+             END DO
+#endif
+          END DO
+
+
+
+          ! 5. Along sigma advective trend
+          ! -------------------------------
+          ! ... Second order centered tracer flux at u and v-points
+       
+# if defined key_vectopt_loop
+          jj = 1
+          DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+          DO jj = 1, jpjm1
+             DO ji = 1, jpim1
+# endif
+                iku = mbku(ji,jj)
+                ikv = mbkv(ji,jj)
+                zfui = e2u(ji,jj) * fse3u(ji,jj,iku) * u_trc_bbl(ji,jj,iku)
+                zfvj = e1v(ji,jj) * fse3v(ji,jj,ikv) * v_trc_bbl(ji,jj,ikv)
+                ! upstream scheme
+                zwx(ji,jj) = ( ( zfui + ABS( zfui ) ) * ztrb(ji  ,jj  )   &
+                   &          +( zfui - ABS( zfui ) ) * ztrb(ji+1,jj  ) ) * 0.5
+                zwy(ji,jj) = ( ( zfvj + ABS( zfvj ) ) * ztrb(ji  ,jj  )   &
+                   &          +( zfvj - ABS( zfvj ) ) * ztrb(ji  ,jj+1) ) * 0.5
+#if ! defined key_vectopt_loop
+             END DO
+#endif
+          END DO
+	  
+# if defined key_vectopt_loop
+          jj = 1
+          DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+          DO jj = 2, jpjm1
+             DO ji = 2, jpim1
+# endif
+                ik = mbkt(ji,jj)
+                zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,ik) )
+                ! horizontal advective trends
+                ztra = - zbtr * (  zwx(ji,jj) - zwx(ji-1,jj  )   &
+                   &             + zwy(ji,jj) - zwy(ji  ,jj-1)  )
+ 
+                ! add it to the general tracer trends
+                tra(ji,jj,ik,jn) = tra(ji,jj,ik,jn) + ztra
+#if ! defined key_vectopt_loop
+             END DO
+#endif
+          END DO
+	  
+        END DO
+	
+        IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('bbl - adv')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF         
+       
+       ! 6. Vertical advection velocities
+       ! --------------------------------
+       ! ... computes divergence perturbation (velocties to be removed from upper t boxes :
+       DO jk= 1, jpkm1
+
+          DO jj=1, jpjm1
+             DO ji = 1, fs_jpim1   ! vertor opt.
+                zwu(ji,jj) = -e2u(ji,jj) * u_trc_bbl(ji,jj,jk) * fse3u(ji,jj,jk)
+                zwv(ji,jj) = -e1v(ji,jj) * v_trc_bbl(ji,jj,jk) * fse3v(ji,jj,jk)
+             END DO
+          END DO
+
+          ! ... horizontal divergence
+          DO jj = 2, jpjm1
+             DO ji = fs_2, fs_jpim1   ! vector opt.
+                zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
+                zhdivn(ji,jj,jk) = (  zwu(ji,jj) - zwu(ji-1,jj  )   &
+                   &                + zwv(ji,jj) - zwv(ji  ,jj-1)  ) / zbt
+             END DO
+          END DO
+       END DO
+
+
+       ! ... horizontal bottom divergence
+!gh
+       IF( ln_zps ) THEN 
+	  
+# if defined key_vectopt_loop
+          jj = 1
+          DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+          DO jj = 1, jpjm1
+             DO ji = 1, jpim1
+# endif
+                iku  = mbku(ji  ,jj  )
+                ikv  = mbkv(ji  ,jj  )  
+                iku1 = mbkt(ji+1,jj  )
+                iku2 = mbkt(ji  ,jj  )
+                ikv1 = mbkt(ji  ,jj+1)
+                ikv2 = mbkt(ji  ,jj  )
+                ze3u = MIN( fse3u(ji,jj,iku1), fse3u(ji,jj,iku2) ) 
+                ze3v = MIN( fse3v(ji,jj,ikv1), fse3v(ji,jj,ikv2) ) 
+                
+                zwu(ji,jj) = zalphax(ji,jj) * e2u(ji,jj) * ze3u  
+                zwv(ji,jj) = zalphay(ji,jj) * e1v(ji,jj) * ze3v
+#if ! defined key_vectopt_loop
+             END DO
+#endif
+          END DO
+	
+       ELSE
+
+# if defined key_vectopt_loop
+          jj = 1
+          DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
+# else
+          DO jj = 1, jpjm1
+             DO ji = 1, jpim1
+# endif
+                iku = mbku(ji,jj)
+                ikv = mbkv(ji,jj)
+                zwu(ji,jj) = zalphax(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,iku) 
+                zwv(ji,jj) = zalphay(ji,jj) * e1v(ji,jj) * fse3v(ji,jj,ikv) 
+#if ! defined key_vectopt_loop 
+             END DO
+#endif
+          END DO
+       ENDIF
+
+# if defined key_vectopt_loop
+       jj = 1
+       DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+       DO jj = 2, jpjm1
+          DO ji = 2, jpim1
+# endif
+             ik = mbkt(ji,jj)
+             zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,ik)
+             zhdivn(ji,jj,ik) =   &
+                &   (  zwu(ji  ,jj  ) * ( zunb(ji  ,jj  ) - un(ji  ,jj  ,ik) )   &
+                &    - zwu(ji-1,jj  ) * ( zunb(ji-1,jj  ) - un(ji-1,jj  ,ik) )   &
+                &    + zwv(ji  ,jj  ) * ( zvnb(ji  ,jj  ) - vn(ji  ,jj  ,ik) )   &
+                &    - zwv(ji  ,jj-1) * ( zvnb(ji  ,jj-1) - vn(ji  ,jj-1,ik) )   &
+                &   ) / zbt
+
+# if ! defined key_vectopt_loop
+          END DO
+# endif
+       END DO
+
+       ! 7. compute additional vertical velocity to be used in t boxes
+       ! -------------------------------------------------------------
+       
+       ! ... Computation from the bottom
+       ! Note that w_trc_bbl(:,:,jpk) has been set to 0 in trc_bbl_init
+       DO jk = jpkm1, 1, -1
+          DO jj= 2, jpjm1
+             DO ji = fs_2, fs_jpim1   ! vector opt.
+                w_trc_bbl(ji,jj,jk) = w_trc_bbl(ji,jj,jk+1) - fse3t(ji,jj,jk)*zhdivn(ji,jj,jk)
+             END DO
+          END DO
+       END DO
+
+      ! Boundary condition on w_bbl   (unchanged sign)
+      CALL lbc_lnk( w_trc_bbl, 'W', 1. )
+
+   END SUBROUTINE trc_bbl_adv
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 1844)
@@ -0,0 +1,841 @@
+MODULE trcdmp
+   !!======================================================================
+   !!                       ***  MODULE  trcdmp  ***
+   !! Ocean physics: internal restoring trend on passive tracers
+   !!======================================================================
+   !! History :  7.0  !         (G. Madec)  Original code
+   !!                 !  96-01  (G. Madec) 
+   !!                 !  97-05  (H. Loukos)  adapted for passive tracers
+   !!            8.5  !  02-08  (G. Madec )  free form + modules
+   !!            9.0  !  04-03  (C. Ethe)    free form + modules
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if  defined key_top && defined key_trcdmp 
+   !!----------------------------------------------------------------------
+   !!   key_trcdmp                                         internal damping
+   !!----------------------------------------------------------------------
+   !!   trc_dmp      : update the tracer trend with the internal damping
+   !!   trc_dmp_init : initialization, namlist read, parameters control
+   !!   trccof_zoom  : restoring coefficient for zoom domain
+   !!   trccof       : restoring coefficient for global domain
+   !!   cofdis       : compute the distance to the coastline
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! ocean dynamics and tracers variables
+   USE trc             ! ocean passive tracers variables
+   USE trctrp_lec      ! passive tracers transport
+   USE trcdta
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_dmp      ! routine called by step.F90
+
+   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .TRUE.   !: internal damping flag
+   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::   restotr   ! restoring coeff. on tracers (s-1)
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcdmp.F90,v 1.11 2006/09/01 14:03:49 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_dmp( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_dmp  ***
+      !!                  
+      !! ** Purpose :   Compute the passive tracer trend due to a newtonian damping
+      !!      of the tracer field towards given data field and add it to the
+      !!      general tracer trends.
+      !!
+      !! ** Method  :   Newtonian damping towards trdta computed 
+      !!      and add to the general tracer trends:
+      !!                     trn = tra + restotr * (trdta - trb)
+      !!         The trend is computed either throughout the water column
+      !!      (nlmdmptr=0) or in area of weak vertical mixing (nlmdmptr=1) or
+      !!      below the well mixed layer (nlmdmptr=2)
+      !!
+      !! ** Action  : - update the tracer trends tra with the newtonian 
+      !!                damping trends.
+      !!              - save the trends ('key_trdmld_trc')
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrtrd => ua  ! use ua as 3D workspace   
+      !!
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      INTEGER  ::   ji, jj, jk, jn       ! dummy loop indices
+      REAL(wp) ::   ztest, ztra !!!, zdt    ! temporary scalars
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization (first time-step only)
+      !    --------------
+      IF( kt == nittrc000 ) CALL trc_dmp_init
+
+
+      ! 1. Newtonian damping trends on tracer fields
+      ! --------------------------------------------
+      !    compute the newtonian damping trends depending on nmldmptr
+
+!!!      zdt  = rdt * FLOAT( ndttrc )
+
+      ! Initialize the input fields for newtonian damping
+      CALL dta_trc( kt )
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)    ! save trends 
+
+         IF( lutini(jn) ) THEN
+
+            SELECT CASE ( nmldmptr )
+
+            CASE( 0 )                ! newtonian damping throughout the water column
+
+               DO jk = 1, jpkm1
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1   ! vector opt.
+                        ztra = restotr(ji,jj,jk,jn) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
+                        ! add the trends to the general tracer trends
+!!                        trn(ji,jj,jk,jn) = trn(ji,jj,jk,jn) + ztra * zdt
+                        tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+                     END DO
+                  END DO
+               END DO
+
+            CASE ( 1 )                ! no damping in the turbocline (avt > 5 cm2/s)
+               DO jk = 1, jpkm1
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1   ! vector opt.
+                        ztest = avt(ji,jj,jk) - 5.e-4
+                        IF( ztest < 0. ) THEN
+                           ztra = restotr(ji,jj,jk,jn) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
+                        ELSE
+                           ztra = 0.e0
+                        ENDIF
+                        ! add the trends to the general tracer trends
+!!                        trn(ji,jj,jk,jn) = trn(ji,jj,jk,jn) + ztra * zdt
+                        tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra 
+#    if defined key_trc_diatrd
+                        ! save the trends for diagnostics
+                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc) = ztra
+#    endif
+
+                     END DO
+                  END DO
+               END DO
+
+            CASE ( 2 )                ! no damping in the mixed layer 
+               DO jk = 1, jpkm1
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1   ! vector opt.
+                        IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
+                           ztra = restotr(ji,jj,jk,jn) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
+                        ELSE
+                           ztra = 0.e0
+                        ENDIF
+                        ! add the trends to the general tracer trends
+!!                        trn(ji,jj,jk,jn) = trn(ji,jj,jk,jn) + ztra * zdt
+                        tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+#    if defined key_trc_diatrd
+                        ! save the trends for diagnostics
+                        IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),jpdiatrc) = ztra
+#    endif
+
+                     END DO
+                  END DO
+               END DO
+               
+            END SELECT
+
+         ENDIF
+
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) -  ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_dmp, kt )        ! trends diags.
+         END IF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('dmp')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd' )
+      ENDIF
+  
+      trb(:,:,:,:) = trn(:,:,:,:)
+   
+   END SUBROUTINE trc_dmp
+
+
+   SUBROUTINE trc_dmp_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_dmp_init  ***
+      !! 
+      !! ** Purpose :   Initialization for the newtonian damping 
+      !!
+      !! ** Method  :   read the nammbf namelist and check the parameters
+      !!      called by trc_dmp at the first timestep (nit000)
+      !!----------------------------------------------------------------------
+
+      SELECT CASE ( ndmptr )
+
+      CASE ( -1 )               ! ORCA: damping in Red & Med Seas only
+         IF(lwp) WRITE(numout,*) '          tracer damping in the Med & Red seas only'
+
+      CASE ( 1:90 )             ! Damping poleward of 'ndmptr' degrees
+         IF(lwp) WRITE(numout,*) '          tracer damping poleward of', ndmptr, ' degrees'
+
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for ndmptr = ', ndmptr
+         CALL ctl_stop(ctmp1)
+
+      END SELECT
+
+
+      SELECT CASE ( nmldmptr )
+
+      CASE ( 0 )                ! newtonian damping throughout the water column
+         IF(lwp) WRITE(numout,*) '          tracer damping throughout the water column'
+
+      CASE ( 1 )                ! no damping in the turbocline (avt > 5 cm2/s)
+         IF(lwp) WRITE(numout,*) '          no tracer damping in the turbocline'
+
+      CASE ( 2 )                ! no damping in the mixed layer 
+         IF(lwp) WRITE(numout,*) '          no tracer damping in the mixed layer'
+
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for nmldmptr = ', nmldmptr
+         CALL ctl_stop(ctmp1)
+
+      END SELECT
+
+      ! Damping coefficients initialization
+      ! -----------------------------------
+      IF( lzoom ) THEN
+         CALL trccof_zoom
+      ELSE
+         CALL trccof
+      ENDIF
+ 
+   END SUBROUTINE trc_dmp_init
+
+
+   SUBROUTINE trccof_zoom
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trccof_zoom  ***
+      !!
+      !! ** Purpose :   Compute the damping coefficient for zoom domain
+      !!
+      !! ** Method  : - set along closed boundary due to zoom a damping over
+      !!      6 points with a max time scale of 5 days.
+      !!              - ORCA arctic/antarctic zoom: set the damping along
+      !!      south/north boundary over a latitude strip.
+      !!
+      !! ** Action  : - restotr, the damping coeff. passive tracers
+      !!
+      !! History :
+      !!   9.0  !  03-09  (G. Madec)  Original code
+      !!   9.0  !  04-03  (C. Ethe)   adapted for passive tracers
+      !!----------------------------------------------------------------------
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk, jn       ! dummy loop indices
+      REAL(wp) ::   &
+         zlat, zlat0, zlat1, zlat2     ! temporary scalar
+      REAL(wp), DIMENSION(6)  ::   &
+         zfact                         ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      zfact(1) =  1.
+      zfact(2) =  1. 
+      zfact(3) = 11./12.
+      zfact(4) =  8./12.
+      zfact(5) =  4./12.
+      zfact(6) =  1./12.
+      zfact(:) = zfact(:) / ( 5. * rday )    ! 5 days max restoring time scale
+
+      restotr(:,:,:,:) = 0.e0
+
+      ! damping along the forced closed boundary over 6 grid-points
+      DO jn = 1, 6
+         IF( lzoom_w )   restotr( mi0(jn+jpizoom):mi1(jn+jpizoom), : , : , : ) = zfact(jn) ! west  closed
+         IF( lzoom_s )   restotr( : , mj0(jn+jpjzoom):mj1(jn+jpjzoom), : , : ) = zfact(jn) ! south closed 
+         IF( lzoom_e )   restotr( mi0(jpiglo+jpizoom-1-jn):mi1(jpiglo+jpizoom-1-jn) , : , : , : ) &
+                       &              = zfact(jn)                                 ! east  closed 
+         IF( lzoom_n )   restotr( : , mj0(jpjglo+jpjzoom-1-jn):mj1(jpjglo+jpjzoom-1-jn) , : , : ) &
+                       &              = zfact(jn)                                 ! north closed
+      END DO
+
+
+      IF( lzoom_arct .AND. lzoom_anta ) THEN
+
+         ! ====================================================
+         !  ORCA configuration : arctic zoom or antarctic zoom
+         ! ====================================================
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp .AND. lzoom_arct ) WRITE(numout,*) '              trccof_zoom : ORCA    Arctic zoom'
+         IF(lwp .AND. lzoom_arct ) WRITE(numout,*) '              trccof_zoom : ORCA Antarctic zoom'
+         IF(lwp) WRITE(numout,*)
+
+         ! ... Initialization : 
+         !     zlat0 : latitude strip where resto decreases
+         !     zlat1 : resto = 1 before zlat1
+         !     zlat2 : resto decreases from 1 to 0 between zlat1 and zlat2
+         restotr(:,:,:,:) = 0.e0
+         zlat0 = 10.
+         zlat1 = 30.
+         zlat2 = zlat1 + zlat0
+
+         ! ... Compute arrays resto ; value for internal damping : 5 days
+         DO jn = 1, jptra
+            DO jk = 2, jpkm1 
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zlat = ABS( gphit(ji,jj) )
+                     IF ( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
+                        restotr(ji,jj,jk,jn) = 0.5 * ( 1./(5.*rday) ) *   &
+                           ( 1. - COS(rpi*(zlat2-zlat)/zlat0) ) 
+                     ELSE IF ( zlat < zlat1 ) THEN
+                        restotr(ji,jj,jk,jn) = 1./(5.*rday)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+         END DO
+
+      ENDIF
+
+      ! ... Mask resto array
+        DO jn = 1, jptra
+           restotr(:,:,:,jn) = restotr(:,:,:,jn) * tmask(:,:,:)
+        END DO
+
+
+   END SUBROUTINE trccof_zoom
+
+   SUBROUTINE trccof
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trccof  ***
+      !!
+      !! ** Purpose :   Compute the damping coefficient
+      !!
+      !! ** Method  :   Arrays defining the damping are computed for each grid
+      !!      point passive tracers (restotr)
+      !!      Damping depends on distance to coast, depth and latitude
+      !!
+      !! ** Action  : - restotr, the damping coeff. for passive tracers
+      !!
+      !! History :
+      !!   5.0  !  91-03  (O. Marti, G. Madec)  Original code
+      !!        !  92-06  (M. Imbard)  doctor norme
+      !!        !  96-01  (G. Madec) statement function for e3
+      !!        !  98-07  (M. Imbard, G. Madec) ORCA version
+      !!        !  00-08  (G. Madec, D. Ludicone) 
+      !!   8.2  !  04-03  (H. Loukos) adapted for passive tracers
+      !!        !  04-02  (O. Aumont, C. Ethe) rewritten for debuging and update
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE iom
+      USE ioipsl
+
+      !! * Local declarations
+      INTEGER ::  ji, jj, jk, jn    ! dummy loop indices
+      INTEGER ::   itime
+      INTEGER ::  ii0, ii1, ij0, ij1  !    "          "
+      INTEGER ::   &
+         idmp,     &  ! logical unit for file restoring damping term
+         icot         ! logical unit for file distance to the coast
+
+      CHARACTER (len=32) ::   clname3
+      REAL(wp) ::   &
+         zdate0, zinfl, zlon,         & ! temporary scalars
+         zlat, zlat0, zlat1, zlat2,   & !    "         "
+         zsdmp, zbdmp                   !    "         "
+      REAL(wp), DIMENSION(jpk) ::   &
+         gdept, zhfac
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zmrs
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zdct
+      !!----------------------------------------------------------------------
+
+      ! ====================================
+      !  ORCA configuration : global domain
+      ! ====================================
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '              trccof : Global domain of ORCA'
+      IF(lwp) WRITE(numout,*) '              ------------------------------'
+
+
+      ! ... Initialization : 
+      !   zdct()      : distant to the coastline
+      !   resto()     : array of restoring coeff. 
+      
+      zdct (:,:,:) = 0.e0
+      restotr(:,:,:,:) = 0.e0
+
+
+      IF ( ndmptr > 0 ) THEN
+
+         !    ------------------------------------
+         !     Damping poleward of 'ndmptr' degrees
+         !    ------------------------------------
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '              Damping poleward of ', ndmptr,' deg.'
+         IF(lwp) WRITE(numout,*)
+
+         ! ... Distance to coast (zdct)
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) ' dtacof : distance to coast file'
+         CALL iom_open ( 'dist.coast.trc.nc', icot )
+         IF( icot > 0 ) THEN
+            CALL iom_get ( icot, jpdom_data, 'Tcoast', zdct )
+            CALL iom_close (icot)
+         ELSE
+            !   ... Compute and save the distance-to-coast array (output in zdct)
+            CALL cofdis( zdct )
+         ENDIF
+
+
+         ! ... Compute arrays resto 
+         !      zinfl : distance of influence for damping term
+         !      zlat0 : latitude strip where resto decreases
+         !      zlat1 : resto = 0 between -zlat1 and zlat1
+         !      zlat2 : resto increases from 0 to 1 between |zlat1| and |zlat2|
+         !          and resto = 1 between |zlat2| and 90 deg.
+         zinfl = 1000.e3
+         zlat0 = 10
+         zlat1 = ndmptr
+         zlat2 = zlat1 + zlat0
+
+         DO jn = 1, jptra
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zlat = ABS( gphit(ji,jj) )
+                  IF ( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
+                     restotr(ji,jj,1,jn) = 0.5 * ( 1. - COS(rpi*(zlat-zlat1)/zlat0 ) )
+                  ELSEIF ( zlat > zlat2 ) THEN
+                     restotr(ji,jj,1,jn) = 1.
+                  ENDIF
+               END DO
+            END DO
+         END DO
+
+         !   ... North Indian ocean (20N/30N x 45E/100E) : resto=0
+         IF ( ndmptr == 20 ) THEN
+            DO jn = 1, jptra
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zlat = gphit(ji,jj)
+                     zlon = MOD( glamt(ji,jj), 360. )
+                     IF ( zlat1 < zlat .AND. zlat < zlat2 .AND.   &
+                        45.  < zlon .AND. zlon < 100. ) THEN
+                        restotr(ji,jj,1,jn) = 0.
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+         ENDIF
+
+         zsdmp = 1./(sdmptr * rday)
+         zbdmp = 1./(bdmptr * rday)
+         DO jn = 1, jptra
+            DO jk = 2, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zdct(ji,jj,jk) = MIN( zinfl, zdct(ji,jj,jk) )
+
+                     !   ... Decrease the value in the vicinity of the coast
+                     restotr(ji,jj,jk,jn) = restotr(ji,jj,1,jn)*0.5   &
+                        &                 * ( 1. - COS( rpi*zdct(ji,jj,jk)/zinfl) )
+
+                     !   ... Vertical variation from zsdmp (sea surface) to zbdmp (bottom)
+                     restotr(ji,jj,jk,jn) = restotr(ji,jj,jk,jn)   &
+                        &                 * ( zbdmp + (zsdmp-zbdmp)*EXP(-fsdept(ji,jj,jk)/hdmptr) )
+                  END DO
+               END DO
+            END DO
+         END DO
+
+      ENDIF
+
+
+      IF( cp_cfg == "orca" .AND. ( ndmptr > 0 .OR. ndmptr == -1 ) ) THEN
+
+         !                                         ! =========================
+         !                                         !  Med and Red Sea damping
+         !                                         ! =========================
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) '              ORCA configuration: Damping in Med and Red Seas'
+
+
+         zmrs(:,:) = 0.e0                             ! damping term on the Med or Red Sea
+
+         SELECT CASE ( jp_cfg )
+            !                                           ! =======================
+         CASE ( 4 )                                     !  ORCA_R4 configuration 
+            !                                           ! =======================
+
+            ! Mediterranean Sea
+            ij0 =  50   ;   ij1 =  56
+            ii0 =  81   ;   ii1 =  91   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 =  50   ;   ij1 =  55
+            ii0 =  75   ;   ii1 =  80   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 =  52   ;   ij1 =  53
+            ii0 =  70   ;   ii1 =  74   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
+            DO jk = 1, 17
+               zhfac (jk) = 0.5*( 1.- COS( rpi*(jk-1)/16. ) ) / rday
+            END DO
+            DO jk = 18, jpkm1
+               zhfac (jk) = 1./rday
+            END DO
+
+            !                                        ! =======================
+         CASE ( 2 )                                  !  ORCA_R2 configuration 
+            !                                        ! =======================
+
+            ! Mediterranean Sea
+            ij0 =  96   ;   ij1 = 110
+            ii0 = 157   ;   ii1 = 181   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 = 100   ;   ij1 = 110
+            ii0 = 144   ;   ii1 = 156   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ij0 = 100   ;   ij1 = 103
+            ii0 = 139   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Gibraltar Strait
+            ij0 = 101   ;   ij1 = 102
+            ii0 = 139   ;   ii1 = 141   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.e0
+            ii0 = 142   ;   ii1 = 142   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ii0 = 143   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40e0
+            ii0 = 144   ;   ii1 = 144   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75e0
+            ! Red Sea
+            ij0 =  87   ;   ij1 =  96
+            ii0 = 147   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Bab el Mandeb Strait
+            ij0 =  91   ;   ij1 =  91
+            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.80e0
+            ij0 =  90   ;   ij1 =  90
+            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40e0
+            ij0 =  89   ;   ij1 =  89
+            ii0 = 158   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ij0 =  88   ;   ij1 =  88
+            ii0 = 160   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.e0
+            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
+            DO jk = 1, 17
+               zhfac (jk) = 0.5*( 1.- COS( rpi*(jk-1)/16. ) ) / rday
+            END DO
+            DO jk = 18, jpkm1
+               zhfac (jk) = 1./rday
+            END DO
+
+            !                                        ! =======================
+         CASE ( 05 )                                 !  ORCA_R05 configuration
+            !                                        ! =======================
+
+            ! Mediterranean Sea
+            ii0 = 568   ;   ii1 = 574 
+            ij0 = 324   ;   ij1 = 333   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ii0 = 575   ;   ii1 = 658
+            ij0 = 314   ;   ij1 = 366   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Black Sea (remaining part
+            ii0 = 641   ;   ii1 = 651
+            ij0 = 367   ;   ij1 = 372   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Gibraltar Strait
+            ii0 = 324   ;   ii1 = 333
+            ij0 = 565   ;   ij1 = 565   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0 / 90.e0
+            ij0 = 566   ;   ij1 = 566   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
+            ij0 = 567   ;   ij1 = 567   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75
+            ! Red Sea
+            ii0 = 641   ;   ii1 = 665
+            ij0 = 270   ;   ij1 = 310   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1.e0
+            ! Decrease before Bab el Mandeb Strait
+            ii0 = 666   ;   ii1 = 675
+            ij0 = 270   ;   ij1 = 290   
+            DO ji = mi0(ii0), mi1(ii1)
+               zmrs( ji , mj0(ij0):mj1(ij1) ) = 0.1 * ABS( FLOAT(ji - mi1(ii1)) )
+            END DO
+            zsdmp = 1./(sdmptr * rday)
+            zbdmp = 1./(bdmptr * rday)
+            DO jk = 1, jpk
+               zhfac (jk) = ( zbdmp + (zsdmp-zbdmp) * EXP(-fsdept(1,1,jk)/hdmptr) )
+            END DO
+
+            !                                       ! ========================
+         CASE ( 025 )                               !  ORCA_R025 configuration 
+
+            CALL ctl_stop( ' Not yet implemented in ORCA_R025' ) 
+
+         END SELECT
+
+         DO jn = 1, jptra
+            DO jk = 1, jpkm1
+               restotr(:,:,jk,jn) = zmrs(:,:) * zhfac(jk) + ( 1. - zmrs(:,:) ) * restotr(:,:,jk,jn)
+            END DO
+
+            ! Mask resto array and set to 0 first and last levels
+            restotr(:,:, : ,jn) = restotr(:,:,:,jn) * tmask(:,:,:)
+            restotr(:,:, 1 ,jn) = 0.e0
+            restotr(:,:,jpk,jn) = 0.e0
+         END DO
+
+      ELSE
+         !    ------------
+         !     No damping
+         !    ------------
+         CALL ctl_stop( 'Choose a correct value of ndmp or DO NOT defined key_tradmp' )
+
+      ENDIF
+
+        !    ----------------------------
+         !     Create Print damping array
+         !    ----------------------------
+         
+         ! ndmpftr   : = 1 create a damping.coeff NetCDF file
+
+      IF( ndmpftr == 1 ) THEN
+         DO jn = 1, jptra
+            IF(lwp) WRITE(numout,*) '  create damping.coeff.nc file  ',jn
+            itime   = 0
+            clname3 = 'damping.coeff'//ctrcnm(jn)
+            CALL ymds2ju( 0     , 1     , 1      , 0.e0 , zdate0 )
+            CALL restini( 'NONE', jpi   , jpj    , glamt, gphit,    &
+           &              jpk   , gdept , clname3, itime, zdate0,   &
+           &              rdt   , idmp  , domain_id=nidom)
+            CALL restput( idmp, 'Resto', jpi, jpj, jpk, 0 , restotr(:,:,:,jn)  )
+            CALL restclo( idmp )
+         END DO
+      ENDIF
+
+
+   END SUBROUTINE trccof
+
+
+   SUBROUTINE cofdis ( pdct )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE cofdis  ***
+      !!
+      !! ** Purpose :   Compute the distance between ocean T-points and the
+      !!      ocean model coastlines. Save the distance in a NetCDF file.
+      !!
+      !! ** Method  :   For each model level, the distance-to-coast is 
+      !!      computed as follows : 
+      !!       - The coastline is defined as the serie of U-,V-,F-points
+      !!      that are at the ocean-land bound.
+      !!       - For each ocean T-point, the distance-to-coast is then 
+      !!      computed as the smallest distance (on the sphere) between the 
+      !!      T-point and all the coastline points.
+      !!       - For land T-points, the distance-to-coast is set to zero.
+      !!      C A U T I O N : Computation not yet implemented in mpp case.
+      !!
+      !! ** Action  : - pdct, distance to the coastline (argument)
+      !!              - NetCDF file 'trc.dist.coast.nc' 
+      !!        
+      !! History :
+      !!   7.0  !  01-02  (M. Imbard)  Original code
+      !!   8.1  !  01-02  (G. Madec, E. Durand)
+      !!   8.5  !  02-08  (G. Madec, E. Durand)  Free form, F90
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ioipsl
+
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   &
+         pdct                     ! distance to the coastline
+
+      !! * local declarations
+      INTEGER :: ji, jj, jk, jl      ! dummy loop indices
+      INTEGER :: iju, ijt            ! temporary integers
+      INTEGER :: icoast, itime
+      INTEGER ::   &
+         icot         ! logical unit for file distance to the coast
+      LOGICAL, DIMENSION(jpi,jpj) ::   &
+         llcotu, llcotv, llcotf   ! ???
+      CHARACTER (len=32) ::   clname
+      REAL(wp) ::   zdate0
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zxt, zyt, zzt,                 &  ! cartesian coordinates for T-points
+         zmask                             
+      REAL(wp), DIMENSION(3*jpi*jpj) ::   &
+         zxc, zyc, zzc, zdis      ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization
+      ! -----------------
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'cofdis : compute the distance to coastline'
+      IF(lwp) WRITE(numout,*) '~~~~~~'
+      IF(lwp) WRITE(numout,*)
+      IF( lk_mpp ) &
+           & CALL ctl_stop('         Computation not yet implemented with key_mpp_...', &
+           &               '         Rerun the code on another computer or ', &
+           &               '         create the "dist.coast.nc" file using IDL' )
+
+
+      pdct(:,:,:) = 0.e0
+      zxt(:,:) = cos( rad * gphit(:,:) ) * cos( rad * glamt(:,:) )
+      zyt(:,:) = cos( rad * gphit(:,:) ) * sin( rad * glamt(:,:) )
+      zzt(:,:) = sin( rad * gphit(:,:) )
+
+
+      ! 1. Loop on vertical levels
+      ! --------------------------
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         ! Define the coastline points (U, V and F)
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zmask(ji,jj) =  ( tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) &
+                   &           + tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk) )
+               llcotu(ji,jj) = ( tmask(ji,jj,  jk) + tmask(ji+1,jj  ,jk) == 1. ) 
+               llcotv(ji,jj) = ( tmask(ji,jj  ,jk) + tmask(ji  ,jj+1,jk) == 1. ) 
+               llcotf(ji,jj) = ( zmask(ji,jj) > 0. ) .AND. ( zmask(ji,jj) < 4. )
+            END DO
+         END DO
+
+         ! Lateral boundaries conditions
+         llcotu(:, 1 ) = umask(:,  2  ,jk) == 1
+         llcotu(:,jpj) = umask(:,jpjm1,jk) == 1
+         llcotv(:, 1 ) = vmask(:,  2  ,jk) == 1
+         llcotv(:,jpj) = vmask(:,jpjm1,jk) == 1
+         llcotf(:, 1 ) = fmask(:,  2  ,jk) == 1
+         llcotf(:,jpj) = fmask(:,jpjm1,jk) == 1
+
+         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN
+            llcotu( 1 ,:) = llcotu(jpim1,:)
+            llcotu(jpi,:) = llcotu(  2  ,:)
+            llcotv( 1 ,:) = llcotv(jpim1,:)
+            llcotv(jpi,:) = llcotv(  2  ,:)
+            llcotf( 1 ,:) = llcotf(jpim1,:)
+            llcotf(jpi,:) = llcotf(  2  ,:)
+         ELSE
+            llcotu( 1 ,:) = umask(  2  ,:,jk) == 1
+            llcotu(jpi,:) = umask(jpim1,:,jk) == 1
+            llcotv( 1 ,:) = vmask(  2  ,:,jk) == 1
+            llcotv(jpi,:) = vmask(jpim1,:,jk) == 1
+            llcotf( 1 ,:) = fmask(  2  ,:,jk) == 1
+            llcotf(jpi,:) = fmask(jpim1,:,jk) == 1
+         ENDIF
+         IF( nperio == 3 .OR. nperio == 4 ) THEN
+            DO ji = 1, jpim1
+               iju = jpi - ji + 1
+               llcotu(ji,jpj  ) = llcotu(iju,jpj-2)
+               llcotf(ji,jpj-1) = llcotf(iju,jpj-2)
+               llcotf(ji,jpj  ) = llcotf(iju,jpj-3)
+            END DO
+            DO ji = jpi/2, jpi-1
+               iju = jpi - ji + 1
+               llcotu(ji,jpjm1) = llcotu(iju,jpjm1)
+            END DO
+            DO ji = 2, jpi
+               ijt = jpi - ji + 2
+               llcotv(ji,jpj-1) = llcotv(ijt,jpj-2)
+               llcotv(ji,jpj  ) = llcotv(ijt,jpj-3)
+            END DO
+         ENDIF
+         IF( nperio == 5 .OR. nperio == 6 ) THEN
+            DO ji = 1, jpim1
+               iju = jpi - ji
+               llcotu(ji,jpj  ) = llcotu(iju,jpj-1)
+               llcotf(ji,jpj  ) = llcotf(iju,jpj-2)
+            END DO
+            DO ji = jpi/2, jpi-1
+               iju = jpi - ji
+               llcotf(ji,jpjm1) = llcotf(iju,jpjm1)
+            END DO
+            DO ji = 1, jpi
+               ijt = jpi - ji + 1
+               llcotv(ji,jpj  ) = llcotv(ijt,jpj-1)
+            END DO
+            DO ji = jpi/2+1, jpi
+               ijt = jpi - ji + 1
+               llcotv(ji,jpjm1) = llcotv(ijt,jpjm1)
+            END DO
+         ENDIF
+
+         ! Compute cartesian coordinates of coastline points
+         ! and the number of coastline points
+
+         icoast = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( llcotf(ji,jj) ) THEN
+                  icoast = icoast + 1
+                  zxc(icoast) = COS( rad*gphif(ji,jj) ) * COS( rad*glamf(ji,jj) )
+                  zyc(icoast) = COS( rad*gphif(ji,jj) ) * SIN( rad*glamf(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphif(ji,jj) )
+               ENDIF
+               IF( llcotu(ji,jj) ) THEN
+                  icoast = icoast+1
+                  zxc(icoast) = COS( rad*gphiu(ji,jj) ) * COS( rad*glamu(ji,jj) )
+                  zyc(icoast) = COS( rad*gphiu(ji,jj) ) * SIN( rad*glamu(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphiu(ji,jj) )
+               ENDIF
+               IF( llcotv(ji,jj) ) THEN
+                  icoast = icoast+1
+                  zxc(icoast) = COS( rad*gphiv(ji,jj) ) * COS( rad*glamv(ji,jj) )
+                  zyc(icoast) = COS( rad*gphiv(ji,jj) ) * SIN( rad*glamv(ji,jj) )
+                  zzc(icoast) = SIN( rad*gphiv(ji,jj) )
+               ENDIF
+            END DO
+         END DO
+
+         ! Distance for the T-points
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( tmask(ji,jj,jk) == 0. ) THEN
+                  pdct(ji,jj,jk) = 0.
+               ELSE
+                  DO jl = 1, icoast
+                     zdis(jl) = ( zxt(ji,jj) - zxc(jl) )**2   &
+                              + ( zyt(ji,jj) - zyc(jl) )**2   &
+                              + ( zzt(ji,jj) - zzc(jl) )**2
+                  END DO
+                  pdct(ji,jj,jk) = ra * SQRT( MINVAL( zdis(1:icoast) ) )
+               ENDIF
+            END DO
+         END DO
+         !                                                ! ===============
+      END DO                                              !   End of slab
+      !                                                   ! ===============
+
+
+      ! 2. Create the  distance to the coast file in NetCDF format
+      ! ----------------------------------------------------------    
+      clname = 'trc.dist.coast'
+      itime = 0
+      CALL ymds2ju( 0     , 1     , 1     , 0.e0 , zdate0 )
+      CALL restini( 'NONE', jpi   , jpj   , glamt, gphit ,   &
+                    jpk   , gdept , clname, itime, zdate0,   &
+                    rdt   , icot , domain_id=nidom         )
+      CALL restput( icot, 'Tcoast', jpi, jpj, jpk, 0, pdct )
+      CALL restclo( icot )
+
+   END SUBROUTINE cofdis
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO internal damping
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .FALSE.    !: internal damping flag
+CONTAINS
+   SUBROUTINE trc_dmp( kt )        ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_dmp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_dmp
+#endif
+
+   !!======================================================================
+END MODULE trcdmp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilap.F90	(revision 1844)
@@ -0,0 +1,234 @@
+MODULE trcldf_bilap
+   !!======================================================================
+   !!                   ***  MODULE  trcldf_bilap  ***
+   !! Ocean passive tracers:  horiz. component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :       !  91-11  (G. Madec)  Original code
+   !!                 !  93-03  (M. Guyon)  symetrical conditions
+   !!                 !  95-11  (G. Madec)  suppress volumetric scale factors
+   !!                 !  96-01  (G. Madec)  statement function for e3
+   !!                 !  96-01  (M. Imbard)  mpp exchange
+   !!                 !  97-07  (G. Madec)  optimization, and ahtt
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-10  (MA Foujols E. Kestenare) use passive tracer coefficient
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe )  F90: Free form and module
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   trc_ldf_bilap : update the tracer trend with the horizontal diffusion
+   !!                   using a iso-level biharmonic operator
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trp_trc         ! ocean passive tracers variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ldf_bilap   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcldf_bilap.F90,v 1.10 2006/09/12 11:10:14 opalod Exp $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE trc_ldf_bilap( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_ldf_bilap  ***
+      !!
+      !! ** Purpose :   Compute the before horizontal tracer tra diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   4th order diffusive operator along model level surfaces 
+      !!      evaluated using before fields (forward time scheme). The hor.
+      !!      diffusive trends of passive tracer is given by:
+      !!       * s-coordinate, the vertical scale 
+      !!      factors e3. are inside the derivatives:
+      !!      Laplacian of trb:
+      !!         zlt   = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(trb) ]
+      !!                                  + dj-1[ e1v*e3v/e2v dj(trb) ]  }
+      !!      Multiply by the eddy diffusivity coef. and insure lateral bc:
+      !!        zlt   = ahtt * zlt
+      !!        call to lbc_lnk
+      !!      Bilaplacian (laplacian of zlt):
+      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(zlt) ]
+      !!                                  + dj-1[ e1v*e3v/e2v dj(zlt) ]  }
+      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
+      !!      Laplacian of trb:
+      !!         zlt   = 1/(e1t*e2t) {  di-1[ e2u/e1u di(trb) ]
+      !!                              + dj-1[ e1v/e2v dj(trb) ] }
+      !!      Multiply by the eddy diffusivity coef. and insure lateral bc:
+      !!        zlt   = ahtt * zlt
+      !!        call to lbc_lnk
+      !!      Bilaplacian (laplacian of zlt):
+      !!         difft = 1/(e1t*e2t) {  di-1[ e2u/e1u di(zlt) ]
+      !!                              + dj-1[ e1v/e2v dj(zlt) ]  }
+      !!
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + difft 
+      !!
+      !! ** Action : - Update tra arrays with the before iso-level
+      !!               biharmonic mixing trend.
+      !!             - Save the trends ('key_trdmld_trc')
+      !!----------------------------------------------------------------------
+      USE oce_trc,   ztrtrd => ua        ! use ua as workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt                             ! ocean time-step index
+      INTEGER ::   ji, jj, jk, jn                               ! dummy loop indices
+      INTEGER ::   iku, ikv                                     ! temporary integers
+      REAL(wp) ::   ztra                                        ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zeeu, zeev, zbtr, zlt   ! workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztu, ztv            ! workspace
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_ldf_bilap : iso-level biharmonic operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
+      ENDIF
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)   ! save trends
+
+                                                          ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+
+            ! 0. Initialization of metric arrays (for z- or s-coordinates)
+            ! ----------------------------------
+
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+#if ! defined key_zco 
+                  ! s-coordinates, vertical scale factor are used
+                  zbtr(ji,jj) = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  zeeu(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj) * umask(ji,jj,jk)
+                  zeev(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj) * vmask(ji,jj,jk)
+#else
+                  ! z-coordinates, no vertical scale factors
+                  zbtr(ji,jj) = 1. / ( e1t(ji,jj)*e2t(ji,jj) )
+                  zeeu(ji,jj) = e2u(ji,jj) / e1u(ji,jj) * umask(ji,jj,jk)
+                  zeev(ji,jj) = e1v(ji,jj) / e2v(ji,jj) * vmask(ji,jj,jk)
+#endif
+               END DO
+            END DO
+
+
+            ! 1. Laplacian
+            ! ------------
+
+            ! First derivative (gradient)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ztu(ji,jj,jk) = zeeu(ji,jj) * ( trb(ji+1,jj  ,jk,jn) - trb(ji,jj,jk,jn) )
+                  ztv(ji,jj,jk) = zeev(ji,jj) * ( trb(ji  ,jj+1,jk,jn) - trb(ji,jj,jk,jn) )
+               END DO
+            END DO
+
+            IF( ln_zps ) THEN
+               DO jj = 1, jpj-1
+                  DO ji = 1, jpi-1
+                     ! last level
+                     iku = MIN ( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+                     ikv = MIN ( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+                     IF( iku == jk ) THEN
+                        ztu(ji,jj,jk) = zeeu(ji,jj) * gtru(ji,jj,jn)
+                     ENDIF
+                     IF( ikv == jk ) THEN
+                        ztv(ji,jj,jk) = zeev(ji,jj) * gtrv(ji,jj,jn)
+                     ENDIF
+                  END DO
+               END DO
+            ENDIF
+
+            ! Second derivative (divergence)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zlt(ji,jj) = zbtr(ji,jj) * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               END DO
+            END DO
+
+            ! Multiply by the eddy diffusivity coefficient
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zlt(ji,jj) = fsahtrt(ji,jj,jk) * zlt(ji,jj)
+               END DO
+            END DO
+
+            ! Lateral boundary conditions on the laplacian zlt   (unchanged sgn)
+            CALL lbc_lnk( zlt, 'T', 1. )  
+
+            ! 2. Bilaplacian
+            ! --------------
+
+            ! third derivative (gradient)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ztu(ji,jj,jk) = zeeu(ji,jj) * ( zlt(ji+1,jj  ) - zlt(ji,jj) )
+                  ztv(ji,jj,jk) = zeev(ji,jj) * ( zlt(ji  ,jj+1) - zlt(ji,jj) )
+               END DO
+            END DO
+
+            ! fourth derivative (divergence) and add to the general tracer trend
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! horizontal diffusive trends
+                  ztra = zbtr(ji,jj) * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  ! save the horizontal diffusive trends
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),4) = (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) ) * zbtr(ji,jj)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),5) = (  ztv(ji,jj,jk) - ztv(ji-1,jj,jk) ) * zbtr(ji,jj)
+#endif
+
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           ! Horizontal slab
+         !                                                ! ===============
+#if defined key_trc_diatrd
+         ! Lateral boundary conditions on the laplacian zlt   (unchanged sgn)
+         IF (luttrd(jn)) CALL lbc_lnk( trtrd(:,:,:,ikeep(jn),5), 'T', 1. )
+#endif
+
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_ldf, kt )    ! trends diags
+         END IF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop                
+      !                                                          ! ===========
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ldf - bilap')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd' )
+      ENDIF
+
+   END SUBROUTINE trc_ldf_bilap
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ldf_bilap( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_ldf_bilap: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_ldf_bilap
+#endif
+   !!==============================================================================
+END MODULE trcldf_bilap
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilapg.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilapg.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_bilapg.F90	(revision 1844)
@@ -0,0 +1,362 @@
+MODULE trcldf_bilapg
+   !!======================================================================
+   !!                       ***  MODULE  trcldf_bilapg  ***
+   !! Ocean passive tracers:  horizontal component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :  8.0  !  97-07  (G. Madec)  Original code
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe)  adapted for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if key_top && defined key_ldfslp
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   trc_ldf_bilapg : update the tracer trend with the horizontal diffusion
+   !!                    using an horizontal biharmonic operator in s-coordinate 
+   !!   ldfght         :  ???
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and tracers variables
+   USE trc                 ! ocean passive tracers variables
+   USE lbclnk              ! ocean lateral boundary condition (or mpp link)
+   USE prtctl_trc          ! Print control for debbuging
+   USE trp_trc
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ldf_bilapg    ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcldf_bilapg.F90,v 1.9 2006/04/10 15:38:54 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE trc_ldf_bilapg( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE trc_ldf_bilapg  ***
+      !!                    
+      !! ** Purpose :   Compute the before horizontal passive tracer diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The lateral diffusive trends is provided by a 4th order
+      !!      operator rotated along geopotential surfaces. It is computed
+      !!      using before fields (forward in time) and geopotential slopes
+      !!      computed in routine inildf.
+      !!         -1- compute the geopotential harmonic operator applied to
+      !!      trb and multiply it by the eddy diffusivity coefficient
+      !!      (done by a call to ldfght routine, result in wk1 array).
+      !!      Applied the domain lateral boundary conditions by call to lbc_lnk
+      !!         -2- compute the geopotential harmonic operator applied to
+      !!      wk1 by a second call to ldfght routine (result in wk3 array).
+      !!         -3- Add this trend to the general trend (ta,sa):
+      !!            tra = tra + wk3
+      !!
+      !! ** Action : - Update tra arrays with the before geopotential 
+      !!               biharmonic mixing trend.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                         ! ocean time-step index
+      INTEGER ::   ji, jj, jk, jn                           ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::   wk1, wk2  ! work array used for rotated biharmonic
+      !                                                     ! operator on tracers and/or momentum
+      CHARACTER (len=22) ::   charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_ldf_bilapg : horizontal biharmonic operator in s-coordinate'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
+      ENDIF
+
+      ! 1. Laplacian of passive tracers trb * aht
+      ! ----------------------------- 
+      ! rotated harmonic operator applied to trb 
+      ! and multiply by aht (output in wk1 )
+
+      CALL ldfght ( trb, wk1, 1 )
+
+      DO jn = 1, jptra
+      ! Lateral boundary conditions on wk1   (unchanged sign)
+         CALL lbc_lnk( wk1(:,:,:,jn) , 'T', 1. )
+      END DO
+
+      ! 2. Bilaplacian of trb
+      ! -------------------------
+      ! rotated harmonic operator applied to wk1 (output in wk2 )
+
+      CALL ldfght ( wk1, wk2, 2 )
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+
+         ! 3. Update the tracer trends                    (j-slab :   2, jpj-1)
+         ! ---------------------------
+         !                                                ! ===============
+         DO jj = 2, jpjm1                                 !  Vertical slab
+            !                                             ! ===============
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + wk2(ji,jj,jk,jn)
+#if defined key_trc_diatrd
+                  ! save the horizontal diffusive trends
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),3) = wk2(ji,jj,jk,jn)
+#endif
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         IF( l_trdtrc .AND. luttrd(jn) ) CALL trd_mod_trc( wk2(:,:,:,jn), jn, jptrc_trd_ldf, kt )
+
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ldf - bilapg')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd' )
+      ENDIF
+
+   END SUBROUTINE trc_ldf_bilapg
+
+
+   SUBROUTINE ldfght ( pt, plt, kaht )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldfght  ***
+      !!          
+      !! ** Purpose :   Apply a geopotential harmonic operator to pt and 
+      !!      multiply it by the eddy diffusivity coefficient (if kaht=1).
+      !!      Routine only used in s-coordinates (l_sco=T) with bilaplacian
+      !!      operator (ln_traldf_bilap=T) acting along geopotential surfaces
+      !!      (ln_traldf_hor).
+      !!
+      !! ** Method  :   The harmonic operator rotated along geopotential 
+      !!      surfaces is applied to pt using the slopes of geopotential
+      !!      surfaces computed in inildf routine. The result is provided in
+      !!      plt arrays. It is computed in 2 steps:
+      !!
+      !!      First step: horizontal part of the operator. It is computed on
+      !!      ==========  pt as follows (idem on ps)
+      !!      horizontal fluxes :
+      !!         zftu = e2u*e3u/e1u di[ pt ] - e2u*uslp dk[ mi(mk(pt)) ]
+      !!         zftv = e1v*e3v/e2v dj[ pt ] - e1v*vslp dk[ mj(mk(pt)) ]
+      !!      take the horizontal divergence of the fluxes (no divided by
+      !!      the volume element :
+      !!         plt  = di-1[ zftu ] +  dj-1[ zftv ]
+      !!
+      !!      Second step: vertical part of the operator. It is computed on
+      !!      ===========  pt as follows (idem on ps)
+      !!      vertical fluxes :
+      !!         zftw = e1t*e2t/e3w * (wslpi^2+wslpj^2)  dk-1[ pt ]
+      !!              -     e2t     *       wslpi        di[ mi(mk(pt)) ]
+      !!              -     e1t     *       wslpj        dj[ mj(mk(pt)) ]
+      !!      take the vertical divergence of the fluxes add it to the hori-
+      !!      zontal component, divide the result by the volume element and
+      !!      if kaht=1, multiply by the eddy diffusivity coefficient:
+      !!         plt  = aht / (e1t*e2t*e3t) { plt + dk[ zftw ] }
+      !!      else:
+      !!         plt  =  1  / (e1t*e2t*e3t) { plt + dk[ zftw ] }
+      !!
+      !! * Action :
+      !!      'key_trdtra' defined: the trend is saved for diagnostics.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra), INTENT( in  ) ::   &
+         pt               ! tracer fields before for 1st call
+      !                   ! and laplacian of these fields for 2nd call.
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra), INTENT( out ) ::   &
+         plt              ! partial harmonic operator applied to
+      !                   ! pt components except
+      !                   ! second order vertical derivative term)
+      INTEGER, INTENT( in ) ::   &
+         kaht             ! =1 multiply the laplacian by the eddy diffusivity coeff.
+      !                   ! =2 no multiplication
+
+      INTEGER ::   ji, jj, jk,jn             ! dummy loop indices
+      REAL(wp) ::   &
+         zabe1, zabe2, zmku, zmkv,     &  ! temporary scalars
+         zbtr, ztah, ztav, &
+         zcof0, zcof1, zcof2,          &
+         zcof3, zcof4
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zftu, zftv ,                   &  ! workspace
+         zdkt, zdk1t
+
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         zftw,                          &  ! workspace
+         zdit, zdjt, zdj1t
+      !!----------------------------------------------------------------------
+
+      DO jn = 1, jptra
+         !                               ! ********** !   ! ===============
+         DO jk = 1, jpkm1                ! First step !   ! Horizontal slab
+            !                            ! ********** !   ! ===============
+
+            ! I.1 Vertical gradient of pt and ps at level jk and jk+1
+            ! -------------------------------------------------------
+            !     surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
+
+            zdk1t(:,:) = ( pt(:,:,jk,jn) - pt(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
+
+            IF( jk == 1 ) THEN
+               zdkt(:,:) = zdk1t(:,:)
+            ELSE
+               zdkt(:,:) = ( pt(:,:,jk-1,jn) - pt(:,:,jk,jn) ) * tmask(:,:,jk)
+            ENDIF
+
+
+            ! I.2 Horizontal fluxes
+            ! ---------------------
+
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zabe1 = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj)
+                  zabe2 = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj)
+
+                  zmku=1./MAX( tmask(ji+1,jj,jk  )+tmask(ji,jj,jk+1)   &
+                              +tmask(ji+1,jj,jk+1)+tmask(ji,jj,jk  ),1. )
+                  zmkv=1./MAX( tmask(ji,jj+1,jk  )+tmask(ji,jj,jk+1)   &
+                              +tmask(ji,jj+1,jk+1)+tmask(ji,jj,jk  ),1. )
+
+                  zcof1= -e2u(ji,jj) * uslp(ji,jj,jk) * zmku
+                  zcof2= -e1v(ji,jj) * vslp(ji,jj,jk) * zmkv
+
+                  zftu(ji,jj)= umask(ji,jj,jk) *   &
+                     (  zabe1 *( pt(ji+1,jj,jk,jn) - pt(ji,jj,jk,jn) )   &
+                      + zcof1 *( zdkt (ji+1,jj) + zdk1t(ji,jj)           &
+                                +zdk1t(ji+1,jj) + zdkt (ji,jj) )  )
+
+                  zftv(ji,jj)= vmask(ji,jj,jk) *   &
+                     (  zabe2 *( pt(ji,jj+1,jk,jn) - pt(ji,jj,jk,jn) )   &
+                      + zcof2 *( zdkt (ji,jj+1) + zdk1t(ji,jj)           &
+                                +zdk1t(ji,jj+1) + zdkt (ji,jj) )  )
+               END DO
+            END DO
+
+
+            ! I.3 Second derivative (divergence) (not divided by the volume)
+            ! ---------------------
+
+            DO jj = 2 , jpjm1
+               DO ji = 2 , jpim1
+                  ztah = zftu(ji,jj) - zftu(ji-1,jj) + zftv(ji,jj) - zftv(ji,jj-1)
+                  plt(ji,jj,jk,jn) = ztah
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+
+
+         !                             ! ************ !   ! ===============
+         DO jj = 2, jpjm1              !  Second step !   ! Horizontal slab
+            !                          ! ************ !   ! ===============
+
+            ! II.1 horizontal tracer gradient
+            ! -------------------------------
+
+            DO jk = 1, jpk
+               DO ji = 1, jpim1
+                  zdit (ji,jk) = ( pt(ji+1,jj  ,jk,jn) - pt(ji,jj  ,jk,jn) ) * umask(ji,jj  ,jk)
+                  zdjt (ji,jk) = ( pt(ji  ,jj+1,jk,jn) - pt(ji,jj  ,jk,jn) ) * vmask(ji,jj  ,jk)
+                  zdj1t(ji,jk) = ( pt(ji  ,jj  ,jk,jn) - pt(ji,jj-1,jk,jn) ) * vmask(ji,jj-1,jk)
+               END DO
+            END DO
+
+
+            ! II.2 Vertical fluxes
+            ! --------------------
+
+            ! Surface and bottom vertical fluxes set to zero
+            zftw(:, 1 ) = 0.e0
+            zftw(:,jpk) = 0.e0
+
+            ! interior (2=<jk=<jpk-1)
+            DO jk = 2, jpkm1
+               DO ji = 2, jpim1
+                  zcof0 = e1t(ji,jj) * e2t(ji,jj) / fse3w(ji,jj,jk)   &
+                     * (  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)        &
+                        + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
+
+                  zmku =1./MAX(  umask(ji  ,jj,jk-1)+umask(ji-1,jj,jk)   &
+                                +umask(ji-1,jj,jk-1)+umask(ji  ,jj,jk), 1. )
+
+                  zmkv =1./MAX(  vmask(ji,jj  ,jk-1)+vmask(ji,jj-1,jk)   &
+                                +vmask(ji,jj-1,jk-1)+vmask(ji,jj  ,jk), 1. )
+
+                  zcof3 = - e2t(ji,jj) * wslpi (ji,jj,jk) * zmku
+                  zcof4 = - e1t(ji,jj) * wslpj (ji,jj,jk) * zmkv
+
+                  zftw(ji,jk) = tmask(ji,jj,jk) *   &
+                     (  zcof0 * ( pt  (ji,jj,jk-1,jn) - pt  (ji,jj,jk,jn) )   &
+                      + zcof3 * ( zdit (ji  ,jk-1) + zdit (ji-1,jk)           &
+                                 +zdit (ji-1,jk-1) + zdit (ji  ,jk) )         &
+                      + zcof4 * ( zdjt (ji  ,jk-1) + zdj1t(ji  ,jk)           &
+                                 +zdj1t(ji  ,jk-1) + zdjt (ji  ,jk) )  )
+               END DO
+            END DO
+
+
+            ! II.3 Divergence of vertical fluxes added to the horizontal divergence
+            ! ---------------------------------------------------------------------
+
+            IF( kaht == 1 ) THEN
+               ! multiply the laplacian by the eddy diffusivity coefficient
+               DO jk = 1, jpkm1
+                  DO ji = 2, jpim1
+                     ! eddy coef. divided by the volume element
+                     zbtr = fsahtrt(ji,jj,jk) / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                     ! vertical divergence
+                     ztav = zftw(ji,jk) - zftw(ji,jk+1)
+                     ! harmonic operator applied to (pt,ps) and multiply by aht
+                     plt(ji,jj,jk,jn) = ( plt(ji,jj,jk,jn) + ztav ) * zbtr
+                  END DO
+               END DO
+            ELSEIF( kaht == 2 ) THEN
+               ! second call, no multiplication
+               DO jk = 1, jpkm1
+                  DO ji = 2, jpim1
+                     ! inverse of the volume element
+                     zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                     ! vertical divergence
+                     ztav = zftw(ji,jk) - zftw(ji,jk+1)
+                     ! harmonic operator applied to (pt,ps) 
+                     plt(ji,jj,jk,jn) = ( plt(ji,jj,jk,jn) + ztav ) * zbtr
+                  END DO
+               END DO
+            ELSE
+               IF(lwp) WRITE(numout,*) ' ldfght: kaht= 1 or 2, here =', kaht
+               IF(lwp) WRITE(numout,*) '         We stop'
+               STOP 'ldfght'
+            ENDIF
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+
+      END DO
+
+   END SUBROUTINE ldfght
+
+#else  
+   !!----------------------------------------------------------------------
+   !!   Dummy module :             NO rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ldf_bilapg( kt )               ! Dummy routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_ldf_bilapg: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_ldf_bilapg
+#endif
+
+   !!==============================================================================
+END MODULE trcldf_bilapg
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso.F90	(revision 1844)
@@ -0,0 +1,312 @@
+MODULE trcldf_iso
+   !!==============================================================================
+   !!                    ***  MODULE  trcldf_iso  ***
+   !!======================================================================
+   !! Ocean passive tracers:  horizontal component of the lateral tracer mixing trend
+   !! History :
+   !!        !  94-08  (G. Madec, M. Imbard)
+   !!        !  97-05  (G. Madec)  split into traldf and trazdf
+   !!        !  98-03  (L. Bopp, MA Foujols) passive tracer generalisation
+   !!        !  00-10  (MA Foujols E Kestenare) USE passive tracer coefficient
+   !!   8.5  !  02-08  (G. Madec)  Free form, F90
+   !!   9.0  !  04-03  (C. Ethe)  Free form, F90
+   !!        !  06-08  (C. Deltel) Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if key_top && defined key_ldfslp 
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   trc_ldf_iso : update the tracer trend with the horizontal component
+   !!                 of iso neutral laplacian operator or horizontal 
+   !!                 laplacian operator in s-coordinate
+   !!----------------------------------------------------------------------
+   USE oce_trc      ! ocean dynamics and tracers variables
+   USE trp_trc      ! ocean passive tracers variables
+   USE prtctl_trc   ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ldf_iso  ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcldf_iso.F90,v 1.9 2006/04/10 15:38:54 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ldf_iso( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_ldf_iso  ***
+      !! 
+      !! ** Purpose :   Compute the before horizontal tracer  diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The horizontal component of the lateral diffusive trends 
+      !!      is provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      horizontal fluxes associated with the rotated lateral mixing:
+      !!         zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ]
+      !!               - aht       e2u*uslp    dk[ mi(mk(tb)) ]
+      !!         zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ]
+      !!               - aht       e2u*vslp    dk[ mj(mk(tb)) ]
+      !!      add horizontal Eddy Induced advective fluxes (lk_traldf_eiv=T):
+      !!         zftu = zftu - dk-1[ aht e2u mi(wslpi) ] mi( tb ) 
+      !!         zftv = zftv - dk-1[ aht e1v mj(wslpj) ] mj( tb ) 
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + difft
+      !!
+      !! ** Action  : - Update tra arrays with the before isopycnal or
+      !!                geopotential s-coord harmonic mixing trend.
+      !!              - Save the trends ('key_trdmld_trc')
+      !!----------------------------------------------------------------------
+      USE oce_trc       , zftu => ua,  &  ! use ua as workspace
+         &                zftv => va      ! use va as workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt                             ! ocean time-step index
+      !!                                                 
+      INTEGER ::   ji, jj, jk, jn                               ! dummy loop indices
+      REAL(wp) ::   zabe1, zabe2, zcof1, zcof2                  ! temporary scalars
+      REAL(wp) ::   zmsku, zmskv, zbtr, ztra
+#if defined key_trcldf_eiv
+      REAL(wp) ::   zcg1, zcg2, zuwk, zvwk, zuwk1, zvwk1
+      REAL(wp) ::   z_hdivn_x, z_hdivn_y
+#endif
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdkt, zdk1t             ! workspace
+#if defined key_trcldf_eiv
+      REAL(wp), DIMENSION(jpi,jpj) ::   zftug, zftvg
+#endif
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd       ! trends arrays
+#   if defined key_trcldf_eiv
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd_xei
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd_yei
+#endif
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_ldf_iso : iso neutral lateral diffusion or'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   horizontal laplacian diffusion in s-coordinate'
+#if defined key_trcldf_eiv && defined key_diaeiv
+         u_trc_eiv(:,:,:) = 0.e0
+         v_trc_eiv(:,:,:) = 0.e0
+#endif
+      ENDIF
+
+      IF( l_trdtrc ) THEN
+         ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+#   if defined key_trcldf_eiv
+         ALLOCATE( ztrtrd_xei(jpi,jpj,jpk) )
+         ALLOCATE( ztrtrd_yei(jpi,jpj,jpk) )
+#   endif
+      ENDIF
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)
+
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            ! 1. Vertical tracer gradient at level jk and jk+1
+            ! ------------------------------------------------
+            ! surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
+
+            zdk1t(:,:) = ( trb(:,:,jk,jn) - trb(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
+
+            IF( jk == 1 ) THEN
+               zdkt(:,:) = zdk1t(:,:)
+            ELSE
+               zdkt(:,:) = ( trb(:,:,jk-1,jn) - trb(:,:,jk,jn) ) * tmask(:,:,jk)
+            ENDIF
+
+
+            ! 2. Horizontal fluxes
+            ! --------------------
+
+            DO jj = 1 , jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zabe1 = ( fsahtru(ji,jj,jk) + ahtrb0 ) * e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj)
+                  zabe2 = ( fsahtrv(ji,jj,jk) + ahtrb0 ) * e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj)
+
+                  zmsku = 1. / MAX(   tmask(ji+1,jj,jk  ) + tmask(ji,jj,jk+1)   &
+                     + tmask(ji+1,jj,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+                  zmskv = 1. / MAX(   tmask(ji,jj+1,jk  ) + tmask(ji,jj,jk+1)   &
+                     + tmask(ji,jj+1,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+                  zcof1 = -fsahtru(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku
+                  zcof2 = -fsahtrv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv
+
+                  zftu(ji,jj,jk) = umask(ji,jj,jk) * (   zabe1 * (   trb(ji+1,jj,jk,jn) - trb(ji,jj,jk,jn)  )   &
+                     &                              + zcof1 * (   zdkt (ji+1,jj) + zdk1t(ji,jj)      &
+                     &                                          + zdk1t(ji+1,jj) + zdkt (ji,jj)  )  )
+
+                  zftv(ji,jj,jk) = vmask(ji,jj,jk) * (   zabe2 * (   trb(ji,jj+1,jk,jn) - trb(ji,jj,jk,jn)  )   &
+                     &                              + zcof2 * (   zdkt (ji,jj+1) + zdk1t(ji,jj)      &
+                     &                                          + zdk1t(ji,jj+1) + zdkt (ji,jj)  )  )
+
+               END DO
+            END DO
+
+#   if defined key_trcldf_eiv
+            !                              ! ---------------------------------------!
+            !                              ! Eddy induced vertical advective fluxes !
+            !                              ! ---------------------------------------!
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj,jk  ) ) * fsaeitru(ji,jj,jk  ) * umask(ji,jj,jk  )
+                  zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj,jk+1) ) * fsaeitru(ji,jj,jk+1) * umask(ji,jj,jk+1)
+                  zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji,jj+1,jk  ) ) * fsaeitrv(ji,jj,jk  ) * vmask(ji,jj,jk  )
+                  zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji,jj+1,jk+1) ) * fsaeitrv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
+
+                  zcg1= -0.25 * e2u(ji,jj) * umask(ji,jj,jk) * ( zuwk-zuwk1 )
+                  zcg2= -0.25 * e1v(ji,jj) * vmask(ji,jj,jk) * ( zvwk-zvwk1 )
+
+                  zftug(ji,jj) = zcg1 * ( trb(ji+1,jj,jk,jn) + trb(ji,jj,jk,jn) )
+                  zftvg(ji,jj) = zcg2 * ( trb(ji,jj+1,jk,jn) + trb(ji,jj,jk,jn) )
+
+                  zftu(ji,jj,jk) = zftu(ji,jj,jk) + zftug(ji,jj)
+                  zftv(ji,jj,jk) = zftv(ji,jj,jk) + zftvg(ji,jj)
+
+#   if defined key_diaeiv
+                  u_trc_eiv(ji,jj,jk) = -2. * zcg1 / ( e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  v_trc_eiv(ji,jj,jk) = -2. * zcg2 / ( e1v(ji,jj) * fse3v(ji,jj,jk) )
+#   endif
+               END DO
+            END DO
+#   endif
+
+            ! 3. Second derivative (divergence) and add to the general trend
+            ! --------------------------------------------------------------
+
+            DO jj = 2 , jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr= 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ztra = zbtr * (  zftu(ji,jj,jk) - zftu(ji-1,jj  ,jk)   &
+                       &         + zftv(ji,jj,jk) - zftv(ji  ,jj-1,jk)  )
+                  tra (ji,jj,jk,jn) = tra (ji,jj,jk,jn) + ztra
+#if defined key_trc_diatrd
+                  IF (luttrd(jn)) trtrd (ji,jj,jk,ikeep(jn),4) = ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk  ) ) * zbtr
+                  IF (luttrd(jn)) trtrd (ji,jj,jk,ikeep(jn),5) = ( zftv(ji,jj,jk) - zftv(ji,jj-1,jk  ) ) * zbtr
+#endif
+
+               END DO
+            END DO
+            !                                          ! ===============
+         END DO                                        !   End of slab  
+         !                                             ! ===============
+
+         ! 4. Save the trends for diagnostic
+         ! ---------------------------------
+
+         IF( l_trdtrc ) THEN
+#   if defined key_trcldf_eiv
+
+            ! 4.1) Compute the eiv ZONAL & MERIDIONAL advective trends
+                                                          ! ===============
+            DO jk = 1, jpkm1                              ! Horizontal slab
+                                                          ! ===============
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj,jk  ) ) * fsaeitru(ji,jj,jk  ) * umask(ji,jj,jk  )
+                     zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj,jk+1) ) * fsaeitru(ji,jj,jk+1) * umask(ji,jj,jk+1)
+                     zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji,jj+1,jk  ) ) * fsaeitrv(ji,jj,jk  ) * vmask(ji,jj,jk  )
+                     zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji,jj+1,jk+1) ) * fsaeitrv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
+                     
+                     zcg1= -0.25 * e2u(ji,jj) * umask(ji,jj,jk) * ( zuwk-zuwk1 )
+                     zcg2= -0.25 * e1v(ji,jj) * vmask(ji,jj,jk) * ( zvwk-zvwk1 )
+                     
+                     zftug(ji,jj) = zcg1 * ( trb(ji+1,jj,jk,jn) + trb(ji,jj,jk,jn) )
+                     zftvg(ji,jj) = zcg2 * ( trb(ji,jj+1,jk,jn) + trb(ji,jj,jk,jn) )
+                  END DO
+               END DO
+               
+               DO jj = 2 , jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zbtr= 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                     
+                     !-- Compute zonal & meridional divergences of the eiv field :
+                     !     d_x[u_trc_eiv] = 1/(e1t*e2t*e3t) ( di[e2u*e3u u_trc_eiv] )
+                     !     d_y[v_trc_eiv] = 1/(e1t*e2t*e3t) ( dj[e1v*e3v v_trc_eiv] )
+                     !   N.B.  This is only possible if key_diaeiv is switched on.
+#       if defined key_diaeiv
+                     z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * u_trc_eiv(ji  ,jj  ,jk)  &
+                          &       - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * u_trc_eiv(ji-1,jj  ,jk) ) * zbtr
+                     z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * v_trc_eiv(ji,  jj  ,jk)  &
+                          &       - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * v_trc_eiv(ji  ,jj-1,jk) ) * zbtr
+#       else
+                     z_hdivn_x = 0.e0   ;   z_hdivn_y = 0.e0 
+#       endif
+                     !-- Compute the zonal advective trends associated with eiv
+                     ztrtrd_xei(ji,jj,jk) =  zbtr * ( zftug(ji,jj) - zftug(ji-1,jj  ) )          &
+                          &                 - trn(ji,jj,jk,jn) * z_hdivn_x
+                     
+                     !-- Compute the merid. advective trends associated with eiv
+                     ztrtrd_yei(ji,jj,jk) =  zbtr * ( zftvg(ji,jj) - zftvg(ji  ,jj-1) )          &
+                          &                 - trn(ji,jj,jk,jn) * z_hdivn_y
+                  END DO
+               END DO
+                                                          ! ===============
+            END DO                                        !   End of slab  
+                                                          ! ===============
+            ! 4.2) Deduce the trend
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:) - ztrtrd_xei(:,:,:) - ztrtrd_yei(:,:,:)
+#   else
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+#   endif
+            
+            ! 4.3) save the trends for diagnostic
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd    , jn, jptrc_trd_ldf, kt ) 
+#   if defined key_trcldf_eiv
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd_xei, jn, jptrc_trd_xei, kt )
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd_yei, jn, jptrc_trd_yei, kt )
+#   endif
+         ENDIF
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+
+      IF( l_trdtrc ) THEN
+         DEALLOCATE( ztrtrd )
+#   if defined key_trcldf_eiv
+         DEALLOCATE( ztrtrd_xei )
+         DEALLOCATE( ztrtrd_yei )
+#   endif
+      ENDIF
+
+      IF( ln_ctl ) THEN        ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ldf - iso')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_ldf_iso
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :             No rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ldf_iso( kt )               ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_ldf_iso: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_ldf_iso
+#endif
+
+   !!==============================================================================
+END MODULE trcldf_iso
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso_zps.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso_zps.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_iso_zps.F90	(revision 1844)
@@ -0,0 +1,352 @@
+MODULE trcldf_iso_zps
+   !!======================================================================
+   !!                   ***  MODULE  trcldf_iso_zps  ***
+   !! Ocean passive tracers:  horizontal component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :       !  94-08  (G. Madec, M. Imbard)
+   !!                 !  97-05  (G. Madec)  split into traldf and trazdf
+   !!            8.5  !  02-08  (G. Madec)  Free form, F90
+   !!            9.0  !  04-03  (C. Ethe)  adapted for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if key_top &&  defined key_ldfslp 
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'               slope of the lateral diffusive direction
+   !!----------------------------------------------------------------------
+   !!   trc_ldf_iso_zps : update the tracer trend with the horizontal 
+   !!                     component of a iso-neutral laplacian operator
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc                 ! ocean passive tracers variables
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ldf_iso_zps  ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcldf_iso_zps.F90,v 1.10 2006/09/12 11:10:14 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ldf_iso_zps( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_ldf_iso_zps  ***
+      !!
+      !! ** Purpose :   Compute the before horizontal tracer  diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The horizontal component of the lateral diffusive trends 
+      !!      is provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      horizontal fluxes associated with the rotated lateral mixing:
+      !!         zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ]
+      !!               - aht       e2u*uslp    dk[ mi(mk(trb)) ]
+      !!         zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ]
+      !!               - aht       e2u*vslp    dk[ mj(mk(trb)) ]
+      !!      add horizontal Eddy Induced advective fluxes (lk_traldf_eiv=T):
+      !!         zftu = zftu - dk-1[ aht e2u mi(wslpi) ] mi( trb ) 
+      !!         zftv = zftv - dk-1[ aht e1v mj(wslpj) ] mj( trb ) 
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + difft
+      !!
+      !!      'key_trdtra' defined: the trend is saved for diagnostics.
+      !!
+      !!      macro-tasked on horizontal slab (jk-loop).
+      !!
+      !! ** Action :
+      !!         Update tra arrays with the before along level biharmonic
+      !!      mixing trend.
+      !!         Save the trends if 'key_trdmld_trc' defined
+      !!----------------------------------------------------------------------
+      USE oce_trc       , zftu => ua,  &  ! use ua as workspace
+         &                zftv => va      ! use va as workspace
+      !!
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+      INTEGER ::   ji, jj, jk,jn          ! dummy loop indices
+      INTEGER ::   iku, ikv               ! temporary integer
+      REAL(wp) ::   &
+         zabe1, zabe2, zcof1, zcof2,   &  ! temporary scalars
+         zmsku, zmskv, zbtr, ztra
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zdkt , zdk1t                     ! temporary workspace
+
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   & 
+         zgtbu, zgtbv               ! temporary workspace
+
+#if defined key_trcldf_eiv
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zftug, zftvg                     ! temporary workspace
+      REAL(wp) ::   &
+         z_hdivn_x, z_hdivn_y, zcg1, zcg2,  &
+         zuwk, zvwk, zuwk1, zvwk1
+#endif
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd_xei
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd_yei
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_ldf_iso_zps : iso neutral laplacian diffusion in '
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~   z-coordinates with partial steps'
+#if defined key_trcldf_eiv && defined key_diaeiv
+         u_trc_eiv(:,:,:) = 0.e0
+         v_trc_eiv(:,:,:) = 0.e0
+#endif
+      ENDIF
+
+      IF( l_trdtrc ) THEN
+         ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+#   if defined key_trcldf_eiv
+         ALLOCATE( ztrtrd_xei(jpi,jpj,jpk) )
+         ALLOCATE( ztrtrd_yei(jpi,jpj,jpk) )
+#   endif
+      ENDIF
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)   ! save trends
+      
+         zgtbu(:,:,:) = 0.     ;     zgtbv(:,:,:) = 0.
+         ! Horizontal passive tracer gradient 
+         DO jk = 1, jpk
+            DO jj = 1, jpj-1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zgtbu(ji,jj,jk) = tmask(ji,jj,jk) * ( trb(ji+1,jj  ,jk,jn) - trb(ji,jj,jk,jn) )
+                  zgtbv(ji,jj,jk) = tmask(ji,jj,jk) * ( trb(ji  ,jj+1,jk,jn) - trb(ji,jj,jk,jn) )
+               END DO
+            END DO
+         END DO
+         ! partial steps correction at the last level 
+         DO jj = 1, jpj-1
+            DO ji = 1, jpi-1
+               ! last level
+               iku = MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+               ikv = MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+               zgtbu(ji,jj,iku) = gtru(ji,jj,jn)               
+               zgtbv(ji,jj,ikv) = gtrv(ji,jj,jn)               
+            END DO
+         END DO
+
+         !                                                ! ===============
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !                                             ! ===============
+            ! 1. Vertical tracer gradient at level jk and jk+1
+            ! ------------------------------------------------
+            ! surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
+
+            zdk1t(:,:) = ( trb(:,:,jk,jn) - trb(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
+
+            IF( jk == 1 ) THEN
+               zdkt(:,:) = zdk1t(:,:)
+            ELSE
+               zdkt(:,:) = ( trb(:,:,jk-1,jn) - trb(:,:,jk,jn) ) * tmask(:,:,jk)
+            ENDIF
+
+            ! 2. Horizontal fluxes
+            ! --------------------
+
+            DO jj = 1 , jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zabe1 = ( fsahtru(ji,jj,jk) + ahtrb0 ) * e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj)
+                  zabe2 = ( fsahtrv(ji,jj,jk) + ahtrb0 ) * e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj)
+
+                  zmsku = 1. / MAX(  tmask(ji+1,jj,jk  ) + tmask(ji,jj,jk+1)   &
+                       &           + tmask(ji+1,jj,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+                  zmskv = 1. / MAX(  tmask(ji,jj+1,jk  ) + tmask(ji,jj,jk+1)   &
+                       &           + tmask(ji,jj+1,jk+1) + tmask(ji,jj,jk  ), 1. )
+
+                  zcof1 = -fsahtru(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku
+                  zcof2 = -fsahtrv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv
+
+                  zftu(ji,jj,jk) = umask(ji,jj,jk) * (  zabe1 * zgtbu(ji,jj,jk)   &
+                       &                              + zcof1 * (  zdkt (ji+1,jj) + zdk1t(ji,jj)      &
+                       &                                         + zdk1t(ji+1,jj) + zdkt (ji,jj)  )  )
+                  zftv(ji,jj,jk) = vmask(ji,jj,jk) * (  zabe2 * zgtbv(ji,jj,jk)   &
+                       &                              + zcof2 * (  zdkt (ji,jj+1) + zdk1t(ji,jj)      &
+                       &                                         + zdk1t(ji,jj+1) + zdkt (ji,jj)  )  )
+               END DO
+            END DO
+
+# if defined key_trcldf_eiv
+
+            ! ... Eddy induced horizontal advective fluxes
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj  ,jk  ) ) * fsaeitru(ji,jj,jk  ) * umask(ji,jj,jk  )
+                  zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj  ,jk+1) ) * fsaeitru(ji,jj,jk+1) * umask(ji,jj,jk+1)
+                  zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji  ,jj+1,jk  ) ) * fsaeitrv(ji,jj,jk  ) * vmask(ji,jj,jk  )
+                  zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji  ,jj+1,jk+1) ) * fsaeitrv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
+
+                  zcg1= -0.25 * e2u(ji,jj) * umask(ji,jj,jk) * ( zuwk-zuwk1 )
+                  zcg2= -0.25 * e1v(ji,jj) * vmask(ji,jj,jk) * ( zvwk-zvwk1 )
+
+                  zftug(ji,jj) = zcg1 * ( trb(ji+1,jj,jk,jn) + trb(ji,jj,jk,jn) )
+                  zftvg(ji,jj) = zcg2 * ( trb(ji,jj+1,jk,jn) + trb(ji,jj,jk,jn) )
+
+                  zftu(ji,jj,jk) = zftu(ji,jj,jk) + zftug(ji,jj)
+                  zftv(ji,jj,jk) = zftv(ji,jj,jk) + zftvg(ji,jj)
+
+#   if defined key_diaeiv
+                  u_trc_eiv(ji,jj,jk) = -2. * zcg1 / ( e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  v_trc_eiv(ji,jj,jk) = -2. * zcg2 / ( e1v(ji,jj) * fse3v(ji,jj,jk) )
+#   endif
+               END DO
+            END DO
+# endif
+
+            ! 3. Second derivative (divergence) and add to the general trend
+            ! --------------------------------------------------------------
+
+            DO jj = 2 , jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  ztra = zbtr * ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)  )
+                  tra(ji,jj,jk,jn) = tra (ji,jj,jk,jn) + ztra
+               END DO
+            END DO
+
+#if defined key_trc_diatrd
+            DO jj = 2 , jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  IF( luttrd(jn) ) THEN 
+                     trtrd (ji,jj,jk,ikeep(jn),4) = zbtr * ( zftu(ji,jj,jk) - zftu(ji-1,  jj,jk) )
+                     trtrd (ji,jj,jk,ikeep(jn),5) = zbtr * ( zftv(ji,jj,jk) - zftv(ji  ,jj-1,jk) )
+                  ENDIF
+#   if defined key_trcldf_eiv
+                  IF( luttrd(jn) ) THEN 
+                     trtrd (ji,jj,jk,ikeep(jn),4) = trtrd(ji,jj,jk,ikeep(jn),4)    &
+                     &                            - zbtr * ( zftug(ji,jj) - zftug(ji-1,jj  ) ) 
+                     trtrd (ji,jj,jk,ikeep(jn),5) = trtrd(ji,jj,jk,ikeep(jn),5)    &
+                     &                            - zbtr * ( zftvg(ji,jj) - zftvg(ji  ,jj-1) )
+                  ENDIF
+#   endif
+               END DO
+            END DO
+#endif
+
+            !                                          ! ===============
+         END DO                                        !   End of slab  
+         !                                             ! ===============
+
+         ! 4. Save the horizontal diffusive and advective (eiv) trends for diagnostics
+         ! ---------------------------------------------------------------------------
+         IF( l_trdtrc ) THEN
+
+            ! 4.1) Compute the eiv ZONAL & MERIDIONAL advective trends
+
+#   if defined key_trcldf_eiv
+            !                                                ! ===============
+            DO jk = 1, jpkm1                                 ! Horizontal slab
+               !                                             ! ===============
+
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj  ,jk  ) ) * fsaeitru(ji,jj,jk  ) * umask(ji,jj,jk  )
+                     zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj  ,jk+1) ) * fsaeitru(ji,jj,jk+1) * umask(ji,jj,jk+1)
+                     zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji  ,jj+1,jk  ) ) * fsaeitrv(ji,jj,jk  ) * vmask(ji,jj,jk  )
+                     zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji  ,jj+1,jk+1) ) * fsaeitrv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
+                     
+                     zcg1= -0.25 * e2u(ji,jj) * umask(ji,jj,jk) * ( zuwk-zuwk1 )
+                     zcg2= -0.25 * e1v(ji,jj) * vmask(ji,jj,jk) * ( zvwk-zvwk1 )
+                     
+                     zftug(ji,jj) = zcg1 * ( trb(ji+1,jj,jk,jn) + trb(ji,jj,jk,jn) )
+                     zftvg(ji,jj) = zcg2 * ( trb(ji,jj+1,jk,jn) + trb(ji,jj,jk,jn) )
+                  END DO
+               END DO
+
+               DO jj = 2 , jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                  
+                     zbtr = 1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+
+                     !-- Compute zonal & meridional divergences of the eiv field :
+                     !     d_x[u_trc_eiv] = 1/(e1t*e2t*e3t) ( di[e2u*e3u u_trc_eiv] )
+                     !     d_y[v_trc_eiv] = 1/(e1t*e2t*e3t) ( dj[e1v*e3v v_trc_eiv] )
+                     !   N.B.  This is only possible if key_diaeiv is switched on.
+#       if defined key_diaeiv
+                     z_hdivn_x = (  e2u(ji  ,jj) * fse3u(ji  ,jj,jk) * u_trc_eiv(ji  ,jj  ,jk)  &
+                          &       - e2u(ji-1,jj) * fse3u(ji-1,jj,jk) * u_trc_eiv(ji-1,jj  ,jk) ) * zbtr
+                     z_hdivn_y = (  e1v(ji,  jj) * fse3v(ji,jj  ,jk) * v_trc_eiv(ji,  jj  ,jk)  &
+                          &       - e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * v_trc_eiv(ji  ,jj-1,jk) ) * zbtr
+#       else
+                     z_hdivn_x = 0.e0   ;   z_hdivn_y = 0.e0 
+#       endif
+                     !-- Compute the zonal advective trends associated with eiv
+                     ztrtrd_xei(ji,jj,jk) = zbtr * ( zftug(ji,jj) - zftug(ji-1,jj  ) )          &
+                          &                 - trn(ji,jj,jk,jn) * z_hdivn_x
+                     
+                     !-- Compute the merid. advective trends associated with eiv
+                     ztrtrd_yei(ji,jj,jk) = zbtr * ( zftvg(ji,jj) - zftvg(ji  ,jj-1) )          &
+                          &                 - trn(ji,jj,jk,jn) * z_hdivn_y
+
+                  END DO
+               END DO
+               !                                             ! ===============
+            END DO                                           !   End of slab  
+            !                                                ! ===============
+#   else
+            ztrtrd_xei(:,:,:) = 0.e0
+            ztrtrd_yei(:,:,:) = 0.e0
+#   endif
+            ! 4.2) Substract the eddy induced velocity
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:) - ztrtrd_xei(:,:,:) - ztrtrd_yei(:,:,:)
+
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd    , jn, jptrc_trd_ldf, kt )
+#   if defined key_trcldf_eiv
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd_xei, jn, jptrc_trd_xei, kt )
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd_yei, jn, jptrc_trd_yei, kt )
+#   endif
+
+         ENDIF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+      IF( l_trdtrc ) THEN
+         DEALLOCATE( ztrtrd )
+#   if defined key_trcldf_eiv
+         DEALLOCATE( ztrtrd_xei )
+         DEALLOCATE( ztrtrd_yei )
+#   endif
+      ENDIF
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ldf - iso/zps')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd' )
+      ENDIF
+
+   END SUBROUTINE trc_ldf_iso_zps
+
+#else
+   !!----------------------------------------------------------------------
+   !!   default option :   Dummy code   NO rotation of the diffusive tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ldf_iso_zps( kt )               ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_ldf_iso_zps: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_ldf_iso_zps
+#endif
+
+   !!==============================================================================
+END MODULE trcldf_iso_zps
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_lap.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_lap.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcldf_lap.F90	(revision 1844)
@@ -0,0 +1,181 @@
+MODULE trcldf_lap
+   !!======================================================================
+   !!                       ***  MODULE  trcldf_lap  ***
+   !! Ocean passive tracers:  horizontal component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :  1.0  !  87-06  (P. Andrich, D. L Hostis)  Original code
+   !!                 !  91-11  (G. Madec)
+   !!                 !  95-02  (M. Levy)    passive tracers
+   !!                 !  95-11  (G. Madec)  suppress volumetric scale factors
+   !!                 !  96-01  (G. Madec)  statement function for e3
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe)   passive tracer
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   trc_ldf_lap  : update the tracer trend with the horizontal diffusion
+   !!                 using a iso-level harmonic (laplacien) operator.
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc                 ! ocean passive tracers variables
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_ldf_lap  ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcldf_lap.F90,v 1.10 2006/09/12 11:10:14 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE trc_ldf_lap( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_ldf_lap  ***
+      !!                   
+      !! ** Purpose :   Compute the before horizontal tracer diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   Second order diffusive operator evaluated using before
+      !!      fields (forward time scheme). The horizontal diffusive trends of 
+      !!      the passive tracer is given by:
+      !!       * s-coordinate, the vertical scale 
+      !!      factors e3. are inside the derivatives:
+      !!          difft = 1/(e1t*e2t*e3t) {  di-1[ aht e2u*e3u/e1u di(trb) ]
+      !!                                   + dj-1[ aht e1v*e3v/e2v dj(trb) ] }
+      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
+      !!          difft = 1/(e1t*e2t) {  di-1[ aht e2u/e1u di(trb) ]
+      !!                               + dj-1[ aht e1v/e2v dj(trb) ] }
+      !!      Add this trend to the general tracer trend tra :
+      !!          tra = tra + difft
+      !!
+      !! ** Action  : - Update tra arrays with the before iso-level 
+      !!                harmonic mixing trend.
+      !!              - Save the trends ('key_trdmld_trc')
+      !!----------------------------------------------------------------------
+      USE oce_trc          , ztu => ua,  &  ! use ua as workspace
+         &                   ztv => va      ! use va as workspace
+
+      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
+
+      !! * Local save
+      REAL(wp), DIMENSION(jpi,jpj), SAVE ::   &
+         ze1ur, ze2vr, zbtr2              ! scale factor coefficients
+      
+      INTEGER ::   ji, jj, jk, jn         ! dummy loop indices
+      REAL(wp) ::   &
+         zabe1, zabe2, zbtr               ! temporary scalars
+
+      REAL(wp) ::   &
+         ztrax, ztray               ! workspace
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_ldf_lap : iso-level laplacian diffusion'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+         ze1ur(:,:) = e2u(:,:) / e1u(:,:)
+         ze2vr(:,:) = e1v(:,:) / e2v(:,:)
+         zbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+      ENDIF
+
+      IF( l_trdtrc ) THEN
+!         STOP 'trcldf_lap: this was never validated, please comment this line to proceed...'
+      ENDIF
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)
+         
+         !                                                  ! =============
+         DO jk = 1, jpkm1                                   ! Vertical slab
+            !                                               ! =============
+            ! 1. First derivative (gradient)
+            ! ------------------------------
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  IF ( ln_sco ) THEN
+                     zabe1 = fsahtru(ji,jj,jk) * umask(ji,jj,jk) * ze1ur(ji,jj) * fse3u(ji,jj,jk)
+                     zabe2 = fsahtrv(ji,jj,jk) * vmask(ji,jj,jk) * ze2vr(ji,jj) * fse3v(ji,jj,jk)
+                  ELSE
+                     zabe1 = fsahtru(ji,jj,jk) * umask(ji,jj,jk) * ze1ur(ji,jj)
+                     zabe2 = fsahtrv(ji,jj,jk) * vmask(ji,jj,jk) * ze2vr(ji,jj)
+                  ENDIF
+                  ztu(ji,jj,jk) = zabe1 * ( trb(ji+1,jj  ,jk,jn) - trb(ji,jj,jk,jn) )
+                  ztv(ji,jj,jk) = zabe2 * ( trb(ji  ,jj+1,jk,jn) - trb(ji,jj,jk,jn) )
+               END DO
+            END DO
+
+
+            ! 2. Second derivative (divergence)
+            ! ---------------------------------
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF ( ln_sco ) THEN
+                     zbtr = zbtr2(ji,jj) / fse3t(ji,jj,jk)
+                  ELSE
+                     zbtr = zbtr2(ji,jj)
+                  ENDIF
+                  ! horizontal diffusive trends
+                  ztrax = zbtr * ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) )
+                  ztray = zbtr * ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )
+
+                  ! add it to the general tracer trends
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztrax + ztray
+#if defined key_trc_diatrd
+                  ! save the horizontal diffusive trends
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),4) = ztrax
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),5) = ztray
+#endif
+
+               END DO
+            END DO
+            !                                               ! =============
+         END DO                                             !  End of slab  
+         !                                                  ! =============
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_ldf, kt )   ! trends diags
+         END IF
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ldf - lap')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      ENDIF
+
+   END SUBROUTINE trc_ldf_lap
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ldf_lap( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_ldf_lap: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_ldf_lap
+#endif
+
+   !!==============================================================================
+END MODULE trcldf_lap
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcnxt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 1844)
@@ -0,0 +1,204 @@
+MODULE trcnxt
+   !!======================================================================
+   !!                       ***  MODULE  trcnxt  ***
+   !! Ocean passive tracers:  time stepping on passives tracers
+   !!======================================================================
+   !!======================================================================
+   !! History :  7.0  !  91-11  (G. Madec)  Original code
+   !!                 !  93-03  (M. Guyon)  symetrical conditions
+   !!                 !  95-02  (M. Levy)   passive tracers
+   !!                 !  96-02  (G. Madec & M. Imbard)  opa release 8.0
+   !!            8.0  !  96-04  (A. Weaver)  Euler forward step
+   !!            8.2  !  99-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!                 !  02-11  (C. Talandier, A-M Treguier) Open boundaries
+   !!            9.0  !  04-03  (C. Ethe) passive tracers
+   !!                 !  07-02  (C. Deltel) Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_nxt     : time stepping on passive tracers
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc         ! ocean dynamics and tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE trctrp_lec      ! pasive tracers transport
+   USE prtctl_trc      ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE agrif_top_update
+   USE agrif_top_interp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_nxt          ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_nxt( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trcnxt  ***
+      !!
+      !! ** Purpose :   Compute the passive tracers fields at the 
+      !!      next time-step from their temporal trends and swap the fields.
+      !! 
+      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through 
+      !!      call to lbc_lnk routine
+      !!   default:
+      !!      arrays swap
+      !!         (trn) = (tra) ; (tra) = (0,0)
+      !!         (trb) = (trn) 
+      !!
+      !!   For Arakawa or TVD Scheme : 
+      !!      A Asselin time filter applied on now tracers (trn) to avoid
+      !!      the divergence of two consecutive time-steps and tr arrays
+      !!      to prepare the next time_step:
+      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
+      !!         (trn) = (tra) ; (tra) = (0,0)
+      !!
+      !!
+      !! ** Action  : - update trb, trn
+      !!----------------------------------------------------------------------
+      USE oce, ONLY :   ztrtrd => ua    ! use ua as 3D workspace 
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp) ::   zfact            ! temporary scalar
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
+      ENDIF
+
+      DO jn = 1, jptra
+
+         ! 0. Lateral boundary conditions on tra (T-point, unchanged sign)
+         ! ---------------------------------============
+         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
+         
+         !                                                ! ===============
+         DO jk = 1, jpk                                   ! Horizontal slab
+            !                                             ! ===============
+            ! 1. Leap-frog scheme (only in explicit case, otherwise the 
+            ! -------------------  time stepping is already done in trczdf)
+            IF( l_trczdf_exp .AND. ( ln_trcadv_cen2 .OR. ln_trcadv_tvd) ) THEN
+               zfact = 2. * rdttra(jk) * FLOAT(ndttrc) 
+               IF( neuler == 0 .AND. kt == nittrc000 ) zfact = rdttra(jk) * FLOAT(ndttrc) 
+               tra(:,:,jk,jn) = ( trb(:,:,jk,jn) + zfact * tra(:,:,jk,jn) ) * tmask(:,:,jk)
+            ENDIF
+
+         END DO
+
+#if defined key_obc
+        CALL ctl_stop( '          Passive tracers and Open Boundary condition can not be used together ' &
+           &           '          Check in trc_nxt routine' )
+#endif
+
+#if defined key_agrif
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      ! Interp tracers on boundaries (coarse => fine)
+      CALL Agrif_trc
+      !                                                ! ===============
+      DO jn = 1, jptra                                 ! Horizontal slab
+         !                                             ! ===============
+#endif
+
+         DO jk = 1, jpk  
+
+            ! 2. Time filter and swap of arrays
+            ! ---------------------------------
+            IF ( ln_trcadv_cen2 .OR. ln_trcadv_tvd  ) THEN
+
+               IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn)
+                        trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)
+                        tra(ji,jj,jk,jn) = 0.
+                     END DO
+                  END DO
+                  IF( l_trdtrc )   ztrtrd(:,:,:) = 0.e0           !    no trend
+               ELSE
+                  IF( l_trdtrc ) THEN                             !    Asselin trend
+                     DO jj = 1, jpj
+                        DO ji = 1, jpi
+                           ztrtrd(ji,jj,jk) = atfp * ( trb(ji,jj,jk,jn) - 2*trn(ji,jj,jk,jn) + tra(ji,jj,jk,jn) )
+                        END DO
+                     END DO
+                  ENDIF
+
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        trb(ji,jj,jk,jn) = atfp  * ( trb(ji,jj,jk,jn) + tra(ji,jj,jk,jn) ) + atfp1 * trn(ji,jj,jk,jn)
+                        trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)
+                        tra(ji,jj,jk,jn) = 0.
+                     END DO
+                  END DO
+               ENDIF
+            ELSE                                                  ! >> EULER-FORWARD schemes (SMOLAR, MUSCL)
+               IF( l_trdtrc ) ztrtrd(:,:,:) = 0.e0                !    no trend
+
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     trb(ji,jj,jk,jn) = tra(ji,jj,jk,jn)
+                     trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)
+                     tra(ji,jj,jk,jn) = 0.
+                  END DO
+               END DO
+
+            ENDIF
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+
+         IF( l_trdtrc ) THEN                                      ! trends
+            DO jk = 1, jpk
+               zfact = 2. * rdttra(jk) * FLOAT(ndttrc)
+               ztrtrd(:,:,jk) = ztrtrd(:,:,jk) / zfact            ! n.b. ztrtrd=0 in Euler-forward case
+            END DO
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_atf, kt )
+         ENDIF
+         !                                                        ! ===========
+      END DO                                                      ! tracer loop
+      !                                                           ! ===========
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('nxt')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
+      ENDIF
+
+#if defined key_agrif
+      IF (.NOT.Agrif_Root())    CALL Agrif_Update_Trc( kt )
+#endif      
+
+
+   END SUBROUTINE trc_nxt
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_nxt( kt )  
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_nxt
+#endif
+   !!======================================================================
+END MODULE trcnxt
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcrad.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 1844)
@@ -0,0 +1,237 @@
+MODULE trcrad
+   !!======================================================================
+   !!                       ***  MODULE  trcrad  ***
+   !! Ocean passive tracers:  correction of negative concentrations
+   !!======================================================================
+   !! History :   -   !  01-01  (O. Aumont & E. Kestenare)  Original code
+   !!            1.0  !  04-03  (C. Ethe)  free form F90
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_rad    : correction of negative concentrations
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE lib_mpp
+   USE prtctl_trc          ! Print control for debbuging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_rad         ! routine called by trcstp.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+
+   SUBROUTINE trc_rad( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_rad  ***
+      !!
+      !! ** Purpose :   "crappy" routine to correct artificial negative
+      !!              concentrations due to isopycnal scheme
+      !!
+      !! ** Method  : - PISCES or LOBSTER: Set negative concentrations to zero
+      !!                while computing the corresponding tracer content that
+      !!                is added to the tracers. Then, adjust the tracer 
+      !!                concentration using a multiplicative factor so that 
+      !!                the total tracer concentration is preserved.
+      !!              - CFC: simply set to zero the negative CFC concentration
+      !!                (the total CFC content is not strictly preserved)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index      
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_rad : Correct artificial negative concentrations '
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      IF( lk_cfc     )   CALL trc_rad_sms( kt, trb, trn, jp_cfc0 , jp_cfc1               )  ! CFC model
+      IF( lk_c14b    )   CALL trc_rad_sms( kt, trb, trn, jp_c14b0, jp_c14b1              )  ! bomb C14
+      IF( lk_lobster )   CALL trc_rad_sms( kt, trb, trn, jp_lob0 , jp_lob1, cpreserv='Y' )  ! LOBSTER model
+      IF( lk_pisces  )   CALL trc_rad_sms( kt, trb, trn, jp_pcs0 , jp_pcs1, cpreserv='Y' )  ! PISCES model
+      IF( lk_my_trc  )   CALL trc_rad_sms( kt, trb, trn, jp_myt0 , jp_myt1               )  ! MY_TRC model
+
+
+      !
+      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('rad')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
+      ENDIF
+      !
+   END SUBROUTINE trc_rad
+
+   SUBROUTINE trc_rad_sms( kt, ptrb, ptrn, jp_sms0, jp_sms1, cpreserv )
+      !!-----------------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_rad_sms  ***
+      !!
+      !! ** Purpose :   "crappy" routine to correct artificial negative
+      !!              concentrations due to isopycnal scheme
+      !!
+      !! ** Method  : 2 cases :
+      !!                - Set negative concentrations to zero while computing
+      !!                  the corresponding tracer content that is added to the
+      !!                  tracers. Then, adjust the tracer concentration using
+      !!                  a multiplicative factor so that the total tracer 
+      !!                  concentration is preserved.
+      !!                - simply set to zero the negative CFC concentration
+      !!                  (the total content of concentration is not strictly preserved)
+      !!--------------------------------------------------------------------------------
+      !! Arguments
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      INTEGER  , INTENT( in ) ::  &
+         jp_sms0, &       !: First index of the passive tracer model
+         jp_sms1          !: Last  index of  the passive tracer model
+
+      REAL(wp), DIMENSION (jpi,jpj,jpk,jptra), INTENT( inout )  :: &
+         ptrb, ptrn       !: before and now traceur concentration
+
+      CHARACTER( len = 1) , INTENT(in), OPTIONAL  :: &
+         cpreserv          !: flag to preserve content or not
+      
+      ! Local declarations
+      INTEGER  ::  ji, jj, jk, jn     ! dummy loop indices
+      REAL(wp) :: zvolk, ztrcorb, ztrmasb   ! temporary scalars
+      REAL(wp) :: zcoef, ztrcorn, ztrmasn   !    "         "
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrdb  ! workspace arrays
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrdn  ! workspace arrays
+      REAL(wp) :: zs2rdt
+      LOGICAL ::   lldebug = .FALSE.
+
+      !!----------------------------------------------------------------------
+
+      IF( l_trdtrc ) THEN
+        !
+        ALLOCATE( ztrtrdb(jpi,jpj,jpk) )
+        ALLOCATE( ztrtrdn(jpi,jpj,jpk) )
+        !
+      ENDIF
+      
+      IF( PRESENT( cpreserv )  ) THEN   !  total tracer concentration is preserved 
+      
+         DO jn = jp_sms0, jp_sms1
+         !                                                        ! ===========
+            ztrcorb = 0.e0   ;   ztrmasb = 0.e0
+            ztrcorn = 0.e0   ;   ztrmasn = 0.e0
+
+           IF( l_trdtrc ) THEN
+              ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
+              ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
+           ENDIF
+
+
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zvolk  = cvol(ji,jj,jk)
+# if defined key_off_degrad
+                     zvolk  = zvolk * facvol(ji,jj,jk)
+# endif
+                     ztrcorb = ztrcorb + MIN( 0., ptrb(ji,jj,jk,jn) ) * zvolk
+                     ztrcorn = ztrcorn + MIN( 0., ptrn(ji,jj,jk,jn) ) * zvolk
+
+                     ptrb(ji,jj,jk,jn) = MAX( 0., ptrb(ji,jj,jk,jn) )
+                     ptrn(ji,jj,jk,jn) = MAX( 0., ptrn(ji,jj,jk,jn) )
+
+                     ztrmasb = ztrmasb + ptrb(ji,jj,jk,jn) * zvolk
+                     ztrmasn = ztrmasn + ptrn(ji,jj,jk,jn) * zvolk
+                  END DO
+               END DO
+            END DO
+
+            IF( lk_mpp ) THEN
+               CALL mpp_sum( ztrcorb )      ! sum over the global domain
+               CALL mpp_sum( ztrcorn )      ! sum over the global domain
+               CALL mpp_sum( ztrmasb )      ! sum over the global domain
+               CALL mpp_sum( ztrmasn )      ! sum over the global domain
+            ENDIF
+
+            IF( ztrcorb /= 0 ) THEN
+               zcoef = 1. + ztrcorb / ztrmasb
+               DO jk = 1, jpkm1
+                  ptrb(:,:,jk,jn) = ptrb(:,:,jk,jn) * zcoef * tmask(:,:,jk)
+               END DO
+            ENDIF
+
+            IF( ztrcorn /= 0 ) THEN
+               zcoef = 1. + ztrcorn / ztrmasn
+               DO jk = 1, jpkm1
+                  ptrn(:,:,jk,jn) = ptrn(:,:,jk,jn) * zcoef * tmask(:,:,jk)
+               END DO
+            ENDIF
+            !
+            IF( l_trdtrc ) THEN
+               !
+               zs2rdt = 1. / ( 2. * rdt )
+               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
+               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
+               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdb, jn, jptrc_trd_radb, kt )       ! Asselin-like trend handling
+               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdn, jn, jptrc_trd_radn, kt )       ! standard     trend handling
+              !
+            ENDIF
+
+         END DO
+         !
+         !
+      ELSE  ! total CFC content is not strictly preserved
+
+         DO jn = jp_sms0, jp_sms1  
+
+           IF( l_trdtrc ) THEN
+              ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
+              ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
+           ENDIF
+
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ptrn(ji,jj,jk,jn) = MAX( 0. , ptrn(ji,jj,jk,jn) )
+                     ptrb(ji,jj,jk,jn) = MAX( 0. , ptrb(ji,jj,jk,jn) )
+                  END DO
+               END DO
+            END DO
+         
+            IF( l_trdtrc ) THEN
+               !
+               zs2rdt = 1. / ( 2. * rdt * FLOAT(ndttrc) )
+               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
+               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
+               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdb, jn, jptrc_trd_radb, kt )       ! Asselin-like trend handling
+               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdn, jn, jptrc_trd_radn, kt )       ! standard     trend handling
+              !
+            ENDIF
+            !
+         ENDDO
+
+      ENDIF
+
+      IF( l_trdtrc )   DEALLOCATE( ztrtrdb, ztrtrdn )
+
+   END SUBROUTINE trc_rad_sms
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                         NO TOP model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rad( kt )              ! Empty routine
+      INTEGER, INTENT(in) ::   kt
+      WRITE(*,*) 'trc_rad: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_rad
+#endif
+   
+   !!======================================================================
+END MODULE trcrad
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 1844)
@@ -0,0 +1,135 @@
+MODULE trcsbc
+   !!==============================================================================
+   !!                       ***  MODULE  trcsbc  ***
+   !! Ocean passive tracers:  surface boundary condition
+   !!======================================================================
+   !! History :  8.2  !  98-10  (G. Madec, G. Roullet, M. Imbard)  Original code
+   !!            8.2  !  01-02  (D. Ludicone)  sea ice and free surface
+   !!            8.5  !  02-06  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe)  adapted for passive tracers
+   !!                 !  06-08  (C. Deltel) Diagnose ML trends for passive tracers
+   !!==============================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_sbc      : update the tracer trend at ocean surface
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc                 ! ocean  passive tracers variables
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_sbc              ! routine called by step.F90
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sbc ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_sbc  ***
+      !!                   
+      !! ** Purpose :   Compute the tracer surface boundary condition trend of
+      !!      (concentration/dilution effect) and add it to the general 
+      !!       trend of tracer equations.
+      !!
+      !! ** Method :
+      !!      * concentration/dilution effect:
+      !!            The surface freshwater flux modify the ocean volume
+      !!         and thus the concentration of a tracer as :
+      !!            tra = tra + emp * trn / e3t   for k=1
+      !!         where emp, the surface freshwater budget (evaporation minus
+      !!         precipitation minus runoff) given in kg/m2/s is divided
+      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s.
+      !!
+      !! ** Action  : - Update the 1st level of tra with the trend associated
+      !!                with the tracer surface boundary condition 
+      !!
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER  ::   ji, jj, jn           ! dummy loop indices
+      REAL(wp) ::   ztra, zsrau, zse3t   ! temporary scalars
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+      CHARACTER (len=22) :: charout
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
+         IF(lwp) WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+      ! 0. initialization
+      zsrau = 1. / rau0
+      IF( .NOT. ln_sco )  zse3t = 1. / fse3t(1,1,1)
+
+      DO jn = 1, jptra
+         ! 1. Concentration dillution effect on tra
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
+
+         DO jj = 2, jpj
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               IF( ln_sco ) zse3t = 1. / fse3t(ji,jj,1)
+               ! concent./dilut. effect
+               ztra = emps(ji,jj) * zsrau * trn(ji,jj,1,jn) * zse3t * tmask(ji,jj,1)
+               ! add the trend to the general tracer trend
+               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ztra
+#if defined key_trc_diatrd
+               IF( luttrd(jn) ) &
+               &    trtrd(ji,jj,1,ikeep(jn),jpdiatrc) = trtrd(ji,jj,1,ikeep(jn),jpdiatrc) + ztra
+#endif
+
+            END DO
+         END DO
+         
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_sbc, kt)
+         END IF
+
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sbc')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_sbc
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      NO passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_sbc (kt)              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sbc
+#endif
+   
+   !!======================================================================
+END MODULE trcsbc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 1844)
@@ -0,0 +1,144 @@
+MODULE trctrp
+   !!======================================================================
+   !!                       ***  MODULE trctrp  ***
+   !! Ocean Physics    : manage the passive tracer transport
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (C. Ethe) Original code
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_trp        : passive tracer transport
+   !!----------------------------------------------------------------------
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trp_trc         ! ocean passive tracers variables 
+   USE trctrp_lec      ! passive tracers transport parameters
+   USE prtctl_trc      ! Print control for debbuging
+
+   USE trcbbl          ! bottom boundary layer               (trc_bbl routine)
+   USE trcdmp          ! internal damping                    (trc_dmp routine)
+
+   USE trcldf_bilapg   ! lateral mixing               (trc_ldf_bilapg routine)
+   USE trcldf_bilap    ! lateral mixing                (trc_ldf_bilap routine)
+   USE trcldf_iso      ! lateral mixing                  (trc_ldf_iso routine)
+   USE trcldf_iso_zps  ! lateral mixing              (trc_ldf_iso_zps routine)
+   USE trcldf_lap      ! lateral mixing                  (trc_ldf_lap routine)
+ 
+   USE trcnxt          ! time-stepping                       (trc_nxt routine)
+   USE trcrad          ! positivity                          (trc_rad routine)
+
+   USE trcadv_cen2     ! 2nd order centered advection   (trc_adv_cen2 routine)
+   USE trcadv_muscl    ! MUSCL advection               (trc_adv_muscl routine)
+   USE trcadv_muscl2   ! MUSCL2 advection             (trc_adv_muscl2 routine)
+   USE trcadv_tvd      ! TVD advection                   (trc_adv_tvd routine)
+   USE trcadv_smolar   ! SMOLAR advection             (trc_adv_smolar routine)
+
+   USE trczdf_exp      ! vertical diffusion              (trc_zdf_exp routine)
+   USE trczdf_imp      ! vertical diffusion              (trc_zdf_exp routine)
+   USE trczdf_iso      ! vertical diffusion              (trc_zdf_exp routine)
+   USE trczdf_iso_vopt ! vertical diffusion              (trc_zdf_exp routine)
+   USE trcsbc          ! surface boundary condition          (trc_sbc routine)
+
+   USE zpshde_trc      ! partial step: hor. derivative   (zps_hde_trc routine)
+
+#if defined key_agrif
+   USE agrif_top_sponge ! Momemtum and tracers sponges
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_trp    ! called by trc_stp
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_trp( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_trp  ***
+      !!                      
+      !! ** Purpose :   Management of passive tracers transport
+      !! 
+      !! ** Method  : - Compute the passive tracers trends 
+      !!              - Update the passive tracers
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::  kt  ! ocean time-step index
+      !!
+      CHARACTER (len=25) :: charout
+      !! ---------------------------------------------------------------------
+
+                               CALL trc_sbc( kt )            ! surface boundary condition
+# if defined key_trcbbc
+!!gm bug : this should be control during the initialisation phase, not here!
+       CALL ctl_stop( '  Bottom heat flux not yet implemented with passive tracer         ' &
+           &          '  Check in trc_trp routine ' )
+# endif 
+      !                                                      ! bottom boundary condition
+      IF( lk_trcbbl_dif    )   CALL trc_bbl_dif( kt )            ! diffusive bottom boundary layer scheme
+      IF( lk_trcbbl_adv    )   CALL trc_bbl_adv( kt )            ! advective (and/or diffusive) bottom boundary layer scheme
+
+      IF( lk_trcdmp        )   CALL trc_dmp( kt )            ! internal damping trends
+
+      !                                                      ! horizontal & vertical advection
+      IF( ln_trcadv_cen2   )   CALL trc_adv_cen2  ( kt )         ! 2nd order centered scheme
+      IF( ln_trcadv_muscl  )   CALL trc_adv_muscl ( kt )         ! MUSCL scheme
+      IF( ln_trcadv_muscl2 )   CALL trc_adv_muscl2( kt )         ! MUSCL2 scheme
+      IF( ln_trcadv_tvd    )   CALL trc_adv_tvd   ( kt )         ! TVD scheme
+      IF( ln_trcadv_smolar )   CALL trc_adv_smolar( kt )         ! SMOLARKIEWICZ scheme
+
+ 
+      IF( n_cla == 1   ) THEN
+!!gm bug : this should be control during the initialisation phase, not here!
+         WRITE(ctmp1,*) ' Cross Land Advection not yet implemented with passive tracer n_cla = ',n_cla
+         CALL ctl_stop( ctmp1 )
+      ENDIF
+
+      !                                                      ! lateral mixing 
+      IF( l_trcldf_bilapg  )   CALL trc_ldf_bilapg ( kt )        ! s-coord. horizontal bilaplacian
+      IF( l_trcldf_bilap   )   CALL trc_ldf_bilap  ( kt )        ! iso-level bilaplacian 
+      IF( l_trcldf_iso     )   CALL trc_ldf_iso    ( kt )        ! iso-neutral laplacian 
+      IF( l_trcldf_iso_zps )   CALL trc_ldf_iso_zps( kt )        ! partial step iso-neutral laplacian
+      IF( l_trcldf_lap     )   CALL trc_ldf_lap    ( kt )        ! iso-level laplacian
+
+#if defined key_agrif
+      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_trc               ! tracers sponge
+#endif
+ 
+      !                                                      ! vertical diffusion
+      IF( l_trczdf_exp     )   CALL trc_zdf_exp     ( kt )       ! explicit time stepping (time splitting scheme)
+      IF( l_trczdf_imp     )   CALL trc_zdf_imp     ( kt )       ! implicit time stepping (euler backward)
+      IF( l_trczdf_iso     )   CALL trc_zdf_iso     ( kt )       ! isopycnal
+      IF( l_trczdf_iso_vo  )   CALL trc_zdf_iso_vopt( kt )       ! vector opt. isopycnal
+
+                               CALL trc_nxt( kt )            ! tracer fields at next time step
+     
+      IF( ln_trcrad )          CALL trc_rad( kt )            ! Correct artificial negative concentrations
+      !                                                      ! especially useful when isopycnal mixing is used
+      !                                                      
+
+      IF( ln_zps .AND. .NOT. lk_trc_c1d )   &              ! Partial steps: now horizontal gradient of passive
+         &                     CALL zps_hde_trc( kt, trb, gtru, gtrv )       ! tracers at the bottom ocean level
+      !
+   END SUBROUTINE trc_trp
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                        No TOP models
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_trp( kt )              ! Empty routine
+      INTEGER, INTENT(in) ::   kt
+      WRITE(*,*) 'trc_trp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_trp
+#endif
+   
+   !!======================================================================
+END MODULE trctrp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_ctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_ctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_ctl.F90	(revision 1844)
@@ -0,0 +1,330 @@
+MODULE trctrp_ctl
+   !!======================================================================
+   !!                       ***  MODULE  trctrp_ctl  ***
+   !! TOP :   transport option control
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (C. Ethe) Original code
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_trp_ctl  : control the different options of transport
+   !!   trc_adv_ctl  : control the different options of the advection
+   !!   trc_ldf_ctl  : control the different options of the lateral diffusion
+   !!   trc_zdf_ctl  : control the different options of the vertical diffusion
+   !!   trc_dmp_ctl  : control the different options of the internal damping
+   !!----------------------------------------------------------------------
+   USE oce_trc       ! ocean dynamics and active tracers variables
+   USE trp_trc           ! ocean passive tracers variables
+   USE trctrp_lec    ! passive tracers transport
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_trp_ctl   ! called by ???
+
+#if defined key_trcldf_eiv
+      LOGICAL, PARAMETER ::   lk_trcldf_eiv   = .TRUE.   !: eddy induced velocity flag
+#else   
+      LOGICAL, PARAMETER ::   lk_trcldf_eiv   = .FALSE.  !: eddy induced velocity flag
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_trp_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_trp_ctl  ***
+      !!                
+      !! ** Purpose :   Control the consistency between cpp options for 
+      !!                tracer transport
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      CALL trc_adv_ctl      ! Control of Advection scheme options
+
+      CALL trc_ldf_ctl      ! Control of Lateral diffusion scheme options
+
+      CALL trc_zdf_ctl      ! Control of Vertival diffusion scheme options
+
+      !                     ! Control of Newtonian damping  options
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' *** Tracer damping option'
+      ENDIF
+#if defined key_trcdmp
+      IF(lwp) WRITE(numout,*) '     key_trcdmp is defined:   Check trcdmp ROUTINE '
+      CALL trc_dmp_ctl
+#else
+      IF(lwp) WRITE(numout,*) '     No tracer damping'
+#endif
+      !
+   END SUBROUTINE trc_trp_ctl
+
+
+   SUBROUTINE trc_adv_ctl
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_adv_ctl  ***
+      !!                
+      !! ** Purpose :   Control the consistency between cpp options for 
+      !!              tracer advection schemes
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio
+      !!----------------------------------------------------------------------
+
+      ! Control of Advection scheme options
+      ! -----------------------------------
+     IF( lk_trc_c1d ) THEN
+         ln_trcadv_cen2   = .FALSE.    ;  ln_trcadv_tvd    = .FALSE. ; ln_trcadv_muscl  = .FALSE.
+         ln_trcadv_muscl2 = .FALSE.    ;  ln_trcadv_smolar = .FALSE.
+         IF(lwp) WRITE(numout,*) ' *** 1D configuration : No advection on passive tracers '
+         IF(lwp) WRITE(numout,*) 
+      ELSE
+         ioptio = 0
+         IF( ln_trcadv_cen2   )   ioptio = ioptio + 1
+         IF( ln_trcadv_tvd    )   ioptio = ioptio + 1
+         IF( ln_trcadv_muscl  )   ioptio = ioptio + 1
+         IF( ln_trcadv_muscl2 )   ioptio = ioptio + 1
+         IF( ln_trcadv_smolar )   ioptio = ioptio + 1
+         
+         IF( lk_esopa ) THEN
+            IF(lwp) WRITE(numout,*) ' esopa control : the use of all scheme is forced'
+            ln_trcadv_cen2   = .TRUE.
+            ln_trcadv_tvd    = .TRUE.
+            ln_trcadv_muscl  = .TRUE.
+            ln_trcadv_muscl2 = .TRUE.
+            ln_trcadv_smolar = .TRUE.
+         ELSEIF( ioptio > 1 .OR. ioptio == 0 ) THEN
+            CALL ctl_stop( '  Choose one advection scheme in namelist nam_trcadv' )
+         ENDIF
+         
+         IF( n_cla == 1 .AND. .NOT. ln_trcadv_cen2 ) &
+            &    CALL ctl_stop( '    cross-land advection only with 2nd order advection scheme ' )
+      ENDIF
+      !
+   END SUBROUTINE trc_adv_ctl
+
+
+   SUBROUTINE trc_ldf_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_ldf_ctl  ***
+      !! 
+      !! ** Purpose :   Control the consistency between cpp options for 
+      !!      tracer lateral diffusion 
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio               ! ???
+      LOGICAL ::   ll_print = .FALSE.   ! =T print eddy coef. in numout      
+      !!----------------------------------------------------------------------
+
+      ! Parameter control
+
+      IF( .NOT. ln_trcldf_diff .OR. lk_trc_c1d ) THEN
+         l_trcldf_lap = .FALSE.   ;   l_trcldf_bilap   = .FALSE.   ;   l_trcldf_bilapg  = .FALSE.
+         l_trcldf_iso = .FALSE.   ;   l_trcldf_iso_zps = .FALSE.
+         l_trczdf_iso = .FALSE.   ;   l_trczdf_iso_vo  = .FALSE.
+         IF(lwp ) WRITE(numout,*) '*** No lateral diffusion on passive tracers '
+         IF(lwp ) WRITE(numout,*) 
+      ELSE
+         ! control the input
+         ioptio = 0
+         IF( ln_trcldf_lap   )   ioptio = ioptio + 1
+         IF( ln_trcldf_bilap )   ioptio = ioptio + 1
+         IF( ioptio /= 1 )   CALL ctl_stop( '    use ONE of the 2 lap/bilap operator type on tracer' )
+         
+         ioptio = 0
+         IF( ln_trcldf_level )   ioptio = ioptio + 1
+         IF( ln_trcldf_hor   )   ioptio = ioptio + 1
+         IF( ln_trcldf_iso   )   ioptio = ioptio + 1
+         IF( ioptio /= 1 )   CALL ctl_stop( '   use only ONE direction (level/hor/iso)' )
+         
+         ! ... Choice of the lateral scheme used
+         IF( lk_trcldf_eiv ) THEN
+            IF(lwp) WRITE(numout,*) '          eddy induced velocity on tracers'
+            IF( .NOT.ln_trcldf_iso .OR. ln_trcldf_bilap ) &
+               &      CALL ctl_stop( ' the eddy induced velocity on tracers ',&
+               &                     'requires isopycnal laplacian diffusion' )
+         ENDIF
+         
+         IF( ln_sco ) THEN          ! s-coordinates: rotation required for horizontal or isopycnal mixing
+            IF( ( ln_trcldf_iso .OR. ln_trcldf_hor ) .AND. .NOT.lk_ldfslp ) &
+               &      CALL ctl_stop( '  the rotation of the diffusive tensor require key_ldfslp' )
+         ELSE                       ! z-coordinates with/without partial step:
+            ln_trcldf_level = ln_trcldf_level .OR. ln_trcldf_hor      ! level diffusion = horizontal diffusion
+            ln_trcldf_hor   = .FALSE.
+            IF(lwp) WRITE(numout,*) '          horizontal mixing in z-coord or partial steps: force ln_trcldf_level = T'
+            IF(lwp) WRITE(numout,*) '                                                  and    force ln_trcldf_hor   = F'
+            IF( ln_trcldf_iso .AND. .NOT.lk_ldfslp ) &            ! rotation required for isopycnal mixing
+               &      CALL ctl_stop( ' the rotation of the diffusive tensor require key_ldfslp' )
+         ENDIF
+         
+         l_trcldf_lap     =  ln_trcldf_lap   .AND. ln_trcldf_level     ! iso-level   laplacian operator
+         l_trcldf_bilap   =  ln_trcldf_bilap .AND. ln_trcldf_level     ! iso-level bilaplacian operator
+         l_trcldf_bilapg  =  ln_trcldf_bilap .AND. ln_trcldf_hor       ! geopotential bilap. (s-coord)
+         l_trcldf_iso     =  ln_trcldf_lap   .AND.                  &  ! laplacian operator
+            &              ( ln_trcldf_iso   .OR.  ln_trcldf_hor )  &  ! iso-neutral (z-coord) or horizontal (s-coord)
+            &                                     .AND. .NOT.ln_zps
+         l_trcldf_iso_zps =  ln_trcldf_lap   .AND.                  &  ! laplacian operator
+            &              ( ln_trcldf_iso   .OR.  ln_trcldf_hor )  &  ! iso-neutral (partial steps)
+            &                                .AND. ln_zps              ! or geopotential in mixed partial steps/s-coord
+         l_trczdf_iso    = .FALSE.
+         l_trczdf_iso_vo = .FALSE.
+         IF( l_trcldf_iso     )   l_trczdf_iso = .TRUE.
+         IF( l_trcldf_iso_zps )   l_trczdf_iso = .TRUE.
+#if defined key_vectopt_memory
+         IF( l_trczdf_iso ) THEN
+            l_trczdf_iso    = .FALSE.
+            l_trczdf_iso_vo = .TRUE.
+         ENDIF
+#endif
+         
+         ioptio = 0
+         IF( l_trcldf_lap     )   ioptio = ioptio + 1
+         IF( l_trcldf_bilap   )   ioptio = ioptio + 1
+         IF( l_trcldf_bilapg  )   ioptio = ioptio + 1
+         IF( l_trcldf_iso     )   ioptio = ioptio + 1
+         IF( l_trcldf_iso_zps )   ioptio = ioptio + 1
+         IF( ioptio /= 1 ) &
+            &   CALL ctl_stop( '  this combination of operator and direction has not been implemented' )
+         
+         IF( lk_esopa ) THEN
+            l_trcldf_lap = .TRUE.   ;   l_trcldf_bilap   = .TRUE.   ;   l_trcldf_bilapg  = .TRUE.
+            l_trcldf_iso = .TRUE.   ;   l_trcldf_iso_zps = .TRUE.
+            l_trczdf_iso = .TRUE.   ;   l_trczdf_iso_vo  = .TRUE.
+            IF(lwp ) WRITE(numout,*) '          esopa test: use all lateral physics options'
+         ENDIF
+         
+         ! ... Space variation of eddy coefficients
+         ioptio = 0
+#if defined key_traldf_c3d || defined key_off_degrad
+         IF(lwp) WRITE(numout,*) 'tracer mixing coef. = F( latitude, longitude, depth)'
+         ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c2d && ! defined key_off_degrad
+         IF(lwp) WRITE(numout,*) 'tracer mixing coef. = F( latitude, longitude)'
+         ioptio = ioptio + 1
+#endif
+#if defined key_traldf_c1d && ! defined key_off_degrad
+         IF(lwp) WRITE(numout,*) 'tracer mixing coef. = F( depth )'
+         ioptio = ioptio + 1
+         IF( ln_sco ) &
+            &  CALL ctl_stop( '    key_traldf_c1d cannot be used in s-coordinate ' )
+#endif
+         IF( ioptio == 0 ) THEN
+            IF(lwp) WRITE(numout,*) ' tracer mixing coef. = constant (default option)'
+         ELSEIF( ioptio > 1 ) THEN
+            CALL ctl_stop( '  use only one of the following keys:',   &
+               &                 ' key_traldf_c3d, key_traldf_c2d, key_traldf_c1d' )
+         ENDIF
+         
+         IF( l_trcldf_bilap .OR. l_trcldf_bilapg ) THEN
+            IF(lwp) WRITE(numout,*) '  biharmonic tracer diffusion'
+            IF( ahtrc0 > 0 .AND. .NOT. lk_esopa ) &
+               &  CALL ctl_stop( '  The horizontal diffusivity coef. aht0 must be negative' )
+         ELSE
+            IF(lwp) WRITE(numout,*) ' harmonic tracer diffusion (default)'
+            IF( ahtrc0 < 0 .AND. .NOT. lk_esopa ) &
+               &  CALL ctl_stop( ' The horizontal diffusivity coef. aht0 must be positive' )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE trc_ldf_ctl
+
+
+   SUBROUTINE trc_zdf_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_ctl  ***
+      !! 
+      !! ** Purpose :   Control the consistency between cpp options for 
+      !!              tracer vertical diffusion
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+
+      ! Parameter & key controls
+      ! ------------------------
+      ! ... vertical mixing
+      ! time stepping scheme (N.B. TKE && KPP scheme => force the use of implicit scheme)
+#if defined key_zdftke || defined key_zdftke_old || defined key_zdfkpp
+      l_trczdf_exp = .FALSE.          ! use implicit scheme
+      l_trczdf_imp = .TRUE. 
+#else
+      IF( ln_trc_zdfexp  ) THEN  
+         l_trczdf_exp = .TRUE.           ! use explicit scheme
+         l_trczdf_imp = .FALSE.
+      ELSE
+         l_trczdf_exp = .FALSE.          ! use implicit scheme
+         l_trczdf_imp = .TRUE. 
+      ENDIF
+#endif
+
+      IF( l_trczdf_iso .OR. l_trczdf_iso_vo ) THEN  
+         l_trczdf_exp = .FALSE.          ! iso-neutral diffusion : 
+         l_trczdf_imp = .FALSE.          ! implicit scheme included in iso-neutral routine
+      ENDIF
+
+#if defined key_esopa
+      l_trczdf_exp = .TRUE.           ! esopa: use all options
+      l_trczdf_imp = .TRUE.
+#endif
+      !
+   END SUBROUTINE trc_zdf_ctl
+
+
+   SUBROUTINE trc_dmp_ctl
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_dmp_ctl  ***
+      !! 
+      !! ** Purpose :    Control the consistency between cpp options for 
+      !!              tracer newtonian damping 
+      !!----------------------------------------------------------------------
+#if defined key_trcdmp
+
+      SELECT CASE ( ndmptr )
+      !
+      CASE ( -1 )               ! ORCA: damping in Red & Med Seas only
+         IF(lwp) WRITE(numout,*) '          tracer damping in the Med & Red seas only'
+         !
+      CASE ( 1:90 )             ! Damping poleward of 'ndmptr' degrees
+         IF(lwp) WRITE(numout,*) '          tracer damping poleward of', ndmptr, ' degrees'
+         !
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for nmldmp = ', ndmptr
+         CALL ctl_stop(ctmp1)
+         !
+      END SELECT
+
+      SELECT CASE ( nmldmptr )
+      !
+      CASE ( 0 )                ! newtonian damping throughout the water column
+         IF(lwp) WRITE(numout,*) '          tracer damping throughout the water column'
+         !
+      CASE ( 1 )                ! no damping in the turbocline (avt > 5 cm2/s)
+         IF(lwp) WRITE(numout,*) '          no tracer damping in the turbocline'
+         !
+      CASE ( 2 )                ! no damping in the mixed layer 
+         IF(lwp) WRITE(numout,*) '          no tracer damping in the mixed layer'
+         !
+      CASE DEFAULT
+         WRITE(ctmp1,*) '          bad flag value for nmldmp = ', nmldmptr
+         CALL ctl_stop(ctmp1)
+         !
+      END SELECT
+#endif
+      !
+   END SUBROUTINE trc_dmp_ctl
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                        No TOP models
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_trp_ctl             ! Empty routine
+   END SUBROUTINE trc_trp_ctl
+#endif
+   
+  !!======================================================================
+END MODULE trctrp_ctl
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_lec.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_lec.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trctrp_lec.F90	(revision 1844)
@@ -0,0 +1,216 @@
+MODULE trctrp_lec
+   !!======================================================================
+   !!                       ***  MODULE  trctrp_lec  ***
+   !! TOP :   namelist read options for transport
+   !!======================================================================
+   !! History :   1.0  !  2004-03  (C. Ethe)  Original code
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_trp_lec  : read the passive tracer namelist for transport
+   !!----------------------------------------------------------------------
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc                 ! ocean passive tracers variables
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_trp_lec    ! routine called by step module
+ 
+   !                                                  !!: ** Advection (nam_traadv) **
+   LOGICAL , PUBLIC ::   ln_trcadv_cen2   = .FALSE.   !: 2nd order centered scheme flag
+   LOGICAL , PUBLIC ::   ln_trcadv_tvd    = .FALSE.   !: TVD scheme flag
+   LOGICAL , PUBLIC ::   ln_trcadv_muscl  = .FALSE.   !: MUSCL scheme flag
+   LOGICAL , PUBLIC ::   ln_trcadv_muscl2 = .FALSE.   !: MUSCL2 scheme flag
+   LOGICAL , PUBLIC ::   ln_trcadv_smolar = .TRUE.    !: Smolarkiewicz scheme flag
+
+   !                                                 !!: **  bottom boundary layer (nambbl) **
+   REAL(wp), PUBLIC ::   atrcbbl = 1.e+3              ! lateral coeff. for bottom boundary layer scheme (m2/s)
+
+   !                                                 !!: ** lateral mixing namelist (nam_trcldf) **
+   LOGICAL , PUBLIC ::   ln_trcldf_diff  = .FALSE.    !: flag of perform or not the lateral diff.
+   LOGICAL , PUBLIC ::   ln_trcldf_lap   = .TRUE.     !: laplacian operator
+   LOGICAL , PUBLIC ::   ln_trcldf_bilap = .FALSE.    !: bilaplacian operator
+   LOGICAL , PUBLIC ::   ln_trcldf_level = .FALSE.    !: iso-level direction
+   LOGICAL , PUBLIC ::   ln_trcldf_hor   = .FALSE.    !: horizontal (geopotential) direction
+   LOGICAL , PUBLIC ::   ln_trcldf_iso   = .TRUE.     !: iso-neutral direction
+
+   !                                                 !!: ** Treatment of Negative concentrations ( nam_trcrad )
+   LOGICAL , PUBLIC ::   ln_trcrad       = .TRUE.     !: flag to artificially correct negative concentrations
+
+   !                                                 !!: flag of the lateral diff. scheme used
+   LOGICAL , PUBLIC ::   l_trcldf_lap                 !: iso-level laplacian operator
+   LOGICAL , PUBLIC ::   l_trcldf_bilap               !: iso-level bilaplacian operator
+   LOGICAL , PUBLIC ::   l_trcldf_bilapg              !: geopotential bilap. (s-coord)
+   LOGICAL , PUBLIC ::   l_trcldf_iso                 !: iso-neutral laplacian or horizontal lapacian (s-coord)
+   LOGICAL , PUBLIC ::   l_trczdf_iso                 !: idem for the vertical component
+   LOGICAL , PUBLIC ::   l_trczdf_iso_vo              !: idem with vectopt_memory
+   LOGICAL , PUBLIC ::   l_trcldf_iso_zps             !: iso-neutral laplacian (partial steps)
+
+   !                                                 !!: ** Vertical diffusion (nam_trczdf) **
+   LOGICAL , PUBLIC ::   ln_trczdf_exp = .FALSE.      !: explicit vertical diffusion scheme flag
+
+   !                                                 !!: ** vertical diffusion (namzdf) **
+   INTEGER , PUBLIC ::   n_trczdf_exp = 3             !: number of sub-time step (explicit time stepping)
+
+   LOGICAL , PUBLIC ::   l_trczdf_exp     = .FALSE.   !: explicit vertical diffusion
+   LOGICAL , PUBLIC ::   l_trczdf_imp     = .FALSE.   !: implicit vertical diffusion
+
+#if defined key_trcdmp
+   !                                                 !!: ** newtonian damping namelist (nam_trcdmp) **
+   INTEGER  , PUBLIC ::   ndmptr   =   -1             !: = 0/-1/'latitude' for damping over tracers
+   INTEGER  , PUBLIC ::   ndmpftr  =    2             !: = 1 create a damping.coeff NetCDF file 
+   INTEGER  , PUBLIC ::   nmldmptr =    0             !: = 0/1/2 flag for damping in the mixed layer
+
+   !                                                 !!: ** newtonian damping (namdmp) **
+   REAL(wp) , PUBLIC ::   sdmptr   =   50.            !: surface time scale for internal damping (days)
+   REAL(wp) , PUBLIC ::   bdmptr   =  360.            !: bottom time scale for internal damping (days)
+   REAL(wp) , PUBLIC ::   hdmptr   =  800.            !: depth of transition between sdmp and bdmp (meters)
+#endif
+   !                                                 !!: ** SMOLAR advection scheme
+   REAL(wp) , PUBLIC ::  rsc       = 1.               !: tuning coefficient for anti-diffusion
+   INTEGER  , PUBLIC ::  ncortrc   = 1                !: number of corrective phases
+   LOGICAL  , PUBLIC ::  crosster  = .FALSE.          !: computes crossterms (T) or not (F)
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_trp_lec
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_trp_lec  ***
+      !!                
+      !! ** Purpose :   Read Namelist for tracer transport option
+      !!----------------------------------------------------------------------
+      NAMELIST/namtopadv/ ln_trcadv_cen2 , ln_trcadv_tvd,   &
+         &                ln_trcadv_muscl, ln_trcadv_muscl2, ln_trcadv_smolar, &
+         &                rsc, ncortrc, crosster
+#if  defined key_trcbbl_dif   ||   defined key_trcbbl_adv 
+      NAMELIST/namtopbbl/ atrcbbl
+#endif
+      NAMELIST/namtopldf/  ln_trcldf_diff  , ln_trcldf_lap  , ln_trcldf_bilap, &
+         &                 ln_trcldf_level, ln_trcldf_hor, ln_trcldf_iso,   &
+         &                 ahtrc0, ahtrb0, aeivtr0, trcrat
+      NAMELIST/namtopzdf/ ln_trczdf_exp, n_trczdf_exp
+      NAMELIST/namtoprad/ ln_trcrad
+#if defined key_trcdmp
+      NAMELIST/namtopdmp/ ndmptr, ndmpftr, nmldmptr, sdmptr, bdmptr, hdmptr
+#endif
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_trp_lec: read namelist for tracer transport'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
+
+      !                                ! tracer advection scheme
+      REWIND( numnat )                 !   ! Read Namelist namtopadv
+      READ  ( numnat, namtopadv )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtopadv : chose a advection scheme for tracers'
+         WRITE(numout,*) '      2nd order advection scheme               ln_trcadv_cen2   = ', ln_trcadv_cen2
+         WRITE(numout,*) '      TVD advection scheme                     ln_trcadv_tvd    = ', ln_trcadv_tvd
+         WRITE(numout,*) '      MUSCL  advection scheme                  ln_trcadv_muscl  = ', ln_trcadv_muscl
+         WRITE(numout,*) '      MUSCL2 advection scheme                  ln_trcadv_muscl2 = ', ln_trcadv_muscl2
+         WRITE(numout,*) '      SMOLARKIEWICZ advection scheme           ln_trcadv_smolar = ', ln_trcadv_smolar
+         IF( ln_trcadv_smolar ) THEN
+            WRITE(numout,*) '      SMOLARKIEWICZ : tuning coefficient                rsc      = ', rsc
+            WRITE(numout,*) '      SMOLARKIEWICZ : number of corrective phase        ncortrc  = ', ncortrc
+            WRITE(numout,*) '      SMOLARKIEWICZ : computes or not crossterms        crosster = ', crosster
+         ENDIF
+      ENDIF
+
+#if  defined key_trcbbl_dif
+      !                                ! Bottom boundary layer 
+      REWIND( numnat )                 !   ! Read Namelist namtopbbl
+      READ  ( numnat, namtopbbl )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtopbbl : set Diffusive Bottom Boundary Layer parameters'
+         WRITE(numout,*) '      bottom boundary layer coef.    atrcbbl = ', atrcbbl
+# if defined key_trcbbl_adv
+         WRITE(numout,*) '   * Advective Bottom Boundary Layer'
+# endif
+      ENDIF
+#endif
+
+      !                                ! Lateral physics on tracers   
+      REWIND( numnat )                 !   ! Read Namelist namtopldf
+      READ  ( numnat, namtopldf )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtopldf : set lateral mixing parameters (type, direction, coefficients)'
+         WRITE(numout,*) '      perform lateral diffusion or not               ln_trcldf_diff  = ', ln_trcldf_diff
+         WRITE(numout,*) '      laplacian operator                             ln_trcldf_lap   = ', ln_trcldf_lap
+         WRITE(numout,*) '      bilaplacian operator                           ln_trcldf_bilap = ', ln_trcldf_bilap
+         WRITE(numout,*) '      iso-level                                      ln_trcldf_level = ', ln_trcldf_level
+         WRITE(numout,*) '      horizontal (geopotential)                      ln_trcldf_hor   = ', ln_trcldf_hor
+         WRITE(numout,*) '      iso-neutral                                    ln_trcldf_iso   = ', ln_trcldf_iso
+         WRITE(numout,*) '      lateral eddy diffusivity                              ahtrc0   = ', ahtrc0
+         WRITE(numout,*) '      background hor. diffusivity                            ahtrb0  = ', ahtrb0
+         WRITE(numout,*) '      eddy induced velocity coef.                           aeivtr0  = ', aeivtr0
+         WRITE(numout,*) '      ratio between passive and active tracer diffusion coef  trcrat = ', trcrat
+      ENDIF
+
+      !                                ! Vertical mixing
+      REWIND( numnat )                 !   ! Read namtopzdf namelist
+      READ  ( numnat, namtopzdf )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtopzdf : set vertical diffusion parameters'
+         WRITE(numout,*) '      time splitting / backward scheme ln_trczdf_exp = ', ln_trczdf_exp
+         WRITE(numout,*) '      number of time step               n_trczdf_exp = ', n_trczdf_exp
+      ENDIF
+
+      !
+      REWIND( numnat )                 !   Read Namelist namtoprad
+      READ  ( numnat, namtoprad )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtoprad : treatment of negative concentrations'
+         WRITE(numout,*) '      correct artificially negative concen. or not ln_trcrad = ', ln_trcrad
+      ENDIF
+
+
+# if defined key_trcdmp
+      !                                ! passive tracres damping term
+      REWIND( numnat )                 !   ! Read Namelist namtdp
+      READ  ( numnat, namtopdmp )
+      IF( lzoom )   nmldmptr = 0           ! restoring to climatology at closed north or south boundaries
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtopdmp : set damping parameter'
+         WRITE(numout,*) '      tracers damping option         ndmptr   = ', ndmptr
+         WRITE(numout,*) '      create a damping.coeff file    ndmpftr  = ', ndmpftr
+         WRITE(numout,*) '      mixed layer damping option     nmldmptr = ', nmldmptr, '(zoom: forced to 0)'
+         WRITE(numout,*) '      surface time scale (days)      sdmptr   = ', sdmptr
+         WRITE(numout,*) '      bottom time scale (days)       bdmptr   = ', bdmptr
+         WRITE(numout,*) '      depth of transition (meters)   hdmptr   = ', hdmptr
+      ENDIF
+#endif
+      !
+   END SUBROUTINE trc_trp_lec
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                         No TOP model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_trp_lec              ! Empty routine
+   END SUBROUTINE trc_trp_lec
+#endif
+
+  !!======================================================================
+END MODULE trctrp_lec
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_exp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_exp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_exp.F90	(revision 1844)
@@ -0,0 +1,203 @@
+MODULE trczdf_exp
+   !!==============================================================================
+   !!                    ***  MODULE  trczdf_exp  ***
+   !! Ocean passive tracers:  vertical component of the tracer mixing trend using
+   !!                        an explicit time-stepping (time spllitting scheme)
+   !!======================================================================
+   !! History :  6.0  !  90-10  (B. Blanke)  Original code
+   !!            7.0  !  91-11  (G. Madec)
+   !!                 !  92-06  (M. Imbard)  correction on tracer trend loops
+   !!                 !  96-01  (G. Madec)  statement function for e3
+   !!                 !  97-05  (G. Madec)  vertical component of isopycnal
+   !!                 !  97-07  (G. Madec)  geopotential diffusion in s-coord
+   !!                 !  98-03  (L. Bopp MA Foujols) passive tracer generalisation
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-06  (O Aumont)  correct isopycnal scheme suppress
+   !!                 !                     avt multiple correction
+   !!                 !  00-08  (G. Madec)  double diffusive mixing
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe )  adapted for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_zdf_exp  : update the tracer trend with the vertical diffusion
+   !!                  using an explicit time stepping
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc          ! ocean dynamics and active tracers variables
+   USE trp_trc              ! ocean passive tracers variables
+   USE trctrp_lec       ! passive tracers transport
+   USE prtctl_trc          ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_zdf_exp          ! routine called by step.F90
+
+   !! * Module variable
+   REAL(wp), DIMENSION(jpk) ::   &
+      rdttrc                     ! vertical profile of 2 x tracer time-step
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_zdf_exp( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_exp  ***
+      !!                   
+      !! ** Purpose :   Compute the trend due to the vertical tracer mixing 
+      !!      using an explicit time stepping and add it to the general trend 
+      !!      of the tracer equations.
+      !!
+      !! ** Method  :   The vertical diffusion of tracers  is given by:
+      !!         difft = dz( avt dz(trb) ) = 1/e3t dk+1( avt/e3w dk(trb) )
+      !!      It is evaluated with an Euler scheme, using a time splitting
+      !!      technique.
+      !!      Surface and bottom boundary conditions: no diffusive flux on
+      !!      both tracers (bottom, applied through the masked field avt).
+      !!      Add this trend to the general trend tra :
+      !!          tra = tra + dz( avt dz(t) ) if lk_zdfddm= T)
+      !!
+      !! ** Action : - Update tra with the before vertical diffusion trend
+      !!             - Save the trends ('key_trdmld_trc')
+      !!
+      !!---------------------------------------------------------------------
+      USE oce, ONLY :   ztrtrd => ua    ! use ua as 3D workspace
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+      
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk, jl, jn             ! dummy loop indices
+      REAL(wp) ::   &
+         zlavmr,                 &  ! ???
+         zave3r, ze3tr,          &  ! ???
+         ztra                  !
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         zwx, zwy
+      CHARACTER (len=22) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_zdf_exp : vertical tracer mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+      ENDIF
+
+      IF( l_trdtrc ) THEN
+         STOP 'trczdf_exp: this was never validated, please comment this line to proceed...'
+      ENDIF
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN
+         ! time step = 2 rdttra with Arakawa or TVD advection scheme
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+            rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)             ! restarting with Euler time stepping
+         ELSEIF( kt <= nittrc000 + ndttrc ) THEN
+            rdttrc(:) = 2. * rdttra(:) * FLOAT(ndttrc)         ! leapfrog
+         ENDIF
+      ELSE
+         rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)      
+      ENDIF
+
+
+      zlavmr = 1. / FLOAT( n_trczdf_exp )
+
+      DO jn = 1, jptra
+         !
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)   ! save trends
+         !                                                ! ===============
+         DO jj = 2, jpjm1                                 !  Vertical slab
+            !                                             ! ===============
+            ! 1. Initializations
+            ! ------------------
+
+            ! Surface & bottom boundary conditions: no flux
+            DO ji = 2, jpim1
+               zwy(ji, 1 ) = 0.e0
+               zwy(ji,jpk) = 0.e0
+            END DO
+
+            ! zwx and zwz arrays set to before tracer values
+            DO jk = 1, jpk
+               DO ji = 2, jpim1
+                  zwx(ji,jk) = trb(ji,jj,jk,jn)
+               END DO
+            END DO
+
+
+            ! 2. Time splitting loop
+            ! ----------------------
+
+            DO jl = 1, n_trczdf_exp
+
+               ! first vertical derivative
+               ! double diffusion: fstravs(ji,jj,jk) = avt(ji,jj,jk) /= avs (key_trc_zdfddm) 
+               !                   fstravs(ji,jj,jk) = avs(ji,jj,jk) = avt
+               DO jk = 2, jpk
+                  DO ji = 2, jpim1
+                     zave3r = 1.e0 / fse3w(ji,jj,jk) 
+                     zwy(ji,jk) = fstravs(ji,jj,jk) * ( zwx(ji,jk-1) - zwx(ji,jk) ) * zave3r
+                  END DO
+               END DO
+
+
+               ! trend estimation at kt+l*2*rdt/n_zdfexp
+               DO jk = 1, jpkm1
+                  DO ji = 2, jpim1
+                     ze3tr = zlavmr / fse3t(ji,jj,jk)
+                     ! 2nd vertical derivative
+                     ztra = ( zwy(ji,jk) - zwy(ji,jk+1) ) * ze3tr
+                     ! update the tracer trends
+                     tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
+                     ! update tracer fields at kt+l*2*rdt/n_trczdf_exp
+                     zwx(ji,jk) = zwx(ji,jk) + rdttrc(jk) * ztra * tmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         IF( l_trdtrc ) THEN
+            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_zdf, kt )
+         END IF
+
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - exp')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_zdf_exp
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      NO passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_zdf_exp (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_zdf_exp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_zdf_exp
+#endif
+   
+   !!==============================================================================
+END MODULE trczdf_exp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_imp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_imp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_imp.F90	(revision 1844)
@@ -0,0 +1,297 @@
+MODULE trczdf_imp
+   !!==============================================================================
+   !!                    ***  MODULE  trczdf_imp  ***
+   !! Ocean passive tracers:  vertical component of the tracer mixing trend
+   !!==============================================================================
+   !! History :  6.0  !  90-10  (B. Blanke)  Original code
+   !!            7.0  !  91-11  (G. Madec)
+   !!                 !  92-06  (M. Imbard)  correction on tracer trend loops
+   !!                 !  96-01  (G. Madec)  statement function for e3
+   !!                 !  97-05  (G. Madec)  vertical component of isopycnal
+   !!                 !  97-07  (G. Madec)  geopotential diffusion in s-coord
+   !!                 !  98-03  (L. Bopp MA Foujols) passive tracer generalisation
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-06  (O Aumont)  correct isopycnal scheme suppress
+   !!                 !                     avt multiple correction
+   !!                 !  00-08  (G. Madec)  double diffusive mixing
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe )  adapted for passive tracers
+   !!                 !  07-02  (C. Deltel)  Diagnose ML trends for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_zdf_imp  : update the tracer trend with the vertical diffusion
+   !!                  using an implicit time-stepping.
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc             ! ocean dynamics and active tracers variables
+   USE trp_trc                 ! ocean passive tracers variables
+   USE trctrp_lec          ! passive tracers transport
+   USE prtctl_trc
+   USE trdmld_trc
+   USE trdmld_trc_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_zdf_imp          ! routine called by step.F90
+
+   !! * Module variable
+   REAL(wp), DIMENSION(jpk) ::   &
+      rdttrc                     ! vertical profile of 2 x tracer time-step
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_zdf_imp( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_imp  ***
+      !!
+      !! ** Purpose :   Compute the trend due to the vertical tracer mixing 
+      !!      using an implicit time stepping and add it to the general trend
+      !!      of the tracer equations.
+      !!
+      !! ** Method  :   The vertical diffusion of tracers tra is given by:
+      !!          difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(tra) )
+      !!      It is thus evaluated using a backward time scheme
+      !!      Surface and bottom boundary conditions: no diffusive flux on
+      !!      both tracers (bottom, applied through the masked field avt).
+      !!      Add this trend to the general trend tra :
+      !!          tra = tra + dz( avt dz(t) )
+      !!         (tra = tra + dz( avs dz(t) ) if lk_zdfddmtrc=T)
+      !!
+      !! ** Action  : - Update tra with the before vertical diffusion trend
+      !!              - save the trends 
+      !!
+      !!---------------------------------------------------------------------
+      !!
+      !! * Arguments
+      USE oce, ONLY :   ztrtrd => ua    ! use ua as 3D workspace 
+
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+      INTEGER ::   ikst, ikenm2, ikstp1
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk, jn             ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zwd, zws, zwi,          &  ! ???
+         zwx, zwy, zwt              ! ???
+#if defined key_trc_diatrd
+      REAL(wp) ::  ztra      ! temporary scalars
+#endif
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) ::   &
+         ztrd
+      CHARACTER (len=22) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_zdf_implicit : vertical tracer mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~'
+      ENDIF
+
+      ! 0. Local constant initialization
+      ! --------------------------------
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN
+         ! time step = 2 rdttra with Arakawa or TVD advection scheme
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+            rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)             ! restarting with Euler time stepping
+         ELSEIF( kt <= nittrc000 + ndttrc ) THEN
+            rdttrc(:) = 2. * rdttra(:) * FLOAT(ndttrc)         ! leapfrog
+         ENDIF
+      ELSE
+         rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)      
+      ENDIF
+
+      ! Initialisation
+      zwd( 1 ,:,:) = 0.e0     ;     zwd(jpi,:,:) = 0.e0
+      zws( 1 ,:,:) = 0.e0     ;     zws(jpi,:,:) = 0.e0
+      zwi( 1 ,:,:) = 0.e0     ;     zwi(jpi,:,:) = 0.e0
+      !                                          
+      ! 0. Matrix construction 
+      ! ----------------------
+
+      ! Diagonal, inferior, superior
+      ! (including the bottom boundary condition via avs masked
+      DO jk = 1, jpkm1                    
+         DO jj = 2, jpjm1                                    
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwi(ji,jj,jk) = - rdttrc(jk) * fstravs(ji,jj,jk  ) /( fse3t(ji,jj,jk) * fse3w(ji,jj,jk  ) )
+               zws(ji,jj,jk) = - rdttrc(jk) * fstravs(ji,jj,jk+1) /( fse3t(ji,jj,jk) * fse3w(ji,jj,jk+1) )
+               zwd(ji,jj,jk) = 1. - zwi(ji,jj,jk) - zws(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1        
+         DO ji = fs_2, fs_jpim1
+            zwi(ji,jj,1) = 0.e0
+            zwd(ji,jj,1) = 1. - zws(ji,jj,1) 
+         END DO
+      END DO
+
+      !                                                       ! ===========
+      DO jn = 1, jptra                                        ! tracer loop
+         !                                                    ! ===========
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)         ! ??? validation needed
+
+	 zwt( 1 ,:,:) = 0.e0     ;     zwt(jpi,:,:) = 0.e0     
+         zwt(  :,:,1) = 0.e0     ;     zwt(  :,:,jpk) = 0.e0
+         
+         ! Second member construction
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1     
+               DO ji = fs_2, fs_jpim1
+                  zwy(ji,jj,jk) = trb(ji,jj,jk,jn) + rdttrc(jk) * tra(ji,jj,jk,jn)
+               END DO
+            END DO
+         END DO
+         
+         
+         ! Matrix inversion from the first level
+         !----------------------------------------------------------------------
+         !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+         !
+         !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+         !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+         !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+         !        (        ...               )( ...  ) ( ...  )
+         !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+         !
+         !   m is decomposed in the product of an upper and lower triangular matrix
+         !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+         !   The second member is in 2d array zwy
+         !   The solution is in 2d array zwx
+         !   The 3d arry zwt is a work space array
+         !   zwy is used and then used as a work space array : its value is modified!
+         !
+         !   N.B. the starting vertical index (ikst) is equal to 1 except for
+         !   the resolution of tke matrix where surface tke value is prescribed
+         !   so that ikstrt=2.
+        ikst = 1
+        ikstp1 = ikst + 1
+        ikenm2 = jpk - 2
+        
+        DO jj = 2, jpjm1
+           DO ji = fs_2, fs_jpim1
+              zwt(ji,jj,ikst) = zwd(ji,jj,ikst)
+           END DO
+        END DO
+        
+        DO jk = ikstp1, jpkm1
+           DO jj = 2, jpjm1
+              DO ji = fs_2, fs_jpim1
+                 zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwt(ji,jj,jk-1)
+              END DO
+           END DO
+        END DO
+        
+        DO jk = ikstp1, jpkm1
+           DO jj = 2, jpjm1
+              DO ji = fs_2, fs_jpim1
+                 zwy(ji,jj,jk) = zwy(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * zwy(ji,jj,jk-1)
+              END DO
+           END DO
+        END DO
+        
+        DO jj = 2, jpjm1
+           DO ji = fs_2, fs_jpim1
+              zwx(ji,jj,jpkm1) = zwy(ji,jj,jpkm1) / zwt(ji,jj,jpkm1)
+           END DO
+        END DO
+        
+        DO jk = ikenm2, ikst, -1
+           DO jj = 2, jpjm1
+              DO ji = fs_2, fs_jpim1
+                 zwx(ji,jj,jk) = ( zwy(ji,jj,jk) - zws(ji,jj,jk) * zwx(ji,jj,jk+1) ) / zwt(ji,jj,jk)
+              END DO
+           END DO
+        END DO
+
+#if defined key_trc_diatrd
+         ! Compute and save the vertical diffusive of tracers trends
+#  if defined key_trcldf_iso
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztra = ( zwx(ji,jj,jk) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztra - tra(ji,jj,jk,jn) + trtrd(ji,jj,jk,ikeep(jn),6)
+               END DO
+            END DO
+         END DO
+#  else
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztra = ( zwx(ji,jj,jk) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztra - tra(ji,jj,jk,jn)
+               END DO
+            END DO
+         END DO
+#  endif
+#endif
+
+         ! Save the masked passive tracer after in tra
+         ! (c a u t i o n:  tracer not its trend, Leap-frog scheme done
+         !                  it will not be done in tranxt)
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  tra(ji,jj,jk,jn) = zwx(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         IF( l_trdtrc ) THEN                            ! trends
+            DO jk = 1, jpkm1
+               ztrtrd(:,:,jk) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / rdttrc(jk) ) - ztrtrd(:,:,jk)
+            END DO
+            IF (luttrd(jn)) CALL trd_mod_trc(ztrtrd, jn, jptrc_trd_zdf, kt)
+         END IF
+
+         IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+            ztrd(:,:,:,:) = 0.
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztrd(ji,jj,jk,jn) = ( zwx(ji,jj,jk) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - imp')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=ztrd, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_zdf_imp
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                      NO passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_zdf_imp (kt )              ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_zdf_imp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_zdf_imp
+#endif
+   
+!!==============================================================================
+END MODULE trczdf_imp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso.F90	(revision 1844)
@@ -0,0 +1,527 @@
+MODULE trczdf_iso
+   !!==============================================================================
+   !!                    ***  MODULE  trczdf_iso  ***
+   !! Ocean passive tracers:  vertical component of the tracer mixing trend
+   !!==============================================================================
+   !! History :  7.0  !  91-11  (G. Madec)  Original code
+   !!                 !  92-06  (M. Imbard)  correction on tracer trend loops
+   !!                 !  96-01  (G. Madec)  statement function for e3
+   !!                 !  97-05  (G. Madec)  vertical component of isopycnal
+   !!                 !  97-07  (G. Madec)  geopotential diffusion in s-coord
+   !!                 !  98-03  (L. Bopp MA Foujols) passive tracer generalisation
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-06  (O Aumont)  correct isopycnal scheme suppress
+   !!                 !                     avt multiple correction
+   !!                 !  00-08  (G. Madec)  double diffusive mixing
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe )  adapted for passive tracers
+   !!----------------------------------------------------------------------
+#if defined key_top  &&  ( defined key_ldfslp   ||   defined key_esopa )
+   !!----------------------------------------------------------------------
+   !!   'key_top'       and                                      TOP models
+   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   trc_zdf_iso  : update the tracer trend with the vertical part of 
+   !!                  the isopycnal or geopotential s-coord. operator and
+   !!                  the vertical diffusion
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc          ! ocean dynamics and tracers variables
+   USE trp_trc              ! ocean passive tracers variables 
+   USE lbclnk           ! ocean lateral boundary conditions (or mpp link)
+   USE trctrp_lec       ! passive tracers transport
+   USE trdmld_trc
+   USE trdmld_trc_oce
+   USE prtctl_trc          ! Print control for debbuging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC trc_zdf_iso    ! routine called by step.F90
+
+   !! * Module variable
+   REAL(wp), DIMENSION(jpk) ::   &
+      rdttrc                     ! vertical profile of 2 x tracer time-step
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_zdf_iso( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_iso  ***
+      !!
+      !! ** Purpose :
+      !!     Compute the trend due to the vertical tracer diffusion inclu-
+      !!     ding the vertical component of lateral mixing (only for second
+      !!     order operator, for fourth order it is already computed and
+      !!     add to the general trend in trcldf.F) and add it to the general
+      !!     trend of the tracer equations.
+      !!
+      !! ** Method :
+      !!         The vertical component of the lateral diffusive trends is
+      !!      provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      First part: vertical trends associated with the lateral mixing
+      !!      ==========  (excluding the vertical flux proportional to dk[t] )
+      !!      vertical fluxes associated with the rotated lateral mixing:
+      !!         zftw =-aht {  e2t*wslpi di[ mi(mk(trb)) ]
+      !!                     + e1t*wslpj dj[ mj(mk(trb)) ]  }
+      !!      save avt coef. resulting from vertical physics alone in zavt:
+      !!         zavt = avt
+      !!      update and save in zavt the vertical eddy viscosity coefficient:
+      !!         avt = avt + wslpi^2+wslj^2
+      !!      add vertical Eddy Induced advective fluxes ('lk_trcldf_eiv=T):
+      !!         zftw = zftw + { di[aht e2u mi(wslpi)]
+      !!                    +dj[aht e1v mj(wslpj)] } mk(trb)
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) dk[ zftw ] 
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + difft
+      !!
+      !!      Second part: vertical trend associated with the vertical physics
+      !!      ===========  (including the vertical flux proportional to dk[t]
+      !!                  associated with the lateral mixing, through the
+      !!                  update of avt)
+      !!      The vertical diffusion of tracers tra  is given by:
+      !!             difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(t) )
+      !!      It is computed using a backward time scheme, t=ta.
+      !!      Surface and bottom boundary conditions: no diffusive flux on
+      !!      both tracers (bottom, applied through the masked field avt).
+      !!      Add this trend to the general trend tra  :
+      !!         tra = tra + dz( avt dz(t) )
+      !!         (tra = tra + dz( avs dz(t) ) if lk_trc_zdfddm=T )
+      !!
+      !!      Third part: recover avt resulting from the vertical physics
+      !!      ==========  alone, for further diagnostics (for example to
+      !!                  compute the turbocline depth in diamld).
+      !!         avt = zavt
+      !!         (avs = zavs if lk_trc_zdfddm=T )
+      !!
+      !!      'key_trdmld_trc' defined: trend saved for futher diagnostics.
+      !!
+      !!      macro-tasked on vertical slab (jj-loop)
+      !!
+      !! ** Action :
+      !!         Update tra arrays with the before vertical diffusion trend
+      !!         Save in trtrd arrays the trends if 'key_trdmld_trc' defined
+      !!---------------------------------------------------------------------
+      !! * Modules used
+      USE oce , ONLY :    zavs => va, ztrtrd => ua
+
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
+
+      !! * Local declarations
+      INTEGER ::   ji, jj, jk, jn                 ! dummy loop indices
+      INTEGER ::   ikst, ikenm2, ikstp1       ! temporary integers
+      INTEGER ::   iku, ikv, ikv1             ! temporary integers
+
+      REAL(wp) ::   &
+         ztavg,                 &  ! ???
+         zcoef0, zcoef3,        &  ! ???
+         zcoef4, zavi,          &  ! ???
+         zbtr, zmku, zmkv,      &  !
+         ztav
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         zwd, zws, zwi,         &  ! ???
+         zwx, zwy, zwz, zwt        ! ???
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         ztfw, zdit, zdjt, zdj1t
+#if defined key_trcldf_eiv   ||   defined key_esopa
+      REAL(wp), DIMENSION(jpi,jpk) ::   &
+         ztfwg
+
+      REAL(wp) ::         &
+         zcoeg3,          &
+         zuwk, zvwk,      &
+         zuwki, zvwki, z_hdivn_z
+#endif
+      CHARACTER (len=22) :: charout
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  ztrtrd_tmp
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'trc_zdf_iso : vertical mixing (including isopycnal component)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+#if defined key_trcldf_eiv && defined key_diaeiv
+         w_trc_eiv(:,:,:) = 0.e0
+#endif
+      ENDIF
+
+
+      ! 0.0  Local constant initialization
+      ! --------------------------------
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN
+         ! time step = 2 rdttra with Arakawa or TVD advection scheme
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+            rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)             ! restarting with Euler time stepping
+         ELSEIF( kt <= nittrc000 + ndttrc ) THEN
+            rdttrc(:) = 2. * rdttra(:) * FLOAT(ndttrc)         ! leapfrog
+         ENDIF
+      ELSE
+         rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)      
+      ENDIF
+
+
+
+      ! 0.1 Save avs in zavs to recover avs in output files
+      !---------------------------------------------------
+      zavs(:,:,:) = fstravs(:,:,:)
+
+
+      ! 0.2 Update and save of avt (and avs if double diffusive mixing)
+      ! ---------------------------
+
+     DO jj = 2, jpjm1                                 !  Vertical slab
+        !                                             ! ===============
+         DO jk = 2, jpkm1
+            DO ji = 2, jpim1
+               zavi = fsahtw(ji,jj,jk)*( wslpi(ji,jj,jk)*wslpi(ji,jj,jk)   &
+                  &                     +wslpj(ji,jj,jk)*wslpj(ji,jj,jk) )
+               ! add isopycnal vertical coeff. to avs
+               fstravs(ji,jj,jk) = fstravs(ji,jj,jk) + zavi
+            END DO
+         END DO
+       !
+     END DO
+
+
+
+     DO jn = 1, jptra
+
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)          ! save trends
+
+         ztavg = 0.e0
+
+         !                                                ! ===============
+         DO jj = 2, jpjm1                                 !  Vertical slab
+            !                                             ! ===============
+
+            ! I. vertical trends associated with the lateral mixing
+            ! =====================================================
+            !  (excluding the vertical flux proportional to dk[t]
+
+
+            ! I.1 horizontal tracer gradient
+            ! ------------------------------
+
+            DO jk = 1, jpkm1
+               DO ji = 1, jpim1
+                  ! i-gradient of passive tracer at jj
+                  zdit (ji,jk) = ( trb(ji+1,jj,jk,jn)-trb(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                  ! j-gradient of passive tracer at jj
+                  zdjt (ji,jk) = ( trb(ji,jj+1,jk,jn)-trb(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+                  ! j-gradient of passive tracer at jj+1
+                  zdj1t(ji,jk) = ( trb(ji,jj,jk,jn)-trb(ji,jj-1,jk,jn) ) * vmask(ji,jj-1,jk)
+               END DO
+            END DO
+
+            IF( ln_zps ) THEN
+               ! partial steps correction at the bottom ocean level 
+               DO ji = 1, jpim1
+                  ! last ocean level
+                  iku  = MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+                  ikv  = MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+                  ikv1 = MIN( mbathy(ji,jj), mbathy(ji  ,jj-1) ) - 1
+                  ! i-gradient of of passive tracer at jj
+                  zdit (ji,iku) = gtru(ji,jj,jn)
+                  ! j-gradient of of passive tracer at jj
+                  zdjt (ji,ikv) = gtrv(ji,jj,jn) 
+                  ! j-gradient of of passive tracer at jj+1
+                  zdj1t(ji,ikv1)= gtrv(ji,jj-1,jn)
+               END DO
+            ENDIF
+
+            ! I.2 Vertical fluxes
+            ! -------------------
+
+            ! Surface and bottom vertical fluxes set to zero
+            ztfw(:, 1 ) = 0.e0
+            ztfw(:,jpk) = 0.e0
+
+#if defined key_trcldf_eiv
+            ztfwg(:, 1 ) = 0.e0
+            ztfwg(:,jpk) = 0.e0
+#endif
+
+            ! interior (2=<jk=<jpk-1)
+            DO jk = 2, jpkm1
+               DO ji = 2, jpim1
+                  zcoef0 = - fsahtw(ji,jj,jk) * tmask(ji,jj,jk)
+
+                  zmku = 1./MAX( umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)   &
+                     &          +umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk), 1. )
+
+                  zmkv = 1./MAX( vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)   &
+                     &          +vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk), 1. )
+
+                  zcoef3 = zcoef0 * e2t(ji,jj) * zmku * wslpi (ji,jj,jk)
+                  zcoef4 = zcoef0 * e1t(ji,jj) * zmkv * wslpj (ji,jj,jk)
+
+                  ztfw(ji,jk) = zcoef3 * ( zdit (ji  ,jk-1) + zdit (ji-1,jk)     &
+                     &                    +zdit (ji-1,jk-1) + zdit (ji  ,jk) )   &
+                     &        + zcoef4 * ( zdjt (ji  ,jk-1) + zdj1t(ji  ,jk)     &
+                     &                    +zdj1t(ji  ,jk-1) + zdjt (ji  ,jk) )
+
+               END DO
+            END DO
+
+
+#if defined key_trcldf_eiv
+            !                              ! ---------------------------------------!
+            !                              ! Eddy induced vertical advective fluxes !
+            !                              ! ---------------------------------------!
+#if defined key_traldf_c2d || defined key_traldf_c3d || defined key_off_degrad
+            DO jk = 2, jpkm1
+               DO ji = 2, jpim1
+                  zuwki = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) )   &
+                     &  * fsaeitru(ji-1,jj,jk) * e2u(ji-1,jj)*umask(ji-1,jj,jk)
+                  zuwk  = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) )   &
+                     &  * fsaeitru(ji  ,jj,jk) * e2u(ji  ,jj)*umask(ji  ,jj,jk)
+                  zvwki = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) )   &
+                     &  * fsaeitrv(ji,jj-1,jk) * e1v(ji,jj-1)*vmask(ji,jj-1,jk)
+                  zvwk  = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) )   &
+                     &  * fsaeitrv(ji,jj  ,jk) * e1v(ji  ,jj)*vmask(ji  ,jj,jk)
+
+                  zcoeg3 = + 0.25 * tmask(ji,jj,jk) * ( zuwk - zuwki + zvwk - zvwki )
+
+                  ztfwg(ji,jk) = + zcoeg3 * ( trb(ji,jj,jk,jn) + trb(ji,jj,jk-1,jn) ) 
+                  ztfw(ji,jk) = ztfw(ji,jk) + ztfwg(ji,jk)
+
+# if defined key_diaeiv
+                  w_trc_eiv(ji,jj,jk) = -2. *  zcoeg3 / ( e1t(ji,jj)*e2t(ji,jj) )
+# endif
+               END DO
+            END DO
+
+#else
+            DO jk = 2, jpkm1
+               DO ji = 2, jpim1
+                  zuwki = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) )   &
+                     &  * e2u(ji-1,jj)*umask(ji-1,jj,jk)
+                  zuwk  = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) )   &
+                     &  * e2u(ji  ,jj)*umask(ji  ,jj,jk)
+                  zvwki = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) )   &
+                     &  * e1v(ji,jj-1)*vmask(ji,jj-1,jk)
+                  zvwk  = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) )   &
+                     &  * e1v(ji  ,jj)*vmask(ji  ,jj,jk)
+
+                  zcoeg3 = + 0.25 * tmask(ji,jj,jk) * fsaeitrw(ji,jj,jk)   &
+                     &            * ( zuwk - zuwki + zvwk - zvwki )
+
+                  ztfwg(ji,jk) = + zcoeg3 * ( trb(ji,jj,jk,jn) + trb(ji,jj,jk-1,jn) )
+                  ztfw(ji,jk) = ztfw(ji,jk) + ztfwg(ji,jk)
+
+# if defined key_diaeiv
+                  w_trc_eiv(ji,jj,jk) = -2. *  zcoeg3 / ( e1t(ji,jj)*e2t(ji,jj) )
+# endif
+               END DO
+            END DO
+#endif
+
+#endif
+
+
+            ! I.5 Divergence of vertical fluxes added to the general tracer trend
+            ! -------------------------------------------------------------------
+
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  zbtr =  1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ztav = (  ztfw(ji,jk) - ztfw(ji,jk+1)  ) * zbtr
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztav
+#if defined key_trc_diatrd
+#   if defined key_trcldf_eiv
+                  ztavg = ( ztfwg(ji,jk) - ztfwg(ji,jk+1) ) * zbtr
+                  !  WARNING trtrd(ji,jj,jk,6) used for vertical gent velocity trend
+                  !                           not for damping !!!
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztavg
+#   endif
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztav - ztavg
+#endif
+
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+         ! II. Save the trends for diagnostics
+         ! ===================================
+         IF( l_trdtrc ) THEN
+#   if defined key_trcldf_eiv
+
+            ! II.1) Compute the eiv VERTICAL trend
+            DO jj = 2, jpjm1
+               DO jk = 1, jpkm1
+                  DO ji = 2, jpim1
+
+                     !-- Compute the eiv vertical divergence : 1/e3t ( dk[w_eiv] )
+                     !   N.B. This is only possible if key_diaeiv is switched on.
+                     !     Else, the vertical eiv is not diagnosed,
+                     !     so we can only store the flux form trend d_z ( T * w_eiv )
+                     !     instead of w_eiv * d_z( T ). Then, ONLY THE SUM of zonal,
+                     !     meridional, and vertical trends are valid.
+#       if defined key_diaeiv
+                     z_hdivn_z = ( 1. / fse3t(ji,jj,jk) ) * ( w_trc_eiv(ji,jj,jk) - w_trc_eiv(ji,jj,jk+1) )
+#       else
+                     z_hdivn_z = 0.e0
+#       endif
+                     !-- Compute the vertical advective trend associated with eiv
+                     zbtr =  1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                     ztrtrd_tmp(ji,jj,jk) = (  ztfwg(ji,jk) - ztfwg(ji,jk+1)  ) * zbtr   &
+                          &                 - trn(ji,jj,jk,jn) * z_hdivn_z
+                  END DO
+               END DO
+            END DO
+
+            ! II.2) Save the vertical eiv trend
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd_tmp, jn, jptrc_trd_zei, kt )
+
+#   endif
+
+            !-- Remove vert. eiv from the current up-to-date trend
+            !   N.B. ztrtrd_tmp is recycled for this purpose
+            ztrtrd_tmp(:,:,:) = ( tra(:,:,:,jn) - ztrtrd(:,:,:) ) - ztrtrd_tmp(:,:,:)
+
+            ! Save the new trends
+            ztrtrd(:,:,:) = tra(:,:,:,jn)
+         END IF
+
+
+      END DO
+
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - 1')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+      DO jn = 1, jptra
+         !                                                ! ===============
+         DO jj = 2, jpjm1                                 !  Vertical slab
+            !                                             ! ===============
+
+            ! II. Vertical trend associated with the vertical physics
+            ! =======================================================
+            !     (including the vertical flux proportional to dk[t] associated
+            !      with the lateral mixing, through the avt update)
+            !     dk[ avt dk[ (t,s) ] ] diffusive trends
+
+
+            ! Diagonal, inferior, superior
+            ! (including the bottom boundary condition via avs masked)
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  zwi(ji,jk) = - rdttrc(jk) * fstravs(ji,jj,jk  )   &
+                     /( fse3t(ji,jj,jk) * fse3w(ji,jj,jk  ) )
+                  zws(ji,jk) = - rdttrc(jk) * fstravs(ji,jj,jk+1)   &
+                     /( fse3t(ji,jj,jk) * fse3w(ji,jj,jk+1) )
+                  zwd(ji,jk) = 1. - zwi(ji,jk) - zws(ji,jk)
+               END DO
+            END DO
+
+            ! Surface boudary conditions
+            DO ji = 2, jpim1
+               zwi(ji,1) = 0.e0
+               zwd(ji,1) = 1. - zws(ji,1)
+            END DO
+
+            ! Second member construction
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  zwy(ji,jk) = trb(ji,jj,jk,jn) + rdttrc(jk) * tra(ji,jj,jk,jn)
+               END DO
+            END DO
+
+            ! Matrix inversion from the first level
+            ikst = 1
+#   include "zdf.matrixsolver.h90"
+#if defined key_trc_diatrd
+            ! Compute and save the vertical diffusive of tracers trends
+#  if defined key_trcldf_iso
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ztav = ( zwx(ji,jk) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztav - tra(ji,jj,jk,jn) + trtrd(ji,jj,jk,ikeep(jn),6)
+               END DO
+            END DO
+#  else
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  ztav = ( zwx(ji,jk) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztav - tra(ji,jj,jk,jn)
+               END DO
+            END DO
+#  endif
+#endif
+            ! Compute and save the vertical diffusive of tracers trends
+            ! Save the masked passive tracer after in tra
+            ! (c a u t i o n:  tracer not its trend, Leap-frog scheme done
+            !                  it will not be done in tranxt)
+            DO jk = 1, jpkm1
+               DO ji = 2, jpim1
+                  tra(ji,jj,jk,jn) = zwx(ji,jk)  * tmask(ji,jj,jk)
+               END DO
+            END DO
+            !                                             ! ===============
+         END DO                                           !   End of slab
+         !                                                ! ===============
+
+         ! IV. Save the trends for diagnostics
+         ! ===================================
+         IF( l_trdtrc ) THEN
+            ! deduce the full vertical diff. trend (except for vertical eiv advection)
+#if defined key_trcldf_iso
+            DO jk = 1, jpkm1
+               ztrtrd(:,:,jk) = ( (tra(:,:,jk,jn) - trb(:,:,jk,jn))/rdttrc(jk) ) - ztrtrd(:,:,jk) + ztrtrd_tmp(:,:,jk)
+            END DO
+#else
+            DO jk = 1, jpkm1
+               ztrtrd(:,:,jk) = ( (tra(:,:,jk,jn) - trb(:,:,jk,jn))/rdttrc(jk) ) - ztrtrd(:,:,jk)
+            END DO
+#endif
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_zdf, kt )
+
+         END IF
+
+      END DO
+
+
+
+      ! III. recover the avt (avs) resulting from vertical physics only
+      !---------------------------------------------------------------
+      fstravs(:,:,:) = zavs(:,:,:)
+
+      
+      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - 2')")
+         CALL prt_ctl_trc_info(charout)
+         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
+      ENDIF
+
+   END SUBROUTINE trc_zdf_iso
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module               NO rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_zdf_iso( kt )              ! empty routine
+      WRITE(*,*) 'trc_zdf_iso: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_zdf_iso
+#endif
+
+   !!==============================================================================
+END MODULE trczdf_iso
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90	(revision 1844)
@@ -0,0 +1,638 @@
+MODULE trczdf_iso_vopt
+   !!======================================================================
+   !!                 ***  MODULE  trczdf_iso_vopt  ***
+   !! Ocean passive tracers:  vertical component of the tracer mixing trend
+   !!======================================================================
+   !! History :  6.0  !  90-10 (B. Blanke)  Original code
+   !!            7.0  !  91-11 (G. Madec)
+   !!                 !  92-06 (M. Imbard) correction on tracer trend loops
+   !!                 !  96-01 (G. Madec) statement function for e3
+   !!                 !  97-05 (G. Madec) vertical component of isopycnal
+   !!                 !  97-07 (G. Madec) geopotential diffusion in s-coord
+   !!                 !  98-03  (L. Bopp MA Foujols) passive tracer generalisation
+   !!                 !  00-05  (MA Foujols) add lbc for tracer trends
+   !!                 !  00-06  (O Aumont)  correct isopycnal scheme suppress
+   !!                 !                     avt multiple correction
+   !!                 !  00-08  (G. Madec)  double diffusive mixing
+   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !!            9.0  !  04-03  (C. Ethe )  adapted for passive tracers
+   !!                 !  06-08  (C. Deltel) Diagnose ML trends for passive tracer
+   !!----------------------------------------------------------------------
+#if defined key_top && ( defined key_ldfslp   ||   defined key_esopa )
+   !!----------------------------------------------------------------------
+   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+   !!   trc_zdf_iso_vopt : Update the tracer trend with the vertical part of 
+   !!                  the isopycnal or geopotential s-coord. operator and
+   !!                  the vertical diffusion. vector optimization, use
+   !!                  k-j-i loops.
+   !!   trc_zdf_iso  :
+   !!   trc_zdf_zdf  :
+   !!----------------------------------------------------------------------
+   USE oce_trc               ! ocean dynamics and tracers variables
+   USE trp_trc                   ! ocean passive tracers variables 
+   USE lbclnk                ! ocean lateral boundary conditions (or mpp link)
+   USE trctrp_lec
+   USE prtctl_trc            ! Print control for debbuging
+   USE trdmld_trc
+   USE trdmld_trc_oce     
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_zdf_iso_vopt   !  routine called by step.F90
+
+   REAL(wp), DIMENSION(jpk) ::   rdttrc                    ! vertical profile of 2 x time-step
+   REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrcavg  ! workspace arrays
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90,v 1.11 2007/02/21 12:55:33 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+   
+   SUBROUTINE trc_zdf_iso_vopt( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_iso_vopt  ***
+      !!
+      !! ** Purpose :
+      !! ** Method  :
+      !! ** Action  :
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      CHARACTER (len=22) :: charout
+      !!---------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) 'trc_zdf_iso_vopt : vertical mixing computation'
+         IF(lwp)WRITE(numout,*) '~~~~~~~~~~~~~~~~   is  iso-neutral diffusion : implicit vertical time stepping'
+#if defined key_trcldf_eiv && defined key_diaeiv 
+         w_trc_eiv(:,:,:) = 0.e0
+#endif
+      ENDIF
+
+      IF( l_trdtrc ) THEN
+         ALLOCATE( ztrcavg(jpi,jpj,jpk,jptra) )
+         ztrcavg(:,:,:,:) = 0.e0          ! initialisation step
+      ENDIF
+
+      ! I. vertical extra-diagonal part of the rotated tensor
+      ! -----------------------------------------------------
+
+      CALL trc_zdf_iso( kt )
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - 1')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      ENDIF
+
+      ! II. vertical diffusion (including the vertical diagonal part of the rotated tensor)
+      ! ----------------------
+
+      CALL trc_zdf_zdf( kt )
+
+      IF( ln_ctl ) THEN    ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('zdf - 2')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      ENDIF
+
+      IF( l_trdtrc ) DEALLOCATE( ztrcavg )
+
+   END SUBROUTINE trc_zdf_iso_vopt
+
+
+   SUBROUTINE trc_zdf_zdf( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE trc_zdf_zdf  ***
+      !!                    
+      !! ** Purpose :   Compute the trend due to the vertical tracer diffusion
+      !!     including the vertical component of lateral mixing (only for 2nd
+      !!     order operator, for fourth order it is already computed and add
+      !!     to the general trend in traldf.F) and add it to the general trend
+      !!     of the tracer equations.
+      !!
+      !! ** Method  :   The vertical component of the lateral diffusive trends
+      !!      is provided by a 2nd order operator rotated along neural or geo-
+      !!      potential surfaces to which an eddy induced advection can be 
+      !!      added. It is computed using before fields (forward in time) and 
+      !!      isopycnal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      Second part: vertical trend associated with the vertical physics
+      !!      ===========  (including the vertical flux proportional to dk[t]
+      !!                  associated with the lateral mixing, through the
+      !!                  update of avt)
+      !!      The vertical diffusion of tracers  is given by:
+      !!             difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(t) )
+      !!      It is computed using a backward time scheme (t=tra).
+      !!      Surface and bottom boundary conditions: no diffusive flux on
+      !!      both tracers (bottom, applied through the masked field avt).
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + dz( avt dz(t) )
+      !!         (tra = tra + dz( avs dz(t) ) if lk_trc_zdfddm=T )
+      !!
+      !!      Third part: recover avt resulting from the vertical physics
+      !!      ==========  alone, for further diagnostics (for example to
+      !!                  compute the turbocline depth in diamld).
+      !!         avt = zavt
+      !!         (avs = zavs if lk_trc_zdfddm=T )
+      !!
+      !!      'key_trdtra' defined: trend saved for futher diagnostics.
+      !!
+      !!      macro-tasked on vertical slab (jj-loop)
+      !!
+      !! ** Action  : - Update tra with before vertical diffusion trend
+      !!              - Save the trend in trtrd  ('key_trdmld_trc')
+      !!---------------------------------------------------------------------
+      USE oce, ONLY :       zwd   => ua,  &  ! ua, va used as
+                            zws   => va      ! workspace
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
+      INTEGER  ::   ji, jj, jk, jn            ! dummy loop indices
+      REAL(wp) ::   zavi, zrhs               ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
+         zwi, zwt, zavsi                     ! temporary workspace arrays
+#  if defined key_trc_diatrd
+      REAL(wp) ::   ztra
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrd
+#  endif
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+      !!---------------------------------------------------------------------
+
+
+      ! I. Local constant initialization
+      ! --------------------------------
+      ! ... time step = 2 rdttra ex
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN
+         ! time step = 2 rdttra with Arakawa or TVD advection scheme
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN
+            rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)             ! restarting with Euler time stepping
+         ELSEIF( kt <= nittrc000 + ndttrc ) THEN
+            rdttrc(:) = 2. * rdttra(:) * FLOAT(ndttrc)         ! leapfrog
+         ENDIF
+      ELSE
+         rdttrc(:) =  rdttra(:) * FLOAT(ndttrc)      
+      ENDIF
+
+         
+      zwd  ( 1, :, : ) = 0.e0    ;     zwd  ( jpi, :,   : ) = 0.e0
+      zws  ( 1, :, : ) = 0.e0    ;     zws  ( jpi, :,   : ) = 0.e0
+      zwi  ( 1, :, : ) = 0.e0    ;     zwi  ( jpi, :,   : ) = 0.e0
+      zwt  ( 1, :, : ) = 0.e0    ;     zwt  ( jpi, :,   : ) = 0.e0
+      zwt  ( :, :, 1 ) = 0.e0    ;     zwt  (   :, :, jpk ) = 0.e0
+      zavsi( 1, :, : ) = 0.e0    ;     zavsi( jpi, :,   : ) = 0.e0 
+      zavsi( :, :, 1 ) = 0.e0    ;     zavsi(   :, :, jpk ) = 0.e0
+
+
+      ! II. Vertical trend associated with the vertical physics
+      !=======================================================
+      !     (including the vertical flux proportional to dk[t] associated
+      !      with the lateral mixing, through the avt update)
+      !     dk[ avt dk[ (t,s) ] ] diffusive trends
+
+      ! II.0 Matrix construction
+      ! ------------------------        
+      ! update and save of avt (and avs if double diffusive mixing)
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zavi = fsahtw(ji,jj,jk) * (                 &   ! vertical mixing coef. due to lateral mixing
+                  &                           wslpi(ji,jj,jk) * wslpi(ji,jj,jk)      &
+                  &                         + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
+               zavsi(ji,jj,jk) = fstravs(ji,jj,jk) + zavi        ! dd mixing: zavsi = total vertical mixing coef. on tracer
+            END DO
+         END DO
+      END DO
+
+      ! II.1 Vertical diffusion on tracer
+      ! ---------------------------------
+      ! Rebuild the Matrix as avt /= avs
+
+      ! Diagonal, inferior, superior  (including the bottom boundary condition via avs masked)
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwi(ji,jj,jk) = - rdttrc(jk) * zavsi(ji,jj,jk  ) / ( fse3t(ji,jj,jk) * fse3w(ji,jj,jk  ) )
+               zws(ji,jj,jk) = - rdttrc(jk) * zavsi(ji,jj,jk+1) / ( fse3t(ji,jj,jk) * fse3w(ji,jj,jk+1) )
+               zwd(ji,jj,jk) = 1. - zwi(ji,jj,jk) - zws(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Surface boudary conditions
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zwi(ji,jj,1) = 0.e0
+            zwd(ji,jj,1) = 1. - zws(ji,jj,1)
+         END DO
+      END DO
+
+      !! Matrix inversion from the first level
+      !!----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and lower triangular
+      !   matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The second member is in 2d array zwy
+      !   The solution is in 2d array zwx
+      !   The 3d arry zwt is a work space array
+      !   zwy is used and then used as a work space array : its value is modified!
+
+      ! first recurrence:   Tk = Dk - Ik Sk-1 / Tk-1   (increasing k)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,1) = zwd(ji,jj,1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1)/zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+         
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)          ! save trends
+
+#  if defined key_trc_diatrd
+         ! save the tra trend
+         ztrd(:,:,:) = tra(:,:,:,jn)
+#  endif
+
+         ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               tra(ji,jj,1,jn) = trb(ji,jj,1,jn) + rdttrc(1) * tra(ji,jj,1,jn)
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  zrhs = trb(ji,jj,jk,jn) + rdttrc(jk) * tra(ji,jj,jk,jn)   ! zrhs=right hand side
+                  tra(ji,jj,jk,jn) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * tra(ji,jj,jk-1,jn)
+               END DO
+            END DO
+         END DO
+
+         ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk
+         ! Save the masked passive tracer after in tra
+         ! (c a u t i o n: passive tracer not its trend, Leap-frog scheme done it will not be done in tranxt)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               tra(ji,jj,jpkm1,jn) = tra(ji,jj,jpkm1,jn) / zwt(ji,jj,jpkm1) * tmask(ji,jj,jpkm1)
+            END DO
+         END DO
+         DO jk = jpk-2, 1, -1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  tra(ji,jj,jk,jn) = ( tra(ji,jj,jk,jn) - zws(ji,jj,jk) * tra(ji,jj,jk+1,jn) ) / zwt(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+#if defined key_trc_diatrd
+         ! Compute and save the vertical diffusive passive tracer trends
+#  if defined key_trcldf_iso
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztra = ( tra(ji,jj,jk,jn) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztra - ztrd(ji,jj,jk) + trtrd(ji,jj,jk,ikeep(jn),6)
+               END DO
+            END DO
+         END DO
+#  else
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ztra = ( tra(ji,jj,jk,jn) - trb(ji,jj,jk,jn) ) / rdttrc(jk)
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztra - ztrd(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+#  endif
+#endif
+
+
+         ! III. Save vertical trend assoc. with the vertical physics for diagnostics
+         ! =========================================================================
+         IF( l_trdtrc )   THEN
+
+            ! III.1) Deduce the full vertical diff. trend (except for vertical eiv advection)
+            ! N.B. tavg & savg contain the contribution from the extra diagonal part
+            !   of the rotated tensor (from trc_zdf_iso).
+            IF( ln_trcldf_iso ) THEN
+               DO jk = 1, jpkm1
+                  ztrtrd(:,:,jk) = ( (tra(:,:,jk,jn) - trb(:,:,jk,jn))/rdttrc(jk) ) - ztrtrd(:,:,jk)  &
+                       &           + ztrcavg(:,:,jk,jn) 
+               END DO
+            ELSE
+               DO jk = 1, jpkm1
+                  ztrtrd(:,:,jk) = ( (tra(:,:,jk,jn) - trb(:,:,jk,jn))/rdttrc(jk) ) - ztrtrd(:,:,jk)
+               END DO
+            ENDIF
+            
+            ! III.2) save the trends for diagnostic
+            ! N.B. However the purely vertical diffusion "K_z" (included here) will be deduced
+            !   and removed from this trend before storage. It is stored separately, so as to
+            !   clearly distinguish both contributions (see trd_mld)
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrtrd, jn, jptrc_trd_zdf, kt )
+
+         END IF
+         !                                                    ! ===========
+      END DO                                                  ! tracer loop
+      !                                                       ! ===========
+      
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+   END SUBROUTINE trc_zdf_zdf
+
+
+   SUBROUTINE trc_zdf_iso ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_zdf_iso  ***
+      !!
+      !! ** Purpose :
+      !!     Compute the trend due to the vertical tracer diffusion inclu-
+      !!     ding the vertical component of lateral mixing (only for second
+      !!     order operator, for fourth order it is already computed and
+      !!     add to the general trend in traldf.F) and add it to the general
+      !!     trend of the tracer equations.
+      !!
+      !! ** Method :
+      !!         The vertical component of the lateral diffusive trends is
+      !!      provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      First part: vertical trends associated with the lateral mixing
+      !!      ==========  (excluding the vertical flux proportional to dk[t] )
+      !!      vertical fluxes associated with the rotated lateral mixing:
+      !!         zftw =-aht {  e2t*wslpi di[ mi(mk(trb)) ]
+      !!                     + e1t*wslpj dj[ mj(mk(trb)) ]  }
+      !!      save avt coef. resulting from vertical physics alone in zavt:
+      !!         zavt = avt
+      !!      update and save in zavt the vertical eddy viscosity coefficient:
+      !!         avt = avt + wslpi^2+wslj^2
+      !!      add vertical Eddy Induced advective fluxes (lk_traldf_eiv=T):
+      !!         zftw = zftw + { di[aht e2u mi(wslpi)]
+      !!                    +dj[aht e1v mj(wslpj)] } mk(trb)
+      !!      take the horizontal divergence of the fluxes:
+      !!         difft = 1/(e1t*e2t*e3t) dk[ zftw ] 
+      !!      Add this trend to the general trend tra :
+      !!         tra = tra + difft
+      !!
+      !! ** Action :
+      !!         Update tra arrays with the before vertical diffusion trend
+      !!         Save in trtrd arrays the trends if 'key_trdmld_trc' defined
+      !!---------------------------------------------------------------------
+      USE oce, ONLY :   zwx => ua,  &  ! use ua, va as
+                        zwy => va      ! workspace arrays
+      INTEGER, INTENT(in) :: kt
+
+      INTEGER ::   ji, jj, jk, jn                ! dummy loop indices
+      INTEGER ::   iku, ikv                      
+      REAL(wp) ::   ztavg                        ! temporary scalars
+      REAL(wp) ::   zcoef0, zcoef3               !    "         "
+      REAL(wp) ::   zcoef4                       !    "         "
+      REAL(wp) ::   zbtr, zmku, zmkv             !    "         "
+#if defined key_trcldf_eiv                       
+      REAL(wp) ::   zcoeg3, z_hdivn_z            !    "         "
+      REAL(wp) ::   zuwki, zvwki                 !    "         "
+      REAL(wp) ::   zuwk, zvwk                   !    "         "
+#endif
+      REAL(wp) ::   ztav
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz  ! temporary workspace arrays
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwt
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztfw
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
+      !!---------------------------------------------------------------------
+
+
+      IF( l_trdtrc ) ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+
+      !                                                          ! ===========
+      DO jn = 1, jptra                                           ! tracer loop
+         !                                                       ! ===========
+
+         ! 0. Local constant initialization
+         ! --------------------------------
+         zwx (1,:,:) = 0.e0    ;     zwx (jpi,:,:) = 0.e0
+         zwy (1,:,:) = 0.e0    ;     zwy (jpi,:,:) = 0.e0
+         zwz (1,:,:) = 0.e0    ;     zwz (jpi,:,:) = 0.e0
+         zwt (1,:,:) = 0.e0    ;     zwt (jpi,:,:) = 0.e0
+         ztfw(1,:,:) = 0.e0    ;     ztfw(jpi,:,:) = 0.e0
+
+         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)          ! save trends
+
+         ztavg = 0.e0
+
+         ! I. Vertical trends associated with lateral mixing
+         ! -------------------------------------------------
+         !    (excluding the vertical flux proportional to dk[t] )
+
+         ! I.1 horizontal tracer gradient
+         ! ------------------------------
+
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ! i-gradient of passive tracer at ji
+                  zwx (ji,jj,jk) = ( trb(ji+1,jj,jk,jn)-trb(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                  ! j-gradient of passive tracer at jj
+                  zwy (ji,jj,jk) = ( trb(ji,jj+1,jk,jn)-trb(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( ln_zps ) THEN
+            ! partial steps correction at the bottom ocean level 
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ! last ocean level
+                  iku  = MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1
+                  ikv  = MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1
+                  ! i-gradient of passive tracer
+                  zwx (ji,jj,iku) = gtru(ji,jj,jn)
+                  ! j-gradient of passive tracer
+                  zwy (ji,jj,ikv) = gtrv(ji,jj,jn)  
+               END DO
+            END DO
+         ENDIF
+
+         ! I.2 Vertical fluxes
+         ! -------------------
+
+         ! Surface and bottom vertical fluxes set to zero
+         ztfw(:,:, 1 ) = 0.e0
+         ztfw(:,:,jpk) = 0.e0
+
+         ! interior (2=<jk=<jpk-1)
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zcoef0 = - fsahtw(ji,jj,jk) * tmask(ji,jj,jk)
+
+                  zmku = 1./MAX(   umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)      &
+                     &           + umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk), 1.  )
+
+                  zmkv = 1./MAX(   vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)      &
+                     &           + vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk), 1.  )
+
+                  zcoef3 = zcoef0 * e2t(ji,jj) * zmku * wslpi (ji,jj,jk)
+                  zcoef4 = zcoef0 * e1t(ji,jj) * zmkv * wslpj (ji,jj,jk)
+
+                  ztfw(ji,jj,jk) = zcoef3 * (   zwx(ji  ,jj  ,jk-1) + zwx(ji-1,jj  ,jk)      &
+                     &                        + zwx(ji-1,jj  ,jk-1) + zwx(ji  ,jj  ,jk)  )   &
+                     &           + zcoef4 * (   zwy(ji  ,jj  ,jk-1) + zwy(ji  ,jj-1,jk)      &
+                     &                        + zwy(ji  ,jj-1,jk-1) + zwy(ji  ,jj  ,jk)  )
+               END DO
+            END DO
+         END DO
+
+#if defined key_trcldf_eiv
+         !                              ! ---------------------------------------!
+         !                              ! Eddy induced vertical advective fluxes !
+         !                              ! ---------------------------------------!
+         zwx(:,:, 1 ) = 0.e0
+         zwx(:,:,jpk) = 0.e0
+
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+#   if defined key_traldf_c2d || defined key_traldf_c3d  || defined key_off_degrad
+                  zuwki = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) )   &
+                     &  * fsaeitru(ji-1,jj,jk) * e2u(ji-1,jj) * umask(ji-1,jj,jk)
+                  zuwk  = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) )   &
+                     &  * fsaeitru(ji  ,jj,jk) * e2u(ji  ,jj) * umask(ji  ,jj,jk)
+                  zvwki = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) )   &
+                     &  * fsaeitrv(ji,jj-1,jk) * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
+                  zvwk  = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) )   &
+                     &  * fsaeitrv(ji,jj  ,jk) * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
+
+                  zcoeg3 = + 0.25 * tmask(ji,jj,jk) * ( zuwk - zuwki + zvwk - zvwki )
+#   else
+                  zuwki = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) )   &
+                     &  * e2u(ji-1,jj) * umask(ji-1,jj,jk)
+                  zuwk  = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) )   &
+                     &  * e2u(ji  ,jj) * umask(ji  ,jj,jk)
+                  zvwki = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) )   &
+                     &  * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
+                  zvwk  = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) )   &
+                     &  * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
+
+                  zcoeg3 = + 0.25 * tmask(ji,jj,jk) * fsaeiw(ji,jj,jk)   &
+                     &            * ( zuwk - zuwki + zvwk - zvwki )
+#   endif
+                  zwx(ji,jj,jk) = + zcoeg3 * ( trb(ji,jj,jk,jn) + trb(ji,jj,jk-1,jn) )
+
+                  ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + zwx(ji,jj,jk)
+#   if defined key_diaeiv
+                  w_trc_eiv(ji,jj,jk) = -2. * zcoeg3 / ( e1t(ji,jj)*e2t(ji,jj) )
+#   endif
+               END DO
+            END DO
+         END DO
+#endif
+
+         ! I.3 Divergence of vertical fluxes added to the general tracer trend
+         ! -------------------------------------------------------------------
+
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zbtr =  1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                  ztav = (  ztfw(ji,jj,jk) - ztfw(ji,jj,jk+1)  ) * zbtr
+                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztav
+#if defined key_trc_diatrd
+#   if defined key_trcldf_eiv
+                  ztavg = ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) ) * zbtr
+                  !  WARNING trtrd(ji,jj,jk,7) used for vertical gent velocity trend  not for damping !!!
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),7) = ztavg
+#   endif
+                  IF (luttrd(jn)) trtrd(ji,jj,jk,ikeep(jn),6) = ztav - ztavg
+#endif
+
+               END DO
+            END DO
+         END DO
+
+         ! II. Save the trends for diagnostics
+         ! -----------------------------------
+         IF( l_trdtrc )   THEN
+#if defined key_trcldf_eiv
+
+            ! II.1) Compute the eiv VERTICAL trend
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     
+                     !-- Compute the eiv vertical divergence : 1/e3t ( dk[w_eiv] )
+                     !   N.B. This is only possible if key_diaeiv is switched on.
+                     !     Else, the vertical eiv is not diagnosed,
+                     !     so we can only store the flux form trend d_z ( T * w_eiv )
+                     !     instead of w_eiv * d_z( T ). Then, ONLY THE SUM of zonal,
+                     !     meridional, and vertical trends are valid.
+#   if defined key_diaeiv
+                     z_hdivn_z = ( 1. / fse3t(ji,jj,jk) ) * ( w_trc_eiv(ji,jj,jk) - w_trc_eiv(ji,jj,jk+1) )
+#   else
+                     z_hdivn_z = 0.e0
+#   endif
+                     zbtr =  1. / ( e1t(ji,jj)*e2t(ji,jj)*fse3t(ji,jj,jk) )
+                     ztrcavg(ji,jj,jk,jn) = ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) ) * zbtr &
+                           &                - trn(ji,jj,jk,jn) * z_hdivn_z
+                  END DO
+               END DO
+            END DO
+
+            ! II.2) save the trends for diagnostic
+            !       N.B. The other part of the computed trend is stored below for later
+            !         output (see trc_zdf_zdf)  
+            IF (luttrd(jn)) CALL trd_mod_trc( ztrcavg(:,:,:,jn), jn, jptrc_trd_zei, kt )
+
+#endif
+            !-- Retain only the vertical diff. trends due to the extra diagonal
+            !   part of the rotated tensor (i.e. remove vert. eiv from the trend)
+            !   N.B. ztrcavg is recycled for this purpose
+            ztrcavg(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:) - ztrcavg(:,:,:,jn)
+
+          END IF
+
+         !                                                       ! ===========
+      END DO                                                     ! tracer loop
+      !                                                          ! ===========
+
+      IF( l_trdtrc ) DEALLOCATE( ztrtrd )
+
+   END SUBROUTINE trc_zdf_iso
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :             NO rotation of the lateral mixing tensor
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_zdf_iso_vopt( kt )              ! empty routine
+      WRITE(*,*) 'trc_zdf_iso_vopt: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_zdf_iso_vopt
+#endif
+
+   !!==============================================================================
+END MODULE trczdf_iso_vopt
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 1844)
@@ -0,0 +1,1593 @@
+MODULE trdmld_trc
+   !!======================================================================
+   !!                       ***  MODULE  trdmld_trc  ***
+   !! Ocean diagnostics:  mixed layer passive tracer trends 
+   !!======================================================================
+   !! History :  9.0  !  06-08  (C. Deltel)  Original code (from trdmld.F90)
+   !!                 !  07-04  (C. Deltel)  Bug fix : add trcrad trends
+   !!                 !  07-06  (C. Deltel)  key_gyre : do not call lbc_lnk
+   !!----------------------------------------------------------------------
+#if   defined key_top && ( defined key_trdmld_trc   ||   defined key_esopa )
+   !!----------------------------------------------------------------------
+   !!   'key_trdmld_trc'                      mixed layer trend diagnostics
+   !!----------------------------------------------------------------------
+   !!   trd_mld_trc      : passive tracer cumulated trends averaged over ML
+   !!   trd_mld_trc_zint : passive tracer trends vertical integration
+   !!   trd_mld_trc_init : initialization step
+   !!----------------------------------------------------------------------
+   USE trp_trc           ! tracer definitions (trn, trb, tra, etc.)
+   USE oce_trc           ! needed for namelist logicals, and euphotic layer arrays
+   USE trctrp_lec
+   USE trdmld_trc_oce    ! definition of main arrays used for trends computations
+   USE in_out_manager    ! I/O manager
+   USE dianam            ! build the name of file (routine)
+   USE ldfslp            ! iso-neutral slopes 
+   USE ioipsl            ! NetCDF library
+   USE lbclnk            ! ocean lateral boundary conditions (or mpp link)
+   USE trdmld_trc_rst    ! restart for diagnosing the ML trends
+   USE prtctl            ! print control
+   USE sms_pisces        
+   USE sms_lobster
+   USE trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTERFACE trd_mod_trc
+      MODULE PROCEDURE trd_mod_trc_trp, trd_mod_trc_bio
+   END INTERFACE
+
+   PUBLIC trd_mod_trc                                             ! routine called by step.F90
+   PUBLIC trd_mld_trc
+   PUBLIC trd_mld_bio
+   PUBLIC trd_mld_trc_init
+
+   CHARACTER (LEN=40) ::  clhstnam                                ! name of the trends NetCDF file
+   INTEGER ::   nmoymltrd
+   INTEGER ::   ndextrd1(jpi*jpj)
+   INTEGER, DIMENSION(jptra) ::   nidtrd, nh_t
+   INTEGER ::   ndimtrd1                        
+   INTEGER, SAVE ::  ionce, icount
+#if defined key_lobster
+   INTEGER ::   nidtrdbio, nh_tb
+   INTEGER, SAVE ::  ioncebio, icountbio
+   INTEGER, SAVE ::   nmoymltrdbio
+#endif
+   LOGICAL :: llwarn  = .TRUE.                                    ! this should always be .TRUE.
+   LOGICAL :: lldebug = .TRUE.
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2007) 
+   !! $Header:  $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trd_mod_trc_trp( ptrtrd, kjn, ktrd, kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mod_trc  ***
+      !!----------------------------------------------------------------------
+#if defined key_trcbbl_adv
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zun, zvn                   ! temporary arrays
+#else
+      USE oce_trc,   zun => un                                            ! When no bbl, zun == un
+      USE oce_trc,   zvn => vn                                            ! When no bbl, zvn == vn
+#endif
+      INTEGER, INTENT( in )  ::   kt                                  ! time step
+      INTEGER, INTENT( in )  ::   kjn                                 ! tracer index
+      INTEGER, INTENT( in )  ::   ktrd                                ! tracer trend index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout )  ::   ptrtrd  ! Temperature or U trend
+      !!----------------------------------------------------------------------
+
+      IF( kt == nittrc000 ) THEN
+!         IF(lwp)WRITE(numout,*)
+!         IF(lwp)WRITE(numout,*) 'trd_mod_trc:'
+!         IF(lwp)WRITE(numout,*) '~~~~~~~~~~~~'
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Mixed layer trends for passive tracers
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+      SELECT CASE ( ktrd )
+         CASE ( jptrc_trd_xad     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_xad    , '3D', kjn )
+         CASE ( jptrc_trd_yad     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_yad    , '3D', kjn )
+         CASE ( jptrc_trd_zad     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_zad    , '3D', kjn )
+         CASE ( jptrc_trd_ldf     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_ldf    , '3D', kjn )
+         CASE ( jptrc_trd_xei     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_xei    , '3D', kjn )
+         CASE ( jptrc_trd_yei     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_yei    , '3D', kjn )
+         CASE ( jptrc_trd_bbl     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_bbl    , '3D', kjn )
+         CASE ( jptrc_trd_zdf     )
+            IF( ln_trcldf_iso ) THEN
+               CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_ldf, '3D', kjn )
+            ELSE
+               CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_zdf, '3D', kjn )
+            ENDIF
+         CASE ( jptrc_trd_zei     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_zei    , '3D', kjn )
+         CASE ( jptrc_trd_dmp     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_dmp    , '3D', kjn )
+         CASE ( jptrc_trd_sbc     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_sbc    , '2D', kjn )
+         CASE ( jptrc_trd_sms     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_sms    , '3D', kjn )
+         CASE ( jptrc_trd_bbc     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_bbc    , '3D', kjn )
+         CASE ( jptrc_trd_radb    )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_radb   , '3D', kjn )
+         CASE ( jptrc_trd_radn    )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_radn   , '3D', kjn )
+         CASE ( jptrc_trd_atf     )   ;   CALL trd_mld_trc_zint( ptrtrd, jpmld_trc_atf    , '3D', kjn )
+      END SELECT
+
+
+   END SUBROUTINE trd_mod_trc_trp
+
+   SUBROUTINE trd_mod_trc_bio( ptrbio, ktrd, kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mod_bio  ***
+      !!----------------------------------------------------------------------
+
+      INTEGER, INTENT( in )  ::   kt                                  ! time step
+      INTEGER, INTENT( in )  ::   ktrd                                ! bio trend index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout )  ::   ptrbio  ! Bio trend
+      !!----------------------------------------------------------------------
+
+      CALL trd_mld_bio_zint( ptrbio, ktrd ) ! Verticaly integrated biological trends
+
+   END SUBROUTINE trd_mod_trc_bio
+
+
+   SUBROUTINE trd_mld_trc_zint( ptrc_trdmld, ktrd, ctype, kjn )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_trc_zint  ***
+      !! 
+      !! ** Purpose :   Compute the vertical average of the 3D fields given as arguments 
+      !!                to the subroutine. This vertical average is performed from ocean
+      !!                surface down to a chosen control surface.
+      !!
+      !! ** Method/usage :
+      !!      The control surface can be either a mixed layer depth (time varying)
+      !!      or a fixed surface (jk level or bowl). 
+      !!      Choose control surface with nctls_trc in namelist NAMTRD :
+      !!        nctls_trc = -2  : use isopycnal surface
+      !!        nctls_trc = -1  : use euphotic layer with light criterion 
+      !!        nctls_trc =  0  : use mixed layer with density criterion 
+      !!        nctls_trc =  1  : read index from file 'ctlsurf_idx'
+      !!        nctls_trc >  1  : use fixed level surface jk = nctls_trc
+      !!      Note: in the remainder of the routine, the volume between the 
+      !!            surface and the control surface is called "mixed-layer"
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   ktrd, kjn                        ! ocean trend index and passive tracer rank
+      CHARACTER(len=2), INTENT( in ) ::  ctype                    ! surface/bottom (2D) or interior (3D) physics
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  ptrc_trdmld ! passive tracer trend
+      INTEGER ::   ji, jj, jk, isum
+      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
+      !!----------------------------------------------------------------------
+
+      ! I. Definition of control surface and integration weights
+      ! --------------------------------------------------------
+
+      ONCE_PER_TIME_STEP : IF( icount == 1 ) THEN
+         !
+         tmltrd_trc(:,:,:,:) = 0.e0                               ! <<< reset trend arrays to zero
+          
+         ! ... Set nmld(ji,jj) = index of first T point below control surf. or outside mixed-layer
+         SELECT CASE ( nctls_trc )                                ! choice of the control surface
+            CASE ( -2  )   ;   STOP 'trdmld_trc : not ready '     !     -> isopycnal surface (see ???)
+#if defined key_pisces || defined key_lobster
+            CASE ( -1  )   ;   nmld_trc(:,:) = neln(:,:)          !     -> euphotic layer with light criterion
+#endif
+            CASE (  0  )   ;   nmld_trc(:,:) = nmln(:,:)          !     -> ML with density criterion (see zdfmxl)
+            CASE (  1  )   ;   nmld_trc(:,:) = nbol_trc(:,:)          !     -> read index from file
+            CASE (  2: )   ;   nctls_trc = MIN( nctls_trc, jpktrd_trc - 1 )
+                               nmld_trc(:,:) = nctls_trc + 1      !     -> model level
+         END SELECT
+
+         ! ... Compute ndextrd1 and ndimtrd1  ??? role de jpktrd_trc
+         IF( ionce == 1 ) THEN
+            !
+            isum  = 0   ;   zvlmsk(:,:) = 0.e0
+
+            IF( jpktrd_trc < jpk ) THEN                           ! description ???
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF( nmld_trc(ji,jj) <= jpktrd_trc ) THEN
+                        zvlmsk(ji,jj) = tmask(ji,jj,1)
+                     ELSE
+                        isum = isum + 1
+                        zvlmsk(ji,jj) = 0.e0
+                     ENDIF
+                  END DO
+               END DO
+            ENDIF
+
+            IF( isum > 0 ) THEN                                   ! index of ocean points (2D only)
+               WRITE(numout,*)' tmltrd_trc : Number of invalid points nmld_trc > jpktrd', isum 
+               CALL wheneq( jpi*jpj, zvlmsk(:,:) , 1, 1., ndextrd1, ndimtrd1 )
+            ELSE 
+               CALL wheneq( jpi*jpj, tmask(:,:,1), 1, 1., ndextrd1, ndimtrd1 )
+            ENDIF                                
+
+            ionce = 0                                             ! no more pass here
+            !
+         ENDIF   ! ionce == 1
+         
+         ! ... Weights for vertical averaging
+         wkx_trc(:,:,:) = 0.e0
+         DO jk = 1, jpktrd_trc                                    ! initialize wkx_trc with vertical scale factor in mixed-layer
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( jk - nmld_trc(ji,jj) < 0 )   wkx_trc(ji,jj,jk) = fse3t(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         
+         rmld_trc(:,:) = 0.e0
+         DO jk = 1, jpktrd_trc                                    ! compute mixed-layer depth : rmld_trc
+            rmld_trc(:,:) = rmld_trc(:,:) + wkx_trc(:,:,jk)
+         END DO
+         
+         DO jk = 1, jpktrd_trc                                    ! compute integration weights
+            wkx_trc(:,:,jk) = wkx_trc(:,:,jk) / MAX( 1., rmld_trc(:,:) )
+         END DO
+
+         icount = 0                                               ! <<< flag = off : control surface & integr. weights
+         !                                                        !     computed only once per time step
+      ENDIF ONCE_PER_TIME_STEP
+
+      ! II. Vertical integration of trends in the mixed-layer
+      ! -----------------------------------------------------
+
+      SELECT CASE ( ctype )
+         CASE ( '3D' )                                            ! mean passive tracer trends in the mixed-layer
+            DO jk = 1, jpktrd_trc
+               tmltrd_trc(:,:,ktrd,kjn) = tmltrd_trc(:,:,ktrd,kjn) + ptrc_trdmld(:,:,jk) * wkx_trc(:,:,jk)   
+            END DO
+         CASE ( '2D' )                                            ! forcing at upper boundary of the mixed-layer 
+            tmltrd_trc(:,:,ktrd,kjn) = tmltrd_trc(:,:,ktrd,kjn) + ptrc_trdmld(:,:,1) * wkx_trc(:,:,1)  ! non penetrative
+      END SELECT
+
+    END SUBROUTINE trd_mld_trc_zint
+    
+    SUBROUTINE trd_mld_bio_zint( ptrc_trdmld, ktrd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_bio_zint  ***
+      !!
+      !! ** Purpose :   Compute the vertical average of the 3D fields given as arguments
+      !!                to the subroutine. This vertical average is performed from ocean
+      !!                surface down to a chosen control surface.
+      !!
+      !! ** Method/usage :
+      !!      The control surface can be either a mixed layer depth (time varying)
+      !!      or a fixed surface (jk level or bowl).
+      !!      Choose control surface with nctls in namelist NAMTRD :
+      !!        nctls_trc = 0  : use mixed layer with density criterion
+      !!        nctls_trc = 1  : read index from file 'ctlsurf_idx'
+      !!        nctls_trc > 1  : use fixed level surface jk = nctls_trc
+      !!      Note: in the remainder of the routine, the volume between the
+      !!            surface and the control surface is called "mixed-layer"
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   ktrd          ! bio trend index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::  ptrc_trdmld ! passive trc trend
+#if defined key_lobster
+      !! local variables
+      INTEGER ::   ji, jj, jk, isum
+      REAL(wp), DIMENSION(jpi,jpj) ::  zvlmsk
+      !!----------------------------------------------------------------------
+
+      ! I. Definition of control surface and integration weights
+      ! --------------------------------------------------------
+      !            ==> only once per time step <==
+
+      IF( icountbio == 1 ) THEN
+         !
+         tmltrd_bio(:,:,:) = 0.e0    ! <<< reset trend arrays to zero
+         ! ... Set nmld(ji,jj) = index of first T point below control surf. or outside mixed-layer
+         SELECT CASE ( nctls_trc )                                    ! choice of the control surface
+            CASE ( -2  )   ;   STOP 'trdmld_trc : not ready '     !     -> isopycnal surface (see ???)
+            CASE ( -1  )   ;   nmld_trc(:,:) = neln(:,:)          !     -> euphotic layer with light criterion
+            CASE (  0  )   ;   nmld_trc(:,:) = nmln(:,:)          !     -> ML with density criterion (see zdfmxl)
+            CASE (  1  )   ;   nmld_trc(:,:) = nbol_trc(:,:)          !     -> read index from file
+            CASE (  2: )   ;   nctls_trc = MIN( nctls_trc, jpktrd_trc - 1 )
+                               nmld_trc(:,:) = nctls_trc + 1          !     -> model level
+         END SELECT
+
+         ! ... Compute ndextrd1 and ndimtrd1 only once
+         IF( ioncebio == 1 ) THEN
+            !
+            ! Check of validity : nmld_trc(ji,jj) <= jpktrd_trc
+            isum        = 0
+            zvlmsk(:,:) = 0.e0
+
+            IF( jpktrd_trc < jpk ) THEN
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF( nmld_trc(ji,jj) <= jpktrd_trc ) THEN
+                        zvlmsk(ji,jj) = tmask(ji,jj,1)
+                     ELSE
+                        isum = isum + 1
+                        zvlmsk(ji,jj) = 0.
+                     END IF
+                  END DO
+               END DO
+            END IF
+
+            ! Index of ocean points (2D only)
+            IF( isum > 0 ) THEN
+               WRITE(numout,*)' tmltrd_trc : Number of invalid points nmld_trc > jpktrd', isum
+               CALL wheneq( jpi*jpj, zvlmsk(:,:) , 1, 1., ndextrd1, ndimtrd1 )
+            ELSE
+               CALL wheneq( jpi*jpj, tmask(:,:,1), 1, 1., ndextrd1, ndimtrd1 )
+            END IF
+
+            ioncebio = 0                  ! no more pass here
+            !
+         END IF !  ( ioncebio == 1 )
+
+         ! ... Weights for vertical averaging
+         wkx_trc(:,:,:) = 0.e0
+         DO jk = 1, jpktrd_trc         ! initialize wkx_trc with vertical scale factor in mixed-layer
+            DO jj = 1,jpj
+              DO ji = 1,jpi
+                  IF( jk - nmld_trc(ji,jj) < 0. )   wkx_trc(ji,jj,jk) = fse3t(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+
+         rmld_trc(:,:) = 0.
+         DO jk = 1, jpktrd_trc         ! compute mixed-layer depth : rmld_trc
+            rmld_trc(:,:) = rmld_trc(:,:) + wkx_trc(:,:,jk)
+         END DO
+
+         DO jk = 1, jpktrd_trc         ! compute integration weights
+            wkx_trc(:,:,jk) = wkx_trc(:,:,jk) / MAX( 1., rmld_trc(:,:) )
+         END DO
+
+         icountbio = 0                    ! <<< flag = off : control surface & integr. weights
+         !                             !     computed only once per time step
+      END IF ! ( icountbio == 1 )
+
+      ! II. Vertical integration of trends in the mixed-layer
+      ! -----------------------------------------------------
+
+
+      DO jk = 1, jpktrd_trc
+         tmltrd_bio(:,:,ktrd) = tmltrd_bio(:,:,ktrd) + ptrc_trdmld(:,:,jk) * wkx_trc(:,:,jk)
+      END DO
+
+#endif
+
+    END SUBROUTINE trd_mld_bio_zint
+
+
+    SUBROUTINE trd_mld_trc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_trc  ***
+      !! 
+      !! ** Purpose :  Compute and cumulate the mixed layer trends over an analysis
+      !!               period, and write NetCDF (or dimg) outputs.
+      !!
+      !! ** Method/usage :
+      !!          The stored trends can be chosen twofold (according to the ln_trdmld_trc_instant 
+      !!          logical namelist variable) :
+      !!          1) to explain the difference between initial and final 
+      !!             mixed-layer T & S (where initial and final relate to the
+      !!             current analysis window, defined by ntrc_trc in the namelist)
+      !!          2) to explain the difference between the current and previous 
+      !!             TIME-AVERAGED mixed-layer T & S (where time-averaging is
+      !!             performed over each analysis window).
+      !!
+      !! ** Consistency check : 
+      !!        If the control surface is fixed ( nctls_trc > 1 ), the residual term (dh/dt
+      !!        entrainment) should be zero, at machine accuracy. Note that in the case
+      !!        of time-averaged mixed-layer fields, this residual WILL NOT BE ZERO
+      !!        over the first two analysis windows (except if restart).
+      !!        N.B. For ORCA2_LIM, use e.g. ntrc_trc=5, ucf_trc=1., nctls_trc=8
+      !!             for checking residuals.
+      !!             On a NEC-SX5 computer, this typically leads to:
+      !!                   O(1.e-20) temp. residuals (tml_res) when ln_trdmld_trc_instant=.false.
+      !!                   O(1.e-21) temp. residuals (tml_res) when ln_trdmld_trc_instant=.true.
+      !!
+      !! ** Action :
+      !!       At each time step, mixed-layer averaged trends are stored in the 
+      !!       tmltrd(:,:,jpmld_xxx) array (see trdmld_oce.F90 for definitions of jpmld_xxx).
+      !!       This array is known when trd_mld is called, at the end of the stp subroutine, 
+      !!       except for the purely vertical K_z diffusion term, which is embedded in the
+      !!       lateral diffusion trend.
+      !!
+      !!       In I), this K_z term is diagnosed and stored, thus its contribution is removed
+      !!       from the lateral diffusion trend.
+      !!       In II), the instantaneous mixed-layer T & S are computed, and misc. cumulative
+      !!       arrays are updated.
+      !!       In III), called only once per analysis window, we compute the total trends,
+      !!       along with the residuals and the Asselin correction terms.
+      !!       In IV), the appropriate trends are written in the trends NetCDF file.
+      !!
+      !! References :
+      !!       - Vialard & al.
+      !!       - See NEMO documentation (in preparation)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                               ! ocean time-step index
+      INTEGER ::   ji, jj, jk, jl, ik, it, itmod, jn
+      REAL(wp) ::   zavt, zfn, zfn2
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltot             ! d(trc)/dt over the anlysis window (incl. Asselin)
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlres             ! residual = dh/dt entrainment term
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlatf             ! for storage only
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlrad             ! for storage only (for trb<0 corr in trcrad)
+      !!
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltot2            ! -+
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlres2            !  | working arrays to diagnose the trends
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmltrdm2           !  | associated with the time meaned ML
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlatf2            !  | passive tracers
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   ztmlrad2            !  | (-> for trb<0 corr in trcrad)
+      REAL(wp), DIMENSION(jpi,jpj,jpltrd_trc,jptra) ::  ztmltrd2  ! -+
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d                       ! temporary array, used for eiv arrays
+      CHARACTER (LEN= 5) ::   clvar
+#if defined key_dimgout
+      INTEGER ::   iyear,imon,iday
+      CHARACTER(LEN=80) ::   cltext, clmode
+#endif
+      !!----------------------------------------------------------------------
+
+      IF( llwarn ) THEN                                           ! warnings
+         IF(      ( nittrc000 /= nit000   ) &
+              .OR.( ndttrc    /= 1        )    ) THEN
+
+            WRITE(numout,*) 'Be careful, trends diags never validated'
+            STOP 'Uncomment this line to proceed'
+         ENDIF
+      ENDIF
+
+      ! ======================================================================
+      ! I. Diagnose the purely vertical (K_z) diffusion trend
+      ! ======================================================================
+
+      ! ... These terms can be estimated by flux computation at the lower boundary of the ML 
+      !     (we compute (-1/h) * K_z * d_z( tracer ))
+
+      IF( ln_trcldf_iso ) THEN
+         !
+         DO jj = 1,jpj
+            DO ji = 1,jpi
+               ik = nmld_trc(ji,jj)
+               zavt = avt(ji,jj,ik)
+               DO jn = 1, jptra
+                  IF( luttrd(jn) )    &
+                  tmltrd_trc(ji,jj,jpmld_trc_zdf,jn) = - zavt / fse3w(ji,jj,ik) * tmask(ji,jj,ik)  &
+                       &                    * ( trn(ji,jj,ik-1,jn) - trn(ji,jj,ik,jn) )            &
+                       &                    / MAX( 1., rmld_trc(ji,jj) ) * tmask(ji,jj,1)
+               END DO
+            END DO
+         END DO
+
+         DO jn = 1, jptra
+         ! ... Remove this K_z trend from the iso-neutral diffusion term (if any)
+            IF( luttrd(jn) ) &
+                 tmltrd_trc(:,:,jpmld_trc_ldf,jn) = tmltrd_trc(:,:,jpmld_trc_ldf,jn) - tmltrd_trc(:,:,jpmld_trc_zdf,jn)
+   
+         END DO
+         !      
+      ENDIF
+
+#if ! defined key_gyre
+      ! GYRE : for diagnostic fields, are needed if cyclic B.C. are present, but not for purely MPI comm. 
+      ! therefore we do not call lbc_lnk in GYRE config. (closed basin, no cyclic B.C.)
+      DO jn = 1, jptra
+         IF( luttrd(jn) ) THEN
+            DO jl = 1, jpltrd_trc
+               CALL lbc_lnk( tmltrd_trc(:,:,jl,jn), 'T', 1. )        ! lateral boundary conditions
+            END DO
+         ENDIF
+      END DO
+#endif
+      ! ======================================================================
+      ! II. Cumulate the trends over the analysis window
+      ! ======================================================================
+
+      ztmltrd2(:,:,:,:) = 0.e0   ;   ztmltot2(:,:,:)   = 0.e0     ! <<< reset arrays to zero
+      ztmlres2(:,:,:)   = 0.e0   ;   ztmlatf2(:,:,:)   = 0.e0
+      ztmlrad2(:,:,:)   = 0.e0
+
+      ! II.1 Set before values of vertically averages passive tracers
+      ! -------------------------------------------------------------
+      IF( kt > nittrc000 ) THEN
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               tmlb_trc   (:,:,jn) = tml_trc   (:,:,jn)
+               tmlatfn_trc(:,:,jn) = tmltrd_trc(:,:,jpmld_trc_atf,jn)
+               tmlradn_trc(:,:,jn) = tmltrd_trc(:,:,jpmld_trc_radb,jn)
+            ENDIF
+         END DO
+      ENDIF
+
+      ! II.2 Vertically averaged passive tracers
+      ! ----------------------------------------
+      tml_trc(:,:,:) = 0.e0
+      DO jk = 1, jpktrd_trc ! - 1 ???
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) &
+               tml_trc(:,:,jn) = tml_trc(:,:,jn) + wkx_trc(:,:,jk) * trn(:,:,jk,jn)
+         END DO
+      END DO
+
+      ! II.3 Initialize mixed-layer "before" arrays for the 1rst analysis window    
+      ! ------------------------------------------------------------------------
+      IF( kt == 2 ) THEN  !  i.e. ( .NOT. ln_rstart ).AND.( kt == nit000 + 1)    ???
+         !
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               tmlbb_trc  (:,:,jn) = tmlb_trc   (:,:,jn)   ;   tmlbn_trc  (:,:,jn) = tml_trc    (:,:,jn)
+               tmlatfb_trc(:,:,jn) = tmlatfn_trc(:,:,jn)   ;   tmlradb_trc(:,:,jn) = tmlradn_trc(:,:,jn)
+               
+               tmltrd_csum_ub_trc (:,:,:,jn) = 0.e0   ;   tmltrd_atf_sumb_trc  (:,:,jn) = 0.e0
+               tmltrd_rad_sumb_trc  (:,:,jn) = 0.e0
+            ENDIF
+         END DO
+         
+         rmldbn_trc(:,:) = rmld_trc(:,:)
+         !
+      ENDIF
+
+      ! II.4 Cumulated trends over the analysis period
+      ! ----------------------------------------------
+      !
+      !         [  1rst analysis window ] [     2nd analysis window     ]                       
+      !
+      !     o---[--o-----o-----o-----o--]-[--o-----o-----o-----o-----o--]---o-----o--> time steps
+      !                            ntrd                             2*ntrd       etc.
+      !     1      2     3     4    =5 e.g.                          =10
+      !
+      IF( ( kt >= 2 ).OR.( ln_rsttr ) ) THEN                        ! ???
+         !
+         nmoymltrd = nmoymltrd + 1
+
+
+         ! ... Cumulate over BOTH physical contributions AND over time steps
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               DO jl = 1, jpltrd_trc
+                  tmltrdm_trc(:,:,jn) = tmltrdm_trc(:,:,jn) + tmltrd_trc(:,:,jl,jn)
+               END DO
+            ENDIF
+         END DO
+
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               ! ... Special handling of the Asselin trend 
+               tmlatfm_trc(:,:,jn) = tmlatfm_trc(:,:,jn) + tmlatfn_trc(:,:,jn)
+               tmlradm_trc(:,:,jn) = tmlradm_trc(:,:,jn) + tmlradn_trc(:,:,jn)
+
+               ! ... Trends associated with the time mean of the ML passive tracers
+               tmltrd_sum_trc    (:,:,:,jn) = tmltrd_sum_trc    (:,:,:,jn) + tmltrd_trc    (:,:,:,jn)
+               tmltrd_csum_ln_trc(:,:,:,jn) = tmltrd_csum_ln_trc(:,:,:,jn) + tmltrd_sum_trc(:,:,:,jn)
+               tml_sum_trc       (:,:,jn)   = tml_sum_trc       (:,:,jn)   + tml_trc       (:,:,jn)
+            ENDIF
+         ENDDO
+
+         rmld_sum_trc      (:,:)     = rmld_sum_trc      (:,:)     + rmld_trc      (:,:)
+         !
+      ENDIF
+
+      ! ======================================================================
+      ! III. Prepare fields for output (get here ONCE PER ANALYSIS PERIOD)
+      ! ======================================================================
+
+      ! Convert to appropriate physical units
+      tmltrd_trc(:,:,:,:) = tmltrd_trc(:,:,:,:) * ucf_trc
+
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      MODULO_NTRD : IF( MOD( itmod, ntrd_trc ) == 0 ) THEN           ! nitend MUST be multiple of ntrd_trc
+         !
+         ztmltot (:,:,:) = 0.e0                                   ! reset arrays to zero
+         ztmlres (:,:,:) = 0.e0
+         ztmltot2(:,:,:) = 0.e0
+         ztmlres2(:,:,:) = 0.e0
+      
+         zfn  = FLOAT( nmoymltrd )    ;    zfn2 = zfn * zfn
+         
+         ! III.1 Prepare fields for output ("instantaneous" diagnostics) 
+         ! -------------------------------------------------------------
+
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               !-- Compute total trends    (use rdttrc instead of rdt ???)
+               IF ( ln_trcadv_smolar .OR. ln_trcadv_muscl .OR. ln_trcadv_muscl2 ) THEN  ! EULER-FORWARD schemes
+                  ztmltot(:,:,jn) =  ( tml_trc(:,:,jn) - tmlbn_trc(:,:,jn) )/rdt
+               ELSE                                                                     ! LEAP-FROG schemes
+                  ztmltot(:,:,jn) =  ( tml_trc(:,:,jn) - tmlbn_trc(:,:,jn) + tmlb_trc(:,:,jn) - tmlbb_trc(:,:,jn))/(2.*rdt)
+               ENDIF
+               
+               !-- Compute residuals
+               ztmlres(:,:,jn) = ztmltot(:,:,jn) - ( tmltrdm_trc(:,:,jn) - tmlatfn_trc(:,:,jn) + tmlatfb_trc(:,:,jn) &
+                  &                                                 - tmlradn_trc(:,:,jn) + tmlradb_trc(:,:,jn)  )
+               
+               !-- Diagnose Asselin trend over the analysis window 
+               ztmlatf(:,:,jn) = tmlatfm_trc(:,:,jn) - tmlatfn_trc(:,:,jn) + tmlatfb_trc(:,:,jn)
+               ztmlrad(:,:,jn) = tmlradm_trc(:,:,jn) - tmlradn_trc(:,:,jn) + tmlradb_trc(:,:,jn)
+               
+         !-- Lateral boundary conditions
+#if ! defined key_gyre
+
+               CALL lbc_lnk( ztmltot(:,:,jn) , 'T', 1. )   ;   CALL lbc_lnk( ztmlres(:,:,jn) , 'T', 1. )
+               CALL lbc_lnk( ztmlatf(:,:,jn) , 'T', 1. )   ;   CALL lbc_lnk( ztmlrad(:,:,jn) , 'T', 1. )
+
+#endif
+
+#if defined key_diainstant
+               STOP 'tmltrd_trc : key_diainstant was never checked within trdmld. Comment this to proceed.'
+#endif
+            ENDIF
+         END DO
+
+         ! III.2 Prepare fields for output ("mean" diagnostics) 
+         ! ----------------------------------------------------
+         
+         !-- Update the ML depth time sum (to build the Leap-Frog time mean)
+         rmld_sum_trc(:,:) = rmldbn_trc(:,:) + 2 * ( rmld_sum_trc(:,:) - rmld_trc(:,:) ) + rmld_trc(:,:)
+
+               !-- Compute passive tracer total trends
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               tml_sum_trc(:,:,jn) = tmlbn_trc(:,:,jn) + 2 * ( tml_sum_trc(:,:,jn) - tml_trc(:,:,jn) ) + tml_trc(:,:,jn)
+               ztmltot2   (:,:,jn) = ( tml_sum_trc(:,:,jn) - tml_sumb_trc(:,:,jn) ) /  ( 2.*rdt )    ! now tracer unit is /sec
+            ENDIF
+         END DO
+
+         !-- Compute passive tracer residuals
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+               !
+               DO jl = 1, jpltrd_trc
+                  ztmltrd2(:,:,jl,jn) = tmltrd_csum_ub_trc(:,:,jl,jn) + tmltrd_csum_ln_trc(:,:,jl,jn)
+               END DO
+               
+               ztmltrdm2(:,:,jn) = 0.e0
+               DO jl = 1, jpltrd_trc
+                  ztmltrdm2(:,:,jn) = ztmltrdm2(:,:,jn) + ztmltrd2(:,:,jl,jn)
+               END DO
+               
+               ztmlres2(:,:,jn) =  ztmltot2(:,:,jn)  -       &
+                  & ( ztmltrdm2(:,:,jn) - tmltrd_sum_trc(:,:,jpmld_trc_atf ,jn) + tmltrd_atf_sumb_trc(:,:,jn) &
+                  &                     - tmltrd_sum_trc(:,:,jpmld_trc_radb,jn) + tmltrd_rad_sumb_trc(:,:,jn) )
+               !
+
+               !-- Diagnose Asselin trend over the analysis window
+               ztmlatf2(:,:,jn) = ztmltrd2(:,:,jpmld_trc_atf ,jn) - tmltrd_sum_trc(:,:,jpmld_trc_atf ,jn) &
+                  &                                               + tmltrd_atf_sumb_trc(:,:,jn)
+               ztmlrad2(:,:,jn) = ztmltrd2(:,:,jpmld_trc_radb,jn) - tmltrd_sum_trc(:,:,jpmld_trc_radb,jn) &
+                  &                                               + tmltrd_rad_sumb_trc(:,:,jn)
+
+         !-- Lateral boundary conditions
+#if ! defined key_gyre         
+               CALL lbc_lnk( ztmltot2(:,:,jn), 'T', 1. )
+               CALL lbc_lnk( ztmlres2(:,:,jn), 'T', 1. )
+               DO jl = 1, jpltrd_trc
+                  CALL lbc_lnk( ztmltrd2(:,:,jl,jn), 'T', 1. )       ! will be output in the NetCDF trends file
+               END DO
+#endif
+            ENDIF
+         END DO
+
+         ! * Debugging information *
+         IF( lldebug ) THEN
+            !
+            WRITE(numout,*) 'trd_mld_trc : write trends in the Mixed Layer for debugging process:'
+            WRITE(numout,*) '~~~~~~~~~~~  '
+            WRITE(numout,*)
+            WRITE(numout,*) 'TRC kt = ', kt, '    nmoymltrd = ', nmoymltrd
+
+            DO jn = 1, jptra
+
+               IF( luttrd(jn) ) THEN
+                  WRITE(numout, *)
+                  WRITE(numout, *) '>>>>>>>>>>>>>>>>>>  TRC TRACER jn =', jn, ' <<<<<<<<<<<<<<<<<<'
+                  
+                  WRITE(numout, *)
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM ztmlres     : ', SUM2D(ztmlres(:,:,jn))
+                  !CD??? PREVOIR: z2d = ztmlres(:,:,jn)   ;   CALL prt_ctl(tab2d_1=z2d, clinfo1=' ztmlres   -   : ')
+                  
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM ABS(ztmlres): ', SUM2D(ABS(ztmlres(:,:,jn)))
+                  WRITE(numout, '(3x,a)') ' -->>>------------------- ztmlres is computed from ------------- '
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +ztmltot    : ', SUM2D(+ztmltot    (:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmltrdm_trc: ', SUM2D(+tmltrdm_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmlatfn_trc: ', SUM2D(-tmlatfn_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmlatfb_trc: ', SUM2D(+tmlatfb_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmlradn_trc: ', SUM2D(-tmlradn_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmlradb_trc: ', SUM2D(+tmlradb_trc(:,:,jn))
+                  WRITE(numout, '(3x,a)') ' --<<<----------------------------------------------------------- '
+                  
+                  WRITE(numout, *)
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM ztmlres2    : ', SUM2D(ztmlres2(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM ABS(ztmlres2):', SUM2D(ABS(ztmlres2(:,:,jn)))
+                  WRITE(numout, '(3x,a)') ' -->>>------------------- ztmlres2 is computed from ------------ '
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +ztmltot2            : ', SUM2D(+ztmltot2(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +ztmltrdm2           : ', SUM2D(+ztmltrdm2(:,:,jn)) 
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmltrd_sum_trc      : ', SUM2D(-tmltrd_sum_trc(:,:,jpmld_trc_atf,jn)) 
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmltrd_atf_sumb_trc : ', SUM2D(+tmltrd_atf_sumb_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmltrd_sum_trc      : ', SUM2D(-tmltrd_sum_trc(:,:,jpmld_trc_radb,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmltrd_rad_sumb_trc : ', SUM2D(+tmltrd_rad_sumb_trc(:,:,jn) )
+                  WRITE(numout, '(3x,a)') ' --<<<----------------------------------------------------------- '
+                  
+                  WRITE(numout, *)
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM ztmltot     : ', SUM2D(ztmltot    (:,:,jn))
+                  WRITE(numout, '(3x,a)') ' -->>>------------------- ztmltot is computed from ------------- '
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tml_trc    : ', SUM2D(tml_trc    (:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmlbn_trc  : ', SUM2D(tmlbn_trc  (:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM +tmlb_trc   : ', SUM2D(tmlb_trc   (:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM -tmlbb_trc  : ', SUM2D(tmlbb_trc  (:,:,jn))
+                  WRITE(numout, '(3x,a)') ' --<<<----------------------------------------------------------- '
+                  
+                  WRITE(numout, *)
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM tmltrdm_trc : ', SUM2D(tmltrdm_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM tmlatfb_trc : ', SUM2D(tmlatfb_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM tmlatfn_trc : ', SUM2D(tmlatfn_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM tmlradb_trc : ', SUM2D(tmlradb_trc(:,:,jn))
+                  WRITE(numout,98) 'TRC jn =', jn, ' SUM tmlradn_trc : ', SUM2D(tmlradn_trc(:,:,jn))
+                  
+                  WRITE(numout, *)
+                  DO jl = 1, jpltrd_trc
+                     WRITE(numout,97) 'TRC jn =', jn, ' TREND INDEX jpmld_trc_xxx = ', jl, &
+                        & ' SUM tmltrd_trc : ', SUM2D(tmltrd_trc(:,:,jl,jn))
+                  END DO
+               
+                  WRITE(numout,*) 
+                  WRITE(numout,*) ' *********************** ZTMLRES, ZTMLRES2 *********************** '
+                  WRITE(numout,*)
+                  WRITE(numout,*) 'TRC ztmlres (jpi/2,jpj/2,:) : ', ztmlres (jpi/2,jpj/2,jn)
+                  WRITE(numout,*)
+                  WRITE(numout,*) 'TRC ztmlres2(jpi/2,jpj/2,:) : ', ztmlres2(jpi/2,jpj/2,jn)
+                  
+                  WRITE(numout,*) 
+                  WRITE(numout,*) ' *********************** ZTMLRES *********************** '
+                  WRITE(numout,*)
+                  
+                  WRITE(numout,*) '...................................................'
+                  WRITE(numout,*) 'TRC jn =', jn, ' ztmlres (1:10,1:5,jn) : '
+                  DO jj = 5, 1, -1
+                     WRITE(numout,99) jj, ( ztmlres (ji,jj,jn), ji=1,10 )
+                  END DO
+                  
+                  WRITE(numout,*) 
+                  WRITE(numout,*) ' *********************** ZTMLRES2 *********************** '
+                  WRITE(numout,*)
+                  
+                  WRITE(numout,*) '...................................................'
+                  WRITE(numout,*) 'TRC jn =', jn, ' ztmlres2 (1:10,1:5,jn) : '
+                  DO jj = 5, 1, -1
+                     WRITE(numout,99) jj, ( ztmlres2 (ji,jj,jn), ji=1,10 )
+                  END DO
+                  !
+               ENDIF
+               !
+            END DO
+
+
+97            FORMAT(a10, i3, 2x, a30, i3, a20, 2x, g20.10)
+98            FORMAT(a10, i3, 2x, a30, 2x, g20.10)
+99            FORMAT('TRC jj =', i3,' : ', 10(g10.3,2x))
+              WRITE(numout,*)
+            !
+         ENDIF
+
+         ! III.3 Time evolution array swap
+         ! -------------------------------
+         ! ML depth
+         rmldbn_trc(:,:)   = rmld_trc(:,:)
+         rmld_sum_trc(:,:)     = rmld_sum_trc(:,:)     /      (2*zfn)  ! similar to tml_sum and sml_sum
+         DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN        
+               ! For passive tracer instantaneous diagnostics
+               tmlbb_trc  (:,:,jn) = tmlb_trc   (:,:,jn)   ;   tmlbn_trc  (:,:,jn) = tml_trc    (:,:,jn)
+               tmlatfb_trc(:,:,jn) = tmlatfn_trc(:,:,jn)   ;   tmlradb_trc(:,:,jn) = tmlradn_trc(:,:,jn)
+               
+               ! For passive tracer mean diagnostics
+               tmltrd_csum_ub_trc (:,:,:,jn) = zfn * tmltrd_sum_trc(:,:,:,jn) - tmltrd_csum_ln_trc(:,:,:,jn)
+               tml_sumb_trc       (:,:,jn)   = tml_sum_trc(:,:,jn)
+               tmltrd_atf_sumb_trc(:,:,jn)   = tmltrd_sum_trc(:,:,jpmld_trc_atf ,jn)
+               tmltrd_rad_sumb_trc(:,:,jn)   = tmltrd_sum_trc(:,:,jpmld_trc_radb,jn)
+               
+               
+               ! III.4 Convert to appropriate physical units
+               ! -------------------------------------------
+               ztmltot     (:,:,jn)   = ztmltot     (:,:,jn)   * ucf_trc/zfn   ! instant diags
+               ztmlres     (:,:,jn)   = ztmlres     (:,:,jn)   * ucf_trc/zfn
+               ztmlatf     (:,:,jn)   = ztmlatf     (:,:,jn)   * ucf_trc/zfn
+               ztmlrad     (:,:,jn)   = ztmlrad     (:,:,jn)   * ucf_trc/zfn
+               tml_sum_trc (:,:,jn)   = tml_sum_trc (:,:,jn)   /      (2*zfn)  ! mean diags
+               ztmltot2    (:,:,jn)   = ztmltot2    (:,:,jn)   * ucf_trc/zfn2
+               ztmltrd2    (:,:,:,jn) = ztmltrd2    (:,:,:,jn) * ucf_trc/zfn2
+               ztmlatf2    (:,:,jn)   = ztmlatf2    (:,:,jn)   * ucf_trc/zfn2
+               ztmlrad2    (:,:,jn)   = ztmlrad2    (:,:,jn)   * ucf_trc/zfn2
+               ztmlres2    (:,:,jn)   = ztmlres2    (:,:,jn)   * ucf_trc/zfn2
+            ENDIF
+         END DO
+         !
+      ENDIF MODULO_NTRD
+
+      ! ======================================================================
+      ! IV. Write trends in the NetCDF file
+      ! ======================================================================
+
+      ! IV.1 Code for dimg mpp output
+      ! -----------------------------
+
+# if defined key_dimgout
+      STOP 'Not implemented'
+# else
+      
+      ! IV.2 Code for IOIPSL/NetCDF output
+      ! ----------------------------------
+
+      IF( lwp .AND. MOD( itmod , ntrd_trc ) == 0 ) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) 'trd_mld_trc : write passive tracer trends in the NetCDF file :'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '          ', trim(clhstnam), ' at kt = ', kt
+         WRITE(numout,*) '          N.B. nmoymltrd = ', nmoymltrd
+         WRITE(numout,*) ' '
+      ENDIF
+         
+      NETCDF_OUTPUT : IF( ln_trdmld_trc_instant ) THEN            ! <<< write the trends for passive tracer instant. diags
+         !
+
+         DO jn = 1, jptra
+            !
+            IF( luttrd(jn) ) THEN
+               !-- Specific treatment for EIV trends
+               !   WARNING : When eiv is switched on but key_diaeiv is not, we do NOT diagnose
+               !   u_eiv, v_eiv, and w_eiv : the exact eiv advective trends thus cannot be computed,
+               !   only their sum makes sense => mask directional contrib. to avoid confusion
+               z2d(:,:) = tmltrd_trc(:,:,jpmld_trc_xei,jn) + tmltrd_trc(:,:,jpmld_trc_yei,jn) &
+                    &   + tmltrd_trc(:,:,jpmld_trc_zei,jn)
+#if ( defined key_trcldf_eiv && defined key_diaeiv )
+               tmltrd_trc(:,:,jpmld_trc_xei,jn) = -999.
+               tmltrd_trc(:,:,jpmld_trc_yei,jn) = -999.
+               tmltrd_trc(:,:,jpmld_trc_zei,jn) = -999.
+#endif   
+               CALL histwrite( nidtrd(jn), "mxl_depth", it, rmld_trc(:,:), ndimtrd1, ndextrd1 )
+               !-- Output the fields
+               clvar = trim(ctrcnm(jn))//"ml"                        ! e.g. detml, zooml, nh4ml, etc.
+               CALL histwrite( nidtrd(jn), clvar         , it, tml_trc(:,:,jn), ndimtrd1, ndextrd1 ) 
+               CALL histwrite( nidtrd(jn), clvar//"_tot" , it, ztmltot(:,:,jn), ndimtrd1, ndextrd1 ) 
+               CALL histwrite( nidtrd(jn), clvar//"_res" , it, ztmlres(:,:,jn), ndimtrd1, ndextrd1 ) 
+           
+               DO jl = 1, jpltrd_trc - 2
+                  CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jl,2)),             &
+                    &          it, tmltrd_trc(:,:,jl,jn), ndimtrd1, ndextrd1 )
+               END DO
+
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_radb,2)),    &  ! now trcrad    : jpltrd_trc - 1
+                    &          it, ztmlrad(:,:,jn), ndimtrd1, ndextrd1 )
+
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_atf,2)),     &  ! now Asselin   : jpltrd_trc
+                    &          it, ztmlatf(:,:,jn), ndimtrd1, ndextrd1 )
+                     
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc( jpltrd_trc+1,2)),     &  ! now total EIV : jpltrd_trc + 1
+                    &          it, z2d(:,:), ndimtrd1, ndextrd1 )                     
+            !
+            ENDIF
+         END DO
+
+         IF( kt == nitend ) THEN 
+            DO jn = 1, jptra
+               IF( luttrd(jn) )  CALL histclo( nidtrd(jn) )
+            END DO
+         ENDIF
+
+      ELSE                                                        ! <<< write the trends for passive tracer mean diagnostics
+         
+                 
+         DO jn = 1, jptra
+            !
+            IF( luttrd(jn) ) THEN
+               !-- Specific treatment for EIV trends
+               !   WARNING : see above
+               z2d(:,:) = ztmltrd2(:,:,jpmld_trc_xei,jn) + ztmltrd2(:,:,jpmld_trc_yei,jn) &
+                   &   + ztmltrd2(:,:,jpmld_trc_zei,jn)
+
+#if ( defined key_trcldf_eiv && defined key_diaeiv )
+               ztmltrd2(:,:,jpmld_trc_xei,jn) = -999.
+               ztmltrd2(:,:,jpmld_trc_yei,jn) = -999.
+               ztmltrd2(:,:,jpmld_trc_zei,jn) = -999.
+#endif
+               CALL histwrite( nidtrd(jn), "mxl_depth", it, rmld_sum_trc(:,:), ndimtrd1, ndextrd1 ) 
+               !-- Output the fields
+               clvar = trim(ctrcnm(jn))//"ml"                        ! e.g. detml, zooml, nh4ml, etc.
+
+               CALL histwrite( nidtrd(jn), clvar         , it, tml_sum_trc(:,:,jn), ndimtrd1, ndextrd1 )
+               CALL histwrite( nidtrd(jn), clvar//"_tot" , it,    ztmltot2(:,:,jn), ndimtrd1, ndextrd1 ) 
+               CALL histwrite( nidtrd(jn), clvar//"_res" , it,    ztmlres2(:,:,jn), ndimtrd1, ndextrd1 ) 
+
+               DO jl = 1, jpltrd_trc - 2
+                  CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jl,2)),           &
+                    &          it, ztmltrd2(:,:,jl,jn), ndimtrd1, ndextrd1 )
+               END DO
+            
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_radb,2)),   &  ! now trcrad    : jpltrd_trc - 1
+                 &          it, ztmlrad2(:,:,jn), ndimtrd1, ndextrd1 )
+
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_atf,2)),    &  ! now Asselin   : jpltrd_trc
+                 &          it, ztmlatf2(:,:,jn), ndimtrd1, ndextrd1 )
+
+               CALL histwrite( nidtrd(jn), trim(clvar//ctrd_trc( jpltrd_trc+1,2)),    &  ! now total EIV : jpltrd_trc + 1
+                 &          it, z2d(:,:), ndimtrd1, ndextrd1 )
+
+            ENDIF 
+            !
+         END DO
+         IF( kt == nitend ) THEN 
+            DO jn = 1, jptra
+               IF( luttrd(jn) )  CALL histclo( nidtrd(jn) )
+            END DO
+         ENDIF
+
+         !
+      ENDIF NETCDF_OUTPUT
+         
+      ! Compute the control surface (for next time step) : flag = on
+      icount = 1
+
+# endif /* key_dimgout */
+
+      IF( MOD( itmod, ntrd_trc ) == 0 ) THEN
+         !
+         ! Reset cumulative arrays to zero
+         ! -------------------------------         
+         nmoymltrd = 0
+         tmltrdm_trc        (:,:,:)   = 0.e0   ;   tmlatfm_trc        (:,:,:)   = 0.e0
+         tmlradm_trc        (:,:,:)   = 0.e0   ;   tml_sum_trc        (:,:,:)   = 0.e0
+         tmltrd_csum_ln_trc (:,:,:,:) = 0.e0   ;   tmltrd_sum_trc     (:,:,:,:) = 0.e0
+         rmld_sum_trc       (:,:)     = 0.e0
+         !
+      ENDIF
+
+      ! ======================================================================
+      ! V. Write restart file
+      ! ======================================================================
+
+      IF( lrst_trc )   CALL trd_mld_trc_rst_write( kt )  ! this must be after the array swap above (III.3)
+
+   END SUBROUTINE trd_mld_trc
+
+    SUBROUTINE trd_mld_bio( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld  ***
+      !!
+      !! ** Purpose :  Compute and cumulate the mixed layer biological trends over an analysis
+      !!               period, and write NetCDF (or dimg) outputs.
+      !!
+      !! ** Method/usage :
+      !!          The stored trends can be chosen twofold (according to the ln_trdmld_trc_instant
+      !!          logical namelist variable) :
+      !!          1) to explain the difference between initial and final
+      !!             mixed-layer T & S (where initial and final relate to the
+      !!             current analysis window, defined by ntrd in the namelist)
+      !!          2) to explain the difference between the current and previous
+      !!             TIME-AVERAGED mixed-layer T & S (where time-averaging is
+      !!             performed over each analysis window).
+      !!
+      !! ** Consistency check :
+      !!        If the control surface is fixed ( nctls > 1 ), the residual term (dh/dt
+      !!        entrainment) should be zero, at machine accuracy. Note that in the case
+      !!        of time-averaged mixed-layer fields, this residual WILL NOT BE ZERO
+      !!        over the first two analysis windows (except if restart).
+      !!        N.B. For ORCA2_LIM, use e.g. ntrd=5, ucf=1., nctls=8
+      !!             for checking residuals.
+      !!             On a NEC-SX5 computer, this typically leads to:
+      !!                   O(1.e-20) temp. residuals (tml_res) when ln_trdmld_trc_instant=.false.
+      !!                   O(1.e-21) temp. residuals (tml_res) when ln_trdmld_trc_instant=.true.
+      !!
+      !! ** Action :
+      !!       At each time step, mixed-layer averaged trends are stored in the
+      !!       tmltrd(:,:,jpmld_xxx) array (see trdmld_oce.F90 for definitions of jpmld_xxx).
+      !!       This array is known when trd_mld is called, at the end of the stp subroutine,
+      !!       except for the purely vertical K_z diffusion term, which is embedded in the
+      !!       lateral diffusion trend.
+      !!
+      !!       In I), this K_z term is diagnosed and stored, thus its contribution is removed
+      !!       from the lateral diffusion trend.
+      !!       In II), the instantaneous mixed-layer T & S are computed, and misc. cumulative
+      !!       arrays are updated.
+      !!       In III), called only once per analysis window, we compute the total trends,
+      !!       along with the residuals and the Asselin correction terms.
+      !!       In IV), the appropriate trends are written in the trends NetCDF file.
+      !!
+      !! References :
+      !!       - Vialard & al.
+      !!       - See NEMO documentation (in preparation)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt                       ! ocean time-step index
+#if defined key_lobster
+      INTEGER  ::  jl, it, itmod
+      LOGICAL  :: llwarn  = .TRUE., lldebug = .TRUE.
+      REAL(wp), DIMENSION(jpi,jpj,jpdiabio) ::  ztmltrdbio2  ! only needed for mean diagnostics
+      REAL(wp) :: zfn, zfn2
+#if defined key_dimgout
+      INTEGER ::  iyear,imon,iday
+      CHARACTER(LEN=80) :: cltext, clmode
+#endif
+      !!----------------------------------------------------------------------
+      ! ... Warnings
+      IF( llwarn ) THEN
+         IF(      ( nittrc000 /= nit000   ) &
+              .OR.( ndttrc    /= 1        )    ) THEN
+
+            WRITE(numout,*) 'Be careful, trends diags never validated'
+            STOP 'Uncomment this line to proceed'
+         END IF
+      END IF
+
+      ! ======================================================================
+      ! II. Cumulate the trends over the analysis window
+      ! ======================================================================
+
+      ztmltrdbio2(:,:,:) = 0.e0  ! <<< reset arrays to zero
+
+      ! II.3 Initialize mixed-layer "before" arrays for the 1rst analysis window
+      ! ------------------------------------------------------------------------
+      IF( kt == 2 ) THEN  !  i.e. ( .NOT. ln_rstart ).AND.( kt == nit000 + 1)
+         !
+         tmltrd_csum_ub_bio (:,:,:) = 0.e0
+         !
+      END IF
+
+      ! II.4 Cumulated trends over the analysis period
+      ! ----------------------------------------------
+      !
+      !         [  1rst analysis window ] [     2nd analysis window     ]
+      !
+      !
+      !     o---[--o-----o-----o-----o--]-[--o-----o-----o-----o-----o--]---o-----o--> time steps
+      !                            ntrd                             2*ntrd       etc.
+      !     1      2     3     4    =5 e.g.                          =10
+      !
+      IF( ( kt >= 2 ).OR.( ln_rsttr ) ) THEN
+         !
+         nmoymltrdbio = nmoymltrdbio + 1
+
+         ! ... Trends associated with the time mean of the ML passive tracers
+         tmltrd_sum_bio    (:,:,:) = tmltrd_sum_bio    (:,:,:) + tmltrd_bio    (:,:,:)
+         tmltrd_csum_ln_bio(:,:,:) = tmltrd_csum_ln_bio(:,:,:) + tmltrd_sum_bio(:,:,:)
+         !
+      END IF
+
+      ! ======================================================================
+      ! III. Prepare fields for output (get here ONCE PER ANALYSIS PERIOD)
+      ! ======================================================================
+
+      ! Convert to appropriate physical units
+      tmltrd_bio(:,:,:) = tmltrd_bio(:,:,:) * ucf_trc
+
+      MODULO_NTRD : IF( MOD( kt, ntrd_trc ) == 0 ) THEN      ! nitend MUST be multiple of ntrd
+         !
+         zfn  = float(nmoymltrdbio)    ;    zfn2 = zfn * zfn
+
+         ! III.1 Prepare fields for output ("instantaneous" diagnostics)
+         ! -------------------------------------------------------------
+
+#if defined key_diainstant
+         STOP 'tmltrd_bio : key_diainstant was never checked within trdmld. Comment this to proceed.'
+#endif
+         ! III.2 Prepare fields for output ("mean" diagnostics)
+         ! ----------------------------------------------------
+
+         ztmltrdbio2(:,:,:) = tmltrd_csum_ub_bio(:,:,:) + tmltrd_csum_ln_bio(:,:,:)
+
+         !-- Lateral boundary conditions
+#if ! defined key_gyre
+         ! ES_B27_CD_WARN : lbc inutile GYRE, cf. + haut
+         DO jn = 1, jpdiabio
+           CALL lbc_lnk( ztmltrdbio2(:,:,jn), 'T', 1. )
+         ENDDO
+#endif
+         IF( lldebug ) THEN
+            !
+            WRITE(numout,*) 'trd_mld_bio : write trends in the Mixed Layer for debugging process:'
+            WRITE(numout,*) '~~~~~~~~~~~  '
+            WRITE(numout,*) 'TRC kt = ', kt, 'nmoymltrdbio = ', nmoymltrdbio
+            WRITE(numout,*)
+
+            DO jl = 1, jpdiabio
+              IF( ln_trdmld_trc_instant ) THEN
+                  WRITE(numout,97) 'TRC jl =', jl, ' bio TREND INDEX  = ', jl, &
+                     & ' SUM tmltrd_bio : ', SUM2D(tmltrd_bio(:,:,jl))
+              ELSE
+                  WRITE(numout,97) 'TRC jl =', jl, ' bio TREND INDEX  = ', jl, &
+                     & ' SUM ztmltrdbio2 : ', SUM2D(ztmltrdbio2(:,:,jl))
+              endif
+            END DO
+
+97          FORMAT(a10, i3, 2x, a30, i3, a20, 2x, g20.10)
+98          FORMAT(a10, i3, 2x, a30, 2x, g20.10)
+99          FORMAT('TRC jj =', i3,' : ', 10(g10.3,2x))
+            WRITE(numout,*)
+            !
+         ENDIF
+
+         ! III.3 Time evolution array swap
+         ! -------------------------------
+
+         ! For passive tracer mean diagnostics
+         tmltrd_csum_ub_bio (:,:,:) = zfn * tmltrd_sum_bio(:,:,:) - tmltrd_csum_ln_bio(:,:,:)
+
+         ! III.4 Convert to appropriate physical units
+         ! -------------------------------------------
+         ztmltrdbio2    (:,:,:) = ztmltrdbio2    (:,:,:) * ucf_trc/zfn2
+
+      END IF MODULO_NTRD
+
+      ! ======================================================================
+      ! IV. Write trends in the NetCDF file
+      ! ======================================================================
+
+      ! IV.1 Code for dimg mpp output
+      ! -----------------------------
+
+# if defined key_dimgout
+      STOP 'Not implemented'
+# else
+
+      ! IV.2 Code for IOIPSL/NetCDF output
+      ! ----------------------------------
+
+      ! define time axis
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      IF( lwp .AND. MOD( itmod , ntrd_trc ) == 0 ) THEN
+         WRITE(numout,*) ' '
+         WRITE(numout,*) 'trd_mld_bio : write ML bio trends in the NetCDF file :'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '          ', TRIM(clhstnam), ' at kt = ', kt
+         WRITE(numout,*) '          N.B. nmoymltrdbio = ', nmoymltrdbio
+         WRITE(numout,*) ' '
+      END IF
+
+
+      ! 2. Start writing data
+      ! ---------------------
+
+      NETCDF_OUTPUT : IF( ln_trdmld_trc_instant ) THEN    ! <<< write the trends for passive tracer instant. diags
+         !
+            DO jl = 1, jpdiabio
+               CALL histwrite( nidtrdbio,TRIM("ML_"//ctrd_bio(jl,2)) ,            &
+                    &          it, tmltrd_bio(:,:,jl), ndimtrd1, ndextrd1 )
+            END DO
+
+
+         IF( kt == nitend )   CALL histclo( nidtrdbio )
+
+      ELSE    ! <<< write the trends for passive tracer mean diagnostics
+
+            DO jl = 1, jpdiabio
+               CALL histwrite( nidtrdbio, TRIM("ML_"//ctrd_bio(jl,2)) ,            &
+                    &          it, ztmltrdbio2(:,:,jl), ndimtrd1, ndextrd1 )
+            END DO
+
+            IF( kt == nitend )   CALL histclo( nidtrdbio )
+            !
+      END IF NETCDF_OUTPUT
+
+      ! Compute the control surface (for next time step) : flag = on
+      icountbio = 1
+
+
+# endif /* key_dimgout */
+
+      IF( MOD( itmod, ntrd_trc ) == 0 ) THEN
+         !
+         ! III.5 Reset cumulative arrays to zero
+         ! -------------------------------------
+         nmoymltrdbio = 0
+         tmltrd_csum_ln_bio (:,:,:) = 0.e0
+         tmltrd_sum_bio     (:,:,:) = 0.e0
+      END IF
+
+      ! ======================================================================
+      ! Write restart file
+      ! ======================================================================
+
+! restart write is done in trd_mld_trc_write which is called by trd_mld_bio (Marina)
+!
+#endif
+   END SUBROUTINE trd_mld_bio
+
+   REAL FUNCTION sum2d( ztab )
+      !!----------------------------------------------------------------------
+      !! CD ??? prevoir d'utiliser plutot prtctl
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( in ) ::  ztab      
+      !!----------------------------------------------------------------------
+      sum2d = SUM(ztab(2:jpi-1,2:jpj-1))
+   END FUNCTION sum2d
+
+   SUBROUTINE trd_mld_trc_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trd_mld_init  ***
+      !! 
+      !! ** Purpose :   computation of vertically integrated T and S budgets
+      !!      from ocean surface down to control surface (NetCDF output)
+      !!
+      !! ** Method/usage :
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER :: inum   ! logical unit
+      INTEGER :: ilseq, jl, jn
+      REAL(wp) ::   zjulian, zsto, zout
+      CHARACTER (LEN=40) ::   clop, cleiv
+      CHARACTER (LEN=15) ::   csuff
+      CHARACTER (LEN=12) ::   clmxl
+      CHARACTER (LEN=16) ::   cltrcu
+      CHARACTER (LEN= 5) ::   clvar
+
+      NAMELIST/namtoptrd/ ntrd_trc, nctls_trc, ucf_trc, &
+                          ln_trdmld_trc_restart, ln_trdmld_trc_instant, luttrd
+
+      !!----------------------------------------------------------------------
+
+      ! ======================================================================
+      ! I. initialization
+      ! ======================================================================
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' trd_mld_trc_init : Mixed-layer trends for passive tracers                '
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
+         WRITE(numout,*)
+      ENDIF
+
+      
+      ! I.1 Check consistency of user defined preferences
+      ! -------------------------------------------------
+#if defined key_trcldf_eiv
+      IF( lk_trdmld_trc .AND. ln_trcldf_iso ) THEN
+         WRITE(numout,cform_war)
+         WRITE(numout,*) '                You asked for ML diagnostics with iso-neutral diffusion   '
+         WRITE(numout,*) '                and eiv physics.                                          '
+         WRITE(numout,*) '                Yet, key_diaeiv is NOT switched on, so the eddy induced   '
+         WRITE(numout,*) '                velocity is not diagnosed.                                '
+         WRITE(numout,*) '                Therefore, we cannot deduce the eiv advective trends.     '
+         WRITE(numout,*) '                Only THE SUM of the i,j,k directional contributions then  '
+         WRITE(numout,*) '                makes sense => To avoid any confusion, we choosed to mask '
+         WRITE(numout,*) '                these i,j,k directional contributions (with -999.)        '
+         nwarn = nwarn + 1
+      ENDIF
+#  endif
+
+      IF( ( lk_trdmld_trc ) .AND. ( MOD( nitend, ntrd_trc ) /= 0 ) ) THEN
+         WRITE(numout,cform_err)
+         WRITE(numout,*) '                Your nitend parameter, nitend = ', nitend
+         WRITE(numout,*) '                is no multiple of the trends diagnostics frequency        '
+         WRITE(numout,*) '                          you defined, ntrd_trc   = ', ntrd_trc
+         WRITE(numout,*) '                This will not allow you to restart from this simulation.  '
+         WRITE(numout,*) '                You should reconsider this choice.                        ' 
+         WRITE(numout,*) 
+         WRITE(numout,*) '                N.B. the nitend parameter is also constrained to be a     '
+         WRITE(numout,*) '                multiple of the sea-ice frequency parameter (typically 5) '
+         nstop = nstop + 1
+      ENDIF
+
+      IF( ( lk_trdmld_trc ) .AND. ( n_cla == 1 ) ) THEN
+         WRITE(numout,cform_war)
+         WRITE(numout,*) '                You set n_cla = 1. Note that the Mixed-Layer diagnostics  '
+         WRITE(numout,*) '                are not exact along the corresponding straits.            '
+         nwarn = nwarn + 1
+      ENDIF
+
+
+      ! * Debugging information *
+      IF( lldebug ) THEN
+         WRITE(numout,*) '               ln_trcadv_muscl = '      , ln_trcadv_muscl
+         WRITE(numout,*) '               ln_trcadv_smolar = '     , ln_trcadv_smolar
+         WRITE(numout,*) '               ln_trdmld_trc_instant = ', ln_trdmld_trc_instant
+      ENDIF
+
+      IF( ln_trcadv_smolar .AND. .NOT. ln_trdmld_trc_instant ) THEN
+         WRITE(numout,cform_err)
+         WRITE(numout,*) '                Currently, you can NOT use simultaneously tracer Smolark. '
+         WRITE(numout,*) '                advection and window averaged diagnostics of ML trends.   '
+         WRITE(numout,*) '                WHY? Everything in trdmld_trc is coded for leap-frog, and '
+         WRITE(numout,*) '                Smolarkiewicz scheme is Euler forward.                    '
+         WRITE(numout,*) '                In particuliar, entrainment trend would be FALSE. However '
+         WRITE(numout,*) '                this residual is correct for instantaneous ML diagnostics.'
+         WRITE(numout,*) 
+         nstop = nstop + 1
+      ENDIF
+
+      IF( ln_trcadv_muscl .AND. .NOT. ln_trdmld_trc_instant ) THEN
+         WRITE(numout,cform_err)
+         WRITE(numout,*) '                Currently, you can NOT use simultaneously tracer MUSCL    '
+         WRITE(numout,*) '                advection and window averaged diagnostics of ML trends.   '
+         WRITE(numout,*) '                WHY? Everything in trdmld_trc is coded for leap-frog, and '
+         WRITE(numout,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
+         WRITE(numout,*) '                that MUSCL is leap-frog for active tracers T/S).          '
+         WRITE(numout,*) '                In particuliar, entrainment trend would be FALSE. However '
+         WRITE(numout,*) '                this residual is correct for instantaneous ML diagnostics.'
+         WRITE(numout,*) 
+         nstop = nstop + 1
+      ENDIF
+
+      IF( ln_trcadv_muscl2 .AND. .NOT. ln_trdmld_trc_instant ) THEN
+         WRITE(numout,cform_err)
+         WRITE(numout,*) '                Currently, you can NOT use simultaneously tracer MUSCL2    '
+         WRITE(numout,*) '                advection and window averaged diagnostics of ML trends.   '
+         WRITE(numout,*) '                WHY? Everything in trdmld_trc is coded for leap-frog, and '
+         WRITE(numout,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
+         WRITE(numout,*) '                that MUSCL is leap-frog for active tracers T/S).          '
+         WRITE(numout,*) '                In particuliar, entrainment trend would be FALSE. However '
+         WRITE(numout,*) '                this residual is correct for instantaneous ML diagnostics.'
+         WRITE(numout,*) 
+         nstop = nstop + 1
+      ENDIF
+
+      ! I.2 Initialize arrays to zero or read a restart file
+      ! ----------------------------------------------------
+      nmoymltrd   = 0
+
+      rmld_trc           (:,:)     = 0.e0   ;   tml_trc            (:,:,:)   = 0.e0       ! inst.
+      tmltrdm_trc        (:,:,:)   = 0.e0   ;   tmlatfm_trc        (:,:,:)   = 0.e0
+      tmlradm_trc        (:,:,:)   = 0.e0
+
+      tml_sum_trc        (:,:,:)   = 0.e0   ;   tmltrd_sum_trc     (:,:,:,:) = 0.e0       ! mean
+      tmltrd_csum_ln_trc (:,:,:,:) = 0.e0   ;   rmld_sum_trc       (:,:)     = 0.e0
+
+#if defined key_lobster
+      nmoymltrdbio   = 0
+      tmltrd_sum_bio     (:,:,:) = 0.e0     ;   tmltrd_csum_ln_bio (:,:,:) = 0.e0
+      DO jl = 1, jp_lobster_trd
+          ctrd_bio(jl,1) = ctrbil(jl)   ! long name
+          ctrd_bio(jl,2) = ctrbio(jl)   ! short name
+       ENDDO
+#endif
+
+      IF( ln_rsttr .AND. ln_trdmld_trc_restart ) THEN
+         CALL trd_mld_trc_rst_read
+      ELSE
+         tmlb_trc           (:,:,:)   = 0.e0   ;   tmlbb_trc          (:,:,:)   = 0.e0     ! inst.
+         tmlbn_trc          (:,:,:)   = 0.e0
+
+         tml_sumb_trc       (:,:,:)   = 0.e0   ;   tmltrd_csum_ub_trc (:,:,:,:) = 0.e0     ! mean
+         tmltrd_atf_sumb_trc(:,:,:)   = 0.e0   ;   tmltrd_rad_sumb_trc(:,:,:)   = 0.e0 
+#if defined key_lobster
+         tmltrd_csum_ub_bio (:,:,:) = 0.e0
+#endif
+
+       ENDIF
+
+      icount = 1   ;   ionce  = 1  ! open specifier   
+
+#if defined key_lobster
+      icountbio = 1   ;   ioncebio  = 1  ! open specifier
+#endif
+
+      ! I.3 Read control surface from file ctlsurf_idx
+      ! ----------------------------------------------
+      IF( nctls_trc == 1 ) THEN
+         CALL ctl_opn( inum, 'ctlsurf_idx', 'OLD', 'UNFORMATTED', 'SEQUENTIAL', -1, numout, lwp )
+         READ ( inum ) nbol_trc
+         CLOSE( inum )
+      ENDIF
+
+      ! ======================================================================
+      ! II. netCDF output initialization
+      ! ======================================================================
+
+#if defined key_dimgout 
+      ???
+#else
+      ! clmxl = legend root for netCDF output
+      IF( nctls_trc == 0 ) THEN                                   ! control surface = mixed-layer with density criterion
+         clmxl = 'Mixed Layer '
+      ELSE IF( nctls_trc == 1 ) THEN                              ! control surface = read index from file 
+         clmxl = '      Bowl '
+      ELSE IF( nctls_trc >= 2 ) THEN                              ! control surface = model level
+         WRITE(clmxl,'(A10,I2,1X)') 'Levels 1 -', nctls_trc
+      ENDIF
+
+      ! II.1 Define frequency of output and means
+      ! -----------------------------------------
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#  if defined key_diainstant
+      IF( .NOT. ln_trdmld_trc_instant ) THEN
+         STOP 'trd_mld_trc : this was never checked. Comment this line to proceed...'
+      ENDIF
+      zsto = ntrd_trc * rdt
+      clop = "inst("//TRIM(clop)//")"
+#  else
+      IF( ln_trdmld_trc_instant ) THEN
+         zsto = rdt                                               ! inst. diags : we use IOIPSL time averaging
+      ELSE
+         zsto = ntrd_trc * rdt                                    ! mean  diags : we DO NOT use any IOIPSL time averaging
+      ENDIF
+      clop = "ave("//TRIM(clop)//")"
+#  endif
+      zout = ntrd_trc * rdt
+
+      IF(lwp) WRITE (numout,*) '                netCDF initialization'
+
+      ! II.2 Compute julian date from starting date of the run
+      ! ------------------------------------------------------
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      IF(lwp) WRITE(numout,*)' '  
+      IF(lwp) WRITE(numout,*)' Date 0 used :', nit000                  &
+           &   ,' YEAR ', nyear, ' MONTH ', nmonth,' DAY ', nday       &
+           &   ,'Julian day : ', zjulian
+
+      ! II.3 Define the T grid trend file (nidtrd)
+      ! ------------------------------------------
+
+      !-- Define long and short names for the NetCDF output variables
+      !       ==> choose them according to trdmld_trc_oce.F90 <==
+
+#if defined key_diaeiv
+      cleiv = " (*** only total EIV is meaningful ***)"           ! eiv advec. trends require u_eiv, v_eiv
+#else
+      cleiv = " "
+#endif
+      ctrd_trc(jpmld_trc_xad    ,1) = " Zonal advection"                 ;   ctrd_trc(jpmld_trc_xad    ,2) = "_xad"
+      ctrd_trc(jpmld_trc_yad    ,1) = " Meridional advection"            ;   ctrd_trc(jpmld_trc_yad    ,2) = "_yad"
+      ctrd_trc(jpmld_trc_zad    ,1) = " Vertical advection"              ;   ctrd_trc(jpmld_trc_zad    ,2) = "_zad"
+      ctrd_trc(jpmld_trc_ldf    ,1) = " Lateral diffusion"               ;   ctrd_trc(jpmld_trc_ldf    ,2) = "_ldf"
+      ctrd_trc(jpmld_trc_zdf    ,1) = " Vertical diff. (Kz)"             ;   ctrd_trc(jpmld_trc_zdf    ,2) = "_zdf"
+      ctrd_trc(jpmld_trc_xei    ,1) = " Zonal EIV advection"//cleiv      ;   ctrd_trc(jpmld_trc_xei    ,2) = "_xei"
+      ctrd_trc(jpmld_trc_yei    ,1) = " Merid. EIV advection"//cleiv     ;   ctrd_trc(jpmld_trc_yei    ,2) = "_yei"
+      ctrd_trc(jpmld_trc_zei    ,1) = " Vertical EIV advection"//cleiv   ;   ctrd_trc(jpmld_trc_zei    ,2) = "_zei"
+      ctrd_trc(jpmld_trc_bbc    ,1) = " Geothermal flux"                 ;   ctrd_trc(jpmld_trc_bbc    ,2) = "_bbc"
+      ctrd_trc(jpmld_trc_bbl    ,1) = " Adv/diff. Bottom boundary layer" ;   ctrd_trc(jpmld_trc_bbl    ,2) = "_bbl"
+      ctrd_trc(jpmld_trc_dmp    ,1) = " Tracer damping"                  ;   ctrd_trc(jpmld_trc_dmp    ,2) = "_dmp"
+      ctrd_trc(jpmld_trc_sbc    ,1) = " Surface boundary cond."          ;   ctrd_trc(jpmld_trc_sbc    ,2) = "_sbc"
+      ctrd_trc(jpmld_trc_sms,    1) = " Sources minus sinks"             ;   ctrd_trc(jpmld_trc_sms    ,2) = "_sms"
+      ctrd_trc(jpmld_trc_radb   ,1) = " Correct negative concentrations" ;   ctrd_trc(jpmld_trc_radb   ,2) = "_radb"
+      ctrd_trc(jpmld_trc_radn   ,1) = " Correct negative concentrations" ;   ctrd_trc(jpmld_trc_radn   ,2) = "_radn"
+      ctrd_trc(jpmld_trc_atf    ,1) = " Asselin time filter"             ;   ctrd_trc(jpmld_trc_atf    ,2) = "_atf"
+      ctrd_trc(jpltrd_trc+1     ,1) = " Total EIV"//cleiv                ;   ctrd_trc(jpltrd_trc+1     ,2) = "_tei"
+
+      DO jn = 1, jptra      
+      !-- Create a NetCDF file and enter the define mode 
+         IF( luttrd(jn) ) THEN
+            csuff="ML_"//ctrcnm(jn)
+            CALL dia_nam( clhstnam, ntrd_trc, csuff )
+            CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,                                            &
+               &        1, jpi, 1, jpj, nittrc000-ndttrc, zjulian, rdt, nh_t(jn), nidtrd(jn), domain_id=nidom )
+      
+            !-- Define the ML depth variable
+            CALL histdef(nidtrd(jn), "mxl_depth", clmxl//" Mixed Layer Depth", "m",                        &
+               &        jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+
+         ENDIF
+      END DO
+
+#if defined key_lobster
+          !-- Create a NetCDF file and enter the define mode
+          CALL dia_nam( clhstnam, ntrd_trc, 'trdbio' )
+          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,                                            &
+             &             1, jpi, 1, jpj, nittrc000-ndttrc, zjulian, rdt, nh_tb, nidtrdbio, domain_id=nidom )
+#endif
+
+      !-- Define physical units
+      IF( ucf_trc == 1. ) THEN
+         cltrcu = "(mmole-N/m3)/sec"                              ! all passive tracers have the same unit 
+      ELSEIF ( ucf_trc == 3600.*24.) THEN                         ! ??? trop long : seulement (mmole-N/m3)
+         cltrcu = "(mmole-N/m3)/day"                              ! ??? apparait dans les sorties netcdf 
+      ELSE
+         cltrcu = "unknown?"
+      ENDIF
+
+      !-- Define miscellaneous passive tracer mixed-layer variables 
+      IF( jpltrd_trc /= jpmld_trc_atf .OR.  jpltrd_trc - 1 /= jpmld_trc_radb ) THEN
+         STOP 'Error : jpltrd_trc /= jpmld_trc_atf .OR.  jpltrd_trc - 1 /= jpmld_trc_radb'  ! see below
+      ENDIF
+
+      DO jn = 1, jptra
+         !
+         IF( luttrd(jn) ) THEN
+            clvar = trim(ctrcnm(jn))//"ml"                           ! e.g. detml, zooml, no3ml, etc.
+            CALL histdef(nidtrd(jn), clvar,           clmxl//" "//trim(ctrcnm(jn))//" Mixed Layer ",                         &
+              & "mmole-N/m3", jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zsto, zout )           
+            CALL histdef(nidtrd(jn), clvar//"_tot"  , clmxl//" "//trim(ctrcnm(jn))//" Total trend ",                         & 
+              &       cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zout, zout ) 
+            CALL histdef(nidtrd(jn), clvar//"_res"  , clmxl//" "//trim(ctrcnm(jn))//" dh/dt Entrainment (Resid.)",           & 
+              &       cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zout, zout )                   
+         
+            DO jl = 1, jpltrd_trc - 2                                ! <== only true if jpltrd_trc == jpmld_trc_atf
+               CALL histdef(nidtrd(jn), trim(clvar//ctrd_trc(jl,2)), clmxl//" "//clvar//ctrd_trc(jl,1),                      & 
+                 &    cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zsto, zout ) ! IOIPSL: time mean
+            END DO                                                                         ! if zsto=rdt above
+         
+            CALL histdef(nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_radb,2)), clmxl//" "//clvar//ctrd_trc(jpmld_trc_radb,1), & 
+              &       cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zout, zout ) ! IOIPSL: NO time mean
+         
+            CALL histdef(nidtrd(jn), trim(clvar//ctrd_trc(jpmld_trc_atf,2)), clmxl//" "//clvar//ctrd_trc(jpmld_trc_atf,1),   & 
+              &       cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zout, zout ) ! IOIPSL: NO time mean
+         
+            CALL histdef(nidtrd(jn), trim(clvar//ctrd_trc(jpltrd_trc+1,2)),  clmxl//" "//clvar//ctrd_trc(jpltrd_trc+1 ,1),   & 
+              &       cltrcu, jpi, jpj, nh_t(jn), 1  , 1, 1  , -99 , 32, clop, zsto, zout ) ! Total EIV 
+         !
+         ENDIF
+      END DO
+
+#if defined key_lobster
+      DO jl = 1, jp_lobster_trd
+         CALL histdef(nidtrdbio, TRIM("ML_"//ctrd_bio(jl,2)), TRIM(clmxl//" ML_"//ctrd_bio(jl,1))   ,            &
+             &    cltrcu, jpi, jpj, nh_tb, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) ! IOIPSL: time mean
+      END DO                                                                         ! if zsto=rdt above
+#endif
+
+      !-- Leave IOIPSL/NetCDF define mode
+      DO jn = 1, jptra
+         IF( luttrd(jn) )  CALL histend( nidtrd(jn) )
+      END DO
+
+#if defined key_lobster
+      !-- Leave IOIPSL/NetCDF define mode
+      CALL histend( nidtrdbio )
+
+      IF(lwp) WRITE(numout,*)
+       IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization for ML bio trends'
+#endif
+
+#endif        /* key_dimgout */
+   END SUBROUTINE trd_mld_trc_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                       Empty module
+   !!----------------------------------------------------------------------
+
+   INTERFACE trd_mod_trc
+      MODULE PROCEDURE trd_mod_trc_trp, trd_mod_trc_bio
+   END INTERFACE
+
+CONTAINS
+
+   SUBROUTINE trd_mld_trc( kt )                                   ! Empty routine
+      INTEGER, INTENT( in) ::   kt
+      WRITE(*,*) 'trd_mld_trc: You should not have seen this print! error?', kt
+   END SUBROUTINE trd_mld_trc
+
+   SUBROUTINE trd_mld_bio( kt )
+      INTEGER, INTENT( in) ::   kt
+      WRITE(*,*) 'trd_mld_bio: You should not have seen this print! error?', kt
+   END SUBROUTINE trd_mld_bio
+
+   SUBROUTINE trd_mod_trc_bio( ptrbio, ktrd, kt )
+      INTEGER               , INTENT( in )     ::   kt      ! time step
+      INTEGER               , INTENT( in )     ::   ktrd    ! bio trend index
+      REAL, DIMENSION(:,:,:), INTENT( inout )  ::   ptrbio  ! Bio trend
+      WRITE(*,*) 'trd_mod_trc_bio : You should not have seen this print! error?', ptrbio(1,1,1)
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', ktrd
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', kt
+   END SUBROUTINE trd_mod_trc_bio
+
+   SUBROUTINE trd_mod_trc_trp( ptrtrd, kjn, ktrd, kt )
+      INTEGER               , INTENT( in )     ::   kt      ! time step
+      INTEGER               , INTENT( in )     ::   kjn     ! tracer index
+      INTEGER               , INTENT( in )     ::   ktrd    ! tracer trend index
+      REAL, DIMENSION(:,:,:), INTENT( inout )  ::   ptrtrd  ! Temperature or U trend
+      WRITE(*,*) 'trd_mod_trc_trp : You should not have seen this print! error?', ptrtrd(1,1,1)
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', kjn
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', ktrd
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', kt
+   END SUBROUTINE trd_mod_trc_trp
+
+   SUBROUTINE trd_mld_trc_zint( ptrc_trdmld, ktrd, ctype, kjn )
+      INTEGER               , INTENT( in ) ::  ktrd, kjn              ! ocean trend index and passive tracer rank
+      CHARACTER(len=2)      , INTENT( in ) ::  ctype                  ! surface/bottom (2D) or interior (3D) physics
+      REAL, DIMENSION(:,:,:), INTENT( in ) ::  ptrc_trdmld            ! passive trc trend
+      WRITE(*,*) 'trd_mld_trc_zint: You should not have seen this print! error?', ptrc_trdmld(1,1,1)
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', ctype
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', ktrd
+      WRITE(*,*) '  "      "      : You should not have seen this print! error?', kjn
+   END SUBROUTINE trd_mld_trc_zint
+
+   SUBROUTINE trd_mld_trc_init                                    ! Empty routine
+      WRITE(*,*) 'trd_mld_trc_init: You should not have seen this print! error?'
+   END SUBROUTINE trd_mld_trc_init
+#endif
+
+   !!======================================================================
+END MODULE trdmld_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_oce.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_oce.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_oce.F90	(revision 1844)
@@ -0,0 +1,150 @@
+MODULE trdmld_trc_oce
+   !!======================================================================
+   !!                   ***  MODULE trdmld_trc_oce  ***
+   !! Ocean trends :   set tracer and momentum trend variables
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_oce.F90,v 1.2 2005/03/27 18:35:23 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+
+   USE par_oce                        ! ocean parameters
+   USE par_trc                        ! passive tracers parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!* Namelist namtoptrd:  diagnostics on passive tracers trends
+   INTEGER  ::    ntrd_trc                !: time step frequency dynamics and tracers trends
+   INTEGER  ::    nctls_trc               !: control surface type for trends vertical integration
+   REAL(wp) ::    ucf_trc                 !: unit conversion factor (for netCDF trends outputs)
+   LOGICAL  ::    ln_trdmld_trc_instant   !: flag to diagnose inst./mean ML trc trends
+   LOGICAL  ::    ln_trdmld_trc_restart   !: flag to restart mixed-layer trc diagnostics
+   CHARACTER(len=50) ::  cn_trdrst_trc_in  !: suffix of pass. tracer restart name (input)
+   CHARACTER(len=50) ::  cn_trdrst_trc_out !: suffix of pass. tracer restart name (output)
+   LOGICAL, DIMENSION (jptra) ::   luttrd   !: large trends diagnostic to write or not (namelist)
+
+   !!* Passive tracers trends indexes
+   INTEGER, PARAMETER ::   jptrc_trd_xad     =  1   !: x- horizontal advection
+   INTEGER, PARAMETER ::   jptrc_trd_yad     =  2   !: y- horizontal advection
+   INTEGER, PARAMETER ::   jptrc_trd_zad     =  3   !: z- vertical   advection
+   INTEGER, PARAMETER ::   jptrc_trd_ldf     =  4   !: lateral       diffusion
+   INTEGER, PARAMETER ::   jptrc_trd_zdf     =  5   !: vertical diffusion (Kz)
+   INTEGER, PARAMETER ::   jptrc_trd_xei     =  6   !: x- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_trd_yei     =  7   !: y- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_trd_zei     =  8   !: z- vert.  EIV advection
+   INTEGER, PARAMETER ::   jptrc_trd_bbc     =  9   !: Bottom Boundary Condition (geoth. flux)
+   INTEGER, PARAMETER ::   jptrc_trd_bbl     = 10   !: Bottom Boundary Layer (diffusive/convective)
+   INTEGER, PARAMETER ::   jptrc_trd_dmp     = 11   !: damping
+   INTEGER, PARAMETER ::   jptrc_trd_sbc     = 12   !: surface boundary condition
+   INTEGER, PARAMETER ::   jptrc_trd_sms     = 13   !: sources m. sinks
+   INTEGER, PARAMETER ::   jptrc_trd_radn    = 14   !: corr. trn<0 in trcrad
+   INTEGER, PARAMETER ::   jptrc_trd_radb    = 15   !: corr. trb<0 in trcrad (like atf)
+   INTEGER, PARAMETER ::   jptrc_trd_atf     = 16   !: Asselin correction
+
+#if defined key_trdmld_trc
+   !!----------------------------------------------------------------------
+   !!   'key_trdmld_trc'                     mixed layer trends diagnostics
+   !!----------------------------------------------------------------------
+
+   LOGICAL, PARAMETER ::   lk_trdmld_trc = .TRUE.    !: ML trend flag
+   LOGICAL, PARAMETER ::   l_trdtrc = .TRUE.         !: passive tracers trend flag
+
+   INTEGER, PARAMETER ::            & !: mixed layer trends indices
+        jpmld_trc_xad     =  1,     & !:     zonal      \
+        jpmld_trc_yad     =  2,     & !:     meridonal   > advection
+        jpmld_trc_zad     =  3,     & !:     vertical   /
+        jpmld_trc_ldf     =  4,     & !:     lateral diffusion (geopot. or iso-neutral)
+        jpmld_trc_zdf     =  5,     & !:     vertical diffusion (TKE)
+        jpmld_trc_xei     =  6,     & !:     zonal      \
+        jpmld_trc_yei     =  7,     & !:     meridional  > eddy induced advection
+        jpmld_trc_zei     =  8,     & !:     vertical   / 
+        jpmld_trc_bbc     =  9,     & !:     geothermal flux
+        jpmld_trc_bbl     = 10,     & !:     bottom boundary layer (advective/diffusive)
+        jpmld_trc_dmp     = 11,     & !:     internal restoring trend
+        jpmld_trc_sbc     = 12,     & !:     forcing 
+        jpmld_trc_sms     = 13,     & !:     sources minus sinks trend
+  !     jpmld_trc_xxx     = xx,     & !:     add here any additional trend    (** AND UPDATE JPLTRD_TRC BELOW **)
+        jpmld_trc_radn    = 14,     & !:     corr. trn<0 in trcrad
+        jpmld_trc_radb    = 15,     & !:     corr. trb<0 in trcrad (like atf) (** MUST BE BEFORE THE LAST ONE **)
+        jpmld_trc_atf     = 16        !:     asselin trend                    (** MUST BE    THE      LAST ONE**)
+
+   !! Trends diagnostics parameters
+   !!---------------------------------------------------------------------
+   INTEGER, PARAMETER ::            &
+      jpltrd_trc = 16,                  & !: number of mixed-layer trends arrays
+      jpktrd_trc = jpk                    !: max level for mixed-layer trends diag.
+
+   !! Arrays used for diagnosing mixed-layer trends 
+   !!---------------------------------------------------------------------
+   CHARACTER(LEN=80) :: clname_trc, ctrd_trc(jpltrd_trc+1,2)
+
+   INTEGER, DIMENSION(jpi,jpj) ::   &
+      nmld_trc       , &                            !: mixed layer depth indexes 
+      nbol_trc                                   !: mixed-layer depth indexes when read from file
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk) ::  wkx_trc  !:
+
+   REAL(wp), DIMENSION(jpi,jpj) ::  rmld_trc     !: ML depth (m) corresponding to nmld_trc
+   REAL(wp), DIMENSION(jpi,jpj) ::  rmld_sum_trc !: needed to compute the leap-frog time mean of ML depth
+   REAL(wp), DIMENSION(jpi,jpj) ::  rmldbn_trc   !: idem
+
+   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &
+      tml_trc    ,                        &      !: \ "now" mixed layer temperature/salinity
+      tmlb_trc   ,                        &      !: /  and associated "before" fields
+      tmlbb_trc  ,                        &      !: \  idem, but valid at the 1rst time step of the
+      tmlbn_trc  ,                        &      !: /  current analysis window
+      tml_sum_trc,                        &      !: mixed layer T, summed over the current analysis period
+      tml_sumb_trc,                       &      !: idem, but from the previous analysis period
+      tmltrd_atf_sumb_trc,                &      !: Asselin trends, summed over the previous analysis period
+      tmltrd_rad_sumb_trc                        !: trends due to trb correction in trcrad.F90, summed over the
+                                                 !:     previous analysis period
+                                                 
+   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &      
+      tmlatfb_trc, tmlatfn_trc ,          &      !: "before" Asselin contrib. at beginning of the averaging
+                                                 !:     period (i.e. last contrib. from previous such period)
+                                                 !:     and "now" Asselin contrib. to the ML trc. trends
+      tmlatfm_trc,                        &      !: accumulator for Asselin trends (needed for storage only)
+      tmlradb_trc, tmlradn_trc ,          &      !: similar to Asselin above, but for the trend due to trb
+                                                 !:     correction in trcrad.F90
+      tmlradm_trc                                !: accumulator for the previous trcrad trend
+
+   REAL(wp), DIMENSION(jpi,jpj,jpltrd_trc,jptra) ::  &
+      tmltrd_trc,                         &      !: \ physical contributions to the total trend (for T/S),
+                                                 !: / cumulated over the current analysis window
+      tmltrd_sum_trc,                     &      !: sum of these trends over the analysis period
+      tmltrd_csum_ln_trc,                 &      !: now cumulated sum of trends over the "lower triangle"
+      tmltrd_csum_ub_trc                         !: before (prev. analysis period) cumulated sum over the
+                                                 !: upper triangle
+   REAL(wp), DIMENSION(jpi,jpj,jptra) ::  &
+      tmltrdm_trc                                !: total cumulative trends over the analysis window
+
+#else
+   LOGICAL, PARAMETER ::   lk_trdmld_trc = .FALSE.   !: ML trend flag
+   LOGICAL, PARAMETER ::   l_trdtrc = .FALSE.             !: passive tracers trend flag
+#endif
+
+#if defined key_lobster
+   CHARACTER(LEN=80) :: clname_bio, ctrd_bio(jpdiabio,2)
+   REAL(wp), DIMENSION(jpi,jpj,jpdiabio) ::  &
+      tmltrd_bio,                         &      !: \ biological contributions to the total trend ,
+                                                 !: / cumulated over the current analysis window
+      tmltrd_sum_bio,                     &      !: sum of these trends over the analysis period
+      tmltrd_csum_ln_bio,                 &      !: now cumulated sum of trends over the "lower triangle"
+      tmltrd_csum_ub_bio                         !: before (prev. analysis period) cumulated sum over the
+                                                 !: upper triangle
+#endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+#endif
+
+
+END MODULE trdmld_trc_oce
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_rst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_rst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trdmld_trc_rst.F90	(revision 1844)
@@ -0,0 +1,221 @@
+MODULE trdmld_trc_rst
+   !!======================================================================
+   !!                       ***  MODULE  trdmld_rst  ***
+   !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
+   !!======================================================================
+   !! History :  9.0  ! 07-03 (C. Deltel) Original code
+   !!----------------------------------------------------------------------
+  
+#if defined key_top && defined key_trdmld_trc
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE trc             ! for ndttrc ctrcnm
+   USE trdmld_trc_oce  ! for lk_trdmld_trc
+
+   IMPLICIT NONE
+   PRIVATE
+  
+   PUBLIC   trd_mld_trc_rst_read    ! routine called by trd_mld_init
+   PUBLIC   trd_mld_trc_rst_write   ! routine called by step.F90
+  
+   INTEGER ::   nummldw_trc               ! logical unit for mld restart
+   !!---------------------------------------------------------------------------------
+   !! OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_rst.F90,v 1.6 2006/11/14 09:46:13 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!---------------------------------------------------------------------------------
+  
+CONTAINS
+  
+
+    SUBROUTINE trd_mld_trc_rst_write( kt )
+      !!--------------------------------------------------------------------------------
+      !!                  ***  SUBROUTINE trd_mld_rst_wri  ***
+      !!                
+      !! ** Purpose :   Write mixed-layer diagnostics restart fields.
+      !!--------------------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
+      !
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      CHARACTER (len=35) :: charout
+      INTEGER :: jl,  jk, jn               ! loop indice
+      !!--------------------------------------------------------------------------------
+
+      IF( kt == nitrst - ndttrc .OR. nitend - nit000 + 1 < 2 * ndttrc ) THEN ! idem trcrst.F90
+         IF( nitrst > 1.0e9 ) THEN
+            WRITE(clkt,*) nitrst
+         ELSE
+           WRITE(clkt,'(i8.8)') nitrst
+         ENDIF
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trdrst_trc_out)
+         IF(lwp) WRITE(numout,*) '             open ocean restart_mld_trc NetCDF  '//clname
+         CALL iom_open( clname, nummldw_trc, ldwrt = .TRUE., kiolib = jprstlib )
+      ENDIF
+
+      IF( kt == nitend .AND. lk_trdmld_trc ) THEN
+
+         IF( kt == nitend .AND. lwp ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'trdmld_trc_rst: output for ML diags. restart, with trd_mld_trc_rst_write routine'
+            WRITE(numout,*) '~~~~~~~~~~~~~~'
+            WRITE(numout,*)
+         ENDIF
+
+         IF( ln_trdmld_trc_instant ) THEN 
+            !
+            DO jn = 1, jptra
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbb_trc_'  //ctrcnm(jn), tmlbb_trc  (:,:,jn) )
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbn_trc_'  //ctrcnm(jn), tmlbn_trc  (:,:,jn) )
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlatfb_trc_'//ctrcnm(jn), tmlatfb_trc(:,:,jn) )
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlradb_trc_'//ctrcnm(jn), tmlradb_trc(:,:,jn) )
+            END DO
+            !
+         ELSE
+            !
+            CALL iom_rstput( kt, nitrst, nummldw_trc, 'rmldbn_trc', rmldbn_trc )  ! 2D x 1
+            
+            !                                                          ! ===========
+            DO jn = 1, jptra                                           ! tracer loop
+               !                                                       ! ===========
+
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlatfb_trc_' //ctrcnm(jn), tmlatfb_trc (:,:,jn) ) ! 2D x jptra
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbb_trc_'   //ctrcnm(jn), tmlbb_trc   (:,:,jn) ) ! 2D x jptra
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlradb_trc_' //ctrcnm(jn), tmlradb_trc (:,:,jn) ) ! 2D x jptra
+
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbn_trc_'   //ctrcnm(jn), tmlbn_trc   (:,:,jn) ) ! 2D x jptra
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tml_sumb_trc_'//ctrcnm(jn), tml_sumb_trc(:,:,jn) ) ! 2D x jptra
+               
+               DO jk = 1, jpltrd_trc
+                  IF( jk < 10 )   THEN
+                     WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I1)") ctrcnm(jn), jk
+                  ELSE
+                     WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I2)") ctrcnm(jn), jk
+                  ENDIF
+                  CALL iom_rstput( kt, nitrst, nummldw_trc, charout, tmltrd_csum_ub_trc(:,:,jk,jn) )
+               END DO
+               
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_atf_sumb_trc_'//ctrcnm(jn) , &
+                    &           tmltrd_atf_sumb_trc(:,:,jn) ) ! 2D x jptra
+
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_rad_sumb_trc_'//ctrcnm(jn) , &
+                    &           tmltrd_rad_sumb_trc(:,:,jn) ) ! 2D x jptra
+               !                                                       ! ===========
+            END DO                                                     ! tracer loop
+            !                                                          ! ===========
+#if defined key_lobster
+            DO jl = 1, jp_lobster_trd
+               CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_csum_ub_bio'//ctrd_bio(jl,2), tmltrd_csum_ub_bio(:,:,jl) )
+            ENDDO
+#endif
+
+         ENDIF
+         
+         CALL iom_close( nummldw_trc )
+         lrst_trc = .TRUE.
+
+      ENDIF
+
+    END SUBROUTINE trd_mld_trc_rst_write
+
+
+    SUBROUTINE trd_mld_trc_rst_read
+      !!----------------------------------------------------------------------------
+      !!                   ***  SUBROUTINE trd_mld_rst_lec  ***
+      !!                   
+      !! ** Purpose :   Read file for mixed-layer diagnostics restart.
+      !!----------------------------------------------------------------------------
+      INTEGER  ::  inum       ! temporary logical unit
+      !
+      CHARACTER (len=35) :: charout
+      INTEGER ::  jk, jn, jl     ! loop indice
+      INTEGER ::  jlibalt = jprstlib
+      LOGICAL ::  llok
+      !!-----------------------------------------------------------------------------
+      
+      IF(lwp)  THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' trd_mld_trc_rst_read : read the NetCDF MLD restart file'
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~'
+      ENDIF
+      
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if {cn_trdrst_trc_in}.nc exists, then set jlibalt to jpnf90
+        INQUIRE( FILE = TRIM(cn_trdrst_trc_in)//'.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
+      ENDIF
+
+      CALL iom_open( cn_trdrst_trc_in, inum, kiolib = jlibalt ) 
+      
+      IF( ln_trdmld_trc_instant ) THEN 
+         
+         DO jn = 1, jptra
+            CALL iom_get( inum, jpdom_autoglo, 'tmlbb_trc_'  //ctrcnm(jn), tmlbb_trc  (:,:,jn) )
+            CALL iom_get( inum, jpdom_autoglo, 'tmlbn_trc_'  //ctrcnm(jn), tmlbn_trc  (:,:,jn) )
+            CALL iom_get( inum, jpdom_autoglo, 'tmlatfb_trc_'//ctrcnm(jn), tmlatfb_trc(:,:,jn) )
+            CALL iom_get( inum, jpdom_autoglo, 'tmlradb_trc_'//ctrcnm(jn), tmlradb_trc(:,:,jn) )
+         END DO
+         
+      ELSE
+         CALL iom_get( inum, jpdom_autoglo, 'rmldbn_trc', rmldbn_trc ) ! needed for rmld_sum
+         
+         !                                                          ! ===========
+         DO jn = 1, jptra                                           ! tracer loop
+            !                                                       ! ===========
+            CALL iom_get( inum, jpdom_autoglo, 'tmlatfb_trc_' //ctrcnm(jn), tmlatfb_trc(:,:,jn) )
+            CALL iom_get( inum, jpdom_autoglo, 'tmlbb_trc_'   //ctrcnm(jn), tmlbb_trc  (:,:,jn) )
+            CALL iom_get( inum, jpdom_autoglo, 'tmlradb_trc_' //ctrcnm(jn), tmlradb_trc(:,:,jn) )
+
+            CALL iom_get( inum, jpdom_autoglo, 'tmlbn_trc_'   //ctrcnm(jn), tmlbn_trc   (:,:,jn) ) ! needed for tml_sum
+            CALL iom_get( inum, jpdom_autoglo, 'tml_sumb_trc_'//ctrcnm(jn), tml_sumb_trc(:,:,jn) )
+            
+            DO jk = 1, jpltrd_trc
+               IF( jk < 10 )   THEN
+                  WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I1)") ctrcnm(jn), jk
+               ELSE
+                  WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I2)") ctrcnm(jn), jk
+               ENDIF
+               CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub_trc(:,:,jk,jn) )
+            END DO
+            
+            CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb_trc_'//ctrcnm(jn) , &
+                 &        tmltrd_atf_sumb_trc(:,:,jn) )
+
+            CALL iom_get( inum, jpdom_autoglo, 'tmltrd_rad_sumb_trc_'//ctrcnm(jn) , &
+                 &        tmltrd_rad_sumb_trc(:,:,jn) )
+            !                                                       ! ===========
+         END DO                                                     ! tracer loop
+         !                                                          ! ===========
+
+#if defined key_lobster
+         DO jl = 1, jp_lobster_trd
+            CALL iom_get( inum, jpdom_autoglo, 'tmltrd_csum_ub_bio'//ctrd_bio(jl,2), tmltrd_csum_ub_bio(:,:,jl) )
+         ENDDO
+#endif
+         
+         CALL iom_close( inum )
+      ENDIF
+      
+    END SUBROUTINE trd_mld_trc_rst_read
+  
+#else
+  !!=================================================================================
+  !!                       ***  MODULE  trdmld_rst  ***
+  !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
+  !!=================================================================================
+CONTAINS
+  SUBROUTINE trd_mld_trc_rst_opn( kt )
+    WRITE(*,*) 'trd_mld_trc_rst_opn: You should not have seen this print! error?', kt
+  END SUBROUTINE trd_mld_trc_rst_opn
+  SUBROUTINE trd_mld_trc_rst_write( kt )           !  No ML diags ==> empty routine
+    WRITE(*,*) 'trd_mld_trc_rst_wri: You should not have seen this print! error?', kt
+  END SUBROUTINE trd_mld_trc_rst_write
+  SUBROUTINE trd_mld_trc_rst_read                  !  No ML Diags ==> empty routine
+  END SUBROUTINE trd_mld_trc_rst_read
+#endif
+
+  !!=================================================================================
+END MODULE trdmld_trc_rst
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trp_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trp_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/trp_trc.F90	(revision 1844)
@@ -0,0 +1,76 @@
+MODULE trp_trc
+   !!======================================================================
+   !!                         ***  MODULE trp_trc  ***
+   !! TOP :   TOP parameters used in TRP
+   !!======================================================================
+   !! History :   1.0  !  2004-03 (C. Ethe) original code
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE par_trc
+
+   !! passive tracers fields 
+   USE trc, ONLY :   trai      =>   trai     !: initial total tracer
+   USE trc, ONLY :   trb       =>   trb      !: tracer field (before)
+   USE trc, ONLY :   tra       =>   tra      !: tracer field (now)
+   USE trc, ONLY :   trn       =>   trn      !: tracer field (after)
+
+   !! Ocean volume
+   USE trc, ONLY :   cvol      =>   cvol     !: masked grid volume
+
+   !! time step
+   USE trc, ONLY :   ndttrc    =>   ndttrc   !: frequency of step on passive tracers (NAMELIST)
+   USE trc, ONLY :   ctrcnm    =>   ctrcnm   !: 
+   USE trc, ONLY :   numnat    =>   numnat   !: namelist
+   USE trc, ONLY :   nittrc000 =>   nittrc000
+   USE trc, ONLY :   lrst_trc  =>   lrst_trc  !: logical to control the trc restart write
+
+   !! isopycnal scheme for passive tracers
+   !! ------------------------------------  
+   REAL(wp), PUBLIC ::   ahtrb0     !: background diffusivity coefficient for passive tracer (m2/s)
+   REAL(wp), PUBLIC ::   trcrat     !: ratio between passive and active tracer coeff for diffusion
+   REAL(wp), PUBLIC ::   ahtrc0     !: horizontal eddy diffusivity for passive tracers (m2/s)
+   REAL(wp), PUBLIC ::   aeivtr0    !: eddy induced velocity coefficient (m2/s)
+
+   !! interpolated gradient
+   !!--------------------------------------------------  
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jptra) ::   gtru   !: horizontal gradient at u-points at bottom ocean level
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jptra) ::   gtrv   !: horizontal gradient at v-points at bottom ocean level
+
+   
+# if defined key_trcldf_eiv && defined key_diaeiv
+   !! The three component of the eddy induced velocity
+   !! --------------------------------------------------
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) ::   u_trc_eiv   !: u-eiv (m/s)
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) ::   v_trc_eiv   !: v-eiv (m/s)
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) ::   w_trc_eiv   !: w-eiv (m/s)
+# endif
+
+# if defined key_trc_diatrd
+
+   !!  non conservative trends (biological, ...)
+   !! --------------------------------------------------
+   !!  Advection-diffusion trends
+   REAL(wp), PUBLIC, DIMENSION(:,:,:,:,:), ALLOCATABLE ::   trtrd   !: trends of the tracer equations
+
+   INTEGER, PUBLIC, DIMENSION(jptra) :: ikeep ! indice of tracer for which dyn trends are stored
+   INTEGER, PUBLIC                   :: nkeep ! number of tracers for which dyn trends are stored
+   !                                          ! (used to allocate trtrd buffer)
+
+   INTEGER , PUBLIC ::   nwritetrd   !: frequency of additional arrays outputs(namelist)
+# endif
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE trp_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/zpshde_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/zpshde_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/TRP/zpshde_trc.F90	(revision 1844)
@@ -0,0 +1,201 @@
+MODULE zpshde_trc
+   !!==============================================================================
+   !!                       ***  MODULE zpshde_trc   ***
+   !! Ocean passive tracers: 
+   !!==============================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!                  z-coordinate with partial steps
+   !!----------------------------------------------------------------------
+   !!   zps_hde_trc  :  Horizontal DErivative of passive tracers at the last
+   !!                   ocean level (Z-coord. with Partial Steps)
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc         ! ocean dynamics and tracers variables
+   USE trp_trc             ! ocean passive tracers variables
+   USE lbclnk          ! lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC zps_hde_trc          ! routine called by step.F90
+
+   !! * module variables
+   INTEGER, DIMENSION(jpi,jpj) ::   &
+      mbatu, mbatv      ! bottom ocean level index at U- and V-points
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE zps_hde_trc ( kt, ptra, pgtru, pgtrv )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE zps_hde_trc  ***
+      !!                    
+      !! ** Purpose :   Compute the horizontal derivative of passive tracers
+      !!      TRA at u- and v-points with a linear interpolation for z-coordinate
+      !!      with partial steps.
+      !!
+      !! ** Method  :   In z-coord with partial steps, scale factors on last 
+      !!      levels are different for each grid point, so that TRA points 
+      !!      are not at the same depth as in z-coord. To have horizontal
+      !!      gradients again, we interpolate TRA at the good depth : 
+      !!      Linear interpolation of TRA  
+      !!         Computation of di(trb) and dj(trb) by vertical interpolation:
+      !!          di(tra) = tra~ - tra(i,j,k) or tra(i+1,j,k) - tra~
+      !!          dj(tra) = tra~ - tra(i,j,k) or tra(i,j+1,k) - tra~
+      !!         This formulation computes the two cases:
+      !!                 CASE 1                   CASE 2  
+      !!         k-1  ___ ___________   k-1   ___ ___________
+      !!                  TRAi  TRA~             TRA~  TRAi+1
+      !!                  _____                        _____
+      !!         k        |   |TRAi+1   k         TRAi |   |
+      !!                  |   |____                ____|   |
+      !!              ___ |   |   |           ___  |   |   |
+      !!                  
+      !!      case 1->   e3w(i+1) >= e3w(i) ( and e3w(j+1) >= e3w(j) ) then
+      !!      tra~ = tra(i+1,j  ,k) + (e3w(i+1) - e3w(i)) * dk(TRAi+1)/e3w(i+1)
+      !!    ( tra~ = tra(i  ,j+1,k) + (e3w(j+1) - e3w(j)) * dk(TRAj+1)/e3w(j+1))
+      !!          or
+      !!      case 2->   e3w(i+1) <= e3w(i) ( and e3w(j+1) <= e3w(j) ) then
+      !!       tra~ = tra(i,j,k) + (e3w(i) - e3w(i+1)) * dk(TRAi)/e3w(i )
+      !!     ( tra~ = tra(i,j,k) + (e3w(j) - e3w(j+1)) * dk(TRAj)/e3w(j ) )
+      !!      
+      !!
+      !! ** Action  : - pgtru : horizontal gradient of TRA at U-points 
+      !!              - pgtrv : horizontal gradient of TRA at V-points 
+      !!
+      !! History :
+      !!   8.5  !  02-04  (A. Bozec)  Original code
+      !!   8.5  !  02-08  (G. Madec E. Durand)  Optimization and Free form
+      !!   9.0  !  04-03  (C. Ethe)  adapted for passive tracers
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   kt ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra), INTENT( in ) ::   &
+         ptra                       ! 4D tracers fields
+      REAL(wp), DIMENSION(jpi,jpj,jptra), INTENT( out ) ::   &
+         pgtru,                 &  ! horizontal grad. of TRA u- and v-points 
+         pgtrv                     ! of the partial step level
+
+      !! * Local declarations
+      INTEGER ::   ji, jj,jn,     &  ! Dummy loop indices
+                   iku,ikv          ! partial step level at u- and v-points
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         zti, ztj                   ! tempory arrays
+
+      REAL(wp), DIMENSION(jpi,jpj,jptra) ::   &
+         ztrai, ztraj               ! interpolated value of TRA
+
+      REAL(wp) ::   &
+         ze3wu, ze3wv,           &  ! temporary scalars
+         zmaxu1, zmaxu2,         &  !    "         "
+         zmaxv1, zmaxv2             !    "         "
+      !!----------------------------------------------------------------------
+
+      ! Initialization (first time-step only): compute mbatu and mbatv
+      IF( kt == nittrc000 ) THEN
+         mbatu(:,:) = 0
+         mbatv(:,:) = 0
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               mbatu(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji+1,jj  ) ) - 1, 2 )
+               mbatv(ji,jj) = MAX( MIN( mbathy(ji,jj), mbathy(ji  ,jj+1) ) - 1, 2 )
+            END DO
+         END DO
+         zti(:,:) = FLOAT( mbatu(:,:) )
+         ztj(:,:) = FLOAT( mbatv(:,:) )
+         ! lateral boundary conditions: T-point, sign unchanged
+         CALL lbc_lnk( zti , 'U', 1. )
+         CALL lbc_lnk( ztj , 'V', 1. )
+         mbatu(:,:) = MAX( INT( zti(:,:) ), 2 )
+         mbatv(:,:) = MAX( INT( ztj(:,:) ), 2 )
+      ENDIF
+      
+
+      DO jn = 1, jptra
+         ! Interpolation of passive tracers at the last ocean level
+# if defined key_vectopt_loop
+         jj = 1
+         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
+# else
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+# endif
+               ! last level
+               iku = mbatu(ji,jj)
+               ikv = mbatv(ji,jj)
+
+               ze3wu  = fse3w(ji+1,jj  ,iku) - fse3w(ji,jj,iku)
+               ze3wv  = fse3w(ji  ,jj+1,ikv) - fse3w(ji,jj,ikv)
+               zmaxu1 =  ze3wu / fse3w(ji+1,jj  ,iku)
+               zmaxu2 = -ze3wu / fse3w(ji  ,jj  ,iku)
+               zmaxv1 =  ze3wv / fse3w(ji  ,jj+1,ikv)
+               zmaxv2 = -ze3wv / fse3w(ji  ,jj  ,ikv)
+
+               ! i- direction
+
+               IF( ze3wu >= 0. ) THEN      ! case 1
+                  ! interpolated values of passive tracers
+                  ztrai(ji,jj,jn) = ptra(ji+1,jj,iku,jn) + zmaxu1 * ( ptra(ji+1,jj,iku-1,jn) - ptra(ji+1,jj,iku,jn) )
+                  ! gradient of passive tracers
+                  pgtru(ji,jj,jn) = umask(ji,jj,1) * ( ztrai(ji,jj,jn) - ptra(ji,jj,iku,jn) )
+               ELSE                        ! case 2
+                  ! interpolated values of passive tracers
+                  ztrai(ji,jj,jn) = ptra(ji,jj,iku,jn) + zmaxu2 * ( ptra(ji,jj,iku-1,jn) - ptra(ji,jj,iku,jn) )
+                  ! gradient of passive tracers
+                  pgtru(ji,jj,jn) = umask(ji,jj,1) * ( ptra(ji+1,jj,iku,jn) - ztrai (ji,jj,jn) )
+               ENDIF
+
+               ! j- direction
+
+               IF( ze3wv >= 0. ) THEN      ! case 1
+                  ! interpolated values of passive tracers
+                  ztraj(ji,jj,jn) = ptra(ji,jj+1,ikv,jn) + zmaxv1 * ( ptra(ji,jj+1,ikv-1,jn) - ptra(ji,jj+1,ikv,jn) )
+                  ! gradient of passive tracers
+                  pgtrv(ji,jj,jn) = vmask(ji,jj,1) * ( ztraj(ji,jj,jn) - ptra(ji,jj,ikv,jn) )
+               ELSE                        ! case 2
+                  ! interpolated values of passive tracers
+                  ztraj(ji,jj,jn) = ptra(ji,jj,ikv,jn) + zmaxv2 * ( ptra(ji,jj,ikv-1,jn) - ptra(ji,jj,ikv,jn) )
+                  ! gradient of passive tracers
+                  pgtrv(ji,jj,jn) = vmask(ji,jj,1) * ( ptra(ji,jj+1,ikv,jn) - ztraj(ji,jj,jn) )
+               ENDIF
+# if ! defined key_vectopt_loop
+            END DO
+# endif
+         END DO
+
+         ! Lateral boundary conditions on each gradient
+         CALL lbc_lnk( pgtru(:,:,jn) , 'U', -1. ) 
+         CALL lbc_lnk( pgtrv(:,:,jn) , 'V', -1. )
+
+      END DO
+
+   END SUBROUTINE zps_hde_trc
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                         Empty module
+   !!----------------------------------------------------------------------
+   USE par_kind
+CONTAINS
+   SUBROUTINE zps_hde_trc ( kt, ptra, pgtru, pgtrv ) ! Empty routine
+      INTEGER, INTENT( in) :: kt
+      REAL(wp), DIMENSION(:,:,:,:) :: ptra
+      REAL(wp) :: pgtru, pgtrv
+      WRITE(*,*) 'zps_hde_trc: You should not have seen this print! error?',   &
+         kt, ptra, pgtru, pgtrv
+   END SUBROUTINE zps_hde_trc
+#endif
+
+   !!======================================================================
+END MODULE zpshde_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/oce_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/oce_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/oce_trc.F90	(revision 1844)
@@ -0,0 +1,248 @@
+MODULE oce_trc
+   !!======================================================================
+   !!                      ***  MODULE  oce_trc  ***
+   !! TOP :   variables shared between ocean and passive tracers
+   !!======================================================================
+   !! History :   1.0  !  2004-03  (C. Ethe)  original code
+   !!             2.0  !  2007-12 (C. Ethe, G. Madec)  rewritting
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0,  LOCEAN-IPSL (2007)
+   !! $Id$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+
+   !* Domain size *
+   USE par_oce , ONLY :   cp_cfg   =>   cp_cfg     !: name of the configuration
+   USE par_oce , ONLY :   jp_cfg   =>   jp_cfg     !: resolution of the configuration
+   USE par_oce , ONLY :   jpiglo   =>   jpiglo     !: first  dimension of global domain --> i
+   USE par_oce , ONLY :   jpjglo   =>   jpjglo     !: second dimension of global domain --> j
+   USE par_oce , ONLY :   jpi      =>   jpi        !: first  dimension of grid --> i 
+   USE par_oce , ONLY :   jpj      =>   jpj        !: second dimension of grid --> j  
+   USE par_oce , ONLY :   jpk      =>   jpk        !: number of levels  
+   USE par_oce , ONLY :   jpim1    =>   jpim1      !: jpi - 1
+   USE par_oce , ONLY :   jpjm1    =>   jpjm1      !: jpj - 1 
+   USE par_oce , ONLY :   jpkm1    =>   jpkm1      !: jpk - 1  
+   USE par_oce , ONLY :   jpij     =>   jpij       !: jpi x jpj
+   USE par_oce , ONLY :   jpidta   =>   jpidta     !: first horizontal dimension  > or = jpi
+   USE par_oce , ONLY :   jpjdta   =>   jpjdta     !: second horizontal dimension > or = jpj
+   USE par_oce , ONLY :   jpkdta   =>   jpkdta     !: number of levels            > or = jpk
+   USE par_oce , ONLY :   lk_esopa =>   lk_esopa   !: flag to activate the all option
+
+   !* IO manager *
+   USE in_out_manager      ! use all the variables
+   !* physical constants *
+   USE phycst              ! use all the variables
+
+   !* model domain *
+   USE dom_oce , ONLY :   lzoom      => lzoom        !: zoom flag
+   USE dom_oce , ONLY :   lzoom_e    => lzoom_e      !: East  zoom type flag
+   USE dom_oce , ONLY :   lzoom_w    => lzoom_w      !: West  zoom type flag
+   USE dom_oce , ONLY :   lzoom_s    => lzoom_s      !: South zoom type flag
+   USE dom_oce , ONLY :   lzoom_n    => lzoom_n      !: North zoom type flag
+   USE dom_oce , ONLY :   lzoom_arct => lzoom_arct   !: ORCA    arctic zoom flag
+   USE dom_oce , ONLY :   lzoom_anta => lzoom_anta   !: ORCA antarctic zoom flag
+   USE dom_oce , ONLY :   nperio     =>   nperio     !: type of lateral boundary condition       
+   USE dom_oce , ONLY :   nimpp      =>   nimpp      !: i index for mpp-subdomain left bottom
+   USE dom_oce , ONLY :   njmpp      =>   njmpp      !: j index for mpp-subdomain left bottom
+   USE dom_oce , ONLY :   nproc      =>   nproc      !: number for local processor
+   USE dom_oce , ONLY :   narea      =>   narea      !: number for local area
+   USE dom_oce , ONLY :   mig        =>   mig        !: local  ==> global  domain i-indice
+   USE dom_oce , ONLY :   mjg        =>   mjg        !: local  ==> global  domain i-indice
+   USE dom_oce , ONLY :   mi0        =>   mi0        !: global ==> local domain i-indice 
+   USE dom_oce , ONLY :   mi1        =>   mi1        !: (mi0=1 and mi1=0 if the global indice is not in the local one)
+   USE dom_oce , ONLY :   mj0        =>   mj0        !: global ==> local domain j-indice 
+   USE dom_oce , ONLY :   mj1        =>   mj1        !: (mj0=1 and mj1=0 if the global indice is not in the local one)
+   USE dom_oce , ONLY :   nidom      =>   nidom
+   USE dom_oce , ONLY :   nimppt     => nimppt     !:i-indexes for each processor
+   USE dom_oce , ONLY :   njmppt     => njmppt       !:j-indexes for each processor
+   USE dom_oce , ONLY :   ibonit     => ibonit       !:i-processor neighbour existence
+   USE dom_oce , ONLY :   ibonjt     => ibonjt       !:j- processor neighbour existence 
+   USE dom_oce , ONLY :   nlci       => nlci         !:i- & j-dimensions of the local subdomain
+   USE dom_oce , ONLY :   nlcj       => nlcj         !:
+   USE dom_oce , ONLY :   nldi       => nldi         !:first and last indoor i- and j-indexes
+   USE dom_oce , ONLY :   nlei       => nlei         !:
+   USE dom_oce , ONLY :   nldj       => nldj         !:
+   USE dom_oce , ONLY :   nlej       => nlej         !:
+   USE dom_oce , ONLY :   nlcit      => nlcit        !:dimensions of every i-subdomain
+   USE dom_oce , ONLY :   nlcjt      => nlcjt        !:dimensions of every j-subdomain
+   USE dom_oce , ONLY :   nldit      => nldit        !:first indoor index for each i-domain 
+   USE dom_oce , ONLY :   nleit      => nleit        !:last indoor index for each i-domain 
+   USE dom_oce , ONLY :   nldjt      => nldjt        !:first indoor index for each j-domain 
+   USE dom_oce , ONLY :   nlejt      => nlejt        !:last indoor index for each j-domain 
+ 
+   !* horizontal mesh *
+   USE dom_oce , ONLY :   glamt      =>   glamt      !: longitude of t-point (degre)  
+   USE dom_oce , ONLY :   glamu      =>   glamu      !: longitude of t-point (degre)  
+   USE dom_oce , ONLY :   glamv      =>   glamv      !: longitude of t-point (degre)  
+   USE dom_oce , ONLY :   glamf      =>   glamf      !: longitude of t-point (degre)  
+   USE dom_oce , ONLY :   gphit      =>   gphit      !: latitude  of t-point (degre)   
+   USE dom_oce , ONLY :   gphiu      =>   gphiu      !: latitude  of t-point (degre)   
+   USE dom_oce , ONLY :   gphiv      =>   gphiv      !: latitude  of t-point (degre)   
+   USE dom_oce , ONLY :   gphif      =>   gphif      !: latitude  of t-point (degre)   
+   USE dom_oce , ONLY :   e1t        =>   e1t        !: horizontal scale factors at t-point (m)  
+   USE dom_oce , ONLY :   e2t        =>   e2t        !: horizontal scale factors at t-point (m)   
+   USE dom_oce , ONLY :   e1u        =>   e1u        !: horizontal scale factors at u-point (m)
+   USE dom_oce , ONLY :   e2u        =>   e2u        !: horizontal scale factors at u-point (m)
+   USE dom_oce , ONLY :   e1v        =>   e1v        !: horizontal scale factors at v-point (m)
+   USE dom_oce , ONLY :   e2v        =>   e2v        !: horizontal scale factors at v-point (m)  
+
+   !* vertical mesh *
+   USE dom_oce , ONLY :   gdept_0    =>   gdept_0    !: reference depth of t-points (m)
+   USE dom_oce , ONLY :   e3t_0      =>   e3t_0      !: reference depth of t-points (m)  
+   USE dom_oce , ONLY :   e3w_0      =>   e3w_0      !: reference depth of w-points (m)
+   USE dom_oce , ONLY :   gdepw_0    =>   gdepw_0    !: reference depth of w-points (m)
+# if ! defined key_zco
+   USE dom_oce , ONLY :   gdep3w     =>  gdep3w      !: ???
+   USE dom_oce , ONLY :   gdept      =>  gdept       !: depth of t-points (m)
+   USE dom_oce , ONLY :   gdepw      =>  gdepw       !: depth of t-points (m)
+   USE dom_oce , ONLY :   e3t        =>  e3t         !: vertical scale factors at t-
+   USE dom_oce , ONLY :   e3u        =>  e3u         !: vertical scale factors at u-
+   USE dom_oce , ONLY :   e3v        =>  e3v         !: vertical scale factors v-
+   USE dom_oce , ONLY :   e3w        =>  e3w         !: w-points (m)
+   USE dom_oce , ONLY :   e3f        =>  e3f         !: f-points (m)
+   USE dom_oce , ONLY :   e3uw       =>  e3uw        !: uw-points (m)
+   USE dom_oce , ONLY :   e3vw       =>  e3vw        !: vw-points (m)
+# endif
+   USE dom_oce , ONLY :   ln_zps     =>  ln_zps      !: partial steps flag
+   USE dom_oce , ONLY :   ln_sco     =>  ln_sco      !: s-coordinate flag
+   USE dom_oce , ONLY :   ln_zco     =>  ln_zco      !: z-coordinate flag
+   USE dom_oce , ONLY :   lk_zco     =>  lk_zco      !: z-coordinate flag (1D or 3D arrays)
+   USE dom_oce , ONLY :   hbatt      =>   hbatt      !: ocean depth at the vertical of  t-point (m)
+   USE dom_oce , ONLY :   hbatu      =>   hbatu      !: ocean depth at the vertical of  u-point (m)
+   USE dom_oce , ONLY :   hbatv      =>   hbatv      !: ocean depth at the vertical of w-point (m)
+   USE dom_oce , ONLY :   gsigt      =>   gsigt      !: model level depth coefficient at T-levels
+   USE dom_oce , ONLY :   gsigw      =>   gsigw      !: model level depth coefficient at W-levels
+   USE dom_oce , ONLY :   gsi3w      =>   gsi3w      !: model level depth coef at w-levels (defined as the sum of e3w)
+   USE dom_oce , ONLY :   esigt      =>   esigt      !: vertical scale factor coef. at t-levels
+   USE dom_oce , ONLY :   esigw      =>   esigw      !: vertical scale factor coef. at w-levels
+   USE dom_oce , ONLY :   lk_vvl     => lk_vvl       !: variable grid flag
+
+   !* masks, bathymetry *
+   USE dom_oce , ONLY :   mbathy     =>   mbathy     !: number of ocean level (=0,  & 1, ... , jpk-1) 
+   USE dom_oce , ONLY :   tmask_i    =>   tmask_i    !: Interior mask at t-points
+   USE dom_oce , ONLY :   tmask      =>   tmask      !: land/ocean mask at t-points
+   USE dom_oce , ONLY :   umask      =>   umask      !: land/ocean mask at u-points   
+   USE dom_oce , ONLY :   vmask      =>   vmask      !: land/ocean mask at v-points 
+   USE dom_oce , ONLY :   fmask      =>   fmask      !: land/ocean mask at f-points 
+# if defined key_off_degrad
+   USE dom_oce , ONLY :   facvol     =>   facvol     !: volume factor for degradation
+# endif
+
+   !* time domain *
+   USE dom_oce , ONLY :   neuler     =>   neuler     !: restart euler forward option (0=Euler)
+   USE dom_oce , ONLY :   rdt        =>   rdt        !: time step for the dynamics 
+   USE dom_oce , ONLY :   atfp       =>   atfp       !: asselin time filter parameter
+   USE dom_oce , ONLY :   atfp1      =>   atfp1      !: asselin time filter coeff. (atfp1= 1-2*atfp)
+   USE dom_oce , ONLY :   rdttra     =>   rdttra     !: vertical profile of tracer time step
+   !                                                 !: it is the accumulated duration of previous runs
+   !                                                 !: that may have been run with different time steps.
+   !* calendar variables *
+   USE dom_oce , ONLY :   nyear      =>   nyear      !: current year
+   USE dom_oce , ONLY :   nmonth     =>   nmonth     !: current month
+   USE dom_oce , ONLY :   nday       =>   nday       !: current day of the month
+   USE dom_oce , ONLY :   ndastp     =>   ndastp     !: time step date in yyyymmdd format
+   USE dom_oce , ONLY :   nday_year  =>   nday_year  !: current day counted from jan 1st of the current year
+   USE dom_oce , ONLY :   nsec_year  =>   nsec_year  !: current time step counted in second since 00h jan 1st of the current year
+   USE dom_oce , ONLY :   nsec_month =>   nsec_month !: current time step counted in second since 00h 1st day of the current month
+   USE dom_oce , ONLY :   nsec_day   =>   nsec_day   !: current time step counted in second since 00h of the current day
+   USE dom_oce , ONLY :   fjulday    =>   fjulday    !: julian day
+   USE dom_oce , ONLY :   adatrj     =>   adatrj     !: number of elapsed days since the begining of the whole simulation
+                                                     !: (cumulative duration of previous runs 
+                                                     !: that may have used different time-step size)
+   USE dom_oce , ONLY :   nyear_len  =>   nyear_len  !: length in days of the previous/current year
+   USE dom_oce , ONLY :   nmonth_len =>   nmonth_len !: length in days of the months of the current year
+
+
+   !* ocean fields: here now and after fields *
+   USE oce , ONLY :   ua      =>    ua      !: i-horizontal velocity (m s-1) 
+   USE oce , ONLY :   va      =>    va      !: j-horizontal velocity (m s-1)
+   USE oce , ONLY :   un      =>    un      !: i-horizontal velocity (m s-1) 
+   USE oce , ONLY :   vn      =>    vn      !: j-horizontal velocity (m s-1)
+   USE oce , ONLY :   wn      =>    wn      !: vertical velocity (m s-1)  
+   USE oce , ONLY :   tn      =>    tn      !: pot. temperature (celsius)
+   USE oce , ONLY :   sn      =>    sn      !: salinity (psu)
+   USE oce , ONLY :   rhop    =>    rhop    !: potential volumic mass (kg m-3) 
+   USE oce , ONLY :   rhd     =>    rhd     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE oce , ONLY :   hdivn   =>    hdivn   !: horizontal divergence (1/s)
+#if defined key_off_tra
+   USE oce , ONLY :   gtu     =>    gtu     !: t-, s- and rd horizontal gradient at u- and
+   USE oce , ONLY :   gsu     =>    gsu     !: v-points at bottom ocean level
+   USE oce , ONLY :   gru     =>    gru     !:
+   USE oce , ONLY :   gtv     =>    gtv     !:
+   USE oce , ONLY :   gsv     =>    gsv     !:
+   USE oce , ONLY :   grv     =>    grv     !: 
+#endif
+   USE lib_mpp , ONLY :   lk_mpp    =>  lk_mpp       !: Mpp flag
+
+   USE dom_oce , ONLY :   n_cla     =>   n_cla         !: flag (0/1) for cross land advection 
+
+   !* surface fluxes *
+   USE sbc_oce , ONLY :   utau       =>    utau       !: i-surface stress component
+   USE sbc_oce , ONLY :   vtau       =>    vtau       !: j-surface stress component
+   USE sbc_oce , ONLY :   wndm       =>    wndm       !: 10m wind speed 
+   USE sbc_oce , ONLY :   qsr        =>    qsr        !: penetrative solar radiation (w m-2)  
+   USE sbc_oce , ONLY :   emp        =>    emp        !: evaporation minus precipitation (kg m-2 s-2) 
+   USE sbc_oce , ONLY :   emps       =>    emps       !: evaporation minus precipitation (kg m-2 s-2)
+   USE sbc_oce , ONLY :   fr_i       =>    fr_i       !: ice fraction (between 0 to 1)
+   USE traqsr  , ONLY :   rn_abs     =>    rn_abs     !: fraction absorbed in the very near surface
+   USE traqsr  , ONLY :   rn_si0     =>    rn_si0     !: very near surface depth of extinction
+   USE traqsr  , ONLY :   rn_si2     =>    rn_si2     !: deepest depth of extinction (blue &  0.01 mg.m-3)     (RGB)
+   USE traqsr  , ONLY :   ln_qsr_bio =>    ln_qsr_bio !: flag to use or not the biological fluxes for light
+   USE sbcrnf  , ONLY :   rnfmsk     =>    rnfmsk     !: mixed adv scheme in runoffs vicinity (hori.) 
+   USE sbcrnf  , ONLY :   rnfmsk_z   =>    rnfmsk_z   !: mixed adv scheme in runoffs vicinity (vert.)
+
+   !* bottom boundary layer *
+# if   defined key_trabbl_dif   ||   defined key_trabbl_adv
+# if ! defined key_off_tra 
+   USE trabbl , ONLY :   atrbbl   =>   rn_ahtbbl     !: lateral coeff. for bottom boundary layer scheme (m2/s)
+# else 
+   USE trabbl, ONLY :   bblx   => bblx         !: ???
+   USE trabbl, ONLY :   bbly   => bbly         !: ???
+#  endif
+# endif
+
+   !* lateral diffusivity (tracers) *
+   USE ldftra_oce , ONLY :   aht0    =>   aht0     !: horizontal eddy diffusivity for tracers (m2/s)
+   USE ldftra_oce , ONLY :   ahtb0   =>   ahtb0    !: background eddy diffusivity for isopycnal diff. (m2/s)
+   USE ldftra_oce , ONLY :   ahtu    =>   ahtu     !: lateral diffusivity coef. at u-points 
+   USE ldftra_oce , ONLY :   ahtv    =>   ahtv     !: lateral diffusivity coef. at v-points 
+   USE ldftra_oce , ONLY :   ahtw    =>   ahtw     !: lateral diffusivity coef. at w-points 
+   USE ldftra_oce , ONLY :   ahtt    =>   ahtt     !: lateral diffusivity coef. at t-points
+   USE ldftra_oce , ONLY :   aeiv0   =>   aeiv0    !: eddy induced velocity coefficient (m2/s) 
+   USE ldftra_oce , ONLY :   aeiu    =>   aeiu     !: eddy induced velocity coef. at u-points (m2/s)   
+   USE ldftra_oce , ONLY :   aeiv    =>   aeiv     !: eddy induced velocity coef. at v-points (m2/s) 
+   USE ldftra_oce , ONLY :   aeiw    =>   aeiw     !: eddy induced velocity coef. at w-points (m2/s) 
+
+   !* vertical diffusion *
+   USE zdf_oce , ONLY :   avt        =>   avt         !: vert. diffusivity coef. at w-point for temp  
+# if defined key_zdfddm
+   USE zdfddm  , ONLY :   avs        =>    avs        !: salinity vertical diffusivity coeff. at w-point
+# endif
+
+   !* mixing & mixed layer depth *
+   USE zdfmxl , ONLY :   nmln        =>   nmln        !: number of level in the mixed layer
+   USE zdfmxl , ONLY :   hmld        =>   hmld        !: mixing layer depth (turbocline)
+   USE zdfmxl , ONLY :   hmlp        =>   hmlp        !: mixed layer depth  (rho=rho0+zdcrit) (m)
+   USE zdfmxl , ONLY :   hmlpt       =>   hmlpt       !: mixed layer depth at t-points (m)
+
+   !* direction of lateral diffusion *
+   USE ldfslp , ONLY :   lk_ldfslp  =>  lk_ldfslp     !: slopes flag
+# if   defined key_ldfslp
+   USE ldfslp , ONLY :   uslp       =>   uslp         !: i-direction slope at u-, w-points
+   USE ldfslp , ONLY :   vslp       =>   vslp         !: j-direction slope at v-, w-points
+   USE ldfslp , ONLY :   wslpi      =>   wslpi        !: i-direction slope at u-, w-points
+   USE ldfslp , ONLY :   wslpj      =>   wslpj        !: j-direction slope at v-, w-points
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE oce_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/par_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/par_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/par_trc.F90	(revision 1844)
@@ -0,0 +1,76 @@
+MODULE par_trc
+   !!======================================================================
+   !!                        ***  par_trc  ***
+   !! TOP :   set the passive tracers parameters
+   !!======================================================================
+   !! History :    -   !  1996-01  (M. Levy)  original code
+   !!              -   !  1999-07  (M. Levy)  for LOBSTER1 or NPZD model
+   !!              -   !  2000-04  (O. Aumont, M.A. Foujols)  HAMOCC3 and P3ZD
+   !!             1.0  !  2004-03  (C. Ethe) Free form and module
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_kind          ! kind parameters
+   !
+   USE par_lobster   ! LOBSTER model
+   USE par_pisces    ! PISCES  model
+   USE par_c14b      ! C14 bomb tracer
+   USE par_cfc       ! CFC 11 and 12 tracers
+   USE par_my_trc    ! user defined passive tracers
+
+   IMPLICIT NONE
+   PUBLIC
+
+   ! Passive tracers : Total size
+   ! ---------------               ! total number of passive tracers, of 2d and 3d output and trend arrays
+   INTEGER, PUBLIC, PARAMETER ::   jptra    =  jp_lobster    + jp_pisces     + jp_cfc     + jp_my_trc
+   INTEGER, PUBLIC, PARAMETER ::   jpdia2d  =  jp_lobster_2d + jp_pisces_2d  + jp_cfc_2d  + jp_my_trc_2d
+   INTEGER, PUBLIC, PARAMETER ::   jpdia3d  =  jp_lobster_3d + jp_pisces_3d  + jp_cfc_3d  + jp_my_trc_3d
+   !                     ! total number of sms diagnostic arrays
+   INTEGER, PUBLIC, PARAMETER ::   jpdiabio = jp_lobster_trd + jp_pisces_trd + jp_cfc_trd + jp_my_trc_trd
+   
+   !  1D configuration ("key_c1d")
+   ! -----------------
+# if defined key_c1d
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trc_c1d   = .TRUE.   !: 1D pass. tracer configuration flag
+# else   
+   LOGICAL, PUBLIC, PARAMETER ::   lk_trc_c1d   = .FALSE.  !: 1D pass. tracer configuration flag
+# endif
+   ! Passive tracers : size for TRP trends diagnotics (used if 'key_trc_diatrd' defined)
+# if defined key_trc_diatrd
+   ! Passive tracers : size for TRP trends diagnotics (used if 'key_trc_diatrd' defined)
+   INTEGER, PARAMETER ::   jptrc_xad     =  1   !: x- horizontal advection
+   INTEGER, PARAMETER ::   jptrc_yad     =  2   !: y- horizontal advection
+   INTEGER, PARAMETER ::   jptrc_zad     =  3   !: z- vertical   advection
+   INTEGER, PARAMETER ::   jptrc_xdf     =  4   !: lateral       diffusion
+   INTEGER, PARAMETER ::   jptrc_ydf     =  5   !: lateral       diffusion
+   INTEGER, PARAMETER ::   jptrc_zdf     =  6   !: vertical diffusion (Kz)
+   INTEGER, PARAMETER ::   jptrc_sbc     =  7   !: surface boundary condition
+#if ! defined key_trcldf_eiv && ! defined key_trcdmp
+   INTEGER, PARAMETER ::   jpdiatrc      =  7  !: trends: 3*(advection + diffusion       ) + sbc
+#endif
+#if defined key_trcldf_eiv && defined key_trcdmp
+   INTEGER, PARAMETER ::   jptrc_xei     =  8   !: x- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_yei     =  9   !: y- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_zei     = 10   !: z- vert.  EIV advection
+   INTEGER, PARAMETER ::   jptrc_dmp     = 11   !: damping
+   INTEGER, PARAMETER ::   jpdiatrc      = 11   !: trends: 3*(advection + diffusion + eiv ) + sbc + damping
+#endif
+#if defined key_trcldf_eiv && ! defined key_trcdmp
+   INTEGER, PARAMETER ::   jptrc_xei     =  8   !: x- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_yei     =  9   !: y- horiz. EIV advection
+   INTEGER, PARAMETER ::   jptrc_zei     = 10   !: z- vert.  EIV advection
+   INTEGER, PARAMETER ::   jpdiatrc      = 10   !: trends: 3*(advection + diffusion + eiv ) + sbc 
+#endif
+#if ! defined key_trcldf_eiv && defined key_trcdmp
+   INTEGER, PARAMETER ::   jptrc_dmp     =  8   !: damping
+   INTEGER, PARAMETER ::   jpdiatrc      =  8   !: trends: 3*(advection + diffusion       ) + sbc + damping
+#endif
+#endif
+
+   REAL(wp), PUBLIC  :: rtrn  = 1.e-15      !: truncation value     
+   !!======================================================================
+END MODULE par_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/prtctl_trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/prtctl_trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/prtctl_trc.F90	(revision 1844)
@@ -0,0 +1,470 @@
+MODULE prtctl_trc
+   !!======================================================================
+   !!                         ***  MODULE prtctl_trc  ***
+   !! TOP :   print all SUM trends for each processor domain
+   !!======================================================================
+   !! History :    -   !  2005-07  (C. Talandier) original code for OPA
+   !!             1.0  !  2005-10  (C. Ethe     ) adapted to passive tracer
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   prt_ctl_trc      :   control print in mpp for passive tracers
+   !!   prt_ctl_trc_info :   ???
+   !!   prt_ctl_trc_init :   ???
+   !!----------------------------------------------------------------------
+   USE par_trc          ! TOP parameters
+   USE oce_trc          ! ocean space and time domain variables
+   USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! distributed memory computing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   numid_trc          !: logical unit 
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   nlditl , nldjtl    !: first, last indoor index for each i-domain
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   nleitl , nlejtl    !: first, last indoor index for each j-domain
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   nimpptl, njmpptl   !: i-, j-indexes for each processor
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   nlcitl , nlcjtl    !: dimensions of every subdomain
+   INTEGER , DIMENSION(:), ALLOCATABLE ::   ibonitl, ibonjtl
+
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   tra_ctl         !: previous trend values
+
+   PUBLIC prt_ctl_trc         ! called by all subroutines
+   PUBLIC prt_ctl_trc_info    !
+   PUBLIC prt_ctl_trc_init    ! called by opa.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE prt_ctl_trc( tab4d, mask, clinfo, ovlap, kdim, clinfo2 )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl  ***
+      !!
+      !! ** Purpose : - print sum control 3D arrays over the same area 
+      !!                in mono and mpp case. This way can be usefull when
+      !!                debugging a new parametrization in mono or mpp. 
+      !!
+      !! ** Method  : 2 possibilities exist when setting the ln_ctl parameter to
+      !!                .true. in the ocean namelist:
+      !!              - to debug a MPI run .vs. a mono-processor one; 
+      !!                the control print will be done over each sub-domain.
+      !!                The nictl[se] and njctl[se] parameters in the namelist must 
+      !!                be set to zero and [ij]splt to the corresponding splitted
+      !!                domain in MPI along respectively i-, j- directions.
+      !!              - to debug a mono-processor run over the whole domain/a specific area; 
+      !!                in the first case the nictl[se] and njctl[se] parameters must be set
+      !!                to zero else to the indices of the area to be controled. In both cases
+      !!                isplt and jsplt must be set to 1.
+      !!              - All arguments of the above calling sequence are optional so their
+      !!                name must be explicitly typed if used. For instance if the mask
+      !!                array tmask(:,:,:) must be passed through the prt_ctl subroutine, 
+      !!                it must looks like: CALL prt_ctl( mask=tmask ).
+      !!----------------------------------------------------------------------
+      REAL(wp)         , DIMENSION(:,:,:,:), INTENT(in), OPTIONAL ::   tab4d     ! 4D array
+      REAL(wp)         , DIMENSION(:,:,:)  , INTENT(in), OPTIONAL ::   mask      ! 3D mask to apply to the tab4d array
+      CHARACTER (len=*), DIMENSION(:)      , INTENT(in), OPTIONAL ::   clinfo    ! information about the tab3d array
+      CHARACTER (len=*)                    , INTENT(in), OPTIONAL ::   clinfo2   ! ???
+      INTEGER                              , INTENT(in), OPTIONAL ::   ovlap     ! overlap value
+      INTEGER                              , INTENT(in), OPTIONAL ::   kdim      ! k- direction for 4D arrays
+      !!
+      INTEGER  ::   overlap, jn, js, sind, eind, kdir, j_id
+      REAL(wp) ::   zsum, zvctl
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask, ztab3d
+      CHARACTER (len=20), DIMENSION(jptra) ::   cl
+      CHARACTER (len=10) ::   cl2
+      !!----------------------------------------------------------------------
+
+      !                                      ! Arrays, scalars initialization 
+      overlap       = 0
+      kdir          = jpkm1
+      zsum          = 0.e0
+      zvctl         = 0.e0
+      cl(:)         = ''
+      cl2           = ''
+      ztab3d(:,:,:) = 0.e0
+      zmask (:,:,:) = 1.e0
+
+      !                                      ! Control of optional arguments
+      IF( PRESENT(ovlap)   )   overlap       = ovlap
+      IF( PRESENT(kdim)    )   kdir          = kdim
+      IF( PRESENT(clinfo ) )   cl(:)         = clinfo(:)
+      IF( PRESENT(clinfo2) )   cl2           = clinfo2
+      IF( PRESENT(mask)    )   zmask (:,:,:) = mask(:,:,:)
+
+      IF( lk_mpp )   THEN      ! processor number
+         sind = narea
+         eind = narea
+      ELSE                     ! processors total number
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. the total number of processors ijsplt
+      DO js = sind, eind
+         !
+         ! Set logical unit
+         j_id = numid_trc( js - narea + 1 )
+         ! Set indices for the SUM control
+         IF( .NOT. lsp_area ) THEN
+            IF (lk_mpp )   THEN
+               nictls = MAX( 1, nlditl(js) - overlap )
+               nictle = nleitl(js) + overlap * MIN( 1, nlcitl(js) - nleitl(js)) 
+               njctls = MAX( 1, nldjtl(js) - overlap )
+               njctle = nlejtl(js) + overlap * MIN( 1, nlcjtl(js) - nlejtl(js))
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(js) == -1 .OR. ibonitl(js) == 2 )   nictls = MAX( 2, nictls )
+               IF( ibonitl(js) ==  1 .OR. ibonitl(js) == 2 )   nictle = MIN( nictle, nleitl(js) - 1 )
+               IF( ibonjtl(js) == -1 .OR. ibonjtl(js) == 2 )   njctls = MAX( 2, njctls )
+               IF( ibonjtl(js) ==  1 .OR. ibonjtl(js) == 2 )   njctle = MIN( njctle, nlejtl(js) - 1 )
+            ELSE
+               nictls = MAX( 1, nimpptl(js) + nlditl(js) - 1 - overlap )
+               nictle = nimpptl(js) + nleitl(js) - 1 + overlap * MIN( 1, nlcitl(js) - nleitl(js) ) 
+               njctls = MAX( 1, njmpptl(js) + nldjtl(js) - 1 - overlap )
+               njctle = njmpptl(js) + nlejtl(js) - 1 + overlap * MIN( 1, nlcjtl(js) - nlejtl(js) ) 
+               ! Do not take into account the bound of the domain
+               IF( ibonitl(js) == -1 .OR. ibonitl(js) == 2 )   nictls = MAX( 2, nictls )
+               IF( ibonjtl(js) == -1 .OR. ibonjtl(js) == 2 )   njctls = MAX( 2, njctls )
+               IF( ibonitl(js) ==  1 .OR. ibonitl(js) == 2 )   nictle = MIN( nictle, nimpptl(js) + nleitl(js) - 2 )
+               IF( ibonjtl(js) ==  1 .OR. ibonjtl(js) == 2 )   njctle = MIN( njctle, njmpptl(js) + nlejtl(js) - 2 )
+            ENDIF
+         ENDIF
+         !
+         IF( PRESENT(clinfo2) ) THEN
+            DO jn = 1, jptra
+               zvctl  = tra_ctl(jn,js)
+               ztab3d(:,:,:) = tab4d(:,:,:,jn)
+               zsum          = SUM( ztab3d(nictls:nictle,njctls:njctle,1:kdir)   &
+                  &                * zmask(nictls:nictle,njctls:njctle,1:kdir) )
+               WRITE(j_id,FMT="(3x,a,' : ',D23.16)") cl(jn), zsum-zvctl
+               tra_ctl(jn,js) = zsum
+            END DO
+         ELSE
+            DO jn = 1, jptra
+               ztab3d(:,:,:) = tab4d(:,:,:,jn)
+               zsum          = SUM( ztab3d(nictls:nictle,njctls:njctle,1:kdir)   &
+                  &               *  zmask(nictls:nictle,njctls:njctle,1:kdir) )
+               WRITE(j_id,FMT="(3x,a,' : ',D23.16)") cl(jn), zsum
+            END DO
+         ENDIF
+         !
+      END DO
+      !
+   END SUBROUTINE prt_ctl_trc
+
+
+   SUBROUTINE prt_ctl_trc_info( clinfo )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_trc_info  ***
+      !!
+      !! ** Purpose : - print information without any computation
+      !!----------------------------------------------------------------------
+      CHARACTER (len=*), INTENT(in) ::   clinfo      ! information to print
+      !! 
+      INTEGER ::   js, sind, eind, j_id
+      !!----------------------------------------------------------------------
+
+      IF( lk_mpp ) THEN      ! processor number
+         sind = narea
+         eind = narea
+      ELSE                   ! total number of processors
+         sind = 1
+         eind = ijsplt
+      ENDIF
+
+      ! Loop over each sub-domain, i.e. number of processors ijsplt
+      DO js = sind, eind
+         j_id = numid_trc(js - narea + 1)
+         WRITE(j_id,*) clinfo
+      END DO
+      !
+   END SUBROUTINE prt_ctl_trc_info
+
+
+   SUBROUTINE prt_ctl_trc_init
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_trc_init  ***
+      !!
+      !! ** Purpose :   open ASCII files & compute indices
+      !!----------------------------------------------------------------------
+      INTEGER            ::   js, sind, eind, j_id
+      CHARACTER (len=31) :: clfile_out
+      CHARACTER (len=27) :: clb_name
+      CHARACTER (len=19) :: cl_run
+      !!----------------------------------------------------------------------
+
+      !                             ! Allocate arrays
+      ALLOCATE( nlditl (ijsplt) )
+      ALLOCATE( nldjtl (ijsplt) )
+      ALLOCATE( nleitl (ijsplt) )
+      ALLOCATE( nlejtl (ijsplt) )
+      ALLOCATE( nimpptl(ijsplt) )
+      ALLOCATE( njmpptl(ijsplt) )
+      ALLOCATE( nlcitl (ijsplt) )
+      ALLOCATE( nlcjtl (ijsplt) )
+      ALLOCATE( tra_ctl(jptra,ijsplt) )
+      ALLOCATE( ibonitl(ijsplt) )
+      ALLOCATE( ibonjtl(ijsplt) )
+
+      tra_ctl(:,:) = 0.e0           ! Initialization to zero
+
+      IF( lk_mpp ) THEN
+         sind = narea
+         eind = narea
+         clb_name = "('mpp.top.output_',I3.3)"
+         cl_run = 'MULTI processor run'
+         ! use indices for each area computed by mpp_init subroutine
+         nlditl(:) = nldit(:) 
+         nleitl(:) = nleit(:) 
+         nldjtl(:) = nldjt(:) 
+         nlejtl(:) = nlejt(:) 
+         !
+         nimpptl(:) = nimppt(:)
+         njmpptl(:) = njmppt(:)
+         !
+         nlcitl(:) = nlcit(:)
+         nlcjtl(:) = nlcjt(:)
+         !
+         ibonitl(:) = ibonit(:)
+         ibonjtl(:) = ibonjt(:)
+      ELSE
+         sind = 1
+         eind = ijsplt
+         clb_name = "('mono.top.output_',I3.3)"
+         cl_run   = 'MONO processor run '
+         ! compute indices for each area as done in mpp_init subroutine
+         CALL sub_dom
+      ENDIF
+
+      ALLOCATE( numid_trc(eind-sind+1) )
+
+      DO js = sind, eind
+         WRITE(clfile_out,FMT=clb_name) js-1
+         CALL ctl_opn( numid_trc(js -narea + 1), clfile_out, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+         j_id = numid_trc(js -narea + 1)
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                 L O D Y C - I P S L'
+         WRITE(j_id,*) '                       N E M 0 '
+         WRITE(j_id,*) '            Ocean General Circulation Model'
+         WRITE(j_id,*) '               version TOP 1.0  (2005) '
+         WRITE(j_id,*)
+         WRITE(j_id,*) '                   PROC number: ', js
+         WRITE(j_id,*)
+         WRITE(j_id,FMT="(19x,a20)") cl_run
+
+         ! Print the SUM control indices
+         IF( .NOT. lsp_area )   THEN
+            IF ( lk_mpp )   THEN
+               nictls = nlditl(js) 
+               nictle = nleitl(js)
+               njctls = nldjtl(js)
+               njctle = nlejtl(js)
+            ELSE
+               nictls = nimpptl(js) + nlditl(js) - 1
+               nictle = nimpptl(js) + nleitl(js) - 1
+               njctls = njmpptl(js) + nldjtl(js) - 1
+               njctle = njmpptl(js) + nlejtl(js) - 1
+            ENDIF
+         ENDIF
+         WRITE(j_id,*) 
+         WRITE(j_id,*) 'prt_tra_ctl :  Sum control indices'
+         WRITE(j_id,*) '~~~~~~~'
+         WRITE(j_id,*)
+         WRITE(j_id,9000)'                                nlej   = ', nlejtl(js), '              '
+         WRITE(j_id,9000)'                  ------------- njctle = ', njctle, ' -------------'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9002)'           nictls = ', nictls,  '                           nictle = ', nictle
+         WRITE(j_id,9002)'           nldi   = ', nlditl(js),  '                           nlei   = ', nleitl(js)
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9001)'                  |                                       |'
+         WRITE(j_id,9004)'  njmpp  = ',njmpptl(js),'   ------------- njctls = ', njctls, ' -------------'
+         WRITE(j_id,9003)'           nimpp  = ', nimpptl(js), '        nldj   = ', nldjtl(js), '              '
+         WRITE(j_id,*)
+         WRITE(j_id,*)
+
+9000     FORMAT(a41,i4.4,a14)
+9001     FORMAT(a59)
+9002     FORMAT(a20,i4.4,a36,i3.3)
+9003     FORMAT(a20,i4.4,a17,i4.4)
+9004     FORMAT(a11,i4.4,a26,i4.4,a14)
+      END DO
+      !
+   END SUBROUTINE prt_ctl_trc_init
+
+
+   SUBROUTINE sub_dom
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sub_dom  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors. 
+      !!                CAUTION: 
+      !!                This part has been extracted from the mpp_init
+      !!                subroutine and names of variables/arrays have been 
+      !!                slightly changed to avoid confusion but the computation
+      !!                is exactly the same. Any modification about indices of
+      !!                each sub-domain in the mppini.F90 module should be reported 
+      !!                here.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!                Periodic condition is a function of the local domain position
+      !!                (global boundary or neighbouring domain) and of the global
+      !!                periodic
+      !!                Type :         jperio global periodic condition
+      !!                               nperio local  periodic condition
+      !!
+      !! ** Action  : - set domain parameters
+      !!                    nimpp     : longitudinal index 
+      !!                    njmpp     : latitudinal  index
+      !!                    nperio    : lateral condition type 
+      !!                    narea     : number for local area
+      !!                    nlcil      : first dimension
+      !!                    nlcjl      : second dimension
+      !!                    nbondil    : mark for "east-west local boundary"
+      !!                    nbondjl    : mark for "north-south local boundary"
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, js               ! dummy loop indices
+      INTEGER ::   ii, ij                   ! temporary integers
+      INTEGER ::   irestil, irestjl         !    "          "
+      INTEGER ::   ijpi  , ijpj, nlcil      ! temporary logical unit
+      INTEGER ::   nlcjl , nbondil, nbondjl
+      INTEGER ::   nrecil, nrecjl, nldil, nleil, nldjl, nlejl
+      REAL(wp) ::   zidom, zjdom            ! temporary scalars
+      INTEGER, DIMENSION(:,:), ALLOCATABLE ::   iimpptl, ijmpptl, ilcitl, ilcjtl   ! temporary workspace
+      !!----------------------------------------------------------------------
+
+      ! Dimension arrays for subdomains
+      ! -------------------------------
+      !  Computation of local domain sizes ilcitl() ilcjtl()
+      !  These dimensions depend on global sizes isplt,jsplt and jpiglo,jpjglo
+      !  The subdomains are squares leeser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap
+      !  array (cf. par_oce.F90).
+
+      ijpi = ( jpiglo-2*jpreci + (isplt-1) ) / isplt + 2*jpreci
+      ijpj = ( jpjglo-2*jprecj + (jsplt-1) ) / jsplt + 2*jprecj
+
+      ALLOCATE( ilcitl (isplt,jsplt) )
+      ALLOCATE( ilcjtl (isplt,jsplt) )
+
+      nrecil  = 2 * jpreci
+      nrecjl  = 2 * jprecj
+      irestil = MOD( jpiglo - nrecil , isplt )
+      irestjl = MOD( jpjglo - nrecjl , jsplt )
+
+      IF(  irestil == 0 )   irestil = isplt
+      DO jj = 1, jsplt
+         DO ji = 1, irestil
+            ilcitl(ji,jj) = ijpi
+         END DO
+         DO ji = irestil+1, isplt
+            ilcitl(ji,jj) = ijpi -1
+         END DO
+      END DO
+      
+      IF( irestjl == 0 )   irestjl = jsplt
+      DO ji = 1, isplt
+         DO jj = 1, irestjl
+            ilcjtl(ji,jj) = ijpj
+         END DO
+         DO jj = irestjl+1, jsplt
+            ilcjtl(ji,jj) = ijpj -1
+         END DO
+      END DO
+      
+      zidom = nrecil
+      DO ji = 1, isplt
+         zidom = zidom + ilcitl(ji,1) - nrecil
+      END DO
+      
+      zjdom = nrecjl
+      DO jj = 1, jsplt
+         zjdom = zjdom + ilcjtl(1,jj) - nrecjl
+      END DO
+
+      ! Index arrays for subdomains
+      ! ---------------------------
+
+      ALLOCATE( iimpptl(isplt,jsplt) )
+      ALLOCATE( ijmpptl(isplt,jsplt) )
+      
+      iimpptl(:,:) = 1
+      ijmpptl(:,:) = 1
+      
+      IF( isplt > 1 ) THEN
+         DO jj = 1, jsplt
+            DO ji = 2, isplt
+               iimpptl(ji,jj) = iimpptl(ji-1,jj) + ilcitl(ji-1,jj) - nrecil
+            END DO
+         END DO
+      ENDIF
+
+      IF( jsplt > 1 ) THEN
+         DO jj = 2, jsplt
+            DO ji = 1, isplt
+               ijmpptl(ji,jj) = ijmpptl(ji,jj-1)+ilcjtl(ji,jj-1)-nrecjl
+            END DO
+         END DO
+      ENDIF
+      
+      ! Subdomain description
+      ! ---------------------
+
+      DO js = 1, ijsplt
+         ii = 1 + MOD( js-1, isplt )
+         ij = 1 + (js-1) / isplt
+         nimpptl(js) = iimpptl(ii,ij)
+         njmpptl(js) = ijmpptl(ii,ij)
+         nlcitl (js) = ilcitl (ii,ij)     
+         nlcil       = nlcitl (js)     
+         nlcjtl (js) = ilcjtl (ii,ij)     
+         nlcjl       = nlcjtl (js)
+         nbondjl = -1                                    ! general case
+         IF( js   >  isplt          )   nbondjl = 0      ! first row of processor
+         IF( js   >  (jsplt-1)*isplt )  nbondjl = 1     ! last  row of processor
+         IF( jsplt == 1             )   nbondjl = 2      ! one processor only in j-direction
+         ibonjtl(js) = nbondjl
+         
+         nbondil = 0                                     ! 
+         IF( MOD( js, isplt ) == 1 )   nbondil = -1      !
+         IF( MOD( js, isplt ) == 0 )   nbondil =  1      !
+         IF( isplt            == 1 )   nbondil =  2      ! one processor only in i-direction
+         ibonitl(js) = nbondil
+         
+         nldil =  1   + jpreci
+         nleil = nlcil - jpreci
+         IF( nbondil == -1 .OR. nbondil == 2 )   nldil = 1
+         IF( nbondil ==  1 .OR. nbondil == 2 )   nleil = nlcil
+         nldjl =  1   + jprecj
+         nlejl = nlcjl - jprecj
+         IF( nbondjl == -1 .OR. nbondjl == 2 )   nldjl = 1
+         IF( nbondjl ==  1 .OR. nbondjl == 2 )   nlejl = nlcjl
+         nlditl(js) = nldil
+         nleitl(js) = nleil
+         nldjtl(js) = nldjl
+         nlejtl(js) = nlejl
+      END DO
+
+      DEALLOCATE( iimpptl )
+      DEALLOCATE( ijmpptl )
+      DEALLOCATE( ilcitl )
+      DEALLOCATE( ilcjtl )
+      !
+   END SUBROUTINE sub_dom
+ 
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module :                                    NO passive tracer
+   !!----------------------------------------------------------------------
+#endif
+    
+   !!======================================================================
+END MODULE prtctl_trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/top_substitute.h90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/top_substitute.h90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/top_substitute.h90	(revision 1844)
@@ -0,0 +1,80 @@
+   !!----------------------------------------------------------------------
+   !!                    ***  top_substitute.h90   ***
+   !!----------------------------------------------------------------------
+   !! ** purpose : Statement function file: to be include in all routines
+   !!              concerning passive tracer model 
+   !!----------------------------------------------------------------------
+   !! History :   1.0  !  2004-03 (C. Ethe) Original code
+   !!             2.0  !  2007-12 (C. Ethe, G. Madec) new architecture
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+    ! Lateral eddy diffusivity coefficient for passive tracer:
+    ! ========================================================
+#if defined key_traldf_c3d || defined key_off_degrad
+!   'key_traldf_c3d' :                 aht: 3D coefficient
+#       define fsahtrt(i,j,k)  trcrat * ahtt(i,j,k)
+#       define fsahtru(i,j,k)  trcrat * ahtu(i,j,k)
+#       define fsahtrv(i,j,k)  trcrat * ahtv(i,j,k)
+#       define fsahtrw(i,j,k)  trcrat * ahtw(i,j,k)
+#elif defined key_traldf_c2d
+!   'key_traldf_c2d' :                 aht: 2D coefficient
+#       define fsahtrt(i,j,k)  trcrat * ahtt(i,j)
+#       define fsahtru(i,j,k)  trcrat * ahtu(i,j)
+#       define fsahtrv(i,j,k)  trcrat * ahtv(i,j)
+#       define fsahtrw(i,j,k)  trcrat * ahtw(i,j)
+#elif defined key_traldf_c1d
+!   'key_traldf_c1d' :                 aht: 1D coefficient
+#       define fsahtrt(i,j,k)  trcrat * ahtt(k)
+#       define fsahtru(i,j,k)  trcrat * ahtu(k)
+#       define fsahtrv(i,j,k)  trcrat * ahtv(k)
+#       define fsahtrw(i,j,k)  trcrat * ahtw(k)
+#else
+!   Default option :             aht: Constant coefficient
+#       define fsahtrt(i,j,k)  ahtrc0
+#       define fsahtru(i,j,k)  ahtrc0
+#       define fsahtrv(i,j,k)  ahtrc0
+#       define fsahtrw(i,j,k)  ahtrc0
+#endif
+
+    ! Eddy induced velocity  coefficient for passive tracer:
+    ! ========================================================
+#if defined key_traldf_c3d || defined key_off_degrad
+!   'key_traldf_c3d' :                 eiv: 3D coefficient
+#       define fsaeitru(i,j,k)  trcrat * aeiu(i,j,k)
+#       define fsaeitrv(i,j,k)  trcrat * aeiv(i,j,k)
+#       define fsaeitrw(i,j,k)  trcrat * aeiw(i,j,k)
+#elif defined key_traldf_c2d
+!   'key_traldf_c2d' :                 eiv: 2D coefficient
+#       define fsaeitru(i,j,k)  trcrat * aeiu(i,j)
+#       define fsaeitrv(i,j,k)  trcrat * aeiv(i,j)
+#       define fsaeitrw(i,j,k)  trcrat * aeiw(i,j)
+#elif defined key_traldf_c1d
+!   'key_traldf_c1d' :                 eiv: 1D coefficient
+#       define fsaeitru(i,j,k)  trcrat * aeiu(k)
+#       define fsaeitrv(i,j,k)  trcrat * aeiv(k)
+#       define fsaeitrw(i,j,k)  trcrat * aeiw(k)
+#else
+!   Default option :             eiv: Constant coefficient
+#       define fsaeitru(i,j,k)  aeiv0
+#       define fsaeitrv(i,j,k)  aeiv0
+#       define fsaeitrw(i,j,k)  aeiv0
+#endif
+    ! mixing for passive tracer:
+    ! ========================================================
+#if defined key_trc_zdfddm
+!   'key_trc_zdfddm' :    avs 
+#       define fstravs(i,j,k)   avs(i,j,k)
+#else
+!   Defautl option :   avs = avt
+#       define fstravs(i,j,k)   avt(i,j,k)
+#endif
+
+! ========================================================
+#include "domzgr_substitute.h90"
+#include "ldfeiv_substitute.h90"
+#include "ldftra_substitute.h90"
+#include "vectopt_loop_substitute.h90"
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trc.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trc.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trc.F90	(revision 1844)
@@ -0,0 +1,108 @@
+MODULE trc
+   !!======================================================================
+   !!                      ***  MODULE  trc  ***
+   !! Passive tracers   :  module for tracers defined
+   !!======================================================================
+   !! History :    -   !  1996-01  (M. Levy)  Original code
+   !!              -   !  1999-07  (M. Levy)  for LOBSTER1 or NPZD model
+   !!              -   !  2000-04  (O. Aumont, M.A. Foujols)  HAMOCC3 and P3ZD
+   !!             1.0  !  2004-03  (C. Ethe)  Free form and module
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   USE par_oce
+   USE par_trc
+   
+   IMPLICIT NONE
+   PUBLIC
+
+   !! passive tracers names and units (read in namelist)
+   !! --------------------------------------------------
+   CHARACTER(len=12), PUBLIC, DIMENSION(jptra) ::   ctrcnm     !: tracer name 
+   CHARACTER(len=12), PUBLIC, DIMENSION(jptra) ::   ctrcun     !: tracer unit
+   CHARACTER(len=80), PUBLIC, DIMENSION(jptra) ::   ctrcnl     !: tracer long name 
+   
+   
+   !! parameters for the control of passive tracers
+   !! --------------------------------------------------
+   INTEGER, PUBLIC                   ::   numnat   !: the number of the passive tracer NAMELIST
+   LOGICAL, PUBLIC, DIMENSION(jptra) ::   lutini   !:  initialisation from FILE or not (NAMELIST)
+   LOGICAL, PUBLIC, DIMENSION(jptra) ::   lutsav   !:  logical for saving tracer or not
+   INTEGER, PUBLIC, DIMENSION(jptra) ::   nutini   !: FORTRAN LOGICAL UNIT for initialisation file
+
+   !! passive tracers fields (before,now,after)
+   !! --------------------------------------------------
+   REAL(wp), PUBLIC ::   trai                         !: initial total tracer
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk) :: cvol  !: masked grid volume 
+   REAL(wp), PUBLIC ::   areatot                      !: total volume 
+
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   trn   !: traceur concentration for actual time step
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   tra   !: traceur concentration for next time step
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jptra) ::   trb   !: traceur concentration for before time step
+
+   
+   !! passive tracers restart (input and output)
+   !! ------------------------------------------  
+   INTEGER , PUBLIC  ::  ndttrc     !: frequency of step on passive tracers
+   INTEGER , PUBLIC  ::  nittrc000  !: first time step of passive tracers model
+   LOGICAL , PUBLIC  ::  ln_rsttr     !: boolean term for restart i/o for passive tracers (namelist)
+   LOGICAL , PUBLIC  ::  lrst_trc   !: logical to control the trc restart write
+   INTEGER , PUBLIC  ::  nutwrs     !: output FILE for passive tracers restart
+   INTEGER , PUBLIC  ::  nutrst     !: logical unit for restart FILE for passive tracers
+   INTEGER , PUBLIC  ::  nrsttr     !: control of the time step ( 0 or 1 ) for pass. tr.
+   CHARACTER(len=50) ::  cn_trcrst_in  !: suffix of pass. tracer restart name (input)
+   CHARACTER(len=50) ::  cn_trcrst_out !: suffix of pass. tracer restart name (output)
+   
+   !! information for outputs
+   !! --------------------------------------------------
+   INTEGER , PUBLIC ::   nwritetrc   !: time step frequency for concentration outputs (namelist)
+   
+# if defined key_trc_diaadd && ! defined key_iomput
+   !! additional 2D/3D outputs namelist
+   !! --------------------------------------------------
+   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2d   !: 2d output field name
+   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2u   !: 2d output field unit   
+   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3d   !: 3d output field name
+   CHARACTER(len= 8), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3u   !: 3d output field unit
+   CHARACTER(len=80), PUBLIC, DIMENSION (jpdia2d) ::   ctrc2l   !: 2d output field long name
+   CHARACTER(len=80), PUBLIC, DIMENSION (jpdia3d) ::   ctrc3l   !: 3d output field long name
+
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,    jpdia2d) ::   trc2d   !:  additional 2d outputs  
+   REAL(wp), PUBLIC, DIMENSION (jpi,jpj,jpk,jpdia3d) ::   trc3d   !:  additional 3d outputs  
+   
+   INTEGER , PUBLIC ::   nwritedia     !: frequency of additional arrays outputs(namelist)
+# endif
+
+#if defined key_trc_diabio || defined key_trdmld_trc
+   CHARACTER(len=8),  DIMENSION(jpdiabio) ::   ctrbio   !: biological trends name      (NAMELIST)
+   CHARACTER(len=20), DIMENSION(jpdiabio) ::   ctrbiu   !: biological trends unit      (NAMELIST)
+   CHARACTER(len=80), DIMENSION(jpdiabio) ::   ctrbil   !: biological trends long name (NAMELIST)
+   INTEGER ::   nwritebio   !: time step frequency for biological outputs (NAMELIST)
+#endif
+# if defined key_trc_diabio
+   !! Biological trends
+   !! -----------------
+   REAL(wp), DIMENSION(jpi,jpj,jpk,jpdiabio) :: trbio   !: biological trends
+# endif
+
+   
+   !! passive tracers data read and at given time_step
+   !! --------------------------------------------------
+# if defined key_dtatrc
+   INTEGER , PUBLIC, DIMENSION(jptra) ::   numtr   !: logical unit for passive tracers data
+# endif
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE trc
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcctl.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcctl.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcctl.F90	(revision 1844)
@@ -0,0 +1,120 @@
+MODULE trcctl
+   !!======================================================================
+   !!                         ***  MODULE trcctl  ***
+   !! TOP :   control the cpp options, files and namelist values of a run
+   !!======================================================================
+   !! History :   1.0  !  2005-03 (O. Aumont, A. El Moussaoui) original code
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_ctl    : control the cpp options, files and namelist values
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE trc
+   USE trctrp_ctl
+   USE trcctl_lobster
+   USE trcctl_pisces
+   USE trcctl_cfc
+   USE trcctl_c14b
+   USE trcctl_my_trc
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_ctl      ! called by ???
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_ctl
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!              we use IF/ENDIF inside #IF defined option-cpp
+      !!              FILE name must not exceed 21 characters
+      !!----------------------------------------------------------------------
+      INTEGER ::   istop, jn
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ctl :   passive tracer option'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~'
+
+      istop = 0      ! initialise to zero
+
+      ! restart for passive tracer (input)
+      IF( ln_rsttr ) THEN
+         IF(lwp) WRITE(numout,*) '       READ a restart FILE for passive tracer'
+         IF(lwp) WRITE(numout,*) ' '
+      ELSE
+         IF(lwp) WRITE(numout,*) '       no restart FILE'
+         IF(lwp) WRITE(numout,*)
+         DO jn = 1, jptra
+            IF( lutini(jn) ) THEN      ! OPEN input FILE only IF lutini(jn) is true
+               IF(lwp) WRITE(numout,*)  &
+                  '       READ an initial FILE  for passive tracer number :', jn, ' traceur : ', ctrcnm(jn) 
+            END IF
+         END DO
+      ENDIF
+
+      ! transport scheme option
+      CALL trc_trp_ctl
+
+      ! SMS model
+      IF(lwp) WRITE(numout,*) '  '
+      IF(lwp) WRITE(numout,*) '       Source/Sink model option'
+      IF(lwp) WRITE(numout,*) '  '
+
+      IF( lk_lobster ) THEN   ;   CALL trc_ctl_lobster      ! LOBSTER bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          LOBSTER not used'
+      ENDIF
+
+      IF( lk_pisces  ) THEN   ;   CALL trc_ctl_pisces      ! PISCES  bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
+      ENDIF
+
+      IF( lk_cfc     ) THEN   ;   CALL trc_ctl_cfc         ! CFC     tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
+      ENDIF
+
+      IF( lk_c14b    ) THEN   ;   CALL trc_ctl_c14b        ! C14 bomb   tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14b not used'
+      ENDIF
+
+
+      IF( lk_my_trc  ) THEN   ;   CALL trc_ctl_my_trc      ! MY_TRC  tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
+      ENDIF
+
+
+      ! E r r o r  control
+      ! ------------------
+      IF( istop > 0  ) THEN
+         IF(lwp)WRITE(numout,*)
+         IF(lwp)WRITE(numout,*) istop,' E R R O R found : we stop'
+         IF(lwp)WRITE(numout,*) '  **************************'
+         IF(lwp)WRITE(numout,*)
+         STOP 'trcctl'
+      ENDIF
+      !
+   END SUBROUTINE trc_ctl
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ctl                      ! Dummy routine
+   END SUBROUTINE trc_ctl
+#endif
+
+   !!======================================================================
+END MODULE trcctl
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdia.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdia.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdia.F90	(revision 1844)
@@ -0,0 +1,755 @@
+MODULE trcdia
+   !!======================================================================
+   !!                       *** MODULE trcdia ***
+   !! TOP :   Output of passive tracers
+   !!======================================================================
+   !! History :    -   !  1995-01 (M. Levy)  Original code
+   !!              -   !  1998-01 (C. Levy) NETCDF format using ioipsl interface
+   !!              -   !  1999-01 (M.A. Foujols) adapted for passive tracer
+   !!              -   !  1999-09 (M.A. Foujols) split into three parts
+   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!                  !  2008-05 (C. Ethe re-organization)
+   !!----------------------------------------------------------------------
+#if defined key_top && ! defined key_iomput
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !! trc_dia     : main routine of output passive tracer
+   !! trcdit_wr   : outputs of concentration fields
+   !! trcdid_wr   : outputs of dvection-diffusion trends
+   !! trcdii_wr   : outputs of additional 2D/3D diagnostics
+   !! trcdib_wr   : outputs of biological fields
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain variables 
+   USE oce_trc
+   USE trc
+   USE trp_trc
+   USE par_trc
+   USE trdmld_trc_oce, ONLY : luttrd
+   USE dianam    ! build name of file (routine)
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp
+   USE ioipsl
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_dia      
+
+   INTEGER  ::   nit5      !: id for tracer output file
+   INTEGER  ::   ndepit5   !: id for depth mesh
+   INTEGER  ::   nhorit5   !: id for horizontal mesh
+   INTEGER  ::   ndimt50   !: number of ocean points in index array
+   INTEGER  ::   ndimt51   !: number of ocean points in index array
+   REAL(wp) ::   zjulian   !: ????   not DOCTOR !
+   INTEGER , DIMENSION (jpij*jpk) ::   ndext50   !: integer arrays for ocean 3D index
+   INTEGER , DIMENSION (jpij)     ::   ndext51   !: integer arrays for ocean surface index
+# if defined key_trc_diaadd
+   INTEGER  ::   nitd      !: id for additional array output file
+   INTEGER  ::   ndepitd   !: id for depth mesh
+   INTEGER  ::   nhoritd   !: id for horizontal mesh
+# endif
+# if defined key_trc_diatrd
+   INTEGER , DIMENSION (jptra) ::   nit6      !: id for additional array output file
+   INTEGER , DIMENSION (jptra) ::   ndepit6   !: id for depth mesh
+   INTEGER , DIMENSION (jptra) ::   nhorit6   !: id for horizontal mesh
+# endif
+# if defined key_trc_diabio
+   INTEGER  ::   nitb        !:         id.         for additional array output file
+   INTEGER  ::   ndepitb   !:  id for depth mesh
+   INTEGER  ::   nhoritb   !:  id for horizontal mesh
+# endif
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_dia( kt )  
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_dia  ***
+      !!
+      !! ** Purpose :   output passive tracers fields 
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) :: kt
+      INTEGER               :: kindic
+      !!---------------------------------------------------------------------
+      
+      CALL trcdit_wr( kt, kindic )      ! outputs for tracer concentration
+      CALL trcdid_wr( kt, kindic )      ! outputs for dynamical trends
+      CALL trcdii_wr( kt, kindic )      ! outputs for additional arrays
+      CALL trcdib_wr( kt, kindic )      ! outputs for biological trends
+
+      !
+   END SUBROUTINE trc_dia
+
+   SUBROUTINE trcdit_wr( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trcdit_wr  ***
+      !!
+      !! ** Purpose :   Standard output of passive tracer : concentration fields
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), define all
+      !!             the NETCDF files and fields for concentration of passive tracer
+      !!
+      !!        At each time step call histdef to compute the mean if necessary
+      !!        Each nwritetrc time step, output the instantaneous or mean fields
+      !!
+      !!        IF kindic <0, output of fields before the model interruption.
+      !!        IF kindic =0, time step loop
+      !!        IF kindic >0, output of fields before the time step loop
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
+      !!
+      INTEGER ::   jn
+      LOGICAL ::   ll_print = .FALSE.
+      CHARACTER (len=40) :: clhstnam, clop
+#if defined key_off_tra
+      INTEGER ::   inum = 11             ! temporary logical unit
+#endif
+      CHARACTER (len=20) :: cltra, cltrau
+      CHARACTER (len=80) :: cltral
+      REAL(wp) :: zsto, zout, zdt
+      INTEGER  :: iimi, iima, ijmi, ijma, ipk, it, itmod
+      !!----------------------------------------------------------------------
+
+      ! Initialisation
+      ! --------------
+
+      ! local variable for debugging
+      ll_print = .FALSE.                  ! change it to true for more control print
+      ll_print = ll_print .AND. lwp
+
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+# if defined key_diainstant
+      zsto = nwritetrc * rdt
+      clop = "inst("//TRIM(clop)//")"
+# else
+      zsto = zdt
+      clop = "ave("//TRIM(clop)//")"
+# endif
+      zout = nwritetrc * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      ! Define NETCDF files and fields at beginning of first time step
+      ! --------------------------------------------------------------
+
+      IF(ll_print)WRITE(numout,*)'trcdit_wr kt=',kt,' kindic ',kindic
+      
+      IF( kt == nittrc000 ) THEN
+
+         ! Compute julian date from starting date of the run
+         CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
+         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+         IF(lwp)WRITE(numout,*)' '  
+         IF(lwp)WRITE(numout,*)' Date 0 used :', nittrc000                         &
+            &                 ,' YEAR ', nyear, ' MONTH ', nmonth, ' DAY ', nday   &
+            &                 ,'Julian day : ', zjulian  
+  
+         IF(lwp) WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,  &
+            &                    ' limit storage in depth = ', ipk
+
+#if defined key_off_tra
+        ! WRITE root name in date.file for use by postpro
+         IF(lwp) THEN
+            CALL dia_nam( clhstnam, nwritetrc,' ' )
+            CALL ctlopn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, narea )
+            WRITE(inum,*) clhstnam
+            CLOSE(inum)
+         ENDIF
+#endif
+
+         ! Define the NETCDF files for passive tracer concentration
+         CALL dia_nam( clhstnam, nwritetrc, 'ptrc_T' )
+         IF(lwp)WRITE(numout,*)" Name of NETCDF file ", clhstnam
+
+         ! Horizontal grid : glamt and gphit
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,     &
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,         & 
+            &          nittrc000-ndttrc, zjulian, zdt, nhorit5, nit5 , domain_id=nidom)
+
+         ! Vertical grid for tracer : gdept
+         CALL histvert( nit5, 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepit5)
+
+         ! Index of ocean points in 3D and 2D (surface)
+         CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndext50, ndimt50 )
+         CALL wheneq( jpi*jpj    , tmask, 1, 1., ndext51, ndimt51 )
+
+         ! Declare all the output fields as NETCDF variables
+         DO jn = 1, jptra
+            IF( lutsav(jn) ) THEN
+               cltra  = ctrcnm(jn)   ! short title for tracer
+               cltral = ctrcnl(jn)   ! long title for tracer
+               cltrau = ctrcun(jn)   ! UNIT for tracer
+               CALL histdef( nit5, cltra, cltral, cltrau, jpi, jpj, nhorit5,  &
+                  &          ipk, 1, ipk,  ndepit5, 32, clop, zsto, zout ) 
+            ENDIF
+         END DO
+
+         ! end netcdf files header
+         CALL histend( nit5 )
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdit_wr'
+         IF( ll_print )   CALL FLUSH(numout )
+
+      ENDIF
+
+      ! Start writing the tracer concentrations
+      ! ---------------------------------------
+
+      IF( lwp .AND. MOD( itmod, nwritetrc ) == 0 ) THEN
+         WRITE(numout,*) 'trcdit_wr : write NetCDF passive tracer concentrations at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~~~~ '
+      ENDIF
+
+      DO jn = 1, jptra
+         cltra = ctrcnm(jn)      ! short title for tracer
+         IF( lutsav(jn) ) CALL histwrite( nit5, cltra, it, trn(:,:,:,jn), ndimt50, ndext50 )
+      END DO
+
+      ! close the file 
+      ! --------------
+      IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nit5 )
+      !
+
+   END SUBROUTINE trcdit_wr
+
+# if defined key_trc_diatrd
+
+   SUBROUTINE trcdid_wr( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trcdid_wr  ***
+      !!
+      !! ** Purpose :   output of passive tracer : advection-diffusion trends
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), define all
+      !!             the NETCDF files and fields for concentration of passive tracer
+      !!
+      !!        At each time step call histdef to compute the mean if necessary
+      !!        Each nwritetrd time step, output the instantaneous or mean fields
+      !!
+      !!        IF kindic <0, output of fields before the model interruption.
+      !!        IF kindic =0, time step loop
+      !!        IF kindic >0, output of fields before the time step loop
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
+      !!
+      LOGICAL ::   ll_print = .FALSE.
+      CHARACTER (len=40) ::   clhstnam, clop
+      CHARACTER (len=20) ::   cltra, cltrau
+      CHARACTER (len=80) ::   cltral
+      CHARACTER (len=10) ::   csuff
+      INTEGER  ::   jn, jl, ikn
+      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it, itmod
+      REAL(wp) ::   zsto, zout, zdt
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialisation
+      ! -----------------
+      
+
+      ! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+      !
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#  if defined key_diainstant
+      zsto = nwritetrd * rdt
+      clop = "inst("//TRIM(clop)//")"
+#  else
+      zsto = zdt
+      clop = "ave("//TRIM(clop)//")"
+#  endif
+      zout = nwritetrd * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      ! Define the NETCDF files (one per tracer)
+      IF( ll_print ) WRITE(numout,*) 'trcdid kt=', kt, ' kindic ', kindic
+      
+      
+      IF( kt == nittrc000 ) THEN
+
+         DO jn = 1, jptra
+            !
+            IF( luttrd(jn) ) THEN      ! Define the file for dynamical trends - one per each tracer IF required
+
+               IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,  &
+                   &                   ' limit storage in depth = ', ipk
+               csuff='DY_'//ctrcnm(jn)
+               CALL dia_nam( clhstnam, nwritetrd, csuff )
+               IF(lwp)WRITE(numout,*)   " Name of NETCDF file for dynamical trends",   &
+                  &                     " of tracer number : ",clhstnam
+
+               CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,       &
+                  &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,   &
+                  &          nittrc000-ndttrc, zjulian, zdt, nhorit6(jn),  &
+                  &          nit6(jn) , domain_id=nidom )
+
+               ! Vertical grid for tracer trend - one per each tracer IF needed
+               CALL histvert( nit6(jn), 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepit6(jn) ) 
+             END IF
+          END DO
+
+          ! Declare all the output fields as NETCDF variables
+          DO jn = 1, jptra
+            IF( luttrd(jn) ) THEN
+                DO jl = 1, jpdiatrc
+                  IF( jl == jptrc_xad ) THEN
+                      ! short and long title for x advection for tracer
+                      WRITE (cltra,'("XAD_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("X advective trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+                  IF( jl == jptrc_yad ) THEN
+                      ! short and long title for y advection for tracer
+                      WRITE (cltra,'("YAD_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y advective trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+                  IF( jl == jptrc_zad ) THEN
+                      ! short and long title for Z advection for tracer
+                      WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z advective trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+                  IF( jl == jptrc_xdf ) THEN
+                      ! short and long title for X diffusion for tracer
+                      WRITE (cltra,'("XDF_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("X diffusion trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+                  IF( jl == jptrc_ydf ) THEN
+                      ! short and long title for Y diffusion for tracer
+                      WRITE (cltra,'("YDF_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y diffusion trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+                  IF( jl == jptrc_zdf ) THEN
+                      ! short and long title for Z diffusion for tracer
+                      WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z diffusion trend for ",58a)') ctrcnl(jn)(1:58)
+                  END IF
+# if defined key_trcldf_eiv
+                  IF( jl == jptrc_xei ) THEN
+                      ! short and long title for x gent velocity for tracer
+                      WRITE (cltra,'("XGV_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("X gent velocity trend for ",53a)') ctrcnl(jn)(1:53)
+                  END IF
+                  IF( jl == jptrc_yei ) THEN
+                      ! short and long title for y gent velocity for tracer
+                      WRITE (cltra,'("YGV_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Y gent velocity trend for ",53a)') ctrcnl(jn)(1:53)
+                  END IF
+                  IF( jl == jptrc_zei ) THEN
+                      ! short and long title for Z gent velocity for tracer
+                      WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Z gent velocity trend for ",53a)') ctrcnl(jn)(1:53)
+                  END IF
+# endif
+# if defined key_trcdmp
+                  IF( jl == jptrc_dmp ) THEN
+                      ! last trends for tracer damping : short and long title
+                      WRITE (cltra,'("TDM_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Tracer damping trend for ",55a)') ctrcnl(jn)(1:55)
+                  END IF
+# endif
+                  IF( jl == jptrc_sbc ) THEN
+                      ! last trends for tracer damping : short and long title
+                      WRITE (cltra,'("SBC_",16a)') ctrcnm(jn)
+                      WRITE (cltral,'("Surface boundary flux ",58a)') ctrcnl(jn)(1:55)
+                  END IF
+                      WRITE (cltral,'("Surface boundary flux ",58a)') ctrcnl(jn)(1:55)
+                  END IF
+                  CALL FLUSH( numout )
+                  cltrau = ctrcun(jn)      ! UNIT for tracer /trends
+                  CALL histdef( nit6(jn), cltra, cltral, cltrau, jpi,jpj,  &
+                     &          nhorit6(jn), ipk, 1, ipk,  ndepit6(jn), 32, clop ,  &
+                     &          zsto,zout )
+               END DO
+            END IF
+         END DO
+         ! CLOSE netcdf Files
+          DO jn = 1, jptra
+             IF( luttrd(jn) )   CALL histend( nit6(jn) )
+          END DO
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdid'
+         IF(ll_print) CALL FLUSH(numout )
+         !
+      ENDIF
+
+      ! SOME diagnostics to DO first time
+
+      ! Start writing data
+      ! ---------------------
+
+      ! trends for tracer concentrations
+
+      IF( lwp .AND. MOD( itmod, nwritetrd ) == 0 ) THEN
+         WRITE(numout,*) 'trcdid_wr : write NetCDF dynamical trends at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      DO jn = 1, jptra
+         IF( luttrd(jn) ) THEN
+            ikn = ikeep(jn) 
+            DO jl = 1, jpdiatrc
+               ! short titles
+               IF( jl == jptrc_xad)   WRITE (cltra,'("XAD_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_yad)   WRITE (cltra,'("YAD_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_zad)   WRITE (cltra,'("ZAD_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_xdf)   WRITE (cltra,'("XDF_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_ydf)   WRITE (cltra,'("YDF_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_zdf)   WRITE (cltra,'("ZDF_",16a)') ctrcnm(jn)
+# if defined key_trcldf_eiv
+               IF( jl == jptrc_xei)   WRITE (cltra,'("XGV_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_yei)   WRITE (cltra,'("YGV_",16a)') ctrcnm(jn)
+               IF( jl == jptrc_zei)   WRITE (cltra,'("ZGV_",16a)') ctrcnm(jn)
+# endif
+# if defined key_trcdmp
+               IF( jl == jptrc_dmp )  WRITE (cltra,'("TDM_",16a)') ctrcnm(jn)
+# endif
+               IF( jl == jptrc_sbc )  WRITE (cltra,'("SBC_",16a)') ctrcnm(jn)
+               !
+               CALL histwrite(nit6(jn), cltra, it, trtrd(:,:,:,ikn,jl),ndimt50, ndext50)
+            END DO
+         END IF
+      END DO
+
+      ! Closing all files
+      ! -----------------
+      IF( kt == nitend .OR. kindic < 0 ) THEN
+         DO jn = 1, jptra
+            IF( luttrd(jn) )   CALL histclo( nit6(jn) )
+         END DO
+      ENDIF
+      !
+
+   END SUBROUTINE trcdid_wr
+
+# else
+
+   SUBROUTINE trcdid_wr( kt, kindic )                      ! Dummy routine
+      INTEGER, INTENT ( in ) ::   kt, kindic
+   END SUBROUTINE trcdid_wr
+
+# endif
+
+#if defined key_trc_diaadd
+
+   SUBROUTINE trcdii_wr( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trcdii_wr  ***
+      !!
+      !! ** Purpose :   output of passive tracer : additional 2D and 3D arrays
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), define all
+      !!             the NETCDF files and fields for concentration of passive tracer
+      !!
+      !!        At each time step call histdef to compute the mean if necessary
+      !!        Each nwritedia time step, output the instantaneous or mean fields
+      !!
+      !!        IF kindic <0, output of fields before the model interruption.
+      !!        IF kindic =0, time step loop
+      !!        IF kindic >0, output of fields before the time step loop
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
+      !!
+      LOGICAL ::   ll_print = .FALSE.
+      CHARACTER (len=40) ::   clhstnam, clop
+      CHARACTER (len=20) ::   cltra, cltrau
+      CHARACTER (len=80) ::   cltral
+      INTEGER  ::   jl
+      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it, itmod
+      REAL(wp) ::   zsto, zout, zdt
+      !!----------------------------------------------------------------------
+
+      ! Initialisation
+      ! --------------
+      
+      ! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+      !
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#  if defined key_diainstant
+      zsto = nwritedia * zdt
+      clop = "inst("//TRIM(clop)//")"
+#  else
+      zsto = zdt
+      clop = "ave("//TRIM(clop)//")"
+#  endif
+      zout = nwritedia * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      IF( ll_print ) WRITE(numout,*) 'trcdii_wr kt=', kt, ' kindic ', kindic
+
+      IF( kt == nittrc000 ) THEN
+
+         ! Define the NETCDF files for additional arrays : 2D or 3D
+
+         ! Define the T grid file for tracer auxiliary files
+
+         CALL dia_nam( clhstnam, nwritedia, 'diad_T' )
+         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
+
+         ! Define a netcdf FILE for 2d and 3d arrays
+
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,             &
+            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,         &
+            &          nittrc000-ndttrc, zjulian, zdt, nhoritd, nitd , domain_id=nidom )
+
+         ! Vertical grid for 2d and 3d arrays
+
+         CALL histvert( nitd, 'deptht', 'Vertical T levels','m', ipk, gdept_0, ndepitd)
+
+         ! Declare all the output fields as NETCDF variables
+
+         ! more 3D horizontal arrays
+         DO jl = 1, jpdia3d
+            cltra  = ctrc3d(jl)   ! short title for 3D diagnostic
+            cltral = ctrc3l(jl)   ! long title for 3D diagnostic
+            cltrau = ctrc3u(jl)   ! UNIT for 3D diagnostic
+            CALL histdef( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,   &
+               &          ipk, 1, ipk,  ndepitd, 32, clop, zsto, zout )
+         END DO
+
+         ! more 2D horizontal arrays
+         DO jl = 1, jpdia2d
+            cltra  = ctrc2d(jl)    ! short title for 2D diagnostic
+            cltral = ctrc2l(jl)   ! long title for 2D diagnostic
+            cltrau = ctrc2u(jl)   ! UNIT for 2D diagnostic
+            CALL histdef( nitd, cltra, cltral, cltrau, jpi, jpj, nhoritd,  &
+               &          1, 1, 1,  -99, 32, clop, zsto, zout )
+         END DO
+
+         ! TODO: more 2D vertical sections arrays : I or J indice fixed
+
+         ! CLOSE netcdf Files
+         CALL histend( nitd )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdii_wr'
+         IF( ll_print )   CALL FLUSH(numout )
+         !
+      ENDIF
+
+      ! 2. Start writing data
+      ! ---------------------
+
+      IF( lwp .AND. MOD( itmod, nwritedia ) == 0 ) THEN
+         WRITE(numout,*) 'trcdii_wr : write NetCDF additional arrays at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      ! more 3D horizontal arrays
+      DO jl = 1, jpdia3d
+         cltra = ctrc3d(jl)   ! short title for 3D diagnostic
+         CALL histwrite( nitd, cltra, it, trc3d(:,:,:,jl), ndimt50 ,ndext50)
+      END DO
+
+      ! more 2D horizontal arrays
+      DO jl = 1, jpdia2d
+         cltra = ctrc2d(jl)   ! short title for 2D diagnostic
+         CALL histwrite(nitd, cltra, it, trc2d(:,:,jl), ndimt51  ,ndext51)
+      END DO
+
+      ! Closing all files
+      ! -----------------
+      IF( kt == nitend .OR. kindic < 0 )   CALL histclo(nitd)
+      !
+
+   END SUBROUTINE trcdii_wr
+
+# else
+
+   SUBROUTINE trcdii_wr( kt, kindic )                      ! Dummy routine
+      INTEGER, INTENT ( in ) :: kt, kindic
+   END SUBROUTINE trcdii_wr
+
+# endif
+
+# if defined key_trc_diabio
+
+   SUBROUTINE trcdib_wr( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trcdib_wr  ***
+      !!
+      !! ** Purpose :   output of passive tracer : biological fields
+      !!
+      !! ** Method  :   At the beginning of the first time step (nit000), define all
+      !!             the NETCDF files and fields for concentration of passive tracer
+      !!
+      !!        At each time step call histdef to compute the mean if necessary
+      !!        Each nwritebio time step, output the instantaneous or mean fields
+      !!
+      !!        IF kindic <0, output of fields before the model interruption.
+      !!        IF kindic =0, time step loop
+      !!        IF kindic >0, output of fields before the time step loop
+      !!----------------------------------------------------------------------
+      !!
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      INTEGER, INTENT( in ) ::   kindic      ! indicator of abnormal termination
+      !!
+      LOGICAL ::   ll_print = .FALSE.
+      CHARACTER (len=40) ::   clhstnam, clop
+      CHARACTER (len=20) ::   cltra, cltrau
+      CHARACTER (len=80) ::   cltral
+      INTEGER  ::   ji, jj, jk, jl
+      INTEGER  ::   iimi, iima, ijmi, ijma, ipk, it, itmod
+      REAL(wp) ::   zsto, zout, zdt
+      !!----------------------------------------------------------------------
+
+      ! Initialisation
+      ! --------------
+
+      
+      ! local variable for debugging
+      ll_print = .FALSE.
+      ll_print = ll_print .AND. lwp
+
+      ! Define frequency of output and means
+      zdt = rdt
+      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
+      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
+      ENDIF
+#        if defined key_diainstant
+      zsto = nwritebio * zdt
+      clop = "inst("//TRIM(clop)//")"
+#        else
+      zsto = zdt
+      clop = "ave("//TRIM(clop)//")"
+#        endif
+      zout = nwritebio * zdt
+
+      ! Define indices of the horizontal output zoom and vertical limit storage
+      iimi = 1      ;      iima = jpi
+      ijmi = 1      ;      ijma = jpj
+      ipk = jpk
+
+      ! define time axis
+      itmod = kt - nittrc000 + 1
+      it    = kt
+
+      ! Define NETCDF files and fields at beginning of first time step
+      ! --------------------------------------------------------------
+
+      IF(ll_print) WRITE(numout,*)'trcdib_wr kt=',kt,' kindic ',kindic
+
+      IF( kt == nittrc000 ) THEN
+
+         ! Define the NETCDF files for biological trends
+
+         CALL dia_nam(clhstnam,nwritebio,'biolog')
+         IF(lwp)WRITE(numout,*) " Name of NETCDF file for biological trends ", clhstnam
+         ! Horizontal grid : glamt and gphit
+         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,      &
+            &    iimi, iima-iimi+1, ijmi, ijma-ijmi+1,          &
+            &    nittrc000-ndttrc, zjulian, zdt, nhoritb, nitb , domain_id=nidom )
+         ! Vertical grid for biological trends
+         CALL histvert(nitb, 'deptht', 'Vertical T levels', 'm', ipk, gdept_0, ndepitb)
+
+         ! Declare all the output fields as NETCDF variables
+         ! biological trends
+         DO jl = 1, jpdiabio
+            cltra  = ctrbio(jl)   ! short title for biological diagnostic
+            cltral = ctrbil(jl)   ! long title for biological diagnostic
+            cltrau = ctrbiu(jl)   ! UNIT for biological diagnostic
+            CALL histdef( nitb, cltra, cltral, cltrau, jpi, jpj, nhoritb,  &
+               &         ipk, 1, ipk,  ndepitb, 32, clop, zsto, zout)
+         END DO
+
+         ! CLOSE netcdf Files
+          CALL histend( nitb )
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization in trcdib_wr'
+         IF(ll_print) CALL FLUSH(numout )
+         !
+      ENDIF
+
+      ! Start writing data
+      ! ------------------
+
+      ! biological trends
+      IF( lwp .AND. MOD( itmod, nwritebio ) == 0 ) THEN
+         WRITE(numout,*) 'trcdit_wr : write NetCDF biological trends at ', kt, 'time-step'
+         WRITE(numout,*) '~~~~~~ '
+      ENDIF
+
+      DO jl = 1, jpdiabio
+         cltra = ctrbio(jl)  ! short title for biological diagnostic
+         CALL histwrite(nitb, cltra, it, trbio(:,:,:,jl), ndimt50,ndext50)
+      END DO
+
+      ! Closing all files
+      ! -----------------
+      IF( kt == nitend .OR. kindic < 0 )   CALL histclo( nitb )
+      !
+
+   END SUBROUTINE trcdib_wr
+
+# else
+
+   SUBROUTINE trcdib_wr( kt, kindic )                      ! Dummy routine
+      INTEGER, INTENT ( in ) ::   kt, kindic
+   END SUBROUTINE trcdib_wr
+
+# endif 
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_dia( kt )                      ! Empty routine   
+      INTEGER, INTENT(in) :: kt
+   END SUBROUTINE trc_dia   
+
+#endif
+
+   !!======================================================================
+END MODULE trcdia
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdta.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdta.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcdta.F90	(revision 1844)
@@ -0,0 +1,217 @@
+MODULE trcdta
+   !!======================================================================
+   !!                     ***  MODULE  trcdta  ***
+   !! TOP :  reads passive tracer data 
+   !!=====================================================================
+   !! History :   1.0  !  2002-04  (O. Aumont)  original code
+   !!              -   !  2004-03  (C. Ethe)  module
+   !!              -   !  2005-03  (O. Aumont, A. El Moussaoui) F90
+   !!----------------------------------------------------------------------
+#if  defined key_top  &&  defined key_dtatrc
+   !!----------------------------------------------------------------------
+   !!   'key_top'  and  'key_dtatrc'        TOP model + passive tracer data
+   !!----------------------------------------------------------------------
+   !!   trc_dta      : read ocean passive tracer data
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE par_trc
+   USE trc
+   USE lib_print
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_dta   ! called in trcini.F90 and trcdmp.F90
+
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtatrc = .TRUE.   !: temperature data flag
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk,jptra) ::   trdta   !: tracer data at given time-step
+
+   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,2) ::   tracdta            ! tracer data at two consecutive times
+   INTEGER , DIMENSION(jptra) ::   nlectr      !: switch for reading once
+   INTEGER , DIMENSION(jptra) ::   ntrc1       !: number of first month when reading 12 monthly value
+   INTEGER , DIMENSION(jptra) ::   ntrc2       !: number of second month when reading 12 monthly value
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   !!----------------------------------------------------------------------
+   !!   Default case                                            NetCDF file
+   !!----------------------------------------------------------------------
+   
+   SUBROUTINE trc_dta( kt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_dta  ***
+      !!
+      !! ** Purpose :   Reads passive tracer data (Levitus monthly data)
+      !!
+      !! ** Method  :   Read on unit numtr the interpolated tracer concentra-
+      !!      tion onto the global grid. Data begin at january. 
+      !!      The value is centered at the middle of month. 
+      !!      In the opa model, kt=1 agree with january 1. 
+      !!      At each time step, a linear interpolation is applied between 
+      !!      two monthly values.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+      !!
+      CHARACTER (len=39) ::   clname(jptra)
+      INTEGER, PARAMETER ::   &
+         jpmonth = 12    ! number of months
+      INTEGER ::   ji, jj, jn, jl 
+      INTEGER ::   imois, iman, i15, ik  ! temporary integers 
+      REAL(wp) ::   zxy, zl
+      !!----------------------------------------------------------------------
+
+      DO jn = 1, jptra
+
+         IF( lutini(jn) ) THEN 
+
+            IF ( kt == nittrc000 ) THEN
+               !! 3D tracer data
+               IF(lwp)WRITE(numout,*)
+               IF(lwp)WRITE(numout,*) ' dta_trc: reading tracer' 
+               IF(lwp)WRITE(numout,*) ' data file ', jn, ctrcnm(jn)
+               IF(lwp)WRITE(numout,*)
+               nlectr(jn) = 0
+            ENDIF
+            ! Initialization
+            iman = jpmonth
+            i15  = nday / 16
+            imois = nmonth + i15 -1
+            IF( imois == 0 ) imois = iman
+
+
+            ! First call kt=nit000
+            ! --------------------
+
+            IF ( kt == nittrc000 .AND. nlectr(jn) == 0 ) THEN
+               ntrc1(jn) = 0
+               IF(lwp) WRITE(numout,*) ' trc_dta : Levitus tracer data monthly fields'
+               ! open file 
+# if defined key_pisces
+               clname(jn) = 'data_1m_'//TRIM(ctrcnm(jn))//'_nomask'
+# else
+               clname(jn) = TRIM(ctrcnm(jn))
+# endif
+               CALL iom_open ( clname(jn), numtr(jn) )              
+
+            ENDIF
+
+# if defined key_pisces
+            ! Read montly file
+            IF( ( kt == nittrc000 .AND. nlectr(jn) == 0)  .OR. imois /= ntrc1(jn) ) THEN
+               nlectr(jn) = 1
+
+               ! Calendar computation
+
+               ! ntrc1 number of the first file record used in the simulation
+               ! ntrc2 number of the last  file record
+
+               ntrc1(jn) = imois
+               ntrc2(jn) = ntrc1(jn) + 1
+               ntrc1(jn) = MOD( ntrc1(jn), iman )
+               IF ( ntrc1(jn) == 0 ) ntrc1(jn) = iman
+               ntrc2(jn) = MOD( ntrc2(jn), iman )
+               IF ( ntrc2(jn) == 0 ) ntrc2(jn) = iman
+               IF(lwp) WRITE(numout,*) 'first record file used ntrc1 ', ntrc1(jn) 
+               IF(lwp) WRITE(numout,*) 'last  record file used ntrc2 ', ntrc2(jn)
+
+               ! Read montly passive tracer data Levitus 
+
+               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), tracdta(:,:,:,jn,1), ntrc1(jn) )
+               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), tracdta(:,:,:,jn,2), ntrc2(jn) )
+
+               IF(lwp) THEN
+                  WRITE(numout,*)
+                  WRITE(numout,*) ' read tracer data ', ctrcnm(jn),' ok'
+                  WRITE(numout,*)
+               ENDIF
+
+               ! Apply Mask
+               DO jl = 1, 2
+                  tracdta(:,:,:  ,jn,jl) = tracdta(:,:,:,jn,jl) * tmask(:,:,:) 
+                  tracdta(:,:,jpk,jn,jl) = 0.
+                  IF( ln_zps ) THEN                ! z-coord. with partial steps
+                     DO jj = 1, jpj                ! interpolation of temperature at the last level
+                        DO ji = 1, jpi
+                           ik = mbathy(ji,jj) - 1
+                           IF( ik > 2 ) THEN
+                              zl = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
+                              tracdta(ji,jj,ik,jn,jl) = (1.-zl) * tracdta(ji,jj,ik  ,jn,jl)    &
+                                 &                    +     zl  * tracdta(ji,jj,ik-1,jn,jl)
+                           ENDIF
+                        END DO
+                     END DO
+                  ENDIF
+
+               END DO
+
+            ENDIF
+
+            IF(lwp) THEN
+               WRITE(numout,*) ctrcnm(jn), 'Levitus month ', ntrc1(jn), ntrc2(jn)
+               WRITE(numout,*)
+               WRITE(numout,*) ' Levitus month = ', ntrc1(jn), '  level = 1'
+               CALL prihre( tracdta(1,1,1,jn,1), jpi, jpj, 1, jpi, 20, 1   &
+                  &        ,jpj, 20, 1., numout )
+               WRITE(numout,*) ' Levitus month = ', ntrc1(jn), '  level = ',jpk/2
+               CALL prihre( tracdta(1,1,jpk/2,jn,1), jpi, jpj, 1, jpi,    &
+                  &         20, 1, jpj, 20, 1., numout )
+               WRITE(numout,*) ' Levitus month = ',ntrc1(jn),'  level = ',jpkm1
+               CALL prihre( tracdta(1,1,jpkm1,jn,1), jpi, jpj, 1, jpi,     &
+                  &         20, 1, jpj, 20, 1., numout )
+            ENDIF
+
+            ! At every time step compute temperature data
+            zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+            trdta(:,:,:,jn) =  ( 1. - zxy ) * tracdta(:,:,:,jn,1)    &
+               &              +       zxy   * tracdta(:,:,:,jn,2) 
+
+            IF( jn == jpno3 )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   7.6e-6
+            IF( jn == jpdic )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
+            IF( jn == jptal )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
+            IF( jn == jpoxy )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *  44.6e-6
+            IF( jn == jpsil )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
+            IF( jn == jppo4 )   trdta(:,:,:,jn) = trdta(:,:,:,jn) * 122.0e-6
+
+            ! Close the file
+            ! --------------
+            
+            IF( kt == nitend )   CALL iom_close( numtr(jn) )
+
+# else
+            ! Read init file only
+            IF( kt == nittrc000  ) THEN
+               ntrc1(jn) = 1
+               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), trdta(:,:,:,jn), ntrc1(jn) )
+               trdta(:,:,:,jn) = trdta(:,:,:,jn) * tmask(:,:,:)
+               CALL iom_close ( numtr(jn) )
+            ENDIF 
+# endif
+
+         ENDIF
+
+      END DO
+      !
+   END SUBROUTINE trc_dta
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Dummy module                              NO 3D passive tracer data
+   !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtatrc = .FALSE.   !: temperature data flag
+CONTAINS
+   SUBROUTINE trc_dta( kt )        ! Empty routine
+      WRITE(*,*) 'trc_dta: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_dta
+#endif
+
+   !!======================================================================
+END MODULE trcdta
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcini.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcini.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcini.F90	(revision 1844)
@@ -0,0 +1,176 @@
+MODULE trcini
+   !!======================================================================
+   !!                         ***  MODULE trcini  ***
+   !! TOP :   Manage the passive tracer initialization
+   !!======================================================================
+   !! History :    -   !  1991-03  ()  original code
+   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!              -   !  2005-10 (C. Ethe) print control
+   !!             2.0  !  2005-10 (C. Ethe, G. Madec) revised architecture
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   trc_ini :   Initialization for passive tracer
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE trc
+   USE trp_trc
+   USE trcrst
+   USE trcctl
+   USE trclec
+   USE trcini_cfc      ! CFC      initialisation
+   USE trcini_lobster  ! LOBSTER  initialisation
+   USE trcini_pisces   ! PISCES   initialisation
+   USE trcini_c14b     ! C14 bomb initialisation
+   USE trcini_my_trc   ! MY_TRC   initialisation
+   USE trcdta   
+#if defined key_off_tra 
+   USE daymod
+#endif
+   USE zpshde_trc      ! partial step: hor. derivative 
+   USE in_out_manager  ! I/O manager
+   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
+   USE lib_mpp         ! distributed memory computing library
+   
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   trc_ini   ! called by opa
+
+    !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+  
+CONTAINS
+   
+   SUBROUTINE trc_ini
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini  ***
+      !!
+      !! ** Purpose :   Initialization of the passive tracer fields 
+      !!
+      !! ** Method  : - read namelist
+      !!              - control the consistancy 
+      !!              - compute specific initialisations
+      !!              - set initial tracer fields (either read restart 
+      !!                or read data or analytical formulation
+      !!---------------------------------------------------------------------
+      INTEGER ::   jk, jn    ! dummy loop indices
+      CHARACTER (len=25) :: charout
+
+      !!---------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'trc_ini : initial set up of the passive tracers'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+      !                 ! masked grid volume
+      DO jk = 1, jpk
+         cvol(:,:,jk) = e1t(:,:) * e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) * tmask_i(:,:)
+      END DO
+
+      ! total volume of the ocean
+#if ! defined key_off_degrad
+      areatot = SUM( cvol(:,:,:) )
+#else
+      areatot = SUM( cvol(:,:,:) * facvol(:,:,:) ) ! degrad option: reduction by facvol
+#endif
+      IF( lk_mpp )   CALL mpp_sum( areatot )     ! sum over the global domain  
+
+                                  CALL trc_lec      ! READ passive tracers namelists
+
+                                  CALL trc_ctl      ! control consistency between parameters, cpp key
+
+      IF( lk_lobster ) THEN   ;   CALL trc_ini_lobster      ! LOBSTER bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          LOBSTER not used'
+      ENDIF
+      
+      IF( lk_pisces  ) THEN   ;   CALL trc_ini_pisces       ! PISCES  bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
+      ENDIF
+      
+      IF( lk_cfc     ) THEN   ;   CALL trc_ini_cfc          ! CFC     tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
+      ENDIF
+
+      IF( lk_c14b    ) THEN   ;   CALL trc_ini_c14b         ! C14 bomb  tracer
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14 not used'
+      ENDIF
+      
+      IF( lk_my_trc  ) THEN   ;   CALL trc_ini_my_trc       ! MY_TRC  tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
+      ENDIF
+
+      IF( .NOT. ln_rsttr ) THEN 
+#if defined key_off_tra
+         CALL day_init      ! calendar
+#endif
+# if defined key_dtatrc
+         ! Initialization of tracer from a file that may also be used for damping
+         CALL trc_dta( nittrc000 )
+         DO jn = 1, jptra
+            IF( lutini(jn) )   trn(:,:,:,jn) = trdta(:,:,:,jn) * tmask(:,:,:)   ! initialisation from file if required
+         END DO
+# endif
+         trb(:,:,:,:) = trn(:,:,:,:)
+      ELSE
+         !
+         CALL trc_rst_read      ! restart from a file
+         !
+      ENDIF
+
+      tra(:,:,:,:) = 0.
+      
+      IF( ln_zps .AND. .NOT. lk_trc_c1d )   &              ! Partial steps: before horizontal gradient of passive
+      &                     CALL zps_hde_trc( nittrc000, trb, gtru, gtrv )       ! tracers at the bottom ocean level
+
+
+      !                 ! Computation content of all tracers
+      trai = 0.e0
+      DO jn = 1, jptra
+#if ! defined key_off_degrad
+         trai = trai + SUM( trn(:,:,:,jn) * cvol(:,:,:) )
+#else
+         trai = trai + SUM( trn(:,:,:,jn) * cvol(:,:,:) * facvol(:,:,:) ) ! degrad option: reduction by facvol
+#endif
+      END DO      
+      IF( lk_mpp )   CALL mpp_sum( trai )     ! sum over the global domain  
+
+
+      !                 ! control print
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
+      IF(lwp) WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
+      IF(lwp) WRITE(numout,*) '          *** Total inital content of all tracers  = ', trai
+      IF(lwp) WRITE(numout,*)
+
+      IF( ln_ctl )   CALL prt_ctl_trc_init      ! control print
+      !
+
+      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('ini ')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
+      ENDIF
+
+   END SUBROUTINE trc_ini
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_ini                      ! Dummy routine   
+   END SUBROUTINE trc_ini
+#endif
+
+   !!======================================================================
+END MODULE trcini
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trclec.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trclec.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trclec.F90	(revision 1844)
@@ -0,0 +1,238 @@
+MODULE trclec
+   !!======================================================================
+   !!                       ***  MODULE trclec  ***
+   !! TOP :   Read and print options for the passive tracer run (namelist)
+   !!======================================================================
+   !! History :    -   !  1996-11  (M.A. Foujols, M. Levy)  original code
+   !!              -   !  1998-04  (M.A Foujols, L. Bopp) ahtrb0 for isopycnal mixing
+   !!              -   !  1999-10  (M.A. Foujols, M. Levy) separation of sms
+   !!              -   !  2000-07  (A. Estublier) add TVD and MUSCL : Tests on ndttrc
+   !!              -   !  2000-11  (M.A Foujols, E Kestenare) trcrat, ahtrc0 and aeivtr0
+   !!              -   !  2001-01 (E Kestenare) suppress ndttrc=1 for CEN2 and TVD schemes
+   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_lec    :  Read and print options for the passive tracer run (namelist)
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE trc
+   USE trp_trc
+   USE trctrp_lec
+   USE trclsm_lobster    ! LOBSTER namelist
+   USE trclsm_pisces     ! PISCES namelist
+   USE trclsm_cfc        ! CFC SMS namelist
+   USE trclsm_c14b       ! C14 SMS namelist
+   USE trclsm_my_trc     ! MY_TRC SMS namelist
+   USE in_out_manager    ! I/O manager
+   USE trdmld_trc_oce
+
+   IMPLICIT NONE
+   PRIVATE 
+
+   PUBLIC trc_lec      ! called in ???
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_lec
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_lec  ***
+      !!
+      !! ** Purpose :   READ and PRINT options for the passive tracer run (namelist) 
+      !!
+      !! ** Method  : - read passive tracer namelist 
+      !!              - read namelist of each defined SMS model
+      !!                ( (LOBSTER, PISCES, CFC, MY_TRC )
+      !!---------------------------------------------------------------------
+      INTEGER ::  jn
+
+      ! Definition of a tracer as a structure
+      TYPE PTRACER
+         CHARACTER(len = 20)  :: sname  !: short name
+         CHARACTER(len = 80 ) :: lname  !: long name
+         CHARACTER(len = 20 ) :: unit   !: unit
+         LOGICAL              :: lini   !: read in a file or not
+         LOGICAL              :: lsav   !: ouput the tracer or not 
+      END TYPE PTRACER
+
+      TYPE(PTRACER) , DIMENSION(jptra) :: tracer
+
+      !!
+      NAMELIST/namtoptrc/ ndttrc, nwritetrc, ln_rsttr, nrsttr, &
+                          cn_trcrst_in, cn_trcrst_out, tracer
+#if defined key_trdmld_trc || defined key_trc_diatrd
+      NAMELIST/namtoptrd/ ntrd_trc, nctls_trc, ucf_trc, &
+                         ln_trdmld_trc_restart, ln_trdmld_trc_instant, &
+                         cn_trdrst_trc_in, cn_trdrst_trc_out, luttrd
+#endif
+
+      !!---------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*) 'trc_lec : read the passive tracer namelists'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+
+      CALL ctl_opn( numnat, 'namelist_top', 'OLD', 'FORMATTED', 'SEQUENTIAL', 1, numout, .FALSE. )
+
+      ! Namelist nattrc (files)
+      ! ----------------------------------------------
+      ndttrc    = 1                 ! default values
+      nwritetrc = 10      
+      ln_rsttr    = .FALSE.
+      nrsttr    =  0
+      cn_trcrst_in  = 'restart_trc'
+      cn_trcrst_out = 'restart_trc'
+      DO jn = 1, jptra
+         WRITE(ctrcnm(jn),'("TR_",I1)'           ) jn
+         WRITE(ctrcnl(jn),'("TRACER NUMBER ",I1)') jn
+         ctrcun(jn) = 'mmole/m3'
+         lutini(jn) = .FALSE. 
+         lutsav(jn) = .TRUE.
+      END DO
+
+      REWIND( numnat )               ! read nattrc
+      READ  ( numnat, namtoptrc )
+
+      !!Chris  computes the first time step of tracer model
+      nittrc000 = nit000 + ndttrc - 1
+
+      DO jn = 1, jptra
+         ctrcnm(jn) = tracer(jn)%sname
+         ctrcnl(jn) = tracer(jn)%lname
+         ctrcun(jn) = tracer(jn)%unit
+         lutini(jn) = tracer(jn)%lini
+         lutsav(jn) = tracer(jn)%lsav
+      END DO
+
+
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : namtoptrc'
+         WRITE(numout,*) '    time step freq. for pass. trac. ndttrc             = ', ndttrc
+         WRITE(numout,*) '    1st time step for pass. trac. nittrc000            = ', nittrc000
+         WRITE(numout,*) '    frequency of outputs for passive tracers nwritetrc = ', nwritetrc  
+         WRITE(numout,*) '    restart LOGICAL for passive tr. ln_rsttr           = ', ln_rsttr
+         WRITE(numout,*) '    control of time step for p. tr. nrsttr             = ', nrsttr
+         WRITE(numout,*) ' '
+         DO jn = 1, jptra
+            WRITE(numout,*) '   tracer nb             : ', jn 
+            WRITE(numout,*) '   short name            : ', TRIM(ctrcnm(jn))
+            WRITE(numout,*) '   long name             : ', TRIM(ctrcnl(jn))
+            WRITE(numout,*) '   unit                  : ', TRIM(ctrcun(jn))
+            WRITE(numout,*) '   initial value in FILE : ', lutini(jn) 
+            WRITE(numout,*) '   output of tracer      : ', lutsav(jn)
+            WRITE(numout,*) ' '
+         END DO
+      ENDIF
+
+#if defined key_trdmld_trc || defined key_trc_diatrd
+
+      ! Namelist natrtd (transport trends)
+      ! ----------------------------------------------
+      ntrd_trc  = 20
+      nctls_trc =  6
+      ucf_trc   =  1.
+      ln_trdmld_trc_instant = .TRUE.
+      ln_trdmld_trc_restart =.FALSE.
+      cn_trdrst_trc_in  = "restart_mld_trc"
+      cn_trdrst_trc_out = "restart_mld_trc"
+      DO jn = 1, jptra
+         luttrd(jn) = .FALSE.
+      END DO
+
+      REWIND( numnat )               !  namelist namtoptrd : passive tracer trends diagnostic
+      READ  ( numnat, namtoptrd )
+
+#if defined key_trc_diatrd
+      nkeep    = 0
+      ikeep(:) = 0
+      DO jn = 1, jptra
+         IF( luttrd(jn) ) THEN 
+             nkeep     = nkeep + 1
+             ikeep(jn) = nkeep
+         END IF 
+      END DO
+      IF( nkeep > 0 ) THEN  
+        IF(.NOT. ALLOCATED( trtrd ) )   ALLOCATE( trtrd(jpi,jpj,jpk,nkeep,jpdiatrc) ) 
+        trtrd(:,:,:,:,:) = 0.e0
+      ENDIF 
+
+      nwritetrd = ntrd_trc
+#endif
+
+     IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) ' trd_mld_trc_init : read namelist namtoptrd                        '
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~                                               '
+         WRITE(numout,*) '   * frequency of trends diagnostics   ntrd_trc               = ', ntrd_trc
+         WRITE(numout,*) '   * control surface type              nctls_trc              = ', nctls_trc
+         WRITE(numout,*) '   * restart for ML diagnostics        ln_trdmld_trc_restart  = ', ln_trdmld_trc_restart
+         WRITE(numout,*) '   * flag to diagnose trends of                                 '
+         WRITE(numout,*) '     instantantaneous or mean ML T/S   ln_trdmld_trc_instant  = ', ln_trdmld_trc_instant
+         WRITE(numout,*) '   * unit conversion factor            ucf_trc                = ', ucf_trc
+#if defined key_trdmld_trc
+         DO jn = 1, jptra
+            WRITE(numout,*) '    keep dynamical trends for tracer number :', jn, luttrd(jn)
+         END DO
+#else
+         DO jn = 1, jptra
+            WRITE(numout,*) '    keep dynamical trends for tracer number :', jn, luttrd(jn), ikeep(jn)
+         END DO
+
+         WRITE(numout,*)
+         WRITE(numout,*) '    total = ', nkeep, ' tracers dyn trends saved'
+         WRITE(numout,*) '    size of trtrd = ', jpi*jpj*jpk*nkeep*jpdiatrc
+#endif
+      ENDIF
+
+#endif
+
+
+      ! namelist of transport
+      ! ---------------------
+      CALL trc_trp_lec
+
+      ! namelist of SMS
+      ! ---------------      
+      IF( lk_lobster ) THEN   ;   CALL trc_lsm_lobster      ! LOBSTER bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          LOBSTER not used'
+      ENDIF
+
+      IF( lk_pisces  ) THEN   ;   CALL trc_lsm_pisces      ! PISCES  bio-model
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
+      ENDIF
+
+      IF( lk_cfc     ) THEN   ;   CALL trc_lsm_cfc         ! CFC     tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
+      ENDIF
+
+      IF( lk_c14b     ) THEN   ;   CALL trc_lsm_c14b         ! C14 bomb     tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14 not used'
+      ENDIF
+
+      IF( lk_my_trc  ) THEN   ;   CALL trc_lsm_my_trc      ! MY_TRC  tracers
+      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
+      ENDIF
+      !
+   END SUBROUTINE trc_lec
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_lec                      ! Empty routine   
+   END SUBROUTINE trc_lec
+#endif
+
+   !!======================================================================
+END MODULE  trclec
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcrst.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcrst.F90	(revision 1844)
@@ -0,0 +1,372 @@
+MODULE trcrst
+   !!======================================================================
+   !!                         ***  MODULE trcrst  ***
+   !! TOP :   Manage the passive tracer restart
+   !!======================================================================
+   !! History :    -   !  1991-03  ()  original code
+   !!             1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!              -   !  2005-10 (C. Ethe) print control
+   !!             2.0  !  2005-10 (C. Ethe, G. Madec) revised architecture
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   trc_rst :   Restart for passive tracer
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_rst_opn    : open  restart file
+   !!   trc_rst_read   : read  restart file
+   !!   trc_rst_wri    : write restart file
+   !!----------------------------------------------------------------------
+   USE oce_trc
+   USE trc
+   USE trctrp_lec
+   USE lib_mpp
+   USE iom
+   USE trcrst_cfc      ! CFC      
+   USE trcrst_lobster  ! LOBSTER  restart
+   USE trcrst_pisces   ! PISCES   restart
+   USE trcrst_c14b     ! C14 bomb restart
+   USE trcrst_my_trc   ! MY_TRC   restart
+#if defined key_off_tra
+    USE daymod
+#endif
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_rst_opn       ! called by ???
+   PUBLIC   trc_rst_read      ! called by ???
+   PUBLIC   trc_rst_wri       ! called by ???
+
+   INTEGER, PUBLIC ::   numrtr, numrtw   !: logical unit for trc restart (read and write)
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   
+CONTAINS
+   
+   SUBROUTINE trc_rst_opn( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  trc_rst_opn  ***
+      !!
+      !! ** purpose  :   output of sea-trc variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      !
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step define as a character
+      CHARACTER(LEN=50)   ::   clname   ! trc output restart file name
+      !!----------------------------------------------------------------------
+      !
+# if ! defined key_off_tra
+      IF( kt == nit000 ) lrst_trc = .FALSE. 
+# else
+      IF( kt == nit000 ) THEN
+        lrst_trc = .FALSE. 
+        nitrst = nitend  
+      ENDIF
+
+      IF( MOD( kt - 1, nstock ) == 0 ) THEN
+         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
+         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
+      ENDIF
+# endif
+     ! to get better performances with NetCDF format:
+     ! we open and define the tracer restart file one tracer time step before writing the data (-> at nitrst - 2*ndttrc + 1)
+     ! except if we write tracer restart files every tracer time step or if a tracer restart file was writen at nitend - 2*ndttrc + 1
+     IF( kt == nitrst - 2*ndttrc + 1 .OR. nstock == ndttrc .OR. ( kt == nitend - ndttrc + 1 .AND. .NOT. lrst_trc ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough)
+         IF( nitrst > 1.0e9 ) THEN   ;   WRITE(clkt,*       ) nitrst
+         ELSE                        ;   WRITE(clkt,'(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         IF(lwp) WRITE(numout,*)
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trcrst_out)
+         IF(lwp) WRITE(numout,*) '             open trc restart.output NetCDF file: '//clname
+         CALL iom_open( clname, numrtw, ldwrt = .TRUE., kiolib = jprstlib )
+         lrst_trc = .TRUE.
+      ENDIF
+      !
+   END SUBROUTINE trc_rst_opn
+
+   SUBROUTINE trc_rst_read
+      !!----------------------------------------------------------------------
+      !!                    ***  trc_rst_opn  ***
+      !!
+      !! ** purpose  :   read passive tracer fields in restart files
+      !!----------------------------------------------------------------------
+      INTEGER  ::  jn     
+      INTEGER  ::  iarak0 
+      REAL(wp) ::  zarak0
+      INTEGER  ::  jlibalt = jprstlib
+      LOGICAL  ::  llok
+
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'trc_rst_read : read the TOP restart file'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+
+      IF ( jprstlib == jprstdimg ) THEN
+        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
+        ! if {cn_trcrst_in}.nc exists, then set jlibalt to jpnf90 
+        INQUIRE( FILE = TRIM(cn_trcrst_in)//'.nc', EXIST = llok )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF 
+      ENDIF
+
+      CALL iom_open( cn_trcrst_in, numrtr, kiolib = jlibalt ) 
+
+      ! Time domain : restart
+      ! ---------------------
+      CALL trc_rst_cal( nittrc000, 'READ' )   ! calendar
+
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN   ;   iarak0 = 1
+      ELSE                                           ;   iarak0 = 0
+      ENDIF
+      CALL iom_get( numrtr, 'arak0', zarak0 )
+
+      IF( iarak0 /= NINT( zarak0 ) )   &                           ! Control of the scheme
+         & CALL ctl_stop( ' ===>>>> : problem with advection scheme', &
+         & ' it must be the same type for both restart and previous run', &
+         & ' centered or euler '  )
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    arakawa option      : ', NINT( zarak0 )
+
+      ! READ prognostic variables and computes diagnostic variable
+      DO jn = 1, jptra
+         CALL iom_get( numrtr, jpdom_autoglo, 'TRN'//ctrcnm(jn), trn(:,:,:,jn) )
+      END DO
+
+      DO jn = 1, jptra
+         CALL iom_get( numrtr, jpdom_autoglo, 'TRB'//ctrcnm(jn), trb(:,:,:,jn) )
+      END DO
+
+      IF( lk_lobster )   CALL trc_rst_read_lobster( numrtr )      ! LOBSTER bio-model
+      IF( lk_pisces  )   CALL trc_rst_read_pisces ( numrtr )      ! PISCES  bio-model
+      IF( lk_cfc     )   CALL trc_rst_read_cfc    ( numrtr )      ! CFC     tracers
+      IF( lk_c14b    )   CALL trc_rst_read_c14b   ( numrtr )      ! C14 bomb  tracer
+      IF( lk_my_trc  )   CALL trc_rst_read_my_trc ( numrtr )      ! MY_TRC  tracers
+
+      CALL iom_close( numrtr )
+      !
+   END SUBROUTINE trc_rst_read
+
+   SUBROUTINE trc_rst_wri( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  trc_rst_wri  ***
+      !!
+      !! ** purpose  :   write passive tracer fields in restart files
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt    ! ocean time-step index
+      !!
+      INTEGER  :: jn
+      REAL(wp) :: zarak0
+      !!----------------------------------------------------------------------
+
+
+      CALL trc_rst_cal( kt, 'WRITE' )   ! calendar
+
+      IF( ln_trcadv_cen2 .OR. ln_trcadv_tvd ) THEN   ;   zarak0 = 1.
+      ELSE                                           ;   zarak0 = 0.
+      ENDIF
+      CALL iom_rstput( kt, nitrst, numrtw, 'arak0', zarak0 )
+
+      ! prognostic variables 
+      ! -------------------- 
+      DO jn = 1, jptra
+         CALL iom_rstput( kt, nitrst, numrtw, 'TRN'//ctrcnm(jn), trn(:,:,:,jn) )
+      END DO
+
+      DO jn = 1, jptra
+         CALL iom_rstput( kt, nitrst, numrtw, 'TRB'//ctrcnm(jn), trb(:,:,:,jn) )
+      END DO
+
+      IF( lk_lobster )   CALL trc_rst_wri_lobster( kt, nitrst, numrtw )      ! LOBSTER bio-model
+      IF( lk_pisces  )   CALL trc_rst_wri_pisces ( kt, nitrst, numrtw )      ! PISCES  bio-model
+      IF( lk_cfc     )   CALL trc_rst_wri_cfc    ( kt, nitrst, numrtw )      ! CFC     tracers
+      IF( lk_c14b    )   CALL trc_rst_wri_c14b   ( kt, nitrst, numrtw )      ! C14 bomb  tracer
+      IF( lk_my_trc  )   CALL trc_rst_wri_my_trc ( kt, nitrst, numrtw )      ! MY_TRC  tracers
+
+      IF( kt == nitrst ) THEN
+          CALL trc_rst_stat            ! statistics
+          CALL iom_close( numrtw )     ! close the restart file (only at last time step)
+#if ! defined key_trdmld_trc
+          lrst_trc = .FALSE.
+#endif
+      ENDIF
+      !
+   END SUBROUTINE trc_rst_wri 
+
+
+   SUBROUTINE trc_rst_cal( kt, cdrw )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE trc_rst_cal  ***
+      !!
+      !!  ** Purpose : Read or write calendar in restart file:
+      !!
+      !!  WRITE(READ) mode:
+      !!       kt        : number of time step since the begining of the experiment at the
+      !!                   end of the current(previous) run
+      !!       adatrj(0) : number of elapsed days since the begining of the experiment at the
+      !!                   end of the current(previous) run (REAL -> keep fractions of day)
+      !!       ndastp    : date at the end of the current(previous) run (coded as yyyymmdd integer)
+      !!
+      !!   According to namelist parameter nrstdt,
+      !!       nrsttr = 0  no control on the date (nittrc000 is  arbitrary).
+      !!       nrsttr = 1  we verify that nit000 is equal to the last
+      !!                   time step of previous run + 1.
+      !!       In both those options, the  exact duration of the experiment
+      !!       since the beginning (cumulated duration of all previous restart runs)
+      !!       is not stored in the restart and is assumed to be (nit000-1)*rdt.
+      !!       This is valid is the time step has remained constant.
+      !!
+      !!       nrsttr = 2  the duration of the experiment in days (adatrj)
+      !!                    has been stored in the restart file.
+      !!----------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
+      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
+      !
+      REAL(wp) ::  zkt
+#if defined key_off_tra
+      REAL(wp) ::  zndastp
+#endif
+
+      ! Time domain : restart
+      ! ---------------------
+
+      IF( TRIM(cdrw) == 'READ' ) THEN
+         CALL iom_get ( numrtr, 'kt', zkt )   ! last time-step of previous run
+         IF(lwp) THEN
+            WRITE(numout,*) ' *** Info read in restart : '
+            WRITE(numout,*) '   previous time-step                               : ', NINT( zkt )
+            WRITE(numout,*) ' *** restart option'
+            SELECT CASE ( nrsttr )
+            CASE ( 0 )   ;   WRITE(numout,*) ' nrsttr = 0 : no control of nittrc000'
+            CASE ( 1 )   ;   WRITE(numout,*) ' nrsttr = 1 : no control the date at nit000 (use ndate0 read in the namelist)'
+            CASE ( 2 )   ;   WRITE(numout,*) ' nrsttr = 2 : calendar parameters read in restart'
+            END SELECT
+            WRITE(numout,*)
+         ENDIF
+         ! Control of date 
+         IF( nittrc000  - NINT( zkt ) /= 1 .AND.  nrsttr /= 0 )                                  &
+            &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 &
+            &                  ' verify the restart file or rerun with nrsttr = 0 (namelist)' )
+#if defined key_off_tra
+         ! define ndastp and adatrj
+         IF ( nrsttr == 2 ) THEN
+            CALL iom_get( numrtr, 'ndastp', zndastp ) 
+            ndastp = NINT( zndastp )
+            CALL iom_get( numrtr, 'adatrj', adatrj  )
+         ELSE
+            ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam
+            adatrj = ( REAL( nittrc000-1, wp ) * rdttra(1) ) / rday
+            ! note this is wrong if time step has changed during run
+         ENDIF
+         !
+         IF(lwp) THEN
+           WRITE(numout,*) ' *** Info used values : '
+           WRITE(numout,*) '   date ndastp                                      : ', ndastp
+           WRITE(numout,*) '   number of elapsed days since the begining of run : ', adatrj
+           WRITE(numout,*)
+         ENDIF
+         !
+         CALL day_init          ! compute calendar
+         !
+#endif
+
+      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
+         !
+         IF(  kt == nitrst ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'trc_wri : write the TOP restart file (NetCDF) at it= ', kt, ' date= ', ndastp
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
+         ENDIF
+         ! calendar control
+         CALL iom_rstput( kt, nitrst, numrtw, 'kt'     , REAL( kt    , wp) )   ! time-step
+         CALL iom_rstput( kt, nitrst, numrtw, 'ndastp' , REAL( ndastp, wp) )   ! date
+         CALL iom_rstput( kt, nitrst, numrtw, 'adatrj' , adatrj            )   ! number of elapsed days since
+         !                                                                     ! the begining of the run [s]
+      ENDIF
+
+   END SUBROUTINE trc_rst_cal
+
+
+   SUBROUTINE trc_rst_stat
+      !!----------------------------------------------------------------------
+      !!                    ***  trc_rst_stat  ***
+      !!
+      !! ** purpose  :   Compute tracers statistics
+      !!----------------------------------------------------------------------
+
+      INTEGER  :: ji, jj, jk, jn
+      REAL(wp) :: zdiag_var, zdiag_varmin, zdiag_varmax, zdiag_tot
+      REAL(wp) :: zder, zvol
+      !!----------------------------------------------------------------------
+
+
+      IF( lwp ) THEN
+         WRITE(numout,*) 
+         WRITE(numout,*) '           ----TRACER STAT----             '
+         WRITE(numout,*) 
+      ENDIF
+      
+      zdiag_tot = 0.e0
+      DO jn = 1, jptra
+         zdiag_var    = 0.e0
+         zdiag_varmin = 0.e0
+         zdiag_varmax = 0.e0
+         DO jk = 1, jpk
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zvol = cvol(ji,jj,jk)
+#  if defined key_off_degrad
+                  zvol = zvol * facvol(ji,jj,jk)
+#  endif
+                  zdiag_var = zdiag_var + trn(ji,jj,jk,jn) * zvol
+               END DO
+            END DO
+         END DO
+         
+         zdiag_varmin = MINVAL( trn(:,:,:,jn), mask= ((tmask*SPREAD(tmask_i,DIM=3,NCOPIES=jpk).NE.0.)) )
+         zdiag_varmax = MAXVAL( trn(:,:,:,jn), mask= ((tmask*SPREAD(tmask_i,DIM=3,NCOPIES=jpk).NE.0.)) )
+         IF( lk_mpp ) THEN
+            CALL mpp_min( zdiag_varmin )      ! min over the global domain
+            CALL mpp_max( zdiag_varmax )      ! max over the global domain
+            CALL mpp_sum( zdiag_var    )      ! sum over the global domain
+         END IF
+         zdiag_tot = zdiag_tot + zdiag_var
+         zdiag_var = zdiag_var / areatot
+         IF(lwp) WRITE(numout,*) '   MEAN NO ', jn, ctrcnm(jn), ' = ', zdiag_var,   &
+            &                    ' MIN = ', zdiag_varmin, ' MAX = ', zdiag_varmax
+      END DO
+      
+      zder = ( ( zdiag_tot - trai ) / ( trai + 1.e-12 )  ) * 100._wp
+      IF(lwp) WRITE(numout,*) '   Integral of all tracers over the full domain  = ', zdiag_tot
+      IF(lwp) WRITE(numout,*) '   Drift of the sum of all tracers =', zder, ' %'
+      
+   END SUBROUTINE trc_rst_stat
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_rst_read                      ! Empty routines
+   END SUBROUTINE trc_rst_read
+   SUBROUTINE trc_rst_wri( kt )
+      INTEGER, INTENT ( in ) :: kt
+      WRITE(*,*) 'trc_rst_wri: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_rst_wri   
+#endif
+
+   !!======================================================================
+END MODULE trcrst
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcsms.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcsms.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcsms.F90	(revision 1844)
@@ -0,0 +1,78 @@
+MODULE trcsms
+   !!======================================================================
+   !!                         ***  MODULE trcsms  ***
+   !! TOP :   Time loop of passive tracers sms
+   !!======================================================================
+   !! History :   1.0  !  2005-03 (O. Aumont, A. El Moussaoui) F90
+   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
+   !!----------------------------------------------------------------------
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   'key_top'                                                TOP models
+   !!----------------------------------------------------------------------
+   !!   trc_sms        :  Time loop of passive tracers sms
+   !!----------------------------------------------------------------------
+   USE oce_trc            !
+   USE trc                !
+   USE trcsms_lobster     ! LOBSTER bio-model
+   USE trcsms_pisces      ! PISCES biogeo-model
+   USE trcsms_cfc         ! CFC 11 & 12
+   USE trcsms_c14b        ! C14b tracer 
+   USE trcsms_my_trc      ! MY_TRC  tracers
+   USE prtctl_trc         ! Print control for debbuging
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_sms    ! called in trcstp.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_sms( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_sms  ***
+      !!
+      !! ** Purpose :   Managment of the time loop of passive tracers sms 
+      !!
+      !! ** Method  : -  call the main routine of of each defined tracer model
+      !! -------------------------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index      
+      !!
+      CHARACTER (len=25) :: charout
+      !!---------------------------------------------------------------------
+
+      IF ( MOD(kt,ndttrc) /= 0) RETURN      ! this ROUTINE is called only every ndttrc time step
+
+      IF( lk_lobster )   CALL trc_sms_lobster( kt )    ! main program of LOBSTER
+      IF( lk_pisces  )   CALL trc_sms_pisces ( kt )    ! main program of PISCES 
+      IF( lk_cfc     )   CALL trc_sms_cfc    ( kt )    ! surface fluxes of CFC
+      IF( lk_c14b    )   CALL trc_sms_c14b   ( kt )    ! surface fluxes of C14
+      IF( lk_my_trc  )   CALL trc_sms_my_trc ( kt )    ! MY_TRC  tracers
+
+      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
+         WRITE(charout, FMT="('sms ')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
+      ENDIF
+      !
+   END SUBROUTINE trc_sms
+
+#else
+   !!======================================================================
+   !!  Dummy module :                                     No passive tracer
+   !!======================================================================
+CONTAINS
+   SUBROUTINE trc_sms( kt )                   ! Empty routine
+      INTEGER, INTENT( in ) ::   kt
+      WRITE(*,*) 'trc_sms: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_sms
+#endif 
+
+   !!======================================================================
+END MODULE  trcsms
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcstp.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcstp.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcstp.F90	(revision 1844)
@@ -0,0 +1,90 @@
+MODULE trcstp
+   !!======================================================================
+   !!                       ***  MODULE trcstp  ***
+   !! Time-stepping    : time loop of opa for passive tracer
+   !!======================================================================
+#if defined key_top
+   !!----------------------------------------------------------------------
+   !!   trc_stp      : passive tracer system time-stepping
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce_trc          ! ocean dynamics and active tracers variables
+   USE trp_trc
+   USE trctrp           ! passive tracers transport
+   USE trcsms           ! passive tracers sources and sinks
+   USE prtctl_trc       ! Print control for debbuging
+   USE trcdia
+   USE trcwri
+   USE trcrst
+   USE trdmld_trc_oce
+   USE trdmld_trc
+   USE iom
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC trc_stp           ! called by step
+   !!----------------------------------------------------------------------
+   !!   TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id: trcstp.F90 1285 2009-02-03 13:38:51Z cetlod $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_stp( kt )
+      !!-------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_stp  ***
+      !!                      
+      !! ** Purpose : Time loop of opa for passive tracer
+      !! 
+      !! ** Method  : 
+      !!              Compute the passive tracers trends 
+      !!              Update the passive tracers
+      !!
+      !! History :
+      !!   9.0  !  04-03  (C. Ethe)  Original
+      !!-------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::  kt  ! ocean time-step index
+      CHARACTER (len=25)    ::  charout
+
+      ! this ROUTINE is called only every ndttrc time step
+      IF( MOD( kt , ndttrc ) /= 0 ) RETURN
+
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
+         CALL prt_ctl_trc_info(charout)
+      ENDIF
+
+      IF( kt == nittrc000 .AND. lk_trdmld_trc  )  &
+         &                   CALL trd_mld_trc_init        ! trends: Mixed-layer
+                             CALL trc_rst_opn( kt )       ! Open tracer restart file 
+                             CALL trc_sms( kt )           ! tracers: sink and source
+                             CALL trc_trp( kt )           ! transport of passive tracers
+      IF( kt == nittrc000 )  CALL iom_close( numrtr )     ! close input  passive tracers restart file
+      IF( lrst_trc )         CALL trc_rst_wri( kt )       ! write tracer restart file
+      IF( lk_iomput ) THEN
+                             CALL trc_wri( kt )           ! output of passive tracers
+      ELSE
+                             CALL trc_dia( kt )   ! diagnostics
+      ENDIF
+      IF( lk_trdmld_trc  )   CALL trd_mld_trc( kt )     ! trends: Mixed-layer
+
+   END SUBROUTINE trc_stp
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default key                                     NO passive tracers
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE trc_stp( kt )        ! Empty routine
+      INTEGER, INTENT(in) :: kt
+      WRITE(*,*) 'trc_stp: You should not have seen this print! error?', kt
+   END SUBROUTINE trc_stp
+#endif
+
+   !!======================================================================
+END MODULE trcstp
Index: /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcwri.F90
===================================================================
--- /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcwri.F90	(revision 1844)
+++ /branches/DEV_r1837_MLF/NEMO/TOP_SRC/trcwri.F90	(revision 1844)
@@ -0,0 +1,153 @@
+MODULE trcwri
+   !!===================================================================================
+   !!                       *** MODULE trcwri ***
+   !!    TOP :   Output of passive tracers
+   !!====================================================================================
+   !! History :   1.0  !  2009-05 (C. Ethe)  Original code
+   !!                  !  2010-03 (C. Ethe, R. Seferian ) Add the tracer transport trends
+   !!----------------------------------------------------------------------
+#if defined key_top &&  defined key_iomput
+   !!----------------------------------------------------------------------
+   !!   'key_top' && 'key_iomput'                              TOP models
+   !!----------------------------------------------------------------------
+   !! trc_wri_trc   :  outputs of concentration fields
+   !! trc_wri_trd   :  outputs of transport trends
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain variables
+   USE oce_trc
+   USE trp_trc
+   USE trc
+   USE trdmld_trc_oce, ONLY : luttrd
+   USE iom
+#if defined key_off_tra
+   USE oce_trc
+   USE dianam
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC trc_wri      
+
+   !! * Substitutions
+#  include "top_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
+   !! $Id: trcdia.F90 1450 2009-05-15 14:12:12Z cetlod $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE trc_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri  ***
+      !! 
+      !! ** Purpose :   output passive tracers fields and dynamical trends
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) :: kt
+      !!---------------------------------------------------------------------
+
+      !
+      CALL iom_setkt  ( kt + ndttrc - 1 )       ! set the passive tracer time step
+      CALL trc_wri_trc( kt              )       ! outputs for tracer concentration
+      CALL trc_wri_trd( kt              )       ! outputs for dynamical trends
+      CALL iom_setkt  ( kt              )       ! set the model time step
+      !
+   END SUBROUTINE trc_wri
+
+   SUBROUTINE trc_wri_trc( kt )  
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri_trc  ***
+      !!
+      !! ** Purpose :   output passive tracers fields 
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT( in ) :: kt       ! ocean time-step
+      INTEGER               :: jn
+      CHARACTER (len=20)    :: cltra, cltras
+#if defined key_off_tra
+      CHARACTER (len=40) :: clhstnam
+      INTEGER ::   inum = 11            ! temporary logical unit
+#endif
+      !!---------------------------------------------------------------------
+ 
+#if defined key_off_tra
+      IF( kt == nittrc000 ) THEN
+        ! WRITE root name in date.file for use by postpro
+         IF(lwp) THEN
+            CALL dia_nam( clhstnam, nwritetrc,' ' )
+            CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+            WRITE(inum,*) clhstnam
+            CLOSE(inum)
+         ENDIF
+      ENDIF
+#endif
+      ! write the tracer concentrations in the file
+      ! ---------------------------------------
+      DO jn = 1, jptra
+         cltra = ctrcnm(jn)                   ! short title for tracer
+         CALL iom_put( cltra, trn(:,:,:,jn) )
+      END DO
+      !
+   END SUBROUTINE trc_wri_trc
+
+# if defined key_trc_diatrd
+
+   SUBROUTINE trc_wri_trd( kt )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_wri_trd  ***
+      !!
+      !! ** Purpose :   output of passive tracer : advection-diffusion trends
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt          ! ocean time-step
+      !!
+      CHARACTER (len=3) ::   cltra
+      INTEGER  ::   jn, jl, ikn
+      !!----------------------------------------------------------------------
+
+      DO jn = 1, jptra
+         IF( luttrd(jn) ) THEN
+            ikn = ikeep(jn)
+            DO jl = 1, jpdiatrc
+               IF( jl == jptrc_xad ) WRITE (cltra,"(3a)") 'XAD' ! x advection for tracer
+               IF( jl == jptrc_yad ) WRITE (cltra,"(3a)") 'YAD'  ! y advection for tracer
+               IF( jl == jptrc_zad ) WRITE (cltra,"(3a)") 'ZAD'  ! z advection for tracer
+               IF( jl == jptrc_xdf ) WRITE (cltra,"(3a)") 'XDF'  ! x diffusion for tracer
+               IF( jl == jptrc_ydf ) WRITE (cltra,"(3a)") 'YDF'  ! y diffusion for tracer
+               IF( jl == jptrc_zdf ) WRITE (cltra,"(3a)") 'ZDF'  ! z diffusion for tracer
+# if defined key_trcldf_eiv
+               IF( jl == jptrc_xei ) WRITE (cltra,"(3a)") 'XGV'  ! x gent velocity for tracer
+               IF( jl == jptrc_yei ) WRITE (cltra,"(3a)") 'YGV'  ! y gent velocity for tracer
+               IF( jl == jptrc_zei ) WRITE (cltra,"(3a)") 'ZGV'  ! z gent velocity for tracer
+# endif
+# if defined key_trcdmp
+               IF( jl == jptrc_dmp ) WRITE (cltra,"(3a)") 'DMP'  ! damping
+# endif
+               IF( jl == jptrc_sbc ) WRITE (cltra,"(3a)") 'SBC'  ! surface boundary conditions
+               ! write the trends
+               CALL iom_put( cltra, trtrd(:,:,:,ikn,jl) )
+            END DO
+         END IF
+      END DO
+      !
+   END SUBROUTINE trc_wri_trd
+
+# else
+   SUBROUTINE trc_wri_trd( kt )                      ! Dummy routine
+      INTEGER, INTENT ( in ) ::   kt
+   END SUBROUTINE trc_wri_trd
+#endif
+#else
+   !!----------------------------------------------------------------------
+   !!  Dummy module :                                     No passive tracer
+   !!----------------------------------------------------------------------
+   PUBLIC trc_wri
+CONTAINS
+   SUBROUTINE trc_wri( kt )                     ! Empty routine   
+   INTEGER, INTENT(in) :: kt
+   END SUBROUTINE trc_wri
+#endif
+
+   !!======================================================================
+END MODULE trcwri
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make	(revision 1844)
@@ -0,0 +1,39 @@
+# $Id$
+all: launch
+
+# Copy required scripts and launch jobs
+launch: $(RUN) $(MKMO)
+ifneq ($(JOB),nojob)
+	cp    ../NVTK/INSTALL/JOBS/LOBSTER_stat.ksh        $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	cp    ../NVTK/INSTALL/JOBS/PISCES_stat.ksh         $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	cp -p ../NVTK/INSTALL/JOBS/assessment.ksh          $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	cp -p ../NVTK/INSTALL/JOBS/cron_jobs.ksh           $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	cp    ../NVTK/INSTALL/JOBS/CPU_time_$(HPCTAR).ksh  $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	cp    ../NVTK/INSTALL/JOBS/MEM_size_$(HPCTAR).ksh  $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/.
+	@for rtype in `echo $(RUN)` ; do \
+	cp    ../NVTK/INSTALL/JOBS/job_$(NEMOLIB).ksh      $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/$$rtype/. ; \
+	cp    ../NVTK/INSTALL/JOBS/jhd_$(HPCTAR)_$$rtype   $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/$$rtype/. ; \
+	cp -p ../NVTK/INSTALL/JOBS/lance_batch.ksh         $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/$$rtype/. ; \
+	( cd $(WWDIR)/NEMO_VALID/W$(NEMOLIB)/$$rtype/ ; ./lance_batch.ksh $(NEMOLIB) $(MKTE) $(JOB) $(REXP) \
+          $(MPIIJ) $(RTG) $(USE_IOMPUT) $(USE_IOSERVER) $(NB_PROCS_IOSERVER) ; ) ; \
+	done
+endif
+
+# Compilation rules
+$(RUN) memo:
+	@if [ $@ = 'mpi' ] ; then \
+	cd MY_SRC ; \
+	grep -h jpni  par_oce.F90_keep | grep -v "*" | head -1 > tmp ; VAR_I=`( cat tmp )` ; rm -f tmp ; \
+	grep -h jpnj  par_oce.F90_keep | grep -v "*" | head -1 > tmp ; VAR_J=`( cat tmp )` ; rm -f tmp ; \
+	grep -h jpnij par_oce.F90_keep | grep -v "*" | head -1 > tmp ; VARIJ=`( cat tmp )` ; rm -f tmp ; \
+	sed -e "s%$$VAR_I%      jpni  = $$MPI_I  , \&%" \
+	    -e "s%$$VAR_J%      jpnj  = $$MPI_J  , \&%" \
+	    -e "s%$$VARIJ%      jpnij = $$MPIIJ      %" par_oce.F90_keep > par_oce.F90 ; \
+	cd .. ; \
+	fi
+	@gmake -C WORK COMP=$@ EXPER=$(REXP) USE_IOMPUT=$(USE_IOMPUT) clean > $(NEMOLIB)_logbook_$@.txt
+	@gmake -C WORK COMP=$@ EXPER=$(REXP) USE_IOMPUT=$(USE_IOMPUT) >> $(NEMOLIB)_logbook_$@.txt
+	@rm -f ./MY_SRC/par_oce.F90 > /dev/null 2>&1
+
+nomemo:
+	@echo 'No memory check'
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make.ldef
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make.ldef	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/AA_make.ldef	(revision 1844)
@@ -0,0 +1,27 @@
+# $Id$
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCA :
+#-      ORCA  (lib, executable : opa)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../../../lib
+BINDIR = ../../../../bin
+MODDIR = $(LIBDIR)
+NEMOLIB := $(shell awk '{ print $$1 }' ./WORK/.config)
+RUN=
+MPI_I=
+MPI_J=
+MPIIJ=
+JOB=
+RTG=
+MKTE=
+MKMO=
+REXP=
+USE_IOMPUT = 
+USE_IOSERVER = 
+NB_PROCS_IOSERVER = 
+WWDIR=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+HPCTAR=
+#---------------------------------------------------------------------
+#-
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE	(revision 1844)
@@ -0,0 +1,50 @@
+# $Id$
+#---------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model (BB_make.ldef in scripts)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+
+#-
+#- Key options for GYRE ocean configuration: Analytical forcing ---
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_zco key_gyre key_dynspg_flt key_ldfslp key_zdftke key_vectopt_loop key_vectopt_memory   
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER	(revision 1844)
@@ -0,0 +1,50 @@
+# $Id$
+#---------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model (BB_make.ldef in scripts)
+#---------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+MODDIR = $(LIBDIR)
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+
+#-
+#- Key options for GYRE+LOBSTER configuration: Analytical forcing ---
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_zco key_gyre key_dynspg_flt key_ldfslp key_zdftke key_vectopt_loop key_vectopt_memory key_top key_lobster key_trc_diaadd key_trc_dia3d
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM	(revision 1844)
@@ -0,0 +1,51 @@
+# $Id$
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+USE_IOMPUT = 
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_trabbc key_zdftke key_zdfddm
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3	(revision 1844)
@@ -0,0 +1,51 @@
+# $Id$
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+USE_IOMPUT = 
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim3 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_trabbc key_zdftke key_zdfddm
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES	(revision 1844)
@@ -0,0 +1,50 @@
+# $Id: BB_make.ldef_ORCA2_LIM 1301 2009-02-09 17:15:38Z ctlod $
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_trabbc key_zdftke key_zdfddm key_top key_pisces key_trcbbl_dif key_trcldf_eiv key_trc_zdfddm
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES	(revision 1844)
@@ -0,0 +1,50 @@
+# $Id: BB_make.ldef_ORCA2_LIM 1301 2009-02-09 17:15:38Z ctlod $
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 6
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_dynspg_flt key_ldfslp key_traldf_c2d key_traldf_eiv key_zdftke key_zdfddm key_top key_off_tra key_pisces key_trcbbl_dif key_trcldf_eiv key_trc_zdfddm
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF	(revision 1844)
@@ -0,0 +1,50 @@
+# $Id$
+#----------------------------------------------------------------------
+#- NEMO SYSTEM : Ocean model + Sea Ice Model   (BB_make.ldef in scripts)
+#----------------------------------------------------------------------
+SHELL = /bin/sh
+#-
+#-Q- t3e     #--- Please use gmake instead of make
+#-Q- fjvpp   #--- Please use gmake instead of make
+
+#-
+#- Define the libraries ---
+LIBDIR = ../../../lib
+NEMOLIB := $(shell awk '{ print $$1 }' .config)
+COMP=
+EXPER=
+MODDIR = $(LIBDIR)
+MODEL_LIB = $(LIBDIR)/oce_$(NEMOLIB)/$(COMP)
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+#-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+AGRIF_LIB = $(LIBDIR)/libagrif.a
+#-Q- sxdkrz AGRIF_LIB = $(LIBDIR)/libsxagrif.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+OASISMPI2_LIB = 
+LIBMPI  =
+LIBMP   =
+EXEC_BIN = ../../../bin/opa_$(NEMOLIB)_$(COMP)_$(EXPER)
+NBPRC = 1
+
+#-
+#- Key options for OPA ocean model + LIM sea ice model : ORCA_R2 - FORCED (CLIO)
+#  Keys have to be written on one single line (does NOT accept "\")
+
+P_P = key_trabbl_dif key_vectopt_loop key_vectopt_memory key_orca_r2 key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_dtatem key_dtasal key_trabbc key_zdftke key_zdfddm key_agrif
+
+#-
+#- Prefix for preprocessing ---
+#-Q- sx8mercure prefix = -D
+#-Q- sx8brodie prefix = -D
+#-Q- es2 prefix = -D
+#-Q- sxdkrz prefix = -D
+#-Q- linux  prefix = -D
+#-Q- lxiv7  prefix = -D
+#-Q- lxiv8  prefix = -D
+#-Q- g95    prefix = -D
+#-Q- gfortran  prefix = -D
+#-Q- aix6    prefix = -WF,-D
+#-Q- babel  prefix = -WF,-D
+#-Q- osxxlf prefix = -WF,-D
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_aix6.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_aix6.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_aix6.ksh	(revision 1844)
@@ -0,0 +1,161 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zrunt  : run type to treat
+#     - zfile1 : mon run timing input file name
+#     - zfile2 : mpi run timing input file name
+#     - zout   : output file name
+#     - ztag   : tag name to which are compared files
+#     - zxis   : (0/1) reference timing files (do/do not) exist
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the aix target for 
+#        mon & mpi run 
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-r] [-a] [-b] [-o] [-t] [-x]"
+  echo "Options: These are optional argument"
+  echo " -r : run type to treat"
+  echo " -a : current version timing input file name"
+  echo " -b : reference version timing input file name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " -x : (0/1) reference timing files (do/do not) exist"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zrunt=
+zfile1=
+zfile2=
+zout=
+ztag=
+zxis=1
+
+# Get arguments
+while getopts r:a:b:o:t:x: opt
+do
+  case "$opt" in
+    r) zrunt="$OPTARG";;
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    x) zxis="$OPTARG";;
+    *) help_CPU_time;;
+  esac
+done
+
+# Check if results must be compare to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+case "${zrunt}" in
+
+     'mon' )
+
+           # OUTPUT TIMING OF THE MON RUN
+           ##############################
+           
+           if [ ${evaltag} -a ${zxis} == 0 ] ; then
+               # Get values from the reference tag
+               zreal=$( awk '/wall clock time/           {print $6}' ${zfile2} )
+               zuser=$( awk '/Total amount of time in u/ {print $9}' ${zfile2} )
+               zmemo=$( awk '/Maximum resident set size/ {print $6/1024}' ${zfile2} )
+               zuzra=$( awk '/Utilization rate/          {print $4}' ${zfile2} )
+               # Print: Variable long name | current version values | reference version values | variations
+               echo "                                                 Current version     ${ztag} version       Variation " >> ${zout}
+               echo "                                                                 " >> ${zout}
+               awk '/wall clock time/            { creal=$6      ; printf("%-6s %.33s %8s %12.2f    | %12.2f      |     %7.2f % \n", " ", $0, "(sec) :"    , $6  , invar, ((creal-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '/Total amount of time in u/  { cuser=$9      ; printf("%-6s %.34s %7s %12.2f    | %12.2f      |     %7.2f % \n", " ", $0, "(sec) :"    , $9  , invar, ((cuser-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '/Maximum resident set size/  { cmflo=$6/1024 ; printf("%-6s %.26s %15s %12.2f    | %12.2f      |     %7.2f % \n", " ", $0, "(Mo) :"     ,cmflo, invar, ((cmflo-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               awk '/Utilization rate/           { cuzra=$4      ; printf("%-5s %.24s %18s %12.2f    | %12.2f      |     %7.2f % \n", " ", $0, "~100% (%) :", $4  , invar, ((cuzra-invar)/invar)*100 ) }' invar=${zuzra} ${zfile1} >> ${zout}
+           else
+               # Print: Variable long name | current version values
+               echo "                                                 Current version " >> ${zout}
+               echo "                                                                 " >> ${zout}
+               awk '/wall clock time/            {printf("%-6s %.33s %8s %9.2f \n", " ", $0, "(sec) :"    , $6      ) }' ${zfile1} >> ${zout}
+               awk '/Total amount of time in u/  {printf("%-6s %.34s %7s %9.2f \n", " ", $0, "(sec) :"    , $9      ) }' ${zfile1} >> ${zout}
+               awk '/Maximum resident set size/  {printf("%-6s %.26s %15s %9.2f \n", " ", $0, "(Mo) :"     , $6/1024) }' ${zfile1} >> ${zout}
+               awk '/Utilization rate/           {printf("%-5s %.24s %18s %9.2f \n", " ", $0, "~100% (%) :", $4     ) }' ${zfile1} >> ${zout}
+           fi 
+
+           ;;
+
+     'mpi' )
+           
+           # OUTPUT TIMING OF THE MPI RUN
+           ##############################
+           
+           if [ ${evaltag} -a ${zxis} == 0 ] ; then
+               # Get values from the reference tag
+               awk '/wall clock time/           {print}' ${zfile2} > temp1
+               awk '/Maximum resident set size/ {print}' ${zfile2} > temp2
+               awk '/Utilization rate/          {print}' ${zfile2} > temp3
+           
+               zreal=$( awk '/wall clock time/           {cum += $6} END {printf("%f", cum/NR) }'        temp1 )
+               zuser=$( awk '/Total amount of time in u/ {cum += $9} END {printf("%f", cum )   }'        ${zfile2})
+               zmemo=$( awk '/Maximum resident set size/ {cum += $6} END {printf("%f", cum/(1024*NR)) }' temp2 )
+               zuzra=$( awk '/Utilization rate/          {cum += $4} END {printf("%f", cum/NR) }'        temp3 )
+           
+               # Get values from the current version
+               awk '/wall clock time/           {print}' ${zfile1} > temp1
+               awk '/Maximum resident set size/ {print}' ${zfile1} > temp2
+               awk '/Utilization rate/          {print}' ${zfile1} > temp3
+           
+               echo "                                                 Current version     ${ztag} version       Variation " >> ${zout}
+               echo "                                                                                                     " >> ${zout}
+               awk '/wall clock time/           {cum += $6} END {printf("%-7s %-39s %1s %11.2f    |     %12.2f   |     %7.2f %\n" , " ", "Execution time (wall clock time)  (sec)", ":", cum/NR       , invar, ((cum/NR-invar)/invar)*100  ) }' invar=${zreal} temp1     >> ${zout}
+               awk '/Total amount of time in u/ {cum += $9} END {printf("%-7s %-39s %1s %11.2f    |     %12.2f   |     %7.2f %\n" , " ", "Total amount of time in user mode (sec)", ":", cum          , invar, ((cum-invar)/invar)*100  ) }'    invar=${zuser} ${zfile1} >> ${zout}
+               awk '/Maximum resident set size/ {cum += $6} END {printf("%-7s %-25s %15s %12.2f   |     %12.2f   |     %7.2f %\n", " ", "Maximum resident set size", "(Mo)  :"        , cum/(1024*NR), invar, ((cum/(1024*NR)-invar)/invar)*100  ) }'  invar=${zmemo} temp2     >> ${zout}
+               awk '/Utilization rate/          {cum += $4} END {printf("%-7s %-16s %24s %12.2f   |     %12.2f   |     %7.2f %\n", " ", "Utilization rate", "(%)   :"                 , cum/NR       , invar, ((cum/NR-invar)/invar)*100  ) }' invar=${zuzra} temp3     >> ${zout}
+           
+               echo "                                                                                                     " >> ${zout}
+           
+               \rm temp*
+           
+           else
+               # Get values from the current version
+               awk '/wall clock time/           {print}' ${zfile1} > temp1
+               awk '/Maximum resident set size/ {print}' ${zfile1} > temp2
+               awk '/Utilization rate/          {print}' ${zfile1} > temp3
+           
+               echo "                                                 Current version " >> ${zout}
+               echo "                                                                 " >> ${zout}
+               awk '/wall clock time/           {cum += $6} END {printf("%-7s %-39s %1s %9.2f\n" , " ", "Execution time (wall clock time)  (sec)", ":", cum/NR ) }' temp1     >> ${zout}
+               awk '/Total amount of time in u/ {cum += $9} END {printf("%-7s %-39s %1s %9.2f\n" , " ", "Total amount of time in user mode (sec)", ":", cum ) }'    ${zfile1} >> ${zout}
+               awk '/Maximum resident set size/ {cum += $6} END {printf("%-7s %-25s %15s %9.2f\n", " ", "Maximum resident set size", "(Mo)  :", cum/(1024*NR) ) }'  temp2     >> ${zout}
+               awk '/Utilization rate/          {cum += $4} END {printf("%-7s %-16s %24s %9.2f\n", " ", "Utilization rate", "(%)   :", cum/NR ) }'                  temp3     >> ${zout}
+           
+               echo "                                                                                                     " >> ${zout}
+           
+               \rm temp*
+           fi
+
+           ;;
+esac
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_osxxlf.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_osxxlf.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_osxxlf.ksh	(revision 1844)
@@ -0,0 +1,180 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zrunt  : run type to treat
+#     - zfile1 : mon run timing input file name
+#     - zfile2 : mpi run timing input file name
+#     - zout   : output file name
+#     - ztag   : tag name to which are compared files
+#     - zxis   : (0/1) reference timing files (do/do not) exist
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-r] [-a] [-b] [-o] [-t] [-x]"
+  echo "Options: These are optional argument"
+  echo " -r : run type to treat"
+  echo " -a : current version timing input file name"
+  echo " -b : reference version timing input file name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " -x : (0/1) reference timing files (do/do not) exist"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zrunt=
+zfile1=
+zfile2=
+zout=
+ztag=
+zxis=1
+
+# Get arguments
+while getopts r:a:b:o:t:x: opt
+do
+  case "$opt" in
+    r) zrunt="$OPTARG";;
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    x) zxis="$OPTARG";;
+    *) help_CPU_time;;
+  esac
+done
+
+# Check if results must be compare to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+case "${zrunt}" in
+
+     'mon' )
+
+           # OUTPUT TIMING OF THE MON/OMP RUN
+           ###################################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get values from the reference tag
+               zreal=$( (awk '/Real/        {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '/User/        {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '/MFLOPS/ && ! /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmfli=$( (awk '/MFLOPS/ &&   /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmprc=$( (awk '/Max Concurrent Proc/           {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '/VLEN/        {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '/Memory Size/ {print $NF}' ${zfile2} ) )
+               # Print: Variable long name | current version values | reference version values | variations
+               echo "                                Current version    ${ztag} version    Variation " >> ${zout}
+               awk '/Real/         { creal=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((creal-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '/User/         { cuser=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cuser-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/      { cmflo=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmflo-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/      { cmfli=$4 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmfli-invar)/invar)*100 ) }' invar=${zmfli} ${zfile1} >> ${zout}
+               awk '/VLEN/         { cvlen=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cvlen-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '/Memory Size/  { cmemo=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmemo-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout} 
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i      | %10i    |   %7i \n", " ", $0, $NF, invar, (cmprc-invar) ) }' invar=${zmprc} ${zfile1} >> ${zout} 
+           else
+               # Print: Variable long name | current version values
+               echo "                                 Current version " >> ${zout}
+               awk '/Real/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/User/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/VLEN/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/Memory Size/ {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i\n", " ", $0, $NF ) }' ${zfile1} >> ${zout} 
+           fi 
+
+           ;;
+
+     'mpi' )
+           # OUTPUT TIMING OF THE MPI RUN
+           ##############################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get reference tag information
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '( /\[/ && /\]/ ) && /User/                           {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '( /\[/ && /\]/ ) && /MFLOPS/                         {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '( /\[/ && /\]/ ) && /Average Vector Length/          {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values | reference version values | variations
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Global Data/ { printf( "        %.29s  Current version   %s version      Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("        %s \n", $0) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Get reference tag information (Overall data)
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '!( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/                {print $NF}' ${zfile2} ) )
+               zgflo=$( (awk '!( /\[/ && /\]/ ) && /GFLOPS/                         {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '!( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values 
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Overall Data/ { printf( "        %-28s  Current version   %s version       Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zgflo} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+           else
+           
+               # Print: Variable long name | current version values 
+               awk '/Global Data/ { printf( "        %.29s   Current version\n ", $0) }' ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("%-7s %-.26s \n", " ", $0) } ' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Print: Variable long name | current version values (Overall data)
+               awk '/Overall Data/ { printf( "        %-28s   Current version\n ", $0 ) }' ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/  && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               echo "" >> ${zout} 
+           fi
+           ;;
+esac
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8brodie.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8brodie.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8brodie.ksh	(revision 1844)
@@ -0,0 +1,180 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zrunt  : run type to treat
+#     - zfile1 : mon run timing input file name
+#     - zfile2 : mpi run timing input file name
+#     - zout   : output file name
+#     - ztag   : tag name to which are compared files
+#     - zxis   : (0/1) reference timing files (do/do not) exist
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-r] [-a] [-b] [-o] [-t] [-x]"
+  echo "Options: These are optional argument"
+  echo " -r : run type to treat"
+  echo " -a : current version timing input file name"
+  echo " -b : reference version timing input file name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " -x : (0/1) reference timing files (do/do not) exist"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zrunt=
+zfile1=
+zfile2=
+zout=
+ztag=
+zxis=1
+
+# Get arguments
+while getopts r:a:b:o:t:x: opt
+do
+  case "$opt" in
+    r) zrunt="$OPTARG";;
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    x) zxis="$OPTARG";;
+    *) help_CPU_time;;
+  esac
+done
+
+# Check if results must be compare to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+case "${zrunt}" in
+
+     'mon' | 'omp' )
+
+           # OUTPUT TIMING OF THE MON/OMP RUN
+           ###################################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get values from the reference tag
+               zreal=$( (awk '/Real/        {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '/User/        {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '/MFLOPS/ && ! /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmfli=$( (awk '/MFLOPS/ &&   /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmprc=$( (awk '/Max Concurrent Proc/           {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '/VLEN/        {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '/Memory Size/ {print $NF}' ${zfile2} ) )
+               # Print: Variable long name | current version values | reference version values | variations
+               echo "                                Current version    ${ztag} version    Variation " >> ${zout}
+               awk '/Real/         { creal=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((creal-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '/User/         { cuser=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cuser-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/      { cmflo=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmflo-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/      { cmfli=$4 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmfli-invar)/invar)*100 ) }' invar=${zmfli} ${zfile1} >> ${zout}
+               awk '/VLEN/         { cvlen=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cvlen-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '/Memory Size/  { cmemo=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmemo-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout} 
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i      | %10i    |   %7i \n", " ", $0, $NF, invar, (cmprc-invar) ) }' invar=${zmprc} ${zfile1} >> ${zout} 
+           else
+               # Print: Variable long name | current version values
+               echo "                                 Current version " >> ${zout}
+               awk '/Real/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/User/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/VLEN/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/Memory Size/ {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i\n", " ", $0, $NF ) }' ${zfile1} >> ${zout} 
+           fi 
+
+           ;;
+
+     'mpi' )
+           # OUTPUT TIMING OF THE MPI RUN
+           ##############################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get reference tag information
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '( /\[/ && /\]/ ) && /User/                           {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '( /\[/ && /\]/ ) && /MFLOPS/                         {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '( /\[/ && /\]/ ) && /Average Vector Length/          {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values | reference version values | variations
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Global Data/ { printf( "        %.29s  Current version   %s version      Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("        %s \n", $0) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Get reference tag information (Overall data)
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '!( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/                {print $NF}' ${zfile2} ) )
+               zgflo=$( (awk '!( /\[/ && /\]/ ) && /GFLOPS/                         {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '!( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values 
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Overall Data/ { printf( "        %-28s  Current version   %s version       Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zgflo} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+           else
+           
+               # Print: Variable long name | current version values 
+               awk '/Global Data/ { printf( "        %.29s   Current version\n ", $0) }' ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("%-7s %-.26s \n", " ", $0) } ' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Print: Variable long name | current version values (Overall data)
+               awk '/Overall Data/ { printf( "        %-28s   Current version\n ", $0 ) }' ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/  && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               echo "" >> ${zout} 
+           fi
+           ;;
+esac
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8mercure.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8mercure.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/CPU_time_sx8mercure.ksh	(revision 1844)
@@ -0,0 +1,180 @@
+#!/bin/ksh
+# $Id: CPU_time_sx8brodie.ksh 1301 2009-02-09 17:15:38Z ctlod $
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zrunt  : run type to treat
+#     - zfile1 : mon run timing input file name
+#     - zfile2 : mpi run timing input file name
+#     - zout   : output file name
+#     - ztag   : tag name to which are compared files
+#     - zxis   : (0/1) reference timing files (do/do not) exist
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-r] [-a] [-b] [-o] [-t] [-x]"
+  echo "Options: These are optional argument"
+  echo " -r : run type to treat"
+  echo " -a : current version timing input file name"
+  echo " -b : reference version timing input file name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " -x : (0/1) reference timing files (do/do not) exist"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zrunt=
+zfile1=
+zfile2=
+zout=
+ztag=
+zxis=1
+
+# Get arguments
+while getopts r:a:b:o:t:x: opt
+do
+  case "$opt" in
+    r) zrunt="$OPTARG";;
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    x) zxis="$OPTARG";;
+    *) help_CPU_time;;
+  esac
+done
+
+# Check if results must be compare to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+case "${zrunt}" in
+
+     'mon' | 'omp' )
+
+           # OUTPUT TIMING OF THE MON/OMP RUN
+           ###################################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get values from the reference tag
+               zreal=$( (awk '/Real/        {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '/User/        {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '/MFLOPS/ && ! /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmfli=$( (awk '/MFLOPS/ &&   /concurrent/      {print $NF}' ${zfile2} ) )
+               [ ${zrunt} = 'omp' ] && zmprc=$( (awk '/Max Concurrent Proc/           {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '/VLEN/        {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '/Memory Size/ {print $NF}' ${zfile2} ) )
+               # Print: Variable long name | current version values | reference version values | variations
+               echo "                                Current version    ${ztag} version    Variation " >> ${zout}
+               awk '/Real/         { creal=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((creal-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '/User/         { cuser=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cuser-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/      { cmflo=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmflo-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/      { cmfli=$4 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmfli-invar)/invar)*100 ) }' invar=${zmfli} ${zfile1} >> ${zout}
+               awk '/VLEN/         { cvlen=$3 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cvlen-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '/Memory Size/  { cmemo=$5 ; printf("%-5s %.25s  %10.2f      | %10.2f    |   %7.2f % \n", " ", $0, $NF, invar, ((cmemo-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout} 
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i      | %10i    |   %7i \n", " ", $0, $NF, invar, (cmprc-invar) ) }' invar=${zmprc} ${zfile1} >> ${zout} 
+           else
+               # Print: Variable long name | current version values
+               echo "                                 Current version " >> ${zout}
+               awk '/Real/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/User/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/MFLOPS/ && ! /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/MFLOPS/ &&   /concurrent/     {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/VLEN/        {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               awk '/Memory Size/ {printf("%-5s %.25s  %10.2f\n", " ", $0, $NF ) }' ${zfile1} >> ${zout}
+               [ ${zrunt} = 'omp' ] && awk '/Max Concurrent Proc/  { cmprc=$5 ; printf("%-5s %.25s  %10i\n", " ", $0, $NF ) }' ${zfile1} >> ${zout} 
+           fi 
+
+           ;;
+
+     'mpi' )
+           # OUTPUT TIMING OF THE MPI RUN
+           ##############################
+           
+           if [ ${evaltag} == 0 -a ${zxis} == 0 ] ; then
+               # Get reference tag information
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '( /\[/ && /\]/ ) && /User/                           {print $NF}' ${zfile2} ) )
+               zmflo=$( (awk '( /\[/ && /\]/ ) && /MFLOPS/                         {print $NF}' ${zfile2} ) )
+               zvlen=$( (awk '( /\[/ && /\]/ ) && /Average Vector Length/          {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values | reference version values | variations
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Global Data/ { printf( "        %.29s  Current version   %s version      Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("        %s \n", $0) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmflo} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zvlen} ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Get reference tag information (Overall data)
+               # Syntax: 1) search pattern between // symbol, 2) print text of the last column (identified by $NF)
+               zreal=$( (awk '!( /\[/ && /\]/ ) && /Real/                           {print $NF}' ${zfile2} ) )
+               zuser=$( (awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/                {print $NF}' ${zfile2} ) )
+               zgflo=$( (awk '!( /\[/ && /\]/ ) && /GFLOPS/                         {print $NF}' ${zfile2} ) )
+               zmemo=$( (awk '!( /\[/ && /\]/ ) && ! /Global/ && /Memory size used/ {print $NF}' ${zfile2} ) )
+           
+               # Print: Variable long name | current version values 
+               # Syntax: 1) search pattern between // symbol, 2) print text & values following a format (printf) explicited between "" symbol
+               awk '/Overall Data/ { printf( "        %-28s  Current version   %s version       Variation \n", $0, tag) }' tag=${ztag} ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zreal} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zuser} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zgflo} ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/ && !/Global/ { printf( "%-7s %.29s  %10.2f     |   %10.2f    |    %7.2f %\n", " ", $0 , $NF, invar, (($NF-invar)/invar)*100 ) }' invar=${zmemo} ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+           else
+           
+               # Print: Variable long name | current version values 
+               awk '/Global Data/ { printf( "        %.29s   Current version\n ", $0) }' ${zfile1} >> ${zout}
+               awk '/==========================/ { printf("%-7s %-.26s \n", " ", $0) } ' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Real/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /User/                  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /MFLOPS/                { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Average Vector Length/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               awk '( /\[/ && /\]/ ) && /Memory size used/ && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF) }' ${zfile1} >> ${zout}
+               echo " " >> ${zout} 
+           
+               # Print: Variable long name | current version values (Overall data)
+               awk '/Overall Data/ { printf( "        %-28s   Current version\n ", $0 ) }' ${zfile1} >> ${zout}
+               echo "        =============" >> ${zout} 
+               awk '!( /\[/ && /\]/ ) && /Real/             { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && ! /OPS/ && /User/  { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /GFLOPS/           { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               awk '!( /\[/ && /\]/ ) && /Memory size used/  && ! /Global/ { printf( "%-7s %.29s  %10.2f \n", " ", $0 , $NF ) }' ${zfile1} >> ${zout}
+               echo "" >> ${zout} 
+           fi
+           ;;
+esac
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/LOBSTER_stat.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/LOBSTER_stat.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/LOBSTER_stat.ksh	(revision 1844)
@@ -0,0 +1,56 @@
+#!/bin/ksh
+# $Id: BIO_sx8brodie.ksh 1301 2009-02-09 17:15:38Z ctlod $
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 2
+#     - zfile1 : first tracer statistic file to output
+#     - zfile2 : second tracer statistic file to output
+#
+# WORK: It aims to :
+#
+#      - Extract tracers statistics from ocean.output 
+#        for mon, mpi & omp runs
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Initialization
+zfile1=
+zfile2=
+
+# Get arguments
+while getopts a:b:c: opt
+do
+  case "$opt" in
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    c) zfile3="$OPTARG";;
+  esac
+done
+
+zfile[0]=${zfile1}
+zfile[1]=${zfile2}
+zfilein=${zfile3}
+
+ind=0
+
+while [ ${ind} -le 1 ] ; do
+
+       zpath=$( ( dirname ${zfile[${ind}]} ) )
+
+       awk '/----TRACER STAT----/ { print $0 }' ${zpath}/${zfilein} > ${zfile[${ind}]}
+       awk '/MEAN NO   1  DET/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   2  ZOO/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   3  PHY/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   4  NO3/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   5  NH4/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   6  DOM/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+
+       let ind=${ind}+1
+done
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_aix6.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_aix6.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_aix6.ksh	(revision 1844)
@@ -0,0 +1,106 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zxcm   : (0/1) mon${zconf}_err file (do/do not) exist"
+#     - zxrs   : (0/1) Ref memory_size.txt file (do/do not) exist"
+#     - zxrm   : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+#     - zexp   : experience name directory"
+#     - zconf  : configuration name"
+#     - zout   : output file name"
+#     - ztag   : tag name to which are compared files"
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-a] [-b] [-d] [-e] [-c] [-o] [-t]"
+  echo "Options: These are optional argument"
+  echo " -a : (0/1) mon${zconf}_err file (do/do not) exist"
+  echo " -b : (0/1) Ref memory_size.txt file (do/do not) exist"
+  echo " -d : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+  echo " -e : experience name directory"
+  echo " -c : configuration name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zxcm=1
+zxrs=1
+zxrm=1
+zexp=
+zconf=
+zout=
+ztag=
+
+# Get arguments
+while getopts a:b:d:e:c:o:t: opt
+do
+  case "$opt" in
+    a) zxcm="$OPTARG";;
+    b) zxrs="$OPTARG";;
+    d) zxrm="$OPTARG";;
+    e) zexp="$OPTARG";;
+    c) zconf="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    *) help_MEM_size;;
+  esac
+done
+
+# Check if results must be compared to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+zfilecs="mon/LONG/${zexp}/memory_size.txt" ;  zfilers="mon/LONG/${ztag}/memory_size.txt"
+zfilecm="mon/LONG/${zexp}/mon${zconf}_err"  ;  zfilerm="mon/LONG/${ztag}/mon${zconf}_err"
+
+# If reference version files exist
+if [ ${evaltag} == 0 -a ${zxrm} == 0 ] ;  then
+    # Get values from the reference tag
+    Mo_stack_ms=$( awk '/Stack/ {print $NF/(1024*1024) }' ${zfilers} )
+    Mo_stati_ms=$( awk '/Stati/ {print $NF/(1024*1024) }' ${zfilers} )
+    if [ ${zxcm} == 0 ] ; then Mo_max_used=$( awk '/resident/ {print $6/1024}' ${zfilerm} ) ; fi
+
+    # Print: Variable long name | current version values | reference version values | variations
+    echo "                                                 " >> ${zout}
+    echo "                                      Version    " >> ${zout}
+    echo "             Memory          Current /       \ ${ztag}        Variation " >> ${zout}
+    awk ' /Stack/ { val=$NF/(1024*1024) } END {printf("%-9s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Stack     (Mo) :", val, inck, ((val-inck)/inck)*100 ) }' inck=${Mo_stack_ms} ${zfilecs} >> ${zout}
+    awk ' /Stati/ { val=$NF/(1024*1024) } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Static    (Mo) :", val, inti, ((val-inti)/inti)*100 ) }' inti=${Mo_stati_ms} ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /resident/ { val=$6/1024 } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Max. used (Mo) :", val, inus, ((val-inus)/inus)*100 ) }' inus=${Mo_max_used} ${zfilecm} >> ${zout} ; fi
+else
+    # Print: Variable long name | current version values
+    echo "                                                 " >> ${zout}
+    echo "             Memory          Current version "     >> ${zout}
+    awk ' /Stack/  {printf("%-9s %-.16s %11.1f\n ", " ", "Stack     (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    awk ' /Stati/  {printf("%-8s %-.16s %11.1f\n ", " ", "Static    (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /resident/ {printf("%-8s %-.16s %11.1f\n ", " ", "Max. used (Mo) :", $6/1024 ) }' ${zfilecm} >> ${zout} ; fi
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_osxxlf.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_osxxlf.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_osxxlf.ksh	(revision 1844)
@@ -0,0 +1,112 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zmxcu  : (0/1) mon${CONF}_err file (do/do not) exist"
+#     - zxrs   : (0/1) Ref memory_size.txt file (do/do not) exist"
+#     - zxrm   : (0/1) Ref mon${CONF}_err file (do/do not) exist"
+#     - zexp   : experience name directory"
+#     - zconf  : configuration name"
+#     - zout   : output file name"
+#     - ztag   : tag name to which are compared files"
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the osxxlf target for 
+#        mon, mpi runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-a] [-b] [-d] [-c] [-o] [-t]"
+  echo "Options: These are optional argument"
+  echo " -a : (0/1) mon${CONF}_err file (do/do not) exist"
+  echo " -b : (0/1) Ref memory_size.txt file (do/do not) exist"
+  echo " -d : (0/1) Ref mon${CONF}_err file (do/do not) exist"
+  echo " -e : experience name directory"
+  echo " -c : configuration name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zmxcu=1
+zxrs=1
+zxrm=1
+zexp=
+zconf=
+zout=
+ztag=
+
+# Get arguments
+while getopts a:b:d:e:c:o:t: opt
+do
+  case "$opt" in
+    a) zmxcu="$OPTARG";;
+    b) zxrs="$OPTARG";;
+    d) zxrm="$OPTARG";;
+    e) zexp="$OPTARG";;
+    c) zconf="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    *) help_MEM_size;;
+  esac
+done
+
+# Check if results must be compared to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+zfilecs='mon/LONG/${zexp}/memory_size.txt'
+zfilers='mon/LONG/${ztag}/memory_size.txt'
+
+# Select only appropriate lines
+grep -v Stack ${zfilecs} | head -1 > temp_cs_sck
+tail -1 ${zfilecs}                 > temp_cs_sic
+
+# Select only appropriate lines
+grep -v Stack ${zfilers} | head -1 > temp_rs_sck
+tail -1 ${zfilers}                 > temp_rs_sic
+
+# If reference version files exist
+if [ ${evaltag} == 0 -a ${zxrs} == 0 ] ;  then
+    # Get values from the reference tag
+    Mo_stack_ms=$( (awk '{print $5/(1024*1024) }' temp_rs_sck ) )
+    Mo_stati_ms=$( (awk '{print $5/(1024*1024) }' temp_rs_sic ) )
+
+    # Print: Variable long name | current version values | reference version values | variations
+    echo "                                                 " >> ${zout}
+    echo "                                      Version    " >> ${zout}
+    echo "             Memory          Current /       \ ${ztag}        Variation " >> ${zout}
+    awk ' { val=$5/(1024*1024) } {printf("%-9s %-16s %8.1f      |   %8.1f     |    %5.1f \n ", " ", "Stack     (Mo) :", val, inck, ((val-inck)/inck)*100 ) }' inck=${Mo_stack_ms} temp_cs_sck >> ${zout}
+    awk ' { val=$5/(1024*1024) } {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f \n ", " ", "Static    (Mo) :", val, inti, ((val-inti)/inti)*100 ) }' inti=${Mo_stati_ms} temp_cs_sic >> ${zout}
+else
+    # Print: Variable long name | current version values
+    echo "                                                 " >> ${zout}
+    echo "             Memory          Current version "     >> ${zout}
+    awk ' {printf("%-9s %-.16s %11.1f\n ", " ", "Stack     (Mo) :", $5/(1024*1024) ) }' temp_cs_sck >> ${zout}
+    awk ' {printf("%-8s %-.16s %11.1f\n ", " ", "Static    (Mo) :", $5/(1024*1024) ) }' temp_cs_sic >> ${zout}
+fi
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8brodie.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8brodie.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8brodie.ksh	(revision 1844)
@@ -0,0 +1,106 @@
+#!/bin/ksh
+# $Id$
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zxcm   : (0/1) mon${zconf}_err file (do/do not) exist"
+#     - zxrs   : (0/1) Ref memory_size.txt file (do/do not) exist"
+#     - zxrm   : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+#     - zexp   : experience name directory"
+#     - zconf  : configuration name"
+#     - zout   : output file name"
+#     - ztag   : tag name to which are compared files"
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-a] [-b] [-d] [-e] [-c] [-o] [-t]"
+  echo "Options: These are optional argument"
+  echo " -a : (0/1) mon${zconf}_err file (do/do not) exist"
+  echo " -b : (0/1) Ref memory_size.txt file (do/do not) exist"
+  echo " -d : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+  echo " -e : experience name directory"
+  echo " -c : configuration name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zxcm=1
+zxrs=1
+zxrm=1
+zexp=
+zconf=
+zout=
+ztag=
+
+# Get arguments
+while getopts a:b:d:e:c:o:t: opt
+do
+  case "$opt" in
+    a) zxcm="$OPTARG";;
+    b) zxrs="$OPTARG";;
+    d) zxrm="$OPTARG";;
+    e) zexp="$OPTARG";;
+    c) zconf="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    *) help_MEM_size;;
+  esac
+done
+
+# Check if results must be compared to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+zfilecs="mon/LONG/${zexp}/memory_size.txt" ;  zfilers="mon/LONG/${ztag}/memory_size.txt"
+zfilecm="mon/LONG/${zexp}/mon${zconf}_err"  ;  zfilerm="mon/LONG/${ztag}/mon${zconf}_err"
+
+# If reference version files exist
+if [ ${evaltag} == 0 -a ${zxrm} == 0 ] ;  then
+    # Get values from the reference tag
+    Mo_stack_ms=$( (awk '/Stack/ {print $NF/(1024*1024) }' ${zfilers} ) )
+    Mo_stati_ms=$( (awk '/Stati/ {print $NF/(1024*1024) }' ${zfilers} ) )
+    if [ ${zxcm} == 0 ] ; then Mo_max_used=$( (awk '/Memory Size/ {print $NF}' ${zfilerm} ) ) ; fi
+
+    # Print: Variable long name | current version values | reference version values | variations
+    echo "                                                 " >> ${zout}
+    echo "                                      Version    " >> ${zout}
+    echo "             Memory          Current /       \ ${ztag}        Variation " >> ${zout}
+    awk ' /Stack/ { val=$NF/(1024*1024) } END {printf("%-9s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Stack     (Mo) :", val, inck, ((val-inck)/inck)*100 ) }' inck=${Mo_stack_ms} ${zfilecs} >> ${zout}
+    awk ' /Stati/ { val=$NF/(1024*1024) } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Static    (Mo) :", val, inti, ((val-inti)/inti)*100 ) }' inti=${Mo_stati_ms} ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /Memory Size/ { val=$NF } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Max. used (Mo) :", val, inus, ((val-inus)/inus)*100 ) }' inus=${Mo_max_used} ${zfilecm} >> ${zout} ; fi
+else
+    # Print: Variable long name | current version values
+    echo "                                                 " >> ${zout}
+    echo "             Memory          Current version "     >> ${zout}
+    awk ' /Stack/  {printf("%-9s %-.16s %11.1f\n ", " ", "Stack     (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    awk ' /Stati/  {printf("%-8s %-.16s %11.1f\n ", " ", "Static    (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /Memory/   {printf("%-8s %-.16s %11.1f\n ", " ", "Max. used (Mo) :", $NF ) }' ${zfilecm} >> ${zout} ; fi
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8mercure.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8mercure.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/MEM_size_sx8mercure.ksh	(revision 1844)
@@ -0,0 +1,106 @@
+#!/bin/ksh
+# $Id: MEM_size_sx8brodie.ksh 1301 2009-02-09 17:15:38Z ctlod $
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 6
+#     - zxcm   : (0/1) mon${zconf}_err file (do/do not) exist"
+#     - zxrs   : (0/1) Ref memory_size.txt file (do/do not) exist"
+#     - zxrm   : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+#     - zexp   : experience name directory"
+#     - zconf  : configuration name"
+#     - zout   : output file name"
+#     - ztag   : tag name to which are compared files"
+#
+# WORK: It aims to :
+#
+#      - Treat output timing from the sx8brodie target for 
+#        mon, mpi & omp runs
+#     *- compare it to a reference version 
+#
+# * this step is performed only if a reference tag 
+#   is specified with the -t option and if files exist.
+#   See the Makefile under ./config/NVTK directory
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+#
+# help_CPU_time() To print help
+#
+function help_CPU_time
+{
+  echo "Usage: $nscript [-a] [-b] [-d] [-e] [-c] [-o] [-t]"
+  echo "Options: These are optional argument"
+  echo " -a : (0/1) mon${zconf}_err file (do/do not) exist"
+  echo " -b : (0/1) Ref memory_size.txt file (do/do not) exist"
+  echo " -d : (0/1) Ref mon${zconf}_err file (do/do not) exist"
+  echo " -e : experience name directory"
+  echo " -c : configuration name"
+  echo " -o : output file name"
+  echo " -t : tag name to which are compared files"
+  echo " their values are not taken)"
+  exit 1
+}
+
+# Initialization
+zxcm=1
+zxrs=1
+zxrm=1
+zexp=
+zconf=
+zout=
+ztag=
+
+# Get arguments
+while getopts a:b:d:e:c:o:t: opt
+do
+  case "$opt" in
+    a) zxcm="$OPTARG";;
+    b) zxrs="$OPTARG";;
+    d) zxrm="$OPTARG";;
+    e) zexp="$OPTARG";;
+    c) zconf="$OPTARG";;
+    o) zout="$OPTARG";;
+    t) ztag="$OPTARG";;
+    *) help_MEM_size;;
+  esac
+done
+
+# Check if results must be compared to the reference version
+test -n "${ztag}"
+evaltag=$?
+
+zfilecs="mon/LONG/${zexp}/memory_size.txt" ;  zfilers="mon/LONG/${ztag}/memory_size.txt"
+zfilecm="mon/LONG/${zexp}/mon${zconf}_err"  ;  zfilerm="mon/LONG/${ztag}/mon${zconf}_err"
+
+# If reference version files exist
+if [ ${evaltag} == 0 -a ${zxrm} == 0 ] ;  then
+    # Get values from the reference tag
+    Mo_stack_ms=$( (awk '/Stack/ {print $NF/(1024*1024) }' ${zfilers} ) )
+    Mo_stati_ms=$( (awk '/Stati/ {print $NF/(1024*1024) }' ${zfilers} ) )
+    if [ ${zxcm} == 0 ] ; then Mo_max_used=$( (awk '/Memory/ {print $NF}' ${zfilerm} ) ) ; fi
+
+    # Print: Variable long name | current version values | reference version values | variations
+    echo "                                                 " >> ${zout}
+    echo "                                      Version    " >> ${zout}
+    echo "             Memory          Current /       \ ${ztag}        Variation " >> ${zout}
+    awk ' /Stack/ { val=$NF/(1024*1024) } END {printf("%-9s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Stack     (Mo) :", val, inck, ((val-inck)/inck)*100 ) }' inck=${Mo_stack_ms} ${zfilecs} >> ${zout}
+    awk ' /Stati/ { val=$NF/(1024*1024) } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Static    (Mo) :", val, inti, ((val-inti)/inti)*100 ) }' inti=${Mo_stati_ms} ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /Memory/ { val=$NF } END {printf("%-8s %-16s %8.1f      |   %8.1f     |    %5.1f %\n ", " ", "Max. used (Mo) :", val, inus, ((val-inus)/inus)*100 ) }' inus=${Mo_max_used} ${zfilecm} >> ${zout} ; fi
+else
+    # Print: Variable long name | current version values
+    echo "                                                 " >> ${zout}
+    echo "             Memory          Current version "     >> ${zout}
+    awk ' /Stack/  {printf("%-9s %-.16s %11.1f\n ", " ", "Stack     (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    awk ' /Stati/  {printf("%-8s %-.16s %11.1f\n ", " ", "Static    (Mo) :", $NF/(1024*1024) ) }' ${zfilecs} >> ${zout}
+    if [ ${zxcm} == 0 ] ; then awk ' /Memory/   {printf("%-8s %-.16s %11.1f\n ", " ", "Max. used (Mo) :", $NF ) }' ${zfilecm} >> ${zout} ; fi
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/PISCES_stat.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/PISCES_stat.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/PISCES_stat.ksh	(revision 1844)
@@ -0,0 +1,74 @@
+#!/bin/ksh
+# $Id: BIO_sx8brodie.ksh 1301 2009-02-09 17:15:38Z ctlod $
+##############################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is called by the assessment.ksh script for a 
+# given configuration 
+#
+# INPUT ARGS: 2
+#     - zfile1 : first tracer statistic file to output
+#     - zfile2 : second tracer statistic file to output
+#
+# WORK: It aims to :
+#
+#      - Extract tracers statistics from ocean.output 
+#        for mon, mpi & omp runs
+#
+##############################################################
+#set -xv
+##############################################################
+
+# Initialization
+zfile1=
+zfile2=
+
+# Get arguments
+while getopts a:b:c: opt
+do
+  case "$opt" in
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    c) zfile3="$OPTARG";;
+  esac
+done
+
+zfile[0]=${zfile1}
+zfile[1]=${zfile2}
+zfilein=${zfile3}
+
+ind=0
+
+while [ ${ind} -le 1 ] ; do
+
+       zpath=$( ( dirname ${zfile[${ind}]} ) )
+
+       awk '/----TRACER STAT----/ { print $0 }' ${zpath}/${zfilein} > ${zfile[${ind}]}
+       awk '/MEAN NO   1  DIC/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   2  Alkalini/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   3  O2/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   4  CaCO3/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   5  PO4/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   6  POC/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   7  Si/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   8  PHY/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   9  ZOO/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   10  DOC/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   11  PHY2/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   12  ZOO2/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   13  BSi/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   14  Fer/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   15  BFe/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   16  GOC/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   17  SFe/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   18  DFe/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   19  DSi/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   20  NFe/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   21  NCHL/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   22  DCHL/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   23  NO3/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+       awk '/MEAN NO   24  NH4/ { print $3, $4, $7, $8, $9, $10, $11, $12 }' ${zpath}/${zfilein} >> ${zfile[${ind}]}
+
+       let ind=${ind}+1
+done
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/assessment.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/assessment.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/assessment.ksh	(revision 1844)
@@ -0,0 +1,724 @@
+#!/bin/ksh
+# $Id$
+######################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# It is automatically launched (by the cron_jobs.ksh 
+# script) when all runs (mon, mpi, (omp)) for a given 
+# configuration are finished 
+#
+# INPUT ARGS: 1 
+#    - EXPER: name of the experience for which the 
+#             assessment will be done
+#
+# WORK: It aims to (for each standard configuration) :
+#
+#    I. Check Executable Memory size
+#       - from memory_size.txt output file
+#      *- compare it to a reference version 
+#
+#   II. Check CPU time used (if specified)
+#       - from timing output files
+#      *- compare it to a reference version 
+#
+#  III. Check the reproductibility between mon & mpi runs
+#       - making diff of solver.stat output files
+#
+#   IV. Check the restartability for mon & mpi runs
+#       - making diff of solver.stat output files
+#
+#    V.*Compare current results to a reference one
+#        
+#   VI. Send the assessment file "endjob_EXPER.txt" using 
+#       user's e-mail
+#        
+# * this step is performed only if a reference tag 
+#   is passing through the specifs_EXPER.txt file
+#   See the Makefile under ./config/NVTK directory
+#
+# It is based on the directories architecture below :
+#
+#         NEMO_VALID/WNAME_CONFIG/
+#                    |-- mon            --> MONO run
+#                    |   |-- 1_SHORT
+#                    |   |-- 2_SHORT
+#                    |   |-- LONG
+#                    |   `-- GTIME
+#                    |-- mpi            --> MPI run
+#                    |   |-- 1_SHORT
+#                    |   |-- 2_SHORT
+#                    |   |-- LONG
+#                    |   `-- GTIME
+#                    `-- omp            --> Open-MP run
+#                        |-- 1_SHORT
+#                        |-- 2_SHORT
+#                        |-- LONG
+#                        `-- GTIME
+#
+###########################################################
+#set -xv 
+###########################################################
+CONF=`basename $( pwd ) | cut -c2-`
+EXPER=$1
+TARGET=sx8brodie
+INFOF="./infos/specifs_${EXPER}.txt"
+LRTYPE="$( ( awk '/runs=/ { printf  "%s %s %s", $2 , $3 , $4}' ${INFOF} ) )"
+MPIDCI="$( ( awk '/mpis=/ { printf  "%s ", $2}' ${INFOF} ) )"
+MPIDCJ="$( ( awk '/mpis=/ { printf  "%s ", $3}' ${INFOF} ) )"
+MPIDCIJ="$( ( awk '/mpis=/ { printf  "%s ", $4}' ${INFOF} ) )"
+VTIME=$( ( awk '/time=/ { print $2 }' ${INFOF} ) )
+REF_TAG=$( (awk '/tagname=/ {print $2}' ${INFOF}) )
+URL_USE=$( (awk '/URL:/ {print $0}' ${INFOF} ) )
+REV_USE=$( (awk '/Revision:/ {print $2}' ${INFOF} ) )
+TITLE="NEMO VALIDATION ${EXPER} : $CONF on $TARGET"
+EMAIL='ctlod@locean-ipsl.upmc.fr'
+
+OUTPUTF="endjob_${EXPER}.txt"
+
+\rm ${OUTPUTF} 2> /dev/null
+touch ${OUTPUTF}
+
+if [ ${CONF} == 'ORCA2_LIM' ] ; then
+    CONFS=ORCA2
+elif [ ${CONF} == 'ORCA2_LIM3' ] ; then
+    CONFS=OR2L3
+elif [ ${CONF} == 'GYRE' ] ; then
+    CONFS=GYREO
+elif [ ${CONF} == 'GYRE_LOBSTER' ] ; then
+    CONFS=GYREL
+elif [ ${CONF} == 'ORCA2_LIM_PISCES' ] ; then
+    CONFS=OR2LP
+elif [ ${CONF} == 'ORCA2_OFF_PISCES' ] ; then
+    CONFS=OR2OP
+elif [ ${CONF} == 'ZAGRIF' ] ; then
+    CONFS=ZAGRI
+else
+    CONFS=${CONF}
+fi
+
+###########################################################
+# checkfile() is a local function to check if a file exist
+# 5 arguments:
+#    - zf2check : file name to check
+#    - zoutfile : output file name to print results
+#    - zwork    : kind of prints to perform
+#    - zreprint : print a message once (yes/no)
+#    - ziter    : (optional) print time steps number (yes/no)
+###########################################################
+################ Begin checkfile function #################
+function checkfile
+{
+# name of the file to check
+zf2check=$1
+# print output file name
+zoutfile=$2
+# white space prints
+zworkt=$3
+# Print a message only once
+zreprint=$4
+# Print iterations number
+ziter=$5
+
+#set -x 
+
+test -n "${ziter}"
+zrepiter=$?
+
+
+genf=$( basename ${zf2check} )
+
+case "${zworkt}" in
+      'NORM' )  blnk='       ' ;;
+      'DIFF' )  blnk=' '  ;;
+esac
+fmes4=" - file ${zf2check} doesn't exist "
+
+# Check file exists
+if [ -a ${zf2check} ] ; then
+    fmes1=" List ${genf} files and check date creation:   "
+    fmes2=" `ls -o ${zf2check}`           "
+    fmes3=" - file ${zf2check} is empty  "
+    fmes4="                  Num. time steps:   done  /  expected "
+    if [ ${zreprint} = 'yes' ] ; then 
+        if [ ${zrepiter} == 0 ] ; then 
+            echo "${blnk}${fmes1}" "${fmes4}" >> ${zoutfile}
+        else
+            echo "${blnk}${fmes1}"          >> ${zoutfile}
+        fi
+    fi
+
+   # Check file is not empty
+   if [ -s ${zf2check} ] ; then
+       if [ ${zrepiter} == 0 ] ; then
+           # Check run's iterations number from solver.stat
+           basedir="`dirname ${zf2check}`"
+           echo "`tail -1 ${zf2check}`" > temp1
+           echo "`grep nn_itend ${basedir}/namelist`" > temp2
+           typeset -Z4 ziter_run
+           typeset -Z4 ziter_ask
+           ziter_run="`awk '{print $2}' temp1`"
+           ziter_ask="`awk '{print $3}' temp2`"
+           \rm temp1 temp2
+           [ ${zoutfile} ] && echo "${blnk}${fmes2}" "   ${ziter_run}  /   ${ziter_ask}" >> ${zoutfile}
+           xist=0 ; return ${xist}
+       else
+           [ ${zoutfile} ] && echo "${blnk}${fmes2}" >> ${zoutfile}
+           xist=0 ; return ${xist}
+       fi
+   else
+       [ ${zoutfile} ] &&  echo "${blnk}${fmes3}" >> ${zoutfile}
+       xist=1 ; return ${xist}
+   fi
+else
+   [ ${zoutfile} ] && echo "${blnk}${fmes4}" >> ${zoutfile}
+   xist=1 ; return ${xist}
+fi
+return
+}
+############### End checkfile function ###############
+######################################################
+
+# Get the name of the present script
+nscript=$( (basename $0) )
+
+###########################################################
+# mak_diff_file() is a local function which performs diff
+# on some files and print messages in the endjob_EXPER.txt file
+# 7 input arguments:
+#    - zfex    : (0/1) (make/do not make) diff (files doesn't exist)
+#    - zfile1  : first input file name
+#    - zfile2  : second input file name
+#    - zruntype: run type (mon, mpi, omp)
+#    - zstream : stream of the run (long, stream_1, stream_2)
+#    - ztag    : the tag name to which are compared files
+#    - zkind   : kind of the check (repro/resta)
+###############################################################
+################ Begin mak_diff_file function #################
+function mak_diff_file
+{
+#
+# help_diff() To print help
+#
+function help_diff
+{
+  echo "Usage: ${nscript} [-x] [-a] [-b] [-r] [-s] [-t] [-k]"
+  echo "Options: These are optional argument"
+  echo " -x : (0/1) (make/do not make) diff "
+  echo " -a : first input file name"
+  echo " -b : second input file name"
+  echo " -r : run type (mon, mpi, omp)"
+  echo " -s : stream of the run (long, stream_1, stream_2)"
+  echo " -t : tag name to which are compared files"
+  echo " -k : kind of the check (repro/resta)" 
+  echo " their values are not taken)"
+  exit 1
+}
+
+##set -xv
+
+# Initialization
+zfex=1
+zfile1=
+zfile2=
+zruntype=
+zstream=
+ztag=
+zkind=none
+outdir='./infos/inter/'
+
+# Get arguments
+while getopts x:a:b:r:s:t:k: opt
+do
+  case "$opt" in
+    x) zfex="$OPTARG";;
+    a) zfile1="$OPTARG";;
+    b) zfile2="$OPTARG";;
+    r) zruntype="$OPTARG";;
+    s) zstream="$OPTARG";;
+    t) ztag="$OPTARG";;
+    k) zkind="$OPTARG";;
+    *) help_diff;;
+  esac
+done
+
+zgenf=$( basename ${zfile1} )
+zgenftrc=$( basename ${zfile1%.*} )
+
+case "$zkind" in
+  none ) 
+      zmesg1="                   Current run                                                     ${ztag} run   "
+      zmesg2="                   -----------                                                     --------------"
+      zmesg_NOK="        ${zstream} ${zgenf} is NOT identical to the version ${ztag} one"
+      zmesg_OK="        ${zstream} ${zgenf} IS IDENTICAL to the version ${ztag} one  "
+      zmesg_wht="        NO comparison between current ${zstream} and the version ${ztag} ${zgenf} "
+      bnam=${outdir}'cvref_'${zgenftrc}_${zstream}_${zruntype}_${EXPER} ;;
+  repro ) 
+      zmesg1="                   mon run                                                         ${zruntype} run      "
+      zmesg2="                   -------                                                         -------      "
+      zmesg_NOK="        NO NO NO NO NO NO for the current version"
+      zmesg_OK="        YES YES YES YES YES YES YES YES for the current version "
+      zmesg_wht="        NO CONCLUSION !!!!!  "
+      bnam=${outdir}${zkind}_${zgenftrc}_${EXPER} ;;
+  resta ) 
+      zmesg1="                   LONG Stream                                                     SHORT Streams"
+      zmesg2="                   -----------                                                     -------------"
+      zmesg_NOK="        NO NO NO NO NO NO for the current version i.e. LONG stream != ( 1_SHORT + 2_SHORT ) streams "
+      zmesg_OK="        YES YES YES YES YES YES YES YES for the current version i.e. LONG stream = ( 1_SHORT + 2_SHORT ) streams "
+      zmesg_wht="        NO CONCLUSION !!!!!! "
+      bnam=${outdir}${zkind}_${zgenftrc}_${EXPER} ;;
+esac
+
+
+if [ ${zfex} == 0 ] ;  then
+    \rm ${bnam}.txt 2> /dev/null
+    echo "                                    Make difference between ${zgenf} files                       "  > ${bnam}.txt
+    echo "                                            ${zstream} ${zruntype} run                           " >> ${bnam}.txt
+    echo "${zmesg1}"                                                                                         >> ${bnam}.txt
+    echo "${zmesg2}"                                                                                         >> ${bnam}.txt
+    sdiff    ${zfile1} ${zfile2} >>  ${bnam}.txt
+    sdiff -s ${zfile1} ${zfile2} >>  ${bnam}_dd.txt
+
+    #---------
+    if [ ${zgenf} = 'ocean.output' ] ; then
+        echo "                                                                                                 " >> ${outdir}${zstream}_head.txt
+        echo "                                    Make difference between ${zgenf} files                       "  > ${outdir}${zstream}_head.txt
+        echo "                                            ${zstream} ${zruntype} run                           " >> ${outdir}${zstream}_head.txt
+        echo "                   Current run                                                     ${ztag} run   " >> ${outdir}${zstream}_head.txt
+        echo "                   -----------                                                     --------------" >> ${outdir}${zstream}_head.txt
+        echo "                                                                                                 " >> ${outdir}${zstream}_head.txt
+        zfout=${bnam}_dd.txt
+        zspmes=" See ${bnam}.txt file for full difference"
+    else
+        touch ${outdir}${zstream}_head.txt
+        zfout=${bnam}.txt
+        zspmes=""
+    fi
+    #---------
+    if [ -s ${bnam}_dd.txt ] ; then
+    # Differences exist between solver.stat or ocean.output files
+       echo "                                           " >> ${OUTPUTF}
+       echo "${zmesg_NOK}"                                >> ${OUTPUTF}
+       echo "           ${zspmes}                       " >> ${OUTPUTF}
+       echo "                                           " >> ${OUTPUTF}
+       cat ${outdir}${zstream}_head.txt ${zfout}     >> ${OUTPUTF}
+       echo "                                           " >> ${OUTPUTF}
+       echo "                                           " >> ${OUTPUTF}
+    else
+       # No differences exist between solver.stat or ocean.output files
+       echo "                             " >> ${OUTPUTF}
+       echo "${zmesg_OK}"                   >> ${OUTPUTF}
+       echo "                             " >> ${OUTPUTF}
+    fi
+
+    rm -f ${outdir}*_dd* ${outdir}*_head.txt 2> /dev/null
+
+else
+       # It is not possible to conclude because files are missing or empty
+       echo "                             " >> ${OUTPUTF}
+       echo "${zmesg_wht}"                  >> ${OUTPUTF}
+       echo "                             " >> ${OUTPUTF}
+fi
+
+return
+
+}
+############### End mak_diff_file function ####################
+###############################################################
+
+###########################################################
+# concat_perf() is a local function to gather performances
+# files (perfs_runtype.txt_xxxx) build with the hpmcount 
+# command on Zahir and standard(s) error output file(s)
+# runtypeCONFNAME_err
+# 1 argument:
+#    - zconf : configuration name
+#############################################################
+################ Begin concat_perf function #################
+function concat_perf
+{
+
+#set -x
+
+# name of the configuration
+zconf=$1
+
+# List of files to treat
+zcatfe[0]="mon/LONG/${EXPER}/mon${zconf}_err"
+zcatfe[1]="mon/GTIME/${EXPER}/mon${zconf}_err"
+zcatfe[2]="mpi/GTIME/${EXPER}/mpi${zconf}_err"
+
+ind=0
+while [ ${ind} -lt 3 ] ; do
+
+       zpath=$( ( dirname ${zcatfe[${ind}]} ) )
+       zname=$( ( basename ${zcatfe[${ind}]} ) )
+       cd ${zpath}
+       cp ${zname} ${zname}_save
+       for kf in `ls perf*` ; do
+           cat ${kf} >> ${zname}
+       done
+       cd ../../..
+       let ind=${ind}+1
+done
+
+return
+}
+############### End concat_perf function ###############
+########################################################
+
+
+# ###############################
+# 0. EXPERIENCE NAME
+# ###############################
+echo " ############################                           "  > ${OUTPUTF}
+echo " EXPERIENCE NAME: $EXPER                                " >> ${OUTPUTF}
+echo " ############################                           " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+
+# ###############################
+# 0.I LIST OF FILES TESTED, i.e. stored under NVTK/2TEST directory
+# ###############################
+echo " #################################################      " >> ${OUTPUTF}
+echo " FILES STORED UNDER NVTK/${EXPER} DIRECTORY & TESTED    " >> ${OUTPUTF}
+echo " #################################################      " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+LSFILES=`tail -2 ${INFOF} | head -1 | wc -w`
+if [ $LSFILES != 0 ] ; then
+    for file in `tail -2 ${INFOF} | head -1` ; do 
+        echo "   -" $file                                       >> ${OUTPUTF}
+    done
+else
+    echo "                                                    " >> ${OUTPUTF}
+    echo "   ---> NO files tested                             " >> ${OUTPUTF}
+    echo "                                                    " >> ${OUTPUTF}
+fi
+echo "                                                        " >> ${OUTPUTF}
+
+# ###############################
+# 0.II LIST OF CPP KEYS USED
+# ###############################
+echo " #################################################      " >> ${OUTPUTF}
+echo " CPP KEYS USED FOR ${EXPER} EXPERIENCE                  " >> ${OUTPUTF}
+echo " #################################################      " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+for file in `tail -2 ${INFOF} | tail -1` ; do 
+    echo "   -" $file                                           >> ${OUTPUTF}
+done
+echo "                                                        " >> ${OUTPUTF}
+
+
+# ###############################
+# ###############################
+# 0.III NEMO MPI DECOMPOSITION USED
+# ###############################
+for runt in ${LRTYPE} ; do
+    if [ ${runt} = 'mpi' ] ; then
+        echo " #############################                               " >> ${OUTPUTF}
+        echo " NEMO MPI DECOMPOSITION USED                                 " >> ${OUTPUTF}
+        echo " #############################                               " >> ${OUTPUTF}
+        echo "                                                             " >> ${OUTPUTF}
+        echo "   jpni = ${MPIDCI} ; jpnj = ${MPIDCJ} ; jpnij = ${MPIDCIJ}  " >> ${OUTPUTF}
+        echo "                                                             " >> ${OUTPUTF}
+    fi
+done
+
+# ###############################
+# ###############################
+# 0.IV NEMO SOURCE FILES INFORMATION, i.e. revision & URL downloaded
+# ###############################
+echo " #############################                          " >> ${OUTPUTF}
+echo " NEMO SOURCE FILES INFORMATION                          " >> ${OUTPUTF}
+echo " #############################                          " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+echo "   NEMO downloaded from server: ${URL_USE}              " >> ${OUTPUTF}
+echo "   NEMO revision : ${REV_USE}                           " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+
+if [ ${TARGET} = 'aix6' -a ${VTIME} = 'timing' ] ; then concat_perf ${CONFS} ; fi
+
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# ###############################
+# I. CHECK EXECUTABLE MEMORY SIZE
+# ###############################
+filecs="mon/LONG/${EXPER}/memory_size.txt"  ;  filers="mon/LONG/${REF_TAG}/memory_size.txt"
+filecm="mon/LONG/${EXPER}/mon${CONFS}_err"  ;  filerm="mon/LONG/${REF_TAG}/mon${CONFS}_err"
+xfilecs=0  ; xfilecm=0 ; xfilers=0 ; xfilerm=0
+echo " ############################                           " >> ${OUTPUTF}
+echo " CHECK EXECUTABLE MEMORY SIZE                           " >> ${OUTPUTF}
+echo " ############################                           " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+#--------
+                  checkfile ${filecs} ${OUTPUTF} DIFF yes ; xfilecs=$?
+[ ${REF_TAG} ] && checkfile ${filers} ${OUTPUTF} DIFF no  ; xfilers=$?
+                  checkfile ${filecm} ${OUTPUTF} DIFF no  ; xfilecm=$?
+[ ${REF_TAG} ] && checkfile ${filerm} ${OUTPUTF} DIFF no  ; xfilerm=$?
+
+# If current version files exist
+if [ ${xfilecs} == 0 ] ;  then
+
+    if [ ${REF_TAG} ] ; then 
+        ./MEM_size_${TARGET}.ksh -a ${xfilecm} -b ${xfilers} -d ${xfilerm} -e ${EXPER} -c ${CONFS} -o ${OUTPUTF} -t ${REF_TAG} 
+    else
+        ./MEM_size_${TARGET}.ksh -a ${xfilecm} -b ${xfilers} -d ${xfilerm} -e ${EXPER} -c ${CONFS} -o ${OUTPUTF}
+    fi
+
+else
+    echo "                                                    " >> ${OUTPUTF}
+    echo "   ---> NO memory size check                        " >> ${OUTPUTF}
+    echo "                                                    " >> ${OUTPUTF}
+fi
+#
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# #######################
+# II. CHECK CPU TIME USED
+# #######################
+if [ ${VTIME} = 'timing' ] ; then
+
+    echo "                                                        " >> ${OUTPUTF}
+    echo " ######################                                 " >> ${OUTPUTF}
+    echo " CHECK CPU TIME USED                                    " >> ${OUTPUTF}
+    echo " ######################                                 " >> ${OUTPUTF}
+    echo "                                                        " >> ${OUTPUTF}
+    #------
+
+    for runt in ${LRTYPE} ; do
+
+        echo "                                                    " >> ${OUTPUTF}
+        echo "   ---> Timing for the ${runt} run :                " >> ${OUTPUTF}
+        echo "        ----------------------------                " >> ${OUTPUTF}
+        echo "                                                    " >> ${OUTPUTF}
+
+        xfilecv=0 ; xfilerv=0
+
+        # Check that timing file for the ${runt} current version exist
+        filecv="${runt}/GTIME/${EXPER}/${runt}${CONFS}_err" 
+        checkfile ${filecv} ${OUTPUTF} NORM yes ; xfilecv=$?
+
+        # Check that timing file for the ${runt} reference version exist
+        if [ ${REF_TAG} ] ; then 
+            filerv="${runt}/GTIME/${REF_TAG}/${runt}${CONFS}_err" 
+            checkfile ${filerv} ${OUTPUTF} NORM no ; xfilerv=$?
+        else 
+            filerv='NoFile'
+            xfilerv=1
+        fi
+        echo "                                                             " >> ${OUTPUTF}
+
+        if [ ${xfilecv} == 0 ] ; then 
+            if [ ${REF_TAG} ] ; then 
+                ./CPU_time_${TARGET}.ksh -r ${runt} -a ${filecv} -b ${filerv} -o ${OUTPUTF} -x ${xfilerv} -t ${REF_TAG} 
+            else
+                ./CPU_time_${TARGET}.ksh -r ${runt} -a ${filecv} -b ${filerv} -o ${OUTPUTF} -x ${xfilerv}
+            fi
+        fi
+
+    done
+
+fi
+
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# ########################################################
+# III. CHECK REPRODUCTIBILITY: mon .vs. mpi & mon .vs .omp
+# ########################################################
+echo "                                                        " >> ${OUTPUTF}
+echo " ######################                                 " >> ${OUTPUTF}
+echo " CHECK REPRODUCTIBILITY                                 " >> ${OUTPUTF}
+echo " ######################                                 " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+#------
+for runt in ${LRTYPE} ; do
+
+    if [ ${runt} != 'mon' ] ; then
+
+        if  [ ${CONF} != 'ORCA2_OFF_PISCES' ] ; then
+           echo "                                                          " >> ${OUTPUTF}
+           echo "   ---> Ocean Reproductibility mon .vs. ${runt} ? :       " >> ${OUTPUTF}
+           echo "        -------------------------------------------       " >> ${OUTPUTF}
+
+           filemon="mon/LONG/${EXPER}/solver.stat" ;  filexxx="${runt}/LONG/${EXPER}/solver.stat"
+           xfilemon=0
+
+           checkfile ${filemon} ${OUTPUTF} NORM yes yes ; xfilemon=$?
+           checkfile ${filexxx} ${OUTPUTF} NORM no  yes ; xfilemon=$?
+        
+           mak_diff_file -x ${xfilemon} -a ${filemon} -b ${filexxx} -r ${runt} -s LONG -k repro
+        fi
+        
+        if [ ${CONF} = 'GYRE_LOBSTER' -o ${CONF} = 'ORCA2_LIM_PISCES' -o ${CONF} = 'ORCA2_OFF_PISCES' ] ; then
+            # check that ocean.output files exist
+            filemon="mon/LONG/${EXPER}/ocean.output" ;  filexxx="${runt}/LONG/${EXPER}/ocean.output"
+            xfilemon=0
+
+            checkfile ${filemon} ${OUTPUTF} NORM yes ; xfilemon=$?
+            checkfile ${filexxx} ${OUTPUTF} NORM no  ; xfilemon=$?
+            
+            # check that tracer.stat files have been built based on ocean.output ones
+            filemon="mon/LONG/${EXPER}/tracer.stat" ;  filexxx="${runt}/LONG/${EXPER}/tracer.stat"
+            xfilemon=0
+            if [ ${CONF} = 'GYRE_LOBSTER' ] ; then
+               echo "                                                        " >> ${OUTPUTF}
+               echo "   ---> LOBSTER Reproductibility mon .vs. ${runt} ? :   " >> ${OUTPUTF}
+               echo "        ---------------------------------------------   " >> ${OUTPUTF}
+
+               ./LOBSTER_stat.ksh -a ${filemon} -b ${filexxx} -c ocean.output
+            else
+               echo "                                                        " >> ${OUTPUTF}
+               echo "   ---> PISCES  Reproductibility mon .vs. ${runt} ? :   " >> ${OUTPUTF}
+               echo "        ---------------------------------------------   " >> ${OUTPUTF}
+
+               ./PISCES_stat.ksh -a ${filemon} -b ${filexxx} -c ocean.output
+            fi
+
+            checkfile ${filemon} ${OUTPUTF} NORM yes ; xfilemon=$?
+            checkfile ${filexxx} ${OUTPUTF} NORM no  ; xfilemon=$?
+            
+            mak_diff_file -x ${xfilemon} -a ${filemon} -b ${filexxx} -r ${runt} -s LONG -k repro
+        fi
+    fi
+done
+
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# ##########################################
+# IV. CHECK RESTARTABILITY: mon mpi omp runs
+# ##########################################
+echo "                                                        " >> ${OUTPUTF}
+echo " ####################                                   " >> ${OUTPUTF}
+echo " CHECK RESTARTABILITY                                   " >> ${OUTPUTF}
+echo " ####################                                   " >> ${OUTPUTF}
+echo "                                                        " >> ${OUTPUTF}
+
+for runt in ${LRTYPE} ; do
+    if  [ ${CONF} != 'ORCA2_OFF_PISCES' ] ; then
+       echo "                                                          " >> ${OUTPUTF}
+       echo "   ---> ${runt} ocean restartability ? :                  " >> ${OUTPUTF}
+       echo "        --------------------------------                  " >> ${OUTPUTF}
+
+       file1="${runt}/1_SHORT/${EXPER}/solver.stat" ;  file2="${runt}/2_SHORT/${EXPER}/solver.stat" ; file3="${runt}/LONG/${EXPER}/solver.stat"
+       xfile1=0
+       #-------
+       checkfile ${file1} ${OUTPUTF} NORM yes yes ; xfile1=$?
+       checkfile ${file2} ${OUTPUTF} NORM no  yes ; xfile1=$?
+       #
+       cat ${file1} ${file2}  > short_solver_${runt}.stat
+       mak_diff_file -x ${xfile1} -a ${file3} -b short_solver_${runt}.stat -r ${runt} -k resta
+       \rm short_solver_${runt}.stat
+    fi 
+    #-------
+
+    if [ ${CONF} = 'GYRE_LOBSTER' -o ${CONF} = 'ORCA2_LIM_PISCES' -o ${CONF} = 'ORCA2_OFF_PISCES' ] ; then
+
+       # check that ocean.output files exist
+        file1="${runt}/2_SHORT/${EXPER}/ocean.output" ;  file2="${runt}/LONG/${EXPER}/ocean.output"
+        xfile1=0
+
+        checkfile ${file1} ${OUTPUTF} NORM yes ; xfile1=$?
+        checkfile ${file2} ${OUTPUTF} NORM no  ; xfile1=$?
+            
+        # check that tracer.stat files have been built based on ocean.output ones
+        file1="${runt}/2_SHORT/${EXPER}/tracer.stat" ;  file2="${runt}/LONG/${EXPER}/tracer.stat"
+        xfile1=0
+
+        if [ ${CONF} = 'GYRE_LOBSTER' ] ; then
+           echo "                                                        " >> ${OUTPUTF}
+           echo "   ---> ${runt} LOBSTER restartability ? :              " >> ${OUTPUTF}
+           echo "        ----------------------------------              " >> ${OUTPUTF}
+
+           ./LOBSTER_stat.ksh -a ${file1} -b ${file2} -c ocean.output
+        else
+           echo "                                                        " >> ${OUTPUTF}
+           echo "   ---> ${runt} PISCES  restartability ? :              " >> ${OUTPUTF}
+           echo "        ---------------------------------------------   " >> ${OUTPUTF}
+
+           ./PISCES_stat.ksh -a ${file1} -b ${file2} -c ocean.output
+        fi
+
+
+        checkfile ${file1} ${OUTPUTF} NORM yes ; xfile1=$?
+        checkfile ${file2} ${OUTPUTF} NORM no  ; xfile1=$?
+        #
+        mak_diff_file -x ${xfile1} -a ${file2} -b ${file1} -r ${runt} -k resta
+
+    fi
+    
+done
+
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# #######################################################
+# V. COMPARE CURRENT ${runt} RESULTS TO THE $REF_TAG ONES
+# #######################################################
+
+# This step is realised only if a reference tag ${REF_TAG} is specified
+if [ ${REF_TAG} ] ; then
+
+    echo "                                                        " >> ${OUTPUTF}
+    echo " ####################################################   " >> ${OUTPUTF}
+    echo " COMPARE CURRENT VERSION RESULTS TO THE $REF_TAG ONES   " >> ${OUTPUTF}
+    echo " ####################################################   " >> ${OUTPUTF}
+    echo "                                                        " >> ${OUTPUTF}
+
+    for runt in ${LRTYPE} ; do
+
+        echo "   -----------------------------------------------------------------------------" >> ${OUTPUTF}
+        echo "   ---> ${runt} results :  current version  |   ${REF_TAG} version  STREAM 1 & 2" >> ${OUTPUTF}
+        echo '                        solver.stat    .vs.    solver.stat         '              >> ${OUTPUTF}
+        echo '                        ocean.output   .vs.    ocean.output        '              >> ${OUTPUTF}
+
+        file1="${runt}/1_SHORT/${EXPER}/solver.stat"          ;  file2="${runt}/2_SHORT/${EXPER}/solver.stat"
+        filev1="${runt}/1_SHORT/${REF_TAG}/solver.stat"              ;  filev2="${runt}/2_SHORT/${REF_TAG}/solver.stat"
+        file_oc1="${runt}/1_SHORT/${EXPER}/ocean.output"      ;  file_oc2="${runt}/2_SHORT/${EXPER}/ocean.output"
+        file_roc1="${runt}/1_SHORT/${REF_TAG}/ocean.output"          ;  file_roc2="${runt}/2_SHORT/${REF_TAG}/ocean.output"
+        xfilev1=0 ; xfilev2=0 ; xfile_oc1=0 ; xfile_oc2=0
+
+        echo "                                           " >> ${OUTPUTF}
+        echo "        STREAM 1 results :                 " >> ${OUTPUTF}
+        echo "        -----------------                  " >> ${OUTPUTF}
+        #
+        #-------
+        # solver.stat STREAM 1
+        checkfile ${file1}  ${OUTPUTF} NORM yes ; xfilev1=$?
+        checkfile ${filev1} ${OUTPUTF} NORM no  ; xfilev1=$?
+    
+        mak_diff_file -x ${xfilev1} -a ${file1} -b ${filev1} -r ${runt} -s STREAM_1 -t ${REF_TAG}
+    
+        #-------
+        # ocean.output STREAM 1
+        checkfile ${file_oc1}  ${OUTPUTF} NORM yes ; xfile_oc1=$?
+        checkfile ${file_roc1} ${OUTPUTF} NORM no  ; xfile_oc1=$?
+    
+        mak_diff_file -x ${xfile_oc1} -a ${file_oc1} -b ${file_roc1} -r ${runt} -s STREAM_1 -t ${REF_TAG}
+    
+        echo "                                           " >> ${OUTPUTF}
+        echo "        STREAM 2 results :                 " >> ${OUTPUTF}
+        echo "        -----------------                  " >> ${OUTPUTF}
+        #
+        #-------
+        # solver.stat STREAM 2
+        checkfile ${file2}  ${OUTPUTF} NORM yes ; xfilev2=$?
+        checkfile ${filev2} ${OUTPUTF} NORM no  ; xfilev2=$?
+    
+        mak_diff_file -x ${xfilev2} -a ${file2} -b ${filev2} -r ${runt} -s STREAM_2 -t ${REF_TAG}
+    
+        #-------
+        # ocean.output STREAM 2
+        checkfile ${file_oc2}  ${OUTPUTF} NORM yes ; xfile_oc2=$?
+        checkfile ${file_roc2} ${OUTPUTF} NORM no  ; xfile_oc2=$?
+    
+        mak_diff_file -x ${xfile_oc2} -a ${file_oc2} -b ${file_roc2} -r ${runt} -s STREAM_2 -t ${REF_TAG}
+    
+    done
+    #
+    #-------
+fi
+
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# ###############################################
+# VI. SEND THE ASSESSMENT FILE REPORT "endjob_EXPER.txt"
+# ###############################################
+mail -s "$TITLE" ${EMAIL} < ${OUTPUTF}
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/cron_jobs.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/cron_jobs.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/cron_jobs.ksh	(revision 1844)
@@ -0,0 +1,32 @@
+#!/usr/bin/ksh
+# $Id$
+######################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# This script is launched by the lance_batch.ksh script
+# for a given configuration.
+# It aims to (for each standard configuration) check if
+# there are jobs in queue associated with the considered 
+# configuration. 
+# If jobs are still in queue it re-launched itself either
+# it launchs the assessment.ksh script 
+######################################################
+
+#set -xv
+
+REXPE=$1
+CONFS=$2
+LJOBS=qstat
+
+JOBS_LIST=` ${LJOBS} |  grep -c ${CONFS}`
+if [ ${JOBS_LIST} = 0 ]
+then
+    sleep 60
+    ./assessment.ksh ${REXPE} &
+    exit
+fi
+sleep 300
+./cron_jobs.ksh ${REXPE} ${CONFS} &
+exit
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mon
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mon	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mon	(revision 1844)
@@ -0,0 +1,20 @@
+#!/bin/ksh
+# $Id$
+############################################################################
+#### ax_mono Header mon
+############################################################################
+# Temps CPU max. en secondes (d'un processus)
+# @ wall_clock_limit  = 0:20:00
+# Mémoire max. utilisée (ici 11 Go)
+# @ data_limit = 3gb
+# Type du travail
+# @ job_type = parallel
+# Nom du travail LoadLeveler
+# @ job_name   = 
+# Fichier de sortie standard du travail
+# @ output     = $(job_name)_std
+# Fichier de sortie d'erreur du travail
+# @ error      =  $(job_name)_err
+# @ queue
+#                                           
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mpi
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mpi	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_aix6_mpi	(revision 1844)
@@ -0,0 +1,22 @@
+#!/bin/ksh
+# $Id$
+############################################################################
+#### aix Header mpi
+############################################################################
+# Temps CPU max. en secondes (d'un processus)
+# @ wall_clock_limit  = 0:10:00
+# Mémoire max. utilisée (ici 11 Go)
+# @ data_limit = 3gb
+# Type du travail
+# @ job_type = parallel
+# Nom du travail LoadLeveler
+# @ job_name   = 
+# Fichier de sortie standard du travail
+# @ output     = $(job_name)_std
+# Fichier de sortie d'erreur du travail
+# @ error      =  $(job_name)_err
+# Nombre de processus demandes
+# @ total_tasks = 8
+# @ queue
+#                                           
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mon
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mon	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mon	(revision 1844)
@@ -0,0 +1,5 @@
+#!/bin/ksh
+# $Id$
+############################################################################
+#### osxxlf Header mon
+############################################################################
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mpi
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mpi	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_osxxlf_mpi	(revision 1844)
@@ -0,0 +1,5 @@
+#!/bin/ksh
+# $Id$
+############################################################################
+#### osxxlf Header mpi
+############################################################################
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mon
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mon	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mon	(revision 1844)
@@ -0,0 +1,13 @@
+# $Id$
+############################################################################
+#### sx8brodie Header mon
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -l cputim_prc=00:20:00       # temps max (HH:MM:SS)
+#PBS -l cputim_job=00:40:00       # temps max (HH:MM:SS)
+#PBS -l memsz_job=5.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mpi
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mpi	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_mpi	(revision 1844)
@@ -0,0 +1,14 @@
+# $Id$
+############################################################################
+#### sx8brodie Header mpi
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -q multi                     # classe multiple
+#PBS -l cpunum_job=8              # réservation de 8 processeurs
+#PBS -l cputim_prc=00:20:00       # temps max (HH:MM:SS)
+#PBS -l cputim_job=00:40:00       # temps max (HH:MM:SS)
+#PBS -l memsz_job=8.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_omp
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_omp	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8brodie_omp	(revision 1844)
@@ -0,0 +1,15 @@
+# $Id$
+############################################################################
+#### sx8brodie Header omp
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -q multi                     # classe multiple
+#PBS -l cpunum_job=8              # réservation de 8 processeurs
+#PBS -l cputim_prc=00:20:00       # temps max (HH:MM:SS)
+#PBS -l cputim_job=00:40:00       # temps max (HH:MM:SS)
+#PBS -l memsz_job=3.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mon
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mon	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mon	(revision 1844)
@@ -0,0 +1,12 @@
+# $Id: jhd_sx8brodie_mon 1155 2008-06-26 14:39:39Z ctlod $
+############################################################################
+#### sx8mercure Header mon
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -l cputim_job=00:40:00       # temps max (HH:MM:SS)
+#PBS -l memsz_job=5.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mpi
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mpi	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_mpi	(revision 1844)
@@ -0,0 +1,12 @@
+# $Id: jhd_sx8brodie_mpi 1155 2008-06-26 14:39:39Z ctlod $
+############################################################################
+#### sx8mercure Header mpi
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -l cpunum_job=8              # réservation de 8 processeurs
+#PBS -l elapstim_req=0:30:00      # temps max (HH:MM:SS)
+#PBS -l memsz_job=8.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_omp
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_omp	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/jhd_sx8mercure_omp	(revision 1844)
@@ -0,0 +1,15 @@
+# $Id: jhd_sx8brodie_omp 1155 2008-06-26 14:39:39Z ctlod $
+############################################################################
+#### sx8mercure Header omp
+############################################################################
+#PBS -S /bin/ksh                  # Shell used
+#PBS -q multi                     # classe multiple
+#PBS -l cpunum_job=8              # réservation de 8 processeurs
+#PBS -l cputim_prc=00:20:00       # temps max (HH:MM:SS)
+#PBS -l cputim_job=00:30:00       # temps max (HH:MM:SS)
+#PBS -l memsz_job=4.0gb           # memoire max /job
+#PBS -N                           # Job name
+#PBS -e                           # error output file name
+#PBS -o                           # standard output file name
+
+
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE.ksh	(revision 1844)
@@ -0,0 +1,271 @@
+# $Id$
+set -xv
+
+CONF=GYRE
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee831/NVTK
+WORK=/workdir/rech/eee/reee831/NVTK/modipsl/config
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=360 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=180 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=180 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=4320 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# namelist modifications
+PAT_NIT000=$( supergrep nn_it000           namelist )
+PAT_NITEND=$( supergrep nn_itend           namelist )
+PAT_NSTOCK=$( supergrep nn_stock           namelist )
+PAT_NWRITE=$( supergrep nn_write           namelist )
+PAT_NRSTDT=$( supergrep nn_rstctl          namelist )
+PAT_NBITCM=$( supergrep nn_bit_cmp         namelist )
+PAT_NSOLVV=$( supergrep nn_solv            namelist )
+PAT_RESTAR=$( supergrep ln_rstart          namelist )
+PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+
+sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"          \
+    -e "s%$PAT_NIT000%   nn_it000    =     1   %"           \
+    -e "s%$PAT_NITEND%   nn_itend    =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nn_stock    =     ${ITERATIONS} %" \
+    -e "s%$PAT_NWRITE%   nn_write    =     60  %"           \
+    -e "s%$PAT_NRSTDT%   nn_rstctl   =     0   %"           \
+    -e "s%$PAT_NBITCM%   nn_bit_cmp  =     1%"              \
+    -e "s%$PAT_NSOLVV%   nn_solv     =      2%"              \
+    -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# Analytical forcing
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart.nc restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld.nc restart_mld.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_${i}.nc restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_${i}.nc restart_mld_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nn_it000             namelist )
+    PAT_NITEND=$( supergrep nn_itend             namelist )
+    PAT_NRSTDT=$( supergrep nn_rstctl             namelist )
+    PAT_RESTAR=$( supergrep ln_rstart          namelist )
+    PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+         -e "s%$PAT_NIT000%   nn_it000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nn_itend     =     $ORCA_NITEND %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl     =     2%"             \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6 ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6 ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+esac
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files=' *abort* memory* namelist* perfs* solver.stat ocean.output layout* GYRE* restart* mono*' ;;
+	'mpi' )
+               liste_files=' *abort* namelist* solver.stat perfs* ocean.output* layout* GYRE* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE_LOBSTER.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE_LOBSTER.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_GYRE_LOBSTER.ksh	(revision 1844)
@@ -0,0 +1,305 @@
+# $Id$
+set -xv
+
+CONF=GYRE_LOBSTER
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=360 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=180 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=180 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=4320 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# Biogeochemistry namelists
+get_namelist ${LOC_NAM} namelist_top ${MYO_EXP} namelist_top
+get_namelist ${LOC_NAM} namelist_lobster ${MYO_EXP} namelist_lobster
+
+# namelist modifications
+PAT_NIT000=$( supergrep nn_it000           namelist )
+PAT_NITEND=$( supergrep nn_itend           namelist )
+PAT_NSTOCK=$( supergrep nn_stock           namelist )
+PAT_NWRITE=$( supergrep nn_write           namelist )
+PAT_NRSTDT=$( supergrep nn_rstctl          namelist )
+PAT_NBITCM=$( supergrep nn_bit_cmp         namelist )
+PAT_NSOLVV=$( supergrep nn_solv            namelist )
+PAT_RESTAR=$( supergrep ln_rstart          namelist )
+PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+
+sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"          \
+    -e "s%$PAT_NIT000%   nn_it000    =     1   %"           \
+    -e "s%$PAT_NITEND%   nn_itend    =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nn_stock    =     ${ITERATIONS} %" \
+    -e "s%$PAT_NWRITE%   nn_write    =     60  %"           \
+    -e "s%$PAT_NRSTDT%   nn_rstctl   =     0   %"           \
+    -e "s%$PAT_NBITCM%   nn_bit_cmp  =     1%"              \
+    -e "s%$PAT_NSOLVV%   nn_solv     =      2%"              \
+    -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# namelist modifications
+PAT_NWRITRC=$( supergrep nwritetrc               namelist_top )
+PAT_NWRITRD=$( supergrep ntrd_trc                namelist_top )
+PAT_RESTTRD=$( supergrep ln_trdmld_trc_restart   namelist_top )
+PAT_LTRCRAD=$( supergrep ln_trcrad               namelist_top )
+
+sed -e "s%$PAT_NWRITRC%   nwritetrc   = ${ITERATIONS}%" \
+    -e "s%$PAT_NWRITRD%   ntrd_trc    = ${ITERATIONS}%" \
+    -e "s%$PAT_LTRCRAD%   ln_trcrad   =  .false.%"      \
+    -e "s%$PAT_RESTTRD%   ln_trdmld_trc_restart =  .false.%" namelist_top > nam.tmp
+
+mv nam.tmp namelist_top
+
+PAT_ADD=$( supergrep nwritedia namelist_lobster )
+sed -e "s%$PAT_ADD%   nwritedia    = ${ITERATIONS}%" namelist_lobster > nam.tmp
+mv nam.tmp namelist_lobster
+
+# Analytical forcing
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart.nc         restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld.nc     restart_mld.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_trc.nc     restart_trc.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_trc.nc restart_mld_trc.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_${i}.nc         restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_${i}.nc     restart_mld_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_trc_${i}.nc     restart_trc_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_trc_${i}.nc restart_mld_trc_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nn_it000             namelist )
+    PAT_NITEND=$( supergrep nn_itend             namelist )
+    PAT_NRSTDT=$( supergrep nn_rstctl             namelist )
+    PAT_RESTAR=$( supergrep ln_rstart          namelist )
+    PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+         -e "s%$PAT_NIT000%   nn_it000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nn_itend     =     $ORCA_NITEND %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl     =     2%"             \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+    # Biogeochemistry namelist modifications
+    PAT_RESTAR=$( supergrep ln_rsttr                  namelist_top )
+    PAT_RESTRD=$( supergrep ln_trdmld_trc_restart   namelist_top ) 
+   
+    sed -e "s%$PAT_RESTAR%   ln_rsttr      = .true. %"  \
+        -e "s%$PAT_RESTRD%   ln_trdmld_trc_restart =  .true.%" namelist_top > nam.tmp
+
+    mv nam.tmp namelist_top
+
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6 ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6 ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+esac
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files=' *abort* memory* namelist* perfs* solver.stat ocean.output layout* GYRE* restart* mono*' ;;
+	'mpi' )
+               liste_files=' *abort* namelist* solver.stat perfs* ocean.output* layout* GYRE* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM.ksh	(revision 1844)
@@ -0,0 +1,336 @@
+# $Id$
+set -xv
+
+CONF=ORCA2_LIM
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+USE_IOMPUT=xxx
+USE_IOSERVER=xxx
+NB_PROCS_IOSERVER=xxx
+#
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=300 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=150 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=150 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=5475 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# Sea-Ice namelist
+get_namelist ${LOC_NAM} namelist_ice_lim2 ${MYO_EXP} namelist_ice
+
+# iom_put xml file
+if [ "${USE_IOMPUT}" = "true" ]
+then
+    get_namelist ${LOC_NAM} xmlio_server.def ${MYO_EXP} xmlio_server.def
+    get_namelist ${LOC_NAM} iodef.xml ${MYO_EXP} iodef.xml
+    sed -e "s/^ *using_server *=.*$/  using_server = .${USE_IOSERVER}./" xmlio_server.def > tmp$$
+    mv tmp$$ xmlio_server.def
+fi
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# namelist modifications
+PAT_NIT000=$( supergrep nn_it000           namelist )
+PAT_NITEND=$( supergrep nn_itend           namelist )
+PAT_NSTOCK=$( supergrep nn_stock           namelist )
+PAT_NWRITE=$( supergrep nn_write           namelist )
+PAT_NRSTDT=$( supergrep nn_rstctl          namelist )
+PAT_NBITCM=$( supergrep nn_bit_cmp         namelist )
+PAT_TRACEN=$( supergrep ln_traadv_cen2     namelist )
+PAT_TRATVD=$( supergrep ln_traadv_tvd      namelist )
+PAT_N_CLAA=$( supergrep nn_cla             namelist )
+PAT_NSOLVV=$( supergrep nn_solv            namelist )
+PAT_RESTAR=$( supergrep ln_rstart          namelist )
+PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+PAT_NN_FWB=$( supergrep nn_fwb             namelist )
+PAT_NNSSSR=$( supergrep nn_sssr            namelist )
+
+sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"          \
+    -e "s%$PAT_NIT000%   nn_it000     =     1   %"           \
+    -e "s%$PAT_NITEND%   nn_itend     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nn_stock     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NWRITE%   nn_write     =     75  %"           \
+    -e "s%$PAT_NRSTDT%   nn_rstctl    =     0   %"           \
+    -e "s%$PAT_NBITCM%   nn_bit_cmp   =     1%"              \
+    -e "s%$PAT_TRACEN%   ln_traadv_cen2   =  .false.%"     \
+    -e "s%$PAT_TRATVD%   ln_traadv_tvd    =  .true.%"      \
+    -e "s%$PAT_N_CLAA%   nn_cla   = 0%"                     \
+    -e "s%$PAT_NSOLVV%   nn_solv     =      2%"              \
+    -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" \
+    -e "s%$PAT_NN_FWB%   nn_fwb      =      0%"              \
+    -e "s%$PAT_NNSSSR%   nn_sssr     =      1%"  namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# Get forcing files
+${D_GET} ${D_INPUT}/ORCA2_LIM_nemo_v3.1.tar ORCA2_LIM_nemo_v3.1.tar
+tar xvf ORCA2_LIM_nemo_v3.1.tar
+rm -f ORCA2_LIM_nemo_v3.1.tar
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart.nc restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice.nc restart_ice_in.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld.nc restart_mld.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_${i}.nc restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice_${i}.nc restart_ice_in_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_${i}.nc restart_mld_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nn_it000             namelist )
+    PAT_NITEND=$( supergrep nn_itend             namelist )
+    PAT_NRSTDT=$( supergrep nn_rstctl             namelist )
+    PAT_RESTAR=$( supergrep ln_rstart          namelist )
+    PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+         -e "s%$PAT_NIT000%   nn_it000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nn_itend     =     $ORCA_NITEND %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl     =     2%"             \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+if [ "${USE_IOSERVER}" = "true" ]
+then
+    cp ${MAINDIR}/modipsl/bin/ioserver ioserver
+    chmod 777 ioserver
+fi
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+
+if [ "${USE_IOSERVER}" = "true" ]
+then
+#-T- aix6        rm -f cmdfile
+#-T- aix6        cnt=1
+#-T- aix6        while [ $cnt -le ${NB_PROCS_IOSERVER} ]
+#-T- aix6        do
+#-T- aix6          echo "${CPERF#poe} ./ioserver" >> cmdfile
+#-T- aix6          cnt=$(( $cnt + 1 ))
+#-T- aix6        done
+#-T- aix6        cnt=1
+#-T- aix6        while [ $cnt -le ${NB_PROCS} ]
+#-T- aix6        do
+#-T- aix6          echo "${CPERF#poe} ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- aix6          cnt=$(( $cnt + 1 ))
+#-T- aix6        done
+#-T- aix6        poe -pgmmodel MPMD -cmdfile ./cmdfile
+#-T- sx8brodie   echo "-p ${NB_PROCS_IOSERVER} -e ./ioserver" > cmdfile
+#-T- sx8brodie   echo "-p ${NB_PROCS} -e ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- sx8brodie   ${CPERF} ${LEXE%% *} -f cmdfile 
+#-T- sx8mercure  echo "-p ${NB_PROCS_IOSERVER} -e ./ioserver" > cmdfile
+#-T- sx8mercure  echo "-p ${NB_PROCS} -e ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- sx8mercure  ${CPERF} ${LEXE%% *} -f cmdfile 
+else
+    case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+    esac
+    
+fi
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files='*abort* memory* namelist* *xml* perfs* cmdfile solver.stat ocean.output layout* ORCA2* restart* mono*' ;;
+	'mpi' )
+               liste_files='*abort* namelist* *xml* solver.stat perfs* cmdfile ocean.output* layout* ORCA2* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM3.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM3.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM3.ksh	(revision 1844)
@@ -0,0 +1,332 @@
+# $Id$
+set -xv
+
+CONF=ORCA2_LIM3
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+USE_IOMPUT=xxx
+USE_IOSERVER=xxx
+NB_PROCS_IOSERVER=xxx
+#
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=300 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=150 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=150 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=5475 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# Sea-Ice namelist
+get_namelist ${LOC_NAM} namelist_ice_lim3 ${MYO_EXP} namelist_ice
+
+# iom_put xml file
+if [ "${USE_IOMPUT}" = "true" ]
+then
+    get_namelist ${LOC_NAM} xmlio_server.def ${MYO_EXP} xmlio_server.def
+    get_namelist ${LOC_NAM} iodef.xml ${MYO_EXP} iodef.xml
+    sed -e "s/^ *using_server *=.*$/  using_server = .${USE_IOSERVER}./" xmlio_server.def > tmp$$
+    mv tmp$$ xmlio_server.def
+fi
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# namelist modifications
+PAT_NIT000=$( supergrep nn_it000           namelist )
+PAT_NITEND=$( supergrep nn_itend           namelist )
+PAT_NSTOCK=$( supergrep nn_stock           namelist )
+PAT_NWRITE=$( supergrep nn_write           namelist )
+PAT_NRSTDT=$( supergrep nn_rstctl          namelist )
+PAT_NBITCM=$( supergrep nn_bit_cmp         namelist )
+PAT_TRACEN=$( supergrep ln_traadv_cen2     namelist )
+PAT_TRATVD=$( supergrep ln_traadv_tvd      namelist )
+PAT_N_CLAA=$( supergrep nn_cla             namelist )
+PAT_NSOLVV=$( supergrep nn_solv            namelist )
+PAT_RESTAR=$( supergrep ln_rstart          namelist )
+PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+
+sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"          \
+    -e "s%$PAT_NIT000%   nn_it000     =     1   %"           \
+    -e "s%$PAT_NITEND%   nn_itend     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nn_stock     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NWRITE%   nn_write     =     75  %"           \
+    -e "s%$PAT_NRSTDT%   nn_rstctl    =     0   %"           \
+    -e "s%$PAT_NBITCM%   nn_bit_cmp   =     1%"              \
+    -e "s%$PAT_TRACEN%   ln_traadv_cen2   =  .false.%"     \
+    -e "s%$PAT_TRATVD%   ln_traadv_tvd    =  .true.%"      \
+    -e "s%$PAT_N_CLAA%   nn_cla   = 0%"                     \
+    -e "s%$PAT_NSOLVV%   nn_solv     =      2%"              \
+    -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# Get forcing files
+${D_GET} ${D_INPUT}/ORCA2_LIM_nemo_v3.1.tar ORCA2_LIM_nemo_v3.1.tar
+tar xvf ORCA2_LIM_nemo_v3.1.tar
+rm -f ORCA2_LIM_nemo_v3.1.tar
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart.nc restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice.nc restart_ice_in.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld.nc restart_mld.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_${i}.nc restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice_${i}.nc restart_ice_in_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_${i}.nc restart_mld_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nn_it000             namelist )
+    PAT_NITEND=$( supergrep nn_itend             namelist )
+    PAT_NRSTDT=$( supergrep nn_rstctl             namelist )
+    PAT_RESTAR=$( supergrep ln_rstart          namelist )
+    PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+         -e "s%$PAT_NIT000%   nn_it000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nn_itend     =     $ORCA_NITEND %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl     =     2%"             \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+if [ "${USE_IOSERVER}" = "true" ]
+then
+    cp ${MAINDIR}/modipsl/bin/ioserver ioserver
+    chmod 777 ioserver
+fi
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+
+if [ "${USE_IOSERVER}" = "true" ]
+then
+#-T- aix6        rm -f cmdfile
+#-T- aix6        cnt=1
+#-T- aix6        while [ $cnt -le ${NB_PROCS_IOSERVER} ]
+#-T- aix6        do
+#-T- aix6          echo "${CPERF#poe} ./ioserver" >> cmdfile
+#-T- aix6          cnt=$(( $cnt + 1 ))
+#-T- aix6        done
+#-T- aix6        cnt=1
+#-T- aix6        while [ $cnt -le ${NB_PROCS} ]
+#-T- aix6        do
+#-T- aix6          echo "${CPERF#poe} ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- aix6          cnt=$(( $cnt + 1 ))
+#-T- aix6        done
+#-T- aix6        poe -pgmmodel MPMD -cmdfile ./cmdfile
+#-T- sx8brodie   echo "-p ${NB_PROCS_IOSERVER} -e ./ioserver" > cmdfile
+#-T- sx8brodie   echo "-p ${NB_PROCS} -e ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- sx8brodie   ${CPERF} ${LEXE%% *} -f cmdfile 
+#-T- sx8mercure  echo "-p ${NB_PROCS_IOSERVER} -e ./ioserver" > cmdfile
+#-T- sx8mercure  echo "-p ${NB_PROCS} -e ./opa_${CONF}_${RUN}_${MYO_EXP}" >> cmdfile
+#-T- sx8mercure  ${CPERF} ${LEXE%% *} -f cmdfile 
+else
+    case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+    esac
+    
+fi
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files='*abort* memory* namelist* *xml* perfs* cmdfile solver.stat ocean.output layout* ORCA2* restart* mono*' ;;
+	'mpi' )
+               liste_files='*abort* namelist* *xml* solver.stat perfs* cmdfile ocean.output* layout* ORCA2* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM_PISCES.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM_PISCES.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_LIM_PISCES.ksh	(revision 1844)
@@ -0,0 +1,344 @@
+# $Id: job_ORCA2_LIM.ksh 1301 2009-02-09 17:15:38Z ctlod $
+set -xv
+
+CONF=ORCA2_LIM_PISCES
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=300 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=150 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=150 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=5475 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# Sea-Ice namelist
+get_namelist ${LOC_NAM} namelist_ice_lim2 ${MYO_EXP} namelist_ice
+
+# Passive transport namelist
+get_namelist ${LOC_NAM} namelist_top ${MYO_EXP} namelist_top
+
+# Pisces namelist
+get_namelist ${LOC_NAM} namelist_pisces ${MYO_EXP} namelist_pisces
+get_namelist ${LOC_NAM} kRGB61.txt      ${MYO_EXP} kRGB61.txt
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# namelist modifications
+PAT_NIT000=$( supergrep nn_it000           namelist )
+PAT_NITEND=$( supergrep nn_itend           namelist )
+PAT_NSTOCK=$( supergrep nn_stock           namelist )
+PAT_NWRITE=$( supergrep nn_write           namelist )
+PAT_NRSTDT=$( supergrep nn_rstctl          namelist )
+PAT_NBITCM=$( supergrep nn_bit_cmp         namelist )
+PAT_TRACEN=$( supergrep ln_traadv_cen2     namelist )
+PAT_TRATVD=$( supergrep ln_traadv_tvd      namelist )
+PAT_N_CLAA=$( supergrep nn_cla             namelist )
+PAT_NSOLVV=$( supergrep nn_solv            namelist )
+PAT_RESTAR=$( supergrep ln_rstart          namelist )
+PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+PAT_NN_FWB=$( supergrep nn_fwb             namelist )
+PAT_NNSSSR=$( supergrep nn_sssr            namelist )
+
+sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"          \
+    -e "s%$PAT_NIT000%   nn_it000     =     1   %"           \
+    -e "s%$PAT_NITEND%   nn_itend     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nn_stock     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NWRITE%   nn_write     =     75  %"           \
+    -e "s%$PAT_NRSTDT%   nn_rstctl    =     0   %"           \
+    -e "s%$PAT_NBITCM%   nn_bit_cmp   =     1%"              \
+    -e "s%$PAT_TRACEN%   ln_traadv_cen2   =  .false.%"     \
+    -e "s%$PAT_TRATVD%   ln_traadv_tvd    =  .true.%"      \
+    -e "s%$PAT_N_CLAA%   nn_cla   = 0%"                     \
+    -e "s%$PAT_NSOLVV%   nn_solv     =      2%"              \
+    -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" \
+    -e "s%$PAT_NN_FWB%   nn_fwb      =      0%"              \
+    -e "s%$PAT_NNSSSR%   nn_sssr     =      1%"  namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# namelist top modifications
+PAT_NWRTRC=$( supergrep nwritetrc         namelist_top )
+PAT_LRSTTR=$( supergrep ln_rsttr            namelist_top )
+PAT_NRSTTR=$( supergrep nrsttr            namelist_top )
+PAT_TRCRAD=$( supergrep ln_trcrad         namelist_top )
+
+sed -e "s%$PAT_NWRTRC%   nwritetrc   = ${ITERATIONS}%" \
+    -e "s%$PAT_LRSTTR%   ln_rsttr      =  .false.%"      \
+    -e "s%$PAT_NRSTTR%   nrsttr      =     0   %"       \
+    -e "s%$PAT_TRCRAD%   ln_trcrad   =  .false.%" namelist_top > nam.tmp     
+
+mv nam.tmp namelist_top
+
+# namelist pisces modifications
+PAT_DUSTF=$( supergrep ln_dustfer        namelist_pisces )
+PAT_RIVER=$( supergrep ln_river          namelist_pisces )
+PAT_NDEPO=$( supergrep ln_ndepo          namelist_pisces )
+PAT_SEDIN=$( supergrep ln_sedinput       namelist_pisces )
+
+sed -e "s%$PAT_DUSTF%   ln_dustfer    =  .false.%"  \
+    -e "s%$PAT_RIVER%   ln_river      =  .false.%"  \
+    -e "s%$PAT_NDEPO%   ln_ndepo      =  .false.%"  \
+    -e "s%$PAT_SEDIN%   ln_sedinput   =  .false.%" namelist_pisces > nam.tmp     
+
+mv nam.tmp namelist_pisces
+
+# Get forcing files
+${D_GET} ${D_INPUT}/ORCA2_LIM_nemo_v3.1.tar ORCA2_LIM_nemo_v3.1.tar
+tar xvf ORCA2_LIM_nemo_v3.1.tar
+rm -f ORCA2_LIM_nemo_v3.1.tar
+
+# Get forcing pisces files
+${D_GET} ${D_INPUT}/INPUTS_PISCES_v3.tar INPUTS_PISCES_v3.tar
+tar xvf INPUTS_PISCES_v3.tar
+rm -f INPUTS_PISCES_v3.tar
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart.nc restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice.nc restart_ice_in.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_trc.nc restart_trc.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_${i}.nc restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_ice_${i}.nc restart_ice_in_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_trc_${i}.nc restart_trc_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nn_it000             namelist )
+    PAT_NITEND=$( supergrep nn_itend             namelist )
+    PAT_NRSTDT=$( supergrep nn_rstctl             namelist )
+    PAT_RESTAR=$( supergrep ln_rstart          namelist )
+    PAT_RESMLD=$( supergrep ln_trdmld_restart  namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+         -e "s%$PAT_NIT000%   nn_it000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nn_itend     =     $ORCA_NITEND %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl     =     2%"             \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+   # Biogeochemistry namelist modifications
+    PAT_LRSTTR=$( supergrep ln_rsttr        namelist_top )
+    PAT_NRSTTR=$( supergrep nrsttr        namelist_top )
+
+    sed -e "s%$PAT_LRSTTR%   ln_rsttr     = .true. %"  \
+        -e "s%$PAT_NRSTTR%   nrsttr     = 2%" namelist_top > nam.tmp
+
+    mv nam.tmp namelist_top
+
+   PAT_PISDMP=$( supergrep ln_pisdmp     namelist_pisces )
+   sed -e "s%$PAT_PISDMP%  ln_pisdmp     = .false.%" namelist_pisces > nam.tmp
+   mv nam.tmp namelist_pisces
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+esac
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files='*abort* memory* namelist* perfs* solver.stat ocean.output layout* ORCA2* restart* mono*' ;;
+	'mpi' )
+               liste_files='*abort* namelist* solver.stat perfs* ocean.output* layout* ORCA2* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_OFF_PISCES.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_OFF_PISCES.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ORCA2_OFF_PISCES.ksh	(revision 1844)
@@ -0,0 +1,316 @@
+# $Id: job_ORCA2_LIM.ksh 1301 2009-02-09 17:15:38Z ctlod $
+set -xv
+
+CONF=ORCA2_OFF_PISCES
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=120 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=60 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=60 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=1460 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+#-T- osxxlf mkdir -p ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/RUN
+#-T- osxxlf zback=$?
+#-T- osxxlf if [ ${zback} = 0 ] ; then rm -rf namelist* *.nc memory* solver.stat ocean.output* mpp.output* mono.output* ; fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+
+# Passive transport namelist
+get_namelist ${LOC_NAM} namelist_top ${MYO_EXP} namelist_top
+
+# Pisces namelist
+get_namelist ${LOC_NAM} namelist_pisces ${MYO_EXP} namelist_pisces
+get_namelist ${LOC_NAM} kRGB61.txt      ${MYO_EXP} kRGB61.txt
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# namelist modifications
+PAT_NIT000=$( supergrep nit000             namelist )
+PAT_NITEND=$( supergrep nitend             namelist )
+PAT_NSTOCK=$( supergrep nstock             namelist )
+
+sed -e "s%$PAT_NIT000%   nit000     =     1   %"           \
+    -e "s%$PAT_NITEND%   nitend     =     ${ITERATIONS} %" \
+    -e "s%$PAT_NSTOCK%   nstock     =     ${ITERATIONS} %" namelist > nam.tmp
+
+mv nam.tmp namelist
+
+# namelist modifications
+PAT_NWRTRC=$( supergrep nwritetrc         namelist_top )
+PAT_LRSTTR=$( supergrep ln_rsttr            namelist_top )
+PAT_NRSTTR=$( supergrep nrsttr            namelist_top )
+PAT_TRCRAD=$( supergrep ln_trcrad         namelist_top )
+
+sed -e "s%$PAT_NWRTRC%   nwritetrc   = ${ITERATIONS}%" \
+    -e "s%$PAT_LRSTTR%   ln_rsttr      =  .false.%"      \
+    -e "s%$PAT_NRSTTR%   nrsttr      =     0   %"       \
+    -e "s%$PAT_TRCRAD%   ln_trcrad   =  .false.%" namelist_top > nam.tmp     
+
+mv nam.tmp namelist_top
+
+# namelist pisces modifications
+PAT_DUSTF=$( supergrep ln_dustfer        namelist_pisces )
+PAT_RIVER=$( supergrep ln_river          namelist_pisces )
+PAT_NDEPO=$( supergrep ln_ndepo          namelist_pisces )
+PAT_SEDIN=$( supergrep ln_sedinput       namelist_pisces )
+
+sed -e "s%$PAT_DUSTF%   ln_dustfer    =  .false.%"  \
+    -e "s%$PAT_RIVER%   ln_river      =  .false.%"  \
+    -e "s%$PAT_NDEPO%   ln_ndepo      =  .false.%"  \
+    -e "s%$PAT_SEDIN%   ln_sedinput   =  .false.%" namelist_pisces > nam.tmp
+
+mv nam.tmp namelist_pisces
+
+
+# Get forcing files
+${D_GET} ${D_INPUT}/INPUTS_DYNA_v3.tar  INPUTS_DYNA_v3.tar
+tar xvf INPUTS_DYNA_v3.tar
+rm -f INPUTS_DYNA_v3.tar
+
+# Get meshmask file
+${D_GET} ${D_INPUT}/INPUTS_INIT_v3.tar INPUTS_INIT_v3.tar
+tar xvf INPUTS_INIT_v3.tar
+rm -f INPUTS_INIT_v3.tar
+rm -f restart_trc*.nc
+
+# Get forcing pisces files
+${D_GET} ${D_INPUT}/INPUTS_PISCES_v3.tar INPUTS_PISCES_v3.tar
+tar xvf INPUTS_PISCES_v3.tar
+rm -f INPUTS_PISCES_v3.tar
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_trc.nc restart_trc.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*restart_trc_${i}.nc restart_trc_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    # Ocean namelist modifications
+    PAT_NIT000=$( supergrep nit000             namelist )
+    PAT_NITEND=$( supergrep nitend             namelist )
+    ORCA_NIT000=$(( $ITERATIONS + 1 ))
+    ORCA_NITEND=$(( $ITERATIONS*2 ))
+    
+    sed  -e "s%$PAT_NIT000%   nit000     =     $ORCA_NIT000 %" \
+         -e "s%$PAT_NITEND%   nitend     =     $ORCA_NITEND %" namelist > nam.tmp
+    
+    mv nam.tmp namelist
+
+   # Biogeochemistry namelist modifications
+    PAT_LRSTTR=$( supergrep ln_rsttr        namelist_top )
+    PAT_NRSTTR=$( supergrep nrsttr        namelist_top )
+
+    sed -e "s%$PAT_LRSTTR%   ln_rsttr     = .true. %"  \
+        -e "s%$PAT_NRSTTR%   nrsttr     = 2%" namelist_top > nam.tmp
+
+    mv nam.tmp namelist_top
+
+   PAT_PISDMP=$( supergrep ln_pisdmp     namelist_pisces )
+   sed -e "s%$PAT_PISDMP%  ln_pisdmp     = .false.%" namelist_pisces > nam.tmp
+   mv nam.tmp namelist_pisces
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+#-T- osxxlf echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- osxxlf echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;; 
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6     ;;
+#-T- osxxlf   ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- osxxlf   mpd&
+#-T- osxxlf   sleep 5
+#-T- osxxlf   ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP}
+#-T- osxxlf   mpdallexit ;;
+esac
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files='*abort* memory* namelist* perfs* ocean.output layout* PISCES* restart* mono*' ;;
+	'mpi' )
+               liste_files='*abort* namelist* perfs* ocean.output* layout* PISCES* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ZAGRIF.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ZAGRIF.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/job_ZAGRIF.ksh	(revision 1844)
@@ -0,0 +1,319 @@
+# $Id$
+set -xv
+
+CONF=ZAGRIF
+# Variables changed by lance_batch.ksh script
+RUN=xxx
+NB_PROCS=xxx
+LAUNCH=xxx
+LEXE=xxx
+CPERF=xxx
+D_INPUT=xxx
+D_GET=xxx
+REF_TAG=xxx
+MYO_EXP=xxx
+TSYMB=xxx
+
+# Variables changed by ins_valid.ksh script
+MAINDIR=/workdir/rech/eee/reee534/AUTRE
+WORK=/workdir/rech/eee/reee534/AUTRE/modipsl/config/
+REF_OD=/u/rech/eee/reee831/NEMO_VALIDATION
+
+# Arguments
+# type = 'long' or '1_short' or '2_short'
+type=$1
+
+case ${type} in
+        'long' ) 
+             DIROUT='LONG'
+             ITERATIONS=300
+             NOUTPUT=75 ;;
+              
+        '1_short' ) 
+             DIROUT='1_SHORT'
+             ITERATIONS=150
+             NOUTPUT=75 ;;
+              
+        '2_short' ) 
+             DIROUT='2_SHORT'
+             ITERATIONS=150
+             NOUTPUT=75 ;;
+
+        'gtime' ) 
+             DIROUT='GTIME'
+             ITERATIONS=5475
+             NOUTPUT=75 ;;
+esac
+
+# Working directory
+cd ${TMPDIR}
+
+##############################################################
+##############################################################
+##############################################################
+###             Input files
+##############################################################
+##############################################################
+##############################################################
+# Local function to copy namelists files
+get_namelist () {
+    if [ -a $1/$2_$3 ] ; then
+        cp $1/$2_$3 $4
+    else
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        echo "              $2_$3 file doesn't exist, we use the standard $2"
+        echo '                ###############################################################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ######################## W A R N I N G ########################'
+        echo '                ###############################################################'
+        cp $1/$2 $4
+    fi
+}
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+# Ocean namelist
+LOC_NAM=${MAINDIR}/modipsl/config/${CONF}/EXP00
+get_namelist ${LOC_NAM} namelist ${MYO_EXP} namelist
+get_namelist ${LOC_NAM} 1_namelist ${MYO_EXP} 1_namelist
+
+# Sea-Ice namelist
+get_namelist ${LOC_NAM} namelist_ice_lim2 ${MYO_EXP} namelist_ice
+get_namelist ${LOC_NAM} 1_namelist_ice_lim2 ${MYO_EXP} 1_namelist_ice
+
+# AGRIF file
+cp ${LOC_NAM}/AGRIF_FixedGrids.in AGRIF_FixedGrids.in
+
+# Local function to find namelists parameters
+supergrep () {
+    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
+}
+
+for CHGFILE in `ls *namelist`
+do
+     # namelist modifications
+     PAT_NIT000=$( supergrep nn_it000             ${CHGFILE} )
+     PAT_NITEND=$( supergrep nn_itend             ${CHGFILE} )
+     PAT_NSTOCK=$( supergrep nn_stock             ${CHGFILE} )
+     PAT_NWRITE=$( supergrep nn_write             ${CHGFILE} )
+     PAT_NRSTDT=$( supergrep nn_rstctl            ${CHGFILE} )
+     PAT_NBITCM=$( supergrep nn_bit_cmp           ${CHGFILE} )
+     PAT_TRACEN=$( supergrep ln_traadv_cen2       ${CHGFILE} )
+     PAT_TRATVD=$( supergrep ln_traadv_tvd        ${CHGFILE} )
+     PAT_N_CLAA=$( supergrep nn_cla               ${CHGFILE} )
+     PAT_NSOLVV=$( supergrep nn_solv              ${CHGFILE} )
+     PAT_RESTAR=$( supergrep ln_rstart          ${CHGFILE} )
+     PAT_RESMLD=$( supergrep ln_trdmld_restart  ${CHGFILE} )
+     PAT_NAMECF=$( supergrep cn_exp             ${CHGFILE} )
+     PAT_NN_FWB=$( supergrep nn_fwb             ${CHGFILE} )
+     PAT_NNSSSR=$( supergrep nn_sssr            ${CHGFILE} )
+
+    if [ ${CHGFILE} = 'namelist' ] ; then
+        ORCA_NITEND=$(( $ITERATIONS   ))
+        ORCA_NSTOCK=$(( $NOUTPUT   ))
+        PAT_NAMECF_tmp="   cn_exp     =     \"${CONF}\""
+    else
+        ORCA_NITEND=$(( $ITERATIONS*2 ))
+        ORCA_NSTOCK=$(( $NOUTPUT*2   ))
+        PAT_NAMECF_tmp="$PAT_NAMECF"
+    fi
+
+     sed -e "s%$PAT_RESTAR%   ln_rstart   =  .false.%"           \
+         -e "s%$PAT_NAMECF%$PAT_NAMECF_tmp%"                     \
+         -e "s%$PAT_NIT000%   nn_it000     =     1   %"            \
+         -e "s%$PAT_NITEND%   nn_itend     =     ${ORCA_NITEND} %" \
+         -e "s%$PAT_NSTOCK%   nn_stock     =     ${ORCA_NITEND} %" \
+         -e "s%$PAT_NWRITE%   nn_write     =     ${ORCA_NSTOCK} %" \
+         -e "s%$PAT_NRSTDT%   nn_rstctl    =     0   %"            \
+         -e "s%$PAT_NBITCM%   nn_bit_cmp   =     1%"                 \
+         -e "s%$PAT_TRACEN%   ln_traadv_cen2   =  .false.%"      \
+         -e "s%$PAT_TRATVD%   ln_traadv_tvd    =  .true.%"       \
+         -e "s%$PAT_N_CLAA%   nn_cla   = 0%"                      \
+         -e "s%$PAT_NSOLVV%   nn_solv  =      2%"               \
+         -e "s%$PAT_NN_FWB%   nn_fwb      =      0%"            \
+         -e "s%$PAT_NNSSSR%   nn_sssr     =      1%"            \
+         -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .false.%" ${CHGFILE} > nam.$$
+     
+     mv nam.$$ ${CHGFILE} && rm -f nam.$$
+done
+
+# Get forcing files
+${D_GET} ${D_INPUT}/ORCA2_LIM_nemo_v3.1.tar ORCA2_LIM_nemo_v3.1.tar
+tar xvf ORCA2_LIM_nemo_v3.1.tar
+rm -f ORCA2_LIM_nemo_v3.1.tar
+
+# Get restarts files if needed
+if [ $type = '2_short' ]
+then
+    if [ ${RUN} = 'mon' -o ${RUN} = 'omp' ] ; then 
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/ZAGRI*_restart.nc restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/1_*restart.nc 1_restart.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/ZAGRI*restart_ice.nc restart_ice_in.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/1_*restart_ice.nc 1_restart_ice_in.nc
+        cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld.nc restart_mld.nc
+    fi
+
+    if [ ${RUN} = 'mpi' ] ; then
+        typeset -Z4 i=0
+        while [ $i -lt $NB_PROCS ]
+        do
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/ZAGRI*_restart_${i}.nc restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/1_*restart_${i}.nc 1_restart_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/ZAGRI*_restart_ice_${i}.nc restart_ice_in_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/1_*restart_ice_${i}.nc 1_restart_ice_in_${i}.nc
+           cp ${WORK}/NEMO_VALID/W${CONF}/${RUN}/1_SHORT/${MYO_EXP}/*_restart_mld_${i}.nc restart_mld_${i}.nc
+           let i=$i+1
+        done
+    fi
+
+    for CHGFILE in `ls *namelist`
+    do
+        # namelist modifications
+        PAT_NIT000=$( supergrep nn_it000             ${CHGFILE} )
+        PAT_NITEND=$( supergrep nn_itend             ${CHGFILE} )
+        PAT_NRSTDT=$( supergrep nn_rstctl            ${CHGFILE} )
+        PAT_RESTAR=$( supergrep ln_rstart          ${CHGFILE} )
+        PAT_RESMLD=$( supergrep ln_trdmld_restart  ${CHGFILE} )
+
+        if [ ${CHGFILE} = 'namelist' ] ; then
+            ORCA_NIT000=$(( $ITERATIONS + 1 ))
+            ORCA_NITEND=$(( $ITERATIONS*2   ))
+        else
+            ORCA_NIT000=$(( $ITERATIONS*2 + 1 ))
+            ORCA_NITEND=$(( $ITERATIONS*4 ))
+        fi
+        
+        sed -e "s%$PAT_RESTAR%   ln_rstart   =  .true.%"          \
+            -e "s%$PAT_NIT000%   nn_it000    =     $ORCA_NIT000 %" \
+            -e "s%$PAT_NITEND%   nn_itend    =     $ORCA_NITEND %" \
+            -e "s%$PAT_NRSTDT%   nn_rstctl   =     2%"             \
+            -e "s%$PAT_RESMLD%   ln_trdmld_restart =  .true.%" ${CHGFILE} > nam.$$
+        
+        mv nam.$$ ${CHGFILE} && rm -f nam.$$
+    done
+
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch run
+##############################################################
+##############################################################
+##############################################################
+
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_${RUN}_${MYO_EXP} opa_${CONF}_${RUN}_${MYO_EXP}
+cp ${MAINDIR}/modipsl/bin/opa_${CONF}_memo_${MYO_EXP} opa_${CONF}_memo_${MYO_EXP}
+chmod 777 opa_${CONF}_${RUN}_${MYO_EXP}
+chmod 777 opa_${CONF}_memo_${MYO_EXP}
+
+#
+# Profiling & Executable memory size
+####################################
+touch memory_size.txt
+
+case ${RUN} in
+        'mon' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8brodie echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure echo "Stack memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- sx8mercure echo "Static memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"   >> memory_size.txt  ;;
+#-T- aix6 echo "Stack memory: $( (size opa_${CONF}_memo_${MYO_EXP}) )"    >> memory_size.txt 
+#-T- aix6 echo "Static memory: $( (size opa_${CONF}_${RUN}_${MYO_EXP}) )"   >> memory_size.txt ;;
+        'mpi' ) 
+#-T- sx8brodie export MPIPROGINF=detail ;;
+#-T- sx8mercure export MPIPROGINF=detail ;;
+#-T- aix6     ;;
+        'omp' ) 
+#-T- sx8brodie export F_PROGINF=detail
+#-T- sx8brodie export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- sx8mercure export F_PROGINF=detail
+#-T- sx8mercure export OMP_NUM_THREADS=${NB_PROCS} ;;
+#-T- aix6     ;;
+esac
+#
+# >>>>>> EXECUTION < < < <
+##########################
+
+case ${RUN} in
+        'mon' | 'omp' ) 
+              ${CPERF} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+        'mpi' ) 
+#-T- sx8brodie         ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- sx8mercure        ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+#-T- aix6              ${CPERF} ${LEXE} ./opa_${CONF}_${RUN}_${MYO_EXP} ;;
+esac
+
+ls -l
+#
+
+##############################################################
+##############################################################
+##############################################################
+###             Save output files
+##############################################################
+##############################################################
+##############################################################
+case ${RUN} in
+	'mon' | 'omp' )
+               liste_files=' *abort* memory* *namelist* perfs* solver.stat ocean.output 1_Agulhas* layout* ZAGRIF* restart* mono*' ;;
+	'mpi' )
+               liste_files=' *abort* *namelist* solver.stat perfs* ocean.output* layout* 1_Agulhas* ZAGRIF* restart* mpp*' ;;
+esac
+
+# Ensure that all files saved are coming from the current run
+ind=1
+for k in $liste_files
+do
+   echo $k > temp
+   var=$( ( awk '{printf("%-.4s", varin ) } ' varin=$k temp ) )
+   if [ ${ind} = 1 -a ${var} = 'perf' ] ; then
+       kc='perf*'
+       rm -f ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/${kc}
+       ind=0
+   fi
+   cp $k ${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${MYO_EXP}/$k
+done
+
+##############################################################
+##############################################################
+##############################################################
+###             Retrieve some reference run files
+##############################################################
+##############################################################
+##############################################################
+if [ ${REF_TAG} = 'nemo_v2' -o ${REF_TAG} = 'nemo_v2_3' -o ${REF_TAG} = 'nemo_v3' ]
+then
+   STORE_DATA=${REF_OD}/${CONF}/${REF_TAG}/${RUN}/${DIROUT}
+   LFILES="solver.stat memory_size.txt ocean.output ${RUN}${CONF}_err"
+   SAV_DIR=${WORK}/NEMO_VALID/W${CONF}/${RUN}/${DIROUT}/${REF_TAG}
+   if [ ! -d ${SAV_DIR} ] ;  then
+      mkdir ${SAV_DIR}
+   fi
+   for ref_file in ${LFILES}
+   do
+       ${D_GET} ${STORE_DATA}/${TSYMB}${ref_file} ${SAV_DIR}/${ref_file}
+   done
+fi
+
+##############################################################
+##############################################################
+##############################################################
+###             Launch restart job
+##############################################################
+##############################################################
+##############################################################
+if [ $type = '1_short' ] ; then
+    cd ${WORK}/NEMO_VALID/W${CONF}/${RUN}/2_SHORT/${MYO_EXP}
+    ${LAUNCH}job_${RUN}_2_short_${MYO_EXP}.ksh
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/lance_batch.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/lance_batch.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/JOBS/lance_batch.ksh	(revision 1844)
@@ -0,0 +1,339 @@
+#!/bin/ksh
+# $Id$
+######################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# INPUT ARGS: 9
+#     - CONF  : configuration name (ORCA2_LIM, GYRE ..)
+#     - MTIME : timing/no timing (timing or notiming)
+#     - JOBTOL: jobs to launch: all, long, 1_short or gtime
+#     - OWNEXP: name of the experience performed
+#     - PRC   : total number of processors
+#     - REFTAG: reference tag name to be compare to
+#     - USE_IOMPUT: true of false (default false)
+#     - USE_IOSERVER: true of false (default false)
+#     - NB_PROCS_IOSERVER: (default 0)
+#
+# WORK: This script aims to (for each standard configuration) :
+#
+#    I.   Take into account target's specificities 
+#         Variables below must be filled for a new target
+#         - W_XX   = name of target 
+#         - LAUN   = name of jobs launcher command
+#         - LLJOBS = name of jobs listing command
+#         - LSUB   = name of running command
+#         - LPERF  = name of timing command for the whole run
+#         - LJTIM  = required time for a one year run (/proc)
+#         - LJTIMJ = required time for a one year run (job)
+#         - CMDGET = name of specific command to retrieve files
+#         - SYMBOL = identifier associated to a platform which 
+#                    is used to name all outputs files
+#                    Ex: For Brodie, this symbol could be "B_" so
+#                    file names looks like B_solver.stat ...
+#
+#    II.  Build jobs
+#         - based on specific header depending on target, it must 
+#           be provided for a new target following samples
+#           jhd_[target_name]_mon for mono-processors runs
+#           jhd_[target_name]_mpi for multi-processors MPI runs
+#           jhd_[target_name]_omp for multi-processors OPen-MP runs
+#
+#    III. Launch jobs
+#         to test both reproductibility and restartability
+#         for each configuration NAME_CONF 
+#         & for each run type [mon, mpi, omp] 
+#         3 runs will be launched:
+#              - LONG
+#              - 1_SHORT
+#              - 2_SHORT
+#
+#    IV. Launch cron job
+#         Since no jobs (for a given configuration) are in 
+#         the batch queue, this cron will launch the assessment.ksh 
+#         script
+#
+##########################################################
+#set -xv
+##########################################################
+##### Begin Users modifications
+##########################################################
+# IODIR     : directory where to get ORCA2_LIM_nemo_v3.1.tar 
+##########################################################
+IODIR=/u/rech/eee/reee512/NEMO/
+TARGET=sx8brodie
+##########################################################
+##### End   Users modifications
+##########################################################
+
+CONF=$1
+MTIME=$2
+JOBTOL=$3
+OWNEXP=$4
+PRC=$5
+REFTAG=$6
+USE_IOMPUT=${7:-false}
+USE_IOSERVER=${8:-false}
+NB_PROCS_IOSERVER=${9:-0}
+[ "${USE_IOMPUT}" = "false" ] && USE_IOSERVER=false
+[ "${USE_IOSERVER}" = "false" ] && NB_PROCS_IOSERVER=0
+RUN=$(basename `pwd`)
+[ "${RUN}" = "mon" ] && PRC=1
+if [[ ( "${TARGET}" = "sx8brodie" ) || ( "${TARGET}" = "sx8mercure" ) ]]
+then
+    if [ $(( ${PRC} + ${NB_PROCS_IOSERVER} )) -gt 8 ]
+    then
+	echo NVTK is not made to use more than 1 node on SX8 machines...
+	echo please, reduce the number of cpu used by NEMO or/and the ioserver
+	exit 1
+    fi
+fi
+# ---------------------------------------------------------------
+#  I. Take into account target's specificities 
+#     Select appropriate target lines in Job_${CONF}.ksh
+# ---------------------------------------------------------------
+if   [ ${TARGET} = 'sx8brodie' ]; then
+    W_XX='#-T- sx8brodie'
+    LAUN='qsub '
+    LLJOBS=qstat
+    LSUB="mpirun -np ${PRC}"
+    LPERF=
+    LJTIM='01:20:00'
+    LJTIMJ='01:40:00'
+    CMDGET=mfget
+    SYMBOL=B_
+elif [ ${TARGET} = 'sx8mercure' ]; then
+    W_XX='#-T- sx8mercure'
+    LAUN='qsub '
+    LLJOBS=qstat
+    LSUB="mpirun -np ${PRC}"
+    LPERF=
+    LJTIM='01:20:00'
+    LJTIMJ='01:40:00'
+    CMDGET=cp
+    SYMBOL=M_
+elif [ ${TARGET} = 'aix6' ]; then
+    W_XX='#-T- aix6'
+    LAUN='llsubmit '
+    LLJOBS=Qstat
+    LSUB=
+    LPERF="poe hpmcount -o perfs_mpi.txt" 
+    LJTIM='01:10:00'
+    LJTIMJ=
+    CMDGET=mfget
+    SYMBOL=V_
+elif [ ${TARGET} = 'osxxlf' ]; then
+    W_XX='#-T- osxxlf'
+    LAUN='./'
+    LLJOBS=
+    LSUB="mpirun -np ${PRC}"
+    LPERF=
+    LJTIM=
+    LJTIMJ=
+    CMDGET=cp
+    SYMBOL=D_
+else
+    echo '	#######################################'
+    echo ' 	You must give a target name :'
+    echo ' 	sx8brodie, aix6 or add one'
+    echo ' 	Have a look in lance_batch.ksh script'
+    echo '	#######################################'
+    stop
+fi
+
+sed -e "s%^$W_XX *%%" job_${CONF}.ksh | grep -v '^#-T- ' > job_${CONF}.$$
+
+# --------------------------------------------------------------
+# II. Build jobs 
+#     Adapt header (batch jobs) and concatanate it with core job
+# --------------------------------------------------------------
+if [ ${CONF} == 'ORCA2_LIM' ] ; then
+    CONFS=ORCA2
+elif [ ${CONF} == 'ORCA2_LIM3' ] ; then
+    CONFS=OR2L3
+elif [ ${CONF} == 'GYRE' ] ; then
+    CONFS=GYREO
+elif [ ${CONF} == 'GYRE_LOBSTER' ] ; then
+    CONFS=GYREL
+elif [ ${CONF} == 'ORCA2_LIM_PISCES' ] ; then
+    CONFS=OR2LP
+elif [ ${CONF} == 'ORCA2_OFF_PISCES' ] ; then
+    CONFS=OR2OP
+elif [ ${CONF} == 'ZAGRIF' ] ; then
+    CONFS=ZAGRI
+else
+    CONFS=${CONF}
+fi
+
+case ${TARGET} in
+    'osxxlf' )
+	cp jhd_${TARGET}_${RUN} jhd_${TARGET}_${RUN}_tmp  ;;
+    'aix6' )
+	CAR_JNAM=$( grep '\# @ job_name' jhd_${TARGET}_${RUN} )
+	CAR_JMPI=$( grep '\# @ total_tasks' jhd_${TARGET}_${RUN} )
+	sed -e "s%$CAR_JNAM%\# @ job_name = ${RUN}${CONFS}%" \
+	    -e "s%$CAR_JMPI%\# @ total_tasks = $(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
+	    jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp  ;;
+    'sx8brodie' )
+	CAR_JNAM=$( grep '\#PBS -N ' jhd_${TARGET}_${RUN} )
+	CAR_JNAMO=$( grep '\#PBS -o ' jhd_${TARGET}_${RUN} )
+	CAR_JNAME=$( grep '\#PBS -e ' jhd_${TARGET}_${RUN} )
+	if [ ${RUN} = 'mpi' -o ${RUN} = 'omp' ] ; then
+	    CAR_JMPI=$( grep '\#PBS -l cpunum_job' jhd_${TARGET}_${RUN} )
+	    sed -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
+		-e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
+		-e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
+		-e "s%$CAR_JMPI%\#PBS -l cpunum_job=$(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
+		jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
+	else
+	    sed -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
+		-e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
+		-e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
+		jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
+	fi ;;
+    'sx8mercure' )
+	CAR_JNAM=$( grep '\#PBS -N ' jhd_${TARGET}_${RUN} )
+	CAR_JNAMO=$( grep '\#PBS -o ' jhd_${TARGET}_${RUN} )
+	CAR_JNAME=$( grep '\#PBS -e ' jhd_${TARGET}_${RUN} )
+	if [ ${RUN} = 'mpi' -o ${RUN} = 'omp' ] ; then
+	    CAR_JMPI=$( grep '\#PBS -l cpunum_job' jhd_${TARGET}_${RUN} )
+	    sed -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
+		-e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
+		-e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
+		-e "s%$CAR_JMPI%\#PBS -l cpunum_job=$(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
+		jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
+	else
+	    sed -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
+		-e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
+		-e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
+		jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
+	fi ;;
+esac
+
+cat jhd_${TARGET}_${RUN}_tmp job_${CONF}.$$ > job_tmp_${RUN}.ksh
+rm -f job_${CONF}.$$ jhd_${TARGET}_${RUN}_tmp
+
+# -----------------------------------------------------------------------------
+# III. Launch jobs
+#      The 3 following jobs are created for the run [type]=mon,mpi,omp :
+#      - "job_[type]_long.ksh"      ---> long run
+#      - "job_[type]_1_short.ksh"   ---> stream 1 run
+#      - "job_[type]_2_short.ksh"   ---> stream 2 run
+#      - "job_[type]_gtime.ksh"     ---> one year run
+#      The first 2 as the last one are immediatly launched whereas "job_[type]_2_short.ksh"
+#      is launched only when the "job_[type]_1_short.ksh" short run is finished
+# -----------------------------------------------------------------------------
+jobnam[0]=long ; jobnam[1]=1_short ; jobnam[2]=2_short ; jobnam[3]=gtime 
+dirjob[0]=LONG ; dirjob[1]=1_SHORT ; dirjob[2]=2_SHORT ; dirjob[3]=GTIME 
+
+case ${JOBTOL} in
+    'all' )
+	if [ ${MTIME} = 'timing' ] ; then 
+	    ind=0 
+	    iloop=4
+	else
+	    ind=0 
+	    iloop=3
+	fi 
+	;;
+    'long' )
+	ind=0 
+	iloop=1 ;;
+    'short' )
+	ind=1 
+	iloop=3 ;;
+    'gtime' )
+	ind=3 
+	iloop=4 ;;
+esac
+
+chwd () { 
+    word=$( grep "^ *${1}" job_tmp_${RUN}.ksh | cut -f 1 -d " " )
+    if [ "${word}" != "" ] 
+	then
+	sed -e "s@${word}@${1%=*}=\"${2}\"@" job_tmp_${RUN}.ksh > tmp$$
+	mv tmp$$ job_tmp_${RUN}.ksh
+    fi
+}
+
+chwd "RUN=xxx"              "${RUN}"
+chwd "NB_PROCS=xxx"          ${PRC}
+chwd "LAUNCH=xxx"           "${LAUN}"
+chwd "LEXE=xxx"             "${LSUB}"
+chwd "CPERF=xxx"            "${LPERF}"
+chwd "D_INPUT=xxx"          "${IODIR}"
+chwd "D_GET=xxx"            "${CMDGET}"
+chwd "REF_TAG=xxx"          "${REFTAG}" 
+chwd "MYO_EXP=xxx"          "${OWNEXP}"
+chwd "TSYMB=xxx"            "${SYMBOL}"
+chwd "USE_IOMPUT=xxx"        ${USE_IOMPUT}
+chwd "USE_IOSERVER=xxx"      ${USE_IOSERVER}
+chwd "NB_PROCS_IOSERVER=xxx" ${NB_PROCS_IOSERVER}
+
+while [ $ind -lt ${iloop} ]
+  do
+  
+  chwd "type=" "${jobnam[$ind]}"  
+  cp job_tmp_${RUN}.ksh job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
+  
+  if [ ${jobnam[$ind]} = 'gtime' ] ; then
+      
+      case ${TARGET} in
+	  'aix6' )
+	      CAR_JTIM=$( grep '\# @ wall_clock_limit' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
+	      sed -e "s%$CAR_JTIM%\# @ wall_clock_limit = ${LJTIM}%" \
+		  job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
+	  'sx8brodie' )
+	      CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
+	      CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
+	      sed -e "s%$CAR_JTIMP%\#PBS -l cputim_prc=${LJTIM}%" \
+		  -e "s%$CAR_JTIMJ%\#PBS -l cputim_job=${LJTIMJ}%" \
+		  job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
+	  'sx8mercure' )
+	      CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
+	      CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
+	      sed -e "s%$CAR_JTIMP%\#PBS -l cputim_prc=${LJTIM}%" \
+		  -e "s%$CAR_JTIMJ%\#PBS -l cputim_job=${LJTIMJ}%" \
+		  job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
+      esac
+      mv job_${RUN}_${jobnam[$ind]}.ksh_tmp job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
+      
+  fi
+  
+  chmod 750 job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
+  
+  if [ ! -d ${dirjob[$ind]}/$OWNEXP ] ;  then
+      mkdir ${dirjob[$ind]}/$OWNEXP
+  fi
+  mv job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh ${dirjob[$ind]}/${OWNEXP}/.
+  
+  if [ ${jobnam[$ind]} != '2_short' ] ; then
+      cd ${dirjob[$ind]}/${OWNEXP}
+      ${LAUN}job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh &
+      cd ../..
+  fi
+  
+  let ind=$ind+1
+done
+rm -f job_tmp_${RUN}.ksh
+
+# List all jobs submitted
+${LLJOBS}
+
+# -----------------------------------------------------------------------------
+# IV. Launch cron to be able to launch the assessment step
+# -----------------------------------------------------------------------------
+if [ ${RUN} == 'mon' ] ; then
+    cd ..
+    
+    CAR_LJOB_tmp=$( grep 'LJOBS=' cron_jobs.ksh )
+    CAR_LJOB=`echo $CAR_LJOB_tmp | cut -f 1 -d " " `
+    
+    sed    -e "s%$CAR_LJOB%LJOBS=${LLJOBS}%" cron_jobs.ksh > cron_jobs.$$
+    mv cron_jobs.$$ cron_jobs.ksh &&  rm -rf cron_jobs.$$
+    chmod 744 cron_jobs.ksh 
+    
+    if [ ${TARGET} != 'osxxlf' ]; then
+        ./cron_jobs.ksh ${OWNEXP} ${CONFS} &
+    fi
+fi
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/MODIPSL_FILES/ins_make
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/MODIPSL_FILES/ins_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/MODIPSL_FILES/ins_make	(revision 1844)
@@ -0,0 +1,193 @@
+#!/bin/bash
+# $Id$
+#---------------------------------------------------------------------
+#- Installation of Makefiles according to an environment
+#---------------------------------------------------------------------
+shopt -s extglob
+#-
+function ins_make_Usage
+{
+typeset v0 v1 v2 v3 v4 v5 v6 v7 h_n;
+echo -e "
+ins_make install the Makefile in the directories
+
+Usage :
+  ${b_n} [-h] [-v] [-d] [-p r] [-t h] [-w w] [-m m]
+
+Options :
+  -h   : help
+  -v   : verbose mode
+  -d   : debug mode
+  -p p : int and real precision I4R4/I4R8/I8R8/4/8
+  -t h : target host_name
+  -w w : directory Where to install the Makefile (recursive)
+  -m m : mpi context choosen for the coupling MPI1/MPI2
+
+Defaults :
+   -t local_host -p I4R8
+
+Example for remote host compilation :
+  ins_make -t sx8brodie
+"
+echo -e "Supported targets :\n"
+[[ ! -f "${MKTG}" ]] && { echo -e "? (${MKTG} unreachable)\n"; exit 3; }
+while read v1 v2 v3 v4 v5 v6 v7
+  do
+    [[ -n "${v1}" && "${v1}${v3}" = '#-Q-#-'                       && \
+       -n "${v4}" && "${v4}${v5}${v6}" = 'Globaldefinitionsfor' ]] && \
+     { h_n=${v2}'           '; echo -e "${h_n:0:13} : ${v7}"; }
+  done <${MKTG}
+echo -e "
+For other targets, look in ${MKTG}.
+"
+}
+#-    dirname     and      basename
+d_n=$(dirname ${0}); b_n=$(basename ${0});
+#- File containing global definitions
+MKTG=${d_n}'/AA_make.gdef'
+
+#- Retrieving and validation of the options
+x_v='silencious'; x_d='normal'; x_p="??"; x_t="??"; x_w="??"; x_m='??';
+while getopts :hvdp:m:t:w: V
+  do
+   case ${V} in
+    (h)  ins_make_Usage; exit 0;;
+    (v)  x_v='verbose';;
+    (d)  x_d='debug';;
+    (p)  x_p=${OPTARG};;
+    (t)  x_t=${OPTARG};;
+    (w)  x_w=${OPTARG};;
+    (m)  x_m=${OPTARG};;
+    (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
+         exit 2;;
+    (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
+         exit 2;;
+   esac
+  done
+shift $(($OPTIND-1));
+#-
+# Treatment of the options
+#-
+# Default INTEGER and REAL precision
+case ${x_p} in
+ ( I4R4 | 4 )  x_p='I4R4'; w_ip='4'; w_rp='4';;
+ ( I4R8 | ?? ) x_p='I4R8'; w_ip='4'; w_rp='8';;
+ ( I8R8 | 8 )  x_p='I8R8'; w_ip='8'; w_rp='8';;
+ (*)
+   echo 'Invalid precision ' 1>&2;
+   echo ${x_p}' (must be I4R4, I4R8, I8R8, 4 or 8)' 1>&2;
+   exit 1;;
+esac
+#-
+# Target_Host Name
+[[ ${x_t} = '??' ]] && \
+ { x_t=$(${d_n}/w_i_h);
+   { [[ ${?} != 0 ]] && \
+      { echo "Bad installation : w_i_h/uname unreachable" 1>&2;
+        exit 1; }; } || \
+     [[ ${x_t} = "Unknown" ]] && \
+      { echo "Local_Host not supported" 1>&2; exit 1; }; }
+#-
+# Get editing header
+#x_h=$(${d_n}/w_i_p ${x_t});
+x_h=${x_t};
+#-
+[[ ! -f "${MKTG}" ]] && { echo "${MKTG} unreachable ..."; exit 3; }
+#-
+W_X1=$(sed -n -e "s/^#-Q-  *\(${x_h}\)[\t ].*$/\1/p" ${MKTG} | sort -u);
+[[ '\?'"${W_X1}" != '\?'"${x_h}" ]] && \
+  { echo "Target_Host  "${x_t}"  not supported" 1>&2; exit 1; }
+#-
+case ${x_m} in
+ ( mpi1 | mpi2 | MPI1 | MPI2 | ?? );;
+ (*) echo "MPI context "${x_m}" not supported" 1>&2; exit 1;;
+esac
+#-
+[[ ${x_v} = 'verbose' ]] && \
+ { echo "";
+   echo '--- Mode         : '${x_v};
+   echo '--- Compilation  : '${x_d};
+   echo '--- Precision    : '${x_p};
+   echo '--- Target       : '${x_t};
+   echo '--- MPI context  : '${x_m}; }
+#-
+echo "";
+echo "Installation of makefiles, scripts and data for ${x_t}";
+echo "";
+#-
+w_t='AA_make';
+#-
+if [ ${x_w} = '??' ]; then
+l_rep=$(cd ${d_n};find .. -name ${w_t} -print)
+else
+l_rep=$(cd ${d_n};find ../*/${x_w} -name ${w_t} -print)
+fi
+#-
+for i in ${l_rep}
+do
+  k=${i%/${w_t}}; k=${k#./}; j=${d_n}'/'${k}; j=${j#./};
+  echo "Installation in ${j}";
+  MKTL="${j}"'/AA_make.ldef';
+  [[ ! -f "${MKTL}" ]] && { echo "${MKTL} unreachable ..."; exit 3; }
+  MKTR="${j}"'/AA_make';
+  cat ${MKTL} ${MKTG} ${MKTR} > mk1.$$;
+  W_PR='#-Q-  *'; W_X1=${W_PR}${x_h};
+  sed -e "/^${W_X1}[\t ]/ s/^${W_X1} *//" -e "/^${W_PR}/d" mk1.$$ > mk2.$$;
+#-
+# Default INTEGER and REAL precision
+  W_PR='#-P- '; W_X1=${W_PR}${x_p};
+  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk2.$$ > mk1.$$;
+#-
+# Handle the precision module "defprec.f90" in "IOIPSL/src"
+  [[ '!!'${j##*/modeles} = '!!/IOIPSL/src' ]] && \
+   { [[ ${x_v} = 'verbose' ]] && W_X1='-v' || W_X1="";
+     ${d_n}/ins_m_prec ${W_X1} -i ${w_ip} -r ${w_rp}; r_c=${?};
+     unset w_ip w_rp;
+     [[ ${r_c} != 0 ]] && exit ${r_c}; }
+#-
+# Debug
+  W_PR='#-D- ';
+  [[ ${x_d} = 'debug' ]] && W_X1=${W_PR}'MD' || W_X1=${W_PR}'MN';
+  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$;
+#-
+# Retrieve the path of the Makefile directory
+# and the path from the directory to modipsl/util
+  mk_dir=$(cd ${j};/bin/pwd;);
+  ut_dir=''; for ww in ${k//\//' '}; do ut_dir=${ut_dir}'../'; done
+  ut_dir=${ut_dir%'../'}'util';
+  echo "Path from Makefile to modipsl/util : ${ut_dir}";
+# Update the values
+  W_X1='UTIL_DIR ='; W_X2='MAKE_DIR =';
+  sed -e "s!^${W_X1}.*!${W_X1} ${ut_dir}!" \
+      -e "s!^${W_X2}.*!${W_X2} ${mk_dir}!" \
+      mk2.$$ > mk1.$$
+  unset mk_dir ut_dir;
+#-
+# Choice of mpi library for the coupling
+  W_X1='LIB_MPI ='; W_X2='LIB_MPI_BIS =';
+  case ${x_m} in
+   ( mpi1 | MPI1 )
+    lib_mpi='MPI1'; lib_mpi_bis='MPI1';
+    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \
+        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \
+      mk1.$$ > ${j}/Makefile;;
+   ( mpi2 | MPI2 )
+    lib_mpi='MPI2'; lib_mpi_bis='';
+    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \
+        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \
+      mk1.$$ > ${j}/Makefile;;
+   (??) 
+    cp mk1.$$ ${j}/Makefile;;
+   (*) ;;
+  esac
+  unset lib_mpi lib_mpi_bis;
+#-
+done
+#-
+# Creating environment file 
+echo ${x_t} > ${d_n}/.host_target
+#-
+echo "";
+unset W_X1 W_X2 w_t; rm -f mk1.$$ mk2.$$;
+#-
+exit 0;
Index: /branches/DEV_r1837_MLF/NVTK/INSTALL/ins_nvtk.ksh
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/INSTALL/ins_nvtk.ksh	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/INSTALL/ins_nvtk.ksh	(revision 1844)
@@ -0,0 +1,233 @@
+#!/bin/ksh
+# $Id$
+######################################################
+# Original : C. Talandier for NEMO team
+# Contact  : nemo_st@locean-ipsl.upmc.fr
+#
+# This script aims to (for each standard configuration) :
+#  - I. Take into account specific files changes
+#       - ./modipsl/util/ins_make
+#       - ./modipsl/config/NAME_CONFIG/AA_make*
+#       - ./modipsl/config/NAME_CONFIG/scripts/BB_make.ldef
+#  - II. Build configuration's environment & dependencies
+#       - ./modipsl/config/NAME_CONFIG/WORK
+#       - ./modipsl/config/NAME_CONFIG/MY_SRC
+#       - ./modipsl/config/NAME_CONFIG/scripts/BB_make
+#  - III. Build results sub-directories in the OUTDIR 
+#         directory specified by user just below
+#         NEMO_VALID/WNAME_CONFIG/
+#                    |-- mon		--> MONO run
+#                    |   |-- 1_SHORT
+#                    |   |-- 2_SHORT
+#                    |   |-- LONG
+#                    |   `-- GTIME
+#                    |-- mpi		--> MPI run
+#                    |   |-- 1_SHORT
+#                    |   |-- 2_SHORT
+#                    |   |-- LONG
+#                    |   `-- GTIME
+#                    `-- omp		--> Open-MP run
+#                        |-- 1_SHORT
+#                        |-- 2_SHORT
+#                        |-- LONG
+#                        `-- GTIME
+#
+#  - IV. Modify lance_batch.ksh & assessment.ksh scripts
+#  - V. Preliminary compilations
+######################################################
+
+#set -xv
+
+##########################################################
+##### Begin Users modifications
+##########################################################
+# OUTDIR : working directory from which jobs will be launched 
+#          & results stored
+# INPUTD : directory where to get ORCA2_LIM_nemo_v2.tar 
+# REFDAT : directory where to get results from reference tags
+# MAIL   : give your e-mail
+# UAGRIF : one of the standard configurations is based on AGRIF yes/no
+##########################################################
+OUTDIR=/Users/ctlod/WORK/AZE/modipsl/config
+INPUTD=/u/rech/eee/reee831/IO_NEMO_ORCA2_LIM
+REFDAT=/u/rech/eee/reee831/NEMO_VALIDATION
+MAIL="ctlod@locean-ipsl.upmc.fr"
+UAGRIF=yes
+##########################################################
+##### End   Users modifications
+##########################################################
+
+
+# Standard configurations
+NBCFG=7
+CONF[0]=ORCA2_LIM
+CONF[1]=ORCA2_LIM3
+CONF[2]=GYRE
+CONF[3]=GYRE_LOBSTER
+CONF[4]=ORCA2_LIM_PISCES
+CONF[5]=ORCA2_OFF_PISCES
+CONF[6]=ZAGRIF
+LCLDIR=`pwd`
+
+# Use a modified modipsl script: ins_make
+# which allows to build Makefiles of a specific configuration
+# using the following syntax: ins_make -w NAME_CONF
+cp ./MODIPSL_FILES/ins_make ../../../util/.
+
+# Get the current target name
+LOCTARG=`../../../util/w_i_h`
+
+# Set following variable in AA_make.ldef script And master Makefile
+# - WWDIR = directory where to store results and jobs
+CAR_WORK_tmp=$( grep 'WWDIR=' ./CONFIG_FILES/AA_make.ldef )
+CAR_WORK=`echo $CAR_WORK_tmp | cut -f 1 -d " " `
+CAR_TARG_tmp=$( grep 'HPCTAR=' ./CONFIG_FILES/AA_make.ldef )
+CAR_TARG=`echo $CAR_TARG_tmp`
+sed -e "s?${CAR_WORK}?WWDIR=${OUTDIR}?" -e "s?${CAR_TARG}?HPCTAR=${LOCTARG}?" \
+       ./CONFIG_FILES/AA_make.ldef > ./CONFIG_FILES/AA_make.ldef.$$ 
+mv ./CONFIG_FILES/AA_make.ldef.$$  ./CONFIG_FILES/AA_make.ldef && rm -f ./CONFIG_FILES/AA_make.ldef.$$
+
+sed -e "s?DELFIL?${OUTDIR}?" ../Makefile > ../Makefile.$$ 
+mv ../Makefile.$$  ../Makefile && rm -f ../Makefile.$$
+
+# Loop over each standard configuration
+# #####################################
+ind=0
+while [ $ind -lt ${NBCFG} ]
+do
+       # I. Take into account specific changes
+       # #####################################
+       # Set following variables in job_NAME_CONF.ksh script
+       # - MAINDIR = directory where to get namelist input files
+       # - WORK    = directory where to store results
+       # - REF_OD  = directory where Are stored results from previous tags
+       cd ../../../.. ; NAME_ARCH=$( pwd ) ;
+       cd ${LCLDIR}
+       echo ${NAME_ARCH}
+       CAR_MAIN_tmp=$( grep 'MAINDIR=' ./JOBS/job_${CONF[${ind}]}.ksh )
+       CAR_MAIN=`echo $CAR_MAIN_tmp | cut -f 1 -d " " `
+       CAR_WORK_tmp=$( grep 'WORK=' ./JOBS/job_${CONF[${ind}]}.ksh )
+       CAR_WORK=`echo $CAR_WORK_tmp | cut -f 1 -d " " `
+       CAR_REFO_tmp=$( grep 'REF_OD=' ./JOBS/job_${CONF[${ind}]}.ksh  | head -1 )
+       CAR_REFO=`echo $CAR_REFO_tmp | cut -f 1 -d " " `
+       sed -e "s?${CAR_MAIN}?MAINDIR=${NAME_ARCH}?" -e "s?${CAR_WORK}?WORK=${OUTDIR}?" \
+       -e "s?${CAR_REFO}?REF_OD=${REFDAT}?" ./JOBS/job_${CONF[${ind}]}.ksh > ./JOBS/job_tmp.$$
+       mv ./JOBS/job_tmp.$$  ./JOBS/job_${CONF[${ind}]}.ksh && rm -f ./JOBS/job_tmp.$$
+
+       # II. Build configuration environment
+       # ###################################
+       (cd ../ ; ./use_cfg -n ${CONF[${ind}]} ;)
+echo '			'
+echo '	     >>>>>>>>   Configuration directories have been built:'
+echo "			./config/${CONF[${ind}]}/WORK"
+echo "			./config/${CONF[${ind}]}/MY_SRC"
+echo '			'
+
+       cp ./CONFIG_FILES/AA_make* ../../${CONF[${ind}]}/.
+       cp ./CONFIG_FILES/BB_make.ldef_${CONF[${ind}]} ../../${CONF[${ind}]}/scripts/BB_make.ldef
+
+       # Configuration dependencies
+       (cd ../../${CONF[${ind}]} ; ../NVTK/fait_AA_make ; )
+echo '                  '
+echo "             >>>>>>>>   Dependencies file ./config/${CONF[${ind}]}/BB_make have been re-built"
+
+       # III. Build output sub-directories
+       # #################################
+       # Directories from where Jobs will be launched 
+       # and where results will be stored before analysed
+       cd ${OUTDIR}
+       if [ ! -d 'NEMO_VALID' ] ;  then
+           mkdir  NEMO_VALID
+       fi
+       cd NEMO_VALID
+       mkdir -p W${CONF[${ind}]}/infos/inter
+       mkdir -p W${CONF[${ind}]}/mon/LONG
+       mkdir -p W${CONF[${ind}]}/mon/GTIME
+       mkdir -p W${CONF[${ind}]}/mon/1_SHORT
+       mkdir -p W${CONF[${ind}]}/mon/2_SHORT
+       #
+       mkdir -p W${CONF[${ind}]}/mpi/LONG
+       mkdir -p W${CONF[${ind}]}/mpi/GTIME
+       mkdir -p W${CONF[${ind}]}/mpi/1_SHORT
+       mkdir -p W${CONF[${ind}]}/mpi/2_SHORT
+       #
+       mkdir -p W${CONF[${ind}]}/omp/LONG
+       mkdir -p W${CONF[${ind}]}/omp/GTIME
+       mkdir -p W${CONF[${ind}]}/omp/1_SHORT
+       mkdir -p W${CONF[${ind}]}/omp/2_SHORT
+       #
+echo '			'
+echo '	     >>>>>>>>   The following sub-directories have been built '
+echo '                        under main directory '$( pwd )
+echo '			They are dedicated to store results'
+       find W${CONF[${ind}]} -type d
+echo '			'
+
+       cd ${LCLDIR}
+
+       let ind=$ind+1
+done
+
+
+# IV. Modify lance_batch.ksh & assessment.ksh scripts
+# ###################################################
+# Set following variables in lance_batch.ksh script
+# - IODIR = directory where to get ORCA2_LIM_nemo_v2.tar
+# - PRC   = total number of processors which will be used
+
+CAR_INPU_tmp=$( grep 'IODIR=' ./JOBS/lance_batch.ksh )
+CAR_INPU=`echo $CAR_INPU_tmp | cut -f 1 -d " " `
+CAR_TARG_tmp=$( grep 'TARGET=' ./JOBS/lance_batch.ksh | head -1)
+CAR_TARG=`echo $CAR_TARG_tmp | cut -f 1 -d " " `
+sed -e "s?${CAR_INPU}?IODIR=${INPUTD}?" -e "s/${CAR_TARG}/TARGET=${LOCTARG}/" \
+./JOBS/lance_batch.ksh > ./JOBS/lance_batch.$$
+mv ./JOBS/lance_batch.$$  ./JOBS/lance_batch.ksh && rm -f ./JOBS/lance_batch.$$
+chmod 744 ./JOBS/lance_batch.ksh
+
+# Set following variables in assessment.ksh script
+# - TARGET = the current plateform 
+# - MAIL   = your e-mail
+CAR_TARG_tmp=$( grep 'TARGET=' ./JOBS/assessment.ksh )
+CAR_TARG=`echo $CAR_TARG_tmp | cut -f 1 -d " " `
+CAR_MAIL_tmp=$( grep 'EMAIL=' ./JOBS/assessment.ksh )
+CAR_MAIL=`echo $CAR_MAIL_tmp | cut -f 1 -d " " `
+sed -e "s/${CAR_TARG}/TARGET=${LOCTARG}/" -e "s/${CAR_MAIL}/EMAIL='${MAIL}'/" \
+./JOBS/assessment.ksh > ./JOBS/assessment.$$
+mv ./JOBS/assessment.$$  ./JOBS/assessment.ksh && rm -f ./JOBS/assessment.$$
+chmod 744 ./JOBS/assessment.ksh
+
+# V. Preliminary compilations
+# ###########################
+
+# IOIPSL compilation
+../../../util/ins_make -w IOIPSL
+if [ ${LOCTARG} = 'sx8brodie' -o ${LOCTARG} = 'sx8mercure' ] ; then
+    (cd ../../../modeles/IOIPSL/src ; sxgmake ;)
+else
+    (cd ../../../modeles/IOIPSL/src ; gmake ;)
+fi
+echo '			'
+echo '	     >>>>>>>>   IOIPSL Makefile and compilation done'
+echo '			'
+
+# AGRIF compilation
+if [ ${UAGRIF} = 'yes' ] ;  then
+    ../../../util/ins_make -w AGRIF
+    (cd ../../../modeles/AGRIF/ ; gmake ;)
+    echo '			'
+    echo '			AGRIF Makefile and compilation done'
+    echo '			'
+fi
+
+
+echo '			'
+echo '			#############################################################'
+echo '             >>>>>>>>   Following configuration(s) can be used with NVTK:'
+ind=0
+while [ $ind -lt ${NBCFG} ]
+do
+echo "                        # ${CONF[${ind}]}"
+let ind=$ind+1
+done
+echo '			###########################################################'
+echo '			'
Index: /branches/DEV_r1837_MLF/NVTK/Makefile
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/Makefile	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/Makefile	(revision 1844)
@@ -0,0 +1,228 @@
+# $Id$
+#####################################################################
+# Author : Claude Talandier for NEMO team
+# Contact : nemo_st@locean-ipsl.upmc.fr
+#
+# VARS TO SET: 12 + 1 (optional)
+#     - NAM_V             : name of the current test (associated to the same directory name)
+#     - LISTE_CONF        : configurations name (ORCA2_LIM, GYRE ...)
+#     - JOBS_2LAUN        : jobs to launch (nojob, all, long, short or gtime)
+#     - BUILD_MAKE        : run type (mon, mpi ... )
+#     - MPI_I             : i- MPI decomposition
+#     - MPI_J             : j- MPI decomposition
+#     - MPIIJ             : Total number of processors
+#     - MAK_TIME          : to perform a CPU time check use keyword: 'timing' or 'notiming'
+#     - USE_IOMPUT        : use or not the new I/O interface
+#     - USE_IOSERVER      : use the I/O interface using the server possibility
+#     - NB_PROCS_IOSERVER : number of processors dedicated to the I/O server
+#     - MAK_MEMO          : to perform a memory check use keyword: 'memo' or 'nomemo'
+#     - REF_TAGV          : (optional) tag/experience name. If specified, 
+#                           current results will be compare to the results 
+#                           of this tag/experience (for a given configuration and run type)
+#
+# WORK: Allows to launch all the validation process, i.e. 
+#     I.   to build dependencies use: > gmake -s dep
+#     II.  to launch compilation,simulation,final report use: > gmake
+#     III. to remove NetCDF output files of the NAM_V experience use: > gmake delf
+#
+#####################################################################
+SHELL = /bin/ksh
+#####################################################################
+##### Begin Users modifications
+#####################################################################
+#-
+#- Name of the test
+NAM_V = 2TEST
+#-
+#- Configurations list which must be tested
+LISTE_CONF = GYRE GYRE_LOBSTER ORCA2_LIM ORCA2_LIM3 ORCA2_LIM_PISCES ORCA2_OFF_PISCES
+#-
+#- Jobs to launch use keyword: nojob, all, long, short or gtime
+JOBS_2LAUN = all
+#-
+#- Compilation list type to perform, mon (mono) &/or mpi &/or omp (Open-MP)
+BUILD_MAKE = mon mpi
+#-
+#- MPI decomposition
+MPI_I=2
+MPI_J=4
+MPIIJ=8
+#-
+#- Do we use the new io interface (iom_put)? With the io_server? On how many procs?
+USE_IOMPUT = false
+USE_IOSERVER = false
+NB_PROCS_IOSERVER = 1
+#-
+#- Proceed to a timing, use keyword: 'timing' or 'notiming'
+MAK_TIME = notiming
+#-
+#- Proceed to a memory check, use keyword: 'memo' or 'nomemo'
+MAK_MEMO = memo
+#-
+#- Experience name or reference Tag name (nemo_v2, nemo_v2_3 or nemo_v3)
+REF_TAGV = nemo_v3
+#-
+#####################################################################
+##### End Users modifications
+#####################################################################
+
+##
+all: $(LISTE_CONF)
+	@echo '      '
+	@echo '             ----->>>>>>>>>   Compilation process ended for configuration(s) :' $(LISTE_CONF)
+	@echo '      '
+
+#- Make good links & launch the compilation process
+$(LISTE_CONF): 
+	@echo 
+	@echo "CONFIGURATION :" $@
+	@( if [ ! -d ${NAM_V} ] ; then mkdir ${NAM_V} ;  fi ; )
+	@( cd ${NAM_V} ; MYREP_LIST=`( ls *.[Ffh]90 )` ; cd ../../$@/MY_SRC ; rm -rf *.[Ffh]90 ; \
+        if [ -n "$$MYREP_LIST" ] ; then ln -sf ../../NVTK/${NAM_V}/*.[Ffh]90 . ; fi ; )
+	@echo "test=" $(NAM_V)                               >  DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo "runs=" $(BUILD_MAKE)                          >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo "mpis=" $(MPI_I) $(MPI_J) $(MPIIJ)             >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo "time=" $(MAK_TIME)                            >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo "memo=" $(MAK_MEMO)                            >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo "tagname=" $(REF_TAGV)                         >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo `svn info ../../modeles/NEMO | grep URL`       >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@echo `svn info ../../modeles/NEMO | grep Revision ` >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt
+	@( cd ${NAM_V} ; LSFILES=`( ls *.[Ffh]90 )` ; if [ -n "$$LSFILES" ] ; then \
+        echo $$LSFILES >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt ; else \
+        echo "  " >> DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt ; fi ; )
+	@echo 
+	@echo '             ----->>>>>>>>>   Links from NVTK/'${NAM_V} ' to '$@/MY_SRC 'done'
+	@echo 
+	@echo '                              Build the Makefile for' $@ 'configuration'
+	@../../util/ins_make -w $@
+ifeq ($(USE_IOMPUT),true)
+	@../../util/ins_make -w XMLF90
+	@../../util/ins_make -w XMLIO_SERVER
+endif
+	@( cd ../$@/WORK ; grep P_P Makefile | head -1 > $$ ; LSCPPKEY=`( cut -c,6- $$ )` ; \
+          rm -f $$ ; if [ -n "$$LSCPPKEY" ] ; then echo $$LSCPPKEY >> \
+          DELFIL/NEMO_VALID/W$@/infos/specifs_$(NAM_V).txt ; fi ; )
+	@echo
+	@echo
+	@gmake -C ../$@ RUN='$(BUILD_MAKE)' MPI_I=$(MPI_I) MPI_J=$(MPI_J) MPIIJ=$(MPIIJ) JOB=$(JOBS_2LAUN) RTG=$(REF_TAGV) MKTE=$(MAK_TIME) MKMO=$(MAK_MEMO) REXP=$(NAM_V) USE_IOMPUT=$(USE_IOMPUT) USE_IOSERVER=$(USE_IOSERVER) NB_PROCS_IOSERVER=$(NB_PROCS_IOSERVER) > $@_step.txt
+
+#- Rebuild dependencies when new cpp key and/or new module used
+dep: clear
+	@for conf in ${LISTE_CONF}; do \
+	    echo ; \
+	    echo ; \
+	    echo ; \
+	    echo '             ----->>>>>>>>> Rebuild dependencies for the' $$conf 'configuration' ; \
+	    echo ; \
+	    echo '                          > Build links from NVTK/'${NAM_V} ' to '$$conf'/MY_SRC directory :' ; \
+	    echo ; \
+	    cd ${NAM_V} ; \
+	    MYREP_LIST=`( ls *.[Ffh]90 )` ; \
+            cd ../../$$conf/MY_SRC ; rm -rf *.[Ffh]90 ; \
+            if [ -n "$$MYREP_LIST" ] ; \
+            then for F in $$MYREP_LIST; do \
+            echo "                             # link from NVTK/"${NAM_V} "to "$$conf"/MY_SRC/$$F" ; \
+                   ln -sf  ../../NVTK/${NAM_V}/$$F . ; \
+                done ; fi ; \
+	    echo ; \
+	    echo ; \
+	    echo '                          > Rebuild links in the '$$conf'/WORK directory:' ; \
+	    echo ; \
+            cd ../WORK ; \
+	    rm -rf `ls | fgrep -v -f .patron` ; \
+	    check=`grep OPA_SRC .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use OPA_SRC component files"                ; \
+	        ln -sf ../../../modeles/NEMO/OPA_SRC/*.[Ffh]90          . ; \
+	        ln -sf ../../../modeles/NEMO/OPA_SRC/*/*.[Ffh]90      . ; \
+            fi ; \
+	    check=`grep LIM_SRC_2 .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use LIM_SRC_2 component files"                ; \
+                ln -sf ../../../modeles/NEMO/LIM_SRC_2/*.[Ffh]90          . ; \
+            fi ; \
+	    check=`grep LIM_SRC_3 .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use LIM_SRC_3 component files"                ; \
+                ln -sf ../../../modeles/NEMO/LIM_SRC_3/*.[Ffh]90          . ; \
+            fi ; \
+	    check=`grep NST_SRC .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use NST_SRC component files"                ; \
+                \rm -rf agrif_opa_interp.F90           ; \
+                \rm -rf agrif_opa_sponge.F90           ; \
+                \rm -rf agrif_opa_update.F90           ; \
+                \rm -rf agrif_top_interp.F90           ; \
+                \rm -rf agrif_top_sponge.F90           ; \
+                \rm -rf agrif_top_update.F90           ; \
+                ln -sf ../../../modeles/NEMO/NST_SRC/*.[Ffh]90      .     ; \
+            fi ; \
+	    check=`grep C1D_SRC .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use C1D_SRC component files"                ; \
+                ln -sf ../../../modeles/NEMO/C1D_SRC/*.[Ffh]90          . ; \
+            fi ; \
+	    check=`grep TOP_SRC .config`              ; \
+	    if [ -n "$$check" ] ; then  \
+	        echo "                             # use TOP_SRC component files"                ; \
+                ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh]90          . ; \
+                ln -sf ../../../modeles/NEMO/TOP_SRC/*/*.[Ffh]90      . ; \
+            fi ; \
+	    check=`grep OFF_SRC .config`              ; \
+	    if [ -n "$$check" ] ; then                   \
+	        echo "                             # use OFF_SRC component files"                ; \
+                ln -sf ../../../modeles/NEMO/OFF_SRC/*.[Ffh]90          . ; \
+                ln -sf ../../../modeles/NEMO/OFF_SRC/*/*.[Ffh]90        . ; \
+            fi ; \
+	    mn=`awk '{ print $$1 }' .config `  ; \
+            myrep=../../../config/$$mn/MY_SRC ; \
+	    echo "                             # use MY_SRC component files"                ; \
+            for i in `ls $$myrep` ; do \
+              [ -f $$i ] && \rm -rf $$i ;\
+            done ; \
+            cd $$myrep ; \
+            myrep_list=`( ls *.[Ffh]90 )` ; \
+            cd ../WORK ; \
+            if [ -n "$$myrep_list" ] ; then \
+                for F in $$myrep_list; do \
+                   ln -sf  $$myrep/$$F . ; \
+                done ; \
+            fi ; \
+            cd .. ; ../NVTK/fait_AA_make ; \
+            cd WORK ; \
+            ls -1 | fgrep -v -f .patron >tmplist ; \
+            cp tmplist SRC_FILE_LIST.temp ; \
+	    echo ; \
+	    echo "                             #################################" ;\
+	    echo "                             Dependencies for" $$conf "ready" ;\
+	    echo "                             #################################" ;\
+	    echo ;\
+            cd ../../NVTK ; \
+        done 
+	@echo
+	@echo "                             ##################################################" 
+	@echo "                             Launch the compilation and job process using gmake" 
+	@echo "                             ##################################################"
+	@echo
+
+clear :
+	@echo
+	@echo 
+	@clear 
+
+#- Delete NetCDF files for a given experience to save memory 
+delf: 
+	@for conf in ${LISTE_CONF}; do \
+	    echo ; \
+	    echo ; \
+	    echo ; \
+	    echo '             ----->>>>>>>>> Remove all' $$conf '*.nc output files for the' ${NAM_V} 'experience' ; \
+	    echo ; \
+	    echo ; \
+	    for typer in ${BUILD_MAKE}; do \
+	        rm -f DELFIL/NEMO_VALID/W$$conf/$$typer/LONG/${NAM_V}/*.nc     ; \
+	        rm -f DELFIL/NEMO_VALID/W$$conf/$$typer/1_SHORT/${NAM_V}/*.nc  ; \
+	        rm -f DELFIL/NEMO_VALID/W$$conf/$$typer/2_SHORT/${NAM_V}/*.nc  ; \
+		rm -f DELFIL/NEMO_VALID/W$$conf/$$typer/GTIME/${NAM_V}/*.nc    ; \
+	    done ; \
+	done 
Index: /branches/DEV_r1837_MLF/NVTK/cfg.txt
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/cfg.txt	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/cfg.txt	(revision 1844)
@@ -0,0 +1,7 @@
+ORCA2_LIM OPA_SRC LIM_SRC_2 C1D_SRC NST_SRC
+ORCA2_LIM3 OPA_SRC LIM_SRC_3 C1D_SRC NST_SRC
+GYRE OPA_SRC LIM_SRC_2 C1D_SRC
+ZAGRIF OPA_SRC LIM_SRC_2 C1D_SRC NST_SRC
+GYRE_LOBSTER OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+ORCA2_LIM_PISCES OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+ORCA2_OFF_PISCES OFF_SRC TOP_SRC
Index: /branches/DEV_r1837_MLF/NVTK/fait_AA_make
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/fait_AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/fait_AA_make	(revision 1844)
@@ -0,0 +1,642 @@
+#!/bin/ksh
+# $Id$
+##set -vx
+############################################################
+#
+# Purpose :
+# This script aims to create create the AA_make file
+# in the WORK directory. 
+# AA_make contains :
+#    - compilation options speccific to NEMO
+#    - compilation rules
+#    - dependancies
+# Running the modipsl/util/ins_make command is needed AFTER
+# fait_AA_make.
+#
+# Method :
+# We use temporary files to perform the following steps :
+#    1- search all CPP keys in the code
+#    2- write compilation rules 
+#    3- add compilation options add the beginning of AA_make 
+#    4- search and write dependancies
+#    5- add some specific rules (links creation in the WORK)
+#
+############################################################
+#-
+echo "This script must be run from the ../modipsl/config/CONFIG_NAME directory"
+echo ""
+
+#- Save the previous BB_make file before its rebuild
+echo "Save the previous BB_make file before its rebuild"
+cp scripts/BB_make scripts/BB_make_save
+
+#- Start the BB_make rebuild step
+echo "Start the BB_make rebuild step"
+
+cd WORK
+pwd
+
+# Test version of echo
+stringtest=`echo "\c"`
+if [ "$stringtest" ]; then
+   echo 'aliasing echo with /bin/echo -e ...'
+   alias echo='echo -e'
+fi
+
+#-
+#- Search CPP keys ---
+liste_cle=$(egrep '^# *if[!( &]*def|^# *elif' *.[Fh] *.[Fh]90  2> /dev/null | grep key_ | sed 's/||/\
+/' | sed 's/\&\&/\
+/' | sed 's/^.*key_/key_/' | sed 's/ *[) ] *$//' | sort -u  )
+
+#-
+#- Write main compilation rules ---
+cat > tampon <<end
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all :	diroce libioipsl key keyverif src_file_list libioserver libagrif \$(IOIPSL_LIB) \$(AGRIF_LIB)
+		@echo --------------------------------------------
+		time gmake \$(EXEC_BIN) -j \$(NBPRC)
+		@echo --------------------------------------------
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+
+# Cleaning objects, libraries and executables
+clean:
+ifeq (\$(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		\$(RM) model.o \$(EXEC_BIN)
+		\$(RM) \$(MODDIR)/oce_\$(NEMOLIB)/\$(COMP)/*.mod
+		\$(RM) \$(MODEL_LIB)/*.o
+		\$(RM) ../../../tmp/tmp_\$(NEMOLIB)/\$(COMP)/* 
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce_\$(NEMOLIB) ] ; then mkdir ../../../lib/oce_\$(NEMOLIB) ; fi
+		@if [ ! -d ../../../tmp/tmp_\$(NEMOLIB) ] ; then mkdir ../../../tmp/tmp_\$(NEMOLIB) ; fi
+		@if [ ! -d ../../../lib/oce_\$(NEMOLIB)/\$(COMP) ] ; then mkdir ../../../lib/oce_\$(NEMOLIB)/\$(COMP) ; fi
+		@if [ ! -d ../../../tmp/tmp_\$(NEMOLIB)/\$(COMP) ] ; then mkdir ../../../tmp/tmp_\$(NEMOLIB)/\$(COMP) ; fi
+
+\$(EXEC_BIN) :	 \$(MODEL_LIB) agrif2model.o model.o
+ifeq (\$(AGRIF),use)
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o agrif2model.o \$(MODEL_LIB)/*.o \$(OASISMPI2_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) \$(NCDF_LIB) \$(USER_LIB) \$(LIBMPI) \$(LIBMP)
+else
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o \$(MODEL_LIB)/*.o \$(OASISMPI2_LIB) \$(IOIPSL_LIB) \$(NCDF_LIB) \$(USER_LIB) \$(LIBMPI) \$(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq (\$(IOSERVER),use)
+ifeq (\$(FCM),use)
+	(cd ../../../modeles/XMLF90; ./configure -arch \$(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../../modeles/XMLIO_SERVER; ./configure -arch \$(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../../modeles/XMLF90/external ; \$(M_K) -f Makefile )
+	(cd ../../../modeles/XMLIO_SERVER/external ; \$(M_K) -f Makefile P_P="\$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif : firstagrif mpiagrif
+ifeq (\$(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../../modeles/AGRIF ; \$(M_K) -f Makefile P_P="\$(AGRIF_MPI)" )
+	@cp -rf ../../../modeles/AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../../modeles/AGRIF/conv OPAFILES/. 
+	@cp -rf ../../../modeles/AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq (\$(AGRIF),use)
+	@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+	@\$(F_C) \\
+#-Q- aix6		-qsuffix=f=F90 \\
+#-Q- babel		-qsuffix=f=F90 \\
+#-Q- osxxlf		-qsuffix=f=F90 \\
+	\$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+	   OPAFILES/\$*.F90 || { mv \$(PREF).L \$(TMP) ; false ; exit ; }
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../../modeles/IOIPSL/src ; \$(M_K) -f Makefile )
+
+# Main program
+model.o :	\$(MODEL_LIB) model.f90
+		@\$(F_C) \$(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : \$(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : \$(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : \$(SXMODEL_LIB)
+
+# library dependancies
+\$(MODEL_LIB):	\$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+\$(MODEL_LIB)/%.o : %.f90           
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.f90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+		@mv \$*.o \$(MODEL_LIB)/.
+		@\$(RM) \$*.[f]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce_\$(NEMOLIB)/\$(COMP) ; fi
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+# rules for the .F90 files
+\$(MODEL_LIB)/%.o : %.F90           
+ifeq (\$(AGRIF),use) 
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \\
+#-Q- linux		-SubloopScalar \\
+#-Q- g95			-SubloopScalar \\
+#-Q- f95			-SubloopScalar \\
+#-Q- osf1			-SubloopScalar \\
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile \$*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC OPAFILES/\$*.F90 > OPAFILES/AGRIF_MODELFILES/\$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		OPAFILES/\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; } 
+else
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+endif
+		@mv \$*.o \$(MODEL_LIB)/.
+		@\$(RM) \$*.[f]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce_\$(NEMOLIB)/\$(COMP) ; fi
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+end
+#-
+#- Compilation options ---
+exec 1> AA_make
+MAIN="model"
+echo '# some variables'
+echo 'TMP = ../../../tmp/tmp_$(NEMOLIB)/$(COMP)'
+echo ''
+echo '#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function'
+echo '#          This doesnt happen whith Fortran 90 compilers but'
+echo '#          Check your compilers option in consequence when using real F95 compilers'
+echo ''
+echo '#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) '
+echo '#-Q- platine F_O = -O3 -i4 -r8 -module $(MODEL_LIB) -I $(MODDIR) -I$(MODEL_LIB) -I$(NCDF_INC) $(USER_INC) '
+echo '#-Q- platine L_X = $(L_O) '
+echo '#-Q- sx8mercure  # Compiler options NEMO (CEA SX8-NEC) '
+echo '#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 shape=10000000 -L transform' -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sx8mercure  L_X = $(L_O)'
+echo '#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) '
+echo '#-Q- sx8brodie  F_O = -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sx8brodie  L_X = $(L_O)'
+echo '#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) '
+echo '#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sxdkrz  L_X = $(L_O) -ftrace'
+echo '#-Q- es2  # Compiler options for NEMO (Earth Simulator)'
+echo '#-Q- es2  # for super perfs!'
+echo '#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- es2  # regular options!'
+echo '#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- es2  L_X = $(L_O)'
+echo '#-Q- linux  # Compiler options for NEMO (pgf version)'
+echo '#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- linux  L_X = -r8 -O3'
+echo '#-Q- lxiv7  # Compiler options for NEMO (ifc version)'
+echo '#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- lxiv7  L_X = -r8 -O3'
+echo '#-Q- lxiv8  # Compiler options for NEMO (ifort version)'
+echo '#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- lxiv8  L_X = -r8 -O3'
+echo '#-Q- g95  # Compiler options for NEMO (g95 version)'
+echo '#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- g95  L_X = -r8 -O3'
+echo '#-Q- gfortran  # Compiler options for NEMO (gfortran version)'
+echo '#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- gfortran  L_X = -fdefault-real-8'
+echo '#-Q- aix6  # Compiler options for NEMO (aix6 version)'
+echo '#-Q- aix6  F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- aix6  L_O = $(F_P) -q64 -O3'
+echo '#-Q- aix6  L_X = $(L_O)'
+echo '#-Q- babel  # Compiler options for NEMO (blue gene version)'
+echo '#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- babel  L_X = $(L_O)'
+echo '#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)'
+echo '#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODEL_LIB) -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- osxxlf    L_X = -qrealsize=8 -O3'
+
+echo 'PREF='
+echo '#-Q- sx8mercure	PREF=i.'
+echo '#-Q- sx8brodie	PREF=i.'
+echo '#-Q- sxdkrz	PREF=i.'
+echo '#-Q- es2	PREF=i.'
+echo ''
+echo '#Run type: mon, mpi or omp '
+echo 'ifeq ($(COMP),mon)'
+echo '#-Q- osxxlf  override F_C = xlf90 -c'
+echo '#-Q- osxxlf  override F_L = xlf90'
+echo 'endif'
+echo ''
+echo 'ifeq ($(COMP),memo)'
+echo '#-Q- sx8brodie  F_O := $(F_O) -P static'
+echo '#-Q- osxxlf     F_O := $(F_O) -qnosave'
+echo 'endif'
+echo ''
+echo 'ifeq ($(COMP),mpi)'
+echo 'P_P := $(P_P) key_mpp_mpi'
+echo '#-Q- osxxlf  override F_C = mpif90 -c'
+echo '#-Q- osxxlf  override F_L = mpif90'
+echo 'endif'
+echo ''
+echo 'ifeq ($(COMP),omp)'
+echo 'P_P := $(P_P) key_mpp_omp'
+echo '#-Q- sx8brodie F_O := $(F_O) -P auto'
+echo '#-Q- sx8brodie override F_F = $(F_O) '
+echo '#-Q- sx8brodie L_X := $(L_X) -P auto'
+echo 'endif'
+echo ''
+echo 'ifeq ($(USE_IOMPUT),true)'
+echo 'P_P := $(P_P) key_iomput'
+echo 'endif'
+echo ''
+echo '# add suffix to P_P'
+echo 'P_P := $(P_P:%=$(prefix)%)'
+echo ''
+echo '# Some tests to define variables related to Agrif compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_agrif,$(P_P)))'
+echo 'AGRIF=use'
+echo 'else'
+echo 'AGRIF=notuse'
+echo 'AGRIF_LIB='
+echo 'endif'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'AGRIF_MPI=-DAGRIF_MPI'
+echo 'else'
+echo 'AGRIF_MPI='
+echo 'endif'
+echo ''
+echo '# Some tests to define variables related to xmlioserver compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_iomput,$(P_P)))'
+echo 'IOSERVER=use'
+echo 'override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90'
+echo 'override USER_INC += -I../../../lib/libxmlio_server'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'IOSERVER_MPI='
+echo 'else'
+echo 'IOSERVER_MPI=-DNO_MPI'
+echo 'endif'
+echo 'else'
+echo 'IOSERVER=notuse'
+echo 'endif'
+echo ''
+
+echo '# A variables related to xmlioserver compilationi (fcm or AA_make)'
+echo '# Please do not change '
+echo 'override FCM += notuse'
+
+ echo ''
+# Write the cpp key list with one key by line
+echo 'KEY_LIST = \c'
+for i in ${liste_cle}
+do
+ echo "\\"
+ echo "     $i \c"
+done
+
+echo ''
+echo '# .o file list in the library'
+echo 'LIB_OBJ = \c'
+#
+# find all .f90 in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.f90  `
+do
+  bn=`basename $i .f90`
+  if [ "${bn}" != "${MAIN}" ] 
+  then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
+    echo "\\"
+    echo "		\$(MODEL_LIB)/$bn.o\c"
+  fi
+  fi
+done
+
+# find all .F90 in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.F90  `
+do
+  bn=`basename $i .F90`
+  if [ "${bn}" != "${MAIN}" ] 
+  then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
+    echo "\\"
+    echo "		\$(MODEL_LIB)/$bn.o\c"
+  fi
+  fi
+done
+
+echo ""
+
+cat tampon
+rm tampon
+#-
+#- Write all dependancies ---
+
+for fic in `ls *.f90 *.F90  *.F 2> /dev/null `
+do
+    if [ "${fic}" != "agrif2model.F90" ]
+    then
+    if [ "${fic}" != "${MAIN}.[Ff]" ]
+    then
+	i=0
+	j=0
+	dep=""
+	inc=""
+	inc2=""
+	inc3=""
+	luse0=""
+	luse1=""
+	luse2=""
+	luse3=""
+	key=""
+#- search include files (old ice model form, should it be suppressed ?)
+	for inc in `sed -n 's/^[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+	    dep="$dep\n$inc"
+	done
+
+#- take into account CPP dependancies  keys only (par_trc_trp example)
+	for key in `sed -n 's/^#[       eElL]*[iF][fF][         ]*[dD][eE][fF][iI][nN][eE][dD][         ]*//p' $fic | sort -u`
+	do
+	    j=1
+	done
+
+#- search include files on 3 levels
+	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+	    j=1
+	    dep="$dep\n$inc"
+		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
+		do
+		    dep="$dep\n$inc2"
+		    #- search include  in include (third level !!!)
+		    for inc3 in `sed -n 's/^#[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc2 | sort -u`
+		    do
+			dep="$dep\n$inc3"
+		    done
+		done
+	done
+
+#- search USE in include files
+	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+		for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc | sort -u`
+		do
+                    [ -f $fuse0.[hfF]90 ] || continue
+		    lfuse0=$fuse0.f90
+		    [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		    luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)/$fuse0.o"
+		done
+
+#- search USE in  files included in included files and add to luse0
+
+		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
+		do
+		    for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc2 | sort -u`
+		    do
+                        [ -f $fuse0.[hfF]90 ] || continue
+		        lfuse0=$fuse0.f90
+		        [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		        luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)/$fuse0.o"
+		    done
+  	        done
+	done
+
+#- search USE (and USE of USE and so on three levels)
+	for fuse1 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $fic | sort -u`
+	do
+            [ -f $fuse1.[hfF]90 ] || continue
+	    lfuse1=$fuse1.f90
+	    [ -f $fuse1.F90 ] && lfuse1=$fuse1.F90
+	    luse1="$luse1\n$lfuse1\n\$(MODEL_LIB)/$fuse1.o"
+		for fuse2 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse1 | sort -u`
+		do
+                    [ -f $fuse2.[hfF]90 ] || continue
+		    lfuse2=$fuse2.f90
+		    [ -f $fuse2.F90 ] && lfuse2=$fuse2.F90
+		    luse2="$luse2\n$lfuse2\n\$(MODEL_LIB)/$fuse2.o"
+		    # on cherche les USE  dans le fichier deja USE (3eme niveau! balaise!)
+		    for fuse3 in `sed -n 's/^#[  	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse2 | sort -u`
+		    do
+                        [ -f $fuse3.[hfF]90 ] || continue
+			luse3="$luse3\n$lfuse3\n\$(MODEL_LIB)($fuse3.o)"
+                    done
+		done
+	done
+#-
+#-  dep contains all dependancies 
+	echo "\$(MODEL_LIB)/`echo $fic|awk -F. '{print $1}'`.o :       \c"
+	for depele in `echo $luse3 | sort -u` `echo $luse2 | sort -u` `echo $luse1 | sort -u` `echo $luse0 | sort -u` `echo $dep | sort -u`
+	do
+	    echo "\\"
+ 	    echo "	$depele \c"
+ 	    let i=i+1 # pour signaler le premier
+	done
+
+#-
+#- add dependancies with IOIPSL library (if source files contains IOIPSL)
+        grep -i 'use *ioipsl' ${fic} >/dev/null && ( echo "\\" ; echo "	\$(IOIPSL_LIB) \c")
+
+#-
+#- add dependancies with IOIPSL library (if source files contains Agrif_*)
+        grep -i 'use Agrif_*' ${fic} >/dev/null && ( echo "\\" ; echo "	\$(AGRIF_LIB) \c")
+
+#-
+#- add dependancies with KEY_CPP (if source file includes cpp  keys)
+	if [ ${j} != "0" ] 
+        then 
+	  echo "\\"
+	  echo "	KEY_CPP \c" 
+	fi
+#-
+#- end with the file itself
+	     echo "\\"
+       	     echo "	$fic"
+    fi
+    fi
+echo $fic done >/dev/tty
+done
+#-
+#- Write some special rules ---
+echo '# agrif previous use'
+echo "firstagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo '	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce_$(NEMOLIB)/$(COMP)/*.mod $(SXMODEL_LIB); fi'
+echo "else"
+echo '	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce_$(NEMOLIB)/$(COMP)/*.mod $(SXMODEL_LIB); fi'
+echo "endif"
+#-
+echo '#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp'
+echo '#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC'
+echo '# recompile all in this case' 
+echo "mpiagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo "ifeq (,\$(AGRIF_MPI))"
+echo '	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce_$(NEMOLIB)/$(COMP)/*.mod $(SXMODEL_LIB); fi'
+echo "endif"
+echo "endif"
+#-
+echo '# key changing control'
+echo "key: "
+echo "	@echo CHANGE of CPP KEYS yes/no ?"
+echo "	-@if [ \"\`cat KEY_CPP\`\" != \"\$(P_P:\$(prefix)%=%)\" ] ; then \\"
+echo "		echo CPP options changed ; echo \"\$(P_P:\$(prefix)%=%)\" > KEY_CPP ; fi "
+#-
+echo '# check key values'
+echo "keyverif:"
+echo '	@echo CHECKING KEY'
+echo '	@echo KEY USED : '
+echo '	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \'
+echo '	do \'
+echo '	echo $$v ;\'
+echo '        w=`echo $$v | cut -c1-3` ; \'
+echo '        if [ $$w = `echo "key"` ] ; then \'
+echo '        r=n ; \'
+echo '        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \'
+echo '           if [ $$r != "n" ] ; then \'
+echo '              echo "UNKNOWN KEY" ;\'
+echo '              false ;  \'
+echo '              exit ;  \'
+echo '           fi \'
+echo '        fi \'
+echo '	done'
+echo '# Checking the number of routines'
+echo "src_file_list: EMPTY"
+echo '	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES '
+echo '	@$(RM) `ls | fgrep -v -f .patron` '
+echo '	@check=`grep OPA_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OPA_SRC files"                ; \'
+echo '	    ln -sf ../../../modeles/NEMO/OPA_SRC/*.[Ffh]90          . ; \'
+echo '	    ln -sf ../../../modeles/NEMO/OPA_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_2 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_2 files"                ; \'
+echo '      ln -sf ../../../modeles/NEMO/LIM_SRC_2/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_3 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_3 files"                ; \'
+echo '      ln -sf ../../../modeles/NEMO/LIM_SRC_3/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep NST_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use NST_SRC files"                ; \'
+echo '      \$(RM) agrif_opa_interp.F90           ; \'
+echo '      \$(RM) agrif_opa_sponge.F90           ; \'
+echo '      \$(RM) agrif_opa_update.F90           ; \'
+echo '      \$(RM) agrif_top_interp.F90           ; \'
+echo '      \$(RM) agrif_top_sponge.F90           ; \'
+echo '      \$(RM) agrif_top_update.F90           ; \'
+echo '      ln -sf ../../../modeles/NEMO/NST_SRC/*.[Ffh]90      .     ; \'
+echo '  fi '
+echo '	@check=`grep C1D_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use C1D_SRC files"                ; \'
+echo '      ln -sf ../../../modeles/NEMO/C1D_SRC/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep TOP_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then  \'
+echo '	echo "   use TOP_SRC files"                ; \'
+echo '      ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../../../modeles/NEMO/TOP_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep OFF_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OFF_SRC files"                ; \'
+echo '      ln -sf ../../../modeles/NEMO/OFF_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../../../modeles/NEMO/OFF_SRC/*/*.[Ffh]90        . ; \'
+echo '  fi '
+echo ' '
+echo '	@mn=`awk '"'"'{ print $$1 }'"'"' .config `  ; \'
+echo '  myrep=../../../config/$$mn/MY_SRC ; \'
+echo '  echo "*** Dealing with my modified source code, located in" $$myrep ; \'
+echo '  for i in `ls $$myrep` ; do \'
+echo '    [ -f $$i ] && \$(RM) $$i ;\'
+echo '  done ; \'
+echo '  myrep_list=`(cd $$myrep ; ls *.[Ffh]90 *.[Ffh] *.mk )` ; \'
+echo '  if [ -n "$$myrep_list" ] ; then \'
+echo '      for F in $$myrep_list; do \'
+echo '         echo "---> Reconstruct link to MY_SRC/$$F" ; \'
+echo '         ln -sf  $$myrep/$$F . ; \'
+echo '      done ; \'
+echo '  fi '
+echo ' '
+echo '	@\$(RM) tmplist'
+echo '	@ls -1 | fgrep -v -f .patron >tmplist'
+echo '	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \'
+echo '	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \'
+echo '	\$(RM) model.o \$(MODEL_LIB)/*.o  \$(EXEC_BIN) ; \'
+echo '	echo "Rebuilding the AA_make files" ; \'
+echo '	cd ..  ; ../NVTK/fait_AA_make ; echo " " ; \'
+echo '	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \'
+echo '	echo "========================================== " ; \'
+echo '	../../util/ins_make -w \$(NEMOLIB) ; echo " " ;  false ; exit ; }'
+echo "EMPTY: "
+exec > /dev/null
+
Index: /branches/DEV_r1837_MLF/NVTK/use_cfg
===================================================================
--- /branches/DEV_r1837_MLF/NVTK/use_cfg	(revision 1844)
+++ /branches/DEV_r1837_MLF/NVTK/use_cfg	(revision 1844)
@@ -0,0 +1,298 @@
+#!/bin/ksh
+# $Id$
+######################################################
+# Author : Rachid benshila for NEMO team
+# Contact : nemo_st@lodyc.jussieu.fr
+#
+# This script aims to create the OPA/WORK directory
+# and to link in the WORK the BB_make and BB_make.ldef 
+# associated  to a chosen configuration
+#
+######################################################
+d_n=$(dirname $0); b_n=$(basename $0);
+
+#set -xv
+
+#- Saisie et validation des options
+x_d="";
+x_n="";
+x_r="";
+while getopts :hld:n:r: V
+  do
+    case $V in
+      (h)  echo "Usage    : "${b_n} \
+                " [-h] [-l] [-d] [-p r] [-t h] ";
+           echo " -h      : help";
+           echo " -l      : list existing configurations";
+           echo " -n name : config name";
+           echo " -d dir  : choose directories";
+           echo "";
+           echo "Example to install a new configuration MY_CONFIG";
+           echo "with OPA_SRC and ICE_SRC ";
+           echo "use_cfg -n MY_CONFIG -d \"OPA_SRC ICE_SRC\"";
+           echo "";
+#           echo "Defaults     : ";
+           echo "";
+           exit 0;;
+      (d)  x_d=${OPTARG};;
+      (n)  x_n=${OPTARG};;
+      (r)  x_r=${OPTARG};;
+      (l)  cat ${d_n}/cfg.txt; exit;;
+      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
+           exit 2;;
+      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
+           exit 2;;
+    esac
+  done
+shift $(($OPTIND-1));
+
+#- Some tests ---
+m_n=${x_n}
+
+if [ ${#x_n} -eq 0 ]; then
+echo "Warning"
+echo "No configuration specified"
+echo "use_cfg -h for help"
+exit
+fi
+
+cat ${d_n}/cfg.txt | grep ${m_n} > ${d_n}/cfg.tmp
+read CONFIG TAB[0] TAB[1] TAB[2] TAB[3] TAB[4] TAB[5] < ${d_n}/cfg.tmp
+\rm ${d_n}/cfg.tmp
+
+if [ ${#CONFIG} -eq 0 ] ; then
+if [ ${#x_d} -eq 0 ] ; then
+
+echo "You are  installing a new configuration"
+echo -n " OPA_SRC [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[1]=OPA_SRC   
+echo " OPA_SRC selected "
+echo "  "
+    else
+echo " OPA_SRC Not selected "
+echo "  "
+    fi
+unset answer
+echo -n " LIM_SRC_2 [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[2]=LIM_SRC_2 
+echo " LIM_SRC_2 selected "
+echo "  "
+    else
+echo " LIM_SRC_2 Not selected "
+echo "  "
+    fi
+unset answer
+echo -n " LIM_SRC_3 [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[2]=LIM_SRC_3
+echo " LIM_SRC_3 selected "
+echo "  "
+    else
+echo " LIM_SRC_3 Not selected "
+echo "  "
+    fi
+unset answer
+echo -n " TOP_SRC [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[3]=TOP_SRC   
+echo " TOP_SRC selected "
+echo "  "
+    else
+echo " TOP_SRC Not selected "
+echo "  "
+    fi
+unset answer   
+echo -n " C1D_SRC [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[4]=C1D_SRC   
+echo " C1D_SRC selected "
+echo "  "
+    else
+echo " C1D_SRC Not selected "
+echo "  "
+    fi
+unset answer
+echo -n " NST_SRC [Y/n] "
+    read answer
+    answer=`echo $answer | sed 's/^[yY].*$/y/'`
+    if [  -z "$answer" -o "x$answer" = "xy" ]; then
+    TAB[5]=NST_SRC   
+echo " NST_SRC selected "
+echo "  "
+    else
+echo " NST_SRC Not selected "
+echo "  "
+    fi
+unset answer
+
+else
+set -A TAB ${x_d} 
+fi
+print ${m_n} ${TAB[*]} >> ${d_n}/cfg.txt
+fi
+
+
+#- Create the config  --
+r_cfg='ORCA2_LIM'
+if [ ${#x_r} -ne 0 ]; then
+r_cfg=${x_r}
+fi
+
+if  [ ! -d ${d_n}/../../config/${m_n} ]; then
+echo " The new configuration ${x_n} will be based on ${r_cfg} following files:"
+echo "`ls ../${r_cfg}/AA_make*` "
+echo "`ls ../${r_cfg}/scripts/BB_make*` "
+echo "`ls ../${r_cfg}/EXP00/*` "
+echo "`ls ../${r_cfg}/MY_SRC/*` "
+echo "  "
+\mkdir  ${d_n}/../../config/${m_n} 
+\mkdir  ${d_n}/../../config/${m_n}/scripts
+\mkdir  ${d_n}/../../config/${m_n}/EXP00
+\mkdir  ${d_n}/../../config/${m_n}/MY_SRC
+\cp -R ${d_n}/../../config/${r_cfg}/AA_make ${d_n}/../../config/${m_n}/. 
+\cp -R ${d_n}/../../config/${r_cfg}/AA_make.ldef ${d_n}/../../config/${m_n}/. 
+\cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make ${d_n}/../../config/${m_n}/scripts/. 
+\cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make.ldef ${d_n}/../../config/${m_n}/scripts/. 
+\cp -R ${d_n}/../../config/${r_cfg}/EXP00/* ${d_n}/../../config/${m_n}/EXP00/. 
+\cp -R ${d_n}/../../config/${r_cfg}/MY_SRC/* ${d_n}/../../config/${m_n}/MY_SRC/. 
+fi
+#- Create the WORK --
+d_m=`find ${d_n}/../.. -name ${m_n}`  ;
+[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK;
+cd ${d_m}/WORK
+
+#- Clean links and librairies
+[ -n "`\ls`" ] && \rm * 
+
+#- Find the number of directories ---
+NDIR=${#TAB[*]}
+
+#- Creating the good links, at first on OPA_SRC ---
+    echo " Creating ${m_n}/WORK = ${TAB[*]} for ${m_n}"
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*.[Ffh]90 .
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*/*.[Ffh]90 . && break
+	let i=$i+1
+    done
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+      if [ "${TAB[i]}" = "LIM_SRC_2" ]; then
+	  ln -sf ../../../modeles/NEMO/LIM_SRC_2/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "LIM_SRC_3" ]; then
+	  ln -sf ../../../modeles/NEMO/LIM_SRC_3/*.[Ffh]90 .  
+
+      elif [ "${TAB[i]}" = "TOP_SRC" ]; then
+	   ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh]90 . 
+	   ln -sf ../../../modeles/NEMO/TOP_SRC/*/*.[Ffh]90 . 
+      
+      elif [ "${TAB[i]}" = "OFF_SRC" ]; then  
+	  ln -sf ../../../modeles/NEMO/OFF_SRC/*.[Ffh]90 .
+	  ln -sf ../../../modeles/NEMO/OFF_SRC/*/*.[Ffh]90 .
+
+      elif [ "${TAB[i]}" = "C1D_SRC" ]; then  
+	  ln -sf ../../../modeles/NEMO/C1D_SRC/*.[Ffh]90 .
+
+      elif [ "${TAB[i]}" = "NST_SRC" ]; then  
+	 \rm agrif_opa_interp.F90
+	 \rm agrif_opa_sponge.F90
+	 \rm agrif_opa_update.F90
+	 \rm agrif_top_interp.F90
+	 \rm agrif_top_sponge.F90
+	 \rm agrif_top_update.F90
+	  ln -sf ../../../modeles/NEMO/NST_SRC/*.[Ffh]90 .
+      fi
+      let i=$i+1
+    done
+
+    ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; 
+    ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ;
+
+
+    if [ -d ../../../config/${m_n}/MY_SRC ]; then
+        f_list=`\ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90`  ;
+        if [ ${#f_list} -ne 0 ] ; then
+            echo " "
+            echo " Files in the ../config/${m_n}/MY_SRC directory will be taken into account"
+            echo " "
+	    for i in `ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90`
+	       do
+	       [ -f $i ] && \rm $i  
+	       [ -f ../../../config/${m_n}/MY_SRC/$i ] &&  ln -sf ../../../config/${m_n}/MY_SRC/${i} .
+	     done
+        fi
+    fi
+
+#- Building the standard list of source files ---
+cat >.patron <<"EOF" 
+CVS
+SRC_PARAM
+SRC_FILE_LIST
+tmplist
+AA_make
+KEY_CPP
+Makefile
+*?.o
+ i.?*
+*?.L
+.patron
+bloc.com
+para.com
+defcst.f
+fontbc.f
+icdyna.f
+thersf.f
+OPAFILES
+EOF
+
+[ ! -d ../../../config/${m_n}/scripts/Attic ] && \mkdir ../../../config/${m_n}/scripts/Attic
+
+#- Writing KEY_CPP file ---
+sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > ../../../config/${m_n}/scripts/Attic/KEY_CPP  
+ln -sf ../../../config/${m_n}/scripts/Attic/KEY_CPP .  
+
+#- Creating SRC list ---
+ls -1 | fgrep -v -f .patron  > ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST
+ln -sf ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST .
+cp SRC_FILE_LIST SRC_FILE_LIST.temp   
+
+#- Save new configuration and directories names ---
+print ${m_n} ${TAB[*]} >.config 
+
+#- Create repository to store modified files
+[ ! -d ../../../config/${m_n}/MY_SRC ] && \mkdir ../../../config/${m_n}/MY_SRC
+cp ../../../modeles/NEMO/OPA_SRC/par_oce.F90 ../../../config/${m_n}/MY_SRC/par_oce.F90_keep
+if [ -d ../../../config/NVTK/2TEST ]; then
+    f_2test=`\ls ../../../config/NVTK/2TEST/*.[Ffh]90`  ;
+    if [ ${#f_2test} -ne 0 ] ; then
+        echo " "
+        echo " Files in the ../config/NVTK/2TEST directory will be taken into account"
+        echo " "
+        for i in `ls ../../../config/NVTK/2TEST/*.[Ffh]90`
+          do
+             ln -sf ../../../config/NVTK/2TEST/${i} ../../../config/${m_n}/MY_SRC/.
+          done
+    fi
+fi
+
+unset m_n
+unset TAB
+unset CONFIG
+exit 0;
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/Makefile
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/Makefile	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/Makefile	(revision 1844)
@@ -0,0 +1,57 @@
+#
+# Makefile 
+#
+#---------------------------------------------------------------------
+
+EXEC_BIN1 = create_coordinates.exe
+
+NCDF_PATH= /usr/local/include
+NETCDF_LIB = -L/usr/local/lib -lnetcdf
+
+F_C = gfortran
+F_P = 
+F_O = -ffixed-line-length-132 -fdefault-real-8 -c -I$(NCDF_PATH) $(F_P) $(NETCDF_LIB)
+
+OBJSET  = \
+	agrif_types.o \
+	io_netcdf.o \
+	agrif_readwrite.o \
+ 	tools_brice.o \
+
+### Target
+all: 		$(EXEC_BIN1) 
+		@echo compilation is OK		
+
+
+### dependancies
+$(EXEC_BIN1) :	$(OBJSET) create_coordinates.o
+		$(F_C) -o $(EXEC_BIN1) create_coordinates.o $(OBJSET) $(NETCDF_LIB)
+                    			
+
+
+agrif_readwrite.o : io_netcdf.o agrif_types.o agrif_readwrite.f90
+	$(F_C)  $(F_O) agrif_readwrite.f90 
+
+create_coordinates.o : agrif_readwrite.o create_coordinates.f90
+	$(F_C)  $(F_O) create_coordinates.f90
+
+agrif_types.o : agrif_types.f90
+	$(F_C)  $(F_O) agrif_types.f90 
+
+io_netcdf.o : agrif_types.o io_netcdf.f90
+	$(F_C)  $(F_O) io_netcdf.f90
+
+tools_brice.o : agrif_types.o tools_brice.f90
+	$(F_C)  $(F_O) tools_brice.f90
+
+
+### cleaning objects, libraries and executables
+clean:
+		rm -f *.o *.mod $(EXEC_BIN1)
+		@echo \(.o .mod and executables are removed\)
+
+### execution
+exe:
+		./$(EXEC_BIN1) namelist
+		make clean
+		@echo \(OK execution\)
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_readwrite.f90
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_readwrite.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_readwrite.f90	(revision 1844)
@@ -0,0 +1,212 @@
+MODULE agrif_readwrite
+  !
+  USE agrif_types
+  !USE tools_brice
+  !
+  IMPLICIT NONE
+  !
+  !INTEGER :: nx_fine, ny_fine
+  !
+CONTAINS
+  !       
+  !*****************************************************
+  !   function Read_Coordinates(name,Grid)
+  !*****************************************************
+
+  INTEGER FUNCTION Read_Coordinates(name,Grid,Pacifique)
+    !
+    USE io_netcdf
+    !    
+    !  file name to open
+    ! 
+    CHARACTER(*) name
+    LOGICAL,OPTIONAL :: Pacifique
+    ! 
+    TYPE(Coordinates) :: Grid
+    !      
+    CALL Read_Ncdf_var('glamt',name,Grid%glamt)
+    CALL Read_Ncdf_var('glamu',name,Grid%glamu)
+    CALL Read_Ncdf_var('glamv',name,Grid%glamv)
+    CALL Read_Ncdf_var('glamf',name,Grid%glamf)
+    CALL Read_Ncdf_var('gphit',name,Grid%gphit)
+    CALL Read_Ncdf_var('gphiu',name,Grid%gphiu)
+    CALL Read_Ncdf_var('gphiv',name,Grid%gphiv)
+    CALL Read_Ncdf_var('gphif',name,Grid%gphif)
+    CALL Read_Ncdf_var('e1t',name,Grid%e1t)
+    CALL Read_Ncdf_var('e1u',name,Grid%e1u)
+    CALL Read_Ncdf_var('e1v',name,Grid%e1v)
+    CALL Read_Ncdf_var('e1f',name,Grid%e1f)
+    CALL Read_Ncdf_var('e2t',name,Grid%e2t)
+    CALL Read_Ncdf_var('e2u',name,Grid%e2u)
+    CALL Read_Ncdf_var('e2v',name,Grid%e2v)
+    CALL Read_Ncdf_var('e2f',name,Grid%e2f)
+    CALL Read_Ncdf_var('nav_lon',name,Grid%nav_lon)
+    CALL Read_Ncdf_var('nav_lat',name,Grid%nav_lat)       
+    ! 
+    IF( PRESENT(Pacifique) )THEN
+       IF ( Grid%glamt(1,1) > Grid%glamt(nxfin,nyfin) ) THEN           
+       Pacifique = .TRUE.
+       WHERE ( Grid%glamt < 0 )
+          Grid%glamt = Grid%glamt + 360.
+       END WHERE
+       WHERE ( Grid%glamf < 0 )
+          Grid%glamf = Grid%glamf + 360.
+       END WHERE
+       WHERE ( Grid%glamu < 0 )
+          Grid%glamu = Grid%glamu + 360.
+       END WHERE
+       WHERE ( Grid%glamv < 0 )
+          Grid%glamv = Grid%glamv + 360.
+       END WHERE
+       WHERE ( Grid%nav_lon < 0 )
+          Grid%nav_lon = Grid%nav_lon + 360.
+       END WHERE
+       ENDIF
+    ENDIF
+    !            
+    WRITE(*,*) ' '
+    WRITE(*,*) 'Reading coordinates file: ',name
+    WRITE(*,*) ' '
+    !      
+    Read_Coordinates = 1
+    !      
+  END FUNCTION Read_Coordinates
+
+  !*****************************************************
+  !   function Write_Coordinates(name,Grid)
+  !*****************************************************
+
+  INTEGER FUNCTION Write_Coordinates(name,Grid,nx_fine,ny_fine)
+    !
+    USE io_netcdf
+    CHARACTER(*) name
+    TYPE(Coordinates) :: Grid
+    INTEGER :: status,ncid,z
+    REAL*8,DIMENSION(:),POINTER :: tabtemp
+    INTEGER,DIMENSION(:),POINTER :: tabint
+    CHARACTER(len=20),DIMENSION(4) :: dimnames
+	INTEGER :: nx_fine, ny_fine
+    !
+    status = nf90_create(name,NF90_WRITE,ncid)
+    status = nf90_close(ncid)
+    !           
+    !CALL Write_Ncdf_dim('x',name,nxfin)
+    !CALL Write_Ncdf_dim('y',name,nyfin)
+	CALL Write_Ncdf_dim('x',name,nx_fine)
+    CALL Write_Ncdf_dim('y',name,ny_fine)
+    IF(.NOT. iom_activated) CALL Write_Ncdf_dim('z',name,1)
+    CALL Write_Ncdf_dim('time',name,0)
+    !      
+    dimnames(1)='x'
+    dimnames(2)='y'
+    CALL Write_Ncdf_var('nav_lon',dimnames(1:2),name,Grid%nav_lon,'float')      
+    CALL Write_Ncdf_var('nav_lat',dimnames(1:2),name,Grid%nav_lat,'float')
+    !
+    IF(.NOT. iom_activated) THEN
+       ! copy nav_lev variable -> IOIPSL
+       CALL Read_Ncdf_dim('z',parent_coordinate_file,z)
+       ALLOCATE(tabtemp(z))
+       CALL Read_Ncdf_var('nav_lev',TRIM(parent_coordinate_file),tabtemp)
+       CALL Write_Ncdf_var('nav_lev','z',name,tabtemp,'float')           
+       DEALLOCATE(tabtemp)
+    ENDIF
+    !
+    CALL Read_Ncdf_var('time',TRIM(parent_coordinate_file),tabtemp)
+    CALL Write_Ncdf_var('time','time',name,tabtemp,'float')           
+    DEALLOCATE(tabtemp)      
+    CALL Read_Ncdf_var('time_steps',TRIM(parent_coordinate_file),tabint)
+    CALL Write_Ncdf_var('time_steps','time',name,tabint) 
+    !      
+    dimnames(1)='x'
+    dimnames(2)='y'
+    IF(iom_activated) THEN
+       dimnames(3)='time'
+    ELSE
+       dimnames(3)='z'
+       dimnames(4)='time'
+    ENDIF
+
+    CALL Write_Ncdf_var('glamt',dimnames,name,Grid%glamt,3,'double')
+    CALL Write_Ncdf_var('glamu',dimnames,name,Grid%glamu,3,'double')
+    CALL Write_Ncdf_var('glamv',dimnames,name,Grid%glamv,3,'double')
+    CALL Write_Ncdf_var('glamf',dimnames,name,Grid%glamf,3,'double')
+    CALL Write_Ncdf_var('gphit',dimnames,name,Grid%gphit,3,'double')
+    CALL Write_Ncdf_var('gphiu',dimnames,name,Grid%gphiu,3,'double')
+    CALL Write_Ncdf_var('gphiv',dimnames,name,Grid%gphiv,3,'double')
+    CALL Write_Ncdf_var('gphif',dimnames,name,Grid%gphif,3,'double')      
+    CALL Write_Ncdf_var('e1t',dimnames,name,Grid%e1t,3,'double')      
+    CALL Write_Ncdf_var('e1u',dimnames,name,Grid%e1u,3,'double')     
+    CALL Write_Ncdf_var('e1v',dimnames,name,Grid%e1v,3,'double')      
+    CALL Write_Ncdf_var('e1f',dimnames,name,Grid%e1f,3,'double')
+    CALL Write_Ncdf_var('e2t',dimnames,name,Grid%e2t,3,'double')
+    CALL Write_Ncdf_var('e2u',dimnames,name,Grid%e2u,3,'double')
+    CALL Write_Ncdf_var('e2v',dimnames,name,Grid%e2v,3,'double')
+    CALL Write_Ncdf_var('e2f',dimnames,name,Grid%e2f,3,'double')
+    !      
+    CALL Copy_Ncdf_att('nav_lon',TRIM(parent_coordinate_file),name,&
+         MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon))
+    CALL Copy_Ncdf_att('nav_lat',TRIM(parent_coordinate_file),name,&
+         MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat))
+    CALL Copy_Ncdf_att('nav_lev',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('time',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('time_steps',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('glamt',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('glamu',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('glamv',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('glamf',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('gphit',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('gphiu',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('gphiv',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('gphif',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e1t',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e1u',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e1v',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e1f',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e2t',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e2u',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e2v',TRIM(parent_coordinate_file),name)
+    CALL Copy_Ncdf_att('e2f',TRIM(parent_coordinate_file),name)            
+    !
+    WRITE(*,*) ' '
+    WRITE(*,*) 'Writing coordinates file: ',name
+    IF(.NOT. iom_activated) WRITE(*,*) 'IOISPL format'
+    IF(iom_activated) WRITE(*,*) 'IOM format'      
+    WRITE(*,*) ' '
+    !
+    Write_Coordinates = 1
+    !      
+  END FUNCTION Write_Coordinates
+  !
+  !
+  !*****************************************************
+  !   function set_child_name(Parentname,Childname)
+  !*****************************************************
+  !
+  SUBROUTINE set_child_name(Parentname,Childname)
+    !
+    CHARACTER(*),INTENT(in) :: Parentname
+    CHARACTER(*),INTENT(out) :: Childname
+    CHARACTER(2) :: prefix
+    INTEGER :: pos
+    !   
+    pos  = INDEX(TRIM(Parentname),'/',back=.TRUE.)
+    !
+    prefix=Parentname(pos+1:pos+2)
+    IF (prefix == '1_') THEN
+       Childname = '2_'//Parentname(pos+3:LEN(Parentname)) 
+    ELSEIF (prefix == '2_') THEN
+       Childname = '3_'//Parentname(pos+3:LEN(Parentname)) 
+    ELSEIF (prefix == '3_') THEN
+       Childname = '4_'//Parentname(pos+3:LEN(Parentname)) 
+    ELSEIF (prefix == '4_') THEN
+       Childname = '5_'//Parentname(pos+3:LEN(Parentname)) 
+    ELSE
+       Childname = '1_'//Parentname(pos+1:LEN(Parentname)) 
+    ENDIF
+    !   
+  END SUBROUTINE set_child_name
+  !
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!             
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+END MODULE agrif_readwrite
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_types.f90
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_types.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/agrif_types.f90	(revision 1844)
@@ -0,0 +1,274 @@
+!      
+MODULE agrif_types
+  !
+  PUBLIC
+  !   
+  !*****************************
+  ! Coordinates type definition 
+  !*****************************
+  TYPE Coordinates
+     !
+     REAL*8, DIMENSION(:,:), POINTER :: nav_lon,nav_lat => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: glamv, glamu, glamt, glamf => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: gphit, gphiu, gphiv, gphif => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: e1t, e1u, e1v, e1f => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: e2t, e2u, e2v, e2f => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: bathy_level => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: bathy_meter => NULL()
+     REAL*8, DIMENSION(:,:,:),POINTER :: fmask,umask,vmask,tmask => NULL()
+     REAL*8, DIMENSION(:,:,:),POINTER :: e3t_ps,e3w_ps,gdept_ps,gdepwps => NULL()
+     REAL*8, DIMENSION(:,:),POINTER :: gdepw_ps => NULL()
+     REAL*8, DIMENSION(:), POINTER :: gdeptht => NULL()
+     INTEGER, DIMENSION(:) , POINTER :: time_steps => NULL()
+     !     
+  END TYPE Coordinates
+  !
+  !
+  !
+  TYPE mixed_coordinates
+   !
+     REAL*8, DIMENSION(:,:), POINTER :: nav_lon,nav_lat => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: glam => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: gphi => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: e1 => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: e2 => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: bathy_level => NULL()
+     REAL*8, DIMENSION(:,:), POINTER :: bathy_meter => NULL()
+     REAL*8, DIMENSION(:,:,:),POINTER :: fmask,umask,vmask,tmask => NULL()
+     REAL*8, DIMENSION(:,:,:),POINTER :: e3t_ps,e3w_ps,gdept_ps,gdepwps => NULL()
+     REAL*8, DIMENSION(:,:),POINTER :: gdepw_ps => NULL()
+     REAL*8, DIMENSION(:), POINTER :: gdeptht => NULL()
+     INTEGER, DIMENSION(:) , POINTER :: time_steps => NULL()
+     !     
+  END TYPE mixed_coordinates
+  !
+  !
+  !
+  CHARACTER*8,DIMENSION(10) :: flxtab = (/'socliot1','socliot2','socliopl',&
+       'socliocl','socliohu','socliowi','soshfldo','sohefldo','sowaflup','sofbt   '/)
+  !
+  !
+  !**************************************************************
+  ! Declaration of various input file variables (namelist.input) 
+  !**************************************************************
+  !
+  INTEGER irafx,irafy
+  INTEGER nxfin,nyfin
+  INTEGER, PARAMETER :: nbghostcellsfine = 2
+  INTEGER, PARAMETER :: nbghostcellscoarse = 1
+  !      
+  INTEGER imin,jmin,imax,jmax,rho,rhot
+  INTEGER shlat
+  INTEGER N,type_bathy_interp
+  ! 
+  INTEGER jpizoom,jpjzoom,nb_connection_pts
+  !      
+  REAL*8 ppacr,ppdzmin,pphmax,ppkth,smoothing_factor,e3zps_min,e3zps_rat
+  REAL*8 psur,pa0,pa1,adatrj
+  !       
+  LOGICAL partial_steps,smoothing,bathy_update
+  LOGICAL new_topo,removeclosedseas,dimg,iom_activated
+  !       
+  CHARACTER*100 parent_bathy_level,elevation_database,parent_bathy_meter
+  CHARACTER*100 parent_coordinate_file,restart_file,updated_parent_file,restart_trc_file
+  CHARACTER*100 dimg_output_file,interp_type
+  !      
+  CHARACTER(len=80),DIMENSION(20) :: flx_Files, u_files, v_files
+  CHARACTER(len=255),DIMENSION(20) :: VAR_INTERP
+  !
+  NAMELIST /input_output/iom_activated
+  !
+  NAMELIST /coarse_grid_files/parent_coordinate_file,parent_bathy_level
+  !      
+  NAMELIST /bathymetry/new_topo,elevation_database,smoothing,smoothing_factor, &
+       nb_connection_pts,removeclosedseas,type_bathy_interp      
+  !      
+  NAMELIST /nesting/imin,imax,jmin,jmax,rho,rhot,bathy_update,updated_parent_file      
+  !
+  NAMELIST /vertical_grid/ppkth,ppacr,ppdzmin,pphmax,psur,pa0,pa1,N
+  ! 
+  NAMELIST /partial_cells/partial_steps,parent_bathy_meter,e3zps_min,e3zps_rat      
+  !
+  NAMELIST /nemo_coarse_grid/ jpizoom,jpjzoom 
+  !          
+  NAMELIST /forcing_files/ flx_files, u_files, v_files 
+  !           
+  NAMELIST /interp/ VAR_INTERP
+  !      
+  NAMELIST /restart/ restart_file,shlat,dimg,dimg_output_file,adatrj,interp_type 
+
+  NAMELIST /restart_trc/ restart_trc_file,interp_type 
+
+  INTEGER :: connectionsize = 3
+  !
+CONTAINS
+  !
+  !********************************************************
+  !subroutine agrif_grid_allocate				*
+  !							*
+  !allocation of grid type elements 			*
+  !      according to nx and ny				*
+  !							*
+  !							*
+  !********************************************************
+  !       
+  SUBROUTINE agrif_grid_allocate(Grid,nx,ny)
+    !
+    TYPE(Coordinates) :: Grid
+    INTEGER :: nx,ny
+    !
+    ALLOCATE(Grid%nav_lon(nx,ny),Grid%nav_lat(nx,ny))
+    !
+    ALLOCATE(Grid%glamt(nx,ny),Grid%glamu(nx,ny),Grid%glamv(nx,ny),Grid%glamf(nx,ny))
+    ALLOCATE(Grid%gphit(nx,ny),Grid%gphiu(nx,ny),Grid%gphiv(nx,ny),Grid%gphif(nx,ny))
+    !
+    ALLOCATE(Grid%e1t(nx,ny),Grid%e1u(nx,ny),Grid%e1v(nx,ny),Grid%e1f(nx,ny))
+    ALLOCATE(Grid%e2t(nx,ny),Grid%e2u(nx,ny),Grid%e2v(nx,ny),Grid%e2f(nx,ny))
+    !
+    ALLOCATE(Grid%bathy_level(nx,ny))
+    !
+  END SUBROUTINE agrif_grid_allocate
+  !
+  !
+  !********************************************************
+  !subroutine mixed_grid_allocate				*
+  !							*
+  !allocation of grid type elements 			*
+  !      according to nx and ny				*
+  !							*
+  !							*
+  !********************************************************
+  !       
+  SUBROUTINE mixed_grid_allocate(Grid,nx,ny)
+    !
+    TYPE(mixed_Coordinates) :: Grid
+    INTEGER :: nx,ny
+    !
+    ALLOCATE(Grid%nav_lon(nx,ny),Grid%nav_lat(nx,ny))
+    !
+    ALLOCATE(Grid%glam(nx,ny))
+    ALLOCATE(Grid%gphi(nx,ny))
+    !
+    ALLOCATE(Grid%e1(nx,ny))
+    ALLOCATE(Grid%e2(nx,ny))
+    !
+    ALLOCATE(Grid%bathy_level(nx,ny))
+    !
+  END SUBROUTINE mixed_grid_allocate
+  !
+  !
+!************************************************************************
+  !									*
+  !   subroutine read_namelist						*
+  !									*
+  !   read variables contained in namelist.input file   			*
+  !   filled in by user 							*
+  !									*
+  !************************************************************************
+  !
+  SUBROUTINE read_namelist(namelistname)
+    !
+    IMPLICIT NONE
+    CHARACTER(len=80) :: namelistname
+    CHARACTER*255 :: output
+    LOGICAL :: is_it_there
+    INTEGER unit_nml
+    !      
+    FLX_FILES = '/NULL'
+    U_FILES = '/NULL'
+    V_FILES = '/NULL'
+    VAR_INTERP = 'NULL'
+    unit_nml = Agrif_Get_Unit()
+    !      
+    INQUIRE ( FILE = namelistname , EXIST = is_it_there )      
+    !
+    IF ( is_it_there ) THEN 
+       !
+       OPEN ( FILE   = namelistname , &
+            UNIT   =  unit_nml        , &
+            STATUS = 'OLD'            , &
+            FORM   = 'FORMATTED'      , &
+            ACTION = 'READ'           , &
+            ACCESS = 'SEQUENTIAL'     )	  
+       !
+       REWIND(unit_nml)
+       READ (unit_nml , NML = input_output)
+       READ (unit_nml , NML = coarse_grid_files)
+       READ (unit_nml , NML = bathymetry)	  
+       READ (unit_nml , NML = nesting) 
+       READ (unit_nml , NML = vertical_grid)
+       READ (unit_nml , NML = partial_cells)                    
+       READ (unit_nml , NML = nemo_coarse_grid ) 
+      ! READ (unit_nml , NML = forcing_files )  
+       READ (unit_nml , NML = interp )   
+       READ (unit_nml , NML = restart )
+       READ (unit_nml , NML = restart_trc )
+       CLOSE(unit_nml)
+       !	
+       irafx = rho
+       irafy = rho
+       imin = imin + jpizoom - 1
+       imax = imax + jpizoom - 1
+       jmin = jmin + jpjzoom - 1
+       jmax = jmax + jpjzoom - 1
+       !
+       !nxfin = (imax-imin)*irafx+nbghostcellsfine*2
+       !nyfin = (jmax-jmin)*irafy+nbghostcellsfine*2
+	   !IF(imin>imax) THEN
+	   !   nxfin = (722-imin+imax-1)*rho + NINT(1-(1./rho))
+	   !ELSE
+	   !   nxfin = (imax-imin+1)*rho + 1
+       !ENDIF
+	   !	  nyfin = (jmax-jmin+1)*rho + 1
+	   !
+    ELSE
+       !
+       PRINT *,'namelist file ''',TRIM(namelistname),''' not found'
+       STOP	 
+       !
+    END IF
+    !
+    !
+  END SUBROUTINE read_namelist
+
+  INTEGER FUNCTION agrif_int(x)
+
+    REAL :: x
+    INTEGER ::i
+
+    i = FLOOR(x) + 1
+
+    IF( ABS(x - i).LE.0.0001 )THEN
+       agrif_int = i
+    ELSE
+       agrif_int = i-1
+    ENDIF
+
+  END FUNCTION agrif_int
+  !
+  !*************************************************
+  !   function Agrif_Get_Unit                             
+  !*************************************************
+  !
+
+  INTEGER FUNCTION Agrif_Get_Unit()
+    !
+    INTEGER n
+    LOGICAL op
+    INTEGER :: nunit
+    INTEGER :: iii,out,iiimax 
+    ! 
+    DO n = 7,1000
+       ! 
+       INQUIRE(Unit=n,Opened=op)
+       !
+       IF (.NOT.op) EXIT
+       !      
+    ENDDO
+    !
+    Agrif_Get_Unit=n
+    !
+    !
+  END FUNCTION Agrif_Get_Unit
+  !
+END MODULE agrif_types
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/cfg_tools.f90
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/cfg_tools.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/cfg_tools.f90	(revision 1844)
@@ -0,0 +1,1027 @@
+MODULE tools_brice
+!-----------------------------------------------------------
+!
+!   to make it we use a 4th order polynomial interpolation
+!
+!	        Created by Brice Lemaire on 12/2009.
+!
+!-----------------------------------------------------------
+USE agrif_types
+  !
+  IMPLICIT NONE
+     PUBLIC
+	 !
+     INTEGER :: nxGmix, nyGmix
+     INTEGER :: nxG1, nyG1, nxG2, nyG2, nxG3, nyG3, nxG4, nyG4
+	 INTEGER :: nxG1mix, nyG1mix
+	 INTEGER :: nxG2mix, nyG2mix
+	 INTEGER :: nxG3mix, nyG3mix
+	 INTEGER :: nxG4mix, nyG4mix
+	 INTEGER :: nx_fine, ny_fine, nx_coarse, ny_coarse
+	 INTEGER :: i, j, i_min, j_min
+	 INTEGER :: k, m
+	 !
+	 PUBLIC mixed_grid
+	 PRIVATE mixed_G1, mixed_G2, mixed_G4
+	 !
+	 INTERFACE mixed_grid
+		MODULE PROCEDURE mixed_G1, mixed_G2, mixed_G4
+	 END INTERFACE
+	 !
+   CONTAINS
+     !
+     !********************************************************
+     !              SUBROUTINE mixed grid 				    *
+     !									        			*
+     !	  mix from four grids (U,V,F,T) to one grid			*
+     !												        *
+     !		   CALLED from create_coordinates.f90	        *
+     !********************************************************
+     !    
+	 SUBROUTINE mixed_G1(G1,Gmix)
+	  !
+	 TYPE(Coordinates), INTENT(IN) :: G1
+	 TYPE(mixed_coordinates), INTENT(INOUT) :: Gmix
+     !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE mixed_G1 ***'
+	 WRITE(*,*) ''
+	 !
+	 nxG1 = (imax+1) - (imin-1) + 1   !(+1) rajout de 2 bandes fantmes
+	 nyG1 = (jmax+1) - (jmin-1) + 1
+	 !
+     WRITE(*,*) ''
+     WRITE(*,*) '*** CHECKING SIZE OF INPUT GRID***'
+     WRITE(*,*) nxG1, 'x', nyG1
+     WRITE(*,*) ''
+	 !
+	 nx_coarse = nxG1
+	 ny_coarse = nyG1
+	 !
+	 !!!Calculate size of mixed grid (nx x ny)
+	 nxGmix = (nx_coarse) * 2                       !nbre de pts connus (T,U,V,F) suivant x
+	 nxGmix = nxGmix + (rho-1)*(nxGmix-1)             !nbre de points  interpoler
+     ! 
+	 nyGmix = (ny_coarse) * 2                       !nbre de pts connus (T,U,V,F) suivant y
+	 nyGmix = nyGmix + (rho-1)*(nyGmix-1)             !nbre de points  interpoler
+     ! 
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** SIZE OF MIXED GRID ***'
+	 WRITE(*,*) nxGmix, ' x ', nyGmix
+	 WRITE(*,*) ''
+	 !
+	 nx_fine = (nx_coarse-2)*rho + 1
+	 ny_fine = (ny_coarse-2)*rho + 1
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** SIZE OF FINE GRID ***'
+	 WRITE(*,*) nx_fine, ' x ', ny_fine
+	 WRITE(*,*) ''
+	 !
+	 !!!Allocate mixed grid
+     CALL mixed_grid_allocate(Gmix,nxGmix,nyGmix)      !from agrif_types
+     !
+	 !!!Calculate part of each grid to make Gmix
+	 nxG1mix = nxGmix                        
+	 nyG1mix = nyGmix                          
+	 !
+	 !***On rcupre les pts depuis G1
+   j_min = jmin-1
+   DO j=1,nyG1mix,(2*rho)
+   	  i_min = imin-1
+      DO i=1,nxG1mix,(2*rho)
+	     Gmix%nav_lon(i,j)      =  G1%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,j)  =  G1%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,j)         =  G1%glamt(i_min,j_min)
+         Gmix%glam(i+rho,j)     =  G1%glamu(i_min,j_min)
+		 Gmix%glam(i,j+rho)     =  G1%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,j+rho) =  G1%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,j)         =  G1%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,j)     =  G1%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,j+rho)     =  G1%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,j+rho) =  G1%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,j)         =  G1%e1t(i_min,j_min)
+         Gmix%e1(i+rho,j)     =  G1%e1u(i_min,j_min)		 
+		 Gmix%e1(i,j+rho)     =  G1%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,j+rho) =  G1%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,j)         =  G1%e2t(i_min,j_min)
+         Gmix%e2(i+rho,j)     =  G1%e2u(i_min,j_min)		 
+		 Gmix%e2(i,j+rho)     =  G1%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,j+rho) =  G1%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+!print*, 'Gmix%nav_lat= '
+!DO j=1,nyG1mix
+!print*, Gmix%nav_lat(:,j)
+!END DO  
+   !
+print*, 'G1%glamt= '
+DO j=jmin-1,jmax+1
+print*, G1%glamt(imin-1:imax+1,j)
+ENDDO
+print*,''
+print*, 'G1%glamu= '
+DO j=jmin-1,jmax+1
+print*, G1%glamu(imin-1:imax+1,j)
+ENDDO
+print*,''
+print*, 'Gmix%glam= '
+DO j=1,nyGmix
+print*, Gmix%glam(:,j)
+ENDDO
+     !
+	 END SUBROUTINE
+	 !	  
+	 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+	 !
+	 SUBROUTINE mixed_G2(G1,G2,Gmix)
+	  !
+	 TYPE(Coordinates), INTENT(IN) :: G1,G2
+	 TYPE(mixed_coordinates), INTENT(INOUT) :: Gmix
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE mixed_G2 ***'
+	 WRITE(*,*) ''
+	 !
+     !
+	 nxG1 = SIZE(G1%glamt,1) - (imin-1) + 1   !(+1) rajout d'une bande fantme
+	 nyG1 = (jmax+1) - (jmin-1) + 1
+	 print*, nxG1, nyG1
+	 !
+	 nxG2 = (imax+1) - 2      !(-2) on supprime les bandes de chevauchement
+     nyG2 = nyG1
+	 print*, nxG2, nyG2
+	 !
+	 nx_coarse = nxG1+nxG2 
+	 ny_coarse = nyG1 
+	 !
+	 !!!Calculate size of mixed grid (nx x ny)
+	 nxGmix = (nx_coarse) * 2       !nbre de pts connus (T,U,V,F) suivant x
+	 nxGmix = nxGmix + (rho-1)*(nxGmix-1)             !nbre de points  interpoler
+     ! 
+	 nyGmix = (ny_coarse) * 2       !nbre de pts connus (T,U,V,F) suivant y
+	 nyGmix = nyGmix + (rho-1)*(nyGmix-1)             !nbre de points  interpoler
+     ! 
+	 WRITE(*,*) '*** SIZE OF MIXED GRID ***'
+	 WRITE(*,*) nxGmix, ' x ', nyGmix
+	 WRITE(*,*) ''
+	 !
+	 !nx_fine = (nxG1-1 + nxG2-1)*rho + 1   !(-1) on supprime les 2 bandes fantmes
+	 !ny_fine = (nyG1-1)*rho + 1	
+	 
+	 nx_fine = (nx_coarse-2)*rho + 1
+	 ny_fine = (ny_coarse-2)*rho + 1
+	 !
+	 WRITE(*,*) '*** SIZE OF FINE GRID ***'
+	 WRITE(*,*) nx_fine, ' x ', ny_fine
+	 WRITE(*,*) ''
+	 !
+	 !!!Allocate mixed grid
+     CALL mixed_grid_allocate(Gmix,nxGmix,nyGmix)      !from agrif_types
+     !
+	 !!!Calculate part of each grid to make Gmix
+	 nxG1mix = nxG1  * 2                                !nbre de pts connus (T,U,V,F) suivant x
+	 nxG1mix = nxG1mix + (rho-1)*(nxG1mix-1)            !nbre de points  interpoler
+     !    
+	 nyG1mix = nyG1  * 2                                !nbre de pts connus (T,U,V,F) suivant x
+	 nyG1mix = nyG1mix + (rho-1)*(nyG1mix-1)            !nbre de points  interpoler
+     print*,'nxG1mix= ', nxG1mix, 'nyG1mix= ', nyG1mix
+	 !
+	 nxG2mix = nxG2  * 2                                !nbre de pts connus (T,U,V,F) suivant x
+	 nxG2mix = nxG2mix + (rho-1)*(nxG2mix-1) + 1        !nbre de points  interpoler
+    ! 
+	 nyG2mix = nyG2  * 2                                !nbre de pts connus (T,U,V,F) suivant x
+	 nyG2mix = nyG2mix + (rho-1)*(nyG2mix-1)            !nbre de points  interpoler
+	 print*,'nxG2mix= ', nxG2mix, 'nyG2mix= ', nyG2mix     
+	 !
+	 IF((nxG1mix+nxG2mix).NE.nxGmix) THEN
+        WRITE(*,*) ''
+		WRITE(*,*) '*** ERROR ***'
+		WRITE(*,*) 'nxG1mix + nxG2mix /= nxGmix'
+	    WRITE(*,*) nxG1mix + nxG2mix, ' /= ', nxGmix
+	    WRITE(*,*) ''
+	 ENDIF	
+	 !
+   !*** On rcupre les pts depuis G1
+   j_min = jmin-1
+   DO j=1,nyG1mix,(2*rho)
+   	  i_min = imin-1
+      DO i=1,nxG1mix,(2*rho)
+	     Gmix%nav_lon(i,j)      =  G1%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,j)  =  G1%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,j)         =  G1%glamt(i_min,j_min)
+         Gmix%glam(i+rho,j)     =  G1%glamu(i_min,j_min)
+		 Gmix%glam(i,j+rho)     =  G1%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,j+rho) =  G1%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,j)         =  G1%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,j)     =  G1%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,j+rho)     =  G1%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,j+rho) =  G1%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,j)         =  G1%e1t(i_min,j_min)
+         Gmix%e1(i+rho,j)     =  G1%e1u(i_min,j_min)		 
+		 Gmix%e1(i,j+rho)     =  G1%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,j+rho) =  G1%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,j)         =  G1%e2t(i_min,j_min)
+         Gmix%e2(i+rho,j)     =  G1%e2u(i_min,j_min)		 
+		 Gmix%e2(i,j+rho)     =  G1%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,j+rho) =  G1%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+   !***On rcupre les pts depuis G2
+   j_min = jmin - 1
+   DO j=1,nyG2mix,(2*rho)      
+	  i_min = 3
+      DO k=i,nxGmix,(2*rho)
+	  print*, k       
+	     Gmix%nav_lon(k,j)      =  G2%nav_lon(i_min,j_min)
+         Gmix%nav_lat(k+rho,j)  =  G2%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(k,j)         =  G2%glamt(i_min,j_min)
+         Gmix%glam(k+rho,j)     =  G2%glamu(i_min,j_min)
+		 Gmix%glam(k,j+rho)     =  G2%glamv(i_min,j_min)
+	     Gmix%glam(k+rho,j+rho) =  G2%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(k,j)         =  G2%gphit(i_min,j_min)
+         Gmix%gphi(k+rho,j)     =  G2%gphiu(i_min,j_min)		 
+		 Gmix%gphi(k,j+rho)     =  G2%gphiv(i_min,j_min)
+	     Gmix%gphi(k+rho,j+rho) =  G2%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(k,j)         =  G2%e1t(i_min,j_min)
+         Gmix%e1(k+rho,j)     =  G2%e1u(i_min,j_min)		 
+		 Gmix%e1(k,j+rho)     =  G2%e1v(i_min,j_min)
+	     Gmix%e1(k+rho,j+rho) =  G2%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(k,j)         =  G2%e2t(i_min,j_min)
+         Gmix%e2(k+rho,j)     =  G2%e2u(i_min,j_min)		 
+		 Gmix%e2(k,j+rho)     =  G2%e2v(i_min,j_min)
+	     Gmix%e2(k+rho,j+rho) =  G2%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+     !
+print*, 'G1%glamt= '
+DO j=jmin-1,jmax+1
+print*, G1%glamt(imin-1:SIZE(G1%glamt,1),j)
+ENDDO
+print*,''
+print*, 'G1%glamu= '
+DO j=jmin-1,jmax+1
+print*, G1%glamu(imin-1:SIZE(G1%glamu,1),j)
+ENDDO
+print*,''
+print*, 'Gmix%glam= '
+DO j=1,nyGmix
+print*, Gmix%glam(:,j)
+ENDDO
+
+	 END SUBROUTINE
+	 !
+	 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+	 !
+	 SUBROUTINE mixed_G3(G1,G3,Gmix)
+	  !
+	 TYPE(Coordinates), INTENT(IN) :: G1,G2,G3
+	 TYPE(mixed_coordinates), INTENT(INOUT) :: Gmix
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE mixed_G3 ***'
+	 WRITE(*,*) ''
+	 !
+     !
+	 nxG1 = (imax+1) - (imin-1) + 1				  !(+1) rajout de 2 bandes fantmes
+	 nyG1 = SIZE(G1%glamt,2) - (jmin-1) + 1
+	 print*, nxG1, nyG1
+     !
+     nxG3 = nxG1  
+     nyG3 = SIZE(G3%glamt,2) - (jmax-1) + 1 - 2   !(-2) on supprime les bandes de chevauchement
+	 print*, nxG3, nyG3
+	 !
+	 nx_coarse = nxG1 
+	 ny_coarse = nyG1 + nyG3
+	 !
+	 !!!Calculate size of mixed grid (nx x ny)
+	 nxGmix = (nx_coarse) * 2       !nbre de pts connus (T,U,V,F) suivant x
+	 nxGmix = nxGmix + (rho-1)*(nxGmix-1)             !nbre de points  interpoler
+     ! 
+	 nyGmix = (ny_coarse) * 2       !nbre de pts connus (T,U,V,F) suivant y
+	 nyGmix = nyGmix + (rho-1)*(nyGmix-1)             !nbre de points  interpoler
+     ! 
+	 WRITE(*,*) '*** SIZE OF MIXED GRID ***'
+	 WRITE(*,*) nxGmix, ' x ', nyGmix
+	 WRITE(*,*) ''
+	 !
+	 !nx_fine = (nxGmix/2) - 1
+	 !ny_fine = (nyGmix/2) - 1
+	 nx_fine = (nx_coarse-2)*rho + 1
+	 ny_fine = (ny_coarse-2)*rho + 1
+	
+	 !
+	 WRITE(*,*) '*** SIZE OF FINE GRID ***'
+	 WRITE(*,*) nx_fine, ' x ', ny_fine
+	 WRITE(*,*) ''
+	 !
+	 !!!Allocate mixed grid
+     CALL mixed_grid_allocate(Gmix,nxGmix,nyGmix)      !from agrif_types
+     !
+	 !!!Calculate part of each grid to make Gmix
+	 nxG1mix = nxG1  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG1mix = nxG1mix + (rho-1)*(nxG1mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG1mix = nyG1  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG1mix = nyG1mix + (rho-1)*(nyG1mix-1)        !nbre de points  interpoler
+     print*,'nxG1mix= ', nxG1mix, 'nyG1mix= ', nyG1mix
+	 !
+	 nxG2mix = nxG2  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG2mix = nxG2mix + (rho-1)*(nxG2mix-1)        !nbre de points  interpoler
+    ! 
+	 nyG2mix = nyG2  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG2mix = nyG2mix + (rho-1)*(nyG2mix-1)        !nbre de points  interpoler
+	 print*,'nxG2mix= ', nxG2mix, 'nyG2mix= ', nyG2mix     
+	 !
+	 nxG3mix = nxG3  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG3mix = nxG3mix + (rho-1)*(nxG3mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG3mix = nyG3  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG3mix = nyG3mix + (rho-1)*(nyG3mix-1)        !nbre de points  interpoler
+	 print*,'nxG3mix= ', nxG3mix, 'nyG3mix= ', nyG3mix          
+	 !
+	 nxG4mix = nxG4  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG4mix = nxG4mix + (rho-1)*(nxG4mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG4mix = nyG4  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG4mix = nyG4mix + (rho-1)*(nyG4mix-1)        !nbre de points  interpoler
+ 	 print*,'nxG4mix= ', nxG4mix, 'nyG4mix= ', nyG4mix         
+	 !
+
+   !***On rcupre les pts depuis G1
+   j_min = jmin-1
+   DO j=1,nyG1mix,(2*rho)
+   	  i_min = imin-1
+      DO i=1,nxG1mix,(2*rho)
+	     Gmix%nav_lon(i,j)      =  G1%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,j)  =  G1%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,j)         =  G1%glamt(i_min,j_min)
+         Gmix%glam(i+rho,j)     =  G1%glamu(i_min,j_min)
+		 Gmix%glam(i,j+rho)     =  G1%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,j+rho) =  G1%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,j)         =  G1%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,j)     =  G1%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,j+rho)     =  G1%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,j+rho) =  G1%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,j)         =  G1%e1t(i_min,j_min)
+         Gmix%e1(i+rho,j)     =  G1%e1u(i_min,j_min)		 
+		 Gmix%e1(i,j+rho)     =  G1%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,j+rho) =  G1%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,j)         =  G1%e2t(i_min,j_min)
+         Gmix%e2(i+rho,j)     =  G1%e2u(i_min,j_min)		 
+		 Gmix%e2(i,j+rho)     =  G1%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,j+rho) =  G1%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+   !***On rcupre les pts depuis G2
+   j_min = jmin - 1
+   DO j=1,nyG2mix,(2*rho)      
+	  i_min = 3
+      DO k=i,nxGmix,(2*rho)       
+	     Gmix%nav_lon(k,j)      =  G2%nav_lon(i_min,j_min)
+         Gmix%nav_lat(k+rho,j)  =  G2%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(k,j)         =  G2%glamt(i_min,j_min)
+         Gmix%glam(k+rho,j)     =  G2%glamu(i_min,j_min)
+		 Gmix%glam(k,j+rho)     =  G2%glamv(i_min,j_min)
+	     Gmix%glam(k+rho,j+rho) =  G2%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(k,j)         =  G2%gphit(i_min,j_min)
+         Gmix%gphi(k+rho,j)     =  G2%gphiu(i_min,j_min)		 
+		 Gmix%gphi(k,j+rho)     =  G2%gphiv(i_min,j_min)
+	     Gmix%gphi(k+rho,j+rho) =  G2%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(k,j)         =  G2%e1t(i_min,j_min)
+         Gmix%e1(k+rho,j)     =  G2%e1u(i_min,j_min)		 
+		 Gmix%e1(k,j+rho)     =  G2%e1v(i_min,j_min)
+	     Gmix%e1(k+rho,j+rho) =  G2%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(k,j)         =  G2%e2t(i_min,j_min)
+         Gmix%e2(k+rho,j)     =  G2%e2u(i_min,j_min)		 
+		 Gmix%e2(k,j+rho)     =  G2%e2v(i_min,j_min)
+	     Gmix%e2(k+rho,j+rho) =  G2%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+   !**On rcupre les pts depuis G3
+   j_min = SIZE(G3%glamt,2)-2      !on supprime les bandes de chevauchement
+   DO m=j,nyGmix,(2*rho)
+   	  i_min = imin + imax
+      DO i=1,nxG3mix,(2*rho)
+	     Gmix%nav_lon(i,m)      =  G3%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,m)  =  G3%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,m)         =  G3%glamt(i_min,j_min)
+         Gmix%glam(i+rho,m)     =  G3%glamu(i_min,j_min)
+		 Gmix%glam(i,m+rho)     =  G3%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,m+rho) =  G3%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,m)         =  G3%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,m)     =  G3%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,m+rho)     =  G3%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,m+rho) =  G3%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,m)         =  G3%e1t(i_min,j_min)
+         Gmix%e1(i+rho,m)     =  G3%e1u(i_min,j_min)		 
+		 Gmix%e1(i,m+rho)     =  G3%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,m+rho) =  G3%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,m)         =  G3%e2t(i_min,j_min)
+         Gmix%e2(i+rho,m)     =  G3%e2u(i_min,j_min)		 
+		 Gmix%e2(i,m+rho)     =  G3%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,m+rho) =  G3%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min - 1      !on se dplace le long de (-i)	
+	  ENDDO
+	  j_min = j_min - 1         !on se dplace le long de (-j)	
+   ENDDO
+   !   
+   !**On rcupre les pts depuis G4
+   j_min =  SIZE(G4%glamt,2)-2     !on supprime les bandes de chevauchement
+   DO m=j,nyGmix,(2*rho)
+   	  i_min = SIZE(G4%glamt,1)-2
+      DO k=i,nxGmix,(2*rho)
+	     Gmix%nav_lon(k,m)      =  G4%nav_lon(i_min,j_min)
+         Gmix%nav_lat(k+rho,m)  =  G4%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(k,m)         =  G4%glamt(i_min,j_min)
+         Gmix%glam(k+rho,m)     =  G4%glamu(i_min,j_min)
+		 Gmix%glam(k,m+rho)     =  G4%glamv(i_min,j_min)
+	     Gmix%glam(k+rho,m+rho) =  G4%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(k,m)         =  G4%gphit(i_min,j_min)
+         Gmix%gphi(k+rho,m)     =  G4%gphiu(i_min,j_min)		 
+		 Gmix%gphi(k,m+rho)     =  G4%gphiv(i_min,j_min)
+	     Gmix%gphi(k+rho,m+rho) =  G4%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(k,m)         =  G4%e1t(i_min,j_min)
+         Gmix%e1(k+rho,m)     =  G4%e1u(i_min,j_min)		 
+		 Gmix%e1(k,m+rho)     =  G4%e1v(i_min,j_min)
+	     Gmix%e1(k+rho,m+rho) =  G4%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(k,m)         =  G4%e2t(i_min,j_min)
+         Gmix%e2(k+rho,m)     =  G4%e2u(i_min,j_min)		 
+		 Gmix%e2(k,m+rho)     =  G4%e2v(i_min,j_min)
+	     Gmix%e2(k+rho,m+rho) =  G4%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min - 1      !on se dplace le long de (-i)	
+	  ENDDO
+	  j_min = j_min - 1         !on se dplace le long de (-j)	
+   ENDDO
+   !
+print*, 'G1%glamt= '
+DO j=jmin-1,SIZE(G1%glamt,2)
+print*, G1%glamt(imin-1:SIZE(G1%glamt,1),j)
+ENDDO
+print*,''
+print*, 'G1%glamu= '
+DO j=jmin-1,SIZE(G1%glamu,2)
+print*, G1%glamu(imin-1:SIZE(G1%glamu,1),j)
+ENDDO
+print*,''
+print*, 'Gmix%glam= '
+DO j=1,nyGmix
+print*, Gmix%glam(:,j)
+ENDDO
+
+	 END SUBROUTINE
+	 !
+	 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+	 ! 
+     SUBROUTINE mixed_G4(G1,G2,G3,G4,Gmix)
+	 !
+	 TYPE(Coordinates), INTENT(IN) :: G1,G2,G3,G4
+	 TYPE(mixed_coordinates), INTENT(INOUT) :: Gmix
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE mixed_G4 ***'
+	 WRITE(*,*) ''
+	 !
+     !
+	 nxG1 = SIZE(G1%glamt,1) - (imin-1) + 1   !(+1) rajout d'une bande fantme
+	 nyG1 = SIZE(G1%glamt,2) - (jmin-1) + 1
+	 print*, nxG1, nyG1
+	 !
+	 nxG2 = imax + 1 - 2      !(-2) on supprime les bandes de chevauchement
+     nyG2 = SIZE(G2%glamt,2) - (jmin-1) + 1
+	 print*, nxG2, nyG2
+     !
+     nxG3 = SIZE(G3%glamt,1) - (imin-1) + 1  
+     nyG3 = SIZE(G3%glamt,2) - (jmax-1) + 1 - 2   !(-2) on supprime les bandes de chevauchement
+	 print*, nxG3, nyG3
+	 !
+     nxG4 = imax + 1 - 2      !(-2) on supprime les bandes de chevauchement
+     nyG4 = SIZE(G4%glamt,2) - (jmax-1) + 1 - 2   !(-2) on supprime les bandes de chevauchement
+     print*, nxG4, nyG4
+	 !
+     WRITE(*,*) ''
+     WRITE(*,*) '*** CHECKING SIZE OF THE MIXED GRID***'
+     WRITE(*,*) ' nxG1 + nxG2 = nxG3 + nxG4 = nx_coarse'
+     WRITE(*,*) nxG1 + nxG2, ' = ', nxG3 + nxG4 
+     WRITE(*,*) ''
+	 WRITE(*,*) ' nyG1 + nyG3 = nyG2 + nyG4 = ny_coarse'
+     WRITE(*,*) nyG1 + nyG3, ' = ', nyG2 + nyG4 
+     WRITE(*,*) ''
+	 !
+	 nx_coarse = nxG1 + nxG2
+	 ny_coarse = nyG1 + nyG3
+	 !
+	 !!!Calculate size of mixed grid (nx x ny)
+	 nxGmix = (nxG1  + nxG2) * 2       !nbre de pts connus (T,U,V,F) suivant x
+	 nxGmix = nxGmix + (rho-1)*(nxGmix-1)             !nbre de points  interpoler
+     ! 
+	 nyGmix = (nyG1 + nyG3) * 2       !nbre de pts connus (T,U,V,F) suivant y
+	 nyGmix = nyGmix + (rho-1)*(nyGmix-1)             !nbre de points  interpoler
+     ! 
+	 WRITE(*,*) '*** SIZE OF MIXED GRID ***'
+	 WRITE(*,*) nxGmix, ' x ', nyGmix
+	 WRITE(*,*) ''
+	 !
+	 !nx_fine = (nxGmix/2) - 1
+	 !ny_fine = (nyGmix/2) - 1
+	 nx_fine = (nx_coarse-2)*rho + 1
+	 ny_fine = (ny_coarse-2)*rho + 1
+	
+	 !
+	 WRITE(*,*) '*** SIZE OF FINE GRID ***'
+	 WRITE(*,*) nx_fine, ' x ', ny_fine
+	 WRITE(*,*) ''
+	 !
+	 !!!Allocate mixed grid
+     CALL mixed_grid_allocate(Gmix,nxGmix,nyGmix)      !from agrif_types
+     !
+	 !!!Calculate part of each grid to make Gmix
+	 nxG1mix = nxG1  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG1mix = nxG1mix + (rho-1)*(nxG1mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG1mix = nyG1  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG1mix = nyG1mix + (rho-1)*(nyG1mix-1)        !nbre de points  interpoler
+     print*,'nxG1mix= ', nxG1mix, 'nyG1mix= ', nyG1mix
+	 !
+	 nxG2mix = nxG2  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG2mix = nxG2mix + (rho-1)*(nxG2mix-1)        !nbre de points  interpoler
+    ! 
+	 nyG2mix = nyG2  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG2mix = nyG2mix + (rho-1)*(nyG2mix-1)        !nbre de points  interpoler
+	 print*,'nxG2mix= ', nxG2mix, 'nyG2mix= ', nyG2mix     
+	 !
+	 nxG3mix = nxG3  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG3mix = nxG3mix + (rho-1)*(nxG3mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG3mix = nyG3  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG3mix = nyG3mix + (rho-1)*(nyG3mix-1)        !nbre de points  interpoler
+	 print*,'nxG3mix= ', nxG3mix, 'nyG3mix= ', nyG3mix          
+	 !
+	 nxG4mix = nxG4  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nxG4mix = nxG4mix + (rho-1)*(nxG4mix-1)        !nbre de points  interpoler
+     ! 
+	 nyG4mix = nyG4  * 2                           !nbre de pts connus (T,U,V,F) suivant x
+	 nyG4mix = nyG4mix + (rho-1)*(nyG4mix-1)        !nbre de points  interpoler
+ 	 print*,'nxG4mix= ', nxG4mix, 'nyG4mix= ', nyG4mix         
+	 !
+
+   !***On rcupre les pts depuis G1
+   j_min = jmin-1
+   DO j=1,nyG1mix,(2*rho)
+   	  i_min = imin-1
+      DO i=1,nxG1mix,(2*rho)
+	     Gmix%nav_lon(i,j)      =  G1%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,j)  =  G1%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,j)         =  G1%glamt(i_min,j_min)
+         Gmix%glam(i+rho,j)     =  G1%glamu(i_min,j_min)
+		 Gmix%glam(i,j+rho)     =  G1%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,j+rho) =  G1%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,j)         =  G1%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,j)     =  G1%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,j+rho)     =  G1%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,j+rho) =  G1%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,j)         =  G1%e1t(i_min,j_min)
+         Gmix%e1(i+rho,j)     =  G1%e1u(i_min,j_min)		 
+		 Gmix%e1(i,j+rho)     =  G1%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,j+rho) =  G1%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,j)         =  G1%e2t(i_min,j_min)
+         Gmix%e2(i+rho,j)     =  G1%e2u(i_min,j_min)		 
+		 Gmix%e2(i,j+rho)     =  G1%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,j+rho) =  G1%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+   !***On rcupre les pts depuis G2
+   j_min = jmin - 1
+   DO j=1,nyG2mix,(2*rho)      
+	  i_min = 3
+      DO k=i,nxGmix,(2*rho)       
+	     Gmix%nav_lon(k,j)      =  G2%nav_lon(i_min,j_min)
+         Gmix%nav_lat(k+rho,j)  =  G2%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(k,j)         =  G2%glamt(i_min,j_min)
+         Gmix%glam(k+rho,j)     =  G2%glamu(i_min,j_min)
+		 Gmix%glam(k,j+rho)     =  G2%glamv(i_min,j_min)
+	     Gmix%glam(k+rho,j+rho) =  G2%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(k,j)         =  G2%gphit(i_min,j_min)
+         Gmix%gphi(k+rho,j)     =  G2%gphiu(i_min,j_min)		 
+		 Gmix%gphi(k,j+rho)     =  G2%gphiv(i_min,j_min)
+	     Gmix%gphi(k+rho,j+rho) =  G2%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(k,j)         =  G2%e1t(i_min,j_min)
+         Gmix%e1(k+rho,j)     =  G2%e1u(i_min,j_min)		 
+		 Gmix%e1(k,j+rho)     =  G2%e1v(i_min,j_min)
+	     Gmix%e1(k+rho,j+rho) =  G2%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(k,j)         =  G2%e2t(i_min,j_min)
+         Gmix%e2(k+rho,j)     =  G2%e2u(i_min,j_min)		 
+		 Gmix%e2(k,j+rho)     =  G2%e2v(i_min,j_min)
+	     Gmix%e2(k+rho,j+rho) =  G2%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min+1	
+	  ENDDO
+	  j_min = j_min+1	
+   ENDDO
+   !
+   !**On rcupre les pts depuis G3
+   j_min = SIZE(G3%glamt,2)-2      !on supprime les bandes de chevauchement
+   DO m=j,nyGmix,(2*rho)
+   	  i_min = imin + imax
+      DO i=1,nxG3mix,(2*rho)
+	     Gmix%nav_lon(i,m)      =  G3%nav_lon(i_min,j_min)
+         Gmix%nav_lat(i+rho,m)  =  G3%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(i,m)         =  G3%glamt(i_min,j_min)
+         Gmix%glam(i+rho,m)     =  G3%glamu(i_min,j_min)
+		 Gmix%glam(i,m+rho)     =  G3%glamv(i_min,j_min)
+	     Gmix%glam(i+rho,m+rho) =  G3%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(i,m)         =  G3%gphit(i_min,j_min)
+         Gmix%gphi(i+rho,m)     =  G3%gphiu(i_min,j_min)		 
+		 Gmix%gphi(i,m+rho)     =  G3%gphiv(i_min,j_min)
+	     Gmix%gphi(i+rho,m+rho) =  G3%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(i,m)         =  G3%e1t(i_min,j_min)
+         Gmix%e1(i+rho,m)     =  G3%e1u(i_min,j_min)		 
+		 Gmix%e1(i,m+rho)     =  G3%e1v(i_min,j_min)
+	     Gmix%e1(i+rho,m+rho) =  G3%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(i,m)         =  G3%e2t(i_min,j_min)
+         Gmix%e2(i+rho,m)     =  G3%e2u(i_min,j_min)		 
+		 Gmix%e2(i,m+rho)     =  G3%e2v(i_min,j_min)
+	     Gmix%e2(i+rho,m+rho) =  G3%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min - 1      !on se dplace le long de (-i)	
+	  ENDDO
+	  j_min = j_min - 1         !on se dplace le long de (-j)	
+   ENDDO
+   !   
+   !**On rcupre les pts depuis G4
+   j_min =  SIZE(G4%glamt,2)-2     !on supprime les bandes de chevauchement
+   DO m=j,nyGmix,(2*rho)
+   	  i_min = SIZE(G4%glamt,1)-2
+      DO k=i,nxGmix,(2*rho)
+	     Gmix%nav_lon(k,m)      =  G4%nav_lon(i_min,j_min)
+         Gmix%nav_lat(k+rho,m)  =  G4%nav_lat(i_min,j_min)	    
+		 !
+         Gmix%glam(k,m)         =  G4%glamt(i_min,j_min)
+         Gmix%glam(k+rho,m)     =  G4%glamu(i_min,j_min)
+		 Gmix%glam(k,m+rho)     =  G4%glamv(i_min,j_min)
+	     Gmix%glam(k+rho,m+rho) =  G4%glamf(i_min,j_min)		    
+		 !
+         Gmix%gphi(k,m)         =  G4%gphit(i_min,j_min)
+         Gmix%gphi(k+rho,m)     =  G4%gphiu(i_min,j_min)		 
+		 Gmix%gphi(k,m+rho)     =  G4%gphiv(i_min,j_min)
+	     Gmix%gphi(k+rho,m+rho) =  G4%gphif(i_min,j_min)
+		 !
+		 Gmix%e1(k,m)         =  G4%e1t(i_min,j_min)
+         Gmix%e1(k+rho,m)     =  G4%e1u(i_min,j_min)		 
+		 Gmix%e1(k,m+rho)     =  G4%e1v(i_min,j_min)
+	     Gmix%e1(k+rho,m+rho) =  G4%e1f(i_min,j_min)	
+		 !	
+		 Gmix%e2(k,m)         =  G4%e2t(i_min,j_min)
+         Gmix%e2(k+rho,m)     =  G4%e2u(i_min,j_min)		 
+		 Gmix%e2(k,m+rho)     =  G4%e2v(i_min,j_min)
+	     Gmix%e2(k+rho,m+rho) =  G4%e2f(i_min,j_min) 
+		 !
+		 i_min = i_min - 1      !on se dplace le long de (-i)	
+	  ENDDO
+	  j_min = j_min - 1         !on se dplace le long de (-j)	
+   ENDDO
+   !
+print*, 'G1%glamt= '
+DO j=jmin-1,SIZE(G1%glamt,2)
+print*, G1%glamt(imin-1:SIZE(G1%glamt,1),j)
+ENDDO
+print*,''
+print*, 'G1%glamu= '
+DO j=jmin-1,SIZE(G1%glamu,2)
+print*, G1%glamu(imin-1:SIZE(G1%glamu,1),j)
+ENDDO
+print*,''
+print*, 'Gmix%glam= '
+DO j=1,nyGmix
+print*, Gmix%glam(:,j)
+ENDDO
+	 END SUBROUTINE
+     !
+     !
+     !********************************************************
+     !                 SUBROUTINE interp   				    *
+     !									        			*
+     !	calculate polynomial interpolation at 4th order		*
+     !												        *
+     !		   CALLED from create_coordinates.f90	        *
+     !********************************************************
+     !       
+     SUBROUTINE interp_grid(Gmix)
+	 !
+	 TYPE(mixed_coordinates) :: Gmix
+	 !TYPE(Coordinates) :: Grid1
+	 REAL*8, DIMENSION(rho-1,4) :: S      !Array to store the coefficients of Lagrange 	 
+     INTEGER :: i, j, k, status
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE interp ***'
+	 WRITE(*,*) ''
+	 !
+	 !!!Calculate coefficients 
+	 status = pol_coef(S)
+	 !
+	 !IF(rho>1) THEN
+	 !!!Interpolation along longitude
+	 do j=1,SIZE(Gmix%glam,2),rho
+	    do i=1,SIZE(Gmix%glam,1),rho
+		   do k=1,rho-1
+		      Gmix%glam(i+rho+k,j) =   S(k,1) * Gmix%glam(i,j)         &
+										   + S(k,2) * Gmix%glam(i+1*rho,j)   &
+									       + S(k,3) * Gmix%glam(i+2*rho,j)   &
+									       + S(k,4) * Gmix%glam(i+3*rho,j)
+			  !
+			  Gmix%gphi(i+rho+k,j) =   S(k,1) * Gmix%gphi(i,j)         &
+										   + S(k,2) * Gmix%gphi(i+1*rho,j)   &
+									       + S(k,3) * Gmix%gphi(i+2*rho,j)   &
+									       + S(k,4) * Gmix%gphi(i+3*rho,j)
+			  !
+			  Gmix%e1(i+rho+k,j) =     S(k,1) * Gmix%e1(i,j)         &
+										   + S(k,2) * Gmix%e1(i+1*rho,j)   &
+									       + S(k,3) * Gmix%e1(i+2*rho,j)   &
+									       + S(k,4) * Gmix%e1(i+3*rho,j)
+			  !
+			  Gmix%e2(i+rho+k,j) =     S(k,1) * Gmix%e2(i,j)         &
+										   + S(k,2) * Gmix%e2(i+1*rho,j)   &
+									       + S(k,3) * Gmix%e2(i+2*rho,j)   &
+									       + S(k,4) * Gmix%e2(i+3*rho,j)
+			  !
+			  Gmix%nav_lon(i+rho+k,j) = Gmix%glam(i+rho+k,j)
+			  Gmix%nav_lat(i+rho+k,j) = Gmix%gphi(i+rho+k,j)
+			  !
+		   end do
+		   !							   
+	       IF(i+3*rho == SIZE(Gmix%glam,1)) EXIT
+		end do
+	end do
+	 !
+	 !!!Interpolation along latitude
+	 do i=1,SIZE(Gmix%glam,1)
+	    do j=1,SIZE(Gmix%glam,2),rho
+		   do k=1,rho-1
+		      Gmix%glam(i,j+rho+k) =   S(k,1) * Gmix%glam(i,j)       &
+										   + S(k,2) * Gmix%glam(i,j+rho)   &
+									       + S(k,3) * Gmix%glam(i,j+2*rho) &
+									       + S(k,4) * Gmix%glam(i,j+3*rho)
+		      !
+			  Gmix%gphi(i,j+rho+k) =   S(k,1) * Gmix%gphi(i,j)       &
+										   + S(k,2) * Gmix%gphi(i,j+rho)   &
+									       + S(k,3) * Gmix%gphi(i,j+2*rho) &
+									       + S(k,4) * Gmix%gphi(i,j+3*rho)
+			  !
+			  Gmix%e1(i,j+rho+k) =     S(k,1) * Gmix%e1(i,j)       &
+										   + S(k,2) * Gmix%e1(i,j+rho)   &
+									       + S(k,3) * Gmix%e1(i,j+2*rho) &
+									       + S(k,4) * Gmix%e1(i,j+3*rho)
+			  !
+			  Gmix%e2(i,j+rho+k) =     S(k,1) * Gmix%e2(i,j)       &
+										   + S(k,2) * Gmix%e2(i,j+rho)   &
+									       + S(k,3) * Gmix%e2(i,j+2*rho) &
+									       + S(k,4) * Gmix%e2(i,j+3*rho)
+			  !
+			  Gmix%nav_lon(i,j+rho+k) = Gmix%glam(i,j+rho+k)
+			  Gmix%nav_lat(i,j+rho+k) = Gmix%gphi(i,j+rho+k)
+			  !
+			end do
+			  !							   
+			IF(j+3*rho == SIZE(Gmix%glam,2)) EXIT
+		end do
+	end do	
+
+     !
+    
+	 END SUBROUTINE
+     !
+	 !
+     !********************************************************
+     !                  FUNCTION pol_coef   			    *
+     !									        			*
+     !	      calculate the coefficients of Lagrange   		*
+     !			 for the polynomial interpolation	        *
+     !												        *
+	 !             CALLED from SUBROUTINE interp            *
+     !********************************************************
+     !     
+	 REAL FUNCTION pol_coef(vect)
+	    !
+		REAL*8, DIMENSION(rho-1,4) :: vect
+		REAL*8, DIMENSION(3) :: v		
+		INTEGER :: i, m, k
+		REAL*8 :: x0      !position relative du point  calculer 
+		INTEGER :: x_k, x_i      !position relative des points utiliss pour l'interpolation
+		REAL*8 :: eps 
+		!
+		!on parle de position relative puisque nous utilisons les positions
+		!indiciaires, lesquelles sont rptes dans toute la grille.
+		!Il n'est donc ncessaire de calculer qu'une fois les 4 coefficients 
+		!qui seront utiliss dans toute la grille en fonction de rho
+		!
+		     !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** FUNCTION pol_coef ***'
+	 WRITE(*,*) ''
+	 !
+		m=1
+		eps = 1.-1e-8
+		!
+		do k=1,rho-1 
+		   x0=rho+1+k
+		   i=1
+		   do x_i=1,4+3*(rho-1),rho
+			m=1
+			   do x_k=1,4+3*(rho-1),rho
+			     IF(x_k == x_i) THEN
+				    CYCLE
+				 ELSE	
+		         v(m) = (x0-x_k) / (x_i-x_k)
+				 m=m+1
+		         END IF
+			   end do
+		       vect(k,i) = product(v)
+			   i=i+1
+		   end do
+		end do
+		!
+		IF((SUM(vect)<eps .OR. SUM(vect)>eps) .AND. rho>1) THEN
+		   print*,''
+		   print*, '*** CHECK LAGRANGE COEFFICIENTS: ***'
+		   print*,''
+		   do i=1,rho-1
+		      print*,'point #',i
+		      print*, 'S(i,:)= ', vect(i,:)
+		      print*, 'SUM(S(i,:)) =', SUM(vect(i,:))
+			  print*,''
+		   end do
+		   print*, ''
+		   pol_coef = 1
+		ELSE
+		   !print*,'Error with Lagrange coefficients'
+		   pol_coef = 0
+		END IF
+	    !
+	 END FUNCTION pol_coef
+	 !
+     !
+     !********************************************************
+     !             SUBROUTINE alloc_child_grid   		    *
+     !									        			*
+     !	      create the child grid from mixed grid		    *
+     !												        *
+     !		   CALLED from create_coordinates.f90	        *
+     !********************************************************
+     !       
+     SUBROUTINE alloc_child_grid(Gmix, Grid1)	 
+	 !
+	 TYPE(mixed_coordinates), INTENT(IN) :: Gmix
+	 TYPE(coordinates), INTENT(INOUT) :: Grid1
+	 INTEGER :: i, j, p, q
+	 !
+	 WRITE(*,*) ''
+	 WRITE(*,*) '*** ROUTINE alloc_child_grid ***'
+	 WRITE(*,*) ''
+	 !
+	 !
+	 IF(rho>1) THEN
+	    q=1
+	    DO j=rho+2,(SIZE(Gmix%glam,2)-(rho)),2
+	    p=1
+	    DO i=rho+2,(SIZE(Gmix%glam,1)-(rho)),2
+		   !
+		   Grid1%nav_lon(p,q) = Gmix%nav_lon(i,j)
+		   Grid1%nav_lat(p,q) = Gmix%nav_lat(i,j)
+		   !
+		   Grid1%glamt(p,q) = Gmix%glam(i,j)
+		   Grid1%glamu(p,q) = Gmix%glam(i+1,j)
+		   Grid1%glamv(p,q) = Gmix%glam(i,j+1)
+		   Grid1%glamf(p,q) = Gmix%glam(i+1,j+1)
+		   !
+		   Grid1%gphit(p,q) = Gmix%gphi(i,j)
+		   Grid1%gphiu(p,q) = Gmix%gphi(i+1,j)
+		   Grid1%gphiv(p,q) = Gmix%gphi(i,j+1)
+		   Grid1%gphif(p,q) = Gmix%gphi(i+1,j+1)
+		   !
+		   Grid1%e1t(p,q) = Gmix%e1(i,j)
+		   Grid1%e1u(p,q) = Gmix%e1(i+1,j)
+		   Grid1%e1v(p,q) = Gmix%e1(i,j+1)
+		   Grid1%e1f(p,q) = Gmix%e1(i+1,j+1)
+		   !
+		   Grid1%e2t(p,q) = Gmix%e2(i,j)
+		   Grid1%e2u(p,q) = Gmix%e2(i+1,j)
+		   Grid1%e2v(p,q) = Gmix%e2(i,j+1)
+		   Grid1%e2f(p,q) = Gmix%e2(i+1,j+1)
+		   !		
+		   p=p+1
+		END DO
+		q=q+1
+	END DO
+ELSE
+	     q=1
+	    DO j=1,SIZE(Gmix%glam,2),2
+	    p=1
+	    DO i=1,SIZE(Gmix%glam,1),2
+		   !
+		   Grid1%nav_lon(p,q) = Gmix%nav_lon(i,j)
+		   Grid1%nav_lat(p,q) = Gmix%nav_lat(i+1,j)
+		   !
+		   Grid1%glamt(p,q) = Gmix%glam(i,j)
+		   Grid1%glamu(p,q) = Gmix%glam(i+1,j)
+		   Grid1%glamv(p,q) = Gmix%glam(i,j+1)
+		   Grid1%glamf(p,q) = Gmix%glam(i+1,j+1)
+		   !
+		   Grid1%gphit(p,q) = Gmix%gphi(i,j)
+		   Grid1%gphiu(p,q) = Gmix%gphi(i+1,j)
+		   Grid1%gphiv(p,q) = Gmix%gphi(i,j+1)
+		   Grid1%gphif(p,q) = Gmix%gphi(i+1,j+1)
+		   !
+		   Grid1%e1t(p,q) = Gmix%e1(i,j)
+		   Grid1%e1u(p,q) = Gmix%e1(i+1,j)
+		   Grid1%e1v(p,q) = Gmix%e1(i,j+1)
+		   Grid1%e1f(p,q) = Gmix%e1(i+1,j+1)
+		   !
+		   Grid1%e2t(p,q) = Gmix%e2(i,j)
+		   Grid1%e2u(p,q) = Gmix%e2(i+1,j)
+		   Grid1%e2v(p,q) = Gmix%e2(i,j+1)
+		   Grid1%e2f(p,q) = Gmix%e2(i+1,j+1)
+		   !		
+		p=p+1
+		END DO
+		q=q+1
+		END DO
+	   ENDIF
+	
+   WRITE(*,*) ''
+   WRITE(*,*) 'Size of the Child grid: ', nx_fine, ' x ', ny_fine
+   WRITE(*,*) ''	
+print*, 'Grid1%nav_lat= '
+DO j=1,ny_fine
+print*, Grid1%nav_lat(:,j)
+END DO    
+	 !
+	 END SUBROUTINE alloc_child_grid
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!             
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+END MODULE tools_brice
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/create_coordinates.f90
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/create_coordinates.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/create_coordinates.f90	(revision 1844)
@@ -0,0 +1,93 @@
+program create_coordinates
+!-----------------------------------------------------------
+!
+!	  to create coordinates file (e.g. 1_coordinates.nc)
+!    for fine grid from coarse grid (e.g. coordinates.nc)
+!
+!   to make it we use a 4th order polynomial interpolation
+!
+!	        Created by Brice Lemaire on 12/2009.
+!
+!-----------------------------------------------------------
+USE netcdf
+USE agrif_readwrite
+USE tools_brice
+!------------
+IMPLICIT NONE
+   !
+   TYPE(coordinates) :: G1, G2, G3, G4     !from agrif_types from agrif_readwrite
+   TYPE(coordinates) :: fine_grid
+   TYPE(mixed_coordinates) :: Gmix      !from agrif_types from agrif_readwrite
+   !INTEGER :: nxG1, nyG1, nxG2, nyG2, nxG3, nyG3, nxG4, nyG4
+   INTEGER :: narg,iargc
+   INTEGER :: status
+   CHARACTER(len=80) :: namelistname, Child_filename
+   !
+   !!!Read input file (namelist file)
+   narg = iargc()
+   !
+   IF (narg == 0) THEN
+	   namelistname = 'namelist.input'
+   ELSE
+	   CALL getarg(1,namelistname)
+   ENDIF
+   !
+   CALL read_namelist(namelistname)      !imin,imax,jmin,jmax,parent_coordinate_file
+   !
+   !!!Read parent coordinate file
+   IF((imin.LT.imax).AND.(jmin.LT.jmax)) THEN
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G1)      !from agrif_readwrite
+   ELSEIF((imin.GE.imax).AND.(jmin.LT.jmax)) THEN
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G1)      !from agrif_readwrite
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G2)      !from agrif_readwrite
+   ELSEIF((imin.GE.imax).AND.(jmin.GE.jmax)) THEN
+	  status = Read_Coordinates(TRIM(parent_coordinate_file),G1)      !from agrif_readwrite
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G2)      !from agrif_readwrite
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G3)      !from agrif_readwrite
+      status = Read_Coordinates(TRIM(parent_coordinate_file),G4)      !from agrif_readwrite
+   ENDIF
+   ! 
+   !
+   !!!Create the mixed grid with U,V,F & W values
+   IF((imin.LT.imax).AND.(jmin.LT.jmax)) THEN
+      CALL mixed_grid(G1,Gmix)
+   ELSEIF((imin.GE.imax).AND.(jmin.LT.jmax)) THEN
+      CALL mixed_grid(G1,G2,Gmix)
+   ELSEIF((imin.GE.imax).AND.(jmin.GE.jmax)) THEN
+      CALL mixed_grid(G1,G2,G3,G4,Gmix)      !from tools_brice
+   !ELSEIF()
+   ENDIF
+   
+   
+!print*, 'G1%nav_lat= '
+!DO j=jmin-1,jmax+1
+!print*, G1%nav_lat(imin-1:imax+1,j)
+!END DO  
+
+!print*, 'G1%nav_lon= '
+!DO j=jmin-1,jmax+1
+!print*, G1%nav_lon(imin-1:imax+1,j)
+!END DO 
+   !
+   !!!Interpolation inside the mixed grid
+   IF(rho>1) THEN
+      CALL interp_grid(Gmix)      !from tools_brice
+   ENDIF
+   !   
+   !!!Define name of child coordinate file
+   CALL set_child_name(parent_coordinate_file,Child_filename)      !coordinates.nc -> 1_coordinates.nc
+   !
+   !!!Allocation of child grid elements
+   CALL agrif_grid_allocate(fine_grid,nx_fine,ny_fine)      !from agrif_types
+   !
+   !!!Break the mixed grid Gmix into 4 grids (G1%u, G1%v, G1%t, GI%f)
+   CALL alloc_child_grid(Gmix,fine_grid)      !from tools_brice
+   !
+print*, 'fine_grid%glamf= '
+DO j=1,ny_fine
+print*, fine_grid%glamf(:,j)
+END DO 
+    !!!Read parent coordinate file
+   status = Write_Coordinates(Child_filename,fine_grid,nx_fine,ny_fine)      !from agrif_readwrite
+   !
+end program create_coordinates
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/io_netcdf.f90
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/io_netcdf.f90	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/io_netcdf.f90	(revision 1844)
@@ -0,0 +1,1815 @@
+!************************************************************************
+! Fortran 95 OPA Nesting tools						*
+!									*
+!     Copyright (C) 2005 Florian Lemari�(Florian.Lemarie@imag.fr)	*
+!									*
+!************************************************************************
+!
+!********************************************************************************
+!										*
+! module io_netcdf								*
+!										*
+! NetCDF Fortran 90 read/write interface					*
+! using input/output functions provided						*
+! by unidata									*
+!										*
+!http://my.unidata.ucar.edu/content/software/netcdf/docs/netcdf-f90/index.html	*
+!										*
+!********************************************************************************
+!
+!
+!
+MODULE io_netcdf
+  !      
+  USE netcdf
+  USE agrif_types
+  !      
+  INTERFACE Read_Ncdf_var
+     MODULE PROCEDURE Read_Ncdf_var1d_Real,   &
+          Read_Ncdf_var2d_Real,   &
+          Read_Ncdf_var2d_Real_bis,   &
+          Read_Ncdf_var3d_Real,   &
+          Read_Ncdf_var4d_Real,   &
+          Read_Ncdf_var3d_Real_t, &
+          Read_Ncdf_var4d_Real_t, &
+          Read_Ncdf_var4d_Real_nt, &
+          Read_Ncdf_var1d_Int,    &
+          Read_Ncdf_var2d_Int,    &
+          Read_Ncdf_var3d_Int,    &
+          Read_Ncdf_var4d_Int,    &
+          Read_Ncdf_var0d_Int,    &
+          Read_Ncdf_var0d_Real
+  END INTERFACE
+  !
+  INTERFACE Write_Ncdf_var
+     MODULE PROCEDURE Write_Ncdf_var1d_Real,   &
+          Write_Ncdf_var2d_Real,   &
+          Write_Ncdf_var3d_Real,   &
+          Write_Ncdf_var4d_Real,   &
+          Write_Ncdf_var3d_Real_t, &
+          Write_Ncdf_var4d_Real_t, &
+          Write_Ncdf_var4d_Real_nt, &                           
+          Write_Ncdf_var2d_Real_bis,&			   
+          Write_Ncdf_var1d_Int,    &
+          Write_Ncdf_var2d_Int,    &
+          Write_Ncdf_var3d_Int,    &
+          Write_Ncdf_var4d_Int,    &
+          Write_Ncdf_var0d_Real
+  END INTERFACE
+  ! 
+  INTERFACE Copy_Ncdf_att
+     MODULE PROCEDURE Copy_Ncdf_att_latlon,Copy_Ncdf_att_var
+  END INTERFACE
+  !
+CONTAINS
+  !
+  !****************************************************************
+  !   subroutine Read_Ncdf_dim					*
+  !								*
+  ! subroutine to retrieve value of a given dimension 		*
+  !								*
+  !     dimname : name of dimension to retrieve			*
+  !     file    : netcdf file name				*
+  !     dimval  : value of the required dimension			*
+  !								*
+  !****************************************************************
+  !
+  SUBROUTINE Read_Ncdf_dim(dimname,file,dimval)   
+    !      
+    IMPLICIT NONE
+    !           
+    CHARACTER(*),INTENT(in) :: dimname,file    
+    INTEGER    :: dimval
+    !            
+    ! local variables
+    !
+    INTEGER ncid,status,dimid
+    !     
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname,dimid)
+    status = nf90_inquire_dimension(ncid,dimid,len=dimval)						                
+    !      
+    status = nf90_close(ncid)
+    !      
+  END SUBROUTINE Read_Ncdf_dim
+  !
+  !**************************************************************
+  ! end subroutine Read_Ncdf_dim
+  !**************************************************************      
+  !
+  !****************************************************************
+  !   subroutine Write_Ncdf_dim					*
+  !								*
+  ! subroutine to write a dimension in a given file 		*
+  !								*
+  !     dimname : name of dimension to initialize			*
+  !     file    : netcdf file name				*
+  !     dimval  : value of the dimension to write			*
+  !								*
+  !****************************************************************
+  !
+  SUBROUTINE Write_Ncdf_dim(dimname,file,dimval)   
+    !      
+    IMPLICIT NONE
+    !           
+    CHARACTER(*),INTENT(in) :: dimname,file    
+    INTEGER    :: dimval
+    !      
+    ! local variables
+    !
+    INTEGER ncid,status,dimid
+    !     
+    status = nf90_open(file,NF90_WRITE,ncid)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_redef(ncid)
+    IF(dimval.EQ.0) THEN
+       status = nf90_def_dim(ncid,dimname,nf90_unlimited,dimid)       
+    ELSE
+       status = nf90_def_dim(ncid,dimname,dimval,dimid)  
+    END IF
+
+    status = nf90_enddef(ncid)
+    !      
+
+    status = nf90_close(ncid)
+    !      
+  END SUBROUTINE Write_Ncdf_dim
+  !
+  !**************************************************************
+  ! end subroutine Write_Ncdf_dim
+  !**************************************************************            
+  ! 
+  !****************************************************************
+  !   subroutine Read_Ncdf_var					*
+  !								*
+  ! subroutine to retrieve values of a given variable 		*
+  !								*
+  !     varname : name of variable to retrieve			*
+  !     file    : netcdf file name				*
+  !     tabvar  : array containing values of the required variable*
+  !								*
+  !****************************************************************
+  !          
+  !**************************************************************
+  !   subroutine Read_Ncdf_var1d_real
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var1d_Real(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8, DIMENSION(:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(1) :: dimID
+    INTEGER :: dim1
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimID)
+    status=nf90_inquire_dimension(ncid,dimID(1),len=dim1)
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1))  
+    ELSE
+       IF( ANY(SHAPE(tabvar)/=(/dim1/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1))      
+       ENDIF
+    ENDIF
+    !        
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Read_Ncdf_var1d_Real
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var1d_real
+  !**************************************************************          
+  !            
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var2d_real
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var2d_Real(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8, DIMENSION(:,:), POINTER :: tabvar
+    !local variables
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2))  
+    ELSE
+       IF( ANY(SHAPE(tabvar)/=(/dim1,dim2/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2))      
+       ENDIF
+    ENDIF
+    !       
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var2d_Real
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var2d_real
+  !**************************************************************          
+  !    
+
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var2d_real_bis
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var2d_Real_bis(varname,file,tabvar,strt,cnt)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8, DIMENSION(:,:), POINTER :: tabvar
+    !local variables
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER, DIMENSION(2) :: strt,cnt
+    INTEGER :: dim1,dim2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    dim1 = cnt(1) 
+    dim2 = cnt(2)
+    !      
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2))  
+    ELSE
+       IF( ANY(SHAPE(tabvar)/=(/dim1,dim2/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2))      
+       ENDIF
+    ENDIF
+    !       
+    status=nf90_get_var(ncid,varid,tabvar,start = strt,count = cnt)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var2d_Real_bis
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var2d_real_bis
+  !**************************************************************          
+  !  
+
+
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var3d_real
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var3d_Real(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2,dim3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)  
+    status=nf90_inquire_dimension(ncid,dimIDS(3),len=dim3)
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,dim3))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2,dim3/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2,dim3))      
+       ENDIF
+    ENDIF
+    !      
+    status=nf90_get_var(ncid,varid,tabvar) 
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to retrieve netcdf variable : ",TRIM(varname)
+       STOP
+    ENDIF
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var3d_Real
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var3d_real
+  !**************************************************************          
+  ! 
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var4d_real
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var4d_Real(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2,dim3,dim4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)  
+    status=nf90_inquire_dimension(ncid,dimIDS(3),len=dim3)   
+    status=nf90_inquire_dimension(ncid,dimIDS(4),len=dim4)       
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,dim3,dim4))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2,dim3,dim4/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2,dim3,dim4))      
+       ENDIF
+    ENDIF
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var4d_Real
+
+  SUBROUTINE Read_Ncdf_var0d_Real(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    REAL*8 :: tabvar
+    !
+    !local variables
+    !
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    !
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var0d_Real
+
+  SUBROUTINE Read_Ncdf_var0d_Int(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    !
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var0d_Int
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var4d_real
+  !**************************************************************          
+  !             
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var1d_int
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var1d_Int(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER, DIMENSION(:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER,DIMENSION(10) :: dimID
+    INTEGER :: dim1
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimID)
+    status=nf90_inquire_dimension(ncid,dimID(1),len=dim1)          
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1))      
+       ENDIF
+    ENDIF
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !      
+  END SUBROUTINE Read_Ncdf_var1d_Int
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var1d_int
+  !**************************************************************          
+  !            
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var2d_int
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var2d_Int(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER, DIMENSION(:,:), POINTER :: tabvar
+    !local variables
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)      
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2))      
+       ENDIF
+    ENDIF
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !      
+  END SUBROUTINE Read_Ncdf_var2d_Int
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var2d_Int
+  !**************************************************************          
+  !    
+
+  !           
+  !**************************************************************
+  !   subroutine Read_Ncdf_var3d_Int
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var3d_Int(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2,dim3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)  
+    status=nf90_inquire_dimension(ncid,dimIDS(3),len=dim3)          
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,dim3))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2,dim3/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2,dim3))      
+       ENDIF
+    ENDIF
+    ! 
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !      
+  END SUBROUTINE Read_Ncdf_var3d_Int
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var3d_int
+  !**************************************************************  
+  !
+  !
+  !
+  !**************************************************************
+  !   subroutine Read_Ncdf_var4d_int
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var4d_Int(varname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(10) :: dimIDS
+    INTEGER :: dim1,dim2,dim3,dim4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)  
+    status=nf90_inquire_dimension(ncid,dimIDS(3),len=dim3)   
+    status=nf90_inquire_dimension(ncid,dimIDS(4),len=dim4)       
+    !                
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,dim3,dim4))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2,dim3,dim4/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2,dim3,dim4))      
+       ENDIF
+    ENDIF
+    !  
+    status=nf90_get_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var4d_Int
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var4d_real
+  !**************************************************************         
+  !    
+  !
+  !****************************************************************
+  !   subroutine Write_Ncdf_var					*
+  !								*
+  ! subroutine to write a variable in a given file 		*
+  !								*
+  !     varname : name of variable to store			*     
+  !     dimname : name of dimensions of the given variable	*
+  !     file    : netcdf file name				*
+  !     tabvar  : values of the variable to write			*
+  !								*
+  !****************************************************************
+  !    
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var1d_real
+  !**************************************************************    
+  !      
+  SUBROUTINE Write_Ncdf_var1d_Real(varname,dimname,file,tabvar,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,dimname,typevar
+    REAL*8, DIMENSION(:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname, dimid)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    SELECT CASE(TRIM(typevar))
+    CASE('double')
+       status = nf90_def_var(ncid,varname,nf90_double,(/dimid/),varid)
+    CASE('float')
+       status = nf90_def_var(ncid,varname,nf90_float,(/dimid/),varid)      
+    END SELECT
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var1d_Real
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var1d_real
+  !**************************************************************
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var2d_real
+  !**************************************************************    
+  !      
+  SUBROUTINE Write_Ncdf_var2d_Real_bis(varname,dimname,file,tabvar,nbdim,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    INTEGER,INTENT(in) :: nbdim
+    CHARACTER(*), DIMENSION(4) :: dimname
+    REAL*8, DIMENSION(:,:) :: tabvar
+    REAL*8, DIMENSION(:,:,:),POINTER :: tabtemp3d
+    REAL*8, DIMENSION(:,:,:,:),POINTER :: tabtemp4d
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3,dimid4
+    INTEGER :: status,ncid,ncid2
+    INTEGER :: varid,varid2             
+    ! 
+    IF(nbdim==4) THEN      
+       ALLOCATE(tabtemp4d(SIZE(tabvar,1),SIZE(tabvar,2),1,1))
+       tabtemp4d(:,:,1,1) = tabvar(:,:)
+    ELSE IF(nbdim==3) THEN
+       ALLOCATE(tabtemp3d(SIZE(tabvar,1),SIZE(tabvar,2),1))
+       tabtemp3d(:,:,1) = tabvar(:,:)
+    END IF
+    !      
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+    !      
+    IF(nbdim==4) status = nf90_inq_dimid(ncid,dimname(4), dimid4)
+    !      
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    IF(nbdim==4 .AND. typevar == 'double') THEN
+       status = nf90_def_var(ncid,varname,nf90_double,     &
+            (/dimid1,dimid2,dimid3,dimid4/),varid)
+       !                              
+    ELSE IF(nbdim==4 .AND. typevar == 'float') THEN
+       status = nf90_def_var(ncid,varname,nf90_float,     &
+            (/dimid1,dimid2,dimid3,dimid4/),varid)                        
+       !          
+    ELSE IF(nbdim==3 .AND. typevar == 'float') THEN
+       status = nf90_def_var(ncid,varname,nf90_float,     &
+            (/dimid1,dimid2,dimid3/),varid)
+       !
+    ELSE IF(nbdim==3 .AND. typevar == 'double') THEN
+       status = nf90_def_var(ncid,varname,nf90_double,     &
+            (/dimid1,dimid2,dimid3/),varid)
+       !     			      			      
+    ENDIF
+    !      			      
+    status = nf90_enddef(ncid)
+    IF(nbdim==4) status = nf90_put_var(ncid,varid,tabtemp4d)
+    IF(nbdim==3) status = nf90_put_var(ncid,varid,tabtemp3d)
+    !      
+    IF(ASSOCIATED( tabtemp3d ) ) DEALLOCATE( tabtemp3d )   
+    IF(ASSOCIATED( tabtemp4d ) ) DEALLOCATE( tabtemp4d )     
+    !
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var2d_Real_bis
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var2d_real
+  !**************************************************************  
+  !   
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var2d_real
+  !**************************************************************    
+  !      
+  SUBROUTINE Write_Ncdf_var2d_Real(varname,dimname,file,tabvar,typevar)
+    !      
+    !      implicit none
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*), DIMENSION(2) :: dimname
+    REAL*8, DIMENSION(:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+
+    SELECT CASE(TRIM(typevar))
+    CASE('double')
+       status = nf90_def_var(ncid,varname,nf90_double,     &
+            (/dimid1,dimid2/),varid)
+    CASE('float')
+       status = nf90_def_var(ncid,varname,nf90_float,     &
+            (/dimid1,dimid2/),varid)     
+    END SELECT
+    !
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var2d_Real
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var2d_real
+  !**************************************************************  
+  !
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var3d_real
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var3d_Real(varname,dimname,file,tabvar,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*),DIMENSION(3),INTENT(in) :: dimname
+    REAL*8, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+
+    SELECT CASE(TRIM(typevar))
+    CASE('double')
+       status = nf90_def_var(ncid,varname,nf90_double,     &
+            (/dimid1,dimid2,dimid3/),varid)
+    CASE('float')
+       status = nf90_def_var(ncid,varname,nf90_float,     &
+            (/dimid1,dimid2,dimid3/),varid)    
+    END SELECT
+    !
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var3d_Real
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var3d_real
+  !**************************************************************
+  ! 
+  !
+  !**************************************************************
+  !   subroutine Write_Ncdf_var4d_real
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var4d_Real(varname,dimname,file,tabvar,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*),DIMENSION(4),INTENT(in) :: dimname
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3,dimid4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !
+    status = nf90_inq_varid(ncid,varname,varid)
+    !      
+    IF(status/=nf90_noerr) THEN
+       !     
+       status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+       status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+       status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+       status = nf90_inq_dimid(ncid,dimname(4), dimid4)
+       status = nf90_redef(ncid)
+       !      
+       SELECT CASE(TRIM(typevar))
+       CASE('double')
+          status = nf90_def_var(ncid,varname,nf90_double,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)
+       CASE('float')
+          status = nf90_def_var(ncid,varname,nf90_float,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)   
+       END SELECT
+       !
+       status = nf90_enddef(ncid)
+    ENDIF
+    !         
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var4d_Real
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var4d_real
+  !**************************************************************
+  !
+  !
+  !  
+  !**************************************************************
+  !   subroutine Write_Ncdf_var1d_Int
+  !**************************************************************    
+  !      
+  SUBROUTINE Write_Ncdf_var1d_Int(varname,dimname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,dimname
+    INTEGER, DIMENSION(:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    !           print *,'ici tabvar = ',tabvar,varname,dimname
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname, dimid)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    status = nf90_def_var(ncid,varname,nf90_int,(/dimid/),varid)
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var1d_Int
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var1d_Int
+  !**************************************************************
+  !  
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var2d_Int
+  !**************************************************************    
+  !      
+  SUBROUTINE Write_Ncdf_var2d_Int(varname,dimname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    CHARACTER(*), DIMENSION(2) :: dimname
+    INTEGER, DIMENSION(:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    status = nf90_def_var(ncid,varname,nf90_int,     &
+         (/dimid1,dimid2/),varid)
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var2d_Int
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var2d_Int
+  !**************************************************************  
+  ! 
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var3d_Int
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var3d_Int(varname,dimname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    CHARACTER(*),DIMENSION(3),INTENT(in) :: dimname
+    INTEGER, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    status = nf90_def_var(ncid,varname,nf90_int,     &
+         (/dimid1,dimid2,dimid3/),varid)
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var3d_Int
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var3d_Int
+  !**************************************************************
+  ! 
+  !
+  !**************************************************************
+  !   subroutine Write_Ncdf_var4d_Int
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var4d_Int(varname,dimname,file,tabvar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    CHARACTER(*),DIMENSION(4),INTENT(in) :: dimname
+    INTEGER, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3,dimid4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+    status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+    status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+    status = nf90_inq_dimid(ncid,dimname(4), dimid4)
+    status = nf90_inq_varid(ncid,varname,varid)
+    status = nf90_redef(ncid)
+    status = nf90_def_var(ncid,varname,nf90_int,     &
+         (/dimid1,dimid2,dimid3,dimid4/),varid)
+    status = nf90_enddef(ncid)
+    status = nf90_put_var(ncid,varid,tabvar)     
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var4d_Int
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var4d_Int
+  !************************************************************** 
+  !
+  !
+  !****************************************************************
+  !   subroutine Read_Ncdf_var_t					*
+  !								*
+  ! subroutine to read a variable in a given file for time t	*
+  !								*
+  !     varname : name of variable to read			*     
+  !     file    : netcdf file name				*
+  !     tabvar  : values of the read variable			*
+  !     time    : time corresponding to the values to read	*	
+  !								*
+  !****************************************************************
+  !
+  !
+  !**************************************************************
+  !   subroutine Read_Ncdf_var3d_real_t
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var3d_Real_t(varname,file,tabvar,time)
+    !      
+    USE agrif_types     
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER,INTENT(in) :: time
+    REAL*8, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(3) :: dimIDS
+    INTEGER :: dim1,dim2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    !        
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)
+    !
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,1))  
+    ELSE
+       IF( ANY(SHAPE(tabvar) /= (/dim1,dim2,1/)) ) THEN	   
+          DEALLOCATE(tabvar)   
+          ALLOCATE(tabvar(dim1,dim2,1))      
+       ENDIF
+    ENDIF
+
+    status=nf90_get_var(ncid,varid,tabvar,start=(/1,1,time/))
+
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to retrieve netcdf variable : ",TRIM(varname)
+       STOP
+    ENDIF
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var3d_Real_t
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var3d_real_t
+  !**************************************************************          
+  !
+  !
+  !
+  !****************************************************************
+  !   subroutine Write_Ncdf_var_t					*
+  !								*
+  ! subroutine to write a variable in a given file for time t	*
+  !								*
+  !     varname : name of variable to store			*     
+  !     dimname : name of dimensions of the given variable	*
+  !     file    : netcdf file name				*
+  !     tabvar  : values of the variable to write			*
+  !     time    : time corresponding to the values to store	*	
+  !								*
+  !****************************************************************
+  !
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var3d_real_t
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var3d_Real_t(varname,dimname,file,tabvar,time,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*),DIMENSION(3),INTENT(in) :: dimname
+    INTEGER :: time
+    REAL*8, DIMENSION(:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    IF(time==1) THEN
+       !      
+       status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+       status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+       status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+       status = nf90_redef(ncid)
+
+       !      
+       SELECT CASE(TRIM(typevar))
+       CASE('double')
+          status = nf90_def_var(ncid,varname,nf90_double,     &
+               (/dimid1,dimid2,dimid3/),varid) 
+       CASE('float')
+          status = nf90_def_var(ncid,varname,nf90_float,     &
+               (/dimid1,dimid2,dimid3/),varid)    
+       END SELECT
+       !
+       status = nf90_enddef(ncid)
+
+    ELSE
+       status = nf90_inq_varid(ncid, varname, varid)
+    ENDIF
+    !      
+    status = nf90_put_var(ncid,varid,tabvar,start=(/1,1,time/))
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to store variable ",varname, &
+	    " in file ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var3d_Real_t
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var3d_real_t
+  !**************************************************************
+  !
+  !
+  !****************************************************************
+  !   subroutine Read_Ncdf_var_t					*
+  !								*
+  ! subroutine to read a variable in a given file for time t	*
+  !						at level n	*
+  !     varname : name of variable to read			*     
+  !     file    : netcdf file name				*
+  !     tabvar  : values of the read variable			*
+  !     time    : time corresponding to the values to read	*	
+  !     level   : level corresponding to the values to read	*
+  !								*
+  !****************************************************************
+  !
+  !
+  !**************************************************************
+  !   subroutine Read_Ncdf_var4d_real_nt
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var4d_Real_nt(varname,file,tabvar,time,level)
+    !      
+    USE agrif_types     
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER,INTENT(in) :: time,level
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(4) :: dimIDS
+    INTEGER :: dim1,dim2
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    !        
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)
+    !
+    IF(.NOT. ASSOCIATED(tabvar)) THEN
+       ALLOCATE(tabvar(dim1,dim2,1,1))  
+    ELSE
+       IF ((SIZE(tabvar,1) /= dim1) .OR. (SIZE(tabvar,2) /= dim2)) THEN
+          DEALLOCATE(tabvar)
+          ALLOCATE(tabvar(dim1,dim2,1,1))
+       ENDIF
+    ENDIF
+    !
+    status=nf90_get_var(ncid,varid,tabvar,start=(/1,1,level,time/),count=(/dim1,dim2,1,1/))
+    !                                             
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to retrieve netcdf variable : ",TRIM(varname)
+       STOP
+    ENDIF
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var4d_Real_nt
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var4d_real_nt
+  !**************************************************************          
+  !
+  !
+  !**************************************************************
+  !   subroutine Read_Ncdf_var4d_real_t
+  !**************************************************************          
+  !      
+  SUBROUTINE Read_Ncdf_var4d_Real_t(varname,file,tabvar,time)
+    !      
+    USE agrif_types     
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file
+    INTEGER,INTENT(in) :: time
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    !local variables
+    !
+    INTEGER, DIMENSION(4) :: dimIDS
+    INTEGER :: dim1,dim2,dim3
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_NOWRITE,ncid)
+    !      
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !     
+    status = nf90_inq_varid(ncid,varname,varid)
+    !        
+    status=nf90_inquire_variable(ncid,varid,dimids=dimIDS)
+    status=nf90_inquire_dimension(ncid,dimIDS(1),len=dim1)
+    status=nf90_inquire_dimension(ncid,dimIDS(2),len=dim2)
+    status=nf90_inquire_dimension(ncid,dimIDS(3),len=dim3)
+    !
+    IF(.NOT. ASSOCIATED(tabvar)) ALLOCATE(tabvar(dim1,dim2,dim3,1))  
+    status=nf90_get_var(ncid,varid,tabvar,start=(/1,1,1,time/))
+
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to retrieve netcdf variable : ",TRIM(varname)
+       STOP
+    ENDIF
+    !     
+    status = nf90_close(ncid)
+    !     
+  END SUBROUTINE Read_Ncdf_var4d_Real_t
+  !           
+  !**************************************************************
+  ! end subroutine Read_Ncdf_var4d_real_t
+  !**************************************************************          
+  !
+  !
+  !****************************************************************
+  !   subroutine Write_Ncdf_var_t					*
+  !								*
+  ! subroutine to write a variable in a given file for time t	*
+  !						at level n	*
+  !     varname : name of variable to store			*     
+  !     dimname : name of dimensions of the given variable	*
+  !     file    : netcdf file name				*
+  !     tabvar  : values of the variable to write			*
+  !     time    : time corresponding to the values to store	*	
+  !     level   : level corresponding to the values to store	*
+  !								*
+  !****************************************************************
+  !
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var4d_real_t
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var4d_Real_t(varname,dimname,file,tabvar,time,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*),DIMENSION(4),INTENT(in) :: dimname
+    INTEGER :: time,level
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3,dimid4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !      
+    IF(time==1) THEN
+       !      
+       status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+       status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+       status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+       status = nf90_inq_dimid(ncid,dimname(4), dimid4)
+       status = nf90_redef(ncid)
+       !      
+       SELECT CASE(TRIM(typevar))
+       CASE('double')
+          status = nf90_def_var(ncid,TRIM(varname),nf90_double,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)  
+       CASE('float')
+          status = nf90_def_var(ncid,TRIM(varname),nf90_float,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)    
+       END SELECT
+       !
+       status = nf90_enddef(ncid)
+
+    ELSE
+       status = nf90_inq_varid(ncid, varname, varid)
+    ENDIF
+    !    
+    status = nf90_put_var(ncid,varid,tabvar,start=(/1,1,1,time/))
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to store variable ",varname, &
+	    " in file ",file
+       STOP
+    ENDIF
+    !    
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var4d_Real_t
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var4d_real_t
+  !**************************************************************
+  !
+  !      
+  !**************************************************************
+  !   subroutine Write_Ncdf_var4d_real_nt
+  !**************************************************************
+  !      
+  SUBROUTINE Write_Ncdf_var4d_Real_nt(varname,dimname,file,tabvar,time,level,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    CHARACTER(*),DIMENSION(4),INTENT(in) :: dimname
+    INTEGER :: time,level
+    REAL*8, DIMENSION(:,:,:,:), POINTER :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: dimid1,dimid2,dimid3,dimid4
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !      
+    IF(time==1.AND.level==1) THEN
+       !      
+       status = nf90_inq_dimid(ncid,dimname(1), dimid1)
+       status = nf90_inq_dimid(ncid,dimname(2), dimid2)
+       status = nf90_inq_dimid(ncid,dimname(3), dimid3)
+       status = nf90_inq_dimid(ncid,dimname(4), dimid4)
+       status = nf90_redef(ncid)
+       !      
+       SELECT CASE(TRIM(typevar))
+       CASE('double')
+          status = nf90_def_var(ncid,TRIM(varname),nf90_double,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)  
+       CASE('float')
+          status = nf90_def_var(ncid,TRIM(varname),nf90_float,     &
+               (/dimid1,dimid2,dimid3,dimid4/),varid)    
+       END SELECT
+       !
+       status = nf90_enddef(ncid)
+
+    ELSE
+       status = nf90_inq_varid(ncid, varname, varid)
+    ENDIF
+    !    
+    status = nf90_put_var(ncid,varid,tabvar,start=(/1,1,level,time/))
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to store variable ",varname, &
+	    " in file ",file
+       STOP
+    ENDIF
+    !    
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var4d_Real_nt
+
+  SUBROUTINE Write_Ncdf_var0d_Real(varname,file,tabvar,typevar)
+    !      
+    IMPLICIT NONE
+    !       
+    CHARACTER(*),INTENT(in) :: varname,file,typevar
+    INTEGER :: time,level
+    REAL*8 :: tabvar
+    !
+    ! local variables
+    !
+    INTEGER :: status,ncid
+    INTEGER :: varid             
+    !
+    status = nf90_open(file,NF90_WRITE,ncid)       
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",file
+       STOP
+    ENDIF
+    !      
+
+    status = nf90_redef(ncid)
+    !      
+    SELECT CASE(TRIM(typevar))
+    CASE('double')
+       status = nf90_def_var(ncid,TRIM(varname),nf90_double,     &
+            varid=varid)  
+    CASE('float')
+       status = nf90_def_var(ncid,TRIM(varname),nf90_float,     &
+            varid=varid)    
+    END SELECT
+    !
+    status = nf90_enddef(ncid)
+
+    !    
+    status = nf90_put_var(ncid,varid,tabvar)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to store variable ",varname, &
+	    " in file ",file
+       STOP
+    ENDIF
+    !    
+    status = nf90_close(ncid)
+    ! 
+  END SUBROUTINE Write_Ncdf_var0d_Real
+  !      
+  !**************************************************************
+  !   end subroutine Write_Ncdf_var4d_real_nt
+  !**************************************************************
+  !
+  !****************************************************************
+  !   subroutine Read_Ncdf_VarName				*
+  !								*
+  ! subroutine to retrieve of all variables 			*
+  ! included in a given file					*
+  !								*
+  !     filename    : netcdf file name				*
+  !     tabvarname  : array containing various variables names	*
+  !								*
+  !****************************************************************
+  !
+  !**************************************************************
+  !   subroutine Read_Ncdf_VarName
+  !**************************************************************          
+  !
+  SUBROUTINE Read_Ncdf_VarName(filename,tabvarname)
+    !      
+    CHARACTER(*),INTENT(in) :: filename
+    CHARACTER*20,DIMENSION(:),POINTER :: tabvarname
+    INTEGER :: nDimensions,nVariables
+    INTEGER :: nAttributes,unlimitedDimId,i
+    INTEGER :: ncid,status,dimid
+    !     
+    status = nf90_open(filename,NF90_NOWRITE,ncid)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",filename
+       STOP
+    ENDIF
+    !      
+    status = nf90_inquire(ncid,nDimensions,nVariables,nAttributes, &                                                      
+         unlimitedDimId) 
+    !
+    ALLOCATE(tabvarname(nVariables))
+    !
+    DO i=1,nVariables
+       status = nf90_inquire_variable(ncid,i,tabvarname(i))
+    END DO
+
+  END SUBROUTINE Read_Ncdf_Varname
+  !
+  !**************************************************************
+  !   end subroutine Read_Ncdf_VarName
+  !**************************************************************          
+  !
+  !**************************************************************
+  !   subroutine Copy_Ncdf_att
+  !**************************************************************          
+  !
+  SUBROUTINE Copy_Ncdf_att_var(varname,filein,fileout)
+    !      
+    CHARACTER(*),INTENT(in) :: filein,fileout
+    CHARACTER(*),INTENT(in) :: varname
+    INTEGER :: ncid_in,ncid_out,status,varid_in,varid_out
+    !     
+    !      print *,'filein = ',filein,fileout
+    status = nf90_open(filein,NF90_NOWRITE,ncid_in)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open input netcdf file : ",filein
+       STOP
+    ENDIF
+    !     							     	   
+    status = nf90_open(fileout,NF90_WRITE,ncid_out)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open output netcdf file : ",fileout
+       STOP
+    ENDIF
+    !  
+    !      print *,'ici1'
+    status = nf90_inq_varid(ncid_in,varname,varid_in)
+    status = nf90_inq_varid(ncid_out,varname,varid_out)
+    !
+    status = nf90_redef(ncid_out)
+    !      
+    status = nf90_copy_att(ncid_in,varid_in,'units',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'valid_min',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'valid_max',ncid_out,varid_out) 
+    status = nf90_copy_att(ncid_in,varid_in,'long_name',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'calendar',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'title',ncid_out,varid_out)     
+    status = nf90_copy_att(ncid_in,varid_in,'time_origin',ncid_out,varid_out) 
+    status = nf90_copy_att(ncid_in,varid_in,'positive',ncid_out,varid_out)                 
+    status = nf90_copy_att(ncid_in,varid_in,'tstep_sec',ncid_out,varid_out)          
+    status = nf90_copy_att(ncid_in,varid_in,'nav_model',ncid_out,varid_out)   
+    status = nf90_copy_att(ncid_in,varid_in,'Minvalue=',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'Maxvalue=',ncid_out,varid_out)  
+    status = nf90_copy_att(ncid_in,varid_in,'short_name',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'online_operation',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'axis',ncid_out,varid_out)            
+    status = nf90_copy_att(ncid_in,varid_in,'interval_operation',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'interval_write',ncid_out,varid_out) 
+    status = nf90_copy_att(ncid_in,varid_in,'associate',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'actual_range',ncid_out,varid_out) 
+    status = nf90_copy_att(ncid_in,varid_in,'longitude',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'latitude',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'scale_factor',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'add_offset',ncid_out,varid_out)
+    status = nf90_copy_att(ncid_in,varid_in,'missing_value',ncid_out,varid_out) 
+    !      
+    status = nf90_enddef(ncid_out)  
+    !
+    status = nf90_close(ncid_in)
+    status = nf90_close(ncid_out)
+    !      print *,'ici2'
+    ! 
+  END SUBROUTINE Copy_Ncdf_att_var
+  !
+  !**************************************************************
+  !   end subroutine Copy_Ncdf_att
+  !**************************************************************         
+  !**************************************************************
+  !   subroutine Copy_Ncdf_att
+  !**************************************************************          
+  !
+  SUBROUTINE Copy_Ncdf_att_latlon(varname,filein,fileout,min,max)
+    !      
+    CHARACTER(*),INTENT(in) :: filein,fileout
+    CHARACTER(*),INTENT(in) :: varname
+    REAL*8 :: min,max
+    INTEGER :: ncid_in,ncid_out,status,varid_in,varid_out
+    !     
+    status = nf90_open(filein,NF90_NOWRITE,ncid_in)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",filein
+       STOP
+    ENDIF
+    !     							     	   
+    status = nf90_open(fileout,NF90_WRITE,ncid_out)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",fileout
+       STOP
+    ENDIF
+    !  
+    status = nf90_inq_varid(ncid_in,varname,varid_in)
+    status = nf90_inq_varid(ncid_out,varname,varid_out)
+    !
+    status = nf90_redef(ncid_out)
+    !      
+    SELECT CASE (varname)
+       !      
+    CASE('nav_lon')     
+       status = nf90_copy_att(ncid_in,varid_in,'units',ncid_out,varid_out) 
+       status = nf90_put_att(ncid_out,varid_out,'valid_min',REAL(min,4))
+       status = nf90_put_att(ncid_out,varid_out,'valid_max',REAL(max,4))
+       status = nf90_copy_att(ncid_in,varid_in,'long_name',ncid_out,varid_out)
+       status = nf90_copy_att(ncid_in,varid_in,'nav_model',ncid_out,varid_out)
+       status = nf90_copy_att(ncid_in,varid_in,'title',ncid_out,varid_out)
+       !
+    CASE('nav_lat')
+       status = nf90_copy_att(ncid_in,varid_in,'units',ncid_out,varid_out) 
+       status = nf90_put_att(ncid_out,varid_out,'valid_min',REAL(min,4))
+       status = nf90_put_att(ncid_out,varid_out,'valid_max',REAL(max,4))
+       status = nf90_copy_att(ncid_in,varid_in,'long_name',ncid_out,varid_out)
+       status = nf90_copy_att(ncid_in,varid_in,'nav_model',ncid_out,varid_out)
+       status = nf90_copy_att(ncid_in,varid_in,'title',ncid_out,varid_out) 
+       !
+    END SELECT
+    !      
+    status = nf90_enddef(ncid_out)  
+    !
+    status = nf90_close(ncid_in)
+    status = nf90_close(ncid_out)
+  END SUBROUTINE Copy_Ncdf_att_latlon
+  !*************************************************************
+  !**************************************************************
+  !**************************************************************
+  !   function Get_NbDims
+  !**************************************************************          
+  !
+  INTEGER FUNCTION Get_NbDims( varname , filename )
+    !
+    CHARACTER(*),INTENT(in) :: varname,filename
+    INTEGER :: status,ncid,varid    
+    !      
+    status = nf90_open(TRIM(filename),NF90_NOWRITE,ncid)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",TRIM(filename)
+       STOP
+    ENDIF
+    status = nf90_inq_varid(ncid,TRIM(varname),varid)     
+    status = nf90_inquire_variable(ncid, varid , ndims = Get_NbDims)
+    !
+    RETURN
+    !
+  END FUNCTION Get_NbDims
+  !
+  !*************************************************************
+  !**************************************************************
+  !   function Get_NbDims
+  !**************************************************************          
+  !
+  LOGICAL FUNCTION Dims_Existence( dimname , filename )
+    !
+    CHARACTER(*),INTENT(in) :: dimname,filename
+    INTEGER :: status,ncid,dimid    
+    !      
+    status = nf90_open(TRIM(filename),NF90_NOWRITE,ncid)
+    IF (status/=nf90_noerr) THEN    
+       WRITE(*,*)"unable to open netcdf file : ",TRIM(filename)
+       STOP
+    ENDIF
+    status = nf90_inq_dimid(ncid,dimname,dimid)
+    !      
+    IF (status/=nf90_noerr) THEN
+       Dims_Existence = .FALSE.
+    ELSE
+       Dims_Existence = .TRUE.
+    ENDIF
+    !
+    RETURN
+    !
+  END FUNCTION Dims_Existence
+  !
+  !*************************************************************
+  !**************************************************************
+END MODULE io_netcdf
Index: /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/namelist
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/namelist	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/CFG_TOOLS/namelist	(revision 1844)
@@ -0,0 +1,95 @@
+&input_output
+    iom_activated = true 
+/
+
+&coarse_grid_files    
+    parent_coordinate_file = 'coordinates_ORCA_R05.nc'
+    parent_bathy_level    = 'bathy_level.nc'  
+/    
+    
+&bathymetry    
+! new_topo = true
+    new_topo = false
+    elevation_database = 'bathymetry_meter_ORCA_R05.nc'
+    smoothing = true
+    smoothing_factor = 0.6
+    nb_connection_pts = 3    
+    removeclosedseas = true
+    type_bathy_interp = 0 
+/   
+
+&nesting    
+    imin = 722
+    imax = 3
+    jmin = 50
+    jmax = 52
+    rho  = 2
+								
+    rhot = 2
+    bathy_update = true
+    updated_parent_file = 'bathy_updated.nc'				
+/
+
+&vertical_grid    
+    ppkth = 21.4333619793800
+    ppacr = 3
+    ppdzmin = 0
+    pphmax  = 0
+    psur = -4762.96143546300
+    pa0  = 255.58049070440
+    pa1  = 245.58132232490
+    N  = 31
+/    
+    
+&partial_cells    	
+    partial_steps = true
+    parent_bathy_meter = 'bathy_meter.nc'
+    e3zps_min = 25.
+    e3zps_rat = 0.2
+/
+
+&nemo_coarse_grid    
+    jpizoom = 1			
+    jpjzoom = 1			
+/
+&forcing_files		   
+    U_FILES = taux_1m.nc
+!'dyna_grid_U.nc'                              ! needed for Offline
+    V_FILES =  tauy_1m.nc
+!'dyna_grid_V.nc'                              ! needed for Offline
+    FLX_FILES = 
+    'data_1m_salinity_nomask.nc',
+    'data_1m_potential_temperature_nomask.nc',
+    'flx.nc',
+    'geothermal_heating.nc'
+!    'river.orca.nc ',                         ! needed for Pisces
+!    'ndeposition.orca.nc',                    ! needed for Pisces 
+!    'dust.orca.nc',                           ! needed for Pisces 
+!    'bathy.orca.nc'                           ! needed for Pisces
+!'dyna_grid_T.nc',                             ! needed for Offline
+!'dyna_grid_W.nc'                              ! needed for Offline 
+/
+
+&interp
+    VAR_INTERP =
+    'votemper/bicubic',
+    'vosaline/bicubic'
+!    'dust/bilinear',
+!    'riverdic/bilinear',
+!    'riverpoc/bilinear',
+!    'riverdoc/bilinear',
+!    'nedep/bilinear',
+!    'bathy/bilinear'
+/
+
+&restart
+    restart_file = 'restart.nc'   
+    shlat = 0
+    dimg = false
+    dimg_output_file = 'test_dimg'
+    adatrj = 360.25 
+    interp_type = 'bilinear'
+/ 
+&restart_trc
+    restart_trc_file = 'restart_trc.nc'   
+/ 
Index: /branches/DEV_r1837_MLF/UTIL/chk_iomput.sh
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/chk_iomput.sh	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/chk_iomput.sh	(revision 1844)
@@ -0,0 +1,95 @@
+#!/bin/bash
+#------------------------------------------------
+#$Id$
+#------------------------------------------------
+#
+set -u
+#
+inxml=0
+insrc=0
+xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
+srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
+while [ $# -gt 0 ]   # Until you run out of parameters . . . 
+do    
+    case "$1" in 
+        --inxml) inxml=1 ;;
+        --insrc) insrc=1 ;;
+	*) xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
+	   srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
+	   shift
+    esac
+    shift       # Check next set of parameters. 
+done 
+#
+#------------------------------------------------
+#
+[ $inxml -eq 1 ] && grep "< *field * id *=" $xmlfile
+[ $insrc -eq 1 ] && find $srcdir -name "*.[Ffh]90" -exec grep -iH "^[^\!]*call  *iom_put *(" {} \;
+[ $(( $insrc + $inxml )) -ge 1 ] && exit
+#
+#------------------------------------------------
+#
+# list of file containing "CALL iom_put" in $srcdir
+#
+srclist=$( find $srcdir -name "*.[Ffh]90" -exec grep -il "^[^\!]*call  *iom_put *(" {} \; )
+#
+# list of variables used in "CALL iom_put"
+#
+varlistsrc=$( find $srcdir -name "*.[Ffh]90" -exec grep -i  "^[^\!]*call  *iom_put *(" {} \; | sed -e "s/.*iom_put *( *[\"\']\([^\"\']*\)[\"\'] *,.*/\1/" | sort -d )
+#
+# list of variables defined in the xml file
+#
+varlistxml=$( grep "< *field * id *=" $xmlfile  | sed -e "s/^.*< *field * id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+# list of variables to be outputed in the xml file
+#
+varlistout=$( grep "< *field * ref *=" $xmlfile  | sed -e "s/^.*< *field * ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+echo "--------------------------------------------------"
+echo  check if all iom_put found in $srcdir
+echo  have a corresponding variable definition in $xmlfile
+echo "--------------------------------------------------"
+for var in $varlistsrc
+do
+    tst=$( echo " "$varlistxml" " | grep -c " $var " )
+    if [ $tst -ne 1 ] 
+    then
+	echo "$tst problem with $var, defined in"
+	for f in $srclist
+	do
+	    grep -iH "^[^\!]*call  *iom_put *( *[\"\']${var}[\"\'] *," $f
+	done
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  check if all variables defined in $xmlfile
+echo  have a corresponding \"call iom_put\" in sources found in $srcdir
+echo "--------------------------------------------------"
+#
+for var in $varlistxml
+do
+    found=$( echo " "$varlistsrc" " | grep -c " $var " )
+    if [ $found -eq 0 ] 
+    then
+	echo \"call iom_put\" not found for variable $var
+	grep "< *field * id *= *[\"\']${var}[\"\']" $xmlfile
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  ${xmlfile}: check if all variables to be outputed in files are really defined...
+echo "--------------------------------------------------"
+#
+# list of variables defined in the xml file
+for var in $varlistout
+do
+    found=$( echo " "$varlistxml" " | grep -c " $var " )
+    [ $found -eq 0 ] && echo variable to be outputed but not defined: $var 
+done
+
+
+
+exit
Index: /branches/DEV_r1837_MLF/UTIL/fait_AA_make
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/fait_AA_make	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/fait_AA_make	(revision 1844)
@@ -0,0 +1,612 @@
+#!/bin/ksh
+#set -vx
+############################################################
+#
+# Purpose :
+# This script aims to create create the AA_make file
+# in the WORK directory. 
+# AA_make contains :
+#    - compilation options speccific to NEMO
+#    - compilation rules
+#    - dependancies
+# Running the modipsl/util/ins_make command is needed AFTER
+# fait_AA_make.
+#
+# Method :
+# We use temporary files to perform the following steps :
+#    1- search all CPP keys in the code
+#    2- write compilation rules 
+#    3- add compilation options add the beginning of AA_make 
+#    4- search and write dependancies
+#    5- add some specific rules (links creation in the WORK)
+#
+# Modification : - add F_F for .F file compiler option on aix
+#                - add KEY_CPP dependancy for source containing 
+#                              only #if defined CPP statement
+#
+############################################################
+#-
+echo "This script must be run while in the modipsl/modeles/NEMO directory"
+cd WORK || exit
+pwd
+
+# Test version of echo
+stringtest=`echo "\c"`
+if [ "$stringtest" ]; then
+   echo 'aliasing echo with /bin/echo -e ...'
+   alias echo='echo -e'
+fi
+
+#-
+#- Search CPP keys ---
+liste_cle=$(egrep '^# *if[!( &]*def|^# *elif' *.[Fh] *.[Fh]90  2> /dev/null | grep key_ | sed 's/||/\
+/' | sed 's/\&\&/\
+/' | sed 's/^.*key_/key_/' | sed 's/ *[) ] *$//' | sort -u  )
+
+#-
+#- Write main compilation rules ---
+cat > tampon <<end
+
+.SUFFIXES: .f90 .F90 .F
+
+# Target
+all: 		diroce \$(EXEC_BIN)
+		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
+		@echo OPA model is OK
+# Cleaning objects, libraries and executables
+clean:
+ifeq (\$(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
+		\$(RM) model.o \$(MODDIR)/oce/*.mod \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN)
+		@echo OPA model \(.o .mod libraries and executables are removed\)
+
+# Dependancies
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+\$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif key keyverif src_file_list libagrif \$(MODEL_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) agrif2model.o model.o 
+ifeq (\$(AGRIF),use)
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o agrif2model.o \$(SXMODEL_LIB) \$(USER_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
+else
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o \$(SXMODEL_LIB) \$(USER_LIB) \$(IOIPSL_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq (\$(IOSERVER),use)
+ifeq (\$(FCM),use)
+	(cd ../../XMLF90; ./configure -arch \$(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch \$(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; \$(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; \$(M_K) -f Makefile P_P="\$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :
+ifeq (\$(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; \$(M_K) -f Makefile P_P="\$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq (\$(AGRIF),use)
+	@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+	@\$(F_C) \\
+#-Q- aix		-qsuffix=f=F90 \\
+#-Q- aix6		-qsuffix=f=F90 \\
+#-Q- babel		-qsuffix=f=F90 \\
+#-Q- osxxlf		-qsuffix=f=F90 \\
+	\$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- aix		-qsource \\
+#-Q- babel		-qsource \\
+	   OPAFILES/\$*.F90 || { mv \$(PREF).L \$(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- es2			@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; \$(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@\$(F_C) \$(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : \$(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : \$(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : \$(SXMODEL_LIB)
+
+# library dependancies
+\$(MODEL_LIB):	\$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.f90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- es2		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+		@\$(A_C) \$(MODEL_LIB) \$*.o  > /dev/null
+		@\$(RM) \$*.[of]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce ; fi
+#-Q- aix		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq (\$(AGRIF),use) 
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \\
+#-Q- linux		-SubloopScalar \\
+#-Q- g95			-SubloopScalar \\
+#-Q- f95			-SubloopScalar \\
+#-Q- osf1			-SubloopScalar \\
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile \$*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC OPAFILES/\$*.F90 > OPAFILES/AGRIF_MODELFILES/\$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		OPAFILES/\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; } 
+else
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- es2		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- es2		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+		@\$(A_C) \$(MODEL_LIB) \$*.o  > /dev/null
+		@\$(RM) \$*.[of]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce ; fi
+#-Q- aix		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+end
+#-
+#- Compilation options ---
+exec 1> AA_make
+MAIN="model"
+echo '# $Header$'
+echo '# some variables'
+echo 'TMP = ../../../tmp'
+echo ''
+echo '#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function'
+echo '#          This doesnt happen whith Fortran 90 compilers but'
+echo '#          Check your compilers option in consequence when using real F95 compilers'
+echo ''
+echo '#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) '
+echo '#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) '
+echo '#-Q- platine L_X = $(L_O) '
+echo '#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) '
+echo '#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 shape=10000000 -L transform' -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) '
+echo '#-Q- sx8mercure  L_X = $(L_O)'
+echo '#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) '
+echo '#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 shape=10000000 -L transform' -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) '
+echo '#-Q- sx9mercure  L_X = $(L_O)'
+echo '#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) '
+echo '#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sx8brodie  L_X = $(L_O)'
+echo '#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) '
+echo '#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sxdkrz  L_X = $(L_O) -ftrace'
+echo '#-Q- es2  # Compiler options for NEMO (Earth Simulator)'
+echo '#-Q- es2  # for super perfs!'
+echo '#-Q- es2  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- es2  # regular options!'
+echo '#-Q- es2  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- es2  L_X = $(L_O)'
+echo '#-Q- linux  # Compiler options for NEMO (pgf version)'
+echo '#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- linux  L_X = -r8 -O3'
+echo '#-Q- lxiv7  # Compiler options for NEMO (ifc version)'
+echo '#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- lxiv7  L_X = -r8 -O3'
+echo '#-Q- lxiv8  # Compiler options for NEMO (ifort version)'
+echo '#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- lxiv8  L_X = -r8 -O3'
+echo '#-Q- g95  # Compiler options for NEMO (g95 version)'
+echo '#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- g95  L_X = -r8 -O3'
+echo '#-Q- gfortran  # Compiler options for NEMO (gfortran version)'
+echo '#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- gfortran  L_X = -fdefault-real-8'
+echo '#-Q- aix    # Compiler options for NEMO (aix version)'
+echo '#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- aix   L_O = $(F_P) -q64 -O3'
+echo '#-Q- aix   L_X = $(L_O)'
+echo '#-Q- aix6    # Compiler options for NEMO (aix6 version)'
+echo '#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- aix6   L_O = $(F_P) -q64 -O3'
+echo '#-Q- aix6   L_X = $(L_O)'
+echo '#-Q- babel  # Compiler options for NEMO (blue gene version)'
+echo '#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- babel  L_X = $(L_O)'
+echo '#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)'
+echo '#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- osxxlf    L_X = -qrealsize=8 -O3'
+
+echo 'PREF='
+echo '#-Q- sx8mercure	PREF=i.'
+echo '#-Q- sx9mercure	PREF=i.'
+echo '#-Q- sx8brodie	PREF=i.'
+echo '#-Q- sxdkrz	PREF=i.'
+echo '#-Q- es2	PREF=i.'
+echo ''
+echo '# add suffix to P_P'
+echo 'override P_P := $(P_P:%=$(prefix)%)'
+echo ''
+echo '# Some tests to define variables related to Agrif compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_agrif,$(P_P)))'
+echo 'AGRIF=use'
+echo 'else'
+echo 'AGRIF=notuse'
+echo 'AGRIF_LIB='
+echo 'endif'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'AGRIF_MPI=-DAGRIF_MPI'
+echo 'else'
+echo 'AGRIF_MPI='
+echo 'endif'
+echo ''
+echo '# Some tests to define variables related to xmlioserver compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_iomput,$(P_P)))'
+echo 'IOSERVER=use'
+echo 'override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90'
+echo 'override USER_INC += -I../../../lib/libxmlio_server'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'IOSERVER_MPI='
+echo 'else'
+echo 'IOSERVER_MPI=-DNO_MPI'
+echo 'endif'
+echo 'else'
+echo 'IOSERVER=notuse'
+echo 'endif'
+echo ''
+
+echo '# A variables related to xmlioserver compilationi (fcm or AA_make)'
+echo '# Please do not change '
+echo 'override FCM ?= notuse'
+echo ''
+
+echo '#check key compatibility'
+echo 'keycompat=$(if $(word 2, $(findstring $1,$(P_P)) $(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))'
+
+echo ''
+# Write the cpp key list with one key by line
+echo 'KEY_LIST = \c'
+for i in ${liste_cle}
+do
+ echo "\\"
+ echo "     $i \c"
+done
+
+echo ''
+echo '# .o file list in the library'
+echo 'LIB_OBJ = \c'
+#
+# find all .f90 in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.f90  `
+do
+  bn=`basename $i .f90`
+  if [ "${bn}" != "${MAIN}" ] 
+  then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
+    echo "\\"
+    echo "		\$(MODEL_LIB)($bn.o)\c"
+  fi
+  fi
+done
+
+# find all .F90 in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.F90  `
+do
+  bn=`basename $i .F90`
+  if [ "${bn}" != "${MAIN}" ] 
+  then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
+    echo "\\"
+    echo "		\$(MODEL_LIB)($bn.o)\c"
+  fi
+  fi
+done
+
+echo ""
+
+cat tampon
+rm tampon
+#-
+#- Write all dependancies ---
+
+for fic in `ls *.f90 *.F90  *.F 2> /dev/null `
+do
+    if [ "${fic}" != "agrif2model.F90" ]
+    then
+    if [ "${fic}" != "${MAIN}.[Ff]" ]
+    then
+	i=0
+	j=0
+	dep=""
+	inc=""
+	inc2=""
+	inc3=""
+	luse0=""
+	luse1=""
+	luse2=""
+	luse3=""
+        key=""
+#- search include files (old ice model form, should it be suppressed ?)
+	for inc in `sed -n 's/^[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+	    dep="$dep\n$inc"
+	done
+
+#- take into account CPP dependancies  keys only (par_trc_trp example)
+	for key in `sed -n 's/^#[ 	eElL]*[iF][fF][ 	]*[dD][eE][fF][iI][nN][eE][dD][ 	]*//p' $fic | sort -u`
+	do
+	    j=1
+	done
+
+#- search include files on 3 levels
+	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+	    j=1
+	    dep="$dep\n$inc"
+		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
+		do
+		    dep="$dep\n$inc2"
+		    #- search include  in include (third level !!!)
+		    for inc3 in `sed -n 's/^#[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc2 | sort -u`
+		    do
+			dep="$dep\n$inc3"
+		    done
+		done
+	done
+
+#- search USE in include files
+	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
+	do
+		for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc | sort -u`
+		do
+                    [ -f $fuse0.[hfF]90 ] || continue
+		    lfuse0=$fuse0.f90
+		    [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		    luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
+		done
+
+#- search USE in  files included in included files and add to luse0
+
+		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
+		do
+		    for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc2 | sort -u`
+		    do
+                        [ -f $fuse0.[hfF]90 ] || continue
+		        lfuse0=$fuse0.f90
+		        [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		        luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
+		    done
+  	        done
+	done
+
+#- search USE (and USE of USE and so on three levels)
+	for fuse1 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $fic | sort -u`
+	do
+            [ -f $fuse1.[hfF]90 ] || continue
+	    lfuse1=$fuse1.f90
+	    [ -f $fuse1.F90 ] && lfuse1=$fuse1.F90
+	    luse1="$luse1\n$lfuse1\n\$(MODEL_LIB)($fuse1.o)"
+		for fuse2 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse1 | sort -u`
+		do
+                    [ -f $fuse2.[hfF]90 ] || continue
+		    lfuse2=$fuse2.f90
+		    [ -f $fuse2.F90 ] && lfuse2=$fuse2.F90
+		    luse2="$luse2\n$lfuse2\n\$(MODEL_LIB)($fuse2.o)"
+		    # on cherche les USE  dans le fichier deja USE (3eme niveau! balaise!)
+		    for fuse3 in `sed -n 's/^#[  	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse2 | sort -u`
+		    do
+                        [ -f $fuse3.[hfF]90 ] || continue
+			luse3="$luse3\n$lfuse3\n\$(MODEL_LIB)($fuse3.o)"
+                    done
+		done
+	done
+#-
+#-  dep contains all dependancies 
+	echo "\$(MODEL_LIB)(`echo $fic|awk -F. '{print $1}'`.o) :	\c"
+	for depele in `echo $luse3 | sort -u` `echo $luse2 | sort -u` `echo $luse1 | sort -u` `echo $luse0 | sort -u` `echo $dep | sort -u`
+	do
+	    echo "\\"
+ 	    echo "	$depele \c"
+ 	    let i=i+1 # pour signaler le premier
+	done
+
+#-
+#- add dependancies with IOIPSL library (if source files contains IOIPSL)
+        grep -i 'use *ioipsl' ${fic} >/dev/null && ( echo "\\" ; echo "	\$(IOIPSL_LIB) \c")
+
+#-
+#- add dependancies with IOIPSL library (if source files contains Agrif_*)
+        grep -i 'use Agrif_*' ${fic} >/dev/null && ( echo "\\" ; echo "	\$(AGRIF_LIB) \c")
+
+#-
+#- add dependancies with KEY_CPP (if source file includes cpp  keys)
+	if [ ${j} != "0" ] 
+        then 
+	  echo "\\"
+	  echo "	KEY_CPP \c" 
+	fi
+#-
+#- end with the file itself
+	     echo "\\"
+       	     echo "	$fic"
+    fi
+    fi
+echo $fic done >/dev/tty
+done
+#-
+#- Write some special rules ---
+echo '# agrif previous use'
+echo "firstagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo '	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "else"
+echo '	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "endif"
+#-
+echo '#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp'
+echo '#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC'
+echo '# recompile all in this case' 
+echo "mpiagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo "ifeq (,\$(AGRIF_MPI))"
+echo '	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "endif"
+echo "endif"
+#-
+echo '# key changing control'
+echo "key: "
+echo "	@echo CHANGE of CPP KEYS yes/no ?"
+echo "	-@if [ \"\`cat KEY_CPP\`\" != \"\$(P_P:\$(prefix)%=%)\" ] ; then \\"
+echo "		echo CPP options changed ; echo \"\$(P_P:\$(prefix)%=%)\" > KEY_CPP ; fi "
+#-
+echo '# check key values'
+echo "keyverif:"
+echo '	@echo CHECKING KEY'
+echo '	@echo KEY USED : '
+echo '	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \'
+echo '	do \'
+echo '	echo $$v ;\'
+echo '        w=`echo $$v | cut -c1-3` ; \'
+echo '        if [ $$w = `echo "key"` ] ; then \'
+echo '        r=n ; \'
+echo '        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \'
+echo '           if [ $$r != "n" ] ; then \'
+echo '              echo "UNKNOWN KEY" ;\'
+echo '              false ;  \'
+echo '              exit ;  \'
+echo '           fi \'
+echo '        fi \'
+echo '	done'
+echo '# Checking the number of routines'
+echo "src_file_list: "
+echo '	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES '
+echo '	@$(RM) `ls | fgrep -v -f .patron` '
+echo '	@check=`grep OPA_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OPA_SRC files"                ; \'
+echo '	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \'
+echo '	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_3 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_3 files"                ; \'
+echo '      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_2 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_2 files"                ; \'
+echo '      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep C1D_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use C1D_SRC files"                ; \'
+echo '      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep TOP_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then  \'
+echo '	echo "   use TOP_SRC files"                ; \'
+echo '      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep OFF_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OFF_SRC files"                ; \'
+echo '      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../OFF_SRC/*/*.[Ffh]90        . ; \'
+echo '  fi '
+echo '	@check=`grep NST_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use NST_SRC files"                ; \'
+echo '      \$(RM) agrif_opa_interp.F90           ; \'
+echo '      \$(RM) agrif_opa_sponge.F90           ; \'
+echo '      \$(RM) agrif_opa_update.F90           ; \'
+echo '      \$(RM) agrif_top_interp.F90           ; \'
+echo '      \$(RM) agrif_top_sponge.F90           ; \'
+echo '      \$(RM) agrif_top_update.F90           ; \'
+echo '      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \'
+echo '  fi '
+echo '	@\$(RM) tmplist'
+echo '	@ls -1 | fgrep -v -f .patron  >tmplist'
+echo '	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \'
+echo '	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \'
+echo '	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \'
+echo '	echo "Rebuilding the AA_make files" ; \'
+echo '	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \'
+echo '	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \'
+echo '	echo "========================================== " ; \'
+echo '	../../util/ins_make ; echo " " ;  false ; exit ; }'
+exec > /dev/null
+
Index: /branches/DEV_r1837_MLF/UTIL/fait_config
===================================================================
--- /branches/DEV_r1837_MLF/UTIL/fait_config	(revision 1844)
+++ /branches/DEV_r1837_MLF/UTIL/fait_config	(revision 1844)
@@ -0,0 +1,171 @@
+#!/bin/ksh
+######################################################
+# Author : Rachid benshila for ESOPA
+# Contact : opatlod@lodyc.jussieu.fr
+#
+# This script aims to create the OPA/WORK directory 
+# with links to target directories for the sources
+# and to link in the WORK the BB_make and BB_make.ldef 
+# associated  to a chosen configuration
+#
+######################################################
+
+###################################
+#                                 #
+# Beginning of user modifications #
+#                                 #
+###################################
+#- Config name ---
+# To add a new configuration called NAME you have to change this script
+# 1. Add your configuration in LIST
+# 2. Add the directories needed for this config : set -A DIR_NAME DIR1 DIR2 ...
+# 3. Run fait_config NAME
+# If there is no directory config/NAME/scripts, and in this no BB_make.ldef, 
+# the config/ORCA2_LIM directory is copied under NAME
+#
+# Example 1 : in order to create a GYRE_TRC configuration :
+# 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nGYRE_TRC"
+# 2. In this script, add set -A DIR_GYRE_TRC OPA_SRC LIM_SRC_3 TOP_SRC C1D_SRC, take care of the syntax
+# 3. Run fait_config GYRE_TRC
+# Example 2 : in order to create an OFFLINE_TRC configuration :
+# 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nOFFLINE_TRC"
+# 2. In this script, add set -A DIR_OFFLINE_TRC OFF_SRC TOP_SRC, take care of the syntax
+# 3. Run fait_config OFFLINE_TRC
+# Example 2 : in order to use LIM3, just change LIM_SRC_2 in LIM_SRC_3
+
+LIST="ORCA2_LIM \nGYRE \nGYRE_LOBSTER \nORCA2_LIM_PISCES \nORCA2_OFF_PISCES \nPOMME \nIPSLCM5 \nIPSLCM5_LOOP"
+set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC_2 C1D_SRC NST_SRC
+set -A DIR_GYRE OPA_SRC LIM_SRC_2 C1D_SRC 
+set -A DIR_GYRE_LOBSTER OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+set -A DIR_ORCA2_LIM_PISCES OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC NST_SRC 
+set -A DIR_ORCA2_OFF_PISCES OFF_SRC TOP_SRC
+set -A DIR_POMME OPA_SRC LIM_SRC_2 C1D_SRC 
+set -A DIR_IPSLCM5 OPA_SRC LIM_SRC_2 C1D_SRC
+set -A DIR_IPSLCM5_LOOP OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+set -A DIR_IPSL_ESM_v2 OPA_SRC LIM_SRC_2 C1D_SRC
+
+###################################
+#                                 #
+#    End of user modifications    #
+#                                 #
+###################################
+
+
+#- Some tests ---
+d_n=$(dirname $0); b_n=$(basename $0);
+
+if   [ ${#} -gt 1 ]; then
+    echo 'Only one configuration can be specified in:' 1>&2;
+    echo $LIST 1>&2;
+    exit 3;
+elif [ ${#} -eq 1 ]; then
+     m_n="${1}"
+elif [ ${#} -eq 0 ]; then
+    echo 'You must specify one configuration in :' 1>&2;
+    echo $LIST 1>&2;
+    echo 'You can also complete fait_config to add a new one'
+    exit 3;
+fi
+
+#- Create the WORK --
+d_m=`find ${d_n}/.. -name NEMO`  ;
+[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK;
+cd ${d_m}/WORK
+
+#- Clean links and librairies
+[ -f Makefile ] && gmake clean 
+[ -n "`\ls`" ] && \rm -rf * 
+
+#- Find the number of directories ---
+eval NDIR=\${#DIR_${m_n}[*]}
+
+#- Build a working array TAB containing the directories ---
+i=0
+while [ i -lt $NDIR ]
+do
+    eval  TAB[i]=\${DIR_${m_n}[i]}
+    let i=i+1
+done
+
+#- Creating the good links, at first on OPA_SRC ---
+if [ ${#TAB[*]} -ne 0 ] ; then
+    echo " Creating NEMO/WORK = ${TAB[*]} for ${m_n}"
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*.[Ffh]90 .
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*/*.[Ffh]90 . && break
+	let i=$i+1
+    done
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+      if [ "${TAB[i]}" = "LIM_SRC_3" ]; then
+	  ln -sf ../LIM_SRC_3/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "LIM_SRC_2" ]; then
+	  ln -sf ../LIM_SRC_2/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "C1D_SRC" ]; then
+	  ln -sf ../C1D_SRC/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "TOP_SRC" ]; then
+	  ln -sf ../TOP_SRC/*.[Ffh]90 .       
+	  ln -sf ../TOP_SRC/*/*.[Ffh]90 .
+      
+      elif [ "${TAB[i]}" = "NST_SRC" ]; then
+	  [ -f  agrif_opa_interp.F90 ] && \rm agrif_opa_interp.F90                    
+	  [ -f  agrif_opa_sponge.F90 ] && \rm agrif_opa_sponge.F90                    
+	  [ -f  agrif_opa_update.F90 ] && \rm agrif_opa_update.F90                    
+	  [ -f  agrif_top_interp.F90 ] && \rm agrif_top_interp.F90                    
+	  [ -f  agrif_top_sponge.F90 ] && \rm agrif_top_sponge.F90                    
+	  [ -f  agrif_top_update.F90 ] && \rm agrif_top_update.F90                    
+	  ln -sf ../NST_SRC/*.[Ffh]90 .
+      
+      elif [ "${TAB[i]}" = "OFF_SRC" ]; then  
+	  ln -sf ../OFF_SRC/*.[Ffh]90 .
+	  ln -sf ../OFF_SRC/*/*.[Ffh]90 .
+      fi
+      let i=$i+1
+    done
+
+    [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/ORCA2_LIM ../../../config/${m_n} 
+    ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; 
+    ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ;
+
+else
+
+    echo "Configuration "${m_n}" not supported" 1>&2
+    echo 'Make your choice in :' 1>&2
+    echo $LIST 1>&2
+    echo 'You can also complete fait_config to add a new one'
+    exit 1
+
+fi 
+
+#- Building the standard list of source files ---
+cat >.patron <<"EOF" 
+CVS
+SRC_PARAM
+SRC_FILE_LIST
+tmplist
+AA_make
+KEY_CPP
+Makefile
+*?.o
+ i.?*
+*?.L
+.patron
+OPAFILES
+EOF
+ls -1 | fgrep -v -f .patron  >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ;
+
+#- Writing KEY_CPP file ---
+sed -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP;    
+
+#- Save new configuration an d directories names ---
+print ${m_n} ${TAB[*]} >.config 
+
+exit 0;
